1
votes

I'm having an overflow issue, but I'm not sure why since integers are supposed to be unlimited in pytho. The issue is happening at the last line. OverflowError: (34, 'Result too large').

temperature_planet = 200
temperature_atmosphere = 250

epsilon = 0.25
dt = 60*10
heat_capacity = 1E5
insolation = 1370
sigma = 5.67E-8
planet_radius = 6.4E6
while True:
        temperature_planet += dt*(circle*insolation + sphere* epsilon*sigma* temperature_atmosphere**4 - sphere*sigma*temperature_planet**4)/heat_capacity

If I tried initializing temperature_planet with decimal.Decimal I get:
TypeError: unsupported operand type(s) for *: 'float' and 'decimal.Decimal'

2

2 Answers

0
votes

It's because you are compiling with python2 instead of with python3.

Check this other question: Maximum and Minimum values for ints

0
votes

You are working with various floats... epsilon, heat_capacity, sigma, and planet_radius....

Your expression,

dt*(circle*insolation + sphere* epsilon*sigma* temperature_atmosphere**4 - sphere*sigma*temperature_planet**4)/heat_capacity

will always be a float. Why do you expect otherwise?