Files
global_warming_course/Time-Stepping Naked Planet Model/Grading/Naked_Earth.py
2025-09-16 13:35:18 +02:00

33 lines
950 B
Python

import matplotlib.pyplot as plt
timeStep = 10 # years
waterDepth = 4000 # meters
L = 1350 # Watts/m2
albedo = 0.3
epsilon = 1
sigma = 5.67E-8 # W/m2 K4
#nSteps = int(input(""))
nSteps=200
heat_cap=waterDepth*4.2E6 #J/Kg/deg
time_list=[0]
temperature_list=[400]
heat_content=heat_cap*temperature_list[0]
heat_in=L*(1-albedo)/4
heat_out=0
secs_in_yr=3.14E7
for t in range(0,nSteps):
time_list.append(timeStep+time_list[-1])
heat_out=epsilon*sigma*pow(temperature_list[-1],4)
heat_content=heat_content+(heat_in-heat_out)*timeStep*secs_in_yr
temperature_list.append(heat_content/heat_cap)
heat_out = epsilon * sigma * pow(temperature_list[-1], 4)
print(temperature_list[-1])
#print(temperature_list[-1], heat_out)
plt.plot(time_list, temperature_list, marker='.', color="k")
plt.xlabel("Time (years)")
plt.ylabel("Temperature (degrees Kelvin)")
plt.show()