I'm using the JiTCDDE module to solve delayed differential equations. My work requires me to let the model evolve for a while and then perturb it. To that end I'm trying to use jitcdd.purge_past()
followed by jitcdde.add_past_points()
. Issue is, the latter requires me to provide not only the values at the times I input, but also the values of the derivative.
Is there a way to get those from the jitcdde
instance itself, or do I need to manually and clunckily calculate them?
EDIT: more info
My system consists of two non linear oscillators coupled together (they are not phase oscillators). I let the system evolve for a while until it reaches a steady state and then perturb it by shifting one of the two oscillators in time a bit. The amount I shift it is calculated as a percentage of the period of oscillation, what amounts to an effective phase shift.
My system is 12-dimensional and I'm struggling to get a minimal working example going, so here's a non-working mockup of the code:
f = [...]
DDE = jitcdde(f)
DDE.constant_past([1]*len(f))
DDE.step_on_discontinuities()
initial_integration_time = 30
DDE.integrate(initial_integration_time)
After doing this, I'd like to perform the perturbation that should be, lets say 10% of a period, assume I know the stationary period length to be T
. What I'm trying to do is to use get_state
to get the current state of the system and derivative, and the state and derivative perturbation
time units ago. Then, I can construct a new set of anchor
s that I can pass to DDE.add_past_points
to start integrating from there.
T = ...
perturbation = 0.1*T #in units of time
state = DDE.get_state()
# get position and derivative of first oscilator
# since the system is 12-D, the first six correspond to osc1
osc1_x = [state[1][6:] for s in state]
osc1_dx = [state[2][6:] for s in state]
# here, do the same for osc2 at DDE.t - perturbation