Animation of the Motion of a Small Spacecraft Passing Near Jupiter
Science Project 29

by
K. D. Stroyan
University of Iowa

Copyright 1993 by Academic Press, Inc. - All rights reserved.

From the written explanation in Science Project 29, we obtain the differential equations:

		dx/dt = z
		
		dy/dt = w
		
		dz/dt = f   -   for the formula  f  given below
		
		dw/dt = g  -  for the formula g given below

The  rkSoln[{1,f,g},{t,x,y},{t0,x0,y0},tfinal,dt] package

BeginPackage["bddSolutionsRK`"]

rkSoln::usage = "bddSolnRK[{1, e1, e2, ...}, {t, y1, y2, ...},
{t0, a1, a2, ...}, tfin, dt, opns] solves the system of differential
equations yi' = ei, with intial conditions ai, as t goes from t0 to
tfin in steps of dt.  bddSolnRK returns graphs of the solutions drawn
with the specified options and a solutions list.  Solutions that
exceed 10^6 are truncated."


huge = 10^6;

bddRungeKutta[f_List, y_List, y0_List, {t1_, dt_}] :=
	NestList[ rKstep[f, y, #, N[dt]]&, N[y0], Round[N[t1/dt]] ] /;
				Length[f] == Length[y] == Length[y0]
				
rKstep[f_, y_, y0_, dt_] :=
	Block[ {k1, k2, k3, k4, z, huge = 10^6},
		k1 = dt N[ f /. Thread[y -> y0] ] ;
		k2 = dt N[ f /. Thread[y -> y0 + k1/2] ] ;
		k3 = dt N[ f /. Thread[y -> y0 + k2/2] ] ;
		k4 = dt N[ f /. Thread[y -> y0 + k3] ] ;
		z = y0 + (k1 + 2 k2 + 2 k3 + k4)/6 ;
		z /. r_?NumberQ :> huge Sign[r] /; Abs[r] > huge
	]
	
makeGraphs[solutions_List, y_List, opns___Rule] :=
	Block[ {coordnum = Length[ solutions[[1]] ],
			coordvalues = Transpose[solutions],
			horzlabel = y[[1]], sol, j},
		Do[
			sol = coordvalues[[{1, j}]] ;
			sol = Transpose[sol] ;
			ListPlot[ sol, PlotJoined -> True, opns,
						AxesLabel -> {horzlabel, y[[j]]} ],
			{j, 2, coordnum}
		] ;
		Map[ ListPlot[#, PlotJoined -> True, opns]&,
				solutionslist] ;
	]		
	
rkSoln[f_List, y_List, y0_List, tfin_, dt_, 
					opns___Rule] :=
	Block[{},				
		solutions = bddRungeKutta[f, y, y0, {tfin, dt}] ;
		]


EndPackage[]

Physical Parameters

mJ = 9.499 10^-4;
pJ = 2 Pi (5.2)^(3/2) (1 + mJ)^(-1/2);
nJ = 2 Pi/pJ;

Differential Equations

xJ := 5.2 Cos[nJ (t - t0)];
yJ := 5.2 Sin[nJ (t - t0)];

d := Sqrt[(x - xJ)^2 + (y - yJ)^2];
r := Sqrt[x^2 + y^2];  (*Dist. fr Satt. to Sun.*)

f := -x/r^3 - mJ (x - xJ)/d^3;
g := -y/r^3 - mJ (y - yJ)/d^3;

Initial Space Conditions and time step

q = 1;
xI = 1; (*Initial x-position.*)
yI = 0;(*Initial y-position.*)
zI = 0; (*Initial x-velocity.*)
wI = -Sqrt[2 5.2/(q (q + 5.2))]; (*Initial y-velocity.*)

dt = .1 ;

A Big View of a Close Encounter

t0 = -20.5;
(*Initial time for position of Jupiter, 20.5 yrs ago.*)

Do[
rkSoln[{1,z,w,f,g},{t,x,y,z,w},{0,xI,yI,zI,wI},tfinal,dt];
transsoln = Transpose[ solutions ];
xyPairs = Transpose[{transsoln[[2]],transsoln[[3]]}];
satPlot = ListPlot[xyPairs,PlotJoined->True,
	AspectRatio->1,PlotRange->{{-10,10},{-10,10}}];
jupPlot = ParametricPlot[{xJ,yJ},{t,0,tfinal},
	AspectRatio->1,PlotRange->{{-10,10},{-10,10}}];
Show[jupPlot,satPlot,PlotLabel->{"t = ",tfinal}];
,
{tfinal,15,30}]

A Small View of a Close Encounter

t0 = -20.5;
(*Initial time for position of Jupiter, 20.5 yrs ago.*)

Do[
rkSoln[{1,z,w,f,g},{t,x,y,z,w},{0,xI,yI,zI,wI},tfinal,dt];
transsoln = Transpose[ solutions ];
xyPairs = Transpose[{transsoln[[2]],transsoln[[3]]}];
satPlot = ListPlot[xyPairs,PlotJoined->True,
	AspectRatio->1,PlotRange->{{-6,-4},{-2,2}}];
jupPlot = ParametricPlot[{xJ,yJ},{t,0,tfinal},
	AspectRatio->1,PlotRange->{{-6,-4},{-2,2}}];
Show[jupPlot,satPlot,PlotLabel->{"t = ",tfinal}];
,
{tfinal,17,25}]

Does the Cat come Back?