SevenNet (sevenn)

0.12.1 · active · verified Thu Apr 16

SevenNet is a Python library implementing Scalable EquiVariance Enabled Neural Networks, primarily for atomistic simulations and materials science. It integrates with the Atomic Simulation Environment (ASE) for molecular dynamics, energy, and force calculations. The library is actively developed, with frequent minor releases and specific checkpoint releases for new pre-trained models. The current stable version is 0.12.1.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `SevenNetCalculator` to compute energy, forces, and stress for an ASE `Atoms` object using a pre-trained SevenNet model. Ensure you have a model checkpoint available locally.

import os
import numpy as np
from ase.build import bulk
from sevenn.calculator import SevenNetCalculator

# Assuming a pre-trained model checkpoint path
# Replace with your actual model path or a path to a downloaded checkpoint
# Example: sevenn_cp download 'SevenNet-Omni-i8' will download to current dir
MODEL_PATH = os.environ.get('SEVENN_MODEL_PATH', 'SevenNet-Omni-i8.ckpt')

# Create an ASE atom object
atoms = bulk('Si', 'diamond', a=5.43, cubic=True)
atoms.set_positions(atoms.get_positions() + np.random.rand(*atoms.get_positions().shape) * 0.1)

# Initialize the SevenNetCalculator
calculator = SevenNetCalculator(
    path=MODEL_PATH,
    device='cuda' if os.environ.get('SEVENN_USE_CUDA', 'false').lower() == 'true' else 'cpu'
)
atoms.set_calculator(calculator)

# Get energy and forces
energy = atoms.get_potential_energy()
forces = atoms.get_forces()
stress = atoms.get_stress()

print(f"Energy: {energy:.4f} eV")
print(f"Forces (first atom): {forces[0]}")
print(f"Stress: {stress}")

# Clean up (optional, if you're done with the calculator)
calculator.cleanup()

view raw JSON →