From 03bcc99b6698a8cd5309ba99c53940adf0e519d3 Mon Sep 17 00:00:00 2001 From: Daniel Wortmann Date: Thu, 4 Jul 2024 10:05:26 +0200 Subject: [PATCH] add ssdisp_conv wf to CLI --- aiida_fleur/cmdline/launch/launch.py | 48 ++++++++++++++++++++++++++++ aiida_fleur/cmdline/util/types.py | 11 +++++-- aiida_fleur/workflows/ssdisp_conv.py | 13 +++----- 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/aiida_fleur/cmdline/launch/launch.py b/aiida_fleur/cmdline/launch/launch.py index b905fbe4..bee4cd2d 100755 --- a/aiida_fleur/cmdline/launch/launch.py +++ b/aiida_fleur/cmdline/launch/launch.py @@ -607,6 +607,54 @@ def launch_ssdisp(structure, inpgen, calc_parameters, fleur, wf_parameters, scf_ builder.update(inputs) utils.launch_process(builder, daemon) +@click.command('ssdisp_conv') +@options.STRUCTURE_OR_FILE(default="inp.xml", show_default=True) +@options.INPGEN() +@options.CALC_PARAMETERS() +@options.FLEUR() +@options.WF_PARAMETERS(required=True) +@options.SCF_PARAMETERS() +@options.DAEMON() +@options.OPTION_NODE() +def launch_ssdisp(structure, inpgen, calc_parameters, fleur, wf_parameters, scf_parameters, daemon, option_node): + """ + Launch a ssdisp_conv workchain + """ + workchain_class = WorkflowFactory('fleur.ssdisp_conv') + + fleurinp=None + if (isinstance(structure,FleurinpData)): + fleurinp=structure + structure=None + inpgen=None + calc_parameters=None + + inputs = { + 'scf': { + 'wf_parameters': scf_parameters, + 'calc_parameters': calc_parameters, + 'options': option_node, + 'inpgen': inpgen, + 'structure': structure, + 'fleurinp': fleurinp, + 'fleur': fleur + }, + 'wf_parameters': wf_parameters, + } + inputs = clean_nones(inputs) + builder = workchain_class.get_builder() + builder.update(inputs) + pk=utils.launch_process(builder, daemon) + + if not daemon: + from aiida.orm import load_node + wf=load_node(pk) + ssdisp_output=wf.outputs.output_ssdisp_conv_wc_para.get_dict() + #json with dict + import json + with open("ssdisp_conv.json","w") as file: + json.dump(ssdisp_output,file,indent=2) + @click.command('dmi') @options.STRUCTURE_OR_FILE(default=defaults.get_fept_film_structure, show_default=True) diff --git a/aiida_fleur/cmdline/util/types.py b/aiida_fleur/cmdline/util/types.py index 6ec9063d..b2fbee81 100644 --- a/aiida_fleur/cmdline/util/types.py +++ b/aiida_fleur/cmdline/util/types.py @@ -46,8 +46,15 @@ '"film_distance_relaxation": "False", // if True, sets relaxXYZ="FFT" for all atoms\n' '"force_criterion": 0.049, // Sets the threshold of the largest force\n' '"relax_iter": 5 // Maximum number of optimization iterations\n' - '}' - + '}', + "ssdisp_conv":'{\n' + '"beta": {"all": 1.57079}, // set the angle of some or all atoms\n' + '"q_vectors": {"label1": [0.0,0.0,0.0], //set the q-vectors. Each has a label attached\n' + ' "label2": [0.1,0.0,0.0]\n' + ' }\n' + '//"suppress_symmetries": False // Only if you start from a structure: do not use symmetries\n' + '}' + } diff --git a/aiida_fleur/workflows/ssdisp_conv.py b/aiida_fleur/workflows/ssdisp_conv.py index 0373058e..b8b3b80e 100644 --- a/aiida_fleur/workflows/ssdisp_conv.py +++ b/aiida_fleur/workflows/ssdisp_conv.py @@ -106,18 +106,15 @@ def get_inputs_scf(self, qss): with inpxml_changes(input_scf) as fm: for key, val in self.ctx.wf_dict['beta'].items(): fm.set_atomgroup_label(key, {'nocoParams': {'beta': val}}) - if self.ctx.wf_dict['suppress_symmetries']: fm.set_inpchanges({'qss': qss}) if 'calc_parameters' in input_scf: calc_parameters = input_scf.calc_parameters.get_dict() - else: - calc_parameters = {} - if self.ctx.wf_dict['suppress_symmetries']: - calc_parameters['qss'] = {'x': 1.221, 'y': 0.522, 'z': -0.5251} - else: - calc_parameters['qss'] = {'x': qss[0], 'y': qss[1], 'z': qss[2]} - input_scf.calc_parameters = Dict(calc_parameters) + if self.ctx.wf_dict['suppress_symmetries']: + calc_parameters['qss'] = {'x': 1.221, 'y': 0.522, 'z': -0.5251} + else: + calc_parameters['qss'] = {'x': qss[0], 'y': qss[1], 'z': qss[2]} + input_scf.calc_parameters = Dict(calc_parameters) return input_scf