Hello all!
I'm trying to solve numerically a system of 5 ODEs using NDSolve[]
. The problem is that some of the solutions take negative values, which doesn't make sense from a physical point of view. Is there any way to force these functions to stay non-negative?
I've read about the command WhenEvent[]
, but I don't know if it can be useful to fix this.
Thank you in advance for any help!
PD: This isn't my mathematical model, which is pretty large, but it might serve as an example:
\[Phi] = 0.08;
a = 0.7;
b = 0.8;
tmax = 200.0;
V0 = 1.0;
U0 = 1.0;
i = 1.0;
sol = NDSolve[{V[0] == V0, U[0] == U0,
V'[t] == V[t] - 1/3 V[t]^3 - U[t] + i,
U'[t] == \[Phi] (V[t] + a - b U[t])}, V[t], {t, 0, tmax},
DependentVariables -> {V[t], U[t]}, Method -> "Adams"];
Plot[V[t] /. sol, {t, 0, tmax}]