Group Abstract Group Abstract

Message Boards Message Boards

Simulate this system of $n$ nonlinear DEs?

Posted 7 years ago
POSTED BY: Muhammed Ercan

It looks so there is no equation for X, Y. Try working code that can be developed further

ClearAll["Global`*"]
P[i_][t] = {X[i][t], Y[i][t]};
p[j_, i_] = Norm[P[i][t] - P[j][t]];
A@p[j, i] = (a*(P[i][t] - P[j][t]))/Exp[b*p[j, i]];
R@p[j, i] = (c*(P[i][t] - P[j][t]))/p[j, i]^2;
summand1 = R@p[j, i] - A@p[j, i];
A@p[i, j] = (a*(P[j][t] - P[i][t]))/Exp[b*p[i, j]];
R@p[i, j] = (c*(P[j][t] - P[i][t]))/p[i, j]^2;
summand2 = A@p[i, j] - R@p[i, j];
n = 5;
sys = Table[{X[i]'[t], Y[i]'[t]} == 
    Sum[If[j < i, summand1, 0], {j, 1, n}] + 
     Sum[If[i < j, summand2, 0], {j, 1, n}], {i, 1, n}];
Xsol = Table[
  ParametricNDSolveValue[{sys, {X[1][0], Y[1][0]} == {1, 1}, {X[2][0],
       Y[2][0]} == {1, 6}, {X[3][0], Y[3][0]} == {1, -1}, {X[4][0], 
      Y[4][0]} == {5, 3}, {X[5][0], Y[5][0]} == {6, 2}}, 
   X[i], {t, 0, 5}, {a, b, c}], {i, 1, n}]; Ysol = 
 Table[ParametricNDSolveValue[{sys, {X[1][0], Y[1][0]} == {1, 
      1}, {X[2][0], Y[2][0]} == {1, 6}, {X[3][0], 
      Y[3][0]} == {1, -1}, {X[4][0], Y[4][0]} == {5, 3}, {X[5][0], 
      Y[5][0]} == {6, 2}}, Y[i], {t, 0, 5}, {a, b, c}], {i, 1, n}];

Manipulate[
 ParametricPlot[{Xsol[[1]][a, b, c][t], Ysol[[1]][a, b, c][t]}, {t, 0,
    5}, PlotRange -> Automatic, ImageSize -> Large, 
  AspectRatio -> 1], {{a, 1}, .1, 5}, {{b, 1}, .1, 5}, {{c, .1}, .1, 
  5}]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard