NBodySimulation[law,{state1,…,staten},t]
指定されたポテンシャルまたは力の法則に支配される n 体の系の運動のシミュレーションを,初期状態 stateiで時間 t の間生成する.
NBodySimulation[law,<|body1state1,…,bodynstaten|>,t]
bodyiという名前の n 体の系の運動のシミュレーションを生成する.
NBodySimulation
NBodySimulation[law,{state1,…,staten},t]
指定されたポテンシャルまたは力の法則に支配される n 体の系の運動のシミュレーションを,初期状態 stateiで時間 t の間生成する.
NBodySimulation[law,<|body1state1,…,bodynstaten|>,t]
bodyiという名前の n 体の系の運動のシミュレーションを生成する.
詳細とオプション
- NBodySimulationは,結果としてNBodySimulationDataオブジェクトを与える.
- NBodySimulationは,デフォルトで,古典的な非相対的な運動方程式を解く.
- 状態 stateiは,次の要素を含む連想として与えられる.
-
"Mass" 質量 "Position" 位置 "Velocity" 速度 "Charge" 電荷(任意) "PositionVariable" 位置の変数(任意) "MomentumVariable" 運動量の変数(任意) - 特定のポテンシャルあるいは力の法則が使う追加的要素も加えることができる.
- ポテンシャルあるいは力の法則は以下で与えられる.
-
"name" 名前付きの法則 <|"prop1"f1,…|> 指定された特性を持つ法則 fun 対ポテンシャル関数 - 次は,使用可能な名前付きの法則である.
-
"InverseSquare" 単位のない逆2乗の法則 "Harmonic" 単位のない調和ポテンシャル {"Harmonic",params} 単位はないがパラメータがある調和ポテンシャル "Newtonian" 物理単位があるニュートンの重力法則 "Coulomb" 物理単位があるクーロンの法則 - デフォルトで,"Harmonic"はバネ定数1と平衡長1を使う.
- {"Harmonic",<|"SpringConstant"->k,"EquilibriumLength"->len|>}はバネ係数 k と平衡長 len を使う.
- 法則を連想として与える際には次のキーを使うことができる.
-
"PairwisePotential" 任意の2体間の対ポテンシャル関数 "PairwiseForce" 任意の2体間の対力関数 "ExternalPotential" 各体に適用される追加的なポテンシャル関数 "ExternalForce" 各体に適用される追加的な力関数 "Region" 物体の領域 - 対ポテンシャル関数または対力関数 f は,物体 i と物体 j のすべての対に f[statei,statej]の形で適用される.
- 各体について指定された初期状態の値は,単位がある数量として与えることができる.
例題
すべて開く すべて閉じる例 (2)
data = NBodySimulation["Harmonic", {<|"Mass" -> 1, "Position" -> {-1 / 3}, "Velocity" -> {0}|>,
<|"Mass" -> 2, "Position" -> {1 / 3}, "Velocity" -> {0}|>}, 10]Plot[Evaluate[data[All, "Position", t]], {t, 0, 10}]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]data[All, 4]ParametricPlot[Evaluate[data[All, "Position", t]], {t, 0, 4}]スコープ (8)
data = NBodySimulation["InverseSquare", {<|"Mass" -> 1, "Position" -> {0, 0, 0}, "Velocity" -> {0, 0, 0}|>,
<|"Mass" -> 2, "Position" -> {1, 1, 1}, "Velocity" -> {0, 0, 0}|>,
<|"Mass" -> 3, "Position" -> {1, 1, 0}, "Velocity" -> {0, 0, 0}|>,
<|"Mass" -> 4, "Position" -> {0, 1, 1}, "Velocity" -> {0, 0, 0}|>}, 1]ParametricPlot3D[Evaluate[data[All, "Position", t]], {t, 0, 1}]シミュレーションの間にエネルギーがどのように変化するかを表示する:
Plot[Evaluate[Map[data[#, t]&, {"TotalKineticEnergy", "TotalPairwiseInteractionEnergy", "TotalEnergy"}]], {t, 0, 1}, PlotRange -> All]data["Equations"]data["HamiltonEquations"]バネで繋がれた名前付きの3体のシミュレーションを二次元で行う:
data = NBodySimulation[{"Harmonic", "SpringConstant" -> .5, "EquilibriumLength" -> 1.5},
<|"bill" -> <|"Mass" -> .25, "Position" -> {0, 1}, "Velocity" -> {0, 0}|>,
"sam" -> <|"Mass" -> 1, "Position" -> {-1, 0}, "Velocity" -> {0, 0}|>, "george" -> <|"Mass" -> 1, "Position" -> {1, 0}, "Velocity" -> {0, 0}|>|>, 25]「bill」の縦の位置が時間とともにどのように変化するかを示す:
Plot[Last[data["bill", "Position", t]], {t, 0, 25}]「sam」と「george」の水平位置が時間とともにどのように変化するかを示す:
Plot[{First[data["sam", "Position", t]], First[data["george", "Position", t]]}, {t, 0, 25}]names = {"bill", "sam", "george"};ListAnimate[Table[
Graphics[Map[Text[#, data[#, "Position", t]]&, names], PlotRange -> {{-1.5, 1.5}, {-.1, 1.6}}], {t, 0, 25, .25}]]data = NBodySimulation[<|"PairwisePotential" -> "InverseSquare", "Region" -> Disk[]|>, {<|"Mass" -> 1, "Position" -> {0, 0}, "Velocity" -> {0, 0}|>,
<|"Mass" -> 1, "Position" -> {0, -.9}, "Velocity" -> {1, 0}|>,
<|"Mass" -> 1, "Position" -> {0, .9}, "Velocity" -> {-2, 0}|>}, 5]Show[Region[Disk[]], ParametricPlot[Evaluate[data[All, "Position", t]], {t, 0, 5}], Axes -> True]data = NBodySimulation["Coulomb", {<|"Mass" -> Quantity[1, "Kilograms"], "Position" -> Quantity[{0, 0}, "Meters"], "Velocity" -> Quantity[{1, 0}, "Meters" / "Seconds"], "Charge" -> Quantity[10^-4, "Coulombs"]|>,
<|"Mass" -> Quantity[1, "Kilograms"], "Position" -> Quantity[{1, 1}, "Meters"], "Velocity" -> Quantity[{-1, 0}, "Meters" / "Seconds"], "Charge" -> Quantity[-10^-5, "Coulombs"]|>}, 1]ParametricPlot[Evaluate[data[All, "Position", t]], {t, 0, 1}]data = NBodySimulation["InverseSquare", {<|"Mass" -> 1, "Position" -> {0, 0}, "Velocity" -> {0, 0}|>,
<|"Mass" -> 1, "Position" -> {1, 1}, "Velocity" -> {0, 0}|>}, 2]ctime = data["SimulationTime"]ParametricPlot[Evaluate[data[All, "Position", t]], {t, 0, ctime}]n = 7;
data = NBodySimulation[<|"PairwisePotential" -> AssociationThread[Partition[Range[n], 2, 1, {1, 1}] -> ConstantArray[{"Harmonic", "EquilibriumLength" -> (2π/n)}, n]]|>,
MapThread[<|"Mass" -> #1, "Position" -> #2, "Velocity" -> {0, 0}|>&, {Range[n], CirclePoints[1.1, n]}], 47]ParametricPlot[Evaluate[data[All, "Position", t]], {t, 0, 47}]Plot[Evaluate[Table[Norm[data[i, "Position", t] - data[Mod[i + 1, n, 1], "Position", t]], {i, n}]], {t, 0, 47}, PlotRange -> All]"PairwiseForce"を使って半径1の2つの球体間の弾性衝突をモデル化する:
force[r_, e_] := With[{delta = #1["Position"] - #2["Position"]}, Function[delta e Ramp[2 r - Norm[delta]] ^ (3 / 2) / (2 Norm[delta])]];data = NBodySimulation[<|"PairwiseForce" -> force[1., 2.]|>, {<|"Mass" -> 1, "Position" -> {0, 0, 0}, "Velocity" -> {0, 0, 0}|>, <|"Mass" -> 1, "Position" -> {.1, .1, 1}, "Velocity" -> {0, 0, -1}|>}, 2];ParametricPlot3D[Evaluate[data[All, "Position", t]], {t, 0, 2}]data = NBodySimulation["InverseSquare", {<|"Mass" -> 1, "Position" -> {0, 0}, "Velocity" -> {0, .5}, "PositionVariable" -> x1, "MomentumVariable" -> p1|>,
<|"Mass" -> 1, "Position" -> {1, 1}, "Velocity" -> {0, -.5}, "PositionVariable" -> x2, "MomentumVariable" -> p2|>,
<|"Mass" -> 1, "Position" -> {0, 1}, "Velocity" -> {0, 0}, "PositionVariable" -> x3, "MomentumVariable" -> p3|>}, 4]data["Equations"]data["HamiltonEquations"]アプリケーション (1)
sun = Entity["Star", "Sun"];
earth = Entity["Planet", "Earth"];
moon = Entity["PlanetaryMoon", "Moon"];date = DateObject[{2018, 1, 1}, "Day", "Gregorian", -4.];sunPosition = Table[Quantity[0, "AstronomicalUnits"], 3];earthPosition = EntityValue[earth, EntityProperty["Planet", "HelioCoordinates", {"Date" -> date}]];
moonPosition = EntityValue[moon, EntityProperty["PlanetaryMoon", "HelioCoordinates", {"Date" -> date}]];day = Quantity[1, "Days"];sunVelocity = sunPosition / day;
earthVelocity = (EntityValue[earth, EntityProperty["Planet", "HelioCoordinates", {"Date" -> date + day}]] - earthPosition) / day;
moonVelocity = (EntityValue[moon, EntityProperty["PlanetaryMoon", "HelioCoordinates", {"Date" -> date + day}]] - moonPosition) / day;data = NBodySimulation["Newtonian", <|sun -> <|"Position" -> sunPosition, "Velocity" -> sunVelocity|>, earth -> <|"Position" -> earthPosition, "Velocity" -> earthVelocity|>, moon -> <|"Position" -> moonPosition, "Velocity" -> moonVelocity|>|>, Quantity[1, "Years"]]tend = data["SimulationTime"]ParametricPlot3D[Evaluate[data[earth, "Position", t]], {t, 0, tend}]ParametricPlot3D[Evaluate[data[moon, "Position", t] - data[earth, "Position", t]], {t, 0, tend}]Plot[Evaluate[Norm[data[moon, "Position", t] - data[earth, "Position", t]]], {t, 0, tend}]関連するガイド
-
▪
- 微分方程式 ▪
- 天文学の計算とデータ ▪
- 分子の構造と計算 ▪
- 科学的モデル ▪
- 物理学と化学のデータと計算
テキスト
Wolfram Research (2019), NBodySimulation, Wolfram言語関数, https://reference.wolfram.com/language/ref/NBodySimulation.html.
CMS
Wolfram Language. 2019. "NBodySimulation." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NBodySimulation.html.
APA
Wolfram Language. (2019). NBodySimulation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NBodySimulation.html
BibTeX
@misc{reference.wolfram_2026_nbodysimulation, author="Wolfram Research", title="{NBodySimulation}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/NBodySimulation.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_nbodysimulation, organization={Wolfram Research}, title={NBodySimulation}, year={2019}, url={https://reference.wolfram.com/language/ref/NBodySimulation.html}, note=[Accessed: 03-November-2026]}