Exemple #1
0
def launch_aiida_bulk_modulus(structure,
                              code_string,
                              resources,
                              label="AlN VASP relax calculation"):
    incar_dict = {
        'PREC': 'Accurate',
        'EDIFF': 1e-8,
        'NELMIN': 5,
        'NELM': 100,
        'ENCUT': 500,
        'IALGO': 38,
        'ISMEAR': 0,
        'SIGMA': 0.01,
        'GGA': 'PS',
        'LREAL': False,
        'LCHARG': False,
        'LWAVE': False,
    }

    kpoints = KpointsData()
    kpoints.set_kpoints_mesh([6, 6, 4], offset=[0, 0, 0.5])

    options = {'resources': resources, 'max_wallclock_seconds': 3600 * 10}

    potential_family = 'PBE.54'
    potential_mapping = {'Al': 'Al', 'N': 'N'}

    parser_settings = {
        'add_energies': True,
        'add_forces': True,
        'add_stress': True
    }

    code = Code.get_from_string(code_string)
    Workflow = WorkflowFactory('vasp_bm.bulkmodulus')
    builder = Workflow.get_builder()
    builder.code = code
    builder.parameters = Dict(dict=incar_dict)
    builder.structure = structure
    builder.settings = Dict(dict={'parser_settings': parser_settings})
    builder.potential_family = Str(potential_family)
    builder.potential_mapping = Dict(dict=potential_mapping)
    builder.kpoints = kpoints
    builder.options = Dict(dict=options)
    builder.metadata.label = label
    builder.metadata.description = label
    builder.clean_workdir = Bool(False)
    builder.relax = Bool(True)
    builder.force_cutoff = Float(1e-8)
    builder.steps = Int(10)
    builder.positions = Bool(True)
    builder.shape = Bool(True)
    builder.volume = Bool(True)
    builder.convergence_on = Bool(True)
    builder.convergence_volume = Float(1e-8)
    builder.convergence_max_iterations = Int(2)
    builder.verbose = Bool(True)

    node = submit(builder)
    return node
Exemple #2
0
 def run_two_volumes(self):
     self.report("run_two_volumes")
     for strain, future_name in zip((0.99, 1.01), ('minus', 'plus')):
         Workflow = WorkflowFactory('vasp.relax')
         builder = Workflow.get_builder()
         for key in self.ctx.inputs:
             builder[key] = self.ctx.inputs[key]
         if 'label' in self.ctx.inputs.metadata:
             label = self.ctx.inputs.metadata['label'] + " " + future_name
             builder.metadata['label'] = label
         if 'description' in self.ctx.inputs.metadata:
             description = self.ctx.inputs.metadata['description']
             description += " " + future_name
             builder.metadata['description'] = description
         builder.structure = self.ctx['structure_%s' % future_name]
         relax = AttributeDict()
         relax.perform = Bool(True)
         relax.force_cutoff = Float(1e-8)
         relax.positions = Bool(True)
         relax.shape = Bool(True)
         relax.volume = Bool(False)
         relax.convergence_on = Bool(False)
         builder.relax = relax
         future = self.submit(builder)
         self.to_context(**{future_name: future})
Exemple #3
0
def launch_phono3py(cutoff_energy=350, is_nac=False):
    """Launch calculation."""
    structure, forces_config, nac_config, phonon_settings = get_settings(
        cutoff_energy, is_nac)
    Phono3pyWorkChain = WorkflowFactory("phonopy.phono3py")
    builder = Phono3pyWorkChain.get_builder()
    builder.structure = structure
    builder.calculator_settings = Dict(dict={
        "forces": forces_config,
        "nac": nac_config
    })
    builder.run_phono3py = Bool(False)
    builder.remote_phono3py = Bool(False)
    builder.code_string = Str("phonopy@nancy")
    builder.phonon_settings = Dict(dict=phonon_settings)
    builder.symmetry_tolerance = Float(1e-5)
    builder.options = Dict(dict=forces_config["options"])
    dim = phonon_settings["supercell_matrix"]
    kpoints_mesh = forces_config["kpoints_mesh"]
    label = "ZnTe phono3py %dx%dx%d kpt %dx%dx%d PBEsol %d eV" % (
        tuple(dim) + tuple(kpoints_mesh) + (cutoff_energy, ))
    builder.metadata.label = label
    builder.metadata.description = label

    future = submit(builder)
    print(label)
    print(future)
    print("Running workchain with pk={}".format(future.pk))
Exemple #4
0
def launch_mae(structure, inpgen, calc_parameters, fleurinp, fleur,
               wf_parameters, scf_parameters, parent_folder, daemon, settings,
               option_node):
    """
    Launch a mae workchain
    """
    workchain_class = WorkflowFactory('fleur.mae')
    inputs = {
        'scf': {
            'wf_parameters': scf_parameters,
            'structure': structure,
            'calc_parameters': calc_parameters,
            'settings': settings,
            'inpgen': inpgen,
            'fleur': fleur
        },
        'wf_parameters': wf_parameters,
        'fleurinp': fleurinp,
        'remote': parent_folder,
        'fleur': fleur,
        'options': option_node
    }

    inputs = clean_nones(inputs)
    builder = workchain_class.get_builder()
    builder.update(inputs)
    launch_process(builder, daemon)
Exemple #5
0
def launch_fleur(fleurinp, fleur, parent_folder, settings, daemon,
                 max_num_machines, max_wallclock_seconds,
                 num_mpiprocs_per_machine, option_node, with_mpi, launch_base):
    """
    Launch a base_fleur workchain.
    If launch_base is False launch a single fleur calcjob instead.

    """

    process_class = CalculationFactory('fleur.fleur')
    workchain_class = WorkflowFactory('fleur.base')

    inputs = {
        'code': fleur,
        'fleurinpdata': fleurinp,
        'parent_folder': parent_folder,
        'settings': settings,
        'metadata': {
            'options': {
                'withmpi': with_mpi,
                'max_wallclock_seconds': max_wallclock_seconds,
                'resources': {
                    'num_machines': max_num_machines,
                    'num_mpiprocs_per_machine': num_mpiprocs_per_machine,
                }
            }
        }
    }

    if not launch_base:
        inputs = clean_nones(inputs)
        builder = process_class.get_builder()
        builder.update(inputs)
    else:
        if option_node is None:
            option_node = Dict(
                dict={
                    'withmpi': with_mpi,
                    'max_wallclock_seconds': max_wallclock_seconds,
                    'resources': {
                        'num_machines': max_num_machines,
                        'num_mpiprocs_per_machine': num_mpiprocs_per_machine
                    }
                })

        inputs_base = {
            'code': fleur,
            'fleurinpdata': fleurinp,
            'parent_folder': parent_folder,
            'settings': settings,
            'options': option_node
        }
        inputs_base = clean_nones(inputs_base)
        builder = workchain_class.get_builder()
        builder.update(**inputs_base)

    launch_process(builder, daemon)
Exemple #6
0
 def run_relax(self):
     self.report("run_relax")
     Workflow = WorkflowFactory('vasp.relax')
     builder = Workflow.get_builder()
     for key in self.ctx.inputs:
         builder[key] = self.ctx.inputs[key]
     if 'label' in self.ctx.inputs.metadata:
         label = self.ctx.inputs.metadata['label'] + " relax"
         builder.metadata['label'] = label
     if 'description' in self.ctx.inputs.metadata:
         description = self.ctx.inputs.metadata['description'] + " relax"
         builder.metadata['description'] = description
     future = self.submit(builder)
     self.to_context(**{'relax': future})
Exemple #7
0
def launch_banddos(fleurinp, fleur, wf_parameters, parent_folder, daemon,
                   settings, option_node):
    """
    Launch a banddos workchain
    """
    workchain_class = WorkflowFactory('fleur.banddos')
    inputs = {
        'wf_parameters': wf_parameters,
        'fleur': fleur,
        'remote': parent_folder,
        'fleurinp': fleurinp,
        'options': option_node
    }
    inputs = clean_nones(inputs)
    builder = workchain_class.get_builder()
    builder.update(inputs)
    launch_process(builder, daemon)
Exemple #8
0
def launch_corehole(structure, inpgen, calc_parameters, fleurinp, fleur,
                    wf_parameters, daemon, settings, option_node):
    """
    Launch a corehole workchain
    """
    workchain_class = WorkflowFactory('fleur.corehole')
    inputs = {
        'calc_parameters': calc_parameters,
        'options': option_node,
        'inpgen': inpgen,
        'fleur': fleur,
        'wf_parameters': wf_parameters,
        'structure': structure
    }
    inputs = clean_nones(inputs)
    builder = workchain_class.get_builder()
    builder.update(inputs)
    launch_process(builder, daemon)
Exemple #9
0
def launch_ssdisp(structure, inpgen, calc_parameters, fleur, wf_parameters,
                  scf_parameters, daemon, option_node):
    """
    Launch a ssdisp workchain
    """
    workchain_class = WorkflowFactory('fleur.ssdisp')
    inputs = {
        'scf': {
            'wf_parameters': scf_parameters,
            'structure': structure,
            'calc_parameters': calc_parameters,
            'options': option_node,
            'inpgen': inpgen,
            'fleur': fleur
        },
        'wf_parameters': wf_parameters,
        'fleur': fleur,
        'options': option_node
    }
    inputs = clean_nones(inputs)
    builder = workchain_class.get_builder()
    builder.update(inputs)
    launch_process(builder, daemon)
Exemple #10
0
def launch_relax(structure, inpgen, calc_parameters, fleur, wf_parameters,
                 scf_parameters, daemon, settings, option_node):
    """
    Launch a base relax workchain

    # TODO final scf input
    """
    workchain_class = WorkflowFactory('fleur.base_relax')
    inputs = {
        'scf': {
            'wf_parameters': scf_parameters,
            'structure': structure,
            'calc_parameters': calc_parameters,
            'options': option_node,
            'inpgen': inpgen,
            'fleur': fleur
        },
        'wf_parameters': wf_parameters
    }
    inputs = clean_nones(inputs)
    builder = workchain_class.get_builder()
    builder.update(inputs)
    launch_process(builder, daemon)
Exemple #11
0
def launch_dmi(structure, inpgen, calc_parameters, fleur, wf_parameters,
               scf_parameters, daemon, option_node):
    """
    Launch a dmi workchain
    """
    click.echo('Not implemented yet, sorry. Please implement me!')
    workchain_class = WorkflowFactory('fleur.dmi')
    inputs = {
        'scf': {
            'wf_parameters': scf_parameters,
            'structure': structure,
            'calc_parameters': calc_parameters,
            'options': option_node,
            'inpgen': inpgen,
            'fleur': fleur
        },
        'wf_parameters': wf_parameters,
        'fleur': fleur,
        'options': option_node
    }
    inputs = clean_nones(inputs)
    builder = workchain_class.get_builder()
    builder.update(inputs)
    launch_process(builder, daemon)
Exemple #12
0
def launch_create_magnetic(inpgen, calc_parameters, fleur, wf_parameters,
                           eos_parameters, scf_parameters, relax_parameters,
                           daemon, option_node):
    """
    Launch a create_magnetic workchain
    """
    workchain_class = WorkflowFactory('fleur.create_magnetic')
    inputs = {
        'eos': {
            'scf': {
                'wf_parameters': scf_parameters,
                'calc_parameters': calc_parameters,
                'options': option_node,
                'inpgen': inpgen,
                'fleur': fleur
            },
            'wf_parameters': eos_parameters
        },
        'relax': {
            'scf': {
                'wf_parameters': scf_parameters,
                'calc_parameters': calc_parameters,
                'options': option_node,
                'inpgen': inpgen,
                'fleur': fleur
            },
            'wf_parameters': relax_parameters,
            'label': 'relaxation',
        },
        'wf_parameters': wf_parameters
    }

    inputs = clean_nones(inputs)
    builder = workchain_class.get_builder()
    builder.update(inputs)
    launch_process(builder, daemon)
def _get_vasp_builder(structure, settings_dict, pressure=0.0, label=None):
    """
    Generate the input paramemeters needed to run a calculation for VASP

    :param structure:  StructureData object containing the crystal structure
    :param settings:  dict object containing a dictionary with the
        INCAR parameters
    :return: Calculation process object, input dictionary
    """

    code_string = settings_dict['code_string']
    VaspWorkflow = WorkflowFactory('vasp.vasp')
    builder = VaspWorkflow.get_builder()
    if label:
        builder.metadata.label = label
    builder.code = Code.get_from_string(code_string)
    builder.structure = structure
    options = Dict(dict=settings_dict['options'])
    builder.options = options
    builder.clean_workdir = Bool(False)

    if 'parser_settings' in settings_dict:
        parser_settings_dict = settings_dict['parser_settings']
    else:
        parser_settings_dict = {}
    if 'add_forces' not in parser_settings_dict:
        parser_settings_dict.update({'add_forces': True})

    builder.settings = DataFactory('dict')(
        dict={
            'parser_settings': parser_settings_dict
        })

    incar = dict(settings_dict['parameters'])
    keys_lower = [key.lower() for key in incar]
    if 'ediff' not in keys_lower:
        incar.update({'EDIFF': 1.0E-8})
    builder.parameters = Dict(dict=incar)
    builder.potential_family = Str(settings_dict['potential_family'])
    builder.potential_mapping = Dict(dict=settings_dict['potential_mapping'])

    kpoints = KpointsData()
    kpoints.set_cell_from_structure(structure)
    if 'kpoints_density' in settings_dict:
        kpoints.set_kpoints_mesh_from_density(settings_dict['kpoints_density'])
    elif 'kpoints_mesh' in settings_dict:
        if 'kpoints_offset' in settings_dict:
            kpoints_offset = settings_dict['kpoints_offset']
        else:
            kpoints_offset = [0.0, 0.0, 0.0]

        kpoints.set_kpoints_mesh(settings_dict['kpoints_mesh'],
                                 offset=kpoints_offset)
    else:
        raise InputValidationError(
            'no kpoint definition in input. '
            'Define either kpoints_density or kpoints_mesh')

    builder.kpoints = kpoints

    return builder
Exemple #14
0
def launch_aiida():
    import spglib
    from phonopy.interface.vasp import (read_vasp_from_strings,
                                        get_vasp_structure_lines)
    from phonopy.structure.atoms import PhonopyAtoms
    from aiida.plugins import DataFactory, WorkflowFactory
    from aiida.engine import run, submit
    from aiida_phonopy.common.utils import phonopy_atoms_to_structure

    Dict = DataFactory('dict')
    unitcell_str = """ Na Cl
   1.00000000000000
     5.6903014761756712    0.0000000000000000    0.0000000000000000
     0.0000000000000000    5.6903014761756712    0.0000000000000000
     0.0000000000000000    0.0000000000000000    5.6903014761756712
   4   4
Direct
  0.0000000000000000  0.0000000000000000  0.0000000000000000
  0.0000000000000000  0.5000000000000000  0.5000000000000000
  0.5000000000000000  0.0000000000000000  0.5000000000000000
  0.5000000000000000  0.5000000000000000  0.0000000000000000
  0.5000000000000000  0.5000000000000000  0.5000000000000000
  0.5000000000000000  0.0000000000000000  0.0000000000000000
  0.0000000000000000  0.5000000000000000  0.0000000000000000
  0.0000000000000000  0.0000000000000000  0.5000000000000000"""

    lat, pos, num = spglib.refine_cell(
        read_vasp_from_strings(unitcell_str).to_tuple())
    cell = PhonopyAtoms(cell=lat, scaled_positions=pos, numbers=num)
    cell = read_vasp_from_strings(
        '\n'.join(get_vasp_structure_lines(cell)))
    structure = phonopy_atoms_to_structure(cell)

    base_incar_dict = {
        'PREC': 'Accurate',
        'IBRION': -1,
        'EDIFF': 1e-8,
        'NELMIN': 5,
        'NELM': 100,
        'ENCUT': 520,
        'IALGO': 38,
        'ISMEAR': 0,
        'SIGMA': 0.01,
        # 'GGA': 'PS',
        'LREAL': False,
        'lcharg': False,
        'lwave': False,
    }

    base_config = {'code_string': 'vasp544mpi@stern',
                   'kpoints_density': 0.5,  # k-point density,
                   'potential_family': 'PBE.54',
                   'potential_mapping': {'Na': 'Na_pv', 'Cl': 'Cl'},
                   'options': {'resources': {'parallel_env': 'mpi*',
                                             'tot_num_mpiprocs': 16},
                               'max_wallclock_seconds': 3600 * 10}}
    base_parser_settings = {'add_energies': True,
                            'add_forces': True,
                            'add_stress': True}
    forces_config = base_config.copy()
    forces_config.update({'parser_settings': base_parser_settings,
                          'parameters': base_incar_dict})
    nac_config = base_config.copy()
    nac_parser_settings = {'add_born_charges': True,
                           'add_dielectrics': True}
    nac_parser_settings.update(base_parser_settings)
    nac_incar_dict = {'lepsilon': True}
    nac_incar_dict.update(base_incar_dict)
    nac_config.update({'parser_settings': nac_parser_settings,
                       'parameters': nac_incar_dict})

    PhononPhonopy = WorkflowFactory('phonopy.phonopy')
    builder = PhononPhonopy.get_builder()
    builder.structure = structure
    builder.calculator_settings = Dict(dict={'forces': forces_config,
                                             'nac': nac_config})
    builder.run_phonopy = Bool(True)
    builder.remote_phonopy = Bool(True)
    builder.code_string = Str('phonopy@stern')
    builder.phonon_settings = Dict(
        dict={'mesh': 50.0,
              'supercell_matrix': [1, 1, 1],
              'distance': 0.01,
              'is_nac': True})
    builder.symmetry_tolerance = Float(1e-5)
    builder.options = Dict(dict=base_config['options'])
    builder.metadata.label = "NaCl 2x2x2 phonon test on stern"
    builder.metadata.description = "NaCl 2x2x2 phonon test on stern"

    # Chose how to run the calculation
    run_by_deamon = True
    if not run_by_deamon:
        result = run(builder)
        print(result)
    else:
        future = submit(builder)
        print(future)
        print('Running workchain with pk={}'.format(future.pk))
import re
from aiida.engine import submit

from aiida.plugins import DataFactory, WorkflowFactory
Qecp = WorkflowFactory('qecpworkchain.cp')
StructureData = DataFactory('structure')

#load your initial structure
aiida_structure = aiida.orm.load_node(29073)

#eventually build a supercell
supercell = aiida_structure.get_pymatgen_structure()
supercell.make_supercell([3, 3, 3])
aiida_structure = aiida.orm.StructureData(pymatgen_structure=supercell)

build = Qecp.get_builder()

#cluster parameters
pw = Code.get_from_string('pw-6.7@your_cluster')
cp = Code.get_from_string('cp-6.7@your_cluster')
#for cp code
resources = {
    'resources': {
        'num_machines': 4,
        'num_mpiprocs_per_machine': 48,
    },
    'wallclock': 60 * 60 * 12,
    'queue': 'your_queue',
    'account': 'your_account',
}
#for pw code
Exemple #16
0
def launch_aiida():

    Dict = DataFactory('dict')
    unitcell_str = """ Na Cl
   1.00000000000000
     5.6903014761756712    0.0000000000000000    0.0000000000000000
     0.0000000000000000    5.6903014761756712    0.0000000000000000
     0.0000000000000000    0.0000000000000000    5.6903014761756712
   4   4
Direct
  0.0000000000000000  0.0000000000000000  0.0000000000000000
  0.0000000000000000  0.5000000000000000  0.5000000000000000
  0.5000000000000000  0.0000000000000000  0.5000000000000000
  0.5000000000000000  0.5000000000000000  0.0000000000000000
  0.5000000000000000  0.5000000000000000  0.5000000000000000
  0.5000000000000000  0.0000000000000000  0.0000000000000000
  0.0000000000000000  0.5000000000000000  0.0000000000000000
  0.0000000000000000  0.0000000000000000  0.5000000000000000"""

    cell = read_vasp_from_strings(unitcell_str)
    structure = phonopy_atoms_to_structure(cell)

    base_incar_dict = {
        'PREC': 'Accurate',
        'IBRION': -1,
        'EDIFF': 1e-8,
        'NELMIN': 5,
        'NELM': 100,
        'ENCUT': 520,
        'IALGO': 38,
        'ISMEAR': 0,
        'SIGMA': 0.01,
        'LREAL': False,
        'lcharg': False,
        'lwave': False,
    }

    base_config = {
        'code_string': 'vasp544mpi@nancy',
        'kpoints_density': 0.5,  # k-point density,
        'potential_family': 'PBE.54',
        'potential_mapping': {
            'Na': 'Na_pv',
            'Cl': 'Cl'
        },
        'options': {
            'resources': {
                'num_machines': 1,
                'parallel_env': 'mpi*',
                'tot_num_mpiprocs': 24
            },
            'max_wallclock_seconds': 3600 * 10
        }
    }
    base_parser_settings = {
        'add_energies': True,
        'add_forces': True,
        'add_stress': True
    }
    forces_config = base_config.copy()
    forces_config.update({
        'parser_settings': base_parser_settings,
        'parameters': base_incar_dict
    })
    nac_config = base_config.copy()
    nac_parser_settings = {'add_born_charges': True, 'add_dielectrics': True}
    nac_parser_settings.update(base_parser_settings)
    nac_incar_dict = {'lepsilon': True}
    nac_incar_dict.update(base_incar_dict)
    nac_config.update({
        'parser_settings': nac_parser_settings,
        'parameters': nac_incar_dict
    })

    PhononPhonopy = WorkflowFactory('phonopy.phonopy')
    builder = PhononPhonopy.get_builder()
    builder.structure = structure
    builder.calculator_settings = Dict(dict={
        'forces': forces_config,
        'nac': nac_config
    })
    builder.run_phonopy = Bool(True)
    builder.remote_phonopy = Bool(True)
    builder.code_string = Str('phonopy@nancy')
    builder.phonon_settings = Dict(
        dict={
            'mesh': 50.0,
            'supercell_matrix': [2, 2, 2],
            'distance': 0.01,
            'is_nac': True
        })
    builder.symmetry_tolerance = Float(1e-5)
    builder.options = Dict(dict=base_config['options'])
    builder.metadata.label = "NaCl 2x2x2 phonon example"
    builder.metadata.description = "NaCl 2x2x2 phonon example"

    future = submit(builder)
    print(future)
    print('Running workchain with pk={}'.format(future.pk))
def launch_aiida_low_kpoints(structure, code_string, resources, label):
    Dict = DataFactory('dict')
    KpointsData = DataFactory("array.kpoints")
    base_incar_dict = {
        'SYSTEM':'Si',
        'ISYM' :2,                      # 0-nonsym 1-usesym 2-fastsym
        'ISTART':0,                     # 0-nwe job, 1-restart
        'ICHARG':2,                     # charge: 1-file 2-atom 10-const
        'INIWAV':1,                     # electro: 0-lowe 1-rand 

        # ! ELectronic Relaxation  
        'ISPIN':1,                      # spin polarisation 1-no 2-yes
        'PREC':'Accurate',              # Low/Medium/High/Normal/Single/Accurate
        'ENCUT':200,                    # Energy cutoff                              
        'GGA':'MK',                     # Functional
        'PARAM1':0.1234,
        'PARAM2':1.0000,
        'LUSE_VDW':'.TRUE.',
        'AGGAC':0.0000,
        'LASPH':'.TRUE.',
        #'VOSKOMN':1,                    # Vosko Wilk Nusair interpolation
        'ALGO':'FAST',                  # IALGO = 48 (Davidson: 38)+ RMM-DISS algorithm for electrons
        'NELM':300,                     # Max iteration in SC loop
        'NELMIN': 3,                    # Min iteration in SC loop
        'EDIFF':1.0E-6,                 # [Global break cond. for the electrons. SC-loop] Energy
        'LREAL': 'Auto',                # F-small molecule A-normal system

        # ! Ioinic Relaxation
        'ISIF':2,                       # Stress tensor, 0-not, 2-ralax only positions, 3-relax cell shape+positions
        'EDIFFG':-0.02,                 # Convergence criterion for foreces (-0.03 for TS)
        'NSW': 600,                     # Max steps
        'IBRION':2,                     # 0-MD 1-Brodyn(opt,TS) 2-CG(opt) 3-damped MD(opt) 5-frequency calculation 44-dimer
        'POTIM':0.4,                    # Ion step size/time step(fs) for MD fc-0.01

        # ! MD run
        #'TEIN':20.0,                    # Initial temperature
        #'TEBEG':20.0,                   # TEEND = 0.0 temperature during run
        #'SMASS':-3.00,                  # Nose mass parameter (am)
        #'RWIGS':-1.00,                  # Atomic Wigner radii 

        # ! DOS related values
        'ISMEAR': -5,                   # -5-accurate total energy and DOS 0-large cell 1-metal
        'SIGMA':0.10,                   
        #'EMIN':10,
        #'EMAX':-10,                     # Atomic Wigner-Seitz radii

        # ! Dimer method
        #'MAXMIX':60,                    

        # ! Frequency Calculation
        #'NFREE':2,

        # ! Write
        'NWRITE':2,                     # How much will be written out
        #'LCHARG': '.True.',             # Write restart charge file
        #'LWAVE':'.True.',               # Write restart wf file
        #'LVHAR':'.False.',              # Write LOCPOT, Hartree potential only
        #'LVTOT':'.False.',              # Write LOCPOT, total locl potential
        'NPAR':4,                       # Adjust to number of processors best on berni up to 8 CPUs Close it when doing fc
        #'LPLANE':'.True.'
        #'LORBIT':11,                    # Write magnetic moment for each atom
}

    base_config = {'code_string': code_string,
                   'potential_family': 'PBE',
                   'potential_mapping': {'Si': 'Si', },
                   'options': {'resources': resources,
                               'account': 'ucapyba',
                               'max_wallclock_seconds': 3600 * 10}}
    base_parser_settings = {'add_energies': True,
                            'add_forces': True,
                            'add_stress': True}
    code = Code.get_from_string(base_config['code_string'])
    Workflow = WorkflowFactory('vasp.relax')
    builder = Workflow.get_builder()
    builder.code = code
    builder.parameters = Dict(dict=base_incar_dict)
    builder.structure = structure
    builder.settings = Dict(dict={'parser_settings': base_parser_settings})
    builder.potential_family = Str(base_config['potential_family'])
    builder.potential_mapping = Dict(dict=base_config['potential_mapping'])
    kpoints = KpointsData()
    kpoints.set_kpoints_mesh([4, 4, 1])
    builder.kpoints = kpoints
    builder.options = Dict(dict=base_config['options'])
    builder.metadata.label = label
    builder.metadata.description = label
    builder.clean_workdir = Bool(False)
    builder.relax = Bool(True)
    builder.force_cutoff = Float(1e-5)
    builder.steps = Int(10)
    builder.positions = Bool(True)
    builder.shape = Bool(True)
    builder.volume = Bool(True)
    builder.convergence_on = Bool(True)
    builder.convergence_volume = Float(1e-5)
    builder.convergence_max_iterations = Int(2)
    builder.verbose = Bool(True)

    node = submit(builder)
    return node
def launch_aiida():

    Dict = DataFactory('dict')
    unitcell_str = """ Sr Ti O
   1.0
     3.9050000000000000    0.0000000000000000    0.0000000000000000
     0.0000000000000000    3.9050000000000000    0.0000000000000000
     0.0000000000000000    0.0000000000000000    3.9050000000000000
 Sr Ti O
   1   1   3
Direct
   0.0000000000000000  0.0000000000000000  0.0000000000000000
   0.5000000000000000  0.5000000000000000  0.5000000000000000
   0.5000000000000000  0.0000000000000000  0.5000000000000000
   0.5000000000000000  0.5000000000000000  0.0000000000000000
   0.0000000000000000  0.5000000000000000  0.5000000000000000"""

    cell = read_vasp_from_strings(unitcell_str)
    structure = phonopy_atoms_to_structure(cell)

    base_incar_dict = {
        'PREC': 'Accurate',
        'IBRION': -1,
        'EDIFF': 1e-8,
        'NELMIN': 5,
        'NELM': 100,
        'ENCUT': 500,
        'IALGO': 38,
        'ISMEAR': 0,
        'SIGMA': 0.01,
        'GGA': 'PS',
        'LREAL': False,
        'lcharg': False,
        'lwave': False,
    }

    base_config = {
        'code_string': 'vasp544mpi@nancy',
        'potential_family': 'PBE.54',
        'potential_mapping': {
            'O': 'O',
            'Ti': 'Ti_pv',
            'Sr': 'Sr_sv'
        },
        'options': {
            'resources': {
                'num_machines': 1,
                'parallel_env': 'mpi*',
                'tot_num_mpiprocs': 24
            },
            'max_wallclock_seconds': 3600 * 10
        }
    }
    base_parser_settings = {
        'add_energies': True,
        'add_forces': True,
        'add_stress': True
    }
    forces_config = base_config.copy()
    forces_config.update({
        'kpoints_mesh': [4, 4, 4],  # k-point density,
        'parser_settings': base_parser_settings,
        'parameters': base_incar_dict
    })
    nac_config = base_config.copy()
    nac_parser_settings = {'add_born_charges': True, 'add_dielectrics': True}
    nac_parser_settings.update(base_parser_settings)
    nac_incar_dict = {'lepsilon': True}
    nac_incar_dict.update(base_incar_dict)
    nac_config.update({
        'kpoints_mesh': [8, 8, 8],  # k-point density,
        'parser_settings': nac_parser_settings,
        'parameters': nac_incar_dict
    })

    # PhononPhonopy = WorkflowFactory('phonopy.phonopy')
    # builder = PhononPhonopy.get_builder()
    PhonopyIterHA = WorkflowFactory('phonopy.iter_ha')
    builder = PhonopyIterHA.get_builder()
    builder.structure = structure
    builder.calculator_settings = Dict(dict={
        'forces': forces_config,
        'nac': nac_config
    })
    builder.run_phonopy = Bool(False)
    builder.remote_phonopy = Bool(True)
    builder.code_string = Str('phonopy@nancy')
    builder.phonon_settings = Dict(
        dict={
            'mesh': 50.0,
            'supercell_matrix': [2, 2, 2],
            'distance': 0.01,
            'is_nac': True,
            'fc_calculator': 'alm'
        })
    builder.symmetry_tolerance = Float(1e-5)
    builder.options = Dict(dict=base_config['options'])
    builder.metadata.label = "SrTiO3 iterative phonon 2x2x2 1000K test"
    builder.metadata.description = "SrTiO3 iterative phonon 2x2x2 1000K test"
    builder.max_iteration = Int(50)
    builder.number_of_snapshots = Int(40)
    builder.temperature = Float(1000.0)
    builder.number_of_steps_for_fitting = Int(20)
    builder.include_ratio = Float(0.99)
    # builder.initial_nodes = Dict(
    #     dict={'nodes':  [86164, 86936, 87708, 88480, 89252,
    #                      90024, 90796, 91568, 92340, 93112]})

    # Chose how to run the calculation
    run_by_deamon = True
    if not run_by_deamon:
        result = run(builder)
        print(result)
    else:
        future = submit(builder)
        print(future)
        print('Running workchain with pk={}'.format(future.pk))
        #'LPLANE':'.True.'
        #'LORBIT':11,                    # Write magnetic moment for each atom
}

   base_config = {'code_string': code_string,
                   'potential_family': 'PBE',
                   'potential_mapping': {'Si': 'Si',},
                   'options': {'resources': resources,
                               'account': 'ucapyba',
                               'max_wallclock_seconds': 3600 * 10}}
    base_parser_settings = {'add_energies': True,
                            'add_forces': True,
                            'add_stress': True}
    code = Code.get_from_string(base_config['code_string'])
    Workflow = WorkflowFactory('vasp.relax')
    builder = Workflow.get_builder()
    builder.code = code
    builder.parameters = Dict(dict=base_incar_dict)
    builder.structure = structure
    builder.settings = Dict(dict={'parser_settings': base_parser_settings})
    builder.potential_family = Str(base_config['potential_family'])
    builder.potential_mapping = Dict(dict=base_config['potential_mapping'])
    kpoints = KpointsData()
    kpoints.set_kpoints_mesh([7, 7, 1])
    builder.kpoints = kpoints
    builder.options = Dict(dict=base_config['options'])
    builder.metadata.label = label
    builder.metadata.description = label
    builder.clean_workdir = Bool(False)
    builder.relax = Bool(True)
    builder.force_cutoff = Float(1e-5)