コード例 #1
0
def gen(symbol, exx=False, name=None, **kwargs):
    if mpi.rank == 0:
        if 'scalarrel' not in kwargs:
            kwargs['scalarrel'] = True
        g = Generator(symbol, **kwargs)
        if 'orbital_free' in kwargs:
            g.run(exx=exx, name=name, use_restart_file=False,
                  **tf_parameters.get(symbol, {'rcut': 0.9}))
        else:
            g.run(exx=exx, name=name, use_restart_file=False,
                  **parameters[symbol])
    mpi.world.barrier()
    if setup_paths[0] != '.':
        setup_paths.insert(0, '.')
コード例 #2
0
def gen(symbol, exx=False, name=None, **kwargs):
    if mpi.rank == 0:
        if 'scalarrel' not in kwargs:
            kwargs['scalarrel'] = True
        g = Generator(symbol, **kwargs)
        if 'orbital_free' in kwargs:
            g.run(exx=exx,
                  name=name,
                  use_restart_file=False,
                  **tf_parameters.get(symbol, {'rcut': 0.9}))
        else:
            g.run(exx=exx,
                  name=name,
                  use_restart_file=False,
                  **parameters[symbol])
    mpi.world.barrier()
    if setup_paths[0] != '.':
        setup_paths.insert(0, '.')
コード例 #3
0
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)