@@ -59,27 +59,17 @@ def compute_ensemble(
5959 if self .force_computed is None :
6060 self .force_computed = np .array ([False ] * self .N , dtype = bool )
6161
62- n_calcs = np .sum (self .force_computed .astype (int ))
63- computing_ensemble = self
64-
6562 self .has_stress = True # by default we calculate stresses with the `get_builder_from_protocol`
6663 if overrides :
6764 try :
6865 tstress = overrides ['pw' ]['parameters' ]['CONTROL' ]['tstress' ]
6966 self .has_stress = tstress
7067 except KeyError :
7168 pass
72-
73- # Check wheter compute the whole ensemble, or just a small part
74- should_i_merge = False
75- if n_calcs != self .N :
76- should_i_merge = True
77- computing_ensemble = self .get_noncomputed ()
78- self .remove_noncomputed ()
7969
8070 # ============= AIIDA SECTION ============= #
8171 workchains = submit_and_get_workchains (
82- structures = computing_ensemble .structures ,
72+ structures = self .structures ,
8373 pw_code = pw_code ,
8474 temperature = self .current_T ,
8575 protocol = protocol ,
@@ -93,28 +83,33 @@ def compute_ensemble(
9383
9484 workchains_copy = copy (workchains )
9585 while (workchains_copy ):
96- workchains_copy = get_running_workchains (workchains_copy , computing_ensemble .force_computed )
86+ workchains_copy = get_running_workchains (workchains_copy , self .force_computed )
9787 if workchains_copy :
9888 time .sleep (60 ) # wait before checking again
9989
100- for i , is_computed in enumerate (computing_ensemble .force_computed ):
90+ for i , is_computed in enumerate (self .force_computed ):
10191 if is_computed :
10292 out = workchains [i ].outputs
103- computing_ensemble .energies [i ] = out .output_parameters .dict .energy / CONSTANTS .ry_to_ev
104- computing_ensemble .forces [i ] = out .output_trajectory .get_array ('forces' )[- 1 ] / CONSTANTS .ry_to_ev
93+ self .energies [i ] = out .output_parameters .dict .energy / CONSTANTS .ry_to_ev
94+ self .forces [i ] = out .output_trajectory .get_array ('forces' )[- 1 ] / CONSTANTS .ry_to_ev
10595 if self .has_stress :
106- computing_ensemble .stresses [i ] = out .output_trajectory .get_array ('stress' )[- 1 ] * gpa_to_rybohr3
96+ self .stresses [i ] = out .output_trajectory .get_array ('stress' )[- 1 ] * gpa_to_rybohr3
10797 # ============= AIIDA SECTION ============= #
10898
10999 if self .has_stress :
110- computing_ensemble .stress_computed = copy (computing_ensemble .force_computed )
100+ self .stress_computed = copy (self .force_computed )
111101
112- print ( "CE BEFORE MERGE:" , len ( self .force_computed ) )
102+ self ._clean_runs ( )
113103
114- if should_i_merge :
115- # Remove the noncomputed ensemble from here, and merge
116- self .merge (computing_ensemble )
117- print ("CE AFTER MERGE:" , len (self .force_computed ))
104+ def _clean_runs (self ) -> None :
105+ """Clean the failed runs and print summary."""
106+ n_calcs = np .sum (self .force_computed .astype (int ))
107+ print ('=============== SUMMARY AIIDA CALCULATIONS =============== \n ' )
108+ print ('Total structures included: ' , n_calcs )
109+ print ('Structures not included : ' , self .N - n_calcs , '\n ' )
110+ print ('===================== END OF SUMMARY ===================== \n ' )
111+ if n_calcs != self .N :
112+ self .remove_noncomputed ()
118113
119114
120115def get_running_workchains (workchains : list , success : list [bool ]) -> list :
0 commit comments