Skip to content

Commit

Permalink
Merge pull request #53 from anthofflab/create-pull-request/patch
Browse files Browse the repository at this point in the history
[AUTO] Format files using DocumentFormat
  • Loading branch information
lrennels authored May 18, 2023
2 parents d099219 + 1feb881 commit a6624f6
Show file tree
Hide file tree
Showing 22 changed files with 346 additions and 346 deletions.
6 changes: 3 additions & 3 deletions src/MimiDICE2010.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module MimiDICE2010

using Mimi
using XLSX:readxlsx
using XLSX: readxlsx

include("parameters.jl")
include("marginaldamage.jl")
Expand Down Expand Up @@ -48,7 +48,7 @@ function get_model(params=nothing)
# Socioeconomics
connect_param!(m, :grosseconomy, :I, :neteconomy, :I)
connect_param!(m, :emissions, :YGROSS, :grosseconomy, :YGROSS)

# Climate
connect_param!(m, :co2cycle, :E, :emissions, :E)
connect_param!(m, :radiativeforcing, :MAT, :co2cycle, :MAT)
Expand Down Expand Up @@ -76,4 +76,4 @@ end

construct_dice = get_model # still export the old version of the function name

end # module
end # module
18 changes: 9 additions & 9 deletions src/components/climatedynamics_component.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@defcomp climatedynamics begin
TATM = Variable(index=[time]) # Increase in temperature of atmosphere (degrees C from 1900)
TOCEAN = Variable(index=[time]) # Increase in temperature of lower oceans (degrees C from 1900)
TATM = Variable(index=[time]) # Increase in temperature of atmosphere (degrees C from 1900)
TOCEAN = Variable(index=[time]) # Increase in temperature of lower oceans (degrees C from 1900)

FORC = Parameter(index=[time]) # Increase in radiative forcing (watts per m2 from 1900)
fco22x = Parameter() # Forcings of equilibrium CO2 doubling (Wm-2)
t2xco2 = Parameter() # Equilibrium temp impact (oC per doubling CO2)
tatm0 = Parameter() # Initial atmospheric temp change (C from 1900) in 2005
tatm1 = Parameter() # Initial atmospheric temp change (C from 1900) in 2015
FORC = Parameter(index=[time]) # Increase in radiative forcing (watts per m2 from 1900)
fco22x = Parameter() # Forcings of equilibrium CO2 doubling (Wm-2)
t2xco2 = Parameter() # Equilibrium temp impact (oC per doubling CO2)
tatm0 = Parameter() # Initial atmospheric temp change (C from 1900) in 2005
tatm1 = Parameter() # Initial atmospheric temp change (C from 1900) in 2015
tocean0 = Parameter() # Initial lower stratum temp change (C from 1900)

# Transient TSC Correction ("Speed of Adjustment Parameter")
Expand All @@ -25,10 +25,10 @@
if t.t == 2
v.TATM[t] = p.tatm1
else
v.TATM[t] = v.TATM[t - 1] + p.c1 * ((p.FORC[t] - (p.fco22x / p.t2xco2) * v.TATM[t - 1]) - (p.c3 * (v.TATM[t - 1] - v.TOCEAN[t - 1])))
v.TATM[t] = v.TATM[t-1] + p.c1 * ((p.FORC[t] - (p.fco22x / p.t2xco2) * v.TATM[t-1]) - (p.c3 * (v.TATM[t-1] - v.TOCEAN[t-1])))
end

v.TOCEAN[t] = v.TOCEAN[t - 1] + p.c4 * (v.TATM[t - 1] - v.TOCEAN[t - 1])
v.TOCEAN[t] = v.TOCEAN[t-1] + p.c4 * (v.TATM[t-1] - v.TOCEAN[t-1])
end
end
end
44 changes: 22 additions & 22 deletions src/components/co2cycle_component.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
@defcomp co2cycle begin
MAT = Variable(index=[time]) # Carbon concentration increase in atmosphere (GtC from 1750)
MAT_final = Variable() # MAT calculation one timestep further than the model's index
ML = Variable(index=[time]) # Carbon concentration increase in lower oceans (GtC from 1750)
MU = Variable(index=[time]) # Carbon concentration increase in shallow oceans (GtC from 1750)
MAT = Variable(index=[time]) # Carbon concentration increase in atmosphere (GtC from 1750)
MAT_final = Variable() # MAT calculation one timestep further than the model's index
ML = Variable(index=[time]) # Carbon concentration increase in lower oceans (GtC from 1750)
MU = Variable(index=[time]) # Carbon concentration increase in shallow oceans (GtC from 1750)

E = Parameter(index=[time]) # Total CO2 emissions (GtC per year)
mat0 = Parameter() # Initial Concentration in atmosphere 2000 (GtC)
mat1 = Parameter() # Concentration 2010 (GtC)
ml0 = Parameter() # Initial Concentration in lower strata (GtC)
mu0 = Parameter() # Initial Concentration in upper strata (GtC)
E = Parameter(index=[time]) # Total CO2 emissions (GtC per year)
mat0 = Parameter() # Initial Concentration in atmosphere 2000 (GtC)
mat1 = Parameter() # Concentration 2010 (GtC)
ml0 = Parameter() # Initial Concentration in lower strata (GtC)
mu0 = Parameter() # Initial Concentration in upper strata (GtC)

# Parameters for long-run consistency of carbon cycle
b11 = Parameter() # Carbon cycle transition matrix atmosphere to atmosphere
b12 = Parameter() # Carbon cycle transition matrix atmosphere to shallow ocean
b21 = Parameter() # Carbon cycle transition matrix biosphere/shallow oceans to atmosphere
b22 = Parameter() # Carbon cycle transition matrix shallow ocean to shallow oceans
b23 = Parameter() # Carbon cycle transition matrix shallow to deep ocean
b32 = Parameter() # Carbon cycle transition matrix deep ocean to shallow ocean
b33 = Parameter() # Carbon cycle transition matrix deep ocean to deep oceans
b11 = Parameter() # Carbon cycle transition matrix atmosphere to atmosphere
b12 = Parameter() # Carbon cycle transition matrix atmosphere to shallow ocean
b21 = Parameter() # Carbon cycle transition matrix biosphere/shallow oceans to atmosphere
b22 = Parameter() # Carbon cycle transition matrix shallow ocean to shallow oceans
b23 = Parameter() # Carbon cycle transition matrix shallow to deep ocean
b32 = Parameter() # Carbon cycle transition matrix deep ocean to shallow ocean
b33 = Parameter() # Carbon cycle transition matrix deep ocean to deep oceans

function run_timestep(p, v, d, t)
# Define functions for MU, ML, and MAT
Expand All @@ -29,15 +29,15 @@
v.MAT[TimestepIndex(1)] = p.mat0
v.MAT[TimestepIndex(2)] = p.mat1

else
else

v.MU[t] = v.MAT[t - 1] * p.b12 + v.MU[t - 1] * p.b22 + v.ML[t - 1] * p.b32
v.MU[t] = v.MAT[t-1] * p.b12 + v.MU[t-1] * p.b22 + v.ML[t-1] * p.b32

v.ML[t] = v.ML[t - 1] * p.b33 + v.MU[t - 1] * p.b23
v.ML[t] = v.ML[t-1] * p.b33 + v.MU[t-1] * p.b23

if !is_last(t)
v.MAT[t+1] = v.MAT[t] * p.b11 + v.MU[t] * p.b21 + p.E[t] * 10

if ! is_last(t)
v.MAT[t + 1] = v.MAT[t] * p.b11 + v.MU[t] * p.b21 + p.E[t] * 10

else # last timestep
v.MAT_final = v.MAT[t] * p.b11 + v.MU[t] * p.b21 + p.E[t] * 10
end
Expand Down
22 changes: 11 additions & 11 deletions src/components/damages_component.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@defcomp damages begin
DAMFRAC = Variable(index=[time]) # Damages (fraction of gross output)

TATM = Parameter(index=[time]) # Increase temperature of atmosphere (degrees C from 1900)
YGROSS = Parameter(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)
a1 = Parameter() # Damage intercept
a2 = Parameter() # Damage quadratic term
a3 = Parameter() # Damage exponent
TotSLR = Parameter(index=[time]) # Path of total SLR
b1 = Parameter() # Coefficient on SLR
b2 = Parameter() # Coefficient on quadratic SLR term
b3 = Parameter() # SLR exponent
TATM = Parameter(index=[time]) # Increase temperature of atmosphere (degrees C from 1900)
YGROSS = Parameter(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)
a1 = Parameter() # Damage intercept
a2 = Parameter() # Damage quadratic term
a3 = Parameter() # Damage exponent

TotSLR = Parameter(index=[time]) # Path of total SLR
b1 = Parameter() # Coefficient on SLR
b2 = Parameter() # Coefficient on quadratic SLR term
b3 = Parameter() # SLR exponent

function run_timestep(p, v, d, t)
# Define function for DAMFRAC
v.DAMFRAC[t] = p.a1 * p.TATM[t] + p.a2 * p.TATM[t]^p.a3 + p.b1 * p.TotSLR[t] + p.b2 * p.TotSLR[t]^p.b3
v.DAMFRAC[t] = p.a1 * p.TATM[t] + p.a2 * p.TATM[t]^p.a3 + p.b1 * p.TotSLR[t] + p.b2 * p.TotSLR[t]^p.b3
end

end
22 changes: 11 additions & 11 deletions src/components/emissions_component.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
@defcomp emissions begin
CCA = Variable(index=[time]) # Cumulative indiustrial emissions
E = Variable(index=[time]) # Total CO2 emissions (GtC per year)
EIND = Variable(index=[time]) # Industrial emissions (GtC per year)
CCA = Variable(index=[time]) # Cumulative indiustrial emissions
E = Variable(index=[time]) # Total CO2 emissions (GtC per year)
EIND = Variable(index=[time]) # Industrial emissions (GtC per year)

etree = Parameter(index=[time]) # Emissions from deforestation
MIU = Parameter(index=[time]) # Emission control rate GHGs
sigma = Parameter(index=[time]) # CO2-equivalent-emissions output ratio
YGROSS = Parameter(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)
etree = Parameter(index=[time]) # Emissions from deforestation
MIU = Parameter(index=[time]) # Emission control rate GHGs
sigma = Parameter(index=[time]) # CO2-equivalent-emissions output ratio
YGROSS = Parameter(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)

function run_timestep(p, v, d, t)
# Define function for EIND
v.EIND[t] = p.sigma[t] * p.YGROSS[t] * (1 - p.MIU[t])

# Define function for E
v.E[t] = v.EIND[t] + p.etree[t]

# Define function for CCA
if is_first(t)
v.CCA[t] = v.EIND[t] * 10
v.CCA[t] = v.EIND[t] * 10
else
v.CCA[t] = v.CCA[t - 1] + v.EIND[t] * 10
v.CCA[t] = v.CCA[t-1] + v.EIND[t] * 10
end
end
end
18 changes: 9 additions & 9 deletions src/components/grosseconomy_component.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@defcomp grosseconomy begin
K = Variable(index=[time]) # Capital stock (trillions 2005 US dollars)
YGROSS = Variable(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)
K = Variable(index=[time]) # Capital stock (trillions 2005 US dollars)
YGROSS = Variable(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)

al = Parameter(index=[time]) # Level of total factor productivity
I = Parameter(index=[time]) # Investment (trillions 2005 USD per year)
l = Parameter(index=[time]) # Level of population and labor
dk = Parameter() # Depreciation rate on capital (per year)
gama = Parameter() # Capital elasticity in production function
k0 = Parameter() # Initial capital value (trill 2005 USD)
al = Parameter(index=[time]) # Level of total factor productivity
I = Parameter(index=[time]) # Investment (trillions 2005 USD per year)
l = Parameter(index=[time]) # Level of population and labor
dk = Parameter() # Depreciation rate on capital (per year)
gama = Parameter() # Capital elasticity in production function
k0 = Parameter() # Initial capital value (trill 2005 USD)

function run_timestep(p, v, d, t)
# Define function for K
if is_first(t)
v.K[t] = p.k0
else
v.K[t] = v.K[t - 1] * (1 - p.dk)^10 + 10 * p.I[t - 1]
v.K[t] = v.K[t-1] * (1 - p.dk)^10 + 10 * p.I[t-1]
end

# Define function for YGROSS
Expand Down
38 changes: 19 additions & 19 deletions src/components/neteconomy_component.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
@defcomp neteconomy begin

ABATECOST = Variable(index=[time]) # Cost of emissions reductions (trillions 2005 USD per year)
C = Variable(index=[time]) # Consumption (trillions 2005 US dollars per year)
CPC = Variable(index=[time]) # Per capita consumption (thousands 2005 USD per year)
CPRICE = Variable(index=[time]) # Carbon price (2005$ per ton of CO2)
I = Variable(index=[time]) # Investment (trillions 2005 USD per year)
Y = Variable(index=[time]) # Gross world product net of abatement and damages (trillions 2005 USD per year)
YNET = Variable(index=[time]) # Output net of damages equation (trillions 2005 USD per year)

cost1 = Parameter(index=[time]) # Abatement cost function coefficient
DAMFRAC = Parameter(index=[time]) # Damages (fraction of gross output)
l = Parameter(index=[time]) # Level of population and labor
MIU = Parameter(index=[time]) # Emission control rate GHGs
partfract = Parameter(index=[time]) # Fraction of emissions in control regime
pbacktime = Parameter(index=[time]) # Backstop price
S = Parameter(index=[time]) # Gross savings rate as fraction of gross world product
YGROSS = Parameter(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)
expcost2 = Parameter() # Exponent of control cost function
ABATECOST = Variable(index=[time]) # Cost of emissions reductions (trillions 2005 USD per year)
C = Variable(index=[time]) # Consumption (trillions 2005 US dollars per year)
CPC = Variable(index=[time]) # Per capita consumption (thousands 2005 USD per year)
CPRICE = Variable(index=[time]) # Carbon price (2005$ per ton of CO2)
I = Variable(index=[time]) # Investment (trillions 2005 USD per year)
Y = Variable(index=[time]) # Gross world product net of abatement and damages (trillions 2005 USD per year)
YNET = Variable(index=[time]) # Output net of damages equation (trillions 2005 USD per year)

cost1 = Parameter(index=[time]) # Abatement cost function coefficient
DAMFRAC = Parameter(index=[time]) # Damages (fraction of gross output)
l = Parameter(index=[time]) # Level of population and labor
MIU = Parameter(index=[time]) # Emission control rate GHGs
partfract = Parameter(index=[time]) # Fraction of emissions in control regime
pbacktime = Parameter(index=[time]) # Backstop price
S = Parameter(index=[time]) # Gross savings rate as fraction of gross world product
YGROSS = Parameter(index=[time]) # Gross world product GROSS of abatement and damages (trillions 2005 USD per year)
expcost2 = Parameter() # Exponent of control cost function

function run_timestep(p, v, d, t)
# Define function for YNET
Expand All @@ -37,15 +37,15 @@
elseif t < TimestepIndex(60)
v.C[t] = v.Y[t] - v.I[t]
elseif t == TimestepIndex(60)
v.C[t] = v.C[t - 1]
v.C[t] = v.C[t-1]
end

# Define function for CPC
v.CPC[t] = 1000 * v.C[t] / p.l[t]

# Define function for CPRICE
if t == TimestepIndex(26)
v.CPRICE[t] = v.CPRICE[t - 1]
v.CPRICE[t] = v.CPRICE[t-1]
else
v.CPRICE[t] = p.pbacktime[t] * 1000 * p.MIU[t]^(p.expcost2 - 1)
end
Expand Down
12 changes: 6 additions & 6 deletions src/components/radiativeforcing_component.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@defcomp radiativeforcing begin
FORC = Variable(index=[time]) # Increase in radiative forcing (watts per m2 from 1900)
FORC = Variable(index=[time]) # Increase in radiative forcing (watts per m2 from 1900)

forcoth = Parameter(index=[time]) # Exogenous forcing for other greenhouse gases
MAT = Parameter(index=[time]) # Carbon concentration increase in atmosphere (GtC from 1750)
forcoth = Parameter(index=[time]) # Exogenous forcing for other greenhouse gases
MAT = Parameter(index=[time]) # Carbon concentration increase in atmosphere (GtC from 1750)
MAT_final = Parameter() # MAT calculation one timestep further than the model's index
fco22x = Parameter() # Forcings of equilibrium CO2 doubling (Wm-2)
fco22x = Parameter() # Forcings of equilibrium CO2 doubling (Wm-2)

function run_timestep(p, v, d, t)
# Define function for FORC
if ! is_last(t)
v.FORC[t] = p.fco22x * (log((((p.MAT[t] + p.MAT[t + 1]) / 2) + 0.000001) / 596.4) / log(2)) + p.forcoth[t]
if !is_last(t)
v.FORC[t] = p.fco22x * (log((((p.MAT[t] + p.MAT[t+1]) / 2) + 0.000001) / 596.4) / log(2)) + p.forcoth[t]
else # final timestep
# need to use MAT_final, calculated one step further
v.FORC[t] = p.fco22x * (log((((p.MAT[t] + p.MAT_final) / 2) + 0.000001) / 596.4) / log(2)) + p.forcoth[t]
Expand Down
Loading

0 comments on commit a6624f6

Please sign in to comment.