So I went online to find out how you can calculate the temperature of a planetary body based on the size and temperature of its star, and the body's distance from its star. That brought about this solution:
function calcBodyTempSolar(starTemp, starRadius, bodySemiMajorAxis) { //MAGIC math. Determines approx. body temp based on the body's distance from it's star.
return starTemp*Math.sqrt(starRadius/(2 * bodySemiMajorAxis)) * Math.pow(.7, 1/4)}
Next I thought "If I can know how hot a planet will be at a given distance, can I reverse that to determine the "Habitable Zone"?"
I reversed the equation above, but I'm getting the wrong numbers.
(Math.pow(starTemp/(254.58 * Math.pow(0.7, 1/4)), 2) * (starRadius/2))/AU
Running the above equation gives me the wrong number. I have input the proper temperature of earth* but it isn't giving me the right answer. (should be 1, is 1.428...)
*if earth had no atmosphere.
The source of the equations above, is here: https://www.astro.princeton.edu/~strauss/FRS113/writeup3/
I'm thinking that I simply reversed the first equation wrong. But I'm not sure. Any math people here to weigh in?
CodePudding user response:
According to the equation in the source this should be the planet temperature based on star, size and distance. (That part you got right). The reverse is just as simple
function calcPlanetTemp(starTemp, starRadius, distance, absorbtion) {
absorbtion = absorbtion || 0.7
return starTemp * Math.sqrt(starRadius / (2 * distance)) * Math.pow(absorbtion, 1 / 4)
}
var AU = 150 * 1e6; // distance to sun = 1 astornomical unit
// for earth and sun:
var planetTemp = calcPlanetTemp(6000, 700000, AU)
console.log("earth temp (celsius): ", planetTemp - 273.15)
console.log("(that's minus the greenhouse effect)")
// 265.1027012854874
/*
function calcStarTemp(planetTemp, starRadius, distance, absorbtion) {
absorbtion = absorbtion || 0.7
return planetTemp / (Math.sqrt(starRadius / (2 * distance)) * Math.pow(absorbtion, 1 / 4))
}
console.log("sun temp: ", calcStarTemp(planetTemp, 700000, AU))
*/
function calcDistance(planetTemp, starTemp, starRadius, absorbtion) {
absorbtion = absorbtion || 0.7
return 1 / (Math.pow(planetTemp / starTemp / Math.pow(absorbtion, 1 / 4), 2) * 2 / starRadius)
}
console.log("distance from sun: ", calcDistance(planetTemp, 6000, 700000, 0.7))