I'm trying to use NDSolve
to solve a wave equations to check if it is easier and/or faster to use it instead of my old characteristics eq. method implementation.
I'm getting a lot of instability that I don't get with the characteristics method, and since these are simple equations, I wonder what is wrong... (hopefully, not the physical aspect of the problem...)
ans = Flatten@NDSolve[{
u[t, x]*D[d[t, x], x] + d[t, x]*D[u[t, x], x] + D[d[t, x], t] == 0,
D[d[t, x], x] + u[t, x]/9.8*D[u[t, x], x] +
1/9.8*D[u[t, x], t] + 0.0001 u[t, x]*Abs[u[t, x]] == 0,
u[0, x] == 0,
d[0, x] == 3 + x/1000*1,
u[t, 0] == 0,
u[t, 1000] == 0
},
d, {t, 0, 1000}, {x, 0, 1000}, DependentVariables -> {u, d}
]
Animate[Plot[(d /. ans)[t, x], {x, 0, 1000},
PlotRange -> {{0, 1000}, {0, 6}}], {t, 0, 1000}
]
Can someone help me?
EDIT:
I've placed the NDSolve
solution (following JxB's editing) with my characteristics solution, together on the same animation. They match close enough, with the exception of the initial quick oscillations. With time they tend do start do desynchronize, but I believe this is probably due to a small simplification we have to admit when deducing the characteristics.
Red: NDsolve
; Blue: "manual" characteristics method;
press F5 (refresh your browser), to restart the animation from t=0
.
(xx scale is the number of points I used with my "manual" method, where each point represents 20 units of the NDSolve
/physical scale)
Playing with NDSolve
grid sampling, renders completely different oscillation effects. Does anyone have or know of a technique to ensure a proper integration?
ρ · utt = k · uxx + kx · ux. When the elasticity k is constant, this reduces to usual two term wave equation utt = c2uxx where the velocity c = √k/ρ varies for changing density.
RM can be calculated as : RM (Righting moment or moment of statical stability) = (W. GZ) = W. sinθ ( GM + 1/2 BM tan2θ) = 4000 x sin240(0.4 + 1/2 x 3.4 x tan2240 ) = 1200tm.
The wave equation is one of the most important equations in mechanics. It describes not only the movement of strings and wires, but also the movement of fluid surfaces, e.g., water waves. The wave equation is surprisingly simple to derive and not very complicated to solve although it is a second-order PDE.
The (Neumann) boundary conditions are ux(0,t) = ux(L, t)=0.
By changing your coefficients to infinite precision (e.g., 1/9.8->10/98), and setting WorkingPrecision->5
(a value of 6 is too high), I no longer get the error message:
ans = Flatten@
NDSolve[{D[u[t, x] d[t, x], x] + D[d[t, x], t] == 0,
D[d[t, x], x] + u[t, x] 10/98*D[u[t, x], x] +
10/98*D[u[t, x], t] + 1/10000 u[t, x]*Abs[u[t, x]] == 0,
u[0, x] == 0, d[0, x] == 3 + x/1000, u[t, 0] == 0,
u[t, 1000] == 0}, d, {t, 0, 1000}, {x, 0, 1000},
DependentVariables -> {u, d}, WorkingPrecision -> 5]
Animate[
Plot[(d /. ans)[t, x], {x, 0, 1000},
PlotRange -> {{0, 1000}, {0, 6}}], {t, 0, 1000}]
I'm don't know this equation, so I don't believe the solution: small-scale oscillations grow initially, then are damped out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With