Skip to content

Commit

Permalink
Fix for input units None and incorrect units for density
Browse files Browse the repository at this point in the history
  • Loading branch information
timcallow committed Oct 24, 2024
1 parent 055b5aa commit 063c01d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mala/targets/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,12 @@ def read_from_cube(self, path, units="1/Bohr^3", **kwargs):
Units the density is saved in. Usually none.
"""
printout("Reading density from .cube file ", path, min_verbosity=0)
if units != "1/(Ry*Bohr^3)":
# automatically convert units if they are None since cube files take atomic units
if units is None:
units="1/Bohr^3"
if units != "1/Bohr^3":
printout(
"The expected units for the LDOS from cube files are 1/(Ry*Bohr^3)\n"
"The expected units for the density from cube files are 1/Bohr^3\n"
f"Proceeding with specified units of {units}\n"
"We recommend to check and change the requested units"
)
Expand Down
3 changes: 3 additions & 0 deletions mala/targets/ldos.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ def read_from_cube(
# tmp.pp003ELEMENT_ldos.cube
# ...
# tmp.pp100ELEMENT_ldos.cube
# automatically convert units if they are None since cube files take atomic units
if units is None:
units = "1/(Ry*Bohr^3)"
if units != "1/(Ry*Bohr^3)":
printout(
"The expected units for the LDOS from cube files are 1/(Ry*Bohr^3)\n"
Expand Down

0 comments on commit 063c01d

Please sign in to comment.