d = 0.9575
t = pi / 180 * 104.51
H2O = Atoms([Atom('O', (0, 0, 0)),
             Atom('H', (d, 0, 0)),
             Atom('H', (d * cos(t), d * sin(t), 0))],
            cell=(a, a, a), pbc=False)
H2O.center()
calc = GPAW(nbands=10, h=0.2, setups={'O': 'hch1s'})
H2O.set_calculator(calc)
e = H2O.get_potential_energy()
niter = calc.get_number_of_iterations()

import gpaw.mpi as mpi

if mpi.size == 1: #
    xas = XAS(calc)
    x, y = xas.get_spectra()
    e1_n = xas.eps_n
    de1 = e1_n[1] - e1_n[0]

calc.write('h2o-xas.gpw')

if mpi.size == 1:
    calc = GPAW('h2o-xas.gpw', txt=None)
    calc.initialize()
    xas = XAS(calc)
    x, y = xas.get_spectra()
    e2_n = xas.eps_n
    w_n = np.sum(xas.sigma_cn.real**2, axis=0)
    de2 = e2_n[1] - e2_n[0]
Example #2
0
from gpaw import GPAW, setup_paths
from gpaw.xas import XAS
import pylab as plt

setup_paths.insert(0, '.')

dks_energy = 532.774  # from dks calcualtion

calc = GPAW('h2o_xas.gpw')
calc.set_positions()

xas = XAS(calc, mode='xas')
x, y = xas.get_spectra(fwhm=0.5, linbroad=[4.5, -1.0, 5.0])
x_s, y_s = xas.get_spectra(stick=True)

shift = dks_energy - x_s[0]  # shift the first transition

y_tot = y[0] + y[1] + y[2]
y_tot_s = y_s[0] + y_s[1] + y_s[2]

plt.plot(x + shift, y_tot)
plt.bar(x_s + shift, y_tot_s, width=0.001)
plt.show()
Example #3
0
H2O = Atoms([Atom('O', (0, 0, 0)),
             Atom('H', (d, 0, 0)),
             Atom('H', (d * cos(t), d * sin(t), 0))],
            cell=(a, a, a), pbc=False)
H2O.center()
calc = GPAW(nbands=10, h=0.2, setups={'O': 'hch1s'},
            experimental={'niter_fixdensity': 2},
            poissonsolver=FDPoissonSolver(use_charge_center=True))
H2O.set_calculator(calc)
e = H2O.get_potential_energy()
niter = calc.get_number_of_iterations()

import gpaw.mpi as mpi

if mpi.size == 1:
    xas = XAS(calc)
    x, y = xas.get_spectra()
    e1_n = xas.eps_n
    de1 = e1_n[1] - e1_n[0]

calc.write('h2o-xas.gpw')

if mpi.size == 1:
    calc = GPAW('h2o-xas.gpw', txt=None,
                poissonsolver=FDPoissonSolver(use_charge_center=True))
    calc.initialize()
    xas = XAS(calc)
    x, y = xas.get_spectra()
    e2_n = xas.eps_n
    w_n = np.sum(xas.sigma_cn.real**2, axis=0)
    de2 = e2_n[1] - e2_n[0]
Example #4
0
import numpy as np
from gpaw import GPAW, setup_paths
from gpaw.xas import XAS
import pylab as plt
setup_paths.insert(0, '.')

h = 0.2

offset = 0.0
for L in np.arange(4, 14, 2) * 8 * h:
    calc = GPAW('h2o_hch_%.1f.gpw' % L)
    xas = XAS(calc)
    x, y = xas.get_spectra(fwhm=0.4)
    plt.plot(x,sum(y) + offset, label=str(L))
    offset += 0.005

plt.legend()
plt.xlim(-6, 4)
plt.ylim(-0.002, 0.03)
plt.show()
Example #5
0
            h=0.25,
            kpts=(2, 2, 2),
            occupations=FermiDirac(width=0.05),
            setups={0: 'hch1s'},
            symmetry='off')

si_nonortho.set_calculator(calc)
e = si_nonortho.get_potential_energy()
niter = calc.get_number_of_iterations()
calc.write('si_nonortho_xas_nosym.gpw')

# restart from file
calc1 = GPAW('si_nonortho_xas_sym.gpw')
calc2 = GPAW('si_nonortho_xas_nosym.gpw')
if mpi.size == 1:
    xas1 = XAS(calc1)
    x, y1 = xas1.get_spectra()
    xas2 = XAS(calc2)
    x2, y2 = xas2.get_spectra(E_in=x)

    assert (np.sum(abs(y1 - y2)[0, :500]**2) < 5e-9)
    assert (np.sum(abs(y1 - y2)[1, :500]**2) < 5e-9)
    assert (np.sum(abs(y1 - y2)[2, :500]**2) < 5e-9)

#else:
#    x = np.linspace(0, 10, 50)
#
#r1 = RecursionMethod(calc1)
#r1.run(40)
#
#r2 = RecursionMethod(calc1)
Example #6
0
import numpy as np
from gpaw import GPAW, setup_paths
from gpaw.xas import XAS
import pylab as plt
setup_paths.insert(0, '.')

h = 0.2

offset = 0.0
for L in np.arange(4, 14, 2) * 8 * h:
    calc = GPAW('h2o_hch_%.1f.gpw' % L)
    xas = XAS(calc)
    x, y = xas.get_spectra(fwhm=0.4)
    plt.plot(x, sum(y) + offset, label=str(L))
    offset += 0.005

plt.legend()
plt.xlim(-6, 4)
plt.ylim(-0.002, 0.03)
plt.show()