Skip to content

Commit

Permalink
partial work on threebody example problem
Browse files Browse the repository at this point in the history
  • Loading branch information
jic13003 committed Dec 2, 2015
1 parent 9b57a20 commit cafa17d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
23 changes: 22 additions & 1 deletion src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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{

Expand All @@ -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;
}
}
11 changes: 6 additions & 5 deletions src/jat/examples/ThreeBodyExample/ThreeBodyExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit cafa17d

Please sign in to comment.