Skip to content

Commit

Permalink
Fix bug related to solvent in xtb_gaussian runs
Browse files Browse the repository at this point in the history
  • Loading branch information
tstuyver committed Jan 16, 2024
1 parent dbab28f commit 92db3c2
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 142 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
src/reaction_profile_generator/__pycache__/*
.autode_calculations
__pycache__/
src/ts_tools/__pycache__/*.pyc
128 changes: 0 additions & 128 deletions run_scripts/dft_validation.py

This file was deleted.

2 changes: 1 addition & 1 deletion run_scripts/run_ts_searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def obtain_transition_states(target_dir, reaction_list, xtb_external_path, solve
setup_dir(args.target_dir)
reaction_list = get_reaction_list(args.input_file)
start_time = time.time()
xtb_external_path = f'"{os.path.join(os.getcwd(), args.xtb_external_path)}"'
xtb_external_path = f'{os.path.join(os.getcwd(), args.xtb_external_path)}'

# run all reactions in parallel
successful_reactions = obtain_transition_states(args.target_dir, reaction_list,
Expand Down
2 changes: 1 addition & 1 deletion run_scripts/run_ts_searcher_dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def obtain_transition_states(target_dir, reaction_list, xtb_external_path, solve
setup_dir(args.target_dir)
reaction_list = get_reaction_list(args.input_file)
start_time = time.time()
xtb_external_path = f'"{os.path.join(os.getcwd(), args.xtb_external_path)}"'
xtb_external_path = f'{os.path.join(os.getcwd(), args.xtb_external_path)}'

# run all reactions in parallel
successful_reactions = obtain_transition_states(args.target_dir, reaction_list,
Expand Down
Binary file modified src/ts_tools/__pycache__/irc_search.cpython-310.pyc
Binary file not shown.
Binary file modified src/ts_tools/__pycache__/ts_optimizer.cpython-310.pyc
Binary file not shown.
14 changes: 6 additions & 8 deletions src/ts_tools/irc_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,13 @@ def generate_gaussian_irc_input(xyz_file, output_prefix='irc_calc', method='B3LY
f'\n\nIRC Calculation\n\n{charge} {multiplicity}\n{"".join(atom_coords)}\n\n'
else:
if solvent is not None:
input_content_f = f'%Chk={xyz_file.split("/")[-1][:-4]}.chk\n#p IRC(calcfc, maxpoint=50, stepsize=15, Forward) {method} SCRF=(Solvent={solvent})\n\n' \
f'IRC Calculation\n\n{charge} {multiplicity}\n{"".join(atom_coords)}\n\n'
input_content_r = f'%Chk={xyz_file.split("/")[-1][:-4]}.chk\n#p IRC(calcfc, maxpoint=50, stepsize=15, Reverse) {method} SCRF=(Solvent={solvent})\n\n' \
f'IRC Calculation\n\n{charge} {multiplicity}\n{"".join(atom_coords)}\n\n'
external_method = f'external="{method} alpb={solvent}"'
else:
input_content_f = f'%Chk={xyz_file.split("/")[-1][:-4]}.chk\n#p IRC(calcfc, maxpoint=50, stepsize=15, Forward) {method}\n\n' \
f'IRC Calculation\n\n{charge} {multiplicity}\n{"".join(atom_coords)}\n\n'
input_content_r = f'%Chk={xyz_file.split("/")[-1][:-4]}.chk\n#p IRC(calcfc, maxpoint=50, stepsize=15, Reverse) {method}\n\n' \
f'IRC Calculation\n\n{charge} {multiplicity}\n{"".join(atom_coords)}\n\n'
external_method = f'external="{method}"'
input_content_f = f'%Chk={xyz_file.split("/")[-1][:-4]}.chk\n#p IRC(calcfc, maxpoint=50, stepsize=15, Forward) {external_method}\n\n' \
f'IRC Calculation\n\n{charge} {multiplicity}\n{"".join(atom_coords)}\n\n'
input_content_r = f'%Chk={xyz_file.split("/")[-1][:-4]}.chk\n#p IRC(calcfc, maxpoint=50, stepsize=15, Reverse) {external_method}\n\n' \
f'IRC Calculation\n\n{charge} {multiplicity}\n{"".join(atom_coords)}\n\n'

# Write the input content to a Gaussian input file -- forward
input_filename_f = os.path.join(os.path.dirname(xyz_file), f'{output_prefix}_forward.com')
Expand Down
10 changes: 6 additions & 4 deletions src/ts_tools/ts_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ def determine_ts(self, xtb=True, method='UB3LYP', basis_set='6-31G**'):
return False

if xtb:
method = f'external={self.xtb_external_path}'
if self.solvent is not None:
method = f'external="{self.xtb_external_path} alpb={self.solvent}"'
else:
method = f'external="{self.xtb_external_path}"'
basis_set = ''

if self.solvent is not None:
if self.solvent is not None and not xtb:
extra_commands = f'opt=(ts, calcall, noeigen, nomicro) SCRF=(Solvent={self.solvent})'
else:
extra_commands = f'opt=(ts, calcall, noeigen, nomicro)'
Expand Down Expand Up @@ -292,7 +295,7 @@ def confirm_opt_transition_state(self, log_file, xtb=True, method='UB3LYP', basi
irc_input_file_f, irc_input_file_r = generate_gaussian_irc_input(
f'{os.path.splitext(log_file)[0]}.xyz',
output_prefix=f'{os.path.splitext(log_file)[0]}_irc',
method=f'external={self.xtb_external_path}',
method=self.xtb_external_path,
mem=self.mem, proc=self.proc,
solvent=self.solvent, charge=self.charge, multiplicity=self.multiplicity
)
Expand Down Expand Up @@ -321,7 +324,6 @@ def confirm_opt_transition_state(self, log_file, xtb=True, method='UB3LYP', basi
return reaction_correct

except Exception as e:
#print(e)
return False

def reaction_is_intramolecular(self):
Expand Down

0 comments on commit 92db3c2

Please sign in to comment.