1
$\begingroup$

Here x[i,j][t], y[i,j][t] ... denote the coordinates of 4*4 interacting particles labelled [i,j] taken as in a network, t is the time

Clear
epsilon = 0.01
eqns = {Table[-(x[i, j][t] x[i, j]'[t] + 
y[i, j][t] y[i, j]'[t])/(((x[i, j][t])^2 + (y[i, j][t])^2 + 
epsilon^2)^(3/2)) x[i, j]'[
t] + (1/((x[i, j][t])^2 + (y[i, j][t])^2 + epsilon^2)^(1/2)) x[
i, j]''[t] == -((x[i, j][t])^2 + (y[i, j][t])^2) Sum[(x[i, 
j][t] - 
x[k, l][t])/(((x[i, j][t] - x[k, l][t])^2 + (y[i, j][t] - 
y[k, l][t])^2 + epsilon^2)^(3/2)), {k, 0, 3}, {l, 0, 
3}], {i, 0, 3}, {j, 0, 3}], 
Table[-(x[i, j][t] x[i, j]'[t] + 
y[i, j][t] y[i, j]'[
t])/(((x[i, j][t])^2 + (y[i, j][t])^2)^(3/2) + 
epsilon^2) y[i, j]'[
t] + (1/((x[i, j][t])^2 + (y[i, j][t])^2 + epsilon^2)^(1/2) + 
epsilon^2) y[i, j]''[
t] == -((x[i, j][t])^2 + (y[i, j][t])^2) Sum[(y[i, j][t] - 
y[k, l][t])/(((x[i, j][t] - x [k, l][t])^2 + (y[i, j][t] - 
y[k, l][t])^2 + epsilon^2)^(3/2)), {k, 0, 3}, {l, 0, 
3}], {i, 0, 3}, {j, 0, 3}], 
Table[x[i, j][0] == 0.1 (1 - i), {i, 0, 3}, {j, 0, 3}],
Table[y[i, j][0] == 0.1 (1 - j), {i, 0, 3}, {j, 0, 3}],
Table[x[i, j]'[0] == -0.1 (1 - j), {i, 0, 3}, {j, 0, 3}], 
Table[y[i, j]'[0] == 0, {i, 0, 3}, {j, 0, 3}]}
sol = NDSolve[
eqns,  {Table[x[i, j], {i, 0, 3}, {j, 0, 3}], 
Table[y[i, j], {i, 0, 3}, {j, 0, 3}]} , {t, 0, 0.1}]  
ParametricPlot[Evaluate[{x[1, 2][t], y[1, 2][t]} /. sol], {t, 0, 0.1},
PlotStyle -> Automatic]
$\endgroup$
2
$\begingroup$

Flatten the variables inside NDSolve

sol = NDSolve[eqns, {Table[x[i, j], {i, 0, 3}, {j, 0, 3}],Table[y[i, j], {i, 0, 3}, {j, 0, 3}]} // Flatten, {t, 0, 0.1}];

ParametricPlot[Evaluate[{x[1, 2][t], y[1, 2][t]} /. sol], {t, 0, 0.1},PlotStyle -> Automatic, AspectRatio -> 1]

enter image description here

| improve this answer | |
$\endgroup$
0
$\begingroup$

Ulrich Neumann had gave a effective solution.

Here is a remedy way.

xsol = Flatten /@ First@First@sol // Thread;
ysol = Flatten /@ Last@First@sol // Thread;
ParametricPlot[{x[1, 2][t], y[1, 2][t]} /. xsol /. ysol, {t, 0, 0.1}, 
 PlotStyle -> Automatic, AspectRatio -> 1]
| improve this answer | |
$\endgroup$

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.