From 6d85f0314c2c5753f0b5db4864e75f5abe825b0e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 10 Aug 2023 16:08:21 +0200 Subject: [PATCH 001/187] model-internal EAT Lancet diet implementation following Isabelles draft --- config/default.cfg | 36 +- main.gms | 20 +- .../15_food/anthro_iso_jun22/declarations.gms | 114 +++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 189 ++++++-- modules/15_food/anthro_iso_jun22/input.gms | 14 +- modules/15_food/anthro_iso_jun22/preloop.gms | 12 +- .../15_food/anthro_iso_jun22/realization.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 117 ++++- modules/15_food/input/files | 2 + renv/activate.R | 421 +++++++++++++----- scripts/start/projects/project_EAT2.R | 44 ++ standalone/HOWTO.md | 2 +- 12 files changed, 726 insertions(+), 247 deletions(-) create mode 100644 scripts/start/projects/project_EAT2.R diff --git a/config/default.cfg b/config/default.cfg index f796720c61..028ef4483e 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -397,16 +397,23 @@ cfg$gms$s15_exo_waste <- 0 # def = 0 # * (1.2): corresponds to 20% food waste ~ half waste of HIC cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 -# * switch for transition to exogenous diet scenarios (EAT Lancet and National Institute of Nutrition (NIN)) -# * (2): transition towards exogenous diets (NIN for India and EAT for other regions) -# * Please use this switch in combination with cfg$gms$c15_EAT_scen <- "FLX_hmilk" -# * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" -# * (1): transition towards exogenous diets and food demand -# * (0): regression-based estimation of diets and food demand +# * Switch for transition to exogenous diet scenarios +# * (EAT Lancet and National Institute of Nutrition (NIN)) +# * (3): MAgPIE-specific realization of the EAT-Lancet diet, where model-internal +# * (regression-based) food demand projections are constraint by ranges for +# * intake targets of food groups to ensure healthy and sustainable diets as +# * recommended by the EAT-Lancet Commission +# * (2): transition towards exogenous diets (NIN for India and EAT for other regions) +# * Please use this switch in combination with cfg$gms$c15_EAT_scen <- "FLX_hmilk" +# * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" +# * (1): transition towards exogenous diets and food demand parametrized +# * to a food-specific data set published by the EAT-Lancet Commission +# * (Willett et al., 2019) +# * (0): regression-based estimation of diets and food demand cfg$gms$s15_exo_diet <- 0 # def = 0 # * exogenous calorie scenario (EAT Lancet diet scenarios) -# * only activated if s15_exo_diet is set to 1 +# * only activated if s15_exo_diet is > 0 # * options: healthy_BMI, 2100kcal, 2500kcal, # * endo, no_underweight, no_overweight # * half_overweight, no_underweight_half_overweight @@ -421,7 +428,8 @@ cfg$gms$s15_exo_diet <- 0 # def = 0 cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI # # * exogenous food-specific diet scenario (EAT Lancet diet scenarios) -# * only activated if s15_exo_diet is set to 1 +# * only activated if s15_exo_diet is > 0 +#******** ISABELLE/BENNI: Or is this only active for s15_exo_diet = 1???? # * options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat cfg$gms$c15_EAT_scen <- "FLX" # def = FLX @@ -441,9 +449,9 @@ cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet -# * The EAT-Lancet diet only allows for added sugars, but does not include processed food or -# * alcohol. -# * only activated if s15_exo_diet is set to 1 +# * The EAT-Lancet diet only allows for added sugars, +# * but does not include processed food or alcohol. +# * only activated if s15_exo_diet is > 0 cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet @@ -703,7 +711,7 @@ cfg$gms$c31_grassl_yld_scenario <- "cc" # def = "cc" # * SSP scenario switch for pasture suitability areas (only take effect for realization grasslands_apr22) # * options: ssp126, ssp245, ssp370, ssp460, ssp585 -# * nocc (fixed to values from 1995), +# * nocc (fixed to values from 1995), # * nocc_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370" @@ -1281,8 +1289,8 @@ cfg$gms$nitrogen <- "rescaled_jan21" # def = rescaled_jan21 cfg$gms$carbon <- "normal_dec17" # def = normal_dec17 # * RCP scenario of land carbon sink adjustment factor, from Grassi et al 2021 -# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU, -# * nocc (fixed to values from 1995), +# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU, +# * nocc (fixed to values from 1995), # * nocc_hist (RCPBU until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c52_land_carbon_sink_rcp <- "RCPBU" diff --git a/main.gms b/main.gms index 3595e9c073..374f08fc64 100644 --- a/main.gms +++ b/main.gms @@ -149,24 +149,24 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * * Used data set: rev4.87_h12_magpie.tgz -* md5sum: 658398f1dcbef89198bd85d61b1db9ad -* Repository: /p/projects/rd3mod/inputdata/output +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz -* md5sum: 8a1d668acfe66a700eb5da2143b31cb2 -* Repository: /p/projects/rd3mod/inputdata/output +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: rev4.87_h12_validation.tgz -* md5sum: d02217d791b58400e6e3be7186527ed5 -* Repository: /p/projects/rd3mod/inputdata/output +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: additional_data_rev4.43.tgz * md5sum: NA * Repository: https://rse.pik-potsdam.de/data/magpie/public * -* Used data set: calibration_H12_per_ton_fao_may22_glo_08Jul23.tgz -* md5sum: 7315d0f268d6225805a4c1f1c3c05b13 -* Repository: /p/projects/landuse/data/input/calibration +* Used data set: calibration_H12_per_ton_fao_may22_glo_14Jul23.tgz +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Low resolution: c200 * High resolution: 0.5 @@ -195,7 +195,7 @@ $title magpie * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * * -* Last modification (input data): Thu Jul 13 10:36:10 2023 +* Last modification (input data): Thu Aug 10 15:24:22 2023 * *###################### R SECTION END (VERSION INFO) ########################### diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index b5f7cd8ef2..10b8d8274e 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -11,14 +11,11 @@ equations ; positive variables - vm_dem_food(i,kall) Food demand (mio. tDM per yr) + vm_dem_food(i,kall) Food demand (mio. tDM per yr) ; *** #### Food Demand Model - - - equations q15_aim Objective function of food demand model (mio. USD05PPP) q15_budget(iso) Household budget constraint (USD05PPP per cap per day) @@ -39,7 +36,6 @@ equations q15_foodtree_kcal_processed(iso,kfo_pf) Demand for processed products (kcal per cap per day) q15_foodtree_kcal_staples(iso,kfo_st) Demand for staple products (kcal per cap per day) q15_foodtree_kcal_vegetables(iso) Demand for vegetable and fruit products (kcal per cap per day) - ; @@ -50,8 +46,8 @@ positive variables v15_income_pc_real_ppp_iso(iso) Real income per cap (USD05PPP per cap) v15_income_balance(iso) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD05PPP per cap per yr) v15_kcal_intake_total_regr(iso) Food intake (kcal per cap per day) - v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) Hierarchical tree parameter regressions (1) - v15_bmi_shr_regr(iso,sex,age,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) + v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) Hierarchical tree parameter regressions (1) + v15_bmi_shr_regr(iso,sex,age,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) v15_bmi_shr_overgroups(iso,sex,agegroup15,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) ; @@ -71,20 +67,20 @@ parameters p15_iteration_counter(t) Number of iterations required for reaching an equilibrium between food demand model and magpie (1) p15_convergence_measure(t,iter15) Convergence measure to decide for continuation or stop of food_demand - magpie iteration (1) i15_dem_intercept(iso,regr15) Food regression parameters intercept in kcal or as share (X) - i15_dem_saturation(iso,regr15) Food regression parameters saturation in kcal or as share (X) - i15_dem_halfsat(iso,regr15) Food regression parameters halfsaturation (USD05PPP per cap) - i15_dem_nonsat(iso,regr15) Food regression parameters nonsaturation (1) + i15_dem_saturation(iso,regr15) Food regression parameters saturation in kcal or as share (X) + i15_dem_halfsat(iso,regr15) Food regression parameters halfsaturation (USD05PPP per cap) + i15_dem_nonsat(iso,regr15) Food regression parameters nonsaturation (1) *prices p15_prices_kcal(t,iso,kfo,iter15) Prices from MAgPIE after optimization (USD05PPP per kcal) i15_prices_initial_kcal(iso,kfo) Initial prices that capture the approximate level of prices in 1961-2010 (USD05PPP per kcal) * anthropometrics - p15_bodyheight(t,iso,sex,age,estimates15) Body height (cm per cap) - p15_bodyweight(t,iso,sex,age,bmi_group15) Body weight (kg per cap) - p15_bodyheight_calib(t,iso,sex,age_new_estimated15) Calibration factor for regional height differences (cm) - p15_kcal_growth_food(t_all,iso,underaged15) Average per capita demand for body size growth relevant food items in the last three 5-year steps (kcal per capita per day) - p15_physical_activity_level(t,iso,sex,age) Physical activity levels in PAL relative to basic metabolic rate BMR (kcal per kcal) + p15_bodyheight(t,iso,sex,age,estimates15) Body height (cm per cap) + p15_bodyweight(t,iso,sex,age,bmi_group15) Body weight (kg per cap) + p15_bodyheight_calib(t,iso,sex,age_new_estimated15) Calibration factor for regional height differences (cm) + p15_kcal_growth_food(t_all,iso,underaged15) Average per capita demand for body size growth relevant food items in the last three 5-year steps (kcal per capita per day) + p15_physical_activity_level(t,iso,sex,age) Physical activity levels in PAL relative to basic metabolic rate BMR (kcal per kcal) i15_bmi_intercept(sex,agegroup15,bmi_tree15) BMI share regression intercept (1) i15_bmi_saturation(sex,agegroup15,bmi_tree15) BMI share regression saturation (1) @@ -101,20 +97,20 @@ parameters i15_milk_share_fadeout_india(t_all) Temporal fader of milk share in india (applied before food demand model) (1) i15_rum_share_fadeout(t_all,iso) Temporal fader of ruminant meat share (applied before food demand model) (1) - i15_ruminant_fadeout(t,iso) Ruminant fadeout share (1) - i15_fish_fadeout(t,iso) Fish fadeout share (1) - i15_alcohol_fadeout(t,iso) Alcohol fadeout share (1) - i15_livestock_fadeout(t,iso) Livestock fadeout share (1) - i15_rumdairy_fadeout(t,iso) Ruminant meat and dairy fadeout share (1) - i15_rumdairy_scp_fadeout(t,iso) Ruminant meat and dairy fadeout share to be replaced by SCP (1) - i15_livestock_fadeout_threshold(t,iso) Livestock fadeout share for threshold (1) + i15_ruminant_fadeout(t,iso) Ruminant fadeout share (1) + i15_fish_fadeout(t,iso) Fish fadeout share (1) + i15_alcohol_fadeout(t,iso) Alcohol fadeout share (1) + i15_livestock_fadeout(t,iso) Livestock fadeout share (1) + i15_rumdairy_fadeout(t,iso) Ruminant meat and dairy fadeout share (1) + i15_rumdairy_scp_fadeout(t,iso) Ruminant meat and dairy fadeout share to be replaced by SCP (1) + i15_livestock_fadeout_threshold(t,iso) Livestock fadeout share for threshold (1) - i15_protein_to_kcal_ratio(t,kfo) protein-to-kcal ratio (g protein per kcal) + i15_protein_to_kcal_ratio(t,kfo) Protein-to-kcal ratio (g protein per kcal) - i15_staples_kcal_structure_iso(t,iso,kfo_st) Share of single staple products within total staples (1) - i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) Share of single livestock products within total livestock products (uncorrected for future changes in shares) (1) - i15_livestock_kcal_structure_iso(t,iso,kfo_ap) Share of single livestock products within total livestock products (corrected for future changes in shares) (1) - i15_processed_kcal_structure_iso Share of single processed products within total processed food (1) + i15_staples_kcal_structure_iso(t,iso,kfo_st) Share of single staple products within total staples (1) + i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) Share of single livestock products within total livestock products (uncorrected for future changes in shares) (1) + i15_livestock_kcal_structure_iso(t,iso,kfo_ap) Share of single livestock products within total livestock products (corrected for future changes in shares) (1) + i15_processed_kcal_structure_iso Share of single processed products within total processed food (1) * diet calibration p15_kcal_calib(t,iso,kfo) Balance flow to diverge from mean calories of regressions (kcal per cap per day) @@ -125,38 +121,58 @@ parameters * before shock o15_kcal_regr_initial(t,iso,kfo) Uncalibrated per capita demand before price shock (kcal per capita per day) - pm_kcal_pc_initial(t,i,kall) Per capita consumption in food demand model before price shock (kcal per capita per day) + pm_kcal_pc_initial(t,i,kall) Per capita consumption in food demand model before price shock (kcal per capita per day) p15_kcal_pc_initial_iso(t,iso,kfo) Per capita consumption in food demand model before price shock on country level (kcal per capita per day) * after price shock - p15_kcal_pc_iso(t,iso,kfo) Per capita consumption in food demand model after price shock on country level (kcal per capita per day) - p15_kcal_pc(t,i,kfo) Per capita consumption in food demand model after price shock on regional level (kcal per capita per day) - p15_kcal_pc_calibrated(t,i,kfo) Calibrated per capita consumption in food demand model after price shock (kcal per capita per day) - p15_kcal_pc_iso_orig(t,iso,kfo) Auxiliary parameter for per capita food consumption - basis for convergence into waste and diet scenarios (kcal per capita per day) - p15_kcal_pc_iso_livestock_orig(t,iso) Auxiliary parameter for per capita livestock consumption - basis for scenarios of livestock food substitution (kcal per capita per day) - p15_kcal_pc_iso_rumdairy_orig(t,iso) Auxiliary parameter for per capita ruminant and dairy consumption - basis for scenarios of ruminant-based food substitution (kcal per capita per day) - p15_kcal_pc_iso_plant_orig(t,iso) Auxiliary parameter for per capita plant-based food consumption - basis for scenarios of livestock food substitution (kcal per capita per day) + p15_kcal_pc_iso(t,iso,kfo) Per capita consumption in food demand model after price shock on country level (kcal per capita per day) + p15_kcal_pc(t,i,kfo) Per capita consumption in food demand model after price shock on regional level (kcal per capita per day) + p15_kcal_pc_calibrated(t,i,kfo) Calibrated per capita consumption in food demand model after price shock (kcal per capita per day) + p15_kcal_pc_iso_orig(t,iso,kfo) Auxiliary parameter for per capita food consumption - basis for convergence into waste and diet scenarios (kcal per capita per day) + p15_kcal_pc_iso_livestock_orig(t,iso) Auxiliary parameter for per capita livestock consumption - basis for scenarios of livestock food substitution (kcal per capita per day) + p15_kcal_pc_iso_rumdairy_orig(t,iso) Auxiliary parameter for per capita ruminant and dairy consumption - basis for scenarios of ruminant-based food substitution (kcal per capita per day) + p15_kcal_pc_iso_plant_orig(t,iso) Auxiliary parameter for per capita plant-based food consumption - basis for scenarios of livestock food substitution (kcal per capita per day) p15_livestock_kcal_structure_orig(t,iso,kfo_lp) Auxiliary parameter for livestock kcal structure - basis for scenarios of livestock food substitution (1) p15_rumdairy_kcal_structure_orig(t,iso,kfo_rd) Auxiliary parameter for ruminant and dairy kcal structure - basis for scenarios of ruminant-based food substitution (1) p15_plant_kcal_structure_orig(t,iso,kfo_pp) Auxiliary parameter for plant-based food kcal structure - basis for scenarios of livestock food substitution (1) - p15_kcal_pc_livestock_supply_target(iso) Target of per capita livestock consumption (kcal per capita per day) + p15_kcal_pc_livestock_supply_target(iso) Target of per capita livestock consumption (kcal per capita per day) - p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) Calibrated estimates of BMI share for population groups (1) - p15_bmi_shr_target(t,iso,sex,age,bmi_group15) Target for BMI shares under exogenous scenarios (1) - p15_intake_total(t,iso) Total food intake in a country (kcal per capita per day) + p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) Calibrated estimates of BMI share for population groups (1) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) Target for BMI shares under exogenous scenarios (1) + p15_intake_total(t,iso) Total food intake in a country (kcal per capita per day) *food waste - p15_demand2intake_ratio(t,iso) Ratio between food calorie demand and intake (kcal per kcal) - p15_waste_pc(t,iso,kfo) Household waste by food group (kcal per capita per day) - p15_intake_detail(t,iso,kfo) Intake by food group (kcal per capita per day) - p15_demand2intake_ratio_detail(t,iso,kfo) Food waste ratio by food group (kcal per kcal) + p15_demand2intake_ratio(t,iso) Ratio between food calorie demand and intake (kcal per kcal) + p15_waste_pc(t,iso,kfo) Household waste by food group (kcal per capita per day) + p15_intake_detail(t,iso,kfo) Intake by food group (kcal per capita per day) + p15_demand2intake_ratio_detail(t,iso,kfo) Food waste ratio by food group (kcal per kcal) p15_demand2intake_ratio_detail_preexo(t,iso,kfo) Food waste as outcome of regression (kcal per kcal) * transition to exogenous scenario diets - i15_intake_scen_target(t,iso) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) - i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) - i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + i15_intake_scen_target(t,iso) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) + i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) + i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + + +*** NEW PARAMETERS IN ISABELLE'S VERSION *** + +* transformed to iso (check whether input data is available like that) + i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) + i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) +* why is the following needed? + i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) + p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) + p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) + i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) + +* are these needed? +p15_demand2intake_ratio_ref(i) Ratio between food calorie demand and intake for the historical time step of EAT Lancet diets (1) +i15_demand2intake_detailed_ref(i,kfo) Historical ratio between food calorie demand and intake for different food commodities (1) + +*** NEW PARAMETERS IN ISABELLE'S VERSION *** + p15_foodwaste_growth(t,iso) Increase in food waste over time relative to the historical time step of EAT Lancet diets (1) i15_kcal_pc_scen_target(t,iso,kfo) Target for per capita food consumption according to an exogenous diet scenario (kcal per capita per day) @@ -171,13 +187,13 @@ parameters ; scalars - s15_year Current year as integer value (yr) /2000/ + s15_year Current year as integer value (yr) / 2000 / ; + *' @code *' The food demand model consists of the following equations, which are not *' part of MAgPIE. - model m15_food_demand / q15_aim, q15_budget, diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index a8a5b23e44..029bb1ca25 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -221,15 +221,12 @@ if (s15_run_diet_postprocessing = 1, *' calculation of food intake and demand according to a predefined speed of *' convergence from `p15_kcal_pc_calibrated(t,iso,kfo)` to the scenario-dependent target *' `i15_kcal_pc_scen_target(t,iso,kfo)` by setting the switch `s15_exo_diet` -*' to 1. - - - if((s15_exo_diet = 1 or s15_exo_diet = 2), +*' to 1, 2 or 3. +if ((s15_exo_diet > 0), *' 1.) In a first step, the exogenous scenario diets are defined by selecting a *' scenario target for total daily per capita food intake - $ifthen "%c15_kcal_scen%" == "healthy_BMI" p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=0; @@ -273,6 +270,7 @@ $elseif "%c15_kcal_scen%" == "no_overweight" im_demography(t,iso,sex,age)*p15_intake(t,iso,sex,age,bmi_group15) ) + i15_kcal_pregnancy(t,iso)) / sum((sex,age), im_demography(t,iso,sex,age)); + $elseif "%c15_kcal_scen%" == "half_overweight" p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15); p15_bmi_shr_target(t,iso,sex,age,"medium")= @@ -288,6 +286,7 @@ $elseif "%c15_kcal_scen%" == "half_overweight" im_demography(t,iso,sex,age)*p15_intake(t,iso,sex,age,bmi_group15) ) + i15_kcal_pregnancy(t,iso)) / sum((sex,age), im_demography(t,iso,sex,age)); + $elseif "%c15_kcal_scen%" == "no_underweight_half_overweight" p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15); p15_bmi_shr_target(t,iso,sex,age,"medium") = @@ -307,28 +306,37 @@ $elseif "%c15_kcal_scen%" == "no_underweight_half_overweight" im_demography(t,iso,sex,age)*p15_intake(t,iso,sex,age,bmi_group15) ) + i15_kcal_pregnancy(t,iso)) / sum((sex,age), im_demography(t,iso,sex,age)); + $elseif "%c15_kcal_scen%" == "endo" i15_intake_scen_target(t,iso) = p15_intake_total(t,iso); p15_bmi_shr_target(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15); + $else i15_intake_scen_target(t,iso) = sum(kfo,i15_intake_EATLancet_all(iso,"%c15_kcal_scen%","%c15_EAT_scen%",kfo)); p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=0; p15_bmi_shr_target(t,iso,sex,age,"medium")=1; $endif - -*' Intake target is adjusted to meet the calorie target - i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso)>0) = +*' The intake target is adjusted to meet the calorie target + i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); *' 2.) The second step defines the daily per capita intake of different food -*' commodities by filling up the scenario target for total daily per capita food -*' intake according to different scenario assumptions on dietary patterns. Calories -*' for staple crops can be modified in order to meet the total calorie target. +*' commodities. + +*---------------------------------------------------------------------------------------- +if (s15_exo_diet = 1, +*' In case of diet scenarios that are parametrized to a food-specific data set published +*' by the EAT-Lancet Commission (`s15_exo_diet=1`), this calculation step consists of +*' filling up the scenario target for total daily per capita food intake according +*' to the food-specific calorie intake of non-staple crops of this data set based on +*' exogenous food demand projections. +*' In case that the in step 1.) selected total calorie intake is not equal to total intake +*' of the data set, only the calories for staple crops are modified and calories for +*' non-staple food commodities are preserved. *' The EAT lancet target values are the same for non-staples irrespective of the calorie target *' Only non-staples differ - i15_intake_EATLancet(iso,kfo) = i15_intake_EATLancet_all(iso,"2100kcal","%c15_EAT_scen%",kfo); @@ -371,9 +379,133 @@ $endif = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))>0) = ( - i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)) )*( - i15_intake_EATLancet(iso,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) ); + i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * + (i15_intake_EATLancet(iso,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) + ; + +* VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? + +*---------------------------------------------------------------------------------------- +elseif s15_exo_diet = 3, +*' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), +*' model-internal diet projections are constraint by recommended ranges for intake +*' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable +*' diets according to the EAT-Lancet Commission. After all calorie recommendations +*' for non-staple food groups are satisfied, intake of staple crops is modified such +*' that the in step 1.) selected total calorie intake is met. +* Note: brans is the only food commodity group that will not be affected +* by the following calculations. + +*' Where maximum target is not exceeded, total scenario food intake is assigned +*' to EAT-Lancet recommendation + i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); +*** ISABELLE: Why does the i15_rec_EATLancet have to be overwritten, though? + +*' It is, however, switched off for roots, since they will, as staples, +*' later be treated as balancing post to meet total calorie intake: + i15_rec_EATLancet(iso,"t_roots","max") = i15_intake_scen_target(t,iso); +*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target +*** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) + + +*** ISABELLE/BENNI: I think this is not required anymore (food waste calculations have changed since then) +** Use p15_intake_detail(t,iso,kfo) instead? +* The parameter p15_intake_detailed_regr doesn't exist anymore in this realization. +*p15_intake_detailed_regr(t,i,kfo) = p15_kcal_pc_calibrated(t,i,kfo) +* / (i15_calib_fsupply(i) * i15_demand2intake_detailed_ref(i,kfo) * p15_foodwaste_growth(t,i)); +*i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); + +*' The intake target is adjusted to meet the EAT-Lancet recommendations +*** Minimum recommendations *** +*' If projected food intake is below minimum, it is increased it to meet +*' the EAT-Lancet recommendations: + i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) + ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) + ) = + (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) + * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"min")) + ; + +*** Maximum recommendations *** +*' If projected food intake is above maximum, it is decreased it to meet +*' the EAT-Lancet recommendations: + i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) + ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) + ) = + (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) + * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"max")) + ; + +*** Special case: Fruits, vegetables and nuts *** +*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category. +*' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) +*' of fruits and vegetables in this aggregate category + if (sum(sameas(t_past,t),1) = 1, + i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t,iso); + else + i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t-1,iso); + ); + +*' This ratio is used to split the 'others' category into fruits plus vegetables +*' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower +*****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso) * p15_intake_detail(t,iso,"others"); + p15_intake_detail_nsothers(t,iso) = (1-i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); + i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); + i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); + +*' Minimum recommendation for fruits and vegetables: + i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) + = i15_rec_EATLancet(iso,"t_fruitveg","min"); + +*' Minimum recommendation for nuts +*' (a) nuts and seeds that are included in "others" + i15_intake_detailed_scen_nsothers(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail_nsothers(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; +*' (b) for rapeseed, groundnut, sunflower: +*** BENNI/ISABELLE: where to put groundnuts? separate? + i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; + +*' The resulting intake of the "others" category is: + i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nsothers(t,iso); +* Update of the ratio of fruits and vegetables within the "others" category: + i15_fruitveg2others_kcal_ratio_scen(t,iso)$(i15_intake_detailed_scen_target(t,iso,"others") > 0) + = i15_intake_detailed_scen_fruitveg(t,iso) / i15_intake_detailed_scen_target(t,iso,"others"); + +* Food commodities that are not included in diet recommendations are set to zero: + i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; +* Optionally, there is an exception for alcohol: +* Via 's15_alc_scen' a maximum target for alcohol consumption can be defined, e.g. according to Lassen et al., (2020). + if (s15_alc_scen > 0, +* first, reduce projected alcohol consumption by a quarter: + i15_intake_detailed_scen_target(t,iso,"alcohol") = p15_intake_detail(t,iso,"alcohol") * 3/4; +* if still above target, set to maximum: + i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) + = s15_alc_scen * i15_intake_scen_target(t,iso); + ); +***** ISABELLE: Why is this done in two steps? +***** BENNI: This is also done in the other EAT implementation (s15_exo_diet = 1). +***** Should it be done the same way in both? (Should it be taken out of the if-condition (applied to both)?) + +*** Balancing calorie requirements *** +*' After all calorie recommendations for non-staple food groups are satisfied, intake of staple crops is +*' now modified such that the in step 1.) selected total calorie intake is met: + i15_intake_detailed_scen_target(t,iso,EAT_staples) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) + * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); + +); +*** End of MAgPIE-specific realization of the EAT Lancet diet *' 3.) In the third step, the regression-based calculation of intake *' is faded into the exogenous intake scenario according to a predefined speed of @@ -385,9 +517,8 @@ $endif p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); - ); -*' End of special postprocessing food demand scenarios. +*** End of special postprocessing food demand scenarios. *' 4.) The fourth step estimates the calorie supply at household level by multiplying @@ -395,10 +526,9 @@ $endif *' previously. It assures that if commodities with higher food waste ratio are *' increasingly consumed, food waste increases. p15_kcal_pc_iso(t,iso,kfo) = p15_intake_detail(t,iso,kfo) - *p15_demand2intake_ratio_detail(t,iso,kfo); + * p15_demand2intake_ratio_detail(t,iso,kfo); *' Total waste share and total intake are adapted to new calculations. - p15_intake_total(t,iso) = sum(kfo, p15_intake_detail(t,iso,kfo)); p15_waste_pc(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_intake_detail(t,iso,kfo); @@ -408,22 +538,19 @@ $endif * ###### Exogenous food waste scenario - - if(s15_exo_waste = 1, +if (s15_exo_waste = 1, *' "Downwards convergence" of regional calorie oversupply due to food waste to the *' waste reduction target, i.e. only for values that are higher than the target: - p15_demand2intake_ratio(t,iso)$(p15_demand2intake_ratio(t,iso) > s15_waste_scen ) - = p15_demand2intake_ratio(t,iso)*(1-i15_exo_foodscen_fader(t,iso)) - + s15_waste_scen*i15_exo_foodscen_fader(t,iso); + = p15_demand2intake_ratio(t,iso) * (1-i15_exo_foodscen_fader(t,iso)) + + s15_waste_scen * i15_exo_foodscen_fader(t,iso); ); *' waste calculation by crop type - - p15_waste_pc(t,iso,kfo)$(sum(kfo2, p15_waste_pc(t,iso,kfo2))<>0) = p15_waste_pc(t,iso,kfo) / sum(kfo2, p15_waste_pc(t,iso,kfo2))* - (p15_intake_total(t,iso)*p15_demand2intake_ratio(t,iso)-p15_intake_total(t,iso)); + p15_waste_pc(t,iso,kfo)$(sum(kfo2, p15_waste_pc(t,iso,kfo2))<>0) = p15_waste_pc(t,iso,kfo) / sum(kfo2, p15_waste_pc(t,iso,kfo2)) * + (p15_intake_total(t,iso)*p15_demand2intake_ratio(t,iso) - p15_intake_total(t,iso)); *' Waste ratio is applied p15_kcal_pc_iso(t,iso,kfo) = p15_intake_detail(t,iso,kfo) + p15_waste_pc(t,iso,kfo); @@ -462,12 +589,12 @@ $endif ); -*' Finally, we calibrate countries with zero food demand according to FAOSTAT +*' Finally, countries with zero food demand according to FAOSTAT are calibrated *' down to zero to match FAO world totals. *' Values are rounded to avoid path dependencies of MAgPIE solver. - p15_kcal_pc_calibrated(t,i,kfo)=p15_kcal_pc(t,i,kfo)+p15_balanceflow_kcal(t,i,kfo); - p15_kcal_pc_calibrated(t,i,kfo)=round(p15_kcal_pc_calibrated(t,i,kfo),2); - p15_kcal_pc_calibrated(t,i,kfo)$(p15_kcal_pc_calibrated(t,i,kfo)<0)=0; + p15_kcal_pc_calibrated(t,i,kfo) = p15_kcal_pc(t,i,kfo) + p15_balanceflow_kcal(t,i,kfo); + p15_kcal_pc_calibrated(t,i,kfo) = round(p15_kcal_pc_calibrated(t,i,kfo), 2); + p15_kcal_pc_calibrated(t,i,kfo)$(p15_kcal_pc_calibrated(t,i,kfo) < 0) = 0; *' @stop ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 099e6acbfc..c1ed29dede 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -250,9 +250,19 @@ $ondelim $include "./modules/15_food/input/f15_supply2intake_ratio_FAO_iso.cs3" $offdelim; +*** EAT Lancet diet recommendation +table f15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) +$ondelim +$include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" +$offdelim; + +table f15_fruitveg2others_kcal_ratio(t_all,iso) Ratio of calories from fruits and vegetables within the others food category (1) +$ondelim +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.csv" +$offdelim; -**This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions -**Different set elements for sets "t_scen15", "kcal_scen15" and "EAT_scen15" result in the identical target diet as per f15_intake_EATLancet +* This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions +* Different set elements for sets "t_scen15", "kcal_scen15" and "EAT_scen15" result in the identical target diet as per f15_intake_EATLancet table f15_intake_NIN(t_scen15,iso,kcal_scen15,EAT_scen15,kfo) NIN scenarios for food-specific intake (kcal per capita per day) $ondelim $include "./modules/15_food/input/f15_intake_NIN_iso.cs3" diff --git a/modules/15_food/anthro_iso_jun22/preloop.gms b/modules/15_food/anthro_iso_jun22/preloop.gms index 0397c55f4b..cc0750210a 100644 --- a/modules/15_food/anthro_iso_jun22/preloop.gms +++ b/modules/15_food/anthro_iso_jun22/preloop.gms @@ -9,7 +9,7 @@ i15_bmi_saturation(sex,agegroup15,bmi_tree15) = f15_bmi_shr_paras(sex,agegroup15,bmi_tree15,"saturation"); i15_bmi_halfsat(sex,agegroup15,bmi_tree15) = f15_bmi_shr_paras(sex,agegroup15,bmi_tree15,"halfsaturation"); -p15_bodyheight(t,iso,sex,age,estimates15) = f15_bodyheight(t,iso,sex,age); + p15_bodyheight(t,iso,sex,age,estimates15) = f15_bodyheight(t,iso,sex,age); * calculating growth food for historical period @@ -55,8 +55,7 @@ Elseif s15_milk_share_fadeout_india = 1, * ###### Exogenous food waste and diet scenarios as well as food substitution scenarios - -* Switch to determine countries for which exogenous food scenarios (EAT Lancet diet and +* Switch to determine countries for which exogenous food scenarios (EAT Lancet diet and * food waste scenarios), and food substitution scenarios shall be applied. * In the default case, the exogenous food scenarios affect all countries. p15_country_dummy(iso) = 0; @@ -81,16 +80,19 @@ i15_exo_foodscen_fader(t,iso) = (1-f15_food_substitution_fader(t,"%c15_exo_foods $ifthen "%c15_exo_foodscen%" == "lin_zero_20_30" i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2030",iso,kcal_scen15,EAT_scen15,kfo); *extra condition to see if India diet scenario has been selected - if(s15_exo_diet = 2, + if (s15_exo_diet = 2, i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2030",iso,kcal_scen15,EAT_scen15,kfo); ); $else i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2050",iso,kcal_scen15,EAT_scen15,kfo); - if(s15_exo_diet = 2, + if (s15_exo_diet = 2, i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2050",iso,kcal_scen15,EAT_scen15,kfo); ); $endif +* Initialisation of the recommendations for healthy food intake: +i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) = f15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15); + * initial prices in $US per Kcal i15_prices_initial_kcal(iso,kfo)$(fm_nutrition_attributes("y1995",kfo,"kcal")>0) = f15_prices_initial(kfo) / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); diff --git a/modules/15_food/anthro_iso_jun22/realization.gms b/modules/15_food/anthro_iso_jun22/realization.gms index 87624010d9..724e75d087 100644 --- a/modules/15_food/anthro_iso_jun22/realization.gms +++ b/modules/15_food/anthro_iso_jun22/realization.gms @@ -45,4 +45,4 @@ $Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthro_iso_jun22/posts *' diet scenarios, most importantly the shift to the Planetary Health diet *' [@willett_food_2019]. *' -*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier, Marco Springmann diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 18f196764f..19c01fff13 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,6 +109,15 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / + kfo_ns(kfo) Food products that can be counted towards nuts and nuts_seeds + / rapeseed, groundnut, sunflower / +** BENNI/ISABELLE: Where should groundnut be counted towards? + + kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation + / sugr_cane, sugr_beet, molasses, alcohol, scp / +** Note: To Do: attribute sugr_cane, sugr_bee, molasses to sugar +* ISABELLE: What about brans? + knf(kall) Non-food products in the sectoral version / oilpalm,cottn_pro,foddr, pasture, begr, betr, oilcakes,ethanol,distillers_grain,fibres, @@ -116,7 +125,7 @@ sets wood, woodfuel / nutrition Nutrition attributes - /kcal, protein/ + / kcal, protein/ par15 Parameters for food module / intercept,saturation,halfsaturation,non_saturation / @@ -164,26 +173,97 @@ sets EAT_scen15 Scenario of daily per capita calorie intake / BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat / - EAT_monogastrics15(kfo) monogastic products + EAT_monogastrics15(kfo) monogastic products / livst_pig, livst_egg, livst_chick / - EAT_ruminants15(kfo) ruminant products + EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / - EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds - /rapeseed,sunflower,others/ - EAT_pulses15(kfo) pulses - /soybean,puls_pro,groundnut/ - EAT_sugar15(kfo) sugar - /sugr_cane,sugr_beet,sugar,molasses/ - - EAT_staples(kfo) All staple food products according to EAT Lancet definition - / tece,maiz,trce,rice_pro,potato,cassav_sp / - EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition - / soybean,rapeseed,groundnut,sunflower,puls_pro, - sugr_cane,sugr_beet, - oils,sugar,molasses,alcohol,brans,scp, - livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish, + EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds + / rapeseed, sunflower, others / + EAT_pulses15(kfo) pulses + / soybean, puls_pro, groundnut / +** BENNI: are groundnuts nuts or pulses? +** also note: peanuts (=groundnut?) has actually a single target (shouldn't we separate it?) + EAT_sugar15(kfo) sugar + / sugr_cane, sugr_beet, sugar, molasses / + + EAT_staples(kfo) All staple food products according to EAT Lancet definition + / tece, maiz, trce, rice_pro, potato, cassav_sp / +*** ISABELLE/BENNI/MARCO: Should potato and cassav_sp be included in staples (balancing post?) +* Alternatively: +*EAT_starch(kfo) Food group starch as of EAT +* / tece, maiz, trce, rice_pro / + EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition + / soybean, rapeseed, groundnut, sunflower, puls_pro, + sugr_cane, sugr_beet, + oils, sugar, molasses, alcohol, brans, scp, + livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / +* Food groups for Marco's diet model (my suggestion) +* EAT_starch(kfo) Food group starch as of EAT --> different from EAT_staples (see above) +* / tece, maiz, trce, rice_pro / +* EAT_soybeans(kfo) Soybeans as of EAT --> not new set definition required +* / soybean / +* EAT_nutsseeds(kfo) Food group of nuts and seeds as of EAT +* / rapeseed, groundnut, sunflower / +**** BENNI: Is groundnut nuts or pulses? +* EAT_legumes(kfo) Legumes as of EAT +* / puls_pro / +* EAT_roots(kfo) Food group of roots as of EAT +* / potato, cassav_sp / +* EAT_sugar15(kfo) Sugar as of EAT --> same as in above code, but different from Isabelle's +* / sugr_cane, sugr_beet, sugar, molasses / +* EAT_redmeat(kfo) Food group of red meat as of EAT target +* / livst_rum, livst_pig / +* EAT_poultry(kfo) EAT target food group poultry ---> for 1:1 product, no extra set necessary +* / livst_chick / +* EAT_eggs(kfo) EAT target food group eggs ---> for 1:1 product, no extra set necessary +* / livst_egg / +* EAT_milk(kfo) EAT target food group milk +* / livst_milk / +* EAT_fish(kfo) EAT target food group fish +* / fish / +* EAT_fruits --> common target for fruits and vegetables? (just add up?) +* EAT_vegetables --> common target for fruits and vegetables? (just add up?) +* For others: check how Isabelle solved this (separation of nuts from other (based on FAO)) +* Where should oils, alcohol, brans, scp be attributed to? +* For oils (same problem!): just combine oil_palm and oil_veg to one target? (how did Isabelle solve this?) +* scp -> redmeat? +* for brans -> keep regression value? +* alcohol: 0 or default value (Lassen et al.)? + + +* Isabelle's code: +EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations + / min, max / + +EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined + / t_nutseeds, t_fruitveg, + t_roots, t_redmeat, + t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + +EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible + / t_roots, t_redmeat, + t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + +EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories +* ISABELLE: Where are groundnuts? (peanuts have separate target. should we add it?) +* + / t_roots . (potato, cassav_sp) +* Note: To Do: split roots target because cassav_sp contains bananas/plantains (see Marco's model: starchy fruits) + t_redmeat . (livst_rum, livst_pig) + t_puls_pro . (puls_pro) + t_soybean . (soybean) + t_fish . (fish) + t_livst_chick . (livst_chick) + t_livst_egg . (livst_egg) + t_livst_milk . (livst_milk) + t_sugar . (sugar) +* Note: To Do: add sugr_cane, sugr_beet, molasses + t_oils . (oils) +* Note: To Do: double check whether the oils target contains oil_palm and oil_veg + / + ; alias(kst,kst2); @@ -192,6 +272,9 @@ alias(kfo,kfo2); alias(kfo_ap,kfo_ap2); alias(kfo_st,kfo_st2); alias(kfo_pf,kfo_pf2); +alias(kfo_ns,kfo_ns2); alias(iso,iso2); alias(reproductive,reproductive2); alias(EAT_staples,EAT_staples2); +alias(EAT_mtargets15,EAT_mtargets15_2); +alias(EATtar_kfo15,EATtar_kfo15_2); diff --git a/modules/15_food/input/files b/modules/15_food/input/files index c71a6ff7c9..1fa6f16081 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -20,6 +20,8 @@ f15_supply2intake_ratio_bottomup.cs3 f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 +f15_targets_EATLancet_iso.cs3 +f15_fruitveg2others_kcal_ratio_iso.csv f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv diff --git a/renv/activate.R b/renv/activate.R index 019b5a6693..55dae8650e 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -3,6 +3,7 @@ local({ # the requested version of renv version <- "0.16.0" + attr(version, "sha") <- "0e3aab27a928eb261819a3fc45a3ee2b4ba902a5" # the project directory project <- getwd() @@ -60,21 +61,75 @@ local({ # load bootstrap tools `%||%` <- function(x, y) { - if (is.environment(x) || length(x)) x else y + if (is.null(x)) y else x + } + + catf <- function(fmt, ..., appendLF = TRUE) { + + quiet <- getOption("renv.bootstrap.quiet", default = FALSE) + if (quiet) + return(invisible()) + + msg <- sprintf(fmt, ...) + cat(msg, file = stdout(), sep = if (appendLF) "\n" else "") + + invisible(msg) + + } + + header <- function(label, + ..., + prefix = "#", + suffix = "-", + n = min(getOption("width"), 78)) + { + label <- sprintf(label, ...) + n <- max(n - nchar(label) - nchar(prefix) - 2L, 8L) + if (n <= 0) + return(paste(prefix, label)) + + tail <- paste(rep.int(suffix, n), collapse = "") + paste0(prefix, " ", label, " ", tail) + + } + + startswith <- function(string, prefix) { + substring(string, 1, nchar(prefix)) == prefix } bootstrap <- function(version, library) { + friendly <- renv_bootstrap_version_friendly(version) + section <- header(sprintf("Bootstrapping renv %s", friendly)) + catf(section) + # attempt to download renv - tarball <- tryCatch(renv_bootstrap_download(version), error = identity) - if (inherits(tarball, "error")) - stop("failed to download renv ", version) + catf("- Downloading renv ... ", appendLF = FALSE) + withCallingHandlers( + tarball <- renv_bootstrap_download(version), + error = function(err) { + catf("FAILED") + stop("failed to download:\n", conditionMessage(err)) + } + ) + catf("OK") + on.exit(unlink(tarball), add = TRUE) # now attempt to install - status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) - if (inherits(status, "error")) - stop("failed to install renv ", version) + catf("- Installing renv ... ", appendLF = FALSE) + withCallingHandlers( + status <- renv_bootstrap_install(version, tarball, library), + error = function(err) { + catf("FAILED") + stop("failed to install:\n", conditionMessage(err)) + } + ) + catf("OK") + + # add empty line to break up bootstrapping from normal output + catf("") + return(invisible()) } renv_bootstrap_tests_running <- function() { @@ -83,28 +138,32 @@ local({ renv_bootstrap_repos <- function() { + # get CRAN repository + cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") + # check for repos override repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) + if (!is.na(repos)) { + + # check for RSPM; if set, use a fallback repository for renv + rspm <- Sys.getenv("RSPM", unset = NA) + if (identical(rspm, repos)) + repos <- c(RSPM = rspm, CRAN = cran) + return(repos) + } + # check for lockfile repositories repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) if (!inherits(repos, "error") && length(repos)) return(repos) - # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) - return(getOption("renv.tests.repos")) - # retrieve current repos repos <- getOption("repos") # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- getOption( - "renv.repos.cran", - "https://cloud.r-project.org" - ) + repos[repos == "@CRAN@"] <- cran # add in renv.bootstrap.repos if set default <- c(FALLBACK = "https://cloud.r-project.org") @@ -143,33 +202,34 @@ local({ renv_bootstrap_download <- function(version) { - # if the renv version number has 4 components, assume it must - # be retrieved via github - nv <- numeric_version(version) - components <- unclass(nv)[[1]] - - # if this appears to be a development version of 'renv', we'll - # try to restore from github - dev <- length(components) == 4L - - # begin collecting different methods for finding renv - methods <- c( - renv_bootstrap_download_tarball, - if (dev) - renv_bootstrap_download_github - else c( - renv_bootstrap_download_cran_latest, - renv_bootstrap_download_cran_archive + sha <- attr(version, "sha", exact = TRUE) + + methods <- if (!is.null(sha)) { + + # attempting to bootstrap a development version of renv + c( + function() renv_bootstrap_download_tarball(sha), + function() renv_bootstrap_download_github(sha) + ) + + } else { + + # attempting to bootstrap a release version of renv + c( + function() renv_bootstrap_download_tarball(version), + function() renv_bootstrap_download_cran_latest(version), + function() renv_bootstrap_download_cran_archive(version) ) - ) + + } for (method in methods) { - path <- tryCatch(method(version), error = identity) + path <- tryCatch(method(), error = identity) if (is.character(path) && file.exists(path)) return(path) } - stop("failed to download renv ", version) + stop("All download methods failed") } @@ -233,8 +293,6 @@ local({ type <- spec$type repos <- spec$repos - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - baseurl <- utils::contrib.url(repos = repos, type = type) ext <- if (identical(type, "source")) ".tar.gz" @@ -251,13 +309,10 @@ local({ condition = identity ) - if (inherits(status, "condition")) { - message("FAILED") + if (inherits(status, "condition")) return(FALSE) - } # report success and return - message("OK (downloaded ", type, ")") destfile } @@ -314,8 +369,6 @@ local({ urls <- file.path(repos, "src/contrib/Archive/renv", name) destfile <- file.path(tempdir(), name) - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - for (url in urls) { status <- tryCatch( @@ -323,14 +376,11 @@ local({ condition = identity ) - if (identical(status, 0L)) { - message("OK") + if (identical(status, 0L)) return(destfile) - } } - message("FAILED") return(FALSE) } @@ -344,8 +394,7 @@ local({ return() # allow directories - info <- file.info(tarball, extra_cols = FALSE) - if (identical(info$isdir, TRUE)) { + if (dir.exists(tarball)) { name <- sprintf("renv_%s.tar.gz", version) tarball <- file.path(tarball, name) } @@ -354,7 +403,7 @@ local({ if (!file.exists(tarball)) { # let the user know we weren't able to honour their request - fmt <- "* RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." + fmt <- "- RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." msg <- sprintf(fmt, tarball) warning(msg) @@ -363,10 +412,7 @@ local({ } - fmt <- "* Bootstrapping with tarball at path '%s'." - msg <- sprintf(fmt, tarball) - message(msg) - + catf("- Using local tarball '%s'.", tarball) tarball } @@ -393,8 +439,6 @@ local({ on.exit(do.call(base::options, saved), add = TRUE) } - message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) - url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) name <- sprintf("renv_%s.tar.gz", version) destfile <- file.path(tempdir(), name) @@ -404,26 +448,105 @@ local({ condition = identity ) - if (!identical(status, 0L)) { - message("FAILED") + if (!identical(status, 0L)) return(FALSE) - } - message("OK") + renv_bootstrap_download_augment(destfile) + return(destfile) } + # Add Sha to DESCRIPTION. This is stop gap until #890, after which we + # can use renv::install() to fully capture metadata. + renv_bootstrap_download_augment <- function(destfile) { + sha <- renv_bootstrap_git_extract_sha1_tar(destfile) + if (is.null(sha)) { + return() + } + + # Untar + tempdir <- tempfile("renv-github-") + on.exit(unlink(tempdir, recursive = TRUE), add = TRUE) + untar(destfile, exdir = tempdir) + pkgdir <- dir(tempdir, full.names = TRUE)[[1]] + + # Modify description + desc_path <- file.path(pkgdir, "DESCRIPTION") + desc_lines <- readLines(desc_path) + remotes_fields <- c( + "RemoteType: github", + "RemoteHost: api.github.com", + "RemoteRepo: renv", + "RemoteUsername: rstudio", + "RemotePkgRef: rstudio/renv", + paste("RemoteRef: ", sha), + paste("RemoteSha: ", sha) + ) + writeLines(c(desc_lines[desc_lines != ""], remotes_fields), con = desc_path) + + # Re-tar + local({ + old <- setwd(tempdir) + on.exit(setwd(old), add = TRUE) + + tar(destfile, compression = "gzip") + }) + invisible() + } + + # Extract the commit hash from a git archive. Git archives include the SHA1 + # hash as the comment field of the tarball pax extended header + # (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) + # For GitHub archives this should be the first header after the default one + # (512 byte) header. + renv_bootstrap_git_extract_sha1_tar <- function(bundle) { + + # open the bundle for reading + # We use gzcon for everything because (from ?gzcon) + # > Reading from a connection which does not supply a ‘gzip’ magic + # > header is equivalent to reading from the original connection + conn <- gzcon(file(bundle, open = "rb", raw = TRUE)) + on.exit(close(conn)) + + # The default pax header is 512 bytes long and the first pax extended header + # with the comment should be 51 bytes long + # `52 comment=` (11 chars) + 40 byte SHA1 hash + len <- 0x200 + 0x33 + res <- rawToChar(readBin(conn, "raw", n = len)[0x201:len]) + + if (grepl("^52 comment=", res)) { + sub("52 comment=", "", res) + } else { + NULL + } + } + renv_bootstrap_install <- function(version, tarball, library) { # attempt to install it into project library - message("* Installing renv ", version, " ... ", appendLF = FALSE) dir.create(library, showWarnings = FALSE, recursive = TRUE) + output <- renv_bootstrap_install_impl(library, tarball) + + # check for successful install + status <- attr(output, "status") + if (is.null(status) || identical(status, 0L)) + return(status) + + # an error occurred; report it + header <- "installation of renv failed" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- paste(c(header, lines, output), collapse = "\n") + stop(text) + + } + + renv_bootstrap_install_impl <- function(library, tarball) { # invoke using system2 so we can capture and report output bin <- R.home("bin") exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" - r <- file.path(bin, exe) + R <- file.path(bin, exe) args <- c( "--vanilla", "CMD", "INSTALL", "--no-multiarch", @@ -431,19 +554,7 @@ local({ shQuote(path.expand(tarball)) ) - output <- system2(r, args, stdout = TRUE, stderr = TRUE) - message("Done!") - - # check for successful install - status <- attr(output, "status") - if (is.numeric(status) && !identical(status, 0L)) { - header <- "Error installing renv:" - lines <- paste(rep.int("=", nchar(header)), collapse = "") - text <- c(header, lines, output) - writeLines(text, con = stderr()) - } - - status + system2(R, args, stdout = TRUE, stderr = TRUE) } @@ -653,34 +764,60 @@ local({ } - renv_bootstrap_validate_version <- function(version) { + renv_bootstrap_validate_version <- function(version, description = NULL) { - loadedversion <- utils::packageDescription("renv", fields = "Version") - if (version == loadedversion) - return(TRUE) + # resolve description file + description <- description %||% { + path <- getNamespaceInfo("renv", "path") + packageDescription("renv", lib.loc = dirname(path)) + } - # assume four-component versions are from GitHub; three-component - # versions are from CRAN - components <- strsplit(loadedversion, "[.-]")[[1]] - remote <- if (length(components) == 4L) - paste("rstudio/renv", loadedversion, sep = "@") + # check whether requested version 'version' matches loaded version of renv + sha <- attr(version, "sha", exact = TRUE) + valid <- if (!is.null(sha)) + renv_bootstrap_validate_version_dev(sha, description) else - paste("renv", loadedversion, sep = "@") + renv_bootstrap_validate_version_release(version, description) + + if (valid) + return(TRUE) + + # the loaded version of renv doesn't match the requested version; + # give the user instructions on how to proceed + remote <- if (!is.null(description[["RemoteSha"]])) { + paste("rstudio/renv", description[["RemoteSha"]], sep = "@") + } else { + paste("renv", description[["Version"]], sep = "@") + } + + # display both loaded version + sha if available + friendly <- renv_bootstrap_version_friendly( + version = description[["Version"]], + sha = description[["RemoteSha"]] + ) fmt <- paste( "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", - "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", - "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + "- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", sep = "\n" ) - - msg <- sprintf(fmt, loadedversion, version, remote) - warning(msg, call. = FALSE) + catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) FALSE } + renv_bootstrap_validate_version_dev <- function(version, description) { + expected <- description[["RemoteSha"]] + is.character(expected) && startswith(expected, version) + } + + renv_bootstrap_validate_version_release <- function(version, description) { + expected <- description[["Version"]] + is.character(expected) && identical(expected, version) + } + renv_bootstrap_hash_text <- function(text) { hashfile <- tempfile("renv-hash-") @@ -700,6 +837,12 @@ local({ # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) + # execute renv load hooks, if any + hooks <- getHook("renv::autoload") + for (hook in hooks) + if (is.function(hook)) + tryCatch(hook(), error = warning) + # load the project renv::load(project) @@ -839,14 +982,66 @@ local({ } + renv_bootstrap_version_friendly <- function(version, sha = NULL) { + sha <- sha %||% attr(version, "sha", exact = TRUE) + parts <- c(version, sprintf("[sha: %s]", substring(sha, 1L, 7L))) + paste(parts, collapse = " ") + } + + renv_bootstrap_run <- function(version, libpath) { + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + return(renv::load(project = getwd())) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + + } + + + renv_bootstrap_in_rstudio <- function() { + commandArgs()[[1]] == "RStudio" + } renv_json_read <- function(file = NULL, text = NULL) { + jlerr <- NULL + # if jsonlite is loaded, use that instead - if ("jsonlite" %in% loadedNamespaces()) - renv_json_read_jsonlite(file, text) + if ("jsonlite" %in% loadedNamespaces()) { + + json <- catch(renv_json_read_jsonlite(file, text)) + if (!inherits(json, "error")) + return(json) + + jlerr <- json + + } + + # otherwise, fall back to the default JSON reader + json <- catch(renv_json_read_default(file, text)) + if (!inherits(json, "error")) + return(json) + + # report an error + if (!is.null(jlerr)) + stop(jlerr) else - renv_json_read_default(file, text) + stop(json) } @@ -964,31 +1159,23 @@ local({ if (renv_bootstrap_load(project, libpath, version)) return(TRUE) - # load failed; inform user we're about to bootstrap - prefix <- paste("# Bootstrapping renv", version) - postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") - header <- paste(prefix, postfix) - message(header) - - # perform bootstrap - bootstrap(version, libpath) - - # exit early if we're just testing bootstrap - if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) - return(TRUE) + if (renv_bootstrap_in_rstudio()) { + setHook("rstudio.sessionInit", function(...) { + renv_bootstrap_run(version, libpath) - # try again to load - if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { - message("* Successfully installed and loaded renv ", version, ".") - return(renv::load()) + # Work around buglet in RStudio if hook uses readline + tryCatch( + { + tools <- as.environment("tools:rstudio") + tools$.rs.api.sendToConsole("", echo = FALSE, focus = FALSE) + }, + error = function(cnd) {} + ) + }) + } else { + renv_bootstrap_run(version, libpath) } - # failed to download or load renv; warn the user - msg <- c( - "Failed to find an renv installation: the project will not be loaded.", - "Use `renv::activate()` to re-initialize the project." - ) - - warning(paste(msg, collapse = "\n"), call. = FALSE) + invisible() }) diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R new file mode 100644 index 0000000000..1ef1c567c9 --- /dev/null +++ b/scripts/start/projects/project_EAT2.R @@ -0,0 +1,44 @@ +# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | MAgPIE License Exception, version 1.0 (see LICENSE file). +# | Contact: magpie@pik-potsdam.de + +# ---------------------------------------------------------- +# description: EAT 2.0 simulations +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### +library(gms) +library(lucode2) +library(magclass) + +# load start_function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# laod default configuration +source("config/default.cfg") + +# Set defaults +codeCheck <- FALSE + +################################################# +# Testing of new EAT-Lancet diet implementation # +################################################# +# Current develop default diet +cfg$title <- "default_Diet" +cfg$gms$s15_exo_diet <- 0 # default +start_run(cfg, codeCheck = codeCheck) + +# Previous EAT-Lancet implementation +cfg$title <- "eatLancet_1" +cfg$gms$s15_exo_diet <- 1 +start_run(cfg, codeCheck = codeCheck) + +# New EAT-Lancet implementation +cfg$title <- "eatLancet_2" +cfg$gms$s15_exo_diet <- 3 +start_run(cfg, codeCheck = codeCheck) diff --git a/standalone/HOWTO.md b/standalone/HOWTO.md index 98ec2668e2..6a69274151 100644 --- a/standalone/HOWTO.md +++ b/standalone/HOWTO.md @@ -4,7 +4,7 @@ Standalone models can be used to run simulations which only require a subset of modules coming with the model. It can also be used to run a module isolated from the rest of the code. -A new standalone model is created by copying the template.gms within the standalone folder to a gms file with the name of the new model. The new model file needs to include all modules relevant for the calculation (done by adding a line for each module in the "MODULE SETUP" section) and make sure that all interfaces of the modules are properly adressed. Especially, interfaces to modules not part of that reduced model need to be fed with information coming from that new model file. +A new standalone model is created by copying the template.gms within the standalone folder to a gms file with the name of the new model. The new model file needs to include all modules relevant for the calculation (done by adding a line for each module in the "MODULE SETUP" section) and make sure that all interfaces of the modules are properly addressed. Especially, interfaces to modules not part of that reduced model need to be fed with information coming from that new model file. The standalone model file needs to follow the coding etiquette as any other file, meaning that it is only allowed to interact through interfaces with the modules. This is necessary to allow the reduced model to work with all realizations of a coupled module. From 52afec653b0b16003fa2ef06320eaa67714f4c1b Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 11 Aug 2023 10:35:26 +0200 Subject: [PATCH 002/187] add standalone tests --- .../15_food/anthro_iso_jun22/declarations.gms | 50 ++---- .../15_food/anthro_iso_jun22/exodietmacro.gms | 33 ++-- modules/15_food/anthro_iso_jun22/preloop.gms | 10 +- scripts/start/projects/test_eat2_standalone.R | 23 +++ .../projects/test_fooddemand_standalone.R | 25 +++ standalone/eat2.gms | 156 ++++++++++++++++++ 6 files changed, 239 insertions(+), 58 deletions(-) create mode 100644 scripts/start/projects/test_eat2_standalone.R create mode 100644 scripts/start/projects/test_fooddemand_standalone.R create mode 100644 standalone/eat2.gms diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 10b8d8274e..28828dfb2f 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -40,12 +40,12 @@ equations positive variables - v15_kcal_regr(iso,kfo) Uncalibrated regression estimates of calorie demand (kcal per cap per day) - v15_kcal_regr_total(iso) Uncalibrated regression estimates of total per cap calories (kcal per cap per day) - v15_demand_regr(iso, regr15) Uncalibrated regression estimates of kcal shares (1) - v15_income_pc_real_ppp_iso(iso) Real income per cap (USD05PPP per cap) - v15_income_balance(iso) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD05PPP per cap per yr) - v15_kcal_intake_total_regr(iso) Food intake (kcal per cap per day) + v15_kcal_regr(iso,kfo) Uncalibrated regression estimates of calorie demand (kcal per cap per day) + v15_kcal_regr_total(iso) Uncalibrated regression estimates of total per cap calories (kcal per cap per day) + v15_demand_regr(iso, regr15) Uncalibrated regression estimates of kcal shares (1) + v15_income_pc_real_ppp_iso(iso) Real income per cap (USD05PPP per cap) + v15_income_balance(iso) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD05PPP per cap per yr) + v15_kcal_intake_total_regr(iso) Food intake (kcal per cap per day) v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) Hierarchical tree parameter regressions (1) v15_bmi_shr_regr(iso,sex,age,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) v15_bmi_shr_overgroups(iso,sex,agegroup15,bmi_group15) Uncalibrated share of population groups belonging to a certain BMI group (1) @@ -86,8 +86,8 @@ parameters i15_bmi_saturation(sex,agegroup15,bmi_tree15) BMI share regression saturation (1) i15_bmi_halfsat(sex,agegroup15,bmi_tree15) BMI share regression halfsaturation (1) - p15_bmi_shr_regr(t,iso,sex,age,bmi_group15) Uncalibrated regression estimates of BMI shares (1) - i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) Calibration parameters to meet historical BMI shares (1) + p15_bmi_shr_regr(t,iso,sex,age,bmi_group15) Uncalibrated regression estimates of BMI shares (1) + i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) Calibration parameters to meet historical BMI shares (1) i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15) Calibration parameters of the last year with historical observations (1) * diet structure @@ -154,29 +154,15 @@ parameters i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) + i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) + i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) + p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) + p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) + i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) -*** NEW PARAMETERS IN ISABELLE'S VERSION *** - -* transformed to iso (check whether input data is available like that) - i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) -* why is the following needed? - i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) - p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) - p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) - i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) - -* are these needed? -p15_demand2intake_ratio_ref(i) Ratio between food calorie demand and intake for the historical time step of EAT Lancet diets (1) -i15_demand2intake_detailed_ref(i,kfo) Historical ratio between food calorie demand and intake for different food commodities (1) - -*** NEW PARAMETERS IN ISABELLE'S VERSION *** - - - p15_foodwaste_growth(t,iso) Increase in food waste over time relative to the historical time step of EAT Lancet diets (1) - i15_kcal_pc_scen_target(t,iso,kfo) Target for per capita food consumption according to an exogenous diet scenario (kcal per capita per day) - i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) + i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) * country-specific scenario switch p15_country_dummy(iso) Dummy parameter indicating whether country is affected by diet scenarios (1) @@ -219,8 +205,6 @@ model m15_food_demand / q15_foodtree_kcal_vegetables /; - - *' In contrast, the equation `q15_food_demand` is part of MAgPIE, but *' not of the food demand model. *' @stop @@ -230,8 +214,6 @@ m15_food_demand.scaleopt = 1 ; m15_food_demand.solprint = 0 ; m15_food_demand.holdfixed = 1 ; - - *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_dem_food(t,i,kall,type) Food demand (mio. tDM per yr) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 029bb1ca25..5b1969680f 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -22,7 +22,7 @@ if (s15_run_diet_postprocessing = 1, v15_kcal_regr.l(iso,kfo) + p15_kcal_calib(t,iso,kfo) * s15_calibrate; *' Negative values that can possibly occur due to calibration are set to zero. - p15_kcal_pc_iso(t,iso,kfo)$(p15_kcal_pc_iso(t,iso,kfo)<0) = 0; + p15_kcal_pc_iso(t,iso,kfo)$(p15_kcal_pc_iso(t,iso,kfo) < 0) = 0; * saving regression outcome for BMI shares p15_bmi_shr_regr(t,iso,sex,age,bmi_group15) = v15_bmi_shr_regr.l(iso,sex,age,bmi_group15); @@ -43,7 +43,6 @@ if (s15_run_diet_postprocessing = 1, *############################################################################### * ###### Food substitution scenarios - * Substitution of ruminant beef with poultry: p15_kcal_pc_iso_orig(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); p15_kcal_pc_iso(t,iso,"livst_rum") = @@ -107,7 +106,7 @@ if (s15_run_diet_postprocessing = 1, + p15_kcal_pc_iso_rumdairy_orig(t,iso) * (1- i15_rumdairy_fadeout(t,iso))); *** Substitution of ruminant meat and dairy products (kfo_rd) with single-cell protein (SCP) based on protein/cap/day - i15_protein_to_kcal_ratio(t,kfo) = fm_nutrition_attributes(t,kfo,"protein")/fm_nutrition_attributes(t,kfo,"kcal"); + i15_protein_to_kcal_ratio(t,kfo) = fm_nutrition_attributes(t,kfo,"protein") / fm_nutrition_attributes(t,kfo,"kcal"); * Before the substitution, kfo_rd is converted from kcal/cap/day to g protein/cap/day * using i15_protein_to_kcal_ratio(t,kfo_rd). * After the substitution of kfo_rd with SCP (1-i15_rumdairy_scp_fadeout), SCP is converted @@ -170,22 +169,20 @@ if (s15_run_diet_postprocessing = 1, * food waste ratio. * To achieve maximum consistency, this calibration involves three steps. -* first apply FAO waste factors, than rescale intake proportionally to meet total intake +* First, FAO waste factors are applied and then intake is proportionally rescaled to meet total intake * This distributes the differences in waste estimates rather equally over different products - - p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo)/f15_overcons_FAOwaste(iso,kfo); + p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) / f15_overcons_FAOwaste(iso,kfo); p15_intake_detail(t,iso,kfo)$(sum(kfo2, p15_intake_detail(t,iso,kfo2))<>0) = p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2))* p15_intake_total(t,iso); -* to avoid negative waste, we reduce intake where it exceed food availabiltiy +* To avoid negative waste, we reduce intake where it exceed food availabiltiy p15_intake_detail(t,iso,kfo)$(p15_intake_detail(t,iso,kfo)>p15_kcal_pc_iso(t,iso,kfo)) = p15_kcal_pc_iso(t,iso,kfo); -* in a second round of calibration, we rescale food waste to meet total food waste. +* In a second round of calibration, we rescale food waste to meet total food waste. * Now, waste is increasing only where there is already waste. - p15_waste_pc(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_intake_detail(t,iso,kfo); p15_waste_pc(t,iso,kfo) = 0$(sum(kfo2, p15_waste_pc(t,iso,kfo2))=0) + ( @@ -196,15 +193,14 @@ if (s15_run_diet_postprocessing = 1, p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_waste_pc(t,iso,kfo); -* the third calibration is only needed for those countries where total intake exceeds calory availabtility -* here we want to have the inconsistency in the waste, not in the intake. - +* The third calibration is only needed for those countries where total intake exceeds calory availabtility. +* Here we want to have the inconsistency in the waste, not in the intake. p15_intake_detail(t,iso,kfo)$(sum(kfo2, p15_intake_detail(t,iso,kfo2))<>0) = p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2))* p15_intake_total(t,iso); p15_waste_pc(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) - p15_intake_detail(t,iso,kfo); -* we calculate a product specific demand2intake ratio +* We calculate a product specific demand2intake ratio p15_demand2intake_ratio_detail(t,iso,kfo)=1$(p15_intake_detail(t,iso,kfo) = 0) + (p15_kcal_pc_iso(t,iso,kfo) / p15_intake_detail(t,iso,kfo))$(p15_intake_detail(t,iso,kfo) > 0); @@ -216,12 +212,11 @@ if (s15_run_diet_postprocessing = 1, * ###### Exogenous EAT Lancet diet scenario *' @code -*' Transition to exogenous Planetary Health diet scenarios [@willett_food_2019]: +*' Transition to exogenous Planetary Health diet (PHD) scenarios [@willett_food_2019]: *' It is possible to define exogenous diet scenarios that replace the regression-based -*' calculation of food intake and demand according to a predefined speed of -*' convergence from `p15_kcal_pc_calibrated(t,iso,kfo)` to the scenario-dependent target -*' `i15_kcal_pc_scen_target(t,iso,kfo)` by setting the switch `s15_exo_diet` -*' to 1, 2 or 3. +*' calculation of food intake and demand scenario-dependent targets following the +*' exogenous PHDs, India-specific recommendations or model-internal intake estimates +*' that hit the PHD targets by setting the switch `s15_exo_diet` to 1, 2 or 3. if ((s15_exo_diet > 0), @@ -381,7 +376,7 @@ if (s15_exo_diet = 1, i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * - (i15_intake_EATLancet(iso,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) + (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) ; * VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? diff --git a/modules/15_food/anthro_iso_jun22/preloop.gms b/modules/15_food/anthro_iso_jun22/preloop.gms index cc0750210a..b10933b160 100644 --- a/modules/15_food/anthro_iso_jun22/preloop.gms +++ b/modules/15_food/anthro_iso_jun22/preloop.gms @@ -81,12 +81,12 @@ $ifthen "%c15_exo_foodscen%" == "lin_zero_20_30" i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2030",iso,kcal_scen15,EAT_scen15,kfo); *extra condition to see if India diet scenario has been selected if (s15_exo_diet = 2, - i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2030",iso,kcal_scen15,EAT_scen15,kfo); + i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2030",iso,kcal_scen15,EAT_scen15,kfo); ); $else i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_EATLancet("y2050",iso,kcal_scen15,EAT_scen15,kfo); if (s15_exo_diet = 2, - i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2050",iso,kcal_scen15,EAT_scen15,kfo); + i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) = f15_intake_NIN("y2050",iso,kcal_scen15,EAT_scen15,kfo); ); $endif @@ -95,6 +95,6 @@ i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) = f15_rec_EATLancet(iso,EA * initial prices in $US per Kcal i15_prices_initial_kcal(iso,kfo)$(fm_nutrition_attributes("y1995",kfo,"kcal")>0) = f15_prices_initial(kfo) - / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); -p15_prices_kcal(t,iso,kfo,"iter1")=i15_prices_initial_kcal(iso,kfo); -p15_convergence_measure(t,iter15)=NA; + / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); +p15_prices_kcal(t,iso,kfo,"iter1") = i15_prices_initial_kcal(iso,kfo); +p15_convergence_measure(t,iter15) = NA; diff --git a/scripts/start/projects/test_eat2_standalone.R b/scripts/start/projects/test_eat2_standalone.R new file mode 100644 index 0000000000..1f0bfa3acb --- /dev/null +++ b/scripts/start/projects/test_eat2_standalone.R @@ -0,0 +1,23 @@ +# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | MAgPIE License Exception, version 1.0 (see LICENSE file). +# | Contact: magpie@pik-potsdam.de + + +# ---------------------------------------------------------- +# description: Food Demand Standalone +# ---------------------------------------------------------- + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# start MAgPIE run +source("config/default.cfg") +cfg$model <- "standalone/eat2.gms" +cfg$recalibrate <- FALSE +cfg$gms$c_timesteps <- "1" + +cfg$title <- "test1" +start_run(cfg = cfg) diff --git a/scripts/start/projects/test_fooddemand_standalone.R b/scripts/start/projects/test_fooddemand_standalone.R new file mode 100644 index 0000000000..9a3d3a07dd --- /dev/null +++ b/scripts/start/projects/test_fooddemand_standalone.R @@ -0,0 +1,25 @@ +# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | MAgPIE License Exception, version 1.0 (see LICENSE file). +# | Contact: magpie@pik-potsdam.de + + +# ---------------------------------------------------------- +# description: Food Demand Standalone +# ---------------------------------------------------------- + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# start MAgPIE run +source("config/default.cfg") +cfg$model <- "standalone/demand_model.gms" +cfg$recalibrate <- FALSE +cfg$gms$c_timesteps <- "pastandfuture" +cfg$gms$s15_calibrate <- 1 +cfg$gms$s15_elastic_demand <- 0 + +cfg$title <- "test1" +start_run(cfg = cfg) diff --git a/standalone/eat2.gms b/standalone/eat2.gms new file mode 100644 index 0000000000..7d6655d830 --- /dev/null +++ b/standalone/eat2.gms @@ -0,0 +1,156 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +* This is a standalone skeleton which should be used as template +* if only parts of the model should be run. It contains the basic, +* structural components of the model. +* To use it, please copy this file, give it an explaining name and +* save it in the "models" folder. After that you can modify it based +* on the given requirements. You can add own code, but also delete +* code (e.g. the model statement or the provided loops) if these parts +* are irrelevant for your analysis. + +$title eatLancetDiet2 + +$offupper +$offsymxref +$offsymlist +$offlisting + +$setglobal c_timesteps "1" +$setglobal c_past "till_1995" + +*******************************MODULE SETUP************************************* +$setglobal drivers aug17 +$setglobal food anthro_iso_jun22 + +***************************PREDEFINED MACROS************************************ +$include "./core/macros.gms" + +***************************BASIC SETS INDICES*********************************** +$include "./core/sets.gms" +$batinclude "./modules/include.gms" sets + +***** BENNI: What would I need that for? Isn't it enough to have them defined in the module? +*sets +* exampleset / elem1, elem2, elem3 / +*; + +**********INTRODUCE CALCULATION PARAMETERS, VARIABLES AND EQUATIONS************* +$include "./core/declarations.gms" +$batinclude "./modules/include.gms" declarations + +*parameters +* p_example(exampleset) example parameter (1) +*; + +*variables +* v_example example variable (1) +*; + +*equations +* q_example example equation (1) +*; + +*****************************IMPORT DATA FILES********************************** +$batinclude "./modules/include.gms" input + +********************OBJECTIVE FUNCTION & CONSTRAINTS**************************** +$batinclude "./modules/include.gms" equations + +*q_example .. +* v_example =g= sum(exampleset, p_example(exampleset)); + + +*******************MODEL DEFINITION & SOLVER OPTIONS**************************** +model magpie / all - m15_food_demand /; +magpie.scaleopt = 1 ; +magpie.holdfixed = 1 ; + +option lp = cplex ; +option nlp = conopt4 ; +option iterlim = 1000000 ; +option reslim = 1000000 ; +option sysout = Off ; +option savepoint = 1 ; + +*model example / q_example /; + +*****************************VARIABLE SCALING*********************************** +$batinclude "./modules/include.gms" scaling + +****************************PREPROCESSING START********************************* +* In this section everything is calculated that is not influenced by the +* optimization process. Hence these lines CAN INFLUENCE the optimization process +* but CANNOT BE INFLUENCED by it. + +$batinclude "./modules/include.gms" preloop + +*p_example(exampleset) = 1; + +* create dummy file (this is necessary to be able to use put_utility and it has +* to be done here because a file declaration cannot be inside a loop +file dummy; dummy.pw=2000; put dummy; + +************************OPTIMIZATION PROCESS START****************************** +* This section contains only sourcecode that is directly connected to the +* optimization process. That means that everything on the following lines +* INFLUENCES and IS INFLUENCED by the optimization process (except the +* redefinition on preprocessed data). +* Hence one can describe this section together with the constraints section +* as "model-core". + +* clear ct set +ct(t) = no; + +***************************TIMESTEP LOOP START********************************** +loop (t, + +* set ct to current time period + ct(t) = yes; + display "Year"; + display ct; + +$batinclude "./modules/include.gms" presolve + +* intersolve for food demand model + sm_intersolve = 0; + + while(sm_intersolve = 0, + +*************************SOLVE STATEMENT START********************************** +* #### additional phases ### +* set additional phases which should be detected by +* update_module_embeddings. Most phases will be detected automatically, +* but batincludes used within a module are not detected and therefore +* have to be set manually! (Syntax: "* !add_phase!: ") +* !add_phase!: nl_fix +* !add_phase!: nl_release +* !add_phase!: nl_relax + +$batinclude "./modules/include.gms" solve + +* intersolve for food demand model + sm_intersolve = 1; +* solve example USING lp MINIMIZING v_example; + + +$batinclude "./modules/include.gms" intersolve + + ); + +**************************SOLVE STATEMENT END*********************************** + +$batinclude "./modules/include.gms" postsolve + +**********************WRITE ALL DATA IN 1 GDX FILE****************************** + Execute_Unload "fulldata.gdx"; + +* clear ct set + ct(t) = no; +); +****************************TIMESTEP LOOP END*********************************** From f9a9b55333791bc073c3cf23fc48c5f219aede51 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 15 Aug 2023 16:48:24 +0200 Subject: [PATCH 003/187] bugfixing standalone scripts --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- standalone/demand_model.gms | 4 ++++ standalone/eat2.gms | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 5b1969680f..ff1b4e6e69 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -448,7 +448,7 @@ elseif s15_exo_diet = 3, *' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower *****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso) * p15_intake_detail(t,iso,"others"); - p15_intake_detail_nsothers(t,iso) = (1-i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); + p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); @@ -564,7 +564,7 @@ if (s15_exo_waste = 1, p15_kcal_pc(t,i,kfo)$( sum(i_to_iso(i,iso), im_pop_iso(t,iso) - ) >0 ) = + ) > 0) = sum(i_to_iso(i,iso), p15_kcal_pc_iso(t,iso,kfo) * im_pop_iso(t,iso) @@ -575,7 +575,7 @@ if (s15_exo_waste = 1, p15_balanceflow_kcal(t,i,kfo)$( sum(i_to_iso(i,iso), im_pop_iso(t,iso) - ) >0 ) = + ) > 0) = sum(i_to_iso(i,iso), p15_balanceflow_kcal_iso(t,iso,kfo) * im_pop_iso(t,iso) diff --git a/standalone/demand_model.gms b/standalone/demand_model.gms index 20c44f2abf..81fea54c9e 100644 --- a/standalone/demand_model.gms +++ b/standalone/demand_model.gms @@ -14,7 +14,11 @@ $offlisting $setglobal c_timesteps pastandfuture $setglobal c_past till_1975 +$setglobal c_title default +scalars +s_use_gdx use of gdx files / 0 / +; *******************************MODULE SETUP************************************* $setglobal drivers aug17 diff --git a/standalone/eat2.gms b/standalone/eat2.gms index 7d6655d830..3e22bdf607 100644 --- a/standalone/eat2.gms +++ b/standalone/eat2.gms @@ -23,6 +23,11 @@ $offlisting $setglobal c_timesteps "1" $setglobal c_past "till_1995" +$setglobal c_title default + +scalars +s_use_gdx use of gdx files / 0 / +; *******************************MODULE SETUP************************************* $setglobal drivers aug17 From 346022c65c0390b4fdfcfeebae643ea59e71836b Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 21 Aug 2023 12:11:47 +0200 Subject: [PATCH 004/187] included display statements for checking --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index ff1b4e6e69..7bd203ed57 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -382,7 +382,7 @@ if (s15_exo_diet = 1, * VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? *---------------------------------------------------------------------------------------- -elseif s15_exo_diet = 3, +elseif (s15_exo_diet = 3), *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), *' model-internal diet projections are constraint by recommended ranges for intake *' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable @@ -403,6 +403,7 @@ elseif s15_exo_diet = 3, *** ISABELLE: Why are roots and staples used as balancing post? Roots has a target *** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) +display i15_rec_EATLancet; *** ISABELLE/BENNI: I think this is not required anymore (food waste calculations have changed since then) ** Use p15_intake_detail(t,iso,kfo) instead? @@ -444,6 +445,8 @@ elseif s15_exo_diet = 3, i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t-1,iso); ); +display i15_fruitveg2others_kcal_ratio; + *' This ratio is used to split the 'others' category into fruits plus vegetables *' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower *****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) @@ -499,6 +502,8 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); +display i15_intake_detailed_scen_target; + ); *** End of MAgPIE-specific realization of the EAT Lancet diet @@ -512,6 +517,8 @@ elseif s15_exo_diet = 3, p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); +display p15_intake_detail; + ); *** End of special postprocessing food demand scenarios. From 3d58d99cf9f25855d730e5de7074e15e2bad97aa Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 25 Aug 2023 12:27:21 +0200 Subject: [PATCH 005/187] added EAT2p0 start script for scenarios to be reported by MAgPIE --- .../anthropometrics_jan18/intersolve.gms | 4 +- scripts/start/projects/project_EAT2p0.R | 92 +++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 scripts/start/projects/project_EAT2p0.R diff --git a/modules/15_food/anthropometrics_jan18/intersolve.gms b/modules/15_food/anthropometrics_jan18/intersolve.gms index a8326dab0a..a554ed199f 100644 --- a/modules/15_food/anthropometrics_jan18/intersolve.gms +++ b/modules/15_food/anthropometrics_jan18/intersolve.gms @@ -223,12 +223,12 @@ p15_kcal_pc_calibrated(t,i,kfo_pp) = p15_plant_kcal_structure_orig(t,i,kfo_pp) *** Substitution of ruminant meat and dairy products (kfo_rd) with single-cell protein (SCP) based on protein/cap/day i15_protein_to_kcal_ratio(t,kfo) = fm_nutrition_attributes(t,kfo,"protein")/fm_nutrition_attributes(t,kfo,"kcal"); -* Before the substitution, kfo_rd is converted from kcal/cap/day to g protein/cap/day +* Before the substitution, kfo_rd is converted from kcal/cap/day to g protein/cap/day * using i15_protein_to_kcal_ratio(t,kfo_rd). * After the substitution of kfo_rd with SCP (1-i15_rumdairy_scp_fadeout), SCP is converted * back to kcal/cap/day using i15_protein_to_kcal_ratio(t,"scp"). p15_kcal_pc_calibrated(t,i,"scp") = p15_kcal_pc_calibrated(t,i,"scp") + - sum(kfo_rd, p15_kcal_pc_calibrated(t,i,kfo_rd) * (1-i15_rumdairy_scp_fadeout(t,i)) * + sum(kfo_rd, p15_kcal_pc_calibrated(t,i,kfo_rd) * (1-i15_rumdairy_scp_fadeout(t,i)) * i15_protein_to_kcal_ratio(t,kfo_rd)) / i15_protein_to_kcal_ratio(t,"scp"); p15_kcal_pc_calibrated(t,i,kfo_rd) = p15_kcal_pc_calibrated(t,i,kfo_rd) * i15_rumdairy_scp_fadeout(t,i); diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R new file mode 100644 index 0000000000..9783506f18 --- /dev/null +++ b/scripts/start/projects/project_EAT2p0.R @@ -0,0 +1,92 @@ +# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | MAgPIE License Exception, version 1.0 (see LICENSE file). +# | Contact: magpie@pik-potsdam.de + +# ---------------------------------------------------------- +# description: EAT2p0 project simulations 2023 +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# start MAgPIE runs +source("config/default.cfg") + +cfg$force_download <- FALSE + +#cfg$results_folder <- "output/:title:" +cfg$results_folder <- "output/:title::date:" + + +######################### +# 1 Baseline BAU_RCP4.5 # +######################### +# SSP: SSP2 +# Diet: BAU-SSP2 +# Waste: BAU-SSP2 +# Crop and Livestock productivity: BAU-SSP2 +# Mitigation policies: current policies +# Land-use policies: current policies +# RCP/GCM: tba +# Trade: BAU-SSP2 +cfg$title <- "BAU_RCP4p5" +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +start_run(cfg, codeCheck = FALSE) + +######################### +# 2 Baseline PHD_RCP4.5 # +######################### +# SSP: SSP2 +# Diet: EL2p0 +# Waste: half +# Crop and Livestock productivity: high (SSP1?) +# Mitigation policies: current policies +# Land-use policies: current policies +# RCP/GCM: tba +# Trade: BAU-SSP2 +cfg$title <- "PHD_RCP4p5" +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +# Diets: exogenous EATLancet diet +cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +# Waste: half food waste +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +start_run(cfg, codeCheck = FALSE) + +######################### +# 3 Baseline PHD_MIT1p9 # +######################### +# SSP: SSP2 +# Diet: EL2p0 +# Waste: half +# Crop and Livestock productivity: high (SSP1?) +# Mitigation policies: 1.5 degrees +# Land-use policies: 1.5 degrees +# RCP/GCM: tba +# Trade: BAU-SSP2 +cfg$title <- "PHD_MIT1p9" +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +# Diets: exogenous EATLancet diet +cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +# Waste: half food waste +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +# Mitigation +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" +cfg$gms$c56_emis_policy <- "sdp_all" +start_run(cfg, codeCheck = FALSE) From 00027d3ccb7869b487be326cd61c3b125f45a40b Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 Nov 2023 14:02:46 +0100 Subject: [PATCH 006/187] area-based bioenergy policy --- modules/30_crop/endo_apr21/declarations.gms | 4 ++++ modules/30_crop/endo_apr21/equations.gms | 5 +++++ modules/30_crop/endo_apr21/input.gms | 2 ++ modules/30_crop/endo_apr21/postsolve.gms | 5 +++++ modules/30_crop/endo_apr21/preloop.gms | 2 ++ modules/30_crop/endo_apr21/presolve.gms | 6 ++++++ 6 files changed, 24 insertions(+) diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index 628262432a..2bc9a1de29 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -13,6 +13,8 @@ parameters i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based bioenergy constraint (mio. ha) + p30_bioen_pol Area-based 2nd gen bioenergy policy (1) ; positive variables @@ -32,6 +34,7 @@ equations q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_bioen(j) Land constraint for bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -48,6 +51,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index da0f4ce868..5a2b9c1a91 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -71,3 +71,8 @@ =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + +*' Area-based constraint for 2nd gen. bioenergy, depending on `s30_bioen_pol`. +*' Available area for the cultivation of begr and betr can be limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. + q30_land_bioen(j2)$(s30_bioen_pol = 1) .. + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index db30cd69a8..8dbb19c42d 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,6 +27,8 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / +s30_bioen_pol Area-based 2nd gen bioenergy policy (0 = off 1 = on) / 1 / +s30_bioen_pol_ref_year Reference year for bioenergy policy / 2020 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_crop/endo_apr21/postsolve.gms index 33550027e2..87f98d6c2e 100644 --- a/modules/30_crop/endo_apr21/postsolve.gms +++ b/modules/30_crop/endo_apr21/postsolve.gms @@ -5,6 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +p30_bioen_pol_ref_area(j)$(sum(ct, m_year(ct)) = s30_bioen_pol_ref_year) = pcm_land(j,"crop"); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); @@ -19,6 +20,7 @@ oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); + oq30_land_bioen(t,j,"marginal") = q30_land_bioen.m(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); @@ -31,6 +33,7 @@ oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); + oq30_land_bioen(t,j,"level") = q30_land_bioen.l(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); @@ -43,6 +46,7 @@ oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); + oq30_land_bioen(t,j,"upper") = q30_land_bioen.up(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); @@ -55,4 +59,5 @@ oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); + oq30_land_bioen(t,j,"lower") = q30_land_bioen.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index 695f756062..d33724c1bd 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -25,3 +25,5 @@ p30_country_dummy(policy_countries30) = 1; * Countries are weighted by available cropland area. i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); + +p30_bioen_pol_ref_area(j) = 0; diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index efcc51f181..7c9445eb1a 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -36,3 +36,9 @@ p30_snv_shr(t,j) = p30_snv_scenario_fader(t) * *' Area potentially available for cropping p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); *' @stop + +if(sum(ct, m_year(ct)) <= s30_bioen_pol_ref_year, + p30_bioen_pol = 0; +else + p30_bioen_pol = s30_bioen_pol; +); From 565480a6936e38abc69682dd847d1aec1b52695d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:28:37 +0100 Subject: [PATCH 007/187] Update modules/30_crop/endo_apr21/declarations.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/declarations.gms | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index 2bc9a1de29..ef24f6092a 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -14,7 +14,6 @@ parameters p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based bioenergy constraint (mio. ha) - p30_bioen_pol Area-based 2nd gen bioenergy policy (1) ; positive variables From c0aba67cc79b83fdf1f6a0ad47762bef8ef243a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:28:44 +0100 Subject: [PATCH 008/187] Update modules/30_crop/endo_apr21/equations.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/equations.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index 5a2b9c1a91..ab5fbc364b 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -74,5 +74,5 @@ *' Area-based constraint for 2nd gen. bioenergy, depending on `s30_bioen_pol`. *' Available area for the cultivation of begr and betr can be limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. - q30_land_bioen(j2)$(s30_bioen_pol = 1) .. + q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); From 8150445eb839e578d1a5c38656fe6a8f90376a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:30:05 +0100 Subject: [PATCH 009/187] Update modules/30_crop/endo_apr21/equations.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/equations.gms | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index ab5fbc364b..a7bf9fe686 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -72,7 +72,6 @@ (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); -*' Area-based constraint for 2nd gen. bioenergy, depending on `s30_bioen_pol`. -*' Available area for the cultivation of begr and betr can be limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. +*' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); From 5c2608eb6fb46cc430764df41e9b29ce2bfb2c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:30:12 +0100 Subject: [PATCH 010/187] Update modules/30_crop/endo_apr21/input.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/input.gms | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 8dbb19c42d..ab2fa77efd 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,7 +27,6 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_bioen_pol Area-based 2nd gen bioenergy policy (0 = off 1 = on) / 1 / s30_bioen_pol_ref_year Reference year for bioenergy policy / 2020 / ; From 291a89ea57e7b457ae3557fa4c14d877bc3a8d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:30:23 +0100 Subject: [PATCH 011/187] Update modules/30_crop/endo_apr21/input.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/input.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index ab2fa77efd..550ffab863 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,7 +27,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_bioen_pol_ref_year Reference year for bioenergy policy / 2020 / +s30_bioen_pol_ref_year Reference year for bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy From 12791f23c0b66f0c94bd4c45d07bc20b5f2b63cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:33:05 +0100 Subject: [PATCH 012/187] Update modules/30_crop/endo_apr21/presolve.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/presolve.gms | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index 7c9445eb1a..efcc51f181 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -36,9 +36,3 @@ p30_snv_shr(t,j) = p30_snv_scenario_fader(t) * *' Area potentially available for cropping p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); *' @stop - -if(sum(ct, m_year(ct)) <= s30_bioen_pol_ref_year, - p30_bioen_pol = 0; -else - p30_bioen_pol = s30_bioen_pol; -); From c97f4d5164939168a478bf4f27c453c32eb4abfc Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 Nov 2023 09:59:39 +0100 Subject: [PATCH 013/187] area-based bioenergy policy#2 --- CHANGELOG.md | 1 + config/default.cfg | 6 ++++++ modules/30_crop/endo_apr21/declarations.gms | 6 +++--- modules/30_crop/endo_apr21/input.gms | 2 +- modules/30_crop/penalty_apr22/declarations.gms | 5 ++++- modules/30_crop/penalty_apr22/equations.gms | 4 ++++ modules/30_crop/penalty_apr22/input.gms | 1 + modules/30_crop/penalty_apr22/postsolve.gms | 5 +++++ modules/30_crop/penalty_apr22/preloop.gms | 2 ++ modules/30_crop/rotation_apr22/declarations.gms | 5 ++++- modules/30_crop/rotation_apr22/equations.gms | 4 ++++ modules/30_crop/rotation_apr22/input.gms | 1 + modules/30_crop/rotation_apr22/postsolve.gms | 5 +++++ modules/30_crop/rotation_apr22/preloop.gms | 1 + 14 files changed, 42 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa24e5da3b..4637679499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors - **32_forestry** new interface `vm_land_forestry` +- **30_crop** Added option for area-based bioenergy constraint (`s30_bioen_pol_ref_year`) in all realizations. Available area for the cultivation of begr and betr can be limited to the cropland area of a given time step. ### removed - diff --git a/config/default.cfg b/config/default.cfg index ecb455b574..b0588aaccf 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -632,10 +632,16 @@ cfg$gms$ageclass <- "feb21" # def = feb21 # * (penalty_apr22): rotational and fallow constraints are incentivized via penalty payments. Dynamic cropland and detailed cropland availability data at grid cell level. # NOTE: It is recommended to recalibrate the model when changing this setting! cfg$gms$crop <- "endo_apr21" # def = endo_apr21 + # * (c30_bioen_type): switch for type of bioenergy crops; options: begr, betr, all cfg$gms$c30_bioen_type <- "all" # def = "all" # * (c30_bioen_water): switch for irrigation of bioenergy crops; options: rainfed, irrigated, all cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" +# * (s30_bioen_pol_ref_year) Area-based constraint for 2nd gen. bioenergy +# * The cultivation of begr and betr is limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. +# * Note: The default value of 2200 has no effect on the model results. Only values within the time step modelled (e.g. 2020) will have an effect. +cfg$gms$s30_bioen_pol_ref_year <- 2200 # def = 2200 + # * (c30_rotation_constraints): switch for rotational constraints: on, off cfg$gms$c30_rotation_constraints <- "on" # def = "on" # * (c30_rotation_scenario): scenarios for constraints. diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index ef24f6092a..03a1f924b4 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -13,7 +13,7 @@ parameters i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) - p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based bioenergy constraint (mio. ha) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based 2nd gen bioenergy constraint (mio. ha) ; positive variables @@ -33,7 +33,7 @@ equations q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) - q30_land_bioen(j) Land constraint for bioenergy (mio. ha) + q30_land_bioen(j) Land constraint for 2nd gen bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -50,7 +50,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) - oq30_land_bioen(t,j,type) Land constraint for bioenergy (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for 2nd gen bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 550ffab863..4502aec395 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,7 +27,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_bioen_pol_ref_year Reference year for bioenergy area constraint / 2200 / +s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/penalty_apr22/declarations.gms b/modules/30_crop/penalty_apr22/declarations.gms index 9f5120b9ca..d6519f63bc 100644 --- a/modules/30_crop/penalty_apr22/declarations.gms +++ b/modules/30_crop/penalty_apr22/declarations.gms @@ -14,6 +14,7 @@ parameters i30_rotation_incentives(t_all,rota30) Penalty for violating rotational constraints (USD05MER per ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based 2nd gen bioenergy constraint (mio. ha) ; positive variables @@ -36,7 +37,8 @@ equations q30_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) - q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_bioen(j) Land constraint for 2nd gen bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -57,6 +59,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for 2nd gen bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index bb649fa47f..d4c6c17211 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -102,3 +102,7 @@ q30_rotation_penalty(i2) .. =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + +*' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. + q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/penalty_apr22/input.gms b/modules/30_crop/penalty_apr22/input.gms index 22bc0de7d0..9af0c1b428 100644 --- a/modules/30_crop/penalty_apr22/input.gms +++ b/modules/30_crop/penalty_apr22/input.gms @@ -33,6 +33,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / +s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/penalty_apr22/postsolve.gms b/modules/30_crop/penalty_apr22/postsolve.gms index 1f3170e857..07a8a3e92e 100644 --- a/modules/30_crop/penalty_apr22/postsolve.gms +++ b/modules/30_crop/penalty_apr22/postsolve.gms @@ -5,6 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +p30_bioen_pol_ref_area(j)$(sum(ct, m_year(ct)) = s30_bioen_pol_ref_year) = pcm_land(j,"crop"); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); @@ -23,6 +24,7 @@ oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); + oq30_land_bioen(t,j,"marginal") = q30_land_bioen.m(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); @@ -39,6 +41,7 @@ oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); + oq30_land_bioen(t,j,"level") = q30_land_bioen.l(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); @@ -55,6 +58,7 @@ oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); + oq30_land_bioen(t,j,"upper") = q30_land_bioen.up(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); @@ -71,4 +75,5 @@ oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); + oq30_land_bioen(t,j,"lower") = q30_land_bioen.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/penalty_apr22/preloop.gms b/modules/30_crop/penalty_apr22/preloop.gms index ee7f996e18..4456a3647e 100644 --- a/modules/30_crop/penalty_apr22/preloop.gms +++ b/modules/30_crop/penalty_apr22/preloop.gms @@ -32,3 +32,5 @@ p30_country_dummy(policy_countries30) = 1; * Countries are weighted by available cropland area. i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); + +p30_bioen_pol_ref_area(j) = 0; diff --git a/modules/30_crop/rotation_apr22/declarations.gms b/modules/30_crop/rotation_apr22/declarations.gms index 4fd7cb47e2..86705de389 100644 --- a/modules/30_crop/rotation_apr22/declarations.gms +++ b/modules/30_crop/rotation_apr22/declarations.gms @@ -15,6 +15,7 @@ parameters i30_rotation_min_shr(t_all,rotamin30) Minimum share of a certain crop group on cropland (ha per ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based 2nd gen bioenergy constraint (mio. ha) ; positive variables @@ -34,7 +35,8 @@ equations q30_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) - q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_bioen(j) Land constraint for 2nd gen bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -52,6 +54,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for 2nd gen bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index d3db06641a..725a864faa 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -83,3 +83,7 @@ =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + +*' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. + q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/rotation_apr22/input.gms b/modules/30_crop/rotation_apr22/input.gms index 38c2288b78..66a4482010 100644 --- a/modules/30_crop/rotation_apr22/input.gms +++ b/modules/30_crop/rotation_apr22/input.gms @@ -33,6 +33,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / +s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/rotation_apr22/postsolve.gms b/modules/30_crop/rotation_apr22/postsolve.gms index f0dddfe6f9..3cccea2b1d 100644 --- a/modules/30_crop/rotation_apr22/postsolve.gms +++ b/modules/30_crop/rotation_apr22/postsolve.gms @@ -5,6 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +p30_bioen_pol_ref_area(j)$(sum(ct, m_year(ct)) = s30_bioen_pol_ref_year) = pcm_land(j,"crop"); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); @@ -20,6 +21,7 @@ oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); + oq30_land_bioen(t,j,"marginal") = q30_land_bioen.m(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); @@ -33,6 +35,7 @@ oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); + oq30_land_bioen(t,j,"level") = q30_land_bioen.l(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); @@ -46,6 +49,7 @@ oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); + oq30_land_bioen(t,j,"upper") = q30_land_bioen.up(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); @@ -59,4 +63,5 @@ oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); + oq30_land_bioen(t,j,"lower") = q30_land_bioen.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/rotation_apr22/preloop.gms b/modules/30_crop/rotation_apr22/preloop.gms index feaa2aeed3..e7320f2e99 100644 --- a/modules/30_crop/rotation_apr22/preloop.gms +++ b/modules/30_crop/rotation_apr22/preloop.gms @@ -38,3 +38,4 @@ p30_country_dummy(policy_countries30) = 1; i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); +p30_bioen_pol_ref_area(j) = 0; From 1e08a9bc0baed8c2665f80d6db862b63768d2297 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 Nov 2023 09:39:20 +0100 Subject: [PATCH 014/187] area-based bioenergy policy#3 --- CHANGELOG.md | 2 +- config/default.cfg | 2 ++ modules/30_crop/endo_apr21/equations.gms | 2 +- modules/30_crop/endo_apr21/input.gms | 1 + modules/30_crop/penalty_apr22/equations.gms | 2 +- modules/30_crop/penalty_apr22/input.gms | 1 + modules/30_crop/rotation_apr22/equations.gms | 2 +- modules/30_crop/rotation_apr22/input.gms | 1 + 8 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4637679499..650916e0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors - **32_forestry** new interface `vm_land_forestry` -- **30_crop** Added option for area-based bioenergy constraint (`s30_bioen_pol_ref_year`) in all realizations. Available area for the cultivation of begr and betr can be limited to the cropland area of a given time step. +- **30_crop** Added option for area-based bioenergy constraint (`s30_bioen_pol_ref_year`) in all realizations. Available area for the cultivation of begr and betr can be limited to a share (`s30_bioen_pol_shr`) of the total cropland area in the reference year. ### removed - diff --git a/config/default.cfg b/config/default.cfg index b0588aaccf..6cbf5b5c5a 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -641,6 +641,8 @@ cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" # * The cultivation of begr and betr is limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. # * Note: The default value of 2200 has no effect on the model results. Only values within the time step modelled (e.g. 2020) will have an effect. cfg$gms$s30_bioen_pol_ref_year <- 2200 # def = 2200 +# * (s30_bioen_pol_shr): Share of total cropland area in reference year `s30_bioen_pol_ref_year` available for 2nd gen bioenergy +cfg$gms$s30_bioen_pol_shr <- 1 # def = 1 # * (c30_rotation_constraints): switch for rotational constraints: on, off cfg$gms$c30_rotation_constraints <- "on" # def = "on" diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index a7bf9fe686..f3d2aa403c 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -74,4 +74,4 @@ *' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. - sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= s30_bioen_pol_shr * p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 4502aec395..fd5720c47b 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -28,6 +28,7 @@ s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / +s30_bioen_pol_shr Share of total cropland area in reference year available for 2nd gen bioenergy / 1 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index d4c6c17211..a8a5a3c783 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -105,4 +105,4 @@ q30_rotation_penalty(i2) .. *' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. - sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= s30_bioen_pol_shr * p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/penalty_apr22/input.gms b/modules/30_crop/penalty_apr22/input.gms index 9af0c1b428..abd9940d06 100644 --- a/modules/30_crop/penalty_apr22/input.gms +++ b/modules/30_crop/penalty_apr22/input.gms @@ -34,6 +34,7 @@ s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / +s30_bioen_pol_shr Share of total cropland area in reference year available for 2nd gen bioenergy / 1 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index 725a864faa..2601d044d6 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -86,4 +86,4 @@ *' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. - sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= s30_bioen_pol_shr * p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/rotation_apr22/input.gms b/modules/30_crop/rotation_apr22/input.gms index 66a4482010..f50caf8f61 100644 --- a/modules/30_crop/rotation_apr22/input.gms +++ b/modules/30_crop/rotation_apr22/input.gms @@ -34,6 +34,7 @@ s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / +s30_bioen_pol_shr Share of total cropland area in reference year available for 2nd gen bioenergy / 1 / ; * Set-switch for countries affected by regional SNV policy From 9c35655ec44fc3132ec1901f72a4b7beb0e12880 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 Nov 2023 14:02:46 +0100 Subject: [PATCH 015/187] area-based bioenergy policy --- modules/30_crop/endo_apr21/declarations.gms | 4 ++++ modules/30_crop/endo_apr21/equations.gms | 5 +++++ modules/30_crop/endo_apr21/input.gms | 2 ++ modules/30_crop/endo_apr21/postsolve.gms | 5 +++++ modules/30_crop/endo_apr21/preloop.gms | 2 ++ modules/30_crop/endo_apr21/presolve.gms | 6 ++++++ 6 files changed, 24 insertions(+) diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index 628262432a..2bc9a1de29 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -13,6 +13,8 @@ parameters i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based bioenergy constraint (mio. ha) + p30_bioen_pol Area-based 2nd gen bioenergy policy (1) ; positive variables @@ -32,6 +34,7 @@ equations q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_bioen(j) Land constraint for bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -48,6 +51,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index da0f4ce868..5a2b9c1a91 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -71,3 +71,8 @@ =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + +*' Area-based constraint for 2nd gen. bioenergy, depending on `s30_bioen_pol`. +*' Available area for the cultivation of begr and betr can be limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. + q30_land_bioen(j2)$(s30_bioen_pol = 1) .. + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index db30cd69a8..8dbb19c42d 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,6 +27,8 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / +s30_bioen_pol Area-based 2nd gen bioenergy policy (0 = off 1 = on) / 1 / +s30_bioen_pol_ref_year Reference year for bioenergy policy / 2020 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_crop/endo_apr21/postsolve.gms index 33550027e2..87f98d6c2e 100644 --- a/modules/30_crop/endo_apr21/postsolve.gms +++ b/modules/30_crop/endo_apr21/postsolve.gms @@ -5,6 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +p30_bioen_pol_ref_area(j)$(sum(ct, m_year(ct)) = s30_bioen_pol_ref_year) = pcm_land(j,"crop"); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); @@ -19,6 +20,7 @@ oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); + oq30_land_bioen(t,j,"marginal") = q30_land_bioen.m(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); @@ -31,6 +33,7 @@ oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); + oq30_land_bioen(t,j,"level") = q30_land_bioen.l(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); @@ -43,6 +46,7 @@ oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); + oq30_land_bioen(t,j,"upper") = q30_land_bioen.up(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); @@ -55,4 +59,5 @@ oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); + oq30_land_bioen(t,j,"lower") = q30_land_bioen.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index 695f756062..d33724c1bd 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -25,3 +25,5 @@ p30_country_dummy(policy_countries30) = 1; * Countries are weighted by available cropland area. i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); + +p30_bioen_pol_ref_area(j) = 0; diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index efcc51f181..7c9445eb1a 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -36,3 +36,9 @@ p30_snv_shr(t,j) = p30_snv_scenario_fader(t) * *' Area potentially available for cropping p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); *' @stop + +if(sum(ct, m_year(ct)) <= s30_bioen_pol_ref_year, + p30_bioen_pol = 0; +else + p30_bioen_pol = s30_bioen_pol; +); From b37ac17cb5ef6b7ecb8691e98598476cef2cb776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:28:37 +0100 Subject: [PATCH 016/187] Update modules/30_crop/endo_apr21/declarations.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/declarations.gms | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index 2bc9a1de29..ef24f6092a 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -14,7 +14,6 @@ parameters p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based bioenergy constraint (mio. ha) - p30_bioen_pol Area-based 2nd gen bioenergy policy (1) ; positive variables From e284f1f3bdbd5cf63a244e50d9906386551af47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:28:44 +0100 Subject: [PATCH 017/187] Update modules/30_crop/endo_apr21/equations.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/equations.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index 5a2b9c1a91..ab5fbc364b 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -74,5 +74,5 @@ *' Area-based constraint for 2nd gen. bioenergy, depending on `s30_bioen_pol`. *' Available area for the cultivation of begr and betr can be limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. - q30_land_bioen(j2)$(s30_bioen_pol = 1) .. + q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); From 6386169cd87aa467095303fcbbbdcf00b125e2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:30:05 +0100 Subject: [PATCH 018/187] Update modules/30_crop/endo_apr21/equations.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/equations.gms | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index ab5fbc364b..a7bf9fe686 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -72,7 +72,6 @@ (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); -*' Area-based constraint for 2nd gen. bioenergy, depending on `s30_bioen_pol`. -*' Available area for the cultivation of begr and betr can be limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. +*' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); From 2ac8175a4b3f01b6d3e854a95776034b4c92d867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:30:12 +0100 Subject: [PATCH 019/187] Update modules/30_crop/endo_apr21/input.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/input.gms | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 8dbb19c42d..ab2fa77efd 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,7 +27,6 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_bioen_pol Area-based 2nd gen bioenergy policy (0 = off 1 = on) / 1 / s30_bioen_pol_ref_year Reference year for bioenergy policy / 2020 / ; From c9106d1924a0285d23f1d55404dbdad8f67637fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:30:23 +0100 Subject: [PATCH 020/187] Update modules/30_crop/endo_apr21/input.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/input.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index ab2fa77efd..550ffab863 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,7 +27,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_bioen_pol_ref_year Reference year for bioenergy policy / 2020 / +s30_bioen_pol_ref_year Reference year for bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy From 32313866c06d6549456467989a3f5b50f2f45680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 3 Nov 2023 09:33:05 +0100 Subject: [PATCH 021/187] Update modules/30_crop/endo_apr21/presolve.gms Co-authored-by: Jan Dietrich --- modules/30_crop/endo_apr21/presolve.gms | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index 7c9445eb1a..efcc51f181 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -36,9 +36,3 @@ p30_snv_shr(t,j) = p30_snv_scenario_fader(t) * *' Area potentially available for cropping p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); *' @stop - -if(sum(ct, m_year(ct)) <= s30_bioen_pol_ref_year, - p30_bioen_pol = 0; -else - p30_bioen_pol = s30_bioen_pol; -); From 6d6eb1a79e498d65d45dcd0fedf3d8f231bcb1ab Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 Nov 2023 09:59:39 +0100 Subject: [PATCH 022/187] area-based bioenergy policy#2 --- CHANGELOG.md | 1 + config/default.cfg | 6 ++++++ modules/30_crop/endo_apr21/declarations.gms | 6 +++--- modules/30_crop/endo_apr21/input.gms | 2 +- modules/30_crop/penalty_apr22/declarations.gms | 5 ++++- modules/30_crop/penalty_apr22/equations.gms | 4 ++++ modules/30_crop/penalty_apr22/input.gms | 1 + modules/30_crop/penalty_apr22/postsolve.gms | 5 +++++ modules/30_crop/penalty_apr22/preloop.gms | 2 ++ modules/30_crop/rotation_apr22/declarations.gms | 5 ++++- modules/30_crop/rotation_apr22/equations.gms | 4 ++++ modules/30_crop/rotation_apr22/input.gms | 1 + modules/30_crop/rotation_apr22/postsolve.gms | 5 +++++ modules/30_crop/rotation_apr22/preloop.gms | 1 + 14 files changed, 42 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa24e5da3b..4637679499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors - **32_forestry** new interface `vm_land_forestry` +- **30_crop** Added option for area-based bioenergy constraint (`s30_bioen_pol_ref_year`) in all realizations. Available area for the cultivation of begr and betr can be limited to the cropland area of a given time step. ### removed - diff --git a/config/default.cfg b/config/default.cfg index ecb455b574..b0588aaccf 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -632,10 +632,16 @@ cfg$gms$ageclass <- "feb21" # def = feb21 # * (penalty_apr22): rotational and fallow constraints are incentivized via penalty payments. Dynamic cropland and detailed cropland availability data at grid cell level. # NOTE: It is recommended to recalibrate the model when changing this setting! cfg$gms$crop <- "endo_apr21" # def = endo_apr21 + # * (c30_bioen_type): switch for type of bioenergy crops; options: begr, betr, all cfg$gms$c30_bioen_type <- "all" # def = "all" # * (c30_bioen_water): switch for irrigation of bioenergy crops; options: rainfed, irrigated, all cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" +# * (s30_bioen_pol_ref_year) Area-based constraint for 2nd gen. bioenergy +# * The cultivation of begr and betr is limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. +# * Note: The default value of 2200 has no effect on the model results. Only values within the time step modelled (e.g. 2020) will have an effect. +cfg$gms$s30_bioen_pol_ref_year <- 2200 # def = 2200 + # * (c30_rotation_constraints): switch for rotational constraints: on, off cfg$gms$c30_rotation_constraints <- "on" # def = "on" # * (c30_rotation_scenario): scenarios for constraints. diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index ef24f6092a..03a1f924b4 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -13,7 +13,7 @@ parameters i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) - p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based bioenergy constraint (mio. ha) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based 2nd gen bioenergy constraint (mio. ha) ; positive variables @@ -33,7 +33,7 @@ equations q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) - q30_land_bioen(j) Land constraint for bioenergy (mio. ha) + q30_land_bioen(j) Land constraint for 2nd gen bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -50,7 +50,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) - oq30_land_bioen(t,j,type) Land constraint for bioenergy (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for 2nd gen bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 550ffab863..4502aec395 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -27,7 +27,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_bioen_pol_ref_year Reference year for bioenergy area constraint / 2200 / +s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/penalty_apr22/declarations.gms b/modules/30_crop/penalty_apr22/declarations.gms index 9f5120b9ca..d6519f63bc 100644 --- a/modules/30_crop/penalty_apr22/declarations.gms +++ b/modules/30_crop/penalty_apr22/declarations.gms @@ -14,6 +14,7 @@ parameters i30_rotation_incentives(t_all,rota30) Penalty for violating rotational constraints (USD05MER per ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based 2nd gen bioenergy constraint (mio. ha) ; positive variables @@ -36,7 +37,8 @@ equations q30_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) - q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_bioen(j) Land constraint for 2nd gen bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -57,6 +59,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for 2nd gen bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index bb649fa47f..d4c6c17211 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -102,3 +102,7 @@ q30_rotation_penalty(i2) .. =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + +*' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. + q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/penalty_apr22/input.gms b/modules/30_crop/penalty_apr22/input.gms index 22bc0de7d0..9af0c1b428 100644 --- a/modules/30_crop/penalty_apr22/input.gms +++ b/modules/30_crop/penalty_apr22/input.gms @@ -33,6 +33,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / +s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/penalty_apr22/postsolve.gms b/modules/30_crop/penalty_apr22/postsolve.gms index 1f3170e857..07a8a3e92e 100644 --- a/modules/30_crop/penalty_apr22/postsolve.gms +++ b/modules/30_crop/penalty_apr22/postsolve.gms @@ -5,6 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +p30_bioen_pol_ref_area(j)$(sum(ct, m_year(ct)) = s30_bioen_pol_ref_year) = pcm_land(j,"crop"); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); @@ -23,6 +24,7 @@ oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); + oq30_land_bioen(t,j,"marginal") = q30_land_bioen.m(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); @@ -39,6 +41,7 @@ oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); + oq30_land_bioen(t,j,"level") = q30_land_bioen.l(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); @@ -55,6 +58,7 @@ oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); + oq30_land_bioen(t,j,"upper") = q30_land_bioen.up(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); @@ -71,4 +75,5 @@ oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); + oq30_land_bioen(t,j,"lower") = q30_land_bioen.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/penalty_apr22/preloop.gms b/modules/30_crop/penalty_apr22/preloop.gms index ee7f996e18..4456a3647e 100644 --- a/modules/30_crop/penalty_apr22/preloop.gms +++ b/modules/30_crop/penalty_apr22/preloop.gms @@ -32,3 +32,5 @@ p30_country_dummy(policy_countries30) = 1; * Countries are weighted by available cropland area. i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); + +p30_bioen_pol_ref_area(j) = 0; diff --git a/modules/30_crop/rotation_apr22/declarations.gms b/modules/30_crop/rotation_apr22/declarations.gms index 4fd7cb47e2..86705de389 100644 --- a/modules/30_crop/rotation_apr22/declarations.gms +++ b/modules/30_crop/rotation_apr22/declarations.gms @@ -15,6 +15,7 @@ parameters i30_rotation_min_shr(t_all,rotamin30) Minimum share of a certain crop group on cropland (ha per ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_bioen_pol_ref_area(j) Cropland area used as reference for area-based 2nd gen bioenergy constraint (mio. ha) ; positive variables @@ -34,7 +35,8 @@ equations q30_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) - q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q30_land_bioen(j) Land constraint for 2nd gen bioenergy (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -52,6 +54,7 @@ parameters oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq30_land_bioen(t,j,type) Land constraint for 2nd gen bioenergy (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index d3db06641a..725a864faa 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -83,3 +83,7 @@ =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + +*' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. + q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/rotation_apr22/input.gms b/modules/30_crop/rotation_apr22/input.gms index 38c2288b78..66a4482010 100644 --- a/modules/30_crop/rotation_apr22/input.gms +++ b/modules/30_crop/rotation_apr22/input.gms @@ -33,6 +33,7 @@ s30_snv_scenario_start SNV scenario start year / 2020 / s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / +s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/rotation_apr22/postsolve.gms b/modules/30_crop/rotation_apr22/postsolve.gms index f0dddfe6f9..3cccea2b1d 100644 --- a/modules/30_crop/rotation_apr22/postsolve.gms +++ b/modules/30_crop/rotation_apr22/postsolve.gms @@ -5,6 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +p30_bioen_pol_ref_area(j)$(sum(ct, m_year(ct)) = s30_bioen_pol_ref_year) = pcm_land(j,"crop"); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); @@ -20,6 +21,7 @@ oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); + oq30_land_bioen(t,j,"marginal") = q30_land_bioen.m(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); @@ -33,6 +35,7 @@ oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); + oq30_land_bioen(t,j,"level") = q30_land_bioen.l(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); @@ -46,6 +49,7 @@ oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); + oq30_land_bioen(t,j,"upper") = q30_land_bioen.up(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); @@ -59,4 +63,5 @@ oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); + oq30_land_bioen(t,j,"lower") = q30_land_bioen.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/rotation_apr22/preloop.gms b/modules/30_crop/rotation_apr22/preloop.gms index feaa2aeed3..e7320f2e99 100644 --- a/modules/30_crop/rotation_apr22/preloop.gms +++ b/modules/30_crop/rotation_apr22/preloop.gms @@ -38,3 +38,4 @@ p30_country_dummy(policy_countries30) = 1; i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); +p30_bioen_pol_ref_area(j) = 0; From c5991071b7c64fc2cfbb163f558aaa6dcb1587c2 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 Nov 2023 09:39:20 +0100 Subject: [PATCH 023/187] area-based bioenergy policy#3 --- CHANGELOG.md | 2 +- config/default.cfg | 2 ++ modules/30_crop/endo_apr21/equations.gms | 2 +- modules/30_crop/endo_apr21/input.gms | 1 + modules/30_crop/penalty_apr22/equations.gms | 2 +- modules/30_crop/penalty_apr22/input.gms | 1 + modules/30_crop/rotation_apr22/equations.gms | 2 +- modules/30_crop/rotation_apr22/input.gms | 1 + 8 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4637679499..650916e0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors - **32_forestry** new interface `vm_land_forestry` -- **30_crop** Added option for area-based bioenergy constraint (`s30_bioen_pol_ref_year`) in all realizations. Available area for the cultivation of begr and betr can be limited to the cropland area of a given time step. +- **30_crop** Added option for area-based bioenergy constraint (`s30_bioen_pol_ref_year`) in all realizations. Available area for the cultivation of begr and betr can be limited to a share (`s30_bioen_pol_shr`) of the total cropland area in the reference year. ### removed - diff --git a/config/default.cfg b/config/default.cfg index b0588aaccf..6cbf5b5c5a 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -641,6 +641,8 @@ cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" # * The cultivation of begr and betr is limited to the cropland area of the time step given by `s30_bioen_pol_ref_year`. # * Note: The default value of 2200 has no effect on the model results. Only values within the time step modelled (e.g. 2020) will have an effect. cfg$gms$s30_bioen_pol_ref_year <- 2200 # def = 2200 +# * (s30_bioen_pol_shr): Share of total cropland area in reference year `s30_bioen_pol_ref_year` available for 2nd gen bioenergy +cfg$gms$s30_bioen_pol_shr <- 1 # def = 1 # * (c30_rotation_constraints): switch for rotational constraints: on, off cfg$gms$c30_rotation_constraints <- "on" # def = "on" diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index a7bf9fe686..f3d2aa403c 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -74,4 +74,4 @@ *' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. - sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= s30_bioen_pol_shr * p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 4502aec395..fd5720c47b 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -28,6 +28,7 @@ s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / +s30_bioen_pol_shr Share of total cropland area in reference year available for 2nd gen bioenergy / 1 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index d4c6c17211..a8a5a3c783 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -105,4 +105,4 @@ q30_rotation_penalty(i2) .. *' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. - sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= s30_bioen_pol_shr * p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/penalty_apr22/input.gms b/modules/30_crop/penalty_apr22/input.gms index 9af0c1b428..abd9940d06 100644 --- a/modules/30_crop/penalty_apr22/input.gms +++ b/modules/30_crop/penalty_apr22/input.gms @@ -34,6 +34,7 @@ s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / +s30_bioen_pol_shr Share of total cropland area in reference year available for 2nd gen bioenergy / 1 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index 725a864faa..2601d044d6 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -86,4 +86,4 @@ *' Area-based constraint for 2nd gen. bioenergy, limiting the cultivation of begr and betr to the cropland area of the time step given by `s30_bioen_pol_ref_year`. q30_land_bioen(j2)$(sum(ct, m_year(ct)) > s30_bioen_pol_ref_year) .. - sum((kbe30,w), vm_area(j2,kbe30,w)) =l= p30_bioen_pol_ref_area(j2); + sum((kbe30,w), vm_area(j2,kbe30,w)) =l= s30_bioen_pol_shr * p30_bioen_pol_ref_area(j2); diff --git a/modules/30_crop/rotation_apr22/input.gms b/modules/30_crop/rotation_apr22/input.gms index 66a4482010..f50caf8f61 100644 --- a/modules/30_crop/rotation_apr22/input.gms +++ b/modules/30_crop/rotation_apr22/input.gms @@ -34,6 +34,7 @@ s30_snv_scenario_target SNV scenario target year / 2030 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_bioen_pol_ref_year Reference year for 2nd gen bioenergy area constraint / 2200 / +s30_bioen_pol_shr Share of total cropland area in reference year available for 2nd gen bioenergy / 1 / ; * Set-switch for countries affected by regional SNV policy From 02fc8d65f845337cd2423800ce21fddd73b5cc1e Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 7 Nov 2023 17:35:49 +0100 Subject: [PATCH 024/187] revision --- modules/58_peatland/v2/declarations.gms | 1 + modules/58_peatland/v2/equations.gms | 6 +++--- modules/58_peatland/v2/preloop.gms | 5 +++-- modules/58_peatland/v2/presolve.gms | 15 +++++++++++---- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index 79deb095b0..965de9d9f9 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -7,6 +7,7 @@ parameters p58_scaling_factor(j) Scaling factor for managed peatland (1) + p58_calib_factor(t,j,land58) Calibration factor for managed peatland (1) pc58_peatland(j,land58) Peatland area (mio. ha) p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index 93a71cee3a..287663ad61 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -33,17 +33,17 @@ q58_peatland_crop(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"crop") =e= pc58_peatland(j2,"crop") - + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2)); + + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2)*sum(ct, p58_calib_factor(ct,j2,"crop"))); q58_peatland_past(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"past") =e= pc58_peatland(j2,"past") - + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2)); + + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2)*sum(ct, p58_calib_factor(ct,j2,"past"))); q58_peatland_forestry(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"forestry") =e= pc58_peatland(j2,"forestry") - + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2)); + + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2)*sum(ct, p58_calib_factor(ct,j2,"forestry"))); *' This constraint avoids the conversion of intact peatland into rewetted peatland. *' In each cluster, rewetted peatland area can only increase if no intact peatland area is lost. diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms index 2b06e06be0..b37452bd3b 100644 --- a/modules/58_peatland/v2/preloop.gms +++ b/modules/58_peatland/v2/preloop.gms @@ -11,8 +11,9 @@ vm_emissions_reg.up(i,"peatland",poll58) = Inf; p58_mapping_cell_climate(j,clcl58) = sum(clcl_mapping(clcl,clcl58),pm_climate_class(j,clcl)); -* Peatland scaling factor: ratio of total peatland area and total land area -p58_scaling_factor(j)$(sum(land, pcm_land(j,land)) > 1e-20) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); +* Initialization of peatland scaling factor and peatland calibration factor +p58_scaling_factor(j) = 1; +p58_calib_factor(t,j,land58) = 1; * Initialization of peatland area pc58_peatland(j,land58) = 0; diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index bb84a16ec5..d801382aa5 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -10,11 +10,18 @@ if (m_year(t) <= s58_fix_peatland, * For initialization, degraded peatland is estimated by multiplication of managed land (cropland, pasture, forestry) with the peatland scaling factor (p58_scaling_factor) * and simultaneously constrained by observed degraded peatland area (f58_peatland_area). p58_scaling_factor(j)$(sum(land, pcm_land(j,land)) > 1e-20) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); - pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop") * p58_scaling_factor(j)); - pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past") * p58_scaling_factor(j)); - pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); + p58_calib_factor(t,j,"crop")$(pcm_land(j,"crop") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"crop") / (pcm_land(j,"crop") * p58_scaling_factor(j)); + p58_calib_factor(t,j,"past")$(pcm_land(j,"past") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"past") / (pcm_land(j,"past") * p58_scaling_factor(j)); + p58_calib_factor(t,j,"forestry")$(pcm_land_forestry(j,"plant") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"forestry") / (pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); +* pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop") * p58_scaling_factor(j)); +* pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past") * p58_scaling_factor(j)); +* pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); + pc58_peatland(j,"crop") = f58_peatland_area(j,"crop"); + pc58_peatland(j,"past") = f58_peatland_area(j,"past"); + pc58_peatland(j,"forestry") = f58_peatland_area(j,"forestry"); + pc58_peatland(j,"unused") = 0; * The residual is added to an "unused" category, which represents degraded but unused peatland. - pc58_peatland(j,"unused") = sum(landDrainedUsed58, f58_peatland_area(j,landDrainedUsed58) - pc58_peatland(j,landDrainedUsed58)); +* pc58_peatland(j,"unused") = sum(landDrainedUsed58, f58_peatland_area(j,landDrainedUsed58) - pc58_peatland(j,landDrainedUsed58)); * Area used for peat extraction pc58_peatland(j,"peatExtract") = f58_peatland_area(j,"peatExtract"); * Intact peatland area From 0bcb81f58644b48d507385a161b742abd2f9d26f Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 7 Nov 2023 17:52:29 +0100 Subject: [PATCH 025/187] revision2 --- modules/58_peatland/v2/declarations.gms | 2 +- modules/58_peatland/v2/equations.gms | 6 +++--- modules/58_peatland/v2/preloop.gms | 2 +- modules/58_peatland/v2/presolve.gms | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index 965de9d9f9..f1b9764492 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -7,7 +7,7 @@ parameters p58_scaling_factor(j) Scaling factor for managed peatland (1) - p58_calib_factor(t,j,land58) Calibration factor for managed peatland (1) + p58_calib_factor(j,land58) Calibration factor for managed peatland (1) pc58_peatland(j,land58) Peatland area (mio. ha) p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index 287663ad61..c2b9b9751a 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -33,17 +33,17 @@ q58_peatland_crop(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"crop") =e= pc58_peatland(j2,"crop") - + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2)*sum(ct, p58_calib_factor(ct,j2,"crop"))); + + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2)*p58_calib_factor(j2,"crop")); q58_peatland_past(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"past") =e= pc58_peatland(j2,"past") - + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2)*sum(ct, p58_calib_factor(ct,j2,"past"))); + + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2)*p58_calib_factor(j2,"past")); q58_peatland_forestry(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"forestry") =e= pc58_peatland(j2,"forestry") - + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2)*sum(ct, p58_calib_factor(ct,j2,"forestry"))); + + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2)*p58_calib_factor(j2,"forestry")); *' This constraint avoids the conversion of intact peatland into rewetted peatland. *' In each cluster, rewetted peatland area can only increase if no intact peatland area is lost. diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms index b37452bd3b..f5944038b4 100644 --- a/modules/58_peatland/v2/preloop.gms +++ b/modules/58_peatland/v2/preloop.gms @@ -13,7 +13,7 @@ p58_mapping_cell_climate(j,clcl58) = sum(clcl_mapping(clcl,clcl58),pm_climate_cl * Initialization of peatland scaling factor and peatland calibration factor p58_scaling_factor(j) = 1; -p58_calib_factor(t,j,land58) = 1; +p58_calib_factor(j,land58) = 1; * Initialization of peatland area pc58_peatland(j,land58) = 0; diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index d801382aa5..01d348f9c1 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -10,9 +10,9 @@ if (m_year(t) <= s58_fix_peatland, * For initialization, degraded peatland is estimated by multiplication of managed land (cropland, pasture, forestry) with the peatland scaling factor (p58_scaling_factor) * and simultaneously constrained by observed degraded peatland area (f58_peatland_area). p58_scaling_factor(j)$(sum(land, pcm_land(j,land)) > 1e-20) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); - p58_calib_factor(t,j,"crop")$(pcm_land(j,"crop") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"crop") / (pcm_land(j,"crop") * p58_scaling_factor(j)); - p58_calib_factor(t,j,"past")$(pcm_land(j,"past") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"past") / (pcm_land(j,"past") * p58_scaling_factor(j)); - p58_calib_factor(t,j,"forestry")$(pcm_land_forestry(j,"plant") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"forestry") / (pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); + p58_calib_factor(j,"crop")$(pcm_land(j,"crop") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"crop") / (pcm_land(j,"crop") * p58_scaling_factor(j)); + p58_calib_factor(j,"past")$(pcm_land(j,"past") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"past") / (pcm_land(j,"past") * p58_scaling_factor(j)); + p58_calib_factor(j,"forestry")$(pcm_land_forestry(j,"plant") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"forestry") / (pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); * pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop") * p58_scaling_factor(j)); * pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past") * p58_scaling_factor(j)); * pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); From fa8be1362aa5d3b861ae134808c83450f4e533ee Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 8 Nov 2023 12:15:08 +0100 Subject: [PATCH 026/187] revision3 --- modules/58_peatland/v2/presolve.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index 01d348f9c1..893052fa62 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -10,9 +10,9 @@ if (m_year(t) <= s58_fix_peatland, * For initialization, degraded peatland is estimated by multiplication of managed land (cropland, pasture, forestry) with the peatland scaling factor (p58_scaling_factor) * and simultaneously constrained by observed degraded peatland area (f58_peatland_area). p58_scaling_factor(j)$(sum(land, pcm_land(j,land)) > 1e-20) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); - p58_calib_factor(j,"crop")$(pcm_land(j,"crop") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"crop") / (pcm_land(j,"crop") * p58_scaling_factor(j)); - p58_calib_factor(j,"past")$(pcm_land(j,"past") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"past") / (pcm_land(j,"past") * p58_scaling_factor(j)); - p58_calib_factor(j,"forestry")$(pcm_land_forestry(j,"plant") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"forestry") / (pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); +* p58_calib_factor(j,"crop")$(pcm_land(j,"crop") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"crop") / (pcm_land(j,"crop") * p58_scaling_factor(j)); +* p58_calib_factor(j,"past")$(pcm_land(j,"past") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"past") / (pcm_land(j,"past") * p58_scaling_factor(j)); +* p58_calib_factor(j,"forestry")$(pcm_land_forestry(j,"plant") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"forestry") / (pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); * pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop") * p58_scaling_factor(j)); * pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past") * p58_scaling_factor(j)); * pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); From 8f0e77801298d35d953a8de2f58f3b9700fbe2a2 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 10 Nov 2023 20:13:08 +0100 Subject: [PATCH 027/187] revision4 --- modules/58_peatland/v2/declarations.gms | 5 +---- modules/58_peatland/v2/equations.gms | 17 +++++--------- modules/58_peatland/v2/postsolve.gms | 4 ---- modules/58_peatland/v2/preloop.gms | 8 +++---- modules/58_peatland/v2/presolve.gms | 30 ++++++++++++------------- modules/58_peatland/v2/realization.gms | 6 ++--- 6 files changed, 28 insertions(+), 42 deletions(-) diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index f1b9764492..bc72f37bae 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -6,8 +6,7 @@ *** | Contact: magpie@pik-potsdam.de parameters - p58_scaling_factor(j) Scaling factor for managed peatland (1) - p58_calib_factor(j,land58) Calibration factor for managed peatland (1) + p58_scaling_factor(j,landDrainedUsed58) Scaling factor for managed peatland (1) pc58_peatland(j,land58) Peatland area (mio. ha) p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) @@ -20,7 +19,6 @@ equations q58_peatland(j) Constraint for peatland area (mio. ha) q58_expansion(j,land58) Peatland expansion (mio. ha) q58_reduction(j,land58) Peatland reduction (mio. ha) - q58_peatland_rewet(j) Constraint for peatland rewetting (mio. ha) q58_peatland_crop(j) Degraded peatland used as cropland (mio. ha) q58_peatland_past(j) Degraded peatland used as pasture (mio. ha) q58_peatland_forestry(j) Degraded peatland used for forestry (mio. ha) @@ -56,7 +54,6 @@ parameters oq58_peatland(t,j,type) Constraint for peatland area (mio. ha) oq58_expansion(t,j,land58,type) Peatland expansion (mio. ha) oq58_reduction(t,j,land58,type) Peatland reduction (mio. ha) - oq58_peatland_rewet(t,j,type) Constraint for peatland rewetting (mio. ha) oq58_peatland_crop(t,j,type) Degraded peatland used as cropland (mio. ha) oq58_peatland_past(t,j,type) Degraded peatland used as pasture (mio. ha) oq58_peatland_forestry(t,j,type) Degraded peatland used for forestry (mio. ha) diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index c2b9b9751a..dd375bdd17 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -20,8 +20,8 @@ q58_reduction(j2,land58) .. v58_reduction(j2,land58) =g= pc58_peatland(j2,land58)-v58_peatland(j2,land58); -*' Future peatland degradation (`v58_peatland`) depends on managed land (`vm_land`, `vm_land_forestry`), -*' scaled with the ratio of total peatland area and total land area (`p58_scaling_factor`). +*' Future peatland dynamics (`v58_peatland`) depend on managed land (`vm_land`, `vm_land_forestry`), +*' multiplied with the peatland scaling factor (`p58_scaling_factor`). *' By multiplying changes in managed land with the scaling factor we implicitly assume *' that intact peatlands are distributed equally within a grid cell. *' The following example illustrates the mechanism used for projecting peatland dynamics: @@ -33,24 +33,17 @@ q58_peatland_crop(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"crop") =e= pc58_peatland(j2,"crop") - + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2)*p58_calib_factor(j2,"crop")); + + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2,"crop")); q58_peatland_past(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"past") =e= pc58_peatland(j2,"past") - + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2)*p58_calib_factor(j2,"past")); + + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2,"past")); q58_peatland_forestry(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"forestry") =e= pc58_peatland(j2,"forestry") - + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2)*p58_calib_factor(j2,"forestry")); - -*' This constraint avoids the conversion of intact peatland into rewetted peatland. -*' In each cluster, rewetted peatland area can only increase if no intact peatland area is lost. -*' Therefore, rewetted peatland area can only increase if degraded peatland area (`landDrained58`) declines. - - q58_peatland_rewet(j2) .. - v58_expansion(j2,"rewetted") * v58_reduction(j2,"intact") =e= 0; + + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2,"forestry")); *' Costs for peatland degradation and rewetting diff --git a/modules/58_peatland/v2/postsolve.gms b/modules/58_peatland/v2/postsolve.gms index a8ac15872b..7ad8b0489d 100644 --- a/modules/58_peatland/v2/postsolve.gms +++ b/modules/58_peatland/v2/postsolve.gms @@ -18,7 +18,6 @@ pc58_peatland(j,land58) = v58_peatland.l(j,land58); oq58_peatland(t,j,"marginal") = q58_peatland.m(j); oq58_expansion(t,j,land58,"marginal") = q58_expansion.m(j,land58); oq58_reduction(t,j,land58,"marginal") = q58_reduction.m(j,land58); - oq58_peatland_rewet(t,j,"marginal") = q58_peatland_rewet.m(j); oq58_peatland_crop(t,j,"marginal") = q58_peatland_crop.m(j); oq58_peatland_past(t,j,"marginal") = q58_peatland_past.m(j); oq58_peatland_forestry(t,j,"marginal") = q58_peatland_forestry.m(j); @@ -37,7 +36,6 @@ pc58_peatland(j,land58) = v58_peatland.l(j,land58); oq58_peatland(t,j,"level") = q58_peatland.l(j); oq58_expansion(t,j,land58,"level") = q58_expansion.l(j,land58); oq58_reduction(t,j,land58,"level") = q58_reduction.l(j,land58); - oq58_peatland_rewet(t,j,"level") = q58_peatland_rewet.l(j); oq58_peatland_crop(t,j,"level") = q58_peatland_crop.l(j); oq58_peatland_past(t,j,"level") = q58_peatland_past.l(j); oq58_peatland_forestry(t,j,"level") = q58_peatland_forestry.l(j); @@ -56,7 +54,6 @@ pc58_peatland(j,land58) = v58_peatland.l(j,land58); oq58_peatland(t,j,"upper") = q58_peatland.up(j); oq58_expansion(t,j,land58,"upper") = q58_expansion.up(j,land58); oq58_reduction(t,j,land58,"upper") = q58_reduction.up(j,land58); - oq58_peatland_rewet(t,j,"upper") = q58_peatland_rewet.up(j); oq58_peatland_crop(t,j,"upper") = q58_peatland_crop.up(j); oq58_peatland_past(t,j,"upper") = q58_peatland_past.up(j); oq58_peatland_forestry(t,j,"upper") = q58_peatland_forestry.up(j); @@ -75,7 +72,6 @@ pc58_peatland(j,land58) = v58_peatland.l(j,land58); oq58_peatland(t,j,"lower") = q58_peatland.lo(j); oq58_expansion(t,j,land58,"lower") = q58_expansion.lo(j,land58); oq58_reduction(t,j,land58,"lower") = q58_reduction.lo(j,land58); - oq58_peatland_rewet(t,j,"lower") = q58_peatland_rewet.lo(j); oq58_peatland_crop(t,j,"lower") = q58_peatland_crop.lo(j); oq58_peatland_past(t,j,"lower") = q58_peatland_past.lo(j); oq58_peatland_forestry(t,j,"lower") = q58_peatland_forestry.lo(j); diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms index f5944038b4..9f78fafd1f 100644 --- a/modules/58_peatland/v2/preloop.gms +++ b/modules/58_peatland/v2/preloop.gms @@ -11,9 +11,9 @@ vm_emissions_reg.up(i,"peatland",poll58) = Inf; p58_mapping_cell_climate(j,clcl58) = sum(clcl_mapping(clcl,clcl58),pm_climate_class(j,clcl)); -* Initialization of peatland scaling factor and peatland calibration factor -p58_scaling_factor(j) = 1; -p58_calib_factor(j,land58) = 1; - * Initialization of peatland area pc58_peatland(j,land58) = 0; + +* For the internal GHG emission pricing it is assumed that intact peatlands have the same emission factors as rewetted peatlands. +* Without this assumption, GHG emissions of intact peatlands would be zero (no data available). This can lead to cases where intact peatland is converted to rewetted peatland. +f58_ipcc_wetland_ef(clcl58,"intact",emis58) = f58_ipcc_wetland_ef(clcl58,"rewetted",emis58); diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index 893052fa62..2e44a82e9d 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -7,26 +7,26 @@ if (m_year(t) <= s58_fix_peatland, -* For initialization, degraded peatland is estimated by multiplication of managed land (cropland, pasture, forestry) with the peatland scaling factor (p58_scaling_factor) -* and simultaneously constrained by observed degraded peatland area (f58_peatland_area). - p58_scaling_factor(j)$(sum(land, pcm_land(j,land)) > 1e-20) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); -* p58_calib_factor(j,"crop")$(pcm_land(j,"crop") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"crop") / (pcm_land(j,"crop") * p58_scaling_factor(j)); -* p58_calib_factor(j,"past")$(pcm_land(j,"past") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"past") / (pcm_land(j,"past") * p58_scaling_factor(j)); -* p58_calib_factor(j,"forestry")$(pcm_land_forestry(j,"plant") * p58_scaling_factor(j) > 1e-20) = f58_peatland_area(j,"forestry") / (pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); -* pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop") * p58_scaling_factor(j)); -* pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past") * p58_scaling_factor(j)); -* pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); - pc58_peatland(j,"crop") = f58_peatland_area(j,"crop"); - pc58_peatland(j,"past") = f58_peatland_area(j,"past"); - pc58_peatland(j,"forestry") = f58_peatland_area(j,"forestry"); - pc58_peatland(j,"unused") = 0; -* The residual is added to an "unused" category, which represents degraded but unused peatland. -* pc58_peatland(j,"unused") = sum(landDrainedUsed58, f58_peatland_area(j,landDrainedUsed58) - pc58_peatland(j,landDrainedUsed58)); +* Initialization of peatland area. Drained and used peatland area cannot exceed the corresponding managed area + pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop")); + pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past")); + pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant")); +* The residual is added to an "unused" category, which represents drained but unused peatland. + pc58_peatland(j,"unused") = sum(landDrainedUsed58, f58_peatland_area(j,landDrainedUsed58) - pc58_peatland(j,landDrainedUsed58)); * Area used for peat extraction pc58_peatland(j,"peatExtract") = f58_peatland_area(j,"peatExtract"); * Intact peatland area pc58_peatland(j,"intact") = f58_peatland_area(j,"intact"); +* Peatland scaling factor for estimating future peatland dynamics +* The peatland scaling factor for cells with drained peatland area depends on the ratio of drained peatland and managed land (remains fixed after s58_fix_peatland) + p58_scaling_factor(j,landDrainedUsed58) = 0; + p58_scaling_factor(j,"crop")$(pcm_land(j,"crop") > 1e-20) = pc58_peatland(j,"crop") / pcm_land(j,"crop"); + p58_scaling_factor(j,"past")$(pcm_land(j,"past") > 1e-20) = pc58_peatland(j,"past") / pcm_land(j,"past"); + p58_scaling_factor(j,"forestry")$(pcm_land_forestry(j,"plant") > 1e-20) = pc58_peatland(j,"forestry") / pcm_land_forestry(j,"plant"); +* The peatland scaling factor for cells without drained peatland area depends on the ratio of total peatland area and total land area (remains fixed after s58_fix_peatland). + p58_scaling_factor(j,landDrainedUsed58)$(pc58_peatland(j,landDrainedUsed58) = 0) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); + * Peatland area is fixed to `pc58_peatland` until the year given by s58_fix_peatland v58_peatland.fx(j,land58) = pc58_peatland(j,land58); i58_cost_rewet_recur(t) = 0; diff --git a/modules/58_peatland/v2/realization.gms b/modules/58_peatland/v2/realization.gms index 1a521c029c..f67915a788 100644 --- a/modules/58_peatland/v2/realization.gms +++ b/modules/58_peatland/v2/realization.gms @@ -9,9 +9,9 @@ *' methodology described in @humpenoder_peatland_2020. *' The initial map for intact, degraded and rewetted peatland is based on the *' [Global Peatland Map 2.0](https://globalpeatlands.org/resource-library/global-peatland-map-20) -*' and the [Global Peatland Database](https://greifswaldmoor.de/global-peatland-database-en.html), both for the year 2020. +*' and the [Global Peatland Database](https://greifswaldmoor.de/global-peatland-database-en.html), both for the year 2022. *' Therefore, it is advised to set `s58_fix_peatland` to `2020` when using this realisation. -*' Future peatland dynamics are estimated by scaling changes in managed land with the ratio of total peatland area and total land area (peatland scaling factor). +*' Future peatland dynamics are estimated by multiplying changes in managed land with a peatland scaling factor. *' GHG emissions from drained and rewetted peatlands as well as from peat extraction are calculated based on GHG emission factors. *' In this realisation, peatland GHG emission factors for boreal and tropical climates are based on @IPCC_wetland_2013 and @wilson_2016. *' Peatland GHG emission factors for temperate climates are based on more recent estimates from @tiemeyer_peatland_2020. @@ -20,7 +20,7 @@ *' Intact peatland area can only decrease. *' Degraded peatland area (crop, past, forestry and unused) depends on managed land. *' Area for peat extraction (peatExtract) is fixed. -*' Rewetted peatland area can only increase if degraded peatland area declines and intact peatland area remains constant. +*' Rewetted and intact peatland have the same GHG emission factors, which avoids that intact is converted to rewetted peatland area. *' @stop From 0562bf3e6fa9765a406b5f708c9f40812329d19e Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 10 Nov 2023 20:56:11 +0100 Subject: [PATCH 028/187] revision5 --- modules/58_peatland/v2/input.gms | 3 +-- modules/58_peatland/v2/preloop.gms | 2 +- scripts/output/extra/disaggregation.R | 28 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/modules/58_peatland/v2/input.gms b/modules/58_peatland/v2/input.gms index 3dfd0ee85b..d0f3ac08c9 100644 --- a/modules/58_peatland/v2/input.gms +++ b/modules/58_peatland/v2/input.gms @@ -11,8 +11,7 @@ scalars s58_cost_degrad_recur Recurring costs for degraded peatland (USD05MER per ha) / 0 / s58_cost_degrad_onetime One-time costs for peatland degradation (USD05MER per ha) / 0 / s58_rewetting_switch Peatland rewetting on (Inf) or off (0) / Inf / - s58_fix_peatland Year indicating until when peatland area should be fixed to 2020 levels (year) / 2015 / - s58_cost_balance Artificial cost for balance variable (USD05MER per ha) / 1e+06 / + s58_fix_peatland Year indicating until when peatland area should be fixed (year) / 2015 / ; *Peatland area based on Global Peatland Map 2.0 and Global Peatland Database diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms index 9f78fafd1f..ac58258d2b 100644 --- a/modules/58_peatland/v2/preloop.gms +++ b/modules/58_peatland/v2/preloop.gms @@ -14,6 +14,6 @@ p58_mapping_cell_climate(j,clcl58) = sum(clcl_mapping(clcl,clcl58),pm_climate_cl * Initialization of peatland area pc58_peatland(j,land58) = 0; -* For the internal GHG emission pricing it is assumed that intact peatlands have the same emission factors as rewetted peatlands. +* For the internal GHG emission pricing it is assumed that intact peatlands have the same GHG emission factors as rewetted peatlands. * Without this assumption, GHG emissions of intact peatlands would be zero (no data available). This can lead to cases where intact peatland is converted to rewetted peatland. f58_ipcc_wetland_ef(clcl58,"intact",emis58) = f58_ipcc_wetland_ef(clcl58,"rewetted",emis58); diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index ae5adb26b2..4cf7467042 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -38,6 +38,8 @@ land_hr_split_file <- file.path(outputdir, "cell.land_split_0.5.mz") land_hr_shr_split_file <- file.path(outputdir, "cell.land_split_0.5_share.mz") luh_side_layers <- file.path(outputdir, "luh2_side_layers_0.5.mz") bii_hr_out_file <- file.path(outputdir, "cell.bii_0.5.mz") +peatland_hr_out_file <- file.path(outputdir, "cell.peatland_0.5.mz") +peatland_hr_share_out_file <- file.path(outputdir, "cell.peatland_0.5_share.mz") cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) @@ -475,4 +477,30 @@ bii_hr <- dimSums(land_bii_hr * bii_hr, dim = 3, na.rm = TRUE) ) gc() + +# -------------------------------- +# Disaggregate peatland +# -------------------------------- + +message("Disaggregating peatland") + +peat_lr <- PeatlandArea(gdx,level="cell",sum=FALSE) +peat_ini_hr <- read.magpie("input/f58_peatland_area_0.5.mz") +peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewetted",dim = "d3",fill = 0) +peat_ini_hr <- add_columns(peat_ini_hr,addnm = "unused",dim = "d3",fill = 0) +peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) +peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] + + +# Write output +.writeDisagg(peat_hr, peatland_hr_out_file, + comment = "unit: Mha per grid-cell", + message = "Write outputs peatland Mha" +) +.writeDisagg(peat_hr / dimSums(land_hr, dim = 3.1), peatland_hr_share_out_file, + comment = "unit: grid-cell land area fraction", + message = "Write outputs peatland share" +) +gc() + message("Finished disaggregation") From 341066467d5c68b72ab085806c56120e2e5d9fc4 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 10 Nov 2023 21:15:17 +0100 Subject: [PATCH 029/187] update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97228b5c6d..497d327020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors - **32_forestry** new interface `vm_land_forestry` +- **scripts** added peatland to output/extra/disaggregation.R ### removed - From 7ee69b5450bf92b1ce3568a8a3e349e40cc5b223 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 11 Nov 2023 11:00:51 +0100 Subject: [PATCH 030/187] update + bugfix --- CHANGELOG.md | 2 +- config/default.cfg | 5 ++- core/sets.gms | 44 +++++++++++++-------------- scripts/output/extra/disaggregation.R | 25 +++++++++++---- 4 files changed, 46 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 497d327020..516ec7fa27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93 - **inputdata** There was a major bug (related to proj/terra) in the rev4.91 inputdata that was fixed with rev4.92 - **scripts** Fixed a bug in NPI/NDC calculations leading to missing AD policies when run with 67k - +- **scripts** Fixed a bug in output/extra/disaggregation.R related to 67k ## [4.6.11] - 2023-09-05 diff --git a/config/default.cfg b/config/default.cfg index 4bb8230385..a1293ce6ed 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1935,7 +1935,10 @@ cfg$files2export$start <- c("input/info.txt", "land_conversion_cost_calib_*.cs3", "input/spamplot_*.pdf", "input/regionmapping*.csv", - "input/kba_land_0.5.mz") + "input/kba_land_0.5.mz", + "input/f58_peatland_area_0.5.mz", + "input/f58_peatland_intact_0.5.mz", + "input/f58_peatland_degrad_0.5.mz") # Files that should be copied after the MAgPIE run is finished cfg$files2export$end <- NULL diff --git a/core/sets.gms b/core/sets.gms index 844ea9e52f..e49a577fe4 100644 --- a/core/sets.gms +++ b/core/sets.gms @@ -55,31 +55,31 @@ sets VEN, VGB, VIR, VNM, VUT, WLF, WSM, YEM, ZAF, ZMB, ZWE / j number of LPJ cells - / CAZ_1*CAZ_6, - CHA_7*CHA_23, - EUR_24*EUR_32, - IND_33*IND_40, - JPN_41*JPN_41, - LAM_42*LAM_85, - MEA_86*MEA_111, - NEU_112*NEU_118, - OAS_119*OAS_128, - REF_129*REF_141, - SSA_142*SSA_179, + / CAZ_1*CAZ_5, + CHA_6*CHA_21, + EUR_22*EUR_29, + IND_30*IND_36, + JPN_37*JPN_38, + LAM_39*LAM_79, + MEA_80*MEA_109, + NEU_110*NEU_117, + OAS_118*OAS_128, + REF_129*REF_140, + SSA_141*SSA_179, USA_180*USA_200 / cell(i,j) number of LPJ cells per region i - / CAZ . (CAZ_1*CAZ_6) - CHA . (CHA_7*CHA_23) - EUR . (EUR_24*EUR_32) - IND . (IND_33*IND_40) - JPN . (JPN_41*JPN_41) - LAM . (LAM_42*LAM_85) - MEA . (MEA_86*MEA_111) - NEU . (NEU_112*NEU_118) - OAS . (OAS_119*OAS_128) - REF . (REF_129*REF_141) - SSA . (SSA_142*SSA_179) + / CAZ . (CAZ_1*CAZ_5) + CHA . (CHA_6*CHA_21) + EUR . (EUR_22*EUR_29) + IND . (IND_30*IND_36) + JPN . (JPN_37*JPN_38) + LAM . (LAM_39*LAM_79) + MEA . (MEA_80*MEA_109) + NEU . (NEU_110*NEU_117) + OAS . (OAS_118*OAS_128) + REF . (REF_129*REF_140) + SSA . (SSA_141*SSA_179) USA . (USA_180*USA_200) / i_to_iso(i,iso) mapping regions to iso countries diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index 4cf7467042..29e9a4122c 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -38,6 +38,9 @@ land_hr_split_file <- file.path(outputdir, "cell.land_split_0.5.mz") land_hr_shr_split_file <- file.path(outputdir, "cell.land_split_0.5_share.mz") luh_side_layers <- file.path(outputdir, "luh2_side_layers_0.5.mz") bii_hr_out_file <- file.path(outputdir, "cell.bii_0.5.mz") +peatland_v2_hr_file <- file.path(outputdir, "f58_peatland_area_0.5.mz") +peatland_on_intact_hr_file <- file.path(outputdir, "f58_peatland_intact_0.5.mz") +peatland_on_degrad_hr_file <- file.path(outputdir, "f58_peatland_degrad_0.5.mz") peatland_hr_out_file <- file.path(outputdir, "cell.peatland_0.5.mz") peatland_hr_share_out_file <- file.path(outputdir, "cell.peatland_0.5_share.mz") @@ -145,6 +148,7 @@ if (length(map_file) > 1) { consv_scaling <- toolAggregate(consv_scaling, map, from = "cluster", to = "cell") land_consv_hr[, , "past"] <- consv_scaling[, , "past"] * land_consv_hr[, , "past"] land_consv_hr[, , natveg] <- consv_scaling[, , "natveg"] * land_consv_hr[, , natveg] + if (length(getCells(land_consv_hr)) == "67420") getSets(land_consv_hr, fulldim = FALSE)[1] <- "x.y.iso" return(land_consv_hr) } @@ -484,12 +488,21 @@ gc() message("Disaggregating peatland") -peat_lr <- PeatlandArea(gdx,level="cell",sum=FALSE) -peat_ini_hr <- read.magpie("input/f58_peatland_area_0.5.mz") -peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewetted",dim = "d3",fill = 0) -peat_ini_hr <- add_columns(peat_ini_hr,addnm = "unused",dim = "d3",fill = 0) -peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) -peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] +#check for peatland version +if(cfg$gms$peatland == "v2") { + peat_lr <- PeatlandArea(gdx,level="cell",sum=FALSE) + peat_ini_hr <- read.magpie(peatland_v2_hr_file) + peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewetted",dim = "d3",fill = 0) + peat_ini_hr <- add_columns(peat_ini_hr,addnm = "unused",dim = "d3",fill = 0) + peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) + peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] +} else if (cfg$gms$peatland == "on") { + peat_lr <- PeatlandArea(gdx,level="cell",sum=TRUE) + peat_ini_hr <- mbind(setNames(read.magpie(peatland_on_intact_hr_file),"intact"),setNames(read.magpie(peatland_on_degrad_hr_file),"degrad")) + peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewet",dim = "d3",fill = 0) + peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) + peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] +} # Write output From e43bf0323beaf7b4df46eae2f696f300005d92ae Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 11 Nov 2023 11:15:48 +0100 Subject: [PATCH 031/187] bugfix --- scripts/output/extra/disaggregation.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index 29e9a4122c..9a5f5e4cac 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -78,6 +78,7 @@ if (length(map_file) > 1) { # calculate crop area as share of total cell area area_shr_hr <- madrat::toolAggregate(area_shr, map_file, to = "cell") * crop_shr + if (length(getCells(area_shr_hr)) == "67420") getSets(area_shr_hr, fulldim = FALSE)[1] <- "x.y.iso" return(area_shr_hr) } @@ -169,6 +170,7 @@ if (length(map_file) > 1) { # Disaggregate BII coefficients to grid cell level bii_hr <- toolAggregate(x = bii_lr, rel = map_file, from = "cluster", to = "cell") + if (length(getCells(bii_hr)) == "67420") getSets(bii_hr, fulldim = FALSE)[1] <- "x.y.iso" return(bii_hr) } @@ -496,12 +498,15 @@ if(cfg$gms$peatland == "v2") { peat_ini_hr <- add_columns(peat_ini_hr,addnm = "unused",dim = "d3",fill = 0) peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] + if (length(getCells(peat_hr)) == "67420") getSets(peat_hr, fulldim = FALSE)[1] <- "x.y.iso" + } else if (cfg$gms$peatland == "on") { peat_lr <- PeatlandArea(gdx,level="cell",sum=TRUE) peat_ini_hr <- mbind(setNames(read.magpie(peatland_on_intact_hr_file),"intact"),setNames(read.magpie(peatland_on_degrad_hr_file),"degrad")) peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewet",dim = "d3",fill = 0) peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] + if (length(getCells(peat_hr)) == "67420") getSets(peat_hr, fulldim = FALSE)[1] <- "x.y.iso" } From 4a66255fb8b337746f85d4ab96b341e8a779eab6 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 11 Nov 2023 11:33:12 +0100 Subject: [PATCH 032/187] bugfix --- scripts/output/extra/disaggregation.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index 9a5f5e4cac..eb3b5f989b 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -515,7 +515,7 @@ if(cfg$gms$peatland == "v2") { comment = "unit: Mha per grid-cell", message = "Write outputs peatland Mha" ) -.writeDisagg(peat_hr / dimSums(land_hr, dim = 3.1), peatland_hr_share_out_file, +.writeDisagg(peat_hr / dimSums(land_hr[,getYears(peat_hr),], dim = 3), peatland_hr_share_out_file, comment = "unit: grid-cell land area fraction", message = "Write outputs peatland share" ) From 48d6341177b016d32bc824c4c12b434f34f4da0a Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 11 Nov 2023 17:45:26 +0100 Subject: [PATCH 033/187] bugfix --- scripts/output/extra/disaggregation.R | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index eb3b5f989b..6d825d69b7 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -496,7 +496,7 @@ if(cfg$gms$peatland == "v2") { peat_ini_hr <- read.magpie(peatland_v2_hr_file) peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewetted",dim = "d3",fill = 0) peat_ini_hr <- add_columns(peat_ini_hr,addnm = "unused",dim = "d3",fill = 0) - peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) + peat_hr <- suppressWarnings(luscale::interpolate2(peat_lr,peat_ini_hr,map_file)) peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] if (length(getCells(peat_hr)) == "67420") getSets(peat_hr, fulldim = FALSE)[1] <- "x.y.iso" @@ -504,7 +504,7 @@ if(cfg$gms$peatland == "v2") { peat_lr <- PeatlandArea(gdx,level="cell",sum=TRUE) peat_ini_hr <- mbind(setNames(read.magpie(peatland_on_intact_hr_file),"intact"),setNames(read.magpie(peatland_on_degrad_hr_file),"degrad")) peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewet",dim = "d3",fill = 0) - peat_hr <- luscale::interpolate2(peat_lr,peat_ini_hr,map_file) + peat_hr <- suppressWarnings(luscale::interpolate2(peat_lr,peat_ini_hr,map_file)) peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] if (length(getCells(peat_hr)) == "67420") getSets(peat_hr, fulldim = FALSE)[1] <- "x.y.iso" } @@ -513,12 +513,16 @@ if(cfg$gms$peatland == "v2") { # Write output .writeDisagg(peat_hr, peatland_hr_out_file, comment = "unit: Mha per grid-cell", - message = "Write outputs peatland Mha" -) -.writeDisagg(peat_hr / dimSums(land_hr[,getYears(peat_hr),], dim = 3), peatland_hr_share_out_file, + message = "Write outputs peatland Mha") +gc() + +out <- peat_hr / dimSums(land_hr[,getYears(peat_hr),], dim = 3) +out[is.nan(out)] <- 0 +out[is.infinite(out)] <- 0 + +.writeDisagg(out, peatland_hr_share_out_file, comment = "unit: grid-cell land area fraction", - message = "Write outputs peatland share" -) + message = "Write outputs peatland share") gc() message("Finished disaggregation") From 8ac4fe023983b0af0f522e69be7a2d265da178ec Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Thu, 26 Oct 2023 14:18:36 +0200 Subject: [PATCH 034/187] fix disaggregation --- scripts/output/extra/disaggregation.R | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index ae5adb26b2..fc85241ca3 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -54,9 +54,14 @@ if (length(map_file) > 1) { # Output functions # ----------------------------------------- +.fixCoords <- function(x) { + getSets(x, fulldim = FALSE)[1] <- "x.y.iso" + return(x) +} + .writeDisagg <- function(x, file, comment, message) { - write.magpie(x, file, comment = comment) - write.magpie(x, sub(".mz", ".nc", file), comment = comment, verbose = FALSE) + write.magpie(.fixCoords(x), file, comment = comment) + write.magpie(.fixCoords(x), sub(".mz", ".nc", file), comment = comment, verbose = FALSE) } .dissagcrop <- function(gdx, land_hr, map_file) { @@ -82,7 +87,8 @@ if (length(map_file) > 1) { map <- readRDS(map_file) # create full time series - land_consv_hr <- new.magpie(map[, "cell"], getYears(land_consv_lr), getNames(wdpa_hr)) + land_consv_hr <- new.magpie(map[, "cell"], getYears(land_consv_lr), getNames(wdpa_hr), + sets = c("x.y.iso", "year", getSets(wdpa_hr, fulldim = FALSE)[3])) land_consv_hr[, getYears(land_consv_hr), ] <- wdpa_hr[, nyears(wdpa_hr), ] land_consv_hr[, getYears(wdpa_hr), ] <- wdpa_hr @@ -91,7 +97,8 @@ if (length(map_file) > 1) { consv_prio_all <- read.magpie(consv_prio_hr_file) consv_prio_hr <- new.magpie( cells_and_regions = map[, "cell"], - names = getNames(consv_prio_all, dim = 2), fill = 0 + names = getNames(consv_prio_all, dim = 2), fill = 0, + sets = c("x.y.iso", "year", "data") ) iso <- readGDX(gdx, "iso") consv_iso <- readGDX(gdx, "policy_countries22") @@ -299,6 +306,7 @@ land_hr <- interpolateAvlCroplandWeighted( snv_pol_shr = snv_pol_shr, snv_pol_fader = snv_pol_fader ) +land_hr <- .fixCoords(land_hr) # Write output .writeDisagg(land_hr, land_hr_out_file, @@ -458,6 +466,7 @@ land_bii_hr <- interpolateAvlCroplandWeighted( snv_pol_fader = snv_pol_fader, unit = "share" ) +land_bii_hr <- .fixCoords(land_bii_hr) # Add primary and secondaray other land land_bii_hr <- PrimSecdOtherLand(land_bii_hr, land_hr_file) From e78d674d540cdb2a46e0a66fe4b0dd4d68a687b6 Mon Sep 17 00:00:00 2001 From: emolinab Date: Thu, 26 Oct 2023 21:49:03 +0200 Subject: [PATCH 035/187] update LUH_disaggregtion --- scripts/output/extra/disaggregation_LUH2.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index b90dded6a7..b5f18049b8 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -46,15 +46,16 @@ out_dir<-paste0(outputdir,"/disaggregation_LUH2") convertLUH2 <- function(x) { #interpolate years years <- getYears(x,as.integer = TRUE) + getSets(x, fulldim = FALSE)[1] <- "x.y.iso" x <- toolFillYears(x,seq(range(years)[1],range(years)[2],by=1)) - for(n in seq(1995,2085,15)){ x_1<- if(n==1995) as.RasterBrick(x[,n:(n+15),]) else as.RasterBrick(x[,(n+1):(n+15),]) x_aux<- if(n==1995) x_1 else stack(x_aux,x_1) } #re-project raster from 0.5 to 0.25 degree - x <- suppressWarnings(projectRaster(x_aux,raster(res=c(0.25,0.25)),method = "ngb")) + x <- suppressWarnings(raster::projectRaster(x_aux,raster::raster(res=c(0.25,0.25)),method = "ngb")) + crs(x) <- "+proj=utm +zone=1 +datum=WGS84" return(x) } @@ -489,4 +490,4 @@ gc() write.magpie(a, paste0(out_dir, "/LUH2_Yield_Nr.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() -} +} \ No newline at end of file From fc1297919c6e5f851fd74d45b122e6596d0e86ca Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Wed, 15 Nov 2023 21:45:34 +0100 Subject: [PATCH 036/187] Add script fixes to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97228b5c6d..7a0e9c6c86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93 - **inputdata** There was a major bug (related to proj/terra) in the rev4.91 inputdata that was fixed with rev4.92 - **scripts** Fixed a bug in NPI/NDC calculations leading to missing AD policies when run with 67k - +- **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k ## [4.6.11] - 2023-09-05 From 33eb00a0b3211f139979e889d3d5733a1fd05007 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 16 Nov 2023 14:55:44 +0100 Subject: [PATCH 037/187] update --- scripts/output/extra/disaggregation.R | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index 355764b8c3..05ef287729 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -83,7 +83,6 @@ if (length(map_file) > 1) { # calculate crop area as share of total cell area area_shr_hr <- madrat::toolAggregate(area_shr, map_file, to = "cell") * crop_shr - if (length(getCells(area_shr_hr)) == "67420") getSets(area_shr_hr, fulldim = FALSE)[1] <- "x.y.iso" return(area_shr_hr) } @@ -156,7 +155,6 @@ if (length(map_file) > 1) { consv_scaling <- toolAggregate(consv_scaling, map, from = "cluster", to = "cell") land_consv_hr[, , "past"] <- consv_scaling[, , "past"] * land_consv_hr[, , "past"] land_consv_hr[, , natveg] <- consv_scaling[, , "natveg"] * land_consv_hr[, , natveg] - if (length(getCells(land_consv_hr)) == "67420") getSets(land_consv_hr, fulldim = FALSE)[1] <- "x.y.iso" return(land_consv_hr) } @@ -177,7 +175,6 @@ if (length(map_file) > 1) { # Disaggregate BII coefficients to grid cell level bii_hr <- toolAggregate(x = bii_lr, rel = map_file, from = "cluster", to = "cell") - if (length(getCells(bii_hr)) == "67420") getSets(bii_hr, fulldim = FALSE)[1] <- "x.y.iso" return(bii_hr) } @@ -507,17 +504,15 @@ if(cfg$gms$peatland == "v2") { peat_ini_hr <- add_columns(peat_ini_hr,addnm = "unused",dim = "d3",fill = 0) peat_hr <- suppressWarnings(luscale::interpolate2(peat_lr,peat_ini_hr,map_file)) peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] - if (length(getCells(peat_hr)) == "67420") getSets(peat_hr, fulldim = FALSE)[1] <- "x.y.iso" - + } else if (cfg$gms$peatland == "on") { peat_lr <- PeatlandArea(gdx,level="cell",sum=TRUE) peat_ini_hr <- mbind(setNames(read.magpie(peatland_on_intact_hr_file),"intact"),setNames(read.magpie(peatland_on_degrad_hr_file),"degrad")) peat_ini_hr <- add_columns(peat_ini_hr,addnm = "rewet",dim = "d3",fill = 0) peat_hr <- suppressWarnings(luscale::interpolate2(peat_lr,peat_ini_hr,map_file)) peat_hr <- peat_hr[,getYears(peat_hr,as.integer = T) >= cfg$gms$s58_fix_peatland,] - if (length(getCells(peat_hr)) == "67420") getSets(peat_hr, fulldim = FALSE)[1] <- "x.y.iso" } - +peat_hr <- .fixCoords(peat_hr) # Write output .writeDisagg(peat_hr, peatland_hr_out_file, From e97eabdc83211cf8691c06e132095f20d7f9d10a Mon Sep 17 00:00:00 2001 From: Alexandre Koberle Date: Fri, 17 Nov 2023 16:05:16 +0100 Subject: [PATCH 038/187] Adjusted how f31_pastr_suitability is read in to align with ssp-rcp specific input files, required minor change in default.cfg. --- CHANGELOG.md | 2 ++ CITATION.cff | 8 +++++- config/default.cfg | 9 +------ modules/31_past/grasslands_apr22/input.gms | 26 ++++++++++---------- modules/31_past/grasslands_apr22/preloop.gms | 9 ------- modules/31_past/grasslands_apr22/sets.gms | 3 --- modules/31_past/input/files | 2 +- modules/31_past/static/not_used.txt | 1 - 8 files changed, 24 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a0e9c6c86..4634f206a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **14_yields_and_config** The new default is to not use yield calibration factors from a calibration run. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors. - **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files. - **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits. +- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. +- **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **36_employment** regression between hourly labor regression and GDP pc changed from linear to log-log ### added diff --git a/CITATION.cff b/CITATION.cff index bde8fd0ac5..46043bc0eb 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -112,7 +112,13 @@ authors: affiliation: "Potsdam Institute for Climate Impact Research" email: pascal.sauer@pik-potsdam.de - - family-names: Lotze-Campen + - family-names: Köberle + given-names: Alexandre + orcid: https://orcid.org/0000-0003-0328-4750 + affiliation: "Potsdam Institute for Climate Impact Research" + email: alexkob@pik-potsdam.de + +- family-names: Lotze-Campen given-names: Hermann orcid: https://orcid.org/0000-0002-0003-5508 affiliation: "Potsdam Institute for Climate Impact Research" diff --git a/config/default.cfg b/config/default.cfg index 4bb8230385..e8e69f27c3 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -718,19 +718,12 @@ cfg$gms$s31_fac_req_past <- 1 # def = 1 # * reflecting that not all pasture area is grazed. cfg$gms$s31_unequal <- 1 # def = 1 -# * Scenario for grassland and pasture yields (only take effect for realization grasslands_apr22) +# * Scenario for grassland, pasture suitability areas and pasture yields (only take effect for realization grasslands_apr22) # * options: cc (climate change) # * nocc (no climate change) # * nocc_hist (no climate change after year defined by sm_fix_cc) cfg$gms$c31_grassl_yld_scenario <- "cc" # def = "cc" - -# * SSP scenario switch for pasture suitability areas (only take effect for realization grasslands_apr22) -# * options: ssp126, ssp245, ssp370, ssp460, ssp585 -# * nocc (fixed to values from 1995), -# * nocc_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter) -cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370" - # * Switch that allows selecting how yield calibration factors will be calculated. # * If 0, grassland yield calibration will be calculated as multiplicative relative values. # * If 1, calibration values will be limited to additive absolute values when modeled yields strongly diff --git a/modules/31_past/grasslands_apr22/input.gms b/modules/31_past/grasslands_apr22/input.gms index 0896afc475..5c96e90de6 100644 --- a/modules/31_past/grasslands_apr22/input.gms +++ b/modules/31_past/grasslands_apr22/input.gms @@ -11,26 +11,26 @@ scalars s31_cost_grass_prod Grasslands factor costs (USD05MER per tDM) / 1 / ; -$setglobal c31_past_suit_scen ssp370 +$setglobal c31_grassl_yld_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) -table f31_pastr_suitability(t_all,j,ssp_past) Areas suitable for pasture management (mio. ha) +parameter f31_pastr_suitability(t_all,j) Areas suitable for pasture management (mio. ha) +/ $ondelim -$include "./modules/31_past/input/f31_pastr_suitability.cs3" +$include "./modules/31_past/input/f31_pastr_suitability.cs2" $offdelim -; +/; + +i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j) +* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used +$if "%c31_grassl_yld_scenario%" == "nocc" i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j); +$if "%c31_grassl_yld_scenario%" == "nocc_hist" i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = i31_manpast_suit(t_all,j)$(m_year(t_all) = sm_fix_cc); -table f31_LUH2v2(t_all,j,f31_luh) Different land type areas (mio. ha) -$ondelim -$include "./modules/31_past/input/f31_LUH2v2.cs3" -$offdelim -; scalar s31_limit_calib Relative managament calibration switch (1=limited 0=pure relative) / 1 /; -$setglobal c31_grassl_yld_scenario cc -* options: cc (climate change) -* nocc (no climate change) -* nocc_hist (no climate change after year defined by sm_fix_cc) table f31_grassl_yld(t_all,j,grassland,w) LPJmL potential yields per cell (rainfed only) (tDM per ha) $ondelim diff --git a/modules/31_past/grasslands_apr22/preloop.gms b/modules/31_past/grasslands_apr22/preloop.gms index 5b48e2cfc5..7a84ab73e3 100644 --- a/modules/31_past/grasslands_apr22/preloop.gms +++ b/modules/31_past/grasslands_apr22/preloop.gms @@ -5,15 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -$ifthen "%c31_past_suit_scen%" == "nocc" - i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245"); -$elseif "%c31_past_suit_scen%" == "nocc_hist" - i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245"); - i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc); -$else - i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); - i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); -$endif pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland); diff --git a/modules/31_past/grasslands_apr22/sets.gms b/modules/31_past/grasslands_apr22/sets.gms index a157221583..0fa2cee21e 100644 --- a/modules/31_past/grasslands_apr22/sets.gms +++ b/modules/31_past/grasslands_apr22/sets.gms @@ -19,7 +19,4 @@ sets grass_from31(grassland) pasture management options / pastr,range / - ssp_past SSP scenarios for pasture suitability areas - / ssp126, ssp245, ssp370, ssp460, ssp585 / - ; diff --git a/modules/31_past/input/files b/modules/31_past/input/files index f4f049409d..b628d2f69c 100644 --- a/modules/31_past/input/files +++ b/modules/31_past/input/files @@ -1,5 +1,5 @@ * list of files that are required here -f31_pastr_suitability.cs3 +f31_pastr_suitability.cs2 f31_LUH2v2.cs3 f31_grassl_yld.cs3 f31_grass_bio_hist.cs3 diff --git a/modules/31_past/static/not_used.txt b/modules/31_past/static/not_used.txt index 57f7b20c03..6bd07855f0 100644 --- a/modules/31_past/static/not_used.txt +++ b/modules/31_past/static/not_used.txt @@ -4,5 +4,4 @@ vm_yld, input, not needed pm_land_conservation,input,questionnaire vm_tau,input,questionnaire fm_pastr_tau_hist,input,questionnaire -sm_fix_SSP2, input, not needed sm_fix_cc, input, not needed From 508593566588def3b8d93207115197b5f0552596 Mon Sep 17 00:00:00 2001 From: Alexandre Koberle Date: Fri, 17 Nov 2023 19:16:40 +0100 Subject: [PATCH 039/187] Adjusting 31_past to work with grasslands_apr22 realization. Parameter sm_fix_SSP2 no longer used. --- modules/31_past/endo_jun13/not_used.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/31_past/endo_jun13/not_used.txt b/modules/31_past/endo_jun13/not_used.txt index e695835bae..2b47ed0ec1 100644 --- a/modules/31_past/endo_jun13/not_used.txt +++ b/modules/31_past/endo_jun13/not_used.txt @@ -2,5 +2,4 @@ name,type,reason pcm_land, input, not needed vm_tau,input,questionnaire fm_pastr_tau_hist,input,questionnaire -sm_fix_SSP2, input, not needed sm_fix_cc, input, not needed From a52044b301a2dce810e0c15613f73c98083991fe Mon Sep 17 00:00:00 2001 From: Alexandre Koberle Date: Fri, 17 Nov 2023 21:21:22 +0100 Subject: [PATCH 040/187] In CHANGELOG, moved switch removal in default.cfg from changes to removals. --- CHANGELOG.md | 5 ++--- core/sets.gms | 44 ++++++++++++++++++++++---------------------- main.gms | 38 +++++++++++++++++++------------------- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4634f206a1..c94ef7b952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **14_yields_and_config** The new default is to not use yield calibration factors from a calibration run. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors. - **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files. - **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits. -- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. -- **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. +- **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **36_employment** regression between hourly labor regression and GDP pc changed from linear to log-log ### added @@ -23,7 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **32_forestry** new interface `vm_land_forestry` ### removed -- +- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. ### fixed - **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93 diff --git a/core/sets.gms b/core/sets.gms index 844ea9e52f..e49a577fe4 100644 --- a/core/sets.gms +++ b/core/sets.gms @@ -55,31 +55,31 @@ sets VEN, VGB, VIR, VNM, VUT, WLF, WSM, YEM, ZAF, ZMB, ZWE / j number of LPJ cells - / CAZ_1*CAZ_6, - CHA_7*CHA_23, - EUR_24*EUR_32, - IND_33*IND_40, - JPN_41*JPN_41, - LAM_42*LAM_85, - MEA_86*MEA_111, - NEU_112*NEU_118, - OAS_119*OAS_128, - REF_129*REF_141, - SSA_142*SSA_179, + / CAZ_1*CAZ_5, + CHA_6*CHA_21, + EUR_22*EUR_29, + IND_30*IND_36, + JPN_37*JPN_38, + LAM_39*LAM_79, + MEA_80*MEA_109, + NEU_110*NEU_117, + OAS_118*OAS_128, + REF_129*REF_140, + SSA_141*SSA_179, USA_180*USA_200 / cell(i,j) number of LPJ cells per region i - / CAZ . (CAZ_1*CAZ_6) - CHA . (CHA_7*CHA_23) - EUR . (EUR_24*EUR_32) - IND . (IND_33*IND_40) - JPN . (JPN_41*JPN_41) - LAM . (LAM_42*LAM_85) - MEA . (MEA_86*MEA_111) - NEU . (NEU_112*NEU_118) - OAS . (OAS_119*OAS_128) - REF . (REF_129*REF_141) - SSA . (SSA_142*SSA_179) + / CAZ . (CAZ_1*CAZ_5) + CHA . (CHA_6*CHA_21) + EUR . (EUR_22*EUR_29) + IND . (IND_30*IND_36) + JPN . (JPN_37*JPN_38) + LAM . (LAM_39*LAM_79) + MEA . (MEA_80*MEA_109) + NEU . (NEU_110*NEU_117) + OAS . (OAS_118*OAS_128) + REF . (REF_129*REF_140) + SSA . (SSA_141*SSA_179) USA . (USA_180*USA_200) / i_to_iso(i,iso) mapping regions to iso countries diff --git a/main.gms b/main.gms index 74151a0464..5427e7b2fb 100644 --- a/main.gms +++ b/main.gms @@ -148,25 +148,25 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * -* Used data set: rev4.88_h12_magpie.tgz -* md5sum: 740da40ceda04850eb374df215837c1b -* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public +* Used data set: rev4.94_h12_magpie.tgz +* md5sum: 25623b5ad3e8b72bd3008da9b69adfe0 +* Repository: /p/projects/rd3mod/inputdata/output * -* Used data set: rev4.88_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz -* md5sum: 9edbcc62e75b663eada84524402bccbf -* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public +* Used data set: rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* md5sum: d7800a0ffe271483116a8f00a939a89a +* Repository: /p/projects/rd3mod/inputdata/output * -* Used data set: rev4.88_h12_validation.tgz -* md5sum: d42abd58de683506a807b411d7fe87cb -* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public +* Used data set: rev4.94_h12_validation.tgz +* md5sum: 4b4128910822cf45603cab46f45ccf78 +* Repository: /p/projects/rd3mod/inputdata/output * -* Used data set: additional_data_rev4.45.tgz -* md5sum: bb51c8c8608b8b9363582eb4aa220754 -* Repository: /p/projects/landuse/data/input/archive +* Used data set: additional_data_rev4.46.tgz +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz -* md5sum: 5d34e4b54112db10f330f1e59dd60cc9 -* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public +* md5sum: NA +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Low resolution: c200 * High resolution: 0.5 @@ -175,15 +175,15 @@ $title magpie * * Number of cells per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA -* 6 17 9 8 1 44 26 7 10 13 38 21 +* 5 16 8 7 2 41 30 8 11 12 39 21 * * Regionscode: 62eff8f7 * -* Regions data revision: 4.88 +* Regions data revision: 4.94 * * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.88 +* * Revision: 4.94 * * aggregation settings: * * Input resolution: 0.5 @@ -191,11 +191,11 @@ $title magpie * * Regionscode: 62eff8f7 * * Number of clusters per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA -* 6 17 9 8 1 44 26 7 10 13 38 21 +* 5 16 8 7 2 41 30 8 11 12 39 21 * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * * -* Last modification (input data): Fri Sep 22 15:20:24 2023 +* Last modification (input data): Fri Nov 17 19:42:06 2023 * *###################### R SECTION END (VERSION INFO) ########################### From 0e556246466c4e4dccae8e8d7f917a08caf0010e Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 21 Nov 2023 15:51:08 +0100 Subject: [PATCH 041/187] update --- core/macros.gms | 5 +++++ modules/58_peatland/v2/declarations.gms | 2 +- modules/58_peatland/v2/equations.gms | 17 ++++++++--------- modules/58_peatland/v2/presolve.gms | 8 +------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core/macros.gms b/core/macros.gms index 1c8bdd6f0f..423c4851ee 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -97,3 +97,8 @@ $macro m_carbon_stock(land,carbon_density,item) \ $macro m_carbon_stock_ac(land,carbon_density,sets,sets_sub) \ sum((&&sets), land(j2,&&sets) * sum(ct, carbon_density(ct,j2,&&sets,ag_pools)))$(sameas(stockType,"actual")) + \ sum((&&sets_sub), land(j2,&&sets_sub) * sum(ct, carbon_density(ct,j2,&&sets_sub,ag_pools)))$(sameas(stockType,"actualNoAcEst")); + +* macro for peatland dynamics +$macro m_peatland(pc58_peatland,peatland_item,vm_land,pcm_land,land_item,p58_scaling_factor) \ + pc58_peatland(j2,peatland_item) + ((vm_land(j2,land_item)-pcm_land(j2,land_item)) * p58_scaling_factor(j2)) * \ + (p58_scaling_factor(j2) * vm_land(j2,land_item) - pc58_peatland(j2,peatland_item)) / ((vm_land(j2,land_item) - pcm_land(j2,land_item)) * p58_scaling_factor(j2) + 1e-6) diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index bc72f37bae..294c7674a7 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -6,7 +6,7 @@ *** | Contact: magpie@pik-potsdam.de parameters - p58_scaling_factor(j,landDrainedUsed58) Scaling factor for managed peatland (1) + p58_scaling_factor(j) Scaling factor for managed peatland (1) pc58_peatland(j,land58) Peatland area (mio. ha) p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index dd375bdd17..da3266fc7f 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -20,8 +20,10 @@ q58_reduction(j2,land58) .. v58_reduction(j2,land58) =g= pc58_peatland(j2,land58)-v58_peatland(j2,land58); -*' Future peatland dynamics (`v58_peatland`) depend on managed land (`vm_land`, `vm_land_forestry`), -*' multiplied with the peatland scaling factor (`p58_scaling_factor`). +*' Future peatland dynamics (`v58_peatland`) depend on changes in managed land +*' (`vm_land-pcm_land`, `vm_land_forestry-pcm_land_forestry`), +*' multiplied with the peatland scaling factor (`p58_scaling_factor`) and an adjustment term for cells where +*' the initial peatland area is inconsistent with the scaling factor (see marco m_peatland for details). *' By multiplying changes in managed land with the scaling factor we implicitly assume *' that intact peatlands are distributed equally within a grid cell. *' The following example illustrates the mechanism used for projecting peatland dynamics: @@ -31,19 +33,16 @@ *' If the total cell would become cropland, degraded peatland would equal to the total peatland area (50 Mha x 0.2 = 10 Mha). q58_peatland_crop(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. - v58_peatland(j2,"crop") =e= - pc58_peatland(j2,"crop") - + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2,"crop")); + v58_peatland(j2,"crop") =e= + m_peatland(pc58_peatland,"crop",vm_land,pcm_land,"crop",p58_scaling_factor); q58_peatland_past(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"past") =e= - pc58_peatland(j2,"past") - + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2,"past")); + m_peatland(pc58_peatland,"past",vm_land,pcm_land,"past",p58_scaling_factor); q58_peatland_forestry(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,"forestry") =e= - pc58_peatland(j2,"forestry") - + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2,"forestry")); + m_peatland(pc58_peatland,"forestry",vm_land_forestry,pcm_land_forestry,"plant",p58_scaling_factor); *' Costs for peatland degradation and rewetting diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index 2e44a82e9d..73b2ddbfe8 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -19,13 +19,7 @@ if (m_year(t) <= s58_fix_peatland, pc58_peatland(j,"intact") = f58_peatland_area(j,"intact"); * Peatland scaling factor for estimating future peatland dynamics -* The peatland scaling factor for cells with drained peatland area depends on the ratio of drained peatland and managed land (remains fixed after s58_fix_peatland) - p58_scaling_factor(j,landDrainedUsed58) = 0; - p58_scaling_factor(j,"crop")$(pcm_land(j,"crop") > 1e-20) = pc58_peatland(j,"crop") / pcm_land(j,"crop"); - p58_scaling_factor(j,"past")$(pcm_land(j,"past") > 1e-20) = pc58_peatland(j,"past") / pcm_land(j,"past"); - p58_scaling_factor(j,"forestry")$(pcm_land_forestry(j,"plant") > 1e-20) = pc58_peatland(j,"forestry") / pcm_land_forestry(j,"plant"); -* The peatland scaling factor for cells without drained peatland area depends on the ratio of total peatland area and total land area (remains fixed after s58_fix_peatland). - p58_scaling_factor(j,landDrainedUsed58)$(pc58_peatland(j,landDrainedUsed58) = 0) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); +p58_scaling_factor(j) = sum(land58, pc58_peatland(j,land58)) / sum(land, pcm_land(j,land)); * Peatland area is fixed to `pc58_peatland` until the year given by s58_fix_peatland v58_peatland.fx(j,land58) = pc58_peatland(j,land58); From b354839b1c50bcd486a2e3c4ce5c899f9dc5747c Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 21 Nov 2023 15:59:53 +0100 Subject: [PATCH 042/187] bugfix --- core/macros.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/macros.gms b/core/macros.gms index 423c4851ee..da05ca2379 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -99,6 +99,6 @@ $macro m_carbon_stock_ac(land,carbon_density,sets,sets_sub) \ sum((&&sets_sub), land(j2,&&sets_sub) * sum(ct, carbon_density(ct,j2,&&sets_sub,ag_pools)))$(sameas(stockType,"actualNoAcEst")); * macro for peatland dynamics -$macro m_peatland(pc58_peatland,peatland_item,vm_land,pcm_land,land_item,p58_scaling_factor) \ - pc58_peatland(j2,peatland_item) + ((vm_land(j2,land_item)-pcm_land(j2,land_item)) * p58_scaling_factor(j2)) * \ - (p58_scaling_factor(j2) * vm_land(j2,land_item) - pc58_peatland(j2,peatland_item)) / ((vm_land(j2,land_item) - pcm_land(j2,land_item)) * p58_scaling_factor(j2) + 1e-6) +$macro m_peatland(peatland,peatland_item,vm_land,pcm_land,land_item,scaling_factor) \ + peatland(j2,peatland_item) + ((vm_land(j2,land_item)-pcm_land(j2,land_item)) * scaling_factor(j2)) * \ + (scaling_factor(j2) * vm_land(j2,land_item) - peatland(j2,peatland_item)) / ((vm_land(j2,land_item) - pcm_land(j2,land_item)) * scaling_factor(j2) + 1e-6) From 8f829ad68ea17bfe28c3a008d1f859ff9408c8b7 Mon Sep 17 00:00:00 2001 From: Alexandre Koberle Date: Sat, 25 Nov 2023 23:20:13 +0100 Subject: [PATCH 043/187] Bugfix to 31_past module grasslands_apr22 realization. --- CITATION.cff | 2 +- config/default.cfg | 6 +++--- modules/31_past/grasslands_apr22/input.gms | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 46043bc0eb..a152dd2299 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -118,7 +118,7 @@ authors: affiliation: "Potsdam Institute for Climate Impact Research" email: alexkob@pik-potsdam.de -- family-names: Lotze-Campen + - family-names: Lotze-Campen given-names: Hermann orcid: https://orcid.org/0000-0002-0003-5508 affiliation: "Potsdam Institute for Climate Impact Research" diff --git a/config/default.cfg b/config/default.cfg index e8e69f27c3..6e162ca449 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.94_h12_magpie.tgz", - cellular = "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.94_h12_validation.tgz", +cfg$input <- c(regional = "rev4.95_h12_magpie.tgz", + cellular = "rev4.95_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.95_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/31_past/grasslands_apr22/input.gms b/modules/31_past/grasslands_apr22/input.gms index 5c96e90de6..dcb0bca3bf 100644 --- a/modules/31_past/grasslands_apr22/input.gms +++ b/modules/31_past/grasslands_apr22/input.gms @@ -46,3 +46,10 @@ table f31_grass_bio(t_all,i, grassland) Estimated regional grass biomass consump $ondelim $include "./modules/31_past/input/f31_grass_bio_hist.cs3" $offdelim; + + + +table f31_LUH2v2(t_all,j, f31_luh) LUH2v2 land classes separating rangelands from managed pastures +$ondelim +$include "./modules/31_past/input/f31_LUH2v2.cs3" +$offdelim; From 53a6a1089c672d661113e64aadf56bc0709e8239 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 28 Nov 2023 11:28:30 +0100 Subject: [PATCH 044/187] update + bugfix --- core/macros.gms | 14 +- .../dynamic_feb21/declarations.gms | 97 +++--- .../32_forestry/dynamic_feb21/equations.gms | 7 +- .../32_forestry/dynamic_feb21/postsolve.gms | 313 +++++++++--------- modules/32_forestry/dynamic_feb21/preloop.gms | 3 - .../32_forestry/dynamic_feb21/presolve.gms | 1 + modules/58_peatland/off/not_used.txt | 6 +- modules/58_peatland/on/not_used.txt | 6 +- modules/58_peatland/v2/declarations.gms | 68 ++-- modules/58_peatland/v2/equations.gms | 87 ++--- modules/58_peatland/v2/not_used.txt | 2 + modules/58_peatland/v2/postsolve.gms | 84 +++-- modules/58_peatland/v2/preloop.gms | 3 + modules/58_peatland/v2/presolve.gms | 17 +- modules/58_peatland/v2/sets.gms | 11 +- 15 files changed, 394 insertions(+), 325 deletions(-) create mode 100644 modules/58_peatland/v2/not_used.txt diff --git a/core/macros.gms b/core/macros.gms index da05ca2379..5f99a88bdc 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -98,7 +98,13 @@ $macro m_carbon_stock_ac(land,carbon_density,sets,sets_sub) \ sum((&&sets), land(j2,&&sets) * sum(ct, carbon_density(ct,j2,&&sets,ag_pools)))$(sameas(stockType,"actual")) + \ sum((&&sets_sub), land(j2,&&sets_sub) * sum(ct, carbon_density(ct,j2,&&sets_sub,ag_pools)))$(sameas(stockType,"actualNoAcEst")); -* macro for peatland dynamics -$macro m_peatland(peatland,peatland_item,vm_land,pcm_land,land_item,scaling_factor) \ - peatland(j2,peatland_item) + ((vm_land(j2,land_item)-pcm_land(j2,land_item)) * scaling_factor(j2)) * \ - (scaling_factor(j2) * vm_land(j2,land_item) - peatland(j2,peatland_item)) / ((vm_land(j2,land_item) - pcm_land(j2,land_item)) * scaling_factor(j2) + 1e-6) +* macros for peatland scaling factors +* expansion: (maxPeat - totManPeat) / (maxLand - totManLand) +$macro m_peatland_scaling_factor_exp(peatland,pcm_land) \ + ((sum(land58, peatland(j,land58)) - sum(manPeat58, peatland(j,manPeat58))) / (sum(land, pcm_land(j,land)) - sum(manLand58, pcm_land(j,manLand58))) )\ + $(sum(land58, peatland(j,land58)) > 1e-10 AND sum(land, pcm_land(j,land)) > 1e-10)\ + + 0$(sum(land58, peatland(j,land58)) <= 1e-10 OR sum(land, pcm_land(j,land)) <= 1e-10) +* reduction: totManPeat / totManLand +$macro m_peatland_scaling_factor_red(peatland,pcm_land) \ + (sum(manPeat58, peatland(j,manPeat58)) / sum(manLand58, pcm_land(j,manLand58)))$(sum(manPeat58, peatland(j,manPeat58)) > 1e-10 AND sum(manLand58, pcm_land(j,manLand58)) > 1e-10) \ + + 0$(sum(manPeat58, peatland(j,manPeat58)) <= 1e-10 OR sum(manLand58, pcm_land(j,manLand58)) <= 1e-10) diff --git a/modules/32_forestry/dynamic_feb21/declarations.gms b/modules/32_forestry/dynamic_feb21/declarations.gms index 02cfec92c9..54c2438db8 100644 --- a/modules/32_forestry/dynamic_feb21/declarations.gms +++ b/modules/32_forestry/dynamic_feb21/declarations.gms @@ -59,7 +59,6 @@ parameters p32_bii_coeff(type32,bii_class_secd,potnatveg) bii coeff (1) p32_c_density_ac_fast_forestry(t_all,j,ac) Carbon densities in plantations based on Braakhekke et al (tC per ha) p32_disturbance_loss_ftype32(t,j,type32,ac) Loss due to disturbances in all plantation type forests (mio. ha) - pcm_land_forestry(j,type32) Forestry land (mio. ha) ; positive variables @@ -74,12 +73,13 @@ positive variables v32_cost_establishment(i) Cost of establishment calculated at the current time step (mio. USD) v32_hvarea_forestry(j,ac) Harvested area from timber plantations (mio. ha) vm_prod_forestry(j,kforestry) Production of woody biomass from commercial plantations (mio. tDM per yr) - vm_land_forestry(j,type32) Forestry land (mio. ha) - ; + vm_landexpansion_forestry(j,type32) Forestry land expansion (mio. ha) + vm_landreduction_forestry(j,type32) Forestry land reduction (mio. ha) +; variables vm_cdr_aff(j,ac,aff_effect) Expected bgc (CDR) and local bph effects of afforestation depending on planning horizon (mio. tC) - ; +; equations q32_cost_total(i) Total forestry costs constraint (mio. USD) @@ -87,68 +87,71 @@ equations q32_cdr_aff(j,ac) Calculation of CDR from afforestation (mio. tC) q32_carbon(j,ag_pools,stockType) Forestry carbon stock calculation (mio. tC) q32_land_diff Aggregated difference in forestry land compared to previous timestep (mio. ha) - q32_max_aff Maximum total global afforestation (mio. ha) + q32_max_aff Maximum total global afforestation (mio. ha) q32_max_aff_reg(i) Maximum total regional afforestation (mio. ha) q32_aff_pol(j) Afforestation policy constraint (mio. ha) q32_aff_est(j) Afforestation constraint for establishment age classes (mio. ha) q32_hvarea_forestry(j,ac) Plantations area harvest (mio. ha) q32_cost_recur(i) Recurruing costs (mio. USD) q32_establishment_dynamic(i) Establishment in current time step for future demand (mio. ha) - q32_establishment_dynamic_yield(i) Regional timber yield (tDM per ha) + q32_establishment_dynamic_yield(i) Regional timber yield (tDM per ha) q32_establishment_fixed(j) Establishment in current time step for future demand (mio. ha) q32_land_expansion(j,type32,ac) Land expansion (mio. ha) q32_land_reduction(j,type32,ac) Land contraction (mio. ha) q32_cost_establishment(i) Present value of cost of establishment (mio. USD) q32_bgp_aff(j,ac) Biophysical afforestation calculation (mio. tCeq) q32_forestry_est(j,type32,ac) Distribution of forestry establishment over ac_est (mio. ha) - q32_cost_hvarea(i) Cost of harvesting timber from forests (mio. USD per yr) - q32_prod_forestry(j) Production of woody biomass from commercial plantations (mio. tDM per yr) + q32_cost_hvarea(i) Cost of harvesting timber from forests (mio. USD per yr) + q32_prod_forestry(j) Production of woody biomass from commercial plantations (mio. tDM per yr) q32_bv_aff(j,potnatveg) Biodiversity value for aff forestry land (Mha) q32_bv_ndc(j,potnatveg) Biodiversity value for ndc forestry land (Mha) q32_bv_plant(j,potnatveg) Biodiversity value for plantations (Mha) - q32_land_forestry(j,type32) Forestry land (Mha) + q32_land_expansion_forestry(j,type32) Forestry land expansion (mio. ha) + q32_land_reduction_forestry(j,type32) Forestry land reduction (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_cost_fore(t,i,type) Forestry costs (Mio USD) - ov32_cost_hvarea(t,i,type) Cost of harvesting timber from forests (mio. USD per yr) - ov32_land(t,j,type32,ac,type) Forestry land pools (mio. ha) - ov32_land_missing(t,j,type) Forestry land which can be used at extrmemly high costs in case not enough area is available for new establishment (mio. ha) - ov_landdiff_forestry(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) - ov32_cost_recur(t,i,type) Recurring forest management costs (USD per ha) - ov32_land_expansion(t,j,type32,ac,type) Forestry land expansion (mio. ha) - ov32_land_reduction(t,j,type32,ac,type) Forestry land reduction (mio. ha) - ov32_cost_establishment(t,i,type) Cost of establishment calculated at the current time step (mio. USD) - ov32_hvarea_forestry(t,j,ac,type) Harvested area from timber plantations (mio. ha) - ov_prod_forestry(t,j,kforestry,type) Production of woody biomass from commercial plantations (mio. tDM per yr) - ov_land_forestry(t,j,type32,type) Forestry land (mio. ha) - ov_cdr_aff(t,j,ac,aff_effect,type) Expected bgc (CDR) and local bph effects of afforestation depending on planning horizon (mio. tC) - oq32_cost_total(t,i,type) Total forestry costs constraint (mio. USD) - oq32_land(t,j,type) Land constraint (mio. ha) - oq32_cdr_aff(t,j,ac,type) Calculation of CDR from afforestation (mio. tC) - oq32_carbon(t,j,ag_pools,stockType,type) Forestry carbon stock calculation (mio. tC) - oq32_land_diff(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) - oq32_max_aff(t,type) Maximum total global afforestation (mio. ha) - oq32_max_aff_reg(t,i,type) Maximum total regional afforestation (mio. ha) - oq32_aff_pol(t,j,type) Afforestation policy constraint (mio. ha) - oq32_aff_est(t,j,type) Afforestation constraint for establishment age classes (mio. ha) - oq32_hvarea_forestry(t,j,ac,type) Plantations area harvest (mio. ha) - oq32_cost_recur(t,i,type) Recurruing costs (mio. USD) - oq32_establishment_dynamic(t,i,type) Establishment in current time step for future demand (mio. ha) - oq32_establishment_dynamic_yield(t,i,type) Regional timber yield (tDM per ha) - oq32_establishment_fixed(t,j,type) Establishment in current time step for future demand (mio. ha) - oq32_land_expansion(t,j,type32,ac,type) Land expansion (mio. ha) - oq32_land_reduction(t,j,type32,ac,type) Land contraction (mio. ha) - oq32_cost_establishment(t,i,type) Present value of cost of establishment (mio. USD) - oq32_bgp_aff(t,j,ac,type) Biophysical afforestation calculation (mio. tCeq) - oq32_forestry_est(t,j,type32,ac,type) Distribution of forestry establishment over ac_est (mio. ha) - oq32_cost_hvarea(t,i,type) Cost of harvesting timber from forests (mio. USD per yr) - oq32_prod_forestry(t,j,type) Production of woody biomass from commercial plantations (mio. tDM per yr) - oq32_bv_aff(t,j,potnatveg,type) Biodiversity value for aff forestry land (Mha) - oq32_bv_ndc(t,j,potnatveg,type) Biodiversity value for ndc forestry land (Mha) - oq32_bv_plant(t,j,potnatveg,type) Biodiversity value for plantations (Mha) - oq32_land_forestry(t,j,type32,type) Forestry land (Mha) + ov_cost_fore(t,i,type) Forestry costs (Mio USD) + ov32_cost_hvarea(t,i,type) Cost of harvesting timber from forests (mio. USD per yr) + ov32_land(t,j,type32,ac,type) Forestry land pools (mio. ha) + ov32_land_missing(t,j,type) Forestry land which can be used at extrmemly high costs in case not enough area is available for new establishment (mio. ha) + ov_landdiff_forestry(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) + ov32_cost_recur(t,i,type) Recurring forest management costs (USD per ha) + ov32_land_expansion(t,j,type32,ac,type) Forestry land expansion (mio. ha) + ov32_land_reduction(t,j,type32,ac,type) Forestry land reduction (mio. ha) + ov32_cost_establishment(t,i,type) Cost of establishment calculated at the current time step (mio. USD) + ov32_hvarea_forestry(t,j,ac,type) Harvested area from timber plantations (mio. ha) + ov_prod_forestry(t,j,kforestry,type) Production of woody biomass from commercial plantations (mio. tDM per yr) + ov_landexpansion_forestry(t,j,type32,type) Forestry land expansion (mio. ha) + ov_landreduction_forestry(t,j,type32,type) Forestry land reduction (mio. ha) + ov_cdr_aff(t,j,ac,aff_effect,type) Expected bgc (CDR) and local bph effects of afforestation depending on planning horizon (mio. tC) + oq32_cost_total(t,i,type) Total forestry costs constraint (mio. USD) + oq32_land(t,j,type) Land constraint (mio. ha) + oq32_cdr_aff(t,j,ac,type) Calculation of CDR from afforestation (mio. tC) + oq32_carbon(t,j,ag_pools,stockType,type) Forestry carbon stock calculation (mio. tC) + oq32_land_diff(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) + oq32_max_aff(t,type) Maximum total global afforestation (mio. ha) + oq32_max_aff_reg(t,i,type) Maximum total regional afforestation (mio. ha) + oq32_aff_pol(t,j,type) Afforestation policy constraint (mio. ha) + oq32_aff_est(t,j,type) Afforestation constraint for establishment age classes (mio. ha) + oq32_hvarea_forestry(t,j,ac,type) Plantations area harvest (mio. ha) + oq32_cost_recur(t,i,type) Recurruing costs (mio. USD) + oq32_establishment_dynamic(t,i,type) Establishment in current time step for future demand (mio. ha) + oq32_establishment_dynamic_yield(t,i,type) Regional timber yield (tDM per ha) + oq32_establishment_fixed(t,j,type) Establishment in current time step for future demand (mio. ha) + oq32_land_expansion(t,j,type32,ac,type) Land expansion (mio. ha) + oq32_land_reduction(t,j,type32,ac,type) Land contraction (mio. ha) + oq32_cost_establishment(t,i,type) Present value of cost of establishment (mio. USD) + oq32_bgp_aff(t,j,ac,type) Biophysical afforestation calculation (mio. tCeq) + oq32_forestry_est(t,j,type32,ac,type) Distribution of forestry establishment over ac_est (mio. ha) + oq32_cost_hvarea(t,i,type) Cost of harvesting timber from forests (mio. USD per yr) + oq32_prod_forestry(t,j,type) Production of woody biomass from commercial plantations (mio. tDM per yr) + oq32_bv_aff(t,j,potnatveg,type) Biodiversity value for aff forestry land (Mha) + oq32_bv_ndc(t,j,potnatveg,type) Biodiversity value for ndc forestry land (Mha) + oq32_bv_plant(t,j,potnatveg,type) Biodiversity value for plantations (Mha) + oq32_land_expansion_forestry(t,j,type32,type) Forestry land expansion (mio. ha) + oq32_land_reduction_forestry(t,j,type32,type) Forestry land reduction (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index 08a5a60016..aee0554c37 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -56,8 +56,11 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( q32_land(j2) .. vm_land(j2,"forestry") =e= sum((type32,ac), v32_land(j2,type32,ac)); - q32_land_forestry(j2,type32) .. - vm_land_forestry(j2,type32) =e= sum(ac, v32_land(j2,type32,ac)); + q32_land_expansion_forestry(j2,type32) .. + vm_landexpansion_forestry(j2,type32) =e= sum(ac_est, v32_land_expansion(j2,type32,ac_est)); + + q32_land_reduction_forestry(j2,type32) .. + vm_landreduction_forestry(j2,type32) =e= sum(ac_sub, v32_land_reduction(j2,type32,ac_sub)); *' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. diff --git a/modules/32_forestry/dynamic_feb21/postsolve.gms b/modules/32_forestry/dynamic_feb21/postsolve.gms index 71a9bd11c6..20733b8320 100644 --- a/modules/32_forestry/dynamic_feb21/postsolve.gms +++ b/modules/32_forestry/dynamic_feb21/postsolve.gms @@ -7,160 +7,167 @@ *' @code *' Exchange land information after optimization p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); -pcm_land_forestry(j,type32) = vm_land_forestry.l(j,type32); *' @stop *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_fore(t,i,"marginal") = vm_cost_fore.m(i); - ov32_cost_hvarea(t,i,"marginal") = v32_cost_hvarea.m(i); - ov32_land(t,j,type32,ac,"marginal") = v32_land.m(j,type32,ac); - ov32_land_missing(t,j,"marginal") = v32_land_missing.m(j); - ov_landdiff_forestry(t,"marginal") = vm_landdiff_forestry.m; - ov32_cost_recur(t,i,"marginal") = v32_cost_recur.m(i); - ov32_land_expansion(t,j,type32,ac,"marginal") = v32_land_expansion.m(j,type32,ac); - ov32_land_reduction(t,j,type32,ac,"marginal") = v32_land_reduction.m(j,type32,ac); - ov32_cost_establishment(t,i,"marginal") = v32_cost_establishment.m(i); - ov32_hvarea_forestry(t,j,ac,"marginal") = v32_hvarea_forestry.m(j,ac); - ov_prod_forestry(t,j,kforestry,"marginal") = vm_prod_forestry.m(j,kforestry); - ov_land_forestry(t,j,type32,"marginal") = vm_land_forestry.m(j,type32); - ov_cdr_aff(t,j,ac,aff_effect,"marginal") = vm_cdr_aff.m(j,ac,aff_effect); - oq32_cost_total(t,i,"marginal") = q32_cost_total.m(i); - oq32_land(t,j,"marginal") = q32_land.m(j); - oq32_cdr_aff(t,j,ac,"marginal") = q32_cdr_aff.m(j,ac); - oq32_carbon(t,j,ag_pools,stockType,"marginal") = q32_carbon.m(j,ag_pools,stockType); - oq32_land_diff(t,"marginal") = q32_land_diff.m; - oq32_max_aff(t,"marginal") = q32_max_aff.m; - oq32_max_aff_reg(t,i,"marginal") = q32_max_aff_reg.m(i); - oq32_aff_pol(t,j,"marginal") = q32_aff_pol.m(j); - oq32_aff_est(t,j,"marginal") = q32_aff_est.m(j); - oq32_hvarea_forestry(t,j,ac,"marginal") = q32_hvarea_forestry.m(j,ac); - oq32_cost_recur(t,i,"marginal") = q32_cost_recur.m(i); - oq32_establishment_dynamic(t,i,"marginal") = q32_establishment_dynamic.m(i); - oq32_establishment_dynamic_yield(t,i,"marginal") = q32_establishment_dynamic_yield.m(i); - oq32_establishment_fixed(t,j,"marginal") = q32_establishment_fixed.m(j); - oq32_land_expansion(t,j,type32,ac,"marginal") = q32_land_expansion.m(j,type32,ac); - oq32_land_reduction(t,j,type32,ac,"marginal") = q32_land_reduction.m(j,type32,ac); - oq32_cost_establishment(t,i,"marginal") = q32_cost_establishment.m(i); - oq32_bgp_aff(t,j,ac,"marginal") = q32_bgp_aff.m(j,ac); - oq32_forestry_est(t,j,type32,ac,"marginal") = q32_forestry_est.m(j,type32,ac); - oq32_cost_hvarea(t,i,"marginal") = q32_cost_hvarea.m(i); - oq32_prod_forestry(t,j,"marginal") = q32_prod_forestry.m(j); - oq32_bv_aff(t,j,potnatveg,"marginal") = q32_bv_aff.m(j,potnatveg); - oq32_bv_ndc(t,j,potnatveg,"marginal") = q32_bv_ndc.m(j,potnatveg); - oq32_bv_plant(t,j,potnatveg,"marginal") = q32_bv_plant.m(j,potnatveg); - oq32_land_forestry(t,j,type32,"marginal") = q32_land_forestry.m(j,type32); - ov_cost_fore(t,i,"level") = vm_cost_fore.l(i); - ov32_cost_hvarea(t,i,"level") = v32_cost_hvarea.l(i); - ov32_land(t,j,type32,ac,"level") = v32_land.l(j,type32,ac); - ov32_land_missing(t,j,"level") = v32_land_missing.l(j); - ov_landdiff_forestry(t,"level") = vm_landdiff_forestry.l; - ov32_cost_recur(t,i,"level") = v32_cost_recur.l(i); - ov32_land_expansion(t,j,type32,ac,"level") = v32_land_expansion.l(j,type32,ac); - ov32_land_reduction(t,j,type32,ac,"level") = v32_land_reduction.l(j,type32,ac); - ov32_cost_establishment(t,i,"level") = v32_cost_establishment.l(i); - ov32_hvarea_forestry(t,j,ac,"level") = v32_hvarea_forestry.l(j,ac); - ov_prod_forestry(t,j,kforestry,"level") = vm_prod_forestry.l(j,kforestry); - ov_land_forestry(t,j,type32,"level") = vm_land_forestry.l(j,type32); - ov_cdr_aff(t,j,ac,aff_effect,"level") = vm_cdr_aff.l(j,ac,aff_effect); - oq32_cost_total(t,i,"level") = q32_cost_total.l(i); - oq32_land(t,j,"level") = q32_land.l(j); - oq32_cdr_aff(t,j,ac,"level") = q32_cdr_aff.l(j,ac); - oq32_carbon(t,j,ag_pools,stockType,"level") = q32_carbon.l(j,ag_pools,stockType); - oq32_land_diff(t,"level") = q32_land_diff.l; - oq32_max_aff(t,"level") = q32_max_aff.l; - oq32_max_aff_reg(t,i,"level") = q32_max_aff_reg.l(i); - oq32_aff_pol(t,j,"level") = q32_aff_pol.l(j); - oq32_aff_est(t,j,"level") = q32_aff_est.l(j); - oq32_hvarea_forestry(t,j,ac,"level") = q32_hvarea_forestry.l(j,ac); - oq32_cost_recur(t,i,"level") = q32_cost_recur.l(i); - oq32_establishment_dynamic(t,i,"level") = q32_establishment_dynamic.l(i); - oq32_establishment_dynamic_yield(t,i,"level") = q32_establishment_dynamic_yield.l(i); - oq32_establishment_fixed(t,j,"level") = q32_establishment_fixed.l(j); - oq32_land_expansion(t,j,type32,ac,"level") = q32_land_expansion.l(j,type32,ac); - oq32_land_reduction(t,j,type32,ac,"level") = q32_land_reduction.l(j,type32,ac); - oq32_cost_establishment(t,i,"level") = q32_cost_establishment.l(i); - oq32_bgp_aff(t,j,ac,"level") = q32_bgp_aff.l(j,ac); - oq32_forestry_est(t,j,type32,ac,"level") = q32_forestry_est.l(j,type32,ac); - oq32_cost_hvarea(t,i,"level") = q32_cost_hvarea.l(i); - oq32_prod_forestry(t,j,"level") = q32_prod_forestry.l(j); - oq32_bv_aff(t,j,potnatveg,"level") = q32_bv_aff.l(j,potnatveg); - oq32_bv_ndc(t,j,potnatveg,"level") = q32_bv_ndc.l(j,potnatveg); - oq32_bv_plant(t,j,potnatveg,"level") = q32_bv_plant.l(j,potnatveg); - oq32_land_forestry(t,j,type32,"level") = q32_land_forestry.l(j,type32); - ov_cost_fore(t,i,"upper") = vm_cost_fore.up(i); - ov32_cost_hvarea(t,i,"upper") = v32_cost_hvarea.up(i); - ov32_land(t,j,type32,ac,"upper") = v32_land.up(j,type32,ac); - ov32_land_missing(t,j,"upper") = v32_land_missing.up(j); - ov_landdiff_forestry(t,"upper") = vm_landdiff_forestry.up; - ov32_cost_recur(t,i,"upper") = v32_cost_recur.up(i); - ov32_land_expansion(t,j,type32,ac,"upper") = v32_land_expansion.up(j,type32,ac); - ov32_land_reduction(t,j,type32,ac,"upper") = v32_land_reduction.up(j,type32,ac); - ov32_cost_establishment(t,i,"upper") = v32_cost_establishment.up(i); - ov32_hvarea_forestry(t,j,ac,"upper") = v32_hvarea_forestry.up(j,ac); - ov_prod_forestry(t,j,kforestry,"upper") = vm_prod_forestry.up(j,kforestry); - ov_land_forestry(t,j,type32,"upper") = vm_land_forestry.up(j,type32); - ov_cdr_aff(t,j,ac,aff_effect,"upper") = vm_cdr_aff.up(j,ac,aff_effect); - oq32_cost_total(t,i,"upper") = q32_cost_total.up(i); - oq32_land(t,j,"upper") = q32_land.up(j); - oq32_cdr_aff(t,j,ac,"upper") = q32_cdr_aff.up(j,ac); - oq32_carbon(t,j,ag_pools,stockType,"upper") = q32_carbon.up(j,ag_pools,stockType); - oq32_land_diff(t,"upper") = q32_land_diff.up; - oq32_max_aff(t,"upper") = q32_max_aff.up; - oq32_max_aff_reg(t,i,"upper") = q32_max_aff_reg.up(i); - oq32_aff_pol(t,j,"upper") = q32_aff_pol.up(j); - oq32_aff_est(t,j,"upper") = q32_aff_est.up(j); - oq32_hvarea_forestry(t,j,ac,"upper") = q32_hvarea_forestry.up(j,ac); - oq32_cost_recur(t,i,"upper") = q32_cost_recur.up(i); - oq32_establishment_dynamic(t,i,"upper") = q32_establishment_dynamic.up(i); - oq32_establishment_dynamic_yield(t,i,"upper") = q32_establishment_dynamic_yield.up(i); - oq32_establishment_fixed(t,j,"upper") = q32_establishment_fixed.up(j); - oq32_land_expansion(t,j,type32,ac,"upper") = q32_land_expansion.up(j,type32,ac); - oq32_land_reduction(t,j,type32,ac,"upper") = q32_land_reduction.up(j,type32,ac); - oq32_cost_establishment(t,i,"upper") = q32_cost_establishment.up(i); - oq32_bgp_aff(t,j,ac,"upper") = q32_bgp_aff.up(j,ac); - oq32_forestry_est(t,j,type32,ac,"upper") = q32_forestry_est.up(j,type32,ac); - oq32_cost_hvarea(t,i,"upper") = q32_cost_hvarea.up(i); - oq32_prod_forestry(t,j,"upper") = q32_prod_forestry.up(j); - oq32_bv_aff(t,j,potnatveg,"upper") = q32_bv_aff.up(j,potnatveg); - oq32_bv_ndc(t,j,potnatveg,"upper") = q32_bv_ndc.up(j,potnatveg); - oq32_bv_plant(t,j,potnatveg,"upper") = q32_bv_plant.up(j,potnatveg); - oq32_land_forestry(t,j,type32,"upper") = q32_land_forestry.up(j,type32); - ov_cost_fore(t,i,"lower") = vm_cost_fore.lo(i); - ov32_cost_hvarea(t,i,"lower") = v32_cost_hvarea.lo(i); - ov32_land(t,j,type32,ac,"lower") = v32_land.lo(j,type32,ac); - ov32_land_missing(t,j,"lower") = v32_land_missing.lo(j); - ov_landdiff_forestry(t,"lower") = vm_landdiff_forestry.lo; - ov32_cost_recur(t,i,"lower") = v32_cost_recur.lo(i); - ov32_land_expansion(t,j,type32,ac,"lower") = v32_land_expansion.lo(j,type32,ac); - ov32_land_reduction(t,j,type32,ac,"lower") = v32_land_reduction.lo(j,type32,ac); - ov32_cost_establishment(t,i,"lower") = v32_cost_establishment.lo(i); - ov32_hvarea_forestry(t,j,ac,"lower") = v32_hvarea_forestry.lo(j,ac); - ov_prod_forestry(t,j,kforestry,"lower") = vm_prod_forestry.lo(j,kforestry); - ov_land_forestry(t,j,type32,"lower") = vm_land_forestry.lo(j,type32); - ov_cdr_aff(t,j,ac,aff_effect,"lower") = vm_cdr_aff.lo(j,ac,aff_effect); - oq32_cost_total(t,i,"lower") = q32_cost_total.lo(i); - oq32_land(t,j,"lower") = q32_land.lo(j); - oq32_cdr_aff(t,j,ac,"lower") = q32_cdr_aff.lo(j,ac); - oq32_carbon(t,j,ag_pools,stockType,"lower") = q32_carbon.lo(j,ag_pools,stockType); - oq32_land_diff(t,"lower") = q32_land_diff.lo; - oq32_max_aff(t,"lower") = q32_max_aff.lo; - oq32_max_aff_reg(t,i,"lower") = q32_max_aff_reg.lo(i); - oq32_aff_pol(t,j,"lower") = q32_aff_pol.lo(j); - oq32_aff_est(t,j,"lower") = q32_aff_est.lo(j); - oq32_hvarea_forestry(t,j,ac,"lower") = q32_hvarea_forestry.lo(j,ac); - oq32_cost_recur(t,i,"lower") = q32_cost_recur.lo(i); - oq32_establishment_dynamic(t,i,"lower") = q32_establishment_dynamic.lo(i); - oq32_establishment_dynamic_yield(t,i,"lower") = q32_establishment_dynamic_yield.lo(i); - oq32_establishment_fixed(t,j,"lower") = q32_establishment_fixed.lo(j); - oq32_land_expansion(t,j,type32,ac,"lower") = q32_land_expansion.lo(j,type32,ac); - oq32_land_reduction(t,j,type32,ac,"lower") = q32_land_reduction.lo(j,type32,ac); - oq32_cost_establishment(t,i,"lower") = q32_cost_establishment.lo(i); - oq32_bgp_aff(t,j,ac,"lower") = q32_bgp_aff.lo(j,ac); - oq32_forestry_est(t,j,type32,ac,"lower") = q32_forestry_est.lo(j,type32,ac); - oq32_cost_hvarea(t,i,"lower") = q32_cost_hvarea.lo(i); - oq32_prod_forestry(t,j,"lower") = q32_prod_forestry.lo(j); - oq32_bv_aff(t,j,potnatveg,"lower") = q32_bv_aff.lo(j,potnatveg); - oq32_bv_ndc(t,j,potnatveg,"lower") = q32_bv_ndc.lo(j,potnatveg); - oq32_bv_plant(t,j,potnatveg,"lower") = q32_bv_plant.lo(j,potnatveg); - oq32_land_forestry(t,j,type32,"lower") = q32_land_forestry.lo(j,type32); + ov_cost_fore(t,i,"marginal") = vm_cost_fore.m(i); + ov32_cost_hvarea(t,i,"marginal") = v32_cost_hvarea.m(i); + ov32_land(t,j,type32,ac,"marginal") = v32_land.m(j,type32,ac); + ov32_land_missing(t,j,"marginal") = v32_land_missing.m(j); + ov_landdiff_forestry(t,"marginal") = vm_landdiff_forestry.m; + ov32_cost_recur(t,i,"marginal") = v32_cost_recur.m(i); + ov32_land_expansion(t,j,type32,ac,"marginal") = v32_land_expansion.m(j,type32,ac); + ov32_land_reduction(t,j,type32,ac,"marginal") = v32_land_reduction.m(j,type32,ac); + ov32_cost_establishment(t,i,"marginal") = v32_cost_establishment.m(i); + ov32_hvarea_forestry(t,j,ac,"marginal") = v32_hvarea_forestry.m(j,ac); + ov_prod_forestry(t,j,kforestry,"marginal") = vm_prod_forestry.m(j,kforestry); + ov_landexpansion_forestry(t,j,type32,"marginal") = vm_landexpansion_forestry.m(j,type32); + ov_landreduction_forestry(t,j,type32,"marginal") = vm_landreduction_forestry.m(j,type32); + ov_cdr_aff(t,j,ac,aff_effect,"marginal") = vm_cdr_aff.m(j,ac,aff_effect); + oq32_cost_total(t,i,"marginal") = q32_cost_total.m(i); + oq32_land(t,j,"marginal") = q32_land.m(j); + oq32_cdr_aff(t,j,ac,"marginal") = q32_cdr_aff.m(j,ac); + oq32_carbon(t,j,ag_pools,stockType,"marginal") = q32_carbon.m(j,ag_pools,stockType); + oq32_land_diff(t,"marginal") = q32_land_diff.m; + oq32_max_aff(t,"marginal") = q32_max_aff.m; + oq32_max_aff_reg(t,i,"marginal") = q32_max_aff_reg.m(i); + oq32_aff_pol(t,j,"marginal") = q32_aff_pol.m(j); + oq32_aff_est(t,j,"marginal") = q32_aff_est.m(j); + oq32_hvarea_forestry(t,j,ac,"marginal") = q32_hvarea_forestry.m(j,ac); + oq32_cost_recur(t,i,"marginal") = q32_cost_recur.m(i); + oq32_establishment_dynamic(t,i,"marginal") = q32_establishment_dynamic.m(i); + oq32_establishment_dynamic_yield(t,i,"marginal") = q32_establishment_dynamic_yield.m(i); + oq32_establishment_fixed(t,j,"marginal") = q32_establishment_fixed.m(j); + oq32_land_expansion(t,j,type32,ac,"marginal") = q32_land_expansion.m(j,type32,ac); + oq32_land_reduction(t,j,type32,ac,"marginal") = q32_land_reduction.m(j,type32,ac); + oq32_cost_establishment(t,i,"marginal") = q32_cost_establishment.m(i); + oq32_bgp_aff(t,j,ac,"marginal") = q32_bgp_aff.m(j,ac); + oq32_forestry_est(t,j,type32,ac,"marginal") = q32_forestry_est.m(j,type32,ac); + oq32_cost_hvarea(t,i,"marginal") = q32_cost_hvarea.m(i); + oq32_prod_forestry(t,j,"marginal") = q32_prod_forestry.m(j); + oq32_bv_aff(t,j,potnatveg,"marginal") = q32_bv_aff.m(j,potnatveg); + oq32_bv_ndc(t,j,potnatveg,"marginal") = q32_bv_ndc.m(j,potnatveg); + oq32_bv_plant(t,j,potnatveg,"marginal") = q32_bv_plant.m(j,potnatveg); + oq32_land_expansion_forestry(t,j,type32,"marginal") = q32_land_expansion_forestry.m(j,type32); + oq32_land_reduction_forestry(t,j,type32,"marginal") = q32_land_reduction_forestry.m(j,type32); + ov_cost_fore(t,i,"level") = vm_cost_fore.l(i); + ov32_cost_hvarea(t,i,"level") = v32_cost_hvarea.l(i); + ov32_land(t,j,type32,ac,"level") = v32_land.l(j,type32,ac); + ov32_land_missing(t,j,"level") = v32_land_missing.l(j); + ov_landdiff_forestry(t,"level") = vm_landdiff_forestry.l; + ov32_cost_recur(t,i,"level") = v32_cost_recur.l(i); + ov32_land_expansion(t,j,type32,ac,"level") = v32_land_expansion.l(j,type32,ac); + ov32_land_reduction(t,j,type32,ac,"level") = v32_land_reduction.l(j,type32,ac); + ov32_cost_establishment(t,i,"level") = v32_cost_establishment.l(i); + ov32_hvarea_forestry(t,j,ac,"level") = v32_hvarea_forestry.l(j,ac); + ov_prod_forestry(t,j,kforestry,"level") = vm_prod_forestry.l(j,kforestry); + ov_landexpansion_forestry(t,j,type32,"level") = vm_landexpansion_forestry.l(j,type32); + ov_landreduction_forestry(t,j,type32,"level") = vm_landreduction_forestry.l(j,type32); + ov_cdr_aff(t,j,ac,aff_effect,"level") = vm_cdr_aff.l(j,ac,aff_effect); + oq32_cost_total(t,i,"level") = q32_cost_total.l(i); + oq32_land(t,j,"level") = q32_land.l(j); + oq32_cdr_aff(t,j,ac,"level") = q32_cdr_aff.l(j,ac); + oq32_carbon(t,j,ag_pools,stockType,"level") = q32_carbon.l(j,ag_pools,stockType); + oq32_land_diff(t,"level") = q32_land_diff.l; + oq32_max_aff(t,"level") = q32_max_aff.l; + oq32_max_aff_reg(t,i,"level") = q32_max_aff_reg.l(i); + oq32_aff_pol(t,j,"level") = q32_aff_pol.l(j); + oq32_aff_est(t,j,"level") = q32_aff_est.l(j); + oq32_hvarea_forestry(t,j,ac,"level") = q32_hvarea_forestry.l(j,ac); + oq32_cost_recur(t,i,"level") = q32_cost_recur.l(i); + oq32_establishment_dynamic(t,i,"level") = q32_establishment_dynamic.l(i); + oq32_establishment_dynamic_yield(t,i,"level") = q32_establishment_dynamic_yield.l(i); + oq32_establishment_fixed(t,j,"level") = q32_establishment_fixed.l(j); + oq32_land_expansion(t,j,type32,ac,"level") = q32_land_expansion.l(j,type32,ac); + oq32_land_reduction(t,j,type32,ac,"level") = q32_land_reduction.l(j,type32,ac); + oq32_cost_establishment(t,i,"level") = q32_cost_establishment.l(i); + oq32_bgp_aff(t,j,ac,"level") = q32_bgp_aff.l(j,ac); + oq32_forestry_est(t,j,type32,ac,"level") = q32_forestry_est.l(j,type32,ac); + oq32_cost_hvarea(t,i,"level") = q32_cost_hvarea.l(i); + oq32_prod_forestry(t,j,"level") = q32_prod_forestry.l(j); + oq32_bv_aff(t,j,potnatveg,"level") = q32_bv_aff.l(j,potnatveg); + oq32_bv_ndc(t,j,potnatveg,"level") = q32_bv_ndc.l(j,potnatveg); + oq32_bv_plant(t,j,potnatveg,"level") = q32_bv_plant.l(j,potnatveg); + oq32_land_expansion_forestry(t,j,type32,"level") = q32_land_expansion_forestry.l(j,type32); + oq32_land_reduction_forestry(t,j,type32,"level") = q32_land_reduction_forestry.l(j,type32); + ov_cost_fore(t,i,"upper") = vm_cost_fore.up(i); + ov32_cost_hvarea(t,i,"upper") = v32_cost_hvarea.up(i); + ov32_land(t,j,type32,ac,"upper") = v32_land.up(j,type32,ac); + ov32_land_missing(t,j,"upper") = v32_land_missing.up(j); + ov_landdiff_forestry(t,"upper") = vm_landdiff_forestry.up; + ov32_cost_recur(t,i,"upper") = v32_cost_recur.up(i); + ov32_land_expansion(t,j,type32,ac,"upper") = v32_land_expansion.up(j,type32,ac); + ov32_land_reduction(t,j,type32,ac,"upper") = v32_land_reduction.up(j,type32,ac); + ov32_cost_establishment(t,i,"upper") = v32_cost_establishment.up(i); + ov32_hvarea_forestry(t,j,ac,"upper") = v32_hvarea_forestry.up(j,ac); + ov_prod_forestry(t,j,kforestry,"upper") = vm_prod_forestry.up(j,kforestry); + ov_landexpansion_forestry(t,j,type32,"upper") = vm_landexpansion_forestry.up(j,type32); + ov_landreduction_forestry(t,j,type32,"upper") = vm_landreduction_forestry.up(j,type32); + ov_cdr_aff(t,j,ac,aff_effect,"upper") = vm_cdr_aff.up(j,ac,aff_effect); + oq32_cost_total(t,i,"upper") = q32_cost_total.up(i); + oq32_land(t,j,"upper") = q32_land.up(j); + oq32_cdr_aff(t,j,ac,"upper") = q32_cdr_aff.up(j,ac); + oq32_carbon(t,j,ag_pools,stockType,"upper") = q32_carbon.up(j,ag_pools,stockType); + oq32_land_diff(t,"upper") = q32_land_diff.up; + oq32_max_aff(t,"upper") = q32_max_aff.up; + oq32_max_aff_reg(t,i,"upper") = q32_max_aff_reg.up(i); + oq32_aff_pol(t,j,"upper") = q32_aff_pol.up(j); + oq32_aff_est(t,j,"upper") = q32_aff_est.up(j); + oq32_hvarea_forestry(t,j,ac,"upper") = q32_hvarea_forestry.up(j,ac); + oq32_cost_recur(t,i,"upper") = q32_cost_recur.up(i); + oq32_establishment_dynamic(t,i,"upper") = q32_establishment_dynamic.up(i); + oq32_establishment_dynamic_yield(t,i,"upper") = q32_establishment_dynamic_yield.up(i); + oq32_establishment_fixed(t,j,"upper") = q32_establishment_fixed.up(j); + oq32_land_expansion(t,j,type32,ac,"upper") = q32_land_expansion.up(j,type32,ac); + oq32_land_reduction(t,j,type32,ac,"upper") = q32_land_reduction.up(j,type32,ac); + oq32_cost_establishment(t,i,"upper") = q32_cost_establishment.up(i); + oq32_bgp_aff(t,j,ac,"upper") = q32_bgp_aff.up(j,ac); + oq32_forestry_est(t,j,type32,ac,"upper") = q32_forestry_est.up(j,type32,ac); + oq32_cost_hvarea(t,i,"upper") = q32_cost_hvarea.up(i); + oq32_prod_forestry(t,j,"upper") = q32_prod_forestry.up(j); + oq32_bv_aff(t,j,potnatveg,"upper") = q32_bv_aff.up(j,potnatveg); + oq32_bv_ndc(t,j,potnatveg,"upper") = q32_bv_ndc.up(j,potnatveg); + oq32_bv_plant(t,j,potnatveg,"upper") = q32_bv_plant.up(j,potnatveg); + oq32_land_expansion_forestry(t,j,type32,"upper") = q32_land_expansion_forestry.up(j,type32); + oq32_land_reduction_forestry(t,j,type32,"upper") = q32_land_reduction_forestry.up(j,type32); + ov_cost_fore(t,i,"lower") = vm_cost_fore.lo(i); + ov32_cost_hvarea(t,i,"lower") = v32_cost_hvarea.lo(i); + ov32_land(t,j,type32,ac,"lower") = v32_land.lo(j,type32,ac); + ov32_land_missing(t,j,"lower") = v32_land_missing.lo(j); + ov_landdiff_forestry(t,"lower") = vm_landdiff_forestry.lo; + ov32_cost_recur(t,i,"lower") = v32_cost_recur.lo(i); + ov32_land_expansion(t,j,type32,ac,"lower") = v32_land_expansion.lo(j,type32,ac); + ov32_land_reduction(t,j,type32,ac,"lower") = v32_land_reduction.lo(j,type32,ac); + ov32_cost_establishment(t,i,"lower") = v32_cost_establishment.lo(i); + ov32_hvarea_forestry(t,j,ac,"lower") = v32_hvarea_forestry.lo(j,ac); + ov_prod_forestry(t,j,kforestry,"lower") = vm_prod_forestry.lo(j,kforestry); + ov_landexpansion_forestry(t,j,type32,"lower") = vm_landexpansion_forestry.lo(j,type32); + ov_landreduction_forestry(t,j,type32,"lower") = vm_landreduction_forestry.lo(j,type32); + ov_cdr_aff(t,j,ac,aff_effect,"lower") = vm_cdr_aff.lo(j,ac,aff_effect); + oq32_cost_total(t,i,"lower") = q32_cost_total.lo(i); + oq32_land(t,j,"lower") = q32_land.lo(j); + oq32_cdr_aff(t,j,ac,"lower") = q32_cdr_aff.lo(j,ac); + oq32_carbon(t,j,ag_pools,stockType,"lower") = q32_carbon.lo(j,ag_pools,stockType); + oq32_land_diff(t,"lower") = q32_land_diff.lo; + oq32_max_aff(t,"lower") = q32_max_aff.lo; + oq32_max_aff_reg(t,i,"lower") = q32_max_aff_reg.lo(i); + oq32_aff_pol(t,j,"lower") = q32_aff_pol.lo(j); + oq32_aff_est(t,j,"lower") = q32_aff_est.lo(j); + oq32_hvarea_forestry(t,j,ac,"lower") = q32_hvarea_forestry.lo(j,ac); + oq32_cost_recur(t,i,"lower") = q32_cost_recur.lo(i); + oq32_establishment_dynamic(t,i,"lower") = q32_establishment_dynamic.lo(i); + oq32_establishment_dynamic_yield(t,i,"lower") = q32_establishment_dynamic_yield.lo(i); + oq32_establishment_fixed(t,j,"lower") = q32_establishment_fixed.lo(j); + oq32_land_expansion(t,j,type32,ac,"lower") = q32_land_expansion.lo(j,type32,ac); + oq32_land_reduction(t,j,type32,ac,"lower") = q32_land_reduction.lo(j,type32,ac); + oq32_cost_establishment(t,i,"lower") = q32_cost_establishment.lo(i); + oq32_bgp_aff(t,j,ac,"lower") = q32_bgp_aff.lo(j,ac); + oq32_forestry_est(t,j,type32,ac,"lower") = q32_forestry_est.lo(j,type32,ac); + oq32_cost_hvarea(t,i,"lower") = q32_cost_hvarea.lo(i); + oq32_prod_forestry(t,j,"lower") = q32_prod_forestry.lo(j); + oq32_bv_aff(t,j,potnatveg,"lower") = q32_bv_aff.lo(j,potnatveg); + oq32_bv_ndc(t,j,potnatveg,"lower") = q32_bv_ndc.lo(j,potnatveg); + oq32_bv_plant(t,j,potnatveg,"lower") = q32_bv_plant.lo(j,potnatveg); + oq32_land_expansion_forestry(t,j,type32,"lower") = q32_land_expansion_forestry.lo(j,type32); + oq32_land_reduction_forestry(t,j,type32,"lower") = q32_land_reduction_forestry.lo(j,type32); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/32_forestry/dynamic_feb21/preloop.gms b/modules/32_forestry/dynamic_feb21/preloop.gms index a1754a92d2..08088d1a86 100644 --- a/modules/32_forestry/dynamic_feb21/preloop.gms +++ b/modules/32_forestry/dynamic_feb21/preloop.gms @@ -215,9 +215,6 @@ loop(j, p32_land_start_ac(j,"ndc","ac0") = p32_land_start_ac(j,"ndc","ac0") + (pm_land_start(j,"forestry") - sum((type32,ac),p32_land_start_ac(j,type32,ac))); ); ); -** Initialization of land -vm_land_forestry.l(j,type32) = sum(ac, p32_land_start_ac(j,type32,ac)); -pcm_land_forestry(j,type32) = vm_land_forestry.l(j,type32); *** NPI/NDC policies BEGIN ** Afforestation policies NPI and NDCs diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 459ceddd89..69c878cfa3 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -15,6 +15,7 @@ ac_sub(ac) = yes$(ord(ac) > (m_yeardiff_forestry(t)/5)); *Reduction of ac_est is not possible. v32_hvarea_forestry.fx(j,ac_est) = 0; v32_land_reduction.fx(j,type32,ac_est) = 0; +v32_land_expansion.fx(j,type32,ac_sub) = 0; ** START ndc ** * calc NPI/NDC afforestation per time step based on forest stock change diff --git a/modules/58_peatland/off/not_used.txt b/modules/58_peatland/off/not_used.txt index 8b45b33bd6..01c510fae9 100644 --- a/modules/58_peatland/off/not_used.txt +++ b/modules/58_peatland/off/not_used.txt @@ -3,5 +3,7 @@ vm_land, input, not used pcm_land, input, not used pm_interest, input, not used pm_climate_class, input, not used -vm_land_forestry, input, not used -pcm_land_forestry, input, not used +vm_landexpansion, input, not used +vm_landreduction, input, not used +vm_landexpansion_forestry, input, not used +vm_landreduction_forestry, input, not used diff --git a/modules/58_peatland/on/not_used.txt b/modules/58_peatland/on/not_used.txt index a2be78997a..9a52df7eb8 100644 --- a/modules/58_peatland/on/not_used.txt +++ b/modules/58_peatland/on/not_used.txt @@ -1,3 +1,5 @@ name, type, reason -vm_land_forestry, input, not used -pcm_land_forestry, input, not used +vm_landexpansion, input, not used +vm_landreduction, input, not used +vm_landexpansion_forestry, input, not used +vm_landreduction_forestry, input, not used diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index 294c7674a7..2dd283b5ab 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -6,61 +6,69 @@ *** | Contact: magpie@pik-potsdam.de parameters - p58_scaling_factor(j) Scaling factor for managed peatland (1) + p58_scaling_factor_exp(t,j) Scaling factor for managed peatland expansion (1) + p58_scaling_factor_red(t,j) Scaling factor for managed peatland reduction (1) pc58_peatland(j,land58) Peatland area (mio. ha) p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) i58_cost_rewet_onetime(t) One-time costs for peatland restoration (USD05MER per ha) i58_cost_degrad_recur(t) Recurring costs for degraded peatland (USD05MER per ha) i58_cost_degrad_onetime(t) One-time costs for peatland degradation (USD05MER per ha) + p58_weight(t,j,manPeat58) Weight for distribution of total peatland changes to managed peatland categories (1) ; equations - q58_peatland(j) Constraint for peatland area (mio. ha) - q58_expansion(j,land58) Peatland expansion (mio. ha) - q58_reduction(j,land58) Peatland reduction (mio. ha) - q58_peatland_crop(j) Degraded peatland used as cropland (mio. ha) - q58_peatland_past(j) Degraded peatland used as pasture (mio. ha) - q58_peatland_forestry(j) Degraded peatland used for forestry (mio. ha) - q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - q58_peatland_cost_annuity(j) Annuity costs of peatland conversion in the current timestep (mio. USD05MER per yr) + q58_peatland(j) Constraint for total peatland area (mio. ha) + q58_peatlandChange(j,land58) Peatland area Change (mio. ha) + q58_peatlandMan(j,manPeat58) Change of managed peatland area (mio. ha) + q58_peatlandRewet(j) Change of rewetted peatland area (mio. ha) + q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + q58_peatland_cost_annuity_intact(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + q58_peatland_cost_annuity_rewet(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) q58_peatland_emis_detail(j,land58,emis58) Detailed GHG emissions from peatlands (Tg per yr) - q58_peatland_emis(i,poll58) GHG emissions from managed peatland (Tg per yr) + q58_peatland_emis(i,poll58) GHG emissions from managed peatland (Tg per yr) + q58_manLandExp(j,manLand58) Managed land expansion (mio. ha) + q58_manLandRed(j,manLand58) Managed land reduction (mio. ha) ; variables - vm_peatland_cost(j) One-time and recurring cost of managed peatland including artifical balance cost (mio. USD05MER per yr) - v58_peatland_cost(j) One-time and recurring cost of managed peatland (mio. USD05MER per yr) - v58_peatland_cost_annuity(j) Annuity costs of managed peatland expansion in the current timestep (mio. USD05MER per yr) + vm_peatland_cost(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + v58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) v58_peatland_emis(j,land58,emis58) Detailed GHG peatland GHG emissions (Tg per yr) + v58_peatlandChange(j,land58) Peatland area change (mio. ha) ; positive variables - v58_expansion(j,land58) Peatland expansion (mio. ha) - v58_reduction(j,land58) Peatland reduction (mio. ha) - v58_peatland(j,land58) Managed peatland (mio. ha) + v58_peatland_cost_annuity_intact(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + v58_peatland_cost_annuity_rewet(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + v58_peatland(j,land58) Peatland area (mio. ha) + v58_manLandExp(j,manLand58) Managed land expansion (mio. ha) + v58_manLandRed(j,manLand58) Managed land reduction (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_peatland_cost(t,j,type) One-time and recurring cost of managed peatland including artifical balance cost (mio. USD05MER per yr) - ov58_peatland_cost(t,j,type) One-time and recurring cost of managed peatland (mio. USD05MER per yr) - ov58_peatland_cost_annuity(t,j,type) Annuity costs of managed peatland expansion in the current timestep (mio. USD05MER per yr) + ov_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + ov58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) ov58_peatland_emis(t,j,land58,emis58,type) Detailed GHG peatland GHG emissions (Tg per yr) - ov58_expansion(t,j,land58,type) Peatland expansion (mio. ha) - ov58_reduction(t,j,land58,type) Peatland reduction (mio. ha) - ov58_peatland(t,j,land58,type) Managed peatland (mio. ha) - oq58_peatland(t,j,type) Constraint for peatland area (mio. ha) - oq58_expansion(t,j,land58,type) Peatland expansion (mio. ha) - oq58_reduction(t,j,land58,type) Peatland reduction (mio. ha) - oq58_peatland_crop(t,j,type) Degraded peatland used as cropland (mio. ha) - oq58_peatland_past(t,j,type) Degraded peatland used as pasture (mio. ha) - oq58_peatland_forestry(t,j,type) Degraded peatland used for forestry (mio. ha) + ov58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) + ov58_peatland_cost_annuity_intact(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + ov58_peatland_cost_annuity_rewet(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + ov58_peatland(t,j,land58,type) Peatland area (mio. ha) + ov58_manLandExp(t,j,manLand58,type) Managed land expansion (mio. ha) + ov58_manLandRed(t,j,manLand58,type) Managed land reduction (mio. ha) + oq58_peatland(t,j,type) Constraint for total peatland area (mio. ha) + oq58_peatlandChange(t,j,land58,type) Peatland area Change (mio. ha) + oq58_peatlandMan(t,j,manPeat58,type) Change of managed peatland area (mio. ha) + oq58_peatlandRewet(t,j,type) Change of rewetted peatland area (mio. ha) oq58_peatland_cost_full(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - oq58_peatland_cost_annuity(t,j,type) Annuity costs of peatland conversion in the current timestep (mio. USD05MER per yr) + oq58_peatland_cost_annuity_intact(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + oq58_peatland_cost_annuity_rewet(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) oq58_peatland_emis_detail(t,j,land58,emis58,type) Detailed GHG emissions from peatlands (Tg per yr) oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) + oq58_manLandExp(t,j,manLand58,type) Managed land expansion (mio. ha) + oq58_manLandRed(t,j,manLand58,type) Managed land reduction (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index da3266fc7f..69f1676262 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -7,42 +7,50 @@ *' @equations -*' Constraint for constant total peatland area: +*' Constraint for constant total peatland area over time: - q58_peatland(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + q58_peatland(j2) .. sum(land58, v58_peatland(j2,land58)) =e= sum(land58, pc58_peatland(j2,land58)); -*' Constraints for peatland area expansion and reduction: +*' Peatland area change: - q58_expansion(j2,land58) .. - v58_expansion(j2,land58) =g= v58_peatland(j2,land58)-pc58_peatland(j2,land58); + q58_peatlandChange(j2,land58) .. + v58_peatlandChange(j2,land58) =e= v58_peatland(j2,land58)-pc58_peatland(j2,land58); - q58_reduction(j2,land58) .. - v58_reduction(j2,land58) =g= pc58_peatland(j2,land58)-v58_peatland(j2,land58); - -*' Future peatland dynamics (`v58_peatland`) depend on changes in managed land -*' (`vm_land-pcm_land`, `vm_land_forestry-pcm_land_forestry`), -*' multiplied with the peatland scaling factor (`p58_scaling_factor`) and an adjustment term for cells where -*' the initial peatland area is inconsistent with the scaling factor (see marco m_peatland for details). -*' By multiplying changes in managed land with the scaling factor we implicitly assume -*' that intact peatlands are distributed equally within a grid cell. -*' The following example illustrates the mechanism used for projecting peatland dynamics: -*' In a given grid cell, the total land area is 50 Mha and the total peatland area is 10 Mha. -*' Therefore, the scaling factor is 0.2 (10 Mha divided by 50 Mha). -*' If cropland expands by 5 Mha, 1 Mha of intact peatland is converted to degraded peatland (5 Mha x 0.2). -*' If the total cell would become cropland, degraded peatland would equal to the total peatland area (50 Mha x 0.2 = 10 Mha). - - q58_peatland_crop(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. - v58_peatland(j2,"crop") =e= - m_peatland(pc58_peatland,"crop",vm_land,pcm_land,"crop",p58_scaling_factor); - - q58_peatland_past(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. - v58_peatland(j2,"past") =e= - m_peatland(pc58_peatland,"past",vm_land,pcm_land,"past",p58_scaling_factor); - - q58_peatland_forestry(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. - v58_peatland(j2,"forestry") =e= - m_peatland(pc58_peatland,"forestry",vm_land_forestry,pcm_land_forestry,"plant",p58_scaling_factor); +*' Managed land area expansion and reduction: + + q58_manLandExp(j2,manLand58) .. + v58_manLandExp(j2,manLand58) =e= + vm_landexpansion(j2,"crop")$(sameas(manLand58,"crop")) + + vm_landexpansion(j2,"past")$(sameas(manLand58,"past")) + + vm_landexpansion_forestry(j2,"plant")$(sameas(manLand58,"forestry")); + + q58_manLandRed(j2,manLand58) .. + v58_manLandRed(j2,manLand58) =e= + vm_landreduction(j2,"crop")$(sameas(manLand58,"crop")) + + vm_landreduction(j2,"past")$(sameas(manLand58,"past")) + + vm_landreduction_forestry(j2,"plant")$(sameas(manLand58,"forestry")); + +*' Future peatland dynamics (`v58_peatland`) depend on changes in managed land (`v58_manLandExp`, `v58_manLandRed`), +*' multiplied with corresponding scaling factors for expansion (`p58_scaling_factor_exp`) and reduction (`p58_scaling_factor_red`). +*' The scaling factor for expansion makes sure that in case the full cell area consists of +*' managed land (cropland, pasture, forestry plantations), the full peatland area is drained. +*' Likewise, the scaling factor for reduction makes sure that in case no area is used for managed land, +*' managed peatland (`manPeat58`) is reduced to zero. +*' In case managed land remains unchanged, also managed peatland remains unchanged. +*' The distribution of changes in total peatland area to managed peatland categories (`manPeat58`) +*' depends on the weight of these categories in the previous time step (`p58_weight`). + + q58_peatlandMan(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatland(j2,manPeat58) =e= + pc58_peatland(j2,manPeat58) + + sum(manLand58, v58_manLandExp(j2,manLand58)) * sum(ct, p58_scaling_factor_exp(ct,j2) * p58_weight(ct,j2,manPeat58)) + - sum(manLand58, v58_manLandRed(j2,manLand58)) * sum(ct, p58_scaling_factor_red(ct,j2) * p58_weight(ct,j2,manPeat58)); + +*' This constraint avoids the conversion of intact peatland into rewetted peatland. + + q58_peatlandRewet(j2) .. + v58_peatlandChange(j2,"rewetted") =l= -sum(drained58, v58_peatlandChange(j2,drained58)) + v58_peatlandChange(j2,"intact"); *' Costs for peatland degradation and rewetting @@ -50,15 +58,20 @@ vm_peatland_cost(j2) =e= v58_peatland_cost(j2); q58_peatland_cost(j2) .. - v58_peatland_cost(j2) =e= v58_peatland_cost_annuity(j2) + v58_peatland_cost(j2) =e= v58_peatland_cost_annuity_intact(j2) + v58_peatland_cost_annuity_rewet(j2) + v58_peatland(j2,"rewetted") * sum(ct, i58_cost_rewet_recur(ct)) - + sum(landDrainedUsed58, v58_peatland(j2,landDrainedUsed58)) * sum(ct, i58_cost_degrad_recur(ct)); + + sum(manPeat58, v58_peatland(j2,manPeat58)) * sum(ct, i58_cost_degrad_recur(ct)); - q58_peatland_cost_annuity(j2) .. - v58_peatland_cost_annuity(j2) =e= - (v58_expansion(j2,"rewetted") * sum(ct, i58_cost_rewet_onetime(ct)) - + v58_reduction(j2,"intact") * sum(ct, i58_cost_degrad_onetime(ct))) + q58_peatland_cost_annuity_intact(j2) .. + v58_peatland_cost_annuity_intact(j2) =e= + - v58_peatlandChange(j2,"intact") * sum(ct, i58_cost_degrad_onetime(ct)) * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + + q58_peatland_cost_annuity_rewet(j2) .. + v58_peatland_cost_annuity_rewet(j2) =g= + v58_peatlandChange(j2,"rewetted") * sum(ct, i58_cost_rewet_onetime(ct)) + * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + *' Detailed peatland GHG emissions diff --git a/modules/58_peatland/v2/not_used.txt b/modules/58_peatland/v2/not_used.txt new file mode 100644 index 0000000000..9f23b880c7 --- /dev/null +++ b/modules/58_peatland/v2/not_used.txt @@ -0,0 +1,2 @@ +name, type, reason +vm_land, input, not used diff --git a/modules/58_peatland/v2/postsolve.gms b/modules/58_peatland/v2/postsolve.gms index 7ad8b0489d..72934224b9 100644 --- a/modules/58_peatland/v2/postsolve.gms +++ b/modules/58_peatland/v2/postsolve.gms @@ -10,74 +10,86 @@ pc58_peatland(j,land58) = v58_peatland.l(j,land58); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); ov58_peatland_cost(t,j,"marginal") = v58_peatland_cost.m(j); - ov58_peatland_cost_annuity(t,j,"marginal") = v58_peatland_cost_annuity.m(j); ov58_peatland_emis(t,j,land58,emis58,"marginal") = v58_peatland_emis.m(j,land58,emis58); - ov58_expansion(t,j,land58,"marginal") = v58_expansion.m(j,land58); - ov58_reduction(t,j,land58,"marginal") = v58_reduction.m(j,land58); + ov58_peatlandChange(t,j,land58,"marginal") = v58_peatlandChange.m(j,land58); + ov58_peatland_cost_annuity_intact(t,j,"marginal") = v58_peatland_cost_annuity_intact.m(j); + ov58_peatland_cost_annuity_rewet(t,j,"marginal") = v58_peatland_cost_annuity_rewet.m(j); ov58_peatland(t,j,land58,"marginal") = v58_peatland.m(j,land58); + ov58_manLandExp(t,j,manLand58,"marginal") = v58_manLandExp.m(j,manLand58); + ov58_manLandRed(t,j,manLand58,"marginal") = v58_manLandRed.m(j,manLand58); oq58_peatland(t,j,"marginal") = q58_peatland.m(j); - oq58_expansion(t,j,land58,"marginal") = q58_expansion.m(j,land58); - oq58_reduction(t,j,land58,"marginal") = q58_reduction.m(j,land58); - oq58_peatland_crop(t,j,"marginal") = q58_peatland_crop.m(j); - oq58_peatland_past(t,j,"marginal") = q58_peatland_past.m(j); - oq58_peatland_forestry(t,j,"marginal") = q58_peatland_forestry.m(j); + oq58_peatlandChange(t,j,land58,"marginal") = q58_peatlandChange.m(j,land58); + oq58_peatlandMan(t,j,manPeat58,"marginal") = q58_peatlandMan.m(j,manPeat58); + oq58_peatlandRewet(t,j,"marginal") = q58_peatlandRewet.m(j); oq58_peatland_cost_full(t,j,"marginal") = q58_peatland_cost_full.m(j); oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); - oq58_peatland_cost_annuity(t,j,"marginal") = q58_peatland_cost_annuity.m(j); + oq58_peatland_cost_annuity_intact(t,j,"marginal") = q58_peatland_cost_annuity_intact.m(j); + oq58_peatland_cost_annuity_rewet(t,j,"marginal") = q58_peatland_cost_annuity_rewet.m(j); oq58_peatland_emis_detail(t,j,land58,emis58,"marginal") = q58_peatland_emis_detail.m(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); + oq58_manLandExp(t,j,manLand58,"marginal") = q58_manLandExp.m(j,manLand58); + oq58_manLandRed(t,j,manLand58,"marginal") = q58_manLandRed.m(j,manLand58); ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); ov58_peatland_cost(t,j,"level") = v58_peatland_cost.l(j); - ov58_peatland_cost_annuity(t,j,"level") = v58_peatland_cost_annuity.l(j); ov58_peatland_emis(t,j,land58,emis58,"level") = v58_peatland_emis.l(j,land58,emis58); - ov58_expansion(t,j,land58,"level") = v58_expansion.l(j,land58); - ov58_reduction(t,j,land58,"level") = v58_reduction.l(j,land58); + ov58_peatlandChange(t,j,land58,"level") = v58_peatlandChange.l(j,land58); + ov58_peatland_cost_annuity_intact(t,j,"level") = v58_peatland_cost_annuity_intact.l(j); + ov58_peatland_cost_annuity_rewet(t,j,"level") = v58_peatland_cost_annuity_rewet.l(j); ov58_peatland(t,j,land58,"level") = v58_peatland.l(j,land58); + ov58_manLandExp(t,j,manLand58,"level") = v58_manLandExp.l(j,manLand58); + ov58_manLandRed(t,j,manLand58,"level") = v58_manLandRed.l(j,manLand58); oq58_peatland(t,j,"level") = q58_peatland.l(j); - oq58_expansion(t,j,land58,"level") = q58_expansion.l(j,land58); - oq58_reduction(t,j,land58,"level") = q58_reduction.l(j,land58); - oq58_peatland_crop(t,j,"level") = q58_peatland_crop.l(j); - oq58_peatland_past(t,j,"level") = q58_peatland_past.l(j); - oq58_peatland_forestry(t,j,"level") = q58_peatland_forestry.l(j); + oq58_peatlandChange(t,j,land58,"level") = q58_peatlandChange.l(j,land58); + oq58_peatlandMan(t,j,manPeat58,"level") = q58_peatlandMan.l(j,manPeat58); + oq58_peatlandRewet(t,j,"level") = q58_peatlandRewet.l(j); oq58_peatland_cost_full(t,j,"level") = q58_peatland_cost_full.l(j); oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); - oq58_peatland_cost_annuity(t,j,"level") = q58_peatland_cost_annuity.l(j); + oq58_peatland_cost_annuity_intact(t,j,"level") = q58_peatland_cost_annuity_intact.l(j); + oq58_peatland_cost_annuity_rewet(t,j,"level") = q58_peatland_cost_annuity_rewet.l(j); oq58_peatland_emis_detail(t,j,land58,emis58,"level") = q58_peatland_emis_detail.l(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); + oq58_manLandExp(t,j,manLand58,"level") = q58_manLandExp.l(j,manLand58); + oq58_manLandRed(t,j,manLand58,"level") = q58_manLandRed.l(j,manLand58); ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); ov58_peatland_cost(t,j,"upper") = v58_peatland_cost.up(j); - ov58_peatland_cost_annuity(t,j,"upper") = v58_peatland_cost_annuity.up(j); ov58_peatland_emis(t,j,land58,emis58,"upper") = v58_peatland_emis.up(j,land58,emis58); - ov58_expansion(t,j,land58,"upper") = v58_expansion.up(j,land58); - ov58_reduction(t,j,land58,"upper") = v58_reduction.up(j,land58); + ov58_peatlandChange(t,j,land58,"upper") = v58_peatlandChange.up(j,land58); + ov58_peatland_cost_annuity_intact(t,j,"upper") = v58_peatland_cost_annuity_intact.up(j); + ov58_peatland_cost_annuity_rewet(t,j,"upper") = v58_peatland_cost_annuity_rewet.up(j); ov58_peatland(t,j,land58,"upper") = v58_peatland.up(j,land58); + ov58_manLandExp(t,j,manLand58,"upper") = v58_manLandExp.up(j,manLand58); + ov58_manLandRed(t,j,manLand58,"upper") = v58_manLandRed.up(j,manLand58); oq58_peatland(t,j,"upper") = q58_peatland.up(j); - oq58_expansion(t,j,land58,"upper") = q58_expansion.up(j,land58); - oq58_reduction(t,j,land58,"upper") = q58_reduction.up(j,land58); - oq58_peatland_crop(t,j,"upper") = q58_peatland_crop.up(j); - oq58_peatland_past(t,j,"upper") = q58_peatland_past.up(j); - oq58_peatland_forestry(t,j,"upper") = q58_peatland_forestry.up(j); + oq58_peatlandChange(t,j,land58,"upper") = q58_peatlandChange.up(j,land58); + oq58_peatlandMan(t,j,manPeat58,"upper") = q58_peatlandMan.up(j,manPeat58); + oq58_peatlandRewet(t,j,"upper") = q58_peatlandRewet.up(j); oq58_peatland_cost_full(t,j,"upper") = q58_peatland_cost_full.up(j); oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); - oq58_peatland_cost_annuity(t,j,"upper") = q58_peatland_cost_annuity.up(j); + oq58_peatland_cost_annuity_intact(t,j,"upper") = q58_peatland_cost_annuity_intact.up(j); + oq58_peatland_cost_annuity_rewet(t,j,"upper") = q58_peatland_cost_annuity_rewet.up(j); oq58_peatland_emis_detail(t,j,land58,emis58,"upper") = q58_peatland_emis_detail.up(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); + oq58_manLandExp(t,j,manLand58,"upper") = q58_manLandExp.up(j,manLand58); + oq58_manLandRed(t,j,manLand58,"upper") = q58_manLandRed.up(j,manLand58); ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); ov58_peatland_cost(t,j,"lower") = v58_peatland_cost.lo(j); - ov58_peatland_cost_annuity(t,j,"lower") = v58_peatland_cost_annuity.lo(j); ov58_peatland_emis(t,j,land58,emis58,"lower") = v58_peatland_emis.lo(j,land58,emis58); - ov58_expansion(t,j,land58,"lower") = v58_expansion.lo(j,land58); - ov58_reduction(t,j,land58,"lower") = v58_reduction.lo(j,land58); + ov58_peatlandChange(t,j,land58,"lower") = v58_peatlandChange.lo(j,land58); + ov58_peatland_cost_annuity_intact(t,j,"lower") = v58_peatland_cost_annuity_intact.lo(j); + ov58_peatland_cost_annuity_rewet(t,j,"lower") = v58_peatland_cost_annuity_rewet.lo(j); ov58_peatland(t,j,land58,"lower") = v58_peatland.lo(j,land58); + ov58_manLandExp(t,j,manLand58,"lower") = v58_manLandExp.lo(j,manLand58); + ov58_manLandRed(t,j,manLand58,"lower") = v58_manLandRed.lo(j,manLand58); oq58_peatland(t,j,"lower") = q58_peatland.lo(j); - oq58_expansion(t,j,land58,"lower") = q58_expansion.lo(j,land58); - oq58_reduction(t,j,land58,"lower") = q58_reduction.lo(j,land58); - oq58_peatland_crop(t,j,"lower") = q58_peatland_crop.lo(j); - oq58_peatland_past(t,j,"lower") = q58_peatland_past.lo(j); - oq58_peatland_forestry(t,j,"lower") = q58_peatland_forestry.lo(j); + oq58_peatlandChange(t,j,land58,"lower") = q58_peatlandChange.lo(j,land58); + oq58_peatlandMan(t,j,manPeat58,"lower") = q58_peatlandMan.lo(j,manPeat58); + oq58_peatlandRewet(t,j,"lower") = q58_peatlandRewet.lo(j); oq58_peatland_cost_full(t,j,"lower") = q58_peatland_cost_full.lo(j); oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); - oq58_peatland_cost_annuity(t,j,"lower") = q58_peatland_cost_annuity.lo(j); + oq58_peatland_cost_annuity_intact(t,j,"lower") = q58_peatland_cost_annuity_intact.lo(j); + oq58_peatland_cost_annuity_rewet(t,j,"lower") = q58_peatland_cost_annuity_rewet.lo(j); oq58_peatland_emis_detail(t,j,land58,emis58,"lower") = q58_peatland_emis_detail.lo(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); + oq58_manLandExp(t,j,manLand58,"lower") = q58_manLandExp.lo(j,manLand58); + oq58_manLandRed(t,j,manLand58,"lower") = q58_manLandRed.lo(j,manLand58); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms index ac58258d2b..7380c4b097 100644 --- a/modules/58_peatland/v2/preloop.gms +++ b/modules/58_peatland/v2/preloop.gms @@ -17,3 +17,6 @@ pc58_peatland(j,land58) = 0; * For the internal GHG emission pricing it is assumed that intact peatlands have the same GHG emission factors as rewetted peatlands. * Without this assumption, GHG emissions of intact peatlands would be zero (no data available). This can lead to cases where intact peatland is converted to rewetted peatland. f58_ipcc_wetland_ef(clcl58,"intact",emis58) = f58_ipcc_wetland_ef(clcl58,"rewetted",emis58); + +* Initialization of peatland weight +p58_weight(t,j,manPeat58) = 1/card(manPeat58); diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index 73b2ddbfe8..4621971a10 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -10,17 +10,14 @@ if (m_year(t) <= s58_fix_peatland, * Initialization of peatland area. Drained and used peatland area cannot exceed the corresponding managed area pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop")); pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past")); - pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant")); + pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land(j,"forestry")); * The residual is added to an "unused" category, which represents drained but unused peatland. - pc58_peatland(j,"unused") = sum(landDrainedUsed58, f58_peatland_area(j,landDrainedUsed58) - pc58_peatland(j,landDrainedUsed58)); + pc58_peatland(j,"unused") = sum(manPeat58, f58_peatland_area(j,manPeat58) - pc58_peatland(j,manPeat58)); * Area used for peat extraction pc58_peatland(j,"peatExtract") = f58_peatland_area(j,"peatExtract"); * Intact peatland area pc58_peatland(j,"intact") = f58_peatland_area(j,"intact"); -* Peatland scaling factor for estimating future peatland dynamics -p58_scaling_factor(j) = sum(land58, pc58_peatland(j,land58)) / sum(land, pcm_land(j,land)); - * Peatland area is fixed to `pc58_peatland` until the year given by s58_fix_peatland v58_peatland.fx(j,land58) = pc58_peatland(j,land58); i58_cost_rewet_recur(t) = 0; @@ -31,7 +28,7 @@ else * Define bounds and costs for peatland area after the year given by s58_fix_peatland v58_peatland.lo(j,land58) = 0; v58_peatland.l(j,land58) = pc58_peatland(j,land58); - v58_peatland.up(j,landDrained58) = Inf; + v58_peatland.up(j,drained58) = Inf; v58_peatland.up(j,"rewetted") = s58_rewetting_switch; v58_peatland.up(j,"intact") = pc58_peatland(j,"intact"); v58_peatland.fx(j,"peatExtract") = pc58_peatland(j,"peatExtract"); @@ -40,3 +37,11 @@ else i58_cost_degrad_recur(t) = s58_cost_degrad_recur; i58_cost_degrad_onetime(t) = s58_cost_degrad_onetime; ); + +* Peatland scaling factors for estimating future peatland dynamics; see macros for details. +p58_scaling_factor_exp(t,j) = m_peatland_scaling_factor_exp(pc58_peatland,pcm_land); +p58_scaling_factor_red(t,j) = m_peatland_scaling_factor_red(pc58_peatland,pcm_land); + +* Peatland weight for distribution of total peatland changes to managed peatland categories +p58_weight(t,j,manPeat58)$(sum(manPeat58_alias, pc58_peatland(j,manPeat58_alias)) > 1e-10) = + pc58_peatland(j,manPeat58) / sum(manPeat58_alias, pc58_peatland(j,manPeat58_alias)); diff --git a/modules/58_peatland/v2/sets.gms b/modules/58_peatland/v2/sets.gms index 0abd629107..d4a99c9441 100644 --- a/modules/58_peatland/v2/sets.gms +++ b/modules/58_peatland/v2/sets.gms @@ -7,13 +7,16 @@ sets - land58 Peatland land types + land58 Peatland categories / intact, crop, past, forestry, peatExtract, unused, rewetted / - landDrained58(land58) Peatland land types + drained58(land58) Drained peatland categories / crop, past, forestry, unused / - landDrainedUsed58(land58) Peatland land types + manPeat58(land58) Drained and managed peatland categories + / crop, past, forestry / + + manLand58(land) Managed main land categories / crop, past, forestry / emis58 Wetland emission types @@ -69,3 +72,5 @@ sets / ; + +alias (manPeat58,manPeat58_alias); From 4ab2df7008cba79bb6b1b6a6294daa8b90b15505 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 28 Nov 2023 11:31:04 +0100 Subject: [PATCH 045/187] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86871eb759..b1169a6bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **18_residues** Included cluster-level residue realization, for cluster-level production of residues (but balancing of recycling and burning budgets remains at region-level, for computational lightness) - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors -- **32_forestry** new interface `vm_land_forestry` +- **32_forestry** new interfaces `vm_landexpansion_forestry` and `vm_landreduction_forestry` - **scripts** added peatland to output/extra/disaggregation.R ### removed From 5c5d8ca6ddabaa3f625d073f1533d36d51089e6d Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 28 Nov 2023 14:34:47 +0100 Subject: [PATCH 046/187] bugfix --- config/scenario_config.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 1bc205be25..1c6266c95c 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -30,7 +30,6 @@ gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;a gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; -gms$c31_past_suit_scen;;nocc;nocc_hist;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585; gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; From 36cd9fb0b34d0802dc88a6d74d94092fb9e132df Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 29 Nov 2023 17:59:36 +0100 Subject: [PATCH 047/187] added eat2p0 reporting output script and eat2p0 start script for core and decomposition runs --- scripts/output/projects/eat2p0_report.R | 36 ++++ scripts/start/projects/project_EAT2p0.R | 272 +++++++++++++++++++----- 2 files changed, 258 insertions(+), 50 deletions(-) create mode 100644 scripts/output/projects/eat2p0_report.R diff --git a/scripts/output/projects/eat2p0_report.R b/scripts/output/projects/eat2p0_report.R new file mode 100644 index 0000000000..1e7be72a54 --- /dev/null +++ b/scripts/output/projects/eat2p0_report.R @@ -0,0 +1,36 @@ +# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | MAgPIE License Exception, version 1.0 (see LICENSE file). +# | Contact: magpie@pik-potsdam.de + +# -------------------------------------------------------------- +# description: extract agmip-report in rds format from run +# comparison script: FALSE +# --------------------------------------------------------------- + +library(magclass) +library(magpie4) +library(lucode2) +library(quitte) +library(gms) +options("magclass.verbosity" = 1) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- "/p/projects/landuse/users/miodrag/projects/tests/flexreg/output/H12_setup1_2016-11-23_12.38.56/" + readArgs("outputdir") +} + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +gdx <- file.path(outputdir, "fulldata.gdx") +mif <- paste0(outputdir, "/eat2p0_report.mif") +rds <- paste0(outputdir, "/eat2p0_report.rds") +############################################################################### + +report <- getReportAgMIP(gdx, scenario = cfg$title) + +### regional aggregation +write.report(report, file = mif) +saveRDS(as.quitte(report), file = rds) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 9783506f18..32de97fef6 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -28,65 +28,237 @@ cfg$force_download <- FALSE #cfg$results_folder <- "output/:title:" cfg$results_folder <- "output/:title::date:" +####################### +# SCENARIO DEFINITION # +####################### +cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) -######################### -# 1 Baseline BAU_RCP4.5 # -######################### +### BAU Scenario ### # SSP: SSP2 # Diet: BAU-SSP2 # Waste: BAU-SSP2 # Crop and Livestock productivity: BAU-SSP2 # Mitigation policies: current policies # Land-use policies: current policies -# RCP/GCM: tba -# Trade: BAU-SSP2 -cfg$title <- "BAU_RCP4p5" -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +# RCP/GCM: 7p0 shocks on crops, livestock, labor +# Trade: BAU +bau <- function(cfg) { + ### General settings ### + # For impacts of CC on labor: + cfg$gms$factor_costs <- "sticky_labor" # @Alex/Edna/Florian: Should we use this one? + cfg$gms$labor_prod <- "exo" + cfg$gms$c37_labor_rcp <- "rcp585" # @Florian: which one to choose for RCP 7p0? + + ### Components for Decomposition ### + # Diets: exogenous EATLancet diet + cfg$gms$s15_exo_diet <- 0 # default + cfg$gms$c15_kcal_scen <- "healthy_BMI" # default (but not active b/c of s15_exo_diet = 0) + cfg$gms$c15_EAT_scen <- "FLX" # default (but not active b/c of s15_exo_diet = 0) + # Waste: half food waste + cfg$gms$s15_exo_waste <- 0 # default + cfg$gms$s15_waste_scen <- 1.2 # default (but not active b/c of s15_exo_waste = 0) + # Higher endogenous productivity achieved through lower costs + cfg$gms$tc <- "endo_jan22" # default + cfg$gms$c13_tccost <- "medium" # default + # Mitigation: no mitigation beyond NPI (NPI already set in setScenario) + cfg$gms$c56_emis_policy <- "redd+natveg_nosoil" # default # @Florian: should it be "red+natveg_nosoil" or "default" for case of current policies / no additional mitigation + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" # default + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default + # Climate Change + input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + + return(cfg) +} + +### Diet component ## +# Globally achieves EL2 diet by 2050 # To Do: Check implementation +diet <- function(cfg) { + cfg$gms$s15_exo_diet <- 1 # To Do: switch to 3 once implementation is ready + cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) + cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) + return(cfg) +} + +### Productivity component ## +# High productivity growth rate similar to productivity trends +# associated with SSP1 (e.g., PRD 1 in Stehfest et al.) +prod <- function(cfg) { + # Higher endogenous productivity achieved through lower costs + cfg$gms$tc <- "endo_jan22" # default: not necessary to set it again (To Do: remove) + cfg$gms$c13_tccost <- "low" # Should I set it like this? @Jan? Or how was it done in Stehfest et al. PRD1? + return(cfg) +} + +### Waste component ## +# Reduction (halving) of food loss and waste +waste <- function(cfg) { + # Waste: half food waste + cfg$gms$s15_exo_waste <- 1 + cfg$gms$s15_waste_scen <- 1.2 + return(cfg) +} + +### Mitigation component ## +# Adds mitigation and land-use policies consistent with 1.5C by 2050 to BAU +miti <- function(cfg) { + # Mitigation: consistent with 1.5C + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? + cfg$gms$c56_emis_policy <- "sdp_all" # @Florian: Which emissions to price? all? + return(cfg) +} + +### NoCC component ## +# No climate change impacts +noCC <- function(cfg) { + # deactivate climate change impacts + cfg$gms$c59_som_scenario <- "nocc" + cfg$gms$c14_yields_scenario <- "nocc" + cfg$gms$c31_grassl_yld_scenario <- "nocc" # Note: anyway not active in current default. + cfg$gms$c42_watdem_scenario <- "nocc" + cfg$gms$c43_watavail_scenario <- "nocc" + cfg$gms$c52_carbon_scenario <- "nocc" + return(cfg) +} + +### RCP 2.6 ### +# Decomposition Scenario. Apply lower climate impacts based on RCP 2.6 to BAU +rcp26 <- function(cfg) { + cfg$input['cellular'] <- "rev4.94_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz" + return(cfg) +} + + +################# +# SCENARIO RUNS # +################# +# BAU # +# Business as usual scenario based on SSP2 +# with a higher climate impact reflected by RCP 7.0 +cfg$title <- "BAU" +cfg <- bau(cfg = cfg) start_run(cfg, codeCheck = FALSE) -######################### -# 2 Baseline PHD_RCP4.5 # -######################### -# SSP: SSP2 -# Diet: EL2p0 -# Waste: half -# Crop and Livestock productivity: high (SSP1?) -# Mitigation policies: current policies -# Land-use policies: current policies -# RCP/GCM: tba -# Trade: BAU-SSP2 -cfg$title <- "PHD_RCP4p5" -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) -# Diets: exogenous EATLancet diet -cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready -cfg$gms$c15_kcal_scen <- "healthy_BMI" -cfg$gms$c15_EAT_scen <- "FLX" -# Waste: half food waste -cfg$gms$s15_exo_waste <- 1 -cfg$gms$s15_waste_scen <- 1.2 +# BAU_DIET # +# Decomposition scenario. Adds EL2.0 Diet to BAU: +# Globally achieves EL2 diet by 2050 # To Do: Check implemention! +cfg$title <- "BAU_DIET" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) start_run(cfg, codeCheck = FALSE) -######################### -# 3 Baseline PHD_MIT1p9 # -######################### -# SSP: SSP2 -# Diet: EL2p0 -# Waste: half -# Crop and Livestock productivity: high (SSP1?) -# Mitigation policies: 1.5 degrees -# Land-use policies: 1.5 degrees -# RCP/GCM: tba -# Trade: BAU-SSP2 -cfg$title <- "PHD_MIT1p9" -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) -# Diets: exogenous EATLancet diet -cfg$gms$s15_exo_diet <- 1 # Note: switch to 3 once implementation is ready -cfg$gms$c15_kcal_scen <- "healthy_BMI" -cfg$gms$c15_EAT_scen <- "FLX" -# Waste: half food waste -cfg$gms$s15_exo_waste <- 1 -cfg$gms$s15_waste_scen <- 1.2 -# Mitigation -cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" -cfg$gms$c56_emis_policy <- "sdp_all" +# BAU_PROD # +# Decomposition scenario adds high productivity to BAU +cfg$title <- "BAU_PROD" +cfg <- bau(cfg = cfg) +cfg <- prod(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_WAST # +# Decomposition scenario. Adds a reduction (halving) of food loss and waste +cfg$title <- "BAU_WAST" +cfg <- bau(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_RCP26 # +# Decomposition Scenario. Apply lower climate impacts based on RCP 2.6 to BAU +cfg$title <- "BAU_RCP26" +cfg <- bau(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_NoCC # +# Decomposition scenario. Remove climate impacts (NoCC) from BAU to isolate climate effects +cfg$title <- "BAU_NoCC" +cfg <- bau(cfg = cfg) +cfg <- noCC(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_MITI # +# Decomposition Scenario. Adds mitigation and land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "BAU_MITI" +cfg <- bau(cfg = cfg) +cfg <- miti(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# EL2 # +# Full EAT-Lancet Scenario (diet, productivity, FLW) without mitigation and higher climate impacts based on RCP 7.0 +cfg$title <- "EL2" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM # +# Full EAT-Lancet scenario (diet, productivity, FLW) with mitigation policies consistent with 1.5C. Climate based on a lower climate impacts with RCP 2.6 +cfg$title <- "ELM" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_Diet # +# Decomposition Scenario. Removes Diet from ELM +cfg$title <- "ELM_DIET" +cfg <- bau(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_PROD # +# Decomposition Scenario. Removed productivity trend from ELM +cfg$title <- "ELM_PROD" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_WAST # +# Decomposition Scenario. Removes FLW from ELM +cfg$title <- "ELM_WAST" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- rcp26(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_RCP70 # +# Decomposition Scenario. Applies RCP 7.0 climate impacts to ELM +cfg$title <- "ELM_RCP70" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_NoCC # +# Decomposition Scenario. Removes climate impacts (NoCC) from ELM +cfg$title <- "ELM_NoCC" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- noCC(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_MITI # +# Decomposition Scenario. Removes climate mitigation and LUC policies from ELM +cfg$title <- "ELM_MITI" +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +cfg <- rcp26(cfg = cfg) start_run(cfg, codeCheck = FALSE) From bcae77d423e2a05b43a07863c5ecdb163989d079 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 29 Nov 2023 18:35:22 +0100 Subject: [PATCH 048/187] bugfix in eat2p0 start script --- scripts/start/projects/project_EAT2p0.R | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 32de97fef6..e369ad8849 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -17,21 +17,18 @@ library(lucode2) library(magclass) library(gms) -# Load start_run(cfg) function which is needed to start MAgPIE runs +# Load start function needed to start MAgPIE runs source("scripts/start_functions.R") - -# start MAgPIE runs +# obtain settings from default config source("config/default.cfg") -cfg$force_download <- FALSE - -#cfg$results_folder <- "output/:title:" +# set title and date cfg$results_folder <- "output/:title::date:" ####################### # SCENARIO DEFINITION # ####################### -cfg <- gms::setScenario(cfg, c("SSP2", "NPI")) +cfg <- setScenario(cfg, c("SSP2", "NPI")) ### BAU Scenario ### # SSP: SSP2 @@ -65,7 +62,7 @@ bau <- function(cfg) { cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" # default cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default # Climate Change - input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" return(cfg) } From fc969ad88b5495e95ede8364c6e28e297b7dc89f Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 30 Nov 2023 09:40:27 +0100 Subject: [PATCH 049/187] bugfix --- config/scenario_fsec.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 28569804a8..5ea2924d7b 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -30,7 +30,6 @@ gms$c30_bioen_water;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rainfed;;;;;;;;;;;;;;;;;;; gms$s30_snv_scenario_target;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;; gms$s30_snv_shr;;;;;;;;;;;;;;;;;;;;;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;; gms$past;endo_jun13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c31_past_suit_scen;ssp245;ssp126;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp126;ssp245;ssp370;ssp460;ssp585;ssp126;ssp126;ssp245;ssp245;ssp460;ssp370;ssp585; gms$c32_aff_policy;;;;;;;;;;;;;;;;;;;;;;;;;ndc;;;;;;;;;;;;;;;;;;;;;;;; gms$c32_aff_mask;;;;;;;;;;;;;;;;;;;;;;;;;onlytropical;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_max_aff_area;;;;;;;;;;;;;;;;;;;;;;;;;500;;;;;;;;;;;;;;;;;;;;;;;; From e2dc646a7108446367d6d5ebee6fa510908f5566 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 1 Dec 2023 15:01:57 +0100 Subject: [PATCH 050/187] Peatland. removed on realisation. Update v2 --- CHANGELOG.md | 4 +- config/default.cfg | 26 ++-- core/macros.gms | 21 ++-- main.gms | 2 +- .../dynamic_feb21/declarations.gms | 5 + .../32_forestry/dynamic_feb21/equations.gms | 3 + .../32_forestry/dynamic_feb21/postsolve.gms | 8 ++ .../32_forestry/dynamic_feb21/presolve.gms | 1 + modules/58_peatland/module.gms | 1 - modules/58_peatland/off/not_used.txt | 2 + modules/58_peatland/on/declarations.gms | 83 ------------- modules/58_peatland/on/equations.gms | 114 ----------------- modules/58_peatland/on/input.gms | 40 ------ modules/58_peatland/on/not_used.txt | 5 - modules/58_peatland/on/postsolve.gms | 115 ------------------ modules/58_peatland/on/preloop.gms | 43 ------- modules/58_peatland/on/presolve.gms | 57 --------- modules/58_peatland/on/realization.gms | 29 ----- modules/58_peatland/on/scaling.gms | 9 -- modules/58_peatland/on/sets.gms | 94 -------------- modules/58_peatland/v2/declarations.gms | 71 ++++++----- modules/58_peatland/v2/equations.gms | 45 +++---- modules/58_peatland/v2/input.gms | 2 +- modules/58_peatland/v2/not_used.txt | 2 - modules/58_peatland/v2/postsolve.gms | 85 +++++++------ modules/58_peatland/v2/preloop.gms | 3 - modules/58_peatland/v2/presolve.gms | 21 ++-- modules/58_peatland/v2/realization.gms | 2 +- 28 files changed, 165 insertions(+), 728 deletions(-) delete mode 100644 modules/58_peatland/on/declarations.gms delete mode 100644 modules/58_peatland/on/equations.gms delete mode 100644 modules/58_peatland/on/input.gms delete mode 100644 modules/58_peatland/on/not_used.txt delete mode 100644 modules/58_peatland/on/postsolve.gms delete mode 100644 modules/58_peatland/on/preloop.gms delete mode 100644 modules/58_peatland/on/presolve.gms delete mode 100644 modules/58_peatland/on/realization.gms delete mode 100644 modules/58_peatland/on/scaling.gms delete mode 100644 modules/58_peatland/on/sets.gms delete mode 100644 modules/58_peatland/v2/not_used.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index b1169a6bd3..7a63682fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,16 +14,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits. - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **36_employment** regression between hourly labor regression and GDP pc changed from linear to log-log +- **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` ### added - **18_residues** Included cluster-level residue realization, for cluster-level production of residues (but balancing of recycling and burning budgets remains at region-level, for computational lightness) - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors -- **32_forestry** new interfaces `vm_landexpansion_forestry` and `vm_landreduction_forestry` +- **32_forestry** new interfaces `vm_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` - **scripts** added peatland to output/extra/disaggregation.R ### removed - **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. +- **58_peatland** removed realization "on" ### fixed - **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93 diff --git a/config/default.cfg b/config/default.cfg index 39f47ab09b..7004784428 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1532,15 +1532,12 @@ cfg$gms$s57_maxmac_ch4_awms <- -1 # def = -1 # ***--------------------- 58_peatland ------------------------------------ # * (off): Peatland area and associated GHG emissions are assumed zero -# * (on): Peatland area is initialized with degraded and intact peatland for the year 2015, -# * and projected into the future based on changes in managed land. -# * GHG emissions are calculated using IPCC Tier 1 emission factors (2013 Wetland supplement). -# * (v2): Peatland area is initialized with degraded and intact peatland area for the year 2020, +# * (v2): Peatland area is initialized with degraded and intact peatland area for the year 2022, # * and projected into the future based on changes in managed land. # * For boreal and tropical climates, GHG emissions are calculated using emission # * factors from the IPCC 2013 Wetland supplement. For temperate climates, more recent # * estimates from Tiemeyer et al 2020 are used. -cfg$gms$peatland <- "on" # def = on +cfg$gms$peatland <- "v2" # def = v2 # * peatland rewetting # * options: 0 (off) @@ -1552,26 +1549,17 @@ cfg$gms$s58_cost_rewet_onetime <- 7000 # def = 7000 cfg$gms$s58_cost_rewet_recur <- 200 # def = 200 # * One-time and recurring costs for peatland degradation (USD05MER per ha) -# * Can be used to test area-based incentives for peatland protection and restoration, -# * complementary or in addition to pricing GHG emissions from degraded peatlands (see s56_peatland_policy). # * One-time costs apply on the conversion of intact (and rewetted) peatland to degraded peatland. -# * Therefore, one-time costs can used to incentivize the protection of intact peatlands. -# * Recurring costs apply on the level of degraded peatland. Therefore, recurring costs, -# * in combination with one-time costs, can be used to incentivize peatland restoration. +# * Recurring costs apply on the level of degraded peatland. cfg$gms$s58_cost_degrad_onetime <- 0 # def = 0 cfg$gms$s58_cost_degrad_recur <- 0 # def = 0 -# * Artificial cost for balance variables (USD05MER per ha) -# * The balance variables in the peatland module avoid infeasibilities due to -# * differences in accuracy between parameters and variables in GAMS. -# * High costs make sure that the balance variables are only used as a last resort. -cfg$gms$s58_cost_balance <- 1e+06 # def = 1e+06 - -# * Switch for fixing peatland area between 1995 and the year given by s58_fix_peatland -# * Note: Depending on the realisation, the initial peatland area is only available for the year 2015 (`on`) or 2020 (`v2`). +# * Switch for fixing peatland area until the year given by s58_fix_peatland to historic levels (not available in `off`). +# * Note: In the realisation `v2`, historic peatland area is only available for the year 2022. +# * Due to the 5-year time step limitation in MAgPIE, the suggested default is 2020. # * Fixing peatland area in previous time steps provides a better # * proxy for GHG emissions from peatlands than assuming no peatland area. -cfg$gms$s58_fix_peatland <- 2015 # def = 2015 +cfg$gms$s58_fix_peatland <- 2020 # def = 2020 # ***------------------------- 59_som ------------------------------------- # * (static_jan19): static soil carbon loss for cropland diff --git a/core/macros.gms b/core/macros.gms index 5f99a88bdc..5c79563547 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -98,13 +98,14 @@ $macro m_carbon_stock_ac(land,carbon_density,sets,sets_sub) \ sum((&&sets), land(j2,&&sets) * sum(ct, carbon_density(ct,j2,&&sets,ag_pools)))$(sameas(stockType,"actual")) + \ sum((&&sets_sub), land(j2,&&sets_sub) * sum(ct, carbon_density(ct,j2,&&sets_sub,ag_pools)))$(sameas(stockType,"actualNoAcEst")); -* macros for peatland scaling factors -* expansion: (maxPeat - totManPeat) / (maxLand - totManLand) -$macro m_peatland_scaling_factor_exp(peatland,pcm_land) \ - ((sum(land58, peatland(j,land58)) - sum(manPeat58, peatland(j,manPeat58))) / (sum(land, pcm_land(j,land)) - sum(manLand58, pcm_land(j,manLand58))) )\ - $(sum(land58, peatland(j,land58)) > 1e-10 AND sum(land, pcm_land(j,land)) > 1e-10)\ - + 0$(sum(land58, peatland(j,land58)) <= 1e-10 OR sum(land, pcm_land(j,land)) <= 1e-10) -* reduction: totManPeat / totManLand -$macro m_peatland_scaling_factor_red(peatland,pcm_land) \ - (sum(manPeat58, peatland(j,manPeat58)) / sum(manLand58, pcm_land(j,manLand58)))$(sum(manPeat58, peatland(j,manPeat58)) > 1e-10 AND sum(manLand58, pcm_land(j,manLand58)) > 1e-10) \ - + 0$(sum(manPeat58, peatland(j,manPeat58)) <= 1e-10 OR sum(manLand58, pcm_land(j,manLand58)) <= 1e-10) +* macro for merging managed land area into peatland categories +$macro m_peatLandMerge(land,landForestry,set) \ + land(&&set,"crop")$(sameas(manPeat58,"crop")) \ + + land(&&set,"past")$(sameas(manPeat58,"past")) \ + + landForestry(&&set,"plant")$(sameas(manPeat58,"forestry")) + +* macro for peatland expansion factor +$macro m_peatLandLeft(pclandFull,setFull,vland,pcland) \ + (sum(&&setFull,pclandFull(j2,&&setFull)) \ + - sum(manPeat58_alias$(not sameas(manPeat58_alias,manPeat58)),vland(j2,manPeat58_alias)) \ + - sum(manPeat58_alias$(sameas(manPeat58_alias,manPeat58)),pcland(j2,manPeat58_alias))) diff --git a/main.gms b/main.gms index 5427e7b2fb..dd73db9181 100644 --- a/main.gms +++ b/main.gms @@ -277,7 +277,7 @@ $setglobal phosphorus off $setglobal awms ipcc2006_aug16 $setglobal ghg_policy price_aug22 $setglobal maccs on_aug22 -$setglobal peatland on +$setglobal peatland v2 $setglobal som static_jan19 $setglobal bioenergy 1stgen_priced_dec18 diff --git a/modules/32_forestry/dynamic_feb21/declarations.gms b/modules/32_forestry/dynamic_feb21/declarations.gms index 54c2438db8..32047560ec 100644 --- a/modules/32_forestry/dynamic_feb21/declarations.gms +++ b/modules/32_forestry/dynamic_feb21/declarations.gms @@ -59,6 +59,7 @@ parameters p32_bii_coeff(type32,bii_class_secd,potnatveg) bii coeff (1) p32_c_density_ac_fast_forestry(t_all,j,ac) Carbon densities in plantations based on Braakhekke et al (tC per ha) p32_disturbance_loss_ftype32(t,j,type32,ac) Loss due to disturbances in all plantation type forests (mio. ha) + pcm_land_forestry(j,type32) Forestry land pools (mio. ha) ; positive variables @@ -75,6 +76,7 @@ positive variables vm_prod_forestry(j,kforestry) Production of woody biomass from commercial plantations (mio. tDM per yr) vm_landexpansion_forestry(j,type32) Forestry land expansion (mio. ha) vm_landreduction_forestry(j,type32) Forestry land reduction (mio. ha) + vm_land_forestry(j,type32) Forestry land pools (mio. ha) ; variables @@ -84,6 +86,7 @@ variables equations q32_cost_total(i) Total forestry costs constraint (mio. USD) q32_land(j) Land constraint (mio. ha) + q32_land_type32(j,type32) Land constraint (mio. ha) q32_cdr_aff(j,ac) Calculation of CDR from afforestation (mio. tC) q32_carbon(j,ag_pools,stockType) Forestry carbon stock calculation (mio. tC) q32_land_diff Aggregated difference in forestry land compared to previous timestep (mio. ha) @@ -126,9 +129,11 @@ parameters ov_prod_forestry(t,j,kforestry,type) Production of woody biomass from commercial plantations (mio. tDM per yr) ov_landexpansion_forestry(t,j,type32,type) Forestry land expansion (mio. ha) ov_landreduction_forestry(t,j,type32,type) Forestry land reduction (mio. ha) + ov_land_forestry(t,j,type32,type) Forestry land pools (mio. ha) ov_cdr_aff(t,j,ac,aff_effect,type) Expected bgc (CDR) and local bph effects of afforestation depending on planning horizon (mio. tC) oq32_cost_total(t,i,type) Total forestry costs constraint (mio. USD) oq32_land(t,j,type) Land constraint (mio. ha) + oq32_land_type32(t,j,type32,type) Land constraint (mio. ha) oq32_cdr_aff(t,j,ac,type) Calculation of CDR from afforestation (mio. tC) oq32_carbon(t,j,ag_pools,stockType,type) Forestry carbon stock calculation (mio. tC) oq32_land_diff(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index aee0554c37..c2e9550776 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -56,6 +56,9 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( q32_land(j2) .. vm_land(j2,"forestry") =e= sum((type32,ac), v32_land(j2,type32,ac)); + q32_land_type32(j2,type32) .. + vm_land_forestry(j2,type32) =e= sum(ac, v32_land(j2,type32,ac)); + q32_land_expansion_forestry(j2,type32) .. vm_landexpansion_forestry(j2,type32) =e= sum(ac_est, v32_land_expansion(j2,type32,ac_est)); diff --git a/modules/32_forestry/dynamic_feb21/postsolve.gms b/modules/32_forestry/dynamic_feb21/postsolve.gms index 20733b8320..2b4ec5bd53 100644 --- a/modules/32_forestry/dynamic_feb21/postsolve.gms +++ b/modules/32_forestry/dynamic_feb21/postsolve.gms @@ -23,9 +23,11 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov_prod_forestry(t,j,kforestry,"marginal") = vm_prod_forestry.m(j,kforestry); ov_landexpansion_forestry(t,j,type32,"marginal") = vm_landexpansion_forestry.m(j,type32); ov_landreduction_forestry(t,j,type32,"marginal") = vm_landreduction_forestry.m(j,type32); + ov_land_forestry(t,j,type32,"marginal") = vm_land_forestry.m(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"marginal") = vm_cdr_aff.m(j,ac,aff_effect); oq32_cost_total(t,i,"marginal") = q32_cost_total.m(i); oq32_land(t,j,"marginal") = q32_land.m(j); + oq32_land_type32(t,j,type32,"marginal") = q32_land_type32.m(j,type32); oq32_cdr_aff(t,j,ac,"marginal") = q32_cdr_aff.m(j,ac); oq32_carbon(t,j,ag_pools,stockType,"marginal") = q32_carbon.m(j,ag_pools,stockType); oq32_land_diff(t,"marginal") = q32_land_diff.m; @@ -63,9 +65,11 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov_prod_forestry(t,j,kforestry,"level") = vm_prod_forestry.l(j,kforestry); ov_landexpansion_forestry(t,j,type32,"level") = vm_landexpansion_forestry.l(j,type32); ov_landreduction_forestry(t,j,type32,"level") = vm_landreduction_forestry.l(j,type32); + ov_land_forestry(t,j,type32,"level") = vm_land_forestry.l(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"level") = vm_cdr_aff.l(j,ac,aff_effect); oq32_cost_total(t,i,"level") = q32_cost_total.l(i); oq32_land(t,j,"level") = q32_land.l(j); + oq32_land_type32(t,j,type32,"level") = q32_land_type32.l(j,type32); oq32_cdr_aff(t,j,ac,"level") = q32_cdr_aff.l(j,ac); oq32_carbon(t,j,ag_pools,stockType,"level") = q32_carbon.l(j,ag_pools,stockType); oq32_land_diff(t,"level") = q32_land_diff.l; @@ -103,9 +107,11 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov_prod_forestry(t,j,kforestry,"upper") = vm_prod_forestry.up(j,kforestry); ov_landexpansion_forestry(t,j,type32,"upper") = vm_landexpansion_forestry.up(j,type32); ov_landreduction_forestry(t,j,type32,"upper") = vm_landreduction_forestry.up(j,type32); + ov_land_forestry(t,j,type32,"upper") = vm_land_forestry.up(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"upper") = vm_cdr_aff.up(j,ac,aff_effect); oq32_cost_total(t,i,"upper") = q32_cost_total.up(i); oq32_land(t,j,"upper") = q32_land.up(j); + oq32_land_type32(t,j,type32,"upper") = q32_land_type32.up(j,type32); oq32_cdr_aff(t,j,ac,"upper") = q32_cdr_aff.up(j,ac); oq32_carbon(t,j,ag_pools,stockType,"upper") = q32_carbon.up(j,ag_pools,stockType); oq32_land_diff(t,"upper") = q32_land_diff.up; @@ -143,9 +149,11 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov_prod_forestry(t,j,kforestry,"lower") = vm_prod_forestry.lo(j,kforestry); ov_landexpansion_forestry(t,j,type32,"lower") = vm_landexpansion_forestry.lo(j,type32); ov_landreduction_forestry(t,j,type32,"lower") = vm_landreduction_forestry.lo(j,type32); + ov_land_forestry(t,j,type32,"lower") = vm_land_forestry.lo(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"lower") = vm_cdr_aff.lo(j,ac,aff_effect); oq32_cost_total(t,i,"lower") = q32_cost_total.lo(i); oq32_land(t,j,"lower") = q32_land.lo(j); + oq32_land_type32(t,j,type32,"lower") = q32_land_type32.lo(j,type32); oq32_cdr_aff(t,j,ac,"lower") = q32_cdr_aff.lo(j,ac); oq32_carbon(t,j,ag_pools,stockType,"lower") = q32_carbon.lo(j,ag_pools,stockType); oq32_land_diff(t,"lower") = q32_land_diff.lo; diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 69c878cfa3..438b709e37 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -93,6 +93,7 @@ pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); p32_land_before(t,j,type32,ac) = p32_land(t,j,type32,ac); vm_land.l(j,"forestry") = sum((type32,ac), v32_land.l(j,type32,ac)); pcm_land(j,"forestry") = sum((type32,ac), v32_land.l(j,type32,ac)); +pcm_land_forestry(j,type32) = sum(ac, v32_land.l(j,type32,ac)); ** reset all bounds v32_land.lo(j,type32,ac) = 0; diff --git a/modules/58_peatland/module.gms b/modules/58_peatland/module.gms index a69f8bb9a3..d9e66e626f 100644 --- a/modules/58_peatland/module.gms +++ b/modules/58_peatland/module.gms @@ -13,6 +13,5 @@ *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%peatland%" == "off" $include "./modules/58_peatland/off/realization.gms" -$Ifi "%peatland%" == "on" $include "./modules/58_peatland/on/realization.gms" $Ifi "%peatland%" == "v2" $include "./modules/58_peatland/v2/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/58_peatland/off/not_used.txt b/modules/58_peatland/off/not_used.txt index 01c510fae9..0297c16bec 100644 --- a/modules/58_peatland/off/not_used.txt +++ b/modules/58_peatland/off/not_used.txt @@ -1,6 +1,8 @@ name, type, reason vm_land, input, not used pcm_land, input, not used +vm_land_forestry, input, not used +pcm_land_forestry, input, not used pm_interest, input, not used pm_climate_class, input, not used vm_landexpansion, input, not used diff --git a/modules/58_peatland/on/declarations.gms b/modules/58_peatland/on/declarations.gms deleted file mode 100644 index 0effd7a210..0000000000 --- a/modules/58_peatland/on/declarations.gms +++ /dev/null @@ -1,83 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -parameters - p58_scaling_factor(j) Scaling factor for managed peatland (1) - p58_calib_factor(j,land58) Calibration factor for managed peatland (1) - p58_peatland_degrad(j) Intermediate calculation in peatland initialization (mio. ha) - p58_ipcc_wetland_ef(clcl58,land58,emis58,man58) Wetland GWP100 emission factors (t CO2eq per ha) - p58_man_land_area(j) Total managed land (mio. ha) - pc58_peatland_man(j,man58,land58) Managed peatland (mio. ha) - pc58_peatland_intact(j) Intact peatland (mio. ha) - p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) - p58_peatland_degrad_weight(j,land58) Weight for peatland distribution to land58 (1) - i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) - i58_cost_rewet_onetime(t) One-time costs for peatland restoration (USD05MER per ha) - i58_cost_degrad_recur(t) Recurring costs for degraded peatland (USD05MER per ha) - i58_cost_degrad_onetime(t) One-time costs for peatland degradation (USD05MER per ha) - p58_conversion_factor(emisSub58) Conversion factor from GWP100 GHG emissions to element (1) -; - -equations - q58_transition_matrix(j) Peatland transitions (mio. ha) - q58_transition_to(j,to58) Peatland transitions to (mio. ha) - q58_transition_from(j,from58) Peatland transitions from (mio. ha) - q58_expansion(j,to58) Peatland expansion (mio. ha) - q58_reduction(j,from58) Peatland reduction (mio. ha) - q58_peatland_degrad(j,land58) Constraint for peatland degradation (mio. ha) - q58_peatland_rewet(j) Constraint for peatland rewetting (mio. ha) - q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - q58_peatland_cost_annuity(j) Annuity costs of peatland conversion in the current timestep (mio. USD05MER per yr) - q58_peatland_emis_detail(j,emis58) Detailed GHG emissions from managed peatland (t CO2eq per year) - q58_peatland_emis(i,poll58) GHG emissions from managed peatland (Tg per yr) -; - -variables - vm_peatland_cost(j) One-time and recurring cost of managed peatland including artifical balance cost (mio. USD05MER per yr) - v58_peatland_cost(j) One-time and recurring cost of managed peatland (mio. USD05MER per yr) - v58_peatland_cost_annuity(j) Annuity costs of managed peatland expansion in the current timestep (mio. USD05MER per yr) - v58_peatland_emis(j,emis58) Detailed GHG emissions from managed peatland (t CO2eq per year) -; - -positive variables - v58_lu_transitions(j,from58,to58) Peatland transitions (mio. ha) - v58_expansion(j,stat58) Peatland expansion (mio. ha) - v58_reduction(j,stat58) Peatland reduction (mio. ha) - v58_peatland_man(j,man58,land58) Managed peatland (mio. ha) - v58_peatland_intact(j) Intact peatland (mio. ha) - v58_balance_positive(j) Balance variable for peatland transitions (mio. ha) - v58_balance_negative(j) Balance variable for peatland transitions (mio. ha) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_peatland_cost(t,j,type) One-time and recurring cost of managed peatland including artifical balance cost (mio. USD05MER per yr) - ov58_peatland_cost(t,j,type) One-time and recurring cost of managed peatland (mio. USD05MER per yr) - ov58_peatland_cost_annuity(t,j,type) Annuity costs of managed peatland expansion in the current timestep (mio. USD05MER per yr) - ov58_peatland_emis(t,j,emis58,type) Detailed GHG emissions from managed peatland (t CO2eq per year) - ov58_lu_transitions(t,j,from58,to58,type) Peatland transitions (mio. ha) - ov58_expansion(t,j,stat58,type) Peatland expansion (mio. ha) - ov58_reduction(t,j,stat58,type) Peatland reduction (mio. ha) - ov58_peatland_man(t,j,man58,land58,type) Managed peatland (mio. ha) - ov58_peatland_intact(t,j,type) Intact peatland (mio. ha) - ov58_balance_positive(t,j,type) Balance variable for peatland transitions (mio. ha) - ov58_balance_negative(t,j,type) Balance variable for peatland transitions (mio. ha) - oq58_transition_matrix(t,j,type) Peatland transitions (mio. ha) - oq58_transition_to(t,j,to58,type) Peatland transitions to (mio. ha) - oq58_transition_from(t,j,from58,type) Peatland transitions from (mio. ha) - oq58_expansion(t,j,to58,type) Peatland expansion (mio. ha) - oq58_reduction(t,j,from58,type) Peatland reduction (mio. ha) - oq58_peatland_degrad(t,j,land58,type) Constraint for peatland degradation (mio. ha) - oq58_peatland_rewet(t,j,type) Constraint for peatland rewetting (mio. ha) - oq58_peatland_cost_full(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - oq58_peatland_cost_annuity(t,j,type) Annuity costs of peatland conversion in the current timestep (mio. USD05MER per yr) - oq58_peatland_emis_detail(t,j,emis58,type) Detailed GHG emissions from managed peatland (t CO2eq per year) - oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/58_peatland/on/equations.gms b/modules/58_peatland/on/equations.gms deleted file mode 100644 index 78b8ef032b..0000000000 --- a/modules/58_peatland/on/equations.gms +++ /dev/null @@ -1,114 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*' @equations - -*' Land transition matrix for peatland area. -*' The sum of current peatland area defined in `v58_lu_transitions` has to equal the sum of -*' peatland area in the previous time step (`pc58_peatland_man` + `pc58_peatland_intact`). -*' The two balancing variables `v58_balance_positive` and `v58_balance_negative` are needed -*' to avoid technical infeasibilities due to small differences in accuracy between -*' variables and parameters in GAMS. The use of `v58_balance_positive` and -*' `v58_balance_negative` is minimized by putting a high cost factor on these variables -*' (`q58_peatland_cost_full`). In practice, `v58_balance_positive` and -*' `v58_balance_negative`should deviate from zero only in exceptional cases. - - q58_transition_matrix(j2) .. - sum((from58,to58), v58_lu_transitions(j2,from58,to58)) - + v58_balance_positive(j2) - v58_balance_negative(j2) =e= - sum((man58,land58), pc58_peatland_man(j2,man58,land58)) + pc58_peatland_intact(j2); - - q58_transition_to(j2,to58) .. - sum(from58, v58_lu_transitions(j2,from58,to58)) =e= - v58_peatland_man(j2,"degrad","crop")$(sameas(to58,"degrad_crop")) - + v58_peatland_man(j2,"degrad","past")$(sameas(to58,"degrad_past")) - + v58_peatland_man(j2,"degrad","forestry")$(sameas(to58,"degrad_forestry")) - + v58_peatland_man(j2,"unused","crop")$(sameas(to58,"unused_crop")) - + v58_peatland_man(j2,"unused","past")$(sameas(to58,"unused_past")) - + v58_peatland_man(j2,"unused","forestry")$(sameas(to58,"unused_forestry")) - + v58_peatland_man(j2,"rewet","crop")$(sameas(to58,"rewet_crop")) - + v58_peatland_man(j2,"rewet","past")$(sameas(to58,"rewet_past")) - + v58_peatland_man(j2,"rewet","forestry")$(sameas(to58,"rewet_forestry")) - + v58_peatland_intact(j2)$(sameas(to58,"intact")); - - q58_transition_from(j2,from58) .. - sum(to58, v58_lu_transitions(j2,from58,to58)) =e= - pc58_peatland_man(j2,"degrad","crop")$(sameas(from58,"degrad_crop")) - + pc58_peatland_man(j2,"degrad","past")$(sameas(from58,"degrad_past")) - + pc58_peatland_man(j2,"degrad","forestry")$(sameas(from58,"degrad_forestry")) - + pc58_peatland_man(j2,"unused","crop")$(sameas(from58,"unused_crop")) - + pc58_peatland_man(j2,"unused","past")$(sameas(from58,"unused_past")) - + pc58_peatland_man(j2,"unused","forestry")$(sameas(from58,"unused_forestry")) - + pc58_peatland_man(j2,"rewet","crop")$(sameas(from58,"rewet_crop")) - + pc58_peatland_man(j2,"rewet","past")$(sameas(from58,"rewet_past")) - + pc58_peatland_man(j2,"rewet","forestry")$(sameas(from58,"rewet_forestry")) - + pc58_peatland_intact(j2)$(sameas(from58,"intact")); - -*' The following two equations calculate land expansion and land contraction based -*' on the above land transition matrix. - - q58_expansion(j2,to58) .. - v58_expansion(j2,to58) =e= - sum(from58$(not sameas(from58,to58)), - v58_lu_transitions(j2,from58,to58)); - - q58_reduction(j2,from58) .. - v58_reduction(j2,from58) =e= - sum(to58$(not sameas(from58,to58)), - v58_lu_transitions(j2,from58,to58)); - -*' Future peatland degradation (`v58_peatland_man`) depends on managed land (`vm_land`), -*' scaled with the ratio of total peatland area and total land area (`p58_scaling_factor`) -*' and a calibration factor (`p58_calib_factor`) for alignment with historic levels of degraded peatland. -*' By multiplying changes in managed land (`vm_land`) with the scaling factor we implicitly assume -*' that intact peatlands are distributed equally within a grid cell. -*' The following example illustrates the mechanism used for projecting peatland dynamics: -*' In a given grid cell, the total land area is 50 Mha and the total peatland area is 10 Mha. -*' Therefore, the scaling factor is 0.2 (10 Mha divided by 50 Mha). -*' If cropland expands by 5 Mha, 1 Mha of intact peatland is converted to degraded peatland (5 Mha x 0.2). -*' If the total cell would become cropland, degraded peatland would equal to the total peatland area (50 Mha x 0.2 = 10 Mha). - - q58_peatland_degrad(j2,land58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. - v58_peatland_man(j2,"degrad",land58) =e= - vm_land(j2,land58)*p58_scaling_factor(j2)*p58_calib_factor(j2,land58); - -*' This constraint avoids the conversion of intact peatland into rewetted peatland. - - q58_peatland_rewet(j2) .. - sum(stat_rewet58, v58_expansion(j2,stat_rewet58)) =l= - sum(stat_degrad58, v58_reduction(j2,stat_degrad58) + v58_expansion(j2,stat_degrad58)) - v58_reduction(j2,"intact"); - -*' Costs for peatland degradation and rewetting - - q58_peatland_cost_full(j2) .. - vm_peatland_cost(j2) =e= v58_peatland_cost(j2) + (v58_balance_positive(j2) + v58_balance_negative(j2)) * s58_cost_balance; - - q58_peatland_cost(j2) .. - v58_peatland_cost(j2) =e= v58_peatland_cost_annuity(j2) - + sum(land58, v58_peatland_man(j2,"rewet",land58)) * sum(ct, i58_cost_rewet_recur(ct)) - + sum((degrad58,land58), v58_peatland_man(j2,degrad58,land58)) * sum(ct, i58_cost_degrad_recur(ct)); - - q58_peatland_cost_annuity(j2) .. - v58_peatland_cost_annuity(j2) =e= - (sum(stat_rewet58, v58_expansion(j2,stat_rewet58)) * sum(ct, i58_cost_rewet_onetime(ct)) - + (v58_reduction(j2,"intact") + sum(stat_rewet58, v58_reduction(j2,stat_rewet58))) * sum(ct, i58_cost_degrad_onetime(ct))) - * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - -*' GHG emissions from managed peatlands (degraded and rewetted) - - q58_peatland_emis_detail(j2,emis58) .. - v58_peatland_emis(j2,emis58) =e= - sum((man58,land58,clcl58), v58_peatland_man(j2,man58,land58) * - p58_mapping_cell_climate(j2,clcl58) * p58_ipcc_wetland_ef(clcl58,land58,emis58,man58)); - -*' Conversion from CO2 equivalent to element unit for interface `vm_emissions_reg` -*' using GWP100 conversion factors from AR5 (same as in @wilson_2016). - - q58_peatland_emis(i2,poll58) .. - vm_emissions_reg(i2,"peatland",poll58) =e= - sum((cell(i2,j2),emisSub58_to_poll58(emisSub58,poll58)), - v58_peatland_emis(j2,emisSub58) * p58_conversion_factor(emisSub58)); diff --git a/modules/58_peatland/on/input.gms b/modules/58_peatland/on/input.gms deleted file mode 100644 index 2a9a73cc03..0000000000 --- a/modules/58_peatland/on/input.gms +++ /dev/null @@ -1,40 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -scalars - s58_cost_rewet_recur Recurring costs for rewetted peatland (USD05MER per ha) / 200 / - s58_cost_rewet_onetime One-time costs for peatland restoration (USD05MER per ha) / 7000 / - s58_cost_degrad_recur Recurring costs for degraded peatland (USD05MER per ha) / 0 / - s58_cost_degrad_onetime One-time costs for peatland degradation (USD05MER per ha) / 0 / - s58_rewetting_switch Peatland rewetting on (Inf) or off (0) / Inf / - s58_fix_peatland Year indicating until when peatland area should be fixed to 2015 levels (year) / 2015 / - s58_cost_balance Artificial cost for balance variable (USD05MER per ha) / 1e+06 / -; - -parameters -f58_peatland_degrad(j) Degrading peatland area (mio. ha) -/ -$ondelim -$include "./modules/58_peatland/input/f58_peatland_degrad.cs2" -$offdelim -/ -; - -parameters -f58_peatland_intact(j) Intact peatland area (mio. ha) -/ -$ondelim -$include "./modules/58_peatland/input/f58_peatland_intact.cs2" -$offdelim -/ -; - -table f58_ipcc_wetland_ef(clcl58,land58,emis58,ef58) Wetland GWP100 emission factors (t CO2eq per ha) -$ondelim -$include "./modules/58_peatland/input/f58_ipcc_wetland_ef.cs3" -$offdelim -; diff --git a/modules/58_peatland/on/not_used.txt b/modules/58_peatland/on/not_used.txt deleted file mode 100644 index 9a52df7eb8..0000000000 --- a/modules/58_peatland/on/not_used.txt +++ /dev/null @@ -1,5 +0,0 @@ -name, type, reason -vm_landexpansion, input, not used -vm_landreduction, input, not used -vm_landexpansion_forestry, input, not used -vm_landreduction_forestry, input, not used diff --git a/modules/58_peatland/on/postsolve.gms b/modules/58_peatland/on/postsolve.gms deleted file mode 100644 index 0c9b5643f0..0000000000 --- a/modules/58_peatland/on/postsolve.gms +++ /dev/null @@ -1,115 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -* Update of degraded peatland based on current managed land in the last time steps of fixed peatland area. -if (m_year(t) = s58_fix_peatland, - p58_scaling_factor(j)$(sum(land, vm_land.l(j,land)) > 1e-20) = (sum((man58,land58), v58_peatland_man.l(j,man58,land58)) + v58_peatland_intact.l(j)) / sum(land, vm_land.l(j,land)); - p58_calib_factor(j,land58) = 1; - p58_calib_factor(j,land58)$(vm_land.l(j,land58) * p58_scaling_factor(j) > 1e-20) = (p58_peatland_degrad(j) * p58_peatland_degrad_weight(j,land58)) / (vm_land.l(j,land58) * p58_scaling_factor(j)); - p58_calib_factor(j,land58)$(p58_calib_factor(j,land58) > 1) = 1; - pc58_peatland_man(j,"degrad",land58) = vm_land.l(j,land58) * p58_scaling_factor(j) * p58_calib_factor(j,land58); - pc58_peatland_man(j,"unused",land58) = p58_peatland_degrad(j) * p58_peatland_degrad_weight(j,land58) - pc58_peatland_man(j,"degrad",land58); -else - pc58_peatland_man(j,man58,land58) = v58_peatland_man.l(j,man58,land58); -); - -pc58_peatland_intact(j) = v58_peatland_intact.l(j); - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); - ov58_peatland_cost(t,j,"marginal") = v58_peatland_cost.m(j); - ov58_peatland_cost_annuity(t,j,"marginal") = v58_peatland_cost_annuity.m(j); - ov58_peatland_emis(t,j,emis58,"marginal") = v58_peatland_emis.m(j,emis58); - ov58_lu_transitions(t,j,from58,to58,"marginal") = v58_lu_transitions.m(j,from58,to58); - ov58_expansion(t,j,stat58,"marginal") = v58_expansion.m(j,stat58); - ov58_reduction(t,j,stat58,"marginal") = v58_reduction.m(j,stat58); - ov58_peatland_man(t,j,man58,land58,"marginal") = v58_peatland_man.m(j,man58,land58); - ov58_peatland_intact(t,j,"marginal") = v58_peatland_intact.m(j); - ov58_balance_positive(t,j,"marginal") = v58_balance_positive.m(j); - ov58_balance_negative(t,j,"marginal") = v58_balance_negative.m(j); - oq58_transition_matrix(t,j,"marginal") = q58_transition_matrix.m(j); - oq58_transition_to(t,j,to58,"marginal") = q58_transition_to.m(j,to58); - oq58_transition_from(t,j,from58,"marginal") = q58_transition_from.m(j,from58); - oq58_expansion(t,j,to58,"marginal") = q58_expansion.m(j,to58); - oq58_reduction(t,j,from58,"marginal") = q58_reduction.m(j,from58); - oq58_peatland_degrad(t,j,land58,"marginal") = q58_peatland_degrad.m(j,land58); - oq58_peatland_rewet(t,j,"marginal") = q58_peatland_rewet.m(j); - oq58_peatland_cost_full(t,j,"marginal") = q58_peatland_cost_full.m(j); - oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); - oq58_peatland_cost_annuity(t,j,"marginal") = q58_peatland_cost_annuity.m(j); - oq58_peatland_emis_detail(t,j,emis58,"marginal") = q58_peatland_emis_detail.m(j,emis58); - oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); - ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); - ov58_peatland_cost(t,j,"level") = v58_peatland_cost.l(j); - ov58_peatland_cost_annuity(t,j,"level") = v58_peatland_cost_annuity.l(j); - ov58_peatland_emis(t,j,emis58,"level") = v58_peatland_emis.l(j,emis58); - ov58_lu_transitions(t,j,from58,to58,"level") = v58_lu_transitions.l(j,from58,to58); - ov58_expansion(t,j,stat58,"level") = v58_expansion.l(j,stat58); - ov58_reduction(t,j,stat58,"level") = v58_reduction.l(j,stat58); - ov58_peatland_man(t,j,man58,land58,"level") = v58_peatland_man.l(j,man58,land58); - ov58_peatland_intact(t,j,"level") = v58_peatland_intact.l(j); - ov58_balance_positive(t,j,"level") = v58_balance_positive.l(j); - ov58_balance_negative(t,j,"level") = v58_balance_negative.l(j); - oq58_transition_matrix(t,j,"level") = q58_transition_matrix.l(j); - oq58_transition_to(t,j,to58,"level") = q58_transition_to.l(j,to58); - oq58_transition_from(t,j,from58,"level") = q58_transition_from.l(j,from58); - oq58_expansion(t,j,to58,"level") = q58_expansion.l(j,to58); - oq58_reduction(t,j,from58,"level") = q58_reduction.l(j,from58); - oq58_peatland_degrad(t,j,land58,"level") = q58_peatland_degrad.l(j,land58); - oq58_peatland_rewet(t,j,"level") = q58_peatland_rewet.l(j); - oq58_peatland_cost_full(t,j,"level") = q58_peatland_cost_full.l(j); - oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); - oq58_peatland_cost_annuity(t,j,"level") = q58_peatland_cost_annuity.l(j); - oq58_peatland_emis_detail(t,j,emis58,"level") = q58_peatland_emis_detail.l(j,emis58); - oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); - ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); - ov58_peatland_cost(t,j,"upper") = v58_peatland_cost.up(j); - ov58_peatland_cost_annuity(t,j,"upper") = v58_peatland_cost_annuity.up(j); - ov58_peatland_emis(t,j,emis58,"upper") = v58_peatland_emis.up(j,emis58); - ov58_lu_transitions(t,j,from58,to58,"upper") = v58_lu_transitions.up(j,from58,to58); - ov58_expansion(t,j,stat58,"upper") = v58_expansion.up(j,stat58); - ov58_reduction(t,j,stat58,"upper") = v58_reduction.up(j,stat58); - ov58_peatland_man(t,j,man58,land58,"upper") = v58_peatland_man.up(j,man58,land58); - ov58_peatland_intact(t,j,"upper") = v58_peatland_intact.up(j); - ov58_balance_positive(t,j,"upper") = v58_balance_positive.up(j); - ov58_balance_negative(t,j,"upper") = v58_balance_negative.up(j); - oq58_transition_matrix(t,j,"upper") = q58_transition_matrix.up(j); - oq58_transition_to(t,j,to58,"upper") = q58_transition_to.up(j,to58); - oq58_transition_from(t,j,from58,"upper") = q58_transition_from.up(j,from58); - oq58_expansion(t,j,to58,"upper") = q58_expansion.up(j,to58); - oq58_reduction(t,j,from58,"upper") = q58_reduction.up(j,from58); - oq58_peatland_degrad(t,j,land58,"upper") = q58_peatland_degrad.up(j,land58); - oq58_peatland_rewet(t,j,"upper") = q58_peatland_rewet.up(j); - oq58_peatland_cost_full(t,j,"upper") = q58_peatland_cost_full.up(j); - oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); - oq58_peatland_cost_annuity(t,j,"upper") = q58_peatland_cost_annuity.up(j); - oq58_peatland_emis_detail(t,j,emis58,"upper") = q58_peatland_emis_detail.up(j,emis58); - oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); - ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); - ov58_peatland_cost(t,j,"lower") = v58_peatland_cost.lo(j); - ov58_peatland_cost_annuity(t,j,"lower") = v58_peatland_cost_annuity.lo(j); - ov58_peatland_emis(t,j,emis58,"lower") = v58_peatland_emis.lo(j,emis58); - ov58_lu_transitions(t,j,from58,to58,"lower") = v58_lu_transitions.lo(j,from58,to58); - ov58_expansion(t,j,stat58,"lower") = v58_expansion.lo(j,stat58); - ov58_reduction(t,j,stat58,"lower") = v58_reduction.lo(j,stat58); - ov58_peatland_man(t,j,man58,land58,"lower") = v58_peatland_man.lo(j,man58,land58); - ov58_peatland_intact(t,j,"lower") = v58_peatland_intact.lo(j); - ov58_balance_positive(t,j,"lower") = v58_balance_positive.lo(j); - ov58_balance_negative(t,j,"lower") = v58_balance_negative.lo(j); - oq58_transition_matrix(t,j,"lower") = q58_transition_matrix.lo(j); - oq58_transition_to(t,j,to58,"lower") = q58_transition_to.lo(j,to58); - oq58_transition_from(t,j,from58,"lower") = q58_transition_from.lo(j,from58); - oq58_expansion(t,j,to58,"lower") = q58_expansion.lo(j,to58); - oq58_reduction(t,j,from58,"lower") = q58_reduction.lo(j,from58); - oq58_peatland_degrad(t,j,land58,"lower") = q58_peatland_degrad.lo(j,land58); - oq58_peatland_rewet(t,j,"lower") = q58_peatland_rewet.lo(j); - oq58_peatland_cost_full(t,j,"lower") = q58_peatland_cost_full.lo(j); - oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); - oq58_peatland_cost_annuity(t,j,"lower") = q58_peatland_cost_annuity.lo(j); - oq58_peatland_emis_detail(t,j,emis58,"lower") = q58_peatland_emis_detail.lo(j,emis58); - oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/58_peatland/on/preloop.gms b/modules/58_peatland/on/preloop.gms deleted file mode 100644 index c679acaa1d..0000000000 --- a/modules/58_peatland/on/preloop.gms +++ /dev/null @@ -1,43 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -vm_emissions_reg.fx(i,"peatland",pollutants) = 0; -vm_emissions_reg.lo(i,"peatland",poll58) = -Inf; -vm_emissions_reg.up(i,"peatland",poll58) = Inf; - -* GHG emission conversion factors from GWP100 to element unit. -p58_conversion_factor("co2") = 12/44; -p58_conversion_factor("ch4") = 1/34; -p58_conversion_factor("n2o") = 1/298*28/44; - -p58_mapping_cell_climate(j,clcl58) = sum(clcl_mapping(clcl,clcl58),pm_climate_class(j,clcl)); - -p58_ipcc_wetland_ef(clcl58,land58,emis58,ef58) = f58_ipcc_wetland_ef(clcl58,land58,emis58,ef58); -p58_ipcc_wetland_ef(clcl58,land58,emis58,"unused") = f58_ipcc_wetland_ef(clcl58,land58,emis58,"degrad"); - -* Peatland scaling factor: ratio of total peatland area and total land area -p58_scaling_factor(j) = (f58_peatland_degrad(j) + f58_peatland_intact(j)) / sum(land, pcm_land(j,land)); -* Intact peatland area -pc58_peatland_intact(j) = f58_peatland_intact(j); -* Share of cropland, pasture and forestry in total managed land, used for distribution of degraded peatland (f58_peatland_degrad) to managed land. -p58_man_land_area(j) = sum(land58, pcm_land(j,land58)); -p58_peatland_degrad_weight(j,land58) = 1/card(land58); -p58_peatland_degrad_weight(j,land58)$(p58_man_land_area(j) > 0) = pcm_land(j,land58) / p58_man_land_area(j); -* Calibration factor for alignment with historic levels of degraded peatland -p58_calib_factor(j,land58) = 1; -p58_calib_factor(j,land58)$(pcm_land(j,land58) * p58_scaling_factor(j) > 1e-20) = (f58_peatland_degrad(j) * p58_peatland_degrad_weight(j,land58)) / (pcm_land(j,land58)*p58_scaling_factor(j)); -p58_calib_factor(j,land58)$(p58_calib_factor(j,land58) > 1) = 1; - -* Initialization of peatland -pc58_peatland_man(j,man58,land58) = 0; -* Degraded peatland is estimated by multiplication of managed land (pcm_land) with the peatland scaling factor (p58_scaling_factor). -* The calibration factor (p58_calib_factor) reduces this estimate to historic levels of degraded peatland. p58_calib_factor is 1 for most cases. -pc58_peatland_man(j,"degrad",land58) = pcm_land(j,land58) * p58_scaling_factor(j) * p58_calib_factor(j,land58); -* The residual is added to an "unused" category, which represents degraded but unused peatland. -pc58_peatland_man(j,"unused",land58) = f58_peatland_degrad(j) * p58_peatland_degrad_weight(j,land58) - pc58_peatland_man(j,"degrad",land58); -pc58_peatland_man(j,"unused",land58)$(pc58_peatland_man(j,"unused",land58) < 0) = 0; -p58_peatland_degrad(j) = sum((man58,land58), pc58_peatland_man(j,man58,land58)); diff --git a/modules/58_peatland/on/presolve.gms b/modules/58_peatland/on/presolve.gms deleted file mode 100644 index ce77e7f904..0000000000 --- a/modules/58_peatland/on/presolve.gms +++ /dev/null @@ -1,57 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*define bound for peatland area - v58_peatland_man.lo(j,man58,land58) = 0; - v58_peatland_man.up(j,"degrad",land58) = Inf; - v58_peatland_man.up(j,"unused",land58) = Inf; - v58_peatland_man.l(j,man58,land58) = pc58_peatland_man(j,man58,land58); - -*define allowed transitions within peatland area - v58_lu_transitions.fx(j,from58,to58)$(not sameas(from58,to58)) = 0; - v58_lu_transitions.up(j,"intact","degrad_crop") = Inf; - v58_lu_transitions.up(j,"intact","degrad_past") = Inf; - v58_lu_transitions.up(j,"intact","degrad_forestry") = Inf; - v58_lu_transitions.up(j,"degrad_crop","unused_crop") = Inf; - v58_lu_transitions.up(j,"degrad_past","unused_past") = Inf; - v58_lu_transitions.up(j,"degrad_forestry","unused_forestry") = Inf; - v58_lu_transitions.up(j,"degrad_crop","rewet_crop") = Inf; - v58_lu_transitions.up(j,"degrad_past","rewet_past") = Inf; - v58_lu_transitions.up(j,"degrad_forestry","rewet_forestry") = Inf; - v58_lu_transitions.up(j,"unused_crop","degrad_crop") = Inf; - v58_lu_transitions.up(j,"unused_crop","degrad_past") = Inf; - v58_lu_transitions.up(j,"unused_crop","degrad_forestry") = Inf; - v58_lu_transitions.up(j,"unused_past","degrad_crop") = Inf; - v58_lu_transitions.up(j,"unused_past","degrad_past") = Inf; - v58_lu_transitions.up(j,"unused_past","degrad_forestry") = Inf; - v58_lu_transitions.up(j,"unused_forestry","degrad_crop") = Inf; - v58_lu_transitions.up(j,"unused_forestry","degrad_past") = Inf; - v58_lu_transitions.up(j,"unused_forestry","degrad_forestry") = Inf; - v58_lu_transitions.up(j,"unused_crop","rewet_crop") = Inf; - v58_lu_transitions.up(j,"unused_past","rewet_past") = Inf; - v58_lu_transitions.up(j,"unused_forestry","rewet_forestry") = Inf; - v58_lu_transitions.up(j,"rewet_crop","degrad_crop") = Inf; - v58_lu_transitions.up(j,"rewet_past","degrad_past") = Inf; - v58_lu_transitions.up(j,"rewet_forestry","degrad_forestry") = Inf; - -if (m_year(t) <= s58_fix_peatland, - v58_peatland_man.fx(j,man58,land58) = pc58_peatland_man(j,man58,land58); - v58_peatland_intact.fx(j) = pc58_peatland_intact(j); - i58_cost_rewet_recur(t) = 0; - i58_cost_rewet_onetime(t) = 0; - i58_cost_degrad_recur(t) = 0; - i58_cost_degrad_onetime(t) = 0; -else - v58_peatland_man.up(j,"rewet",land58) = s58_rewetting_switch; - v58_peatland_intact.lo(j) = 0; - v58_peatland_intact.up(j) = pc58_peatland_intact(j); - v58_peatland_intact.l(j) = pc58_peatland_intact(j); - i58_cost_rewet_recur(t) = s58_cost_rewet_recur; - i58_cost_rewet_onetime(t) = s58_cost_rewet_onetime; - i58_cost_degrad_recur(t) = s58_cost_degrad_recur; - i58_cost_degrad_onetime(t) = s58_cost_degrad_onetime; -); diff --git a/modules/58_peatland/on/realization.gms b/modules/58_peatland/on/realization.gms deleted file mode 100644 index 8485443ce9..0000000000 --- a/modules/58_peatland/on/realization.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -*' @description In this realization, the state of peatlands is modelled as described in @humpenoder_peatland_2020. -*' The initial map of peatland area consists of intact and degraded peatland area for the year 2015, -*' based on @leifeld_2018 and the [Global Peatland Database](https://greifswaldmoor.de/global-peatland-database-en.html). -*' Future peatland dynamics are estimated by scaling changes in managed land with the ratio of total peatland area and total land area (peatland scaling factor). -*' GHG emissions from degraded and rewetted peatlands are calculated using IPCC wetland GHG emission factors from @IPCC_wetland_2013 and @wilson_2016. -*' @stop - - -*' -*' @limitations Peatland area and GHG emissions are fixed to 2015 levels for the historic period, -*' depending on `s58_fix_peatland`. Organic carbon stocks in peatlands are not accounted for. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/58_peatland/on/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/58_peatland/on/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/58_peatland/on/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/58_peatland/on/equations.gms" -$Ifi "%phase%" == "scaling" $include "./modules/58_peatland/on/scaling.gms" -$Ifi "%phase%" == "preloop" $include "./modules/58_peatland/on/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/58_peatland/on/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/58_peatland/on/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/58_peatland/on/scaling.gms b/modules/58_peatland/on/scaling.gms deleted file mode 100644 index 0d3b287285..0000000000 --- a/modules/58_peatland/on/scaling.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -v58_expansion.scale(j,stat58) = 10e-3; -v58_reduction.scale(j,stat58) = 10e-3; diff --git a/modules/58_peatland/on/sets.gms b/modules/58_peatland/on/sets.gms deleted file mode 100644 index a9bfd548b5..0000000000 --- a/modules/58_peatland/on/sets.gms +++ /dev/null @@ -1,94 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -sets - - man58 State of managed peatland - / degrad, unused, rewet / - - degrad58(man58) State of degraded peatland - / degrad, unused / - - ef58(man58) Peatland emissions factors - / degrad, rewet / - - land58(land) Managed land types - / crop, past, forestry / - - stat58 Peatland status - / intact, - degrad_crop, degrad_past, degrad_forestry, - unused_crop, unused_past, unused_forestry, - rewet_crop, rewet_past, rewet_forestry / - - stat_man58(stat58) Peatland status managed land - / degrad_crop, degrad_past, degrad_forestry, - unused_crop, unused_past, unused_forestry, - rewet_crop, rewet_past, rewet_forestry / - - stat_degrad58(stat58) Peatland status degrad - / degrad_crop, degrad_past, degrad_forestry, - unused_crop, unused_past, unused_forestry / - - stat_rewet58(stat58) Peatland status rewet - / rewet_crop, rewet_past, rewet_forestry / - - emis58 Wetland emission types - / co2, doc, ch4, n2o / - - emisSub58(emis58) Wetland emission types - / co2, ch4, n2o / - - poll58(pollutants) Wetland emissions that can be taxed - / co2_c, ch4, n2o_n_direct / - - emisSub58_to_poll58(emisSub58,poll58) Mapping - / co2 .(co2_c) - ch4 .(ch4) - n2o .(n2o_n_direct) / - - clcl58 simple climate classes - / tropical, temperate, boreal / - - clcl_mapping(clcl,clcl58) Mapping between detailed and simple climate classes - / - Af .(tropical) "Tropical rainforest climate" - Am .(tropical) "Tropical monsoon climate" - As .(tropical) "Tropical dry savanna climate" - Aw .(tropical) "Tropical savanna, wet" - BSh .(tropical) "Hot semi-arid (steppe) climate" - BSk .(tropical) "Cold semi-arid (steppe) climate" - BWh .(tropical) "Hot deserts climate" - BWk .(tropical) "Cold desert climate" - Cfa .(tropical) "Humid subtropical climate" - Cfb .(temperate) "Temperate oceanic climate" - Cfc .(boreal) "Subpolar oceanic climate" - Csa .(temperate) "Hot-summer Mediterranean climate" - Csb .(temperate) "Warm-summer Mediterranean climate" - Csc .(temperate) "Cool-summer Mediterranean climate" - Cwa .(tropical) "Monsoon-influenced humid subtropical climate" - Cwb .(tropical) "Dry-winter subtropical highland climate" - Cwc .(boreal) "Dry-winter subpolar oceanic climate" - Dfa .(temperate) "Hot-summer humid continental climate" - Dfb .(boreal) "Warm-summer humid continental climate" - Dfc .(boreal) "Subarctic climate" - Dfd .(boreal) "Extremely cold subarctic climate" - Dsa .(temperate) "Hot, dry-summer continental climate" - Dsb .(boreal) "Warm, dry-summer continental climate" - Dsc .(boreal) "Dry-summer subarctic climate" - Dsd .(boreal) "snow summer dry extremely continental" - Dwa .(temperate) "Monsoon-influenced hot-summer humid continental climate" - Dwb .(boreal) "Monsoon-influenced warm-summer humid continental climate" - Dwc .(boreal) "Monsoon-influenced subarctic climate" - Dwd .(boreal) "Monsoon-influenced extremely cold subarctic climate" - EF .(boreal) "Ice cap climate" - ET .(boreal) "Tundra" - / - -; - -alias (stat58, from58, to58); diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index 2dd283b5ab..5bb6a8ffb3 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -6,69 +6,74 @@ *** | Contact: magpie@pik-potsdam.de parameters - p58_scaling_factor_exp(t,j) Scaling factor for managed peatland expansion (1) - p58_scaling_factor_red(t,j) Scaling factor for managed peatland reduction (1) - pc58_peatland(j,land58) Peatland area (mio. ha) - p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) - i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) - i58_cost_rewet_onetime(t) One-time costs for peatland restoration (USD05MER per ha) - i58_cost_degrad_recur(t) Recurring costs for degraded peatland (USD05MER per ha) - i58_cost_degrad_onetime(t) One-time costs for peatland degradation (USD05MER per ha) - p58_weight(t,j,manPeat58) Weight for distribution of total peatland changes to managed peatland categories (1) + pc58_peatland(j,land58) Peatland area (mio. ha) + pc58_manLand(j,manPeat58) Managed land area (mio. ha) + p58_scalingFactorRed(t,j,manPeat58) Scaling factor for peatland reduction (1) + p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) + i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) + i58_cost_rewet_onetime(t) One-time costs for peatland restoration (USD05MER per ha) + i58_cost_degrad_recur(t) Recurring costs for degraded peatland (USD05MER per ha) + i58_cost_degrad_onetime(t) One-time costs for peatland degradation (USD05MER per ha) ; equations - q58_peatland(j) Constraint for total peatland area (mio. ha) - q58_peatlandChange(j,land58) Peatland area Change (mio. ha) - q58_peatlandMan(j,manPeat58) Change of managed peatland area (mio. ha) - q58_peatlandRewet(j) Change of rewetted peatland area (mio. ha) - q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - q58_peatland_cost_annuity_intact(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + q58_peatland(j) Constraint for total peatland area (mio. ha) + q58_peatlandChange(j,land58) Peatland area change (mio. ha) + q58_manLand(j,manPeat58) Managed land area (mio. ha) + q58_manLandExp(j,manPeat58) Managed land area expansion (mio. ha) + q58_manLandRed(j,manPeat58) Managed land area reduction (mio. ha) + q58_peatlandMan(j,manPeat58) Change of managed peatland area (mio. ha) + q58_scalingFactorExp(j,manPeat58) Scaling factor for peatland expansion (1) + q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + q58_peatland_cost_annuity_degrad(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) q58_peatland_cost_annuity_rewet(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) q58_peatland_emis_detail(j,land58,emis58) Detailed GHG emissions from peatlands (Tg per yr) q58_peatland_emis(i,poll58) GHG emissions from managed peatland (Tg per yr) - q58_manLandExp(j,manLand58) Managed land expansion (mio. ha) - q58_manLandRed(j,manLand58) Managed land reduction (mio. ha) ; variables + v58_peatlandChange(j,land58) Peatland area change (mio. ha) vm_peatland_cost(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) v58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) v58_peatland_emis(j,land58,emis58) Detailed GHG peatland GHG emissions (Tg per yr) - v58_peatlandChange(j,land58) Peatland area change (mio. ha) ; positive variables - v58_peatland_cost_annuity_intact(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - v58_peatland_cost_annuity_rewet(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) v58_peatland(j,land58) Peatland area (mio. ha) - v58_manLandExp(j,manLand58) Managed land expansion (mio. ha) - v58_manLandRed(j,manLand58) Managed land reduction (mio. ha) + v58_manLand(j,manPeat58) Managed land area (mio. ha) + v58_manLandExp(j,manPeat58) Managed land area expansion (mio. ha) + v58_manLandRed(j,manPeat58) Managed land area reduction (mio. ha) + v58_scalingFactorExp(j,manPeat58) Scaling factor for peatland expansion (1) + v58_peatland_cost_annuity_degrad(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + v58_peatland_cost_annuity_rewet(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters + ov58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) ov_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) ov58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) ov58_peatland_emis(t,j,land58,emis58,type) Detailed GHG peatland GHG emissions (Tg per yr) - ov58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) - ov58_peatland_cost_annuity_intact(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - ov58_peatland_cost_annuity_rewet(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) ov58_peatland(t,j,land58,type) Peatland area (mio. ha) - ov58_manLandExp(t,j,manLand58,type) Managed land expansion (mio. ha) - ov58_manLandRed(t,j,manLand58,type) Managed land reduction (mio. ha) + ov58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) + ov58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) + ov58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) + ov58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) + ov58_peatland_cost_annuity_degrad(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + ov58_peatland_cost_annuity_rewet(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) oq58_peatland(t,j,type) Constraint for total peatland area (mio. ha) - oq58_peatlandChange(t,j,land58,type) Peatland area Change (mio. ha) + oq58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) + oq58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) + oq58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) + oq58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) oq58_peatlandMan(t,j,manPeat58,type) Change of managed peatland area (mio. ha) - oq58_peatlandRewet(t,j,type) Change of rewetted peatland area (mio. ha) + oq58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) oq58_peatland_cost_full(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - oq58_peatland_cost_annuity_intact(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + oq58_peatland_cost_annuity_degrad(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) oq58_peatland_cost_annuity_rewet(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) oq58_peatland_emis_detail(t,j,land58,emis58,type) Detailed GHG emissions from peatlands (Tg per yr) oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) - oq58_manLandExp(t,j,manLand58,type) Managed land expansion (mio. ha) - oq58_manLandRed(t,j,manLand58,type) Managed land reduction (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index 69f1676262..62a2c900e1 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -17,40 +17,41 @@ q58_peatlandChange(j2,land58) .. v58_peatlandChange(j2,land58) =e= v58_peatland(j2,land58)-pc58_peatland(j2,land58); +*' Managed land area: + + q58_manLand(j2,manPeat58) .. + v58_manLand(j2,manPeat58) =e= m_peatLandMerge(vm_land,vm_land_forestry,"j2"); + *' Managed land area expansion and reduction: - q58_manLandExp(j2,manLand58) .. - v58_manLandExp(j2,manLand58) =e= - vm_landexpansion(j2,"crop")$(sameas(manLand58,"crop")) - + vm_landexpansion(j2,"past")$(sameas(manLand58,"past")) - + vm_landexpansion_forestry(j2,"plant")$(sameas(manLand58,"forestry")); + q58_manLandExp(j2,manPeat58) .. + v58_manLandExp(j2,manPeat58) =e= m_peatLandMerge(vm_landexpansion,vm_landexpansion_forestry,"j2"); - q58_manLandRed(j2,manLand58) .. - v58_manLandRed(j2,manLand58) =e= - vm_landreduction(j2,"crop")$(sameas(manLand58,"crop")) - + vm_landreduction(j2,"past")$(sameas(manLand58,"past")) - + vm_landreduction_forestry(j2,"plant")$(sameas(manLand58,"forestry")); + q58_manLandRed(j2,manPeat58) .. + v58_manLandRed(j2,manPeat58) =e= m_peatLandMerge(vm_landreduction,vm_landreduction_forestry,"j2"); *' Future peatland dynamics (`v58_peatland`) depend on changes in managed land (`v58_manLandExp`, `v58_manLandRed`), -*' multiplied with corresponding scaling factors for expansion (`p58_scaling_factor_exp`) and reduction (`p58_scaling_factor_red`). +*' multiplied with corresponding scaling factors for expansion (`v58_scalingFactorExp`) and reduction (`p58_scalingFactorRed`). *' The scaling factor for expansion makes sure that in case the full cell area consists of *' managed land (cropland, pasture, forestry plantations), the full peatland area is drained. *' Likewise, the scaling factor for reduction makes sure that in case no area is used for managed land, *' managed peatland (`manPeat58`) is reduced to zero. *' In case managed land remains unchanged, also managed peatland remains unchanged. -*' The distribution of changes in total peatland area to managed peatland categories (`manPeat58`) -*' depends on the weight of these categories in the previous time step (`p58_weight`). q58_peatlandMan(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland(j2,manPeat58) =e= pc58_peatland(j2,manPeat58) - + sum(manLand58, v58_manLandExp(j2,manLand58)) * sum(ct, p58_scaling_factor_exp(ct,j2) * p58_weight(ct,j2,manPeat58)) - - sum(manLand58, v58_manLandRed(j2,manLand58)) * sum(ct, p58_scaling_factor_red(ct,j2) * p58_weight(ct,j2,manPeat58)); + + v58_manLandExp(j2,manPeat58) * v58_scalingFactorExp(j2,manPeat58) + - v58_manLandRed(j2,manPeat58) * sum(ct, p58_scalingFactorRed(ct,j2,manPeat58)); -*' This constraint avoids the conversion of intact peatland into rewetted peatland. +*' Peatland scaling factor for expansion: (maxPeatland - totalManagedPeatland) / (maxLand - totalManagedLand). +*' See macro `m_peatLandLeft` for details. - q58_peatlandRewet(j2) .. - v58_peatlandChange(j2,"rewetted") =l= -sum(drained58, v58_peatlandChange(j2,drained58)) + v58_peatlandChange(j2,"intact"); +q58_scalingFactorExp(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_scalingFactorExp(j2,manPeat58) =e= + (m_peatLandLeft(pc58_peatland,"land58",v58_peatland,pc58_peatland) / m_peatLandLeft(pcm_land,"land",v58_manLand,pc58_manLand)) + $(m_peatLandLeft(pc58_peatland,"land58",pc58_peatland,pc58_peatland) > 1e-10 AND m_peatLandLeft(pcm_land,"land",pc58_manLand,pc58_manLand) > 1e-10) + + 0$(m_peatLandLeft(pc58_peatland,"land58",pc58_peatland,pc58_peatland) <= 1e-10 OR m_peatLandLeft(pcm_land,"land",pc58_manLand,pc58_manLand) <= 1e-10); *' Costs for peatland degradation and rewetting @@ -58,13 +59,13 @@ vm_peatland_cost(j2) =e= v58_peatland_cost(j2); q58_peatland_cost(j2) .. - v58_peatland_cost(j2) =e= v58_peatland_cost_annuity_intact(j2) + v58_peatland_cost_annuity_rewet(j2) + v58_peatland_cost(j2) =e= v58_peatland_cost_annuity_degrad(j2) + v58_peatland_cost_annuity_rewet(j2) + v58_peatland(j2,"rewetted") * sum(ct, i58_cost_rewet_recur(ct)) + sum(manPeat58, v58_peatland(j2,manPeat58)) * sum(ct, i58_cost_degrad_recur(ct)); - q58_peatland_cost_annuity_intact(j2) .. - v58_peatland_cost_annuity_intact(j2) =e= - - v58_peatlandChange(j2,"intact") * sum(ct, i58_cost_degrad_onetime(ct)) + q58_peatland_cost_annuity_degrad(j2) .. + v58_peatland_cost_annuity_degrad(j2) =e= + sum(drained58, v58_peatlandChange(j2,drained58)) * sum(ct, i58_cost_degrad_onetime(ct)) * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); q58_peatland_cost_annuity_rewet(j2) .. diff --git a/modules/58_peatland/v2/input.gms b/modules/58_peatland/v2/input.gms index d0f3ac08c9..65ea3f4d82 100644 --- a/modules/58_peatland/v2/input.gms +++ b/modules/58_peatland/v2/input.gms @@ -11,7 +11,7 @@ scalars s58_cost_degrad_recur Recurring costs for degraded peatland (USD05MER per ha) / 0 / s58_cost_degrad_onetime One-time costs for peatland degradation (USD05MER per ha) / 0 / s58_rewetting_switch Peatland rewetting on (Inf) or off (0) / Inf / - s58_fix_peatland Year indicating until when peatland area should be fixed (year) / 2015 / + s58_fix_peatland Year indicating until when peatland area should be fixed (year) / 2020 / ; *Peatland area based on Global Peatland Map 2.0 and Global Peatland Database diff --git a/modules/58_peatland/v2/not_used.txt b/modules/58_peatland/v2/not_used.txt deleted file mode 100644 index 9f23b880c7..0000000000 --- a/modules/58_peatland/v2/not_used.txt +++ /dev/null @@ -1,2 +0,0 @@ -name, type, reason -vm_land, input, not used diff --git a/modules/58_peatland/v2/postsolve.gms b/modules/58_peatland/v2/postsolve.gms index 72934224b9..c54b37ff17 100644 --- a/modules/58_peatland/v2/postsolve.gms +++ b/modules/58_peatland/v2/postsolve.gms @@ -6,90 +6,103 @@ *** | Contact: magpie@pik-potsdam.de pc58_peatland(j,land58) = v58_peatland.l(j,land58); +pc58_manLand(j,manPeat58) = v58_manLand.l(j,manPeat58); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov58_peatlandChange(t,j,land58,"marginal") = v58_peatlandChange.m(j,land58); ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); ov58_peatland_cost(t,j,"marginal") = v58_peatland_cost.m(j); ov58_peatland_emis(t,j,land58,emis58,"marginal") = v58_peatland_emis.m(j,land58,emis58); - ov58_peatlandChange(t,j,land58,"marginal") = v58_peatlandChange.m(j,land58); - ov58_peatland_cost_annuity_intact(t,j,"marginal") = v58_peatland_cost_annuity_intact.m(j); - ov58_peatland_cost_annuity_rewet(t,j,"marginal") = v58_peatland_cost_annuity_rewet.m(j); ov58_peatland(t,j,land58,"marginal") = v58_peatland.m(j,land58); - ov58_manLandExp(t,j,manLand58,"marginal") = v58_manLandExp.m(j,manLand58); - ov58_manLandRed(t,j,manLand58,"marginal") = v58_manLandRed.m(j,manLand58); + ov58_manLand(t,j,manPeat58,"marginal") = v58_manLand.m(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"marginal") = v58_manLandExp.m(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"marginal") = v58_manLandRed.m(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"marginal") = v58_scalingFactorExp.m(j,manPeat58); + ov58_peatland_cost_annuity_degrad(t,j,"marginal") = v58_peatland_cost_annuity_degrad.m(j); + ov58_peatland_cost_annuity_rewet(t,j,"marginal") = v58_peatland_cost_annuity_rewet.m(j); oq58_peatland(t,j,"marginal") = q58_peatland.m(j); oq58_peatlandChange(t,j,land58,"marginal") = q58_peatlandChange.m(j,land58); + oq58_manLand(t,j,manPeat58,"marginal") = q58_manLand.m(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"marginal") = q58_manLandExp.m(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"marginal") = q58_manLandRed.m(j,manPeat58); oq58_peatlandMan(t,j,manPeat58,"marginal") = q58_peatlandMan.m(j,manPeat58); - oq58_peatlandRewet(t,j,"marginal") = q58_peatlandRewet.m(j); + oq58_scalingFactorExp(t,j,manPeat58,"marginal") = q58_scalingFactorExp.m(j,manPeat58); oq58_peatland_cost_full(t,j,"marginal") = q58_peatland_cost_full.m(j); oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); - oq58_peatland_cost_annuity_intact(t,j,"marginal") = q58_peatland_cost_annuity_intact.m(j); + oq58_peatland_cost_annuity_degrad(t,j,"marginal") = q58_peatland_cost_annuity_degrad.m(j); oq58_peatland_cost_annuity_rewet(t,j,"marginal") = q58_peatland_cost_annuity_rewet.m(j); oq58_peatland_emis_detail(t,j,land58,emis58,"marginal") = q58_peatland_emis_detail.m(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); - oq58_manLandExp(t,j,manLand58,"marginal") = q58_manLandExp.m(j,manLand58); - oq58_manLandRed(t,j,manLand58,"marginal") = q58_manLandRed.m(j,manLand58); + ov58_peatlandChange(t,j,land58,"level") = v58_peatlandChange.l(j,land58); ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); ov58_peatland_cost(t,j,"level") = v58_peatland_cost.l(j); ov58_peatland_emis(t,j,land58,emis58,"level") = v58_peatland_emis.l(j,land58,emis58); - ov58_peatlandChange(t,j,land58,"level") = v58_peatlandChange.l(j,land58); - ov58_peatland_cost_annuity_intact(t,j,"level") = v58_peatland_cost_annuity_intact.l(j); - ov58_peatland_cost_annuity_rewet(t,j,"level") = v58_peatland_cost_annuity_rewet.l(j); ov58_peatland(t,j,land58,"level") = v58_peatland.l(j,land58); - ov58_manLandExp(t,j,manLand58,"level") = v58_manLandExp.l(j,manLand58); - ov58_manLandRed(t,j,manLand58,"level") = v58_manLandRed.l(j,manLand58); + ov58_manLand(t,j,manPeat58,"level") = v58_manLand.l(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"level") = v58_manLandExp.l(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"level") = v58_manLandRed.l(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"level") = v58_scalingFactorExp.l(j,manPeat58); + ov58_peatland_cost_annuity_degrad(t,j,"level") = v58_peatland_cost_annuity_degrad.l(j); + ov58_peatland_cost_annuity_rewet(t,j,"level") = v58_peatland_cost_annuity_rewet.l(j); oq58_peatland(t,j,"level") = q58_peatland.l(j); oq58_peatlandChange(t,j,land58,"level") = q58_peatlandChange.l(j,land58); + oq58_manLand(t,j,manPeat58,"level") = q58_manLand.l(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"level") = q58_manLandExp.l(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"level") = q58_manLandRed.l(j,manPeat58); oq58_peatlandMan(t,j,manPeat58,"level") = q58_peatlandMan.l(j,manPeat58); - oq58_peatlandRewet(t,j,"level") = q58_peatlandRewet.l(j); + oq58_scalingFactorExp(t,j,manPeat58,"level") = q58_scalingFactorExp.l(j,manPeat58); oq58_peatland_cost_full(t,j,"level") = q58_peatland_cost_full.l(j); oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); - oq58_peatland_cost_annuity_intact(t,j,"level") = q58_peatland_cost_annuity_intact.l(j); + oq58_peatland_cost_annuity_degrad(t,j,"level") = q58_peatland_cost_annuity_degrad.l(j); oq58_peatland_cost_annuity_rewet(t,j,"level") = q58_peatland_cost_annuity_rewet.l(j); oq58_peatland_emis_detail(t,j,land58,emis58,"level") = q58_peatland_emis_detail.l(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); - oq58_manLandExp(t,j,manLand58,"level") = q58_manLandExp.l(j,manLand58); - oq58_manLandRed(t,j,manLand58,"level") = q58_manLandRed.l(j,manLand58); + ov58_peatlandChange(t,j,land58,"upper") = v58_peatlandChange.up(j,land58); ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); ov58_peatland_cost(t,j,"upper") = v58_peatland_cost.up(j); ov58_peatland_emis(t,j,land58,emis58,"upper") = v58_peatland_emis.up(j,land58,emis58); - ov58_peatlandChange(t,j,land58,"upper") = v58_peatlandChange.up(j,land58); - ov58_peatland_cost_annuity_intact(t,j,"upper") = v58_peatland_cost_annuity_intact.up(j); - ov58_peatland_cost_annuity_rewet(t,j,"upper") = v58_peatland_cost_annuity_rewet.up(j); ov58_peatland(t,j,land58,"upper") = v58_peatland.up(j,land58); - ov58_manLandExp(t,j,manLand58,"upper") = v58_manLandExp.up(j,manLand58); - ov58_manLandRed(t,j,manLand58,"upper") = v58_manLandRed.up(j,manLand58); + ov58_manLand(t,j,manPeat58,"upper") = v58_manLand.up(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"upper") = v58_manLandExp.up(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"upper") = v58_manLandRed.up(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"upper") = v58_scalingFactorExp.up(j,manPeat58); + ov58_peatland_cost_annuity_degrad(t,j,"upper") = v58_peatland_cost_annuity_degrad.up(j); + ov58_peatland_cost_annuity_rewet(t,j,"upper") = v58_peatland_cost_annuity_rewet.up(j); oq58_peatland(t,j,"upper") = q58_peatland.up(j); oq58_peatlandChange(t,j,land58,"upper") = q58_peatlandChange.up(j,land58); + oq58_manLand(t,j,manPeat58,"upper") = q58_manLand.up(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"upper") = q58_manLandExp.up(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"upper") = q58_manLandRed.up(j,manPeat58); oq58_peatlandMan(t,j,manPeat58,"upper") = q58_peatlandMan.up(j,manPeat58); - oq58_peatlandRewet(t,j,"upper") = q58_peatlandRewet.up(j); + oq58_scalingFactorExp(t,j,manPeat58,"upper") = q58_scalingFactorExp.up(j,manPeat58); oq58_peatland_cost_full(t,j,"upper") = q58_peatland_cost_full.up(j); oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); - oq58_peatland_cost_annuity_intact(t,j,"upper") = q58_peatland_cost_annuity_intact.up(j); + oq58_peatland_cost_annuity_degrad(t,j,"upper") = q58_peatland_cost_annuity_degrad.up(j); oq58_peatland_cost_annuity_rewet(t,j,"upper") = q58_peatland_cost_annuity_rewet.up(j); oq58_peatland_emis_detail(t,j,land58,emis58,"upper") = q58_peatland_emis_detail.up(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); - oq58_manLandExp(t,j,manLand58,"upper") = q58_manLandExp.up(j,manLand58); - oq58_manLandRed(t,j,manLand58,"upper") = q58_manLandRed.up(j,manLand58); + ov58_peatlandChange(t,j,land58,"lower") = v58_peatlandChange.lo(j,land58); ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); ov58_peatland_cost(t,j,"lower") = v58_peatland_cost.lo(j); ov58_peatland_emis(t,j,land58,emis58,"lower") = v58_peatland_emis.lo(j,land58,emis58); - ov58_peatlandChange(t,j,land58,"lower") = v58_peatlandChange.lo(j,land58); - ov58_peatland_cost_annuity_intact(t,j,"lower") = v58_peatland_cost_annuity_intact.lo(j); - ov58_peatland_cost_annuity_rewet(t,j,"lower") = v58_peatland_cost_annuity_rewet.lo(j); ov58_peatland(t,j,land58,"lower") = v58_peatland.lo(j,land58); - ov58_manLandExp(t,j,manLand58,"lower") = v58_manLandExp.lo(j,manLand58); - ov58_manLandRed(t,j,manLand58,"lower") = v58_manLandRed.lo(j,manLand58); + ov58_manLand(t,j,manPeat58,"lower") = v58_manLand.lo(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"lower") = v58_manLandExp.lo(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"lower") = v58_manLandRed.lo(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"lower") = v58_scalingFactorExp.lo(j,manPeat58); + ov58_peatland_cost_annuity_degrad(t,j,"lower") = v58_peatland_cost_annuity_degrad.lo(j); + ov58_peatland_cost_annuity_rewet(t,j,"lower") = v58_peatland_cost_annuity_rewet.lo(j); oq58_peatland(t,j,"lower") = q58_peatland.lo(j); oq58_peatlandChange(t,j,land58,"lower") = q58_peatlandChange.lo(j,land58); + oq58_manLand(t,j,manPeat58,"lower") = q58_manLand.lo(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"lower") = q58_manLandExp.lo(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"lower") = q58_manLandRed.lo(j,manPeat58); oq58_peatlandMan(t,j,manPeat58,"lower") = q58_peatlandMan.lo(j,manPeat58); - oq58_peatlandRewet(t,j,"lower") = q58_peatlandRewet.lo(j); + oq58_scalingFactorExp(t,j,manPeat58,"lower") = q58_scalingFactorExp.lo(j,manPeat58); oq58_peatland_cost_full(t,j,"lower") = q58_peatland_cost_full.lo(j); oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); - oq58_peatland_cost_annuity_intact(t,j,"lower") = q58_peatland_cost_annuity_intact.lo(j); + oq58_peatland_cost_annuity_degrad(t,j,"lower") = q58_peatland_cost_annuity_degrad.lo(j); oq58_peatland_cost_annuity_rewet(t,j,"lower") = q58_peatland_cost_annuity_rewet.lo(j); oq58_peatland_emis_detail(t,j,land58,emis58,"lower") = q58_peatland_emis_detail.lo(j,land58,emis58); oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); - oq58_manLandExp(t,j,manLand58,"lower") = q58_manLandExp.lo(j,manLand58); - oq58_manLandRed(t,j,manLand58,"lower") = q58_manLandRed.lo(j,manLand58); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms index 7380c4b097..ac58258d2b 100644 --- a/modules/58_peatland/v2/preloop.gms +++ b/modules/58_peatland/v2/preloop.gms @@ -17,6 +17,3 @@ pc58_peatland(j,land58) = 0; * For the internal GHG emission pricing it is assumed that intact peatlands have the same GHG emission factors as rewetted peatlands. * Without this assumption, GHG emissions of intact peatlands would be zero (no data available). This can lead to cases where intact peatland is converted to rewetted peatland. f58_ipcc_wetland_ef(clcl58,"intact",emis58) = f58_ipcc_wetland_ef(clcl58,"rewetted",emis58); - -* Initialization of peatland weight -p58_weight(t,j,manPeat58) = 1/card(manPeat58); diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index 4621971a10..af64883270 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -7,10 +7,11 @@ if (m_year(t) <= s58_fix_peatland, +* Managed land area + pc58_manLand(j,manPeat58) = m_peatLandMerge(pcm_land,pcm_land_forestry,"j"); + * Initialization of peatland area. Drained and used peatland area cannot exceed the corresponding managed area - pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop")); - pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past")); - pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land(j,"forestry")); + pc58_peatland(j,manPeat58) = min(f58_peatland_area(j,manPeat58),pc58_manLand(j,manPeat58)); * The residual is added to an "unused" category, which represents drained but unused peatland. pc58_peatland(j,"unused") = sum(manPeat58, f58_peatland_area(j,manPeat58) - pc58_peatland(j,manPeat58)); * Area used for peat extraction @@ -38,10 +39,12 @@ else i58_cost_degrad_onetime(t) = s58_cost_degrad_onetime; ); -* Peatland scaling factors for estimating future peatland dynamics; see macros for details. -p58_scaling_factor_exp(t,j) = m_peatland_scaling_factor_exp(pc58_peatland,pcm_land); -p58_scaling_factor_red(t,j) = m_peatland_scaling_factor_red(pc58_peatland,pcm_land); +*' @code +*' Peatland scaling factor for reduction: currentPeatland / currentManagedLand + +p58_scalingFactorRed(t,j,manPeat58) = + (pc58_peatland(j,manPeat58)/pc58_manLand(j,manPeat58)) + $(pc58_peatland(j,manPeat58) > 1e-10 AND pc58_manLand(j,manPeat58) > 1e-10) + + 0$(pc58_peatland(j,manPeat58) <= 1e-10 OR pc58_manLand(j,manPeat58) <= 1e-10); -* Peatland weight for distribution of total peatland changes to managed peatland categories -p58_weight(t,j,manPeat58)$(sum(manPeat58_alias, pc58_peatland(j,manPeat58_alias)) > 1e-10) = - pc58_peatland(j,manPeat58) / sum(manPeat58_alias, pc58_peatland(j,manPeat58_alias)); +*' @stop diff --git a/modules/58_peatland/v2/realization.gms b/modules/58_peatland/v2/realization.gms index f67915a788..1b0e6d4d58 100644 --- a/modules/58_peatland/v2/realization.gms +++ b/modules/58_peatland/v2/realization.gms @@ -25,7 +25,7 @@ *' -*' @limitations Peatland area and GHG emissions are fixed to 2015/2020 levels for the historic period, +*' @limitations Peatland area and GHG emissions are fixed to 2020 levels for the historic period, *' depending on `s58_fix_peatland`. Organic carbon stocks in peatlands are not accounted for. *####################### R SECTION START (PHASES) ############################## From c805a39df8eeca036d5b1da9e3dcfad29df2b3af Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 1 Dec 2023 15:09:57 +0100 Subject: [PATCH 051/187] update --- config/default.cfg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 7004784428..f93288dff8 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1917,9 +1917,7 @@ cfg$files2export$start <- c("input/info.txt", "input/spamplot_*.pdf", "input/regionmapping*.csv", "input/kba_land_0.5.mz", - "input/f58_peatland_area_0.5.mz", - "input/f58_peatland_intact_0.5.mz", - "input/f58_peatland_degrad_0.5.mz") + "input/f58_peatland_area_0.5.mz") # Files that should be copied after the MAgPIE run is finished cfg$files2export$end <- NULL From a68158a022360ef52fdabfa7bc1715f03ea142b1 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 1 Dec 2023 16:05:33 +0100 Subject: [PATCH 052/187] bugfix --- modules/58_peatland/v2/declarations.gms | 60 +++---- modules/58_peatland/v2/equations.gms | 19 ++- modules/58_peatland/v2/postsolve.gms | 200 ++++++++++++------------ 3 files changed, 149 insertions(+), 130 deletions(-) diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index 5bb6a8ffb3..c76cb8ce56 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -26,8 +26,9 @@ equations q58_scalingFactorExp(j,manPeat58) Scaling factor for peatland expansion (1) q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - q58_peatland_cost_annuity_degrad(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - q58_peatland_cost_annuity_rewet(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + q58_peatland_cost_annuity_intact_decrease(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + q58_peatland_cost_annuity_rewet_decrease(j) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) + q58_peatland_cost_annuity_rewet_increase(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) q58_peatland_emis_detail(j,land58,emis58) Detailed GHG emissions from peatlands (Tg per yr) q58_peatland_emis(i,poll58) GHG emissions from managed peatland (Tg per yr) ; @@ -45,35 +46,38 @@ positive variables v58_manLandExp(j,manPeat58) Managed land area expansion (mio. ha) v58_manLandRed(j,manPeat58) Managed land area reduction (mio. ha) v58_scalingFactorExp(j,manPeat58) Scaling factor for peatland expansion (1) - v58_peatland_cost_annuity_degrad(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - v58_peatland_cost_annuity_rewet(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + v58_peatland_cost_annuity_intact_decrease(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + v58_peatland_cost_annuity_rewet_decrease(j) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) + v58_peatland_cost_annuity_rewet_increase(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) - ov_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - ov58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - ov58_peatland_emis(t,j,land58,emis58,type) Detailed GHG peatland GHG emissions (Tg per yr) - ov58_peatland(t,j,land58,type) Peatland area (mio. ha) - ov58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) - ov58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) - ov58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) - ov58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) - ov58_peatland_cost_annuity_degrad(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - ov58_peatland_cost_annuity_rewet(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) - oq58_peatland(t,j,type) Constraint for total peatland area (mio. ha) - oq58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) - oq58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) - oq58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) - oq58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) - oq58_peatlandMan(t,j,manPeat58,type) Change of managed peatland area (mio. ha) - oq58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) - oq58_peatland_cost_full(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - oq58_peatland_cost_annuity_degrad(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - oq58_peatland_cost_annuity_rewet(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) - oq58_peatland_emis_detail(t,j,land58,emis58,type) Detailed GHG emissions from peatlands (Tg per yr) - oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) + ov58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) + ov_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + ov58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + ov58_peatland_emis(t,j,land58,emis58,type) Detailed GHG peatland GHG emissions (Tg per yr) + ov58_peatland(t,j,land58,type) Peatland area (mio. ha) + ov58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) + ov58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) + ov58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) + ov58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) + ov58_peatland_cost_annuity_intact_decrease(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + ov58_peatland_cost_annuity_rewet_decrease(t,j,type) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) + ov58_peatland_cost_annuity_rewet_increase(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + oq58_peatland(t,j,type) Constraint for total peatland area (mio. ha) + oq58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) + oq58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) + oq58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) + oq58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) + oq58_peatlandMan(t,j,manPeat58,type) Change of managed peatland area (mio. ha) + oq58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) + oq58_peatland_cost_full(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + oq58_peatland_cost_annuity_intact_decrease(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) + oq58_peatland_cost_annuity_rewet_decrease(t,j,type) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) + oq58_peatland_cost_annuity_rewet_increase(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + oq58_peatland_emis_detail(t,j,land58,emis58,type) Detailed GHG emissions from peatlands (Tg per yr) + oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index 62a2c900e1..3063daa8af 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -59,17 +59,24 @@ q58_scalingFactorExp(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. vm_peatland_cost(j2) =e= v58_peatland_cost(j2); q58_peatland_cost(j2) .. - v58_peatland_cost(j2) =e= v58_peatland_cost_annuity_degrad(j2) + v58_peatland_cost_annuity_rewet(j2) + v58_peatland_cost(j2) =e= v58_peatland_cost_annuity_intact_decrease(j2) + + v58_peatland_cost_annuity_rewet_decrease(j2) + + v58_peatland_cost_annuity_rewet_increase(j2) + v58_peatland(j2,"rewetted") * sum(ct, i58_cost_rewet_recur(ct)) + sum(manPeat58, v58_peatland(j2,manPeat58)) * sum(ct, i58_cost_degrad_recur(ct)); - q58_peatland_cost_annuity_degrad(j2) .. - v58_peatland_cost_annuity_degrad(j2) =e= - sum(drained58, v58_peatlandChange(j2,drained58)) * sum(ct, i58_cost_degrad_onetime(ct)) + q58_peatland_cost_annuity_intact_decrease(j2) .. + v58_peatland_cost_annuity_intact_decrease(j2) =g= + - v58_peatlandChange(j2,"intact") * sum(ct, i58_cost_degrad_onetime(ct)) + * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + + q58_peatland_cost_annuity_rewet_decrease(j2) .. + v58_peatland_cost_annuity_rewet_decrease(j2) =g= + - v58_peatlandChange(j2,"rewetted") * sum(ct, i58_cost_degrad_onetime(ct)) * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - q58_peatland_cost_annuity_rewet(j2) .. - v58_peatland_cost_annuity_rewet(j2) =g= + q58_peatland_cost_annuity_rewet_increase(j2) .. + v58_peatland_cost_annuity_rewet_increase(j2) =g= v58_peatlandChange(j2,"rewetted") * sum(ct, i58_cost_rewet_onetime(ct)) * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); diff --git a/modules/58_peatland/v2/postsolve.gms b/modules/58_peatland/v2/postsolve.gms index c54b37ff17..308561feb8 100644 --- a/modules/58_peatland/v2/postsolve.gms +++ b/modules/58_peatland/v2/postsolve.gms @@ -9,100 +9,108 @@ pc58_peatland(j,land58) = v58_peatland.l(j,land58); pc58_manLand(j,manPeat58) = v58_manLand.l(j,manPeat58); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov58_peatlandChange(t,j,land58,"marginal") = v58_peatlandChange.m(j,land58); - ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); - ov58_peatland_cost(t,j,"marginal") = v58_peatland_cost.m(j); - ov58_peatland_emis(t,j,land58,emis58,"marginal") = v58_peatland_emis.m(j,land58,emis58); - ov58_peatland(t,j,land58,"marginal") = v58_peatland.m(j,land58); - ov58_manLand(t,j,manPeat58,"marginal") = v58_manLand.m(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"marginal") = v58_manLandExp.m(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"marginal") = v58_manLandRed.m(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"marginal") = v58_scalingFactorExp.m(j,manPeat58); - ov58_peatland_cost_annuity_degrad(t,j,"marginal") = v58_peatland_cost_annuity_degrad.m(j); - ov58_peatland_cost_annuity_rewet(t,j,"marginal") = v58_peatland_cost_annuity_rewet.m(j); - oq58_peatland(t,j,"marginal") = q58_peatland.m(j); - oq58_peatlandChange(t,j,land58,"marginal") = q58_peatlandChange.m(j,land58); - oq58_manLand(t,j,manPeat58,"marginal") = q58_manLand.m(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"marginal") = q58_manLandExp.m(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"marginal") = q58_manLandRed.m(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"marginal") = q58_peatlandMan.m(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"marginal") = q58_scalingFactorExp.m(j,manPeat58); - oq58_peatland_cost_full(t,j,"marginal") = q58_peatland_cost_full.m(j); - oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); - oq58_peatland_cost_annuity_degrad(t,j,"marginal") = q58_peatland_cost_annuity_degrad.m(j); - oq58_peatland_cost_annuity_rewet(t,j,"marginal") = q58_peatland_cost_annuity_rewet.m(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"marginal") = q58_peatland_emis_detail.m(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); - ov58_peatlandChange(t,j,land58,"level") = v58_peatlandChange.l(j,land58); - ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); - ov58_peatland_cost(t,j,"level") = v58_peatland_cost.l(j); - ov58_peatland_emis(t,j,land58,emis58,"level") = v58_peatland_emis.l(j,land58,emis58); - ov58_peatland(t,j,land58,"level") = v58_peatland.l(j,land58); - ov58_manLand(t,j,manPeat58,"level") = v58_manLand.l(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"level") = v58_manLandExp.l(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"level") = v58_manLandRed.l(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"level") = v58_scalingFactorExp.l(j,manPeat58); - ov58_peatland_cost_annuity_degrad(t,j,"level") = v58_peatland_cost_annuity_degrad.l(j); - ov58_peatland_cost_annuity_rewet(t,j,"level") = v58_peatland_cost_annuity_rewet.l(j); - oq58_peatland(t,j,"level") = q58_peatland.l(j); - oq58_peatlandChange(t,j,land58,"level") = q58_peatlandChange.l(j,land58); - oq58_manLand(t,j,manPeat58,"level") = q58_manLand.l(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"level") = q58_manLandExp.l(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"level") = q58_manLandRed.l(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"level") = q58_peatlandMan.l(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"level") = q58_scalingFactorExp.l(j,manPeat58); - oq58_peatland_cost_full(t,j,"level") = q58_peatland_cost_full.l(j); - oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); - oq58_peatland_cost_annuity_degrad(t,j,"level") = q58_peatland_cost_annuity_degrad.l(j); - oq58_peatland_cost_annuity_rewet(t,j,"level") = q58_peatland_cost_annuity_rewet.l(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"level") = q58_peatland_emis_detail.l(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); - ov58_peatlandChange(t,j,land58,"upper") = v58_peatlandChange.up(j,land58); - ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); - ov58_peatland_cost(t,j,"upper") = v58_peatland_cost.up(j); - ov58_peatland_emis(t,j,land58,emis58,"upper") = v58_peatland_emis.up(j,land58,emis58); - ov58_peatland(t,j,land58,"upper") = v58_peatland.up(j,land58); - ov58_manLand(t,j,manPeat58,"upper") = v58_manLand.up(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"upper") = v58_manLandExp.up(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"upper") = v58_manLandRed.up(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"upper") = v58_scalingFactorExp.up(j,manPeat58); - ov58_peatland_cost_annuity_degrad(t,j,"upper") = v58_peatland_cost_annuity_degrad.up(j); - ov58_peatland_cost_annuity_rewet(t,j,"upper") = v58_peatland_cost_annuity_rewet.up(j); - oq58_peatland(t,j,"upper") = q58_peatland.up(j); - oq58_peatlandChange(t,j,land58,"upper") = q58_peatlandChange.up(j,land58); - oq58_manLand(t,j,manPeat58,"upper") = q58_manLand.up(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"upper") = q58_manLandExp.up(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"upper") = q58_manLandRed.up(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"upper") = q58_peatlandMan.up(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"upper") = q58_scalingFactorExp.up(j,manPeat58); - oq58_peatland_cost_full(t,j,"upper") = q58_peatland_cost_full.up(j); - oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); - oq58_peatland_cost_annuity_degrad(t,j,"upper") = q58_peatland_cost_annuity_degrad.up(j); - oq58_peatland_cost_annuity_rewet(t,j,"upper") = q58_peatland_cost_annuity_rewet.up(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"upper") = q58_peatland_emis_detail.up(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); - ov58_peatlandChange(t,j,land58,"lower") = v58_peatlandChange.lo(j,land58); - ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); - ov58_peatland_cost(t,j,"lower") = v58_peatland_cost.lo(j); - ov58_peatland_emis(t,j,land58,emis58,"lower") = v58_peatland_emis.lo(j,land58,emis58); - ov58_peatland(t,j,land58,"lower") = v58_peatland.lo(j,land58); - ov58_manLand(t,j,manPeat58,"lower") = v58_manLand.lo(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"lower") = v58_manLandExp.lo(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"lower") = v58_manLandRed.lo(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"lower") = v58_scalingFactorExp.lo(j,manPeat58); - ov58_peatland_cost_annuity_degrad(t,j,"lower") = v58_peatland_cost_annuity_degrad.lo(j); - ov58_peatland_cost_annuity_rewet(t,j,"lower") = v58_peatland_cost_annuity_rewet.lo(j); - oq58_peatland(t,j,"lower") = q58_peatland.lo(j); - oq58_peatlandChange(t,j,land58,"lower") = q58_peatlandChange.lo(j,land58); - oq58_manLand(t,j,manPeat58,"lower") = q58_manLand.lo(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"lower") = q58_manLandExp.lo(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"lower") = q58_manLandRed.lo(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"lower") = q58_peatlandMan.lo(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"lower") = q58_scalingFactorExp.lo(j,manPeat58); - oq58_peatland_cost_full(t,j,"lower") = q58_peatland_cost_full.lo(j); - oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); - oq58_peatland_cost_annuity_degrad(t,j,"lower") = q58_peatland_cost_annuity_degrad.lo(j); - oq58_peatland_cost_annuity_rewet(t,j,"lower") = q58_peatland_cost_annuity_rewet.lo(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"lower") = q58_peatland_emis_detail.lo(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); + ov58_peatlandChange(t,j,land58,"marginal") = v58_peatlandChange.m(j,land58); + ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); + ov58_peatland_cost(t,j,"marginal") = v58_peatland_cost.m(j); + ov58_peatland_emis(t,j,land58,emis58,"marginal") = v58_peatland_emis.m(j,land58,emis58); + ov58_peatland(t,j,land58,"marginal") = v58_peatland.m(j,land58); + ov58_manLand(t,j,manPeat58,"marginal") = v58_manLand.m(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"marginal") = v58_manLandExp.m(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"marginal") = v58_manLandRed.m(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"marginal") = v58_scalingFactorExp.m(j,manPeat58); + ov58_peatland_cost_annuity_intact_decrease(t,j,"marginal") = v58_peatland_cost_annuity_intact_decrease.m(j); + ov58_peatland_cost_annuity_rewet_decrease(t,j,"marginal") = v58_peatland_cost_annuity_rewet_decrease.m(j); + ov58_peatland_cost_annuity_rewet_increase(t,j,"marginal") = v58_peatland_cost_annuity_rewet_increase.m(j); + oq58_peatland(t,j,"marginal") = q58_peatland.m(j); + oq58_peatlandChange(t,j,land58,"marginal") = q58_peatlandChange.m(j,land58); + oq58_manLand(t,j,manPeat58,"marginal") = q58_manLand.m(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"marginal") = q58_manLandExp.m(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"marginal") = q58_manLandRed.m(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"marginal") = q58_peatlandMan.m(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"marginal") = q58_scalingFactorExp.m(j,manPeat58); + oq58_peatland_cost_full(t,j,"marginal") = q58_peatland_cost_full.m(j); + oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); + oq58_peatland_cost_annuity_intact_decrease(t,j,"marginal") = q58_peatland_cost_annuity_intact_decrease.m(j); + oq58_peatland_cost_annuity_rewet_decrease(t,j,"marginal") = q58_peatland_cost_annuity_rewet_decrease.m(j); + oq58_peatland_cost_annuity_rewet_increase(t,j,"marginal") = q58_peatland_cost_annuity_rewet_increase.m(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"marginal") = q58_peatland_emis_detail.m(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); + ov58_peatlandChange(t,j,land58,"level") = v58_peatlandChange.l(j,land58); + ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); + ov58_peatland_cost(t,j,"level") = v58_peatland_cost.l(j); + ov58_peatland_emis(t,j,land58,emis58,"level") = v58_peatland_emis.l(j,land58,emis58); + ov58_peatland(t,j,land58,"level") = v58_peatland.l(j,land58); + ov58_manLand(t,j,manPeat58,"level") = v58_manLand.l(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"level") = v58_manLandExp.l(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"level") = v58_manLandRed.l(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"level") = v58_scalingFactorExp.l(j,manPeat58); + ov58_peatland_cost_annuity_intact_decrease(t,j,"level") = v58_peatland_cost_annuity_intact_decrease.l(j); + ov58_peatland_cost_annuity_rewet_decrease(t,j,"level") = v58_peatland_cost_annuity_rewet_decrease.l(j); + ov58_peatland_cost_annuity_rewet_increase(t,j,"level") = v58_peatland_cost_annuity_rewet_increase.l(j); + oq58_peatland(t,j,"level") = q58_peatland.l(j); + oq58_peatlandChange(t,j,land58,"level") = q58_peatlandChange.l(j,land58); + oq58_manLand(t,j,manPeat58,"level") = q58_manLand.l(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"level") = q58_manLandExp.l(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"level") = q58_manLandRed.l(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"level") = q58_peatlandMan.l(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"level") = q58_scalingFactorExp.l(j,manPeat58); + oq58_peatland_cost_full(t,j,"level") = q58_peatland_cost_full.l(j); + oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); + oq58_peatland_cost_annuity_intact_decrease(t,j,"level") = q58_peatland_cost_annuity_intact_decrease.l(j); + oq58_peatland_cost_annuity_rewet_decrease(t,j,"level") = q58_peatland_cost_annuity_rewet_decrease.l(j); + oq58_peatland_cost_annuity_rewet_increase(t,j,"level") = q58_peatland_cost_annuity_rewet_increase.l(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"level") = q58_peatland_emis_detail.l(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); + ov58_peatlandChange(t,j,land58,"upper") = v58_peatlandChange.up(j,land58); + ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); + ov58_peatland_cost(t,j,"upper") = v58_peatland_cost.up(j); + ov58_peatland_emis(t,j,land58,emis58,"upper") = v58_peatland_emis.up(j,land58,emis58); + ov58_peatland(t,j,land58,"upper") = v58_peatland.up(j,land58); + ov58_manLand(t,j,manPeat58,"upper") = v58_manLand.up(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"upper") = v58_manLandExp.up(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"upper") = v58_manLandRed.up(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"upper") = v58_scalingFactorExp.up(j,manPeat58); + ov58_peatland_cost_annuity_intact_decrease(t,j,"upper") = v58_peatland_cost_annuity_intact_decrease.up(j); + ov58_peatland_cost_annuity_rewet_decrease(t,j,"upper") = v58_peatland_cost_annuity_rewet_decrease.up(j); + ov58_peatland_cost_annuity_rewet_increase(t,j,"upper") = v58_peatland_cost_annuity_rewet_increase.up(j); + oq58_peatland(t,j,"upper") = q58_peatland.up(j); + oq58_peatlandChange(t,j,land58,"upper") = q58_peatlandChange.up(j,land58); + oq58_manLand(t,j,manPeat58,"upper") = q58_manLand.up(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"upper") = q58_manLandExp.up(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"upper") = q58_manLandRed.up(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"upper") = q58_peatlandMan.up(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"upper") = q58_scalingFactorExp.up(j,manPeat58); + oq58_peatland_cost_full(t,j,"upper") = q58_peatland_cost_full.up(j); + oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); + oq58_peatland_cost_annuity_intact_decrease(t,j,"upper") = q58_peatland_cost_annuity_intact_decrease.up(j); + oq58_peatland_cost_annuity_rewet_decrease(t,j,"upper") = q58_peatland_cost_annuity_rewet_decrease.up(j); + oq58_peatland_cost_annuity_rewet_increase(t,j,"upper") = q58_peatland_cost_annuity_rewet_increase.up(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"upper") = q58_peatland_emis_detail.up(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); + ov58_peatlandChange(t,j,land58,"lower") = v58_peatlandChange.lo(j,land58); + ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); + ov58_peatland_cost(t,j,"lower") = v58_peatland_cost.lo(j); + ov58_peatland_emis(t,j,land58,emis58,"lower") = v58_peatland_emis.lo(j,land58,emis58); + ov58_peatland(t,j,land58,"lower") = v58_peatland.lo(j,land58); + ov58_manLand(t,j,manPeat58,"lower") = v58_manLand.lo(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"lower") = v58_manLandExp.lo(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"lower") = v58_manLandRed.lo(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"lower") = v58_scalingFactorExp.lo(j,manPeat58); + ov58_peatland_cost_annuity_intact_decrease(t,j,"lower") = v58_peatland_cost_annuity_intact_decrease.lo(j); + ov58_peatland_cost_annuity_rewet_decrease(t,j,"lower") = v58_peatland_cost_annuity_rewet_decrease.lo(j); + ov58_peatland_cost_annuity_rewet_increase(t,j,"lower") = v58_peatland_cost_annuity_rewet_increase.lo(j); + oq58_peatland(t,j,"lower") = q58_peatland.lo(j); + oq58_peatlandChange(t,j,land58,"lower") = q58_peatlandChange.lo(j,land58); + oq58_manLand(t,j,manPeat58,"lower") = q58_manLand.lo(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"lower") = q58_manLandExp.lo(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"lower") = q58_manLandRed.lo(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"lower") = q58_peatlandMan.lo(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"lower") = q58_scalingFactorExp.lo(j,manPeat58); + oq58_peatland_cost_full(t,j,"lower") = q58_peatland_cost_full.lo(j); + oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); + oq58_peatland_cost_annuity_intact_decrease(t,j,"lower") = q58_peatland_cost_annuity_intact_decrease.lo(j); + oq58_peatland_cost_annuity_rewet_decrease(t,j,"lower") = q58_peatland_cost_annuity_rewet_decrease.lo(j); + oq58_peatland_cost_annuity_rewet_increase(t,j,"lower") = q58_peatland_cost_annuity_rewet_increase.lo(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"lower") = q58_peatland_emis_detail.lo(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### From f7b9120de80ff3d0c3e105fa15f904c0cb7296b9 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 2 Dec 2023 12:57:40 +0100 Subject: [PATCH 053/187] scaling factor --- modules/58_peatland/v2/realization.gms | 1 + modules/58_peatland/v2/scaling.gms | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 modules/58_peatland/v2/scaling.gms diff --git a/modules/58_peatland/v2/realization.gms b/modules/58_peatland/v2/realization.gms index 1b0e6d4d58..8d13b5ebee 100644 --- a/modules/58_peatland/v2/realization.gms +++ b/modules/58_peatland/v2/realization.gms @@ -33,6 +33,7 @@ $Ifi "%phase%" == "sets" $include "./modules/58_peatland/v2/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/58_peatland/v2/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/58_peatland/v2/input.gms" $Ifi "%phase%" == "equations" $include "./modules/58_peatland/v2/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/58_peatland/v2/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/58_peatland/v2/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/58_peatland/v2/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/58_peatland/v2/postsolve.gms" diff --git a/modules/58_peatland/v2/scaling.gms b/modules/58_peatland/v2/scaling.gms new file mode 100644 index 0000000000..4e088d0bfb --- /dev/null +++ b/modules/58_peatland/v2/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +v58_peatlandChange.scale(j,land58) = 10e-3; From 924dabd0ac13fb6ed3d0f30d20128e0c7065dedc Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 4 Dec 2023 15:41:25 +0100 Subject: [PATCH 054/187] updated EAT2p0 related start and output scripts --- scripts/output/projects/agmip_merge_report.R | 33 +++++++++------ scripts/output/projects/agmip_report.R | 4 +- scripts/start/projects/project_EAT2p0.R | 42 +++++++++++++++----- 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/scripts/output/projects/agmip_merge_report.R b/scripts/output/projects/agmip_merge_report.R index d7bf55b10d..19785491cc 100644 --- a/scripts/output/projects/agmip_merge_report.R +++ b/scripts/output/projects/agmip_merge_report.R @@ -30,35 +30,44 @@ cat("\nStarting output generation\n") missing <- NULL -if(file.exists("output/agmip_report_full.csv")) file.rename("output/agmip_report_full.csv","output/agmip_report_full.bak") +if (file.exists("output/agmip_report_full.csv")) { + file.rename("output/agmip_report_full.csv", "output/agmip_report_full.bak") +} for (i in 1:length(outputdir)) { - print(paste("Processing",outputdir[i])) + print(paste("Processing", outputdir[i])) #gdx file - rep<-file.path(outputdir[i],"agmip_report.mif") - if(file.exists(rep)) { + rep <- file.path(outputdir[i],"agmip_report.mif") + if (file.exists(rep)) { #get scenario name cfg <- gms::loadConfig(file.path(outputdir[i], "config.yml")) scen <- cfg$title #Remove prefix starting with "V", like "V2" - scen_parts <- unlist(strsplit(scen,"_")) - remove <- grep("V[0-9]",scen_parts) - if (length(remove)>0) scen <- paste(scen_parts[-remove],collapse = "_") + scen_parts <- unlist(strsplit(scen, "_")) + remove <- grep("V[0-9]", scen_parts) + if (length(remove) > 0) { + scen <- paste(scen_parts[-remove], collapse = "_") + } #read-in reporting file a <- read.report(rep,as.list = FALSE) - getNames(a,dim=1) <- scen + getNames(a, dim = 1) <- scen #add to reporting csv file - write.report(a,file="output/agmip_report_full.csv",append=TRUE,ndigit = 4,skipempty = FALSE) - } else missing <- c(missing,outputdir[i]) + write.report(a, file = "output/agmip_report_full.csv", append = TRUE, + ndigit = 4, skipempty = FALSE) + } else { + missing <- c(missing, outputdir[i]) + } } if (!is.null(missing)) { cat("\nList of folders with missing agmip_report.mif\n") print(missing) } -if(file.exists("output/agmip_report_full.csv")) { +if (file.exists("output/agmip_report_full.csv")) { #saveRDS(read.quitte("output/agmip_report_full.csv"),file = "output/agmip_report_full.rds") #agmip_report_full <- read.report(file="agmip_report_full.csv") - write.reportProject(mif="output/agmip_report_full.csv",mapping = system.file("extdata",mapping="variablemappingAgMIP.csv",package = "magpie4"), file = "output/agmip_report_subset.csv",format="AgMIP") + write.reportProject(mif = "output/agmip_report_full.csv", + mapping = system.file("extdata", mapping = "variablemappingAgMIP.csv", package = "magpie4"), + file = "output/agmip_report_subset.csv", format = "AgMIP") #write.reportProject(mif="output/agmip_report_full.csv",mapping = "mapping_magpie_agmip.csv", file = "agmip_report_subset.csv",format="AgMIP") } diff --git a/scripts/output/projects/agmip_report.R b/scripts/output/projects/agmip_report.R index 23545059d2..f16d59fe75 100644 --- a/scripts/output/projects/agmip_report.R +++ b/scripts/output/projects/agmip_report.R @@ -29,10 +29,8 @@ mif <- paste0(outputdir, "/agmip_report.mif") rds <- paste0(outputdir, "/agmip_report.rds") ############################################################################### - report <- getReportAgMIP(gdx, scenario = cfg$title) -###regional aggregation - +### regional aggregation write.report(report, file = mif) saveRDS(as.quitte(report), file = rds) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index e369ad8849..016fee17e1 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -44,7 +44,10 @@ bau <- function(cfg) { # For impacts of CC on labor: cfg$gms$factor_costs <- "sticky_labor" # @Alex/Edna/Florian: Should we use this one? cfg$gms$labor_prod <- "exo" - cfg$gms$c37_labor_rcp <- "rcp585" # @Florian: which one to choose for RCP 7p0? + cfg$gms$c37_labor_rcp <- "rcp585" + # Note: the effect of labor impacts is very low in MAgPIE and we don't have the + # Nelson data implemented. We therefore use the existing data from LAMACLIMA + # and the scenarios rcp119 and rcp585. ### Components for Decomposition ### # Diets: exogenous EATLancet diet @@ -54,13 +57,18 @@ bau <- function(cfg) { # Waste: half food waste cfg$gms$s15_exo_waste <- 0 # default cfg$gms$s15_waste_scen <- 1.2 # default (but not active b/c of s15_exo_waste = 0) - # Higher endogenous productivity achieved through lower costs - cfg$gms$tc <- "endo_jan22" # default - cfg$gms$c13_tccost <- "medium" # default + # Default interest rate (for default productivity) + cfg$gms$s12_interest_lic <- 0.1 # default + cfg$gms$s12_interest_hic <- 0.04 # default + # Default livestock productivity + cfg$gms$c70_feed_scen <- "ssp2" # Mitigation: no mitigation beyond NPI (NPI already set in setScenario) - cfg$gms$c56_emis_policy <- "redd+natveg_nosoil" # default # @Florian: should it be "red+natveg_nosoil" or "default" for case of current policies / no additional mitigation + cfg$gms$c56_emis_policy <- "redd+natveg_nosoil" # default + cfg$path_to_report_ghgprices <- NA cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" # default + cfg$path_to_report_bioenergy <- NA cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default + # Climate Change cfg$input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" @@ -80,9 +88,12 @@ diet <- function(cfg) { # High productivity growth rate similar to productivity trends # associated with SSP1 (e.g., PRD 1 in Stehfest et al.) prod <- function(cfg) { - # Higher endogenous productivity achieved through lower costs - cfg$gms$tc <- "endo_jan22" # default: not necessary to set it again (To Do: remove) - cfg$gms$c13_tccost <- "low" # Should I set it like this? @Jan? Or how was it done in Stehfest et al. PRD1? + # Higher endogenous productivity achieved through lower interest rates + # representing more trust and therefore easier investments + cfg$gms$s12_interest_lic <- 0.06 + cfg$gms$s12_interest_hic <- 0.04 + # Livestock productivity follows SSP1 + cfg$gms$c70_feed_scen <- "ssp1" return(cfg) } @@ -97,11 +108,20 @@ waste <- function(cfg) { ### Mitigation component ## # Adds mitigation and land-use policies consistent with 1.5C by 2050 to BAU +# Note on our implementation: +# We use a GHG pricing pathway based on a peak budget of 500 with overshoot +# starting from 2020. +# Please note that with the diet shift, a lower ghg price would be necessary. +# However, to be consistent with the other models and for the decomposition +# scenarios to be "additive", we choose to use the same ghg price for all scenarios +# where miti is active. +# Reference: Humpenöder, F., Popp, A., Merfort, L., Luderer, G., Weindl, I., Bodirsky, B., Stevanović, M., Klein, D., Rodrigues, R., Bauer, N., Dietrich, J., Lotze-Campen, H., & Rockström, J. (2023). Data repository - Dietary shifts increase the feasibility of 1.5°C pathways (Version 1) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.8328217 miti <- function(cfg) { # Mitigation: consistent with 1.5C - cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? - cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg1300" # @Florian: What to choose for 1.5 degrees? - cfg$gms$c56_emis_policy <- "sdp_all" # @Florian: Which emissions to price? all? + cfg$path_to_report_ghgprices <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" + cfg$gms$c60_2ndgen_biodem <- "coupling" return(cfg) } From 851e1f8dafb4e734590e97f2cc9709d5957f6b8c Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 4 Dec 2023 16:06:08 +0100 Subject: [PATCH 055/187] update agmip output script --- scripts/output/projects/agmip_report.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/output/projects/agmip_report.R b/scripts/output/projects/agmip_report.R index f16d59fe75..6d10cfd725 100644 --- a/scripts/output/projects/agmip_report.R +++ b/scripts/output/projects/agmip_report.R @@ -29,7 +29,7 @@ mif <- paste0(outputdir, "/agmip_report.mif") rds <- paste0(outputdir, "/agmip_report.rds") ############################################################################### -report <- getReportAgMIP(gdx, scenario = cfg$title) +report <- getReportAgMIP(gdx, scenario = cfg$title, detail = TRUE) ### regional aggregation write.report(report, file = mif) From d664588dc470985ae4595a1c7ee29b32e14c4045 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 4 Dec 2023 16:12:36 +0100 Subject: [PATCH 056/187] new sets in standalone food demand model --- standalone/demand_model.gms | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/standalone/demand_model.gms b/standalone/demand_model.gms index 81fea54c9e..9e336aad32 100644 --- a/standalone/demand_model.gms +++ b/standalone/demand_model.gms @@ -41,6 +41,19 @@ sets / livst_rum,livst_pig,livst_chick, livst_egg, livst_milk / + + kli_rd(kap) Ruminant meat and dairy products + / livst_rum,livst_milk / + + kap_to_kfo_ap(kap,kfo_ap) Mapping between animal products and animal food products + /livst_rum . livst_rum + livst_pig . livst_pig + livst_chick . livst_chick + livst_egg . livst_egg + livst_milk . livst_milk + fish . fish + / + ; From 4f5a17561db5f195363358caa214fea19c415d76 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 5 Dec 2023 07:25:54 +0100 Subject: [PATCH 057/187] update cost peatland --- config/default.cfg | 12 +- core/macros.gms | 7 +- modules/58_peatland/module.gms | 2 +- modules/58_peatland/v2/declarations.gms | 65 ++++----- modules/58_peatland/v2/equations.gms | 42 ++---- modules/58_peatland/v2/input.gms | 7 +- modules/58_peatland/v2/postsolve.gms | 184 +++++++++++------------- modules/58_peatland/v2/presolve.gms | 12 +- modules/58_peatland/v2/realization.gms | 4 +- modules/58_peatland/v2/sets.gms | 4 +- 10 files changed, 147 insertions(+), 192 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index f93288dff8..169cbabd5f 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1548,11 +1548,13 @@ cfg$gms$s58_rewetting_switch <- Inf # def = Inf cfg$gms$s58_cost_rewet_onetime <- 7000 # def = 7000 cfg$gms$s58_cost_rewet_recur <- 200 # def = 200 -# * One-time and recurring costs for peatland degradation (USD05MER per ha) -# * One-time costs apply on the conversion of intact (and rewetted) peatland to degraded peatland. -# * Recurring costs apply on the level of degraded peatland. -cfg$gms$s58_cost_degrad_onetime <- 0 # def = 0 -cfg$gms$s58_cost_degrad_recur <- 0 # def = 0 +# * One-time and recurring costs for peatland drainage (USD05MER per ha) +# * One-time costs apply on the drainage of intact and rewetted peatland +# * Recurring costs apply on the level of drained and managed peatland +cfg$gms$s58_cost_drain_intact_onetime <- 0 # def = 0 +cfg$gms$s58_cost_drain_rewet_onetime <- 0 # def = 0 +cfg$gms$s58_cost_drain_recur <- 0 # def = 0 + # * Switch for fixing peatland area until the year given by s58_fix_peatland to historic levels (not available in `off`). # * Note: In the realisation `v2`, historic peatland area is only available for the year 2022. diff --git a/core/macros.gms b/core/macros.gms index 5c79563547..37e70b23f7 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -98,14 +98,13 @@ $macro m_carbon_stock_ac(land,carbon_density,sets,sets_sub) \ sum((&&sets), land(j2,&&sets) * sum(ct, carbon_density(ct,j2,&&sets,ag_pools)))$(sameas(stockType,"actual")) + \ sum((&&sets_sub), land(j2,&&sets_sub) * sum(ct, carbon_density(ct,j2,&&sets_sub,ag_pools)))$(sameas(stockType,"actualNoAcEst")); -* macro for merging managed land area into peatland categories -$macro m_peatLandMerge(land,landForestry,set) \ +* macros for peatland module +$macro m58_LandMerge(land,landForestry,set) \ land(&&set,"crop")$(sameas(manPeat58,"crop")) \ + land(&&set,"past")$(sameas(manPeat58,"past")) \ + landForestry(&&set,"plant")$(sameas(manPeat58,"forestry")) -* macro for peatland expansion factor -$macro m_peatLandLeft(pclandFull,setFull,vland,pcland) \ +$macro m58_LandLeft(pclandFull,setFull,vland,pcland) \ (sum(&&setFull,pclandFull(j2,&&setFull)) \ - sum(manPeat58_alias$(not sameas(manPeat58_alias,manPeat58)),vland(j2,manPeat58_alias)) \ - sum(manPeat58_alias$(sameas(manPeat58_alias,manPeat58)),pcland(j2,manPeat58_alias))) diff --git a/modules/58_peatland/module.gms b/modules/58_peatland/module.gms index d9e66e626f..8d9647e112 100644 --- a/modules/58_peatland/module.gms +++ b/modules/58_peatland/module.gms @@ -9,7 +9,7 @@ *' *' @description The peatland module calculates GHG emissions from degrading/drained peatlands. *' -*' @authors Florian Humpenöder +*' @authors Florian Humpenöder, Debbora Leip *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%peatland%" == "off" $include "./modules/58_peatland/off/realization.gms" diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms index c76cb8ce56..24fce3e0ea 100644 --- a/modules/58_peatland/v2/declarations.gms +++ b/modules/58_peatland/v2/declarations.gms @@ -11,9 +11,10 @@ parameters p58_scalingFactorRed(t,j,manPeat58) Scaling factor for peatland reduction (1) p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) - i58_cost_rewet_onetime(t) One-time costs for peatland restoration (USD05MER per ha) - i58_cost_degrad_recur(t) Recurring costs for degraded peatland (USD05MER per ha) - i58_cost_degrad_onetime(t) One-time costs for peatland degradation (USD05MER per ha) + i58_cost_rewet_onetime(t) One-time costs for peatland rewetting (USD05MER per ha) + i58_cost_drain_recur(t) Recurring costs for drained and managed peatlands (USD05MER per ha) + i58_cost_drain_intact_onetime(t) One-time costs for drainage of intact peatland (USD05MER per ha) + i58_cost_drain_rewet_onetime(t) One-time costs for drainage of rewetted peatland (USD05MER per ha) ; equations @@ -24,19 +25,15 @@ equations q58_manLandRed(j,manPeat58) Managed land area reduction (mio. ha) q58_peatlandMan(j,manPeat58) Change of managed peatland area (mio. ha) q58_scalingFactorExp(j,manPeat58) Scaling factor for peatland expansion (1) - q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - q58_peatland_cost_annuity_intact_decrease(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - q58_peatland_cost_annuity_rewet_decrease(j) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) - q58_peatland_cost_annuity_rewet_increase(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + q58_peatland_cost_annuity(j,cost58) Annuity costs for peatland conversion in the current timestep (mio. USD05MER per yr) q58_peatland_emis_detail(j,land58,emis58) Detailed GHG emissions from peatlands (Tg per yr) q58_peatland_emis(i,poll58) GHG emissions from managed peatland (Tg per yr) ; variables v58_peatlandChange(j,land58) Peatland area change (mio. ha) - vm_peatland_cost(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - v58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + vm_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) v58_peatland_emis(j,land58,emis58) Detailed GHG peatland GHG emissions (Tg per yr) ; @@ -46,38 +43,30 @@ positive variables v58_manLandExp(j,manPeat58) Managed land area expansion (mio. ha) v58_manLandRed(j,manPeat58) Managed land area reduction (mio. ha) v58_scalingFactorExp(j,manPeat58) Scaling factor for peatland expansion (1) - v58_peatland_cost_annuity_intact_decrease(j) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - v58_peatland_cost_annuity_rewet_decrease(j) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) - v58_peatland_cost_annuity_rewet_increase(j) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) + v58_peatland_cost_annuity(j,cost58) Annuity costs for peatland conversion in the current timestep (mio. USD05MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) - ov_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - ov58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - ov58_peatland_emis(t,j,land58,emis58,type) Detailed GHG peatland GHG emissions (Tg per yr) - ov58_peatland(t,j,land58,type) Peatland area (mio. ha) - ov58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) - ov58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) - ov58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) - ov58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) - ov58_peatland_cost_annuity_intact_decrease(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - ov58_peatland_cost_annuity_rewet_decrease(t,j,type) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) - ov58_peatland_cost_annuity_rewet_increase(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) - oq58_peatland(t,j,type) Constraint for total peatland area (mio. ha) - oq58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) - oq58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) - oq58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) - oq58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) - oq58_peatlandMan(t,j,manPeat58,type) Change of managed peatland area (mio. ha) - oq58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) - oq58_peatland_cost_full(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) - oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) - oq58_peatland_cost_annuity_intact_decrease(t,j,type) Annuity costs for reduction of intact peatland in the current timestep (mio. USD05MER per yr) - oq58_peatland_cost_annuity_rewet_decrease(t,j,type) Annuity costs for reduction of rewetted peatland in the current timestep (mio. USD05MER per yr) - oq58_peatland_cost_annuity_rewet_increase(t,j,type) Annuity costs for expansion of rewetted peatland in the current timestep (mio. USD05MER per yr) - oq58_peatland_emis_detail(t,j,land58,emis58,type) Detailed GHG emissions from peatlands (Tg per yr) - oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) + ov58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) + ov_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + ov58_peatland_emis(t,j,land58,emis58,type) Detailed GHG peatland GHG emissions (Tg per yr) + ov58_peatland(t,j,land58,type) Peatland area (mio. ha) + ov58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) + ov58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) + ov58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) + ov58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) + ov58_peatland_cost_annuity(t,j,cost58,type) Annuity costs for peatland conversion in the current timestep (mio. USD05MER per yr) + oq58_peatland(t,j,type) Constraint for total peatland area (mio. ha) + oq58_peatlandChange(t,j,land58,type) Peatland area change (mio. ha) + oq58_manLand(t,j,manPeat58,type) Managed land area (mio. ha) + oq58_manLandExp(t,j,manPeat58,type) Managed land area expansion (mio. ha) + oq58_manLandRed(t,j,manPeat58,type) Managed land area reduction (mio. ha) + oq58_peatlandMan(t,j,manPeat58,type) Change of managed peatland area (mio. ha) + oq58_scalingFactorExp(t,j,manPeat58,type) Scaling factor for peatland expansion (1) + oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + oq58_peatland_cost_annuity(t,j,cost58,type) Annuity costs for peatland conversion in the current timestep (mio. USD05MER per yr) + oq58_peatland_emis_detail(t,j,land58,emis58,type) Detailed GHG emissions from peatlands (Tg per yr) + oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms index 3063daa8af..02697f4001 100644 --- a/modules/58_peatland/v2/equations.gms +++ b/modules/58_peatland/v2/equations.gms @@ -20,15 +20,15 @@ *' Managed land area: q58_manLand(j2,manPeat58) .. - v58_manLand(j2,manPeat58) =e= m_peatLandMerge(vm_land,vm_land_forestry,"j2"); + v58_manLand(j2,manPeat58) =e= m58_LandMerge(vm_land,vm_land_forestry,"j2"); *' Managed land area expansion and reduction: q58_manLandExp(j2,manPeat58) .. - v58_manLandExp(j2,manPeat58) =e= m_peatLandMerge(vm_landexpansion,vm_landexpansion_forestry,"j2"); + v58_manLandExp(j2,manPeat58) =e= m58_LandMerge(vm_landexpansion,vm_landexpansion_forestry,"j2"); q58_manLandRed(j2,manPeat58) .. - v58_manLandRed(j2,manPeat58) =e= m_peatLandMerge(vm_landreduction,vm_landreduction_forestry,"j2"); + v58_manLandRed(j2,manPeat58) =e= m58_LandMerge(vm_landreduction,vm_landreduction_forestry,"j2"); *' Future peatland dynamics (`v58_peatland`) depend on changes in managed land (`v58_manLandExp`, `v58_manLandRed`), *' multiplied with corresponding scaling factors for expansion (`v58_scalingFactorExp`) and reduction (`p58_scalingFactorRed`). @@ -45,41 +45,27 @@ - v58_manLandRed(j2,manPeat58) * sum(ct, p58_scalingFactorRed(ct,j2,manPeat58)); *' Peatland scaling factor for expansion: (maxPeatland - totalManagedPeatland) / (maxLand - totalManagedLand). -*' See macro `m_peatLandLeft` for details. +*' See macro `m58_LandLeft` for details. q58_scalingFactorExp(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_scalingFactorExp(j2,manPeat58) =e= - (m_peatLandLeft(pc58_peatland,"land58",v58_peatland,pc58_peatland) / m_peatLandLeft(pcm_land,"land",v58_manLand,pc58_manLand)) - $(m_peatLandLeft(pc58_peatland,"land58",pc58_peatland,pc58_peatland) > 1e-10 AND m_peatLandLeft(pcm_land,"land",pc58_manLand,pc58_manLand) > 1e-10) - + 0$(m_peatLandLeft(pc58_peatland,"land58",pc58_peatland,pc58_peatland) <= 1e-10 OR m_peatLandLeft(pcm_land,"land",pc58_manLand,pc58_manLand) <= 1e-10); + (m58_LandLeft(pc58_peatland,"land58",v58_peatland,pc58_peatland) / m58_LandLeft(pcm_land,"land",v58_manLand,pc58_manLand)) + $(m58_LandLeft(pc58_peatland,"land58",pc58_peatland,pc58_peatland) > 1e-10 AND m58_LandLeft(pcm_land,"land",pc58_manLand,pc58_manLand) > 1e-10) + + 0$(m58_LandLeft(pc58_peatland,"land58",pc58_peatland,pc58_peatland) <= 1e-10 OR m58_LandLeft(pcm_land,"land",pc58_manLand,pc58_manLand) <= 1e-10); *' Costs for peatland degradation and rewetting - q58_peatland_cost_full(j2) .. - vm_peatland_cost(j2) =e= v58_peatland_cost(j2); - q58_peatland_cost(j2) .. - v58_peatland_cost(j2) =e= v58_peatland_cost_annuity_intact_decrease(j2) - + v58_peatland_cost_annuity_rewet_decrease(j2) - + v58_peatland_cost_annuity_rewet_increase(j2) + vm_peatland_cost(j2) =e= sum(cost58, v58_peatland_cost_annuity(j2,cost58)) + v58_peatland(j2,"rewetted") * sum(ct, i58_cost_rewet_recur(ct)) - + sum(manPeat58, v58_peatland(j2,manPeat58)) * sum(ct, i58_cost_degrad_recur(ct)); - - q58_peatland_cost_annuity_intact_decrease(j2) .. - v58_peatland_cost_annuity_intact_decrease(j2) =g= - - v58_peatlandChange(j2,"intact") * sum(ct, i58_cost_degrad_onetime(ct)) - * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + + sum(manPeat58, v58_peatland(j2,manPeat58)) * sum(ct, i58_cost_drain_recur(ct)); - q58_peatland_cost_annuity_rewet_decrease(j2) .. - v58_peatland_cost_annuity_rewet_decrease(j2) =g= - - v58_peatlandChange(j2,"rewetted") * sum(ct, i58_cost_degrad_onetime(ct)) + q58_peatland_cost_annuity(j2,cost58) .. + v58_peatland_cost_annuity(j2,cost58) =g= + (- v58_peatlandChange(j2,"intact") * sum(ct, i58_cost_drain_intact_onetime(ct)))$sameas(cost58,"drain_intact") + + (- v58_peatlandChange(j2,"rewetted") * sum(ct, i58_cost_drain_rewet_onetime(ct)))$sameas(cost58,"drain_rewetted") + + (v58_peatlandChange(j2,"rewetted") * sum(ct, i58_cost_rewet_onetime(ct)))$sameas(cost58,"rewet") * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - - q58_peatland_cost_annuity_rewet_increase(j2) .. - v58_peatland_cost_annuity_rewet_increase(j2) =g= - v58_peatlandChange(j2,"rewetted") * sum(ct, i58_cost_rewet_onetime(ct)) - * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - *' Detailed peatland GHG emissions diff --git a/modules/58_peatland/v2/input.gms b/modules/58_peatland/v2/input.gms index 65ea3f4d82..297f945d39 100644 --- a/modules/58_peatland/v2/input.gms +++ b/modules/58_peatland/v2/input.gms @@ -7,9 +7,10 @@ scalars s58_cost_rewet_recur Recurring costs for rewetted peatland (USD05MER per ha) / 200 / - s58_cost_rewet_onetime One-time costs for peatland restoration (USD05MER per ha) / 7000 / - s58_cost_degrad_recur Recurring costs for degraded peatland (USD05MER per ha) / 0 / - s58_cost_degrad_onetime One-time costs for peatland degradation (USD05MER per ha) / 0 / + s58_cost_rewet_onetime One-time costs for peatland rewetting (USD05MER per ha) / 7000 / + s58_cost_drain_recur Recurring costs for drained and managed peatlands (USD05MER per ha) / 0 / + s58_cost_drain_intact_onetime One-time costs for drainage of intact peatland (USD05MER per ha) / 0 / + s58_cost_drain_rewet_onetime One-time costs for drainage of rewetted peatland (USD05MER per ha) / 0 / s58_rewetting_switch Peatland rewetting on (Inf) or off (0) / Inf / s58_fix_peatland Year indicating until when peatland area should be fixed (year) / 2020 / ; diff --git a/modules/58_peatland/v2/postsolve.gms b/modules/58_peatland/v2/postsolve.gms index 308561feb8..838d8f57ef 100644 --- a/modules/58_peatland/v2/postsolve.gms +++ b/modules/58_peatland/v2/postsolve.gms @@ -9,108 +9,84 @@ pc58_peatland(j,land58) = v58_peatland.l(j,land58); pc58_manLand(j,manPeat58) = v58_manLand.l(j,manPeat58); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov58_peatlandChange(t,j,land58,"marginal") = v58_peatlandChange.m(j,land58); - ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); - ov58_peatland_cost(t,j,"marginal") = v58_peatland_cost.m(j); - ov58_peatland_emis(t,j,land58,emis58,"marginal") = v58_peatland_emis.m(j,land58,emis58); - ov58_peatland(t,j,land58,"marginal") = v58_peatland.m(j,land58); - ov58_manLand(t,j,manPeat58,"marginal") = v58_manLand.m(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"marginal") = v58_manLandExp.m(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"marginal") = v58_manLandRed.m(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"marginal") = v58_scalingFactorExp.m(j,manPeat58); - ov58_peatland_cost_annuity_intact_decrease(t,j,"marginal") = v58_peatland_cost_annuity_intact_decrease.m(j); - ov58_peatland_cost_annuity_rewet_decrease(t,j,"marginal") = v58_peatland_cost_annuity_rewet_decrease.m(j); - ov58_peatland_cost_annuity_rewet_increase(t,j,"marginal") = v58_peatland_cost_annuity_rewet_increase.m(j); - oq58_peatland(t,j,"marginal") = q58_peatland.m(j); - oq58_peatlandChange(t,j,land58,"marginal") = q58_peatlandChange.m(j,land58); - oq58_manLand(t,j,manPeat58,"marginal") = q58_manLand.m(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"marginal") = q58_manLandExp.m(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"marginal") = q58_manLandRed.m(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"marginal") = q58_peatlandMan.m(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"marginal") = q58_scalingFactorExp.m(j,manPeat58); - oq58_peatland_cost_full(t,j,"marginal") = q58_peatland_cost_full.m(j); - oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); - oq58_peatland_cost_annuity_intact_decrease(t,j,"marginal") = q58_peatland_cost_annuity_intact_decrease.m(j); - oq58_peatland_cost_annuity_rewet_decrease(t,j,"marginal") = q58_peatland_cost_annuity_rewet_decrease.m(j); - oq58_peatland_cost_annuity_rewet_increase(t,j,"marginal") = q58_peatland_cost_annuity_rewet_increase.m(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"marginal") = q58_peatland_emis_detail.m(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); - ov58_peatlandChange(t,j,land58,"level") = v58_peatlandChange.l(j,land58); - ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); - ov58_peatland_cost(t,j,"level") = v58_peatland_cost.l(j); - ov58_peatland_emis(t,j,land58,emis58,"level") = v58_peatland_emis.l(j,land58,emis58); - ov58_peatland(t,j,land58,"level") = v58_peatland.l(j,land58); - ov58_manLand(t,j,manPeat58,"level") = v58_manLand.l(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"level") = v58_manLandExp.l(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"level") = v58_manLandRed.l(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"level") = v58_scalingFactorExp.l(j,manPeat58); - ov58_peatland_cost_annuity_intact_decrease(t,j,"level") = v58_peatland_cost_annuity_intact_decrease.l(j); - ov58_peatland_cost_annuity_rewet_decrease(t,j,"level") = v58_peatland_cost_annuity_rewet_decrease.l(j); - ov58_peatland_cost_annuity_rewet_increase(t,j,"level") = v58_peatland_cost_annuity_rewet_increase.l(j); - oq58_peatland(t,j,"level") = q58_peatland.l(j); - oq58_peatlandChange(t,j,land58,"level") = q58_peatlandChange.l(j,land58); - oq58_manLand(t,j,manPeat58,"level") = q58_manLand.l(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"level") = q58_manLandExp.l(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"level") = q58_manLandRed.l(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"level") = q58_peatlandMan.l(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"level") = q58_scalingFactorExp.l(j,manPeat58); - oq58_peatland_cost_full(t,j,"level") = q58_peatland_cost_full.l(j); - oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); - oq58_peatland_cost_annuity_intact_decrease(t,j,"level") = q58_peatland_cost_annuity_intact_decrease.l(j); - oq58_peatland_cost_annuity_rewet_decrease(t,j,"level") = q58_peatland_cost_annuity_rewet_decrease.l(j); - oq58_peatland_cost_annuity_rewet_increase(t,j,"level") = q58_peatland_cost_annuity_rewet_increase.l(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"level") = q58_peatland_emis_detail.l(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); - ov58_peatlandChange(t,j,land58,"upper") = v58_peatlandChange.up(j,land58); - ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); - ov58_peatland_cost(t,j,"upper") = v58_peatland_cost.up(j); - ov58_peatland_emis(t,j,land58,emis58,"upper") = v58_peatland_emis.up(j,land58,emis58); - ov58_peatland(t,j,land58,"upper") = v58_peatland.up(j,land58); - ov58_manLand(t,j,manPeat58,"upper") = v58_manLand.up(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"upper") = v58_manLandExp.up(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"upper") = v58_manLandRed.up(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"upper") = v58_scalingFactorExp.up(j,manPeat58); - ov58_peatland_cost_annuity_intact_decrease(t,j,"upper") = v58_peatland_cost_annuity_intact_decrease.up(j); - ov58_peatland_cost_annuity_rewet_decrease(t,j,"upper") = v58_peatland_cost_annuity_rewet_decrease.up(j); - ov58_peatland_cost_annuity_rewet_increase(t,j,"upper") = v58_peatland_cost_annuity_rewet_increase.up(j); - oq58_peatland(t,j,"upper") = q58_peatland.up(j); - oq58_peatlandChange(t,j,land58,"upper") = q58_peatlandChange.up(j,land58); - oq58_manLand(t,j,manPeat58,"upper") = q58_manLand.up(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"upper") = q58_manLandExp.up(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"upper") = q58_manLandRed.up(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"upper") = q58_peatlandMan.up(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"upper") = q58_scalingFactorExp.up(j,manPeat58); - oq58_peatland_cost_full(t,j,"upper") = q58_peatland_cost_full.up(j); - oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); - oq58_peatland_cost_annuity_intact_decrease(t,j,"upper") = q58_peatland_cost_annuity_intact_decrease.up(j); - oq58_peatland_cost_annuity_rewet_decrease(t,j,"upper") = q58_peatland_cost_annuity_rewet_decrease.up(j); - oq58_peatland_cost_annuity_rewet_increase(t,j,"upper") = q58_peatland_cost_annuity_rewet_increase.up(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"upper") = q58_peatland_emis_detail.up(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); - ov58_peatlandChange(t,j,land58,"lower") = v58_peatlandChange.lo(j,land58); - ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); - ov58_peatland_cost(t,j,"lower") = v58_peatland_cost.lo(j); - ov58_peatland_emis(t,j,land58,emis58,"lower") = v58_peatland_emis.lo(j,land58,emis58); - ov58_peatland(t,j,land58,"lower") = v58_peatland.lo(j,land58); - ov58_manLand(t,j,manPeat58,"lower") = v58_manLand.lo(j,manPeat58); - ov58_manLandExp(t,j,manPeat58,"lower") = v58_manLandExp.lo(j,manPeat58); - ov58_manLandRed(t,j,manPeat58,"lower") = v58_manLandRed.lo(j,manPeat58); - ov58_scalingFactorExp(t,j,manPeat58,"lower") = v58_scalingFactorExp.lo(j,manPeat58); - ov58_peatland_cost_annuity_intact_decrease(t,j,"lower") = v58_peatland_cost_annuity_intact_decrease.lo(j); - ov58_peatland_cost_annuity_rewet_decrease(t,j,"lower") = v58_peatland_cost_annuity_rewet_decrease.lo(j); - ov58_peatland_cost_annuity_rewet_increase(t,j,"lower") = v58_peatland_cost_annuity_rewet_increase.lo(j); - oq58_peatland(t,j,"lower") = q58_peatland.lo(j); - oq58_peatlandChange(t,j,land58,"lower") = q58_peatlandChange.lo(j,land58); - oq58_manLand(t,j,manPeat58,"lower") = q58_manLand.lo(j,manPeat58); - oq58_manLandExp(t,j,manPeat58,"lower") = q58_manLandExp.lo(j,manPeat58); - oq58_manLandRed(t,j,manPeat58,"lower") = q58_manLandRed.lo(j,manPeat58); - oq58_peatlandMan(t,j,manPeat58,"lower") = q58_peatlandMan.lo(j,manPeat58); - oq58_scalingFactorExp(t,j,manPeat58,"lower") = q58_scalingFactorExp.lo(j,manPeat58); - oq58_peatland_cost_full(t,j,"lower") = q58_peatland_cost_full.lo(j); - oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); - oq58_peatland_cost_annuity_intact_decrease(t,j,"lower") = q58_peatland_cost_annuity_intact_decrease.lo(j); - oq58_peatland_cost_annuity_rewet_decrease(t,j,"lower") = q58_peatland_cost_annuity_rewet_decrease.lo(j); - oq58_peatland_cost_annuity_rewet_increase(t,j,"lower") = q58_peatland_cost_annuity_rewet_increase.lo(j); - oq58_peatland_emis_detail(t,j,land58,emis58,"lower") = q58_peatland_emis_detail.lo(j,land58,emis58); - oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); + ov58_peatlandChange(t,j,land58,"marginal") = v58_peatlandChange.m(j,land58); + ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); + ov58_peatland_emis(t,j,land58,emis58,"marginal") = v58_peatland_emis.m(j,land58,emis58); + ov58_peatland(t,j,land58,"marginal") = v58_peatland.m(j,land58); + ov58_manLand(t,j,manPeat58,"marginal") = v58_manLand.m(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"marginal") = v58_manLandExp.m(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"marginal") = v58_manLandRed.m(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"marginal") = v58_scalingFactorExp.m(j,manPeat58); + ov58_peatland_cost_annuity(t,j,cost58,"marginal") = v58_peatland_cost_annuity.m(j,cost58); + oq58_peatland(t,j,"marginal") = q58_peatland.m(j); + oq58_peatlandChange(t,j,land58,"marginal") = q58_peatlandChange.m(j,land58); + oq58_manLand(t,j,manPeat58,"marginal") = q58_manLand.m(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"marginal") = q58_manLandExp.m(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"marginal") = q58_manLandRed.m(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"marginal") = q58_peatlandMan.m(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"marginal") = q58_scalingFactorExp.m(j,manPeat58); + oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); + oq58_peatland_cost_annuity(t,j,cost58,"marginal") = q58_peatland_cost_annuity.m(j,cost58); + oq58_peatland_emis_detail(t,j,land58,emis58,"marginal") = q58_peatland_emis_detail.m(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); + ov58_peatlandChange(t,j,land58,"level") = v58_peatlandChange.l(j,land58); + ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); + ov58_peatland_emis(t,j,land58,emis58,"level") = v58_peatland_emis.l(j,land58,emis58); + ov58_peatland(t,j,land58,"level") = v58_peatland.l(j,land58); + ov58_manLand(t,j,manPeat58,"level") = v58_manLand.l(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"level") = v58_manLandExp.l(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"level") = v58_manLandRed.l(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"level") = v58_scalingFactorExp.l(j,manPeat58); + ov58_peatland_cost_annuity(t,j,cost58,"level") = v58_peatland_cost_annuity.l(j,cost58); + oq58_peatland(t,j,"level") = q58_peatland.l(j); + oq58_peatlandChange(t,j,land58,"level") = q58_peatlandChange.l(j,land58); + oq58_manLand(t,j,manPeat58,"level") = q58_manLand.l(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"level") = q58_manLandExp.l(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"level") = q58_manLandRed.l(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"level") = q58_peatlandMan.l(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"level") = q58_scalingFactorExp.l(j,manPeat58); + oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); + oq58_peatland_cost_annuity(t,j,cost58,"level") = q58_peatland_cost_annuity.l(j,cost58); + oq58_peatland_emis_detail(t,j,land58,emis58,"level") = q58_peatland_emis_detail.l(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); + ov58_peatlandChange(t,j,land58,"upper") = v58_peatlandChange.up(j,land58); + ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); + ov58_peatland_emis(t,j,land58,emis58,"upper") = v58_peatland_emis.up(j,land58,emis58); + ov58_peatland(t,j,land58,"upper") = v58_peatland.up(j,land58); + ov58_manLand(t,j,manPeat58,"upper") = v58_manLand.up(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"upper") = v58_manLandExp.up(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"upper") = v58_manLandRed.up(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"upper") = v58_scalingFactorExp.up(j,manPeat58); + ov58_peatland_cost_annuity(t,j,cost58,"upper") = v58_peatland_cost_annuity.up(j,cost58); + oq58_peatland(t,j,"upper") = q58_peatland.up(j); + oq58_peatlandChange(t,j,land58,"upper") = q58_peatlandChange.up(j,land58); + oq58_manLand(t,j,manPeat58,"upper") = q58_manLand.up(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"upper") = q58_manLandExp.up(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"upper") = q58_manLandRed.up(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"upper") = q58_peatlandMan.up(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"upper") = q58_scalingFactorExp.up(j,manPeat58); + oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); + oq58_peatland_cost_annuity(t,j,cost58,"upper") = q58_peatland_cost_annuity.up(j,cost58); + oq58_peatland_emis_detail(t,j,land58,emis58,"upper") = q58_peatland_emis_detail.up(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); + ov58_peatlandChange(t,j,land58,"lower") = v58_peatlandChange.lo(j,land58); + ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); + ov58_peatland_emis(t,j,land58,emis58,"lower") = v58_peatland_emis.lo(j,land58,emis58); + ov58_peatland(t,j,land58,"lower") = v58_peatland.lo(j,land58); + ov58_manLand(t,j,manPeat58,"lower") = v58_manLand.lo(j,manPeat58); + ov58_manLandExp(t,j,manPeat58,"lower") = v58_manLandExp.lo(j,manPeat58); + ov58_manLandRed(t,j,manPeat58,"lower") = v58_manLandRed.lo(j,manPeat58); + ov58_scalingFactorExp(t,j,manPeat58,"lower") = v58_scalingFactorExp.lo(j,manPeat58); + ov58_peatland_cost_annuity(t,j,cost58,"lower") = v58_peatland_cost_annuity.lo(j,cost58); + oq58_peatland(t,j,"lower") = q58_peatland.lo(j); + oq58_peatlandChange(t,j,land58,"lower") = q58_peatlandChange.lo(j,land58); + oq58_manLand(t,j,manPeat58,"lower") = q58_manLand.lo(j,manPeat58); + oq58_manLandExp(t,j,manPeat58,"lower") = q58_manLandExp.lo(j,manPeat58); + oq58_manLandRed(t,j,manPeat58,"lower") = q58_manLandRed.lo(j,manPeat58); + oq58_peatlandMan(t,j,manPeat58,"lower") = q58_peatlandMan.lo(j,manPeat58); + oq58_scalingFactorExp(t,j,manPeat58,"lower") = q58_scalingFactorExp.lo(j,manPeat58); + oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); + oq58_peatland_cost_annuity(t,j,cost58,"lower") = q58_peatland_cost_annuity.lo(j,cost58); + oq58_peatland_emis_detail(t,j,land58,emis58,"lower") = q58_peatland_emis_detail.lo(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms index af64883270..c88bb54a58 100644 --- a/modules/58_peatland/v2/presolve.gms +++ b/modules/58_peatland/v2/presolve.gms @@ -8,7 +8,7 @@ if (m_year(t) <= s58_fix_peatland, * Managed land area - pc58_manLand(j,manPeat58) = m_peatLandMerge(pcm_land,pcm_land_forestry,"j"); + pc58_manLand(j,manPeat58) = m58_LandMerge(pcm_land,pcm_land_forestry,"j"); * Initialization of peatland area. Drained and used peatland area cannot exceed the corresponding managed area pc58_peatland(j,manPeat58) = min(f58_peatland_area(j,manPeat58),pc58_manLand(j,manPeat58)); @@ -22,9 +22,10 @@ if (m_year(t) <= s58_fix_peatland, * Peatland area is fixed to `pc58_peatland` until the year given by s58_fix_peatland v58_peatland.fx(j,land58) = pc58_peatland(j,land58); i58_cost_rewet_recur(t) = 0; + i58_cost_drain_recur(t) = 0; + i58_cost_drain_intact_onetime(t) = 0; + i58_cost_drain_rewet_onetime(t) = 0; i58_cost_rewet_onetime(t) = 0; - i58_cost_degrad_recur(t) = 0; - i58_cost_degrad_onetime(t) = 0; else * Define bounds and costs for peatland area after the year given by s58_fix_peatland v58_peatland.lo(j,land58) = 0; @@ -34,9 +35,10 @@ else v58_peatland.up(j,"intact") = pc58_peatland(j,"intact"); v58_peatland.fx(j,"peatExtract") = pc58_peatland(j,"peatExtract"); i58_cost_rewet_recur(t) = s58_cost_rewet_recur; + i58_cost_drain_recur(t) = s58_cost_drain_recur; + i58_cost_drain_intact_onetime(t) = s58_cost_drain_intact_onetime; + i58_cost_drain_rewet_onetime(t) = s58_cost_drain_rewet_onetime; i58_cost_rewet_onetime(t) = s58_cost_rewet_onetime; - i58_cost_degrad_recur(t) = s58_cost_degrad_recur; - i58_cost_degrad_onetime(t) = s58_cost_degrad_onetime; ); *' @code diff --git a/modules/58_peatland/v2/realization.gms b/modules/58_peatland/v2/realization.gms index 8d13b5ebee..7750b42f01 100644 --- a/modules/58_peatland/v2/realization.gms +++ b/modules/58_peatland/v2/realization.gms @@ -10,7 +10,7 @@ *' The initial map for intact, degraded and rewetted peatland is based on the *' [Global Peatland Map 2.0](https://globalpeatlands.org/resource-library/global-peatland-map-20) *' and the [Global Peatland Database](https://greifswaldmoor.de/global-peatland-database-en.html), both for the year 2022. -*' Therefore, it is advised to set `s58_fix_peatland` to `2020` when using this realisation. +*' Therefore, it is advised to set `s58_fix_peatland` to `2020` when using this realisation (2022 is not available as time step in MAgPIE). *' Future peatland dynamics are estimated by multiplying changes in managed land with a peatland scaling factor. *' GHG emissions from drained and rewetted peatlands as well as from peat extraction are calculated based on GHG emission factors. *' In this realisation, peatland GHG emission factors for boreal and tropical climates are based on @IPCC_wetland_2013 and @wilson_2016. @@ -25,7 +25,7 @@ *' -*' @limitations Peatland area and GHG emissions are fixed to 2020 levels for the historic period, +*' @limitations Peatland area and GHG emissions are fixed to 2022 levels for the historic period, *' depending on `s58_fix_peatland`. Organic carbon stocks in peatlands are not accounted for. *####################### R SECTION START (PHASES) ############################## diff --git a/modules/58_peatland/v2/sets.gms b/modules/58_peatland/v2/sets.gms index d4a99c9441..d5e5579b0c 100644 --- a/modules/58_peatland/v2/sets.gms +++ b/modules/58_peatland/v2/sets.gms @@ -16,8 +16,8 @@ sets manPeat58(land58) Drained and managed peatland categories / crop, past, forestry / - manLand58(land) Managed main land categories - / crop, past, forestry / + cost58 annunity cost categories + / drain_intact, drain_rewetted, rewet / emis58 Wetland emission types / co2, doc, ch4, n2o / From 2e8003c3235955cabb335867215f229c23c51709 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 5 Dec 2023 11:43:22 +0100 Subject: [PATCH 058/187] updated preprocessing for EAT runs --- scripts/start/projects/project_EAT2p0.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 016fee17e1..87554bf481 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -70,7 +70,7 @@ bau <- function(cfg) { cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default # Climate Change - cfg$input['cellular'] <- "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "WARNINGS2_rev4.95_h12_c6a7458f_cellularmagpie_c200_IPSL-CM6A-LR-ssp370_lpjml-8e6c5eb1.tgz" return(cfg) } @@ -141,7 +141,7 @@ noCC <- function(cfg) { ### RCP 2.6 ### # Decomposition Scenario. Apply lower climate impacts based on RCP 2.6 to BAU rcp26 <- function(cfg) { - cfg$input['cellular'] <- "rev4.94_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "WARNINGS4_rev4.95_h12_5033a1ce_cellularmagpie_c200_IPSL-CM6A-LR-ssp126_lpjml-8e6c5eb1.tgz" return(cfg) } From f11de073438a15bfbd451e36ad7217986cbc1b5c Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 5 Dec 2023 18:21:25 +0100 Subject: [PATCH 059/187] remove TRUE argument from getReportAgMIP as it might cause error --- scripts/output/projects/agmip_report.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/output/projects/agmip_report.R b/scripts/output/projects/agmip_report.R index 6d10cfd725..f16d59fe75 100644 --- a/scripts/output/projects/agmip_report.R +++ b/scripts/output/projects/agmip_report.R @@ -29,7 +29,7 @@ mif <- paste0(outputdir, "/agmip_report.mif") rds <- paste0(outputdir, "/agmip_report.rds") ############################################################################### -report <- getReportAgMIP(gdx, scenario = cfg$title, detail = TRUE) +report <- getReportAgMIP(gdx, scenario = cfg$title) ### regional aggregation write.report(report, file = mif) From 7ee4d9b764dae82561e84d27bd9a2a26c63f85e1 Mon Sep 17 00:00:00 2001 From: davidho Date: Thu, 7 Dec 2023 14:34:09 +0100 Subject: [PATCH 060/187] added consistency check for yield calibration run without use of calibration factors --- scripts/start_functions.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 55bda9ae88..bf8630bc91 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -433,6 +433,19 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) } # Yield calibration + + # check for inconsistent settings + if((cfg$recalibrate == TRUE || cfg$recalibrate == "ifneeded") + && cfg$gms$s14_use_yield_calib == 0) { + stop("Recalibration of yields with a calibration run is requested (if needed), + but the resulting factors from this run are specified to not be used in the model. + This combination of settings is inconsistent and assumed to be unintended. + Please check the config and either set `cfg$gms$s14_use_yield_calib <- 1` + if yield calibration is desired, or `cfg$recalibrate <- FALSE` if not. + Note that the current default is to not use yield calibration.") + } + + # decide if calibration is needed if "ifneeded" is specified calib_file <- "modules/14_yields/input/f14_yld_calib.csv" if(cfg$recalibrate=="ifneeded") { if(!file.exists(calib_file)) { From fe96303b3ae0a92e9258bb58f527e3dee5340df7 Mon Sep 17 00:00:00 2001 From: davidho Date: Thu, 7 Dec 2023 14:58:37 +0100 Subject: [PATCH 061/187] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a63682fe4..09405b9b20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed +- **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **inputdata** Now using inputdata rev4.94 which is based on 67420 cells (67k, previously 59k) - **14_yields_and_config** The new default is to not use yield calibration factors from a calibration run. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors. - **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files. From 72079da988cd90afb2c5809694467aa2def78e34 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:18:25 +0100 Subject: [PATCH 062/187] Update start_functions.R Reformulated error message. --- scripts/start_functions.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index bf8630bc91..4f98b1417b 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -437,10 +437,9 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) # check for inconsistent settings if((cfg$recalibrate == TRUE || cfg$recalibrate == "ifneeded") && cfg$gms$s14_use_yield_calib == 0) { - stop("Recalibration of yields with a calibration run is requested (if needed), - but the resulting factors from this run are specified to not be used in the model. - This combination of settings is inconsistent and assumed to be unintended. - Please check the config and either set `cfg$gms$s14_use_yield_calib <- 1` + stop("The combination of the switches `cfg$recalibrate <- TRUE/ifneeded` + and `cfg$gms$s14_use_yield_calib <- 0` is inconsistent. + Please check the config and set `cfg$gms$s14_use_yield_calib <- 1` if yield calibration is desired, or `cfg$recalibrate <- FALSE` if not. Note that the current default is to not use yield calibration.") } From 11b4ac3a2d8e4d8d239b5dd180e1644e80de97b1 Mon Sep 17 00:00:00 2001 From: DavidhoPIK <101278418+DavidhoPIK@users.noreply.github.com> Date: Thu, 7 Dec 2023 16:58:41 +0100 Subject: [PATCH 063/187] Update start_functions.R --- scripts/start_functions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 4f98b1417b..a6d47fe389 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -437,7 +437,7 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) # check for inconsistent settings if((cfg$recalibrate == TRUE || cfg$recalibrate == "ifneeded") && cfg$gms$s14_use_yield_calib == 0) { - stop("The combination of the switches `cfg$recalibrate <- TRUE/ifneeded` + stop("The combination of the switch configurations `cfg$recalibrate <- TRUE/ifneeded` and `cfg$gms$s14_use_yield_calib <- 0` is inconsistent. Please check the config and set `cfg$gms$s14_use_yield_calib <- 1` if yield calibration is desired, or `cfg$recalibrate <- FALSE` if not. From bd1dcd8636fed64a45f9462a9d9ad7f9482cf21f Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 11 Dec 2023 09:18:04 +0100 Subject: [PATCH 064/187] bugfix 4.95 scenario config --- config/scenario_config.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 1c6266c95c..0597b2f5ad 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -78,7 +78,7 @@ gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;; gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.94_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.94_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.94_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.94_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.94_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.95_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.95_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.95_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.95_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.95_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.95_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; From 0f5dd9a02761c1c7a37a09bf4ca45b3034e1dae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Tue, 12 Dec 2023 10:50:54 +0100 Subject: [PATCH 065/187] fix changelog --- CHANGELOG.md | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9a3370ee9..500dba0be0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,45 +8,42 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed -- +- **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib +- **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. +- **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` ### added -- +- **32_forestry** new interfaces `vm_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` +- **scripts** added peatland to output/extra/disaggregation.R ### removed -- +- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. +- **58_peatland** removed realization "on" ### fixed -- +- **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k ## [4.7.0] - 2023-12-11 ### changed -- **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib -- **inputdata** Now using inputdata rev4.94 which is based on 67420 cells (67k, previously 59k) - **14_yields_and_config** The new default is to not use yield calibration factors from a calibration run. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors. -- **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files. -- **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits. -- **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **36_employment** regression between hourly labor regression and GDP pc changed from linear to log-log -- **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` +- **inputdata** Now using inputdata rev4.94 which is based on 67420 cells (67k, previously 59k) +- **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits. +- **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files. ### added - **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. +- **18_residues** Included cluster-level residue realization, for cluster-level production of residues (but balancing of recycling and burning budgets remains at region-level, for computational lightness) +- **32_forestry** new interface `vm_land_forestry` - **58_peatland** added realization "v2" with updated peatland map and GHG emission factors -- **32_forestry** new interfaces `vm_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` -- **scripts** added peatland to output/extra/disaggregation.R - -### removed -- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. -- **58_peatland** removed realization "on" ### fixed - **inputdata** There was a major bug (related to proj/terra) in the rev4.91 inputdata that was fixed with rev4.92 - **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93 - **scripts** Fixed a bug in NPI/NDC calculations leading to missing AD policies when run with 67k -- **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k + ## [4.6.11] - 2023-09-05 From f81916680d6d5a54a6aba163a8ac9a7cf32eb72e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 12 Dec 2023 14:59:54 +0100 Subject: [PATCH 066/187] added small amount to p15_intake_detail where sum over food products would be zero to avoid divison by zero --- config/default.cfg | 2 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 4ea83f956d..5304dbeb84 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -424,7 +424,7 @@ cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 # * Switch for transition to exogenous diet scenarios # * (EAT Lancet and National Institute of Nutrition (NIN)) # * (3): MAgPIE-specific realization of the EAT-Lancet diet, where model-internal -# * (regression-based) food demand projections are constraint by ranges for +# * (regression-based) food demand projections are constrained by ranges for # * intake targets of food groups to ensure healthy and sustainable diets as # * recommended by the EAT-Lancet Commission # * (2): transition towards exogenous diets (NIN for India and EAT for other regions) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 7bd203ed57..d838e8afab 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -384,7 +384,7 @@ if (s15_exo_diet = 1, *---------------------------------------------------------------------------------------- elseif (s15_exo_diet = 3), *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), -*' model-internal diet projections are constraint by recommended ranges for intake +*' model-internal diet projections are constrained by recommended ranges for intake *' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable *' diets according to the EAT-Lancet Commission. After all calorie recommendations *' for non-staple food groups are satisfied, intake of staple crops is modified such @@ -400,7 +400,7 @@ elseif (s15_exo_diet = 3), *' It is, however, switched off for roots, since they will, as staples, *' later be treated as balancing post to meet total calorie intake: i15_rec_EATLancet(iso,"t_roots","max") = i15_intake_scen_target(t,iso); -*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target +*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target... *** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) display i15_rec_EATLancet; @@ -412,6 +412,14 @@ display i15_rec_EATLancet; * / (i15_calib_fsupply(i) * i15_demand2intake_detailed_ref(i,kfo) * p15_foodwaste_growth(t,i)); *i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); +*' For cases where the intake in a EAT-Lancet food group is zero for a country +*' in a particular time step, a small amount is added to ensure no division by +*' zero. This way, all kfo-items in the respective food group are corrected by +*' the same amount. +p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) = 0) = + p15_intake_detail(t,iso,kfo) + 1e-6; + *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** *' If projected food intake is below minimum, it is increased it to meet @@ -421,7 +429,7 @@ display i15_rec_EATLancet; ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) ) = (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"min")) + * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) ; *** Maximum recommendations *** @@ -432,7 +440,7 @@ display i15_rec_EATLancet; ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) ) = (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo),i15_rec_EATLancet(iso,EAT_mtargets15,"max")) + * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) ; *** Special case: Fruits, vegetables and nuts *** From 791c26b3889efba84a98d501dd8b0b4c8c9e8445 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 13 Dec 2023 13:38:58 +0100 Subject: [PATCH 067/187] bugfix of too many ) --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index d838e8afab..4953fb7b1c 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -413,11 +413,11 @@ display i15_rec_EATLancet; *i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); *' For cases where the intake in a EAT-Lancet food group is zero for a country -*' in a particular time step, a small amount is added to ensure no division by +*' in a particular time step, a small amount is added to ensure no division by *' zero. This way, all kfo-items in the respective food group are corrected by *' the same amount. p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), - sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) = 0) = + sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; *' The intake target is adjusted to meet the EAT-Lancet recommendations From 0be1aa211ea89dac40ef9c4dcad405c86349dadf Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 08:49:27 +0100 Subject: [PATCH 068/187] splitting cassav_sp category in starchy fruits and roots --- config/default.cfg | 8 +- .../15_food/anthro_iso_jun22/declarations.gms | 8 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 89 ++++++++++--------- modules/15_food/anthro_iso_jun22/input.gms | 4 +- modules/15_food/anthro_iso_jun22/presolve.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 69 +++----------- modules/15_food/input/files | 2 +- scripts/start/projects/project_EAT2p0.R | 1 + 8 files changed, 74 insertions(+), 109 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 5304dbeb84..a115b9e681 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.95_h12_magpie.tgz", - cellular = "rev4.95_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.95_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS1_rev4.95EL2__h12_magpie.tgz", + cellular = "rev4.95EL2__h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.95EL2__h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") @@ -1274,7 +1274,7 @@ cfg$gms$c50_scen_neff_noselect <- "baseeff_add3_add5_add10_max65" # def = base # * For pastures, only two scenarios exist: a constant scenario, and one where # * the minimum NUE increases to 55,60 and 65% for 2020,2050 and 2100, to avoid -# * that pastures which dont have a nutrient deficit are fertilized +# * that pastures which do not have a nutrient deficit are fertilized # * (historical NUE may be low despite no fertilization) # * Options: # * constant, constant_min55_min60_min65 diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 28828dfb2f..3596b74d90 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -155,10 +155,14 @@ parameters i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others food category (1) - i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others food category for an exogenous diet scenario (1) + i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) + i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories for an exogenous diet scenario (1) + p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) + p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) + i15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 4953fb7b1c..712109de02 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -174,7 +174,7 @@ if (s15_run_diet_postprocessing = 1, p15_intake_detail(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo) / f15_overcons_FAOwaste(iso,kfo); p15_intake_detail(t,iso,kfo)$(sum(kfo2, p15_intake_detail(t,iso,kfo2))<>0) = - p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2))* + p15_intake_detail(t,iso,kfo) / sum(kfo2, p15_intake_detail(t,iso,kfo2)) * p15_intake_total(t,iso); * To avoid negative waste, we reduce intake where it exceed food availabiltiy @@ -308,8 +308,8 @@ $elseif "%c15_kcal_scen%" == "endo" $else i15_intake_scen_target(t,iso) = sum(kfo,i15_intake_EATLancet_all(iso,"%c15_kcal_scen%","%c15_EAT_scen%",kfo)); - p15_bmi_shr_target(t,iso,sex,age,bmi_group15)=0; - p15_bmi_shr_target(t,iso,sex,age,"medium")=1; + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) = 0; + p15_bmi_shr_target(t,iso,sex,age,"medium") = 1; $endif *' The intake target is adjusted to meet the calorie target @@ -395,27 +395,12 @@ elseif (s15_exo_diet = 3), *' Where maximum target is not exceeded, total scenario food intake is assigned *' to EAT-Lancet recommendation i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); -*** ISABELLE: Why does the i15_rec_EATLancet have to be overwritten, though? - -*' It is, however, switched off for roots, since they will, as staples, -*' later be treated as balancing post to meet total calorie intake: - i15_rec_EATLancet(iso,"t_roots","max") = i15_intake_scen_target(t,iso); -*** ISABELLE: Why are roots and staples used as balancing post? Roots has a target... -*** Also: discuss with Isabelle and Benni about splitting the roots target into potatos and cassav_sp (see Marcos distinction between starchy_fruits and roots) - -display i15_rec_EATLancet; - -*** ISABELLE/BENNI: I think this is not required anymore (food waste calculations have changed since then) -** Use p15_intake_detail(t,iso,kfo) instead? -* The parameter p15_intake_detailed_regr doesn't exist anymore in this realization. -*p15_intake_detailed_regr(t,i,kfo) = p15_kcal_pc_calibrated(t,i,kfo) -* / (i15_calib_fsupply(i) * i15_demand2intake_detailed_ref(i,kfo) * p15_foodwaste_growth(t,i)); -*i15_intake_detailed_scen_target(t,iso,kfo) = p15_intake_detailed_regr(t,i,kfo); - -*' For cases where the intake in a EAT-Lancet food group is zero for a country -*' in a particular time step, a small amount is added to ensure no division by -*' zero. This way, all kfo-items in the respective food group are corrected by -*' the same amount. +*** JAN: Should i15_rec_EATLancet be p15_rec_EATLancet then? + +* For cases where the intake in a EAT-Lancet food group is zero for a country +* in a particular time step, a small amount is added to ensure no division by +* zero. This way, all kfo-items in the respective food group are corrected by +* the same amount. p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; @@ -444,28 +429,51 @@ p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), ; *** Special case: Fruits, vegetables and nuts *** -*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category. +*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category; +*' and bananas and plantains are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) -*' of fruits and vegetables in this aggregate category +*' of fruits and vegetables in this aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t,iso); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); else - i15_fruitveg2others_kcal_ratio(t,iso) = f15_fruitveg2others_kcal_ratio(t-1,iso); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); ); -display i15_fruitveg2others_kcal_ratio; +*' Separation of starchy fruits (bananas and plantains) +*' and roots (cassava, sweet potato, yams) in the cassav_sp food category +p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); +p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); + +*' Maximum recommendation for starchy fruits: +i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) + = i15_rec_EATLancet(iso,"t_fruitstarch","max"); + +*' Maximum recommendation for roots: +i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = i15_rec_EATLancet(iso,"t_roots","max"); + +i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + +i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = + p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - + i15_intake_detailed_scen_target(t,iso,"potato") + + p15_intake_detail_starchyfruit(t,iso); -*' This ratio is used to split the 'others' category into fruits plus vegetables -*' and those nuts and seeds that are not included in rapeseed, groundnut and sunflower -*****BENNI/ISABELLE: Are groundnuts nuts or pulses in the end? Or should they be anyway be a separate target (peanuts) - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso) * p15_intake_detail(t,iso,"others"); - p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso)) * p15_intake_detail(t,iso,"others"); +*' Split the 'others' category into fruits plus vegetables +*' and those nuts and seeds that are not included in rapeseed and sunflower + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + p15_intake_detail_starchyfruit(t,iso); + p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); *' Minimum recommendation for fruits and vegetables: i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) = i15_rec_EATLancet(iso,"t_fruitveg","min"); +*' Extract fruits and vegetables that are part of others categroy +* Note that starchy fruits are kept at the previously assigned maximum level +* and their amount has been added to cassav_sp already. + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso); *' Minimum recommendation for nuts *' (a) nuts and seeds that are included in "others" @@ -474,8 +482,7 @@ display i15_fruitveg2others_kcal_ratio; = (p15_intake_detail_nsothers(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; -*' (b) for rapeseed, groundnut, sunflower: -*** BENNI/ISABELLE: where to put groundnuts? separate? +*' (b) for rapeseed, sunflower: i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso))) @@ -484,9 +491,6 @@ display i15_fruitveg2others_kcal_ratio; *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nsothers(t,iso); -* Update of the ratio of fruits and vegetables within the "others" category: - i15_fruitveg2others_kcal_ratio_scen(t,iso)$(i15_intake_detailed_scen_target(t,iso,"others") > 0) - = i15_intake_detailed_scen_fruitveg(t,iso) / i15_intake_detailed_scen_target(t,iso,"others"); * Food commodities that are not included in diet recommendations are set to zero: i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; @@ -504,8 +508,11 @@ display i15_fruitveg2others_kcal_ratio; ***** Should it be done the same way in both? (Should it be taken out of the if-condition (applied to both)?) *** Balancing calorie requirements *** -*' After all calorie recommendations for non-staple food groups are satisfied, intake of staple crops is -*' now modified such that the in step 1.) selected total calorie intake is met: +*' After all calorie recommendations for non-staple food groups are satisfied, +*' intake of staple crops is now modified such that the +*' in step 1.) selected total calorie intake is met. +*' Note that brans do not have an EAT Lancet target and are kept at their +*' original level. i15_intake_detailed_scen_target(t,iso,EAT_staples) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index c1ed29dede..ee21df3034 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -256,9 +256,9 @@ $ondelim $include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" $offdelim; -table f15_fruitveg2others_kcal_ratio(t_all,iso) Ratio of calories from fruits and vegetables within the others food category (1) +table f15_fruitveg2others_kcal_ratio(t_all,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) $ondelim -$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.csv" +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.cs3" $offdelim; * This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions diff --git a/modules/15_food/anthro_iso_jun22/presolve.gms b/modules/15_food/anthro_iso_jun22/presolve.gms index 2606232578..8f422f32d7 100644 --- a/modules/15_food/anthro_iso_jun22/presolve.gms +++ b/modules/15_food/anthro_iso_jun22/presolve.gms @@ -317,7 +317,7 @@ $include "./modules/15_food/anthro_iso_jun22/exodietmacro.gms"; * some calculations for postprocessing and other modules p15_kcal_pc_initial_iso(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); pm_kcal_pc_initial(t,i,kfo) = p15_kcal_pc(t,i,kfo); -o15_kcal_regr_initial(t,iso,kfo)=v15_kcal_regr.l(iso,kfo); +o15_kcal_regr_initial(t,iso,kfo) = v15_kcal_regr.l(iso,kfo); *' @stop diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 19c01fff13..dbcb26bfeb 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -110,13 +110,10 @@ sets / oils,alcohol,sugar / kfo_ns(kfo) Food products that can be counted towards nuts and nuts_seeds - / rapeseed, groundnut, sunflower / -** BENNI/ISABELLE: Where should groundnut be counted towards? + / rapeseed, sunflower / kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation - / sugr_cane, sugr_beet, molasses, alcohol, scp / -** Note: To Do: attribute sugr_cane, sugr_bee, molasses to sugar -* ISABELLE: What about brans? + / sugr_cane, sugr_beet, molasses, alcohol / knf(kall) Non-food products in the sectoral version / oilpalm,cottn_pro,foddr, pasture, begr, betr, @@ -181,17 +178,11 @@ sets / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses / soybean, puls_pro, groundnut / -** BENNI: are groundnuts nuts or pulses? -** also note: peanuts (=groundnut?) has actually a single target (shouldn't we separate it?) EAT_sugar15(kfo) sugar / sugr_cane, sugr_beet, sugar, molasses / EAT_staples(kfo) All staple food products according to EAT Lancet definition - / tece, maiz, trce, rice_pro, potato, cassav_sp / -*** ISABELLE/BENNI/MARCO: Should potato and cassav_sp be included in staples (balancing post?) -* Alternatively: -*EAT_starch(kfo) Food group starch as of EAT -* / tece, maiz, trce, rice_pro / + / tece, maiz, trce, rice_pro / EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition / soybean, rapeseed, groundnut, sunflower, puls_pro, sugr_cane, sugr_beet, @@ -199,69 +190,31 @@ sets livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / -* Food groups for Marco's diet model (my suggestion) -* EAT_starch(kfo) Food group starch as of EAT --> different from EAT_staples (see above) -* / tece, maiz, trce, rice_pro / -* EAT_soybeans(kfo) Soybeans as of EAT --> not new set definition required -* / soybean / -* EAT_nutsseeds(kfo) Food group of nuts and seeds as of EAT -* / rapeseed, groundnut, sunflower / -**** BENNI: Is groundnut nuts or pulses? -* EAT_legumes(kfo) Legumes as of EAT -* / puls_pro / -* EAT_roots(kfo) Food group of roots as of EAT -* / potato, cassav_sp / -* EAT_sugar15(kfo) Sugar as of EAT --> same as in above code, but different from Isabelle's -* / sugr_cane, sugr_beet, sugar, molasses / -* EAT_redmeat(kfo) Food group of red meat as of EAT target -* / livst_rum, livst_pig / -* EAT_poultry(kfo) EAT target food group poultry ---> for 1:1 product, no extra set necessary -* / livst_chick / -* EAT_eggs(kfo) EAT target food group eggs ---> for 1:1 product, no extra set necessary -* / livst_egg / -* EAT_milk(kfo) EAT target food group milk -* / livst_milk / -* EAT_fish(kfo) EAT target food group fish -* / fish / -* EAT_fruits --> common target for fruits and vegetables? (just add up?) -* EAT_vegetables --> common target for fruits and vegetables? (just add up?) -* For others: check how Isabelle solved this (separation of nuts from other (based on FAO)) -* Where should oils, alcohol, brans, scp be attributed to? -* For oils (same problem!): just combine oil_palm and oil_veg to one target? (how did Isabelle solve this?) -* scp -> redmeat? -* for brans -> keep regression value? -* alcohol: 0 or default value (Lassen et al.)? - - * Isabelle's code: EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations / min, max / EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined - / t_nutseeds, t_fruitveg, + / t_nutseeds, t_fruitveg, t_fruitstarch, t_roots, t_redmeat, - t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible / t_roots, t_redmeat, - t_puls_pro, t_soybean, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + +EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio + / cassav_sp, others / EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories -* ISABELLE: Where are groundnuts? (peanuts have separate target. should we add it?) -* - / t_roots . (potato, cassav_sp) -* Note: To Do: split roots target because cassav_sp contains bananas/plantains (see Marco's model: starchy fruits) - t_redmeat . (livst_rum, livst_pig) - t_puls_pro . (puls_pro) - t_soybean . (soybean) + / t_redmeat . (livst_rum, livst_pig, scp) + t_legumes . (puls_pro, groundnut, soybean) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) t_livst_milk . (livst_milk) t_sugar . (sugar) -* Note: To Do: add sugr_cane, sugr_beet, molasses t_oils . (oils) -* Note: To Do: double check whether the oils target contains oil_palm and oil_veg / ; diff --git a/modules/15_food/input/files b/modules/15_food/input/files index 1fa6f16081..3a2b8735ad 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -21,7 +21,7 @@ f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 f15_targets_EATLancet_iso.cs3 -f15_fruitveg2others_kcal_ratio_iso.csv +f15_fruitveg2others_kcal_ratio_iso.cs3 f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 016fee17e1..0e3982d443 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -79,6 +79,7 @@ bau <- function(cfg) { # Globally achieves EL2 diet by 2050 # To Do: Check implementation diet <- function(cfg) { cfg$gms$s15_exo_diet <- 1 # To Do: switch to 3 once implementation is ready + cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) return(cfg) From 9b30b182099d146594e160b99220dcb414946549 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 09:10:49 +0100 Subject: [PATCH 069/187] bugfix dimension mismatch in fruitveg2others ratio --- modules/15_food/anthro_iso_jun22/declarations.gms | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 3596b74d90..88122ba32f 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -155,8 +155,7 @@ parameters i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) - i15_fruitveg2others_kcal_ratio_scen(t,iso) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories for an exogenous diet scenario (1) + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) From 60122c0d573a5a5874bad6e89ac903203f4300e2 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 13:03:19 +0100 Subject: [PATCH 070/187] bugfix of starchyfruit --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 712109de02..1087375229 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -458,11 +458,11 @@ i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - i15_intake_detailed_scen_target(t,iso,"potato") + - p15_intake_detail_starchyfruit(t,iso); + i15_intake_detailed_scen_starchyfruit(t,iso); *' Split the 'others' category into fruits plus vegetables *' and those nuts and seeds that are not included in rapeseed and sunflower - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + p15_intake_detail_starchyfruit(t,iso); + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); @@ -473,7 +473,7 @@ i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,is *' Extract fruits and vegetables that are part of others categroy * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso); + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts *' (a) nuts and seeds that are included in "others" From d29556a158cdbefa687b929622db7f993cab6ae0 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 20 Dec 2023 13:30:19 +0100 Subject: [PATCH 071/187] bugfix wrong staples definition with new cassava treatment in new implementation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 1087375229..763b32f0ca 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -375,7 +375,7 @@ if (s15_exo_diet = 1, ); i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) ; diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index dbcb26bfeb..d04b7c2d73 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -183,12 +183,19 @@ sets EAT_staples(kfo) All staple food products according to EAT Lancet definition / tece, maiz, trce, rice_pro / - EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition + + EAT_nonstaples_old(kfo) All non-staple food products according to EAT Lancet definition / soybean, rapeseed, groundnut, sunflower, puls_pro, sugr_cane, sugr_beet, oils, sugar, molasses, alcohol, brans, scp, livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / + EAT_nonstaples(kfo) All non-staple food products according to EAT Lancet definition + / soybean, rapeseed, groundnut, sunflower, puls_pro, potato, cassav_sp, + sugr_cane, sugr_beet, + oils, sugar, molasses, alcohol, brans, scp, + livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, + others / * Isabelle's code: EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations From 9a6ccd5f452d1e77d89718409add06a8ad0c0ed7 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 22 Dec 2023 11:02:51 +0100 Subject: [PATCH 072/187] update bioen+ghg price --- config/default.cfg | 6 ++--- main.gms | 24 +++++++++---------- modules/56_ghg_policy/price_aug22/sets.gms | 15 ++++++++++++ .../60_bioenergy/1stgen_priced_dec18/sets.gms | 15 ++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 169cbabd5f..79c0faf107 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.95_h12_magpie.tgz", - cellular = "rev4.95_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.95_h12_validation.tgz", +cfg$input <- c(regional = "rev4.96_h12_magpie.tgz", + cellular = "rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/main.gms b/main.gms index dd73db9181..6e0178ebe5 100644 --- a/main.gms +++ b/main.gms @@ -148,17 +148,17 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * -* Used data set: rev4.94_h12_magpie.tgz -* md5sum: 25623b5ad3e8b72bd3008da9b69adfe0 -* Repository: /p/projects/rd3mod/inputdata/output +* Used data set: rev4.96_h12_magpie.tgz +* md5sum: NA +* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output * -* Used data set: rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz -* md5sum: d7800a0ffe271483116a8f00a939a89a -* Repository: /p/projects/rd3mod/inputdata/output +* Used data set: rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* md5sum: NA +* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output * -* Used data set: rev4.94_h12_validation.tgz -* md5sum: 4b4128910822cf45603cab46f45ccf78 -* Repository: /p/projects/rd3mod/inputdata/output +* Used data set: rev4.96_h12_validation.tgz +* md5sum: NA +* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output * * Used data set: additional_data_rev4.46.tgz * md5sum: NA @@ -179,11 +179,11 @@ $title magpie * * Regionscode: 62eff8f7 * -* Regions data revision: 4.94 +* Regions data revision: 4.96 * * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.94 +* * Revision: 4.96 * * aggregation settings: * * Input resolution: 0.5 @@ -195,7 +195,7 @@ $title magpie * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * * -* Last modification (input data): Fri Nov 17 19:42:06 2023 +* Last modification (input data): Fri Dec 22 11:01:20 2023 * *###################### R SECTION END (VERSION INFO) ########################### diff --git a/modules/56_ghg_policy/price_aug22/sets.gms b/modules/56_ghg_policy/price_aug22/sets.gms index f64637e8cb..b4d84ff05e 100644 --- a/modules/56_ghg_policy/price_aug22/sets.gms +++ b/modules/56_ghg_policy/price_aug22/sets.gms @@ -41,6 +41,21 @@ sets R2M41-SSP2-Budg950, R2M41-SSP2-NDC, R2M41-SSP2-NPi, + R32M46-SDP_MC-NDC, + R32M46-SDP_MC-NPi, + R32M46-SDP_MC-PkBudg650, + R32M46-SSP1-NDC, + R32M46-SSP1-NPi, + R32M46-SSP1-PkBudg1050, + R32M46-SSP1-PkBudg650, + R32M46-SSP2EU-NDC, + R32M46-SSP2EU-NPi, + R32M46-SSP2EU-PkBudg1050, + R32M46-SSP2EU-PkBudg650, + R32M46-SSP5-NDC, + R32M46-SSP5-NPi, + R32M46-SSP5-PkBudg1050, + R32M46-SSP5-PkBudg650, SSPDB-SSP1-19-IMAGE, SSPDB-SSP1-19-REMIND-MAGPIE, SSPDB-SSP1-26-IMAGE, diff --git a/modules/60_bioenergy/1stgen_priced_dec18/sets.gms b/modules/60_bioenergy/1stgen_priced_dec18/sets.gms index e314b1648a..f392a212a4 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/sets.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/sets.gms @@ -41,6 +41,21 @@ sets R2M41-SSP2-Budg950, R2M41-SSP2-NDC, R2M41-SSP2-NPi, + R32M46-SDP_MC-NDC, + R32M46-SDP_MC-NPi, + R32M46-SDP_MC-PkBudg650, + R32M46-SSP1-NDC, + R32M46-SSP1-NPi, + R32M46-SSP1-PkBudg1050, + R32M46-SSP1-PkBudg650, + R32M46-SSP2EU-NDC, + R32M46-SSP2EU-NPi, + R32M46-SSP2EU-PkBudg1050, + R32M46-SSP2EU-PkBudg650, + R32M46-SSP5-NDC, + R32M46-SSP5-NPi, + R32M46-SSP5-PkBudg1050, + R32M46-SSP5-PkBudg650, SSPDB-SSP1-19-IMAGE, SSPDB-SSP1-19-REMIND-MAGPIE, SSPDB-SSP1-26-IMAGE, From 96790b8ff5c7dfdf49f3db11a8ccaae9dfa2f1d9 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 22 Dec 2023 11:17:32 +0100 Subject: [PATCH 073/187] update forestry settings --- CHANGELOG.md | 3 +++ config/default.cfg | 4 ++-- config/scenario_config.csv | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 500dba0be0..9c8520ee61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` +- **default.cfg and scenario_config.csv** Default for cfg$gms$c56_cprice_aff changed from `redd+natveg_nosoil` to `reddnatveg_nosoil`,i.e. timber plantations are excluded from carbon pricing by default +- **default.cfg** Default for cfg$gms$c56_emis_policy changed from `forestry_vegc` to `secdforest_vegc` +- **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` ### added - **32_forestry** new interfaces `vm_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` diff --git a/config/default.cfg b/config/default.cfg index 169cbabd5f..9fcc13fae4 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1441,7 +1441,7 @@ cfg$gms$s56_c_price_induced_aff <- 1 # def = on # * Options: forestry_vegc, primforest_vegc, secdforest_vegc # * This setting interacts with `c56_emis_policy`. # * If "forestry" is not included in `c56_emis_policy` (e.g. reddnatveg_nosoil), there will be no C-price driven afforestation unless `c56_cprice_aff` is changed to primforest_vegc or secdforest_vegc. -cfg$gms$c56_cprice_aff <- "forestry_vegc" # def = forestry_vegc +cfg$gms$c56_cprice_aff <- "secdforest_vegc" # def = secdforest_vegc # * C price expectation for afforestation decision-making in years # * 0 is myopic behaviour (only C price of current time step) @@ -1494,7 +1494,7 @@ cfg$gms$s56_limit_ch4_n2o_price <- 4000 # def = 4000 # * ecoSysProtAll_agMgmtExclN2O: (Above ground CO2 emis from LUC in forest, forestry, natveg; All types of emis from peatland; All CH4 emis, no further N2O emis) # * ecoSysProtAll_agMgmtExclCH4: (Above ground CO2 emis from LUC in forest, forestry, natveg; All types of emis from peatland; All N2O emis, no further CH4 emis) # * ecoSysProtAll_agMgmtOff: (Above ground CO2 emis from LUC in forest, forestry, natveg; All types of emis from peatland; No further CH4/N2O/other emis related to ag. management) -cfg$gms$c56_emis_policy <- "redd+natveg_nosoil" # def = redd+natveg_nosoil +cfg$gms$c56_emis_policy <- "reddnatveg_nosoil" # def = reddnatveg_nosoil # * CO2 emissions subject to carbon pricing # * options: actual, actualNoAcEst diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 0597b2f5ad..af88f78ea4 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -54,7 +54,7 @@ gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; gms$s56_buffer_aff;;;;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.5;0.2;0.3;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c56_emis_policy;;;;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+_nosoil;all_nosoil;;;;;;;redd+natveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c56_emis_policy;;;;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;redd_nosoil;all_nosoil;;;;;;;reddnatveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;; gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; @@ -69,10 +69,10 @@ gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;; gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;cc;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;;; gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;;; -gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; +gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;0;0;0;0;0;;;;;0;0;0;;;;;;;;;;;; gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;; gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; From a4d902bb6c15fe4440eac6c5f79c8abe749e0a4f Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 22 Dec 2023 11:19:41 +0100 Subject: [PATCH 074/187] bugfix --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c8520ee61..6f155cd4e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` -- **default.cfg and scenario_config.csv** Default for cfg$gms$c56_cprice_aff changed from `redd+natveg_nosoil` to `reddnatveg_nosoil`,i.e. timber plantations are excluded from carbon pricing by default -- **default.cfg** Default for cfg$gms$c56_emis_policy changed from `forestry_vegc` to `secdforest_vegc` +- **default.cfg and scenario_config.csv** Default for cfg$gms$c56_emis_policy changed from `redd+natveg_nosoil` to `reddnatveg_nosoil`,i.e. timber plantations are excluded from carbon pricing by default +- **default.cfg** Default for cfg$gms$c56_cprice_aff changed from `forestry_vegc` to `secdforest_vegc` - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` ### added From 077cf0d6018fcf2df2cd074931fd1e73103f2978 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 22 Dec 2023 16:53:42 +0100 Subject: [PATCH 075/187] update --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 79c0faf107..cb4f87ac6e 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -25,7 +25,7 @@ cfg$model <- "main.gms" #def = "main.gms" cfg$input <- c(regional = "rev4.96_h12_magpie.tgz", cellular = "rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.96_h12_validation.tgz", - additional = "additional_data_rev4.46.tgz", + additional = "additional_data_rev4.47.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data From 94d77642f65cac2e75544f36204789d765fe82cd Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 31 Dec 2023 12:20:54 +0100 Subject: [PATCH 076/187] update highres --- scripts/output/extra/highres.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index 60083fafff..63b1843c92 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -39,7 +39,7 @@ source("scripts/start_functions.R") highres <- function(cfg) { #lock the model folder - lockId <- gms::model_lock(timeout1 = 1) + lockId <- gms::model_lock(timeout1 = 24) withr::defer(gms::model_unlock(lockId)) if(any(!(modelstat(gdx) %in% c(2,7)))) stop("Modelstat different from 2 or 7 detected") @@ -47,7 +47,7 @@ highres <- function(cfg) { cfg$output <- cfg$output[cfg$output!="extra/highres"] # set high resolution, available options are c1000 and c2000 - res <- "c1000" + res <- "c2000" # search for matching high resolution file in repositories # pattern: "rev4.65_h12_*_cellularmagpie_c2000_MRI-ESM2-0-ssp370_lpjml-3eb70376.tgz" @@ -145,6 +145,12 @@ highres <- function(cfg) { cfg$gms$optimization <- "nlp_par" cfg$gms$s15_elastic_demand <- 0 + #get exogenous bioenergy demand and GHG prices from c200 run because these files may have been overwritten + write.magpie(readGDX(gdx,"f56_pollutant_prices_coupling"),"modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3") + write.magpie(readGDX(gdx,"f56_pollutant_prices_emulator"),"modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") + write.magpie(readGDX(gdx,"f60_bioenergy_dem_coupling"),"modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv") + write.magpie(readGDX(gdx,"f60_bioenergy_dem_emulator"),"modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv") + #get regional afforestation patterns from low resolution run with c200 aff <- dimSums(landForestry(gdx)[,,c("aff","ndc")],dim=3) #Take away initial NDC area for consistency with global afforestation limit From df96254e31e76bff59a569ba98e0d1be2116b577 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 2 Jan 2024 11:07:27 +0100 Subject: [PATCH 077/187] rev back to c1000 --- scripts/output/extra/highres.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index 63b1843c92..a048be56b2 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -47,7 +47,7 @@ highres <- function(cfg) { cfg$output <- cfg$output[cfg$output!="extra/highres"] # set high resolution, available options are c1000 and c2000 - res <- "c2000" + res <- "c1000" # search for matching high resolution file in repositories # pattern: "rev4.65_h12_*_cellularmagpie_c2000_MRI-ESM2-0-ssp370_lpjml-3eb70376.tgz" From 4d622ed078e21aa7d3c2f7c65aef9929d77edb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Tue, 2 Jan 2024 12:26:45 +0100 Subject: [PATCH 078/187] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f155cd4e3..8e1dc62971 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **default.cfg and scenario_config.csv** Default for cfg$gms$c56_emis_policy changed from `redd+natveg_nosoil` to `reddnatveg_nosoil`,i.e. timber plantations are excluded from carbon pricing by default - **default.cfg** Default for cfg$gms$c56_cprice_aff changed from `forestry_vegc` to `secdforest_vegc` - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` +- **scenario_config.csv** removed erroneous setting `cc` from column `input` ### added - **32_forestry** new interfaces `vm_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` From 795f0e08a54c5097f2db8bdfb7fe55e465381ab7 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 3 Jan 2024 09:58:38 +0100 Subject: [PATCH 079/187] update bioen and ghg prices --- CHANGELOG.md | 4 ++ config/default.cfg | 50 +++++++++++++------ main.gms | 6 +-- modules/56_ghg_policy/price_aug22/input.gms | 4 +- modules/56_ghg_policy/price_aug22/preloop.gms | 2 + modules/56_ghg_policy/price_aug22/sets.gms | 5 +- .../1stgen_priced_dec18/input.gms | 4 +- .../1stgen_priced_dec18/preloop.gms | 4 +- 8 files changed, 54 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e1dc62971..b9f0fd781c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,10 +15,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **default.cfg** Default for cfg$gms$c56_cprice_aff changed from `forestry_vegc` to `secdforest_vegc` - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` - **scenario_config.csv** removed erroneous setting `cc` from column `input` +- **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` +- **default.cfg** update input data to rev 4.96 ### added - **32_forestry** new interfaces `vm_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` - **scripts** added peatland to output/extra/disaggregation.R +- **56_ghg_policy_** added new trajectories for R32M46 +- **60_bioenergy** added new trajectories for R32M46 ### removed - **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. diff --git a/config/default.cfg b/config/default.cfg index d6bb6f970c..897553e379 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1357,18 +1357,27 @@ cfg$gms$s56_cprice_red_factor <- 1 # def = 1 # * GHG emission price scenario # * Note: For best consistency it is recommended to use trajectories from the most recent -# * coupled REMIND-MAgPIE runs. Currently, this is R21M42. -# * Note on available scenarios from coupled REMIND-MAgPIE runs -# * NPi: Current policies; above 3.0°C in 2100 +# * coupled REMIND-MAgPIE runs. Currently, this is R32M46. +# * Available options: +# * none: no 2nd generation bioenergy demand +# * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2 and MAgPIE 4.6 +# * NPi: Current policies; above 3.0°C in 2100 +# * NDC: ? +# * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 +# * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 +# * R32M46-SDP_MC-NPi, R32M46-SDP_MC-NDC, R32M46-SDP_MC-PkBudg650, +# * R32M46-SSP1-NPi, R32M46-SSP1-NDC, R32M46-SSP1-PkBudg1050, R32M46-SSP1-PkBudg650, +# * R32M46-SSP2-NPi, R32M46-SSP2-NDC, R32M46-SSP2-PkBudg1050, R32M46-SSP2-PkBudg650, +# * R32M46-SSP5-NPi, R32M46-SSP5-NDC, R32M46-SSP5-PkBudg1050, R32M46-SSP5-PkBudg650, +# * R21M42: Coupled REMIND-MAgPIE runs with REMIND 2.1 and MAgPIE 4.2 +# * NPi: Current policies; above 3.0°C in 2100 # * PkBudg900: Budget with 900 GtCO2; well-below 1.5°C in 2100 (PkBudg1000 for SDP) # * PkBudg1300: Budget with 1300 GtCO2; well-below 2.0°C in 2100 -# * -# * Available scenarios: -# * Coupled REMIND-MAgPIE runs # * R21M42-SDP-NPi, R21M42-SDP-PkBudg1000, R21M42-SDP-PkBudg1100, R21M42-SDP-PkBudg900, # * R21M42-SSP1-NPi, R21M42-SSP1-PkBudg1100, R21M42-SSP1-PkBudg1300, R21M42-SSP1-PkBudg900, # * R21M42-SSP2-NPi, R21M42-SSP2-PkBudg1100, R21M42-SSP2-PkBudg1300, R21M42-SSP2-PkBudg900, # * R21M42-SSP5-NPi, R21M42-SSP5-PkBudg1100, R21M42-SSP5-PkBudg1300, R21M42-SSP5-PkBudg900, +# * R2M41: Coupled REMIND-MAgPIE runs with REMIND 2.0 and MAgPIE 4.1 # * R2M41-SSP2-NPi, R2M41-SSP2-NDC, R2M41-SSP2-Budg1300, R2M41-SSP2-Budg600, R2M41-SSP2-Budg950 # * Standalone REMIND runs from Strefler et al 2021; well-below 2.0°C in 2100 # * https://www.nature.com/articles/s41467-021-22211-2 @@ -1405,8 +1414,8 @@ cfg$gms$s56_cprice_red_factor <- 1 # def = 1 # * c56_pollutant_prices_noselect applies to all other countries. # * Available scenarios for c56_pollutant_prices_noselect are identical to c56_pollutant_prices # * (see above) except for emulator and coupling (which can only be chosen for c56_pollutant_prices) -cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" # def = R21M42-SSP2-NPi -cfg$gms$c56_pollutant_prices_noselect <- "R21M42-SSP2-NPi" # def = R21M42-SSP2-NPi +cfg$gms$c56_pollutant_prices <- "R32M46-SSP2EU-NPi" # def = R32M46-SSP2EU-NPi +cfg$gms$c56_pollutant_prices_noselect <- "R32M46-SSP2EU-NPi" # def = R32M46-SSP2EU-NPi # * The following two settings can be used to provide exogenous ghg prices # * via a file that is not part of the input data. This is currently used @@ -1607,18 +1616,27 @@ cfg$gms$c60_1stgen_biodem <- "const2020" # def = const2020 # * 2nd generation bioenergy demand scenario # * Note: For best consistency it is recommended to use trajectories from the most recent -# * coupled REMIND-MAgPIE runs. Currently, this is R21M42. -# * Note on available scenarios from coupled REMIND-MAgPIE runs -# * NPi: Current policies; above 3.0°C in 2100 +# * coupled REMIND-MAgPIE runs. Currently, this is R32M46. +# * Available options: +# * none: no 2nd generation bioenergy demand +# * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2 and MAgPIE 4.6 +# * NPi: Current policies; above 3.0°C in 2100 +# * NDC: ? +# * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 +# * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 +# * R32M46-SDP_MC-NPi, R32M46-SDP_MC-NDC, R32M46-SDP_MC-PkBudg650, +# * R32M46-SSP1-NPi, R32M46-SSP1-NDC, R32M46-SSP1-PkBudg1050, R32M46-SSP1-PkBudg650, +# * R32M46-SSP2-NPi, R32M46-SSP2-NDC, R32M46-SSP2-PkBudg1050, R32M46-SSP2-PkBudg650, +# * R32M46-SSP5-NPi, R32M46-SSP5-NDC, R32M46-SSP5-PkBudg1050, R32M46-SSP5-PkBudg650, +# * R21M42: Coupled REMIND-MAgPIE runs with REMIND 2.1 and MAgPIE 4.2 +# * NPi: Current policies; above 3.0°C in 2100 # * PkBudg900: Budget with 900 GtCO2; well-below 1.5°C in 2100 (PkBudg1000 for SDP) # * PkBudg1300: Budget with 1300 GtCO2; well-below 2.0°C in 2100 -# * -# * Available scenarios: -# * Coupled REMIND-MAgPIE runs # * R21M42-SDP-NPi, R21M42-SDP-PkBudg1000, R21M42-SDP-PkBudg1100, R21M42-SDP-PkBudg900, # * R21M42-SSP1-NPi, R21M42-SSP1-PkBudg1100, R21M42-SSP1-PkBudg1300, R21M42-SSP1-PkBudg900, # * R21M42-SSP2-NPi, R21M42-SSP2-PkBudg1100, R21M42-SSP2-PkBudg1300, R21M42-SSP2-PkBudg900, # * R21M42-SSP5-NPi, R21M42-SSP5-PkBudg1100, R21M42-SSP5-PkBudg1300, R21M42-SSP5-PkBudg900, +# * R2M41: Coupled REMIND-MAgPIE runs with REMIND 2.0 and MAgPIE 4.1 # * R2M41-SSP2-NPi, R2M41-SSP2-NDC, R2M41-SSP2-Budg1300, R2M41-SSP2-Budg600, R2M41-SSP2-Budg950 # * Standalone REMIND runs from Strefler et al 2021; well-below 2.0°C in 2100 # * https://www.nature.com/articles/s41467-021-22211-2 @@ -1653,8 +1671,8 @@ cfg$gms$c60_1stgen_biodem <- "const2020" # def = const2020 # * coupling # * Note: c60_2ndgen_biodem applies to countries selected in scen_countries60 # * c60_2ndgen_biodem_noselect applies to all other countries. -cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # def = R21M42-SSP2-NPi -cfg$gms$c60_2ndgen_biodem_noselect <- "R21M42-SSP2-NPi" # def = R21M42-SSP2-NPi +cfg$gms$c60_2ndgen_biodem <- "R32M46-SSP2EU-NPi" # def = R32M46-SSP2EU-NPi +cfg$gms$c60_2ndgen_biodem_noselect <- "R32M46-SSP2EU-NPi" # def = R32M46-SSP2EU-NPi # * The following setting can be used to provide exogenous bioenergy demand # * via a .mif file that is not part of the input data. This is currently used diff --git a/main.gms b/main.gms index 6e0178ebe5..68a82959c5 100644 --- a/main.gms +++ b/main.gms @@ -160,9 +160,9 @@ $title magpie * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output * -* Used data set: additional_data_rev4.46.tgz +* Used data set: additional_data_rev4.47.tgz * md5sum: NA -* Repository: https://rse.pik-potsdam.de/data/magpie/public +* Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive * * Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz * md5sum: NA @@ -195,7 +195,7 @@ $title magpie * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * * -* Last modification (input data): Fri Dec 22 11:01:20 2023 +* Last modification (input data): Fri Dec 22 16:58:47 2023 * *###################### R SECTION END (VERSION INFO) ########################### diff --git a/modules/56_ghg_policy/price_aug22/input.gms b/modules/56_ghg_policy/price_aug22/input.gms index fdb5290128..92697d0b8a 100644 --- a/modules/56_ghg_policy/price_aug22/input.gms +++ b/modules/56_ghg_policy/price_aug22/input.gms @@ -48,8 +48,8 @@ scalars s56_offset helper for C price interpolation (1) / 0 / ; -$setglobal c56_pollutant_prices R21M42-SSP2-NPi -$setglobal c56_pollutant_prices_noselect R21M42-SSP2-NPi +$setglobal c56_pollutant_prices R32M46-SSP2EU-NPi +$setglobal c56_pollutant_prices_noselect R32M46-SSP2EU-NPi $setglobal c56_emis_policy redd+natveg_nosoil $setglobal c56_cprice_aff forestry_vegc $setglobal c56_mute_ghgprices_until y2030 diff --git a/modules/56_ghg_policy/price_aug22/preloop.gms b/modules/56_ghg_policy/price_aug22/preloop.gms index ec4d512a9a..9ec7f69d82 100644 --- a/modules/56_ghg_policy/price_aug22/preloop.gms +++ b/modules/56_ghg_policy/price_aug22/preloop.gms @@ -26,6 +26,8 @@ $ifthen "%c56_pollutant_prices%" == "coupling" im_pollutant_prices(t_all,i,pollutants,emis_source) = f56_pollutant_prices_coupling(t_all,i,pollutants); $elseif "%c56_pollutant_prices%" == "emulator" im_pollutant_prices(t_all,i,pollutants,emis_source) = f56_pollutant_prices_emulator(t_all,i,pollutants); +$elseif "%c56_pollutant_prices%" == "none" + im_pollutant_prices(t_all,i,pollutants,emis_source) = 0; $else im_pollutant_prices(t_all,i,pollutants,emis_source) = f56_pollutant_prices(t_all,i,pollutants,"%c56_pollutant_prices%") * p56_region_price_shr(t_all,i) + f56_pollutant_prices(t_all,i,pollutants,"%c56_pollutant_prices_noselect%") * (1-p56_region_price_shr(t_all,i)); diff --git a/modules/56_ghg_policy/price_aug22/sets.gms b/modules/56_ghg_policy/price_aug22/sets.gms index b4d84ff05e..051ad91295 100644 --- a/modules/56_ghg_policy/price_aug22/sets.gms +++ b/modules/56_ghg_policy/price_aug22/sets.gms @@ -130,7 +130,10 @@ sets ecoSysProtOff, ecoSysProtAll_agMgmtExclN2O, ecoSysProtAll_agMgmtExclCH4, - ecoSysProtAll_agMgmtOff / + ecoSysProtAll_agMgmtOff, + co2_reddnatveg_nosoil, + co2_peatland, + co2_reddnatveg_nosoil_peatland / ; *######################### R SECTION END (SETS) ################################ diff --git a/modules/60_bioenergy/1stgen_priced_dec18/input.gms b/modules/60_bioenergy/1stgen_priced_dec18/input.gms index a27aa6b4ca..c71e5d7046 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/input.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/input.gms @@ -39,8 +39,8 @@ scalars s60_2ndgen_bioenergy_dem_min Minimum dedicated 2nd generation bioenergy demand assumed in each region (mio. GJ per yr) / 1 / ; -$setglobal c60_2ndgen_biodem R21M42-SSP2-NPi -$setglobal c60_2ndgen_biodem_noselect R21M42-SSP2-NPi +$setglobal c60_2ndgen_biodem R32M46-SSP2EU-NPi +$setglobal c60_2ndgen_biodem_noselect R32M46-SSP2EU-NPi $if "%c60_2ndgen_biodem%" == "coupling" table f60_bioenergy_dem_coupling(t_all,i) Bioenergy demand (regional) (mio. GJ per yr) diff --git a/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms b/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms index edd93ec225..6294749431 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms @@ -20,11 +20,13 @@ $ifthen "%c60_2ndgen_biodem%" == "coupling" i60_bioenergy_dem(t,i) = f60_bioenergy_dem_coupling(t,i); $elseif "%c60_2ndgen_biodem%" == "emulator" i60_bioenergy_dem(t,i) = f60_bioenergy_dem_emulator(t)/card(i); +$elseif "%c60_2ndgen_biodem%" == "none" + i60_bioenergy_dem(t,i) = 0; $else i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"%c60_2ndgen_biodem%") * p60_region_BE_shr(t,i) + f60_bioenergy_dem(t,i,"%c60_2ndgen_biodem_noselect%") * (1-p60_region_BE_shr(t,i)); ** Harmonize till 2020 if not coupled or emulator loop(t$(m_year(t) <= sm_fix_SSP2), - i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"R21M42-SSP2-NPi"); + i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"R32M46-SSP2EU-NPi"); ); $endif From c2ab8e235464babef751ba07e4149db358256d55 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 3 Jan 2024 10:01:50 +0100 Subject: [PATCH 080/187] update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9f0fd781c..a1ec4a7573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### fixed - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k +- **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs ## [4.7.0] - 2023-12-11 From 99fdb7fb4e40576966c62efecb8582e7d039f697 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 3 Jan 2024 17:15:37 +0100 Subject: [PATCH 081/187] scenario config --- config/scenario_config.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index af88f78ea4..14373e5f00 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -78,7 +78,7 @@ gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;; gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.95_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.95_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.95_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.95_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.95_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.95_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.96_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; From 98cdad9b5b1eee86cf257860332f3433ed99b875 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 3 Jan 2024 17:42:15 +0100 Subject: [PATCH 082/187] bugfix forestry --- .../32_forestry/dynamic_feb21/declarations.gms | 8 ++++---- modules/32_forestry/dynamic_feb21/equations.gms | 13 +++++++------ modules/32_forestry/dynamic_feb21/postsolve.gms | 16 ++++++++-------- modules/32_forestry/dynamic_feb21/presolve.gms | 1 - 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/32_forestry/dynamic_feb21/declarations.gms b/modules/32_forestry/dynamic_feb21/declarations.gms index 32047560ec..314a392b55 100644 --- a/modules/32_forestry/dynamic_feb21/declarations.gms +++ b/modules/32_forestry/dynamic_feb21/declarations.gms @@ -69,7 +69,7 @@ positive variables v32_land_missing(j) Forestry land which can be used at extrmemly high costs in case not enough area is available for new establishment (mio. ha) vm_landdiff_forestry Aggregated difference in forestry land compared to previous timestep (mio. ha) v32_cost_recur(i) Recurring forest management costs (USD per ha) - v32_land_expansion(j,type32,ac) Forestry land expansion (mio. ha) + v32_land_expansion(j,type32) Forestry land expansion (mio. ha) v32_land_reduction(j,type32,ac) Forestry land reduction (mio. ha) v32_cost_establishment(i) Cost of establishment calculated at the current time step (mio. USD) v32_hvarea_forestry(j,ac) Harvested area from timber plantations (mio. ha) @@ -99,7 +99,7 @@ equations q32_establishment_dynamic(i) Establishment in current time step for future demand (mio. ha) q32_establishment_dynamic_yield(i) Regional timber yield (tDM per ha) q32_establishment_fixed(j) Establishment in current time step for future demand (mio. ha) - q32_land_expansion(j,type32,ac) Land expansion (mio. ha) + q32_land_expansion(j,type32) Land expansion (mio. ha) q32_land_reduction(j,type32,ac) Land contraction (mio. ha) q32_cost_establishment(i) Present value of cost of establishment (mio. USD) q32_bgp_aff(j,ac) Biophysical afforestation calculation (mio. tCeq) @@ -122,7 +122,7 @@ parameters ov32_land_missing(t,j,type) Forestry land which can be used at extrmemly high costs in case not enough area is available for new establishment (mio. ha) ov_landdiff_forestry(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) ov32_cost_recur(t,i,type) Recurring forest management costs (USD per ha) - ov32_land_expansion(t,j,type32,ac,type) Forestry land expansion (mio. ha) + ov32_land_expansion(t,j,type32,type) Forestry land expansion (mio. ha) ov32_land_reduction(t,j,type32,ac,type) Forestry land reduction (mio. ha) ov32_cost_establishment(t,i,type) Cost of establishment calculated at the current time step (mio. USD) ov32_hvarea_forestry(t,j,ac,type) Harvested area from timber plantations (mio. ha) @@ -146,7 +146,7 @@ parameters oq32_establishment_dynamic(t,i,type) Establishment in current time step for future demand (mio. ha) oq32_establishment_dynamic_yield(t,i,type) Regional timber yield (tDM per ha) oq32_establishment_fixed(t,j,type) Establishment in current time step for future demand (mio. ha) - oq32_land_expansion(t,j,type32,ac,type) Land expansion (mio. ha) + oq32_land_expansion(t,j,type32,type) Land expansion (mio. ha) oq32_land_reduction(t,j,type32,ac,type) Land contraction (mio. ha) oq32_cost_establishment(t,i,type) Present value of cost of establishment (mio. USD) oq32_bgp_aff(t,j,ac,type) Biophysical afforestation calculation (mio. tCeq) diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index c2e9550776..fee1225023 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -60,7 +60,7 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( vm_land_forestry(j2,type32) =e= sum(ac, v32_land(j2,type32,ac)); q32_land_expansion_forestry(j2,type32) .. - vm_landexpansion_forestry(j2,type32) =e= sum(ac_est, v32_land_expansion(j2,type32,ac_est)); + vm_landexpansion_forestry(j2,type32) =e= v32_land_expansion(j2,type32); q32_land_reduction_forestry(j2,type32) .. vm_landreduction_forestry(j2,type32) =e= sum(ac_sub, v32_land_reduction(j2,type32,ac_sub)); @@ -95,12 +95,13 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( *' Forestry land expansion and reduction is calculated as follows: - q32_land_diff .. vm_landdiff_forestry =e= sum((j2,type32,ac), - v32_land_expansion(j2,type32,ac) - + v32_land_reduction(j2,type32,ac)); + q32_land_diff .. vm_landdiff_forestry =e= sum((j2,type32), + v32_land_expansion(j2,type32) + + sum(ac_sub, v32_land_reduction(j2,type32,ac_sub))); - q32_land_expansion(j2,type32,ac_est) .. - v32_land_expansion(j2,type32,ac_est) =e= v32_land(j2,type32,ac_est) - pc32_land(j2,type32,ac_est); + q32_land_expansion(j2,type32) .. + v32_land_expansion(j2,type32) =e= + sum(ac_est, v32_land(j2,type32,ac_est)) - sum(ac_est, pc32_land(j2,type32,ac_est)); q32_land_reduction(j2,type32,ac_sub) .. v32_land_reduction(j2,type32,ac_sub) =e= pc32_land(j2,type32,ac_sub) - v32_land(j2,type32,ac_sub); diff --git a/modules/32_forestry/dynamic_feb21/postsolve.gms b/modules/32_forestry/dynamic_feb21/postsolve.gms index 2b4ec5bd53..887e6b3e9f 100644 --- a/modules/32_forestry/dynamic_feb21/postsolve.gms +++ b/modules/32_forestry/dynamic_feb21/postsolve.gms @@ -16,7 +16,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_land_missing(t,j,"marginal") = v32_land_missing.m(j); ov_landdiff_forestry(t,"marginal") = vm_landdiff_forestry.m; ov32_cost_recur(t,i,"marginal") = v32_cost_recur.m(i); - ov32_land_expansion(t,j,type32,ac,"marginal") = v32_land_expansion.m(j,type32,ac); + ov32_land_expansion(t,j,type32,"marginal") = v32_land_expansion.m(j,type32); ov32_land_reduction(t,j,type32,ac,"marginal") = v32_land_reduction.m(j,type32,ac); ov32_cost_establishment(t,i,"marginal") = v32_cost_establishment.m(i); ov32_hvarea_forestry(t,j,ac,"marginal") = v32_hvarea_forestry.m(j,ac); @@ -40,7 +40,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_establishment_dynamic(t,i,"marginal") = q32_establishment_dynamic.m(i); oq32_establishment_dynamic_yield(t,i,"marginal") = q32_establishment_dynamic_yield.m(i); oq32_establishment_fixed(t,j,"marginal") = q32_establishment_fixed.m(j); - oq32_land_expansion(t,j,type32,ac,"marginal") = q32_land_expansion.m(j,type32,ac); + oq32_land_expansion(t,j,type32,"marginal") = q32_land_expansion.m(j,type32); oq32_land_reduction(t,j,type32,ac,"marginal") = q32_land_reduction.m(j,type32,ac); oq32_cost_establishment(t,i,"marginal") = q32_cost_establishment.m(i); oq32_bgp_aff(t,j,ac,"marginal") = q32_bgp_aff.m(j,ac); @@ -58,7 +58,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_land_missing(t,j,"level") = v32_land_missing.l(j); ov_landdiff_forestry(t,"level") = vm_landdiff_forestry.l; ov32_cost_recur(t,i,"level") = v32_cost_recur.l(i); - ov32_land_expansion(t,j,type32,ac,"level") = v32_land_expansion.l(j,type32,ac); + ov32_land_expansion(t,j,type32,"level") = v32_land_expansion.l(j,type32); ov32_land_reduction(t,j,type32,ac,"level") = v32_land_reduction.l(j,type32,ac); ov32_cost_establishment(t,i,"level") = v32_cost_establishment.l(i); ov32_hvarea_forestry(t,j,ac,"level") = v32_hvarea_forestry.l(j,ac); @@ -82,7 +82,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_establishment_dynamic(t,i,"level") = q32_establishment_dynamic.l(i); oq32_establishment_dynamic_yield(t,i,"level") = q32_establishment_dynamic_yield.l(i); oq32_establishment_fixed(t,j,"level") = q32_establishment_fixed.l(j); - oq32_land_expansion(t,j,type32,ac,"level") = q32_land_expansion.l(j,type32,ac); + oq32_land_expansion(t,j,type32,"level") = q32_land_expansion.l(j,type32); oq32_land_reduction(t,j,type32,ac,"level") = q32_land_reduction.l(j,type32,ac); oq32_cost_establishment(t,i,"level") = q32_cost_establishment.l(i); oq32_bgp_aff(t,j,ac,"level") = q32_bgp_aff.l(j,ac); @@ -100,7 +100,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_land_missing(t,j,"upper") = v32_land_missing.up(j); ov_landdiff_forestry(t,"upper") = vm_landdiff_forestry.up; ov32_cost_recur(t,i,"upper") = v32_cost_recur.up(i); - ov32_land_expansion(t,j,type32,ac,"upper") = v32_land_expansion.up(j,type32,ac); + ov32_land_expansion(t,j,type32,"upper") = v32_land_expansion.up(j,type32); ov32_land_reduction(t,j,type32,ac,"upper") = v32_land_reduction.up(j,type32,ac); ov32_cost_establishment(t,i,"upper") = v32_cost_establishment.up(i); ov32_hvarea_forestry(t,j,ac,"upper") = v32_hvarea_forestry.up(j,ac); @@ -124,7 +124,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_establishment_dynamic(t,i,"upper") = q32_establishment_dynamic.up(i); oq32_establishment_dynamic_yield(t,i,"upper") = q32_establishment_dynamic_yield.up(i); oq32_establishment_fixed(t,j,"upper") = q32_establishment_fixed.up(j); - oq32_land_expansion(t,j,type32,ac,"upper") = q32_land_expansion.up(j,type32,ac); + oq32_land_expansion(t,j,type32,"upper") = q32_land_expansion.up(j,type32); oq32_land_reduction(t,j,type32,ac,"upper") = q32_land_reduction.up(j,type32,ac); oq32_cost_establishment(t,i,"upper") = q32_cost_establishment.up(i); oq32_bgp_aff(t,j,ac,"upper") = q32_bgp_aff.up(j,ac); @@ -142,7 +142,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_land_missing(t,j,"lower") = v32_land_missing.lo(j); ov_landdiff_forestry(t,"lower") = vm_landdiff_forestry.lo; ov32_cost_recur(t,i,"lower") = v32_cost_recur.lo(i); - ov32_land_expansion(t,j,type32,ac,"lower") = v32_land_expansion.lo(j,type32,ac); + ov32_land_expansion(t,j,type32,"lower") = v32_land_expansion.lo(j,type32); ov32_land_reduction(t,j,type32,ac,"lower") = v32_land_reduction.lo(j,type32,ac); ov32_cost_establishment(t,i,"lower") = v32_cost_establishment.lo(i); ov32_hvarea_forestry(t,j,ac,"lower") = v32_hvarea_forestry.lo(j,ac); @@ -166,7 +166,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_establishment_dynamic(t,i,"lower") = q32_establishment_dynamic.lo(i); oq32_establishment_dynamic_yield(t,i,"lower") = q32_establishment_dynamic_yield.lo(i); oq32_establishment_fixed(t,j,"lower") = q32_establishment_fixed.lo(j); - oq32_land_expansion(t,j,type32,ac,"lower") = q32_land_expansion.lo(j,type32,ac); + oq32_land_expansion(t,j,type32,"lower") = q32_land_expansion.lo(j,type32); oq32_land_reduction(t,j,type32,ac,"lower") = q32_land_reduction.lo(j,type32,ac); oq32_cost_establishment(t,i,"lower") = q32_cost_establishment.lo(i); oq32_bgp_aff(t,j,ac,"lower") = q32_bgp_aff.lo(j,ac); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 438b709e37..d00ddfcab1 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -15,7 +15,6 @@ ac_sub(ac) = yes$(ord(ac) > (m_yeardiff_forestry(t)/5)); *Reduction of ac_est is not possible. v32_hvarea_forestry.fx(j,ac_est) = 0; v32_land_reduction.fx(j,type32,ac_est) = 0; -v32_land_expansion.fx(j,type32,ac_sub) = 0; ** START ndc ** * calc NPI/NDC afforestation per time step based on forest stock change From 6c130ce3e83657f07305319c1d6fca22b3fdb17d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 4 Jan 2024 12:10:13 +0100 Subject: [PATCH 083/187] test summation mapping and parentheses --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 763b32f0ca..c2ed2c6617 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -392,19 +392,30 @@ elseif (s15_exo_diet = 3), * Note: brans is the only food commodity group that will not be affected * by the following calculations. -*' Where maximum target is not exceeded, total scenario food intake is assigned +*' Where no maximum target is assigned, total scenario food intake is assigned *' to EAT-Lancet recommendation i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); *** JAN: Should i15_rec_EATLancet be p15_rec_EATLancet then? +*** BENNI: +*Und assigned wird nicht der total food intake, sondern der (eventuell total-intake korrigierte) endogene intake. +*Ich wĂĽrde ausserdem den wert auf 9999 setzen fĂĽr fälle die man nicht erreichen will, nicht auf 0. +*Vielleicht will man ja einen max target von 0, zum beispiel bei Zucker. Ausserdem brauchst du dann auch keine sonderregel, und du kannst das ganz weglassen. +*** FELI: You mean 9999 in the file that is preprocessed? In the calcEATLancetTargets function, right? * For cases where the intake in a EAT-Lancet food group is zero for a country * in a particular time step, a small amount is added to ensure no division by * zero. This way, all kfo-items in the respective food group are corrected by * the same amount. -p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), + p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; +* Test whether sums and parentheses are set correctly +display(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro")))); +display(p15_intake_detail(t,iso,"puls_pro")) +display(p15_intake_detail(t,iso,"groundnut")) +display(p15_intake_detail(t,iso,"soybean")) + *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** *' If projected food intake is below minimum, it is increased it to meet @@ -455,6 +466,11 @@ i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_ i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail(t,iso,"potato"); +* Benni's suggestion: +*i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) +* = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + + i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - i15_intake_detailed_scen_target(t,iso,"potato") + From 3ffd65b82adb2e1ee343da22a72339ff7f58f40d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 4 Jan 2024 12:19:55 +0100 Subject: [PATCH 084/187] bugfix in display statements --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index c2ed2c6617..ebf5e1c9b0 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -412,9 +412,9 @@ elseif (s15_exo_diet = 3), * Test whether sums and parentheses are set correctly display(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro")))); -display(p15_intake_detail(t,iso,"puls_pro")) -display(p15_intake_detail(t,iso,"groundnut")) -display(p15_intake_detail(t,iso,"soybean")) +display(p15_intake_detail(t,iso,"puls_pro")); +display(p15_intake_detail(t,iso,"groundnut")); +display(p15_intake_detail(t,iso,"soybean")); *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** From dcd3300570cc93145f41ad9cbb17e5bdb4ace505 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 4 Jan 2024 12:32:04 +0100 Subject: [PATCH 085/187] bugfix in display statment --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index ebf5e1c9b0..ada52c85c0 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -411,10 +411,10 @@ elseif (s15_exo_diet = 3), p15_intake_detail(t,iso,kfo) + 1e-6; * Test whether sums and parentheses are set correctly -display(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro")))); -display(p15_intake_detail(t,iso,"puls_pro")); -display(p15_intake_detail(t,iso,"groundnut")); -display(p15_intake_detail(t,iso,"soybean")); +display sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro"))); +display p15_intake_detail(t,iso,"puls_pro"); +display p15_intake_detail(t,iso,"groundnut"); +display p15_intake_detail(t,iso,"soybean"); *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** From 4b782fe14ad1a8da06b143cd02680f94686b47d4 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 4 Jan 2024 15:04:02 +0100 Subject: [PATCH 086/187] changelog fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e1dc62971..0bbad81ed1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** removed erroneous setting `cc` from column `input` ### added -- **32_forestry** new interfaces `vm_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` +- **32_forestry** new interfaces `vm_land_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` - **scripts** added peatland to output/extra/disaggregation.R ### removed From 22c8d9c07b30eada6bf5b73adc15d9e0b2ae1e82 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 Jan 2024 10:25:36 +0100 Subject: [PATCH 087/187] bugfixes after Benni's code review --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 42 ++++++++----------- modules/15_food/anthro_iso_jun22/sets.gms | 3 +- scripts/start/projects/project_EAT2p0.R | 1 + 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index ada52c85c0..b0707c4487 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -316,6 +316,9 @@ $endif i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); +*** BENNI: Is this initiated correctly? (If p15_intake_total = 0, no value is written into i15_intake_detailed_scen_target. Is that a problem?) +* Am Ende fadet ja dann p15_intake_detail zu i15_intake_detailed_scen_target, d.h. wir mĂĽssen sicherstellen, dass in i15_intake_detailed_scen_target auch echt alles richtig drinsteht. + *' 2.) The second step defines the daily per capita intake of different food *' commodities. @@ -410,16 +413,11 @@ elseif (s15_exo_diet = 3), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; -* Test whether sums and parentheses are set correctly -display sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,"puls_pro"))); -display p15_intake_detail(t,iso,"puls_pro"); -display p15_intake_detail(t,iso,"groundnut"); -display p15_intake_detail(t,iso,"soybean"); - *' The intake target is adjusted to meet the EAT-Lancet recommendations *** Minimum recommendations *** -*' If projected food intake is below minimum, it is increased it to meet -*' the EAT-Lancet recommendations: +*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, +*' projected food intake it is increased to meet the EAT-Lancet recommendations +*' if it is below the minimum recommendation: i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) @@ -429,8 +427,9 @@ display p15_intake_detail(t,iso,"soybean"); ; *** Maximum recommendations *** -*' If projected food intake is above maximum, it is decreased it to meet -*' the EAT-Lancet recommendations: +*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, +*' projected food intake it is decreased to meet the EAT-Lancet recommendations +*' if it is above the maximum recommendation: i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) @@ -456,28 +455,24 @@ p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"ca p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); *' Maximum recommendation for starchy fruits: +i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) = i15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Maximum recommendation for roots: +i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = i15_rec_EATLancet(iso,"t_roots","max"); i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail(t,iso,"potato"); - -* Benni's suggestion: -*i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) -* = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); - + = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = - p15_intake_detail_roots(t,iso) / i15_intake_detailed_scen_roots(t,iso) * p15_intake_detail_roots(t,iso) - + i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - i15_intake_detailed_scen_target(t,iso,"potato") + i15_intake_detailed_scen_starchyfruit(t,iso); -*' Split the 'others' category into fruits plus vegetables -*' and those nuts and seeds that are not included in rapeseed and sunflower +*' Split the 'others' category into fruits plus vegetables and nuts p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); @@ -513,15 +508,9 @@ i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,is * Optionally, there is an exception for alcohol: * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined, e.g. according to Lassen et al., (2020). if (s15_alc_scen > 0, -* first, reduce projected alcohol consumption by a quarter: - i15_intake_detailed_scen_target(t,iso,"alcohol") = p15_intake_detail(t,iso,"alcohol") * 3/4; -* if still above target, set to maximum: i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) = s15_alc_scen * i15_intake_scen_target(t,iso); ); -***** ISABELLE: Why is this done in two steps? -***** BENNI: This is also done in the other EAT implementation (s15_exo_diet = 1). -***** Should it be done the same way in both? (Should it be taken out of the if-condition (applied to both)?) *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, @@ -535,6 +524,9 @@ i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,is display i15_intake_detailed_scen_target; +**** FELI: Check whether it gets negative... And come up with solution for fixing this... (Maybe via positive declaration / setting everyting that's negative to 0?) +* BENNI: What if EATLancet leads to too much calories? Just allow higher values? + ); *** End of MAgPIE-specific realization of the EAT Lancet diet diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index d04b7c2d73..b723532739 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -207,8 +207,7 @@ EAT_targets15 Food groups as well as individual foods for which EAT Lancet targe t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_roots, t_redmeat, - t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 0e3982d443..80215d589d 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -82,6 +82,7 @@ diet <- function(cfg) { cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) + cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. return(cfg) } From fa697c3fcee1bc2a352b6723050291fd55f75f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 5 Jan 2024 16:25:33 +0100 Subject: [PATCH 088/187] Update config/default.cfg Co-authored-by: David Klein --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 897553e379..411c8cb5b6 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1360,7 +1360,7 @@ cfg$gms$s56_cprice_red_factor <- 1 # def = 1 # * coupled REMIND-MAgPIE runs. Currently, this is R32M46. # * Available options: # * none: no 2nd generation bioenergy demand -# * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2 and MAgPIE 4.6 +# * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2.1.dev412 and MAgPIE 4.6.11 # * NPi: Current policies; above 3.0°C in 2100 # * NDC: ? # * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 From 2051958f3395200ad4d1b46d77cc19643ba5e61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 5 Jan 2024 16:25:44 +0100 Subject: [PATCH 089/187] Update config/default.cfg Co-authored-by: David Klein --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 411c8cb5b6..acb6ef15e8 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1362,7 +1362,7 @@ cfg$gms$s56_cprice_red_factor <- 1 # def = 1 # * none: no 2nd generation bioenergy demand # * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2.1.dev412 and MAgPIE 4.6.11 # * NPi: Current policies; above 3.0°C in 2100 -# * NDC: ? +# * NDC: Nationally determined contributions; limit peak warming to 2.5°C # * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 # * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 # * R32M46-SDP_MC-NPi, R32M46-SDP_MC-NDC, R32M46-SDP_MC-PkBudg650, From f05853e5f4fc444f36d34d1c12dfef644163dd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Humpen=C3=B6der?= Date: Fri, 5 Jan 2024 16:25:50 +0100 Subject: [PATCH 090/187] Update config/default.cfg Co-authored-by: David Klein --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index acb6ef15e8..9ae49173b3 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1361,7 +1361,7 @@ cfg$gms$s56_cprice_red_factor <- 1 # def = 1 # * Available options: # * none: no 2nd generation bioenergy demand # * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2.1.dev412 and MAgPIE 4.6.11 -# * NPi: Current policies; above 3.0°C in 2100 +# * NPi: Current policies; limit peak warming to 3.0°C # * NDC: Nationally determined contributions; limit peak warming to 2.5°C # * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 # * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 From af41e84779283c62f612a332aad9a03cb08d241c Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 Jan 2024 16:34:26 +0100 Subject: [PATCH 091/187] decomposing EATLancet diet into single targets --- config/default.cfg | 26 +- .../15_food/anthro_iso_jun22/declarations.gms | 4 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 236 +++++++++++------- modules/15_food/anthro_iso_jun22/sets.gms | 40 ++- 4 files changed, 183 insertions(+), 123 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index a115b9e681..fd2e43c928 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -453,24 +453,25 @@ cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI # # * exogenous food-specific diet scenario (EAT Lancet diet scenarios) # * only activated if s15_exo_diet is > 0 -#******** ISABELLE/BENNI: Or is this only active for s15_exo_diet = 1???? # * options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat cfg$gms$c15_EAT_scen <- "FLX" # def = FLX -# * Subspecifications: Which commodities shall be included in the diet shift +# * Sub-specifications: Which commodities shall be included in the diet shift # * towards cfg$gms$c15_EAT_scen ? Only selected (1) commodities will be # * included, while the others will remain to be endogenous. # * Any shift will be compensated to reach the calorie target by adjusting # * staple calories. -cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) +cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) +cfg$gms$s15_exo_redmeatdairy <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) +cfg$gms$s15_exo_poultry <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) +cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, @@ -482,6 +483,9 @@ cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 +# FELI: I would strongly suggest to set it to 0 because otherwise it is not in line with EATLancet, +# but that would be what the user expects! It would be better if the user manually has to set it to 0.014 +# when (s)he wants to divert from the standard EATLancet setting! # # # * Switch and specification of countries for which exogenous food scenarios diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 88122ba32f..0aac72e28e 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -159,11 +159,11 @@ parameters p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) - p15_intake_detail_nsothers(t,iso) Auxiliary parameter for the intake of those nuts and seeds included in others (kcal per capita per day) + p15_intake_detail_nuts(t,iso) Auxiliary parameter for the intake of nuts included in others (kcal per capita per day) i15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) i15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - i15_intake_detailed_scen_nsothers(t,iso) Auxiliary scenario target for the intake of those nuts and seeds included in others (kcal per capita per day) + i15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index b0707c4487..6477237d56 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -338,7 +338,7 @@ if (s15_exo_diet = 1, i15_intake_EATLancet(iso,kfo) = i15_intake_EATLancet_all(iso,"2100kcal","%c15_EAT_scen%",kfo); -*' upper bound for monogastric meat +*' upper bound for monogastric meat and eggs if (s15_exo_monogastric=1, i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15)$(i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15) > i15_intake_EATLancet(iso,EAT_monogastrics15)) = i15_intake_EATLancet(iso,EAT_monogastrics15)); @@ -382,7 +382,9 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) ; -* VARTIKA: What about s15_exo_diet = 2? Is there any special treatment needed here? +* VARTIKA: What about s15_exo_diet = 2? +* Can this be transformed to the new diet implementation? Did you have target values there? +* (Note: The old EATLancet implementation should be deleted soon.) *---------------------------------------------------------------------------------------- elseif (s15_exo_diet = 3), @@ -395,16 +397,6 @@ elseif (s15_exo_diet = 3), * Note: brans is the only food commodity group that will not be affected * by the following calculations. -*' Where no maximum target is assigned, total scenario food intake is assigned -*' to EAT-Lancet recommendation - i15_rec_EATLancet(iso,EAT_targets15,"max")$(i15_rec_EATLancet(iso,EAT_targets15,"max") = 0) = i15_intake_scen_target(t,iso); -*** JAN: Should i15_rec_EATLancet be p15_rec_EATLancet then? -*** BENNI: -*Und assigned wird nicht der total food intake, sondern der (eventuell total-intake korrigierte) endogene intake. -*Ich wĂĽrde ausserdem den wert auf 9999 setzen fĂĽr fälle die man nicht erreichen will, nicht auf 0. -*Vielleicht will man ja einen max target von 0, zum beispiel bei Zucker. Ausserdem brauchst du dann auch keine sonderregel, und du kannst das ganz weglassen. -*** FELI: You mean 9999 in the file that is preprocessed? In the calcEATLancetTargets function, right? - * For cases where the intake in a EAT-Lancet food group is zero for a country * in a particular time step, a small amount is added to ensure no division by * zero. This way, all kfo-items in the respective food group are corrected by @@ -412,105 +404,176 @@ elseif (s15_exo_diet = 3), p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; +* FELI: Check whether this is still necessary when the targets are split + +*' The single targets can also be set manually via switches +*' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). + +*' upper bound for chicken and eggs + if (s15_exo_poultry = 1, +* upper bound for eggs + i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") + > i15_rec_EATLancet(iso,"t_livst_egg","max")) + ) = + i15_rec_EATLancet(iso,"t_livst_egg","max"); + +* upper bound for chicken + i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") + > i15_rec_EATLancet(iso,"t_livst_chick","max")) + ) = + i15_rec_EATLancet(iso,"t_livst_chick","max"); + ); + +*' upper bound for redmeat and milk + if (s15_exo_redmeatdairy = 1, +* upper bound for redmeat (pig and ruminant) + i15_intake_detailed_scen_target(t,iso,EAT_redmeat15)$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > i15_rec_EATLancet(iso,"t_redmeat","max") + ) = + (p15_intake_detail(t,iso,EAT_redmeat15) / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) + * i15_rec_EATLancet(iso,"t_redmeat","max"); +* upper bound for milk + i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") + > i15_rec_EATLancet(iso,"t_livst_milk","max")) + ) = + i15_rec_EATLancet(iso,"t_livst_milk","max"); + ); -*' The intake target is adjusted to meet the EAT-Lancet recommendations -*** Minimum recommendations *** -*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, -*' projected food intake it is increased to meet the EAT-Lancet recommendations -*' if it is below the minimum recommendation: - i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), - sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) - ) < sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) - ) = - (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"min")) - ; - -*** Maximum recommendations *** -*' For food groups where direct mapping between EATLancet and MAgPIE food groups is possible, -*' projected food intake it is decreased to meet the EAT-Lancet recommendations -*' if it is above the maximum recommendation: - i15_intake_detailed_scen_target(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), - sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)) - ) > sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) - ) = - (p15_intake_detail(t,iso,kfo) / sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2)))) - * sum(EATtar_kfo15(EAT_mtargets15,kfo), i15_rec_EATLancet(iso,EAT_mtargets15,"max")) - ; +*' lower bound for fish + if (s15_exo_fish = 1, + i15_intake_detailed_scen_target(t,iso,"fish")$(p15_intake_detail(t,iso,"fish") + < i15_rec_EATLancet(iso,"t_fish","min") + ) = + i15_rec_EATLancet(iso,"t_fish","min"); + ); +*' lower bound for fruits, veggies, nuts and seeds +*' and upper bound for starchy fruits and roots + if (s15_exo_fruitvegnut = 1, *** Special case: Fruits, vegetables and nuts *** -*' In MAgPIE fruits, vegetables and (some) nuts are combined to the 'other' food category; -*' and bananas and plantains are included in the 'cassav_sp' category. +*' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; +*' Bananas and plantains are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) -*' of fruits and vegetables in this aggregate categories. - if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); - else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); - ); +*' of fruits and vegetables in these aggregate categories. + if (sum(sameas(t_past,t),1) = 1, + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + else + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); + ); *' Separation of starchy fruits (bananas and plantains) *' and roots (cassava, sweet potato, yams) in the cassav_sp food category -p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); -p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); + p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); + p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); *' Maximum recommendation for starchy fruits: -i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); -i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) - = i15_rec_EATLancet(iso,"t_fruitstarch","max"); + i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); + i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) + = i15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Maximum recommendation for roots: -i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); -i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_rec_EATLancet(iso,"t_roots","max"); + i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); + i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = i15_rec_EATLancet(iso,"t_roots","max"); -i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) + = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); -i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = - i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - - i15_intake_detailed_scen_target(t,iso,"potato") + - i15_intake_detailed_scen_starchyfruit(t,iso); + i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = + i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - + i15_intake_detailed_scen_target(t,iso,"potato") + + i15_intake_detailed_scen_starchyfruit(t,iso); *' Split the 'others' category into fruits plus vegetables and nuts - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); - p15_intake_detail_nsothers(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); - i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); - i15_intake_detailed_scen_nsothers(t,iso) = p15_intake_detail_nsothers(t,iso); + p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detail_nuts(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); + i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); + i15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); *' Minimum recommendation for fruits and vegetables: - i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) - = i15_rec_EATLancet(iso,"t_fruitveg","min"); + i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) + = i15_rec_EATLancet(iso,"t_fruitveg","min"); *' Extract fruits and vegetables that are part of others categroy * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); - -*' Minimum recommendation for nuts -*' (a) nuts and seeds that are included in "others" - i15_intake_detailed_scen_nsothers(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nsothers(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nsothers(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") - ; + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); + +*' Minimum recommendation for nuts & seeds +*' (a) nuts included in "others" + i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; +*FELI: Check here! I think something is wrong with the set!!! + *' (b) for rapeseed, sunflower: - i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nsothers(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") - ; + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) + ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) + * i15_rec_EATLancet(iso,"t_nutseeds","min") + ; *' The resulting intake of the "others" category is: - i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nsothers(t,iso); + i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + ); + +*' lower bound for legumes + if (s15_exo_pulses = 1, + i15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2)) + < i15_rec_EATLancet(iso,"t_legumes","min") + ) = + (p15_intake_detail(t,iso,EAT_pulses15) / sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2))) + * i15_rec_EATLancet(iso,"t_legumes","min"); + ); + +*' upper bound for sugar + if (s15_exo_sugar = 1, + i15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") + > i15_rec_EATLancet(iso,"t_sugar","max")) + ) = + i15_rec_EATLancet(iso,"t_sugar","max"); + ); + +*' upper and lower bound for oils + if (s15_exo_oils = 1, +* i15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") +* oil_veg has a minimum and maximum recommendation in EAT + i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + < i15_rec_EATLancet(iso,"t_oils","min") + ) = + i15_rec_EATLancet(iso,"t_oils","min"); + +* oil palm has a maximum recommendation in EAT + i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + > i15_rec_EATLancet(iso,"t_oils","max")) + ) = + i15_rec_EATLancet(iso,"t_oils","max"); + ); + * Food commodities that are not included in diet recommendations are set to zero: - i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; -* Optionally, there is an exception for alcohol: -* Via 's15_alc_scen' a maximum target for alcohol consumption can be defined, e.g. according to Lassen et al., (2020). - if (s15_alc_scen > 0, - i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) - = s15_alc_scen * i15_intake_scen_target(t,iso); - ); + i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; + +* Optionally, there is an exception for alcohol if s15_exo_alcohol = 1: +* Even though it would be 0 following the EAT Lancet recommendation, +* an alternative maximum target can be set via 's15_alc_scen' for alcohol consumption, +* e.g. following the recommendation according to Lassen et al., (2020). + if (s15_exo_alcohol = 1, + i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) + = s15_alc_scen * i15_intake_scen_target(t,iso); + ); +*' There is no explicit target for brans in the EATLancet recommendations. +*' It is therefore set to 0. +*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level / including it as part of staples. + if (s15_exo_brans = 1, + i15_intake_detailed_scen_target(t,iso,"brans") = 0; + ); +*' There is no explicit target for single cell protein in the EATLancet recommendations. +*' It is therefore set to 0. + if (s15_exo_scp = 1, + i15_intake_detailed_scen_target(t,iso,"scp") = 0; + ); *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, @@ -526,6 +589,7 @@ display i15_intake_detailed_scen_target; **** FELI: Check whether it gets negative... And come up with solution for fixing this... (Maybe via positive declaration / setting everyting that's negative to 0?) * BENNI: What if EATLancet leads to too much calories? Just allow higher values? +* JAN: Can a parameter be declared as positive? Or only variables? ); *** End of MAgPIE-specific realization of the EAT Lancet diet diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index b723532739..f2030daa47 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,7 +109,7 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / - kfo_ns(kfo) Food products that can be counted towards nuts and nuts_seeds + kfo_seeds(kfo) Food products that are counted towards seeds / rapeseed, sunflower / kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation @@ -174,6 +174,8 @@ sets / livst_pig, livst_egg, livst_chick / EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / + EAT_redmeat15(kfo) + / livest_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses @@ -212,28 +214,18 @@ EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MA EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / -EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories - / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, groundnut, soybean) - t_fish . (fish) - t_livst_chick . (livst_chick) - t_livst_egg . (livst_egg) - t_livst_milk . (livst_milk) - t_sugar . (sugar) - t_oils . (oils) - / - ; -alias(kst,kst2); -alias(bmi_group15,bmi_group15_2); -alias(kfo,kfo2); -alias(kfo_ap,kfo_ap2); -alias(kfo_st,kfo_st2); -alias(kfo_pf,kfo_pf2); -alias(kfo_ns,kfo_ns2); -alias(iso,iso2); -alias(reproductive,reproductive2); -alias(EAT_staples,EAT_staples2); -alias(EAT_mtargets15,EAT_mtargets15_2); -alias(EATtar_kfo15,EATtar_kfo15_2); +alias(kst, kst2); +alias(bmi_group15, bmi_group15_2); +alias(kfo, kfo2); +alias(kfo_ap, kfo_ap2); +alias(kfo_st, kfo_st2); +alias(kfo_pf, kfo_pf2); +alias(kfo_seeds, kfo_seeds2); +alias(iso, iso2); +alias(reproductive, reproductive2); +alias(EAT_staples, EAT_staples2); +alias(EAT_pulses15, EAT_pulses15_2); +alias(EAT_redmeat15, EAT_redmeat15_2) +alias(EAT_mtargets15, EAT_mtargets15_2); From 63522b179b011395ee2ddf79d2878f3353a04a59 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 5 Jan 2024 16:38:26 +0100 Subject: [PATCH 092/187] update test runs --- config/default.cfg | 10 +++++----- scripts/start/test_runs.R | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 9ae49173b3..2fe439c2b0 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1367,7 +1367,7 @@ cfg$gms$s56_cprice_red_factor <- 1 # def = 1 # * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 # * R32M46-SDP_MC-NPi, R32M46-SDP_MC-NDC, R32M46-SDP_MC-PkBudg650, # * R32M46-SSP1-NPi, R32M46-SSP1-NDC, R32M46-SSP1-PkBudg1050, R32M46-SSP1-PkBudg650, -# * R32M46-SSP2-NPi, R32M46-SSP2-NDC, R32M46-SSP2-PkBudg1050, R32M46-SSP2-PkBudg650, +# * R32M46-SSP2EU-NPi, R32M46-SSP2EU-NDC, R32M46-SSP2EU-PkBudg1050, R32M46-SSP2EU-PkBudg650, # * R32M46-SSP5-NPi, R32M46-SSP5-NDC, R32M46-SSP5-PkBudg1050, R32M46-SSP5-PkBudg650, # * R21M42: Coupled REMIND-MAgPIE runs with REMIND 2.1 and MAgPIE 4.2 # * NPi: Current policies; above 3.0°C in 2100 @@ -1619,14 +1619,14 @@ cfg$gms$c60_1stgen_biodem <- "const2020" # def = const2020 # * coupled REMIND-MAgPIE runs. Currently, this is R32M46. # * Available options: # * none: no 2nd generation bioenergy demand -# * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2 and MAgPIE 4.6 -# * NPi: Current policies; above 3.0°C in 2100 -# * NDC: ? +# * R32M46: Coupled REMIND-MAgPIE runs with REMIND 3.2.1.dev412 and MAgPIE 4.6.11 +# * NPi: Current policies; limit peak warming to 3.0°C +# * NDC: Nationally determined contributions; limit peak warming to 2.5°C # * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 # * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 # * R32M46-SDP_MC-NPi, R32M46-SDP_MC-NDC, R32M46-SDP_MC-PkBudg650, # * R32M46-SSP1-NPi, R32M46-SSP1-NDC, R32M46-SSP1-PkBudg1050, R32M46-SSP1-PkBudg650, -# * R32M46-SSP2-NPi, R32M46-SSP2-NDC, R32M46-SSP2-PkBudg1050, R32M46-SSP2-PkBudg650, +# * R32M46-SSP2EU-NPi, R32M46-SSP2EU-NDC, R32M46-SSP2EU-PkBudg1050, R32M46-SSP2EU-PkBudg650, # * R32M46-SSP5-NPi, R32M46-SSP5-NDC, R32M46-SSP5-PkBudg1050, R32M46-SSP5-PkBudg650, # * R21M42: Coupled REMIND-MAgPIE runs with REMIND 2.1 and MAgPIE 4.2 # * NPi: Current policies; above 3.0°C in 2100 diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index 7815102f9a..780e3563dc 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -47,23 +47,23 @@ for(ssp in c("SSP1","SSP2","SSP5")) { cfg$title <- .title(cfg, paste(ssp,"Ref",sep="-")) cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) cfg$gms$c56_mute_ghgprices_until <- "y2150" - cfg$gms$c56_pollutant_prices <- paste0("R21M42-",ssp,"-NPi") - cfg$gms$c60_2ndgen_biodem <- paste0("R21M42-",ssp,"-NPi") + cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-NPi") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-NPi") start_run(cfg, codeCheck = FALSE) cfg$title <- .title(cfg, paste(ssp,"NDC",sep="-")) cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) cfg$gms$c56_mute_ghgprices_until <- "y2150" -# Input for NDC from R21M42 is not available, therefore NPi is used. - cfg$gms$c56_pollutant_prices <- paste0("R21M42-",ssp,"-NPi") - cfg$gms$c60_2ndgen_biodem <- paste0("R21M42-",ssp,"-NPi") +# Input for NDC from R32M46 is not available, therefore NPi is used. + cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-NDC") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-NDC") start_run(cfg, codeCheck = FALSE) - cfg$title <- .title(cfg, paste(ssp,"PkBudg900",sep="-")) + cfg$title <- .title(cfg, paste(ssp,"PkBudg650",sep="-")) cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9")) cfg$gms$c56_mute_ghgprices_until <- "y2030" - cfg$gms$c56_pollutant_prices <- paste0("R21M42-",ssp,"-PkBudg900") - cfg$gms$c60_2ndgen_biodem <- paste0("R21M42-",ssp,"-PkBudg900") + cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-PkBudg650") start_run(cfg, codeCheck = FALSE) } From ddabcecd0894ffa27b530fcbc9652e9d746ba64a Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 Jan 2024 17:01:40 +0100 Subject: [PATCH 093/187] correct typo --- modules/15_food/anthro_iso_jun22/sets.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index f2030daa47..eadc741589 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -175,7 +175,7 @@ sets EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / EAT_redmeat15(kfo) - / livest_rum, livst_pig / + / livst_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses From b21f03b8bc9274e13234e13122a953327c5d4bbd Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 5 Jan 2024 22:26:32 +0100 Subject: [PATCH 094/187] update --- scripts/start/test_runs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index 780e3563dc..2dff4f7ac9 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -42,7 +42,7 @@ cfg$gms$c_timesteps <- timeSteps # Reference and Policy run for SSP1, SSP2 and SSP5 -for(ssp in c("SSP1","SSP2","SSP5")) { +for(ssp in c("SSP1","SSP2EU","SSP5")) { cfg$title <- .title(cfg, paste(ssp,"Ref",sep="-")) cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) From be844fc0410d7059c1a74473a948fec01745993c Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 7 Jan 2024 17:31:53 +0100 Subject: [PATCH 095/187] update FSEC config --- config/scenario_fsec.csv | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 5ea2924d7b..384a29f5aa 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -51,7 +51,7 @@ gms$c50_scen_neff_noselect;;;baseeff_add3_add10_add20_max75;;;;;;;;;;;;;;;;;;;;; gms$c52_land_carbon_sink_rcp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP34;RCP45;RCP60;RCPBU;RCPBU; gms$c55_scen_conf;;;;;;;;;;;;;;;;;GoodPractice;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c56_emis_policy;none;;;;;;;;;;;;;;;;;;sdp_cropeff;;;;;;sdp_redd;sdp_redd;;;;;sdp_peatland;sdp_soil;;;sdp_redd_soil_peat;sdp_all;;;;;;;;;;;;; -gms$c56_pollutant_prices;R21M42-SSP2-PkBudg1300;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices;R32M46-SSP2EU-PkBudg1050;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s56_c_price_induced_aff;0;;;;;;;;;;;;;;;;;;;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;; gms$s57_maxmac_n_soil;-1;;;;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s57_maxmac_ch4_rice;-1;;;;;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -59,15 +59,15 @@ gms$s57_maxmac_ch4_entferm;-1;;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s57_maxmac_ch4_awms;-1;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Inf;;;;;;;;;;;;;;;;;; gms$som;cellpool_aug16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem;;;;R21M42-SSP2-PkBudg900;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;R21M42-SSP1-PkBudg900 +gms$c60_2ndgen_biodem;;;;R32M46-SSP2EU-PkBudg650;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;R32M46-SSP1-PkBudg650 gms$c60_res_2ndgenBE_dem;;;;sdp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s62_max_dem_bioplastic;0;;;;400;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_fac_req_regr;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_feed_scen;;;;;;;;;;;;;;;;;;ssp1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;; -input['cellular'];rev4.94_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.94_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.94_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -input['regional'];rev4.94_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['validation'];rev4.94_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['additional'];additional_data_rev4.46.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['cellular'];rev4.96_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.96_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['regional'];rev4.96_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['validation'];rev4.96_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['additional'];additional_data_rev4.47.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_24Mar23.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_SSP1-PkBudg900.mif From 245c11b73b11d05d30b9d6b8cf13cf2d0996ab61 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 8 Jan 2024 11:44:21 +0100 Subject: [PATCH 096/187] re-introduced mapping between magpie and eat categories for division by zero avoidance constraint --- modules/15_food/anthro_iso_jun22/sets.gms | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index eadc741589..a0dc886c24 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -214,6 +214,18 @@ EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MA EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / + +EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories + / t_redmeat . (livst_rum, livst_pig, scp) + t_legumes . (puls_pro, groundnut, soybean) + t_fish . (fish) + t_livst_chick . (livst_chick) + t_livst_egg . (livst_egg) + t_livst_milk . (livst_milk) + t_sugar . (sugar) + t_oils . (oils) + / + ; alias(kst, kst2); @@ -227,5 +239,6 @@ alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); alias(EAT_pulses15, EAT_pulses15_2); -alias(EAT_redmeat15, EAT_redmeat15_2) +alias(EAT_redmeat15, EAT_redmeat15_2); +alias(EATtar_kfo15, EATtar_kfo15_2); alias(EAT_mtargets15, EAT_mtargets15_2); From 3ab7734e9d60307ebe9e7d81edcb8b08d608f3ea Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 8 Jan 2024 14:29:32 +0100 Subject: [PATCH 097/187] updated preprocessing tgzs --- config/default.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index fd2e43c928..f7730e2d51 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS1_rev4.95EL2__h12_magpie.tgz", - cellular = "rev4.95EL2__h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.95EL2__h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", + cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") From ce560c6fdd9372b6f4a12bdc3e604f7a52a4e6bd Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 9 Jan 2024 10:05:34 +0100 Subject: [PATCH 098/187] bugfixes in new DietImplementation with target separation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 10 +++++----- modules/15_food/anthro_iso_jun22/input.gms | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 6477237d56..46f009ff12 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -413,13 +413,13 @@ elseif (s15_exo_diet = 3), if (s15_exo_poultry = 1, * upper bound for eggs i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") - > i15_rec_EATLancet(iso,"t_livst_egg","max")) + > i15_rec_EATLancet(iso,"t_livst_egg","max") ) = i15_rec_EATLancet(iso,"t_livst_egg","max"); * upper bound for chicken i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") - > i15_rec_EATLancet(iso,"t_livst_chick","max")) + > i15_rec_EATLancet(iso,"t_livst_chick","max") ) = i15_rec_EATLancet(iso,"t_livst_chick","max"); ); @@ -434,7 +434,7 @@ elseif (s15_exo_diet = 3), * i15_rec_EATLancet(iso,"t_redmeat","max"); * upper bound for milk i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") - > i15_rec_EATLancet(iso,"t_livst_milk","max")) + > i15_rec_EATLancet(iso,"t_livst_milk","max") ) = i15_rec_EATLancet(iso,"t_livst_milk","max"); ); @@ -530,7 +530,7 @@ elseif (s15_exo_diet = 3), *' upper bound for sugar if (s15_exo_sugar = 1, i15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") - > i15_rec_EATLancet(iso,"t_sugar","max")) + > i15_rec_EATLancet(iso,"t_sugar","max") ) = i15_rec_EATLancet(iso,"t_sugar","max"); ); @@ -546,7 +546,7 @@ elseif (s15_exo_diet = 3), * oil palm has a maximum recommendation in EAT i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") - > i15_rec_EATLancet(iso,"t_oils","max")) + > i15_rec_EATLancet(iso,"t_oils","max") ) = i15_rec_EATLancet(iso,"t_oils","max"); ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index ee21df3034..ffbc06e32f 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -97,6 +97,8 @@ scalar s15_exo_diet Switch for transition towards exogenous diet scenario (1) / * If the switch is set to 1,the exogenous diets are activated. * For all other settings (!=1), the endogenous estimate is used. * When activating a target, total calories are always preserved via scaling of staples +scalar s15_exo_poultry Exogenous EAT Lancet animal product target on (1) / 1 /; +scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; From 37e3537162d241db84fe032f25a7d139370725c8 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 9 Jan 2024 18:00:05 +0100 Subject: [PATCH 099/187] groundnuts is allocated to nuts because of dietary target --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 20 ++++++++++++------- modules/15_food/anthro_iso_jun22/sets.gms | 11 +++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 46f009ff12..65a72f38dc 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -406,6 +406,9 @@ elseif (s15_exo_diet = 3), p15_intake_detail(t,iso,kfo) + 1e-6; * FELI: Check whether this is still necessary when the targets are split +* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail +* to grams using i15_protein_to_kcal_ratio + *' The single targets can also be set manually via switches *' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). @@ -500,17 +503,16 @@ elseif (s15_exo_diet = 3), *' Minimum recommendation for nuts & seeds *' (a) nuts included in "others" - i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) + i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail_nuts(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; -*FELI: Check here! I think something is wrong with the set!!! -*' (b) for rapeseed, sunflower: - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) +*' (b) for other nuts (groundnut) and seeds (rapeseed, sunflower): + i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; @@ -565,7 +567,7 @@ elseif (s15_exo_diet = 3), ); *' There is no explicit target for brans in the EATLancet recommendations. *' It is therefore set to 0. -*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level / including it as part of staples. +*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level or including it as part of staples. if (s15_exo_brans = 1, i15_intake_detailed_scen_target(t,iso,"brans") = 0; ); @@ -575,6 +577,10 @@ elseif (s15_exo_diet = 3), i15_intake_detailed_scen_target(t,iso,"scp") = 0; ); + +* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail +* back to kcal using i15_protein_to_kcal_ratio + *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, *' intake of staple crops is now modified such that the diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index a0dc886c24..dda75b79ed 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,8 +109,9 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / - kfo_seeds(kfo) Food products that are counted towards seeds - / rapeseed, sunflower / +* Note: From a nutritional perspective, groundnut counts towards nuts + kfo_ns(kfo) Food products that are counted towards nuts and seeds + / rapeseed, sunflower, groundnut/ kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation / sugr_cane, sugr_beet, molasses, alcohol / @@ -179,7 +180,7 @@ sets EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / EAT_pulses15(kfo) pulses - / soybean, puls_pro, groundnut / + / soybean, puls_pro / EAT_sugar15(kfo) sugar / sugr_cane, sugr_beet, sugar, molasses / @@ -217,7 +218,7 @@ EAT_special MAgPIE food groups that need special treatment with respect to fruit EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, groundnut, soybean) + t_legumes . (puls_pro, soybean) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) @@ -234,7 +235,7 @@ alias(kfo, kfo2); alias(kfo_ap, kfo_ap2); alias(kfo_st, kfo_st2); alias(kfo_pf, kfo_pf2); -alias(kfo_seeds, kfo_seeds2); +alias(kfo_ns, kfo_ns2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); From 0099c452c98356532a437873f1924baa1669f41a Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 10 Jan 2024 14:16:06 +0100 Subject: [PATCH 100/187] bugfix in old diet implementation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 ++++-- modules/15_food/anthro_iso_jun22/sets.gms | 4 ++++ scripts/start/projects/project_EAT2.R | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 65a72f38dc..e6dfdbcd0b 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -377,9 +377,9 @@ if (s15_exo_diet = 1, = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2)) > 0) = + i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * - (i15_intake_EATLancet(iso,EAT_staples) / sum(EAT_staples2,i15_intake_EATLancet(iso,EAT_staples2))) + (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old))) ; * VARTIKA: What about s15_exo_diet = 2? @@ -508,6 +508,8 @@ elseif (s15_exo_diet = 3), = (p15_intake_detail_nuts(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; +* 25 for peanuts +* 25 for nuts from other + seeds *' (b) for other nuts (groundnut) and seeds (rapeseed, sunflower): i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index dda75b79ed..7c7d9bb831 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -184,6 +184,9 @@ sets EAT_sugar15(kfo) sugar / sugr_cane, sugr_beet, sugar, molasses / + EAT_staples_old(kfo) All staple food products according to EAT Lancet definition + / tece, maiz, trce, rice_pro, potato, cassav_sp / + EAT_staples(kfo) All staple food products according to EAT Lancet definition / tece, maiz, trce, rice_pro / @@ -239,6 +242,7 @@ alias(kfo_ns, kfo_ns2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); +alias(EAT_staples_old, EAT_staples2_old); alias(EAT_pulses15, EAT_pulses15_2); alias(EAT_redmeat15, EAT_redmeat15_2); alias(EATtar_kfo15, EATtar_kfo15_2); diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R index 1ef1c567c9..63f3526d0a 100644 --- a/scripts/start/projects/project_EAT2.R +++ b/scripts/start/projects/project_EAT2.R @@ -22,6 +22,8 @@ source("scripts/start_functions.R") # laod default configuration source("config/default.cfg") +cfg$force_download <- TRUE + # Set defaults codeCheck <- FALSE From da7cac19771999f19c54de896ec1b8822d1a077d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 11 Jan 2024 09:50:20 +0100 Subject: [PATCH 101/187] separation of peanuts from nuts --- config/default.cfg | 6 +++--- .../15_food/anthro_iso_jun22/exodietmacro.gms | 21 +++++++++++-------- modules/15_food/anthro_iso_jun22/sets.gms | 10 ++++----- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 6a94fc6104..10c7ea3b35 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", - cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.96EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", + cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.97EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e6dfdbcd0b..623215c770 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -502,21 +502,24 @@ elseif (s15_exo_diet = 3), i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds -*' (a) nuts included in "others" - i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_ns, p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso) +*' (a) nuts included in "others" counted towards EAT nuts & seeds category + i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nuts(t,iso) / (sum(kfo_ns,p15_intake_detail(t,iso,kfo_ns)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; -* 25 for peanuts -* 25 for nuts from other + seeds - -*' (b) for other nuts (groundnut) and seeds (rapeseed, sunflower): - i15_intake_detailed_scen_target(t,iso,kfo_ns)$((sum(kfo_ns2,p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso) +*' (b) seeds (rapeseed, sunflower): + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_ns) / (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) + = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) * i15_rec_EATLancet(iso,"t_nutseeds","min") ; +*' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds +*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts? + i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") + < i15_rec_EATLancet(iso,"t_peanuts","min") + ) = + i15_rec_EATLancet(iso,"t_peanuts","min"); *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 7c7d9bb831..52cad210c4 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,9 +109,8 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / -* Note: From a nutritional perspective, groundnut counts towards nuts - kfo_ns(kfo) Food products that are counted towards nuts and seeds - / rapeseed, sunflower, groundnut/ + kfo_seeds(kfo) Food products that are counted towards seeds + / rapeseed, sunflower/ kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation / sugr_cane, sugr_beet, molasses, alcohol / @@ -213,7 +212,7 @@ EAT_targets15 Food groups as well as individual foods for which EAT Lancet targe t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + / t_redmeat, t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / @@ -222,6 +221,7 @@ EAT_special MAgPIE food groups that need special treatment with respect to fruit EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories / t_redmeat . (livst_rum, livst_pig, scp) t_legumes . (puls_pro, soybean) + t_peanuts . (groundnut) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) @@ -238,7 +238,7 @@ alias(kfo, kfo2); alias(kfo_ap, kfo_ap2); alias(kfo_st, kfo_st2); alias(kfo_pf, kfo_pf2); -alias(kfo_ns, kfo_ns2); +alias(kfo_seeds, kfo_seeds2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); From 4960920888a942eb5768ab19ddbdb72e0dc2198d Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 11 Jan 2024 11:05:55 +0100 Subject: [PATCH 102/187] bugfix in peanuts implementation and in eat1 as it diverged from develop --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++-- modules/15_food/anthro_iso_jun22/sets.gms | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 623215c770..708e36b642 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -355,8 +355,8 @@ if (s15_exo_diet = 1, = i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)); *' lower bound for pulses if (s15_exo_pulses=1, - i15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(i15_intake_detailed_scen_target(t,iso,EAT_pulses15) < i15_intake_EATLancet(iso,EAT_pulses15)) - = i15_intake_EATLancet(iso,EAT_pulses15)); + i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old)$(i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old) < i15_intake_EATLancet(iso,EAT_pulses15_old)) + = i15_intake_EATLancet(iso,EAT_pulses15_old)); *' upper bound for sugar if (s15_exo_sugar=1, i15_intake_detailed_scen_target(t,iso,EAT_sugar15)$(i15_intake_detailed_scen_target(t,iso,EAT_sugar15) > i15_intake_EATLancet(iso,EAT_sugar15)) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 52cad210c4..35fdb73429 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -178,6 +178,8 @@ sets / livst_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / + EAT_pulses15_old(kfo) pulses + / soybean, puls_pro, groundnut / EAT_pulses15(kfo) pulses / soybean, puls_pro / EAT_sugar15(kfo) sugar @@ -209,7 +211,7 @@ EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendation EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined / t_nutseeds, t_fruitveg, t_fruitstarch, t_roots, t_redmeat, - t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible / t_redmeat, t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / @@ -244,6 +246,7 @@ alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); alias(EAT_staples_old, EAT_staples2_old); alias(EAT_pulses15, EAT_pulses15_2); +alias(EAT_pulses15_old, EAT_pulses15_2_old); alias(EAT_redmeat15, EAT_redmeat15_2); alias(EATtar_kfo15, EATtar_kfo15_2); alias(EAT_mtargets15, EAT_mtargets15_2); From dc9f7d582149ce21500c4b7487649c5afa279354 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 12 Jan 2024 13:49:18 +0100 Subject: [PATCH 103/187] changed iso-level fruitveg ratio to regional level --- config/default.cfg | 2 +- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 9 +++++---- modules/15_food/anthro_iso_jun22/input.gms | 4 ++-- modules/15_food/input/files | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 10c7ea3b35..e2d5cb9d8c 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -483,7 +483,7 @@ cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 -# FELI: I would strongly suggest to set it to 0 because otherwise it is not in line with EATLancet, +# BENNI: I (Feli) would suggest to set it to 0 because otherwise it is not in line with EATLancet, # but that would be what the user expects! It would be better if the user manually has to set it to 0.014 # when (s)he wants to divert from the standard EATLancet setting! # diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 708e36b642..e6b92954f1 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -407,7 +407,7 @@ elseif (s15_exo_diet = 3), * FELI: Check whether this is still necessary when the targets are split * To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail -* to grams using i15_protein_to_kcal_ratio +* to grams using *' The single targets can also be set manually via switches *' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). @@ -456,12 +456,13 @@ elseif (s15_exo_diet = 3), *** Special case: Fruits, vegetables and nuts *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; *' Bananas and plantains are included in the 'cassav_sp' category. -*' The f15_fruitveg2others_kcal_ratio gives the historical share (fixed into the future based on last historic year) +*' The f15_fruitveg2others_kcal_ratio gives the regional average historical share +*' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t,i,EAT_special)); else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t-1,i,EAT_special)); ); *' Separation of starchy fruits (bananas and plantains) diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index ffbc06e32f..5960190762 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -258,9 +258,9 @@ $ondelim $include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" $offdelim; -table f15_fruitveg2others_kcal_ratio(t_all,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) +table f15_fruitveg2others_kcal_ratio(t_all,i,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) $ondelim -$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.cs3" +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio.cs3" $offdelim; * This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions diff --git a/modules/15_food/input/files b/modules/15_food/input/files index 3a2b8735ad..46b2d569ee 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -21,7 +21,7 @@ f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 f15_targets_EATLancet_iso.cs3 -f15_fruitveg2others_kcal_ratio_iso.cs3 +f15_fruitveg2others_kcal_ratio.cs3 f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv From f7dce1ecfb7e180fe56a09d1972df8a579a9e9c0 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 15 Jan 2024 10:48:18 +0100 Subject: [PATCH 104/187] bugfixes ac_est --- .../32_forestry/dynamic_feb21/equations.gms | 2 +- .../32_forestry/dynamic_feb21/presolve.gms | 4 +-- .../35_natveg/dynamic_feb21/declarations.gms | 16 +++++----- modules/35_natveg/dynamic_feb21/equations.gms | 16 +++++----- modules/35_natveg/dynamic_feb21/postsolve.gms | 32 +++++++++---------- modules/35_natveg/dynamic_feb21/presolve.gms | 2 +- modules/35_natveg/dynamic_feb21/scaling.gms | 4 +-- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index fee1225023..9908227cf2 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -101,7 +101,7 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( q32_land_expansion(j2,type32) .. v32_land_expansion(j2,type32) =e= - sum(ac_est, v32_land(j2,type32,ac_est)) - sum(ac_est, pc32_land(j2,type32,ac_est)); + sum(ac_est, v32_land(j2,type32,ac_est)); q32_land_reduction(j2,type32,ac_sub) .. v32_land_reduction(j2,type32,ac_sub) =e= pc32_land(j2,type32,ac_sub) - v32_land(j2,type32,ac_sub); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index d00ddfcab1..e22d1651b4 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -57,7 +57,7 @@ else ); p32_disturbance_loss_ftype32(t,j,"aff",ac_sub) = pc32_land(j,"aff",ac_sub) * f32_forest_shock(t,"%c32_shock_scenario%") * m_timestep_length; -pc32_land(j,"aff",ac_est) = pc32_land(j,"aff",ac_est) + sum(ac_sub,p32_disturbance_loss_ftype32(t,j,"aff",ac_sub))/card(ac_est); +pc32_land(j,"aff",ac_est) = pc32_land(j,"aff",ac_est) + sum(ac_sub,p32_disturbance_loss_ftype32(t,j,"aff",ac_sub))/card(ac_est2); pc32_land(j,"aff",ac_sub) = pc32_land(j,"aff",ac_sub) - p32_disturbance_loss_ftype32(t,j,"aff",ac_sub); @@ -130,7 +130,7 @@ elseif s32_hvarea = 2, ** overwrite bounds for ac_est v32_land.lo(j,"plant",ac_est) = 0; v32_land.up(j,"plant",ac_est) = Inf; -v32_land.l(j,"plant",ac_est) = 0.001; +v32_land.l(j,"plant",ac_est) = 0; ** fix ndc afforestation forever, all age-classes are fixed except ac_est diff --git a/modules/35_natveg/dynamic_feb21/declarations.gms b/modules/35_natveg/dynamic_feb21/declarations.gms index 4dc3d2587f..21a3efa502 100644 --- a/modules/35_natveg/dynamic_feb21/declarations.gms +++ b/modules/35_natveg/dynamic_feb21/declarations.gms @@ -44,9 +44,9 @@ equations q35_min_forest(j) Minimum forest land constraint (mio. ha) q35_min_other(j) Minimum other land constraint (mio. ha) q35_landdiff Difference in natveg land (mio. ha) - q35_other_expansion(j,ac) Other land expansion (mio. ha) + q35_other_expansion(j) Other land expansion (mio. ha) q35_other_reduction(j,ac) Other land reduction (mio. ha) - q35_secdforest_expansion(j,ac) Secdforest reduction (mio. ha) + q35_secdforest_expansion(j) Secdforest reduction (mio. ha) q35_secdforest_reduction(j,ac) Secdforest reduction (mio. ha) q35_primforest_reduction(j) Primforest reduction (mio. ha) q35_secdforest_regeneration(j) Secondary forest remains secondary forest (mio. ha) @@ -70,9 +70,9 @@ positive variables v35_secdforest(j,ac) Detailed stock of secdforest (mio. ha) v35_other(j,ac) Detailed stock of other land (mio. ha) vm_landdiff_natveg Aggregated difference in natveg land compared to previous timestep (mio. ha) - v35_other_expansion(j,ac) Other land expansion compared to previous timestep (mio. ha) + v35_other_expansion(j) Other land expansion compared to previous timestep (mio. ha) v35_other_reduction(j,ac) Other land reduction compared to previous timestep (mio. ha) - v35_secdforest_expansion(j,ac) Secdforest reduction compared to previous timestep (mio. ha) + v35_secdforest_expansion(j) Secdforest reduction compared to previous timestep (mio. ha) v35_secdforest_reduction(j,ac) Secdforest reduction compared to previous timestep (mio. ha) v35_primforest_reduction(j) Primforest reduction compared to previous timestep (mio. ha) v35_hvarea_secdforest(j,ac) Harvested area from secondary forest (mio. ha) @@ -88,9 +88,9 @@ parameters ov35_secdforest(t,j,ac,type) Detailed stock of secdforest (mio. ha) ov35_other(t,j,ac,type) Detailed stock of other land (mio. ha) ov_landdiff_natveg(t,type) Aggregated difference in natveg land compared to previous timestep (mio. ha) - ov35_other_expansion(t,j,ac,type) Other land expansion compared to previous timestep (mio. ha) + ov35_other_expansion(t,j,type) Other land expansion compared to previous timestep (mio. ha) ov35_other_reduction(t,j,ac,type) Other land reduction compared to previous timestep (mio. ha) - ov35_secdforest_expansion(t,j,ac,type) Secdforest reduction compared to previous timestep (mio. ha) + ov35_secdforest_expansion(t,j,type) Secdforest reduction compared to previous timestep (mio. ha) ov35_secdforest_reduction(t,j,ac,type) Secdforest reduction compared to previous timestep (mio. ha) ov35_primforest_reduction(t,j,type) Primforest reduction compared to previous timestep (mio. ha) ov35_hvarea_secdforest(t,j,ac,type) Harvested area from secondary forest (mio. ha) @@ -106,9 +106,9 @@ parameters oq35_min_forest(t,j,type) Minimum forest land constraint (mio. ha) oq35_min_other(t,j,type) Minimum other land constraint (mio. ha) oq35_landdiff(t,type) Difference in natveg land (mio. ha) - oq35_other_expansion(t,j,ac,type) Other land expansion (mio. ha) + oq35_other_expansion(t,j,type) Other land expansion (mio. ha) oq35_other_reduction(t,j,ac,type) Other land reduction (mio. ha) - oq35_secdforest_expansion(t,j,ac,type) Secdforest reduction (mio. ha) + oq35_secdforest_expansion(t,j,type) Secdforest reduction (mio. ha) oq35_secdforest_reduction(t,j,ac,type) Secdforest reduction (mio. ha) oq35_primforest_reduction(t,j,type) Primforest reduction (mio. ha) oq35_secdforest_regeneration(t,j,type) Secondary forest remains secondary forest (mio. ha) diff --git a/modules/35_natveg/dynamic_feb21/equations.gms b/modules/35_natveg/dynamic_feb21/equations.gms index 3c66722468..00218a980b 100644 --- a/modules/35_natveg/dynamic_feb21/equations.gms +++ b/modules/35_natveg/dynamic_feb21/equations.gms @@ -74,23 +74,23 @@ q35_landdiff .. vm_landdiff_natveg =e= sum((j2,ac), - v35_other_expansion(j2,ac) + v35_other_expansion(j2) + v35_other_reduction(j2,ac) - + v35_secdforest_expansion(j2,ac) + + v35_secdforest_expansion(j2) + v35_secdforest_reduction(j2,ac) + v35_primforest_reduction(j2)); - q35_other_expansion(j2,ac_est) .. - v35_other_expansion(j2,ac_est) =e= - v35_other(j2,ac_est) - pc35_other(j2,ac_est); + q35_other_expansion(j2) .. + v35_other_expansion(j2) =e= + sum(ac_est, v35_other(j2,ac_est)); q35_other_reduction(j2,ac_sub) .. v35_other_reduction(j2,ac_sub) =e= pc35_other(j2,ac_sub) - v35_other(j2,ac_sub); - q35_secdforest_expansion(j2,ac_est) .. - v35_secdforest_expansion(j2,ac_est) =e= - v35_secdforest(j2,ac_est) - pc35_secdforest(j2,ac_est); + q35_secdforest_expansion(j2) .. + v35_secdforest_expansion(j2) =e= + sum(ac_est, v35_secdforest(j2,ac_est)); q35_secdforest_reduction(j2,ac_sub) .. v35_secdforest_reduction(j2,ac_sub) =e= diff --git a/modules/35_natveg/dynamic_feb21/postsolve.gms b/modules/35_natveg/dynamic_feb21/postsolve.gms index 085cb4c533..32369cb725 100644 --- a/modules/35_natveg/dynamic_feb21/postsolve.gms +++ b/modules/35_natveg/dynamic_feb21/postsolve.gms @@ -15,9 +15,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); ov35_secdforest(t,j,ac,"marginal") = v35_secdforest.m(j,ac); ov35_other(t,j,ac,"marginal") = v35_other.m(j,ac); ov_landdiff_natveg(t,"marginal") = vm_landdiff_natveg.m; - ov35_other_expansion(t,j,ac,"marginal") = v35_other_expansion.m(j,ac); + ov35_other_expansion(t,j,"marginal") = v35_other_expansion.m(j); ov35_other_reduction(t,j,ac,"marginal") = v35_other_reduction.m(j,ac); - ov35_secdforest_expansion(t,j,ac,"marginal") = v35_secdforest_expansion.m(j,ac); + ov35_secdforest_expansion(t,j,"marginal") = v35_secdforest_expansion.m(j); ov35_secdforest_reduction(t,j,ac,"marginal") = v35_secdforest_reduction.m(j,ac); ov35_primforest_reduction(t,j,"marginal") = v35_primforest_reduction.m(j); ov35_hvarea_secdforest(t,j,ac,"marginal") = v35_hvarea_secdforest.m(j,ac); @@ -33,9 +33,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); oq35_min_forest(t,j,"marginal") = q35_min_forest.m(j); oq35_min_other(t,j,"marginal") = q35_min_other.m(j); oq35_landdiff(t,"marginal") = q35_landdiff.m; - oq35_other_expansion(t,j,ac,"marginal") = q35_other_expansion.m(j,ac); + oq35_other_expansion(t,j,"marginal") = q35_other_expansion.m(j); oq35_other_reduction(t,j,ac,"marginal") = q35_other_reduction.m(j,ac); - oq35_secdforest_expansion(t,j,ac,"marginal") = q35_secdforest_expansion.m(j,ac); + oq35_secdforest_expansion(t,j,"marginal") = q35_secdforest_expansion.m(j); oq35_secdforest_reduction(t,j,ac,"marginal") = q35_secdforest_reduction.m(j,ac); oq35_primforest_reduction(t,j,"marginal") = q35_primforest_reduction.m(j); oq35_secdforest_regeneration(t,j,"marginal") = q35_secdforest_regeneration.m(j); @@ -56,9 +56,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); ov35_secdforest(t,j,ac,"level") = v35_secdforest.l(j,ac); ov35_other(t,j,ac,"level") = v35_other.l(j,ac); ov_landdiff_natveg(t,"level") = vm_landdiff_natveg.l; - ov35_other_expansion(t,j,ac,"level") = v35_other_expansion.l(j,ac); + ov35_other_expansion(t,j,"level") = v35_other_expansion.l(j); ov35_other_reduction(t,j,ac,"level") = v35_other_reduction.l(j,ac); - ov35_secdforest_expansion(t,j,ac,"level") = v35_secdforest_expansion.l(j,ac); + ov35_secdforest_expansion(t,j,"level") = v35_secdforest_expansion.l(j); ov35_secdforest_reduction(t,j,ac,"level") = v35_secdforest_reduction.l(j,ac); ov35_primforest_reduction(t,j,"level") = v35_primforest_reduction.l(j); ov35_hvarea_secdforest(t,j,ac,"level") = v35_hvarea_secdforest.l(j,ac); @@ -74,9 +74,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); oq35_min_forest(t,j,"level") = q35_min_forest.l(j); oq35_min_other(t,j,"level") = q35_min_other.l(j); oq35_landdiff(t,"level") = q35_landdiff.l; - oq35_other_expansion(t,j,ac,"level") = q35_other_expansion.l(j,ac); + oq35_other_expansion(t,j,"level") = q35_other_expansion.l(j); oq35_other_reduction(t,j,ac,"level") = q35_other_reduction.l(j,ac); - oq35_secdforest_expansion(t,j,ac,"level") = q35_secdforest_expansion.l(j,ac); + oq35_secdforest_expansion(t,j,"level") = q35_secdforest_expansion.l(j); oq35_secdforest_reduction(t,j,ac,"level") = q35_secdforest_reduction.l(j,ac); oq35_primforest_reduction(t,j,"level") = q35_primforest_reduction.l(j); oq35_secdforest_regeneration(t,j,"level") = q35_secdforest_regeneration.l(j); @@ -97,9 +97,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); ov35_secdforest(t,j,ac,"upper") = v35_secdforest.up(j,ac); ov35_other(t,j,ac,"upper") = v35_other.up(j,ac); ov_landdiff_natveg(t,"upper") = vm_landdiff_natveg.up; - ov35_other_expansion(t,j,ac,"upper") = v35_other_expansion.up(j,ac); + ov35_other_expansion(t,j,"upper") = v35_other_expansion.up(j); ov35_other_reduction(t,j,ac,"upper") = v35_other_reduction.up(j,ac); - ov35_secdforest_expansion(t,j,ac,"upper") = v35_secdforest_expansion.up(j,ac); + ov35_secdforest_expansion(t,j,"upper") = v35_secdforest_expansion.up(j); ov35_secdforest_reduction(t,j,ac,"upper") = v35_secdforest_reduction.up(j,ac); ov35_primforest_reduction(t,j,"upper") = v35_primforest_reduction.up(j); ov35_hvarea_secdforest(t,j,ac,"upper") = v35_hvarea_secdforest.up(j,ac); @@ -115,9 +115,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); oq35_min_forest(t,j,"upper") = q35_min_forest.up(j); oq35_min_other(t,j,"upper") = q35_min_other.up(j); oq35_landdiff(t,"upper") = q35_landdiff.up; - oq35_other_expansion(t,j,ac,"upper") = q35_other_expansion.up(j,ac); + oq35_other_expansion(t,j,"upper") = q35_other_expansion.up(j); oq35_other_reduction(t,j,ac,"upper") = q35_other_reduction.up(j,ac); - oq35_secdforest_expansion(t,j,ac,"upper") = q35_secdforest_expansion.up(j,ac); + oq35_secdforest_expansion(t,j,"upper") = q35_secdforest_expansion.up(j); oq35_secdforest_reduction(t,j,ac,"upper") = q35_secdforest_reduction.up(j,ac); oq35_primforest_reduction(t,j,"upper") = q35_primforest_reduction.up(j); oq35_secdforest_regeneration(t,j,"upper") = q35_secdforest_regeneration.up(j); @@ -138,9 +138,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); ov35_secdforest(t,j,ac,"lower") = v35_secdforest.lo(j,ac); ov35_other(t,j,ac,"lower") = v35_other.lo(j,ac); ov_landdiff_natveg(t,"lower") = vm_landdiff_natveg.lo; - ov35_other_expansion(t,j,ac,"lower") = v35_other_expansion.lo(j,ac); + ov35_other_expansion(t,j,"lower") = v35_other_expansion.lo(j); ov35_other_reduction(t,j,ac,"lower") = v35_other_reduction.lo(j,ac); - ov35_secdforest_expansion(t,j,ac,"lower") = v35_secdforest_expansion.lo(j,ac); + ov35_secdforest_expansion(t,j,"lower") = v35_secdforest_expansion.lo(j); ov35_secdforest_reduction(t,j,ac,"lower") = v35_secdforest_reduction.lo(j,ac); ov35_primforest_reduction(t,j,"lower") = v35_primforest_reduction.lo(j); ov35_hvarea_secdforest(t,j,ac,"lower") = v35_hvarea_secdforest.lo(j,ac); @@ -156,9 +156,9 @@ p35_other(t,j,ac) = v35_other.l(j,ac); oq35_min_forest(t,j,"lower") = q35_min_forest.lo(j); oq35_min_other(t,j,"lower") = q35_min_other.lo(j); oq35_landdiff(t,"lower") = q35_landdiff.lo; - oq35_other_expansion(t,j,ac,"lower") = q35_other_expansion.lo(j,ac); + oq35_other_expansion(t,j,"lower") = q35_other_expansion.lo(j); oq35_other_reduction(t,j,ac,"lower") = q35_other_reduction.lo(j,ac); - oq35_secdforest_expansion(t,j,ac,"lower") = q35_secdforest_expansion.lo(j,ac); + oq35_secdforest_expansion(t,j,"lower") = q35_secdforest_expansion.lo(j); oq35_secdforest_reduction(t,j,ac,"lower") = q35_secdforest_reduction.lo(j,ac); oq35_primforest_reduction(t,j,"lower") = q35_primforest_reduction.lo(j); oq35_secdforest_regeneration(t,j,"lower") = q35_secdforest_regeneration.lo(j); diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index b2a9ca33af..3c62ba8d0f 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -41,7 +41,7 @@ if(s35_forest_damage=4, ); * Distribution of damages correctly -pc35_secdforest(j,ac_est) = pc35_secdforest(j,ac_est) + sum(ac_sub,p35_disturbance_loss_secdf(t,j,ac_sub))/card(ac_est) + p35_disturbance_loss_primf(t,j)/card(ac_est); +pc35_secdforest(j,ac_est) = pc35_secdforest(j,ac_est) + sum(ac_sub,p35_disturbance_loss_secdf(t,j,ac_sub))/card(ac_est2) + p35_disturbance_loss_primf(t,j)/card(ac_est2); pc35_secdforest(j,ac_sub) = pc35_secdforest(j,ac_sub) - p35_disturbance_loss_secdf(t,j,ac_sub); pcm_land(j,"primforest") = pcm_land(j,"primforest") - p35_disturbance_loss_primf(t,j); diff --git a/modules/35_natveg/dynamic_feb21/scaling.gms b/modules/35_natveg/dynamic_feb21/scaling.gms index 449a174513..0e395c335b 100644 --- a/modules/35_natveg/dynamic_feb21/scaling.gms +++ b/modules/35_natveg/dynamic_feb21/scaling.gms @@ -5,9 +5,9 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -v35_other_expansion.scale(j,ac) = 10e-3; +v35_other_expansion.scale(j) = 10e-3; v35_other_reduction.scale(j,ac) = 10e-3; -v35_secdforest_expansion.scale(j,ac) = 10e-3; +v35_secdforest_expansion.scale(j) = 10e-3; v35_secdforest_reduction.scale(j,ac) = 10e-3; v35_hvarea_other.scale(j,ac) = 10e-3; vm_cost_hvarea_natveg.scale(i)$(s35_hvarea = 1 OR s35_hvarea = 2) = 10e4; From 207de3e713d2e0ae98c4d605bc169571710539cd Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 15 Jan 2024 14:41:27 +0100 Subject: [PATCH 105/187] bugfix in way fruitveg2other parameter is written into the future --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e6b92954f1..90e5dd239f 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -462,7 +462,7 @@ elseif (s15_exo_diet = 3), if (sum(sameas(t_past,t),1) = 1, i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t,i,EAT_special)); else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t-1,i,EAT_special)); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = i15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); ); *' Separation of starchy fruits (bananas and plantains) From 24b22c49ed1c77f612acccf58cbba96a52965ce5 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 15 Jan 2024 15:27:08 +0100 Subject: [PATCH 106/187] bugfixes ac_est --- modules/35_natveg/dynamic_feb21/equations.gms | 6 +++--- modules/44_biodiversity/bii_target/equations.gms | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/35_natveg/dynamic_feb21/equations.gms b/modules/35_natveg/dynamic_feb21/equations.gms index 00218a980b..78a0b98e45 100644 --- a/modules/35_natveg/dynamic_feb21/equations.gms +++ b/modules/35_natveg/dynamic_feb21/equations.gms @@ -73,11 +73,11 @@ *' This information is then passed to the land module ([10_land]): q35_landdiff .. vm_landdiff_natveg =e= - sum((j2,ac), + sum(j2, v35_other_expansion(j2) - + v35_other_reduction(j2,ac) + + sum(ac_sub, v35_other_reduction(j2,ac_sub)) + v35_secdforest_expansion(j2) - + v35_secdforest_reduction(j2,ac) + + sum(ac_sub, v35_secdforest_reduction(j2,ac_sub)) + v35_primforest_reduction(j2)); q35_other_expansion(j2) .. diff --git a/modules/44_biodiversity/bii_target/equations.gms b/modules/44_biodiversity/bii_target/equations.gms index c1aec812a0..681e398e4e 100644 --- a/modules/44_biodiversity/bii_target/equations.gms +++ b/modules/44_biodiversity/bii_target/equations.gms @@ -10,14 +10,14 @@ *' The Biodiversity Intactness Index (BII) is calculated at the level of 71 biomes. *' The regional layer is needed for compatibility with the high resolution parallel optimization output script (scripts/output/extra/highres.R) - q44_bii(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 0) .. v44_bii(i2,biome44) + q44_bii(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 1e-10) .. v44_bii(i2,biome44) =e= (sum((cell(i2,j2),potnatveg,landcover44), vm_bv(j2,landcover44,potnatveg) * f44_biome(j2,biome44)) / sum((cell(i2,j2),land), pcm_land(j2,land) * f44_biome(j2,biome44))); *' For each of the 71 biomes, the BII has to meet a minium level based on `s44_bii_lower_bound`. *' `v44_bii_missing` is a technical variable to maintain feasibility in case `v44_bii` cannot be increased. - q44_bii_target(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 0) .. + q44_bii_target(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 1e-10) .. v44_bii(i2,biome44) + v44_bii_missing(i2,biome44) =g= sum(ct, p44_bii_lower_bound(ct,i2,biome44)); *' Costs accrue only for `v44_bii_missing`. In the best case costs should be zero or close to zero. From 0800985ea46042a5b9b46ac5ce28329f26df0f5f Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 15 Jan 2024 17:04:12 +0100 Subject: [PATCH 107/187] bugfixes ac_est --- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index e22d1651b4..97b4f3db0b 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -130,7 +130,7 @@ elseif s32_hvarea = 2, ** overwrite bounds for ac_est v32_land.lo(j,"plant",ac_est) = 0; v32_land.up(j,"plant",ac_est) = Inf; -v32_land.l(j,"plant",ac_est) = 0; +v32_land.l(j,"plant",ac_est) = 0.001; ** fix ndc afforestation forever, all age-classes are fixed except ac_est From ca7be922bc4c73039a1e2b9e9ccf1ee2e1d1ee78 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 15 Jan 2024 20:55:10 +0100 Subject: [PATCH 108/187] bugfix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdf140693e..da44c64838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### fixed - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k - **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs +- **35_natveg** bugfixes ac_est ## [4.7.0] - 2023-12-11 From 94a5319c1c6bfaf0692f4a3dbbcd93866124757f Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 15 Jan 2024 20:59:27 +0100 Subject: [PATCH 109/187] bugfix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da44c64838..811abac497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k - **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs - **35_natveg** bugfixes ac_est +- **44_biodiversity** bugfix condition for constraints ## [4.7.0] - 2023-12-11 From 1b6d0dfa193ad45ea8625c30755f243bb1f52eb9 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 16 Jan 2024 23:08:01 +0100 Subject: [PATCH 110/187] clean up recalibration scripts --- scripts/start/extra/recalibrate.R | 29 ---------- scripts/start/extra/recalibrate_all.R | 54 ------------------- ...nversion_costs.R => recalibrate_default.R} | 11 ++-- .../start/extra/recalibrate_realizations.R | 6 +-- 4 files changed, 5 insertions(+), 95 deletions(-) delete mode 100644 scripts/start/extra/recalibrate.R delete mode 100644 scripts/start/extra/recalibrate_all.R rename scripts/start/extra/{recalibrate_land_conversion_costs.R => recalibrate_default.R} (83%) diff --git a/scripts/start/extra/recalibrate.R b/scripts/start/extra/recalibrate.R deleted file mode 100644 index e769c0f279..0000000000 --- a/scripts/start/extra/recalibrate.R +++ /dev/null @@ -1,29 +0,0 @@ -# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | MAgPIE License Exception, version 1.0 (see LICENSE file). -# | Contact: magpie@pik-potsdam.de - -# -------------------------------------------------------- -# description: calculate and store new calibration factors for yields -# for default setup (land conversion cost calibration factors are only calculated if needed) -# -------------------------------------------------------- - -library(magpie4) -library(magclass) - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -#start MAgPIE run -source("config/default.cfg") -cfg$results_folder <- "output/:title:" -cfg$recalibrate <- TRUE -cfg$recalibrate_landconversion_cost <- "ifneeded" -cfg$title <- "calib_run" -cfg$output <- c("rds_report","validation_short") -cfg$force_replace <- TRUE -cfg$best_calib <- TRUE -start_run(cfg,codeCheck=FALSE) -magpie4::submitCalibration("H12") diff --git a/scripts/start/extra/recalibrate_all.R b/scripts/start/extra/recalibrate_all.R deleted file mode 100644 index 7586968782..0000000000 --- a/scripts/start/extra/recalibrate_all.R +++ /dev/null @@ -1,54 +0,0 @@ -# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | MAgPIE License Exception, version 1.0 (see LICENSE file). -# | Contact: magpie@pik-potsdam.de - -# -------------------------------------------------------- -# description: calculate and store new calibration factors for yields AND -# land conversion costs for default setup -# (time consuming; up to 40 model runs with 1 or 5 time steps) -# -------------------------------------------------------- - -library(magpie4) -library(magclass) - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -# Start MAgPIE run -source("config/default.cfg") -cfg$results_folder <- "output/:title:" - -## Yield calibration -cfg$recalibrate <- TRUE -# Up to which accuracy shall be recalibrated? -cfg$calib_accuracy <- 0.05 # def = 0.05 -# What is the maximum number of iterations if the precision goal is not reached? -cfg$calib_maxiter <- 20 # def = 20 -cfg$damping_factor <- 0.96 # def= 0.96 - -cfg$best_calib <- TRUE # def = TRUE - -## Land conversion cost calibration -cfg$recalibrate_landconversion_cost <- TRUE -# Up to which accuracy shall be recalibrated? -cfg$calib_accuracy_landconversion_cost <- 0.05 # def = 0.05 -# What is the maximum number of iterations if the precision goal is not reached? -cfg$calib_maxiter_landconversion_cost <- 40 # def = 40 -cfg$best_calib_landconversion_cost <- FALSE # def = FALSE - -# set upper limit for cropland calibration factor -cfg$cost_calib_max_landconversion_cost <- 3 # def= 3 -# set lower limit for cropland calibration factor -cfg$cost_calib_min_landconversion_cost <- 0.05 # def= 0.05 - -# factor determining how much the new calibration factor influences the result (0-1) -cfg$damping_factor_landconversion_cost <- 0.96 # def= 0.96 - -cfg$title <- "calib_run" -cfg$output <- c("rds_report","validation_short") -cfg$force_replace <- TRUE -start_run(cfg, codeCheck = FALSE) -magpie4::submitCalibration("H12") diff --git a/scripts/start/extra/recalibrate_land_conversion_costs.R b/scripts/start/extra/recalibrate_default.R similarity index 83% rename from scripts/start/extra/recalibrate_land_conversion_costs.R rename to scripts/start/extra/recalibrate_default.R index d07d5f9519..2980b6afa4 100644 --- a/scripts/start/extra/recalibrate_land_conversion_costs.R +++ b/scripts/start/extra/recalibrate_default.R @@ -6,7 +6,7 @@ # | Contact: magpie@pik-potsdam.de # -------------------------------------------------------- -# description: calculate and store new land conversion cost calibration factors for default setup (time consuming; up to 40 model runs with 1 or 5 time steps) +# description: calculate and store new land conversion cost calibration factors for default setup (time consuming; up to 40 model runs with 5 time steps) # -------------------------------------------------------- library(magpie4) @@ -18,13 +18,8 @@ source("scripts/start_functions.R") #start MAgPIE run source("config/default.cfg") cfg$results_folder <- "output/:title:" - -cfg$recalibrate_landconversion_cost <- TRUE -cfg$best_calib_landconversion_cost <- FALSE - -cfg$recalibrate <- "ifneeded" -cfg$gms$c_timesteps <- 5 -cfg$sequential <- TRUE +cfg$recalibrate <- FALSE +cfg$recalibrate_landconversion_cost <- "ifneeded" cfg$title <- "calib_run" cfg$output <- c("rds_report","validation_short") cfg$force_replace <- TRUE diff --git a/scripts/start/extra/recalibrate_realizations.R b/scripts/start/extra/recalibrate_realizations.R index 0b33c7b95c..02a86b1499 100644 --- a/scripts/start/extra/recalibrate_realizations.R +++ b/scripts/start/extra/recalibrate_realizations.R @@ -6,9 +6,7 @@ # | Contact: magpie@pik-potsdam.de # -------------------------------------------------------- -# description: calculate and store new yield and -# land conversion cost calib factors -# for realizations of factor costs +# description: calculate and store new land conversion cost calibration factors for all factor cost module realizations (time consuming; up to 40 model runs with 5 time steps) # -------------------------------------------------------- library(magpie4) @@ -24,7 +22,7 @@ realizations <- c("per_ton_fao_may22", "sticky_feb18") # "sticky_labor" is very type <- NULL cfg$results_folder <- "output/:title:" -cfg$recalibrate <- TRUE +cfg$recalibrate <- FALSE cfg$recalibrate_landconversion_cost <- TRUE cfg$output <- c("rds_report", "validation_short") From 4224f7bc7002e1fd2f6e2ed59cdfc88fb12b4bc5 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 17 Jan 2024 12:39:36 +0100 Subject: [PATCH 111/187] FSEC calibration script --- scripts/start/extra/recalibrate_FSEC.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/start/extra/recalibrate_FSEC.R b/scripts/start/extra/recalibrate_FSEC.R index 22c894b2d1..0e7313584a 100644 --- a/scripts/start/extra/recalibrate_FSEC.R +++ b/scripts/start/extra/recalibrate_FSEC.R @@ -6,9 +6,9 @@ # | Contact: magpie@pik-potsdam.de # -------------------------------------------------------- -# description: calculate and store new calibration factors for yields AND +# description: calculate and store new calibration factors for # land conversion costs for FSEC regional setup -# (time consuming; up to 40 model runs with 1 or 5 time steps) +# (time consuming; up to 40 model runs with 5 time steps) # -------------------------------------------------------- library(magpie4) @@ -22,7 +22,7 @@ source("scripts/projects/fsec.R") cfg <- fsecScenario(scenario = "c_BAU") cfg$title <- "FSEC24Mar23" cfg$results_folder <- "output/:title:" -cfg$recalibrate <- TRUE # required when penality_apr22 activated +cfg$recalibrate <- FALSE # required when penality_apr22 activated cfg$best_calib <- TRUE cfg$recalibrate_landconversion_cost <- TRUE cfg$best_calib_landconversion_cost <- FALSE From a200ed486c2fc4f2dff623b9c5f299bf11227b84 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 17 Jan 2024 15:06:59 +0100 Subject: [PATCH 112/187] bugfix balancing equation --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 90e5dd239f..d95482cbcc 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -387,7 +387,7 @@ if (s15_exo_diet = 1, * (Note: The old EATLancet implementation should be deleted soon.) *---------------------------------------------------------------------------------------- -elseif (s15_exo_diet = 3), +elseif s15_exo_diet = 3, *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), *' model-internal diet projections are constrained by recommended ranges for intake *' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable @@ -593,7 +593,7 @@ elseif (s15_exo_diet = 3), *' in step 1.) selected total calorie intake is met. *' Note that brans do not have an EAT Lancet target and are kept at their *' original level. - i15_intake_detailed_scen_target(t,iso,EAT_staples) = + i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); From 891002289d99142cca5db978927da5e611e6580a Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 17 Jan 2024 15:43:10 +0100 Subject: [PATCH 113/187] revert back bii condition --- CHANGELOG.md | 1 - modules/44_biodiversity/bii_target/equations.gms | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 811abac497..da44c64838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k - **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs - **35_natveg** bugfixes ac_est -- **44_biodiversity** bugfix condition for constraints ## [4.7.0] - 2023-12-11 diff --git a/modules/44_biodiversity/bii_target/equations.gms b/modules/44_biodiversity/bii_target/equations.gms index 681e398e4e..c1aec812a0 100644 --- a/modules/44_biodiversity/bii_target/equations.gms +++ b/modules/44_biodiversity/bii_target/equations.gms @@ -10,14 +10,14 @@ *' The Biodiversity Intactness Index (BII) is calculated at the level of 71 biomes. *' The regional layer is needed for compatibility with the high resolution parallel optimization output script (scripts/output/extra/highres.R) - q44_bii(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 1e-10) .. v44_bii(i2,biome44) + q44_bii(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 0) .. v44_bii(i2,biome44) =e= (sum((cell(i2,j2),potnatveg,landcover44), vm_bv(j2,landcover44,potnatveg) * f44_biome(j2,biome44)) / sum((cell(i2,j2),land), pcm_land(j2,land) * f44_biome(j2,biome44))); *' For each of the 71 biomes, the BII has to meet a minium level based on `s44_bii_lower_bound`. *' `v44_bii_missing` is a technical variable to maintain feasibility in case `v44_bii` cannot be increased. - q44_bii_target(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 1e-10) .. + q44_bii_target(i2,biome44)$(sum(cell(i2,j2), f44_biome(j2,biome44)) > 0) .. v44_bii(i2,biome44) + v44_bii_missing(i2,biome44) =g= sum(ct, p44_bii_lower_bound(ct,i2,biome44)); *' Costs accrue only for `v44_bii_missing`. In the best case costs should be zero or close to zero. From 9195bccf342bc7ea74846626f8d0d2eb9bef43b0 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 17 Jan 2024 16:02:19 +0100 Subject: [PATCH 114/187] separation of targets is now the same as before (monogastric and ruminant) rather than redmeat and poultry --- config/default.cfg | 6 +-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 43 ++++++++----------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index e2d5cb9d8c..dd7829c9db 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -461,10 +461,8 @@ cfg$gms$c15_EAT_scen <- "FLX" # def = FLX # * included, while the others will remain to be endogenous. # * Any shift will be compensated to reach the calorie target by adjusting # * staple calories. -cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) -cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 1) -cfg$gms$s15_exo_redmeatdairy <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) -cfg$gms$s15_exo_poultry <- 1 # def = 1, options: 0,1 (only relevant for s15_exo_diet = 3) +cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index d95482cbcc..2ed0b672bf 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -404,36 +404,37 @@ elseif s15_exo_diet = 3, p15_intake_detail(t,iso,kfo)$(sum(EATtar_kfo15(EAT_mtargets15_2,kfo), sum(EATtar_kfo15_2(EAT_mtargets15_2,kfo2), p15_intake_detail(t,iso,kfo2))) = 0) = p15_intake_detail(t,iso,kfo) + 1e-6; -* FELI: Check whether this is still necessary when the targets are split -* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail -* to grams using - -*' The single targets can also be set manually via switches +*' The single targets can be set manually via switches *' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). -*' upper bound for chicken and eggs - if (s15_exo_poultry = 1, +*' upper bound for monogastric products + if (s15_exo_monogastric = 1, * upper bound for eggs i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") > i15_rec_EATLancet(iso,"t_livst_egg","max") ) = i15_rec_EATLancet(iso,"t_livst_egg","max"); - * upper bound for chicken i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") - > i15_rec_EATLancet(iso,"t_livst_chick","max") + > i15_rec_EATLancet(iso,"t_livst_chick","max") + ) = + i15_rec_EATLancet(iso,"t_livst_chick","max"); +* upper bound for redmeat (share of pigs in redmeat) + i15_intake_detailed_scen_target(t,iso,"livst_pig")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > i15_rec_EATLancet(iso,"t_redmeat","max") ) = - i15_rec_EATLancet(iso,"t_livst_chick","max"); + (p15_intake_detail(t,iso,"livst_pig") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) + * i15_rec_EATLancet(iso,"t_redmeat","max"); ); -*' upper bound for redmeat and milk - if (s15_exo_redmeatdairy = 1, +*' upper bound for ruminant products + if (s15_exo_ruminant = 1, * upper bound for redmeat (pig and ruminant) - i15_intake_detailed_scen_target(t,iso,EAT_redmeat15)$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + i15_intake_detailed_scen_target(t,iso,"livst_rum")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) > i15_rec_EATLancet(iso,"t_redmeat","max") ) = - (p15_intake_detail(t,iso,EAT_redmeat15) / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) + (p15_intake_detail(t,iso,"livst_rum") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) * i15_rec_EATLancet(iso,"t_redmeat","max"); * upper bound for milk i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") @@ -574,6 +575,7 @@ elseif s15_exo_diet = 3, *' There is no explicit target for brans in the EATLancet recommendations. *' It is therefore set to 0. *** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level or including it as part of staples. +*** To Do: exclude from both old and new (as last step when approval for the rest of the implementation by Benni/Isabelle) if (s15_exo_brans = 1, i15_intake_detailed_scen_target(t,iso,"brans") = 0; ); @@ -583,10 +585,6 @@ elseif s15_exo_diet = 3, i15_intake_detailed_scen_target(t,iso,"scp") = 0; ); - -* To Do: transform i15_intake_detailed_scen_target and i15_intake_scen_target and p15_intake_detail -* back to kcal using i15_protein_to_kcal_ratio - *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, *' intake of staple crops is now modified such that the @@ -597,11 +595,8 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); -display i15_intake_detailed_scen_target; - -**** FELI: Check whether it gets negative... And come up with solution for fixing this... (Maybe via positive declaration / setting everyting that's negative to 0?) -* BENNI: What if EATLancet leads to too much calories? Just allow higher values? -* JAN: Can a parameter be declared as positive? Or only variables? + if (i15_intake_detailed_scen_target(t,iso,EAT_staples) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing.", i15_intake_detailed_scen_target(t,iso,EAT_staples);); +* JAN: Is there if(any(x)) in GAMS? Or does this above check for each individual and therefore is a if any? ); *** End of MAgPIE-specific realization of the EAT Lancet diet @@ -616,8 +611,6 @@ display i15_intake_detailed_scen_target; p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); -display p15_intake_detail; - ); *** End of special postprocessing food demand scenarios. From 400eb2d02946b0fb37c25bb95542d9b6de123cb4 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 13:07:26 +0100 Subject: [PATCH 115/187] abort statement if intake_detail_scen_target is negative --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 2ed0b672bf..d2b6437ec3 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -595,8 +595,10 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); - if (i15_intake_detailed_scen_target(t,iso,EAT_staples) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing.", i15_intake_detailed_scen_target(t,iso,EAT_staples);); -* JAN: Is there if(any(x)) in GAMS? Or does this above check for each individual and therefore is a if any? + if (smin((iso,EAT_staples), i15_intake_detailed_scen_target(t,iso,EAT_staples)) < 0, + abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + ); + ); *** End of MAgPIE-specific realization of the EAT Lancet diet From c121a679a8552d3e5a75f9ffa0456ddb62018dc1 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 15:47:36 +0100 Subject: [PATCH 116/187] clean-up --- CHANGELOG.md | 4 +- config/default.cfg | 4 +- .../15_food/anthro_iso_jun22/realization.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 1 - scripts/start/projects/test_eat2_standalone.R | 23 --- .../projects/test_fooddemand_standalone.R | 25 --- standalone/eat2.gms | 161 ------------------ 7 files changed, 5 insertions(+), 215 deletions(-) delete mode 100644 scripts/start/projects/test_eat2_standalone.R delete mode 100644 scripts/start/projects/test_fooddemand_standalone.R delete mode 100644 standalone/eat2.gms diff --git a/CHANGELOG.md b/CHANGELOG.md index c07daa02d0..41f6ac6a44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed -- **15_food** Added new EAT Lancet diet implementation +- **15_food** Added improved EAT Lancet diet implementation - **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` - **scenario_config.csv** removed erroneous setting `cc` from column `input` - **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` -- **default.cfg** update input data to rev 4.96 +- **default.cfg** update input data to rev 4.97 ### added - **32_forestry** new interfaces `vm_land_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` diff --git a/config/default.cfg b/config/default.cfg index dd7829c9db..c5c3857bfc 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -474,14 +474,14 @@ cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. -# * only activated if s15_exo_diet is > 0 +# * only activated if s15_exo_diet is set to 1 cfg$gms$s15_exo_alcohol <- 1 # default: 1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 -# BENNI: I (Feli) would suggest to set it to 0 because otherwise it is not in line with EATLancet, +# BENNI: I (Feli) would suggest to set s15_exo_alcohol to 0 in default because otherwise it is not in line with EATLancet, # but that would be what the user expects! It would be better if the user manually has to set it to 0.014 # when (s)he wants to divert from the standard EATLancet setting! # diff --git a/modules/15_food/anthro_iso_jun22/realization.gms b/modules/15_food/anthro_iso_jun22/realization.gms index 724e75d087..e2c4c14760 100644 --- a/modules/15_food/anthro_iso_jun22/realization.gms +++ b/modules/15_food/anthro_iso_jun22/realization.gms @@ -45,4 +45,4 @@ $Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthro_iso_jun22/posts *' diet scenarios, most importantly the shift to the Planetary Health diet *' [@willett_food_2019]. *' -*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier, Marco Springmann +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 35fdb73429..c8a241c6e9 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -204,7 +204,6 @@ sets livst_rum, livst_pig, livst_chick, livst_egg, livst_milk, fish, others / -* Isabelle's code: EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendations / min, max / diff --git a/scripts/start/projects/test_eat2_standalone.R b/scripts/start/projects/test_eat2_standalone.R deleted file mode 100644 index 1f0bfa3acb..0000000000 --- a/scripts/start/projects/test_eat2_standalone.R +++ /dev/null @@ -1,23 +0,0 @@ -# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | MAgPIE License Exception, version 1.0 (see LICENSE file). -# | Contact: magpie@pik-potsdam.de - - -# ---------------------------------------------------------- -# description: Food Demand Standalone -# ---------------------------------------------------------- - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -# start MAgPIE run -source("config/default.cfg") -cfg$model <- "standalone/eat2.gms" -cfg$recalibrate <- FALSE -cfg$gms$c_timesteps <- "1" - -cfg$title <- "test1" -start_run(cfg = cfg) diff --git a/scripts/start/projects/test_fooddemand_standalone.R b/scripts/start/projects/test_fooddemand_standalone.R deleted file mode 100644 index 9a3d3a07dd..0000000000 --- a/scripts/start/projects/test_fooddemand_standalone.R +++ /dev/null @@ -1,25 +0,0 @@ -# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | MAgPIE License Exception, version 1.0 (see LICENSE file). -# | Contact: magpie@pik-potsdam.de - - -# ---------------------------------------------------------- -# description: Food Demand Standalone -# ---------------------------------------------------------- - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -# start MAgPIE run -source("config/default.cfg") -cfg$model <- "standalone/demand_model.gms" -cfg$recalibrate <- FALSE -cfg$gms$c_timesteps <- "pastandfuture" -cfg$gms$s15_calibrate <- 1 -cfg$gms$s15_elastic_demand <- 0 - -cfg$title <- "test1" -start_run(cfg = cfg) diff --git a/standalone/eat2.gms b/standalone/eat2.gms deleted file mode 100644 index 3e22bdf607..0000000000 --- a/standalone/eat2.gms +++ /dev/null @@ -1,161 +0,0 @@ -*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -*** | authors, and contributors see CITATION.cff file. This file is part -*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -*** | AGPL-3.0, you are granted additional permissions described in the -*** | MAgPIE License Exception, version 1.0 (see LICENSE file). -*** | Contact: magpie@pik-potsdam.de - -* This is a standalone skeleton which should be used as template -* if only parts of the model should be run. It contains the basic, -* structural components of the model. -* To use it, please copy this file, give it an explaining name and -* save it in the "models" folder. After that you can modify it based -* on the given requirements. You can add own code, but also delete -* code (e.g. the model statement or the provided loops) if these parts -* are irrelevant for your analysis. - -$title eatLancetDiet2 - -$offupper -$offsymxref -$offsymlist -$offlisting - -$setglobal c_timesteps "1" -$setglobal c_past "till_1995" -$setglobal c_title default - -scalars -s_use_gdx use of gdx files / 0 / -; - -*******************************MODULE SETUP************************************* -$setglobal drivers aug17 -$setglobal food anthro_iso_jun22 - -***************************PREDEFINED MACROS************************************ -$include "./core/macros.gms" - -***************************BASIC SETS INDICES*********************************** -$include "./core/sets.gms" -$batinclude "./modules/include.gms" sets - -***** BENNI: What would I need that for? Isn't it enough to have them defined in the module? -*sets -* exampleset / elem1, elem2, elem3 / -*; - -**********INTRODUCE CALCULATION PARAMETERS, VARIABLES AND EQUATIONS************* -$include "./core/declarations.gms" -$batinclude "./modules/include.gms" declarations - -*parameters -* p_example(exampleset) example parameter (1) -*; - -*variables -* v_example example variable (1) -*; - -*equations -* q_example example equation (1) -*; - -*****************************IMPORT DATA FILES********************************** -$batinclude "./modules/include.gms" input - -********************OBJECTIVE FUNCTION & CONSTRAINTS**************************** -$batinclude "./modules/include.gms" equations - -*q_example .. -* v_example =g= sum(exampleset, p_example(exampleset)); - - -*******************MODEL DEFINITION & SOLVER OPTIONS**************************** -model magpie / all - m15_food_demand /; -magpie.scaleopt = 1 ; -magpie.holdfixed = 1 ; - -option lp = cplex ; -option nlp = conopt4 ; -option iterlim = 1000000 ; -option reslim = 1000000 ; -option sysout = Off ; -option savepoint = 1 ; - -*model example / q_example /; - -*****************************VARIABLE SCALING*********************************** -$batinclude "./modules/include.gms" scaling - -****************************PREPROCESSING START********************************* -* In this section everything is calculated that is not influenced by the -* optimization process. Hence these lines CAN INFLUENCE the optimization process -* but CANNOT BE INFLUENCED by it. - -$batinclude "./modules/include.gms" preloop - -*p_example(exampleset) = 1; - -* create dummy file (this is necessary to be able to use put_utility and it has -* to be done here because a file declaration cannot be inside a loop -file dummy; dummy.pw=2000; put dummy; - -************************OPTIMIZATION PROCESS START****************************** -* This section contains only sourcecode that is directly connected to the -* optimization process. That means that everything on the following lines -* INFLUENCES and IS INFLUENCED by the optimization process (except the -* redefinition on preprocessed data). -* Hence one can describe this section together with the constraints section -* as "model-core". - -* clear ct set -ct(t) = no; - -***************************TIMESTEP LOOP START********************************** -loop (t, - -* set ct to current time period - ct(t) = yes; - display "Year"; - display ct; - -$batinclude "./modules/include.gms" presolve - -* intersolve for food demand model - sm_intersolve = 0; - - while(sm_intersolve = 0, - -*************************SOLVE STATEMENT START********************************** -* #### additional phases ### -* set additional phases which should be detected by -* update_module_embeddings. Most phases will be detected automatically, -* but batincludes used within a module are not detected and therefore -* have to be set manually! (Syntax: "* !add_phase!: ") -* !add_phase!: nl_fix -* !add_phase!: nl_release -* !add_phase!: nl_relax - -$batinclude "./modules/include.gms" solve - -* intersolve for food demand model - sm_intersolve = 1; -* solve example USING lp MINIMIZING v_example; - - -$batinclude "./modules/include.gms" intersolve - - ); - -**************************SOLVE STATEMENT END*********************************** - -$batinclude "./modules/include.gms" postsolve - -**********************WRITE ALL DATA IN 1 GDX FILE****************************** - Execute_Unload "fulldata.gdx"; - -* clear ct set - ct(t) = no; -); -****************************TIMESTEP LOOP END*********************************** From 0f666a3bc3627a25443a76712ba18406f95ae62e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 16:06:47 +0100 Subject: [PATCH 117/187] clean up after check worflow run failed --- scripts/output/extra/disaggregation_LUH2.R | 12 ++++++------ scripts/start/projects/project_EAT2p0.R | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index b5f18049b8..461d98e197 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -226,10 +226,10 @@ gc() #check for dynamic foresty if(!is.null(harvested_area_timber(gdx,level = "cell"))) { message("Start forestry / timber reporting") - + #### Wood land_lr <- madrat::toolAggregate(dimSums(land_hr,dim=3), map_file, from = "cell",to = "cluster") - + ### Wood: Harvested Area a <- harvested_area_timber(gdx,level = "cell") b <- a / land_lr @@ -249,12 +249,12 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { rm(a,b) gc() } - + #### Wood: Yields a <- ForestYield(gdx,level="cell") a_fix<- new.magpie(cells_and_regions=getCells(a),years=getYears(a), names=getNames(a)) - + # BugFix in the mean time. Strange jump from ForestYield a_fix[,1,]<-0 a_fix[,-1,]<-setYears(a[,2100,,invert=TRUE],getYears(a_fix[,-1,])) @@ -275,7 +275,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { rm(a,b) gc() } - + #### Wood: Harvested Biomass Product Split b <- TimberProductionVolumetric(gdx,level = "cell",sumSource = FALSE,sumProduct = FALSE) b <- dimSums(b,dim=3.1) @@ -490,4 +490,4 @@ gc() write.magpie(a, paste0(out_dir, "/LUH2_Yield_Nr.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() -} \ No newline at end of file +} diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index eb6d8e594f..321ef40d12 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -82,7 +82,7 @@ diet <- function(cfg) { cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) - cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. + cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. return(cfg) } @@ -232,7 +232,7 @@ cfg <- rcp26(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_PROD # -# Decomposition Scenario. Removed productivity trend from ELM +# Decomposition Scenario. Removed productivity trend from ELM cfg$title <- "ELM_PROD" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) @@ -242,7 +242,7 @@ cfg <- rcp26(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_WAST # -# Decomposition Scenario. Removes FLW from ELM +# Decomposition Scenario. Removes FLW from ELM cfg$title <- "ELM_WAST" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) @@ -262,7 +262,7 @@ cfg <- miti(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_NoCC # -# Decomposition Scenario. Removes climate impacts (NoCC) from ELM +# Decomposition Scenario. Removes climate impacts (NoCC) from ELM cfg$title <- "ELM_NoCC" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) @@ -273,7 +273,7 @@ cfg <- noCC(cfg = cfg) start_run(cfg, codeCheck = FALSE) # ELM_MITI # -# Decomposition Scenario. Removes climate mitigation and LUC policies from ELM +# Decomposition Scenario. Removes climate mitigation and LUC policies from ELM cfg$title <- "ELM_MITI" cfg <- bau(cfg = cfg) cfg <- diet(cfg = cfg) From 2b67fe563b80712ee1b3b9944c9c716b24fd2be4 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 18 Jan 2024 16:11:10 +0100 Subject: [PATCH 118/187] added missing description --- modules/15_food/anthro_iso_jun22/sets.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index c8a241c6e9..c210001afd 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -174,7 +174,7 @@ sets / livst_pig, livst_egg, livst_chick / EAT_ruminants15(kfo) ruminant products / livst_milk, livst_rum / - EAT_redmeat15(kfo) + EAT_redmeat15(kfo) livstock products that are categorized as red meat / livst_rum, livst_pig / EAT_fruitvegnutseed15(kfo) vegetables fruits nuts seeds / rapeseed, sunflower, others / From a94016df6cd646c2028af33a3def1357b6a4f0fb Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 19 Jan 2024 13:20:28 +0100 Subject: [PATCH 119/187] test --- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- modules/35_natveg/dynamic_feb21/preloop.gms | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 97b4f3db0b..816116c1f2 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -123,7 +123,7 @@ elseif s32_hvarea = 2, ** The offset is needed because the first element of ac is ac0, which is not included in p32_rotation_cellular_harvesting. v32_land.fx(j,"plant",ac)$(ac.off < p32_rotation_cellular_harvesting(t,j)) = pc32_land(j,"plant",ac); ** After the rotation period, plantations are free for harvesting - v32_land.up(j,"plant",ac)$(ac.off >= p32_rotation_cellular_harvesting(t,j)) = pc32_land(j,"plant",ac); + v32_land.up(j,"plant",ac)$(ac.off >= p32_rotation_cellular_harvesting(t,j)) = 0; s32_establishment_static = 0; s32_establishment_dynamic = 1; ); diff --git a/modules/35_natveg/dynamic_feb21/preloop.gms b/modules/35_natveg/dynamic_feb21/preloop.gms index cfb1d236a2..cde5da7970 100644 --- a/modules/35_natveg/dynamic_feb21/preloop.gms +++ b/modules/35_natveg/dynamic_feb21/preloop.gms @@ -74,7 +74,7 @@ p35_gs_scaling_reg(i) = 1; p35_gs_scaling_reg(i)$(f35_gs_relativetarget(i)>0 AND p35_observed_gs_reg(i)>0) = f35_gs_relativetarget(i) / p35_observed_gs_reg(i); ** Update c-densitiy based on calibration factor for growing stocks -pm_carbon_density_ac(t_all,j,ac,"vegc") = pm_carbon_density_ac(t_all,j,ac,"vegc") * sum(cell(i,j),p35_gs_scaling_reg(i)); +*pm_carbon_density_ac(t_all,j,ac,"vegc") = pm_carbon_density_ac(t_all,j,ac,"vegc") * sum(cell(i,j),p35_gs_scaling_reg(i)); * ----------------------------- * Set forest damage trajectory From c506d382bc8bd2934f843b18dc52bcfbf151210d Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 19 Jan 2024 14:38:53 +0100 Subject: [PATCH 120/187] test --- modules/32_forestry/dynamic_feb21/preloop.gms | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/32_forestry/dynamic_feb21/preloop.gms b/modules/32_forestry/dynamic_feb21/preloop.gms index 08088d1a86..4f843df002 100644 --- a/modules/32_forestry/dynamic_feb21/preloop.gms +++ b/modules/32_forestry/dynamic_feb21/preloop.gms @@ -279,6 +279,8 @@ p32_gs_scaling_reg(i) = 1; p32_gs_scaling_reg(i)$(f32_gs_relativetarget(i)>0 AND f32_plantedforest(i)>0) = f32_gs_relativetarget(i) / p32_observed_gs_reg(i); ** Calibration factors lower than 1 are set to 1 p32_gs_scaling_reg(i)$(p32_gs_scaling_reg(i) < 1) = 1; +** limit calibration factor to max value of 2 +p32_gs_scaling_reg(i)$(p32_gs_scaling_reg(i) > 2) = 2; ** Save pm_carbon_density_ac_forestry in a parameter before upscaling to FAO growing stocks. ** This allows to use plantation growth curves for CO2 price driven afforestation. From da6cf7c91d0c04bea13ced182356c0410fa56000 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 19 Jan 2024 17:59:21 +0100 Subject: [PATCH 121/187] test --- modules/32_forestry/dynamic_feb21/preloop.gms | 2 -- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- modules/73_timber/default/preloop.gms | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/32_forestry/dynamic_feb21/preloop.gms b/modules/32_forestry/dynamic_feb21/preloop.gms index 4f843df002..08088d1a86 100644 --- a/modules/32_forestry/dynamic_feb21/preloop.gms +++ b/modules/32_forestry/dynamic_feb21/preloop.gms @@ -279,8 +279,6 @@ p32_gs_scaling_reg(i) = 1; p32_gs_scaling_reg(i)$(f32_gs_relativetarget(i)>0 AND f32_plantedforest(i)>0) = f32_gs_relativetarget(i) / p32_observed_gs_reg(i); ** Calibration factors lower than 1 are set to 1 p32_gs_scaling_reg(i)$(p32_gs_scaling_reg(i) < 1) = 1; -** limit calibration factor to max value of 2 -p32_gs_scaling_reg(i)$(p32_gs_scaling_reg(i) > 2) = 2; ** Save pm_carbon_density_ac_forestry in a parameter before upscaling to FAO growing stocks. ** This allows to use plantation growth curves for CO2 price driven afforestation. diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 816116c1f2..369ab2a3c3 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -122,7 +122,7 @@ elseif s32_hvarea = 2, ** Fix timber plantations until the end of the rotation. "ac.off" identical to "ord(ac)-1". ** The offset is needed because the first element of ac is ac0, which is not included in p32_rotation_cellular_harvesting. v32_land.fx(j,"plant",ac)$(ac.off < p32_rotation_cellular_harvesting(t,j)) = pc32_land(j,"plant",ac); -** After the rotation period, plantations are free for harvesting +** After the rotation period, timber plantations are harvested to avoid unrealistic carbon storage in timber plantations. v32_land.up(j,"plant",ac)$(ac.off >= p32_rotation_cellular_harvesting(t,j)) = 0; s32_establishment_static = 0; s32_establishment_dynamic = 1; diff --git a/modules/73_timber/default/preloop.gms b/modules/73_timber/default/preloop.gms index 4437e845c6..b11af8945c 100644 --- a/modules/73_timber/default/preloop.gms +++ b/modules/73_timber/default/preloop.gms @@ -46,6 +46,9 @@ $ifthen "%c73_wood_scen%" == "construction" p73_timber_demand_gdp_pop(t_all,i,"wood") = p73_timber_demand_gdp_pop(t_all,i,"wood") * f73_demand_modifier(t_all,"%c73_wood_scen%"); $endif +*Temporary bugfix for MEA; has to be moved to pre-processing! +p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") = p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") * 0.5; + ** Convert to tDM from mio m3 ** p73_timber_demand_gdp_pop is in mio m^3 ** pm_demand_ext in mio ton DM From f745d369c6644ee246c2fd0cac4480bee1cf467d Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 20 Jan 2024 14:23:21 +0100 Subject: [PATCH 122/187] test --- modules/32_forestry/dynamic_feb21/declarations.gms | 2 +- modules/32_forestry/dynamic_feb21/preloop.gms | 4 +++- modules/32_forestry/dynamic_feb21/presolve.gms | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/32_forestry/dynamic_feb21/declarations.gms b/modules/32_forestry/dynamic_feb21/declarations.gms index 314a392b55..ca4d9f0a8e 100644 --- a/modules/32_forestry/dynamic_feb21/declarations.gms +++ b/modules/32_forestry/dynamic_feb21/declarations.gms @@ -48,7 +48,7 @@ parameters pm_representative_rotation(t_all,i) Representative regional rotation (1) p32_aff_bgp(j,ac) Biophysical impact of afforestation (tCeq per ha) p32_tcre_glo(j) Global mean Transient Climate Response to cumulative Emissions (degree C per tC per ha) - p32_observed_gs_reg(i) Observed growing stock (tDM per ha) + p32_observed_gs_reg(i) Observed growing stock (m3 per ha) p32_gs_scaling_reg(i) Calibration factor for scaling up the relative growing stock (1) p32_rotation_dist(j,ac) Poulter distribution within celular rotation lengths (1) p32_updated_gs_reg(t,i) Updated growing stock information after calibration (m3 per ha) diff --git a/modules/32_forestry/dynamic_feb21/preloop.gms b/modules/32_forestry/dynamic_feb21/preloop.gms index 08088d1a86..8606d85e5c 100644 --- a/modules/32_forestry/dynamic_feb21/preloop.gms +++ b/modules/32_forestry/dynamic_feb21/preloop.gms @@ -266,7 +266,7 @@ p32_plantation_contribution(t_ext,i)$(f32_gs_relativetarget(i)>0) = f32_plantati ******************************************************************************* ** Calibrate plantations yields ******************************************************************************* -** Initialize with 1 tDM/ha - to avoid dvision by 0 +** Initialize with 1 m3 per ha - to avoid dvision by 0 p32_observed_gs_reg(i) = 1; ** Wherever FAO reports >0 growing stock, we calculate how much growing stock MAGPIE ** sees even before optimization starts @@ -286,6 +286,8 @@ p32_c_density_ac_fast_forestry(t_all,j,ac) = pm_carbon_density_ac_forestry(t_all ** Update c-density for timber plantations based on calibration factor to match FAO growing stocks pm_carbon_density_ac_forestry(t_all,j,ac,"vegc") = pm_carbon_density_ac_forestry(t_all,j,ac,"vegc") * sum(cell(i,j),p32_gs_scaling_reg(i)); +** keep c-density for timber plantations constant after rotation length to avoid unrealistic carbon sequestration in unharvested timber plantations +pm_carbon_density_ac_forestry(t_all,j,ac,"vegc")$(ac.off >= p32_rotation_cellular_harvesting(t_all,j)) = sum(ac2$(ac2.off = p32_rotation_cellular_harvesting(t_all,j)), pm_carbon_density_ac_forestry(t_all,j,ac2,"vegc")); ** set bii coefficients p32_bii_coeff(type32,bii_class_secd,potnatveg) = 0; diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 369ab2a3c3..97b4f3db0b 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -122,8 +122,8 @@ elseif s32_hvarea = 2, ** Fix timber plantations until the end of the rotation. "ac.off" identical to "ord(ac)-1". ** The offset is needed because the first element of ac is ac0, which is not included in p32_rotation_cellular_harvesting. v32_land.fx(j,"plant",ac)$(ac.off < p32_rotation_cellular_harvesting(t,j)) = pc32_land(j,"plant",ac); -** After the rotation period, timber plantations are harvested to avoid unrealistic carbon storage in timber plantations. - v32_land.up(j,"plant",ac)$(ac.off >= p32_rotation_cellular_harvesting(t,j)) = 0; +** After the rotation period, plantations are free for harvesting + v32_land.up(j,"plant",ac)$(ac.off >= p32_rotation_cellular_harvesting(t,j)) = pc32_land(j,"plant",ac); s32_establishment_static = 0; s32_establishment_dynamic = 1; ); From 5266414b843767568a66494e90d0a9cd41121836 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Jan 2024 11:15:44 +0100 Subject: [PATCH 123/187] t_all --- modules/52_carbon/normal_dec17/start.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/52_carbon/normal_dec17/start.gms b/modules/52_carbon/normal_dec17/start.gms index fc7e67e3ff..998b35222f 100644 --- a/modules/52_carbon/normal_dec17/start.gms +++ b/modules/52_carbon/normal_dec17/start.gms @@ -21,7 +21,7 @@ pm_carbon_density_ac_forestry(t_all,j,ac,"litc") = m_growth_litc_soilc(pc52_carb *** Natveg *calculate vegetation age-class carbon density in current time step with chapman richards equation -pm_carbon_density_ac(t,j,ac,"vegc") = m_growth_vegc(pc52_carbon_density_start(t,j,"vegc"),fm_carbon_density(t,j,"other","vegc"),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"k","natveg")),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"m","natveg")),(ord(ac)-1)); +pm_carbon_density_ac(t_all,j,ac,"vegc") = m_growth_vegc(pc52_carbon_density_start(t_all,j,"vegc"),fm_carbon_density(t_all,j,"other","vegc"),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"k","natveg")),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"m","natveg")),(ord(ac)-1)); *calculate litter carbon density based on linear growth funktion: carbon_density(ac) = intercept + slope*ac (20 year time horizon taken from IPCC) -pm_carbon_density_ac(t,j,ac,"litc") = m_growth_litc_soilc(pc52_carbon_density_start(t,j,"litc"),fm_carbon_density(t,j,"other","litc"),(ord(ac)-1)); +pm_carbon_density_ac(t_all,j,ac,"litc") = m_growth_litc_soilc(pc52_carbon_density_start(t_all,j,"litc"),fm_carbon_density(t_all,j,"other","litc"),(ord(ac)-1)); From 8bc839d97e57c3b132fb8a9ebf2210cab696e18e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 22 Jan 2024 18:11:03 +0100 Subject: [PATCH 124/187] nuts in others are scaled by the same amount as fruits and vegetables and seeds are used to fill up to meet the nuts target AND fruit ratio in others at country level --- config/default.cfg | 6 +-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 38 ++++++++++++------- modules/15_food/anthro_iso_jun22/input.gms | 4 +- modules/15_food/input/files | 2 +- scripts/start/projects/project_EAT2p0.R | 3 ++ 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index c5c3857bfc..7cee9a5bbb 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", - cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.97EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", + cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index d2b6437ec3..23e9b53fbf 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -457,11 +457,11 @@ elseif s15_exo_diet = 3, *** Special case: Fruits, vegetables and nuts *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; *' Bananas and plantains are included in the 'cassav_sp' category. -*' The f15_fruitveg2others_kcal_ratio gives the regional average historical share +*' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = sum(i_to_iso(i,iso), f15_fruitveg2others_kcal_ratio(t,i,EAT_special)); + i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); else i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = i15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); ); @@ -498,24 +498,28 @@ elseif s15_exo_diet = 3, *' Minimum recommendation for fruits and vegetables: i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) = i15_rec_EATLancet(iso,"t_fruitveg","min"); -*' Extract fruits and vegetables that are part of others categroy -* Note that starchy fruits are kept at the previously assigned maximum level -* and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds -*' (a) nuts included in "others" counted towards EAT nuts & seeds category +*' (a) nuts included in "others" count towards nuts & seeds EAT target, +*' but they are scaled by the same amount as vegetables +*' because in MAgPIE, they are represented by a uniform category. i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail_nuts(t,iso) / (sum(kfo_seeds,p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") + = p15_intake_detail_nuts(t,iso) * (i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso)) ; -*' (b) seeds (rapeseed, sunflower): - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2,p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso) +*** BENNI: It is not scaled up if the nuts target is fulfilled. Is this correct? That way we lose the 1:1 connection of nuts and fruits&vegetables, but otherwise we would potentially overfulfill nuts. +*** Note: It could even already be overfulfilled by this method, right? I would ensure that we don't overfulfill by this equation: (Makes sense to you?) + i15_intake_detailed_scen_nuts(t,iso)$(i15_intake_detailed_scen_nuts(t,iso) > i15_rec_EATLancet(iso,"t_nutseeds","min")) + = i15_rec_EATLancet(iso,"t_nutseeds","min"); + +*' (b) seeds (rapeseed, sunflower) are scaled up towards the EAT target if scaling +*' of nuts in others was not sufficient to meet the nuts target. + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = (p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + p15_intake_detail_nuts(t,iso))) - * i15_rec_EATLancet(iso,"t_nutseeds","min") - ; + = p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2))) + * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts) + ; + *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds *** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts? i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") @@ -523,6 +527,12 @@ elseif s15_exo_diet = 3, ) = i15_rec_EATLancet(iso,"t_peanuts","min"); +*' Extract fruits and vegetables that are part of others categroy +* Note that starchy fruits are kept at the previously assigned maximum level +* and their amount has been added to cassav_sp already. + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); +*** BENNI: Please double check whether the starchyfruit should be subtracted here or before the nut treatment happens. + *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 5960190762..39709fc156 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -258,9 +258,9 @@ $ondelim $include "./modules/15_food/input/f15_targets_EATLancet_iso.cs3" $offdelim; -table f15_fruitveg2others_kcal_ratio(t_all,i,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) +table f15_fruitveg2others_kcal_ratio(t_all,iso,EAT_special) Country-specific ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) $ondelim -$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio.cs3" +$include "./modules/15_food/input/f15_fruitveg2others_kcal_ratio_iso.cs3" $offdelim; * This file contains exogenous dietary recommendations for India and EAT Lancet recommendations for all other regions diff --git a/modules/15_food/input/files b/modules/15_food/input/files index 46b2d569ee..3a2b8735ad 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -21,7 +21,7 @@ f15_supply2intake_ratio_FAO_iso.cs3 f15_intake_EATLancet.cs3 f15_intake_EATLancet_iso.cs3 f15_targets_EATLancet_iso.cs3 -f15_fruitveg2others_kcal_ratio.cs3 +f15_fruitveg2others_kcal_ratio_iso.cs3 f15_food_substitution_fader.csv f15_ruminant_fadeout_india.csv f15_milk_fadeout_india.csv diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index 321ef40d12..a7acf1ab9e 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -124,6 +124,9 @@ miti <- function(cfg) { cfg$gms$c56_pollutant_prices <- "coupling" cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" cfg$gms$c60_2ndgen_biodem <- "coupling" + +# Switch on NDCs? + return(cfg) } From 0b6a47fd2fae3de5096d25c3dec19bc82f9daa7b Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Jan 2024 10:07:50 +0100 Subject: [PATCH 125/187] prot re/aff --- config/default.cfg | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 2fe439c2b0..8a4b10729d 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -772,7 +772,12 @@ cfg$gms$s32_max_aff_area <- Inf # def = Inf # Protection of afforested areas (endogenous CO2 price driven) # 0=until end of planning horizon (see s32_planing_horizon) # 1=forever -cfg$gms$s32_aff_prot <- 0 # def = 0 +# Note: Without a price on CO2 emissions from land-use change in module 32_forestry, +# which is the current default (c56_emis_policy <- "reddnatveg_nosoil"), +# the recommended setting for s32_aff_prot is 1. +# Otherwise, the model can do re/afforestation on existing re/afforestation areas +# after the end of planning horizon without penalty for CO2 emissions. +cfg$gms$s32_aff_prot <- 1 # def = 1 # Type of afforestation constraint cfg$gms$s32_max_aff_area_glo <- 1 # def = 1 From db5d3ea6581e8bae6a460ff1990c198dd8e7feab Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Jan 2024 14:09:56 +0100 Subject: [PATCH 126/187] highest age-class is set to value of long-term natural vegetation carbon density --- modules/52_carbon/normal_dec17/start.gms | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/52_carbon/normal_dec17/start.gms b/modules/52_carbon/normal_dec17/start.gms index 998b35222f..c52e52f58f 100644 --- a/modules/52_carbon/normal_dec17/start.gms +++ b/modules/52_carbon/normal_dec17/start.gms @@ -13,6 +13,8 @@ pc52_carbon_density_start(t_all,j,"litc") = fm_carbon_density(t_all,j,"past","li *calculate vegetation age-class carbon density in current time step with chapman richards equation pm_carbon_density_ac_forestry(t_all,j,ac,"vegc") = m_growth_vegc(pc52_carbon_density_start(t_all,j,"vegc"),fm_carbon_density(t_all,j,"other","vegc"),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"k","plantations")),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"m","plantations")),(ord(ac)-1)); +*highest age-class is set to value of long-term natural vegetation carbon density. This is needed because after 150 years, the length of ac set, the long-term natural vegetation carbon density is not reached in all cases, depending on the parameters k and m. +pm_carbon_density_ac_forestry(t_all,j,"acx","vegc") = fm_carbon_density(t_all,j,"other","vegc"); *calculate litter carbon density based on linear growth funktion: carbon_density(ac) = intercept + slope*ac (20 year time horizon taken from IPCC) pm_carbon_density_ac_forestry(t_all,j,ac,"litc") = m_growth_litc_soilc(pc52_carbon_density_start(t_all,j,"litc"),fm_carbon_density(t_all,j,"other","litc"),(ord(ac)-1)); @@ -22,6 +24,8 @@ pm_carbon_density_ac_forestry(t_all,j,ac,"litc") = m_growth_litc_soilc(pc52_carb *calculate vegetation age-class carbon density in current time step with chapman richards equation pm_carbon_density_ac(t_all,j,ac,"vegc") = m_growth_vegc(pc52_carbon_density_start(t_all,j,"vegc"),fm_carbon_density(t_all,j,"other","vegc"),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"k","natveg")),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"m","natveg")),(ord(ac)-1)); +*highest age-class is set to value of long-term natural vegetation carbon density. This is needed because after 150 years, the length of ac set, the long-term natural vegetation carbon density is not reached in all cases, depending on the parameters k and m. +pm_carbon_density_ac(t_all,j,"acx","vegc") = fm_carbon_density(t_all,j,"other","vegc"); *calculate litter carbon density based on linear growth funktion: carbon_density(ac) = intercept + slope*ac (20 year time horizon taken from IPCC) pm_carbon_density_ac(t_all,j,ac,"litc") = m_growth_litc_soilc(pc52_carbon_density_start(t_all,j,"litc"),fm_carbon_density(t_all,j,"other","litc"),(ord(ac)-1)); From 77950e2a8fab8fefdf9d57ca011212ed4f57db9c Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Jan 2024 18:31:01 +0100 Subject: [PATCH 127/187] test selfsuf --- modules/21_trade/selfsuff_reduced/preloop.gms | 5 +---- modules/73_timber/default/preloop.gms | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index b336661fbd..3bc9a05c6a 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -8,10 +8,7 @@ i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","%c21_trade_liberalization%"); -loop(t_all$(m_year(t_all)>=2015), -i21_trade_bal_reduction(t_all,"wood") = i21_trade_bal_reduction(t_all,"wood") * s21_trade_bal_damper; -); -i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); +i21_trade_bal_reduction(t_all,kforestry) = i21_trade_bal_reduction(t_all,kforestry) * s21_trade_bal_damper; i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); diff --git a/modules/73_timber/default/preloop.gms b/modules/73_timber/default/preloop.gms index b11af8945c..3962bd370c 100644 --- a/modules/73_timber/default/preloop.gms +++ b/modules/73_timber/default/preloop.gms @@ -47,7 +47,7 @@ p73_timber_demand_gdp_pop(t_all,i,"wood") = p73_timber_demand_gdp_pop(t_all,i,"w $endif *Temporary bugfix for MEA; has to be moved to pre-processing! -p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") = p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") * 0.5; +*p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") = p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") * 0.5; ** Convert to tDM from mio m3 ** p73_timber_demand_gdp_pop is in mio m^3 From 1372029d4895692d03920c561b1bd416fba4cfb0 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Jan 2024 18:39:49 +0100 Subject: [PATCH 128/187] test selfsuf --- modules/21_trade/selfsuff_reduced/preloop.gms | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index 3bc9a05c6a..5fa002855d 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -8,7 +8,8 @@ i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","%c21_trade_liberalization%"); -i21_trade_bal_reduction(t_all,kforestry) = i21_trade_bal_reduction(t_all,kforestry) * s21_trade_bal_damper; +i21_trade_bal_reduction(t_all,"wood") = i21_trade_bal_reduction(t_all,"wood") * s21_trade_bal_damper; +i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"woodfuel") * s21_trade_bal_damper; i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); From 0bcea49343838f461075b16ccc516242020a84cd Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Jan 2024 20:12:36 +0100 Subject: [PATCH 129/187] revert back --- modules/21_trade/selfsuff_reduced/preloop.gms | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index 5fa002855d..b336661fbd 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -8,8 +8,10 @@ i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","%c21_trade_liberalization%"); +loop(t_all$(m_year(t_all)>=2015), i21_trade_bal_reduction(t_all,"wood") = i21_trade_bal_reduction(t_all,"wood") * s21_trade_bal_damper; -i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"woodfuel") * s21_trade_bal_damper; +); +i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); From 3b793fd98f2a3a8007b1e0bdeb9e4756d696a7ea Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Jan 2024 09:13:49 +0100 Subject: [PATCH 130/187] test woodfuel --- modules/21_trade/selfsuff_reduced/preloop.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index b336661fbd..95578ba197 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -11,7 +11,7 @@ i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hard loop(t_all$(m_year(t_all)>=2015), i21_trade_bal_reduction(t_all,"wood") = i21_trade_bal_reduction(t_all,"wood") * s21_trade_bal_damper; ); -i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); +*i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); From 1713cd72a59451f51f808d3f93042a82434f826d Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Jan 2024 11:14:25 +0100 Subject: [PATCH 131/187] more testing --- modules/21_trade/selfsuff_reduced/preloop.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index 95578ba197..0b04b38ee2 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -8,9 +8,9 @@ i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","%c21_trade_liberalization%"); -loop(t_all$(m_year(t_all)>=2015), +*loop(t_all$(m_year(t_all)>=2015), +*); i21_trade_bal_reduction(t_all,"wood") = i21_trade_bal_reduction(t_all,"wood") * s21_trade_bal_damper; -); *i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); From bc4648cf9c6c5e3fb82fa1ac7175204857921621 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Jan 2024 12:07:36 +0100 Subject: [PATCH 132/187] revert back --- modules/21_trade/selfsuff_reduced/preloop.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index 0b04b38ee2..95578ba197 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -8,9 +8,9 @@ i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","%c21_trade_liberalization%"); -*loop(t_all$(m_year(t_all)>=2015), -*); +loop(t_all$(m_year(t_all)>=2015), i21_trade_bal_reduction(t_all,"wood") = i21_trade_bal_reduction(t_all,"wood") * s21_trade_bal_damper; +); *i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); From 30d6cfa8819be73994631db9584b3e24b16fcc67 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Jan 2024 13:52:20 +0100 Subject: [PATCH 133/187] revert back --- modules/21_trade/selfsuff_reduced/preloop.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index 95578ba197..b336661fbd 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -11,7 +11,7 @@ i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hard loop(t_all$(m_year(t_all)>=2015), i21_trade_bal_reduction(t_all,"wood") = i21_trade_bal_reduction(t_all,"wood") * s21_trade_bal_damper; ); -*i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); +i21_trade_bal_reduction(t_all,"woodfuel") = i21_trade_bal_reduction(t_all,"wood"); i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); From 537cdcec623c270024aa868844a3e18f7502b787 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Jan 2024 15:00:50 +0100 Subject: [PATCH 134/187] update --- modules/21_trade/selfsuff_reduced/input.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/21_trade/selfsuff_reduced/input.gms b/modules/21_trade/selfsuff_reduced/input.gms index 1185f72439..461ef262ed 100644 --- a/modules/21_trade/selfsuff_reduced/input.gms +++ b/modules/21_trade/selfsuff_reduced/input.gms @@ -10,7 +10,7 @@ $setglobal c21_trade_liberalization l909090r808080 scalars s21_trade_tariff Trade tariff switch (1=on 0=off) (1) / 1 / - s21_trade_bal_damper Fraction to ease self sufficiency pool trade for roundwood /0.75/ + s21_trade_bal_damper Fraction to ease self sufficiency pool trade for roundwood / 0.65 / ; table f21_trade_bal_reduction(t_all,trade_groups21,trade_regime21) Share of inelastic trade pool (1) From cfe24b7112c7aabf14ef13c76b5ad796c87747c5 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Jan 2024 21:34:45 +0100 Subject: [PATCH 135/187] changelog --- CHANGELOG.md | 5 ++++- config/default.cfg | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da44c64838..8d7dc89942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** removed erroneous setting `cc` from column `input` - **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` - **default.cfg** update input data to rev 4.96 +- **default.cfg** changed default for `cfg$gms$s56_buffer_aff` from 0.2 to 0.5 +- **default.cfg** changed default for `cfg$gms$s32_aff_prot` from 0 to 1 ### added - **32_forestry** new interfaces `vm_land_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` @@ -32,7 +34,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k - **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs - **35_natveg** bugfixes ac_est - +- **35_natveg** removed scaling of pm_carbon_density_ac +- **52_carbon** bugfix acx long-term carbon density ## [4.7.0] - 2023-12-11 diff --git a/config/default.cfg b/config/default.cfg index 8a4b10729d..48fbfdec0d 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1463,10 +1463,12 @@ cfg$gms$c56_cprice_aff <- "secdforest_vegc" # def = secdforest_vegc # * should not be higher than s32_planing_horizon cfg$gms$s56_c_price_exp_aff <- 50 # def = 50 -# * share of carbon credits for afforestation projects pooled in a buffer -# * Values > 0 will reduced the incentive for c price induced afforestation -# * a plausible value is 0.2, based on the Gold Standard for afforestation projects -cfg$gms$s56_buffer_aff <- 0.2 # def = 0.2 +# * Share of carbon credits for re/afforestation projects set aside in a buffer to +# * account for potential failure of permanent carbon storage. +# * Alternatively, this parameter can be interpreted as a reduction factor +# * of the carbon price for non-permanent CDR. +# * Values > 0 will reduce the incentive for c-price-induced re/afforestation +cfg$gms$s56_buffer_aff <- 0.5 # def = 0.5 # * Upper limit for CH4 and N2O GHG price (USD05MER per tC) # * Limits GHG prices selected in c56_pollutant_prices to the chosen value. From a5f0b3714a64e9d654cdd5fa6f3da506a503cfbc Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Jan 2024 21:45:47 +0100 Subject: [PATCH 136/187] cleanup --- CHANGELOG.md | 3 +++ modules/35_natveg/dynamic_feb21/declarations.gms | 2 -- modules/35_natveg/dynamic_feb21/preloop.gms | 14 -------------- modules/73_timber/default/preloop.gms | 3 --- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d7dc89942..aa8d7dd03c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **default.cfg** update input data to rev 4.96 - **default.cfg** changed default for `cfg$gms$s56_buffer_aff` from 0.2 to 0.5 - **default.cfg** changed default for `cfg$gms$s32_aff_prot` from 0 to 1 +- **21_trade** s21_trade_bal_damper for roundwood changed from 0.75 to 0.65 ### added - **32_forestry** new interfaces `vm_land_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` @@ -36,6 +37,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **35_natveg** bugfixes ac_est - **35_natveg** removed scaling of pm_carbon_density_ac - **52_carbon** bugfix acx long-term carbon density +- **32_forestry** keep c-density for timber plantations constant after rotation length to avoid unrealistic carbon sequestration in unharvested timber plantation +- **32_forestry** bugfix unit p32_observed_gs_reg ## [4.7.0] - 2023-12-11 diff --git a/modules/35_natveg/dynamic_feb21/declarations.gms b/modules/35_natveg/dynamic_feb21/declarations.gms index 21a3efa502..7734016a95 100644 --- a/modules/35_natveg/dynamic_feb21/declarations.gms +++ b/modules/35_natveg/dynamic_feb21/declarations.gms @@ -29,8 +29,6 @@ parameters p35_land(t,j,land_natveg,ac) Natural vegetation area (mio. ha) p35_updated_gs_natfor(t,i) Updated growing stock in natural forests after calibration (m3 per ha) p35_land_start_ac(j,ac,land_natveg) Initial Natural vegetation area (mio. ha) - p35_observed_gs_reg(i) Observed growing stock in natural forests before calibration (m3 per ha) - p35_gs_scaling_reg(i) Regional calibration factors for natural vegetation yields (1) p35_protection_dist(j,ac) Distribution of secondary forest protection (1) p35_land_restoration(j,land_natveg) Actual secondary forest and other land restoration area (mio. ha) ; diff --git a/modules/35_natveg/dynamic_feb21/preloop.gms b/modules/35_natveg/dynamic_feb21/preloop.gms index cde5da7970..e277913b3b 100644 --- a/modules/35_natveg/dynamic_feb21/preloop.gms +++ b/modules/35_natveg/dynamic_feb21/preloop.gms @@ -61,20 +61,6 @@ p35_land_start_ac(j,ac,land_natveg) = 0; p35_land_start_ac(j,"acx","primforest") = pcm_land(j,"primforest"); p35_land_start_ac(j,ac,"secdforest") = i35_secdforest(j,ac); -** Wherever FAO reports >0 growing stock, we calculate how much growing stock MAGPIE -** sees even before optimization starts -p35_observed_gs_reg(i) = 0; -p35_observed_gs_reg(i)$(f35_gs_relativetarget(i)>0 AND sum((cell(i,j),ac,land_natveg),p35_land_start_ac(j,ac,land_natveg)$(not sameas(ac,"ac0")))>0) = - (sum((cell(i,j),ac,land_natveg),(pm_timber_yield_initial(j,ac,land_natveg)$(not sameas(ac,"ac0")) / sm_wood_density) * p35_land_start_ac(j,ac,land_natveg)$(not sameas(ac,"ac0")))/ sum((cell(i,j),ac,land_natveg),p35_land_start_ac(j,ac,land_natveg)$(not sameas(ac,"ac0")))); - -** Initialze calibration factor for growing stocks as 1 -** we dont set it to 0 as we don't want to modify carbon densities by multiplication with 0 later -p35_gs_scaling_reg(i) = 1; -** Calculate the ratio between target growing stock (reported by FAO) and observed growing stock (value at initialization in MAgPIE) -p35_gs_scaling_reg(i)$(f35_gs_relativetarget(i)>0 AND p35_observed_gs_reg(i)>0) = f35_gs_relativetarget(i) / p35_observed_gs_reg(i); - -** Update c-densitiy based on calibration factor for growing stocks -*pm_carbon_density_ac(t_all,j,ac,"vegc") = pm_carbon_density_ac(t_all,j,ac,"vegc") * sum(cell(i,j),p35_gs_scaling_reg(i)); * ----------------------------- * Set forest damage trajectory diff --git a/modules/73_timber/default/preloop.gms b/modules/73_timber/default/preloop.gms index 3962bd370c..4437e845c6 100644 --- a/modules/73_timber/default/preloop.gms +++ b/modules/73_timber/default/preloop.gms @@ -46,9 +46,6 @@ $ifthen "%c73_wood_scen%" == "construction" p73_timber_demand_gdp_pop(t_all,i,"wood") = p73_timber_demand_gdp_pop(t_all,i,"wood") * f73_demand_modifier(t_all,"%c73_wood_scen%"); $endif -*Temporary bugfix for MEA; has to be moved to pre-processing! -*p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") = p73_timber_demand_gdp_pop(t_all,"MEA","woodfuel") * 0.5; - ** Convert to tDM from mio m3 ** p73_timber_demand_gdp_pop is in mio m^3 ** pm_demand_ext in mio ton DM From 571db928bc296fe12d8cac48433baeb0fa7757d4 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 25 Jan 2024 08:50:39 +0100 Subject: [PATCH 137/187] scenario config --- config/scenario_config.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 14373e5f00..167b6c5696 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -53,7 +53,7 @@ gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1; gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_buffer_aff;;;;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.5;0.2;0.3;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_buffer_aff;;;;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.2;0.3;;;;;;;0.5;;;;;;;;;;;;;;;;;;;;;;;;; gms$c56_emis_policy;;;;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;redd_nosoil;all_nosoil;;;;;;;reddnatveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;; gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; From 77e0f6324f6a3f5f8c4801d3919d53c2537485ef Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 11:47:51 +0100 Subject: [PATCH 138/187] scaling of nuts together with fruits and veggies and abort statement for old implementation --- config/default.cfg | 6 +++--- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 7cee9a5bbb..c5c3857bfc 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.96EAT2p0_h12_magpie.tgz", - cellular = "rev4.96EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.96EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", + cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.97EAT2p0_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 23e9b53fbf..c84d03b10d 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -316,8 +316,7 @@ $endif i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); -*** BENNI: Is this initiated correctly? (If p15_intake_total = 0, no value is written into i15_intake_detailed_scen_target. Is that a problem?) -* Am Ende fadet ja dann p15_intake_detail zu i15_intake_detailed_scen_target, d.h. wir mĂĽssen sicherstellen, dass in i15_intake_detailed_scen_target auch echt alles richtig drinsteht. + i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) = 0) = 0; *' 2.) The second step defines the daily per capita intake of different food *' commodities. @@ -382,6 +381,10 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old))) ; + if (smin((iso,EAT_staples_old), i15_intake_detailed_scen_target(t,iso,EAT_staples_old)) < 0, + abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + ); + * VARTIKA: What about s15_exo_diet = 2? * Can this be transformed to the new diet implementation? Did you have target values there? * (Note: The old EATLancet implementation should be deleted soon.) @@ -505,7 +508,7 @@ elseif s15_exo_diet = 3, *' because in MAgPIE, they are represented by a uniform category. i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = p15_intake_detail_nuts(t,iso) * (i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso)) + = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / p15_intake_detail_fruitveg(t,iso) ; *** BENNI: It is not scaled up if the nuts target is fulfilled. Is this correct? That way we lose the 1:1 connection of nuts and fruits&vegetables, but otherwise we would potentially overfulfill nuts. *** Note: It could even already be overfulfilled by this method, right? I would ensure that we don't overfulfill by this equation: (Makes sense to you?) @@ -516,8 +519,8 @@ elseif s15_exo_diet = 3, *' of nuts in others was not sufficient to meet the nuts target. i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_nuts(t,iso) ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = p15_intake_detail(t,iso,kfo_seeds) / (sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2))) - * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts) + = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds From bc3eea9e3d3dbf7287e2a9327ae51d8505a006d7 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 14:37:41 +0100 Subject: [PATCH 139/187] code improvements following Bennis suggestions and correction of calorie balancing when negative --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 87 ++++++++++++------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index c84d03b10d..1abb4f1008 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -376,14 +376,24 @@ if (s15_exo_diet = 1, = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * - (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old,i15_intake_EATLancet(iso,EAT_staples2_old))) + i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = + smax(0 , (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)))) * + (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; - if (smin((iso,EAT_staples_old), i15_intake_detailed_scen_target(t,iso,EAT_staples_old)) < 0, +* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) + ; +*** BENNI / JAN: Please double check: The correction is the same as above commented out code +* The purpose is to correct cases where the EATLancet diet lead to more consumption than allowed by calorie target and staple balancing not sufficient to bring it down. +* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = +* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) +* ; + + if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; - ); + ); * VARTIKA: What about s15_exo_diet = 2? * Can this be transformed to the new diet implementation? Did you have target values there? @@ -502,42 +512,50 @@ elseif s15_exo_diet = 3, i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) = i15_rec_EATLancet(iso,"t_fruitveg","min"); +*' Extract fruits and vegetables that are part of others categroy +* Note that starchy fruits are kept at the previously assigned maximum level +* and their amount has been added to cassav_sp already. + i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); + *' Minimum recommendation for nuts & seeds -*' (a) nuts included in "others" count towards nuts & seeds EAT target, -*' but they are scaled by the same amount as vegetables -*' because in MAgPIE, they are represented by a uniform category. - i15_intake_detailed_scen_nuts(t,iso)$((sum(kfo_seeds, p15_intake_detail(t,iso,kfo_seeds)) + p15_intake_detail_nuts(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) - = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / p15_intake_detail_fruitveg(t,iso) +*' (a) nuts included in "others" +*' are scaled by the same amount as fruits and vegetables +*' because the food group "others" is treated as homogenous food category + i15_intake_detailed_scen_nuts(t,iso) + = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso)) ; -*** BENNI: It is not scaled up if the nuts target is fulfilled. Is this correct? That way we lose the 1:1 connection of nuts and fruits&vegetables, but otherwise we would potentially overfulfill nuts. -*** Note: It could even already be overfulfilled by this method, right? I would ensure that we don't overfulfill by this equation: (Makes sense to you?) - i15_intake_detailed_scen_nuts(t,iso)$(i15_intake_detailed_scen_nuts(t,iso) > i15_rec_EATLancet(iso,"t_nutseeds","min")) - = i15_rec_EATLancet(iso,"t_nutseeds","min"); - -*' (b) seeds (rapeseed, sunflower) are scaled up towards the EAT target if scaling -*' of nuts in others was not sufficient to meet the nuts target. - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$((sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_nuts(t,iso) - ) < i15_rec_EATLancet(iso,"t_nutseeds","min")) + +*' The resulting intake of the "others" category is: + i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + +* Check (temporarily for testing) +display i15_intake_detailed_scen_target; +*' (b) seeds (rapeseed, sunflower) are scaled up or down towards the EAT target +*' considering scaling of nuts in others. +*' Note that the nuts in others count towards the EAT target + i15_intake_detailed_scen_target(t,iso,kfo_seeds) = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; +* Check (temporarily for testing) +display i15_intake_detailed_scen_target; + +* If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, +* seed consumption is reduced to zero. + i15_intake_detailed_scen_target(t,iso,kfo_seeds)$(i15_intake_detailed_scen_target(t,iso,kfo_seeds) < 0) = 0; + +* Just to make sure. Can probably be deleted after testing (Just included because I removed the if conditions above as suggested by Benni) + if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), + abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; + ); *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds -*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts? +*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts even though the EATLancet 2 recommendation is having it as one nuts target? i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") < i15_rec_EATLancet(iso,"t_peanuts","min") ) = i15_rec_EATLancet(iso,"t_peanuts","min"); -*' Extract fruits and vegetables that are part of others categroy -* Note that starchy fruits are kept at the previously assigned maximum level -* and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); -*** BENNI: Please double check whether the starchyfruit should be subtracted here or before the nut treatment happens. - -*' The resulting intake of the "others" category is: - i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); ); *' lower bound for legumes @@ -605,14 +623,17 @@ elseif s15_exo_diet = 3, *' Note that brans do not have an EAT Lancet target and are kept at their *' original level. i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples))) - * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); + smax(0, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)))) + * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); + +* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)); - if (smin((iso,EAT_staples), i15_intake_detailed_scen_target(t,iso,EAT_staples)) < 0, + if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; ); - ); *** End of MAgPIE-specific realization of the EAT Lancet diet From 1d12ac654c4245277557e474b959ed4b80b96771 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 15:36:43 +0100 Subject: [PATCH 140/187] set already under control fix --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 1abb4f1008..f44c69c0b7 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -377,13 +377,15 @@ if (s15_exo_diet = 1, ); i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = - smax(0 , (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old,i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)))) * + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old))) * (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) + i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = + 0; + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) ; *** BENNI / JAN: Please double check: The correction is the same as above commented out code * The purpose is to correct cases where the EATLancet diet lead to more consumption than allowed by calorie target and staple balancing not sufficient to bring it down. @@ -623,12 +625,14 @@ display i15_intake_detailed_scen_target; *' Note that brans do not have an EAT Lancet target and are kept at their *' original level. i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = - smax(0, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)))) + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)); + i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = + 0; + i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; From 7e9cd64d529c67b841b7e4b7443f9319812ed3d3 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 29 Jan 2024 15:56:31 +0100 Subject: [PATCH 141/187] small bufix --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 6 +++--- modules/15_food/anthro_iso_jun22/sets.gms | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index f44c69c0b7..900e11abff 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -547,9 +547,9 @@ display i15_intake_detailed_scen_target; i15_intake_detailed_scen_target(t,iso,kfo_seeds)$(i15_intake_detailed_scen_target(t,iso,kfo_seeds) < 0) = 0; * Just to make sure. Can probably be deleted after testing (Just included because I removed the if conditions above as suggested by Benni) - if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), - abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; - ); +* if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), +* abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; +* ); *' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds *** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts even though the EATLancet 2 recommendation is having it as one nuts target? diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index c210001afd..c340a6b096 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -243,7 +243,9 @@ alias(kfo_seeds, kfo_seeds2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); +alias(EAT_nonstaples, EAT_nonstaples2); alias(EAT_staples_old, EAT_staples2_old); +alias(EAT_nonstaples_old, EAT_nonstaples2_old); alias(EAT_pulses15, EAT_pulses15_2); alias(EAT_pulses15_old, EAT_pulses15_2_old); alias(EAT_redmeat15, EAT_redmeat15_2); From 8f1f0accf15b5efeea52e258245e1bb3ac9cb233 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 30 Jan 2024 17:58:07 +0100 Subject: [PATCH 142/187] cleanup --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 14 +++----------- scripts/start/projects/project_EAT2p0.R | 5 +++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 900e11abff..09b26247b6 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -218,7 +218,7 @@ if (s15_run_diet_postprocessing = 1, *' exogenous PHDs, India-specific recommendations or model-internal intake estimates *' that hit the PHD targets by setting the switch `s15_exo_diet` to 1, 2 or 3. -if ((s15_exo_diet > 0), +if (s15_exo_diet > 0, *' 1.) In a first step, the exogenous scenario diets are defined by selecting a *' scenario target for total daily per capita food intake @@ -387,11 +387,6 @@ if (s15_exo_diet = 1, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) ; -*** BENNI / JAN: Please double check: The correction is the same as above commented out code -* The purpose is to correct cases where the EATLancet diet lead to more consumption than allowed by calorie target and staple balancing not sufficient to bring it down. -* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)) < 0) = -* i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old))) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) -* ; if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; @@ -530,8 +525,6 @@ elseif s15_exo_diet = 3, *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); -* Check (temporarily for testing) -display i15_intake_detailed_scen_target; *' (b) seeds (rapeseed, sunflower) are scaled up or down towards the EAT target *' considering scaling of nuts in others. *' Note that the nuts in others count towards the EAT target @@ -539,8 +532,6 @@ display i15_intake_detailed_scen_target; = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; -* Check (temporarily for testing) -display i15_intake_detailed_scen_target; * If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, * seed consumption is reduced to zero. @@ -632,7 +623,8 @@ display i15_intake_detailed_scen_target; i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = 0; i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); + i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / + sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index a7acf1ab9e..ccf51dbfed 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -119,14 +119,15 @@ waste <- function(cfg) { # where miti is active. # Reference: Humpenöder, F., Popp, A., Merfort, L., Luderer, G., Weindl, I., Bodirsky, B., Stevanović, M., Klein, D., Rodrigues, R., Bauer, N., Dietrich, J., Lotze-Campen, H., & Rockström, J. (2023). Data repository - Dietary shifts increase the feasibility of 1.5°C pathways (Version 1) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.8328217 miti <- function(cfg) { + # NDCs + cfg <- setScenario(cfg, c("SSP2", "NDC")) + # Mitigation: consistent with 1.5C cfg$path_to_report_ghgprices <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" cfg$gms$c56_pollutant_prices <- "coupling" cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/florianh/projects/paper/LandEnergy/modelrunsGrassland7/remind/output/C_SSP2EU-PkBudg500-rem-5/REMIND_generic_C_SSP2EU-PkBudg500-rem-5.mif" cfg$gms$c60_2ndgen_biodem <- "coupling" -# Switch on NDCs? - return(cfg) } From e6f66de52dd9b022e89591cf23f3905702882c24 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 1 Feb 2024 10:26:11 +0100 Subject: [PATCH 143/187] re-introduced combined target for nuts (seeds and groundnut) --- config/default.cfg | 6 ++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 29 +++++++------------ modules/15_food/anthro_iso_jun22/sets.gms | 13 ++++----- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index c5c3857bfc..6f544eb120 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "WARNINGS30_rev4.97EAT2p0_h12_magpie.tgz", - cellular = "rev4.97EAT2p0_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.97EAT2p0_h12_validation.tgz", +cfg$input <- c(regional = "rev4.98_h12_magpie.tgz", + cellular = "rev4.98_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.98_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 09b26247b6..550095f245 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -525,29 +525,22 @@ elseif s15_exo_diet = 3, *' The resulting intake of the "others" category is: i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); -*' (b) seeds (rapeseed, sunflower) are scaled up or down towards the EAT target +*' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled +*' up or down towards the EAT nuts target *' considering scaling of nuts in others. -*' Note that the nuts in others count towards the EAT target - i15_intake_detailed_scen_target(t,iso,kfo_seeds) - = p15_intake_detail(t,iso,kfo_seeds) / sum(kfo_seeds2, p15_intake_detail(t,iso,kfo_seeds2)) + i15_intake_detailed_scen_target(t,iso,kfo_ns) + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; +*** ISABELLE: Please double-check whether I can remove the if condition here +*** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) +*** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, +*** it would be ok to correct the seeds and groundnuts down, too...) + * If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, -* seed consumption is reduced to zero. - i15_intake_detailed_scen_target(t,iso,kfo_seeds)$(i15_intake_detailed_scen_target(t,iso,kfo_seeds) < 0) = 0; - -* Just to make sure. Can probably be deleted after testing (Just included because I removed the if conditions above as suggested by Benni) -* if ((sum(kfo_seeds, i15_intake_detailed_scen_target(t,iso,kfo_seeds)) + i15_intake_detailed_scen_nuts(t,iso)) < i15_rec_EATLancet(iso,"t_nutseeds","min"), -* abort "The nuts target is not fulfilled. Please make sure enough nuts and seeds are consumed"; -* ); - -*' (c) For model-internal reasons, MAgPIE considers the peanuts target separate from the other nuts & seeds -*** BENNI: Can you replace "model-internal reasons" with a short explanation why we went for the solution to separate peanuts from nuts even though the EATLancet 2 recommendation is having it as one nuts target? - i15_intake_detailed_scen_target(t,iso,"groundnut")$(p15_intake_detail(t,iso,"groundnut") - < i15_rec_EATLancet(iso,"t_peanuts","min") - ) = - i15_rec_EATLancet(iso,"t_peanuts","min"); +* seed and groundnut consumption is reduced to zero. + i15_intake_detailed_scen_target(t,iso,kfo_ns)$(i15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; ); diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index c340a6b096..8b4735624d 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -109,8 +109,8 @@ sets kfo_pf(kfo) Processed foods including oils sugar alcohol / oils,alcohol,sugar / - kfo_seeds(kfo) Food products that are counted towards seeds - / rapeseed, sunflower/ + kfo_ns(kfo) Food products that are counted towards seeds and nuts other than those included in others + / rapeseed, sunflower, groundnut / kfo_norec(kfo) Food products that do not have an EAT-Lancet recommendation / sugr_cane, sugr_beet, molasses, alcohol / @@ -210,10 +210,10 @@ EAT_targettype15 Minimum or maximum target type of the EAT Lancet recommendation EAT_targets15 Food groups as well as individual foods for which EAT Lancet targets are defined / t_nutseeds, t_fruitveg, t_fruitstarch, t_roots, t_redmeat, - t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_redmeat, t_legumes, t_peanuts, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / + / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / @@ -221,8 +221,7 @@ EAT_special MAgPIE food groups that need special treatment with respect to fruit EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, soybean) - t_peanuts . (groundnut) + t_legumes . (puls_pro, soybean, groundnut) t_fish . (fish) t_livst_chick . (livst_chick) t_livst_egg . (livst_egg) @@ -239,7 +238,7 @@ alias(kfo, kfo2); alias(kfo_ap, kfo_ap2); alias(kfo_st, kfo_st2); alias(kfo_pf, kfo_pf2); -alias(kfo_seeds, kfo_seeds2); +alias(kfo_ns, kfo_ns2); alias(iso, iso2); alias(reproductive, reproductive2); alias(EAT_staples, EAT_staples2); From 511181a3607db6b6689ba0bf74ae7420ce437891 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 1 Feb 2024 15:23:39 +0100 Subject: [PATCH 144/187] bugfixes and update of brans and alcohol default --- config/default.cfg | 28 ++++----- .../15_food/anthro_iso_jun22/exodietmacro.gms | 18 +++--- modules/15_food/anthro_iso_jun22/input.gms | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 27 +++++---- scripts/start/projects/project_EAT2.R | 59 ++++++++++++++++++- scripts/start/test_runs.R | 2 - 6 files changed, 94 insertions(+), 42 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 91996d84a5..f2419153eb 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -432,7 +432,9 @@ cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 # * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" # * (1): transition towards exogenous diets and food demand parametrized # * to a food-specific data set published by the EAT-Lancet Commission -# * (Willett et al., 2019) +# * (Willett et al., 2019). This EATLancet implementation is deprecated. +# * Please use MAgPIE-specific realization of the EAT-Lancet diet (3) +# * for EATLancet diet. # * (0): regression-based estimation of diets and food demand cfg$gms$s15_exo_diet <- 0 # def = 0 @@ -464,26 +466,24 @@ cfg$gms$c15_EAT_scen <- "FLX" # def = FLX cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. # * only activated if s15_exo_diet is set to 1 -cfg$gms$s15_exo_alcohol <- 1 # default: 1 +cfg$gms$s15_exo_alcohol <- 0 # def = 1 (as in EATLancet definition), options: 0,1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. +# * Only activated if s15_exo_alcohol = 1 # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 -# BENNI: I (Feli) would suggest to set s15_exo_alcohol to 0 in default because otherwise it is not in line with EATLancet, -# but that would be what the user expects! It would be better if the user manually has to set it to 0.014 -# when (s)he wants to divert from the standard EATLancet setting! # # # * Switch and specification of countries for which exogenous food scenarios @@ -782,11 +782,11 @@ cfg$gms$s32_max_aff_area <- Inf # def = Inf # Protection of afforested areas (endogenous CO2 price driven) # 0=until end of planning horizon (see s32_planing_horizon) # 1=forever -# Note: Without a price on CO2 emissions from land-use change in module 32_forestry, -# which is the current default (c56_emis_policy <- "reddnatveg_nosoil"), -# the recommended setting for s32_aff_prot is 1. -# Otherwise, the model can do re/afforestation on existing re/afforestation areas -# after the end of planning horizon without penalty for CO2 emissions. +# Note: Without a price on CO2 emissions from land-use change in module 32_forestry, +# which is the current default (c56_emis_policy <- "reddnatveg_nosoil"), +# the recommended setting for s32_aff_prot is 1. +# Otherwise, the model can do re/afforestation on existing re/afforestation areas +# after the end of planning horizon without penalty for CO2 emissions. cfg$gms$s32_aff_prot <- 1 # def = 1 # Type of afforestation constraint @@ -1473,9 +1473,9 @@ cfg$gms$c56_cprice_aff <- "secdforest_vegc" # def = secdforest_vegc # * should not be higher than s32_planing_horizon cfg$gms$s56_c_price_exp_aff <- 50 # def = 50 -# * Share of carbon credits for re/afforestation projects set aside in a buffer to +# * Share of carbon credits for re/afforestation projects set aside in a buffer to # * account for potential failure of permanent carbon storage. -# * Alternatively, this parameter can be interpreted as a reduction factor +# * Alternatively, this parameter can be interpreted as a reduction factor # * of the carbon price for non-permanent CDR. # * Values > 0 will reduce the incentive for c-price-induced re/afforestation cfg$gms$s56_buffer_aff <- 0.5 # def = 0.5 diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 550095f245..3f66ae702e 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -349,7 +349,7 @@ if (s15_exo_diet = 1, if (s15_exo_fish=1, i15_intake_detailed_scen_target(t,iso,"fish") = i15_intake_EATLancet(iso,"fish")); *' lower bound for fruits, veggies, nuts and seeds - if (s15_exo_fruitvegnut=1, + if (s15_exo_fruitvegnutroots=1, i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15)$(i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15) < i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)) = i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)); *' lower bound for pulses @@ -463,7 +463,7 @@ elseif s15_exo_diet = 3, *' lower bound for fruits, veggies, nuts and seeds *' and upper bound for starchy fruits and roots - if (s15_exo_fruitvegnut = 1, + if (s15_exo_fruitvegnutroots = 1, *** Special case: Fruits, vegetables and nuts *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; *' Bananas and plantains are included in the 'cassav_sp' category. @@ -518,7 +518,7 @@ elseif s15_exo_diet = 3, *' (a) nuts included in "others" *' are scaled by the same amount as fruits and vegetables *' because the food group "others" is treated as homogenous food category - i15_intake_detailed_scen_nuts(t,iso) + i15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso) > 0) = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso)) ; @@ -528,17 +528,17 @@ elseif s15_exo_diet = 3, *' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled *' up or down towards the EAT nuts target *' considering scaling of nuts in others. - i15_intake_detailed_scen_target(t,iso,kfo_ns) - = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + i15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; -*** ISABELLE: Please double-check whether I can remove the if condition here +*** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations *** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) *** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, *** it would be ok to correct the seeds and groundnuts down, too...) -* If seeds have been corrected downwards because nuts target already overfulfilled with nuts in others, +* If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. i15_intake_detailed_scen_target(t,iso,kfo_ns)$(i15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; @@ -590,9 +590,7 @@ elseif s15_exo_diet = 3, = s15_alc_scen * i15_intake_scen_target(t,iso); ); *' There is no explicit target for brans in the EATLancet recommendations. -*' It is therefore set to 0. -*** BENNI: Why was this decided in the previous implementation? My approach would have been to keep it at the current level or including it as part of staples. -*** To Do: exclude from both old and new (as last step when approval for the rest of the implementation by Benni/Isabelle) +*' It is set to 0 when s15_exo_brans is activated. if (s15_exo_brans = 1, i15_intake_detailed_scen_target(t,iso,"brans") = 0; ); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 39709fc156..dc19c5132d 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -102,7 +102,7 @@ scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; -scalar s15_exo_fruitvegnut Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; +scalar s15_exo_fruitvegnutroots Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; scalar s15_exo_pulses Exogenous pulses target on (1) / 1 /; scalar s15_exo_sugar Exogenous sugar target on (1) / 1 /; scalar s15_exo_oils Exogenous oils (1) / 1 /; diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 8b4735624d..9eaae22c18 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -212,23 +212,26 @@ EAT_targets15 Food groups as well as individual foods for which EAT Lancet targe t_roots, t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / -EAT_mtargets15(EAT_targets15) EAT Lancet food targets where direct mapping to MAgPIE categories is possible - / t_redmeat, t_legumes, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / +EAT_mtargets15(EAT_targets15) EAT Lancet food targets mapping to MAgPIE categories + / t_redmeat, t_legumes, t_nutseeds, t_roots, t_fish, t_livst_chick, t_livst_egg, t_livst_milk, t_sugar, t_oils / EAT_special MAgPIE food groups that need special treatment with respect to fruit ratio / cassav_sp, others / - +* Note: It is not a 1 to 1 mapping. For certain groups (e.g., others, cassav_sp, +* there are special rules in exodietmacro.gms) EATtar_kfo15(EAT_mtargets15,kfo) Mapping between EAT Lancet food targets and MAgPIE categories - / t_redmeat . (livst_rum, livst_pig, scp) - t_legumes . (puls_pro, soybean, groundnut) - t_fish . (fish) - t_livst_chick . (livst_chick) - t_livst_egg . (livst_egg) - t_livst_milk . (livst_milk) - t_sugar . (sugar) - t_oils . (oils) - / + / t_redmeat . (livst_rum, livst_pig) + t_legumes . (puls_pro, soybean) + t_nutseeds . (rapeseed, sunflower, groundnut) + t_roots . (cassav_sp, potato) + t_fish . (fish) + t_livst_chick . (livst_chick) + t_livst_egg . (livst_egg) + t_livst_milk . (livst_milk) + t_sugar . (sugar) + t_oils . (oils) + / ; diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R index 63f3526d0a..c1fd5fa9c8 100644 --- a/scripts/start/projects/project_EAT2.R +++ b/scripts/start/projects/project_EAT2.R @@ -31,16 +31,69 @@ codeCheck <- FALSE # Testing of new EAT-Lancet diet implementation # ################################################# # Current develop default diet -cfg$title <- "default_Diet" +cfg$title <- "default_Diet_update" cfg$gms$s15_exo_diet <- 0 # default start_run(cfg, codeCheck = codeCheck) # Previous EAT-Lancet implementation -cfg$title <- "eatLancet_1" +cfg$title <- "eatLancet_1_update" cfg$gms$s15_exo_diet <- 1 start_run(cfg, codeCheck = codeCheck) # New EAT-Lancet implementation -cfg$title <- "eatLancet_2" +cfg$title <- "eatLancet_2_update" cfg$gms$s15_exo_diet <- 3 start_run(cfg, codeCheck = codeCheck) + +# Single measures on or off +cfg$title <- "eatLancet_2_ruminants" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) + +cfg$title <- "eatLancet_2_monogastrics" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) + +cfg$title <- "eatLancet_2_fruits" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) + +cfg$title <- "eatLancet_2_legumes" +cfg$gms$s15_exo_diet <- 3 +cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 +start_run(cfg, codeCheck = codeCheck) diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index 2dff4f7ac9..0a5f8c9204 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -54,7 +54,6 @@ for(ssp in c("SSP1","SSP2EU","SSP5")) { cfg$title <- .title(cfg, paste(ssp,"NDC",sep="-")) cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) cfg$gms$c56_mute_ghgprices_until <- "y2150" -# Input for NDC from R32M46 is not available, therefore NPi is used. cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-NDC") cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-NDC") start_run(cfg, codeCheck = FALSE) @@ -84,4 +83,3 @@ start_run(cfg = cfg, codeCheck = codeCheck) cfg <- fsecScenario(scenario = "e_FSDP") cfg$results_folder_highres <- "output" start_run(cfg = cfg, codeCheck = codeCheck) - From c4607157fedd4e679fb8838d56a6eacded5d877f Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 1 Feb 2024 17:33:19 +0100 Subject: [PATCH 145/187] updated config and included test --- config/default.cfg | 6 +++--- config/scenario_config.csv | 1 + config/scenario_fsec.csv | 1 + modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index f2419153eb..8745f97157 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -476,14 +476,14 @@ cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. -# * only activated if s15_exo_diet is set to 1 -cfg$gms$s15_exo_alcohol <- 0 # def = 1 (as in EATLancet definition), options: 0,1 +# * Only activated if s15_exo_diet is set to 1 +cfg$gms$s15_exo_alcohol <- 1 # def = 1, options: 0,1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * Only activated if s15_exo_alcohol = 1 # * (0): no alcohol consumption, as in the original version of the EAT-Lancet diet # * (0.014): maximum target for alcohol consumption is 1.4% of total calorie consumption # * (see Lassen et al., 2020) -cfg$gms$s15_alc_scen <- 0.014 # def = 0.014 +cfg$gms$s15_alc_scen <- 0 # def = 0 # # # * Switch and specification of countries for which exogenous food scenarios diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 167b6c5696..6368478075 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -23,6 +23,7 @@ gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 384a29f5aa..928dc548e8 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -19,6 +19,7 @@ gms$s15_exo_sugar;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_oils;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_scp;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_alcohol;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; +gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c15_food_scenario;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c21_trade_liberalization;;;;;;;;;;;;;;;;;;;;;;;l908080r807070;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BH_IFL;;;;;;;;;;;;;;;;;;;; diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 3f66ae702e..6aa32ba567 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -381,6 +381,8 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; +display i15_intake_detailed_scen_target; + * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = 0; @@ -610,6 +612,8 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); +display i15_intake_detailed_scen_target; + * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = 0; From ef4fd1e8085d9601f69aff8264dcffacf0df2c4f Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 5 Feb 2024 18:03:33 +0100 Subject: [PATCH 146/187] updated preprocessing revision to 4.99 --- CHANGELOG.md | 2 +- config/default.cfg | 6 +++--- config/scenario_fsec.csv | 6 +++--- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 4 ---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8296b1c137..3566c4a1e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### changed - **15_food** Added improved EAT Lancet diet implementation (EAT 2p0) -- **default.cfg** update input data to rev 4.98 +- **default.cfg** update input data to rev 4.99 (new validation data, new EATLancet recommendations, new semi-natural vegtation cropland data) - **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. - **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` diff --git a/config/default.cfg b/config/default.cfg index 8745f97157..a120182de7 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.98_h12_magpie.tgz", - cellular = "rev4.98_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.98_h12_validation.tgz", +cfg$input <- c(regional = "rev4.99_h12_magpie.tgz", + cellular = "rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.99_h12_validation.tgz", additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 928dc548e8..9069268243 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -66,9 +66,9 @@ gms$s62_max_dem_bioplastic;0;;;;400;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_fac_req_regr;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_feed_scen;;;;;;;;;;;;;;;;;;ssp1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;; -input['cellular'];rev4.96_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.96_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -input['regional'];rev4.96_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['validation'];rev4.96_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['cellular'];rev4.99_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.99_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.99_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['regional'];rev4.99_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['validation'];rev4.99_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['additional'];additional_data_rev4.47.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_24Mar23.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_SSP1-PkBudg900.mif diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 6aa32ba567..cb8be4c701 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -394,10 +394,6 @@ display i15_intake_detailed_scen_target; abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; ); -* VARTIKA: What about s15_exo_diet = 2? -* Can this be transformed to the new diet implementation? Did you have target values there? -* (Note: The old EATLancet implementation should be deleted soon.) - *---------------------------------------------------------------------------------------- elseif s15_exo_diet = 3, *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), From 3e4b0a8c7f1608f795b20b48c3fe7826b81639b3 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 5 Feb 2024 18:11:40 +0100 Subject: [PATCH 147/187] delte testing script --- scripts/start/projects/project_EAT2.R | 99 --------------------------- 1 file changed, 99 deletions(-) delete mode 100644 scripts/start/projects/project_EAT2.R diff --git a/scripts/start/projects/project_EAT2.R b/scripts/start/projects/project_EAT2.R deleted file mode 100644 index c1fd5fa9c8..0000000000 --- a/scripts/start/projects/project_EAT2.R +++ /dev/null @@ -1,99 +0,0 @@ -# | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | MAgPIE License Exception, version 1.0 (see LICENSE file). -# | Contact: magpie@pik-potsdam.de - -# ---------------------------------------------------------- -# description: EAT 2.0 simulations -# ---------------------------------------------------------- - -###################################### -#### Script to start a MAgPIE run #### -###################################### -library(gms) -library(lucode2) -library(magclass) - -# load start_function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -# laod default configuration -source("config/default.cfg") - -cfg$force_download <- TRUE - -# Set defaults -codeCheck <- FALSE - -################################################# -# Testing of new EAT-Lancet diet implementation # -################################################# -# Current develop default diet -cfg$title <- "default_Diet_update" -cfg$gms$s15_exo_diet <- 0 # default -start_run(cfg, codeCheck = codeCheck) - -# Previous EAT-Lancet implementation -cfg$title <- "eatLancet_1_update" -cfg$gms$s15_exo_diet <- 1 -start_run(cfg, codeCheck = codeCheck) - -# New EAT-Lancet implementation -cfg$title <- "eatLancet_2_update" -cfg$gms$s15_exo_diet <- 3 -start_run(cfg, codeCheck = codeCheck) - -# Single measures on or off -cfg$title <- "eatLancet_2_ruminants" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) - -cfg$title <- "eatLancet_2_monogastrics" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) - -cfg$title <- "eatLancet_2_fruits" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) - -cfg$title <- "eatLancet_2_legumes" -cfg$gms$s15_exo_diet <- 3 -cfg$gms$s15_exo_monogastric <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_ruminant <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fish <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_sugar <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_oils <- 0 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 -cfg$gms$s15_exo_scp <- 0 # def = 1, options: 0,1 -start_run(cfg, codeCheck = codeCheck) From 89eb6135fe05c405d183578fb411f3a2802db517 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 7 Feb 2024 15:39:57 +0100 Subject: [PATCH 148/187] updated renv setting --- config/default.cfg | 2 +- core/sets.gms | 48 +++--- main.gms | 46 ++--- renv/activate.R | 421 +++++++++++++-------------------------------- 4 files changed, 165 insertions(+), 352 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index a120182de7..71fcaca7d0 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -25,7 +25,7 @@ cfg$model <- "main.gms" #def = "main.gms" cfg$input <- c(regional = "rev4.99_h12_magpie.tgz", cellular = "rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.99_h12_validation.tgz", - additional = "additional_data_rev4.46.tgz", + additional = "additional_data_rev4.47.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data diff --git a/core/sets.gms b/core/sets.gms index e49a577fe4..4e35a355a6 100644 --- a/core/sets.gms +++ b/core/sets.gms @@ -55,32 +55,32 @@ sets VEN, VGB, VIR, VNM, VUT, WLF, WSM, YEM, ZAF, ZMB, ZWE / j number of LPJ cells - / CAZ_1*CAZ_5, - CHA_6*CHA_21, - EUR_22*EUR_29, - IND_30*IND_36, - JPN_37*JPN_38, - LAM_39*LAM_79, - MEA_80*MEA_109, - NEU_110*NEU_117, - OAS_118*OAS_128, - REF_129*REF_140, - SSA_141*SSA_179, - USA_180*USA_200 / + / CAZ_1*CAZ_14, + CHA_15*CHA_37, + EUR_38*EUR_47, + IND_48*IND_54, + JPN_55*JPN_58, + LAM_59*LAM_84, + MEA_85*MEA_105, + NEU_106*NEU_114, + OAS_115*OAS_130, + REF_131*REF_153, + SSA_154*SSA_185, + USA_186*USA_200 / cell(i,j) number of LPJ cells per region i - / CAZ . (CAZ_1*CAZ_5) - CHA . (CHA_6*CHA_21) - EUR . (EUR_22*EUR_29) - IND . (IND_30*IND_36) - JPN . (JPN_37*JPN_38) - LAM . (LAM_39*LAM_79) - MEA . (MEA_80*MEA_109) - NEU . (NEU_110*NEU_117) - OAS . (OAS_118*OAS_128) - REF . (REF_129*REF_140) - SSA . (SSA_141*SSA_179) - USA . (USA_180*USA_200) / + / CAZ . (CAZ_1*CAZ_14) + CHA . (CHA_15*CHA_37) + EUR . (EUR_38*EUR_47) + IND . (IND_48*IND_54) + JPN . (JPN_55*JPN_58) + LAM . (LAM_59*LAM_84) + MEA . (MEA_85*MEA_105) + NEU . (NEU_106*NEU_114) + OAS . (OAS_115*OAS_130) + REF . (REF_131*REF_153) + SSA . (SSA_154*SSA_185) + USA . (USA_186*USA_200) / i_to_iso(i,iso) mapping regions to iso countries / CAZ . (AUS, CAN, HMD, NZL, SPM) diff --git a/main.gms b/main.gms index bc9b0bacfc..20ea421f75 100644 --- a/main.gms +++ b/main.gms @@ -147,56 +147,56 @@ $title magpie *' * Always try to access model outputs through the corresponding magpie package instead of accessing them directly with readGDX. It cannot be guaranteed that your script will work in the future if you do otherwise (as only the corresponding magpie package will be continuously adapted to changes in the GAMS code). *##################### R SECTION START (VERSION INFO) ########################## -* -* Used data set: rev4.96_h12_magpie.tgz +* +* Used data set: rev4.99_h12_magpie.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* -* Used data set: rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* +* Used data set: rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* -* Used data set: rev4.96_h12_validation.tgz +* +* Used data set: rev4.99_h12_validation.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* +* * Used data set: additional_data_rev4.47.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive -* +* * Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz * md5sum: NA * Repository: https://rse.pik-potsdam.de/data/magpie/public -* +* * Low resolution: c200 * High resolution: 0.5 -* +* * Total number of cells: 200 -* +* * Number of cells per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA -* 5 16 8 7 2 41 30 8 11 12 39 21 -* +* 14 23 10 7 4 26 21 9 16 23 32 15 +* * Regionscode: 62eff8f7 -* -* Regions data revision: 4.96 -* +* +* Regions data revision: 4.99 +* * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.96 -* +* * Revision: 4.99 +* * aggregation settings: * * Input resolution: 0.5 * * Output resolution: c200 * * Regionscode: 62eff8f7 * * Number of clusters per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA -* 5 16 8 7 2 41 30 8 11 12 39 21 +* 14 23 10 7 4 26 21 9 16 23 32 15 * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) -* -* -* Last modification (input data): Fri Dec 22 16:58:47 2023 -* +* +* +* Last modification (input data): Wed Feb 7 15:35:14 2024 +* *###################### R SECTION END (VERSION INFO) ########################### $offupper diff --git a/renv/activate.R b/renv/activate.R index 55dae8650e..019b5a6693 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -3,7 +3,6 @@ local({ # the requested version of renv version <- "0.16.0" - attr(version, "sha") <- "0e3aab27a928eb261819a3fc45a3ee2b4ba902a5" # the project directory project <- getwd() @@ -61,75 +60,21 @@ local({ # load bootstrap tools `%||%` <- function(x, y) { - if (is.null(x)) y else x - } - - catf <- function(fmt, ..., appendLF = TRUE) { - - quiet <- getOption("renv.bootstrap.quiet", default = FALSE) - if (quiet) - return(invisible()) - - msg <- sprintf(fmt, ...) - cat(msg, file = stdout(), sep = if (appendLF) "\n" else "") - - invisible(msg) - - } - - header <- function(label, - ..., - prefix = "#", - suffix = "-", - n = min(getOption("width"), 78)) - { - label <- sprintf(label, ...) - n <- max(n - nchar(label) - nchar(prefix) - 2L, 8L) - if (n <= 0) - return(paste(prefix, label)) - - tail <- paste(rep.int(suffix, n), collapse = "") - paste0(prefix, " ", label, " ", tail) - - } - - startswith <- function(string, prefix) { - substring(string, 1, nchar(prefix)) == prefix + if (is.environment(x) || length(x)) x else y } bootstrap <- function(version, library) { - friendly <- renv_bootstrap_version_friendly(version) - section <- header(sprintf("Bootstrapping renv %s", friendly)) - catf(section) - # attempt to download renv - catf("- Downloading renv ... ", appendLF = FALSE) - withCallingHandlers( - tarball <- renv_bootstrap_download(version), - error = function(err) { - catf("FAILED") - stop("failed to download:\n", conditionMessage(err)) - } - ) - catf("OK") - on.exit(unlink(tarball), add = TRUE) + tarball <- tryCatch(renv_bootstrap_download(version), error = identity) + if (inherits(tarball, "error")) + stop("failed to download renv ", version) # now attempt to install - catf("- Installing renv ... ", appendLF = FALSE) - withCallingHandlers( - status <- renv_bootstrap_install(version, tarball, library), - error = function(err) { - catf("FAILED") - stop("failed to install:\n", conditionMessage(err)) - } - ) - catf("OK") - - # add empty line to break up bootstrapping from normal output - catf("") + status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) + if (inherits(status, "error")) + stop("failed to install renv ", version) - return(invisible()) } renv_bootstrap_tests_running <- function() { @@ -138,32 +83,28 @@ local({ renv_bootstrap_repos <- function() { - # get CRAN repository - cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") - # check for repos override repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) { - - # check for RSPM; if set, use a fallback repository for renv - rspm <- Sys.getenv("RSPM", unset = NA) - if (identical(rspm, repos)) - repos <- c(RSPM = rspm, CRAN = cran) - + if (!is.na(repos)) return(repos) - } - # check for lockfile repositories repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) if (!inherits(repos, "error") && length(repos)) return(repos) + # if we're testing, re-use the test repositories + if (renv_bootstrap_tests_running()) + return(getOption("renv.tests.repos")) + # retrieve current repos repos <- getOption("repos") # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- cran + repos[repos == "@CRAN@"] <- getOption( + "renv.repos.cran", + "https://cloud.r-project.org" + ) # add in renv.bootstrap.repos if set default <- c(FALLBACK = "https://cloud.r-project.org") @@ -202,34 +143,33 @@ local({ renv_bootstrap_download <- function(version) { - sha <- attr(version, "sha", exact = TRUE) - - methods <- if (!is.null(sha)) { - - # attempting to bootstrap a development version of renv - c( - function() renv_bootstrap_download_tarball(sha), - function() renv_bootstrap_download_github(sha) + # if the renv version number has 4 components, assume it must + # be retrieved via github + nv <- numeric_version(version) + components <- unclass(nv)[[1]] + + # if this appears to be a development version of 'renv', we'll + # try to restore from github + dev <- length(components) == 4L + + # begin collecting different methods for finding renv + methods <- c( + renv_bootstrap_download_tarball, + if (dev) + renv_bootstrap_download_github + else c( + renv_bootstrap_download_cran_latest, + renv_bootstrap_download_cran_archive ) - - } else { - - # attempting to bootstrap a release version of renv - c( - function() renv_bootstrap_download_tarball(version), - function() renv_bootstrap_download_cran_latest(version), - function() renv_bootstrap_download_cran_archive(version) - ) - - } + ) for (method in methods) { - path <- tryCatch(method(), error = identity) + path <- tryCatch(method(version), error = identity) if (is.character(path) && file.exists(path)) return(path) } - stop("All download methods failed") + stop("failed to download renv ", version) } @@ -293,6 +233,8 @@ local({ type <- spec$type repos <- spec$repos + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + baseurl <- utils::contrib.url(repos = repos, type = type) ext <- if (identical(type, "source")) ".tar.gz" @@ -309,10 +251,13 @@ local({ condition = identity ) - if (inherits(status, "condition")) + if (inherits(status, "condition")) { + message("FAILED") return(FALSE) + } # report success and return + message("OK (downloaded ", type, ")") destfile } @@ -369,6 +314,8 @@ local({ urls <- file.path(repos, "src/contrib/Archive/renv", name) destfile <- file.path(tempdir(), name) + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + for (url in urls) { status <- tryCatch( @@ -376,11 +323,14 @@ local({ condition = identity ) - if (identical(status, 0L)) + if (identical(status, 0L)) { + message("OK") return(destfile) + } } + message("FAILED") return(FALSE) } @@ -394,7 +344,8 @@ local({ return() # allow directories - if (dir.exists(tarball)) { + info <- file.info(tarball, extra_cols = FALSE) + if (identical(info$isdir, TRUE)) { name <- sprintf("renv_%s.tar.gz", version) tarball <- file.path(tarball, name) } @@ -403,7 +354,7 @@ local({ if (!file.exists(tarball)) { # let the user know we weren't able to honour their request - fmt <- "- RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." + fmt <- "* RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." msg <- sprintf(fmt, tarball) warning(msg) @@ -412,7 +363,10 @@ local({ } - catf("- Using local tarball '%s'.", tarball) + fmt <- "* Bootstrapping with tarball at path '%s'." + msg <- sprintf(fmt, tarball) + message(msg) + tarball } @@ -439,6 +393,8 @@ local({ on.exit(do.call(base::options, saved), add = TRUE) } + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) name <- sprintf("renv_%s.tar.gz", version) destfile <- file.path(tempdir(), name) @@ -448,105 +404,26 @@ local({ condition = identity ) - if (!identical(status, 0L)) + if (!identical(status, 0L)) { + message("FAILED") return(FALSE) - - renv_bootstrap_download_augment(destfile) - - return(destfile) - - } - - # Add Sha to DESCRIPTION. This is stop gap until #890, after which we - # can use renv::install() to fully capture metadata. - renv_bootstrap_download_augment <- function(destfile) { - sha <- renv_bootstrap_git_extract_sha1_tar(destfile) - if (is.null(sha)) { - return() } - # Untar - tempdir <- tempfile("renv-github-") - on.exit(unlink(tempdir, recursive = TRUE), add = TRUE) - untar(destfile, exdir = tempdir) - pkgdir <- dir(tempdir, full.names = TRUE)[[1]] - - # Modify description - desc_path <- file.path(pkgdir, "DESCRIPTION") - desc_lines <- readLines(desc_path) - remotes_fields <- c( - "RemoteType: github", - "RemoteHost: api.github.com", - "RemoteRepo: renv", - "RemoteUsername: rstudio", - "RemotePkgRef: rstudio/renv", - paste("RemoteRef: ", sha), - paste("RemoteSha: ", sha) - ) - writeLines(c(desc_lines[desc_lines != ""], remotes_fields), con = desc_path) - - # Re-tar - local({ - old <- setwd(tempdir) - on.exit(setwd(old), add = TRUE) - - tar(destfile, compression = "gzip") - }) - invisible() - } + message("OK") + return(destfile) - # Extract the commit hash from a git archive. Git archives include the SHA1 - # hash as the comment field of the tarball pax extended header - # (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) - # For GitHub archives this should be the first header after the default one - # (512 byte) header. - renv_bootstrap_git_extract_sha1_tar <- function(bundle) { - - # open the bundle for reading - # We use gzcon for everything because (from ?gzcon) - # > Reading from a connection which does not supply a ‘gzip’ magic - # > header is equivalent to reading from the original connection - conn <- gzcon(file(bundle, open = "rb", raw = TRUE)) - on.exit(close(conn)) - - # The default pax header is 512 bytes long and the first pax extended header - # with the comment should be 51 bytes long - # `52 comment=` (11 chars) + 40 byte SHA1 hash - len <- 0x200 + 0x33 - res <- rawToChar(readBin(conn, "raw", n = len)[0x201:len]) - - if (grepl("^52 comment=", res)) { - sub("52 comment=", "", res) - } else { - NULL - } } renv_bootstrap_install <- function(version, tarball, library) { # attempt to install it into project library + message("* Installing renv ", version, " ... ", appendLF = FALSE) dir.create(library, showWarnings = FALSE, recursive = TRUE) - output <- renv_bootstrap_install_impl(library, tarball) - - # check for successful install - status <- attr(output, "status") - if (is.null(status) || identical(status, 0L)) - return(status) - - # an error occurred; report it - header <- "installation of renv failed" - lines <- paste(rep.int("=", nchar(header)), collapse = "") - text <- paste(c(header, lines, output), collapse = "\n") - stop(text) - - } - - renv_bootstrap_install_impl <- function(library, tarball) { # invoke using system2 so we can capture and report output bin <- R.home("bin") exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" - R <- file.path(bin, exe) + r <- file.path(bin, exe) args <- c( "--vanilla", "CMD", "INSTALL", "--no-multiarch", @@ -554,7 +431,19 @@ local({ shQuote(path.expand(tarball)) ) - system2(R, args, stdout = TRUE, stderr = TRUE) + output <- system2(r, args, stdout = TRUE, stderr = TRUE) + message("Done!") + + # check for successful install + status <- attr(output, "status") + if (is.numeric(status) && !identical(status, 0L)) { + header <- "Error installing renv:" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- c(header, lines, output) + writeLines(text, con = stderr()) + } + + status } @@ -764,58 +653,32 @@ local({ } - renv_bootstrap_validate_version <- function(version, description = NULL) { - - # resolve description file - description <- description %||% { - path <- getNamespaceInfo("renv", "path") - packageDescription("renv", lib.loc = dirname(path)) - } - - # check whether requested version 'version' matches loaded version of renv - sha <- attr(version, "sha", exact = TRUE) - valid <- if (!is.null(sha)) - renv_bootstrap_validate_version_dev(sha, description) - else - renv_bootstrap_validate_version_release(version, description) + renv_bootstrap_validate_version <- function(version) { - if (valid) + loadedversion <- utils::packageDescription("renv", fields = "Version") + if (version == loadedversion) return(TRUE) - # the loaded version of renv doesn't match the requested version; - # give the user instructions on how to proceed - remote <- if (!is.null(description[["RemoteSha"]])) { - paste("rstudio/renv", description[["RemoteSha"]], sep = "@") - } else { - paste("renv", description[["Version"]], sep = "@") - } - - # display both loaded version + sha if available - friendly <- renv_bootstrap_version_friendly( - version = description[["Version"]], - sha = description[["RemoteSha"]] - ) + # assume four-component versions are from GitHub; three-component + # versions are from CRAN + components <- strsplit(loadedversion, "[.-]")[[1]] + remote <- if (length(components) == 4L) + paste("rstudio/renv", loadedversion, sep = "@") + else + paste("renv", loadedversion, sep = "@") fmt <- paste( "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", - "- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", - "- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", sep = "\n" ) - catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) - FALSE + msg <- sprintf(fmt, loadedversion, version, remote) + warning(msg, call. = FALSE) - } - - renv_bootstrap_validate_version_dev <- function(version, description) { - expected <- description[["RemoteSha"]] - is.character(expected) && startswith(expected, version) - } + FALSE - renv_bootstrap_validate_version_release <- function(version, description) { - expected <- description[["Version"]] - is.character(expected) && identical(expected, version) } renv_bootstrap_hash_text <- function(text) { @@ -837,12 +700,6 @@ local({ # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) - # execute renv load hooks, if any - hooks <- getHook("renv::autoload") - for (hook in hooks) - if (is.function(hook)) - tryCatch(hook(), error = warning) - # load the project renv::load(project) @@ -982,66 +839,14 @@ local({ } - renv_bootstrap_version_friendly <- function(version, sha = NULL) { - sha <- sha %||% attr(version, "sha", exact = TRUE) - parts <- c(version, sprintf("[sha: %s]", substring(sha, 1L, 7L))) - paste(parts, collapse = " ") - } - - renv_bootstrap_run <- function(version, libpath) { - - # perform bootstrap - bootstrap(version, libpath) - - # exit early if we're just testing bootstrap - if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) - return(TRUE) - - # try again to load - if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { - return(renv::load(project = getwd())) - } - - # failed to download or load renv; warn the user - msg <- c( - "Failed to find an renv installation: the project will not be loaded.", - "Use `renv::activate()` to re-initialize the project." - ) - - warning(paste(msg, collapse = "\n"), call. = FALSE) - - } - - - renv_bootstrap_in_rstudio <- function() { - commandArgs()[[1]] == "RStudio" - } renv_json_read <- function(file = NULL, text = NULL) { - jlerr <- NULL - # if jsonlite is loaded, use that instead - if ("jsonlite" %in% loadedNamespaces()) { - - json <- catch(renv_json_read_jsonlite(file, text)) - if (!inherits(json, "error")) - return(json) - - jlerr <- json - - } - - # otherwise, fall back to the default JSON reader - json <- catch(renv_json_read_default(file, text)) - if (!inherits(json, "error")) - return(json) - - # report an error - if (!is.null(jlerr)) - stop(jlerr) + if ("jsonlite" %in% loadedNamespaces()) + renv_json_read_jsonlite(file, text) else - stop(json) + renv_json_read_default(file, text) } @@ -1159,23 +964,31 @@ local({ if (renv_bootstrap_load(project, libpath, version)) return(TRUE) - if (renv_bootstrap_in_rstudio()) { - setHook("rstudio.sessionInit", function(...) { - renv_bootstrap_run(version, libpath) + # load failed; inform user we're about to bootstrap + prefix <- paste("# Bootstrapping renv", version) + postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") + header <- paste(prefix, postfix) + message(header) - # Work around buglet in RStudio if hook uses readline - tryCatch( - { - tools <- as.environment("tools:rstudio") - tools$.rs.api.sendToConsole("", echo = FALSE, focus = FALSE) - }, - error = function(cnd) {} - ) - }) - } else { - renv_bootstrap_run(version, libpath) + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + message("* Successfully installed and loaded renv ", version, ".") + return(renv::load()) } - invisible() + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) }) From adbbca6e61b95475d1a7e298276381a47eb8d360 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:48:24 +0100 Subject: [PATCH 149/187] Shuffled authors in food module --- modules/15_food/anthro_iso_jun22/realization.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/realization.gms b/modules/15_food/anthro_iso_jun22/realization.gms index e2c4c14760..10726a83ea 100644 --- a/modules/15_food/anthro_iso_jun22/realization.gms +++ b/modules/15_food/anthro_iso_jun22/realization.gms @@ -45,4 +45,4 @@ $Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthro_iso_jun22/posts *' diet scenarios, most importantly the shift to the Planetary Health diet *' [@willett_food_2019]. *' -*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich, Felicitas Beier +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Felicitas Beier, Jan Philipp Dietrich From e14238471d3c18e9829f79158d3d8ea62651ca42 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 7 Feb 2024 16:47:50 +0100 Subject: [PATCH 150/187] removed unnecessary display statements --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 3 --- modules/15_food/anthropometrics_jan18/preloop.gms | 5 ----- 2 files changed, 8 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index cb8be4c701..2b0582432a 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -381,8 +381,6 @@ if (s15_exo_diet = 1, (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; -display i15_intake_detailed_scen_target; - * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = 0; @@ -608,7 +606,6 @@ elseif s15_exo_diet = 3, (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); -display i15_intake_detailed_scen_target; * Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = diff --git a/modules/15_food/anthropometrics_jan18/preloop.gms b/modules/15_food/anthropometrics_jan18/preloop.gms index 8d84dcd7c6..f8c9a123fa 100644 --- a/modules/15_food/anthropometrics_jan18/preloop.gms +++ b/modules/15_food/anthropometrics_jan18/preloop.gms @@ -52,11 +52,6 @@ Elseif s15_milk_share_fadeout_india = 1, i15_milk_share_fadeout_india(t) = f15_milk_share_fadeout_india(t); ); -display i15_milk_share_fadeout_india; - - - - * ###### Exogenous food waste and diet scenarios as well as food substitution scenarios From 89854b60232982168bf0b38cbe1cd37d4524f5d1 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 9 Feb 2024 14:28:54 +0100 Subject: [PATCH 151/187] improvements recommended by Bennis review --- config/default.cfg | 5 +- .../15_food/anthro_iso_jun22/declarations.gms | 3 +- .../15_food/anthro_iso_jun22/exodietmacro.gms | 202 +++++++++--------- modules/15_food/anthro_iso_jun22/input.gms | 3 +- modules/15_food/anthro_iso_jun22/preloop.gms | 3 - .../anthropometrics_jan18/declarations.gms | 2 +- .../anthropometrics_jan18/intersolve.gms | 8 +- .../anthropometrics_jan18/presolve.gms | 10 +- 8 files changed, 121 insertions(+), 115 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 71fcaca7d0..183f0dbb0b 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -466,11 +466,12 @@ cfg$gms$c15_EAT_scen <- "FLX" # def = FLX cfg$gms$s15_exo_monogastric <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_ruminant <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_fish <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_fruitvegnutroots <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_fruitvegnut <- 1 # def = 1, options: 0,1 +cfg$gms$s15_exo_roots <- 1 # def = 1, options: 0,1 (only relevant for new EATLancet realization s15_exo_diet=3) cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet. with 1: brans are set to 0), options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet, they are kept at their historical value, unless switch activated (1), then brans are set to 0), options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 0aac72e28e..c87cd37652 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -152,9 +152,8 @@ parameters i15_intake_scen_target(t,iso) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_intake_EATLancet_all(iso,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) - i15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + p15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) Minimum and maximum targets for healthy diets recommended by the EAT-Lancet Commission (kcal per capita per day) i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 2b0582432a..e56b2ef099 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -313,10 +313,10 @@ $else $endif *' The intake target is adjusted to meet the calorie target - i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = + p15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) > 0) = p15_intake_detail(t,iso,kfo) / p15_intake_total(t,iso) * i15_intake_scen_target(t,iso); - i15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) = 0) = 0; + p15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_total(t,iso) = 0) = 0; *' 2.) The second step defines the daily per capita intake of different food *' commodities. @@ -339,64 +339,64 @@ if (s15_exo_diet = 1, *' upper bound for monogastric meat and eggs if (s15_exo_monogastric=1, - i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15)$(i15_intake_detailed_scen_target(t,iso,EAT_monogastrics15) > i15_intake_EATLancet(iso,EAT_monogastrics15)) + p15_intake_detailed_scen_target(t,iso,EAT_monogastrics15)$(p15_intake_detailed_scen_target(t,iso,EAT_monogastrics15) > i15_intake_EATLancet(iso,EAT_monogastrics15)) = i15_intake_EATLancet(iso,EAT_monogastrics15)); *' upper bound for ruminant products if (s15_exo_ruminant=1, - i15_intake_detailed_scen_target(t,iso,EAT_ruminants15)$(i15_intake_detailed_scen_target(t,iso,EAT_ruminants15) > i15_intake_EATLancet(iso,EAT_ruminants15)) + p15_intake_detailed_scen_target(t,iso,EAT_ruminants15)$(p15_intake_detailed_scen_target(t,iso,EAT_ruminants15) > i15_intake_EATLancet(iso,EAT_ruminants15)) = i15_intake_EATLancet(iso,EAT_ruminants15)); *' target value for fish if (s15_exo_fish=1, - i15_intake_detailed_scen_target(t,iso,"fish") = i15_intake_EATLancet(iso,"fish")); + p15_intake_detailed_scen_target(t,iso,"fish") = i15_intake_EATLancet(iso,"fish")); *' lower bound for fruits, veggies, nuts and seeds - if (s15_exo_fruitvegnutroots=1, - i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15)$(i15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15) < i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)) + if (s15_exo_fruitvegnut=1, + p15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15)$(p15_intake_detailed_scen_target(t,iso,EAT_fruitvegnutseed15) < i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)) = i15_intake_EATLancet(iso,EAT_fruitvegnutseed15)); *' lower bound for pulses if (s15_exo_pulses=1, - i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old)$(i15_intake_detailed_scen_target(t,iso,EAT_pulses15_old) < i15_intake_EATLancet(iso,EAT_pulses15_old)) + p15_intake_detailed_scen_target(t,iso,EAT_pulses15_old)$(p15_intake_detailed_scen_target(t,iso,EAT_pulses15_old) < i15_intake_EATLancet(iso,EAT_pulses15_old)) = i15_intake_EATLancet(iso,EAT_pulses15_old)); *' upper bound for sugar if (s15_exo_sugar=1, - i15_intake_detailed_scen_target(t,iso,EAT_sugar15)$(i15_intake_detailed_scen_target(t,iso,EAT_sugar15) > i15_intake_EATLancet(iso,EAT_sugar15)) + p15_intake_detailed_scen_target(t,iso,EAT_sugar15)$(p15_intake_detailed_scen_target(t,iso,EAT_sugar15) > i15_intake_EATLancet(iso,EAT_sugar15)) = i15_intake_EATLancet(iso,EAT_sugar15)); *' target value for oils if (s15_exo_oils=1, - i15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils")); + p15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils")); *' target value for brans if (s15_exo_brans=1, - i15_intake_detailed_scen_target(t,iso,"brans") = i15_intake_EATLancet(iso,"brans")); + p15_intake_detailed_scen_target(t,iso,"brans") = i15_intake_EATLancet(iso,"brans")); *' target value for single cell protein if (s15_exo_scp=1, - i15_intake_detailed_scen_target(t,iso,"scp") = i15_intake_EATLancet(iso,"scp")); + p15_intake_detailed_scen_target(t,iso,"scp") = i15_intake_EATLancet(iso,"scp")); *' upper bound for alcohol * alcohol target is not part of EAT Lancet recommendation. Upper boundary is therefore included as specific switch s15_alc_scen if (s15_exo_alcohol=1, - i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,iso)) + p15_intake_detailed_scen_target(t,iso,"alcohol")$(p15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,iso)) = s15_alc_scen*i15_intake_scen_target(t,iso); ); - i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old))) * + p15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old)) > 0) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old))) * (i15_intake_EATLancet(iso,EAT_staples_old) / sum(EAT_staples2_old, i15_intake_EATLancet(iso,EAT_staples2_old))) ; -* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = +* Correction where calorie balancing would lead to negative p15_intake_detailed_scen_target values + p15_intake_detailed_scen_target(t,iso,EAT_staples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = 0; - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) + p15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) < 0) = + i15_intake_scen_target(t,iso) * p15_intake_detailed_scen_target(t,iso,EAT_nonstaples_old) / sum(EAT_nonstaples2_old, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2_old)) ; - if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, - abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + if (smin((iso,kfo), p15_intake_detailed_scen_target(t,iso,kfo)) < 0, + abort "The parameter p15_intake_detailed_scen_target became negative after calorie balancing."; ); *---------------------------------------------------------------------------------------- elseif s15_exo_diet = 3, *' In case of a MAgPIE-specific realization of the EAT Lancet diet (`s15_exo_diet=3`), *' model-internal diet projections are constrained by recommended ranges for intake -*' (`i15_rec_EATLancet`) of different food groups to ensure healthy and sustainable +*' (`f15_rec_EATLancet`) of different food groups to ensure healthy and sustainable *' diets according to the EAT-Lancet Commission. After all calorie recommendations *' for non-staple food groups are satisfied, intake of staple crops is modified such *' that the in step 1.) selected total calorie intake is met. @@ -417,52 +417,50 @@ elseif s15_exo_diet = 3, *' upper bound for monogastric products if (s15_exo_monogastric = 1, * upper bound for eggs - i15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") - > i15_rec_EATLancet(iso,"t_livst_egg","max") + p15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") + > f15_rec_EATLancet(iso,"t_livst_egg","max") ) = - i15_rec_EATLancet(iso,"t_livst_egg","max"); + f15_rec_EATLancet(iso,"t_livst_egg","max"); * upper bound for chicken - i15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") - > i15_rec_EATLancet(iso,"t_livst_chick","max") + p15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") + > f15_rec_EATLancet(iso,"t_livst_chick","max") ) = - i15_rec_EATLancet(iso,"t_livst_chick","max"); + f15_rec_EATLancet(iso,"t_livst_chick","max"); * upper bound for redmeat (share of pigs in redmeat) - i15_intake_detailed_scen_target(t,iso,"livst_pig")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) - > i15_rec_EATLancet(iso,"t_redmeat","max") + p15_intake_detailed_scen_target(t,iso,"livst_pig")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > f15_rec_EATLancet(iso,"t_redmeat","max") ) = (p15_intake_detail(t,iso,"livst_pig") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) - * i15_rec_EATLancet(iso,"t_redmeat","max"); + * f15_rec_EATLancet(iso,"t_redmeat","max"); ); *' upper bound for ruminant products if (s15_exo_ruminant = 1, * upper bound for redmeat (pig and ruminant) - i15_intake_detailed_scen_target(t,iso,"livst_rum")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) - > i15_rec_EATLancet(iso,"t_redmeat","max") + p15_intake_detailed_scen_target(t,iso,"livst_rum")$(sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2)) + > f15_rec_EATLancet(iso,"t_redmeat","max") ) = (p15_intake_detail(t,iso,"livst_rum") / sum(EAT_redmeat15_2, p15_intake_detail(t,iso,EAT_redmeat15_2))) - * i15_rec_EATLancet(iso,"t_redmeat","max"); + * f15_rec_EATLancet(iso,"t_redmeat","max"); * upper bound for milk - i15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") - > i15_rec_EATLancet(iso,"t_livst_milk","max") + p15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") + > f15_rec_EATLancet(iso,"t_livst_milk","max") ) = - i15_rec_EATLancet(iso,"t_livst_milk","max"); + f15_rec_EATLancet(iso,"t_livst_milk","max"); ); *' lower bound for fish if (s15_exo_fish = 1, - i15_intake_detailed_scen_target(t,iso,"fish")$(p15_intake_detail(t,iso,"fish") - < i15_rec_EATLancet(iso,"t_fish","min") + p15_intake_detailed_scen_target(t,iso,"fish")$(p15_intake_detail(t,iso,"fish") + < f15_rec_EATLancet(iso,"t_fish","min") ) = - i15_rec_EATLancet(iso,"t_fish","min"); + f15_rec_EATLancet(iso,"t_fish","min"); ); -*' lower bound for fruits, veggies, nuts and seeds -*' and upper bound for starchy fruits and roots - if (s15_exo_fruitvegnutroots = 1, -*** Special case: Fruits, vegetables and nuts *** + +*** Special case: Fruits, vegetables, nuts, and roots *** *' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; -*' Bananas and plantains are included in the 'cassav_sp' category. +*' Starchy fruits (bananas and plantains) are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. @@ -477,23 +475,17 @@ elseif s15_exo_diet = 3, p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); -*' Maximum recommendation for starchy fruits: +* Initialize scenario target for case that switch is not active i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); - i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > i15_rec_EATLancet(iso,"t_fruitstarch","max")) - = i15_rec_EATLancet(iso,"t_fruitstarch","max"); - -*' Maximum recommendation for roots: i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); - i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_rec_EATLancet(iso,"t_roots","max"); + p15_intake_detailed_scen_target(t,iso,"potato") = p15_intake_detail(t,iso,"potato"); - i15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) - = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); +*' lower bound for fruits, veggies, nuts and seeds + if (s15_exo_fruitvegnut = 1, - i15_intake_detailed_scen_target(t,iso,"cassav_sp")$(p15_intake_detail_roots(t,iso) > i15_rec_EATLancet(iso,"t_roots","max")) = - i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail_roots(t,iso) - - i15_intake_detailed_scen_target(t,iso,"potato") + - i15_intake_detailed_scen_starchyfruit(t,iso); +*' Maximum recommendation for starchy fruits: + i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > f15_rec_EATLancet(iso,"t_fruitstarch","max")) + = f15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Split the 'others' category into fruits plus vegetables and nuts p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); @@ -502,10 +494,10 @@ elseif s15_exo_diet = 3, i15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); *' Minimum recommendation for fruits and vegetables: - i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < i15_rec_EATLancet(iso,"t_fruitveg","min")) - = i15_rec_EATLancet(iso,"t_fruitveg","min"); + i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < f15_rec_EATLancet(iso,"t_fruitveg","min")) + = f15_rec_EATLancet(iso,"t_fruitveg","min"); -*' Extract fruits and vegetables that are part of others categroy +*' Extract fruits and vegetables that are part of others category * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); @@ -519,103 +511,119 @@ elseif s15_exo_diet = 3, ; *' The resulting intake of the "others" category is: - i15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + p15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); *' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled *' up or down towards the EAT nuts target *' considering scaling of nuts in others. - i15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (i15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) ; *** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations *** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) *** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, -*** it would be ok to correct the seeds and groundnuts down, too...) +*** it would be ok to correct the seeds and groundnuts down...) * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. - i15_intake_detailed_scen_target(t,iso,kfo_ns)$(i15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(p15_intake_detailed_scen_target(t,iso,kfo_ns) < 0) = 0; ); +*' upper bound for roots + if (s15_exo_roots = 1, + +*' Maximum recommendation for roots: + i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) + = f15_rec_EATLancet(iso,"t_roots","max"); + + p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) + = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + + ); + +* Assign starchy fruit and cassava roots back to cassava_sp scenario target + p15_intake_detailed_scen_target(t,iso,"cassav_sp") = + i15_intake_detailed_scen_roots(t,iso) - + p15_intake_detailed_scen_target(t,iso,"potato") + + i15_intake_detailed_scen_starchyfruit(t,iso); + *' lower bound for legumes if (s15_exo_pulses = 1, - i15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2)) - < i15_rec_EATLancet(iso,"t_legumes","min") + p15_intake_detailed_scen_target(t,iso,EAT_pulses15)$(sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2)) + < f15_rec_EATLancet(iso,"t_legumes","min") ) = (p15_intake_detail(t,iso,EAT_pulses15) / sum(EAT_pulses15_2, p15_intake_detail(t,iso,EAT_pulses15_2))) - * i15_rec_EATLancet(iso,"t_legumes","min"); + * f15_rec_EATLancet(iso,"t_legumes","min"); ); *' upper bound for sugar if (s15_exo_sugar = 1, - i15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") - > i15_rec_EATLancet(iso,"t_sugar","max") + p15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") + > f15_rec_EATLancet(iso,"t_sugar","max") ) = - i15_rec_EATLancet(iso,"t_sugar","max"); + f15_rec_EATLancet(iso,"t_sugar","max"); ); *' upper and lower bound for oils if (s15_exo_oils = 1, -* i15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") +* p15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") * oil_veg has a minimum and maximum recommendation in EAT - i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") - < i15_rec_EATLancet(iso,"t_oils","min") + p15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + < f15_rec_EATLancet(iso,"t_oils","min") ) = - i15_rec_EATLancet(iso,"t_oils","min"); + f15_rec_EATLancet(iso,"t_oils","min"); * oil palm has a maximum recommendation in EAT - i15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") - > i15_rec_EATLancet(iso,"t_oils","max") + p15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + > f15_rec_EATLancet(iso,"t_oils","max") ) = - i15_rec_EATLancet(iso,"t_oils","max"); + f15_rec_EATLancet(iso,"t_oils","max"); ); * Food commodities that are not included in diet recommendations are set to zero: - i15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; + p15_intake_detailed_scen_target(t,iso,kfo_norec) = 0; * Optionally, there is an exception for alcohol if s15_exo_alcohol = 1: * Even though it would be 0 following the EAT Lancet recommendation, * an alternative maximum target can be set via 's15_alc_scen' for alcohol consumption, * e.g. following the recommendation according to Lassen et al., (2020). if (s15_exo_alcohol = 1, - i15_intake_detailed_scen_target(t,iso,"alcohol")$(i15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) + p15_intake_detailed_scen_target(t,iso,"alcohol")$(p15_intake_detailed_scen_target(t,iso,"alcohol") > s15_alc_scen * i15_intake_scen_target(t,iso)) = s15_alc_scen * i15_intake_scen_target(t,iso); ); *' There is no explicit target for brans in the EATLancet recommendations. *' It is set to 0 when s15_exo_brans is activated. if (s15_exo_brans = 1, - i15_intake_detailed_scen_target(t,iso,"brans") = 0; + p15_intake_detailed_scen_target(t,iso,"brans") = 0; ); *' There is no explicit target for single cell protein in the EATLancet recommendations. *' It is therefore set to 0. if (s15_exo_scp = 1, - i15_intake_detailed_scen_target(t,iso,"scp") = 0; + p15_intake_detailed_scen_target(t,iso,"scp") = 0; ); *** Balancing calorie requirements *** *' After all calorie recommendations for non-staple food groups are satisfied, -*' intake of staple crops is now modified such that the -*' in step 1.) selected total calorie intake is met. -*' Note that brans do not have an EAT Lancet target and are kept at their -*' original level. - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = - (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) +*' intake of staple crops is now modified such that +*' the above-selected total calorie intake is met. + p15_intake_detailed_scen_target(t,iso,EAT_staples)$(sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2)) > 0) = + (i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2))) * (p15_intake_detail(t,iso,EAT_staples) / sum(EAT_staples2, p15_intake_detail(t,iso,EAT_staples2))); -* Correction where calorie balancing would lead to negative i15_intake_detailed_scen_target values - i15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = +* Correction where calorie balancing would lead to negative p15_intake_detailed_scen_target values + p15_intake_detailed_scen_target(t,iso,EAT_staples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = 0; - i15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = - i15_intake_scen_target(t,iso) * i15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / - sum(EAT_nonstaples2, i15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); + p15_intake_detailed_scen_target(t,iso,EAT_nonstaples)$(i15_intake_scen_target(t,iso) - sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)) < 0) = + i15_intake_scen_target(t,iso) * p15_intake_detailed_scen_target(t,iso,EAT_nonstaples) / + sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); - if (smin((iso,kfo), i15_intake_detailed_scen_target(t,iso,kfo)) < 0, - abort "The parameter i15_intake_detailed_scen_target became negative after calorie balancing."; + if (smin((iso,kfo), p15_intake_detailed_scen_target(t,iso,kfo)) < 0, + abort "The parameter p15_intake_detailed_scen_target became negative after calorie balancing."; ); ); @@ -626,7 +634,7 @@ elseif s15_exo_diet = 3, *' convergence (note that fading should start after the historical time slice of *' the EAT Lancet diet scenarios (y2010) as defined in `i15_exo_foodscen_fader(t,iso)`): p15_intake_detail(t,iso,kfo) = p15_intake_detail(t,iso,kfo) * (1-i15_exo_foodscen_fader(t,iso)) - + i15_intake_detailed_scen_target(t,iso,kfo) * i15_exo_foodscen_fader(t,iso); + + p15_intake_detailed_scen_target(t,iso,kfo) * i15_exo_foodscen_fader(t,iso); p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) * (1-i15_exo_foodscen_fader(t,iso)) + p15_bmi_shr_target(t,iso,sex,age,bmi_group15) * i15_exo_foodscen_fader(t,iso); diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index dc19c5132d..4df838948e 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -102,7 +102,8 @@ scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; -scalar s15_exo_fruitvegnutroots Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; +scalar s15_exo_fruitvegnut Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 /; +scalar s15_exo_roots Exogenous EAT Lancet root target on (1) / 1 /; scalar s15_exo_pulses Exogenous pulses target on (1) / 1 /; scalar s15_exo_sugar Exogenous sugar target on (1) / 1 /; scalar s15_exo_oils Exogenous oils (1) / 1 /; diff --git a/modules/15_food/anthro_iso_jun22/preloop.gms b/modules/15_food/anthro_iso_jun22/preloop.gms index b10933b160..6d2b9fba94 100644 --- a/modules/15_food/anthro_iso_jun22/preloop.gms +++ b/modules/15_food/anthro_iso_jun22/preloop.gms @@ -90,9 +90,6 @@ $else ); $endif -* Initialisation of the recommendations for healthy food intake: -i15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15) = f15_rec_EATLancet(iso,EAT_targets15,EAT_targettype15); - * initial prices in $US per Kcal i15_prices_initial_kcal(iso,kfo)$(fm_nutrition_attributes("y1995",kfo,"kcal")>0) = f15_prices_initial(kfo) / (fm_nutrition_attributes("y1995",kfo,"kcal")*10**6); diff --git a/modules/15_food/anthropometrics_jan18/declarations.gms b/modules/15_food/anthropometrics_jan18/declarations.gms index 072a935f0c..b945726f5f 100644 --- a/modules/15_food/anthropometrics_jan18/declarations.gms +++ b/modules/15_food/anthropometrics_jan18/declarations.gms @@ -154,7 +154,7 @@ parameters i15_intake_scen_target(t,i) Target for total per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) i15_intake_EATLancet_all(i,kcal_scen15,EAT_scen15,kfo) Food-specific per capita calorie intake according to various EAT Lancet diet scenarios (kcal per capita per day) i15_intake_EATLancet(i,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) - i15_intake_detailed_scen_target(t,i,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) + p15_intake_detailed_scen_target(t,i,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) p15_intake_detailed_regr(t,i,kfo) Food-specific per capita calorie intake according to regression-based projections (kcal per capita per day) p15_demand2intake_ratio_ref(i) Ratio between food calorie demand and intake for the historical time step of EAT Lancet diets (1) diff --git a/modules/15_food/anthropometrics_jan18/intersolve.gms b/modules/15_food/anthropometrics_jan18/intersolve.gms index a554ed199f..49e85612ff 100644 --- a/modules/15_food/anthropometrics_jan18/intersolve.gms +++ b/modules/15_food/anthropometrics_jan18/intersolve.gms @@ -352,12 +352,12 @@ if(s15_exo_diet = 1, * Via 's15_alc_scen' a maximum target for alcohol consumption is defined. if(s15_alc_scen>0, - i15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); - i15_intake_detailed_scen_target(t,i,"alcohol")$(i15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) + p15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); + p15_intake_detailed_scen_target(t,i,"alcohol")$(p15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) = s15_alc_scen*i15_intake_scen_target(t,i); ); - i15_intake_detailed_scen_target(t,i,EAT_staples) = ( + p15_intake_detailed_scen_target(t,i,EAT_staples) = ( i15_intake_scen_target(t,i) - sum(EAT_nonstaples,i15_intake_EATLancet(i,EAT_nonstaples)) )*( i15_intake_EATLancet(i,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(i,EAT_staples2)) ); @@ -374,7 +374,7 @@ if(s15_exo_diet = 1, i15_kcal_pc_scen_target(t,i,kfo) = (f15_calib_fsupply(i)*f15_overcons_FAOwaste(i,kfo) - *i15_intake_detailed_scen_target(t,i,kfo)) + *p15_intake_detailed_scen_target(t,i,kfo)) *p15_foodwaste_growth(t,i); *' In the last step, the regression-based calculation of daily per capita food demand diff --git a/modules/15_food/anthropometrics_jan18/presolve.gms b/modules/15_food/anthropometrics_jan18/presolve.gms index 64ed7f2fe4..d293c2348c 100644 --- a/modules/15_food/anthropometrics_jan18/presolve.gms +++ b/modules/15_food/anthropometrics_jan18/presolve.gms @@ -597,17 +597,17 @@ p15_intake_detailed_regr(t,i,kfo) = p15_kcal_pc_calibrated(t,i,kfo) /(f15_calib_fsupply(i)*f15_overcons_FAOwaste(i,kfo)*p15_foodwaste_growth(t,i)); -i15_intake_detailed_scen_target(t,i,EAT_nonstaples) = i15_intake_EATLancet(i,EAT_nonstaples); +p15_intake_detailed_scen_target(t,i,EAT_nonstaples) = i15_intake_EATLancet(i,EAT_nonstaples); * The EAT-Lancet diet only allows for added sugars, but does not include processed food or * alcohol. Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. if(s15_alc_scen>0, -i15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); -i15_intake_detailed_scen_target(t,i,"alcohol")$(i15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) +p15_intake_detailed_scen_target(t,i,"alcohol") = p15_intake_detailed_regr(t,i,"alcohol"); +p15_intake_detailed_scen_target(t,i,"alcohol")$(p15_intake_detailed_scen_target(t,i,"alcohol") > s15_alc_scen*i15_intake_scen_target(t,i)) = s15_alc_scen*i15_intake_scen_target(t,i); ); -i15_intake_detailed_scen_target(t,i,EAT_staples) = ( +p15_intake_detailed_scen_target(t,i,EAT_staples) = ( i15_intake_scen_target(t,i) - sum(EAT_nonstaples,i15_intake_EATLancet(i,EAT_nonstaples)) )*( i15_intake_EATLancet(i,EAT_staples)/sum(EAT_staples2,i15_intake_EATLancet(i,EAT_staples2)) ); @@ -624,7 +624,7 @@ i15_intake_detailed_scen_target(t,i,EAT_staples) = ( *' of the EAT Lancet diet scenarios, according to the regression-based approach. i15_kcal_pc_scen_target(t,i,kfo) = (f15_calib_fsupply(i)*f15_overcons_FAOwaste(i,kfo) - *i15_intake_detailed_scen_target(t,i,kfo)) + *p15_intake_detailed_scen_target(t,i,kfo)) *p15_foodwaste_growth(t,i); *' 4.) In the last step, the regression-based calculation of daily per capita food demand From c95f929b0ad91dfe705df54c3e8a1d8d959bbaed Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 12 Feb 2024 11:40:33 +0100 Subject: [PATCH 152/187] added roots switch to scenario config files --- config/scenario_config.csv | 1 + config/scenario_fsec.csv | 1 + 2 files changed, 2 insertions(+) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 6368478075..3e06cb6c78 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -17,6 +17,7 @@ gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_roots;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 9069268243..41d3fe24e0 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -14,6 +14,7 @@ gms$s15_exo_monogastric;;;;;;;;0;0;0;1;0;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;; gms$s15_exo_ruminant;;;;;;;;0;0;0;0;1;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_fish;;;;;;;;0;0;0;0;0;0;0;1;0;;;;;;;;;;;;;;;;;0;0;;;;;;;;;;;;;;; gms$s15_exo_fruitvegnut;;;;;;;;0;0;1;0;0;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; +gms$s15_exo_roots;;;;;;;;0;0;1;0;0;0;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_pulses;;;;;;;;0;0;0;0;0;1;0;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_sugar;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$s15_exo_oils;;;;;;;;0;0;0;0;0;0;1;0;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; From c81d11154fff9c3b32b7c2c96f846b27aa58e867 Mon Sep 17 00:00:00 2001 From: Felicitas Beier Date: Mon, 12 Feb 2024 12:21:32 +0100 Subject: [PATCH 153/187] added new column with EATLancet 2 diet for coupled runs in magpie scenario config --- config/scenario_config.csv | 174 ++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 87 deletions(-) mode change 100644 => 100755 config/scenario_config.csv diff --git a/config/scenario_config.csv b/config/scenario_config.csv old mode 100644 new mode 100755 index 3e06cb6c78..f01fc4c2f2 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -1,87 +1,87 @@ -;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5;NGFS_o_lowdem -gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 -gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 -gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; -gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;;; -gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;;;lin_zero_20_50 -gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 -gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;;;1.2 -gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 -gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;;;healthy_BMI -gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;;; -gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_roots;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; -gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; -gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; -gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; -gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;;; -gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; -gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; -gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; -gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; -gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; -gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;;; -gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;3;3;3;3;3;;;;;;;;;;;;;;;;;;; -gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;on;on;on;on;on;;;;;;;;;;;;;;;;;;; -gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;;; -gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_buffer_aff;;;;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.2;0.3;;;;;;;0.5;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c56_emis_policy;;;;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;redd_nosoil;all_nosoil;;;;;;;reddnatveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; -gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;;; -gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; -gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; -gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; -gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; -gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; -gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;;; -gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;;; -gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;0;0;0;0;0;;;;;0;0;0;;;;;;;;;;;; -gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; -gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;; -gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; -gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.96_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; -gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; -gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; -gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;; +;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;EL2_Diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5;NGFS_o_lowdem +gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; +gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;;;lin_zero_20_50 +gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;;;1.2 +gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;3;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;;;healthy_BMI +gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;;; +gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_roots;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;0;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_alc_scen;0.014;;;;;;;;;;;;;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; +gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; +gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;;; +gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;;; +gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;;3;3;3;3;3;;;;;;;;;;;;;;;;;;; +gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;;on;on;on;on;on;;;;;;;;;;;;;;;;;;; +gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;;; +gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_buffer_aff;;;;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.2;0.3;;;;;;;0.5;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c56_emis_policy;;;;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;redd_nosoil;all_nosoil;;;;;;;reddnatveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;;; +gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; +gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; +gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;;; +gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;;; +gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;;0;0;0;0;0;;;;;0;0;0;;;;;;;;;;;; +gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; +gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;; +gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; +gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; +gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.96_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; +gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; +gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; +gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;; From 0fc7724d04d9a20f2a94e46596b10043ad37dab4 Mon Sep 17 00:00:00 2001 From: Felicitas Beier Date: Mon, 12 Feb 2024 14:16:43 +0100 Subject: [PATCH 154/187] added productivity increase in EATLancet 2 diet scenario --- config/scenario_config.csv | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index f01fc4c2f2..bf6c7bed6a 100755 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -2,6 +2,8 @@ gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$s12_interest_lic;;;;;;;;;;;;;;;;;;;;;;0.06;;;;;;;;;;;;;;;;;;;;;;;; +gms$s12_interest_hic;;;;;;;;;;;;;;;;;;;;;;0.04;;;;;;;;;;;;;;;;;;;;;;;; gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; @@ -65,7 +67,7 @@ gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;ph gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; -gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; From 28393d0bbab7b0058851d38656370c6c821ecdc5 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:35:56 +0100 Subject: [PATCH 155/187] Update CHANGELOG.md Update changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3566c4a1e9..9daf4f1a9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` - **scenario_config.csv** removed erroneous setting `cc` from column `input` - **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` -- **default.cfg** update input data to rev 4.96 - **default.cfg** changed default for `cfg$gms$s56_buffer_aff` from 0.2 to 0.5 - **default.cfg** changed default for `cfg$gms$s32_aff_prot` from 0 to 1 - **21_trade** s21_trade_bal_damper for roundwood changed from 0.75 to 0.65 From af7249dcd3077ab40937f95b97d761291afa515a Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:38:38 +0100 Subject: [PATCH 156/187] Update default.cfg Added reference to Springmann et al. 2018 --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 183f0dbb0b..1b4c193dde 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -426,7 +426,7 @@ cfg$gms$s15_waste_scen <- 1.2 # def = 1.2 # * (3): MAgPIE-specific realization of the EAT-Lancet diet, where model-internal # * (regression-based) food demand projections are constrained by ranges for # * intake targets of food groups to ensure healthy and sustainable diets as -# * recommended by the EAT-Lancet Commission +# * recommended by the EAT-Lancet Commission (following Springmann et al. 2018 and Willett et al. 2019) # * (2): transition towards exogenous diets (NIN for India and EAT for other regions) # * Please use this switch in combination with cfg$gms$c15_EAT_scen <- "FLX_hmilk" # * If only India's diet needs to be changed, then set cfg$gms$scen_countries15 <- "IND" From 003c3e72e93ec23e81f5c60d938bbcba6e664a5d Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:54:14 +0100 Subject: [PATCH 157/187] Update literature.bib added springmann reference --- literature.bib | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/literature.bib b/literature.bib index 697d7d6b71..adb1364d84 100644 --- a/literature.bib +++ b/literature.bib @@ -43,6 +43,19 @@ @article{willett_food_2019 year = {2019}, } +@article{springmann_options_2018, + title = {Options for Keeping the Food System within Environmental Limits}, + doi = {https://doi.org/10.1038/s41586-018-0594-0}, + language = {en}, + journal = {Nature}, + volume = "562", + number = "7728", + pages = "519 - 525", + author = {Springmann, Marco, Michael Clark, Daniel Mason-D’Croz, Keith Wiebe, Benjamin Leon Bodirsky, Luis Lassaletta, Wim de Vries, Sonja J. Vermeulen, Mario Herrero, Kimberly M. Carlson, Malin Jonell, Max Troell, Fabrice DeClerck, Line J. Gordon, Rami Zurayk, Peter Scarborough, Mike Rayner, Brent Loken, Jess Franzo, H. Charles J. Godfray, David Tilman, Johan Rockström, Walter Willett}, + month = oct, + year = {2018}, +} + @misc{FAOSTAT, author = {FAOSTAT}, title = {{FAOSTAT Database}}, From 156bed07635953f78417b88e0cb1b77cc3f67ed4 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:57:52 +0100 Subject: [PATCH 158/187] Update default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 1b4c193dde..37cb67d9f0 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -459,7 +459,7 @@ cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI cfg$gms$c15_EAT_scen <- "FLX" # def = FLX # * Sub-specifications: Which commodities shall be included in the diet shift -# * towards cfg$gms$c15_EAT_scen ? Only selected (1) commodities will be +# * towards the selected scenario diet? Only selected (1) commodities will be # * included, while the others will remain to be endogenous. # * Any shift will be compensated to reach the calorie target by adjusting # * staple calories. From 1f2f9690a90cdc817a6eb48040cd44cca079aeaf Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:50:50 +0100 Subject: [PATCH 159/187] Update default.cfg updated additional data --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 37cb67d9f0..38efa6659e 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -25,7 +25,7 @@ cfg$model <- "main.gms" #def = "main.gms" cfg$input <- c(regional = "rev4.99_h12_magpie.tgz", cellular = "rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.99_h12_validation.tgz", - additional = "additional_data_rev4.47.tgz", + additional = "additional_data_rev4.48.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data From 9a673b989ff54b5ae1fa9446533f70eb9c8f84d3 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:52:04 +0100 Subject: [PATCH 160/187] Update default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 38efa6659e..07c68713b6 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -471,7 +471,7 @@ cfg$gms$s15_exo_roots <- 1 # def = 1, options: 0,1 (only relevant for n cfg$gms$s15_exo_pulses <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_sugar <- 1 # def = 1, options: 0,1 cfg$gms$s15_exo_oils <- 1 # def = 1, options: 0,1 -cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet, they are kept at their historical value, unless switch activated (1), then brans are set to 0), options: 0,1 +cfg$gms$s15_exo_brans <- 0 # def = 0 (as no target defined in EATLancet, they are kept at their projected level, unless switch activated (1), then brans are set to 0), options: 0,1 cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet From 34b9621129de9597837049e19c15aae4e10cce5e Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 09:41:16 +0100 Subject: [PATCH 161/187] updated EAT2p0 start script --- scripts/start/projects/project_EAT2p0.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R index ccf51dbfed..cbc789fbc5 100644 --- a/scripts/start/projects/project_EAT2p0.R +++ b/scripts/start/projects/project_EAT2p0.R @@ -78,11 +78,10 @@ bau <- function(cfg) { ### Diet component ## # Globally achieves EL2 diet by 2050 # To Do: Check implementation diet <- function(cfg) { - cfg$gms$s15_exo_diet <- 1 # To Do: switch to 3 once implementation is ready + cfg$gms$s15_exo_diet <- 3 cfg$gms$s15_alc_scen <- 0 # No alcohol allowed as in the definition of EATLancet cfg$gms$c15_kcal_scen <- "healthy_BMI" # default: not necessary to set it again (To Do: remove) cfg$gms$c15_EAT_scen <- "FLX" # default: not necessary to set it again (To Do: remove) - cfg$gms$s15_alc_scen <- 0 # In EATLancet, no calories for alcohol. return(cfg) } From 1f4add998d1ba40ea5b72eb492338bfc19f2ba1c Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:44:15 +0100 Subject: [PATCH 162/187] Update default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 07c68713b6..c2f42ff6dc 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -477,7 +477,7 @@ cfg$gms$s15_exo_scp <- 1 # def = 1, options: 0,1 # * Scenario target for the inclusion of alcohol in the EAT-Lancet diet # * The EAT-Lancet diet only allows for added sugars, # * but does not include processed food or alcohol. -# * Only activated if s15_exo_diet is set to 1 +# * Only activated if s15_exo_diet is set to 1 or 3 cfg$gms$s15_exo_alcohol <- 1 # def = 1, options: 0,1 # * Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. # * Only activated if s15_exo_alcohol = 1 From efefb22ad2e88fbbace45c5c2fa1a071d46b5ac5 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 14:21:13 +0100 Subject: [PATCH 163/187] small fixed requested in the review from Isabelle and renaming to stick to the coding etiquette --- .../15_food/anthro_iso_jun22/declarations.gms | 10 ++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 49 +++++++++---------- modules/15_food/anthro_iso_jun22/input.gms | 2 +- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index c87cd37652..48ed9d52de 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -154,15 +154,15 @@ parameters i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) p15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) + i15_fruit_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) p15_intake_detail_nuts(t,iso) Auxiliary parameter for the intake of nuts included in others (kcal per capita per day) - i15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) - i15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) - i15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - i15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) + p15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) + p15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) + p15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) + p15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e56b2ef099..aa5d22e61f 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -322,7 +322,7 @@ $endif *' commodities. *---------------------------------------------------------------------------------------- -if (s15_exo_diet = 1, +if ((s15_exo_diet = 1 or s15_exo_diet = 2), *' In case of diet scenarios that are parametrized to a food-specific data set published *' by the EAT-Lancet Commission (`s15_exo_diet=1`), this calculation step consists of *' filling up the scenario target for total daily per capita food intake according @@ -459,71 +459,71 @@ elseif s15_exo_diet = 3, *** Special case: Fruits, vegetables, nuts, and roots *** -*' In MAgPIE fruits, vegetables and nuts are combined in the 'other' food category; +*' In MAgPIE fruits, vegetables and certain nuts are combined in the 'other' food category; *' Starchy fruits (bananas and plantains) are included in the 'cassav_sp' category. *' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. if (sum(sameas(t_past,t),1) = 1, - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + i15_fruit_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); else - i15_fruitveg2others_kcal_ratio(t,iso,EAT_special) = i15_fruitveg2others_kcal_ratio(t-1,iso,EAT_special); + i15_fruit_ratio(t,iso,EAT_special) = i15_fruit_ratio(t-1,iso,EAT_special); ); *' Separation of starchy fruits (bananas and plantains) *' and roots (cassava, sweet potato, yams) in the cassav_sp food category - p15_intake_detail_starchyfruit(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); - p15_intake_detail_roots(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); + p15_intake_detail_starchyfruit(t,iso) = i15_fruit_ratio(t,iso,"cassav_sp") * p15_intake_detail(t,iso,"cassav_sp"); + p15_intake_detail_roots(t,iso) = (1 - i15_fruit_ratio(t,iso,"cassav_sp")) * p15_intake_detail(t,iso,"cassav_sp") + p15_intake_detail(t,iso,"potato"); * Initialize scenario target for case that switch is not active - i15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); - i15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); + p15_intake_detailed_scen_starchyfruit(t,iso) = p15_intake_detail_starchyfruit(t,iso); + p15_intake_detailed_scen_roots(t,iso) = p15_intake_detail_roots(t,iso); p15_intake_detailed_scen_target(t,iso,"potato") = p15_intake_detail(t,iso,"potato"); *' lower bound for fruits, veggies, nuts and seeds if (s15_exo_fruitvegnut = 1, *' Maximum recommendation for starchy fruits: - i15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > f15_rec_EATLancet(iso,"t_fruitstarch","max")) + p15_intake_detailed_scen_starchyfruit(t,iso)$(p15_intake_detail_starchyfruit(t,iso) > f15_rec_EATLancet(iso,"t_fruitstarch","max")) = f15_rec_EATLancet(iso,"t_fruitstarch","max"); *' Split the 'others' category into fruits plus vegetables and nuts - p15_intake_detail_fruitveg(t,iso) = i15_fruitveg2others_kcal_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + i15_intake_detailed_scen_starchyfruit(t,iso); - p15_intake_detail_nuts(t,iso) = (1 - i15_fruitveg2others_kcal_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); - i15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); - i15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); + p15_intake_detail_fruitveg(t,iso) = i15_fruit_ratio(t,iso,"others") * p15_intake_detail(t,iso,"others") + p15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detail_nuts(t,iso) = (1 - i15_fruit_ratio(t,iso,"others")) * p15_intake_detail(t,iso,"others"); + p15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detail_fruitveg(t,iso); + p15_intake_detailed_scen_nuts(t,iso) = p15_intake_detail_nuts(t,iso); *' Minimum recommendation for fruits and vegetables: - i15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < f15_rec_EATLancet(iso,"t_fruitveg","min")) + p15_intake_detailed_scen_fruitveg(t,iso)$(p15_intake_detail_fruitveg(t,iso) < f15_rec_EATLancet(iso,"t_fruitveg","min")) = f15_rec_EATLancet(iso,"t_fruitveg","min"); *' Extract fruits and vegetables that are part of others category * Note that starchy fruits are kept at the previously assigned maximum level * and their amount has been added to cassav_sp already. - i15_intake_detailed_scen_fruitveg(t,iso) = i15_intake_detailed_scen_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds *' (a) nuts included in "others" *' are scaled by the same amount as fruits and vegetables *' because the food group "others" is treated as homogenous food category - i15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso) > 0) - = p15_intake_detail_nuts(t,iso) * i15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - i15_intake_detailed_scen_starchyfruit(t,iso)) + p15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso) > 0) + = p15_intake_detail_nuts(t,iso) * p15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso)) ; *' The resulting intake of the "others" category is: - p15_intake_detailed_scen_target(t,iso,"others") = i15_intake_detailed_scen_fruitveg(t,iso) + i15_intake_detailed_scen_nuts(t,iso); + p15_intake_detailed_scen_target(t,iso,"others") = p15_intake_detailed_scen_fruitveg(t,iso) + p15_intake_detailed_scen_nuts(t,iso); *' (b) remaining nuts (groundnut) and seeds (rapeseed, sunflower) are scaled *' up or down towards the EAT nuts target *' considering scaling of nuts in others. p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (f15_rec_EATLancet(iso,"t_nutseeds","min") - i15_intake_detailed_scen_nuts(t,iso)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) ; *** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations *** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) -*** Benni and my reasoning was that if the nuts in others (i15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, +*** Benni and my reasoning was that if the nuts in others (p15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, *** it would be ok to correct the seeds and groundnuts down...) * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, @@ -536,19 +536,19 @@ elseif s15_exo_diet = 3, if (s15_exo_roots = 1, *' Maximum recommendation for roots: - i15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) + p15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) = f15_rec_EATLancet(iso,"t_roots","max"); p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) - = i15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + = p15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); ); * Assign starchy fruit and cassava roots back to cassava_sp scenario target p15_intake_detailed_scen_target(t,iso,"cassav_sp") = - i15_intake_detailed_scen_roots(t,iso) - + p15_intake_detailed_scen_roots(t,iso) - p15_intake_detailed_scen_target(t,iso,"potato") + - i15_intake_detailed_scen_starchyfruit(t,iso); + p15_intake_detailed_scen_starchyfruit(t,iso); *' lower bound for legumes if (s15_exo_pulses = 1, @@ -569,7 +569,6 @@ elseif s15_exo_diet = 3, *' upper and lower bound for oils if (s15_exo_oils = 1, -* p15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils") * oil_veg has a minimum and maximum recommendation in EAT p15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") < f15_rec_EATLancet(iso,"t_oils","min") diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 4df838948e..4d9328f4cf 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -107,7 +107,7 @@ scalar s15_exo_roots Exogenous EAT Lancet root target on (1) / 1 /; scalar s15_exo_pulses Exogenous pulses target on (1) / 1 /; scalar s15_exo_sugar Exogenous sugar target on (1) / 1 /; scalar s15_exo_oils Exogenous oils (1) / 1 /; -scalar s15_exo_brans Exogenous brans (1) / 1 /; +scalar s15_exo_brans Exogenous brans (1) / 0 /; scalar s15_exo_scp Exogenous microbial protein target on (1) / 1 /; * The EAT-Lancet diet only allows for added sugars, but does not include processed food or * alcohol. Via 's15_alc_scen' a maximum target for alcohol consumption can be defined. From d47d7cb3c68e9280d4d0bd36e59680f644a654ee Mon Sep 17 00:00:00 2001 From: pvjeetze Date: Mon, 19 Feb 2024 16:38:43 +0100 Subject: [PATCH 164/187] changed SEALS reporting and underlying function --- scripts/output/extra/reportMAgPIE2SEALS.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/output/extra/reportMAgPIE2SEALS.R b/scripts/output/extra/reportMAgPIE2SEALS.R index 9045995e17..437b86a1d4 100644 --- a/scripts/output/extra/reportMAgPIE2SEALS.R +++ b/scripts/output/extra/reportMAgPIE2SEALS.R @@ -34,7 +34,7 @@ title <- cfg$title # Restructure data to conform to SEALS reportLandUseForSEALS( - magCellLand = "cell.land_0.5_share.nc", + magCellLand = "cell.land_0.5_share.mz", outFile = paste0("cell.land_0.5_SEALS_", title, ".nc"), - dir = outputdir, selectyears = c(2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050) + dir = outputdir, selectyears = c(2020, 2030, 2040, 2050) ) From 8934a353d4e9b47a10e218e5896d387290d09d36 Mon Sep 17 00:00:00 2001 From: pvjeetze Date: Mon, 19 Feb 2024 16:45:34 +0100 Subject: [PATCH 165/187] changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa8d7dd03c..69e3616681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` - **scenario_config.csv** removed erroneous setting `cc` from column `input` - **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` -- **default.cfg** update input data to rev 4.96 +- **default.cfg** update input data to rev 4.96 - **default.cfg** changed default for `cfg$gms$s56_buffer_aff` from 0.2 to 0.5 - **default.cfg** changed default for `cfg$gms$s32_aff_prot` from 0 to 1 - **21_trade** s21_trade_bal_damper for roundwood changed from 0.75 to 0.65 @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **58_peatland** removed realization "on" ### fixed +- **scripts** Fixed writing of NetCDF files in output/reportMAgPIE2SEALS.R - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k - **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs - **35_natveg** bugfixes ac_est From fa1c114498141a491433d6eff3b280f6c297a8cd Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 17:06:44 +0100 Subject: [PATCH 166/187] update nuts correction based on Isabelles review --- literature.bib | 2 +- .../15_food/anthro_iso_jun22/declarations.gms | 4 ++-- .../15_food/anthro_iso_jun22/exodietmacro.gms | 22 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/literature.bib b/literature.bib index adb1364d84..6f31716a32 100644 --- a/literature.bib +++ b/literature.bib @@ -51,7 +51,7 @@ @article{springmann_options_2018 volume = "562", number = "7728", pages = "519 - 525", - author = {Springmann, Marco, Michael Clark, Daniel Mason-D’Croz, Keith Wiebe, Benjamin Leon Bodirsky, Luis Lassaletta, Wim de Vries, Sonja J. Vermeulen, Mario Herrero, Kimberly M. Carlson, Malin Jonell, Max Troell, Fabrice DeClerck, Line J. Gordon, Rami Zurayk, Peter Scarborough, Mike Rayner, Brent Loken, Jess Franzo, H. Charles J. Godfray, David Tilman, Johan Rockström, Walter Willett}, + author = {Springmann, Marco, Michael Clark, Daniel Mason-D'Croz, Keith Wiebe, Benjamin Leon Bodirsky, Luis Lassaletta, Wim de Vries, Sonja J. Vermeulen, Mario Herrero, Kimberly M. Carlson, Malin Jonell, Max Troell, Fabrice DeClerck, Line J. Gordon, Rami Zurayk, Peter Scarborough, Mike Rayner, Brent Loken, Jess Franzo, H. Charles J. Godfray, David Tilman, Johan Rockström, Walter Willett}, month = oct, year = {2018}, } diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms index 48ed9d52de..f56cb86e72 100644 --- a/modules/15_food/anthro_iso_jun22/declarations.gms +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -154,7 +154,7 @@ parameters i15_intake_EATLancet(iso,kfo) Food-specific per capita calorie intake according to EAT Lancet diet scenario (kcal per capita per day) p15_intake_detailed_scen_target(t,iso,kfo) Target for food-specific per capita calorie intake according to an exogenous diet scenario (kcal per capita per day) - i15_fruit_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) + i15_fruit_ratio(t,iso,EAT_special) Ratio of calories from fruits and vegetables within the others and cassav_sp food categories (1) p15_intake_detail_starchyfruit(t,iso) Auxiliary parameter for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detail_roots(t,iso) Auxiliary parameter for the intake of roots (kcal per capita per day) p15_intake_detail_fruitveg(t,iso) Auxiliary parameter for the intake of fruits and vegetables included in others (kcal per capita per day) @@ -162,7 +162,7 @@ parameters p15_intake_detailed_scen_starchyfruit(t,iso) Auxiliary scenario target for the intake of starchy fruits included in cassav_sp (kcal per capita per day) p15_intake_detailed_scen_roots(t,iso) Auxiliary scenario target for the intake of roots (kcal per capita per day) p15_intake_detailed_scen_fruitveg(t,iso) Auxiliary scenario target for the intake of fruits and vegetables included in others (kcal per capita per day) - p15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) + p15_intake_detailed_scen_nuts(t,iso) Auxiliary scenario target for the intake of nuts included in others (kcal per capita per day) i15_exo_foodscen_fader(t,iso) Fader that converges per capita food consumption to an exogenous diet scenario (1) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index aa5d22e61f..4c2e891364 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -517,14 +517,14 @@ elseif s15_exo_diet = 3, *' up or down towards the EAT nuts target *' considering scaling of nuts in others. p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) - = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) - ; + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + * (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - p15_intake_detailed_scen_nuts(t,iso)) + ; -*** ISABELLE: Please double-check whether I can remove the if condition from the nuts target equations -*** ($((sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + p15_intake_detail_nuts(t,iso))) -*** Benni and my reasoning was that if the nuts in others (p15_intake_detailed_scen_nuts already over-fulfill the nuts and seeds target, -*** it would be ok to correct the seeds and groundnuts down...) + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target,iso,kfo_ns2) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) + = p15_intake_detailed_scen_target(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) + ; * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. @@ -536,11 +536,11 @@ elseif s15_exo_diet = 3, if (s15_exo_roots = 1, *' Maximum recommendation for roots: - p15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) - = f15_rec_EATLancet(iso,"t_roots","max"); + p15_intake_detailed_scen_roots(t,iso)$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) = + f15_rec_EATLancet(iso,"t_roots","max"); - p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) - = p15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); + p15_intake_detailed_scen_target(t,iso,"potato")$(p15_intake_detail_roots(t,iso) > f15_rec_EATLancet(iso,"t_roots","max")) = + p15_intake_detailed_scen_roots(t,iso) / p15_intake_detail_roots(t,iso) * p15_intake_detail(t,iso,"potato"); ); From fb8fad1e04859eeddec167f3f6508e3d56e93f96 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 19 Feb 2024 17:17:59 +0100 Subject: [PATCH 167/187] bugfixes --- modules/15_food/anthro_iso_jun22/exodietmacro.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index 4c2e891364..e4a54e2623 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -521,7 +521,7 @@ elseif s15_exo_diet = 3, * (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - p15_intake_detailed_scen_nuts(t,iso)) ; - p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target,iso,kfo_ns2) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) + p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) = p15_intake_detailed_scen_target(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) ; From 9917c46d31fab03aa37a155bacbb7e3c4af96fb0 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 20 Feb 2024 16:11:01 +0100 Subject: [PATCH 168/187] bugfixes --- .../15_food/anthro_iso_jun22/exodietmacro.gms | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms index e4a54e2623..b4627e8844 100644 --- a/modules/15_food/anthro_iso_jun22/exodietmacro.gms +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -464,11 +464,11 @@ elseif s15_exo_diet = 3, *' The f15_fruitveg2others_kcal_ratio gives the country-level historical share *' (fixed into the future based on last historic year) *' of fruits and vegetables in these aggregate categories. - if (sum(sameas(t_past,t),1) = 1, - i15_fruit_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); - else - i15_fruit_ratio(t,iso,EAT_special) = i15_fruit_ratio(t-1,iso,EAT_special); - ); + if (sum(sameas(t_past,t),1) = 1, + i15_fruit_ratio(t,iso,EAT_special) = f15_fruitveg2others_kcal_ratio(t,iso,EAT_special); + else + i15_fruit_ratio(t,iso,EAT_special) = i15_fruit_ratio(t-1,iso,EAT_special); + ); *' Separation of starchy fruits (bananas and plantains) *' and roots (cassava, sweet potato, yams) in the cassav_sp food category @@ -499,7 +499,7 @@ elseif s15_exo_diet = 3, *' Extract fruits and vegetables that are part of others category * Note that starchy fruits are kept at the previously assigned maximum level -* and their amount has been added to cassav_sp already. +* and their amount will be added to cassav_sp. p15_intake_detailed_scen_fruitveg(t,iso) = p15_intake_detailed_scen_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso); *' Minimum recommendation for nuts & seeds @@ -507,7 +507,7 @@ elseif s15_exo_diet = 3, *' are scaled by the same amount as fruits and vegetables *' because the food group "others" is treated as homogenous food category p15_intake_detailed_scen_nuts(t,iso)$(p15_intake_detail_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso) > 0) - = p15_intake_detail_nuts(t,iso) * p15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - p15_intake_detail_starchyfruit(t,iso)) + = p15_intake_detail_nuts(t,iso) * p15_intake_detailed_scen_fruitveg(t,iso) / (p15_intake_detail_fruitveg(t,iso) - p15_intake_detailed_scen_starchyfruit(t,iso)) ; *' The resulting intake of the "others" category is: @@ -517,14 +517,9 @@ elseif s15_exo_diet = 3, *' up or down towards the EAT nuts target *' considering scaling of nuts in others. p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) > 0) - = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - * (sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) - p15_intake_detailed_scen_nuts(t,iso)) - ; + = p15_intake_detail(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detail(t,iso,kfo_ns2)) + * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)); - p15_intake_detailed_scen_target(t,iso,kfo_ns)$(sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) < (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso))) - = p15_intake_detailed_scen_target(t,iso,kfo_ns) / sum(kfo_ns2, p15_intake_detailed_scen_target(t,iso,kfo_ns2)) - * (f15_rec_EATLancet(iso,"t_nutseeds","min") - p15_intake_detailed_scen_nuts(t,iso)) - ; * If seeds have been corrected downwards below zero because nuts target already overfulfilled with nuts in others, * seed and groundnut consumption is reduced to zero. @@ -622,6 +617,7 @@ elseif s15_exo_diet = 3, sum(EAT_nonstaples2, p15_intake_detailed_scen_target(t,iso,EAT_nonstaples2)); if (smin((iso,kfo), p15_intake_detailed_scen_target(t,iso,kfo)) < 0, + display p15_intake_detailed_scen_target; abort "The parameter p15_intake_detailed_scen_target became negative after calorie balancing."; ); From 6774271e0c2c2954f18340dbc1315f28589563dd Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 21 Feb 2024 13:58:42 +0100 Subject: [PATCH 169/187] memory spike avoiding ncdf4 based nc writing --- scripts/output/extra/disaggregation.R | 41 ++++++++++++++++++++-- scripts/output/extra/disaggregation_LUH2.R | 2 +- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index 05ef287729..b08c4dcf30 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -64,9 +64,46 @@ if (length(map_file) > 1) { return(x) } +.ncdf4Write <- function(x, filename, unit = "", missval = -9999) { + # magclass objects are sparse, fill gaps with NA + xy <- getCoords(x) + lonCoords <- seq(min(xy$x), max(xy$x), 0.5) + latCoords <- seq(max(xy$y), min(xy$y), -0.5) + + coords <- expand.grid(x = lonCoords, y = latCoords) + coords <- paste0(coords$x, "|", coords$y) + coords <- gsub("\\.", "p", coords) + coords <- sub("\\|", ".", coords) + + getItems(x, 1.3) <- NULL + + extended <- new.magpie(coords, getItems(x, 2), getItems(x, 3)) + extended[getItems(x, 1), , ] <- x + x <- extended + + # create netCDF file + lonLatTime <- list(ncdf4::ncdim_def("lon", "degrees_east", lonCoords), + ncdf4::ncdim_def("lat", "degrees_north", latCoords), + ncdf4::ncdim_def("time", "years", getYears(x, as.integer = TRUE), unlim = TRUE)) + vars <- lapply(getItems(x, 3), function(vname) { + return(ncdf4::ncvar_def(vname, units = unit, dim = lonLatTime, missval = missval)) + }) + + nc <- ncdf4::nc_create(filename, vars = vars) + withr::defer(ncdf4::nc_close(nc)) + + for (vname in getItems(x, 3)) { + ncdf4::ncvar_put(nc, vname, x[, , vname]) + } +} + .writeDisagg <- function(x, file, comment, message) { - write.magpie(.fixCoords(x), file, comment = comment) - write.magpie(.fixCoords(x), sub(".mz", ".nc", file), comment = comment, verbose = FALSE) + base::message(message) + x <- .fixCoords(x) + write.magpie(x, file, comment = comment) + + unit <- if (grepl("^unit: ", comment)) sub("^unit: ", "", comment) else "" + .ncdf4Write(x, sub(".mz", ".nc", file), unit = unit) } .dissagcrop <- function(gdx, land_hr, map_file) { diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index b5f18049b8..d8ec9dfac8 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -490,4 +490,4 @@ gc() write.magpie(a, paste0(out_dir, "/LUH2_Yield_Nr.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() -} \ No newline at end of file +} From 80383c382ba39ae4dd99bdf0b781350fea01b76c Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 21 Feb 2024 14:02:55 +0100 Subject: [PATCH 170/187] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e3616681..2081ce311a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **58_peatland** removed realization "on" ### fixed +- **scripts** fixed memory spike leading to crashes in disaggregation.R - **scripts** Fixed writing of NetCDF files in output/reportMAgPIE2SEALS.R - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k - **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs From 4eaa922bdfa0e2443980a77f7618130608046083 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 21 Feb 2024 14:44:44 +0100 Subject: [PATCH 171/187] reduce disaggregation.R memory footprint with rm --- scripts/output/extra/disaggregation.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index b08c4dcf30..5a76352481 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -381,6 +381,9 @@ gc() land_split_hr <- land_hr[, getYears(area_shr_hr), ] area_hr <- area_shr_hr * dimSums(land_split_hr, dim = 3) +rm(area_shr_hr) +gc() + # replace crop in land_hr in with crop_kfo_rf, crop_kfo_ir, crop_kbe_rf # and crop_kbe_ir kbe <- c("betr", "begr") @@ -409,6 +412,8 @@ land_split_hr <- land_split_hr[, , "crop", invert = TRUE] # combine land_split_hr with crop_hr. land_split_hr <- mbind(crop_hr, fallow, land_split_hr) +rm(crop_kfo_rf, crop_kfo_ir, crop_kbe_rf, crop_kbe_ir, crop_hr, fallow, area_hr) + # split "forestry" into timber plantations, pre-scribed afforestation (NPi/NDC) and endogenous afforestation (CO2 price driven) message("Disaggregating forestry") farea <- dimSums(landForestry(gdx, level = "cell"), dim = "ac") @@ -430,6 +435,9 @@ land_split_hr <- land_split_hr[, , "forestry", invert = TRUE] # combine land_split_hr with farea_hr land_split_hr <- mbind(land_split_hr, farea_hr) +rm(farea, farea_shr, farea_hr) +gc() + # Write output .writeDisagg(land_split_hr, land_hr_split_file, comment = "unit: Mha per grid-cell", @@ -439,6 +447,7 @@ land_split_hr <- mbind(land_split_hr, farea_hr) comment = "unit: grid-cell land area fraction", message = "Write cropsplit land area share" ) +rm(land_split_hr) gc() # -------------------------------- @@ -508,6 +517,9 @@ land_bii_hr <- interpolateAvlCroplandWeighted( snv_pol_fader = snv_pol_fader, unit = "share" ) + +rm(land_consv_hr, urban_land_hr) + land_bii_hr <- .fixCoords(land_bii_hr) # Add primary and secondaray other land @@ -518,12 +530,14 @@ land_bii_hr <- land_bii_hr * side_layers_hr[, , c("forested", "nonforested")] # Sum over land classes bii_hr <- dimSums(land_bii_hr * bii_hr, dim = 3, na.rm = TRUE) +rm(land_bii_hr) # Write output .writeDisagg(bii_hr, bii_hr_out_file, comment = "unitless", message = "Write output BII at 0.5°" ) +rm(bii_hr) gc() @@ -561,6 +575,8 @@ out <- peat_hr / dimSums(land_hr[,getYears(peat_hr),], dim = 3) out[is.nan(out)] <- 0 out[is.infinite(out)] <- 0 +rm(land_hr, peat_hr) + .writeDisagg(out, peatland_hr_share_out_file, comment = "unit: grid-cell land area fraction", message = "Write outputs peatland share") From d30d13afcf1a1cc6512ec05d2c17bcbe188abd70 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 21 Feb 2024 15:43:46 +0100 Subject: [PATCH 172/187] write terra-compatible nc files --- scripts/output/extra/disaggregation.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index 5a76352481..6d521ca198 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -84,7 +84,7 @@ if (length(map_file) > 1) { # create netCDF file lonLatTime <- list(ncdf4::ncdim_def("lon", "degrees_east", lonCoords), ncdf4::ncdim_def("lat", "degrees_north", latCoords), - ncdf4::ncdim_def("time", "years", getYears(x, as.integer = TRUE), unlim = TRUE)) + ncdf4::ncdim_def("time", "years since 0", getYears(x, as.integer = TRUE), unlim = TRUE)) vars <- lapply(getItems(x, 3), function(vname) { return(ncdf4::ncvar_def(vname, units = unit, dim = lonLatTime, missval = missval)) }) @@ -92,6 +92,8 @@ if (length(map_file) > 1) { nc <- ncdf4::nc_create(filename, vars = vars) withr::defer(ncdf4::nc_close(nc)) + ncdf4::ncatt_put(nc, "time", "axis", "T") + for (vname in getItems(x, 3)) { ncdf4::ncvar_put(nc, vname, x[, , vname]) } From 37fb30f452f3e014c93535bc559fd5870365a5fd Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 21 Feb 2024 15:58:26 +0100 Subject: [PATCH 173/187] use compression --- scripts/output/extra/disaggregation.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index 6d521ca198..d2d90f6c61 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -64,7 +64,7 @@ if (length(map_file) > 1) { return(x) } -.ncdf4Write <- function(x, filename, unit = "", missval = -9999) { +.ncdf4Write <- function(x, filename, unit = "", compression = 2, missval = -9999) { # magclass objects are sparse, fill gaps with NA xy <- getCoords(x) lonCoords <- seq(min(xy$x), max(xy$x), 0.5) @@ -86,7 +86,8 @@ if (length(map_file) > 1) { ncdf4::ncdim_def("lat", "degrees_north", latCoords), ncdf4::ncdim_def("time", "years since 0", getYears(x, as.integer = TRUE), unlim = TRUE)) vars <- lapply(getItems(x, 3), function(vname) { - return(ncdf4::ncvar_def(vname, units = unit, dim = lonLatTime, missval = missval)) + return(ncdf4::ncvar_def(vname, units = unit, dim = lonLatTime, + missval = missval, compression = compression)) }) nc <- ncdf4::nc_create(filename, vars = vars) From 42ce67cd8bde96acdd6c56ff34de0744f4bd6fa1 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Wed, 21 Feb 2024 17:56:57 +0100 Subject: [PATCH 174/187] code cleanup: remove unused scalars --- modules/15_food/anthro_iso_jun22/input.gms | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms index 4d9328f4cf..79e10b5d87 100644 --- a/modules/15_food/anthro_iso_jun22/input.gms +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -97,8 +97,6 @@ scalar s15_exo_diet Switch for transition towards exogenous diet scenario (1) / * If the switch is set to 1,the exogenous diets are activated. * For all other settings (!=1), the endogenous estimate is used. * When activating a target, total calories are always preserved via scaling of staples -scalar s15_exo_poultry Exogenous EAT Lancet animal product target on (1) / 1 /; -scalar s15_exo_redmeatdairy Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 /; scalar s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 /; From 4b4c75b1c998a9b44c62f2f6fdfb3a3bedea29f9 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 23 Feb 2024 11:43:36 +0100 Subject: [PATCH 175/187] updated comment in default.cfg --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index c2f42ff6dc..81d263859b 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -454,7 +454,7 @@ cfg$gms$s15_exo_diet <- 0 # def = 0 cfg$gms$c15_kcal_scen <- "healthy_BMI" # def = healthy_BMI # # * exogenous food-specific diet scenario (EAT Lancet diet scenarios) -# * only activated if s15_exo_diet is > 0 +# * only activated if s15_exo_diet is 1 or 2 # * options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat cfg$gms$c15_EAT_scen <- "FLX" # def = FLX From 49034743a2d6307176c148b0d573f95e19a7529c Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 23 Feb 2024 15:36:59 +0100 Subject: [PATCH 176/187] bugfix v21_manna_from_heaven highres.R --- CHANGELOG.md | 1 + modules/21_trade/exo/input.gms | 4 ++++ modules/21_trade/exo/preloop.gms | 3 +++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e3616681..7370f54da5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **52_carbon** bugfix acx long-term carbon density - **32_forestry** keep c-density for timber plantations constant after rotation length to avoid unrealistic carbon sequestration in unharvested timber plantation - **32_forestry** bugfix unit p32_observed_gs_reg +- **21_trade** v21_manna_from_heaven fixed to zero by default. Without fixing to zero, v21_manna_from_heaven was used unnecessarily in runs started with highres.R ## [4.7.0] - 2023-12-11 diff --git a/modules/21_trade/exo/input.gms b/modules/21_trade/exo/input.gms index 536c1dc76b..79d3de83e2 100644 --- a/modules/21_trade/exo/input.gms +++ b/modules/21_trade/exo/input.gms @@ -5,6 +5,10 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +scalars + s21_manna_from_heaven v21_manna_from_heaven fixed to zero (0) or available at high cost (1) (binary) / 0 / +; + table f21_trade_balance(t_all,h,kall) trade balance of positive exports and negative imports (mio. tDM per yr) $ondelim $include "./modules/21_trade/input/f21_trade_balance.cs3" diff --git a/modules/21_trade/exo/preloop.gms b/modules/21_trade/exo/preloop.gms index 29b3f14108..2c50afbd24 100644 --- a/modules/21_trade/exo/preloop.gms +++ b/modules/21_trade/exo/preloop.gms @@ -8,3 +8,6 @@ ** Save self sufficiency values as a interface parameter needed in forestry module pm_selfsuff_ext(t_ext,h,kforestry) = f21_self_suff("y2150",h,kforestry); pm_selfsuff_ext(t_all,h,kforestry) = f21_self_suff(t_all,h,kforestry); + +** fix to zero by default +v21_manna_from_heaven.fx(h,kall)$(s21_manna_from_heaven = 0) = 0; From 19b606eccad4e15b4a673f399169d7616df89bd7 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 23 Feb 2024 15:55:22 +0100 Subject: [PATCH 177/187] added switch to default.cfg --- CHANGELOG.md | 2 +- config/default.cfg | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7370f54da5..ceb75f8621 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **52_carbon** bugfix acx long-term carbon density - **32_forestry** keep c-density for timber plantations constant after rotation length to avoid unrealistic carbon sequestration in unharvested timber plantation - **32_forestry** bugfix unit p32_observed_gs_reg -- **21_trade** v21_manna_from_heaven fixed to zero by default. Without fixing to zero, v21_manna_from_heaven was used unnecessarily in runs started with highres.R +- **21_trade** introduced s21_manna_from_heaven for fixing v21_manna_from_heaven to zero. Without fixing to zero, v21_manna_from_heaven was used unnecessarily in runs started with highres.R ## [4.7.0] - 2023-12-11 diff --git a/config/default.cfg b/config/default.cfg index 48fbfdec0d..4609e6ec78 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -554,6 +554,11 @@ cfg$gms$c20_scp_type <- "sugar" # def = sugar # * to exports cfg$gms$trade <- "selfsuff_reduced" # def = selfsuff_reduced +# * option for `exo` realization only: +# * fix `v21_manna_from_heaven` to zero (0) or not (1) +# Note: Without fixing to zero, v21_manna_from_heaven might be used unnecessarily in runs started with highres.R +cfg$gms$21_manna_from_heaven <- 0 + # * trade balance reduction scenario # * (l909090r808080): 10 percent trade liberalisation for secondary and # * livestock products in 2030,2050,2100 and 20 percent for From c78a8fa9acb360ec588d43274642edeee08bdcb3 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 25 Feb 2024 12:14:43 +0100 Subject: [PATCH 178/187] bugfix s21_manna_from_heaven --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 4609e6ec78..80521de913 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -557,7 +557,7 @@ cfg$gms$trade <- "selfsuff_reduced" # def = selfsuff_reduced # * option for `exo` realization only: # * fix `v21_manna_from_heaven` to zero (0) or not (1) # Note: Without fixing to zero, v21_manna_from_heaven might be used unnecessarily in runs started with highres.R -cfg$gms$21_manna_from_heaven <- 0 +cfg$gms$s21_manna_from_heaven <- 0 # * trade balance reduction scenario # * (l909090r808080): 10 percent trade liberalisation for secondary and From 3129c4ad956e2c630138d9ef7407e6c5c105ae31 Mon Sep 17 00:00:00 2001 From: Felicitas Beier Date: Mon, 26 Feb 2024 12:31:22 +0100 Subject: [PATCH 179/187] updated additional data in scenario_fsec config file --- config/scenario_fsec.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 41d3fe24e0..7d55a17ed6 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -70,6 +70,6 @@ gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;; input['cellular'];rev4.99_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.99_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.99_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.99_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; input['regional'];rev4.99_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['validation'];rev4.99_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['additional'];additional_data_rev4.47.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['additional'];additional_data_rev4.48.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_24Mar23.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_SSP1-PkBudg900.mif From 2e08d5562f8b715310d8c2d8dfb0e7135ae6d4b0 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Mon, 26 Feb 2024 12:42:04 +0100 Subject: [PATCH 180/187] use new magclass nc writing --- DESCRIPTION | 2 +- scripts/output/extra/disaggregation.R | 38 +-------------------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e581d4b690..6e21eb0a26 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,7 +21,7 @@ Imports: lusweave, m4fsdp, madrat, - magclass, + magclass (>= 6.14.0), magpie4, MagpieNCGains, magpiesets, diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index d2d90f6c61..e4d78ee74e 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -64,49 +64,13 @@ if (length(map_file) > 1) { return(x) } -.ncdf4Write <- function(x, filename, unit = "", compression = 2, missval = -9999) { - # magclass objects are sparse, fill gaps with NA - xy <- getCoords(x) - lonCoords <- seq(min(xy$x), max(xy$x), 0.5) - latCoords <- seq(max(xy$y), min(xy$y), -0.5) - - coords <- expand.grid(x = lonCoords, y = latCoords) - coords <- paste0(coords$x, "|", coords$y) - coords <- gsub("\\.", "p", coords) - coords <- sub("\\|", ".", coords) - - getItems(x, 1.3) <- NULL - - extended <- new.magpie(coords, getItems(x, 2), getItems(x, 3)) - extended[getItems(x, 1), , ] <- x - x <- extended - - # create netCDF file - lonLatTime <- list(ncdf4::ncdim_def("lon", "degrees_east", lonCoords), - ncdf4::ncdim_def("lat", "degrees_north", latCoords), - ncdf4::ncdim_def("time", "years since 0", getYears(x, as.integer = TRUE), unlim = TRUE)) - vars <- lapply(getItems(x, 3), function(vname) { - return(ncdf4::ncvar_def(vname, units = unit, dim = lonLatTime, - missval = missval, compression = compression)) - }) - - nc <- ncdf4::nc_create(filename, vars = vars) - withr::defer(ncdf4::nc_close(nc)) - - ncdf4::ncatt_put(nc, "time", "axis", "T") - - for (vname in getItems(x, 3)) { - ncdf4::ncvar_put(nc, vname, x[, , vname]) - } -} - .writeDisagg <- function(x, file, comment, message) { base::message(message) x <- .fixCoords(x) write.magpie(x, file, comment = comment) unit <- if (grepl("^unit: ", comment)) sub("^unit: ", "", comment) else "" - .ncdf4Write(x, sub(".mz", ".nc", file), unit = unit) + write.magpie(x, sub(".mz", ".nc", file), unit = unit) } .dissagcrop <- function(gdx, land_hr, map_file) { From c8aa381fe5e65b6d389361af853dfe3533425688 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Mon, 26 Feb 2024 15:08:53 +0100 Subject: [PATCH 181/187] fix disaggregation_LUH2.R --- CHANGELOG.md | 1 + scripts/output/extra/disaggregation.R | 4 +- scripts/output/extra/disaggregation_LUH2.R | 79 ++++++++++++++++++---- 3 files changed, 66 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2081ce311a..e2a92ef755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **58_peatland** removed realization "on" ### fixed +- **scripts** fixed disaggregation_LUH2.R which no longer relies on the old raster-based write.magpie for nc files - **scripts** fixed memory spike leading to crashes in disaggregation.R - **scripts** Fixed writing of NetCDF files in output/reportMAgPIE2SEALS.R - **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index e4d78ee74e..9c4b2736db 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -68,9 +68,7 @@ if (length(map_file) > 1) { base::message(message) x <- .fixCoords(x) write.magpie(x, file, comment = comment) - - unit <- if (grepl("^unit: ", comment)) sub("^unit: ", "", comment) else "" - write.magpie(x, sub(".mz", ".nc", file), unit = unit) + write.magpie(x, sub(".mz", ".nc", file), comment = comment) } .dissagcrop <- function(gdx, land_hr, map_file) { diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index d8ec9dfac8..f3f28f362e 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -60,6 +60,55 @@ convertLUH2 <- function(x) { } +# code taken from the old raster-based nc writing in write.magpie +# https://raw.githubusercontent.com/pik-piam/magclass/19fc7d098fbbea4af26240d6472e7e088356bf57/R/write.magpie.R +writeRasterBrick <- function(x, file_name, comment = NULL, zname = "Time", ...) { + if (!requireNamespace("ncdf4", quietly = TRUE) || !requireNamespace("raster", quietly = TRUE)) { + stop("The packages \"ncdf4\" and \"raster\" are required!") + } + .sub <- function(rx, name) { + layer <- sub("^.*\\.\\.", "", names(rx)) + if (length(unique(layer)) == 1) return(rx) + return(rx[[which(layer == name)]]) + } + tmp <- names(x) + tmp <- strsplit(tmp, "\\..") + years <- sort(unique(unlist(lapply(tmp, function(x) x[1])))) + varnames <- sort(unique(unlist(lapply(tmp, function(x) x[2])))) + zunit <- ifelse(all(isYear(years)), "years", "") + years <- as.numeric(gsub("y", "", years)) + if (is.null(varnames)) varnames <- "Variable" + if (is.null(comment)) { + unit <- "not specified" + } else { + indicators <- sub(":.*$", "", comment) + units <- sub("^.*: ", "", comment) + if (any(grepl("unit", indicators))) { + unit <- units[grep("unit", indicators)] + } else { + unit <- "not specified" + } + } + # raster is using partial matching resulting in a warning if warnPartialMatchDollar is set + suppressSpecificWarnings({ + raster::writeRaster(.sub(x, varnames[1]), filename = filePath, format = "CDF", overwrite = TRUE, + compression = 9, zname = zname, zunit = zunit, varname = varnames[1], varunit = unit, ...) + }, "partial match of 'group' to 'groups'", fixed = TRUE) + nc <- ncdf4::nc_open(filePath, write = TRUE) + if (zunit == "years") { + try(ncdf4::ncvar_put(nc, zname, years), silent = TRUE) + } + if (length(varnames) > 1) { + for (i in varnames[-1]) { + suppressSpecificWarnings({ + nc <- ncdf4::ncvar_add(nc, ncdf4::ncvar_def(i, unit, nc$dim, compression = 9)) + }, "partial match of 'group' to 'groups'", fixed = TRUE) + ncdf4::ncvar_put(nc, i, aperm(as.array(.sub(x, i)), c(2, 1, 3))) + } + } + ncdf4::nc_close(nc) +} + withr::local_options(list(magclass_sizeLimit = 1e+12)) @@ -194,7 +243,7 @@ saveRDS(states,paste0(outputdir,"/states.rds")) gc() states <- convertLUH2(states) gc() -write.magpie(states, paste0(out_dir, "/LUH2_states.nc"), comment = "unit: fraction of grid-cell area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(states, paste0(out_dir, "/LUH2_states.nc"), comment = "unit: fraction of grid-cell area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(states) gc() } @@ -217,7 +266,7 @@ gc() if(!file.exists(paste0(out_dir,"/LUH2_protected_area.nc"))){ b <- convertLUH2(b) gc() -write.magpie(b, paste0(out_dir, "/LUH2_protected_area.nc"), comment = "unit: fraction of grid-cell", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(b, paste0(out_dir, "/LUH2_protected_area.nc"), comment = "unit: fraction of grid-cell", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(b) gc() } @@ -245,7 +294,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_area.nc"))){ b <- convertLUH2(b) gc() - write.magpie(b, paste0(out_dir, "/LUH2_wood_harvest_area.nc"), comment = "unit: fraction of grid-cell area per year", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") + writeRasterBrick(b, paste0(out_dir, "/LUH2_wood_harvest_area.nc"), comment = "unit: fraction of grid-cell area per year", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,b) gc() } @@ -271,7 +320,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_yields.nc"))){ b <- convertLUH2(b) gc() - write.magpie(b, paste0(out_dir, "/LUH2_wood_harvest_yields.nc"), comment = "unit: m3 per ha per year", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") + writeRasterBrick(b, paste0(out_dir, "/LUH2_wood_harvest_yields.nc"), comment = "unit: m3 per ha per year", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,b) gc() } @@ -285,7 +334,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_biomass_split.nc"))){ b <- convertLUH2(b) gc() - write.magpie(b, paste0(out_dir, "/LUH2_wood_harvest_biomass_split.nc"), comment = "unit: fraction of wood harvest biomass", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") + writeRasterBrick(b, paste0(out_dir, "/LUH2_wood_harvest_biomass_split.nc"), comment = "unit: fraction of wood harvest biomass", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(b) gc() } @@ -304,7 +353,7 @@ if (any(abs(d) > 0.1 )) message(paste0("Difference between cluster and grid cell if(!file.exists(paste0(out_dir,"/LUH2_irrigation.nc"))){ irrig_hr_shr <- convertLUH2(irrig_hr_shr) gc() -write.magpie(irrig_hr_shr, paste0(out_dir, "/LUH2_irrigation.nc"), comment = "unit: fraction of crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writewriteRasterBrick(irrig_hr_shr, paste0(out_dir, "/LUH2_irrigation.nc"), comment = "unit: fraction of crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(irrig_hr_shr,d) gc() } @@ -322,7 +371,7 @@ if (any(abs(d) > 0.1)) message(paste0("Difference between cluster and grid cell if (!file.exists(paste0(out_dir, "/LUH2_flood.nc"))) { flooded <- convertLUH2(flooded) gc() - write.magpie(flooded, paste0(out_dir, "/LUH2_flood.nc"), comment = "unit: flooded fraction of C3 annual crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") + writeRasterBrick(flooded, paste0(out_dir, "/LUH2_flood.nc"), comment = "unit: flooded fraction of C3 annual crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(flooded, d) gc() } @@ -341,7 +390,7 @@ getNames(bio_hr_shr,dim=1) <- c("crpbf_c4per","crpbf_c3per") if(!file.exists(paste0(out_dir,"/LUH2_bioenergy.nc"))){ bio_hr_shr <- convertLUH2(bio_hr_shr) gc() -write.magpie(bio_hr_shr, paste0(out_dir, "/LUH2_bioenergy.nc"), comment = "unit: fraction of crop type area occupied by biofuel crops", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(bio_hr_shr, paste0(out_dir, "/LUH2_bioenergy.nc"), comment = "unit: fraction of crop type area occupied by biofuel crops", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(bio_hr_shr,d) gc() } @@ -398,19 +447,19 @@ x <- NULL if(!file.exists(paste0(out_dir,"/LUH2_Nitrogen_fertilizer.nc"))){ x <- convertLUH2(clean_magpie(collapseNames(a[,,"fertilizer"],collapsedim = 3.1))) gc() -write.magpie(x, paste0(out_dir, "/LUH2_Nitrogen_fertilizer.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(x, paste0(out_dir, "/LUH2_Nitrogen_fertilizer.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") } if(!file.exists(paste0(out_dir,"/LUH2_Nitrogen_manure.nc"))){ x <- convertLUH2(clean_magpie(collapseNames(a[,,"manure"],collapsedim = 3.1))) gc() -write.magpie(x, paste0(out_dir, "/LUH2_Nitrogen_manure.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(x, paste0(out_dir, "/LUH2_Nitrogen_manure.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") } if(!file.exists(paste0(out_dir,"/LUH2_Nitrogen_surplus.nc"))){ x <- convertLUH2(clean_magpie(collapseNames(a[,,"surplus"],collapsedim = 3.1))) gc() -write.magpie(x, paste0(out_dir, "/LUH2_Nitrogen_surplus.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(x, paste0(out_dir, "/LUH2_Nitrogen_surplus.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") } rm(a,x,weight) @@ -430,7 +479,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_DM.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a, paste0(out_dir, "/LUH2_Yield_DM.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(a, paste0(out_dir, "/LUH2_Yield_DM.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } @@ -449,7 +498,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_DM_rainfed.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a, paste0(out_dir, "/LUH2_Yield_DM_rainfed.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(a, paste0(out_dir, "/LUH2_Yield_DM_rainfed.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } @@ -468,7 +517,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_DM_irrigated.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a, paste0(out_dir, "/LUH2_Yield_DM_irrigated.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(a, paste0(out_dir, "/LUH2_Yield_DM_irrigated.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } @@ -487,7 +536,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_Nr.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a, paste0(out_dir, "/LUH2_Yield_Nr.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(a, paste0(out_dir, "/LUH2_Yield_Nr.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } From 7f8fa027ef448baa5401bb4463487da614f9e576 Mon Sep 17 00:00:00 2001 From: Felicitas Beier Date: Mon, 26 Feb 2024 16:54:26 +0100 Subject: [PATCH 182/187] remove yield calibration from FSEC config --- config/scenario_fsec.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 7d55a17ed6..7ef1b57b6b 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -5,7 +5,7 @@ gms$c09_pal_scenario;;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s12_interest_lic;;;0.06;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s12_interest_hic;;;0.04;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$food;anthro_iso_jun22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s14_use_yield_calib;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s14_use_yield_calib;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s15_exo_waste;;;;;;;;0;0;0;0;0;0;0;0;1;;;;;;;;;;;;;;;;;0;1;;;;;;;;;;;;;;; gms$s15_exo_diet;;;;;;;;1;1;1;1;1;1;1;1;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$c15_kcal_scen;;;;;;;;no_underweight;half_overweight;endo;endo;endo;endo;endo;endo;endo;;;;;;;;;;;;;;;;;no_underweight_half_overweight;no_underweight_half_overweight;;;;;;;;;;;;;;; From fdecc798dc35781178fce98075a0b845958ef8d2 Mon Sep 17 00:00:00 2001 From: Felicitas Beier Date: Tue, 27 Feb 2024 09:35:31 +0100 Subject: [PATCH 183/187] update scenario config to rev 4.99 input data --- config/scenario_config.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index bf6c7bed6a..3579ee883f 100755 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -82,7 +82,7 @@ gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;; gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.96_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.96_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.96_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.96_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.96_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.96_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.99_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.99_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.99_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.99_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.99_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.99_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; From ba540f0b1e0ead2c9264cf16bf30df3af65d3f7a Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Tue, 27 Feb 2024 09:56:42 +0100 Subject: [PATCH 184/187] fixes in disaggregation_LUH2.R --- scripts/output/extra/disaggregation_LUH2.R | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index f3f28f362e..7e8b880df7 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -62,7 +62,7 @@ convertLUH2 <- function(x) { # code taken from the old raster-based nc writing in write.magpie # https://raw.githubusercontent.com/pik-piam/magclass/19fc7d098fbbea4af26240d6472e7e088356bf57/R/write.magpie.R -writeRasterBrick <- function(x, file_name, comment = NULL, zname = "Time", ...) { +writeRasterBrick <- function(x, filePath, comment = NULL, zname = "Time", ...) { if (!requireNamespace("ncdf4", quietly = TRUE) || !requireNamespace("raster", quietly = TRUE)) { stop("The packages \"ncdf4\" and \"raster\" are required!") } @@ -89,20 +89,15 @@ writeRasterBrick <- function(x, file_name, comment = NULL, zname = "Time", ...) unit <- "not specified" } } - # raster is using partial matching resulting in a warning if warnPartialMatchDollar is set - suppressSpecificWarnings({ - raster::writeRaster(.sub(x, varnames[1]), filename = filePath, format = "CDF", overwrite = TRUE, - compression = 9, zname = zname, zunit = zunit, varname = varnames[1], varunit = unit, ...) - }, "partial match of 'group' to 'groups'", fixed = TRUE) + raster::writeRaster(.sub(x, varnames[1]), filename = filePath, format = "CDF", overwrite = TRUE, + compression = 9, zname = zname, zunit = zunit, varname = varnames[1], varunit = unit, ...) nc <- ncdf4::nc_open(filePath, write = TRUE) if (zunit == "years") { try(ncdf4::ncvar_put(nc, zname, years), silent = TRUE) } if (length(varnames) > 1) { for (i in varnames[-1]) { - suppressSpecificWarnings({ - nc <- ncdf4::ncvar_add(nc, ncdf4::ncvar_def(i, unit, nc$dim, compression = 9)) - }, "partial match of 'group' to 'groups'", fixed = TRUE) + nc <- ncdf4::ncvar_add(nc, ncdf4::ncvar_def(i, unit, nc$dim, compression = 9)) ncdf4::ncvar_put(nc, i, aperm(as.array(.sub(x, i)), c(2, 1, 3))) } } @@ -353,7 +348,7 @@ if (any(abs(d) > 0.1 )) message(paste0("Difference between cluster and grid cell if(!file.exists(paste0(out_dir,"/LUH2_irrigation.nc"))){ irrig_hr_shr <- convertLUH2(irrig_hr_shr) gc() -writewriteRasterBrick(irrig_hr_shr, paste0(out_dir, "/LUH2_irrigation.nc"), comment = "unit: fraction of crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") +writeRasterBrick(irrig_hr_shr, paste0(out_dir, "/LUH2_irrigation.nc"), comment = "unit: fraction of crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(irrig_hr_shr,d) gc() } From 78d4380edae192671ea10152bcffb1fb8c2765f1 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Tue, 27 Feb 2024 09:57:52 +0100 Subject: [PATCH 185/187] changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a92ef755..c4ccc9ca78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,10 +32,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **58_peatland** removed realization "on" ### fixed -- **scripts** fixed disaggregation_LUH2.R which no longer relies on the old raster-based write.magpie for nc files +- **scripts** disaggregation_LUH2.R which no longer relies on the old raster-based write.magpie for nc files - **scripts** fixed memory spike leading to crashes in disaggregation.R -- **scripts** Fixed writing of NetCDF files in output/reportMAgPIE2SEALS.R -- **scripts** Fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k +- **scripts** fixed writing of NetCDF files in output/reportMAgPIE2SEALS.R +- **scripts** fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k - **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs - **35_natveg** bugfixes ac_est - **35_natveg** removed scaling of pm_carbon_density_ac From 3b310cbff5bef27bfccb5c6fefe1a65138ca52ac Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:47:38 +0100 Subject: [PATCH 186/187] Set yieldcalib back to 1 in FSEC for now --- config/scenario_fsec.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 7ef1b57b6b..7d55a17ed6 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -5,7 +5,7 @@ gms$c09_pal_scenario;;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s12_interest_lic;;;0.06;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s12_interest_hic;;;0.04;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$food;anthro_iso_jun22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s14_use_yield_calib;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s14_use_yield_calib;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s15_exo_waste;;;;;;;;0;0;0;0;0;0;0;0;1;;;;;;;;;;;;;;;;;0;1;;;;;;;;;;;;;;; gms$s15_exo_diet;;;;;;;;1;1;1;1;1;1;1;1;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$c15_kcal_scen;;;;;;;;no_underweight;half_overweight;endo;endo;endo;endo;endo;endo;endo;;;;;;;;;;;;;;;;;no_underweight_half_overweight;no_underweight_half_overweight;;;;;;;;;;;;;;; From 66b0d87df6cf0af59023c15228b0525b87e5291c Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 28 Feb 2024 14:14:08 +0100 Subject: [PATCH 187/187] magpie release 4.7.1 --- .zenodo.json | 4 ++-- CHANGELOG.md | 42 ++++++++++++++++++++++-------------------- CITATION.cff | 4 ++-- README.md | 6 +++--- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index fd247d6f0d..0445d5a03b 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "MAgPIE - An Open Source land-use modeling framework", - "version": "4.7.0dev", + "version": "4.7.1", "creators": [ { "name": "Dietrich, Jan Philipp", @@ -114,5 +114,5 @@ "license": { "id": "AGPL-3.0-or-later" }, - "publication_date": "2023-12-11" + "publication_date": "2024-02-28" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e5a622fb5..ab98fc616f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,45 +5,46 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [Unreleased] +## [4.7.1] - 2024-02-28 ### changed - **15_food** Added improved EAT Lancet diet implementation (EAT 2p0) -- **default.cfg** update input data to rev 4.99 (new validation data, new EATLancet recommendations, new semi-natural vegtation cropland data) -- **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib +- **21_trade** s21_trade_bal_damper for roundwood changed from 0.75 to 0.65 - **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations. -- **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` - **default.cfg and scenario_config.csv** Default for cfg$gms$c56_emis_policy changed from `redd+natveg_nosoil` to `reddnatveg_nosoil`,i.e. timber plantations are excluded from carbon pricing by default +- **default.cfg** changed default for `cfg$gms$s32_aff_prot` from 0 to 1 +- **default.cfg** changed default for `cfg$gms$s56_buffer_aff` from 0.2 to 0.5 - **default.cfg** Default for cfg$gms$c56_cprice_aff changed from `forestry_vegc` to `secdforest_vegc` -- **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` -- **scenario_config.csv** removed erroneous setting `cc` from column `input` +- **default.cfg** Default for cfg$gms$peatland changed from `on` to `v2` - **default.cfg** update default `cfg$gms$c56_pollutant_prices` and `cfg$gms$c60_2ndgen_biodem` to `R32M46-SSP2EU-NPi` -- **default.cfg** changed default for `cfg$gms$s56_buffer_aff` from 0.2 to 0.5 -- **default.cfg** changed default for `cfg$gms$s32_aff_prot` from 0 to 1 -- **21_trade** s21_trade_bal_damper for roundwood changed from 0.75 to 0.65 +- **default.cfg** update input data to rev 4.99 (new validation data, new EATLancet recommendations, new semi-natural vegtation cropland data) +- **scenario_config.csv** removed erroneous setting `cc` from column `input` +- **scenario_config.csv** settings for cfg$gms$s35_secdf_distribution in `ForestryEndo` and `ForestryExo` changed from `2` to `0` +- **start_functions** Check if cfg$recalibrate is consistent with cfg$gms$s14_use_yield_calib ### added - **32_forestry** new interfaces `vm_land_forestry`, `pcm_land_forestry` `vm_landexpansion_forestry` and `vm_landreduction_forestry` -- **scripts** added peatland to output/extra/disaggregation.R - **56_ghg_policy_** added new trajectories for R32M46 - **60_bioenergy** added new trajectories for R32M46 +- **scripts** added peatland to output/extra/disaggregation.R ### removed -- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. - **58_peatland** removed realization "on" +- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario. ### fixed -- **scripts** disaggregation_LUH2.R which no longer relies on the old raster-based write.magpie for nc files -- **scripts** fixed memory spike leading to crashes in disaggregation.R -- **scripts** fixed writing of NetCDF files in output/reportMAgPIE2SEALS.R -- **scripts** fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k -- **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs +- **21_trade** introduced s21_manna_from_heaven for fixing v21_manna_from_heaven to zero. Without fixing to zero, v21_manna_from_heaven was used unnecessarily in runs started with highres.R +- **32_forestry** bugfix unit p32_observed_gs_reg +- **32_forestry** keep c-density for timber plantations constant after rotation length to avoid unrealistic carbon sequestration in unharvested timber plantation - **35_natveg** bugfixes ac_est - **35_natveg** removed scaling of pm_carbon_density_ac - **52_carbon** bugfix acx long-term carbon density -- **32_forestry** keep c-density for timber plantations constant after rotation length to avoid unrealistic carbon sequestration in unharvested timber plantation -- **32_forestry** bugfix unit p32_observed_gs_reg -- **21_trade** introduced s21_manna_from_heaven for fixing v21_manna_from_heaven to zero. Without fixing to zero, v21_manna_from_heaven was used unnecessarily in runs started with highres.R +- **scripts** bugfix highres.R for bioenergy demand and GHG prices in coupled runs +- **scripts** disaggregation_LUH2.R which no longer relies on the old raster-based write.magpie for nc files +- **scripts** fixed disaggregation.R and disaggregation_LUH2.R to be used with 67k +- **scripts** fixed memory spike leading to crashes in disaggregation.R +- **scripts** fixed writing of NetCDF files in output/reportMAgPIE2SEALS.R + ## [4.7.0] - 2023-12-11 @@ -821,7 +822,8 @@ This release version is focussed on consistency between the MAgPIE setup and the First open source release of the framework. See [MAgPIE 4.0 paper](https://doi.org/10.5194/gmd-12-1299-2019) for more information. -[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.7.0...develop +[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.7.1...develop +[4.7.1]: https://github.com/magpiemodel/magpie/compare/v4.7.0...v4.7.1 [4.7.0]: https://github.com/magpiemodel/magpie/compare/v4.6.11...v4.7.0 [4.6.11]: https://github.com/magpiemodel/magpie/compare/v4.6.10...v4.6.11 [4.6.10]: https://github.com/magpiemodel/magpie/compare/v4.6.9...v4.6.10 diff --git a/CITATION.cff b/CITATION.cff index c08883e0ce..e0441304b2 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -131,8 +131,8 @@ authors: email: popp@pik-potsdam.de title: MAgPIE - An Open Source land-use modeling framework -version: 4.7.0dev -date-released: 2023-12-11 +version: 4.7.1 +date-released: 2024-02-28 repository-code: https://github.com/magpiemodel/magpie keywords: - landuse diff --git a/README.md b/README.md index 7ae86d6331..787cd31368 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ https://www.pik-potsdam.de/research/projects/activities/land-use-modelling/magpi A framework description paper has been published in Geoscientific Model Development (GMD): https://doi.org/10.5194/gmd-12-1299-2019 -The model documentation for version 4.7.0 can be found at -https://rse.pik-potsdam.de/doc/magpie/4.7.0/ +The model documentation for version 4.7.1 can be found at +https://rse.pik-potsdam.de/doc/magpie/4.7.1/ A most recent version of the documentation can also be extracted from the model source code via the R package goxygen @@ -188,7 +188,7 @@ magpie@pik-potsdam.de Please contact magpie@pik-potsdam.de ## CITATION -See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.7.0/#how-to-cite) in the model documentation for information how to cite the model. +See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.7.1/#how-to-cite) in the model documentation for information how to cite the model. ## AUTHORS See list of authors in CITATION.cff