@@ -139,9 +139,6 @@ def calculate_unit_cells(self, forcefield_cutoff):
139139
140140 def write_out (self , output_path ):
141141 with open (output_path , "w" ) as log_file :
142- # log_file.write("input file: " + self.sorbent_file + "\n")
143- # log_file.write("helium_void_fraction: " + str(self.helium_void_fraction) + "\n")
144- # log_file.write("helium_void_fraction: " + str(self.helium_void_fraction) + "\n")
145142 log_file .write (self .raspa_output )
146143
147144# assigns charges to the atoms in the simulation file using the MEPO Qeq charge equilibration method
@@ -192,21 +189,18 @@ def run_gcmc_simulation(
192189 initialization_cycles = 0 ,
193190 equilibration_cycles = 2000 ,
194191 production_cycles = 2000 ,
195- forcefield = "UFF-TraPPe " ,
192+ forcefield = "UFF" ,
196193 forcefield_cutoff = 12 ,
197194 molecule_definitions = "TraPPE" ,
198195 unit_cells = [0 , 0 , 0 ],
199196 cleanup = False ,
197+ rewrite_raspa_input = False ,
200198):
201199 # copy cif file into parent RASPA folder
202200 shutil .copy (simulation .sorbent_file , raspa_path + "/share/raspa/structures/cif/" )
203201 workdir = simulation .rundir / "raspa_output" / simulation .identifier
204202 workdir .mkdir (exist_ok = True , parents = True )
205203
206- # create and enter temp directory
207- # os.mkdir(simulation.rundir / "raspa_output" / simulation.identifier)
208- # os.chdir(os.getcwd() + "/temp/raspa_output/" + simulation.identifier)
209-
210204 sorbent_file = "." .join (simulation .sorbent_file .split ("/" )[- 1 ].split ("." )[:- 1 ])
211205
212206 # calculate number of unit cells needed if not user defined
@@ -299,8 +293,14 @@ def run_gcmc_simulation(
299293 # write out raspa input file
300294 with open (workdir / "simulation.input" , "w" ) as raspa_input :
301295 raspa_input .write (simulation .raspa_config )
296+
297+ # optionally rewrite input file to avoid errors with RASPA reading it
298+ if rewrite_raspa_input :
299+ raspa_input_path = workdir / "simulation.input"
300+ subprocess .run (["mv" , raspa_input_path , f"{ raspa_input_path } .orig" ])
301+ command = f"printf '%s\\ n' \" $(cat { raspa_input_path } .orig)\" > { raspa_input_path } "
302+ subprocess .Popen (command , shell = True )
302303
303- # os.chdir(str(workdir))
304304 # run raspa simulation
305305 subprocess .run ([raspa_sim_path , "simulation.input" ], cwd = str (workdir ))
306306
@@ -313,4 +313,4 @@ def run_gcmc_simulation(
313313
314314 # clear temp directory
315315 if cleanup :
316- shutil .rmtree (str (workdir ))
316+ shutil .rmtree (str (workdir ))
0 commit comments