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

Add damages for crops from methane emissions #99

Open
wants to merge 6 commits into
base: ccac
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions analysis/allscc/runmodel_annual_bash_BACKUP_700.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

for jj_scen in {1..4}
do
echo $jj_scen
nohup nice ~/added/julia-1.6.1/bin/julia runmodel_annualGrowth.jl $jj_scen >& log1-$jj_scen.log &
sleep 30
nohup nice ~/added/julia-1.6.1/bin/julia runmodel_annualGrowth_ARvariability.jl $jj_scen >& log2-$jj_scen.log &
sleep 30
done
Empty file.
10 changes: 10 additions & 0 deletions analysis/allscc/runmodel_annual_bash_LOCAL_700.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

for jj_scen in {1..4}
do
echo $jj_scen
nohup nice ~/added/julia-1.6.1/bin/julia runmodel_annualGrowth.jl $jj_scen >& log1-$jj_scen.log &
sleep 30
nohup nice ~/added/julia-1.6.1/bin/julia runmodel_annualGrowth_ARvariability.jl $jj_scen >& log2-$jj_scen.log &
sleep 30
done
10 changes: 10 additions & 0 deletions analysis/allscc/runmodel_annual_bash_REMOTE_700.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

for jj_scen in {1..4}
do
echo $jj_scen
nohup nice ~/added/julia-1.6.1/bin/julia runmodel_annualGrowth.jl $jj_scen >& log1-$jj_scen.log &
sleep 30
nohup nice ~/added/julia-1.6.1/bin/julia runmodel_annualGrowth_ARvariability.jl $jj_scen >& log2-$jj_scen.log &
sleep 30
done
194 changes: 194 additions & 0 deletions data/Corp_Yield/methane_crop_yield_value.csv

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions src/components/MarketDamageAQ.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
methane_on_crops = myloadcsv("data/Corp_yield/methane_crop_yield_value.csv")
@defcomp MarketDamageAQ begin
country = Index()

# Incoming parameter: Global CH4 emissions from ch4emissions component
global_ch4_emissions = Parameter(index=[time], unit="Mtonne/year")

# Impact parameters: value per Mt methane emitted in year 1, year 2, ..., year 50
crop_yield_value_per_mton_ch4 = Parameter(index=[country, 50], unit="\$/Mtonne")

# Component variable to store total crop yield value
total_crop_yield_value = Variable(index=[time, country], unit="\$")

function run_timestep(p, v, d, t)
# Model Year
y_year = [2020, 2030, 2040, 2050, 2075, 2100, 2150, 2200, 2250, 2300]
y_year_0 = 2015 # Model Start Year

for c in d.country
total_value = 0.0
for tt in 1:50
if t > 1
# Determine the current year
uu = gettime(t) - tt + 1

if uu <= 2020
# Use historical data
if t - tt + 1 > 0 && t - tt + 1 <= length(p.global_ch4_emissions)
total_value += p.global_ch4_emissions[TimestepIndex(t - tt + 1)] * p.crop_yield_value_per_mton_ch4[c, tt]
end
else
# Linear interpolation
y1, y2 = find_model_years(uu, y_year)
e1 = p.global_ch4_emissions[TimestepIndex(findfirst(==(y1), y_year))]
e2 = p.global_ch4_emissions[TimestepIndex(findfirst(==(y2), y_year))]

# Linear interpolation formula
interpolated_emission = e1 + (e2 - e1) * (uu - y1) / (y2 - y1)
total_value += interpolated_emission * p.crop_yield_value_per_mton_ch4[c, tt]
end
end
end
v.total_crop_yield_value[t, c] = total_value
end
end
end

# Function to find which model years the current year (uu) falls between
function find_model_years(uu, model_years)
for i in 1:(length(model_years) - 1)
if model_years[i] <= uu && uu <= model_years[i+1]
return model_years[i], model_years[i+1]
end
end
error("Year not found between model years.")
end

function addMarketDamageAQ(model::Model)
marketdamageaqcomp = add_comp!(model, MarketDamageAQ)
formatteddata = zeros(dim_count(model, :country), 50)
for t in 1:50
formatteddata[:, t] =readcountrydata_i_const(model, methane_on_crops, :ISO3, Symbol(t))
end
marketdamageaqcomp[:crop_yield_value_per_mton_ch4] = formatteddata
return marketdamageaqcomp
end
2 changes: 2 additions & 0 deletions src/main_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ include("components/EquityWeighting.jl")
include("components/PermafrostSiBCASA.jl")
include("components/PermafrostJULES.jl")
include("components/PermafrostTotal.jl")
include("components/MarketDamageAQ.jl")


include("models/main_model_def.jl")

10 changes: 6 additions & 4 deletions src/models/main_model_def.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ function buildpage(m::Model, scenario::String, use_permafrost::Bool=true, use_se
nonmarketdamages = addnonmarketdamages(m)
discontinuity = adddiscontinuity(m)

# Total costs component
add_comp!(m, TotalCosts)
# Add MarketDamageAQ (Country version)
marketdamageaqcomp = addMarketDamageAQ(m)

# Equity weighting and Total Costs
add_comp!(m, TotalCosts)
countrylevelnpv = addcountrylevelnpv(m)
equityweighting = addequityweighting(m)

# connect parameters together
#continue
connect_param!(m, :GlobalTemperature => :fant_anthroforcing, :TotalForcing => :fant_anthroforcing)
regtemp[:rt_g_globaltemperature] = glotemp[:rt_g_globaltemperature]

Expand Down Expand Up @@ -221,6 +221,8 @@ function buildpage(m::Model, scenario::String, use_permafrost::Bool=true, use_se
connect_param!(m, :MarketDamagesBurke => :isatg_impactfxnsaturation, :GDP => :isatg_impactfxnsaturation)
connect_param!(m, :MarketDamagesBurke => :gdp, :GDP => :gdp)
connect_param!(m, :MarketDamagesBurke => :pop_population, :Population => :pop_population)

connect_param!(m, :MarketDamageAQ => :global_ch4_emissions, :ch4emissions => :e_globalCH4emissions)

connect_param!(m, :NonMarketDamages => :rtl_realizedtemperature_change, :RegionTemperature => :rtl_realizedtemperature_change)
connect_param!(m, :NonMarketDamages => :rtl_g_landtemperature, :RegionTemperature => :rtl_g_landtemperature)
Expand Down
Loading