def generate_setup(self): if mpi.rank == 0: gen = Generator(self.symbol, 'PBE', scalarrel=True) gen.run(logderiv=True, **parameters[self.symbol]) data = analyse(gen, show=False) g = np.arange(gen.N) r_g = gen.r dr_g = gen.beta * gen.N / (gen.N - g)**2 rcutcomp = gen.rcutcomp rcutfilter = gen.rcutfilter # Find cutoff for core density: if gen.Nc == 0: rcore = 0.5 else: N = 0.0 g = gen.N - 1 while N < 1e-7: N += np.sqrt(4 * np.pi) * gen.nc[g] * r_g[g]**2 * dr_g[g] g -= 1 rcore = r_g[g] nlfer = [] for j in range(gen.njcore): nlfer.append((gen.n_j[j], gen.l_j[j], gen.f_j[j], gen.e_j[j], 0.0)) for n, l, f, eps in zip(gen.vn_j, gen.vl_j, gen.vf_j, gen.ve_j): nlfer.append((n, l, f, eps, gen.rcut_l[l])) self.data = dict(Z=gen.Z, Nv=gen.Nv, Nc=gen.Nc, rcutcomp=rcutcomp, rcutfilter=rcutfilter, rcore=rcore, Ekin=gen.Ekin, Epot=gen.Epot, Exc=gen.Exc, nlfer=nlfer)
def generate_setup(self): if mpi.rank == 0: gen = Generator(self.symbol, 'PBE', scalarrel=True) gen.run(logderiv=True, **parameters[self.symbol]) data = analyse(gen, show=False) g = np.arange(gen.N) r_g = gen.r dr_g = gen.beta * gen.N / (gen.N - g)**2 rcutcomp = gen.rcutcomp rcutfilter = gen.rcutfilter # Find cutoff for core density: if gen.Nc == 0: rcore = 0.5 else: N = 0.0 g = gen.N - 1 while N < 1e-7: N += np.sqrt(4 * np.pi) * gen.nc[g] * r_g[g]**2 * dr_g[g] g -= 1 rcore = r_g[g] nlfer = [] for j in range(gen.njcore): nlfer.append( (gen.n_j[j], gen.l_j[j], gen.f_j[j], gen.e_j[j], 0.0)) for n, l, f, eps in zip(gen.vn_j, gen.vl_j, gen.vf_j, gen.ve_j): nlfer.append((n, l, f, eps, gen.rcut_l[l])) self.data = dict(Z=gen.Z, Nv=gen.Nv, Nc=gen.Nc, rcutcomp=rcutcomp, rcutfilter=rcutfilter, rcore=rcore, Ekin=gen.Ekin, Epot=gen.Epot, Exc=gen.Exc, nlfer=nlfer)
def main(): parser = build_parser() opt, args = parser.parse_args() import sys from gpaw.atom.generator import Generator from gpaw.atom.configurations import parameters, tf_parameters from gpaw.atom.all_electron import AllElectron from gpaw import ConvergenceError if args: atoms = args else: atoms = parameters.keys() bad_density_warning = """\ Problem with initial electron density guess! Try to run the program with the '-nw' option (non-scalar-relativistic calculation + write density) and then try again without the '-n' option (this will generate a good initial guess for the density).""" for symbol in atoms: scalarrel = not opt.non_scalar_relativistic corehole = None if opt.core_hole is not None: state, occ = opt.core_hole.split(',') # Translate corestate string ('1s') to n and l: ncorehole = int(state[0]) lcorehole = 'spdf'.find(state[1]) fcorehole = float(occ) corehole = (ncorehole, lcorehole, fcorehole) if opt.all_electron_only: a = AllElectron(symbol, opt.xcfunctional, scalarrel, corehole, opt.configuration, not opt.write_files, '-', opt.points_per_node, opt.orbital_free, opt.tw_coefficient) try: a.run() except ConvergenceError: print(bad_density_warning, file=sys.stderr) continue g = Generator(symbol, opt.xcfunctional, scalarrel, corehole, opt.configuration, not opt.write_files, '-', opt.points_per_node, orbital_free=opt.orbital_free, tw_coeff=opt.tw_coefficient) if opt.orbital_free: p = tf_parameters.get(symbol, {'rcut': 0.9}) else: p = parameters.get(symbol, {}) if opt.core is not None: p['core'] = opt.core if opt.radius is not None: p['rcut'] = [float(x) for x in opt.radius.split(',')] if opt.extra_projectors is not None: extra = {} if opt.extra_projectors != '': for l, x in enumerate(opt.extra_projectors.split(';')): if x != '': extra[l] = [float(y) for y in x.split(',')] p['extra'] = extra if opt.normconserving is not None: p['normconserving'] = opt.normconserving if opt.filter is not None: p['filter'] = [float(x) for x in opt.filter.split(',')] if opt.compensation_charge_radius is not None: p['rcutcomp'] = opt.compensation_charge_radius if opt.zero_potential is not None: vbar = opt.zero_potential.split(',') p['vbar'] = (vbar[0], float(vbar[1])) if opt.empty_states is not None: p['empty_states'] = opt.empty_states try: g.run(logderiv=opt.logarithmic_derivatives, exx=opt.exact_exchange, name=opt.name, use_restart_file=opt.use_restart_file, **p) except ConvergenceError: print(bad_density_warning, file=sys.stderr) except RuntimeError as m: if len(m.__str__()) == 0: raise print(m) if opt.plot: from gpaw.atom.analyse_setup import analyse analyse(g, show=True)
def main(): parser = build_parser() opt, args = parser.parse_args() import sys from gpaw.atom.generator import Generator from gpaw.atom.configurations import parameters, tf_parameters from gpaw.atom.all_electron import AllElectron from gpaw import ConvergenceError if args: atoms = args else: atoms = parameters.keys() bad_density_warning = """\ Problem with initial electron density guess! Try to run the program with the '-nw' option (non-scalar-relativistic calculation + write density) and then try again without the '-n' option (this will generate a good initial guess for the density).""" for symbol in atoms: scalarrel = not opt.non_scalar_relativistic corehole = None if opt.core_hole is not None: state, occ = opt.core_hole.split(',') # Translate corestate string ('1s') to n and l: ncorehole = int(state[0]) lcorehole = 'spdf'.find(state[1]) fcorehole = float(occ) corehole = (ncorehole, lcorehole, fcorehole) if opt.all_electron_only: a = AllElectron(symbol, opt.xcfunctional, scalarrel, corehole, opt.configuration, not opt.write_files, '-', opt.points_per_node, opt.orbital_free, opt.tf_coefficient) try: a.run() except ConvergenceError: print(bad_density_warning, file=sys.stderr) continue g = Generator(symbol, opt.xcfunctional, scalarrel, corehole, opt.configuration, not opt.write_files, '-', opt.points_per_node, orbital_free=opt.orbital_free, tf_coeff=opt.tf_coefficient) if opt.orbital_free: p = tf_parameters.get(symbol, {'rcut': 0.9}) else: p = parameters.get(symbol, {}) if opt.core is not None: p['core'] = opt.core if opt.radius is not None: p['rcut'] = [float(x) for x in opt.radius.split(',')] if opt.extra_projectors is not None: extra = {} if opt.extra_projectors != '': for l, x in enumerate(opt.extra_projectors.split(';')): if x != '': extra[l] = [float(y) for y in x.split(',')] p['extra'] = extra if opt.normconserving is not None: p['normconserving'] = opt.normconserving if opt.filter is not None: p['filter'] = [float(x) for x in opt.filter.split(',')] if opt.compensation_charge_radius is not None: p['rcutcomp'] = opt.compensation_charge_radius if opt.zero_potential is not None: vbar = opt.zero_potential.split(',') p['vbar'] = (vbar[0], float(vbar[1])) if opt.empty_states is not None: p['empty_states'] = opt.empty_states try: g.run(logderiv=opt.logarithmic_derivatives, exx=opt.exact_exchange, name=opt.name, use_restart_file=opt.use_restart_file, **p) except ConvergenceError: print(bad_density_warning, file=sys.stderr) except RuntimeError, m: if len(m.__str__()) == 0: raise print(m) if opt.plot: from gpaw.atom.analyse_setup import analyse analyse(g, show=True)