コード例 #1
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.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)
コード例 #2
0
    plt.xlabel(r'h [\AA]')
    plt.ylabel('energy [eV]')
    plt.legend(loc='best')

    plt.subplot(312)
    plt.semilogy(h, np.abs(data['Fegg']).max(axis=1), '-o',
                 label=r'$|\mathbf{F}_{egg}|$')
    plt.semilogy(h, np.abs(data['Fdimer'].sum(axis=2)).max(axis=1), '-o',
                 label=r'$|\mathbf{F}_1 + \mathbf{F}_2|$')
    #plt.title('Forces')
    plt.xlabel(r'h [\AA]')
    plt.ylabel(r'force [eV/\AA]')
    plt.legend(loc='best')

    plt.subplot(313)
    d = ddimer0[-1]
    plt.plot(h, ddimer0, '-o')
    #plt.title('Bond length')
    plt.xlabel(r'h [\AA]')
    plt.axis(ymin=d * 0.98, ymax=d * 1.02)
    plt.ylabel(r'bond length [\AA]')

    plt.savefig('../_static/setups-data/%s-dimer-eggbox.png' % symbol, dpi=dpi)
    #plt.show()

args = sys.argv[1:]
if len(args) == 0:
    args = parameters.keys()
for symbol in args:
    make_page(symbol)
コード例 #3
0
ファイル: pbe_gpaw_pw.py プロジェクト: eojons/gpaw-scme
fit = (5, 0.02)

w = 0.06

ecut = 1200
kd = 8.0

tag = 'dcdft_%s_gpaw_pw' % xc.lower()

task = Task(
    calcfactory=Factory(xc=xc,
                        mode=PW(ecut),
                        occupations=FermiDirac(w),
                        maxiter=250,
                        kptdensity=kd,
                        ),
    tag=tag,
    fit=fit,
    use_lock_files=True,
    )

if __name__ == '__main__':
    if element is None:
        keys = set(parameters.keys()).intersection(set(task.collection.names))
        for s in elements_slow:
            keys.remove(s)  # those are slow, run separately
    else:
        keys = [element]
    task.run(keys)
コード例 #4
0
ファイル: make_setup_pages.py プロジェクト: qsnake/gpaw
    # plt.title('Energy differences')
    plt.xlabel(u"h [Å]")
    plt.ylabel("energy [eV]")
    plt.legend(loc="best")

    plt.subplot(312)
    plt.semilogy(h, np.abs(data["Fegg"]).max(axis=1), "-o", label=r"$|\mathbf{F}_{egg}|$")
    plt.semilogy(h, np.abs(data["Fdimer"].sum(axis=2)).max(axis=1), "-o", label=r"$|\mathbf{F}_1 + \mathbf{F}_2|$")
    # plt.title('Forces')
    plt.xlabel(u"h [Å]")
    plt.ylabel(u"force [eV/Å]")
    plt.legend(loc="best")

    plt.subplot(313)
    d = ddimer0[-1]
    plt.plot(h, ddimer0, "-o")
    # plt.title('Bond length')
    plt.xlabel(u"h [Å]")
    plt.axis(ymin=d * 0.98, ymax=d * 1.02)
    plt.ylabel(u"bond length [Å]")

    plt.savefig("../_static/setups-data/%s-dimer-eggbox.png" % symbol, dpi=dpi)
    # plt.show()


args = sys.argv[1:]
if len(args) == 0:
    args = parameters.keys()
for symbol in args:
    make_page(symbol)
コード例 #5
0
fit = (5, 0.02)

w = 0.06

ecut = 1200
kd = 8.0

tag = 'dcdft_%s_gpaw_pw' % xc.lower()

task = Task(
    calcfactory=Factory(
        xc=xc,
        mode=PW(ecut),
        occupations=FermiDirac(w),
        maxiter=250,
        kptdensity=kd,
    ),
    tag=tag,
    fit=fit,
    use_lock_files=True,
)

if __name__ == '__main__':
    if element is None:
        keys = set(parameters.keys()).intersection(set(task.collection.names))
        for s in elements_slow:
            keys.remove(s)  # those are slow, run separately
    else:
        keys = [element]
    task.run(keys)
コード例 #6
0
def main():
    parser = OptionParser(usage='%prog [OPTION...] [SYMBOL...]',
                          description=description)
    parser.add_option('--xc',
                      metavar='FUNCTIONAL',
                      default='PBE',
                      help='generate basis sets for FUNCTIONAL[=%default]')
    parser.add_option('--from',
                      metavar='SYMBOL',
                      dest='_from',
                      help='generate starting from SYMBOL if generating '
                      'for all elements')
    opts, symbols = parser.parse_args()

    if len(symbols) == 0:
        symbols = sorted(parameters.keys())
        othersymbols = []
        for symbol in parameters_extra:
            name = parameters_extra[symbol]['name']
            code = '%s.%s' % (symbol, name)
            othersymbols.append(code)
        trouble = set(['Os.8', 'Ta.5', 'V.5', 'W.6', 'Ir.9'])
        othersymbols = [
            symbol for symbol in othersymbols if symbol not in trouble
        ]
        symbols.extend(sorted(othersymbols))

        if opts._from:
            index = symbols.index(opts._from)
            symbols = symbols[index:]

    specifications = []
    for sym in symbols:
        try:
            s = SetupData(sym, opts.xc)
        except RuntimeError as e:
            if str(e).startswith('Could not find'):
                #print 'No %s' % sym
                continue
            else:
                raise

        # One could include basis functions also for the ``virtual'' states
        # (marked with negative n)

        jvalues = []
        jextra = []
        for j in range(len(s.f_j)):
            if s.eps_j[j] < 0:
                jvalues.append(j)
                if s.f_j[j] == 0.0 and s.n_j[j] > 0:
                    jextra.append(j)
        if len(jextra) > 0:
            specifications.append(BasisSpecification(s, jvalues, jextra))
            #print sym, jvalues
        # XXX check whether automatic settings coincide with those of official
        # setups distribution
        #bm = BasisMaker(sym, ''

    if world.rank == 0:
        print('Generating basis sets for: %s' %
              ' '.join(spec.setup.symbol for spec in specifications))
    sys.stdout.flush()
    world.barrier()

    for i, spec in enumerate(specifications):
        if i % world.size != world.rank:
            continue
        if world.size > 1:
            print(world.rank, spec)
        else:
            print(spec)
        gtxt = None

        # XXX figure out how to accept Ag.11
        tokens = spec.setup.symbol.split('.')
        sym = tokens[0]

        if len(tokens) == 1:
            p = parameters
            name = 'pvalence'
        elif len(tokens) == 2:
            p = parameters_extra
            name = '%s.pvalence' % tokens[1]
        else:
            raise ValueError('Strange setup specification')

        type = 'dz'  # XXXXXXXXX
        bm = BasisMaker(sym,
                        '%s.%s' % (name, type),
                        run=False,
                        gtxt=gtxt,
                        xc=opts.xc)
        bm.generator.run(write_xml=False, use_restart_file=False, **p[sym])
        basis = bm.generate(2, 0, txt=None, jvalues=spec.jvalues)
        basis.write_xml()
コード例 #7
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)