From 13fa49837182b4428f6b36acf812798d5e21620b Mon Sep 17 00:00:00 2001 From: qzhu2017 Date: Sat, 10 Feb 2024 23:43:06 -0500 Subject: [PATCH] update the function of get_forcefield --- doc/Installation.rst | 2 +- pyxtal/__init__.py | 7 ++++++- requirements.txt | 1 + scripts/pyxtal_main.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/Installation.rst b/doc/Installation.rst index fffeec17..ee0c371b 100644 --- a/doc/Installation.rst +++ b/doc/Installation.rst @@ -53,7 +53,7 @@ or make a copy of the source code, and then install it manually. $ git clone https://github.com/qzhu2017/pyxtal $ cd pyxtal - $ python setup.py install + $ pip install . or update the code to our developing version diff --git a/pyxtal/__init__.py b/pyxtal/__init__.py index c48612a0..15ec4cf3 100644 --- a/pyxtal/__init__.py +++ b/pyxtal/__init__.py @@ -3002,7 +3002,7 @@ def to_atomic_xtal(self): def get_forcefield(self, ff_style='openff', code='lammps', - chargemethod='am1bcc'): + chargemethod='am1bcc', parameters=None): """ An interface to create forcefield for molecular simulation with - Charmm @@ -3014,6 +3014,7 @@ def get_forcefield(self, ff_style='openff', code='lammps', - ff_style: 'gaff' or 'openff' - code: 'lammps' or 'charmm' - charge_method: 'am1bcc', 'am1-mulliken', 'mmff94', 'gasteiger' + - parameters: 1D-array of user-specified FF parameters Returns: An ase_atoms_objects with force field information @@ -3055,6 +3056,10 @@ def get_forcefield(self, ff_style='openff', code='lammps', # Initialize the forcefield instance from ost ff = forcefield(smiles, style=ff_style, chargemethod=chargemethod) + # update the parameters from the user + if parameters is not None: + ff.update_parameters(parameters) + # Create the Parmed to handle FF parameters if sum(n_mols) == 1: pd_struc = ff.molecules[0].copy(cls=ParmEdStructure) diff --git a/requirements.txt b/requirements.txt index 952858f6..39212b15 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ networkx>=2.3 scipy>=1.7.3 importlib_metadata>=1.4 ase>=3.18.0 +monty==2023.11.3 diff --git a/scripts/pyxtal_main.py b/scripts/pyxtal_main.py index 10f8678a..704fcd2d 100755 --- a/scripts/pyxtal_main.py +++ b/scripts/pyxtal_main.py @@ -140,7 +140,7 @@ rand_crystal.from_random(3, sg, system, numIons0, factor, conventional=conventional) elif dimension == 2: rand_crystal.from_random(2, sg, system, numIons0, factor, thickness, conventional=conventional) - elif dimension == 1: + elif dimension == 1: rand_crystal.from_random(1, sg, system, numIons0, factor, thickness, conventional=conventional) if dimension == 0: rand_crystal.from_random(0, sg, system, numIons0, factor)