Skip to content

Commit

Permalink
Fix implementation for BigDFT
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber committed Feb 19, 2024
1 parent af83379 commit 4d8d95e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
34 changes: 16 additions & 18 deletions aiida_common_workflows/workflows/relax/bigdft/generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Implementation of `aiida_common_workflows.common.relax.generator.CommonRelaxInputGenerator` for BigDFT."""
from aiida import engine, orm, plugins
from aiida import engine, plugins

from aiida_common_workflows.common import ElectronicType, RelaxType, SpinType
from aiida_common_workflows.generators import ChoiceType, CodeType
Expand Down Expand Up @@ -176,18 +176,10 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:

builder = self.process_class.get_builder()

if relax_type == RelaxType.POSITIONS:
relaxation_schema = 'relax'
elif relax_type == RelaxType.NONE:
relaxation_schema = 'relax'
builder.relax.perform = orm.Bool(False)
else:
raise ValueError(f'relaxation type `{relax_type.value}` is not supported')

builder.structure = structure
builder.BigDFT.structure = structure

# for now apply simple stupid heuristic : atoms < 200 -> cubic, else -> linear.
if len(builder.structure.sites) <= 200:
if len(builder.BigDFT.structure.sites) <= 200:
inputdict = copy.deepcopy(self.get_protocol(protocol)['inputdict_cubic'])
else:
inputdict = copy.deepcopy(self.get_protocol(protocol)['inputdict_linear'])
Expand All @@ -200,7 +192,7 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
else:
hgrids = logfile.get('dft').get('hgrids')
first_hgrid = hgrids[0] if isinstance(hgrids, list) else hgrids
inputdict['dft']['hgrids'] = first_hgrid * builder.structure.cell_lengths[0] / \
inputdict['dft']['hgrids'] = first_hgrid * builder.BigDFT.structure.cell_lengths[0] / \
reference_workchain.inputs.structure.cell_lengths[0]

if electronic_type is ElectronicType.METAL:
Expand All @@ -227,12 +219,18 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
if self.get_protocol(protocol).get('kpoints_distance'):
inputdict['kpt'] = {'method': 'auto', 'kptrlen': self.get_protocol(protocol).get('kpoints_distance')}

builder.parameters = BigDFTParameters(dict=inputdict)
builder.code = engines[relaxation_schema]['code']
run_opts = {'options': engines[relaxation_schema]['options']}
builder.run_opts = orm.Dict(dict=run_opts)
if relax_type == RelaxType.POSITIONS:
inputdict['geopt'] = {
'method': 'FIRE',
'forcemax': threshold_forces or 0,
}
elif relax_type == RelaxType.NONE:
pass
else:
raise ValueError(f'relaxation type `{relax_type.value}` is not supported')

if threshold_forces is not None:
builder.relax.threshold_forces = orm.Float(threshold_forces)
builder.BigDFT.parameters = BigDFTParameters(dict=inputdict)
builder.BigDFT.code = engines['relax']['code']
builder.BigDFT.metadata = {'options': engines['relax']['options']}

return builder
2 changes: 1 addition & 1 deletion aiida_common_workflows/workflows/relax/bigdft/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class BigDftCommonRelaxWorkChain(CommonRelaxWorkChain):
"""Implementation of `aiida_common_workflows.common.relax.workchain.CommonRelaxWorkChain` for BigDFT."""

_process_class = WorkflowFactory('bigdft.relax')
_process_class = WorkflowFactory('bigdft')
_generator_class = BigDftCommonRelaxInputGenerator

@classmethod
Expand Down

0 comments on commit 4d8d95e

Please sign in to comment.