From cca7ee0e6e5691b8436b4535be804b10c5fef61a Mon Sep 17 00:00:00 2001 From: Timothy Callow Date: Thu, 3 Mar 2022 16:47:46 +0100 Subject: [PATCH 1/2] make a MIS property for the Density object --- atoMEC/staticKS.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/atoMEC/staticKS.py b/atoMEC/staticKS.py index 20350286..78fb0287 100644 --- a/atoMEC/staticKS.py +++ b/atoMEC/staticKS.py @@ -619,6 +619,8 @@ def __init__(self, orbs): "N": np.zeros((config.spindims)), } + self._MIS = 0.0 + self._orbs = orbs @property @@ -655,6 +657,13 @@ def unbound(self): self._unbound = self.construct_rho_unbound() return self._unbound + @property + def MIS(self): + """ndarray: the mean ionization state.""" + occs_pos = np.where(self._orbs.eigvals > 0, self._orbs.occnums_w, 0) + self._MIS = np.sum(occs_pos, axis=(0, 2, 3)) + self.unbound["N"] + return self._MIS + @staticmethod def construct_rho_orbs(eigfuncs, occnums, xgrid): """ From d9dfbf25b490a28928b55e0f3354a2d8e143fd31 Mon Sep 17 00:00:00 2001 From: Timothy Callow Date: Thu, 3 Mar 2022 19:21:02 +0100 Subject: [PATCH 2/2] Call Density.MIS in writeoutput instead of recalculating --- atoMEC/writeoutput.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/atoMEC/writeoutput.py b/atoMEC/writeoutput.py index 4dedcfa6..203b1569 100644 --- a/atoMEC/writeoutput.py +++ b/atoMEC/writeoutput.py @@ -282,8 +282,7 @@ def write_final(self, energy, orbitals, density, conv_vals): output_str += self.write_final_energies(energy) + spc # write the chemical potential and mean ionization state - occs_pos = np.where(orbitals.eigvals > 0, orbitals.occnums_w, 0) - N_ub = np.sum(occs_pos, axis=(0, 2, 3)) + density.unbound["N"] + N_ub = density.MIS if config.spindims == 2: mu_str = "Chemical potential (u/d)"