11"""
22The test data is retrieved from:
33
4- @misc{liang2025gold,
5- title={Gold-Standard Chemical Database 137 (GSCDB137): A diverse set of accurate energy differences for assessing and developing density functionals},
4+ @misc{liang2025gold,
5+ title={Gold-Standard Chemical Database 137 (GSCDB137): A diverse set of accurate energy differences for assessing and developing density functionals},
66 author={Jiashu Liang and Martin Head-Gordon},
77 year={2025},
88 eprint={2508.13468},
99 archivePrefix={arXiv},
1010 primaryClass={physics.chem-ph},
11- url={https://arxiv.org/abs/2508.13468},
11+ url={https://arxiv.org/abs/2508.13468},
1212}
1313
1414https://github.com/JiashuLiang/GSCDB
2727import logging
2828
2929
30-
31-
3230def run_inference (
3331 model : ASEModel ,
3432 test_data : Path ,
3533) -> dict [str , float ]:
36-
3734 lookup_table = pd .read_csv (test_data / "lookup_table.csv" )
3835 lookup_table .reset_index (inplace = True )
3936 stoichiometry = pd .read_csv (test_data / "stoichiometry.csv" )
@@ -46,31 +43,36 @@ def run_inference(
4643 labels = []
4744 success = len (stoichiometry )
4845
49- calc = model .calc
46+ calc = model .calc
5047
5148 for i , row in tqdm (stoichiometry .iterrows ()):
5249 try :
5350 reactions = row ["Stoichiometry" ].split ("," )
54- num_species = len (reactions ) // 2
51+ num_species = len (reactions ) // 2
5552 pred = 0
5653 for i in range (num_species ):
57- stoi = float (reactions [2 * i ])
58- reactant = reactions [2 * i + 1 ]
59- structure_index = lookup_table [lookup_table ["ID" ] == reactant ].index .values [0 ]
54+ stoi = float (reactions [2 * i ])
55+ reactant = reactions [2 * i + 1 ]
56+ structure_index = lookup_table [
57+ lookup_table ["ID" ] == reactant
58+ ].index .values [0 ]
6059 atoms = traj [structure_index ]
61- atoms .info .update ({"fparam" : np .array ([atoms .info ["charge" ], atoms .info ["spin" ]])})
60+ atoms .info .update (
61+ {"fparam" : np .array ([atoms .info ["charge" ], atoms .info ["spin" ]])}
62+ )
6263 atoms .calc = calc
6364 energy = atoms .get_potential_energy ()
6465 pred += stoi * energy
6566 preds .append (pred * EV_TO_KCAL )
6667 labels .append (row ["Reference" ] * HARTREE_TO_KCAL )
67- except :
68- logging .warning (f"Failed to calculate reaction energy for reaction: { row ['Stoichiometry' ]} " )
68+ except Exception as e :
69+ logging .warning (
70+ f"Failed to calculate reaction energy for reaction: { row ['Stoichiometry' ]} . Error: { e } "
71+ )
6972 success -= 1
70-
7173
7274 return {
7375 "MAE" : mean_absolute_error (labels , preds ), # kcal/mol
7476 "RMSE" : root_mean_squared_error (labels , preds ), # kcal/mol
7577 "success_rate" : success / len (stoichiometry ),
76- }
78+ }
0 commit comments