Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update rep discrete #287

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pyxtal/lego/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ def optimize_reps(self, reps, ncpu=1, opt_type='local',
T=0.2, niter=20, early_quit=0.02,
add_db=True, symmetrize=False,
minimizers=[('Nelder-Mead', 100), ('L-BFGS-B', 100)],
discrete=False):
N_grids=None):
"""
Perform optimization for each structure

Expand All @@ -884,12 +884,12 @@ def optimize_reps(self, reps, ncpu=1, opt_type='local',
"""
args = (opt_type, T, niter, early_quit, add_db, symmetrize, minimizers)
if ncpu == 1:
valid_xtals = self.optimize_reps_serial(reps, args, discrete)
valid_xtals = self.optimize_reps_serial(reps, args, N_grids)
else:
valid_xtals = self.optimize_reps_mproc(reps, ncpu, args, discrete)
valid_xtals = self.optimize_reps_mproc(reps, ncpu, args, N_grids)
return valid_xtals

def optimize_reps_serial(self, reps, args, discrete):
def optimize_reps_serial(self, reps, args, N_grids):
"""
Optimization in multiprocess mode.

Expand All @@ -904,7 +904,7 @@ def optimize_reps_serial(self, reps, args, discrete):
xtal = pyxtal()
xtal.from_tabular_representation(rep,
normalize=False,
discrete=discrete)
discrete=N_grids)
#verbose=True)
xtal, sim, _xs = self.optimize_xtal(xtal, i, *args)
if xtal is not None:
Expand All @@ -913,7 +913,7 @@ def optimize_reps_serial(self, reps, args, discrete):
# print("Debug===="); import sys; sys.exit()
return xtals_opt

def optimize_reps_mproc(self, reps, ncpu, args, discrete):
def optimize_reps_mproc(self, reps, ncpu, args, N_grids):
"""
Optimization in multiprocess mode.

Expand Down Expand Up @@ -946,9 +946,11 @@ def generate_args():
for id in _ids:
rep = reps[id]
xtal = pyxtal()
discrete = False if N_grids is None else True
xtal.from_tabular_representation(rep,
normalize=False,
discrete=discrete)
discrete=discrete,
N_grids=N_grids)
x = xtal.get_1d_rep_x()
spg, wps, _ = self.get_input_from_ref_xtal(xtal)
wp_libs.append((x, spg, wps))
Expand Down