Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AUTO] Format files using DocumentFormat #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MimiRICE2010.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function constructrice(p)
return m
end #function

function get_model(;datafile=joinpath(@__DIR__, "..", "data", "RICE_2010_base_000.xlsm"))
function get_model(; datafile=joinpath(@__DIR__, "..", "data", "RICE_2010_base_000.xlsm"))
params = getrice2010parameters(datafile)

m = constructrice(params)
Expand Down
2 changes: 1 addition & 1 deletion src/components/climatedynamics_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
elseif 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

#Define function for TOCEAN
Expand Down
2 changes: 1 addition & 1 deletion src/components/co2cycle_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
if is_first(t)
v.MATSUM[t] = 0
else
v.MATSUM[t] = v.MAT[t] + (v.MAT[t] * p.b11 + v.MU[t] * p.b21 + (p.E[t] * 10))
v.MATSUM[t] = v.MAT[t] + (v.MAT[t] * p.b11 + v.MU[t] * p.b21 + (p.E[t] * 10))
end
end
end
6 changes: 3 additions & 3 deletions src/components/damages_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

#Define function for DAMFRAC
for r in d.regions
v.DAMFRAC[t,r] = (((p.a1[r] * p.TATM[t]) + (p.a2[r] * p.TATM[t]^p.a3[r])) / 100) + (p.SLRDAMAGES[t,r] / 100)
v.DAMFRAC[t, r] = (((p.a1[r] * p.TATM[t]) + (p.a2[r] * p.TATM[t]^p.a3[r])) / 100) + (p.SLRDAMAGES[t, r] / 100)
end

#Define function for DAMAGES
for r in d.regions
if is_first(t)
v.DAMAGES[t,r] = p.YGROSS[t,r] * (1 - 1 / (1+v.DAMFRAC[t,r]))
v.DAMAGES[t, r] = p.YGROSS[t, r] * (1 - 1 / (1 + v.DAMFRAC[t, r]))
else
v.DAMAGES[t,r] = (p.YGROSS[t,r] * v.DAMFRAC[t,r]) / (1. + v.DAMFRAC[t,r]^10)
v.DAMAGES[t, r] = (p.YGROSS[t, r] * v.DAMFRAC[t, r]) / (1. + v.DAMFRAC[t, r]^10)
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions src/components/emissions_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@

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

#Define function for E
v.E[t] = sum(v.EIND[t,:]) + p.etree[t]
v.E[t] = sum(v.EIND[t, :]) + p.etree[t]

#Define function for CCA
if is_first(t)
v.CCA[t] = sum(v.EIND[t,:]) * 10.
v.CCA[t] = sum(v.EIND[t, :]) * 10.
else
v.CCA[t] = v.CCA[t-1] + (sum(v.EIND[t,:]) * 10.)
v.CCA[t] = v.CCA[t-1] + (sum(v.EIND[t, :]) * 10.)
end

#Define function for ABATECOST
for r in d.regions
v.ABATECOST[t,r] = p.YGROSS[t,r] * p.cost1[t,r] * (p.MIU[t,r]^p.expcost2[r]) * (p.partfract[t,r]^(1 - p.expcost2[r]))
v.ABATECOST[t, r] = p.YGROSS[t, r] * p.cost1[t, r] * (p.MIU[t, r]^p.expcost2[r]) * (p.partfract[t, r]^(1 - p.expcost2[r]))
end

#Define function for MCABATE
for r in d.regions
v.MCABATE[t,r] = p.pbacktime[t,r] * p.MIU[t,r]^(p.expcost2[r] - 1)
v.MCABATE[t, r] = p.pbacktime[t, r] * p.MIU[t, r]^(p.expcost2[r] - 1)
end

#Define function for CPRICE
for r in d.regions
v.CPRICE[t,r] = p.pbacktime[t,r] * 1000 * p.MIU[t,r]^(p.expcost2[r] - 1)
v.CPRICE[t, r] = p.pbacktime[t, r] * 1000 * p.MIU[t, r]^(p.expcost2[r] - 1)
end
end

Expand Down
8 changes: 4 additions & 4 deletions src/components/grosseconomy_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
#Define function for K
for r in d.regions
if is_first(t)
v.K[t,r] = p.k0[r]
v.K[t, r] = p.k0[r]
else
v.K[t,r] = (1 - p.dk[r])^10 * v.K[t-1,r] + 10 * p.I[t-1,r]
v.K[t, r] = (1 - p.dk[r])^10 * v.K[t-1, r] + 10 * p.I[t-1, r]
end
end

#Define function for YGROSS
for r in d.regions
v.YGROSS[t,r] = (p.al[t,r] * (p.l[t,r]/1000)^(1-p.gama)) * (v.K[t,r]^p.gama)
v.YGROSS[t, r] = (p.al[t, r] * (p.l[t, r] / 1000)^(1 - p.gama)) * (v.K[t, r]^p.gama)
end

# TODO remove this, just a temporary output trick
for r in d.regions
v.L[t,r] = p.l[t,r]
v.L[t, r] = p.l[t, r]
end
end
end
14 changes: 7 additions & 7 deletions src/components/neteconomy_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@
#Define function for YNET
for r in d.regions
if is_first(t)
v.YNET[t,r] = p.YGROSS[t,r]/(1+p.DAMFRAC[t,r])
v.YNET[t, r] = p.YGROSS[t, r] / (1 + p.DAMFRAC[t, r])
else
v.YNET[t,r] = p.YGROSS[t,r] - p.DAMAGES[t,r]
v.YNET[t, r] = p.YGROSS[t, r] - p.DAMAGES[t, r]
end
end

#Define function for Y
for r in d.regions
v.Y[t,r] = v.YNET[t,r] - p.ABATECOST[t,r]
v.Y[t, r] = v.YNET[t, r] - p.ABATECOST[t, r]
end

#Define function for I
for r in d.regions
v.I[t,r] = p.S[t,r] * v.Y[t,r]
v.I[t, r] = p.S[t, r] * v.Y[t, r]
end

#Define function for C
for r in d.regions
if t.t != 60
v.C[t,r] = v.Y[t,r] - v.I[t,r]
v.C[t, r] = v.Y[t, r] - v.I[t, r]
else
v.C[t,r] = v.C[t-1, r]
v.C[t, r] = v.C[t-1, r]
end
end

#Define function for CPC
for r in d.regions
v.CPC[t,r] = 1000 * v.C[t,r] / p.l[t,r]
v.CPC[t, r] = 1000 * v.C[t, r] / p.l[t, r]
end
end
end
4 changes: 2 additions & 2 deletions src/components/radiativeforcing_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
function run_timestep(p, v, d, t)
#Define function for FORC
if is_first(t)
v.FORC[t] = p.fco22x * ((log10((((p.MAT[t] + p.mat1)/2)+0.000001)/596.4)/log10(2))) + p.forcoth[t] #TEMP NOTE: Uses mat1 because it's given as a parameter...not calculated so couldn't use MATSUM
v.FORC[t] = p.fco22x * ((log10((((p.MAT[t] + p.mat1) / 2) + 0.000001) / 596.4) / log10(2))) + p.forcoth[t] #TEMP NOTE: Uses mat1 because it's given as a parameter...not calculated so couldn't use MATSUM
else
v.FORC[t] = p.fco22x * ((log10((((p.MATSUM[t])/2)+0.000001)/596.4)/log10(2))) + p.forcoth[t]
v.FORC[t] = p.fco22x * ((log10((((p.MATSUM[t]) / 2) + 0.000001) / 596.4) / log10(2))) + p.forcoth[t]
end
end
end
148 changes: 74 additions & 74 deletions src/components/slr_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,98 +39,98 @@
function run_timestep(p, v, d, t)


#THERMAL EXPANSION
#THERMAL EXPANSION

#Define function for THERMEQUIL
v.THERMEQUIL[t] = p.TATM[t] * p.thermeq

#Define function for SLRTHERM
if is_first(t)
v.SLRTHERM[t] = p.therm0 + p.thermadj * (v.THERMEQUIL[t] - p.therm0)
else
v.SLRTHERM[t] = v.SLRTHERM[t-1] + p.thermadj * (v.THERMEQUIL[t] - v.SLRTHERM[t-1])
end
#Define function for SLRTHERM
if is_first(t)
v.SLRTHERM[t] = p.therm0 + p.thermadj * (v.THERMEQUIL[t] - p.therm0)
else
v.SLRTHERM[t] = v.SLRTHERM[t-1] + p.thermadj * (v.THERMEQUIL[t] - v.SLRTHERM[t-1])
end

#GLACIERS AND SMALL ICE CAPS (GSIC)

#Define function for GSICREMAIN
if is_first(t)
v.GSICREMAIN[t] = p.gsictotal
else
v.GSICREMAIN[t] = p.gsictotal - v.GSICCUM[t-1]
end

#Define function for GSICMELTRATE
if is_first(t)
v.GSICMELTRATE[t] = 0.01464 # #Bug in Excel Model? gsiceq parameter drops out after first period (this is replicated here by just setting period 1 and exluding gsiceq from equation)
else
v.GSICMELTRATE[t] = p.gsicmelt * 10 * (v.GSICREMAIN[t] / p.gsictotal)^(p.gsicexp) * p.TATM[t]
end

#Define function for GSICCUM
if is_first(t)
v.GSICCUM[t] = v.GSICMELTRATE[t]
else
v.GSICCUM[t] = v.GSICCUM[t-1] + v.GSICMELTRATE[t]
end
#Define function for GSICREMAIN
if is_first(t)
v.GSICREMAIN[t] = p.gsictotal
else
v.GSICREMAIN[t] = p.gsictotal - v.GSICCUM[t-1]
end

#Define function for GSICMELTRATE
if is_first(t)
v.GSICMELTRATE[t] = 0.01464 # #Bug in Excel Model? gsiceq parameter drops out after first period (this is replicated here by just setting period 1 and exluding gsiceq from equation)
else
v.GSICMELTRATE[t] = p.gsicmelt * 10 * (v.GSICREMAIN[t] / p.gsictotal)^(p.gsicexp) * p.TATM[t]
end

#Define function for GSICCUM
if is_first(t)
v.GSICCUM[t] = v.GSICMELTRATE[t]
else
v.GSICCUM[t] = v.GSICCUM[t-1] + v.GSICMELTRATE[t]
end

#GREENLAND ICE SHEETS (GIS)

#Define function for GISREMAIN
if is_first(t)
v.GISREMAIN[t] = p.gis0
else
v.GISREMAIN[t] = v.GISREMAIN[t-1] - v.GISMELTRATE[t-1] / 100
end

#Define function for GISMELTRATE
if is_first(t) || t.t == 2
v.GISMELTRATE[t] = p.gismelt0
else
v.GISMELTRATE[t] = (p.gismeltabove * (p.TATM[t] - p.gismineq) + p.gismelt0) * v.GISEXPONENT[t-1]
end

#Define function for GISCUM
if is_first(t)
v.GISCUM[t] = p.gismelt0 / 100
else
v.GISCUM[t] = v.GISCUM[t-1] + v.GISMELTRATE[t] / 100
end

#Define function for GISEXPONENT
if is_first(t) || t.t == 2
v.GISEXPONENT[t] = 1.
else
v.GISEXPONENT[t] = 1. - (v.GISCUM[t] / p.gis0)^p.gisexp
end
#Define function for GISREMAIN
if is_first(t)
v.GISREMAIN[t] = p.gis0
else
v.GISREMAIN[t] = v.GISREMAIN[t-1] - v.GISMELTRATE[t-1] / 100
end

#Define function for GISMELTRATE
if is_first(t) || t.t == 2
v.GISMELTRATE[t] = p.gismelt0
else
v.GISMELTRATE[t] = (p.gismeltabove * (p.TATM[t] - p.gismineq) + p.gismelt0) * v.GISEXPONENT[t-1]
end

#Define function for GISCUM
if is_first(t)
v.GISCUM[t] = p.gismelt0 / 100
else
v.GISCUM[t] = v.GISCUM[t-1] + v.GISMELTRATE[t] / 100
end

#Define function for GISEXPONENT
if is_first(t) || t.t == 2
v.GISEXPONENT[t] = 1.
else
v.GISEXPONENT[t] = 1. - (v.GISCUM[t] / p.gis0)^p.gisexp
end

#ANTARCTIC ICE SHEET (AIS)

#Define function for AISMELTRATE
if t.t <= 11
#Define function for AISMELTRATE
if t.t <= 11
v.AISMELTRATE[t] = ifelse(p.TATM[t] < 3., (p.aismeltlow * p.TATM[t] * p.aisratio + p.aisintercept), (p.aisinflection * p.aismeltlow + p.aismeltup * (p.TATM[t] - 3.) + p.aisintercept))
else
else
v.AISMELTRATE[t] = ifelse(p.TATM[t] < 3., (p.aismeltlow * p.TATM[t] * p.aisratio + p.aismelt0), (p.aisinflection * p.aismeltlow + p.aismeltup * (p.TATM[t] - 3.) + p.aismelt0))
end

#Define function for AISCUM
if is_first(t)
v.AISCUM[t] = v.AISMELTRATE[t] / 100
else
v.AISCUM[t] = v.AISCUM[t-1] + v.AISMELTRATE[t] / 100
end

#Define function for AISREMAIN
if is_first(t)
v.AISREMAIN[t] = p.aiswais + p.aisother
else
v.AISREMAIN[t] = v.AISREMAIN[TimestepIndex(1)] - v.AISCUM[t]
end
end

#Define function for AISCUM
if is_first(t)
v.AISCUM[t] = v.AISMELTRATE[t] / 100
else
v.AISCUM[t] = v.AISCUM[t-1] + v.AISMELTRATE[t] / 100
end

#Define function for AISREMAIN
if is_first(t)
v.AISREMAIN[t] = p.aiswais + p.aisother
else
v.AISREMAIN[t] = v.AISREMAIN[TimestepIndex(1)] - v.AISCUM[t]
end

#TOTAL SEA LEVEL RISE AND DAMAGES

#Define function for TOTALSLR
v.TOTALSLR[t] = v.SLRTHERM[t] + v.GSICCUM[t] + v.GISCUM[t] + v.AISCUM[t]
#Define function for TOTALSLR
v.TOTALSLR[t] = v.SLRTHERM[t] + v.GSICCUM[t] + v.GISCUM[t] + v.AISCUM[t]

end
end
4 changes: 2 additions & 2 deletions src/components/slrdamages_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#Define function for SLRDAMAGES
for r in d.regions
if is_first(t)
v.SLRDAMAGES[t,r] = 0.
v.SLRDAMAGES[t, r] = 0.
else
v.SLRDAMAGES[t,r] = 100. * p.slrmultiplier[r] * (p.TOTALSLR[t-1] * p.slrdamlinear[r] + p.TOTALSLR[t-1]^2 * p.slrdamquadratic[r]) * (p.YGROSS[t-1,r] / p.YGROSS[TimestepIndex(1),r])^(1/p.slrelasticity[r])
v.SLRDAMAGES[t, r] = 100. * p.slrmultiplier[r] * (p.TOTALSLR[t-1] * p.slrdamlinear[r] + p.TOTALSLR[t-1]^2 * p.slrdamquadratic[r]) * (p.YGROSS[t-1, r] / p.YGROSS[TimestepIndex(1), r])^(1 / p.slrelasticity[r])
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions src/components/welfare_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@

#Define function for PERIODU #NEED TO ADD IF STATEMENT LIKE IN JUMP MODEL OR IS THAT ONLY ISSUES WHEN ELASMU = 1.0?
for r in d.regions
if p.elasmu[r]==1.
v.PERIODU[t,r] = log(p.CPC[t,r]) * p.alpha[t,r]
if p.elasmu[r] == 1.
v.PERIODU[t, r] = log(p.CPC[t, r]) * p.alpha[t, r]
else
v.PERIODU[t,r] = ((1. / (1. - p.elasmu[r])) * (p.CPC[t,r])^(1. - p.elasmu[r]) + 1.) * p.alpha[t,r]
v.PERIODU[t, r] = ((1. / (1. - p.elasmu[r])) * (p.CPC[t, r])^(1. - p.elasmu[r]) + 1.) * p.alpha[t, r]
end
end

#Define function for CEMUTOTPER
for r in d.regions
if t.t != 60
v.CEMUTOTPER[t,r] = v.PERIODU[t,r] * p.l[t,r] * p.rr[t,r]
v.CEMUTOTPER[t, r] = v.PERIODU[t, r] * p.l[t, r] * p.rr[t, r]
else
v.CEMUTOTPER[t,r] = v.PERIODU[t,r] * p.l[t,r] * p.rr[t,r] / (1. - ((p.rr[t-1,r] / (1. + 0.015)^10) / p.rr[t-1,r]))
v.CEMUTOTPER[t, r] = v.PERIODU[t, r] * p.l[t, r] * p.rr[t, r] / (1. - ((p.rr[t-1, r] / (1. + 0.015)^10) / p.rr[t-1, r]))
end
end

#Define function for REGCUMCEMUTOTPER
for r in d.regions
if is_first(t)
v.REGCUMCEMUTOTPER[t,r] = v.CEMUTOTPER[t,r]
v.REGCUMCEMUTOTPER[t, r] = v.CEMUTOTPER[t, r]
else
v.REGCUMCEMUTOTPER[t,r] = v.REGCUMCEMUTOTPER[t-1, r] + v.CEMUTOTPER[t,r]
v.REGCUMCEMUTOTPER[t, r] = v.REGCUMCEMUTOTPER[t-1, r] + v.CEMUTOTPER[t, r]
end
end

if t.t == 60
#Define function for REGUTILITY
for r in d.regions
v.REGUTILITY[r] = 10 * p.scale1[r] * v.REGCUMCEMUTOTPER[t,r] + p.scale2[r]
v.REGUTILITY[r] = 10 * p.scale1[r] * v.REGCUMCEMUTOTPER[t, r] + p.scale2[r]
end
#Define function for UTILITY
v.UTILITY = sum(v.REGUTILITY[:])
Expand Down
Loading