|
5 | 5 | from aiida import orm |
6 | 6 | from aiida import plugins |
7 | 7 |
|
8 | | -from aiida_common_workflows.common import ElectronicType, RelaxType, SpinType |
| 8 | +from aiida_common_workflows.common import ElectronicType, RelaxType, SpinType, SmearingMethodType, XcFunctionalType |
9 | 9 | from aiida_common_workflows.generators import ChoiceType, InputGenerator |
10 | 10 |
|
11 | 11 | __all__ = ('CommonRelaxInputGenerator',) |
@@ -109,3 +109,65 @@ def define(cls, spec): |
109 | 109 | required=False, |
110 | 110 | help='Options for the geometry optimization calculation jobs.', |
111 | 111 | ) |
| 112 | + |
| 113 | + |
| 114 | +class CommonDftRelaxInputGenerator(CommonRelaxInputGenerator, metaclass=abc.ABCMeta): |
| 115 | + """Input generator for the common relax workflow. |
| 116 | +
|
| 117 | + .. note:: This class is a subclass of the ``CommonRelaxInputGenerator`` but defines some additional inputs that are |
| 118 | + common to a number of implementations. |
| 119 | +
|
| 120 | + This class should be subclassed by implementations for specific quantum engines. After calling the super, they can |
| 121 | + modify the ports defined here in the base class as well as add additional custom ports. |
| 122 | + """ |
| 123 | + |
| 124 | + @staticmethod |
| 125 | + def validate_kpoints_shift(value, _): |
| 126 | + """Validate the ``kpoints_shift`` input.""" |
| 127 | + if not isinstance(value, list) or len(value) != 3 or any(not isinstance(element, float) for element in value): |
| 128 | + return f'The `kpoints_shift` argument should be a list of three floats, but got: `{value}`.' |
| 129 | + |
| 130 | + @classmethod |
| 131 | + def define(cls, spec): |
| 132 | + """Define the specification of the input generator. |
| 133 | +
|
| 134 | + The ports defined on the specification are the inputs that will be accepted by the ``get_builder`` method. |
| 135 | + """ |
| 136 | + super().define(spec) |
| 137 | + spec.input( |
| 138 | + 'kpoints_distance', |
| 139 | + valid_type=float, |
| 140 | + required=False, |
| 141 | + help='The desired minimum distance between k-points in reciprocal space in 1/Å. The implementation will' |
| 142 | + 'guarantee that a k-point mesh is generated for which the distances between all adjacent k-points along ' |
| 143 | + 'each cell vector are at most this distance. It is therefore possible that the distance is smaller than ' |
| 144 | + 'requested along certain directions.', |
| 145 | + ) |
| 146 | + spec.input( |
| 147 | + 'kpoints_shift', |
| 148 | + valid_type=list, |
| 149 | + validator=cls.validate_kpoints_shift, |
| 150 | + required=False, |
| 151 | + help='Optional shift to apply to all k-points of the k-point mesh. Should be a list of three floats where ' |
| 152 | + 'each float is a number between 0 and 1.', |
| 153 | + ) |
| 154 | + spec.input( |
| 155 | + 'smearing_method', |
| 156 | + valid_type=SmearingMethodType, |
| 157 | + serializer=SmearingMethodType, |
| 158 | + default=SmearingMethodType.GAUSSIAN, |
| 159 | + help='The method to use for the smearing of the electronic occupations.', |
| 160 | + ) |
| 161 | + spec.input( |
| 162 | + 'smearing_broadening', |
| 163 | + valid_type=float, |
| 164 | + required=False, |
| 165 | + help='The broadening of the smearing in eV.', |
| 166 | + ) |
| 167 | + spec.input( |
| 168 | + 'functional', |
| 169 | + valid_type=XcFunctionalType, |
| 170 | + serializer=XcFunctionalType, |
| 171 | + default=XcFunctionalType.PBE, |
| 172 | + help='The functional for the exchange-correlation to be used.', |
| 173 | + ) |
0 commit comments