Simple Climate Model
# Simple climate model (Nathan Urban, nurban@lanl.gov)
import matplotlib.pyplot as plt; import numpy as np
infrared_loss = 1.7 # watts per square meter per degree Celsiusupper_ocean_depth = 100 # meters
water_heat_capacity = 4184000 # Joules per cubic meterheat_capacity = water_heat_capacity * upper_ocean_depthdt = 31557600 # seconds per year
# forcing for doubled CO2number_of_years = 51Forcing = np.full(number_of_years, 3.7) # watts per square meter for doubled CO2Time = np.arange(0, number_of_years, 1)
Temperature = np.zeros(number_of_years)
for year in range(0, number_of_years-1): heat_in = Forcing[year] * dt heat_out = infrared_loss * Temperature[year] * dt heat = heat_in - heat_out
temperature_change = heat / heat_capacity Temperature[year+1] = Temperature[year] + temperature_change
plt.plot(Time, Temperature)plt.xlabel('Year')plt.ylabel('Temperature')plt.show()