Advertisement
TripleAlpha

HorseshoeModelSimulation with RA * cos(DE) approach

Jan 28th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. /* Princeton University Explorer Competition
  2. * Team: Sherlock Ohms */
  3.  
  4. import java.util.Scanner;
  5. import java.util.ArrayList;
  6. import java.io.*;
  7.  
  8. public class HorseshoeModelSimulation {
  9. public static void main(String[] args) throws IOException {
  10. Scanner input = new Scanner(new File("EphemerisData.txt"));
  11.  
  12. ArrayList<Double> motion = new ArrayList<Double>(); //contains data for apparent motion in RA (corrected by cos(DEC) = real motion in sky (in arcsec/min)
  13. ArrayList<Double> distances = new ArrayList<Double>(); //contains data for simulated distances of horseshoe asteroid to the Sun (in AU)
  14.  
  15. //populates radii and motion ArrayLists with data from Ephemeris simulation
  16. while(input.hasNextLine()) {
  17. //When adding each new motion value in arcsec/min, it is automatically converted to AU/day by the convertMotion() method
  18. // motion.add(convertMotion(input.nextDouble()));
  19. motion.add(input.nextDouble());
  20. distances.add(input.nextDouble());
  21. }
  22.  
  23. ArrayList<Double> modeledDistances = checkModel(motion, distances);
  24.  
  25. double error;
  26. for(int i = 0; i < modeledDistances.size(); i++) {
  27. error = Math.abs(1 - (modeledDistances.get(i) / distances.get(i)));
  28. System.out.printf("%.4f %.4f %.4f\n", distances.get(i), modeledDistances.get(i), error);
  29. }
  30. input.close();
  31. }
  32.  
  33. public static ArrayList<Double> checkModel(ArrayList<Double> motion, ArrayList<Double> distances) {
  34. // Formula: r(theta) = [a * (1 - e^2)] / [1 + e * cos(theta)]
  35.  
  36. ArrayList<Double> modeledDistances = new ArrayList<Double>(); //contains model's calculated distance between horseshoe asteroid and the Sun for each day
  37.  
  38. double distance; //current distance between horseshoe asteroid and the Sun (in AU)
  39. double e = 0.51485; //eccentricity of orbit
  40. double a = 0.99774; //semi-major axis (in AU)
  41. double b = a * (Math.sqrt(1 - Math.pow(e, 2))); //semi-minor axis (in AU)
  42. double theta = 0; //true anomaly: angle between current position of the orbiting object and periapsis (which is the first day of data in the text file) (in radians)
  43.  
  44. //double distanceSincePeriapsis = 0; //distance traveled along orbit since periapsis (in AU)
  45.  
  46. //use approximation of ellipse circumference
  47. //double orbitCircumference = calcCircumference(a, b);
  48.  
  49. for(int i = 0; i < motion.size(); i++) {
  50. //total distance traveled in period to current day is iterative sum of ArrayList<BigDecimal> motion to current day
  51. //distanceSincePeriapsis += motion.get(i);
  52.  
  53. //Now, to obtain the anomaly angle (in radians), we take the percentage of orbit completed and multiply it by 2 pi
  54. //theta = (distanceSincePeriapsis / orbitCircumference) * (2 * Math.PI);
  55. theta += motion.get(i) * 1440 / 3600 * Math.PI / 180;
  56. //System.out.println(theta);
  57.  
  58. distance = (a * (1 - Math.pow(e, 2))) / (1 + e * Math.cos(theta));
  59.  
  60. modeledDistances.add(distance);
  61. }
  62.  
  63. return modeledDistances;
  64. }
  65.  
  66. public static double convertMotion(double motion) {
  67. //motion is given in arcsec/min. First, we must convert it to arcsec/day.
  68.  
  69. double convertedMotion = motion;
  70.  
  71. convertedMotion *= 1440; //There are 1440 minutes in 1 day. Now, we have motion in arcsec/day.
  72.  
  73. convertedMotion = 1 / convertedMotion; //To convert from arcsec/day to parsec/day, we compute 1 / motion.
  74.  
  75. convertedMotion *= 206265; //There are 206265 AU in 1 parsec. Hence, we multiply motion by 206265.
  76.  
  77. return convertedMotion;
  78. }
  79.  
  80. //performs approximation of elliptical circumference given semi-major axis and semi-minor axis; +/- 5% of true circumference
  81. /* public static double calcCircumference(double a, double b) {
  82. double circumference = Math.PI;
  83.  
  84. circumference *= (a + b);
  85.  
  86. double tempMult = 3;
  87. tempMult *= Math.pow(a - b, 2);
  88. tempMult /= Math.pow(a + b, 2);
  89.  
  90. double tempDivisorPart = Math.pow(a - b, 2) / Math.pow(a + b, 2);
  91. tempDivisorPart *= -3;
  92. tempDivisorPart += 4;
  93.  
  94. tempMult /= (Math.sqrt(tempDivisorPart) + 10);
  95.  
  96. tempMult += 1;
  97.  
  98. circumference *= tempMult;
  99.  
  100. return circumference;
  101. } */
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement