Skip to content

Commit a85b017

Browse files
committed
Refactor.
the input namespace for EpwCalculation is fully exposed in EpwBaseWorkChain. Related code and protocols are adapted for this change. EpwWorkChan is renamed as EpwPrepWorkChain. validations are stashed for next PR. A small validation of parameters are moved into EpwCalculation. comments are deleted. function `check_kpoints_compatibility` is moved into tools/kpoints.py
1 parent ba2d5f8 commit a85b017

11 files changed

Lines changed: 422 additions & 540 deletions

File tree

src/aiida_epw/calculations/epw.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,21 @@ def test_offset(offset):
207207
remote_list.append(
208208
(parent_folder_epw.computer.uuid, Path(epw_path, filename).as_posix(), Path(filename).as_posix())
209209
)
210+
# check if wannierize is True and if parent_folder_epw or parent_folder_chk is provided
211+
wannierize = parameters['INPUTEPW'].get('wannierize', False)
212+
213+
if wannierize and any(
214+
_ in self.inputs
215+
for _ in ["parent_folder_epw", "parent_folder_chk"]
216+
):
217+
self.report("Should not have a parent folder of epw or chk if wannierize is True")
218+
return self.exit_codes.ERROR_PARAMETERS_NOT_VALID
219+
220+
# check if nstemp is too large
221+
nstemp = parameters['INPUTEPW'].get('nstemp', None)
222+
if nstemp and nstemp > self._MAX_NSTEMP:
223+
self.report(f'nstemp too large, reset it to maximum allowed: {self._MAX_NSTEMP}')
224+
parameters['INPUTEPW']['nstemp'] = self._MAX_NSTEMP
210225

211226
parameters['INPUTEPW']['outdir'] = self._OUTPUT_SUBFOLDER
212227
parameters['INPUTEPW']['dvscf_dir'] = self._FOLDER_SAVE

src/aiida_epw/parsers/__init__.py

Whitespace-only changes.

src/aiida_epw/tools/calculators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ def calculate_lambda_omega(frequency: ArrayLike, spectrum: ArrayLike) -> tuple:
2727
omega_log = omega_log * meV_to_Kelvin
2828

2929
return lambda_, omega_log
30+
31+
# This function is taken from https://www.sciencedirect.com/science/article/pii/S0010465516302260 eq.81
32+
def bcs_gap_function(T, Tc, p, Delta_0):
33+
return Delta_0 * numpy.sqrt(1 - (T/Tc)**p)

src/aiida_epw/tools/kpoints.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def check_kpoints_qpoints_compatibility(
2+
kpoints,
3+
qpoints,
4+
) -> tuple[bool, str ]:
5+
"""Check if the kpoints and qpoints are compatible."""
6+
7+
kpoints_mesh, kpoints_shift = kpoints.get_kpoints_mesh()
8+
qpoints_mesh, qpoints_shift = qpoints.get_kpoints_mesh()
9+
10+
multiplicities = []
11+
remainder = []
12+
13+
for k, q in zip(kpoints_mesh, qpoints_mesh):
14+
multiplicities.append(k // q)
15+
remainder.append(k % q)
16+
17+
if kpoints_shift != [0.0, 0.0, 0.0] or qpoints_shift != [0.0, 0.0, 0.0]:
18+
return (False, "Shift grid is not supported.")
19+
else:
20+
if remainder == [0, 0, 0]:
21+
return (True, f"The kpoints and qpoints are compatible with multiplicities {multiplicities}.")
22+
else:
23+
return (False, "The kpoints and qpoints are not compatible.")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Workflows for the EPW code."""
2+
from .base import EpwBaseWorkChain
3+
from .prep import EpwPrepWorkChain
4+
from .supercon import SuperConWorkChain
5+
6+
__all__ = [
7+
'EpwBaseWorkChain',
8+
'EpwPrepWorkChain',
9+
'SuperConWorkChain',
10+
]

0 commit comments

Comments
 (0)