Below is a “from–first-principles” walk-through of how a static, uniform magnetic field is introduced into a quantum-chemical (DFT) calculation and how the shielding constant becomes a second derivative of the electronic energy.
(You will see that we never actually “dial-up” the field in the program; instead the code builds analytic first- and second-order operators that contain the field symbolically.)
- Start with the field–free electronic Hamiltonian
For an (N)-electron molecule (atomic units, (\hbar = m_e = e = 1))
( \displaystyle
\hat H^{(0)} = \sum_{i=1}^{N} \frac{\mathbf{p}i^{,2}}{2} ; + ; V{\text{ne}}(\mathbf{r}) ; + ; V_{\text{ee}}(\mathbf{r})
)
- Minimal-coupling substitution: (\mathbf{p} \rightarrow \mathbf{p}+ \mathbf{A}(\mathbf{r}))
Place the molecule in a static magnetic field (\mathbf{B}).
Introduce the vector potential (\mathbf{A}) such that (\nabla !\times! \mathbf{A} = \mathbf{B}).
For a uniform field the simplest choice is the symmetric (Coulomb) gauge
( \mathbf{A}(\mathbf{r}) ;=; \tfrac12 , \mathbf{B} \times \mathbf{r}. )
Insert (\mathbf{A}) wherever momentum appears:
( \displaystyle
\hat H(\mathbf{B}) = \sum_i \frac{1}{2}\bigl[\mathbf{p}i + \mathbf{A}(\mathbf{r}i)\bigr]^2
+ V{\text{ne}} + V{\text{ee}}
;+; \hat H_{\text{spin}}(\mathbf{B}),
)
where ( \hat H_{\text{spin}} = - g_s \mu_B \sum_i \mathbf{S}_i !\cdot! \mathbf{B}) is the (usually small for NMR) electron spin–Zeeman term.
Expand the square:
( \hat H(\mathbf{B}) = \hat H^{(0)}
+ \underbrace{\tfrac12 \sum_i \bigl(\mathbf{p}i!\cdot!\mathbf{A}
+ \mathbf{A}!\cdot!\mathbf{p}i \bigr)}{\text{linear in } \mathbf{B}}
+ \underbrace{\tfrac12 \sum_i \mathbf{A}^2}{\text{quadratic in } \mathbf{B}} .)
The linear piece is called the paramagnetic term, the quadratic one the diamagnetic term.
Those are the pieces that the program needs for first- and second-order perturbation theory.
- Add the perturbation from a nuclear magnetic dipole
Each nucleus (I) with magnetic moment (\boldsymbol{\mu}_I) also generates a tiny vector potential
( \displaystyle
\mathbf{A}_I(\mathbf{r}) = \frac{\boldsymbol{\mu}_I \times (\mathbf{r}-\mathbf{R}_I)}
{|\mathbf{r}-\mathbf{R}_I|^3}.
)
Treating (\boldsymbol{\mu}_I) as a perturbation yields an operator
( \hat V(\boldsymbol{\mu}_I) = \sum_i
\bigl(\mathbf{p}_i !\cdot! \mathbf{A}_I + \mathbf{A}_I!\cdot!\mathbf{p}_i \bigr)/2. )
- Why the shielding is a cross derivative
The isotropic shielding constant is defined (Ramsey 1950) as the mixed second derivative of the electronic energy with respect to the external field and the nuclear dipole:
( \sigma_{I,\alpha\beta} =
\Bigl.\frac{\partial^2 E(\mathbf{B},\boldsymbol{\mu}I)}
{\partial B\alpha ,\partial \mu_{I,\beta}}\Bigr|_{\mathbf{B}=0,\ \boldsymbol{\mu}_I=0}. )
Mathematically you can think of this as:
- Turn on an infinitesimal nuclear dipole → electrons feel a vector potential ( \mathbf{A}_I).
- Now see how the energy change produced by that dipole itself varies when you add a small uniform field (\mathbf{B}).
(Or vice versa; mixed derivatives commute.)
- How codes evaluate the derivative without brute-force fields
A modern DFT program builds the explicit operators corresponding to
( \partial \hat H / \partial \mathbf{B}) and ( \partial \hat H / \partial \boldsymbol{\mu}_I ) from the formulas above and then solves the Coupled-Perturbed Kohn–Sham (CPKS) equations:
(variation of KS orbitals) + (field-dependent operators) = 0.
The outcome is:
• First-order change of each KS orbital with respect to ( \mathbf{B} ) and to ( \boldsymbol{\mu}_I ).
• Matrix elements like
( \langle \psi_i^{(0)} | \partial \hat H/\partial \mathbf{B} | \psi_j^{(1,\mu)}\rangle )
that feed the shielding formula (Ramsey’s two-term expression).
No finite-difference ΔB is needed; everything is analytic.
- Gauge problem & solution: London / GIAO basis functions
With a vector potential the Hamiltonian depends on the chosen origin.
To keep energies gauge-origin invariant we multiply each AO basis function by a field-dependent phase factor (London 1937):
( \chi_\mu^{\text{GIAO}}(\mathbf{r}) ;=; \exp!\bigl[-\tfrac{i}{2},(\mathbf{B}\times\mathbf{R}\mu)!\cdot!\mathbf{r}\bigr] ,
\chi\mu(\mathbf{r}). )
Because these “Gauge-Including Atomic Orbitals” already carry the correct linear dependence on (\mathbf{B}), the diamagnetic and paramagnetic pieces combine properly, eliminating origin artifacts.
- Putting it all together
Step-by-step inside the code:
- Read optimized geometry.
- Build standard KS matrices (field-free).
- Build derivative matrices
• ( \mathbf{h}^{(B)} = \partial \mathbf{H}/\partial B_\alpha)
• ( \mathbf{h}^{(\mu_I)} = \partial \mathbf{H}/\partial\mu_{I,\beta})
using GIAO integrals.
- Solve CPKS for the first-order density matrices
( \mathbf{P}^{(B)} ) and ( \mathbf{P}^{(\mu_I)}).
- Contract them to obtain the mixed second derivative (shielding tensor).
- Take its trace → isotropic shielding → convert to chemical shift.
All of this is fully analytic and runs in one “NMR” job step; no external loop over different B-field values is needed.
Key take-aways
• The magnetic field enters through the vector potential ( \mathbf{A}(\mathbf{r})).
• Minimal-coupling gives operators linear and quadratic in ( \mathbf{B}).
• Gauge origin problems are solved with London / GIAO orbitals.
• The shielding is the mixed second derivative of the total electronic energy with respect to ( \mathbf{B}) and the nuclear dipole (\boldsymbol{\mu}_I).
• Programs evaluate those derivatives analytically via CPKS rather than numerically by actually applying a finite field.
Hope this clarifies where the magnetic field hides inside a DFT-NMR calculation and how the second derivative gets evaluated! 🎯