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

本文介绍

黑洞的简单实现和模拟

代码

% 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 start
    jetZ(jetZ > jetHeight) = 0;
    
    % Pause to create animation effect
    pause(0.05);
end

效果

在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值