Skip to content

Commit 8fd3331

Browse files
committed
Got rid of the try except things.
1 parent 18484d2 commit 8fd3331

File tree

1 file changed

+25
-57
lines changed

1 file changed

+25
-57
lines changed

src/ts-workflow-examples/neb_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)
@@ -23,69 +22,38 @@
2322

2423

2524
def main():
26-
try:
27-
# Read reactant and product structures
28-
reactant = read(REACTANT_XYZ_FILE)
29-
product = read(PRODUCT_XYZ_FILE)
30-
logger.info("Successfully read reactant and product structures.")
31-
except Exception as e:
32-
logger.error(f"Error reading reactant and product structures: {e}")
33-
return
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.")
3429

35-
try:
36-
# Create NEB job
37-
job1 = neb_job(reactant, product, calc_kwargs=calc_kwargs1)
38-
job1.update_metadata({"tag": f'neb_{TAG}'})
39-
logger.info("Created NEB job.")
40-
except Exception as e:
41-
logger.error(f"Error creating NEB job: {e}")
42-
return
30+
# Create NEB job
31+
job1 = neb_job(reactant, product, calc_kwargs=calc_kwargs1)
32+
logger.info("Created NEB job.")
4333

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

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

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

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

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

8956

9057
if __name__ == "__main__":
9158
main()
59+

0 commit comments

Comments
 (0)