1 Star 0 Fork 0

ACertainUser/我的赛博大物实验

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.gitignore
Advection1D_PDE.m
BrownBridge.m
EM2D_PDE2.m
EM2D_potential.m
EM3D_pde_potential_pytorch.py
EM3D_pde_yee_torch.py
EM3D_plot.m
Elastic1D_PDE.m
ExplicitEuler.m
KG2D_PDE.m
KG_PDE.m
LICENSE
NBody3D.m
Nbody.m
README.md
Rnl.m
atomic.html
atomic_energylv.m
atomic_orbitals.m
atomic_orbitals_plotly.py
atomic_ortibal_s.m
audio_wavepacket.m
chemlab.m
chemlab_exp.m
decay.m
diff1D_fourier.m
diff2D_fourier.m
diff3D_PDE_torch.py
diffusion2D_PDE.m
diffusion_PDE.m
displacementSim_multi.m
elastic2D.m
element_data.txt
laplacian2D_PDE.m
laplacian3D_PDE.py
matrixGen_latex.m
movingcharge2.m
multiParticleWaveFunc.m
pendulum.m
quantumOscillator.m
relativityTrain.m
schrodinger1D_ODE.m
schrodinger2D_PDE.m
seeMesh.m
simple_crystal.m
simple_crystal_voxel.py
simple_molecule.m
simple_molecule_chirality.m
simple_molecule_json_voxel.py
simple_molecule_voxel.py
standingWaves_123D.m
theVibrator_PDE.m
wave2D_PDE.m
wave2D_superposition.m
wave3D_PDE_torch.py
wave_PDE.m
wave_PDE_dualinterface.m
wave_PDE_interface.m
wave_dispersive.m
wave_pde_seq.m
简单刚体碰撞模拟器.html
克隆/下载
movingcharge2.m 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
ACertainUser 提交于 6个月前 . 突然发现打错公式了
% 绘制匀速运动电荷的电磁场
% 使用AI辅助
% Gitee Repo
% 清除工作区和命令窗口
clc;
clear;
% 定义网格参数
L = 1;
dx = 0.2;
% 创建三维网格
[x, y, z] = meshgrid(-L:dx:L, -L:dx:L, -L:dx:L);
v = 0.8;%速度
t = 0;
gamma = 1 / sqrt(1 - v^2);% 相对论因子 gamma
figure;
for t = -1:0.1:1
% 计算距离平方和距离
R2 = (x-v*t).^2 + y.^2 + z.^2;
R = sqrt(R2);
% 计算 cos^2 和 sin^2
cos2 = ((x-v*t).^2) ./ R2;
sin2 = 1 - cos2;
% 计算系数 coeff
coeff = 0.1 ./ (gamma^2 * (1 - v^2 * sin2)) ./ R.^3;
% 处理无效值
coeff(isnan(coeff) | isinf(coeff)) = 0;
coeff(coeff > 1) = 1;
coeff(coeff < -1) = -1;
% 计算电场分量
coeff(abs(coeff) < 0.05) = 0;
Ex = coeff .* (x-v*t);
Ey = coeff .* y;
Ez = coeff .* z;
% 计算磁场分量
Bx = zeros(size(Ex));
By = -v*Ez;
Bz = v*Ey;
% 绘制结果
clf
hold on;
axis equal;
axis([-L,L,-L,L,-L,L])
quiver3(x, y, z, Ex, Ey, Ez, 0);
quiver3(x, y, z, Bx, By, Bz, 0);
title('匀速电荷的电磁场');
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
scatter3(v*t,0,0,'r')
%legend('Electric Field', 'Magnetic Field');
drawnow
pause(0.1)
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/acertainuser/my---matlab-script.git
git@gitee.com:acertainuser/my---matlab-script.git
acertainuser
my---matlab-script
我的赛博大物实验
master

搜索帮助