Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce log grid #221

Merged
merged 2 commits into from
Nov 8, 2023
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
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 @@
"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(

Check warning on line 49 in atoMEC/postprocess/conductivity.py

View check run for this annotation

Codecov / codecov/patch

atoMEC/postprocess/conductivity.py#L49

Added line #L49 was not covered by tests
"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 @@
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(

Check warning on line 1678 in atoMEC/staticKS.py

View check run for this annotation

Codecov / codecov/patch

atoMEC/staticKS.py#L1678

Added line #L1678 was not covered by tests
"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"))