-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implemention of
CalcJobImporter
for pw.x
calculations
- Loading branch information
Showing
9 changed files
with
1,777 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
""":class:`aiida.engine.processes.calcjobs.importer.CalcJobImporter` implementation for ``PwCalculation``.""" | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
import tempfile | ||
|
||
from aiida.engine import CalcJobImporter | ||
from aiida.orm import AbstractCode, Node, RemoteData | ||
|
||
|
||
class PwCalculationImporter(CalcJobImporter): | ||
""":class:`aiida.engine.processes.calcjobs.importer.CalcJobImporter` implementation for ``PwCalculation``. | ||
This class allows to import a completed ``pw.x`` calculation that was executed without AiiDA, into an AiiDA profile. | ||
""" | ||
|
||
@staticmethod | ||
def parse_remote_data( # pylint: disable=arguments-differ | ||
remote_data: RemoteData, | ||
input_file_name: str, | ||
code: AbstractCode | None = None, | ||
metadata: dict | None = None, | ||
pseudo_folder_path: str | None = None, | ||
) -> dict[str, Node | dict]: | ||
"""Parse the input nodes from the files in the provided ``RemoteData``. | ||
:param remote_data: the remote data node containing the raw input files. | ||
:param input_file_name: the filename of the main Quantum ESPRESSO input file. | ||
:param code: Optional ``AbstractCode`` node to attach to the imported node, as if it would have been run with | ||
the ``code`` input in a real run. | ||
:param metadata: Optional ``metadata`` inputs to set on the imported node, as if it would have been run with | ||
the ``metadata`` input in a real run. | ||
:returns: a dictionary with the parsed inputs nodes that match the input spec of the associated ``CalcJob``. | ||
""" | ||
from aiida_quantumespresso.tools.pwinputparser import create_builder_from_file | ||
|
||
with tempfile.TemporaryDirectory() as tmppath: | ||
dirpath = pathlib.Path(tmppath) / 'folder' | ||
with remote_data.get_authinfo().get_transport() as transport: | ||
transport.copytree(remote_data.get_remote_path(), dirpath) | ||
|
||
builder = create_builder_from_file( | ||
str(dirpath), input_file_name, code, metadata or {}, pseudo_folder_path=pseudo_folder_path | ||
) | ||
|
||
inputs = dict(builder) | ||
inputs['remote_folder'] = remote_data | ||
|
||
return inputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for the :class:`aiida_quantumespresso.calculations.importers.pw.PwCalculationImporter` class.""" | ||
from pathlib import Path | ||
|
||
from aiida.engine import run | ||
from aiida.orm import RemoteData | ||
|
||
from aiida_quantumespresso.calculations.importers.pw import PwCalculationImporter | ||
from aiida_quantumespresso.calculations.pw import PwCalculation | ||
|
||
|
||
def test_default(filepath_tests, fixture_code, aiida_localhost): | ||
"""Test importing a typical completed ``pw.x`` calculation.""" | ||
aiida_localhost.configure() | ||
filepath_remote = Path(filepath_tests) / 'calculations' / 'importers' / 'test_pw' / 'test_default' | ||
remote_data = RemoteData(str(filepath_remote), computer=aiida_localhost) | ||
input_file_name = 'aiida.in' | ||
code = fixture_code('quantumespresso.pw') | ||
pseudo_folder_path = filepath_remote / 'pseudo' | ||
inputs = PwCalculationImporter().parse_remote_data( | ||
remote_data, input_file_name, code, pseudo_folder_path=str(pseudo_folder_path) | ||
) | ||
results, node = run.get_node(PwCalculation, **inputs) | ||
assert node.is_finished_ok | ||
assert node.is_imported | ||
assert set(results.keys()) == {'output_band', 'output_trajectory', 'output_parameters', 'retrieved'} |
8 changes: 8 additions & 0 deletions
8
tests/calculations/importers/test_pw/test_default/_aiidasubmit.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
exec > _scheduler-stdout.txt | ||
exec 2> _scheduler-stderr.txt | ||
|
||
|
||
|
||
|
||
'/home/sph/code/qe/qe-6.6/bin/pw.x' '-in' 'aiida.in' > 'aiida.out' |
27 changes: 27 additions & 0 deletions
27
tests/calculations/importers/test_pw/test_default/aiida.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
&CONTROL | ||
calculation = 'scf' | ||
outdir = './out/' | ||
prefix = 'aiida' | ||
pseudo_dir = './pseudo/' | ||
verbosity = 'high' | ||
/ | ||
&SYSTEM | ||
ecutrho = 2.4000000000d+02 | ||
ecutwfc = 3.0000000000d+01 | ||
ibrav = 0 | ||
nat = 2 | ||
ntyp = 1 | ||
/ | ||
&ELECTRONS | ||
/ | ||
ATOMIC_SPECIES | ||
Si 28.085 Si.UPF | ||
ATOMIC_POSITIONS angstrom | ||
Si 0.0000000000 0.0000000000 0.0000000000 | ||
Si 1.3575000000 1.3575000000 1.3575000000 | ||
K_POINTS automatic | ||
2 2 2 0 0 0 | ||
CELL_PARAMETERS angstrom | ||
0.0000000000 2.7150000000 2.7150000000 | ||
2.7150000000 0.0000000000 2.7150000000 | ||
2.7150000000 2.7150000000 0.0000000000 |
Oops, something went wrong.