Skip to content

Commit 77eacad

Browse files
committed
enable stripe
1 parent 154565d commit 77eacad

3 files changed

Lines changed: 12 additions & 17 deletions

File tree

examples/example_09_QRS_conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def plot_id_vs_energy(code, energies, match_ids=None, match_energies=None, out_d
171171
)
172172

173173
for code in db.get_all_codes():
174-
#if code not in ['ACSALA']: continue
175-
if code not in ['OBEQIX']: continue
174+
if code not in ['ACSALA']: continue
175+
#if code not in ['OBEQIX']: continue
176176
#if code not in ['XAFQON']: continue
177177
#if code not in ['NACJAF']: continue
178178
row = db.get_row(code=code)

pyxtal/optimize/base.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -991,38 +991,33 @@ def local_optimization_mproc(self, xtals, ncpu, ids=None, qrs=False, pool=None):
991991
if ids is None:
992992
ids = range(len(xtals))
993993

994-
N_cycle = int(np.ceil(len(xtals) / ncpu))
995-
# Generator to create arg_lists for multiprocessing tasks
994+
# Interleaved assignment: worker i handles indices i, i+ncpu, i+2*ncpu, …
995+
# so all workers stay busy and results can be sorted to 0,1,2,3… order.
996996
def generate_args_lists():
997997
for i in range(ncpu):
998-
id1 = i * N_cycle
999-
id2 = min([id1 + N_cycle, len(xtals)])
1000-
_ids = ids[id1: id2]
998+
_indices = list(range(i, len(xtals), ncpu))
999+
_ids = [ids[j] for j in _indices]
10011000
job_tags = [self.tag + "-g" + str(gen)
10021001
+ "-p" + str(id) for id in _ids]
1003-
_xtals = [xtals[id][0] for id in range(id1, id2)]
1002+
_xtals = [xtals[j][0] for j in _indices]
10041003
mutates = []
10051004
labels = []
1006-
for i in range(id1, id2):
1007-
orig_tag = xtals[i][1]
1005+
for j in _indices:
1006+
orig_tag = xtals[j][1]
10081007
if qrs:
10091008
mutates.append(False)
10101009
labels.append(orig_tag if orig_tag != "Random" else None)
10111010
else:
1012-
if orig_tag == "Mutation":
1013-
mutates.append(True)
1014-
else:
1015-
mutates.append(False)
1011+
mutates.append(orig_tag == "Mutation")
10161012
labels.append(None)
10171013
my_args = [_xtals, _ids, mutates, job_tags, labels, *args, self.rank, self.timeout]
1018-
yield tuple(my_args) # Yield args instead of appending to a list
1014+
yield tuple(my_args)
10191015

10201016
gen_results = []
10211017
for result in pool.imap_unordered(process_task, generate_args_lists()):
10221018
if result is not None:
10231019
for _res in result:
10241020
gen_results.append(_res)
1025-
10261021
return gen_results
10271022

10281023
def gen_summary(self, t0, gen_results, xtals):

pyxtal/optimize/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def optimizer_single(
662662
strs += f" {match:.3f}"
663663

664664
xtal.energy = eng
665-
print(f"{id:3d} " + strs)#; import sys; sys.exit()
665+
print(f"{id:3d} " + strs)
666666
return xtal, match, stable
667667
else:
668668
return None, match, stable

0 commit comments

Comments
 (0)