def launch(code, calculation, kpoints, max_num_machines, max_wallclock_seconds, daemon): """ Run a HpCalculation for a previously completed PwCalculation """ from aiida.orm import load_node from aiida.orm.data.parameter import ParameterData from aiida.orm.data.upf import get_pseudos_from_structure from aiida.orm.utils import CalculationFactory from aiida.work.launch import run_get_pid, submit from aiida_quantumespresso.utils.resources import get_default_options from aiida_quantumespresso_hp.utils.validation import validate_parent_calculation HpCalculation = CalculationFactory('quantumespresso.hp') try: validate_parent_calculation(calculation) except ValueError as exception: raise click.BadParameter( 'invalid parent calculation: {}'.format(exception)) parameters = {'INPUTHP': {}} inputs = { 'code': code, 'qpoints': kpoints, 'parameters': ParameterData(dict=parameters), 'parent_folder': calculation.out.remote_folder, 'options': get_default_options(max_num_machines, max_wallclock_seconds), } click.echo('Running a hp.x calculation ... ') process = HpCalculation.process() if daemon: calculation = submit(process, **inputs) pk = calculation.pk click.echo('Submitted {}<{}> to the daemon'.format( HpCalculation.__name__, calculation.pk)) else: results, pk = run_get_pid(process, **inputs) calculation = load_node(pk) click.echo('HpCalculation<{}> terminated with state: {}'.format( pk, calculation.get_state())) click.echo('\n{link:25s} {node}'.format(link='Output link', node='Node pk and type')) click.echo('{s}'.format(s='-' * 60)) for link, node in sorted(calculation.get_outputs(also_labels=True)): click.echo('{:25s} <{}> {}'.format(link, node.pk, node.__class__.__name__))
def launch(code, structure, pseudo_family, kpoints, max_num_machines, max_wallclock_seconds, daemon, mode): """ Run a PwCalculation for a given input structure """ from aiida.orm import load_node from aiida.orm.data.parameter import ParameterData from aiida.orm.data.upf import get_pseudos_from_structure from aiida.orm.utils import CalculationFactory from aiida.work.run import run, submit from aiida_quantumespresso.utils.resources import get_default_options PwCalculation = CalculationFactory('quantumespresso.pw') parameters = { 'CONTROL': { 'calculation': mode, }, 'SYSTEM': { 'ecutwfc': 30., 'ecutrho': 240., }, } inputs = { 'code': code, 'structure': structure, 'pseudo': get_pseudos_from_structure(structure, pseudo_family), 'kpoints': kpoints, 'parameters': ParameterData(dict=parameters), 'settings': ParameterData(dict={}), '_options': get_default_options(max_num_machines, max_wallclock_seconds), } process = PwCalculation.process() if daemon: calculation = submit(process, **inputs) click.echo('Submitted {}<{}> to the daemon'.format( PwCalculation.__name__, calculation.pid)) else: click.echo('Running a PwCalculation in the {} mode... '.format(mode)) results, pk = run(process, _return_pid=True, **inputs) calculation = load_node(pk) click.echo('PwCalculation<{}> terminated with state: {}'.format( pk, calculation.get_state())) click.echo('\n{link:25s} {node}'.format(link='Output link', node='Node pk and type')) click.echo('{s}'.format(s='-' * 60)) for link, node in sorted(calculation.get_outputs(also_labels=True)): click.echo('{:25s} <{}> {}'.format(link, node.pk, node.__class__.__name__))
def generate_scf_input_params(structure, codename, pseudo_family): # The inputs pw_calculation_class = CalculationFactory("quantumespresso.pw") inputs = pw_calculation_class.process().get_builder() # The structure inputs.structure = structure inputs.code = orm.Code.get_from_string(codename.value) inputs.options.resources = {"num_machines": 1} inputs.options.max_wallclock_seconds = 30 * 60 # Kpoints KpointsData = orm.DataFactory("array.kpoints") kpoints = KpointsData() kpoints_mesh = 2 kpoints.set_kpoints_mesh([kpoints_mesh, kpoints_mesh, kpoints_mesh]) inputs.kpoints = kpoints # Calculation parameters parameters_dict = { "CONTROL": { "calculation": "scf", "tstress": True, "tprnfor": True, }, "SYSTEM": { "ecutwfc": 30., "ecutrho": 200., }, "ELECTRONS": { "conv_thr": 1.e-6, } } orm.data.ParameterData = orm.DataFactory("parameter") inputs.parameters = orm.data.ParameterData(dict=parameters_dict) # Pseudopotentials inputs.pseudo = get_pseudos(structure, str(pseudo_family)) return inputs