import os from gpaw.atom.generator import Generator """ SetupGenerators use a name; the generated setup files will be named accordingly such that several tests can be run simultaneously without overwriting Each concurrently active generator should, of course, use a different name """ class SetupGenerator: def __init__(self, name): #We don't want anything to mess up with existing files #so make sure a proper name is entered with a couple of chars #(it should be enough to test for len==0, but what the heck) if len(name) < 3: raise Exception self.name = name def new_nitrogen_setup(self, r=1.1, rvbar=None, rcomp=None, rfilter=None, hfilter=0.4): """Generate new nitrogen setup. The new setup depends on five parameters (Bohr units): * 0.6 < r < 1.9: cutoff radius for projector functions * 0.6 < rvbar < 1.9: cutoff radius zero potential (vbar) * 0.6 < rcomp < 1.9: cutoff radius for compensation charges * 0.6 < rfilter < 1.9: cutoff radius for Fourier-filtered projector functions * 0.2 < hfilter < 0.6: target grid spacing Use the setup like this:: calc = Calculator(setups={'N': 'opt'}, ...) """ if rvbar is None: rvbar = r if rcomp is None: rcomp = r if rfilter is None: rfilter = 2 * r g = Generator('N', 'PBE', scalarrel=True, nofiles=True) g.run(core='[He]', rcut=r, vbar=('poly', rvbar), filter=(hfilter, rfilter / r), rcutcomp=rcomp, logderiv=False) path = os.environ['GPAW_SETUP_PATH'].split(':')[0] os.rename('N.PBE', path + '/N.'+self.name+'.PBE') def f(self, par): self.new_nitrogen_setup(*par) #new_nitrogen_setup(1.1, 1.1, 1.1, 1.9, 0.4) #f([1.2]) #f([1.2, 1.0, 1.0])