Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhParser: allow for pattern initialization #1034

Merged
merged 8 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/aiida_quantumespresso/parsers/parse_raw/ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
The function that needs to be called from outside is parse_raw_ph_output(). Ideally, the functions should work even
without aiida and will return a dictionary with parsed keys.
"""
from __future__ import annotations

import numpy
from qe_tools import CONSTANTS

Expand Down Expand Up @@ -440,11 +442,16 @@ def parse_ph_dynmat(data, logs, lattice_parameter=None, also_eigenvectors=False,
return parsed_data


def parse_initialization_qpoints(stdout: str) -> dict:
def parse_initialization_qpoints(stdout: str) -> tuple[dict, bool]:
"""Return the number of q-points from an initialization run.

Here, the initialization run refers to the one performed by specifying
`start_irr` and `last_irr` to 0 in the inputs.

:return: (parsed dictionary, error found), the last is a boolean
regarding whether an expected quantity has not been properly
parse; it also checks that the number of q-points parsed within
parenthesis and the amount of q-points parsed from coordinaes coincide.
"""
import re

Expand All @@ -471,4 +478,10 @@ def parse_initialization_qpoints(stdout: str) -> dict:

parameters.update({'q_points': q_points})

return parameters
if 'number_of_qpoints' not in parameters and 'q_points' not in parameters:
return parameters, False

if parameters['number_of_qpoints'] != len(parameters['q_points']):
return parameters, False

return parameters, True
bastonero marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 3 additions & 2 deletions src/aiida_quantumespresso/parsers/ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ def parse(self, **kwargs):
# When `start_irr` and `last_irr` are set to 0, `JOB DONE` is not in stdout (expected behaviour).
# Though, we at least expect that `stdout` is not empty, otherwise something went wrong.
if stdout and _is_initialization(self.node.inputs.parameters.get_dict()):
parameters = parse_initialization_qpoints(stdout)
if parameters:
parameters, parsed_ok = parse_initialization_qpoints(stdout)
if parsed_ok:
self.out('output_parameters', orm.Dict(parameters))
return
# we let it go, as it should exit with STDOUT_INCOMPLETE or similar

# If the scheduler detected OOW, simply keep that exit code by not returning anything more specific.
if self.node.exit_status == PhCalculation.exit_codes.ERROR_SCHEDULER_OUT_OF_WALLTIME:
Expand Down
66 changes: 66 additions & 0 deletions tests/parsers/fixtures/ph/initialization_failed/aiida.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

Program PHONON v.7.2 starts on 18Jun2024 at 18:33:27

This program is part of the open-source Quantum ESPRESSO suite
for quantum simulation of materials; please cite
"P. Giannozzi et al., J. Phys.:Condens. Matter 21 395502 (2009);
"P. Giannozzi et al., J. Phys.:Condens. Matter 29 465901 (2017);
"P. Giannozzi et al., J. Chem. Phys. 152 154105 (2020);
URL http://www.quantum-espresso.org",
in publications or presentations arising from this work. More details at
http://www.quantum-espresso.org/quote

Parallel version (MPI), running on 8 processors

MPI processes distributed on 1 nodes
37704 MiB available memory on the printing compute node when the environment starts

Reading input from ph.init.in

Reading xml data from directory:

./tmp/graphene.save/

R & G space division: proc/nbgrp/npool/nimage = 8
Subspace diagonalization in iterative solution of the eigenvalue problem:
a serial algorithm will be used


IMPORTANT: XC functional enforced from input :
Exchange-correlation= PZ
( 1 1 0 0 0 0 0)
Any further DFT definition will be discarded
Please, verify this is what you really want


Parallelization info
--------------------
sticks: dense smooth PW G-vecs: dense smooth PW
Min 30 30 10 3040 3040 660
Max 31 31 11 3065 3065 691
Sum 241 241 85 24369 24369 5409

Using Slab Decomposition

----2D----2D----2D----2D----2D----2D----2D----2D----2D----2D----2D----2D
The code is running with the 2D cutoff
Please refer to:
Sohier, T., Calandra, M., & Mauri, F. (2017),
Density functional perturbation theory for gated two-dimensional heterostructu
res:
Theoretical developments and application to flexural phonons in graphene.
Physical Review B, 96(7), 75448. https://doi.org/10.1103/PhysRevB.96.075448
----2D----2D----2D----2D----2D----2D----2D----2D----2D----2D----2D----2D
Reading collected, re-writing distributed wavefunctions in ./tmp/


Dynamical matrices for ( 2, 2, 2) uniform grid of q-points
( 8 q-points):
N xq(1) xq(2) xq(3)
1 0.000000000 0.000000000 0.000000000
2 0.000000000 0.000000000 -0.061660223
3 0.000000000 -0.577350269 0.000000000
4 0.000000000 -0.577350269 -0.061660223
5 -0.500000000 -0.288675135 0.000000000
6 -0.500000000 -0.288675135 -0.061660223
7 -0.500000000 -0.866025404 0.000000000
17 changes: 17 additions & 0 deletions tests/parsers/test_ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ def test_ph_initialization(fixture_localhost, generate_calc_job_node, generate_p
data_regression.check(results['output_parameters'].get_dict())


def test_ph_initialization_failed(fixture_localhost, generate_calc_job_node, generate_parser):
"""Test a failed `ph.x` calculation performed with `start_irr` and `last_irr` set to 0."""
name = 'initialization_failed'
entry_point_calc_job = 'quantumespresso.ph'
entry_point_parser = 'quantumespresso.ph'

inputs = {'parameters': orm.Dict({'INPUTPH': {'start_irr': 0, 'last_irr': 0}})}

node = generate_calc_job_node(entry_point_calc_job, fixture_localhost, name, inputs)
parser = generate_parser(entry_point_parser)
_, calcfunction = parser.parse_from_node(node, store_provenance=False)

assert calcfunction.is_finished, calcfunction.exception
assert calcfunction.is_failed, calcfunction.exit_status
assert calcfunction.exit_status == node.process_class.exit_codes.ERROR_OUTPUT_STDOUT_INCOMPLETE.status


def test_ph_failed_computing_cholesky(fixture_localhost, generate_calc_job_node, generate_parser):
"""Test the parsing of a calculation that failed during cholesky factorization.

Expand Down
Loading