Skip to main content

Potential Energy Surfaces on Graphs

Project description

graph-pes - Potential Energy Surfaces on Graphs

graph-pes is a Python framework for training Potential Energy Surface (PES) models that operate on graph representations of atomic structures. Under-the-hood, this relies on Pytorch/Geometric for efficient tensor operations.

Batteries are included:

  • easy data manipulations : see docs relating to AtomicGraph, intuitive batching, easy conversion from ase etc.
  • easy construction of PES models : implement predict_local_energies , easy to save, load and share
  • useful primitives : PerSpeciesParameter
  • easy training : forces, energies, well conditioned losses etc.

Installation

pip install graph-pes

Minimal example

from graph_pes import GraphPESModel
from graph_pes.data import convert_to_graphs, AtomicGraph
from graph_pes.training import train_model
from ase.io import read
import torch

# 1. define a model
class LennardJones(GraphPES):
    def __init__(self):
        super().__init__()
        self.sigma = nn.Parameter(torch.tensor(1.0))
        self.epsilon = nn.Parameter(torch.tensor(1.0))

    def predict_local_energies(self, graph: AtomicGraph) -> torch.Tensor:
        central_atoms, neighbours = graph.neighbour_index
        distances = graph.neighbour_distances
        
        # calculate pairwise interactions
        x = (self.sigma / distances)**6
        pairwise_interaction = 4 * self.epsilon * (x**2 - x)

        # sum over neighbours to get per-atom contributions
        return torch.scatter_add(
            torch.zeros(graph.n_atoms, device=graph.device),
            central_atoms,
            pairwise_interaction
        )

# 2. load some structures
structures = read('structures.xyz', index=':10')

# 3. convert to graphs (e.g. using a radius cutoff)
graphs = convert_to_graphs(structures, cutoff=5.0)

# 4. train the model
model = LennardJones()
train_model(model, graphs, max_epochs=100)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph-pes-0.0.0.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

graph_pes-0.0.0-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file graph-pes-0.0.0.tar.gz.

File metadata

  • Download URL: graph-pes-0.0.0.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for graph-pes-0.0.0.tar.gz
Algorithm Hash digest
SHA256 6dfc6e7df91b6ef3ca3c9a5cb60b100d8385ee3a7271a333933e1fc24a8d060a
MD5 e4089ce8aa3dd47ff9e4d25fa4db44cb
BLAKE2b-256 f387d475def87e30daed24a8a781aceb432e3106716e04be55b77979b86167a7

See more details on using hashes here.

File details

Details for the file graph_pes-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: graph_pes-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for graph_pes-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 330290a61f9512dba78189cc228a16aba3d3da8af718750e81a06607b96efbb6
MD5 a7edcf3e6e723c579548b957ba415ff8
BLAKE2b-256 54a73eeb53cfe2b0d4b554bc47bb28503c5b558e4057a9df6fb5d837a793e11c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page