1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
% 该代码将绘制氢原子电子云角向分布图并导出 tiff 文件。
clear
clc
t = 5; % 图片行数
hfig = figure;
for i = 1:t
for j = 1:i
subplot(t, t, t*(i-1)+j)
electronic_cloud(i-1, j-1)
axis equal
axis off
end
end
% 文件导出
figWidth = 10;
figHeight = 10;
set(hfig, 'PaperUnits', 'inches');
set(hfig, 'PaperPosition', [0 0 figWidth figHeight]);
fileout = ['electron_distribution1'];
print(hfig, fileout, '-r300', ' -dtiff'); % 图片精度
function electronic_cloud(l, m)
dx = pi/60;
alt = 0:dx:pi;
az = 0:3*dx:2*pi;
[phi,theta] = meshgrid(az,alt);
Plm = legendre(l, cos(theta));
if l ~= 0
P = reshape(Plm(m+1, :, :), size(phi));
else
P = Plm;
end
a = (2*l+1) * factorial(l-m);
b = 4 * pi * factorial(l+m);
C = sqrt(a/b);
Y = C .* P .* exp(1i*m*phi);
[Xm,Ym,Zm] = sph2cart(phi, theta-pi/2, abs(Y).^2);
surf(Xm,Ym,Zm)
str = ['$|Y_', num2str(l), '^', num2str(m), '|^2$'];
title(str, 'interpreter', 'latex')
end
|