Skip to content

Commit ddf2bd2

Browse files
authored
Merge pull request #423 from anyangml2nd/main
fix: separate spin charge
2 parents b073018 + 217f978 commit ddf2bd2

3 files changed

Lines changed: 30 additions & 22 deletions

File tree

lambench/models/ase_models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,12 @@ def run_ase_dptest(
398398
}
399399
)
400400
elif model.model_family == "DP":
401-
atoms.info.update({"charge_spin": frame.data["fparam"]})
402-
atoms.info.update({"fparam": frame.data["fparam"]})
401+
if getattr(
402+
model.model_metadata, "use_separate_spin_charge", False
403+
):
404+
atoms.info.update({"charge_spin": frame.data["fparam"]})
405+
else:
406+
atoms.info.update({"fparam": frame.data["fparam"]})
403407
atoms.calc = calc
404408

405409
# Energy

lambench/tasks/calculator/binding/binding.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ def run_inference(
3838
try:
3939
for atoms in (site, drug, combo):
4040
atoms.calc = calc
41-
atoms.info.update(
42-
{
43-
"charge_spin": np.array(
44-
[atoms.info["charge"], atoms.info["spin"]]
45-
)
46-
}
47-
)
48-
atoms.info.update(
49-
{"fparam": np.array([atoms.info["charge"], atoms.info["spin"]])}
50-
)
41+
if getattr(model.model_metadata, "use_separate_spin_charge", False):
42+
atoms.info.update(
43+
{
44+
"charge_spin": np.array(
45+
[atoms.info["charge"], atoms.info["spin"]]
46+
)
47+
}
48+
)
49+
else:
50+
atoms.info.update(
51+
{"fparam": np.array([atoms.info["charge"], atoms.info["spin"]])}
52+
)
5153

5254
site_energy = site.get_potential_energy()
5355
drug_energy = drug.get_potential_energy()

lambench/tasks/calculator/rxn_barrier/barrier.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,18 @@ def run_inference(
5757
lookup_table["ID"] == reactant
5858
].index.values[0]
5959
atoms = traj[structure_index]
60-
atoms.info.update(
61-
{
62-
"charge_spin": np.array(
63-
[atoms.info["charge"], atoms.info["spin"]]
64-
)
65-
}
66-
)
67-
atoms.info.update(
68-
{"fparam": np.array([atoms.info["charge"], atoms.info["spin"]])}
69-
)
60+
if getattr(model.model_metadata, "use_separate_spin_charge", False):
61+
atoms.info.update(
62+
{
63+
"charge_spin": np.array(
64+
[atoms.info["charge"], atoms.info["spin"]]
65+
)
66+
}
67+
)
68+
else:
69+
atoms.info.update(
70+
{"fparam": np.array([atoms.info["charge"], atoms.info["spin"]])}
71+
)
7072
atoms.calc = calc
7173
energy = atoms.get_potential_energy()
7274
pred += stoi * energy

0 commit comments

Comments
 (0)