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

Make Methfessel Paxton default in SPHInX #416

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
32 changes: 22 additions & 10 deletions pyiron_atomistics/sphinx/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def load_default_input(self):
self.input.KpointCoords = [0.5, 0.5, 0.5]
self.input.KpointFolding = [4, 4, 4]
self.input.EmptyStates = "auto"
self.input.MethfesselPaxton = 1
self.input.Sigma = 0.2
self.input.Xcorr = "PBE"
self.input.VaspPot = False
Expand Down Expand Up @@ -522,10 +523,14 @@ def load_hamilton_group(self):
"""
self.input.sphinx.PAWHamiltonian.setdefault(
"nEmptyStates", self.input["EmptyStates"]
)
)
self.input.sphinx.PAWHamiltonian.setdefault(
"ekt", self.input["Sigma"]
)
)
for k in ['MethfesselPaxton', 'FermiDirac']:
if k in self.input.list_nodes():
self.input.sphinx.PAWHamiltonian.setdefault(k, self.input[k])
break
self.input.sphinx.PAWHamiltonian.setdefault("xc", self.input["Xcorr"])
self.input.sphinx.PAWHamiltonian["spinPolarized"] = self._spin_enabled

Expand Down Expand Up @@ -965,20 +970,27 @@ def set_mixing_parameters(
+ set_mixing_parameters.__doc__
)

def set_occupancy_smearing(self, smearing=None, width=None):
def set_occupancy_smearing(self, smearing=None, width=None, order=1):
"""
Set how the finite temperature smearing is applied in
determining partial occupancies

Args:
smearing (str): Type of smearing (only fermi is
implemented anything else will be ignored)
smearing (str): Type of smearing, 'FermiDirac' or 'MethfesselPaxton'
width (float): Smearing width (eV) (default: 0.2)
"""
if smearing is not None and not isinstance(smearing, str):
raise ValueError(
"Smearing must be a string"
)
order (int): Smearing order
"""
if smearing is not None:
if not isinstance(smearing, str):
raise ValueError("Smearing must be a string")
if smearing.lower().startswith('meth'):
self.input.MethfesselPaxton = order
if 'FermiDirac' in self.input.list_nodes():
del self.input['FermiDirac']
elif smearing.lower().startswith('fermi'):
self.input.FermiDirac = order
if 'MethfesselPaxton' in self.input.list_nodes():
del self.input['MethfesselPaxton']
if width is not None and width < 0:
raise ValueError("Smearing value must be a float >= 0")
if width is not None:
Expand Down
4 changes: 4 additions & 0 deletions tests/sphinx/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_write_input(self):
'PAWHamiltonian {\n',
'\tnEmptyStates = 6;\n',
'\tekt = 0.2;\n',
'\tMethfesselPaxton = 1;\n',
'\txc = PBE;\n',
'\tspinPolarized;\n',
'}\n',
Expand Down Expand Up @@ -386,6 +387,9 @@ def test_set_occupancy_smearing(self):
ValueError, self.sphinx_band_structure.set_occupancy_smearing, "fermi", -0.1
)
self.sphinx_band_structure.set_occupancy_smearing("fermi", 0.1)
self.assertTrue('FermiDirac' in self.sphinx_band_structure.input)
self.sphinx_band_structure.set_occupancy_smearing("methfessel", 0.1)
self.assertTrue('MethfesselPaxton' in self.sphinx_band_structure.input)

def test_load_default_groups(self):
backup = self.sphinx_band_structure.structure.copy()
Expand Down