Your project is spectacular; the NBodyVisualize
Module really shows the semi-major axis within equations in Hamiltonian form! For example, increase the mass and time step, de-structure dataCentered[tloc]
or decrease the initial position & velocity.
NBodySimulation[
"InverseSquare", {<|"Mass" -> 1, "Position" -> {0, 0, 0},
"Velocity" -> {0, 0, 0}|>,
<|"Mass" -> 1, "Position" -> {1, 1, 1}, "Velocity" -> {0, 0, 0}|>,
<|"Mass" -> 1, "Position" -> {1, 1, 0},
"Velocity" -> {0, 0, 0}|>},
1
]["HamiltonEquations"]
What are some initial positions and velocities? Why not call helper functions until they are invoked? Is it possible to set dimensions like 0.700002 or e.g. -4.48, and "fix" the position to some random value around {0,0,0}?
What do you know about uploading & embedding animations, for example via Liferay or removing warnings without closing the cell group? So we've got that framework, and now the Star-Planet-Moon three-body system!
NBodyVisualize[NObj_,
m_,
inPos_,
inVel_,
{t1_, t2_}] := Module[{data1, dataCentered1},
data = NBodySimulation[
"InverseSquare",
Table[<|"Mass" -> m[[i]], "Position" -> inPos[[i]],
"Velocity" -> inVel[[i]]|>, {i, 1, NObj}],
t2];
dataCentered = (Table[
data[i, "Position"][#] - data[1, "Position"][#], {i, 1,
NObj}]) &;
Show[ParametricPlot3D[
{dataCentered[tloc][[1]], dataCentered[tloc][[2]],
dataCentered[tloc][[3]]},
{tloc, t1, t2},
PlotStyle -> {Black, Green, Blue}
],
Graphics3D[{PointSize[0.02], Point[dataCentered[t2]]}]]]
inPosInstance = Table[RandomReal[{-1, 1}, 3], 3]
inVelInstance = Table[RandomReal[{-0.1, 0.1}, 3], 3]
ListAnimate[Table[NBodyVisualize[3,
{100, 10, 0.1},
inPosInstance,
inVelInstance,
{t, t + 1}],
{t, 0, .01, .001}], 10]
It sort of looks like a butterfly flap when you provide the number of objects, the scalar mass in a list for the n bodies, the n×n matrices of positions and velocities, as well as the start and end time, and the dimensions of the plot in both directions.