Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11386
| From | Nick Broderick <crazychessman@msn.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | NDSolve bug? |
| Date | 2012-08-17 07:44 +0000 |
| Message-ID | <k0ksom$66f$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
I am using NDSolve to simulate the motion of a particle under linear drag and constant acceleration directed such that the particle is always forced back towards the origin. There are two drag constants: one is applied when the particle moves back towards centre, the other when it is moving away from the origin. The particle experiences no acceleration or drag when it sits precisely on the origin. This creates five subcases in my equation of motion. (g, b and c are always positive, x0 and v0 are initial position and velocity, respectively.)
sol =
First[x /.
NDSolve[{x''[t] ==
Piecewise[{{-g - b*x'[t],
x[t] > 0 && x'[t] > 0}, {-g - c*x'[t],
x[t] > 0 && x'[t] <= 0}, {g - b*x'[t],
x[t] <= 0 && x'[t] <= 0}, {g - c*x'[t],
x[t] <= 0 && x'[t] > 0}}, 0], x'[0] == v0,
x[0] == x0}, x, {t, 0, T}, MaxSteps -> \[Infinity],
AccuracyGoal -> 3]];
In most cases for the calculation is fine. But when I try the special case x0=0 and v0=0 (or very small numbers, on the order of 10^0) my plot of the solution becomes almost chaotic. I thought the case x0=0 and v0=0 is covered by the default case in Piecewise so that the particle should not move at all under these conditions. What can I do to fix this?
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
NDSolve bug? Nick Broderick <crazychessman@msn.com> - 2012-08-17 07:44 +0000 Re: NDSolve bug? DC <b.gatessucks@gmail.com> - 2012-08-18 07:44 +0000
csiph-web