MATLAB ode45 不在初始条件下启动

计算科学 matlab 计算物理学 微分方程
2021-12-12 10:36:17

我在 MATLAB 中编写了一个代码来求解一个微分方程组,但我的解决方案似乎没有考虑到我指定的初始条件。我不确定如何解释这个问题。在下面的代码中,r_0 等于 32612336,但输出 rsol 从 0 开始: 输出 我将非常感谢任何想法/帮助!

% %function definitions
syms r(T) p(T) T Y t

G= 4.30091252525*(10^(-3)); %grav constant, in (parsec*km^2)/(Ms*sec^2) 
M = 170000; %mass of the Black Hole, in solar masses
m = 30; %mass of the object, in solar masses
reduced = m*M / (m+M);
c = 0.0020053761; % AU/sec, speed of 
rs = 2*G*M / c^2; %Schwarzchild radius
PI = 3.14;
E = 89656170000.0000;
L = 2.592191000000000e-13;

ode1 = diff(r,T) == sqrt((E^2/c^2 - c^2) + 2*parsec_to_AU(G)*M/r*(1+L^2/((c^2)*(r^2)))-(L^2)/(r^2));
ode2 = diff(p,T) == (1/r^2) * L;


% %function setup
[f1, Subs]= odeToVectorField([ode1 ode2]);
F1= matlabFunction(f1, 'Vars',{T,Y})

%
r_0= 32612336; %In KM
p_0 = PI;
span = [0 10^(-11)];
conditions = [r_0;p_0]; 
options = odeset('MaxStep', 10^(-14),'AbsTol',10^(-7));
[rsol,psol] = ode45(@(T,Y)F1(T,Y),span,conditions,options);
1个回答

您正在打印时间步长。

如果您打印出解决方案,您应该会发现 IC 已正确初始化。