Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ml_peg/calcs/bulk_crystal/elasticity/calc_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def process_result(self, result: dict | None, model_name: str) -> dict: # noqa:
dict
Dictionary of processed elastic properties.
"""
key = get_crystal_system(result["final_structure"])
return {
f"bulk_modulus_vrh_{model_name}": (
result["bulk_modulus_vrh"] * eVA3ToGPa
Expand All @@ -158,7 +157,11 @@ def process_result(self, result: dict | None, model_name: str) -> dict: # noqa:
if result is not None
else float("nan")
),
f"crystal_system_{model_name}": key,
f"crystal_system_{model_name}": get_crystal_system(
result["final_structure"]
)
if result is not None
else None,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import random
from typing import Any
import urllib.request
from warnings import warn

from ase import Atoms
from ase.constraints import FixSymmetry
from ase.io import write as ase_write
from ase.units import GPa
from janus_core.calculations.geom_opt import GeomOpt
import numpy as np
import pandas as pd
from pymatgen.entries.computed_entries import ComputedStructureEntry
from pymatgen.io.ase import AseAtomsAdaptor
Expand Down Expand Up @@ -200,13 +202,17 @@ def relax_with_pressure(
converged = True
counter += 1
atoms = relaxed
except Exception as e:
print(f"Relaxation failed: {e}")
return None, False, None
except Exception as exc:
warn(f"Relaxation failed: {exc}", stacklevel=2)
return None, False, np.nan
if not converged:
return None, False, None
return None, False, np.nan
# Calculate enthalpy: H = E + PV
energy = relaxed.get_potential_energy()
try:
energy = relaxed.get_potential_energy()
except Exception as exc:
warn(f"Error calculating energy: {exc}", stacklevel=2)
energy = np.nan
volume = relaxed.get_volume()
enthalpy = energy + pressure_gpa * GPa * volume
n_atoms = len(relaxed)
Expand Down
Loading
Loading