@@ -78,20 +78,20 @@ def run_patch_rpi(rpi_params):
7878
7979 critical_params = ["path_to_save_Hvibs" , "iread" , "fread" , "nsteps" , "npatches" , "nstates" , "path_to_save_patch" ]
8080 default_params = {"run_slurm" : False , "submit_template" : 'submit_template.slm' , "submission_exe" : 'sbatch' ,
81- "run_python_file" : 'run_template.py' ,
82- "iconds" : [0 ],
83- "dt" : 1.0 * units .fs2au ,
84- }
81+ "run_python_file" : 'run_template.py' , "python_exe" : 'python' , "basis_type" : 'ci' ,
82+ "iconds" : [0 ], "dt" : 1.0 * units .fs2au }
83+
8584 comn .check_input (rpi_params , default_params , critical_params )
8685
86+ path_to_save_Hvibs , basis_type = rpi_params ["path_to_save_Hvibs" ], rpi_params ["basis_type" ]
87+ iread , fread = rpi_params ["iread" ], rpi_params ["fread" ]
88+ nsteps , dt = rpi_params ["nsteps" ], rpi_params ["dt" ]
89+ npatches , nstates = rpi_params ["npatches" ], rpi_params ["nstates" ]
90+
8791 out_dir = rpi_params ["path_to_save_patch" ]
8892 if not os .path .exists (out_dir ):
8993 os .mkdir (out_dir )
9094
91- file = open (rpi_params ["run_python_file" ], 'r' )
92- lines = file .readlines ()
93- file .close ()
94-
9595 os .chdir (out_dir )
9696
9797 for ibatch , icond in enumerate (rpi_params ["iconds" ]):
@@ -100,37 +100,26 @@ def run_patch_rpi(rpi_params):
100100 print (F"Submitting patch dynamics job of icond = { ibatch } , ipatch = { ipatch } , istate = { istate } " )
101101
102102 # Compute the istep and fstep here, for each patch
103- istep = rpi_params [ ' iread' ] + icond + ipatch * int (rpi_params [ ' nsteps' ] / rpi_params [ ' npatches' ] )
104- fstep = fstep = istep + int (rpi_params [ ' nsteps' ] / rpi_params [ ' npatches' ] ) + 1
103+ istep = iread + icond + ipatch * int ( nsteps / npatches )
104+ fstep = istep + int ( nsteps / npatches ) + 1
105105
106106 dir_patch = F"job_{ ibatch } _{ ipatch } _{ istate } "
107107 if os .path .exists (dir_patch ):
108108 os .system ('rm -rf ' + dir_patch )
109109 os .mkdir (dir_patch )
110110 os .chdir (dir_patch )
111- file = open ('run.py' , 'w' )
112-
113- for i in range (len (lines )):
114- if "params['path_to_save_Hvibs'] =" in lines [i ]:
115- file .write ("""params['path_to_save_Hvibs'] = "%s"\n """ % rpi_params ["path_to_save_Hvibs" ])
116- elif "params['istep'] =" in lines [i ]:
117- file .write ("params['istep'] = %d\n " % istep )
118- elif "params['fstep'] =" in lines [i ]:
119- file .write ("params['fstep'] = %d\n " % fstep )
120- elif "params['nsteps'] =" in lines [i ]:
121- file .write ("params['nsteps'] = %d\n " % rpi_params ["nsteps" ])
122- elif "params['npatches'] =" in lines [i ]:
123- file .write ("params['npatches'] = %d\n " % rpi_params ["npatches" ])
124- elif "params['istate'] =" in lines [i ]:
125- file .write ("params['istate'] = %d\n " % istate )
126- elif "params['dt'] =" in lines [i ]:
127- file .write ("params['dt'] = %f\n " % rpi_params ["dt" ])
128- else :
129- file .write (lines [i ])
130- file .close ()
131-
111+
112+ # Submit jobs or run each patch dynamics through this loop
132113 if rpi_params ["run_slurm" ]:
114+ os .system ('cp ../../%s %s' % (rpi_params ["run_python_file" ], rpi_params ["run_python_file" ]))
133115 os .system ('cp ../../%s %s' % (rpi_params ["submit_template" ], rpi_params ["submit_template" ]))
116+
117+ file = open (rpi_params ["submit_template" ], 'a' )
118+ args_fmt = ' --path_to_save_Hvibs %s --basis_type %s --istep %d --fstep %d --istate %d --dt %f'
119+ file .write ('%s %s' % (rpi_params ["python_exe" ], rpi_params ["run_python_file" ]) + \
120+ args_fmt % (path_to_save_Hvibs , basis_type , istep , fstep , istate , dt ) + " >log" )
121+ file .close ()
122+
134123 os .system ('%s %s' % (rpi_params ["submission_exe" ], rpi_params ["submit_template" ]))
135124 else :
136125 # Just in case you want to use a bash file and not submitting
0 commit comments