How to manipulate ODE via EventLocator?
- To: mathgroup at smc.vnet.net
- Subject: [mg109529] How to manipulate ODE via EventLocator?
- From: Zachar István <replicatorzed at gmail.com>
- Date: Mon, 3 May 2010 07:53:55 -0400 (EDT)
Dear Group,
is there a way to manipulate a set of ordinary diff.equations during
NDSolve-runtime, via the EventLocator option? I would like to see for
example that when a specific variable x reaches a certain value at
time t, e.g. x[t] = 10, then its value should be reset to 1 and the
integration should continue from x[t] = 1. Is it possible?
So far I've set up the basics:
sol = NDSolve[{x'[t] == 1.5*x[t], x[0] == 0.1}, {x}, {t, 0, 2},
Method -> {"EventLocator", "Event" -> x[t] - 1, "EventAction" :>
Throw[end = t, "StopIntegration"]}];
end
Plot[Evaluate[x[t] /. sol], {t, 0, end}, Frame -> True, Axes -> False]
What I'm interested in is what to put inside EventAction to change the
behaviour of the x'[t] function. Any ideas?
Thanks in advance,
Istvan