diff --git a/pyxtal/optimize/base.py b/pyxtal/optimize/base.py index c272aca..c6a029e 100644 --- a/pyxtal/optimize/base.py +++ b/pyxtal/optimize/base.py @@ -50,26 +50,26 @@ def handler(signum, frame): # Set the timeout signal cwd = os.getcwd() timeout = int(args[-1]) - logger.info(f"Rank-{args[-2]} entering optimizer_with_timeout") + #logger.info(f"Rank-{args[-2]} entering optimizer_with_timeout") signal.signal(signal.SIGALRM, handler) signal.alarm(timeout) - logger.info(f"Rank-{args[-2]} after signal") + #logger.info(f"Rank-{args[-2]} after signal") try: logger.info(f"Rank-{args[-2]} running optimizer_par for PID {os.getpid()}") result = optimizer_par(*args[:-2]) - logger.info(f"Rank-{args[-2]} finished optimizer_par for PID {os.getpid()} successfully") + logger.info(f"Rank-{args[-2]} finished optimizer_par for PID {os.getpid()}") signal.alarm(0) # Disable the alarm return result except TimeoutError: - logger.info(f"Rank-{args[-1]} Process {os.getpid()} timed out after {timeout} seconds.") + logger.info(f"Rank-{args[-2]} Process {os.getpid()} timed out after {timeout} seconds.") os.chdir(cwd) return None # or some other placeholder for timeout results # Update process_task to accept a logger def process_task(args): logger = logging.getLogger() - logger.info(f"Rank {args[-2]} start process_task.") + #logger.info(f"Rank {args[-2]} start process_task.") result = run_optimizer_with_timeout(args, logger) return result @@ -786,7 +786,8 @@ def print_matches(self, header=None): matches = sorted( self.matches, key=lambda x: -x[4]) # similarity else: - matches = sorted(self.matches, key=lambda x: x[4]) # rmsd + print(self.matches) + matches = sorted(self.matches, key=lambda x: x[3]) # eng for match_data in matches: d1, match = None, None @@ -813,7 +814,7 @@ def print_matches(self, header=None): if e is not None: rank = len(all_engs[all_engs < (e - 1e-3)]) + 1 - strs += f"{rank:d}/{self.N_struc:d} {tag:s}" + strs += f" {rank:d}/{self.N_struc:d} {tag:s}" ranks.append(rank) print(strs) @@ -1084,11 +1085,10 @@ def generate_args_lists(): + "-p" + str(id) for id in _ids] _xtals = [xtals[id][0] for id in range(id1, id2)] mutates = [False if qrs else xtal is not None for xtal in _xtals] - my_args = [_xtals, _ids, mutates, job_tags, *args, self.timeout] + my_args = [_xtals, _ids, mutates, job_tags, *args, self.rank, self.timeout] yield tuple(my_args) # Yield args instead of appending to a list gen_results = [] - #for result in pool.imap_unordered(process_task, args_lists): for result in pool.imap_unordered(process_task, generate_args_lists()): if result is not None: for _res in result: diff --git a/pyxtal/optimize/common.py b/pyxtal/optimize/common.py index 83c36e3..c7b95d7 100644 --- a/pyxtal/optimize/common.py +++ b/pyxtal/optimize/common.py @@ -368,6 +368,7 @@ def optimizer_par( use_hall, skip_ani, check_stable, + pre_opt, ): """ A routine used for parallel structure optimization @@ -406,6 +407,7 @@ def optimizer_par( use_hall, skip_ani, check_stable, + pre_opt, ) results.append((id, xtal, match)) return results