@@ -502,7 +502,7 @@ def init(self):
502502
503503
504504
505- def load (self , data_dir , population , N , verbose = False , load_displacements = True , raise_error_on_not_found = False , load_noncomputed_ensemble = False ,
505+ def load (self , data_dir , population , N , verbose = False , load_displacements = True , raise_error_on_not_found = False , load_noncomputed_ensemble = False , skip_extra_rows = False ,
506506 timer = None ):
507507 """
508508 LOAD THE ENSEMBLE
@@ -554,6 +554,9 @@ def load(self, data_dir, population, N, verbose = False, load_displacements = Tr
554554 load_noncomputed_ensemble: bool
555555 If True, it allows for loading an ensemble where some of the configurations forces and stresses are missing.
556556 Note that it must be compleated before running a SCHA minimization
557+ skip_extra_rows : bool
558+ If True, only loads the first Nat_sc rows of the forces.
559+ Useful if the parsing script reads more than the necessary rows from the calculation output.
557560 """
558561 A_TO_BOHR = 1.889725989
559562
@@ -599,6 +602,12 @@ def load(self, data_dir, population, N, verbose = False, load_displacements = Tr
599602 total_t_for_loading = 0
600603 total_t_for_sscha_ef = 0
601604 t_before_for = time .time ()
605+
606+ # Avoid reading extra rows on the forces
607+ maxrowforces = None
608+ if skip_extra_rows :
609+ maxrowforces = Nat_sc
610+
602611 for i in range (self .N ):
603612 # Load the structure
604613 structure = CC .Structure .Structure ()
@@ -636,10 +645,11 @@ def load(self, data_dir, population, N, verbose = False, load_displacements = Tr
636645 force_path = os .path .join (data_dir , "forces_population%d_%d.dat" % (population , i + 1 ))
637646
638647 if os .path .exists (force_path ):
648+
639649 if timer :
640- self .forces [i ,:,:] = timer .execute_timed_function (np .loadtxt , force_path ) * A_TO_BOHR
650+ self .forces [i ,:,:] = timer .execute_timed_function (np .loadtxt , force_path , max_rows = maxrowforces ) * A_TO_BOHR
641651 else :
642- self .forces [i ,:,:] = np .loadtxt (force_path ) * A_TO_BOHR
652+ self .forces [i ,:,:] = np .loadtxt (force_path , max_rows = maxrowforces ) * A_TO_BOHR
643653 self .force_computed [i ] = True
644654 else :
645655 if raise_error_on_not_found :
0 commit comments