Initialize printing:


```
%pylab inline
from sympy.interactive.printing import init_printing
init_printing()
```

    
    Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
    For more information, type 'help(pylab)'.


# Poisson Equation

Radial Poisson equation is
$$
\phi''(r)+{2\over r} \phi'(r) = -4\pi\rho(r).
$$
Alternatively, this can also be written as:
$$
{1\over r}(r \phi(r))'' = -4\pi\rho(r).
$$
### Example I

Positive Gaussian charge density:


```
from sympy import var, exp, pi, sqrt, integrate, refine, Q, oo, Symbol, DiracDelta
var("r alpha Z")
alpha = Symbol("alpha", positive=True)
rho = Z * (alpha / sqrt(pi))**3 * exp(-alpha**2 * r**2)
rho
```

The total charge is $Z$:


```
integrate(4*pi*rho*r**2, (r, 0, oo))
```

Solve for $\phi(r)$ from the Poisson equation:


```
phi = integrate(-4*pi*rho*r, r, r)/r
phi
```

Tell SymPy that $\alpha$ is positive:


```
phi = refine(phi, Q.positive(alpha))
phi
```

Plot the charge:


```
from sympy import plot
```


```
plot(rho.subs({Z: 1, alpha: 0.1}), (r, 0, 100));
```

Plot the potential


```
plot(phi.subs({Z: 1, alpha: 0.1}), 1/r, (r, 0, 100), ylim=[0, 0.12]);
```


```

```

643187d55934abb07a78ee72efc7bc9071c58aca
ipynb
Jupyter Notebook
tutorial_exercises/Poisson equation.ipynb
certik/scipy-2013-tutorial
26a1cab3a16402afdc20088cedf47acd9bc58483
BSD-3-Clause
2015-02-28T08:53:05.000Z
2021-12-05T05:37:59.000Z
sympy/Poisson equation.ipynb
certik/scipy-in-13
418c139ab6e1b0c9acd53e7e1a02b8b930005096
BSD-3-Clause
2021-04-17T15:05:46.000Z
2021-04-17T15:05:46.000Z
sympy/Poisson equation.ipynb
certik/scipy-in-13
418c139ab6e1b0c9acd53e7e1a02b8b930005096
BSD-3-Clause
2015-03-11T00:25:21.000Z
2021-08-25T14:52:40.000Z
Qwen/Qwen-72B
1. YES
2. YES