-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a51de0
commit 9d40601
Showing
2 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
|
||
""" | ||
Original Author: Samuel Blau | ||
Modifier: Anup Kumar | ||
Module for adding calculations to a FireWorks LaunchPad. | ||
Includes functions to add transition state and IRC (Intrinsic Reaction Coordinate) | ||
calculations to a LaunchPad for QChem using the FireWorks workflow management tool. | ||
""" | ||
|
||
import toml | ||
import glob | ||
import jobflow as jf | ||
from ase import Atoms | ||
from ase.io import read | ||
from fireworks import LaunchPad | ||
from quacc.recipes.qchem.ts import ts_job | ||
from quacc.recipes.qchem.ts import irc_job | ||
from quacc.recipes.qchem.core import freq_job | ||
from jobflow.managers.fireworks import flow_to_workflow | ||
|
||
|
||
def add_to_launchpad( | ||
index: str, | ||
atoms: Atoms, | ||
tag: str, | ||
lpad: LaunchPad, | ||
run_job_locally: bool = False, | ||
RUN: bool = False, | ||
) -> None: | ||
""" | ||
Add QChem calculations to a LaunchPad. | ||
Parameters: | ||
index (str): Identifier for the calculation. | ||
atoms (Atoms): ASE Atoms object representing the molecular structure. | ||
tag (str): Tag to classify the calculation. | ||
lpad (LaunchPad): FireWorks LaunchPad object. | ||
run_job_locally (bool, optional): Whether to run the job locally. Defaults to False. | ||
RUN (bool, optional): Whether to add the workflow to the LaunchPad. Defaults to False. | ||
Returns: | ||
None | ||
""" | ||
job1 = ts_job( | ||
atoms, | ||
0, | ||
1, | ||
method="wb97x", | ||
basis="6-31G*", | ||
) | ||
job1.name = f"ind{index}_{tag}_ts" | ||
|
||
job1f = freq_job( | ||
job1.output, | ||
0, | ||
1, | ||
method="wb97x", | ||
basis="6-31G*", | ||
) | ||
job1f.name = f"ind{index}_{tag}_freq" | ||
|
||
job2 = irc_job( | ||
job1.output, | ||
0, | ||
1, | ||
direction="forward", | ||
method="wb97x", | ||
basis="6-31G*", | ||
) | ||
job2.name = f"ind{index}_{tag}_firc" | ||
|
||
job2f = freq_job( | ||
job2.output, | ||
0, | ||
1, | ||
method="wb97x", | ||
basis="6-31G*", | ||
) | ||
job2f.name = f"ind{index}_{tag}_firc_freq" | ||
|
||
job3 = irc_job( | ||
job1.output, | ||
0, | ||
1, | ||
direction="reverse", | ||
method="wb97x", | ||
basis="6-31G*", | ||
) | ||
job3.name = f"ind{index}_{tag}_rirc" | ||
|
||
job3f = freq_job( | ||
job3.output, | ||
0, | ||
1, | ||
method="wb97x", | ||
basis="6-31G*" | ||
) | ||
job3f.name = f"ind{index}_{tag}_rirc_freq" | ||
|
||
job_list = [job1, job1f, job2, job2f, job3, job3f] | ||
|
||
for job in job_list: | ||
job.update_metadata( | ||
{ | ||
"class": f"{tag}" | ||
} | ||
) | ||
|
||
flow = jf.Flow(job_list) | ||
|
||
if run_job_locally: | ||
responses = jf.run_locally(flow) | ||
result = responses[job2.uuid][1].output | ||
print(result) | ||
else: | ||
wf = flow_to_workflow(flow) | ||
|
||
if RUN: | ||
lpad.add_wf(wf) | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Main function to add QChem calculations to the LaunchPad. | ||
Returns: | ||
None | ||
""" | ||
config = toml.load('inputs/config44.toml') | ||
|
||
index_files = [index_file for index_file in glob.glob(config['indices']['xyz_files_dir'] + '/*')] | ||
tag = config['general']['tag'] | ||
run = config['general']['run'] | ||
LAUNCHPAD_FILE = config['general']['launchpad_file'] | ||
lpad = LaunchPad.from_file(LAUNCHPAD_FILE) | ||
|
||
for index_file in index_files: | ||
atoms = read(index_file) | ||
index = index_file.split('/')[-1].split('.')[0] | ||
add_to_launchpad( | ||
index, | ||
atoms, | ||
tag, | ||
lpad, | ||
RUN=run, | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
|
||
""" | ||
Author: Anup Kumar | ||
""" | ||
|
||
import toml | ||
import glob | ||
import jobflow as jf | ||
from ase import Atoms | ||
from ase.io import read | ||
from fireworks import LaunchPad | ||
from jobflow.managers.fireworks import flow_to_workflow | ||
from quacc.recipes.newtonnet.ts import ts_job | ||
from quacc.recipes.newtonnet.ts import irc_job | ||
from atomate.common.powerups import add_tags | ||
|
||
|
||
def add_to_launchpad( | ||
index: str, | ||
atoms: Atoms, | ||
config: dict, | ||
lpad: LaunchPad, | ||
ts_type: int = 0, | ||
run_job_locally: bool = True, | ||
) -> None: | ||
""" | ||
Add transition state and IRC jobs to the FireWorks LaunchPad. | ||
Args: | ||
index (str): The index string. | ||
atoms (Atoms): The ASE Atoms object. | ||
config (dict): The configuration dictionary. | ||
lpad (LaunchPad): The FireWorks LaunchPad. | ||
ts_type (int, optional): The type of transition state. Defaults to 0. | ||
run_job_locally (bool, optional): Whether to run the job locally or add to LaunchPad. Defaults to True. | ||
""" | ||
tag = config['general']['tag'].format(ts_type) | ||
|
||
if ts_type == 0: | ||
job1 = ts_job( | ||
atoms, | ||
use_custom_hessian=True, | ||
) | ||
job1.update_metadata( | ||
{ | ||
"tag": f'TS{ts_type}-{index}' | ||
} | ||
) | ||
else: | ||
job1 = ts_job(atoms, use_custom_hessian=False) | ||
job1.update_metadata( | ||
{ | ||
"tag": f'TS{ts_type}-{index}' | ||
} | ||
) | ||
|
||
opt_swaps = { | ||
"run_kwargs": { | ||
"direction": "forward", | ||
}, | ||
} | ||
|
||
calc_swaps = { | ||
"use_custom_hessian": False | ||
} | ||
|
||
job2 = irc_job( | ||
job1.output["atoms"], | ||
opt_swaps=opt_swaps, | ||
calc_swaps=calc_swaps, | ||
) | ||
job2.update_metadata( | ||
{ | ||
"tag": f'irc-forward{ts_type}-{index}', | ||
} | ||
) | ||
|
||
opt_swaps = { | ||
"run_kwargs": { | ||
"direction": "reverse", | ||
}, | ||
} | ||
|
||
job3 = irc_job( | ||
job1.output["atoms"], | ||
opt_swaps=opt_swaps, | ||
calc_swaps=calc_swaps, | ||
) | ||
job3.update_metadata( | ||
{ | ||
"tag": f'irc-reverse{ts_type}-{index}', | ||
} | ||
) | ||
|
||
flow = jf.Flow([job1, job2, job3]) | ||
|
||
if run_job_locally: | ||
responses = jf.run_locally(flow) | ||
result = responses[job2.uuid][1].output | ||
print(result) | ||
else: | ||
wf = flow_to_workflow(flow) | ||
wf = add_tags(wf, {"class": tag}) | ||
if config['general']['run']: | ||
lpad.add_wf(wf) | ||
|
||
|
||
def main(): | ||
""" | ||
Main function to add transition state and IRC jobs to the LaunchPad. | ||
""" | ||
config = toml.load('inputs/config43.toml') | ||
index_files = [index_file for index_file in glob.glob(config['indices']['xyz_files_dir'] + '/*')] | ||
|
||
LAUNCHPAD_FILE = config['general']['launchpad_file'] | ||
lpad = LaunchPad.from_file(LAUNCHPAD_FILE) | ||
|
||
for index_file in index_files: | ||
atoms = read(index_file) | ||
index = index_file.split('/')[-1].split('.')[0] | ||
add_to_launchpad( | ||
index, | ||
atoms, | ||
config, | ||
lpad, | ||
ts_type=0, | ||
run_job_locally=False, | ||
) | ||
add_to_launchpad( | ||
index, | ||
atoms, | ||
config, | ||
lpad, | ||
ts_type=1, | ||
run_job_locally=False, | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |