Message Boards Message Boards

Solve numerically a system of 5 ODEs using NDSolve?

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}]
2 Replies

The variable U does not change sign:

{solV, solU} = 
  NDSolveValue[{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, U}, {t, 0, tmax}, 
   Method -> "Adams"];
ParametricPlot[{solV[t], solU[t]}, {t, 0, tmax}]
POSTED BY: Gianluca Gorni

Thank you for your answer!

Yes, it's true, U doesn't change sign. I was thinking about the variable V...

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract