利用Python绘制电子云图样
时间: 2023-06-20 14:09:34 浏览: 100
例。
好的,以下是利用 Python 绘制电子云图的示例代码:
``` python
import numpy as np
import matplotlib.pyplot as plt
# 电子云的半径
r = [1.0, 0.5, 0.3]
# 电子云的位置
x = [2.0, -1.0, 0.5]
y = [-1.0, 0.5, 1.0]
xrange = np.linspace(-5, 5, 200)
yrange = np.linspace(-5, 5, 200)
# 创建二维坐标系
x, y = np.meshgrid(xrange,yrange)
# 计算每个点的电子云密度
z = np.zeros_like(x)
for i in range(len(r)):
z += 1 / (2 * np.pi)**(3/2) / r[i]**3 * np.exp(-(x-x[i])**2/2/r[i]**2) * \
np.exp(-(y-y[i])**2/2/r[i]**2)
# 绘制等密度线
levels = np.linspace(0, np.max(z), 50)
plt.contourf(x, y, z, levels=levels, cmap='hot')
plt.show()
```
运行以上代码,即可得到绘制的电子云图。请注意,此处绘制的电子云仅为示例,具体电子云的形态和密度应根据实际情况进行调整。
相关问题
利用Python绘制氢原子3d态电子云图样
好的,我可以回答您的问题。您可以使用Python中的matplotlib和mayavi库来绘制氢原子3D态电子云图样。具体实现方式是,先用Python计算氢原子的波函数,然后利用计算结果生成3D态电子云图样。以下是示例代码:
```python
import numpy as np
from mayavi import mlab
# 计算氢原子的波函数
def psi(n, l, m, rho, phi, theta):
a0 = 1
R_nl = np.sqrt((2 / n / a0) ** 3 * np.math.factorial(n - l - 1) / 2 / n / np.math.factorial(n + l) ** 3) * np.exp(-rho / n / a0) * (2 * rho / n / a0) ** l * np.polyval(np.poly1d(np.array([(-1) ** (n - l - 1) / np.math.factorial(n - l - 1)]) * np.math.factorial(n + l) / (2 * l + 1) / np.math.factorial(n) / (n - l - 1 - m + np.array(range(1, n - l)))), rho / n / a0)
Y_lm = np.sqrt((2 * l + 1) / 4 / np.pi * np.math.factorial(l - m) / np.math.factorial(l + m)) * np.real(np.exp(1j * m * phi) * np.math.cos(theta) ** m * np.math.sin(theta) ** l)
return R_nl * Y_lm
# 生成3D态电子云图样
def draw_wf(n, l, m):
n_points = 100
rho_max = 50
phi_max = 2 * np.pi
theta_max = np.pi
rho, phi, theta = np.mgrid[0:rho_max:n_points * 1j, 0:phi_max:n_points * 1j, 0:theta_max:n_points * 1j]
wf = psi(n, l, m, rho, phi, theta)
# 绘制3D态电子云图样
fig = mlab.figure()
mlab.contour3d(rho * np.math.sin(theta) * np.math.cos(phi), rho * np.math.sin(theta) * np.math.sin(phi), rho * np.math.cos(theta), abs(wf))
mlab.axes()
mlab.colorbar()
mlab.title('Hydrogen atom WF\nn = %d, l = %d, m = %d' % (n, l, m))
draw_wf(2, 1, 0)
```
通过运行以上代码,您将生成一个3D态电子云图样,它与氢原子的波函数对应。
利用Python绘制氢原子电子云与电子轨道图样
好的,可以通过Python中的matplotlib库来绘制氢原子电子云与电子轨道图样。以下是一段Python代码,可以绘制出氢原子的电子云和电子轨道图样:
```python
import numpy as np
import matplotlib.pyplot as plt
# 定义常数
a0 = 1 # 玻尔半径
Z = 1 # 氢原子核电荷数
n = 1 # 能级
l = 0 # 轨道角动量量子数
m = 0 # 磁量子数
# 采样点数
N = 200
# 构造网格
x = np.linspace(-a0, a0, N)
y = np.linspace(-a0, a0, N)
X, Y = np.meshgrid(x, y)
# 计算电子云的概率密度函数
R = np.sqrt(X**2 + Y**2)
rho = (Z/a0)**3 * np.exp(-2*Z*R/a0) / np.pi / a0**3
# 绘制电子云的等值面
plt.contour(X, Y, rho, alpha=0.5)
# 绘制电子轨道的投影
theta = np.linspace(-np.pi, np.pi, 100)
R = a0 * n**2 / (Z*np.sqrt(l*(l+1))) * (Z*R / (n*a0))**l * np.exp(-Z*R/(n*a0))
X_proj = R * np.sin(theta)
Y_proj = R * np.cos(theta)
plt.plot(X_proj, Y_proj, lw=2)
# 设置坐标轴范围和标签
plt.xlim(-a0, a0)
plt.ylim(-a0, a0)
plt.xlabel('x (m)')
plt.ylabel('y (m)')
# 显示图形
plt.show()
```
以上代码运行后,会在屏幕上显示出绘制的氢原子电子云与电子轨道图样。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)