@@ -149,25 +149,32 @@ def write_input(self, conformer, ase_calculator):
149149 """
150150
151151 ase_calculator .write_input (conformer .ase_molecule )
152- try :
153- os . makedirs ( ase_calculator . scratch )
154- except OSError :
155- pass
152+ scratch = getattr ( ase_calculator , "scratch" , None ) or ase_calculator . parameters . get ( "scratch" )
153+ if not scratch :
154+ raise AttributeError ( "ASE Gaussian calculator has no scratch location (no .scratch and no parameters['scratch'])." )
155+ os . makedirs ( scratch , exist_ok = True )
156156
157- shutil .move (
158- ase_calculator .label + ".com" ,
159- os .path .join (
160- ase_calculator .scratch ,
161- ase_calculator .label + ".com"
162- ))
157+ base = ase_calculator .label
158+ com_src = f"{ base } .com"
159+ if not os .path .exists (com_src ):
160+ raise FileNotFoundError (f"Expected ASE to write { com_src } in CWD={ os .getcwd ()} " )
163161
164162 shutil .move (
165- ase_calculator . label + ".ase" ,
163+ com_src ,
166164 os .path .join (
167- ase_calculator . scratch ,
168- ase_calculator . label + ".ase"
165+ scratch ,
166+ com_src
169167 ))
170168
169+ ase_src = f"{ base } .ase"
170+ if os .path .exists (ase_src ):
171+ shutil .move (
172+ ase_src ,
173+ os .path .join (
174+ scratch ,
175+ ase_src
176+ ))
177+
171178 def check_complete (self , label ):
172179 """
173180 A method to determine if a job is still running
@@ -271,7 +278,10 @@ def submit_conformer(self, conformer, restart=False):
271278 self .calculator .conformer = conformer
272279 ase_calculator = self .calculator .get_conformer_calc ()
273280 label = conformer .smiles + f"_{ conformer .index } "
274- file_path = os .path .join (ase_calculator .scratch , label )
281+ scratch = getattr (ase_calculator , "scratch" , None ) or ase_calculator .parameters .get ("scratch" )
282+ if not scratch :
283+ raise AttributeError ("ASE Gaussian calculator has no scratch location (no .scratch and no parameters['scratch'])." )
284+ file_path = os .path .join (scratch , label )
275285 # for testing
276286 os .environ ["FILE_PATH" ] = file_path
277287
@@ -604,7 +614,9 @@ def submit_transitionstate(self, transitionstate, opt_type, restart=False):
604614 self .write_input (transitionstate , ase_calculator )
605615
606616 label = ase_calculator .label
607- scratch = ase_calculator .scratch
617+ scratch = getattr (ase_calculator , "scratch" , None ) or ase_calculator .parameters .get ("scratch" )
618+ if not scratch :
619+ raise AttributeError ("ASE Gaussian calculator has no scratch location (no .scratch and no parameters['scratch'])." )
608620 file_path = os .path .join (scratch , label )
609621 # for testing
610622 os .environ ["FILE_PATH" ] = file_path
@@ -853,7 +865,10 @@ def submit_rotor(self, conformer, torsion_index, restart=False):
853865 self .calculator .conformer = conformer
854866 ase_calculator = self .calculator .get_rotor_calc (torsion_index )
855867 label = ase_calculator .label
856- file_path = os .path .join (ase_calculator .scratch , ase_calculator .label )
868+ scratch = getattr (ase_calculator , "scratch" , None ) or ase_calculator .parameters .get ("scratch" )
869+ if not scratch :
870+ raise AttributeError ("ASE Gaussian calculator has no scratch location (no .scratch and no parameters['scratch'])." )
871+ file_path = os .path .join (scratch , ase_calculator .label )
857872
858873 os .environ ["FILE_PATH" ] = file_path
859874
0 commit comments