From 73287ae6530c9a9501909737fcf33b5f0bba9ff0 Mon Sep 17 00:00:00 2001 From: Timothy Callow Date: Wed, 8 Nov 2023 16:16:35 +0100 Subject: [PATCH 1/2] Enforce log grid in Kubo-Greenwood class --- atoMEC/postprocess/conductivity.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/atoMEC/postprocess/conductivity.py b/atoMEC/postprocess/conductivity.py index 92fa40e..c4f9937 100644 --- a/atoMEC/postprocess/conductivity.py +++ b/atoMEC/postprocess/conductivity.py @@ -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: From cca4b9837605df799ed8954e800e50dadebe3264 Mon Sep 17 00:00:00 2001 From: Timothy Callow Date: Wed, 8 Nov 2023 16:50:54 +0100 Subject: [PATCH 2/2] Enforce log grid for gramschmidt --- atoMEC/staticKS.py | 9 ++++++++- tests/gramschmidt_test.py | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/atoMEC/staticKS.py b/atoMEC/staticKS.py index 4ad88b1..151a9d0 100644 --- a/atoMEC/staticKS.py +++ b/atoMEC/staticKS.py @@ -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. diff --git a/tests/gramschmidt_test.py b/tests/gramschmidt_test.py index 83e23c1..55d8e19 100644 --- a/tests/gramschmidt_test.py +++ b/tests/gramschmidt_test.py @@ -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 @@ -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, @@ -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) @@ -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"))