diff --git a/aiida_sssp_workflow/cli/inspect.py b/aiida_sssp_workflow/cli/inspect.py index 09079a61..d2cdcf0a 100644 --- a/aiida_sssp_workflow/cli/inspect.py +++ b/aiida_sssp_workflow/cli/inspect.py @@ -228,7 +228,10 @@ def convergence_plot( @cmd_root.command("analyze") @click.argument("group") # The group to inspect, name or pk of the group @click.option("--output", "-o", default="output", help="The output file name") -def analyze(group, output): +@click.option( + "--ylimit", "-y", default=0.5, help="The y limit for the plot", type=float +) +def analyze(group, output, ylimit): """Render the plot for the given pseudos and measure type.""" from aiida_sssp_workflow.utils import ACWF_CONFIGURATIONS, parse_label @@ -281,7 +284,7 @@ def analyze(group, output): ax.text(0 - d, 0.33 + d, "0.33 good agreement", color="black") ax.legend(loc="upper right", prop={"size": 10}) ax.set_ylabel("ν -factor") - ax.set_ylim([0, 0.5]) + ax.set_ylim([0, ylimit]) xticks_shift = len(nodes_lst) * width / 2 xticks = [i + xticks_shift for i in range(len(ACWF_CONFIGURATIONS))] @@ -367,7 +370,10 @@ def inspect(node, output): # A4 canvas for plot # landscape mode, shoulder to shoulder for ecutwfc and ecutrho for each property # five rows for five properties - rows = len(wf_node.outputs.convergence) + + # always plot 5 rows if the result is not accessable, add a text to indicate the property is not calculated + # rows = len(wf_node.outputs.convergence) + rows = 5 fig, axs = plt.subplots( rows, 2, @@ -378,12 +384,19 @@ def inspect(node, output): subplot_index = 0 for property in [ - "bands", - "cohesive_energy", "pressure", "delta", "phonon_frequencies", + "cohesive_energy", + "bands", ]: + # plot to the ax + # ax1 on the left for ecutwfc + # ax2 on the right for ecutrho + # the ratio of the width is 3:1 + ax1 = axs.flat[subplot_index] + ax2 = axs.flat[subplot_index + 1] + # print summary of the convergence to a json file try: convergence = wf_node.outputs.convergence[property] @@ -392,6 +405,18 @@ def inspect(node, output): f"Property {property} is not calculated for this workflow", fg="red", ) + # add to ax1 and ax2 with a red text to indicate the property is not calculated + ax1.text( + 0.5, + 0.5, + f"Convergence test of {property} is not run or failed.", + color="red", + ) + ax1.set_axis_off() + ax2.set_axis_off() + # jump to the next row + subplot_index += 2 + continue cutoff_control_protocol = wf_node.inputs.convergence.cutoff_control.value @@ -443,13 +468,6 @@ def inspect(node, output): convergence_summary[property] = property_summary - # plot to the ax - # ax1 on the left for ecutwfc - # ax2 on the right for ecutrho - # the ratio of the width is 3:1 - ax1 = axs.flat[subplot_index] - ax2 = axs.flat[subplot_index + 1] - # data preparation # Will only plot the measured properties e.g. for bands it is the eta_c _ConvergenceWorkChain = WorkflowFactory( diff --git a/aiida_sssp_workflow/workflows/evaluate/_bands.py b/aiida_sssp_workflow/workflows/evaluate/_bands.py index d54e2ebb..bf0124c1 100644 --- a/aiida_sssp_workflow/workflows/evaluate/_bands.py +++ b/aiida_sssp_workflow/workflows/evaluate/_bands.py @@ -66,7 +66,9 @@ class BandsWorkChain(_BaseEvaluateWorkChain): # maximum number of bands factor increase loop # to prevent the infinite loop in bands evaluation - _MAX_NUM_BANDS_FACTOR = 5 + # If start from 1.5, and increase 2.0 every time, it will reach 11.5 at most. + _MAX_INCREMENT_BANDS_FACTOR = 10 + _BANDS_FACTOR_INCREASE_STEP = 2.0 @classmethod def define(cls, spec): @@ -108,7 +110,7 @@ def define(cls, spec): spec.exit_code(201, 'ERROR_SUB_PROCESS_FAILED_BANDS', message='The `PwBandsWorkChain` sub process failed.') spec.exit_code(203, 'ERROR_REACH_MAX_BANDS_FACTOR_INCREASE_LOOP', - message=f'The maximum number={cls._MAX_NUM_BANDS_FACTOR} of bands factor' + message=f'The maximum number={cls._MAX_INCREMENT_BANDS_FACTOR} of bands factor' 'increase loop reached, but still cannot get enough bands.') spec.exit_code(204, 'ERROR_KPOINTS_DISTANCE_BAND_STRUCTURE_NOT_SET', message=f'kpoints distance is not set in inputs.') @@ -197,11 +199,11 @@ def increase_nbands(self): # # If the bands evaluation failed it will keeps on increasing the `nbands_factor` # which lead to the infinite loop to this work chain. - # Here I work around it by giving maximum nbands_factor loop to _MAX_NUM_BANDS_FACTOR=5. + # Here I work around it by giving maximum nbands_factor loop to _MAX_INCREMENT_BANDS_FACTOR=10. # And add a `break_increase_nbands` to break and get out from `should_run_bands` immediately. if ( self.ctx.nbands_factor - > self.inputs.init_nbands_factor.value + self._MAX_NUM_BANDS_FACTOR + > self.inputs.init_nbands_factor.value + self._MAX_INCREMENT_BANDS_FACTOR ): return self.exit_codes.ERROR_REACH_MAX_BANDS_FACTOR_INCREASE_LOOP @@ -210,9 +212,9 @@ def increase_nbands(self): # I should not increase it anyway because this ctx is used # for the input of band structure calculation. self.report( - f"increasing nbands_factor to from {self.ctx.nbands_factor} to {self.ctx.nbands_factor + 1.0}" + f"increasing nbands_factor to from {self.ctx.nbands_factor} to {self.ctx.nbands_factor + self._BANDS_FACTOR_INCREASE_STEP}" ) - self.ctx.nbands_factor += 1.0 + self.ctx.nbands_factor += self._BANDS_FACTOR_INCREASE_STEP def should_run_band_structure(self): """whether run band structure""" diff --git a/aiida_sssp_workflow/workflows/evaluate/_eos.py b/aiida_sssp_workflow/workflows/evaluate/_eos.py index ad7a817d..9f07d046 100644 --- a/aiida_sssp_workflow/workflows/evaluate/_eos.py +++ b/aiida_sssp_workflow/workflows/evaluate/_eos.py @@ -141,7 +141,7 @@ def inspect_eos(self): self.out("output_volume_energy", output_volume_energy) output_birch_murnaghan_fit, node = run_get_node( - birch_murnaghan_fit, output_volume_energy + birch_murnaghan_fit, volume_energy=output_volume_energy ) if not node.is_finished_ok: diff --git a/aiida_sssp_workflow/workflows/measure/__init__.py b/aiida_sssp_workflow/workflows/measure/__init__.py index 95063d7d..8e6dee37 100644 --- a/aiida_sssp_workflow/workflows/measure/__init__.py +++ b/aiida_sssp_workflow/workflows/measure/__init__.py @@ -15,7 +15,7 @@ class _BaseMeasureWorkChain(SelfCleanWorkChain): # ECUT for oxygen, remember to update this if the oxygen pseudo is changed # Currently the oxygen pseudo is `O.paw.z_6.ld1.psl.v0.1.upf` - _O_ECUTWFC = 75.0 + _O_ECUTWFC = 70.0 _O_ECUTRHO = 560.0 # ECUT for nitrogen, remember to update this if the nitrogen pseudo is changed diff --git a/setup.cfg b/setup.cfg index 861b6806..2ef2db72 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ project_urls = [options] packages = find: install_requires = - aiida-core[atomic_tools]~=2.4.0 + aiida-core[atomic_tools]~=2.4 aiida-quantumespresso~=4.3.0 python_requires = >=3.8 include_package_data = True