TransWikia.com

NDSolve works but no results in ParametricPlot?

Mathematica Asked on May 11, 2021

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]

2 Answers

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

Answered by Ulrich Neumann on May 11, 2021

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]

Answered by cvgmt on May 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP