diff --git a/src/jat/coreNOSA/cm/ThreeBody.java b/src/jat/coreNOSA/cm/ThreeBody.java index ef46b20..a9eaabd 100644 --- a/src/jat/coreNOSA/cm/ThreeBody.java +++ b/src/jat/coreNOSA/cm/ThreeBody.java @@ -34,9 +34,9 @@ import jat.coreNOSA.math.MatrixVector.data.VectorN; public class ThreeBody implements Derivatives //, Printable { - protected double steps = 500.; - protected double G; // Gravitational constant - protected double m1, m2, m3; // masses + + private double G; // Gravitational constant + private double m1, m2, m3; // masses /** * Method ThreeBody. diff --git a/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java b/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java index 0cabaaa..aa379c1 100644 --- a/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java +++ b/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java @@ -17,20 +17,30 @@ public class ThreeBodyAPL extends ThreeBody implements FirstOrderDifferentialEqu public ArrayList xsol = new ArrayList(); public ArrayList ysol = new ArrayList(); public ArrayList zsol = new ArrayList(); - protected double[] randv[]; + /* + * Why we created the ThreeBodyAPL: + * The APL is responsible for computing the derivatives used in the ThreeBodyExample and interpolating data + * APL stands for Applied Physics Laboratory + */ + + /* + * What we used from existing code + * The information that this class uses from the ThreeBody class are calculations for: + * Masses, center of mass and energy. + * This is usefull for us because all of this is necessary for our modification + */ + public ThreeBodyAPL(double G, double m1, double m2, double m3) { - //constructor super(G, m1, m2, m3); - this.randv(); } - + @Override public void computeDerivatives(double t, double[] y, double[] yDot) { // returns the derivatives of the ThreeBody problem yDot = this.derivs(t, y); } - + @Override public int getDimension() { // returns a dimension of 6 @@ -67,18 +77,18 @@ public class ThreeBodyAPL extends ThreeBody implements FirstOrderDifferentialEqu } public StepHandler stepHandler = new StepHandler() { - //step handler for dp853 integrator public void init(double t0, double[] y0, double t) { } public void handleStep(StepInterpolator interpolator, boolean isLast) { double t = interpolator.getCurrentTime(); double[] y = interpolator.getInterpolatedState(); - System.out.println(t + " " + y[0] + " " + y[1]+ " " + y[2]); //prints time and xyz positions + System.out.println(t + " " + y[0] + " " + y[1]+ " " + y[2]); time.add(t); xsol.add(y[0]); ysol.add(y[1]); zsol.add(y[2]); } }; + } \ No newline at end of file diff --git a/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java b/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java index b55c7e9..cd9a912 100644 --- a/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java +++ b/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java @@ -19,6 +19,13 @@ import org.apache.commons.math3.linear.RealVectorFormat; import org.apache.commons.math3.ode.FirstOrderIntegrator; import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator; +/* + * We modified the ThreeBodyProblem by emulating the two body problem, and expanding it to ThreeBody + * Elements of two body, such as the orbit calculations, were not as heavily focused on + * We acknowledge that some of our calculations may be a bit inaccurate because some of the math got a bit over our heads + * + * @author Maegan and John + */ public class ThreeBodyExample { public ThreeBodyExample() { @@ -53,8 +60,21 @@ public class ThreeBodyExample { VectorN cm = sat.center_of_mass(y); // obtain current energy + totalEnergy = sat.Energy(y); - + /* + * Notes about the calculations: + * Dormand Prince is a type of Runge-Kutta diff eq. (another method of checking diff eq) + * Errors are calculated looking at 4th and 5th level differential equations + * These were most likely chosen by the original creator of the project because they take the error into account fairly accurately + * In relation to physics, this calculates the relative orbits for the bodies + * The step handler is another type of analyzing the algorithms for each body + * These provide fairly accurate results + * + * In general, these equations went over our heads, but refer to the NASA site as well as + * look into other resources to get more information on 3-Body calculations + * + */ // propagate the orbit FirstOrderIntegrator dp853 = new DormandPrince853Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10); dp853.addStepHandler(sat.stepHandler); @@ -112,4 +132,4 @@ public class ThreeBodyExample { System.out.println("end"); } -} +} \ No newline at end of file