Ghostotw

Goldilocks Zone Calculator

Sep 12th, 2017
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. //variables are currently hard-coded to Earth values. Plan to parameterize them to allow variation
  7. //based on the algorithm explained in this video- https://www.youtube.com/watch?v=GK6J-t_cBPw
  8.  
  9. int nPlanetDiameter = 12756; //not needed with the current hard-coded values
  10. int nPowerIn = 1368; //watts per square meter as received from the sun
  11. int nGreenhouseEffect = 30; //degrees celsius added by atmosphere
  12. int nMinTemp = 273; //freezing point of water in degrees Kelvin
  13. int nMaxTemp = 373; //boiling point of water in degrees kelvin
  14.  
  15. float fAlbedo = .3; //percentage of energy reflected by the atmosphere
  16. float fDistance = 1; //distance in AU
  17.  
  18. double dStefanConstant = 5.6704e-8; //constant which defines heat loss from planet
  19.  
  20. void calculate(int temp)
  21. {
  22.     fDistance = sqrt ((nPowerIn*(1 - fAlbedo))/(4*dStefanConstant*(pow(temp-nGreenhouseEffect,4)))) ;
  23. }
  24.  
  25. int main()
  26. {
  27.     calculate(nMinTemp);
  28.     cout << "Water would freeze at " << fDistance << " AU from the star." << endl;
  29.     calculate(nMaxTemp);
  30.     cout << "Water would boil off at " << fDistance << " AU from the star." << endl;
  31.  
  32.     system("pause");
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment