def test_bool(): from pickle import loads, dumps from pylada.vasp import Vasp a = Vasp() assert a._input['addgrid'].keyword == 'addgrid' assert a._input['addgrid'].output_map() is None assert a.addgrid is None a.addgrid = False assert a.addgrid is False assert 'addgrid' in a._input['addgrid'].output_map() assert a._input['addgrid'].output_map()['addgrid'] == '.FALSE.' a.addgrid = True assert a.addgrid is True assert 'addgrid' in a._input['addgrid'].output_map() assert a._input['addgrid'].output_map()['addgrid'] == '.TRUE.' a.addgrid = None assert a._input['addgrid'].keyword == 'addgrid' assert a._input['addgrid'].output_map() is None a.addgrid = 0 assert a.addgrid is False a.addgrid = False o = a._input['addgrid'] d = {'BoolKeyword': o.__class__} assert repr(eval(repr(o), d)) == repr(o) assert eval(repr(o), d).output_map()['addgrid'] == '.FALSE.' assert repr(loads(dumps(o))) == repr(o) a.addgrid = True o = a._input['addgrid'] assert repr(eval(repr(o), d)) == repr(o) assert eval(repr(o), d).output_map()['addgrid'] == '.TRUE.' assert repr(loads(dumps(o))) == repr(o) a.addgrid = None o = a._input['addgrid'] assert repr(eval(repr(o), d)) == repr(o) assert eval(repr(o), d).output_map() is None assert repr(loads(dumps(o))) == repr(o)
def main(): from boost.mpi import world from scipy.optimize import fmin as scipy_simplex from pylada.vasp import Extract, ExtractGW, Vasp, Specie from pylada.vasp.specie import nlep as nlep_parameters, U as u_parameters from pylada.vasp.incar import Standard, NBands from sys import exit indir = "SnO2" dft_in = Extract(directory=indir, comm=world) dft_in.OUTCAR = "OUTCAR_pbe" dft_in.CONTCAR = "POSCAR" gw_in = ExtractGW(directory=indir, comm=world) gw_in.OUTCAR = "OUTCAR_gw" gw_in.CONTCAR = "POSCAR" # Creates species with nlep parameters to optimize species = Specie\ ( "Sn", path="pseudos/Sn", U=[nlep_parameters(type="Dudarev", l=i, U0=0e0) for i in ["s", "p", "d"]] ),\ Specie\ ( "O", path="pseudos/O", U=[nlep_parameters(type="Dudarev", l=i, U0=0e0) for i in ["s", "p"]] ) # add U to Sn atoms. species[0].U.append( u_parameters(type="Dudarev", U=2e0, l=2) ) # creates vasp launcher vasp = Vasp\ ( kpoints = lambda x: "Automatic generation\n0\ngamma\n6 6 10\n0 0 0", precision = "accurate", smearing = "bloechl", ediff = 1e-5, relaxation = "ionic", encut = 1, # uses ENMAX * 1, which is VASP default species = species ) # adds some extra parameters. vasp.nbands = Standard("NBANDS", 64) vasp.lorbit = Standard("LORBIT", 10) vasp.npar = Standard("NPAR", 2) vasp.lplane = Standard("LPLANE", ".TRUE.") vasp.addgrid = Standard("ADDGRID", ".TRUE.") del vasp.fftgrid # creates objective function. objective = Objective(vasp, dft_in, gw_in) x0, f0, iter, funcalls, warnflag = scipy_simplex(objective, objective.x, maxfun=150, full_output=1, xtol=0.2) world.barrier() if world.rank == 0: print "minimum value:", f0 print "for: ", x0 * units print "after %i iterations and %i function calls." % (iter, funcalls) print "with warning flag: ", warnflag print final(x0)
pseudoDir = '/home/vstevano/software/pseudos' vasp.add_specie = "In", pseudoDir + "/In" vasp.add_specie = "O", pseudoDir + "/O" vasp.prec = "accurate" vasp.encut = 340. vasp.ismear = 0 vasp.sigma = 0.05 vasp.ediff = 1.0e-6 vasp.ediffg = -0.01 vasp.convergence= 1.0e-6 vasp.nsw = 1 vasp.lwave = True vasp.lorbit = 10 vasp.lplane = True vasp.addgrid = True vasp.npar = 8 vasp.isym = 0 vasp.lcharg = True vasp.lwave = True vasp.lmaxmix = 4 vasp.loptics = False vasp.lpead = False vasp.algo = "Normal" vasp.relaxation = "ionic" relax = Relax(copy=vasp) relax.nsw=75 relax.minrelsteps= 4 relax.maxiter = 10