Skip to content

Commit

Permalink
This will emulate the jat.examplesTwoBodyExample. We are now in the
Browse files Browse the repository at this point in the history
process of changing our derivatives. We will be looking into the
DormandPrince853Integrator, FirstOrderIntegrator, and
FirstOrderDifferentialEquations
  • Loading branch information
mxd12001 authored and mxd12001 committed Dec 4, 2015
1 parent cafa17d commit 38236f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
12 changes: 10 additions & 2 deletions src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package jat.examples.ThreeBodyExample;

import java.util.ArrayList;

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{
double initial_ta;
public ArrayList<Double> time = new ArrayList<Double>();
public ArrayList<Double> xsol = new ArrayList<Double>();
public ArrayList<Double> ysol = new ArrayList<Double>();
public ArrayList<Double> zsol = new ArrayList<Double>();

public ThreeBodyAPL(double G, double m1, double m2, double m3) {
super(G, m1, m2, m3);
public ThreeBodyAPL(double mu, VectorN r, VectorN v) {
super(mu, r, v);
initial_ta = ta;
}

@Override
Expand Down
22 changes: 10 additions & 12 deletions src/jat/examples/ThreeBodyExample/ThreeBodyExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
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;
import java.text.DecimalFormat;
Expand All @@ -20,29 +18,30 @@
import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator;

public class ThreeBodyExample {

public ThreeBodyExample() {
}

public static void main(String[] args) {
// TODO Auto-generated method stub

ThreeBodyExample x = new ThreeBodyExample();

// create a ThreeBody orbit using three masses and gravitational con
ThreeBodyAPL sat = new ThreeBodyAPL(10, 0.3, 1.0, 2.0);
//initialize VectorN elements
// create a TwoBody orbit using orbit elements
ThreeBodyAPL sat = new ThreeBodyAPL(7000.0, 0.3, 0.0, 0.0, 0.0, 0.0);

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 derivs of the problem
double[] derivs = sat.derivs(2.0, y);
// find out the period of the orbit
double period = sat.period();

// set the final time = one orbit period
double tf = 2.0;
double tf = period;

// set the initial time to zero
double t0 = 0.0;
Expand Down Expand Up @@ -92,5 +91,4 @@ public static void main(String[] args) {
System.out.println("end");

}

}

0 comments on commit 38236f3

Please sign in to comment.