Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
finished project
  • Loading branch information
rog13002 committed Dec 9, 2015
1 parent 2686368 commit a520d53
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
43 changes: 28 additions & 15 deletions src/jat/examples/ThreeBodyExample/ThreeBodyAPL.java
Expand Up @@ -60,23 +60,23 @@ public class ThreeBodyAPL extends ThreeBody implements FirstOrderDifferentialEqu
// vector v3 is x[15], x[16], x[17]
double[] randv = new double[18];
randv[0] = 2.0;
randv[1] = 6.0;
randv[2] = 7.0;
randv[1] = 3.0;
randv[2] = 3.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[4] = 5.0;
randv[5] = 5.0;
randv[6] = 4.0;
randv[7] = 5.0;
randv[8] = 6.0;
randv[9] = 7.0;
randv[10] = 7.0;
randv[11] = 8.0;
randv[12] = 9.0;
randv[13] = 0.0;
randv[14] = 0.0;
randv[15] = 7.0;
randv[16] = 7.0;
randv[17] = 8.0;
randv[17] = 7.0;
return randv;
}

Expand All @@ -87,11 +87,24 @@ public class ThreeBodyAPL extends ThreeBody implements FirstOrderDifferentialEqu
public void handleStep(StepInterpolator interpolator, boolean isLast) {
double t = interpolator.getCurrentTime();
double[] y = interpolator.getInterpolatedState();
// takes first mass elements and adds it to array
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]);
// takes second mass elements and adds it to array
System.out.println(t + " " + y[6] + " " + y[7]+ " " + y[8]);
time.add(t);
xsol.add(y[6]);
ysol.add(y[7]);
zsol.add(y[8]);
//takes third mass elements and adds it to array
System.out.println(t + " " + y[12] + " " + y[13]+ " " + y[14]);
time.add(t);
xsol.add(y[12]);
ysol.add(y[13]);
zsol.add(y[14]);
}
};

Expand Down
12 changes: 6 additions & 6 deletions src/jat/examples/ThreeBodyExample/ThreeBodyExample.java
Expand Up @@ -118,16 +118,16 @@ public class ThreeBodyExample {

// test outputs
// output derivatives
for (int i = 0; i< derivs.length; i++)
{
System.out.println(derivs[i]);
}
//for (int i = 0; i< derivs.length; i++)
//{
// System.out.println(derivs[i]);
//}

// output center of mass
System.out.println(cm);
System.out.println("\nCenter of Mass: "+ cm);

// output total energy of the system
System.out.println(totalEnergy);
System.out.println("Total Energy of the System: "+ totalEnergy + "\n");
new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

System.out.println("end");
Expand Down

0 comments on commit a520d53

Please sign in to comment.