Skip to content

Commit 1e268db

Browse files
committed
Added PseudoDojo protocols for CASTEP
1 parent bb9090a commit 1e268db

File tree

3 files changed

+159
-4
lines changed

3 files changed

+159
-4
lines changed

aiida_common_workflows/workflows/relax/castep/generator.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from aiida.common import exceptions
1111
from aiida_castep.data import get_pseudos_from_structure
1212
from aiida_castep.data.otfg import OTFGGroup
13+
from aiida_pseudo.groups.family.pseudo_dojo import PseudoDojoFamily
14+
import numpy as np
1315
import yaml
1416

1517
from aiida_common_workflows.common import ElectronicType, RelaxType, SpinType
@@ -49,7 +51,16 @@ def define(cls, spec):
4951
super().define(spec)
5052
spec.input(
5153
'protocol',
52-
valid_type=ChoiceType(('fast', 'moderate', 'precise', 'verification-PBE-v1', 'verification-PBE-v1-a0')),
54+
valid_type=ChoiceType((
55+
'fast',
56+
'moderate',
57+
'precise',
58+
'verification-PBE-v1',
59+
'verification-PBE-v1-a0',
60+
'verification-PBE-v1-dojo-a0',
61+
'verification-PBE-v1-dojo-a1',
62+
'verification-PBE-v1-qc5-a0',
63+
)),
5364
default='moderate',
5465
help='The protocol to use for the automated input generation. This value indicates the level of precision '
5566
'of the results and computational cost that the input parameters will be selected for.',
@@ -183,7 +194,28 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
183194

184195
# Ensure the pseudopotential family requested does exist
185196
pseudos_family = protocol['relax']['base']['pseudos_family']
186-
ensure_otfg_family(pseudos_family)
197+
198+
# Set up pseudopotentials
199+
try:
200+
pseudo_group = orm.Group.objects.get(label=pseudos_family)
201+
except exceptions.NotExistent:
202+
# No family found - make this family if possible
203+
ensure_otfg_family(pseudos_family)
204+
else:
205+
# If we are using a family from aiida-pseudos, set the cut off energy accordingly
206+
if isinstance(pseudo_group, PseudoDojoFamily):
207+
# Using aiida_pseudo interface
208+
# In this case we also have to set the cut off energy based on the protocol,
209+
# as CASTEP cannot infer default
210+
# basis-related settings
211+
cutoff, _ = pseudo_group.get_recommended_cutoffs(
212+
structure=structure, stringency=protocol['cutoff_stringency'], unit='eV'
213+
)
214+
cutoff = np.ceil(cutoff)
215+
if not param:
216+
override['base']['calc']['parameters'] = {}
217+
override['base']['calc']['parameters']['cut_off_energy'] = cutoff
218+
override['base']['calc']['parameters'].pop('basis_precision', None)
187219

188220
builder = self.process_class.get_builder()
189221
inputs = generate_inputs(self.process_class._process_class, protocol, code, structure, override) # pylint: disable=protected-access
@@ -252,11 +284,12 @@ def generate_inputs(
252284
# pylint: disable=too-many-arguments,unused-argument
253285
from aiida.common.lang import type_check
254286

287+
# Sanity checks for the pseudofamily
255288
family_name = protocol['relax']['base']['pseudos_family']
256289
if isinstance(family_name, orm.Str):
257290
family_name = family_name.value
258291
try:
259-
otfg_family = OTFGGroup.objects.get(label=family_name)
292+
otfg_family = orm.Group.objects.get(label=family_name)
260293
except exceptions.NotExistent as exc:
261294
raise ValueError(
262295
'protocol `{}` requires the `{}` `pseudos family` but could not be found.'.format(

aiida_common_workflows/workflows/relax/castep/protocol.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,89 @@ verification-PBE-v1-a0:
125125
ADDITIONAL_RETRIEVE_TEMPORARY_LIST: ["aiida.castep_bin"]
126126

127127

128+
verification-PBE-v1-dojo-a0:
129+
name: 'verification-PBE-dojo-a0'
130+
description: 'Protocol for the oxides validation study using PseudoDojo.'
131+
cutoff_stringency: "high"
132+
relax:
133+
relax_options:
134+
max_meta_iterations: 5
135+
136+
base:
137+
pseudos_family: 'PseudoDojo/0.4/PBE/SR/standard/upf'
138+
max_iterations: 5
139+
kpoints_spacing: 0.06 # K point spacing in A^-1, not the A^-1 2Pi that CASTEP defaults to
140+
ensure_gamma_centering: True # Ensure that the kpoint grid is Gamma-centered
141+
calc:
142+
parameters:
143+
task: geometryoptimisation
144+
xc_functional: pbe
145+
symmetry_generate: true
146+
snap_to_symmetry: true
147+
calculate_stress: true
148+
# This cut off energy has no effect as the cutoff_stringency takes the precedence
149+
# The actual cut off energy used depends on the speices involved in the calculation
150+
cut_off_energy: 800
151+
write_otfg: false
152+
opt_strategy: speed
153+
write_bib: false
154+
write_checkpoint: minimal
155+
finite_basis_corr: none # No finite basis corr as we are NOT moving any atoms....
156+
max_scf_cycles: 100
157+
elec_energy_tol: 1e-8
158+
geom_force_tol: 0.03
159+
geom_energy_tol: 1.0e-5
160+
geom_stress_tol: 0.05
161+
grid_scale: 2
162+
# Revised smearing scheme for the oxide validation project
163+
smearing_width: 0.06122561905370023 # Equivalent to 0.0045 Ry
164+
smearing_scheme: FERMIDIRAC
165+
perc_extra_bands: 80
166+
settings:
167+
ADDITIONAL_RETRIEVE_TEMPORARY_LIST: ["aiida.castep_bin"]
168+
169+
verification-PBE-v1-dojo-a1:
170+
name: 'verification-PBE-dojo-a1'
171+
description: 'Protocol for the oxides validation study using PseudoDojo.'
172+
cutoff_stringency: "high"
173+
relax:
174+
relax_options:
175+
max_meta_iterations: 5
176+
177+
base:
178+
pseudos_family: 'PseudoDojo/0.4/PBE/SR/standard/upf'
179+
max_iterations: 5
180+
kpoints_spacing: 0.06 # K point spacing in A^-1, not the A^-1 2Pi that CASTEP defaults to
181+
ensure_gamma_centering: True # Ensure that the kpoint grid is Gamma-centered
182+
calc:
183+
parameters:
184+
task: geometryoptimisation
185+
xc_functional: pbe
186+
symmetry_generate: true
187+
snap_to_symmetry: true
188+
calculate_stress: true
189+
# This cut off energy has no effect as the cutoff_stringency takes the precedence
190+
# The actual cut off energy used depends on the speices involved in the calculation
191+
cut_off_energy: 800
192+
write_otfg: false
193+
opt_strategy: speed
194+
write_bib: false
195+
write_checkpoint: minimal
196+
finite_basis_corr: none # No finite basis corr as we are NOT moving any atoms....
197+
max_scf_cycles: 100
198+
elec_energy_tol: 1e-8
199+
geom_force_tol: 0.03
200+
geom_energy_tol: 1.0e-5
201+
geom_stress_tol: 0.05
202+
grid_scale: 2
203+
fine_grid_scale: 4 # Include a finer charge grid, despite normal converging potentials
204+
# Revised smearing scheme for the oxide validation project
205+
smearing_width: 0.06122561905370023 # Equivalent to 0.0045 Ry
206+
smearing_scheme: FERMIDIRAC
207+
perc_extra_bands: 80
208+
settings:
209+
ADDITIONAL_RETRIEVE_TEMPORARY_LIST: ["aiida.castep_bin"]
210+
128211
verification-PBE-v1:
129212
name: 'verification-PBE-v1'
130213
description: 'Protocol for the oxides validation study.'
@@ -163,3 +246,42 @@ verification-PBE-v1:
163246
perc_extra_bands: 80
164247
settings:
165248
ADDITIONAL_RETRIEVE_TEMPORARY_LIST: ["aiida.castep_bin"]
249+
250+
verification-PBE-v1-qc5-a0:
251+
name: 'verification-PBE-v1-qc5-a0'
252+
description: 'Protocol for the oxides validation study, but using the QC5 pseudopotential'
253+
relax:
254+
relax_options:
255+
max_meta_iterations: 5
256+
257+
base:
258+
pseudos_family: 'QC5'
259+
max_iterations: 5
260+
kpoints_spacing: 0.06 # K point spacing in A^-1, not the A^-1 2Pi that CASTEP defaults to
261+
ensure_gamma_centering: True # Ensure that the kpoint grid is Gamma-centered
262+
calc:
263+
parameters:
264+
task: geometryoptimisation
265+
xc_functional: pbe
266+
symmetry_generate: true
267+
snap_to_symmetry: true
268+
calculate_stress: true
269+
cut_off_energy: 400 # Fixed cut off energy for handling both unaries and oxides, for QC5 it should be more than enough
270+
write_otfg: false
271+
opt_strategy: speed
272+
write_bib: false
273+
write_checkpoint: minimal
274+
finite_basis_corr: none # No finite basis corr as we are NOT moving any atoms....
275+
max_scf_cycles: 100
276+
elec_energy_tol: 1e-8
277+
geom_force_tol: 0.03
278+
geom_energy_tol: 1.0e-5
279+
geom_stress_tol: 0.05
280+
grid_scale: 2
281+
fine_grid_scale : 3
282+
# Revised smearing scheme for the oxide validation project
283+
smearing_width: 0.06122561905370023 # Equivalent to 0.0045 Ry
284+
smearing_scheme: FERMIDIRAC
285+
perc_extra_bands: 80
286+
settings:
287+
ADDITIONAL_RETRIEVE_TEMPORARY_LIST: ["aiida.castep_bin"]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
'abipy',
2626
'aiida-abinit~=0.4.0',
2727
'aiida-bigdft>=0.2.6',
28-
'aiida-castep>=1.2.0a5',
28+
'aiida-castep>=1.3.0',
2929
'aiida-core[atomic_tools]~=1.6',
3030
'aiida-cp2k~=1.3',
3131
'aiida-fleur>=1.3.0',

0 commit comments

Comments
 (0)