当前位置: 首页> 游戏> 单机 > matlab模拟黑洞包含吸积盘和喷流,简单模拟

matlab模拟黑洞包含吸积盘和喷流,简单模拟

时间:2025/7/11 20:39:10来源:https://blog.csdn.net/u013531166/article/details/139485607 浏览次数:0次

本文介绍

黑洞的简单实现和模拟

代码

% Black Hole Simulation in 3D% Clear workspace and figures
clear; close all; clc;% Create figure and set axis properties
figure;
axis([-10 10 -10 10 -10 10]);
hold on;
grid on;
view(3);% Parameters for the black hole and accretion disk
numParticles = 1000;  % Number of particles in the accretion disk
diskRadius = 5;       % Radius of the accretion disk
diskHeight = 0.5;     % Height of the accretion disk
jetHeight = 10;       % Height of the jet
jetRadius = 1;        % Radius of the jet% Create particles for the accretion disk
theta = 2*pi*rand(numParticles,1);
r = diskRadius * sqrt(rand(numParticles,1));
x = r .* cos(theta);
y = r .* sin(theta);
z = diskHeight * (rand(numParticles,1) - 0.5);% Create particles for the jet
jetParticles = 500;
jetX = jetRadius * (rand(jetParticles,1) - 0.5);
jetY = jetRadius * (rand(jetParticles,1) - 0.5);
jetZ = linspace(0, jetHeight, jetParticles)';% Plot the black hole
[xSphere, ySphere, zSphere] = sphere(20);
surf(0.5*xSphere, 0.5*ySphere, 0.5*zSphere, 'FaceColor', 'k', 'EdgeColor', 'none');% Plot the accretion disk
hDisk = scatter3(x, y, z, 1, 'r');% Plot the jet
hJet = scatter3(jetX, jetY, jetZ, 1, 'b');% Animation loop
numFrames = 200;
for t = 1:numFrames% Update accretion disk particles (simple circular motion)theta = theta + 0.1;x = r .* cos(theta);y = r .* sin(theta);set(hDisk, 'XData', x, 'YData', y, 'ZData', z);% Update jet particles (move upwards)jetZ = jetZ + 0.1;set(hJet, 'XData', jetX, 'YData', jetY, 'ZData', jetZ);% Loop jet particles back to startjetZ(jetZ > jetHeight) = 0;% Pause to create animation effectpause(0.05);
end

效果

在这里插入图片描述

关键字:matlab模拟黑洞包含吸积盘和喷流,简单模拟

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: