## Matrix-Darstellung und Basissätze ### Diskretisierung ############################################################## Schrödinger-Gleichung - Differentialgleichung für $\psi(\mathbf{r})$ - Funktion: unendlich viele Werte - Rechner: endlich viele Zahlen Idee - Funktion als Vektor bezüglich einer Basis - Operator als Matrix - Differentialgleichung $\Rightarrow$ lineare Algebra - Näherung (!) Vektor in 2D - Basis $\mathbf{a}_1, \mathbf{a}_2$, nicht notwendig orthogonal - $\mathbf{v}$ vollständig durch $(c_1, c_2)$ beschrieben -|- ```plot: a1 = np.array([1.0, 0.0]) a2 = np.array([0.6, 0.8]) c1, c2 = 1.5, 1.2 v = c1*a1 + c2*a2 fig, ax = plt.subplots() def arrow(start, end, color, lw=2.5): ax.annotate('', xy=end, xytext=start, arrowprops=dict(arrowstyle='-|>', color=color, lw=lw, mutation_scale=20)) arrow((0, 0), c1*a1, 'C0', lw=1) arrow((0, 0), c2*a2, 'C1', lw=1) ax.plot([c1*a1[0], v[0]], [c1*a1[1], v[1]], 'C1--', lw=1) ax.plot([c2*a2[0], v[0]], [c2*a2[1], v[1]], 'C0--', lw=1) arrow((0, 0), a1, 'C0') arrow((0, 0), a2, 'C1') arrow((0, 0), v, 'k') ax.text(0.45, -0.2, r'$\mathbf{a}_1$', color='C0', fontsize=16) ax.text(0.05, 0.5, r'$\mathbf{a}_2$', color='C1', fontsize=16) ax.text(v[0] - 0.3, v[1] + 0.12, r'$\mathbf{v} = c_1\mathbf{a}_1 + c_2\mathbf{a}_2$', fontsize=16) ax.set_xlim(-0.2, 3.0) ax.set_ylim(-0.3, 1.4) ax.set_aspect('equal') ax.axis('off') plt.tight_layout() ``` ### Funktionen als Vektoren $$\psi(\mathbf{r}) = \sum_{\mu=1}^{N} {c_\mu}\,{\phi_\mu(\mathbf{r})} \quad\Leftrightarrow\quad \mathbf{c} = (c_1,\ldots,c_N)^T$$ [[ {c_\mu} ]] Gewicht [[ {\phi_\mu(\mathbf{r})} ]] Basisfunktion [[ N ]] Anzahl Basisfunktionen $$S_{\mu\nu} = \langle\phi_\mu|\phi_\nu\rangle \neq \delta_{\mu\nu}$$ [[ S_{\mu\nu} ]] Überlappmatrixelement -|- ```plot: x = np.linspace(-6, 6, 800) f = (1 + 0.6*x) * np.exp(-0.25*x**2) mu = np.linspace(-4, 4, 7) G = np.exp(-0.8*(x[:, None] - mu[None, :])**2) c = np.linalg.lstsq(G, f, rcond=None)[0] fig, ax = plt.subplots() for k in range(len(mu)): ax.plot(x, c[k]*G[:, k], '-', lw=2, color=f'C{k}', label=f'$\\phi_{k}$') ax.plot(x, G @ c, 'k', lw=1.5, label=r'$\psi$') ax.axhline(0, color='gray', lw=0.5) ax.set_xlabel(r'$x$') ax.set_ylabel(r'$\psi(x)$') ax.set_xticks([]) ax.set_yticks([]) ax.set_ylim(top=1.9*np.max(G @ c)) ax.legend(loc='upper right', ncol=2) ins = ax.inset_axes([0.06, 0.55, 0.3, 0.4]) for k in range(len(mu)): ins.bar(k+1, c[k], color=f'C{k}', alpha=0.3) ins.bar(k+1, c[k], fill=False, edgecolor=f'C{k}', lw=1) ins.axhline(0, color='gray', lw=0.5) for s in ins.spines.values(): s.set_visible(False) ins.set_xticks([]) ins.set_yticks([0]) ins.tick_params(labelsize='small') ins.set_title(r'$c_\mu$', fontsize='small') plt.tight_layout() ``` ### Operatoren als Matrizen Einsetzen in $\widehat{H}\psi = E\psi$ $$\sum_\nu c_\nu\,\widehat{H}\phi_\nu = E\sum_\nu c_\nu\,\phi_\nu$$ Projektion: von links $\langle\phi_\mu|$ $$\sum_\nu {\langle\phi_\mu|\widehat{H}|\phi_\nu\rangle}\,c_\nu = E\sum_\nu {\langle\phi_\mu|\phi_\nu\rangle}\,c_\nu \quad \forall\,\mu$$ [[ {\langle\phi_\mu|\widehat{H}|\phi_\nu\rangle} ]] $H_{\mu\nu}$ [[ {\langle\phi_\mu|\phi_\nu\rangle} ]] $S_{\mu\nu}$ $$\mathbf{H}\,\mathbf{c} = E\,\mathbf{S}\,\mathbf{c}$$ [[ \mathbf{H} ]] Hamilton-Matrix $N\times N$ [[ \mathbf{S} ]] Überlappmatrix $N\times N$ [[ E ]] Eigenwert, Energie -|- Verallgemeinertes Eigenwertproblem - identisch zum Ritz-Verfahren - Lösung: Löwdin $\mathbf{S}^{-1/2}\mathbf{H}\,\mathbf{S}^{-1/2}$, dann diagonalisieren Eigenschaften - $\widehat{H}$ hermitesch $\Rightarrow$ $\mathbf{H}$ hermitesch - $N$ reelle Eigenwerte $E_1 \leq \ldots \leq E_N$ - $N$ Eigenvektoren: Grundzustand und angeregte Zustände ### Beispiel: harmonischer Oszillator ```plot: a = 1.0 xs = np.arange(-5, 6) * 0.8 D = xs[:, None] - xs[None, :] P = (xs[:, None] + xs[None, :]) / 2 m = a / 2 S = np.exp(-m*D**2) T = m*(1 - 2*m*D**2) * S V = 0.5*(P**2 + 1/(4*a)) * S s, U = np.linalg.eigh(S) X = U @ np.diag(s**-0.5) @ U.T E, C = np.linalg.eigh(X @ (T + V) @ X) C = X @ C x = np.linspace(-6, 6, 800) G = np.exp(-a*(x[:, None] - xs[None, :])**2) fig, ax = plt.subplots() ax.plot(x, 0.5*x**2, 'k', lw=2, label=r'$V$') for mu in range(len(xs)): ax.plot(x, 0.6*G[:, mu], color='gray', lw=0.8) for n in range(3): psi = G @ C[:, n] psi *= np.sign(psi[np.argmax(np.abs(psi))]) ax.axhline(E[n], color=f'C{n}', lw=0.5, ls=':') ax.plot(x, E[n] + 0.6*psi, color=f'C{n}', lw=2, label=rf'$E_{n}$') ax.set_xlim(-6, 6) ax.set_ylim(-0.1, 4.5) ax.set_xlabel(r'$x$') ax.set_ylabel(r'$E$') ax.legend(loc='upper center', ncol=2) plt.tight_layout() ``` -|- $$\widehat{H} = -\frac{1}{2}\frac{d^2}{dx^2} + \frac{1}{2}x^2 \qquad \phi_\mu(x) = e^{-(x-x_\mu)^2}$$ [[ x_\mu ]] Position Basis: Gauß-Funktionen - Eigenwerte: Energien $E_n$ - Eigenvektoren: Wellenfunktionen $$E_n = n + \frac{1}{2}$$ Höhere Zustände - reichen über die Basis hinaus - Basis nur im Bereich $|x| \lesssim 4$ ### Harmonischer Oszillator: Matrizen Harmonischer Oszillator, 11 Gauß-Funktionen ```plot: a = 1.0 xs = np.arange(-5, 6) * 0.8 D = xs[:, None] - xs[None, :] P = (xs[:, None] + xs[None, :]) / 2 m = a / 2 S = np.exp(-m*D**2) T = m*(1 - 2*m*D**2) * S V = 0.5*(P**2 + 1/(4*a)) * S H = T + V fig, axes = plt.subplots(1, 2) for ax, M, name in zip(axes, [S, H], [r'$\mathbf{S}$', r'$\mathbf{H}$']): vmax = np.abs(M).max() im = ax.imshow(M, cmap='RdBu_r', vmin=-vmax, vmax=vmax) ax.set_title(name) plt.colorbar(im, ax=ax, fraction=0.046) ax.set_xticks([]) ax.set_yticks([]) plt.tight_layout() ``` ### Eigenwerte und Basisgröße ```plot: def solve(xs, a=1.0): D = xs[:, None] - xs[None, :] P = (xs[:, None] + xs[None, :]) / 2 m = a / 2 S = np.exp(-m*D**2) H = m*(1 - 2*m*D**2)*S + 0.5*(P**2 + 1/(4*a))*S s, U = np.linalg.eigh(S) X = U @ np.diag(s**-0.5) @ U.T return np.linalg.eigvalsh(X @ H @ X) Nmax = 10 order = 0.8 * np.array([0] + [s*k for k in range(1, 8) for s in (1, -1)]) fig, ax = plt.subplots() for n in range(Nmax-1): ax.axhline(n + 0.5, color='gray', lw=0.5, ls='-') Es = [solve(order[:N]) for N in range(1, Nmax+1)] for n in range(Nmax): Ns = range(n+1, Nmax+1) En = [E[n] for E in Es[n:]] ax.fill_between(Ns, n + 0.5, En, color='C0', alpha=0.2, lw=0, label='BSIE' if n == 0 else None) ax.plot(Ns, En, 'o-', color='C0') ax.set_xlabel(r'Anzahl Basis-Funktionen $N$') ax.set_ylabel(r'Eigenwerte $E$') ax.set_xticks(range(1, Nmax+1)) ax.set_ylim(0, Nmax + 0.5) ax.legend(loc='upper left') plt.tight_layout() ``` -|- Basis schrittweise erweitern - Zentren $0,\ \pm 0.8,\ \pm 1.6,\ \ldots$ Beobachtung - jeder Eigenwert sinkt mit $N$ - stets oberhalb des exakten Werts - $N$ Funktionen: $N$ Eigenwerte - oberster Eigenwert stets am schlechtesten Basis Set Incompleteness Error (BSIE) - Frage: woher kommt Rest bei $n=6, 8, 9$? ### Endliche Basis Vollständige Basis - exakt - effizient: endliches $N$ Variationsprinzip - $E_1(N) \geq E_0$: obere Schranke - Basis orthogonal erweitern: $E_1$ sinkt monoton - Basissatzfehler: $E_1(N) - E_1(\infty)$ -|- Rechenaufwand - Matrixelemente: $\mathcal{O}(N^2)$ Integrale - Diagonalisierung: $\mathcal{O}(N^3)$ - Zwei-Elektronen-Integrale: $\mathcal{O}(N^4)$ --- Gute Basis - wenige Funktionen, schnelle Konvergenz - Integrale einfach - hier: atomzentrierte Funktionen [*] Vereinfacht, mehr dazu in Wahlpflicht *Computational Chemistry* ### Beispiel: H-Atom Basis aus $N$ s-Gauß-Funktionen $e^{-\alpha_\mu r^2}$, $\alpha_\mu = 0.05\cdot 3^{\mu-1}$ ```plot: def solve(alpha): a, b = alpha[:, None], alpha[None, :] p = a + b S = (np.pi/p)**1.5 H = 3*a*b/p * S - 2*np.pi/p s, U = np.linalg.eigh(S) X = U @ np.diag(s**-0.5) @ U.T e, C = np.linalg.eigh(X @ H @ X) return e[0], X @ C[:, 0] alpha_all = 0.05 * 3.0**np.arange(10) Ns = np.arange(1, 11) Es = [solve(alpha_all[:n])[0] for n in Ns] fig, axes = plt.subplots(1, 2) ax = axes[0] ax.plot(Ns, Es, 'o-', color='C0', lw=2) ax.axhline(-0.5, color='gray', ls='--', label=r'exakt $-\frac{1}{2}E_h$') ax.set_xlabel(r'Anzahl Gauß-Funktionen $N$') ax.set_ylabel(r'$E\;[E_h]$') ax.legend() ax = axes[1] r = np.linspace(0, 4, 400) ax.plot(r, np.exp(-r)/np.sqrt(np.pi), 'k', lw=3, label='exakt') for k, n in enumerate([1, 3, 6]): alpha = alpha_all[:n] c = solve(alpha)[1] psi = np.exp(-alpha[None, :]*r[:, None]**2) @ c psi *= np.sign(psi[0]) ax.plot(r, psi, color=f'C{k+1}', lw=1.5, label=rf'$N={n}$') ax.set_xlabel(r'$r\;[a_0]$') ax.set_ylabel(r'$\psi_{1s}(r)$') ax.legend() plt.tight_layout() ``` ### Slater vs. Gauß ```plot: r = np.linspace(0, 6, 600) sto = np.exp(-r) / np.sqrt(np.pi) a = 0.270950 gto = (2*a/np.pi)**0.75 * np.exp(-a*r**2) fig, axes = plt.subplots(1, 2) for ax in axes: ax.plot(r, sto, 'C0', lw=2, label=r'Slater $e^{-\zeta r}$') ax.plot(r, gto, 'C1', lw=2, label=r'Gauß $e^{-\alpha r^2}$') ax.set_xlabel(r'$r\;[a_0]$') axes[0].set_ylabel(r'$\phi(r)$') axes[0].annotate('Cusp', xy=(0, sto[0]), xytext=(0.8, 0.55), arrowprops=dict(arrowstyle='->')) axes[0].legend() axes[1].set_yscale('log') axes[1].set_ylim(1e-6, 1) axes[1].set_title('logarithmisch') plt.tight_layout() ``` ### Warum trotzdem Gauß? ```plot: x = np.linspace(-4, 4, 800) A, B, a, b = -1.0, 1.5, 1.0, 0.5 p = a + b P = (a*A + b*B) / p K = np.exp(-a*b/p*(A - B)**2) ga = np.exp(-a*(x - A)**2) gb = np.exp(-b*(x - B)**2) sa = np.exp(-np.abs(x - A)) sb = np.exp(-np.abs(x - B)) fig, axes = plt.subplots(2, 1, sharex=True) ax = axes[0] ax.plot(x, ga, 'C0', lw=1.5, label=r'$e^{-a(x-A)^2}$') ax.plot(x, gb, 'C1', lw=1.5, label=r'$e^{-b(x-B)^2}$') ax.plot(x, ga*gb, 'k', lw=3, label='Produkt') #ax.axvline(P, color='gray', ls=':', lw=1) #ax.set_title('Gauß: Produkt wieder Gauß') ax.set_ylim(top=1.45) ax.legend(loc='upper center', ncol=3) ax = axes[1] ax.plot(x, sa, 'C0', lw=1.5, label=r'$e^{-|x-A|}$') ax.plot(x, sb, 'C1', lw=1.5, label=r'$e^{-|x-B|}$') ax.plot(x, sa*sb, 'k', lw=3, label='Produkt') #ax.set_title('Slater: Produkt kein Slater') ax.set_xlabel(r'$x$') ax.set_ylim(top=1.45) ax.legend(loc='upper center', ncol=3) plt.tight_layout(h_pad=0.2) ``` -|- $$e^{-a(x-A)^2}\,e^{-b(x-B)^2} = e^{-\frac{ab}{p}(A-B)^2}\,e^{-p(x-P)^2}$$ [[ P ]] neues Zentrum zwischen $A$ und $B$ $$p = a+b \qquad P = \frac{aA+bB}{a+b}$$ Produkte effizient - Integrale über mehrere Zentren analytisch ### Winkelanteil Kartesische Gauß-Funktion $$\phi(\mathbf{r}) = {x^i\,y^j\,z^k}\,e^{-\alpha r^2} \qquad {l} = i+j+k$$ [[ {x^i\,y^j\,z^k} ]] Winkelanteil, Zentrum im Ursprung [[ \alpha ]] Exponent [[ {l} ]] Drehimpuls: $s$, $p$, $d$ für $0, 1, 2$ ```plot: x = np.linspace(-3, 3, 300) X, Z = np.meshgrid(x, x) G = np.exp(-0.7*(X**2 + Z**2)) funcs = [(G, r'$s$: $1$'), (Z*G, r'$p_z$: $z$'), (X*Z*G, r'$d_{xz}$: $xz$'), ((2*Z**2 - X**2)*G, r'$d_{z^2}$: $2z^2-x^2-y^2$')] fig, axes = plt.subplots(1, 4) for ax, (F, name) in zip(axes, funcs): vmax = np.abs(F).max() ax.contourf(X, Z, F, levels=np.linspace(-vmax, vmax, 21), cmap='RdBu_r') ax.contour(X, Z, F, levels=[0], colors='k', linewidths=0.8) ax.set_title(name) ax.set_aspect('equal') ax.set_xlabel(r'$x$') axes[0].set_ylabel(r'$z$') plt.tight_layout() ``` ### Exponenten: eng vs. diffus ```plot: r = np.linspace(0, 8, 600) alpha = 0.04 * 3.0**np.arange(4) fig, axes = plt.subplots(1, 2) ax = axes[0] for k, a in enumerate(alpha): ax.plot(r, np.exp(-a*r**2), color=plt.cm.viridis(k/(len(alpha)-1)), lw=2, label=rf'$\alpha={a:.2g}$') ax.set_xlabel(r'$r\;[a_0]$') ax.set_ylabel(r'$e^{-\alpha r^2}$') ax.set_title(r'eng $\leftarrow\;\to$ diffus') ax.legend(ncols=1) ax = axes[1] betas = np.linspace(1.05, 4, 200) smin = [] for beta in betas: a = 0.04 * beta**np.arange(7) p = a[:, None] + a[None, :] S = (np.pi/p)**1.5 d = np.sqrt(np.diag(S)) smin.append(np.linalg.eigvalsh(S / np.outer(d, d))[0]) ax.semilogy(betas, smin, 'C3', lw=2) ax.set_xlabel(r'Verhältnis $\alpha_{k+1}/\alpha_k$') ax.set_ylabel(r'kleinster Eigenwert von $\mathbf{S}$') plt.tight_layout() ``` ähnliche Exponenten: $\mathbf{S}$ fast singulär, lineare Abhängigkeit ### Basissätze für Eisen: d-Funktionen ```plot: def radial(alpha, d, r): alpha, d = np.array(alpha), np.array(d) N = alpha**1.75 R = (d*N*np.exp(-alpha[None, :]*r[:, None]**2)).sum(axis=1) * r**2 norm = np.sqrt(np.sum(R**2 * r**2) * (r[1] - r[0])) return R / norm r = np.linspace(1e-4, 6, 2000) a = [6.411803475, 1.955804428, 0.7546101508] ds = [[0.2197679508, 0.6555473627, 0.2865732590]] fig, ax = plt.subplots() for k, d in enumerate(ds): ax.plot(r, radial(a, d, r), color=f'C{k}', lw=2, label=rf'$\phi_{{{k+1}}}$') ax.axhline(0, color='gray', lw=0.5) ax.set_title('STO-3G: 1 d-Funktion') ax.set_xlabel(r'$r\;[a_0]$') ax.set_ylabel(r'$R(r)$') ax.set_ylim(-2, 2.6) ax.set_xlim(0, 4) ax.legend() plt.tight_layout() ``` -|- ```plot: def radial(alpha, d, r): alpha, d = np.array(alpha), np.array(d) N = alpha**1.75 R = (d*N*np.exp(-alpha[None, :]*r[:, None]**2)).sum(axis=1) * r**2 norm = np.sqrt(np.sum(R**2 * r**2) * (r[1] - r[0])) return R / norm r = np.linspace(1e-4, 6, 2000) a = [113.344, 33.6414, 12.331, 4.99478, 2.0728, 0.830753, 0.309178, 0.10013] ds = [[0.00353, 0.025784, 0.099119, 0.239073, 0.357199, 0.362188, 0.236461, 0.060118], [-0.00389, -0.028442, -0.112429, -0.274257, -0.315546, 0.057109, 0.563604, 0.384637], [0.005695, 0.042001, 0.17354, 0.410157, 0.113252, -0.76968, -0.031643, 0.713797], [0, 0, 0, 0, 0, 0, 0, 1]] fig, ax = plt.subplots() for k, d in enumerate(ds): ax.plot(r, radial(a, d, r), color=f'C{k}', lw=2, label=rf'$\phi_{{{k+1}}}$') ax.axhline(0, color='gray', lw=0.5) ax.set_title('cc-pVTZ: 4 d-Funktionen') ax.set_xlabel(r'$r\;[a_0]$') ax.set_ylabel(r'$R(r)$') ax.set_ylim(-2, 2.6) ax.set_xlim(0, 4) ax.legend(ncols=2, loc="upper right") plt.tight_layout() ``` [*] Beispiele an Basissätzen, Namensgebung hier nicht relevant ### ? Zusammenfassung ################################################################## Matrix-Darstellung - Funktion $\to$ Vektor $\mathbf{c}$ - Operator $\to$ Matrix $\mathbf{H}$ - $\mathbf{H}\,\mathbf{c} = E\,\mathbf{S}\,\mathbf{c}$ Endliche Basis - obere Schranke, Basissatzfehler - Aufwand $\mathcal{O}(N^3)$ bis $\mathcal{O}(N^4)$ -|- Gauß-Funktionen - Form schlechter als Slater - Integrale analytisch: Produkttheorem Basissätze - Winkelanteil $s, p, d, \ldots$; Exponenten eng bis diffus - verschiedene Größen nach Anwendungsfall (Details später)