Skip to content

Commit

Permalink
Support get_str and get_string
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Feb 6, 2024
1 parent c61760c commit 8ad40e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion abipy/abio/tests/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def test_helper_functions(self):
assert inp["ndivsm"] == 3 and inp["iscf"] == -2 and len(inp["kptbounds"]) == 12

inp.set_kpath(ndivsm=-20)
assert inp["nkpt"] == 157 and inp["iscf"] == -2
assert inp["nkpt"] in (156, 157) and inp["iscf"] == -2

inp.set_qpath(ndivsm=3, qptbounds=None)
assert len(inp["ph_qpath"]) == 12 and inp["ph_nqpath"] == 12 and inp["ph_ndivsm"] == 3
Expand Down
5 changes: 4 additions & 1 deletion abipy/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,10 @@ def convert(self, fmt: str = "cif", **kwargs) -> str:
# Don't call super for poscar because we need more significant_figures to
# avoid problems with abinit space group routines where the default numerical tolerance is tight.
from pymatgen.io.vasp import Poscar
return Poscar(self).get_str(significant_figures=12)
try:
return Poscar(self).get_str(significant_figures=12)
except AttributeError:
return Poscar(self).get_string(significant_figures=12)
else:
return super().to(fmt=fmt, **kwargs)

Expand Down
2 changes: 2 additions & 0 deletions abipy/ml/aseml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,8 @@ def store_abi_forstr_atoms(self, abi_forces, abi_stress, atoms):
self.reset()
ml_forces = self.get_forces(atoms=atoms)
ml_stress = self.get_stress(atoms=atoms)
if ml_stress.ndim == 1:
ml_stress = voigt_6_to_full_3x3_strain(ml_stress)
self.reset()
self.__ml_forces_list.append(ml_forces)
self.__ml_stress_list.append(ml_stress)
Expand Down

0 comments on commit 8ad40e9

Please sign in to comment.