Skip to content

Commit

Permalink
Merge pull request #41 from kzinovjev/emle-analyze-fix
Browse files Browse the repository at this point in the history
Emle analyze fix
  • Loading branch information
lohedges authored Jan 19, 2025
2 parents 68c27a5 + 1b1808b commit 6926142
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ decomposition of the in vacuo electronic density of the QM region with
[horton](https://theochem.github.io/horton/2.1.1/index.html). Usage:
```
emle-analyze --qm-xyz qm.xyz \
--pc.xyz pc.xyz \
--pc-xyz pc.xyz \
--emle-model model.mat \
--orca-tarball orca.tar \
--backend [deepmd, ani2x]
Expand Down Expand Up @@ -464,7 +464,7 @@ with `--deepmd-model`.
Training of custom EMLE models can be performed with `emle-train` tool. It
requires a tarball with the reference QM calculations with the same naming
convention as the one for `emle-analyze` script, with the difference that only
gas phase calculations are required and dipolar polarizabilies must be present.
gas phase calculations are required and dipolar polarizabilities must be present.
Simple usage:
```
emle-train --orca-tarball orca.tar model.mat
Expand Down
4 changes: 2 additions & 2 deletions bin/emle-analyze
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ if args.backend == "mace" and not args.mace_model:

backend = None
if args.backend == "torchani":
from emle._models import ANI2xEMLE
from emle.models import ANI2xEMLE

backend = ANI2xEMLE()
elif args.backend == "mace":
from emle._models import MACEEMLE
from emle.models import MACEEMLE

backend = MACEEMLE(mace_model=args.mace_model)
elif args.backend == "deepmd":
Expand Down
8 changes: 5 additions & 3 deletions emle/_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def __init__(
)
self.alpha = self._get_mol_alpha(self.A_thole, self.atomic_numbers)

mesh_data = emle_base._get_mesh_data(qm_xyz_bohr, pc_xyz_bohr, self.s)
mask = (self.atomic_numbers > 0).unsqueeze(-1)
mesh_data = emle_base._get_mesh_data(qm_xyz_bohr, pc_xyz_bohr, self.s, mask)
self.e_static = (
emle_base.get_static_energy(
self.q_core, self.q_val, self.pc_charges, mesh_data
Expand All @@ -133,7 +134,7 @@ def __init__(
)
self.e_induced = (
emle_base.get_induced_energy(
self.A_thole, self.pc_charges, self.s, mesh_data
self.A_thole, self.pc_charges, self.s, mesh_data, mask
)
* _HARTREE_TO_KCAL_MOL
)
Expand All @@ -155,6 +156,7 @@ def __init__(
"q_val",
"q_total",
"alpha",
"e_backend"
"e_static",
"e_induced",
"e_static_mbis",
Expand Down Expand Up @@ -184,7 +186,7 @@ def _parse_qm_xyz(filename):
"""

atoms = _ase_io.read(filename, index=":")
atomic_numbers = _pad_to_max([_.get_atomic_numbers() for _ in atoms], -1)
atomic_numbers = _pad_to_max([_.get_atomic_numbers() for _ in atoms], 0)
xyz = _np.array([_.get_positions() for _ in atoms])
return atomic_numbers, xyz

Expand Down

0 comments on commit 6926142

Please sign in to comment.