Dear Rijan,
Thanks a lot for the interest in using AiiDA and aiida-vibroscopy.
So, I'd suggest you to follow this one in case you didn't find it before, as it would answer most of your questions.
In the following some pointers that may be useful after you would follow the tutorials, but then feel free to come back again for any further explanations.
- Aiida-vibroscopy uses workflows provided by aiida-quantumespresso, which handles `pw.x` workflows with error handling features - namely the `PwBaseWorkChain`. This is the one you should use. To use it, you need to define a `computer` and a `code`.
You should achieve this with the following yaml file (save it as e.g. `computer.yaml`):
```
label: hpc # PLEASE CHANGE HERE AS YOU WISH
description: A DESCRIPTION # PLEASE CHANGE HERE AS YOU WISH
hostname: <PLEASE ADD HOSTNAME> # for example
lumi.csc.fi for LUMI-G supercomputer; in your case it can also be a resolved address like 111.222.33.44
transport: core.ssh
scheduler: core.slurm
work_dir: "/scratch/path/to/my_aiida_runs/" # PLEASE CHANGE HERE AS YOU WISH
mpirun_command: "srun -n {tot_num_mpiprocs}" # leave it like this, so that `{tot_num_mpiprocs}` can be changed dynamically, e.g. in case you have other partitions on the same cluster
mpiprocs_per_machine: 256 # your default number of mpiprocs on the default partition
```
And then from the console:
```
verdi computer setup --config computer.yaml
```
Verify it work via
```
verdi computer test hpc
```
You should achieve this with the following yaml file (save it as e.g. `code.yaml`):
```
label: 'qe-7.3'
description: 'quantum_espresso v7.3'
default_calc_job_plugin: '
quantumespresso.pw'
filepath_executable: '/users/rkarkee/q-e-qe-7.3/bin/pw.x'
computer: 'hpc'
prepend_text: |
module swap PrgEnv-cray PrgEnv-intel
module load cmake
append_text: ' '
```
And then install it in AiiDA:
```
verdi code create core.code.installed --config code.yaml
```
You should obtain after these steps a code, in this example it would be called `pw-7.3@hpc`. You can verify you have your code using `verdi code list`. The preparation of sbatch script, input file, parsing etc is all done by AiiDA, so you don't have to worry anymore about all these details. You just need to specify the code `pw-7.3@hpc`.
Once you have this code, then all the other info regarding the scheduler would come later. In AiiDA, these information (e.g. walltime, number of nodes, ...) are passed to the `CalcJob` (in this case `PwCalculation`) via the `metadata.options` namespace. In your case, this can be achieved by specifying in the `PwBaseWorkChain` the `metadata.options` for the `PwCalculation`. If you are familiar with the builder, then you would have something like the following:
```
from aiida_quantumespresso.workflows.pw.base import PwBaseWorkChain
builder = PwBaseWorkChain.get_builder()
builder.pw.metadata.options = {
'resources': {'num_machines':1, 'num_mpiprocs_per_machine': 256, 'num_cores_per_mpiproc': 1},
'max_wallclock_seconds': 43200, # walltime in seconds
'queue_name': 'standard',
}
```
The code would be specified via:
```
from aiida.orm import *
builder.pw.code = load_code('pw-7.3@hpc')
```
- For specific pw parallelization options, these are specified in the settings:
```
builder.pw.settings = Dict({'cmdline':['-pd', '.true.', '-nk', '4']}) # mind that everything should be a string, even numbers!
```
- For the structure, you need to create a `StructureData` instance. A possible way would be to use:
```
from aiida import load_profile
load_profile()
from aiida.orm import *
atoms = read('/path/to/input.pwi') # here I mean the QE pw.x input you just showed
structure = StructureData(ase=atoms)
structure.store()
```
This last step would print a number (the "PK"); save it somewhere so you can load again the structure information. For instance, in this way:
```
from aiida import load_profile
load_profile()
from aiida.orm import *
structure = load_node(PK) # PK is an integer number
```
For instance:
```
aiida-pseudo install family /path/to/pseudo_folder/ MyPseudos -P pseudo.upf
```
Then you would load the pseudos from you structure as follows:
```
from aiida.orm import *
structure = load_node(PK)
pseudo_family = load_group('MyPseudos')
pseudos = pseudo_family.get_pseudos(structure=structure)
builder = PwBaseWorkChain.get_builder()
builder.pw.structure = structure
builder.pw.pseudos = pseudos
```
A possible final python script would be:
```
from aiida import load_profile
from aiida.orm import *
from aiida.engine import submit
load_profile()
builder = PwBaseWorkChain.get_builder()
structure = load_node(PK)
code = load_code('pw-7.3@hpc')
pseudo_family = load_group('MyPseudos')
pseudos = pseudo_family.get_pseudos(structure=structure)
kpoints = KpointsData()
kpoints.set_kpoints_mesh([4,4,2],[0.5,0.5,0.5])
settings = {'cmdline':['-pd', '.true.', '-nk', '4']}
parameters = { # note: prefix, pseudos, and others are controlled by the plugin automatically!
'CONTROL': {
'tprnfor': True,
'tstress': True,
},
'SYSTEM': { # note: ibrav, nat, ntyp are controlled by the plugin automatically!
'ecutwfc': 70,
'lspinorb': True,
'noncolin': True,
'vdw_corr': 'Grimme-D2',
},
'ELECTRONS': {
'conv_thr': 1.0e-10
'electron_maxstep': 200,
'mixing_beta': 0.2,
'diagonalization': 'david',
},
}
builder.clean_workdir = Bool(False) # whether to remove the work directory after the run is finished
builder.kpoints = kpoints
builder.pw.structure = structure
builder.pw.pseudos = pseudos
builder.pw.code = code
builder.pw.parameters = Dict(parameters)
builder.pw.settings = Dict(settings)
builder.pw.metadata.options = {
'resources': {'num_machines':1, 'num_mpiprocs_per_machine': 256, 'num_cores_per_mpiproc': 1},
'max_wallclock_seconds': 43200, # walltime in seconds
'queue_name': 'standard',
}
calc = submit(builder) # submit to aiida and run the workflow!
print(f'Launched a PwBaseWorkChain with PK = {
calc.pk}') # register the PK and save it (e.g. in the same script); after it finishes, you can inspect the outputs
```
You can launch this script by simply `python script.py`, where `script.py` is a file containing the previous lines.
This can also be done via the `get_builder_from_protocol` method, which provides an easy way to fill the builder automatically, and then overrides the inputs you need (and very useful for more complex and nested inputs of aiida-vibroscopy - for vibroscopy workflows, have a look at its docs:
https://aiida-vibroscopy.readthedocs.io/en/latest/howto/overrides.html):
```
from aiida import load_profile
from aiida.orm import *
from aiida.engine import submit
from aiida_quantumespresso.common.types import ElectronicType
import yaml
load_profile()
with open('/path/to/overrides.yaml', 'r') as handle:
overrides = yaml.safe_load(handle)
structure = load_node(PK)
code = load_code('pw-7.3@hpc')
pseudo_family = load_group('MyPseudos')
pseudos = pseudo_family.get_pseudos(structure=structure)
kpoints = KpointsData()
kpoints.set_kpoints_mesh([4,4,2],[0.5,0.5,0.5])
overrides['pw']['pseudos'] = pseudos # need to specifically override pseudos
overrides['kpoints'] = kpoints # need to specifically override kpoints
kwargs = {'electronic_type': ElectronicType.INSULATOR} # this puts fixed occupations
builder = PwBaseWorkChain.get_builder_from_protocol(code=code, structure=structure, overrides=overrides, **kwargs)
submit(builder)
print(f'Launched a PwBaseWorkChain with PK = {
calc.pk}') # register the PK and save it (e.g. in the same script); after it finishes, you can inspect the outputs
```
Where `overrides.yaml` is a yaml file containing your inputs :
```
clean_workdir: False
max_iterations: 10
meta_parameters:
conv_thr_per_atom: 1.e-11
pw:
parameters:
SYSTEM:
ecutwfc: 70
ecutrho: 280
lspinorb: True
noncolin: True
vdw_corr: Grimme-D2
ELECTRONS:
mixing_beta: 0.2
electron_maxstep: 200
diagonalization: davidson
settings:
cmdline: ['-pd', '.true.', '-nk', '4']
metadata:
options:
resources:
num_machines: 1
num_mpiprocs_per_machine: 256
max_wallclock_seconds: 43200 # Twelve hours
queue_name: standard
```
As you see, the script will be much shorter, and you can separate better the inputs, so it's easier to change and resubmit the calculations.
Side note: please, consider to repost the same question on the Aiida Discourse channel, now the favoured communication channel, so that also other people can see this thread, thanks!
Hope this is useful.
Lorenzo