Skip to content

Commit

Permalink
Adding pseudofamily in stepdata and using it for builders.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikibonacci committed Dec 4, 2024
1 parent 35d793f commit ad368a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
7 changes: 6 additions & 1 deletion src/aiida_koopmans/engine/aiida.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,17 @@ def get_pseudopotential(self, library: str, element: str):
qb.append(orm.Group, filters={'label': {'==': library}}, tag='pseudo_group')
qb.append(UpfData, filters={'attributes.element': {'==': element}}, with_group='pseudo_group')

print(qb.all())
pseudo_data = None
for pseudo in qb.all():
with tempfile.TemporaryDirectory() as dirpath:
temp_file = pathlib.Path(dirpath) / (pseudo[0].attributes['element'] + '.upf')
with pseudo[0].open(pseudo[0].attributes['element'] + '.upf', 'rb') as handle:
temp_file.write_bytes(handle.read())
pseudo_data = read_pseudo_file(temp_file)

if not pseudo_data:
raise ValueError(f"Could not find pseudopotential for element {element} in library {library}")

self.step_data['pseudo_family'] = library

return pseudo_data
25 changes: 3 additions & 22 deletions src/aiida_koopmans/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,6 @@ def get_PwBaseWorkChain_from_ase(pw_calculator, step_data=None):

load_profile()

"""
We should check automatically on the accepted keywords in PwCalculation and where are. Should be possible.
we suppose that the calculator has an attribute called mode e.g.
pw_calculator.parameters.mode = {
"pw_code": "pw-7.2-ok@localhost",
"metadata": {
"options": {
"max_wallclock_seconds": 3600,
"resources": {
"num_machines": 1,
"num_mpiprocs_per_machine": 1,
"num_cores_per_mpiproc": 1
},
"custom_scheduler_commands": "export OMP_NUM_THREADS=1"
}
}
}
"""
aiida_inputs = step_data['configuration']
calc_params = pw_calculator._parameters

Expand All @@ -81,12 +62,12 @@ def get_PwBaseWorkChain_from_ase(pw_calculator, step_data=None):
for k in pw_keys['electrons']:
if k in calc_params.keys() and k not in ALL_BLOCKED_KEYWORDS:
pw_overrides["ELECTRONS"][k] = calc_params[k]

builder = PwBaseWorkChain.get_builder_from_protocol(
code=aiida_inputs["pw_code"],
structure=structure,
overrides={
"pseudo_family": "PseudoDojo/0.4/LDA/SR/standard/upf", # TODO: automatic store of pseudos from koopmans folder, if not.
"pseudo_family": step_data["pseudo_family"], # TODO: automatic store of pseudos from koopmans folder, if not.
"pw": {"parameters": pw_overrides},
},
electronic_type=ElectronicType.INSULATOR,
Expand Down Expand Up @@ -152,7 +133,7 @@ def get_Wannier90BandsWorkChain_builder_from_ase(w90_calculator, step_data=None)
builder = Wannier90BandsWorkChain.get_builder_from_protocol(
codes=codes,
structure=nscf.inputs.pw.structure,
pseudo_family="PseudoDojo/0.4/LDA/SR/standard/upf",
pseudo_family=step_data["pseudo_family"],
protocol="moderate",
projection_type=WannierProjectionType.ANALYTIC,
print_summary=False,
Expand Down

0 comments on commit ad368a7

Please sign in to comment.