from gpaw.xc.fxc_correlation_energy import FXCCorrelation import numpy as np a0 = 5.43 Ni = bulk('Ni', 'fcc') Ni.set_initial_magnetic_moments([0.7]) kpts = monkhorst_pack((3,3,3)) calc = GPAW(mode='pw', kpts=kpts, occupations=FermiDirac(0.001), setups={'Ni': '10'}, communicator=serial_comm) Ni.set_calculator(calc) E = Ni.get_potential_energy() calc.diagonalize_full_hamiltonian(nbands=50) rpa = RPACorrelation(calc) E_rpa = rpa.get_rpa_correlation_energy(ecut=50, skip_gamma=True, gauss_legendre=8) fxc = FXCCorrelation(calc, xc='RPA') E_fxc = fxc.get_fxc_correlation_energy(ecut=50, skip_gamma=True, gauss_legendre=8) equal(E_rpa, -7.826, 0.01) equal(E_fxc, -7.827, 0.01)
ecut = 25 N2 = molecule('N2') N2.center(vacuum=2.0) calc = GPAW(mode='pw', dtype=complex, xc='PBE', communicator=serial_comm) N2.set_calculator(calc) E_n2_pbe = N2.get_potential_energy() E_n2_hf = E_n2_pbe + calc.get_xc_difference(HybridXC('EXX', etotflag=True)) calc.diagonalize_full_hamiltonian(nbands=100) rpa = RPACorrelation(calc, vcut='3D') E_n2_rpa = rpa.get_rpa_correlation_energy(ecut=ecut, directions=[[0, 2/3.], [2, 1/3.]], gauss_legendre=8) # ------------------------------------------------------------------------- N = molecule('N') N.set_cell(N2.cell) calc = GPAW(mode='pw', dtype=complex, xc='PBE', communicator=serial_comm) N.set_calculator(calc) E_n_pbe = N.get_potential_energy() E_n_hf = E_n_pbe + calc.get_xc_difference(HybridXC('EXX', etotflag=True)) calc.diagonalize_full_hamiltonian(nbands=100) rpa = RPACorrelation(calc, vcut='3D')
from __future__ import print_function # Refer to J. Harl, et.al, PRB 81, 115126 (2010) # Table III for parameter used in this calculation # Fig. 2 to compare the correlation energy. import numpy as np from gpaw import GPAW from gpaw.xc.rpa_correlation_energy import RPACorrelation from gpaw.mpi import serial_comm, size from ase.parallel import paropen tag = 'Nabulk' f = paropen('%s_RPA.dat' %(tag), 'a') for i in range(9): ecut = 120 + 10 * i calc = GPAW('gs_%s.gpw' %(tag), communicator=serial_comm, txt=None) rpa = RPACorrelation(calc, txt='rpa_%s_%s.txt' %(tag,ecut)) E = rpa.get_rpa_correlation_energy(ecut=ecut, skip_gamma=False, directions=[[0,1.0]], kcommsize=size, dfcommsize=size) print('%s '%(ecut), E, file=f) f.close()
from ase import * from ase.parallel import paropen from gpaw import * from gpaw.mpi import serial_comm from gpaw.xc.rpa_correlation_energy import RPACorrelation calc1 = GPAW('N.gpw', communicator=serial_comm, txt=None) calc2 = GPAW('N2.gpw', communicator=serial_comm, txt=None) rpa1 = RPACorrelation(calc1, txt='rpa_N.txt') rpa2 = RPACorrelation(calc2, txt='rpa_N2.txt') f = paropen('rpa_N2.dat', 'w') for ecut in [100, 150, 200, 250, 300, 350, 400]: E1 = rpa1.get_rpa_correlation_energy(ecut=ecut, directions=[[0, 1.0]]) E2 = rpa2.get_rpa_correlation_energy(ecut=ecut, directions=[[0, 2/3.], [2, 1/3.]]) print >> f, ecut, E2 - 2*E1 f.close()
from ase import * from ase.parallel import paropen from gpaw import * from gpaw.mpi import serial_comm from gpaw.xc.rpa_correlation_energy import RPACorrelation calc = GPAW('gs_12_lda.gpw', communicator=serial_comm, txt=None) rpa = RPACorrelation(calc, txt='rpa_12_lda.txt') #for ecut in [100,150,200,250,300,350,400]: for ecut in [400, 450, 500, 550]: E = rpa.get_rpa_correlation_energy(ecut=ecut, directions=[[0, 1.0]], kcommsize=32) f = paropen('rpa_12_lda.dat', 'a') print >> f, ecut, E f.close()
from ase import * from ase.parallel import paropen from gpaw import * from gpaw.mpi import serial_comm from gpaw.xc.rpa_correlation_energy import RPACorrelation ecut = 200 ds = [1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 5.0, 6.0, 10.0] for d in ds: calc = GPAW("gs_%s.gpw" % d, communicator=serial_comm, txt=None) rpa = RPACorrelation(calc, txt="rpa_%s_%s.txt" % (ecut, d)) E_rpa = rpa.get_rpa_correlation_energy( ecut=ecut, frequency_cut=800, frequency_scale=2.5, kcommsize=128, skip_gamma=True, # directions=[[0, 2/3.], [2, 1/3.]], restart="restart_%s_%s.txt" % (ecut, d), ) f = paropen("rpa_%s.dat" % ecut, "a") print >> f, d, E_rpa f.close()
#!/usr/bin/env python from ase import * from ase.parallel import paropen from gpaw import * from gpaw.mpi import serial_comm from gpaw.xc.rpa_correlation_energy import RPACorrelation w = np.linspace(0.0, 200.0, 32) calc1 = GPAW('N_4000.gpw', communicator=serial_comm, txt=None) calc2 = GPAW('N2_4000.gpw', communicator=serial_comm, txt=None) rpa1 = RPACorrelation(calc1, txt='rpa_N.txt') rpa2 = RPACorrelation(calc2, txt='rpa_N2.txt') for ecut in [150, 200, 250, 300, 350, 400]: E1 = rpa1.get_rpa_correlation_energy(ecut=ecut, w=w) E2 = rpa2.get_rpa_correlation_energy(ecut=ecut, w=w) f = paropen('rpa_atomization.dat', 'a') print >> f, ecut, bands, E2 - 2 * E1 f.close()
#!/usr/bin/env python from ase import * from ase.parallel import paropen from gpaw import * from gpaw.mpi import serial_comm from gpaw.xc.rpa_correlation_energy import RPACorrelation w = np.linspace(0.0, 200.0, 32) calc1 = GPAW('N_4000.gpw', communicator=serial_comm, txt=None) calc2 = GPAW('N2_4000.gpw', communicator=serial_comm, txt=None) rpa1 = RPACorrelation(calc1, txt='rpa_N.txt') rpa2 = RPACorrelation(calc2, txt='rpa_N2.txt') for ecut in [150, 200, 250, 300, 350, 400]: E1 = rpa1.get_rpa_correlation_energy(ecut=ecut, w=w) E2 = rpa2.get_rpa_correlation_energy(ecut=ecut, w=w) f = paropen('rpa_atomization.dat', 'a') print >> f, ecut, bands, E2 - 2*E1 f.close()
from ase import * from ase.parallel import paropen from gpaw import * from gpaw.mpi import serial_comm from gpaw.xc.rpa_correlation_energy import RPACorrelation calc = GPAW('N2.gpw', communicator=serial_comm, txt=None) rpa = RPACorrelation(calc, txt='rpa_N2_frequencies.txt') f = paropen('con_freq.dat', 'w') for N in [4, 6, 8, 12, 16, 24, 32]: E = rpa.get_rpa_correlation_energy(ecut=200, gauss_legendre=N, directions=[[0, 2/3.], [2, 1/3.]]) print >> f, N, E f.close()
from ase import * from ase.structure import bulk import numpy as np from gpaw import * from gpaw.mpi import serial_comm from gpaw.test import equal from gpaw.xc.rpa_correlation_energy import RPACorrelation calc = GPAW(h=0.18, xc='LDA', kpts=(4,4,4), #usesymm=None, nbands=15, eigensolver='cg', convergence={'bands': -5}, communicator=serial_comm) V = 30. a0 = (4.*V)**(1/3.) Kr = bulk('Kr', 'fcc', a=a0) Kr.set_calculator(calc) Kr.get_potential_energy() ecut = 30. w = np.linspace(0.0, 50., 8) rpa = RPACorrelation(calc) E_rpa = rpa.get_rpa_correlation_energy(ecut=ecut, w=w) equal(E_rpa, -3.2, 0.1)