# Hydrogen atom

\begin{equation}
\label{eq1}
-\frac{\hbar^2}{2 \mu} \left[ \frac{1}{r^2} \frac{\partial }{\partial r} \left( r^2 \frac{ \partial \psi}{\partial r}\right) + \frac{1}{r^2 \sin \theta} \frac{\partial }{\partial \theta} \left( \sin \theta \frac{\partial \psi}{\partial \theta}\right) + \frac{1}{r^2 \sin^2 \theta} \frac{\partial^2 \psi}{\partial \phi^2} \right] - \frac{e^2}{ 4 \pi \epsilon_0 r} \psi= E \psi
\end{equation}


\begin{equation}
\label{eqsol1}
\psi_{n\ell m}(r,\vartheta,\varphi) = \sqrt {{\left (  \frac{2}{n a^*_0} \right )}^3 \frac{(n-\ell-1)!}{2n(n+\ell)!}} e^{- \rho / 2} \rho^{\ell} L_{n-\ell-1}^{2\ell+1}(\rho) Y_{\ell}^{m}(\vartheta, \varphi ) 
\end{equation}



```python
import k3d
from ipywidgets import interact, FloatSlider

import numpy as np
import scipy.special
import scipy.misc

r = lambda x,y,z: np.sqrt(x**2+y**2+z**2)
theta = lambda x,y,z: np.arccos(z/r(x,y,z))
phi = lambda x,y,z: np.arctan2(y,x)

a0 = 1.
R = lambda r,n,l: (2*r/(n*a0))**l * np.exp(-r/n/a0) * scipy.special.genlaguerre(n-l-1,2*l+1)(2*r/n/a0)
WF = lambda r,theta,phi,n,l,m: R(r,n,l) * scipy.special.sph_harm(m,l,phi,theta)
absWF = lambda r,theta,phi,n,l,m: abs(WF(r,theta,phi,n,l,m)).astype(np.float32)**2
N = 50j
a = 30.0
x,y,z = np.ogrid[-a:a:N,-a:a:N,-a:a:N]
x = x.astype(np.float32)
y = y.astype(np.float32)
z = z.astype(np.float32)
```


```python
orbital = WF(r(x,y,z),theta(x,y,z),phi(x,y,z),4,1,0).real.astype(np.float32) # 4p
```


```python
plt_vol = k3d.volume(orbital)
plt_label = k3d.text2d(r'n=1\; l=0\; m=0',(0.,0.))
plot = k3d.plot()
plot += plt_vol
plot += plt_label

plt_vol.opacity_function  = [0.        , 0.        , 0.21327923, 0.98025   , 0.32439035,
       0.        , 0.5       , 0.        , 0.67560965, 0.        ,
       0.74537706, 0.9915    , 1.        , 0.        ]

plt_vol.color_map = k3d.colormaps.paraview_color_maps.Cool_to_Warm_Extended
plt_vol.color_range = (-0.5,0.5)



plot.display()
```

## animation 
### single wave function is sent at a time


```python
E = 4
for l in range(E):
    for m in range(-l,l+1):
        psi2 = WF(r(x,y,z),theta(x,y,z),phi(x,y,z),E,l,m).real.astype(np.float32)
        plt_vol.volume =  psi2/np.max(psi2)
        plt_label.text = 'n=%d \quad l=%d \quad m=%d'%(E,l,m)
    

```

### using time series 

 - series of volumetric data are sent to k3d, 
 - player interpolates between  


```python
E = 4
psi_t = {}
t = 0.0
for l in range(E):
    for m in range(-l,l+1):
        
        psi2 = WF(r(x,y,z),theta(x,y,z),phi(x,y,z),E,l,m)
        psi_t[str(t)] = (psi2.real/np.max(np.abs(psi2))).astype(np.float32)
        t += 0.3    
plt_vol.volume = psi_t    

```


```python

```


```python

```

e7a7ce2b57edc31264c90ebd4ed5524169347c6f
ipynb
Jupyter Notebook
atomic_orbitals_wave_function.ipynb
OpenDreamKit/k3d_demo
1281b2944f5ca9b16ee3b7b2249f4d8a5baf0067
MIT
2020-09-17T18:25:55.000Z
2020-09-17T18:25:55.000Z
atomic_orbitals_wave_function.ipynb
OpenDreamKit/k3d_demo
1281b2944f5ca9b16ee3b7b2249f4d8a5baf0067
MIT
atomic_orbitals_wave_function.ipynb
OpenDreamKit/k3d_demo
1281b2944f5ca9b16ee3b7b2249f4d8a5baf0067
MIT
2020-04-24T13:37:54.000Z
2021-03-03T08:54:13.000Z
Qwen/Qwen-72B
1. YES
2. YES