Skip to content

Commit

Permalink
Unit of loading Potentialfield (#307)
Browse files Browse the repository at this point in the history
* Add one line

* Longer printing with structure.py

* removed empty line

* Patched dimensions of potential fields

* Modified the test accordingly

---------

Co-authored-by: Tom van Waas <[email protected]>
  • Loading branch information
TeetotalingTom and Tom van Waas authored Dec 22, 2024
1 parent 1eaf333 commit 8782929
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions abipy/core/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import numpy as np
import pandas as pd
import pymatgen.core.units as pmgu
import typing

from collections import OrderedDict
Expand All @@ -15,7 +14,7 @@
from monty.string import is_string, marquee
from monty.termcolor import cprint
from monty.inspect import all_subclasses
from pymatgen.core.units import bohr_to_angstrom
from pymatgen.core.units import bohr_to_angstrom, Ha_to_eV
from abipy.core.structure import Structure
from abipy.core.mesh3d import Mesh3D
from abipy.core.func1d import Function1D
Expand Down Expand Up @@ -1180,9 +1179,9 @@ def read_denpot(self, varname, field_cls):

# Structure uses Angstrom. Abinit uses Bohr.
if issubclass(field_cls, _DensityField):
fact = 1 / pmgu.bohr_to_angstrom ** 3
fact = 1 / bohr_to_angstrom ** 3
if issubclass(field_cls, _PotentialField):
fact = pmgu.Ha_to_eV / pmgu.bohr_to_angstrom ** 3
fact = Ha_to_eV

datar *= fact

Expand Down
2 changes: 1 addition & 1 deletion abipy/core/tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def test_potentials(self):
assert not vxc.is_density_like
assert vxc.is_potential_like
#assert vxc.datar.dtype == np.float
fact = pmgu.Ha_to_eV / pmgu.bohr_to_angstrom ** 3
fact = pmgu.Ha_to_eV
self.assert_almost_equal(vxc.datar[0, 0, 0, 0], -2.40411892342838 * fact)
self.assert_almost_equal(vxc.datar[0, 0, 0, 1], -2.31753083824603 * fact)

Expand Down

0 comments on commit 8782929

Please sign in to comment.