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 ?


closed as off-topic by Henrik Schumacher, Chris K, MarcoB, m_goldberg, Alex Trounev Apr 11 at 15:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Henrik Schumacher, Chris K, MarcoB, m_goldberg, Alex Trounev
If this question can be reworded to fit the rules in the help center, please edit the question.

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