Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added entire-year non-ag water demand for PB postprocessing #689

Merged
merged 11 commits into from
Jun 19, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24`
- **default.cfg** update additional data to rev4.51
- **scripts** adjusted SLURM job handling
- **scripts** updated EL2p0 start scripts

### added
- **42_water_demand** added non-agricultural water demand for entire year
- **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` and `simple_apr24` (default).
- **10_land** added interface `pm_land_hist` with historic land use patterns

Expand Down
24 changes: 13 additions & 11 deletions main.gms
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,22 @@ $title magpie

*##################### R SECTION START (VERSION INFO) ##########################
*
* Used data set: rev4.108_h12_magpie.tgz
* Used data set: rev4.109_h12_magpie.tgz
* md5sum: NA
* Repository: https://rse.pik-potsdam.de/data/magpie/public
* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output
*
* Used data set: rev4.108_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz
* Used data set: rev4.109_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz
* md5sum: NA
* Repository: https://rse.pik-potsdam.de/data/magpie/public
* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output
*
* Used data set: rev4.108_h12_validation.tgz
* Used data set: rev4.109_h12_validation.tgz
* md5sum: NA
* Repository: https://rse.pik-potsdam.de/data/magpie/public
* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output
*
* Used data set: additional_data_rev4.51.tgz
* Used data set: additional_data_rev4.50.tgz
* md5sum: NA
* Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive
* Repository: https://rse.pik-potsdam.de/data/magpie/public

*
* Used data set: calibration_H12_26Mar24.tgz
* md5sum: NA
Expand All @@ -179,11 +180,11 @@ $title magpie
*
* Regionscode: 62eff8f7
*
* Regions data revision: 4.108
* Regions data revision: 4.109
*
* lpj2magpie settings:
* * LPJmL data: MRI-ESM2-0:ssp370
* * Revision: 4.108
* * Revision: 4.109
*
* aggregation settings:
* * Input resolution: 0.5
Expand All @@ -195,7 +196,8 @@ $title magpie
* * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler)
*
*
* Last modification (input data): Sat Jun 15 13:10:19 2024
* Last modification (input data): Tue Jun 18 09:52:31 2024

*
*###################### R SECTION END (VERSION INFO) ###########################

Expand Down
25 changes: 13 additions & 12 deletions modules/42_water_demand/agr_sector_aug13/declarations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
*** | Contact: [email protected]

parameters
i42_wat_req_k(t,j,k) LPJmL annual water demand for irrigation per ha per year (m^3) + Livestock demand per ton (m^3)
ic42_wat_req_k(j,k) LPJmL annual water demand for irrigation per ha per year (m^3) + Livestock demand per ton (m^3)
i42_env_flows(t,j) Environmental flow requirements if a protection policy is in place (mio. m^3)
i42_env_flows_base(t,j) Environmental flow requirements if no protection policy is in place (mio. m^3)
ic42_env_flow_policy(i) Determines whether environmental flow protection is enforced in the current time step (1)
i42_env_flow_policy(t,i) Determines whether environmental flow protection is enforced (1)
p42_efp(t_all,scen42) Determines whether environmental flow protection is enforced and its fading in of environmental flow policy (1)
p42_efp_fader(t_all) Determines the fading in of environmental flow policy (1)
p42_country_dummy(iso) Dummy parameter indicating whether country is affected by EFP (1)
p42_EFP_region_shr(t_all,i) Weighted share of region with regards to EFP (1)
ic42_pumping_cost(i) Parameter to capture values for pumping costs in a particular time step (USD05MER per m^3)
i42_wat_req_k(t,j,k) LPJmL annual water demand for irrigation per ha per year (m^3) + Livestock demand per ton (m^3)
ic42_wat_req_k(j,k) LPJmL annual water demand for irrigation per ha per year (m^3) + Livestock demand per ton (m^3)
i42_env_flows(t,j) Environmental flow requirements if a protection policy is in place (mio. m^3)
i42_env_flows_base(t,j) Environmental flow requirements if no protection policy is in place (mio. m^3)
ic42_env_flow_policy(i) Determines whether environmental flow protection is enforced in the current time step (1)
i42_env_flow_policy(t,i) Determines whether environmental flow protection is enforced (1)
p42_efp(t_all,scen42) Determines whether environmental flow protection is enforced and its fading in of environmental flow policy (1)
p42_efp_fader(t_all) Determines the fading in of environmental flow policy (1)
p42_country_dummy(iso) Dummy parameter indicating whether country is affected by EFP (1)
p42_EFP_region_shr(t_all,i) Weighted share of region with regards to EFP (1)
ic42_pumping_cost(i) Parameter to capture values for pumping costs in a particular time step (USD05MER per m^3)
i42_watdem_total(t,j,watdem_ineldo) Non-agricultural water demand for entire year used in post-processing (mio. m^3 per yr)
;

equations
q42_water_demand(wat_dem,j) Water withdrawals of different sectors (mio. m^3 per yr)
q42_water_cost(i) Total cost of pumping irrigation water (USD05MER per yr)
q42_water_cost(i) Total cost of pumping irrigation water (USD05MER per yr)
;

positive variables
Expand Down
4 changes: 4 additions & 0 deletions modules/42_water_demand/agr_sector_aug13/presolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ vm_watdem.fx("manufacturing",j) = sum(wat_src, im_wat_avail(t,wat_src,j)) * s42_
vm_watdem.fx("electricity",j) = 0;
vm_watdem.fx("domestic",j) = 0;

* Fill non-agricultural water demand parameter of entire year for post-processing
i42_watdem_total(t,j,watdem_ineldo) = 0;
i42_watdem_total(t,j,"manufacturing") = sum(wat_src, im_wat_avail(t,wat_src,j)) * s42_reserved_fraction;

* Country switch to determine countries for which EFP holds.
* In the default case, the EFP affects all countries when activated.
p42_country_dummy(iso) = 0;
Expand Down
3 changes: 3 additions & 0 deletions modules/42_water_demand/agr_sector_aug13/sets.gms
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ sets
watdem_exo(wat_dem) Exogenous water demands
/ manufacturing, electricity, domestic, ecosystem /

watdem_ineldo(wat_dem) Exogenous water demand subset covering humanly induced demands
/ domestic, manufacturing, electricity /

scen42 Environmental Flow Policy (EFP)
/ off, on /

Expand Down
27 changes: 14 additions & 13 deletions modules/42_water_demand/all_sectors_aug13/declarations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
*** | Contact: [email protected]

parameters
i42_wat_req_k(t_all,j,k) LPJmL annual water demand for irrigation per ha per yr and livestock demand per ton per yr (m^3)
ic42_wat_req_k(j,k) LPJmL annual water demand for irrigation per ha per yr and livestock demand per ton per yr (m^3)
i42_env_flows(t,j) Environmental flow requirements in case of policy (mio m^3)
i42_env_flows_base(t,j) Environmental flow requirements in case of no policy (mio m^3)
ic42_env_flow_policy(i) Determines whether environmental flow protection is enforced in the current time step (1)
i42_env_flow_policy(t,i) Determines whether environmental flow protection is enforced (1)
p42_efp(t_all,scen42) Determines whether environmental flow protection is enforced and its fading in of environmental flow policy (1)
p42_efp_fader(t_all) Determines the fading in of environmental flow policy (1)
p42_country_dummy(iso) Dummy parameter indicating whether country is affected by EFP (1)
p42_EFP_region_shr(t_all,i) Weighted share of region with regards to EFP (1)
ic42_pumping_cost(i) Parameter to capture values for pumping costs in a particular time step (USD05MER per m^3)
i42_wat_req_k(t_all,j,k) LPJmL annual water demand for irrigation per ha per yr and livestock demand per ton per yr (m^3)
ic42_wat_req_k(j,k) LPJmL annual water demand for irrigation per ha per yr and livestock demand per ton per yr (m^3)
i42_env_flows(t,j) Environmental flow requirements in case of policy (mio m^3)
i42_env_flows_base(t,j) Environmental flow requirements in case of no policy (mio m^3)
ic42_env_flow_policy(i) Determines whether environmental flow protection is enforced in the current time step (1)
i42_env_flow_policy(t,i) Determines whether environmental flow protection is enforced (1)
p42_efp(t_all,scen42) Determines whether environmental flow protection is enforced and its fading in of environmental flow policy (1)
p42_efp_fader(t_all) Determines the fading in of environmental flow policy (1)
p42_country_dummy(iso) Dummy parameter indicating whether country is affected by EFP (1)
p42_EFP_region_shr(t_all,i) Weighted share of region with regards to EFP (1)
ic42_pumping_cost(i) Parameter to capture values for pumping costs in a particular time step (USD05MER per m^3)
i42_watdem_total(t,j,watdem_ineldo) Non-agricultural water demand for entire year used in post-processing (mio. m^3 per yr)
;

equations
q42_water_demand(wat_dem,j) Water withdrawals of different sectors (mio. m^3 per yr)
q42_water_cost(i) Total cost of pumping irrigation water (USD05MER per yr)
q42_water_demand(wat_dem,j) Water withdrawals of different sectors (mio. m^3 per yr)
q42_water_cost(i) Total cost of pumping irrigation water (USD05MER per yr)
;

positive variables
Expand Down
10 changes: 9 additions & 1 deletion modules/42_water_demand/all_sectors_aug13/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,21 @@ $include "./modules/42_water_demand/input/f42_wat_req_fao.csv"
$offdelim
/;

table f42_watdem_ineldo(t_all,j,scen_watdem_nonagr,watdem_ineldo) Manufacturing electricity and domestic water demand under different socioeconomic scenarios (mio. m^3)
table f42_watdem_ineldo(t_all,j,scen_watdem_nonagr,watdem_ineldo) Manufacturing electricity and domestic water demand under different socioeconomic scenarios in the growing period (mio. m^3)
$ondelim
$include "./modules/42_water_demand/input/watdem_nonagr_grper.cs3"
$offdelim
;
m_fillmissingyears(f42_watdem_ineldo,"j,scen_watdem_nonagr,watdem_ineldo");

* This input is not used within MAgPIE, but necessary for the postprocessing
table f42_watdem_ineldo_total(t_all,j,scen_watdem_nonagr,watdem_ineldo) Manufacturing electricity and domestic water demand under different socioeconomic scenarios in the entire year (mio. m^3)
$ondelim
$if exist "./modules/42_water_demand/input/watdem_nonagr_total.cs3" $include "./modules/42_water_demand/input/watdem_nonagr_total.cs3"
$offdelim
;
m_fillmissingyears(f42_watdem_ineldo_total,"j,scen_watdem_nonagr,watdem_ineldo");

parameter
f42_env_flows(t_all,j) Environmental flow requirements from LPJ and Smakhtin algorithm (mio. m^3)
/
Expand Down
8 changes: 6 additions & 2 deletions modules/42_water_demand/all_sectors_aug13/presolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ if ((s42_pumping = 1),
* depends on the socioeconomic scenario
if (m_year(t) <= sm_fix_SSP2,
vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"ssp2",watdem_ineldo);
i42_watdem_total(t,j,watdem_ineldo) = f42_watdem_ineldo_total(t,j,"ssp2",watdem_ineldo);
else
if ((s42_watdem_nonagr_scenario = 1),
vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"ssp1",watdem_ineldo);
Elseif(s42_watdem_nonagr_scenario = 2),
i42_watdem_total(t,j,watdem_ineldo) = f42_watdem_ineldo_total(t,j,"ssp1",watdem_ineldo);
Elseif (s42_watdem_nonagr_scenario = 2),
vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"ssp2",watdem_ineldo);
Elseif(s42_watdem_nonagr_scenario = 3),
i42_watdem_total(t,j,watdem_ineldo) = f42_watdem_ineldo_total(t,j,"ssp2",watdem_ineldo);
Elseif (s42_watdem_nonagr_scenario = 3),
vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"ssp3",watdem_ineldo);
i42_watdem_total(t,j,watdem_ineldo) = f42_watdem_ineldo_total(t,j,"ssp3",watdem_ineldo);
);
);

Expand Down
1 change: 1 addition & 0 deletions modules/42_water_demand/input/files
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
lpj_airrig.cs2
lpj_envflow_grper.cs2
watdem_nonagr_grper.cs3
watdem_nonagr_total.cs3
f42_wat_req_fao.csv
f42_pumping_cost.cs4
1 change: 1 addition & 0 deletions modules/44_biodiversity/bv_btc_mar21/not_used.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name,type,reason
pcm_land, input, not used
sm_fix_SSP2, input, not used
8 changes: 4 additions & 4 deletions scripts/output/extra/checkSummation.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ library(piamInterfaces)
options(width = 180)

## Check outputdir
if(!exists("source_include")) {
if (!exists("source_include")) {
outputdir <- "."
}

f <- file.path(outputdir, "report.mif")

if(!file.exists(f)) {
if (!file.exists(f)) {
warning("report.mif missing, cannot check anything. Please create report first!")
} else {
failvar <- checkSummations(f, outputDirectory = NULL, absDiff = 0.001,
summationsFile = "extractVariableGroups")
if(nrow(failvars) > 0) saveRDS(failvar, file.path(outputdir, "summationCheck.rds"))
}
if (nrow(failvars) > 0) saveRDS(failvar, file.path(outputdir, "summationCheck.rds"))
}
6 changes: 3 additions & 3 deletions scripts/start/projects/project_EAT2p0.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bau <- function(cfg) {
cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default

# Climate Change
cfg$input['cellular'] <- "rev4.99_h12_c6a7458f_cellularmagpie_c200_IPSL-CM6A-LR-ssp370_lpjml-8e6c5eb1.tgz"
cfg$input['cellular'] <- "rev4.109_h12_c6a7458f_cellularmagpie_c200_IPSL-CM6A-LR-ssp370_lpjml-8e6c5eb1.tgz"

return(cfg)
}
Expand Down Expand Up @@ -133,9 +133,9 @@ waste <- function(cfg) {
# 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 considering diet change
cfg$path_to_report_ghgprices <- "/p/projects/magpie/users/beier/EL2_DeepDive/remind/output/C_SSP2EU-DSPkB500-noDS-rem-5/REMIND_generic_C_SSP2EU-DSPkB500-noDS-rem-5.mif"
cfg$path_to_report_ghgprices <- "/p/projects/magpie/users/beier/EL2_DeepDive_default/remind/output/C_SSP2EU-DSPkB650-DS_betax_AgMIP-rem-5/REMIND_generic_C_SSP2EU-DSPkB500-noDS-rem-5.mif"
cfg$gms$c56_pollutant_prices <- "coupling"
cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/beier/EL2_DeepDive/remind/output/C_SSP2EU-DSPkB500-noDS-rem-5/REMIND_generic_C_SSP2EU-DSPkB500-noDS-rem-5.mif"
cfg$path_to_report_bioenergy <- "/p/projects/magpie/users/beier/EL2_DeepDive_default/remind/output/C_SSP2EU-DSPkB650-DS_betax_AgMIP-rem-5/REMIND_generic_C_SSP2EU-DSPkB500-noDS-rem-5.mif"
cfg$gms$c60_2ndgen_biodem <- "coupling"

return(cfg)
Expand Down
Loading
Loading