Skip to content

Commit 420fb7e

Browse files
committed
Got rid of try error blocks. Defined the newtonnet calculator model and config paths in the relative sense. Also got rid of the tags.
1 parent 52a8f53 commit 420fb7e

File tree

8 files changed

+194
-410
lines changed

8 files changed

+194
-410
lines changed

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "ts-workflow examples"
6+
name = "ts-workflow-examples"
77
description="A Python package description goes here."
88
version = "0.0.1"
99
readme = "README.md"
@@ -25,7 +25,7 @@ classifiers = [
2525
"Operating System :: MacOS",
2626
]
2727
requires-python = ">=3.9"
28-
dependencies = ["numpy"]
28+
dependencies = []
2929

3030
[project.optional-dependencies]
3131
dev = ["pytest>=7.4.0", "pytest-cov>=3.0.0", "ruff>=0.0.285"]
@@ -39,15 +39,15 @@ docs = [
3939
]
4040

4141
[project.urls]
42-
repository = "https://github.com/Quantum-Accelerators/ts-workflow examples"
43-
documentation = "https://quantum-accelerators.github.io/ts-workflow examples/"
44-
changelog = "https://github.com/Quantum-Accelerators/ts-workflow examples/blob/main/CHANGELOG.md"
42+
repository = "https://github.com/Quantum-Accelerators/ts-workflow-examples"
43+
documentation = "https://quantum-accelerators.github.io/ts-workflow-examples/"
44+
changelog = "https://github.com/Quantum-Accelerators/ts-workflow-examples/blob/main/CHANGELOG.md"
4545

46-
[tool.setuptools.package-data]
47-
ts-workflow examples = ["py.typed"]
46+
# [tool.setuptools.package-data]
47+
# ts-workflow-examples = ["py.typed"]
4848

4949
[tool.pyright]
50-
include = ["ts-workflow examples"]
50+
include = ["ts-workflow-examples"]
5151
exclude = ["**/__pycache__"]
5252

5353
[tool.pytest.ini_options]
@@ -137,7 +137,7 @@ lint.unfixable = [
137137
"F841", # Removes unused variables
138138
]
139139
lint.pydocstyle.convention = "numpy"
140-
lint.isort.known-first-party = ["ts-workflow examples"]
140+
lint.isort.known-first-party = ["ts-workflow-examples"]
141141
lint.isort.required-imports = ["from __future__ import annotations"]
142142
extend-include = ["*.ipynb"]
143143

src/ts-workflow-examples/geodesic_ts_with_hessian/using_mace.py

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# Constants from TOML file
1111
REACTANT_XYZ_FILE = config['paths']['reactant']
1212
PRODUCT_XYZ_FILE = config['paths']['product']
13-
TAG = config['run']['tag']
1413

1514
# Setup logging
1615
logging.basicConfig(level=logging.INFO)
@@ -21,69 +20,38 @@
2120
}
2221

2322
def main():
24-
try:
25-
# Read reactant and product structures
26-
reactant = read(REACTANT_XYZ_FILE)
27-
product = read(PRODUCT_XYZ_FILE)
28-
logger.info("Successfully read reactant and product structures.")
29-
except Exception as e:
30-
logger.error(f"Error reading reactant and product structures: {e}")
31-
return
23+
# Read reactant and product structures
24+
reactant = read(REACTANT_XYZ_FILE)
25+
product = read(PRODUCT_XYZ_FILE)
26+
logger.info("Successfully read reactant and product structures.")
3227

33-
try:
34-
# Create NEB job
35-
job1 = geodesic_job(reactant, product, calc_kwargs=calc_kwargs)
36-
job1.update_metadata({"tag": f'geodesic_{TAG}'})
37-
logger.info("Created Geodesic job.")
38-
except Exception as e:
39-
logger.error(f"Error creating Geodesic job: {e}")
40-
return
28+
# Create NEB job
29+
job1 = geodesic_job(reactant, product, calc_kwargs=calc_kwargs)
30+
logger.info("Created Geodesic job.")
4131

42-
try:
43-
# Create TS job with custom Hessian
44-
job2 = ts_job(job1.output['highest_e_atoms'], use_custom_hessian=True, **calc_kwargs)
45-
job2.update_metadata({"tag": f'ts_hess_{TAG}'})
46-
logger.info("Created TS job with custom Hessian.")
47-
except Exception as e:
48-
logger.error(f"Error creating TS job: {e}")
49-
return
32+
# Create TS job with custom Hessian
33+
job2 = ts_job(job1.output['highest_e_atoms'], use_custom_hessian=True, **calc_kwargs)
34+
logger.info("Created TS job with custom Hessian.")
5035

51-
try:
52-
# Create IRC job in forward direction
53-
job3 = irc_job(job2.output['atoms'], direction='forward', **calc_kwargs)
54-
job3.update_metadata({"tag": f'ircf_hess_{TAG}'})
55-
logger.info("Created IRC job in forward direction.")
56-
except Exception as e:
57-
logger.error(f"Error creating IRC job in forward direction: {e}")
58-
return
36+
# Create IRC job in forward direction
37+
job3 = irc_job(job2.output['atoms'], direction='forward', **calc_kwargs)
38+
logger.info("Created IRC job in forward direction.")
5939

60-
try:
61-
# Create IRC job in reverse direction
62-
job4 = irc_job(job2.output['atoms'], direction='reverse', **calc_kwargs)
63-
job4.update_metadata({"tag": f'ircr_hess_{TAG}'})
64-
logger.info("Created IRC job in reverse direction.")
65-
except Exception as e:
66-
logger.error(f"Error creating IRC job in reverse direction: {e}")
67-
return
40+
# Create IRC job in reverse direction
41+
job4 = irc_job(job2.output['atoms'], direction='reverse', **calc_kwargs)
42+
logger.info("Created IRC job in reverse direction.")
6843

69-
try:
70-
# Combine jobs into a flow
71-
jobs = [job1, job2, job3, job4]
72-
flow = jf.Flow(jobs)
73-
logger.info("Jobs combined into a flow.")
74-
except Exception as e:
75-
logger.error(f"Error combining jobs into a flow: {e}")
76-
return
44+
# Combine jobs into a flow
45+
jobs = [job1, job2, job3, job4]
46+
flow = jf.Flow(jobs)
47+
logger.info("Jobs combined into a flow.")
7748

78-
try:
79-
# Execute the workflow locally
80-
responses = jf.managers.local.run_locally(flow)
81-
logger.info("Workflow executed successfully.")
82-
logger.info(f"Responses: {responses}")
83-
except Exception as e:
84-
logger.error(f"Error executing workflow: {e}")
85-
return
49+
# Execute the workflow locally
50+
responses = jf.managers.local.run_locally(flow)
51+
logger.info("Workflow executed successfully.")
52+
logger.info(f"Responses: {responses}")
8653

8754

8855
if __name__ == "__main__":
8956
main()
57+

src/ts-workflow-examples/geodesic_ts_with_hessian/using_newtonnet.py

Lines changed: 39 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
2-
import logging
32
import toml
3+
import logging
4+
import jobflow as jf
45
from ase.io import read
6+
from quacc import get_settings
57
from quacc.recipes.newtonnet.ts import ts_job, irc_job, geodesic_job
6-
import jobflow as jf
8+
79

810
# Load configuration from TOML file
911
config = toml.load('inputs_using_newtonnet.toml')
@@ -13,87 +15,55 @@
1315
PRODUCT_XYZ_FILE = config['paths']['product']
1416
MODEL_PATH = config['paths']['model_path']
1517
SETTINGS_PATH = config['paths']['settings_path']
16-
TAG = config['run']['tag']
1718

1819
# Setup logging
1920
logging.basicConfig(level=logging.INFO)
2021
logger = logging.getLogger(__name__)
2122

23+
settings = get_settings()
24+
settings.NEWTONNET_MODEL_PATH = os.getcwd() + MODEL_PATH
25+
settings.NEWTONNET_CONFIG_PATH = os.getcwd() + SETTINGS_PATH
26+
2227
# Calculation and optimization keyword arguments
2328
calc_kwargs1 = {
24-
'model_path': MODEL_PATH,
25-
'settings_path': SETTINGS_PATH,
2629
'hess_method': None,
2730
}
2831
calc_kwargs2 = {
29-
'model_path': MODEL_PATH,
30-
'settings_path': SETTINGS_PATH,
3132
'hess_method': 'autograd',
3233
}
3334

35+
3436
def main():
35-
try:
36-
# Read reactant and product structures
37-
reactant = read(REACTANT_XYZ_FILE)
38-
product = read(PRODUCT_XYZ_FILE)
39-
logger.info("Successfully read reactant and product structures.")
40-
except Exception as e:
41-
logger.error(f"Error reading reactant and product structures: {e}")
42-
return
43-
44-
try:
45-
# Create NEB job
46-
job1 = geodesic_job(reactant, product, calc_kwargs=calc_kwargs1)
47-
job1.update_metadata({"tag": f'geodesic_{TAG}'})
48-
logger.info("Created Geodesic job.")
49-
except Exception as e:
50-
logger.error(f"Error creating Geodesic job: {e}")
51-
return
52-
53-
try:
54-
# Create TS job with custom Hessian
55-
job2 = ts_job(job1.output['highest_e_atoms'], use_custom_hessian=True, **calc_kwargs2)
56-
job2.update_metadata({"tag": f'ts_hess_{TAG}'})
57-
logger.info("Created TS job with custom Hessian.")
58-
except Exception as e:
59-
logger.error(f"Error creating TS job: {e}")
60-
return
61-
62-
try:
63-
# Create IRC job in forward direction
64-
job3 = irc_job(job2.output['atoms'], direction='forward', **calc_kwargs1)
65-
job3.update_metadata({"tag": f'ircf_hess_{TAG}'})
66-
logger.info("Created IRC job in forward direction.")
67-
except Exception as e:
68-
logger.error(f"Error creating IRC job in forward direction: {e}")
69-
return
70-
71-
try:
72-
# Create IRC job in reverse direction
73-
job4 = irc_job(job2.output['atoms'], direction='reverse', **calc_kwargs1)
74-
job4.update_metadata({"tag": f'ircr_hess_{TAG}'})
75-
logger.info("Created IRC job in reverse direction.")
76-
except Exception as e:
77-
logger.error(f"Error creating IRC job in reverse direction: {e}")
78-
return
79-
80-
try:
81-
# Combine jobs into a flow
82-
jobs = [job1, job2, job3, job4]
83-
flow = jf.Flow(jobs)
84-
logger.info("Jobs combined into a flow.")
85-
except Exception as e:
86-
logger.error(f"Error combining jobs into a flow: {e}")
87-
return
88-
89-
try:
90-
# Execute the workflow locally
91-
responses = jf.managers.local.run_locally(flow)
92-
logger.info("Workflow executed successfully.")
93-
logger.info(f"Responses: {responses}")
94-
except Exception as e:
95-
logger.error(f"Error executing workflow: {e}")
96-
return
37+
# Read reactant and product structures
38+
reactant = read(REACTANT_XYZ_FILE)
39+
product = read(PRODUCT_XYZ_FILE)
40+
logger.info("Successfully read reactant and product structures.")
41+
42+
# Create NEB job
43+
job1 = geodesic_job(reactant, product, calc_kwargs=calc_kwargs1)
44+
logger.info("Created Geodesic job.")
45+
46+
# Create TS job with custom Hessian
47+
job2 = ts_job(job1.output['highest_e_atoms'], use_custom_hessian=True, **calc_kwargs2)
48+
logger.info("Created TS job with custom Hessian.")
49+
50+
# Create IRC job in forward direction
51+
job3 = irc_job(job2.output['atoms'], direction='forward', **calc_kwargs1)
52+
logger.info("Created IRC job in forward direction.")
53+
54+
# Create IRC job in reverse direction
55+
job4 = irc_job(job2.output['atoms'], direction='reverse', **calc_kwargs1)
56+
logger.info("Created IRC job in reverse direction.")
57+
58+
# Combine jobs into a flow
59+
jobs = [job1, job2, job3, job4]
60+
flow = jf.Flow(jobs)
61+
logger.info("Jobs combined into a flow.")
62+
63+
# Execute the workflow locally
64+
responses = jf.managers.local.run_locally(flow)
65+
logger.info("Workflow executed successfully.")
66+
logger.info(f"Responses: {responses}")
9767

9868

9969
if __name__ == "__main__":

src/ts-workflow-examples/geodesic_ts_without_hessian/using_mace.py

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# Constants from TOML file
1212
REACTANT_XYZ_FILE = config['paths']['reactant']
1313
PRODUCT_XYZ_FILE = config['paths']['product']
14-
TAG = config['run']['tag']
1514

1615
# Setup logging
1716
logging.basicConfig(level=logging.INFO)
@@ -22,69 +21,38 @@
2221
}
2322

2423
def main():
25-
try:
26-
# Read reactant and product structures
27-
reactant = read(REACTANT_XYZ_FILE)
28-
product = read(PRODUCT_XYZ_FILE)
29-
logger.info("Successfully read reactant and product structures.")
30-
except Exception as e:
31-
logger.error(f"Error reading reactant and product structures: {e}")
32-
return
24+
# Read reactant and product structures
25+
reactant = read(REACTANT_XYZ_FILE)
26+
product = read(PRODUCT_XYZ_FILE)
27+
logger.info("Successfully read reactant and product structures.")
3328

34-
try:
35-
# Create NEB job
36-
job1 = geodesic_job(reactant, product, calc_kwargs=calc_kwargs)
37-
job1.update_metadata({"tag": f'geodesic_{TAG}'})
38-
logger.info("Created Geodesic job.")
39-
except Exception as e:
40-
logger.error(f"Error creating Geodesic job: {e}")
41-
return
29+
# Create NEB job
30+
job1 = geodesic_job(reactant, product, calc_kwargs=calc_kwargs)
31+
logger.info("Created Geodesic job.")
4232

43-
try:
44-
# Create TS job with custom Hessian
45-
job2 = ts_job(job1.output['highest_e_atoms'], use_custom_hessian=False, **calc_kwargs)
46-
job2.update_metadata({"tag": f'ts_no_hess_{TAG}'})
47-
logger.info("Created TS job without custom Hessian.")
48-
except Exception as e:
49-
logger.error(f"Error creating TS job: {e}")
50-
return
33+
# Create TS job with custom Hessian
34+
job2 = ts_job(job1.output['highest_e_atoms'], use_custom_hessian=False, **calc_kwargs)
35+
logger.info("Created TS job without custom Hessian.")
5136

52-
try:
53-
# Create IRC job in forward direction
54-
job3 = irc_job(job2.output['atoms'], direction='forward', **calc_kwargs)
55-
job3.update_metadata({"tag": f'ircf_no_hess_{TAG}'})
56-
logger.info("Created IRC job in forward direction.")
57-
except Exception as e:
58-
logger.error(f"Error creating IRC job in forward direction: {e}")
59-
return
37+
# Create IRC job in forward direction
38+
job3 = irc_job(job2.output['atoms'], direction='forward', **calc_kwargs)
39+
logger.info("Created IRC job in forward direction.")
6040

61-
try:
62-
# Create IRC job in reverse direction
63-
job4 = irc_job(job2.output['atoms'], direction='reverse', **calc_kwargs)
64-
job4.update_metadata({"tag": f'ircr_no_hess_{TAG}'})
65-
logger.info("Created IRC job in reverse direction.")
66-
except Exception as e:
67-
logger.error(f"Error creating IRC job in reverse direction: {e}")
68-
return
41+
# Create IRC job in reverse direction
42+
job4 = irc_job(job2.output['atoms'], direction='reverse', **calc_kwargs)
43+
logger.info("Created IRC job in reverse direction.")
6944

70-
try:
71-
# Combine jobs into a flow
72-
jobs = [job1, job2, job3, job4]
73-
flow = jf.Flow(jobs)
74-
logger.info("Jobs combined into a flow.")
75-
except Exception as e:
76-
logger.error(f"Error combining jobs into a flow: {e}")
77-
return
45+
# Combine jobs into a flow
46+
jobs = [job1, job2, job3, job4]
47+
flow = jf.Flow(jobs)
48+
logger.info("Jobs combined into a flow.")
7849

79-
try:
80-
# Execute the workflow locally
81-
responses = jf.managers.local.run_locally(flow)
82-
logger.info("Workflow executed successfully.")
83-
logger.info(f"Responses: {responses}")
84-
except Exception as e:
85-
logger.error(f"Error executing workflow: {e}")
86-
return
50+
# Execute the workflow locally
51+
responses = jf.managers.local.run_locally(flow)
52+
logger.info("Workflow executed successfully.")
53+
logger.info(f"Responses: {responses}")
8754

8855

8956
if __name__ == "__main__":
9057
main()
58+

0 commit comments

Comments
 (0)