def make_input(paw=False): """Build a template input file for GS calculations with k-point parallelism """ pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") if not paw else \ abidata.pseudos("Si.GGA_PBE-JTH-paw.xml", "o.paw") structure = abidata.structure_from_ucell("SiO2-alpha") inp = abilab.AbinitInput(structure, pseudos) inp.set_kmesh(ngkpt=[1,1,1], shiftk=[0,0,0]) # Global variables ecut = 24 inp.set_vars( ecut=ecut, pawecutdg=ecut*2 if paw else None, nsppol=1, nband=28, paral_kgb=0, #istwfk="*1", #fftalg=312, timopt=-1, chksymbreak=0, prtwf=0, prtden=0, tolvrs=1e-10, ) return inp
def make_input(paw=False): """ Build and return an input file for GS calculations with paral_kgb=1 """ pseudos = abidata.pseudos("14si.pspnc") if not paw else abidata.pseudos("Si.GGA_PBE-JTH-paw.xml") structure = abidata.structure_from_ucell("Si") inp = abilab.AbinitInput(structure, pseudos) inp.set_kmesh(ngkpt=[1,1,1], shiftk=[0,0,0]) # Global variables ecut = 20 inp.set_vars( ecut=ecut, pawecutdg=ecut*4 if paw else None, nsppol=1, nband=20, paral_kgb=1, istwfk="*1", timopt=-1, chksymbreak=0, prtwf=0, prtden=0, tolvrs=1e-8, nstep=50, ) return inp
def make_input(paral_kgb=1, paw=False): """Build a template input file for GS calculations with paral_kgb""" pseudos = abidata.pseudos("14si.pspnc") if not paw else abidata.pseudos("Si.GGA_PBE-JTH-paw.xml") inp = abilab.AbiInput(pseudos=pseudos) inp.set_structure(abidata.structure_from_ucell("Si")) inp.set_kmesh(ngkpt=[2,2,2], shiftk=[0,0,0]) # Global variables ecut = 10 inp.set_vars( ecut=ecut, pawecutdg=ecut*4, nsppol=1, nband=20, paral_kgb=paral_kgb, npkpt=1, npband=1, npfft=1, # istwfk="*1", timopt=-1, chksymbreak=0, prtwf=0, prtden=0, tolvrs=1e-10, nstep=50, ) return inp
def make_ngkpt_flow(structure_file=None, metal=False): """ A 'factory function' (a function that returns an instance of the class defined above. If no specific system is specified, structure_file=None, an example flow for silicon in constructed and returned. """ ngkpt_list = [(2, 2, 2), (4, 4, 4), (6, 6, 6), (8, 8, 8)] # Defining the structure and adding the appropriate pseudo potentials if structure_file is None: inp = abilab.AbiInput(pseudos=abidata.pseudos("14si.pspnc"), ndtset=len(ngkpt_list)) inp.set_structure(abidata.cif_file("si.cif")) workdir = "lesson_Si_kpoint_convergence" else: structure = abilab.Structure.from_file(structure_file) pseudos = abidata.pseudos(get_pseudos(structure)) inp = abilab.AbiInput(pseudos=pseudos, ndtset=len(ngkpt_list)) inp.set_structure(structure) workdir = "lesson_" + structure.composition.reduced_formula + "_kpoint_convergence" # Global variables inp.set_variables(ecut=10, tolvrs=1e-9) if metal: inp.set_variables(occopt=7, tsmear=0.04) # Specific variables for the different calculations for i, ngkpt in enumerate(ngkpt_list): inp[i+1].set_kmesh(ngkpt=ngkpt, shiftk=[0, 0, 0]) return NgkptFlow.from_inputs(workdir=workdir, inputs=inp.split_datasets())
def setUp(self): # Si ebands self.si_structure = abidata.structure_from_cif("si.cif") self.si_pseudo = abidata.pseudos("14si.pspnc") self.gan_structure = abidata.structure_from_cif("gan.cif") self.n_pseudo = abidata.pseudos("7n.pspnc") self.ga_pseudo = abidata.pseudos("31ga.pspnc")
def input_scf_phonon_gan_low(): pseudos = [abidata.pseudos("31ga.pspnc").pseudo_with_symbol('Ga'), abidata.pseudos("7n.pspnc").pseudo_with_symbol('N')] structure = get_gan_structure() scf_in = scf_for_phonons(structure, pseudos, kppa=100, ecut=4, spin_mode="unpolarized", accuracy="low", smearing=None) return scf_in
def h2_h_input(x=0.7, ecut=10, acell=(10, 10, 10)): """ This file to optimize the H2 bond length, compute the associated total energy, then to compute the total energy of the isolated H atom. """ h2 = abilab.Structure.from_abivars( natom=2, ntypat=1, typat=(1, 1), znucl=1, xcart=[-x, 0.0, 0.0, +x, 0.0, 0.0], acell=acell, rprim=[1, 0, 0, 0, 1, 0, 0, 0, 1], ) h = abilab.Structure.from_abivars( natom=1, ntypat=1, typat=1, znucl=1, xcart=[0.0, 0.0, 0.0], acell=acell, rprim=[1, 0, 0, 0, 1, 0, 0, 0, 1], ) global_vars = dict( ecut=ecut, nband=1, diemac=2.0, nstep=10, ) h2_inp = abilab.AbinitInput(structure=h2, pseudos=abidata.pseudos("01h.pspgth")) h2_inp.set_vars(global_vars) h2_inp.set_kmesh(ngkpt=(1,1,1), shiftk=(0,0,0)) h2_inp.set_vars( ionmov=3, ntime=10, tolmxf=5e-4, toldff=5e-5, ) h_inp = abilab.AbinitInput(structure=h, pseudos=abidata.pseudos("01h.pspgth")) h_inp.set_vars(global_vars) h_inp.set_vars( nsppol=2, nband=(1, 1), occopt=2, occ=(1.0, 0.0), toldfe=1e-6, spinat=(0.0, 0.0, 1.0), ) return h2_inp, h_inp
def make_inputs(paw=False): pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") if not paw else \ abidata.pseudos("Si.GGA_PBE-JTH-paw.xml", "o.paw") structure = abidata.structure_from_ucell("SiO2-alpha") multi = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=4) ecut = 24 multi.set_vars( ecut=ecut, pawecutdg=ecut*2 if paw else None, paral_kgb=0, istwfk="*1", timopt=-1, ) multi.set_kmesh(ngkpt=[4,4,3], shiftk=[0.0, 0.0, 0.0]) gs, nscf, scr, sigma = multi.split_datasets() # Dataset 1 (GS run) gs.set_vars(tolvrs=1e-6, nband=28,) # Dataset 2 (NSCF run) nscf.set_vars(iscf=-2, tolwfr=1e-4, nband=600, nbdbuf=200, ) # Dataset3: Calculation of the screening. scr.set_vars( optdriver=3, gwpara=2, nband=25, ecutwfn=ecut, symchi=1, inclvkb=0, ecuteps=6.0, ) # Dataset4: Calculation of the Self-Energy matrix elements (GW corrections) sigma.set_vars( optdriver=4, gwpara=2, ecutwfn=ecut, ecuteps=6.0, ecutsigx=ecut, symsigma=1, gw_qprange=1, ) return gs, nscf, scr, sigma
def make_inputs(paw=False): # Crystalline silicon # Calculation of the GW correction to the direct band gap in Gamma # Dataset 1: ground state calculation # Dataset 2: BSE with haydock method and model dielectric function. structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) pseudos = abidata.pseudos("14si.pspnc") if not paw else abidata.pseudos("Si.GGA_PBE-JTH-paw.xml") multi = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=2) ecut = 8 multi.set_vars( ecut=ecut, pawecutdg=ecut*4 if paw else None, nsppol=1, timopt=-1, istwfk="*1", paral_kgb=0, ) # This grid is the most economical, but does not contain the Gamma point. multi.set_kmesh( ngkpt=[8, 8, 8], shiftk=[0.0, 0.0, 0.0], ) gs, bse = multi.split_datasets() gs.set_vars(tolvrs=1e-6, nband=8, ) # Dataset 6 BSE equation with Model dielectric function and Haydock (only resonant + W + v) # Note that SCR file is not needed here bse.set_vars( optdriver=99, ecutwfn=ecut, ecuteps=4.0, inclvkb=2, bs_algorithm=2, # Haydock bs_haydock_niter=60, # No. of iterations for Haydock bs_exchange_term=1, bs_coulomb_term=21, # Use model W and full W_GG. mdf_epsinf=12.0, bs_calctype=1, # Use KS energies and orbitals to construct L0 mbpt_sciss="0.8 eV", bs_coupling=0, bs_loband=2, nband=8, bs_freq_mesh="0 10 0.1 eV", bs_hayd_term=0, # No terminator #gwmem=01 # Compute the model-dielectric function on-the-fly. ) return gs, bse
def setUp(self): # Si ebands si_structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) self.si_ebands = ebands_input(si_structure, abidata.pseudos("14si.pspnc"), ecut=2, kppa=10) # Reference input string. Used to test if decorators do not change the initial Input. self.si_ebands_inpstr = str(self.si_ebands) # NiO bands with PAW nio_structure = abidata.structure_from_ucell("NiO") self.nio_ebands = ebands_input(nio_structure, abidata.pseudos("28ni.paw", "8o.2.paw"), ecut=2, pawecutdg=4, kppa=10) self.nio_ebands_inpstr = str(self.nio_ebands)
def build_flow(options): # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") workdir = options.workdir if not options.workdir: workdir = os.path.basename(__file__).replace(".py", "").replace("run_","flow_") # Instantiate the TaskManager. manager = abilab.TaskManager.from_user_config() if not options.manager else \ abilab.TaskManager.from_file(options.manager) pseudos = data.pseudos("14si.pspnc", "8o.pspnc") base_structure = abilab.Structure.from_file(data.cif_file("si.cif")) news, uparams = [], [0.1, 0.2, 0.3] for u in uparams: new = special_positions(base_structure.lattice, u) news.append(new) flow = abilab.Flow(workdir, manager=manager) # Create the list of workflows. Each workflow defines a band structure calculation. for new_structure, u in zip(news, uparams): # Generate the workflow and register it. flow.register_work(make_workflow(new_structure, pseudos)) return flow.allocate()
def get_gsinput_si(usepaw=0, as_task=False): # Build GS input file. pseudos = abidata.pseudos("14si.pspnc") if usepaw == 0 else data.pseudos("Si.GGA_PBE-JTH-paw.xml") #silicon = abilab.Structure.zincblende(5.431, ["Si", "Si"], units="ang") silicon = abidata.cif_file("si.cif") from abipy.abio.inputs import AbinitInput scf_input = AbinitInput(silicon, pseudos) ecut = 6 scf_input.set_vars( ecut=ecut, pawecutdg=40, nband=6, paral_kgb=0, iomode=3, toldfe=1e-9, ) if usepaw: scf_input.set_vars(pawecutdg=4 * ecut) # K-point sampling (shifted) scf_input.set_autokmesh(nksmall=4) if not as_task: return scf_input else: from abipy.flowtk.tasks import ScfTask return ScfTask(scf_input)
def build_flow(options): # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") workdir = options.workdir if not options.workdir: workdir = os.path.basename(__file__).replace(".py", "").replace("run_","flow_") flow = abilab.Flow(workdir, manager=options.manager) # Create the work for the band structure calculation. structure = abidata.structure_from_ucell("NiO") pseudos = abidata.pseudos("28ni.paw", "8o.2.paw") # The code below set up the parameters for the LDA+U calculation in NiO. #usepawu 1 #lpawu 2 -1 #upawu 8.0 0.0 eV #jpawu 0.8 0.0 eV usepawu = 1 u_values = [5.0, 8.0] for u in u_values: # Apply U-J on Ni only. luj_params = abilab.LdauParams(usepawu, structure) luj_params.luj_for_symbol("Ni", l=2, u=u, j=0.1*u, unit="eV") scf_input, nscf_input, dos_input = make_scf_nscf_dos_inputs(structure, pseudos, luj_params) work = abilab.BandStructureWork(scf_input, nscf_input, dos_inputs=dos_input) flow.register_work(work) return flow
def make_input(): """Build a template input file for GS calculations with k-point parallelism """ pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") structure = abidata.structure_from_ucell("SiO2-alpha") #structure.make_supercell([3,3,3]) inp = abilab.AbinitInput(structure, pseudos) inp.set_kmesh(ngkpt=[4,4,4], shiftk=[0,0,0]) # Global variables ecut = 24 inp.set_vars( ecut=ecut, nsppol=1, nband=28, paral_kgb=0, istwfk="*1", timopt=-1, chksymbreak=0, chkprim=0, maxnsym=2400, prtwf=0, prtden=0, tolvrs=1e-8, ) return inp
def make_scf_nscf_inputs(structure, paral_kgb=1): multi = abilab.MultiDataset(structure, pseudos=data.pseudos("14si.pspnc"), ndtset=2) # Global variables global_vars = dict( ecut=6, nband=8, timopt=-1, paral_kgb=0, #nstep=4, # This is not enough to converge. Used to test the automatic restart. nstep=10, iomode=3, ) multi.set_vars(global_vars) # Dataset 1 (GS run) multi[0].set_kmesh(ngkpt=[8,8,8], shiftk=[0,0,0]) multi[0].set_vars(tolvrs=1e-6) # Dataset 2 (NSCF run) kptbounds = [ [0.5, 0.0, 0.0], # L point [0.0, 0.0, 0.0], # Gamma point [0.0, 0.5, 0.5], # X point ] multi[1].set_kpath(ndivsm=6, kptbounds=kptbounds) multi[1].set_vars(tolwfr=1e-12) # Generate two input files for the GS and the NSCF run scf_input, nscf_input = multi.split_datasets() return scf_input, nscf_input
def gs_input(ecut, pawecutdg, acell_ang=3.567): # tpaw1_2.in # Input for PAW1 tutorial # Diamond at experimental volume structure = abilab.Structure.from_abivars( natom=2, ntypat=1, typat=2 * [1], znucl=6, acell=3*[abilab.Length(acell_ang, "ang").to("bohr")], rprim=[0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0], xred=[0.0, 0.0, 0.0, 1/4, 1/4, 1/4], ) inp = abilab.AbinitInput(structure=structure, pseudos=abidata.pseudos("6c.lda.atompaw")) # Optimization of the lattice parameters inp.set_vars( ecut=ecut, pawecutdg=pawecutdg, ecutsm=0.5, nband=6, tolvrs=1e-10, nstep=20, ) inp.set_autokmesh(nksmall=6) # ngkpt=[6, 6, 6], shiftk=[0.5, 0.5, 0.5]) return inp
def test_abinit_calls(self): """Testing AbinitInput methods invoking Abinit.""" inp = AbinitInput(structure=abidata.cif_file("si.cif"), pseudos=abidata.pseudos("14si.pspnc")) inp.set_kmesh(ngkpt=(2, 2, 2), shiftk=(0, 0, 0)) # The code below invokes Abinit. # Test validate with wrong input inp.set_vars(ecut=-1) v = inp.abivalidate() assert v.retcode != 0 and v.log_file.read() # Test validate with correct input inp.set_vars(ecut=2, toldfe=1e-6) v = inp.abivalidate() assert v.retcode == 0 # Test abiget_ibz ibz = inp.abiget_ibz() assert np.all(ibz.points == [[ 0. , 0. , 0. ], [ 0.5, 0. , 0. ], [ 0.5, 0.5, 0. ]]) assert np.all(ibz.weights == [0.125, 0.5, 0.375]) # Test abiget_irred_phperts # [{'idir': 1, 'ipert': 1, 'qpt': [0.0, 0.0, 0.0]}] irred_perts = inp.abiget_irred_phperts(qpt=(0, 0, 0)) assert len(irred_perts) == 1 pert = irred_perts[0] assert pert.idir == 1 and (pert.idir, pert.ipert) == (1, 1) and all(c == 0 for c in pert.qpt) # Test abiget_autoparal_pconfs inp["paral_kgb"] = 0 pconfs = inp.abiget_autoparal_pconfs(max_ncpus=5) inp["paral_kgb"] = 1 pconfs = inp.abiget_autoparal_pconfs(max_ncpus=5)
def TestInputCheckSum(self): """Testing the hash method of AbinitInput""" inp = ebands_input(abidata.cif_file("si.cif"), abidata.pseudos("14si.pspnc"), kppa=10, ecut=2)[0] inp_cs = inp.variable_checksum() ecut = inp.pop('ecut') inp.set_vars({'ecut': ecut}) self.assertEqual(inp_cs, inp.variable_checksum())
def test_input_errors(self): """Testing typical AbinitInput Error""" si_structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) # Ambiguous list of pseudos. with self.assertRaises(AbinitInput.Error): AbinitInput(si_structure, pseudos=abidata.pseudos("14si.pspnc", "Si.oncvpsp")) # Pseudos do not match structure. with self.assertRaises(AbinitInput.Error): AbinitInput(si_structure, pseudos=abidata.pseudos("13al.981214.fhi")) # Negative triple product. with self.assertRaises(AbinitInput.Error): s = abidata.structure_from_ucell("Al-negative-volume") AbinitInput(s, pseudos=abidata.pseudos("13al.981214.fhi"))
def test_helper_functions(self): """Testing AbinitInput helper functions.""" inp = AbinitInput(structure=abidata.cif_file("si.cif"), pseudos=abidata.pseudos("14si.pspnc")) nval_atoms = inp.valence_electrons_per_atom assert len(nval_atoms) == 2 assert nval_atoms == [4, 4] inp.set_kmesh(ngkpt=(1, 2, 3), shiftk=(1, 2, 3, 4, 5, 6)) assert inp["kptopt"] == 1 and inp["nshiftk"] == 2 inp.set_autokmesh(nksmall=2) assert inp["kptopt"] == 1 and np.all(inp["ngkpt"] == [2, 2, 2]) and inp["nshiftk"] == 4 inp.set_kpath(ndivsm=3, kptbounds=None) assert inp["iscf"] == -2 and len(inp["kptbounds"]) == 12 inp.set_kptgw(kptgw=(1, 2, 3, 4, 5, 6), bdgw=(1, 2)) assert inp["nkptgw"] == 2 and np.all(inp["bdgw"].ravel() == np.array(len(inp["kptgw"]) * [1,2]).ravel()) linps = inp.linspace("ecut", 2, 6, num=3, endpoint=True) assert len(linps) == 3 and (linps[0]["ecut"] == 2 and (linps[-1]["ecut"] == 6)) ranginps = inp.arange("ecut", start=3, stop=5, step=1) assert len(ranginps) == 2 and (ranginps[0]["ecut"] == 3 and (ranginps[-1]["ecut"] == 4)) prod_inps = inp.product("ngkpt", "tsmear", [[2,2,2], [4,4,4]], [0.1, 0.2, 0.3]) #prod_inps = inp.product([("ngkpt", [[2,2,2], [4,4,4]]), ("tsmear", [0.1, 0.2, 0.3])]) assert len(prod_inps) == 6 assert prod_inps[0]["ngkpt"] == [2,2,2] and prod_inps[0]["tsmear"] == 0.1 assert prod_inps[-1]["ngkpt"] == [4,4,4] and prod_inps[-1]["tsmear"] == 0.3
def make_scf_nscf_inputs(nsppol): inp = abilab.AbiInput(pseudos=data.pseudos("26fe.pspnc"), ndtset=2) # Fe normal bcc structure for test of a ferromagnetic calculation structure = data.structure_from_ucell("Fe-fm") inp.set_structure(structure) # Global variables global_vars = dict(nsppol=nsppol, ecut=18, nband=8, occopt=3, tsmear=0.01, ) if nsppol == 2: global_vars.update(spinat=[0.0, 0.0, 4.0]) inp.set_variables(**global_vars) # Dataset 1 (GS run) inp[1].set_kmesh(ngkpt=[4,4,4], shiftk=[0.5,0.5,0.5]) inp[1].set_variables(tolvrs=1e-6) # Dataset 2 (NSCF run) inp[2].set_kpath(ndivsm=4) inp[2].set_variables(tolwfr=1e-8) # Generate two input files for the GS and the NSCF run scf_input, nscf_input = inp.split_datasets() return scf_input, nscf_input
def ion_relaxation(tvars, ntime=50): pseudos = abidata.pseudos("14si.pspnc") cif_file = abidata.cif_file("si.cif") structure = abilab.Structure.from_file(cif_file) # Perturb the structure (random perturbation of 0.1 Angstrom) structure.perturb(distance=0.02) global_vars = dict( ecut=6, ngkpt=[2,2,2], shiftk=[0,0,0], nshiftk=1, chksymbreak=0, paral_kgb=tvars.paral_kgb, ) inp = abilab.AbiInput(pseudos=pseudos) inp.set_structure(structure) # Global variables inp.set_variables(**global_vars) # Dataset 1 (Atom Relaxation) inp[1].set_variables( optcell=0, ionmov=2, tolrff=0.02, tolmxf=5.0e-5, ntime=ntime, #dilatmx=1.05, # FIXME: abinit crashes if I don't use this ) return inp
def build_flow(options): structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) scf_kppa = 40 nscf_nband = 6 ndivsm = 5 #dos_ngkpt = [4,4,4] #dos_shiftk = [0.1, 0.2, 0.3] extra_abivars = dict( ecut=6, timopt=-1, accesswff=3, istwfk="*1", ) # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") workdir = options.workdir if not options.workdir: workdir = os.path.basename(__file__).replace(".py", "").replace("run_","flow_") # Instantiate the TaskManager. manager = abilab.TaskManager.from_user_config() if not options.manager else \ abilab.TaskManager.from_file(options.manager) # Initialize the flow. # FIXME Abistructure is not pickleable with protocol -1 flow = abilab.AbinitFlow(workdir=workdir, manager=manager, pickle_protocol=0) work = bandstructure(structure, abidata.pseudos("14si.pspnc"), scf_kppa, nscf_nband, ndivsm, spin_mode="unpolarized", smearing=None, **extra_abivars) flow.register_work(work) return flow.allocate()
def make_scf_nscf_inputs(nsppol, paral_kgb=1): """ Generate two input files for the GS and the NSCF run for given `nsppol`. """ # Fe normal bcc structure for test of a ferromagnetic calculation multi = abilab.MultiDataset(structure=data.structure_from_ucell("Fe-fm"), pseudos=data.pseudos("26fe.pspnc"), ndtset=2) # Global variables global_vars = dict( nsppol=nsppol, ecut=18, nband=8, occopt=3, tsmear=0.01, paral_kgb=paral_kgb, ) if nsppol == 2: global_vars.update(spinat=[0.0, 0.0, 4.0]) multi.set_vars(global_vars) # Dataset 1 (GS run) multi[0].set_kmesh(ngkpt=[4,4,4], shiftk=[0.5,0.5,0.5]) multi[0].set_vars(tolvrs=1e-6) # Dataset 2 (NSCF run) multi[1].set_kpath(ndivsm=4) multi[1].set_vars(tolwfr=1e-8) # Generate two input files for the GS and the NSCF run scf_input, nscf_input = multi.split_datasets() return scf_input, nscf_input
def make_template(): """Build a template input file for GS calculations with paral_kgb""" inp = abilab.AbiInput(pseudos=data.pseudos("14si.pspnc")) inp.set_structure(data.structure_from_ucell("Si")) # GS run with paral_kgb inp.set_kmesh(ngkpt=[1,1,1], shiftk=[0,0,0]) # Global variables global_vars = dict(ecut=20, nsppol=1, nband=20, paral_kgb=1, npkpt=1, npband=1, npfft=1, # istwfk="*1", timopt=-1, chksymbreak=0, prtwf=0, prtden=0, tolvrs=1e-8, nstep=10, ) inp.set_variables(**global_vars) return inp
def make_scf_input(paral_kgb=0): """ This function constructs the input files for the phonon calculation: GS input + the input files for the phonon calculation. """ # Crystalline AlAs: computation of the second derivative of the total energy structure = abidata.structure_from_ucell("AlAs") pseudos = abidata.pseudos("13al.981214.fhi", "33as.pspnc") gs_inp = abilab.AbinitInput(structure, pseudos=pseudos) gs_inp.set_vars( nband=4, ecut=2.0, ngkpt=[4, 4, 4], nshiftk=4, shiftk=[0.0, 0.0, 0.5, # This gives the usual fcc Monkhorst-Pack grid 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.5], #shiftk=[0, 0, 0], paral_kgb=paral_kgb, tolvrs=1.0e-10, ixc=1, diemac=9.0, iomode=3, ) return gs_inp
def make_electronic_structure_flow(ngkpts_for_dos=[(2, 2, 2), (4, 4, 4), (6, 6, 6), (8, 8, 8)]): """Band structure calculation.""" multi = abilab.MultiDataset(structure=abidata.cif_file("si.cif"), pseudos=abidata.pseudos("14si.pspnc"), ndtset=2 + len(ngkpts_for_dos)) # Global variables multi.set_vars(ecut=10) # Dataset 1 multi[0].set_vars(tolvrs=1e-9) multi[0].set_kmesh(ngkpt=[4, 4, 4], shiftk=[0, 0, 0]) # Dataset 2 multi[1].set_vars(tolwfr=1e-15) multi[1].set_kpath(ndivsm=5) # Dataset 3 for i, ngkpt in enumerate(ngkpts_for_dos): multi[2+i].set_vars(tolwfr=1e-15) multi[2+i].set_kmesh(ngkpt=ngkpt, shiftk=[0,0,0]) inputs = multi.split_datasets() scf_input, nscf_input, dos_input = inputs[0], inputs[1], inputs[2:] return abilab.bandstructure_flow(workdir="flow_dos_bands", scf_input=scf_input, nscf_input=nscf_input, dos_inputs=dos_input)
def make_scf_nscf_inputs(paral_kgb=1): """Returns two input files: GS run and NSCF on a high symmetry k-mesh.""" multi = abilab.MultiDataset(structure=abidata.cif_file("si.cif"), pseudos=abidata.pseudos("14si.pspnc"), ndtset=2) # Global variables ecut = 4 global_vars = dict(ecut=ecut, nband=8, nstep=15, paral_kgb=paral_kgb) if multi.ispaw: global_vars.update(pawecutdg=2*ecut) multi.set_vars(global_vars) # Dataset 1 (GS run) multi[0].set_kmesh(ngkpt=[2,2,2], shiftk=[0,0,0]) multi[0].set_vars(tolvrs=1e-4) # Dataset 2 (NSCF run) kptbounds = [ [0.5, 0.0, 0.0], # L point [0.0, 0.0, 0.0], # Gamma point [0.0, 0.5, 0.5], # X point ] multi[1].set_kpath(ndivsm=2, kptbounds=kptbounds) multi[1].set_vars(tolwfr=1e-4) # Generate two input files for the GS and the NSCF run scf_input, nscf_input = multi.split_datasets() return scf_input, nscf_input
def gs_input(x=0.7, acell=(10, 10, 10)): """H2 molecule in a big box""" structure = abilab.Structure.from_abivars( ntypat=1, znucl=1, natom=2, typat=(1, 1), xcart=[-x, 0.0, 0.0, +x, 0.0, 0.0], acell=acell, rprim=[1, 0, 0, 0, 1, 0, 0, 0, 1] ) inp = abilab.AbinitInput(structure=structure, pseudos=abidata.pseudos("01h.pspgth")) inp.set_vars( ecut=10, nband=1, diemac=2.0, nstep=10, toldfe=1e-6, ) inp.set_kmesh(ngkpt=(1,1,1), shiftk=(0,0,0)) return inp
def build_flow(options): # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") if not options.workdir: options.workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_") structure = abidata.structure_from_ucell("MgB2") # Get pseudos from a table. table = abilab.PseudoTable(abidata.pseudos("12mg.pspnc", "5b.pspnc")) pseudos = table.get_pseudos_for_structure(structure) flow = flowtk.Flow(workdir=options.workdir) # Build work of GS task. Each gs_task uses different (ngkpt, tsmear) values # and represent the starting point of the phonon works. scf_work = flowtk.Work() ngkpt_list = [[4, 4, 4], [8, 8, 8]] #, [12, 12, 12]] tsmear_list = [0.01, 0.02] # , 0.04] for ngkpt in ngkpt_list: for tsmear in tsmear_list: scf_input = make_scf_input(structure, ngkpt, tsmear, pseudos) scf_work.register_scf_task(scf_input) flow.register_work(scf_work) # This call uses the information reported in the GS task to # compute all the independent atomic perturbations corresponding to a [2, 2, 2] q-mesh. # For each GS task, construct a phonon work that will inherit (ngkpt, tsmear) from scf_task. for scf_task in scf_work: ph_work = flowtk.PhononWork.from_scf_task(scf_task, qpoints=[2, 2, 2], is_ngqpt=True) flow.register_work(ph_work) return flow.allocate(use_smartio=True)
def make_input(): """ GS calculations with paralkgb==1 Gold with 107 atoms. """ pseudos = abidata.pseudos("au.paw") # Atomic Positions. xred = np.fromstring(""" 0.0000000000E+00 1.6326095981E-01 1.6326095981E-01 1.6326095981E-01 0.0000000000E+00 1.6326095981E-01 1.6326095981E-01 1.6326095981E-01 0.0000000000E+00 0.0000000000E+00 1.6641506689E-01 5.0000000000E-01 1.6641506689E-01 0.0000000000E+00 5.0000000000E-01 1.6596912386E-01 1.6596912386E-01 3.3213568011E-01 0.0000000000E+00 0.0000000000E+00 3.3251308046E-01 0.0000000000E+00 1.6326095981E-01 8.3673904019E-01 1.6326095981E-01 0.0000000000E+00 8.3673904019E-01 1.6596912386E-01 1.6596912386E-01 6.6786431989E-01 0.0000000000E+00 0.0000000000E+00 6.6748691954E-01 0.0000000000E+00 5.0000000000E-01 1.6641506689E-01 1.6596912386E-01 3.3213568011E-01 1.6596912386E-01 1.6641506689E-01 5.0000000000E-01 0.0000000000E+00 0.0000000000E+00 3.3251308046E-01 0.0000000000E+00 0.0000000000E+00 5.0000000000E-01 5.0000000000E-01 1.6649623194E-01 3.3291657817E-01 5.0000000000E-01 1.6649623194E-01 5.0000000000E-01 3.3291657817E-01 0.0000000000E+00 3.3314040855E-01 3.3314040855E-01 0.0000000000E+00 5.0000000000E-01 8.3358493311E-01 1.6596912386E-01 3.3213568011E-01 8.3403087614E-01 1.6649623194E-01 5.0000000000E-01 6.6708342183E-01 0.0000000000E+00 3.3314040855E-01 6.6685959145E-01 0.0000000000E+00 8.3673904019E-01 1.6326095981E-01 1.6596912386E-01 6.6786431989E-01 1.6596912386E-01 1.6326095981E-01 8.3673904019E-01 0.0000000000E+00 0.0000000000E+00 6.6748691954E-01 0.0000000000E+00 0.0000000000E+00 8.3358493311E-01 5.0000000000E-01 1.6649623194E-01 6.6708342183E-01 5.0000000000E-01 1.6596912386E-01 8.3403087614E-01 3.3213568011E-01 0.0000000000E+00 6.6685959145E-01 3.3314040855E-01 0.0000000000E+00 8.3673904019E-01 8.3673904019E-01 1.6596912386E-01 6.6786431989E-01 8.3403087614E-01 1.6596912386E-01 8.3403087614E-01 6.6786431989E-01 0.0000000000E+00 6.6685959145E-01 6.6685959145E-01 3.3213568011E-01 1.6596912386E-01 1.6596912386E-01 5.0000000000E-01 0.0000000000E+00 1.6641506689E-01 5.0000000000E-01 1.6641506689E-01 0.0000000000E+00 3.3251308046E-01 0.0000000000E+00 0.0000000000E+00 3.3291657817E-01 1.6649623194E-01 5.0000000000E-01 5.0000000000E-01 0.0000000000E+00 5.0000000000E-01 5.0000000000E-01 1.6649623194E-01 3.3291657817E-01 3.3314040855E-01 0.0000000000E+00 3.3314040855E-01 3.3213568011E-01 1.6596912386E-01 8.3403087614E-01 5.0000000000E-01 0.0000000000E+00 8.3358493311E-01 5.0000000000E-01 1.6649623194E-01 6.6708342183E-01 3.3314040855E-01 0.0000000000E+00 6.6685959145E-01 3.3291657817E-01 5.0000000000E-01 1.6649623194E-01 5.0000000000E-01 3.3291657817E-01 1.6649623194E-01 5.0000000000E-01 5.0000000000E-01 0.0000000000E+00 3.3314040855E-01 3.3314040855E-01 0.0000000000E+00 3.3316116420E-01 5.0000000000E-01 5.0000000000E-01 5.0000000000E-01 3.3316116420E-01 5.0000000000E-01 5.0000000000E-01 5.0000000000E-01 3.3316116420E-01 3.3302887829E-01 3.3302887829E-01 3.3302887829E-01 3.3291657817E-01 5.0000000000E-01 8.3350376806E-01 5.0000000000E-01 3.3291657817E-01 8.3350376806E-01 5.0000000000E-01 5.0000000000E-01 6.6683883580E-01 3.3302887829E-01 3.3302887829E-01 6.6697112171E-01 3.3213568011E-01 8.3403087614E-01 1.6596912386E-01 5.0000000000E-01 6.6708342183E-01 1.6649623194E-01 5.0000000000E-01 8.3358493311E-01 0.0000000000E+00 3.3314040855E-01 6.6685959145E-01 0.0000000000E+00 3.3291657817E-01 8.3350376806E-01 5.0000000000E-01 5.0000000000E-01 6.6683883580E-01 5.0000000000E-01 5.0000000000E-01 8.3350376806E-01 3.3291657817E-01 3.3302887829E-01 6.6697112171E-01 3.3302887829E-01 3.3213568011E-01 8.3403087614E-01 8.3403087614E-01 5.0000000000E-01 6.6708342183E-01 8.3350376806E-01 5.0000000000E-01 8.3350376806E-01 6.6708342183E-01 3.3302887829E-01 6.6697112171E-01 6.6697112171E-01 6.6786431989E-01 1.6596912386E-01 1.6596912386E-01 8.3673904019E-01 0.0000000000E+00 1.6326095981E-01 8.3673904019E-01 1.6326095981E-01 0.0000000000E+00 6.6748691954E-01 0.0000000000E+00 0.0000000000E+00 6.6708342183E-01 1.6649623194E-01 5.0000000000E-01 8.3358493311E-01 0.0000000000E+00 5.0000000000E-01 8.3403087614E-01 1.6596912386E-01 3.3213568011E-01 6.6685959145E-01 0.0000000000E+00 3.3314040855E-01 6.6786431989E-01 1.6596912386E-01 8.3403087614E-01 8.3673904019E-01 0.0000000000E+00 8.3673904019E-01 8.3403087614E-01 1.6596912386E-01 6.6786431989E-01 6.6685959145E-01 0.0000000000E+00 6.6685959145E-01 6.6708342183E-01 5.0000000000E-01 1.6649623194E-01 8.3403087614E-01 3.3213568011E-01 1.6596912386E-01 8.3358493311E-01 5.0000000000E-01 0.0000000000E+00 6.6685959145E-01 3.3314040855E-01 0.0000000000E+00 6.6683883580E-01 5.0000000000E-01 5.0000000000E-01 8.3350376806E-01 3.3291657817E-01 5.0000000000E-01 8.3350376806E-01 5.0000000000E-01 3.3291657817E-01 6.6697112171E-01 3.3302887829E-01 3.3302887829E-01 6.6708342183E-01 5.0000000000E-01 8.3350376806E-01 8.3403087614E-01 3.3213568011E-01 8.3403087614E-01 8.3350376806E-01 5.0000000000E-01 6.6708342183E-01 6.6697112171E-01 3.3302887829E-01 6.6697112171E-01 6.6786431989E-01 8.3403087614E-01 1.6596912386E-01 8.3403087614E-01 6.6786431989E-01 1.6596912386E-01 8.3673904019E-01 8.3673904019E-01 0.0000000000E+00 6.6685959145E-01 6.6685959145E-01 0.0000000000E+00 6.6708342183E-01 8.3350376806E-01 5.0000000000E-01 8.3350376806E-01 6.6708342183E-01 5.0000000000E-01 8.3403087614E-01 8.3403087614E-01 3.3213568011E-01 6.6697112171E-01 6.6697112171E-01 3.3302887829E-01 6.6786431989E-01 8.3403087614E-01 8.3403087614E-01 8.3403087614E-01 6.6786431989E-01 8.3403087614E-01 8.3403087614E-01 8.3403087614E-01 6.6786431989E-01 6.6697112171E-01 6.6697112171E-01 6.6697112171E-01 """, sep=" ").reshape((-1,3)) # Crystal structure. structure = abilab.Structure.from_abivars( acell=3*[23.01], rprim=np.eye(3), typat=107*[1], znucl=79., xred=xred, ) inp = abilab.AbinitInput(structure, pseudos) inp.set_vars( # Basis set. ecut=10., pawecutdg=20., # SCF algorithm paral_kgb=1, wfoptalg=1, fftalg=402, #fftalg=302, # To use FFTW instead of ABINIT FFT # SCF cycle toldfe=1.e-5, nstep=20, # K-points and symmetries. nkpt=1, kpt=3*[0.], kptopt=0, istwfk="*1", nsym=0, chksymbreak=0, chkprim=0, # Bands and occupation scheme nband=650, occopt=3, tsmear=0.002, nbdbuf=20, # IO optforces=2, optstress=1, prtwf=0, prtden=0, prteig=0, timopt=-1, ) return inp
def make_input(paw=False): """ Build and return an input file for MD calculations with paral_kgb=1 """ pseudos = abidata.pseudos("Al.oncvpsp") if not paw else \ abidata.pseudos("Al.GGA_PBE-JTH-paw.xml") # Atomic Positions. xred = np.fromstring(""" 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.25000000E+00 0.25000000E+00 0.25000000E+00 0.00000000E+00 0.25000000E+00 0.25000000E+00 0.25000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.50000000E+00 0.00000000E+00 0.25000000E+00 0.75000000E+00 0.25000000E+00 0.00000000E+00 0.75000000E+00 0.25000000E+00 0.25000000E+00 0.50000000E+00 0.00000000E+00 0.50000000E+00 0.00000000E+00 0.00000000E+00 0.75000000E+00 0.25000000E+00 0.25000000E+00 0.50000000E+00 0.25000000E+00 0.25000000E+00 0.75000000E+00 0.00000000E+00 0.00000000E+00 0.50000000E+00 0.50000000E+00 0.00000000E+00 0.75000000E+00 0.75000000E+00 0.25000000E+00 0.50000000E+00 0.75000000E+00 0.25000000E+00 0.75000000E+00 0.50000000E+00 0.50000000E+00 0.00000000E+00 0.00000000E+00 0.50000000E+00 0.25000000E+00 0.25000000E+00 0.75000000E+00 0.00000000E+00 0.25000000E+00 0.75000000E+00 0.25000000E+00 0.00000000E+00 0.50000000E+00 0.00000000E+00 0.50000000E+00 0.50000000E+00 0.25000000E+00 0.75000000E+00 0.75000000E+00 0.00000000E+00 0.75000000E+00 0.75000000E+00 0.25000000E+00 0.50000000E+00 0.50000000E+00 0.50000000E+00 0.00000000E+00 0.50000000E+00 0.75000000E+00 0.25000000E+00 0.75000000E+00 0.50000000E+00 0.25000000E+00 0.75000000E+00 0.75000000E+00 0.00000000E+00 0.50000000E+00 0.50000000E+00 0.50000000E+00 0.50000000E+00 0.75000000E+00 0.75000000E+00 0.75000000E+00 0.50000000E+00 0.75000000E+00 0.75000000E+00 0.75000000E+00 0.50000000E+00 """, sep=" ").reshape((-1, 3)) # Crystal structure (32 Al atoms) structure = abilab.Structure.from_abivars( acell=3 * [12.81], rprim=np.eye(3), ntypat=1, typat=32 * [1], znucl=13.0, xred=xred, ) inp = abilab.AbinitInput(structure, pseudos) inp.set_vars( # parallelization paral_kgb=1, #npband=10, #npfft=3, #npkpt=4, #bandpp=2, ecut=3.0, pawecutdg=6.0 if paw else None, nband=80, nsppol=1, # SCF cycle parameters tolvrs=1.e-3, nstep=50, # K-points and sym occopt=3, nsym=1, # Molecular Dynamics parameters ionmov=12, ntime=100, dtion=100, mdtemp=[3000, 3000], tsmear=0.009500446, # IO prtden=0, prtwf=0, prteig=0, timopt=-1, ) inp.set_kmesh(ngkpt=[1, 1, 1], shiftk=[0, 0, 0]) #%% nprocs_to_test = 120 return inp
def setUp(cls): cls.gan_structure = abilab.Structure.from_file(abidata.cif_file("gan.cif")) cls.gan_pseudos = [abidata.pseudos("31ga.pspnc").pseudo_with_symbol('Ga'), abidata.pseudos("7n.pspnc").pseudo_with_symbol('N')] cls.scf_inp = scf_input(cls.gan_structure, cls.gan_pseudos, ecut=2, kppa=10, smearing=None, spin_mode="unpolarized")
def make_inputs(ngkpt, paral_kgb=1): # Crystalline silicon # Calculation of the GW correction to the direct band gap in Gamma # Dataset 1: ground state calculation # Dataset 2: NSCF calculation # Dataset 3: calculation of the screening # Dataset 4-5-6: Self-Energy matrix elements (GW corrections) with different values of nband multi = abilab.MultiDataset(structure=data.cif_file("si.cif"), pseudos=data.pseudos("14si.pspnc"), ndtset=6) # This grid is the most economical, but does not contain the Gamma point. scf_kmesh = dict( ngkpt=ngkpt, 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]) # This grid contains the Gamma point, which is the point at which # we will compute the (direct) band gap. gw_kmesh = dict( ngkpt=ngkpt, shiftk=[0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0]) # Global variables. gw_kmesh is used in all datasets except DATASET 1. ecut = 6 multi.set_vars( ecut=ecut, timopt=-1, istwfk="*1", paral_kgb=paral_kgb, gwpara=2, ) multi.set_kmesh(**gw_kmesh) # Dataset 1 (GS run) multi[0].set_kmesh(**scf_kmesh) multi[0].set_vars( tolvrs=1e-6, nband=4, ) # Dataset 2 (NSCF run) # Here we select the second dataset directly with the syntax multi[1] multi[1].set_vars( iscf=-2, tolwfr=1e-12, nband=35, nbdbuf=5, ) # Dataset3: Calculation of the screening. multi[2].set_vars( optdriver=3, nband=25, ecutwfn=ecut, symchi=1, inclvkb=0, ecuteps=4.0, ppmfrq="16.7 eV", ) # Dataset4: Calculation of the Self-Energy matrix elements (GW corrections) kptgw = [ -2.50000000E-01, -2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, ] bdgw = [1, 8] for idx, nband in enumerate([10, 20, 30]): multi[3 + idx].set_vars( optdriver=4, nband=nband, ecutwfn=ecut, ecuteps=4.0, ecutsigx=6.0, symsigma=1, #gw_qprange=0, #nkptgw=0, ) multi[3 + idx].set_kptgw(kptgw, bdgw) return multi.split_datasets()
def itest_tolsymerror_handler(fwp): """ Test the handler of TolSymError. The test triggers: --- !TolSymError message: | Could not find the point group src_file: symptgroup.F90 src_line: 236 ... at the level of the symmetry finder and autoparal fails because it cannot find the parallel configurations. """ pytest.xfail( "tolsymerror_handler has been disabled because this problem has been fixed in v9." ) structure = dict( acell=(1.0, 1.0, 1.0), xred=[ 1.0001907690, 1.0040151117, 0.0099335191, 0.2501907744, 0.2540150788, 0.2599335332 ], rprim=[ -6.2733366562, 0.0000000000, -3.6219126071, -6.2733366562, 0.0000000000, 3.6219126071, -4.1822244376, 5.9145585205, 0.0000000000 ], typat=(1, 1), ntypat=1, znucl=14, natom=2, ) inp = abilab.AbinitInput(structure=structure, pseudos=abidata.pseudos("14si.pspnc")) inp.set_vars( ntime=5, tolrff=0.02, shiftk=[0, 0, 0], ngkpt=(4, 4, 4), chksymbreak=0, ecut=4, tolmxf=5e-05, nshiftk=1, #tolsym=1e-10, ) flow = flowtk.Flow(workdir=fwp.workdir, manager=fwp.manager) flow.register_task(inp, task_class=flowtk.RelaxTask) flow.allocate() assert flow.make_scheduler().start() == 0 flow.show_status() if not flow.all_ok: flow.debug() raise RuntimeError() task = flow[0][0] assert len(task.corrections) == 1 assert task.corrections[0]["event"]["@class"] == "TolSymError"
def test_api(self): """Test MultiDataset API.""" structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) multi = MultiDataset(structure=structure, pseudos=abidata.pseudos("14si.pspnc")) assert len(multi) == 1 and multi.ndtset == 1 for i, inp in enumerate(multi): assert inp.keys() == multi[i].keys() multi.addnew_from(0) assert multi.ndtset == 2 and multi[0] is not multi[1] assert multi[0].structure == multi[1].structure assert multi[0].structure is not multi[1].structure multi.set_vars(ecut=2) assert all(inp["ecut"] == 2 for inp in multi) multi[1].set_vars(ecut=1) assert multi[0]["ecut"] == 2 and multi[1]["ecut"] == 1 pert_structure = structure.copy() pert_structure.perturb(distance=0.1) assert structure != pert_structure assert multi.set_structure(structure) == multi.ndtset * [structure] assert all(s == structure for s in multi.structure) assert multi.has_same_structures multi[1].set_structure(pert_structure) assert multi[0].structure != multi[1].structure and multi[ 1].structure == pert_structure assert not multi.has_same_structures split = multi.split_datasets() assert len(split) == 2 and all(split[i] == multi[i] for i in range(multi.ndtset)) print(multi) #print(dir(multi)) #assert 0 tmp_dir = tempfile.mkdtemp() tmp_file = os.path.join(tmp_dir, "run.abi") inp.write(filepath=tmp_file) new_multi = MultiDataset.from_inputs([inp for inp in multi]) assert new_multi.ndtset == multi.ndtset assert new_multi.structure == multi.structure for old_inp, new_inp in zip(multi, new_multi): assert old_inp is not new_inp self.assertDictEqual(old_inp.as_dict(), new_inp.as_dict()) ref_input = multi[0] new_multi = MultiDataset.replicate_input(input=ref_input, ndtset=4) assert new_multi.ndtset == 4 for inp in new_multi: assert ref_input is not inp self.assertDictEqual(ref_input.as_dict(), inp.as_dict()) # Compatible with Pickle and MSONable? #self.serialize_with_pickle(multi, test_eq=False) #self.assertMSONable(multi) # Test tags new_multi.add_tags([GROUND_STATE, RELAX], [0, 2]) assert len(new_multi[0].tags) == 2 sub_multi = new_multi.filter_by_tags(GROUND_STATE) assert len(sub_multi) == 2 new_multi.remove_tags([RELAX]) assert len(new_multi[0].tags) == 1
def build_flow(options): """ Build and return an AbiPy flow to compute phonon linewidths and Eliashberg function in Aluminium: 1. Compute DFPT phonons on a 4x4x4 q-mesh with a coarse 8x8x8 k-sampling 2. Generate 3 WFK files on a much denser k-mesh (x16, x24, x32) 3. Run the EPH code with: - one of the WFK files generated in point 2. - interpolated DFPT potentials (from the initial 4x4x4 to a 8x8x8 q-mesh) 4. Analyze the convergence of the results wrt nkpt. Note that the q-point grid must be a sub-grid of the k-point grid """ workdir = options.workdir if (options and options.workdir) else "flow_eph_al" # Create empty flow. flow = flowtk.Flow(workdir=workdir) # Init structure. Use NC pseudo structure = abilab.Structure.fcc(a=7.5, species=["Al"], units="bohr") pseudos = abidata.pseudos("Al.oncvpsp") # Input for GS part. gs_inp = abilab.AbinitInput(structure, pseudos) gs_inp.set_vars( istwfk="*1", ecut=8.0, nband=4, occopt=7, # Include metallic occupation function with a small smearing tsmear=0.04, tolvrs=1e-7, ) # The k-grid is minimalistic to keep the calculation manageable. gs_inp.set_kmesh( ngkpt=[8, 8, 8], shiftk=[0.0, 0.0, 0.0], ) # Build new input for NSCF calculation along k-path (automatically selected by AbiPy) # Used to plot the KS band structure. nscf_kpath_inp = gs_inp.new_with_vars( nband=4, tolwfr=1e-16, iscf=-2, ) nscf_kpath_inp.set_kpath(ndivsm=10) # Build NSCF inputs with denser k-meshes # This step generates the WFK files used to compute the Eliashberg function. # We have a cubic material so we only need to specify the first number of divisions. nk_list = [16, 24, 32] nscf_kmesh_inputs = [] for nk in nk_list: new_inp = gs_inp.new_with_vars( tolwfr=1e-16, iscf=-2, ngkpt=[nk] * 3, shiftk=[0.0, 0.0, 0.0], ) nscf_kmesh_inputs.append(new_inp) # Register GS + NSCF kpath + NSCF with k-meshes in work0. work0 = flowtk.BandStructureWork(gs_inp, nscf_kpath_inp, dos_inputs=nscf_kmesh_inputs) flow.register_work(work0) # Generate Phonon work with 4x4x4 q-mesh # Reuse the variables from GS input and let AbiPy handle the generation of the input files # Note that the q-point grid is a sub-grid of the k-mesh so we do not need WFQ on k+q mesh. ddb_ngqpt = [4, 4, 4] ph_work = flowtk.PhononWork.from_scf_task(work0[0], ddb_ngqpt, is_ngqpt=True) flow.register_work(ph_work) # Ssction for EPH calculation: compute linewidths with different WKK files. eph_work = flowtk.Work() for ik, nk in enumerate(nk_list): # Each task uses a different WFK file. DDB and DBDB do not change. eph_deps = {work0[2 + ik]: "WFK", ph_work: ["DDB", "DVDB"]} # Interpolate DFPT potentials 4x4x4 --> 8x8x8 eph_ngqpt_fine = (8, 8, 8) # Build input for E-PH run. See also v7/Input/t85.in # The k-points must be in the WFK file eph_inp = gs_inp.new_with_vars( optdriver=7, # Enter EPH driver. eph_task=1, # Compute phonon linewidths in metals. ddb_ngqpt= ddb_ngqpt, # q-mesh used to produce the DDB file (must be consistent with DDB data) eph_fsewin= "0.8 eV", # Energy window around Ef (only states in this window are included) eph_intmeth=2, # Tetra method #eph_intmeth=1, # Gaussian #eph_fsmear=eph_fsmear * abilab.units.eV_to_Ha, # Broadening eph_ngqpt_fine= eph_ngqpt_fine, # Interpolate DFPT potentials if != ddb_ngqpt eph_mustar=0.12, # mustar parameter ngkpt=[nk] * 3, shiftk=[0.0, 0.0, 0.0], ) # Set q-path to interpolate phonons and phonon linewidths. eph_inp.set_qpath(10) # Set q-mesh for phonons DOS and a2F(w) eph_inp.set_phdos_qmesh(nqsmall=24, method="tetra") eph_work.register_eph_task(eph_inp, deps=eph_deps) flow.register_work(eph_work) # Avoid producing (big) output files that not required by children. flow.allocate(use_smartio=True) return flow
def make_input(): """ UO2 with 96 atoms. GS calculations with paralkgb==1 """ pseudos = abidata.pseudos("u.paw", "o.paw") # Atomic Positions. xred = np.fromstring(""" 0.00000000000000 0.00000000000000 0.00000000000000 0.25000000000000 0.25000000000000 0.00000000000000 0.25000000000000 0.00000000000000 0.25000000000000 0.00000000000000 0.25000000000000 0.25000000000000 0.00000000000000 0.00000000000000 0.50000000000000 0.25000000000000 0.25000000000000 0.50000000000000 0.25000000000000 0.00000000000000 0.75000000000000 0.00000000000000 0.25000000000000 0.75000000000000 0.00000000000000 0.50000000000000 0.00000000000000 0.25000000000000 0.75000000000000 0.00000000000000 0.25000000000000 0.50000000000000 0.25000000000000 0.00000000000000 0.75000000000000 0.25000000000000 0.00000000000000 0.50000000000000 0.50000000000000 0.25000000000000 0.75000000000000 0.50000000000000 0.25000000000000 0.50000000000000 0.75000000000000 0.00000000000000 0.75000000000000 0.75000000000000 0.50000000000000 0.00000000000000 0.00000000000000 0.75000000000000 0.25000000000000 0.00000000000000 0.75000000000000 0.00000000000000 0.25000000000000 0.50000000000000 0.25000000000000 0.25000000000000 0.50000000000000 0.00000000000000 0.50000000000000 0.75000000000000 0.25000000000000 0.50000000000000 0.75000000000000 0.00000000000000 0.75000000000000 0.50000000000000 0.25000000000000 0.75000000000000 0.50000000000000 0.50000000000000 0.00000000000000 0.75000000000000 0.75000000000000 0.00000000000000 0.75000000000000 0.50000000000000 0.25000000000000 0.50000000000000 0.75000000000000 0.25000000000000 0.50000000000000 0.50000000000000 0.50000000000000 0.75000000000000 0.75000000000000 0.50000000000000 0.75000000000000 0.50000000000000 0.75000000000000 0.50000000000000 0.75000000000000 0.75000000000000 0.12500000000000 0.12500000000000 0.12500000000000 0.12500000000000 0.37500000000000 0.12500000000000 0.37500000000000 0.12500000000000 0.12500000000000 0.37500000000000 0.37500000000000 0.12500000000000 0.12500000000000 0.12500000000000 0.37500000000000 0.12500000000000 0.37500000000000 0.37500000000000 0.37500000000000 0.12500000000000 0.37500000000000 0.37500000000000 0.37500000000000 0.37500000000000 0.12500000000000 0.12500000000000 0.62500000000000 0.12500000000000 0.37500000000000 0.62500000000000 0.37500000000000 0.12500000000000 0.62500000000000 0.37500000000000 0.37500000000000 0.62500000000000 0.12500000000000 0.12500000000000 0.87500000000000 0.12500000000000 0.37500000000000 0.87500000000000 0.37500000000000 0.12500000000000 0.87500000000000 0.37500000000000 0.37500000000000 0.87500000000000 0.12500000000000 0.62500000000000 0.12500000000000 0.12500000000000 0.87500000000000 0.12500000000000 0.37500000000000 0.62500000000000 0.12500000000000 0.37500000000000 0.87500000000000 0.12500000000000 0.12500000000000 0.62500000000000 0.37500000000000 0.12500000000000 0.87500000000000 0.37500000000000 0.37500000000000 0.62500000000000 0.37500000000000 0.37500000000000 0.87500000000000 0.37500000000000 0.12500000000000 0.62500000000000 0.62500000000000 0.12500000000000 0.87500000000000 0.62500000000000 0.37500000000000 0.62500000000000 0.62500000000000 0.37500000000000 0.87500000000000 0.62500000000000 0.12500000000000 0.62500000000000 0.87500000000000 0.12500000000000 0.87500000000000 0.87500000000000 0.37500000000000 0.62500000000000 0.87500000000000 0.37500000000000 0.87500000000000 0.87500000000000 0.62500000000000 0.12500000000000 0.12500000000000 0.62500000000000 0.37500000000000 0.12500000000000 0.87500000000000 0.12500000000000 0.12500000000000 0.87500000000000 0.37500000000000 0.12500000000000 0.62500000000000 0.12500000000000 0.37500000000000 0.62500000000000 0.37500000000000 0.37500000000000 0.87500000000000 0.12500000000000 0.37500000000000 0.87500000000000 0.37500000000000 0.37500000000000 0.62500000000000 0.12500000000000 0.62500000000000 0.62500000000000 0.37500000000000 0.62500000000000 0.87500000000000 0.12500000000000 0.62500000000000 0.87500000000000 0.37500000000000 0.62500000000000 0.62500000000000 0.12500000000000 0.87500000000000 0.62500000000000 0.37500000000000 0.87500000000000 0.87500000000000 0.12500000000000 0.87500000000000 0.87500000000000 0.37500000000000 0.87500000000000 0.62500000000000 0.62500000000000 0.12500000000000 0.62500000000000 0.87500000000000 0.12500000000000 0.87500000000000 0.62500000000000 0.12500000000000 0.87500000000000 0.87500000000000 0.12500000000000 0.62500000000000 0.62500000000000 0.37500000000000 0.62500000000000 0.87500000000000 0.37500000000000 0.87500000000000 0.62500000000000 0.37500000000000 0.87500000000000 0.87500000000000 0.37500000000000 0.62500000000000 0.62500000000000 0.62500000000000 0.62500000000000 0.87500000000000 0.62500000000000 0.87500000000000 0.62500000000000 0.62500000000000 0.87500000000000 0.87500000000000 0.62500000000000 0.62500000000000 0.62500000000000 0.87500000000000 0.62500000000000 0.87500000000000 0.87500000000000 0.87500000000000 0.62500000000000 0.87500000000000 0.87500000000000 0.87500000000000 0.87500000000000 """, sep=" ").reshape((-1, 3)) # Crystal structure with acell 3*11. angstrom natom 96 ntypat 2 structure = abilab.Structure.from_abivars( acell=3 * [11. / bohr_to_ang], rprim=np.eye(3), typat=32 * [1] + 64 * [2], znucl=[92, 8], xred=xred, ) inp = abilab.AbinitInput(structure, pseudos) inp.set_vars( # SCF algorithm paral_kgb=1, wfoptalg=1, nline=6, fftalg=402, #fftalg=302, ! To use FFTW instead of ABINIT FFT # Basis set ecut=6, pawecutdg=10, # SCF parameters toldfe=1.e-5, nstep=28, #diemac 500. # K-Points and symmetries. nkpt=1, kpt=[0.5, 0.5, 0.5], kptopt=0, istwfk="*1", nsym=0, maxnsym=2048, chksymbreak=0, chkprim=0, # Bands and occupation scheme nsppol=2, nband=448, nbdbuf=20, occopt=3, tsmear=0.0005, # IO optforces=2, optstress=1, prtwf=0, prtden=0, prteig=0, timopt=-1, # Initial magnetization. spinat=""" 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 2*0 1 192*0""", ) return inp
def build_flow(options, paral_kgb=0): # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") workdir = options.workdir if not options.workdir: workdir = os.path.basename(__file__).replace(".py", "").replace( "run_", "flow_") multi = abilab.MultiDataset(structure=data.structure_from_ucell("GaAs"), pseudos=data.pseudos("31ga.pspnc", "33as.pspnc"), ndtset=5) # Global variables kmesh = dict(ngkpt=[4, 4, 4], nshiftk=4, 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]]) global_vars = dict(ecut=2, paral_kgb=paral_kgb) global_vars.update(kmesh) multi.set_vars(global_vars) # Dataset 1 (GS run) multi[0].set_vars( tolvrs=1e-6, nband=4, ) # NSCF run with large number of bands, and points in the the full BZ multi[1].set_vars( iscf=-2, nband=20, nstep=25, kptopt=1, tolwfr=1.e-9, #kptopt=3, ) # Fourth dataset : ddk response function along axis 1 # Fifth dataset : ddk response function along axis 2 # Sixth dataset : ddk response function along axis 3 for dir in range(3): rfdir = 3 * [0] rfdir[dir] = 1 multi[2 + dir].set_vars( iscf=-3, nband=20, nstep=1, nline=0, prtwf=3, kptopt=3, nqpt=1, qpt=[0.0, 0.0, 0.0], rfdir=rfdir, rfelfd=2, tolwfr=1.e-9, ) scf_inp, nscf_inp, ddk1, ddk2, ddk3 = multi.split_datasets() # Initialize the flow. flow = flowtk.Flow(workdir, manager=options.manager, remove=options.remove) bands_work = flowtk.BandStructureWork(scf_inp, nscf_inp) flow.register_work(bands_work) ddk_work = flowtk.Work() for inp in [ddk1, ddk2, ddk3]: ddk_work.register_ddk_task(inp, deps={bands_work.nscf_task: "WFK"}) flow.register_work(ddk_work) # Optic does not support MPI with ncpus > 1. optic_input = abilab.OpticInput( broadening=0.002, # Value of the smearing factor, in Hartree domega=0.0003, # Frequency mesh. maxomega=0.3, scissor=0.000, # Scissor shift if needed, in Hartree tolerance=0.002, # Tolerance on closeness of singularities (in Hartree) num_lin_comp= 1, # Number of components of linear optic tensor to be computed lin_comp=11, # Linear coefficients to be computed (x=1, y=2, z=3) num_nonlin_comp= 2, # Number of components of nonlinear optic tensor to be computed nonlin_comp=(123, 222), # Non-linear coefficients to be computed ) # TODO # Check is the order of the 1WF files is relevant. Can we use DDK files ordered # in an arbitrary way or do we have to pass (x,y,z)? optic_task = flowtk.OpticTask(optic_input, nscf_node=bands_work.nscf_task, ddk_nodes=ddk_work) flow.register_task(optic_task) return flow
def itest_phonon_restart(fwp): """Test the restart of phonon calculations with the scheduler.""" # Crystalline AlAs: computation of the second derivative of the total energy structure = abidata.structure_from_ucell("AlAs") # List of q-points for the phonon calculation (4,4,4) mesh. qpoints = np.reshape( [ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, #5.00000000E-01, 0.00000000E+00, 0.00000000E+00, # XXX Uncomment this line to test restart from 1DEN # Too long --> disabled ], (-1, 3)) # Global variables used both for the GS and the DFPT run. global_vars = dict( nband=4, ecut=3.0, ngkpt=[4, 4, 4], shiftk=[0, 0, 0], tolvrs=1.0e-5, ) multi = abilab.MultiDataset(structure=structure, pseudos=abidata.pseudos( "13al.981214.fhi", "33as.pspnc"), ndtset=1 + len(qpoints)) multi.set_vars(global_vars) for i, qpt in enumerate(qpoints): # Response-function calculation for phonons. multi[i + 1].set_vars( rfphon=1, # Will consider phonon-type perturbation. nqpt=1, # One wavevector is to be considered. qpt=qpt, # q-wavevector. kptopt=3, nstep=5, # This is to trigger the phonon restart. ) #rfatpol 1 1 # Only the first atom is displaced #rfdir 1 0 0 # Along the first reduced coordinate axis #kptopt 2 # Automatic generation of k points, taking # i == 0 --> restart from WFK if i == 1: multi[i + 1].set_vars(prtwf=-1, nstep=5) # Restart with WFK and smart- io. if i == 2: multi[i + 1].set_vars( prtwf=0, nstep=8) # Restart from 1DEN. Too long --> disabled. all_inps = multi.split_datasets() scf_input, ph_inputs = all_inps[0], all_inps[1:] flow = phonon_flow(fwp.workdir, scf_input, ph_inputs, manager=fwp.manager) flow.set_garbage_collector() for task in flow.iflat_tasks(): task.manager.qadapter.max_num_launches = 20 assert flow.make_scheduler().start() == 0 flow.check_status(show=True, verbose=1) assert all(work.finalized for work in flow) if not flow.all_ok: flow.debug() raise RuntimeError() assert sum(task.num_restarts for task in flow.iflat_tasks()) > 0
def make_g0w0_inputs(ngkpt, tvars): """ Input files for the calculation of the GW corrections. Returns: gs_input, nscf_input, scr_input, sigma_input """ multi = abilab.MultiDataset(structure=abidata.cif_file("si.cif"), pseudos=abidata.pseudos("14si.pspnc"), ndtset=4) # This grid is the most economical, but does not contain the Gamma point. scf_kmesh = dict( ngkpt=ngkpt, 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]) # This grid contains the Gamma point, which is the point at which # we will compute the (direct) band gap. gw_kmesh = dict( ngkpt=ngkpt, shiftk=[0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0]) # Global variables. gw_kmesh is used in all datasets except DATASET 1. ecut = 4 multi.set_vars( ecut=ecut, pawecutdg=ecut * 2 if multi.ispaw else None, istwfk="*1", paral_kgb=tvars.paral_kgb, gwpara=2, ) multi.set_kmesh(**gw_kmesh) # Dataset 1 (GS run) multi[0].set_kmesh(**scf_kmesh) multi[0].set_vars(tolvrs=1e-6, nband=4) # Dataset 2 (NSCF run) multi[1].set_vars(iscf=-2, tolwfr=1e-10, nband=10, nbdbuf=2) # Dataset3: Calculation of the screening. multi[2].set_vars( optdriver=3, nband=8, ecutwfn=ecut, symchi=1, inclvkb=0, ecuteps=2.0, ) # Dataset4: Calculation of the Self-Energy matrix elements (GW corrections) kptgw = [ -2.50000000E-01, -2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, ] multi[3].set_vars( optdriver=4, nband=10, ecutwfn=ecut, ecuteps=2.0, ecutsigx=2.0, symsigma=1, #gw_qprange=0, ) bdgw = [4, 5] multi[3].set_kptgw(kptgw, bdgw) return multi.split_datasets()
def make_inputs(paral_kgb=1, paw=False): # Crystalline silicon # Calculation of the GW correction to the direct band gap in Gamma # Dataset 1: ground state calculation # Dataset 2: NSCF calculation # Dataset 3: calculation of the screening # Dataset 4: calculation of the Self-Energy matrix elements (GW corrections) structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) pseudos = abidata.pseudos("14si.pspnc") if not paw else abidata.pseudos("Si.GGA_PBE-JTH-paw.xml") ecut = 6 global_vars = dict( ecut=ecut, pawecutdg=ecut*4, gwpara=2, timopt=-1, istwfk="*1", ) inp = abilab.AbiInput(pseudos=pseudos, ndtset=4) inp.set_structure(structure) inp.set_vars(**global_vars) gs, nscf, scr, sigma = inp.split_datasets() # This grid is the most economical, but does not contain the Gamma point. gs_kmesh = dict( ngkpt=[2, 2, 2], 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] ) # This grid contains the Gamma point, which is the point at which # we will compute the (direct) band gap. gw_kmesh = dict( ngkpt=[2, 2, 2], shiftk=[0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0] ) # Dataset 1 (GS run) gs.set_kmesh(**gs_kmesh) gs.set_vars(tolvrs=1e-6, nband=4, ) # Dataset 2 (NSCF run) # Here we select the second dataset directly with the syntax inp[2] nscf.set_kmesh(**gw_kmesh) nscf.set_vars(iscf=-2, tolwfr=1e-12, nband=35, nbdbuf=5, ) # Dataset3: Calculation of the screening. scr.set_kmesh(**gw_kmesh) scr.set_vars( optdriver=3, nband=25, ecutwfn=ecut, symchi=1, inclvkb=0, ecuteps=4.0, ) # Dataset4: Calculation of the Self-Energy matrix elements (GW corrections) sigma.set_kmesh(**gw_kmesh) sigma.set_vars( optdriver=4, nband=35, ecutwfn=ecut, ecuteps=4.0, ecutsigx=6.0, symsigma=1, gw_qprange=1, ) return gs, nscf, scr, sigma
def setUp(self): self.si_structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) self.si_scf_input = ebands_input(self.si_structure, abidata.pseudos("14si.pspnc"), ecut=2, kppa=10).split_datasets()[0]
def scf_ph_inputs(tvars=None): """ This function constructs the input files for the phonon calculation: GS input + the input files for the phonon calculation. """ # Crystalline AlAs: computation of the second derivative of the total energy structure = abidata.structure_from_ucell("AlAs") # List of q-points for the phonon calculation (4,4,4) mesh. qpoints = [ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, ] qpoints = np.reshape(qpoints, (-1, 3)) # Global variables used both for the GS and the DFPT run. global_vars = dict( nband=4, ecut=3.0, ngkpt=[4, 4, 4], shiftk=[0, 0, 0], tolvrs=1.0e-6, paral_kgb=0 if tvars is None else tvars.paral_kgb, ) multi = abilab.MultiDataset(structure=structure, pseudos=abidata.pseudos( "13al.981214.fhi", "33as.pspnc"), ndtset=1 + len(qpoints)) multi.set_vars(global_vars) for i, qpt in enumerate(qpoints): # Response-function calculation for phonons. multi[i + 1].set_vars( nstep=20, rfphon=1, # Will consider phonon-type perturbation nqpt=1, # One wavevector is to be considered qpt=qpt, # This wavevector is q=0 (Gamma) kptopt=3, ) #rfatpol 1 1 # Only the first atom is displaced #rfdir 1 0 0 # Along the first reduced coordinate axis #kptopt 2 # Automatic generation of k points, taking # Split input into gs_inp and ph_inputs return multi.split_datasets()
def make_input(paw=True): """ Titanium with 256 atoms. GS calculations with paralkgb == 1 """ pseudos = abidata.pseudos("ti.paw") if paw else abidata.pseudos( "Ti-sp.psp8") # Atomic Positions. xred = np.fromstring(""" 0.00000000000000 0.00000000000000 0.00000000000000 0.06250000000000 0.12500000000000 0.12500000000000 0.00000000000000 0.00000000000000 0.25000000000000 0.06250000000000 0.12500000000000 0.37500000000000 0.00000000000000 0.00000000000000 0.50000000000000 0.06250000000000 0.12500000000000 0.62500000000000 0.00000000000000 0.00000000000000 0.75000000000000 0.06250000000000 0.12500000000000 0.87500000000000 0.00000000000000 0.25000000000000 0.00000000000000 0.06250000000000 0.37500000000000 0.12500000000000 0.00000000000000 0.25000000000000 0.25000000000000 0.06250000000000 0.37500000000000 0.37500000000000 0.00000000000000 0.25000000000000 0.50000000000000 0.06250000000000 0.37500000000000 0.62500000000000 0.00000000000000 0.25000000000000 0.75000000000000 0.06250000000000 0.37500000000000 0.87500000000000 0.00000000000000 0.50000000000000 0.00000000000000 0.06250000000000 0.62500000000000 0.12500000000000 0.00000000000000 0.50000000000000 0.25000000000000 0.06250000000000 0.62500000000000 0.37500000000000 0.00000000000000 0.50000000000000 0.50000000000000 0.06250000000000 0.62500000000000 0.62500000000000 0.00000000000000 0.50000000000000 0.75000000000000 0.06250000000000 0.62500000000000 0.87500000000000 0.00000000000000 0.75000000000000 0.00000000000000 0.06250000000000 0.87500000000000 0.12500000000000 0.00000000000000 0.75000000000000 0.25000000000000 0.06250000000000 0.87500000000000 0.37500000000000 0.00000000000000 0.75000000000000 0.50000000000000 0.06250000000000 0.87500000000000 0.62500000000000 0.00000000000000 0.75000000000000 0.75000000000000 0.06250000000000 0.87500000000000 0.87500000000000 0.12500000000000 0.00000000000000 0.00000000000000 0.18750000000000 0.12500000000000 0.12500000000000 0.12500000000000 0.00000000000000 0.25000000000000 0.18750000000000 0.12500000000000 0.37500000000000 0.12500000000000 0.00000000000000 0.50000000000000 0.18750000000000 0.12500000000000 0.62500000000000 0.12500000000000 0.00000000000000 0.75000000000000 0.18750000000000 0.12500000000000 0.87500000000000 0.12500000000000 0.25000000000000 0.00000000000000 0.18750000000000 0.37500000000000 0.12500000000000 0.12500000000000 0.25000000000000 0.25000000000000 0.18750000000000 0.37500000000000 0.37500000000000 0.12500000000000 0.25000000000000 0.50000000000000 0.18750000000000 0.37500000000000 0.62500000000000 0.12500000000000 0.25000000000000 0.75000000000000 0.18750000000000 0.37500000000000 0.87500000000000 0.12500000000000 0.50000000000000 0.00000000000000 0.18750000000000 0.62500000000000 0.12500000000000 0.12500000000000 0.50000000000000 0.25000000000000 0.18750000000000 0.62500000000000 0.37500000000000 0.12500000000000 0.50000000000000 0.50000000000000 0.18750000000000 0.62500000000000 0.62500000000000 0.12500000000000 0.50000000000000 0.75000000000000 0.18750000000000 0.62500000000000 0.87500000000000 0.12500000000000 0.75000000000000 0.00000000000000 0.18750000000000 0.87500000000000 0.12500000000000 0.12500000000000 0.75000000000000 0.25000000000000 0.18750000000000 0.87500000000000 0.37500000000000 0.12500000000000 0.75000000000000 0.50000000000000 0.18750000000000 0.87500000000000 0.62500000000000 0.12500000000000 0.75000000000000 0.75000000000000 0.18750000000000 0.87500000000000 0.87500000000000 0.25000000000000 0.00000000000000 0.00000000000000 0.31250000000000 0.12500000000000 0.12500000000000 0.25000000000000 0.00000000000000 0.25000000000000 0.31250000000000 0.12500000000000 0.37500000000000 0.25000000000000 0.00000000000000 0.50000000000000 0.31250000000000 0.12500000000000 0.62500000000000 0.25000000000000 0.00000000000000 0.75000000000000 0.31250000000000 0.12500000000000 0.87500000000000 0.25000000000000 0.25000000000000 0.00000000000000 0.31250000000000 0.37500000000000 0.12500000000000 0.25000000000000 0.25000000000000 0.25000000000000 0.31250000000000 0.37500000000000 0.37500000000000 0.25000000000000 0.25000000000000 0.50000000000000 0.31250000000000 0.37500000000000 0.62500000000000 0.25000000000000 0.25000000000000 0.75000000000000 0.31250000000000 0.37500000000000 0.87500000000000 0.25000000000000 0.50000000000000 0.00000000000000 0.31250000000000 0.62500000000000 0.12500000000000 0.25000000000000 0.50000000000000 0.25000000000000 0.31250000000000 0.62500000000000 0.37500000000000 0.25000000000000 0.50000000000000 0.50000000000000 0.31250000000000 0.62500000000000 0.62500000000000 0.25000000000000 0.50000000000000 0.75000000000000 0.31250000000000 0.62500000000000 0.87500000000000 0.25000000000000 0.75000000000000 0.00000000000000 0.31250000000000 0.87500000000000 0.12500000000000 0.25000000000000 0.75000000000000 0.25000000000000 0.31250000000000 0.87500000000000 0.37500000000000 0.25000000000000 0.75000000000000 0.50000000000000 0.31250000000000 0.87500000000000 0.62500000000000 0.25000000000000 0.75000000000000 0.75000000000000 0.31250000000000 0.87500000000000 0.87500000000000 0.37500000000000 0.00000000000000 0.00000000000000 0.43750000000000 0.12500000000000 0.12500000000000 0.37500000000000 0.00000000000000 0.25000000000000 0.43750000000000 0.12500000000000 0.37500000000000 0.37500000000000 0.00000000000000 0.50000000000000 0.43750000000000 0.12500000000000 0.62500000000000 0.37500000000000 0.00000000000000 0.75000000000000 0.43750000000000 0.12500000000000 0.87500000000000 0.37500000000000 0.25000000000000 0.00000000000000 0.43750000000000 0.37500000000000 0.12500000000000 0.37500000000000 0.25000000000000 0.25000000000000 0.43750000000000 0.37500000000000 0.37500000000000 0.37500000000000 0.25000000000000 0.50000000000000 0.43750000000000 0.37500000000000 0.62500000000000 0.37500000000000 0.25000000000000 0.75000000000000 0.43750000000000 0.37500000000000 0.87500000000000 0.37500000000000 0.50000000000000 0.00000000000000 0.43750000000000 0.62500000000000 0.12500000000000 0.37500000000000 0.50000000000000 0.25000000000000 0.43750000000000 0.62500000000000 0.37500000000000 0.37500000000000 0.50000000000000 0.50000000000000 0.43750000000000 0.62500000000000 0.62500000000000 0.37500000000000 0.50000000000000 0.75000000000000 0.43750000000000 0.62500000000000 0.87500000000000 0.37500000000000 0.75000000000000 0.00000000000000 0.43750000000000 0.87500000000000 0.12500000000000 0.37500000000000 0.75000000000000 0.25000000000000 0.43750000000000 0.87500000000000 0.37500000000000 0.37500000000000 0.75000000000000 0.50000000000000 0.43750000000000 0.87500000000000 0.62500000000000 0.37500000000000 0.75000000000000 0.75000000000000 0.43750000000000 0.87500000000000 0.87500000000000 0.50066333333333 0.43795366666666 0.20604666666667 0.58978833333333 0.17685666666666 0.24527666666667 0.59038833333333 0.04865666666666 0.46713866666667 0.57337833333333 0.36896766666666 0.44071566666667 0.49437333333333 0.29799666666666 0.62702666666667 0.58165333333333 0.34787366666666 0.95079666666667 0.54251333333333 0.10940666666666 0.84782666666667 0.67878919833333 0.40517666666666 0.06963666666667 0.59048833333333 0.45379666666666 0.10264666666667 0.60238833333333 0.47341066666666 0.31733066666667 0.50515833333333 0.27181666666666 0.25024666666667 0.60375833333333 0.54262666666666 0.50900866666667 0.59347833333333 0.44882266666666 0.67936666666667 0.67186083333333 0.62119666666666 0.73076666666667 0.63907933333333 0.58259666666666 0.93075666666667 0.67825691833333 0.39313466666666 0.28615666666667 0.55216833333333 0.64702666666666 0.29008666666667 0.65788433333333 0.66224666666666 0.34085666666667 0.54558333333333 0.70723666666666 0.50473966666667 0.59868333333333 0.84143666666666 0.65086666666667 0.56312333333333 0.65245666666666 0.66560666666667 0.59459833333333 0.74256666666666 0.86209666666667 0.54859333333333 0.64326666666666 0.02438666666667 0.61449833333333 0.84178666666666 0.03484666666667 0.50916333333333 0.81220666666666 0.08581666666667 0.96250333333333 0.00988666666666 0.16680666666667 0.61246833333333 0.84705666666666 0.43006566666667 0.58969333333333 0.24281666666666 0.62900666666667 0.52407833333333 0.87938666666666 0.92985666666667 0.63529633333333 0.04594666666666 0.68961666666667 0.55587333333333 0.04528666666666 0.08935666666667 0.66776783333333 0.01468666666666 0.17755666666667 0.70887233333333 0.20161666666666 0.21002666666667 0.92334333333333 0.16592666666666 0.29334666666667 0.67033283333333 0.01914666666666 0.36823266666667 0.65631933333333 0.21883666666666 0.36941666666667 0.62474833333333 0.22426666666666 0.80279666666667 0.66286883333333 0.41444856666666 0.82225666666667 0.62886383333333 0.18910666666666 0.05475666666667 0.71154233333333 0.27103666666666 0.73880666666667 0.73958333333333 0.15453666666666 0.01370666666667 0.75625833333333 0.64794666666666 0.24326666666667 0.76121333333333 0.28914666666666 0.37663266666667 0.72632283333333 0.51671666666666 0.43261966666667 0.67498088333333 0.39143366666666 0.52916666666667 0.76689333333333 0.74595666666666 0.77130666666667 0.74752333333333 0.55142666666666 0.86622666666667 0.74464333333333 0.55552666666666 0.08736666666667 0.64824733333333 0.59911666666666 0.13674666666667 0.83169333333333 0.97781666666666 0.30673666666667 0.66809783333333 0.72582666666666 0.55477666666667 0.76887333333333 0.70689666666666 0.49468866666667 0.74088833333333 0.56763666666666 0.64551666666667 0.79800333333333 0.77201666666666 0.97858666666667 0.69187333333333 0.74064666666666 0.93339666666667 0.71363633333333 0.95878666666666 0.99392666666667 0.65551333333333 0.83387666666666 0.24756666666667 0.75738333333333 0.99888666666666 0.18068666666667 0.74925833333333 0.84733666666666 0.35821766666667 0.68541433333333 0.90449666666666 0.52917666666667 0.68926733333333 0.85888666666666 0.73183666666667 0.75026333333333 0.06949666666666 0.64433666666667 0.60628833333333 0.97677666666666 0.86873666666667 0.69994983333333 0.07068666666666 0.84985666666667 0.87101333333333 0.05882666666666 0.16847666666667 0.84889333333333 0.41975886666666 0.18471666666667 0.93339833333333 0.98165666666666 0.38450366666667 0.67249083333333 0.17969666666666 0.57686666666667 0.85423833333333 0.10957666666666 0.47681066666667 0.82493333333333 0.49135366666666 0.55000666666667 0.78462333333333 0.29096666666666 0.57421666666667 0.76800333333333 0.36121566666666 0.92644666666667 0.81058333333333 0.16971666666666 0.22684666666667 0.90856333333333 0.57026666666666 0.23815666666667 0.76182833333333 0.37614666666666 0.18845666666667 0.88871833333333 0.53080666666666 0.42358146666667 0.85562833333333 0.32263166666666 0.36426866666667 0.83515833333333 0.59152666666666 0.77291666666667 0.78718833333333 0.38821366666666 0.74611666666667 0.83699333333333 0.68114666666666 0.18497666666667 0.82814333333333 0.73293666666666 0.36987966666667 0.85414333333333 0.87401666666666 0.48911766666667 0.81410333333333 0.50145866666666 0.34903766666667 0.85689833333333 0.67681666666666 0.58823666666667 0.86804333333333 0.78560666666666 0.84977666666667 0.93271333333333 0.57988666666666 0.81896666666667 0.71184083333333 0.77304666666666 0.11347666666667 0.90540833333333 0.74061666666666 0.03022666666667 0.81621333333333 0.85319666666666 0.13512666666667 0.52441333333333 0.08306666666666 0.34711166666667 0.75732333333333 0.03364666666666 0.44157466666667 0.94750833333333 0.01092666666666 0.60645666666667 0.77594833333333 0.83782666666666 0.62102666666667 0.86107833333333 0.04928666666666 0.67310666666667 0.79300333333333 0.97135666666666 0.79084666666667 0.82238833333333 0.01293666666666 0.97004666666667 0.83750833333333 0.23664666666666 0.02062666666667 0.95388333333333 0.34178766666666 0.44811166666667 0.88708833333333 0.27382666666666 0.58093666666667 0.53206333333333 0.20845666666666 0.48642566666667 0.94568833333333 0.16754666666666 0.74426666666667 0.49329333333333 0.31900866666666 0.82460666666667 0.79113333333333 0.15633666666666 0.84792666666667 0.51232833333333 0.25059666666666 0.04522666666667 0.91374333333333 0.47641466666666 0.07637666666667 0.48904333333333 0.52828666666666 0.38552966666667 0.85357333333333 0.27436666666666 0.76343666666667 0.51098333333333 0.49550966666666 0.56943666666667 0.90882833333333 0.41875446666666 0.67028666666667 0.55464333333333 0.52472666666666 0.82758666666667 0.88878333333333 0.39984166666666 0.89648666666667 0.49674833333333 0.46952266666666 0.97251666666667 0.50698333333333 0.81906666666666 0.32010066666667 0.56672333333333 0.96197666666666 0.24366666666667 0.93230333333333 0.73529666666666 0.43107266666667 0.50525833333333 0.82783666666666 0.66778666666667 0.94398833333333 0.65432666666666 0.66346666666667 0.48605333333333 0.74336666666666 0.85736666666667 0.83221333333333 0.55263666666666 0.00047666666667 0.47925833333333 0.63845666666666 0.16634666666667 0.91936333333333 0.84625666666666 0.22666666666667 0.91682333333333 0.28260666666666 0.13265666666667 0.51926833333333 0.92371666666666 0.50915766666667 0.53698833333333 0.07929666666666 0.66035666666667 0.89665333333333 0.84174666666666 0.67481666666667 0.93254833333333 0.97751666666666 0.81711666666667 0.91770833333333 0.93970666666666 0.99482666666667 0.92680333333333 0.14577666666666 0.95922666666667 """, sep=" ").reshape((-1, 3)) # Crystal structure. structure = abilab.Structure.from_abivars( acell=[50.4, 25.2, 25.2], rprim=np.eye(3), typat=256 * [1], znucl=22, xred=xred, ) inp = abilab.AbinitInput(structure, pseudos) inp.set_vars( # SCF algorithm paral_kgb=1, #wfoptalg=1, #fftalg=402, #fftalg-302, # To use FFTW instead of ABINIT FFT # Basis set ecut=5, pawecutdg=10, # SCF cycle tolvrs=1.e-3, nstep=20, # K-Points and symmetries nkpt=2, kpt=[3 * [0.5], [0, 0, 0.5]], kptopt=0, istwfk="*1", nsym=0, chksymbreak=0, chkprim=0, pawovlp=-1, # bands and occupation scheme. nband=2048, occopt=3, tsmear="1800. K", # IO optforces=2, optstress=1, prtwf=0, prtden=0, prteig=0, timopt=-1, ) return inp
def input_scf_si_low(): pseudos = abidata.pseudos("14si.pspnc") cif_file = abidata.cif_file("si.cif") structure = abilab.Structure.from_file(cif_file) return ebands_input(structure, pseudos, kppa=100, ecut=6).split_datasets()[0]
def make_inputs(paw=False): pseudos = abidata.pseudos("56ba.psp_mod", "22ti.psp_mod", "8o.psp_mod") #pseudos = abidata.pseudos("56ba.psp_mod", "22ti.psp_mod", "8o.pspnc") if paw: raise NotImplementedError("PAW") # SLAB ending TiO2 double layer. paralelectric configuration # N=9 # Supercell and atoms xcart = np.fromstring(""" 0.0000000000E+00 0.0000000000E+00 -4.2633349730E+00 3.7794522658E+00 3.7794522658E+00 -3.2803418097E+00 0.0000000000E+00 3.7794522658E+00 -3.6627278067E+00 3.7794522658E+00 0.0000000000E+00 6.5250113947E-01 0.0000000000E+00 3.7794522658E+00 -1.0555036964E-01 3.7794522658E+00 3.7794522658E+00 3.2682166278E-01 0.0000000000E+00 0.0000000000E+00 3.9815918094E+00 3.7794522658E+00 3.7794522658E+00 4.0167907030E+00 3.7794522658E+00 0.0000000000E+00 7.7541444349E+00 0.0000000000E+00 3.7794522658E+00 7.6664087705E+00 3.7794522658E+00 3.7794522658E+00 7.7182324796E+00 0.0000000000E+00 0.0000000000E+00 1.1412913350E+01 3.7794522658E+00 3.7794522658E+00 1.1416615533E+01 3.7794522658E+00 0.0000000000E+00 1.5117809063E+01 0.0000000000E+00 3.7794522658E+00 1.5117809063E+01 3.7794522658E+00 3.7794522658E+00 1.5117809063E+01 0.0000000000E+00 0.0000000000E+00 1.8822704777E+01 3.7794522658E+00 3.7794522658E+00 1.8819002593E+01 3.7794522658E+00 0.0000000000E+00 2.2481473692E+01 0.0000000000E+00 3.7794522658E+00 2.2569209355E+01 3.7794522658E+00 3.7794522658E+00 2.2517385647E+01 0.0000000000E+00 0.0000000000E+00 2.6254026317E+01 3.7794522658E+00 3.7794522658E+00 2.6218827423E+01 3.7794522658E+00 0.0000000000E+00 2.9583116986E+01 0.0000000000E+00 3.7794522658E+00 3.0341168496E+01 3.7794522658E+00 3.7794522658E+00 2.9908796464E+01 0.0000000000E+00 0.0000000000E+00 3.4498953099E+01 3.7794522658E+00 3.7794522658E+00 3.3515959935E+01 0.0000000000E+00 3.7794522658E+00 3.3898345933E+01 """, sep=" ").reshape((-1, 3)) # Crystal structure. structure = abilab.Structure.from_abivars( #acell="4.0 4.0 28.0 Angstrom", acell=abilab.ArrayWithUnit([4.0, 4.0, 28], "ang").to("bohr"), rprim=np.eye(3), typat=[ int(i) for i in "3 3 2 3 3 2 1 3 3 3 2 1 3 3 3 2 1 3 3 3 2 1 3 3 3 2 3 3 2".split( ) ], znucl=[56, 22, 8], xcart=xcart, ) multi = abilab.MultiDataset(structure, pseudos, ndtset=2) # Global variables used both for the GS and the DFPT run. multi.set_vars( #electronic structure nband=120, ecut=15.0, pawecutdg=30.0 if paw else None, nstep=80, ngkpt=[4, 4, 1], shiftk=[0, 0, 0], paral_kgb=1, timopt=-1, prtden=0, ) gs_inp, ph_inp = multi.split_datasets() gs_inp.set_vars(tolvrs=1e-6, kptopt=1) ph_inp.set_vars( kptopt=3, rfphon=1, irdwfk=1, rfatpol=[1, 1], rfdir=[0, 0, 1], nqpt=1, qpt=[0.0, 0.25, 0.0], prtwf=0, #tolwfr=1.0e-22, toldfe=1.0e-9, tolrde= 0.0, # This is a development input variable, used in the present case to avoid load unbalance # when studying the scaling with respect to the number of cores. Do not define it in # your production runs ) return gs_inp, ph_inp
def test_utils(self): """Test utilities for the generation of Abinit inputs.""" # Test as_structure and from/to abivars si = Structure.as_structure(abidata.cif_file("si.cif")) assert si.formula == "Si2" assert si.abi_spacegroup is None and not si.has_abi_spacegroup assert "ntypat" in si.to(fmt="abivars") spgroup = si.spgset_abi_spacegroup(has_timerev=True) assert spgroup is not None assert si.has_abi_spacegroup assert si.abi_spacegroup.spgid == 227 with self.assertRaises(TypeError): Structure.as_structure({}) with self.assertRaises(TypeError): Structure.as_structure([]) si_wfk = Structure.as_structure(abidata.ref_file("si_scf_WFK.nc")) assert si_wfk.formula == "Si2" si_wfk.print_neighbors(radius=2.5) assert si_wfk.has_abi_spacegroup # Cannot change spacegroup with self.assertRaises(ValueError): si_wfk.spgset_abi_spacegroup(has_timerev=True) # TODO: Fix order of atoms in supercells. # Test __mul__, __rmul__ (should return Abipy structures) assert si_wfk == 1 * si_wfk supcell = si_wfk * [2, 2, 2] assert len(supcell) == 8 * len(si_wfk) and hasattr(supcell, "abi_string") si_abi = Structure.from_file(abidata.ref_file("refs/si_ebands/run.abi")) assert si_abi.formula == "Si2" self.assert_equal(si_abi.frac_coords, [[0, 0, 0], [0.25, 0.25, 0.25]]) si_abo = Structure.from_file(abidata.ref_file("refs/si_ebands/run.abo")) assert si_abo == si_abi assert "ntypat" in si_abi.to(fmt="abivars") znse = Structure.from_file(abidata.ref_file("refs/znse_phonons/ZnSe_hex_qpt_DDB")) assert len(znse) == 4 assert znse.formula == "Zn2 Se2" self.assert_almost_equal(znse.frac_coords.flat, [ 0.33333333333333, 0.66666666666667, 0.99962203020000, 0.66666666666667, 0.33333333333333, 0.49962203020000, 0.33333333333333, 0.66666666666667, 0.62537796980000, 0.66666666666667, 0.33333333333333, 0.12537796980000]) from abipy.core.structure import diff_structures diff_structures([si_abi, znse], headers=["si_abi", "znse"], fmt="abivars", mode="table") diff_structures([si_abi, znse], headers=["si_abi", "znse"], fmt="abivars", mode="diff") # From pickle file. import pickle tmp_path = self.get_tmpname(suffix=".pickle") with open(tmp_path, "wb") as fh: pickle.dump(znse, fh) same_znse = Structure.from_file(tmp_path) assert same_znse == znse same_znse = Structure.as_structure(tmp_path) assert same_znse == znse for fmt in ["abivars", "cif", "POSCAR", "json", "xsf", "qe"]: assert len(znse.convert(fmt=fmt)) > 0 oxi_znse = znse.get_oxi_state_decorated() assert len(oxi_znse.abi_string) from pymatgen.core.periodic_table import Specie assert Specie("Zn", 2) in oxi_znse.composition.elements assert Specie("Se", -2) in oxi_znse.composition.elements system = si.spget_lattice_type() assert system == "cubic" e = si.spget_equivalent_atoms(printout=True) assert len(e.irred_pos) == 1 self.assert_equal(e.eqmap[0], [0, 1]) for irr_pos in e.irred_pos: assert len(e.eqmap[irr_pos]) > 0 assert "equivalent_atoms" in e.spgdata if self.has_matplotlib(): assert si.plot_bz(show=False) assert si.plot_bz(pmg_path=False, show=False) assert si.plot(show=False) if sys.version[0:3] > '2.7': # pmg broke py compatibility assert si.plot_xrd(show=False) if self.has_mayavi(): #assert si.vtkview(show=False) # Disabled due to (core dumped) on travis assert si.mayaview(show=False) assert si is Structure.as_structure(si) assert si == Structure.as_structure(si.to_abivars()) assert si == Structure.from_abivars(si.to_abivars()) assert len(si.abi_string) assert si.reciprocal_lattice == si.lattice.reciprocal_lattice kptbounds = si.calc_kptbounds() ksamp = si.calc_ksampling(nksmall=10) shiftk = [[ 0.5, 0.5, 0.5], [ 0.5, 0. , 0. ], [ 0. , 0.5, 0. ], [ 0. , 0. , 0.5]] self.assert_equal(si.calc_ngkpt(nksmall=2), [2, 2, 2]) self.assert_equal(si.calc_shiftk(), shiftk) self.assert_equal(ksamp.ngkpt, [10, 10, 10]) self.assert_equal(ksamp.shiftk, shiftk) si = Structure.from_mpid("mp-149") assert si.formula == "Si2" mgb2_cod = Structure.from_cod_id(1526507, primitive=True) assert mgb2_cod.formula == "Mg1 B2" assert mgb2_cod.spget_lattice_type() == "hexagonal" mgb2 = abidata.structure_from_ucell("MgB2") if self.has_ase(): mgb2.abi_primitive() assert [site.species_string for site in mgb2.get_sorted_structure_z()] == ["B", "B", "Mg"] s2inds = mgb2.get_symbol2indices() self.assert_equal(s2inds["Mg"], [0]) self.assert_equal(s2inds["B"], [1, 2]) s2coords = mgb2.get_symbol2coords() self.assert_equal(s2coords["Mg"], [[0, 0, 0]]) self.assert_equal(s2coords["B"], [[1/3, 2/3, 0.5], [2/3, 1/3, 0.5]]) # TODO: This part should be tested more carefully mgb2.abi_sanitize() mgb2.abi_sanitize(primitive_standard=True) mgb2.get_conventional_standard_structure() assert len(mgb2.abi_string) assert len(mgb2.spget_summary(verbose=10)) #print(structure._repr_html_()) self.serialize_with_pickle(mgb2) pseudos = abidata.pseudos("12mg.pspnc", "5b.pspnc") nv = mgb2.num_valence_electrons(pseudos) assert nv == 8 and isinstance(nv , int) assert mgb2.valence_electrons_per_atom(pseudos) == [2, 3, 3] self.assert_equal(mgb2.calc_shiftk() , [[0.0, 0.0, 0.5]]) bmol = Structure.boxed_molecule(pseudos, cart_coords=[[0, 0, 0], [5, 5, 5]], acell=[10, 10, 10]) self.assert_almost_equal(bmol.volume, (10 * bohr_to_ang) ** 3) # FIXME This is buggy #acell = np.array([10, 20, 30]) #batom = Structure.boxed_atom(abidata.pseudo("12mg.pspnc"), cart_coords=[1, 2, 3], acell=acell) #assert isinstance(batom, Structure) #assert len(batom.cart_coords) == 1 #self.assert_equal(batom.cart_coords[0], [1, 2, 3]) # Function to compute cubic a0 from primitive v0 (depends on struct_type) vol2a = {"fcc": lambda vol: (4 * vol) ** (1/3.), "bcc": lambda vol: (2 * vol) ** (1/3.), "zincblende": lambda vol: (4 * vol) ** (1/3.), "rocksalt": lambda vol: (4 * vol) ** (1/3.), "ABO3": lambda vol: vol ** (1/3.), "hH": lambda vol: (4 * vol) ** (1/3.), } a = 10 bcc_prim = Structure.bcc(a, ["Si"], primitive=True) assert len(bcc_prim) == 1 self.assert_almost_equal(a, vol2a["bcc"](bcc_prim.volume)) bcc_conv = Structure.bcc(a, ["Si"], primitive=False) assert len(bcc_conv) == 2 self.assert_almost_equal(a**3, bcc_conv.volume) fcc_prim = Structure.fcc(a, ["Si"], primitive=True) assert len(fcc_prim) == 1 self.assert_almost_equal(a, vol2a["fcc"](fcc_prim.volume)) fcc_conv = Structure.fcc(a, ["Si"], primitive=False) assert len(fcc_conv) == 4 self.assert_almost_equal(a**3, fcc_conv.volume) zns = Structure.zincblende(a / bohr_to_ang, ["Zn", "S"], units="bohr") self.assert_almost_equal(a, vol2a["zincblende"](zns.volume)) rock = Structure.rocksalt(a, ["Na", "Cl"]) assert len(rock) == 2 self.assert_almost_equal(a, vol2a["rocksalt"](rock.volume)) perov = Structure.ABO3(a, ["Ca", "Ti", "O", "O", "O"]) assert len(perov) == 5 self.assert_almost_equal(a**3, perov.volume) # Test notebook generation. if self.has_nbformat(): mgb2.write_notebook(nbpath=self.get_tmpname(text=True))
def setUpClass(cls): cls.gan_structure = abilab.Structure.from_file(abidata.cif_file("gan.cif")) cls.gan_pseudos = [abidata.pseudos("31ga.pspnc").pseudo_with_symbol('Ga'), abidata.pseudos("7n.pspnc").pseudo_with_symbol('N')]
def itest_phonopy_gruneisen_flow(fwp, tvars): """ Testing phonopy Gruneisen flow with the scheduler. """ if not has_phonopy(): raise unittest.SkipTest("This test requires phonopy") #print("tvars:\n %s" % str(tvars)) si_structure = abidata.structure_from_cif("si.cif") gsinp = gs_input(si_structure, pseudos=abidata.pseudos("14si.pspnc"), kppa=10, ecut=2, spin_mode="unpolarized") gsinp["paral_kgb"] = tvars.paral_kgb flow = flowtk.Flow(workdir=fwp.workdir, manager=fwp.manager) scdims = [2, 2, 2] # Grunesein with phonopy grun_work = abiph.PhonopyGruneisenWork.from_gs_input(gsinp, voldelta=0.1, scdims=scdims, phonopy_kwargs=None, displ_kwargs=None) flow.register_work(grun_work) assert len(grun_work) == 3 nptu.assert_equal(scdims, grun_work.scdims) # Will remove output files (WFK) flow.set_garbage_collector() flow.use_smartio() flow.build_and_pickle_dump(abivalidate=True) scheduler = flow.make_scheduler() assert scheduler.start() == 0 assert not scheduler.exceptions flow.show_status() if not flow.all_ok: flow.debug() raise RuntimeError() # Initialial work + 3 phonopy works. assert len(flow) == 4 assert all(work.finalized for work in flow) # The WFK files should have been removed because we called set_garbage_collector # FIXME: This does not work because new works that have been created. #for task in flow.iflat_tasks(): # assert not task.outdir.has_abiext("WFK") for work in flow[1:]: out_filenames = set( [os.path.basename(f) for f in work.outdir.list_filepaths()]) nmiss = 0 for f in [ "POSCAR", "disp.yaml", "FORCE_SETS", "band.conf", "dos.conf", "band-dos.conf", "README.md" ]: if f not in out_filenames: nmiss += 1 print("Cannot find %s in work.outdir" % f) assert nmiss == 0
def test_dfpt_methods(self): """Testing DFPT methods.""" gs_inp = AbinitInput(structure=abidata.structure_from_ucell("AlAs"), pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc")) gs_inp.set_vars( nband=4, ecut=2, ngkpt=[4, 4, 4], nshiftk=4, shiftk=[ 0.0, 0.0, 0.5, # This gives the usual fcc Monkhorst-Pack grid 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.5 ], #shiftk=[0, 0, 0], paral_kgb=1, nstep=25, tolvrs=1.0e-10, ) ################ # Phonon methods ################ with self.assertRaises(gs_inp.Error): ddk_inputs = gs_inp.make_ddk_inputs(tolerance={"tolfoo": 1e10}) phg_inputs = gs_inp.make_ph_inputs_qpoint(qpt=(0, 0, 0), tolerance=None) print("phonon inputs at Gamma\n", phg_inputs) assert len(phg_inputs) == 2 assert np.all(phg_inputs[0]["rfatpol"] == [1, 1]) assert np.all(phg_inputs[1]["rfatpol"] == [2, 2]) assert all(np.all(inp["rfdir"] == [1, 0, 0] for inp in phg_inputs)) assert all(np.all(inp["kptopt"] == 2 for inp in phg_inputs)) # Validate vs = phg_inputs.abivalidate() assert all(v.retcode == 0 for v in vs) ############# # DDK methods ############# with self.assertRaises(gs_inp.Error): ddk_inputs = gs_inp.make_ddk_inputs(tolerance={"tolvrs": 1e10}) ddk_inputs = gs_inp.make_ddk_inputs(tolerance=None) print("DDK inputs\n", ddk_inputs) assert len(ddk_inputs) == 3 assert all(inp["iscf"] == -3 for inp in ddk_inputs) assert all(inp["rfelfd"] == 2 for inp in ddk_inputs) # Validate vs = ddk_inputs.abivalidate() assert all(v.retcode == 0 for v in vs) ################# # Strain methods ################# strain_inputs = gs_inp.make_strain_perts_inputs(tolerance=None) print("STRAIN inputs\n", strain_inputs) assert all(inp["tolvrs"] == 1e-12 for inp in strain_inputs) vs = strain_inputs.abivalidate() assert all(v.retcode == 0 for v in vs)
def build_flow(options): # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") if not options.workdir: options.workdir = os.path.basename(__file__).replace( ".py", "").replace("run_", "flow_") # Preparatory run for E-PH calculations. # The sequence of datasets makes the ground states and # all of the independent perturbations of the single Al atom # for the irreducible qpoints in a 4x4x4 grid. # Note that the q-point grid must be a sub-grid of the k-point grid (here 8x8x8) pseudos = abidata.pseudos("Al.oncvpsp") structure = abilab.Structure.from_abivars( acell=3 * [7.5], rprim=[0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0], typat=1, xred=[0.0, 0.0, 0.0], ntypat=1, znucl=13, ) same_structure = abilab.Structure.fcc(a=7.5, species=["Al"], units="bohr") assert same_structure == structure gs_inp = abilab.AbinitInput(structure, pseudos) gs_inp.set_vars( istwfk="*1", ecut=8.0, nband=5, occopt=7, # include metallic occupation function with a small smearing tsmear=0.04, tolvrs=1e-7, #timeopt=-1, ) # The kpoint grid is minimalistic to keep the calculation manageable. gs_inp.set_kmesh( ngkpt=[8, 8, 8], shiftk=[0.0, 0.0, 0.0], #kptopt=3, ) # Phonon calculation with 4x4x4 ddb_ngqpt = [4, 4, 4] qpoints = gs_inp.abiget_ibz(ngkpt=ddb_ngqpt, shiftk=[0, 0, 0], kptopt=1).points flow = flowtk.Flow(options.workdir, manager=options.manager) work0 = flow.register_scf_task(gs_inp) ph_work = flowtk.PhononWork.from_scf_task(work0[0], qpoints) flow.register_work(ph_work) eph_work = flow.register_work(flowtk.Work()) eph_deps = {work0[0]: "WFK", ph_work: ["DDB", "DVDB"]} for eph_ngqpt_fine in [( 4, 4, 4, ), (8, 8, 8)]: # Build input file for E-PH run. eph_inp = gs_inp.new_with_vars( optdriver=7, ddb_ngqpt= ddb_ngqpt, # q-mesh used to produce the DDB file (must be consistent with DDB data) eph_intmeth=2, # Tetra method eph_fsewin="0.8 eV", # Energy window around Ef eph_mustar=0.12, # mustar parameter eph_ngqpt_fine= eph_ngqpt_fine, # Interpolate DFPT potentials if != ddb_ngqpt ) # Set q-path for phonons and phonon linewidths. eph_inp.set_qpath(20) # TODO: Define wstep and smear # Set q-mesh for phonons DOS and a2F(w) eph_inp.set_phdos_qmesh(nqsmall=16, method="tetra") eph_work.register_eph_task(eph_inp, deps=eph_deps) flow.allocate(use_smartio=True) return flow
def scf_ph_inputs(paral_kgb=0): """ This function constructs the input files for the phonon calculation: GS input + the input files for the phonon calculation. """ # Crystalline AlAs: computation of the second derivative of the total energy structure = abidata.structure_from_ucell("AlAs") pseudos = abidata.pseudos("13al.981214.fhi", "33as.pspnc") # List of q-points for the phonon calculation. qpoints = [ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, ] qpoints = np.reshape(qpoints, (-1, 3)) # Global variables used both for the GS and the DFPT run. global_vars = dict( nband=4, ecut=2.0, ngkpt=[4, 4, 4], nshiftk=4, shiftk=[ 0.0, 0.0, 0.5, # This gives the usual fcc Monkhorst-Pack grid 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.5 ], #shiftk=[0, 0, 0], paral_kgb=paral_kgb, ixc=1, nstep=25, diemac=9.0, ) gs_inp = abilab.AbinitInput(structure, pseudos=pseudos) gs_inp.set_vars(global_vars) gs_inp.set_vars(tolvrs=1.0e-18) # Get the qpoints in the IBZ. Note that here we use a q-mesh with ngkpt=(4,4,4) and shiftk=(0,0,0) # i.e. the same parameters used for the k-mesh in gs_inp. qpoints = gs_inp.abiget_ibz(ngkpt=(4, 4, 4), shiftk=(0, 0, 0), kptopt=1).points print("get_ibz", qpoints) ph_inputs = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=len(qpoints)) for ph_inp, qpt in zip(ph_inputs, qpoints): # Response-function calculation for phonons. ph_inp.set_vars(global_vars) ph_inp.set_vars( rfphon=1, # Will consider phonon-type perturbation nqpt=1, # One wavevector is to be considered qpt=qpt, # This wavevector is q=0 (Gamma) tolwfr=1.0e-20, kptopt=3, #nstep=4, # This is to trigger the restart. ) #rfatpol 1 1 # Only the first atom is displaced #rfdir 1 0 0 # Along the first reduced coordinate axis #kptopt 2 # Automatic generation of k points, taking # Split input into gs_inp and ph_inputs all_inps = [gs_inp] all_inps.extend(ph_inputs.split_datasets()) return all_inps
def setUpClass(cls): cls.si_structure = abilab.Structure.from_file(abidata.cif_file("si.cif")) cls.scf_inp = scf_input(cls.si_structure, abidata.pseudos("14si.pspnc"), ecut=2, kppa=10) cls.setup_fireworks()
def test_api(self): """Test AbinitInput API.""" # Build simple input with structure and pseudos unit_cell = { "acell": 3 * [10.217], 'rprim': [[.0, .5, .5], [.5, .0, .5], [.5, .5, .0]], 'ntypat': 1, 'znucl': [ 14, ], 'natom': 2, 'typat': [1, 1], 'xred': [[.0, .0, .0], [.25, .25, .25]] } inp = AbinitInput(structure=unit_cell, pseudos=abidata.pseudos("14si.pspnc")) print(repr(inp)) assert len(inp) == 0 and not inp assert inp.get("foo", "bar") == "bar" and inp.pop("foo", "bar") == "bar" assert inp.comment is None inp.set_comment("This is a comment") assert inp.comment == "This is a comment" assert inp.isnc and not inp.ispaw assert not inp.decorators assert len(inp.structure) == 2 and inp.num_valence_electrons == 8 # foo is not a valid Abinit variable with self.assertRaises(inp.Error): inp["foo"] = 1 inp["ecut"] = 1 assert inp.get("ecut") == 1 and len( inp) == 1 and "ecut" in inp.keys() and "foo" not in inp assert inp.mnemonics == False inp.set_mnemonics(True) assert inp.mnemonics == True # Test to_string inp.to_string(sortmode="a", with_structure=True, with_pseudos=True) inp.to_string(sortmode="section", with_structure=True, with_pseudos=True) inp.set_vars(ecut=5, toldfe=1e-6) assert inp["ecut"] == 5 inp.set_vars_ifnotin(ecut=-10) assert inp["ecut"] == 5 _, tmp_file = tempfile.mkstemp() inp.write(filepath=tmp_file) # Cannot change structure variables directly. with self.assertRaises(inp.Error): inp.set_vars(unit_cell) # Test deepcopy and remove_vars. inp["bdgw"] = [1, 2] inp_copy = inp.deepcopy() inp_copy["bdgw"][1] = 3 assert inp["bdgw"] == [1, 2] assert inp.remove_vars("bdgw") and "bdgw" not in inp removed = inp.pop_tolerances() assert len(removed) == 1 and removed["toldfe"] == 1e-6 # Test set_spin_mode old_vars = inp.set_spin_mode("polarized") assert "nsppol" in inp and inp["nspden"] == 2 and inp["nspinor"] == 1 inp.set_vars(old_vars) # Test set_structure new_structure = inp.structure.copy() new_structure.perturb(distance=0.1) inp.set_structure(new_structure) assert inp.structure == new_structure # Compatible with Pickle and MSONable? self.serialize_with_pickle(inp, test_eq=False) self.assertMSONable(inp) # Test tags assert isinstance(inp.tags, set) assert len(inp.tags) == 0 inp.add_tags([GROUND_STATE, SCF]) assert len(inp.tags) == 2 inp.remove_tags([GROUND_STATE]) assert len(inp.tags) == 1
def build_flow(options, paral_kgb=0): """ Build flow for the calculation of optical properties with optic + band structure along high-symmetry k-path. DDK are computed with 3 k-meshes of increasing density to monitor the convergece of the spectra. """ # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") if not options.workdir: options.workdir = os.path.basename(sys.argv[0]).replace( ".py", "").replace("run_", "flow_") multi = abilab.MultiDataset(structure=abidata.structure_from_ucell("GaAs"), pseudos=abidata.pseudos( "31ga.pspnc", "33as.pspnc"), ndtset=2) # Usa same shifts in all tasks. 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]] # Global variables. multi.set_vars(ecut=2, paral_kgb=paral_kgb) # Dataset 1 (GS run) multi[0].set_vars(tolvrs=1e-8, nband=4) multi[0].set_kmesh(ngkpt=[4, 4, 4], shiftk=shiftk) # NSCF run on k-path with large number of bands multi[1].set_vars(iscf=-2, nband=20, tolwfr=1.e-9) multi[1].set_kpath(ndivsm=10) # Initialize the flow. flow = flowtk.Flow(options.workdir, manager=options.manager) # GS to get the density + NSCF along the path. scf_inp, nscf_inp = multi.split_datasets() bands_work = flowtk.BandStructureWork(scf_inp, nscf_inp) flow.register_work(bands_work) # Build OpticInput used to compute optical properties. optic_input = abilab.OpticInput( broadening=0.002, # Value of the smearing factor, in Hartree domega=0.0003, # Frequency mesh. maxomega=0.3, scissor=0.000, # Scissor shift if needed, in Hartree tolerance=0.002, # Tolerance on closeness of singularities (in Hartree) num_lin_comp= 2, # Number of components of linear optic tensor to be computed lin_comp=(11, 33), # Linear coefficients to be computed (x=1, y=2, z=3) num_nonlin_comp= 2, # Number of components of nonlinear optic tensor to be computed nonlin_comp=(123, 222), # Non-linear coefficients to be computed ) # ddk_nband is fixed here, in principle it depends on nelect and the frequency range in chi(w). ddk_nband = 20 # Perform converge study wrt ngkpt (shiftk is constant). ngkpt_convergence = [[4, 4, 4], [8, 8, 8], [16, 16, 16]] from abipy.flowtk.dfpt_works import NscfDdksWork for ddk_ngkpt in ngkpt_convergence: # Build work for NSCF from DEN produced by the first GS task + 3 DDKs. # All tasks use more bands and a denser k-mesh defined by ddk_ngkpt. ddks_work = NscfDdksWork.from_scf_task(bands_work[0], ddk_ngkpt, shiftk, ddk_nband) flow.register_work(ddks_work) # Build optic task to compute chi with this value of ddk_ngkpt. optic_task = flowtk.OpticTask( optic_input, nscf_node=ddks_work.task_with_ks_energies, ddk_nodes=ddks_work.ddk_tasks, use_ddknc=False) ddks_work.register_task(optic_task) return flow
def make_inputs(ngkpt, dos_ngkpt=(6, 6, 6), paral_kgb=0): """ Crystalline silicon: calculation of the G0W0 band structure with the scissors operator. Args: ngkpt: list of 3 integers. Abinit variable defining the k-point sampling. dos_ngkpt: list of 3 integers. k-point sampling for DOS. paral_kgb: Option used to select the eigensolver in the GS part. Return: Six AbinitInput objects: [0]: Ground state run to get the density. [1]: NSCF run to get the KS band structure on a high-symmetry k-path. [2]: NSCF run with a homogeneous sampling of the BZ to compute the KS DOS with `dos_ngkpt`. [3]: NSCF run with empty states to prepare the GW steps. [4]: Calculation of the screening from the WFK file computed in dataset 4. [5]: Use the SCR file computed at step 5 and the WFK file computed in dataset 4 to get the GW corrections. """ multi = abilab.MultiDataset(abidata.cif_file("si.cif"), pseudos=abidata.pseudos("14si.pspnc"), ndtset=6) # Add mnemonics to input file. multi.set_mnemonics(True) # This grid is the most economical and we will use it for the GS. # Note that it does not contain Gamma point so we cannot use it to # compute the QP corrections at the Gamma point. scf_kmesh = dict( ngkpt=ngkpt, 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] ) # k-point sampling for DOS (gamma-centered) dos_kmesh = dict( ngkpt=dos_ngkpt, shiftk=[0.0, 0.0, 0.0]) # This grid contains the Gamma point, which is the point at which # we will compute the (direct) band gap. gw_kmesh = dict( ngkpt=ngkpt, shiftk=[0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0] ) # Global variables ecut = 6 multi.set_vars( ecut=ecut, istwfk="*1", paral_kgb=paral_kgb, gwpara=2, ) # Dataset 1 (GS run to get the density) multi[0].set_kmesh(**scf_kmesh) multi[0].set_vars( tolvrs=1e-6, nband=4, ) multi[0].set_kmesh(**scf_kmesh) # Dataset 2 (NSCF run with k-path) multi[1].set_vars(iscf=-2, tolwfr=1e-12, nband=8, ) multi[1].set_kpath(ndivsm=8) # Dataset 3 (DOS NSCF) multi[2].set_vars(iscf=-2, tolwfr=1e-12, nband=8, ) multi[2].set_kmesh(**dos_kmesh) # Dataset 4 (NSCF run to produce WFK for GW, note the presence of empty states) multi[3].set_vars(iscf=-2, tolwfr=1e-12, nband=35, ) multi[3].set_kmesh(**gw_kmesh) # Dataset3: Calculation of the screening. multi[4].set_vars( optdriver=3, nband=25, ecutwfn=ecut, symchi=1, inclvkb=0, # Disable [Vnl, r] contribution for q --> 0 ecuteps=4.0, ) multi[4].set_kmesh(**gw_kmesh) multi[5].set_vars( optdriver=4, nband=10, ecutwfn=ecut, ecuteps=4.0, ecutsigx=6.0, symsigma=1, gw_qprange=-4, # Compute GW corrections for all kpts in IBZ, # all occupied states and 4 empty states, ) multi[5].set_kmesh(**gw_kmesh) return multi.split_datasets()
def make_base_flow(options): multi = abilab.MultiDataset(structure=data.structure_from_ucell("GaAs"), pseudos=data.pseudos("31ga.pspnc", "33as.pspnc"), ndtset=5) # Global variables kmesh = dict(ngkpt=[4, 4, 4], nshiftk=4, 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]]) paral_kgb = 1 global_vars = dict(ecut=2, paral_kgb=paral_kgb) global_vars.update(kmesh) multi.set_vars(global_vars) # Dataset 1 (GS run) multi[0].set_vars( tolvrs=1e-6, nband=4, ) # NSCF run with large number of bands, and points in the the full BZ multi[1].set_vars( iscf=-2, nband=20, nstep=25, kptopt=1, tolwfr=1.e-9, #kptopt=3, ) # Fourth dataset: ddk response function along axis 1 # Fifth dataset: ddk response function along axis 2 # Sixth dataset: ddk response function along axis 3 for dir in range(3): rfdir = 3 * [0] rfdir[dir] = 1 multi[2 + dir].set_vars( iscf=-3, nband=20, nstep=1, nline=0, prtwf=3, kptopt=3, nqpt=1, qpt=[0.0, 0.0, 0.0], rfdir=rfdir, rfelfd=2, tolwfr=1.e-9, ) scf_inp, nscf_inp, ddk1, ddk2, ddk3 = multi.split_datasets() # Initialize the flow. flow = BenchmarkFlow(workdir=options.get_workdir(__file__), remove=options.manager) bands_work = flowtk.BandStructureWork(scf_inp, nscf_inp) flow.register_work(bands_work) flow.exclude_from_benchmark(bands_work) ddk_work = flowtk.Work() for inp in [ddk1, ddk2, ddk3]: ddk_work.register_ddk_task(inp, deps={bands_work.nscf_task: "WFK"}) flow.register_work(ddk_work) flow.exclude_from_benchmark(ddk_work) return flow
def make_input(): # pragma: no cover """ """ pseudos = abidata.pseudos("8o_hard.paw", "7n.paw", "1h.paw") # Crystal structure and definition of the path xangst = np.fromstring(""" 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 -3.7593832509E-01 -2.8581911534E-01 8.7109635973E-01 -3.8439081179E-01 8.6764073738E-01 -2.8530130333E-01 4.0000000000E+00 0.0000000000E+00 0.0000000000E+00 4.3461703447E+00 -9.9808458269E-02 -9.5466143436E-01 4.3190273240E+00 -7.8675247603E-01 5.6699786920E-01 4.3411410402E+00 8.7383785043E-01 4.0224838603E-01 1.0280313162E+00 2.2598784215E-02 1.5561763093E-02""", sep=" ").reshape((-1, 3)) xangst_lastimg = np.fromstring(""" 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 -3.0400286349E-01 -1.9039526061E-01 9.0873550186E-01 -3.2251946581E-01 9.0284480687E-01 -1.8824324581E-01 4.0000000000E+00 0.0000000000E+00 0.0000000000E+00 4.4876385468E+00 -1.4925704575E-01 -8.9716581956E-01 4.2142401901E+00 -7.8694929117E-01 6.3097154506E-01 4.3498225718E+00 8.7106686509E-01 4.2709343135E-01 2.9570301511E+00 5.5992672027E-02 -1.3560839453E-01""", sep=" ").reshape((-1, 3)) structure = abilab.Structure.from_abivars( acell=abilab.ArrayWithUnit([10, 5, 5], "ang").to("bohr"), rprim=np.eye(3), typat=[1, 3, 3, 2, 3, 3, 3, 3], # Type of atoms (H2O + NH3 + H) znucl=[8.0, 7.0, 1.0], xangst=xangst, ) inp = abilab.AbinitInput(structure, pseudos) inp.set_vars( # Options for parallelism paral_kgb=1, # Input/output options prtwf=0, prtden=0, prteig=0, prtdensph=0, timopt=-1, # Convergence parameters ecut=20., pawecutdg=40., # Control of the relaxation # TO BE SUPPRESSED WHEN USING IMGMOV keyword #ionmov 3 # BFGS (Broyden) algorithm for ions relaxation #optcell 0 # No cell optimization #ntime 20 # Max. number of "time" steps #tolmxf 5.0d-5 # Stopping criterion of relaxation cycle # Control of the SCF cycle toldff=5.0e-7, nstep=50, # Electronic configuration nband=10, occopt=1, ixc="-001009", # Select LDA XC functional (LDA PZ from LibXC) # BZ sampling kptopt=0, # Scheme for k-points generation nkpt=1, kpt=3 * [0.], # Explicit k-point (gamma point) nsym=1, # No symmetry natfix=2, iatfix=[1, 4], # Keep O and N atoms fixed charge=1.0, # Charge of the simulation cell # IMAGE section. nimage=12, # Number of points along the string imgmov=2, # Selection of "String Method" algo ntimimage=50, # Max. number of relaxation steps of the string tolimg= 0.0001, # Tol. criterion (will stop when average energy of cells < tolimg) dynimage="0 10*1 0", # Keep first and last images fixed fxcartfactor=1.0, # Time step for evolution step of string method. prtvolimg=2, # Printing volume (0=full, 1=intermediate, 2=minimal) xangst_lastimg=xangst_lastimg, ) return inp
def make_flow_ephinp(options): # Preparatory run for E-PH calculations. # The sequence of datasets makes the ground states and # all of the independent perturbations of the single Al atom # for the irreducible qpoints in a 4x4x4 grid. # Note that the q-point grid must be a sub-grid of the k-point grid (here 8x8x8) pseudos = abidata.pseudos("Al.oncvpsp") if not options.paw else \ abidata.pseudos("Al.GGA_PBE-JTH-paw.xml") structure = abilab.Structure.from_abivars( acell=3*[7.5], rprim=[0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0], typat=1, xred=[0.0, 0.0, 0.0], ntypat=1, znucl=13, ) gs_inp = abilab.AbinitInput(structure, pseudos) gs_inp.set_vars( nsppol=1, prtpot=1, istwfk="*1", ecut=12.0, nband=5, occopt=7, # include metallic occupation function with a small smearing tsmear=0.04, tolvrs=1e-7, timopt=-1, ) # The kpoint grid is minimalistic to keep the calculation manageable. gs_inp.set_kmesh( ngkpt=[8, 8, 8], kptopt=3, shiftk=[0.0, 0.0, 0.0], ) # Phonon calculation with 4x4x4 qpoints = np.reshape([ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 2.50000000e-01, 0.00000000e+00, 0.00000000e+00, 5.00000000e-01, 0.00000000e+00, 0.00000000e+00, 2.50000000e-01, 2.50000000e-01, 0.00000000e+00, 5.00000000e-01, 2.50000000e-01, 0.00000000e+00, -2.50000000e-01, 2.50000000e-01, 0.00000000e+00, 5.00000000e-01, 5.00000000e-01, 0.00000000e+00, -2.50000000e-01, 5.00000000e-01, 2.50000000e-01, ], (-1,3)) flow = BenchmarkFlow(workdir=options.get_workdir(__file__), remove=options.remove) work0 = flow.register_task(gs_inp, task_class=abilab.ScfTask) flow.exclude_from_benchmark(work0) ph_work = abilab.PhononWork.from_scf_task(work0[0], qpoints) flow.register_work(ph_work) flow.exclude_from_benchmark(ph_work) # Build input file for E-PH run. eph_inp = gs_inp.new_with_vars( optdriver=7, #ddb_ngqpt=[1, 1, 1], # q-mesh used to produce the DDB file (must be consisten with DDB data) ddb_ngqpt=[4, 4, 4], # q-mesh used to produce the DDB file (must be consisten with DDB data) eph_intmeth=2, # Tetra eph_fsewin="0.8 eV", # Energy window around Ef eph_mustar=0.12, # mustar parameter # q-path for phonons and phonon linewidths. ph_ndivsm=20, ph_nqpath=3, ph_qpath= [ 0 , 0 , 0, 0.5, 0 , 0, 0.5, 0.5, 0,], # phonon DOS obtained via Fourier interpolation ph_intmeth=2, # Tetra for phonon DOS and A2F ph_smear="0.001 eV", ph_wstep="0.0001 eV", ph_ngqpt=[16, 16, 16], # q-mesh for Fourier interpolatation of IFC and a2F(w) ph_nqshift=1, ph_qshift=[0, 0, 0], ) return flow, eph_inp