I'm trying to model the solar system with NDSolve
, basically a numerical n-body solution.
I model the initial positions of bodies from a data set thusly:
{"sun",
{-1.068000648301820*^9, -4.176802125684930*^8, 3.084467020687090*^7},
{9.305300847631915, -1.283176670344807*10,-1.631528028381386*^-1},
1.988544*^30, White}
Where the first triplet is the body's initial position with regard to the solar system's barycentre, the second triplet its initial velocity, and the fourth position number its mass.
The NDSolve
, then evaluates the law of gravitation with respect to all tuples of masses in Cartesian component form.
This works fine for the major bodies. I'm currently getting roughly 3-4 accurate significant numbers after a setting the time of the model to 1 year.
My problem is with modelling the asteroid belt. Naturally, I can't model it as a single point particle. So I was wondering if there is a way to model it as a distribution with mass $3\times10^{21}$. I'm really only interested in finding a way to have the asteroid belt excert its gravitational influence on other bodies.
Here is a minimal working example, if I understand how to do it here, I can work out how to incorporate it in the actual model.
Supposing I started with a very simple model of one planet (sun+earth):
G = 6.6740831*10^-11;
{m1,m2} = {1.98855*^30, 5.97237*^24};
a = {x1''[
t] == (G m2) (-x1[t] +
x2[t])/((-x1[t] + x2[t])^2 + (-y1[t] + y2[t])^2 + (-z1[t] +
z2[t])^2)^(3/2),
x2''[
t] == (G m1) (-x2[t] +
x1[t])/((-x2[t] + x1[t])^2 + (-y1[t] + y2[t])^2 + (-z1[t] +
z2[t])^2)^(3/2),
y1''[
t] == (G m2) (-y1[t] +
y2[t])/((-x1[t] + x2[t])^2 + (-y1[t] + y2[t])^2 + (-z1[t] +
z2[t])^2)^(3/2),
y2''[
t] == (G m1) (-y2[t] +
y1[t])/((-x2[t] + x1[t])^2 + (-y1[t] + y2[t])^2 + (-z1[t] +
z2[t])^2)^(3/2),
z1''[
t] == (G m2) (-z1[t] +
z2[t])/((-x1[t] + x2[t])^2 + (-y1[t] + y2[t])^2 + (-z1[t] +
z2[t])^2)^(3/2),
z2''[
t] == (G m1) (-z2[t] +
z1[t])/((-x2[t] + x1[t])^2 + (-y1[t] + y2[t])^2 + (-z1[t] +
z2[t])^2)^(3/2)};
vel = {{Derivative[1][x1][0] == 0,
Derivative[1][x2][0] == 0}, {Derivative[1][y1][0] == -0.0894406,
Derivative[1][y2][0] == 29780}, {Derivative[1][z1][0] == 0,
Derivative[1][z2][0] == 0}};
pos = {{x1[0] == 0, x2[0] == 152100000000}, {y1[0] == 0,
y2[0] == 0}, {z1[0] == 0, z2[0] == 0}};
var = {x1, x2, y1, y2, z1, z2};
tmax = 3600*24*365.24;
s = NDSolve[Flatten[{a, vel, pos}], var, {t, 0, tmax}];
ParametricPlot3D[
Flatten[Thread[{{x1[t], y1[t], z1[t]}, {x2[t], y2[t], z2[t]}} /.s]],
{t, 0, tmax},
PlotRange -> {{-2*^11, 2*^11}, {-2*^11, 2*^11}, {-0.5*^11, 0.5*^11}}]
This doesn't make a complete orbit in one year, but obviously the accuracy here is low.
Where a
is the acceleration vectors ,vel
the velocities, and pos
the positions.