gpt4 book ai didi

wolfram-mathematica - 数学; ND求解;我可以使用 InterpolatingFunction 作为初始条件吗?

转载 作者:行者123 更新时间:2023-12-04 18:20:33 26 4
gpt4 key购买 nike

出现问题是因为我想使用一个 PDE 的解作为初始条件来求解另一个。因为在 NDSolve 中,解是由 InterpolatingFunction 给出的,所以我必须在第二个 PDE 中使用 InterpolatingFunction。这可能吗?为什么我的电脑需要永远运行它?我的代码:

(*********************Parameters********************)
\[Gamma] = 10^(-5);
T = 500;
tm = -250;
\[Sigma] = 100;
L = 1;
L0 = -(L/2);
L1 = L0 + L;
c = 29.979;
\[Omega] = 1.32949/10^8;
\[Eta] = 1539.1;
\[Mu] = 6.27;
\[Beta] = 0.1334;
k = 40895.3;

(*********************1st PDE********************)
solS = NDSolve[{D[sS[z, t], t] == (-(\[Gamma] + I*\[Beta]*z))*sS[z, t]-I*\[Omega]*aS[z, t],
D[aS[z, t], z] + (1/c)*D[aS[z, t], t] == (-I)*\[Eta]*k*sS[z, t], sS[z, -T] == 0,
aS[z, -T] == E^(-((-T - tm)^2/(2*\[Sigma]^2))),
aS[L0, t] == E^(-((t - tm)^2/(2*\[Sigma]^2)))}, {sS, aS}, {z, L0, L1}, {t, -T, 0},
MaxSteps -> Infinity]

(*************take the result and plot**************)
iniR = solS[[1]][[1]][[2]]
Plot3D[Re[iniR[z, t]], {z, L0, L1}, {t, -T, 0}, PlotRange -> All]

(***********2nd PDE, with the 1st result as ini. con.***********)
solR = NDSolve[{D[sR[z, t], t] == (-(\[Gamma] - I*\[Beta]*z))*sR[z, t] - I*\[Omega]*aR[z, t],
D[aR[z, t], z] + (1/c)*D[aR[z, t], t] == (-I)*\[Eta]*k*sR[z, t],
sR[z, 0] == iniR[z, 0], aR[z, 0] == 0, aR[L0, t] == 0}, {sR, aR}, {z, L0, L1},
{t, 0, T}, MaxSteps -> Infinity]

最佳答案

首先:是的,您可以使用插值函数。这没有错。对于 Mathematica,InterpolatingFunction 仅具有一个插值多项式,应用于点集以产生中间点。事实上,生成的 InterpolatingFunction 是您可以使用的最准确的表示。

您的计算“永远”进行的原因是因为您将 MaxSteps 设置为无穷大。

这不是使用插值函数的问题。您正在进行的模拟对数值敏感,这是一个更大的问题。通过指定 MaxSteps->Infinity,您告诉 Mathematica 花费尽可能多的时间来生成解决方案。

在这样做的过程中,它可能会将步长减小到非常小的程度,比如 10^-6,只是为了获得数值稳定的结果。这样做只是因为 MaxSteps->Infinity 设置。如果您删除它,它实际上可以产生一个解决方案,但它会警告您该解决方案很差。

您甚至会收到来自 Mathematica 的错误,提示解决方案会很糟糕:

NDSolve::eerr: Warning: Scaled local spatial error estimate of 559.4348244417077at t = 3.808844111947534 in the direction of independent variable z is much greater than prescribed error tolerance. Grid spacing with 25 points may be too large to achieve the desired accuracy or precision. A singularity may have formed or you may want to specify a smaller grid spacing using the MaxStepSize or MinPoints method options. >>

关于wolfram-mathematica - 数学; ND求解;我可以使用 InterpolatingFunction 作为初始条件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7935351/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com