({{, (RefLink[NBodySimulationData, paclet:ref/NBodySimulationData])[data…] 
represents the result of an n-body simulation.}})

OpenersNotesSection(Spacer1)Details

(RefLink[NBodySimulation, paclet:ref/NBodySimulation]) generates an (RefLink[NBodySimulationData, paclet:ref/NBodySimulationData]) object.

The following operations can be performed on an (RefLink[NBodySimulationData, paclet:ref/NBodySimulationData])[…] object nbsd:

Possible combined quantities include:

Possible overall simulation properties include:

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Simulate a three-body problem in two dimensions:

data  =NBodySimulation["InverseSquare",{<|"Mass"->1,"Position"->{0,0},"Velocity"->{0,.5}|>,
<|"Mass"->1,"Position"->{1,1},"Velocity"->{0,-.5}|>,
<|"Mass"->1,"Position"->{0,1},"Velocity"->{0,0}|>},4]

Get the data for body 1 at time  t=4:

data[1,4.]

Plot the positions of the bodies:

ParametricPlot[Evaluate[data[All,"Position",t]],{t,0,4}]

Plot the velocity for bodies 2 and 3:

ParametricPlot[Evaluate[data[{2,3},"Velocity",t]],{t,0,4},PlotRange->All,PlotPoints->1000]

Continue a simulation further:

data2 =NBodySimulation["InverseSquare",<|"b1"-><|"Mass"->1,"Position"->{0,0},"Velocity"->{0,.5}|>,"b2"-><|"Mass"->2,"Position"->{1,1},"Velocity"->{0,-.5}|>|>,2]

data4= NBodySimulation[data2,4]

The new data has the same body parameters as the original:

data4[All,"Mass"]

The new data contains the simulation data from the original. Plot the position of the bodies:

Show[ParametricPlot[Evaluate[data2[All,"Position", t]],{t,0,2},PlotStyle->Thickness[.05]],ParametricPlot[Evaluate[data4[All,"Position",t]],{t,0,4}],PlotRange->All]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[NBodySimulation, paclet:ref/NBodySimulation])  ▪  (RefLink[NDSolveValue, paclet:ref/NDSolveValue])  ▪  (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Scientific Models, paclet:guide/ScientificModels])}})}})