Skip to content

Commit

Permalink
enable ff opt function
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Nov 3, 2024
1 parent 8d6a496 commit 5d35ed9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 5 additions & 3 deletions pyxtal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4045,6 +4045,8 @@ def optimize_lattice_and_rotation(self, iterations=3, verbose=False):
"""
Iteratively cut lattice and optimize the rotation
"""
for i in range(iterations):
self.cut_lattice(2.0, verbose=verbose)
self.optimize_orientation_by_energy(20, verbose=verbose)
if self.molecular:
for i in range(iterations):
self.cut_lattice(2.0, verbose=verbose)
if self.molecules[0].active_sites is not None:
self.optimize_orientation_by_energy(20, verbose=verbose)
15 changes: 9 additions & 6 deletions pyxtal/optimize/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def __init__(
self.parameters = None
self.ff_opt = False
else:
self.ff_parameters = ff_parameters
self.reference_file = reference_file
self.ff_parameters = self.workdir + "/" + ff_parameters
self.reference_file = self.workdir + "/" + reference_file
# Only call ForceFieldParameters once
# No need to broadcast self.parameters?
# Just broadcast atom_info should be fine
Expand All @@ -236,7 +236,11 @@ def __init__(
if self.rank == 0:
from pyocse.parameters import ForceFieldParameters
self.parameters = ForceFieldParameters(
self.smiles, style=ff_style, f_coef=1.0, s_coef=1.0, ncpu=self.ncpu)
self.smiles, style=ff_style,
f_coef=1.0,
s_coef=1.0,
ref_evaluator='mace',
ncpu=self.ncpu)

# Preload two set for FF parameters 1 for opt and 2 for refinement
if isinstance(self.ff_parameters, list):
Expand Down Expand Up @@ -267,8 +271,7 @@ def __init__(
ff_style,
)
params0 = self.parameters.params_init.copy()
self.parameters.export_parameters(
self.workdir + "/" + self.ff_parameters, params0)
self.parameters.export_parameters(self.ff_parameters, params0)
atom_info = self._prepare_chm_info(
params0, suffix='pyxtal')

Expand Down Expand Up @@ -391,7 +394,7 @@ def select_xtals(self, ref_xtals, ids, N_max):
"""
xtals = []
for id in ids:
xtal = ref_xtals[id]
(xtal, _) = ref_xtals[id]
if xtal.energy <= self.E_max and self.new_struc(xtal, xtals):
xtals.append(xtal) # .to_ase(resort=False))
if len(xtals) == N_max:
Expand Down

0 comments on commit 5d35ed9

Please sign in to comment.