Exemplo n.º 1
0
def cmd_import(filename, dry_run, fleurinp):
    """
    Import a `StructureData` from a Fleur input file.

    FILENAME is the name/path of the inp.xml file to use.

    If you want to import a structure from any file type you can use
    'verdi data structure import -ase <filename>' instead.
    """
    from aiida_fleur.data.fleurinp import FleurinpData

    if not filename.endswith('.xml'):
        echo.echo_critical(
            'Error: Currently, only StructureData from a inp.xml file can be extracted.'
        )
    fleurinpd = FleurinpData(files=[filename])
    if not fleurinp or dry_run:
        structure = fleurinpd.get_structuredata_ncf()
    else:
        structure = fleurinpd.get_structuredata()
    formula = structure.get_formula()

    if dry_run:
        echo.echo_success(f'parsed structure with formula {formula}')
    else:
        structure.store()
        echo.echo_success(
            f'parsed and stored StructureData<{structure.pk}> with formula {formula}, also stored FleurinpData<{fleurinpd.pk}>'
        )
Exemplo n.º 2
0
    def get_results_relax(self):
        """
        Generates results of the workchain.
        Creates a new structure data node which is an
        optimized structure.
        """

        if self.ctx.wf_dict.get('relaxation_type', 'atoms') is None:
            input_scf = AttributeDict(
                self.exposed_inputs(FleurScfWorkChain, namespace='scf'))
            if 'structure' in input_scf:
                structure = input_scf.structure
            elif 'fleurinp' in input_scf:
                structure = input_scf.fleurinp.get_structuredata_ncf()
            else:
                pass
            self.ctx.final_structure = structure
            self.ctx.final_cell = structure.cell
            # The others are already put to None
            return

        try:
            relax_out = self.ctx.scf_res.outputs.last_fleur_calc_output
            last_fleur = find_nested_process(self.ctx.scf_res, FleurCalc)[-1]
            retrieved_node = last_fleur.outputs.retrieved
        except NotExistent:
            return self.exit_codes.ERROR_NO_SCF_OUTPUT

        relax_out = relax_out.get_dict()

        try:
            total_energy = relax_out['energy']
            total_energy_units = relax_out['energy_units']
            atomtype_info = relax_out['relax_atomtype_info']
        except KeyError:
            return self.exit_codes.ERROR_NO_RELAX_OUTPUT

        self.ctx.total_energy_last = total_energy
        self.ctx.total_energy_units = total_energy_units
        self.ctx.atomtype_info = atomtype_info

        fleurinp = FleurinpData(files=['inp.xml', 'relax.xml'],
                                node=retrieved_node)
        structure = fleurinp.get_structuredata_ncf()

        self.ctx.final_structure = structure
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
"""Helper for regenerating inp.xml files
"""
from aiida import load_profile
load_profile()

from aiida.orm import load_node
from aiida.engine import run
from aiida.plugins import CalculationFactory
from aiida_fleur.data.fleurinp import FleurinpData

inpgenc = CalculationFactory('fleur.inpgen')
path = './inp.xml'

fleurinp = FleurinpData(inpxml=path)

struc = fleurinp.get_structuredata_ncf()
param = fleurinp.get_parameterdata_ncf()
inpgen_code = load_node()

runa = run(inpgenc, code=inpgen_code, structure=struc, calc_parameter=param)