def test_nested_expose(self): res = launch.run( GrandParentExposeWorkChain, sub=dict( sub=dict( a=Int(1), sub_1={ 'b': Float(2.3), 'c': Bool(True) }, sub_2={ 'b': Float(1.2), 'sub_3': { 'c': Bool(False) } }, ) ) ) self.assertEqual( res, { 'sub': { 'sub': { 'a': Float(2.2), 'sub_1': { 'b': Float(2.3), 'c': Bool(True) }, 'sub_2': { 'b': Float(1.2), 'sub_3': { 'c': Bool(False) } } } } } )
def define(cls, spec): super(PhononPhono3py, cls).define(spec) spec.input("structure", valid_type=StructureData) spec.input("ph_settings", valid_type=Dict) spec.input("es_settings", valid_type=Dict) # Optional arguments spec.input("optimize", valid_type=Bool, required=False, default=Bool(True)) spec.input("pressure", valid_type=Float, required=False, default=Float(0.0)) spec.input("use_nac", valid_type=Bool, required=False, default=Bool(False)) # false by default spec.input("calculate_fc", valid_type=Bool, required=False, default=Bool(False)) # false by default spec.input("chunks", valid_type=Int, required=False, default=Int(100)) spec.input("cutoff", valid_type=Float, required=False, default=Float(0)) spec.input("recover", required=False, default=Bool(False)) # temporal patch spec.input("data_sets", required=False, default=Bool(False)) spec.outline( _If(cls.use_optimize)(cls.optimize), # cls.create_displacement_calculations, _While(cls.continue_submitting) (cls.create_displacement_calculations_chunk), cls.collect_data, _If(cls.calculate_fc)(cls.calculate_force_constants))
def test_operator(self): """Test all binary operators.""" term_a = Float(2.2) term_b = Int(3) for oper in [ operator.add, operator.mul, operator.pow, operator.lt, operator.le, operator.gt, operator.ge, operator.iadd, operator.imul ]: for term_x, term_y in [(term_a, term_b), (term_b, term_a)]: res = oper(term_x, term_y) c_val = oper(term_x.value, term_y.value) self.assertEqual(res._type, type(c_val)) # pylint: disable=protected-access self.assertEqual(res, oper(term_x.value, term_y.value))
def parse(self, **kwargs): # pylint: disable=inconsistent-return-statements try: out_folder = self.retrieved except KeyError: return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER try: with out_folder.open( DifferenceCalculation._OUTPUT_FILE_NAME, # pylint: disable=protected-access 'r') as f: res = float(f.read()) except IOError: return self.exit_codes.ERROR_OUTPUT_FILE_MISSING self.out('difference', Float(res))
def main(): inputs = { 'a': Float(3.14), 'b': Int(4), 'c': Int(6) } results = run(SumWorkChain, **inputs) print('Result of SumWorkChain: {}'.format(results)) results = run(ProductWorkChain, **inputs) print('Result of ProductWorkChain: {}'.format(results)) results = run(SumProductWorkChain, **inputs) print('Result of SumProductWorkChain: {}'.format(results))
def define(cls, spec): super().define(spec) spec.expose_inputs(PhonopyWorkChain, exclude=['immigrant_calculation_folders', 'calculation_nodes', 'dry_run']) spec.input('max_iteration', valid_type=Int, default=lambda: Int(10)) spec.input('number_of_snapshots', valid_type=Int, default=lambda: Int(100)) spec.input('number_of_steps_for_fitting', valid_type=Int, default=lambda: Int(4)) spec.input('temperature', valid_type=Float, default=lambda: Float(300.0)) spec.input('include_ratio', valid_type=Float, default=lambda: Float(1)) spec.input('linear_decay', valid_type=Bool, default=lambda: Bool(False)) spec.input('random_seed', valid_type=Int, required=False) spec.input('initial_nodes', valid_type=Dict, required=False) spec.outline( cls.initialize, if_(cls.import_initial_nodes)( cls.set_initial_nodes, ).else_( cls.run_initial_phonon, ), while_(cls.is_loop_finished)( cls.collect_displacements_and_forces, if_(cls.remote_phonopy)( cls.run_force_constants_calculation_remote, cls.generate_displacements, ).else_( cls.generate_displacements_local, ), cls.run_phonon, ), cls.finalize, )
def get_vasp_force_sets_dict(**forces_dict): forces = [] energies = [] forces_0 = None energy_0 = None for key in forces_dict: num = int(key.split('_')[-1]) if num == 0: continue if 'forces' in key: forces.append(None) elif 'misc' in key: energies.append(None) for key in forces_dict: num = int(key.split('_')[-1]) # e.g. "001" --> 1 if 'forces' in key: forces_ndarray = forces_dict[key].get_array('final') if num == 0: forces_0 = forces_ndarray else: forces[num - 1] = forces_ndarray elif 'misc' in key: energy = forces_dict[key]['total_energies']['energy_no_entropy'] if num == 0: energy_0 = energy else: energies[num - 1] = energy if forces_0 is not None: for forces_ndarray in forces: forces_ndarray -= forces_0 force_sets = ArrayData() force_sets.set_array('force_sets', np.array(forces)) if energies: force_sets.set_array('energies', np.array(energies)) force_sets.label = 'force_sets' ret_dict = {'force_sets': force_sets} if forces_0 is not None: forces_0_array = ArrayData() forces_0_array.set_array('forces', forces_0) ret_dict['supercell_forces'] = forces_0_array if energy_0 is not None: ret_dict['supercell_energy'] = Float(energy_0) return ret_dict
def _generate_eos_node(include_magnetization=True): from aiida.common import LinkType from aiida.orm import Float, WorkflowNode node = WorkflowNode(process_type='aiida.workflows:common_workflows.eos').store() for index in range(5): structure = generate_structure().store() energy = Float(index).store() structure.add_incoming(node, link_type=LinkType.RETURN, link_label=f'structures__{index}') energy.add_incoming(node, link_type=LinkType.RETURN, link_label=f'total_energies__{index}') if include_magnetization: magnetization = Float(index).store() magnetization.add_incoming(node, link_type=LinkType.RETURN, link_label=f'total_magnetizations__{index}') return node
def example_base(code, pseudo_family): """Run simple silicon DFT calculation.""" print('Testing the AbinitBaseWorkChain single-point on Silicon') thisdir = os.path.dirname(os.path.realpath(__file__)) structure = StructureData(pymatgen=mg.core.Structure.from_file(os.path.join(thisdir, 'files', 'Si.cif'))) pseudo_family = Group.objects.get(label=pseudo_family) pseudos = pseudo_family.get_pseudos(structure=structure) base_parameters_dict = { 'kpoints_distance': Float(0.3), # 1 / Angstrom 'abinit': { 'code': code, 'structure': structure, 'pseudos': pseudos, 'parameters': Dict( dict={ 'ecut': 8.0, # Maximal kinetic energy cut-off, in Hartree 'nshiftk': 4, # of the reciprocal space (that form a BCC lattice !) 'shiftk': [[0.5, 0.5, 0.5], [0.5, 0.0, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.5]], 'nstep': 20, # Maximal number of SCF cycles 'toldfe': 1.0e-6, # Will stop when, twice in a row, the difference # between two consecutive evaluations of total energy # differ by less than toldfe (in Hartree) } ), 'metadata': { 'options': { 'withmpi': True, 'max_wallclock_seconds': 2 * 60, 'resources': { 'num_machines': 1, 'num_mpiprocs_per_machine': 4, } } } } } print('Running work chain...') run(AbinitBaseWorkChain, **base_parameters_dict)
def _validate_process(self, proposal): process_node = proposal['value'] builder = process_node.get_builder_restart() try: # Check that parameters are consistent with what we would expect for the app. # This ensures that both processes we create with the app and those that are # loaded are consistent. assert process_node.process_label == 'PwBandsWorkChain' assert builder.scf.pseudo_family.value == builder.bands.pseudo_family.value assert dict(load_default_parameters()) \ == dict(builder.scf.pw['parameters']) \ == dict(builder.bands.pw['parameters']) assert builder.scf.kpoints_distance == Float(0.8) except AssertionError as error: raise traitlets.TraitError(f"Unable to set process, parameters are inconsistent: {error}") return proposal['value']
def get_data_sets(self): print('cutoff: {}'.format(self.ctx.cutoff)) future = submit( PhononPhono3py, structure=self.ctx.final_structure, ph_settings=self.inputs.ph_settings, es_settings=self.inputs.es_settings, optimize=Bool(False), cutoff=Float(self.ctx.cutoff), chunks=self.inputs.chunks, data_sets=self.ctx.input_data_sets, # data_sets=load_node(81481), # Test purposes only ) print('start phonon3 (pk={})'.format(self.pid)) return ToContext(anharmonic=future)
def generate_convergence_results(iteration_keys, used_values, target_values, converged, converged_index): ''' Generates the final output of the convergence workflows. ''' convergence_results = { 'converged': Bool(converged), } if converged: #pylint: disable=unnecessary-comprehension converged_parameters = DataFactory('dict')( dict={key: val for key, val in zip(iteration_keys, used_values[converged_index.value])} ) convergence_results['converged_parameters'] = converged_parameters convergence_results['converged_target_value'] = Float(target_values[converged_index.value]) return convergence_results
def submit(self, _=None): assert self.input_structure is not None builder = WorkflowFactory('quantumespresso.pw.bands').get_builder() builder.scf.pw.code = self.code_group.selected_code builder.scf.pw.parameters = load_default_parameters() builder.scf.pw.metadata.options = self.options builder.scf.kpoints_distance = Float(0.8) builder.scf.pseudo_family = Str(self.pseudo_family_selection.value) builder.bands.pw.code = self.code_group.selected_code builder.bands.pw.parameters = load_default_parameters() builder.bands.pw.metadata.options = self.options builder.bands.pseudo_family = Str(self.pseudo_family_selection.value) builder.structure = self.input_structure self.process = submit(builder)
def test_calcfunction_band_gap(db_test_app, data_regression): data = get_test_data("edge_at_fermi") array = ArrayData() array.set_array("energies", np.array(data.energies)) array.set_array("total", np.array(data.densities)) outputs, node = calcfunction_band_gap.run_get_node( doss_array=array, doss_results=Dict(dict={ "fermi_energy": data.fermi, "units": { "energy": "eV" } }), dtol=Float(1e-6), try_fshifts=List(list=data.try_fshifts), metadata={"store_provenance": True}, ) assert node.is_finished_ok, node.exit_status assert "results" in node.outputs data_regression.check(recursive_round(node.outputs.results.attributes, 4))
def run_eos_wf(code, pseudo_family, element): """Run an equation of state of a bulk crystal structure for the given element.""" # This will print the pk of the work function print('Running run_eos_wf<{}>'.format(Process.current().pid)) scale_factors = (0.96, 0.98, 1.0, 1.02, 1.04) labels = ['c1', 'c2', 'c3', 'c4', 'c5'] calculations = {} # Create an initial bulk crystal structure for the given element, using the calculation function defined earlier initial_structure = create_diamond_fcc(element) # Loop over the label and scale_factor pairs for label, factor in list(zip(labels, scale_factors)): # Generated the scaled structure from the initial structure structure = rescale(initial_structure, Float(factor)) # Generate the inputs for the `PwCalculation` inputs = generate_scf_input_params(structure, code, pseudo_family) # Launch a `PwCalculation` for each scaled structure print('Running a scf for {} with scale factor {}'.format( element, factor)) calculations[label] = run(PwCalculation, **inputs) # Bundle the individual results from each `PwCalculation` in a single dictionary node. # Note: since we are 'creating' new data from existing data, we *have* to go through a `calcfunction`, otherwise # the provenance would be lost! inputs = { label: result['output_parameters'] for label, result in calculations.items() } eos = create_eos_dictionary(**inputs) # Finally, return the results of this work function result = {'initial_structure': initial_structure, 'eos': eos} return result
def strain_structures(inp_structure, scalelist): """ Creates many re-scaled StructureData nodes out of a crystal structure. Keeps the provenance in the database. :param StructureData, a StructureData node (pk, sor uuid) :param scale-list, list of floats, scaling factors for the cell :returns: list of New StructureData nodes with rescalled structure, which are linked to input Structure """ structure = is_structure(inp_structure) if not structure: # TODO: log something (test if it gets here at all) return None re_structures = [] for scale in scalelist: structure_rescaled = rescale(structure, Float(scale)) # this is a wf re_structures.append(structure_rescaled) return re_structures
def _set_nac_params_from_external(self, nac_node): """ Set nac params from external nac node. """ from aiida_phonopy.common.utils import get_nac_params from aiida.orm import Float params = get_nac_params( born_charges=nac_node.outputs.born_charges, epsilon=nac_node.outputs.dielectrics, nac_structure=nac_node.inputs.structure, symmetry_tolerance=Float(1e-5), ) # borns = nac_node.outputs.born_charges.get_array('born_charges') # epsilon = nac_node.outputs.dielectrics.get_array('epsilon') borns = params.get_array('born_charges') epsilon = params.get_array('epsilon') nac_params = { 'born': borns, 'factor': 14.399652, 'dielectric': epsilon } self._nac_params = nac_params
def run_eos(self): """Run calculations for equation of state.""" # Create basic structure and attach it as an output initial_structure = create_diamond_fcc(self.inputs.element) self.out('initial_structure', initial_structure) calculations = {} for label, factor in zip(labels, scale_facs): structure = rescale(initial_structure, Float(factor)) inputs = generate_scf_input_params(structure, self.inputs.code, self.inputs.pseudo_family) self.report( 'Running an SCF calculation for {} with scale factor {}'. format(self.inputs.element, factor)) future = self.submit(PwCalculation, **inputs) calculations[label] = future # Ask the workflow to continue when the results are ready and store them in the context return ToContext(**calculations)
def test_dos_calc(db_test_app, generate_parser, generate_calc_job_node, sto_calc_inputs): """ Iterate through internal test cases. Check if the results are parsed correctly. """ output_folder = "Si-geom-stress" inputs = sto_calc_inputs # Swap the correct structure to allow desort to work inputs = sto_calc_inputs inputs.structure = get_x2_structure("Si") parser = generate_parser('castep.castep') node = generate_calc_job_node('castep.castep', output_folder, inputs) out, _ = parser.parse_from_node(node, store_provenance=False) bands = out.get(ln_name['bands'], None) # Compute dos dos = dos_from_bands(bands, Float(0.05), Int(1000)) xname, xval, xunit = dos.get_x() assert xval.shape == (1000, ) assert xname == "Energy" assert xunit == "eV" yname, yval, yunit = dos.get_y()[ 0] # Returns a list of (yname, yval, yunit) assert yval.shape == (1000, ) assert yname == "DOS_SPIN_0" assert yunit == "eV^-1" efermi = dos.get_attribute("fermi_energy") mask = xval < efermi sumval = (yval[mask].sum() * (xval[1] - xval[0])) assert sumval == pytest.approx(4.0, 1e-4)
def extract_dos_data_from_folder(self, folder, last_calc): """ Get DOS data and parse files. """ # initialize in case dos data is not extracted dosXyDatas = None # get list of files in directory (needed since SandboxFolder does not have `list_object_names` method) # also extract absolute path of folder (needed by parse_impdosfiles since calcfunction does not work with SandboxFolder as input) if isinstance(folder, SandboxFolder): folder_abspath = folder.abspath filelist = os.listdir(folder_abspath) else: filelist = folder.list_object_names() with folder.open(filelist[0]) as tmpfile: folder_abspath = tmpfile.name.replace(filelist[0], '') # check if out_ldos* files are there and parse dos files if 'out_ldos.interpol.atom=01_spin1.dat' in filelist: # extract EF and number of atoms from kkrflex_writeout calculation kkrflex_writeout = load_node(self.ctx.pk_flexcalc) parent_calc_kkr_converged = kkrflex_writeout.inputs.parent_folder.get_incoming( node_class=CalcJobNode).first().node ef = parent_calc_kkr_converged.outputs.output_parameters.get_dict( ).get('fermi_energy') last_calc_output_params = last_calc.outputs.output_parameters natom = last_calc_output_params.get_dict().get( 'number_of_atoms_in_unit_cell') # parse dosfiles using nspin, EF and Natom inputs dosXyDatas = parse_impdosfiles(Str(folder_abspath), Int(natom), Int(self.ctx.nspin), Float(ef)) dos_extracted = True else: dos_extracted = False dosXyDatas = None return dos_extracted, dosXyDatas
def create_eos_result_node(**kwargs): """ This is a pseudo cf, to create the right graph structure of AiiDA. This calcfunction will create the output nodes in the database. It also connects the output_nodes to all nodes the information comes from. This includes the output_parameter node for the eos, connections to run scfs, and returning of the gs_structure (best scale) So far it is just parsed in as kwargs argument, because we are to lazy to put most of the code overworked from return_results in here. """ outdict = {} outpara = kwargs.get('results_node', {}) outdict['output_eos_wc_para'] = outpara.clone() # copy, because we rather produce the same node twice # then have a circle in the database for now... outputdict = outpara.get_dict() structure = load_node(outputdict.get('initial_structure')) gs_scaling = outputdict.get('scaling_gs', 0) if gs_scaling: gs_structure = rescale_nowf(structure, Float(gs_scaling)) outdict['gs_structure'] = gs_structure return outdict
def test_identifier_sub_classes(self): """ The sub_classes keyword argument should allow to narrow the scope of the query based on the orm class """ node_bool = Bool(True).store() node_float = Float(0.0).store() node_int = Int(1).store() param_type_normal = NodeParamType() param_type_scoped = NodeParamType(sub_classes=('aiida.data:bool', 'aiida.data:float')) # For the base NodeParamType all node types should be matched self.assertEqual(param_type_normal.convert(str(node_bool.pk), None, None).uuid, node_bool.uuid) self.assertEqual(param_type_normal.convert(str(node_float.pk), None, None).uuid, node_float.uuid) self.assertEqual(param_type_normal.convert(str(node_int.pk), None, None).uuid, node_int.uuid) # The scoped NodeParamType should only match Bool and Float self.assertEqual(param_type_scoped.convert(str(node_bool.pk), None, None).uuid, node_bool.uuid) self.assertEqual(param_type_scoped.convert(str(node_float.pk), None, None).uuid, node_float.uuid) # The Int should not be found and raise with self.assertRaises(click.BadParameter): param_type_scoped.convert(str(node_int.pk), None, None)
def _parse_log(self, log_file_string, inputs): # parse with cclib property_dict = self._parse_log_cclib(log_file_string) if property_dict is None: return self.exit_codes.ERROR_OUTPUT_PARSING property_dict.update(self._parse_electron_numbers(log_file_string)) # set output nodes self.out("output_parameters", Dict(dict=property_dict)) if 'scfenergies' in property_dict: self.out("energy_ev", Float(property_dict['scfenergies'][-1])) self._set_output_structure(inputs, property_dict) exit_code = self._final_checks_on_log(log_file_string, property_dict) if exit_code is not None: return exit_code return None
def create_unit_cell_expansions(self): print('start Gruneisen (pk={})'.format(self.pid)) print('start create cell expansions') # For testing testing = False if testing: self.ctx._content['plus'] = load_node(13603) self.ctx._content['origin'] = load_node(13600) self.ctx._content['minus'] = load_node(13606) return calcs = {} for expansions in { 'plus': float(self.inputs.pressure) + float(self.inputs.stress_displacement), 'origin': float(self.inputs.pressure), 'minus': float(self.inputs.pressure) - float(self.inputs.stress_displacement) }.items(): future = submit(PhononPhonopy, structure=self.inputs.structure, ph_settings=self.inputs.ph_settings, es_settings=self.inputs.es_settings, pressure=Float(expansions[1]), optimize=Bool(True), use_nac=self.inputs.use_nac) calcs[expansions[0]] = future print('phonon workchain: {} {}'.format(expansions[0], future.pid)) return ToContext(**calcs)
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))
def get_total_energy(parameters): """Return the total energy [eV] from the output parameters node.""" return Float(parameters['scfenergies'][-1]) # already eV
def launch_workflow(code, structure, pseudo_family, kpoints_distance, ecutwfc, ecutrho, hubbard_u, hubbard_v, hubbard_file_pk, starting_magnetization, smearing, automatic_parallelization, clean_workdir, max_num_machines, max_wallclock_seconds, with_mpi, daemon, final_scf): """Run a `PwRelaxWorkChain`.""" from aiida.orm import Bool, Float, Dict, Str from aiida.plugins import WorkflowFactory from aiida_quantumespresso.utils.resources import get_default_options, get_automatic_parallelization_options builder = WorkflowFactory('quantumespresso.pw.relax').get_builder() cutoff_wfc, cutoff_rho = pseudo_family.get_recommended_cutoffs( structure=structure, unit='Ry') parameters = { 'CONTROL': { 'calculation': 'relax', }, 'SYSTEM': { 'ecutwfc': ecutwfc or cutoff_wfc, 'ecutrho': ecutrho or cutoff_rho, }, } try: hubbard_file = validate.validate_hubbard_parameters( structure, parameters, hubbard_u, hubbard_v, hubbard_file_pk) except ValueError as exception: raise click.BadParameter(str(exception)) try: validate.validate_starting_magnetization(structure, parameters, starting_magnetization) except ValueError as exception: raise click.BadParameter(str(exception)) try: validate.validate_smearing(parameters, smearing) except ValueError as exception: raise click.BadParameter(str(exception)) builder.structure = structure builder.base.kpoints_distance = Float(kpoints_distance) builder.base.pw.code = code builder.base.pw.pseudos = pseudo_family.get_pseudos(structure=structure) builder.base.pw.parameters = Dict(dict=parameters) if hubbard_file: builder.base.pw.hubbard_file = hubbard_file if automatic_parallelization: automatic_parallelization = get_automatic_parallelization_options( max_num_machines, max_wallclock_seconds) builder.base.automatic_parallelization = Dict( dict=automatic_parallelization) else: builder.base.pw.metadata.options = get_default_options( max_num_machines, max_wallclock_seconds, with_mpi) if clean_workdir: builder.clean_workdir = Bool(True) if final_scf: builder.base_final_scf.pseudo_family = Str(pseudo_family) builder.base_final_scf.kpoints_distance = Float(kpoints_distance) builder.base_final_scf.pw.code = code builder.base_final_scf.pw.parameters = Dict(dict=parameters) builder.base_final_scf.pw.metadata.options = get_default_options( max_num_machines, max_wallclock_seconds, with_mpi) launch.launch_process(builder, daemon)
def _generate_dissociation_curve_node(include_magnetization=True, include_energy=True): from aiida.common import LinkType from aiida.orm import Float, WorkflowNode node = WorkflowNode(process_type='aiida.workflows:common_workflows.dissociation_curve').store() for index in range(5): distance = Float(index / 10).store() distance.add_incoming(node, link_type=LinkType.RETURN, link_label=f'distances__{index}') # `include_energy` can be set to False to test cases with missing outputs if include_energy: energy = Float(index).store() energy.add_incoming(node, link_type=LinkType.RETURN, link_label=f'total_energies__{index}') if include_magnetization: magnetization = Float(index).store() magnetization.add_incoming(node, link_type=LinkType.RETURN, link_label=f'total_magnetizations__{index}') node.set_exit_status(0) return node
def _create_inputs(self): if not self.initialized: return [{self.input_key: Float(self.lower)}, {self.input_key: Float(self.upper)}] return [{self.input_key: Float(self.average)}]
"num_machines": 1, "num_mpiprocs_per_machine": 1, } } # # Parameters --------------------------------------------------- # settings_dict = {} settings = Dict(dict=settings_dict) # #--All the inputs of a Siesta calculations are listed in a dictionary-- # inputs = { 'settings': settings, 'spin_option': Str("q"), 'value': Float(height), 'mode': Str("constant-height"), 'code': code, 'ldos_folder': remotedata, 'metadata': { 'options': options, 'label': "STM test", } } if submit_test: inputs["metadata"]["dry_run"] = True inputs["metadata"]["store_provenance"] = False process = submit(STMCalculation, **inputs) print("Submited test for calculation (uuid='{}')".format(process.uuid)) print("Check the folder submit_test for the result of the test")