Beispiel #1
0
    def __init__(self, calc):
        """
        Init
        """
        from aiida.common import aiidalogger

        self._logger = aiidalogger.getChild('parser').getChild(
            self.__class__.__name__)

        self._calc = calc
Beispiel #2
0
    def __init__(self, *args, **kwargs):  # pylint: disable=unused-argument
        """
        __init__ method of the Transport base class.
        """
        from aiida.common import aiidalogger

        self._logger = aiidalogger.getChild('transport').getChild(
            self.__class__.__name__)
        self._logger_extra = None
        self._is_open = False
        self._enters = 0
        self._safe_open_interval = DEFAULT_TRANSPORT_INTERVAL
Beispiel #3
0
    def __init__(self, calc_parser_cls=None, **kwargs):  # pylint: disable=unused-argument
        super(BaseFileParser, self).__init__()
        self._logger = aiidalogger.getChild(self.__class__.__name__)
        self._vasp_parser = calc_parser_cls
        self.settings = None

        if calc_parser_cls is not None:
            calc_parser_cls.get_quantity.append(self.get_quantity)
            self.settings = calc_parser_cls.settings

        self._parsable_items = {}
        self._parsed_data = {}
        self._data_obj = None
Beispiel #4
0
    def __init__(self, calculation):
        """Initialize the instance of YamboParser"""
        from aiida.common import aiidalogger
        self._logger = aiidalogger.getChild('parser').getChild(
            self.__class__.__name__)
        # check for valid input
        if not isinstance(calculation, YamboCalculation):
            raise OutputParsingError(
                "Input calculation must be a YamboCalculation")
        self._calc = calculation

        self._eels_array_linkname = 'array_eels'
        self._eps_array_linkname = 'array_eps'
        self._alpha_array_linkname = 'array_alpha'
        self._qp_array_linkname = 'array_qp'
        self._ndb_linkname = 'array_ndb'
        self._ndb_QP_linkname = 'array_ndb_QP'
        self._ndb_HF_linkname = 'array_ndb_HFlocXC'
        self._lifetime_bands_linkname = 'bands_lifetime'
        self._quasiparticle_bands_linkname = 'bands_quasiparticle'
        self._parameter_linkname = 'output_parameters'
        super(YamboParser, self).__init__(calculation)
from aiida.common import aiidalogger
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer
from aiida.orm import CalculationFactory, DataFactory

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.0"
__authors__ = "The AiiDA team."

UpfData = DataFactory('upf')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
StructureData = DataFactory('structure')

logger = aiidalogger.getChild('WorkflowXTiO3')

## ===============================================
##    WorkflowXTiO3_EOS
## ===============================================

class WorkflowXTiO3_EOS(Workflow):
    def __init__(self, **kwargs):

        super(WorkflowXTiO3_EOS, self).__init__(**kwargs)

    ## ===============================================
    ##    Structure generators
    ## ===============================================

    def get_structure(self, alat=4, x_material='Ba'):
Beispiel #6
0
# -*- coding: utf-8 -*-
###########################################################################
# Copyright (c), The AiiDA team. All rights reserved.                     #
# This file is part of the AiiDA code.                                    #
#                                                                         #
# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core #
# For further information on the license, see the LICENSE.txt file        #
# For further information please visit http://www.aiida.net               #
###########################################################################

from aiida.common import aiidalogger
from aiida.common.datastructures import wf_states, wf_exit_call, wf_default_call

logger = aiidalogger.getChild('workflowmanager')


def execute_steps():
    """
    This method loops on the RUNNING workflows and handled the execution of the
    steps until each workflow reaches an end (or gets stopped for errors).

    In the loop for each RUNNING workflow the method loops also in each of its 
    RUNNING steps, testing if all the calculation and subworkflows attached to 
    the step are FINISHED. In this case the step is set as FINISHED and the 
    workflow is advanced to the step's next method present in the db with 
    ``advance_workflow``, otherwise if any step's JobCalculation is found in 
    NEW state the method will submit. If none of the previous conditions apply 
    the step is flagged as ERROR and cannot proceed anymore, blocking the future
    execution of the step and, connected, the workflow.

    Finally, for each workflow the method tests if there are INITIALIZED steps 
Beispiel #7
0
"""AiiDA - Workflow to get bandstructure of a material using VASP"""
from aiida.common import aiidalogger
from aiida.orm.workflow import Workflow
from aiida.orm import DataFactory

from aiida_vasp.calcs.maker import VaspMaker

LOGGER = aiidalogger.getChild('Bandstructure')
PARAMETER_CLS = DataFactory('parameter')


class Bandstructure(Workflow):
    """
    AiiDA workflow to get bandstructure of a material using VASP.

    Necessary steps are:
        * selfconsistent run with few kpoints
        * nonselfconsistent run with more kpoints and CHGCAR from
          selfconsistent run
    """
    def get_calc_maker(self):
        """Return an VaspMaker instance."""
        from aiida.orm import Code
        params = self.get_parameters()
        maker = VaspMaker(structure=params['structure'])
        maker.add_parameters(icharg=0,
                             istart=0,
                             lorbit=11,
                             lsorbit=True,
                             sigma=0.05,
                             ismear=0,
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer
from aiida.orm import CalculationFactory, DataFactory
from aiida.orm.utils import load_node

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.0"
__authors__ = "The AiiDA team."

UpfData = DataFactory('upf')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
StructureData = DataFactory('structure')

logger = aiidalogger.getChild('WorkflowStressTensor')

## ===============================================
##    Workflow_PW_Stress_Tensor_MLagrange
## ===============================================

class Workflow_PW_stress_tensor_MLagrange(Workflow):
    def __init__(self, **kwargs):

        super(Workflow_PW_stress_tensor_MLagrange, self).__init__(**kwargs)

    ## ===============================================
    ##    Structure generators
    ## ===============================================

    def get_MLagrange_distorted_structure(self, structure_id, M_MLagrange_eps):
Beispiel #9
0
# For further information on the license, see the LICENSE.txt file        #
# For further information please visit http://www.aiida.net               #
###########################################################################
from __future__ import division
import aiida.common
from aiida.common import aiidalogger
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer
from aiida.orm import CalculationFactory, DataFactory

UpfData = DataFactory('upf')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
StructureData = DataFactory('structure')

logger = aiidalogger.getChild('WorkflowXTiO3')

## ===============================================
##    WorkflowXTiO3_EOS
## ===============================================


class WorkflowXTiO3_EOS(Workflow):
    def __init__(self, **kwargs):

        super(WorkflowXTiO3_EOS, self).__init__(**kwargs)

    ## ===============================================
    ##    Structure generators
    ## ===============================================
Beispiel #10
0
# -*- coding: utf-8 -*-

import aiida.common
from aiida.common import aiidalogger
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.1"
__authors__ = "The AiiDA team."

logger = aiidalogger.getChild('WorkflowDemo')


class WorkflowDemo(Workflow):
    def __init__(self, **kwargs):
        super(WorkflowDemo, self).__init__(**kwargs)

    def generate_calc(self):
        from aiida.orm import Code, Computer, CalculationFactory
        from aiida.common.datastructures import calc_states

        CustomCalc = CalculationFactory('simpleplugins.templatereplacer')

        computer = Computer.get("localhost")

        calc = CustomCalc(computer=computer, withmpi=True)
        calc.set_resources({"num_machines": 1, "num_mpiprocs_per_machine": 1})
        calc.store()
        calc._set_state(calc_states.FINISHED)
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer
from aiida.orm import CalculationFactory, DataFactory
from aiida.orm.utils import load_node

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.0"
__authors__ = "The AiiDA team."

LapwbasisData = DataFactory('lapwbasis')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
StructureData = DataFactory('structure')

logger = aiidalogger.getChild('WorkflowEOS')

## ===============================================
##    Workflow_LAPW_EOS
## ===============================================

class Workflow_LAPW_EOS(Workflow):
    def __init__(self, **kwargs):

        super(Workflow_LAPW_EOS, self).__init__(**kwargs)

    ## ===============================================
    ##    Structure generators
    ## ===============================================

    def get_structure(self, structure_id, scale=1.0):
Beispiel #12
0
from aiida.workflows.user.epfl_theos.quantumespresso.pw import PwWorkflow, PwrestartWorkflow
from aiida.workflows.user.epfl_theos.quantumespresso.helpers import get_pw_wfs_with_parameters
from aiida.common.example_helpers import test_and_get_code

__copyright__ = u"Copyright (c), 2015, ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE (Theory and Simulation of Materials (THEOS) and National Centre for Computational Design and Discovery of Novel Materials (NCCR MARVEL)), Switzerland and ROBERT BOSCH LLC, USA. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file"
__version__ = "0.4.1"
__contributors__ = "Gianluca Prandini"

UpfData = DataFactory('upf')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
StructureData = DataFactory('structure')
PwCalculation = CalculationFactory('quantumespresso.pw')
SimpleCalculation = CalculationFactory('quantumespresso.simple')
logger = aiidalogger.getChild('ColourWorkflow')

## ===============================================
##    ColourWorkflow
## ===============================================

class ColourWorkflow(Workflow):
    """
    Workflow to compute the IPA dielectric function of a structure.
    
    Inputs:
    { 'pw_' + any parameter to be used in the pw workflow for the self-consistent DFT calculation
     
      'nscf_' + any parameter to be used in the pwrestart workflow for the nscf calculation
      
      'simple_' + any parameter to be used in the simple.x calculation
Beispiel #13
0
"""AiiDA - VASP workflow to get tight binding model of a material using VASP and wannier90"""
from aiida.common import aiidalogger
from aiida.common.exceptions import NotExistent
from aiida.orm import DataFactory, Group, CalculationFactory, Code
from aiida.orm.workflow import Workflow

from aiida_vasp.calcs.maker import VaspMaker

LOGGER = aiidalogger.getChild('Tbmodel')
PARAMETER_CLS = DataFactory('parameter')


class TbmodelWorkflow(Workflow):
    """
    AiiDA workflow to get tight binding model of a material using VASP and wannier90.

    Necessary steps are:
        * selfconsistent run with few kpoints
        * nonselfconsistent run with lwannier90
        * lwannier90 run with projections block
        * wannier.x run with hr_plot = True
    """
    def __init__(self, **kwargs):
        super(TbmodelWorkflow, self).__init__(**kwargs)
        self.group = None
        try:
            self.group = Group.get_from_string('tbmodel')
        except NotExistent:
            self.group = Group(name='tbmodel')
            self.group.store()
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer
from aiida.orm import CalculationFactory, DataFactory
from aiida.orm.utils import load_node

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.0"
__authors__ = "The AiiDA team."

UpfData = DataFactory('upf')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
StructureData = DataFactory('structure')

logger = aiidalogger.getChild('WorkflowElasticConstants')

## ===============================================
##    Workflow_PW_Elastic_Constants_Lagrange
## ===============================================

class Workflow_PW_elastic_constants_Lagrange(Workflow):
    def __init__(self, **kwargs):

        super(Workflow_PW_elastic_constants_Lagrange, self).__init__(**kwargs)

    ## ===============================================
    ##    Structure generators
    ## ===============================================

    def get_Lagrange_distorted_structure(self, structure_id, M_Lagrange_eps):
Beispiel #15
0
    def parse_from_calc(self, manual=True, custom_instruct=None):
        """
        Parses the datafolder, stores results.
        """
        from aiida.common.exceptions import InvalidOperation
        from aiida.common import aiidalogger
        from aiida.utils.logger import get_dblogger_extra

        parserlogger = aiidalogger.getChild('vaspparser')
        logger_extra = get_dblogger_extra(self._calc)

        # suppose at the start that the job is successful
        successful = True
        parser_warnings = {}  # for logging non-critical events

        # check that calculation is in the right state
        if not manual:
            state = self._calc.get_state()
            if state != calc_states.PARSING:
                raise InvalidOperation("Calculation not in {} state".format(
                    calc_states.PARSING))

        # get parser instructions
        # TODO: output parser should NOT interpret the input !!!
        try:
            instruct = self._calc.get_inputs_dict().pop(
                self._calc.get_linkname('settings'))
            instruct = instruct.get_dict()
            instruct = instruct[u'PARSER_INSTRUCTIONS']

            ##########   Abel Modification to test custom parsers

            if custom_instruct is not None:
                instruct = custom_instruct

##########

# check if structure, data, and error parsers are specified
# if not append defaults
            itypes = [i['type'] for i in instruct]
            # structure
            if not 'structure' in itypes:
                instruct.append({
                    'instr': 'default_structure_parser',
                    'type': 'structure',
                    'params': {}
                })
                parser_warnings.setdefault(
                    'Structure parser instruction not found!',
                    'default_structure_parser loaded.')
            # error
            if not 'error' in itypes:
                instruct.append({
                    'instr': 'default_error_parser',
                    'type': 'error',
                    'params': {}
                })
                parser_warnings.setdefault(
                    'Error parser instruction not found!',
                    'default_error_parser loaded.')
            # output
            if not 'data' in itypes:
                instruct.append({
                    'instr': 'default_vasprun_parser',
                    'type': 'data',
                    'params': {}
                })
                parser_warnings.setdefault(
                    'Data parser instruction not found!',
                    'default_data_parser_parser loaded.')
        except:
            parser_warnings.setdefault('Parser instructions not found',
                                       'Default instructions were loaded.')
            # don't crash, load default instructions instead
            instruct = [
                # output
                {
                    'instr': 'default_vasprun_parser',
                    'type': 'data',
                    'params': {}
                },
                # error
                {
                    'instr': 'default_error_parser',
                    'type': 'error',
                    'params': {}
                },
                # structure
                {
                    'instr': 'default_structure_parser',
                    'type': 'structure',
                    'params': {}
                }
            ]

        # select the folder object
        out_folder = self._calc.get_retrieved_node()

        # check what is inside the folder
        list_of_files = out_folder.get_folder_list()

        # === check if mandatory files exist ===
        # default output file should exist
        if not self._calc._default_output in list_of_files:
            successful = False
            parserlogger.error("Standard output file ({}) not found".format(
                self._calc._default_output),
                               extra=logger_extra)
            return successful, ()
        # output structure file should exist
        if not self._calc._output_structure in list_of_files:
            successful = False
            parserlogger.error("Output structure file ({}) not found".format(
                self._calc._output_structure),
                               extra=logger_extra)
            return successful, ()
        # stderr file should exist
        if not self._calc._SCHED_ERROR_FILE in list_of_files:
            successful = False
            parserlogger.error("STDERR file ({}) not found".format(
                self._calc._SCHED_ERROR_FILE),
                               extra=logger_extra)
            return successful, ()

        instr_node_list = []
        errors_node_list = []

        # === execute instructions ===
        #    print instruct
        for instr in instruct:
            # create an executable instruction
            try:
                # load instruction
                itype = instr['type'].lower()
                iname = instr['instr']
                iparams = instr['params']
                ifull_name = "{}.{}".format(itype, iname)

                # append parameters
                if itype == 'error':
                    iparams.setdefault('SCHED_ERROR_FILE',
                                       self._calc._SCHED_ERROR_FILE)
                elif itype == 'structure':
                    iparams.setdefault('OUTPUT_STRUCTURE',
                                       self._calc._output_structure)

                # instantiate
                instr = ParserInstructionFactory(ifull_name)
                instr_exe = instr(out_folder,
                                  params=iparams if iparams else None)
            except ValueError:
                parser_warnings.setdefault(
                    '{}_instruction'.format(instr),
                    'Invalid parser instruction - could not be instantiated!')
                instr_exe = None

            # execute

            if instr_exe:
                try:
                    for item in instr_exe.execute():  # store the results
                        instr_node_list.append(item)
                except Exception as e:
                    print instr, e
                    #        parser_warnings['output'].setdefault(  Modified by Abel
                    parser_warnings.setdefault(
                        'output', {
                            '{}_instruction'.format(instr),
                            'Failed to execute. Errors: {}'.format(e)
                        })

        # add all parser warnings to the error list
        parser_warnings = ParameterData(dict=parser_warnings)
        errors_node_list.append(('parser_warnings', parser_warnings))

        # === save the outputs ===
        new_nodes_list = []

        # save the errors/warrnings
        for item in errors_node_list:
            new_nodes_list.append(item)

        # save vasp data
        if instr_node_list:
            for item in instr_node_list:
                new_nodes_list.append(item)

        return successful, new_nodes_list
Beispiel #16
0
# ~ import aiida.common
from aiida.common import aiidalogger
from aiida.common.exceptions import NotExistent
from aiida.orm.workflow import Workflow
from aiida.orm import DataFactory, Group, CalculationFactory, Code
from aiida.orm.calculation.job.vasp.maker import VaspMaker

logger = aiidalogger.getChild('Tbmodel')
ParameterData = DataFactory('parameter')


class TbmodelWorkflow(Workflow):
    '''
    AiiDA workflow to get tight binding model of a material using VASP and
    wannier90.

    Necessary steps are:
        * selfconsistent run with few kpoints
        * nonselfconsistent run with lwannier90
        * lwannier90 run with projections block
        * wannier.x run with hr_plot = True
    '''
    def __init__(self, **kwargs):
        super(TbmodelWorkflow, self).__init__(**kwargs)
        self.group = None
        try:
            self.group = Group.get_from_string('tbmodel')
        except NotExistent:
            self.group = Group(name='tbmodel')
            self.group.store()
Beispiel #17
0
import os
from aiida.orm.workflow import Workflow
from aiida.workflows.user.hpc_workflow.hpc import HpcWorkflow
from aiida.orm import DataFactory
from aiida.common import aiidalogger

StructureData = DataFactory('structure')
UpfData = DataFactory('upf')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
pseudo_family = 'ssp_eff_pbe'
logger = aiidalogger.getChild('BenchWorkflow')


class BenchWorkflow(Workflow):
    def __init__(self, **kwargs):
        super(BenchWorkflow, self).__init__(**kwargs)
        self.times = []

    ## ===============================================
    ##    Wf steps
    ## ===============================================
    @Workflow.step
    def start(self):
        work_params = self.get_parameters()
        self.append_to_report("HPC params are: {}".format(
            work_params['hpc_params_0'].get_attrs()))
        self.next(self.launch_hpcworkflow)

    @Workflow.step
    def launch_hpcworkflow(self):
Beispiel #18
0
"""AiiDA - VASP workflow to run a VASP scf calculation"""
from aiida.common import aiidalogger
from aiida.orm import Workflow

from .helper import WorkflowHelper

LOGGER = aiidalogger.getChild('ScfWorkflow')


class ScfWorkflow(Workflow):
    """
    AiiDA workflow to run a VASP scf calculation

    the resulting WAVECAR and CHGCAR can then be reused in further workflows.
    """
    Helper = WorkflowHelper

    def __init__(self, **kwargs):
        self.helper = self.Helper(parent=self)
        super(ScfWorkflow, self).__init__(**kwargs)

    def get_calc_maker(self):
        maker = self.helper._get_calc_maker('vasp.scf')  # pylint: disable=protected-access
        maker.add_parameters(icharg=0, istart=0)
        return maker

    @Workflow.step
    # pylint: disable=protected-access
    def start(self):
        """Submit the calculation"""
        params = self.get_parameters()
Beispiel #19
0
the routines make reference to the suitable plugins for all
plugin-specific operations.
"""
import os

from aiida.common import aiidalogger
from aiida.common import exceptions
from aiida.common.datastructures import calc_states
from aiida.common.folders import SandboxFolder
from aiida.common.links import LinkType
from aiida.common.log import get_dblogger_extra
from aiida.orm import load_node, DataFactory
from aiida.orm.data.folder import FolderData
from aiida.scheduler.datastructures import JOB_STATES

execlogger = aiidalogger.getChild('execmanager')


def submit_calculation(calculation, transport):
    """
    Submit a calculation

    :param calculation: the instance of JobCalculation to submit.
    :param transport: an already opened transport to use to submit the calculation.
    """
    from aiida.orm import Code
    from aiida.common.exceptions import InputValidationError
    from aiida.orm.data.remote import RemoteData

    computer = calculation.get_computer()
Beispiel #20
0
    def parse_from_calc(self):
        """
        Parses the datafolder, stores results.
        This parser for this code ...
        """
        from aiida.common.exceptions import InvalidOperation
        from aiida.common import aiidalogger
        from aiida.utils.logger import get_dblogger_extra

        parserlogger = aiidalogger.getChild('yamboparser')
        logger_extra = get_dblogger_extra(self._calc)

        # suppose at the start that the job is unsuccessful, unless proven otherwise
        successful = False

        # check whether the yambo calc was an initialisation (p2y)
        try:
            settings_dict = self._calc.inp.settings.get_dict()
            settings_dict = _uppercase_dict(settings_dict,
                                            dict_name='settings')
        except AttributeError:
            settings_dict = {}

        initialise = settings_dict.pop('INITIALISE', None)

        # select the folder object
        out_folder = self._calc.get_retrieved_node()

        # check what is inside the folder
        list_of_files = out_folder.get_folder_list()

        try:
            input_params = self._calc.inp.parameters.get_dict()
        except AttributeError:
            if not initialise:
                raise ParsingError("Input parameters not found!")
            else:
                input_params = {}
        # retrieve the cell: if parent_calc is a YamboCalculation we must find the original PwCalculation
        # going back through the graph tree.
        parent_calc = self._calc.inp.parent_calc_folder.inp.remote_folder
        cell = {}
        if isinstance(parent_calc, YamboCalculation):
            has_found_cell = False
            while (not has_found_cell):
                try:
                    cell = parent_calc.inp.structure.cell
                    has_found_cell = True
                except AttributeError:
                    parent_calc = parent_calc.inp.parent_calc_folder.inp.remote_folder
        elif isinstance(parent_calc, PwCalculation):
            cell = self._calc.inp.parent_calc_folder.inp.remote_folder.inp.structure.cell

        output_params = {'warnings': [], 'errors': [], 'yambo_wrote': False}
        new_nodes_list = []
        ndbqp = {}
        ndbhf = {}
        try:
            results = YamboFolder(out_folder.get_abs_path())
        except Exception, e:
            success = False
            raise ParsingError("Unexpected behavior of YamboFolder: %s" % e)
Beispiel #21
0
                                         wf_default_call, calc_states)
from aiida.common.utils import str_timedelta
from aiida.common import aiidalogger
from aiida.orm.implementation.calculation import JobCalculation

from aiida.backends.utils import get_automatic_user

from aiida.utils import timezone
from aiida.utils.logger import get_dblogger_extra

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.1"
__authors__ = "The AiiDA team."

logger = aiidalogger.getChild('Workflow')


class WorkflowKillError(AiidaException):
    """
    An exception raised when a workflow failed to be killed.
    The error_message_list attribute contains the error messages from
    all the subworkflows.
    """
    def __init__(self, *args, **kwargs):
        # Call the base class constructor with the parameters it needs
        super(WorkflowKillError, self).__init__(*args)

        self.error_message_list = kwargs.pop('error_message_list', [])
        if kwargs:
            raise ValueError("Unknown parameters passed to WorkflowKillError")
Beispiel #22
0
    def parse_from_calc(self):
        """
        Parses the datafolder, stores results.
        This parser for this simple code does simply store in the DB a node
        representing the file of forces in real space
        """
        from aiida.common.exceptions import InvalidOperation
        from aiida.common import aiidalogger
        from aiida.djsite.utils import get_dblogger_extra

        import ase, ase.io

        parserlogger = aiidalogger.getChild('aseparser')
        logger_extra = get_dblogger_extra(self._calc)

        # suppose at the start that the job is successful
        successful = True

        # check that calculation is in the right state
        state = self._calc.get_state()
        if state != calc_states.PARSING:
            raise InvalidOperation("Calculation not in {} state".format(
                calc_states.PARSING))

        # select the folder object
        out_folder = self._calc.get_retrieved_node()

        # check what is inside the folder
        list_of_files = out_folder.get_folder_list()

        # at least the stdout should exist
        if not self._calc._OUTPUT_FILE_NAME in list_of_files:
            successful = False
            parserlogger.error("Standard output not found", extra=logger_extra)
            return successful, ()

        # output structure
        has_out_atoms = True if self._calc._output_aseatoms in list_of_files else False
        if has_out_atoms:
            out_atoms = ase.io.read(
                out_folder.get_abs_path(self._calc._output_aseatoms))
            out_structure = StructureData().set_ase(out_atoms)

        # load the results dictionary
        json_outfile = out_folder.get_abs_path(self._calc._OUTPUT_FILE_NAME)
        with open(json_outfile, 'r') as f:
            json_params = json.load(f)

        # extract arrays from json_params
        dictionary_array = {}
        for k, v in list(json_params.iteritems()):
            if isinstance(v, (list, tuple)):
                dictionary_array[k] = json_params.pop(k)

        # look at warnings
        warnings = []
        with open(out_folder.get_abs_path(self._calc._SCHED_ERROR_FILE)) as f:
            errors = f.read()
        if errors:
            warnings = [errors]
        json_params['warnings'] = warnings

        # save the outputs
        new_nodes_list = []

        # save the arrays
        if dictionary_array:
            array_data = ArrayData()
            for k, v in dictionary_array.iteritems():
                array_data.set_array(k, numpy.array(v))
            new_nodes_list.append((self._outarray_name, array_data))

        # save the parameters
        if json_params:
            parameter_data = ParameterData(dict=json_params)
            new_nodes_list.append((self._outdict_name, parameter_data))

        if has_out_atoms:
            structure_data = StructureData()
            new_nodes_list.append((self._outstruc_name, structure_data))

        return successful, new_nodes_list
Beispiel #23
0
the data structure to be filled for job submission (JobTemplate), and
the data structure that is returned when querying for jobs in the scheduler
(JobInfo).
"""
from __future__ import division
from aiida.common.extendeddicts import (
    DefaultFieldsAttributeDict, Enumerate)

from aiida.common import aiidalogger

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.1"
__authors__ = "The AiiDA team."

scheduler_logger = aiidalogger.getChild('scheduler')


class JobState(Enumerate):
    pass

# This is the list of possible job states
# Note on names: Jobs are the entities on a
# scheduler; Calcs are the calculations in
#   the AiiDA database (whose list of possible
#   statuses is defined in aida.common.datastructures
#   with the calc_states Enumerate).
# NOTE: for the moment, I don't define FAILED
# (I put everything in DONE)
job_states = JobState((
    'UNDETERMINED',
# -*- coding: utf-8 -*-

import aiida.common
from aiida.common import aiidalogger
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.0"
__authors__ = "The AiiDA team."

logger = aiidalogger.getChild('WorkflowDemo')


class WorkflowDemo(Workflow):
    def __init__(self, **kwargs):
        super(WorkflowDemo, self).__init__(**kwargs)

    def generate_calc(self):
        from aiida.orm import Code, Computer, CalculationFactory
        from aiida.common.datastructures import calc_states

        CustomCalc = CalculationFactory('simpleplugins.templatereplacer')

        computer = Computer.get("localhost")

        calc = CustomCalc(computer=computer, withmpi=True)
        calc.set_resources({"num_machines": 1, "num_mpiprocs_per_machine": 1})
        calc.store()
        calc._set_state(calc_states.FINISHED)
from aiida.orm.workflow import Workflow
from aiida.orm import Code, Computer
from aiida.orm import CalculationFactory, DataFactory
from aiida.orm.utils import load_node

__copyright__ = u"Copyright (c), This file is part of the AiiDA platform. For further information please visit http://www.aiida.net/. All rights reserved."
__license__ = "MIT license, see LICENSE.txt file."
__version__ = "0.7.0"
__authors__ = "The AiiDA team."

UpfData = DataFactory('upf')
ParameterData = DataFactory('parameter')
KpointsData = DataFactory('array.kpoints')
StructureData = DataFactory('structure')

logger = aiidalogger.getChild('WorkflowStressTensor')

## ===============================================
##    Workflow_PW_Stress_Tensor_Lagrange
## ===============================================


class Workflow_PW_stress_tensor_Lagrange(Workflow):
    def __init__(self, **kwargs):

        super(Workflow_PW_stress_tensor_Lagrange, self).__init__(**kwargs)

    ## ===============================================
    ##    Structure generators
    ## ===============================================
Beispiel #26
0
# For further information please visit http://www.aiida.net               #
###########################################################################
"""
This module defines the main data structures used by the Scheduler.

In particular, there is the definition of possible job states (job_states),
the data structure to be filled for job submission (JobTemplate), and
the data structure that is returned when querying for jobs in the scheduler
(JobInfo).
"""
from __future__ import division
from aiida.common.extendeddicts import (DefaultFieldsAttributeDict, Enumerate)

from aiida.common import aiidalogger

SCHEDULER_LOGGER = aiidalogger.getChild('scheduler')


class JobState(Enumerate):
    pass


# This is the list of possible job states
# Note on names: Jobs are the entities on a
# scheduler; Calcs are the calculations in
#   the AiiDA database (whose list of possible
#   statuses is defined in aida.common.datastructures
#   with the calc_states Enumerate).
# NOTE: for the moment, I don't define FAILED
# (I put everything in DONE)
JOB_STATES = JobState((