【发布时间】:2014-10-23 13:35:46
【问题描述】:
我正在尝试使用 Mathematica 以数字方式解决标题问题,但无济于事。想象一根长度为 L 的杆。杆中的声速为 c。在一端施加宽度与 L/c 相当的高斯形状的压力脉冲。我想求解杆内的粒子位移函数 u(t,x)。 Mathematica 代码如下,
c = 1.0 (*speed of wave*)
L = 1.0 (*length of medium*)
Subscript[P, 0] = 0.0 (*pressure of reservoir at one end*)
Subscript[t, 0] = 5.0*c/L; (*mean time of pressure impulse*)
\[Delta]t = 2.0*c/L; (*Std of pressure impulse*)
K = 1.0; (* proportionality constant, stress-strain *)
Subscript[P, max ] = 1.0; (*max. magnitude of pressure impulse*)
Subscript[P, 1][t_] :=
Subscript[P, max ]
PDF[NormalDistribution[Subscript[t, 0], \[Delta]t], t];
PDE = D[func[t, x], t, t] == c^2 D[func[t, x], x, x]
BC1 = -K func[t, 0] == Subscript[P, 1][t]
BC2 = -K func[t, L] == Subscript[P, 0]
IC1 = func[0,
x] == (-Subscript[P, 1][0]/K) (x/L) + (-Subscript[P, 0]/K) (1 - x/L)
IC2 = Derivative[1, 0][func][0, x] == 0.0
sol = NDSolve[{PDE, BC1, BC2, IC1, IC2},
func, {t, 0, 2 Subscript[t, 0]}, {x, 0, L}]
问题是程序运行了几分钟而没有给出任何输出。鉴于问题的简单性(即存在解析解),我认为应该有一种更快的方法来获得数值解。有人能给我一些建议吗?
【问题讨论】:
-
我强烈建议您不要使用
Subscript,而是使用p0等。也不要以大写字母开头任何您自己的符号,以避免与内置符号冲突。 -
.. 进行这些更改后,我立即得到解决方案,并警告边界条件不一致。我认为你在公元前有一些明显的错误,但你可以通过查看你得到的解决方案来解决这个问题。
-
谢谢,乔治。听从您的建议并解决了问题。
标签: wolfram-mathematica numerical-methods wave pde numerical-computing