1
$\begingroup$

I'm trying to write a stochastic differential equation, using ParametricNDSolve and WhenEvents :

s = ParametricNDSolve[{V'[t] == 
Piecewise[{{(a + mu[t])*V[t], 
   V[t] < V0}, {(a + mu[t])*V[t]^(2/3)*(1 - m[t]/(1 + m[t])) - 
    b*(V[t] - V0), V0 < V[t]}}], 
WhenEvent[Mod[t, dt] == 0., mu[t] -> RandomReal[{-a, a}]], 
m'[t] == 
Piecewise[{{0, V[t] < V0}, {c*(V[t] - V0) - d*m[t], V[t] > V0}}], 
V[0] == Vt0, m[0] == 0, mu[0] == 0}, {V, m, mu}, {t, tmin, tmax}, 
DiscreteVariables -> {mu}, {Vt0, a, b, c, V0}]

but I get the error message :

ParametricNDSolve::dsvar: DiscreteVariables->{mu} cannot be used as a variable.

Could you help me with that plz ?

$\endgroup$
1
  • 3
    $\begingroup$ Options have to appear last. So use ParametricNDSolve [ ... , {Vt0, a, b, c, V0}, DiscreteVariables -> {mu}] instead. $\endgroup$ – Henrik Schumacher Apr 11 '19 at 9:42