Handling Inputs and Namespaces for Quantum ESPRESSO WorkChain

19 views
Skip to first unread message

daniel....@gmail.com

unread,
May 19, 2023, 8:37:34 AM5/19/23
to aiidausers
Dear [Mailing List],

I hope this message finds you all well. I am seeking some guidance on a particular issue I have encountered while using the Quantum ESPRESSO's relax WorkChain in AiiDA.

In my code, I set up and submit inputs to the Quantum ESPRESSO relax WorkChain as follows:

WorkChain = WorkflowFactory('quantumespresso.pw.relax')
inputs.update(relax_inputs)
inputs['structure'] = structure
inputs['base']['pseudo_family'] = Str(pseudo_familyname)
inputs['base']['kpoints'] = kpoints
if calc_method == 'relax':
    inputs['relaxation_scheme'] = Str('relax')
    parameters = wf_delete_vccards(parameters)
    inputs['base']['pw']['parameters'] = parameters
elif calc_method == 'vc-relax':
    inputs['relaxation_scheme'] = Str('vc-relax')
    inputs['base']['pw']['parameters'] = parameters

I've recently run into a problem: the relaxation_scheme is no longer recognized as an input. I think this could be related to some changes in how the WorkChain handles inputs, but I'm not completely sure.

I've gone through the source code for the PwRelaxWorkChain, but I'm still unclear on how to correctly define the relaxation scheme in the inputs. Below is the part of the source code I was reviewing:

class PwRelaxWorkChain(ProtocolMixin, WorkChain):
    """Workchain to relax a structure using Quantum ESPPRESSO pw.x."""

    @classmethod
    def define(cls, spec):
        """Define the process specification."""
        ...
        spec.input('structure', valid_type=orm.StructureData, help='The inputs structure.')
        spec.input('meta_convergence', valid_type=orm.Bool, default=lambda: orm.Bool(True),
            help='If `True` the workchain will perform a meta-convergence on the cell volume.')
        ...

Additionally, I noticed in common/types.py a RelaxType enumeration:

class RelaxType(enum.Enum):
    """Enumeration of known relax types."""

    NONE = 'none'  # All degrees of freedom are fixed, essentially performs single point SCF calculation
    POSITIONS = 'positions'  # Only the atomic positions are relaxed, cell is fixed
    VOLUME = 'volume'  # Only the cell volume is optimized, cell shape and atoms are fixed
    SHAPE = 'shape'  # Only the cell shape is optimized at a fixed volume and fixed atomic positions
    CELL = 'cell'  # Only the cell is optimized, both shape and volume, while atomic positions are fixed
    POSITIONS_VOLUME = 'positions_volume'  # Same as `VOLUME` but atomic positions are relaxed as well
    POSITIONS_SHAPE = 'positions_shape'  # Same as `SHAPE`  but atomic positions are relaxed as well
    POSITIONS_CELL = 'positions_cell'  # Same as `CELL`  but atomic positions are relaxed as well

I believe this could be related to specifying the relaxation scheme, but I am not exactly sure how to use these types.

My question is, what is the correct way to include the relaxation scheme in the inputs now? Are there recent changes that could be affecting the input handling? How do I use the RelaxType enumeration in specifying my relaxation scheme?

Any insights or suggestions would be greatly appreciated. I am also open to further discussion or providing more context if needed.

Thank you in advance for your time and assistance.

Best regards,

Daniel 

Timo Reents

unread,
May 19, 2023, 12:49:53 PM5/19/23
to aiida...@googlegroups.com

Hi Daniel,

the 'relaxation_scheme' input was removed in the following commit: https://github.com/aiidateam/aiida-quantumespresso/commit/a23f802e17bb91cc25e8b9855dd3ccfa92f2f764#diff-4a581d9b5aa384062057a1dedbd5b18c5e1e58bbd5cb5f1e9373377dcf0ec303

You can just specify it via the 'CONTROL' key in the parameters namespace as you would do it in a manual calculation.

    inputs['base']['pw']['parameters']['CONTROL'['calculation'] = 'vc-relax'  (or 'relax')

In case you use the 'get_builder_from_protocol' method, you would specify it via the 'RelaxType' enum which you already mentioned. An example:


    from aiida_quantumespresso.common.types import RelaxType

    WorkChain = WorkflowFactory('quantumespresso.pw.relax')

    builder = WorkChain.get_builder_from_protocol(code, structure, protocol=None, overrides=None, relax_type=RelaxType.POSITIONS_CELL)

Of course, you can also use all other options that are listed in the RelaxType source code.


Best,

Timo

--
AiiDA is supported by the NCCR MARVEL (http://nccr-marvel.ch/), funded by the Swiss National Science Foundation, and by the European H2020 MaX Centre of Excellence (http://www.max-centre.eu/).
 
Before posting your first question, please see the posting guidelines at http://www.aiida.net/?page_id=356 .
---
You received this message because you are subscribed to the Google Groups "aiidausers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aiidausers+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aiidausers/f758bb0a-7912-4dc3-b8d6-c87c00a3f469n%40googlegroups.com.

mbe...@gmail.com

unread,
May 20, 2023, 1:01:26 PM5/20/23
to aiidausers

Hi Daniel and Timo! 👋

Thanks Timo for taking the time to respond! Indeed, the relaxation_scheme was already deprecated since version 3.3.0 and fully removed in version 4.0.0. However, the removal was not diligently reported as a breaking change in the CHANGELOG.md, many apologies. 🙈

To make up for this most egregious oversight, I’ve opened a PR to add some basic documentation how to use the PwRelaxWorkChain and define a RelaxType. Have a look, comments most welcome!

Happy computing! 🚀

Best,
Marnik

Reply all
Reply to author
Forward
0 new messages