Skip to main content

A brief description of the shape library

Project description

Reformpy

A Python package for Rational Exploration of Fingerprint-Oriented Relaxation Methodology

Implemented in Python3

Dependencies

  • Python >= 3.8.5
  • Numpy >= 1.21.4
  • Scipy >= 1.8.0
  • Numba >= 0.56.2
  • ASE >= 3.22.1
  • libfp >= 3.2.1

Setup

To install the C implementation of Fingerprint Library
First, you need create a conda environment:

conda create -n fplibenv python=3.8 pip ; conda activate fplibenv
python3 -m pip install -U pip setuptools wheel

Then use conda to install LAPACK:

conda install conda-forge::lapack

Next, you need to download the fplib using git:

git clone https://github.com/Rutgers-ZRG/fplib.git

and modify the setup.py in fplib/fppy:

lapack_dir=["$CONDA_PREFIX/lib"]
lapack_lib=['openblas']
extra_link_args = ["-Wl,-rpath,$CONDA_PREFIX/lib"]
.
.
.
include_dirs = [source_dir, "$CONDA_PREFIX/include"]

Also set the corresponding DYLD_LIBRARY_PATH in your .bashrc file as:

export DYLD_LIBRARY_PATH="$CONDA_PREFIX/lib:$DYLD_LIBRARY_PATH"

Then:

cd fplib/fppy/ ; python3 -m pip install -e .

Then install the remaining Python packages through pip

python3 -m pip install numpy>=1.21.4 scipy>=1.8.0 numba>=0.56.2 ase==3.22.1

Usage

Basic ASE style documentation

See details for ASE calculator class and ASE calculator proposal

    Fingerprint Calculator interface for ASE
    
        Implemented Properties:
        
            'energy': Sum of atomic fingerprint distance (L2 norm of two atomic 
                                                          fingerprint vectors)
            
            'forces': Gradient of fingerprint energy, using Hellmann–Feynman theorem
            
            'stress': Cauchy stress tensor using finite difference method
            
        Parameters:
        
            atoms:  object
                Attach an atoms object to the calculator.
                
            contract: bool
                Calculate fingerprint vector in contracted Guassian-type orbitals or not
            
            ntype: int
                Number of different types of atoms in unit cell
            
            nx: int
                Maximum number of atoms in the sphere with cutoff radius for specific cell site
                
            lmax: int
                Integer to control whether using s orbitals only or both s and p orbitals for 
                calculating the Guassian overlap matrix (0 for s orbitals only, other integers
                will indicate that using both s and p orbitals)
                
            cutoff: float
                Cutoff radius for f_c(r) (smooth cutoff function) [amp], unit in Angstroms
                

Calling fplib3 calculator from ASE API

import numpy as np
import ase.io
from ase.optimize import BFGS, LBFGS, BFGSLineSearch, QuasiNewton, FIRE
from ase.optimize.sciopt import SciPyFminBFGS, SciPyFminCG
from ase.constraints import StrainFilter, UnitCellFilter
from ase.io.trajectory import Trajectory

from fplib3_api4ase import fp_GD_Calculator
# from fplib3_mixing import MixedCalculator
# from ase.calculators.mixing import MixedCalculator
# from ase.calculators.vasp import Vasp

atoms = ase.io.read('.'+'/'+'POSCAR')
ase.io.vasp.write_vasp('input.vasp', atoms, direct=True)
trajfile = 'opt.traj'

from functools import reduce

chem_nums = list(atoms.numbers)
znucl_list = reduce(lambda re, x: re+[x] if x not in re else re, chem_nums, [])
ntyp = len(znucl_list)
znucl = np.array(znucl_list, int)

calc = fp_GD_Calculator(
            cutoff = 6.0,
            contract = False,
            znucl = znucl,
            lmax = 0,
            nx = 300,
            ntyp = ntyp
            )

atoms.calc = calc

# calc.test_energy_consistency(atoms = atoms)
# calc.test_force_consistency(atoms = atoms)

print ("fp_energy:\n", atoms.get_potential_energy())
print ("fp_forces:\n", atoms.get_forces())
print ("fp_stress:\n", atoms.get_stress())

# af = atoms
# af = StrainFilter(atoms)
af = UnitCellFilter(atoms, scalar_pressure = 0.0)

############################## Relaxation method ##############################

# opt = BFGS(af, maxstep = 1.e-1, trajectory = trajfile)
opt = FIRE(af, maxstep = 1.e-1, trajectory = trajfile)
# opt = LBFGS(af, maxstep = 1.e-1, trajectory = trajfile, memory = 10, use_line_search = True)
# opt = LBFGS(af, maxstep = 1.e-1, trajectory = trajfile, memory = 10, use_line_search = False)
# opt = SciPyFminCG(af, maxstep = 1.e-1, trajectory = trajfile)
# opt = SciPyFminBFGS(af, maxstep = 1.e-1, trajectory = trajfile)

opt.run(fmax = 1.e-5)

traj = Trajectory(trajfile)
ase.io.write('opt.vasp', traj[-1], direct = True, long_format=True, vasp5 = True)

Citation

If you use this Fingerprint Library (or modified version) for your research please kindly cite our paper:

@article{taoAcceleratingStructuralOptimization2024,
  title = {Accelerating Structural Optimization through Fingerprinting Space Integration on the Potential Energy Surface},
  author = {Tao, Shuo and Shao, Xuecheng and Zhu, Li},
  year = {2024},
  month = mar,
  journal = {J. Phys. Chem. Lett.},
  volume = {15},
  number = {11},
  pages = {3185--3190},
  doi = {10.1021/acs.jpclett.4c00275},
  url = {https://pubs.acs.org/doi/10.1021/acs.jpclett.4c00275}
}

If you use Fingerprint distance as a metric to measure crystal similarity please also cite the following paper:

@article{zhuFingerprintBasedMetric2016,
  title = {A Fingerprint Based Metric for Measuring Similarities of Crystalline Structures},
  author = {Zhu, Li and Amsler, Maximilian and Fuhrer, Tobias and Schaefer, Bastian and Faraji, Somayeh and Rostami, Samare and Ghasemi, S. Alireza and Sadeghi, Ali and Grauzinyte, Migle and Wolverton, Chris and Goedecker, Stefan},
  year = {2016},
  month = jan,
  journal = {The Journal of Chemical Physics},
  volume = {144},
  number = {3},
  pages = {034203},
  doi = {10.1063/1.4940026},
  url = {https://doi.org/10.1063/1.4940026}
}

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

reformpy-1.2.0.tar.gz (45.4 kB view details)

Uploaded Source

Built Distribution

reformpy-1.2.0-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file reformpy-1.2.0.tar.gz.

File metadata

  • Download URL: reformpy-1.2.0.tar.gz
  • Upload date:
  • Size: 45.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for reformpy-1.2.0.tar.gz
Algorithm Hash digest
SHA256 843dcdfe5e57daee152ecf4d5e0b9bc50c7042acddea708e41d2c3b93afcfb7a
MD5 b3770991ce19b4e1e1e707277c0df77b
BLAKE2b-256 96b602cf3291ac9abb722d184c93e4ba83b87db938a10ef6cc1c5765fd20e0cf

See more details on using hashes here.

File details

Details for the file reformpy-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: reformpy-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 50.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for reformpy-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ea165c00367736bc6b55681d8b25e32afa6f2d15174392ae18c1973ea71a3e4
MD5 5d9845d12ac2735be514ee7611ca5648
BLAKE2b-256 be6bce6518c05bc542f2ad94a77153f3df8eb073d4f928892778afec35d2e2e3

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