Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- //variables are currently hard-coded to Earth values. Plan to parameterize them to allow variation
- //based on the algorithm explained in this video- https://www.youtube.com/watch?v=GK6J-t_cBPw
- int nPlanetDiameter = 12756; //not needed with the current hard-coded values
- int nPowerIn = 1368; //watts per square meter as received from the sun
- int nGreenhouseEffect = 30; //degrees celsius added by atmosphere
- int nMinTemp = 273; //freezing point of water in degrees Kelvin
- int nMaxTemp = 373; //boiling point of water in degrees kelvin
- float fAlbedo = .3; //percentage of energy reflected by the atmosphere
- float fDistance = 1; //distance in AU
- double dStefanConstant = 5.6704e-8; //constant which defines heat loss from planet
- void calculate(int temp)
- {
- fDistance = sqrt ((nPowerIn*(1 - fAlbedo))/(4*dStefanConstant*(pow(temp-nGreenhouseEffect,4)))) ;
- }
- int main()
- {
- calculate(nMinTemp);
- cout << "Water would freeze at " << fDistance << " AU from the star." << endl;
- calculate(nMaxTemp);
- cout << "Water would boil off at " << fDistance << " AU from the star." << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment