示例#1
0
    def run_pm(self):
        """
        It runs a Ev calculation in PorousMaterials.
        """
        pm_input = self.exposed_inputs(PorousMaterialsCalculation,
                                       'porousmaterials')
        pm_input['structure'] = {}
        pm_input['structure'][self.ctx.label] = self.inputs.structure
        pm_input['acc_voronoi_nodes'] = {}
        pm_input['metadata']['label'] = 'Voronoi Energy Calculation'
        pm_input['metadata']['call_link_label'] = 'run_pm'

        if all(self.ctx.should_run_comp) and all(self.ctx.should_run_pld):
            for key in self.ctx.components.keys():
                zeopp_label = "zeopp_{}".format(key)
                voro_label = "{}_{}".format(self.ctx.label, key)
                pm_input['acc_voronoi_nodes'][voro_label] = self.ctx[
                    zeopp_label].outputs.voro_accessible
            pm_input["parameters"] = modify_pm_parameters(
                self.inputs.porousmaterials.parameters,
                Str('ev_vdw_kh_multicomp_pld_template'))

        if all(self.ctx.should_run_comp) and not all(self.ctx.should_run_pld):
            for key in self.inputs.components.keys():
                zeopp_label = "zeopp_{}".format(key)
                voro_label = "{}_{}".format(self.ctx.label, key)
                pm_input['acc_voronoi_nodes'][voro_label] = self.ctx[
                    zeopp_label].outputs.voro_accessible
            pm_input["parameters"] = modify_pm_parameters(
                self.inputs.porousmaterials.parameters,
                Str('ev_vdw_kh_multicomp_template'))

        if not all(self.ctx.should_run_comp) and all(self.ctx.should_run_pld):
            voro_label = "{}_{}".format(self.ctx.label, 'PLD')
            pm_input['acc_voronoi_nodes'][voro_label] = self.ctx[
                "zeopp_PLD"].outputs.voro_accessible
            pm_input["parameters"] = modify_pm_parameters(
                self.inputs.porousmaterials.parameters,
                Str('ev_vdw_kh_pld_template'))

        pm_ev = self.submit(PorousMaterialsCalculation, **pm_input)  # pylint: disable=invalid-name
        self.report("pk: <{}> | Running Voronoi Energy Calculation".format(
            pm_ev.pk))
        return ToContext(pm_ev=pm_ev)
示例#2
0
    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)
示例#3
0
 def define(cls, spec):
     super().define(spec)
     spec.input('value', default=lambda: Str('A'))
     spec.input('n', default=lambda: Int(3))
     spec.outputs.dynamic = True
     spec.outline(
         cls.step1,
         if_(cls.is_a)(cls.step2).elif_(cls.is_b)(cls.step3).else_(cls.step4), # pylint: disable=no-member
         cls.step5,
         while_(cls.larger_then_n)(cls.step6,),
     )
示例#4
0
    def define(cls, spec):
        super().define(spec)

        spec.input(
            'test',
            valid_type=Str,
            serializer=lambda x: Str(ObjectLoader().identify_object(x)),
        )
        spec.input('reference', valid_type=Str)

        spec.outline(cls.do_test)
def example_multistage_al(cp2k_code):
    """Example usage: verdi run thistest.py cp2k@localhost"""

    print("Testing CP2K multistage workchain on Al (RKS, needs smearing)...")
    print(
        "EXPECTED: the OT (settings_0) will converge to a negative bandgap, then we switch to SMEARING (settings_1)"
    )

    thisdir = os.path.dirname(os.path.abspath(__file__))
    structure = StructureData(
        ase=ase.io.read(os.path.join(thisdir, '../data/Al.cif')))

    # testing user change of parameters and protocol
    parameters = Dict(
        dict={'FORCE_EVAL': {
            'DFT': {
                'MGRID': {
                    'CUTOFF': 250,
                }
            }
        }})
    protocol_mod = Dict(
        dict={
            'initial_magnetization': {
                'Al': 0
            },
            'settings_0': {
                'FORCE_EVAL': {
                    'DFT': {
                        'SCF': {
                            'OUTER_SCF': {
                                'MAX_SCF': 5,
                            }
                        }
                    }
                }
            }
        })

    # Construct process builder
    builder = Cp2kMultistageWorkChain.get_builder()
    builder.structure = structure
    builder.protocol_tag = Str('test')
    builder.starting_settings_idx = Int(0)
    builder.protocol_modify = protocol_mod
    builder.cp2k_base.cp2k.parameters = parameters
    builder.cp2k_base.cp2k.code = cp2k_code
    builder.cp2k_base.cp2k.metadata.options.resources = {
        "num_machines": 1,
        "num_mpiprocs_per_machine": 1,
    }
    builder.cp2k_base.cp2k.metadata.options.max_wallclock_seconds = 1 * 3 * 60

    run(builder)
示例#6
0
 def define(cls, spec):
     super().define(spec)
     spec.input('value', default=lambda: Str('A'))
     spec.input('n', default=lambda: Int(3))
     spec.outputs.dynamic = True
     spec.outline(
         cls.s1,
         if_(cls.isA)(cls.s2).elif_(cls.isB)(cls.s3).else_(cls.s4),
         cls.s5,
         while_(cls.ltN)(cls.s6),
     )
示例#7
0
    def define(cls, spec):
        super().define(spec)

        spec.input(
            'test',
            valid_type=Str,
            serializer=lambda x: Str(ObjectLoader().identify_object(x))
        )

        spec.outline(cls.echo)
        spec.outputs.dynamic = True
示例#8
0
 def finalize(self):
     """
     Return the output after the optimization procedure has finished.
     """
     self.report('Finalizing optimization procedure.')
     with self.optimizer() as opt:
         optimal_process_output = opt.result_value
         optimal_process_output.store()
         self.out('optimal_process_output', optimal_process_output)
         result_index = opt.result_index
         optimal_process = self.ctx[self.eval_key(result_index)]
         self.out('optimal_process_uuid', Str(optimal_process.uuid).store())
def main(codelabel):
    """Example usage: verdi run thistest.py cp2k@localhost"""

    print("Testing CP2K multistage workchain on Al (RKS, needs smearing)...")
    print("EXPECTED: the OT (settings_0) will converge to a negative bandgap, then we switch to SMEARING (settings_1)")

    code = Code.get_from_string(codelabel)

    thisdir = os.path.dirname(os.path.abspath(__file__))
    structure = StructureData(ase=ase.io.read(os.path.join(thisdir, '../data/Al.cif')))

    # testing user change of parameters and protocol
    parameters = Dict(dict={'FORCE_EVAL': {'DFT': {'MGRID': {'CUTOFF': 250,}}}})
    protocol_mod = Dict(dict={
        'initial_magnetization': {
            'Al': 0
        },
        'settings_0': {
            'FORCE_EVAL': {
                'DFT': {
                    'SCF': {
                        'OUTER_SCF': {
                            'MAX_SCF': 5,
                        }
                    }
                }
            }
        }
    })
    options = {
        "resources": {
            "num_machines": 1,
            "num_mpiprocs_per_machine": 1,
        },
        "max_wallclock_seconds": 1 * 3 * 60,
    }
    inputs = {
        'structure': structure,
        'protocol_tag': Str('test'),
        'starting_settings_idx': Int(0),
        'protocol_modify': protocol_mod,
        'cp2k_base': {
            'cp2k': {
                'parameters': parameters,
                'code': code,
                'metadata': {
                    'options': options,
                }
            }
        }
    }

    run(Cp2kMultistageWorkChain, **inputs)
示例#10
0
def main(code_string, incar, kmesh, structure, potential_family,
         potential_mapping, options):
    """Main method to setup the calculation."""

    # First, we need to fetch the AiiDA datatypes which will
    # house the inputs to our calculation
    dict_data = DataFactory('dict')
    kpoints_data = DataFactory('array.kpoints')

    # Then, we set the workchain you would like to call
    workchain = WorkflowFactory('vasp.master')

    # And finally, we declare the options, settings and input containers
    settings = AttributeDict()
    inputs = AttributeDict()

    # Organize settings
    settings.parser_settings = {
        'output_params': ['total_energies', 'maximum_force']
    }

    # Set inputs for the following WorkChain execution
    # Set code
    inputs.code = Code.get_from_string(code_string)
    # Set structure
    inputs.structure = structure
    # Set k-points grid density
    kpoints = kpoints_data()
    kpoints.set_kpoints_mesh(kmesh)
    inputs.kpoints = kpoints
    # Set parameters
    inputs.parameters = dict_data(dict=incar)
    # Set potentials and their mapping
    inputs.potential_family = Str(potential_family)
    inputs.potential_mapping = dict_data(dict=potential_mapping)
    # Set options
    inputs.options = dict_data(dict=options)
    # Set settings
    inputs.settings = dict_data(dict=settings)
    # Set workchain related inputs, in this case, give more explicit output to repor
    inputs.verbose = Bool(True)

    # Master, convergence and relaxation related parameters that is passed to the master,
    # convergence and relaxation workchain, respectively
    # Turn of relaxation
    relax = AttributeDict()
    relax.perform = Bool(False)
    inputs.relax = relax
    # Extract electronic band structure
    inputs.extract_bands = Bool(True)
    # Submit the requested workchain with the supplied inputs
    submit(workchain, **inputs)
示例#11
0
def run_multistage_h2om(cp2k_code):
    """Example usage: verdi run thistest.py cp2k@localhost"""

    print(
        "Testing CP2K multistage workchain on 2xH2O- (UKS, no need for smearing)..."
    )
    print("This is checking:")
    print(" > unit cell resizing")
    print(" > protocol modification")
    print(" > cp2k calc modification")

    atoms = ase.build.molecule('H2O')
    atoms.center(vacuum=2.0)
    structure = StructureData(ase=atoms)

    protocol_mod = Dict(dict={
        'settings_0': {
            'FORCE_EVAL': {
                'DFT': {
                    'MGRID': {
                        'CUTOFF': 300,
                    }
                }
            }
        }
    })
    parameters = Dict(dict={
        'FORCE_EVAL': {
            'DFT': {
                'UKS': True,
                'MULTIPLICITY': 3,
                'CHARGE': -2,
            }
        }
    })

    # Construct process builder
    builder = Cp2kMultistageWorkChain.get_builder()
    builder.structure = structure
    builder.min_cell_size = Float(4.1)
    builder.protocol_tag = Str('test')
    builder.protocol_modify = protocol_mod

    builder.cp2k_base.cp2k.parameters = parameters
    builder.cp2k_base.cp2k.code = cp2k_code
    builder.cp2k_base.cp2k.metadata.options.resources = {
        "num_machines": 1,
        "num_mpiprocs_per_machine": 1,
    }
    builder.cp2k_base.cp2k.metadata.options.max_wallclock_seconds = 1 * 3 * 60

    run(builder)
示例#12
0
    def define(cls, spec):
        super(ParseCalculation, cls).define(spec)

        spec.input('wannier_folder',
                   valid_type=FolderData,
                   help="Folder containing the Wannier90 output data.")
        spec.exit_code(300,
                       'ERROR_OUTPUT_MODEL_FILE',
                       message='The output model HDF5 file was not found.')
        spec.input('pos_kind',
                   valid_type=Str,
                   default=lambda: Str('wannier'),
                   help='Determines how the orbital positions are parsed.')
示例#13
0
def TI_sim(job_work_dir):
    task_abs_dir_list = glob.glob(os.path.join(job_work_dir.value, './task*'))
    task_dir_list = [
        os.path.relpath(ii, start=job_work_dir.value)
        for ii in task_abs_dir_list
    ]
    submission = get_empty_submission(job_work_dir.value)
    task_list = [
        Task(command='lmp_serial -i in.lammps', task_work_path=ii)
        for ii in task_dir_list
    ]
    submission.register_task_list(task_list=task_list)
    submission.run_submission()
    return Str(job_work_dir.value)
示例#14
0
    def define(cls, spec):
        super(FormchkCalculation, cls).define(spec)

        spec.input('parent_calc_folder',
                   valid_type=RemoteData,
                   required=True,
                   help='the folder of a containing the .chk')
        spec.input('chk_name',
                   valid_type=Str,
                   required=False,
                   default=lambda: Str(cls._DEFAULT_INPUT_FILE),
                   help="name of the checkpoint file")

        # Turn mpi off by default
        spec.input('metadata.options.withmpi', valid_type=bool, default=False)
def run_wf(pwscf_code, pw2wannier90_code, wannier_code):
    """Run a simple workflow running Quantum ESPRESSO+wannier90 for GaAs."""
    static_inputs = get_static_inputs()

    pseudo_family_name = get_or_create_pseudo_family()

    # Run the workflow
    run(
        MinimalW90WorkChain,
        pw_code=pwscf_code,  #load_code('pw-6.4-release@localhost'),
        pseudo_family=Str(
            pseudo_family_name),  #Str('SSSP_efficiency_pseudos'),
        wannier_code=wannier_code,  #load_code('wannier90-3-desktop@localhost'),
        pw2wannier90_code=
        pw2wannier90_code,  #load_code('pw2wannier90-6.4-release@localhost'),
        **static_inputs)
示例#16
0
    def parse(self):
        """Parse log file of premod."""

        # Check if retrieved folder is present.
        try:
            output_folder = self.premod_calc.retrieved
        except exceptions.NotExistent:
            return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER
        # Try to load the log file.
        try:
            with output_folder.open('PreModRun.log', 'r') as handle:
                result = self._parse_log(handle)
        except (OSError, IOError):
            return self.exit_codes.ERROR_READING_LOG_FILE
        if result is None:
            return self.exit_codes.ERROR_INVALID_LOG_OUTPUT

        return {'log': Str(result)}
示例#17
0
 def define(cls, spec):
     super(STMWorkChain, cls).define(spec)
     
     spec.input("cp2k_code", valid_type=Code)
     spec.input("structure", valid_type=StructureData)
     spec.input("wfn_file_path", valid_type=Str, default=lambda:Str(""))
     
     spec.input("dft_params", valid_type=Dict)
     
     spec.input("stm_code", valid_type=Code)
     spec.input("stm_params", valid_type=Dict)
     
     spec.outline(
         cls.run_scf_diag,
         cls.run_stm,
         cls.finalize,
     )
     
     spec.outputs.dynamic = True
def main(raspa_code_label, zeopp_code_label):
    """Prepare inputs and submit the Isotherm workchain.
    Usage: verdi run run_IsothermMultiTempWorkChain_HKUST-1.py raspa@localhost zeopp@localhost"""

    builder = IsothermWorkChain.get_builder()

    builder.metadata.label = "test"

    builder.raspa_base.raspa.code = Code.get_from_string(raspa_code_label)
    builder.zeopp.code = Code.get_from_string(zeopp_code_label)

    options = {
        "resources": {
            "num_machines": 1,
            "tot_num_mpiprocs": 1,
        },
        "max_wallclock_seconds": 1 * 60 * 60,
        "withmpi": False,
    }

    builder.raspa_base.raspa.metadata.options = options
    builder.zeopp.metadata.options = options

    builder.structure = CifData(file=os.path.abspath('data/TCC1RS.cif'),
                                label="TCC1RS")
    builder.molecule = Str('co2')
    builder.parameters = Dict(
        dict={
            'forcefield': 'UFF',  # Default: UFF
            'temperature_list': [
                400, 500
            ],  # (K) ******* NOTE: list for multi temperature *********
            'zeopp_volpo_samples':
            1000,  # Default: 1e5 *NOTE: default is good for standard real-case!
            'zeopp_block_samples': 10,  # Default: 100
            'raspa_widom_cycles': 100,  # Default: 1e5
            'raspa_gcmc_init_cycles': 10,  # Default: 1e3
            'raspa_gcmc_prod_cycles': 100,  # Default: 1e4
            'pressure_min': 0.001,  # Default: 0.001 (bar)
            'pressure_max': 3,  # Default: 10 (bar)
        })

    run(builder)
示例#19
0
def main(code_string, incar, kmesh, structures, potential_family,
         potential_mapping, options):
    """Main method to setup the calculation."""

    # First, we need to fetch the AiiDA datatypes which will
    # house the inputs to our calculation
    dict_data = DataFactory('dict')
    kpoints_data = DataFactory('array.kpoints')

    # Then, we set the workchain you would like to call
    workchain = EosWorkChain

    # And finally, we declare the options, settings and input containers
    settings = AttributeDict()
    inputs = AttributeDict()

    # organize settings
    settings.parser_settings = {
        'output_params': ['total_energies', 'maximum_force']
    }

    # set inputs for the following WorkChain execution
    # set code
    inputs.code = Code.get_from_string(code_string)
    # set structures
    inputs.structures = structures
    # set k-points grid density
    kpoints = kpoints_data()
    kpoints.set_kpoints_mesh(kmesh)
    inputs.kpoints = kpoints
    # set parameters
    inputs.parameters = dict_data(dict=incar)
    # set potentials and their mapping
    inputs.potential_family = Str(potential_family)
    inputs.potential_mapping = dict_data(dict=potential_mapping)
    # set options
    inputs.options = dict_data(dict=options)
    # set settings
    inputs.settings = dict_data(dict=settings)
    # set workchain related inputs, in this case, give more explicit output to report
    inputs.verbose = Bool(True)
    # submit the requested workchain with the supplied inputs
    submit(workchain, **inputs)
示例#20
0
 def define(cls, spec):
     super(SOAP, cls).define(spec)
     spec.input('aiida_structure', valid_type=StructureData)
     spec.input('spkit_max', valid_type=ParameterData)
     spec.input('aononymize', valid_type=Bool, default=Bool(True))
     spec.input('scale', valid_type=Bool, default=Bool(True))
     spec.input('scale_per', valid_type=Str, default=Str('site'))
     spec.input('soapargs', valid_type=ParameterData, required=False)
     spec.outline(
         cls.get_quippy_atoms,
         if_(cls.check_anonymize)(
             cls.anonymize_structure,
         )
         if_(cls.check_scale)(
             cls.scale_volume,
         )
         cls.get_soap_fingerprint
     )
     spec.output('soap', valid_type=Dict)
示例#21
0
def test_isotherm_mg_mof74(raspa_code, zeopp_code, mg_mof74_cifdata):
    """Test Isotherm workchain on MOF 74."""

    builder = IsothermWorkChain.get_builder()
    builder.raspa_base.raspa.code = raspa_code
    builder.zeopp.code = zeopp_code

    options = {
        "resources": {
            "num_machines": 1,
            "tot_num_mpiprocs": 1,
        },
        "max_wallclock_seconds": 1 * 60 * 60,
        "withmpi": False,
    }

    builder.raspa_base.raspa.metadata.options = options
    builder.zeopp.metadata.options = options

    builder.structure = mg_mof74_cifdata
    builder.molecule = Str('co2')
    builder.parameters = Dict(
        dict={
            'ff_framework': 'UFF',  # Default: UFF
            'temperature':
            400,  # (K) Note: higher temperature will have less adsorbate and it is faster
            'zeopp_volpo_samples':
            1000,  # Default: 1e5 *NOTE: default is good for standard real-case!
            'zeopp_block_samples': 10,  # Default: 100
            'raspa_widom_cycles': 100,  # Default: 1e5
            'raspa_gcmc_init_cycles': 10,  # Default: 1e3
            'raspa_gcmc_prod_cycles': 100,  # Default: 1e4
            'pressure_min': 0.001,  # Default: 0.001 (bar)
            'pressure_max': 3,  # Default: 10 (bar)
        })

    results = run(builder)

    params = results['output_parameters'].get_dict()

    assert params['Estimated_saturation_loading'] == pytest.approx(
        13.49433, 0.1), params
示例#22
0
    def define(cls, spec):
        super(SiestaSTMWorkChain, cls).define(spec)
        spec.input('code', valid_type=Code)
        spec.input('stm_code', valid_type=Code)
        spec.input('structure', valid_type=StructureData)
        spec.input('protocol', valid_type=Str, default=Str('standard'))
        spec.input('height', valid_type=Float)
        spec.input('e1', valid_type=Float)
        spec.input('e2', valid_type=Float)
        spec.outline(
            cls.setup_protocol,
            cls.setup_structure,
            cls.setup_kpoints,
            cls.setup_pseudo_potentials,
            cls.setup_parameters,
            cls.setup_basis,
            cls.run_relax,  # This should be optional
            cls.
            run_scf_and_ldos,  # We could run this directly, a combined scf+ldos
            cls.run_stm,
            cls.run_results,
        )

        spec.output('stm_array', valid_type=ArrayData)
        # These will be inherited from the Base workchain output
        #spec.output('output_structure',
        #            valid_type=StructureData,
        #            required=False)

        # This could be 'output_parameters', also inherited from the Base workchain, representing
        # the summary of energies, etc. coming out of the last SiestaCalculation run.
        # but its relevance is limited for a "stm" workflow. Left here for now for debugging.
        #spec.output('output_parameters', valid_type=Dict)

        spec.exit_code(140,
                       'ERROR_PROTOCOL_NOT_FOUND',
                       message='The protocol specified is not known')
        spec.exit_code(
            160,
            'ERROR_RELAXED_STRUCTURE_NOT_AVAILABLE',
            message='Failed to get the output structure from the relaxation run'
        )
def main(raspa_code_label, zeopp_code_label):
    """Prepare inputs and submit the Isotherm workchain.
    Usage: verdi run run_IsothermWorkChain_COF-1.py raspa@localhost network@localhost"""

    builder = IsothermWorkChain.get_builder()

    builder.metadata.label = "test"

    builder.raspa_base.raspa.code = Code.get_from_string(raspa_code_label)
    builder.zeopp.code = Code.get_from_string(zeopp_code_label)

    options = {
        "resources": {
            "num_machines": 1,
            "tot_num_mpiprocs": 1,
        },
        "max_wallclock_seconds": 1 * 60 * 60,
        "withmpi": False,
    }

    builder.raspa_base.raspa.metadata.options = options
    builder.zeopp.metadata.options = options

    builder.structure = CifData(file=os.path.abspath('data/COF-1.cif'),
                                label="COF-1")
    builder.molecule = Str('co2')
    builder.parameters = Dict(
        dict={
            'ff_framework': 'UFF',  # Default: UFF
            'temperature':
            400,  # (K) Note: higher temperature will have less adsorbate and it is faster
            'zeopp_volpo_samples':
            1000,  # Default: 1e5 *NOTE: default is good for standard real-case!
            'zeopp_block_samples': 10,  # Default: 100
            'raspa_widom_cycles': 100,  # Default: 1e5
            'raspa_gcmc_init_cycles': 10,  # Default: 1e3
            'raspa_gcmc_prod_cycles': 100,  # Default: 1e4
            'pressure_min': 0.001,  # Default: 0.001 (bar)
            'pressure_max': 3,  # Default: 10 (bar)
        })

    run(builder)
示例#24
0
    def run_isotherms(self):
        """Run Isotherm work chain for CO2 and N2."""

        inputs = self.exposed_inputs(IsothermWorkChain)
        self.report(
            "Run Isotherm work chain for CO2 and N2, in CifData<{}> (label: {} )"
            .format(self.inputs.structure.pk, self.inputs.structure.label))

        for mol in ['co2', 'n2']:

            dict_merge(
                inputs, {
                    'metadata': {
                        'call_link_label': 'run_isotherm_for_{}'.format(mol),
                    },
                    'molecule': Str(mol),
                    'parameters': self.inputs.parameters
                })

            running = self.submit(IsothermWorkChain, **inputs)
            self.to_context(**{'isotherm_{}'.format(mol): running})
def main(codelabel):
    """Example usage: verdi run thistest.py cp2k@localhost"""

    print("Testing CP2K multistage workchain on H2O")
    print(">>> Making it fail because of an unphysical Multiplicity")

    code = Code.get_from_string(codelabel)

    atoms = ase.build.molecule('H2O')
    atoms.center(vacuum=2.0)
    structure = StructureData(ase=atoms)

    options = {
        "resources": {
            "num_machines": 1,
            "num_mpiprocs_per_machine": 1,
        },
        "max_wallclock_seconds": 1 * 3 * 60,
    }
    parameters = Dict(dict={'FORCE_EVAL': {
        'DFT': {
            'UKS': True,
            'MULTIPLICITY': 666,
        }
    }})
    inputs = {
        'structure': structure,
        'protocol_tag': Str('test'),
        'cp2k_base': {
            'max_iterations': Int(1),
            'cp2k': {
                'parameters': parameters,
                'code': code,
                'metadata': {
                    'options': options,
                }
            }
        }
    }
    run(Cp2kMultistageWorkChain, **inputs)
示例#26
0
def main(cp2k_code_label):
    """Example usage: verdi run thistest.py cp2k@localhost"""

    cp2k_code = Code.get_from_string(cp2k_code_label)

    print("Testing CP2K BindingEnergy work chain for CO2 in Zn-MOF-74 ...")
    print("[NOTE: this test will run on 4 cpus and take ca. 10 minutes]")

    thisdir = os.path.dirname(os.path.abspath(__file__))

    # Construct process builder
    builder = BindingEnergyWorkChain.get_builder()
    builder.structure = StructureData(ase=ase.io.read(os.path.join(thisdir, 'data/Zn-MOF-74.cif')))
    builder.molecule = StructureData(ase=ase.io.read(os.path.join(thisdir, 'data/CO2_in_Zn-MOF-74.cif')))
    builder.protocol_tag = Str('test')
    builder.cp2k_base.cp2k.parameters = Dict(dict={ # Lowering CP2K default setting for a faster test calculation
        'FORCE_EVAL': {
            'DFT': {
                'SCF': {
                    'EPS_SCF': 1.0E-4,
                    'OUTER_SCF': {
                        'EPS_SCF': 1.0E-4,
                    },
                },
            },
        },
        'MOTION': {
            'GEO_OPT': {
                'MAX_ITER': 5
            }
        },
    })
    builder.cp2k_base.cp2k.code = cp2k_code
    builder.cp2k_base.cp2k.metadata.options.resources = {
        "num_machines": 1,
        "num_mpiprocs_per_machine": 4,
    }
    builder.cp2k_base.cp2k.metadata.options.max_wallclock_seconds = 1 * 5 * 60

    run(builder)
示例#27
0
def HTI_start(start_info, NVT_end_info):
    work_base_abs_dir = start_info['work_base_abs_dir']
    dag_work_dir = start_info['dag_work_dir']
    if_liquid = start_info['if_liquid']
    conf_lmp = NVT_end_info['out_lmp']

    job_work_dir = Str(os.path.join(dag_work_dir, 'HTI_sim', 'new_job'))
    if os.path.isfile(
            os.path.join(dag_work_dir, 'HTI_sim', 'new_job', 'result.json')):
        return job_work_dir

    if if_liquid:
        with open(os.path.join(work_base_abs_dir, 'hti.liquid.json')) as j:
            hti_jdata = json.load(j)
    else:
        with open(os.path.join(work_base_abs_dir, 'hti.json')) as j:
            hti_jdata = json.load(j)

    task_jdata = hti_jdata.copy()
    # task_jdata['equi_conf'] = "../NVT_sim/new_job/out.lmp"
    # task_jdata['equi_conf'] = os.path.join(start_info['dag_work_dir'], 'NVT_sim', 'new_job', 'out.lmp')
    if conf_lmp is not None:
        task_jdata['equi_conf'] = conf_lmp
    else:
        task_jdata['equi_conf'] = start_info['conf_lmp']

    task_jdata['temp'] = start_info['target_temp']
    task_jdata['pres'] = start_info['target_pres']

    cwd = os.getcwd()
    os.chdir(work_base_abs_dir)
    if if_liquid:
        hti_liq.make_tasks(iter_name=job_work_dir.value, jdata=task_jdata)
    else:
        hti.make_tasks(iter_name=job_work_dir.value,
                       jdata=task_jdata,
                       ref='einstein',
                       switch='three-step')
    os.chdir(cwd)
    return job_work_dir
示例#28
0
def run_multistage_h2o_singlepoint(cp2k_code):
    """Example usage: verdi run thistest.py cp2k@localhost"""

    print("Testing CP2K multistage workchain on H2O")
    print(">>> Using 'singlepoint' tag, with no output structure")

    atoms = ase.build.molecule('H2O')
    atoms.center(vacuum=2.0)
    structure = StructureData(ase=atoms)

    # Construct process builder
    builder = Cp2kMultistageWorkChain.get_builder()
    builder.structure = structure
    builder.protocol_tag = Str('singlepoint')
    builder.cp2k_base.cp2k.code = cp2k_code
    builder.cp2k_base.cp2k.metadata.options.resources = {
        "num_machines": 1,
        "num_mpiprocs_per_machine": 1,
    }
    builder.cp2k_base.cp2k.metadata.options.max_wallclock_seconds = 1 * 3 * 60

    run(builder)
示例#29
0
def NPT_start(start_info):
    work_base_abs_dir = start_info['work_base_abs_dir']
    dag_work_dir = start_info['dag_work_dir']
    job_work_dir = Str(os.path.join(dag_work_dir, 'NPT_sim', 'new_job'))

    result_json_file = os.path.join(job_work_dir.value, 'result.json')
    if os.path.isfile(result_json_file):
        return job_work_dir
    with open(os.path.join(work_base_abs_dir, 'npt.json')) as f:
        npt_jdata = json.load(f)

    task_jdata = npt_jdata.copy()
    task_jdata['equi_conf'] = start_info['conf_lmp']
    task_jdata['temp'] = start_info['target_temp']
    task_jdata['pres'] = start_info['target_pres']
    task_jdata['ens'] = start_info['ens']
    print(task_jdata)
    cwd = os.getcwd()
    os.chdir(work_base_abs_dir)
    equi.make_task(job_work_dir.value, task_jdata)
    os.chdir(cwd)
    return job_work_dir
示例#30
0
    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