1
$\begingroup$

Below is code to simulate a three ODE system. When running the code I get no errors put no output is empty as well. Because of the lack of errors I needed

Code

A = {{2, 5, 0.5}, {0.5, 1, mu}, {1, 0.5, 1}};
A // MatrixForm
tmax = 100;

sol = ParametricNDSolve[{
   x1'[t] == -(1 + x1[t]) (A[[1, 1]] x1[t] + A[[1, 2]] x2[t] + 
       A[[1, 3]] x3[t]),
   x2'[t] == -(1 + x2[t]) (A[[2, 1]] x1[t] + A[[2, 2]] x2[t] + 
       A[[2, 3]] x3[t]),
   x3'[t] == -(1 + x3[t]) (A[[3, 1]] x1[t] + A[[3, 2]] x2[t] + 
       A[[3, 3]] x3[t]),
   x1[0] == x10, x2[0] == x20, x3[0] == x30},
  {x1[t], x2[t], x3[t]}, {t, tmax}, {x10, x20, x30, mu}]

Manipulate[
 ParametricPlot3D[
  Evaluate[{x1[x10, x20, x30, mu], x2[x10, x20, x30, mu], 
     x3[x10, x20, x30, mu]} /. sol], {t, 0, tmax}], {{x10, 1, "x1"}, 
  0.01, 10}, {{x20, 1, "x2"}, 0.01, 10}, {{x30, 1, "x3"}, 0.01, 
  10}, {{mu, 71/48, "mu"}, 0, 3}]

Output

Output

Notes

  • I have not seen code examples using ParametricNDSolve, ParametricPlot3D, and Manipulate so I am posting in part so others can learn.
$\endgroup$
3
$\begingroup$

It is important that Manipulate can "see" the the dependencies on the variable. There might be many ways to get this running. Here is one of them:

sol = ParametricNDSolveValue[{
    x1'[t] == -(1 + x1[t]) (A[[1, 1]] x1[t] + A[[1, 2]] x2[t] + A[[1, 3]] x3[t]), 
    x2'[t] == -(1 + x2[t]) (A[[2, 1]] x1[t] + A[[2, 2]] x2[t] + A[[2, 3]] x3[t]), 
    x3'[t] == -(1 + x3[t]) (A[[3, 1]] x1[t] + A[[3, 2]] x2[t] + A[[3, 3]] x3[t]), 
    x1[0] == x10, x2[0] == x20, x3[0] == x30},
    {x1[t], x2[t], x3[t]},
    {t, tmax}, {x10, x20, x30, mu}];

Manipulate[
 ParametricPlot3D[sol[x10, x20, x30, mu], {t, 0, tmax}], 
 {{x10, 1, "x1"}, 0.01, 10}, 
 {{x20, 1, "x2"}, 0.01, 10}, 
 {{x30, 1, "x3"}, 0.01, 10}, 
 {{mu, 71/48, "mu"}, 0, 3}]
|improve this answer|||||
$\endgroup$
  • $\begingroup$ Thank you for your assistance. Proper syntax can be a pain. $\endgroup$ – AzJ Jun 13 '18 at 22:46
  • $\begingroup$ You're welcome. $\endgroup$ – Henrik Schumacher Jun 13 '18 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.