Skip to content

Commit

Permalink
Local changes for hero run; disentangle later
Browse files Browse the repository at this point in the history
  • Loading branch information
mbercx committed Jul 16, 2024
1 parent 529d2db commit 0489514
Show file tree
Hide file tree
Showing 10 changed files with 45,711 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/aiida_quantumespresso/calculations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ def _generate_PWCPinputdata(cls, parameters, settings, pseudos, structure, kpoin
'namelists using the NAMELISTS inside the `settings` input node'
) from exception

if 'DIRECT_MINIMIZATION' in input_params:
namelists_toprint.append('DIRECT_MINIMIZATION')

inputfile = ''
for namelist_name in namelists_toprint:
inputfile += f'&{namelist_name}\n'
Expand Down
4 changes: 3 additions & 1 deletion src/aiida_quantumespresso/calculations/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class PwCalculation(BasePwCpInputGenerator):
"""`CalcJob` implementation for the pw.x code of Quantum ESPRESSO."""

_default_namelists = ('CONTROL', 'SYSTEM', 'ELECTRONS', 'DIRECT_MINIMIZATION')
_default_namelists = ('CONTROL', 'SYSTEM', 'ELECTRONS')

_automatic_namelists = {
'scf': _default_namelists,
Expand Down Expand Up @@ -161,6 +161,8 @@ def define(cls, spec):
spec.exit_code(542, 'ERROR_RADIAL_FFT_SIGNIFICANT_VOLUME_CONTRACTION',
message=('The cell relaxation caused a significant volume contraction '
'and there is not enough space allocated for radial FFT.'))
spec.exit_code(543, 'ERROR_SYMMETRY_OPERATIONS_NOT_SATISFIED',
message='The variable cell optimization caused the symmetry operations to not be satisfied.')

# Strong warnings about calculation results, but something tells us that you're ok with that
spec.exit_code(710, 'WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED',
Expand Down
3 changes: 2 additions & 1 deletion src/aiida_quantumespresso/parsers/parse_raw/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def detect_important_message(logs, line):
'error': {
'Maximum CPU time exceeded': 'ERROR_OUT_OF_WALLTIME',
'convergence NOT achieved after': 'ERROR_ELECTRONIC_CONVERGENCE_NOT_REACHED',
'history already reset at previous step: stopping': 'ERROR_IONIC_CYCLE_BFGS_HISTORY_FAILURE',
'history already reset at previous step: ': 'ERROR_IONIC_CYCLE_BFGS_HISTORY_FAILURE',
'problems computing cholesky': 'ERROR_DIAGONALIZATION_CHOLESKY_DECOMPOSITION',
'charge is wrong': 'ERROR_CHARGE_IS_WRONG',
'not orthogonal operation': 'ERROR_SYMMETRY_NON_ORTHOGONAL_OPERATION',
Expand All @@ -258,6 +258,7 @@ def detect_important_message(logs, line):
'Error in routine broyden': 'ERROR_BROYDEN_FACTORIZATION',
'Not enough space allocated for radial FFT: try restarting with a larger cell_factor': 'ERROR_RADIAL_FFT_SIGNIFICANT_VOLUME_CONTRACTION',
REG_ERROR_NPOOLS_TOO_HIGH: 'ERROR_NPOOLS_TOO_HIGH',
'some of the original symmetry operations not satisfied': 'ERROR_SYMMETRY_OPERATIONS_NOT_SATISFIED'
},
'warning': {
'Warning:': None,
Expand Down
12 changes: 6 additions & 6 deletions src/aiida_quantumespresso/parsers/parse_xml/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .exceptions import XMLParseError
from .versions import get_default_schema_filepath, get_schema_filepath

from ..pw import fix_sirius_xml_prints

def raise_parsing_error(message):
raise XMLParseError(message)
Expand Down Expand Up @@ -511,8 +511,8 @@ def parse_xml_post_6_2(xml):

for atom in outputs['atomic_structure']['atomic_positions']['atom']:
atomic_species_name.append(atom['@name'])
atoms.append([atom['@name'], [coord * CONSTANTS.bohr_to_ang for coord in atom['$']]])

atoms.append([atom['@name'], [fix_sirius_xml_prints(coord) * CONSTANTS.bohr_to_ang for coord in atom['$']]])
species = outputs['atomic_species']['species']
structure_data = {
'atomic_positions_units': 'Angstrom',
Expand Down Expand Up @@ -568,7 +568,7 @@ def parse_xml_post_6_2(xml):

def parse_step_to_trajectory(trajectory, data, skip_structure=False):
"""."""
from ..pw import fix_sirius_xml_prints
from ..pw import fix_sirius_xml_prints # Do we really need that here? If we use it in other parts of the parser maybe we put it in the beginning?

if 'scf_conv' in data and 'n_scf_steps' in data['scf_conv']:
scf_iterations = data['scf_conv']['n_scf_steps'] # Can be zero in case of initialization-only calculation
Expand Down Expand Up @@ -602,9 +602,9 @@ def parse_step_to_trajectory(trajectory, data, skip_structure=False):
if 'forces' in data and '$' in data['forces']:
forces = np.array(data['forces']['$'])
dimensions = data['forces']['@dims'] # Like [3, 2], should be reversed to reshape the forces array
trajectory['forces'].append(forces.reshape(dimensions[::-1]))
trajectory['forces'].append(fix_sirius_xml_prints(forces.reshape(dimensions[::-1])))

if 'stress' in data and '$' in data['stress']:
stress = np.array(data['stress']['$'])
dimensions = data['stress']['@dims'] # Like [3, 3], should be reversed to reshape the stress array
trajectory['stress'].append(stress.reshape(dimensions[::-1]))
trajectory['stress'].append(fix_sirius_xml_prints(stress.reshape(dimensions[::-1])))
18 changes: 18 additions & 0 deletions src/aiida_quantumespresso/workflows/pw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,21 @@ def handle_electronic_convergence_warning(self, calculation):
self.report_error_handled(calculation, action)
self.results() # Call the results method to attach the output nodes
return ProcessHandlerReport(True, self.exit_codes.WARNING_ELECTRONIC_CONVERGENCE_NOT_REACHED)


@process_handler(priority=541, exit_codes=[
PwCalculation.exit_codes.ERROR_SYMMETRY_NON_ORTHOGONAL_OPERATION,
PwCalculation.exit_codes.ERROR_SYMMETRY_OPERATIONS_NOT_SATISFIED,
])
def handle_symmetry_non_orthogonal_warning(self, calculation):
"""Handle `ERROR_SYMMETRY_NON_ORTHOGONAL_OPERATION` and `ERROR_SYMMETRY_OPERATIONS_NOT_SATISFIED`
Use the structure from the last relaxation step as the starting point and restart from scratch.
"""

self.ctx.inputs.structure = calculation.outputs.output_structure
action = 'initialised the structure again and restarting from scratch.'

self.set_restart_type(RestartType.FROM_SCRATCH)
self.report_error_handled(calculation, action)
return ProcessHandlerReport(True)
2 changes: 1 addition & 1 deletion src/aiida_quantumespresso/workflows/pw/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def should_run_relax(self):
self.report('Pulay stresses still present, running another geometry optimizatio.')
return True

# If the kpoints are defined as a density, make sure the kpoints mesh is the same for the new structur
# If the kpoints are defined as a density, make sure the kpoints mesh is the same for the new structure
if 'kpoints_distance' in self.ctx.relax_inputs:
input_kpts_mesh, _ = base_relax_workchain.base.links.get_outgoing(
link_label_filter='iteration_01'
Expand Down
Loading

0 comments on commit 0489514

Please sign in to comment.