Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
documentation:language_reference:functions:calculateatomicbasisfunctions [2026/11/16 08:24] – Maurits W. Haverkortdocumentation:language_reference:functions:calculateatomicbasisfunctions [2026/11/16 23:35] (current) – Maurits W. Haverkort
Line 3: Line 3:
 <color #ed1c24>New in 0.9.1</color> <color #ed1c24>New in 0.9.1</color>
 ;;# ;;#
- 
  
 ### ###
-//CalculateAtomicBasisFunctions(Z, Configuration, Options)// calculates the radial functions of the orbitals of an atom. //CalculateAtomicBasisFunctions(Z)// is enough for the ground state of the neutral atom. The atom is calculated self-consistently, relativistically (Dirac equation) or nonrelativistically (Schrödinger equation), either in the configuration-average Hartree-Fock approximation or in density functional theory (LDA, PBE). The radial functions are expanded in B-splines and returned as interpolating functions.+//G, F, Atom = CalculateAtomicBasisFunctions(Z, Options)// calculates the radial functions of the orbitals of an atom. //CalculateAtomicBasisFunctions(Z)// is enough for the ground state of the neutral atom. The atom is calculated self-consistently, relativistically (Dirac equation) or nonrelativistically (Schrödinger equation), either in the configuration-average Hartree-Fock approximation or in density functional theory (LDA, PBE). The radial functions are expanded in B-splines and returned as interpolating functions.
 ### ###
  
Line 21: Line 20:
 <code Quanty Example.Quanty> <code Quanty Example.Quanty>
 -- the Ni atom: the ground-state configuration, Dirac-Fock, a Gaussian nucleus of 58Ni -- the Ni atom: the ground-state configuration, Dirac-Fock, a Gaussian nucleus of 58Ni
-G, F, x, Atom = CalculateAtomicBasisFunctions(28)+G, F, Atom = CalculateAtomicBasisFunctions(28)
  
 print(Atom.Configuration, Atom.A) print(Atom.Configuration, Atom.A)
Line 56: Line 55:
  
   * //Z// : Real, the nuclear charge.   * //Z// : Real, the nuclear charge.
-  * //Configuration// : (optional) String, the electron configuration, for example //"[Ar] 3d8 4s2"//, see below. Left out, the ground-state configuration of the neutral atom is used (from the NIST atomic spectra database, for $Z$ = 1 to 103). Every orbital of the configuration is calculated and returned; an orbital with occupation 0, for example //"4p0"//, is calculated as an empty orbital. 
   * Options : (optional) A table of options. Possible options are:   * Options : (optional) A table of options. Possible options are:
 +      * //"Configuration"// : String, the electron configuration, for example //"[Ar] 3d8 4s2"//, see below. Default value is the ground-state configuration of the neutral atom (from the NIST atomic spectra database, for $Z$ = 1 to 103). Every orbital of the configuration is calculated and returned; an orbital with occupation 0, for example //"4p0"//, is calculated as an empty orbital. A configuration of empty orbitals only, for example //"1s0 2s0 2p0"//, is the bare nucleus: the orbitals of a hydrogen-like ion of charge $Z$.
       * //"Method"// : String. //"DHF"// (default) for configuration-average Hartree-Fock, //"LDA"// (Slater exchange and Perdew-Wang 92 correlation), //"LDA-VWN"// (Slater and Vosko-Wilk-Nusair), //"RLDA-MV"// (VWN with the relativistic MacDonald-Vosko correction of the exchange), //"PBE"// or //"PBE-VWN"//.       * //"Method"// : String. //"DHF"// (default) for configuration-average Hartree-Fock, //"LDA"// (Slater exchange and Perdew-Wang 92 correlation), //"LDA-VWN"// (Slater and Vosko-Wilk-Nusair), //"RLDA-MV"// (VWN with the relativistic MacDonald-Vosko correction of the exchange), //"PBE"// or //"PBE-VWN"//.
       * //"Relativistic"// : Boolean. Default value is true (Dirac equation); false solves the Schrödinger equation.       * //"Relativistic"// : Boolean. Default value is true (Dirac equation); false solves the Schrödinger equation.
Line 78: Line 77:
 ===== Output ===== ===== Output =====
  
-  * //G// : A table of the large components $P(r) = r g(r)$ of the orbitals, interpolating functions of type //"DKBSpline"// (relativistic) or //"BSpline"// (nonrelativistic). +  * //G// : A table of the large components $P(r) = r g(r)$ of the orbitals, [[documentation:language_reference:objects:interpolatingfunction:start|interpolating functions]] of type //"DKBSpline"// (relativistic) or //"BSpline"// (nonrelativistic). 
-  * //F// : A table of the small components $Q(r) = r f(r)$ (empty without relativity). The functions are normalized as $\int (P^2 + Q^2) \, \mathrm{d}r = 1$. +  * //F// : A table of the small components $Q(r) = r f(r)$ (empty without relativity). The functions are normalized as $\int (P^2 + Q^2) \, \mathrm{d}r = 1$. Every function returned, also the potentials in //Atom.Potential//, gives the radial points of the quadrature as //f.x//, for example //x = G[1].x//.
-  * //x// : The radial points of the quadrature.+
   * //Atom// : A table with   * //Atom// : A table with
-      * //Etot//, //Ekin//, //Eenuc// and //Edirect//, //Eexchange// (Hartree-Fock) or //Ecoul//, //Exc// (density functional theory): the total energy and its parts, and //Converged//, //Iterations//, //Residual//.+      * //Etot//, //Ekin//, //Eenuc// and //Edirect//, //Eexchange// (Hartree-Fock) or //Ecoul//, //Exc// (density functional theory): the total energy and its parts, //EtotEigenvalueSum//, the total energy from the orbital energies (equal to //Etot// when the calculation is converged; for Hartree-Fock for any orbitals), and //Converged//, //Iterations//, //Residual//.
       * //Orbitals// : per returned orbital //{Label, n, l, kappa, j, Occupation, Energy, RExpectation, ...}//, with //RExpectation[k]// $= \langle r^k \rangle$ for $k = -3$ (for $l > 0$), $-1$, $1$, $2$.       * //Orbitals// : per returned orbital //{Label, n, l, kappa, j, Occupation, Energy, RExpectation, ...}//, with //RExpectation[k]// $= \langle r^k \rangle$ for $k = -3$ (for $l > 0$), $-1$, $1$, $2$.
       * //Labels// : the labels of the orbitals, in the order of //G// and //F//: all calculated orbitals, ordered by $n$, $l$ and $j$. A selection is made in Lua.       * //Labels// : the labels of the orbitals, in the order of //G// and //F//: all calculated orbitals, ordered by $n$, $l$ and $j$. A selection is made in Lua.
Line 89: Line 87:
       * //Zeta// : the spin-orbit coupling constant of every shell returned with both $j$, //Zeta["3d"]//.       * //Zeta// : the spin-orbit coupling constant of every shell returned with both $j$, //Zeta["3d"]//.
       * //Nucleus// : the nucleus as a list of options, to pass on to //NewOperator("Dirac", ...)//.       * //Nucleus// : the nucleus as a list of options, to pass on to //NewOperator("Dirac", ...)//.
-      * //Potential// : the nuclear potential //VN//, the Hartree potential //VH// and (density functional theory) the exchange-correlation potential //Vxc// on the points //x//. +      * //Potential// : //rVN//, //rVH// and (density functional theory) //rVxc//, $r$ times the potential of the nucleus, the Hartree potential and the exchange-correlation potential of the ground state, interpolating functions of type //"BSpline"//, see [[#the_potentials|The potentials]] below. 
-      * //FourierBessel//, //ConvergenceCheck//, //VirialRatio// (nonrelativistic), //Gradient//, //PairGradient// (Hartree-Fock), //MinOverlapEigenvalue//, //OrthonormalityError//, and the input: //Method//, //Relativistic//, //c//, //Z//, //Configuration//, //A//, //NElectron//, //rMin//, //rMax//.+      * //FourierBessel//, //ConvergenceCheck//, //VirialRatio// (nonrelativistic), //PotentialResidual// and //MixDensity// (density functional theory), //Gradient//, //PairGradient// (Hartree-Fock), //EavJJ// (nonrelativistic Hartree-Fock: the average energy with the angular factors of the $j$ subshells, equal to //Etot//), //MinOverlapEigenvalue//, //OrthonormalityError//, and the input: //Method//, //Relativistic//, //c//, //Z//, //Configuration//, //A//, //NElectron//, //rMin//, //rMax//.
  
 All energies are in Hartree and all lengths in bohr. The speed of light is //PhysicalConstants.cAU.value//. All energies are in Hartree and all lengths in bohr. The speed of light is //PhysicalConstants.cAU.value//.
Line 112: Line 110:
 <code Quanty Example.Quanty> <code Quanty Example.Quanty>
 -- Hartree-Fock Slater integrals and spin-orbit coupling of Ni2+ in a 3d8 multiplet calculation -- Hartree-Fock Slater integrals and spin-orbit coupling of Ni2+ in a 3d8 multiplet calculation
-G, F, x, Atom = CalculateAtomicBasisFunctions(28, "[Ar] 3d8")+G, F, Atom = CalculateAtomicBasisFunctions(28, {{"Configuration", "[Ar] 3d8"}})
 eV = 27.211386 eV = 27.211386
 F2 = Atom.SlaterIntegralsNL["3d 3d 3d 3d"][2]*eV F2 = Atom.SlaterIntegralsNL["3d 3d 3d 3d"][2]*eV
Line 156: Line 154:
 <code Quanty Example.Quanty> <code Quanty Example.Quanty>
 -- the full relativistic Hamiltonian of Ne from its own Dirac-Fock orbitals -- the full relativistic Hamiltonian of Ne from its own Dirac-Fock orbitals
-G, F, x, Atom = CalculateAtomicBasisFunctions(10)+G, F, Atom = CalculateAtomicBasisFunctions(10)
 indices, NF = CreateAtomicIndicesList(Atom.Labels, {{"Kappas", true}}) indices, NF = CreateAtomicIndicesList(Atom.Labels, {{"Kappas", true}})
 H = NewOperator("Dirac", NF, 10, indices, G, F, Atom.Nucleus) + NewOperator("AU", NF, indices, G, F) H = NewOperator("Dirac", NF, 10, indices, G, F, Atom.Nucleus) + NewOperator("AU", NF, indices, G, F)
Line 182: Line 180:
 <code Quanty Example.Quanty> <code Quanty Example.Quanty>
 -- a confined basis for Fe: all orbitals up to 5s, 4p and 4d, the empty 4p and 4d contracted -- a confined basis for Fe: all orbitals up to 5s, 4p and 4d, the empty 4p and 4d contracted
-G, F, x, Atom = CalculateAtomicBasisFunctions(26, "[Ar] 3d6 4s2", {{"Method", "LDA"},+G, F, Atom = CalculateAtomicBasisFunctions(26, {{"Configuration", "[Ar] 3d6 4s2"}, {"Method", "LDA"},
   {"NMax", {s = 5, p = 4, d = 4}},   {"NMax", {s = 5, p = 4, d = 4}},
   {"Confinement", {Rho = 4, N = 8}},   {"Confinement", {Rho = 4, N = 8}},
Line 214: Line 212:
 ### ###
 The energies are those of the equation each function was calculated with, including its confinement and its extra charge. //Atom.Orbitals[i].EnergyGround// gives the energy of the returned function in the potential of the free atom. The energies are those of the equation each function was calculated with, including its confinement and its extra charge. //Atom.Orbitals[i].EnergyGround// gives the energy of the returned function in the potential of the free atom.
 +###
 +
 +===== The potentials =====
 +
 +###
 +//Atom.Potential// holds the potentials of the ground state as functions of $r$. Like the radial functions, $P(r) = r g(r)$, they are multiplied by $r$:
 +###
 +
 +  * //rVN// : $r V_N(r)$, the potential of the nucleus. It is $-Z$ for a point nucleus; for a finite nucleus it goes from 0 at the origin to $-Z$ outside the nucleus.
 +  * //rVH// : $r V_H(r)$, the Hartree potential of the electron density. It goes from 0 at the origin to the number of electrons $N$ far from the atom.
 +  * //rVxc// : $r V_{xc}(r)$, the exchange-correlation potential, only in density functional theory. For the gradient corrected functionals //"PBE"// and //"PBE-VWN"// it is the whole potential $\delta E_{xc}/\delta n(r)$, including the term with the gradient of the density. Hartree-Fock has no //rVxc//: its exchange is not a potential but an integral operator, different for every orbital.
 +
 +###
 +$r V(r)$ stays finite at the nucleus and becomes constant far from the atom, where $V$ itself diverges as $1/r$ or goes to 0 slowly. Each potential is a //BSpline// of the degree of the radial functions through its values on the radial points of the quadrature, //G[1].x//. It equals the numbers of the calculation on these points and interpolates between them. The three have the same points and degree, so their sum is again a //BSpline//, without approximation: //rVN + rVH + rVxc// is $r$ times the Kohn-Sham potential that every orbital feels.
 +###
 +
 +###
 +The derivative of a function $f(r) = r V(r)$ is $f'(r) = V(r) + r V'(r)$, not $V'(r)$. The derivative of the potential is
 +$$
 +V'(r) = \frac{f'(r) - f(r)/r}{r},
 +$$
 +with //f(r, 1)// for $f'(r)$. Like every interpolating function the potentials are 0 outside $[x_1, x_N]$, also beyond the last point, where $r V_N$ is still $-Z$.
 +###
 +
 +###
 +The potentials of Kr in LDA. $-r V(r)$ is the charge an electron at $r$ sees: the nucleus, screened by the electrons.
 +###
 +
 +<code Quanty Example.Quanty>
 +-- the potentials of the Kr atom in LDA, as r V(r)
 +G, F, Atom = CalculateAtomicBasisFunctions(36, {{"Configuration", "[Ar] 3d10 4s2 4p6"}, {"Method", "LDA"}})
 +V = Atom.Potential
 +print(V.rVN.type, V.rVN.degree, #V.rVN.x == #G[1].x)
 +
 +-- the charge an electron sees: the nucleus, screened by the electrons
 +ZNH = -(V.rVN + V.rVH)
 +ZKS = -(V.rVN + V.rVH + V.rVxc)
 +print("    r    -r(V_N+V_H)   -r V_KS")
 +for _, r in ipairs({0.001, 0.01, 0.1, 0.5, 1, 2, 4, 8}) do
 +  print(string.format("%6.3f  %10.5f  %10.5f", r, ZNH(r), ZKS(r)))
 +end
 +
 +eV = 27.211386
 +for _, o in ipairs(Atom.Orbitals) do
 +  if o.Label == "4p3/2" then print(string.format("energy of the 4p3/2 orbital %.3f eV", o.Energy*eV)) end
 +end
 +
 +-- the plot on a logarithmic r axis
 +function Curve(f)
 +  local c = {}
 +  for i = 0, 500 do local t = -3 + i*4.5/500; c[i+1] = {t, f(10^t)} end
 +  return c
 +end
 +pl = Graphics.Plot({Curve(ZNH), Curve(ZKS), {{-3, 1}, {1.5, 1}}},
 +       {{"plotIm", false},
 +        {"Frame", {{"Xmin", -3}, {"Xmax", 1.5}, {"Ymin", 0}, {"Ymax", 37}, {"FirstXTick", -3}, {"dXTick", 1}, {"FirstYTick", 0}, {"dYTick", 5},
 +                   {"XFormat", "%.0f"}, {"YFormat", "%.0f"}, {"XLabel", "log10(r/bohr)"}, {"YLabel", "-r V(r)"}, {"XLMargin", 0.1}, {"YAxis", -10}}}})
 +file = io.open("atomic_potentials.svg", "w")
 +file:write(Graphics.ToSVG(pl, {{"RelativeSize", true}}))
 +file:close()
 +</code>
 +
 +<file Quanty_Output Example.out>
 +BSpline 8 true
 +    r    -r(V_N+V_H)   -r V_KS
 + 0.001    35.81293    35.84639
 + 0.010    34.18424    34.44019
 + 0.100    23.89042    24.62054
 + 0.500     7.89282     9.04174
 + 1.000     3.27177     4.17051
 + 2.000     0.61982     1.56722
 + 4.000     0.01626     0.54163
 + 8.000     0.00001     0.09413
 +energy of the 4p3/2 orbital -9.179 eV
 +</file>
 +
 +{{ :documentation:language_reference:functions:atomic_potentials.png?nolink&600 |}}
 +
 +###
 +The black curve, $-r(V_N + V_H)$, goes from $Z = 36$ at the nucleus to $Z - N = 0$ for the neutral atom. The red curve includes the exchange-correlation potential. Far from the atom an electron sees the positive ion that remains, and the exact Kohn-Sham potential goes to $-1/r$: $-r V$ goes to 1 (the blue line). The LDA potential goes to 0 exponentially instead, because the Hartree potential contains the interaction of every electron with itself, and LDA removes this only in part. The outer electrons are therefore bound too weakly: the energy of the 4p orbital is $-9.2$ eV, while the ionization energy of Kr is 14.0 eV.
 +###
 +
 +###
 +The derivative gives the spin-orbit coupling of a nonrelativistic calculation, from the Kohn-Sham potential $V$,
 +$$
 +\zeta_{nl} = \frac{1}{2c^2} \int_0^\infty P_{nl}(r)^2 \, \frac{1}{r} \frac{\mathrm{d}V}{\mathrm{d}r} \, \mathrm{d}r,
 +$$
 +here for the 3d shell of Ni. The integrand is made into an interpolating function through the radial points of the quadrature, //x = G[1].x//, and integrated.
 +###
 +
 +<code Quanty Example.Quanty>
 +-- the spin-orbit coupling of the Ni 3d shell from the derivative of the potential
 +G, F, Atom = CalculateAtomicBasisFunctions(28, {{"Configuration", "[Ar] 3d8 4s2"}, {"Method", "LDA"}, {"Relativistic", false}})
 +x = G[1].x
 +c = Atom.c
 +rV = Atom.Potential.rVN + Atom.Potential.rVH + Atom.Potential.rVxc
 +for i, label in ipairs(Atom.Labels) do if label == "3d" then d = i end end
 +-- zeta = 1/(2c^2) int P^2 (1/r) dV/dr dr, with (1/r) dV/dr = (f'(r) - f(r)/r)/r^2 for f = r V
 +P, f, df = G[d](x), rV(x), rV(x, 1)
 +y = {}
 +for i = 1, #x do y[i] = P[i]^2*(df[i] - f[i]/x[i])/x[i]^2/(2*c*c) end
 +zeta = InterpolatingFunction.Integrate(InterpolatingFunction.BSpline(x, y, 8))
 +
 +G, F, Dirac = CalculateAtomicBasisFunctions(28, {{"Configuration", "[Ar] 3d8 4s2"}, {"Method", "LDA"}})
 +eV = 27.211386
 +print(string.format("zeta(3d) = %.4f eV from the Schroedinger potential, %.4f eV from the Dirac calculation", zeta*eV, Dirac.Zeta["3d"]*eV))
 +</code>
 +
 +<file Quanty_Output Example.out>
 +zeta(3d) = 0.0974 eV from the Schroedinger potential, 0.0962 eV from the Dirac calculation
 +</file>
 +
 +###
 +The two agree to about 1 %. The Dirac value comes from the splitting of the $3d_{3/2}$ and $3d_{5/2}$ energies and includes the relativistic change of the 3d function.
 ### ###
  
Line 224: Line 336:
 ===== Table of contents ===== ===== Table of contents =====
 {{indexmenu>.#1}} {{indexmenu>.#1}}
 +
  
Print/export