@@ -532,10 +532,14 @@ def prepare_input_file(self, structure, calc, label):
532532 """
533533
534534 # Prepare the input file
535- atm = structure .get_ase_atoms ()
536- atm .set_calculator (calc )
537- ase .io .write ("%s/%s.pwi" % (self .local_workdir , label ),
538- atm , ** calc .parameters )
535+ calc .set_directory (self .local_workdir )
536+ calc .set_label (label )
537+ calc .write_input (structure )
538+
539+ print ("LBL: {} | PREFIX: {}" .format (label , calc .input_data ["control" ]["prefix" ]))
540+
541+ #ase.io.write("%s/%s.pwi"% (self.local_workdir, label),
542+ # atm, **calc.parameters)
539543
540544
541545
@@ -603,6 +607,25 @@ def submit(self, script_location):
603607
604608 return self .ExecuteCMD (cmd , True , return_output = True )
605609
610+ def get_output_path (self , label ):
611+ """
612+ Given the label of the submission, retrive the path of all the output files of that calculation
613+ """
614+
615+ out_filename = os .path .join (self .workdir , label + ".pwo" )
616+ return [out_filename ]
617+
618+ def read_results (self , calc , label ):
619+ """
620+ Return a dictionary of the computed property for the given calculation label
621+ """
622+
623+ #calc.set_label("%s/%s" % (self.local_workdir, label))
624+ calc .set_directory (self .local_workdir )
625+ calc .set_label (label )
626+ calc .read_results ()
627+ return copy .deepcopy (calc .results )
628+
606629 def batch_submission (self , list_of_structures , calc , indices ,
607630 in_extension , out_extension ,
608631 label = "ESP" , n_togheder = 1 ):
@@ -722,24 +745,24 @@ def batch_submission(self, list_of_structures, calc, indices,
722745 for i in submitted :
723746 # Prepare a typical label
724747 lbl = label + "_" + str (indices [i ])
725- out_filename = "%s/%s%s" % (self .workdir , lbl , out_extension )
748+ out_fnames = self .get_output_path (lbl )
749+ #out_filename = "%s/%s%s"% (self.workdir, lbl, out_extension)
726750
727- # Get the response
728- cmd = self .scpcmd + " %s:%s %s/" % (self .hostname , out_filename ,
729- self .local_workdir )
730- cp_res = self .ExecuteCMD (cmd , False )
731- #cp_res = os.system(cmd + " > /dev/null")
732- if not cp_res :
733- #print "Error while executing:", cmd
734- #print "Return code:", cp_res
735- #sys.stderr.write(cmd + ": exit with code " + str(cp_res))
736- continue
751+ for out in out_fnames :
752+ # Get the response
753+ cmd = self .scpcmd + " %s:%s %s/" % (self .hostname , out ,
754+ self .local_workdir )
755+ cp_res = self .ExecuteCMD (cmd , False )
756+ #cp_res = os.system(cmd + " > /dev/null")
757+ if not cp_res :
758+ #print "Error while executing:", cmd
759+ #print "Return code:", cp_res
760+ #sys.stderr.write(cmd + ": exit with code " + str(cp_res))
761+ continue
737762
738763 # Get the results
739764 try :
740- calc .set_label ("%s/%s" % (self .local_workdir , lbl ))
741- calc .read_results ()
742- results [i ] = copy .deepcopy (calc .results )
765+ results [i ] = self .read_results (calc , lbl )
743766 except :
744767 pass
745768
@@ -1208,6 +1231,7 @@ def compute_ensemble_batch(self, ensemble, ase_calc, get_stress = True, timeout=
12081231
12091232 # Setup if the ensemble has the stress
12101233 ensemble .has_stress = get_stress
1234+ ensemble .all_properties = [None ] * ensemble .N
12111235
12121236 # Check if the working directory exists
12131237 if not os .path .isdir (self .local_workdir ):
@@ -1225,15 +1249,14 @@ def compute_single_jobarray(jobs_id, calc):
12251249
12261250 for i , res in enumerate (results ):
12271251 num = jobs_id [i ]
1252+
1253+ if res is None :
1254+ continue
12281255
12291256 # Check if the run was good
1230- try :
1231- resk = res .keys ()
1232- except :
1233- continue
1234- check_e = "energy" in resk
1235- check_f = "forces" in resk
1236- check_s = "stress" in resk
1257+ check_e = "energy" in res
1258+ check_f = "forces" in res
1259+ check_s = "stress" in res
12371260
12381261 is_success = check_e and check_f
12391262 if get_stress :
@@ -1242,6 +1265,7 @@ def compute_single_jobarray(jobs_id, calc):
12421265 if not is_success :
12431266 continue
12441267
1268+ ensemble .all_properties [num ] = copy .deepcopy (res )
12451269 ensemble .energies [num ] = res ["energy" ] / units ["Ry" ]
12461270 ensemble .forces [num , :, :] = res ["forces" ] / units ["Ry" ]
12471271 if get_stress :
0 commit comments