Skip to content

Commit 307e0c4

Browse files
committed
Fixed an error
1 parent 6764e37 commit 307e0c4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Modules/Ensemble.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ def load(self, data_dir, population, N, verbose = False, load_displacements = Tr
416416
# Initialize the computation of energy and forces
417417
self.force_computed = np.zeros( self.N, dtype = bool)
418418
self.stress_computed = np.zeros(self.N, dtype = bool)
419+
self.all_properties = [None] * self.N
419420

420421
# Add a counter to check if all the stress tensors are present
421422
count_stress = 0
@@ -1895,23 +1896,23 @@ def get_fc_from_self_consistency(self, subtract_sscha = False, return_error = Fa
18951896

18961897
return new_phi
18971898

1898-
def get_preconditioned_gradient_parallel(self, *args, **kwargs):
1899+
def get_preconditioned_gradient_parallel(self, *args, timer=None, **kwargs):
18991900
"""
19001901
Compute the gradient using multiprocessing.
19011902
For documentation, see get_preconditioned_gradient
19021903
"""
19031904

19041905
print("force length:", len(self.force_computed))
19051906

1906-
def work_function(argument):
1907+
def work_function(argument, timer=None):
19071908
print("force length [inside]:", len(self.force_computed))
19081909
ensemble_start_config, ensemble_end_config = argument
19091910
mask = np.zeros(self.N, dtype = bool)
19101911
mask[ensemble_start_config : ensemble_end_config] = True
19111912
print("mask length:", np.sum(mask.astype(int))," total N:", len(mask))
19121913
new_ensemble = self.split(mask)
19131914

1914-
gradient, _ = new_ensemble.get_preconditioned_gradient(*args, **kwargs)
1915+
gradient, _ = new_ensemble.get_preconditioned_gradient(*args, timer=timer, **kwargs)
19151916

19161917
av_ensemble = np.sum(new_ensemble.rho)
19171918

@@ -1929,7 +1930,11 @@ def work_function(argument):
19291930

19301931
list_of_inputs.append( (start_config, end_config) )
19311932

1932-
gradient = CC.Settings.GoParallel(work_function, list_of_inputs, "+")
1933+
if timer:
1934+
gradient = timer.execute_timed_function(CC.Settings.GoParallel, work_function, list_of_inputs, "+")
1935+
else:
1936+
gradient = CC.Settings.GoParallel(work_function, list_of_inputs, "+")
1937+
19331938
gradient /= np.sum(self.rho)
19341939

19351940
return gradient, np.zeros_like(gradient) + 1

0 commit comments

Comments
 (0)