<jupyter_start><jupyter_text>Potentialfeld und Vektorfeld*** Wir definieren uns als Potentialfunktion $U(x,y)$ die *inverse Länge*:$$U(x,y,z) = {{1} \over {r}} = {{1} \over {\sqrt{(x-x_0)^2 + (y-y_0)^2 + (z-z_0)^2}}} $$mit $(x_0,y_0,z_0)^T$ der Punktquelle des Potentials, und $(x,y,z)^T$ dem Beobachtungspunkt. Setzen wir den Ursprung des Potentials in den Ursprung des Koordinatensystems, $(x_0,y_0,z_0)^T=(0,0,0)^T$, dann gilt:$$U(x,y,z) = {{1} \over {r}} = {{1} \over {\sqrt{x^2 + y^2 + z^2}}} $$ Die Vektorfunktion $\vec{F}(x,y)$ definieren wir als Gradienten des Potentials:$$\vec{F}(x,y) = \nabla U= \left(\begin{array}{c} {{\partial} \over {\partial x}} \\                  {{\partial} \over {\partial y}} \\                  {{\partial} \over {\partial z}} \end{array}\right) \left( {{1} \over {r}} \right)= \left(\begin{array}{c} {{\partial} \over {\partial x}} \\                  {{\partial} \over {\partial y}} \\                  {{\partial} \over {\partial z}} \end{array}\right) \left( x^2 + y^2 + z^2 \right)^{-{{1} \over {2}}}= \left(\begin{array}{c}-{{1} \over {2}} (x^2+y^2+z^2)^{-{{3} \over {2}}} 2x \\-{{1} \over {2}} (x^2+y^2+z^2)^{-{{3} \over {2}}} 2y \\-{{1} \over {2}} (x^2+y^2+z^2)^{-{{3} \over {2}}} 2z\end{array}\right)= \left(\begin{array}{c}-{{x} \over {r^3}} \\-{{y} \over {r^3}} \\-{{z} \over {r^3}}\end{array}\right)= - {{\vec{r}} \over {r^3}}= - {{\hat{r}} \over {r^2}}$$Im letzten Schritt haben wir den *Einheitsvektor* $\hat{r}={{\vec{r}}\over{r}}$, derdie Länge eins hat, eingeführt. Die Definition von Potentialfeld $U$ und Vektorfeld $\vec{F}$ ist eine Beschreibung für so unterschiedliche Felder wie- **Gravitationsfeld**: $\vec{g}=\nabla U$$$\begin{array}{rcl}U       &=& {{GM}\over{r}} \\\vec{g} &=& -{{GM}\over{r^2}} \hat{r}\end{array}$$- **Elektrisches Feld**: $\vec{E}=-\nabla U$$$\begin{array}{rcl}U       &=& {{1}\over{4\pi \epsilon_0}} {{Q}\over{r}} \\\vec{E} &=& {{1}\over{4\pi \epsilon_0}} {{Q}\over{r^2}} \hat{r}\end{array}$$- **Magnetisches Feld**: $\vec{B}=-\nabla U$$$\begin{array}{rcl}U       &=& {{\mu_0}\over{4\pi}} {{P}\over{r}} \\\vec{B} &=& {{\mu_0}\over{4\pi}} {{P}\over{r^2}} \hat{r}\end{array}$$ |Symbol      |Einheit          |Wert                            | Bezeichnung                ||------------|-----------------|--------------------------------|----------------------------||$G$         |m$^3$/kg/s$^2$   |$6.67408 \times 10^{-11}$       | Gravitationskonstante      ||$M$         |kg               |$5.972 \times 10^{24}$          | Masse der Erde             ||$\epsilon_0$|Am/(Vs)          |$8.854 \times 10^{-12}$         | elektrische Permittivität  ||$\mu_0$     |Vs/(Am)          |$4\pi \times 10^{-7}$           | magnetische Permeabilität  |<jupyter_code>%matplotlib inline
'''
calculate scalar potential U in x-y-plane
and derive vector field (Ex,Ey) from nabla(U)
'''
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
# gravitational constant [m3/kg/s2], Earth's mass [kg]
g, mass = 6.67408e-11, 5.972e24
# Dipole charge (C), Permittivity of free space (F.m-1), Dipole +q, -q distance (m)
q, eps0,d = +1.602e-19, 8.854e-12, 1.e-12
# scaling for potential
kgrav     = g*mass
kmonopole = 1/4/np.pi/eps0 * q #* d
k         = 1.

# Cartesian axis system with origin at the dipole (m)
size = 1.5
X = np.linspace(-size, size, 40)
Y = np.linspace(-size, size, 40)
# re-mesh for 2D plot
X, Y = np.meshgrid(X, Y)
# calculate angle T for unit vector components
T = np.arctan2(Y, X)
# calculate R=sqrt(Y**2+Y**2)
R = np.hypot(X,Y)

# Dipole potential (V), using point dipole approximation
U = k * X / np.hypot(X, Y)**3
# Monopole potential (V)
U = k / R
Ey, Ex = np.gradient(U)
Ex, Ey = -1*Ex,-1*Ey
#Ex, Ey = k/R**2 * np.cos(T), k/R**2 * np.sin(T)
E_norm = np.sqrt(Ex**2 + Ey**2)

# define levels for contours and colormap for vector magnitudes
levels = np.array([10**pw for pw in np.linspace(-1,2,7)])
levels = sorted(list(-levels) + list(levels))
cmap = cm.get_cmap(name='nipy_spectral', lut=None)
# plot figure for potential and vector field
plt.figure(figsize=(10.0,10.0))
plt.title('Potential and vector field')
CS = plt.contour(X, Y, U,colors='k',levels=levels)
plt.clabel(CS, inline=1, fontsize=10,fmt='%8.1f')
plt.quiver(X, Y, Ex/E_norm, Ey/E_norm, E_norm, alpha=.5,scale=40)
plt.quiver(X, Y, Ex/E_norm, Ey/E_norm,edgecolor='k', facecolor='None', linewidth=.5,color='blue',scale=40)
plt.show()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup