def run_afms(self):
     self.report("Running PP")
     
     afm_pp_inputs = {}
     afm_pp_inputs['_label'] = "afm_pp"
     afm_pp_inputs['code'] = self.inputs.afm_pp_code
     afm_pp_inputs['parameters'] = self.inputs.afm_pp_params
     afm_pp_inputs['parent_calc_folder'] = self.ctx.scf_diag.out.remote_folder
     afm_pp_inputs['atomtypes'] = SinglefileData(file="/project/apps/scanning_probe/afm/atomtypes_pp.ini")
     afm_pp_inputs['_options'] = {
         "resources": {"num_machines": 1},
         "max_wallclock_seconds": 7200,
     }
     self.report("Afm pp inputs: " + str(afm_pp_inputs))
     afm_pp_future = submit(AfmCalculation.process(), **afm_pp_inputs)
     self.to_context(afm_pp=Calc(afm_pp_future))
     
     self.report("Running 2PP")
     
     afm_2pp_inputs = {}
     afm_2pp_inputs['_label'] = "afm_2pp"
     afm_2pp_inputs['code'] = self.inputs.afm_2pp_code
     afm_2pp_inputs['parameters'] = self.inputs.afm_2pp_params
     afm_2pp_inputs['parent_calc_folder'] = self.ctx.scf_diag.out.remote_folder
     afm_2pp_inputs['atomtypes'] = SinglefileData(file="/project/apps/scanning_probe/afm/atomtypes_2pp.ini")
     afm_2pp_inputs['_options'] = {
         "resources": {"num_machines": 1},
         "max_wallclock_seconds": 7200,
     }
     self.report("Afm 2pp inputs: " + str(afm_2pp_inputs))
     afm_2pp_future = submit(AfmCalculation.process(), **afm_2pp_inputs)
     self.to_context(afm_2pp=Calc(afm_2pp_future))
    def setup(self):
        """
        Launch the first calculation for the input structure,
        and a second calculation for a shifted volume (increased by 4 angstrom^3)
        Store the outputs of the two calcs in r0 and r1
        """
        print "Workchain node identifiers: {}".format(self.calc)

        inputs0 = generate_scf_input_params(self.inputs.structure,
                                            str(self.inputs.code),
                                            self.inputs.pseudo_family)

        initial_volume = self.inputs.structure.get_cell_volume()
        new_volume = initial_volume + 4.  # In ang^3

        scaled_structure = get_structure(self.inputs.structure, new_volume)
        inputs1 = generate_scf_input_params(scaled_structure,
                                            str(self.inputs.code),
                                            self.inputs.pseudo_family)

        self.ctx.last_structure = scaled_structure

        # Run PW
        future0 = submit(PwProcess, **inputs0)
        future1 = submit(PwProcess, **inputs1)

        # Wait to complete before next step
        return ToContext(r0=future0, r1=future1)
예제 #3
0
    def run_export_orbitals(self):
        self.report("Running pp.x to export KS orbitals")

        inputs = {}
        inputs['_label'] = "export_orbitals"
        inputs['code'] = self.inputs.pp_code
        prev_calc = self.ctx.bands_lowres
        self._check_prev_calc(prev_calc)
        inputs['parent_folder'] = prev_calc.out.remote_folder

        nel = prev_calc.res.number_of_electrons
        nkpt = prev_calc.res.number_of_k_points
        nbnd = prev_calc.res.number_of_bands
        nspin = prev_calc.res.number_of_spin_components
        volume = prev_calc.res.volume
        #for....
        kband1 = max(int(nel/2) - 6, 1)
        kband2 = min(int(nel/2) + 7, nbnd)
        kpoint1 = 1
        kpoint2 = nkpt * nspin
        nhours = 8 #24# 2 + min(22, 2*int(volume/1500))

        for inb in range(kband1,kband2+1):     
            parameters = ParameterData(dict={
                  'inputpp': {
                      # contribution of a selected wavefunction
                      # to charge density
                      'plot_num': 7,
                      'kpoint(1)': kpoint1,
                      'kpoint(2)': kpoint2,
                      #'kband(1)': kband1,
                      #'kband(2)': kband2,
                      'kband(1)': inb,
                      'kband(2)': inb,
                  },
                  'plot': {
                      'iflag': 3,  # 3D plot
                      'output_format': 6,  # CUBE format
                      'fileout': '_orbital.cube',
                  },
            })
            inputs['parameters'] = parameters

            inputs['_options'] = {
                "resources": {"num_machines": 1},
                "max_wallclock_seconds": nhours * 60 * 60,  # 6 hours
                "append_text": self._get_cube_cutter(),
            }

            settings = ParameterData(
                     dict={'additional_retrieve_list': ['*.cube.gz']}
                   )
            inputs['settings'] = settings

        #future = submit(PpCalculation.process(), **inputs)
            submit(PpCalculation.process(), **inputs)
        #return ToContext(orbitals=Calc(future))
        return
def main(codelabel, block_pockets):
    code = test_and_get_code(codelabel, expected_code_type='raspa')

    options_dict = {
        "resources": {
            "num_machines": 1,
            "num_mpiprocs_per_machine": 1,
        },
        "max_wallclock_seconds": 3 * 60 * 60,
    }

    options = ParameterData(dict=options_dict)

    params_dict = {
        "GeneralSettings": {
            "SimulationType": "MonteCarlo",
            "NumberOfCycles": 2000,
            "NumberOfInitializationCycles": 2000,
            "PrintEvery": 1000,
            "Forcefield": "GenericMOFs",
            "EwaldPrecision": 1e-6,
            "CutOff": 12.0,
            "Framework": 0,
            "UnitCells": "1 1 1",
            "HeliumVoidFraction": 0.149,
            "ExternalTemperature": 300.0,
            "ExternalPressure": 5e5,
        },
        "Component": [{
            "MoleculeName": "methane",
            "MoleculeDefinition": "TraPPE",
            "TranslationProbability": 0.5,
            "ReinsertionProbability": 0.5,
            "SwapProbability": 1.0,
            "CreateNumberOfMolecules": 0,
        }],
    }
    parameters = ParameterData(dict=params_dict)

    # structure
    pwd = os.path.dirname(os.path.realpath(__file__))
    structure = CifData(file=pwd + '/test_raspa_attach_file/TCC1RS.cif')

    # block pockets
    bp = load_node(block_pockets)

    submit(
        RaspaConvergeWorkChain,
        code=code,
        structure=structure,
        parameters=parameters,
        block_component_0=bp,
        options=options,
        _label='MyFirstWokchain',
    )
예제 #5
0
def run_si_scf(codename, pseudo_family):
    JobCalc = PwCalculation.process()
    inputs = JobCalc.get_inputs_template()

    inputs.code = Code.get_from_string(codename)
    # calc.label = "PW test"
    # calc.description = "My first AiiDA calculation of Silicon with Quantum ESPRESSO"
    inputs._options.resources = {"num_machines": 1}
    inputs._options.max_wallclock_seconds = 30 * 60

    # The structure
    alat = 5.4
    the_cell = [[alat / 2., alat / 2., 0], [alat / 2., 0, alat / 2.],
                [0, alat / 2., alat / 2.]]
    StructureData = DataFactory("structure")
    structure = StructureData(cell=the_cell)
    structure.append_atom(position=(0., 0., 0.), symbols="Si")
    structure.append_atom(position=(alat / 4., alat / 4., alat / 4.),
                          symbols="Si")
    inputs.structure = structure

    # Kpoints
    KpointsData = DataFactory("array.kpoints")
    kpoints = KpointsData()
    kpoints_mesh = 2
    kpoints.set_kpoints_mesh([kpoints_mesh, kpoints_mesh, kpoints_mesh])
    inputs.kpoints = kpoints

    # Calculation parameters
    parameters_dict = {
        "CONTROL": {
            "calculation": "scf",
            "tstress": True,
            "tprnfor": True,
        },
        "SYSTEM": {
            "ecutwfc": 30.,
            "ecutrho": 200.,
        },
        "ELECTRONS": {
            "conv_thr": 1.e-6,
        }
    }
    ParameterData = DataFactory("parameter")
    inputs.parameters = ParameterData(dict=parameters_dict)

    # Pseudopotentials
    inputs.pseudo = get_pseudos(structure, pseudo_family)

    # calc.set_extra("element", "Si")
    # calc.submit()
    submit(JobCalc, **inputs)
예제 #6
0
    def test_multiple_processes(self):
        submit(DummyProcess, _jobs_store=self.storage)
        submit(ExceptionProcess, _jobs_store=self.storage)
        submit(ExceptionProcess, _jobs_store=self.storage)
        submit(DummyProcess, _jobs_store=self.storage)

        self.assertFalse(
            daemon.tick_workflow_engine(self.storage, print_exceptions=False))
예제 #7
0
def launch(code, structure, pseudo_family, daemon, protocol):
    """
    Run the PwBandStructureWorkChain for a given input structure 
    to compute the band structure for the relaxed structure
    """
    from aiida.orm.data.base import Str
    from aiida.orm.utils import WorkflowFactory
    from aiida.work.run import run, submit

    PwBandStructureWorkChain = WorkflowFactory(
        'quantumespresso.pw.band_structure')

    inputs = {
        'code': code,
        'structure': structure,
        'pseudo_family': Str(pseudo_family),
        'protocol': Str(protocol),
    }

    if daemon:
        workchain = submit(PwBandStructureWorkChain, **inputs)
        click.echo('Submitted {}<{}> to the daemon'.format(
            PwBandStructureWorkChain.__name__, workchain.pid))
    else:
        run(PwBandStructureWorkChain, **inputs)
예제 #8
0
    def run_cp2k_charge_density(self):
        """
        Compute the charge-density of a structure that can be later used for extracting ddec point charges.
        """
        options = {
            "resources": {
                "num_machines": 4,
                "num_mpiprocs_per_machine": 12,
            },
            "max_wallclock_seconds": 3 * 60 * 60,
        }

        inputs = {
            'code'       : Code.get_from_string(self.inputs.cp2k_codename.value),
            'structure'  : from_cif_to_structuredata(self.ctx.processed_structure),
            'parameters' : self.inputs.cp2k_parameters,
            '_options'   : options,
            '_label'     : "run_chargedensity_cp2k",
        }

        # Create the calculation process and launch it
        process = Cp2kCalculation.process()
        future  = submit(process, **inputs)
        self.report("pk: {} | Running cp2k to compute the charge-density")
        self.ctx.cp2k_pid=future.pid
        return ToContext(cp2k=Outputs(future))
예제 #9
0
def launch(
    code, parent_calc, kpoints, max_num_machines, max_wallclock_seconds, daemon):
    """
    Run the MatdynBaseWorkChain for a previously completed Q2rCalculation
    """
    from aiida.orm.data.parameter import ParameterData
    from aiida.orm.utils import CalculationFactory, WorkflowFactory
    from aiida.work.run import run, submit
    from aiida_quantumespresso.utils.resources import get_default_options

    MatdynBaseWorkChain = WorkflowFactory('quantumespresso.matdyn.base')

    options = get_default_options(max_num_machines, max_wallclock_seconds)

    inputs = {
        'code': code,
        'kpoints': kpoints,
        'parent_folder': parent_calc.out.force_constants,
        'options': ParameterData(dict=options),
    }

    if daemon:
        workchain = submit(MatdynBaseWorkChain, **inputs)
        click.echo('Submitted {}<{}> to the daemon'.format(MatdynBaseWorkChain.__name__, workchain.pid))
    else:
        run(MatdynBaseWorkChain, **inputs)
예제 #10
0
    def run_cellopt_init(self):
        """Run CELL_OPT calculation."""

        # For the first time we do wery rough cell optimization with only 20 steps max and keeping angles fixed.
        geo_motion = {
            'MOTION': {
                'CELL_OPT': {
                    'MAX_ITER': 20,
                    'KEEP_ANGLES': True,
                },
            },
        }
        dict_merge(geo_motion, self.ctx.last_dft_dict)
        inputs = {
            'code':
            self.inputs.code,
            'structure':
            self.ctx.structure,
            'parameters':
            merge_ParameterData(self.ctx.parameters,
                                ParameterData(dict=geo_motion)),
            '_options':
            self.inputs._options,
            '_label':
            'Stage1_CellOpt',
        }

        # restart wavefunctions if they are provided
        if self.ctx.restart_calc:
            inputs['parent_folder'] = self.ctx.restart_calc

        # run the calculation
        running = submit(Cp2kCellOptWorkChain, **inputs)
        self.report("pk: {} | Running cp2k CELL_OPT".format(running.pid))
        return ToContext(cp2k=Outputs(running))
예제 #11
0
    def run_extmol(self):
        """
        Run the SiestaBaseWorkChain to calculate the extended molecule
        structure
        """

        self.report('Running run_extmol')

        siesta_inputs = dict(self.ctx.siesta_inputs)

        rem_inputs = {}
        rem_inputs['code'] = siesta_inputs['siesta_code']
        rem_inputs['kpoints'] = self.ctx.kpoints_em
        rem_inputs['basis'] = ParameterData(dict=siesta_inputs['basis'])
        rem_inputs['structure'] = self.ctx.structure_em
        rem_inputs['pseudos'] = siesta_inputs['pseudos']
        rem_inputs['parameters'] = ParameterData(
            dict=siesta_inputs['parameters'])
        rem_inputs['settings'] = ParameterData(dict=siesta_inputs['settings'])
        rem_inputs['clean_workdir'] = Bool(False)
        rem_inputs['max_iterations'] = Int(20)
        rem_inputs['options'] = siesta_inputs['options']

        running = submit(SiestaBaseWorkChain, **rem_inputs)

        self.report(
            'launched SiestaBaseWorkChain<{}> in run-Siesta mode'.format(
                running.pid))

        return ToContext(workchain_extmol=running)
예제 #12
0
파일: dos.py 프로젝트: broeder-j/aiida-kkr
    def get_dos(self):
        """
        submit a dos calculation and interpolate result if returns complete
        """

        label = 'KKR DOS calc.'
        dosdict = self.ctx.dos_params_dict
        description = 'dos calculation using the following parameter set. emin= {}, emax= {}, nepts= {}, tempr={}, kmesh={}'.format(
            dosdict['emin'], dosdict['emax'], dosdict['nepts'],
            dosdict['tempr'], dosdict['kmesh'])
        code = self.inputs.kkr
        remote = self.inputs.remote_data
        params = self.ctx.dos_kkrparams
        options = {
            "max_wallclock_seconds": self.ctx.walltime_sec,
            "resources": self.ctx.resources,
            "queue_name": self.ctx.queue
        }  #,
        if self.ctx.custom_scheduler_commands:
            options[
                "custom_scheduler_commands"] = self.ctx.custom_scheduler_commands
        inputs = get_inputs_kkr(code,
                                remote,
                                options,
                                label,
                                description,
                                parameters=params,
                                serial=(not self.ctx.use_mpi))

        # run the DOS calculation
        self.report('INFO: doing calculation')
        dosrun = submit(KkrProcess, **inputs)

        return ToContext(dosrun=dosrun)
예제 #13
0
    def run_zeopp(self):
        """Main function that performs zeo++ VOLPO and block calculations."""
        params = {
                'ha': True,
                #100 samples / Ang^3: accurate for all the structures
                'block': [self.inputs.zeopp_probe_radius.value, 100],
                #100k samples, may need more for structures bigger than 30x30x30
                'volpo': [self.inputs.zeopp_probe_radius.value,
                          self.inputs.zeopp_probe_radius.value, 100000]
        }

        inputs = {
            'code'         : self.inputs.zeopp_code,
            'structure'    : self.inputs.structure,
            'parameters'   : NetworkParameters(dict=params).store(),
            '_options'     : self.inputs._zeopp_options,
            '_label'       : "ZeoppVolpoBlock",
        }

        # Use default zeopp atomic radii only if a .rad file is not specified
        try:
            inputs['atomic_radii'] = self.inputs.zeopp_atomic_radii
            self.report("Zeopp will use atomic radii from the .rad file")
        except:
            self.report("Zeopp will use default atomic radii")

        # Create the calculation process and launch it
        running = submit(ZeoppCalculation.process(), **inputs)
        self.report("pk: {} | Running zeo++ volpo and block calculations".format(running.pid))
        return ToContext(zeopp=Outputs(running))
예제 #14
0
    def run_zeopp(self):

        self.report("Running workchain for structure {}".format(
            self.inputs.structure.filename))

        label = "zeopp"
        inputs = {}
        inputs['_label'] = label
        inputs['_description'] = "Sampling accessible pore surface with zeo++"
        inputs['code'] = self.inputs.zeopp_code
        inputs['structure'] = self.inputs.structure

        NetworkParameters = DataFactory('zeopp.parameters')
        network_dict = {
            'cssr': True,
            'ha': True,
            'vsa': [1.8, 1.8, 1000],
            'sa': [1.8, 1.8, 1000],
        }
        inputs['parameters'] = NetworkParameters(dict=network_dict)
        inputs['_options'] = self.default_options

        NetworkCalculation = CalculationFactory('zeopp.network')
        future = submit(NetworkCalculation.process(), **inputs)
        self.report(
            "pk: {} | Submitted zeo++ calculation for structure {}".format(
                future.pid, self.inputs.structure.filename))

        return ToContext(**{label: Outputs(future)})
예제 #15
0
    def run_inpgen(self):
        """
        So far run inpgen and see what you get
        """

        structure = self.inputs.structure
        self.ctx.formula = structure.get_formula()
        label = 'scf: inpgen'
        description = '{} inpgen on {}'.format(self.ctx.description_wf,
                                               self.ctx.formula)

        inpgencode = self.inputs.inpgen
        if 'calc_parameters' in self.inputs:
            params = self.inputs.calc_parameters
        else:
            params = None

        options = {
            "max_wallclock_seconds": self.ctx.walltime_sec,
            "resources": self.ctx.resources,
            "queue_name": self.ctx.queue
        }

        inputs = get_inputs_inpgen(structure,
                                   inpgencode,
                                   options,
                                   label,
                                   description,
                                   params=params)
        self.report('INFO: run inpgen')
        future = submit(FleurinpProcess, **inputs)

        return ToContext(inpgen=future, last_calc=future)
예제 #16
0
    def run_relax(self):
        """
        Run the PwRelaxWorkChain to run a relax PwCalculation
        """
        inputs = self.inputs.relax
        inputs.update({
            'code': self.inputs.code,
            'structure': self.inputs.structure,
            'pseudo_family': self.inputs.pseudo_family,
        })

        # If options set, add it to the default inputs
        if 'options' in self.inputs:
            inputs['options'] = self.inputs.options

        # If automatic parallelization was set, add it to the default inputs
        if 'automatic_parallelization' in self.inputs:
            inputs[
                'automatic_parallelization'] = self.inputs.automatic_parallelization

        running = submit(PwRelaxWorkChain, **inputs)

        self.report('launching PwRelaxWorkChain<{}>'.format(running.pid))

        return ToContext(workchain_relax=running)
예제 #17
0
    def run_geo_opt(self):
        """Optimize the geometry using the robust 5 steps process"""
        self.ctx.structure = multiply_unit_cell(self.inputs.structure, self.inputs.min_cell_size)
        cp2k_parameters = deepcopy(self.inputs.cp2k_parameters.get_dict())

       # Expand the unit cell so that: min(perpendicular_width) > threshold
        inputs = {
            'code'          : self.inputs.cp2k_code,
            'structure'     : self.ctx.structure,
            'min_cell_size' : self.inputs.min_cell_size,
            '_options'      : self.inputs._cp2k_options,
            '_label'        : "Cp2kRobustGeoOptWorkChain",
        }

        # Trying to guess the multiplicity of the system
        if self.inputs._guess_multiplicity:
            self.report("Guessing multiplicity")
            dict_merge(cp2k_parameters, guess_multiplicity(self.ctx.structure).get_dict())

        # Take parameters
        self.ctx.cp2k_parameters = ParameterData(dict=cp2k_parameters)
        inputs['parameters'] = self.ctx.cp2k_parameters

        # Create the calculation process and launch it
        running = submit(Cp2kRobustGeoOptWorkChain, **inputs)
        self.report("pk: {} | Running Cp2kRobustGeoOptWorkChain to optimize geometry".format(running.pid))
        return ToContext(geo_opt_calc=Outputs(running))
예제 #18
0
    def run_loading_raspa(self):
        """
        This is the main function that will perform a raspa
        calculation for the current pressure
        """
        pressure = self.ctx.pressures[self.ctx.p]
        self.ctx.raspa_parameters['GeneralSettings']['ExternalPressure'] = pressure
        if self.ctx.prev_pk is not None:
            self.ctx.raspa_parameters['GeneralSettings']['RestartFile'] = True
            self.ctx.raspa_parameters['GeneralSettings']['RestartFilePk'] = self.ctx.prev_pk

        # Create the input dictionary
        inputs = {
            'code'       : Code.get_from_string(self.inputs.raspa_codename.value),
            'structure'  : self.ctx.processed_structure,
            'parameters' : ParameterData(dict=self.ctx.raspa_parameters),
            '_options'   : self.inputs._options,
            '_label'     : "run_loading_raspa",
        }

        # 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, pressure/1e5))

        self.ctx.p += 1
        self.ctx.prev_pk = future.pid

        return ToContext(raspa=Outputs(future))
예제 #19
0
    def run_block_zeopp(self):
        """
        This is the main function that will perform a raspa
        calculation for the current pressure
        """

        NetworkParameters = DataFactory('zeopp.parameters')
        # Create the input dictionary
        sigma = self.inputs.probe_molecule.get_dict()['sigma']
        params = {
            'ha':True,
            'block': [sigma, 200],
        }
        inputs = {
            'code'       : Code.get_from_string(self.inputs.zeopp_codename.value),
            'structure'  : self.ctx.processed_structure,
            'parameters' : NetworkParameters(dict=params),
            '_options'   : self.inputs._options,
            '_label'     : "run_block_zeopp",

        }

        # Create the calculation process and launch it
        process = ZeoppCalculation.process()
        future  = submit(process, **inputs)
        self.report("pk: {} | Running zeo++ block volume calculation".format(future.pid))
        
        self.ctx.block_pk = future.pid

        return ToContext(zeopp=Outputs(future))
예제 #20
0
    def run_fleurinpgen(self):
        """
        run the inpgen
        """
        structure = self.inputs.structure
        inpgencode = self.inputs.inpgen
        if 'calc_parameters' in self.inputs:
            params = self.inputs.calc_parameters
        else:
            params = None

        options = {
            "max_wallclock_seconds": self.ctx.walltime_sec,
            "resources": self.ctx.resources,
            "queue_name": self.ctx.queue
        }

        inputs = get_inputs_inpgen(structure,
                                   inpgencode,
                                   options,
                                   params=params)
        print 'run inpgen'
        future = submit(FleurinpProcess, **inputs)

        return ToContext(inpgen=future, last_calc=future)
예제 #21
0
    def run_ph(self):
        """
        Run a PhCalculation either starting from a previous PwCalculation or restarting from a
        previous PhCalculation run in this workchain
        """
        self.ctx.iteration += 1

        # Create local copy of general inputs stored in the context and adapt for next calculation
        inputs = dict(self.ctx.inputs)

        if isinstance(self.ctx.restart_calc, PhCalculation):
            inputs['parameters']['INPUTPH']['recover'] = True
        elif isinstance(self.ctx.restart_calc, PwCalculation):
            pass
        else:
            ctype = type(self.ctx.restart_calc)
            self.abort_nowait(
                "The type '{}' of the parent calculation is invalid".format(
                    ctype))

        inputs['parent_folder'] = self.ctx.restart_calc.out.remote_folder
        inputs['parameters'] = ParameterData(dict=inputs['parameters'])
        inputs['settings'] = ParameterData(dict=inputs['settings'])

        process = PhCalculation.process()
        running = submit(process, **inputs)

        self.report('launching PhCalculation<{}> iteration #{}'.format(
            running.pid, self.ctx.iteration))

        return ToContext(calculations=append_(running))
예제 #22
0
    def run_bands(self):
        """
        Run the PwBaseWorkChain to run a bands PwCalculation along the path of high-symmetry determined by Seekpath
        """
        try:
            remote_folder = self.ctx.workchain_scf.out.remote_folder
        except AttributeError as exception:
            self.abort_nowait(
                'the scf workchain did not output a remote_folder node')
            return

        inputs = self.ctx.inputs
        restart_mode = 'restart'
        calculation_mode = 'bands'

        # Set the correct pw.x input parameters
        inputs.parameters['CONTROL']['restart_mode'] = restart_mode
        inputs.parameters['CONTROL']['calculation'] = calculation_mode

        if 'kpoints' in self.inputs:
            inputs.kpoints = self.inputs.kpoints
        else:
            inputs.kpoints = self.ctx.kpoints_path

        inputs.structure = self.ctx.structure
        inputs.parent_folder = remote_folder

        inputs = prepare_process_inputs(inputs)
        running = submit(PwBaseWorkChain, **inputs)

        self.report('launching PwBaseWorkChain<{}> in {} mode'.format(
            running.pid, calculation_mode))

        return ToContext(workchain_bands=running)
예제 #23
0
    def optimize_cycle(self):

        if not 'counter' in self.ctx:
            self.ctx.counter = 0

        self.ctx.counter += 1

        # self.ctx._get_dict()
        print ('start optimization')

        if not 'optimize' in self.ctx:
            structure = self.inputs.structure
        else:
            structure = parse_optimize_calculation(self.ctx.optimize)['output_structure']

        if self.inputs.standarize_cell:
            structure = standardize_cell(structure)['standardized_structure']

        JobCalculation, calculation_input = generate_inputs(structure,
                                                            self.inputs.es_settings,
                                                            pressure=self.inputs.pressure,
                                                            type='optimize',
                                                            )

        calculation_input._label = 'optimize'
        future = submit(JobCalculation, **calculation_input)
        self.report('optimize calculation pk = {}'.format(future.pid))

        return ToContext(optimize=future)
예제 #24
0
    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)
예제 #25
0
    def run_geom_zeopp(self):
        """This is the main function that will perform a raspa calculation for the current pressure"""
        # network parameters
        sigma = self.inputs.probe_molecule.dict.sigma
        NetworkParameters = DataFactory('zeopp.parameters')
        params = NetworkParameters({
            'ha': True,
            'res': True,
            'sa': [sigma, sigma, 100000],
            'volpo': [sigma, sigma, 100000],
        })

        # Create the input dictionary
        inputs = {
            'code': self.inputs.zeopp_code,
            'structure': self.ctx.structure,
            'parameters': params,
            '_options': self.inputs.zeopp_options.get_dict(),
            '_label': "run_geom_zeopp",
        }

        # Create the calculation process and launch it
        running = submit(ZeoppCalculation.process(), **inputs)
        self.report("pk: {} | Running geometry analysis with zeo++".format(
            running.pid))

        return ToContext(zeopp=Outputs(running))
예제 #26
0
    def run_henry_raspa(self):
        """This is the main function that will perform a raspaa calculation for the current pressure"""
        raspa_parameters = self.inputs.raspa_parameters.get_dict()
        raspa_parameters['GeneralSettings'].pop('ExternalPressure')
        for i, comp in enumerate(raspa_parameters['Component']):
            name = comp['MoleculeName']
            raspa_parameters['Component'][0] = {
                "MoleculeName": name,
                "MoleculeDefinition": "TraPPE",
                "WidomProbability": 1.0,
                "CreateNumberOfMolecules": 0,
            }
        # Create the input dictionary
        inputs = {
            'code': self.inputs.raspa_code,
            'structure': self.ctx.structure,
            'parameters': ParameterData(dict=raspa_parameters),
            'options': self.inputs.raspa_options,
            '_label': "run_henry_raspa",
        }

        # Create the calculation process and launch it
        running = submit(RaspaConvergeWorkChain, **inputs)
        self.report("pk: {} | Running raspa for the Henry coefficients".format(
            running.pid))

        return ToContext(raspa_henry=Outputs(running))
예제 #27
0
    def run_raspa_gcmc(self):
        """Run a GCMC calculation in Raspa @ T,P. """
        pressure = self.ctx.pressures[self.ctx.current_p_index]
        self.ctx.raspa_parameters['GeneralSettings'][
            'ExternalPressure'] = pressure

        # Create the input dictionary
        inputs = {
            'code': self.inputs.raspa_code,
            'structure': self.inputs.structure,
            'parameters':
            ParameterData(dict=self.ctx.raspa_parameters).store(),
            '_options': self.inputs._raspa_options,
            '_label': "RaspaGCMC",
        }
        # Check if there are poket blocks to be loaded
        if self.ctx.number_blocking_spheres > 0:
            inputs['block_component_0'] = self.ctx.zeopp['block']

        # Check if there is a previous calculation (lower p) to restart from
        if self.ctx.restart_raspa_calc is not None:
            inputs['retrieved_parent_folder'] = self.ctx.restart_raspa_calc

        # Create the calculation process and launch it
        running = submit(RaspaConvergeWorkChain, **inputs)
        self.report(
            "pk: {} | Running Raspa GCMC at p(bar)={:.3f} ({} of {})".format(
                running.pid, pressure / 1e5, self.ctx.current_p_index + 1,
                len(self.ctx.pressures)))
        return ToContext(raspa_gcmc=Outputs(running))
예제 #28
0
    def run_raspa_widom(self):
        """Run a Widom calculation in Raspa."""

        # Create the inputs dictionary
        inputs = {
            'code': self.inputs.raspa_code,
            'structure': self.inputs.structure,
            'parameters':
            ParameterData(dict=self.ctx.raspa_parameters).store(),
            '_options': self.inputs._raspa_options,
            '_label': "RaspaWidom",
        }

        # Check if there are blocking spheres (reading the header of the file) and use them for Raspa
        with open(self.ctx.zeopp['block'].get_abs_path() + '/path/' + \
                  self.ctx.zeopp['block'].get_folder_list()[0]) as f:
            self.ctx.number_blocking_spheres = int(f.readline().strip())
        if self.ctx.number_blocking_spheres > 0:
            inputs['block_component_0'] = self.ctx.zeopp['block']
            self.report(
                "Blocking spheres ({}) are present and used for Raspa".format(
                    self.ctx.number_blocking_spheres))
        else:
            self.report("No blocking spheres found")

        # Create the calculation process and launch it
        running = submit(RaspaConvergeWorkChain, **inputs)
        self.report(
            "pk: {} | Running Raspa Widom for the Henry coefficient".format(
                running.pid))

        return ToContext(raspa_widom=Outputs(running))
예제 #29
0
    def _submit_pw_calc(self,
                        structure,
                        label,
                        runtype,
                        wallhours=24,
                        parent_folder=None):
        self.report("Running pw.x for " + label)

        inputs = {}
        inputs['_label'] = label
        inputs['code'] = self.inputs.code
        inputs['structure'] = structure
        inputs['parameters'] = self._get_parameters(structure, runtype,
                                                    parent_folder)
        inputs['pseudo'] = self._get_pseudos(
            structure, family_name="SSSP_efficiency_v1.0")
        if parent_folder:
            inputs['parent_folder'] = parent_folder

        # kpoints
        kpoints = KpointsData()
        kpoints_mesh = 2
        kpoints.set_kpoints_mesh([kpoints_mesh, kpoints_mesh, kpoints_mesh])
        inputs['kpoints'] = kpoints

        inputs['_options'] = {
            "resources": {
                "num_machines": 1,
                "num_mpiprocs_per_machine": 1
            },
            "max_wallclock_seconds": wallhours * 60 * 60,  # hours
        }

        future = submit(PwCalculation.process(), **inputs)
        return ToContext(**{label: Calc(future)})
예제 #30
0
    def run_loading_raspa(self):
        """This function will run RaspaConvergeWorkChain for the current pressure"""
        pressure = self.ctx.pressures[self.ctx.current_p_index]
        self.ctx.raspa_parameters['GeneralSettings'][
            'ExternalPressure'] = pressure

        parameters = ParameterData(dict=self.ctx.raspa_parameters).store()
        # Create the input dictionary
        inputs = {
            'code': self.inputs.raspa_code,
            'structure': self.ctx.structure,
            'parameters': parameters,
            '_options': self.inputs._raspa_options,
            '_label': "run_loading_raspa",
        }
        # Check if there are poket blocks to be loaded
        try:
            inputs['block_component_0'] = self.ctx.zeopp_block['block']
        except:
            pass

        if self.ctx.restart_raspa_calc is not None:
            inputs['retrieved_parent_folder'] = self.ctx.restart_raspa_calc

        # Create the calculation process and launch it
        running = submit(RaspaConvergeWorkChain, **inputs)
        self.report("pk: {} | Running raspa for the pressure {} [bar]".format(
            running.pid, pressure / 1e5))
        self.ctx.current_p_index += 1
        return ToContext(raspa_loading=Outputs(running))
    def submit_jobs(self):
        print("structure PK: %i"%self.inputs.structure.pk)

        grp, created = Group.get_or_create(name=self.inputs.group)
        grp.add_nodes([self.calc])
        print("stress tensor PK: %i"%self.calc.pk)
        
        # get calculation class
        C = CalculationFactory(self.inputs.code.get_input_plugin_name())

        Proc = C.process()

        num_points = 5

        # volume scales from 0.94 to 1.06, alat scales as pow(1/3)
        scales = numpy.linspace(0.94**(1/3.0), 1.06**(1/3.0), num_points).tolist()

        calcs = {}
        
        for scale in scales:
            print("scale = %f"%scale)
            # scaled structure
            new_structure = scaled_structure(self.inputs.structure, Float(scale))
            # basic parameters of the calculation
            params = calculation_helpers.create_calculation_parameters(self.inputs.code,
                                                                       str(self.inputs.partition),
                                                                       int(self.inputs.ranks_per_node),
                                                                       int(self.inputs.ranks_kp),
                                                                       int(self.inputs.ranks_diag))
            
            inputs = Proc.get_inputs_template()
            inputs.code = self.inputs.code

            inputs._options.resources = params['calculation_resources']
            inputs._options.max_wallclock_seconds = 20 * 60
            inputs._options.custom_scheduler_commands = params['custom_scheduler_commands']
            inputs._options.environment_variables = params['environment_variables']
            inputs._options.mpirun_extra_params = params['mpirun_extra_params']

            inputs.structure = new_structure
            inputs.kpoints = KpointsData()
            inputs.kpoints.set_kpoints_mesh(self.inputs.kmesh, offset=(0.0, 0.0, 0.0))

            inputs.parameters = params['calculation_parameters']
            inputs.settings = params['calculation_settings']

            if self.inputs.code.get_input_plugin_name() == 'quantumespresso.pw':
                inputs.pseudo = get_pseudos(new_structure, self.inputs.atomic_files)

            if self.inputs.code.get_input_plugin_name() == 'exciting.exciting':
                inputs.lapwbasis = get_lapwbasis(new_structure, self.inputs.atomic_files)

            future = submit(Proc, **inputs)