Skip to content

Commit 2b02329

Browse files
committed
Updates
1 parent 272fc55 commit 2b02329

5 files changed

Lines changed: 186 additions & 20 deletions

File tree

arc/main.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from arc.job.ssh import SSHClient
3737
from arc.output import write_output_yml
3838
from arc.processor import process_arc_project, resolve_neb_level
39+
from arc.provenance import DecisionKind, EdgeType
3940
from arc.reaction import ARCReaction
4041
from arc.scheduler import Scheduler
4142
from arc.species.converter import str_to_xyz
@@ -671,6 +672,70 @@ def execute(self) -> dict:
671672
log_footer(execution_time=self.execution_time)
672673
return status_dict
673674

675+
def _add_arkane_provenance_nodes(self):
676+
"""Add Arkane computation and result nodes to the provenance graph.
677+
678+
For each converged species with thermo results, creates:
679+
convergence_confirmed → calc(statmech_thermo) → data(thermo)
680+
681+
For each converged reaction with kinetics results, creates:
682+
convergence_confirmed → calc(statmech_kinetics) → data(kinetics)
683+
"""
684+
graph = self.scheduler.graph
685+
for spc in self.scheduler.species_dict.values():
686+
if spc.is_ts or getattr(spc.thermo, 'H298', None) is None:
687+
continue
688+
spc_nid = graph.find_species_node(spc.label)
689+
if spc_nid is None:
690+
continue
691+
# Insert a CalculationNode for the Arkane thermo computation.
692+
calc_nid = graph.add_calculation_node(
693+
label=spc.label,
694+
job_name='arkane_thermo',
695+
job_type='statmech_thermo',
696+
job_adapter=self.thermo_adapter,
697+
status='done',
698+
)
699+
graph.add_edge(spc_nid, calc_nid, EdgeType.belongs_to)
700+
# Link from convergence gate if it exists.
701+
conv_nodes = graph.query(decision_kind=DecisionKind.convergence_confirmed, label=spc.label)
702+
for conv_node in conv_nodes:
703+
graph.add_edge(conv_node.node_id, calc_nid, EdgeType.triggered_by)
704+
thermo_nid = graph.add_data_node(
705+
label=spc.label,
706+
data_kind='thermo',
707+
value=f'H298={spc.thermo.H298:.1f} kJ/mol, S298={spc.thermo.S298:.1f} J/mol/K',
708+
)
709+
graph.add_edge(calc_nid, thermo_nid, EdgeType.output_of)
710+
for rxn in self.scheduler.rxn_list:
711+
if rxn.kinetics is None:
712+
continue
713+
ts_nid = graph.find_species_node(rxn.ts_label)
714+
if ts_nid is None:
715+
continue
716+
# Insert a CalculationNode for the Arkane kinetics computation.
717+
calc_nid = graph.add_calculation_node(
718+
label=rxn.ts_label,
719+
job_name='arkane_kinetics',
720+
job_type='statmech_kinetics',
721+
job_adapter=self.kinetics_adapter,
722+
status='done',
723+
)
724+
graph.add_edge(ts_nid, calc_nid, EdgeType.belongs_to)
725+
# Link from TS convergence gate if it exists.
726+
conv_nodes = graph.query(decision_kind=DecisionKind.convergence_confirmed, label=rxn.ts_label)
727+
for conv_node in conv_nodes:
728+
graph.add_edge(conv_node.node_id, calc_nid, EdgeType.triggered_by)
729+
ea = rxn.kinetics.get('Ea')
730+
ea_str = f', Ea={ea[0]:.1f} {ea[1]}' if ea else ''
731+
kinetics_nid = graph.add_data_node(
732+
label=rxn.ts_label,
733+
data_kind='kinetics',
734+
value=f'{rxn.label}{ea_str}',
735+
)
736+
graph.add_edge(calc_nid, kinetics_nid, EdgeType.output_of)
737+
graph.save(self.scheduler.graph_path)
738+
674739
def save_project_info_file(self):
675740
"""
676741
Save a project info file.

arc/plotter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ def render_provenance_graph(prov_graph, run_label: str = 'ARC run') -> 'graphviz
120120
'ts_validation_freq': 'lightyellow',
121121
'ts_validation_nmd': 'lightyellow',
122122
'ts_validation_irc': 'lightyellow',
123+
'ts_validation_e0': 'lightyellow',
124+
'ts_validation_e_elect': 'lightyellow',
123125
'ts_switch': 'mistyrose',
126+
'convergence_confirmed': 'palegreen',
124127
}
125128

126129
# Edge styling lookup
@@ -235,8 +238,10 @@ def render_provenance_graph(prov_graph, run_label: str = 'ARC run') -> 'graphviz
235238
batch_edges_added.add(edge_key)
236239
etype = edge.edge_type
237240
style_attrs = _edge_styles.get(etype, {})
238-
# Only show labels on semantically interesting edges (not belongs_to, input_of, output_of).
239-
label = etype.replace('_', ' ') if etype not in ('belongs_to', 'input_of', 'output_of') else ''
241+
# Only show labels on semantically interesting edges; suppress purely structural ones.
242+
_suppress = ('belongs_to', 'input_of', 'output_of', 'retried_as')
243+
_rename = {'fine_of': 'fine grid', 'troubleshot_by': 'troubleshoot'}
244+
label = _rename.get(etype, etype.replace('_', ' ')) if etype not in _suppress else ''
240245
gv.edge(src, tgt, label=label, **style_attrs)
241246

242247
return gv

arc/provenance/nodes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ class DecisionKind(str, Enum):
5555
ts_validation_freq = 'ts_validation_freq'
5656
ts_validation_nmd = 'ts_validation_nmd'
5757
ts_validation_irc = 'ts_validation_irc'
58+
ts_validation_e0 = 'ts_validation_e0'
59+
ts_validation_e_elect = 'ts_validation_e_elect'
5860
ts_switch = 'ts_switch'
5961
job_troubleshooting = 'job_troubleshooting'
6062
ts_method_spawning = 'ts_method_spawning'
63+
convergence_confirmed = 'convergence_confirmed'
6164

6265

6366
class EdgeType(str, Enum):

arc/provenance/provenance_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def test_data_kind_values(self):
3333
def test_decision_kind_values(self):
3434
expected = {'conformer_selection', 'ts_guess_clustering', 'ts_guess_selection',
3535
'ts_guess_selection_failed', 'ts_validation_freq', 'ts_validation_nmd',
36-
'ts_validation_irc', 'ts_switch', 'job_troubleshooting', 'ts_method_spawning'}
36+
'ts_validation_irc', 'ts_validation_e0', 'ts_validation_e_elect',
37+
'ts_switch', 'job_troubleshooting', 'ts_method_spawning',
38+
'convergence_confirmed'}
3739
actual = {dk.value for dk in DecisionKind}
3840
self.assertEqual(expected, actual)
3941

0 commit comments

Comments
 (0)