Skip to content
/ PyNEP Public
forked from bigd4/PyNEP

A python interface of NEP

License

Notifications You must be signed in to change notification settings

psn417/PyNEP

 
 

Repository files navigation

PyNEP

Documentation Status

PyNEP is a python interface of the machine learning potential NEP used in GPUMD.

Features

  • ase calculator of NEP
  • descriptor and latent descriptor calculation of atoms
  • load and dump for GPUMD dataset
  • phonopy calculation of NEP (need phonopy and spglib)
  • structures select
    • Farthest Point Sampling

Installation

Requirements

Package version
Python >= 3.8
NumPy < 1.22.0
SciPy >= 1.1
ase >= 3.18.0

By pip

$ pip install git+https://github.com/bigd4/PyNEP.git

By setup.py

$ git clone --recursive https://github.com/bigd4/PyNEP.git
$ cd PyNEP
$ python setup.py install

From Source

$ git clone --recursive https://github.com/bigd4/PyNEP.git
$ cd PyNEP/nep_cpu
$ mkdir build
$ cd build
$ cmake .. && make
$ cp nep.so ../../PyNEP

Add pynep to your PYTHONPATH environment variable in your ~/.bashrc file.

$ export PYTHONPATH=<path-to-pynep-package>:$PYTHONPATH

File format conversion

#For an example of a randomly split training datasets: examples/shuf_xyz.py

# NEP to exyz
train_data = load_nep("train.in", ftype="nep")
dump_nep("train.xyz", train_data, ftype="exyz")

# exyz to NEP
train_data = load_nep("train.xyz", ftype="exyz")
dump_nep("train.in", train_data, ftype="nep")

Usage

from ase.build import bulk
atoms = bulk('C', 'diamond', cubic=True)

# calculate energy and forces
from pynep.calculate import NEP
calc = NEP('nep.txt')
atoms = bulk('C', 'diamond', cubic=True)
atoms.set_calculator(calc)
energy = atoms.get_potential_energy()
forces = atoms.get_forces()
stress = atoms.get_stress()  # stress in ase is different from virial in GPUMD

# calculate descriptors and latent descriptors
des = calc.get_property('descriptor', atoms)
lat = calc.get_property('latent', atoms)

# load and dump GPUMD data
from pynep.io import load_nep, dump_nep
dump_nep('C.in', [atoms])
atoms = load_nep('C.in')[0]

# calculate band strucuture, dos and thermal properties (need spglib and phonopy)
from pynep.phono import PhonoCalc
phono_calc = PhonoCalc(calc)
phono_calc.calculate(atoms)

About

A python interface of NEP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.1%
  • Python 2.8%
  • Other 0.1%