From cafa17d82cfe211a8b2092adbb3bf2481f09d12b Mon Sep 17 00:00:00 2001 From: jic13003 Date: Wed, 2 Dec 2015 17:40:36 -0400 Subject: [PATCH] partial work on threebody example problem --- .../ThreeBodyExample/ThreeBodyAPL.java | 23 ++++++++++++++++++- .../ThreeBodyExample/ThreeBodyExample.java | 11 +++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java b/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java index 966bccc..28104e0 100644 --- a/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java +++ b/src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java @@ -3,6 +3,7 @@ import org.apache.commons.math3.ode.FirstOrderDifferentialEquations; import jat.coreNOSA.cm.ThreeBody; +import jat.coreNOSA.math.MatrixVector.data.VectorN; public class ThreeBodyAPL extends ThreeBody implements FirstOrderDifferentialEquations{ @@ -21,5 +22,25 @@ public int getDimension() { // returns a dimension of 6 return 6; } - + public double[] randv() { + double[] randv = new double[17]; + randv[1] = 1.0; + randv[2] = 1.0; + randv[3] = 1.0; + randv[4] = 1.0; + randv[5] = 1.0; + randv[6] = 1.0; + randv[7] = 1.0; + randv[8] = 1.0; + randv[9] = 1.0; + randv[10] = 1.0; + randv[11] = 1.0; + randv[12] = 1.0; + randv[13] = 1.0; + randv[14] = 1.0; + randv[15] = 1.0; + randv[16] = 1.0; + randv[17] = 1.0; + return randv; + } } diff --git a/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java b/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java index 59c687e..485a326 100644 --- a/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java +++ b/src/jat/examples/ThreeBodyExample/ThreeBodyExample.java @@ -5,6 +5,7 @@ import jat.core.plot.plot.Plot2DPanel; import jat.core.plot.plot.PlotPanel; import jat.core.plot.plot.plots.ScatterPlot; +import jat.coreNOSA.math.MatrixVector.data.VectorN; import jat.examples.TwoBodyExample.TwoBodyExample; import java.awt.Color; @@ -29,19 +30,19 @@ public static void main(String[] args) { // create a ThreeBody orbit using three masses and gravitational con ThreeBodyAPL sat = new ThreeBodyAPL(10, 0.3, 1.0, 2.0); //initialize VectorN elements - VectorN randv = new VectorN() - + double[] y = sat.randv(); + ArrayRealVector v = new ArrayRealVector(y); DecimalFormat df2 = new DecimalFormat("#,###,###,##0.00"); RealVectorFormat format = new RealVectorFormat(df2); System.out.println(format.format(v)); - // find out the period of the orbit - double period = sat.period(); + // find out the derivs of the problem + double[] derivs = sat.derivs(2.0, y); // set the final time = one orbit period - double tf = period; + double tf = 2.0; // set the initial time to zero double t0 = 0.0;