Skip to content

Commit

Permalink
Merge pull request #221 from timcallow/enforce_log_grid
Browse files Browse the repository at this point in the history
Enforce log grid
  • Loading branch information
timcallow authored Nov 8, 2023
2 parents c2ee55b + cca4b98 commit 1ac1ec1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions atoMEC/postprocess/conductivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def __init__(self, Atom, model, orbitals, valence_orbs=[], nmax=0, lmax=0):
"Kubo-Greenwood is not yet set-up for spin-polarized calculations. \
Please run again with spin-unpolarized input."
)

if orbitals.grid_type != "log":
sys.exit(
"Sqrt grid is not yet supported for Kubo-Greenwood calculations."
"Please switch to log grid."
)
if nmax == 0:
self._nmax = nmax_default
else:
Expand Down
9 changes: 8 additions & 1 deletion atoMEC/staticKS.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,17 @@ def calc_entropy(self, orbs):
class GramSchmidt:
"""Class holding Gram-Schmidt orthoganalization process."""

def __init__(self, eigfuncs, xgrid):
def __init__(self, eigfuncs, xgrid, grid_type):
self._eigfuncs = eigfuncs
self._xgrid = xgrid

# check grid is logarithmic
if grid_type != "log":
raise check_inputs.InputError.grid_error(
"Sqrt grid is not yet supported for Gram-Schmidt procedure."
"Please switch to log grid."
)

def make_ortho(self):
"""
Make eigenfunctions orthonormal using Gram-Schmidt orthoganalization.
Expand Down
6 changes: 4 additions & 2 deletions tests/gramschmidt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
integrals and perform Gram-Schmidt orthonormalization.
"""

from atoMEC import Atom, models, staticKS
from atoMEC import Atom, models, staticKS, config
import pytest
from pytest_lazyfixture import lazy_fixture
import numpy as np
Expand Down Expand Up @@ -34,6 +34,7 @@ def SCF_output(self):
)
def test_overlap(self, input_SCF, case, expected):
"""Run overlap integral after orthonormalizatation."""
config.grid_type = "log"
assert np.isclose(
self._run_overlap(input_SCF, case),
expected,
Expand Down Expand Up @@ -88,7 +89,7 @@ def _run_overlap(input_SCF, case):
"""
xgrid = input_SCF["orbitals"]._xgrid
GS = staticKS.GramSchmidt(input_SCF["orbitals"].eigfuncs, xgrid)
GS = staticKS.GramSchmidt(input_SCF["orbitals"].eigfuncs, xgrid, "log")
ortho = GS.make_ortho()
if case == "self":
norm = GS.prod_eigfuncs(ortho[0, 0, 0, 1], ortho[0, 0, 0, 1], xgrid)
Expand All @@ -99,6 +100,7 @@ def _run_overlap(input_SCF, case):


if __name__ == "__main__":
config.grid_type = "log"
SCF_out = TestGS._run_SCF()
print("self_overlap_expected =", TestGS._run_overlap(SCF_out, "self"))
print("overlap_expected =", TestGS._run_overlap(SCF_out, "other"))

0 comments on commit 1ac1ec1

Please sign in to comment.