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 _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)})
def run_export_hartree(self): self.report("Running pp.x to export hartree potential") inputs = {} inputs['_label'] = "export_hartree" inputs['code'] = self.inputs.pp_code prev_calc = self.ctx.scf self._check_prev_calc(prev_calc) inputs['parent_folder'] = prev_calc.out.remote_folder structure = prev_calc.inp.structure cell_a = structure.cell[0][0] cell_b = structure.cell[1][1] cell_c = structure.cell[2][2] parameters = ParameterData( dict={ 'inputpp': { 'plot_num': 11, # the V_bare + V_H potential }, 'plot': { 'iflag': 2, # 2D plot # format suitable for gnuplot (2D) x, y, f(x,y) 'output_format': 7, # 3D vector, origin of the plane (in alat units) 'x0(1)': 0.0, 'x0(2)': 0.0, 'x0(3)': cell_c / cell_a, # 3D vectors which determine the plotting plane # in alat units) 'e1(1)': cell_a / cell_a, 'e1(2)': 0.0, 'e1(3)': 0.0, 'e2(1)': 0.0, 'e2(2)': cell_b / cell_a, 'e2(3)': 0.0, 'nx': 10, # Number of points in the plane 'ny': 10, 'fileout': 'vacuum_hartree.dat', }, }) inputs['parameters'] = parameters settings = ParameterData( dict={'additional_retrieve_list': ['vacuum_hartree.dat']}) inputs['settings'] = settings inputs['_options'] = { "resources": { "num_machines": 1 }, "max_wallclock_seconds": 20 * 60, # workaround for flaw in PpCalculator. # We don't want to retrive this huge intermediate file. "append_text": u"rm -v aiida.filplot\n", } future = submit(PpCalculation.process(), **inputs) return ToContext(hartree=Calc(future))
def _submit_pw_calc(self, structure, label, runtype, precision, min_kpoints, wallhours=24, parent_folder=None): self.report("Running pw.x for " + label) inputs = {} inputs['_label'] = label inputs['code'] = self.inputs.pw_code inputs['structure'] = structure inputs['parameters'] = self._get_parameters(structure, runtype) inputs['pseudo'] = self._get_pseudos(structure, family_name="SSSP_modified") if parent_folder: inputs['parent_folder'] = parent_folder # kpoints cell_a = inputs['structure'].cell[0][0] precision *= self.inputs.precision.value nkpoints = max(min_kpoints, int(30 * 2.5 / cell_a * precision)) use_symmetry = runtype != "bands" kpoints = self._get_kpoints(nkpoints, use_symmetry=use_symmetry) inputs['kpoints'] = kpoints # parallelization settings ## TEMPORARY double pools in case of spin spinpools = 1 start_mag = self._get_magnetization(structure) if any([m != 0 for m in start_mag.values()]): spinpools = 2 npools = min(spinpools + nkpoints / 5, 5) natoms = len(structure.sites) nnodes = (1 + natoms / 60) * npools inputs['_options'] = { "resources": { "num_machines": nnodes }, "max_wallclock_seconds": wallhours * 60 * 60, # hours } settings = {'cmdline': ["-npools", str(npools)]} if runtype == "bands": settings['also_bands'] = True # instruction for output parser inputs['settings'] = ParameterData(dict=settings) # self.report("precision %f"%precision) # self.report("nkpoints %d"%nkpoints) # self.report("npools %d"%npools) # self.report("natoms %d"%natoms) # self.report("nnodes %d"%nnodes) future = submit(PwCalculation.process(), **inputs) return ToContext(**{label: Calc(future)})
def run_geopt_again(self): # TODO: make this nicer. inputs_new = self.build_calc_inputs(self.inputs.structure, self.inputs.cp2k_code, self.inputs.fixed_atoms, self.inputs.num_machines, '', self.ctx.geo_opt.out.remote_folder) self.report("inputs (restart): " + str(inputs_new)) future_new = submit(Cp2kCalculation.process(), **inputs_new) return ToContext(geo_opt=Calc(future_new))
def run_scfs(self): self.report("Running CP2K diagonalization SCF") slab_inputs = self.build_slab_cp2k_inputs( self.inputs.slabsys_structure, self.inputs.pdos_lists, self.inputs.cp2k_code, self.inputs.mgrid_cutoff, self.inputs.wfn_file_path, self.inputs.elpa_switch) self.report("slab_inputs: " + str(slab_inputs)) slab_future = submit(Cp2kCalculation.process(), **slab_inputs) self.to_context(slab_scf=Calc(slab_future)) mol_inputs = self.build_mol_cp2k_inputs(self.inputs.mol_structure, self.inputs.cp2k_code, self.inputs.mgrid_cutoff, self.inputs.elpa_switch) self.report("mol_inputs: " + str(mol_inputs)) mol_future = submit(Cp2kCalculation.process(), **mol_inputs) self.to_context(mol_scf=Calc(mol_future))
def run_geopt(self): self.report("Running CP2K geometry optimization") inputs = self.build_calc_inputs(self.inputs.structure, self.inputs.cp2k_code, self.inputs.fixed_atoms, self.inputs.num_machines, self.inputs.wavefunction, None) self.report("inputs: " + str(inputs)) future = submit(Cp2kCalculation.process(), **inputs) return ToContext(geo_opt=Calc(future))
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 kband1 = max(int(nel/2) - 6, 1) kband2 = min(int(nel/2) + 7, nbnd) kpoint1 = 1 kpoint2 = nkpt * nspin nhours = 2 + min(22, 2*int(volume/1500)) 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, }, '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) return ToContext(orbitals=Calc(future))
def run_scf_diag(self): self.report("Running CP2K diagonalization SCF") n_lumo = int(self.inputs.stm_params.get_dict()['--n_lumo']) inputs = self.build_cp2k_inputs(self.inputs.structure, self.inputs.cp2k_code, self.inputs.dft_params.get_dict(), self.inputs.wfn_file_path, n_lumo) self.report("inputs: " + str(inputs)) future = submit(Cp2kCalculation.process(), **inputs) return ToContext(scf_diag=Calc(future))
def run_scf_diag(self): self.report("Running CP2K diagonalization SCF") inputs = self.build_cp2k_inputs(self.inputs.structure, self.inputs.cell, self.inputs.cp2k_code, self.inputs.mgrid_cutoff, self.inputs.wfn_file_path, self.inputs.elpa_switch) self.report("inputs: "+str(inputs)) future = submit(Cp2kCalculation.process(), **inputs) return ToContext(scf_diag=Calc(future))
def run_geopt(self): self.report("Running CP2K geometry optimization") inputs = self.build_calc_inputs( self.inputs.structure, self.inputs.cp2k_code, self.inputs.max_force, self.inputs.calc_type, self.inputs.mgrid_cutoff, self.inputs.vdw_switch, self.inputs.fixed_atoms, self.inputs.center_switch, self.inputs.num_machines, None) self.report("inputs: " + str(inputs)) future = submit(Cp2kCalculation.process(), **inputs) return ToContext(geo_opt=Calc(future))
def run_export_spinden(self): self.report("Running pp.x to compute spinden") inputs = {} inputs['_label'] = "export_spinden" inputs['code'] = self.inputs.pp_code prev_calc = self.ctx.scf self._check_prev_calc(prev_calc) inputs['parent_folder'] = prev_calc.out.remote_folder nspin = prev_calc.res.number_of_spin_components bands_cmdline = prev_calc.inp.settings.get_dict()['cmdline'] nnodes = int(prev_calc.get_resources()['num_machines']) npools = int(bands_cmdline[bands_cmdline.index('-npools') + 1]) nproc_mach = int( prev_calc.get_resources()['default_mpiprocs_per_machine']) if nspin == 1: self.report("Skipping, got only one spin channel") return parameters = ParameterData( dict={ 'inputpp': { 'plot_num': 6, # spin polarization (rho(up)-rho(down)) }, 'plot': { 'iflag': 3, # 3D plot 'output_format': 6, # CUBE format 'fileout': '_spin.cube', }, }) inputs['parameters'] = parameters inputs['_options'] = { "resources": { "num_machines": nnodes, "num_mpiprocs_per_machine": nproc_mach }, "max_wallclock_seconds": 30 * 60, # 30 minutes "append_text": self._get_cube_cutter(), } settings = ParameterData( dict={ 'additional_retrieve_list': ['*.cube.gz'], 'cmdline': ["-npools", str(npools)] }) inputs['settings'] = settings future = submit(PpCalculation.process(), **inputs) return ToContext(spinden=Calc(future))
def run_phonons(self): self.report("Running CP2K GW") parameters_dict = self.inputs.parameters.get_dict() inputs = self.build_calc_inputs(code=self.inputs.code, parent_folder=None, structure=self.inputs.structure, input_dict=parameters_dict) self.report("inputs: " + str(inputs)) self.report("parameters: " + str(inputs['parameters'].get_dict())) self.report("settings: " + str(inputs['settings'].get_dict())) future = submit(Cp2kCalculation.process(), **inputs) return ToContext(phonons_opt=Calc(future))
def run_scf_diag(self): self.report("Running CP2K diagonalization SCF") emax = float(self.inputs.stm_params.get_dict()['--energy_range'][1]) inputs = self.build_cp2k_inputs(self.inputs.structure, self.inputs.cell, self.inputs.cp2k_code, self.inputs.mgrid_cutoff, self.inputs.wfn_file_path, self.inputs.elpa_switch, emax) self.report("inputs: "+str(inputs)) future = submit(Cp2kCalculation.process(), **inputs) return ToContext(scf_diag=Calc(future))
def run_hrstm(self): self.report("Running HR-STM") inputs = {} inputs['_label'] = "hrstm" inputs['code'] = self.inputs.hrstm_code inputs['parameters'] = self.inputs.hrstm_params inputs['parent_calc_folder'] = self.ctx.scf_diag.out.remote_folder inputs['ppm_calc_folder'] = self.ctx.ppm.out.remote_folder inputs['_options'] = { "resources": {"num_machines": 6}, "max_wallclock_seconds": 14400, # 4:00 hours } self.report("HR-STM Inputs: " + str(inputs)) future = submit(HrstmCalculation.process(), **inputs) return ToContext(hrstm=Calc(future))
def generate_replica(self): self.report("Running CP2K geometry optimization - Target: ".format( self.ctx.this_replica)) inputs = self.build_calc_inputs( self.ctx.structure, self.inputs.cell, self.inputs.cp2k_code, self.ctx.this_replica, self.inputs.fixed_atoms, self.inputs.num_machines, self.ctx.remote_calc_folder, self.ctx.this_name, self.inputs.spring, self.inputs.spring_unit, self.inputs.target_unit, self.inputs.subsys_colvar, self.inputs.calc_type) self.report(" ") self.report("inputs: " + str(inputs)) self.report(" ") future = submit(Cp2kCalculation.process(), **inputs) self.report("future: " + str(future)) self.report(" ") return ToContext(replica=Calc(future))
def run_ppm(self): self.report("Running PPM") inputs = {} inputs['_label'] = "hrstm_ppm" inputs['code'] = self.inputs.ppm_code inputs['parameters'] = self.inputs.ppm_params inputs['parent_calc_folder'] = self.ctx.scf_diag.out.remote_folder # TODO set atom types properly inputs['atomtypes'] = SinglefileData(file="/project/apps/scanning_probe/hrstm/atomtypes_2pp.ini") inputs['_options'] = { "resources": {"num_machines": 1}, "max_wallclock_seconds": 21600, } self.report("PPM inputs: " + str(inputs)) future = submit(AfmCalculation.process(), **inputs) return ToContext(ppm=Calc(future))
def run_export_pdos(self): self.report("Running projwfc.x to export PDOS") inputs = {} inputs['_label'] = "export_pdos" inputs['code'] = self.inputs.projwfc_code prev_calc = self.ctx.bands self._check_prev_calc(prev_calc) volume = prev_calc.res.volume nnodes = max(1, int(volume/1500)) nhours = 2 + min(22, 2*int(volume/1500)) inputs['parent_folder'] = prev_calc.out.remote_folder parameters = ParameterData(dict={ 'projwfc': { 'ngauss': 1, 'degauss': 0.007, 'DeltaE': 0.01, 'filproj': 'projection.out', # 'filpdos' : 'totdos', # 'kresolveddos': True, }, }) inputs['parameters'] = parameters inputs['_options'] = { "resources": { "num_machines": nnodes, "num_mpiprocs_per_machine": 1 }, "max_wallclock_seconds": nhours * 60 * 60, # 12 hours } settings = ParameterData( dict={'additional_retrieve_list': ['./out/aiida.save/atomic_proj.xml', '*_up', '*_down', '*_tot']} ) inputs['settings'] = settings future = submit(ProjwfcCalculation.process(), **inputs) return ToContext(pdos=Calc(future))
def calc_neb(self): self.report("Running CP2K CI-NEB calculation.".format( self.ctx.this_name)) inputs = self.build_calc_inputs( self.inputs.struc_folder, # Setup calculation self.inputs.cell, self.inputs.cp2k_code, self.inputs.fixed_atoms, self.inputs.num_machines, self.ctx.remote_calc_folder, self.inputs.wfn_cp_commands, # NEB input self.inputs.align, self.inputs.endpoints, self.inputs.nproc_rep, self.inputs.nreplicas, self.inputs.nstepsit, self.inputs.rotate, self.inputs.spring, # Calculation type specific self.inputs.calc_type, self.ctx.file_list, # find this in the workflow # instead of passing self.inputs.first_slab_atom, self.inputs.last_slab_atom) self.report(" ") self.report("inputs: " + str(inputs)) self.report(" ") self.report("Using aiida-cp2k: " + str(aiida_cp2k.__file__)) self.report(" ") future = submit(Cp2kCalculation.process(), **inputs) self.report("future: " + str(future)) self.report(" ") return ToContext(neb=Calc(future))
def run_export_pdos(self): self.report("Running projwfc.x to export PDOS") inputs = {} inputs['_label'] = "export_pdos" inputs['code'] = self.inputs.projwfc_code prev_calc = self.ctx.bands self._check_prev_calc(prev_calc) volume = prev_calc.res.volume natoms=len(prev_calc.inp.structure.get_ase()) #nnodes = 2*max(1, int(natoms/60)) #nkpt=len(prev_calc.inp.kpoints.get_kpoints()) nproc_mach=4 bands_cmdline = prev_calc.inp.settings.get_dict()['cmdline'] if natoms < 60: nnodes=2 npools=2 elif natoms <120: nnodes=4 npools=4 else: nnodes=int(prev_calc.get_resources()['num_machines']) npools = int(bands_cmdline[bands_cmdline.index('-npools')+1]) nproc_mach=int(prev_calc.get_resources()['default_mpiprocs_per_machine']) nhours = 24 #2 + min(22, 2*int(volume/1500)) inputs['parent_folder'] = prev_calc.out.remote_folder # use the same number of pools as in bands calculation parameters = ParameterData(dict={ 'projwfc': { 'ngauss': 1, 'degauss': 0.007, 'DeltaE': 0.01, 'filproj': 'projection.out', # 'filpdos' : 'totdos', # 'kresolveddos': True, }, }) inputs['parameters'] = parameters inputs['_options'] = { "resources": { "num_machines": nnodes, "num_mpiprocs_per_machine": nproc_mach }, "max_wallclock_seconds": nhours * 60 * 60, # 12 hours } settings = ParameterData( dict={'additional_retrieve_list': ['./out/aiida.save/atomic_proj.xml', '*_up', '*_down', '*_tot'], 'cmdline': ["-npools", str(npools)] } ) inputs['settings'] = settings future = submit(ProjwfcCalculation.process(), **inputs) return ToContext(pdos=Calc(future))