示例#1
0
def main(pot_family, import_from, queue, code, computer, no_import):
    load_dbenv_if_not_loaded()
    from aiida.orm import WorkflowFactory, Code
    from aiida.work import submit

    if not no_import:
        click.echo('importing POTCAR files...')
        with cli_spinner():
            import_pots(import_from, pot_family)

    code = Code.get_from_string('{}@{}'.format(code, computer))
    workflow = WorkflowFactory('vasp.relax')

    inputs = AttributeDict()
    inputs.structure = create_structure_perturbed()
    inputs.kpoints = AttributeDict()
    inputs.kpoints.distance = get_data_node('float', 0.2)
    inputs.relax = AttributeDict()
    inputs.convergence = AttributeDict()
    inputs.convergence.shape = AttributeDict()
    inputs.convergence.on = get_data_node('bool', True)
    inputs.convergence.positions = get_data_node('float', 0.1)
    inputs.incar_add = get_data_node('parameter', dict={
        'nsw': 1, 'ediffg': -0.0001, 'encut': 240, 'ismear': 0, 'sigma': 0.1, 'system': 'test-case:test_relax_wf',
    })  # yapf: disable
    inputs.restart = AttributeDict()
    inputs.code = code
    inputs.potcar_family = get_data_node('str', pot_family)
    inputs.potcar_mapping = get_data_node('parameter', dict={'Si': 'Si'})
    options = AttributeDict()
    options.queue_name = queue
    options.resources = {'num_machines': 1, 'num_mpiprocs_per_machine': 4}
    inputs.options = get_data_node('parameter', dict=options)

    submit(workflow, **inputs)
示例#2
0
def main(pot_family, import_from, queue, code, computer, no_import):
    load_dbenv_if_not_loaded()
    from aiida.orm import WorkflowFactory, Code
    from aiida.work import submit

    if not no_import:
        click.echo('importing POTCAR files...')
        with cli_spinner():
            import_pots(import_from, pot_family)

    code = Code.get_from_string('{}@{}'.format(code, computer))
    workflow = WorkflowFactory('vasp.base')

    inputs = AttributeDict()
    inputs.structure = create_structure_Si()
    inputs.kpoints = create_kpoints()
    inputs.incar = create_params_simple()
    inputs.code = code
    inputs.potcar_family = get_data_node('str', pot_family)
    inputs.potcar_mapping = get_data_node('parameter', dict={'Si': 'Si'})
    options = AttributeDict()
    options.queue_name = queue
    options.resources = {'num_machines': 1, 'num_mpiprocs_per_machine': 4}
    inputs.options = get_data_node('parameter', dict=options)

    submit(workflow, **inputs)
示例#3
0
    def test_launchers(self):
        """
        Verify that the various launchers are working
        """
        result = run(self.wf_return_true)
        self.assertTrue(result)

        result, node = run_get_node(self.wf_return_true)
        self.assertTrue(result)
        self.assertEqual(result, get_true_node())
        self.assertTrue(isinstance(node, FunctionCalculation))

        with self.assertRaises(AssertionError):
            submit(self.wf_return_true)
示例#4
0
    def _run_loading_raspa(self):
        """Perform raspa calculation at given pressure.
        
        Most of the runtime will be spent in this function.
        """
        # Create the input dictionary
        inputs = {
            'code':
            self.inputs.raspa_code,
            'structure':
            self.inputs.structure,
            'parameters':
            update_raspa_parameters(self.inputs.raspa_parameters,
                                    Float(self.ctx.current_pressure)),
            'block_component_0':
            self.ctx.zeopp['block'],
            '_options':
            self.ctx.options,
        }

        # Create the calculation process and launch it
        process = RaspaCalculation.process()
        future = submit(process, **inputs)
        self.report("pk: {} | Running raspa for the pressure {} [bar]".format(
            future.pid, self.ctx.current_pressure / 1e5))

        return ToContext(raspa=Outputs(future))
示例#5
0
def noncol(pot_family, import_from, queue, code, computer, no_import):
    load_dbenv_if_not_loaded()
    from aiida.orm import CalculationFactory, Code
    from aiida.work import submit
    if not no_import:
        click.echo('importing POTCAR files...')
        with cli_spinner():
            import_pots(import_from, pot_family)
    code = Code.get_from_string('{}@{}'.format(code, computer))
    calc_cls = CalculationFactory('vasp.vasp')

    if builder_interface(calc_cls):
        proc, inputs = noncol_builder(pot_family, queue, code, calc_cls)
    else:
        proc, inputs = noncol_inputs_template(pot_family, queue, code, calc_cls)

    submit(proc, **inputs)
示例#6
0
 def run_bands(self):
     vasp_proc = CalculationFactory('vasp.vasp').process()
     params = vex.BANDS_INCAR_TEMPLATE
     params.update({'icharg': 11})
     inputs = vex.make_inputs(
         codename=self.inputs.vasp_codename.value,
         incar=params,
         structure=self.ctx.relaxed_structure,
         kpoints=self.ctx.kpoints_path,
         settings={'parser_settings': {
             'add_bands': True,
             'add_dos': True
         }},
         queue_name=self.inputs.queue_name.value,
         num_procs=self.inputs.num_procs.value)
     inputs._options.max_wallclock_seconds = self.inputs.max_walltime.value
     inputs.charge_density = self.ctx.scf_run.out.chgcar
     result = submit(vasp_proc, **inputs)
     return ToContext(bands_run=result)
示例#7
0
 def run_relaxation(self):
     vasp_proc = CalculationFactory('vasp.vasp').process()
     params = vex.RELAXATION_INCAR_TEMPLATE
     params.update({'isif': self.ctx.inputs.relax_ISIF})
     inputs = vex.make_inputs(
         codename=self.inputs.vasp_codename.value,
         incar=params,
         structure=self.inputs.structure,
         kpoints=vex.get_relaxation_kpoints(
             structure=self.inputs.structure,
             distance=self.inputs.relax_kpts_dist.value),
         settings={'parser_settings': {
             'add_structure': True
         }},
         queue_name=self.inputs.queue_name.value,
         num_procs=self.inputs.num_procs.value)
     inputs._options.max_wallclock_seconds = self.inputs.max_walltime.value
     result = submit(vasp_proc, **inputs)
     return ToContext(relax_run=result)
示例#8
0
    def run_block_zeopp(self):
        """This function will perform a zeo++ calculation to block inaccessible pockets."""

        # Create the input dictionary
        inputs = {
            'code': self.inputs.zeopp_code,
            'structure': self.inputs.structure,
            'parameters': self.inputs.zeopp_parameters,
            'atomic_radii': self.inputs.atomic_radii,
            '_options': self.ctx.options,
        }

        # Create the calculation process and launch it
        process = ZeoppCalculation.process()
        future = submit(process, **inputs)
        self.report("pk: {} | Running Zeo++ to obtain blocked pockets".format(
            future.pid))

        return ToContext(zeopp=Outputs(future))
示例#9
0
 def run_scf(self):
     vasp_proc = CalculationFactory('vasp.vasp').process()
     params = vex.SCF_INCAR_TEMPLATE
     inputs = vex.make_inputs(
         codename=self.inputs.vasp_codename.value,
         incar=params,
         structure=self.ctx.relaxed_structure,
         kpoints=vex.get_relaxation_kpoints(
             structure=self.inputs.structure,
             distance=self.inputs.relax_kpts_dist.value),
         settings={
             'parser_settings': {
                 'add_structure': True,
                 'add_chgcar': True
             },
             'ADDITIONAL_RETRIEVE_LIST': ['WAVECAR', 'CHGCAR'],
         },
         queue_name=self.inputs.queue_name.value,
         num_procs=self.inputs.num_procs.value)
     inputs._options.max_wallclock_seconds = self.inputs.max_walltime.value
     result = submit(vasp_proc, **inputs)
     return ToContext(scf_run=result)
示例#10
0
    def run_eos(self):
        """
        Run the equation of states for all delta structures with their parameters
        """

        eos_results = {}
        inputs = self.get_inputs_eos()

        
        for struc, para in self.ctx.calcs_to_run[10:33]:#[10:33]
            print para
            formula = struc.get_formula()
            label = '|delta_wc|eos|{}'.format(formula)
            description = '|delta| fleur_eos_wc on {}'.format(formula)            
            if para:
                eos_future = submit(fleur_eos_wc,
                                wf_parameters=inputs['wc_eos_para'], structure=struc,
                                calc_parameters=para, inpgen=inputs['inpgen'], fleur=inputs['fleur'],
                                _label=label, _description=description)
                #fleur_eos_wc.run(#
            else: # TODO: run eos_wc_simple
                eos_future = submit(fleur_eos_wc,
                                wf_parameters=inputs['wc_eos_para'], structure=struc,
                                inpgen=inputs['inpgen'], fleur=inputs['fleur'],
                                _label=label, _description=description)
                #fleur_eos_wc.run(#a
            self.report('launching fleur_eos_wc<{}> on structure {} with parameter {}'
                        ''.format(eos_future.pid, struc.pk, para.pk))
            label = formula
            self.ctx.labels.append(label)
            eos_results[label] = eos_future

        return ToContext(**eos_results)

        '''
        #async to limit through put
        eos_results = {}
        inputs = self.get_inputs_eos()


        for struc, para in self.ctx.calcs_to_run[:4]:
            print para
            formula = struc.get_formula()
            label = '|delta_wc|eos|{}'.format(formula)
            description = '|delta| fleur_eos_wc on {}'.format(formula)
            if para:
                eos_future = asy(fleur_eos_wc,
                                wf_parameters=inputs['wc_eos_para'], structure=struc,
                                calc_parameters=para, inpgen=inputs['inpgen'], fleur=inputs['fleur'],
                                _label=label, _description=description)
                #fleur_eos_wc.run(#
            else:
                eos_future = asy(fleur_eos_wc,
                                wf_parameters=inputs['wc_eos_para'], structure=struc,
                                inpgen=inputs['inpgen'], fleur=inputs['fleur'],
                                _label=label, _description=description)
                #fleur_eos_wc.run(#a
            self.report('launching fleur_eos_wc<{}> on structure {} with parameter {}'
                        ''.format(eos_future.pid, struc.pk, para.pk))
            label = formula
            self.ctx.labels.append(label)
            eos_results[label] = eos_future

        return ToContext(**eos_results)
        '''
        '''
示例#11
0
#####

code = test_and_get_code(codename, expected_code_type='fleur.fleur')

# get where tests folder is, then relative path
inpxmlfile = '/usr/users/iff_th1/broeder/aiida/github/aiida-fleur/tests/inp_xml_files/W/inp.xml'
fleurinp = FleurinpData(files=[inpxmlfile])

wf_para = ParameterData(
    dict={
        'fleur_runmax': 4,
        'density_criterion': 0.000001,  #})
        'queue_name': queue,
        'resources': {
            "num_machines": 1,
            "num_mpiprocs_per_machine": 7
        },
        'walltime_sec': 10 * 60,
        'serial': run_in_serial_mode
    })

if submit_test:
    print('workchain do not have so far a submit_test function')
else:
    res = submit(fleur_scf_wc,
                 wf_parameters=wf_para,
                 fleurinp=fleurinp,
                 fleur=code)
    #remote_data= remote, fleur=code)
    print("Submited fleur_scf_wc")
示例#12
0
def runner(computer_name, test_set, group_name, potcar_family, dry_run,
           experiment):
    from aiida.orm import Code, Group, load_node
    from aiida.work import submit

    config = {}
    run_info_json = py_path.local('./run_info.json')
    cutoff = 'default'
    if experiment:
        config = read_experiment_yaml(experiment)
        if not computer_name:
            computer_name = config['computer']
        if not group_name:
            group_name = config['group_name']
        if not potcar_family:
            potcar_family = config['potcar_family']
        if 'outfile' in config:
            run_info_json = py_path.local(experiment).dirpath().join(
                config['outfile'])
        test_set = test_set or config.get('test_set', 'perturbed')
        cutoff = config.get('cutoff', 'default')

    cutoff_factor = 1
    if cutoff != 'default':
        cutoff_factor = int(cutoff)

    if not dry_run:
        run_info_json.ensure()
        run_info = json.loads(run_info_json.read()
                              or '{{ "{}": {{ }} }}'.format(computer_name))
    else:
        click.echo('run_info file would be created at {}'.format(
            run_info_json.strpath))

    vasp_proc = calc_cls('vasp.vasp').process()
    inputs = vasp_proc.get_inputs_template()

    computer.set_options(computer=computer_name,
                         options_template=inputs._options)
    inputs.code = Code.get_from_string('vasp@{}'.format(computer_name))
    inputs.settings = data_cls('parameter')(dict=TEST_SETTINGS)

    structures_group_name = PERTURBED_SET_GROUPNAME
    if test_set == 'non_perturbed':
        structures_group_name = UNPERTURBED_SET_GROUPNAME
    structures_group = Group.get(name=structures_group_name)

    if not dry_run:
        calc_group, created = Group.get_or_create(name=group_name)
    else:
        created = not bool(Group.query(name=group_name))
    calc_group_msg = 'Appending to {new_or_not} group {name}.'
    new_or_not = 'new' if created else 'existing'
    click.echo(calc_group_msg.format(new_or_not=new_or_not, name=group_name))

    ## limit structures if given in experiment yaml
    structures = list(structures_group.nodes)
    only_formulae = config.get('only_formulae', None)
    if only_formulae:
        structures = [
            structure for structure in structures
            if structure.get_formula() in only_formulae
        ]

    potcar_map = scf_potcar.POTCAR_MAP

    for structure in structures:

        inputs.structure = structure
        kpoints = data_cls('array.kpoints')()
        kpoints.set_cell_from_structure(structure)
        kpoints.set_kpoints_mesh_from_density(0.15, [0] * 3)
        inputs.kpoints = kpoints

        inputs.potential = data_cls('vasp.potcar').get_potcars_from_structure(
            structure=structure, family_name=potcar_family, mapping=potcar_map)

        ispin, magmom = magnetic_info(structure, potcar_family, potcar_map)
        incar_overrides = {}
        if ispin == 1:
            magnetism_string = "non-spin-polarized"
        elif ispin == 2:
            magnetism_string = "collinear-spin"
            incar_overrides['ispin'] = ispin
        else:
            raise Exception(
                "WTF"
            )  # This is not how you do non-collinear calcs! Set noncolin = True instead
        if magmom:
            incar_overrides['magmom'] = magmom

        if cutoff_factor != 1:
            default_enmax = cutoff_from_structure(structure=structure,
                                                  potcar_family=potcar_family,
                                                  mapping=potcar_map)
            incar_overrides['enmax'] = cutoff_factor * default_enmax

        inputs.parameters = scf_incar.get_scf_incar(inputs=inputs,
                                                    overrides=incar_overrides)

        cutoff_msg = 'default'
        if cutoff_factor != 1:
            cutoff_msg = 'cutoff factor: {}'.format(cutoff_factor)

        if not dry_run:
            running_info = submit(vasp_proc, **inputs)
            running_calc = load_node(running_info.pid)
            running_calc.set_extra('magnetism', magnetism_string)
            running_calc.set_extra('cutoff', cutoff_msg)
            calc_group.add_nodes(running_calc)
            run_info[computer_name][inputs.structure.pk] = running_calc.pk
        else:
            click.echo('not submitting {}'.format(structure.get_formula()))
            from pprint import pformat
            click.echo(pformat({k: v for k, v in inputs.items()}))

    if not dry_run:
        with run_info_json.open('w') as run_info_fo:
            json.dump(run_info, run_info_fo)