This maybe isn't a universally helpful question. Maybe a little of a code dump. But here goes.
I'm trying to solve the path Earth moves around Sun from Earths mass, Suns mass, Earths initial velocity and position.
Using NDSolve
this set of equations produces a right kind of result:
nSolutionWorks =
NDSolve[{
forceParticle2ExertsOnParticle1[1][t] == (x1[1]'')[t],
forceParticle2ExertsOnParticle1[2][t] == (x1[2]'')[t],
forceParticle1ExertsOnParticle2[1][t] == 10 (x2[1]'')[t],
forceParticle1ExertsOnParticle2[2][t] == 10 (x2[2]'')[t],
forceParticle1ExertsOnParticle2[1][t] == -forceParticle2ExertsOnParticle1[1][t],
forceParticle1ExertsOnParticle2[2][t] == -forceParticle2ExertsOnParticle1[2][t],
forceParticle2ExertsOnParticle1[1][t] == (10 (-x1[1][t] + x2[1][t]))/(Abs[-x1[1][t] + x2[1][t]]^2 + Abs[-x1[2][t] + x2[2][t]]^2)^(3/2),
forceParticle2ExertsOnParticle1[2][t] == (10 (-x1[2][t] + x2[2][t]))/(Abs[-x1[1][t] + x2[1][t]]^2 + Abs[-x1[2][t] + x2[2][t]]^2)^(3/2),
x1[1][0] == 1,
x1[2][0] == 0,
x2[1][0] == 0,
x2[2][0] == 0,
Derivative[1][x1[1]][0] == 0,
Derivative[1][x1[2]][0] == 2,
Derivative[1][x1[1]][0] + 10 Derivative[1][x2[1]][0] == 0,
Derivative[1][x1[2]][0] + 10 Derivative[1][x2[2]][0] == 0},
{x1[1], x1[2], x2[1], x2[2]}, {t, 0, 10}]
The equations use dummy values for the initial values I mentioned. The next equation has these values replaced with real ones. I just can't get it to work though. Any ideas?
nSolutionDoesntWork = NDSolve[
{forceParticle2ExertsOnParticle1[1][t] ==
5.9721986`*^24 (x1[1]'')[t],
forceParticle2ExertsOnParticle1[2][t] ==
5.9721986`*^24 (x1[2]'')[t],
forceParticle1ExertsOnParticle2[1][t] ==
1.988435`*^30 (x2[1]'')[t],
forceParticle1ExertsOnParticle2[2][t] ==
1.988435`*^30 (x2[2]'')[t],
forceParticle1ExertsOnParticle2[1][
t] == -forceParticle2ExertsOnParticle1[1][t],
forceParticle1ExertsOnParticle2[2][
t] == -forceParticle2ExertsOnParticle1[2][t],
forceParticle2ExertsOnParticle1[1][t] == (
7.925404384598102`*^44 (-x1[1][t] +
x2[1][t]))/(Abs[-x1[1][t] + x2[1][t]]^2 +
Abs[-x1[2][t] + x2[2][t]]^2)^(3/2),
forceParticle2ExertsOnParticle1[2][t] == (
7.925404384598102`*^44 (-x1[2][t] +
x2[2][t]))/(Abs[-x1[1][t] + x2[1][t]]^2 +
Abs[-x1[2][t] + x2[2][t]]^2)^(3/2),
x1[1][0] == 1.4956645729619998`*^11, x1[2][0] == 0, x2[1][0] == 0,
x2[2][0] == 0, Derivative[1][x1[1]][0] == 0,
Derivative[1][x1[2]][0] == 465.10109`,
5.9721986`*^24 Derivative[1][x1[1]][0] +
1.988435`*^30 Derivative[1][x2[1]][0] == 0,
5.9721986`*^24 Derivative[1][x1[2]][0] +
1.988435`*^30 Derivative[1][x2[2]][0] == 0},
{x1[1], x1[2], x2[1], x2[2]},
{t, 0, 60*60*24*300}
]
Evaluating the second NDSolve
gives two error messages:
NDSolve::ivres: NDSolve has computed initial values that give a zero residual for the differential-algebraic system, but some components are different from those specified. If you need them to be satisfied, giving initial conditions for all dependent variables and their derivatives is recommended.
NDSolve::ndsz: At t == 1079.398900143744`, step size is effectively zero; singularity or stiff system suspected.