Skip to content

Commit

Permalink
Replace F77 efermi with pure python efermi
Browse files Browse the repository at this point in the history
Build fortran code bring some unconvinients to package maintainance such
as failed in building docs in readthedocs since the docker image of
readthedocs contain no fortran compiler, and the problem of wired
setup.py setting to build and install the package.

I copy and paste the pure python efermi code from Austin to the package.
The performence not a big concern in this sssp-workflow, because it only
used in calculating the fermi level for metals and fermi level with
specific energy level shifts.
  • Loading branch information
unkcpz committed Oct 11, 2021
1 parent 78c797a commit cfc61d9
Show file tree
Hide file tree
Showing 25 changed files with 2,655 additions and 1,063 deletions.
10 changes: 0 additions & 10 deletions '

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
*.pyc
*.swo
*.swp
efermi_module*
~*
*~
*.pdf
Expand Down
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ repos:
language: system
exclude: &exclude_files >
(?x)^(
aiida_sssp_workflow/workflows/convergence/.*|
efermi/efermi.py|
aiida_sssp_workflow/helpers.py|
setup.py|
examples/.*|
docs/.*|
Expand Down
21 changes: 9 additions & 12 deletions aiida_sssp_workflow/calculations/calculate_bands_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

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

return orm.Dict(
Expand Down Expand Up @@ -59,11 +59,9 @@ def fermi_dirac(band_energy, fermi_energy, smearing):
def retrieve_bands(bandsdata: orm.BandsData, start_band, num_electrons, efermi,
smearing, is_metal):
"""
:bandsdata:
...
TODO docstring
docstring
"""
from sssp.efermi_module import efermi as efermi_calc # pylint: disable=no-name-in-module, import-error
from efermi import pyefermi

bands = bandsdata.get_bands()
bands = bands - efermi # shift all bands to fermi energy 0
Expand All @@ -75,14 +73,13 @@ def retrieve_bands(bandsdata: orm.BandsData, start_band, num_electrons, efermi,
if is_metal:
nelectrons = num_electrons
nkpoints = np.shape(bands)[0]
nbands = np.shape(bands)[1]
weights = np.ones(nkpoints) / nkpoints
bands = np.asfortranarray(bands)
meth = 2 # firmi-dirac smearing

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

# 2 for firmi-dirac smearing
res = efermi_calc(nelectrons, nbands, smearing, nkpoints, weights, 0.0,
bands, 2)
output_efermi = res[1]
else:
homo_energy = get_homo(bands, num_electrons)
output_efermi = homo_energy
Expand Down
Loading

0 comments on commit cfc61d9

Please sign in to comment.