Skip to content

Commit

Permalink
Add bands measure and bands convergence workflow (#78)
Browse files Browse the repository at this point in the history
The bands measure workflow is added to run bandstructure of a typical structure of thi input pseudopotential. The output bands will then used to compare with other pseudopotentials.

Also a convergence workflow is added for bands convergence verification.
  • Loading branch information
unkcpz authored Mar 27, 2022
1 parent 414a240 commit d4ec99d
Show file tree
Hide file tree
Showing 25 changed files with 14,215 additions and 1,955 deletions.
65 changes: 16 additions & 49 deletions aiida_sssp_workflow/calculations/calculate_bands_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,8 @@
"""
import numpy as np
from aiida import orm
from aiida.engine import calcfunction


@calcfunction
def calculate_bands_distance(
bands_structure_a: orm.BandsData,
bands_parameters_a: orm.Dict,
bands_structure_b: orm.BandsData,
bands_parameters_b: orm.Dict,
smearing: orm.Float,
is_metal: orm.Bool,
):
"""doc"""
res = get_bands_distance(
bands_structure_a,
bands_structure_b,
bands_parameters_a,
bands_parameters_b,
smearing.value,
is_metal.value,
)

return orm.Dict(
dict={
"eta_v": res.get("eta_v", None),
"shift_v": res.get("shift_v", None),
"max_diff_v": res.get("max_diff_v", None),
"eta_10": res.get("eta_10", None),
"shift_10": res.get("shift_10", None),
"max_diff_10": res.get("max_diff_10", None),
"bands_unit": "eV",
}
)
from aiida_sssp_workflow.efermi import find_efermi


def get_homo(bands, num_electrons: int):
Expand Down Expand Up @@ -70,8 +39,6 @@ def retrieve_bands(
"""
docstring
"""
from efermi import pyefermi

bands = bandsdata.get_bands()
bands = bands - efermi # shift all bands to fermi energy 0
bands = bands[:, start_band:]
Expand All @@ -86,7 +53,7 @@ def retrieve_bands(
bands = np.asfortranarray(bands)
meth = 2 # firmi-dirac smearing

output_efermi = pyefermi(bands, weights, nelectrons, smearing, nkpoints, meth)
output_efermi = find_efermi(bands, weights, nelectrons, smearing, meth)

else:
homo_energy = get_homo(bands, num_electrons)
Expand Down Expand Up @@ -159,8 +126,9 @@ def get_bands_distance(
bands_b: orm.BandsData,
band_parameters_a: orm.Dict,
band_parameters_b: orm.Dict,
smearing,
is_metal,
smearing: float,
fermi_shift: float,
is_metal: bool,
):
"""
TODO docstring
Expand Down Expand Up @@ -197,36 +165,35 @@ def get_bands_distance(
efermi_b = res["efermi"]

# eta_v
fermi_shift = 0.0
fermi_shift_v = 0.0
if is_metal:
smearing_v = smearing
else:
smearing_v = 0

outputs = calculate_eta_and_max_diff(
bands_a, bands_b, efermi_a, efermi_b, fermi_shift, smearing_v
bands_a, bands_b, efermi_a, efermi_b, fermi_shift_v, smearing_v
)
eta_v = outputs.get("eta")
shift_v = outputs.get("shift")
max_diff_v = outputs.get("max_diff")

# eta_10
fermi_shift = 10.0
# eta_c
# if not metal
smearing_10 = smearing
smearing_c = smearing
outputs = calculate_eta_and_max_diff(
bands_a, bands_b, efermi_a, efermi_b, fermi_shift, smearing_10
bands_a, bands_b, efermi_a, efermi_b, fermi_shift, smearing_c
)

eta_10 = outputs.get("eta")
shift_10 = outputs.get("shift")
max_diff_10 = outputs.get("max_diff")
eta_c = outputs.get("eta")
shift_c = outputs.get("shift")
max_diff_c = outputs.get("max_diff")

return {
"eta_v": eta_v,
"shift_v": shift_v,
"max_diff_v": max_diff_v,
"eta_10": eta_10,
"shift_10": shift_10,
"max_diff_10": max_diff_10,
"eta_c": eta_c,
"shift_c": shift_c,
"max_diff_c": max_diff_c,
}
82 changes: 0 additions & 82 deletions aiida_sssp_workflow/cli/options.py

This file was deleted.

18 changes: 0 additions & 18 deletions aiida_sssp_workflow/cli/workflows/__init__.py

This file was deleted.

65 changes: 0 additions & 65 deletions aiida_sssp_workflow/cli/workflows/delta_measure.py

This file was deleted.

85 changes: 0 additions & 85 deletions aiida_sssp_workflow/cli/workflows/verification.py

This file was deleted.

3 changes: 2 additions & 1 deletion efermi/efermi.py → aiida_sssp_workflow/efermi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
POSHMA = -0.5634 # Positive Hermite (cold I) `a`


def pyefermi(
def find_efermi(
bands,
weights,
nelec: int,
Expand Down Expand Up @@ -75,6 +75,7 @@ def smear(bands, weights, xe: float, nelec: int, swidth: float, stype: int) -> f
for j in range(nbnd):
x = (xe - bands[i, j]) / swidth
z += weights[i] * sfuncs[stype - 1](x)

return z - nelec


Expand Down
Loading

0 comments on commit d4ec99d

Please sign in to comment.