Skip to content
Permalink
f276491efb
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
69 lines (60 sloc) 1.85 KB
package jat.examples.ThreeBodyExample;
import java.util.ArrayList;
import org.apache.commons.math3.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.sampling.StepHandler;
import org.apache.commons.math3.ode.sampling.StepInterpolator;
import jat.coreNOSA.cm.ThreeBody;
import jat.coreNOSA.math.MatrixVector.data.VectorN;
public class ThreeBodyAPL extends ThreeBody implements FirstOrderDifferentialEquations{
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);
}
@Override
public void computeDerivatives(double arg0, double[] arg1, double[] arg2) {
// TODO Auto-generated method stub
}
@Override
public int getDimension() {
// returns a dimension of 6
return 18;
}
public double[] randv() {
double[] randv = new double[18];
randv[0] = 2.0;
randv[1] = 6.0;
randv[2] = 7.0;
randv[3] = 4.0;
randv[4] = 8.0;
randv[5] = 7.0;
randv[6] = 5.0;
randv[7] = 8.0;
randv[8] = 3.0;
randv[9] = 6.0;
randv[10] = 8.0;
randv[11] = 9.0;
randv[12] = 0.0;
randv[13] = 7.0;
randv[14] = 4.0;
randv[15] = 5.0;
randv[16] = 7.0;
randv[17] = 8.0;
return randv;
}
public StepHandler stepHandler = new StepHandler() {
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]);
time.add(t);
xsol.add(y[0]);
ysol.add(y[1]);
zsol.add(y[2]);
}
};
}