Skip to content

Commit

Permalink
Format files using DocumentFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 15, 2020
1 parent 0e0bea3 commit c0539e4
Show file tree
Hide file tree
Showing 70 changed files with 1,089 additions and 1,089 deletions.
6 changes: 3 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Documenter

makedocs(
sitename = "MimiPAGE2009.jl",
pages = [
sitename="MimiPAGE2009.jl",
pages=[
"Home" => "index.md",
"Getting started" => "gettingstarted.md",
"Model Structure" => "model-structure.md",
Expand All @@ -11,5 +11,5 @@ makedocs(
)

deploydocs(
repo = "github.com/anthofflab/MimiPAGE2009.jl.git"
repo="github.com/anthofflab/MimiPAGE2009.jl.git"
)
14 changes: 7 additions & 7 deletions src/MimiPAGE2009.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ include("components/EquityWeighting.jl")

function buildpage(m::Model, policy::String="policy-a")

#add all the components
# add all the components
add_comp!(m, co2emissions)
add_comp!(m, co2cycle)
add_comp!(m, co2forcing)
Expand All @@ -63,11 +63,11 @@ function buildpage(m::Model, policy::String="policy-a")
add_comp!(m, ClimateTemperature)
add_comp!(m, SeaLevelRise)

#Socio-Economics
# Socio-Economics
addpopulation(m)
add_comp!(m, GDP)

#Abatement Costs
# Abatement Costs

addabatementcostparameters(m, :CO2, policy)
addabatementcostparameters(m, :CH4, policy)
Expand All @@ -91,7 +91,7 @@ function buildpage(m::Model, policy::String="policy-a")
addabatementcosts(m, :Lin, policy)
add_comp!(m, TotalAbatementCosts)

#Adaptation Costs
# Adaptation Costs
addadaptationcosts_sealevel(m)
addadaptationcosts_economic(m)
addadaptationcosts_noneconomic(m)
Expand All @@ -108,10 +108,10 @@ function buildpage(m::Model, policy::String="policy-a")
# Total costs component
add_comp!(m, TotalCosts)

#Equity weighting and Total Costs
# Equity weighting and Total Costs
add_comp!(m, EquityWeighting)

#connect parameters together
# connect parameters together
connect_param!(m, :co2cycle => :e_globalCO2emissions, :co2emissions => :e_globalCO2emissions)
connect_param!(m, :co2cycle => :rt_g0_baseglobaltemp, :ClimateTemperature => :rt_g0_baseglobaltemp)
connect_param!(m, :co2cycle => :rt_g_globaltemperature, :ClimateTemperature => :rt_g_globaltemperature)
Expand Down Expand Up @@ -202,7 +202,7 @@ function buildpage(m::Model, policy::String="policy-a")
connect_param!(m, :NonMarketDamages => :rtl_realizedtemperature, :ClimateTemperature => :rtl_realizedtemperature)
connect_param!(m, :NonMarketDamages => :rgdp_per_cap_MarketRemainGDP, :MarketDamages => :rgdp_per_cap_MarketRemainGDP)
connect_param!(m, :NonMarketDamages => :rcons_per_cap_MarketRemainConsumption, :MarketDamages => :rcons_per_cap_MarketRemainConsumption)
connect_param!(m, :NonMarketDamages =>:atl_adjustedtolerableleveloftemprise, :AdaptiveCostsNonEconomic =>:atl_adjustedtolerablelevel, ignoreunits=true)
connect_param!(m, :NonMarketDamages => :atl_adjustedtolerableleveloftemprise, :AdaptiveCostsNonEconomic => :atl_adjustedtolerablelevel, ignoreunits=true)
connect_param!(m, :NonMarketDamages => :imp_actualreduction, :AdaptiveCostsNonEconomic => :imp_adaptedimpacts)
connect_param!(m, :NonMarketDamages => :isatg_impactfxnsaturation, :GDP => :isatg_impactfxnsaturation)

Expand Down
4 changes: 2 additions & 2 deletions src/climate_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ m = Model()
set_dimension!(m, :time, [2009, 2010, 2020, 2030, 2040, 2050, 2075, 2100, 2150, 2200])
set_dimension!(m, :region, ["EU", "USA", "OECD","USSR","China","SEAsia","Africa","LatAmerica"])

#add all the components
# add all the components
add_comp!(m,co2emissions)
add_comp!(m, co2cycle)
add_comp!(m, co2forcing)
Expand All @@ -36,7 +36,7 @@ add_comp!(m, SulphateForcing)
add_comp!(m, TotalForcing)
add_comp!(m, ClimateTemperature)

#connect parameters together
# connect parameters together

set_param!(m, :y_year, [2009.,2010.,2020.,2030.,2040.,2050.,2075.,2100.,2150.,2200.])
set_param!(m, :y_year_0, 2008.)
Expand Down
100 changes: 50 additions & 50 deletions src/components/AbatementCostParameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

region = Index()
y_year = Parameter(index=[time], unit="year")
y_year_0 = Parameter(unit="year", default = 2008.)
y_year_0 = Parameter(unit="year", default=2008.)

#gas inputs
# gas inputs
emit_UncertaintyinBAUEmissFactorinFocusRegioninFinalYear = Parameter(unit="%")
q0propinit_CutbacksinNegativeCostinFocusRegioninBaseYear = Parameter(unit="% of BAU emissions")
c0init_MostNegativeCostCutbackinBaseYear = Parameter(unit="\$/ton")
qmaxminusq0propinit_MaxCutbackCostatPositiveCostinBaseYear = Parameter(unit="% of BAU emissions")
cmaxinit_MaximumCutbackCostinFocusRegioninBaseYear = Parameter(unit="\$/ton")
ies_InitialExperienceStockofCutbacks = Parameter(unit= "Million ton")
e0_baselineemissions = Parameter(index=[region], unit= "Mtonne/year")
ies_InitialExperienceStockofCutbacks = Parameter(unit="Million ton")
e0_baselineemissions = Parameter(index=[region], unit="Mtonne/year")

#regional inputs
emitf_uncertaintyinBAUemissfactor = Parameter(index=[region], unit= "none")
# regional inputs
emitf_uncertaintyinBAUemissfactor = Parameter(index=[region], unit="none")
q0f_negativecostpercentagefactor = Parameter(index=[region], unit="none")
cmaxf_maxcostfactor = Parameter(index=[region], unit="none")

bau_businessasusualemissions = Parameter(index=[time, region], unit = "%")
bau_businessasusualemissions = Parameter(index=[time, region], unit="%")
yagg = Parameter(index=[time], unit="year") # from equity weighting

#inputs with single, uncertain values
# inputs with single, uncertain values
q0propmult_cutbacksatnegativecostinfinalyear = Parameter(unit="none", default=.733333333333333334)
qmax_minus_q0propmult_maxcutbacksatpositivecostinfinalyear = Parameter(unit="none", default=1.2666666666666666)
c0mult_mostnegativecostinfinalyear = Parameter(unit="none", default=.8333333333333334)
Expand All @@ -33,34 +33,34 @@
equity_prop_equityweightsproportion = Parameter(unit="none", default=1.)

# Inputs from other components
cbe_absoluteemissionreductions = Parameter(index=[time, region], unit="Mtonne") #TODO: default here?
cbe_absoluteemissionreductions = Parameter(index=[time, region], unit="Mtonne") # TODO: default here?

#Variables
emit_UncertaintyinBAUEmissFactor = Variable(index=[region], unit = "%")
q0propinit_CutbacksinNegativeCostinBaseYear = Variable(index=[region], unit= "% of BAU emissions")
cmaxinit_MaxCutbackCostinBaseYear = Variable(index=[region], unit = "\$/ton")
zc_zerocostemissions = Variable(index=[time, region], unit= "%")
# Variables
emit_UncertaintyinBAUEmissFactor = Variable(index=[region], unit="%")
q0propinit_CutbacksinNegativeCostinBaseYear = Variable(index=[region], unit="% of BAU emissions")
cmaxinit_MaxCutbackCostinBaseYear = Variable(index=[region], unit="\$/ton")
zc_zerocostemissions = Variable(index=[time, region], unit="%")
cumcbe_cumulativereductionssincebaseyear = Variable(index=[time, region], unit="Mtonne")
cumcbe_g_totalreductions = Variable(index=[time], unit="Mtonne")
learnfac_learning= Variable(index=[time, region], unit= "none")
learnfac_learning = Variable(index=[time, region], unit="none")
auto = Variable(unit="% per year")
autofac = Variable(index=[time], unit= "% per year")
c0g = Variable(unit= "% per year")
c0 = Variable(index=[time], unit= "\$/ton")
qmaxminusq0propg = Variable(unit= "% per year")
qmaxminusq0prop = Variable(unit = "% of BAU emissions")
q0propg = Variable(unit = "% per year")
autofac = Variable(index=[time], unit="% per year")
c0g = Variable(unit="% per year")
c0 = Variable(index=[time], unit="\$/ton")
qmaxminusq0propg = Variable(unit="% per year")
qmaxminusq0prop = Variable(unit="% of BAU emissions")
q0propg = Variable(unit="% per year")
q0prop = Variable(index=[time, region], unit="% of BAU emissions")
q0_absolutecutbacksatnegativecost = Variable(index=[time, region], unit= "Mtonne")
q0_absolutecutbacksatnegativecost = Variable(index=[time, region], unit="Mtonne")
qmax_maxreferencereductions = Variable(index=[time, region], unit="Mtonne")
cmax = Variable(index=[time,region], unit = "\$/tonne")
blo = Variable(index=[time, region], unit = "per Mtonne")
alo = Variable(index=[time, region], unit = "\$/tonne")
bhi = Variable(index=[time, region], unit = "per Mtonne")
ahi = Variable(index=[time, region], unit = "\$/tonne")
mc_marginalcost = Variable(index=[time, region], unit = "\$/tonne")
tcq0 = Variable(index=[time, region], unit = "\$million")
tc_totalcost = Variable(index=[time, region], unit= "\$million")
cmax = Variable(index=[time,region], unit="\$/tonne")
blo = Variable(index=[time, region], unit="per Mtonne")
alo = Variable(index=[time, region], unit="\$/tonne")
bhi = Variable(index=[time, region], unit="per Mtonne")
ahi = Variable(index=[time, region], unit="\$/tonne")
mc_marginalcost = Variable(index=[time, region], unit="\$/tonne")
tcq0 = Variable(index=[time, region], unit="\$million")
tc_totalcost = Variable(index=[time, region], unit="\$million")

function run_timestep(p, v, d, t)

Expand All @@ -72,43 +72,43 @@
v.cmaxinit_MaxCutbackCostinBaseYear[r] = p.cmaxinit_MaximumCutbackCostinFocusRegioninBaseYear *
p.cmaxf_maxcostfactor[r]

v.zc_zerocostemissions[t,r] = (1+v.emit_UncertaintyinBAUEmissFactor[r]/100 * (p.y_year[t]-p.y_year_0)/(p.y_year[end]-p.y_year_0)) * p.bau_businessasusualemissions[t,r]
v.zc_zerocostemissions[t,r] = (1 + v.emit_UncertaintyinBAUEmissFactor[r] / 100 * (p.y_year[t] - p.y_year_0) / (p.y_year[end] - p.y_year_0)) * p.bau_businessasusualemissions[t,r]

if is_first(t)
v.cumcbe_cumulativereductionssincebaseyear[t,r] = 0.
else
v.cumcbe_cumulativereductionssincebaseyear[t,r] = v.cumcbe_cumulativereductionssincebaseyear[t-1, r] + p.cbe_absoluteemissionreductions[t-1, r] * p.yagg[t-1]
v.cumcbe_cumulativereductionssincebaseyear[t,r] = v.cumcbe_cumulativereductionssincebaseyear[t - 1, r] + p.cbe_absoluteemissionreductions[t - 1, r] * p.yagg[t - 1]
end
end

v.cumcbe_g_totalreductions[t] = sum(v.cumcbe_cumulativereductionssincebaseyear[t,:])

v.auto = (1-p.automult_autonomoustechchange^(1/(p.y_year[end]-p.y_year_0)))*100
v.autofac[t] = (1-v.auto/100)^(p.y_year[t] - p.y_year_0)
v.auto = (1 - p.automult_autonomoustechchange^(1 / (p.y_year[end] - p.y_year_0))) * 100
v.autofac[t] = (1 - v.auto / 100)^(p.y_year[t] - p.y_year_0)

v.c0g = (p.c0mult_mostnegativecostinfinalyear^(1/(p.y_year[end]-p.y_year_0))-1)*100
v.c0[t] = p.c0init_MostNegativeCostCutbackinBaseYear* (1+v.c0g/100)^(p.y_year[t]-p.y_year_0)
v.c0g = (p.c0mult_mostnegativecostinfinalyear^(1 / (p.y_year[end] - p.y_year_0)) - 1) * 100
v.c0[t] = p.c0init_MostNegativeCostCutbackinBaseYear * (1 + v.c0g / 100)^(p.y_year[t] - p.y_year_0)

v.qmaxminusq0propg = (p.qmax_minus_q0propmult_maxcutbacksatpositivecostinfinalyear ^(1/(p.y_year[end]-p.y_year_0))- 1)* 100
v.qmaxminusq0prop = p.qmaxminusq0propinit_MaxCutbackCostatPositiveCostinBaseYear * (1+ v.qmaxminusq0propg/100)^(p.y_year[t]-p.y_year_0)
v.qmaxminusq0propg = (p.qmax_minus_q0propmult_maxcutbacksatpositivecostinfinalyear^(1 / (p.y_year[end] - p.y_year_0)) - 1) * 100
v.qmaxminusq0prop = p.qmaxminusq0propinit_MaxCutbackCostatPositiveCostinBaseYear * (1 + v.qmaxminusq0propg / 100)^(p.y_year[t] - p.y_year_0)

v.q0propg = (p.q0propmult_cutbacksatnegativecostinfinalyear^(1/(p.y_year[end]-p.y_year_0))-1)*100
v.q0propg = (p.q0propmult_cutbacksatnegativecostinfinalyear^(1 / (p.y_year[end] - p.y_year_0)) - 1) * 100

for r in d.region
v.learnfac_learning[t,r] = ((p.cross_experiencecrossoverratio *v.cumcbe_g_totalreductions[t]+ (1-p.cross_experiencecrossoverratio)*v.cumcbe_cumulativereductionssincebaseyear[t,r] + p.ies_InitialExperienceStockofCutbacks)/ p.ies_InitialExperienceStockofCutbacks)^ -(log(1/(1-p.learn_learningrate))/log(2))
v.learnfac_learning[t,r] = ((p.cross_experiencecrossoverratio * v.cumcbe_g_totalreductions[t] + (1 - p.cross_experiencecrossoverratio) * v.cumcbe_cumulativereductionssincebaseyear[t,r] + p.ies_InitialExperienceStockofCutbacks) / p.ies_InitialExperienceStockofCutbacks)^-(log(1 / (1 - p.learn_learningrate)) / log(2))

v.q0prop[t,r] = v.q0propinit_CutbacksinNegativeCostinBaseYear[r]* (1+v.q0propg/100)^(p.y_year[t]-p.y_year_0)
v.q0prop[t,r] = v.q0propinit_CutbacksinNegativeCostinBaseYear[r] * (1 + v.q0propg / 100)^(p.y_year[t] - p.y_year_0)

v.q0_absolutecutbacksatnegativecost[t,r]= (v.q0prop[t,r]/100)* (v.zc_zerocostemissions[t,r]/100) * p.e0_baselineemissions[r]
v.q0_absolutecutbacksatnegativecost[t,r] = (v.q0prop[t,r] / 100) * (v.zc_zerocostemissions[t,r] / 100) * p.e0_baselineemissions[r]

v.qmax_maxreferencereductions[t,r] = (v.qmaxminusq0prop/100) * (v.zc_zerocostemissions[t,r]/100)* p.e0_baselineemissions[r] + v.q0_absolutecutbacksatnegativecost[t,r]
v.qmax_maxreferencereductions[t,r] = (v.qmaxminusq0prop / 100) * (v.zc_zerocostemissions[t,r] / 100) * p.e0_baselineemissions[r] + v.q0_absolutecutbacksatnegativecost[t,r]

v.cmax[t,r] = v.cmaxinit_MaxCutbackCostinBaseYear[r] * v.learnfac_learning[t,r]* v.autofac[t]
v.cmax[t,r] = v.cmaxinit_MaxCutbackCostinBaseYear[r] * v.learnfac_learning[t,r] * v.autofac[t]

v.blo[t,r] = -2*log((1+p.curve_below_curvatureofMACcurvebelowzerocost)/(1-p.curve_below_curvatureofMACcurvebelowzerocost))/ v.q0_absolutecutbacksatnegativecost[t,r]
v.alo[t,r] = v.c0[t]/(exp(-v.blo[t,r]*v.q0_absolutecutbacksatnegativecost[t,r])-1)
v.bhi[t,r] = 2*log((1+p.curve_above_curvatureofMACcurveabovezerocost)/(1-p.curve_above_curvatureofMACcurveabovezerocost))/ (v.qmax_maxreferencereductions[t,r] - v.q0_absolutecutbacksatnegativecost[t,r])
v.ahi[t,r] = v.cmax[t,r]/ (exp(v.bhi[t,r]*(v.qmax_maxreferencereductions[t,r]-v.q0_absolutecutbacksatnegativecost[t,r]))-1)
v.blo[t,r] = -2 * log((1 + p.curve_below_curvatureofMACcurvebelowzerocost) / (1 - p.curve_below_curvatureofMACcurvebelowzerocost)) / v.q0_absolutecutbacksatnegativecost[t,r]
v.alo[t,r] = v.c0[t] / (exp(-v.blo[t,r] * v.q0_absolutecutbacksatnegativecost[t,r]) - 1)
v.bhi[t,r] = 2 * log((1 + p.curve_above_curvatureofMACcurveabovezerocost) / (1 - p.curve_above_curvatureofMACcurveabovezerocost)) / (v.qmax_maxreferencereductions[t,r] - v.q0_absolutecutbacksatnegativecost[t,r])
v.ahi[t,r] = v.cmax[t,r] / (exp(v.bhi[t,r] * (v.qmax_maxreferencereductions[t,r] - v.q0_absolutecutbacksatnegativecost[t,r])) - 1)
end
end
end
Expand Down Expand Up @@ -151,8 +151,8 @@ function addabatementcostparameters(model::Model, class::Symbol, policy::String=
setdistinctparameter(model, componentname, :qmaxminusq0propinit_MaxCutbackCostatPositiveCostinBaseYear, 70.)
setdistinctparameter(model, componentname, :cmaxinit_MaximumCutbackCostinFocusRegioninBaseYear, 333.333333333333)
setdistinctparameter(model, componentname, :ies_InitialExperienceStockofCutbacks, 2000.)
setdistinctparameter(model, componentname, :e0_baselineemissions, readpagedata(model,"data/e0_baselineLGemissions.csv"))
setdistinctparameter(model, componentname, :bau_businessasusualemissions, readpagedata(model,"data/bau_linemissions.csv"))
setdistinctparameter(model, componentname, :e0_baselineemissions, readpagedata(model, "data/e0_baselineLGemissions.csv"))
setdistinctparameter(model, componentname, :bau_businessasusualemissions, readpagedata(model, "data/bau_linemissions.csv"))
else
error("Unknown class of abatement costs.")
end
Expand Down
Loading

0 comments on commit c0539e4

Please sign in to comment.