Skip to content

Commit

Permalink
Fix derived data
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Nov 28, 2024
1 parent 93445cc commit 0d12587
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions abcd/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ def from_atoms(cls, atoms: Atoms, extra_info=None, store_calc=True):

for key, value in atoms.calc.results.items():
if isinstance(value, np.ndarray):
if value.shape[0] == n_atoms:
arrays_keys.add(key)
else:
info_keys.add(key)
data[key] = value.tolist()
else:
data[key] = value
Expand Down Expand Up @@ -261,14 +257,14 @@ def pre_save(self):

if cell:
volume = abs(np.linalg.det(cell)) # atoms.get_volume()
self["volume"] = volume
self.derived_keys.append("volume")
self["volume"] = volume

virial = self.get("virial")
if virial:
# pressure P = -1/3 Tr(stress) = -1/3 Tr(virials/volume)
self["pressure"] = -1 / 3 * np.trace(virial / volume)
self.derived_keys.append("pressure")
self["pressure"] = -1 / 3 * np.trace(virial / volume)

# 'elements': Counter(atoms.get_chemical_symbols()),
self["elements"] = Counter(str(element) for element in self["numbers"])
Expand Down

0 comments on commit 0d12587

Please sign in to comment.