Differences
This shows you the differences between two versions of the page.
documentation:tutorials:connection_to_dft:h_atom [2016/10/07 21:04] – created Maurits W. Haverkort | documentation:tutorials:connection_to_dft:h_atom [2016/10/10 09:41] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{indexmenu_n> | ||
+ | ====== H atom ====== | ||
+ | ### | ||
+ | The following example shows calculations using the H atom. In this case the full wavefunction is analytically known and we thus can calculate the complete Hamiltonian. This example does not really use DFT, but shows how to calculate radial integrals from known wavefunctions. | ||
+ | ### | ||
+ | |||
+ | ===== Input ===== | ||
+ | <code Quanty HWaveFunctions.Quanty> | ||
+ | -- The calculations are done using a set of basis spin-orbitals | ||
+ | -- These are very often given by some radial function times a spherical harmonic | ||
+ | -- (or given by sum of these) | ||
+ | -- Here I show for the very simple example of an H atom how one can calculate the | ||
+ | -- appropriate integrals | ||
+ | |||
+ | -- a gnuplot script to make the plots | ||
+ | gnuplotInput = [[ | ||
+ | set autoscale | ||
+ | set xtic auto | ||
+ | set ytic auto | ||
+ | set style line 1 lt 1 lw 1 lc rgb "# | ||
+ | set style line 2 lt 1 lw 1 lc rgb "# | ||
+ | set style line 3 lt 1 lw 1 lc rgb "# | ||
+ | set style line 4 lt 1 lw 1 lc rgb "# | ||
+ | set style line 5 lt 1 lw 1 lc rgb "# | ||
+ | set style line 6 lt 1 lw 1 lc rgb "# | ||
+ | |||
+ | set ylabel " | ||
+ | set xlabel " | ||
+ | |||
+ | set out ' | ||
+ | set size 1.0, 1.0 | ||
+ | set terminal postscript portrait enhanced color " | ||
+ | |||
+ | plot " | ||
+ | plot " | ||
+ | " | ||
+ | plot " | ||
+ | " | ||
+ | " | ||
+ | plot " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | plot " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | set ylabel "< | ||
+ | set xlabel " | ||
+ | |||
+ | i=1 | ||
+ | do for [n1=1:3] { | ||
+ | do for [l1=0:n1-1] { | ||
+ | do for [n2=1:3] { | ||
+ | do for [l2=0:n2-1] { | ||
+ | do for [k=abs(l1-l2): | ||
+ | i=i+1 | ||
+ | plot " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ]] | ||
+ | |||
+ | -- bohr radius in units of Angstrom | ||
+ | a0 = 0.52917721092; | ||
+ | |||
+ | -- Hydrogen wave functions with effective Z | ||
+ | function Rnl (n, l, r, Zeff) | ||
+ | return 2^(l+1) * e^(-r*Zeff/ | ||
+ | end | ||
+ | |||
+ | -- write the radial functions to a file | ||
+ | file = io.open(" | ||
+ | dr=0.01 | ||
+ | Nr=5000 | ||
+ | for ir = 0, Nr, 1 do | ||
+ | r = ir*dr | ||
+ | file: | ||
+ | for n=1, 5, 1 do | ||
+ | for l=0, n-1, 1 do | ||
+ | file: | ||
+ | end | ||
+ | end | ||
+ | file: | ||
+ | end | ||
+ | file: | ||
+ | |||
+ | -- normalization | ||
+ | io.write(" | ||
+ | dr=0.01 | ||
+ | Nr=5000 | ||
+ | for n=1, 5, 1 do | ||
+ | for l=0, n-1, 1 do | ||
+ | sum=0 | ||
+ | for ir = 0, Nr, 1 do | ||
+ | r = ir*dr | ||
+ | sum = sum + dr * r^2 * Rnl(n, | ||
+ | end | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | |||
+ | -- average distance | ||
+ | io.write(" | ||
+ | dr=0.01 | ||
+ | Nr=5000 | ||
+ | for n=1, 5, 1 do | ||
+ | for l=0, n-1, 1 do | ||
+ | sum=0 | ||
+ | for ir = 0, Nr, 1 do | ||
+ | r = ir*dr | ||
+ | sum = sum + dr * r^2 * r * Rnl(n, | ||
+ | end | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | |||
+ | -- average distance | ||
+ | io.write(" | ||
+ | dr=0.01 | ||
+ | Nr=5000 | ||
+ | for n=1, 5, 1 do | ||
+ | for l=0, n-1, 1 do | ||
+ | sum=0 | ||
+ | for ir = 0, Nr, 1 do | ||
+ | r = ir*dr | ||
+ | sum = sum + dr * r^2 * r * Rnl(n, | ||
+ | end | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | |||
+ | -- dipole moments | ||
+ | io.write(" | ||
+ | dr=0.01 | ||
+ | Nr=5000 | ||
+ | io.write(" | ||
+ | for n1=1, 3, 1 do | ||
+ | for l1=0, n1-1, 1 do | ||
+ | io.write(string.format(" | ||
+ | for n2=1, 3, 1 do | ||
+ | for l2=0, n2-1, 1 do | ||
+ | sum=0 | ||
+ | for ir = 0, Nr, 1 do | ||
+ | r = ir*dr | ||
+ | sum = sum + dr * r^2 * Rnl(n1, | ||
+ | end | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | end | ||
+ | |||
+ | -- Slater Integrals | ||
+ | io.write(" | ||
+ | dr=0.05 | ||
+ | Nr=1000 | ||
+ | for n1=1, 3, 1 do | ||
+ | for l1=0, n1-1, 1 do | ||
+ | for n2=1, 3, 1 do | ||
+ | for l2=0, n2-1, 1 do | ||
+ | io.write(string.format(" | ||
+ | for k=0, 2*math.min(l1, | ||
+ | io.write(string.format(" | ||
+ | sum=0 | ||
+ | for ir1 = 1, Nr, 1 do | ||
+ | r1 = ir1*dr | ||
+ | for ir2 = 1, Nr, 1 do | ||
+ | r2 = ir2*dr | ||
+ | sum = sum + a0 * dr^2* r1^2 * r2^2 * Rnl(n1, | ||
+ | end | ||
+ | end | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | io.write(string.format(" | ||
+ | for k=math.abs(l1-l2), | ||
+ | io.write(string.format(" | ||
+ | sum=0 | ||
+ | for ir1 = 1, Nr, 1 do | ||
+ | r1 = ir1*dr | ||
+ | for ir2 = 1, Nr, 1 do | ||
+ | r2 = ir2*dr | ||
+ | sum = sum + a0 * dr^2* r1^2 * r2^2 * Rnl(n1, | ||
+ | end | ||
+ | end | ||
+ | io.write(string.format(" | ||
+ | end | ||
+ | io.write(" | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | |||
+ | -- Expectation value of bessel functions | ||
+ | -- q in units of inverse bohr radii | ||
+ | file = io.open(" | ||
+ | file: | ||
+ | for n1=1, 3, 1 do | ||
+ | for l1=0, n1-1, 1 do | ||
+ | for n2=1, 3, 1 do | ||
+ | for l2=0, n2-1, 1 do | ||
+ | for k=math.abs(l1-l2), | ||
+ | file: | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | file: | ||
+ | dr=0.05 | ||
+ | Nr=1000 | ||
+ | dq=0.1 | ||
+ | Nq=100 | ||
+ | for iq=0, Nq, 1 do | ||
+ | q = iq*dq | ||
+ | file: | ||
+ | for n1=1, 3, 1 do | ||
+ | for l1=0, n1-1, 1 do | ||
+ | for n2=1, 3, 1 do | ||
+ | for l2=0, n2-1, 1 do | ||
+ | for k=math.abs(l1-l2), | ||
+ | sum=0 | ||
+ | for ir = 0, Nr, 1 do | ||
+ | r = ir*dr | ||
+ | sum = sum + dr * r^2 * Rnl(n1, | ||
+ | end | ||
+ | file: | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | file: | ||
+ | end | ||
+ | |||
+ | -- write the gnuplot script to a file | ||
+ | file = io.open(" | ||
+ | file: | ||
+ | file: | ||
+ | |||
+ | -- call gnuplot to execute the script | ||
+ | os.execute(" | ||
+ | </ | ||
+ | |||
+ | ===== Result ===== | ||
+ | |||
+ | The text output of the example is: | ||
+ | <file Quanty_Output HWaveFunctions.out> | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | < | ||
+ | R(1s) | ||
+ | R(1 0) 1.50000000E+00 -5.58701653E-01 | ||
+ | R(2 0) -5.58701653E-01 | ||
+ | R(2 1) 1.29026620E+00 -5.19615242E+00 | ||
+ | R(3 0) -2.43569644E-01 -1.85110879E+00 | ||
+ | R(3 1) 5.16689243E-01 | ||
+ | R(3 2) 3.85117423E-01 -5.93938418E+00 | ||
+ | |||
+ | < | ||
+ | R1(1 0) R2(1 0) F[0]= 6.25361997E-01 | ||
+ | G[0]= 6.25361997E-01 | ||
+ | R1(1 0) R2(2 0) F[0]= 2.09911370E-01 | ||
+ | G[0]= 2.19839069E-02 | ||
+ | R1(1 0) R2(2 1) F[0]= 2.42809270E-01 | ||
+ | G[1]= 5.12484496E-02 | ||
+ | R1(1 0) R2(3 0) F[0]= 9.94970763E-02 | ||
+ | G[0]= 5.77815972E-03 | ||
+ | R1(1 0) R2(3 1) F[0]= 1.08828908E-01 | ||
+ | G[1]= 1.36070257E-02 | ||
+ | R1(1 0) R2(3 2) F[0]= 1.11022542E-01 | ||
+ | G[2]= 1.23687003E-03 | ||
+ | R1(2 0) R2(1 0) F[0]= 2.09911370E-01 | ||
+ | G[0]= 2.19839069E-02 | ||
+ | R1(2 0) R2(2 0) F[0]= 1.50397569E-01 | ||
+ | G[0]= 1.50397569E-01 | ||
+ | R1(2 0) R2(2 1) F[0]= 1.62113568E-01 | ||
+ | G[1]= 8.79037050E-02 | ||
+ | R1(2 0) R2(3 0) F[0]= 8.41155296E-02 | ||
+ | G[0]= 7.47769953E-03 | ||
+ | R1(2 0) R2(3 1) F[0]= 9.00128174E-02 | ||
+ | G[1]= 8.49566045E-03 | ||
+ | R1(2 0) R2(3 2) F[0]= 1.03579160E-01 | ||
+ | G[2]= 3.65275093E-02 | ||
+ | R1(2 1) R2(1 0) F[0]= 2.42809270E-01 | ||
+ | G[1]= 5.12484496E-02 | ||
+ | R1(2 1) R2(2 0) F[0]= 1.62113568E-01 | ||
+ | G[1]= 8.79037050E-02 | ||
+ | R1(2 1) R2(2 1) F[0]= 1.81647891E-01 F[2]= 8.79269507E-02 | ||
+ | G[0]= 1.81647891E-01 G[2]= 8.79269507E-02 | ||
+ | R1(2 1) R2(3 0) F[0]= 8.67567735E-02 | ||
+ | G[1]= 9.42538747E-03 | ||
+ | R1(2 1) R2(3 1) F[0]= 9.39457829E-02 F[2]= 2.58889132E-02 | ||
+ | G[0]= 9.91050614E-03 G[2]= 1.13319343E-02 | ||
+ | R1(2 1) R2(3 2) F[0]= 1.06331648E-01 F[2]= 3.71302391E-02 | ||
+ | G[1]= 3.73743204E-02 G[3]= 2.18070620E-02 | ||
+ | R1(3 0) R2(1 0) F[0]= 9.94970763E-02 | ||
+ | G[0]= 5.77815972E-03 | ||
+ | R1(3 0) R2(2 0) F[0]= 8.41155296E-02 | ||
+ | G[0]= 7.47769953E-03 | ||
+ | R1(3 0) R2(2 1) F[0]= 8.67567735E-02 | ||
+ | G[1]= 9.42538747E-03 | ||
+ | R1(3 0) R2(3 0) F[0]= 6.64069248E-02 | ||
+ | G[0]= 6.64069248E-02 | ||
+ | R1(3 0) R2(3 1) F[0]= 6.87938354E-02 | ||
+ | G[1]= 4.23190720E-02 | ||
+ | R1(3 0) R2(3 2) F[0]= 7.31340175E-02 | ||
+ | G[2]= 2.27882524E-02 | ||
+ | R1(3 1) R2(1 0) F[0]= 1.08828908E-01 | ||
+ | G[1]= 1.36070257E-02 | ||
+ | R1(3 1) R2(2 0) F[0]= 9.00128174E-02 | ||
+ | G[1]= 8.49566045E-03 | ||
+ | R1(3 1) R2(2 1) F[0]= 9.39457829E-02 F[2]= 2.58889132E-02 | ||
+ | G[0]= 9.91050614E-03 G[2]= 1.13319343E-02 | ||
+ | R1(3 1) R2(3 0) F[0]= 6.87938354E-02 | ||
+ | G[1]= 4.23190720E-02 | ||
+ | R1(3 1) R2(3 1) F[0]= 7.18684241E-02 F[2]= 3.59914255E-02 | ||
+ | G[0]= 7.18684241E-02 G[2]= 3.59914255E-02 | ||
+ | R1(3 1) R2(3 2) F[0]= 7.69318422E-02 F[2]= 3.61349053E-02 | ||
+ | G[1]= 3.41809433E-02 G[3]= 2.40553028E-02 | ||
+ | R1(3 2) R2(1 0) F[0]= 1.11022542E-01 | ||
+ | G[2]= 1.23687003E-03 | ||
+ | R1(3 2) R2(2 0) F[0]= 1.03579160E-01 | ||
+ | G[2]= 3.65275093E-02 | ||
+ | R1(3 2) R2(2 1) F[0]= 1.06331648E-01 F[2]= 3.71302391E-02 | ||
+ | G[1]= 3.73743204E-02 G[3]= 2.18070620E-02 | ||
+ | R1(3 2) R2(3 0) F[0]= 7.31340175E-02 | ||
+ | G[2]= 2.27882524E-02 | ||
+ | R1(3 2) R2(3 1) F[0]= 7.69318422E-02 F[2]= 3.61349053E-02 | ||
+ | G[1]= 3.41809433E-02 G[3]= 2.40553028E-02 | ||
+ | R1(3 2) R2(3 2) F[0]= 8.60467604E-02 F[2]= 4.54247742E-02 F[4]= 2.96291766E-02 | ||
+ | G[0]= 8.60467604E-02 G[2]= 4.54247742E-02 G[4]= 2.96291766E-02 | ||
+ | </ | ||
+ | |||
+ | The created pdf is: {{ : | ||
+ | |||
+ | |||
+ | ===== Table of contents ===== | ||
+ | {{indexmenu> |