From 815a84cd869885561534fefd80700400cfcb2f1d Mon Sep 17 00:00:00 2001 From: qzhu2017 Date: Tue, 15 Oct 2024 11:03:56 -0400 Subject: [PATCH] update rep discrete --- pyxtal/lego/builder.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pyxtal/lego/builder.py b/pyxtal/lego/builder.py index 533587a1..c7e1d160 100644 --- a/pyxtal/lego/builder.py +++ b/pyxtal/lego/builder.py @@ -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 @@ -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. @@ -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: @@ -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. @@ -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))