diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000000..9914e75a4b --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,3 @@ +^renv$ +^renv\.lock$ +^.*\.zenodo.json$ diff --git a/.Rprofile b/.Rprofile index 8feeb19129..0e74f9465a 100644 --- a/.Rprofile +++ b/.Rprofile @@ -1,16 +1,42 @@ -# source global .Rprofile (very important to load user specific settings) -# DO NOT EDIT THIS LINE! -if(file.exists("~/.Rprofile")) source("~/.Rprofile") +# | (C) 2008-2025 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 +Sys.setenv(RENV_PATHS_LIBRARY = "renv/library") +if (Sys.info()[["sysname"]] == "Windows") { + # make renv use R's default download function to prevent + # curl: (35) schannel: next InitializeSecurityContext failed: Unknown error + # (0x80092012) - The revocation function was unable to check revocation for the certificate. + options(renv.download.override = utils::download.file) +} -# This profile can be used to link the model to a specified library snapshot -# (e.g. if your model version is from an older date and does not work with the -# newest libraries anymore) -# By default it is not active. Just uncomment the following lines and set the -# snapshot path to a path of your choice -# Please make also sure that in your config file this .Rprofile file is copied -# to the model output folder. Otherwise, the run itself will again use the -# default library set! +# do not check if library and renv.lock are in sync, because normally renv.lock does not exist +options(renv.config.synchronized.check = FALSE, + renv.config.user.profile = TRUE) # load user specific settings from ~/.Rprofile -# snapshot <- "/p/projects/rd3mod/R/libraries/snapshots/dec2016" -# if(file.exists(snapshot)) .libPaths(snapshot) +# the text "renvVersion" is required for a check in a coupling script, will be removed soon +source("renv/activate.R") + +if (!"https://rse.pik-potsdam.de/r/packages" %in% getOption("repos")) { + options(repos = c(getOption("repos"), pik = "https://rse.pik-potsdam.de/r/packages")) +} + +# bootstrapping, will only run once after this repo is freshly cloned +if (isTRUE(rownames(installed.packages(priority = "NA")) == "renv")) { + message("R package dependencies are not installed in this renv, installing now...") + renv::install("rmarkdown", prompt = FALSE) # rmarkdown is required to find dependencies in Rmd files + renv::hydrate(prompt = FALSE, report = FALSE) # auto-detect and install all dependencies + message("Finished installing R package dependencies.") + if (!("upstream" %in% gert::git_remote_list()$name)) { + gert::git_remote_add("https://github.com/magpiemodel/magpie.git", "upstream") + message("Added upstream git remote pointing to magpiemodel/magpie.") + } +} + +# in case bootstrapping fails halfway, install piamenv and rely on requirement auto-fixing +if (tryCatch(utils::packageVersion("piamenv") < "0.5.5", error = function(error) TRUE)) { + renv::install("piamenv", prompt = FALSE) +} diff --git a/.codeCheck b/.codeCheck new file mode 100644 index 0000000000..0c2f270989 --- /dev/null +++ b/.codeCheck @@ -0,0 +1,6 @@ +capitalExclusionList: + - land + - iso + - type + - age + - k diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..eb67b447d2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Handle line endings automatically for files detected as text +# and leave all files detected as binary untouched. +* text=auto diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000000..b4a730a5db --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,35 @@ +#!/usr/bin/env Rscript + +gmsRequiredVersion <- "0.24.1" +if (tryCatch(utils::packageVersion("gms") < gmsRequiredVersion, error = function(error) TRUE)) { + message("gms >= ", gmsRequiredVersion, " is required, installing now...") + install.packages("gms") +} + +message("Checking files for tabs... ", appendLF = FALSE) +gms::checkNoTabs(pattern = "\\.(R|Rprofile|gms|cfg|bib)$", + excludeFolders = c("output", "renv", ".git")) +message("done.") + +stagedFiles <- system("git diff --cached --name-only", intern = TRUE) + +# run codeCheck only if .gms file is staged +if (any(endsWith(stagedFiles, ".gms"))) { + invisible(gms::codeCheck(strict = TRUE)) + message("") +} + + +# make sure that files are not too big +maxFilesize <- 250 # kB +exemptFromLimit <- "^renv/archive/[0-9\\.]+_renv\\.lock$" + +files <- union(system("git ls-tree -r HEAD --name-only", intern = TRUE), stagedFiles) +out <- data.frame(files = files, size = round(file.size(files) / 1024, 2)) +out <- out[!is.na(out$size), ] +out <- out[out$size > maxFilesize & !grepl(exemptFromLimit, out$files), ] +if (nrow(out) > 0) { + stop(nrow(out), " files with size > ", maxFilesize, "kB detected: \n", + paste0(out$files, " (", out$size, "kB)", collapse = "\n")) +} +message("All files are smaller than ", maxFilesize, "kB\n") diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000000..2d19fc766d --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..9243ca1dba --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,53 @@ +## :bird: Description of this PR :bird: + +- Briefly explain the purpose of this pull request + +## :wrench: Checklist for PR creator :wrench: + +- [ ] Label pull request [from the label list](https://github.com/magpiemodel/magpie/labels). + - **Low risk**: Simple bugfixes (missing files, updated documentation, typos) or changes in start or output scripts + - **Medium risk**: Uncritical changes in the model core (e.g. moderate modifications in non-default realizations) + - **High risk**: Critical changes in model core or default settings (e.g. changing a model default or adjusting a core mechanic in the model) + +- [ ] Self-review own code + - No hard coded numbers and cluster/country/region names. + - The new code doesn't contain declared but unused parameters or variables. + - [`magpie4`](https://github.com/pik-piam/magpie4) R library has been updated accordingly and backwards compatible where necessary. + - `scenario_config.csv` has been updated accordingly (important if `default.cfg` has been updated) + +- [ ] Document changes + - Add changes to `CHANGELOG.md` + - Where relevant, put In-code documentation comments + - Properly address updates in interfaces in the module documentations + - run [`goxygen::goxygen()`](https://github.com/pik-piam/goxygen) and verify the modified code is properly documented + +- [ ] Perform test runs + - **Low risk**: + - Run a compilation check via `Rscript start.R --> "compilation check"` + - **Medium risk**: + - Run test runs via `Rscript start.R --> "test runs"` + - Check logs for errors/warnings + - **High risk**: + - Run test runs via `Rscript start.R --> "test runs"` + - Check logs for errors/warnings + - Default run from the PR target branch for comparison + - Provide relevant comparison plots (land-use, emissions, food prices, land-use intensity,...) + +### :chart_with_downwards_trend: Performance changes :chart_with_upwards_trend: + + - Current develop branch default : ** mins + - This PR's default : ** mins + +## :rotating_light: Checklist for reviewer :rotating_light: + +- PR is labeled correctly +- Code changes look reasonable + - No hard coded numbers and cluster/country/region names. + - No unnecessary increase in module interfaces + - model behavior/performance is satisfactory. +- Changes are properly documented + - `CHANGELOG` is updated correctly + - Updates in interfaces have been properly addressed in the module documentations + - In-code documentation looks appropriate +- [ ] content review done (at least 1) +- [ ] RSE review done (at least 1) diff --git a/.github/workflows/test-code.yaml b/.github/workflows/test-code.yaml new file mode 100644 index 0000000000..16a3ce0a0c --- /dev/null +++ b/.github/workflows/test-code.yaml @@ -0,0 +1,33 @@ +on: + push: + branches: + - main + - master + - develop + pull_request: + branches: + - main + - master + - develop + +name: check + +jobs: + check: + runs-on: ubuntu-22.04 + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + + - name: Remove .Rprofile + run: rm .Rprofile + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + extra-repositories: "https://rse.pik-potsdam.de/r/packages" + + - name: pre-commit Hook + run: source(".githooks/pre-commit") + shell: Rscript {0} diff --git a/.gitignore b/.gitignore index af8224471a..a832ed1090 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ magpie_calib.* #ignore input files *.cs* +!/data-changelog.csv *.mz *.rds /input/ @@ -13,6 +14,7 @@ magpie_calib.* *.gdx *.rda *.opt +*.op2 *.lst /output/ @@ -24,6 +26,17 @@ magpie_calib.* #ignore run specific files and folders /225*/ +/run_details/ +/logs/ *.out /scripts/npi_ndc/npi_ndc_overview.txt Rplots.pdf + +#ignore GAMS license +gamslice.txt + +#ignore lock file +/.lock + +/renv.lock +.Rproj.user diff --git a/.lintr b/.lintr new file mode 100644 index 0000000000..c02af8f2f3 --- /dev/null +++ b/.lintr @@ -0,0 +1,2 @@ +linters: lucode2::lintrRules() +encoding: "UTF-8" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 63f6ed34b4..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - -language: R -repos: - CRAN: https://cloud.r-project.org -cache: packages -latex: false -pandoc: false -sudo: false -install: - - Rscript -e "if(!requireNamespace('devtools')) install.packages('devtools')" - - Rscript -e "if(!requireNamespace('lucode')) devtools::install_github('pik-piam/lucode')" -script: - - Rscript -e "null <- lucode::codeCheck(strict=TRUE)" - diff --git a/.zenodo.json b/.zenodo.json new file mode 100644 index 0000000000..702e1e0321 --- /dev/null +++ b/.zenodo.json @@ -0,0 +1,131 @@ +{ + "title": "MAgPIE - An Open Source land-use modeling framework", + "version": "4.13.0dev", + "creators": [ + { + "name": "Dietrich, Jan Philipp", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0002-4309-6431" + }, + { + "name": "Bodirsky, Benjamin Leon", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0002-8242-6712" + }, + { + "name": "Weindl, Isabelle", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Humpenöder, Florian", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0003-2927-9407" + }, + { + "name": "Stevanovic, Miodrag", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Kreidenweis, Ulrich", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Wang, Xiaoxi", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Karstens, Kristine", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Mishra, Abhijeet", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0002-8287-9922" + }, + { + "name": "Beier, Felicitas Dorothea", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Molina Bacca, Edna Johanna", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0001-6530-1849" + }, + { + "name": "von Jeetze, Patrick", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0002-1197-4412" + }, + { + "name": "Windisch, Michael", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Crawford, Michael Scott", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0003-1282-400X" + }, + { + "name": "Leip, Debbora", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Klein, David", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Singh, Vartika", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Ambrósio, Geanderson", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Araujo, Ewerton", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Biewald, Anne", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Sauer, Pascal", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0002-6856-8239" + }, + { + "name": "Köberle, Alexandre", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0003-0328-4750" + }, + { + "name": "Steinhauser, Jan", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0002-5989-6855" + }, + { + "name": "Hötten, David", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Schröter, Georg", + "affiliation": "Potsdam Institute for Climate Impact Research" + }, + { + "name": "Lotze-Campen, Hermann", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0002-0003-5508" + }, + { + "name": "Popp, Alexander", + "affiliation": "Potsdam Institute for Climate Impact Research", + "orcid": "0000-0001-9500-1986" + } + ], + "keywords": ["landuse", "modeling", "model", "nlp", "partial equilibrium"], + "license": { + "id": "AGPL-3.0-or-later" + }, + "publication_date": "2025-10-23" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index cb61c7d69e..d45b28d7fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,1204 @@ - # Changelog 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/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + ## [Unreleased] +### changed +- **inputdata** updated input data to rev4.127, including fix of FAO mass balance and processing shares where maiz to ethanol values were missing for some countries +- **13_tc** the interface variable `vm_tau` now represents a linear combination of tau on regular cropland (`v13_tau_core`) and tau on cropland in conservation priority areas (`v13_tau_consv`). Per default values in `vm_tau` are equal to `v13_tau_core`. +- **inputdata** updated input data to rev4.128, including fix for mismatch between historic urban land in LUH3 and projected future urban land, which is still based on LUH2 +- **60_bioenergy** set `i60_res_2ndgenBE_dem` also for historical period to `off` if `c60_res_2ndgenBE_dem` is set to `off` (do not apply scenario harmonization on it) + +### added +- + +### removed +- + +### fixed +- **32_forestry** fixed parenthesis placement in discounting formula for establishment costs +- **scripts/start_functions.R** added all extra `cfg` arguments in `start_run()` to the config check call +- **32_forestry** bugfix limit for endogenous re/afforestation in historical time steps +- **highres.R** temporary f32_max_aff_area.cs4 is now deleted in case of error + + +## [4.13.0] - 2025-10-23 + +### changed +- **56_ghg_policy** extended set of available ghg price scenarios +- **60_bioenergy** extended set of available second generation bioenergy scenarios +- **config** input data upgraded from rev4.121 to rev4.122, incorporating new bioenergy demand and GHG price trajectories from REMIND standalone runs with biochar (R34BC). +- **inputdata** updated input data to rev4.123, which uses LUH3 instead of LUH2v2 + +### added +- **renv/archive** store `renv.lock` for release versions + +### fixed +- **14_yield** avoid division by zero for special cases +- **14_yield** avoid too high yields in edge cases (in case of data mismatches between FAO/LUH croparea and LPJmL yield data avoid zero references yields that lead to overestimated yields) +- **60_bioenergy** Harmonize 2nd gen bioenergy demand for historic period based on default trajectory "R34M410-SSP2-NPi2025" +- **inputdata** updated input data to rev4.124, which includes two fixes, one with nitrogen emissions being to low and one about accounting for starches in FAO processing data +- **inputdata** updated input data to rev4.126, including fixes related to inconsistencies as part of LUH3 update and growing primary forest +- **scripts/output** removed deprecated `dir` option from `disaggBII` in `disaggregation.R` + + +## [4.12.0] - 2025-09-08 + +### changed +- **inputdata** updated input data to include new FAO food balances, allowing for a new set of past years "coup_2015", i.e. past held until 2015 instead of 2010. To be updated once LUH3 input data comes in, to 2020. +- **readme** added detailed Windows instructions and common installation issues +- **renv/activate.R** updated to version 1.1.5 + +### fixed +- **21_trade** included trade costs into exo realization +- **62_material** fixed inconsistency for historical bioplastic substrate demand +- **default.cfg** input data upgraded to use corrected clusters using aligned population data (rev4.120 onwards) + + +## [4.11.0] - 2025-07-11 + +### changed +- **15_food** add calculation of consumer margins to the postsolve for calculation in model run +- **53_methane** CH4 emissions from enteric fermentation are now calculated using `vm_feed_intake` +- **55_awms** Manure excretion is now calculated using `vm_feed_intake` +- **70_livestock** pasture feed balance flows dynamically linked to pasture demand in regions with high historical scavenged feed use +- **default.cfg** input data upgraded from rev4.118 to rev4.119 (minor update population and GDP) +- **README** added forestry to model description +- **readme** added setup instruction specifics for Linux/macOS +- **scenario_config** update of VLLO scenario to EAT-Lancet 2 +- **scripts** changed setting in the 'mitigation and conservation' start script. + ### added +- **56_ghg_policy** added optional temporal fader for start of C prive driven afforestation +- **70_livestock** added new interfaces `vm_feed_intake` and `vm_feed_balanceflow` +- **core** added unused set number_order to force number sets like maccs_steps to be ordered +- **default.cfg** added switch to control the inclusion of feed balance flows in the calculation of future feed intake +### removed +- **main** Removed Dockerfile, as that is no longer supported/maintained + +### fixed +- **32_forestry** clean-up of switches for rotation length calculation. Removed `c32_interest_rate`. Merged with `c32_rot_calc_type`. +- **71_disagg_lvst** added set.gms to the `off` realization to make these sets available for other modules independent of the selected realization + + +## [4.10.1] - 2025-05-27 ### changed +- **21_trade** changed export share calculation to be done at region level in the model +- **default.cfg** input data upgraded from rev4.117 to rev4.118, default for bioenergy demand and GHG prices changed from R32M46 to R34M410, `rcp4p5` used for SSP2-NPi2025 in line with MAGICC climate outcome and REMIND assumptions. +- **default.cfg** changed running magpie by default with optfile for specified solver settings (Tol_Optimality) +- **scenario_config.csv** SSP2 food system assumptions for ScenarioMIP VLLO to avoid sudden jump of calorie intake after 2025 +- **script/start/test_runs.R** Test runs adjusted based on availability from coupled runs for R34M410. +- **scripts** disaggregation.R moved disaggregateLandConservation function to magpie4 +- **scripts** request 24h for SLURM jobs (except for medium which still requests 7 days) + +### added +- **default.cfg** added options for tau scenarios on conservation priority land in `13_tc`. +- **default.cfg** added option to set Tol_Optimality (GAMS solver setting) to a certain value (GAMS-default 1e-7, new MAgPIE-default 1e-8) +- **80_optimization** added writing of conopt opt files with using scalars from input + +### removed +- **80_optimization** removed older optfile, that should be tried if no optimal solution can be found + +### fixed +- **18_residues** fixed equation for cluster level production of crop residues in flexreg_apr16 realization +- **32_forestry** fixed inconsistency in the application of `s32_max_aff_area` +- **44_biodiversity** expanded age-classes from 150 to 300 years in line with `ac` set. This bugfix is crucial for the BII indicator. + + +## [4.10.0] - 2025-04-03 + +### changed +- **09_drivers** removed SSP2EU scenario from set +- **15_food** included a convergence mechanism to support convergence between iterations +- **15_food** tax recycling for income effect in elastic food demand +- **21_trade** Cost for additional imports to maintain feasibility reduced from 12300 to 1500 USD17MER per tDM to avoid implausibly high costs and prices for wood and woodfuel +- **32_forestry** revised plantation establishment assumptions +- **32_forestry** timber plantation harvest is no longer enforced at rotation age to avoid conflicts with `q21_trade_reg_up`, which can result in huge costs and negative prices for wood +- **35_natveg** revised wood harvest assumptions +- **38_factor_costs** code cleanup, documentation +- **41_area_equipped_for_irrigation** code cleanup +- **56_ghg_policy** Minimum CO2 price of 1 $ per ton CO2 on emissions from deforestation and other land conversion in all time steps to avoid sudden jumps in carbon stock changes (`cfg$gms$s56_minimum_cprice <- 3.67`) +- **60_bioenergy** renamed `c60_bioenergy_subsidy` to `s60_bioenergy_1st_subsidy` to more clearly reflect its use and changed its unit to USD17MER per GJ. Adjusted `q60_bioenergy_incentive` accordingly +- **60_bioenergy** renamed `s60_bioenergy_gj_price_1st` to `s60_bioenergy_1st_price` and `s60_bioenergy_price_2nd` to `s60_bioenergy_2nd_price` +- **73_timber** revised timber demand calculations +- **config.cfg** default for `cfg$gms$cropland` changed from "simple_apr24" to "detail_apr24" +- **config.cfg** default for `cfg$gms$s29_fallow_max ` changed from 0.4 to 0 +- **config.cfg** default for `cfg$gms$s29_treecover_max` changed from 0.4 to 1 +- **config.cfg** default for `cfg$gms$s35_forest_damage ` changed from 2 to 0 +- **default.cfg** default for `cfg$gms$bioenergy` change from `1stgen_priced_dec18` to `1st2ndgen_priced_feb24` +- **default.cfg** default for `s60_bioenergy_1st_subsidy` (formerly `c60_bioenergy_subsidy`) changed from 246 USD17MER per ton to 6.5 USD17MER per GJ based on mean GJ per ton of 1st generation bioenergy products. +- **default.cfg** default for module `44_biodiversity` changed from `bii_target_apr24` to `bii_target` +- **default.cfg** input data upgraded from rev4.116 to rev4.117 +- **default.cfg** Reactivated external scenario for damage from shifting agriculture (`cfg$gms$s35_forest_damage <- 2`) +- **default.cfg** settings for land conversion cost calibration updated +- **scenario_config.csv** `cfg$gms$s56_minimum_cprice` no longer used for `NCD` +- **scripts** changed c30_bioen_water switch to all in EAT2p0 start script and re-included missing BAU_MITI scenario +- **scripts** land conversion cost calibration for cropland - FAO as target data set instead of MAgPIEown +- **scripts** reduced setup information written to main.gms + +### added +- **11_cost** added cost term for soil carbon management +- **22_land_conservation** added option for base protection reversal +- **32_forestry** Upper annual limit for re/afforestation (`s32_annual_aff_limit`) applied to NPI/NDC and CO2-price driven re/afforestation (default: 3% of overall forest establishment potential) +- **58_peatland** Limit for annual peatland rewetting (2% of degraded peatland per year) to avoid adhoc rewetting of degraded peatlands with the introduction of the CO2 price (`cfg$gms$s58_annual_rewetting_limit <- 0.02`) +- **59_som** added soil carbon management option to cellpool_jan23 realization +- **default.cfg** added selection of low and middle-income countries `isoCountriesLowMiddleIncome` +- **default.cfg** added setting for soil carbon management to config and set `cellpool_jan23` realizaton as new default for `59_som` module. +- **scenario_config.csv** added column `NPI-revert` +- **scenario_config.csv** added columns `AR-natveg` and `AR-plant` for CO2 price re/afforestation and AgroForestry settings +- **scenario_config.csv** added scenario `VLLO` based on `SDP-MC` +- **scripts** output script for testing elastic demand +- **scripts** start script for ScenarioMIP MAgPIE standalone runs +- **scripts** The constraint to maintain 20% semi-natural vegetation at the 1x1km scale is passed on to SEALS, if the setting is changed from the `default.cfg` + +### removed +- **15_food/anthropometrics_jan18** removed as outdated +- **44_biodiversity** realisation `bii_target_apr24` removed because it is identical to `bii_target`. `bii_target` set as new default. +- **59_som** removed cellpool_aug16 realization (out-dated parameters) +- **60_bioenergy** removed `s60_bioenergy_1st_subsidy_fix_SSP2`, `s60_2ndgen_bioenergy_dem_min_post_fix` since no longer in use +- **scenario_config.csv** GDP scenario for VLLO in scenario_config.csv changed from SDP-MC to SSP1 (needed for consistency with REMIND) +- **scenario_config.csv** removed column `SSP2-EU` + +### fixed +- **29_cropland** identical results for historic period when using `s29_treecover_bii_coeff` 0 and 1 in scenarios. +- **32_forestry** added contraint `q32_ndc_aff_limit` to make sure that NPI/NDC re/afforestation does not happen at the cost of forests and other natural vegetation. +- **35_natveg** added interface `vm_natforest_reduction` +- **44_biodiversity** scaling of equation `q44_bii` removed, which caused non-matching LHS and RHS +- **56_ghg_policy** bugfixes for regional GHG policy fader +- **59_som** soil carbon reference stock for natural vegetation changed to mean value over cluster ("other_land" lu types) +- **core/macro** wrong use of `vm_supply` corrected in macro `m21_baseline_production` +- **scripts/output** peatland share calculation fixed in disaggreagtion.R and minor bugfixes in disaggreagtion_LUH2.R + + +## [4.9.1] - 2025-01-28 + +### changed +- **scripts** peatland rewetting now automatically considered in `extra/runSEALSallocation.R` + +### added +- **scripts** added start script for land-based mitigation and biodiversity conservation paper +- **scripts** release number can be passed as an argument to test_runs.R to tag as release +- **start_scripts** added `lock_timeout` as option to `start_run` function + +### fixed +- **44_biodiversity** bugfix i44_biome_share, code cleanup, added scaling of `q44_bii` + + +## [4.9.0] - 2024-12-05 + +### changed +- **scripts** changed EL2 Deep Dive c30_bioen_water switch to all and added sensitivity for paper revision +- **35_natveg** revised age-class initialization of secondary forest +- **38_factor_costs** updated use of USDA cost shares +- **config** changed default input data to use 2017USD +- **config** default for `c60_bioenergy_subsidy` changed from 369 to 246 USD17MER per ton +- **config** SHAPE scenarios start year of dietary shift changed to 2025 +- **config** updated input data to rev4.114 +- **core** number of age-classes doubled from 150 to 300 years for better match of growth curves with potential natural vegetation. +- **extra/disaggregation** Peatland now considered in disaggregation of land pools +- **inputdata** changed GDP base year from 2005USD to 2017USD +- **module_documentation** all references to USD05 changed to USD17 +- **modules** update of scaling factors in several modules +- **scripts** NPI/NDC policies synced to the year 2025 - update of additional data to `additional_data_rev4.59.tgz` +- **scripts** REMIND coupling reads data in US$2017, not US$2005 +- **scripts** renamed disaggregation_mrdownscale.R -> mrdownscale_LUH2.R + +### added +- **32_forestry** added option s32_npi_ndc_reversal +- **35_natveg** added option s35_npi_ndc_reversal +- **56_ghg_policy** added new interface pcm_carbon_stock to avoid use of vm_carbon_stock.l in equations +- **58_peatland** added option for exogenous peatland rewetting +- **62_material** added switch to turn off future material demand for bioplastic +- **config** added SSP1-POP-GDP SSP2-POP-GDP and SSP5-POP-GDP +- **modules[29-35]** added initial values for ov_bv for better starting point +- **scripts** add mrdownscale script (0.5deg downscaling using LandUseInit as reference) + +### removed +- **13_tau** removed interface `fm_pastr_tau_hist` +- **31_past** removed `grasslands_apr22` realization + +### fixed +- **10_land** Simplified land transition matrix for improved feasibility +- **11_costs** changed equation to fix bug in total water cost calculation +- **28_ageclass** bugfix input data unit and code clean-up. Renamed `feb21` realization to `oct24` +- **29_cropland** treecover age-class growth was not working properly because ac_sub was erroneously not fixed +- **44_biodiversity** bugfix biorealm_biome.cs3 in input data (shares did not add-up to 1) +- **56_ghg_policy** Fader for GHG emission pricing policy +- **70_livestock** bugfix scaling.gms file in wrong folder +- **config** additional data increased to `additional_data_rev4.58.tgz` which fixes missing gdp2017 conversions in f20_processing_unitcosts +- **config** settings in default.cfg for some switches in `73_timber` did not work correctly +- **scripts** script/output/extra/resubmit.R + + +## [4.8.2] - 2024-09-24 + +### changed +- **15_food** revision of MP/SCP implementation for milk and meat alternatives. Added demand for fat and sugar as ingredients for MP-based milk alternatives. Added optional demand for fat as ingredient for MP-based meat alternatives. +- **21_trade** refactor equations for enhanced readablility and improve documentation +- **29_cropland** added option for linear and sigmoidal faders +- **32_forestry** Interfaces `vm_landexpansion_forestry` and `vm_landreduction_forestry` have been corrected by harvested and replanted timber plantation area +- **58_peatland** variable `v58_scalingFactorExp` converted into parameter `p58_scalingFactorExp` to avoid infeasibilites. `p58_scalingFactorRed` has been revised. +- **80_optimization** abort GAMS in case of execution errors, added threads = 1 as default to avoid infeasibilites and Flg_NoDefc = TRUE as option +- **config** `cfg$gms$land_snv`changed from "secdforest, forestry, past, other" to "secdforest, other" +- **config** additional data update additional_data_rev4.53.tgz +- **config** default settings for 58_peatland revised +- **config** initial treecover on cropland starts from zero +- **config** split scenario_config into project-specific configs +- **config** Submissions with high memory requirements now get 16 CPUs and 80GB of memory to account for the new specifications of PIK's new HPC 'Foote'. `maxMem` was renamed to `highMem`, because 80GB of memory does not correspond to the maximum available memory of a compute node. +- **config** The default realization for the 38_factor_costs module was switched to `sticky_feb18`. In this realization, capital stocks and their depreciation are tracked, giving some inertia to random relocation of production, improving high resolution outputs. +- **script** replaced gdx package with gdx2 package calls +- **script** scripts/start_functions.R decide individually for demand and price whether they are read from a REMIND report. +- **script** updated EATLancet project start scripts +- **scripts** `.nc` files are no longer created by default after disaggregation +- **scripts** output/extra/highres.R use default 13_tc realization +- **scripts** rewrite of merge_report.R based on rds files and rbind, which allows for more flexibility when merging reports. Avoid inconsistent use of "GLO" instead of "World" in report.rds files. +- **modules** renamed `country_dummy` to `country_switch` in all modules + +### added +- **42_water_demand** added water abstraction type dimension for non-ag uses +- **56_ghg_policy** added optional temporal and regional fader for GHG emission pricing policy +- **70_livestock** added realization `fbask_jan16_sticky` +- **config** added `scenario_config_year_fix.csv` for choosing until when parameters are fixed to SSP2 values +- **cropland** added option for discarding initial treecover on cropland +- **script** added output script for conversion of validation.mif file into validation.rds +- **script** check of variables needed in piamInterfaces in report_rds.R +- **script** for downscaling to 0.25 deg using LUH2v2h as reference via mrdownscale +- **scripts** added out of bounds check as output script +- **scripts** added output report `EU_report.R` that uses `EU_report.Rmd` +- **scripts** added output script converting all grid-level .mz files to .nc (netCDF) +- **scripts** added script for automatic submission of SEALS allocation runs `./extra/runSEALSallocation.R` +- **scripts** added start script for 'Healthly Landscapes' paper `paper_healthyLscps.R` + +### fixed +- **15_food** fixing parameter declaration of i15_processed_kcal_structure_iso +- **35_natveg** bugfix secdforest and other land restoration to avoid double-counting of restoration in equation `q29_land_snv` +- **80_optimization** bugfix for variables levels not obeying the bounds in nlp_par, `conopt` changed to `conopt3` +- **scripts** fixing an error in start.R and output.R which occurred if more than one slurm job was submitted at the same time. + + +## [4.8.1] - 2024-06-19 + +### changed +- **29_ageclass** module 29_ageclass has been renamed to 28_ageclass to make space for `29_cropland` just before `30_croparea` +- **30_crop** module `30_crop` renamed to `30_croparea`, which now only accounts for crop area. +- **30_crop** Semi-Natural Vegetation (SNV) implementation has been moved from `30_crop` to `29_cropland` +- **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24` +- **30_crop** the two realizations `penalty_apr22` and `rotation_apr22` have been merged into a single `30_croparea/detail_apr24` realization +- **default.cfg** update additional data to rev4.51 +- **scripts** adjusted SLURM job handling +- **scripts** updated EL2p0 start scripts + +### added +- **10_land** added interface `pm_land_hist` with historic land use patterns +- **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). +- **42_water_demand** added non-agricultural water demand for entire year + +### removed +- **32_forestry** removed technical balance term `v32_land_missing_ndc` + +### fixed +- **22_land_conservation** avoid infeasibilities due to very small numbers, account for cropland tree cover and lower bound of cropland +- **32_forestry** avoid infeasibilities due to very small numbers +- **35_natveg** avoid infeasibilities due to very small numbers +- **44_biodiversity** Fixing to SSP2 parameters until 2025 was not working +- **config** update to input data rev4.109. In the previous rev4.108, MER GDP was wrong and was identical to PPP GDP + + +## [4.8.0] - 2024-06-10 + +### changed +- **14_yields** revised timber yield calculations +- **15_food, default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying food substitution scenarios and exogeneous food intake scenarios +- **22_land_conservation and default.cfg** Added options for baseline protection +- **32_forestry** renamed interface `pm_demand_ext` to `pm_demand_forestry` +- **32_forestry** revision and simplification of forestry implementation, renamed realization from `dynamic_feb21` to `dynamic_may24`. +- **35_natveg** `vm_land(j2,"forestry")` included in NPI/NDC constraint `q35_min_forest` +- **35_natveg** replaced the realisation `dynamic_feb21` with realisation `pot_forest_may24`. The new realisation provides additional information on the potential forest area, which is now used to constrain forest and forestry expansion and recovery. The remaining area for forest establishment is provided to the forestry module via the new interface parameter `pcm_max_forest_est`. +- **41_area_equipped_for_irrigation** updated (non-default) AEI data (from Mehta2022 to Mehta2024) +- **52_carbon** Separate carbon densities for forest and other land. Before there was only a single carbon density for natural vegetation land. +- **70_livestock** default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying feed substitution with SCP scenarios +- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE, CONOPT4 without preprocessing and CONOPT3. +- **default.cfg** changed default realization for 44_biodiversity to new realization `bii_target_apr24` +- **default.cfg** defaults for `cfg$gms$sm_fix_SSP2`, `cfg$gms$sm_fix_cc` and other switches changed from 2020 to 2025 +- **default.cfg** Forestry sector included by default by using the `ForestryEndo` settings from `scenario_config.csv`: `s32_initial_distribution = 1`, `s32_demand_establishment = 1`, `s32_hvarea = 2`, `s35_secdf_distribution = 2`, `s35_hvarea = 2`, `s73_timber_demand_switch = 1` +- **default.cfg** update additional data to rev4.50 +- **scripts** modified agmip_merge_report to use piamInterfaces +- **scripts** start/test_runs.R added 2 more test runs from FSEC + +### added +- **15_food** added additional sigmoid food substition scenarios `sigmoid_75pc_25_50`, `sigmoid_50pc_25_50` and `sigmoid_25pc_25_50` +- **21_trade** Minimum trade margin for forestry products `s21_min_trade_margin_forestry` +- **30_crop** added regional cropland equation `q30_crop_reg` and presolve growth constraint +- **44_biodiversity** added new realization `bii_target_apr24`, taking into account `f44_rr_layer` +- **60_bioenergy** added new realization `1st2ndgen_priced_feb24` to enable price-driven 2nd gen bioenergy production +- **73_timber** added interface `im_timber_prod_cost` +- **citation** added abstract +- **core** added `coup2110`timesteps +- **default.cfg** added cropland growth constraint `cfg$gms$s30_annual_max_growth` +- **default.cfg** added settings for new price-driven bioenergy realization `1st2ndgen_priced_feb24`: `cfg$gms$s60_2ndgen_bioenergy_dem_min_post_fix`, `cfg$gms$c60_bioenergy_subsidy_fix_SSP2`, `s60_bioenergy_gj_price_1st`, +- **default.cfg** added technical cost for missing BII increase `cfg$gms$s44_cost_bii_missing` +- **default.cfg** cfg$gms$s80_secondsolve option for second solve statement with 0=off as default +- **scenario_config.csv** added preset for GENIE project +- **scripts** added "checkSummation" output script for consistency checking a report.mif +- **scripts** added automatic set writer for new bioenergy realization to `start_functions` +- **scripts** added start scripts for the GENIE project +`s60_bioenergy_price_2nd`, `c60_price_implementation` + +### removed +- **14_yields** removed interface `pm_timber_yield_initial` +- **21_trade** removed interface `pm_selfsuff_ext`, removed `v21_manna_from_heaven` +- **32_forestry** removed interface `pm_representative_rotation` +- **35_natveg** removed growing stock calculation and calibration, which is no longer needed. +- **62_material/16_demand** Removed double structure for forestry products. `pm_demand_forestry` is now used in `62_material` +- **73_timber** removed interfaces `pm_demand_forestry_future` and `sm_wood_density` +- **scripts** removed support for spam files in start_functions +- **scripts/output/extra** removed scripts disaggregation_cropsplit and disaggregation_transitions + +### fixed +- **14_yields** fix division by zero in preloop of managementcalib_aug19 +- **44_biodiversity** avoid division by zero +- **58_peatland** Added balance variable to avoid random infeasibilites +- **80_optimization** fixed a bug in nlp_apr17; cycling through CONOPT4, CONOPT4 without preprocessing and CONOPT3 was not working +- **extra/disaggregation** fixed bug in disaggregation of land conservation related to switch from 59k to 67k that produced erroneous outputs +- **scenario_config.csv** same revision for input files as in default.cfg +- **scenario_fsec.csv** scenario settings +- **scripts/start/test_runs.R** include all default output script, in particular disaggregation.R, which is needed for BII +- **start/projects/fsec.R** scenario settings + + +## [4.7.3] - 2024-04-12 + +### changed +- **21_trade** Revision of trade module. Replaced `cfg$gms$s21_trade_bal_damper` in favour of `cfg$gms$k_import21`, which allows for additional imports to maintain feasibility +- **21_trade** v21_import_for_feasibility now available for all countries, not just for importers +- **70_livestock** if `c70_fac_req_regr` is set to `reg`: use of USDA/FAO values for historic factor requirements for livestock instead of using regression values and change of calibration year from 2005 to 2010 for regional factor requirements regression +- **config** updated FSEC scenario config for revision and included new calibration file (after cost fix in preprocessing) +- **default.cfg** updated inputdata revision to 4.104 to have NDC scenarios included +- **scripts** cfg$gms$s35_secdf_distribution <- 2 for FSEC +- **scripts** modified output reporting for SEALS to account for forestry plantations +- **scripts/calibration/landconversion_cost.R** Revised calibration approach for conversion costs for cropland. Information from all calibration time steps in combination with a lowpass filter is now used for deriving the calibration factors, which avoids the previous zickzack pattern. The previous option `cfg$damping_factor_landconversion_cost` has been removed in favor of `cfg$lowpass_filter_landconversion_cost`. + +### added +- **14_yields** added minimum threshold for wood yields. Below this threshold, wood yields are set to zero. +- **config** added switch for minimum timber yields +- **56_ghg_policy** added NDC scenarios +- **60_bioenergy** added NDC scenarios +- **scripts** start script for EAT2p0 Deep Dive project + +### fixed +- **15_food** Small number rather 0 in condition checking calorie balancing +- **34_urban** `static` realization was not working because `vm_carbon_stock` was referenced without the set `stockType` +- **52_carbon** removing jump of carbon content into fully grown forest when a forest changes from second-last age class to last age-class. +- **58_peatland** Equation `q58_scalingFactorExp` revised to avoid division by zero. +- **80_optimization** duplicated solve statement in all instances to avoid non-matchting left- and right-hand sides of equations + + +## [4.7.2] - 2024-04-02 + +### changed +- **21_trade** Revision of trade module. Replaced `cfg$gms$s21_trade_bal_damper` in favour of `cfg$gms$k_import21`, which allows for additional imports to maintain feasibility +- **58_peatland** Threshold in equations changed from 1e-10 to 1e-8 to avoid rare divisions by zero +- **70_livestock** if `c70_fac_req_regr` is set to `reg`: use of USDA/FAO values for historic factor requirements for livestock instead of using regression values and change of calibration year from 2005 to 2010 for regional factor requirements regression +- **config** updated FSEC scenario config for revision and included new calibration file (after cost fix in preprocessing) +- **scripts** modified output reporting for SEALS to account for forestry plantations + +### added +- **30_crop** Improved representation of cropland requiring relocation in response to introducing semi-natural habitat at the 1 km level based on high-resolution satellite imagery. +- **config** added `.codeCheck` with additonal configuration when running `gms::codeCheck` +- **scripts** add additional BII reporting variables in FSDP_collect.R +- **scripts** added a new validation_cell.R output script that generates a pdf with the comparison of magpie land use and crop type outputs with LUH and MAPSPAM historical data at cellular resolution. + +### removed +- **core** removed no longer needed set `si` Suitability classes + +### fixed +- **52_carbon** i52_land_carbon_sink was not identical before 2020 for different RCPs. Fixed by setting to RCPBU until the year defined in sm_fix_cc. +- **inputdata** currency fixed in historic value of production for crops and livestock which affects e.g. total labor costs and in turn hourly labor costs, bugfix in aggregation weight of capital cost share out of factor costs + + +## [4.7.1] - 2024-02-28 + +### changed +- **15_food** Added improved EAT Lancet diet implementation (EAT 2p0) +- **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 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` +- **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** 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` +- **56_ghg_policy_** added new trajectories for R32M46 +- **60_bioenergy** added new trajectories for R32M46 +- **scripts** added peatland to output/extra/disaggregation.R + +### removed +- **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 +- **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 +- **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 + +### changed +- **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. +- **36_employment** regression between hourly labor regression and GDP pc changed from linear to log-log +- **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 + +### 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 + + +## [4.6.11] - 2023-09-05 + +### changed +- **scripts** All time steps between 2015 and 2050 are now reported to SEALS + +### fixed +- **70_livestock** fixed division by zero that could occur depending on the scenario set-up + + +## [4.6.10] - 2023-08-16 + +### changed +- **config** update preprocessing to newest input data v4.88 with new transport costs +- **GitHub action** the github action is now faster, because it installs binary packages from Posit Package Manager +- **scenario_config.csv** update preprocessing to newest input data v4.88 +- **scripts** output.R is now faster, because it no longer searches runfolder renvs for full.gms files + +### fixed +- **scripts** check_config does not warn about c_input_gdx_path anymore while running empty model +- **scripts** fixed erronoeous if clause in output.R +- **scripts** fixed output/extra/disaggregation_LUH2.R. The script was not working any more because magpie4::protectedArea was changed to return protected area for all land types. Moreover, the script now also works for runs without dynamic forestry (default run) but with a warning message. + + +## [4.6.9] - 2023-07-27 + +### fixed +- **70_livestock** consideration of milk demand in the calculation of the pasture management factor +- **scripts** Fixed inaccuracies and inconsistent application of SNV policies during disaggregation in luscale::interpolateAvlCroplandWeighted(), which is called in extra/disaggregation.R + + +## [4.6.8] - 2023-07-17 + +### changed +- **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data +- **80_optimization** printing of solprint when solver status is 7 re-activated +- **scripts** start_functions.R can now handle clusters per region flexibly +- **scripts** the REMIND-MAgPIE coupling now uses renv + +### added +- **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` +- **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp` +- **71_disagg_lvst** added new realisation `foragebased_jul23` which solves GAMS issues at higher spatial resolutions +- **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script +- **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) +- **scenario_config.csv** added a scenario for the NGFS project +- **scripts** New output script for reporting disaggregated land use patterns to the SEALS (Spatial Economic Allocation Landscape Simulator) downscaling model + +### removed +- **config** `s80_num_nonopt_allowed` +- **scripts** removed .snapshot.Rprofile and the Rprofile.R script, renv now fully supersedes snapshots + +### fixed +- **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation +- **71_disagg_lvst** reworked `foragebased_aug18` (including removal of linear version and correction of balance flow calculation) +- **80_optimization** resolve was not working in nlp_par realization due to `s80_num_nonopt_allowed` +- **config** corrected wrong names of parameters for peatland costs +- **config** updated scenario configs to newest preprocessing (4.87) + + +## [4.6.7] - 2023-05-10 + +### changed +- **09_drivers** Harmonization of sets for population, gdp, pal and demography +- **56_ghg_policy** added emission policies without GHG emissions from peatlands +- **config** added scenario `SSP2EU` in scenario_config.csv +- **config** modified `eat_lancet_diet` in scenario_config.csv +- **config** update of additional data to rev4.43 +- **config** update of regional and cellular inputs to 4.85 in default.cfg and scenario_config.csv +- **scripts** added output script for forest area change at cluster level +- **scripts** NDC/NPI calculations can now handle 59k and 67k cell inputs + +### added +- **15_food** added an option in `s15_exo_diet` to allow for exogenous diet scenario for India + + +## [4.6.6] - 2023-05-10 + +### changed +- **config** updated scenario_fsec.csv to reflect new GST validation +- **scripts** included new output indicator for water +- **scripts** updated global surface temperature maps to new RCPs per scenario + + +## [4.6.5] - 2023-03-29 + +### changed +- **22_land_conservation** Replaced old options for land conservation by new conservation priority areas. These include among others a new 30by30 template (based on Key Biodiversity Areas, unprotected habitat in Biodiversity Hotspots, Ecoregions with a high beta-diversity from the Global Safety Net (Dinerstein et al. 2020) and critical connectivity areas (Brennan et al. 2022), a new Half Earth template based on the Global Safety Net (Dinerstein et al. 2020) and land conservation of irrecoverable carbon (Noon et al. 2022). +- **56_ghg_policy** renamed `cfg$mute_ghgprices_until` to `cfg$gms$c56_mute_ghgprices_until` and changed the default to `y2030`, i.e. no GHG emission pricing in the AFOLU sector before (and including) 2030. This setting will be also used in coupled REMIND-MAgPIE runs. +- **config** input data revision to rev4.82 to include new conservation priority areas +- **config** new options for conservation priority areas (including new 30 by 30 protection) +- **scripts** calc_calib.R bug fix. If the calibration factor of a region is equal to the maximum allowed value, its divergence is set the maximum allowed divergence. +- **scripts** Disaggregation of BII merged into standard extra/disaggregation.R +- **scripts** Disaggregation of land use to 0.5° now takes land conservation into account - i.e. cropland expansion is not mapped to areas that are subject to land conservation + +### added +- **56_ghg_policy** added switch `s56_minimum_cprice` +- **config** minimum CO2 price (`s56_minimum_cprice`) of 5 USD per tCO2 (18 USD per tC) for all future time steps in case of NDC policy to guide land-use decisions +- **scripts** added output script which writes landuse data on cluster resolution to a shapefile + +### removed +- **56_ghg_policy** removed `s56_ghgprice_phase_in` and `s56_ghgprice_start` +- **scripts** removed argument `mute_ghgprices_until`, now handeld in GAMS code + +### fixed +- **31_past** fixed pasture suitability to SSP2 before and including 2020 (only relevant for grassland implementation) +- **56_ghg_policy** the renamed switch `c56_mute_ghgprices_until` is now always used for coupled as well as standalone runs. +- **scripts** Fixed occasional memory failure in the disaggregation script + + +## [4.6.4] - 2023-02-22 + +### changed +- **15_food** Interpret EAT-Lancet guidelines not as target but as lower/upper limits +- **config** changed order of output scripts. Some functions in rds_report require gridded outputs. +- **config** input data revision to rev4.81 for trade margin bugfix +- **config** scenario_fsec.csv updated input data tgz +- **config** scenario_fsec.csv updated to new biodiversity scenario +- **scripts** fsec.R and project_FSEC_Scenarios.R include capitalSubst and landscapeElements scenarios +- **scripts** highres.R changed default resolution to c1000 +- **scripts** recalibrate.R and recalibrate_realization were modified to always use best_calib for the yield calibration. +- **scripts** updated FSEC scenario start and output scripts +- **scripts** when manually running output scripts for multiple runs the lockfile is only created once +- **sticky_labor** changed labor cost share constraint from regional to cellular level +- **sticky_labor** renamed equation `q38_labor_capital_ratio` to `q38_labor_share_target` + +### added +- **15_food** half_overweight scenario added +- **21_trade** New Bilateral trade realization selfsuff_reduced_bilat22 for bilateral trade within selffsuff constraints +- **32_forestry** added switch `s32_aff_prot` for protection of afforested areas (0=until end of planning horizon 1=forever) +- **56_ghg_policy** added two scenarios for GHG emission pricing and options for afforestation +- **config** added options for afforestation assumptions and updated additional data to 4.38 +- **config** added setting cfg$keep_restarts which controls whether restart files should be kept after a run finished +- **config** changed default for `s_use_gdx` from 2 to 0 +- **scripts** added restart points after each time step from which the model can now be restarted if the simulation aborts at some point +- **scripts** added SLURM dayMax submission type for standby QOS +- **sticky_labor** `nl_fix`, `nl_relax` and `nl_release` added + +### removed +- **42_water_demand** removed fm_multicropping factor because of fallow inconsistency + +### fixed +- **14_yields** nl_fix updated to current equation +- **32_forestry** pm_land_conservation(t,j,"secdforest","restore") now accounts for the rotation length in timber plantations to avoid infeasibilities +- **44_biodiversity** added regional layer `i` in `bii_target` realisation to make it compatible with the high-resolution parallel optimization output script +- **59_som** division by zero prevented by if condition +- **scripts** fixed a bug where renvs for high resolution runs were missing some packages +- **scripts** fixed in the calc_calib.R script the saving of calib_factors used in each iteration to ensure that they correspond to the divergence reported. Changed divergence from zero to NA for those iterations where calib_factors are above the limit. The best_calib selection criterion was changed from selecting the factors of the iteration with the lowest standard deviation to the selection, for each region, of the factor of the iteration with the lowest divergence. Also, factors from the first iteration are now not considered, and if two different factors had the same divergence for a region, the one of the latest iteration is picked. + + +## [4.6.3] - 2023-01-19 + +### changed +- **15_food** changed `anthro_iso_jun22` realisation such that results in case of `exo_diet = 1/0` and `exo_waste = 1/0` are identical until 2020 +- **30_crop** identical assumptions for bioenergy until 2020 +- **38_factor_costs** changed name of set `req` to `factors` (also used in 11_costs, 57_maccs, 70_livestock) +- **38_factos_costs** sticky_labor realization: included option to set a labor share target +- **62_material** Bioplastic demand identical in all scenarios until 2020 +- **config** added `s38_target_labor_share`, `s38_targetyear_labor_share` and `s38_target_fulfillment` to define labor share target scnarios +- **config** and **38_factor_costs** changed name of `s38_fix_capital_need` to `s38_startyear_labor_substitution` +- **config** update input data to rev4.79 + +### added +- **31_past** added additional limitation (single climate scenario input) for **grasslands_apr22** +- **59_som** added new **cellpool_jan23** realization with updated 2019 IPCC guidelines values +- **scripts** added start script which starts an empty model just regenerating a previous run + +### fixed +- **scripts** make sure that `c_title` in the GAMS code is not containing dots which otherwise could lead to compilation errors + + +## [4.6.2] - 2023-01-12 + +### changed +- **36_employment** include labor costs from MACCs in employment +- **38_factor_cots** renamed `p36_cost_shares` to `pm_cost_share_crops` +- **57_maccs** split costs into labor and capital +- **config** scenario_fsec.csv update +- **config** updated SHAPE SDP scenarios in scenario_config.csv +- **scripts** FSDP_collect FSDP_process fsec.R updates + +### added +- **renv** MAgPIE now runs in an isolated, stable, reproducible R package environment +- **scripts** added output script that generates a short mif containing only variables relevant for the REMIND coupling +- **scripts** added output script that generates subnational validation outputs for fable_India projects +- **setup** required R packages are automatically installed + + +## [4.6.1] - 2022-12-13 + +### changed +- **42_water_demand** replaced `f42_env_flow_policy` with macro +- **30_crop** replaced `f30_scenario_fader` with macro +- **30_crop/config** changed switch `c30_rotation_scenario_speed` to `s30_rotation_scenario_target` +- **30_crop/config** changed switch `c30_snv_target` to `s30_snv_scenario_target` +- **config** changed default value for `c30_marginal_land` from `'all_marginal'` to `'q33_marginal'` for better spatial cropland patterns + +### added +- **10_land** added `vm_lu_transitions` as interface +- **10_land** added interface `fm_land_iso` for consistency +- **30_crop/config** added switch `s30_rotation_scenario_start` +- **30_crop/config** added switch `s30_snv_scenario_start` +- **30_crop/config** added switch for set `land_snv`for defining which land cover types are allowed in the semi-natural vegetation policy in cropland scenarios +- **39_landconversion** scalar `s39_reward_crop_reduction` provides a cropland reduction reward + +### removed +- **10_land** removed `feb15` realization +- **10_land** removed the interfaces `vm_croplandexpansion` and `vm_croplandreduction` +- **30_crop** removed `f30_scenario_fader.csv`input +- **39_landconversion** removed `s39_reward_shr` +- **config** validation_short.R output script is no longer run by default after each run +- **scripts** removed remind2::deletePlus in coupling interface of start_function + +### fixed +- **59_som** fixed land use change tracking for non-cropland pools in the `cellpool_aug16` realization +- **config** changed default value for s56_limit_ch4_n2o_price from 1000 to 4000 for consistency with c57_macc_version = "PBL_2022" +- **scripts** rewrite of land conversion cost calibration script `landconversion_cost.R` + + +## [4.6.0] - 2022-11-09 + +### changed +- **18_residues** bugfix in `q18_cost_prod_res` +- **36_employment** included calculations for minimum wage scenario +- **38_factor_costs** included labor cost scaling in case of wage scenario +- **42_water_demand** account for multiple cropping in water requirements +- **51_nitrogen** moved maccs into emission modules. change of interface from vm_btm_reg to vm_emissions_reg +- **52_carbon** change of interface from vm_btm_reg to vm_emissions_reg +- **52_carbon** Soil C of urban areas set to soil C of natural other land +- **57_maccs** default changed from PBL2007 to PBL2022 +- **58_peatland** moved maccs into emission modules. change of interface from vm_btm_reg to vm_emissions_reg +- **59_som** Now calculates soil C for fallow and urban areas +- **62_material** added biomass demand for bioplastic production +- **70_livestock** included labor cost scaling in case of wage scenario +- **config** added `s62_max_dem_bioplastic` and `s62_midpoint_dem_bioplastic` to define bioplastic scenario +- **config** adjusted PR template +- **config** best_calib set to FALSE in default +- **config** new switches `s36_minimum_wage`, `s36_scale_productivity_with_wage`, and `s38_fix_capital_need` +- **config** non-food system emission MAGICC switch +- **config** updated config to new module setup of MACCs +- **config** updated default realization of 15_food from anthropometrics_jan18 to anthro_iso_jun22 +- **config** updated SHAPE SDP scenarios in scenario_config.csv +- **documentation** added literature +- **inputs** update of NPi for China (additional data 4.30) +- **inputs** updated f56_emis_policy (additional data 4.29) +- **inputs** updated non-food initial prices, MACCs curves, and removed suitability threshold of 0.1 in all_marginal setting +- **scripts** added single time step run to test runs +- **scripts** fix in start_functions for the calibration setting `ifneeded` +- **scripts** FSDP_collect handles the health impacts data provided by Marco Springmann, distributed it into the scenario's various reports. It performs a similar operation for global nutrient surplus (which must be calculated on the grid-level and then aggregated).- **13_tc** relaxed vm_tau upper limit +- **scripts** log files are now written in a subfolder "logs" +- **scripts** output/extra/disaggregation_BII.R adjusted BII output for primary and secondary other land +- **scripts** quit with exit code = gams status at the end of submit.R +- **scripts** update of rds_report to allow gridded intermediate outputs +- **scripts** updated FSEC start and output scripts +- **scripts** updated FSEC start scripts and related config files to introduce new scenarios +- **scripts/start** cleanup of old start scripts + +### added +- **14_yields** added input file containing AQUASTAT yield calibration factors and switch `s14_calib_ir2rf` in default.cfg to activate this yield calibration +- **15_food** added new realization with country level exogenous diets, product-specific intake estimates, new scenarios for exogenous BMI and decomposition switches for EAT Lancet diets. Simplified code and improved iteration procedure. +- **50_nr_soil_budget** new module realization for more consistent MACCs implementation. change of interface from vm_btm_reg to vm_emissions_reg +- **53_methane** moved maccs into emission modules. change of interface from vm_btm_reg to vm_emissions_reg +- **56_ghg_policy** added new ecosystem protection scenarios +- **56_ghg_policy** new module realization for more consistent MACCs implementation +- **57_maccs** added new Marginal Abatement Cost Curve (MACCs) data set from PBL (PBL2022) +- **57_maccs** new more consistent maccs implementation. different mapping of emission sources to maccs. +- **f32_forest** added the option to run generic disturbance scenarios of secondary forest types determined in `f32_forest_shock.csv` +- **f35_natveg** added the option to run generic disturbance scenarios of primary forest determined in `f35_forest_shock.csv` +- **scripts** added output script creating a merged .csv for dietaryIndicators and caloricSupply outputs +- **scripts** added output script creating a merged .csv for dietaryIndicators and caloricSupply outputs +- **scripts** added output script creating a set of outputs for Alessandro Passaro in the FSEC context +- **scripts** added output script creating a set of outputs for Simon Dietz in the FSEC context +- **scripts** added output script for gridded crop diversity indices +- **scripts** added output script running MAGICC7 on a MAgPIE scenario +- **scripts** added output script, FSDP_process creating a merged .csv and .gdx for dietaryIndicators and caloricSupply outputs +- **scripts** added output scripts for FSEC FSDP runs +- **scripts** added water output script for FSEC model runs + +### removed +- **15_food** removed read-in of non-needed input file "f15_calib_factor_FAOfsupply_iso" +- **38_factor_costs** removed `mixed_reg_feb17` realization +- **50_nr_soil_budget** old inconsistent module realizations +- **53_methane** old inconsistent module realizations +- **56_ghg_policy** old inconsistent module realizations +- **57_maccs** old inconsistent module realizations + +### fixed +- **38_factor_costs** fixed calibration of share parameter in `sticky_labor` realization +- **43_water_availability** added missing years after 2100 in "f43_wat_avail" to avoid infeasibilities in coupled runs with less_ts timesteps +- **59_som** corrected the som pool due to the carbon transfer from other and primary forest to secondary forest before optimization (presolve) +- **scripts** fixed some bugs related to background execution of start/output scripts + + +## [4.5.0] - 2022-07-07 + +### changed +- **09_drivers** separation of GDP and population scenarios +- **09_drivers** changed `i09_gdp_pc_mer_iso` to `im_gdp_pc_mer_iso` +- **11_costs** Split of production costs per sector, addded new separated costs to the costs function. +- **13_tc** changed vm_tech_cost upper bound to share of regional GDP PPP (s13_max_gdp_shr) +- **13_tc** Replace endo_jan18 realization by endo_jan22. The new realization adds a new dimension to vm_tau separating crop from managed pastures tau. +- **15_food** added more options to define convergence towards exogenous food intake and waste scenarios accounting for different transition periods +- **18_residues** The variable that include production costs vm_cost_prod for residues changed to a new independent variable called vm_cost_prod_kres +(specific to residues). +- **30_crop** renamed switch `s30_set_aside_shr`, `s30_set_aside_shr_noselect` and `c30_set_aside_target` to `s30_snv_shr`, `s30_snv_shr_noselect` and `c30_snv_target`. +- **31_past** The variable that include production costs vm_cost_prod for pasture changed to a new independent variable called vm_cost_prod_past +(specific to past). +- **31_past** added new realization implementing the separation of rangelands and managed pastures for the production of grass biomass. +- **32_forestry** simplification and bugfix of afforestation limit. `c32_max_aff_area_glo` renamed to `s32_max_aff_area_glo` in default.cfg. +- **34_urban** added set urban_scen34 and the switch c34_urban_scenario +- **35_natveg** corrected naming of Frontier Forests (FF) to Intact Forest Landscapes (IFL) and changed input data for BH_IFL implementation. +- **35_natveg** implementation of land protection moved to new module `22_land_conservation` +- **38_factor_costs** Sticky free/dynamic switch was removed and the realization was split into two realizations: the new per_ton_fao_may22 (free) and sticky_feb18 (dynamic). vm_cost_prod(i,kall) is now vm_cost_prod_crop(i,req) for crops factor costs. The results are now given differentiating between capital and labor for all realizations (new set req). +- **42_water_demand** Added new input data on pumping costs for India, equation to calculate water costs and scalars for policy shocks +- **44_biodiversity** Improved documentation, simplification of equations and flexible options for price on biodiversity loss +- **56_ghg_policy** additional scenarios for c56_emis_policy +- **56_ghg_policy** Deactivated GHG emission policies were not accounted for in the MACCs module. This has been corrected by an extension of the interface `im_pollutant_prices`, which now has an additional dimension for emission sources `emis_source`. In this context some equations in `56_ghg_policy` have been simplified (sets: `emis_source_reg`, `emis_source_cell`). Also, GHG emissions from peatlands have been fully integrated into `56_ghg_policy`. +- **70_livestock** vm_cost_prod(i,kall) is now vm_cost_prod_livst(i,req) for livestock factor costs (req indicates differentiation between capital and labor) and vm_cost_prod_fish(i) for fish. +- **80_optimization** Updated solver settings +- **config** Update of regional and grid inputs from 4.68 to rev4.69, and additional files to 4.17. Removed free/dynamic sticky switch, and added scalars used in mixed_regional factor costs realization. +- **config** added s13_max_gdp_shr setting for tech cost upper bound as share of GDP PPP +- **config** included switch for non-agricultural water demand (s42_watdem_nonagr_scenario) in scenario_config.csv +- **config** included SHAPE SDP scenarios in scenario_config.csv +- **config** Update default tau realization from endo_jan18 to endo_jan22 +- **config** Added new SSP scenario switch for pasture suitability cfg$gms$c31_past_suit_scen +- **config** Added new switch to limiting calibration to relative or absolute managed pastures yields: cfg$gms$s31_limit_calib. +- **inputs** updated non-agricultural water use scenarios (watdem_nonagr_grper.cs3) +- **modules** Moved interface `vm_carbon_stock` from 52_carbon to 56_ghg_policy +- **scripts** replaced redundant files config.log and config.Rdata with a config.yml +- **scripts** updated FSEC modeling start script and added FSEC calibration scripts +- **scripts** clean up of the recalibrate_realizations.R script, project_LAMACLIMA_WP4.R, and sticky.R to remove sticky dynamic/free switch. +- **scripts** bugfix in disaggregation.R, disaggregation_BII.R with respect to urban scenario +- **scripts** added FSEC modeling start script (global runs) +- **scripts** The disaggregation_LUH2.R was extended to include the changes used to generate ISIMIP3b maps for LUH harmonization. The largest changes are: 1) The convertLUH function now breaks the grid level magpie objects by groups of years, then creates the raster for the groups and aggregates them to create the final map at a quarter of a degree resolution (this speeds up the process). 2) The mapping between LUH and MAgPIE is now defined by country and magpie-LUH types (not 1 to 1 anymore). 3) The split of MAgPIE's pasture land type between pasture and rangeland changed. Rangeland is assumed to stay constant after 2015, and changes in MAgPIE's pasture are due to managed pasture. 4) IFs were added so if a certain map already exists in the output folder, it will not generate it once again. 5) Flooded land now corresponds to a share of rice cropland, based on historical values. 6) To speed calculations, yields are read at the cell level, the crops are aggregated based on the new MAgPIE-LUH mapping, and then disaggregated to grid level. +- **scripts** added new disaggregation script to provide grid cell level BII +- **scripts** removed test script "irrig_dep_test" from "start" folder to "extra" folder +- **scripts** Added script projects/paper_grassland.R +- **scripts** scripts/output/extra/emulator.R Remove dependency on deprecated R package "magpie" + +### added +- **core** macros for linear and sigmoidal time interpolation +- **22_land_conservation** added new module and realisation for land conservation. The realisation also includes a new WDPA initialisation data set (from 1995 to 2020) for protected areas under legal protection, meeting IUCN and CBD protected area definitions. The module also adds the interface `pm_land_conservation`. +- **30_crop** new module realizations including crop rotation scenarios by strict constraints (`rotation_apr22`) and by penalties (`penalty_apr22`) +- **36_employment** added new module to calculate agricultural employment. Includes one realization (`exo_may22`) in which employment is calculated based on the total labor costs (for crop and livestock production) +- **38_factor_costs** mixed_reg_feb17 realization added. This realization includes differences in productions costs between irrigated and rainfed crops, with the option of regional differentiation as well. per_ton_fao_may22 realization added. This realization corresponds to the old sticky_feb18 free. +- **38_factor_costs** added switch `c38_fac_req` to choose between global and regional crop factor requirements. The default is "glo" (which corresponds to the previous implementation) +- **44_biodiversity** added new realization `bii_target`, which calculates the BII at the level of 71 biomes and allows to set targets for BII (e.g. no decrease in the future) +- **52_carbon** added land carbon sink adjustment factors, needed in R post-processing +- **70_livestock** added switch `c70_fac_req_regr` to choose between global and regionally calibrated regression to calculate livestock factor requirements. The default is "glo" (which corresponds to the previous implementation) +- **config** added option for CO2 emission pricing `cfg$gms$c56_carbon_stock_pricing` +- **config** added cfg$gms$s70_past_mngmnt_factor_fix with default 2005 (previous default was 2010). The previous setting caused a strong spike in CO2 emissions from pasture expansion in SSA. With 2005, this can be avoided. +- **inputs** New input files added: + f13_pastr_tau_hist.csv -> historical tau for managed pastures. + f31_pastr_suitability.cs3 -> Managed pasture suitability + f31_LUH2v2.cs3 -> LUH2v2 land classes separating rangelands from managed pastures + f31_grassl_yld.cs3 -> Rangelands and managed pastures grass yields + f31_grass_bio_hist.cs3 -> Historical grass biomass demand +- **modules** New dimension in `vm_carbon_stock` for different carbon stock types (actual, previousLandPattern, previousCarbonDensity) +- **scripts** output/projects/FSEC_StevenLord.R to create output for Steven Lord in the FSEC context +- **scripts** output/projects/FSEC_costs.R to create costs ouput for the FSEC project +- **scripts** output/projects/FSEC_dietaryIndicators.R to create output datasets for the FSEC project +- **scripts** output/projects/FSEC_nitrogenPollution.R to create output datasets of nitrogen pollutants for the FSEC project +- **scripts** Extended dissagregation.R script to replace single "past" land class by LHU range and pastr classes when grassland_apr22 realization is used. +- **scripts** `start/projects/test_rotations.R` testscript for different rotation scenario settings + +### removed +- **38_factor_costs** mixed_feb17 and fixed_per_ton_mar18 realizations removed because they are not being used at the moment. + +### fixed +- **09_drivers** bugfix concerning the use of the switch c09_gdp_scenario for defining population assumptions +- **09_drivers** introduced new sets for PAL and demography scenarios to account for only partial coverage of available socio-economic gdp and population scenarios +- **18_residues** off realization; missing variable declarations +- **34_urban** exo_nov21 realization; bugfix in calculation of biodiversity value +- **41_area_equipped_for_irrigation** static realization. bugfix in presolve.gms: f41_irrig_luh("y1995",j) +- **44_biodiversity** fixed accounting for time step length in realization `bv_btc_mar21` +- **50_nr_soil_budget** off realization; missing variable declarations +- **56_ghg_policy** Some equations in `56_ghg_policy` have been simplified. Also, GHG emissions from peatlands have been fully integrated into `56_ghg_policy`. +- **56_ghg_policy and config** removed switch `s56_reward_neg_emis` +- **59_som** static realization; avoid division by zero +- **62_material** exo_flexreg_apr16 realization; avoid division by zero +- **80_optimization** nlp_par realization; bugfix i2 in submission loop +- **inputs** included data for Sudan +- **scripts** calibration; set NA values to 1 +- **scripts** fixed misleading warning in check_config +- **scripts** fixed configuration error in FSEC output scripts, FSEC_dietaryIndicators.R and FSEC_environmentalPollutants.R +- **scripts** scripts/start/extra/emulator.R Throw an error if no file can be found to take the GHG prices from + + +## [4.4.0] - 2021-12-13 + +### changed +- **additional_data** NDCs for Chinas afforestation now start earlier (1995) in line with observed afforestation. +- **config** comments added for correct use of nitrogen switches +- **inputs** new default LPJmL version with growing season adaptation (gsadapt) on +- **51_nitrogen** parameter change in rescaled_jan21, now including regionalized climate-dependent leaching factors +- **config** Update default configuration to new input data (especially cellular inputs) including all module realization updates (14_yield, 22_processing, 30_crop, 38_factor_costs, 39_landconversion). Moreover, climate impatcs (cc options for biophysical inputs) are activiated as default. New best_calib calibration routine is activated as default. +- **config** peatland module on by default (cfg$gms$peatland <- "on") +- **config** update default setting for 2nd generation bioenergy demand and GHG prices +- **config** update default setting for the 42_water_demand module (to all_sectors_aug13) +- **scripts** output/extra/disaggregation.R updated to account for country-specific set-aside shares in post-processing +- **scripts** output/extra/disaggregation.R updated to account for sub-categories of "forestry" +- **scripts** Default recalibration routine does not read in previous calibration factors anymore +- **09_drivers** Update sets in drivers to include new SDP and Ariadne GDP and Pop scenarios +- **21_trade** In the exo and off realization, equations corrected to be consistent with the mapping between supreg h and regions i. Bugfixes in trade exo and off realizations. Added scaling factor for exo realization. +- **inputs** Update of GDP and population scenarios based upon recent historic data from WDI (complemented with growth rates given by the James2019 dataset), short term projections until 2025 from IMF (for GDPpc) and WB (for pop) and reconverge to the original SSP GDPpc levels by 2100. +- **inputs** Update of all input data that are based on FAO, using the most up-to-date version of FAOSTAT datasets available at the date of input calculations via automated download. +- **inputs** Update of additional data to rev4.07 +- **scripts** scripts/start/projects/project_LAMACLIMA.R -> scripts/start/projects/project_LAMACLIMA_WP4.R +- **58_peatland** "On" realization: Degraded peatland is estimated differently, based on an additional calibration factor. +- **43_water_availability** changed scaling factor +- **10_land** Converted "v10_landreduction" to interface "vm_landreduction", used in "modules/39_landconversion/calib" +- **52_carbon** Removed interface "vm_carbon_stock_change", no longer needed +- **scripts** recalibrate_realizations.R and recalibrate.R adjusted for land conversion cost calibration + default time steps for convenient validation of results +- **scripts** start_functions adjustments for land conversion cost calibration +- **scripts** start.R added SLURM medium as choice +- **scripts** yield calibration, "best" setting uses factors from iteration with lowest standard deviation +- **14_yield** read-in file f14_yld_calib.csv if exists. Set default calibration factors to 1 in case f14_yld_calib.csv does not exist +- **13_tc** different educated guess for vm_tau in 1995 +- **scaling** Update of scaling factors. removed duplicates +- **32_forestry** Avoid division by zero (observed under higher regional resolutions) +- **35_natveg** Avoid division by zero (observed under higher regional resolutions) +- **70_livestock** Avoid division by zero (observed under higher regional resolutions) +- **60_bioenergy** Minimum dedicated 2nd generation bioenergy demand assumed in each region raised from 0.01 to 1 mio. GJ per yr, and added as option in the config file (s60_2ndgen_bioenergy_dem_min) +- **config** Remove elements from the parameter list of start_run(), instead include them as regular settings in the default.cfg. +- **scripts** Add option to take ghg prices from different file than the regular reporting file (used in the REMIND coupling) +- **60_bioenergy** Switch off fixing the bioenergy demand to SSP2 until 2020 if MAgPIE runs coupled (to REMIND) or for emulator runs (to derive biomass supply crurves). +- **56_ghg_policy** Switch off fixing the GHG prices to SSP2 until 2020 if MAgPIE runs coupled (to REMIND) or for emulator runs (to derive biomass supply crurves). +- **scripts** start/test_runs.R added SSP1, SSP2 and SSP5 as default test runs + +### added +- **34_urban** New exo_nov21 exogenous realization of urban land expansion +- **21_trade** Missing interface parameter for failing exo realization runs +- **59_som** exogenous pathway for vm_nr_som via f59_som_exogenous +- **config** Addition of a new scenario column (Tland) in scenario_config.csv +- **config** Added option c32_max_aff_area, which allows to provide a file with regional limits for afforestation +- **14_yield** parameter created to save historical cellular yields and to be used in the sticky realization of 38_factor_costs and in the 17_production module +- **17_production** switch added to decide if initialization of cellular crop production is needed or not. Also, a parameter to calculate initial production based on input cellular crop patterns and semicalibrated yields (potential yields calibrated to FAO values). +- **scripts** Added calibration script to generate default calibration for different factor costs realization +- **scripts** scripts/output/extra/disaggregation_LUH2.R script for exporting spatial output in LUH2 format (NetCDF) +- **37_labor_prod** labor productivity module with two realizations: off and exo +- **38_factor_costs** new realization "sticky_labor", based on "sticky_feb18" but accounting for changes in labor productivity +- **15_food** Added additional solve with CONOPT3 in case of modelstat 7 +- **scripts** Added script "landconversion_cost.R" for land conversion cost calibration in scripts/calibration, for matching historic cropland in 2015 +- **39_landconversion_cost** added new realization "calib", which uses the calibration factors derived by "landconversion_cost.R" +- **scripts** Added start script for yield and land conversion cost calibration "recalibrate_all.R" +- **scripts** added script validation_short.R with aggregated crop types (cutting the PDF size in half) -> replaces validation.R in default.cfg +- **scripts** added start script "scripts/start/Rprofile.R" for adding a R snapshot to the ".Rprofile" file +- **config** file "land_carbon_sink_adjust_grassi.mz" added to cfg$files2export$start +- **config** Inclusion of LAMACLIMA scenarios in scenario_config.csv +- **output.R** added SLURM standby maxMem and SLURM priority maxMem; needed for some output scripts (e.g. disaggregation_LUH2.R) + +### removed +- **32_forestry** Removed static realization +- **35_natveg** Removed static realization +- **scripts** lpjml_addon script is removed and all calls within dependend starting scripts +- **scripts** output/extra/disaggregation_transitions_.R moved to deprecated folder +- **scripts** output/extra/disaggregation_cropsplit.R moved to deprecated folder +- **14_yield** Removed `biocorrect` and `dynamic_aug18` realizations +- **20_processing** Removed `substitution_dec18` realization +- **30_crop** Removed `endo_jun13` realization +- **scripts** scripts/start/extra/highres.R +- **39_landconversion_cost** removed realizations "global_static_aug18" and "devstate" + +### fixed +- **80_optimization** Improved solve logic in "nlp_apr17" and "nlp_par" realization, multiple bugfixes and switch to solvelink=3 in "nlp_par" +- **58_peatland** fixed rare infeasibility in "on" realization +- **10_land** fixed rare infeasibility in "landmatrix_dec18" realization +- **38_factor_costs** For the sticky_feb18 realization correction in initial capital stocks, use of production initial values, and 05USDppp units changed to 05USDMER for sticky so it matches the units of the other realizations +- **80_optimization** Bug fixes in the nlp_par (parallel optimization) and improved code to collect failing handles. +- **32_forestry** Avoid division by zero in q32_establishment_dynamic_yield +- **35_natveg** fixed land protection to SSP2 default (WDPA) for historic period +- **15_food** New iteration needs to be started before setting food prices for curr_iter15 +- **scripts** scripts/output/extra/highres.R bugfixes +- **38_factor_costs** units in sticky_feb18 +- **32_forestry** Global afforestation limit s32_max_aff_area was not effective in case of parallel optimization -> added option c32_max_aff_area, which allows to provide a file with regional limits for afforestation; +- **73_timber** plausible cost for balance variable in case of s73_timber_demand_switch = 0 to avoid cost distortion +- **56_ghg_policy** choose the correct scenario for fixing the GHG prices until sm_fix_SSP2 + + +## [4.3.5] - 2021-09-02 + +### changed +- **13_tc** added switch to ignore historic tau patterns in historic time steps (new default) +- **16_demand** Moved most of cropping related set definitions (k, kve, kcr) from **16_demand** to **14_yield** +- **32_forestry** Added option to choose a rotation length calculation criteria +- **35_natveg** Calculation of land protection policies revised and moved from presolve.gms to preloop.gms +- **38_factor_costs** Realization `sticky_feb18` extended to differentiate capital requirements between regions and their specific development status (GDP) in each time step of the magpie run. The changes in the `sticky` realization also include an additional switch so it can be operated as `dynamic` (change of each region capital share at each time step) or `free` (capital shares equal to zero and equivalent to the `fixed_per_ton_mar18` realization). Bugfix in the yearly update of the variable input requirements. Addition of the time dimension and clean up of names of parameters used in the realization. Removal of the management factor (this factor was not being used, it was being cancelled out in previous calculations). Correction of the costs, they are given in 05USDppp. +- **39_landconversion** lower costs for expansion of forestry land +- **58_peatland** Peatland area is initialized in 1995 based on levels for the year 2015, and hold fixed depending on `s58_fix_peatland`. This provides a better proxy for peatland area and associated GHG emissions for the historic period, which where assumed zero in previous versions. +- **80_optimization** **nlp_par** parallelizes now on superregional level `h` instead of regional level `i` as before. +- **script** Added forestry run script which used LPJmL addon +- **script** New standard for cluster to region mapping (rds-files) is used in all scripts. If old spam files are provided by input data, rds-mapping file is created. +- **script** updated test run script. Update of the sticky run script. +- **start scripts** improved function for GAMS set creation from R and outsourced it to package `gms` +- **inputs** Changed file format from cs2 to cs2b for cellular input files with a single data column +- **scenario_config** added RCPs as columns for use with setSceanrio function. This required the addition of "gms$" in the 1st column. + + +### added +- **73_timber** Added construction wood demand scenarios based on Churkina et al. 2020 +- **script(s)** Added scripts to replicate runs for Mishra et al. 2021 (in review : https://doi.org/10.5194/gmd-2021-76) +- **13_tc** Added new interfaces for tau factor of the previous time step (`pcm_tau`) +- **14_yield** Added new realization `managementcalib_aug19` that is able to calibrate yield data coming from uncalibrated crop models (e.g. LPJmL yields for unlimited N supply). The yield calibration is either a purely multipicative factor or is limited to additive change in case of a underestimated FAO yield by the initial crop model yields (based on the switch `s14_limit_calib`). For pastures spillover of crop yield increases due to technological change from the previous time step are allowed and can be scaled using `s14_yld_past_switch`. +- **20_processing** Added new almost identical realization that excludes a calibration of the oil crop demand for oils (Note: old realization can be removed, when old yield realizations are deleted). +- **30_crop** Added new realization `endo_apr21`. The realisation includes new input data for available cropland and a new switch `c30_marginal_land`, which provides different options for including marginal land as cropland. Furthermore, a given share of the available cropland can be set aside for the provisioning of natures contribution to people and to promote biodiversity. The new switches `s30_set_aside_shr` and `c30_set_aside_target` are included to specify the share that should be set aside and the target year. +- **30_crop** Added new interface parameter historic croparea (`fm_croparea`) +- **30_crop** Added new option `policy_countries30` for country specific set aside share +- **35_natveg** Added new option `"FF+BH"` for protected areas. +- **35_natveg** Added new option `policy_countries35` for country specific land protection +- **38_factor_costs** Added scaling factors for improving model run time +- **39_landconversion** new realization `devstate` in which global land conversion costs are scaled with regional development state (0-1) +- **41_area_equipped_for_irrigation** Added switch for using different input data including new LUH2v2 consistent initialisation pattern. +- **41_area_equipped_for_irrigation** Added scalar for depreciation rate that depreciates certain area in every timestep, defined by switch in config. +- **58_peatland** Added option for one-time and recurring costs of peatland degradation (USD05MER per ha) +- **calibration run** has two new features: 1. Upper bound to cropland factor can be added (`crop_calib_max`). 2. Best calibration factor (factor with the lowest divergence) can be picked individually for each regions based on all calibration factors calculated during the calibration run iteration (`best_calib`). +- **disaggregation** Added new disaggregation script that is in line with new crop realisation and can account for cropland availabilty on grid level during disaggregation (see `interpolateAvlCroplandWeighted()` in package `luscale` for further details). +- **sets** added superregional layer `h` as additional spatial layer and moved constraints in **13_tc** and **21_trade** partly to the superregional level. + +### removed +- **13_tc** Removed disfuctional setting c13_tccost = "mixed" +- **core** removed sets ac_young and ac_mature (no longer needed due to changes in 44_biodiversity) + +### fixed +- **32_forestry** BII coefficients for CO2 price driven afforestation +- **32_forestry** growth curve CO2 price driven afforestation +- **32_forestry** NPI/NDC afforestation infeasibility +- **32_forestry** Correct distribution from LUH data to plantations and ndcs +- **35_natveg** option to fade out damage from shifting agriculture by 2030 +- **44_biodiversity** ac0 included in pricing of biodiversity loss + + +## [4.3.4] - 2021-04-30 + +### changed +- **51_nitrogen** New calculations for emissions from agricultural residues (vm_res_ag_burn) +- **53_methane** New calculations for emissions from agricultural residues (vm_res_ag_burn) +- **citation file** added new contributors + +### added +- **config** The set "kfo_rd" (livst_rum, livst_milk), which is used in the food substitution scenarios c15_rumdairy_scp_scen and c15_rumdairyscen, has been added to the default.cfg file. This allows for sensitivity scenarios (e.g. only livst_milk or only livst_rum). +- A new scenario (nocc_hist) was added to the cc/nocc switch. In this scenario, parameters affected by the cc/nocc switch in **14_yields**,**42_water_demand**,**43_water_availability**,**52_carbon**,**59_som** keep their historical/variable values up to the year defined by sm_fix_cc. Afterwards, sm_fix_cc values are kept constant for the overall run horizon. + +### fixed +- **09_drivers** migration of sm_fix_SSP2 and sm_fix_cc declaration from the core declarations to the drivers module. This will allow to set the scalars properly . +- - **15_food** single-cell protein substitution scenarios included in intersolve.gms. +- **20_processing** The "mixed" scenario for single-cell protein production (c20_scp_type) was not working as expected. The corresponding code in 20_processing has been updated. + + +## [4.3.3] - 2021-03-30 + +### added +- **15_food*** added 3 sigmoid food substitution scenarios +- **44_biodiversity** New biodiversity module. The realization bv_btc_mar21 now allows to calculate an area-based biodiversity value across all land types. Switch `c44_price_bv_loss` to implement cost for biodiversity loss. +- **56_ghg_policy** Automatic sets for scenarios +- **60_bioenergy** Automatic sets for scenarios +- **70_livestock*** added 3 sigmoid feed substitution scenarios +- **scripts** added output script for disaggregation to GAINS regions +- **scripts** Automatic sets for 56_ghg_policy and 60_bioenergy +- **scripts** Added pre-commit hook + +### fixed +- **60_bioenergy** Minimal bioenergy demand + + +## [4.3.2] - 2021-03-17 + +### changed +- **12_interest_rate** Interest fader changed to csv +- **15_food** better documentation of parameters over model iterations +- **15_food** added scenario switch for ruminant and dairy replacement by Single-Cell Protein +- **20_processing** added different options for Single-Cell Protein production +- **35_natveg** Fader for HalfEarth protection policy +- **50_nr_soil_budget** added necessary interfaces to 50_nitrogen module +- **70_livestock** added scenario switch for feed replacement (crop and forage) by Single-Cell Protein +- **scripts** Updated AgMIP output scripts. +- **runscripts** adapted to new input data and model version +- **tests** Replaced TravisCI with GithubActions + +### added +- **15_food** Added the option to fade out livestock demand towards a target level in kcal/cap/day. +- **21_trade** Added scalar `s21_trade_bal_damper` and new set `k_trade_excl_timber` +- **29_ageclass** New age-class module +- **32_forestry** added new default realization +- **32_forestry** Simplified routine for plantation establishments. Added plantation area initialization based on MODIS data. Calibration to FAO growing stocks via carbon densities. New switches: `s32_distribution_type `, `s32_hvarea`, `s32_establishment_dynamic`, `s32_establishment_static`, `s32_max_self_suff`. New settings `c32_dev_scen`, `c32_incr_rate`, `c32_incr_rate` +- **35_natveg** Added new default realization +- **35_natveg** Added distribution in secondary forest based on Poulter et al. 2019. Added forest damages due to wildfire and shifting agriculture. Bugfix in forest protection calculations. New switches: `s35_secdf_distribution`, `s35_forest_damage`, `s35_hvarea` +- **35_natveg** Added HalfEarth scenario to protection scenarios +- **51_nitrogen** new module realization rescaled_jan21, which rescales n-related emissions with nitrogen surplus to account for lower emissions with higher NUE +- **52_carbon** Simplified routine for carbon stock calculations in timber plantations and cleanup of unused code. +- **56_ghg_policy** Added new scenario to emission policy +- **73_timber** Additive calibration with FAO data for roundwood demand. New switches: `c73_wood_scen` +- **73_timber** Added new realization `default` (modified version of previous realization) +- **default.cfg** New `forestry` scenario which simulates timber production in MAgPIE +- **scenario.csv** Added three plantation scenarios +- **scaling** Updated scaling across the modules +- **scripts** Updated to `forestry` script with general cleanup for publication. Added `forestry_magpie` script for generic forestry runs. +- **scripts** added output script for disaggregation of land transitions + +### removed +- **32_forestry** Removed previous default realization +- **35_natveg** Removed previous default realization +- **73_timber** Removed previous default realization + +### fixed +- **32_forestry** Bugfixes for "ac_est" and carbon treshold afforestation; removed plantations from "vm_cdr_aff". +- **core** bugfix m_fillmissingyears macro; was running over t before; now running over t_all_ + + +## [4.3.1] - 2020-11-03 + +### added +- **main** Added Dockerfile for running MAgPIE in a container + +### fixed +- **35_natveg** Bugfix "v35_secdforest_expansion" +- **52_carbon** Bugfix "p52_scaling_factor" for climate change runs +- **73_timber** New scenario switch `c73_wood_scen`. + + +## [4.3.0] - 2020-09-15 + +### added +- **38_factor_costs** Added the new "sticky" realization to the factor costs module. The realization "sticky_feb18" favors expansion in cells with preexisting farmland and capital based on capital investment decisions. +- **modules** added endogenous implementation of local biophysical (bph) impacts of afforestation to existing realizations in modules 32_forestry (dynamic_oct19) and 56_ghg_policy (price_jan20). default = off +- **73_timber** Added timber module which brings the ability of producing woody biomass for timber plantations and natural vegetation. Default = off. New switch: `s73_foresight`. New scalars : `s73_timber_prod_cost`, `s73_timber_harvest_cost`,`s73_cost_multiplier`,`s73_free_prod_cost` +- **32_forestry** New realization `dynamic_may20` for forestry land use dynamics. This builds up on previous forestry realization for afforestation. New switches: `s32_fix_plant`, `c32_interest_rate`. New scalars : `s32_plant_share`, `s32_forestry_int_rate`, `s32_investment_cost`, `s52_plantation_threshold`. +- **35_natveg** New realization `dynamic_may20` for natural vegetation land use dynamics. New forest protection scenario. +- **52_carbon** Added interface which is used for calculating additional investment needed in plantations when carbon stocks are lower than a specified threshold. New scalar: `s52_plantation_threshold`. +- **57_maccs** Added MACCs from Harmsen PBL 2019 +- **15_food** Added the option to include calories from alcohol consumption in healthy and sustainable EAT-Lancet diets. +- **scripts** added start script for making timber production runs (forestry.R). + +### changed +- **scripts** updated selection routine for start and output scripts +- **scripts** replaced lucode dependency with newer packages lucode2 and gms +- **32_forestry** include new datasets of the bph effect of afforestation / replaced the bph ageclass switch with a fade-in between ac10 and ac30 in (dynamic_may20) + - **13_tc**, **39_landconversion**, **41_area_equipped_for_irrigation** and **58_peatland**. For the current time step, the optimization costs only include now the annuity of the present investment. magpie4's reportCosts() function was modified to consider these changes. + +### removed + - **scripts** deleted outdated start and output scripts + +### fixed + - **32_forestry** Rotation length calculation based on correct marginals of growth function in timber plantations. Clearer calculations for harvested area for timber production. + - **35_natveg** Clearer calculations for harvested area for timber production. + - **52_carbon** Fix to the Carbon densities received from LPJmL for timber plantations. + + +## [4.2.1] - 2020-05-15 + +### added + - **modules** added option of regional scenario switches in modules 12_interest_rate, 15_food, 42_water_demand, 50_nr_soil_budget, 55_awms, 56_ghg_policy, 60_bioenergy + - **58_peatland** added peatland module. Two realizations: off (=default) and on. + - **80_optimization** added realization for parallel optimization of regions in combination with fixed trade patterns. + - **metadata** added .zenodo.json metadata file for proper metadata information in ZENODO releases + +### changed + - **12_interest_rate** merged the two realizations (glo_jan16 and reg_feb18) into one (select_apr20) with same functionality and add on of option to choose different interest rate scenarios for different regions selected via country switch select_countries12 + - **scripts** streamlined and improved performance of NPI/NDC preprocessing + +### fixed + - **56_ghg_policy and 60_bioenergy** update of GHG prices and 2nd generation bioenergy demand from SSPDB to most recent snapshot + - **NPI/NDC policy calculations** revision of calculation method + + +## [4.2.0] - 2020-04-15 + +This release version is focussed on consistency between the MAgPIE setup and the [REMIND model] and result of a validation exercise of the coupled (REMIND 2.1)-(MAgPIE 4.2) system. + +### added + - **config** Added new socioeconomic scenario (SDP) to scenario_config.csv (which include all switches to define among others the SSP scenarios). For the parametrization of the new SDP (Sustainable Development Pathway) scenario, the list of scenario switches was extended to account for a broad range of sustainability dimensions. + - **10_land** added new land realization landmatrix_dec18 to directly track land transition between land use types + - **15_food** stronger ruminant fade out in India + - **15_food** Added exogenous food substitution scenarios that can be selected via settings in the config-file, defining speed of convergence, scenario targets and transition periods (applied after the food demand model is executed). Among these scenarios are the substitution of livestock products with plant-based food commodities and the substitution of beef or fish with poultry. The food substitution scenarios are based on the model-native, regression-based calculation of food intake and demand. + - **15_food** Added exogenous EAT Lancet diet scenarios: It is now possible to define in the config-file exogenous diet scenarios that replace the regression-based calculation of food intake and demand. Possible settings are the target for total calorie intake (e.g. according to a healthy BMI) and variants of the EAT Lancet diet (e.g. in addition to the flexitarian a vegetarian or vegan variant). + - **15_food** Added exogenous food waste scenarios which can be defined via settings in the config-file, including scenario targets for the ratio between food demand and intake and the year in which full transition to the target should be achieved. + - **30_crop** added crop specific land use initialization pattern (used as interface for other modules) + - **50_nr_soil_budget and 55_awms** Additional inputs for the GoodPractice Scenario. + - **52_carbon** Added new forest growth curve parameters based on Braakhekke et al. 2019. Growth curves are now differentiated between natural vegetation (default) and plantations. + - **59_som** added new realization static_jan19 (new default) including all soil carbon related calculations. Before all carbon pools were updated in the specific land use type modules. This still holds true for the above ground pools (vegetation and litter carbon) + - **.gitattributes** file added to set line ending handling to auto for all text files + - **scaling** added scaling.gms files for several modules to improve optimization (based on gdx::calc_scaling) + - **scripts** added output scripts for global soil carbon maps (SoilMaps.R). + +### changed + - **config** new default ghg emission pricing policy "redd+_nosoil" in c56_emis_policy. Includes all pools included in the previous default "SSP_nosoil", and in addition "forestry". + - **13_tau** lower bound for vm_tau for historical time steps + - **50_nr_soil_budget** atmospheric deposition is now estimated on the cluster-level instead of the region level to improve spatial patterns. + - **56_ghg_policy** updated scenarios in f56_emis_policy: none, all natural (called 'ssp') and all land use change emissions (pure co2) being included in greenhouse gas pricing. ssp and all also featuring additional scenarios excluding soil carbon pricing (marked with '_nosoil' postscript). + - **56_ghg_policy** Several changes regarding afforestation: use of detailed formula for incentive calculation instead of simplified Hotelling formula, 50 year planning horizon (instead of 80 years), phase-in of GHG prices deactivated by default (now done in REMIND), CO2 price reduction factor deactivated by default, introduced buffer reduction factor of 20% for afforestation. + - **59_som** updated cellpool_aug16 realization to use new interfaces from land module on land use type specific land expansion and reduction as well as crop type specific land initialization pattern. Additionally added irrigation as stock change factor sub-type. N fertilizer from soil organic matter decomposition is truncated after threshold to avoid unrealistically high fertilization rates. + - **80_optimization** write extended run information in list file in the case that the final solution is infeasible - **modules** modular structure updated from version 1 to version 2 + - **line endings** changed to unix-style for all text files + +### fixed + - **modules** Fixing of all parameters to SSP2 values until 2020 (switch sm_fix_SSP2) for having identical outcomes in all scenarios (SDP, SSP1-5) until 2020. + - **21_trade** Bugfix kall instead of k in exo realization; Bufix begr/betr trade in default realization; Bugfix sets in free realization + - **32_forestry** NPI/NDC afforestation targets are now counted towards the global afforestation limit, which can be set for specific scenarios via the switch *s32maxaff_area* and constrains the potential for carbon-price induced endogenous afforestation. + - **56_ghg_policy** bugfix full soil carbon loss in default setting, renamed it from ssp to ssp_nosoil, indicating, that soil carbon losses are not priced. + - **56_ghg_policy** bugfix afforestation: vmbtm_cell was a free variable for some sources and pollutants, which could result in GHG cost neutral shifting of age classes to ac0 (e.g. from ac55 to ac0). + - **80_optimization** added fallback routine for CONOPT4 failure (fatal system error) - ### fixed +## [4.1.1] - 2020-03-09 +This version provides the model version used for the publication starved, stuffed and wasteful. It provides a few technical updates compared to the 4.1 release, which include + +### added +- **scripts** a startscript that allows the exchange of model parameters as a sensitivity analysis + +### changed +- **core** allow for flexible calibration period of the model, which allows for uncalibrated runs of the past for validation purposes +- **15_food** Parameters for bodyheight regressions were included explicitly as input parameters +- **config** updated input data of the drivers and food demand regressions + +### fixed +- **15_food** Precision of iteration convergence criterium for magpie-demandmodel-iteration is calculated more precisely, avoiding unnecessary iterations. ## [4.1.0] - 2019-05-02 @@ -43,6 +1226,7 @@ This release version is focussed on consistency between the MAgPIE setup and the - **71_diagg_lvst** adjusted monogastric disaggregation for more flexiblity to avoid infeasibilities with EFPs (see 42_water_demand) - **15_food** correction regarding the convergence measure of the iterative execution of the food demand model and MAgPIE; correction accounting for unusual time step length in body height calculations; body height regression parameters updated + ## [4.0.1] - 2018-10-05 ### fixed @@ -54,7 +1238,44 @@ 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.1.0...develop +[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.13.0...develop +[4.13.0]: https://github.com/magpiemodel/magpie/compare/v4.12.0...v4.13.0 +[4.12.0]: https://github.com/magpiemodel/magpie/compare/v4.11.0...v4.12.0 +[4.11.0]: https://github.com/magpiemodel/magpie/compare/v4.10.1...v4.11.0 +[4.10.1]: https://github.com/magpiemodel/magpie/compare/v4.10.0...v4.10.1 +[4.10.0]: https://github.com/magpiemodel/magpie/compare/v4.9.1...v4.10.0 +[4.9.1]: https://github.com/magpiemodel/magpie/compare/v4.9.0...v4.9.1 +[4.9.0]: https://github.com/magpiemodel/magpie/compare/v4.8.2...v4.9.0 +[4.8.2]: https://github.com/magpiemodel/magpie/compare/v4.8.1...v4.8.2 +[4.8.1]: https://github.com/magpiemodel/magpie/compare/v4.8.0...v4.8.1 +[4.8.0]: https://github.com/magpiemodel/magpie/compare/v4.7.3...v4.8.0 +[4.7.3]: https://github.com/magpiemodel/magpie/compare/v4.7.2...v4.7.3 +[4.7.2]: https://github.com/magpiemodel/magpie/compare/v4.7.1...v4.7.2 +[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 +[4.6.9]: https://github.com/magpiemodel/magpie/compare/v4.6.8...v4.6.9 +[4.6.8]: https://github.com/magpiemodel/magpie/compare/v4.6.7...v4.6.8 +[4.6.7]: https://github.com/magpiemodel/magpie/compare/v4.6.6...v4.6.7 +[4.6.6]: https://github.com/magpiemodel/magpie/compare/v4.6.5...v4.6.6 +[4.6.5]: https://github.com/magpiemodel/magpie/compare/v4.6.4...v4.6.5 +[4.6.4]: https://github.com/magpiemodel/magpie/compare/v4.6.3...v4.6.4 +[4.6.3]: https://github.com/magpiemodel/magpie/compare/v4.6.2...v4.6.3 +[4.6.2]: https://github.com/magpiemodel/magpie/compare/v4.6.1...v4.6.2 +[4.6.1]: https://github.com/magpiemodel/magpie/compare/v4.6.0...v4.6.1 +[4.6.0]: https://github.com/magpiemodel/magpie/compare/v4.5.0...v4.6.0 +[4.5.0]: https://github.com/magpiemodel/magpie/compare/v4.4.0...v4.5.0 +[4.4.0]: https://github.com/magpiemodel/magpie/compare/v4.3.5...v4.4.0 +[4.3.5]: https://github.com/magpiemodel/magpie/compare/v4.3.4...v4.3.5 +[4.3.4]: https://github.com/magpiemodel/magpie/compare/v4.3.3...v4.3.4 +[4.3.3]: https://github.com/magpiemodel/magpie/compare/v4.3.2...v4.3.3 +[4.3.2]: https://github.com/magpiemodel/magpie/compare/v4.3.1...v4.3.2 +[4.3.1]: https://github.com/magpiemodel/magpie/compare/v4.3.0...v4.3.1 +[4.3.0]: https://github.com/magpiemodel/magpie/compare/v4.2.1...v4.3.0 +[4.2.1]: https://github.com/magpiemodel/magpie/compare/v4.2.0...v4.2.1 +[4.2.0]: https://github.com/magpiemodel/magpie/compare/v4.1.1...v4.2.0 +[4.1.1]: https://github.com/magpiemodel/magpie/compare/v4.1.0...v4.1.1 [4.1.0]: https://github.com/magpiemodel/magpie/compare/v4.0.1...v4.1.0 [4.0.1]: https://github.com/magpiemodel/magpie/compare/v4.0...v4.0.1 [4.0.0]: https://github.com/magpiemodel/magpie/releases/tag/v4.0 diff --git a/CITATION.cff b/CITATION.cff index e1c57fecc1..b568ec8442 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,5 +1,6 @@ cff-version: 1.0.3 message: If you use this model, please cite it as below. +type: software authors: - family-names: Dietrich given-names: Jan Philipp @@ -9,6 +10,7 @@ authors: - family-names: Bodirsky given-names: Benjamin Leon + orcid: https://orcid.org/0000-0002-8242-6712 affiliation: "Potsdam Institute for Climate Impact Research" email: bodirsky@pik-potsdam.de @@ -19,6 +21,7 @@ authors: - family-names: Humpenöder given-names: Florian + orcid: https://orcid.org/0000-0003-2927-9407 affiliation: "Potsdam Institute for Climate Impact Research" email: humpenoeder@pik-potsdam.de @@ -43,14 +46,53 @@ authors: - family-names: Mishra given-names: Abhijeet + orcid: https://orcid.org/0000-0002-8287-9922 affiliation: "Potsdam Institute for Climate Impact Research" email: mishra@pik-potsdam.de + - family-names: Beier + given-names: Felicitas Dorothea + affiliation: "Potsdam Institute for Climate Impact Research" + email: beier@pik-potsdam.de + + - family-names: Molina Bacca + given-names: Edna Johanna + orcid: https://orcid.org/0000-0001-6530-1849 + affiliation: "Potsdam Institute for Climate Impact Research" + email: mbacca@pik-potsdam.de + + - family-names: von Jeetze + given-names: Patrick + orcid: https://orcid.org/0000-0002-1197-4412 + affiliation: "Potsdam Institute for Climate Impact Research" + email: vjeetze@pik-potsdam.de + + - family-names: Windisch + given-names: Michael + affiliation: "Potsdam Institute for Climate Impact Research" + email: windisch@pik-potsdam.de + + - family-names: Crawford + given-names: Michael Scott + orcid: https://orcid.org/0000-0003-1282-400X + affiliation: "Potsdam Institute for Climate Impact Research" + email: crawford@pik-potsdam.de + + - family-names: Leip + given-names: Debbora + affiliation: "Potsdam Institute for Climate Impact Research" + email: leip@pik-potsdam.de + - family-names: Klein given-names: David affiliation: "Potsdam Institute for Climate Impact Research" email: dklein@pik-potsdam.de + - family-names: Singh + given-names: Vartika + affiliation: "Potsdam Institute for Climate Impact Research" + email: vasingh@pik-potsdam.de + - family-names: Ambrósio given-names: Geanderson affiliation: "Potsdam Institute for Climate Impact Research" @@ -65,25 +107,69 @@ authors: given-names: Anne affiliation: "Potsdam Institute for Climate Impact Research" + - family-names: Sauer + given-names: Pascal + orcid: https://orcid.org/0000-0002-6856-8239 + affiliation: "Potsdam Institute for Climate Impact Research" + email: pascal.sauer@pik-potsdam.de + + - 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: Steinhauser + given-names: Jan + orcid: https://orcid.org/0000-0002-5989-6855 + affiliation: "Potsdam Institute for Climate Impact Research" + email: janstein@pik-potsdam.de + + - family-names: Hötten + given-names: David + affiliation: "Potsdam Institute for Climate Impact Research" + email: davidho@pik-potsdam.de + + - family-names: Schröter + given-names: Georg + affiliation: "Potsdam Institute for Climate Impact Research" + email: georgsc@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" email: lotze-campen@pik-potsdam.de - family-names: Popp given-names: Alexander + orcid: https://orcid.org/0000-0001-9500-1986 affiliation: "Potsdam Institute for Climate Impact Research" email: popp@pik-potsdam.de title: MAgPIE - An Open Source land-use modeling framework -version: 4.2dev -date-released: 2019-05-02 +abstract: The *Model of Agricultural Production and its Impact on the Environment* (MAgPIE) + is a modular open source framework for modeling global land-systems, which is + coupled to the grid-based dynamic vegetation model LPJmL, with a spatial resolution + of 0.5degx0.5deg. It takes regional economic conditions such as demand for agricultural + commodities, technological development and production costs as well as spatially + explicit data on potential crop yields, land and water constraints (from LPJmL) into + account. Based on these, the model derives specific land use patterns, yields and + total costs of agricultural production for each grid cell. The objective function of + the land use model is to minimize total cost of production for a given amount of + regional food and bioenergy demand. Regional food energy demand is defined for an + exogenously given population in 10 food energy categories, based on regional diets. + Future trends in food demand are derived from a cross-country regression analysis, + based on future scenarios on GDP and population growth. +version: 4.13.0dev +date-released: 2025-10-23 repository-code: https://github.com/magpiemodel/magpie keywords: - landuse - modeling + - model - nlp - partial equilibrium doi: 10.5281/zenodo.1418752 license: AGPL-3.0-or-later -url: https://www.pik-potsdam.de/research/projects/activities/land-use-modelling/magpie +url: https://github.com/magpiemodel/magpie diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000000..71551d1326 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,47 @@ +Package: magpiemodel +Description: Refer to README.md for a description of the MAgPIE model. + This file only lists dependencies and is called DESCRIPTION for + technical reasons. +Imports: + callr, + citation, + curl, + data.table, + dplyr, + gdx2, + ggplot2, + ggrepel, + gms (>= 0.24.0), + here, + iamc, + lucode2 (>= 0.51.1), + luplot, + luscale (>= 2.27.9), + lusweave, + m4fsdp, + madrat, + magclass (>= 6.14.0), + magpie4 (>= 2.42.3), + MagpieNCGains, + magpiesets (>= 0.46.1), + mip, + mrcommons, + patchwork, + piamenv (>= 0.5.5), + piamInterfaces (>= 0.53.4), + piamutils, + quitte, + raster, + remulator, + renv, + stringr, + txtplot, + withr +Suggests: + goxygen, + languageserver, + mrdownscale (>= 0.28.0), + qgraph, + shinyresults, + XML +Encoding: UTF-8 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..18c6a289d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +.PHONY: help docs update-renv update-renv-all archive-renv restore-renv check check-fix start output +.DEFAULT_GOAL := help + +# extracts the help text and formats it nicely +HELP_PARSING = 'm <- readLines("Makefile");\ + m <- grep("\#\#", m, value=TRUE);\ + command <- sub("^([^ ]*) *\#\#(.*)", "\\1", m);\ + help <- sub("^([^ ]*) *\#\#(.*)", "\\2", m);\ + cat(sprintf("%-18s%s", command, help), sep="\n")' + +help: ## Show this help. + @Rscript -e $(HELP_PARSING) + +docs: ## Generate/update model HTML documentation in the doc/ folder. + Rscript -e 'goxygen::goxygen(); warnings()' + @echo -e '\nOpen\ndoc/html/index.htm\nin your browser to view the generated documentation.' + +update-renv: ## Upgrade all pik-piam packages in your renv to the respective + ## latest release and write renv.lock to archive. + Rscript -e 'piamenv::updateRenv()' + +update-renv-all: ## Upgrade all packages (including CRAN packages) in your renv + ## to the respective latest release and write renv.lock to archive. + Rscript -e 'renv::update(); piamenv::archiveRenv()' + +archive-renv: ## Write renv.lock to archive. + Rscript -e 'piamenv::archiveRenv()' + +restore-renv: ## Restore renv to the state described in interactively + ## selected renv.lock from the archive or a run folder. + Rscript -e 'piamenv::restoreRenv()' + +check: ## Check if the GAMS code follows the coding etiquette + ## using gms::codeCheck. + Rscript -e 'invisible(gms::codeCheck(strict = TRUE))' + +check-fix: ## Check if the GAMS code follows the coding etiquette + ## and offer fixing any problems directly if possible + ## using gms::codeCheck. + Rscript -e 'invisible(gms::codeCheck(strict = TRUE, interactive = TRUE))' + +start: ## Start a MAgPIE run. + Rscript start.R + +output: ## Run an output script. + Rscript output.R diff --git a/README.md b/README.md index 7d86622b95..74e2e50319 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,33 @@ # MAgPIE - Modular open source framework for modeling global land-systems - +[![DOI](https://zenodo.org/badge/135430060.svg)](https://zenodo.org/badge/latestdoi/135430060) +[![R build status](https://github.com/magpiemodel/magpie/workflows/check/badge.svg)](https://github.com/magpiemodel/magpie/actions) ## WHAT IS MAGPIE? The *Model of Agricultural Production and its Impact on the Environment* (MAgPIE) -is a modular open source framework for modeling global land-systems, which is -coupled to the grid-based dynamic vegetation model LPJmL, with a spatial resolution -of 0.5°x0.5°. It takes regional economic conditions such as demand for agricultural -commodities, technological development and production costs as well as spatially -explicit data on potential crop yields, land and water constraints (from LPJmL) into -account. Based on these, the model derives specific land use patterns, yields and -total costs of agricultural production for each grid cell. The objective function of +is a modular open-source framework for modeling global land-systems, which +explicitly accounts for both agriculture and forestry. It is coupled to the +grid-based dynamic vegetation model LPJmL, with a spatial resolution of 0.5°x0.5°. +MAgPIE takes regional economic conditions such as demand for agricultural commodities +and timber products, technological development, and production costs into account, +as well as spatially explicit data on potential crop yields, forest growth, +and land and water constraints (from LPJmL). Based on these, the model derives +specific land use patterns, crop yields, timber yields, and total costs of +agricultural and forestry production for each grid cell. The objective function of the land use model is to minimize total cost of production for a given amount of -regional food and bioenergy demand. Regional food energy demand is defined for an -exogenously given population in 10 food energy categories, based on regional diets. -Future trends in food demand are derived from a cross-country regression analysis, +regional food, bioenergy, and timber demand. Regional food energy demand is defined +for an exogenously given population in 10 food energy categories, based on regional +diets. Future trends in food demand are derived from a cross-country regression analysis, based on future scenarios on GDP and population growth. +https://www.pik-potsdam.de/research/projects/activities/land-use-modelling/magpie + ## DOCUMENTATION 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.1 can be found at -https://rse.pik-potsdam.de/doc/magpie/4.1/ +The model documentation for version 4.13.0 can be found at +https://rse.pik-potsdam.de/doc/magpie/4.13.0/ A most recent version of the documentation can also be extracted from the model source code via the R package goxygen @@ -30,14 +35,17 @@ model source code via the R package goxygen package and run the main function (goxygen) in the main folder of the model. The resulting documentation can be found in the folder "doc". -Please pay attentions to the MAgPIE Coding Etiquette when you modify the code. -The Coding Etiquette you find at -https://redmine.pik-potsdam.de/projects/pik-model-operations/wiki/Coding_Etiquette -The Coding Etiquette explains also the used name conventions and other +Please find a set of tutorials here https://magpiemodel.github.io/tutorials. +This guide will give you a brief technical introduction in how to install, run and use the model +and how to analyse the model output. + +Please pay attention to the MAgPIE Coding Etiquette when you modify the code. +The Coding Etiquette you find at the beginning of the documentation mentioned above. +The Coding Etiquette explains also the naming conventions and other structural characteristics. ## COPYRIGHT -Copyright 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +Copyright 2008-2025 Potsdam Institute for Climate Impact Research (PIK) ## LICENSE This program is free software: you can redistribute it and/or modify @@ -59,79 +67,87 @@ When using a modified version of **MAgPIE** which is not identical to versions in the official main repository at https://github.com/magpiemodel add a suffix to the name to allow distinguishing versions (format **MAgPIE-suffix**). -## SYSTEM REQUIREMENTS +## HARDWARE REQUIREMENTS The model is quite resource heavy and works best on machines with high CPU clock -and memory. Recommended is a machine with Windows, MacOS or Linux, with at least -16GB of memory and a Core i7 CPU or similar. +and memory. Recommended is a machine with at least 16GB of memory and a Core i7 CPU or similar. ## HOW TO INSTALL -MAgPIE requires *GAMS* (https://www.gams.com/) including licenses for the -solvers *CONOPT* and (optionally) *CPLEX* for its core calculations. As the model -benefits significantly of recent improvements in *GAMS* and *CONOPT4* it is -recommended to work with the most recent versions of both. -Please make sure that the GAMS installation path is added to the PATH variable -of the system. - -In addition *R* (https://www.r-project.org/) is required for pre- and -postprocessing and run management (needs to be added to the PATH variable -as well). - -For R some packages are required to run MAgPIE. All except of one (`gdxrrw`) are -either distributed via the offical R CRAN or via a separate repository hosted at -PIK (PIK-CRAN). Before proceeding PIK-CRAN should be added to the list of -available repositories via: -``` -options(repos = c(CRAN = "@CRAN@", pik = "https://rse.pik-potsdam.de/r/packages")) -``` - -The `gdxrrw` package has to be downloaded directly from GAMS via -``` -download.file("https://support.gams.com/_media/gdxrrw:gdxrrw_1.0.2.zip", - "gdxrrw_1.0.2.zip") -install.packages(“reshape2”) -install.packages("gdxrrw_1.0.2.zip",repos = NULL) -``` -In some cases it can happen that `gdxrrw` does not return an error message during -installation but also did not install properly. To verify a successful -installation try to load the package via `library(gdxrrw)`. - --------------------------------------------------------------------------------- - -If loading of the package fails you need to install the package from source. -Under Windows this requires to install Rtools -(https://cran.r-project.org/bin/windows/Rtools/) and to add it to the PATH -variable. After that you can run the following lines of code: - +Commands formatted as `code` should generally be run in a terminal (PowerShell on Windows). + +### List of Requirements +- license for gams incl. CONOPT solver +- gams >= 50.1.0 +- git >= 2.23 +- R >= 4.3 (+ matching Rtools on Windows) +- pandoc >= 2.14.2 +- TeX >= 3.14159265 + +### OS specific setup +Choose your operating system and follow the instructions there. You can also +install requirements differently (e.g. using only installers on Windows), in +the end it is only important that all requirements are installed in a suitable +version and added to the PATH environment variable, so MAgPIE can use them. + +#### Ubuntu +1. make sure you have a gams license incl. the CONOPT solver +1. [install gams](https://www.gams.com/46/docs/UG_UNIX_INSTALL.html) +1. install git, R, and pandoc with `sudo apt install git r-base pandoc` +1. install TinyTeX with `Rscript -e 'install.packages("tinytex"); tinytex::install_tinytex()'` + +In case R package installations fail during compilation, install the following system packages: ``` -download.file("https://support.gams.com/_media/gdxrrw:gdxrrw_1.0.2.tar.gz", - "gdxrrw_1.0.2.tar.gz") -install.packages("gdxrrw_1.0.2.tar.gz",repos = NULL, type="source") +sudo apt install build-essential cmake gdal-bin libcurl4-gnutls-dev libcurl4-openssl-dev libfontconfig1 libfreetype-dev libfribidi-dev libgdal-dev libgit2-dev libglpk-dev libharfbuzz-dev libjpeg-dev libnetcdf-dev libpng-dev libpoppler-cpp-dev libssl-dev libtiff5-dev libudunits2-dev libxml2-dev pari-gp qpdf ``` - --------------------------------------------------------------------------------- - - -After that all remaining packages can be installed via `install.packages` - +This list is highly system specific and most likely incomplete. Pay close attention to error messages, usually they state which system package needs to be installed. + +#### macOS +We recommend to NOT have an active conda environment (if you're unsure what this means you likely don't have conda) when working with magpie (`conda deactivate`). We recommend installing system packages via [brew](https://brew.sh/). +Install R from https://cran.r-project.org/bin/macosx/ +Choose the right version: arm for Apple Silicon (M1, M2, …), x86_64 for older Intel-based Macs. +Install gfortran from https://cran.r-project.org/bin/macosx/tools/ +1. make sure you have a gams license incl. the CONOPT solver +1. [install gams](https://www.gams.com/46/docs/UG_MAC_INSTALL.html) +1. install git and pandoc with `brew install git pandoc` +1. install TinyTeX with `Rscript -e 'install.packages("tinytex",repos="https://cloud.r-project.org"); tinytex::install_tinytex()'` + +Usually macOS users can download precompiled binary R packages, but in case R package installations fail during compilation, install the following system packages: ``` -pkgs <- c("ggplot2", - "curl", - "gdx", - "magclass", - "madrat", - "mip", - "lucode", - "magpie4", - "magpiesets", - "lusweave", - "luscale", - "goxygen", - "luplot") -install.packages(pkgs) +brew install abseil cmake fribidi gdal harfbuzz libgit2 libpng libtiff libxml2 pkg-config ``` -For post-processing model outputs *Latex* is required -(https://www.latex-project.org/get/). To be seen by the model it also needs to -added to the PATH variable of your system. +This list is highly system specific and most likely incomplete. Pay close attention to error messages, usually they state which system package needs to be installed. + +#### Windows +Most of the installation steps require administrator rights. +1. make sure you have a gams license incl. the CONOPT solver +1. [install gams](https://www.gams.com/46/docs/UG_WIN_INSTALL.html) +1. [download .msi pandoc file](https://github.com/jgm/pandoc/releases/latest) and run installer (`choco install pandoc` did not work in testing) +1. [install chocolatey](https://chocolatey.org/install) +1. install git, rig (R installer), and tinytex with `choco install -y git rig tinytex` +1. restart terminal +1. install R and Rtools with `rig add release; rig add rtools` + +### check setup is complete +- restart terminal (now without administrator privileges) +- `gams` should print many lines including "The installed license is valid." +- `git --version` +- `Rscript --version` +- `pandoc --version` +- `tex --version` + +If any of these are not found: Find the path to that executable +(gams/git/Rscript/pandoc/tex, on Windows ending in '.exe') and add it to your account's +PATH environment variable. Search for a tutorial online if you are unsure how to do that, +or take a look at the detailed Windows instructions and troubleshooting below. + +### download and run MAgPIE +1. download MAgPIE with `git clone https://github.com/magpiemodel/magpie.git` +1. go into the MAgPIE folder `cd magpie` +1. start a MAgPIE run with `Rscript start.R`, first time: installs all required R packages (takes a while) +1. choose "1" for a default run +1. then select "1" for direct execution + +### troubleshooting +Please check [this discussion](https://github.com/magpiemodel/magpie/discussions/650) for known problems and solutions and to report new problems you encounter while setting up MAgPIE. ## HOW TO CONFIGURE Model run settings are set in `config/default.cfg` (or another config file of @@ -175,7 +191,7 @@ following requirements: For other dependencies comparable measures should apply. When a dependency is added this dependency should be added to the *HOW TO INSTALL* section in the -README file of the model framework (mentioning the depencendy and explaining +README file of the model framework (mentioning the dependency and explaining how it can be installed). If not all requirements can be fulfilled by the new dependency this case should be discussed with the model maintainer (magpie@pik-potsdam.de) to find a good solution for it. @@ -200,19 +216,27 @@ In case that these recommendations can not be followed we would be happy if you could discuss that issue with the MAgPIE development team (magpie@pik-potsdam.de). +## MODEL OUTPUT + +By default the results of a model run are written to an individual results folder within the "output/" folder of the model. The two most important output files are the fulldata.gdx and the report.mif. The fulldata.gdx is the technical output of the GAMS optimization and contains all quantities that were used during the optimization in unchanged form. The mif-file is a csv file of a specific format and is synthetized from the fulldata.gdx by post-processing scripts. It can be read in any text editor or spreadsheet program and is well suited for a quick look at the results and for further analysis. + ## CONTACT magpie@pik-potsdam.de ## KNOWN BUGS ## TROUBLESHOOTING -Please contact magpie@pik-potsdam.de +Please contact magpie@pik-potsdam.de if you're having troubles installing or running a MAgPIE release version. -## CITATION -See file CITATION.cff or the documentation of the model for information how -to cite the model. +### Common issues with installing MAgPIE under Windows +- To modify the `Path` environment variable, you can use the Windows search by pressing the Windows key, start typing "environment" and select the option "Edit environment variables for your account". Edit the `Path` variable by adding the paths to executables which aren't yet found when testing them in the terminal (via the `New` button). You can also display the currently used path variable in the terminal via `echo %PATH%` (regular terminal) and `$env:PATH`(PowerShell) to check what is already included. +- Check if `rtools` was installed successfully: Open an `R` session from a terminal, and run `install.packages("pkgbuild")` followed by `pkgbuild::has_rtools()`. This should report `TRUE`. +- Neither downloading nor running MAgPIE requires administrator privileges, and you'll likely run into issues when trying to run MAgPIE in a folder where `git clone` has been run from an administrator terminal. If you did this by accident, delete the MAgPIE folder and redo the `git clone` from a terminal without administrator privileges. +- Before running `git clone` in the terminal, make sure that you're in a folder where you have write access and not in a Windows system path. If you're using Windows 11, you can access the terminal by right-clicking and starting a terminal from Windows explorer after navigating to the location where you want to download MAgPIE into. +- If you're using PowerShell, starting an interactive R session with `R` doesn't work, and you need to type `R.exe` (or `R.bat` if `R.exe` isn't found) instead. The reason behind this is that `r` is a reserved shortcut for repeating the previous command, which is why you'll be getting a cryptic `Invoke-History: Cannot locate most recent history.` error message when trying to start R in a fresh PowerShell session. -[![DOI](https://zenodo.org/badge/135430060.svg)](https://zenodo.org/badge/latestdoi/135430060) +## CITATION +See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.13.0/#how-to-cite) in the model documentation for information how to cite the model. ## AUTHORS See list of authors in CITATION.cff diff --git a/config/default.cfg b/config/default.cfg index c5311a6cb6..e6be4335b3 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -17,13 +17,20 @@ cfg <- list() cfg$title <- "default" # path to the submodel to be used relative to main model folder -cfg$model <- "main.gms" #def = "main.gms" +cfg$model <- "main.gms" # def = "main.gms" #### input settings #### # which input data sets should be used? +cfg$input <- c(regional = "rev4.128_h12_magpie.tgz", + cellular = "rev4.128_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz", + validation = "rev4.128_h12_92e02314_validation.tgz", + additional = "additional_data_rev4.63.tgz", + calibration = "calibration_H12_FAO_18Sep25.tgz") -cfg$input <- c("magpie4.1_default_apr19.tgz") +# NOTE: It is recommended to recalibrate the model when changing cellular input data +# as well as for any other setting that would affect initial values in the model, +# e.g. changes in costs structure, NPI policies, etc. #a list of repositories (please pay attention to the list format!) in which the #files should be searched for. Files will be searched in all repositories until @@ -41,6 +48,7 @@ cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public"= getOption("magpie_repos")) + # Should input data be downloaded from source even if cfg$input did not change? cfg$force_download <- FALSE @@ -48,26 +56,68 @@ cfg$force_download <- FALSE cfg$force_replace <- FALSE # Settings for the yield calibration +# For this yield calibration (that uses results from a special MAgPIE calibration run +# triggered by the recalibrate switch) to be activated the switch s14_use_yield_calib needs +# to be turned on. (Default is off) +# This switch should only be activated for penalty_apr22 crop realization. +# For other realizations, it is recommended not to use this yield calibration. +# +# Switch to turn on/off recalibration of yields. # * (TRUE): Yield calibration will be performed # * (ifneeded): Yield calibration will only be executed if input data is # * downloaded from repository # * (FALSE): Yield calibration will not be performed -cfg$recalibrate <- "ifneeded" # def = "ifneeded" +cfg$recalibrate <- FALSE # def = FALSE # 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 -# factor determining how much the new calibration factor influences the result -# (0-1) -cfg$damping_factor <- 0.98 # def= 0.98 +# Factor determining how much the divergence infuences the new +# calibration factor in each calibration iteration (0-1) +cfg$damping_factor <- 0.96 # def= 0.96 # switch on/of calibration of cropland (pasture will be left untouched) cfg$calib_cropland <- TRUE # def= TRUE - +# set upper limit for cropland calibration factor +cfg$crop_calib_max <- 1.5 # def= 1.5 +# Selection type of calibration factors. +# If FALSE, calibration factors from the last iteration are used. +# If TRUE, calibration factors from the iteration with the lowest divergence are used. +cfg$best_calib <- TRUE # def = TRUE + +# Settings for land conversion cost calibration (cropland) +# The calibration routine derives a time-series of regional calibration factors for +# costs of cropland expansion and rewards for cropland reduction, +# with the goal to match historical regional cropland in the period 1995-2015. +# * (TRUE): Land conversion cost calibration will be performed +# * (ifneeded): Land conversion cost calibration will only be executed if the input file "f39_calib.csv" is missing +# * (FALSE): Land conversion cost calibration will not be performed +cfg$recalibrate_landconversion_cost <- "ifneeded" #def "ifneeded" +# Up to which accuracy shall be recalibrated? +cfg$calib_accuracy_landconversion_cost <- 0.01 # def = 0.01 +# What is the maximum number of iterations if the precision goal is not reached? +cfg$calib_maxiter_landconversion_cost <- 20 # def = 20 +# Restart from existing calibration factors (TRUE or FALSE) +cfg$restart_landconversion_cost <- FALSE # def = FALSE +# Number of lowpass filter iterations applied on calibration factors +# for time steps 1995-2015 +cfg$lowpass_filter_landconversion_cost <- 0 # def= 0 +# Set upper limit for cropland calibration factor +cfg$cost_calib_max_landconversion_cost <- 2.5 # def= 2.5 +# Set lower limit for cropland calibration factor +cfg$cost_calib_min_landconversion_cost <- 0.2 # def= 0.2 +# Selection type of calibration factors. +# If FALSE, calibration factors from the last iteration are used. +# If TRUE, calibration factors from the iteration with the lowest divergence are used. +cfg$best_calib_landconversion_cost <- FALSE # def = FALSE +# Target data set that will be used for cropland calibration at regional level +# * "MAgPIEown": same data set as used for initialization of cropland +# * "FAO": Data from FAOSTAT on cropland area +cfg$cost_calib_hist_data <- "FAO" # def = "FAO" # Settings for NPI/NDC recalculation # * (TRUE): NPI/NDC recalculation will be performed # * (ifneeded): NPI/NDC recalculation will only be executed if current input files are zero -# * and policy switches (p32_aff_pol, p35_ad_pol, p35_emis_pol) are set to "npi" or "ndc". +# * and policy switches (c32_aff_pol, c35_ad_pol) are set to "npi" or "ndc". # * If policy switches are set to "none" (default) NPI/NDC recalculation will not be performed # * (FALSE): NPI/NDC recalculation will not be performed cfg$recalc_npi_ndc <- "ifneeded" # def = ifneeded @@ -82,8 +132,11 @@ cfg$gms <- list() # Set number of time steps (1-16) or type "less_TS" for remind time steps cfg$gms$c_timesteps <- "coup2100" +# historic time steps +cfg$gms$c_past <- "till_2015" + # use of gdx files -cfg$gms$s_use_gdx <- 2 # def = 2 +cfg$gms$s_use_gdx <- 0 # def = 0 #* 0: gdx will not be loaded #* 1: gdx is loaded in the first time step #* 2: gdx is loaded in all time steps @@ -92,84 +145,462 @@ cfg$gms$s_use_gdx <- 2 # def = 2 # *** MODULES # ***--------------------------------------------------------------------------- +#### Useful shortcuts #### +# Vector of all iso countries (used for regional policy implementations) +all_iso_countries <- "ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE" + +# * Based on https://tntcat.iiasa.ac.at/SspDb/dsd?Action=htmlpage&page=10#regiondefs +oecd90andEU <- "ALB,AUS,AUT,BEL,BIH,BGR,CAN,CYP,CZE,DNK,EST,FIN,FRA, + DEU,GRC,HUN,HRV,ISL,IRL,ITA,JPN,LUX,LVA,LTU,MLT,MNE, + NLD,NOR,NZL,POL,PRT,ROU,SRB,SVK,SVN,ESP,SWE,CHE,MKD,TUR, + GBR,USA" + +isoCountriesEUR <- "ALB,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST,FIN,FRA,FRO, + GBR,GGY,GIB,GRC,HRV,HUN,IMN,IRL,ITA,JEY,LTU,LUX,LVA,MLT, + NLD,POL,PRT,ROU,SVK,SVN,SWE" + + +isoCountriesLowMiddleIncome <- + "ABW,AFG,AGO,AIA,ALA,AND,ARE,ARG,ARM,ASM,ATA, + ATF,ATG,AZE,BDI,BEN,BES,BFA,BGD,BHR,BHS,BLM, + BLR,BLZ,BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF, + CCK,CHN,CHL,CIV,CMR,COD,COG,COK,COL,COM,CPV, + CRI,CUB,CUW,CXR,CYM,DJI,DMA,DOM,DZA,ECU,EGY, + ERI,ESH,ETH,FJI,FLK,FRO,FSM,GAB,GEO,GGY,GHA, + GIB,GIN,GLP,GMB,GNB,GNQ,GRD,GRL,GTM,GUF,GUM, + GUY,HKG,HMD,HND,HTI,IDN,IMN,IND,IOT,IRN,IRQ, + ISR,JAM,JEY,JOR,KAZ,KEN,KGZ,KHM,KIR,KNA,KOR, + KWT,LAO,LBN,LBR,LBY,LCA,LIE,LKA,LSO,MAC,MAF, + MAR,MCO,MDA,MDG,MDV,MEX,MHL,MLI,MMR,MNG,MNP, + MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM,NCL,NER, + NFK,NGA,NIC,NIU,NPL,NRU,OMN,PAK,PAN,PCN,PER, + PHL,PLW,PNG,PRI,PRK,PRY,PSE,PYF,QAT,REU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE,SLV, + SMR,SOM,SPM,SSD,STP,SUR,SWZ,SXM,SYC,SYR,TCA, + TCD,TGO,THA,TJK,TKL,TKM,TLS,TON,TTO,TUN,TUV, + TWN,TZA,UGA,UKR,UMI,URY,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE" + # ***--------------------- 09_drivers ---------------------------------------- # * (aug17): default drivers cfg$gms$drivers <- "aug17" # def = aug17 cfg$gms$c09_pop_scenario <- "SSP2" # def = SSP2 cfg$gms$c09_gdp_scenario <- "SSP2" # def = SSP2 -# * options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" -# * SRES: "A1", "A2", "B1", "B2" +# * options: SSP: "SSP1", "SSP2", "SSP2EU", "SSP3", "SSP4", "SSP5" +# * SDP: "SDP", "SDP_EI", "SDP_MC", "SDP_RC" +# * Note: SSP2EU a European Commission population/income scenario for +# * Ariadne project. SDP is same as SSP1 income, while SDP_EI, SDP_RC, SDP_MC +# * see different GDP trajectories as described in SHAPE project. -# ***--------------------- 10_land ---------------------------------------- -# * (feb15): default land realization -cfg$gms$land <- "feb15" # def = feb15 +# * Physical activity level scenario: +cfg$gms$c09_pal_scenario <- "SSP2" # def = SSP2 +# * options: SSP: "SSP1", "SSP2", "SSP2EU", "SSP3", "SSP4", "SSP5" +# * SDP: "SDP", "SDP_EI", "SDP_MC", "SDP_RC" + +# Year until which all parameters are fixed to SSP2 values +cfg$gms$sm_fix_SSP2 <- 2025 +# Year until which all parameters affected by climate change are fixed to historical values +cfg$gms$sm_fix_cc <- 2025 + +# ***--------------------- 10_land ---------------------------------------- +# * (landmatrix_dec18): includes a land transition matrix +cfg$gms$land <- "landmatrix_dec18" # def = landmatrix_dec18 # ***--------------------- 11_costs ------ -------------------------------- # * (default): default cost realization cfg$gms$costs <- "default" # def = default # ***--------------------- 12_interest_rate --------------------------------- -# * (glo_jan16): global interest rates - annuity calculated with macro m_annuity -# * (reg_feb18): regional interest rates, dependent on development state - -cfg$gms$interest_rate <- "reg_feb18" # def = reg_feb18 +# * (select_apr20): regional interest rates dependent on development state +cfg$gms$interest_rate <- "select_apr20" # def = select_apr20 + +# * Interest rate scenario: +# * Options: coupling (exogenous interest rate) +# * gdp_dependent (regional interest rate dependent on development state) +# * Note: Currently, coupling is included as an option of an exogenous interest +# * rate scenario. It is currently not part of coupled runs with REMIND. +# * Note: In the gdp_dependent scenario, the selected interest rate fully takes +# * effect in 2050. It slowly starts fading in by 2025. +cfg$gms$c12_interest_rate <- "gdp_dependent" # def = "gdp_dependent" + +# * Interest rate coefficients: +# * The coefficients determine the regionally specific interest rate. They do +# * not represent the value of the interest rate. +# * The s12_interest_lic coefficient determines the intercept for future interest +# * rate determination. It represents the interest rate in low income countries. +cfg$gms$s12_interest_lic <- "0.1" # def = 0.1 +# * The s12_interest_hic determines the speed of interest rate adjustment for +# * future interest rates. It represents the interest rate in high income countries. +cfg$gms$s12_interest_hic <- "0.04" # def = 0.04 +# * Analog logic applies to historic interest rate coefficients +cfg$gms$s12_hist_interest_lic <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic <- "0.04" # def = 0.04 +# * Note: It is also possible to choose a global interest rate by setting the +# * upper (s12_interest_lic) and the lower (s12_interest_hic) bound equal +# * This was formerly used for SSP runs and was set to SSP1, SSP5: 0.07 (hist), +# * 0.04 (future), SSP2: 0.07 (hist, future), SSP3: 0.07 (hist), 0.1 (future), +# * SSP4: s12_interest_lic=0.1, s12_interest_hic=0.04, s12_hist_interest_lic=0.07, +# * s12_hist_interest_hic=0.07 + +# * Regional interest rate policy scenario switch +# * Options: list of iso-codes of countries where above selected coefficients +# * should be in effect. +# * In all other countries, alternative coefficients (s12_interest_lic_noselect, s12_interest_hic_noselect, +# * s12_hist_interest_lic_noselect, s12_hist_interest_hic_noselect) that can be selected below +# * are in effect. +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$select_countries12 <- all_iso_countries # def = all_iso_countries + +# * Interest rate coefficients for non-selected countries: +cfg$gms$s12_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_interest_hic_noselect <- "0.04" # def = 0.04 +cfg$gms$s12_hist_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic_noselect <- "0.04" # def = 0.04 -# * interest rate scenario: low, medium, high or mixed -# * This only has effects on glo_jan16 realization, but for the coupling in both realizations -cfg$gms$c12_interest_rate <- "medium" # def = "medium" # ***--------------------- 13_tc ----------------------------------------- -# * (endo_jun18): endogenous technological change with full cost accounting and -# * stepwise updated crop area information -cfg$gms$tc <- "endo_jun18" # def = endo_jun18 +# * (endo_jan22): endogenous technological change with full cost accounting and +# * stepwise updated crop and managed pastures area information +# * (exo): exogenous technological change (removes non-linearities from the model); +# * requires an existing model run with endo tc for generating the input file +# * f13_tau_scenario.csv +cfg$gms$tc <- "endo_jan22" # def = endo_jan22 + +# * tc cost scenario crops: low, medium or high +cfg$gms$c13_tccost <- "medium" # def = medium + +# * ignore historical tau (1) or use it as lower bound (0) +cfg$gms$s13_ignore_tau_historical <- 1 # def = 1 + +# * Maximum regional tech cost expressed as share of regional GDP +# * A meaningful value would be 0.002. However, this bound causes infeasibilities in some cases. +# * Therefore, this bound is not used in the current model version. +cfg$gms$s13_max_gdp_shr <- Inf # def = Inf + +# * Options for tau in conservation priority areas +# * (1) tau in conservation priority areas differs from regular cropland areas +# * (0) tau in conservation priority areas is the same as in regular cropland areas +cfg$gms$c13_croparea_consv <- 0 # def = 0 + +# * Share of cropland in a cluster that is subject to conservation +# * management with a different tau dynamic. A share of 0.15 e.g. +# * means that 15 % of the cropland area in a cluster is subject to a +# * different tau dynamic. If c13_croparea_consv is set to 1 and +# * s13_croparea_consv_shr set to 0, only cropland areas in protected +# * areas with mixed land use that include cropland are considered. +cfg$gms$s13_croparea_consv_shr <- 0 # def = 0 +cfg$gms$s13_croparea_consv_shr_noselect <- 0 # def = 0 + +# * Whether tau in conservation priority areas can increase over time +# * (1) tau in conservation priority areas can increase over time +# * but is subject to s13_croparea_consv_tau_factor. +# * (0) tau in conservation priority areas is subject to s13_croparea_consv_tau_factor +# * but is held constant after s13_croparea_consv_target. +cfg$gms$c13_croparea_consv_tau_increase <- 1 # def = 1 + +# * Tau reduction factor for conservation priority areas +# * E.g. a value of 0.8 means that tau in conservation priority +# * areas is only 80% of tau in regular cropland areas +cfg$gms$s13_croparea_consv_tau_factor <- 0.8 # def = 0.8 +cfg$gms$s13_croparea_consv_tau_factor_noselect <- 0.8 # def = 0.8 + +# * Switch and specification of countries for which a separate tau in +# * conservation priority areas applies +# * Options: list of iso-codes of countries where land conservation should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$croparea_consv_countries13 <- all_iso_countries + +# * Start and target year of implementing s13_croparea_consv_shr. +# * Defines when s13_croparea_consv_shr is fully implemented, using a +# * sigmoidal trajectory. NOTE: This switch is only relevant +# * if s13_croparea_consv_shr is greater than 0. +# * Start year: +cfg$gms$s13_croparea_consv_start <- 2025 # def = 2025 +# * Target year: +cfg$gms$s13_croparea_consv_target <- 2030 # def = 2030 -# * tc cost scenario: low, medium or high -cfg$gms$c13_tccost <- "medium" # ***--------------------- 14_yield -------------------------------------- -# * (biocorrect): cropland TC applied on pasture yields -# * (dynamic_aug18): pasture yields increase based on exogenuous demand-side proxy -# * for growth rate of cattle stocks -cfg$gms$yields <- "dynamic_aug18" # def = dynamic_aug18 +# * (managementcalib_aug19): calibrate potential LPJmL-yields to FAO regional numbers, +# * pasture yields increase based on exogenous demand-side proxy +# * for growth rate of cattle stocks +cfg$gms$yields <- "managementcalib_aug19" # def = managementcalib_aug19 # * yield scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c14_yields_scenario <- "nocc" # def = "nocc" +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +cfg$gms$c14_yields_scenario <- "cc" # def = "cc" # * switch determing the effectivity of translating crop tc into pasture yield # * increase. Value has to be in the range of 0 (no pasture yield growth) -# * and 1 (pasture yields increase linearily with tau) -# * only used in biocorrect realization +# * and 1 (pasture yields increase linearily with tau). Only used in the realizations: +# * biocorrect (tc of current time step) and managementcalib (tc of previous time step). cfg$gms$s14_yld_past_switch <- 0.25 # def = 0.25 +# * Switch that allows selecting how yield calibration factors will be calculated. +# * If 0, crop yields calibration will be calculated as multiplicative relative values. +# * If 1, calibration values will be limited to additive absolute values when modeled yields strongly +# * underestimate historical values. For more information, read the description on the 'preloop' +# * file of module 14_yield. +# * options: 1 (limit to absolute values) +# * 0 (pure relative calibration) +cfg$gms$s14_limit_calib <- 1 # def = 1 + +# * Switch on scaling of irrigated yields to AQUASTAT irrigated-to-rainfed yield +# * ratio on regional scale +# NOTE: It is recommended to recalibrate the model when changing this setting! +cfg$gms$s14_calib_ir2rf <- 1 # def = 1 + +# * Switch to include yield impacts of land degradation. +# * The state of yield-relevant nature's contributions to people (NCP) +# * is reported through ./modules/14_yields/input/f14_yld_ncp_report.cs3 +# * based on estimated outcomes for soil loss or pollination sufficiency +# * per cluster from an existing model run. +# * options: 1 (yields are reduced based on yield reduction coefficients) +# * 0 (land degradation is switched off) +cfg$gms$s14_degradation <- 0 # def = 0 + +# Switch to toggle the use of yield calibration factors (that resulted from a calibration run). +# If 0, no yield calibration factors are used, meaning all calibration factors are set to 1. +# If 1, yield calibration factors are used. (For this option to function, either an existing calibration file +# must be supplied in the input directory, or yields must be recalibrated during preprocessing.) +# This switch should only be activated for penalty_apr22 crop realization. +# For other realizations, it is recommended not to use this yield calibration. +cfg$gms$s14_use_yield_calib <- 0 # def = 0 + +# Include a minimum yield for wood harvest in secondary vegetation (tDM per ha per yr). +# Age classes with wood yields below this threshold have a production of zero. +cfg$gms$s14_minimum_wood_yield <- 10 #def = 10 + + # ***--------------------- 15_food --------------------------------------- # * (anthropometrics_jan18): estimates food using scenario dependent regression # * and demography drivers -cfg$gms$food <- "anthropometrics_jan18" # def = anthropometrics_jan18 +# * (anthro_iso_jun22): estimates food using scenario dependent regression +# * and demography drivers on iso level +cfg$gms$food <- "anthro_iso_jun22" # def = anthro_iso_jun22 + +# * switch between exogenous and endogenous food demand +# * options: 0 (exogenous food demand) and 1 (endogenous food demand) +cfg$gms$s15_elastic_demand <- 0 # def =0 + +# * Per capita redistribution of GHG tax revenues +# * options: 1 (distribution_neutral recycling), 0 (no recycling) +cfg$gms$s15_tax_recycling <- 1 # def = 1 # * maximal number of iterations between food and magpie model before -# * simulation proceeds to next time step -cfg$gms$s15_maxiter <- 5 # def = 5 +# * simulation proceeds to next time step, maximum 10 +cfg$gms$s15_maxiter <- 10 # def = 10 # * convergence criteria: maximal allowed country-wise deviation in calculated # * real income between iterations cfg$gms$s15_convergence <- 0.005 # def = 0.005 -# * switch between exogenous and endogenous food demand -# * options: 0 (exogenous food demand) and 1 (endogenous food demand) -cfg$gms$s15_elastic_demand <- 1 # def =1 - -# * food scenario +# * food scenario for selected (and respectively not selected) countries +# * in scen_countries15 # * options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" # * SRES: "A1", "A2", "B1", "B2" # * OTHER: "PB" (planetary boundaries) -cfg$gms$c15_food_scenario <- "SSP2" # def = SSP2 +cfg$gms$c15_food_scenario <- "SSP2" # def = SSP2 +cfg$gms$c15_food_scenario_noselect <- "SSP2" # def = SSP2 -# * ruminant meat share scenario +# * Temporal development of ruminant meat share within the livestock food product +# * group (applied before food demand model is executed) # * options: constant, halving2050, mixed -cfg$gms$c15_rumscen <- "mixed" # def = mixed +cfg$gms$c15_rum_share <- "mixed" # def = mixed + +# * Stronger ruminant fadeout in India +# * options: 0 (=off), 1 (=on) +cfg$gms$s15_rum_share_fadeout_india_strong <- 1 # def = 1 + +# * Milk share fadeout in India within the livestock food product +# * group (applied before food demand model is executed) +# * options: 0 (=off), 1 (=on) +cfg$gms$s15_milk_share_fadeout_india <- 1 # def = 1 + +# * Food substitution scenarios (applied after food demand model is executed) +# * Values between 0 and 1 are allowed, where 0 means no food is substituted, +# * while 1 corresponds to a full substitution of food items with alternatives. +# * The functional form and the start and target years of the food substitution +# * can be specified below +cfg$gms$s15_ruminant_substitution <- 0 # def = 0 +cfg$gms$s15_fish_substitution <- 0 # def = 0 +cfg$gms$s15_alcohol_substitution <- 0 # def = 0 +cfg$gms$s15_livestock_substitution <- 0 # def = 0 +cfg$gms$s15_rumdairy_scp_substitution <- 0 # def = 0 +cfg$gms$s15_rumdairy_substitution <- 0 # def = 0 + +# * Set items of kfo_rd. This option allows for sensitivity scenarios. +# * kfo_rd is used in the food substitution scenarios s15_rumdairy_scp_substitution and s15_rumdairy_substitution (see above) +# * options: "livst_rum,livst_milk", "livst_rum" or "livst_milk" +cfg$gms$kfo_rd <- "livst_rum" #def = livst_rum + +# * Switch for supplemental fat needed as ingredient for scp-based meat alternatives +# * options: 0 (=off), 1 (=on) +cfg$gms$s15_scp_supplement_fat_meat <- 0 # def = 0 + +# * Convergence of livestock food calorie supply towards a kcal/cap/day target with or w/o substitution. +# * The functional form and the start and target years of the food substitution can be specified below. +# * options: 0 = no converge, 1 = convergence to target +cfg$gms$s15_livescen_target <- 0 # def = 0 +# * maximum kcal/cap/day supply target used for downwards convergence of livestock products +cfg$gms$s15_kcal_pc_livestock_supply_target <- "430" # def = 430 +# * fade-out of livestock products (0) or substitution of livestock products with plant-based products (1) +# * options: 0 (=fade-out), 1 (=substitution) +cfg$gms$s15_livescen_target_subst <- 1 # def = 1 + +# * Functional form of the substitution/convergence over time +# * options: 1 = linear substitution, 2 = sigmoid substitution +cfg$gms$s15_food_subst_functional_form <- 1 # def = 1 +# * Start year of food subsitution +cfg$gms$s15_food_substitution_start <- 2025 # def = 2025 +# * Target year (year when target substitution is reached) +cfg$gms$s15_food_substitution_target <- 2050 # def = 2050 + +# ***** Start configuration of exogenous food intake and waste scenarios ***** +# +# +# * switch for transition to food waste scenarios +# * (1): transition towards exogenous food waste target +# * (0): regression-based estimation of food waste +cfg$gms$s15_exo_waste <- 0 # def = 0 +# +# * scenario target for the ratio between food demand and intake +# * only activated if s15_exo_waste is set to 1 +# * options: scalars >1 +# * (1.1): corresponds to 10% food waste ~ quarter waste of HIC +# * (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)) +# * (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 (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" +# * (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). 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 + +# * exogenous calorie scenario (EAT Lancet diet scenarios) +# * only activated if s15_exo_diet is > 0 +# * options: healthy_BMI, 2100kcal, 2500kcal, +# * endo, no_underweight, no_overweight +# * half_overweight, no_underweight_half_overweight +# * healthy_BMI: all people have a BMI of 20-25 +# * no_underweight: all people with BMI<20 have a BMI 20-25 +# * no_overweight: all people with BMI>25 have a BMI 20-25 +# * half_overweight: number of people with BMI>25 is halved compared to baseline (have BMI 20-25 instead) +# * no_underweight_half_overweight: combination of no_underweight and half_overweight +# * endo: no changes with respect to endogenous BMI +# * 2100kcal, 2500kcal: an exogenous target of 2100 or 2500 kcal, all +# * people have a BMI 20-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 1 or 2 +# * options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat +cfg$gms$c15_EAT_scen <- "FLX" # def = FLX + +# * Sub-specifications: Which commodities shall be included in the diet shift +# * 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. +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_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, 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 +# * 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 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 +# * (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 # def = 0 +# +# +# * Switch and specification of countries for which exogenous food scenarios +# * (EAT Lancet diet and food waste scenarios), food substitution scenarios and +# * c15_food_scenario shall be applied +# * Options: list of iso-codes of countries where exogenous scenario should be +# * in effect +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$scen_countries15 <- all_iso_countries +# +# * Transition to exogenous food intake and waste scenarios (applied after the +# * food demand model is executed). The resulting scenario parametrisation is +# * a linear or sigmoid combination of the default MAgPIE parametrisation and the +# * exogenous scenario data input. +# * The functional form (linear or sigmoid) and the start and target years of +# * the exogeneous food intake scenario can be specified below. +# * Only active if at least one of the exogenous food intake and waste scenario +# * switches (s15_exo_diet and s15_exo_waste) is set to 1. +# * Values between 0 and 1 are allowed, where 0 means no convergence to exogenous +# * food intake scenario, while 1 corresponds to a full convergence to exogenous +# * food intake scenario. +cfg$gms$s15_exo_foodscen_convergence <- 1 # def = 1 +# * Functional form of the convergence to the exogeneous food intake scenario over time +# * options: 1 = linear convergence, 2 = sigmoid convergence +cfg$gms$s15_exo_foodscen_functional_form <- 1 # def = 1 +# * Start year of convergence to exogeneous food intake scenario +cfg$gms$s15_exo_foodscen_start <- 2025 # def = 2025 +# * Target year (year when s15_exo_foodscen_convergence is reached) +cfg$gms$s15_exo_foodscen_target <- 2050 # def = 2050 +# ***** End configuration of exogenous food intake and waste scenarios ***** + + +# * calibration to historical values +# * options: 0, 1 +cfg$gms$s15_calibrate <- 1 # def = 1 + # ***--------------------- 16_demand ------------------------------------- # * (sector_may15): default for flexible regions @@ -179,6 +610,11 @@ cfg$gms$demand <- "sector_may15" # def = sector_may15 # * (flexreg_apr16): default production aggregation cfg$gms$production <- "flexreg_apr16" # def = flexreg_apr16 +#* Additional switch to initialize cellular production +# * (on) : it initializes cellular production +# * (off) : it does not initialize cellular production +cfg$gms$c17_prod_init <- "on" # default = on + # ***--------------------- 18_residues ----------------------------------- # * (flexreg_apr16): detailed residue calculations # * (off): off @@ -191,61 +627,386 @@ cfg$gms$c18_burn_scen <- "phaseout" # def = phaseout # ***--------------------- 20_processing --------------------------------- -# * (substitution_dec18) : processing with couple products allowing for substitution +# * (substitution_may21) : processing with couple products allowing for substitution # * (off): off -cfg$gms$processing <- "substitution_dec18" # def = substitution_dec18 +cfg$gms$processing <- "substitution_may21" # def = substitution_may21 + + +# * SCP route +# * single-cell microbial protein production route +# * options: mixed, methane, sugar, cellulose, hydrogen +# * Mapping of scp route to feedstock: methane:foddr, sugar:sugar_cane, cellulose:begr +# * Note that hydrogen does not require land-based inputs +# * Mixed assumes equal shares of methane, sugar, cellulose and hydrogen +cfg$gms$c20_scp_type <- "sugar" # def = sugar # ***--------------------- 21_trade -------------------------------------- -# * (free_apr16): free trade without restrictions -# * (off): no trade at all -# * (selfsuff_reduced): self-sufficiency based trade with trade costs related -# * to exports +# * (exo): exogenously prescribed trade +# * (selfsuff_reduced): self-sufficiency based trade with trade costs related to exports +# * (selfsuff_reduced_bilateral22): same as `selfsuff_reduced` but with bilateral trade flows cfg$gms$trade <- "selfsuff_reduced" # def = selfsuff_reduced +# * options for `selfsuff_reduced` and `selfsuff_reduced_bilateral22` realizations: +# * Commodities that can have additional imports to maintain feasibility +cfg$gms$k_import21 <- "wood, woodfuel" +# * Cost for additional imports to maintain feasibility in USD17MER per tDM +cfg$gms$s21_cost_import <- 1500 # def = 1500 + # * trade balance reduction scenario # * (l909090r808080): 10 percent trade liberalisation for secondary and # * livestock products in 2030,2050,2100 and 20 percent for # * crops # * (l908080r807070): livestock/secondary: 10% in 2030, 20% in 2050,2100 # * crops: 20% in 2030, 30% in 2050,2100 -# * (l909595r909090): livestock/secondary: 10% in 2030, 5% in 2050,2100 +# * (l909595r809090): livestock/secondary: 10% in 2030, 5% in 2050,2100 # * crops: 20% in 2030, 10% in 2050,2100 +# * Initial values for the trade balance reduction in 1995 are 1, i.e. all trade in +# * 1995 happens through the self-sufficiency pool. For later time steps, additional +# * scenarios of trade liberalization (i.e. of allocation to the comparative advantage pool) +# * are implemented based on Schmitz et al. 2012 (also described in Popp et al. 2017) cfg$gms$c21_trade_liberalization <- "l909090r808080" # def = l909090r808080 -# * whether trade tariff should be considered +# * Fraction to ease self sufficiency pool trade for roundwood +cfg$gms$s21_trade_bal_damper <- 0.65 # def 0.65 + +# * whether trade tariff should be considered at all # * (0) without trade tariff # * (1) with trade tariff cfg$gms$s21_trade_tariff <- 1 # def =1 -# ***--------------------- 30_crop --------------------------------------- -# * (endo_jun13): dynamic cropland -cfg$gms$crop <- "endo_jun13" # def = endo_jun13 +# * whether to fade out trade tariffs (bilateral trade realization) # def = 0 +cfg$gms$s21_trade_tariff_fadeout <- 0 + +# * start year of fadeout if s21_trade_tariff_fadeout = 1 # def = 2025 +cfg$gms$s21_trade_tariff_startyear <- 2025 + +# * end year of fadeout if s21_trade_tariff_fadeout = 1 # def = 2050 +cfg$gms$s21_trade_tariff_targetyear <- 2050 + +# * Minimum trade margin for forestry products (USD17MER per tDM) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate:1.23) +cfg$gms$s21_min_trade_margin_forestry <- 62 # def = 50 * 1.23 + +# ***--------------------- 22_land_conservation -------------------------------------- +# * (area_based_apr22): Area-based conservation (baseline and future) +# * based on WDPA and conservation priority areas +cfg$gms$land_conservation <- "area_based_apr22" # def = area_based_apr22 + +# * Baseline protection in historic and future time steps +# * ("WDPA") All legally protected areas across all IUCN categories +# * ("WDPA_I-II-III") All legally protected areas in IUCN categories I, II & III +# * ("WDPA_IV-V-VI") All legally protected areas in IUCN categories IV, V & VI +# * ("none") No baseline protection +# * Note: c22_base_protect applies to countries selected in policy_countries22 +# * c22_base_protect_noselect applies to all other countries. +cfg$gms$c22_base_protect <- "WDPA" # def = WDPA +cfg$gms$c22_base_protect_noselect <- "WDPA" # def = WDPA + +# Year in which Baseline protection reversal should take place (e.g. 2030) +cfg$gms$s22_base_protect_reversal <- Inf # def = Inf (no reversal) + +# * Additional land conservation target based on conservation priority areas +# * during future time steps (after `cfg$gms$sm_fix_SSP2`). +# * ("none") No additional land conservation target (Baseline only) +# * ("30by30") 30 % of global land surface in Key Biodiversity Areas (KBA), +# * GSN Distinct Species Assemblages & Critical Connectivity Areas + Baseline +# * ("KBA") Key Biodiversity Areas + Baseline +# * ("GSN_DSA") Global Safety Net: Distinct Species Assemblages + Baseline +# * ("GSN_RarePhen") Global Safety Net: Rare Phenomena + Baseline +# * ("GSN_AreaIntct") Global Safety Net: Areas of Intactness + Baseline +# * ("GSN_ClimTier1") Global Safety Net: Climate Stabilisation Tier 1 + Baseline +# * ("GSN_ClimTier2") Global Safety Net: Climate Stabilisation Tier 2 + Baseline +# * ("CCA") Critical Connectivity Areas (Brennan et al. 2022) + Baseline +# * ("IrrC_XXpc") Land area that covers XX percent of total global irrecoverable carbon +# * as defined by Noon et al. (2022), where XX correponds to either +# * 50, 75, 95, or 99 percent + Baseline +# * ("IrrC_XXpc_30by30") 30by30 + Land area that covers XX percent of total global irrecoverable +# * carbon as defined by Noon et al. (2022), where XX correponds to either +# * 50, 75, 95, or 99 percent + Baseline +# * ("BH") Biodiversity Hotspots + Baseline +# * ("IFL") Intact Forest Landscapes + Baseline +# * ("BH_IFL") Biodiversity Hotspots + Intact Forest Landscapes + Baseline +# * ("GSN_HalfEarth") Full protection of areas within the Global Safety Net, which +# * roughly corresponds to 50 percent of the global land surface +# * ("PBL_HalfEarth") Ecoregion-based approach to protecting half of the global land surface +# * Note: c22_protect_scenario applies to countries selected in policy_countries22 +# * c22_protect_scenario_noselect applies to all other countries. +cfg$gms$c22_protect_scenario <- "none" # def = none +cfg$gms$c22_protect_scenario_noselect <- "none" # def = none + +# * Switch and specification of countries for which land conservation +# * in c22_base_protect and c22_protect_scenario apply. +# * Options: list of iso-codes of countries where land conservation should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries22 <- all_iso_countries + +# * Whether land restoration is carried out in areas targeted by land conservation +# * (1) Land is fully restored in conservation priority areas +# * (0) Only remaining forest and other land areas are conserved +cfg$gms$s22_restore_land <- 1 # def = 1 + +# * Land types included in future land conservation. +# * plausible options: "secdforest, forestry, past, other", +# * "secdforest, primforest", etc. +cfg$gms$land_consv <- "primforest, secdforest, other" #def = "primforest, secdforest, other" + +# * Start and target year of land conservation option ('c22_protect_scenario'). +# * Defines when full protection based on 'future options' is reached, using a +# * sigmoidal trajectory. NOTE: This switch is only relevant +# * if one of the 'future options' (e.g. BH) is chosen. +# * Start year: +cfg$gms$s22_conservation_start <- 2025 # def = 2025 +# * Target year (year when full protection is reached): +cfg$gms$s22_conservation_target <- 2050 # def = 2050 + +# ***--------------------- 28_ageclass ----------------------------------- +# * (oct24): Forest age-classes based on GFAD V1.1 from Poulter et al 2019 +cfg$gms$ageclass <- "oct24" # def = oct24 + +# ***--------------------- 29_cropland ----------------------------------- +# * Cropland is defined as the sum of croparea, fallow land and tree cover +# * Croparea is provided by 30_crop. +# * Fallow land and tree cover are defined by 29_cropland, +# * (simple_apr24): Fallow land and tree cover on cropland are fixed to zero +# * (detail_apr24): Fallow land and tree cover based on rules or incentives +# NOTE: It is recommended to recalibrate the model when changing this setting! +cfg$gms$cropland <- "detail_apr24" # def = detail_apr24 + +# *** Options for all cropland realizations *** + +# * Switch to determine whether marginal land (suitability index below 0.33) should be included +# * in the total available cropland. Options are: +# * ("all_marginal"): All marginal land can be used for crop cultivation +# * ("q33_marginal"): The bottom tertile of marginal land is excluded +# * ("no_marginal"): Marginal land is completely excluded from crop cultivation +# * Note: Option "q33_marginal" produces the highest spatial correlation +# * with observed cropland patterns and is recommended for productive runs. +cfg$gms$c29_marginal_land <- "q33_marginal" # def = "q33_marginal" + +# * Switch and specification of countries for selected policies in apply. +# * Options: list of iso-codes of countries where SNV policy should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries29 <- all_iso_countries + +# * Share of available cropland that is withheld for maintaining semi-natural vegetation (SNV) +# * in each square km in cropland areas, including grassland, forest and other land. For example, +# * a share of 0.2 corresponds to 20 % of SNV in terms of the available cropland. +# * The amount of cropland relocation is estimated based on external high resolution +# * land cover information from the Copernicus Global Land Service for the year 2019. +# * Accepted sensible values are between 0 and 0.5 +# Note: s29_snv_shr applies to countries selected in policy_countries29 +# s29_snv_shr_noselect applies to all other countries. +cfg$gms$s29_snv_shr <- 0 # def = 0 +cfg$gms$s29_snv_shr_noselect <- 0 # def = 0 +# * Year by which SNV policy ('s29_snv_shr') is fully implemented. +# * Start year (should be close to 2019): +cfg$gms$s29_snv_scenario_start <- 2025 # def = 2025 +# * Target year (year when full implementation is reached): +cfg$gms$s29_snv_scenario_target <- 2050 # def = 2050 +# * Land types included in the SNV policy. This option allows for sensitivity analyses. +# * plausible options: "secdforest, forestry, past, other", +# * "secdforest, other", +# * "secdforest, past, other" etc. +cfg$gms$land_snv <- "secdforest, other" #def = "secdforest, other" + +# *** Options only available for `detail_apr24` realization *** + +# * Switch for functional form of faders (1=linear 2=sigmoid) +cfg$gms$s29_fader_functional_form <- 2 # def = 2 + +## Agroforestry settings for treecover on cropland +# * Initial tree cover +# * (0): tree cover on cropland starts from zero +# * (1): tree cover on cropland is initialized based on satellite data for 2015 +cfg$gms$s29_treecover_map <- 0 # def = 0 +# * Sigmoid fader for minimum area share of treecover on total cropland at cluster level +# * Minimum area share of treecover on total cropland in target year +# Note: s29_treecover_target applies to countries selected in policy_countries29 +# s29_treecover_target_noselect applies to all other countries. +cfg$gms$s29_treecover_target <- 0 # def = 0 +cfg$gms$s29_treecover_target_noselect <- 0 # def = 0 +# * Avoid loss of existing treecover (1=yes 0=no). +# * If set to 1, `s29_treecover_target` will be adjusted based existing treecover area. +cfg$gms$s29_treecover_keep <- 0 # def = 0 +# * Maximum share of treecover on total cropland (1) +cfg$gms$s29_treecover_max <- 1 # def = 1 +# * Start year of fader +cfg$gms$s29_treecover_scenario_start <- 2025 # def = 2025 +# * Target year of fader (year when full implementation is reached) +cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of treecover target before scenario start (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate:1.23) +cfg$gms$s29_treecover_penalty_before <- 0 # def = 0 +# * Penalty for violation of treecover target after scenario start (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s29_treecover_penalty <- 6150 # def = 5000 * 1.23 +# * Tree cover establishment cost (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate:1.23) +cfg$gms$s29_cost_treecover_est <- 2460 # def = 2000 * 1.23 +# * Tree cover recurring cost (USD17MER per ha) +cfg$gms$s29_cost_treecover_recur <- 615 # def = 500 * 1.23 +# * Switch for using natural vegetation (0) or plantation (1) growth curves towards LPJmL natural +# * vegetation carbon density. +cfg$gms$s29_treecover_plantation <- 0 # def = 0 +# * Switch for using secondary vegetation (0) or timber plantation (1) BII coefficients +# * The recommend setting is to map the BII coefficient to the choice of the growth curve. +cfg$gms$s29_treecover_bii_coeff <- 0 # def = 0 + +# * Sigmoid fader for minimum area share of fallow land on total cropland at cluster level +# * Minimum area share of fallow land on total cropland in target year +cfg$gms$s29_fallow_target <- 0 # def = 0 +# * Maximum share of fallow land on total cropland +cfg$gms$s29_fallow_max <- 0 # def = 0 +# * Start year of fader +cfg$gms$s29_fallow_scenario_start <- 2025 # def = 2025 +# * Target year of fader (year when full implementation is reached) +cfg$gms$s29_fallow_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of fallow land target (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s29_fallow_penalty <- 615 # def = 500 * 1.23 + +# ***--------------------- 30_croparea --------------------------------------- +# * 30_croparea defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. +# * (simple_apr24): Dynamic croparea with simple rotational constraints +# * (detail_apr24): Dynamic croparea with detailed rules and incentives for rotational constraints +# NOTE: It is recommended to recalibrate the model when changing this setting! +cfg$gms$croparea <- "simple_apr24" # def = simple_apr24 + +# *** Options for all croparea realizations *** + +# * (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" + +# * Switch and specification of countries for selected policies in apply. +# * Options: list of iso-codes of countries where SNV policy should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries30 <- all_iso_countries + +## Agroforestry settings for bioenergy trees +# * Sigmoid fader for minimum area share of bioenergy trees (betr) on total cropland at cluster level +# * Minimum area share of bioenergy trees on total cropland in start year +# Note: s30_betr_start applies to countries selected in policy_countries30, +# s30_betr_start_noselect applies to all other countries. +cfg$gms$s30_betr_start <- 0 # def = 0 +cfg$gms$s30_betr_start_noselect <- 0 # def = 0 +# * Minimum area share of bioenergy trees on total cropland in target year +# Note: s30_betr_target applies to countries selected in policy_countries30, +# s30_betr_target_noselect applies to all other countries. +cfg$gms$s30_betr_target <- 0 # def = 0 +cfg$gms$s30_betr_target_noselect <- 0 # def = 0 +# * Start year of fader +cfg$gms$s30_betr_scenario_start <- 2025 # def = 2025 +# * Target year of fader (year when full implementation is reached) +cfg$gms$s30_betr_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of the target (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s30_betr_penalty <- 2460 # def = 2000 * 1.23 + +# * Allowed annual cropland growth per year per region, relative to the current cropland level +# * e.g., 0.02: 2% annual growth, compounded to 10.4% growth for five-years timestep +cfg$gms$s30_annual_max_growth <- Inf # def = Inf + +# *** Options only available for `simple_apr24` realization *** + +# * (c30_rotation_constraints): switch for rotational constraints: on, off +cfg$gms$c30_rotation_constraints <- "on" # def = "on" + +# *** Options only available for `detail_apr24` realization *** + +# * Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios +cfg$gms$s30_implementation <- 1 # def = 1 + +# * Rotation rules: +# * min (minimal constraints), default (best guess), good (good practice), +# * good_20div (good practice - 20% for other crops), setaside (default plus fallow), +# * legumes (minimum share of legumes), sixfoldrotation (crops can only repeat after 6 years), +# * agroecology (mix of previous scenarios), FSEC (similar to agroecology) +# * betr0 (minimum share of short rotation agroforestry trees), betr10, betr20, betr25, betr30, betr40, betr50. +cfg$gms$c30_rotation_rules <- "default" # def = "default" + +# * Rotation incentives: +# * none (no incentives), default (best guess), +# * legumes (increased incentives for legumes), agroecology (mix), +# * betr500 and betr1000 (incentives for short rotation agroforestry trees) +cfg$gms$c30_rotation_incentives <- "none" # def = "none" + +# * Year by which rotation scenario is fully implemented: +# * Start year: +cfg$gms$s30_rotation_scenario_start <- 2025 # def = 2025 +# * Target year (year when full implementation is reached): +cfg$gms$s30_rotation_scenario_target <- 2050 # def = 2050 # ***--------------------- 31_past --------------------------------------- # * (static): static pasture # * (endo_jun13): dynamic pasture +# NOTE: It is recommended to recalibrate the model when changing this setting! cfg$gms$past <- "endo_jun13" # def = endo_jun13 -# * Factor requirements (US$04 per ton DM) +# * Factor requirements (USD17 per ton DM) cfg$gms$s31_fac_req_past <- 1 # def = 1 # ***--------------------- 32_forestry ----------------------------------- -# * (static_sep16) : static forestry sector -# * (affore_vegc_dec16): static forestry sector + afforestation -cfg$gms$forestry <- "affore_vegc_dec16" # def = affore_vegc_dec16 +# * (dynamic_may24): Dynamic forestry sector including afforestation with detailed age-classes +cfg$gms$forestry <- "dynamic_may24" # def = dynamic_may24 + +# * Annual upper limit for re-afforestation as share of overall forest establishment potential (1) +# * The upper limit is applied on both NPI/NDC and CO2-price driven re-afforestation +cfg$gms$s32_annual_aff_limit <- 0.03 # def = 0.03 # * afforestation planing horizon (years) -cfg$gms$s32_planing_horizon <- 80 # def = 80 +cfg$gms$s32_planning_horizon <- 50 # def = 50 + +# * Settings for CO2 price driven afforestation (Growth curve and BII) + +# * Growth curve for CO2 price driven afforestation +# * Switch for using natural vegetation (0) or plantation (1) growth curves towards LPJmL natural +# * vegetation carbon density. +# * Afforestation following plantation growth curves reflects managed or assistent regrowth, +# * and might also include non-native species. +cfg$gms$s32_aff_plantation <- 0 # def = 0 + +# * BII coefficient for CO2 price driven afforestation +# * Switch for using secondary vegetation (0) or timber (1) BII coefficients for CO2 price driven afforestation +# * The recommend setting is to map the BII coefficient to the choice of the growth curve. +# * natural vegetation growth curve (0): secondary vegetation BII coefficient (0) +# * plantation growth curve (1): timber BII coefficient (1) +# * However, afforestation with plantations (1) could possibly be done in a biodiversity friendly way (0) +cfg$gms$s32_aff_bii_coeff <- 0 # def = 0 # Afforestation policy # * ("none"): no prescribed afforestation # * ("npi"): prescribed afforestation based on NPI policies # * ("ndc"): prescribed afforestation based on NPI+NDC policies -cfg$gms$c32_aff_policy <- "npi" # def = "none" +cfg$gms$c32_aff_policy <- "npi" # def = "npi" + +# Year in which NPI NDC reversal should take place (e.g. 2025) +cfg$gms$s32_npi_ndc_reversal <- Inf # def = Inf -# maximum total global afforestation in Mha (Inf = no constraint) +# Maximum total global afforestation in Mha (Inf = no constraint) +# Note 1: the limit applies to the sum of endogenous CO2 price driven and exogenous NPI/NDC afforestation +# Note 2: a limit of 0 or below the level of exogenous NPI/NDC afforestation will be a automatically raised to the level of exogenous NPI/NDC afforestation 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_planning_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. +cfg$gms$s32_aff_prot <- 1 # def = 1 + +# Type of afforestation constraint +cfg$gms$s32_max_aff_area_glo <- 1 # def = 1 +# * (1): global limit based on s32_max_aff_area +# * (0): regional limit based on the input file "f32_max_aff_area.cs4" + # Switch to determine whether afforestation should be limited to # certain latitudinal zones # * ("unrestricted"): No regions excluded @@ -253,26 +1014,94 @@ cfg$gms$s32_max_aff_area <- Inf # def = Inf # * ("onlytropical"): Afforestation only in tropical areas 20deg S-20deg N cfg$gms$c32_aff_mask <- "noboreal" # def = "noboreal" +# Switch to determine whether biogeophysical responses to +# afforestation should be considered +# If this endogenous bgp effect is considered it is adviced to use the +# unrestricted afforestation mask +# to avoid superimposing the additional exogeneous bgp implementation +# * ("nobgp"): No biogeophysical influences +# * ("ann"): Annual BGP +# * ("djf"): Boreal winter BGP December January February +# * ("jja"): Boreal summer BGP June July August +cfg$gms$c32_aff_bgp <- "nobgp" # def = "nobgp" + +# Switch for the different TCRE estimates which are used to +# translate the BGP temperature effect into their carbon equivalent. +# The estimates encompass the ensemble mean +/- SD of 20 CMIP5 models. +# Ceq ~ BGP/TCRE - Hence, high TCRE decreases the BGP effect. +# * ("ann_TCREmean"): Ensemble mean +# * ("ann_TCREhigh"): Ensemble mean + SD +# * ("ann_TCRElow"): Ensemble mean - SD +cfg$gms$c32_tcre_ctrl <- "ann_TCREmean" + +# Switch for dynamic timber plantations +# "off" means that timber plantations are initialized in the highest +# age class and that there is no regrowth seen in such plantations. +# In addition, timber plantations are fixed to 1995 levels in the "off" case. +# In other cases, age-classes in timber plantations are initialized based on +# rotation length and can change dynamically over time. +# * 0= off +# * 1= Area is distributed equally to all age-classes within the rotation period +cfg$gms$s32_initial_distribution <- 1 # def = 1 + +# Global interest rate for plantations in case c32_interest_rate switch is global +# Accepted values between 0 and 1. +cfg$gms$s32_forestry_int_rate <- 0.05 # def = 0.05 + +# Setting to define if the model should be forward looking or not in terms of +# seeing the future demand for current timestep establishment of new plantations. +# * 0 = static (establishment based on current demand) +# * 1 = forward looking (establishment based on future demand according to rotation length) +cfg$gms$s32_demand_establishment <- 1 # def = 1 + +# Establishment cost for plantations (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s32_est_cost_plant <- 2460 # def = 2000 * 1.23 + +# Establishment cost for natural vegetation (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s32_est_cost_natveg <- 2460 # def = 2000 * 1.23 + +# Harvesting switch for timber production +# * 0 = No harvested area from plantations, no age-class shifting (area held constant at 1995 levels) +# * This also means that no harvesting or establishment of new plantations takes place. +# * 1 = "Exogenous" scenario. Harvested area from plantations but with age-class shifting +# * All timber plantations are harvested at rotation age and are re-established +# * such that the total plantation area remains constant. +# * 2 = "Endogenous" scenario. Harvest from plantations including age-class shifting +# * All plantations are harvested at rotation age. Plantation establishment is endogenous. +cfg$gms$s32_hvarea <- 2 # def = 2 + +# Type of rotation length selection criteria +# * ("mean_annual_increment") = Harvesting when the average annual increment is maximum +# * ("current_annual_increment") = Harvesting when the marginal increment is maximum +# * ("instantaneous_growth_rate_reg") = Harvest when instantaneous growth rate is equal to regional interest rate +# * ("instantaneous_growth_rate_glo") = Harvest when instantaneous growth rate is equal to global interest rate + +cfg$gms$c32_rot_calc_type <- "current_annual_increment" + +# Generic forest shock scenarios. Disturbance sets percentage of all age classes back to 0 +# * ("none") No disturbance applied +# * ("002lin2030") Disturbance applied to 0p2 percent per year linear phase-in over 20yrs from 0 in 2030 +# * ("004lin2030") Disturbance applied to 0p4 percent per year linear phase-in over 20yrs from 0 in 2030 +# * ("008lin2030") Disturbance applied to 0p8 percent per year linear phase-in over 20yrs from 0 in 2030 +# * ("016lin2030") Disturbance applied to 1p6 percent per year linear phase-in over 20yrs from 0 in 2030 +cfg$gms$c32_shock_scenario <- "none" # def = "none" + # ***--------------------- 34_urban --------------------------------------- -# * (static): static urban -cfg$gms$urban <- "static" # def = static +# * 34_urban includes urban land +# * (static) static urban land fixed on 1995 patterns from LUH3 +# * (exo_nov21) has exogenous future urban land patterns based on LUH3 +cfg$gms$urban <- "exo_nov21" # def = exo_nov21 + +# * Additional settings for exo_nov21 realization only: +cfg$gms$c34_urban_scenario <- "SSP2" # def = SSP2 +# * options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" # ***--------------------- 35_natveg -------------------------------------- # * 35_natveg includes primforest, secdforest and other land -# * (static): static natveg land -# * (dynamic_may18): dynamic natveg land -cfg$gms$natveg <- "dynamic_may18" # def = dynamic_may18 - -# * protected areas (primforest,secdforest,other land) -# * (WDPA) WDPA IUCN catI+II -# * (BH) Biodiversity Hotspots + WDPA -# * (FF) Frontier Forests + WDPA -# * (CPD) Centres of Plant Diversity + WDPA -# * (LW) last of the wild + WDPA -# * (none) no protection -# * (forest) forest protection (primforest+secdforest) -# * (full) full protection -cfg$gms$c35_protect_scenario <- "WDPA" # def = WDPA +# * (pot_forest_may24): Dynamic natural vegetation land with detailed age-classes +cfg$gms$natveg <- "pot_forest_may24" # def = pot_forest_may24 # Avoided Deforestation policy # * ("none"): no avoided deforestation @@ -280,22 +1109,150 @@ cfg$gms$c35_protect_scenario <- "WDPA" # def = WDPA # * ("ndc"): avoided deforestation based on NPI+NDC policies cfg$gms$c35_ad_policy <- "npi" # def = "npi" -# Avoided Other Land Conversion policye +# Avoided Other Land Conversion policy # * ("none"): no avoided other land conversion # * ("npi"): avoided other land conversion based on NPI policies # * ("ndc"): avoided other land conversion based on NPI+NDC policies cfg$gms$c35_aolc_policy <- "npi" # def = "npi" +# Year in which NPI NDC reversal should take place (e.g. 2025) +cfg$gms$s35_npi_ndc_reversal <- Inf # def = Inf + +# Distribution of age-classes during secondary forest initialization +# * (0): All secondary forest belongs to highest age class +# * (1): Equal distribution of secondary forest in all age-classes +# * (2): Distribution of secondary forest according to Poulter et al 2018 based on MODIS satellite data +cfg$gms$s35_secdf_distribution <- 2 # def = 2 + +# Damages in natural forests +# * (0): No damage simulated +# * (1): Damage from shifting agriculture (constant) +# * (2): Damage from shifting agriculture is faded out by the year defined in 'cfg$gms$c35_forest_damage_end' +# * (4): Generic forest disturbance scenarios defined in `f35_forest_shock.csv` +cfg$gms$s35_forest_damage <- 2 # def = 2 +# * If option (2) above: Year by which damage from shifting agriculture has petered out +cfg$gms$s35_forest_damage_end <- 2050 #def = 2050 + +# Harvesting switch for timber production +# * 0 = No timber production from natveg, no age-class shifting +# * 1 = No timber production from natveg but with age-class shifting +# * 2 = Timber production from natveg including age-class shifting +cfg$gms$s35_hvarea <- 2 # def = 2 + +# Generic forest shock scenarios. Disturbance sets percentage of all age classes back to 0 +# * ("none") No disturbance applied +# * ("002lin2030") Disturbance applied to 0p2 percent per year linear phase-in over 20yrs from 0 in 2030 +# * ("004lin2030") Disturbance applied to 0p4 percent per year linear phase-in over 20yrs from 0 in 2030 +# * ("008lin2030") Disturbance applied to 0p8 percent per year linear phase-in over 20yrs from 0 in 2030 +# * ("016lin2030") Disturbance applied to 1p6 percent per year linear phase-in over 20yrs from 0 in 2030 +cfg$gms$c35_shock_scenario = "none" # def = "none" + +# * Scenario for potential forest area +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +cfg$gms$c35_pot_forest_scenario <- "cc" # def = "cc" + +# ***--------------------- 36_employment ------------------------------- +# * This module calculates agricultural employment. +# * (exo_may22): employment is calculated based on labor costs and not affecting the +# * optimization +cfg$gms$employment <- "exo_may22" # default = "exo_may22" + +# * global minimum wage in USD17MER per hour that needs to be reached in all countries by 2050 +cfg$gms$s36_minimum_wage <- 0 # default = 0 (no minimum wage) + +# * A scenario that increases wages can either be fully related to productivity increase +# * (leading to lower employment for the same total labor costs), or keep productivity +# * constant (leading to the same employment for higher total labor costs), or to a +# * mixture between productivity increase an total labor cost increase. +# * The scalar `s36_scale_productivity_with_wage` describes how high the labor productivity +# * gain should be relative to the increase in hourly labor costs. If set to 0, +# * productivity stays constant, if set to 1 productivity scales proportional to hourly +# * labor costs. Other positive values lead to a mixture of productivity gain and increase +# * in total costs. +cfg$gms$s36_scale_productivity_with_wage <- 0 # default = 0 + +# ***--------------------- 37_labor_prod --------------------------------- +# * This module provides a labour productivity factor (0-1), +# * which reflects the efficiency of labour under changing environmental conditions (1 = no change). +# * The labour productivity factor is currently only considered in the sticky_labor +# * realization of the [38_factor_costs] module. +# * (off): labor productivity factor fixed to 1 +# * (exo): labor productivity factor is affected by climate change impacts +cfg$gms$labor_prod <- "off" # default = off + +# * Additional setting for exo realization only: +# * Climate change impact scenario. Options: "rcp119", "rcp585" +cfg$gms$c37_labor_rcp <- "rcp119" # default = "rcp119" +# * Heat assessment metric. Options: "ISO", "HOTHAPS" +cfg$gms$c37_labor_metric <- "ISO" # default = "ISO" +# * Labour intensity. Options: "300W", "400W" +cfg$gms$c37_labor_intensity <- "400W" # default = "400W" +# * Uncertainty over ESMs. Options: "enslower", "ensmean", "ensupper" +cfg$gms$c37_labor_uncertainty <- "ensmean" # default = "ensmean" # ***--------------------- 38_factor_costs ------------------------------- -# * (fixed_per_ton_mar18): factor costs fixed per ton -# * (mixed_feb17): reimplementation of MAgPIE 3.0 default -cfg$gms$factor_costs <- "mixed_feb17" # default = mixed_feb17 +# * Make sure you use the corresponding calibration file to the selected realization +# * Please, check details in input settings. +# * (per_ton_fao_may22) factor costs fixed per ton +# * (sticky_feb18) factor costs including investments in capital +# * (sticky_labor) based on sticky_feb18 + labor productivity factor included +# NOTE: It is recommended to recalibrate the model when changing this setting! +# NOTE: In case the maximum number of iterations is reached without convergence +# in the calibration, please consider to use the best_calib setting for the calibration run +cfg$gms$factor_costs <- "sticky_feb18" # default = "sticky_feb18" + +# * Regional (reg) or global (glo) factor requirements (applicable for per_ton_fao_may22, +# * sticky_feb18, sticky_labor). The regional version keeps factor requirements constant +# * after 2010, the global version uses values from 2005 for all years. Typically, the +# * same version (glo or reg) should be chosen for c70_fac_req_regr for consistency. +# NOTE: It is recommended to recalibrate the model when changing this setting! +cfg$gms$c38_fac_req <- "glo" # default "glo" + + +# * Only relevant for sticky_labor implementation: + +# * Year until which the capital share should be fixed to the historical values, not allowing for endogenous +# * substitution between labor and capital. +cfg$gms$s38_startyear_labor_substitution <- 2025 # default 2025 + +# * The following two settings are to create exogenous scenarios in which capital is substituted by labor to increase +# * employment: +# * The taget labor share defins a global target for labor share out of labor + capital needed per unit +# * of output. If 0, no target is set. +cfg$gms$s38_target_labor_share <- 0 # default 0 + +# * The target year defines the year for which the global target labor share should be set. +cfg$gms$s38_targetyear_labor_share <- 2050 + +# * The target fulfillment share indicates the share by which a region moves from its baseline +# * labor share towards the target value +cfg$gms$s38_target_fulfillment <- 0.5 # default 0.5 # ***--------------------- 39_landconversion ----------------------------- -# * (global_static_aug18): global static land conversion costs for establishment -# * and land clearing -cfg$gms$landconversion <- "global_static_aug18" # def = global_static_aug18 +# * (calib): Costs for cropland expansion are scaled with a regional calibration factor +# * Costs for pasture and forestry expansion are global static +cfg$gms$landconversion <- "calib" # def = calib +# * Cost for cropland expansion before calibration (USD17MER per hectare) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s39_cost_establish_crop <- 12300 #def = 10000 * 1.23 +# * Reward for cropland reduction before calibration (USD17MER per hectare) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s39_reward_crop_reduction <- 7380 #def = 6000 * 1.23 +# * Cost for pasture land expansion (USD17MER per hectare) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s39_cost_establish_past <- 9840 #def = 8000 * 1.23 +# * Cost for forestry land expansion (USD17MER per hectare) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s39_cost_establish_forestry <- 1230 #def = 1000 * 1.23 +# * Cost for urban land expansion (USD17MER per hectare) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s39_cost_establish_urban <- 12300 #def = 10000 * 1.23 +# * Switch for ignoring land conversion cost calibration factors +# * Options: 1 (ignore calibration factors) +# * 0 (use calibration factors) +cfg$gms$s39_ignore_calib <- 0 #def = 0 # ***--------------------- 40_transport ---------------------------------- # * (off): no transport costs @@ -310,19 +1267,31 @@ cfg$gms$s40_pasture_transport_costs <- 0 # def = 0 # ***--------------------- 41_area_equipped_for_irrigation --------------- # * (static): no expansion # * (endo_apr13): endogenous, cost driven expansion -cfg$gms$area_equipped_for_irrigation <- "endo_apr13" # def = endo_apr13 +cfg$gms$area_equipped_for_irrigation <- "endo_apr13" # def = endo_apr13 + +# * switch for initialization area +# * (LUH3): area equipped for irrigation based on LUH3 irrigated areas +# * (Mehta2024_Siebert2013): area equipped for irrigation from Mehta et al. (2024) using GMIA (Siebert et al, 2013) base map +# * (Mehta2024_Meier2018): are equipped for irrigation from Mehta et al. (2024) using Meier et al. (2018) base map +cfg$gms$c41_initial_irrigation_area <- "LUH3" # def = LUH3 + +# * Sets the rate of depreciation of irrigation infrastructure in every timestep. +# * Only applicable when (endo_apr13) realization is selected +cfg$gms$s41_AEI_depreciation <- 0 # def = 0 + # ***--------------------- 42_water_demand -------------------------------- # * (agr_sector_aug13): fixed fraction of water available is reserved # * for other uses -# * (all_sectors_aug13): industrial, eletricity and domestic demand are +# * (all_sectors_aug13): manufacturing, electricity and domestic demand are # * retrieved from WATERGAP data. -cfg$gms$water_demand<- "agr_sector_aug13" # def = agr_sector_aug13 +cfg$gms$water_demand<- "all_sectors_aug13" # def = all_sectors_aug13 # * water demand scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c42_watdem_scenario <- "nocc" # def = "nocc" +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +cfg$gms$c42_watdem_scenario <- "cc" # def = "cc" # * Choice of fraction of available water that is not # * available for agriculture (only affects agr_sector_aug13 realization) @@ -330,23 +1299,42 @@ cfg$gms$s42_reserved_fraction <- 0.5 # def = 0.5 # * Scenario for non agricultural water demand from WATERGAP # * (only affects all_sector_aug13 realization) -# * (1): SSP2 -# * (2): A2 -# * (3): B1 -cfg$gms$s42_watdem_nonagr_scenario <- 1 # def = 1 +# * (1): ssp1 +# * (2): ssp2 +# * (3): ssp3 +cfg$gms$s42_watdem_nonagr_scenario <- 2 # def = 2 # * Switch to determine the irrigation efficiency scenario # * (1): global static value # * (2): regional static values from gdp regression # * (3): gdp driven increase -cfg$gms$s42_irrig_eff_scenario <- 1 # def = 1 +cfg$gms$s42_irrig_eff_scenario <- 2 # def = 2 + +# * Irrigation efficiency +# * (Only used if global static value is requested) +cfg$gms$s42_irrigation_efficiency <- 0.66 # def=0.66 # * Environmental flow protection policy # * (off): no EFP policy -# * (on): global EFP policy starting in 2015 -# * (mixed): EFP policy starting in 2015 only in hic regions +# * (on): global EFP policy +# * (mixed): EFP policy only in hic regions cfg$gms$c42_env_flow_policy <- "off" # def = "off" +# * Start and target year of environmental flow protection policy ('c42_env_flow_policy'). +# * Defines when linear fading in of policy starts and when the target of +# * full protection based on 's42_env_flow_scenario' is reached +# * Start year: +cfg$gms$s42_efp_startyear <- 2025 # def = 2025 +# * Target year (year when full protection is reached): +cfg$gms$s42_efp_targetyear <- 2040 # def = 2040 + +# * Switch and specification of countries for which environmental flow policy +# * shall apply. +# * Options: list of iso-codes of countries where EFP should be in effect. +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$EFP_countries <- all_iso_countries # def = all_iso_countries + # * Environmental flow protection scenario # * (0): do not consider environmental flows. # * s42_env_flow_base_fraction and @@ -371,14 +1359,84 @@ cfg$gms$s42_env_flow_fraction <- 0.2 # def = 0.2 # * missing protection policy cfg$gms$s42_env_flow_base_fraction <- 0.05 # def = 0.05 +# * Switch to activate pumping costs (only available for India currently), Set to 1 if want to use for India +cfg$gms$s42_pumping <- 0 # def = 0 + +# * Year in which pumping costs will be implemented +cfg$gms$s42_multiplier_startyear <- 1995 # def = 1995 + +# * Scalar to change pumping costs for sensitivity analysis, takes numeric values +# * Default value is 0 for all regions, set value to 1 for India default analysis +# * Only applicable when s42_pumping is equal to 1 +cfg$gms$s42_multiplier <- 0 # def = 0 + # ***--------------------- 43_water_availability -------------------------- # * (total_water_aug13): surface and ground water resources available cfg$gms$water_availability <- "total_water_aug13" # def = total_water_aug13 # * water availability scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c43_watavail_scenario <- "nocc" # def = "nocc" +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +cfg$gms$c43_watavail_scenario <- "cc" # def = "cc" + +# ***------------------------- 44_biodiversity ------------------------------ +# * (bii_target): Biodiversity Intactness Index (BII) for 71 biomes with the option to define a lower bound for BII at biome level (range-rarity layer is not used) +# * (bv_btc_mar21): Global optimization of range-rarity weighted biodiversity stocks based on a price for losses and gains +cfg$gms$biodiversity <- "bii_target" # def = bii_target + +# * Start year for linear increase towards BII target value (in bii_target) or biodiversity target price (in bv_btc_mar21) +cfg$gms$s44_start_year <- 2030 #def = 2030 + +# * Year in which the BII target value (in bii_target) or biodiversity target price (in bv_btc_mar21) is reached +cfg$gms$s44_target_year <- 2100 #def = 2100 + +# ** Options for realization `bii_target` +# * This realisation allows to define a target value and year for the Biodiversity Intactness Index (BII) +# * that is applied in each biome type of each biogeographic realm or at the global level. +# * The BII target value increases in each biome linearly from the BII level in the start year (s44_start_year) to the value defined in `s44_bii_target` in the target year (s44_target_year). +# * The BII has been proposed as a control variable for changes in ecosystem functioning at the global scale +# * and has shown to capture increasing levels of ecosystem degradation. Steffen et al. (2015, 10.1126/science.1259855) have proposed +# * a premliminary boundary of 0.9 at the biome level (safe space) but with an uncertainty range of 0.9-0.3, +# * in which ecosystem degradation may undermine stable ecosystem functioning and the supply of nature's +# * contributions to people (NCP). With BII values below 0.3, the area's biodiversity has been depleted, +# * causing high risk of ecosystem collapse. Estimates for the global BII range between 0.7975 in 1970 and 0.7754 +# * in 2000. https://www.nhm.ac.uk/our-science/data/biodiversity-indicators/biodiversity-intactness-index-data +# * In MAgPIE, the global BII value is about 0.8 in 1995 and declines to 0.795 by 2020. + +# * Target value for BII in target year; plausible range: 0-1 +cfg$gms$s44_bii_target <- 0 #def = 0 + +# * Indicative outcomes for `s44_bii_target` based on c44_bii_decrease = 1, s44_start_year = 2025 and s44_target_year = 2100. +# * < 0.7: continued decrease of global BII +# * 0.74: no further decrease of global BII +# * 0.76: moderate increase of global BII +# * >= 0.78: (very) strong increase of global BII accomplished by high conversion of pasture to non-forest natural land + +# * BII lower bound implementation (binary) +# * options: 0 (no decrease allowed) or 1 (decrease allowed) +# * 0 (no decrease allowed): If the biome-level BII in `s44_start_year` exceeds the lower bound defined in `s44_bii_target, the BII value in the start year is used as lower bound for BII in all future time steps. +# * 1 (decrease allowed): The lower bound for BII can decrease over time, depending on the biome-level BII in the start year and the lower bound defined in `s44_bii_target. +# * Note: The BII constraint is defined as a minimum constraint. Therefore, the actual BII can be higher than the lower bound. +cfg$gms$c44_bii_decrease <- 1 #def = 1 + +# * Technical costs for missing BII increase (USD17MER per unit of BII) +cfg$gms$s44_cost_bii_missing <- 1000000 #def = 1000000 + +# ** Options for realization `bv_btc_mar21` + +# * Price for biodiversity stock loss/gain in target year (USD17MER per ha) +# * Plausible range: 0-10000 +# * Indicative outcomes +# * 0: decrease of BII +# * 3000: rather constant BII +# * 6000: moderate increase of BII +# * 10000: stronger increase of BII +cfg$gms$s44_target_price <- 0 #def = 0 + +# * Price for biodiversity stock loss/gain in start year (USD17MER per ha) +cfg$gms$s44_start_price <- 0 #def = 0 + # ***------------------------- 45_climate --------------------------------- # * (static): static koeppengeiger climate classification data @@ -386,36 +1444,106 @@ cfg$gms$climate <- "static" # def = static # ***------------------------- 50_nr_soil_budget -------------------------- # * (off): off -# * (exoeff_aug16): exogenous nr efficiency -cfg$gms$nr_soil_budget <- "exoeff_aug16" # def = exoeff_aug16 +# * (macceff_aug22): nr efficiency dependent on MACC curves +cfg$gms$nr_soil_budget <- "macceff_aug22" # def = macceff_aug22 + +# * Scenario for baseline nr efficiency (excluding additional improvements based +# * on marginal abatmeent cost curves) on croplands for selected (and +# * respectively non-selected) countries in cropneff_countries and pastneff_countries +# * +# * Options: +# * "constant", +# * Scenarios keep baseline NUE constant. +# * "baseeff_add3_add10_add20_max75", (SSP1) +# * "baseeff_add3_add5_add10_max65", (SSP2) +# * "baseeff_add3_add0_add0_max55", (SSP3) +# * "baseeff_add3_add10_add15_max75", (SSP4) +# * "baseeff_add3_add5_add15_max75", (SSP5) +# * "baseeff_add3_add15_add25_max65", (lowTech) +# * "baseeff_add3_add15_add25_max75", (MaxMitigation) +# * In the baseeff_add scenarios, the baseline NUE starts from historical +# * values in 2010. The three numbers signify how many percentage points +# * the efficiency increases until 2020,2050 and 2100, always relative to +# * 2010. The max efficiency is the maximum base efficiency in 2050 +# * and 2100. "baseeff_add3_add15_add25_max65" means that China with a +# * current NUE of 41 increases to 44% by 2010, 56% by 2050 and 65% by 2100, +# * while the USA, with a current NUE of 71% has a falling base NUE to 65% +# * by 2050 and 2100. These base NUEs can however be improved by the MACCs, +# * leading to a max NUE of 85% for both China and USA in 2100. +# * The recommmended mapping to storylines is shown above in brackets. +# * "maxeff_add3_glo75_glo85", "maxeff_add3_glo75_glo80", +# * "maxeff_add3_glo60_glo65", "maxeff_add3_glo65_glo75", +# * Scenarios with a globaly uniform target NUE. This target NUE is achieved +# * by the combination of full MACCs and baseline NUE. First number is the +# * again additive efficiency increase until 2020, second number is +# * max NUE in 2050, third in 2100. Example: maxeff_add3_glo75_glo85 +# * means efficiency increases a regional specific 3 percentag point +# * improvement until 2020, and then it achieves a globally uniform 75% +# * efficiency in y2050; the baseline NUE value is therefore about 63%, +# * while the MACCs can increase this to 75%. In 2100, the baseline NUE +# * increases to 74%, which can achieve 85% if combined with +# * the MACCs. +# * "maxeff_ZhangBy2030", "maxeff_ZhangBy2050" +# * These two scenarios reach the max NUE of Zhang et al under application +# * of the full MACCs by 2030 or 2050, and then rise a bit further to +# * achieve a maximum NUE of 80% by 2100. + +cfg$gms$c50_scen_neff <- "baseeff_add3_add5_add10_max65" # def = baseeff_add3_add5_add10_max65 +cfg$gms$c50_scen_neff_noselect <- "baseeff_add3_add5_add10_max65" # def = baseeff_add3_add5_add10_max65 + +# * 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 do not have a nutrient deficit are fertilized +# * (historical NUE may be low despite no fertilization) +# * Options: +# * constant, constant_min55_min60_min65 + +cfg$gms$c50_scen_neff_pasture <- "constant_min55_min60_min65" # def = constant_min55_min60_min65 +cfg$gms$c50_scen_neff_pasture_noselect <- "constant_min55_min60_min65" # def = constant_min55_min60_min65 + +# * Switch and specification of countries for which above defined (c50_scen_neff, +# * c50_scen_neff_pasture) apply, respectively. +# * For all other countries c50_scen_neff_noselect / c50_scen_neff_pasture_noselect +# * apply. +# * Options: list of iso-codes of countries where selected neff scenario should +# * be in effect. +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: above defined neff scenario applies to all iso countries +cfg$gms$cropneff_countries <- all_iso_countries +cfg$gms$pastneff_countries <- all_iso_countries -# * options: neff55_55_starty1990,neff60_60_starty1990,neff65_70_starty1990, -# * neff65_70_starty2010,neff60_60_starty2010,neff55_60_starty2010, -# * neff70_75_starty2010,neff75_80_starty2010,neff80_85_starty2010 -cfg$gms$c50_scen_neff <- "neff60_60_starty2010" # def = neff60_60_starty2010 -# * scenario for animal waste management. -# * option: "ssp1", "ssp2", "ssp3", "ssp4", "ssp5", "constant", "a1", "a2", "b1","b2" -cfg$gms$c55_scen_conf <- "ssp2" # def = ssp2 # ***--------------------- 51_nitrogen ------------------------------------ -# * (ipcc2006_sep16): IPCC based nitrogen implementation +# * (rescaled_jan21): IPCC emissions factors rescaled with efficiency # * (off): no nitrogen calculations -cfg$gms$nitrogen <- "ipcc2006_sep16" # def = ipcc2006_sep16 +cfg$gms$nitrogen <- "rescaled_jan21" # def = rescaled_jan21 + # ***--------------------- 52_carbon -------------------------------------- # * (normal_dec17): regrowth of carbon stocks in all c pools starts from pasture levels # * (off): carbon calculations deactivated 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), +# * nocc_hist (RCPBU until year defined in sm_fix_cc, fixed thereafter) +cfg$gms$c52_land_carbon_sink_rcp <- "RCPBU" + + # * carbon scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c52_carbon_scenario <- "nocc" # def = "nocc" +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +cfg$gms$c52_carbon_scenario <- "cc" # def = "cc" + +# * Minimum threshold of carbon density (tC/ha) in timber plantations +cfg$gms$s52_plantation_threshold <- 8 # def = 8 # ***--------------------- 53_methane ------------------------------------- -# * (ipcc2006_flexreg_apr16): IPCC 1996 methodology +# * (ipcc2006_aug22): IPCC 2006 methodology # * (off): methane calculations deactivated -cfg$gms$methane <- "ipcc2006_flexreg_apr16" # def = ipcc2006_flexreg_apr16 +cfg$gms$methane <- "ipcc2006_aug22" # def = ipcc2006_aug22 # ***--------------------- 54_phosphorus ---------------------------------- # * (off): calculations deactivated @@ -427,86 +1555,394 @@ cfg$gms$phosphorus <- "off" # def = off # * (off): deactivated animal waste management cfg$gms$awms <- "ipcc2006_aug16" # def = ipcc2006_aug16 +# * scenario for animal waste management. +# * option: "ssp1", "ssp2", "ssp3", "ssp4", "ssp5", "constant", "a1", "a2", "b1","b2", +#* "GoodPractice" +# * Note: c55_scen_conf applies to countries selected in scen_countries55 +# * c55_scen_conf_noselect applies to all other countries. +# * Available scenarios for c55_scen_conf_noselect are identical to c55_scen_conf +cfg$gms$c55_scen_conf <- "ssp2" # def = ssp2 +cfg$gms$c55_scen_conf_noselect <- "ssp2" # def = ssp2 + +# * Switch and specification of countries for which awm scenario in +# * c55_scen_conf applies. +# * Options: list of iso-codes of countries where awm scneario should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$scen_countries55 <- all_iso_countries + # ***--------------------- 56_ghg_policy ---------------------------------- -# * (price_jan19): GHG emission pricing with phase-in over 20 year period and depending on development state -cfg$gms$ghg_policy <- "price_jan19" # def = price_jan19 +# * (price_aug22): applies pollutant prices to different emission types and calculates the reward for CDR from afforestation +cfg$gms$ghg_policy <- "price_aug22" # def = price_aug22 -# * start year of GHG emission pricing phase-in (only used in price_jan19) -cfg$gms$s56_ghgprice_start <- 2025 # def = 2025 +# * Switch for scaling GHG price with development state (1=on 0=off) +cfg$gms$s56_ghgprice_devstate_scaling <- 0 # def = 0 # * reduction factor for CO2 price (only used in price_jan19) # * lowers the economic incentive for CO2 emission reduction (avoided deforestation) and afforestation -cfg$gms$s56_cprice_red_factor <- 0.5 # def = 0.5 - -# * GHG pollutant price scenario -# * Available scenarios: -# * R2M41-SSP2-Budg1300,R2M41-SSP2-Budg600, -# * R2M41-SSP2-Budg950,R2M41-SSP2-NDC,R2M41-SSP2-NPi, -# * SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, -# * SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, -# * SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, -# * SSPDB-SSP1-37-REMIND-MAGPIE, -# * SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, -# * SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, -# * SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, -# * SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, -# * SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, -# * SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, -# * SSPDB-SSP2-37-REMIND-MAGPIE, -# * SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, -# * SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, -# * SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, -# * SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, -# * SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, -# * SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, -# * SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, -# * SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, -# * SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, -# * SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, -# * SSPDB-SSP5-Ref-REMIND-MAGPIE, +cfg$gms$s56_cprice_red_factor <- 1 # def = 1 + +# * Switch for GHG policy fader (1=on 0=off) +cfg$gms$s56_ghgprice_fader <- 0 # def = 0 +# * Pollutants on which the GHG policy fader will applied +cfg$gms$pollutants_fader <- "co2_c, ch4, n2o_n_direct, n2o_n_indirect, nh3_n, no2_n, no3_n" # def = all pollutants +# * Start year of GHG policy fade-in +cfg$gms$s56_fader_start <- 2035 # def = 2035 +# * End year of GHG policy fade-in +cfg$gms$s56_fader_end <- 2050 # def = 2050 +# * Target value of GHG policy fade-in in end year +cfg$gms$s56_fader_target <- 1 # def = 1 +# * Switch for functional form of GHG policy fader (1=linear 2=sigmoid) +cfg$gms$s56_fader_functional_form <- 1 # def = 1 +# * Countries for which the GHG policy fader applies +# * Options: list of iso-codes of countries where ghg policy should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$fader_countries56 <- isoCountriesLowMiddleIncome # def = isoCountriesLowMiddleIncome + +# * 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 R34M410. +# * Available options: +# * none: no GHG prices +# * R34M410: Coupled REMIND-MAgPIE runs with REMIND 3.4.0.dev619 (dev version close to 3.5) and MAgPIE 4.10 +# * Note: SSP5 is provided but is no longer actively maintained and validated by REMIND +# * Note: See scripts/start/test_runs.R for mapping of NPi2025, PkBudg1050 and PkBudg650 to RCPs for SSP1/SSP2 and SSP3 +# * NPi2025: Current policies; limit peak warming to 3.0°C in SSP1 and SSP2, but not in SSP3. +# * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 +# * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 (not feasible for SSP3) +# * R34M410-SSP1-NPi2025, R34M410-SSP1-PkBudg1000, R34M410-SSP1-PkBudg650, +# * R34M410-SSP2-NPi2025, R34M410-SSP2-PkBudg1000, R34M410-SSP2-PkBudg650, +# * R34M410-SSP3-NPi2025, R34M410-SSP3-PkBudg1000, R34M410-SSP3-rollBack, +# * R34M410-SSP5-NPi2025, R34M410-SSP5-PkBudg1000, R34M410-SSP5-PkBudg650 +# * 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-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 +# * NDC: Nationally determined contributions; limit peak warming to 2.5°C +# * 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 +# * R21M42-SDP-NPi, R21M42-SDP-NDC, R21M42-SDP-PkBudg1000, R21M42-SDP-PkBudg1100, R21M42-SDP-PkBudg900, +# * R21M42-SSP1-NPi, R21M42-SSP1-NDC, R21M42-SSP1-PkBudg1100, R21M42-SSP1-PkBudg1300, R21M42-SSP1-PkBudg900, +# * R21M42-SSP2-NPi, R21M42-SSP2-NDC, R21M42-SSP2-PkBudg1100, R21M42-SSP2-PkBudg1300, R21M42-SSP2-PkBudg900, +# * R21M42-SSP5-NPi, R21M42-SSP5-NDC, 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 +# * R34BC: Standalone REMIND runs based on REMIND 3.4.0 and expanded by the implementation of biochar production +# * R34BC-SSP2-PkBudg650-BCdef, R34BC-SSP2-PkBudg650-BCdef-CTS01, +# * R34BC-SSP2-PkBudg650-BCdef-CTS01-BM70, R34BC-SSP2-PkBudg650-BCpess-CTS01-BM70 +# * Standalone REMIND runs from Strefler et al 2021; well-below 2.0°C in 2100 +# * https://www.nature.com/articles/s41467-021-22211-2 +# * PIK_GDP, PIK_H2C, PIK_HBL, PIK_HOS, PIK_LIN, PIK_NPI, PIK_OPT +# * SSP Database 2018, various SSP, RCP and Model combinations +# * https://tntcat.iiasa.ac.at/SspDb +# * Caution: using trajectories from other models or older MAgPIE versions might be +# * inconsistent with the current MAgPIE version. +# * SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, +# * SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, +# * SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, +# * SSPDB-SSP1-37-REMIND-MAGPIE, +# * SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, +# * SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, +# * SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, +# * SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, +# * SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, +# * SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, +# * SSPDB-SSP2-37-REMIND-MAGPIE, +# * SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, +# * SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, +# * SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, +# * SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, +# * SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, +# * SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, +# * SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, +# * SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, +# * SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, +# * SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, +# * SSPDB-SSP5-Ref-REMIND-MAGPIE, +# * Used for producing coupled runs with REMIND-MAgPIE or for exogenous input (see below) # * coupling -cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-NPi" # def = "R2M41-SSP2-NPi" - -# * Upper limit for CH4 and N2O GHG price (USD05MER per tC) +# * Note: c56_pollutant_prices applies to countries selected in policy_countries56 +# * 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 <- "R34M410-SSP2-NPi2025" # def = R34M410-SSP2-NPi2025 +cfg$gms$c56_pollutant_prices_noselect <- "R34M410-SSP2-NPi2025" # def = R34M410-SSP2-NPi2025 + +# * 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 +# * in the REMIND-MAgPIE coupling to read in the REMIND data. +# * Takes effect only if cfg$gms$c56_pollutant_prices is set to "coupling" + +# * Use ghg prices from the mif file specified here +cfg$path_to_report_ghgprices <- NA + +# * Mute GHG prices until (and including) the year given here +# * Note: minimum C price (see below) will be set regardless of this setting +cfg$gms$c56_mute_ghgprices_until <- "y2030" # def = y2030 + +# * Minium C price (USD17MER per tC) for all time steps to avoid sudden jumps in carbon stock changes +cfg$gms$s56_minimum_cprice <- 3.67 # def = 3.67 + +# * Switch and specification of countries for which pollutant pricing in +# * c56_pollutant_prices applies. +# * Options: list of iso-codes of countries where ghg policy should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +# * Note: Only for exogenous scenarios. Does not take any effect when "coupling" / +# * "emulator" is selected above. +cfg$gms$policy_countries56 <- all_iso_countries # def = all_iso_countries + +# * Switch for C price driven re/afforestation (1=on 0=off) +cfg$gms$s56_c_price_induced_aff <- 1 # def = 1 +# * Settings for optional temporal fade-in of C price driven re/afforestation between start and end year (linear interpolation) +# * Note: The default setting mutes the signal until and including 2030 +# * Start year of C price induced re/afforestation fade-in +cfg$gms$s56_fader_cpriceaff_start <- 2030 # def = 2030 +# * End year of C price induced re/afforestation fade-in +cfg$gms$s56_fader_cpriceaff_end <- 2030 # def = 2030 + +# * C price used as incentive for afforestation +# * Note: This setting should only be changed by experienced users +# * 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 <- "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) +# * reflects perfect-foresight if equal to s32_planning_horizon +# * should not be higher than s32_planning_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 +# * 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 (USD17MER per tC) # * Limits GHG prices selected in c56_pollutant_prices to the chosen value. -# * CH4 and N2O GHG prices are limited by default to 1000 USD05MER per tC equivalent, -# * which induces the maximum abatement possible in the 57_maccs module. -# * Beyond 1000 USD05MER per tC equivalent no further technical mitigation is possible -# * but would increase food prices. -cfg$gms$s56_limit_ch4_n2o_price <- 1000 # def = 1000 - -# * emission policies -# * options: none, all, ssp -# * ssp: CO2 emis from LUC in natveg; all CH4 and N2O emissions -cfg$gms$c56_emis_policy <- "ssp" # def = ssp - -# * Treatment of negative costs originating from negative co2 emissions -# * reward negative co2 emissions (-Inf) or not (0) -# * s56_reward_neg_emis is applied the on emission policy chosen in c56_emis_policy -# * In case of carbon pricing s56_reward_neg_emis = -Inf results in increase of other land -# * For runs with afforestation s56_reward_neg_emis should be 0 (default setting) -cfg$gms$s56_reward_neg_emis <- 0 # def = 0 +# * CH4 and N2O GHG prices are limited by default to 4920 USD17MER per tC equivalent, +# * which induces the maximum abatement possible with c57_macc_version = "PBL_2022" +# * Beyond 4920 USD17MER per tC equivalent no further technical mitigation is possible +# * but would increase agricultural prices. +# * Suggested limits for different c57_macc_version settings +# * PBL_2007: 1230 (200 steps, 5.615 USD each) +# * PBL_2019: 4920 (200 steps, 24.6 USD each) +# * PBL_2022: 4920 (200 steps, 24.6 USD each) +# * (values above are inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s56_limit_ch4_n2o_price <- 4920 # def = 4000 * 1.23 + +# * NOTE: The following 2 options for emission pricing have strong interactions in runs with CO2 prices and should only be changed by experienced users. +# * The main purpose of these options is to regulate the pricing of positive emissions. Note that re/afforestation is covered by a separate mechanism. + +# * GHG emission pricing policies +# * options: +# * none (not including any GHG sources), +# * redd_nosoil (Above ground CO2 emis from LUC in forest; all CH4 and N2O emissions), +# * redd_nosoil_nopeat (same as redd_nosoil but without GHG emissions from peatlands), +# * reddnatveg_nosoil (Above ground CO2 emis from LUC in forest and natveg; all CH4 and N2O emissions), +# * reddnatveg_nosoil_nopeat (same as reddnatveg_nosoil but without GHG emissions from peatlands), +# * redd+_nosoil (Above ground CO2 emis from LUC in forest and forestry; all CH4 and N2O emissions), +# * redd+_nosoil_nopeat (same as redd+_nosoil but without GHG emissions from peatlands), +# * redd+natveg_nosoil (Above ground CO2 emis from LUC in forest, forestry and natveg; all CH4 and N2O emissions), +# * redd+natveg_nosoil_nopeat (same as redd+natveg_nosoil but without GHG emissions from peatlands), +# * all (CO2 emis from LUC in all LUs; all CH4 and N2O emissions), all_nosoil (Above ground CO2 emis from LUC for all LUs; all CH4 and N2O emissions) +# * all_nosoil: Above ground CO2 emis from LUC for all LUs; all CH4 and N2O emissions +# * sdp_cropeff (only ch4 from rice), sdp_livestock (only ch4 and n2o from livestock), sdp_peatland (co2, ch4 and n2o from peatland), +# * sdp_redd (only co2 from vegc), sdp_soil (only co2 from litc and soilc), sdp_redd_soil (only co2 from vegc, litc, soilc), +# * sdp_redd_soil_peat (only co2 from vegc, litc, soilc and co2, ch4 and n2o from peatland), sdp_all (all individual sdp scenarios combined) +# * gcs_lbs (land-based mitigation: above-ground CO2 emis from LUC in forest, forestry and natveg; co2, ch4 and n2o from peatland), +# * gcs_res (mitigation in production systems: all agricultural non-CO2 emissions) +# * ecoSysProtAll: (Above ground CO2 emis from LUC in forest, forestry, natveg; All types of emis from peatland; All CH4 and N2O emis), +# * ecoSysProtForest: (Above ground CO2 emis from LUC in forest, forestry; All CH4 and N2O emis except peatland), +# * ecoSysProtPrimForest: (Above ground CO2 emis from LUC in primary forest; All CH4 and N2O emis except peatland), +# * ecoSysProtOff: (All CH4 and N2O emis except peatland), +# * 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 <- "reddnatveg_nosoil" # def = reddnatveg_nosoil + +# * CO2 emissions subject to carbon pricing +# * options: actual, actualNoAcEst +# * actual: CO2 emissions for pricing are based on the difference of actual carbon stocks between time steps +# * actualNoAcEst: CO2 emissions for pricing are based on actual carbon stocks but +# * without newly established forest and non-forest areas. Note that re/afforestation is covered by a separate mechanism. +c56_carbon_stock_pricing <- "actualNoAcEst" # def = actualNoAcEst + # ***--------------------- 57_maccs --------------------------------------- -# * (on_sep16): maccs for non-CO2 emission mitigation activated -# * (off_jul16): maccs for non-CO2 emission mitigation deactivated -cfg$gms$maccs <- "on_sep16" # def = on_sep16 +# * (on_aug22): maccs for non-CO2 emission mitigation activated +cfg$gms$maccs <- "on_aug22" # def = on_aug22 + +# * Version of MACCs +# * options: PBL_2007, PBL_2019, PBL_2022 +cfg$gms$c57_macc_version <- "PBL_2022" # def = PBL_2022 + +# * MACC scenario (only for PBL_2022) +# * options: Default, Optimistic, Pessimistic +cfg$gms$c57_macc_scenario <- "Default" # def = Default + +# * Exogenous forced mitigation, independent of pollutant prices +# * Overwrites signal of mitigation price by choosing maximum mitigation levels +# * This avoids that emission tax is rolled over to food prices, only the +# * the mitigaton costs are rolled over to prices. +# * options: -1, 1 to 201 for each MACC mitigation step +# * -1: pollutant-price driven maccs +# * 0: inactive MACCs (price level zero) +# * 201: maximum level of mitigation +cfg$gms$s57_maxmac_n_soil <- -1 # def = -1 +cfg$gms$s57_maxmac_n_awms <- -1 # def = -1 +cfg$gms$s57_maxmac_ch4_rice <- -1 # def = -1 +cfg$gms$s57_maxmac_ch4_entferm <- -1 # def = -1 +cfg$gms$s57_maxmac_ch4_awms <- -1 # def = -1 + +# ***--------------------- 58_peatland ------------------------------------ +# * (off): Peatland area and associated GHG emissions are assumed zero +# * (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 <- "v2" # def = v2 + +# * peatland rewetting +# * options: 0 (off) +# * Inf (on) +cfg$gms$s58_rewetting_switch <- Inf # def = Inf + +# * Share of drained peatland that can be rewetted per year. +# * The intention of this setting is to avoid implausibly high adhoc rewetting of degraded peatlands. +cfg$gms$s58_annual_rewetting_limit <- 0.02 # def = 0.02 + +# * Switch and specification of countries for selected policies in apply. +# * Options: list of iso-codes of countries where exogenous peatland rewetting should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries58 <- all_iso_countries + +# * Switch for exogenous peatland rewetting for selected countries (0=off, 1=on) +cfg$gms$s58_rewetting_exo <- 0 # def = 0 +# * Switch for exogenous peatland rewetting for all other countries (0=off, 1=on) +cfg$gms$s58_rewetting_exo_noselect <- 0 # def = 0 +# * The following default values for exogenous peatland rewetting are based on the +# * Nature Restoration Law (NRL): 30 % by 2030, 40% by 2040, 50% by 2050 +# * Start year for exogenous peatland rewetting +cfg$gms$s58_rewet_exo_start_year <- 2025 # def = 2025 +# * Target year for exogenous peatland rewetting +cfg$gms$s58_rewet_exo_target_year <- 2050 # def = 2050 +# * Start value for exogenous peatland rewetting as share of drained peatland in reference period +cfg$gms$s58_rewet_exo_start_value <- 0 # def = 0 +# * Target value for exogenous peatland rewetting as share of drained peatland in reference period +cfg$gms$s58_rewet_exo_target_value <- 0.5 # def = 0.5 + +# * Switch for exogenous protection of intact peatland for selected countries (0=off, 1=on) +cfg$gms$s58_intact_prot_exo <- 0 # def = 0 +# * Switch for exogenous protection of intact peatland for all other countries (0=off, 1=on) +cfg$gms$s58_intact_prot_exo_noselect <- 0 # def = 0 + +# * One-time and recurring costs for peatland rewetting (USD17MER per ha) +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate:1.23) +cfg$gms$s58_cost_rewet_onetime <- 1230 # def = 1000 * 1.23 +cfg$gms$s58_cost_rewet_recur <- 37 # def = 30 * 1.23 + +# * One-time and recurring costs for peatland drainage (USD17MER 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 <- 1230 # def = 1230 +cfg$gms$s58_cost_drain_rewet_onetime <- 0 # def = 0 +cfg$gms$s58_cost_drain_recur <- 0 # def = 0 + +# * Penalty for technical peatland balance term (USD17MER) +cfg$gms$s58_balance_penalty <- 1000000 # def = 1000000 + +# * 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 <- 2020 # def = 2020 # ***------------------------- 59_som ------------------------------------- -# * (off): off -# * (cellpool_aug16): soil organic matter pool on cellular level -cfg$gms$som <- "off" # def = off - -# * som scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c59_som_scenario <- "nocc" # def = "nocc" +# * (static_jan19): static soil carbon loss for cropland +# * (cellpool_jan23): dynamic soil organic matter pool on cellular level +# * with updated, regionalized stock change factors (IPCC guidelines 2019) +cfg$gms$som <- "cellpool_jan23" # def = cellpool_jan23 + +# * static realization switch + +# * options: cellular (use preprocessed cellular stock change factors) +# * cluster (use cshare_released on cluster within gams) +cfg$gms$c59_static_spatial_level <- "cellular" + +# * cellpool realization switches + +# * som climate impact scenario +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +cfg$gms$c59_som_scenario <- "cc" # def = "cc" + +# * irrigation feedback +# * options: on (higher carbon sequestration under irrigation) +# * off (no carbon sequestration under irrigation) +cfg$gms$c59_irrigation_scenario <- "on" # def = "on" + +# * Exogenous nr release through som loss (only in static realization) +# * options: constant (constant from 2020) +# * fadeout_2050 (fading out till 2050) +cfg$gms$c59_exo_scen <- "constant" + +# * Soil organic carbon management settings on cropland (only for cellpool_jan23) + +# * Switch and specification of countries for selected policies in apply. +# * Options: list of iso-codes of countries where SCM should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries59 <- all_iso_countries + +# * Switch for functional form of faders (1=linear 2=sigmoid) +cfg$gms$s59_fader_functional_form <- 1 # def = 1 + +# * Sigmoid fader for minimum area share of SCM on total cropland at cluster level +# * Minimum area share of SCM on total cropland in target year +# Note: s59_scm_target applies to countries selected in policy_countries29 +# s59_scm_target_noselect applies to all other countries. +cfg$gms$s59_scm_target <- 0 # def = 0 +cfg$gms$s59_scm_target_noselect <- 0 # def = 0 + +# * Start year of fader +cfg$gms$s59_scm_scenario_start <- 2025 # def = 2025 + +# * Target year of fader (year when full implementation is reached) +cfg$gms$s59_scm_scenario_target <- 2050 # def = 2050 + +# * Soil carbon management recurring cost (USD17MER per ha) +# * Soil carbon management practices on cropland involve increased crop residue inputs +# * through various agronomic practices. Literature estimates for these practices vary, +# * e.g., from 20 USD06MER per ha (Smith et al. 2008) to 90-115 USD21MER per ha +# * (Uludere Aragon et al. 2024), with a central estimate of 65 USD17MER per ha chosen +# * for this configuration. More details can be found in the input.gms file of the +# * corresponding realization +cfg$gms$s59_cost_scm_recur <- 65 # def = 65 # ***--------------------- 60_bioenergy ----------------------------------- # * (1stgen_priced_dec18): exogenous and price-based 1st generation bioenergy # * demand, 2nd generation residues exogeneous, # * 2nd generation betr and begr coupled with REMIND. -cfg$gms$bioenergy <- "1stgen_priced_dec18" # def = 1stgen_priced_dec18 +# * (1st2ndgen_priced_feb24): exogenous and price-based 1st generation bioenergy +# * demand, 2nd generation residues exogeneous, +# * 2nd generation betr and begr exogenous as well as price driven +cfg$gms$bioenergy <- "1st2ndgen_priced_feb24" # def = 1st2ndgen_priced_feb24 # * 1st generation bioenergy demand scenarios based on Lotze Campen (2014) # * (phaseout2020): increase until 2020, followed by phaseout until 2050 @@ -515,33 +1951,93 @@ cfg$gms$bioenergy <- "1stgen_priced_dec18" # def = 1stgen_priced_dec18 cfg$gms$c60_1stgen_biodem <- "const2020" # def = const2020 # * 2nd generation bioenergy demand scenario -# * Available scenarios: -# * R2M41-SSP2-Budg1300,R2M41-SSP2-Budg600, -# * R2M41-SSP2-Budg950,R2M41-SSP2-NDC,R2M41-SSP2-NPi, -# * SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, -# * SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, -# * SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, -# * SSPDB-SSP1-37-REMIND-MAGPIE, -# * SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, -# * SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, -# * SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, -# * SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, -# * SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, -# * SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, -# * SSPDB-SSP2-37-REMIND-MAGPIE, -# * SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, -# * SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, -# * SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, -# * SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, -# * SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, -# * SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, -# * SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, -# * SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, -# * SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, -# * SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, -# * SSPDB-SSP5-Ref-REMIND-MAGPIE, +# * Note: For best consistency it is recommended to use trajectories from the most recent +# * coupled REMIND-MAgPIE runs. Currently, this is R34M410. +# * Available options: +# * none: no 2nd generation bioenergy demand +# * R34M410: Coupled REMIND-MAgPIE runs with REMIND 3.4.0.dev619 (dev version close to 3.5) and MAgPIE 4.10 +# * Note: SSP5 is provided but is no longer actively maintained and validated by REMIND +# * Note: See scripts/start/test_runs.R for mapping of NPi2025, PkBudg1050 and PkBudg650 to RCPs for SSP1/SSP2 and SSP3 +# * NPi2025: Current policies; limit peak warming to 3.0°C in SSP1 and SSP2, but not in SSP3. +# * PkBudg1050: Peak Budget with 1050 GtCO2 until net-zero CO2 emissions; well-below 2.0°C in 2100 +# * PkBudg650: Peak Budget with 650 GtCO2 until net-zero CO2 emissions; well-below 1.5°C in 2100 (not feasible for SSP3) +# * R34M410-SSP1-NPi2025, R34M410-SSP1-PkBudg1000, R34M410-SSP1-PkBudg650, +# * R34M410-SSP2-NPi2025, R34M410-SSP2-PkBudg1000, R34M410-SSP2-PkBudg650, +# * R34M410-SSP3-NPi2025, R34M410-SSP3-PkBudg1000, R34M410-SSP3-rollBack, +# * R34M410-SSP5-NPi2025, R34M410-SSP5-PkBudg1000, R34M410-SSP5-PkBudg650 +# * 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-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 +# * NDC: Nationally determined contributions; limit peak warming to 2.5°C +# * 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 +# * R21M42-SDP-NPi, R21M42-SDP-NDC, R21M42-SDP-PkBudg1000, R21M42-SDP-PkBudg1100, R21M42-SDP-PkBudg900, +# * R21M42-SSP1-NPi, R21M42-SSP1-NDC, R21M42-SSP1-PkBudg1100, R21M42-SSP1-PkBudg1300, R21M42-SSP1-PkBudg900, +# * R21M42-SSP2-NPi, R21M42-SSP2-NDC, R21M42-SSP2-PkBudg1100, R21M42-SSP2-PkBudg1300, R21M42-SSP2-PkBudg900, +# * R21M42-SSP5-NPi, R21M42-SSP5-NDC, 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 +# * R34BC: Standalone REMIND runs based on REMIND 3.4.0 and expanded by the implementation of biochar production +# * R34BC-SSP2-PkBudg650-BCdef, R34BC-SSP2-PkBudg650-BCdef-CTS01, +# * R34BC-SSP2-PkBudg650-BCdef-CTS01-BM70, R34BC-SSP2-PkBudg650-BCpess-CTS01-BM70 +# * Standalone REMIND runs from Strefler et al 2021; well-below 2.0°C in 2100 +# * https://www.nature.com/articles/s41467-021-22211-2 +# * PIK_GDP, PIK_H2C, PIK_HBL, PIK_HOS, PIK_LIN, PIK_NPI, PIK_OPT +# * SSP Database 2018, various SSP, RCP and Model combinations +# * https://tntcat.iiasa.ac.at/SspDb +# * Caution: using trajectories from other models or older MAgPIE versions might be +# * inconsistent with the current MAgPIE version. +# * SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, +# * SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, +# * SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, +# * SSPDB-SSP1-37-REMIND-MAGPIE, +# * SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, +# * SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, +# * SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, +# * SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, +# * SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, +# * SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, +# * SSPDB-SSP2-37-REMIND-MAGPIE, +# * SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, +# * SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, +# * SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, +# * SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, +# * SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, +# * SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, +# * SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, +# * SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, +# * SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, +# * SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, +# * SSPDB-SSP5-Ref-REMIND-MAGPIE, +# * Used for producing coupled runs with REMIND-MAgPIE or for exogenous input (see below) # * coupling -cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-NPi" # def = R2M41-SSP2-NPi +# * 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 <- "R34M410-SSP2-NPi2025" # def = R34M410-SSP2-NPi2025 +cfg$gms$c60_2ndgen_biodem_noselect <- "R34M410-SSP2-NPi2025" # def = R34M410-SSP2-NPi2025 + +# * 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 +# * in the REMIND-MAgPIE coupling to read in the REMIND data. +# * Takes effect only if cfg$gms$c60_2ndgen_biodem is set to "coupling" +cfg$path_to_report_bioenergy <- NA + +# * Switch and specification of countries for which 2nd gen bioenergy demand +# * scenario applies. +# * Options: list of iso-codes of countries where scenario should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +# * Note: Only for exogenous scenarios. Does not take any effect when "coupling" / +# * "emulator" selected. +cfg$gms$scen_countries60 <- all_iso_countries # * residue demand for 2nd generation bioenergy scenarios # * options: ssp1, ssp2, ssp3, ssp4, ssp5, off @@ -552,26 +2048,168 @@ cfg$gms$c60_res_2ndgenBE_dem <- "ssp2" # def = ssp2 # * (0): global cfg$gms$c60_biodem_level <- 1 # def = 1 +# * Minimum dedicated 2nd generation bioenergy demand assumed in each region (mio. GJ per yr) +# * Without a minimum demand, there is the risk that some regions won't have a price for 2nd generation bioenergy. +# * Therefore, the minimum demand is of particular importance for the coupling with REMIND. +cfg$gms$s60_2ndgen_bioenergy_dem_min <- 1 # def = 1 + +# * First generation bioenergy subsidy (USD17MER per GJ) +# * The subsidy can simulate a perfectly elastic demand for bioenergy from the energy sector and should be used as a +# * default floor price that avoids the wastage of ethanal or oils in case that the demand for byproducts +# * (oilcake and brewers grains) exceeds the demand for these secondary products. As such, it also avoids unrealistic +# * price fluctuations connected to the inelastic demand for couple products. +# * The subsidy is constant over the historic and model horizon. +# * For bioenergy price sensitivity experiments using s60_bioenergy_1st_price, s60_bioenergy_1st_subsidy should be set to 0 +# * as the subsidy works as price floor, overwriting lower prices set by s60_bioenergy_1st_price. +cfg$gms$s60_bioenergy_1st_subsidy <- 6.5 # def = 6.5 + +# ** Options for realization `1st2ndgen_priced_feb24` + +# * GJ-based bioenergy subsidy (USD17MER per GJ), only used in 1st2ndgen_priced_feb24 +# * Target prices for 1st and 2nd gen bioenergy +# * These are used for bioenergy price sensitivy experiments. +# * Caution: Prices above production cost likely create feedback loops with endogenous 13_tc, switch to exogenous to avoid. +cfg$gms$s60_bioenergy_1st_price <- 0 # def = 0 +cfg$gms$s60_bioenergy_2nd_price <- 0 # def = 0 + +# * Shape of price curve towards defined target price, reached in 2100. For years where the 1st generation price is +# * below s60_bioenergy_1st_subsidy, s60_bioenergy_1st_subsidy is used instead. +# * Options: const, exp, lin +# * (const): constant price equal to target price +# * (exp): exponential implementation starting from 0.25 * target price in the first sm_fix_SSP2 year; steps <= sm_fix_SSP2 then fixed to 0. +# * (lin): linear implementation starting from 0 in the sm_fix_SSP2 year. +cfg$gms$c60_price_implementation <- "lin" # def = "lin" + + # ***--------------------- 62_material ------------------------------------ # * (exo_flexreg_apr16): default cfg$gms$material <- "exo_flexreg_apr16" -cfg$gms$c62_material_scenario <- "SSP2" +# * Biomass demand for bioplastics is based on a logistic curve projecting +# * bioplastic demand, which matches the historic demand in 2020, and is +# * defined by the maximum demand for bioplastics s62_max_dem_bioplastics +# * (in mio. tonnes) and the midpoint s62_midpoint_dem_bioplastics (i.e. +# * where bioplastic demand is half of the maximum demand). +# * If s62_include_bioplastic is set to 0, future biomass demand for bioplastic +# * production is not included. Otherwise, bioplastic demand is either kept +# * constant at the value of 2020 (if s62_max_dem_bioplastics is set to 0) +# * or follows a logistic curve with the specified maximum demand and +# * midpoint (s62_midpoint_dem_bioplastic). +# * Projected total plastic use in the "Global Ambiton" scneario of the OECD is +# * about 600 mio. tonnes in 2050 -> E.g. 200 mio. tonnes in 2050 could be a +# * reasonable (but ambitious) bioplastic scenario. With midpoint 2050 this +# * would mean s62_max_dem_bioplastic = 400. +cfg$gms$s62_include_bioplastic <- 1 # def = 1 +cfg$gms$s62_max_dem_bioplastic <- 0 # def = 0 +cfg$gms$s62_midpoint_dem_bioplastic <- 2050 # def = 2050 # ***--------------------- 70_livestock ----------------------------------- # * (fbask_jan16): default feed basket realization -cfg$gms$livestock <- "fbask_jan16" # def = fbask_jan16 +# * (fbask_jan16_sticky): feed basket realization using capital stocks as in sticky_feb18 +cfg$gms$livestock <- "fbask_jan16" # def = fbask_jan16 # * feed scenario -# * options: ssp1, ssp2, ssp3, ssp4, ssp5, constant -cfg$gms$c70_feed_scen <- "ssp2" # def = ssp2 +# * options: SSP: ssp1, ssp2, ssp3, ssp4, ssp5 +# * SDP: SDP, SDP_EI, SDP_MC, SDP_RC +# * other: constant +cfg$gms$c70_feed_scen <- "ssp2" # def = ssp2 + +# * Year until the pasture management factor is fixed to 1 +cfg$gms$s70_past_mngmnt_factor_fix <- "2005" # def = 2005 + +# * Ratio to adjust future pasture feed demand using scavenged feed sources +# * such as browse from forest and other land and thinning and weeding in cropland. +# * Applied only in regions with a high historical pasture balance flow (e.g., South & Central Asia). +cfg$gms$s70_scavenging_ratio <- 0.385 # def = 0.385 + +# * Treatment of feed balance flows for estimating future feed intake. +# * Values between 0 and 1 are allowed, where 0 means exclusion and 1 means +# * full inclusion of feed balance flows in intake calculations. +cfg$gms$s70_feed_intake_weight_balanceflow <- 1 # def = 1 + +# * Feed substitution scenarios. +# * Values between 0 and 1 are allowed, where 0 means no feed is substituted, +# * while 1 corresponds to a full substitution of feed items with SCP. +# * The functional form and the start and target years of the feed substitution +# * can be specified below +# * Cereal feed substituted by SCP +cfg$gms$s70_cereal_scp_substitution <- 0 # def = 0 +# * Fodder feed substituted by SCP +cfg$gms$s70_foddr_scp_substitution <- 0 # def = 0 + +# * Functional form of the feed substitution over time +# * options: 1 = linear substitution, 2 = sigmoid substitution +cfg$gms$s70_feed_subst_functional_form <- 1 # def = 1 +# * Start year of feed subsitution +cfg$gms$s70_feed_substitution_start <- 2025 # def = 2025 +# * Target year (year when target feed substitution is reached) +cfg$gms$s70_feed_substitution_target <- 2050 # def = 2050 + +# * Regional (reg) or global (glo) regression for livestock factor requirements. +# * Typically, the same version (glo or reg) should be chosen for c38_fac_req +# * for consistency. +cfg$gms$c70_fac_req_regr <- "glo" # def = glo + +# Settings only for realization `fbask_jan16_sticky` +cfg$gms$s70_multiplicator_capital_need <- 1 # def = 1 # ***--------------------- 71_disagg_lvst ----------------------------------- # * (off): default # * (foragebased_aug18): Disaggregation of livestock to cells # * with high pasture and fodder availability -cfg$gms$disagg_lvst <- "foragebased_aug18" # def = foragebased_aug18 - +# * (foragebased_jul23): Disaggregation of livestock to cells +# * with high pasture and fodder availability +# * (improved and flexibitized) +cfg$gms$disagg_lvst <- "foragebased_jul23" # def = foragebased_jul23 + + +# ***--------------------- 73_timber ----------------------------------- +# * (default): Demand and production of timber products +cfg$gms$timber <- "default" # def = default + +# Logical switch to turn on or off timber demand (wood and woodfuel). +# Note that "on" requires dynamic timber plantations (s32_hvarea=2 and s35_hvarea=2) +# for actual results. +# Vice-versa, in the "off" case, timber plantations should be static (s32_hvarea=0/1 and s35_hvarea=0/1) +# for a simplified representation of land demand for timber production from plantations +# (implicitly assuming the same rate for plantation harvest and establishment). +# * 1=on +# * 0=off +cfg$gms$s73_timber_demand_switch <- 1 # def = 1 + +# harvesting cost of industrial roundwood per ton of dry matter produced (USD17MER/tDM) +# based on https://unece.org/forests/prices: 60 EUR/m3 = 72 USD/m3; 72 USD/m3 / 0.6 = 120 USD/tDM +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s73_timber_prod_cost_wood <- 148 # def = 120 * 1.23 + +# harvesting cost of woodfuel per ton of dry matter produced (USD17MER/tDM) +# based on https://unece.org/forests/prices +# * (inflated from default originally in USD05 using USD05 --> USD17 inflation rate: 1.23) +cfg$gms$s73_timber_prod_cost_woodfuel <- 74 # def = 60 * 1.23 + +# Cost of production without using any land in case the model is running into infeasibilities. +# This is a last ditch effort for the model and the slack variable associated with this cost +# should not be used in a normally feasible model run (USD17MER/tDM) +cfg$gms$s73_free_prod_cost <- 1000000 # def = 1000000 + +# Switch for modifying woody biomass demand starting in 2035 +# * ("default") = Default paper demand +# * ("nopaper") = Diminishing paper demand +# * ("construction") = Higher demand for construction wood in future +cfg$gms$c73_wood_scen <- "default" # def = "default" + +# Building material demand +# * ("BAU") = Business as usual, only 0.5% of urban dwellers need timber buildings +# * ("10pc") = 10% of urban dwellers need timber buildings +# * ("50pc") = 50% of urban dwellers need timber buildings +# * ("90pc") = 90% of urban dwellers need timber buildings + +cfg$gms$c73_build_demand <- "BAU" # def = "BAU" + +# Linearized multiplier for scaling construction wood demand for easier demand +# scenario tests. The expansion factor is applied over next 80 years starting in +# 2020. +cfg$gms$s73_expansion <- 0 # def = 0 # ***------------------- 80_optimization ------------------------------------ # * (nlp_apr17): solve procedure solving the whole, nonlinear problem @@ -579,37 +2217,72 @@ cfg$gms$disagg_lvst <- "foragebased_aug18" # def = foragebased_ # * (lp_nlp_apr17): alternative approach in which the nonlinear terms are # * fixed first so that the linear problem can be solved # * before the full problem is solved +# * (nlp_par): Parallel optimization of regions. Allows to use higher +# * spatial resolution but works only with exogenous trade patterns +# * from a run with lower resolution solved with nlp_apr17. +# * Usage: add "extra/highres" as output script. This will start a +# * second model run with higher resolution. +# * Make sure that the cellular input file specified in +# * scripts/output/extra/highres.R exists. +# * See scripts/output/extra/highres.R for details. + cfg$gms$optimization <- "nlp_apr17" # def = nlp_apr17 # maximal number of solve iterations -cfg$gms$s80_maxiter <- 30 +cfg$gms$s80_maxiter <- 30 # def = 30 -# * (conopt3): conopt3 +# Solver settings only for realization `lp_nlp_apr17`. All other realizations use `conopt4`. # * (conopt4): conopt4 # * (conopt4+cplex): conopt4 followed by cplex with landdiff optimization # * (conopt4+conopt3): conopt4 followed by conopt3 cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 -# number of allowed non-optimal variables -# Should be set to 0 for GAMS version 25.x.x or earlier -# Should be set to Inf for GAMS version 26.x.x or later -cfg$gms$s80_num_nonopt_allowed <- Inf - # * 1: using optfile for specified solver settings # * 0: default settings (optfile will be ignored) -cfg$gms$s80_optfile <- 0 +cfg$gms$s80_optfile <- 1 # def = 1 + +# Solver setting Tol_Optimality (real): +# Optimality tolerance for reduced gradient when feasible. +# Range: [3.e-13, 1], Solver default: 1.e-7 +cfg$gms$s80_toloptimal <- 1.0e-8 # def = 1.0e-8 +# * Optional second solve statement (0=off, 1=on) +cfg$gms$s80_secondsolve <- 0 # def = 0 #*******************************END MODULE SETUP******************************** #### Other settings (e.g. clustering, gdx files, ...): #### +# Choosing scenario for coupling with MAGICC for emissions outside the food system +# (options) bjoernAR6_C_RemSDP-900-MagSSP1.mif, bjoernAR6_C_RemSSP1-1000-MagSDP.mif, +# bjoernAR6_C_SDP-NPi.mif, bjoernAR6_C_SDP-PkBudg1000.mif, +# bjoernAR6_C_SSP1-Base.mif, bjoernAR6_C_SSP1-NDC.mif, +# bjoernAR6_C_SSP1-NPi.mif, bjoernAR6_C_SSP1-PkBudg900.mif, +# bjoernAR6_C_SSP2-Base.mif, bjoernAR6_C_SSP2-NDC.mif, +# bjoernAR6_C_SSP2-NPi.mif, bjoernAR6_C_SSP2-PkBudg900.mif +cfg$magicc_emis_scen <- "bjoernAR6_C_SSP2-NDC.mif" + +# Years in which SEALS downscaling is applied +cfg$seals_years <- c(2020, 2050) + # Decide whether the runs should be run sequentially (TRUE), # or in parallel (FALSE) # NA means that this decision is taken automatically # (typically on cluster = FALSE and locally = TRUE) cfg$sequential <- NA +# Selection of QOS to be used for submitted runs on cluster. +# Will be ignored for all other runs. +# * options: short (24h max, 3 CPUs, no preemption) +# * short_highMem (same as short but with 16 CPUs and 80GB of memory) +# * medium (1 week max, 3 CPUs, no preemption) +# * priority (immediate start, 24h max, 3 CPUs, but slots limited to 5 in parallel) +# * priority_highMem (same as priority but with 16 CPUs and 80GB of memory) +# * standby (24h max, 3 CPUs, preemption possible) +# * standby_highMem (same as standby but with 16 CPUs and 80GB of memory) +# * NULL (educated guess of best option based on available resources) +cfg$qos <- NULL # def = NULL + # How should log information be treated? # (0:no output, 2:write to full.log 3:show in console) cfg$logoption <- 2 @@ -617,30 +2290,57 @@ cfg$logoption <- 2 # Should output.R generate output? # List of output scripts that should be used # Available scripts can be found in scripts/output/ -cfg$output <- c("rds_report","validation","interpolation") +cfg$output <- c("output_check", "extra/disaggregation", "rds_report") # Set the format for the results folder # :date: is a placeholder for the current time stamp (e.g. "results:date:") # :title: is a placeholder for the current run title (cfg$title) cfg$results_folder <- "output/:title::date:" +# Results folder used by the "highres.R" output script +# If NULL, the default set in "highres.R" is used (currently a subfolder in "output") +# To place highres runs directly in the "output" folder, change to "output" +# To place highres runs in a specific subfolder change to "output/HR" +cfg$results_folder_highres <- NULL + # Which files should be copied into the output folder? cfg$files2export <- list() # Files that should be copied before MAgPIE is started cfg$files2export$start <- c("input/info.txt", - "modules/10_land/input/avl_land.cs3", + "input/avl_land_full_t_0.5.mz", + "input/luh2_side_layers_0.5.mz", + "modules/14_yields/input/lpj_yields_0.5.mz", + "modules/22_land_conservation/input/wdpa_baseline_0.5.mz", + "modules/22_land_conservation/input/consv_prio_areas_0.5.mz", + "modules/29_cropland/input/avl_cropland_0.5.mz", + "modules/50_nr_soil_budget/input/f50_NitrogenFixationRateNatural_0.5.mz", + "modules/50_nr_soil_budget/input/f50_AtmosphericDepositionRates_0.5.mz", + "input/f34_urbanland_0.5.mz", + "modules/35_natveg/input/pot_forest_area_0.5.mz", "input/spatial_header.rda", "scripts/run_submit/submit.R", - "scripts/run_submit/submit.sh", + "scripts/run_submit/submit_*.sh", ".Rprofile", - "input/*.spam", + "input/clustermap*.rds", + "input/lpj_envflow_total_*.mz", + "input/lpj_watavail_total_*.mz", "input/validation.mif", "calib_*.cs3", - "input/spamplot_*.pdf") + "land_conversion_cost_calib_*.cs3", + "input/spamplot_*.pdf", + "input/regionmapping*.csv", + "input/kba_land_0.5.mz", + "input/f58_peatland_area_0.5.mz", + "input/MAPSPAM_croparea_0.5.mz", + "input/LUH3_croparea_0.5.mz") # Files that should be copied after the MAgPIE run is finished cfg$files2export$end <- NULL +# Expert use only, should not be set manually. Path to a renv.lock file +# defining the package environment for newly started runs. +cfg$renv_lock <- NULL + # Folder run statistics should be submitted to cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/magpie" @@ -648,9 +2348,15 @@ cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/magpie" # should usually not be changed cfg$model_name <- "MAgPIE" -# model version of the overall model (use extension "-rc" for release candidate -# and "-dev" for developer version) -cfg$model_version <- "4.0-rc" +# a list of additional information characterizing this run. Can be used +# to save relevant information about the run and can, in contrast to all other +# setting, contain list elements which do not exist in the reference +# configuration +cfg$info <- list() + +# Should the restart files of each iteration be kept in the output folder (TRUE) +# or deleted after the run finished (FALSE) +cfg$keep_restarts <- FALSE # Should the model run in developer mode? This will loosen some restrictions, # such as temporary toleration of coding etiquette violations diff --git a/config/fable.cfg b/config/fable.cfg deleted file mode 100644 index 47cd6a202b..0000000000 --- a/config/fable.cfg +++ /dev/null @@ -1,661 +0,0 @@ -# | (C) 2008-2019 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 - -################## -#### SETTINGS #### -################## - -cfg <- list() - -#### Main settings #### - -# short description of the actual run -cfg$title <- "fable_ind" - -# path to the submodel to be used relative to main model folder -cfg$model <- "main.gms" #def = "main.gms" - -#### input settings #### - -# which input data sets should be used? - -cfg$input <- "magpie4.1_ind_apr19.tgz" - - -#a list of repositories (please pay attention to the list format!) in which the -#files should be searched for. Files will be searched in all repositories until -#found, always starting with the first repository in the list. The argument must -#have the format of a named list with the url of the repository as name and a -#corresponding list of options such as username or password to access the -#repository as value. If no options are required the value has to be NULL. (e.g. -#list("ftp://my_pw_protected_server.de/data"=list(user="me",password=12345), -# "http://free_server.de/dat"=NULL)) -#Please add system or user specific repositories (such as repos with limited -#access for) through the R option "magpie_repos". Through the append command -#below it will get merged into cfg$repositories - -cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public"=NULL), - getOption("magpie_repos")) - - -# Should input data be downloaded from source even if cfg$input did not change? -cfg$force_download <- FALSE - -# Settings for the yield calibration -# * (TRUE): Yield calibration will be performed -# * (ifneeded): Yield calibration will only be executed if input data is -# * downloaded from repository -# * (FALSE): Yield calibration will not be performed -cfg$recalibrate <- "ifneeded" # def = "ifneeded" -# 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 -# factor determining how much the new calibration factor influences the result -# (0-1) -cfg$damping_factor <- 0.98 # def= 0.98 -# switch on/of calibration of cropland (pasture will be left untouched) -cfg$calib_cropland <- TRUE # def= TRUE - - -# Settings for NPI/NDC recalculation -# * (TRUE): NPI/NDC recalculation will be performed -# * (ifneeded): NPI/NDC recalculation will only be executed if current input files are zero -# * and policy switches (p32_aff_pol, p35_ad_pol, p35_emis_pol) are set to "npi" or "ndc". -# * If policy switches are set to "none" (default) NPI/NDC recalculation will not be performed -# * (FALSE): NPI/NDC recalculation will not be performed -cfg$recalc_npi_ndc <- "ifneeded" # def = ifneeded -# * which national or subnational mappinng should be used -# * (iso): policies on the national levels -# * (bra): includes subnational policies for Brazil -cfg$policyregions <- "bra" # def = "bra" - -#### magpie.gms settings #### -cfg$gms <- list() - -# Set number of time steps (1-16) or type "less_TS" for remind time steps -cfg$gms$c_timesteps <- "coup2100" - -# use of gdx files -cfg$gms$s_use_gdx <- 2 # def = 2 -#* 0: gdx will not be loaded -#* 1: gdx is loaded in the first time step -#* 2: gdx is loaded in all time steps - -# **---------------------------------------------------------------------------- -# *** MODULES -# ***--------------------------------------------------------------------------- - -# ***--------------------- 09_drivers ---------------------------------------- -# * (aug17): default drivers -cfg$gms$drivers <- "aug17" # def = aug17 -cfg$gms$c09_pop_scenario <- "SSP2" # def = SSP2 -cfg$gms$c09_gdp_scenario <- "SSP2" # def = SSP2 -# * options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" -# * SRES: "A1", "A2", "B1", "B2" - -# ***--------------------- 10_land ---------------------------------------- -# * (feb15): default land realization -cfg$gms$land <- "feb15" # def = feb15 - - -# ***--------------------- 11_costs ------ -------------------------------- -# * (default): default cost realization -cfg$gms$costs <- "default" # def = default - -# ***--------------------- 12_interest_rate --------------------------------- -# * (glo_jan16): global interest rates - annuity calculated with macro m_annuity -# * (reg_feb18): regional interest rates, dependent on development state - -cfg$gms$interest_rate <- "reg_feb18" # def = reg_feb18 - -# * interest rate scenario: low, medium, high or mixed -# * This only has effects on glo_jan16 realization, but for the coupling in both realizations -cfg$gms$c12_interest_rate <- "medium" # def = "medium" - -# ***--------------------- 13_tc ----------------------------------------- -# * (endo_jun18): endogenous technological change with full cost accounting and -# * stepwise updated crop area information -cfg$gms$tc <- "endo_jun18" # def = endo_jun18 - -# * tc cost scenario: low, medium or high -cfg$gms$c13_tccost <- "medium" - -# ***--------------------- 14_yield -------------------------------------- -# * (biocorrect): cropland TC applied on pasture yields -# * (dynamic_aug18): pasture yields increase based on exogenuous demand-side proxy -# * for growth rate of cattle stocks -cfg$gms$yields <- "dynamic_aug18" # def = dynamic_aug18 - -# * yield scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c14_yields_scenario <- "nocc" # def = "nocc" - -# * switch determing the effectivity of translating crop tc into pasture yield -# * increase. Value has to be in the range of 0 (no pasture yield growth) -# * and 1 (pasture yields increase linearily with tau) -# * only used in biocorrect realization -cfg$gms$s14_yld_past_switch <- 0.25 # def = 0.25 - -# ***--------------------- 15_food --------------------------------------- -# * (anthropometrics_jan18): estimates food using scenario dependent regression -# * and demography drivers -cfg$gms$food <- "anthropometrics_jan18" # def = anthropometrics_jan18 - -# * maximal number of iterations between food and magpie model before -# * simulation proceeds to next time step -cfg$gms$s15_maxiter <- 5 # def = 5 - -# * convergence criteria: maximal allowed country-wise deviation in calculated -# * real income between iterations -cfg$gms$s15_convergence <- 0.005 # def = 0.005 - -# * switch between exogenous and endogenous food demand -# * options: 0 (exogenous food demand) and 1 (endogenous food demand) -cfg$gms$s15_elastic_demand <- 1 # def =1 - -# * food scenario -# * options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" -# * SRES: "A1", "A2", "B1", "B2" -# * OTHER: "PB" (planetary boundaries) -cfg$gms$c15_food_scenario <- "SSP2" # def = SSP2 - -# * ruminant meat share scenario -# * options: constant, halving2050, mixed -cfg$gms$c15_rumscen <- "mixed" # def = mixed - -# ***--------------------- 16_demand ------------------------------------- -# * (sector_may15): default for flexible regions -cfg$gms$demand <- "sector_may15" # def = sector_may15 - -# ***--------------------- 17_production --------------------------------- -# * (flexreg_apr16): default production aggregation -cfg$gms$production <- "flexreg_apr16" # def = flexreg_apr16 - -# ***--------------------- 18_residues ----------------------------------- -# * (flexreg_apr16): detailed residue calculations -# * (off): off -cfg$gms$residues <- "flexreg_apr16" # def = flexreg_apr16 - -# * residue on field burning -# * options: phaseout - phaseout of residue burning to minimum burn share (0-10%) -# * constant - constant shares of on field burning (15-25%) -cfg$gms$c18_burn_scen <- "phaseout" # def = phaseout - - -# ***--------------------- 20_processing --------------------------------- -# * (substitution_dec18) : processing with couple products allowing for substitution -# * (off): off -cfg$gms$processing <- "substitution_dec18" # def = substitution_dec18 - -# ***--------------------- 21_trade -------------------------------------- -# * (free_apr16): free trade without restrictions -# * (off): no trade at all -# * (selfsuff_reduced): self-sufficiency based trade with trade costs related -# * to exports -cfg$gms$trade <- "selfsuff_reduced" # def = selfsuff_reduced - -# * trade balance reduction scenario -# * (l909090r808080): 10 percent trade liberalisation for secondary and -# * livestock products in 2030,2050,2100 and 20 percent for -# * crops -# * (l908080r807070): livestock/secondary: 10% in 2030, 20% in 2050,2100 -# * crops: 20% in 2030, 30% in 2050,2100 -# * (l909595r909090): livestock/secondary: 10% in 2030, 5% in 2050,2100 -# * crops: 20% in 2030, 10% in 2050,2100 -cfg$gms$c21_trade_liberalization <- "l909090r808080" # def = l909090r808080 - -# * whether trade tariff should be considered -# * (0) without trade tariff -# * (1) with trade tariff -cfg$gms$s21_trade_tariff <- 1 # def =1 - -# ***--------------------- 30_crop --------------------------------------- -# * (endo_jun13): dynamic cropland -cfg$gms$crop <- "endo_jun13" # def = endo_jun13 - -# ***--------------------- 31_past --------------------------------------- -# * (static): static pasture -# * (endo_jun13): dynamic pasture -cfg$gms$past <- "endo_jun13" # def = endo_jun13 - -# * Factor requirements (US$04 per ton DM) -cfg$gms$s31_fac_req_past <- 1 # def = 1 - -# ***--------------------- 32_forestry ----------------------------------- -# * (static_sep16) : static forestry sector -# * (affore_vegc_dec16): static forestry sector + afforestation -cfg$gms$forestry <- "affore_vegc_dec16" # def = affore_vegc_dec16 - -# * afforestation planing horizon (years) -cfg$gms$s32_planing_horizon <- 80 # def = 80 - -# Afforestation policy -# * ("none"): no prescribed afforestation -# * ("npi"): prescribed afforestation based on NPI policies -# * ("ndc"): prescribed afforestation based on NPI+NDC policies -cfg$gms$c32_aff_policy <- "npi" # def = "none" - -# maximum total global afforestation in Mha (Inf = no constraint) -cfg$gms$s32_max_aff_area <- Inf # def = Inf - -# Switch to determine whether afforestation should be limited to -# certain latitudinal zones -# * ("unrestricted"): No regions excluded -# * ("noboreal"): Exclude boreal regions > 50deg N -# * ("onlytropical"): Afforestation only in tropical areas 20deg S-20deg N -cfg$gms$c32_aff_mask <- "noboreal" # def = "noboreal" - -# ***--------------------- 34_urban --------------------------------------- -# * (static): static urban -cfg$gms$urban <- "static" # def = static - -# ***--------------------- 35_natveg -------------------------------------- -# * 35_natveg includes primforest, secdforest and other land -# * (static): static natveg land -# * (dynamic_may18): dynamic natveg land -cfg$gms$natveg <- "dynamic_may18" # def = dynamic_may18 - -# * protected areas (primforest,secdforest,other land) -# * (WDPA) WDPA IUCN catI+II -# * (BH) Biodiversity Hotspots + WDPA -# * (FF) Frontier Forests + WDPA -# * (CPD) Centres of Plant Diversity + WDPA -# * (LW) last of the wild + WDPA -# * (none) no protection -# * (forest) forest protection (primforest+secdforest) -# * (full) full protection -cfg$gms$c35_protect_scenario <- "WDPA" # def = WDPA - -# Avoided Deforestation policy -# * ("none"): no avoided deforestation -# * ("npi"): avoided deforestation based on NPI policies -# * ("ndc"): avoided deforestation based on NPI+NDC policies -cfg$gms$c35_ad_policy <- "npi" # def = "npi" - -# Avoided Other Land Conversion policye -# * ("none"): no avoided other land conversion -# * ("npi"): avoided other land conversion based on NPI policies -# * ("ndc"): avoided other land conversion based on NPI+NDC policies -cfg$gms$c35_aolc_policy <- "npi" # def = "npi" - - -# ***--------------------- 38_factor_costs ------------------------------- -# * (fixed_per_ton_mar18): factor costs fixed per ton -# * (mixed_feb17): reimplementation of MAgPIE 3.0 default -cfg$gms$factor_costs <- "mixed_feb17" # default = mixed_feb17 - -# ***--------------------- 39_landconversion ----------------------------- -# * (global_static_aug18): global static land conversion costs for establishment -# * and land clearing -cfg$gms$landconversion <- "global_static_aug18" # def = global_static_aug18 - -# ***--------------------- 40_transport ---------------------------------- -# * (off): no transport costs -# * (gtap_nov12): transport costs applied to crops and ruminant livestock -# * products calibrated based on magpie-output (dynamic pasture) -# * to match GTAP data -cfg$gms$transport <- "gtap_nov12" # def = gtap_nov12 - -# * scalar to introduce pasture transport costs -cfg$gms$s40_pasture_transport_costs <- 0 # def = 0 - -# ***--------------------- 41_area_equipped_for_irrigation --------------- -# * (static): no expansion -# * (endo_apr13): endogenous, cost driven expansion -cfg$gms$area_equipped_for_irrigation <- "endo_apr13" # def = endo_apr13 - -# ***--------------------- 42_water_demand -------------------------------- -# * (agr_sector_aug13): fixed fraction of water available is reserved -# * for other uses -# * (all_sectors_aug13): industrial, eletricity and domestic demand are -# * retrieved from WATERGAP data. -cfg$gms$water_demand<- "agr_sector_aug13" # def = agr_sector_aug13 - -# * water demand scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c42_watdem_scenario <- "nocc" # def = "nocc" - -# * Choice of fraction of available water that is not -# * available for agriculture (only affects agr_sector_aug13 realization) -cfg$gms$s42_reserved_fraction <- 0.5 # def = 0.5 - -# * Scenario for non agricultural water demand from WATERGAP -# * (only affects all_sector_aug13 realization) -# * (1): SSP2 -# * (2): A2 -# * (3): B1 -cfg$gms$s42_watdem_nonagr_scenario <- 1 # def = 1 - -# * Switch to determine the irrigation efficiency scenario -# * (1): global static value -# * (2): regional static values from gdp regression -# * (3): gdp driven increase -cfg$gms$s42_irrig_eff_scenario <- 1 # def = 1 - -# * Environmental flow protection policy -# * (off): no EFP policy -# * (on): global EFP policy starting in 2015 -# * (mixed): EFP policy starting in 2015 only in hic regions -cfg$gms$c42_env_flow_policy <- "off" # def = "off" - -# * Environmental flow protection scenario -# * (0): do not consider environmental flows. -# * s42_env_flow_base_fraction and -# * s42_env_flow_fraction have no effect. -# * (1): Reserve a certain fraction of available water -# * specified by s42_env_flow_fraction for -# * environmental flows -# * (2): Each grid cell receives its own value for -# * environmental flow protection based on LPJ -# * results and a calculation algorithm by Smakhtin 2004. -# * s42_env_flow_fraction has no effect. -cfg$gms$s42_env_flow_scenario <- 2 # def = 2 - -# * Fraction of available water that is reserved for the environment -# * in case of a protection policy -# * In which regions and timesteps a protection policy is in place is determined -# * in the file EFR_protection_policy.csv in the input folder -# * of the 42_water_demand module -cfg$gms$s42_env_flow_fraction <- 0.2 # def = 0.2 - -# * Fraction of available water that is reserved for the environment in case of -# * missing protection policy -cfg$gms$s42_env_flow_base_fraction <- 0.05 # def = 0.05 - -# ***--------------------- 43_water_availability -------------------------- -# * (total_water_aug13): surface and ground water resources available -cfg$gms$water_availability <- "total_water_aug13" # def = total_water_aug13 - -# * water availability scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c43_watavail_scenario <- "nocc" # def = "nocc" - -# ***------------------------- 45_climate --------------------------------- -# * (static): static koeppengeiger climate classification data -cfg$gms$climate <- "static" # def = static - -# ***------------------------- 50_nr_soil_budget -------------------------- -# * (off): off -# * (exoeff_aug16): exogenous nr efficiency -cfg$gms$nr_soil_budget <- "exoeff_aug16" # def = exoeff_aug16 - -# * options: neff55_55_starty1990,neff60_60_starty1990,neff65_70_starty1990, -# * neff65_70_starty2010,neff60_60_starty2010,neff55_60_starty2010, -# * neff70_75_starty2010,neff75_80_starty2010,neff80_85_starty2010 -cfg$gms$c50_scen_neff <- "neff60_60_starty2010" # def = neff60_60_starty2010 - -# ***--------------------- 51_nitrogen ------------------------------------ -# * (ipcc2006_sep16): IPCC based nitrogen implementation -# * (off): no nitrogen calculations -cfg$gms$nitrogen <- "ipcc2006_sep16" # def = ipcc2006_sep16 - -# ***--------------------- 52_carbon -------------------------------------- -# * (normal_dec17): regrowth of carbon stocks in all c pools starts from pasture levels -# * (off): carbon calculations deactivated -cfg$gms$carbon <- "normal_dec17" # def = normal_dec17 - -# * carbon scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c52_carbon_scenario <- "nocc" # def = "nocc" - -# ***--------------------- 53_methane ------------------------------------- -# * (ipcc2006_flexreg_apr16): IPCC 1996 methodology -# * (off): methane calculations deactivated -cfg$gms$methane <- "ipcc2006_flexreg_apr16" # def = ipcc2006_flexreg_apr16 - -# ***--------------------- 54_phosphorus ---------------------------------- -# * (off): calculations deactivated -cfg$gms$phosphorus <- "off" # def = off - -# ***--------------------- 55_awms --------------------------------------- -# * (ipcc2006_aug16): animal waste management systems -# * (based on IPCC 2006 Guidelines) -# * (off): deactivated animal waste management -cfg$gms$awms <- "ipcc2006_aug16" # def = ipcc2006_aug16 - -# ***--------------------- 56_ghg_policy ---------------------------------- -# * (price_jan19): GHG emission pricing with phase-in over 20 year period and depending on development state -cfg$gms$ghg_policy <- "price_jan19" # def = price_jan19 - -# * start year of GHG emission pricing phase-in (only used in price_jan19) -cfg$gms$s56_ghgprice_start <- 2025 # def = 2025 - -# * reduction factor for CO2 price (only used in price_jan19) -# * lowers the economic incentive for CO2 emission reduction (avoided deforestation) and afforestation -cfg$gms$s56_cprice_red_factor <- 0.5 # def = 0.5 - -# * GHG pollutant price scenario -# * Available scenarios: -# * R2M41-SSP2-Budg1300,R2M41-SSP2-Budg600, -# * R2M41-SSP2-Budg950,R2M41-SSP2-NDC,R2M41-SSP2-NPi, -# * SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, -# * SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, -# * SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, -# * SSPDB-SSP1-37-REMIND-MAGPIE, -# * SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, -# * SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, -# * SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, -# * SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, -# * SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, -# * SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, -# * SSPDB-SSP2-37-REMIND-MAGPIE, -# * SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, -# * SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, -# * SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, -# * SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, -# * SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, -# * SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, -# * SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, -# * SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, -# * SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, -# * SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, -# * SSPDB-SSP5-Ref-REMIND-MAGPIE, -# * coupling -cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-NPi" # def = "R2M41-SSP2-NPi" - -# * Upper limit for CH4 and N2O GHG price (USD05MER per tC) -# * Limits GHG prices selected in c56_pollutant_prices to the chosen value. -# * CH4 and N2O GHG prices are limited by default to 1000 USD05MER per tC equivalent, -# * which induces the maximum abatement possible in the 57_maccs module. -# * Beyond 1000 USD05MER per tC equivalent no further technical mitigation is possible -# * but would increase food prices. -cfg$gms$s56_limit_ch4_n2o_price <- 1000 # def = 1000 - -# * emission policies -# * options: none, all, ssp -# * ssp: CO2 emis from LUC in natveg; all CH4 and N2O emissions -cfg$gms$c56_emis_policy <- "ssp" # def = ssp - -# * Treatment of negative costs originating from negative co2 emissions -# * reward negative co2 emissions (-Inf) or not (0) -# * s56_reward_neg_emis is applied the on emission policy chosen in c56_emis_policy -# * In case of carbon pricing s56_reward_neg_emis = -Inf results in increase of other land -# * For runs with afforestation s56_reward_neg_emis should be 0 (default setting) -cfg$gms$s56_reward_neg_emis <- 0 # def = 0 - -# ***--------------------- 57_maccs --------------------------------------- -# * (on_sep16): maccs for non-CO2 emission mitigation activated -# * (off_jul16): maccs for non-CO2 emission mitigation deactivated -cfg$gms$maccs <- "on_sep16" # def = on_sep16 - -# ***------------------------- 59_som ------------------------------------- -# * (off): off -# * (cellpool_aug16): soil organic matter pool on cellular level -cfg$gms$som <- "off" # def = off - -# * som scenario -# * options: cc (climate change) -# * nocc (no climate change) -cfg$gms$c59_som_scenario <- "nocc" # def = "nocc" - -# ***--------------------- 60_bioenergy ----------------------------------- -# * (1stgen_priced_dec18): exogenous and price-based 1st generation bioenergy -# * demand, 2nd generation residues exogeneous, -# * 2nd generation betr and begr coupled with REMIND. -cfg$gms$bioenergy <- "1stgen_priced_dec18" # def = 1stgen_priced_dec18 - -# * 1st generation bioenergy demand scenarios based on Lotze Campen (2014) -# * (phaseout2020): increase until 2020, followed by phaseout until 2050 -# * (const2020): increase until 2020, constant thereafter -# * (const2030): increase until 2030, constant thereafter -cfg$gms$c60_1stgen_biodem <- "const2020" # def = const2020 - -# * 2nd generation bioenergy demand scenario -# * Available scenarios: -# * R2M41-SSP2-Budg1300,R2M41-SSP2-Budg600, -# * R2M41-SSP2-Budg950,R2M41-SSP2-NDC,R2M41-SSP2-NPi, -# * SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, -# * SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, -# * SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, -# * SSPDB-SSP1-37-REMIND-MAGPIE, -# * SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, -# * SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, -# * SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, -# * SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, -# * SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, -# * SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, -# * SSPDB-SSP2-37-REMIND-MAGPIE, -# * SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, -# * SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, -# * SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, -# * SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, -# * SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, -# * SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, -# * SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, -# * SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, -# * SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, -# * SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, -# * SSPDB-SSP5-Ref-REMIND-MAGPIE, -# * coupling -cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-NPi" # def = R2M41-SSP2-NPi - -# * residue demand for 2nd generation bioenergy scenarios -# * options: ssp1, ssp2, ssp3, ssp4, ssp5, off -cfg$gms$c60_res_2ndgenBE_dem <- "ssp2" # def = ssp2 - -# * bioenergy demand level -# * (1): regional -# * (0): global -cfg$gms$c60_biodem_level <- 1 # def = 1 - -# ***--------------------- 62_material ------------------------------------ -# * (exo_flexreg_apr16): default -cfg$gms$material <- "exo_flexreg_apr16" - -cfg$gms$c62_material_scenario <- "SSP2" - -# ***--------------------- 70_livestock ----------------------------------- -# * (fbask_jan16): default feed basket realization -cfg$gms$livestock <- "fbask_jan16" # def = fbask_jan16 - -# * feed scenario -# * options: ssp1, ssp2, ssp3, ssp4, ssp5, constant -cfg$gms$c70_feed_scen <- "ssp2" # def = ssp2 - -# ***--------------------- 71_disagg_lvst ----------------------------------- -# * (off): default -# * (foragebased_aug18): Disaggregation of livestock to cells -# * with high pasture and fodder availability -cfg$gms$disagg_lvst <- "foragebased_aug18" # def = foragebased_aug18 - - -# ***------------------- 80_optimization ------------------------------------ -# * (nlp_apr17): solve procedure solving the whole, nonlinear problem -# * at once -# * (lp_nlp_apr17): alternative approach in which the nonlinear terms are -# * fixed first so that the linear problem can be solved -# * before the full problem is solved -cfg$gms$optimization <- "nlp_apr17" # def = nlp_apr17 - -# maximal number of solve iterations -cfg$gms$s80_maxiter <- 30 - -# * (conopt3): conopt3 -# * (conopt4): conopt4 -# * (conopt4+cplex): conopt4 followed by cplex with landdiff optimization -# * (conopt4+conopt3): conopt4 followed by conopt3 -cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 - -# number of allowed non-optimal variables -# Should be set to 0 for GAMS version 25.x.x or earlier -# Should be set to Inf for GAMS version 26.x.x or later -cfg$gms$s80_num_nonopt_allowed <- Inf - -# * 1: using optfile for specified solver settings -# * 0: default settings (optfile will be ignored) -cfg$gms$s80_optfile <- 0 - - -#*******************************END MODULE SETUP******************************** - -#### Other settings (e.g. clustering, gdx files, ...): #### - -# Decide whether the runs should be run sequentially (TRUE), -# or in parallel (FALSE) -# NA means that this decision is taken automatically -# (typically on cluster = FALSE and locally = TRUE) -cfg$sequential <- NA - -# How should log information be treated? -# (0:no output, 2:write to full.log 3:show in console) -cfg$logoption <- 2 - -# Should output.R generate output? -# List of output scripts that should be used -# Available scripts can be found in scripts/output/ -cfg$output <- c("rds_report","interpolation") - -# Set the format for the results folder -# :date: is a placeholder for the current time stamp (e.g. "results:date:") -# :title: is a placeholder for the current run title (cfg$title) -cfg$results_folder <- "output/:title::date:" - -# Which files should be copied into the output folder? -cfg$files2export <- list() -# Files that should be copied before MAgPIE is started -cfg$files2export$start <- c("input/info.txt", - "modules/10_land/input/avl_land.cs3", - "input/spatial_header.rda", - "scripts/run_submit/submit.R", - "scripts/run_submit/submit.sh", - ".Rprofile", - "input/*.spam", - "input/validation.mif", - "calib_*.cs3", - "input/spamplot_*.pdf") - -# Files that should be copied after the MAgPIE run is finished -cfg$files2export$end <- NULL - -# Folder run statistics should be submitted to -cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/magpie" - -# name of the overall model (just used for reporting purposes) -# should usually not be changed -cfg$model_name <- "MAgPIE" - -# model version of the overall model (use extension "-rc" for release candidate -# and "-dev" for developer version) -cfg$model_version <- "4.0-rc" - -# Should the model run in developer mode? This will loosen some restrictions, -# such as temporary toleration of coding etiquette violations -# Please make sure to set it to FALSE for production runs! -cfg$developer_mode <- FALSE - -# Should the model run in debug mode? -# Download script will copy files from input to destination folder instead of -# moving it allowing to check whether something in the move/copy process goes -# wrong -cfg$debug <- FALSE - -################################################################################ diff --git a/config/projects/scenario_config_el2.csv b/config/projects/scenario_config_el2.csv new file mode 100644 index 0000000000..17689d8a48 --- /dev/null +++ b/config/projects/scenario_config_el2.csv @@ -0,0 +1,24 @@ +;EL2_PHD;EL2_Demand;EL2_default +gms$c09_pal_scenario;SDP;SDP;SSP2 +gms$s12_interest_lic;0.06;0.1;0.1 +gms$s12_interest_hic;0.04;0.04;0.04 +gms$s15_exo_waste;1;1;0 +gms$s15_waste_scen;1.2;1.2;1.2 +gms$s15_exo_diet;3;3;0 +gms$s15_exo_monogastric;1;1;1 +gms$s15_exo_ruminant;1;1;1 +gms$s15_exo_fish;1;1;1 +gms$s15_exo_fruitvegnut;1;1;1 +gms$s15_exo_roots;1;1;1 +gms$s15_exo_pulses;1;1;1 +gms$s15_exo_sugar;1;1;1 +gms$s15_exo_oils;1;1;1 +gms$s15_exo_brans;0;0;0 +gms$s15_exo_scp;1;1;1 +gms$s15_exo_alcohol;1;1;1 +gms$s15_alc_scen;0;0;0 +gms$c30_bioen_water;all;all;all +gms$factor_costs;sticky_labor;sticky_labor;sticky_labor +gms$c70_feed_scen;ssp1;ssp2;ssp2 +input['cellular'];rev4.126EL2_h12_c6a7458f_cellularmagpie_c200_IPSL-CM6A-LR-ssp370_lpjml-8e6c5eb1.tgz;; +magicc_emis_scen;REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12.mif;REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12.mif;REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12.mif diff --git a/config/projects/scenario_config_frst_shock.csv b/config/projects/scenario_config_frst_shock.csv new file mode 100755 index 0000000000..8640d126b1 --- /dev/null +++ b/config/projects/scenario_config_frst_shock.csv @@ -0,0 +1,4 @@ +;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030 +gms$c32_shock_scenario;none;002lin2030;004lin2030;008lin2030;016lin2030 +gms$s35_forest_damage;4;4;4;4;4 +gms$c35_shock_scenario;none;002lin2030;004lin2030;008lin2030;016lin2030 diff --git a/config/projects/scenario_config_fsec.csv b/config/projects/scenario_config_fsec.csv new file mode 100644 index 0000000000..6fe6f1b915 --- /dev/null +++ b/config/projects/scenario_config_fsec.csv @@ -0,0 +1,83 @@ +;FSEC;population;institutions;energy;bioplastics;capitalSubst;minWage;noUnderweight;halfOverweight;fruitsNutsVegSeeds;monogastrics;ruminants;pulses;processed;fish;waste;awms;livestock;cropefficiency;nueMAC;riceMAC;biodiversity;fairTrade;timberCities;REDDaff;REDD;landscapeElements;landSharing;landSparing;waterSparing;peatland;soil;allDiet;allDietAndWaste;allEnvPrice;allEmisPrice;SSP1;SSP2;SSP3;SSP4;SSP5;RCP19;RCP26;RCP34;RCP45;RCP60;RCP70;RCP85;SDPenergy;labor8p5;labor1p9 +gms$c09_pop_scenario;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c09_gdp_scenario;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c09_pal_scenario;;;SDP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +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_minimum_wood_yield;10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +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;;;;;;;;;;;;;;;;; +gms$c15_EAT_scen;;;;;;;;FLX;FLX;FLX;FLX;FLX;FLX;FLX;FLX;FLX;;;;;;;;;;;;;;;;;FLX;FLX;;;;;;;;;;;;;;;;; +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;;;;;;;;;;;;;;;;; +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$s21_trade_bal_damper;0.65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BH_IFL;;;;;;;;;;;;;;;;;;;;;; +gms$croparea;detail_apr24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c30_rotation_rules;FSEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c30_rotation_incentives;default;;;;;;;;;;;;;;;;;;;;;;;;;;;agroecology;;;;;;;;;;;;;;;;;;;;;;; +gms$s30_implementation;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s30_rotation_scenario_target;2050;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;; +gms$c29_marginal_land;q33_marginal;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c30_bioen_water;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_scenario_target;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_shr;;;;;;;;;;;;;;;;;;;;;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;; +gms$past;endo_jun13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c32_aff_policy;ndc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c32_aff_mask;;;;;;;;;;;;;;;;;;;;;;;;;onlytropical;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_max_aff_area;;;;;;;;;;;;;;;;;;;;;;;;;500;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c34_urban_scenario;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c35_ad_policy;ndc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c35_aolc_policy;ndc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s35_forest_damage_end;2050;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;2050;2050;2050;2050;;;;;;;;;; +gms$s35_secdf_distribution;2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s36_minimum_wage;0;;;;;;3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$factor_costs;sticky_labor;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$labor_prod;off;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;exo;exo +gms$c37_labor_rcp;rcp119;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rcp585;rcp119 +gms$c38_fac_req;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s38_target_labor_share;0;;;;;0.8;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s42_watdem_nonagr_scenario;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c42_env_flow_policy;off;;;;;;;;;;;;;;;;;;;;;;;;;;;;;on;;;;;;;;;;;;;;;;;;;;; +gms$s42_efp_startyear;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2025;;;;;;;;;;;;;;;;;;;;; +gms$s42_efp_targetyear;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;; +gms$s44_bii_target;;;;;;;;;;;;;;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c44_bii_decrease;;;;;;;;;;;;;;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$nitrogen;rescaled_jan21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff;;;baseeff_add3_add10_add20_max75;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +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$s56_c_price_induced_aff;0;;;;;;;;;;;;;;;;;;;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s57_maxmac_n_soil;-1;;;;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s57_maxmac_ch4_rice;-1;;;;;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s57_maxmac_ch4_entferm;-1;;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s57_maxmac_ch4_awms;-1;;;;;;;;;;;;;;;;201;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Inf;;;;;;;;;;;;;;;;;;;; +gms$som;cellpool_jan23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem;R21M42-SSP2-NDC;;;R21M42-SSP2-PkBudg900;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;R21M42-SDP-PkBudg900;; +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.128_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.128_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.128_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.128_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.128_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.128_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.128_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;;; +input['regional'];rev4.128_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['validation'];rev4.128_FSEC_92e02314_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['calibration'];calibration_FSEC_FAO_14Aug25.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_RemSDP-900-MagSSP1.mif;; diff --git a/config/projects/scenario_config_gcs.csv b/config/projects/scenario_config_gcs.csv new file mode 100755 index 0000000000..fa07333dc1 --- /dev/null +++ b/config/projects/scenario_config_gcs.csv @@ -0,0 +1,38 @@ +;GCSF;LNDlbs;LNDres;LNDfood;Tland +gms$food;anthro_iso_jun22;;;; +gms$s15_exo_foodscen_start;;;;2020;2020 +gms$s15_exo_foodscen_target;;;;2050;2050 +gms$s15_exo_waste;;;;1;1 +gms$s15_waste_scen;;;;1.2;1.2 +gms$s15_exo_diet;;;;1;1 +gms$c15_kcal_scen;;;;healthy_BMI;healthy_BMI +gms$c15_EAT_scen;;;;FLX;FLX +gms$s15_exo_monogastric;;;;1;1 +gms$s15_exo_ruminant;;;;1;1 +gms$s15_exo_fish;;;;1;1 +gms$s15_exo_fruitvegnut;;;;1;1 +gms$s15_exo_pulses;;;;1;1 +gms$s15_exo_sugar;;;;1;1 +gms$s15_exo_oils;;;;1;1 +gms$s15_exo_brans;;;;1;1 +gms$s15_exo_scp;;;;1;1 +gms$s15_exo_alcohol;;;;1;1 +gms$c22_protect_scenario;;BH_IFL;;;BH_IFL +gms$s29_snv_shr;;0.2;;;0.2 +gms$s29_snv_scenario_target;;2030;;;2030 +gms$c30_bioen_water;;;rainfed;;rainfed +gms$s32_aff_plantation;;0;;;0 +gms$s32_aff_bii_coeff;;0;;;0 +gms$s32_max_aff_area;;500;;;500 +gms$c32_aff_mask;;onlytropical;;;onlytropical +gms$s35_forest_damage_end;;2030;;;2030 +gms$s42_irrig_eff_scenario;;;3;;3 +gms$c42_env_flow_policy;;;on;;on +gms$s42_efp_targetyear;;;2040;;2040 +gms$c50_scen_neff;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add15_add25_max75 +gms$c55_scen_conf;;;ssp1;;ssp1 +gms$s56_buffer_aff;;0.2;;;0.2 +gms$c56_emis_policy;;gcs_lbs;gcs_res;;redd+natveg_nosoil +gms$c60_1stgen_biodem;;;phaseout2020;;phaseout2020 +gms$c60_res_2ndgenBE_dem;;;;sdp;sdp +gms$c70_feed_scen;;;ssp1;;ssp1 diff --git a/config/projects/scenario_config_genie.csv b/config/projects/scenario_config_genie.csv new file mode 100644 index 0000000000..bd86fd965a --- /dev/null +++ b/config/projects/scenario_config_genie.csv @@ -0,0 +1,28 @@ +;GENIE_SCP +gms$c_timesteps;coup2110 +gms$sm_fix_SSP2;2020 +gms$sm_fix_cc;2020 +gms$c13_tccost;high +gms$c14_yields_scenario;nocc +gms$food;anthropometrics_jan18 +gms$kfo_rd;livst_rum,livst_milk +gms$s15_food_subst_functional_form;2 +gms$c20_scp_type;hydrogen +gms$s21_trade_tariff_startyear;2020 +gms$s22_conservation_start;2020 +gms$s22_conservation_target;2030 +gms$s30_annual_max_growth;0.02 +gms$s32_hvarea;0 +gms$s35_hvarea;0 +gms$factor_costs;sticky_feb18 +gms$s38_startyear_labor_substitution;2020 +gms$s42_efp_startyear;2020 +gms$s44_cost_bii_missing;10000000 +gms$c56_pollutant_prices;R32M46-SSP2EU-NPi +gms$c56_pollutant_prices_noselect;R32M46-SSP2EU-NPi +gms$c56_mute_ghgprices_until;y2020 +gms$bioenergy;1st2ndgen_priced_feb24 +gms$c60_1stgen_biodem;phaseout2020 +gms$c60_2ndgen_biodem;R32M46-SSP2EU-NPi +gms$c60_2ndgen_biodem_noselect;R32M46-SSP2EU-NPi +gms$s73_timber_demand_switch;0 diff --git a/config/projects/scenario_config_lama.csv b/config/projects/scenario_config_lama.csv new file mode 100644 index 0000000000..7cc24c1ba6 --- /dev/null +++ b/config/projects/scenario_config_lama.csv @@ -0,0 +1,39 @@ +;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability +gms$c_timesteps;5year;5year;5year;5year;5year +gms$c09_pop_scenario;SSP4;SSP1;SSP4;SSP4;SSP1 +gms$c09_gdp_scenario;SSP4;SSP1;SSP4;SSP4;SSP1 +gms$c09_pal_scenario;SSP4;SSP1;SSP4;SSP4;SSP1 +gms$c15_food_scenario;SSP4;SSP1;SSP4;SSP4;SSP1 +gms$c15_food_scenario_noselect;SSP4;SSP1;SSP4;SSP4;SSP1 +gms$s15_exo_foodscen_start;;2020;;;2020 +gms$s15_exo_foodscen_target;;2050;;;2050 +gms$s15_exo_waste;0;1;0;0;1 +gms$s15_waste_scen;1.2;1.2;1.2;1.2;1.2 +gms$s15_exo_diet;0;1;0;0;1 +gms$s15_exo_brans;1;1;1;1;1 +gms$c21_trade_liberalization;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070 +gms$c22_protect_scenario;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL +gms$c22_protect_scenario_noselect;none;none;BH_IFL;none;BH_IFL +gms$s29_snv_shr;0.2;0.2;0.2;0.2;0.2 +gms$s29_snv_shr_noselect;0;0;0.2;0;0.2 +gms$s29_snv_scenario_target;2030;2030;2030;2030;2030 +gms$s32_max_aff_area;Inf;Inf;Inf;500;500 +gms$c34_urban_scenario;SSP4;SSP1;SSP4;SSP4;SSP1 +gms$c32_aff_policy;ndc;ndc;ndc;ndc;ndc +gms$c35_ad_policy;ndc;ndc;ndc;ndc;ndc +gms$c35_aolc_policy;ndc;ndc;ndc;ndc;ndc +gms$s35_forest_damage_end;2030;2030;2030;2030;2030 +gms$s42_watdem_nonagr_scenario;2;1;2;2;1 +gms$s42_irrig_eff_scenario;3;3;3;3;3 +gms$c42_env_flow_policy;on;on;on;on;on +gms$c50_scen_neff;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_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;ssp1;ssp1;ssp1;ssp1 +gms$c55_scen_conf_noselect;ssp4;ssp4;ssp1;ssp4;ssp1 +gms$c56_pollutant_prices;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000 +gms$c56_pollutant_prices_noselect;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000 +gms$c60_1stgen_biodem;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020 +gms$c60_2ndgen_biodem;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000 +gms$c60_2ndgen_biodem_noselect;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000 +gms$c60_res_2ndgenBE_dem;ssp4;sdp;ssp4;ssp4;sdp +gms$c70_feed_scen;ssp4;ssp1;ssp4;ssp4;ssp1 diff --git a/config/projects/scenario_config_miti_consv.csv b/config/projects/scenario_config_miti_consv.csv new file mode 100644 index 0000000000..358287241a --- /dev/null +++ b/config/projects/scenario_config_miti_consv.csv @@ -0,0 +1,6 @@ +;MitiConsv;AR0;AR150;AR250;AR350;BH +gms$c22_protect_scenario;;;;;;BH +gms$s32_max_aff_area;;;332;432;532; +gms$s56_c_price_induced_aff ;;0;1;1;1; +gms$s56_buffer_aff;0;;;;; +input['calibration'];calibration_rev21_MitiConsv_01Jul25.tgz;;;;; diff --git a/config/projects/scenario_config_navigate.csv b/config/projects/scenario_config_navigate.csv new file mode 100644 index 0000000000..de112a2a6c --- /dev/null +++ b/config/projects/scenario_config_navigate.csv @@ -0,0 +1,6 @@ +;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn +gms$s15_exo_waste;0;0;1;1 +gms$s15_exo_diet;0;0;1;1 +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 diff --git a/config/projects/scenario_config_ngfs.csv b/config/projects/scenario_config_ngfs.csv new file mode 100755 index 0000000000..3780bba98f --- /dev/null +++ b/config/projects/scenario_config_ngfs.csv @@ -0,0 +1,11 @@ +;NGFS_o_lowdem +gms$c15_food_scenario;SSP2 +gms$c15_food_scenario_noselect;SSP2 +gms$s15_exo_foodscen_convergence;1 +gms$s15_exo_foodscen_functional_form;1 +gms$s15_exo_foodscen_start;2020 +gms$s15_exo_foodscen_target;2050 +gms$s15_exo_waste;1 +gms$s15_waste_scen;1.2 +gms$s15_exo_diet;1 +gms$c15_kcal_scen;healthy_BMI diff --git a/config/projects/scenario_config_year_fix.csv b/config/projects/scenario_config_year_fix.csv new file mode 100644 index 0000000000..282d61934e --- /dev/null +++ b/config/projects/scenario_config_year_fix.csv @@ -0,0 +1,16 @@ +;fix_2020;fix_2025 +gms$sm_fix_SSP2;2020;2025 +gms$sm_fix_cc;2020;2025 +gms$s15_food_substitution_start;2020;2025 +gms$s15_exo_foodscen_start;2020;2025 +gms$s21_trade_tariff_startyear;2020;2025 +gms$s22_conservation_start;2020;2025 +gms$s29_snv_scenario_start;2020;2025 +gms$s29_treecover_scenario_start;2020;2025 +gms$s29_fallow_scenario_start;2020;2025 +gms$s30_betr_scenario_start;2020;2025 +gms$s30_rotation_scenario_start;2020;2025 +gms$s38_startyear_labor_substitution;2020;2025 +gms$s42_efp_startyear;2020;2025 +gms$s44_start_year;2020;2025 +gms$s70_feed_substitution_start;2020;2025 diff --git a/config/scenario_config.csv b/config/scenario_config.csv old mode 100644 new mode 100755 index 776f369db9..83087af906 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -1,27 +1,80 @@ -;cc;nocc;SSP1;SSP2;SSP3;SSP4;SSP5;BASE;NPI;NDC;coupling;emulator;input;SUSTAg1;SUSTAg2;SUSTAg3;SUSTAg4;SUSTAg5 -c09_pop_scenario;;;SSP1;SSP2;SSP3;SSP4;SSP5;;;;;;;SSP1;SSP2;SSP3;SSP4;SSP5 -c09_gdp_scenario;;;SSP1;SSP2;SSP3;SSP4;SSP5;;;;;;;SSP1;SSP2;SSP3;SSP4;SSP5 -c12_interest_rate;;;low;medium;high;mixed;low;;;;;;;low;medium;high;mixed;low -c15_food_scenario;;;SSP1;SSP2;SSP3;SSP4;SSP5;;;;;;;SSP1;SSP2;SSP3;SSP4;SSP5 -c21_trade_liberalization;;;l908080r807070;l909090r808080;l909595r809090;l908080r807070;l908080r807070;;;;;;;l908080r807070;l909090r808080;l909595r809090;l908080r807070;l908080r807070 -forestry;;;;;;;;affore_vegc_dec16;affore_vegc_dec16;affore_vegc_dec16;;;;affore_vegc_dec16;affore_vegc_dec16;affore_vegc_dec16;affore_vegc_dec16;affore_vegc_dec16 -c32_aff_policy;;;;;;;;none;npi;ndc;;;;;;;; -c35_ad_policy;;;;;;;;none;npi;ndc;;;;;;;; -c35_aolc_policy;;;;;;;;none;npi;ndc;;;;;;;; -c42_env_flow_policy;;;on;off;off;mixed;on;;;;;;;on;off;off;mixed;on -c50_scen_neff;;;neff65_70_starty2010;neff60_60_starty2010;neff55_60_starty2010;neff65_70_starty2010;neff55_60_starty2010;;;;;;;neff65_70_starty2010;neff60_60_starty2010;neff55_60_starty2010;neff65_70_starty2010;neff55_60_starty2010 -c55_scen_conf;;;ssp1;ssp2;ssp3;ssp4;ssp5;;;;;;;ssp1;ssp2;ssp3;ssp4;ssp5 -c56_pollutant_prices;;;;;;;;;;;coupling;emulator;coupling;SSPDB-SSP1-20-IMAGE;SSPDB-SSP2-26-MESSAGE-GLOBIOM;SSPDB-SSP3-60-AIM-CGE;SSPDB-SSP4-45-GCAM4;SSPDB-SSP5-45-REMIND-MAGPIE -maccs;;;;;;;;;;;;;;on_sep16;on_sep16;on_sep16;on_sep16;on_sep16 -c60_2ndgen_biodem;;;;;;;;;;;coupling;emulator;coupling;SSPDB-SSP1-20-IMAGE;SSPDB-SSP2-26-MESSAGE-GLOBIOM;SSPDB-SSP3-60-AIM-CGE;SSPDB-SSP4-45-GCAM4;SSPDB-SSP5-45-REMIND-MAGPIE -c60_1stgen_biodem;;;phaseout2020;const2020;const2030;const2020;phaseout2020;;;;;;;phaseout2020;const2020;const2030;const2020;phaseout2020 -c60_biodem_level;;;;;;;;;;;1;0;;;;;; -c60_res_2ndgenBE_dem;;;ssp1;ssp2;ssp3;ssp4;ssp5;;;;;;;ssp1;ssp2;ssp3;ssp4;ssp5 -c62_material_scenario;;;SSP1;SSP2;SSP3;SSP4;SSP5;;;;;;;SSP1;SSP2;SSP3;SSP4;SSP5 -c70_feed_scen;;;ssp1;ssp2;ssp3;ssp4;ssp5;;;;;;;ssp1;ssp2;ssp3;ssp4;ssp5 -s80_maxiter;;;;;;;;;;;;;;;;;; -c_timesteps;;;;;;;;;;;less_TS;less_TS;;;;;; -c14_yields_scenario;cc;nocc;;;;;;;;;;;;cc;cc;cc;cc;cc -c42_watdem_scenario;cc;nocc;;;;;;;;;;;;cc;cc;cc;cc;cc -c43_watavail_scenario;cc;nocc;;;;;;;;;;;;cc;cc;cc;cc;cc -c52_carbon_scenario;cc;nocc;;;;;;;;;;;;cc;cc;cc;cc;cc +f;cc;nocc;nocc_hist;SSP1;SSP2;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;VLLO;SSP1-POP-GDP;SSP2-POP-GDP;SSP3-POP-GDP;SSP5-POP-GDP;AR-natveg;AR-plant;BASE;NPI;NPI-revert;NDC;coupling;emulator;input;eat_lancet_diet_v1;eat_lancet_diet_v2;ForestryEndo;ForestryExo;ForestryOff;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5 +gms$c_timesteps;;;;;;;;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;;;;;;;;; +gms$c09_pop_scenario;;;;SSP1;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;SSP1;SSP1;SSP2;SSP3;SSP5;;;;;;;;;;;;;;;;;;;; +gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;SSP1;SSP1;SSP2;SSP3;SSP5;;;;;;;;;;;;;;;;;;;; +gms$c09_pal_scenario;;;;SSP1;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;SSP1;;;;;;;;;;;;;;;;;;;;;;;; +gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c15_food_scenario;;;;SSP1;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;SSP2;;;;;;;;;;;;;;;;;;;;;;;; +gms$s15_rumdairy_scp_substitution;;;;0;0;0;0;0;0;0.5;0;0;0;;;;;;;;;;;;;;;;;;;;;;;; +gms$s15_food_subst_functional_form;;;;1;1;1;1;1;;2;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s15_food_substitution_start;;;;;;;;;;2025;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s15_food_substitution_target;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$kfo_rd;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s15_exo_foodscen_convergence;;;;;;;;;1;1;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_foodscen_functional_form;;;;;;;;;1;1;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_foodscen_start;;;;;;;;;2025;2025;2025;2025;2025;;;;;;;;;;;;;;2025;2025;;;;;;;;; +gms$s15_exo_foodscen_target;;;;;;;;;2050;2050;2050;2070;2070;;;;;;;;;;;;;;2050;2050;;;;;;;;; +gms$s15_exo_waste;;;;0;0;0;0;0;1;1;1;1;1;;;;;;;;;;;;;;;;;;;;;;;; +gms$s15_waste_scen;;;;;;;;;1.2;1.3;1.2;1.25;1.25;;;;;;;;;;;;;;;;;;;;;;;; +gms$s15_exo_diet;;;;0;0;0;0;0;1;1;1;1;3;;;;;;;;;;;;;;1;3;;;;;;;;; +gms$c15_kcal_scen;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;healthy_BMI;;;;;;;;;;;;;;healthy_BMI;;;;;;;;;; +gms$c15_EAT_scen;;;;;;;;;FLX;;FLX;FLX;FLX;;;;;;;;;;;;;;FLX;;;;;;;;;; +gms$s15_exo_monogastric;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_ruminant;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_fish;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_fruitvegnut;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_roots;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_pulses;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_sugar;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_oils;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_brans;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;0;;;;;;;;; +gms$s15_exo_scp;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_exo_alcohol;;;;;;;;;1;0;1;1;1;;;;;;;;;;;;;;1;1;;;;;;;;; +gms$s15_alc_scen;;;;;;;;;;;;;;;;;;;;;;;;;;;0.014;0;;;;;;;;; +gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario;;;;none;none;none;none;none;BH;none;BH_IFL;BH;BH;;;;;;;;;;;;;;;;;;;;;;;; +gms$s22_base_protect_reversal;;;;;;;;;;;;;;;;;;;;Inf;Inf;2030;Inf;;;;;;;;;;;;;; +gms$s29_snv_shr;;;;0;0;0;0;0;0;0;0;0.2;0.2;;;;;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_scenario_target;;;;;;;;;;;;2050;2070;;;;;;;;;;;;;;;;;;;;;;;; +gms$s29_treecover_plantation;;;;;;;;;;;;;;;;;;0;1;;;;;;;;;;;;;;;;;; +gms$s29_treecover_bii_coeff;;;;;;;;;;;;;;;;;;0;1;;;;;;;;;;;;;;;;;; +gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;rainfed;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;1;0;;;;;; +gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2;1;0;;;;;; +gms$s32_aff_plantation;;;;0;0;0;0;0;0;1;0;0;0;;;;;0;1;;;;;;;;;;;;;;;;;; +gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;1;0;0;0;;;;;0;1;;;;;;;;;;;;;;;;;; +gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;500;350;0;700;700;;;;;;;;;;;;;;;;;;;;;;;; +gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;;;;;;;;;;;;;;;;;; +gms$c34_urban_scenario;;;;SSP1;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;SSP1;;;;;;;;;;;;;;;;;;;;;;;; +gms$c32_aff_policy;;;;;;;;;;;;;;;;;;;;none;npi;npi;ndc;;;;;;;;;;;;;; +gms$s32_npi_ndc_reversal;;;;;;;;;;;;;;;;;;;;Inf;Inf;2030;Inf;;;;;;;;;;;;;; +gms$s32_planning_horizon;;;;50;50;50;50;50;50;30;50;50;50;;;;;50;50;;;;;;;;;;;;;;;;;; +gms$c35_ad_policy;;;;;;;;;;;;;;;;;;;;none;npi;npi;ndc;;;;;;;;;;;;;; +gms$c35_aolc_policy;;;;;;;;;;;;;;;;;;;;none;npi;npi;ndc;;;;;;;;;;;;;; +gms$s35_npi_ndc_reversal;;;;;;;;;;;;;;;;;;;;Inf;Inf;2030;Inf;;;;;;;;;;;;;; +gms$c35_pot_forest_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s35_forest_damage_end;;;;2050;2050;2050;2050;2050;2050;2050;2050;2050;2050;;;;;;;;;;;;;;;;;;;;;;;; +gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2;2;0;;;;;; +gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2;2;0;;;;;; +gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s42_watdem_nonagr_scenario;;;;1;2;3;2;1;1;1;3;1;1;;;;;;;;;;;;;;;;;;;;;;;; +gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;3;3;3;3;2;;;;;;;;;;;;;;;;;;;;;;;; +gms$c42_env_flow_policy;;;;on;off;off;mixed;on;on;on;on;on;on;;;;;;;;;;;;;;;;;;;;;;;; +gms$s42_efp_targetyear;;;;;;;;;2040;2050;2070;2050;2070;;;;;;;;;;;;;;;;;;;;;;;; +gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;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;;;;;;;;;;;;;;;;;;;;;;;; +gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU +gms$c55_scen_conf;;;;ssp1;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;;;;;;;; +gms$s56_c_price_exp_aff;;;;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.2;0.3;0.5;;;;;0.5;0.5;;;;;;;;;;;;;;;;;; +gms$c56_emis_policy;;;;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;reddnatveg_nosoil;redd_nosoil;all_nosoil;reddnatveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;; +gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;;;;;;;;; +gms$c60_biodem_level;;;;;;;;;;;;;;;;;;;;;;;;1;0;;;;;;;;;;;; +gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;sdp;;;;;;;;;;;;;;;;;;;;;;;; +gms$c70_feed_scen;;;;ssp1;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;ssp2;;;;;;;;;;;;;;;;;;;;;;;; +gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;1;0;;;;;; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.128_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.128_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.128_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.128_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.128_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.128_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz diff --git a/config/scenario_config_emulator.csv b/config/scenario_config_emulator.csv index 884c8a0bb7..d071e157ae 100644 --- a/config/scenario_config_emulator.csv +++ b/config/scenario_config_emulator.csv @@ -1,12 +1,16 @@ -title;start;mag_scen;co2tax_name;co2tax_2025 -1;0;SSP1;26;48.1662949 -2;0;SSP2,BASE;Base;0 -3;0;SSP2,NDC;NDC;0 -4;0;SSP2,NDC;Budg1300;45.6222 -5;0;SSP2,NDC;Budg950;75.2994 -5;0;SSP2,NDC;Budg600;109.097 -6;0;SSP2;SSP2-26-SPA2-V15-REMIND-MAGPIE;built-in -7;1;SSP1,BASE;Base;0 -8;1;SSP1,NDC;NDC;0 -9;1;SSP1,NDC;Budg1300;48.31652 -11;1;SSP1,NDC;Budg600;114.629 +start;mag_scen;ghgtax_name;mifname;no_ghgprices_land_until +0;SDP-MC|NPI|nocc_hist;Base; C_SDP_MC-Base;y2150 +0;SDP-MC|NDC|nocc_hist;NDC; C_SDP_MC-NDC;y2150 +0;SDP-MC|NDC|nocc_hist;PkBudg500; C_SDP_MC-PkBudg500;y2030 +0;SSP1|NPI|nocc_hist;Base; C_SSP1-Base;y2150 +0;SSP1|NDC|nocc_hist;NDC; C_SSP1-NDC;y2150 +0;SSP1|NDC|nocc_hist;PkBudg1150; C_SSP1-PkBudg1150;y2030 +0;SSP1|NDC|nocc_hist;PkBudg500; C_SSP1-PkBudg500;y2030 +0;SSP2|NPI|nocc_hist;Base; C_SSP2EU-Base;y2150 +0;SSP2|NDC|nocc_hist;NDC; C_SSP2EU-NDC;y2150 +1;SSP2|NDC|nocc_hist;PkBudg1150; C_SSP2EU-PkBudg1150;y2030 +0;SSP2|NDC|nocc_hist;PkBudg500; C_SSP2EU-PkBudg500;y2030 +0;SSP5|NPI|nocc_hist;Base; C_SSP5-Base;y2150 +0;SSP5|NDC|nocc_hist;NDC; C_SSP5-NDC;y2150 +0;SSP5|NDC|nocc_hist;PkBudg1150; C_SSP5-PkBudg1150;y2030 +0;SSP5|NDC|nocc_hist;PkBudg500; C_SSP5-PkBudg500;y2030 diff --git a/core/calculations.gms b/core/calculations.gms index 77ca05b49e..610f2374bc 100644 --- a/core/calculations.gms +++ b/core/calculations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,6 +10,7 @@ * optimization process. Hence these lines CAN INFLUENCE the optimization process * but CANNOT BE INFLUENCED by it. +$batinclude "./modules/include.gms" start $batinclude "./modules/include.gms" preloop @@ -20,7 +21,6 @@ $batinclude "./modules/include.gms" preloop * 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 @@ -31,15 +31,25 @@ file dummy; dummy.pw=2000; put dummy; * clear ct set ct(t) = no; +pt(t) = no; ***************************TIMESTEP LOOP START********************************** -loop (t, +$label TimeLoop +$if not set TIMESTEP $set TIMESTEP 0 + +loop (t$(m_year(t) > %TIMESTEP%), * set ct to current time period - ct(t) = yes; + ct(t) = yes; + pt(t) = yes$(ord(t) = 1); + pt(t-1) = yes$(ord(t) > 1); display "Year"; display ct; + display "Previous Year"; + display pt; + +$batinclude "./modules/include.gms" presolve_ini $batinclude "./modules/include.gms" presolve @@ -81,8 +91,12 @@ $batinclude "./modules/include.gms" postsolve **********************WRITE ALL DATA IN 1 GDX FILE****************************** Execute_Unload "fulldata.gdx"; -* clear ct set +* clear ct and pt set ct(t) = no; + pt(t) = no$(ord(t) = 1); + pt(t-1) = no$(ord(t) > 1); + + put_utility 'save' / 'restart_' t.tl:0;; ******************************************************************************** ); ****************************TIMESTEP LOOP END*********************************** diff --git a/core/declarations.gms b/core/declarations.gms index d2cb620761..be7e95df04 100644 --- a/core/declarations.gms +++ b/core/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,6 +7,7 @@ scalars sm_intersolve if 0 finish loop or if 1 iterate optimization (1) /0/ + ; *** EOF declarations.gms *** diff --git a/core/load_gdx.gms b/core/load_gdx.gms index 274a02e7eb..0c289af313 100644 --- a/core/load_gdx.gms +++ b/core/load_gdx.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/core/macros.gms b/core/macros.gms index f2441934c6..881ba0fd61 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,8 +8,9 @@ *****************************Technical macros*********************************** * Macro for fixing a variable in the case that lower and upper bound are too -* close to each other (closer than argument "sens") -* EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,10e-5); +* close to each other (closer than argument "sens"). +* "arg" specifies the set for fixing. "sufx" specifies to what value the variable should be fixed ("l","lo","up"). +* EXAMPLE: m_boundfix(vm_land,(j,"ifft"),up,1e-6); $macro m_boundfix(x,arg,sufx,sens) x.fx arg$(x.up arg-x.lo arg0) + 0$(sum(s,w)<=0); @@ -39,12 +40,22 @@ $macro m_year(t) (sum(time_annual,ord(time_annual)$sameas(t,time_annual)) + 1964 * sets the difference for the first time step to one. $macro m_yeardiff(t) (1$(ord(t)=1) + (m_year(t)-m_year(t-1))$(ord(t)>1)) +* calculates the difference in years to the previous time step and +* sets the difference for the first time step to five. +$macro m_yeardiff_forestry(t) (5$(ord(t)=1) + (m_year(t)-m_year(t-1))$(ord(t)>1)) + * same as m_yeardiff but only for the current time step and written in a way * that it can be used within equations (no t dependency) * ATTENTION: t2 needs to exist as alias of t to get this macro working! * ATTENTION: ct needs to exist as set containing only the current time step $macro m_timestep_length sum((ct,t2),(1$(ord(t2)=1) + (m_year(t2)-m_year(t2-1))$(ord(t2)>1))$sameas(ct,t2)) +* same as m_yeardiff but only for the current time step and written in a way +* that it can be used within equations (no t dependency) +* ATTENTION: t2 needs to exist as alias of t to get this macro working! +* ATTENTION: ct needs to exist as set containing only the current time step +$macro m_timestep_length_forestry sum((ct,t2),(5$(ord(t2)=1) + (m_year(t2)-m_year(t2-1))$(ord(t2)>1))$sameas(ct,t2)) + * update total costs by distribute annuity costs over all years within the given time horizon $macro m_annuity_costs_update(past_costs, cost_annuity, invest_horizon) past_costs = past_costs \ + cost_annuity$(m_year(t2) > m_year(t) AND m_year(t2) <= m_year(t) + invest_horizon) \ @@ -54,11 +65,55 @@ $macro m_annuity_costs_update(past_costs, cost_annuity, invest_horizon) past_cos * fill empty years with values from previous time step * input = name of input parameter * sets = all sets except of t_all written in quotes (e.g. "kve,w") -$macro m_fillmissingyears(input,sets) loop(t, \ - ct(t) = yes; \ - if(sum((ct,&&sets),input(ct,&&sets))=0, \ - input(t,&&sets) = input(t-1,&&sets); \ - display "Data gap in input filled with data from previous time step for the following year: ",ct; \ +$macro m_fillmissingyears(input,sets) loop(t_all, \ + ct_all(t_all) = yes; \ + if(sum((ct_all,&&sets),input(ct_all,&&sets))=0, \ + input(t_all,&&sets) = input(t_all-1,&&sets); \ + display "Data gap in input filled with data from previous time step for the following year: ",ct_all; \ ); \ - ct(t) = no; \ + ct_all(t_all) = no; \ ); + +*** Time interpolation +* macro for linear time interpolation +$macro m_linear_time_interpol(input,start_year,target_year,start_value,target_value) \ + input(t_all)$(m_year(t_all) > start_year AND m_year(t_all) < target_year) = ((m_year(t_all)-start_year) / (target_year-start_year)); \ + input(t_all) = start_value + input(t_all) * (target_value-start_value); \ + input(t_all)$(m_year(t_all) <= start_year) = start_value; \ + input(t_all)$(m_year(t_all) >= target_year) = target_value; + +* macro for sigmoid time interpolation (S-shaped curve) +$macro m_sigmoid_time_interpol(input,start_year,target_year,start_value,target_value) \ + input(t_all)$(m_year(t_all) >= start_year AND m_year(t_all) <= target_year) = ((m_year(t_all)-start_year) / (target_year-start_year)); \ + input(t_all) = 1 / (1 + exp(-10*(input(t_all)-0.5))); \ + input(t_all) = start_value + input(t_all) * (target_value-start_value); \ + input(t_all)$(m_year(t_all) <= start_year) = start_value; \ + input(t_all)$(m_year(t_all) >= target_year) = target_value; + +*** Data interpolation +* macro for linear cell data interpolation +$macro m_linear_cell_data_interpol(output,x,input_x1,input_x2,input_y1,input_y2) \ + output(j) = input_y1 + (input_y2 - input_y1)/(input_x2 - input_x1) * (x - input_x1); + +* macro for simple carbon stocks +$macro m_carbon_stock(land,carbon_density,item) \ + (land(j2,item) * sum(ct,carbon_density(ct,j2,item,ag_pools)))$(sameas(stockType,"actual")) + \ + (land(j2,item) * sum(ct,carbon_density(ct,j2,item,ag_pools)))$(sameas(stockType,"actualNoAcEst")) + +* macro for carbon stocks with age classes +$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 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 trade module +$macro m21_baseline_production(supply, excess_prod, self_suff) \ + ((sum(supreg(h2,i2),supply(i2,k_trade)) + excess_prod(h2,k_trade)) \ + $((sum(ct,self_suff(ct,h2,k_trade)) >= 1)) \ + + (sum(supreg(h2,i2),supply(i2,k_trade)) * sum(ct,self_suff(ct,h2,k_trade))) \ + $((sum(ct,self_suff(ct,h2,k_trade)) < 1))) diff --git a/core/sets.gms b/core/sets.gms index 345a9483a4..7f07b28586 100644 --- a/core/sets.gms +++ b/core/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -9,119 +9,128 @@ *############################################################################### *######################## R SECTION START (SETS) ############################### -*THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY -*ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT INPUT DOWNLOAD -*CHANGES CAN BE DONE USING THE INPUT DOWNLOADER UNDER SCRIPTS/DOWNLOAD -*THERE YOU CAN ALSO FIND ADDITIONAL INFORMATION +* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY +* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! sets - i World regions /CAZ,CHA,EUR,IND,JPN,LAM,MEA,NEU,OAS,REF,SSA,USA/ - - iso Countries / - ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, - ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, - BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, - BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, - CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, - COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, - DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, - EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, - GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, - GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, - HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, - ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, - KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, - LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, - MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, - MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, - NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, - NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, - PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, - RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, - SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, - SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, - TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, - UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, - VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / - - j Spatial clusters / - CAZ_1*CAZ_28, - CHA_29*CHA_52, - EUR_53*EUR_62, - IND_63*IND_69, - JPN_70*JPN_72, - LAM_73*LAM_125, - MEA_126*MEA_142, - NEU_143*NEU_150, - OAS_151*OAS_172, - REF_173*REF_179, - SSA_180*SSA_190, - USA_191*USA_200/ - - cell(i,j) Mapping between regions i and clusters j - / - CAZ . CAZ_1*CAZ_28 - CHA . CHA_29*CHA_52 - EUR . EUR_53*EUR_62 - IND . IND_63*IND_69 - JPN . JPN_70*JPN_72 - LAM . LAM_73*LAM_125 - MEA . MEA_126*MEA_142 - NEU . NEU_143*NEU_150 - OAS . OAS_151*OAS_172 - REF . REF_173*REF_179 - SSA . SSA_180*SSA_190 - USA . USA_191*USA_200 - / - - i_to_iso(i,iso) Mapping between regions and countries - / - CAZ . (AUS,CAN,HMD,NZL,SPM) - CHA . (CHN,HKG,MAC,TWN) - EUR . (ALA,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST) - EUR . (FIN,FRA,FRO,GBR,GGY,GIB,GRC,HRV,HUN,IMN) - EUR . (IRL,ITA,JEY,LTU,LUX,LVA,MLT,NLD,POL,PRT) - EUR . (ROU,SVK,SVN,SWE) - IND . (IND) - JPN . (JPN) - LAM . (ABW,AIA,ARG,ATA,ATG,BES,BHS,BLM,BLZ,BMU) - LAM . (BOL,BRA,BRB,BVT,CHL,COL,CRI,CUB,CUW,CYM) - LAM . (DMA,DOM,ECU,FLK,GLP,GRD,GTM,GUF,GUY,HND) - LAM . (HTI,JAM,KNA,LCA,MAF,MEX,MSR,MTQ,NIC,PAN) - LAM . (PER,PRI,PRY,SGS,SLV,SUR,SXM,TCA,TTO,URY) - LAM . (VCT,VEN,VGB,VIR) - MEA . (ARE,BHR,DZA,EGY,ESH,IRN,IRQ,ISR,JOR,KWT) - MEA . (LBN,LBY,MAR,OMN,PSE,QAT,SAU,SDN,SYR,TUN) - MEA . (YEM) - NEU . (ALB,AND,BIH,CHE,GRL,ISL,LIE,MCO,MKD,MNE) - NEU . (NOR,SJM,SMR,SRB,TUR,VAT) - OAS . (AFG,ASM,ATF,BGD,BRN,BTN,CCK,COK,CXR,FJI) - OAS . (FSM,GUM,IDN,IOT,KHM,KIR,KOR,LAO,LKA,MDV) - OAS . (MHL,MMR,MNG,MNP,MYS,NCL,NFK,NIU,NPL,NRU) - OAS . (PAK,PCN,PHL,PLW,PNG,PRK,PYF,SGP,SLB,THA) - OAS . (TKL,TLS,TON,TUV,UMI,VNM,VUT,WLF,WSM) - REF . (ARM,AZE,BLR,GEO,KAZ,KGZ,MDA,RUS,TJK,TKM) - REF . (UKR,UZB) - SSA . (AGO,BDI,BEN,BFA,BWA,CAF,CIV,CMR,COD,COG) - SSA . (COM,CPV,DJI,ERI,ETH,GAB,GHA,GIN,GMB,GNB) - SSA . (GNQ,KEN,LBR,LSO,MDG,MLI,MOZ,MRT,MUS,MWI) - SSA . (MYT,NAM,NER,NGA,REU,RWA,SEN,SHN,SLE,SOM) - SSA . (SSD,STP,SWZ,SYC,TCD,TGO,TZA,UGA,ZAF,ZMB) - SSA . (ZWE) - USA . (USA) - / + h all superregional economic regions + / CAZ, CHA, EUR, IND, JPN, LAM, MEA, NEU, OAS, REF, SSA, USA / + + i all economic regions + / CAZ, CHA, EUR, IND, JPN, LAM, MEA, NEU, OAS, REF, SSA, USA / + + supreg(h,i) mapping of superregions to its regions + / CAZ . (CAZ) + CHA . (CHA) + EUR . (EUR) + IND . (IND) + JPN . (JPN) + LAM . (LAM) + MEA . (MEA) + NEU . (NEU) + OAS . (OAS) + REF . (REF) + SSA . (SSA) + USA . (USA) / + + iso list of iso countries + / ABW, AFG, AGO, AIA, ALA, ALB, AND, ARE, ARG, ARM, ASM, ATA, ATF, ATG, + AUS, AUT, AZE, BDI, BEL, BEN, BES, BFA, BGD, BGR, BHR, BHS, BIH, BLM, + BLR, BLZ, BMU, BOL, BRA, BRB, BRN, BTN, BVT, BWA, CAF, CAN, CCK, CHN, + CHE, CHL, CIV, CMR, COD, COG, COK, COL, COM, CPV, CRI, CUB, CUW, CXR, + CYM, CYP, CZE, DEU, DJI, DMA, DNK, DOM, DZA, ECU, EGY, ERI, ESH, ESP, + EST, ETH, FIN, FJI, FLK, FRA, FRO, FSM, GAB, GBR, GEO, GGY, GHA, GIB, + GIN, GLP, GMB, GNB, GNQ, GRC, GRD, GRL, GTM, GUF, GUM, GUY, HKG, HMD, + HND, HRV, HTI, HUN, IDN, IMN, IND, IOT, IRL, IRN, IRQ, ISL, ISR, ITA, + JAM, JEY, JOR, JPN, KAZ, KEN, KGZ, KHM, KIR, KNA, KOR, KWT, LAO, LBN, + LBR, LBY, LCA, LIE, LKA, LSO, LTU, LUX, LVA, MAC, MAF, MAR, MCO, MDA, + MDG, MDV, MEX, MHL, MKD, MLI, MLT, MMR, MNE, MNG, MNP, MOZ, MRT, MSR, + MTQ, MUS, MWI, MYS, MYT, NAM, NCL, NER, NFK, NGA, NIC, NIU, NLD, NOR, + NPL, NRU, NZL, OMN, PAK, PAN, PCN, PER, PHL, PLW, PNG, POL, PRI, PRK, + PRT, PRY, PSE, PYF, QAT, REU, ROU, RUS, RWA, SAU, SDN, SEN, SGP, SGS, + SHN, SJM, SLB, SLE, SLV, SMR, SOM, SPM, SRB, SSD, STP, SUR, SVK, SVN, + SWE, SWZ, SXM, SYC, SYR, TCA, TCD, TGO, THA, TJK, TKL, TKM, TLS, TON, + TTO, TUN, TUR, TUV, TWN, TZA, UGA, UKR, UMI, URY, USA, UZB, VAT, VCT, + VEN, VGB, VIR, VNM, VUT, WLF, WSM, YEM, ZAF, ZMB, ZWE / + + j number of LPJ cells + / CAZ_1*CAZ_5, + CHA_6*CHA_24, + EUR_25*EUR_36, + IND_37*IND_48, + JPN_49*JPN_55, + LAM_56*LAM_88, + MEA_89*MEA_113, + NEU_114*NEU_121, + OAS_122*OAS_137, + REF_138*REF_149, + SSA_150*SSA_182, + USA_183*USA_200 / + + cell(i,j) number of LPJ cells per region i + / CAZ . (CAZ_1*CAZ_5) + CHA . (CHA_6*CHA_24) + EUR . (EUR_25*EUR_36) + IND . (IND_37*IND_48) + JPN . (JPN_49*JPN_55) + LAM . (LAM_56*LAM_88) + MEA . (MEA_89*MEA_113) + NEU . (NEU_114*NEU_121) + OAS . (OAS_122*OAS_137) + REF . (REF_138*REF_149) + SSA . (SSA_150*SSA_182) + USA . (USA_183*USA_200) / + + i_to_iso(i,iso) mapping regions to iso countries + / CAZ . (AUS, CAN, HMD, NZL, SPM) + CHA . (CHN, HKG, MAC, TWN) + EUR . (ALA, AUT, BEL, BGR, CYP, CZE, DEU, DNK, ESP, EST, FIN, FRA, FRO) + EUR . (GBR, GGY, GIB, GRC, HRV, HUN, IMN, IRL, ITA, JEY, LTU, LUX, LVA) + EUR . (MLT, NLD, POL, PRT, ROU, SVK, SVN, SWE) + IND . (IND) + JPN . (JPN) + LAM . (ABW, AIA, ARG, ATA, ATG, BES, BHS, BLM, BLZ, BMU, BOL, BRA, BRB) + LAM . (BVT, CHL, COL, CRI, CUB, CUW, CYM, DMA, DOM, ECU, FLK, GLP, GRD) + LAM . (GTM, GUF, GUY, HND, HTI, JAM, KNA, LCA, MAF, MEX, MSR, MTQ, NIC) + LAM . (PAN, PER, PRI, PRY, SGS, SLV, SUR, SXM, TCA, TTO, URY, VCT, VEN) + LAM . (VGB, VIR) + MEA . (ARE, BHR, DZA, EGY, ESH, IRN, IRQ, ISR, JOR, KWT, LBN, LBY, MAR) + MEA . (OMN, PSE, QAT, SAU, SDN, SYR, TUN, YEM) + NEU . (ALB, AND, BIH, CHE, GRL, ISL, LIE, MCO, MKD, MNE, NOR, SJM, SMR) + NEU . (SRB, TUR, VAT) + OAS . (AFG, ASM, ATF, BGD, BRN, BTN, CCK, COK, CXR, FJI, FSM, GUM, IDN) + OAS . (IOT, KHM, KIR, KOR, LAO, LKA, MDV, MHL, MMR, MNG, MNP, MYS, NCL) + OAS . (NFK, NIU, NPL, NRU, PAK, PCN, PHL, PLW, PNG, PRK, PYF, SGP, SLB) + OAS . (THA, TKL, TLS, TON, TUV, UMI, VNM, VUT, WLF, WSM) + REF . (ARM, AZE, BLR, GEO, KAZ, KGZ, MDA, RUS, TJK, TKM, UKR, UZB) + SSA . (AGO, BDI, BEN, BFA, BWA, CAF, CIV, CMR, COD, COG, COM, CPV, DJI) + SSA . (ERI, ETH, GAB, GHA, GIN, GMB, GNB, GNQ, KEN, LBR, LSO, MDG, MLI) + SSA . (MOZ, MRT, MUS, MWI, MYT, NAM, NER, NGA, REU, RWA, SEN, SHN, SLE) + SSA . (SOM, SSD, STP, SWZ, SYC, TCD, TGO, TZA, UGA, ZAF, ZMB, ZWE) + USA . (USA) / + ; *######################### R SECTION END (SETS) ################################ *############################################################################### +set number_order Ensures that numeric values in sets follow ascending order in the GAMS entry order, necessary for using ord() and index lag + / 1*2200 /; + sets + h2(h) Superregional (dynamic set) i2(i) World regions (dynamic set) j2(j) Spatial Clusters (dynamic set) ; + +h2(h) = yes; i2(i) = yes; j2(j) = yes; +sets + c_title defined to include c_title in GDX + / %c_title% / +; ***TIME STEPS*** * ATTENTION: check macros m_year and m_yeardiff if you change something @@ -131,29 +140,62 @@ j2(j) = yes; sets time_annual Annual extended time steps / y1965*y2150 / - t_all 5-year time periods + t_ext 5-year time periods + / + y1965, y1970, y1975, y1980, y1985, y1990, + y1995, y2000, y2005, y2010, y2015, y2020, y2025, y2030, y2035, y2040, + y2045, y2050, y2055, y2060, y2065, y2070, y2075, y2080, y2085, y2090, + y2095, y2100, y2105, y2110, y2115, y2120, y2125, y2130, y2135, y2140, + y2145, y2150, y2155, y2160, y2165, y2170, y2175, y2180, y2185, y2190, + y2195, y2200, y2205, y2210, y2215, y2220, y2225, y2230, y2235, y2240, + y2245, y2250 + / + + t_all(t_ext) 5-year time periods / y1965, y1970, y1975, y1980, y1985, y1990, y1995, y2000, y2005, y2010, y2015, y2020, y2025, y2030, y2035, y2040, y2045, y2050, y2055, y2060, y2065, y2070, y2075, y2080, y2085, y2090, y2095, y2100, y2105, y2110, y2115, y2120, y2125, y2130, y2135, y2140, y2145, y2150 / - t_past(t_all) Timesteps with observed data - / y1965, y1970, y1975, - y1980, y1985, y1990, - y1995, y2000, y2005, y2010 - / + t_historical(t_all) Historical period + / y1965, y1970, y1975, y1980, y1985, y1990 / + + t_future(t_all) 5-year time periods + / y2105, y2110, y2115, y2120, y2125, y2130, y2135, y2140, + y2145, y2150 / + + t_past_forestry(t_all) Forestry Timesteps with observed data + / y1965, y1970, y1975, + y1980, y1985, y1990, + y1995, y2000, y2005, y2010, y2015 + / + ; + +set t_past(t_all) Timesteps with observed data +$If "%c_past%"== "till_2010" /y1965, y1970, y1975, y1980, y1985, y1990,y1995, y2000, y2005, y2010/; +$If "%c_past%"== "till_2015" /y1965, y1970, y1975, y1980, y1985, y1990,y1995, y2000, y2005, y2010, y2015/; +$If "%c_past%"== "till_2020" /y1965, y1970, y1975, y1980, y1985, y1990,y1995, y2000, y2005, y2010, y2015, y2020/; +$If "%c_past%"== "till_1965" /y1965/; +$If "%c_past%"== "till_1975" /y1965, y1970, y1975/; +$If "%c_past%"== "till_1995" /y1965, y1970, y1975, y1980, y1985, y1990, y1995/; + + set t(t_all) Simulated time periods $If "%c_timesteps%"== "less_TS" /y1995,y2000,y2005,y2010,y2015,y2020,y2025,y2030,y2035,y2040,y2045,y2050,y2055,y2060,y2070,y2080,y2090,y2100,y2110,y2130,y2150/; $If "%c_timesteps%"== "coup2100" /y1995,y2000,y2005,y2010,y2015,y2020,y2025,y2030,y2035,y2040,y2045,y2050,y2055,y2060,y2070,y2080,y2090,y2100/; +$If "%c_timesteps%"== "coup2110" /y1995,y2000,y2005,y2010,y2015,y2020,y2025,y2030,y2035,y2040,y2045,y2050,y2055,y2060,y2070,y2080,y2090,y2100,y2110/; $If "%c_timesteps%"== "test_TS" /y1995,y2000,y2005,y2010,y2020,y2030,y2040,y2050,y2070,y2090,y2110,y2130,y2150/; $If "%c_timesteps%"== "TS_benni" /y1995,y2000,y2005,y2010,y2020,y2030,y2040,y2050/; $If "%c_timesteps%"== "TS_WB" /y1995,y2000,y2005,y2010,y2020,y2030,y2040,y2050,y2060,y2070,y2080/; $If "%c_timesteps%"== "5year" /y1995,y2000,y2005,y2010,y2015,y2020,y2025,y2030,y2035,y2040,y2045,y2050,y2055,y2060,y2065,y2070,y2075,y2080,y2085,y2090,y2095,y2100/; $If "%c_timesteps%"== "5year2050" /y1995,y2000,y2005,y2010,y2015,y2020,y2025,y2030,y2035,y2040,y2045,y2050/; +$If "%c_timesteps%"== "5year2070" /y1995,y2000,y2005,y2010,y2015,y2020,y2025,y2030,y2035,y2040,y2045,y2050,y2055,y2060,y2065,y2070/; $If "%c_timesteps%"== "quicktest" /y1995,y2010,y2025/; +$If "%c_timesteps%"== "quicktest2" /y1995,y2020,y2050,y2100/; +$If "%c_timesteps%"== "calib" /y1995,y2000,y2005,y2010,y2015/; $If "%c_timesteps%"== "1" /y1995/; $If "%c_timesteps%"== "2" /y1995,y2000/; $If "%c_timesteps%"== "3" /y1995,y2000,y2010/; @@ -174,6 +216,8 @@ $If "%c_timesteps%"=="17" /y1995,y2000,y2010,y2020,y2030,y2040,y2050,y2060,y2070 $If "%c_timesteps%"=="past" /y1965,y1970,y1975,y1980,y1985,y1990,y1995,y2000,y2005,y2010/; $If "%c_timesteps%"=="pastandfuture" /y1965,y1970,y1975,y1980,y1985,y1990,y1995,y2000,y2005,y2010,y2015,y2020,y2025,y2030,y2035,y2040,y2045,y2050,y2055,y2060,y2065,y2070,y2075,y2080,y2085,y2090,y2095,y2100/; set ct(t) Current time period; +set pt(t) Previous time period; +set ct_all(t_all) Current time period for loops over t_all; alias(t,t2); @@ -200,30 +244,39 @@ sets wat_src Type of water source / surface, ground, technical, ren_ground / ***WATER DEMAND sectors*** - wat_dem Water demand sectors / agriculture, industry, electricity, domestic, ecosystem / + wat_dem Water demand sectors / agriculture, domestic, manufacturing, electricity, ecosystem / ***LAND POOLS*** - land Land pools + land Land pools / crop, past, forestry, primforest, secdforest, urban, other / land_ag(land) Agricultural land pools - / crop, past / + / crop, past / - land_natveg(land) Natural vegetation land pools + land_timber(land) land from which timber can be taken away + / forestry, primforest, secdforest, other / + + land_forest(land_timber) Forested land pools + / forestry, primforest, secdforest / + + land_natveg(land_timber) Natural vegetation land pools / primforest, secdforest, other / - si Suitability classes - / si0, nsi0 / + forest_type forest type + / plantations, natveg / ***Forestry** - ac Age classes / ac0,ac5,ac10,ac15,ac20,ac25,ac30,ac35,ac40,ac45,ac50, + ac Age classes / ac0,ac5,ac10,ac15,ac20,ac25,ac30,ac35,ac40,ac45,ac50, ac55,ac60,ac65,ac70,ac75,ac80,ac85,ac90,ac95,ac100, - ac105,ac110,ac115,ac120,ac125,ac130,ac135,ac140,ac145,ac150, - ac155,ac160,ac165,ac170,ac175,ac180,ac185,ac190,ac195,ac200, - ac205,ac210,ac215,ac220,ac225,ac230,ac235,ac240,ac245,ac250, - ac255,ac260,ac265,ac270,ac275,ac280,ac285,ac290,ac295,acx / + ac105,ac110,ac115,ac120,ac125,ac130,ac135,ac140,ac145, + ac150,ac155,ac160,ac165,ac170,ac175,ac180,ac185,ac190,ac195, + ac200,ac205,ac210,ac215,ac220,ac225,ac230,ac235,ac240,ac245, + ac250,ac255,ac260,ac265,ac270,ac275,ac280,ac285,ac290,ac295, + ac300, acx / + + ac_est(ac) Dynamic subset of age classes for establishment - when Temporal location relative to optimization / before, after / + ac_sub(ac) Dynamic subset of age classes excluding establishment chap_par Chapman-richards parameters / k,m / @@ -256,30 +309,17 @@ sets primforest_vegc, primforest_litc, primforest_soilc, secdforest_vegc, secdforest_litc, secdforest_soilc, urban_vegc, urban_litc, urban_soilc, other_vegc, other_litc, other_soilc, - beccs/ + peatland/ - emis_source_reg(emis_source) Regional emission sources - / inorg_fert, man_crop, awms, resid, man_past, som, - rice, ent_ferm, beccs / - - emis_source_cell(emis_source) Cellular emission sources - / crop_vegc, crop_litc, crop_soilc, - past_vegc, past_litc, past_soilc, - forestry_vegc, forestry_litc, forestry_soilc, - primforest_vegc, primforest_litc, primforest_soilc, -secdforest_vegc, secdforest_litc, secdforest_soilc, urban_vegc, urban_litc, urban_soilc, - other_vegc, other_litc, other_soilc / + emis_oneoff(emis_source) oneoff emission sources + / crop_vegc, crop_litc, crop_soilc, past_vegc, past_litc, past_soilc, forestry_vegc, + forestry_litc, forestry_soilc, primforest_vegc, primforest_litc, primforest_soilc, + secdforest_vegc, secdforest_litc, secdforest_soilc, + urban_vegc, urban_litc, urban_soilc, other_vegc, other_litc, other_soilc / - emis_co2(emis_source_cell) Land pool CO2 emission sources - / crop_vegc, crop_litc, crop_soilc, - past_vegc, past_litc, past_soilc, - forestry_vegc, forestry_litc, forestry_soilc, - primforest_vegc, primforest_litc, primforest_soilc, -secdforest_vegc, secdforest_litc, secdforest_soilc, urban_vegc, urban_litc, urban_soilc, - other_vegc, other_litc, other_soilc / - - co2_forestry(emis_source_cell) Sources of forestry land CO2 emissions - /forestry_vegc, forestry_litc, forestry_soilc/ + emis_annual(emis_source) annual emission sources + / inorg_fert, man_crop, awms, resid, man_past, som, + rice, ent_ferm, resid_burn, peatland / c_pools Carbon pools /vegc,litc,soilc/ @@ -289,7 +329,7 @@ secdforest_vegc, secdforest_litc, secdforest_soilc, urban_vegc, urban_litc, ***RELATIONSHIPS BETWEEN DIFFERENT SETS*** - emis_land(emis_co2,land,c_pools) Mapping between land and carbon pools + emis_land(emis_oneoff,land,c_pools) Mapping between land and carbon pools /crop_vegc . (crop) . (vegc) crop_litc . (crop) . (litc) crop_soilc . (crop) . (soilc) @@ -313,12 +353,10 @@ secdforest_vegc, secdforest_litc, secdforest_soilc, urban_vegc, urban_litc, other_soilc . (other) . (soilc) / - emis_co2_to_forestry(co2_forestry,c_pools) Mapping between forestry land and carbon pools - /forestry_vegc . (vegc) - forestry_litc . (litc) - forestry_soilc . (soilc) - / - ; +alias(ac,ac2); +alias(ac_sub,ac_sub2); +alias(ac_est,ac_est2); + *** EOF sets.gms *** diff --git a/data-changelog.csv b/data-changelog.csv new file mode 100644 index 0000000000..5d003c6cd2 --- /dev/null +++ b/data-changelog.csv @@ -0,0 +1,6 @@ +version,lucEmisRaw2020,lucEmisRaw2050,lucEmisRaw2100,tau2020,tau2050,tau2100,cropland2020,cropland2050,cropland2100,irrigated2020,irrigated2050,irrigated2100,pasture2020,pasture2050,pasture2100,forest2020,forest2050,forest2100,other2020,other2050,other2100,production2020,production2050,production2100,costs2020,costs2050,costs2100,foodExp2020,foodExp2050,foodExp2100 +4.13.0,1990.53,24.95,1285.68,1.28,1.64,1.89,1570.17,1662.21,1923.37,244.01,368.97,471.48,3256.53,3250.17,3171.2,4054.66,3987.36,3960.69,4032.77,3993.42,3828.39,17356.28,22558.33,25170.7,3443728.93,4567396.69,6824370.26,1623.95,2442.77,4916.26 +4.12.0,2640.51,347.36,829.47,1.27,1.61,1.87,1579.89,1695.16,1962.52,245.57,376.49,459.4,3301.45,3295.75,3169.51,4064.46,3993.45,3933.02,3975.83,3902.13,3811.92,16961.85,22246.11,24761.81,3377362.03,4560650.58,6614375.19,1622.25,2443.32,4917.72 +4.11.0,3955.61,609.99,1065.13,1.25,1.6,1.88,1558.03,1640.44,1891.94,242.12,365.49,494.44,3314.14,3324.15,3296.26,4066.85,4006.65,3900.61,3982.6,3915.24,3788.16,16434.28,21917.78,24491.06,3590863.74,4896810.04,6108842.8,1711.18,2540.35,5047.86 +4.10.1,4029.35,937.76,811.98,1.24,1.58,1.86,1570.1,1641.16,1908.36,238.83,369.84,481.77,3312.71,3338.12,3286.4,4064.03,4009.22,3906.25,3974.78,3897.98,3775.96,16532.71,22332.48,24534.96,3595710.82,4904095.84,6267265.88,490.26,541.95,651.09 +4.10.0,4438.37,642.79,2314.92,1.25,1.59,1.9,1567.73,1648.46,2040.84,248.7,372.56,440.97,3317.58,3325.78,3228.85,4062.96,4005.61,3853.23,3973.36,3906.63,3754.05,16573.7,22530.53,28136.87,3587732.56,4920714.93,6352535.16,493.01,546.41,648.25 diff --git a/literature.bib b/literature.bib index ed5c607346..e1bdd4dbe3 100644 --- a/literature.bib +++ b/literature.bib @@ -7,1145 +7,1752 @@ @Article{dietrich_magpie4 NUMBER = {4}, PAGES = {1299--1317}, URL = {https://www.geosci-model-dev.net/12/1299/2019/}, - DOI = {10.5194/gmd-12-1299-2019} + DOI = {10.5194/gmd-12-1299-2019}, } @article{bodirsky_starved_nodate, - title = {From starved to stuffed: {Long}-term dynamics of diets and anthropometrics.}, - author = {Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Martinelli, Eleonora and Stenstad, Anthonia and Pradhan, Prajal and Rolinski, Susanne and Gabrysch, Sabine and Mishra, Abhijit and Le-Mouel, Chantal and Baumstark, Lavinia and Wang, Xiaoxi and Lotze-Campen, Hermann and Popp, Alexander} + title = {The ongoing nutrition transition thwarts long-term targets for food security, public health and environmental protection}, + volume = {10}, + copyright = {2020 The Author(s)}, + issn = {2045-2322}, + url = {https://www.nature.com/articles/s41598-020-75213-3}, + doi = {10.1038/s41598-020-75213-3}, + abstract = {The nutrition transition transforms food systems globally and shapes public health and environmental change. Here we provide a global forward-looking assessment of a continued nutrition transition and its interlinked symptoms in respect to food consumption. These symptoms range from underweight and unbalanced diets to obesity, food waste and environmental pressure. We find that by 2050, 45\% (39–52\%) of the world population will be overweight and 16\% (13–20\%) obese, compared to 29\% and 9\% in 2010 respectively. The prevalence of underweight approximately halves but absolute numbers stagnate at 0.4–0.7 billion. Aligned, dietary composition shifts towards animal-source foods and empty calories, while the consumption of vegetables, fruits and nuts increases insufficiently. Population growth, ageing, increasing body mass and more wasteful consumption patterns are jointly pushing global food demand from 30 to 45 (43–47) Exajoules. Our comprehensive open dataset and model provides the interfaces necessary for integrated studies of global health, food systems, and environmental change. Achieving zero hunger, healthy diets, and a food demand compatible with environmental boundaries necessitates a coordinated redirection of the nutrition transition. Reducing household waste, animal-source foods, and overweight could synergistically address multiple symptoms at once, while eliminating underweight would not substantially increase food demand.}, + language = {en}, + number = {1}, + urldate = {2020-11-18}, + journal = {Scientific Reports}, + author = {Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Martinelli, Eleonora and Stenstad, Antonia and Pradhan, Prajal and Gabrysch, Sabine and Mishra, Abhijeet and Weindl, Isabelle and Le Mouël, Chantal and Rolinski, Susanne and Baumstark, Lavinia and Wang, Xiaoxi and Waid, Jillian L. and Lotze-Campen, Hermann and Popp, Alexander}, + month = nov, + year = {2020}, + note = {Number: 1; Publisher: Nature Publishing Group}, + pages = {19778}, +} + +@article{willett_food_2019, + title = {Food in the {Anthropocene}: the {EAT}-{Lancet} {Commission} on healthy diets from sustainable food systems}, + issn = {01406736}, + shorttitle = {Food in the {Anthropocene}}, + url = {https://linkinghub.elsevier.com/retrieve/pii/S0140673618317884}, + doi = {10.1016/S0140-6736(18)31788-4}, + language = {en}, + urldate = {2019-01-18}, + journal = {The Lancet}, + author = {Willett, Walter and Rockström, Johan and Loken, Brent and Springmann, Marco and Lang, Tim and Vermeulen, Sonja and Garnett, Tara and Tilman, David and DeClerck, Fabrice and Wood, Amanda and Jonell, Malin and Clark, Michael and Gordon, Line J and Fanzo, Jessica and Hawkes, Corinna and Zurayk, Rami and Rivera, Juan A and De Vries, Wim and Majele Sibanda, Lindiwe and Afshin, Ashkan and Chaudhary, Abhishek and Herrero, Mario and Agustina, Rina and Branca, Francesco and Lartey, Anna and Fan, Shenggen and Crona, Beatrice and Fox, Elizabeth and Bignet, Victoria and Troell, Max and Lindahl, Therese and Singh, Sudhvir and Cornell, Sarah E and Srinath Reddy, K and Narain, Sunita and Nishtar, Sania and Murray, Christopher J L}, + month = jan, + 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}}, - publisher = {The Food and Agriculture Organization of the United Nations (FAO)}, - year = {2016}, - address = {Rome}, - url = {http://www.fao.org/faostat/en/}, - } + author = {FAOSTAT}, + title = {{FAOSTAT Database}}, + publisher = {The Food and Agriculture Organization of the United Nations (FAO)}, + year = {2016}, + address = {Rome}, + url = {http://www.fao.org/faostat/en/}, +} @techreport{Calzadilla2011GTAP, - author = {Alvaro Calzadilla and Katrin Rehdanz and Richard S.J. Tol}, - title = {The GTAP-W model: Accounting for water use in agriculture}, - number = {1745}, - publisher = {Kiel Institute for the World Economy (IfW)}, - type = {Kiel Working Paper}, - address = {Kiel}, - url = {http://hdl.handle.net/10419/54939}, - year = {2011} + author = {Alvaro Calzadilla and Katrin Rehdanz and Richard S.J. Tol}, + title = {The GTAP-W model: Accounting for water use in agriculture}, + number = {1745}, + publisher = {Kiel Institute for the World Economy (IfW)}, + type = {Kiel Working Paper}, + address = {Kiel}, + url = {http://hdl.handle.net/10419/54939}, + year = {2011} } @article{LUCAS200785, -title = "Long-term reduction potential of non-CO2 greenhouse gases", -journal = "Environmental Science & Policy", -volume = "10", -number = "2", -pages = "85 - 103", -year = "2007", -issn = "1462-9011", -doi = "https://doi.org/10.1016/j.envsci.2006.10.007", -url = "http://www.sciencedirect.com/science/article/pii/S1462901106001316", -author = "Paul L. Lucas and Detlef P. van Vuuren and Jos G.J. Olivier and Michel G.J. den Elzen", -keywords = "Non-CO, Abatement potential, Technology development, Mitigation scenarios" + title = "Long-term reduction potential of non-CO2 greenhouse gases", + journal = "Environmental Science & Policy", + volume = "10", + number = "2", + pages = "85 - 103", + year = "2007", + issn = "1462-9011", + doi = "https://doi.org/10.1016/j.envsci.2006.10.007", + url = "http://www.sciencedirect.com/science/article/pii/S1462901106001316", + author = "Paul L. Lucas and Detlef P. van Vuuren and Jos G.J. Olivier and Michel G.J. den Elzen", + keywords = "Non-CO, Abatement potential, Technology development, Mitigation scenarios" } @techreport{ipcc_2006_2006, - title = {2006 {IPCC} {Guidelines} for {National} {Greenhouse} {Gas} {Inventories}, {Prepared} by the {National} {Greenhouse} {Gas} {Inventories} {Programme}}, - author = {{IPCC}}, - collaborator = {Eggleston, H. S. and Buendia, L. and Miwa, K. and Ngara, T. and Tanabe, K. and Hayama, K.}, - year = {2006}, - file = {V4_02_Ch2_Generic.pdf:D\:\\Dissertation\\Bibliographie\\storage\\GXSDRG43\\V4_02_Ch2_Generic.pdf:application/pdf} + title = {2006 {IPCC} {Guidelines} for {National} {Greenhouse} {Gas} {Inventories}, {Prepared} by the {National} {Greenhouse} {Gas} {Inventories} {Programme}}, + author = {{IPCC}}, + collaborator = {Eggleston, H. S. and Buendia, L. and Miwa, K. and Ngara, T. and Tanabe, K. and Hayama, K.}, + year = {2006}, } - + @article{kreidenweis_pasture_2018, - title = {Pasture intensification is insufficient to relieve pressure on conservation priority areas in open agricultural markets}, - volume = {0}, - copyright = {© 2018 John Wiley \& Sons Ltd}, - issn = {1365-2486}, - url = {https://onlinelibrary.wiley.com/doi/abs/10.1111/gcb.14272}, - doi = {10.1111/gcb.14272}, - abstract = {Agricultural expansion is a leading driver of biodiversity loss across the world, but little is known on how future land-use change may encroach on remaining natural vegetation. This uncertainty is, in part, due to unknown levels of future agricultural intensification and international trade. Using an economic land-use model, we assessed potential future losses of natural vegetation with a focus on how these may threaten biodiversity hotspots and intact forest landscapes. We analysed agricultural expansion under proactive and reactive biodiversity protection scenarios, and for different rates of pasture intensification. We found growing food demand to lead to a significant expansion of cropland at the expense of pastures and natural vegetation. In our reference scenario, global cropland area increased by more than 400 Mha between 2015 and 2050, mostly in Africa and Latin America. Grazing intensification was a main determinant of future land-use change. In Africa, higher rates of pasture intensification resulted in smaller losses of natural vegetation, and reduced pressure on biodiversity hotspots and intact forest landscapes. Investments into raising pasture productivity in conjunction with proactive land-use planning appear essential in Africa to reduce further losses of areas with high conservation value. In Latin America, in contrast, higher pasture productivity resulted in increased livestock exports, highlighting that unchecked trade can reduce the land savings of pasture intensification. Reactive protection of sensitive areas significantly reduced the conversion of natural ecosystems in Latin America. We conclude that protection strategies need to adapt to region-specific trade positions. In regions with a high involvement in international trade, area-based conservation measures should be preferred over strategies aimed at increasing pasture productivity, which by themselves might not be sufficient to protect biodiversity effectively.}, - language = {en}, - number = {0}, - urldate = {2018-05-28}, - journal = {Global Change Biology}, - author = {Kreidenweis, Ulrich and Humpenöder, Florian and Kehoe, Laura and Kuemmerle, Tobias and Bodirsky, Benjamin Leon and Lotze-Campen, Hermann and Popp, Alexander}, - year = {2018}, - keywords = {biodiversity hotspots, grazing intensification, intact forest landscapes, land sparing, land-use modelling, protected areas}, - file = {Full Text PDF:/Users/flo/Zotero/storage/ADJQ3QCI/Kreidenweis et al. - Pasture intensification is insufficient to relieve.pdf:application/pdf;Snapshot:/Users/flo/Zotero/storage/5DJ3IA3A/gcb.html:text/html} + title = {Pasture intensification is insufficient to relieve pressure on conservation priority areas in open agricultural markets}, + volume = {0}, + copyright = {© 2018 John Wiley \& Sons Ltd}, + issn = {1365-2486}, + url = {https://onlinelibrary.wiley.com/doi/abs/10.1111/gcb.14272}, + doi = {10.1111/gcb.14272}, + abstract = {Agricultural expansion is a leading driver of biodiversity loss across the world, but little is known on how future land-use change may encroach on remaining natural vegetation. This uncertainty is, in part, due to unknown levels of future agricultural intensification and international trade. Using an economic land-use model, we assessed potential future losses of natural vegetation with a focus on how these may threaten biodiversity hotspots and intact forest landscapes. We analysed agricultural expansion under proactive and reactive biodiversity protection scenarios, and for different rates of pasture intensification. We found growing food demand to lead to a significant expansion of cropland at the expense of pastures and natural vegetation. In our reference scenario, global cropland area increased by more than 400 Mha between 2015 and 2050, mostly in Africa and Latin America. Grazing intensification was a main determinant of future land-use change. In Africa, higher rates of pasture intensification resulted in smaller losses of natural vegetation, and reduced pressure on biodiversity hotspots and intact forest landscapes. Investments into raising pasture productivity in conjunction with proactive land-use planning appear essential in Africa to reduce further losses of areas with high conservation value. In Latin America, in contrast, higher pasture productivity resulted in increased livestock exports, highlighting that unchecked trade can reduce the land savings of pasture intensification. Reactive protection of sensitive areas significantly reduced the conversion of natural ecosystems in Latin America. We conclude that protection strategies need to adapt to region-specific trade positions. In regions with a high involvement in international trade, area-based conservation measures should be preferred over strategies aimed at increasing pasture productivity, which by themselves might not be sufficient to protect biodiversity effectively.}, + language = {en}, + number = {0}, + urldate = {2018-05-28}, + journal = {Global Change Biology}, + author = {Kreidenweis, Ulrich and Humpenöder, Florian and Kehoe, Laura and Kuemmerle, Tobias and Bodirsky, Benjamin Leon and Lotze-Campen, Hermann and Popp, Alexander}, + year = {2018}, + keywords = {biodiversity hotspots, grazing intensification, intact forest landscapes, land sparing, land-use modelling, protected areas}, } @article{ramankutty_suitability_2002, - title = {The global distribution of cultivable lands: current patterns and sensitivity to possible climate change}, - volume = {11}, - shorttitle = {The global distribution of cultivable lands}, - url = {http://onlinelibrary.wiley.com/doi/10.1046/j.1466-822x.2002.00294.x/full}, - number = {5}, - urldate = {2014-09-04}, - journal = {Global Ecology and Biogeography}, - author = {Ramankutty, Navin and Foley, Jonathan A. and Norman, John and McSweeney, Kevin}, - year = {2002}, - pages = {377--392}, - file = {Ramankutty_etal_GEB2002.pdf:/Users/flo/Zotero/storage/PJAB52Z8/Ramankutty_etal_GEB2002.pdf:application/pdf} + title = {The global distribution of cultivable lands: current patterns and sensitivity to possible climate change}, + volume = {11}, + shorttitle = {The global distribution of cultivable lands}, + url = {http://onlinelibrary.wiley.com/doi/10.1046/j.1466-822x.2002.00294.x/full}, + number = {5}, + urldate = {2014-09-04}, + journal = {Global Ecology and Biogeography}, + author = {Ramankutty, Navin and Foley, Jonathan A. and Norman, John and McSweeney, Kevin}, + year = {2002}, + pages = {377--392}, } @book{lotze-campen_trade-offs_2009, - title = {The trade-offs between agricultural expansion, intensification and trade: a global bio-economic modelling approach}, - publisher = {FORESIGHT Expert Workshop on Global Food Modelling}, - author = {Lotze-Campen, Hermann and Popp, Alexander and Beringer, T. and M\"uller, Christoph and Bondeau, A. and Rost, S. and Lucht, W.}, - year = {2009} + title = {The trade-offs between agricultural expansion, intensification and trade: a global bio-economic modelling approach}, + publisher = {FORESIGHT Expert Workshop on Global Food Modelling}, + author = {Lotze-Campen, Hermann and Popp, Alexander and Beringer, T. and M\"uller, Christoph and Bondeau, A. and Rost, S. and Lucht, W.}, + year = {2009} } @article{lotze-campen_global_2008, - title = {Global food demand, productivity growth, and the scarcity of land and water resources: a spatially explicit mathematical programming approach}, - volume = {39}, - shorttitle = {Global food demand, productivity growth, and the scarcity of land and water resources}, - number = {3}, - journal = {Agricultural Economics}, - author = {Lotze-Campen, Hermann and M\"uller, Christoph and Bondeau, A. and Rost, S. and Popp, Alexander and Lucht, W.}, - year = {2008}, - pages = {325--338}, - file = {Lotze-Campen et al 2008.pdf:D\:\\Dissertation\\Bibliographie\\storage\\XJ27FXP3\\Lotze-Campen et al 2008.pdf:application/pdf} + title = {Global food demand, productivity growth, and the scarcity of land and water resources: a spatially explicit mathematical programming approach}, + volume = {39}, + shorttitle = {Global food demand, productivity growth, and the scarcity of land and water resources}, + number = {3}, + journal = {Agricultural Economics}, + author = {Lotze-Campen, Hermann and M\"uller, Christoph and Bondeau, A. and Rost, S. and Popp, Alexander and Lucht, W.}, + year = {2008}, + pages = {325--338}, } @inproceedings{krause_spatially-explicit_2009, - address = {Beijing, China}, - title = {Spatially-explicit scenarios on global cropland expansion and available forest land in an integrated modelling framework.}, - booktitle = {27th {International} {Association} of {Agricultural} {Economists} {Conference}}, - author = {Krause, Michael and Lotze-Campen, Hermann and Popp, Alexander}, - year = {2009} + address = {Beijing, China}, + title = {Spatially-explicit scenarios on global cropland expansion and available forest land in an integrated modelling framework.}, + booktitle = {27th {International} {Association} of {Agricultural} {Economists} {Conference}}, + author = {Krause, Michael and Lotze-Campen, Hermann and Popp, Alexander}, + year = {2009} } @article{krause_implicit_nodate, - title = {The implicit value of foregone global cropland expansion – {What} is the impact of forest conservation?}, - author = {Krause, Michael and Lotze-Campen, H. and Popp, Alexander} + title = {The implicit value of foregone global cropland expansion – {What} is the impact of forest conservation?}, + author = {Krause, Michael and Lotze-Campen, H. and Popp, Alexander} } @article{lotze-campen_scenarios_2009, - title = {Scenarios of global bioenergy production: {The} trade-offs between agricultural expansion, intensification and trade}, - shorttitle = {Scenarios of global bioenergy production}, - number = {221}, - journal = {Ecological Modelling}, - author = {Lotze-Campen, Hermann and Popp, Alexander and Beringer, Tim and M\"uller, Christoph and Bondeau, A. and Rost, S. and Lucht, W.}, - year = {2009}, - pages = {2188 -- 2196}, - file = {Lotze-Campen et al. - 2009 - Scenarios of global bioenergy production The trad.pdf:D\:\\Dissertation\\Bibliographie\\storage\\EX7Z9G5T\\Lotze-Campen et al. - 2009 - Scenarios of global bioenergy production The trad.pdf:application/pdf} + title = {Scenarios of global bioenergy production: {The} trade-offs between agricultural expansion, intensification and trade}, + shorttitle = {Scenarios of global bioenergy production}, + number = {221}, + journal = {Ecological Modelling}, + author = {Lotze-Campen, Hermann and Popp, Alexander and Beringer, Tim and M\"uller, Christoph and Bondeau, A. and Rost, S. and Lucht, W.}, + year = {2009}, + pages = {2188 -- 2196}, } @article{schmitz_trading_2012, - title = {Trading more food: {Implications} for land use, greenhouse gas emissions, and the food system}, - volume = {22}, - issn = {09593780}, - shorttitle = {Trading more food}, - url = {http://linkinghub.elsevier.com/retrieve/pii/S0959378011001488}, - doi = {10.1016/j.gloenvcha.2011.09.013}, - number = {1}, - urldate = {2011-10-20}, - journal = {Global Environmental Change}, - author = {Schmitz, Christoph and Biewald, Anne and Lotze-Campen, Hermann and Popp, Alexander and Dietrich, Jan Philipp and Bodirsky, Benjamin Leon and Krause, Michael and Weindl, Isabelle}, - year = {2012}, - pages = {189--209}, - file = {main2.pdf:D\:\\Dissertation\\Bibliographie\\storage\\2QX97EZJ\\main2.pdf:application/pdf;Schmitz et al. - 2012 - Trading more food Implications for land use, gree.pdf:D\:\\Dissertation\\Bibliographie\\storage\\MJMK8XRD\\Schmitz et al. - 2012 - Trading more food Implications for land use, gree.pdf:application/pdf} + title = {Trading more food: {Implications} for land use, greenhouse gas emissions, and the food system}, + volume = {22}, + issn = {09593780}, + shorttitle = {Trading more food}, + url = {http://linkinghub.elsevier.com/retrieve/pii/S0959378011001488}, + doi = {10.1016/j.gloenvcha.2011.09.013}, + number = {1}, + urldate = {2011-10-20}, + journal = {Global Environmental Change}, + author = {Schmitz, Christoph and Biewald, Anne and Lotze-Campen, Hermann and Popp, Alexander and Dietrich, Jan Philipp and Bodirsky, Benjamin Leon and Krause, Michael and Weindl, Isabelle}, + year = {2012}, + pages = {189--209}, } @inproceedings{weindl_impact_2010, - address = {Stuttgart, Germany}, - title = {Impact of livestock feeding technologies on global greenhouse gas emissions}, - volume = {91277}, - booktitle = {Climate {Change} in {World} {Agriculture}: {Mitigation}, {Adaptation}, {Trade} and {Food} {Security}}, - publisher = {International Agricultural Trade Research Consortium}, - author = {Weindl, Isabelle and Lotze-Campen, Hermann and Popp, Alexander and Bodirsky, Benjamin Leon and Rolinski, Susanne}, - month = jun, - year = {2010}, - pages = {1--21}, - file = {Weindl et al. - 2010 - Impact of livestock feeding technologies on global.pdf:D\:\\Dissertation\\Bibliographie\\storage\\KRPS6JDF\\Weindl et al. - 2010 - Impact of livestock feeding technologies on global.pdf:application/pdf;weindl_livestock_impacts_on_GHG-updated.ppt:D\:\\Dissertation\\Bibliographie\\storage\\B8J5T4ZR\\weindl_livestock_impacts_on_GHG-updated.ppt:application/msword} + address = {Stuttgart, Germany}, + title = {Impact of livestock feeding technologies on global greenhouse gas emissions}, + volume = {91277}, + booktitle = {Climate {Change} in {World} {Agriculture}: {Mitigation}, {Adaptation}, {Trade} and {Food} {Security}}, + publisher = {International Agricultural Trade Research Consortium}, + author = {Weindl, Isabelle and Lotze-Campen, Hermann and Popp, Alexander and Bodirsky, Benjamin Leon and Rolinski, Susanne}, + month = jun, + year = {2010}, + pages = {1--21}, } @misc{schmitz_implementing_2010, - address = {Penang (Malaysia)}, - title = {Implementing endogenous technological change in a global land-use model.}, - url = {www.gtap.agecon.purdue.edu/resources/download/5584.pdf}, - author = {Schmitz, Christoph and Dietrich, Jan Philipp and Lotze-Campen, Hermann and M\"uller, Christoph and Popp, Alexander}, - month = jun, - year = {2010} + address = {Penang (Malaysia)}, + title = {Implementing endogenous technological change in a global land-use model.}, + url = {www.gtap.agecon.purdue.edu/resources/download/5584.pdf}, + author = {Schmitz, Christoph and Dietrich, Jan Philipp and Lotze-Campen, Hermann and M\"uller, Christoph and Popp, Alexander}, + month = jun, + year = {2010} } @article{popp_additional_2012, - title = {Additional {CO}2 emissions from land use change -- forest conservation as a precondition for sustainable production of second generation bioenergy.}, - volume = {74}, - journal = {Ecological Economics}, - author = {Popp, Alexander and Krause, Michael and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Leimbach, Marian and Beringer, Tim and Bauer, Nico}, - year = {2012}, - pages = {64--70}, - file = {Popp et al. - 2012 - Additional CO2 emissions from land use change -- f.pdf:D\:\\Dissertation\\Bibliographie\\storage\\P4QJS7AC\\Popp et al. - 2012 - Additional CO2 emissions from land use change -- f.pdf:application/pdf} + title = {Additional {CO}2 emissions from land use change -- forest conservation as a precondition for sustainable production of second generation bioenergy.}, + volume = {74}, + journal = {Ecological Economics}, + author = {Popp, Alexander and Krause, Michael and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Leimbach, Marian and Beringer, Tim and Bauer, Nico}, + year = {2012}, + pages = {64--70}, } @article{popp_economic_2011, - title = {The economic potential of bioenergy for climate change mitigation with special attention given to implications for the land system}, - volume = {6}, - number = {034017}, - journal = {Environmental Research Letters}, - author = {Popp, Alexander and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Klein, David and Bauer, N. and Krause, Michael and Beringer, T. and Gerten, D. and Edenhofer, O.}, - year = {2011}, - pages = {1--9}, - file = {Popp et al. - 2011 - The economic potential of bioenergy for climate ch.pdf:D\:\\Dissertation\\Bibliographie\\storage\\H8DJW4WK\\Popp et al. - 2011 - The economic potential of bioenergy for climate ch.pdf:application/pdf} + title = {The economic potential of bioenergy for climate change mitigation with special attention given to implications for the land system}, + volume = {6}, + number = {034017}, + journal = {Environmental Research Letters}, + author = {Popp, Alexander and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Klein, David and Bauer, N. and Krause, Michael and Beringer, T. and Gerten, D. and Edenhofer, O.}, + year = {2011}, + pages = {1--9}, } @article{bodirsky_current_2012, - title = {Current state and future scenarios of the global agricultural nitrogen cycle}, - volume = {9}, - issn = {1810-6285}, - url = {http://www.biogeosciences-discuss.net/9/2755/2012/}, - doi = {10.5194/bgd-9-2755-2012}, - number = {3}, - urldate = {2012-03-13}, - journal = {Biogeosciences Discuss.}, - author = {Bodirsky, Benjamin Leon and Popp, Alexander and Weindl, Isabelle and Dietrich, Jan Philipp and Rolinski, Susanne and Scheiffele, Lena and Schmitz, Christoph and Lotze-Campen, Hermann}, - month = mar, - year = {2012}, - pages = {2755--2821}, - file = {bgd-9-C604-2012.pdf:D\:\\Dissertation\\Bibliographie\\storage\\2XV9TJPV\\bgd-9-C604-2012.pdf:application/pdf;bgd-9-C905-2012.pdf:D\:\\Dissertation\\Bibliographie\\storage\\BH6DPUUV\\bgd-9-C905-2012.pdf:application/pdf;bgd-9-C2463-2012.pdf:D\:\\Dissertation\\Bibliographie\\storage\\PE4WF8B8\\bgd-9-C2463-2012.pdf:application/pdf;Biogeosciences Discuss. PDF:D\:\\Dissertation\\Bibliographie\\storage\\8WUT58K5\\Bodirsky et al. - 2012 - Current state and future scenarios of the global a.pdf:application/pdf;Biogeosciences Discuss. Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\8CAQXZ47\\Bodirsky et al. - 2012 - Current state and future scenarios of the global a.html:text/html} + title = {Current state and future scenarios of the global agricultural nitrogen cycle}, + volume = {9}, + issn = {1810-6285}, + url = {http://www.biogeosciences-discuss.net/9/2755/2012/}, + doi = {10.5194/bgd-9-2755-2012}, + number = {3}, + urldate = {2012-03-13}, + journal = {Biogeosciences Discuss.}, + author = {Bodirsky, Benjamin Leon and Popp, Alexander and Weindl, Isabelle and Dietrich, Jan Philipp and Rolinski, Susanne and Scheiffele, Lena and Schmitz, Christoph and Lotze-Campen, Hermann}, + month = mar, + year = {2012}, + pages = {2755--2821}, } @article{bodirsky_n2o_2012, - title = {N2O emissions from the global agricultural nitrogen cycle – current state and future scenarios}, - volume = {9}, - issn = {1726-4189}, - url = {http://www.biogeosciences.net/9/4169/2012/}, - doi = {10.5194/bg-9-4169-2012}, - number = {10}, - urldate = {2012-10-31}, - journal = {Biogeosciences}, - author = {Bodirsky, Benjamin Leon and Popp, Alexander and Weindl, Isabelle and Dietrich, Jan Philipp and Rolinski, Susanne and Scheiffele, Lena and Schmitz, Christoph and Lotze-Campen, Hermann}, - month = oct, - year = {2012}, - pages = {4169--4197}, - file = {Bodirsky et al. - 2012 - N2O emissions from the global agricultural nitroge.pdf:D\:\\Dissertation\\Bibliographie\\storage\\ICF7BCNT\\Bodirsky et al. - 2012 - N2O emissions from the global agricultural nitroge.pdf:application/pdf;supplementary_model_outputs.xls:D\:\\Dissertation\\Bibliographie\\storage\\3W2RXT8B\\supplementary_model_outputs.xls:application/msword} + title = {N2O emissions from the global agricultural nitrogen cycle – current state and future scenarios}, + volume = {9}, + issn = {1726-4189}, + url = {http://www.biogeosciences.net/9/4169/2012/}, + doi = {10.5194/bg-9-4169-2012}, + number = {10}, + urldate = {2012-10-31}, + journal = {Biogeosciences}, + author = {Bodirsky, Benjamin Leon and Popp, Alexander and Weindl, Isabelle and Dietrich, Jan Philipp and Rolinski, Susanne and Scheiffele, Lena and Schmitz, Christoph and Lotze-Campen, Hermann}, + month = oct, + year = {2012}, + pages = {4169--4197}, } @article{popp_food_2010, - title = {Food consumption, diet shifts and associated non-{CO}2 greenhouse gases from agricultural production}, - volume = {20}, - issn = {09593780}, - url = {http://linkinghub.elsevier.com/retrieve/pii/S0959378010000075}, - doi = {10.1016/j.gloenvcha.2010.02.001}, - number = {3}, - urldate = {2012-10-31}, - journal = {Global Environmental Change}, - author = {Popp, Alexander and Lotze-Campen, Hermann and Bodirsky, Benjamin}, - month = aug, - year = {2010}, - pages = {451--462}, - file = {Food consumption, diet shifts and associated non-CO2 greenhouse gases from agricultural production - 1-s2.0-S0959378010000075-main.pdf:D\:\\Dissertation\\Bibliographie\\storage\\HIEWB6DE\\1-s2.0-S0959378010000075-main.pdf:application/pdf;Popp et al. - 2010 - Food consumption, diet shifts and associated non-C.pdf:D\:\\Dissertation\\Bibliographie\\storage\\9EJQUAT4\\Popp et al. - 2010 - Food consumption, diet shifts and associated non-C.pdf:application/pdf;popp et al.pdf:D\:\\Dissertation\\Bibliographie\\storage\\9CMGNTED\\popp et al.pdf:application/pdf} + title = {Food consumption, diet shifts and associated non-{CO}2 greenhouse gases from agricultural production}, + volume = {20}, + issn = {09593780}, + url = {http://linkinghub.elsevier.com/retrieve/pii/S0959378010000075}, + doi = {10.1016/j.gloenvcha.2010.02.001}, + number = {3}, + urldate = {2012-10-31}, + journal = {Global Environmental Change}, + author = {Popp, Alexander and Lotze-Campen, Hermann and Bodirsky, Benjamin}, + month = aug, + year = {2010}, + pages = {451--462}, } @article{popp_sustainability_2011, - title = {On sustainability of bioenergy production: {Integrating} co-emissions from agricultural intensification}, - volume = {35}, - issn = {09619534}, - shorttitle = {On sustainability of bioenergy production}, - url = {http://linkinghub.elsevier.com/retrieve/pii/S0961953410002230}, - doi = {10.1016/j.biombioe.2010.06.014}, - number = {12}, - urldate = {2012-10-31}, - journal = {Biomass and Bioenergy}, - author = {Popp, Alexander and Lotze-Campen, Hermann and Leimbach, Marian and Knopf, Brigitte and Beringer, Tim and Bauer, Nico and Bodirsky, Benjamin}, - month = dec, - year = {2011}, - pages = {4770--4780}, - file = {Popp et al. - 2010 - On sustainability of bioenergy production Integra.pdf:D\:\\Dissertation\\Bibliographie\\storage\\7REFCZI2\\Popp et al. - 2010 - On sustainability of bioenergy production Integra.pdf:application/pdf} + title = {On sustainability of bioenergy production: {Integrating} co-emissions from agricultural intensification}, + volume = {35}, + issn = {09619534}, + shorttitle = {On sustainability of bioenergy production}, + url = {http://linkinghub.elsevier.com/retrieve/pii/S0961953410002230}, + doi = {10.1016/j.biombioe.2010.06.014}, + number = {12}, + urldate = {2012-10-31}, + journal = {Biomass and Bioenergy}, + author = {Popp, Alexander and Lotze-Campen, Hermann and Leimbach, Marian and Knopf, Brigitte and Beringer, Tim and Bauer, Nico and Bodirsky, Benjamin}, + month = dec, + year = {2011}, + pages = {4770--4780}, } @article{bodirsky_global_2015, - title = {Global food demand scenarios for the 21st century}, - doi = {10.1371/journal.pone.0139201}, - journal = {PLoS ONE}, - author = {Bodirsky, Benjamin Leon and Rolinski, Susanne and Biewald, Anne and Weindl, Isabelle and Popp, Alexander and Lotze-Campen, H.}, - year = {2015}, - file = {Bodirsky et al. - Food demand projections for the 21st century.pdf:D\:\\Dissertation\\Bibliographie\\storage\\URVM3GAD\\Bodirsky et al. - Food demand projections for the 21st century.pdf:application/pdf;Global food demand scenarios for the 21st century.pdf:D\:\\Dissertation\\Bibliographie\\storage\\MWXWJMRU\\Global food demand scenarios for the 21st century.pdf:application/pdf} + title = {Global food demand scenarios for the 21st century}, + doi = {10.1371/journal.pone.0139201}, + journal = {PLoS ONE}, + author = {Bodirsky, Benjamin Leon and Rolinski, Susanne and Biewald, Anne and Weindl, Isabelle and Popp, Alexander and Lotze-Campen, H.}, + year = {2015}, } @article{krause_conservation_2013, - title = {Conservation of undisturbed natural forests and economic impacts on agriculture}, - volume = {30}, - issn = {02648377}, - url = {http://linkinghub.elsevier.com/retrieve/pii/S0264837712000543}, - doi = {10.1016/j.landusepol.2012.03.020}, - number = {1}, - urldate = {2013-02-12}, - journal = {Land Use Policy}, - author = {Krause, Michael and Lotze-Campen, Hermann and Popp, Alexander and Dietrich, Jan Philipp and Bonsch, Markus}, - month = jan, - year = {2013}, - pages = {344--354}, - file = {Krause et al. - 2013 - Conservation of undisturbed natural forests and ec.pdf:D\:\\Dissertation\\Bibliographie\\storage\\TB6XWXH6\\Krause et al. - 2013 - Conservation of undisturbed natural forests and ec.pdf:application/pdf} + title = {Conservation of undisturbed natural forests and economic impacts on agriculture}, + volume = {30}, + issn = {02648377}, + url = {http://linkinghub.elsevier.com/retrieve/pii/S0264837712000543}, + doi = {10.1016/j.landusepol.2012.03.020}, + number = {1}, + urldate = {2013-02-12}, + journal = {Land Use Policy}, + author = {Krause, Michael and Lotze-Campen, Hermann and Popp, Alexander and Dietrich, Jan Philipp and Bonsch, Markus}, + month = jan, + year = {2013}, + pages = {344--354}, } @techreport{bodirsky_how_2009, - title = {How can each sector contribute to 2C?}, - url = {http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.177.8150&rep=rep1&type=pdf}, - urldate = {2013-06-11}, - institution = {PIK Potsdam}, - author = {Bodirsky, Benjamin Leon and Kampman, B. and Lotze-Campen, Hermann and Markowska, A. and Monjon, S. and Neuhoff, K. and Noleppa, S. and Popp, Alexander and del Río González, P. and Spielmans, S. and Strohschein, J.}, - year = {2009}, - file = {Bodirsky et al. - How can each sector contribute to 2C.pdf:D\:\\Dissertation\\Bibliographie\\storage\\WUW8JPDN\\Bodirsky et al. - How can each sector contribute to 2C.pdf:application/pdf} + title = {How can each sector contribute to 2C?}, + url = {http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.177.8150&rep=rep1&type=pdf}, + urldate = {2013-06-11}, + institution = {PIK Potsdam}, + author = {Bodirsky, Benjamin Leon and Kampman, B. and Lotze-Campen, Hermann and Markowska, A. and Monjon, S. and Neuhoff, K. and Noleppa, S. and Popp, Alexander and del Río González, P. and Spielmans, S. and Strohschein, J.}, + year = {2009}, } @article{schmitz_blue_2013, - title = {Blue water scarcity and the economic impacts of future agricultural trade and demand}, - volume = {49}, - copyright = {©2013. American Geophysical Union. All Rights Reserved.}, - issn = {1944-7973}, - url = {http://onlinelibrary.wiley.com/doi/10.1002/wrcr.20188/abstract}, - doi = {10.1002/wrcr.20188}, - abstract = {An increasing demand for agricultural goods affects the pressure on global water resources over the coming decades. In order to quantify these effects, we have developed a new agroeconomic water scarcity indicator, considering explicitly economic processes in the agricultural system. The indicator is based on the water shadow price generated by an economic land use model linked to a global vegetation-hydrology model. Irrigation efficiency is implemented as a dynamic input depending on the level of economic development. We are able to simulate the heterogeneous distribution of water supply and agricultural water demand for irrigation through the spatially explicit representation of agricultural production. This allows in identifying regional hot spots of blue water scarcity and explicit shadow prices for water. We generate scenarios based on moderate policies regarding future trade liberalization and the control of livestock-based consumption, dependent on different population and gross domestic product (GDP) projections. Results indicate increased water scarcity in the future, especially in South Asia, the Middle East, and north Africa. In general, water shadow prices decrease with increasing liberalization, foremost in South Asia, Southeast Asia, and the Middle East. Policies to reduce livestock consumption in developed countries not only lower the domestic pressure on water but also alleviate water scarcity to a large extent in developing countries. It is shown that one of the two policy options would be insufficient for most regions to retain water scarcity in 2045 on levels comparable to 2005.}, - language = {en}, - number = {6}, - urldate = {2013-08-16}, - journal = {Water Resources Research}, - author = {Schmitz, Christoph and Lotze-Campen, Hermann and Gerten, Dieter and Dietrich, Jan Philipp and Bodirsky, Benjamin and Biewald, Anne and Popp, Alexander}, - year = {2013}, - keywords = {water scarcity, land use model, irrigation efficiency, trade liberalization, livestock consumption}, - pages = {3601--3617}, - file = {Full Text PDF:D\:\\Dissertation\\Bibliographie\\storage\\ZKUG46RN\\Schmitz et al. - 2013 - Blue water scarcity and the economic impacts of fu.pdf:application/pdf;Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\4I9N95NZ\\abstract.html:text/html} + title = {Blue water scarcity and the economic impacts of future agricultural trade and demand}, + volume = {49}, + copyright = {©2013. American Geophysical Union. All Rights Reserved.}, + issn = {1944-7973}, + url = {http://onlinelibrary.wiley.com/doi/10.1002/wrcr.20188/abstract}, + doi = {10.1002/wrcr.20188}, + abstract = {An increasing demand for agricultural goods affects the pressure on global water resources over the coming decades. In order to quantify these effects, we have developed a new agroeconomic water scarcity indicator, considering explicitly economic processes in the agricultural system. The indicator is based on the water shadow price generated by an economic land use model linked to a global vegetation-hydrology model. Irrigation efficiency is implemented as a dynamic input depending on the level of economic development. We are able to simulate the heterogeneous distribution of water supply and agricultural water demand for irrigation through the spatially explicit representation of agricultural production. This allows in identifying regional hot spots of blue water scarcity and explicit shadow prices for water. We generate scenarios based on moderate policies regarding future trade liberalization and the control of livestock-based consumption, dependent on different population and gross domestic product (GDP) projections. Results indicate increased water scarcity in the future, especially in South Asia, the Middle East, and north Africa. In general, water shadow prices decrease with increasing liberalization, foremost in South Asia, Southeast Asia, and the Middle East. Policies to reduce livestock consumption in developed countries not only lower the domestic pressure on water but also alleviate water scarcity to a large extent in developing countries. It is shown that one of the two policy options would be insufficient for most regions to retain water scarcity in 2045 on levels comparable to 2005.}, + language = {en}, + number = {6}, + urldate = {2013-08-16}, + journal = {Water Resources Research}, + author = {Schmitz, Christoph and Lotze-Campen, Hermann and Gerten, Dieter and Dietrich, Jan Philipp and Bodirsky, Benjamin and Biewald, Anne and Popp, Alexander}, + year = {2013}, + keywords = {water scarcity, land use model, irrigation efficiency, trade liberalization, livestock consumption}, + pages = {3601--3617}, } @article{bodirsky_stuck_nodate, - title = {Stuck in the {Anthropocene}. {The} case of reactive {Nitrogen}.}, - journal = {Nature Communications}, - author = {Bodirsky, Benjamin Leon and Popp, Alexander and Lotze-Campen, Hermann and Dietrich, Jan Philipp and Rolinski, Susanne and Weindl, Isabelle and Schmitz, Christoph and M\"uller, Christoph and Bonsch, Markus and Humpenöder, Florian and Biewald, Anne and Stevanovic, Miodrag}, - file = {Bodirsky et al_0000_Stuck in the Anthropocene.xls:D\:\\Dissertation\\Bibliographie\\storage\\C5JSJS5U\\Bodirsky et al_0000_Stuck in the Anthropocene.xls:application/msword;Bodirsky et al. - Stuck in the Anthropocene. The case of reactive Ni.pdf:D\:\\Dissertation\\Bibliographie\\storage\\H5NEZFA9\\Bodirsky et al. - Stuck in the Anthropocene. The case of reactive Ni.pdf:application/pdf} + title = {Stuck in the {Anthropocene}. {The} case of reactive {Nitrogen}.}, + journal = {Nature Communications}, + author = {Bodirsky, Benjamin Leon and Popp, Alexander and Lotze-Campen, Hermann and Dietrich, Jan Philipp and Rolinski, Susanne and Weindl, Isabelle and Schmitz, Christoph and M\"uller, Christoph and Bonsch, Markus and Humpenöder, Florian and Biewald, Anne and Stevanovic, Miodrag}, } @article{dietrich_measuring_2012, - title = {Measuring agricultural land-use intensity – {A} global analysis using a model-assisted approach}, - volume = {232}, - issn = {03043800}, - url = {http://linkinghub.elsevier.com/retrieve/pii/S0304380012001093}, - doi = {10.1016/j.ecolmodel.2012.03.002}, - urldate = {2013-10-17}, - journal = {Ecological Modelling}, - author = {Dietrich, Jan Philipp and Schmitz, Christoph and M\"uller, Christoph and Fader, Marianela and Lotze-Campen, Hermann and Popp, Alexander}, - month = may, - year = {2012}, - pages = {109--118}, - file = {Dietrich et al 2012 EcolModelling.pdf:D\:\\Dissertation\\Bibliographie\\storage\\45WT64QX\\Dietrich et al 2012 EcolModelling.pdf:application/pdf} + title = {Measuring agricultural land-use intensity – {A} global analysis using a model-assisted approach}, + volume = {232}, + issn = {03043800}, + url = {http://linkinghub.elsevier.com/retrieve/pii/S0304380012001093}, + doi = {10.1016/j.ecolmodel.2012.03.002}, + urldate = {2013-10-17}, + journal = {Ecological Modelling}, + author = {Dietrich, Jan Philipp and Schmitz, Christoph and M\"uller, Christoph and Fader, Marianela and Lotze-Campen, Hermann and Popp, Alexander}, + month = may, + year = {2012}, + pages = {109--118}, } @article{klein_value_2013, - title = {The value of bioenergy in low stabilization scenarios: an assessment using {REMIND}-{MAgPIE}}, - issn = {0165-0009, 1573-1480}, - shorttitle = {The value of bioenergy in low stabilization scenarios}, - url = {http://link.springer.com/article/10.1007/s10584-013-0940-z}, - doi = {10.1007/s10584-013-0940-z}, - abstract = {This study investigates the use of bioenergy for achieving stringent climate stabilization targets and it analyzes the economic drivers behind the choice of bioenergy technologies. We apply the integrated assessment framework REMIND-MAgPIE to show that bioenergy, particularly if combined with carbon capture and storage (CCS) is a crucial mitigation option with high deployment levels and high technology value. If CCS is available, bioenergy is exclusively used with CCS. We find that the ability of bioenergy to provide negative emissions gives rise to a strong nexus between biomass prices and carbon prices. Ambitious climate policy could result in bioenergy prices of 70 /GJ(oreven430/GJ (or even 430 /GJ if bioenergy potential is limited to 100 EJ/year), which indicates a strong demand for bioenergy. For low stabilization scenarios with BECCS availability, we find that the carbon value of biomass tends to exceed its pure energy value. Therefore, the driving factor behind investments into bioenergy conversion capacities for electricity and hydrogen production are the revenues generated from negative emissions, rather than from energy production. However, in REMIND modern bioenergy is predominantly used to produce low-carbon fuels, since the transport sector has significantly fewer low-carbon alternatives to biofuels than the power sector. Since negative emissions increase the amount of permissible emissions from fossil fuels, given a climate target, bioenergy acts as a complement to fossils rather than a substitute. This makes the short-term and long-term deployment of fossil fuels dependent on the long-term availability of BECCS.}, - language = {en}, - urldate = {2013-10-09}, - journal = {Climatic Change}, - author = {Klein, David and Luderer, Gunnar and Kriegler, Elmar and Strefler, Jessica and Bauer, Nico and Leimbach, Marian and Popp, Alexander and Dietrich, Jan Philipp and Humpenöder, Florian and Lotze-Campen, Hermann and Edenhofer, Ottmar}, - year = {2013}, - keywords = {Atmospheric Sciences, Climate Change Impacts}, - pages = {1--14}, - file = {Klein et al_The value of bioenergy in low stabilization scenarios.pdf:D\:\\Dissertation\\Bibliographie\\storage\\DF9W32JG\\Klein et al_The value of bioenergy in low stabilization scenarios.pdf:application/pdf;Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\KIDBMZJI\\s10584-013-0940-z.html:text/html} + title = {The value of bioenergy in low stabilization scenarios: an assessment using {REMIND}-{MAgPIE}}, + issn = {0165-0009, 1573-1480}, + shorttitle = {The value of bioenergy in low stabilization scenarios}, + url = {http://link.springer.com/article/10.1007/s10584-013-0940-z}, + doi = {10.1007/s10584-013-0940-z}, + abstract = {This study investigates the use of bioenergy for achieving stringent climate stabilization targets and it analyzes the economic drivers behind the choice of bioenergy technologies. We apply the integrated assessment framework REMIND-MAgPIE to show that bioenergy, particularly if combined with carbon capture and storage (CCS) is a crucial mitigation option with high deployment levels and high technology value. If CCS is available, bioenergy is exclusively used with CCS. We find that the ability of bioenergy to provide negative emissions gives rise to a strong nexus between biomass prices and carbon prices. Ambitious climate policy could result in bioenergy prices of 70 /GJ(oreven430/GJ (or even 430 /GJ if bioenergy potential is limited to 100 EJ/year), which indicates a strong demand for bioenergy. For low stabilization scenarios with BECCS availability, we find that the carbon value of biomass tends to exceed its pure energy value. Therefore, the driving factor behind investments into bioenergy conversion capacities for electricity and hydrogen production are the revenues generated from negative emissions, rather than from energy production. However, in REMIND modern bioenergy is predominantly used to produce low-carbon fuels, since the transport sector has significantly fewer low-carbon alternatives to biofuels than the power sector. Since negative emissions increase the amount of permissible emissions from fossil fuels, given a climate target, bioenergy acts as a complement to fossils rather than a substitute. This makes the short-term and long-term deployment of fossil fuels dependent on the long-term availability of BECCS.}, + language = {en}, + urldate = {2013-10-09}, + journal = {Climatic Change}, + author = {Klein, David and Luderer, Gunnar and Kriegler, Elmar and Strefler, Jessica and Bauer, Nico and Leimbach, Marian and Popp, Alexander and Dietrich, Jan Philipp and Humpenöder, Florian and Lotze-Campen, Hermann and Edenhofer, Ottmar}, + year = {2013}, + keywords = {Atmospheric Sciences, Climate Change Impacts}, + pages = {1--14}, } @article{dietrich_forecasting_2014, - title = {Forecasting technological change in agriculture—{An} endogenous implementation in a global land use model}, - volume = {81}, - issn = {00401625}, - url = {http://edoc.gfz-potsdam.de/pik/display.epl?mode=doc&id=5818}, - doi = {10.1016/j.techfore.2013.02.003}, - urldate = {2013-10-17}, - journal = {Technological Forecasting and Social Change}, - author = {Dietrich, Jan Philipp and Schmitz, Christoph and Lotze-Campen, Hermann and Popp, Alexander and M\"uller, Christoph}, - year = {2014}, - pages = {236--249}, + title = {Forecasting technological change in agriculture—{An} endogenous implementation in a global land use model}, + volume = {81}, + issn = {00401625}, + url = {http://edoc.gfz-potsdam.de/pik/display.epl?mode=doc&id=5818}, + doi = {10.1016/j.techfore.2013.02.003}, + urldate = {2013-10-17}, + journal = {Technological Forecasting and Social Change}, + author = {Dietrich, Jan Philipp and Schmitz, Christoph and Lotze-Campen, Hermann and Popp, Alexander and M\"uller, Christoph}, + year = {2014}, + pages = {236--249}, } @article{dietrich_reducing_2013, - title = {Reducing the loss of information and gaining accuracy with clustering methods in a global land-use model}, - volume = {263}, - issn = {0304-3800}, - url = {http://www.sciencedirect.com/science/article/pii/S0304380013002603}, - doi = {10.1016/j.ecolmodel.2013.05.009}, - abstract = {Abstract + title = {Reducing the loss of information and gaining accuracy with clustering methods in a global land-use model}, + volume = {263}, + issn = {0304-3800}, + url = {http://www.sciencedirect.com/science/article/pii/S0304380013002603}, + doi = {10.1016/j.ecolmodel.2013.05.009}, + abstract = {Abstract Global land-use models have to deal with processes on several spatial scales, ranging from the global scale down to the farm level. The increasing complexity of modern land-use models combined with the problem of limited computational resources represents a challenge to modelers. One solution of this problem is to perform spatial aggregation based on a regular grid or administrative units such as countries. Unfortunately this type of aggregation flattens many regional differences and produces a homogenized map of the world. In this paper we present an alternative aggregation approach using clustering methods. Clustering reduces the loss of information due to aggregation by choosing an appropriate aggregation pattern. We investigate different clustering methods, examining their quality in terms of information conservation. Our results indicate that clustering is always a good choice and preferable compared to grid-based aggregation. Although all the clustering methods we tested delivered a higher degree of information conservation than grid-based aggregation, the choice of clustering method is not arbitrary. Comparing outputs of a model fed with original data and a model fed with aggregated data, bottom-up clustering delivered the best results for the whole range of numbers of clusters tested.}, - urldate = {2013-11-15}, - journal = {Ecological Modelling}, - author = {Dietrich, Jan Philipp and Popp, Alexander and Lotze-Campen, Hermann}, - month = aug, - year = {2013}, - keywords = {land use model, Aggregation, Downscaling, Clustering, Information conservation, Scale}, - pages = {233--243}, - file = {Reducing the loss of information and gaining accuracy with clustering methods in a global land-use model - 1-s2.0-S0304380013002603-main.pdf:D\:\\Dissertation\\Bibliographie\\storage\\US8NUNNB\\1-s2.0-S0304380013002603-main.pdf:application/pdf;ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\GWA63H4U\\S0304380013002603.html:text/html} + urldate = {2013-11-15}, + journal = {Ecological Modelling}, + author = {Dietrich, Jan Philipp and Popp, Alexander and Lotze-Campen, Hermann}, + month = aug, + year = {2013}, + keywords = {land use model, Aggregation, Downscaling, Clustering, Information conservation, Scale}, + pages = {233--243}, } @article{bodirsky_reactive_2014, - title = {Reactive nitrogen requirements to feed the world in 2050 and potential to mitigate nitrogen pollution}, - volume = {5}, - issn = {2041-1723}, - url = {http://www.nature.com/doifinder/10.1038/ncomms4858}, - doi = {10.1038/ncomms4858}, - urldate = {2014-05-13}, - journal = {Nature Communications}, - author = {Bodirsky, Benjamin Leon and Popp, Alexander and Lotze-Campen, Hermann and Dietrich, Jan Philipp and Rolinski, Susanne and Weindl, Isabelle and Schmitz, Christoph and M\"uller, Christoph and Bonsch, Markus and Humpenöder, Florian and Biewald, Anne and Stevanovic, Miodrag}, - month = may, - year = {2014}, - file = {Bodirsky et al. - 2014 - Reactive nitrogen requirements to feed the world i.pdf:D\:\\Dissertation\\Bibliographie\\storage\\R7XMSXPR\\Bodirsky et al. - 2014 - Reactive nitrogen requirements to feed the world i.pdf:application/pdf;Supplementary Data 1_Bodirsky et al_2014_Reactive nitrogen requirements to feed the world in 2050 and potential to.xls:D\:\\Dissertation\\Bibliographie\\storage\\RQFP2NNQ\\Bodirsky et al_2014_Reactive nitrogen requirements to feed the world in 2050 and potential to.xls:application/msword;Supplementary Data 2_Bodirsky et al_2014_Reactive nitrogen requirements to feed the world in 2050 and potential to.xls:D\:\\Dissertation\\Bibliographie\\storage\\8S5EJV5D\\Bodirsky et al_2014_Reactive nitrogen requirements to feed the world in 2050 and potential to.xls:application/msword} + title = {Reactive nitrogen requirements to feed the world in 2050 and potential to mitigate nitrogen pollution}, + volume = {5}, + issn = {2041-1723}, + url = {http://www.nature.com/doifinder/10.1038/ncomms4858}, + doi = {10.1038/ncomms4858}, + urldate = {2014-05-13}, + journal = {Nature Communications}, + author = {Bodirsky, Benjamin Leon and Popp, Alexander and Lotze-Campen, Hermann and Dietrich, Jan Philipp and Rolinski, Susanne and Weindl, Isabelle and Schmitz, Christoph and M\"uller, Christoph and Bonsch, Markus and Humpenöder, Florian and Biewald, Anne and Stevanovic, Miodrag}, + month = may, + year = {2014}, } @article{humpenoder_investigating_2014, - title = {Investigating afforestation and bioenergy {CCS} as climate change mitigation strategies}, - volume = {9}, - issn = {1748-9326}, - url = {http://stacks.iop.org/1748-9326/9/i=6/a=064029?key=crossref.5fa44a1462d2acebebaa002315d8e4a6}, - doi = {10.1088/1748-9326/9/6/064029}, - number = {6}, - urldate = {2014-06-24}, - journal = {Environmental Research Letters}, - author = {Humpenöder, Florian and Popp, Alexander and Dietrich, Jan Philip and Klein, David and Lotze-Campen, Hermann and Bonsch, Markus and Bodirsky, Benjamin Leon and Weindl, Isabelle and Stevanovic, Miodrag and M\"uller, Christoph}, - month = may, - year = {2014}, - pages = {064029}, - file = {1748-9326_9_6_064029.pdf:D\:\\Dissertation\\Bibliographie\\storage\\5EI6J7WN\\1748-9326_9_6_064029.pdf:application/pdf} + title = {Investigating afforestation and bioenergy {CCS} as climate change mitigation strategies}, + volume = {9}, + issn = {1748-9326}, + url = {http://stacks.iop.org/1748-9326/9/i=6/a=064029?key=crossref.5fa44a1462d2acebebaa002315d8e4a6}, + doi = {10.1088/1748-9326/9/6/064029}, + number = {6}, + urldate = {2014-06-24}, + journal = {Environmental Research Letters}, + author = {Humpenöder, Florian and Popp, Alexander and Dietrich, Jan Philip and Klein, David and Lotze-Campen, Hermann and Bonsch, Markus and Bodirsky, Benjamin Leon and Weindl, Isabelle and Stevanovic, Miodrag and M\"uller, Christoph}, + month = may, + year = {2014}, + pages = {064029}, } @article{klein_global_2014, - title = {The global economic long-term potential of modern biomass in a climate-constrained world}, - volume = {9}, - issn = {1748-9326}, - url = {http://iopscience.iop.org/1748-9326/9/7/074017}, - doi = {10.1088/1748-9326/9/7/074017}, - abstract = {Low-stabilization scenarios consistent with the 2 °C target project large-scale deployment of purpose-grown lignocellulosic biomass. In case a GHG price regime integrates emissions from energy conversion and from land-use/land-use change, the strong demand for bioenergy and the pricing of terrestrial emissions are likely to coincide. We explore the global potential of purpose-grown lignocellulosic biomass and ask the question how the supply prices of biomass depend on prices for greenhouse gas (GHG) emissions from the land-use sector. Using the spatially explicit global land-use optimization model MAgPIE, we construct bioenergy supply curves for ten world regions and a global aggregate in two scenarios, with and without a GHG tax. We find that the implementation of GHG taxes is crucial for the slope of the supply function and the GHG emissions from the land-use sector. Global supply prices start at \$5 GJ−1 and increase almost linearly, doubling at 150 EJ (in 2055 and 2095). The GHG tax increases bioenergy prices by \$5 GJ−1 in 2055 and by \$10 GJ−1 in 2095, since it effectively stops deforestation and thus excludes large amounts of high-productivity land. Prices additionally increase due to costs for N2O emissions from fertilizer use. The GHG tax decreases global land-use change emissions by one-third. However, the carbon emissions due to bioenergy production increase by more than 50\% from conversion of land that is not under emission control. Average yields required to produce 240 EJ in 2095 are roughly 600 GJ ha−1 yr−1 with and without tax.}, - language = {en}, - number = {7}, - urldate = {2014-08-06}, - journal = {Environmental Research Letters}, - author = {Klein, David and Humpenöder, Florian and Bauer, Nico and Dietrich, Jan Philipp and Popp, Alexander and Bodirsky, Benjamin Leon and Bonsch, Markus and Lotze-Campen, Hermann}, - year = {2014}, - pages = {074017}, - file = {Klein et al_2014_The global economic long-term potential of modern biomass in a.pdf:D\:\\Dissertation\\Bibliographie\\storage\\59HJI5RF\\Klein et al_2014_The global economic long-term potential of modern biomass in a.pdf:application/pdf;Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\4SGCT3IG\\074017.html:text/html} + title = {The global economic long-term potential of modern biomass in a climate-constrained world}, + volume = {9}, + issn = {1748-9326}, + url = {http://iopscience.iop.org/1748-9326/9/7/074017}, + doi = {10.1088/1748-9326/9/7/074017}, + abstract = {Low-stabilization scenarios consistent with the 2 °C target project large-scale deployment of purpose-grown lignocellulosic biomass. In case a GHG price regime integrates emissions from energy conversion and from land-use/land-use change, the strong demand for bioenergy and the pricing of terrestrial emissions are likely to coincide. We explore the global potential of purpose-grown lignocellulosic biomass and ask the question how the supply prices of biomass depend on prices for greenhouse gas (GHG) emissions from the land-use sector. Using the spatially explicit global land-use optimization model MAgPIE, we construct bioenergy supply curves for ten world regions and a global aggregate in two scenarios, with and without a GHG tax. We find that the implementation of GHG taxes is crucial for the slope of the supply function and the GHG emissions from the land-use sector. Global supply prices start at \$5 GJ−1 and increase almost linearly, doubling at 150 EJ (in 2055 and 2095). The GHG tax increases bioenergy prices by \$5 GJ−1 in 2055 and by \$10 GJ−1 in 2095, since it effectively stops deforestation and thus excludes large amounts of high-productivity land. Prices additionally increase due to costs for N2O emissions from fertilizer use. The GHG tax decreases global land-use change emissions by one-third. However, the carbon emissions due to bioenergy production increase by more than 50\% from conversion of land that is not under emission control. Average yields required to produce 240 EJ in 2095 are roughly 600 GJ ha−1 yr−1 with and without tax.}, + language = {en}, + number = {7}, + urldate = {2014-08-06}, + journal = {Environmental Research Letters}, + author = {Klein, David and Humpenöder, Florian and Bauer, Nico and Dietrich, Jan Philipp and Popp, Alexander and Bodirsky, Benjamin Leon and Bonsch, Markus and Lotze-Campen, Hermann}, + year = {2014}, + pages = {074017}, } @article{lotze-campen_impacts_2014, - title = {Impacts of increased bioenergy demand on global food markets: an {AgMIP} economic model intercomparison}, - volume = {45}, - issn = {01695150}, - shorttitle = {Impacts of increased bioenergy demand on global food markets}, - url = {http://doi.wiley.com/10.1111/agec.12092}, - doi = {10.1111/agec.12092}, - language = {en}, - number = {1}, - urldate = {2014-10-14}, - journal = {Agricultural Economics}, - author = {Lotze-Campen, Hermann and von Lampe, Martin and Kyle, Page and Fujimori, Shinichiro and Havlik, Petr and van Meijl, Hans and Hasegawa, Tomoko and Popp, Alexander and Schmitz, Christoph and Tabeau, Andrzej and Valin, Hugo and Willenbockel, Dirk and Wise, Marshall}, - month = jan, - year = {2014}, - pages = {103--116}, - file = {agec12092.pdf:D\:\\Dissertation\\Bibliographie\\storage\\S7VJTC5H\\agec12092.pdf:application/pdf} + title = {Impacts of increased bioenergy demand on global food markets: an {AgMIP} economic model intercomparison}, + volume = {45}, + issn = {01695150}, + shorttitle = {Impacts of increased bioenergy demand on global food markets}, + url = {http://doi.wiley.com/10.1111/agec.12092}, + doi = {10.1111/agec.12092}, + language = {en}, + number = {1}, + urldate = {2014-10-14}, + journal = {Agricultural Economics}, + author = {Lotze-Campen, Hermann and von Lampe, Martin and Kyle, Page and Fujimori, Shinichiro and Havlik, Petr and van Meijl, Hans and Hasegawa, Tomoko and Popp, Alexander and Schmitz, Christoph and Tabeau, Andrzej and Valin, Hugo and Willenbockel, Dirk and Wise, Marshall}, + month = jan, + year = {2014}, + pages = {103--116}, } @article{bonsch_trade-offs_2014, - title = {Trade-offs between land and water requirements for large-scale bioenergy production}, - copyright = {© 2014 John Wiley \& Sons Ltd}, - issn = {1757-1707}, - url = {http://onlinelibrary.wiley.com/doi/10.1111/gcbb.12226/abstract}, - doi = {10.1111/gcbb.12226}, - abstract = {Bioenergy is expected to play an important role in the future energy mix as it can substitute fossil fuels and contribute to climate change mitigation. However, large-scale bioenergy cultivation may put substantial pressure on land and water resources. While irrigated bioenergy production can reduce the pressure on land due to higher yields, associated irrigation water requirements may lead to degradation of freshwater ecosystems and to conflicts with other potential users. In this article, we investigate the trade-offs between land and water requirements of large-scale bioenergy production. To this end, we adopt an exogenous demand trajectory for bioenergy from dedicated energy crops, targeted at limiting greenhouse gas emissions in the energy sector to 1100 Gt carbon dioxide equivalent until 2095. We then use the spatially explicit global land- and water-use allocation model MAgPIE to project the implications of this bioenergy target for global land and water resources. We find that producing 300 EJ yr−1 of bioenergy in 2095 from dedicated bioenergy crops is likely to double agricultural water withdrawals if no explicit water protection policies are implemented. Since current human water withdrawals are dominated by agriculture and already lead to ecosystem degradation and biodiversity loss, such a doubling will pose a severe threat to freshwater ecosystems. If irrigated bioenergy production is prohibited to prevent negative impacts of bioenergy cultivation on water resources, bioenergy land requirements for meeting a 300 EJ yr−1 bioenergy target increase substantially (+ 41\%) – mainly at the expense of pasture areas and tropical forests. Thus, avoiding negative environmental impacts of large-scale bioenergy production will require policies that balance associated water and land requirements.}, - language = {en}, - urldate = {2014-11-07}, - journal = {GCB Bioenergy}, - author = {Bonsch, Markus and Humpenöder, Florian and Popp, Alexander and Bodirsky, Benjamin and Dietrich, Jan Philipp and Rolinski, Susanne and Biewald, Anne and Lotze-Campen, Hermann and Weindl, Isabelle and Gerten, Dieter and Stevanovic, Miodrag}, - month = nov, - year = {2014}, - keywords = {sustainability, Bioenergy, land, land-use model, projection, water, water-land nexus}, - pages = {n/a--n/a}, - file = {Full Text PDF:D\:\\Dissertation\\Bibliographie\\storage\\CEBG4ARI\\Bonsch et al. - 2014 - Trade-offs between land and water requirements for.pdf:application/pdf;Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\NP2ZIC24\\abstract.html:text/html} + title = {Trade-offs between land and water requirements for large-scale bioenergy production}, + copyright = {© 2014 John Wiley \& Sons Ltd}, + issn = {1757-1707}, + url = {http://onlinelibrary.wiley.com/doi/10.1111/gcbb.12226/abstract}, + doi = {10.1111/gcbb.12226}, + abstract = {Bioenergy is expected to play an important role in the future energy mix as it can substitute fossil fuels and contribute to climate change mitigation. However, large-scale bioenergy cultivation may put substantial pressure on land and water resources. While irrigated bioenergy production can reduce the pressure on land due to higher yields, associated irrigation water requirements may lead to degradation of freshwater ecosystems and to conflicts with other potential users. In this article, we investigate the trade-offs between land and water requirements of large-scale bioenergy production. To this end, we adopt an exogenous demand trajectory for bioenergy from dedicated energy crops, targeted at limiting greenhouse gas emissions in the energy sector to 1100 Gt carbon dioxide equivalent until 2095. We then use the spatially explicit global land- and water-use allocation model MAgPIE to project the implications of this bioenergy target for global land and water resources. We find that producing 300 EJ yr−1 of bioenergy in 2095 from dedicated bioenergy crops is likely to double agricultural water withdrawals if no explicit water protection policies are implemented. Since current human water withdrawals are dominated by agriculture and already lead to ecosystem degradation and biodiversity loss, such a doubling will pose a severe threat to freshwater ecosystems. If irrigated bioenergy production is prohibited to prevent negative impacts of bioenergy cultivation on water resources, bioenergy land requirements for meeting a 300 EJ yr−1 bioenergy target increase substantially (+ 41\%) – mainly at the expense of pasture areas and tropical forests. Thus, avoiding negative environmental impacts of large-scale bioenergy production will require policies that balance associated water and land requirements.}, + language = {en}, + urldate = {2014-11-07}, + journal = {GCB Bioenergy}, + author = {Bonsch, Markus and Humpenöder, Florian and Popp, Alexander and Bodirsky, Benjamin and Dietrich, Jan Philipp and Rolinski, Susanne and Biewald, Anne and Lotze-Campen, Hermann and Weindl, Isabelle and Gerten, Dieter and Stevanovic, Miodrag}, + month = nov, + year = {2014}, + keywords = {sustainability, Bioenergy, land, land-use model, projection, water, water-land nexus}, + pages = {n/a--n/a}, } @article{popp_land-use_2014, - title = {Land-use protection for climate change mitigation}, - volume = {4}, - copyright = {© 2014 Nature Publishing Group}, - issn = {1758-678X}, - url = {http://www.nature.com/nclimate/journal/vaop/ncurrent/full/nclimate2444.html}, - doi = {10.1038/nclimate2444}, - abstract = {Land-use change, mainly the conversion of tropical forests to agricultural land, is a massive source of carbon emissions and contributes substantially to global warming. Therefore, mechanisms that aim to reduce carbon emissions from deforestation are widely discussed. A central challenge is the avoidance of international carbon leakage if forest conservation is not implemented globally. Here, we show that forest conservation schemes, even if implemented globally, could lead to another type of carbon leakage by driving cropland expansion in non-forested areas that are not subject to forest conservation schemes (non-forest leakage). These areas have a smaller, but still considerable potential to store carbon. We show that a global forest policy could reduce carbon emissions by 77 Gt CO2, but would still allow for decreases in carbon stocks of non-forest land by 96 Gt CO2 until 2100 due to non-forest leakage effects. Furthermore, abandonment of agricultural land and associated carbon uptake through vegetation regrowth is hampered. Effective mitigation measures thus require financing structures and conservation investments that cover the full range of carbon-rich ecosystems. However, our analysis indicates that greater agricultural productivity increases would be needed to compensate for such restrictions on agricultural expansion.}, - language = {en}, - urldate = {2014-11-17}, - journal = {Nature Climate Change}, - author = {Popp, Alexander and Humpenöder, Florian and Weindl, Isabelle and Bodirsky, Benjamin Leon and Bonsch, Markus and Lotze-Campen, Hermann and M\"uller, Christoph and Biewald, Anne and Rolinski, Susanne and Stevanovic, Miodrag and Dietrich, Jan Philipp}, - month = nov, - year = {2014}, - pages = {1095--1098}, - file = {Popp et al_2014_Land-use protection for climate change mitigation.pdf:D\:\\Dissertation\\Bibliographie\\storage\\PS5QW9ZP\\Popp et al_2014_Land-use protection for climate change mitigation.pdf:application/pdf;Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\XIQ4D2E5\\nclimate2444.html:text/html} + title = {Land-use protection for climate change mitigation}, + volume = {4}, + copyright = {© 2014 Nature Publishing Group}, + issn = {1758-678X}, + url = {http://www.nature.com/nclimate/journal/vaop/ncurrent/full/nclimate2444.html}, + doi = {10.1038/nclimate2444}, + abstract = {Land-use change, mainly the conversion of tropical forests to agricultural land, is a massive source of carbon emissions and contributes substantially to global warming. Therefore, mechanisms that aim to reduce carbon emissions from deforestation are widely discussed. A central challenge is the avoidance of international carbon leakage if forest conservation is not implemented globally. Here, we show that forest conservation schemes, even if implemented globally, could lead to another type of carbon leakage by driving cropland expansion in non-forested areas that are not subject to forest conservation schemes (non-forest leakage). These areas have a smaller, but still considerable potential to store carbon. We show that a global forest policy could reduce carbon emissions by 77 Gt CO2, but would still allow for decreases in carbon stocks of non-forest land by 96 Gt CO2 until 2100 due to non-forest leakage effects. Furthermore, abandonment of agricultural land and associated carbon uptake through vegetation regrowth is hampered. Effective mitigation measures thus require financing structures and conservation investments that cover the full range of carbon-rich ecosystems. However, our analysis indicates that greater agricultural productivity increases would be needed to compensate for such restrictions on agricultural expansion.}, + language = {en}, + urldate = {2014-11-17}, + journal = {Nature Climate Change}, + author = {Popp, Alexander and Humpenöder, Florian and Weindl, Isabelle and Bodirsky, Benjamin Leon and Bonsch, Markus and Lotze-Campen, Hermann and M\"uller, Christoph and Biewald, Anne and Rolinski, Susanne and Stevanovic, Miodrag and Dietrich, Jan Philipp}, + month = nov, + year = {2014}, + pages = {1095--1098}, } @misc{bodirsky_scenarios_2015, - address = {Berlin}, - title = {Scenarios of future agricultural phosphorus stocks and flows}, - author = {Bodirsky, Benjamin Leon}, - collaborator = {Heintz, Veikko and Lotze-Campen, Hermann and Popp, Alexander and Rolinski, Susanne and Lutz, Femke and Stevanovic, Miodrag and M\"uller, Christoph and Dietrich, Jan Philipp and Weindl, Isabelle and Bonsch, Markus and Humpenöder, Florian}, - year = {2015}, - file = {phosphorus Bodirsky poster ESPC2.pdf:D\:\\Dissertation\\Bibliographie\\storage\\TAM2BW9Z\\Bodirsky poster ESPC2.pdf:application/pdf} + address = {Berlin}, + title = {Scenarios of future agricultural phosphorus stocks and flows}, + author = {Bodirsky, Benjamin Leon}, + collaborator = {Heintz, Veikko and Lotze-Campen, Hermann and Popp, Alexander and Rolinski, Susanne and Lutz, Femke and Stevanovic, Miodrag and M\"uller, Christoph and Dietrich, Jan Philipp and Weindl, Isabelle and Bonsch, Markus and Humpenöder, Florian}, + year = {2015}, } @article{klein_bio-igcc_2011, - series = {10th {International} {Conference} on {Greenhouse} {Gas} {Control} {Technologies}}, - title = {Bio-{IGCC} with {CCS} as a long-term mitigation option in a coupled energy-system and land-use model}, - volume = {4}, - issn = {1876-6102}, - url = {http://www.sciencedirect.com/science/article/pii/S1876610211003985}, - doi = {10.1016/j.egypro.2011.02.201}, - abstract = {This study analyses the impact of techno-economic performance of the BIGCC process and the effect of different biomass feedstocks on the technology’s long term deployment in climate change mitigation scenarios. As the BIGCC technology demands high amounts of biomass raw material it also affects the land-use sector and is dependent on conditions and constraints on the land-use side. To represent the interaction of biomass demand and supply side the global energy-economy-climate model ReMIND is linked to the global land-use model MAgPIE. The link integrates biomass demand and price as well as emission prices and land-use emissions. Results indicate that BIGCC with CCS could serve as an important mitigation option and that it could even be the main bioenergy conversion technology sharing 33\% of overall mitigation in 2100. The contribution of BIGCC technology to long-term climate change mitigation is much higher if grass is used as fuel instead of wood, provided that the grass-based process is highly efficient. The capture rate has to significantly exceed 60\% otherwise the technology is not applied. The overall primary energy consumption of biomass reacts much more sensitive to price changes of the biomass than to techno-economic performance of the BIGCC process. As biomass is mainly used with CCS technologies high amounts of carbon are captured ranging from 130 GtC to 240 GtC (cumulated from 2005–2100) in different scenarios.}, - urldate = {2015-06-10}, - journal = {Energy Procedia}, - author = {Klein, David and Bauer, Nico and Bodirsky, Benjamin and Dietrich, Jan Philipp and Popp, Alexander}, - year = {2011}, - keywords = {land use, Biomass, IGCC, Carbon capture and sequestration, Soft link}, - pages = {2933--2940}, - file = {Klein et al_2011_Bio-IGCC with CCS as a long-term mitigation option in a coupled energy-system.pdf:D\:\\Dissertation\\Bibliographie\\storage\\EAXAURBB\\Klein et al_2011_Bio-IGCC with CCS as a long-term mitigation option in a coupled energy-system.pdf:application/pdf;ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\365XTA86\\S1876610211003985.html:text/html} + series = {10th {International} {Conference} on {Greenhouse} {Gas} {Control} {Technologies}}, + title = {Bio-{IGCC} with {CCS} as a long-term mitigation option in a coupled energy-system and land-use model}, + volume = {4}, + issn = {1876-6102}, + url = {http://www.sciencedirect.com/science/article/pii/S1876610211003985}, + doi = {10.1016/j.egypro.2011.02.201}, + abstract = {This study analyses the impact of techno-economic performance of the BIGCC process and the effect of different biomass feedstocks on the technology’s long term deployment in climate change mitigation scenarios. As the BIGCC technology demands high amounts of biomass raw material it also affects the land-use sector and is dependent on conditions and constraints on the land-use side. To represent the interaction of biomass demand and supply side the global energy-economy-climate model ReMIND is linked to the global land-use model MAgPIE. The link integrates biomass demand and price as well as emission prices and land-use emissions. Results indicate that BIGCC with CCS could serve as an important mitigation option and that it could even be the main bioenergy conversion technology sharing 33\% of overall mitigation in 2100. The contribution of BIGCC technology to long-term climate change mitigation is much higher if grass is used as fuel instead of wood, provided that the grass-based process is highly efficient. The capture rate has to significantly exceed 60\% otherwise the technology is not applied. The overall primary energy consumption of biomass reacts much more sensitive to price changes of the biomass than to techno-economic performance of the BIGCC process. As biomass is mainly used with CCS technologies high amounts of carbon are captured ranging from 130 GtC to 240 GtC (cumulated from 2005–2100) in different scenarios.}, + urldate = {2015-06-10}, + journal = {Energy Procedia}, + author = {Klein, David and Bauer, Nico and Bodirsky, Benjamin and Dietrich, Jan Philipp and Popp, Alexander}, + year = {2011}, + keywords = {land use, Biomass, IGCC, Carbon capture and sequestration, Soft link}, + pages = {2933--2940}, } @article{nelson_climate_2014, - title = {Climate change effects on agriculture: {Economic} responses to biophysical shocks}, - volume = {111}, - issn = {0027-8424, 1091-6490}, - shorttitle = {Climate change effects on agriculture}, - url = {http://www.pnas.org/content/111/9/3274}, - doi = {10.1073/pnas.1222465110}, - abstract = {Agricultural production is sensitive to weather and thus directly affected by climate change. Plausible estimates of these climate change impacts require combined use of climate, crop, and economic models. Results from previous studies vary substantially due to differences in models, scenarios, and data. This paper is part of a collective effort to systematically integrate these three types of models. We focus on the economic component of the assessment, investigating how nine global economic models of agriculture represent endogenous responses to seven standardized climate change scenarios produced by two climate and five crop models. These responses include adjustments in yields, area, consumption, and international trade. We apply biophysical shocks derived from the Intergovernmental Panel on Climate Change’s representative concentration pathway with end-of-century radiative forcing of 8.5 W/m2. The mean biophysical yield effect with no incremental CO2 fertilization is a 17\% reduction globally by 2050 relative to a scenario with unchanging climate. Endogenous economic responses reduce yield loss to 11\%, increase area of major crops by 11\%, and reduce consumption by 3\%. Agricultural production, cropland area, trade, and prices show the greatest degree of variability in response to climate change, and consumption the lowest. The sources of these differences include model structure and specification; in particular, model assumptions about ease of land use conversion, intensification, and trade. This study identifies where models disagree on the relative responses to climate shocks and highlights research activities needed to improve the representation of agricultural adaptation responses to climate change.}, - language = {en}, - number = {9}, - urldate = {2015-07-03}, - journal = {Proceedings of the National Academy of Sciences}, - author = {Nelson, Gerald C. and Valin, Hugo and Sands, Ronald D. and Havlík, Petr and Ahammad, Helal and Deryng, Delphine and Elliott, Joshua and Fujimori, Shinichiro and Hasegawa, Tomoko and Heyhoe, Edwina and Kyle, Page and Lampe, Martin Von and Lotze-Campen, Hermann and d’Croz, Daniel Mason and Meijl, Hans van and Mensbrugghe, Dominique van der and M\"uller, Christoph and Popp, Alexander and Robertson, Richard and Robinson, Sherman and Schmid, Erwin and Schmitz, Christoph and Tabeau, Andrzej and Willenbockel, Dirk}, - month = apr, - year = {2014}, - pmid = {24344285}, - keywords = {Integrated assessment, Agricultural productivity, climate change adaptation, model intercomparison}, - pages = {3274--3279}, - file = {Nelson et al_2014_Climate change effects on agriculture.pdf:D\:\\Dissertation\\Bibliographie\\storage\\DIQKMG9G\\Nelson et al_2014_Climate change effects on agriculture.pdf:application/pdf;Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\NW99D3UG\\3274.html:text/html} + title = {Climate change effects on agriculture: {Economic} responses to biophysical shocks}, + volume = {111}, + issn = {0027-8424, 1091-6490}, + shorttitle = {Climate change effects on agriculture}, + url = {http://www.pnas.org/content/111/9/3274}, + doi = {10.1073/pnas.1222465110}, + abstract = {Agricultural production is sensitive to weather and thus directly affected by climate change. Plausible estimates of these climate change impacts require combined use of climate, crop, and economic models. Results from previous studies vary substantially due to differences in models, scenarios, and data. This paper is part of a collective effort to systematically integrate these three types of models. We focus on the economic component of the assessment, investigating how nine global economic models of agriculture represent endogenous responses to seven standardized climate change scenarios produced by two climate and five crop models. These responses include adjustments in yields, area, consumption, and international trade. We apply biophysical shocks derived from the Intergovernmental Panel on Climate Change’s representative concentration pathway with end-of-century radiative forcing of 8.5 W/m2. The mean biophysical yield effect with no incremental CO2 fertilization is a 17\% reduction globally by 2050 relative to a scenario with unchanging climate. Endogenous economic responses reduce yield loss to 11\%, increase area of major crops by 11\%, and reduce consumption by 3\%. Agricultural production, cropland area, trade, and prices show the greatest degree of variability in response to climate change, and consumption the lowest. The sources of these differences include model structure and specification; in particular, model assumptions about ease of land use conversion, intensification, and trade. This study identifies where models disagree on the relative responses to climate shocks and highlights research activities needed to improve the representation of agricultural adaptation responses to climate change.}, + language = {en}, + number = {9}, + urldate = {2015-07-03}, + journal = {Proceedings of the National Academy of Sciences}, + author = {Nelson, Gerald C. and Valin, Hugo and Sands, Ronald D. and Havlík, Petr and Ahammad, Helal and Deryng, Delphine and Elliott, Joshua and Fujimori, Shinichiro and Hasegawa, Tomoko and Heyhoe, Edwina and Kyle, Page and Lampe, Martin Von and Lotze-Campen, Hermann and d’Croz, Daniel Mason and Meijl, Hans van and Mensbrugghe, Dominique van der and M\"uller, Christoph and Popp, Alexander and Robertson, Richard and Robinson, Sherman and Schmid, Erwin and Schmitz, Christoph and Tabeau, Andrzej and Willenbockel, Dirk}, + month = apr, + year = {2014}, + pmid = {24344285}, + keywords = {Integrated assessment, Agricultural productivity, climate change adaptation, model intercomparison}, + pages = {3274--3279}, } @article{bonsch_environmental_2015, - title = {Environmental flow provision: {Implications} for agricultural water and land-use at the global scale}, - volume = {30}, - issn = {0959-3780}, - shorttitle = {Environmental flow provision}, - url = {http://www.sciencedirect.com/science/article/pii/S0959378014001964}, - doi = {10.1016/j.gloenvcha.2014.10.015}, - abstract = {Human activity has led to freshwater ecosystem degradation in the past and is likely to continue doing so if no appropriate protection mechanisms are implemented. One potential protection measure is the reallocation of water from human use to environmental purposes – also called environmental flows. Such reallocation may decrease the availability of irrigation water with possible adverse effects on agricultural production. In this analysis, we provide an initial quantitative estimate of how the allocation of annual volumes of water for environmental flow protection (EFP) might influence the food production system on a global scale. The application of a spatially explicit global land and water-use allocation model (MAgPIE) allows us to explore the effect of EFP on agricultural water withdrawals. We will also examine associated reactions in terms of land-use changes and agricultural intensification. Our results suggest that the implications of conserving annual volumes of water for EFP on the land-use system are moderate on an aggregate global level. Cropland expansion into unmanaged land arising from increased food demand up to 2045 is higher by a factor 5–9 than cropland expansion induced by EFP. Global forest losses associated with EFP remain below 1\% of current forest area. Production reallocation and associated land-use change hotspots suggest that local effects are of more concern than aggregate cropland expansion and deforestation.}, - urldate = {2015-08-13}, - journal = {Global Environmental Change}, - author = {Bonsch, Markus and Popp, Alexander and Biewald, Anne and Rolinski, Susanne and Schmitz, Christoph and Weindl, Isabelle and Stevanovic, Miodrag and Högner, Kathrin and Heinke, Jens and Ostberg, Sebastian and Dietrich, Jan Philipp and Bodirsky, Benjamin and Lotze-Campen, Hermann and Humpenöder, Florian}, - month = jan, - year = {2015}, - keywords = {Global, Environmental flows, Water-use, Land-use, Land–water-nexus, Model}, - pages = {113--132}, - file = {Bonsch et al_2015_Environmental flow provision.pdf:D\:\\Dissertation\\Bibliographie\\storage\\Z5Q8GVFX\\Bonsch et al_2015_Environmental flow provision.pdf:application/pdf;ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\FZKIQTNV\\S0959378014001964.html:text/html} + title = {Environmental flow provision: {Implications} for agricultural water and land-use at the global scale}, + volume = {30}, + issn = {0959-3780}, + shorttitle = {Environmental flow provision}, + url = {http://www.sciencedirect.com/science/article/pii/S0959378014001964}, + doi = {10.1016/j.gloenvcha.2014.10.015}, + abstract = {Human activity has led to freshwater ecosystem degradation in the past and is likely to continue doing so if no appropriate protection mechanisms are implemented. One potential protection measure is the reallocation of water from human use to environmental purposes – also called environmental flows. Such reallocation may decrease the availability of irrigation water with possible adverse effects on agricultural production. In this analysis, we provide an initial quantitative estimate of how the allocation of annual volumes of water for environmental flow protection (EFP) might influence the food production system on a global scale. The application of a spatially explicit global land and water-use allocation model (MAgPIE) allows us to explore the effect of EFP on agricultural water withdrawals. We will also examine associated reactions in terms of land-use changes and agricultural intensification. Our results suggest that the implications of conserving annual volumes of water for EFP on the land-use system are moderate on an aggregate global level. Cropland expansion into unmanaged land arising from increased food demand up to 2045 is higher by a factor 5–9 than cropland expansion induced by EFP. Global forest losses associated with EFP remain below 1\% of current forest area. Production reallocation and associated land-use change hotspots suggest that local effects are of more concern than aggregate cropland expansion and deforestation.}, + urldate = {2015-08-13}, + journal = {Global Environmental Change}, + author = {Bonsch, Markus and Popp, Alexander and Biewald, Anne and Rolinski, Susanne and Schmitz, Christoph and Weindl, Isabelle and Stevanovic, Miodrag and Högner, Kathrin and Heinke, Jens and Ostberg, Sebastian and Dietrich, Jan Philipp and Bodirsky, Benjamin and Lotze-Campen, Hermann and Humpenöder, Florian}, + month = jan, + year = {2015}, + keywords = {Global, Environmental flows, Water-use, Land-use, Land–water-nexus, Model}, + pages = {113--132}, } @article{wang_taking_2016, - title = {Taking account of governance: {Implications} for land-use dynamics, food prices, and trade patterns}, - volume = {122}, - issn = {0921-8009}, - shorttitle = {Taking account of governance}, - url = {http://www.sciencedirect.com/science/article/pii/S0921800915004619}, - doi = {10.1016/j.ecolecon.2015.11.018}, - abstract = {Deforestation, mainly caused by unsustainable agricultural expansion, results in a loss of biodiversity and an increase in greenhouse gas emissions, as well as impinges on local livelihoods. Countries' governance performance, particularly with respect to property rights security, exerts significant impacts on land-use patterns by affecting agricultural yield-related technological investment and cropland expansion. This study aims to incorporate governance factors into a recursive agro-economic dynamic model to simulate governance impacts on land-use patterns at the global scale. Due to the difficulties of including governance indicators directly into numerical models, we use lending interest rates as discount rates to reflect risk-accounting factors associated with different governance scenarios. In addition to a reference scenario, three scenarios with high, low and mixed divergent discount rates are formed to represent weak, strong and fragmented governance. We find that weak governance leads to slower yield growth, increased cropland expansion and associated deforestation, mainly in Latin America, Sub-Saharan Africa, South Asia and Southeast Asia. This is associated with increasing food prices, particularly in Sub-Saharan Africa and Southeast Asia. By contrast, strong governance performance provides a stable political and economic situation which may bring down deforestation rates, stimulate investment in agricultural technologies, and induce fairly strong decreases in food prices.}, - urldate = {2016-02-19}, - journal = {Ecological Economics}, - author = {Wang, Xiaoxi and Biewald, Anne and Dietrich, Jan Philipp and Schmitz, Christoph and Lotze-Campen, Hermann and Humpenöder, Florian and Bodirsky, Benjamin Leon and Popp, Alexander}, - month = feb, - year = {2016}, - keywords = {Deforestation, Governance, Cropland expansion, Food prices, Land-use intensity}, - pages = {12--24} + title = {Taking account of governance: {Implications} for land-use dynamics, food prices, and trade patterns}, + volume = {122}, + issn = {0921-8009}, + shorttitle = {Taking account of governance}, + url = {http://www.sciencedirect.com/science/article/pii/S0921800915004619}, + doi = {10.1016/j.ecolecon.2015.11.018}, + abstract = {Deforestation, mainly caused by unsustainable agricultural expansion, results in a loss of biodiversity and an increase in greenhouse gas emissions, as well as impinges on local livelihoods. Countries' governance performance, particularly with respect to property rights security, exerts significant impacts on land-use patterns by affecting agricultural yield-related technological investment and cropland expansion. This study aims to incorporate governance factors into a recursive agro-economic dynamic model to simulate governance impacts on land-use patterns at the global scale. Due to the difficulties of including governance indicators directly into numerical models, we use lending interest rates as discount rates to reflect risk-accounting factors associated with different governance scenarios. In addition to a reference scenario, three scenarios with high, low and mixed divergent discount rates are formed to represent weak, strong and fragmented governance. We find that weak governance leads to slower yield growth, increased cropland expansion and associated deforestation, mainly in Latin America, Sub-Saharan Africa, South Asia and Southeast Asia. This is associated with increasing food prices, particularly in Sub-Saharan Africa and Southeast Asia. By contrast, strong governance performance provides a stable political and economic situation which may bring down deforestation rates, stimulate investment in agricultural technologies, and induce fairly strong decreases in food prices.}, + urldate = {2016-02-19}, + journal = {Ecological Economics}, + author = {Wang, Xiaoxi and Biewald, Anne and Dietrich, Jan Philipp and Schmitz, Christoph and Lotze-Campen, Hermann and Humpenöder, Florian and Bodirsky, Benjamin Leon and Popp, Alexander}, + month = feb, + year = {2016}, + keywords = {Deforestation, Governance, Cropland expansion, Food prices, Land-use intensity}, + pages = {12--24} } @article{bodirsky_global_2015-1, - title = {Global {Food} {Demand} {Scenarios} for the 21st {Century}}, - volume = {10}, - url = {http://dx.doi.org/10.1371/journal.pone.0139201}, - doi = {10.1371/journal.pone.0139201}, - abstract = {Long-term food demand scenarios are an important tool for studying global food security and for analysing the environmental impacts of agriculture. We provide a simple and transparent method to create scenarios for future plant-based and animal-based calorie demand, using time-dependent regression models between calorie demand and income. The scenarios can be customized to a specific storyline by using different input data for gross domestic product (GDP) and population projections and by assuming different functional forms of the regressions. Our results confirm that total calorie demand increases with income, but we also found a non-income related positive time-trend. The share of animal-based calories is estimated to rise strongly with income for low-income groups. For high income groups, two ambiguous relations between income and the share of animal-based products are consistent with historical data: First, a positive relation with a strong negative time-trend and second a negative relation with a slight negative time-trend. The fits of our regressions are highly significant and our results compare well to other food demand estimates. The method is exemplarily used to construct four food demand scenarios until the year 2100 based on the storylines of the IPCC Special Report on Emissions Scenarios (SRES). We find in all scenarios a strong increase of global food demand until 2050 with an increasing share of animal-based products, especially in developing countries.}, - number = {11}, - urldate = {2015-11-05}, - journal = {PLoS ONE}, - author = {Bodirsky, Benjamin Leon and Rolinski, Susanne and Biewald, Anne and Weindl, Isabelle and Popp, Alexander and Lotze-Campen, Hermann}, - month = nov, - year = {2015}, - pages = {e0139201}, - file = {Bodirsky et al_2015_Global Food Demand Scenarios for the 21st Century.pdf:D\:\\Dissertation\\Bibliographie\\storage\\PWG92ZSN\\Bodirsky et al_2015_Global Food Demand Scenarios for the 21st Century.pdf:application/pdf} + title = {Global {Food} {Demand} {Scenarios} for the 21st {Century}}, + volume = {10}, + url = {http://dx.doi.org/10.1371/journal.pone.0139201}, + doi = {10.1371/journal.pone.0139201}, + abstract = {Long-term food demand scenarios are an important tool for studying global food security and for analysing the environmental impacts of agriculture. We provide a simple and transparent method to create scenarios for future plant-based and animal-based calorie demand, using time-dependent regression models between calorie demand and income. The scenarios can be customized to a specific storyline by using different input data for gross domestic product (GDP) and population projections and by assuming different functional forms of the regressions. Our results confirm that total calorie demand increases with income, but we also found a non-income related positive time-trend. The share of animal-based calories is estimated to rise strongly with income for low-income groups. For high income groups, two ambiguous relations between income and the share of animal-based products are consistent with historical data: First, a positive relation with a strong negative time-trend and second a negative relation with a slight negative time-trend. The fits of our regressions are highly significant and our results compare well to other food demand estimates. The method is exemplarily used to construct four food demand scenarios until the year 2100 based on the storylines of the IPCC Special Report on Emissions Scenarios (SRES). We find in all scenarios a strong increase of global food demand until 2050 with an increasing share of animal-based products, especially in developing countries.}, + number = {11}, + urldate = {2015-11-05}, + journal = {PLoS ONE}, + author = {Bodirsky, Benjamin Leon and Rolinski, Susanne and Biewald, Anne and Weindl, Isabelle and Popp, Alexander and Lotze-Campen, Hermann}, + month = nov, + year = {2015}, + pages = {e0139201}, } @article{wiebe_climate_2015, - title = {Climate change impacts on agriculture in 2050 under a range of plausible socioeconomic and emissions scenarios}, - volume = {10}, - issn = {1748-9326}, - url = {http://stacks.iop.org/1748-9326/10/i=8/a=085010}, - doi = {10.1088/1748-9326/10/8/085010}, - abstract = {Previous studies have combined climate, crop and economic models to examine the impact of climate change on agricultural production and food security, but results have varied widely due to differences in models, scenarios and input data. Recent work has examined (and narrowed) these differences through systematic model intercomparison using a high-emissions pathway to highlight the differences. This paper extends that analysis to explore a range of plausible socioeconomic scenarios and emission pathways. Results from multiple climate and economic models are combined to examine the global and regional impacts of climate change on agricultural yields, area, production, consumption, prices and trade for coarse grains, rice, wheat, oilseeds and sugar crops to 2050. We find that climate impacts on global average yields, area, production and consumption are similar across shared socioeconomic pathways (SSP 1, 2 and 3, as we implement them based on population, income and productivity drivers), except when changes in trade policies are included. Impacts on trade and prices are higher for SSP 3 than SSP 2, and higher for SSP 2 than for SSP 1. Climate impacts for all variables are similar across low to moderate emissions pathways (RCP 4.5 and RCP 6.0), but increase for a higher emissions pathway (RCP 8.5). It is important to note that these global averages may hide regional variations. Projected reductions in agricultural yields due to climate change by 2050 are larger for some crops than those estimated for the past half century, but smaller than projected increases to 2050 due to rising demand and intrinsic productivity growth. Results illustrate the sensitivity of climate change impacts to differences in socioeconomic and emissions pathways. Yield impacts increase at high emissions levels and vary with changes in population, income and technology, but are reduced in all cases by endogenous changes in prices and other variables.}, - language = {en}, - number = {8}, - urldate = {2015-10-15}, - journal = {Environmental Research Letters}, - author = {Wiebe, Keith and Lotze-Campen, Hermann and Sands, Ronald and Tabeau, Andrzej and Mensbrugghe, Dominique van der and {Anne Biewald} and Bodirsky, Benjamin and Islam, Shahnila and Kavallari, Aikaterini and Mason-D’Croz, Daniel and {Christoph M\"uller} and Popp, Alexander and Robertson, Richard and Robinson, Sherman and Meijl, Hans van and Willenbockel, Dirk}, - year = {2015}, - pages = {085010}, - file = {Wiebe et al_2015_Climate change impacts on agriculture in 2050 under a range of plausible.pdf:D\:\\Dissertation\\Bibliographie\\storage\\PI86FZG2\\Wiebe et al_2015_Climate change impacts on agriculture in 2050 under a range of plausible.pdf:application/pdf} + title = {Climate change impacts on agriculture in 2050 under a range of plausible socioeconomic and emissions scenarios}, + volume = {10}, + issn = {1748-9326}, + url = {http://stacks.iop.org/1748-9326/10/i=8/a=085010}, + doi = {10.1088/1748-9326/10/8/085010}, + abstract = {Previous studies have combined climate, crop and economic models to examine the impact of climate change on agricultural production and food security, but results have varied widely due to differences in models, scenarios and input data. Recent work has examined (and narrowed) these differences through systematic model intercomparison using a high-emissions pathway to highlight the differences. This paper extends that analysis to explore a range of plausible socioeconomic scenarios and emission pathways. Results from multiple climate and economic models are combined to examine the global and regional impacts of climate change on agricultural yields, area, production, consumption, prices and trade for coarse grains, rice, wheat, oilseeds and sugar crops to 2050. We find that climate impacts on global average yields, area, production and consumption are similar across shared socioeconomic pathways (SSP 1, 2 and 3, as we implement them based on population, income and productivity drivers), except when changes in trade policies are included. Impacts on trade and prices are higher for SSP 3 than SSP 2, and higher for SSP 2 than for SSP 1. Climate impacts for all variables are similar across low to moderate emissions pathways (RCP 4.5 and RCP 6.0), but increase for a higher emissions pathway (RCP 8.5). It is important to note that these global averages may hide regional variations. Projected reductions in agricultural yields due to climate change by 2050 are larger for some crops than those estimated for the past half century, but smaller than projected increases to 2050 due to rising demand and intrinsic productivity growth. Results illustrate the sensitivity of climate change impacts to differences in socioeconomic and emissions pathways. Yield impacts increase at high emissions levels and vary with changes in population, income and technology, but are reduced in all cases by endogenous changes in prices and other variables.}, + language = {en}, + number = {8}, + urldate = {2015-10-15}, + journal = {Environmental Research Letters}, + author = {Wiebe, Keith and Lotze-Campen, Hermann and Sands, Ronald and Tabeau, Andrzej and Mensbrugghe, Dominique van der and {Anne Biewald} and Bodirsky, Benjamin and Islam, Shahnila and Kavallari, Aikaterini and Mason-D’Croz, Daniel and {Christoph M\"uller} and Popp, Alexander and Robertson, Richard and Robinson, Sherman and Meijl, Hans van and Willenbockel, Dirk}, + year = {2015}, + pages = {085010}, } @article{weindl_livestock_2015, - title = {Livestock in a changing climate: production system transitions as an adaptation strategy for agriculture}, - volume = {10}, - issn = {1748-9326}, - shorttitle = {Livestock in a changing climate}, - url = {http://stacks.iop.org/1748-9326/10/i=9/a=094021}, - doi = {10.1088/1748-9326/10/9/094021}, - abstract = {Livestock farming is the world’s largest land use sector and utilizes around 60\% of the global biomass harvest. Over the coming decades, climate change will affect the natural resource base of livestock production, especially the productivity of rangeland and feed crops. Based on a comprehensive impact modeling chain, we assess implications of different climate projections for agricultural production costs and land use change and explore the effectiveness of livestock system transitions as an adaptation strategy. Simulated climate impacts on crop yields and rangeland productivity generate adaptation costs amounting to 3\% of total agricultural production costs in 2045 (i.e. 145 billion US\$). Shifts in livestock production towards mixed crop-livestock systems represent a resource- and cost-efficient adaptation option, reducing agricultural adaptation costs to 0.3\% of total production costs and simultaneously abating deforestation by about 76 million ha globally. The relatively positive climate impacts on grass yields compared with crop yields favor grazing systems inter alia in South Asia and North America. Incomplete transitions in production systems already have a strong adaptive and cost reducing effect: a 50\% shift to mixed systems lowers agricultural adaptation costs to 0.8\%. General responses of production costs to system transitions are robust across different global climate and crop models as well as regarding assumptions on CO 2 fertilization, but simulated values show a large variation. In the face of these uncertainties, public policy support for transforming livestock production systems provides an important lever to improve agricultural resource management and lower adaptation costs, possibly even contributing to emission reduction.}, - language = {en}, - number = {9}, - urldate = {2015-10-22}, - journal = {Environmental Research Letters}, - author = {Weindl, Isabelle and Lotze-Campen, Hermann and Popp, Alexander and M\"uller, Christoph and Havlík, Petr and {Mario Herrero} and Schmitz, Christoph and Rolinski, Susanne}, - year = {2015}, - pages = {094021}, - file = {Weindl et al_2015_Livestock in a changing climate.pdf:D\:\\Dissertation\\Bibliographie\\storage\\2PAVK94H\\Weindl et al_2015_Livestock in a changing climate.pdf:application/pdf} + title = {Livestock in a changing climate: production system transitions as an adaptation strategy for agriculture}, + volume = {10}, + issn = {1748-9326}, + shorttitle = {Livestock in a changing climate}, + url = {http://stacks.iop.org/1748-9326/10/i=9/a=094021}, + doi = {10.1088/1748-9326/10/9/094021}, + abstract = {Livestock farming is the world's largest land use sector and utilizes around 60\% of the global biomass harvest. Over the coming decades, climate change will affect the natural resource base of livestock production, especially the productivity of rangeland and feed crops. Based on a comprehensive impact modeling chain, we assess implications of different climate projections for agricultural production costs and land use change and explore the effectiveness of livestock system transitions as an adaptation strategy. Simulated climate impacts on crop yields and rangeland productivity generate adaptation costs amounting to 3\% of total agricultural production costs in 2045 (i.e. 145 billion US\$). Shifts in livestock production towards mixed crop-livestock systems represent a resource- and cost-efficient adaptation option, reducing agricultural adaptation costs to 0.3\% of total production costs and simultaneously abating deforestation by about 76 million ha globally. The relatively positive climate impacts on grass yields compared with crop yields favor grazing systems inter alia in South Asia and North America. Incomplete transitions in production systems already have a strong adaptive and cost reducing effect: a 50\% shift to mixed systems lowers agricultural adaptation costs to 0.8\%. General responses of production costs to system transitions are robust across different global climate and crop models as well as regarding assumptions on CO 2 fertilization, but simulated values show a large variation. In the face of these uncertainties, public policy support for transforming livestock production systems provides an important lever to improve agricultural resource management and lower adaptation costs, possibly even contributing to emission reduction.}, + language = {en}, + number = {9}, + urldate = {2015-10-22}, + journal = {Environmental Research Letters}, + author = {Weindl, Isabelle and Lotze-Campen, Hermann and Popp, Alexander and M\"uller, Christoph and Havlík, Petr and {Mario Herrero} and Schmitz, Christoph and Rolinski, Susanne}, + year = {2015}, + pages = {094021}, } @article{popp_land_nodate, - title = {Land use futures in the {Shared} {Socio}-{Economic} {Pathways}}, - journal = {Global Environmental Change}, - author = {Popp, Alexander and Calvin, Katherine and Fujimori, Shinichiro and Havlik, Petr and Humpenöder, Florian and Stehfest, Elke and Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Doelmann, Jonathan and Gusti, Mykola and Hasegawa, Tomoko and Kyle, Page and Obersteiner, Michael and Tabeau, Andrzej and Takahashi, Kiyoshi and Valin, Hugo and Waldhoff, Stephanie and Weindl, Isabelle and Wise, Marshall and Kriegler, Elmar and Lotze-Campen, Hermann and Fricko, Oliver and Riahi, Keywan and Vuuren, Detlef van}, - file = {Popp et al SI.docx:D\:\\Dissertation\\Bibliographie\\storage\\S42V3BUD\\Popp et al SI.docx:application/vnd.openxmlformats-officedocument.wordprocessingml.document;Popp et al_submitted_Land use futures in the Shared Socio-Economic Pathways.docx:D\:\\Dissertation\\Bibliographie\\storage\\XCF32NXR\\Popp et al_submitted_Land use futures in the Shared Socio-Economic Pathways.docx:application/vnd.openxmlformats-officedocument.wordprocessingml.document} + title = {Land use futures in the {Shared} {Socio}-{Economic} {Pathways}}, + journal = {Global Environmental Change}, + author = {Popp, Alexander and Calvin, Katherine and Fujimori, Shinichiro and Havlik, Petr and Humpenöder, Florian and Stehfest, Elke and Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Doelmann, Jonathan and Gusti, Mykola and Hasegawa, Tomoko and Kyle, Page and Obersteiner, Michael and Tabeau, Andrzej and Takahashi, Kiyoshi and Valin, Hugo and Waldhoff, Stephanie and Weindl, Isabelle and Wise, Marshall and Kriegler, Elmar and Lotze-Campen, Hermann and Fricko, Oliver and Riahi, Keywan and Vuuren, Detlef van}, } @article{schmitz_land-use_2014, - title = {Land-use change trajectories up to 2050: insights from a global agro-economic model comparison}, - volume = {45}, - copyright = {© 2013 International Association of Agricultural Economists}, - issn = {1574-0862}, - shorttitle = {Land-use change trajectories up to 2050}, - url = {http://onlinelibrary.wiley.com/doi/10.1111/agec.12090/abstract}, - doi = {10.1111/agec.12090}, - abstract = {Changes in agricultural land use have important implications for environmental services. Previous studies of agricultural land-use futures have been published indicating large uncertainty due to different model assumptions and methodologies. In this article we present a first comprehensive comparison of global agro-economic models that have harmonized drivers of population, GDP, and biophysical yields. The comparison allows us to ask two research questions: (1) How much cropland will be used under different socioeconomic and climate change scenarios? (2) How can differences in model results be explained? The comparison includes four partial and six general equilibrium models that differ in how they model land supply and amount of potentially available land. We analyze results of two different socioeconomic scenarios and three climate scenarios (one with constant climate). Most models (7 out of 10) project an increase of cropland of 10–25\% by 2050 compared to 2005 (under constant climate), but one model projects a decrease. Pasture land expands in some models, which increase the treat on natural vegetation further. Across all models most of the cropland expansion takes place in South America and sub-Saharan Africa. In general, the strongest differences in model results are related to differences in the costs of land expansion, the endogenous productivity responses, and the assumptions about potential cropland.}, - language = {en}, - number = {1}, - urldate = {2015-12-16}, - journal = {Agricultural Economics}, - author = {Schmitz, Christoph and van Meijl, Hans and Kyle, Page and Nelson, Gerald C. and Fujimori, Shinichiro and Gurgel, Angelo and Havlik, Petr and Heyhoe, Edwina and d'Croz, Daniel Mason and Popp, Alexander and Sands, Ron and Tabeau, Andrzej and van der Mensbrugghe, Dominique and von Lampe, Martin and Wise, Marshall and Blanc, Elodie and Hasegawa, Tomoko and Kavallari, Aikaterini and Valin, Hugo}, - month = jan, - year = {2014}, - keywords = {Land-use change, Q11, C68, Q54, model intercomparison, C61, Land-use models, Land expansion}, - pages = {69--84}, - file = {Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\WMK7HMP9\\abstract.html:text/html} + title = {Land-use change trajectories up to 2050: insights from a global agro-economic model comparison}, + volume = {45}, + copyright = {© 2013 International Association of Agricultural Economists}, + issn = {1574-0862}, + shorttitle = {Land-use change trajectories up to 2050}, + url = {http://onlinelibrary.wiley.com/doi/10.1111/agec.12090/abstract}, + doi = {10.1111/agec.12090}, + abstract = {Changes in agricultural land use have important implications for environmental services. Previous studies of agricultural land-use futures have been published indicating large uncertainty due to different model assumptions and methodologies. In this article we present a first comprehensive comparison of global agro-economic models that have harmonized drivers of population, GDP, and biophysical yields. The comparison allows us to ask two research questions: (1) How much cropland will be used under different socioeconomic and climate change scenarios? (2) How can differences in model results be explained? The comparison includes four partial and six general equilibrium models that differ in how they model land supply and amount of potentially available land. We analyze results of two different socioeconomic scenarios and three climate scenarios (one with constant climate). Most models (7 out of 10) project an increase of cropland of 10–25\% by 2050 compared to 2005 (under constant climate), but one model projects a decrease. Pasture land expands in some models, which increase the treat on natural vegetation further. Across all models most of the cropland expansion takes place in South America and sub-Saharan Africa. In general, the strongest differences in model results are related to differences in the costs of land expansion, the endogenous productivity responses, and the assumptions about potential cropland.}, + language = {en}, + number = {1}, + urldate = {2015-12-16}, + journal = {Agricultural Economics}, + author = {Schmitz, Christoph and van Meijl, Hans and Kyle, Page and Nelson, Gerald C. and Fujimori, Shinichiro and Gurgel, Angelo and Havlik, Petr and Heyhoe, Edwina and d'Croz, Daniel Mason and Popp, Alexander and Sands, Ron and Tabeau, Andrzej and van der Mensbrugghe, Dominique and von Lampe, Martin and Wise, Marshall and Blanc, Elodie and Hasegawa, Tomoko and Kavallari, Aikaterini and Valin, Hugo}, + month = jan, + year = {2014}, + keywords = {Land-use change, Q11, C68, Q54, model intercomparison, C61, Land-use models, Land expansion}, + pages = {69--84}, } @techreport{biewald_impact_2015, - address = {Potsdam}, - title = {The impact of climate change on costs of food and people exposed to hunger at subnational scale}, - url = {https://www.pik-potsdam.de/research/publications/pikreports/.files/pr128.pdf}, - number = {128}, - urldate = {2016-02-24}, - institution = {PIK}, - author = {Biewald, Anne and Lotze-Campen, Hermann and Otto, Ilona and Brinckmann, Nils and Weindl, Isabelle and Popp, Alexander and Schellnhuber, Hans Joachim and Bodirsky, Benjamin}, - year = {2015}, - file = {pr128.pdf:D\:\\Dissertation\\Bibliographie\\storage\\ANRSHSB7\\pr128.pdf:application/pdf} + address = {Potsdam}, + title = {The impact of climate change on costs of food and people exposed to hunger at subnational scale}, + url = {https://www.pik-potsdam.de/research/publications/pikreports/.files/pr128.pdf}, + number = {128}, + urldate = {2016-02-24}, + institution = {PIK}, + author = {Biewald, Anne and Lotze-Campen, Hermann and Otto, Ilona and Brinckmann, Nils and Weindl, Isabelle and Popp, Alexander and Schellnhuber, Hans Joachim and Bodirsky, Benjamin}, + year = {2015}, } @article{humpenoder_land-use_2015, - title = {Land-{Use} and {Carbon} {Cycle} {Responses} to {Moderate} {Climate} {Change}: {Implications} for {Land}-{Based} {Mitigation}?}, - volume = {49}, - issn = {0013-936X, 1520-5851}, - shorttitle = {Land-{Use} and {Carbon} {Cycle} {Responses} to {Moderate} {Climate} {Change}}, - url = {http://pubs.acs.org/doi/abs/10.1021/es506201r}, - doi = {10.1021/es506201r}, - language = {en}, - number = {11}, - urldate = {2016-03-08}, - journal = {Environmental Science \& Technology}, - author = {Humpenöder, Florian and Popp, Alexander and Stevanovic, Miodrag and M\"uller, Christoph and Bodirsky, Benjamin Leon and Bonsch, Markus and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Weindl, Isabelle and Biewald, Anne and Rolinski, Susanne}, - month = jun, - year = {2015}, - pages = {6731--6739}, - file = {es506201r.pdf:D\:\\Dissertation\\Bibliographie\\storage\\M6U9N3H4\\es506201r.pdf:application/pdf} + title = {Land-{Use} and {Carbon} {Cycle} {Responses} to {Moderate} {Climate} {Change}: {Implications} for {Land}-{Based} {Mitigation}?}, + volume = {49}, + issn = {0013-936X, 1520-5851}, + shorttitle = {Land-{Use} and {Carbon} {Cycle} {Responses} to {Moderate} {Climate} {Change}}, + url = {http://pubs.acs.org/doi/abs/10.1021/es506201r}, + doi = {10.1021/es506201r}, + language = {en}, + number = {11}, + urldate = {2016-03-08}, + journal = {Environmental Science \& Technology}, + author = {Humpenöder, Florian and Popp, Alexander and Stevanovic, Miodrag and M\"uller, Christoph and Bodirsky, Benjamin Leon and Bonsch, Markus and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Weindl, Isabelle and Biewald, Anne and Rolinski, Susanne}, + month = jun, + year = {2015}, + pages = {6731--6739}, } @article{kreidenweis_afforestation_2016, - title = {Afforestation to mitigate climate change: impacts on food prices under consideration of albedo effects}, - volume = {11}, - issn = {1748-9326}, - shorttitle = {Afforestation to mitigate climate change}, - url = {http://stacks.iop.org/1748-9326/11/i=8/a=085001}, - doi = {10.1088/1748-9326/11/8/085001}, - abstract = {Ambitious climate targets, such as the 2 °C target, are likely to require the removal of carbon dioxide from the atmosphere. Afforestation is one such mitigation option but could, through the competition for land, also lead to food prices hikes. In addition, afforestation often decreases land-surface albedo and the amount of short-wave radiation reflected back to space, which results in a warming effect. In particular in the boreal zone, such biophysical warming effects following from afforestation are estimated to offset the cooling effect from carbon sequestration. We assessed the food price response of afforestation, and considered the albedo effect with scenarios in which afforestation was restricted to certain latitudinal zones. In our study, afforestation was incentivized by a globally uniform reward for carbon uptake in the terrestrial biosphere. This resulted in large-scale afforestation (2580 Mha globally) and substantial carbon sequestration (860 GtCO 2 ) up to the end of the century. However, it was also associated with an increase in food prices of about 80\% by 2050 and a more than fourfold increase by 2100. When afforestation was restricted to the tropics the food price response was substantially reduced, while still almost 60\% cumulative carbon sequestration was achieved. In the medium term, the increase in prices was then lower than the increase in income underlying our scenario projections. Moreover, our results indicate that more liberalised trade in agricultural commodities could buffer the food price increases following from afforestation in tropical regions.}, - language = {en}, - number = {8}, - urldate = {2016-07-28}, - journal = {Environmental Research Letters}, - author = {Kreidenweis, Ulrich and Humpenöder, Florian and Stevanovic, Miodrag and Bodirsky, Benjamin Leon and {Elmar Kriegler} and Lotze-Campen, Hermann and Popp, Alexander}, - year = {2016}, - pages = {085001}, - file = {Kreidenweis et al_2016_Afforestation to mitigate climate change.pdf:D\:\\Dissertation\\Bibliographie\\storage\\8EDBJ5UK\\Kreidenweis et al_2016_Afforestation to mitigate climate change.pdf:application/pdf} + title = {Afforestation to mitigate climate change: impacts on food prices under consideration of albedo effects}, + volume = {11}, + issn = {1748-9326}, + shorttitle = {Afforestation to mitigate climate change}, + url = {http://stacks.iop.org/1748-9326/11/i=8/a=085001}, + doi = {10.1088/1748-9326/11/8/085001}, + abstract = {Ambitious climate targets, such as the 2 °C target, are likely to require the removal of carbon dioxide from the atmosphere. Afforestation is one such mitigation option but could, through the competition for land, also lead to food prices hikes. In addition, afforestation often decreases land-surface albedo and the amount of short-wave radiation reflected back to space, which results in a warming effect. In particular in the boreal zone, such biophysical warming effects following from afforestation are estimated to offset the cooling effect from carbon sequestration. We assessed the food price response of afforestation, and considered the albedo effect with scenarios in which afforestation was restricted to certain latitudinal zones. In our study, afforestation was incentivized by a globally uniform reward for carbon uptake in the terrestrial biosphere. This resulted in large-scale afforestation (2580 Mha globally) and substantial carbon sequestration (860 GtCO 2 ) up to the end of the century. However, it was also associated with an increase in food prices of about 80\% by 2050 and a more than fourfold increase by 2100. When afforestation was restricted to the tropics the food price response was substantially reduced, while still almost 60\% cumulative carbon sequestration was achieved. In the medium term, the increase in prices was then lower than the increase in income underlying our scenario projections. Moreover, our results indicate that more liberalised trade in agricultural commodities could buffer the food price increases following from afforestation in tropical regions.}, + language = {en}, + number = {8}, + urldate = {2016-07-28}, + journal = {Environmental Research Letters}, + author = {Kreidenweis, Ulrich and Humpenöder, Florian and Stevanovic, Miodrag and Bodirsky, Benjamin Leon and {Elmar Kriegler} and Lotze-Campen, Hermann and Popp, Alexander}, + year = {2016}, + pages = {085001}, } @article{stevanovic_impact_2016, - title = {The impact of high-end climate change on agricultural welfare}, - volume = {2}, - copyright = {Copyright © 2016, The Authors. This is an open-access article distributed under the terms of the Creative Commons Attribution-NonCommercial license, which permits use, distribution, and reproduction in any medium, so long as the resultant use is not for commercial advantage and provided the original work is properly cited.}, - issn = {2375-2548}, - url = {http://advances.sciencemag.org/content/2/8/e1501452}, - doi = {10.1126/sciadv.1501452}, - language = {en}, - number = {8}, - urldate = {2016-08-25}, - journal = {Science Advances}, - author = {Stevanovic, Miodrag and Popp, Alexander and Lotze-Campen, Hermann and Dietrich, Jan Philipp and M\"uller, Christoph and Bonsch, Markus and Schmitz, Christoph and Bodirsky, Benjamin Leon and Humpenöder, Florian and Weindl, Isabelle}, - month = aug, - year = {2016}, - pages = {e1501452}, + title = {The impact of high-end climate change on agricultural welfare}, + volume = {2}, + copyright = {Copyright © 2016, The Authors. This is an open-access article distributed under the terms of the Creative Commons Attribution-NonCommercial license, which permits use, distribution, and reproduction in any medium, so long as the resultant use is not for commercial advantage and provided the original work is properly cited.}, + issn = {2375-2548}, + url = {http://advances.sciencemag.org/content/2/8/e1501452}, + doi = {10.1126/sciadv.1501452}, + language = {en}, + number = {8}, + urldate = {2016-08-25}, + journal = {Science Advances}, + author = {Stevanovic, Miodrag and Popp, Alexander and Lotze-Campen, Hermann and Dietrich, Jan Philipp and M\"uller, Christoph and Bonsch, Markus and Schmitz, Christoph and Bodirsky, Benjamin Leon and Humpenöder, Florian and Weindl, Isabelle}, + month = aug, + year = {2016}, + pages = {e1501452}, } @article{stevanovic_agriculture_nodate, - title = {Agriculture, {Forestry}, and {Other} {Land}-{Use} {Emissions} {Abatement}: {Mitigation} {Strategies} and {Consequences} for {Food} {Prices}}, - journal = {Environmental Science \& Technology}, - author = {Stevanovic, Miodrag and Popp, Alexander and Bodirsky, Benjamin L. and Humpenöder, Florian and M\"uller, Christoph and Weindl, Isabelle and Dietrich, Jan Philip and Lotze-Campen, Hermann and Kreidenweis, Ulrich and Rolinski, Susanne and Biewald, Anne and Wang, Xiaoxi} + title = {Agriculture, {Forestry}, and {Other} {Land}-{Use} {Emissions} {Abatement}: {Mitigation} {Strategies} and {Consequences} for {Food} {Prices}}, + journal = {Environmental Science \& Technology}, + author = {Stevanovic, Miodrag and Popp, Alexander and Bodirsky, Benjamin L. and Humpenöder, Florian and M\"uller, Christoph and Weindl, Isabelle and Dietrich, Jan Philip and Lotze-Campen, Hermann and Kreidenweis, Ulrich and Rolinski, Susanne and Biewald, Anne and Wang, Xiaoxi} } @article{popp_land-use_nodate, - title = {Land-use futures in the shared socio-economic pathways}, - issn = {0959-3780}, - url = {http://www.sciencedirect.com/science/article/pii/S0959378016303399}, - doi = {10.1016/j.gloenvcha.2016.10.002}, - abstract = {In the future, the land system will be facing new intersecting challenges. While food demand, especially for resource-intensive livestock based commodities, is expected to increase, the terrestrial system has large potentials for climate change mitigation through improved agricultural management, providing biomass for bioenergy, and conserving or even enhancing carbon stocks of ecosystems. However, uncertainties in future socio-economic land use drivers may result in very different land-use dynamics and consequences for land-based ecosystem services. This is the first study with a systematic interpretation of the Shared Socio-Economic Pathways (SSPs) in terms of possible land-use changes and their consequences for the agricultural system, food provision and prices as well as greenhouse gas emissions. Therefore, five alternative Integrated Assessment Models with distinctive land-use modules have been used for the translation of the SSP narratives into quantitative projections. The model results reflect the general storylines of the SSPs and indicate a broad range of potential land-use futures with global agricultural land of 4900 mio ha in 2005 decreasing by 810 mio ha until 2100 at the lower (SSP1) and increasing by 1080 mio ha (SSP3) at the upper end. Greenhouse gas emissions from land use and land use change, as a direct outcome of these diverse land-use dynamics, and agricultural production systems differ strongly across SSPs (e.g. cumulative land use change emissions between 2005 and 2100 range from −54 to 402 Gt CO2). The inclusion of land-based mitigation efforts, particularly those in the most ambitious mitigation scenarios, further broadens the range of potential land futures and can strongly affect greenhouse gas dynamics and food prices. In general, it can be concluded that low demand for agricultural commodities, rapid growth in agricultural productivity and globalized trade, all most pronounced in a SSP1 world, have the potential to enhance the extent of natural ecosystems, lead to lowest greenhouse gas emissions from the land system and decrease food prices over time. The SSP-based land use pathways presented in this paper aim at supporting future climate research and provide the basis for further regional integrated assessments, biodiversity research and climate impact analysis.}, - urldate = {2016-12-23}, - journal = {Global Environmental Change}, - author = {Popp, Alexander and Calvin, Katherine and Fujimori, Shinichiro and Havlik, Petr and Humpenöder, Florian and Stehfest, Elke and Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Doelmann, Jonathan C. and Gusti, Mykola and Hasegawa, Tomoko and Kyle, Page and Obersteiner, Michael and Tabeau, Andrzej and Takahashi, Kiyoshi and Valin, Hugo and Waldhoff, Stephanie and Weindl, Isabelle and Wise, Marshall and Kriegler, Elmar and Lotze-Campen, Hermann and Fricko, Oliver and Riahi, Keywan and Vuuren, Detlef P. van}, - keywords = {land use, Emissions, mitigation, Scenarios, Integrated assessment, Food prices, SSP}, - file = {Popp et al_Land-use futures in the shared socio-economic pathways.pdf:D\:\\Dissertation\\Bibliographie\\storage\\ZUCFU4AQ\\Popp et al_Land-use futures in the shared socio-economic pathways.pdf:application/pdf;ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\BEHGIUR5\\S0959378016303399.html:text/html} + title = {Land-use futures in the shared socio-economic pathways}, + issn = {0959-3780}, + url = {http://www.sciencedirect.com/science/article/pii/S0959378016303399}, + doi = {10.1016/j.gloenvcha.2016.10.002}, + abstract = {In the future, the land system will be facing new intersecting challenges. While food demand, especially for resource-intensive livestock based commodities, is expected to increase, the terrestrial system has large potentials for climate change mitigation through improved agricultural management, providing biomass for bioenergy, and conserving or even enhancing carbon stocks of ecosystems. However, uncertainties in future socio-economic land use drivers may result in very different land-use dynamics and consequences for land-based ecosystem services. This is the first study with a systematic interpretation of the Shared Socio-Economic Pathways (SSPs) in terms of possible land-use changes and their consequences for the agricultural system, food provision and prices as well as greenhouse gas emissions. Therefore, five alternative Integrated Assessment Models with distinctive land-use modules have been used for the translation of the SSP narratives into quantitative projections. The model results reflect the general storylines of the SSPs and indicate a broad range of potential land-use futures with global agricultural land of 4900 mio ha in 2005 decreasing by 810 mio ha until 2100 at the lower (SSP1) and increasing by 1080 mio ha (SSP3) at the upper end. Greenhouse gas emissions from land use and land use change, as a direct outcome of these diverse land-use dynamics, and agricultural production systems differ strongly across SSPs (e.g. cumulative land use change emissions between 2005 and 2100 range from −54 to 402 Gt CO2). The inclusion of land-based mitigation efforts, particularly those in the most ambitious mitigation scenarios, further broadens the range of potential land futures and can strongly affect greenhouse gas dynamics and food prices. In general, it can be concluded that low demand for agricultural commodities, rapid growth in agricultural productivity and globalized trade, all most pronounced in a SSP1 world, have the potential to enhance the extent of natural ecosystems, lead to lowest greenhouse gas emissions from the land system and decrease food prices over time. The SSP-based land use pathways presented in this paper aim at supporting future climate research and provide the basis for further regional integrated assessments, biodiversity research and climate impact analysis.}, + urldate = {2016-12-23}, + journal = {Global Environmental Change}, + author = {Popp, Alexander and Calvin, Katherine and Fujimori, Shinichiro and Havlik, Petr and Humpenöder, Florian and Stehfest, Elke and Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Doelmann, Jonathan C. and Gusti, Mykola and Hasegawa, Tomoko and Kyle, Page and Obersteiner, Michael and Tabeau, Andrzej and Takahashi, Kiyoshi and Valin, Hugo and Waldhoff, Stephanie and Weindl, Isabelle and Wise, Marshall and Kriegler, Elmar and Lotze-Campen, Hermann and Fricko, Oliver and Riahi, Keywan and Vuuren, Detlef P. van}, + keywords = {land use, Emissions, mitigation, Scenarios, Integrated assessment, Food prices, SSP}, } @article{stevanovic_mitigation_2017, - title = {Mitigation {Strategies} for {Greenhouse} {Gas} {Emissions} from {Agriculture} and {Land}-{Use} {Change}: {Consequences} for {Food} {Prices}}, - volume = {51}, - issn = {0013-936X}, - shorttitle = {Mitigation {Strategies} for {Greenhouse} {Gas} {Emissions} from {Agriculture} and {Land}-{Use} {Change}}, - url = {http://dx.doi.org/10.1021/acs.est.6b04291}, - doi = {10.1021/acs.est.6b04291}, - abstract = {The land use sector of agriculture, forestry, and other land use (AFOLU) plays a central role in ambitious climate change mitigation efforts. Yet, mitigation policies in agriculture may be in conflict with food security related targets. Using a global agro–economic model, we analyze the impacts on food prices under mitigation policies targeting either incentives for producers (e.g., through taxes) or consumer preferences (e.g., through education programs). Despite having a similar reduction potential of 43–44\% in 2100, the two types of policy instruments result in opposite outcomes for food prices. Incentive-based mitigation, such as protecting carbon-rich forests or adopting low-emission production techniques, increase land scarcity and production costs and thereby food prices. Preference-based mitigation, such as reduced household waste or lower consumption of animal-based products, decreases land scarcity, prevents emissions leakage, and concentrates production on the most productive sites and consequently lowers food prices. Whereas agricultural emissions are further abated in the combination of these mitigation measures, the synergy of strategies fails to substantially lower food prices. Additionally, we demonstrate that the efficiency of agricultural emission abatement is stable across a range of greenhouse-gas (GHG) tax levels, while resulting food prices exhibit a disproportionally larger spread.}, - number = {1}, - urldate = {2017-01-05}, - journal = {Environmental Science \& Technology}, - author = {Stevanovic, Miodrag and Popp, Alexander and Bodirsky, Benjamin Leon and Humpenöder, Florian and M\"uller, Christoph and Weindl, Isabelle and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Kreidenweis, Ulrich and Rolinski, Susanne and Biewald, Anne and Wang, Xiaoxi}, - month = jan, - year = {2017}, - pages = {365--374}, + title = {Mitigation {Strategies} for {Greenhouse} {Gas} {Emissions} from {Agriculture} and {Land}-{Use} {Change}: {Consequences} for {Food} {Prices}}, + volume = {51}, + issn = {0013-936X}, + shorttitle = {Mitigation {Strategies} for {Greenhouse} {Gas} {Emissions} from {Agriculture} and {Land}-{Use} {Change}}, + url = {http://dx.doi.org/10.1021/acs.est.6b04291}, + doi = {10.1021/acs.est.6b04291}, + abstract = {The land use sector of agriculture, forestry, and other land use (AFOLU) plays a central role in ambitious climate change mitigation efforts. Yet, mitigation policies in agriculture may be in conflict with food security related targets. Using a global agro–economic model, we analyze the impacts on food prices under mitigation policies targeting either incentives for producers (e.g., through taxes) or consumer preferences (e.g., through education programs). Despite having a similar reduction potential of 43–44\% in 2100, the two types of policy instruments result in opposite outcomes for food prices. Incentive-based mitigation, such as protecting carbon-rich forests or adopting low-emission production techniques, increase land scarcity and production costs and thereby food prices. Preference-based mitigation, such as reduced household waste or lower consumption of animal-based products, decreases land scarcity, prevents emissions leakage, and concentrates production on the most productive sites and consequently lowers food prices. Whereas agricultural emissions are further abated in the combination of these mitigation measures, the synergy of strategies fails to substantially lower food prices. Additionally, we demonstrate that the efficiency of agricultural emission abatement is stable across a range of greenhouse-gas (GHG) tax levels, while resulting food prices exhibit a disproportionally larger spread.}, + number = {1}, + urldate = {2017-01-05}, + journal = {Environmental Science \& Technology}, + author = {Stevanovic, Miodrag and Popp, Alexander and Bodirsky, Benjamin Leon and Humpenöder, Florian and M\"uller, Christoph and Weindl, Isabelle and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Kreidenweis, Ulrich and Rolinski, Susanne and Biewald, Anne and Wang, Xiaoxi}, + month = jan, + year = {2017}, + pages = {365--374}, } @article{kriegler_fossil-fueled_2017, - title = {Fossil-fueled development ({SSP}5): {An} energy and resource intensive scenario for the 21st century}, - volume = {42}, - issn = {0959-3780}, - shorttitle = {Fossil-fueled development ({SSP}5)}, - url = {http://www.sciencedirect.com/science/article/pii/S0959378016300711}, - doi = {10.1016/j.gloenvcha.2016.05.015}, - abstract = {This paper presents a set of energy and resource intensive scenarios based on the concept of Shared Socio-Economic Pathways (SSPs). The scenario family is characterized by rapid and fossil-fueled development with high socio-economic challenges to mitigation and low socio-economic challenges to adaptation (SSP5). A special focus is placed on the SSP5 marker scenario developed by the REMIND-MAgPIE integrated assessment modeling framework. The SSP5 baseline scenarios exhibit very high levels of fossil fuel use, up to a doubling of global food demand, and up to a tripling of energy demand and greenhouse gas emissions over the course of the century, marking the upper end of the scenario literature in several dimensions. These scenarios are currently the only SSP scenarios that result in a radiative forcing pathway as high as the highest Representative Concentration Pathway (RCP8.5). This paper further investigates the direct impact of mitigation policies on the SSP5 energy, land and emissions dynamics confirming high socio-economic challenges to mitigation in SSP5. Nonetheless, mitigation policies reaching climate forcing levels as low as in the lowest Representative Concentration Pathway (RCP2.6) are accessible in SSP5. The SSP5 scenarios presented in this paper aim to provide useful reference points for future climate change, climate impact, adaption and mitigation analysis, and broader questions of sustainable development.}, - urldate = {2017-04-19}, - journal = {Global Environmental Change}, - author = {Kriegler, Elmar and Bauer, Nico and Popp, Alexander and Humpenöder, Florian and Leimbach, Marian and Strefler, Jessica and Baumstark, Lavinia and Bodirsky, Benjamin Leon and Hilaire, Jérôme and Klein, David and Mouratiadou, Ioanna and Weindl, Isabelle and Bertram, Christoph and Dietrich, Jan-Philipp and Luderer, Gunnar and Pehl, Michaja and Pietzcker, Robert and Piontek, Franziska and Lotze-Campen, Hermann and Biewald, Anne and Bonsch, Markus and Giannousakis, Anastasis and Kreidenweis, Ulrich and M\"uller, Christoph and Rolinski, Susanne and Schultes, Anselm and Schwanitz, Jana and Stevanovic, Miodrag and Calvin, Katherine and Emmerling, Johannes and Fujimori, Shinichiro and Edenhofer, Ottmar}, - month = jan, - year = {2017}, - keywords = {Land-use change, Integrated assessment modeling, Shared Socio-economic Pathway, SSP5, Emission scenario, Energy transformation}, - pages = {297--315}, - file = {Kriegler et al_2017_Fossil-fueled development (SSP5).pdf:D\:\\Dissertation\\Bibliographie\\storage\\9AQM88TX\\Kriegler et al_2017_Fossil-fueled development (SSP5).pdf:application/pdf;mmc1.docx:D\:\\Dissertation\\Bibliographie\\storage\\KM3PTGHX\\mmc1.docx:application/vnd.openxmlformats-officedocument.wordprocessingml.document;ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\JB6XHVN6\\S0959378016300711.html:text/html} + title = {Fossil-fueled development ({SSP}5): {An} energy and resource intensive scenario for the 21st century}, + volume = {42}, + issn = {0959-3780}, + shorttitle = {Fossil-fueled development ({SSP}5)}, + url = {http://www.sciencedirect.com/science/article/pii/S0959378016300711}, + doi = {10.1016/j.gloenvcha.2016.05.015}, + abstract = {This paper presents a set of energy and resource intensive scenarios based on the concept of Shared Socio-Economic Pathways (SSPs). The scenario family is characterized by rapid and fossil-fueled development with high socio-economic challenges to mitigation and low socio-economic challenges to adaptation (SSP5). A special focus is placed on the SSP5 marker scenario developed by the REMIND-MAgPIE integrated assessment modeling framework. The SSP5 baseline scenarios exhibit very high levels of fossil fuel use, up to a doubling of global food demand, and up to a tripling of energy demand and greenhouse gas emissions over the course of the century, marking the upper end of the scenario literature in several dimensions. These scenarios are currently the only SSP scenarios that result in a radiative forcing pathway as high as the highest Representative Concentration Pathway (RCP8.5). This paper further investigates the direct impact of mitigation policies on the SSP5 energy, land and emissions dynamics confirming high socio-economic challenges to mitigation in SSP5. Nonetheless, mitigation policies reaching climate forcing levels as low as in the lowest Representative Concentration Pathway (RCP2.6) are accessible in SSP5. The SSP5 scenarios presented in this paper aim to provide useful reference points for future climate change, climate impact, adaption and mitigation analysis, and broader questions of sustainable development.}, + urldate = {2017-04-19}, + journal = {Global Environmental Change}, + author = {Kriegler, Elmar and Bauer, Nico and Popp, Alexander and Humpenöder, Florian and Leimbach, Marian and Strefler, Jessica and Baumstark, Lavinia and Bodirsky, Benjamin Leon and Hilaire, Jérôme and Klein, David and Mouratiadou, Ioanna and Weindl, Isabelle and Bertram, Christoph and Dietrich, Jan-Philipp and Luderer, Gunnar and Pehl, Michaja and Pietzcker, Robert and Piontek, Franziska and Lotze-Campen, Hermann and Biewald, Anne and Bonsch, Markus and Giannousakis, Anastasis and Kreidenweis, Ulrich and M\"uller, Christoph and Rolinski, Susanne and Schultes, Anselm and Schwanitz, Jana and Stevanovic, Miodrag and Calvin, Katherine and Emmerling, Johannes and Fujimori, Shinichiro and Edenhofer, Ottmar}, + month = jan, + year = {2017}, + keywords = {Land-use change, Integrated assessment modeling, Shared Socio-economic Pathway, SSP5, Emission scenario, Energy transformation}, + pages = {297--315}, } @article{popp_land-use_2017, - title = {Land-use futures in the shared socio-economic pathways}, - volume = {42}, - issn = {0959-3780}, - url = {http://www.sciencedirect.com/science/article/pii/S0959378016303399}, - doi = {10.1016/j.gloenvcha.2016.10.002}, - abstract = {In the future, the land system will be facing new intersecting challenges. While food demand, especially for resource-intensive livestock based commodities, is expected to increase, the terrestrial system has large potentials for climate change mitigation through improved agricultural management, providing biomass for bioenergy, and conserving or even enhancing carbon stocks of ecosystems. However, uncertainties in future socio-economic land use drivers may result in very different land-use dynamics and consequences for land-based ecosystem services. This is the first study with a systematic interpretation of the Shared Socio-Economic Pathways (SSPs) in terms of possible land-use changes and their consequences for the agricultural system, food provision and prices as well as greenhouse gas emissions. Therefore, five alternative Integrated Assessment Models with distinctive land-use modules have been used for the translation of the SSP narratives into quantitative projections. The model results reflect the general storylines of the SSPs and indicate a broad range of potential land-use futures with global agricultural land of 4900 mio ha in 2005 decreasing by 743 mio ha until 2100 at the lower (SSP1) and increasing by 1080 mio ha (SSP3) at the upper end. Greenhouse gas emissions from land use and land use change, as a direct outcome of these diverse land-use dynamics, and agricultural production systems differ strongly across SSPs (e.g. cumulative land use change emissions between 2005 and 2100 range from −54 to 402 Gt CO2). The inclusion of land-based mitigation efforts, particularly those in the most ambitious mitigation scenarios, further broadens the range of potential land futures and can strongly affect greenhouse gas dynamics and food prices. In general, it can be concluded that low demand for agricultural commodities, rapid growth in agricultural productivity and globalized trade, all most pronounced in a SSP1 world, have the potential to enhance the extent of natural ecosystems, lead to lowest greenhouse gas emissions from the land system and decrease food prices over time. The SSP-based land use pathways presented in this paper aim at supporting future climate research and provide the basis for further regional integrated assessments, biodiversity research and climate impact analysis.}, - urldate = {2017-04-19}, - journal = {Global Environmental Change}, - author = {Popp, Alexander and Calvin, Katherine and Fujimori, Shinichiro and Havlik, Petr and Humpenöder, Florian and Stehfest, Elke and Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Doelmann, Jonathan C. and Gusti, Mykola and Hasegawa, Tomoko and Kyle, Page and Obersteiner, Michael and Tabeau, Andrzej and Takahashi, Kiyoshi and Valin, Hugo and Waldhoff, Stephanie and Weindl, Isabelle and Wise, Marshall and Kriegler, Elmar and Lotze-Campen, Hermann and Fricko, Oliver and Riahi, Keywan and Vuuren, Detlef P. van}, - month = jan, - year = {2017}, - keywords = {land use, Emissions, mitigation, Scenarios, Integrated assessment, Food prices, SSP}, - pages = {331--345}, - file = {Popp et al_2017_Land-use futures in the shared socio-economic pathways.pdf:D\:\\Dissertation\\Bibliographie\\storage\\GDZ2DUXQ\\Popp et al_2017_Land-use futures in the shared socio-economic pathways.pdf:application/pdf;ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\R7UWJ824\\S0959378016303399.html:text/html} + title = {Land-use futures in the shared socio-economic pathways}, + volume = {42}, + issn = {0959-3780}, + url = {http://www.sciencedirect.com/science/article/pii/S0959378016303399}, + doi = {10.1016/j.gloenvcha.2016.10.002}, + abstract = {In the future, the land system will be facing new intersecting challenges. While food demand, especially for resource-intensive livestock based commodities, is expected to increase, the terrestrial system has large potentials for climate change mitigation through improved agricultural management, providing biomass for bioenergy, and conserving or even enhancing carbon stocks of ecosystems. However, uncertainties in future socio-economic land use drivers may result in very different land-use dynamics and consequences for land-based ecosystem services. This is the first study with a systematic interpretation of the Shared Socio-Economic Pathways (SSPs) in terms of possible land-use changes and their consequences for the agricultural system, food provision and prices as well as greenhouse gas emissions. Therefore, five alternative Integrated Assessment Models with distinctive land-use modules have been used for the translation of the SSP narratives into quantitative projections. The model results reflect the general storylines of the SSPs and indicate a broad range of potential land-use futures with global agricultural land of 4900 mio ha in 2005 decreasing by 743 mio ha until 2100 at the lower (SSP1) and increasing by 1080 mio ha (SSP3) at the upper end. Greenhouse gas emissions from land use and land use change, as a direct outcome of these diverse land-use dynamics, and agricultural production systems differ strongly across SSPs (e.g. cumulative land use change emissions between 2005 and 2100 range from −54 to 402 Gt CO2). The inclusion of land-based mitigation efforts, particularly those in the most ambitious mitigation scenarios, further broadens the range of potential land futures and can strongly affect greenhouse gas dynamics and food prices. In general, it can be concluded that low demand for agricultural commodities, rapid growth in agricultural productivity and globalized trade, all most pronounced in a SSP1 world, have the potential to enhance the extent of natural ecosystems, lead to lowest greenhouse gas emissions from the land system and decrease food prices over time. The SSP-based land use pathways presented in this paper aim at supporting future climate research and provide the basis for further regional integrated assessments, biodiversity research and climate impact analysis.}, + urldate = {2017-04-19}, + journal = {Global Environmental Change}, + author = {Popp, Alexander and Calvin, Katherine and Fujimori, Shinichiro and Havlik, Petr and Humpenöder, Florian and Stehfest, Elke and Bodirsky, Benjamin Leon and Dietrich, Jan Philipp and Doelmann, Jonathan C. and Gusti, Mykola and Hasegawa, Tomoko and Kyle, Page and Obersteiner, Michael and Tabeau, Andrzej and Takahashi, Kiyoshi and Valin, Hugo and Waldhoff, Stephanie and Weindl, Isabelle and Wise, Marshall and Kriegler, Elmar and Lotze-Campen, Hermann and Fricko, Oliver and Riahi, Keywan and Vuuren, Detlef P. van}, + month = jan, + year = {2017}, + keywords = {land use, Emissions, mitigation, Scenarios, Integrated assessment, Food prices, SSP}, + pages = {331--345}, } @article{lotze-campen_cross-scale_2017, - title = {A cross-scale impact assessment of {European} nature protection policies under contrasting future socio-economic pathways}, - issn = {1436-3798, 1436-378X}, - url = {https://link.springer.com/article/10.1007/s10113-017-1167-8}, - doi = {10.1007/s10113-017-1167-8}, - abstract = {Protection of natural or semi-natural ecosystems is an important part of societal strategies for maintaining biodiversity, ecosystem services, and achieving overall sustainable development. The assessment of multiple emerging land use trade-offs is complicated by the fact that land use changes occur and have consequences at local, regional, and even global scale. Outcomes also depend on the underlying socio-economic trends. We apply a coupled, multi-scale modelling system to assess an increase in nature protection areas as a key policy option in the European Union (EU). The main goal of the analysis is to understand the interactions between policy-induced land use changes across different scales and sectors under two contrasting future socio-economic pathways. We demonstrate how complementary insights into land system change can be gained by coupling land use models for agriculture, forestry, and urban areas for Europe, in connection with other world regions. The simulated policy case of nature protection shows how the allocation of a certain share of total available land to newly protected areas, with specific management restrictions imposed, may have a range of impacts on different land-based sectors until the year 2040. Agricultural land in Europe is slightly reduced, which is partly compensated for by higher management intensity. As a consequence of higher costs, total calorie supply per capita is reduced within the EU. While wood harvest is projected to decrease, carbon sequestration rates increase in European forests. At the same time, imports of industrial roundwood from other world regions are expected to increase. Some of the aggregate effects of nature protection have very different implications at the local to regional scale in different parts of Europe. Due to nature protection measures, agricultural production is shifted from more productive land in Europe to on average less productive land in other parts of the world. This increases, at the global level, the allocation of land resources for agriculture, leading to a decrease in tropical forest areas, reduced carbon stocks, and higher greenhouse gas emissions outside of Europe. The integrated modelling framework provides a method to assess the land use effects of a single policy option while accounting for the trade-offs between locations, and between regional, European, and global scales.}, - language = {en}, - urldate = {2017-05-16}, - journal = {Regional Environmental Change}, - author = {Lotze-Campen, Hermann and Verburg, Peter H. and Popp, Alexander and Lindner, Marcus and Verkerk, Pieter J. and Moiseyev, Alexander and Schrammeijer, Elizabeth and Helming, John and Tabeau, Andrzej and Schulp, Catharina J. E. and Zanden, Emma H. van der and Lavalle, Carlo and Silva, Filipe Batista e and Walz, Ariane and Bodirsky, Benjamin}, - month = may, - year = {2017}, - pages = {1--12}, - file = {Lotze-Campen et al_2017_A cross-scale impact assessment of European nature protection policies under.pdf:D\:\\Dissertation\\Bibliographie\\storage\\9BCGPGDD\\Lotze-Campen et al_2017_A cross-scale impact assessment of European nature protection policies under.pdf:application/pdf;Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\73IHRHPU\\10.html:text/html} + title = {A cross-scale impact assessment of {European} nature protection policies under contrasting future socio-economic pathways}, + issn = {1436-3798, 1436-378X}, + url = {https://link.springer.com/article/10.1007/s10113-017-1167-8}, + doi = {10.1007/s10113-017-1167-8}, + abstract = {Protection of natural or semi-natural ecosystems is an important part of societal strategies for maintaining biodiversity, ecosystem services, and achieving overall sustainable development. The assessment of multiple emerging land use trade-offs is complicated by the fact that land use changes occur and have consequences at local, regional, and even global scale. Outcomes also depend on the underlying socio-economic trends. We apply a coupled, multi-scale modelling system to assess an increase in nature protection areas as a key policy option in the European Union (EU). The main goal of the analysis is to understand the interactions between policy-induced land use changes across different scales and sectors under two contrasting future socio-economic pathways. We demonstrate how complementary insights into land system change can be gained by coupling land use models for agriculture, forestry, and urban areas for Europe, in connection with other world regions. The simulated policy case of nature protection shows how the allocation of a certain share of total available land to newly protected areas, with specific management restrictions imposed, may have a range of impacts on different land-based sectors until the year 2040. Agricultural land in Europe is slightly reduced, which is partly compensated for by higher management intensity. As a consequence of higher costs, total calorie supply per capita is reduced within the EU. While wood harvest is projected to decrease, carbon sequestration rates increase in European forests. At the same time, imports of industrial roundwood from other world regions are expected to increase. Some of the aggregate effects of nature protection have very different implications at the local to regional scale in different parts of Europe. Due to nature protection measures, agricultural production is shifted from more productive land in Europe to on average less productive land in other parts of the world. This increases, at the global level, the allocation of land resources for agriculture, leading to a decrease in tropical forest areas, reduced carbon stocks, and higher greenhouse gas emissions outside of Europe. The integrated modelling framework provides a method to assess the land use effects of a single policy option while accounting for the trade-offs between locations, and between regional, European, and global scales.}, + language = {en}, + urldate = {2017-05-16}, + journal = {Regional Environmental Change}, + author = {Lotze-Campen, Hermann and Verburg, Peter H. and Popp, Alexander and Lindner, Marcus and Verkerk, Pieter J. and Moiseyev, Alexander and Schrammeijer, Elizabeth and Helming, John and Tabeau, Andrzej and Schulp, Catharina J. E. and Zanden, Emma H. van der and Lavalle, Carlo and Silva, Filipe Batista e and Walz, Ariane and Bodirsky, Benjamin}, + month = may, + year = {2017}, + pages = {1--12}, } @article{weindl_livestock_2017, - title = {Livestock production and the water challenge of future food supply: {Implications} of agricultural management and dietary choices}, - volume = {47}, - issn = {0959-3780}, - shorttitle = {Livestock production and the water challenge of future food supply}, - url = {http://www.sciencedirect.com/science/article/pii/S0959378017303692}, - doi = {10.1016/j.gloenvcha.2017.09.010}, - abstract = {Human activities use more than half of accessible freshwater, above all for agriculture. Most approaches for reconciling water conservation with feeding a growing population focus on the cropping sector. However, livestock production is pivotal to agricultural resource use, due to its low resource-use efficiency upstream in the food supply chain. Using a global modelling approach, we quantify the current and future contribution of livestock production, under different demand- and supply-side scenarios, to the consumption of “green” precipitation water infiltrated into the soil and “blue” freshwater withdrawn from rivers, lakes and reservoirs. Currently, cropland feed production accounts for 38\% of crop water consumption and grazing involves 29\% of total agricultural water consumption (9990km3yr−1). Our analysis shows that changes in diets and livestock productivity have substantial implications for future consumption of agricultural blue water (19–36\% increase compared to current levels) and green water (26–69\% increase), but they can, at best, slow down trends of rising water requirements for decades to come. However, moderate productivity reductions in highly intensive livestock systems are possible without aggravating water scarcity. Productivity gains in developing regions decrease total agricultural water consumption, but lead to expansion of irrigated agriculture, due to the shift from grassland/green water to cropland/blue water resources. While the magnitude of the livestock water footprint gives cause for concern, neither dietary choices nor changes in livestock productivity will solve the water challenge of future food supply, unless accompanied by dedicated water protection policies.}, - number = {Supplement C}, - urldate = {2017-11-01}, - journal = {Global Environmental Change}, - author = {Weindl, Isabelle and Bodirsky, Benjamin Leon and Rolinski, Susanne and Biewald, Anne and Lotze-Campen, Hermann and M\"uller, Christoph and Dietrich, Jan Philipp and Humpenöder, Florian and Stevanovic, Miodrag and Schaphoff, Sibyll and Popp, Alexander}, - month = nov, - year = {2017}, - keywords = {livestock, water scarcity, Productivity, consumptive water use, Dietary changes, Water resources}, - pages = {121--132}, - file = {ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\NFCJMAWA\\S0959378017303692.html:text/html;Weindl et al_2017_Livestock production and the water challenge of future food supply.pdf:D\:\\Dissertation\\Bibliographie\\storage\\WRQZAGWU\\Weindl et al_2017_Livestock production and the water challenge of future food supply.pdf:application/pdf} + title = {Livestock production and the water challenge of future food supply: {Implications} of agricultural management and dietary choices}, + volume = {47}, + issn = {0959-3780}, + shorttitle = {Livestock production and the water challenge of future food supply}, + url = {http://www.sciencedirect.com/science/article/pii/S0959378017303692}, + doi = {10.1016/j.gloenvcha.2017.09.010}, + abstract = {Human activities use more than half of accessible freshwater, above all for agriculture. Most approaches for reconciling water conservation with feeding a growing population focus on the cropping sector. However, livestock production is pivotal to agricultural resource use, due to its low resource-use efficiency upstream in the food supply chain. Using a global modelling approach, we quantify the current and future contribution of livestock production, under different demand- and supply-side scenarios, to the consumption of “green” precipitation water infiltrated into the soil and “blue” freshwater withdrawn from rivers, lakes and reservoirs. Currently, cropland feed production accounts for 38\% of crop water consumption and grazing involves 29\% of total agricultural water consumption (9990km3yr−1). Our analysis shows that changes in diets and livestock productivity have substantial implications for future consumption of agricultural blue water (19–36\% increase compared to current levels) and green water (26–69\% increase), but they can, at best, slow down trends of rising water requirements for decades to come. However, moderate productivity reductions in highly intensive livestock systems are possible without aggravating water scarcity. Productivity gains in developing regions decrease total agricultural water consumption, but lead to expansion of irrigated agriculture, due to the shift from grassland/green water to cropland/blue water resources. While the magnitude of the livestock water footprint gives cause for concern, neither dietary choices nor changes in livestock productivity will solve the water challenge of future food supply, unless accompanied by dedicated water protection policies.}, + number = {Supplement C}, + urldate = {2017-11-01}, + journal = {Global Environmental Change}, + author = {Weindl, Isabelle and Bodirsky, Benjamin Leon and Rolinski, Susanne and Biewald, Anne and Lotze-Campen, Hermann and M\"uller, Christoph and Dietrich, Jan Philipp and Humpenöder, Florian and Stevanovic, Miodrag and Schaphoff, Sibyll and Popp, Alexander}, + month = nov, + year = {2017}, + keywords = {livestock, water scarcity, Productivity, consumptive water use, Dietary changes, Water resources}, + pages = {121--132}, } @article{weindl_livestock_2017-1, - title = {Livestock and human use of land: {Productivity} trends and dietary choices as drivers of future land and carbon dynamics}, - volume = {159}, - issn = {0921-8181}, - shorttitle = {Livestock and human use of land}, - url = {http://www.sciencedirect.com/science/article/pii/S0921818117301480}, - doi = {10.1016/j.gloplacha.2017.10.002}, - abstract = {Land use change has been the primary driving force of human alteration of terrestrial ecosystems. With 80\% of agricultural land dedicated to livestock production, the sector is an important lever to attenuate land requirements for food production and carbon emissions from land use change. In this study, we quantify impacts of changing human diets and livestock productivity on land dynamics and depletion of carbon stored in vegetation, litter and soils. Across all investigated productivity pathways, lower consumption of livestock products can substantially reduce deforestation (47–55\%) and cumulative carbon losses (34–57\%). On the supply side, already minor productivity growth in extensive livestock production systems leads to substantial CO2 emission abatement, but the emission saving potential of productivity gains in intensive systems is limited, also involving trade-offs with soil carbon stocks. If accounting for uncertainties related to future trade restrictions, crop yields and pasture productivity, the range of projected carbon savings from changing diets increases to 23–78\%. Highest abatement of carbon emissions (63–78\%) can be achieved if reduced consumption of animal-based products is combined with sustained investments into productivity increases in plant production. Our analysis emphasizes the importance to integrate demand- and supply-side oriented mitigation strategies and to combine efforts in the crop and livestock sector to enable synergies for climate protection.}, - number = {Supplement C}, - urldate = {2017-11-01}, - journal = {Global and Planetary Change}, - author = {Weindl, Isabelle and Popp, Alexander and Bodirsky, Benjamin Leon and Rolinski, Susanne and Lotze-Campen, Hermann and Biewald, Anne and Humpenöder, Florian and Dietrich, Jan Philipp and Stevanovic, Miodrag}, - month = dec, - year = {2017}, - keywords = {land use, Deforestation, Greenhouse gas mitigation, Livestock productivity, Diets, Carbon emissions}, - pages = {1--10}, - file = {ScienceDirect Snapshot:D\:\\Dissertation\\Bibliographie\\storage\\TBGT6HB2\\S0921818117301480.html:text/html;Weindl et al_2017_Livestock and human use of land.pdf:D\:\\Dissertation\\Bibliographie\\storage\\BJ5UJEN6\\Weindl et al_2017_Livestock and human use of land.pdf:application/pdf} + title = {Livestock and human use of land: {Productivity} trends and dietary choices as drivers of future land and carbon dynamics}, + volume = {159}, + issn = {0921-8181}, + shorttitle = {Livestock and human use of land}, + url = {http://www.sciencedirect.com/science/article/pii/S0921818117301480}, + doi = {10.1016/j.gloplacha.2017.10.002}, + abstract = {Land use change has been the primary driving force of human alteration of terrestrial ecosystems. With 80\% of agricultural land dedicated to livestock production, the sector is an important lever to attenuate land requirements for food production and carbon emissions from land use change. In this study, we quantify impacts of changing human diets and livestock productivity on land dynamics and depletion of carbon stored in vegetation, litter and soils. Across all investigated productivity pathways, lower consumption of livestock products can substantially reduce deforestation (47–55\%) and cumulative carbon losses (34–57\%). On the supply side, already minor productivity growth in extensive livestock production systems leads to substantial CO2 emission abatement, but the emission saving potential of productivity gains in intensive systems is limited, also involving trade-offs with soil carbon stocks. If accounting for uncertainties related to future trade restrictions, crop yields and pasture productivity, the range of projected carbon savings from changing diets increases to 23–78\%. Highest abatement of carbon emissions (63–78\%) can be achieved if reduced consumption of animal-based products is combined with sustained investments into productivity increases in plant production. Our analysis emphasizes the importance to integrate demand- and supply-side oriented mitigation strategies and to combine efforts in the crop and livestock sector to enable synergies for climate protection.}, + number = {Supplement C}, + urldate = {2017-11-01}, + journal = {Global and Planetary Change}, + author = {Weindl, Isabelle and Popp, Alexander and Bodirsky, Benjamin Leon and Rolinski, Susanne and Lotze-Campen, Hermann and Biewald, Anne and Humpenöder, Florian and Dietrich, Jan Philipp and Stevanovic, Miodrag}, + month = dec, + year = {2017}, + keywords = {land use, Deforestation, Greenhouse gas mitigation, Livestock productivity, Diets, Carbon emissions}, + pages = {1--10}, } @techreport{meijl_challenges_2017, - address = {Luxembourg}, - title = {Challenges of {Global} {Agriculture} in a {Climate} {Change} {Context} by 2050 - {AgCLIM}50}, - url = {https://publications.europa.eu/portal2012-portlet/html/downloadHandler.jsp?identifier=8724c378-562d-11e7-a5ca-01aa75ed71a1&format=pdf&language=en&productionSystem=cellar&part=}, - urldate = {2017-11-01}, - institution = {Publications Office of the European Union}, - author = {Meijl, Hans van and Havlik, Petr and Lotze-Campen, Hermann and Stehfest, Elke and Witzke, Peter and Perez Dominguez, Ignacio and Bodirsky, Benjamin Leon and van Dijk, Michiel and Doelman, Jonathan and Fellmann, T. and Humpenöder, Florian and Levin-Koopman, J and M\"uller, Christoph and Popp, Alexander and Tabeau, Andrzej and Valin, Hugo}, - year = {2017}, - pages = {64}, - file = {downloadHandler.pdf:D\:\\Dissertation\\Bibliographie\\storage\\KTKJZTJ5\\downloadHandler.pdf:application/pdf} + address = {Luxembourg}, + title = {Challenges of {Global} {Agriculture} in a {Climate} {Change} {Context} by 2050 - {AgCLIM}50}, + url = {https://publications.europa.eu/portal2012-portlet/html/downloadHandler.jsp?identifier=8724c378-562d-11e7-a5ca-01aa75ed71a1&format=pdf&language=en&productionSystem=cellar&part=}, + urldate = {2017-11-01}, + institution = {Publications Office of the European Union}, + author = {Meijl, Hans van and Havlik, Petr and Lotze-Campen, Hermann and Stehfest, Elke and Witzke, Peter and Perez Dominguez, Ignacio and Bodirsky, Benjamin Leon and van Dijk, Michiel and Doelman, Jonathan and Fellmann, T. and Humpenöder, Florian and Levin-Koopman, J and M\"uller, Christoph and Popp, Alexander and Tabeau, Andrzej and Valin, Hugo}, + year = {2017}, + pages = {64}, } @article{krause_global_2017, - title = {Global consequences of afforestation and bioenergy cultivation on ecosystem service indicators}, - volume = {14}, - issn = {1726-4189}, - url = {https://www.biogeosciences.net/14/4829/2017/}, - doi = {10.5194/bg-14-4829-2017}, - abstract = {Land management for carbon storage is discussed as being indispensable for climate change mitigation because of its large potential to remove carbon dioxide from the atmosphere, and to avoid further emissions from deforestation. However, the acceptance and feasibility of land-based mitigation projects depends on potential side effects on other important ecosystem functions and their services. Here, we use projections of future land use and land cover for different land-based mitigation options from two land-use models (IMAGE and MAgPIE) and evaluate their effects with a global dynamic vegetation model (LPJ-GUESS). In the land-use models, carbon removal was achieved either via growth of bioenergy crops combined with carbon capture and storage, via avoided deforestation and afforestation, or via a combination of both. We compare these scenarios to a reference scenario without land-based mitigation and analyse the LPJ-GUESS simulations with the aim of assessing synergies and trade-offs across a range of ecosystem service indicators: carbon storage, surface albedo, evapotranspiration, water runoff, crop production, nitrogen loss, and emissions of biogenic volatile organic compounds. In our mitigation simulations cumulative carbon storage by year 2099 ranged between 55 and 89 GtC. Other ecosystem service indicators were influenced heterogeneously both positively and negatively, with large variability across regions and land-use scenarios. Avoided deforestation and afforestation led to an increase in evapotranspiration and enhanced emissions of biogenic volatile organic compounds, and to a decrease in albedo, runoff, and nitrogen loss. Crop production could also decrease in the afforestation scenarios as a result of reduced crop area, especially for MAgPIE land-use patterns, if assumed increases in crop yields cannot be realized. Bioenergy-based climate change mitigation was projected to affect less area globally than in the forest expansion scenarios, and resulted in less pronounced changes in most ecosystem service indicators than forest-based mitigation, but included a possible decrease in nitrogen loss, crop production, and biogenic volatile organic compounds emissions.}, - number = {21}, - urldate = {2017-11-03}, - journal = {Biogeosciences}, - author = {Krause, A. and Pugh, T. A. M. and Bayer, A. D. and Doelman, J. C. and Humpenöder, F. and Anthoni, P. and Olin, S. and Bodirsky, B. L. and Popp, A. and Stehfest, E. and Arneth, A.}, - month = nov, - year = {2017}, - pages = {4829--4850}, - file = {Krause et al_2017_Global consequences of afforestation and bioenergy cultivation on ecosystem.pdf:D\:\\Dissertation\\Bibliographie\\storage\\PKIRMHI8\\Krause et al_2017_Global consequences of afforestation and bioenergy cultivation on ecosystem.pdf:application/pdf} -} - -@article{humpenoder_large-scale_2017, - title = {Large-scale bioenergy production: {How} to resolve sustainability trade-offs?}, - issn = {1748-9326}, - shorttitle = {Large-scale bioenergy production}, - url = {http://iopscience.iop.org/10.1088/1748-9326/aa9e3b}, - doi = {10.1088/1748-9326/aa9e3b}, - abstract = {Abstract Large-scale 2nd generation bioenergy deployment is a key element of 1.5°C and 2°C transformation pathways. However, large-scale bioenergy production might have negative sustainability implications and thus may conflict with the Sustainable Development Goal (SDG) agenda. Here, we carry out a multi-criteria sustainability assessment of large-scale bioenergy crop production throughout the 21st century (300 EJ in 2100) using a global land-use model. Our analysis indicates that large-scale bioenergy production without complementary measures results in negative effects on the following sustainability indicators: deforestation, CO2 emissions from land-use change, nitrogen losses, unsustainable water withdrawals and food prices. One of our main findings is that single-sector environmental protection measures next to large-scale bioenergy production are prone to involve trade-offs among these sustainability indicators - at least in the absence of more efficient land or water resource use. For instance, if bioenergy production is accompanied by forest protection, deforestation and associated emissions (SDGs 13 and 15) decline substantially whereas food prices (SDG 2) increase. However, our study also shows that this trade-off strongly depends on the development of future food demand. In contrast to environmental protection measures, we find that agricultural intensification lowers some side-effects of bioenergy production substantially (SDGs 13 and 15) without generating new trade-offs - at least among the sustainability indicators considered here. Moreover, our results indicate that a combination of forest and water protection schemes, improved fertilization efficiency, and agricultural intensification would reduce side-effects of bioenergy production most comprehensively. However, although our study includes more sustainability indicators than previous studies on bioenergy side-effects, our study represent only a small subset of all indicators relevant for the SDG agenda. Based on that we argue that the development of policies for regulating externalities of large-scale bioenergy production should rely on broad sustainability assessments to discover potential trade-offs with the SDG agenda before implementation.}, - language = {en}, - urldate = {2017-11-30}, - journal = {Environmental Research Letters}, - author = {Humpenöder, Florian and Popp, Alexander and Bodirsky, Benjamin Leon and Weindl, Isabelle and Biewald, Anne and Lotze-Campen, Hermann and Dietrich, Jan Philipp and Klein, David and Kreidenweis, Ulrich and M\"uller, Christoph and Rolinski, Susanne and Stevanovic, Miodrag}, - year = {2017}, - file = {IOP Full Text PDF:D\:\\Dissertation\\Bibliographie\\storage\\9I32Q6UT\\Humpenöder et al. - 2017 - Large-scale bioenergy production How to resolve s.pdf:application/pdf} + title = {Global consequences of afforestation and bioenergy cultivation on ecosystem service indicators}, + volume = {14}, + issn = {1726-4189}, + url = {https://www.biogeosciences.net/14/4829/2017/}, + doi = {10.5194/bg-14-4829-2017}, + abstract = {Land management for carbon storage is discussed as being indispensable for climate change mitigation because of its large potential to remove carbon dioxide from the atmosphere, and to avoid further emissions from deforestation. However, the acceptance and feasibility of land-based mitigation projects depends on potential side effects on other important ecosystem functions and their services. Here, we use projections of future land use and land cover for different land-based mitigation options from two land-use models (IMAGE and MAgPIE) and evaluate their effects with a global dynamic vegetation model (LPJ-GUESS). In the land-use models, carbon removal was achieved either via growth of bioenergy crops combined with carbon capture and storage, via avoided deforestation and afforestation, or via a combination of both. We compare these scenarios to a reference scenario without land-based mitigation and analyse the LPJ-GUESS simulations with the aim of assessing synergies and trade-offs across a range of ecosystem service indicators: carbon storage, surface albedo, evapotranspiration, water runoff, crop production, nitrogen loss, and emissions of biogenic volatile organic compounds. In our mitigation simulations cumulative carbon storage by year 2099 ranged between 55 and 89 GtC. Other ecosystem service indicators were influenced heterogeneously both positively and negatively, with large variability across regions and land-use scenarios. Avoided deforestation and afforestation led to an increase in evapotranspiration and enhanced emissions of biogenic volatile organic compounds, and to a decrease in albedo, runoff, and nitrogen loss. Crop production could also decrease in the afforestation scenarios as a result of reduced crop area, especially for MAgPIE land-use patterns, if assumed increases in crop yields cannot be realized. Bioenergy-based climate change mitigation was projected to affect less area globally than in the forest expansion scenarios, and resulted in less pronounced changes in most ecosystem service indicators than forest-based mitigation, but included a possible decrease in nitrogen loss, crop production, and biogenic volatile organic compounds emissions.}, + number = {21}, + urldate = {2017-11-03}, + journal = {Biogeosciences}, + author = {Krause, A. and Pugh, T. A. M. and Bayer, A. D. and Doelman, J. C. and Humpenöder, F. and Anthoni, P. and Olin, S. and Bodirsky, B. L. and Popp, A. and Stehfest, E. and Arneth, A.}, + month = nov, + year = {2017}, + pages = {4829--4850}, +} + +@article{humpenoeder_bioenergy_2018, + title = {Large-scale bioenergy production: how to resolve sustainability trade-offs?}, + volume = {13}, + copyright = {All rights reserved}, + issn = {1748-9326}, + shorttitle = {Large-scale bioenergy production}, + url = {http://stacks.iop.org/1748-9326/13/i=2/a=024011}, + doi = {10.1088/1748-9326/aa9e3b}, + abstract = {Large-scale 2nd generation bioenergy deployment is a key element of 1.5 °C and 2 °C transformation pathways. However, large-scale bioenergy production might have negative sustainability implications and thus may conflict with the Sustainable Development Goal (SDG) agenda. Here, we carry out a multi-criteria sustainability assessment of large-scale bioenergy crop production throughout the 21st century (300 EJ in 2100) using a global land-use model. Our analysis indicates that large-scale bioenergy production without complementary measures results in negative effects on the following sustainability indicators: deforestation, CO 2 emissions from land-use change, nitrogen losses, unsustainable water withdrawals and food prices. One of our main findings is that single-sector environmental protection measures next to large-scale bioenergy production are prone to involve trade-offs among these sustainability indicators—at least in the absence of more efficient land or water resource use. For instance, if bioenergy production is accompanied by forest protection, deforestation and associated emissions (SDGs 13 and 15) decline substantially whereas food prices (SDG 2) increase. However, our study also shows that this trade-off strongly depends on the development of future food demand. In contrast to environmental protection measures, we find that agricultural intensification lowers some side-effects of bioenergy production substantially (SDGs 13 and 15) without generating new trade-offs—at least among the sustainability indicators considered here. Moreover, our results indicate that a combination of forest and water protection schemes, improved fertilization efficiency, and agricultural intensification would reduce the side-effects of bioenergy production most comprehensively. However, although our study includes more sustainability indicators than previous studies on bioenergy side-effects, our study represents only a small subset of all indicators relevant for the SDG agenda. Based on this, we argue that the development of policies for regulating externalities of large-scale bioenergy production should rely on broad sustainability assessments to discover potential trade-offs with the SDG agenda before implementation.}, + language = {en}, + number = {2}, + urldate = {2018-02-01}, + journal = {Environmental Research Letters}, + author = {Humpenöder, Florian and Popp, Alexander and Bodirsky, Benjamin Leon and Weindl, Isabelle and Biewald, Anne and {Hermann Lotze-Campen} and Dietrich, Jan Philipp and Klein, David and Kreidenweis, Ulrich and Müller, Christoph and {Susanne Rolinski} and Stevanovic, Miodrag}, + year = {2018}, + pages = {024011}, +} + +@article{humpenoder_peatland_2020, + title = {Peatland protection and restoration are key for climate change mitigation}, + volume = {15}, + copyright = {All rights reserved}, + issn = {1748-9326}, + url = {https://doi.org/10.1088%2F1748-9326%2Fabae2a}, + doi = {10.1088/1748-9326/abae2a}, + abstract = {Peatlands cover only about 3\% the global land area, but store about twice as much carbon as global forest biomass. If intact peatlands are drained for agriculture or other human uses, peat oxidation can result in considerable CO2 emissions and other greenhouse gases (GHG) for decades or even centuries. Despite their importance, emissions from degraded peatlands have so far not been included explicitly in mitigation pathways compatible with the Paris Agreement. Such pathways include land-demanding mitigation options like bioenergy or afforestation with substantial consequences for the land system. Therefore, besides GHG emissions owing to the historic conversion of intact peatlands, the increased demand for land in current mitigation pathways could result in drainage of presently intact peatlands, e.g. for bioenergy production. Here, we present the first quantitative model-based projections of future peatland dynamics and associated GHG emissions in the context of a 2 °C mitigation pathway. Our spatially explicit land-use modelling approach with global coverage simultaneously accounts for future food demand, based on population and income projections, and land-based mitigation measures. Without dedicated peatland policy and even in the case of peatland protection, our results indicate that the land system would remain a net source of CO2 throughout the 21st century. This result is in contrast to the outcome of current mitigation pathways, in which the land system turns into a net carbon sink by 2100. However, our results indicate that it is possible to reconcile land use and GHG emissions in mitigation pathways through a peatland protection and restoration policy. According to our results, the land system would turn into a global net carbon sink by 2100, as projected by current mitigation pathways, if about 60\% of present-day degraded peatlands would be rewetted in the coming decades, next to the protection of intact peatlands.}, + language = {en}, + number = {10}, + urldate = {2020-10-12}, + journal = {Environmental Research Letters}, + author = {Humpenöder, Florian and Karstens, Kristine and Lotze-Campen, Hermann and Leifeld, Jens and Menichetti, Lorenzo and Barthelmes, Alexandra and Popp, Alexander}, + month = oct, + year = {2020}, + note = {Publisher: IOP Publishing}, + pages = {104093}, +} + + +@article{leifeld_2018, + title = {The underappreciated potential of peatlands in global climate change mitigation strategies}, + volume = {9}, + copyright = {2018 The Author(s)}, + issn = {2041-1723}, + url = {https://www.nature.com/articles/s41467-018-03406-6}, + doi = {10.1038/s41467-018-03406-6}, + abstract = {Human activity, such as draining and mining of peatlands, is transforming these long-term carbon sinks into sources. Here, the authors assess current and future greenhouse gas (GHG) emissions from degrading peatlands and estimate the magnitude of potential GHG savings that could be achieved by restoring them.}, + language = {en}, + number = {1}, + urldate = {2018-05-11}, + journal = {Nature Communications}, + author = {Leifeld, J. and Menichetti, L.}, + month = mar, + year = {2018}, + pages = {1071}, +} + + +@book{IPCC_wetland_2013, + address = {Switzerland}, + title = {2013 {Supplement} to the 2006 {IPCC} {Guidelines} for {National} {Greenhouse} {Gas} {Inventories}: {Wetlands}}, + url = {http://www.ipcc-nggip.iges.or.jp/public/wetlands/}, + publisher = {IPCC}, + editor = {Hiraishi, T and Krug, T and Tanabe, K and Srivastava, N and Baasansuren, J and Fukuda, M and Troxler, T.G.}, + year = {2014}, } @article{valin_fooddemand_2013, - title = {The future of food demand: understanding differences in global economic models}, - issn = {1574-0862}, - shorttitle = {The future of food demand}, - url = {https://onlinelibrary.wiley.com/doi/pdf/10.1111/agec.12089}, - doi = {10.1111/agec.12089}, - abstract = {Understanding the capacity of agricultural systems to feed the world population under climate change requires projecting future food demand. This article reviews demand modeling approaches from 10 global economic models participating in the Agricultural Model Intercomparison and Improvement Project (AgMIP). We compare food demand projections in 2050 for various regions and agricultural products under harmonized scenarios of socioeconomic development, climate change, and bioenergy expansion. In the reference scenario (SSP2), food demand increases by 59–98% between 2005 and 2050, slightly higher than the most recent FAO projection of 54% from 2005/2007. The range of results is large, in particular for animal calories (between 61% and 144%), caused by differences in demand systems specifications, and in income and price elasticities. The results are more sensitive to socioeconomic assumptions than to climate change or bioenergy scenarios. When considering a world with higher population and lower economic growth (SSP3), consumption per capita drops on average by 9% for crops and 18% for livestock. The maximum effect of climate change on calorie availability is −6% at the global level, and the effect of biofuel production on calorie availability is even smaller.}, - language = {en}, - urldate = {2018-04-09}, - journal = {Agricultural Economics}, - author = {Valin, Hugo and Sands, Ronald D. and van der Mensbrugghe, Dominique and Nelson, Gerald C. and Ahammad, Helal and Blanc, Elodie and Bodirsky, Benjamin and Fujimori, Shinichiro and Hasegawa, Tomoko and Havlik, Petr and Heyhoe, Edwina and Kyle, Page and Mason-D'Croz, Daniel and Paltsev, Sergey and Rolinski, Susanne and Tabeau, Andrzej and van Meijl, Hans and von Lampe, Martin and Willenbockel, Dirk}, - year = {2013}, - volume = {45}, - number = {1}, - pages = {51-67}, - keywords = {World food demand, Socioeconomic pathways, Climate change, Computable general equilibrium, Partial equilibrium, C63, C68, Q11, Q54}, - file = {} + title = {The future of food demand: understanding differences in global economic models}, + issn = {1574-0862}, + shorttitle = {The future of food demand}, + url = {https://onlinelibrary.wiley.com/doi/pdf/10.1111/agec.12089}, + doi = {10.1111/agec.12089}, + abstract = {Understanding the capacity of agricultural systems to feed the world population under climate change requires projecting future food demand. This article reviews demand modeling approaches from 10 global economic models participating in the Agricultural Model Intercomparison and Improvement Project (AgMIP). We compare food demand projections in 2050 for various regions and agricultural products under harmonized scenarios of socioeconomic development, climate change, and bioenergy expansion. In the reference scenario (SSP2), food demand increases by 59–98% between 2005 and 2050, slightly higher than the most recent FAO projection of 54% from 2005/2007. The range of results is large, in particular for animal calories (between 61% and 144%), caused by differences in demand systems specifications, and in income and price elasticities. The results are more sensitive to socioeconomic assumptions than to climate change or bioenergy scenarios. When considering a world with higher population and lower economic growth (SSP3), consumption per capita drops on average by 9% for crops and 18% for livestock. The maximum effect of climate change on calorie availability is −6% at the global level, and the effect of biofuel production on calorie availability is even smaller.}, + language = {en}, + urldate = {2018-04-09}, + journal = {Agricultural Economics}, + author = {Valin, Hugo and Sands, Ronald D. and van der Mensbrugghe, Dominique and Nelson, Gerald C. and Ahammad, Helal and Blanc, Elodie and Bodirsky, Benjamin and Fujimori, Shinichiro and Hasegawa, Tomoko and Havlik, Petr and Heyhoe, Edwina and Kyle, Page and Mason-D'Croz, Daniel and Paltsev, Sergey and Rolinski, Susanne and Tabeau, Andrzej and van Meijl, Hans and von Lampe, Martin and Willenbockel, Dirk}, + year = {2013}, + volume = {45}, + number = {1}, + pages = {51-67}, + keywords = {World food demand, Socioeconomic pathways, Climate change, Computable general equilibrium, Partial equilibrium, C63, C68, Q11, Q54}, } @techreport{nelson_transport_2008, - address = {Luxembourg}, - title = {Travel time to major cities: A global map of Accessibility}, - url = {http://forobs.jrc.ec.europa.eu/products/gam/index.php}, - urldate = {2018-09-04}, - doi = {10.2788/95835}, - isbn = {978-92-79-09771-3}, - institution = {Office for Official Publications of the European Communities}, - author = {Nelson, A}, - year = {2008} + address = {Luxembourg}, + title = {Travel time to major cities: A global map of Accessibility}, + url = {http://forobs.jrc.ec.europa.eu/products/gam/index.php}, + urldate = {2018-09-04}, + doi = {10.2788/95835}, + isbn = {978-92-79-09771-3}, + institution = {Office for Official Publications of the European Communities}, + author = {Nelson, A}, + year = {2008} } @article{mueller_projecting_2014, - title = {Projecting future crop productivity for global economic modeling.}, - journal = {Agricultural Economics}, - volume = {45}, - number = {1}, - pages = {37-50}, - author = {M\"uller, C., and Robertson, R. D.}, - year = {2014} + title = {Projecting future crop productivity for global economic modeling.}, + journal = {Agricultural Economics}, + volume = {45}, + number = {1}, + pages = {37-50}, + author = {M\"uller, C., and Robertson, R. D.}, + year = {2014} } - -@article{hurtt_harmonization_inprep, - title = {Harmonization of global land-use change and management for the period 850-2100}, - author = {Hurtt, G., L. Chini, R. Sahajpal, S. Frolking, et al.}, - journal = {Geoscientific Model Development} +@article{hurtt2018luh2, + title = {LUH2: Harmonization of global land-use scenarios for the period 850-2100}, + author = {Hurtt, George C and Chini, Louise P and Sahajpal, Ritvik and Frolking, Steve E and Bodirsky, Benjamin and Calvin, Katherine V and Doelman, Jonathan C and Fisk, Justin and Fujimori, Shinichiro and Goldewijk, Kees and et al.}, + journal = {AGUFM}, + volume = {2018}, + pages = {GC13A--01}, + year = {2018} } @article{biemans_water_2011, - author = {H. Biemans and I. Haddeland and P. Kabat and F. Ludwig and R. W. A. Hutjes and J. Heinke and W. von Bloh and D. Gerten}, - title = {Impact of reservoirs on river discharge and irrigation water supply during the 20th century}, - journal = {Water Resources Research}, - volume = {47}, - number = {3}, - pages = {}, - issn = {1944-7973}, - keywords = {global water resources, irrigation, reservoirs, human impacts}, - doi = {10.1029/2009WR008929}, - url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2009WR008929}, - urldate = {2018-14-04}, - eprint = {https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2009WR008929}, - abstract = {This paper presents a quantitative estimation of the impact of reservoirs on discharge and irrigation water supply during the 20th century at global, continental, and river basin scale. Compared to a natural situation the combined effect of reservoir operation and irrigation extractions decreased mean annual discharge to oceans and significantly changed the timing of this discharge. For example, in Europe, May discharge decreased by 10\%, while in February it increased by 8\%. At the end of the 20th century, reservoir operations and irrigation extractions decreased annual global discharge by about 2.1\% (930 km3 yr−1). Simulation results show that reservoirs contribute significantly to irrigation water supply in many regions. Basins that rely heavily on reservoir water are the Colorado and Columbia River basins in the United States and several large basins in India, China, and central Asia (e.g., in the Krishna and Huang He basins, reservoirs more than doubled surface water supply). Continents gaining the most are North America, Africa, and Asia, where reservoirs supplied 57, 22, and 360 km3 yr−1 respectively between 1981–2000, which is in all cases 40\% more than the availability in the situation without reservoirs. Globally, the irrigation water supply from reservoirs increased from around 18 km3 yr−1 (adding 5\% to surface water supply) at the beginning of the 20th century to 460 km3 yr−1 (adding almost 40\% to surface water supply) at the end of the 20th century. The analysis is performed using a newly developed and validated reservoir operation scheme within a global‐scale hydrology and vegetation model (LPJmL).}, - year = {2011}, + author = {H. Biemans and I. Haddeland and P. Kabat and F. Ludwig and R. W. A. Hutjes and J. Heinke and W. von Bloh and D. Gerten}, + title = {Impact of reservoirs on river discharge and irrigation water supply during the 20th century}, + journal = {Water Resources Research}, + volume = {47}, + number = {3}, + pages = {}, + issn = {1944-7973}, + keywords = {global water resources, irrigation, reservoirs, human impacts}, + doi = {10.1029/2009WR008929}, + url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2009WR008929}, + urldate = {2018-14-04}, + eprint = {https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2009WR008929}, + abstract = {This paper presents a quantitative estimation of the impact of reservoirs on discharge and irrigation water supply during the 20th century at global, continental, and river basin scale. Compared to a natural situation the combined effect of reservoir operation and irrigation extractions decreased mean annual discharge to oceans and significantly changed the timing of this discharge. For example, in Europe, May discharge decreased by 10\%, while in February it increased by 8\%. At the end of the 20th century, reservoir operations and irrigation extractions decreased annual global discharge by about 2.1\% (930 km3 yr−1). Simulation results show that reservoirs contribute significantly to irrigation water supply in many regions. Basins that rely heavily on reservoir water are the Colorado and Columbia River basins in the United States and several large basins in India, China, and central Asia (e.g., in the Krishna and Huang He basins, reservoirs more than doubled surface water supply). Continents gaining the most are North America, Africa, and Asia, where reservoirs supplied 57, 22, and 360 km3 yr−1 respectively between 1981–2000, which is in all cases 40\% more than the availability in the situation without reservoirs. Globally, the irrigation water supply from reservoirs increased from around 18 km3 yr−1 (adding 5\% to surface water supply) at the beginning of the 20th century to 460 km3 yr−1 (adding almost 40\% to surface water supply) at the end of the 20th century. The analysis is performed using a newly developed and validated reservoir operation scheme within a global‐scale hydrology and vegetation model (LPJmL).}, + year = {2011}, } @article{bondeau_lpjml_2007, - author = {Alberte Bondeau and Pascalle C. Smith and Sönke Zaehle And Sibyll Schaphoff and Wolfgang Lucht and Wolfgang Cramer and Dieter Gerten and Hermann Lotze-Campen and Christoph M\"uller and Markus Reichstein and Benjamin Smith}, - title = {Modelling the role of agriculture for the 20th century global terrestrial carbon balance}, - journal = {Global Change Biology}, - volume = {13}, - number = {3}, - pages = {679-706}, - issn = {1365-2486}, - keywords = {agriculture, crop functional type, global biogeochemistry}, - doi = {10.1111/j.1365-2486.2006.01305.x}, - url = {https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1365-2486.2006.01305.x}, - urldate = {2018-14-04}, - eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1365-2486.2006.01305.x}, - abstract = {Abstract In order to better assess the role of agriculture within the global climate‐vegetation system, we present a model of the managed planetary land surface, Lund–Potsdam–Jena managed Land (LPJmL), which simulates biophysical and biogeochemical processes as well as productivity and yield of the most important crops worldwide, using a concept of crop functional types (CFTs). Based on the LPJ‐Dynamic Global Vegetation Model, LPJmL simulates the transient changes in carbon and water cycles due to land use, the specific phenology and seasonal CO2 fluxes of agricultural‐dominated areas, and the production of crops and grazing land. It uses 13 CFTs (11 arable crops and two managed grass types), with specific parameterizations of phenology connected to leaf area development. Carbon is allocated daily towards four carbon pools, one being the yield-bearing storage organs. Management (irrigation, treatment of residues, intercropping) can be considered in order to capture their effect on productivity, on soil organic carbon and on carbon extracted from the ecosystem. For transient simulations for the 20th century, a global historical land use data set was developed, providing the annual cover fraction of the 13 CFTs, rain‐fed and/or irrigated, within 0.5° grid cells for the period 1901–2000, using published data on land use, crop distributions and irrigated areas. Several key results are compared with observations. The simulated spatial distribution of sowing dates for temperate cereals is comparable with the reported crop calendars. The simulated seasonal canopy development agrees better with satellite observations when actual cropland distribution is taken into account. Simulated yields for temperate cereals and maize compare well with FAO statistics. Monthly carbon fluxes measured at three agricultural sites also compare well with simulations. Global simulations indicate a ∼24\% (respectively ∼10\%) reduction in global vegetation (respectively soil) carbon due to agriculture, and 6–9 Pg C of yearly harvested biomass in the 1990s. In contrast to simulations of the potential natural vegetation showing the land biosphere to be an increasing carbon sink during the 20th century, LPJmL simulates a net carbon source until the 1970s (due to land use), and a small sink (mostly due to changing climate and CO2) after 1970. This is comparable with earlier LPJ simulations using a more simple land use scheme, and within the uncertainty range of estimates in the 1980s and 1990s. The fluxes attributed to land use change compare well with Houghton's estimates on the land use related fluxes until the 1970s, but then they begin to diverge, probably due to the different rates of deforestation considered. The simulated impacts of agriculture on the global water cycle for the 1990s are∼5\% (respectively∼20\%) reduction in transpiration (respectively interception), and∼44\% increase in evaporation. Global runoff, which includes a simple irrigation scheme, is practically not affected.}, - year = {2007}, + author = {Alberte Bondeau and Pascalle C. Smith and Sönke Zaehle And Sibyll Schaphoff and Wolfgang Lucht and Wolfgang Cramer and Dieter Gerten and Hermann Lotze-Campen and Christoph M\"uller and Markus Reichstein and Benjamin Smith}, + title = {Modelling the role of agriculture for the 20th century global terrestrial carbon balance}, + journal = {Global Change Biology}, + volume = {13}, + number = {3}, + pages = {679-706}, + issn = {1365-2486}, + keywords = {agriculture, crop functional type, global biogeochemistry}, + doi = {10.1111/j.1365-2486.2006.01305.x}, + url = {https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1365-2486.2006.01305.x}, + urldate = {2018-14-04}, + eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1365-2486.2006.01305.x}, + abstract = {Abstract In order to better assess the role of agriculture within the global climate‐vegetation system, we present a model of the managed planetary land surface, Lund–Potsdam–Jena managed Land (LPJmL), which simulates biophysical and biogeochemical processes as well as productivity and yield of the most important crops worldwide, using a concept of crop functional types (CFTs). Based on the LPJ‐Dynamic Global Vegetation Model, LPJmL simulates the transient changes in carbon and water cycles due to land use, the specific phenology and seasonal CO2 fluxes of agricultural‐dominated areas, and the production of crops and grazing land. It uses 13 CFTs (11 arable crops and two managed grass types), with specific parameterizations of phenology connected to leaf area development. Carbon is allocated daily towards four carbon pools, one being the yield-bearing storage organs. Management (irrigation, treatment of residues, intercropping) can be considered in order to capture their effect on productivity, on soil organic carbon and on carbon extracted from the ecosystem. For transient simulations for the 20th century, a global historical land use data set was developed, providing the annual cover fraction of the 13 CFTs, rain‐fed and/or irrigated, within 0.5° grid cells for the period 1901–2000, using published data on land use, crop distributions and irrigated areas. Several key results are compared with observations. The simulated spatial distribution of sowing dates for temperate cereals is comparable with the reported crop calendars. The simulated seasonal canopy development agrees better with satellite observations when actual cropland distribution is taken into account. Simulated yields for temperate cereals and maize compare well with FAO statistics. Monthly carbon fluxes measured at three agricultural sites also compare well with simulations. Global simulations indicate a ∼24\% (respectively ∼10\%) reduction in global vegetation (respectively soil) carbon due to agriculture, and 6–9 Pg C of yearly harvested biomass in the 1990s. In contrast to simulations of the potential natural vegetation showing the land biosphere to be an increasing carbon sink during the 20th century, LPJmL simulates a net carbon source until the 1970s (due to land use), and a small sink (mostly due to changing climate and CO2) after 1970. This is comparable with earlier LPJ simulations using a more simple land use scheme, and within the uncertainty range of estimates in the 1980s and 1990s. The fluxes attributed to land use change compare well with Houghton's estimates on the land use related fluxes until the 1970s, but then they begin to diverge, probably due to the different rates of deforestation considered. The simulated impacts of agriculture on the global water cycle for the 1990s are∼5\% (respectively∼20\%) reduction in transpiration (respectively interception), and∼44\% increase in evaporation. Global runoff, which includes a simple irrigation scheme, is practically not affected.}, + year = {2007}, } @book{narayanan_gtap7_2008, - author = {Narayanan, G. Badri and Walmsley,Terrie L., Eds.}, - title = {Global Trade, Assistance, and Production: The GTAP 7 Data Base}, - publisher = {Center for Global Trade Analysis, Purdue University}, - url = {http://www.gtap.agecon.purdue.edu/databases/v7/v7_doco.asp}, - urldate = {2018-24-04}, - year = {2008}, + author = {Narayanan, G. Badri and Walmsley,Terrie L., Eds.}, + title = {Global Trade, Assistance, and Production: The GTAP 7 Data Base}, + publisher = {Center for Global Trade Analysis, Purdue University}, + url = {http://www.gtap.agecon.purdue.edu/databases/v7/v7_doco.asp}, + urldate = {2018-24-04}, + year = {2008}, } @article{siebert_FAO_2007, - author = {Stefan Siebert and Petra Döll and Sebastian Feick and Jippe Hoogeveen and Karen Frenken}, - title = {Global Map of Irrigation Areas version 4.0.1.}, - journal = {Johann Wolfgang Goethe University, Frankfurt am Main, Germany / Food and Agriculture Organization of the United Nations, Rome, Italy.}, - url = {http://www.fao.org/nr/water/aquastat/irrigationmap/index10.stm}, - year = {2007}, + author = {Stefan Siebert and Petra Döll and Sebastian Feick and Jippe Hoogeveen and Karen Frenken}, + title = {Global Map of Irrigation Areas version 4.0.1.}, + journal = {Johann Wolfgang Goethe University, Frankfurt am Main, Germany / Food and Agriculture Organization of the United Nations, Rome, Italy.}, + url = {http://www.fao.org/nr/water/aquastat/irrigationmap/index10.stm}, + year = {2007}, +} + +@article{siebert_FAO_2007, + author = {Stefan Siebert and Petra Döll and Sebastian Feick and Jippe Hoogeveen and Karen Frenken}, + year = {2007}, + title = {Global Map of Irrigation Areas version 4.0.1.}, + journal = {Johann Wolfgang Goethe University, Frankfurt am Main, Germany / Food and Agriculture Organization of the United Nations, Rome, Italy.}, + url = {http://www.fao.org/nr/water/aquastat/irrigationmap/index10.stm}, +} + +@article{siebert_FAO_2013, + author = {Stefan Siebert, Verena Henrich, Karen Frenken and Jacob Burk}, + year = {2013}, + title = {Global Map of Irrigation Areas version 5}, + journal = {Rheinische Friedrich-Wilhelms-University, Bonn, Germany / Food and Agriculture Organization of the United Nations, Rome, Italy}, + url = {https://data.apps.fao.org/catalog/iso/f79213a0-88fd-11da-a88f-000d939bc5d8}, +} + +@article{meier_global_2018, + author = {Meier, Jonas; Zabel, Florian; Mauser, Wolfram}, + year = {2018}, + title = {Global Irrigated Areas dataset}, + journal = {PANGAEA}, + doi = {https://doi.org/10.1594/PANGAEA.884744}, + url = {https://doi.pangaea.de/10.1594/PANGAEA.884744}, +} + +@article{mehta_half_2024, + author = {Mehta, P., Siebert, S., Kummu, M. et al.}, + year = {2024}, + title = {Half of twenty-first century global irrigation expansion has been in water-stressed regions}, + journal = {Nature Water}, + doi = {https://doi.org/10.1038/s44221-024-00206-9}, +} + +@book{fao_aquastat_2016, + address = {Rome}, + title = {{AQUASTAT} core database}, + publisher = {Food and Agriculture Organization of the United Nations (FAO)}, + author = {{FAO}}, + url = {{https://data.harvestportal.org/de/dataset/fao-aquastat/resource/c4668555-eb76-4882-83b1-230038e24f02?inner_span=True}}, + year = {2016}, + note = {Database accessed on 2023/02/06}, } @techreport{worldbank_irrigation_1995, - title = {World Bank and Irrigation}, - institution = {World Bank}, - author = {William I. Jones}, - year = {1995}, - address = {Washington, D.C.}, + title = {World Bank and Irrigation}, + institution = {World Bank}, + author = {William I. Jones}, + year = {1995}, + address = {Washington, D.C.}, } @techreport{PIK_report104_2007, - title = {DEVELOPMENT OF FUNCTIONAL IRRIGATION TYPES FOR IMPROVED GLOBAL CROP MODELLING}, - institution = {PIK}, - author = {Janine Rohwer and Dieter Gerten and Wolfgang Lucht}, - year = {2007}, - address = {Potsdam}, + title = {DEVELOPMENT OF FUNCTIONAL IRRIGATION TYPES FOR IMPROVED GLOBAL CROP MODELLING}, + institution = {PIK}, + author = {Janine Rohwer and Dieter Gerten and Wolfgang Lucht}, + year = {2007}, + address = {Potsdam}, } @book{smakhtin_water_2004, - author = {Smakhtin, V. and C. Revenga and P. Döll and et al}, - title = {Taking into Account Environmental Water Requirements in Global-scale Water Resources Assessments}, - year = {2004}, + author = {Smakhtin, V. and C. Revenga and P. Döll and et al}, + title = {Taking into Account Environmental Water Requirements in Global-scale Water Resources Assessments}, + year = {2004}, } -@article{watergap_water_2003, - title = {Development and Testing of the WaterGAP 2 Global Model of Water Use and Availability}, - author = {Alcamo, J. and P. DÖLL and T. Henrichs and et al.}, - journal = {Hydrological Sciences Journal}, - volume = {48}, - number = {3}, - pages = {317–337}, - year = {2003}, +@article{wada_modeling_2016, + title = {Modeling global water use for the 21st century: the Water Futures and Solutions (WFaS) initiative and its approaches}, + author = {Wada, Y. and Flörke, M. and Hanasaki, N. et al.}, + journal = {Geosci. Model Dev.}, + volume = {9}, + pages = {175-222}, + year = {2016}, } @article{rubel_observed_2010, - title = {Observed and projected climate shifts 1901-2100 depicted by world maps of the {Köppen}-{Geiger} climate classification}, - issn = {,}, - url = {https://www.schweizerbart.de/papers/metz/detail/19/74932/Observed_and_projected_climate_shifts_1901_2100_de?af=crossref}, - doi = {10.1127/0941-2948/2010/0430}, - language = {en}, - urldate = {2018-05-22}, - journal = {Meteorologische Zeitschrift}, - author = {Rubel, Franz and Kottek, Markus}, - month = apr, - year = {2010}, - pages = {135--141}, - file = {Snapshot:D\:\\Dropbox\\zotero\\storage\\LAUHZEGW\\Observed_and_projected_climate_shifts_1901_2100_de.html:text/html} + title = {Observed and projected climate shifts 1901-2100 depicted by world maps of the {Köppen}-{Geiger} climate classification}, + issn = {,}, + url = {https://www.schweizerbart.de/papers/metz/detail/19/74932/Observed_and_projected_climate_shifts_1901_2100_de?af=crossref}, + doi = {10.1127/0941-2948/2010/0430}, + language = {en}, + urldate = {2018-05-22}, + journal = {Meteorologische Zeitschrift}, + author = {Rubel, Franz and Kottek, Markus}, + month = apr, + year = {2010}, + pages = {135--141}, } @phdthesis{wirsenius_human_2000, - type = {Doctoral thesis}, - title = {Human {Use} of {Land} and {Organic} {Materials}: {Modeling} the {Turnover} of {Biomass} in the {Global} {Food} {System}}, - shorttitle = {Human {Use} of {Land} and {Organic} {Materials}}, - url = {http://publications.lib.chalmers.se/publication/827-human-use-of-land-and-organic-materials-modeling-the-turnover-of-biomass-in-the-global-food-system}, - abstract = {This thesis is directed towards the issue of the long-term demand and supply of biomass for food, energy and materials. In the coming decades, the global requirements for biomass for such services are likely to increase substantially. Therefore, improved knowledge of options for mitigating the long-term production requirements and the associated effects on the Earth system is essential. {\textless}p /{\textgreater}The thesis gives a thorough survey of the current flows of biomass in the food system. This survey was carried out by means of a physical model which was developed as part of the work. For eight world regions, the model is used to calculate the necessary production of crops and other phytomass from a prescribed end-use of food, efficiency in food production and processing, as well as use of by-products and residues. The model includes all major categories of phytomass used in the food system, depicts all flows and processes on a mass and energy balance basis, and contains detailed descriptions of the production and use of all major by-products and residues generated within the system. {\textless}p /{\textgreater}The global appropriation of terrestrial phytomass production induced by the food system was estimated to some 13 Pg dry matter per year in 1992-94. Of this phytomass, about 0.97 Pg, or 7.5 percent, ended up as food commodities eaten. Animal food systems accounted for roughly two-thirds of the total appropriation of phytomass, whereas their contribution to the human diet was about one-tenth. Use of by-products and residues as feed, and for other purposes within the food system, was estimated to about 1.8 Pg dry matter, or 14 percent of the total phytomass appropriation. {\textless}p /{\textgreater}The results also show large differences in efficiency for animal food systems, between regions as well as between separate commodities. The feed conversion efficiencies of cattle meat systems were estimated to about 2 percent in industrial regions, and around 0.5 percent in most non-industrial regions (on gross energy basis). For pig and poultry systems, feed conversion efficiencies were roughly a factor of ten higher. The differences suggest that there is a substantial scope for mitigating the long-term production demand for crops and other phytomass by increases in efficiency and changes in dietary preferences.}, - language = {English}, - urldate = {2014-09-08}, - school = {Chalmers University of Technology}, - author = {Wirsenius, Stefan}, - year = {2000}, - keywords = {livestock, Diet, efficiency, biomass, Feed, global food system, industrial ecology, physical model}, + type = {Doctoral thesis}, + title = {Human {Use} of {Land} and {Organic} {Materials}: {Modeling} the {Turnover} of {Biomass} in the {Global} {Food} {System}}, + shorttitle = {Human {Use} of {Land} and {Organic} {Materials}}, + url = {http://publications.lib.chalmers.se/publication/827-human-use-of-land-and-organic-materials-modeling-the-turnover-of-biomass-in-the-global-food-system}, + abstract = {This thesis is directed towards the issue of the long-term demand and supply of biomass for food, energy and materials. In the coming decades, the global requirements for biomass for such services are likely to increase substantially. Therefore, improved knowledge of options for mitigating the long-term production requirements and the associated effects on the Earth system is essential. {\textless}p /{\textgreater}The thesis gives a thorough survey of the current flows of biomass in the food system. This survey was carried out by means of a physical model which was developed as part of the work. For eight world regions, the model is used to calculate the necessary production of crops and other phytomass from a prescribed end-use of food, efficiency in food production and processing, as well as use of by-products and residues. The model includes all major categories of phytomass used in the food system, depicts all flows and processes on a mass and energy balance basis, and contains detailed descriptions of the production and use of all major by-products and residues generated within the system. {\textless}p /{\textgreater}The global appropriation of terrestrial phytomass production induced by the food system was estimated to some 13 Pg dry matter per year in 1992-94. Of this phytomass, about 0.97 Pg, or 7.5 percent, ended up as food commodities eaten. Animal food systems accounted for roughly two-thirds of the total appropriation of phytomass, whereas their contribution to the human diet was about one-tenth. Use of by-products and residues as feed, and for other purposes within the food system, was estimated to about 1.8 Pg dry matter, or 14 percent of the total phytomass appropriation. {\textless}p /{\textgreater}The results also show large differences in efficiency for animal food systems, between regions as well as between separate commodities. The feed conversion efficiencies of cattle meat systems were estimated to about 2 percent in industrial regions, and around 0.5 percent in most non-industrial regions (on gross energy basis). For pig and poultry systems, feed conversion efficiencies were roughly a factor of ten higher. The differences suggest that there is a substantial scope for mitigating the long-term production demand for crops and other phytomass by increases in efficiency and changes in dietary preferences.}, + language = {English}, + urldate = {2014-09-08}, + school = {Chalmers University of Technology}, + author = {Wirsenius, Stefan}, + year = {2000}, + keywords = {livestock, Diet, efficiency, biomass, Feed, global food system, industrial ecology, physical model}, } @techreport{ipcc_2006_2006, - address = {IGES, Japan}, - title = {2006 {IPCC} {Guidelines} for {National} {Greenhouse} {Gas} {Inventories}}, - institution = {National Greenhouse Gas Inventories Programme}, - author = {IPCC}, - editor = {Eggleston, H.S. and Buendia, L. and Miwa, K. and Ngara, T. and Tanabe, K.}, - year = {2006} + address = {IGES, Japan}, + title = {2006 {IPCC} {Guidelines} for {National} {Greenhouse} {Gas} {Inventories}}, + institution = {National Greenhouse Gas Inventories Programme}, + author = {IPCC}, + editor = {Eggleston, H.S. and Buendia, L. and Miwa, K. and Ngara, T. and Tanabe, K.}, + year = {2006} } +@misc{calvo_buendia_ipcc_2019, + title = {{{IPCC}} 2019, 2019 {{Refinement}} to the 2006 {{IPCC Guidelines}} for {{National Greenhouse Gas Inventories}},}, + publisher = {Published: IPCC, Switzerland}, + year = {2019}, + editor = {E. {Calvo Buendia} and K. Tanabe and A. Kranjc and J. Baasansuren and M. Fukuda and S. Ngarize and A.Osako and Y. Pyrozhenko and P. Shermanau and S. Federici (eds)}, +} @article{lal_world_2005, - title = {World crop residues production and implications of its use as a biofuel}, - volume = {31}, - issn = {0160-4120}, - doi = {10.1016/j.envint.2004.09.005}, - abstract = {Reducing and off-setting anthropogenic emissions of CO(2) and other greenhouse gases (GHGs) are important strategies of mitigating the greenhouse effect. Thus, the need for developing carbon (C) neutral and renewable sources of energy is more than ever before. Use of crop residue as a possible source of feedstock for bioenergy production must be critically and objectively assessed because of its positive impact on soil C sequestration, soil quality maintenance and ecosystem functions. The amount of crop residue produced in the US is estimated at 367x10(6) Mg/year for 9 cereal crops, 450x10(6) Mg/year for 14 cereals and legumes, and 488x10(6) Mg/year for 21 crops. The amount of crop residue produced in the world is estimated at 2802x10(6) Mg/year for cereal crops, 3107x10(6) Mg/year for 17 cereals and legumes, and 3758x10(6) Mg/year for 27 food crops. The fuel value of the total annual residue produced is estimated at 1.5x10(15) kcal, about 1 billion barrels (bbl) of diesel equivalent, or about 8 quads for the US; and 11.3x10(15) kcal, about 7.5 billion bbl of diesel or 60 quads for the world. However, even a partial removal (30-40\%) of crop residue from land can exacerbate soil erosion hazard, deplete the SOC pool, accentuate emission of CO(2) and other GHGs from soil to the atmosphere, and exacerbate the risks of global climate change. Therefore, establishing bioenergy plantations of site-specific species with potential of producing 10-15 Mg biomass/year is an option that needs to be considered. This option will require 40-60 million hectares of land in the US and about 250 million hectares worldwide to establish bioenergy plantations.}, - language = {eng}, - number = {4}, - journal = {Environment International}, - author = {Lal, R.}, - month = may, - year = {2005}, - pmid = {15788197}, - keywords = {Agriculture, Bioelectric Energy Sources, Biomass, Carbon, Ecosystem, Greenhouse Effect, Plants, Edible, Refuse Disposal, Soil}, - pages = {575--584} + title = {World crop residues production and implications of its use as a biofuel}, + volume = {31}, + issn = {0160-4120}, + doi = {10.1016/j.envint.2004.09.005}, + abstract = {Reducing and off-setting anthropogenic emissions of CO(2) and other greenhouse gases (GHGs) are important strategies of mitigating the greenhouse effect. Thus, the need for developing carbon (C) neutral and renewable sources of energy is more than ever before. Use of crop residue as a possible source of feedstock for bioenergy production must be critically and objectively assessed because of its positive impact on soil C sequestration, soil quality maintenance and ecosystem functions. The amount of crop residue produced in the US is estimated at 367x10(6) Mg/year for 9 cereal crops, 450x10(6) Mg/year for 14 cereals and legumes, and 488x10(6) Mg/year for 21 crops. The amount of crop residue produced in the world is estimated at 2802x10(6) Mg/year for cereal crops, 3107x10(6) Mg/year for 17 cereals and legumes, and 3758x10(6) Mg/year for 27 food crops. The fuel value of the total annual residue produced is estimated at 1.5x10(15) kcal, about 1 billion barrels (bbl) of diesel equivalent, or about 8 quads for the US; and 11.3x10(15) kcal, about 7.5 billion bbl of diesel or 60 quads for the world. However, even a partial removal (30-40\%) of crop residue from land can exacerbate soil erosion hazard, deplete the SOC pool, accentuate emission of CO(2) and other GHGs from soil to the atmosphere, and exacerbate the risks of global climate change. Therefore, establishing bioenergy plantations of site-specific species with potential of producing 10-15 Mg biomass/year is an option that needs to be considered. This option will require 40-60 million hectares of land in the US and about 250 million hectares worldwide to establish bioenergy plantations.}, + language = {eng}, + number = {4}, + journal = {Environment International}, + author = {Lal, R.}, + month = may, + year = {2005}, + pmid = {15788197}, + keywords = {Agriculture, Bioelectric Energy Sources, Biomass, Carbon, Ecosystem, Greenhouse Effect, Plants, Edible, Refuse Disposal, Soil}, + pages = {575--584} } @article{feller_dungung_2007, - title = {D\"ungung im {Freilandgem\"usebau}}, - language = {de}, - journal = {Schriftenreihe des Leibniz- Instituts f\"ur Gem\"use- und Zierpflanzenbau (IGZ)}, - author = {Feller, C. and Fink, M. and Laber, H. and Maync, A. and Paschold, P. and Scharpf, H. and Sclaghecken, J. and Strohmeyer, K. and Weier, U. and Ziegler, J.}, - year = {2007}, - pages = {265} + title = {D\"ungung im {Freilandgem\"usebau}}, + language = {de}, + journal = {Schriftenreihe des Leibniz- Instituts f\"ur Gem\"use- und Zierpflanzenbau (IGZ)}, + author = {Feller, C. and Fink, M. and Laber, H. and Maync, A. and Paschold, P. and Scharpf, H. and Sclaghecken, J. and Strohmeyer, K. and Weier, U. and Ziegler, J.}, + year = {2007}, + pages = {265} } @article{smil_nitrogen_1999, - title = {Nitrogen in crop production: {An} account of global flows}, - volume = {13}, - copyright = {Copyright 1999 by the American Geophysical Union.}, - issn = {1944-9224}, - shorttitle = {Nitrogen in crop production}, - url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/1999GB900015}, - doi = {10.1029/1999GB900015}, - abstract = {Human activities have roughly doubled the amount of reactive N that enters the element's biospheric cycle. Crop production is by far the single largest cause of this anthropogenic alteration. Inorganic fertilizers now provide 80 Tg N yr−1 (Tg = 1012 g), managed (symbiotic) biofixation adds about 20 Tg N yr−1, and between 28 and 36 Tg N yr−1 are recycled in organic wastes. Anthropogenic inputs (including N in seeds and irrigation water) now supply about 85\% of 170 (151–186) Tg N reaching the world's cropland every year. About half of this input, 85 Tg N yr−1, is taken up by harvested crops and their residues. Quantification of N losses from crop fields is beset by major uncertainties. Losses to the atmosphere (denitrification and volatilization) amount to 26–60 Tg N yr−1, while waters receive (from leaching and erosion) 32–45 Tg N yr−1. These N losses are the major reason behind the growing concerns about the enrichment of the biosphere with reactive N. The best evidence suggests that in spite of some significant local and regional losses, the world's agricultural land accumulates N. The addition of 3–4 billion people before the year 2050 will require further substantial increases of N input in cropping, but a large share of this demand can come from improved efficiency of N fertilizer use.}, - language = {en}, - number = {2}, - urldate = {2018-07-09}, - journal = {Global Biogeochemical Cycles}, - author = {Smil, Vaclav}, - year = {1999}, - pages = {647--662}, - file = {Full Text PDF:D\:\\Dropbox\\zotero\\storage\\9JDJDVQY\\Smil - Nitrogen in crop production An account of global .pdf:application/pdf;Snapshot:D\:\\Dropbox\\zotero\\storage\\D75AZCTW\\1999GB900015.html:text/html} + title = {Nitrogen in crop production: {An} account of global flows}, + volume = {13}, + copyright = {Copyright 1999 by the American Geophysical Union.}, + issn = {1944-9224}, + shorttitle = {Nitrogen in crop production}, + url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/1999GB900015}, + doi = {10.1029/1999GB900015}, + abstract = {Human activities have roughly doubled the amount of reactive N that enters the element's biospheric cycle. Crop production is by far the single largest cause of this anthropogenic alteration. Inorganic fertilizers now provide 80 Tg N yr−1 (Tg = 1012 g), managed (symbiotic) biofixation adds about 20 Tg N yr−1, and between 28 and 36 Tg N yr−1 are recycled in organic wastes. Anthropogenic inputs (including N in seeds and irrigation water) now supply about 85\% of 170 (151–186) Tg N reaching the world's cropland every year. About half of this input, 85 Tg N yr−1, is taken up by harvested crops and their residues. Quantification of N losses from crop fields is beset by major uncertainties. Losses to the atmosphere (denitrification and volatilization) amount to 26–60 Tg N yr−1, while waters receive (from leaching and erosion) 32–45 Tg N yr−1. These N losses are the major reason behind the growing concerns about the enrichment of the biosphere with reactive N. The best evidence suggests that in spite of some significant local and regional losses, the world's agricultural land accumulates N. The addition of 3–4 billion people before the year 2050 will require further substantial increases of N input in cropping, but a large share of this demand can come from improved efficiency of N fertilizer use.}, + language = {en}, + number = {2}, + urldate = {2018-07-09}, + journal = {Global Biogeochemical Cycles}, + author = {Smil, Vaclav}, + year = {1999}, + pages = {647--662}, } @article{sathaye_ghg_2005, - title = {{GHG} {Mitigation} {Potential}, {Costs} and {Benefits} in {Global} {Forests}: {A} {Dynamic} {Partial} {Equilibrium} {Approach}}, - shorttitle = {{GHG} {Mitigation} {Potential}, {Costs} and {Benefits} in {Global} {Forests}}, - url = {http://escholarship.org/uc/item/92d5m16v}, - abstract = {This paper reports on the global potential for carbon sequestration in forest plantations, and the reduction of carbon emissions from deforestation, in response to six carbon price scenarios from 2000 to 2100. These carbon price scenarios cover a range typically seen in global integrated assessment models. The world forest sector was disaggregated into ten regions, four largely temperate, developed regions: the European Union, Oceania, Russia, and the United States; and six developing, mostly tropical, regions: Africa, Central America, China, India, Rest of Asia, and South America. Three mitigation options -- long- and short-rotation forestry, and the reduction of deforestation -- were analyzed using a global dynamic partial equilibrium model (GCOMAP). Key findings of this work are that cumulative carbon gain ranges from 50.9 to 113.2 Gt C by 2100, higher carbon prices early lead to earlier carbon gain and vice versa, and avoided deforestation accounts for 51 to 78 percent of modeled carbon gains by 2100. The estimated present value of cumulative welfare change in the sector ranges from a decline of \$158 billion to a gain of \$81 billion by 2100. The decline is associated with a decrease in deforestation.}, - urldate = {2013-03-06}, - journal = {Lawrence Berkeley National Laboratory}, - author = {Sathaye, Jayant and Makundi, Willy and Dale, Larry and Chan, Peter and Andrasko, Kenneth}, - month = mar, - year = {2005}, - keywords = {Environmental Energy Technologies, GCOMAP GHG mitigation global forests partial equilibrium model}, - file = {Sathaye et al. - 2005 - GHG Mitigation Potential, Costs and Benefits in Gl.pdf:/Users/flo/Zotero/storage/C4F4DAWA/Sathaye et al. - 2005 - GHG Mitigation Potential, Costs and Benefits in Gl.pdf:application/pdf} + title = {{GHG} {Mitigation} {Potential}, {Costs} and {Benefits} in {Global} {Forests}: {A} {Dynamic} {Partial} {Equilibrium} {Approach}}, + shorttitle = {{GHG} {Mitigation} {Potential}, {Costs} and {Benefits} in {Global} {Forests}}, + url = {http://escholarship.org/uc/item/92d5m16v}, + abstract = {This paper reports on the global potential for carbon sequestration in forest plantations, and the reduction of carbon emissions from deforestation, in response to six carbon price scenarios from 2000 to 2100. These carbon price scenarios cover a range typically seen in global integrated assessment models. The world forest sector was disaggregated into ten regions, four largely temperate, developed regions: the European Union, Oceania, Russia, and the United States; and six developing, mostly tropical, regions: Africa, Central America, China, India, Rest of Asia, and South America. Three mitigation options -- long- and short-rotation forestry, and the reduction of deforestation -- were analyzed using a global dynamic partial equilibrium model (GCOMAP). Key findings of this work are that cumulative carbon gain ranges from 50.9 to 113.2 Gt C by 2100, higher carbon prices early lead to earlier carbon gain and vice versa, and avoided deforestation accounts for 51 to 78 percent of modeled carbon gains by 2100. The estimated present value of cumulative welfare change in the sector ranges from a decline of \$158 billion to a gain of \$81 billion by 2100. The decline is associated with a decrease in deforestation.}, + urldate = {2013-03-06}, + journal = {Lawrence Berkeley National Laboratory}, + author = {Sathaye, Jayant and Makundi, Willy and Dale, Larry and Chan, Peter and Andrasko, Kenneth}, + month = mar, + year = {2005}, + keywords = {Environmental Energy Technologies, GCOMAP GHG mitigation global forests partial equilibrium model}, } @article{robinson_mapping_2014, - title = {Mapping the {Global} {Distribution} of {Livestock}}, - volume = {9}, - issn = {1932-6203}, - url = {http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0096084}, - doi = {10.1371/journal.pone.0096084}, - number = {5}, - urldate = {2017-09-15}, - journal = {PLOS ONE}, - author = {Robinson, Timothy P. and Wint, G. R. William and Conchedda, Giulia and Boeckel, Thomas P. Van and Ercoli, Valentina and Palamara, Elisa and Cinardi, Giuseppina and D'Aietti, Laura and Hay, Simon I. and Gilbert, Marius}, - month = may, - year = {2014}, - keywords = {Chicken models, Chickens, Ducks, Ecosystems, Forecasting, Livestock, Statistical distributions, Swine}, - pages = {e96084}, - file = {Full Text PDF:C\:\\Users\\karstens\\AppData\\Roaming\\Zotero\\Zotero\\Profiles\\tudvyaev.default\\zotero\\storage\\FDQX9TVH\\Robinson et al. - 2014 - Mapping the Global Distribution of Livestock.pdf:application/pdf;Snapshot:C\:\\Users\\karstens\\AppData\\Roaming\\Zotero\\Zotero\\Profiles\\tudvyaev.default\\zotero\\storage\\79AQ7K3G\\article.html:text/html} + title = {Mapping the {Global} {Distribution} of {Livestock}}, + volume = {9}, + issn = {1932-6203}, + url = {http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0096084}, + doi = {10.1371/journal.pone.0096084}, + number = {5}, + urldate = {2017-09-15}, + journal = {PLOS ONE}, + author = {Robinson, Timothy P. and Wint, G. R. William and Conchedda, Giulia and Boeckel, Thomas P. Van and Ercoli, Valentina and Palamara, Elisa and Cinardi, Giuseppina and D'Aietti, Laura and Hay, Simon I. and Gilbert, Marius}, + month = may, + year = {2014}, + keywords = {Chicken models, Chickens, Ducks, Ecosystems, Forecasting, Livestock, Statistical distributions, Swine}, + pages = {e96084}, } @article{pikaar_decoupling_2018, - title = {Decoupling livestock from land use through industrial feed production pathways}, - volume = {52}, + title = {Decoupling livestock from land use through industrial feed production pathways}, + volume = {52}, number= {13}, - journal = {Environmental Science and Technology}, - author = {Pikaar, I. and Matassa, S. and Bodirsky, B. L. and Weindl, I. and Humpenöder, F. and Rabaey, K. and Boon, N. and Bruschi, M. and Yuan, Z. and Van Zanten, H. and Herrero, M. and Verstraete, W. and Popp, A.}, + journal = {Environmental Science and Technology}, + author = {Pikaar, I. and Matassa, S. and Bodirsky, B. L. and Weindl, I. and Humpenöder, F. and Rabaey, K. and Boon, N. and Bruschi, M. and Yuan, Z. and Van Zanten, H. and Herrero, M. and Verstraete, W. and Popp, A.}, month = {july}, year = {2018}, - pages = {7351--7359}, + pages = {7351--7359}, doi = {10.1021/acs.est.8b00216}, } @techreport{valco_thecost_2016, - title = {The Cost of Ginning Cotton - 2016 Survey Results}, - institution = {National Cotton Ginners Association}, - author = {Valco, T. D. and Ashley, H. and Findley, D. S. and Green, J. K. and Isom, R. A. and Price, T. L.}, + title = {The Cost of Ginning Cotton - 2016 Survey Results}, + institution = {National Cotton Ginners Association}, + author = {Valco, T. D. and Ashley, H. and Findley, D. S. and Green, J. K. and Isom, R. A. and Price, T. L.}, year = {2016}, } @techreport{adanacioglu_profitability_2011, - title = {Profitability and Efficiency in the Cotton Ginning Industry: A Case Study from the Aegean Region of Turkey}, - institution = {custoseagronegocioonline}, - author = {Adanacioglu, Hakan and Olgun, F. A.}, + title = {Profitability and Efficiency in the Cotton Ginning Industry: A Case Study from the Aegean Region of Turkey}, + institution = {custoseagronegocioonline}, + author = {Adanacioglu, Hakan and Olgun, F. A.}, year = {2011}, } + +@article{braakhekke_modelling_2019, + title = {Modelling forest plantations for carbon uptake with the {LPJmL} dynamic global vegetation model}, + issn = {2190-4979}, + url = {https://www.earth-syst-dynam-discuss.net/esd-2019-13/}, + doi = {https://doi.org/10.5194/esd-2019-13}, + abstract = {{\textless}p{\textgreater}{\textless}strong{\textgreater}Abstract.{\textless}/strong{\textgreater} We present an extension of the dynamic global vegetation model LPJmL to simulate planted forests intended for C sequestration. We implemented three functional types to simulate plantation trees in temperate, tropical, and boreal climates. The parameters of these functional types were optimized to fit target growth curves (TGCs). These curves represent the evolution of stemwood C over time in typical productive plantations and were derived by combining field observations and LPJmL estimates for equivalent natural forests. While the calibrated model underestimates stemwood C growth rates compared to the TGCs, it represents substantial improvement over using natural forests to represent afforestation. Based on a simulation experiment in which we compared global natural forest versus global forest plantation, we found that forest plantations allow for much larger C uptake rates on the time scale of 100 years, with a maximum difference of a factor 1.9, around 54 years. In subsequent simulations for an ambitious but realistic scenario in which 650\ Mha (14\ \% of global managed land, 4.5\ \% of global land surface) is converted to forest over 85 years, we found that natural forests take up 37\ PgC versus 48\ PgC for forest plantations. Comparing these results to estimations of C sequestration required to achieve the 2\ \°C climate target, we conclude that afforestation can offer a substantial contribution to climate mitigation. Full evaluation of afforestation as a climate change mitigation strategy requires an integrated assessment which considers all relevant aspects, including costs, biodiversity, and trade-offs with other land-use types. Our extended version of LPJmL can contribute such an assessment by providing improved estimates of C uptake rates by forest plantations.{\textless}/p{\textgreater}}, + language = {English}, + urldate = {2019-04-16}, + journal = {Earth System Dynamics Discussions}, + author = {Braakhekke, Maarten C. and Doelman, Jonathan C. and Baas, Peter and Müller, Christoph and Schaphoff, Sibyll and Stehfest, Elke and Vuuren, Detlef P. van}, + month = apr, + year = {2019}, + pages = {1--24}, +} + +@article{lauri_timber_demand, + url = {http://dx.doi.org/10.1561/112.00000504}, + year = {2019}, + volume = {34}, + journal = {Journal of Forest Economics}, + title = {Global Woody Biomass Harvest Volumes and Forest Area Use Under Different SSP-RCP Scenarios}, + doi = {10.1561/112.00000504}, + issn = {1104-6899}, + number = {3-4}, + pages = {285-309}, + author = {Pekka Lauri and Nicklas Forsell and Mykola Gusti and Anu Korosuo and Petr Havlík and Michael Obersteiner} +} + +@article{morland2018supply, + title = {Supply and demand functions for global wood markets: specification and plausibility testing of econometric models within the global forest sector}, + author = {Morland, Christian and Schier, Franziska and Janzen, Niels and Weimar, Holger}, + journal = {Forest Policy and Economics}, + volume = {92}, + pages = {92--105}, + year = {2018}, + publisher = {Elsevier} +} + +@book{amacher2009economics, + title = {Economics of forest resources}, + author = {Amacher, Gregory S and Ollikainen, Markku and Koskela, Erkki}, + year = {2009}, + publisher = {Mit Press Cambridge} +} + +@article{Harmsen2019, + title = {Long-term marginal abatement cost curves of non-{CO2} greenhouse gases}, + volume = {99}, + issn = {1462-9011}, + url = {http://www.sciencedirect.com/science/article/pii/S146290111830889X}, + doi = {10.1016/j.envsci.2019.05.013}, + abstract = {This study presents a new comprehensive set of long-term Marginal Abatement Cost (MAC) curves of all major non-CO2 greenhouse gas emission sources. The work builds on existing short-term MAC curve datasets and recent literature on individual mitigation measures. The new MAC curves include current technology and costs information as well as estimates of technology development and removal of implementation barriers to capture long-term dynamics. Compared to earlier work, we find a higher projected maximum reduction potential (MRP) of nitrous oxide (N2O) and a lower MRP of methane (CH4). The combined MRP for all non-CO2 gases is similar but has been extended to also capture mitigation measures that can be realized at higher implementation costs. When applying the new MAC curves in a cost-optimal, integrated assessment model-based 2.6 W/m2 scenario, the total non-CO2 mitigation is projected to be 10.9 Mt CO2 equivalents in 2050 (i.e. 58\% reduction compared to baseline emissions) and 15.6 Mt CO2equivalents in 2100 (i.e. a 71\% reduction). In applying the new MAC curves, we account for inertia in thline implementation speed of mitigation measures. Although this does not strongly impact results in an optimal strategy, it means that the contribution of non-CO2 mitigation could be more limited if ambitious climate policy is delayed.}, + urldate = {2019-09-13}, + journal = {Environmental Science \& Policy}, + author = {Harmsen, J. H. M. and van Vuuren, Detlef P. and Nayak, Dali R. and Hof, Andries F. and Höglund-Isaksson, Lena and Lucas, Paul L. and Nielsen, Jens B. and Smith, Pete and Stehfest, Elke}, + month = sep, + year = {2019}, + keywords = {Climate policy, Mitigation, MAC curves, Non-CO}, + pages = {136--149}, +} + +@article{Lynch2020, + title = {Demonstrating {GWP}*: a means of reporting warming-equivalent emissions that captures the contrasting impacts of short- and long-lived climate pollutants}, + volume = {15}, + issn = {1748-9326}, + shorttitle = {Demonstrating {GWP}{\textbackslash}ast}, + url = {https://doi.org/10.1088%2F1748-9326%2Fab6d7e}, + doi = {10.1088/1748-9326/ab6d7e}, + abstract = {The atmospheric lifetime and radiative impacts of different climate pollutants can both differ markedly, so metrics that equate emissions using a single scaling factor, such as the 100-year Global Warming Potential (GWP100), can be misleading. An alternative approach is to report emissions as ‘warming-equivalents’ that result in similar warming impacts without requiring a like-for-like weighting per emission. GWP*, an alternative application of GWPs where the CO2-equivalence of short-lived climate pollutant emissions is predominantly determined by changes in their emission rate, provides a straightforward means of generating warming-equivalent emissions. In this letter we illustrate the contrasting climate impacts resulting from emissions of methane, a short-lived greenhouse gas, and CO2, and compare GWP100 and GWP* CO2-equivalents for a number of simple emissions scenarios. We demonstrate that GWP* provides a useful indication of warming, while conventional application of GWP100 falls short in many scenarios and particularly when methane emissions are stable or declining, with important implications for how we consider ‘zero emission’ or ‘climate neutral’ targets for sectors emitting different compositions of gases. We then illustrate how GWP* can provide an improved means of assessing alternative mitigation strategies. GWP* allows warming-equivalent emissions to be calculated directly from CO2-equivalent emissions reported using GWP100, consistent with the Paris Rulebook agreed by the UNFCCC, on condition that short-lived and cumulative climate pollutants are aggregated separately, which is essential for transparency. It provides a direct link between emissions and anticipated warming impacts, supporting stocktakes of progress towards a long-term temperature goal and compatible with cumulative emissions budgets.}, + language = {en}, + number = {4}, + urldate = {2020-11-20}, + journal = {Environmental Research Letters}, + author = {Lynch, John and Cain, Michelle and Pierrehumbert, Raymond and Allen, Myles}, + month = apr, + year = {2020}, + note = {Publisher: IOP Publishing}, + pages = {044023}, +} + +@article{Allen_2018, + title = {A solution to the misrepresentations of {CO2}-equivalent emissions of short-lived climate pollutants under ambitious mitigation}, + volume = {1}, + issn = {2397-3722}, + url = {http://www.nature.com/articles/s41612-018-0026-8}, + doi = {10.1038/s41612-018-0026-8}, + language = {en}, + number = {1}, + urldate = {2019-12-03}, + journal = {npj Climate and Atmospheric Science}, + author = {Allen, Myles R. and Shine, Keith P. and Fuglestvedt, Jan S. and Millar, Richard J. and Cain, Michelle and Frame, David J. and Macey, Adrian H.}, + month = dec, + year = {2018}, + pages = {16}, +} + +@article{oswalt2019forest, + title = {Forest resources of the United States, 2017: A technical document supporting the Forest Service 2020 RPA Assessment}, + author = {Oswalt, Sonja N and Smith, W Brad and Miles, Patrick D and Pugh, Scott A}, + journal = {Gen. Tech. Rep. WO-97. Washington, DC: US Department of Agriculture, Forest Service, Washington Office.}, + volume = {97}, + year = {2019} +} + +@article{pokharel2017factors, + title = {Factors affecting utilization of woody residues for bioenergy production in the southern United States}, + author = {Pokharel, Raju and Grala, Robert K and Grebner, Donald L and Grado, Stephen C}, + journal = {Biomass and Bioenergy}, + volume = {105}, + pages = {278--287}, + year = {2017}, + publisher = {Elsevier} +} + +@article{poulter2018global, + title = {The global forest age dataset (GFADv1. 0)}, + author = {Poulter, Benjamin and Arag{\~a}o, Luiz and Adela, N and Bellassen, Valentin and Ciais, Philippe and Kato, Tomomichi and Lin, Xin and Nachin, Baatarbileg and Luyssaert, Sebastiaan and Pederson, Niel and others}, + year = {2018}, + publisher = {NASA National Aeronautics and Space Administration, PANGAEA} +} + +@misc{poulter_global_2019, + title = {The global forest age dataset and its uncertainties (GFADv1.1)}, + copyright = {info:eu-repo/semantics/openAccess}, + url = {https://doi.pangaea.de/10.1594/PANGAEA.897392}, + doi = {10.1594/PANGAEA.897392}, + urldate = {2024-10-27}, + publisher = {PANGAEA}, + author = {Poulter, Benjamin and Aragão, Luiz and Andela, Niels and Bellassen, Valentin and Ciais, Philippe and Kato, Tomomichi and Lin, Xin and Nachin, Baatarbileg and Luyssaert, Sebastiaan and Pederson, Niel and Peylin, Philippe and Piao, Shilong and Pugh, Tom and Saatchi, Sassan and Schepaschenko, Dmitry and Schelhaas, Martjan and Shivdenko, Anatoly}, + year = {2019}, + note = {Publication Title: NASA National Aeronautics and Space Administration}, + keywords = {age class, GFAD, Poulter}, +} + +@article{zabel_global_2014, + title = {Global {{Agricultural Land Resources}} \textendash{} {{A High Resolution Suitability Evaluation}} and {{Its Perspectives}} until 2100 under {{Climate Change Conditions}}}, + author = {Zabel, Florian and Putzenlechner, Birgitta and Mauser, Wolfram}, + year = {2014}, + month = sep, + volume = {9}, + pages = {e107522}, + publisher = {{Public Library of Science}}, + issn = {1932-6203}, + doi = {10.1371/journal.pone.0107522}, + abstract = {Changing natural conditions determine the land's suitability for agriculture. The growing demand for food, feed, fiber and bioenergy increases pressure on land and causes trade-offs between different uses of land and ecosystem services. Accordingly, an inventory is required on the changing potentially suitable areas for agriculture under changing climate conditions. We applied a fuzzy logic approach to compute global agricultural suitability to grow the 16 most important food and energy crops according to the climatic, soil and topographic conditions at a spatial resolution of 30 arc seconds. We present our results for current climate conditions (1981\textendash 2010), considering today's irrigated areas and separately investigate the suitability of densely forested as well as protected areas, in order to investigate their potentials for agriculture. The impact of climate change under SRES A1B conditions, as simulated by the global climate model ECHAM5, on agricultural suitability is shown by comparing the time-period 2071\textendash 2100 with 1981\textendash 2010. Our results show that climate change will expand suitable cropland by additionally 5.6 million km2, particularly in the Northern high latitudes (mainly in Canada, China and Russia). Most sensitive regions with decreasing suitability are found in the Global South, mainly in tropical regions, where also the suitability for multiple cropping decreases.}, + journal = {PLOS ONE}, + keywords = {Agricultural irrigation,Agricultural land,Agricultural soil science,Agriculture,Climate change,Conservation science,Crops,Forests}, + language = {en}, + number = {9} +} + +@article{Heinke.2013, + author = {Heinke, J. and Ostberg, S. and Schaphoff, S. and Frieler, K. and M{\"u}ller, C. and Gerten, D. and Meinshausen, M. and Lucht, W.}, + year = {2013}, + title = {A new climate dataset for systematic assessments of climate change impacts as a function of global warming}, + pages = {1689--1703}, + volume = {6}, + number = {5}, + journal = {Geoscientific Model Development}, + doi = {10.5194/gmd-6-1689-2013}, +} + +@article{KleinGoldewijk.2017, + abstract = {(Waridity)}, + author = {{Klein Goldewijk}, Kees and Beusen, Arthur and Doelman, Jonathan and Stehfest, Elke}, + year = {2017}, + title = {Anthropogenic land use estimates for the Holocene -- HYDE 3.2}, + pages = {927--953}, + volume = {9}, + number = {2}, + journal = {Earth System Science Data}, + doi = {10.5194/essd-9-927-2017}, +} + +@article{churkina2020buildings, + title = {Buildings as a global carbon sink}, + author = {Churkina, Galina and Organschi, Alan and Reyer, Christopher PO and Ruff, Andrew and Vinke, Kira and Liu, Zhu and Reck, Barbara K and Graedel, TE and Schellnhuber, Hans Joachim}, + journal = {Nature Sustainability}, + volume = {3}, + number = {4}, + pages = {269--276}, + year = {2020}, + publisher = {Nature Publishing Group} +} + +@misc{orlov_ces_2021, + title = {{CES} production function in {GAMS} with climate change impacts on labor producitivy}, + url = {https://zenodo.org/record/4983177}, + abstract = {This is a conceptual GAMS model for including climate change impacts on labor producitivy into a neoclassical Constant Elasticity of Substitution (CES) or Cobb Douglas (CD) production function.}, + urldate = {2021-06-18}, + publisher = {Zenodo}, + author = {Orlov, Anton and Humpenöder, Florian}, + month = jun, + year = {2021}, + doi = {10.5281/zenodo.4983177}, + note = {Language: eng}, + keywords = {CES production function, climate change impacts, GAMS, labor producitivy}, +} + +@article{orlov_labor_2021, + title = {Global {Economic} {Responses} to {Heat} {Stress} {Impacts} on {Worker} {Productivity} in {Crop} {Production}}, + issn = {2511-1280, 2511-1299}, + url = {https://link.springer.com/10.1007/s41885-021-00091-6}, + doi = {10.1007/s41885-021-00091-6}, + abstract = {The impacts of climate change on the food system are a key concern for societies and policy makers globally. Assessments of the biophysical impacts of crop productivity show modest but uncertain impacts. But crop growth is not the only factor that matters for the food production. Climate impacts on the labour force through increased heat stress also need to be considered. Here, we provide projections for the integrated climate-induced impacts on crop yields and worker productivity on the agro-economy in a global multisector economic model. Biophysical impacts are derived from a multi-model ensemble, which is based on a combination of climate and crop models, and the economic analysis is conducted for different socio-economic pathways. This framework allows for a comprehensive assessment of biophysical and socio-economic risks, and outlines rapid risk increases for high-warming scenarios. Considering heat effects on labour productivity, regional production costs could increase by up to 10 percentage points or more in vulnerable tropical regions such as South and South-East Asia, and Africa. Heat stress effects on labour might offset potential benefits through productivity gains due to the carbon dioxide fertilisation effect. Agricultural adaptation through increased mechanisation might allow to alleviate some of the negative heat stress effects under optimistic scenarios of socio-economic development. Our results highlight the vulnerability of the food system to climate change impacts through multiple impact channels. Overall, we find a consistently negative impact of future climate change on crop production when accounting for worker productivity next to crop yields.}, + language = {en}, + urldate = {2021-08-18}, + journal = {Economics of Disasters and Climate Change}, + author = {Orlov, Anton and Daloz, Anne Sophie and Sillmann, Jana and Thiery, Wim and Douzal, Clara and Lejeune, Quentin and Schleussner, Carl}, + month = aug, + year = {2021}, +} + +@techreport{leclere_biodiv_2018, + type = {Other}, + title = {Towards pathways bending the curve terrestrial biodiversity trends within the 21st century}, + copyright = {cc\_by\_sa\_4}, + url = {http://pure.iiasa.ac.at/id/eprint/15241/}, + abstract = {Unless actions are taken to reduce multiple anthropogenic pressures, biodiversity is expected to continue declining at an alarming rate. Models and scenarios can be used to help design the pathways to sustain a thriving nature and its ability to contribute to people. This approach has so far been hampered by the complexity associated with combining projections of pressures on, and subsequent responses from, biodiversity. Most previous assessments have projected continuous biodiversity declines and very few have identified pathways for reversing the loss of biodiversity without jeopardizing other objectives such as development or climate mitigation. The Bending The Curve initiative set out to advance quantitative modelling techniques towards ambitious scenarios for biodiversity. In this proof-of-concept analysis, we developed a modelling approach that demonstrates how global land use and biodiversity models can shed light on wedges able to bend the curve of biodiversity trends as affected by land-use change, the biggest current threat to biodiversity. In order to address the uncertainties associated with such pathways we used a multi-model framework and relied on the Shared Socioeconomic Pathway/Representative Concentration Pathway scenario framework. This report describes the details of this modelling approach.}, + language = {en}, + urldate = {2018-10-17}, + author = {Leclere, D. and Obersteiner, M. and Alkemade, R. and Almond, R. and Barrett, M. and Bunting, G. and Burgess, N. and Butchart, S. and Chaudhary, A. and Cornell, S. and De Palma, A. and DeClerck, F. and Di Fulvio, F. and Di Marco, M. and Doelman, J. and Dürauer, M. and Ferrier, S. and Freeman, R. and Fritz, S. and Fujimori, S. and Grooten, M. and Harfoot, M. and Harwood, T. and Hasegawa, T. and Havlik, P. and Hellweg, S. and Herrero, M. and Hilbers, J. and Hill, S. and Hoskins, A. and Humpenöder, F. and Kram, T. and Krisztin, T. and Lotze-Campen, H. and Mace, G. and Matsui, T. and Meyer, C. and Nel, D. and Newbold, T. and Ohashi, H. and Popp, A. and Purvis, A. and Schipper, A. and Schmidt-Traub, G. and Stehfest, E. and Strassburg, B. and Tabeau, A. and Valin, H. and van Meijl, H. and van Vuuren, D. and van Zeist, W. and Visconti, P. and Ware, C. and Watson, J. and Wu, W. and Young, L.}, + month = may, + year = {2018}, + doi = {10.22022/ESM/04-2018.15241}, +} + +@article{leclere_bending_2020, + title = {Bending the curve of terrestrial biodiversity needs an integrated strategy}, + volume = {585}, + copyright = {2020 The Author(s), under exclusive licence to Springer Nature Limited}, + issn = {1476-4687}, + url = {https://www.nature.com/articles/s41586-020-2705-y}, + doi = {10.1038/s41586-020-2705-y}, + abstract = {Increased efforts are required to prevent further losses to terrestrial biodiversity and the ecosystem services that it  provides1,2. Ambitious targets have been proposed, such as reversing the declining trends in biodiversity3; however, just feeding the growing human population will make this a challenge4. Here we use an ensemble of land-use and biodiversity models to assess whether—and how—humanity can reverse the declines in terrestrial biodiversity caused by habitat conversion, which is a major threat to biodiversity5. We show that immediate efforts, consistent with the broader sustainability agenda but of unprecedented ambition and coordination, could enable the provision of food for the growing human population while reversing the global terrestrial biodiversity trends caused by habitat conversion. If we decide to increase the extent of land under conservation management, restore degraded land and generalize landscape-level conservation planning, biodiversity trends from habitat conversion could become positive by the mid-twenty-first century on average across models (confidence interval, 2042–2061), but this was not the case for all models. Food prices could increase and, on average across models, almost half (confidence interval, 34–50\%) of the future biodiversity losses could not be avoided. However, additionally tackling the drivers of land-use change could avoid conflict with affordable food provision and reduces the environmental effects of the food-provision system. Through further sustainable intensification and trade, reduced food waste and more plant-based human diets, more than two thirds of future biodiversity losses are avoided and the biodiversity trends from habitat conversion are reversed by 2050 for almost all of the models. Although limiting further loss will remain challenging in several biodiversity-rich regions, and other threats—such as climate change—must be addressed to truly reverse the declines in biodiversity, our results show that ambitious conservation efforts and food system transformation are central to an effective post-2020 biodiversity strategy.}, + language = {en}, + number = {7826}, + urldate = {2020-10-12}, + journal = {Nature}, + author = {Leclère, David and Obersteiner, Michael and Barrett, Mike and Butchart, Stuart H. M. and Chaudhary, Abhishek and De Palma, Adriana and DeClerck, Fabrice A. J. and Di Marco, Moreno and Doelman, Jonathan C. and Dürauer, Martina and Freeman, Robin and Harfoot, Michael and Hasegawa, Tomoko and Hellweg, Stefanie and Hilbers, Jelle P. and Hill, Samantha L. L. and Humpenöder, Florian and Jennings, Nancy and Krisztin, Tamás and Mace, Georgina M. and Ohashi, Haruka and Popp, Alexander and Purvis, Andy and Schipper, Aafke M. and Tabeau, Andrzej and Valin, Hugo and van Meijl, Hans and van Zeist, Willem-Jan and Visconti, Piero and Alkemade, Rob and Almond, Rosamunde and Bunting, Gill and Burgess, Neil D. and Cornell, Sarah E. and Di Fulvio, Fulvio and Ferrier, Simon and Fritz, Steffen and Fujimori, Shinichiro and Grooten, Monique and Harwood, Thomas and Havlík, Petr and Herrero, Mario and Hoskins, Andrew J. and Jung, Martin and Kram, Tom and Lotze-Campen, Hermann and Matsui, Tetsuya and Meyer, Carsten and Nel, Deon and Newbold, Tim and Schmidt-Traub, Guido and Stehfest, Elke and Strassburg, Bernardo B. N. and van Vuuren, Detlef P. and Ware, Chris and Watson, James E. M. and Wu, Wenchao and Young, Lucy}, + month = sep, + year = {2020}, + note = {Number: 7826; Publisher: Nature Publishing Group}, + pages = {551--556}, +} + +@online{iucn_iucn_2020, + title = {The {{IUCN Red List}} of {{Threatened Species}}}, + author = {{IUCN}}, + date = {2020}, + url = {https://www.iucnredlist.org}, + urldate = {2020-11-25} +} + +@incollection{purvis_chapter_2018, + title = {Chapter {{Five}} - {{Modelling}} and {{Projecting}} the {{Response}} of {{Local Terrestrial Biodiversity Worldwide}} to {{Land Use}} and {{Related Pressures}}: {{The PREDICTS Project}}}, + shorttitle = {Chapter {{Five}} - {{Modelling}} and {{Projecting}} the {{Response}} of {{Local Terrestrial Biodiversity Worldwide}} to {{Land Use}} and {{Related Pressures}}}, + booktitle = {Advances in {{Ecological Research}}}, + author = {Purvis, Andy and Newbold, Tim and De Palma, Adriana and Contu, Sara and Hill, Samantha L. L. and Sanchez-Ortiz, Katia and Phillips, Helen R. P. and Hudson, Lawrence N. and Lysenko, Igor and Börger, Luca and Scharlemann, Jörn P. W.}, + editor = {Bohan, David A. and Dumbrell, Alex J. and Woodward, Guy and Jackson, Michelle}, + date = {2018-01-01}, + series = {Next {{Generation Biomonitoring}}: {{Part}} 1}, + volume = {58}, + pages = {201--241}, + publisher = {{Academic Press}}, + doi = {10.1016/bs.aecr.2017.12.003}, + url = {http://www.sciencedirect.com/science/article/pii/S0065250417300284}, + urldate = {2020-02-25}, + abstract = {The PREDICTS project (Projecting Responses of Ecological Diversity In Changing Terrestrial Systems) has collated ecological survey data from hundreds of published biodiversity comparisons of sites facing different land-use and related pressures, and used the resulting taxonomically and geographically broad database (abundance and occurrence data for over 50,000 species and over 30,000 sites in nearly 100 countries) to develop global biodiversity models, indicators, and projections. After outlining the science and science-policy gaps that motivated PREDICTS, this review discusses the key design decisions that helped it to achieve its objectives. In particular, we discuss basing models on a large, taxonomically, and geographically representative database, so that they may be applicable to biodiversity more broadly; space-for-time substitution, which allows estimation of pressure-state models without the need for representative time-series data; and collation of raw data rather than statistical results, greatly expanding the range of response variables that can be modelled. The heterogeneity of data in the PREDICTS database has presented a range of modelling challenges: we discuss these with a focus on our implementation of the Biodiversity Intactness Index, an indicator with considerable policy potential but which had not previously been estimated from primary biodiversity data. We then summarise the findings from analyses of how land use and related pressures affect local (α) diversity and spatial turnover (β diversity), and how these effects are mediated by ecological attributes of species. We discuss the relevance of our findings for policy, before ending with some directions of ongoing and possible future research.}, + langid = {english}, + keywords = {Alpha diversity,Beta diversity,Biodiversity indicators,Biodiversity intactness index,Biodiversity models,Hockey-stick graph,Meta-analysis,Representativeness}, +} + +@article{wilson_2016, + title = {Greenhouse gas emission factors associated with rewetting of organic soils}, + volume = {17}, + issn = {1819-754X}, + url = {http://doi.org/10.19189/MaP.2016.OMB.222}, + doi = {10.19189/MaP.2016.OMB.222}, + abstract = {Drained organic soils are a significant source of greenhouse gas (GHG) emissions to the atmosphere. Rewetting these soils may reduce GHG emissions and could also create suitable conditions for return of the carbon (C) sink function characteristic of undrained organic soils. In this article we expand on the work relating to rewetted organic soils that was carried out for the 2014 Intergovernmental Panel on Climate Change (IPCC) Wetlands Supplement. We describe the methods and scientific approach used to derive the Tier 1 emission factors (the rate of emission per unit of activity) for the full suite of GHG and waterborne C fluxes associated with rewetting of organic soils. We recorded a total of 352 GHG and waterborne annual flux data points from an extensive literature search and these were disaggregated by flux type (i.e. CO2, CH4, N2O and DOC), climate zone and nutrient status. Our results showed fundamental differences between the GHG dynamics of drained and rewetted organic soils and, based on the 100 year global warming potential of each gas, indicated that rewetting of drained organic soils leads to: net annual removals of CO2 in the majority of organic soil classes; an increase in annual CH4 emissions; a decrease in N2O and DOC losses; and a lowering of net GHG emissions. Data published since the Wetlands Supplement (n = 58) generally support our derivations. Significant data gaps exist, particularly with regard to tropical organic soils, DOC and N2O. We propose that the uncertainty associated with our derivations could be significantly reduced by the development of country specific emission factors that could in turn be disaggregated by factors such as vegetation composition, water table level, time since rewetting and previous land use history.}, + language = {en}, + number = {4}, + urldate = {2019-04-29}, + journal = {Mires and Peat}, + author = {Wilson, D. and Blain, D. and Couwenberg, J.}, + month = apr, + year = {2016}, + pages = {4 28 pp}, +} + +@article{brooks_global_2006, + title = {Global {Biodiversity} {Conservation} {Priorities}}, + volume = {313}, + url = {https://www.science.org/doi/10.1126/science.1127609}, + doi = {10.1126/science.1127609}, + number = {5783}, + urldate = {2022-05-18}, + journal = {Science}, + author = {Brooks, T. M. and Mittermeier, R. A. and da Fonseca, G. A. B. and Gerlach, J. and Hoffmann, M. and Lamoreux, J. F. and Mittermeier, C. G. and Pilgrim, J. D. and Rodrigues, A. S. L.}, + month = jul, + year = {2006}, + note = {Publisher: American Association for the Advancement of Science}, + pages = {58--61}, +} + +@article{olson_biome_2001, + title = {Terrestrial {Ecoregions} of the {World}: {A} {New} {Map} of {Life} on {Earth}: {A} new global map of terrestrial ecoregions provides an innovative tool for conserving biodiversity}, + volume = {51}, + issn = {0006-3568}, + shorttitle = {Terrestrial {Ecoregions} of the {World}}, + url = {https://doi.org/10.1641/0006-3568(2001)051[0933:TEOTWA]2.0.CO;2}, + doi = {10.1641/0006-3568(2001)051[0933:TEOTWA]2.0.CO;2}, + number = {11}, + urldate = {2022-06-02}, + journal = {BioScience}, + author = {Olson, David M. and Dinerstein, Eric and Wikramanayake, Eric D. and Burgess, Neil D. and Powell, George V. N. and Underwood, Emma C. and D'amico, Jennifer A. and Itoua, Illanga and Strand, Holly E. and Morrison, John C. and Loucks, Colby J. and Allnutt, Thomas F. and Ricketts, Taylor H. and Kura, Yumiko and Lamoreux, John F. and Wettengel, Wesley W. and Hedao, Prashant and Kassem, Kenneth R.}, + month = nov, + year = {2001}, + pages = {933--938}, +} + + +@article{tiemeyer_peatland_2020, + title = {A new methodology for organic soils in national greenhouse gas inventories: {Data} synthesis, derivation and application}, + volume = {109}, + issn = {1470160X}, + shorttitle = {A new methodology for organic soils in national greenhouse gas inventories}, + url = {https://linkinghub.elsevier.com/retrieve/pii/S1470160X19308325}, + doi = {10.1016/j.ecolind.2019.105838}, + abstract = {Drained organic soils are large sources of anthropogenic greenhouse gases (GHG) in many European and Asian countries. Therefore, these soils urgently need to be considered and adequately accounted for when attempting to decrease emissions from the Agriculture and Land Use, Land Use Change and Forestry (LULUCF) sectors. Here, we describe the methodology, data and results of the German approach for measurement, reporting and verification (MRV) of anthropogenic GHG emissions from drained organic soils and outline ways forward towards tracking drainage and rewetting. The methodology was developed for and is currently applied in the German GHG inventory under the United Nations Framework Convention on Climate Change (UNFCCC) and the Kyoto Protocol.}, + language = {en}, + urldate = {2023-06-19}, + journal = {Ecological Indicators}, + author = {Tiemeyer, Bärbel and Freibauer, Annette and Borraz, Elisa Albiac and Augustin, Jürgen and Bechtold, Michel and Beetz, Sascha and Beyer, Colja and Ebli, Martin and Eickenscheidt, Tim and Fiedler, Sabine and Förster, Christoph and Gensior, Andreas and Giebels, Michael and Glatzel, Stephan and Heinichen, Jan and Hoffmann, Mathias and Höper, Heinrich and Jurasinski, Gerald and Laggner, Andreas and Leiber-Sauheitl, Katharina and Peichl-Brak, Mandy and Drösler, Matthias}, + month = feb, + year = {2020}, + pages = {105838}, +} + + +@article{humpenoeder_overcoming_2022, + title = {Overcoming global inequality is critical for land-based mitigation in line with the {Paris} {Agreement}}, + volume = {13}, + copyright = {2022 The Author(s)}, + issn = {2041-1723}, + url = {https://www.nature.com/articles/s41467-022-35114-7}, + doi = {10.1038/s41467-022-35114-7}, + abstract = {Transformation pathways for the land sector in line with the Paris Agreement depend on the assumption of globally implemented greenhouse gas (GHG) emission pricing, and in some cases also on inclusive socio-economic development and sustainable land-use practices. In such pathways, the majority of GHG emission reductions in the land system is expected to come from low- and middle-income countries, which currently account for a large share of emissions from agriculture, forestry and other land use (AFOLU). However, in low- and middle-income countries the economic, financial and institutional barriers for such transformative changes are high. Here, we show that if sustainable development in the land sector remained highly unequal and limited to high-income countries only, global AFOLU emissions would remain substantial throughout the 21st century. Our model-based projections highlight that overcoming global inequality is critical for land-based mitigation in line with the Paris Agreement. While also a scenario purely based on either global GHG emission pricing or on inclusive socio-economic development would achieve the stringent emissions reductions required, only the latter ensures major co-benefits for other Sustainable Development Goals, especially in low- and middle-income regions.}, + language = {en}, + number = {1}, + urldate = {2022-12-02}, + journal = {Nature Communications}, + author = {Humpenöder, Florian and Popp, Alexander and Schleussner, Carl-Friedrich and Orlov, Anton and Windisch, Michael Gregory and Menke, Inga and Pongratz, Julia and Havermann, Felix and Thiery, Wim and Luo, Fei and v. Jeetze, Patrick and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Weindl, Isabelle and Lejeune, Quentin}, + month = dec, + year = {2022}, + note = {Number: 1 +Publisher: Nature Publishing Group}, + keywords = {Sustainability, Climate-change policy, Climate-change mitigation, Socioeconomic scenarios}, + pages = {7453}, +} + + +@article{mishra_forestry_2021, + title = {Estimating global land system impacts of timber plantations using {MAgPIE} 4.3.5}, + volume = {14}, + copyright = {All rights reserved}, + issn = {1991-959X}, + url = {https://gmd.copernicus.org/articles/14/6467/2021/}, + doi = {10.5194/gmd-14-6467-2021}, + abstract = {{\textless}p{\textgreater}{\textless}strong class="journal-contentHeaderColor"{\textgreater}Abstract.{\textless}/strong{\textgreater} Out of 1150 {\textless}span class="inline-formula"{\textgreater}Mha{\textless}/span{\textgreater} (million hectares) of forest designated primarily for production purposes in 2020, plantations accounted for 11 \% (131 {\textless}span class="inline-formula"{\textgreater}Mha{\textless}/span{\textgreater}) of this area and fulfilled more than 33 \% of the global industrial roundwood demand. However, adding additional timber plantations to meet increasing timber demand intensifies competition for scarce land resources between different land uses such as food, feed, livestock and timber production. Despite the significance of plantations with respect to roundwood production, their importance in meeting the long-term timber demand and the implications of plantation expansion for overall land-use dynamics have not been studied in detail, in particular regarding the competition for land between agriculture and forestry in existing land-use models.{\textless}/p{\textgreater} {\textless}p{\textgreater}This paper describes the extension of the modular, open-source land system Model of Agricultural Production and its Impact on the Environment (MAgPIE) using a detailed representation of forest land, timber production and timber demand dynamics. These extensions allow for a better understanding of the land-use dynamics (including competition for land) and the associated land-use change emissions of timber production.{\textless}/p{\textgreater} {\textless}p{\textgreater}We show that the spatial cropland patterns differ when timber production is accounted for, indicating that timber plantations compete with cropland for the same scarce land resources. When plantations are established on cropland, it causes cropland expansion and deforestation elsewhere. Using the exogenous extrapolation of historical roundwood production from plantations, future timber demand and plantation rotation lengths, we model the future spatial expansion of forest plantations. As a result of increasing timber demand, we show a 177 \% increase in plantation area by the end of the century ({\textless}span class="inline-formula"{\textgreater}+{\textless}/span{\textgreater}171 {\textless}span class="inline-formula"{\textgreater}Mha{\textless}/span{\textgreater} in 1995–2100). We also observe (in our model results) that the increasing demand for timber amplifies the scarcity of land, which is indicated by shifting agricultural land-use patterns and increasing yields from cropland compared with a case without forestry. Through the inclusion of new forest plantation and natural forest dynamics, our estimates of land-related {\textless}span class="inline-formula"{\textgreater}CO$_{\textrm{2}}${\textless}/span{\textgreater} emissions better match with observed data, in particular the gross land-use change emissions and carbon uptake (via regrowth), reflecting higher deforestation with the expansion of managed land and timber production as well as higher regrowth in natural forests and plantations.{\textless}/p{\textgreater}}, + language = {English}, + number = {10}, + urldate = {2021-10-27}, + journal = {Geoscientific Model Development}, + author = {Mishra, Abhijeet and Humpenöder, Florian and Dietrich, Jan Philipp and Bodirsky, Benjamin Leon and Sohngen, Brent and P. O. Reyer, Christopher and Lotze-Campen, Hermann and Popp, Alexander}, + month = oct, + year = {2021}, + note = {Publisher: Copernicus GmbH}, + pages = {6467--6494}, +} + + +@article{mishra_timbercities_2022, + title = {Land use change and carbon emissions of a transformation to timber cities}, + volume = {13}, + copyright = {2022 The Author(s)}, + issn = {2041-1723}, + url = {https://www.nature.com/articles/s41467-022-32244-w}, + doi = {10.1038/s41467-022-32244-w}, + abstract = {Using engineered wood for construction has been discussed for climate change mitigation. It remains unclear where and in which way the additional demand for wooden construction material shall be fulfilled. Here we assess the global and regional impacts of increased demand for engineered wood on land use and associated CO2 emissions until 2100 using an open-source land system model. We show that if 90\% of the new urban population would be housed in newly built urban mid-rise buildings with wooden constructions, 106 Gt of additional CO2 could be saved by 2100. Forest plantations would need to expand by up to 149 Mha by 2100 and harvests from unprotected natural forests would increase. Our results indicate that expansion of timber plantations for wooden buildings is possible without major repercussions on agricultural production. Strong governance and careful planning are required to ensure a sustainable transition to timber cities even if frontier forests and biodiversity hotspots are protected.}, + language = {en}, + number = {1}, + urldate = {2022-08-30}, + journal = {Nature Communications}, + author = {Mishra, Abhijeet and Humpenöder, Florian and Churkina, Galina and Reyer, Christopher P. O. and Beier, Felicitas and Bodirsky, Benjamin Leon and Schellnhuber, Hans Joachim and Lotze-Campen, Hermann and Popp, Alexander}, + month = aug, + year = {2022}, + note = {Number: 1 +Publisher: Nature Publishing Group}, + keywords = {Forestry, Climate-change mitigation}, + pages = {4889}, +} + +@dataset{buchhorn_copernicus_2020, + title = {Copernicus Global Land Service: {{Land}} Cover 100m: Collection 3: Epoch 2019: {{Globe}}}, + author = {Buchhorn, Marcel and Smets, Bruno and Bertels, Luc and Roo, Bert De and Lesiv, Myroslava and Tsendbazar, Nandin-Erdene and Herold, Martin and Fritz, Steffen}, + date = {2020-09}, + publisher = {{Zenodo}}, + doi = {10.5281/zenodo.3939050}, + url = {https://doi.org/10.5281/zenodo.3939050}, + version = {V3.0.1} +} + +@book{muehlhoff_milk_2013, + address = {Rome}, + title = {Milk and dairy products in human nutrition}, + isbn = {978-92-5-107863-1}, + language = {en}, + publisher = {Food and Agriculture Organization of the United Nations}, + editor = {Muehlhoff, Ellen and Bennett, Anthony and MacMahon, Deirdre and {Food and Agriculture Organization of the United Nations}}, + year = {2013}, + note = {OCLC: ocn865477080}, + keywords = {Analysis, Dairy products in human nutrition, Milk, Milk in human nutrition}, +} + +@book{fao_food_2004, + address = {Rome}, + series = {{FAO} food and nutrition paper}, + title = {Food energy: methods of analysis and conversion factors ; report of a technical workshop, {Rome}, 3 - 6 {December} 2002}, + isbn = {978-92-5-105014-9}, + shorttitle = {Food energy}, + language = {en}, + number = {77}, + publisher = {Food and Agriculture Organization of the United Nations}, + editor = {{FAO}}, + year = {2004}, +} + +@article{mazac_novelfoods_2023, + title = {Environmental and nutritional {Life} {Cycle} {Assessment} of novel foods in meals as transformative food for the future}, + volume = {876}, + issn = {0048-9697}, + url = {https://www.sciencedirect.com/science/article/pii/S0048969723014122}, + doi = {10.1016/j.scitotenv.2023.162796}, + abstract = {Sustainable diets are key for mitigating further anthropogenic climate change and meeting future health and sustainability goals globally. Given that current diets need to change significantly, novel/future foods (e.g., insect meal, cultured meat, microalgae, mycoprotein) present options for protein alternatives in future diets with lower total environmental impacts than animal source foods. Comparisons at the more concrete meal level would help consumers better understand the scale of environmental impacts of single meals and substitutability of animal sourced foods with novel foods. Our aim was to compare the environmental impacts of meals including novel/future foods with those of vegan and omnivore meals. We compiled a database on environmental impacts and nutrient composition of novel/future foods and modeled the impacts of calorically similar meals. Additionally, we applied two nutritional Life Cycle Assessment (nLCA) methods to compare the meals in terms of nutritional content and environmental impacts in one index. All meals with novel/future foods had up to 88 \% less Global Warming Potential, 83 \% less land use, 87 \% less scarcity-weighted water use, 95 \% less freshwater eutrophication, 78 \% less marine eutrophication, and 92 \% less terrestrial acidification impacts than similar meals with animal source foods, while still offering the same nutritional value as vegan and omnivore meals. The nLCA indices of most novel/future food meals are similar to protein-rich plant-based alternative meals and show fewer environmental impacts in terms of nutrient richness than most animal source meals. Substituting animal source foods with certain novel/future foods may provide for nutritious meals with substantial environmental benefits for sustainably transforming future food systems.}, + urldate = {2024-07-18}, + journal = {Science of The Total Environment}, + author = {Mazac, Rachel and Järviö, Natasha and Tuomisto, Hanna L.}, + month = jun, + year = {2023}, + keywords = {Acidification, Alternative proteins, Environmental impacts, Eutrophication, Global Warming Potential, Land/water use, Novel foods, Sustainable meals}, + pages = {162796}, +} + +@article{jarvio_LCA_MP_2021, + title = {An attributional life cycle assessment of microbial protein production: {A} case study on using hydrogen-oxidizing bacteria}, + volume = {776}, + issn = {0048-9697}, + shorttitle = {An attributional life cycle assessment of microbial protein production}, + url = {https://www.sciencedirect.com/science/article/pii/S0048969721008317}, + doi = {10.1016/j.scitotenv.2021.145764}, + abstract = {Novel food production technologies are being developed to address the challenges of securing sustainable and healthy nutrition for the growing global population. This study assessed the environmental impacts of microbial protein (MP) produced by autotrophic hydrogen-oxidizing bacteria (HOB). Data was collected from a company currently producing MP using HOB (hereafter simply referred to as MP) on a small-scale. Earlier studies have performed an environmental assessment of MP on a theoretical basis but no study yet has used empirical data. An attributional life cycle assessment (LCA) with a cradle-to-gate approach was used to quantify global warming potential (GWP), land use, freshwater and marine eutrophication potential, water scarcity, human (non-)carcinogenic toxicity, and the cumulative energy demand (CED) of MP production in Finland. A Monte Carlo analysis was performed to assess uncertainties while a sensitivity analysis was used to explore the impacts of alternative production options and locations. The results were compared with animal- and plant-based protein sources for human consumption as well as protein sources for feed. Electricity consumption had the highest contribution to environmental impacts. Therefore, the source of energy had a substantial impact on the results. MP production using hydropower as an energy source yielded 87.5\% lower GWP compared to using the average Finnish electricity mix. In comparison with animal-based protein sources for food production, MP had 53–100\% lower environmental impacts depending on the reference product and the source of energy assumed for MP production. When compared with plant-based protein sources for food production, MP had lower land and water use requirements, and eutrophication potential but GWP was reduced only if low-emission energy sources were used. Compared to protein sources for feed production, MP production often resulted in lower environmental impact for GWP (FHE), land use, and eutrophication and acidification potential, but generally caused high water scarcity and required more energy.}, + language = {en}, + urldate = {2022-02-16}, + journal = {Science of The Total Environment}, + author = {Järviö, Natasha and Maljanen, Netta-Leena and Kobayashi, Yumi and Ryynänen, Toni and Tuomisto, Hanna L.}, + month = jul, + year = {2021}, + keywords = {LCA, Food, Hydrogen-oxidizing bacteria, Cellular agriculture, Microbial protein}, + pages = {145764}, +} + +@techreport{budynski_straw_2020, + title = {Straw manufacturing in {Alberta}}, + url = {https://open.alberta.ca/dataset/690317b0-1d07-4f9e-ae71-6340e16f6493/resource/89789096-1c7a-47ab-beb2-94d55606c922/}, + language = {en}, + institution = {Published by Alberta Agriculture and Forestry}, + author = {Budynski, Stephanie}, + year = {2020}, +} + +@article{smith_greenhouse_2008, + title = {Greenhouse gas mitigation in agriculture}, + volume = {363}, + copyright = {© 2007 The Royal Society}, + issn = {0962-8436, 1471-2970}, + url = {http://rstb.royalsocietypublishing.org/content/363/1492/789}, + doi = {10.1098/rstb.2007.2184}, + language = {en}, + number = {1492}, + urldate = {2016-12-13}, + journal = {Philosophical Transactions of the Royal Society B: Biological Sciences}, + author = {Smith, Pete and Martino, Daniel and Cai, Zucong and Gwary, Daniel and Janzen, Henry and Kumar, Pushpam and McCarl, Bruce and Ogle, Stephen and O'Mara, Frank and Rice, Charles and Scholes, Bob and Sirotenko, Oleg and Howden, Mark and McAllister, Tim and Pan, Genxing and Romanenkov, Vladimir and Schneider, Uwe and Towprayoon, Sirintornthep and Wattenbach, Martin and Smith, Jo}, + month = feb, + year = {2008}, + pmid = {17827109}, + pages = {789--813}, +} + +@article{uludere_aragon_realistic_2024, + title = {The {Realistic} {Potential} of {Soil} {Carbon} {Sequestration} in {U}.{S}. {Croplands} for {Climate} {Mitigation}}, + volume = {12}, + copyright = {© 2024. The Author(s).}, + issn = {2328-4277}, + url = {https://onlinelibrary.wiley.com/doi/abs/10.1029/2023EF003866}, + doi = {10.1029/2023EF003866}, + language = {en}, + number = {6}, + urldate = {2025-02-10}, + journal = {Earth's Future}, + author = {Uludere Aragon, Nazli and Xie, Yanhua and Bigelow, Daniel and Lark, Tyler J. and Eagle, Alison J.}, + year = {2024}, + note = {\_eprint: https://onlinelibrary.wiley.com/doi/pdf/10.1029/2023EF003866}, + keywords = {climate mitigation, natural climate solutions, agricultural land use, carbon sequestration potential, conservation policy, cover cropping, stable croplands}, + pages = {e2023EF003866}, +} diff --git a/main.gms b/main.gms index 1af3a612ba..e098e32f31 100644 --- a/main.gms +++ b/main.gms @@ -1,10 +1,12 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 +$if set RESTARTPOINT $goto %RESTARTPOINT% + $title magpie *' @title MAgPIE - Modelling Framework @@ -66,10 +68,10 @@ $title magpie *' from land-use change dynamics, i.e. from conversion of different biomes into agricultural land *' and consequent loss of terrestrial carbon stocks (@popp_land-use_2014), also including the *' depletion of organic matter in soils ([59_som]). The land also serves as a sink for atmospheric -*' carbon when agricultural land is set aside from production and the associated regrowth of natural +*' carbon when agricultural land is taken out of production and the associated regrowth of natural *' vegetation generates negative emissions from land-use change. *' Nitrogen emissions ([51_nitrogen]) are estimated based on nitrogen budgets for croplands, -*' pastures ([50_nr_budgets]) and the livestock sector ([55_awms]) (@bodirsky_reactive_2014). +*' pastures ([50_nr_soil_budget]) and the livestock sector ([55_awms]) (@bodirsky_reactive_2014). *' CH4 emissions are based on *' livestock feed and rice cultivation areas (@popp_food_2010). In the case of mitigation *' policies for the land sector, the model can reduce CO2 emissions by restraining land-use @@ -78,7 +80,7 @@ $title magpie *' of fertilizer spreaders) (@popp_land-use_2014, @stevanovic_mitigation_2017). In addition, *' the model covers land-based carbon removal technologies such as bioenergy with carbon capture *' and sequestration (CCS) and afforestation (@humpenoder_investigating_2014, -*' @humpenoder_large-scale_2017, @kreidenweis_afforestation_2016). +*' @humpenoeder_bioenergy_2018, @kreidenweis_afforestation_2016). *' *' In response to all involved demand for agricultural commodities, costs of production, *' biophysical constraints and land-related policies, MAgPIE simulates major dynamics of @@ -86,16 +88,65 @@ $title magpie *' and associated increases in both crop yields ([14_yields]) and biomass removal through grazing on *' pastures ([31_past]), land use change ([39_landconversion]), interregional trade flows ([21_trade]), *' and irrigation ([41_area_equipped_for_irrigation]). - - - +*' +*' The MAgPIE GAMS code folllows the coding etiquette as described below. +*' +*' Use the following prefixes: +*' +*' * q_ eQuations +*' * v_ Variables +*' * s_ Scalars +*' * f_ File parameters - these parameters contain data as it was read from file +*' * i_ Input parameters - influencing the optimzation but are not influenced by it +*' * p_ Processing parameters - influencing optimization and are being influenced by it +*' * o_ Output parameters - only being influenced by optimization but without effect on the optimization +*' * x_ eXtremely important output parameters - output parameters, that are necessary for the model to run properly (required by external postprocessing). They must not be removed. +*' * c_ switches from the Config.gms - parameters, that are switches to choose different scenarios +*' * m_ Macros +*' +*' The prefixes have to be extended in some cases by a second letter +*' +*' * ?m_ module-relevant object - This object is used by at least one module and the core code. Changes related to this object have to be performed carefully. +*' * ?00_ (a 2-digit number) module-only object This 2-digit number defines the module the object belongs to. The number is used here to make sure that different modules cannot have the same object +*' +*' Sets +*' +*' Sets are treated slightly different: Instead of adding a prefix sets should get a 2-digit number suffix giving the number +*' of the module in which the set is exclusively used. If the set is used in more than one module no suffix should be given. +*' +*' The prefixes have to be extended by a second letter in some more cases +*' +*' * ?c_ value for the Current timestep - necessary for constraints. Each *c_-object must have a time-depending counterpart +*' * ?q_ parameter containing the values of an equation +*' * ?v_ parameter containing the values of a variable +*' +*' Besides prefixes also suffixes should be used. Suffixes should indicate the level of aggregation of an object: +*' +*' * (no suffix) highest disaggregation available +*' * _(setname) aggregation over set +*' * _reg regional aggregation (exception) +*' * _glo global aggregation (exception) +*' +*' Units +*' +*' * Document units at the location of the variable declaration +*' * Use units that lead to variable values in the range of 0.01 to 100. Keep the option of scaling in mind. +*' * Use only MAgPIE standard units in GAMS code 10^6, 10^6 ha, 10^6 tDM, 10^6 PJ, 10^6 USD, 10^6 m3 +*' * Make sure that your inputs already have the right unit +*' +*' Input files +*' +*' * Input file names must be unique, because input files will be downloaded from a data repository and extracted to the same folder so that different files with the same file name would overwrite each other. +*' * Do not add input files to the git repository. Input files should be copied instead to one of the existing data repositories from which the data is downloaded by the model. +*' +*' Postprocessing +*' +*' * Processing of model outputs is managed in the corresponding magpie R package (e.g. package "magpie4" for MAgPIE version 4.x). +*' * If you change something in the GAMS code make sure that all function in the corresponding magpie R package still work and adapt them if necessary to the new model structure. +*' * When performing modifications in a magpie R package make sure that these changes are downwards compatible. +*' * 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: magpie4.1_default_apr19.tgz -* md5sum: ea3959be0d5a45cf50cfc232571dc9bd -* Repository: https://rse.pik-potsdam.de/data/magpie/public -* * Low resolution: c200 * High resolution: 0.5 * @@ -103,32 +154,9 @@ $title magpie * * Number of cells per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA -* 28 24 10 7 3 53 17 8 22 7 11 10 -* -* Regionscode: 690d3718e151be1b450b394c1064b1c5 -* -* Regions data revision: 4.18 -* -* lpj2magpie settings: -* * LPJmL data folder: /p/projects/landuse/data/input/lpj_input/isimip_rcp/IPSL_CM5A_LR/rcp2p6/co2 -* * Additional input folder: /p/projects/landuse/data/input/other/rev34 -* * Revision: 34 -* * Call: lpj2magpie(input_folder = path(cfg$lpj_input_folder, gsub("-", "/", cfg$input)), input2_folder = path(cfg$additional_input_folder, paste("rev", floor(cfg$revision), sep = "")), output_file = lpj2magpie_file, rev = cfg$revision) -* -* aggregation settings: -* * Input resolution: 0.5 -* * Output resolution: c200 -* * Input file: /p/projects/landuse/data/input/archive/isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev34_0.5.tgz -* * Output file: /p/projects/landuse/data/input/archive/isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev34_c200_690d3718e151be1b450b394c1064b1c5.tgz -* * Regionscode: 690d3718e151be1b450b394c1064b1c5 -* * (clustering) n-repeat: 5 -* * (clustering) n-redistribute: 0 -* * Call: aggregation(input_file = lpj2magpie_file, regionmapping = paste0("../", cfg$regionmapping), output_file = aggregation_file, rev = cfg$revision, res_high = cfg$high_res, res_low = cfg$low_res, hcells = cfg$highres_cells, weight = cfg$cluster_weight, nrepeat = cfg$nrepeat, nredistribute = cfg$nredistribute, sum_spam_file = NULL, debug = FALSE) -* -* -* -* Last modification (input data): Sat Apr 27 13:45:25 2019 +* 5 19 12 12 7 33 25 8 16 12 33 18 * +* Regionscode: 62eff8f7 *###################### R SECTION END (VERSION INFO) ########################### $offupper @@ -152,59 +180,74 @@ $offlisting * Key parameters during model runs $setglobal c_timesteps coup2100 +$setglobal c_past till_2015 +$setglobal c_title default scalars - s_use_gdx use of gdx files / 2 / +s_use_gdx use of gdx files / 0 / ; ******************************************************************************** *******************************MODULE SETUP************************************* $setglobal drivers aug17 -$setglobal land feb15 +$setglobal land landmatrix_dec18 $setglobal costs default -$setglobal interest_rate reg_feb18 -$setglobal tc endo_jun18 -$setglobal yields dynamic_aug18 +$setglobal interest_rate select_apr20 +$setglobal tc endo_jan22 +$setglobal yields managementcalib_aug19 -$setglobal food anthropometrics_jan18 +$setglobal food anthro_iso_jun22 $setglobal demand sector_may15 $setglobal production flexreg_apr16 $setglobal residues flexreg_apr16 -$setglobal processing substitution_dec18 +$setglobal processing substitution_may21 $setglobal trade selfsuff_reduced +$setglobal land_conservation area_based_apr22 + +$setglobal ageclass oct24 -$setglobal crop endo_jun13 +$setglobal cropland detail_apr24 +$setglobal croparea simple_apr24 $setglobal past endo_jun13 -$setglobal forestry affore_vegc_dec16 -$setglobal urban static -$setglobal natveg dynamic_may18 -$setglobal factor_costs mixed_feb17 -$setglobal landconversion global_static_aug18 +$setglobal forestry dynamic_may24 + +$setglobal urban exo_nov21 +$setglobal natveg pot_forest_may24 + +$setglobal employment exo_may22 +$setglobal labor_prod off +$setglobal factor_costs sticky_feb18 +$setglobal landconversion calib $setglobal transport gtap_nov12 $setglobal area_equipped_for_irrigation endo_apr13 -$setglobal water_demand agr_sector_aug13 +$setglobal water_demand all_sectors_aug13 $setglobal water_availability total_water_aug13 +$setglobal biodiversity bii_target $setglobal climate static -$setglobal nr_soil_budget exoeff_aug16 -$setglobal nitrogen ipcc2006_sep16 +$setglobal nr_soil_budget macceff_aug22 +$setglobal nitrogen rescaled_jan21 $setglobal carbon normal_dec17 -$setglobal methane ipcc2006_flexreg_apr16 +$setglobal methane ipcc2006_aug22 $setglobal phosphorus off $setglobal awms ipcc2006_aug16 -$setglobal ghg_policy price_jan19 -$setglobal maccs on_sep16 -$setglobal som off +$setglobal ghg_policy price_aug22 +$setglobal maccs on_aug22 +$setglobal peatland v2 +$setglobal som cellpool_jan23 -$setglobal bioenergy 1stgen_priced_dec18 +$setglobal bioenergy 1st2ndgen_priced_feb24 $setglobal material exo_flexreg_apr16 $setglobal livestock fbask_jan16 -$setglobal disagg_lvst foragebased_aug18 + +$setglobal disagg_lvst foragebased_jul23 + +$setglobal timber default $setglobal optimization nlp_apr17 diff --git a/modules/09_drivers/aug17/declarations.gms b/modules/09_drivers/aug17/declarations.gms index 8f0fcb0965..67f719c8d1 100644 --- a/modules/09_drivers/aug17/declarations.gms +++ b/modules/09_drivers/aug17/declarations.gms @@ -1,31 +1,36 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 +parameters * Population - im_pop_iso(t,iso) Population (mio. per yr) - im_pop(t,i) Population (mio. per yr) + im_pop_iso(t_all,iso) Population (mio. per yr) + im_pop(t_all,i) Population (mio. per yr) + i09_pop_raw(t_all,i,pop_gdp_scen09) Population (mio. per yr) * GDP in MER - i09_gdp_mer_iso(t,iso) Income in market exchange rates (mio. USD05MER per yr) - i09_gdp_mer(t,i) Income in market exchange rates (mio. USD05MER per yr) + i09_gdp_mer_iso(t_all,iso) Income in market exchange rates (mio. USD17MER per yr) + im_gdp_pc_mer_iso(t_all,iso) Income in market exchange rates (mio. USD17MER per yr) + i09_gdp_mer_raw(t_all,i,pop_gdp_scen09) Income in market exchange rates (mio. USD17MER per yr) - im_gdp_pc_mer(t,i) Per capita income in market exchange rates (USD05MER per cap per yr) - i09_gdp_pc_mer_iso(t,iso) Per capita income in market exchange rates (USD05MER per cap per yr) + i09_gdp_pc_mer_raw(t_all,i,pop_gdp_scen09) Per capita income in market exchange rates (USD17MER per cap per yr) + im_gdp_pc_mer(t_all,i) Per capita income in market exchange rates (USD17MER per cap per yr) + i09_gdp_pc_mer_iso_raw(t_all,iso,pop_gdp_scen09) Per capita income in market exchange rates (USD17MER per cap per yr) * GDP in PPP - i09_gdp_ppp_iso(t,iso) Income in purchasing power parity (mio. USD05PPP per yr) - i09_gdp_ppp(t,i) Income in purchasing power parity (mio. USD05PPP per yr) - - im_gdp_pc_ppp(t,i) Per capita income in purchasing power parity (USD05PPP per cap per yr) - im_gdp_pc_ppp_iso(t,iso) Per capita income in purchasing power parity (USD05PPP per cap per yr) + i09_gdp_ppp_iso(t_all,iso) Income in purchasing power parity (mio. USD17PPP per yr) + i09_gdp_ppp_raw(t_all,i,pop_gdp_scen09) Income in purchasing power parity (mio. USD17PPP per yr) + i09_gdp_pc_ppp_raw(t_all,i,pop_gdp_scen09) Per capita income in purchasing power parity (USD17PPP per cap per yr) + i09_gdp_pc_ppp_iso_raw(t_all,iso,pop_gdp_scen09) Per capita income in purchasing power parity (USD17PPP per cap per yr) + im_gdp_pc_ppp_iso(t_all,iso) Per capita income in purchasing power parity (USD17PPP per cap per yr) + * Development State - im_development_state(t,i) Development state according to the World Bank definition where 0=low income country 1=high income country in high income level (1) - im_physical_inactivity(t,iso,sex,age) Share of population which is physically inactive (1) - im_demography(t,iso,sex,age) Population by groups (mio. per yr) + im_development_state(t_all,i) Development state according to the World Bank definition where 0=low income country 1=high income country in high income level (1) + im_physical_inactivity(t_all,iso,sex,age) Share of population which is physically inactive (1) + im_demography(t_all,iso,sex,age) Population by groups (mio. per yr) + ; diff --git a/modules/09_drivers/aug17/input.gms b/modules/09_drivers/aug17/input.gms index 9e7142dea3..e3e424937e 100644 --- a/modules/09_drivers/aug17/input.gms +++ b/modules/09_drivers/aug17/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,40 +6,56 @@ *** | Contact: magpie@pik-potsdam.de $setglobal c09_pop_scenario SSP2 -* options: SSP: "SSP1", "SSP2", "SP3", "SSP4", "SSP5" -* SRES: "a1", "a2", "b1", "b2" +* options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5", "SSP2EU" +* SDP: "SDP", SDP_EI", "SDP_MC", "SDP_RC" $setglobal c09_gdp_scenario SSP2 -* options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" -* SRES: "a1", "a2", "b1", "b2" +* options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5", "SSP2EU" +* SDP: "SDP", "SDP_EI", "SDP_MC", "SDP_RC" +$setglobal c09_pal_scenario SSP2 +* options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5", "SSP2EU" +* SDP: "SDP", "SDP_EI", "SDP_MC", "SDP_RC" -table f09_gdp_ppp_iso(t_all,iso,gdp_scen09) Income in purchasing power parity (mio. USD05PPP per yr) +parameters +* Years where SSPs and nocc/cc scenarios diverge + sm_fix_SSP2 year until which all parameters are fixed to SSP2 values (year) / 2025 / + sm_fix_cc year until which all parameters affected by cc are fixed to historical values (year) / 2025 / +; + +table f09_gdp_ppp_iso(t_all,iso,pop_gdp_scen09) Income in purchasing power parity (mio. USD17PPP per yr) $ondelim $include "./modules/09_drivers/input/f09_gdp_ppp_iso.csv" $offdelim; -table f09_gdp_mer_iso(t_all,iso,gdp_scen09) Income in market exchange rates (mio. USD05MER per yr) +table f09_gdp_mer_iso(t_all,iso,pop_gdp_scen09) Income in market exchange rates (mio. USD17MER per yr) $ondelim $include "./modules/09_drivers/input/f09_gdp_mer_iso.csv" $offdelim; -table f09_pop_iso(t_all,iso,pop_scen09) Population (mio. capita per yr) +table f09_pop_iso(t_all,iso,pop_gdp_scen09) Population (mio. capita per yr) $ondelim $include "./modules/09_drivers/input/f09_pop_iso.csv" $offdelim; -table f09_development_state(t_all,i,gdp_scen09) Development state according to the World Bank definition where 0=low income country 1=high income country in high income level (1) +table f09_development_state(t_all,i,pop_gdp_scen09) Development state according to the World Bank definition where 0=low income country 1=high income country in high income level (1) $ondelim $include "./modules/09_drivers/input/f09_development_state.cs3" $offdelim; -table f09_demography(t_all,iso,pop_scen09,sex,age) Population (mio. capita per yr) +table f09_demography(t_all,iso,pop_gdp_scen09,sex,age) Population (mio. capita per yr) $ondelim $include "./modules/09_drivers/input/f09_demography.cs3" $offdelim; -table f09_physical_inactivity(t_all,iso,gdp_scen09,sex,age) Share of population which is physically inactive (1) +table f09_physical_inactivity(t_all,iso,pop_gdp_scen09,sex,age) Share of population which is physically inactive (1) $ondelim $include "./modules/09_drivers/input/f09_physical_inactivity.cs3" $offdelim; + +parameter fm_gdp_defl_ppp(iso) GDP deflator +/ +$ondelim +$include "./modules/09_drivers/input/fm_gdp_defl_ppp.cs4" +$offdelim +/; diff --git a/modules/09_drivers/aug17/preloop.gms b/modules/09_drivers/aug17/preloop.gms index 7b396f061d..e4671d3f32 100644 --- a/modules/09_drivers/aug17/preloop.gms +++ b/modules/09_drivers/aug17/preloop.gms @@ -1,48 +1,60 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -* get the scenario GDP & Populaiton data for iso countries +* calculate GDP and population data for MAgPIE regions +i09_gdp_mer_raw(t_all,i,pop_gdp_scen09) = sum(i_to_iso(i,iso), f09_gdp_mer_iso(t_all,iso,pop_gdp_scen09)); +i09_gdp_ppp_raw(t_all,i,pop_gdp_scen09) = sum(i_to_iso(i,iso), f09_gdp_ppp_iso(t_all,iso,pop_gdp_scen09)); +i09_pop_raw(t_all,i,pop_gdp_scen09) = sum(i_to_iso(i,iso), f09_pop_iso(t_all,iso,pop_gdp_scen09)); -im_physical_inactivity(t,iso,sex,age) = f09_physical_inactivity(t,iso,"%c09_gdp_scenario%",sex,age); -im_demography(t,iso,sex,age) = f09_demography(t,iso,"%c09_gdp_scenario%",sex,age)+0.000001; +* GPD per capita for MAgPIE regions +i09_gdp_pc_mer_raw(t_all,i,pop_gdp_scen09)$(i09_pop_raw(t_all,i,pop_gdp_scen09) > 0 ) = + i09_gdp_mer_raw(t_all,i,pop_gdp_scen09) / i09_pop_raw(t_all,i,pop_gdp_scen09) +; -i09_gdp_ppp_iso(t,iso) = f09_gdp_ppp_iso(t,iso,"%c09_gdp_scenario%"); -i09_gdp_mer_iso(t,iso) = f09_gdp_mer_iso(t,iso,"%c09_gdp_scenario%"); -im_pop_iso(t,iso) = f09_pop_iso(t,iso,"%c09_pop_scenario%"); -* get the scenario GDP & Populaiton data for MAgPIE regions -i09_gdp_mer(t,i) = sum(i_to_iso(i,iso),i09_gdp_mer_iso(t,iso)); -i09_gdp_ppp(t,i) = sum(i_to_iso(i,iso),i09_gdp_ppp_iso(t,iso)); -im_pop(t,i) = sum(i_to_iso(i,iso),im_pop_iso(t,iso)); +i09_gdp_pc_ppp_raw(t_all,i,pop_gdp_scen09)$(i09_pop_raw(t_all,i,pop_gdp_scen09) > 0 ) = + i09_gdp_ppp_raw(t_all,i,pop_gdp_scen09) / i09_pop_raw(t_all,i,pop_gdp_scen09) +; -* Status of countries' development -im_development_state(t,i) = f09_development_state(t,i,"%c09_gdp_scenario%"); +*' GDP per capita for ISO countries +i09_gdp_pc_ppp_iso_raw(t_all,iso,pop_gdp_scen09) = 0; +i09_gdp_pc_ppp_iso_raw(t_all,iso,pop_gdp_scen09)$(f09_gdp_ppp_iso(t_all,iso,pop_gdp_scen09) * f09_pop_iso(t_all,iso,pop_gdp_scen09) > 0) = f09_gdp_ppp_iso(t_all,iso,pop_gdp_scen09) / f09_pop_iso(t_all,iso,pop_gdp_scen09); +* Countries with no p.c. GDP information receive SSP2 average p.c. GDP +* SSP2 GDP was selected because diverging GDP and population information leads to diverging regional values +i09_gdp_pc_ppp_iso_raw(t_all,iso,pop_gdp_scen09)$(i09_gdp_pc_ppp_iso_raw(t_all,iso,pop_gdp_scen09) = 0) = sum(i_to_iso(i,iso), i09_gdp_pc_ppp_raw(t_all,i,"SSP2")); -* GPD per capita for MAgPIE regions - im_gdp_pc_mer(t,i)$( - sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ) >0 ) = - sum(i_to_iso(i,iso), - i09_gdp_mer_iso(t,iso) - ) / sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ); +i09_gdp_pc_mer_iso_raw(t_all,iso,pop_gdp_scen09) = 0; +i09_gdp_pc_mer_iso_raw(t_all,iso,pop_gdp_scen09)$(f09_gdp_mer_iso(t_all,iso,pop_gdp_scen09) * f09_pop_iso(t_all,iso,pop_gdp_scen09) > 0) = f09_gdp_mer_iso(t_all,iso,pop_gdp_scen09) / f09_pop_iso(t_all,iso,pop_gdp_scen09); +* Countries with no p.c. GDP information receive SSP2 average p.c. GDP +* SSP2 GDP was selected because diverging GDP and population information leads to diverging regional values +i09_gdp_pc_mer_iso_raw(t_all,iso,pop_gdp_scen09)$(i09_gdp_pc_mer_iso_raw(t_all,iso,pop_gdp_scen09) = 0) = sum(i_to_iso(i,iso), i09_gdp_pc_mer_raw(t_all,i,"SSP2")); - im_gdp_pc_ppp(t,i)$( - sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ) >0 ) = - sum(i_to_iso(i,iso), - i09_gdp_ppp_iso(t,iso) - ) / sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ); +* select scenario for GDP, population, demography and physical inactivity +loop(t_all, + if(m_year(t_all) <= sm_fix_SSP2, + im_physical_inactivity(t_all,iso,sex,age) = f09_physical_inactivity(t_all,iso,"SSP2",sex,age); + im_demography(t_all,iso,sex,age) = f09_demography(t_all,iso,"SSP2",sex,age) + 0.000001; + im_pop_iso(t_all,iso) = f09_pop_iso(t_all,iso,"SSP2"); + im_pop(t_all,i) = i09_pop_raw(t_all,i,"SSP2"); + im_gdp_pc_mer(t_all,i) = i09_gdp_pc_mer_raw(t_all,i,"SSP2"); + im_gdp_pc_mer_iso(t_all,iso) = i09_gdp_pc_mer_iso_raw(t_all,iso,"SSP2"); + im_gdp_pc_ppp_iso(t_all,iso) = i09_gdp_pc_ppp_iso_raw(t_all,iso,"SSP2"); + im_development_state(t_all,i) = f09_development_state(t_all,i,"SSP2"); +else + im_physical_inactivity(t_all,iso,sex,age) = f09_physical_inactivity(t_all,iso,"%c09_pal_scenario%",sex,age); + im_demography(t_all,iso,sex,age) = f09_demography(t_all,iso,"%c09_pop_scenario%",sex,age) + 0.000001; + im_pop_iso(t_all,iso) = f09_pop_iso(t_all,iso,"%c09_pop_scenario%"); + im_pop(t_all,i) = i09_pop_raw(t_all,i,"%c09_pop_scenario%"); + im_gdp_pc_mer(t_all,i) = i09_gdp_pc_mer_raw(t_all,i,"%c09_gdp_scenario%"); + im_gdp_pc_mer_iso(t_all,iso) = i09_gdp_pc_mer_iso_raw(t_all,iso,"%c09_gdp_scenario%"); + im_gdp_pc_ppp_iso(t_all,iso) = i09_gdp_pc_ppp_iso_raw(t_all,iso,"%c09_gdp_scenario%"); + im_development_state(t_all,i) = f09_development_state(t_all,i,"%c09_gdp_scenario%"); + ); +); -* GDP per capita for ISO countries -im_gdp_pc_ppp_iso(t,iso)=0; -im_gdp_pc_ppp_iso(t,iso)$(i09_gdp_ppp_iso(t,iso)*im_pop_iso(t,iso)>0) = i09_gdp_ppp_iso(t,iso)/im_pop_iso(t,iso); -im_gdp_pc_ppp_iso(t,iso)$(im_gdp_pc_ppp_iso(t,iso)=0) = sum(i_to_iso(i,iso), im_gdp_pc_ppp(t,i)); +* Calculate GDP from p.c. GDP and population of previously selected scenarios +i09_gdp_mer_iso(t_all,iso) = im_gdp_pc_mer_iso(t_all,iso) * im_pop_iso(t_all,iso); +i09_gdp_ppp_iso(t_all,iso) = im_gdp_pc_ppp_iso(t_all,iso) * im_pop_iso(t_all,iso); diff --git a/modules/09_drivers/aug17/realization.gms b/modules/09_drivers/aug17/realization.gms index 60810e64ca..8cb00dac88 100644 --- a/modules/09_drivers/aug17/realization.gms +++ b/modules/09_drivers/aug17/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/09_drivers/aug17/sets.gms b/modules/09_drivers/aug17/sets.gms index ac72c57f7f..a80f3b76bf 100644 --- a/modules/09_drivers/aug17/sets.gms +++ b/modules/09_drivers/aug17/sets.gms @@ -1,27 +1,23 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 - - pop_scen09 Population scenario - / SSP1, SSP2, SSP3, SSP4, SSP5, - a1, a2, b1, b2 / - gdp_scen09 GDP scenario +sets + pop_gdp_scen09 Population and GDP scenario / SSP1, SSP2, SSP3, SSP4, SSP5, - a1,a2,b1,b2 / + SDP, SDP_EI, SDP_MC, SDP_RC / age Population age groups / 0--4, 5--9, 10--14, 15--19, 20--24, 25--29, 30--34, 35--39, 40--44, 45--49, 50--54, 55--59, 60--64, 65--69, 70--74, 75--79 - 80--84,85--89,90--94,95--99,100+ / + 80--84, 85--89, 90--94, 95--99, 100+ / sex Sex groups - /M,F/ + /M, F/ ; diff --git a/modules/09_drivers/input/files b/modules/09_drivers/input/files index 752a896349..cac0468831 100644 --- a/modules/09_drivers/input/files +++ b/modules/09_drivers/input/files @@ -6,3 +6,4 @@ f09_pop_iso.csv f09_urban_iso.csv f09_demography.cs3 f09_physical_inactivity.cs3 +fm_gdp_defl_ppp.cs4 diff --git a/modules/09_drivers/module.gms b/modules/09_drivers/module.gms index e8cc8041f9..7de9fcf2df 100644 --- a/modules/09_drivers/module.gms +++ b/modules/09_drivers/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/10_land/feb15/declarations.gms b/modules/10_land/feb15/declarations.gms deleted file mode 100644 index 979d13fdc2..0000000000 --- a/modules/10_land/feb15/declarations.gms +++ /dev/null @@ -1,42 +0,0 @@ -*** | (C) 2008-2019 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 - pm_land_start(j,land) Land initialization area (mio. ha) - pcm_land(j,land) Land area in previous time step (mio. ha) -; - -variables - vm_landdiff Aggregated difference in land between current and previous time step (mio. ha) -; - -positive variables - vm_land(j,land) Land area of the different land types (mio. ha) - vm_landexpansion(j,land) Land expansion (mio. ha) - v10_landreduction(j,land) Land reduction (mio. ha) -; - -equations - q10_land(j) Land conversion constraint (mio. ha) - q10_landexpansion(j,land) Land expansion constraint (mio. ha) - q10_landreduction(j,land) Land reduction constraint (mio. ha) - q10_landdiff Land difference constraint (mio. ha) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_landdiff(t,type) Aggregated difference in land between current and previous time step (mio. ha) - ov_land(t,j,land,type) Land area of the different land types (mio. ha) - ov_landexpansion(t,j,land,type) Land expansion (mio. ha) - ov10_landreduction(t,j,land,type) Land reduction (mio. ha) - oq10_land(t,j,type) Land conversion constraint (mio. ha) - oq10_landexpansion(t,j,land,type) Land expansion constraint (mio. ha) - oq10_landreduction(t,j,land,type) Land reduction constraint (mio. ha) - oq10_landdiff(t,type) Land difference constraint (mio. ha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/10_land/feb15/equations.gms b/modules/10_land/feb15/equations.gms deleted file mode 100644 index ddeb0724e3..0000000000 --- a/modules/10_land/feb15/equations.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2019 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 -*' This realization defines the total amount of land to be constant over time. - - q10_land(j2) .. - sum(land, vm_land(j2,land)) =e= sum(land, pm_land_start(j2,land)); - -*' The following two equations calculate the land expansion and land contraction. - - q10_landexpansion(j2,land) .. - vm_landexpansion(j2,land) =g= vm_land(j2,land)-pcm_land(j2,land); - q10_landreduction(j2,land) .. - v10_landreduction(j2,land) =g= pcm_land(j2,land)-vm_land(j2,land); - -*' The gross changes in land are calculated based on land expansion, land -*' contraction and land changes from within the modules [35_natveg] -*' and [32_forestry]: - - q10_landdiff .. - vm_landdiff =e= sum((j2,land), vm_landexpansion(j2,land) - + v10_landreduction(j2,land)) - + vm_landdiff_natveg - + vm_landdiff_forestry; diff --git a/modules/10_land/feb15/input.gms b/modules/10_land/feb15/input.gms deleted file mode 100644 index bc0bc13c57..0000000000 --- a/modules/10_land/feb15/input.gms +++ /dev/null @@ -1,12 +0,0 @@ -*** | (C) 2008-2019 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 - -table f10_land(t_ini10,j,land) Different land type areas (mio. ha) -$ondelim -$include "./modules/10_land/input/avl_land_t.cs3" -$offdelim -; diff --git a/modules/10_land/feb15/postsolve.gms b/modules/10_land/feb15/postsolve.gms deleted file mode 100644 index 517bd14c9f..0000000000 --- a/modules/10_land/feb15/postsolve.gms +++ /dev/null @@ -1,44 +0,0 @@ -*** | (C) 2008-2019 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 - -*** Land Patterns are transferred to next timestep -pcm_land(j,land) = vm_land.l(j,land); - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_landdiff(t,"marginal") = vm_landdiff.m; - ov_land(t,j,land,"marginal") = vm_land.m(j,land); - ov_landexpansion(t,j,land,"marginal") = vm_landexpansion.m(j,land); - ov10_landreduction(t,j,land,"marginal") = v10_landreduction.m(j,land); - oq10_land(t,j,"marginal") = q10_land.m(j); - oq10_landexpansion(t,j,land,"marginal") = q10_landexpansion.m(j,land); - oq10_landreduction(t,j,land,"marginal") = q10_landreduction.m(j,land); - oq10_landdiff(t,"marginal") = q10_landdiff.m; - ov_landdiff(t,"level") = vm_landdiff.l; - ov_land(t,j,land,"level") = vm_land.l(j,land); - ov_landexpansion(t,j,land,"level") = vm_landexpansion.l(j,land); - ov10_landreduction(t,j,land,"level") = v10_landreduction.l(j,land); - oq10_land(t,j,"level") = q10_land.l(j); - oq10_landexpansion(t,j,land,"level") = q10_landexpansion.l(j,land); - oq10_landreduction(t,j,land,"level") = q10_landreduction.l(j,land); - oq10_landdiff(t,"level") = q10_landdiff.l; - ov_landdiff(t,"upper") = vm_landdiff.up; - ov_land(t,j,land,"upper") = vm_land.up(j,land); - ov_landexpansion(t,j,land,"upper") = vm_landexpansion.up(j,land); - ov10_landreduction(t,j,land,"upper") = v10_landreduction.up(j,land); - oq10_land(t,j,"upper") = q10_land.up(j); - oq10_landexpansion(t,j,land,"upper") = q10_landexpansion.up(j,land); - oq10_landreduction(t,j,land,"upper") = q10_landreduction.up(j,land); - oq10_landdiff(t,"upper") = q10_landdiff.up; - ov_landdiff(t,"lower") = vm_landdiff.lo; - ov_land(t,j,land,"lower") = vm_land.lo(j,land); - ov_landexpansion(t,j,land,"lower") = vm_landexpansion.lo(j,land); - ov10_landreduction(t,j,land,"lower") = v10_landreduction.lo(j,land); - oq10_land(t,j,"lower") = q10_land.lo(j); - oq10_landexpansion(t,j,land,"lower") = q10_landexpansion.lo(j,land); - oq10_landreduction(t,j,land,"lower") = q10_landreduction.lo(j,land); - oq10_landdiff(t,"lower") = q10_landdiff.lo; -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/10_land/feb15/preloop.gms b/modules/10_land/feb15/preloop.gms deleted file mode 100644 index d29a486957..0000000000 --- a/modules/10_land/feb15/preloop.gms +++ /dev/null @@ -1,15 +0,0 @@ -*** | (C) 2008-2019 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 - - -*due to some rounding errors the input data currently may contain in some cases -*very small, negative numbers. These numbers have to be set to 0 as area -*cannot be smaller than 0! -pm_land_start(j,land) = f10_land("y1995",j,land); -pm_land_start(j,land)$(pm_land_start(j,land)<0) = 0; - -pcm_land(j,land) = pm_land_start(j,land); diff --git a/modules/10_land/feb15/presolve.gms b/modules/10_land/feb15/presolve.gms deleted file mode 100644 index 4f1e5c980e..0000000000 --- a/modules/10_land/feb15/presolve.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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_land.l(j,land) = pcm_land(j,land); diff --git a/modules/10_land/feb15/realization.gms b/modules/10_land/feb15/realization.gms deleted file mode 100644 index 50fea9087e..0000000000 --- a/modules/10_land/feb15/realization.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @limitations There are currently no known limitations of this realization. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/10_land/feb15/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/10_land/feb15/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/10_land/feb15/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/10_land/feb15/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/10_land/feb15/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/10_land/feb15/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/10_land/feb15/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/10_land/feb15/sets.gms b/modules/10_land/feb15/sets.gms deleted file mode 100644 index c54db68365..0000000000 --- a/modules/10_land/feb15/sets.gms +++ /dev/null @@ -1,10 +0,0 @@ -*** | (C) 2008-2019 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 - t_ini10 Time periods with land initialization data - / y1995, y2000, y2005, y2010, y2015 / diff --git a/modules/10_land/input/files b/modules/10_land/input/files index 77cb6ce8f5..27b769596d 100644 --- a/modules/10_land/input/files +++ b/modules/10_land/input/files @@ -1,3 +1,5 @@ * list of files that are required here avl_land_t.cs3 avl_land_t_0.5.mz +luh2_side_layers.cs3 +avl_land_t_iso.cs3 diff --git a/modules/10_land/landmatrix_dec18/declarations.gms b/modules/10_land/landmatrix_dec18/declarations.gms new file mode 100644 index 0000000000..9479126290 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/declarations.gms @@ -0,0 +1,52 @@ +*** | (C) 2008-2025 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 + pm_land_start(j,land) Land initialization area (mio. ha) + pm_land_hist(t_ini10,j,land) Land area for historial time steps (mio. ha) + pcm_land(j,land) Land area in previous time step including possible changes after optimization (mio. ha) +; + +variables + vm_landdiff Aggregated difference in land between current and previous time step (mio. ha) +; + +positive variables + vm_land(j,land) Land area of the different land types (mio. ha) + vm_landexpansion(j,land) Land expansion (mio. ha) + vm_landreduction(j,land) Land reduction (mio. ha) + vm_cost_land_transition(j) Costs for lu transitions (mio. USD17MER per yr) + vm_lu_transitions(j,land_from,land_to) Land transitions between time steps (mio. ha) +; + +equations + q10_land_area(j) Land transition constraint cell area (mio. ha) + q10_transition_to(j,land_to) Land transition constraint to (mio. ha) + q10_transition_from(j,land_from) Land transition constraint from (mio. ha) + q10_landexpansion(j,land_to) Land expansion constraint (mio. ha) + q10_landreduction(j,land_from) Land reduction constraint (mio. ha) + q10_cost(j) Costs for lu transitions (mio. USD17MER per yr) + q10_landdiff Land difference constraint (mio. ha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_landdiff(t,type) Aggregated difference in land between current and previous time step (mio. ha) + ov_land(t,j,land,type) Land area of the different land types (mio. ha) + ov_landexpansion(t,j,land,type) Land expansion (mio. ha) + ov_landreduction(t,j,land,type) Land reduction (mio. ha) + ov_cost_land_transition(t,j,type) Costs for lu transitions (mio. USD17MER per yr) + ov_lu_transitions(t,j,land_from,land_to,type) Land transitions between time steps (mio. ha) + oq10_land_area(t,j,type) Land transition constraint cell area (mio. ha) + oq10_transition_to(t,j,land_to,type) Land transition constraint to (mio. ha) + oq10_transition_from(t,j,land_from,type) Land transition constraint from (mio. ha) + oq10_landexpansion(t,j,land_to,type) Land expansion constraint (mio. ha) + oq10_landreduction(t,j,land_from,type) Land reduction constraint (mio. ha) + oq10_cost(t,j,type) Costs for lu transitions (mio. USD17MER per yr) + oq10_landdiff(t,type) Land difference constraint (mio. ha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/10_land/landmatrix_dec18/equations.gms b/modules/10_land/landmatrix_dec18/equations.gms new file mode 100644 index 0000000000..ae7eba0b43 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/equations.gms @@ -0,0 +1,54 @@ +*** | (C) 2008-2025 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 + + +*' This equation defines the total amount of land to be constant over time. + + q10_land_area(j2) .. + sum(land, vm_land(j2,land)) =e= + sum(land, pcm_land(j2,land)); + +*' The following two equations describe the land transition matrix. + + q10_transition_to(j2,land_to) .. + sum(land_from, vm_lu_transitions(j2,land_from,land_to)) =e= + vm_land(j2,land_to); + + q10_transition_from(j2,land_from) .. + sum(land_to, vm_lu_transitions(j2,land_from,land_to)) =e= + pcm_land(j2,land_from); + +*' The following two equations calculate land expansion and land contraction based +*' on the above land transition matrix. + + q10_landexpansion(j2,land_to) .. + vm_landexpansion(j2,land_to) =e= + sum(land_from$(not sameas(land_from,land_to)), + vm_lu_transitions(j2,land_from,land_to)); + + q10_landreduction(j2,land_from) .. + vm_landreduction(j2,land_from) =e= + sum(land_to$(not sameas(land_from,land_to)), + vm_lu_transitions(j2,land_from,land_to)); + +*' Small costs of 1 $ per ha on gross land-use change avoid unrealistic patterns in the land transition matrix + + q10_cost(j2) .. + vm_cost_land_transition(j2) =e= + sum(land, vm_landexpansion(j2,land) + vm_landreduction(j2,land)) * 1; + +*' The gross changes in land are calculated based on land expansion, land +*' contraction and land changes from within the modules [35_natveg] +*' and [32_forestry]: + + q10_landdiff .. + vm_landdiff =e= sum((j2,land), vm_landexpansion(j2,land) + + vm_landreduction(j2,land)) + + vm_landdiff_natveg + + vm_landdiff_forestry; diff --git a/modules/10_land/landmatrix_dec18/input.gms b/modules/10_land/landmatrix_dec18/input.gms new file mode 100644 index 0000000000..e6d16d4790 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/input.gms @@ -0,0 +1,29 @@ +*** | (C) 2008-2025 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 + +table f10_land(t_ini10,j,land) Different land type areas (mio. ha) +$ondelim +$include "./modules/10_land/input/avl_land_t.cs3" +$offdelim +; +*due to some rounding errors the input data currently may contain in some cases +*very small, negative numbers. These numbers have to be set to 0 as area +*cannot be smaller than 0! +f10_land(t_ini10,j,land)$(f10_land(t_ini10,j,land)<0) = 0; + + +table fm_luh2_side_layers(j,luh2_side_layers10) luh2 side layers (grid cell share) +$ondelim +$include "./modules/10_land/input/luh2_side_layers.cs3" +$offdelim +; + +table fm_land_iso(t_ini10,iso,land) Land area for different land pools at ISO level (mio. ha) +$ondelim +$include "./modules/10_land/input/avl_land_t_iso.cs3" +$offdelim +; diff --git a/modules/10_land/landmatrix_dec18/postsolve.gms b/modules/10_land/landmatrix_dec18/postsolve.gms new file mode 100644 index 0000000000..6d006315eb --- /dev/null +++ b/modules/10_land/landmatrix_dec18/postsolve.gms @@ -0,0 +1,64 @@ +*** | (C) 2008-2025 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 + +*** Land Patterns are transferred to next timestep +pcm_land(j,land) = vm_land.l(j,land); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_landdiff(t,"marginal") = vm_landdiff.m; + ov_land(t,j,land,"marginal") = vm_land.m(j,land); + ov_landexpansion(t,j,land,"marginal") = vm_landexpansion.m(j,land); + ov_landreduction(t,j,land,"marginal") = vm_landreduction.m(j,land); + ov_cost_land_transition(t,j,"marginal") = vm_cost_land_transition.m(j); + ov_lu_transitions(t,j,land_from,land_to,"marginal") = vm_lu_transitions.m(j,land_from,land_to); + oq10_land_area(t,j,"marginal") = q10_land_area.m(j); + oq10_transition_to(t,j,land_to,"marginal") = q10_transition_to.m(j,land_to); + oq10_transition_from(t,j,land_from,"marginal") = q10_transition_from.m(j,land_from); + oq10_landexpansion(t,j,land_to,"marginal") = q10_landexpansion.m(j,land_to); + oq10_landreduction(t,j,land_from,"marginal") = q10_landreduction.m(j,land_from); + oq10_cost(t,j,"marginal") = q10_cost.m(j); + oq10_landdiff(t,"marginal") = q10_landdiff.m; + ov_landdiff(t,"level") = vm_landdiff.l; + ov_land(t,j,land,"level") = vm_land.l(j,land); + ov_landexpansion(t,j,land,"level") = vm_landexpansion.l(j,land); + ov_landreduction(t,j,land,"level") = vm_landreduction.l(j,land); + ov_cost_land_transition(t,j,"level") = vm_cost_land_transition.l(j); + ov_lu_transitions(t,j,land_from,land_to,"level") = vm_lu_transitions.l(j,land_from,land_to); + oq10_land_area(t,j,"level") = q10_land_area.l(j); + oq10_transition_to(t,j,land_to,"level") = q10_transition_to.l(j,land_to); + oq10_transition_from(t,j,land_from,"level") = q10_transition_from.l(j,land_from); + oq10_landexpansion(t,j,land_to,"level") = q10_landexpansion.l(j,land_to); + oq10_landreduction(t,j,land_from,"level") = q10_landreduction.l(j,land_from); + oq10_cost(t,j,"level") = q10_cost.l(j); + oq10_landdiff(t,"level") = q10_landdiff.l; + ov_landdiff(t,"upper") = vm_landdiff.up; + ov_land(t,j,land,"upper") = vm_land.up(j,land); + ov_landexpansion(t,j,land,"upper") = vm_landexpansion.up(j,land); + ov_landreduction(t,j,land,"upper") = vm_landreduction.up(j,land); + ov_cost_land_transition(t,j,"upper") = vm_cost_land_transition.up(j); + ov_lu_transitions(t,j,land_from,land_to,"upper") = vm_lu_transitions.up(j,land_from,land_to); + oq10_land_area(t,j,"upper") = q10_land_area.up(j); + oq10_transition_to(t,j,land_to,"upper") = q10_transition_to.up(j,land_to); + oq10_transition_from(t,j,land_from,"upper") = q10_transition_from.up(j,land_from); + oq10_landexpansion(t,j,land_to,"upper") = q10_landexpansion.up(j,land_to); + oq10_landreduction(t,j,land_from,"upper") = q10_landreduction.up(j,land_from); + oq10_cost(t,j,"upper") = q10_cost.up(j); + oq10_landdiff(t,"upper") = q10_landdiff.up; + ov_landdiff(t,"lower") = vm_landdiff.lo; + ov_land(t,j,land,"lower") = vm_land.lo(j,land); + ov_landexpansion(t,j,land,"lower") = vm_landexpansion.lo(j,land); + ov_landreduction(t,j,land,"lower") = vm_landreduction.lo(j,land); + ov_cost_land_transition(t,j,"lower") = vm_cost_land_transition.lo(j); + ov_lu_transitions(t,j,land_from,land_to,"lower") = vm_lu_transitions.lo(j,land_from,land_to); + oq10_land_area(t,j,"lower") = q10_land_area.lo(j); + oq10_transition_to(t,j,land_to,"lower") = q10_transition_to.lo(j,land_to); + oq10_transition_from(t,j,land_from,"lower") = q10_transition_from.lo(j,land_from); + oq10_landexpansion(t,j,land_to,"lower") = q10_landexpansion.lo(j,land_to); + oq10_landreduction(t,j,land_from,"lower") = q10_landreduction.lo(j,land_from); + oq10_cost(t,j,"lower") = q10_cost.lo(j); + oq10_landdiff(t,"lower") = q10_landdiff.lo; +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/10_land/landmatrix_dec18/presolve.gms b/modules/10_land/landmatrix_dec18/presolve.gms new file mode 100644 index 0000000000..1a47df4129 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/presolve.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 + +*The following bounds should be moved to the respective land modules in the future (different bounds for different realizations) + +*' @code Some of the land use transitions are restricted: + +*' No planted forest on natveg areas +vm_lu_transitions.fx(j,"primforest","forestry") = 0; + +*' Conversions within natveg are not allowed +vm_lu_transitions.fx(j,"primforest","other") = 0; +vm_lu_transitions.fx(j,"secdforest","other") = 0; + +*' Primforest can only decrease +vm_lu_transitions.fx(j,land_from,"primforest") = 0; +vm_lu_transitions.up(j,"primforest","primforest") = Inf; + +*' @stop + +m_boundfix(vm_land,(j,land),up,1e-6); diff --git a/modules/10_land/landmatrix_dec18/realization.gms b/modules/10_land/landmatrix_dec18/realization.gms new file mode 100644 index 0000000000..7c7ae9a349 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/realization.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2025 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 The landmatrix_dec18 realization tracks land use transitions by +*' directly counting sources and targets of conversions. + +*' @limitations This realization only accounts for net land use transitions. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/10_land/landmatrix_dec18/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/10_land/landmatrix_dec18/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/10_land/landmatrix_dec18/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/10_land/landmatrix_dec18/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/10_land/landmatrix_dec18/scaling.gms" +$Ifi "%phase%" == "start" $include "./modules/10_land/landmatrix_dec18/start.gms" +$Ifi "%phase%" == "presolve" $include "./modules/10_land/landmatrix_dec18/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/10_land/landmatrix_dec18/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/10_land/landmatrix_dec18/scaling.gms b/modules/10_land/landmatrix_dec18/scaling.gms new file mode 100644 index 0000000000..83d4dbc6a4 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_landdiff.scale = 10e3; diff --git a/modules/10_land/landmatrix_dec18/sets.gms b/modules/10_land/landmatrix_dec18/sets.gms new file mode 100644 index 0000000000..781302cd49 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/sets.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + t_ini10 Time periods with land initialization data + / y1995, y2000, y2005, y2010, y2015 / + + luh2_side_layers10 side layers from LUH2 + / manpast, rangeland, primveg, secdveg, forested, nonforested / + + potnatveg(luh2_side_layers10) potentially forested biomes + / forested, nonforested / +; + + alias(land,land_from); + alias(land,land_to); diff --git a/modules/10_land/landmatrix_dec18/start.gms b/modules/10_land/landmatrix_dec18/start.gms new file mode 100644 index 0000000000..5781aa0749 --- /dev/null +++ b/modules/10_land/landmatrix_dec18/start.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + +pm_land_start(j,land) = f10_land("y1995",j,land); +pm_land_hist(t_ini10,j,land) = f10_land(t_ini10,j,land); + +pcm_land(j,land) = pm_land_start(j,land); +vm_land.l(j,land) = pcm_land(j,land); + +*** EOF pre.gms *** diff --git a/modules/10_land/module.gms b/modules/10_land/module.gms index e78a97e73f..07451689f7 100644 --- a/modules/10_land/module.gms +++ b/modules/10_land/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,10 +10,11 @@ *' @description The land module coordinates and analyzes all land related activities *' by summing up all land types and calculating the gross changes in land use *' between two time steps of optimization given the recursive dynamic structure of -*' MAgPIE model. +*' MAgPIE model. The land module tracks land use transitions by directly counting +*' sources and targets of conversions. -*' @authors Jan Philipp Dietrich +*' @authors Jan Philipp Dietrich, Florian Humpenoeder, Kristine Karstens *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%land%" == "feb15" $include "./modules/10_land/feb15/realization.gms" +$Ifi "%land%" == "landmatrix_dec18" $include "./modules/10_land/landmatrix_dec18/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/11_costs/default/declarations.gms b/modules/11_costs/default/declarations.gms index cc37899404..255b84b949 100644 --- a/modules/11_costs/default/declarations.gms +++ b/modules/11_costs/default/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,20 +6,20 @@ *** | Contact: magpie@pik-potsdam.de variables - vm_cost_glo Total costs of production (mio. USD05MER per yr) - v11_cost_reg(i) Regional costs (mio. USD05MER per yr) + vm_cost_glo Total costs of production (mio. USD17MER per yr) + v11_cost_reg(i) Regional costs (mio. USD17MER per yr) ; equations - q11_cost_glo Objective function (mio. USD05MER per yr) - q11_cost_reg(i) Regional cost constraint (mio. USD05MER per yr) + q11_cost_glo Objective function (mio. USD17MER per yr) + q11_cost_reg(i) Regional cost constraint (mio. USD17MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_cost_glo(t,type) Total costs of production (mio. USD05MER per yr) - ov11_cost_reg(t,i,type) Regional costs (mio. USD05MER per yr) - oq11_cost_glo(t,type) Objective function (mio. USD05MER per yr) - oq11_cost_reg(t,i,type) Regional cost constraint (mio. USD05MER per yr) + ov_cost_glo(t,type) Total costs of production (mio. USD17MER per yr) + ov11_cost_reg(t,i,type) Regional costs (mio. USD17MER per yr) + oq11_cost_glo(t,type) Objective function (mio. USD17MER per yr) + oq11_cost_reg(t,i,type) Regional cost constraint (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/11_costs/default/equations.gms b/modules/11_costs/default/equations.gms index 5bd609c171..7e7d0932c7 100644 --- a/modules/11_costs/default/equations.gms +++ b/modules/11_costs/default/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -12,24 +12,37 @@ *' The global costs of production are represented by the sum of regional *' production costs of different production activities. - q11_cost_reg(i2) .. v11_cost_reg(i2) =e= sum(kall, vm_cost_prod(i2,kall)) + q11_cost_reg(i2) .. v11_cost_reg(i2) =e= sum(factors,vm_cost_prod_crop(i2,factors)) + + sum(kres,vm_cost_prod_kres(i2,kres)) + + vm_cost_prod_past(i2) + + vm_cost_prod_fish(i2) + + sum(factors,vm_cost_prod_livst(i2,factors)) + sum((cell(i2,j2),land), vm_cost_landcon(j2,land)) + sum((cell(i2,j2),k), vm_cost_transp(j2,k)) + vm_tech_cost(i2) + + vm_rotation_penalty(i2) + vm_nr_inorg_fert_costs(i2) + vm_p_fert_costs(i2) + vm_emission_costs(i2) - vm_reward_cdr_aff(i2) - + vm_maccs_costs(i2) + + sum(factors,vm_maccs_costs(i2,factors)) + vm_cost_AEI(i2) + vm_cost_trade(i2) + vm_cost_fore(i2) + + vm_cost_timber(i2) + + vm_cost_hvarea_natveg(i2) + vm_cost_processing(i2) - + vm_costs_overrate_cropdiff(i2) + + sum(cell(i2,j2), vm_cost_scm(j2)) + vm_bioenergy_utility(i2) + vm_processing_substitution_cost(i2) + vm_costs_additional_mon(i2) - ; + + sum(cell(i2,j2), vm_cost_land_transition(j2)) + + sum(cell(i2,j2), vm_peatland_cost(j2)) + + sum(cell(i2,j2), vm_cost_cropland(j2)) + + sum(cell(i2,j2), vm_cost_bv_loss(j2)) + + sum(cell(i2,j2), vm_cost_urban(j2)) + + vm_water_cost(i2) +; *' The total regional production cost calculation is based on the sum of different *' MAgPIE production activities. These individual costs are calculated by various @@ -48,4 +61,7 @@ *' Forestry related costs (afforestation) ([32_forestry]), *' Bioenergy costs ([60_bioenergy]), *' Processing costs ([20_processing]), -*' Punish costs for overrate cropland differences ([59_som]). +*' Costs for soil carbon management ([59_som]). +*' Small costs for land transitions ([10_land]). +*' Peatland degradation and restoration costs ([58_peatland]). +*' Peatland emission costs ([56_ghg_policy]). diff --git a/modules/11_costs/default/postsolve.gms b/modules/11_costs/default/postsolve.gms index 8377b2eaa7..28301ee06c 100644 --- a/modules/11_costs/default/postsolve.gms +++ b/modules/11_costs/default/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/11_costs/default/realization.gms b/modules/11_costs/default/realization.gms index 0c3fd09f44..8ea7606c69 100644 --- a/modules/11_costs/default/realization.gms +++ b/modules/11_costs/default/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/11_costs/default/scaling.gms b/modules/11_costs/default/scaling.gms index 3fc467d489..091a379312 100644 --- a/modules/11_costs/default/scaling.gms +++ b/modules/11_costs/default/scaling.gms @@ -1,16 +1,10 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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_cost_glo.scale = 10e6; -v11_cost_reg.scale(i) = 10e5; -vm_tech_cost.scale(i) = 10e4; -vm_cost_prod.scale(i,k) = 10e4; +vm_cost_glo.scale = 10e7; +v11_cost_reg.scale(i) = 10e6; vm_cost_transp.scale(j,k) = 10e3; -vm_nr_inorg_fert_costs.scale(i) = 10e4; -vm_cost_fore.scale(i) = 10e4; -vm_emission_costs.scale(i) = 10e4; -vm_maccs_costs.scale(i) = 10e4; diff --git a/modules/11_costs/module.gms b/modules/11_costs/module.gms index be8e4f71f4..8e3fa59b6e 100644 --- a/modules/11_costs/module.gms +++ b/modules/11_costs/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/12_interest_rate/glo_jan16/declarations.gms b/modules/12_interest_rate/glo_jan16/declarations.gms deleted file mode 100644 index ce62e448a5..0000000000 --- a/modules/12_interest_rate/glo_jan16/declarations.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - pm_interest(i) Current interest rate in each region (% per yr) - p12_interest(t,i) Interest rate (% per yr) -; diff --git a/modules/12_interest_rate/glo_jan16/input.gms b/modules/12_interest_rate/glo_jan16/input.gms deleted file mode 100644 index fa21f01d02..0000000000 --- a/modules/12_interest_rate/glo_jan16/input.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - -$setglobal c12_interest_rate medium - -table f12_interest(t_all,scen12) Interest rate scenarios (% per yr) -$ondelim -$include "./modules/12_interest_rate/input/f12_interest_rate.cs3" -$offdelim -; - -$if "%c12_interest_rate%" == "coupling" parameter f12_interest_coupling(t_all) Interest rate (% per yr) -$if "%c12_interest_rate%" == "coupling" / -$if "%c12_interest_rate%" == "coupling" $ondelim -$if "%c12_interest_rate%" == "coupling" $include "./modules/12_interest_rate/input/f12_interest_rate_coupling.csv" -$if "%c12_interest_rate%" == "coupling" $offdelim -$if "%c12_interest_rate%" == "coupling" / -$if "%c12_interest_rate%" == "coupling" ; diff --git a/modules/12_interest_rate/glo_jan16/not_used.txt b/modules/12_interest_rate/glo_jan16/not_used.txt deleted file mode 100644 index 8f2d28f1bb..0000000000 --- a/modules/12_interest_rate/glo_jan16/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason -im_development_state,input,questionnaire diff --git a/modules/12_interest_rate/glo_jan16/preloop.gms b/modules/12_interest_rate/glo_jan16/preloop.gms deleted file mode 100644 index 7bcbcfcfb3..0000000000 --- a/modules/12_interest_rate/glo_jan16/preloop.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - - -*******Income Country Grouping based on World Bank definitions -t_to_i_to_dev(t,i,dev) = no; -t_to_i_to_dev(t,i,"lic") = yes$(im_gdp_pc_ppp(t,i) <= 1045); -t_to_i_to_dev(t,i,"mic") = yes$(im_gdp_pc_ppp(t,i) > 1045 AND im_gdp_pc_ppp(t,i) < 12746); -t_to_i_to_dev(t,i,"hic") = yes$(im_gdp_pc_ppp(t,i) >= 12746); - -$ifthen "%c12_interest_rate%" == "coupling" p12_interest(t,i) = f12_interest_coupling(t); -$elseif "%c12_interest_rate%" == "mixed" p12_interest(t,i) = sum(t_to_i_to_dev("y1995",i,dev), sum(scen12_to_dev(scen12,dev), f12_interest(t,scen12))); -$else p12_interest(t,i) = f12_interest(t,"%c12_interest_rate%"); -$endif diff --git a/modules/12_interest_rate/glo_jan16/presolve.gms b/modules/12_interest_rate/glo_jan16/presolve.gms deleted file mode 100644 index c05cc488fb..0000000000 --- a/modules/12_interest_rate/glo_jan16/presolve.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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 - -pm_interest(i) = p12_interest(t,i); diff --git a/modules/12_interest_rate/glo_jan16/realization.gms b/modules/12_interest_rate/glo_jan16/realization.gms deleted file mode 100644 index 8f71836fcc..0000000000 --- a/modules/12_interest_rate/glo_jan16/realization.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 the glo_jan16 realization, interest rates are identical in all regions. -*' The initial global interest rate is 7% (in 1995) for all scenarios defined in `scen12`. -*' It undergoes a transition towards 4%, 7% and 10% until 2030 for the low-, medium- -*' and high- interest rate scenarios, respectively. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/12_interest_rate/glo_jan16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/12_interest_rate/glo_jan16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/12_interest_rate/glo_jan16/input.gms" -$Ifi "%phase%" == "preloop" $include "./modules/12_interest_rate/glo_jan16/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/12_interest_rate/glo_jan16/presolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/12_interest_rate/glo_jan16/sets.gms b/modules/12_interest_rate/glo_jan16/sets.gms deleted file mode 100644 index dcf2ed95a9..0000000000 --- a/modules/12_interest_rate/glo_jan16/sets.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - scen12 Interest rate scenarios - / low, medium, high / - - scen12_to_dev(scen12,dev) Mapping between interest scneario and economic development status - / high . (lic) - medium . (mic) - low . (hic) / - - t_to_i_to_dev(t,i,dev) Mapping between time, region and economic development status - -; diff --git a/modules/12_interest_rate/input/files b/modules/12_interest_rate/input/files index dbd3af946c..2ce7304bb4 100644 --- a/modules/12_interest_rate/input/files +++ b/modules/12_interest_rate/input/files @@ -1,4 +1,3 @@ * list of files that are required here -f12_interest_rate.cs3 f12_interest_rate_coupling.csv -f12_interest_rate_bound.cs3 +f12_interest_fader.csv diff --git a/modules/12_interest_rate/module.gms b/modules/12_interest_rate/module.gms index 26fa25fce5..e1bd0422fe 100644 --- a/modules/12_interest_rate/module.gms +++ b/modules/12_interest_rate/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -17,6 +17,5 @@ *' @authors Xiaoxi Wang *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%interest_rate%" == "glo_jan16" $include "./modules/12_interest_rate/glo_jan16/realization.gms" -$Ifi "%interest_rate%" == "reg_feb18" $include "./modules/12_interest_rate/reg_feb18/realization.gms" +$Ifi "%interest_rate%" == "select_apr20" $include "./modules/12_interest_rate/select_apr20/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/12_interest_rate/reg_feb18/declarations.gms b/modules/12_interest_rate/reg_feb18/declarations.gms deleted file mode 100644 index aa7db681cd..0000000000 --- a/modules/12_interest_rate/reg_feb18/declarations.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - s12_min_dev Minimum development_state of all regions in 1995 (1) - s12_max_dev Maximum development_state of all regions in 1995 (1) - s12_slope_a Slope of the linear relationship between development state and interest rate (1) - s12_intercept_b Intercept of the linear relationship between development state and interest rate (1) -; - -parameters - pm_interest(i) Current interest rate in each region (% per yr) - p12_interest(t,i) Interest rate in each region and timestep (% per yr) -; diff --git a/modules/12_interest_rate/reg_feb18/input.gms b/modules/12_interest_rate/reg_feb18/input.gms deleted file mode 100644 index f8a1e965be..0000000000 --- a/modules/12_interest_rate/reg_feb18/input.gms +++ /dev/null @@ -1,23 +0,0 @@ -*** | (C) 2008-2019 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 - -$setglobal c12_interest_rate medium - -table f12_interest_bound(t,bound12) Lower and higher bounds of interest rates (% per yr) -$ondelim -$include "./modules/12_interest_rate/input/f12_interest_rate_bound.cs3" -$offdelim -; - - -$if "%c12_interest_rate%" == "coupling" parameter f12_interest_coupling(t_all) Interest rate (% per yr) -$if "%c12_interest_rate%" == "coupling" / -$if "%c12_interest_rate%" == "coupling" $ondelim -$if "%c12_interest_rate%" == "coupling" $include "./modules/12_interest_rate/input/f12_interest_rate_coupling.csv" -$if "%c12_interest_rate%" == "coupling" $offdelim -$if "%c12_interest_rate%" == "coupling" / -$if "%c12_interest_rate%" == "coupling" ; diff --git a/modules/12_interest_rate/reg_feb18/not_used.txt b/modules/12_interest_rate/reg_feb18/not_used.txt deleted file mode 100644 index e9c51aa2f6..0000000000 --- a/modules/12_interest_rate/reg_feb18/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason -im_gdp_pc_ppp,input,questionnaire diff --git a/modules/12_interest_rate/reg_feb18/preloop.gms b/modules/12_interest_rate/reg_feb18/preloop.gms deleted file mode 100644 index 4d3dc407f6..0000000000 --- a/modules/12_interest_rate/reg_feb18/preloop.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2019 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 - - -*******Income Country Grouping based on World Bank definitions - -*' @code -s12_min_dev = smin(i,im_development_state("y1995",i)); -s12_max_dev = smax(i,im_development_state("y1995",i)); -s12_slope_a = (f12_interest_bound("y1995","high")-f12_interest_bound("y1995","low"))/(s12_min_dev-s12_max_dev); -s12_intercept_b = f12_interest_bound("y1995","high")-s12_slope_a*s12_min_dev; -p12_interest(t,i) = s12_slope_a *im_development_state(t,i) + s12_intercept_b; - -*' @stop - -$ifthen "%c12_interest_rate%" == "coupling" p12_interest(t,i) = f12_interest_coupling(t); -$endif diff --git a/modules/12_interest_rate/reg_feb18/presolve.gms b/modules/12_interest_rate/reg_feb18/presolve.gms deleted file mode 100644 index c05cc488fb..0000000000 --- a/modules/12_interest_rate/reg_feb18/presolve.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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 - -pm_interest(i) = p12_interest(t,i); diff --git a/modules/12_interest_rate/reg_feb18/realization.gms b/modules/12_interest_rate/reg_feb18/realization.gms deleted file mode 100644 index d95c8dda9f..0000000000 --- a/modules/12_interest_rate/reg_feb18/realization.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 The reg_feb18 realization is the default setting, -*' in which the interest rate depends on the development state `im_development_state`, -*' which is calculated based on GDP per capita. -*' Thus, interest rates are regionally specific and dynamic over time. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/12_interest_rate/reg_feb18/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/12_interest_rate/reg_feb18/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/12_interest_rate/reg_feb18/input.gms" -$Ifi "%phase%" == "preloop" $include "./modules/12_interest_rate/reg_feb18/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/12_interest_rate/reg_feb18/presolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/12_interest_rate/reg_feb18/sets.gms b/modules/12_interest_rate/reg_feb18/sets.gms deleted file mode 100644 index ab33e8caa6..0000000000 --- a/modules/12_interest_rate/reg_feb18/sets.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - bound12 Bound for interest rate - /low, high/ -; diff --git a/modules/12_interest_rate/select_apr20/declarations.gms b/modules/12_interest_rate/select_apr20/declarations.gms new file mode 100644 index 0000000000..7bb5b7d3ee --- /dev/null +++ b/modules/12_interest_rate/select_apr20/declarations.gms @@ -0,0 +1,13 @@ +*** | (C) 2008-2025 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 + pm_interest(t_all,i) Interest rate in each region and timestep (% per yr) +* country-specific region scenario switch + p12_country_switch(iso) Switch indicating whether country is affected by interest rate scenario (1) + p12_reg_shr(t_all,i) Weighted share of region with regards to interest rate scenario of countries (1) +; diff --git a/modules/12_interest_rate/select_apr20/input.gms b/modules/12_interest_rate/select_apr20/input.gms new file mode 100644 index 0000000000..77e5c35af2 --- /dev/null +++ b/modules/12_interest_rate/select_apr20/input.gms @@ -0,0 +1,63 @@ +*** | (C) 2008-2025 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 + +$setglobal c12_interest_rate gdp_dependent + +scalars + s12_interest_lic Interest rate in low income countries (1) / 0.1 / + s12_interest_hic Interest rate in high income countries (1) / 0.04 / + s12_hist_interest_lic Historic interest rate in low income countries (1) / 0.1 / + s12_hist_interest_hic Historic interest rate in high income countries (1) / 0.04 / + s12_interest_lic_noselect Interest rate in low income countries for nonselected countries only active when regional switch activated (1) / 0.1 / + s12_interest_hic_noselect Interest rate in high income countries for nonselected countries only active when regional switch activated (1) / 0.04 / + s12_hist_interest_lic_noselect Historic interest rate in low income countries for nonselected countries only active when regional switch activated (1) / 0.1 / + s12_hist_interest_hic_noselect Historic interest rate in high income countries for nonselected countries only active when regional switch activated (1) / 0.04 / +; + +sets + select_countries12(iso) countries to be affected by chosen interest rate scenario / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +parameter f12_interest_fader(t_all) Protection scenario fader (1) +/ +$ondelim +$include "./modules/12_interest_rate/input/f12_interest_fader.csv" +$offdelim +/ +; + +$if "%c12_interest_rate%" == "coupling" parameter f12_interest_coupling(t_all) Interest rate (% per yr) +$if "%c12_interest_rate%" == "coupling" / +$if "%c12_interest_rate%" == "coupling" $ondelim +$if "%c12_interest_rate%" == "coupling" $include "./modules/12_interest_rate/input/f12_interest_rate_coupling.csv" +$if "%c12_interest_rate%" == "coupling" $offdelim +$if "%c12_interest_rate%" == "coupling" / +$if "%c12_interest_rate%" == "coupling" ; diff --git a/modules/12_interest_rate/select_apr20/preloop.gms b/modules/12_interest_rate/select_apr20/preloop.gms new file mode 100644 index 0000000000..a721714000 --- /dev/null +++ b/modules/12_interest_rate/select_apr20/preloop.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 + +* Country switch to determine countries for which chosen interest rate scenario +* shall be applied. +* In the default case, the interest rate scenario affects all countries when +* activated. +p12_country_switch(iso) = 0; +p12_country_switch(select_countries12) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p12_reg_shr(t_all,i) = sum(i_to_iso(i,iso), p12_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + +* Interest rate in countries selected in select_countries12 +$ifthen "%c12_interest_rate%" == "coupling" + p12_interest_select(t_all,i) = f12_interest_coupling(t_all); +$elseif "%c12_interest_rate%" == "gdp_dependent" + pm_interest(t_all,i) = ( (s12_interest_lic - (s12_interest_lic-s12_interest_hic) * im_development_state(t_all,i)) * f12_interest_fader(t_all) + + (s12_hist_interest_lic - (s12_hist_interest_lic-s12_hist_interest_hic) * im_development_state(t_all,i)) * (1-f12_interest_fader(t_all)) ) * p12_reg_shr(t_all,i) + + ( (s12_interest_lic_noselect - (s12_interest_lic_noselect-s12_interest_hic_noselect) * im_development_state(t_all,i)) * f12_interest_fader(t_all) + + (s12_hist_interest_lic_noselect - (s12_hist_interest_lic_noselect-s12_hist_interest_hic_noselect) * im_development_state(t_all,i) ) * (1-f12_interest_fader(t_all)) ) * (1-p12_reg_shr(t_all,i)); +$endif diff --git a/modules/12_interest_rate/select_apr20/realization.gms b/modules/12_interest_rate/select_apr20/realization.gms new file mode 100644 index 0000000000..792c3d8f78 --- /dev/null +++ b/modules/12_interest_rate/select_apr20/realization.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 The select_apr20 realization allows to flexibly choose regional +*' or global interest rates. In the default setting, the interest rate depends +*' on the development state `im_development_state`, which is calculated based +*' on GDP per capita. Thus, interest rates are regionally specific and dynamic +*' over time. +*' Alternative interest rates can be selected via the interest rate coefficients +*' (`s12_interest_lic`, `s12_interest_hic`, `s12_hist_interest_lic`, `s12_hist_interest_hic`). +*' The future interest rate policy fades in starting from 2025 until it is fully +*' in effect by 2050. +*' It is also possible to choose a global interest rate. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/12_interest_rate/select_apr20/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/12_interest_rate/select_apr20/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/12_interest_rate/select_apr20/preloop.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/13_tc/endo_jan22/declarations.gms b/modules/13_tc/endo_jan22/declarations.gms new file mode 100644 index 0000000000..b758f8b5d4 --- /dev/null +++ b/modules/13_tc/endo_jan22/declarations.gms @@ -0,0 +1,56 @@ +*** | (C) 2008-2025 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 + +positive variable + v13_tau_core(h,tautype) Agricultural land use intensity tau for conventional cropland (1) + vm_tech_cost(i) Total Annuitized costs of TC (mio. USD17MER per yr) + v13_cost_tc(i,tautype) Technical change costs per region (mio. USD17MER) + v13_tech_cost(i,tautype) Annuitized costs of TC for crops and pasture (mio. USD17MER per yr) + vm_tau(j,tautype) Overall agricultural land use intensity tau at cluster level (1) + v13_tau_consv(h,tautype) Tau for cropland within conservation priority areas (1) +; + +equations + q13_tech_cost(i, tautype) Total annuitized costs for TC (mio. USD17MER) + q13_cost_tc(i, tautype) Costs for TC (mio. USD17MER per yr) + q13_tech_cost_sum(i) Total Total annuitized costs for TC (mio. USD17MER per yr) + q13_tau(j, tautype) Overall agricultural land use intensity tau (1) + q13_tau_consv(h, tautype) Tau for cropland within conservation priority areas (1) +; + +parameters + pc13_land(i, tautype) Crop and grass land area per region (mio ha) + pcm_tau(j, tautype) Tau factor of the previous time step (1) + pc13_tau(h, tautype) Tau for conventional cropland of the previous time step (1) + pc13_tau_consv(h, tautype) Tau for cropland within conservation priority areas of the previous time step (1) + pc13_tcguess(h, tautype) Guess for annual tc rates in the next time step (1) + i13_tc_factor(t) Regression factor (USD17MER per ha) + i13_tc_exponent(t) Regression exponent (1) + p13_cropland_consv_shr(t,j) Share of cropland within conservation priority areas(1) + p13_croparea_consv_tau_factor(h) Regional tau factor for crop area conservation (1) + i13_croparea_consv_fader(t_all) Crop area conservation fader (1) + i13_tau_croparea_consv_fader(t_all) Fader for tau factor for crop area conservation (1) + p13_country_weight(i) Policy country weight per region (1) + p13_country_switch(iso) Switch indicating whether country is affected by selected cropland policy (1) + p13_country_wght_supreg(h) Policy country weight per super region (1) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov13_tau_core(t,h,tautype,type) Agricultural land use intensity tau for conventional cropland (1) + ov_tech_cost(t,i,type) Total Annuitized costs of TC (mio. USD17MER per yr) + ov13_cost_tc(t,i,tautype,type) Technical change costs per region (mio. USD17MER) + ov13_tech_cost(t,i,tautype,type) Annuitized costs of TC for crops and pasture (mio. USD17MER per yr) + ov_tau(t,j,tautype,type) Overall agricultural land use intensity tau at cluster level (1) + ov13_tau_consv(t,h,tautype,type) Tau for cropland within conservation priority areas (1) + oq13_tech_cost(t,i,tautype,type) Total annuitized costs for TC (mio. USD17MER) + oq13_cost_tc(t,i,tautype,type) Costs for TC (mio. USD17MER per yr) + oq13_tech_cost_sum(t,i,type) Total Total annuitized costs for TC (mio. USD17MER per yr) + oq13_tau(t,j,tautype,type) Overall agricultural land use intensity tau (1) + oq13_tau_consv(t,h,tautype,type) Tau for cropland within conservation priority areas (1) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/13_tc/endo_jan22/equations.gms b/modules/13_tc/endo_jan22/equations.gms new file mode 100644 index 0000000000..7b0bdc570b --- /dev/null +++ b/modules/13_tc/endo_jan22/equations.gms @@ -0,0 +1,60 @@ +*** | (C) 2008-2025 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 + +*' ![Investment-yield ratio in relation to $\tau$-factor +*' [@dietrich_forecasting_2014]](tcc_regression.png){ width=60% } +*' +*' Relative technological change costs `v13_cost_tc` are calculated as a +*' heuristically derived power function of the land use intensity `v13_tau_core` for +*' the investment-yield-ratio (see figure above) multiplied by the current +*' regional crop areas `pc13_land` (taken from previous time step) and shifted +*' 15 years into the future using the region specific interest +*' rate `pm_interest`: + +q13_cost_tc(i2, tautype) .. + v13_cost_tc(i2, tautype) =e= sum(ct, pc13_land(i2, tautype) * + i13_tc_factor(ct) * sum(supreg(h2,i2),v13_tau_core(h2,tautype))** + i13_tc_exponent(ct) * (1+pm_interest(ct,i2))**15); + + +*' The shifting is performed because investments into technological change +*' require on average 15 years of research before a yield increase is achieved, +*' but the model has to see costs and benefits concurrently in order to take the +*' right investment decisions (see also @dietrich_forecasting_2014). Investment +*' costs are scaled in relation to crop area, since a wider areal coverage means +*' typically also higher variety in biophysical conditions, which would require +*' more research for the same overall intensity boost. +*' +*' In order to get the full investments required for the desired intensification +*' the relative technological change costs are multiplied with the given +*' intensification rate. These full costs are then distributed over an infinite +*' time horizon by multiplication with the interest rate `pm_interest(i)` +*' (annuity with infinite time horizon): + +q13_tech_cost(i2, tautype) .. + v13_tech_cost(i2, tautype) =e= sum(supreg(h2,i2), v13_tau_core(h2,tautype)/pc13_tau(h2,tautype)-1) * v13_cost_tc(i2,tautype) + * sum(ct,pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +q13_tech_cost_sum(i2) .. + vm_tech_cost(i2) =e= sum(tautype, v13_tech_cost(i2, tautype)); + + +*' The overall land use intensity factor `vm_tau` is a linear combination between the +*' land use intensity factors `v13_tau_core` for regular cropland and `v13_tau_consv` +*' for cropland in conservation priority areas. + +q13_tau(j2,tautype).. + vm_tau(j2,tautype) =e= sum((ct, cell(i2,j2), supreg(h2,i2)), (1-p13_cropland_consv_shr(ct,j2)) * v13_tau_core(h2,tautype) + p13_cropland_consv_shr(ct,j2) * v13_tau_consv(h2,tautype)); + +*' `v13_tau_consv` for cropland in conservation priority areas is linked to `v13_tau_core` +*' through a multiplication factor that can lower land use intensity in +*' conservation priority areas. + +q13_tau_consv(h2,tautype)$(c13_croparea_consv_tau_increase = 1 OR sum(ct, m_year(ct)) < s13_croparea_consv_start).. + v13_tau_consv(h2,tautype) =e= p13_croparea_consv_tau_factor(h2) * v13_tau_core(h2,tautype); diff --git a/modules/13_tc/endo_jan22/input.gms b/modules/13_tc/endo_jan22/input.gms new file mode 100644 index 0000000000..ccff226873 --- /dev/null +++ b/modules/13_tc/endo_jan22/input.gms @@ -0,0 +1,89 @@ +*** | (C) 2008-2025 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 + s13_ignore_tau_historical ignore historical tau (1) or use it as lower bound (0) (binary) / 1 / + s13_max_gdp_shr Maximum tech cost as share of regional GDP / Inf / + c13_croparea_consv Switch for crop area conservation either in conservation priority areas or in a given share of the total croparea (0=no 1=yes) / 0 / + c13_croparea_consv_tau_increase Switch for tau increase on crop area conservation (0=no 1=yes) / 1 / + s13_croparea_consv_tau_factor Tau factor for crop area conservation / 0.8 / + s13_croparea_consv_tau_factor_noselect Tau factor for crop area conservation in unselected countries / 0.8 / + s13_croparea_consv_shr Share of crop area in which no endogeneous yield changes are allowed due to conservation (1) / 0 / + s13_croparea_consv_shr_noselect Share of crop area in which no endogeneous yield changes are allowed due to conservation (1) / 0 / + s13_croparea_consv_start Croparea conservation start year / 2025 / + s13_croparea_consv_target Croparea conservation target year / 2030 / +; + +sets + croparea_consv_countries13(iso) countries to be affected by croparea conservation policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +parameter fm_tau1995(h) Agricultural land use intensity tau in 1995 (1) +/ +$ondelim +$include "./modules/13_tc/input/fm_tau1995.cs4" +$offdelim +/; + +parameter f13_tcguess(h) Guess for initial annual TC rates (1) +/ +$ondelim +$include "./modules/13_tc/input/f13_tcguess.cs4" +$offdelim +/; + +$setglobal c13_tccost medium + +table f13_tc_factor(t_all,scen13) Regression factor (USD17MER per ha) +$ondelim +$include "./modules/13_tc/input/f13_tc_factor.cs3" +$offdelim +; + +table f13_tc_exponent(t_all,scen13) Regression exponent (1) +$ondelim +$include "./modules/13_tc/input/f13_tc_exponent.cs3" +$offdelim +; + +table f13_tau_historical(t_all,h) historical tau scenario (1) +$ondelim +$include "./modules/13_tc/input/f13_tau_historical.csv" +$offdelim +; + +table f13_pastr_tau_hist(t_all,h) Historical managed pasture tau (1) +$ondelim +$include "./modules/13_tc/input/f13_pastr_tau_hist.csv" +$offdelim +; diff --git a/modules/13_tc/endo_jan22/nl_fix.gms b/modules/13_tc/endo_jan22/nl_fix.gms new file mode 100644 index 0000000000..559acb6fcd --- /dev/null +++ b/modules/13_tc/endo_jan22/nl_fix.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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 + +* ### nl_fix ### + +v13_tau_core.fx(h,tautype) = max(v13_tau_core.lo(h,tautype), min(v13_tau_core.up(h,tautype), v13_tau_core.l(h,tautype))); diff --git a/modules/13_tc/endo_jan22/nl_relax.gms b/modules/13_tc/endo_jan22/nl_relax.gms new file mode 100644 index 0000000000..26c1be6133 --- /dev/null +++ b/modules/13_tc/endo_jan22/nl_relax.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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 + +* ### nl_relax ### + +v13_tau_core.l(h,tautype) = v13_tau_core.l(h,tautype) + 0.1; diff --git a/modules/13_tc/endo_jan22/nl_release.gms b/modules/13_tc/endo_jan22/nl_release.gms new file mode 100644 index 0000000000..c7b6c2d9e0 --- /dev/null +++ b/modules/13_tc/endo_jan22/nl_release.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +* ### nl_release ### + +v13_tau_core.lo(h,tautype) = pc13_tau(h,tautype); +v13_tau_core.up(h,tautype) = 2*pc13_tau(h,tautype); diff --git a/modules/13_tc/endo_jan22/postsolve.gms b/modules/13_tc/endo_jan22/postsolve.gms new file mode 100644 index 0000000000..cba08b0fde --- /dev/null +++ b/modules/13_tc/endo_jan22/postsolve.gms @@ -0,0 +1,64 @@ +*** | (C) 2008-2025 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 + +* Overall TC cost for the current timestep + +if((ord(t)>1), + pc13_tcguess(h,tautype) = (v13_tau_core.l(h,tautype)/pc13_tau(h, tautype))**(1/m_yeardiff(t)) - 1; +); + +pc13_tau(h, tautype) = v13_tau_core.l(h, tautype); +pc13_tau_consv(h, tautype) = v13_tau_consv.l(h, tautype); +pcm_tau(j, tautype) = vm_tau.l(j, tautype); + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov13_tau_core(t,h,tautype,"marginal") = v13_tau_core.m(h,tautype); + ov_tech_cost(t,i,"marginal") = vm_tech_cost.m(i); + ov13_cost_tc(t,i,tautype,"marginal") = v13_cost_tc.m(i,tautype); + ov13_tech_cost(t,i,tautype,"marginal") = v13_tech_cost.m(i,tautype); + ov_tau(t,j,tautype,"marginal") = vm_tau.m(j,tautype); + ov13_tau_consv(t,h,tautype,"marginal") = v13_tau_consv.m(h,tautype); + oq13_tech_cost(t,i,tautype,"marginal") = q13_tech_cost.m(i,tautype); + oq13_cost_tc(t,i,tautype,"marginal") = q13_cost_tc.m(i,tautype); + oq13_tech_cost_sum(t,i,"marginal") = q13_tech_cost_sum.m(i); + oq13_tau(t,j,tautype,"marginal") = q13_tau.m(j,tautype); + oq13_tau_consv(t,h,tautype,"marginal") = q13_tau_consv.m(h,tautype); + ov13_tau_core(t,h,tautype,"level") = v13_tau_core.l(h,tautype); + ov_tech_cost(t,i,"level") = vm_tech_cost.l(i); + ov13_cost_tc(t,i,tautype,"level") = v13_cost_tc.l(i,tautype); + ov13_tech_cost(t,i,tautype,"level") = v13_tech_cost.l(i,tautype); + ov_tau(t,j,tautype,"level") = vm_tau.l(j,tautype); + ov13_tau_consv(t,h,tautype,"level") = v13_tau_consv.l(h,tautype); + oq13_tech_cost(t,i,tautype,"level") = q13_tech_cost.l(i,tautype); + oq13_cost_tc(t,i,tautype,"level") = q13_cost_tc.l(i,tautype); + oq13_tech_cost_sum(t,i,"level") = q13_tech_cost_sum.l(i); + oq13_tau(t,j,tautype,"level") = q13_tau.l(j,tautype); + oq13_tau_consv(t,h,tautype,"level") = q13_tau_consv.l(h,tautype); + ov13_tau_core(t,h,tautype,"upper") = v13_tau_core.up(h,tautype); + ov_tech_cost(t,i,"upper") = vm_tech_cost.up(i); + ov13_cost_tc(t,i,tautype,"upper") = v13_cost_tc.up(i,tautype); + ov13_tech_cost(t,i,tautype,"upper") = v13_tech_cost.up(i,tautype); + ov_tau(t,j,tautype,"upper") = vm_tau.up(j,tautype); + ov13_tau_consv(t,h,tautype,"upper") = v13_tau_consv.up(h,tautype); + oq13_tech_cost(t,i,tautype,"upper") = q13_tech_cost.up(i,tautype); + oq13_cost_tc(t,i,tautype,"upper") = q13_cost_tc.up(i,tautype); + oq13_tech_cost_sum(t,i,"upper") = q13_tech_cost_sum.up(i); + oq13_tau(t,j,tautype,"upper") = q13_tau.up(j,tautype); + oq13_tau_consv(t,h,tautype,"upper") = q13_tau_consv.up(h,tautype); + ov13_tau_core(t,h,tautype,"lower") = v13_tau_core.lo(h,tautype); + ov_tech_cost(t,i,"lower") = vm_tech_cost.lo(i); + ov13_cost_tc(t,i,tautype,"lower") = v13_cost_tc.lo(i,tautype); + ov13_tech_cost(t,i,tautype,"lower") = v13_tech_cost.lo(i,tautype); + ov_tau(t,j,tautype,"lower") = vm_tau.lo(j,tautype); + ov13_tau_consv(t,h,tautype,"lower") = v13_tau_consv.lo(h,tautype); + oq13_tech_cost(t,i,tautype,"lower") = q13_tech_cost.lo(i,tautype); + oq13_cost_tc(t,i,tautype,"lower") = q13_cost_tc.lo(i,tautype); + oq13_tech_cost_sum(t,i,"lower") = q13_tech_cost_sum.lo(i); + oq13_tau(t,j,tautype,"lower") = q13_tau.lo(j,tautype); + oq13_tau_consv(t,h,tautype,"lower") = q13_tau_consv.lo(h,tautype); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/13_tc/endo_jan22/preloop.gms b/modules/13_tc/endo_jan22/preloop.gms new file mode 100644 index 0000000000..b0f0079536 --- /dev/null +++ b/modules/13_tc/endo_jan22/preloop.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2025 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 + +loop(t, + if(m_year(t) <= sm_fix_SSP2, + i13_tc_factor(t) = f13_tc_factor(t,"medium"); + i13_tc_exponent(t) = f13_tc_exponent(t,"medium"); + else + i13_tc_factor(t) = f13_tc_factor(t,"%c13_tccost%"); + i13_tc_exponent(t) = f13_tc_exponent(t,"%c13_tccost%"); + ); +); + +pc13_tau(h,"crop") = fm_tau1995(h); +pc13_tau(h,"pastr") = f13_pastr_tau_hist("y1995",h); +pc13_tcguess(h,tautype) = f13_tcguess(h); + + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p13_country_switch(iso) = 0; +p13_country_switch(croparea_consv_countries13) = 1; + +** Trajectory for implementation of croparea conservation +* sigmoidal interpolation between 2020 and target year +m_sigmoid_time_interpol(i13_croparea_consv_fader,s13_croparea_consv_start,s13_croparea_consv_target,0,1); + +m_sigmoid_time_interpol(i13_tau_croparea_consv_fader,s13_croparea_consv_start,s13_croparea_consv_target,1,s13_croparea_consv_tau_factor); + diff --git a/modules/13_tc/endo_jan22/presolve.gms b/modules/13_tc/endo_jan22/presolve.gms new file mode 100644 index 0000000000..99b1a42df8 --- /dev/null +++ b/modules/13_tc/endo_jan22/presolve.gms @@ -0,0 +1,81 @@ +*** | (C) 2008-2025 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 + + +pc13_land(i,"pastr") = sum(cell(i,j),pcm_land(j,"past")); +pc13_land(i,"crop") = sum(cell(i,j),pcm_land(j,"crop")); + +if (sum(sameas(t_past,t),1) = 1 AND s13_ignore_tau_historical = 0, + v13_tau_core.lo(h,"pastr") = f13_pastr_tau_hist(t,h); + v13_tau_core.lo(h,"crop") = f13_tau_historical(t,h); +else + v13_tau_core.lo(h, tautype) = pc13_tau(h, tautype); +); + + v13_tau_core.up(h,tautype) = 2 * pc13_tau(h,tautype); + +if(m_year(t) > sm_fix_SSP2 AND s13_max_gdp_shr <> Inf, + +* We constrain tech cost to a defined share of regional GDP to avoid unrealistically +* high endogenous tech investments + vm_tech_cost.up(i) = + sum((i_to_iso(i,iso),ct), im_gdp_pc_ppp_iso(ct,iso) * im_pop_iso(ct,iso)) * s13_max_gdp_shr; + +* We set the initial solving basis for the tech cost to its upper bound to support the solver in finding +* a proper solution. Without such initial values, the model leave tech cost at 0 and as such ignore tau +* as an efficient part of the optimal solution. + vm_tech_cost.l(i) = vm_tech_cost.up(i); + +); + +*** Share of cropland within conservation priority area +p13_cropland_consv_shr(t,j) = 0; + +if(c13_croparea_consv = 1, +* the cropland area within conservation priority areas is provided by the interface `pm_land_conservation` + p13_cropland_consv_shr(t,j)$(pcm_land(j,"crop") > 0) = sum(consv_type, pm_land_conservation(t,j,"crop",consv_type))/pcm_land(j,"crop"); + p13_cropland_consv_shr(t,j)$(p13_cropland_consv_shr(t,j) > 1) = 1; + +* The following lines allow to freely chose a given share of the total cropland +* area that should be subject to conservation management with a lower land use intensity. + if(s13_croparea_consv_shr > 0 AND m_year(t) >= s13_croparea_consv_start, +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. + p13_country_weight(i) = sum(i_to_iso(i,iso), p13_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); + p13_cropland_consv_shr(t,j) = i13_croparea_consv_fader(t) * + (s13_croparea_consv_shr * sum(cell(i,j), p13_country_weight(i)) + + s13_croparea_consv_shr_noselect * sum(cell(i,j), 1-p13_country_weight(i))); + + ); + +); + +* ISO country weights are calculated based on the available cropland area in each country +p13_country_wght_supreg(h) = sum((i_to_iso(i,iso), supreg(h,i)), p13_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum((i_to_iso(i,iso), supreg(h,i)), pm_avl_cropland_iso(iso)); + +* Country-weighted tau reduction factor for conservation land +p13_croparea_consv_tau_factor(h) = (s13_croparea_consv_tau_factor * p13_country_wght_supreg(h) + + s13_croparea_consv_tau_factor_noselect * (1-p13_country_wght_supreg(h))); + +if (ord(t) = 1, + pc13_tau_consv(h,tautype) = p13_croparea_consv_tau_factor(h) * pc13_tau(h,"crop"); +elseif c13_croparea_consv_tau_increase = 0 AND m_year(t) >= s13_croparea_consv_start, + v13_tau_consv.fx(h,tautype) = pc13_tau_consv(h,tautype); +); + + +* educated guess for tau levels: +if(ord(t) = 1, + v13_tau_core.l(h,tautype) = pc13_tau(h,tautype); + v13_tau_consv.l(h,tautype) = pc13_tau_consv(h,tautype); + vm_tau.l(j,tautype) = sum((cell(i,j), supreg(h,i)),(1-p13_cropland_consv_shr(t,j)) * v13_tau_core.l(h,tautype) + p13_cropland_consv_shr(t,j) * v13_tau_consv.l(h,tautype)); + pcm_tau(j,tautype) = vm_tau.l(j,tautype); +else + v13_tau_core.l(h,tautype) = pc13_tau(h,tautype)*(1+pc13_tcguess(h,tautype))**m_yeardiff(t); + v13_tau_consv.l(h,tautype) = p13_croparea_consv_tau_factor(h) * v13_tau_core.l(h,tautype); +); diff --git a/modules/13_tc/endo_jan22/realization.gms b/modules/13_tc/endo_jan22/realization.gms new file mode 100644 index 0000000000..5043498cd8 --- /dev/null +++ b/modules/13_tc/endo_jan22/realization.gms @@ -0,0 +1,55 @@ +*** | (C) 2008-2025 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 The endo realization stands for endogenous implementation of +*' technological change and land use intensification. The intensification rates +*' are calculated endogenously based on an interplay between land use intensity +*' $\tau$ and technological change costs (as shown schematically in the figure +*' below). This module realization contains the implementation as described +*' in @dietrich_forecasting_2014 with two minor modifications: +*' +*' * rates of previous investment decisions which still have to be paid are +*' added to the technological change costs +*' * the planning horizon for investments is unified over all investments in +*' the model. +*' +*' ![Implementation of technological change in MAgPIE +*' [@dietrich_forecasting_2014]](tc_schematic.png){ width=60% } +*' +*' Initial land use intensity $\tau$ values for the year 2000 come from +*' @dietrich_measuring_2012 and are shown below. +*' +*' ![$\tau$-factors in world regions & global (GLO) for the year 2000. +*' [@dietrich_measuring_2012]](tau_regional.png){ width=60% } +*' +*' Investments into technological change (TC) trigger land use intensification +*' ($\tau$) which triggers in turn yields increases. How much intensification +*' can be triggered by an investment, depends on the investment-yield ratio, +*' which in turn depends on the current agricultural land use intensity. The +*' higher the current intensity level, the more expensive the additional +*' intensification will become. The interaction between land use intensity and +*' production costs per area as shown in the schematic is not covered by this +*' module and can be found instead in [38_factor_costs]. + +*' @limitations This module significantly reduces the overall computational +*' performance of the model since these endogenous calculations are highly +*' computational intensive. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/13_tc/endo_jan22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/13_tc/endo_jan22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/13_tc/endo_jan22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/13_tc/endo_jan22/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/13_tc/endo_jan22/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/13_tc/endo_jan22/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/13_tc/endo_jan22/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/13_tc/endo_jan22/postsolve.gms" +$Ifi "%phase%" == "nl_fix" $include "./modules/13_tc/endo_jan22/nl_fix.gms" +$Ifi "%phase%" == "nl_release" $include "./modules/13_tc/endo_jan22/nl_release.gms" +$Ifi "%phase%" == "nl_relax" $include "./modules/13_tc/endo_jan22/nl_relax.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/13_tc/endo_jan22/scaling.gms b/modules/13_tc/endo_jan22/scaling.gms new file mode 100644 index 0000000000..6b174c52da --- /dev/null +++ b/modules/13_tc/endo_jan22/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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_tech_cost.scale(i) = 10e3; +v13_cost_tc.scale(i,tautype) = 10e6; +v13_tech_cost.scale(i,tautype) = 10e3; diff --git a/modules/13_tc/endo_jan22/sets.gms b/modules/13_tc/endo_jan22/sets.gms new file mode 100644 index 0000000000..97ee7b8043 --- /dev/null +++ b/modules/13_tc/endo_jan22/sets.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2025 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 + + scen13 tc cost scenario + /low, medium, high/ + + tautype tc type + / pastr, crop / + +; + +*** EOF sets.gms *** diff --git a/modules/13_tc/endo_jun18/tau_regional.png b/modules/13_tc/endo_jan22/tau_regional.png similarity index 100% rename from modules/13_tc/endo_jun18/tau_regional.png rename to modules/13_tc/endo_jan22/tau_regional.png diff --git a/modules/13_tc/endo_jun18/tc_schematic.png b/modules/13_tc/endo_jan22/tc_schematic.png similarity index 100% rename from modules/13_tc/endo_jun18/tc_schematic.png rename to modules/13_tc/endo_jan22/tc_schematic.png diff --git a/modules/13_tc/endo_jun18/tcc_regression.png b/modules/13_tc/endo_jan22/tcc_regression.png similarity index 100% rename from modules/13_tc/endo_jun18/tcc_regression.png rename to modules/13_tc/endo_jan22/tcc_regression.png diff --git a/modules/13_tc/endo_jun18/declarations.gms b/modules/13_tc/endo_jun18/declarations.gms deleted file mode 100644 index 402fbc47e9..0000000000 --- a/modules/13_tc/endo_jun18/declarations.gms +++ /dev/null @@ -1,41 +0,0 @@ -*** | (C) 2008-2019 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 - -positive variable - vm_tau(i) Agricultural land use intensity tau (1) - vm_tech_cost(i) Costs of TC (mio. USD05PPP per yr) - v13_cost_tc(i) Technical change costs per region (mio. USD05PPP) - v13_tech_cost_annuity(i) Annuity costs of TC (mio. USD05PPP per yr) -; - -equations - q13_tech_cost(i) Total costs for TC (mio. USD05PPP) - q13_cost_tc(i) Costs for TC (mio. USD05PPP per yr) - q13_tech_cost_annuity(i) Annuity costs for TC (mio. USD05PPP per yr) -; - -parameters - pc13_land(i) Crop land area per region (mio ha) - pc13_tau(i) Tau factor of the previous time step (1) - p13_tech_cost_past(t,i) Costs for TC from past (mio. USD05PPP per yr) - pc13_tech_cost_past(i) Current costs for TC from past (mio. USD05PPP per yr) - pc13_tcguess(i) Guess for annual tc rates in the next time step (1) - i13_tc_factor(t,i) Regression factor (USD05PPP per ha) - i13_tc_exponent(t,i) Regression exponent (1) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_tau(t,i,type) Agricultural land use intensity tau (1) - ov_tech_cost(t,i,type) Costs of TC (mio. USD05PPP per yr) - ov13_cost_tc(t,i,type) Technical change costs per region (mio. USD05PPP) - ov13_tech_cost_annuity(t,i,type) Annuity costs of TC (mio. USD05PPP per yr) - oq13_tech_cost(t,i,type) Total costs for TC (mio. USD05PPP) - oq13_cost_tc(t,i,type) Costs for TC (mio. USD05PPP per yr) - oq13_tech_cost_annuity(t,i,type) Annuity costs for TC (mio. USD05PPP per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/13_tc/endo_jun18/equations.gms b/modules/13_tc/endo_jun18/equations.gms deleted file mode 100644 index e1033e1c11..0000000000 --- a/modules/13_tc/endo_jun18/equations.gms +++ /dev/null @@ -1,47 +0,0 @@ -*** | (C) 2008-2019 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 - -*' ![Investment-yield ratio in relation to $\tau$-factor -*' [@dietrich_forecasting_2014]](tcc_regression.png){ width=60% } -*' -*' Relative technological change costs `v13_cost_tc` are calculated as a -*' heuristically derived power function of the land use intensity `vm_tau` for -*' the investment-yield-ratio (see figure above) multiplied by the current -*' regional crop areas `pc13_land` (taken from previous time step) and shifted -*' 15 years into the future using the region specific interest -*' rate `pm_interest`: - -q13_cost_tc(i2) .. - v13_cost_tc(i2) =e= sum(ct, pc13_land(i2) * i13_tc_factor(ct,i2) - * vm_tau(i2)**i13_tc_exponent(ct,i2) - * (1+pm_interest(i2))**15); - -*' The shifting is performed because investments into technological change -*' require on average 15 years of research before a yield increase is achieved, -*' but the model has to see costs and benefits concurrently in order to take the -*' right investment decisions (see also @dietrich_forecasting_2014). Investment -*' costs are scaled in relation to crop area, since a wider areal coverage means -*' typically also higher variety in biophysical conditions, which would require -*' more research for the same overall intensity boost. -*' -*' In order to get the full investments required for the desired intensification -*' the relative technological change costs are multiplied with the given -*' intensification rate. These full costs are then distributed over an infinite -*' time horizon by multiplication with the interest rate `pm_interest(i)` -*' (annuity with infinite time horizon): - -q13_tech_cost_annuity(i2) .. - v13_tech_cost_annuity(i2) =e= (vm_tau(i2)/pc13_tau(i2)-1) * v13_cost_tc(i2) - * pm_interest(i2)/(1+pm_interest(i2)); - -*' Additionally, the technological change costs coming from past investment -*' decisions are added to the technological change costs of the current period: - -q13_tech_cost(i2) .. - vm_tech_cost(i2) =e= v13_tech_cost_annuity(i2) + pc13_tech_cost_past(i2); diff --git a/modules/13_tc/endo_jun18/input.gms b/modules/13_tc/endo_jun18/input.gms deleted file mode 100644 index 50a262a6ea..0000000000 --- a/modules/13_tc/endo_jun18/input.gms +++ /dev/null @@ -1,35 +0,0 @@ -*** | (C) 2008-2019 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 - - -parameter fm_tau1995(i) Agricultural land use intensity tau in 1995 (1) -/ -$ondelim -$include "./modules/13_tc/input/fm_tau1995.cs4" -$offdelim -/; - -parameter f13_tcguess(i) Guess for initial annual TC rates (1) -/ -$ondelim -$include "./modules/13_tc/input/f13_tcguess.cs4" -$offdelim -/; - -$setglobal c13_tccost medium - -table f13_tc_factor(t_all,scen13) Regression factor (USD05PPP per ha) -$ondelim -$include "./modules/13_tc/input/f13_tc_factor.cs3" -$offdelim -; - -table f13_tc_exponent(t_all,scen13) Regression exponent (1) -$ondelim -$include "./modules/13_tc/input/f13_tc_exponent.cs3" -$offdelim -; diff --git a/modules/13_tc/endo_jun18/nl_fix.gms b/modules/13_tc/endo_jun18/nl_fix.gms deleted file mode 100644 index eb8ded6714..0000000000 --- a/modules/13_tc/endo_jun18/nl_fix.gms +++ /dev/null @@ -1,10 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_fix ### - -vm_tau.fx(i) = max(vm_tau.lo(i), min(vm_tau.up(i), vm_tau.l(i))); diff --git a/modules/13_tc/endo_jun18/nl_relax.gms b/modules/13_tc/endo_jun18/nl_relax.gms deleted file mode 100644 index a5d317e668..0000000000 --- a/modules/13_tc/endo_jun18/nl_relax.gms +++ /dev/null @@ -1,10 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_relax ### - -vm_tau.l(i) = vm_tau.l(i) + 0.1; diff --git a/modules/13_tc/endo_jun18/nl_release.gms b/modules/13_tc/endo_jun18/nl_release.gms deleted file mode 100644 index 8c3cd5e3a0..0000000000 --- a/modules/13_tc/endo_jun18/nl_release.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_release ### - -vm_tau.lo(i) = pc13_tau(i); -vm_tau.up(i) = 2*pc13_tau(i); diff --git a/modules/13_tc/endo_jun18/postsolve.gms b/modules/13_tc/endo_jun18/postsolve.gms deleted file mode 100644 index 7a91ea5d1d..0000000000 --- a/modules/13_tc/endo_jun18/postsolve.gms +++ /dev/null @@ -1,46 +0,0 @@ -*** | (C) 2008-2019 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 - -p13_tech_cost_past(t2,i) = p13_tech_cost_past(t2,i) + v13_tech_cost_annuity.l(i); - -if((ord(t)>1), - pc13_tcguess(i) = (vm_tau.l(i)/pc13_tau(i))**(1/m_yeardiff(t)) - 1; -); - -pc13_tau(i) = vm_tau.l(i); - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_tau(t,i,"marginal") = vm_tau.m(i); - ov_tech_cost(t,i,"marginal") = vm_tech_cost.m(i); - ov13_cost_tc(t,i,"marginal") = v13_cost_tc.m(i); - ov13_tech_cost_annuity(t,i,"marginal") = v13_tech_cost_annuity.m(i); - oq13_tech_cost(t,i,"marginal") = q13_tech_cost.m(i); - oq13_cost_tc(t,i,"marginal") = q13_cost_tc.m(i); - oq13_tech_cost_annuity(t,i,"marginal") = q13_tech_cost_annuity.m(i); - ov_tau(t,i,"level") = vm_tau.l(i); - ov_tech_cost(t,i,"level") = vm_tech_cost.l(i); - ov13_cost_tc(t,i,"level") = v13_cost_tc.l(i); - ov13_tech_cost_annuity(t,i,"level") = v13_tech_cost_annuity.l(i); - oq13_tech_cost(t,i,"level") = q13_tech_cost.l(i); - oq13_cost_tc(t,i,"level") = q13_cost_tc.l(i); - oq13_tech_cost_annuity(t,i,"level") = q13_tech_cost_annuity.l(i); - ov_tau(t,i,"upper") = vm_tau.up(i); - ov_tech_cost(t,i,"upper") = vm_tech_cost.up(i); - ov13_cost_tc(t,i,"upper") = v13_cost_tc.up(i); - ov13_tech_cost_annuity(t,i,"upper") = v13_tech_cost_annuity.up(i); - oq13_tech_cost(t,i,"upper") = q13_tech_cost.up(i); - oq13_cost_tc(t,i,"upper") = q13_cost_tc.up(i); - oq13_tech_cost_annuity(t,i,"upper") = q13_tech_cost_annuity.up(i); - ov_tau(t,i,"lower") = vm_tau.lo(i); - ov_tech_cost(t,i,"lower") = vm_tech_cost.lo(i); - ov13_cost_tc(t,i,"lower") = v13_cost_tc.lo(i); - ov13_tech_cost_annuity(t,i,"lower") = v13_tech_cost_annuity.lo(i); - oq13_tech_cost(t,i,"lower") = q13_tech_cost.lo(i); - oq13_cost_tc(t,i,"lower") = q13_cost_tc.lo(i); - oq13_tech_cost_annuity(t,i,"lower") = q13_tech_cost_annuity.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/13_tc/endo_jun18/preloop.gms b/modules/13_tc/endo_jun18/preloop.gms deleted file mode 100644 index 19f8499459..0000000000 --- a/modules/13_tc/endo_jun18/preloop.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - -$ifthen "%c13_tccost%" == "mixed" -i13_tc_factor(t,i) = sum(t_to_i_to_dev("y1995",i,dev), sum(scen13_to_dev(scen13,dev), f13_tc_factor(t,scen13))); -i13_tc_exponent(t,i) = sum(t_to_i_to_dev("y1995",i,dev), sum(scen13_to_dev(scen13,dev), f13_tc_exponent(t,scen13))); -$else -i13_tc_factor(t,i) = f13_tc_factor(t,"%c13_tccost%"); -i13_tc_exponent(t,i) = f13_tc_exponent(t,"%c13_tccost%"); -$endif - -pc13_tau(i) = fm_tau1995(i); -pc13_tcguess(i) = f13_tcguess(i); - -p13_tech_cost_past(t,i) = 0; diff --git a/modules/13_tc/endo_jun18/presolve.gms b/modules/13_tc/endo_jun18/presolve.gms deleted file mode 100644 index 27a8c3469e..0000000000 --- a/modules/13_tc/endo_jun18/presolve.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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_tau.lo(i) = pc13_tau(i); -vm_tau.up(i) = 2*pc13_tau(i); - -* educated guess for vm_tau.l: -vm_tau.l(i) = pc13_tau(i)*(1+pc13_tcguess(i))**m_yeardiff(t); - -vm_tech_cost.up(i) = 10e9; - -pc13_tech_cost_past(i) = p13_tech_cost_past(t,i); - -pc13_land(i) = sum(cell(i,j),pcm_land(j,"crop")); diff --git a/modules/13_tc/endo_jun18/realization.gms b/modules/13_tc/endo_jun18/realization.gms deleted file mode 100644 index 0ded9b3638..0000000000 --- a/modules/13_tc/endo_jun18/realization.gms +++ /dev/null @@ -1,55 +0,0 @@ -*** | (C) 2008-2019 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 The endo realization stands for endogenous implementation of -*' technological change and land use intensification. The intensification rates -*' are calculated endogenously based on an interplay between land use intensity -*' $\tau$ and technological change costs (as shown schematically in the figure -*' below). This module realization contains the implementation as described -*' in @dietrich_forecasting_2014 with two minor modifications: -*' -*' * rates of previous investment decisions which still have to be paid are -*' added to the technological change costs -*' * the planning horizon for investments is unified over all investments in -*' the model. -*' -*' ![Implementation of technological change in MAgPIE -*' [@dietrich_forecasting_2014]](tc_schematic.png){ width=60% } -*' -*' Initial land use intensity $\tau$ values for the year 2000 come from -*' @dietrich_measuring_2012 and are shown below. -*' -*' ![$\tau$-factors in world regions & global (GLO) for the year 2000. -*' [@dietrich_measuring_2012]](tau_regional.png){ width=60% } -*' -*' Investments into technological change (TC) trigger land use intensification -*' ($\tau$) which triggers in turn yields increases. How much intensification -*' can be triggered by an investment, depends on the investment-yield ratio, -*' which in turn depends on the current agricultural land use intensity. The -*' higher the current intensity level, the more expensive the additional -*' intensification will become. The interaction between land use intensity and -*' production costs per area as shown in the schematic is not covered by this -*' module and can be found instead in [38_factor_costs]. - -*' @limitations This module significantly reduces the overall computational -*' performance of the model since these endogenous calculations are highly -*' computational intensive. - - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/13_tc/endo_jun18/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/13_tc/endo_jun18/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/13_tc/endo_jun18/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/13_tc/endo_jun18/equations.gms" -$Ifi "%phase%" == "scaling" $include "./modules/13_tc/endo_jun18/scaling.gms" -$Ifi "%phase%" == "preloop" $include "./modules/13_tc/endo_jun18/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/13_tc/endo_jun18/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/13_tc/endo_jun18/postsolve.gms" -$Ifi "%phase%" == "nl_fix" $include "./modules/13_tc/endo_jun18/nl_fix.gms" -$Ifi "%phase%" == "nl_release" $include "./modules/13_tc/endo_jun18/nl_release.gms" -$Ifi "%phase%" == "nl_relax" $include "./modules/13_tc/endo_jun18/nl_relax.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/13_tc/endo_jun18/scaling.gms b/modules/13_tc/endo_jun18/scaling.gms deleted file mode 100644 index 6c3caad7e8..0000000000 --- a/modules/13_tc/endo_jun18/scaling.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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 - -v13_cost_tc.scale(i) = 10e6; -v13_tech_cost_annuity.scale(i) = 10e3; diff --git a/modules/13_tc/endo_jun18/sets.gms b/modules/13_tc/endo_jun18/sets.gms deleted file mode 100644 index dee5edb3e5..0000000000 --- a/modules/13_tc/endo_jun18/sets.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - - scen13 tc cost scenario - /low, medium, high/ - - scen13_to_dev(scen13,dev) mapping between tc cost scenarios and development stages - / high . (lic) - medium . (mic) - low . (hic) / -; - -*** EOF sets.gms *** diff --git a/modules/13_tc/exo/declarations.gms b/modules/13_tc/exo/declarations.gms new file mode 100644 index 0000000000..51acfd1aa7 --- /dev/null +++ b/modules/13_tc/exo/declarations.gms @@ -0,0 +1,39 @@ +*** | (C) 2008-2025 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 + +positive variable + vm_tau(j,tautype) Overall agricultural land use intensity tau at cluster level (1) + vm_tech_cost(i) Costs of TC (mio. USD17MER per yr) +; + +parameters + p13_cost_tc(i,tautype) Technical change costs per region (mio. USD17MER) + pc13_land(i,tautype) Crop and grass land area per region (mio ha) + pcm_tau(j,tautype) Tau factor of the previous time step (1) + pc13_tau(h, tautype) Tau for conventional cropland of the previous time step (1) + pc13_tau_consv(h, tautype) Tau for cropland within conservation priority areas of the previous time step (1) + i13_tc_factor(t) Regression factor (USD17MER per ha) + i13_tc_exponent(t) Regression exponent (1) + p13_tech_cost(i,tautype) Annuitized costs of TC for crops and pasture (mio. USD17MER per yr) + p13_tau_core(h,tautype) Agricultural land use intensity tau for conventional cropland (1) + p13_tau_consv(h,tautype) Tau for cropland within conservation priority areas (1) + p13_cropland_consv_shr(t,j) Share of cropland within conservation priority areas(1) + p13_croparea_consv_tau_factor(h) Regional tau factor for crop area conservation (1) + i13_croparea_consv_fader(t_all) Crop area conservation fader (1) + i13_tau_croparea_consv_fader(t_all) Fader for tau factor for crop area conservation (1) + p13_country_weight(i) Policy country weight per region (1) + p13_country_switch(iso) Switch indicating whether country is affected by selected cropland policy (1) + p13_country_wght_supreg(h) Policy country weight per super region (1) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_tau(t,j,tautype,type) Overall agricultural land use intensity tau at cluster level (1) + ov_tech_cost(t,i,type) Costs of TC (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/13_tc/exo/input.gms b/modules/13_tc/exo/input.gms new file mode 100644 index 0000000000..0139377264 --- /dev/null +++ b/modules/13_tc/exo/input.gms @@ -0,0 +1,81 @@ +*** | (C) 2008-2025 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 + c13_croparea_consv Switch for crop area conservation either in conservation priority areas or in a given share of the total croparea (0=no 1=yes) / 0 / + c13_croparea_consv_tau_increase Switch for tau increase on crop area conservation (0=no 1=yes) / 1 / + s13_croparea_consv_tau_factor Tau factor for crop area conservation / 0.8 / + s13_croparea_consv_tau_factor_noselect Tau factor for crop area conservation in unselected countries / 0.8 / + s13_croparea_consv_shr Share of crop area in which no endogeneous yield changes are allowed due to conservation (1) / 0 / + s13_croparea_consv_shr_noselect Share of crop area in which no endogeneous yield changes are allowed due to conservation (1) / 0 / + s13_croparea_consv_start Croparea conservation start year / 2025 / + s13_croparea_consv_target Croparea conservation target year / 2030 / +; + +sets + croparea_consv_countries13(iso) countries to be affected by croparea conservation policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +parameter fm_tau1995(h) Agricultural land use intensity tau in 1995 (1) +/ +$ondelim +$include "./modules/13_tc/input/fm_tau1995.cs4" +$offdelim +/; + +$setglobal c13_tccost medium + +table f13_tc_factor(t_all,scen13) Regression factor (USD17MER per ha) +$ondelim +$include "./modules/13_tc/input/f13_tc_factor.cs3" +$offdelim +; + +table f13_tc_exponent(t_all,scen13) Regression exponent (1) +$ondelim +$include "./modules/13_tc/input/f13_tc_exponent.cs3" +$offdelim +; + + +table f13_tau_scenario(t_all,h,tautype) tau scenario (1) +$ondelim +$include "./modules/13_tc/input/f13_tau_scenario.csv" +$offdelim +; + +table f13_pastr_tau_hist(t_all,h) Historical managed pasture tau (1) +$ondelim +$include "./modules/13_tc/input/f13_pastr_tau_hist.csv" +$offdelim +; diff --git a/modules/13_tc/exo/not_used.txt b/modules/13_tc/exo/not_used.txt new file mode 100644 index 0000000000..0d06794292 --- /dev/null +++ b/modules/13_tc/exo/not_used.txt @@ -0,0 +1,3 @@ +name,type,reason +im_pop_iso,input,questionnaire +im_gdp_pc_ppp_iso,input,questionnaire diff --git a/modules/13_tc/exo/postsolve.gms b/modules/13_tc/exo/postsolve.gms new file mode 100644 index 0000000000..a9d8487f94 --- /dev/null +++ b/modules/13_tc/exo/postsolve.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + +pcm_tau(j, tautype) = vm_tau.l(j, tautype); +pc13_tau(h, tautype) = p13_tau_core(h, tautype); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_tau(t,j,tautype,"marginal") = vm_tau.m(j,tautype); + ov_tech_cost(t,i,"marginal") = vm_tech_cost.m(i); + ov_tau(t,j,tautype,"level") = vm_tau.l(j,tautype); + ov_tech_cost(t,i,"level") = vm_tech_cost.l(i); + ov_tau(t,j,tautype,"upper") = vm_tau.up(j,tautype); + ov_tech_cost(t,i,"upper") = vm_tech_cost.up(i); + ov_tau(t,j,tautype,"lower") = vm_tau.lo(j,tautype); + ov_tech_cost(t,i,"lower") = vm_tech_cost.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/13_tc/exo/preloop.gms b/modules/13_tc/exo/preloop.gms new file mode 100644 index 0000000000..52b5c914db --- /dev/null +++ b/modules/13_tc/exo/preloop.gms @@ -0,0 +1,31 @@ +*** | (C) 2008-2025 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 + +loop(t, + if(m_year(t) <= sm_fix_SSP2, + i13_tc_factor(t) = f13_tc_factor(t,"medium"); + i13_tc_exponent(t) = f13_tc_exponent(t,"medium"); + else + i13_tc_factor(t) = f13_tc_factor(t,"%c13_tccost%"); + i13_tc_exponent(t) = f13_tc_exponent(t,"%c13_tccost%"); + ); +); + +pc13_tau(h,"crop") = fm_tau1995(h); +pc13_tau(h,"pastr") = f13_pastr_tau_hist("y1995",h); + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p13_country_switch(iso) = 0; +p13_country_switch(croparea_consv_countries13) = 1; + +** Trajectory for implementation of croparea conservation +* sigmoidal interpolation between 2020 and target year +m_sigmoid_time_interpol(i13_croparea_consv_fader,s13_croparea_consv_start,s13_croparea_consv_target,0,1); + +m_sigmoid_time_interpol(i13_tau_croparea_consv_fader,s13_croparea_consv_start,s13_croparea_consv_target,1,s13_croparea_consv_tau_factor); + diff --git a/modules/13_tc/exo/presolve.gms b/modules/13_tc/exo/presolve.gms new file mode 100644 index 0000000000..b252b0a054 --- /dev/null +++ b/modules/13_tc/exo/presolve.gms @@ -0,0 +1,78 @@ +*** | (C) 2008-2025 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 + +pc13_land(i,"pastr") = sum(cell(i,j),pcm_land(j,"past")); +pc13_land(i,"crop") = sum(cell(i,j),pcm_land(j,"crop")); + +*** Share of cropland within conservation priority area +p13_cropland_consv_shr(t,j) = 0; + +if(c13_croparea_consv = 1, +* the cropland area within conservation priority areas is provided by the interface `pm_land_conservation` + p13_cropland_consv_shr(t,j)$(pcm_land(j,"crop") > 0) = sum(consv_type, pm_land_conservation(t,j,"crop",consv_type))/pcm_land(j,"crop"); + p13_cropland_consv_shr(t,j)$(p13_cropland_consv_shr(t,j) > 1) = 1; + +* The following lines allow to freely chose a given share of the total cropland +* area that should be subject to conservation management with a lower land use intensity. + if(s13_croparea_consv_shr > 0 AND m_year(t) >= s13_croparea_consv_start, +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. + p13_country_weight(i) = sum(i_to_iso(i,iso), p13_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); + p13_cropland_consv_shr(t,j) = i13_croparea_consv_fader(t) * + (s13_croparea_consv_shr * sum(cell(i,j), p13_country_weight(i)) + + s13_croparea_consv_shr_noselect * sum(cell(i,j), 1-p13_country_weight(i))); + + ); + +); + +* ISO country weights are calculated based on the available cropland area in each country +p13_country_wght_supreg(h) = sum((i_to_iso(i,iso), supreg(h,i)), p13_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum((i_to_iso(i,iso), supreg(h,i)), pm_avl_cropland_iso(iso)); + +* Country-weighted tau reduction factor for conservation land +p13_croparea_consv_tau_factor(h) = (s13_croparea_consv_tau_factor * p13_country_wght_supreg(h) + + s13_croparea_consv_tau_factor_noselect * (1-p13_country_wght_supreg(h))); + + +if (smin((h,tautype), f13_tau_scenario(t,h,tautype)) <= 0, + abort "tau value of 0 detected in at least one region!"; +); + +p13_tau_core(h,tautype) = f13_tau_scenario(t,h,tautype); + +* p13_tau_consv is linked to p13_tau_core through the +* reduction factor for conservation land +if (c13_croparea_consv_tau_increase = 1 OR m_year(t) < s13_croparea_consv_start, + p13_tau_consv(h,tautype) = p13_croparea_consv_tau_factor(h) * f13_tau_scenario(t,h,tautype); + pc13_tau_consv(h,tautype) = p13_tau_consv(h,tautype); +elseif c13_croparea_consv_tau_increase = 0 AND m_year(t) >= s13_croparea_consv_start, + p13_tau_consv(h,tautype) = pc13_tau_consv(h,tautype); +); + +* The overall land use intensity factor `vm_tau` is a linear combination between the +* land use intensity factors `p13_tau` for regular cropland and `p13_tau_consv` +* for cropland in conservation priority areas. + +vm_tau.fx(j,tautype) = sum((cell(i,j), supreg(h,i)), (1-p13_cropland_consv_shr(t,j)) * p13_tau_core(h,tautype) + p13_cropland_consv_shr(t,j) * p13_tau_consv(h,tautype)); + +* The costs are shifted over 15 years (exponent 15) to reflect the average +* time it takes investments in tc to pay off. + +p13_cost_tc(i,tautype) = pc13_land(i,tautype) * i13_tc_factor(t) + * sum(supreg(h,i), p13_tau_core(h,tautype))**i13_tc_exponent(t) + * (1+pm_interest(t,i))**15; + +p13_tech_cost(i,tautype) = (sum(supreg(h,i),p13_tau_core(h,tautype)/pc13_tau(h,tautype))-1) * p13_cost_tc(i,tautype) + * pm_interest(t,i)/(1+pm_interest(t,i)); + +vm_tech_cost.fx(i) = sum(tautype, p13_tech_cost(i,tautype)); + +if(ord(t) = 1, + pc13_tau_consv(h,tautype) = p13_croparea_consv_tau_factor(h) * pc13_tau(h,"crop"); + pcm_tau(j,tautype) = sum((cell(i,j), supreg(h,i)), (1-p13_cropland_consv_shr(t,j)) * pc13_tau(h,tautype) + p13_cropland_consv_shr(t,j) * pc13_tau_consv(h,tautype)); +); diff --git a/modules/13_tc/exo/realization.gms b/modules/13_tc/exo/realization.gms new file mode 100644 index 0000000000..d9d1a48c74 --- /dev/null +++ b/modules/13_tc/exo/realization.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2025 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 The exo realization stands for exogenous implementation of +*' technological change and land use intensification. The equations and structure +*' are similar to the endo realization, with the difference that all variables are fixed. +*' The idea of exo realization is to prescribe intensification rates based +*' on model runs with the endo realization. For instance, the endogenously derived +*' intensification rates for a SSP2 baseline run can be used as exogenous input for +*' a SSP2 policy run. The tau function in the magpie4 R package can be used to +*' generate the file f13_tau_scenario.csv, which is region and time specific, based on +*' an existing model run: tau(gdx,file="f13_tau_scenario.csv"). This file should then be +*' copied to the input folder (overwrite the existing dummy file f13_tau_scenario.csv). + + +*' @limitations TC is not allowed to adapt to the given demand requirements.This realization +*' might result in infeasibilities if the scenario setup diverges too much from the scenario +*' setup used to generate the file f13_tau_scenario.csv. If the pressure in the system is +*' too high, the tau factors provided in the file f13_tau_scenario.csv might be insufficient +*' to solve the model. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/13_tc/exo/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/13_tc/exo/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/13_tc/exo/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/13_tc/exo/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/13_tc/exo/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/13_tc/exo/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/13_tc/exo/sets.gms b/modules/13_tc/exo/sets.gms new file mode 100644 index 0000000000..60ddb501db --- /dev/null +++ b/modules/13_tc/exo/sets.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2025 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 + + scen13 tc cost scenario + /low, medium, high/ + + tautype tc type + / pastr, crop / +; + +*** EOF sets.gms *** diff --git a/modules/13_tc/input/files b/modules/13_tc/input/files index db7c73ae1e..29f8c46fd4 100644 --- a/modules/13_tc/input/files +++ b/modules/13_tc/input/files @@ -4,3 +4,5 @@ f13_tau_scenario.csv f13_tcguess.cs4 f13_tc_exponent.cs3 f13_tc_factor.cs3 +f13_tau_historical.csv +f13_pastr_tau_hist.csv diff --git a/modules/13_tc/module.gms b/modules/13_tc/module.gms index f02f6d61bc..8b95777c0f 100644 --- a/modules/13_tc/module.gms +++ b/modules/13_tc/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -19,8 +19,9 @@ *' Calculated $\tau$ factors are then used for yields calculation by [14_yields] *' and by [38_factor_costs] for the calculation of factor costs. *' -*' @authors Jan Philipp Dietrich, Christoph Schmitz, Benjamin Bodirsky +*' @authors Jan Philipp Dietrich, Christoph Schmitz, Benjamin Bodirsky, Florian Humpenoeder, Marcos Alves *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%tc%" == "endo_jun18" $include "./modules/13_tc/endo_jun18/realization.gms" +$Ifi "%tc%" == "endo_jan22" $include "./modules/13_tc/endo_jan22/realization.gms" +$Ifi "%tc%" == "exo" $include "./modules/13_tc/exo/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/14_yields/biocorrect/declarations.gms b/modules/14_yields/biocorrect/declarations.gms deleted file mode 100644 index d6f6a9c742..0000000000 --- a/modules/14_yields/biocorrect/declarations.gms +++ /dev/null @@ -1,28 +0,0 @@ -*** | (C) 2008-2019 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 -****** Yields - i14_yields(t,j,kve,w) Biophysical input yields (excluding technological change) (tDM per ha per yr) -; - -positive variables - vm_yld(j,kve,w) Yields (variable because of technical change) (tDM per ha per yr) -; - -equations - q14_yield_crop(j,kcr,w) Crop yields (tDM per ha per yr) - q14_yield_past(j,w) Pasture yields (tDM per ha per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_yld(t,j,kve,w,type) Yields (variable because of technical change) (tDM per ha per yr) - oq14_yield_crop(t,j,kcr,w,type) Crop yields (tDM per ha per yr) - oq14_yield_past(t,j,w,type) Pasture yields (tDM per ha per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/14_yields/biocorrect/equations.gms b/modules/14_yields/biocorrect/equations.gms deleted file mode 100644 index 1a64395fab..0000000000 --- a/modules/14_yields/biocorrect/equations.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 - -q14_yield_crop(j2,kcr,w) .. - vm_yld(j2,kcr,w) =e= sum(ct,i14_yields(ct,j2,kcr,w))*sum(cell(i2,j2),vm_tau(i2)/fm_tau1995(i2)); - -*' For the current time step of the optimization, cellular yields of irrigated -*' and rainfed crops are calculated by multiplying calibrated input yields from -*' LPJmL with the intensification rate relative to the initial time step 1995. - -q14_yield_past(j2,w) .. - vm_yld(j2,"pasture",w) =e= sum(ct,i14_yields(ct,j2,"pasture",w)) - *(1 + s14_yld_past_switch*(sum(cell(i2,j2),vm_tau(i2)/fm_tau1995(i2)) - 1)); - -*' In the case of pasture yields, technological change cannot be fully -*' translated into yield increases. To account for that, the parameter -*' `s14_yld_past_switch` is defined to capture a certain magnitude of spillovers -*' that can range from 0 (no spillover) to 1 (full spillover). diff --git a/modules/14_yields/biocorrect/input.gms b/modules/14_yields/biocorrect/input.gms deleted file mode 100644 index ca7f34159e..0000000000 --- a/modules/14_yields/biocorrect/input.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2019 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 - -$setglobal c14_yields_scenario nocc -* options: cc (climate change) -* nocc (no climate change) - -scalars - s14_yld_past_switch Spillover parameter for translating technological change in the crop sector into pasture yield increases (1) / 0.25 / -; - -******* Calibration factor -table f14_yld_calib(i,ltype14) Calibration factor for the LPJ yields (1) -$ondelim -$include "./modules/14_yields/input/f14_yld_calib.csv" -$offdelim; - -table f14_yields(t_all,j,kve,w) LPJ potential yields per cell (rainfed and irrigated) (tDM per ha per yr) -$ondelim -$include "./modules/14_yields/input/lpj_yields.cs3" -$offdelim -; -* set values to 1995 if nocc scenario is used -$if "%c14_yields_scenario%" == "nocc" f14_yields(t_all,j,kve,w) = f14_yields("y1995",j,kve,w); -m_fillmissingyears(f14_yields,"j,kve,w"); diff --git a/modules/14_yields/biocorrect/nl_fix.gms b/modules/14_yields/biocorrect/nl_fix.gms deleted file mode 100644 index df31303634..0000000000 --- a/modules/14_yields/biocorrect/nl_fix.gms +++ /dev/null @@ -1,12 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_fix ### - -vm_yld.fx(j,kcr,w) = sum(ct,i14_yields(ct,j,kcr,w))*sum(cell(i,j),vm_tau.l(i)/fm_tau1995(i)); -vm_yld.fx(j,"pasture",w) = sum(ct,i14_yields(ct,j,"pasture",w))*((1-s14_yld_past_switch) + s14_yld_past_switch*sum(cell(i,j),vm_tau.l(i)/fm_tau1995(i))); - diff --git a/modules/14_yields/biocorrect/nl_release.gms b/modules/14_yields/biocorrect/nl_release.gms deleted file mode 100644 index 07f1b23bfd..0000000000 --- a/modules/14_yields/biocorrect/nl_release.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_release ### - -vm_yld.lo(j,kve,w) = 0; -vm_yld.up(j,kve,w) = Inf; diff --git a/modules/14_yields/biocorrect/not_used.txt b/modules/14_yields/biocorrect/not_used.txt deleted file mode 100644 index c6661264f2..0000000000 --- a/modules/14_yields/biocorrect/not_used.txt +++ /dev/null @@ -1,9 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason -pm_land_start,input,questionnaire -pm_past_mngmnt_factor,input,questionnaire diff --git a/modules/14_yields/biocorrect/postsolve.gms b/modules/14_yields/biocorrect/postsolve.gms deleted file mode 100644 index 2602c7a8f0..0000000000 --- a/modules/14_yields/biocorrect/postsolve.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_yld(t,j,kve,w,"marginal") = vm_yld.m(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"marginal") = q14_yield_crop.m(j,kcr,w); - oq14_yield_past(t,j,w,"marginal") = q14_yield_past.m(j,w); - ov_yld(t,j,kve,w,"level") = vm_yld.l(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"level") = q14_yield_crop.l(j,kcr,w); - oq14_yield_past(t,j,w,"level") = q14_yield_past.l(j,w); - ov_yld(t,j,kve,w,"upper") = vm_yld.up(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"upper") = q14_yield_crop.up(j,kcr,w); - oq14_yield_past(t,j,w,"upper") = q14_yield_past.up(j,w); - ov_yld(t,j,kve,w,"lower") = vm_yld.lo(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"lower") = q14_yield_crop.lo(j,kcr,w); - oq14_yield_past(t,j,w,"lower") = q14_yield_past.lo(j,w); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/14_yields/biocorrect/preloop.gms b/modules/14_yields/biocorrect/preloop.gms deleted file mode 100644 index 3c432e1fb0..0000000000 --- a/modules/14_yields/biocorrect/preloop.gms +++ /dev/null @@ -1,16 +0,0 @@ -*** | (C) 2008-2019 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 - -i14_yields(t,j,kve,w) = f14_yields(t,j,kve,w); - -***YIELD CORRECTION FOR 2ND GENERATION BIOENERGY CROPS************************** -i14_yields(t,j,"begr",w) = i14_yields(t,j,"begr",w)*sum(cell(i,j),fm_tau1995(i))/smax(i,fm_tau1995(i)); -i14_yields(t,j,"betr",w) = i14_yields(t,j,"betr",w)*sum(cell(i,j),fm_tau1995(i))/smax(i,fm_tau1995(i)); - -***YIELD CALIBRATION************************************************************ -i14_yields(t,j,kcr,w) = i14_yields(t,j,kcr,w) *sum(cell(i,j),f14_yld_calib(i,"crop")); -i14_yields(t,j,"pasture",w) = i14_yields(t,j,"pasture",w)*sum(cell(i,j),f14_yld_calib(i,"past")); diff --git a/modules/14_yields/biocorrect/realization.gms b/modules/14_yields/biocorrect/realization.gms deleted file mode 100644 index 44151ae3cc..0000000000 --- a/modules/14_yields/biocorrect/realization.gms +++ /dev/null @@ -1,34 +0,0 @@ -*** | (C) 2008-2019 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 The biocorrect realization reads in the LPJmL data and performs -*' several corrections. -*' First, a bioenergy yield correction is performed. As there is currently no -*' robust information on bioenergy yields available in [@FAOSTAT], it is assumed -*' that the LPJmL yields for bioenergy correspond to the yields achieved under -*' the highest currently observed value of the $\tau$ factor representing -*' agricultural land use intensity. Bioenergy yields are downscaled -*' proportionally to the respective $\tau$ factor in the given region. -*' Second, yields for all other crops are corrected on the regional -*' level by applying a calibration factor that does not differentiate between -*' crops. Pasture yields have their own regional calibration factors. Applied -*' calibration factors are derived via comparing cropland and pasture areas in -*' the initial time step with values reported by FAO [@FAOSTAT]. -*' -*' @limitations The magnitude of spillover effects from technological change in -*' the crop sector towards improvements in pasture management is very uncertain. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/14_yields/biocorrect/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/14_yields/biocorrect/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/14_yields/biocorrect/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/14_yields/biocorrect/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/14_yields/biocorrect/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/14_yields/biocorrect/postsolve.gms" -$Ifi "%phase%" == "nl_fix" $include "./modules/14_yields/biocorrect/nl_fix.gms" -$Ifi "%phase%" == "nl_release" $include "./modules/14_yields/biocorrect/nl_release.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/14_yields/biocorrect/sets.gms b/modules/14_yields/biocorrect/sets.gms deleted file mode 100644 index 500ac4b7a1..0000000000 --- a/modules/14_yields/biocorrect/sets.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - ltype14 calibration land types - / crop, past / -; diff --git a/modules/14_yields/dynamic_aug18/declarations.gms b/modules/14_yields/dynamic_aug18/declarations.gms deleted file mode 100644 index 9e3a69b8c4..0000000000 --- a/modules/14_yields/dynamic_aug18/declarations.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2019 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 - i14_yields(t,j,kve,w) Biophysical input yields (excluding technological change) (tDM per ha per yr) - p14_pyield_LPJ_reg(t_all,i) Regional average input yields aggregated from clusters with initial pasture area as weights (tDM per ha per yr) - p14_pyield_corr(t,i) Regional pasture management correction for historical time steps (1) -; - -positive variables - vm_yld(j,kve,w) Yields (variable because of technical change) (tDM per ha per yr) -; - -equations - q14_yield_crop(j,kcr,w) Crop yields (tDM per ha per yr) - q14_yield_past(j,w) Pasture yields (tDM per ha per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_yld(t,j,kve,w,type) Yields (variable because of technical change) (tDM per ha per yr) - oq14_yield_crop(t,j,kcr,w,type) Crop yields (tDM per ha per yr) - oq14_yield_past(t,j,w,type) Pasture yields (tDM per ha per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/14_yields/dynamic_aug18/equations.gms b/modules/14_yields/dynamic_aug18/equations.gms deleted file mode 100644 index 2e7f4f07e9..0000000000 --- a/modules/14_yields/dynamic_aug18/equations.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - -***CROP YIELD CALCULATIONS********************************************** -q14_yield_crop(j2,kcr,w) .. - vm_yld(j2,kcr,w) =e= sum(ct,i14_yields(ct,j2,kcr,w))*sum(cell(i2,j2),vm_tau(i2)/fm_tau1995(i2)); - - -***PASTURE YIELD CALCULATIONS******************************************* -*' Pasture yields are not linked to yield increases in the crop sector, but to -*' an exogenous pasture management factor `pm_past_mngmnt_factor`: - -q14_yield_past(j2,w) .. - vm_yld(j2,"pasture",w) =e= - sum(ct,(i14_yields(ct,j2,"pasture",w) - *sum(cell(i2,j2),pm_past_mngmnt_factor(ct,i2)))); diff --git a/modules/14_yields/dynamic_aug18/input.gms b/modules/14_yields/dynamic_aug18/input.gms deleted file mode 100644 index 18910786fd..0000000000 --- a/modules/14_yields/dynamic_aug18/input.gms +++ /dev/null @@ -1,30 +0,0 @@ -*** | (C) 2008-2019 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 - -$setglobal c14_yields_scenario nocc -* options: cc (climate change) -* nocc (no climate change) - -******* Calibration factor -table f14_yld_calib(i,ltype14) Calibration factor for the LPJmL yields (1) -$ondelim -$include "./modules/14_yields/input/f14_yld_calib.csv" -$offdelim; - -table f14_yields(t_all,j,kve,w) LPJmL potential yields per cell (rainfed and irrigated) (tDM per ha per yr) -$ondelim -$include "./modules/14_yields/input/lpj_yields.cs3" -$offdelim -; -* set values to 1995 if nocc scenario is used -$if "%c14_yields_scenario%" == "nocc" f14_yields(t_all,j,kve,w) = f14_yields("y1995",j,kve,w); -m_fillmissingyears(f14_yields,"j,kve,w"); - -table f14_pyld_hist(t_all,i) Modelled regional pasture yields in the past (tDM per ha per yr) -$ondelim -$include "./modules/14_yields/input/f14_pasture_yields_hist.csv" -$offdelim; diff --git a/modules/14_yields/dynamic_aug18/nl_fix.gms b/modules/14_yields/dynamic_aug18/nl_fix.gms deleted file mode 100644 index 01877e5944..0000000000 --- a/modules/14_yields/dynamic_aug18/nl_fix.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_fix ### - -vm_yld.fx(j,kcr,w) = sum(ct,i14_yields(ct,j,kcr,w))*sum(cell(i,j),vm_tau.l(i)/fm_tau1995(i)); - -vm_yld.fx(j,"pasture",w) = sum(ct,i14_yields(ct,j,"pasture",w)*sum(cell(i,j),pm_past_mngmnt_factor(ct,i))); - - - - - - - diff --git a/modules/14_yields/dynamic_aug18/nl_release.gms b/modules/14_yields/dynamic_aug18/nl_release.gms deleted file mode 100644 index 07f1b23bfd..0000000000 --- a/modules/14_yields/dynamic_aug18/nl_release.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_release ### - -vm_yld.lo(j,kve,w) = 0; -vm_yld.up(j,kve,w) = Inf; diff --git a/modules/14_yields/dynamic_aug18/postsolve.gms b/modules/14_yields/dynamic_aug18/postsolve.gms deleted file mode 100644 index 399ea362d0..0000000000 --- a/modules/14_yields/dynamic_aug18/postsolve.gms +++ /dev/null @@ -1,25 +0,0 @@ -*** | (C) 2008-2019 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 - - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_yld(t,j,kve,w,"marginal") = vm_yld.m(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"marginal") = q14_yield_crop.m(j,kcr,w); - oq14_yield_past(t,j,w,"marginal") = q14_yield_past.m(j,w); - ov_yld(t,j,kve,w,"level") = vm_yld.l(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"level") = q14_yield_crop.l(j,kcr,w); - oq14_yield_past(t,j,w,"level") = q14_yield_past.l(j,w); - ov_yld(t,j,kve,w,"upper") = vm_yld.up(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"upper") = q14_yield_crop.up(j,kcr,w); - oq14_yield_past(t,j,w,"upper") = q14_yield_past.up(j,w); - ov_yld(t,j,kve,w,"lower") = vm_yld.lo(j,kve,w); - oq14_yield_crop(t,j,kcr,w,"lower") = q14_yield_crop.lo(j,kcr,w); - oq14_yield_past(t,j,w,"lower") = q14_yield_past.lo(j,w); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/14_yields/dynamic_aug18/preloop.gms b/modules/14_yields/dynamic_aug18/preloop.gms deleted file mode 100644 index c3fc1bd875..0000000000 --- a/modules/14_yields/dynamic_aug18/preloop.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2019 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 - -i14_yields(t,j,kve,w) = f14_yields(t,j,kve,w); - -***YIELD CORRECTION FOR 2ND GENERATION BIOENERGY CROPS************************************* -i14_yields(t,j,"begr",w) = i14_yields(t,j,"begr",w)*sum(cell(i,j),fm_tau1995(i))/smax(i,fm_tau1995(i)); -i14_yields(t,j,"betr",w) = i14_yields(t,j,"betr",w)*sum(cell(i,j),fm_tau1995(i))/smax(i,fm_tau1995(i)); - -***YIELD CORRECTION FOR PASTURE ACCOUNTING FOR REGIONAL DIFFERENCES IN MANAGEMENT*** -p14_pyield_LPJ_reg(t,i) = (sum(cell(i,j),i14_yields(t,j,"pasture","rainfed")*pm_land_start(j,"past"))/sum(cell(i,j),pm_land_start(j,"past")) ); - -p14_pyield_corr(t,i) = (f14_pyld_hist(t,i)/p14_pyield_LPJ_reg(t,i))$(sum(sameas(t_past,t),1) = 1) - + sum(t_past,(f14_pyld_hist(t_past,i)/(p14_pyield_LPJ_reg(t_past,i)+0.000001))$(ord(t_past)=card(t_past)))$(sum(sameas(t_past,t),1) <> 1); -i14_yields(t,j,"pasture",w) = i14_yields(t,j,"pasture",w)*sum(cell(i,j),p14_pyield_corr(t,i)); - -***YIELD CALIBRATION*********************************************************************** -i14_yields(t,j,kcr,w) = i14_yields(t,j,kcr,w) *sum(cell(i,j),f14_yld_calib(i,"crop")); -i14_yields(t,j,"pasture",w) = i14_yields(t,j,"pasture",w)*sum(cell(i,j),f14_yld_calib(i,"past")); - - -***INITIALIZATION OF PARAMETERS FOR THE INITIAL TIME STEP********************************** - - - diff --git a/modules/14_yields/dynamic_aug18/realization.gms b/modules/14_yields/dynamic_aug18/realization.gms deleted file mode 100644 index f2d5132a3f..0000000000 --- a/modules/14_yields/dynamic_aug18/realization.gms +++ /dev/null @@ -1,25 +0,0 @@ -*** | (C) 2008-2019 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 the dynamic_aug18 realization, the crop yield calculations -*' are identical as in the above described realization (biocorrect). -*' -*' @limitations The exogenous implementation of pasture intensification cannot -*' capture feedbacks between land scarcity and efforts to improve pasture -*' management. - - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/14_yields/dynamic_aug18/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/14_yields/dynamic_aug18/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/14_yields/dynamic_aug18/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/14_yields/dynamic_aug18/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/14_yields/dynamic_aug18/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/14_yields/dynamic_aug18/postsolve.gms" -$Ifi "%phase%" == "nl_fix" $include "./modules/14_yields/dynamic_aug18/nl_fix.gms" -$Ifi "%phase%" == "nl_release" $include "./modules/14_yields/dynamic_aug18/nl_release.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/14_yields/dynamic_aug18/sets.gms b/modules/14_yields/dynamic_aug18/sets.gms deleted file mode 100644 index 500ac4b7a1..0000000000 --- a/modules/14_yields/dynamic_aug18/sets.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - ltype14 calibration land types - / crop, past / -; diff --git a/modules/14_yields/input/files b/modules/14_yields/input/files index 729ff9572c..984b93ee32 100644 --- a/modules/14_yields/input/files +++ b/modules/14_yields/input/files @@ -3,3 +3,6 @@ lpj_yields.cs3 f14_yld_calib.csv lpj_yields_0.5.mz f14_pasture_yields_hist.csv +f14_ipcc_bce.cs3 +f14_aboveground_fraction.csv +f14_kcr_pollinator_dependence.csv diff --git a/modules/14_yields/managementcalib_aug19/declarations.gms b/modules/14_yields/managementcalib_aug19/declarations.gms new file mode 100644 index 0000000000..7af3eb8597 --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/declarations.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2025 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 + i14_yields_calib(t,j,kve,w) Calibrated biophysical input yields (excluding technological change) (tDM per ha per yr) + p14_pyield_LPJ_reg(t_all,i) Regional average input yields aggregated from clusters with initial pasture area as weights (tDM per ha per yr) + p14_pyield_corr(t,i) Regional pasture management correction for historical time steps (1) + i14_croparea_total(t_all,w,j) Cellular croparea (mio. ha) + i14_modeled_yields_hist(t_all,i,kcr) Biophysical input yields average over region and water supply type at the historical reference year (tDM per ha per yr) + i14_fao_yields_hist(t,i,kcr) FAO yields per region at the historical referende year (tDM per ha per yr) + i14_lambda_yields(t,i,kcr) Scaling factor for non-linear management calibration (1) + i14_managementcalib(t,j,kcr,w) Regional management calibration factor accounting for FAO yield levels (1) + pm_timber_yield(t,j,ac,land_timber) Forest growing stock (tDM per ha per yr) + pm_yields_semi_calib(j,kve,w) Potential yields calibrated to FAO regional levels (tDM per ha per yr) + i14_calib_yields_hist(i,w) Calibrated yields average over region and crop type at the historical reference year (tDM per ha per yr) + i14_calib_yields_ratio(i) Irrigated to rainfed yield ratio for calibrated yields (1) + i14_target_ratio(i) Target irrigated to rainfed ratio as upper bound (1) + i14_modeled_yields_hist2(i,knbe14) Calibrated yields average over region and water supply type at the historical reference year (tDM per ha per yr) + ; + +positive variables + vm_yld(j,kve,w) Yields (variable because of technical change) (tDM per ha per yr) +; + +equations + q14_yield_crop(j,kcr,w) Crop yields (tDM per ha per yr) + q14_yield_past(j,w) Pasture yields (tDM per ha per yr) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_yld(t,j,kve,w,type) Yields (variable because of technical change) (tDM per ha per yr) + oq14_yield_crop(t,j,kcr,w,type) Crop yields (tDM per ha per yr) + oq14_yield_past(t,j,w,type) Pasture yields (tDM per ha per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/14_yields/managementcalib_aug19/equations.gms b/modules/14_yields/managementcalib_aug19/equations.gms new file mode 100644 index 0000000000..bd8857f4cd --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/equations.gms @@ -0,0 +1,39 @@ +*** | (C) 2008-2025 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 + +***CROP YIELD CALCULATIONS********************************************** + +*' Technological change can increase the initial calibrated yields by: + +q14_yield_crop(j2,kcr,w) .. + vm_yld(j2,kcr,w) =e= sum(ct,i14_yields_calib(ct,j2,kcr,w)) * + vm_tau(j2,"crop") / sum((cell(i2,j2), supreg(h2,i2)), fm_tau1995(h2)); + +*' For the current time step of the optimization, cellular yields of irrigated +*' and rainfed crops are calculated by multiplying calibrated input yields from +*' LPJmL with the intensification rate relative to the initial time step 1995. + +***PASTURE YIELD CALCULATIONS******************************************* + +*' In the case of pasture yields, technological change cannot be fully +*' translated into yield increases, to address that, an exogenous pasture management +*' factor `pm_past_mngmnt_factor` is used to scale pasture yields based on the +*' number of cattle reared to fulfill the domestic demand for ruminant livestock +*' products in module 70. +*' +*' Additionally, the parameter `s14_yld_past_switch` can be used to capture a +*' certain magnitude of spillovers of the yield increase due to technological +*' change from the time step before. It can range from 0 (no spillover) to 1 +*' (full spillover). + +q14_yield_past(j2,w) .. + vm_yld(j2,"pasture",w) =e= + sum(ct,(i14_yields_calib(ct,j2,"pasture",w)) + * sum(cell(i2,j2),pm_past_mngmnt_factor(ct,i2))) + * (1 + s14_yld_past_switch*(sum((cell(i2,j2), supreg(h2,i2)), pcm_tau(j2, "crop")/fm_tau1995(h2)) - 1)); diff --git a/modules/14_yields/managementcalib_aug19/input.gms b/modules/14_yields/managementcalib_aug19/input.gms new file mode 100644 index 0000000000..7d178b20bc --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/input.gms @@ -0,0 +1,94 @@ +*** | (C) 2008-2025 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 + +$setglobal c14_yields_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + + +scalars +s14_limit_calib Relative managament calibration switch (1=limited 0=pure relative) / 1 / +s14_calib_ir2rf Switch to calibrate rainfed to irrigated yield ratios (1=calib 0=not calib) / 1 / +s14_degradation Switch to include yield impacts of land degradation(0=no degradation 1=with degradation) / 0 / +s14_use_yield_calib Switch for using or not using yield calibration factors from the preprocessing (1=use facs 0=not use facs) / 0 / +s14_minimum_wood_yield Minimum wood yield for timber harvest in natural vegetation (tDM per ha per yr) / 10 / +s14_yld_past_switch Spillover parameter for translating technological change in the crop sector into pasture yieldincreases (1) / 0.25 / +s14_yld_reduction_soil_loss Decline of land productivity in areas with severe soil loss (1) / 0.08 / +s14_carbon_fraction Carbon fraction for conversion of biomass to dry matter (1) / 0.5/ +; + + +******* Calibration factor +$onEmpty +table f14_yld_calib(i,ltype14) Calibration factor for the LPJmL yields (1) +$ondelim +$if exist "./modules/14_yields/input/f14_yld_calib.csv" $include "./modules/14_yields/input/f14_yld_calib.csv" +$offdelim +; +$offEmpty + +table f14_yields(t_all,j,kve,w) LPJmL potential yields per cell (rainfed and irrigated) (tDM per ha per yr) +$ondelim +$include "./modules/14_yields/input/lpj_yields.cs3" +$offdelim +; +* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used +$if "%c14_yields_scenario%" == "nocc" f14_yields(t_all,j,kve,w) = f14_yields("y1995",j,kve,w); +$if "%c14_yields_scenario%" == "nocc_hist" f14_yields(t_all,j,kve,w)$(m_year(t_all) > sm_fix_cc) = f14_yields(t_all,j,kve,w)$(m_year(t_all) = sm_fix_cc); +m_fillmissingyears(f14_yields,"j,kve,w"); + +table f14_pyld_hist(t_all,i) Modelled regional pasture yields in the past (tDM per ha per yr) +$ondelim +$include "./modules/14_yields/input/f14_pasture_yields_hist.csv" +$offdelim; + + +table f14_fao_yields_hist(t_all,i,kcr) FAO yields per region (tDM per ha per yr) +$ondelim +$include "./modules/14_yields/managementcalib_aug19/input/f14_region_yields.cs3" +$offdelim +; +m_fillmissingyears(f14_fao_yields_hist,"i,kcr"); + +parameter f14_ir2rf_ratio(i) AQUASTAT ratio of irrigated to rainfed yields per region (1) +/ +$ondelim +$include "./modules/14_yields/managementcalib_aug19/input/f14_ir2rf_ratio.cs4" +$offdelim +/ +; + +table f14_ipcc_bce(clcl,forest_type) IPCC Biomass Conversion and Expansion factors (1) +$ondelim +$include "./modules/14_yields/input/f14_ipcc_bce.cs3" +$offdelim +; + +parameter f14_aboveground_fraction(land_timber) Root to shoot ratio (1) +/ +$ondelim +$include "./modules/14_yields/input/f14_aboveground_fraction.csv" +$offdelim +/ +; + +$onEmpty +table f14_yld_ncp_report(t_all,j,ncp_type14) Share of land with intact natures contributions to people (NCP) (1) +$ondelim +$if exist "./modules/14_yields/input/f14_yld_ncp_report.cs3" $include "./modules/14_yields/input/f14_yld_ncp_report.cs3" +$offdelim +; +$offEmpty + +parameter f14_kcr_pollinator_dependence(kcr) Share of total yield dependent on biotic pollination (1) +/ +$ondelim +$include "./modules/14_yields/input/f14_kcr_pollinator_dependence.csv" +$offdelim +/ +; diff --git a/modules/14_yields/managementcalib_aug19/input/files b/modules/14_yields/managementcalib_aug19/input/files new file mode 100644 index 0000000000..cf2be7a6dc --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/input/files @@ -0,0 +1,5 @@ +* list of files that are required here +f14_region_yields.cs3 +f14_ir2rf_ratio.cs4 +f14_ipcc_bce.cs3 +f14_aboveground_fraction.csv diff --git a/modules/14_yields/managementcalib_aug19/nl_fix.gms b/modules/14_yields/managementcalib_aug19/nl_fix.gms new file mode 100644 index 0000000000..07339b646d --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/nl_fix.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +* ### nl_fix ### + +vm_yld.fx(j,kcr,w) = sum(ct,i14_yields_calib(ct,j,kcr,w)) * sum((cell(i,j), supreg(h,i)),vm_tau.l(h, "crop") / fm_tau1995(h)); +vm_yld.fx(j,"pasture",w) = sum(ct,(i14_yields_calib(ct,j,"pasture",w)) * sum(cell(i,j), pm_past_mngmnt_factor(ct,i))) * (1 + s14_yld_past_switch * (sum((cell(i,j), supreg(h,i)), pcm_tau(h, "crop") / fm_tau1995(h)) - 1)); diff --git a/modules/14_yields/managementcalib_aug19/nl_release.gms b/modules/14_yields/managementcalib_aug19/nl_release.gms new file mode 100644 index 0000000000..f3261b8f87 --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/nl_release.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +* ### nl_release ### + +vm_yld.lo(j,kve,w) = 0; +vm_yld.up(j,kve,w) = Inf; diff --git a/modules/14_yields/managementcalib_aug19/postsolve.gms b/modules/14_yields/managementcalib_aug19/postsolve.gms new file mode 100644 index 0000000000..398d8cf124 --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/postsolve.gms @@ -0,0 +1,24 @@ +*** | (C) 2008-2025 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 + + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_yld(t,j,kve,w,"marginal") = vm_yld.m(j,kve,w); + oq14_yield_crop(t,j,kcr,w,"marginal") = q14_yield_crop.m(j,kcr,w); + oq14_yield_past(t,j,w,"marginal") = q14_yield_past.m(j,w); + ov_yld(t,j,kve,w,"level") = vm_yld.l(j,kve,w); + oq14_yield_crop(t,j,kcr,w,"level") = q14_yield_crop.l(j,kcr,w); + oq14_yield_past(t,j,w,"level") = q14_yield_past.l(j,w); + ov_yld(t,j,kve,w,"upper") = vm_yld.up(j,kve,w); + oq14_yield_crop(t,j,kcr,w,"upper") = q14_yield_crop.up(j,kcr,w); + oq14_yield_past(t,j,w,"upper") = q14_yield_past.up(j,w); + ov_yld(t,j,kve,w,"lower") = vm_yld.lo(j,kve,w); + oq14_yield_crop(t,j,kcr,w,"lower") = q14_yield_crop.lo(j,kcr,w); + oq14_yield_past(t,j,w,"lower") = q14_yield_past.lo(j,w); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/14_yields/managementcalib_aug19/preloop.gms b/modules/14_yields/managementcalib_aug19/preloop.gms new file mode 100644 index 0000000000..c889c3a1a8 --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/preloop.gms @@ -0,0 +1,190 @@ +*** | (C) 2008-2025 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 + +i14_yields_calib(t,j,kve,w) = f14_yields(t,j,kve,w); + +***YIELD CORRECTION FOR 2ND GENERATION BIOENERGY CROPS************************************* +i14_yields_calib(t,j,"begr",w) = f14_yields(t,j,"begr",w) * sum((supreg(h,i),cell(i,j)),fm_tau1995(h))/smax(h,fm_tau1995(h)); +i14_yields_calib(t,j,"betr",w) = f14_yields(t,j,"betr",w) * sum((supreg(h,i),cell(i,j)),fm_tau1995(h))/smax(h,fm_tau1995(h)); + +***YIELD CORRECTION FOR PASTURE ACCOUNTING FOR REGIONAL DIFFERENCES IN MANAGEMENT*** +p14_pyield_LPJ_reg(t,i) = (sum(cell(i,j),i14_yields_calib(t,j,"pasture","rainfed") * pm_land_start(j,"past")) / + sum(cell(i,j),pm_land_start(j,"past")) ); + +p14_pyield_corr(t,i) = (f14_pyld_hist(t,i)/p14_pyield_LPJ_reg(t,i))$(sum(sameas(t_past,t),1) = 1) + + sum(t_past,(f14_pyld_hist(t_past,i)/(p14_pyield_LPJ_reg(t_past,i)+0.000001))$(ord(t_past)=card(t_past)))$(sum(sameas(t_past,t),1) <> 1); +i14_yields_calib(t,j,"pasture",w) = i14_yields_calib(t,j,"pasture",w) * sum(cell(i,j),p14_pyield_corr(t,i)); + + +***YIELD MANAGEMENT CALIBRATION************************************************************ + + +*' @code + +*' The following equations calibrate the cellular yield patterns (`f14_yields`) to match +*' FAO historical yields (`f14_fao_yields_hist`) by calculating a calibration term called +*' 'i14_managementcalib'. For most cases, 'i14_managementcalib' is the ratio of the historical +*' yields reported by FAO (`f14_fao_yields_hist`) and regional mean yields (`i14_modeled_yields_hist`) +*' given historic crop area patterns ('fm_croparea') and cellular yields coming from crop models +*' like LPJmL (`f14_yields`). In these cases, 'i14_managementcalib' represents a purely relative +*' calibration factor that depends only on the initial conditions of the starting year. +*' +*' However, when FAO yields are significantly higher than given by the cellular yield inputs +*' (underestimated baseline), the relative calibration terms can lead to unrealistically large +*' yields in the case of future yield increases within the cellular yield patterns. +*' +*' To address this issue, the factor `i14_lambda_yields` determines the degree +*' to which the baseline (FAO) is under- or overestimated and therefore controls +*' whether the calibration factor is applied as an absolute or relative change. +*' For overestimated FAO yields, `i14_lambda_yields` is 1, which is equivalent +*' to an entirely relative calibration. For underestimated yields, `i14_lambda_yields` +*' is calculated as the squared root of the ratio between LPJmL yields and FAO historical +*' yields, and as `i14_lambda_yields` approaches 0, it reduces the applied relative change +*' resulting in a mean change increasingly similar to an additive term (@Heinke.2013). + +*' This concept is referred to as limited calibration, as it limits the calibration +*' to an additive term in case of a strongly underestimated baseline. The scalar +*' `s14_limit_calib` can be used to switch limited calibration on (1) and off (0). + +i14_croparea_total(t_all,w,j) = sum(kcr, fm_croparea(t_all,j,w,kcr)); + +*' Historic crop area patterns (`fm_croprea`) are used to calculate regional yields +*' (`i14_modeled_yields_hist`) from the given cellular input pattern. In rare cases where +*' a region has no crop area reported for a given crop type, the total crop area is +*' used to calculate a proxy yield for the calibration, given by the following equation: + +i14_modeled_yields_hist(t_past,i,knbe14) + = (sum((cell(i,j),w), fm_croparea(t_past,j,w,knbe14) * f14_yields(t_past,j,knbe14,w)) / + sum((cell(i,j),w), fm_croparea(t_past,j,w,knbe14)))$(sum((cell(i,j),w), fm_croparea(t_past,j,w,knbe14)) > 0.00001 AND + sum((cell(i,j),w), fm_croparea(t_past,j,w,knbe14) * f14_yields(t_past,j,knbe14,w)) > 0.00001) + + (sum((cell(i,j),w), i14_croparea_total(t_past,w,j) * f14_yields(t_past,j,knbe14,w)) / + sum((cell(i,j),w), i14_croparea_total(t_past,w,j)))$(sum((cell(i,j),w), fm_croparea(t_past,j,w,knbe14)) <= 0.00001 OR + sum((cell(i,j),w), fm_croparea(t_past,j,w,knbe14) * f14_yields(t_past,j,knbe14,w)) <= 0.00001); + + +*' The factor `i14_lambda_yields` is calculated for the initial time step depending +*' on the setting `s14_limit_calib` and is then held constant for all other time steps. +*' The regional FAO yield and regional yield of the crop model input of the initial +*' time step is kept constant in the two parameters `i14_fao_yields_hist` and +*' `i14_modeled_yields_hist`: + +loop(t, + if(sum(sameas(t,"y1995"),1)=1, + + if ((s14_limit_calib = 0), + i14_lambda_yields(t,i,knbe14) = 1; + + Elseif (s14_limit_calib =1 ), + i14_lambda_yields(t,i,knbe14) = + 1$(f14_fao_yields_hist(t,i,knbe14) <= i14_modeled_yields_hist(t,i,knbe14)) + + sqrt(i14_modeled_yields_hist(t,i,knbe14)/f14_fao_yields_hist(t,i,knbe14))$ + (f14_fao_yields_hist(t,i,knbe14) > i14_modeled_yields_hist(t,i,knbe14)); + ); + + i14_fao_yields_hist(t,i,knbe14) = f14_fao_yields_hist(t,i,knbe14); + + Else + i14_modeled_yields_hist(t,i,knbe14) = i14_modeled_yields_hist(t-1,i,knbe14); + i14_FAO_yields_hist(t,i,knbe14) = i14_fao_yields_hist(t-1,i,knbe14); + i14_lambda_yields(t,i,knbe14) = i14_lambda_yields(t-1,i,knbe14); + ); +); + +*' The calibrated cellular yield `i14_yields_calib` is calculated for each time step depending +*' on the constant values `i14_modeled_yields_hist`, `i14_fao_yields_hist`, `i14_lambda_yields` +*' and the uncalibrated, cellular yield `f14_yields` following the idea of eq. (9) in [@Heinke.2013]: + +i14_managementcalib(t,j,knbe14,w) = + 1 + (sum(cell(i,j), i14_fao_yields_hist(t,i,knbe14) - i14_modeled_yields_hist(t,i,knbe14)) / + f14_yields(t,j,knbe14,w) * + (f14_yields(t,j,knbe14,w) / (sum(cell(i,j),i14_modeled_yields_hist(t,i,knbe14))+10**(-8))) ** + sum(cell(i,j),i14_lambda_yields(t,i,knbe14)))$(f14_yields(t,j,knbe14,w)>0); + + +i14_yields_calib(t,j,knbe14,w) = i14_managementcalib(t,j,knbe14,w) * f14_yields(t,j,knbe14,w); +pm_yields_semi_calib(j,knbe14,w) = i14_yields_calib("y1995",j,knbe14,w); + +*' Note that the calculation is split into two parts for better readability. + +*' Irrigated yields are calibrated to meet the country-level +*' ratio between irrigated and rainfed yields reported by Aquastat. +*' This can be de-activated with the switch `s14_calib_ir2rf`. +if ((s14_calib_ir2rf = 1), + +* Weighted yields + i14_calib_yields_hist(i,w) + = sum((cell(i,j), knbe14), fm_croparea("y1995",j,"irrigated",knbe14) * i14_yields_calib("y1995",j,knbe14,w)) / + sum((cell(i,j), knbe14), fm_croparea("y1995",j,"irrigated",knbe14)); + +* Use irrigated-rainfed ratio of Aquastat if larger than our calculated ratio + i14_calib_yields_ratio(i) = i14_calib_yields_hist(i,"irrigated") / i14_calib_yields_hist(i,"rainfed"); + i14_target_ratio(i) = max(i14_calib_yields_ratio(i), f14_ir2rf_ratio(i)); + i14_yields_calib(t,j,knbe14,"irrigated") = sum((cell(i,j)), i14_target_ratio(i) / i14_calib_yields_ratio(i)) * + i14_yields_calib(t,j,knbe14,"irrigated"); + +* Calibrate newly calibrated yields to FAO yields + i14_modeled_yields_hist2(i,knbe14) + = (sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14) * i14_yields_calib("y1995",j,knbe14,w)) / + sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14)))$(sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14)) > 0.00001 AND + sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14) * i14_yields_calib("y1995",j,knbe14,w)) > 0.00001) + + (sum((cell(i,j),w), i14_croparea_total("y1995",w,j) * i14_yields_calib("y1995",j,knbe14,w)) / + sum((cell(i,j),w), i14_croparea_total("y1995",w,j)))$(sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14)) <= 0.00001 OR + sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14) * i14_yields_calib("y1995",j,knbe14,w)) <= 0.00001); + + i14_yields_calib(t,j,knbe14,w) = sum((cell(i,j)), i14_fao_yields_hist("y1995",i,knbe14) / + i14_modeled_yields_hist2(i,knbe14)) * + i14_yields_calib(t,j,knbe14,w); + + pm_yields_semi_calib(j,knbe14,w) = i14_yields_calib("y1995",j,knbe14,w); +); + +*' @stop + + +***YIELD CALIBRATION*********************************************************************** + +*' @code +*' Calibrated yields can additionally be adjusted by calibration factors 'f14_yld_calib' +*' determined in a calibration run. As MAgPIE optimizes yield patterns and FAO regional +*' yields are outlier corrected, historical production and croparea can in some cases +*' be better represented with this additional correction: + +* set yield calib factors to 1 in case of no use of yield calibration factors (s14_use_yield_calib = 0) +* or missing input file +if(s14_use_yield_calib = 0 OR sum((i,ltype14),f14_yld_calib(i,ltype14)) = 0, + f14_yld_calib(i,ltype14) = 1; +); + + +i14_yields_calib(t,j,kcr,w) = i14_yields_calib(t,j,kcr,w) + * sum(cell(i,j),f14_yld_calib(i,"crop")); +i14_yields_calib(t,j,"pasture",w) = i14_yields_calib(t,j,"pasture",w) + * sum(cell(i,j),f14_yld_calib(i,"past")); + +*' @stop + +*' @code +*' Land degradation can negatively affect yields. Soil loss for example can +*' notably affect land productivity. Similarly, the yield of pollinator-dependent crops +*' is reduced when there is a lack of pollinators. To account for the impacts of degradation, +*' calibrated yields are multiplied by the share of land with intact NCP in each cell and specific +*' yield reduction coefficients that represent yield loss due to soil erosion and pollination +*' deficiency on non-intact land. + +* set default values in case of missing input file. +if(sum((t,j,ncp_type14),f14_yld_ncp_report(t,j,ncp_type14)) = 0, + f14_yld_ncp_report(t,j,ncp_type14) = 1; +); + +if ((s14_degradation = 1), + i14_yields_calib(t,j,kcr,w) = i14_yields_calib(t,j,kcr,w) * (1 - s14_yld_reduction_soil_loss) + + i14_yields_calib(t,j,kcr,w) * s14_yld_reduction_soil_loss * f14_yld_ncp_report(t,j,"soil_intact"); + i14_yields_calib(t,j,kcr,w) = i14_yields_calib(t,j,kcr,w) * (1 - f14_kcr_pollinator_dependence(kcr)) + + i14_yields_calib(t,j,kcr,w) * f14_kcr_pollinator_dependence(kcr) * f14_yld_ncp_report(t,j,"poll_suff"); +); + +*' @stop diff --git a/modules/14_yields/managementcalib_aug19/presolve.gms b/modules/14_yields/managementcalib_aug19/presolve.gms new file mode 100644 index 0000000000..9b95c9e4ca --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/presolve.gms @@ -0,0 +1,65 @@ +*** | (C) 2008-2025 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 + +*** EOF presolve.gms *** + +* calculate carbon density + +*** YIELDS + +*` `pm_carbon_density_plantation_ac` for vegetation Carbon is above- and belowground +*' carbon density. We convert Carbon density in tC/ha to tDM/ha by using carbon +*' fraction of `s14_carbon_fraction` in tC/tDM. For assessing wood harvesting +*' we need only aboveground biomass information, therefore we multiply with +*' aboveground `f14_aboveground_fraction`. Additionally, we divide aboveground +*' tree biomass by biomass conversion and expansion (BCE) factor to get stem +*' biomass in tDM/ha. + +*` @code + +pm_timber_yield(t,j,ac,"forestry") = + ( + pm_carbon_density_plantation_ac(t,j,ac,"vegc") + / s14_carbon_fraction + * f14_aboveground_fraction("forestry") + / sum(clcl, pm_climate_class(j,clcl) * f14_ipcc_bce(clcl,"plantations")) + ) + ; + +pm_timber_yield(t,j,ac,"primforest") = + ( + fm_carbon_density(t,j,"primforest","vegc") + / s14_carbon_fraction + * f14_aboveground_fraction("primforest") + / sum(clcl, pm_climate_class(j,clcl) * f14_ipcc_bce(clcl,"natveg")) + ) + ; + +pm_timber_yield(t,j,ac,"secdforest") = + ( + pm_carbon_density_secdforest_ac(t,j,ac,"vegc") + / s14_carbon_fraction + * f14_aboveground_fraction("secdforest") + / sum(clcl, pm_climate_class(j,clcl) * f14_ipcc_bce(clcl,"natveg")) + ) + ; + +pm_timber_yield(t,j,ac,"other") = + ( + pm_carbon_density_other_ac(t,j,ac,"vegc") + / s14_carbon_fraction + * f14_aboveground_fraction("other") + / sum(clcl, pm_climate_class(j,clcl) * f14_ipcc_bce(clcl,"natveg")) + ) + ; + +*` @stop + +** Hard constraint to always have a positive number in pm_timber_yield +pm_timber_yield(t,j,ac,land_timber) = pm_timber_yield(t,j,ac,land_timber)$(pm_timber_yield(t,j,ac,land_timber) > 0) + 0.0001$(pm_timber_yield(t,j,ac,land_timber) = 0); +** Put yields to 0 where they dont exceed a minimum yield for harvest +pm_timber_yield(t,j,ac,land_natveg)$(pm_timber_yield(t,j,ac,land_natveg) < s14_minimum_wood_yield) = 0; diff --git a/modules/14_yields/managementcalib_aug19/realization.gms b/modules/14_yields/managementcalib_aug19/realization.gms new file mode 100644 index 0000000000..900faca6c1 --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/realization.gms @@ -0,0 +1,39 @@ +*** | (C) 2008-2025 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 The managementcalib_aug19 realization reads in the LPJmL data and +*' performs a number of calibrations. First, a bioenergy yield correction is performed. +*' As there is currently no robust information on bioenergy yields available in +*' [@FAOSTAT], it is assumed that the LPJmL yields for bioenergy correspond to the +*' yields achieved under the highest currently observed value of the $\tau$ factor +*' representing agricultural land-use intensity. Secondly, pasture yields are calculated +*' based on pasture demand to account for in- and extensification of managed grasslands. +*' Thirdly, irrigated yields are scaled to meet the irrigated-to-rainfed yield +*' ratio as provided by AQUASTAT [@fao_aquastat_2016]. +*' Finally, crop yields are calibrated to FAO [@FAOSTAT] regional yield levels of the +*' initial time step. An additional feature of this realization is to allow crop yields +*' technological change from the precedent times step to spillover to pasture areas. This +*' realization also calculates the growth stocks in commercial plantations and natural +*' vegetation using LPJmL Carbon stocks. + +*' @limitations The exogenous implementation of pasture intensification cannot +*' capture feedbacks between land scarcity and efforts to improve pasture +*' management. Moreover, the magnitude of spillover effects from technological change +*' in the crop sector towards improvements in pasture management is very uncertain. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/14_yields/managementcalib_aug19/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/14_yields/managementcalib_aug19/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/14_yields/managementcalib_aug19/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/14_yields/managementcalib_aug19/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/14_yields/managementcalib_aug19/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/14_yields/managementcalib_aug19/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/14_yields/managementcalib_aug19/postsolve.gms" +$Ifi "%phase%" == "nl_fix" $include "./modules/14_yields/managementcalib_aug19/nl_fix.gms" +$Ifi "%phase%" == "nl_release" $include "./modules/14_yields/managementcalib_aug19/nl_release.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/14_yields/managementcalib_aug19/sets.gms b/modules/14_yields/managementcalib_aug19/sets.gms new file mode 100644 index 0000000000..894b3ac2f9 --- /dev/null +++ b/modules/14_yields/managementcalib_aug19/sets.gms @@ -0,0 +1,37 @@ +*** | (C) 2008-2025 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 + ltype14 calibration land types + / crop, past / + + k(kall) Primary products + / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, + oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, + foddr, pasture, cottn_pro, begr, betr, livst_rum, livst_pig, + livst_chick, livst_egg, livst_milk, fish, wood, woodfuel/ + + kve(k) Land-use activities + / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, + oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, + foddr, pasture, cottn_pro, begr, betr / + + kcr(kve) Cropping activities + / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, + oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, + foddr, cottn_pro, begr, betr / + + knbe14(kcr) Cropping activities excluding bioenergy plants + / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, + oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, + foddr, cottn_pro / + + ncp_type14 natures contributions to people (NCP) relevant for agricultural yields + / soil_intact, poll_suff / + +; + diff --git a/modules/14_yields/module.gms b/modules/14_yields/module.gms index a94b16407b..059e893eba 100644 --- a/modules/14_yields/module.gms +++ b/modules/14_yields/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -17,15 +17,16 @@ *' [@FAOSTAT]. For the simulation of the temporal development of agricultural *' yields, the module receives information about the agricultural land use *' intensity represented by the $\tau$ factor coming from the module [13_tc]. +*' Irrigated yields can optionally be calibrated to meet irrigated-rainfed +*' country-level yield ratios as reported by Aquastat [@fao_aquastat_2016]. *' *' The module returns yields for all crops and for pasture, which is then used *' by the modules [30_crop] and [31_past]. *' -*' @authors Jan Philipp Dietrich, Isabelle Weindl, Florian Humpenöder, Anne Biewald - +*' @authors Jan Philipp Dietrich, Isabelle Weindl, Florian Humpenöder, +*' Anne Biewald, Kristine Karstens *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%yields%" == "biocorrect" $include "./modules/14_yields/biocorrect/realization.gms" -$Ifi "%yields%" == "dynamic_aug18" $include "./modules/14_yields/dynamic_aug18/realization.gms" +$Ifi "%yields%" == "managementcalib_aug19" $include "./modules/14_yields/managementcalib_aug19/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/15_food/anthro_iso_jun22/declarations.gms b/modules/15_food/anthro_iso_jun22/declarations.gms new file mode 100644 index 0000000000..686c32084e --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/declarations.gms @@ -0,0 +1,273 @@ +*** | (C) 2008-2025 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 + q15_food_demand(i,kfo) Food demand (mio. kcal) +; + +positive variables + vm_dem_food(i,kall) Food demand (mio. tDM per yr) +; + + +*** #### Food Demand Model +equations + q15_aim Objective function of food demand model (mio. USD17PPP) + q15_budget(iso) Household budget constraint (USD17PPP per cap per day) + + q15_regr_bmi_shr(iso,sex,agegroup15,bmi_tree15) Estimates regression parameters for BMI regression shares (1) + q15_bmi_shr_verylow(iso,sex,agegroup15) Estimates BMI share for population groups with low BMI (1) + q15_bmi_shr_low(iso,sex,agegroup15) Estimates BMI share for population groups with very low BMI (1) + q15_bmi_shr_medium(iso,sex,agegroup15) Estimates BMI share for population groups with medium BMI(1) + q15_bmi_shr_medium_high(iso,sex,agegroup15) Estimates BMI share for population groups with medium to high BMI (1) + q15_bmi_shr_high(iso,sex,agegroup15) Estimates BMI share for population groups with high BMI (1) + q15_bmi_shr_veryhigh(iso,sex,agegroup15) Estimates BMI share for population groups with very high BMI (1) + q15_bmi_shr_agg(iso,sex,age,bmi_group15) Disaggregates age groups from overarching groups (1) + + q15_intake(iso) Estimates average intake for the entire country (kcal per cap per day) + q15_regr_kcal(iso) Per capita total demand (kcal per cap per day) + q15_regr(iso, regr15) Estimates parameters for food demand and dietary composition (1) + q15_foodtree_kcal_animals(iso,kfo_ap) Demand for animal products (kcal per cap per day) + 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) +; + + +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 (USD17PPP per cap) + v15_income_balance(iso) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD17PPP 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) +; + +variables + v15_objective Objective term (USD17PPP) +; + +scalars + s15_yeardiff Number of 5-year time intervalls between time steps (1) + s15_count Loop counter for interpolating body height estimates between longer timesteps (1) + s15_run_diet_postprocessing run diet postprocessing (1) +; + +parameters +* technical + p15_modelstat(t) Model solver status (1) + 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) + p15_ruminant_subst_fader(t_all) Ruminant meat substitution fader (1) + p15_fish_subst_fader(t_all) Fish substitution fader (1) + p15_alcohol_subst_fader(t_all) Alcohol substitution fader (1) + p15_livestock_subst_fader(t_all) Livestock substitution fader (1) + p15_rumdairy_subst_fader(t_all) Ruminant and dairy substitution fader (1) + p15_rumdairy_scp_subst_fader(t_all) Ruminant and dairy substitution with SCP fader (1) + p15_livestock_threshold_subst_fader(t_all) Fader for livestock threshold target (1) + p15_exo_food_scenario_fader(t_all) Exogenous diet scenario fader (1) + p15_shr_fafh(t,iso) Share of calories consumed away from home (1) + p15_marketing_margin_fah_kcal(t,iso,kfo) Value of the marketing margin per calorie consumed at home (USD17MER per kcal) + p15_marketing_margin_fah(t,iso, kfo) Value of the marketing margin per tDM consumed at home (USD17MER per tDM) + p15_marketing_margin_fafh_kcal(t,iso,kfo) Value of the marketing margin per calorie away from home (USD17MER per kcal) + p15_marketing_margin_fafh(t,iso, kfo) Value of the marketing margin per tDM away from home (USD17MER per tDM) + p15_value_added_expenditures_pc(t,iso,kfo) Expenditures on food value-added not including producer expenditures (USD17MER) + + +* 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) + + i15_bmi_intercept(sex,agegroup15,bmi_tree15) BMI share regression intercept (1) + 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) + i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15) Calibration parameters of the last year with historical observations (1) + +* diet structure + p15_intake(t,iso,sex,age,bmi_group15) Mean food intake by population group (kcal per capita per day) + i15_kcal_pregnancy(t,iso) Additional calorie requirements for pregnancy and lactation (kcal) + p15_kcal_regr(t, iso, kfo) Uncalibrated regression estimates of calorie demand (kcal per cap per day) + + 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_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(t,iso,kfo_pf) 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) + p15_kcal_calib_lastcalibyear(iso,kfo) Calibration factor for the last year with observations (kcal per cap per day) + p15_balanceflow_kcal(t,i,kfo) Balance flow for mismatch between FAOSTAT and demand estimates (kcal per capita per day) + p15_balanceflow_kcal_iso(t,iso,kfo) Balance flow for mismatch between FAOSTAT and demand estimates (kcal per capita per day) + p15_balanceflow_kcal_lastcalibyear(iso,kfo) Balance flow of last historic time step for mismatch between FAOSTAT and demand estimates (kcal per capita per day) + +* 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) + 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_calibrated_alliter(t,i,kfo,iter15) Calibrated per capita consumption in food demand model after each iteration (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_protein_pc_iso_scp(t,iso,kfo_rd) Per capita consumption of SCP in food demand model after price shock on country level (g protein 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_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_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) + 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) + 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) + 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) + +* country-specific scenario switch + p15_country_switch(iso) Switch indicating whether country is affected by diet scenarios (1) + +* elastic demand + p15_tax_recycling(t,iso) Tax revenue recycling to households (USD17PPP per capita) + p15_prices_kcal(t,iso,kfo,iter15) Prices from MAgPIE after optimization (USD17PPP per kcal) + i15_prices_initial_kcal(iso,kfo) Initial prices that capture the approximate level of prices in 1961-2010 (USD17PPP per kcal) + +* calculate diet iteration breakpoint + p15_income_pc_real_ppp(t,i) Regional per capita income after price shock on regional level (USD17PPP per capita) + p15_delta_income(t,i,iter15) Regional change in per capita income due to price shock on regional level (1) +; + +scalars + s15_scp_fat_per_milk Fat needed as ingredient for scp-based milk alternative (g per 100g wet matter) / 3.3 / + s15_scp_sugar_per_milk Sugar needed as ingredient for scp-based milk alternative (g per 100g wet matter) / 4.7 / + s15_scp_protein_per_milk Protein needed as ingredient for scp-based milk alternative (g per 100g wet matter) / 3.3 / + s15_scp_fat_content Fat content of microbial biomass based on Solein from Solar foods (t fat per t DM) / 0.05 / + s15_scp_fat_protein_ratio_meat Ratio of protein to fat in both plant based meat alternatives and current meat products (t fat per t protein) / 0.66 / +; + + +*' @code +*' The food demand model consists of the following equations, which are not +*' part of MAgPIE. +model m15_food_demand / + q15_aim, + q15_budget, + + q15_regr_bmi_shr, + + q15_bmi_shr_verylow, + q15_bmi_shr_low, + q15_bmi_shr_medium, + q15_bmi_shr_medium_high, + q15_bmi_shr_high, + q15_bmi_shr_veryhigh, + + q15_bmi_shr_agg, + + q15_intake, + q15_regr_kcal, + q15_regr, + + q15_foodtree_kcal_animals, + q15_foodtree_kcal_processed, + q15_foodtree_kcal_staples, + q15_foodtree_kcal_vegetables + /; + +*' In contrast, the equation `q15_food_demand` is part of MAgPIE, but +*' not of the food demand model. +*' @stop + +m15_food_demand.optfile = 0 ; +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) + ov15_kcal_regr(t,iso,kfo,type) Uncalibrated regression estimates of calorie demand (kcal per cap per day) + ov15_kcal_regr_total(t,iso,type) Uncalibrated regression estimates of total per cap calories (kcal per cap per day) + ov15_demand_regr(t,iso,regr15,type) Uncalibrated regression estimates of kcal shares (1) + ov15_income_pc_real_ppp_iso(t,iso,type) Real income per cap (USD17PPP per cap) + ov15_income_balance(t,iso,type) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD17PPP per cap per yr) + ov15_kcal_intake_total_regr(t,iso,type) Food intake (kcal per cap per day) + ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,type) Hierarchical tree parameter regressions (1) + ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,type) Uncalibrated share of population groups belonging to a certain BMI group (1) + ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,type) Uncalibrated share of population groups belonging to a certain BMI group (1) + ov15_objective(t,type) Objective term (USD17PPP) + oq15_food_demand(t,i,kfo,type) Food demand (mio. kcal) + oq15_aim(t,type) Objective function of food demand model (mio. USD17PPP) + oq15_budget(t,iso,type) Household budget constraint (USD17PPP per cap per day) + oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,type) Estimates regression parameters for BMI regression shares (1) + oq15_bmi_shr_verylow(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with low BMI (1) + oq15_bmi_shr_low(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with very low BMI (1) + oq15_bmi_shr_medium(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with medium BMI(1) + oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with medium to high BMI (1) + oq15_bmi_shr_high(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with high BMI (1) + oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with very high BMI (1) + oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,type) Disaggregates age groups from overarching groups (1) + oq15_intake(t,iso,type) Estimates average intake for the entire country (kcal per cap per day) + oq15_regr_kcal(t,iso,type) Per capita total demand (kcal per cap per day) + oq15_regr(t,iso,regr15,type) Estimates parameters for food demand and dietary composition (1) + oq15_foodtree_kcal_animals(t,iso,kfo_ap,type) Demand for animal products (kcal per cap per day) + oq15_foodtree_kcal_processed(t,iso,kfo_pf,type) Demand for processed products (kcal per cap per day) + oq15_foodtree_kcal_staples(t,iso,kfo_st,type) Demand for staple products (kcal per cap per day) + oq15_foodtree_kcal_vegetables(t,iso,type) Demand for vegetable and fruit products (kcal per cap per day) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/15_food/anthro_iso_jun22/equations.gms b/modules/15_food/anthro_iso_jun22/equations.gms new file mode 100644 index 0000000000..a3633529a5 --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/equations.gms @@ -0,0 +1,207 @@ +*** | (C) 2008-2025 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 + +q15_food_demand(i2,kfo) .. + (vm_dem_food(i2,kfo) + sum(ct, f15_household_balanceflow(ct,i2,kfo,"dm"))) + * sum(ct,(fm_nutrition_attributes(ct,kfo,"kcal") * 10**6)) =g= + sum(ct,im_pop(ct,i2) * p15_kcal_pc_calibrated(ct,i2,kfo)) * 365 + ; + +*' Above constraint transforms the fooduse of agricultural products into per capita +*' food demand. +*' `vm_dem_food` is the fooduse of agricultural products. It is measured in tons +*' of dry matter prior to processing. The multiplication with the nutrition attributes +*' provides the equivalent in calories. While nutrition attributes are assumed +*' to be globally the same +*' (assumption of homogeneous products), a regional balance flow is used to account +*' for current differences in food processing, where some regions get different calories +*' from the same fooduse quantitiy. Depending on the input data, the balance flow +*' may fade out in the future, which implies actual homogeneous products. + +*' The subsequent equations belong to the standalone food demand model, which is +*' executed before MAgPIE or iterated with MAgPIE. They are excluded from the run +*' of MAgPIE itself. + +q15_aim .. + v15_objective =e= + sum(iso, + - 10**6*v15_income_balance(iso)) + ; + +*' In principle, the food demand model has only one solution that satifies all +*' equations. Technically, the objective could therefore be chosen arbirtrarily, +*' for the solver to find the single solution. +*' However, if the model is executed outside its domain +*' (e.g. with extreme price shocks), it can happen that real income takes a +*' negative value (because the increase in food value exceeds the available income). +*' To avoid this case, a punishment term `v15_income_balance` is introduced. It +*' increases the real income, but affects the maximized objective variable +*' negatively, disincentivizing its use in cases where it is not needed. + + +q15_budget(iso) .. + v15_income_pc_real_ppp_iso(iso) =e= + sum(kfo, v15_kcal_regr(iso,kfo) * 365 + *(i15_prices_initial_kcal(iso,kfo) - sum((ct,prev_iter15), p15_prices_kcal(ct,iso,kfo,prev_iter15)))) + + sum(ct, im_gdp_pc_ppp_iso(ct,iso) + p15_tax_recycling(ct,iso)) + v15_income_balance(iso); + +*' The budget constraint calculates the real income after a possible price +*' shock. The basic assumption is that increasing prices reduce real income, +*' while decreasing prices increase real income. +*' Through this income effect, higher prices reduce the food demand. +*' The income before the food price shock is `im_gdp_pc_ppp_iso`. +*' It is reduced by the change in value of the demanded calories under changed +*' prices. +*' In the following, the real income is used to determine food intake, +*' food demand as well as dietary composition. + +*' The BMI distribution within the population is calculated using +*' regressions in a hierachical tree to estimate the share of the population +*' falling into a certain BMI class. +*' ![Hierarchical tree used to estimate BMI population shares](hierarchical_tree.png){ width=100% } + +*' First, the regression shares are calculated: + +q15_regr_bmi_shr(iso,sex,agegroup15,bmi_tree15) .. + v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) + =e= + i15_bmi_intercept(sex,agegroup15,bmi_tree15) + + (i15_bmi_saturation(sex,agegroup15,bmi_tree15) * (v15_income_pc_real_ppp_iso(iso) * fm_gdp_defl_ppp(iso))) + / (i15_bmi_halfsat(sex,agegroup15,bmi_tree15) + (v15_income_pc_real_ppp_iso(iso) * fm_gdp_defl_ppp(iso))); + +*' Then, these regression shares are applied to parameterize the +*' hierarchical tree structure: + +q15_bmi_shr_verylow(iso,sex,agegroup15) .. + v15_bmi_shr_overgroups(iso,sex,agegroup15,"verylow") + =e= + v15_regr_overgroups(iso,sex,agegroup15,"low") + * v15_regr_overgroups(iso,sex,agegroup15,"lowsplit") + ; + +q15_bmi_shr_low(iso,sex,agegroup15) .. + v15_bmi_shr_overgroups(iso,sex,agegroup15,"low") + =e= + v15_regr_overgroups(iso,sex,agegroup15,"low") + * (1- v15_regr_overgroups(iso,sex,agegroup15,"lowsplit")) + ; + +q15_bmi_shr_medium(iso,sex,agegroup15) .. + v15_bmi_shr_overgroups(iso,sex,agegroup15,"medium") + =e= + (1-v15_regr_overgroups(iso,sex,agegroup15,"low") + -v15_regr_overgroups(iso,sex,agegroup15,"high")) + * (1-v15_regr_overgroups(iso,sex,agegroup15,"mediumsplit")) + ; + +q15_bmi_shr_medium_high(iso,sex,agegroup15) .. + v15_bmi_shr_overgroups(iso,sex,agegroup15,"mediumhigh") + =e= + (1-v15_regr_overgroups(iso,sex,agegroup15,"low") + -v15_regr_overgroups(iso,sex,agegroup15,"high")) + * v15_regr_overgroups(iso,sex,agegroup15,"mediumsplit") + ; + +q15_bmi_shr_high(iso,sex,agegroup15) .. + v15_bmi_shr_overgroups(iso,sex,agegroup15,"high") + =e= + v15_regr_overgroups(iso,sex,agegroup15,"high") + * (1-v15_regr_overgroups(iso,sex,agegroup15,"highsplit")) + ; + +q15_bmi_shr_veryhigh(iso,sex,agegroup15) .. + v15_bmi_shr_overgroups(iso,sex,agegroup15,"veryhigh") + =e= + v15_regr_overgroups(iso,sex,agegroup15,"high") + * v15_regr_overgroups(iso,sex,agegroup15,"highsplit") + ; + + +*' From BMI shares of the larger groups (overgroups), we disaggregate to +*' age-specific subgroups. + +q15_bmi_shr_agg(iso,sex,age,bmi_group15) .. + v15_bmi_shr_regr(iso,sex,age,bmi_group15) + =e= + sum(agegroup2age(agegroup15,age), + v15_bmi_shr_overgroups(iso,sex,agegroup15,bmi_group15) + ); + + +*' Food intake is estimated based on BMI distribution, typical intakes for +*' BMI groups, demographic structure and extra energy requirements for +*' pregnancy and lactation (estimated based on the new-born population size). + +q15_intake(iso).. + v15_kcal_intake_total_regr(iso) + * sum((sex,age,ct), im_demography(ct,iso,sex,age)) + =e= + sum((ct, sex, age, bmi_group15), + v15_bmi_shr_regr(iso,sex,age,bmi_group15)* + im_demography(ct,iso,sex,age) * + p15_intake(ct,iso,sex,age,bmi_group15) + ) + + sum(ct,i15_kcal_pregnancy(ct,iso)) + ; + + +*' Food demand is based on food intake and a regression +*' based on income, which estimates how much the actual demand is relative to +*' the required intake. +*' The difference between demand and intake is food waste (not explicitly +*' mentioned in this equation) + +q15_regr_kcal(iso) .. + v15_kcal_regr_total(iso) =e= + v15_demand_regr(iso, "overconsumption") + *v15_kcal_intake_total_regr(iso); + +*' This equation estimates key dietary composition regressision factors, +*' such as the share of animal products, empty calories, or +*' fruits, vegetables and nuts. + +q15_regr(iso, regr15) .. + v15_demand_regr(iso, regr15) =e= + i15_dem_intercept(iso,regr15) + + (i15_dem_saturation(iso,regr15) * (v15_income_pc_real_ppp_iso(iso) * fm_gdp_defl_ppp(iso))) + / (i15_dem_halfsat(iso,regr15) + (v15_income_pc_real_ppp_iso(iso) * fm_gdp_defl_ppp(iso) )**i15_dem_nonsat(iso,regr15)); + +*' In the subsequent equations, those parameters +*' are used to determine the dietary composition using a hierachical tree: +*' Total calories are first divided into animal- and plant-based. The plant-based +*' calories are further divided into processed empty calories and nutritious +*' calories, and so on. + +q15_foodtree_kcal_animals(iso,kfo_ap) .. + v15_kcal_regr(iso,kfo_ap) =e= + v15_kcal_regr_total(iso) + * v15_demand_regr(iso, "livestockshare") + * sum(ct,i15_livestock_kcal_structure_iso(ct,iso,kfo_ap)); + +q15_foodtree_kcal_processed(iso,kfo_pf) .. + v15_kcal_regr(iso,kfo_pf) =e= + v15_kcal_regr_total(iso) + * (1 - v15_demand_regr(iso, "livestockshare")) + * v15_demand_regr(iso, "processedshare") + * sum(ct,i15_processed_kcal_structure_iso(ct,iso,kfo_pf)) ; + +q15_foodtree_kcal_vegetables(iso) .. + v15_kcal_regr(iso,"others") =e= + v15_kcal_regr_total(iso) + * (1 - v15_demand_regr(iso, "livestockshare")) + * (1 - v15_demand_regr(iso, "processedshare")) + * v15_demand_regr(iso, "vegfruitshare"); + +q15_foodtree_kcal_staples(iso,kfo_st) .. + v15_kcal_regr(iso,kfo_st) =e= + v15_kcal_regr_total(iso) + * (1 - v15_demand_regr(iso, "livestockshare")) + * (1 - v15_demand_regr(iso, "processedshare")) + * (1 - v15_demand_regr(iso, "vegfruitshare")) + * sum(ct,i15_staples_kcal_structure_iso(ct,iso,kfo_st)) ; diff --git a/modules/15_food/anthro_iso_jun22/exodietmacro.gms b/modules/15_food/anthro_iso_jun22/exodietmacro.gms new file mode 100644 index 0000000000..cf9d896e8d --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/exodietmacro.gms @@ -0,0 +1,778 @@ +*** | (C) 2008-2025 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 + +*' as include statements are not allowed within the if statements, we execute +*' the if statement before, put the result in s15_run_diet_postprocessing, +*' and then execute the if statement again within the included file: +if (s15_run_diet_postprocessing = 1, + +*' This macro is executed twice, once after the presolve and once in the +*' intersolve. It calibrates the values, includes exogenous diet modifications +*' in the postprocessing and aggregates to regional level. + +* saving regression outcome for per capita food demand for different foods + p15_kcal_regr(t, iso, kfo) = v15_kcal_regr.l(iso, kfo); + +*' The calibration factor is added to the regression value. + p15_kcal_pc_iso(t,iso,kfo) = + 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; + +* 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); + + p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15) = + p15_bmi_shr_regr(t,iso,sex,age,bmi_group15) + i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) * s15_calibrate; + +* The BMI shares are not allowed to exceed the bounds 0 and 1. Values are corrected to the bounds. + p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15)$(p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15)<0) = 0; + p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15)$(p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15)>1) = 1; +* The mismatch is balanced by moving the exceeding quantities into the middle BMI group. + p15_bmi_shr_calibrated(t,iso,sex,age,"medium")= + 1 - (sum(bmi_group15, p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15)) + - p15_bmi_shr_calibrated(t,iso,sex,age,"medium")); + + + +*############################################################################### +* ###### 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") = + p15_kcal_pc_iso_orig(t,iso,"livst_rum") * i15_ruminant_fadeout(t,iso); + p15_kcal_pc_iso(t,iso,"livst_chick") = p15_kcal_pc_iso_orig(t,iso,"livst_chick") + + p15_kcal_pc_iso_orig(t,iso,"livst_rum") * (1- i15_ruminant_fadeout(t,iso)); + + +* Substitution of fish with poultry: + p15_kcal_pc_iso_orig(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); + p15_kcal_pc_iso(t,iso,"fish") = + p15_kcal_pc_iso_orig(t,iso,"fish") * i15_fish_fadeout(t,iso); + p15_kcal_pc_iso(t,iso,"livst_chick") = p15_kcal_pc_iso_orig(t,iso,"livst_chick") + + p15_kcal_pc_iso_orig(t,iso,"fish") * (1-i15_fish_fadeout(t,iso)); + + +* Fade-out of alcohol consumption without substitution: +* (leads to inconsistencies with BMI estimates) + p15_kcal_pc_iso_orig(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); + p15_kcal_pc_iso(t,iso,"alcohol") = + p15_kcal_pc_iso_orig(t,iso,"alcohol") * i15_alcohol_fadeout(t,iso); + + +* Substitution of livestock products (without fish) with plant-based food commodities: + p15_kcal_pc_iso_orig(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); + p15_kcal_pc_iso_livestock_orig(t,iso) = sum(kfo_lp,p15_kcal_pc_iso(t,iso,kfo_lp)); + p15_kcal_pc_iso_plant_orig(t,iso) = sum(kfo_pp,p15_kcal_pc_iso(t,iso,kfo_pp)); + + p15_livestock_kcal_structure_orig(t,iso,kfo_lp)$(p15_kcal_pc_iso_livestock_orig(t,iso)>0) = + p15_kcal_pc_iso(t,iso,kfo_lp) + /p15_kcal_pc_iso_livestock_orig(t,iso); + + p15_plant_kcal_structure_orig(t,iso,kfo_pp)$(p15_kcal_pc_iso_plant_orig(t,iso)>0) = + p15_kcal_pc_iso(t,iso,kfo_pp) + /p15_kcal_pc_iso_plant_orig(t,iso); + + p15_kcal_pc_iso(t,iso,kfo_lp) = p15_livestock_kcal_structure_orig(t,iso,kfo_lp) + *p15_kcal_pc_iso_livestock_orig(t,iso)*i15_livestock_fadeout(t,iso); + p15_kcal_pc_iso(t,iso,kfo_pp) = p15_plant_kcal_structure_orig(t,iso,kfo_pp) + *(p15_kcal_pc_iso_plant_orig(t,iso) + + p15_kcal_pc_iso_livestock_orig(t,iso) * (1-i15_livestock_fadeout(t,iso))); + + +* Substitution of ruminant meat and dairy products with plant-based food commodities: + p15_kcal_pc_iso_orig(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); + p15_kcal_pc_iso_rumdairy_orig(t,iso) = sum(kfo_rd,p15_kcal_pc_iso(t,iso,kfo_rd)); + p15_kcal_pc_iso_plant_orig(t,iso) = sum(kfo_pp,p15_kcal_pc_iso(t,iso,kfo_pp)); + + p15_rumdairy_kcal_structure_orig(t,iso,kfo_rd)$(p15_kcal_pc_iso_rumdairy_orig(t,iso)>0) = + p15_kcal_pc_iso(t,iso,kfo_rd) + /p15_kcal_pc_iso_rumdairy_orig(t,iso); + + p15_plant_kcal_structure_orig(t,iso,kfo_pp)$(p15_kcal_pc_iso_plant_orig(t,iso)>0) = + p15_kcal_pc_iso(t,iso,kfo_pp) + /p15_kcal_pc_iso_plant_orig(t,iso); + + p15_kcal_pc_iso(t,iso,kfo_rd) = p15_rumdairy_kcal_structure_orig(t,iso,kfo_rd) + *p15_kcal_pc_iso_rumdairy_orig(t,iso)*i15_rumdairy_fadeout(t,iso); + p15_kcal_pc_iso(t,iso,kfo_pp) = p15_plant_kcal_structure_orig(t,iso,kfo_pp) + *(p15_kcal_pc_iso_plant_orig(t,iso) + + p15_kcal_pc_iso_rumdairy_orig(t,iso) * (1- i15_rumdairy_fadeout(t,iso))); + +*' @code +*' Substitution of ruminant meat and dairy products (kfo_rd) with single-cell protein (SCP) based on 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"). +*' +*' Protein to kcal ratio: +i15_protein_to_kcal_ratio(t,kfo) = fm_nutrition_attributes(t,kfo,"protein") / fm_nutrition_attributes(t,kfo,"kcal"); +*' +*' Increase of single-cell protein (SCP): +p15_protein_pc_iso_scp(t,iso,kfo_rd) = p15_kcal_pc_iso(t,iso,kfo_rd) * (1-i15_rumdairy_scp_fadeout(t,iso)) * i15_protein_to_kcal_ratio(t,kfo_rd); +p15_kcal_pc_iso(t,iso,"scp") = p15_kcal_pc_iso(t,iso,"scp") + sum(kfo_rd, p15_protein_pc_iso_scp(t,iso,kfo_rd)) / i15_protein_to_kcal_ratio(t,"scp"); +*' +*' Reduction of ruminant meat and dairy products (kfo_rd): +p15_kcal_pc_iso(t,iso,kfo_rd) = p15_kcal_pc_iso(t,iso,kfo_rd) * i15_rumdairy_scp_fadeout(t,iso); +*' +*' Plant oil and sugar demands as ingredients for animal-free milk alternative production using single cell protein +*' are calculated based on the ratio of fat or sugar to protein in cow milk. +*' This ratio is typically reported on a mass basis, but the ratio is converted here to be based on caloric content. +*' Cow milk content is chosen as the dominant source of milk produced globally. +*' Data sources: @muehlhoff_milk_2013 and @fao_food_2004 +*' +p15_kcal_pc_iso(t,iso,"oils") = p15_kcal_pc_iso(t,iso,"oils") + + sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_protein_pc_iso_scp(t,iso,kfo_rd)) / + s15_scp_protein_per_milk * s15_scp_fat_per_milk * fm_nutrition_attributes(t,"oils", "kcal"); +*' +p15_kcal_pc_iso(t,iso,"sugar") = p15_kcal_pc_iso(t,iso,"sugar") + + sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_protein_pc_iso_scp(t,iso,kfo_rd)) / + s15_scp_protein_per_milk * s15_scp_sugar_per_milk * fm_nutrition_attributes(t, "sugar" ,"kcal"); +*' +*' The ratio of fat to protein in raw microbial biomass (used as single cell protein) is much lower than for +*' plant based meat alternatives and animal based meat products. If the desired microbial product is alternative meat, +*' this may require supplementation with plant based fats to more closely match other existing products. +*' It is therefore possible to choose whether microbial biomass should be supplemented with plant based oil, +*' which drives additional demand for plant based oil production in MAgPIE. +*' For alternative microbial meats supplemented with fat, the desired fat to protein ratio is given +*' as 2:3 on a mass basis, analogous to similar products. Because microbial biomass already contains some fats, +*' the additional amount of plant based fat needed is given as the difference between the amount of fat present +*' in microbial biomass and the amount of fat needed to reach the desired protein to fat ratio. +*' Unlike additional plant oil and sugar demand for microbial milk, the additional amount of plant fat needed +*' for microbial meat is calculated dynamically based on the protein content of microbial biomass. +*' This is because the microbial protein content varies depending on the specific type of microbes used +*' (e.g. bacteria or funghi), whereas the nutritional content of cow milk is assumed to be fixed. +*' If the microbial protein is therefore changed, the amount of fat must also change to keep the same +*' fat to protein ratio. It is also assumed, unlike for microbial milk, that additional carbohydrates +*' (e.g., sugar) are not required for alternative microbial meats. This is because meat products contain +*' very little or no carbohydrates. +*' Data sources: @mazac_novelfoods_2023 and @jarvio_LCA_MP_2021 +*' +p15_kcal_pc_iso(t,iso,"oils")$(s15_scp_supplement_fat_meat = 1) = p15_kcal_pc_iso(t,iso,"oils") + + sum(kfo_rd$sameas(kfo_rd,"livst_rum"), p15_protein_pc_iso_scp(t,iso,kfo_rd)) / + fm_nutrition_attributes(t,"scp", "protein") * (fm_nutrition_attributes(t,"scp", "protein") * + s15_scp_fat_protein_ratio_meat - s15_scp_fat_content) * fm_nutrition_attributes(t,"oils", "kcal"); +*' +*' @stop + +* Conditional reduction of livestock products (without fish) depending on s15_kcal_pc_livestock_supply_target. +* Optional substitution with plant-based products depending on s15_livescen_target_subst. + p15_kcal_pc_iso_orig(t,iso,kfo) = p15_kcal_pc_iso(t,iso,kfo); + p15_kcal_pc_iso_livestock_orig(t,iso) = sum(kfo_lp,p15_kcal_pc_iso(t,iso,kfo_lp)); + p15_kcal_pc_iso_plant_orig(t,iso) = sum(kfo_pp,p15_kcal_pc_iso(t,iso,kfo_pp)); + + p15_livestock_kcal_structure_orig(t,iso,kfo_lp)$(p15_kcal_pc_iso_livestock_orig(t,iso)>0) = + p15_kcal_pc_iso(t,iso,kfo_lp) + /p15_kcal_pc_iso_livestock_orig(t,iso); + + p15_plant_kcal_structure_orig(t,iso,kfo_pp)$(p15_kcal_pc_iso_plant_orig(t,iso)>0) = + p15_kcal_pc_iso(t,iso,kfo_pp) + /p15_kcal_pc_iso_plant_orig(t,iso); + + p15_kcal_pc_livestock_supply_target(iso) = s15_kcal_pc_livestock_supply_target * f15_overcons_FAOwaste(iso,"livst_rum"); + + loop(iso$(p15_kcal_pc_iso_livestock_orig(t,iso) > p15_kcal_pc_livestock_supply_target(iso)), + p15_kcal_pc_iso(t,iso,kfo_lp) = p15_livestock_kcal_structure_orig(t,iso,kfo_lp) + * (p15_kcal_pc_livestock_supply_target(iso)*(1-i15_livestock_fadeout_threshold(t,iso)) + + p15_kcal_pc_iso_livestock_orig(t,iso)*i15_livestock_fadeout_threshold(t,iso)); + p15_kcal_pc_iso(t,iso,kfo_pp) = p15_plant_kcal_structure_orig(t,iso,kfo_pp) + * (p15_kcal_pc_iso_plant_orig(t,iso) + + (p15_kcal_pc_iso_livestock_orig(t,iso) - + sum(kfo_lp, p15_kcal_pc_iso(t,iso,kfo_lp))) * s15_livescen_target_subst); + ); + + +*############################################################################### +* ###### WASTE CALCULATIONS (required for exogenous food waste or diet scenarios) + +* The ratio of food demand at household level to food intake is determined +* by the amount of food that is wasted. This ratio is one of the drivers of +* future food demand trajetories. +* For the calculation of the ratio between food demand and intake, total food +* calorie intake based on CALIBRATED parameters needs to be calculated: + + p15_intake_total(t,iso)$(sum((sex,age), im_demography(t,iso,sex,age)) >0 ) = + (sum((sex, age, bmi_group15), p15_bmi_shr_calibrated(t,iso,sex,age,bmi_group15)* + 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)); + + p15_demand2intake_ratio(t,iso) = 1$(p15_intake_total(t,iso) = 0) + + (sum(kfo,p15_kcal_pc_iso(t,iso,kfo)) / p15_intake_total(t,iso))$( + p15_intake_total(t,iso) <> 0); + + +* Next, we derive a product-specific waste share, which uses product specific +* waste shares from FAO and calibrates them to meet total +* food waste ratio. +* To achieve maximum consistency, this calibration involves three steps. + +* 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)$(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 + 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. +* 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) + ( + 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)) + )$(sum(kfo2, p15_waste_pc(t,iso,kfo2))<>0); + + 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. + 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 + 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); + +* Bodyheight is estimated based on a calorie availabiltiy regression, including +* waste. As food waste scenarios should not affect bodyheight, we apply the +* normal food waste ratios for the growth estimates + p15_demand2intake_ratio_detail_preexo(t,iso,kfo)=p15_demand2intake_ratio_detail(t,iso,kfo); + +* ###### Exogenous EAT Lancet diet scenario + +*' @code +*' 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 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, + +*' 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; + p15_bmi_shr_target(t,iso,sex,age,"medium")=1; + + i15_intake_scen_target(t,iso)$(sum((sex,age), im_demography(t,iso,sex,age)) >0 ) = + (sum((sex, age, bmi_group15), p15_bmi_shr_target(t,iso,sex,age,bmi_group15)* + 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" + + 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")= + p15_bmi_shr_calibrated(t,iso,sex,age,"verylow") + + p15_bmi_shr_calibrated(t,iso,sex,age,"low") + + p15_bmi_shr_calibrated(t,iso,sex,age,"medium"); + p15_bmi_shr_target(t,iso,sex,age,"verylow")=0; + p15_bmi_shr_target(t,iso,sex,age,"low")=0; + + i15_intake_scen_target(t,iso)$(sum((sex,age), im_demography(t,iso,sex,age)) >0 ) = + (sum((sex, age, bmi_group15), p15_bmi_shr_target(t,iso,sex,age,bmi_group15)* + 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_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")= + p15_bmi_shr_calibrated(t,iso,sex,age,"mediumhigh") + + p15_bmi_shr_calibrated(t,iso,sex,age,"high") + + p15_bmi_shr_calibrated(t,iso,sex,age,"veryhigh") + + p15_bmi_shr_calibrated(t,iso,sex,age,"medium"); + p15_bmi_shr_target(t,iso,sex,age,"mediumhigh")=0; + p15_bmi_shr_target(t,iso,sex,age,"high")=0; + p15_bmi_shr_target(t,iso,sex,age,"veryhigh")=0; + i15_intake_scen_target(t,iso)$(sum((sex,age), im_demography(t,iso,sex,age)) >0 ) = + (sum((sex, age, bmi_group15), p15_bmi_shr_target(t,iso,sex,age,bmi_group15)* + 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")= + p15_bmi_shr_calibrated(t,iso,sex,age,"mediumhigh")/2 + + p15_bmi_shr_calibrated(t,iso,sex,age,"high")/2 + + p15_bmi_shr_calibrated(t,iso,sex,age,"veryhigh")/2 + + p15_bmi_shr_calibrated(t,iso,sex,age,"medium"); + p15_bmi_shr_target(t,iso,sex,age,"mediumhigh")=p15_bmi_shr_calibrated(t,iso,sex,age,"mediumhigh")/2; + p15_bmi_shr_target(t,iso,sex,age,"high")=p15_bmi_shr_calibrated(t,iso,sex,age,"high")/2; + p15_bmi_shr_target(t,iso,sex,age,"veryhigh")=p15_bmi_shr_calibrated(t,iso,sex,age,"veryhigh")/2; + i15_intake_scen_target(t,iso)$(sum((sex,age), im_demography(t,iso,sex,age)) >0 ) = + (sum((sex, age, bmi_group15), p15_bmi_shr_target(t,iso,sex,age,bmi_group15)* + 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") = + p15_bmi_shr_calibrated(t,iso,sex,age,"verylow") + + p15_bmi_shr_calibrated(t,iso,sex,age,"low") + + p15_bmi_shr_calibrated(t,iso,sex,age,"mediumhigh")/2 + + p15_bmi_shr_calibrated(t,iso,sex,age,"high")/2 + + p15_bmi_shr_calibrated(t,iso,sex,age,"veryhigh")/2 + + p15_bmi_shr_calibrated(t,iso,sex,age,"medium"); + p15_bmi_shr_target(t,iso,sex,age,"verylow")=0; + p15_bmi_shr_target(t,iso,sex,age,"low")=0; + p15_bmi_shr_target(t,iso,sex,age,"mediumhigh")=p15_bmi_shr_calibrated(t,iso,sex,age,"mediumhigh")/2; + p15_bmi_shr_target(t,iso,sex,age,"high")=p15_bmi_shr_calibrated(t,iso,sex,age,"high")/2; + p15_bmi_shr_target(t,iso,sex,age,"veryhigh")=p15_bmi_shr_calibrated(t,iso,sex,age,"veryhigh")/2; + i15_intake_scen_target(t,iso)$(sum((sex,age), im_demography(t,iso,sex,age)) >0 ) = + (sum((sex, age, bmi_group15), p15_bmi_shr_target(t,iso,sex,age,bmi_group15)* + 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 + +*' The intake target is adjusted to meet the calorie target + 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); + + 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. + +*---------------------------------------------------------------------------------------- +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 +*' 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); + +*' upper bound for monogastric meat and eggs + if (s15_exo_monogastric=1, + 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, + 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, + p15_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, + 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, + 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, + 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, + p15_intake_detailed_scen_target(t,iso,"oils") = i15_intake_EATLancet(iso,"oils")); +*' target value for brans + if (s15_exo_brans=1, + p15_intake_detailed_scen_target(t,iso,"brans") = i15_intake_EATLancet(iso,"brans")); +*' target value for single cell protein + if (s15_exo_scp=1, + 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, + 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); + ); + + 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 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; + 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), p15_intake_detailed_scen_target(t,iso,kfo)) < (-1e-10), + 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 +*' (`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. +* Note: brans is the only food commodity group that will not be affected +* by the following calculations. + +* 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 single targets can be set manually via switches +*' (e.g., s15_exo_ruminant, s15_exo_fish, etc.). + +*' upper bound for monogastric products + if (s15_exo_monogastric = 1, +* upper bound for eggs + p15_intake_detailed_scen_target(t,iso,"livst_egg")$(p15_intake_detail(t,iso,"livst_egg") + > f15_rec_EATLancet(iso,"t_livst_egg","max") + ) = + f15_rec_EATLancet(iso,"t_livst_egg","max"); +* upper bound for chicken + p15_intake_detailed_scen_target(t,iso,"livst_chick")$(p15_intake_detail(t,iso,"livst_chick") + > f15_rec_EATLancet(iso,"t_livst_chick","max") + ) = + f15_rec_EATLancet(iso,"t_livst_chick","max"); +* upper bound for redmeat (share of pigs in redmeat) + 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))) + * f15_rec_EATLancet(iso,"t_redmeat","max"); + ); + +*' upper bound for ruminant products + if (s15_exo_ruminant = 1, +* upper bound for redmeat (pig and ruminant) + 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))) + * f15_rec_EATLancet(iso,"t_redmeat","max"); +* upper bound for milk + p15_intake_detailed_scen_target(t,iso,"livst_milk")$(p15_intake_detail(t,iso,"livst_milk") + > f15_rec_EATLancet(iso,"t_livst_milk","max") + ) = + f15_rec_EATLancet(iso,"t_livst_milk","max"); + ); + +*' lower bound for fish + if (s15_exo_fish = 1, + p15_intake_detailed_scen_target(t,iso,"fish")$(p15_intake_detail(t,iso,"fish") + < f15_rec_EATLancet(iso,"t_fish","min") + ) = + f15_rec_EATLancet(iso,"t_fish","min"); + ); + + +*** Special case: Fruits, vegetables, nuts, and roots *** +*' 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_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 + 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 + 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: + 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_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: + 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 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 +*' (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 + 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_detailed_scen_starchyfruit(t,iso)) + ; + +*' The resulting intake of the "others" category is: + 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") - 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. + 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: + 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"); + + ); + +* Assign starchy fruit and cassava roots back to cassava_sp scenario target + p15_intake_detailed_scen_target(t,iso,"cassav_sp") = + p15_intake_detailed_scen_roots(t,iso) - + p15_intake_detailed_scen_target(t,iso,"potato") + + p15_intake_detailed_scen_starchyfruit(t,iso); + +*' lower bound for legumes + if (s15_exo_pulses = 1, + 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))) + * f15_rec_EATLancet(iso,"t_legumes","min"); + ); + +*' upper bound for sugar + if (s15_exo_sugar = 1, + p15_intake_detailed_scen_target(t,iso,"sugar")$(p15_intake_detail(t,iso,"sugar") + > f15_rec_EATLancet(iso,"t_sugar","max") + ) = + f15_rec_EATLancet(iso,"t_sugar","max"); + ); + +*' upper and lower bound for oils + if (s15_exo_oils = 1, +* 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") + ) = + f15_rec_EATLancet(iso,"t_oils","min"); + +* oil palm has a maximum recommendation in EAT + p15_intake_detailed_scen_target(t,iso,"oils")$(p15_intake_detail(t,iso,"oils") + > f15_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: + 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, + 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, + 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, + 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 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 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; + 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), p15_intake_detailed_scen_target(t,iso,kfo)) < (-1e-10), + display p15_intake_detailed_scen_target; + abort "The parameter p15_intake_detailed_scen_target became negative after calorie balancing."; + ); + +* Correction of very small values + p15_intake_detailed_scen_target(t,iso,kfo)$(p15_intake_detailed_scen_target(t,iso,kfo) < 0) = 0; + + +); +*** 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 +*' 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)) + + 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); + +); +*** End of special postprocessing food demand scenarios. + + +*' 4.) The fourth step estimates the calorie supply at household level by multiplying +*' daily per capita calorie intake with the demand2intake ratio that was estimated +*' 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); + +*' 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); + + p15_demand2intake_ratio(t,iso) = 1$(p15_intake_total(t,iso) = 0) + + (sum(kfo,p15_kcal_pc_iso(t,iso,kfo)) / p15_intake_total(t,iso))$( + p15_intake_total(t,iso) > 0); + + +* ###### Exogenous food waste scenario +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); + +); + +*' 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)); + +*' Waste ratio is applied + p15_kcal_pc_iso(t,iso,kfo) = p15_intake_detail(t,iso,kfo) + p15_waste_pc(t,iso,kfo); + +*' Demand intake detail + 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); + + +*' The country-level parameter p15_kcal_pc_iso is aggregated to the +*' regional level. After removing estimates from countries that are not included +*' in FAOSTAT, the resulting parameter p15_kcal_pc_calibrated is provided to +*' constraint q15_food_demand in the MAgPIE model, which defines the demand for food. + +*' Results are aggregated to regions + p15_kcal_pc(t,i,kfo)$( + sum(i_to_iso(i,iso), + im_pop_iso(t,iso) + ) > 0) = + sum(i_to_iso(i,iso), + p15_kcal_pc_iso(t,iso,kfo) + * im_pop_iso(t,iso) + ) / sum(i_to_iso(i,iso), + im_pop_iso(t,iso) + ); + + p15_balanceflow_kcal(t,i,kfo)$( + sum(i_to_iso(i,iso), + im_pop_iso(t,iso) + ) > 0) = + sum(i_to_iso(i,iso), + p15_balanceflow_kcal_iso(t,iso,kfo) + * im_pop_iso(t,iso) + ) / sum(i_to_iso(i,iso), + im_pop_iso(t,iso) + ); + + +*' 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_alliter(t,i,kfo,curr_iter15) = p15_kcal_pc(t,i,kfo) + p15_balanceflow_kcal(t,i,kfo); + p15_kcal_pc_calibrated_alliter(t,i,kfo,curr_iter15)$(p15_kcal_pc_calibrated_alliter(t,i,kfo,curr_iter15) < 0) = 0; + +*' If the model requires more than 3 iterations, the convergence should be supported by averaging between iterations + if (p15_iteration_counter(t) <= 3, + p15_kcal_pc_calibrated(t,i,kfo) = sum(curr_iter15, p15_kcal_pc_calibrated_alliter(t,i,kfo,curr_iter15)); + else + p15_kcal_pc_calibrated(t,i,kfo) = + sum(curr_iter15, p15_kcal_pc_calibrated_alliter(t,i,kfo,curr_iter15) * (1-s15_convergence_partstep)) + + sum(prev_iter15, p15_kcal_pc_calibrated_alliter(t,i,kfo,prev_iter15) * (s15_convergence_partstep)); + ); + + + + p15_kcal_pc_calibrated(t,i,kfo) = round(p15_kcal_pc_calibrated(t,i,kfo), 2); + +*' @stop + ); diff --git a/modules/15_food/anthro_iso_jun22/food_demand_coupling.png b/modules/15_food/anthro_iso_jun22/food_demand_coupling.png new file mode 100644 index 0000000000..57d25b92f7 Binary files /dev/null and b/modules/15_food/anthro_iso_jun22/food_demand_coupling.png differ diff --git a/modules/15_food/anthro_iso_jun22/food_demand_coupling.svg b/modules/15_food/anthro_iso_jun22/food_demand_coupling.svg new file mode 100644 index 0000000000..225cf78a02 --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/food_demand_coupling.svg @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + D + + elastic + inelastic + + t+1 + + + standalone + coupling + presolve + D + intersolve + M + + + standalone + coupling + M + + t+1 + + t+1 + converged + + + not converged + + D + intersolve + t+1 + M + ... + + iteration>x + fail + + t+1 + + diff --git a/modules/15_food/anthropometrics_jan18/hierarchical_tree.png b/modules/15_food/anthro_iso_jun22/hierarchical_tree.png similarity index 100% rename from modules/15_food/anthropometrics_jan18/hierarchical_tree.png rename to modules/15_food/anthro_iso_jun22/hierarchical_tree.png diff --git a/modules/15_food/anthro_iso_jun22/input.gms b/modules/15_food/anthro_iso_jun22/input.gms new file mode 100644 index 0000000000..346e58f343 --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/input.gms @@ -0,0 +1,271 @@ +*** | (C) 2008-2025 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 + + +$setglobal c15_food_scenario SSP2 +$setglobal c15_food_scenario_noselect SSP2 +* options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" +* SRES: "A1", "A2", "B1", "B2" +* OTHER: "SSP1_boundary", "SSP2_boundary", "SSP3_boundary", "SSP4_boundary", "SSP5_boundary" + +$setglobal c15_calibscen constant +* options: constant, fadeout2050 + +$setglobal c15_rum_share mixed +* options: constant, halving2050, mixed + +$setglobal c15_kcal_scen healthy_BMI +* options: healthy_BMI, 2100kcal, 2500kcal, +* endo, no_underweight, no_overweight +* half_overweight, no_underweight_half_overweight + +$setglobal c15_EAT_scen FLX +* options: BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat + + + +* Set-switch for countries affected by country-specific exogenous diet scenario +* Default: all iso countries selected +sets + scen_countries15(iso) countries to be affected by selected food sceanrio / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +$onMultiR +set kfo_rd(kfo) Ruminant meat and dairy food products / livst_rum /; +$offMulti + +scalars +s15_elastic_demand Elastic demand switch (1=elastic 0=exogenous) (1) / 0 / +s15_tax_recycling Tax recycling multiplier (1=distribution neutral) (1) / 1 / +s15_calibrate Calibration switch (1=calibrated 0=pure regression outcomes) (1) / 1 / +* only for per-capita calories, not for e.g. calibration of transformation parameters between per-capita calories in dm +s15_maxiter Scalar defining maximum number of iterations (1) / 10 / +s15_convergence Convergence criterion (1) / 0.005 / +s15_convergence_partstep Share of last iteration for convergence (1=only current iteration 0.5=half last iteration) / 0.5 / +* maximum relative per-capita gdp difference within a region between two iteratios +s15_exo_waste Switch for transition towards exogenous food waste scenario (1) / 0 / +s15_waste_scen Scenario target for the ratio between food demand and intake (1) / 1.2 / +s15_exo_diet Switch for transition towards exogenous diet scenario (1) / 0 / +* The following switches only become active when s15_exo_diet is active +* They define which components of the diet should become active +* 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 +s15_exo_monogastric Exogenous EAT Lancet animal product target on (1) / 1 / +s15_exo_ruminant Exogenous EAT Lancet animal product target on (1) / 1 / +s15_exo_fish Exogenous EAT Lancet animal product target on (1) / 1 / +s15_exo_fruitvegnut Exogenous EAT Lancet fruit vegetable nut seeds target on (1) / 1 / +s15_exo_roots Exogenous EAT Lancet root target on (1) / 1 / +s15_exo_pulses Exogenous pulses target on (1) / 1 / +s15_exo_sugar Exogenous sugar target on (1) / 1 / +s15_exo_oils Exogenous oils (1) / 1 / +s15_exo_brans Exogenous brans (1) / 0 / +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. +s15_exo_alcohol Exogenous alcohol target on (1) / 1 / +s15_alc_scen Scenario target for the inclusion of alcohol in the EAT-Lancet diet (1) / 0 / +s15_rum_share_fadeout_india_strong Switch for stronger ruminant fadeout in India (binary) / 1 / +s15_milk_share_fadeout_india Switch for milk fadeout in India (binary) / 1 / +s15_kcal_pc_livestock_supply_target Target for livestock food calorie supply (kcal per cap per day) / 430 / +s15_livescen_target_subst Fade-out of livestock products (0) or substitution of livestock products with plant-based products (1) / 1 / +s15_food_subst_functional_form Switch for functional form of substitution fader (1) / 1 / +s15_food_substitution_start Food substitution start year / 2025 / +s15_food_substitution_target Food substitution target year / 2050 / +s15_ruminant_substitution Ruminant substitution share (1) / 0 / +s15_fish_substitution Fish substitution share (1) / 0 / +s15_alcohol_substitution Alcohol substitution share (1) / 0 / +s15_livestock_substitution Livestock substitution share (1) / 0 / +s15_rumdairy_substitution Ruminant meat and dairy substitution share (1) / 0 / +s15_rumdairy_scp_substitution Ruminant meat and dairy substitution with SCP share (1) / 0 / +s15_livescen_target Switch for livestock food calorie supply target (1) / 0 / +s15_exo_foodscen_functional_form Switch for functional form of exogenous food scenario fader (1) / 1 / +s15_exo_foodscen_start Food substitution start year / 2025 / +s15_exo_foodscen_target Food substitution target year / 2050 / +s15_exo_foodscen_convergence Convergence to exogenous food scenario (1) / 1 / +s15_scp_supplement_fat_meat Switch for supplemental fat needed as ingredient for scp-based meat alternatives (1) / 0 / +; + +table f15_household_balanceflow(t_all,i,kall,dm_ge_nr) Balance flow to take account of heterogeneous products and processes (mio. tDM) +$ondelim +$include "./modules/15_food/input/f15_household_balanceflow.cs3" +$offdelim; + +table fm_nutrition_attributes(t_all,kall,nutrition) Nutrition attributes of food items dedicated for fooduse (mio. kcal per tDM | t Protein per tDM) +$ondelim +$include "./modules/15_food/input/f15_nutrition_attributes.cs3" +$offdelim; + + +*** Food Demand Model + + +* Unit for `f15_demand_paras` is +* kcal/capita/day for saturation and intercept, and +* USD05/capita for halfsaturation + +table f15_demand_paras(regr15,food_scen15,par15) Food regression parameters in USD05PPP or dimensionless (X) +$ondelim +$include "./modules/15_food/input/f15_demand_regression_parameters.cs3" +$offdelim; + +table f15_bmi_shr_paras(sex, agegroup15, bmi_tree15, paras_b15) BMI share regression parameters in USD05PPP or dimensionless (X) +$ondelim +$include "./modules/15_food/input/f15_bmi_shr_regr_paras.cs3" +$offdelim; + +table f15_bmi(sex,age,bmi_group15) Mean body mass index for each BMI group (kg per m2) +$ondelim +$include "./modules/15_food/input/f15_bmi.cs3" +$offdelim; + +table f15_bmi_shr_past(t_all,iso,age,sex,bmi_group15) Observed share of population belonging to a BMI group in the past (1) +$ondelim +$include "./modules/15_food/input/f15_bmi_shr_past.cs3" +$offdelim; + + +table f15_kcal_pc_iso(t_all,iso,kfo) Observed per capita food supply in the past (kcal per cap per day) +$ondelim +$include "./modules/15_food/input/f15_kcal_pc_iso.csv" +$offdelim; + + +table f15_intake_pc_observed_iso(t_all,iso,sex,age) Observed per capita food intake in the past (kcal per captia per day) +$ondelim +$include "./modules/15_food/input/f15_intake_pc_observed_iso.cs3" +$offdelim; + + +parameter f15_prices_initial(kall) Food prices in initialization period (USD17MER per t DM) +/ +$ondelim +$include "./modules/15_food/input/f15_prices_initial.csv" +$offdelim +/; + + +parameter f15_price_index(t_all) Food price index in initialization period (1) +/ +$ondelim +$include "./modules/15_food/input/f15_prices_index.csv" +$offdelim +/; + + +table f15_markup_coef(kfo, fafh, margincoef) Coefficient for value-added on food products (X) +$ondelim +$include "./modules/15_food/input/f15_markup_coef.csv" +$offdelim +; + +parameter f15_fafh_coef(fafh_regr) Coefficient for regression of food-at-home (X) +/ +$ondelim +$include "./modules/15_food/input/f15_fafh_coef.csv" +$offdelim +/; + +table f15_kcal_calib_fadeout(t_all,calibscen15) Calibration fadeout factor (1) +$ondelim +$include "./modules/15_food/input/f15_kcal_balanceflow_fadeout.csv" +$offdelim +; + + +table f15_rum_share_fadeout(t_all,livst_fadeoutscen15) Ruminant share fadeout scenario (1) +$ondelim +$include "./modules/15_food/input/f15_ruminant_fadeout.csv" +$offdelim +; + +parameter f15_rum_share_fadeout_india(t_all) Ruminant share fadeout scenario for India (1) +/ +$ondelim +$include "./modules/15_food/input/f15_ruminant_fadeout_india.csv" +$offdelim +/; + +parameter f15_milk_share_fadeout_india(t_all) Milk share India fadeout scenario (1) +/ +$ondelim +$include "./modules/15_food/input/f15_milk_fadeout_india.csv" +$offdelim +/; + + +table f15_bodyheight(t_all,iso,sex,age) Body height (cm per cap) +$ondelim +$include "./modules/15_food/input/f15_bodyheight_historical.cs3" +$offdelim; + +table f15_bodyheight_regr_paras(sex,paras_h15) Body height regression parameters (X) +$ondelim +$include "./modules/15_food/input/f15_bodyheight_regr_paras.cs3" +$offdelim; + +table f15_schofield(sex,age, paras_s15) Schofield equation parameters in kcal per capita per day or kcal per capita per day per weight (X) +$ondelim +$include "./modules/15_food/input/f15_schofield_parameters.cs3" +$offdelim +; + +*** Exogenous food demand scenarios + +table f15_intake_EATLancet(t_scen15,iso,kcal_scen15,EAT_scen15,kfo) EAT Lancet scenarios for food specific intake (kcal per capita per day) +$ondelim +$include "./modules/15_food/input/f15_intake_EATLancet_iso.cs3" +$offdelim; + +table f15_overcons_FAOwaste(iso,kfo) Ratio between food calorie supply and food intake based on FAO food waste shares (1) +$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,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_iso.cs3" +$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 +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" +$offdelim; + +*** EOF input.gms *** diff --git a/modules/15_food/anthro_iso_jun22/intersolve.gms b/modules/15_food/anthro_iso_jun22/intersolve.gms new file mode 100644 index 0000000000..46a6aba846 --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/intersolve.gms @@ -0,0 +1,162 @@ +*** | (C) 2008-2025 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 + +* retrieving interfaces from MAgPIE +* calculate prices for providing 1 kcal per day of one commodity + + if (magpie.modelstat = NA, + display "Coupling: Reading exogenous prices as MAgPIE has not (yet) been run"; + q15_food_demand.m(i,kfo)=0; + p15_prices_kcal(t,iso,kfo,curr_iter15)=i15_prices_initial_kcal(iso,kfo)*f15_price_index(t); + else +*' @code +*' After one time step of MAgPIE is executed, the shadow prices of the food demand +*' constraint are fed back into the food demand module, and the food demand +*' module is executed once again. + display "Coupling: Reading out marginal costs from MAgPIE"; + p15_prices_kcal(t,iso,kfo,curr_iter15)=sum(i_to_iso(i,iso), q15_food_demand.m(i,kfo)); +*' the quantity of tax money from emission pricing for redistribution is calculated + p15_tax_recycling(t,iso) = sum(i_to_iso(i,iso), (vm_emission_costs.l(i) + / im_pop(t,i)) * s15_tax_recycling + * (im_gdp_pc_ppp_iso(t,iso) / im_gdp_pc_mer_iso(t,iso))); +*' @stop + ); + +*' If `s15_elastic_demand` is 0, MAgPIE is not executed again for this time step. +if (s15_elastic_demand = 1 AND m_year(t) > sm_fix_SSP2, + display "elastic demand model is activated"; + + option nlp = conopt4; + option threads = 1; + +* A new iteration is started + p15_iteration_counter(t) = p15_iteration_counter(t) + 1; +* The set current iter includes only one element with the set element +* of the current iteration, e.g. "iter2". As iter0 also exists, +* "iter2" is the third entry of the set iter15, so we add 1. + curr_iter15(iter15) = no; + curr_iter15(iter15)$(ord(iter15)=p15_iteration_counter(t)+1) = yes; +* Now we also define a set for the previous iteration + prev_iter15(iter15) = no; + prev_iter15(iter15)$(ord(iter15)=p15_iteration_counter(t)) = yes; + +*' @code + display "starting m15_food_demand in iteration number ", p15_iteration_counter; + + solve m15_food_demand USING nlp MAXIMIZING v15_objective; +*' @stop in + +* in case of problems try CONOPT3 + if(m15_food_demand.modelstat > 2, + display "Modelstat > 2 | Retry solve with CONOPT3"; + option nlp = conopt3; + solve m15_food_demand USING nlp MAXIMIZING v15_objective; + option nlp = conopt4; + ); + + p15_modelstat(t) = m15_food_demand.modelstat; + + display "Food Demand Model finished with modelstat "; + display p15_modelstat; + + if(p15_modelstat(t) > 2 AND p15_modelstat(t) ne 7, + m15_food_demand.solprint = 1 + Execute_Unload "fulldata.gdx"; + abort "Food Demand Model became infeasible. Should not be possible."; + ); + + +* estimate regional indicators from demand model + + + p15_income_pc_real_ppp(t,i)$( + sum(i_to_iso(i,iso), + im_pop_iso(t,iso) + ) >0 ) = + sum(i_to_iso(i,iso), + v15_income_pc_real_ppp_iso.l(iso) + * im_pop_iso(t,iso) + ) / sum(i_to_iso(i,iso), + im_pop_iso(t,iso) + ); + + + + p15_delta_income(t,i,curr_iter15) = p15_income_pc_real_ppp(t,i) / + ( sum(i_to_iso(i,iso), + im_gdp_pc_ppp_iso(t,iso) + * im_pop_iso(t,iso) + ) / sum(i_to_iso(i,iso), + im_pop_iso(t,iso)) + ); + + +* estimate convergence measure for deciding to stop iteration + + + p15_convergence_measure(t,curr_iter15) =smax(i, + abs(p15_delta_income(t,i,curr_iter15) / sum(prev_iter15,p15_delta_income(t,i,prev_iter15))- 1) + ); + + display "convergence measure:",p15_convergence_measure; + +*' @code + +*' It is checked whether MAgPIE and the +*' food demand model have reached sufficient convergence. The criterion for this +*' is whether the real income in the food demand model has changed in any region +*' by more than `s15_convergences_measure` relative to the last iteration due to +*' changes in food prices from MAgPIE. Moreover, the model aborts when the +*' number of iterations reaches `s15_maxiter`. +*' As long as the iteration continues, the food prices are transferred from +*' MAgPIE to the food demand model, and the food demand is transferred from +*' the food demand model to MAgPIE. +*' @stop + + + if ((sum(curr_iter15,p15_convergence_measure(t,curr_iter15)) > s15_convergence and p15_iteration_counter(t) <= s15_maxiter), + + display "convergence between MAgPIE and Food Demand Model not yet reached"; + display "starting magpie in iteration number ", p15_iteration_counter; + sm_intersolve=0; + s15_run_diet_postprocessing=1; + + elseif(p15_iteration_counter(t) > s15_maxiter), + sm_intersolve=1; + s15_run_diet_postprocessing=0; + display "Warning: convergence between MAgPIE and Food Demand Model not reached after ",p15_iteration_counter," iterations. Continue to next time step!"; + else + sm_intersolve=1; + s15_run_diet_postprocessing=0; + display "Success: convergence between MAgPIE and Food Demand Model reached."; + display "requiring ",p15_iteration_counter," runs of food demand model, "; + display "and one run less with MAgPIE."; +* set back convergence indicators for next timestep + ); + +* if the food demand model is not run again, also postprocessing is not +* executed again. +else + display "exogenous demand information is used" ; + s15_run_diet_postprocessing=0; +); + +* Postprocessing of diets: calibration, exogenous scenario modifications and +* aggregation to regional level. +* As this occurs twice (in presolve and intersolve), it is here included as +* macro. As include comments are not allowed within if statements, we pass the +* information whether postprocessing shall be executed to the macro within +* the parameter s15_run_diet_postprocessing. It is checked within the macro +* whether it shall be executed again. +$include "./modules/15_food/anthro_iso_jun22/exodietmacro.gms"; + +if (s15_run_diet_postprocessing = 1 , + if (p15_modelstat(t) <= 2, + put_utility 'shell' / 'mv -f m15_food_demand_p.gdx m15_food_demand_' t.tl:0'.gdx'; + ); +); +s15_run_diet_postprocessing=1; diff --git a/modules/15_food/anthro_iso_jun22/postsolve.gms b/modules/15_food/anthro_iso_jun22/postsolve.gms new file mode 100644 index 0000000000..c9399b536e --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/postsolve.gms @@ -0,0 +1,233 @@ +*** | (C) 2008-2025 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 + + +*' The following equations calculate the value of the marketing +*' (value-added used equivalently) price margin +*' along with consumer expenditures including the margins. +*' fah and fafh refer to food-(consumed)-at-home and food-away-from-home +*' Regression coefficients from "Chen et al. 2025 Future food prices +*' will become less sensitive to agricultural market prices and mitigation costs" + + +p15_shr_fafh(t,iso) = f15_fafh_coef("a_fafh") + f15_fafh_coef("b_fafh") * im_gdp_pc_mer_iso(t,iso); +p15_shr_fafh(t,iso)$(p15_shr_fafh(t,iso) > 1) = 1; +p15_shr_fafh(t,iso)$(p15_shr_fafh(t, iso) < 0) = 0; + +p15_marketing_margin_fah(t,iso,kfo) = (f15_markup_coef(kfo,"fah","a") * (f15_markup_coef(kfo, "fah", "b")**log(im_gdp_pc_mer_iso(t,iso))) + + f15_markup_coef(kfo, "fah", "c")) * fm_attributes("wm", kfo); +p15_marketing_margin_fah_kcal(t,iso,kfo) = p15_marketing_margin_fah(t,iso,kfo) / (fm_nutrition_attributes(t,kfo,"kcal")*10**6); + +p15_marketing_margin_fafh(t,iso,kfo) = (f15_markup_coef(kfo,"fafh","a") * (f15_markup_coef(kfo, "fafh", "b")**log(im_gdp_pc_mer_iso(t,iso))) + + f15_markup_coef(kfo, "fafh", "c")) * fm_attributes("wm", kfo); +p15_marketing_margin_fafh_kcal(t,iso,kfo) = p15_marketing_margin_fafh(t,iso,kfo) / (fm_nutrition_attributes(t,kfo,"kcal")*10**6); + +p15_value_added_expenditures_pc(t,iso,kfo) = p15_shr_fafh(t,iso) * p15_kcal_pc_iso(t,iso,kfo)*p15_marketing_margin_fafh_kcal(t,iso,kfo) + + (1-p15_shr_fafh(t,iso)) * p15_kcal_pc_iso(t,iso,kfo)*p15_marketing_margin_fah_kcal(t,iso,kfo); + + + +if(ord(t)>1, +* start from bodyheight structure of last period + p15_bodyheight(t,iso,sex,age,"final") = p15_bodyheight(t-1,iso,sex,age,"final"); + p15_kcal_growth_food(t,iso,underaged15) = p15_kcal_growth_food(t-1,iso,underaged15); +); + +s15_yeardiff = m_yeardiff(t)/5; +if(s15_yeardiff<1,s15_yeardiff=1); + +For (s15_count = 1 to s15_yeardiff, + +* circular move of age by 5 years +* to find out about ++1 search for help on Circular Lag and Lead Operators in Assignments + p15_bodyheight(t,iso,sex,age++1,"final") = p15_bodyheight(t,iso,sex,age,"final"); + +* move on consumption agegroups by 5 years + p15_kcal_growth_food(t,iso,underaged15++1)= + p15_kcal_growth_food(t,iso,underaged15); + +* consumption is calculated as linear interpolation between timesteps + p15_kcal_growth_food(t,iso,"0--4") = + sum(growth_food15, + p15_intake_detail(t,iso,growth_food15) + * p15_demand2intake_ratio_detail_preexo(t,iso,growth_food15) + * (s15_count / (m_yeardiff(t)/5)) + + p15_intake_detail(t-1,iso,growth_food15) + * p15_demand2intake_ratio_detail_preexo(t-1,iso,growth_food15) + * (1 - s15_count / (m_yeardiff(t)/5)) + ); + +*' @code +*' After each execution of the food demand model, the body height distribution +*' of the population is estimated. The starting point is the body height +*' distribution of the last timestep. The body height estimates of the old +*' period are moved into the subsequent age class (e.g. the 20-24 year old are +*' now 25-29 years old). The age class of 15-19 year old is estimated newly +*' using the body height regressions and the food consumption of the last 15 +*' years. + + p15_bodyheight(t,iso,sex,"15--19","final") = + f15_bodyheight_regr_paras(sex,"slope")* + (sum(underaged15, + p15_kcal_growth_food(t,iso,underaged15) + )/3)**f15_bodyheight_regr_paras(sex,"exponent") + ; + +*' @stop +); + +*' @code +*' The bodyheight of the underaged age class (0-14) is assumed to diverge from 'normal' +*' body height by the same proportion as the age class of the 15-19 year old. + +p15_bodyheight(t,iso,"M","0--4","final")=p15_bodyheight(t,iso,"M","15--19","final")/176*92; +p15_bodyheight(t,iso,"M","5--9","final")=p15_bodyheight(t,iso,"M","15--19","final")/176*125; +p15_bodyheight(t,iso,"M","10--14","final")=p15_bodyheight(t,iso,"M","15--19","final")/176*152; + +p15_bodyheight(t,iso,"F","0--4","final")=p15_bodyheight(t,iso,"M","15--19","final")/163*91; +p15_bodyheight(t,iso,"F","5--9","final")=p15_bodyheight(t,iso,"M","15--19","final")/163*124; +p15_bodyheight(t,iso,"F","10--14","final")=p15_bodyheight(t,iso,"M","15--19","final")/163*154; + +*' @stop + +*' @code +*' Finally, the regression outcome is calibrated by a country-specific additive +*' term, which is the residual of the regression fit and observation of the last +*' historical time step. + +if (sum(sameas(t_past,t),1) = 1, +* For historical period, the regression results are only used to estimate the calibration parameter. + p15_bodyheight_calib(t,iso,sex,age_new_estimated15) = f15_bodyheight(t,iso,sex,age_new_estimated15) - p15_bodyheight(t,iso,sex,age_new_estimated15,"final"); + p15_bodyheight(t,iso,sex,age_new_estimated15,"final") = f15_bodyheight(t,iso,sex,age_new_estimated15); +else + p15_bodyheight_calib(t,iso,sex,age_new_estimated15)=p15_bodyheight_calib(t-1,iso,sex,age_new_estimated15); + p15_bodyheight(t,iso,sex,age_new_estimated15,"final")=p15_bodyheight(t,iso,sex,age_new_estimated15,"final")+p15_bodyheight_calib(t,iso,sex,age_new_estimated15)*s15_calibrate; +); + +*' @stop + + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_dem_food(t,i,kall,"marginal") = vm_dem_food.m(i,kall); + ov15_kcal_regr(t,iso,kfo,"marginal") = v15_kcal_regr.m(iso,kfo); + ov15_kcal_regr_total(t,iso,"marginal") = v15_kcal_regr_total.m(iso); + ov15_demand_regr(t,iso,regr15,"marginal") = v15_demand_regr.m(iso,regr15); + ov15_income_pc_real_ppp_iso(t,iso,"marginal") = v15_income_pc_real_ppp_iso.m(iso); + ov15_income_balance(t,iso,"marginal") = v15_income_balance.m(iso); + ov15_kcal_intake_total_regr(t,iso,"marginal") = v15_kcal_intake_total_regr.m(iso); + ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"marginal") = v15_regr_overgroups.m(iso,sex,agegroup15,bmi_tree15); + ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"marginal") = v15_bmi_shr_regr.m(iso,sex,age,bmi_group15); + ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"marginal") = v15_bmi_shr_overgroups.m(iso,sex,agegroup15,bmi_group15); + ov15_objective(t,"marginal") = v15_objective.m; + oq15_food_demand(t,i,kfo,"marginal") = q15_food_demand.m(i,kfo); + oq15_aim(t,"marginal") = q15_aim.m; + oq15_budget(t,iso,"marginal") = q15_budget.m(iso); + oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"marginal") = q15_regr_bmi_shr.m(iso,sex,agegroup15,bmi_tree15); + oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_verylow.m(iso,sex,agegroup15); + oq15_bmi_shr_low(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_low.m(iso,sex,agegroup15); + oq15_bmi_shr_medium(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_medium.m(iso,sex,agegroup15); + oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_medium_high.m(iso,sex,agegroup15); + oq15_bmi_shr_high(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_high.m(iso,sex,agegroup15); + oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_veryhigh.m(iso,sex,agegroup15); + oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"marginal") = q15_bmi_shr_agg.m(iso,sex,age,bmi_group15); + oq15_intake(t,iso,"marginal") = q15_intake.m(iso); + oq15_regr_kcal(t,iso,"marginal") = q15_regr_kcal.m(iso); + oq15_regr(t,iso,regr15,"marginal") = q15_regr.m(iso,regr15); + oq15_foodtree_kcal_animals(t,iso,kfo_ap,"marginal") = q15_foodtree_kcal_animals.m(iso,kfo_ap); + oq15_foodtree_kcal_processed(t,iso,kfo_pf,"marginal") = q15_foodtree_kcal_processed.m(iso,kfo_pf); + oq15_foodtree_kcal_staples(t,iso,kfo_st,"marginal") = q15_foodtree_kcal_staples.m(iso,kfo_st); + oq15_foodtree_kcal_vegetables(t,iso,"marginal") = q15_foodtree_kcal_vegetables.m(iso); + ov_dem_food(t,i,kall,"level") = vm_dem_food.l(i,kall); + ov15_kcal_regr(t,iso,kfo,"level") = v15_kcal_regr.l(iso,kfo); + ov15_kcal_regr_total(t,iso,"level") = v15_kcal_regr_total.l(iso); + ov15_demand_regr(t,iso,regr15,"level") = v15_demand_regr.l(iso,regr15); + ov15_income_pc_real_ppp_iso(t,iso,"level") = v15_income_pc_real_ppp_iso.l(iso); + ov15_income_balance(t,iso,"level") = v15_income_balance.l(iso); + ov15_kcal_intake_total_regr(t,iso,"level") = v15_kcal_intake_total_regr.l(iso); + ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"level") = v15_regr_overgroups.l(iso,sex,agegroup15,bmi_tree15); + ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"level") = v15_bmi_shr_regr.l(iso,sex,age,bmi_group15); + ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"level") = v15_bmi_shr_overgroups.l(iso,sex,agegroup15,bmi_group15); + ov15_objective(t,"level") = v15_objective.l; + oq15_food_demand(t,i,kfo,"level") = q15_food_demand.l(i,kfo); + oq15_aim(t,"level") = q15_aim.l; + oq15_budget(t,iso,"level") = q15_budget.l(iso); + oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"level") = q15_regr_bmi_shr.l(iso,sex,agegroup15,bmi_tree15); + oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"level") = q15_bmi_shr_verylow.l(iso,sex,agegroup15); + oq15_bmi_shr_low(t,iso,sex,agegroup15,"level") = q15_bmi_shr_low.l(iso,sex,agegroup15); + oq15_bmi_shr_medium(t,iso,sex,agegroup15,"level") = q15_bmi_shr_medium.l(iso,sex,agegroup15); + oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"level") = q15_bmi_shr_medium_high.l(iso,sex,agegroup15); + oq15_bmi_shr_high(t,iso,sex,agegroup15,"level") = q15_bmi_shr_high.l(iso,sex,agegroup15); + oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"level") = q15_bmi_shr_veryhigh.l(iso,sex,agegroup15); + oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"level") = q15_bmi_shr_agg.l(iso,sex,age,bmi_group15); + oq15_intake(t,iso,"level") = q15_intake.l(iso); + oq15_regr_kcal(t,iso,"level") = q15_regr_kcal.l(iso); + oq15_regr(t,iso,regr15,"level") = q15_regr.l(iso,regr15); + oq15_foodtree_kcal_animals(t,iso,kfo_ap,"level") = q15_foodtree_kcal_animals.l(iso,kfo_ap); + oq15_foodtree_kcal_processed(t,iso,kfo_pf,"level") = q15_foodtree_kcal_processed.l(iso,kfo_pf); + oq15_foodtree_kcal_staples(t,iso,kfo_st,"level") = q15_foodtree_kcal_staples.l(iso,kfo_st); + oq15_foodtree_kcal_vegetables(t,iso,"level") = q15_foodtree_kcal_vegetables.l(iso); + ov_dem_food(t,i,kall,"upper") = vm_dem_food.up(i,kall); + ov15_kcal_regr(t,iso,kfo,"upper") = v15_kcal_regr.up(iso,kfo); + ov15_kcal_regr_total(t,iso,"upper") = v15_kcal_regr_total.up(iso); + ov15_demand_regr(t,iso,regr15,"upper") = v15_demand_regr.up(iso,regr15); + ov15_income_pc_real_ppp_iso(t,iso,"upper") = v15_income_pc_real_ppp_iso.up(iso); + ov15_income_balance(t,iso,"upper") = v15_income_balance.up(iso); + ov15_kcal_intake_total_regr(t,iso,"upper") = v15_kcal_intake_total_regr.up(iso); + ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"upper") = v15_regr_overgroups.up(iso,sex,agegroup15,bmi_tree15); + ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"upper") = v15_bmi_shr_regr.up(iso,sex,age,bmi_group15); + ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"upper") = v15_bmi_shr_overgroups.up(iso,sex,agegroup15,bmi_group15); + ov15_objective(t,"upper") = v15_objective.up; + oq15_food_demand(t,i,kfo,"upper") = q15_food_demand.up(i,kfo); + oq15_aim(t,"upper") = q15_aim.up; + oq15_budget(t,iso,"upper") = q15_budget.up(iso); + oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"upper") = q15_regr_bmi_shr.up(iso,sex,agegroup15,bmi_tree15); + oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_verylow.up(iso,sex,agegroup15); + oq15_bmi_shr_low(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_low.up(iso,sex,agegroup15); + oq15_bmi_shr_medium(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_medium.up(iso,sex,agegroup15); + oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_medium_high.up(iso,sex,agegroup15); + oq15_bmi_shr_high(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_high.up(iso,sex,agegroup15); + oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_veryhigh.up(iso,sex,agegroup15); + oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"upper") = q15_bmi_shr_agg.up(iso,sex,age,bmi_group15); + oq15_intake(t,iso,"upper") = q15_intake.up(iso); + oq15_regr_kcal(t,iso,"upper") = q15_regr_kcal.up(iso); + oq15_regr(t,iso,regr15,"upper") = q15_regr.up(iso,regr15); + oq15_foodtree_kcal_animals(t,iso,kfo_ap,"upper") = q15_foodtree_kcal_animals.up(iso,kfo_ap); + oq15_foodtree_kcal_processed(t,iso,kfo_pf,"upper") = q15_foodtree_kcal_processed.up(iso,kfo_pf); + oq15_foodtree_kcal_staples(t,iso,kfo_st,"upper") = q15_foodtree_kcal_staples.up(iso,kfo_st); + oq15_foodtree_kcal_vegetables(t,iso,"upper") = q15_foodtree_kcal_vegetables.up(iso); + ov_dem_food(t,i,kall,"lower") = vm_dem_food.lo(i,kall); + ov15_kcal_regr(t,iso,kfo,"lower") = v15_kcal_regr.lo(iso,kfo); + ov15_kcal_regr_total(t,iso,"lower") = v15_kcal_regr_total.lo(iso); + ov15_demand_regr(t,iso,regr15,"lower") = v15_demand_regr.lo(iso,regr15); + ov15_income_pc_real_ppp_iso(t,iso,"lower") = v15_income_pc_real_ppp_iso.lo(iso); + ov15_income_balance(t,iso,"lower") = v15_income_balance.lo(iso); + ov15_kcal_intake_total_regr(t,iso,"lower") = v15_kcal_intake_total_regr.lo(iso); + ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"lower") = v15_regr_overgroups.lo(iso,sex,agegroup15,bmi_tree15); + ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"lower") = v15_bmi_shr_regr.lo(iso,sex,age,bmi_group15); + ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"lower") = v15_bmi_shr_overgroups.lo(iso,sex,agegroup15,bmi_group15); + ov15_objective(t,"lower") = v15_objective.lo; + oq15_food_demand(t,i,kfo,"lower") = q15_food_demand.lo(i,kfo); + oq15_aim(t,"lower") = q15_aim.lo; + oq15_budget(t,iso,"lower") = q15_budget.lo(iso); + oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"lower") = q15_regr_bmi_shr.lo(iso,sex,agegroup15,bmi_tree15); + oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_verylow.lo(iso,sex,agegroup15); + oq15_bmi_shr_low(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_low.lo(iso,sex,agegroup15); + oq15_bmi_shr_medium(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_medium.lo(iso,sex,agegroup15); + oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_medium_high.lo(iso,sex,agegroup15); + oq15_bmi_shr_high(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_high.lo(iso,sex,agegroup15); + oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_veryhigh.lo(iso,sex,agegroup15); + oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"lower") = q15_bmi_shr_agg.lo(iso,sex,age,bmi_group15); + oq15_intake(t,iso,"lower") = q15_intake.lo(iso); + oq15_regr_kcal(t,iso,"lower") = q15_regr_kcal.lo(iso); + oq15_regr(t,iso,regr15,"lower") = q15_regr.lo(iso,regr15); + oq15_foodtree_kcal_animals(t,iso,kfo_ap,"lower") = q15_foodtree_kcal_animals.lo(iso,kfo_ap); + oq15_foodtree_kcal_processed(t,iso,kfo_pf,"lower") = q15_foodtree_kcal_processed.lo(iso,kfo_pf); + oq15_foodtree_kcal_staples(t,iso,kfo_st,"lower") = q15_foodtree_kcal_staples.lo(iso,kfo_st); + oq15_foodtree_kcal_vegetables(t,iso,"lower") = q15_foodtree_kcal_vegetables.lo(iso); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/15_food/anthro_iso_jun22/preloop.gms b/modules/15_food/anthro_iso_jun22/preloop.gms new file mode 100644 index 0000000000..bd9aef987f --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/preloop.gms @@ -0,0 +1,147 @@ +*** | (C) 2008-2025 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 + + i15_bmi_intercept(sex,agegroup15,bmi_tree15) = f15_bmi_shr_paras(sex,agegroup15,bmi_tree15,"intercept"); + 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); + +* calculating growth food for historical period + +loop(t_past, + if (ord(t_past)>3, + p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-3,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-2,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); + Elseif ord(t_past)=3, + p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-2,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-2,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); + Elseif ord(t_past)=2, + p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); + Elseif ord(t_past)=1, + p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-0,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-0,iso,growth_food15)); + p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-0,iso,growth_food15)); + ); +); + + +* Temporal development of ruminant meat share within the livestock food product +* group (applied before food demand model is executed) +$ifthen "%c15_rum_share%" == "mixed" i15_rum_share_fadeout(t,iso) = (f15_rum_share_fadeout(t,"constant") + f15_rum_share_fadeout(t,"halving2050"))/2; +$else i15_rum_share_fadeout(t,iso) = f15_rum_share_fadeout(t,"%c15_rum_share%"); +$endif + +* Stronger ruminant fadeout for India +if (s15_rum_share_fadeout_india_strong = 1, + i15_rum_share_fadeout(t,"IND") = f15_rum_share_fadeout_india(t); +); + +* Milk fadeout for India +if (s15_milk_share_fadeout_india = 0, + i15_milk_share_fadeout_india(t) = 1; +Elseif s15_milk_share_fadeout_india = 1, + i15_milk_share_fadeout_india(t) = f15_milk_share_fadeout_india(t); +); + + +* ###### Precalculation of exogenous food waste and diet faders as well as food substitution faders. +* The actual fading happens in exodietmacro.gms + +* 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_switch(iso) = 0; +p15_country_switch(scen_countries15) = 1; + +** The following lines define scenario faders for substituting different food groups +* If s15_exo_foodscen_functional_form = 1, the exogenous food scenario is faded in linearly. +* If s15_exo_foodscen_functional_form = 2, the exogenous food scenario is faded in applying a sigmoid trajectory. +if (s15_food_subst_functional_form = 1, + + m_linear_time_interpol(p15_ruminant_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_ruminant_substitution); + m_linear_time_interpol(p15_fish_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_fish_substitution); + m_linear_time_interpol(p15_alcohol_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_alcohol_substitution); + m_linear_time_interpol(p15_livestock_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_livestock_substitution); + m_linear_time_interpol(p15_rumdairy_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_rumdairy_substitution); + m_linear_time_interpol(p15_rumdairy_scp_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0, s15_rumdairy_scp_substitution); + if(s15_livescen_target = 1, + m_linear_time_interpol(p15_livestock_threshold_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,1); + else + p15_livestock_threshold_subst_fader(t) = 0; + ); + +elseif s15_food_subst_functional_form = 2, + + m_sigmoid_time_interpol(p15_ruminant_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_ruminant_substitution); + m_sigmoid_time_interpol(p15_fish_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_fish_substitution); + m_sigmoid_time_interpol(p15_alcohol_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_alcohol_substitution); + m_sigmoid_time_interpol(p15_livestock_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_livestock_substitution); + m_sigmoid_time_interpol(p15_rumdairy_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,s15_rumdairy_substitution); + m_sigmoid_time_interpol(p15_rumdairy_scp_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0, s15_rumdairy_scp_substitution); + if(s15_livescen_target = 1, + m_sigmoid_time_interpol(p15_livestock_threshold_subst_fader,s15_food_substitution_start,s15_food_substitution_target,0,1); + else + p15_livestock_threshold_subst_fader(t) = 0; + ); + +); + + +* Food substitution scenarios including functional forms, targets and transition periods +i15_ruminant_fadeout(t,iso) = 1 - p15_country_switch(iso)*p15_ruminant_subst_fader(t); +i15_fish_fadeout(t,iso) = 1 - p15_country_switch(iso)*p15_fish_subst_fader(t); +i15_alcohol_fadeout(t,iso) = 1 - p15_country_switch(iso)*p15_alcohol_subst_fader(t); +i15_livestock_fadeout(t,iso) = 1 - p15_country_switch(iso)*p15_livestock_subst_fader(t); +i15_rumdairy_fadeout(t,iso) = 1 - p15_country_switch(iso)*p15_rumdairy_subst_fader(t); +i15_rumdairy_scp_fadeout(t,iso) = 1 - p15_country_switch(iso)*p15_rumdairy_scp_subst_fader(t); +i15_livestock_fadeout_threshold(t,iso) = 1 - p15_country_switch(iso)*p15_livestock_threshold_subst_fader(t); + + +** The following lines define the scenario fader for the exogeneous food scenario +* If s15_exo_foodscen_functional_form = 1, the exogenous food scenario is faded in linearly. +* If s15_exo_foodscen_functional_form = 2, the exogenous food scenario is faded in applying a sigmoid trajectory. +if (s15_exo_foodscen_functional_form = 1, + m_linear_time_interpol(p15_exo_food_scenario_fader,s15_exo_foodscen_start,s15_exo_foodscen_target,0,s15_exo_foodscen_convergence); + +elseif s15_exo_foodscen_functional_form = 2, + m_sigmoid_time_interpol(p15_exo_food_scenario_fader,s15_exo_foodscen_start,s15_exo_foodscen_target,0,s15_exo_foodscen_convergence); + +); + +* Fade in scenarios at country level +i15_exo_foodscen_fader(t,iso) = p15_exo_food_scenario_fader(t) * p15_country_switch(iso); + +* Select from the data set of EAT Lancet scenarios the target years that are +* consistent with the target year of the fader: + +if(s15_exo_foodscen_target = 2030, + 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); + ); +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); + ); +); + +* 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_tax_recycling(t,iso) = 0; +p15_convergence_measure(t,iter15) = NA; + + i15_dem_intercept(iso,regr15) = f15_demand_paras(regr15,"SSP2","intercept"); + i15_dem_saturation(iso,regr15) = f15_demand_paras(regr15,"SSP2","saturation"); diff --git a/modules/15_food/anthro_iso_jun22/presolve.gms b/modules/15_food/anthro_iso_jun22/presolve.gms new file mode 100644 index 0000000000..7b5794fb6e --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/presolve.gms @@ -0,0 +1,339 @@ +*** | (C) 2008-2025 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 + + + +if(m_year(t) <= sm_fix_SSP2, + i15_dem_intercept(iso,regr15) = f15_demand_paras(regr15,"SSP2","intercept"); + i15_dem_saturation(iso,regr15) = f15_demand_paras(regr15,"SSP2","saturation"); + i15_dem_halfsat(iso,regr15) = f15_demand_paras(regr15,"SSP2","halfsaturation"); + i15_dem_nonsat(iso,regr15) = f15_demand_paras(regr15,"SSP2","non_saturation"); +else + i15_dem_intercept(iso,regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","intercept")*p15_country_switch(iso) + + f15_demand_paras(regr15,"%c15_food_scenario_noselect%","intercept")*(1-p15_country_switch(iso)); + i15_dem_saturation(iso,regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","saturation")*p15_country_switch(iso) + + f15_demand_paras(regr15,"%c15_food_scenario_noselect%","saturation")*(1-p15_country_switch(iso)); + i15_dem_halfsat(iso,regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","halfsaturation")*p15_country_switch(iso) + + f15_demand_paras(regr15,"%c15_food_scenario_noselect%","halfsaturation")*(1-p15_country_switch(iso)); + i15_dem_nonsat(iso,regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","non_saturation")*p15_country_switch(iso) + + f15_demand_paras(regr15,"%c15_food_scenario_noselect%","non_saturation")*(1-p15_country_switch(iso)); +); + +option nlp = conopt4; +option threads = 1; + +*' @code +*' Within the major food groups determined by the regressions +*' (animal calories, empty calories, fruits, vegetable and nut calories as well as staple calories), +*' the relative share of individual products (e.g. eggs within animal calories) +*' is assumed to be constant. An exception is the demand for ruminant meat, +*' which declines in the course of the century at the cost of chicken meat. +*' @stop + +if (sum(sameas(t_past,t),1) = 1, + +*** Calculate the share of individual food products within major food groups, and replace zero shares with regional averages +* First set it to equal shares, just in case there is no population + + + i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) = + sum(iso2, f15_kcal_pc_iso(t,iso2,kfo_ap)*im_pop_iso(t,iso2))/ + ( + sum((kfo_ap2,iso2),(f15_kcal_pc_iso(t,iso2,kfo_ap2)*im_pop_iso(t,iso2))) + +10**(-5) + ); + + i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap)$sum(kfo_ap2,f15_kcal_pc_iso(t,iso,kfo_ap2)>0)= + f15_kcal_pc_iso(t,iso,kfo_ap) / + sum(kfo_ap2,f15_kcal_pc_iso(t,iso,kfo_ap2) +* 10**(-5) required to avoid unlogical division by zero error. + ); + + i15_livestock_kcal_structure_iso(t,iso,kfo_ap) = i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap); + + i15_processed_kcal_structure_iso(t,iso,kfo_pf) = + sum(iso2, f15_kcal_pc_iso(t,iso2,kfo_pf)*im_pop_iso(t,iso2)) / + ( + sum((kfo_pf2,iso2),f15_kcal_pc_iso(t,iso2,kfo_pf2)*im_pop_iso(t,iso2)) + +10**(-5) +* 10**(-5) required to avoid unlogical division by zero error. Ask Jan P + ); + + i15_processed_kcal_structure_iso(t,iso,kfo_pf)$(sum(kfo_pf2,f15_kcal_pc_iso(t,iso,kfo_pf2))>0) = + f15_kcal_pc_iso(t,iso,kfo_pf) + /sum(kfo_pf2,f15_kcal_pc_iso(t,iso,kfo_pf2) + ); + + i15_staples_kcal_structure_iso(t,iso,kfo_st) = + sum(iso2, f15_kcal_pc_iso(t,iso2,kfo_st)*im_pop_iso(t,iso2)) / + ( + sum((kfo_st2,iso2),f15_kcal_pc_iso(t,iso2,kfo_st2)*im_pop_iso(t,iso2)) + +10**(-5) +* 10**(-5) required to avoid unlogical division by zero error. Ask Jan P + ); + + i15_staples_kcal_structure_iso(t,iso,kfo_st)$(sum(kfo_st2,f15_kcal_pc_iso(t,iso,kfo_st2))>0) = + f15_kcal_pc_iso(t,iso,kfo_st) + /sum(kfo_st2,f15_kcal_pc_iso(t,iso,kfo_st2) + ); + + + else +* Assumptions on future calorie structure within food groups for future projections: + i15_staples_kcal_structure_iso(t,iso,kfo_st) =i15_staples_kcal_structure_iso(t-1,iso,kfo_st); + i15_processed_kcal_structure_iso(t,iso,kfo_pf) =i15_processed_kcal_structure_iso(t-1,iso,kfo_pf); + i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) = i15_livestock_kcal_structure_iso_raw(t-1,iso,kfo_ap); + i15_livestock_kcal_structure_iso(t,iso,kfo_ap) = i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap); + i15_livestock_kcal_structure_iso(t,iso,"livst_chick") = + i15_livestock_kcal_structure_iso_raw(t,iso,"livst_chick") + + i15_livestock_kcal_structure_iso_raw(t,iso,"livst_rum") * (1-i15_rum_share_fadeout(t,iso)); + i15_livestock_kcal_structure_iso(t,iso,"livst_rum") = + i15_livestock_kcal_structure_iso_raw(t,iso,"livst_rum") * i15_rum_share_fadeout(t,iso); + +* Substitute milk demand in India with chicken, egg and fish (equally distributed) because milk demand in India shows an implausible increase + i15_livestock_kcal_structure_iso(t,"IND","livst_milk") = + i15_livestock_kcal_structure_iso_raw(t,"IND","livst_milk") * i15_milk_share_fadeout_india(t); + i15_livestock_kcal_structure_iso(t,"IND","livst_chick") = + i15_livestock_kcal_structure_iso(t,"IND","livst_chick") + + i15_livestock_kcal_structure_iso_raw(t,"IND","livst_milk") * (1-i15_milk_share_fadeout_india(t)) * 1/3; + i15_livestock_kcal_structure_iso(t,"IND","livst_egg") = + i15_livestock_kcal_structure_iso(t,"IND","livst_egg") + + i15_livestock_kcal_structure_iso_raw(t,"IND","livst_milk") * (1-i15_milk_share_fadeout_india(t)) * 1/3; + i15_livestock_kcal_structure_iso(t,"IND","fish") = + i15_livestock_kcal_structure_iso(t,"IND","fish") + + i15_livestock_kcal_structure_iso_raw(t,"IND","livst_milk") * (1-i15_milk_share_fadeout_india(t)) * 1/3; + ); + + +*' @code +*' The calculations are executed in the following order: +*' +*' In the beginning of each time step, the body height is estimated based on the diets +*' of the previous 15 years. In case that the time step length exceeds 5 years, +*' the consumption is extrapolated using the last two time steps. +*' Body height is estimated using the consumption of proteins and fats, in our case +*' the foodgroups animal products, pulses and oils. +*' To estimate the body size of underaged (0-14 years), we scale the WHO body height +*' recommendations for underaged with the divergence of the 15-19 year old. +*' The body height estimates are repeated again at the end of the time step to improve +*' the results of the extrapolation for cases where the time step length exceeds 5 years. +*' @stop + +* ###### ANTHROPOMETRIC ESTIMATES +* ### Preliminary calculation of body height and weight based on food availability of last 3 timesteps. +* ### This may diverge from final calculation in the case where timestep length exceeds 5 years +* ### as then the demand depends on the result of MAgPIE. +* ### Calculations are therefore repeated after optimization. + +* Calculations are only made after historical period. Before, we use historical values. + +if (sum(sameas(t_past,t),1) = 1, + + p15_bodyheight(t,iso,sex,age,estimates15) = f15_bodyheight(t,iso,sex,age); + + +else + + p15_bodyheight(t,iso,sex,age,"preliminary") = p15_bodyheight(t-1,iso,sex,age,"final"); + p15_kcal_growth_food(t,iso,underaged15) = p15_kcal_growth_food(t-1,iso,underaged15); + + + + + s15_yeardiff = m_yeardiff(t)/5; +* avoid fake 1yr timestep in 1995 + if(s15_yeardiff<1,s15_yeardiff=1); + + For (s15_count = 1 to s15_yeardiff, + + +* circular move of age by 5 years +* to find out about ++1 search for help on Circular Lag and Lead Operators in Assignments + p15_bodyheight(t,iso,sex,age++1,"preliminary") = p15_bodyheight(t,iso,sex,age,"preliminary"); + +* replace age groups of 18 year old + p15_bodyheight(t,iso,sex,"15--19","preliminary") = + f15_bodyheight_regr_paras(sex,"slope")* + (sum(underaged15, + p15_kcal_growth_food(t,iso,underaged15) + )/3)**f15_bodyheight_regr_paras(sex,"exponent") + ; + + ); +*adjust body height of kids proportional to over18 population + p15_bodyheight(t,iso,"M","0--4","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/176*92; + p15_bodyheight(t,iso,"M","5--9","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/176*125; + p15_bodyheight(t,iso,"M","10--14","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/176*152; + + p15_bodyheight(t,iso,"F","0--4","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/163*91; + p15_bodyheight(t,iso,"F","5--9","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/163*124; + p15_bodyheight(t,iso,"F","10--14","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/163*154; + +); + + +*' @code + + + +*### Estimate standardized food requirements +p15_bodyweight(t,iso,sex,age,bmi_group15)= f15_bmi(sex,age,bmi_group15) * (p15_bodyheight(t,iso,sex,age,"preliminary")/100)**2; + +*' Physical activity levels (PAL) relative to the basic metabolic rate (BMR) are +*' estimated based on physical inactivity levels, assuming PALs for sedentary +*' and medium-active populations of 1.53 and 1.76 respectively: +p15_physical_activity_level(t,iso,sex,age)= + im_physical_inactivity(t,iso,sex,age) * 1.53 + +(1-im_physical_inactivity(t,iso,sex,age)) * 1.76 + ; + +p15_intake(t,iso,sex,age,bmi_group15)= + (f15_schofield(sex,age, "intercept") + + f15_schofield(sex,age, "slope")*p15_bodyweight(t,iso,sex,age,bmi_group15)) + * p15_physical_activity_level(t,iso,sex,age); + + +*' Pregnancy and lactation require additional food intake. To account for this, +*' newborns are distributed among reproductive women in a population. This number +*' is then multiplied with the extra energy requirements: +i15_kcal_pregnancy(t,iso)=sum(sex,im_demography(t,iso,sex,"0--4")/5) * ((40/66)*845 + (26/66)*675); + +*' @stop + + + +*###### Estimation of food demand using a first run of the food demand model with unshocked prices. + +*' @code +*' Before MAgPIE is executed, the food demand model is executed, at first +*' without price shocks. +*' @stop + +* demand for non-food products "knf" is set to 0; +vm_dem_food.fx(i,knf)=0; + +*** Food demand model is calculated the first time for the current time step, using standard prices + +* Food prices are intitialized +p15_prices_kcal(t,iso,kfo,"iter0") = i15_prices_initial_kcal(iso,kfo); + +* activating the first iteration +p15_iteration_counter(t) = 1; + +* The set curr_iter15 includes only one element with the set element +* of the current iteration, here "iter1". As iter0 also exists, +* its the second entry of the set. +curr_iter15(iter15) = no; +curr_iter15(iter15)$(ord(iter15)=p15_iteration_counter(t)+1) = yes; +* Now we also define a set for the previous iteration + prev_iter15(iter15) = no; + prev_iter15(iter15)$(ord(iter15)=p15_iteration_counter(t)) = yes; + +p15_delta_income(t,i,curr_iter15) = 1; + +display "starting demand model for initialisation run...."; + + +* helping the solver by starting from reasonable values +* by setting real income per capita on exogenous gdp per capita +v15_income_pc_real_ppp_iso.lo(iso)=10; +v15_income_pc_real_ppp_iso.fx(iso)=im_gdp_pc_ppp_iso(t,iso); + +solve m15_food_demand USING nlp MAXIMIZING v15_objective; + +* in case of problems try CONOPT3 +if(m15_food_demand.modelstat > 2, + display "Modelstat > 2 | Retry solve with CONOPT3"; + option nlp = conopt3; + solve m15_food_demand USING nlp MAXIMIZING v15_objective; + option nlp = conopt4; +); + +p15_modelstat(t) = m15_food_demand.modelstat; + +display "Food Demand Model Initialisation run finished with modelstat "; +display p15_modelstat; + +if(p15_modelstat(t) > 2 AND p15_modelstat(t) ne 7, + m15_food_demand.solprint = 1 + Execute_Unload "fulldata.gdx"; + abort "Food Demand Model became infeasible already during initialisation run. Stop run."; +); + +* releasing real income per capita binding for later runs that include shocks +v15_income_pc_real_ppp_iso.lo(iso)=10; +v15_income_pc_real_ppp_iso.up(iso)=Inf; + +* deriving calibration values + +*' @code +*' Per capita food demand and BMI shares are calibrated so that historical data +*' are met. For this purpose, the residual between the regression fit and the +*' observation is calculated for the historical period. When the historical period +*' ends, the calibration factor is fixed at the value of the last historical time +*' step. Additionally, a second calibration is required to meet the world totals +*' of FAOSTAT food demand for different foods. While the food demand model estimates +*' the demand for all countries of the world, FAOSTAT only covers a subset of +*' countries. To match FAOSTAT totals, the food demand of countries not included +*' in FAOSTAT is calibrated to zero. As this calibration is done ex-post, food +*' demand estimates can still be used for all countries, but MAgPIE only considers +*' demand from FAOSTAT countries. + +if (sum(sameas(t_past,t),1) = 1, + p15_kcal_calib(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))=0) = 0; + p15_balanceflow_kcal_iso(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))>0) = 0; + p15_kcal_calib(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))>0) = f15_kcal_pc_iso(t,iso,kfo) - v15_kcal_regr.l(iso, kfo); + p15_balanceflow_kcal_iso(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))=0) = f15_kcal_pc_iso(t,iso,kfo) - v15_kcal_regr.l(iso, kfo); + + p15_kcal_calib_lastcalibyear(iso,kfo) = p15_kcal_calib(t,iso,kfo); + p15_balanceflow_kcal_lastcalibyear(iso,kfo) = p15_balanceflow_kcal_iso(t,iso,kfo); + + i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) = + f15_bmi_shr_past(t,iso,age,sex,bmi_group15) - + v15_bmi_shr_regr.l(iso,sex,age,bmi_group15); + i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15)= + i15_bmi_shr_calib(t,iso,sex,age,bmi_group15); + +else +*' Depending on the scenario switch c15_calibscen, the divergence of the demand from the +*' historical data is kept constant or faded out. + p15_kcal_calib(t,iso,kfo) = p15_kcal_calib_lastcalibyear(iso,kfo) * f15_kcal_calib_fadeout(t,"%c15_calibscen%"); +*' The divergence of the kcal of countries with no FAOSTAT data is kept constant +*' over time. + p15_balanceflow_kcal_iso(t,iso,kfo) = p15_balanceflow_kcal_lastcalibyear(iso,kfo); + +*' Depending on the scenario switch c15_calibscen, the divergence of the BMI shares from the +*' historical data is kept constant over time or faded out. + i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) = + i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15) + * f15_kcal_calib_fadeout(t,"%c15_calibscen%"); +); + + + +*############################################################################### +* ###### Food substitution scenarios, same as in intersolve +s15_run_diet_postprocessing = 1; +$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); + + +*' @stop + +*############################################################################### + + + + +*' @code +*' Now, MAgPIE is executed. +*' @stop diff --git a/modules/15_food/anthro_iso_jun22/realization.gms b/modules/15_food/anthro_iso_jun22/realization.gms new file mode 100644 index 0000000000..4439c7bfb5 --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/realization.gms @@ -0,0 +1,67 @@ +*** | (C) 2008-2025 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 + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/15_food/anthro_iso_jun22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/15_food/anthro_iso_jun22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/15_food/anthro_iso_jun22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/15_food/anthro_iso_jun22/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/15_food/anthro_iso_jun22/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/15_food/anthro_iso_jun22/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/15_food/anthro_iso_jun22/presolve.gms" +$Ifi "%phase%" == "intersolve" $include "./modules/15_food/anthro_iso_jun22/intersolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthro_iso_jun22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### + +*' @description +*' This realization uses per capita income and the demography of the +*' world population (including sex and age classes at the country level, +*' which are provided from module [09_drivers]) as drivers. +*' The module estimates food demand on iso-country level taking +*' anthropometric food requirements as well as economic dynamics into account. +*' If flexible demand is activated, the module also uses the shadow prices +*' for agircultural products from the optimization, which are the Lagrange +*' multipliers of the constraint `q15_food_demand`. +*' The module consists of a standalone food demand model, which is executed +*' before MAgPIE starts. In the case of endogenous demand, the module is +*' iterated with MAgPIE. +*' Besides providing the fooduse of agricultural products, the model also +*' provides a number of output indicators, including the BMI distribution, +*' body weight and height of the population by age and sex, food intake by +*' age group and sex, food waste, dietary composition between livestock products, +*' empty calories (sugar, oil and alcohol), fruits vegetables and nuts, as well +*' as staple calories. +*' The food demand model can be run in standalone mode by running the +*' the file `standalone/demand_model.gms`. +*' The model is described in [@bodirsky_starved_nodate]. +*' +*' ![Execution order](food_demand_coupling.png){ width=60% } +*' +*' The model also includes a number of switches that allow for exogenous +*' diet scenarios, most importantly the shift to the Planetary Health diet +*' [@willett_food_2019]. +*' +*' Note that, as of MAgPIE v4.12 onwards, FAO food balances +*' were changed from the deprecated FAO food balances +*' (referred to online as Food Balances -2013, old methodology and +*' population) to the current Food Balances and Supply Utilization +*' Accounts which are currently maintained, 2010 onwards, +*' see download date in source folder of FAO_online, +*' FB2010 and SUA2010 folder. As this introduced a methodological +*' break in the food balances in 2010, with inconsistencies +*' between the pre-2010 and post-2010 data, the model sees a shift in +*' food demand due to switching from matching the old to the new data. +*' This is especially apparent in food demand for livestock products +*' in Mt, as some regional Mt/kcal conversion ratios in FAOSTAT, +*' seem to have changed, especially for EUR (lower livestock demand). +*' Future dynamics (i.e. EUR re-gaining livestock demand) +*' also stem from the household balance flow, which is the difference between +*' our regional and FAO global household kcal intake. +*' This balance flow fades out, in a default model run, by 2050, leading +*' to EUR re-increasing livestock demand by 2050. +*' +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Felicitas Beier, Jan Philipp Dietrich diff --git a/modules/15_food/anthro_iso_jun22/scaling.gms b/modules/15_food/anthro_iso_jun22/scaling.gms new file mode 100644 index 0000000000..37143ea0f2 --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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 + +v15_income_pc_real_ppp_iso.scale(iso) = 10e5; +v15_kcal_intake_total_regr.scale(iso) = 10e3; +v15_kcal_regr_total.scale(iso) = 10e4; diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms new file mode 100644 index 0000000000..647489eec1 --- /dev/null +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -0,0 +1,264 @@ +*** | (C) 2008-2025 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 + + iter15 iterations between food demand model and magpie + /iter0*iter10/ + curr_iter15(iter15) currently active iteration + prev_iter15(iter15) last active iteration + + underaged15(age) Group of underaged age classes + /0--4,5--9,10--14/ + + adult15(age) Age groups for adult population + / 15--19, + 20--24, 25--29, 30--34, 35--39, + 40--44, 45--49, 50--54, 55--59, + 60--64, 65--69, 70--74, 75--79 + 80--84,85--89,90--94,95--99,100+ / + + working15(adult15) Group of working age population + / 15--19, + 20--24, 25--29, 30--34, 35--39, + 40--44, 45--49, 50--54, 55--59/ + + retired15(adult15) Age group of retired population + /60--64, 65--69, 70--74, 75--79 + 80--84,85--89,90--94,95--99,100+ / + + agegroup15 All age groups + /underaged,working,retired / + + age2_adults15(agegroup15) Adult age group + /working,retired / + + agegroup2age(agegroup15,age) Mapping between age cohort and age + / + underaged . (0--4,5--9,10--14) + working . (15--19, + 20--24, 25--29, 30--34, 35--39, + 40--44, 45--49, 50--54, 55--59) + retired . (60--64, 65--69, 70--74, 75--79 + 80--84,85--89,90--94,95--99,100+ ) + / + + bmi_tree15 Body mass index + /low,lowsplit,mediumsplit,high,highsplit/ + + bmi_group15 Body mass index gradient + /verylow,low,medium,mediumhigh,high,veryhigh/ + + bmi_group_est15(bmi_group15) Body mass index extremes + /verylow,low,mediumhigh,high,veryhigh/ + + age_new_estimated15(age) Estimated ages + /0--4,5--9,10--14,15--19/ + + reproductive(age) Age group of people in the reproductive age + /20--24, 25--29, 30--34, 35--39/ + + estimates15 Preliminary or final result for body height distribution + /preliminary,final/ + + paras_s15 Schofield equation parameters + /slope, intercept/ + + paras_b15 Intake equation parameters + /saturation,halfsaturation,intercept/ + + paras_h15 Bodyheight equation parameters + /slope, exponent/ + + kfo(kall) All products in the sectoral version + / tece,maiz,trce,rice_pro,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 / + + growth_food15(kfo) Food items that are important for body growth regression + / soybean,groundnut,puls_pro,oils, + livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish / + + kst(kfo) Plant-based staple products in the sectoral version + / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, + potato,cassav_sp,sugr_cane,sugr_beet, + oils,sugar,molasses,alcohol,brans,scp / + + kfo_pp(kfo) Plant-based food products + / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, + potato,cassav_sp,sugr_cane,sugr_beet, + oils,sugar,molasses,alcohol,brans,scp, + others / + + kfo_ap(kfo) Animal food products + / livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish / + + kfo_lp(kfo) Livestock food products + / livst_rum,livst_pig,livst_chick, livst_egg, livst_milk / + + kfo_st(kfo) Staple products + / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, + potato,cassav_sp,sugr_cane,sugr_beet,molasses,brans,scp / + + kfo_pf(kfo) Processed foods including oils sugar alcohol + / oils,alcohol,sugar / + + 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 / + + knf(kall) Non-food products in the sectoral version + / oilpalm,cottn_pro,foddr, pasture, begr, betr, + oilcakes,ethanol,distillers_grain,fibres, + res_cereals, res_fibrous, res_nonfibrous, + wood, woodfuel / + + nutrition Nutrition attributes + / kcal, protein/ + + par15 Parameters for food module + / intercept,saturation,halfsaturation,non_saturation / +* intercept + saturation give the max value if non-saturation is 1 +* halfsaturation is the gdp until which half of saturation is reached + + regr15 Demand regression types + / overconsumption,livestockshare,processedshare,vegfruitshare / + +*** Scenarios + food_scen15 Food scenarios + / SSP1, SSP2, SSP3, SSP4, SSP5, + SSP1_boundary, SSP2_boundary, SSP3_boundary, + SSP4_boundary, SSP5_boundary, + SSP2_lowcal, SSP2_lowls, SSP2_waste, + ssp2_high_yvonne,ssp2_low_yvonne,ssp2_lowest_yvonne, + history / + + pop_scen15 Population scenarios + / SSP1, SSP2, SSP3, SSP4, SSP5 / + + + calibscen15 Calibration scenarios for balance flow + / constant, fadeout2050 / + + livst_fadeoutscen15 Scenarios for changed composition of livestock products + / halving2050, constant / + +* The set kfo_rd can be defined in default.cfg and is used in the food substitution scenarios s15_rumdairy_scp_substitution and s15_rumdairy_substitution + kfo_rd(kfo) Ruminant meat and dairy food products + / livst_rum,livst_milk / + + fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, + lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50, sigmoid_75pc_25_50, sigmoid_50pc_25_50, sigmoid_25pc_25_50 / + + t_scen15(t_all) Target years for transition to exogenous scenario diets + / y2010, y2030, y2050 / + + kcal_scen15 Scenario of daily per capita calorie intake + / 2100kcal, 2500kcal / + + EAT_scen15 Scenario of daily per capita calorie intake + / BMK, FLX, PSC, VEG, VGN, FLX_hmilk, FLX_hredmeat / + + EAT_monogastrics15(kfo) monogastic products + / livst_pig, livst_egg, livst_chick / + EAT_ruminants15(kfo) ruminant products + / livst_milk, livst_rum / + 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 / + EAT_pulses15_old(kfo) pulses + / soybean, puls_pro, groundnut / + EAT_pulses15(kfo) pulses + / soybean, puls_pro / + 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 / + + 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 / + +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_fruitstarch, + 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 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) + 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) + / + +fafh food-at-home fah or food-away-from-home fafh pertaining to where food is consumed + / fah, fafh / + +fafh_regr coefficients for regression of food-at-home fah or food-away-from-home fafh pertaining to where food is consumed + / a_fafh, b_fafh / + +margincoef added-value margin coefficients + / a, b, c / + +; + +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_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); +alias(EATtar_kfo15, EATtar_kfo15_2); +alias(EAT_mtargets15, EAT_mtargets15_2); diff --git a/modules/15_food/anthropometrics_jan18/declarations.gms b/modules/15_food/anthropometrics_jan18/declarations.gms deleted file mode 100644 index e7b2ef9a1c..0000000000 --- a/modules/15_food/anthropometrics_jan18/declarations.gms +++ /dev/null @@ -1,216 +0,0 @@ -*** | (C) 2008-2019 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 - q15_food_demand(i,kfo) Food demand (mio. kcal) -; - -positive variables - 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) - - q15_regr_bmi_shr(iso,sex,agegroup15,bmi_tree15) Estimates regression parameters for BMI regression shares (1) - q15_bmi_shr_verylow(iso,sex,agegroup15) Estimates BMI share for population groups with low BMI (1) - q15_bmi_shr_low(iso,sex,agegroup15) Estimates BMI share for population groups with very low BMI (1) - q15_bmi_shr_medium(iso,sex,agegroup15) Estimates BMI share for population groups with medium BMI(1) - q15_bmi_shr_medium_high(iso,sex,agegroup15) Estimates BMI share for population groups with medium to high BMI (1) - q15_bmi_shr_high(iso,sex,agegroup15) Estimates BMI share for population groups with high BMI (1) - q15_bmi_shr_veryhigh(iso,sex,agegroup15) Estimates BMI share for population groups with very high BMI (1) - q15_bmi_shr_agg(iso,sex,age,bmi_group15) Disaggregates age groups from overarching groups (1) - - q15_intake(iso) Estimates average intake for the entire country (kcal per cap per day) - q15_regr_kcal(iso) Per capita total demand (kcal per cap per day) - q15_regr(iso, regr15) Estimates parameters for food demand and dietary composition (1) - q15_foodtree_kcal_animals(iso,kfo_ap) Demand for animal products (kcal per cap per day) - 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) - -; - - -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_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) -; - -variables - v15_objective Objective term (USD05PPP) -; - -scalars - s15_yeardiff Number of 5-year time intervalls between time steps (1) - s15_count Loop counter for interpolating body height estimates between longer timesteps (1) - -; - -parameters -* technical - p15_modelstat(t) Model solver status (1) - p15_iteration_counter(t) Number of iterations required for reaching an equilibrium between food demand model and magpie (1) - p15_convergence_measure(t) Convergence measure to decide for continuation or stop of food_demand - magpie iteration (1) - i15_dem_intercept(regr15) Food regression parameters intercept in kcal or as share (X) - i15_dem_saturation(regr15) Food regression parameters saturation in kcal or as share (X) - i15_dem_halfsat(regr15) Food regression parameters halfsaturation (USD05PPP per cap) - i15_dem_nonsat(regr15) Food regression parameters nonsaturation (1) - -*prices - p15_prices_kcal(t,iso,kfo) 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 - o15_bmi_shr(t,iso,sex,age,bmi_group15) Calibrated estimates BMI share for population groups (1) - 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) - 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) - i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15) Calibration parameters of the last year with historical observations (1) - -* diet structure - o15_kcal_intake_total(t,iso) Total food intake in a country (kcal per capita per day) - p15_intake(t,iso,sex,age,bmi_group15) Mean food intake by population group (kcal per capita per day) - i15_kcal_pregnancy(t,iso) Additional calorie requirements for pregnancy and lactation (kcal) - p15_kcal_regr(t, iso, kfo) Uncalibrated regression estimates of calorie demand (kcal per cap per day) - - i15_ruminant_fadeout(t_all) Ruminant fadeout share (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) - p15_kcal_calib_lastcalibyear(iso,kfo) Calibration factor for the last year with observations (kcal per cap per day) - p15_balanceflow_kcal(t,i,kfo) Balance flow for mismatch between FAOSTAT and demand estimates (kcal per capita per day) - p15_balanceflow_kcal_iso(t,iso,kfo) Balance flow for mismatch between FAOSTAT and demand estimates (kcal per capita per day) - p15_balanceflow_kcal_lastcalibyear(iso,kfo) Balance flow of last historic time step for mismatch between FAOSTAT and demand estimates (kcal per capita per day) - -* before shock - - o15_kcal_regr_initial(iso,kfo) Uncalibrated per capita demand before price shock (kcal per capita per day) - p15_kcal_pc_initial(t,i,kfo) Per capita consumption in food demand model before price shock on regional level (kcal per capita per day) - pm_kcal_pc_initial(t,i,kfo) 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) - -* calculate diet iteration breakpoint - - p15_income_pc_real_ppp(t,i) Regional per capita income after price shock on regional level (USD05PPP per capita) - p15_delta_income(t,i) Regional change in per capita income due to price shock on regional level (1) - p15_lastiteration_delta_income(t,i) Regional change in per capita income due to price shock of last iteration (1) - -; - -scalars - 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, - - q15_regr_bmi_shr, - - q15_bmi_shr_verylow, - q15_bmi_shr_low, - q15_bmi_shr_medium, - q15_bmi_shr_medium_high, - q15_bmi_shr_high, - q15_bmi_shr_veryhigh, - - q15_bmi_shr_agg, - - q15_intake, - q15_regr_kcal, - q15_regr, - - q15_foodtree_kcal_animals, - q15_foodtree_kcal_processed, - q15_foodtree_kcal_staples, - q15_foodtree_kcal_vegetables - /; - - - -*' In contrast, the equation `q15_food_demand` is part of MAgPIE, but -*' not of the food demand model. -*' @stop - -m15_food_demand.optfile = 0 ; -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) - ov15_kcal_regr(t,iso,kfo,type) Uncalibrated regression estimates of calorie demand (kcal per cap per day) - ov15_kcal_regr_total(t,iso,type) Uncalibrated regression estimates of total per cap calories (kcal per cap per day) - ov15_demand_regr(t,iso,regr15,type) Uncalibrated regression estimates of kcal shares (1) - ov15_income_pc_real_ppp_iso(t,iso,type) Real income per cap (USD05PPP per cap) - ov15_income_balance(t,iso,type) Balance variable to balance cases in which reduction in income is larger than the per capita GDP (USD05PPP per cap per yr) - ov15_kcal_intake_total_regr(t,iso,type) Food intake (kcal per cap per day) - ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,type) Hierarchical tree parameter regressions (1) - ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,type) Uncalibrated share of population groups belonging to a certain BMI group (1) - ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,type) Uncalibrated share of population groups belonging to a certain BMI group (1) - ov15_objective(t,type) Objective term (USD05PPP) - oq15_food_demand(t,i,kfo,type) Food demand (mio. kcal) - oq15_aim(t,type) Objective function of food demand model (mio. USD05PPP) - oq15_budget(t,iso,type) Household budget constraint (USD05PPP per cap per day) - oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,type) Estimates regression parameters for BMI regression shares (1) - oq15_bmi_shr_verylow(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with low BMI (1) - oq15_bmi_shr_low(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with very low BMI (1) - oq15_bmi_shr_medium(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with medium BMI(1) - oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with medium to high BMI (1) - oq15_bmi_shr_high(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with high BMI (1) - oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,type) Estimates BMI share for population groups with very high BMI (1) - oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,type) Disaggregates age groups from overarching groups (1) - oq15_intake(t,iso,type) Estimates average intake for the entire country (kcal per cap per day) - oq15_regr_kcal(t,iso,type) Per capita total demand (kcal per cap per day) - oq15_regr(t,iso,regr15,type) Estimates parameters for food demand and dietary composition (1) - oq15_foodtree_kcal_animals(t,iso,kfo_ap,type) Demand for animal products (kcal per cap per day) - oq15_foodtree_kcal_processed(t,iso,kfo_pf,type) Demand for processed products (kcal per cap per day) - oq15_foodtree_kcal_staples(t,iso,kfo_st,type) Demand for staple products (kcal per cap per day) - oq15_foodtree_kcal_vegetables(t,iso,type) Demand for vegetable and fruit products (kcal per cap per day) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/15_food/anthropometrics_jan18/equations.gms b/modules/15_food/anthropometrics_jan18/equations.gms deleted file mode 100644 index 0ac59e4753..0000000000 --- a/modules/15_food/anthropometrics_jan18/equations.gms +++ /dev/null @@ -1,207 +0,0 @@ -*** | (C) 2008-2019 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 - -q15_food_demand(i2,kfo) .. - (vm_dem_food(i2,kfo) + sum(ct, f15_household_balanceflow(ct,i2,kfo,"dm"))) - * sum(ct,(f15_nutrition_attributes(ct,kfo,"kcal") * 10**6)) =g= - sum(ct,im_pop(ct,i2) * p15_kcal_pc_calibrated(ct,i2,kfo)) * 365 - ; - -*' Above constraint transforms the fooduse of agricultural products into per capita -*' food demand. -*' `vm_dem_food` is the fooduse of agricultural products. It is measured in tons -*' of dry matter prior to processing. The multiplication with the nutrition attributes -*' provides the equivalent in calories. While nutrition attributes are assumed -*' to be globally the same -*' (assumption of homogeneous products), a regional balance flow is used to account -*' for current differences in food processing, where some regions get different calories -*' from the same fooduse quantitiy. Depending on the input data, the balance flow -*' may fade out in the future, which implies actual homogeneous products. - -*' The subsequent equations belong to the standalone food demand model, which is -*' executed before MAgPIE or iterated with MAgPIE. They are excluded from the run -*' of MAgPIE itself. - -q15_aim .. - v15_objective =e= - sum(iso, - - 10**6*v15_income_balance(iso)) - ; - -*' In principle, the food demand model has only one solution that satifies all -*' equations. Technically, the objective could therefore be chosen arbirtrarily, -*' for the solver to find the single solution. -*' However, if the model is executed outside its domain -*' (e.g. with extreme price shocks), it can happen that real income takes a -*' negative value (because the increase in food value exceeds the available income). -*' To avoid this case, a punishment term `v15_income_balance` is introduced. It -*' increases the real income, but affects the maximized objective variable -*' negatively, disincentivizing its use in cases where it is not needed. - - -q15_budget(iso) .. - v15_income_pc_real_ppp_iso(iso) =e= - sum((ct,kfo), v15_kcal_regr(iso,kfo)*365 - *(i15_prices_initial_kcal(iso,kfo)-p15_prices_kcal(ct,iso,kfo))) - + sum(ct,im_gdp_pc_ppp_iso(ct,iso)) + v15_income_balance(iso); - -*' The budget constraint calculates the real income after a possible price -*' shock. The basic assumption is that increasing prices reduce real income, -*' while decreasing prices increase real income. -*' Through this income effect, higher prices reduce the food demand. -*' The income before the food price shock is `im_gdp_pc_ppp`. -*' It is reduced by the change in value of the demanded calories under changed -*' prices. -*' In the following, the real income is used to determine food intake, -*' food demand as well as dietary composition. - -*' The BMI distribution within the population is calculated using -*' regressions in a hierachical tree to estimate the share of the population -*' falling into a certain BMI class. -*' ![Hierarchical tree used to estimate BMI population shares](hierarchical_tree.png){ width=100% } - -*' First, the regression shares are calculated: - -q15_regr_bmi_shr(iso,sex,agegroup15,bmi_tree15) .. - v15_regr_overgroups(iso,sex,agegroup15,bmi_tree15) - =e= - i15_bmi_intercept(sex,agegroup15,bmi_tree15) - + (i15_bmi_saturation(sex,agegroup15,bmi_tree15) * v15_income_pc_real_ppp_iso(iso)) - / (i15_bmi_halfsat(sex,agegroup15,bmi_tree15) + v15_income_pc_real_ppp_iso(iso)); - -*' Then, these regression shares are applied to parameterize the -*' hierarchical tree structure: - -q15_bmi_shr_verylow(iso,sex,agegroup15) .. - v15_bmi_shr_overgroups(iso,sex,agegroup15,"verylow") - =e= - v15_regr_overgroups(iso,sex,agegroup15,"low") - * v15_regr_overgroups(iso,sex,agegroup15,"lowsplit") - ; - -q15_bmi_shr_low(iso,sex,agegroup15) .. - v15_bmi_shr_overgroups(iso,sex,agegroup15,"low") - =e= - v15_regr_overgroups(iso,sex,agegroup15,"low") - * (1- v15_regr_overgroups(iso,sex,agegroup15,"lowsplit")) - ; - -q15_bmi_shr_medium(iso,sex,agegroup15) .. - v15_bmi_shr_overgroups(iso,sex,agegroup15,"medium") - =e= - (1-v15_regr_overgroups(iso,sex,agegroup15,"low") - -v15_regr_overgroups(iso,sex,agegroup15,"high")) - * (1-v15_regr_overgroups(iso,sex,agegroup15,"mediumsplit")) - ; - -q15_bmi_shr_medium_high(iso,sex,agegroup15) .. - v15_bmi_shr_overgroups(iso,sex,agegroup15,"mediumhigh") - =e= - (1-v15_regr_overgroups(iso,sex,agegroup15,"low") - -v15_regr_overgroups(iso,sex,agegroup15,"high")) - * v15_regr_overgroups(iso,sex,agegroup15,"mediumsplit") - ; - -q15_bmi_shr_high(iso,sex,agegroup15) .. - v15_bmi_shr_overgroups(iso,sex,agegroup15,"high") - =e= - v15_regr_overgroups(iso,sex,agegroup15,"high") - * (1-v15_regr_overgroups(iso,sex,agegroup15,"highsplit")) - ; - -q15_bmi_shr_veryhigh(iso,sex,agegroup15) .. - v15_bmi_shr_overgroups(iso,sex,agegroup15,"veryhigh") - =e= - v15_regr_overgroups(iso,sex,agegroup15,"high") - * v15_regr_overgroups(iso,sex,agegroup15,"highsplit") - ; - - -*' From BMI shares of the larger groups (overgroups), we disaggregate to -*' age-specific subgroups. - -q15_bmi_shr_agg(iso,sex,age,bmi_group15) .. - v15_bmi_shr_regr(iso,sex,age,bmi_group15) - =e= - sum(agegroup2age(agegroup15,age), - v15_bmi_shr_overgroups(iso,sex,agegroup15,bmi_group15) - ); - - -*' Food intake is estimated based on BMI distribution, typical intakes for -*' BMI groups, demographic structure and extra energy requirements for -*' pregnancy and lactation (estimated based on the new-born population size). - -q15_intake(iso).. - v15_kcal_intake_total_regr(iso) - * sum((sex,age,ct), im_demography(ct,iso,sex,age)) - =e= - sum((ct, sex, age, bmi_group15), - v15_bmi_shr_regr(iso,sex,age,bmi_group15)* - im_demography(ct,iso,sex,age) * - p15_intake(ct,iso,sex,age,bmi_group15) - ) - + sum(ct,i15_kcal_pregnancy(ct,iso)) - ; - - -*' Food demand is based on food intake and a regression -*' based on income, which estimates how much the actual demand is relative to -*' the required intake. -*' The difference between demand and intake is food waste (not explicitly -*' mentioned in this equation) - -q15_regr_kcal(iso) .. - v15_kcal_regr_total(iso) =e= - v15_demand_regr(iso, "overconsumption") - *v15_kcal_intake_total_regr(iso); - -*' This equation estimates key dietary composition regressision factors, -*' such as the share of animal products, empty calories, or -*' fruits, vegetables and nuts. - -q15_regr(iso, regr15) .. - v15_demand_regr(iso, regr15) =e= - i15_dem_intercept(regr15) - + (i15_dem_saturation(regr15) * v15_income_pc_real_ppp_iso(iso)) - / (i15_dem_halfsat(regr15) + v15_income_pc_real_ppp_iso(iso)**i15_dem_nonsat(regr15)); - -*' In the subsequent equations, those parameters -*' are used to determine the dietary composition using a hierachical tree: -*' Total calories are first divided into animal- and plant-based. The plant-based -*' calories are further divided into processed empty calories and nutritious -*' calories, and so on. - -q15_foodtree_kcal_animals(iso,kfo_ap) .. - v15_kcal_regr(iso,kfo_ap) =e= - v15_kcal_regr_total(iso) - * v15_demand_regr(iso, "livestockshare") - * sum(ct,i15_livestock_kcal_structure_iso(ct,iso,kfo_ap)); - -q15_foodtree_kcal_processed(iso,kfo_pf) .. - v15_kcal_regr(iso,kfo_pf) =e= - v15_kcal_regr_total(iso) - * (1 - v15_demand_regr(iso, "livestockshare")) - * v15_demand_regr(iso, "processedshare") - * sum(ct,i15_processed_kcal_structure_iso(ct,iso,kfo_pf)) ; - -q15_foodtree_kcal_vegetables(iso) .. - v15_kcal_regr(iso,"others") =e= - v15_kcal_regr_total(iso) - * (1 - v15_demand_regr(iso, "livestockshare")) - * (1 - v15_demand_regr(iso, "processedshare")) - * v15_demand_regr(iso, "vegfruitshare"); - -q15_foodtree_kcal_staples(iso,kfo_st) .. - v15_kcal_regr(iso,kfo_st) =e= - v15_kcal_regr_total(iso) - * (1 - v15_demand_regr(iso, "livestockshare")) - * (1 - v15_demand_regr(iso, "processedshare")) - * (1 - v15_demand_regr(iso, "vegfruitshare")) - * sum(ct,i15_staples_kcal_structure_iso(ct,iso,kfo_st)) ; diff --git a/modules/15_food/anthropometrics_jan18/input.gms b/modules/15_food/anthropometrics_jan18/input.gms deleted file mode 100644 index 537fa5db27..0000000000 --- a/modules/15_food/anthropometrics_jan18/input.gms +++ /dev/null @@ -1,121 +0,0 @@ -*** | (C) 2008-2019 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 - - -$setglobal c15_food_scenario SSP2 -* options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" -* SRES: "A1", "A2", "B1", "B2" -* OTHER: "SSP1_boundary", "SSP2_boundary", "SSP3_boundary", "SSP4_boundary", "SSP5_boundary" - -$setglobal c15_calibscen constant -* options: constant, fadeout2050 - -$setglobal c15_rumscen mixed -* options: constant, halving2050, mixed - -scalar s15_elastic_demand Elastic demand switch (1=elastic 0=exogenous) (1) / 1 /; - -scalar s15_calibrate Calibration switch (1=calibrated 0=pure regression outcomes) (1) / 1 /; -* only for per-capita calories, not for e.g. calibration of transformation parameters between per-capita calories in dm - -scalar s15_maxiter Scalar defining maximum number of iterations (1) / 5 /; - -scalar s15_convergence Convergence criterion (1) / 0.005 /; - -table f15_household_balanceflow(t_all,i,kall,dm_ge_nr) Balance flow to take account of heterogeneous products and processes (mio. tDM) -$ondelim -$include "./modules/15_food/input/f15_household_balanceflow.cs3" -$offdelim; - -table f15_nutrition_attributes(t_all,kall,nutrition) Nutrition attributes of food items dedicated for fooduse (mio. kcal per tDM | t Protein per tDM) -$ondelim -$include "./modules/15_food/input/f15_nutrition_attributes.cs3" -$offdelim; - - -*** Food Demand Model - - -* Unit for `f15_demand_paras` is -* kcal/capita/day for saturation and intercept, and -* USD05/capita for halfsaturation - -table f15_demand_paras(regr15,food_scen15,par15) Food regression parameters in USD05PPP or dimensionless (X) -$ondelim -$include "./modules/15_food/input/f15_demand_regression_parameters.cs3" -$offdelim; - -table f15_bmi_shr_paras(sex, agegroup15, bmi_tree15, paras_b15) BMI share regression parameters in USD05PPP or dimensionless (X) -$ondelim -$include "./modules/15_food/input/f15_bmi_shr_regr_paras.cs3" -$offdelim; - -table f15_bmi(sex,age,bmi_group15) Mean body mass index for each BMI group (kg per m2) -$ondelim -$include "./modules/15_food/input/f15_bmi.cs3" -$offdelim; - -table f15_bmi_shr_past(t_all,iso,age,sex,bmi_group15) Observed share of population belonging to a BMI group in the past (1) -$ondelim -$include "./modules/15_food/input/f15_bmi_shr_past.cs3" -$offdelim; - - -table f15_kcal_pc_iso(t_all,iso,kfo) Observed per capita food supply in the past (kcal per cap per day) -$ondelim -$include "./modules/15_food/input/f15_kcal_pc_iso.csv" -$offdelim; - - -table f15_intake_pc_observed_iso(t_all,iso,sex,age) Observed per capita food intake in the past (kcal per captia per day) -$ondelim -$include "./modules/15_food/input/f15_intake_pc_observed_iso.cs3" -$offdelim; - - -parameter f15_prices_initial(kall) Food prices in initialization period (USD05MER per t DM) -/ -$ondelim -$include "./modules/15_food/input/f15_prices_initial.csv" -$offdelim -/; - - -parameter f15_price_index(t_all) Food price index in initialization period (1) -/ -$ondelim -$include "./modules/15_food/input/f15_prices_index.csv" -$offdelim -/; - - -table f15_kcal_calib_fadeout(t_all,calibscen15) Calibration fadeout factor (1) -$ondelim -$include "./modules/15_food/input/f15_kcal_balanceflow_fadeout.csv" -$offdelim -; - -table f15_ruminant_fadeout(t_all,ruminantfadeoutscen15) Ruminant fadeout scenario (1) -$ondelim -$include "./modules/15_food/input/f15_ruminant_fadeout.csv" -$offdelim -; - -table f15_bodyheight(t_all,iso,sex,age) Body height (cm per cap) -$ondelim -$include "./modules/15_food/input/f15_bodyheight_historical.cs3" -$offdelim; - -table f15_schofield(sex,age, paras_s15) Schofield equation parameters in kcal per capita per day or kcal per capita per day per weight (X) -$ondelim -$include "./modules/15_food/input/f15_schofield_parameters.cs3" -$offdelim -; - - - -*** EOF input.gms *** diff --git a/modules/15_food/anthropometrics_jan18/intersolve.gms b/modules/15_food/anthropometrics_jan18/intersolve.gms deleted file mode 100644 index 710bf2d886..0000000000 --- a/modules/15_food/anthropometrics_jan18/intersolve.gms +++ /dev/null @@ -1,142 +0,0 @@ -*** | (C) 2008-2019 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 - -option nlp = conopt4 - -* retrieving interfaces from MAgPIE -* calculate prices for providing 1 kcal per day of one commodity - -*' @code -*' After one time step of MAgPIE is executed, the shadow prices of the food demand -*' constraint are fed back into the food demand module, and the food demand -*' module is executed once again. -*' @stop - -if (magpie.modelstat = NA, - q15_food_demand.m(i,kfo)=0; - p15_prices_kcal(t,iso,kfo)=i15_prices_initial_kcal(iso,kfo)*f15_price_index(t); -else - display "Coupling: Reading out marginal costs from MAgPIE as shock to demand model"; - p15_prices_kcal(t,iso,kfo)=sum(i_to_iso(i,iso), q15_food_demand.m(i,kfo)); -); - -p15_iteration_counter(t)= p15_iteration_counter(t) + 1; - -display "starting m15_food_demand model...."; - -solve m15_food_demand USING nlp MAXIMIZING v15_objective ; -p15_modelstat(t) = m15_food_demand.modelstat; - -display "Food Demand Model finished with modelstat "; -display p15_modelstat; - -if(( p15_modelstat(t)) > 2 and (p15_modelstat(t) ne 7 ), - m15_food_demand.solprint = 1 - Execute_Unload "fulldata.gdx"; - abort "Food Demand Model became infeasible. Should not be possible."; -); - - -* estimate regional indicators from demand model - - - p15_income_pc_real_ppp(t,i)$( - sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ) >0 ) = - sum(i_to_iso(i,iso), - v15_income_pc_real_ppp_iso.l(iso) - * im_pop_iso(t,iso) - ) / sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ); - - p15_delta_income(t,i) = p15_income_pc_real_ppp(t,i) / im_gdp_pc_ppp(t,i); - -* estimate convergence measure for deciding to stop iteration - - - p15_convergence_measure(t) =smax(i, - abs(p15_delta_income(t,i) / p15_lastiteration_delta_income(t,i)- 1) - ); - - -* keeping current deltas for estimating convergence in next timestep - p15_lastiteration_delta_income(t,i) = p15_delta_income(t,i); - - -*' @code -*' If `s15_elastic_demand` is 0, MAgPIE is not executed again for this time step. -*' In case that `s15_elastic_demand` is 1, it is checked whether MAgPIE and the -*' food demand model have reached sufficient convergence. The criterion for this -*' is whether the real income in the food demand model has changed in any region -*' by more than `s15_convergences_measure` relative to the last iteration due to -*' changes in food prices from MAgPIE. Moreover, the model aborts when the -*' number of iterations reaches `s15_maxiter`. -*' As long as the iteration continues, the food prices are transferred from -*' MAgPIE to the food demand model, and the food demand is transferred from -*' the food demand model to MAgPIE. -*' @stop - - -display "finished iteration number ", p15_iteration_counter; -display "convergence measure:",p15_convergence_measure; - -if (s15_elastic_demand * (1-sum(sameas(t_past,t),1)) =1, - display "elastic demand model is activated"; - if ((p15_convergence_measure(t) > s15_convergence and p15_iteration_counter(t) <= s15_maxiter), - - display "convergence between MAgPIE and Food Demand Model not yet reached"; - sm_intersolve=0; - -* saving regression outcome for postprocessing - p15_kcal_regr(t, iso, kfo)=v15_kcal_regr.l(iso, kfo); - p15_bmi_shr_regr(t,iso,sex,age,bmi_group15)=v15_bmi_shr_regr.l(iso,sex,age,bmi_group15); - -* The calibration factor is added to the regression value. - p15_kcal_pc_iso(t,iso,kfo) = 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; - -* aggregate to regions - p15_kcal_pc(t,i,kfo)$( - sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ) >0 ) = - sum(i_to_iso(i,iso), - p15_kcal_pc_iso(t,iso,kfo) - * im_pop_iso(t,iso) - ) / sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ); - -* We calibrate countries with zero food demand according to FAOSTAT -* 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; - - - if (p15_modelstat(t) < 3, - put_utility 'shell' / 'mv -f m15_food_demand_p.gdx m15_food_demand_' t.tl:0'.gdx'; - ); - - elseif(p15_iteration_counter(t) > s15_maxiter), - sm_intersolve=1; - display "Warning: convergence between MAgPIE and Food Demand Model not reached after ",p15_iteration_counter," iterations. Continue to next time step!"; - else - sm_intersolve=1; - display "Success: convergence between MAgPIE and Food Demand Model reached after ",p15_iteration_counter," iterations"; -* set back convergence indicators for next timestep - ); - -else -display "exogenous demand information is used" ; -); - diff --git a/modules/15_food/anthropometrics_jan18/postsolve.gms b/modules/15_food/anthropometrics_jan18/postsolve.gms deleted file mode 100644 index 6f5d2d0560..0000000000 --- a/modules/15_food/anthropometrics_jan18/postsolve.gms +++ /dev/null @@ -1,234 +0,0 @@ -*** | (C) 2008-2019 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 - - -*' The calibration parameter is added to the regression value. - - o15_bmi_shr(t,iso,sex,age,bmi_group15) = - p15_bmi_shr_regr(t,iso,sex,age,bmi_group15)+ - i15_bmi_shr_calib(t,iso,sex,age,bmi_group15); - -*' The BMI shares are not allowed to exceed the bounds 0 and 1. Values are corrected to the bounds. - o15_bmi_shr(t,iso,sex,age,bmi_group15)$(o15_bmi_shr(t,iso,sex,age,bmi_group15)<0) = 0; - o15_bmi_shr(t,iso,sex,age,bmi_group15)$(o15_bmi_shr(t,iso,sex,age,bmi_group15)>1) = 1; -*' The mismatch is balanced by moving the exceeding quantities into the middle BMI group. - o15_bmi_shr(t,iso,sex,age,"medium")= - 1 - (sum(bmi_group15, o15_bmi_shr(t,iso,sex,age,bmi_group15)) - o15_bmi_shr(t,iso,sex,age,"medium")); - -*' We recalculate the intake with the new values. - o15_kcal_intake_total(t,iso) = - ( - sum((sex, age, bmi_group15), - o15_bmi_shr(t,iso,sex,age,bmi_group15)* - 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)); - - - -if(ord(t)>1, -* start from bodyheight structure of last period - p15_bodyheight(t,iso,sex,age,"final") = p15_bodyheight(t-1,iso,sex,age,"final"); - p15_kcal_growth_food(t,iso,underaged15) = p15_kcal_growth_food(t-1,iso,underaged15); -); - -s15_yeardiff = m_yeardiff(t)/5; -if(s15_yeardiff<1,s15_yeardiff=1); - -For (s15_count = 1 to s15_yeardiff, - -* circular move of age by 5 years -* to find out about ++1 search for help on Circular Lag and Lead Operators in Assignments - p15_bodyheight(t,iso,sex,age++1,"final") = p15_bodyheight(t,iso,sex,age,"final"); - -* move on consumption agegroups by 5 years - p15_kcal_growth_food(t,iso,underaged15++1)= - p15_kcal_growth_food(t,iso,underaged15); - -* consumption is calculated as linear interpolation between timesteps - p15_kcal_growth_food(t,iso,"0--4") = - sum(growth_food15, - p15_kcal_pc_iso(t,iso,growth_food15) * (s15_count / (m_yeardiff(t)/5)) - + p15_kcal_pc_iso(t-1,iso,growth_food15) * (1 - s15_count / (m_yeardiff(t)/5)) - ); - -*' @code -*' After each execution of the food demand model, the body height distribution -*' of the population is estimated. The starting point is the body height -*' distribution of the last timestep. The body height estimates of the old -*' period are moved into the subsequent age class (e.g. the 20-24 year old are -*' now 25-29 years old). The age class of 15-19 year old is estimated newly -*' using the body height regressions and the food consumption of the last 15 -*' years. - - p15_bodyheight(t,iso,"F","15--19","final") = - 126.4* - (sum(underaged15, - p15_kcal_growth_food(t,iso,underaged15) - )/3)**0.03467 - ; - p15_bodyheight(t,iso,"M","15--19","final") = - 131.8* - (sum(underaged15, - p15_kcal_growth_food(t,iso,underaged15) - )/3)**0.03978 - ; -*' @stop -); - -*' @code -*' The bodyheight of the underaged age class (0-14) is assumed to diverge from 'normal' -*' body height by the same proportion as the age class of the 15-19 year old. - -p15_bodyheight(t,iso,"M","0--4","final")=p15_bodyheight(t,iso,"M","15--19","final")/176*92; -p15_bodyheight(t,iso,"M","5--9","final")=p15_bodyheight(t,iso,"M","15--19","final")/176*125; -p15_bodyheight(t,iso,"M","10--14","final")=p15_bodyheight(t,iso,"M","15--19","final")/176*152; - -p15_bodyheight(t,iso,"F","0--4","final")=p15_bodyheight(t,iso,"M","15--19","final")/163*91; -p15_bodyheight(t,iso,"F","5--9","final")=p15_bodyheight(t,iso,"M","15--19","final")/163*124; -p15_bodyheight(t,iso,"F","10--14","final")=p15_bodyheight(t,iso,"M","15--19","final")/163*154; - -*' @stop - -*' @code -*' Finally, the regression outcome is calibrated by a country-specific additive -*' term, which is the residual of the regression fit and observation of the last -*' historical time step. - -if (sum(sameas(t_past,t),1) = 1, -* For historical period, the regression results are only used to estimate the calibration parameter. - p15_bodyheight_calib(t,iso,sex,age_new_estimated15) = f15_bodyheight(t,iso,sex,age_new_estimated15) - p15_bodyheight(t,iso,sex,age_new_estimated15,"final"); - p15_bodyheight(t,iso,sex,age_new_estimated15,"final") = f15_bodyheight(t,iso,sex,age_new_estimated15); -else - p15_bodyheight_calib(t,iso,sex,age_new_estimated15)=p15_bodyheight_calib(t-1,iso,sex,age_new_estimated15); - p15_bodyheight(t,iso,sex,age_new_estimated15,"final")=p15_bodyheight(t,iso,sex,age_new_estimated15,"final")+p15_bodyheight_calib(t,iso,sex,age_new_estimated15)*s15_calibrate; -); - -*' @stop - - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_dem_food(t,i,kall,"marginal") = vm_dem_food.m(i,kall); - ov15_kcal_regr(t,iso,kfo,"marginal") = v15_kcal_regr.m(iso,kfo); - ov15_kcal_regr_total(t,iso,"marginal") = v15_kcal_regr_total.m(iso); - ov15_demand_regr(t,iso,regr15,"marginal") = v15_demand_regr.m(iso,regr15); - ov15_income_pc_real_ppp_iso(t,iso,"marginal") = v15_income_pc_real_ppp_iso.m(iso); - ov15_income_balance(t,iso,"marginal") = v15_income_balance.m(iso); - ov15_kcal_intake_total_regr(t,iso,"marginal") = v15_kcal_intake_total_regr.m(iso); - ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"marginal") = v15_regr_overgroups.m(iso,sex,agegroup15,bmi_tree15); - ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"marginal") = v15_bmi_shr_regr.m(iso,sex,age,bmi_group15); - ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"marginal") = v15_bmi_shr_overgroups.m(iso,sex,agegroup15,bmi_group15); - ov15_objective(t,"marginal") = v15_objective.m; - oq15_food_demand(t,i,kfo,"marginal") = q15_food_demand.m(i,kfo); - oq15_aim(t,"marginal") = q15_aim.m; - oq15_budget(t,iso,"marginal") = q15_budget.m(iso); - oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"marginal") = q15_regr_bmi_shr.m(iso,sex,agegroup15,bmi_tree15); - oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_verylow.m(iso,sex,agegroup15); - oq15_bmi_shr_low(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_low.m(iso,sex,agegroup15); - oq15_bmi_shr_medium(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_medium.m(iso,sex,agegroup15); - oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_medium_high.m(iso,sex,agegroup15); - oq15_bmi_shr_high(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_high.m(iso,sex,agegroup15); - oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"marginal") = q15_bmi_shr_veryhigh.m(iso,sex,agegroup15); - oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"marginal") = q15_bmi_shr_agg.m(iso,sex,age,bmi_group15); - oq15_intake(t,iso,"marginal") = q15_intake.m(iso); - oq15_regr_kcal(t,iso,"marginal") = q15_regr_kcal.m(iso); - oq15_regr(t,iso,regr15,"marginal") = q15_regr.m(iso,regr15); - oq15_foodtree_kcal_animals(t,iso,kfo_ap,"marginal") = q15_foodtree_kcal_animals.m(iso,kfo_ap); - oq15_foodtree_kcal_processed(t,iso,kfo_pf,"marginal") = q15_foodtree_kcal_processed.m(iso,kfo_pf); - oq15_foodtree_kcal_staples(t,iso,kfo_st,"marginal") = q15_foodtree_kcal_staples.m(iso,kfo_st); - oq15_foodtree_kcal_vegetables(t,iso,"marginal") = q15_foodtree_kcal_vegetables.m(iso); - ov_dem_food(t,i,kall,"level") = vm_dem_food.l(i,kall); - ov15_kcal_regr(t,iso,kfo,"level") = v15_kcal_regr.l(iso,kfo); - ov15_kcal_regr_total(t,iso,"level") = v15_kcal_regr_total.l(iso); - ov15_demand_regr(t,iso,regr15,"level") = v15_demand_regr.l(iso,regr15); - ov15_income_pc_real_ppp_iso(t,iso,"level") = v15_income_pc_real_ppp_iso.l(iso); - ov15_income_balance(t,iso,"level") = v15_income_balance.l(iso); - ov15_kcal_intake_total_regr(t,iso,"level") = v15_kcal_intake_total_regr.l(iso); - ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"level") = v15_regr_overgroups.l(iso,sex,agegroup15,bmi_tree15); - ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"level") = v15_bmi_shr_regr.l(iso,sex,age,bmi_group15); - ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"level") = v15_bmi_shr_overgroups.l(iso,sex,agegroup15,bmi_group15); - ov15_objective(t,"level") = v15_objective.l; - oq15_food_demand(t,i,kfo,"level") = q15_food_demand.l(i,kfo); - oq15_aim(t,"level") = q15_aim.l; - oq15_budget(t,iso,"level") = q15_budget.l(iso); - oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"level") = q15_regr_bmi_shr.l(iso,sex,agegroup15,bmi_tree15); - oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"level") = q15_bmi_shr_verylow.l(iso,sex,agegroup15); - oq15_bmi_shr_low(t,iso,sex,agegroup15,"level") = q15_bmi_shr_low.l(iso,sex,agegroup15); - oq15_bmi_shr_medium(t,iso,sex,agegroup15,"level") = q15_bmi_shr_medium.l(iso,sex,agegroup15); - oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"level") = q15_bmi_shr_medium_high.l(iso,sex,agegroup15); - oq15_bmi_shr_high(t,iso,sex,agegroup15,"level") = q15_bmi_shr_high.l(iso,sex,agegroup15); - oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"level") = q15_bmi_shr_veryhigh.l(iso,sex,agegroup15); - oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"level") = q15_bmi_shr_agg.l(iso,sex,age,bmi_group15); - oq15_intake(t,iso,"level") = q15_intake.l(iso); - oq15_regr_kcal(t,iso,"level") = q15_regr_kcal.l(iso); - oq15_regr(t,iso,regr15,"level") = q15_regr.l(iso,regr15); - oq15_foodtree_kcal_animals(t,iso,kfo_ap,"level") = q15_foodtree_kcal_animals.l(iso,kfo_ap); - oq15_foodtree_kcal_processed(t,iso,kfo_pf,"level") = q15_foodtree_kcal_processed.l(iso,kfo_pf); - oq15_foodtree_kcal_staples(t,iso,kfo_st,"level") = q15_foodtree_kcal_staples.l(iso,kfo_st); - oq15_foodtree_kcal_vegetables(t,iso,"level") = q15_foodtree_kcal_vegetables.l(iso); - ov_dem_food(t,i,kall,"upper") = vm_dem_food.up(i,kall); - ov15_kcal_regr(t,iso,kfo,"upper") = v15_kcal_regr.up(iso,kfo); - ov15_kcal_regr_total(t,iso,"upper") = v15_kcal_regr_total.up(iso); - ov15_demand_regr(t,iso,regr15,"upper") = v15_demand_regr.up(iso,regr15); - ov15_income_pc_real_ppp_iso(t,iso,"upper") = v15_income_pc_real_ppp_iso.up(iso); - ov15_income_balance(t,iso,"upper") = v15_income_balance.up(iso); - ov15_kcal_intake_total_regr(t,iso,"upper") = v15_kcal_intake_total_regr.up(iso); - ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"upper") = v15_regr_overgroups.up(iso,sex,agegroup15,bmi_tree15); - ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"upper") = v15_bmi_shr_regr.up(iso,sex,age,bmi_group15); - ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"upper") = v15_bmi_shr_overgroups.up(iso,sex,agegroup15,bmi_group15); - ov15_objective(t,"upper") = v15_objective.up; - oq15_food_demand(t,i,kfo,"upper") = q15_food_demand.up(i,kfo); - oq15_aim(t,"upper") = q15_aim.up; - oq15_budget(t,iso,"upper") = q15_budget.up(iso); - oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"upper") = q15_regr_bmi_shr.up(iso,sex,agegroup15,bmi_tree15); - oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_verylow.up(iso,sex,agegroup15); - oq15_bmi_shr_low(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_low.up(iso,sex,agegroup15); - oq15_bmi_shr_medium(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_medium.up(iso,sex,agegroup15); - oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_medium_high.up(iso,sex,agegroup15); - oq15_bmi_shr_high(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_high.up(iso,sex,agegroup15); - oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"upper") = q15_bmi_shr_veryhigh.up(iso,sex,agegroup15); - oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"upper") = q15_bmi_shr_agg.up(iso,sex,age,bmi_group15); - oq15_intake(t,iso,"upper") = q15_intake.up(iso); - oq15_regr_kcal(t,iso,"upper") = q15_regr_kcal.up(iso); - oq15_regr(t,iso,regr15,"upper") = q15_regr.up(iso,regr15); - oq15_foodtree_kcal_animals(t,iso,kfo_ap,"upper") = q15_foodtree_kcal_animals.up(iso,kfo_ap); - oq15_foodtree_kcal_processed(t,iso,kfo_pf,"upper") = q15_foodtree_kcal_processed.up(iso,kfo_pf); - oq15_foodtree_kcal_staples(t,iso,kfo_st,"upper") = q15_foodtree_kcal_staples.up(iso,kfo_st); - oq15_foodtree_kcal_vegetables(t,iso,"upper") = q15_foodtree_kcal_vegetables.up(iso); - ov_dem_food(t,i,kall,"lower") = vm_dem_food.lo(i,kall); - ov15_kcal_regr(t,iso,kfo,"lower") = v15_kcal_regr.lo(iso,kfo); - ov15_kcal_regr_total(t,iso,"lower") = v15_kcal_regr_total.lo(iso); - ov15_demand_regr(t,iso,regr15,"lower") = v15_demand_regr.lo(iso,regr15); - ov15_income_pc_real_ppp_iso(t,iso,"lower") = v15_income_pc_real_ppp_iso.lo(iso); - ov15_income_balance(t,iso,"lower") = v15_income_balance.lo(iso); - ov15_kcal_intake_total_regr(t,iso,"lower") = v15_kcal_intake_total_regr.lo(iso); - ov15_regr_overgroups(t,iso,sex,agegroup15,bmi_tree15,"lower") = v15_regr_overgroups.lo(iso,sex,agegroup15,bmi_tree15); - ov15_bmi_shr_regr(t,iso,sex,age,bmi_group15,"lower") = v15_bmi_shr_regr.lo(iso,sex,age,bmi_group15); - ov15_bmi_shr_overgroups(t,iso,sex,agegroup15,bmi_group15,"lower") = v15_bmi_shr_overgroups.lo(iso,sex,agegroup15,bmi_group15); - ov15_objective(t,"lower") = v15_objective.lo; - oq15_food_demand(t,i,kfo,"lower") = q15_food_demand.lo(i,kfo); - oq15_aim(t,"lower") = q15_aim.lo; - oq15_budget(t,iso,"lower") = q15_budget.lo(iso); - oq15_regr_bmi_shr(t,iso,sex,agegroup15,bmi_tree15,"lower") = q15_regr_bmi_shr.lo(iso,sex,agegroup15,bmi_tree15); - oq15_bmi_shr_verylow(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_verylow.lo(iso,sex,agegroup15); - oq15_bmi_shr_low(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_low.lo(iso,sex,agegroup15); - oq15_bmi_shr_medium(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_medium.lo(iso,sex,agegroup15); - oq15_bmi_shr_medium_high(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_medium_high.lo(iso,sex,agegroup15); - oq15_bmi_shr_high(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_high.lo(iso,sex,agegroup15); - oq15_bmi_shr_veryhigh(t,iso,sex,agegroup15,"lower") = q15_bmi_shr_veryhigh.lo(iso,sex,agegroup15); - oq15_bmi_shr_agg(t,iso,sex,age,bmi_group15,"lower") = q15_bmi_shr_agg.lo(iso,sex,age,bmi_group15); - oq15_intake(t,iso,"lower") = q15_intake.lo(iso); - oq15_regr_kcal(t,iso,"lower") = q15_regr_kcal.lo(iso); - oq15_regr(t,iso,regr15,"lower") = q15_regr.lo(iso,regr15); - oq15_foodtree_kcal_animals(t,iso,kfo_ap,"lower") = q15_foodtree_kcal_animals.lo(iso,kfo_ap); - oq15_foodtree_kcal_processed(t,iso,kfo_pf,"lower") = q15_foodtree_kcal_processed.lo(iso,kfo_pf); - oq15_foodtree_kcal_staples(t,iso,kfo_st,"lower") = q15_foodtree_kcal_staples.lo(iso,kfo_st); - oq15_foodtree_kcal_vegetables(t,iso,"lower") = q15_foodtree_kcal_vegetables.lo(iso); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/15_food/anthropometrics_jan18/preloop.gms b/modules/15_food/anthropometrics_jan18/preloop.gms deleted file mode 100644 index 15dad5de06..0000000000 --- a/modules/15_food/anthropometrics_jan18/preloop.gms +++ /dev/null @@ -1,52 +0,0 @@ -*** | (C) 2008-2019 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 - - - i15_dem_intercept(regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","intercept"); - i15_dem_saturation(regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","saturation"); - i15_dem_halfsat(regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","halfsaturation"); - i15_dem_nonsat(regr15) = f15_demand_paras(regr15,"%c15_food_scenario%","non_saturation"); - - i15_bmi_intercept(sex,agegroup15,bmi_tree15) = f15_bmi_shr_paras(sex,agegroup15,bmi_tree15,"intercept"); - 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); - -* calculating growth food for historical period - -loop(t_past, - if (ord(t_past)>3, - p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-3,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-2,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); - Elseif ord(t_past)=3, - p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-2,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-2,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); - Elseif ord(t_past)=2, - p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-1,iso,growth_food15)); - Elseif ord(t_past)=1, - p15_kcal_growth_food(t_past,iso,"10--14") = sum(growth_food15, f15_kcal_pc_iso(t_past-0,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"5--9") = sum(growth_food15, f15_kcal_pc_iso(t_past-0,iso,growth_food15)); - p15_kcal_growth_food(t_past,iso,"0--4") = sum(growth_food15, f15_kcal_pc_iso(t_past-0,iso,growth_food15)); - ); -); - -* initial prices in $US per Kcal -i15_prices_initial_kcal(iso,kfo)$(f15_nutrition_attributes("y1995",kfo,"kcal")>0) = f15_prices_initial(kfo) - / (f15_nutrition_attributes("y1995",kfo,"kcal")*10**6); -p15_prices_kcal(t,iso,kfo)=i15_prices_initial_kcal(iso,kfo); - -p15_lastiteration_delta_income(t,i) = 1; - - -$ifthen "%c15_rumscen%" == "mixed" i15_ruminant_fadeout(t) = (f15_ruminant_fadeout(t,"constant") + f15_ruminant_fadeout(t,"halving2050"))/2; -$else i15_ruminant_fadeout(t) = f15_ruminant_fadeout(t,"%c15_rumscen%"); -$endif diff --git a/modules/15_food/anthropometrics_jan18/presolve.gms b/modules/15_food/anthropometrics_jan18/presolve.gms deleted file mode 100644 index 9f224c36d7..0000000000 --- a/modules/15_food/anthropometrics_jan18/presolve.gms +++ /dev/null @@ -1,326 +0,0 @@ -*** | (C) 2008-2019 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 - - -option nlp = conopt4 - - -*' @code -*' Within the major food groups determined by the regressions -*' (animal calories, empty calories, fruits, vegetable and nut calories as well as staple calories), -*' the relative share of individual products (e.g. eggs within animal calories) -*' is assumed to be constant. An exception is the demand for ruminant meat, -*' which declines in the course of the century at the cost of chicken meat. -*' @stop - -if (sum(sameas(t_past,t),1) = 1, - -*** Calculate the share of individual food products within major food groups, and replace zero shares with regional averages -* First set it to equal shares, just in case there is no population - - - i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) = - sum(iso2, f15_kcal_pc_iso(t,iso2,kfo_ap)*im_pop_iso(t,iso2))/ - ( - sum((kfo_ap2,iso2),(f15_kcal_pc_iso(t,iso2,kfo_ap2)*im_pop_iso(t,iso2))) - +10**(-5) - ); - - i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap)$sum(kfo_ap2,f15_kcal_pc_iso(t,iso,kfo_ap2)>0)= - f15_kcal_pc_iso(t,iso,kfo_ap) / - sum(kfo_ap2,f15_kcal_pc_iso(t,iso,kfo_ap2) -* 10**(-5) required to avoid unlogical division by zero error. - ); - - i15_livestock_kcal_structure_iso(t,iso,kfo_ap) = i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap); - - i15_processed_kcal_structure_iso(t,iso,kfo_pf) = - sum(iso2, f15_kcal_pc_iso(t,iso2,kfo_pf)*im_pop_iso(t,iso2)) / - ( - sum((kfo_pf2,iso2),f15_kcal_pc_iso(t,iso2,kfo_pf2)*im_pop_iso(t,iso2)) - +10**(-5) -* 10**(-5) required to avoid unlogical division by zero error. Ask Jan P - ); - - - i15_processed_kcal_structure_iso(t,iso,kfo_pf)$(sum(kfo_pf2,f15_kcal_pc_iso(t,iso,kfo_pf2))>0) = - f15_kcal_pc_iso(t,iso,kfo_pf) - /sum(kfo_pf2,f15_kcal_pc_iso(t,iso,kfo_pf2)); - - - - i15_staples_kcal_structure_iso(t,iso,kfo_st) = - sum(iso2, f15_kcal_pc_iso(t,iso2,kfo_st)*im_pop_iso(t,iso2)) / - ( - sum((kfo_st2,iso2),f15_kcal_pc_iso(t,iso2,kfo_st2)*im_pop_iso(t,iso2)) - +10**(-5) -* 10**(-5) required to avoid unlogical division by zero error. Ask Jan P - ); - - - i15_staples_kcal_structure_iso(t,iso,kfo_st)$(sum(kfo_st2,f15_kcal_pc_iso(t,iso,kfo_st2))>0) = - f15_kcal_pc_iso(t,iso,kfo_st) - /sum(kfo_st2,f15_kcal_pc_iso(t,iso,kfo_st2)); - - - - else -* Assumptions on future calorie structure within food groups for future projections: - i15_staples_kcal_structure_iso(t,iso,kfo_st) =i15_staples_kcal_structure_iso(t-1,iso,kfo_st); - i15_processed_kcal_structure_iso(t,iso,kfo_pf) =i15_processed_kcal_structure_iso(t-1,iso,kfo_pf); - i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap) = i15_livestock_kcal_structure_iso_raw(t-1,iso,kfo_ap); - i15_livestock_kcal_structure_iso(t,iso,kfo_ap) = i15_livestock_kcal_structure_iso_raw(t,iso,kfo_ap); - i15_livestock_kcal_structure_iso(t,iso,"livst_chick") = - i15_livestock_kcal_structure_iso_raw(t,iso,"livst_chick") - + i15_livestock_kcal_structure_iso_raw(t,iso,"livst_rum") * (1-i15_ruminant_fadeout(t)); - i15_livestock_kcal_structure_iso(t,iso,"livst_rum") = - i15_livestock_kcal_structure_iso_raw(t,iso,"livst_rum") * i15_ruminant_fadeout(t); - - ); - - -*' @code -*' The calculations are executed in the following order: -*' -*' In the beginning of each time step, the body height is estimated based on the diets -*' of the previous 15 years. In case that the time step length exceeds 5 years, -*' the consumption is extrapolated using the last two time steps. -*' Body height is estimated using the consumption of proteins and fats, in our case -*' the foodgroups animal products, pulses and oils. -*' To estimate the body size of underaged (0-14 years), we scale the WHO body height -*' recommendations for underaged with the divergence of the 15-19 year old. -*' The body height estimates are repeated again at the end of the time step to improve -*' the results of the extrapolation for cases where the time step length exceeds 5 years. -*' @stop - -* ###### ANTHROPOMETRIC ESTIMATES -* ### Preliminary calculation of body height and weight based on food availability of last 3 timesteps. -* ### This may diverge from final calculation in the case where timestep length exceeds 5 years -* ### as then the demand depends on the result of MAgPIE. -* ### Calculations are therefore repeated after optimization. - -* Calculations are only made after historical period. Before, we use historical values. - -if (sum(sameas(t_past,t),1) = 1, - - p15_bodyheight(t,iso,sex,age,estimates15) = f15_bodyheight(t,iso,sex,age); - - -else - - p15_bodyheight(t,iso,sex,age,"preliminary") = p15_bodyheight(t-1,iso,sex,age,"final"); - p15_kcal_growth_food(t,iso,underaged15) = p15_kcal_growth_food(t-1,iso,underaged15); - - - - - s15_yeardiff = m_yeardiff(t)/5; -* avoid fake 1yr timestep in 1995 - if(s15_yeardiff<1,s15_yeardiff=1); - - For (s15_count = 1 to s15_yeardiff, - - -* circular move of age by 5 years -* to find out about ++1 search for help on Circular Lag and Lead Operators in Assignments - p15_bodyheight(t,iso,sex,age++1,"preliminary") = p15_bodyheight(t,iso,sex,age,"preliminary"); - -* replace age groups of 18 year old - p15_bodyheight(t,iso,"F","15--19","preliminary") = - 126.4* - (sum(underaged15, - p15_kcal_growth_food(t,iso,underaged15) - )/3)**0.03467 - ; - p15_bodyheight(t,iso,"M","15--19","preliminary") = - 131.8* - (sum(underaged15, - p15_kcal_growth_food(t,iso,underaged15) - )/3)**0.03978 - ; - ); -*adjust body height of kids proportional to over18 population - p15_bodyheight(t,iso,"M","0--4","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/176*92; - p15_bodyheight(t,iso,"M","5--9","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/176*125; - p15_bodyheight(t,iso,"M","10--14","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/176*152; - - p15_bodyheight(t,iso,"F","0--4","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/163*91; - p15_bodyheight(t,iso,"F","5--9","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/163*124; - p15_bodyheight(t,iso,"F","10--14","preliminary")=p15_bodyheight(t,iso,"M","15--19","preliminary")/163*154; - -); - - -*' @code - - - -*### Estimate standardized food requirements -p15_bodyweight(t,iso,sex,age,bmi_group15)= f15_bmi(sex,age,bmi_group15) * (p15_bodyheight(t,iso,sex,age,"preliminary")/100)**2; - -*' Physical activity levels (PAL) relative to the basic metabolic rate (BMR) are -*' estimated based on physical inactivity levels, assuming PALs for sedentary -*' and medium-active populations of 1.53 and 1.76 respectively: -p15_physical_activity_level(t,iso,sex,age)= - im_physical_inactivity(t,iso,sex,age) * 1.53 - +(1-im_physical_inactivity(t,iso,sex,age)) * 1.76 - ; - -p15_intake(t,iso,sex,age,bmi_group15)= - (f15_schofield(sex,age, "intercept") - + f15_schofield(sex,age, "slope")*p15_bodyweight(t,iso,sex,age,bmi_group15)) - * p15_physical_activity_level(t,iso,sex,age); - - -*' Pregnancy and lactation require additional food intake. To account for this, -*' newborns are distributed among reproductive women in a population. This number -*' is then multiplied with the extra energy requirements: -i15_kcal_pregnancy(t,iso)=sum(sex,im_demography(t,iso,sex,"0--4")/5) * ((40/66)*845 + (26/66)*675); - -*' @stop - - - -*###### Estimation of food demand using a first run of the food demand model with unshocked prices. - -*' @code -*' Before MAgPIE is executed, the food demand model is executed, at first -*' without price shocks. -*' @stop - -* demand for non-food products "knf" is set to 0; -vm_dem_food.fx(i,knf)=0; - -*** Food demand model is calculated the first time for the current time step, using standard prices - -p15_iteration_counter(t) =0; - -display "starting demand model for initialisation run...."; - - -* helping the solver by starting from reasonable values -* by setting real income per capita on exogenous gdp per capita -v15_income_pc_real_ppp_iso.lo(iso)=10; -v15_income_pc_real_ppp_iso.fx(iso)=im_gdp_pc_ppp_iso(t,iso); - -solve m15_food_demand USING nlp MAXIMIZING v15_objective ; -p15_modelstat(t) = m15_food_demand.modelstat; - -display "Food Demand Model Initialisation run finished with modelstat "; -display p15_modelstat; -if(( p15_modelstat(t)) > 2 and (p15_modelstat(t) ne 7 ), - m15_food_demand.solprint = 1 - Execute_Unload "fulldata.gdx"; - abort "Food Demand Model became infeasible already during initialisation run. Stop run."; -); - -* releasing real income per capita binding for later runs that include shocks -v15_income_pc_real_ppp_iso.lo(iso)=10; -v15_income_pc_real_ppp_iso.up(iso)=Inf; - -* saving regression outcome for per capita food demand for different foods -p15_kcal_regr(t, iso, kfo)=v15_kcal_regr.l(iso, kfo); - -* 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); - -* deriving calibration values - -*' @code -*' Per capita food demand and BMI shares are calibrated so that historical data -*' are met. For this purpose, the residual between the regression fit and the -*' observation is calculated for the historical period. When the historical period -*' ends, the calibration factor is fixed at the value of the last historical time -*' step. Additionally, a second calibration is required to meet the world totals -*' of FAOSTAT food demand for different foods. While the food demand model estimates -*' the demand for all countries of the world, FAOSTAT only covers a subset of -*' countries. To match FAOSTAT totals, the food demand of countries not included -*' in FAOSTAT is calibrated to zero. As this calibration is done ex-post, food -*' demand estimates can still be used for all countries, but MAgPIE only considers -*' demand from FAOSTAT countries. - -if (sum(sameas(t_past,t),1) = 1, - p15_kcal_calib(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))=0) = 0; - p15_balanceflow_kcal_iso(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))>0) = 0; - p15_kcal_calib(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))>0) = f15_kcal_pc_iso(t,iso,kfo) - v15_kcal_regr.l(iso, kfo); - p15_balanceflow_kcal_iso(t,iso,kfo)$(sum(kfo2,f15_kcal_pc_iso(t,iso,kfo2))=0) = f15_kcal_pc_iso(t,iso,kfo) - v15_kcal_regr.l(iso, kfo); - - p15_kcal_calib_lastcalibyear(iso,kfo) = p15_kcal_calib(t,iso,kfo); - p15_balanceflow_kcal_lastcalibyear(iso,kfo) = p15_balanceflow_kcal_iso(t,iso,kfo); - - i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) = - f15_bmi_shr_past(t,iso,age,sex,bmi_group15) - - v15_bmi_shr_regr.l(iso,sex,age,bmi_group15); - i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15)= - i15_bmi_shr_calib(t,iso,sex,age,bmi_group15); - -else -*' Depending on the scenario switch c15_calibscen, the divergence of the demand from the -*' historical data is kept constant or faded out. - p15_kcal_calib(t,iso,kfo) = p15_kcal_calib_lastcalibyear(iso,kfo) * f15_kcal_calib_fadeout(t,"%c15_calibscen%"); -*' The divergence of the kcal of countries with no FAOSTAT data is kept constant -*' over time. - p15_balanceflow_kcal_iso(t,iso,kfo) = p15_balanceflow_kcal_lastcalibyear(iso,kfo); - -*' Depending on the scenario switch c15_calibscen, the divergence of the BMI shares from the -*' historical data is kept constant over time or faded out. - i15_bmi_shr_calib(t,iso,sex,age,bmi_group15) = - i15_bmi_shr_calib_lastcalibyear(iso,sex,age,bmi_group15) - * f15_kcal_calib_fadeout(t,"%c15_calibscen%"); -); - -*' The calibration factor is added to the regression value. - p15_kcal_pc_iso(t,iso,kfo) = - 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; - -*' The country-level parameter p15_kcal_pc_iso is aggregated to the -*' regional level. After removing estimates from countries that are not included -*' in FAOSTAT, the resulting parameter p15_kcal_pc_calibrated is provided to -*' constraint q15_food_demand in the MAgPIE model, which defines the demand for food. -*' @stop - -* aggregate to regions - p15_kcal_pc(t,i,kfo)$( - sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ) >0 ) = - sum(i_to_iso(i,iso), - p15_kcal_pc_iso(t,iso,kfo) - * im_pop_iso(t,iso) - ) / sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ); - - p15_balanceflow_kcal(t,i,kfo)$( - sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ) >0 ) = - sum(i_to_iso(i,iso), - p15_balanceflow_kcal_iso(t,iso,kfo) - * im_pop_iso(t,iso) - ) / sum(i_to_iso(i,iso), - im_pop_iso(t,iso) - ); - - - 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(iso,kfo)=v15_kcal_regr.l(iso,kfo); - -* Finally, we calibrate countries with zero food demand according to FAOSTAT -* 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; - -*' @code -*' Now, MAgPIE is executed. -*' @stop diff --git a/modules/15_food/anthropometrics_jan18/realization.gms b/modules/15_food/anthropometrics_jan18/realization.gms deleted file mode 100644 index 3ff14c30eb..0000000000 --- a/modules/15_food/anthropometrics_jan18/realization.gms +++ /dev/null @@ -1,43 +0,0 @@ -*** | (C) 2008-2019 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 - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/15_food/anthropometrics_jan18/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/15_food/anthropometrics_jan18/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/15_food/anthropometrics_jan18/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/15_food/anthropometrics_jan18/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/15_food/anthropometrics_jan18/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/15_food/anthropometrics_jan18/presolve.gms" -$Ifi "%phase%" == "intersolve" $include "./modules/15_food/anthropometrics_jan18/intersolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/15_food/anthropometrics_jan18/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### - -*' @description -*' The realization anthropometrics_jan18 -*' uses per capita income and the demography of the -*' world population (including sex and age classes at the country level, -*' which are provided from module [09_drivers]) as drivers. -*' The module estimates food demand on iso-country level taking -*' anthropometric food requirements as well as economic dynamics into account. -*' If flexible demand is activated, the module also uses the shadow prices -*' for agircultural products from the optimization, which are the Lagrange -*' multipliers of the constraint `q15_food_demand`. -*' The module consists of a standalone food demand model, which is executed -*' before MAgPIE starts. In the case of endogenous demand, the module is -*' iterated with MAgPIE. -*' Besides providing the fooduse of agricultural products, the model also -*' provides a number of output indicators, including the BMI distribution, -*' body weight and height of the population by age and sex, food intake by -*' age group and sex, food waste, dietary composition between livestock products, -*' empty calories (sugar, oil and alcohol), fruits vegetables and nuts, as well -*' as staple calories. -*' The food demand model can be run in standalone mode by running the -*' the file `standalone/demand_model.gms`. -*' The model is described in [@bodirsky_starved_nodate] -*' -*' @authors Benjamin Leon Bodirsky, Jan Philipp Dietrich - diff --git a/modules/15_food/anthropometrics_jan18/sets.gms b/modules/15_food/anthropometrics_jan18/sets.gms deleted file mode 100644 index 01172e35c8..0000000000 --- a/modules/15_food/anthropometrics_jan18/sets.gms +++ /dev/null @@ -1,146 +0,0 @@ -*** | (C) 2008-2019 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 - underaged15(age) Group of underaged age classes - /0--4,5--9,10--14/ - - adult15(age) Age groups for adult population - / 15--19, - 20--24, 25--29, 30--34, 35--39, - 40--44, 45--49, 50--54, 55--59, - 60--64, 65--69, 70--74, 75--79 - 80--84,85--89,90--94,95--99,100+ / - - working15(adult15) Group of working age population - / 15--19, - 20--24, 25--29, 30--34, 35--39, - 40--44, 45--49, 50--54, 55--59/ - - retired15(adult15) Age group of retired population - /60--64, 65--69, 70--74, 75--79 - 80--84,85--89,90--94,95--99,100+ / - - agegroup15 All age groups - /underaged,working,retired / - - age2_adults15(agegroup15) Adult age group - /working,retired / - - agegroup2age(agegroup15,age) Mapping between age cohort and age - / - underaged . (0--4,5--9,10--14) - working . (15--19, - 20--24, 25--29, 30--34, 35--39, - 40--44, 45--49, 50--54, 55--59) - retired . (60--64, 65--69, 70--74, 75--79 - 80--84,85--89,90--94,95--99,100+ ) - / - - bmi_tree15 Body mass index - /low,lowsplit,mediumsplit,high,highsplit/ - - bmi_group15 Body mass index gradient - /verylow,low,medium,mediumhigh,high,veryhigh/ - - bmi_group_est15(bmi_group15) Body mass index extremes - /verylow,low,mediumhigh,high,veryhigh/ - - age_new_estimated15(age) Estimated ages - /0--4,5--9,10--14,15--19/ - - reproductive(age) Age group of people in the reproductive age - /20--24, 25--29, 30--34, 35--39/ - - estimates15 Preliminary or final result for body height distribution - /preliminary,final/ - - paras_s15 Schofield equation parameters - /slope, intercept/ - - paras_b15 Intake equation parameters - /saturation,halfsaturation,intercept/ - - kfo(kall) All products in the sectoral version - / - tece,maiz,trce,rice_pro,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 - / - - growth_food15(kfo) Food items that are important for body growth regression - / soybean,groundnut,puls_pro,oils, - livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish / - - kst(kfo) Plant-based staple products in the sectoral version - / - tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, - potato,cassav_sp,sugr_cane,sugr_beet, - oils,sugar,molasses,alcohol,brans,scp/ - - - kfo_ap(kfo) Animal food products - / - livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish - / - - kfo_st(kfo) Staple products - / - tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, - potato,cassav_sp,sugr_cane,sugr_beet,molasses,brans,scp/ - - kfo_pf(kfo) Processed foods including oils sugar alcohol - / oils,alcohol,sugar / - - knf(kall) Non-food products in the sectoral version - / - oilpalm,cottn_pro,foddr, pasture, begr, betr, - oilcakes,ethanol,distillers_grain,fibres, - res_cereals, res_fibrous, res_nonfibrous, - wood, woodfuel - / - - nutrition Nutrition attributes - /kcal, protein/ - - par15 Parameters for food module - / intercept,saturation,halfsaturation,non_saturation / -* intercept + saturation give the max value if non-saturation is 1 -* halfsaturation is the gdp until which half of saturation is reached - - regr15 Demand regression types - / overconsumption,livestockshare,processedshare,vegfruitshare / - -*** Scenarios - food_scen15 Food scenarios - / SSP1, SSP2, SSP3, SSP4, SSP5, - SSP1_boundary, SSP2_boundary, SSP3_boundary, - SSP4_boundary, SSP5_boundary, - SSP2_lowcal, SSP2_lowls, SSP2_waste, - ssp2_high_yvonne,ssp2_low_yvonne,ssp2_lowest_yvonne, - history / - - pop_scen15 Population scenarios - / SSP1, SSP2, SSP3, SSP4, SSP5 / - - - calibscen15 Calibration scenarios for balance flow - / constant, fadeout2050 / - - ruminantfadeoutscen15 Scenarios for changed composition of livestock products - / halving2050, constant / -; - -alias(kst,kst2); -alias(kfo,kfo2); -alias(kfo_ap,kfo_ap2); -alias(kfo_st,kfo_st2); -alias(kfo_pf,kfo_pf2); -alias(iso,iso2); -alias(reproductive,reproductive2); diff --git a/modules/15_food/input/files b/modules/15_food/input/files index d4cb6976bd..76edb0d3b5 100644 --- a/modules/15_food/input/files +++ b/modules/15_food/input/files @@ -13,7 +13,18 @@ f15_ruminant_fadeout.csv f15_bodyheight_historical.cs3 f15_schofield_parameters.cs3 f15_schofield_parameters_height.cs3 -f15_intake_regression_parameters.cs3 f15_household_balanceflow.cs3 f15_nutrition_attributes.cs3 - +f15_calib_factor_FAOfsupply.cs4 +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.cs3 +f15_ruminant_fadeout_india.csv +f15_milk_fadeout_india.csv +f15_bodyheight_regr_paras.cs3 +f15_intake_NIN_iso.cs3 +f15_markup_coef.csv +f15_fafh_coef.csv diff --git a/modules/15_food/module.gms b/modules/15_food/module.gms index e913af1e0c..daa818e243 100644 --- a/modules/15_food/module.gms +++ b/modules/15_food/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,10 +7,19 @@ *' @title Food demand *' -*' @description The main function of the food demand module is to forecast -*' the food demand from agricultural products, which is used in the module [16_demand]. -*' @authors Benjamin Leon Bodirsky, Jan Philipp Dietrich +*' @description The food demand module forecasts the food demand vm_dem_food for +*' various agricultural products, which is used in the module [16_demand]. +*' Drivers of food demand are population, income, and demographic structure from +*' module [09_drivers], as well as module-specific scenario assumptions. +*' In the case of elastic demand, the model uses the shadow price of +*' agricultural commodities q15_food_demand.m to change food demand and iterates +*' with MAgPIE until a common solution is found. Outputs include next to food +*' demand also projections of anthropometric parameters such as body height and +*' weight distribution, as well as phyiscal activity levels. In addition, this +*' module also provides information about nutrition attributes of foods that can +*' be used in other modules via the interface fm_nutrition_attributes. +*' @authors Benjamin Leon Bodirsky, Isabelle Weindl, Jan Philipp Dietrich *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%food%" == "anthropometrics_jan18" $include "./modules/15_food/anthropometrics_jan18/realization.gms" +$Ifi "%food%" == "anthro_iso_jun22" $include "./modules/15_food/anthro_iso_jun22/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/16_demand/module.gms b/modules/16_demand/module.gms index 7301287bcb..a0a2176784 100644 --- a/modules/16_demand/module.gms +++ b/modules/16_demand/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/16_demand/sector_may15/declarations.gms b/modules/16_demand/sector_may15/declarations.gms index 2ffea3dffb..fe5eb1de8e 100644 --- a/modules/16_demand/sector_may15/declarations.gms +++ b/modules/16_demand/sector_may15/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -21,19 +21,21 @@ q16_supply_residues(i,kres) Supply balance of crop residues (mio. tDM per y q16_supply_pasture(i) Supply balance of pasture (mio. tDM per yr) q16_waste_demand(i,kall) Waste generation (mio. tDM per yr) q16_seed_demand(i,kcr) Seed demand (mio. tDM per yr) +q16_supply_forestry(i,kforestry) Forestry demand (mio. tDM per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_supply(t,i,kall,type) Regional demand (mio. tDM per yr) - ov16_dem_waste(t,i,kall,type) Demand for waste (mio. tDM per yr) - ov_dem_seed(t,i,kall,type) Demand for seed (mio. tDM per yr) - oq16_supply_crops(t,i,kcr,type) Supply balance of crops (mio. tDM per yr) - oq16_supply_livestock(t,i,kap,type) Supply balance of livestock (mio. tDM per yr) - oq16_supply_secondary(t,i,ksd,type) Supply balance of secondary products (mio. tDM per yr) - oq16_supply_residues(t,i,kres,type) Supply balance of crop residues (mio. tDM per yr) - oq16_supply_pasture(t,i,type) Supply balance of pasture (mio. tDM per yr) - oq16_waste_demand(t,i,kall,type) Waste generation (mio. tDM per yr) - oq16_seed_demand(t,i,kcr,type) Seed demand (mio. tDM per yr) + ov_supply(t,i,kall,type) Regional demand (mio. tDM per yr) + ov16_dem_waste(t,i,kall,type) Demand for waste (mio. tDM per yr) + ov_dem_seed(t,i,kall,type) Demand for seed (mio. tDM per yr) + oq16_supply_crops(t,i,kcr,type) Supply balance of crops (mio. tDM per yr) + oq16_supply_livestock(t,i,kap,type) Supply balance of livestock (mio. tDM per yr) + oq16_supply_secondary(t,i,ksd,type) Supply balance of secondary products (mio. tDM per yr) + oq16_supply_residues(t,i,kres,type) Supply balance of crop residues (mio. tDM per yr) + oq16_supply_pasture(t,i,type) Supply balance of pasture (mio. tDM per yr) + oq16_waste_demand(t,i,kall,type) Waste generation (mio. tDM per yr) + oq16_seed_demand(t,i,kcr,type) Seed demand (mio. tDM per yr) + oq16_supply_forestry(t,i,kforestry,type) Forestry demand (mio. tDM per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/16_demand/sector_may15/equations.gms b/modules/16_demand/sector_may15/equations.gms index a009ae43ba..fe74e32cda 100644 --- a/modules/16_demand/sector_may15/equations.gms +++ b/modules/16_demand/sector_may15/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -77,3 +77,12 @@ q16_waste_demand(i2,kall) .. q16_seed_demand(i2,kcr) .. vm_dem_seed(i2,kcr) =e= vm_prod_reg(i2,kcr) * sum(ct,f16_seed_shr(ct,i2,kcr)); + +*' Timber demand is calculated based on population and income. End use product +*' demand is aggregated to timber products of first processing stage i.e., wood +*' and wood fuel. + +q16_supply_forestry(i2,kforestry) .. vm_supply(i2,kforestry) + =e= + vm_dem_material(i2,kforestry) + ; diff --git a/modules/16_demand/sector_may15/input.gms b/modules/16_demand/sector_may15/input.gms index 8df554f5a6..6951e6db95 100644 --- a/modules/16_demand/sector_may15/input.gms +++ b/modules/16_demand/sector_may15/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -17,7 +17,7 @@ $ondelim $include "./modules/16_demand/sector_may15/input/f16_waste_shr.csv" $offdelim; -table fm_attributes(attributes,kall) Conversion factors - where X is ton N P K C DM WM or PJ GE (X per tDM) +table fm_attributes(attributes,kall) Conversion factors - where X is ton N P K C DM WM or GJ GE (X per tDM) $ondelim $include "./modules/16_demand/sector_may15/input/fm_attributes.cs3" $offdelim; diff --git a/modules/16_demand/sector_may15/not_used.txt b/modules/16_demand/sector_may15/not_used.txt deleted file mode 100644 index 4b81dfbae2..0000000000 --- a/modules/16_demand/sector_may15/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason diff --git a/modules/16_demand/sector_may15/postsolve.gms b/modules/16_demand/sector_may15/postsolve.gms index 2626436760..528c9eb840 100644 --- a/modules/16_demand/sector_may15/postsolve.gms +++ b/modules/16_demand/sector_may15/postsolve.gms @@ -1,52 +1,53 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 - - *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_supply(t,i,kall,"marginal") = vm_supply.m(i,kall); - ov16_dem_waste(t,i,kall,"marginal") = v16_dem_waste.m(i,kall); - ov_dem_seed(t,i,kall,"marginal") = vm_dem_seed.m(i,kall); - oq16_supply_crops(t,i,kcr,"marginal") = q16_supply_crops.m(i,kcr); - oq16_supply_livestock(t,i,kap,"marginal") = q16_supply_livestock.m(i,kap); - oq16_supply_secondary(t,i,ksd,"marginal") = q16_supply_secondary.m(i,ksd); - oq16_supply_residues(t,i,kres,"marginal") = q16_supply_residues.m(i,kres); - oq16_supply_pasture(t,i,"marginal") = q16_supply_pasture.m(i); - oq16_waste_demand(t,i,kall,"marginal") = q16_waste_demand.m(i,kall); - oq16_seed_demand(t,i,kcr,"marginal") = q16_seed_demand.m(i,kcr); - ov_supply(t,i,kall,"level") = vm_supply.l(i,kall); - ov16_dem_waste(t,i,kall,"level") = v16_dem_waste.l(i,kall); - ov_dem_seed(t,i,kall,"level") = vm_dem_seed.l(i,kall); - oq16_supply_crops(t,i,kcr,"level") = q16_supply_crops.l(i,kcr); - oq16_supply_livestock(t,i,kap,"level") = q16_supply_livestock.l(i,kap); - oq16_supply_secondary(t,i,ksd,"level") = q16_supply_secondary.l(i,ksd); - oq16_supply_residues(t,i,kres,"level") = q16_supply_residues.l(i,kres); - oq16_supply_pasture(t,i,"level") = q16_supply_pasture.l(i); - oq16_waste_demand(t,i,kall,"level") = q16_waste_demand.l(i,kall); - oq16_seed_demand(t,i,kcr,"level") = q16_seed_demand.l(i,kcr); - ov_supply(t,i,kall,"upper") = vm_supply.up(i,kall); - ov16_dem_waste(t,i,kall,"upper") = v16_dem_waste.up(i,kall); - ov_dem_seed(t,i,kall,"upper") = vm_dem_seed.up(i,kall); - oq16_supply_crops(t,i,kcr,"upper") = q16_supply_crops.up(i,kcr); - oq16_supply_livestock(t,i,kap,"upper") = q16_supply_livestock.up(i,kap); - oq16_supply_secondary(t,i,ksd,"upper") = q16_supply_secondary.up(i,ksd); - oq16_supply_residues(t,i,kres,"upper") = q16_supply_residues.up(i,kres); - oq16_supply_pasture(t,i,"upper") = q16_supply_pasture.up(i); - oq16_waste_demand(t,i,kall,"upper") = q16_waste_demand.up(i,kall); - oq16_seed_demand(t,i,kcr,"upper") = q16_seed_demand.up(i,kcr); - ov_supply(t,i,kall,"lower") = vm_supply.lo(i,kall); - ov16_dem_waste(t,i,kall,"lower") = v16_dem_waste.lo(i,kall); - ov_dem_seed(t,i,kall,"lower") = vm_dem_seed.lo(i,kall); - oq16_supply_crops(t,i,kcr,"lower") = q16_supply_crops.lo(i,kcr); - oq16_supply_livestock(t,i,kap,"lower") = q16_supply_livestock.lo(i,kap); - oq16_supply_secondary(t,i,ksd,"lower") = q16_supply_secondary.lo(i,ksd); - oq16_supply_residues(t,i,kres,"lower") = q16_supply_residues.lo(i,kres); - oq16_supply_pasture(t,i,"lower") = q16_supply_pasture.lo(i); - oq16_waste_demand(t,i,kall,"lower") = q16_waste_demand.lo(i,kall); - oq16_seed_demand(t,i,kcr,"lower") = q16_seed_demand.lo(i,kcr); + ov_supply(t,i,kall,"marginal") = vm_supply.m(i,kall); + ov16_dem_waste(t,i,kall,"marginal") = v16_dem_waste.m(i,kall); + ov_dem_seed(t,i,kall,"marginal") = vm_dem_seed.m(i,kall); + oq16_supply_crops(t,i,kcr,"marginal") = q16_supply_crops.m(i,kcr); + oq16_supply_livestock(t,i,kap,"marginal") = q16_supply_livestock.m(i,kap); + oq16_supply_secondary(t,i,ksd,"marginal") = q16_supply_secondary.m(i,ksd); + oq16_supply_residues(t,i,kres,"marginal") = q16_supply_residues.m(i,kres); + oq16_supply_pasture(t,i,"marginal") = q16_supply_pasture.m(i); + oq16_waste_demand(t,i,kall,"marginal") = q16_waste_demand.m(i,kall); + oq16_seed_demand(t,i,kcr,"marginal") = q16_seed_demand.m(i,kcr); + oq16_supply_forestry(t,i,kforestry,"marginal") = q16_supply_forestry.m(i,kforestry); + ov_supply(t,i,kall,"level") = vm_supply.l(i,kall); + ov16_dem_waste(t,i,kall,"level") = v16_dem_waste.l(i,kall); + ov_dem_seed(t,i,kall,"level") = vm_dem_seed.l(i,kall); + oq16_supply_crops(t,i,kcr,"level") = q16_supply_crops.l(i,kcr); + oq16_supply_livestock(t,i,kap,"level") = q16_supply_livestock.l(i,kap); + oq16_supply_secondary(t,i,ksd,"level") = q16_supply_secondary.l(i,ksd); + oq16_supply_residues(t,i,kres,"level") = q16_supply_residues.l(i,kres); + oq16_supply_pasture(t,i,"level") = q16_supply_pasture.l(i); + oq16_waste_demand(t,i,kall,"level") = q16_waste_demand.l(i,kall); + oq16_seed_demand(t,i,kcr,"level") = q16_seed_demand.l(i,kcr); + oq16_supply_forestry(t,i,kforestry,"level") = q16_supply_forestry.l(i,kforestry); + ov_supply(t,i,kall,"upper") = vm_supply.up(i,kall); + ov16_dem_waste(t,i,kall,"upper") = v16_dem_waste.up(i,kall); + ov_dem_seed(t,i,kall,"upper") = vm_dem_seed.up(i,kall); + oq16_supply_crops(t,i,kcr,"upper") = q16_supply_crops.up(i,kcr); + oq16_supply_livestock(t,i,kap,"upper") = q16_supply_livestock.up(i,kap); + oq16_supply_secondary(t,i,ksd,"upper") = q16_supply_secondary.up(i,ksd); + oq16_supply_residues(t,i,kres,"upper") = q16_supply_residues.up(i,kres); + oq16_supply_pasture(t,i,"upper") = q16_supply_pasture.up(i); + oq16_waste_demand(t,i,kall,"upper") = q16_waste_demand.up(i,kall); + oq16_seed_demand(t,i,kcr,"upper") = q16_seed_demand.up(i,kcr); + oq16_supply_forestry(t,i,kforestry,"upper") = q16_supply_forestry.up(i,kforestry); + ov_supply(t,i,kall,"lower") = vm_supply.lo(i,kall); + ov16_dem_waste(t,i,kall,"lower") = v16_dem_waste.lo(i,kall); + ov_dem_seed(t,i,kall,"lower") = vm_dem_seed.lo(i,kall); + oq16_supply_crops(t,i,kcr,"lower") = q16_supply_crops.lo(i,kcr); + oq16_supply_livestock(t,i,kap,"lower") = q16_supply_livestock.lo(i,kap); + oq16_supply_secondary(t,i,ksd,"lower") = q16_supply_secondary.lo(i,ksd); + oq16_supply_residues(t,i,kres,"lower") = q16_supply_residues.lo(i,kres); + oq16_supply_pasture(t,i,"lower") = q16_supply_pasture.lo(i); + oq16_waste_demand(t,i,kall,"lower") = q16_waste_demand.lo(i,kall); + oq16_seed_demand(t,i,kcr,"lower") = q16_seed_demand.lo(i,kcr); + oq16_supply_forestry(t,i,kforestry,"lower") = q16_supply_forestry.lo(i,kforestry); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/16_demand/sector_may15/realization.gms b/modules/16_demand/sector_may15/realization.gms index 6a9a5726be..4e9f8584d9 100644 --- a/modules/16_demand/sector_may15/realization.gms +++ b/modules/16_demand/sector_may15/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/16_demand/sector_may15/sets.gms b/modules/16_demand/sector_may15/sets.gms index ff92c9749c..580c7326c6 100644 --- a/modules/16_demand/sector_may15/sets.gms +++ b/modules/16_demand/sector_may15/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -13,12 +13,6 @@ sets kres(kall) Residues / res_cereals, res_fibrous, res_nonfibrous / - k(kall) Primary products - / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - foddr, pasture, cottn_pro, begr, betr, livst_rum, livst_pig, - livst_chick, livst_egg, livst_milk, fish / - kap(k) Animal products / livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish @@ -27,15 +21,13 @@ sets kli(kap) Livestock products / livst_rum, livst_pig, livst_chick, livst_egg, livst_milk / - kve(k) Land-use activities - / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - foddr, pasture, cottn_pro, begr, betr / + kli_rd(kap) Ruminant meat and dairy products + / livst_rum,livst_milk / + + kforestry(k) forestry products + / wood, woodfuel / - kcr(kve) Cropping activities - / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - foddr, cottn_pro, begr, betr / ; alias(kap,kap4); +alias(kforestry,kforestry2); diff --git a/modules/17_production/flexreg_apr16/declarations.gms b/modules/17_production/flexreg_apr16/declarations.gms index 2e7b4f3e03..cc25e400f0 100644 --- a/modules/17_production/flexreg_apr16/declarations.gms +++ b/modules/17_production/flexreg_apr16/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -14,6 +14,10 @@ equations q17_prod_reg(i,k) Regional production (mio. tDM per yr) ; +parameters +pm_prod_init(j,kcr) Production initialization for year 1995 (tDM per yr) +; + *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_prod(t,j,k,type) Production in each cell (mio. tDM per yr) @@ -21,4 +25,3 @@ parameters oq17_prod_reg(t,i,k,type) Regional production (mio. tDM per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - diff --git a/modules/17_production/flexreg_apr16/equations.gms b/modules/17_production/flexreg_apr16/equations.gms index 98e8cbad1d..92ae5c9bd6 100644 --- a/modules/17_production/flexreg_apr16/equations.gms +++ b/modules/17_production/flexreg_apr16/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/17_production/flexreg_apr16/input.gms b/modules/17_production/flexreg_apr16/input.gms new file mode 100644 index 0000000000..5843f5d4bd --- /dev/null +++ b/modules/17_production/flexreg_apr16/input.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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 + +$setglobal c17_prod_init on diff --git a/modules/17_production/flexreg_apr16/postsolve.gms b/modules/17_production/flexreg_apr16/postsolve.gms index a0d0bc3b79..2c21b353f6 100644 --- a/modules/17_production/flexreg_apr16/postsolve.gms +++ b/modules/17_production/flexreg_apr16/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/17_production/flexreg_apr16/presolve.gms b/modules/17_production/flexreg_apr16/presolve.gms new file mode 100644 index 0000000000..7a02f3b8bd --- /dev/null +++ b/modules/17_production/flexreg_apr16/presolve.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2025 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 + + + +pm_prod_init(j,kcr)=sum(w,fm_croparea("y1995",j,w,kcr)*pm_yields_semi_calib(j,kcr,w)); + +if (ord(t) = 1, + +$ifthen "%c17_prod_init%" == "on" +vm_prod.l(j,kcr) = pm_prod_init(j,kcr); +$endif + + ); diff --git a/modules/17_production/flexreg_apr16/realization.gms b/modules/17_production/flexreg_apr16/realization.gms index 11cd1fc160..a9043c300d 100644 --- a/modules/17_production/flexreg_apr16/realization.gms +++ b/modules/17_production/flexreg_apr16/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -16,6 +16,8 @@ *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "declarations" $include "./modules/17_production/flexreg_apr16/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/17_production/flexreg_apr16/input.gms" $Ifi "%phase%" == "equations" $include "./modules/17_production/flexreg_apr16/equations.gms" +$Ifi "%phase%" == "presolve" $include "./modules/17_production/flexreg_apr16/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/17_production/flexreg_apr16/postsolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/17_production/module.gms b/modules/17_production/module.gms index 8835abf9b9..98acf234bd 100644 --- a/modules/17_production/module.gms +++ b/modules/17_production/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/18_residues/flexcluster_jul23/declarations.gms b/modules/18_residues/flexcluster_jul23/declarations.gms new file mode 100644 index 0000000000..ab53bb9b53 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/declarations.gms @@ -0,0 +1,76 @@ +*** | (C) 2008-2025 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 + + +positive variables + v18_prod_res(j,kres) Cluster-level production of residues (mio. tDM) + v18_res_biomass_ag_clust(j,kcr) Production of aboveground residues in each cluster (mio. tDM) + vm_res_biomass_ag(i,kcr,attributes) Production of aboveground residues in each region (mio. tDM) + vm_res_biomass_bg(i,kcr,dm_nr) Production of belowground residues in each region (mio. tDM) + + v18_res_ag_removal(j,kcr,attributes) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + v18_res_ag_removal_reg(i,kcr,attributes) Regional removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + v18_res_ag_recycling(i,kcr,attributes) Recycling of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX) + vm_res_ag_burn(i,kcr,attributes) Regional residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + + vm_res_recycling(i,npk) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX) + vm_cost_prod_kres(i,kres) Production costs of harvesting crop residues (mio. USD17MER per yr) +; + +equations + + q18_prod_res_ag_clust(j,kcr) Cluster-level production constraint of aboveground residues (mio. tDM) + q18_prod_res_ag_reg(i,kcr,attributes) Regional production constraint of aboveground residues (mio. tDM) + + q18_prod_res_bg_clust(i,kcr,dm_nr) Cluster-level production constraint of belowground residues (mio. tDM) + + q18_regional_removals(i,kcr,attributes) Calculation of regional level removals (mio. tX) + q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM) + q18_clust_field_constraint(j,kres) Make sure the amount removed in any cluster does not exceed the amount available (mio. tDM) + q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) + q18_translate(j,kres,attributes) Transformation of the multiple crop residues into supply balance crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + + q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr) + q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX) + q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD17MER) + + q18_prod_res_reg(i,kall) Regional production of residues (mio. tDM) + +; + +parameters + i18_res_use_burn(t_all,dev18,kcr) Share of residues burned on field (1) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov18_prod_res(t,j,kres,type) Cluster-level production of residues (mio. tDM) + ov18_res_biomass_ag_clust(t,j,kcr,type) Production of aboveground residues in each cluster (mio. tDM) + ov_res_biomass_ag(t,i,kcr,attributes,type) Production of aboveground residues in each region (mio. tDM) + ov_res_biomass_bg(t,i,kcr,dm_nr,type) Production of belowground residues in each region (mio. tDM) + ov18_res_ag_removal(t,j,kcr,attributes,type) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov18_res_ag_removal_reg(t,i,kcr,attributes,type) Regional removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov18_res_ag_recycling(t,i,kcr,attributes,type) Recycling of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov_res_ag_burn(t,i,kcr,attributes,type) Regional residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov_res_recycling(t,i,npk,type) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX) + ov_cost_prod_kres(t,i,kres,type) Production costs of harvesting crop residues (mio. USD17MER per yr) + oq18_prod_res_ag_clust(t,j,kcr,type) Cluster-level production constraint of aboveground residues (mio. tDM) + oq18_prod_res_ag_reg(t,i,kcr,attributes,type) Regional production constraint of aboveground residues (mio. tDM) + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,type) Cluster-level production constraint of belowground residues (mio. tDM) + oq18_regional_removals(t,i,kcr,attributes,type) Calculation of regional level removals (mio. tX) + oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) + oq18_clust_field_constraint(t,j,kres,type) Make sure the amount removed in any cluster does not exceed the amount available (mio. tDM) + oq18_res_field_burn(t,i,kcr,attributes,type) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) + oq18_translate(t,j,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + oq18_res_recycling_nr(t,i,type) Nutrient recycling of reaactive nitrogen (mio. tNr) + oq18_res_recycling_pk(t,i,pk18,type) Nutrient recycling of phosphorus and potash (mio. tX) + oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD17MER) + oq18_prod_res_reg(t,i,kall,type) Regional production of residues (mio. tDM) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + +*** EOF declarations.gms *** diff --git a/modules/18_residues/flexcluster_jul23/equations.gms b/modules/18_residues/flexcluster_jul23/equations.gms new file mode 100644 index 0000000000..1a99e73d49 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/equations.gms @@ -0,0 +1,145 @@ +*** | (C) 2008-2025 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 + +*' The AG crop residue biomass `vm_res_biomass_ag` is calculated as a function +*' of harvested area `vm_area` and production `vm_prod_reg`. `f18_cgf` contains +*' slope and intercept parameters of the CGFs. + + q18_prod_res_ag_clust(j2,kcr) .. + v18_res_biomass_ag_clust(j2,kcr) + =e= + (sum(w, vm_area(j2,kcr,w)) * sum((ct, cell(i2,j2)), f18_multicropping(ct,i2)) * f18_cgf("intercept",kcr) + + vm_prod(j2,kcr) * f18_cgf("slope",kcr)); + + q18_prod_res_ag_reg(i2,kcr,attributes) .. + vm_res_biomass_ag(i2,kcr,attributes) + =e= + sum(cell(i2,j2), v18_res_biomass_ag_clust(j2,kcr)) + * f18_attributes_residue_ag(attributes,kcr); + +*' The BG crop residue biomass `vm_res_biomass_bg` is calculated as a function of +*' total aboveground biomass. + + q18_prod_res_bg_clust(i2,kcr,dm_nr) .. + vm_res_biomass_bg(i2,kcr,dm_nr) + =e= + (vm_prod_reg(i2,kcr) + vm_res_biomass_ag(i2,kcr,"dm")) * f18_cgf("bg_to_ag",kcr) + * f18_attributes_residue_bg(dm_nr,kcr); + +*' Variable of removals at regional level needs to be greater than +*' the regionally-summed cluster-level variable. This is not an equal-to +*' for run-time considerations, but should be noted if regional removals +*' vm_res_biomass_ag are to be incentivised. + + q18_regional_removals(i2,kcr,attributes) .. + sum(cell(i2,j2), v18_res_ag_removal(j2,kcr,attributes)) + =e= + v18_res_ag_removal_reg(i2,kcr,attributes); + + +*' In contrast to AG biomass, AG production `vm_res_biomass_ag(i,kcr,attributes)` +*' is defined as the part of residues which is removed from the field. The +*' difference between biomass and production is either burned on field or +*' remains on the fields (either incorporated in soils or not) and decays. +*' The field balance equations ensures that the production of AG residues +*' `vm_res_biomass_ag(i,kcr,attributes)` is properly assigned to different uses: +*' removal, on-field burning and recycling of AG residues. + + q18_res_field_balance(i2,kcr,attributes) .. + vm_res_biomass_ag(i2,kcr,attributes) + =e= + v18_res_ag_removal_reg(i2,kcr,attributes) + + vm_res_ag_burn(i2,kcr,attributes) + + v18_res_ag_recycling(i2,kcr,attributes); + +*' make sure removal is less than biomass produced in each cluster + q18_clust_field_constraint(j2,kres) .. + sum(kres_kcr(kres,kcr), v18_res_biomass_ag_clust(j2,kcr)) + =g= + v18_prod_res(j2, kres); + +*' The amount of residues burned on fields in a region `vm_res_ag_burn` is +*' determined by the share (ic18_res_use_min_shr) of AG residue biomass. +*' Based on @smil_nitrogen_1999, residue burning is fixed to 15% of total AG +*' crop residue dry matter in developed and 25% in developing regions for each +*' crop. For future time steps, these rates are scenario dependent, and either +*' kept constant or reduced to 10% and 0% in 2050. + + q18_res_field_burn(i2,kcr,attributes) .. + vm_res_ag_burn(i2,kcr,attributes) + =e= + sum(ct, im_development_state(ct,i2) * i18_res_use_burn(ct,"high_income",kcr) + + (1-im_development_state(ct,i2)) * i18_res_use_burn(ct,"low_income",kcr)) + * vm_res_biomass_ag(i2,kcr,attributes); + + +*' While the residue biomass is estimated with a crop-specific nutrient +*' composition (which is required for consistent nutrient budgets), the +*' removed residues are assumed to have homogeneous properties +*' (to reduce the number of commodities in MAgPIE) within three crop residue +*' groups (cereal straw, fibrous residues that cannot be digested +*' by monogastrics, and non-fibrous residues that can be digested). +*' The following constraint, in combination with the field balance equation, +*' guarantees that mass balances are not violated while a homogeneous +*' good is extracted from heterogeneous goods. + + q18_translate(j2,kres,attributes).. + sum(kres_kcr(kres,kcr), v18_res_ag_removal(j2,kcr,attributes)) + =e= + v18_prod_res(j2,kres) * fm_attributes(attributes,kres); + +*' sum to the regional amount of residues produced for the regional interface + q18_prod_res_reg(i2,kres).. + vm_prod_reg(i2,kres) + =e= + sum(cell(i2,j2), v18_prod_res(j2,kres)) ; + + +*' Residues recycled to croplands in nutrients `vm_res_recycling(i2,"nr")` are +*' calculated based on the amount of AG residues left on field for recycling, the +*' nutrients coming from burned residues, and on biomass that is left in +*' BG residues. They are calculated to be transmitted to the nitrogen budget +*' module [50_nr_soil_budget]. + + q18_res_recycling_nr(i2) .. + vm_res_recycling(i2,"nr") + =e= + sum(kcr, v18_res_ag_recycling(i2,kcr,"nr") + + vm_res_ag_burn(i2,kcr,"nr")*(1-f18_res_combust_eff(kcr)) + + vm_res_biomass_bg(i2,kcr,"nr") + ); + +*' Similar to the recycled nutrients, the potash recycling is determined by the +*' amount of AG residues with the potash content and the amounts of potash from +*' burning residues. As P and K are not volatile and hardly water soluble, only +*' removed aboveground crop residues have to be considered, while nutrients from +*' burned AG as well as BG stay on the field. + + q18_res_recycling_pk(i2,pk18) .. + vm_res_recycling(i2,pk18) + =e= + sum(kcr, + v18_res_ag_recycling(i2,kcr,pk18) + + vm_res_ag_burn(i2,kcr,pk18) + ); + +*' Costs of residue harvest are based on straw baling and hauling from +*' Budynski, Stephanie. 2020. Straw Manufacturing in Alberta (@budynski_straw_2020), +*' using the lower range of the US costs. + + q18_cost_prod_res(i2,kres) .. + vm_cost_prod_kres(i2,kres) + =e= + vm_prod_reg(i2,kres) * fm_attributes("wm",kres) * f18_fac_req_kres(kres); + +*' Trade of AG residues is not considered, so that all produced AG residues have +*' to be assigned to uses within the respective world region. + + +*** EOF constraints.gms *** diff --git a/modules/18_residues/flexcluster_jul23/input.gms b/modules/18_residues/flexcluster_jul23/input.gms new file mode 100644 index 0000000000..0e2ed9f46e --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/input.gms @@ -0,0 +1,51 @@ +*** | (C) 2008-2025 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 + +$setglobal c18_burn_scen phaseout +* options: phaseout,constant + +table f18_multicropping(t_all,i) Multicropping indicator as ratio of area harvested by physical area (1) +$ondelim +$include "./modules/18_residues/input/f18_multicropping.csv" +$offdelim; + +table f18_attributes_residue_ag(attributes,kve) Nutrient content of aboveground crop residues in respective attribute units DM GJ Nr P K WM C (X per DM) +$ondelim +$include "./modules/18_residues/input/f18_attributes_residue_ag.csv" +$offdelim; + + +table f18_attributes_residue_bg(dm_nr,kve) Nutrient content of belowground crop residues in reactive nitorgen and carbon units Nr C (X per DM) +$ondelim +$include "./modules/18_residues/input/f18_attributes_residue_bg.csv" +$offdelim; + +table f18_cgf(cgf,kve) Crop growth functions for all vegetation types containing slope intercept and belowground to aboveground ratio (1) +$ondelim +$include "./modules/18_residues/flexcluster_jul23/input/f18_cgf.csv" +$offdelim; + +table f18_res_use_burn(t_all,burn_scen18,dev18,kcr) Minimum and maximum burn share use for residues developing over time (1) +$ondelim +$include "./modules/18_residues/flexcluster_jul23/input/f18_res_use_burn.cs3" +$offdelim; + +parameter f18_res_combust_eff(kve) Combustion efficiency of residue burning (1) +/ +$ondelim +$include "./modules/18_residues/input/f18_res_combust_eff.cs4" +$offdelim +/; + +parameter f18_fac_req_kres(kres) Factor requirements (USD17MER per tDM) +/ +$ondelim +$include "./modules/18_residues/flexcluster_jul23/input/f18_fac_req_kres.csv" +$offdelim +/; + +*** EOF input.gms *** diff --git a/modules/18_residues/flexcluster_jul23/input/files b/modules/18_residues/flexcluster_jul23/input/files new file mode 100644 index 0000000000..45135c7cef --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/input/files @@ -0,0 +1,4 @@ +* list of files that are required here +f18_cgf.csv +f18_res_use_burn.cs3 +f18_fac_req_kres.csv diff --git a/modules/18_residues/flexcluster_jul23/postsolve.gms b/modules/18_residues/flexcluster_jul23/postsolve.gms new file mode 100644 index 0000000000..3593595ada --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/postsolve.gms @@ -0,0 +1,102 @@ +*** | (C) 2008-2025 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 + +****** Residues + +*** EOF postsolve.gms *** + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov18_prod_res(t,j,kres,"marginal") = v18_prod_res.m(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"marginal") = v18_res_biomass_ag_clust.m(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"marginal") = vm_res_biomass_ag.m(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"marginal") = vm_res_biomass_bg.m(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"marginal") = v18_res_ag_removal.m(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"marginal") = v18_res_ag_removal_reg.m(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"marginal") = v18_res_ag_recycling.m(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"marginal") = vm_res_ag_burn.m(i,kcr,attributes); + ov_res_recycling(t,i,npk,"marginal") = vm_res_recycling.m(i,npk); + ov_cost_prod_kres(t,i,kres,"marginal") = vm_cost_prod_kres.m(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"marginal") = q18_prod_res_ag_clust.m(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"marginal") = q18_prod_res_ag_reg.m(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"marginal") = q18_prod_res_bg_clust.m(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"marginal") = q18_regional_removals.m(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"marginal") = q18_res_field_balance.m(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"marginal") = q18_clust_field_constraint.m(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"marginal") = q18_res_field_burn.m(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"marginal") = q18_translate.m(j,kres,attributes); + oq18_res_recycling_nr(t,i,"marginal") = q18_res_recycling_nr.m(i); + oq18_res_recycling_pk(t,i,pk18,"marginal") = q18_res_recycling_pk.m(i,pk18); + oq18_cost_prod_res(t,i,kres,"marginal") = q18_cost_prod_res.m(i,kres); + oq18_prod_res_reg(t,i,kall,"marginal") = q18_prod_res_reg.m(i,kall); + ov18_prod_res(t,j,kres,"level") = v18_prod_res.l(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"level") = v18_res_biomass_ag_clust.l(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"level") = vm_res_biomass_ag.l(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"level") = vm_res_biomass_bg.l(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"level") = v18_res_ag_removal.l(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"level") = v18_res_ag_removal_reg.l(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"level") = v18_res_ag_recycling.l(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"level") = vm_res_ag_burn.l(i,kcr,attributes); + ov_res_recycling(t,i,npk,"level") = vm_res_recycling.l(i,npk); + ov_cost_prod_kres(t,i,kres,"level") = vm_cost_prod_kres.l(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"level") = q18_prod_res_ag_clust.l(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"level") = q18_prod_res_ag_reg.l(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"level") = q18_prod_res_bg_clust.l(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"level") = q18_regional_removals.l(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"level") = q18_res_field_balance.l(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"level") = q18_clust_field_constraint.l(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"level") = q18_res_field_burn.l(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"level") = q18_translate.l(j,kres,attributes); + oq18_res_recycling_nr(t,i,"level") = q18_res_recycling_nr.l(i); + oq18_res_recycling_pk(t,i,pk18,"level") = q18_res_recycling_pk.l(i,pk18); + oq18_cost_prod_res(t,i,kres,"level") = q18_cost_prod_res.l(i,kres); + oq18_prod_res_reg(t,i,kall,"level") = q18_prod_res_reg.l(i,kall); + ov18_prod_res(t,j,kres,"upper") = v18_prod_res.up(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"upper") = v18_res_biomass_ag_clust.up(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"upper") = vm_res_biomass_ag.up(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"upper") = vm_res_biomass_bg.up(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"upper") = v18_res_ag_removal.up(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"upper") = v18_res_ag_removal_reg.up(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"upper") = v18_res_ag_recycling.up(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"upper") = vm_res_ag_burn.up(i,kcr,attributes); + ov_res_recycling(t,i,npk,"upper") = vm_res_recycling.up(i,npk); + ov_cost_prod_kres(t,i,kres,"upper") = vm_cost_prod_kres.up(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"upper") = q18_prod_res_ag_clust.up(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"upper") = q18_prod_res_ag_reg.up(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"upper") = q18_prod_res_bg_clust.up(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"upper") = q18_regional_removals.up(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"upper") = q18_res_field_balance.up(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"upper") = q18_clust_field_constraint.up(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"upper") = q18_res_field_burn.up(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"upper") = q18_translate.up(j,kres,attributes); + oq18_res_recycling_nr(t,i,"upper") = q18_res_recycling_nr.up(i); + oq18_res_recycling_pk(t,i,pk18,"upper") = q18_res_recycling_pk.up(i,pk18); + oq18_cost_prod_res(t,i,kres,"upper") = q18_cost_prod_res.up(i,kres); + oq18_prod_res_reg(t,i,kall,"upper") = q18_prod_res_reg.up(i,kall); + ov18_prod_res(t,j,kres,"lower") = v18_prod_res.lo(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"lower") = v18_res_biomass_ag_clust.lo(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"lower") = vm_res_biomass_ag.lo(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"lower") = vm_res_biomass_bg.lo(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"lower") = v18_res_ag_removal.lo(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"lower") = v18_res_ag_removal_reg.lo(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"lower") = v18_res_ag_recycling.lo(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"lower") = vm_res_ag_burn.lo(i,kcr,attributes); + ov_res_recycling(t,i,npk,"lower") = vm_res_recycling.lo(i,npk); + ov_cost_prod_kres(t,i,kres,"lower") = vm_cost_prod_kres.lo(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"lower") = q18_prod_res_ag_clust.lo(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"lower") = q18_prod_res_ag_reg.lo(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"lower") = q18_prod_res_bg_clust.lo(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"lower") = q18_regional_removals.lo(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"lower") = q18_res_field_balance.lo(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"lower") = q18_clust_field_constraint.lo(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"lower") = q18_res_field_burn.lo(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"lower") = q18_translate.lo(j,kres,attributes); + oq18_res_recycling_nr(t,i,"lower") = q18_res_recycling_nr.lo(i); + oq18_res_recycling_pk(t,i,pk18,"lower") = q18_res_recycling_pk.lo(i,pk18); + oq18_cost_prod_res(t,i,kres,"lower") = q18_cost_prod_res.lo(i,kres); + oq18_prod_res_reg(t,i,kall,"lower") = q18_prod_res_reg.lo(i,kall); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/18_residues/flexcluster_jul23/preloop.gms b/modules/18_residues/flexcluster_jul23/preloop.gms new file mode 100644 index 0000000000..0cdaa826dc --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/preloop.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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 + + +i18_res_use_burn(t_all,dev18,kcr) = f18_res_use_burn(t_all,"%c18_burn_scen%",dev18,kcr); diff --git a/modules/18_residues/flexcluster_jul23/presolve.gms b/modules/18_residues/flexcluster_jul23/presolve.gms new file mode 100644 index 0000000000..be2459d824 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/presolve.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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 + +v18_res_ag_removal.fx(j,nonused18,attributes)=0; + +*** EOF solve.gms *** diff --git a/modules/18_residues/flexcluster_jul23/realization.gms b/modules/18_residues/flexcluster_jul23/realization.gms new file mode 100644 index 0000000000..084b9ac6b9 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/realization.gms @@ -0,0 +1,42 @@ +*** | (C) 2008-2025 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 As official global statistics exist only for crop production and not for crop +*' residue production, the biomass of residues is obtained in MAgPIE by using +*' crop-type specific plant growth functions based on crop production and area harvested. +*' Plant biomass is divided into three components: the harvested organ as listed +*' in FAO, the aboveground (AG) and the belowground (BG) residues. +*' +*' @ipcc_2006_2006 offers one of the few consistent datasets to estimate +*' both AG and BG residues. Also, by providing crop-growth functions (CGF, `f18_cgf`) +*' instead of fixed harvest indices, it can be used to depict current +*' international differences of harvest indices and their development in the future. +*' The methodology is thus well eligible for global long-term modelling. +*' @ipcc_2006_2006 provides linear CGFs with positive slope and intercept +*' for cereals, leguminous crops, potatoes and grasses. As no values are +*' available for the oilcrops rapeseed, sunflower, oilpalms as well as +*' sugar crops, tropical roots, cotton and others, we use fixed harvest-indices +*' (positive slope without intercept) for these crops based +*' on @wirsenius_human_2000, @lal_world_2005 and @feller_dungung_2007. If different CGFs are available +*' for crops within a crop group, we build a weighted average based on the +*' production in 1995. +*' +*' This realization enforces cluster-level agricultural residue production, based on agricultural production +*' at the same level. However, other uses such as burning and recycling are allowed to be balanced at the +*' regional level, in order to reduce computational complexity. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/18_residues/flexcluster_jul23/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/18_residues/flexcluster_jul23/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/18_residues/flexcluster_jul23/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/18_residues/flexcluster_jul23/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/18_residues/flexcluster_jul23/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/18_residues/flexcluster_jul23/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/18_residues/flexcluster_jul23/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/18_residues/flexcluster_jul23/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/18_residues/flexcluster_jul23/scaling.gms b/modules/18_residues/flexcluster_jul23/scaling.gms new file mode 100644 index 0000000000..a54611a3a1 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_cost_prod_kres.scale(i,kres) = 10e3; diff --git a/modules/18_residues/flexcluster_jul23/sets.gms b/modules/18_residues/flexcluster_jul23/sets.gms new file mode 100644 index 0000000000..0ce45cea6c --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/sets.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2025 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 + +dm_nr(attributes) dry matter and nr +/dm, nr, c/ + +pk18(npk) subset of npk containing P and K nutrients +/p, k/ + +dev18 country development indicator +/high_income,low_income/ + +burn_scen18 scenario for burning residues on field +/constant,phaseout/ + +nonused18(kcr) crops that are not used as residues +/sunflower, oilpalm, foddr, begr, betr/ + +***Feeding groups*** + + kres_kcr(kres,kcr) mapping of crops to different residue types + / res_cereals .(tece,maiz,trce,rice_pro) + res_fibrous .(soybean,rapeseed,groundnut, + puls_pro,sugr_beet,sugr_cane, + cottn_pro) + res_nonfibrous .(potato,cassav_sp,others) + / + + + +; + +*** EOF sets.gms *** diff --git a/modules/18_residues/flexreg_apr16/declarations.gms b/modules/18_residues/flexreg_apr16/declarations.gms index 275fc91cba..b4ce1a141c 100644 --- a/modules/18_residues/flexreg_apr16/declarations.gms +++ b/modules/18_residues/flexreg_apr16/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,27 +7,26 @@ positive variables + v18_prod_res(j,kres) Cellular production of residues (mio. tDM) vm_res_biomass_ag(i,kcr,attributes) Production of aboveground residues in each region (mio. tDM) vm_res_biomass_bg(i,kcr,dm_nr) Production of belowground residues in each region (mio. tDM) v18_res_ag_removal(i,kcr,attributes) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) v18_res_ag_recycling(i,kcr,attributes) Recylcing of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX) - v18_res_ag_burn(i,kcr,attributes) Residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + vm_res_ag_burn(i,kcr,attributes) Residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) vm_res_recycling(i,npk) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX) + vm_cost_prod_kres(i,kres) Production costs of harvesting crop residues (mio. USD17MER per yr) ; equations - q18_prod_res_ag_reg(i,kcr,attributes) Production constraint of aboveground residues (mio. tDM) q18_prod_res_bg_reg(i,kcr,dm_nr) Production constraint of belowground residues (mio. tDM) - q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM) q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) q18_translate(i,kres,attributes) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) - + q18_prod_res_reg(i,kres) Allows for distribution of residues to cellular level (mio. tDM) q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr) q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX) - q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD05MER) - + q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD17MER) ; parameters @@ -36,20 +35,23 @@ parameters *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters + ov18_prod_res(t,j,kres,type) Cellular production of residues (mio. tDM) ov_res_biomass_ag(t,i,kcr,attributes,type) Production of aboveground residues in each region (mio. tDM) ov_res_biomass_bg(t,i,kcr,dm_nr,type) Production of belowground residues in each region (mio. tDM) ov18_res_ag_removal(t,i,kcr,attributes,type) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) ov18_res_ag_recycling(t,i,kcr,attributes,type) Recylcing of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX) - ov18_res_ag_burn(t,i,kcr,attributes,type) Residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov_res_ag_burn(t,i,kcr,attributes,type) Residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) ov_res_recycling(t,i,npk,type) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX) + ov_cost_prod_kres(t,i,kres,type) Production costs of harvesting crop residues (mio. USD17MER per yr) oq18_prod_res_ag_reg(t,i,kcr,attributes,type) Production constraint of aboveground residues (mio. tDM) oq18_prod_res_bg_reg(t,i,kcr,dm_nr,type) Production constraint of belowground residues (mio. tDM) oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) oq18_res_field_burn(t,i,kcr,attributes,type) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) oq18_translate(t,i,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) + oq18_prod_res_reg(t,i,kres,type) Allows for distribution of residues to cellular level (mio. tDM) oq18_res_recycling_nr(t,i,type) Nutrient recycling of reaactive nitrogen (mio. tNr) oq18_res_recycling_pk(t,i,pk18,type) Nutrient recycling of phosphorus and potash (mio. tX) - oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD05MER) + oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD17MER) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/18_residues/flexreg_apr16/equations.gms b/modules/18_residues/flexreg_apr16/equations.gms index 041f621168..7bf6de8aad 100644 --- a/modules/18_residues/flexreg_apr16/equations.gms +++ b/modules/18_residues/flexreg_apr16/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -15,8 +15,8 @@ vm_res_biomass_ag(i2,kcr,attributes) =e= (sum((cell(i2,j2),w), vm_area(j2,kcr,w)) * sum(ct,f18_multicropping(ct,i2)) * f18_cgf("intercept",kcr) - + vm_prod_reg(i2,kcr)*f18_cgf("slope",kcr)) - * f18_attributes_residue_ag(attributes,kcr); + + vm_prod_reg(i2,kcr) * f18_cgf("slope",kcr)) + * f18_attributes_residue_ag(attributes,kcr); *' The BG crop residue biomass `vm_res_biomass_bg` is calculated as a function of *' total aboveground biomass. @@ -24,7 +24,7 @@ q18_prod_res_bg_reg(i2,kcr,dm_nr) .. vm_res_biomass_bg(i2,kcr,dm_nr) =e= - (vm_prod_reg(i2,kcr) + vm_res_biomass_ag(i2,kcr,"dm"))*f18_cgf("bg_to_ag",kcr) + (vm_prod_reg(i2,kcr) + vm_res_biomass_ag(i2,kcr,"dm")) * f18_cgf("bg_to_ag",kcr) * f18_attributes_residue_bg(dm_nr,kcr); *' In contrast to AG biomass, AG production `vm_res_biomass_ag(i,kcr,attributes)` @@ -39,10 +39,10 @@ vm_res_biomass_ag(i2,kcr,attributes) =e= v18_res_ag_removal(i2,kcr,attributes) - + v18_res_ag_burn(i2,kcr,attributes) + + vm_res_ag_burn(i2,kcr,attributes) + v18_res_ag_recycling(i2,kcr,attributes); -*' The amount of residues burned on fields in a region `v18_res_ag_burn` is +*' The amount of residues burned on fields in a region `vm_res_ag_burn` is *' determined by the share (ic18_res_use_min_shr) of AG residue biomass. *' Based on @smil_nitrogen_1999, residue burning is fixed to 15% of total AG *' crop residue dry matter in developed and 25% in developing regions for each @@ -50,7 +50,7 @@ *' kept constant or reduced to 10% and 0% in 2050. q18_res_field_burn(i2,kcr,attributes) .. - v18_res_ag_burn(i2,kcr,attributes) + vm_res_ag_burn(i2,kcr,attributes) =e= sum(ct, im_development_state(ct,i2) * i18_res_use_burn(ct,"high_income",kcr) + (1-im_development_state(ct,i2)) * i18_res_use_burn(ct,"low_income",kcr)) @@ -72,6 +72,15 @@ =e= vm_prod_reg(i2,kres) * fm_attributes(attributes,kres); +*' Amount produced at cellular level is flexible, can be distributed as it wants +*' and is just bound by the regional sum via + + q18_prod_res_reg(i2,kres).. + sum(cell(i2,j2), v18_prod_res(j2,kres)) + =e= + vm_prod_reg(i2,kres); + + *' Residues recycled to croplands in nutrients `vm_res_recycling(i2,"nr")` are *' calcualted based on the amount of AG residues left on field for recycling, the *' nutrients coming from burned residues, and on biomass that is left in @@ -82,7 +91,7 @@ vm_res_recycling(i2,"nr") =e= sum(kcr, v18_res_ag_recycling(i2,kcr,"nr") - + v18_res_ag_burn(i2,kcr,"nr")*(1-f18_res_combust_eff(kcr)) + + vm_res_ag_burn(i2,kcr,"nr")*(1-f18_res_combust_eff(kcr)) + vm_res_biomass_bg(i2,kcr,"nr") ); @@ -97,22 +106,17 @@ =e= sum(kcr, v18_res_ag_recycling(i2,kcr,pk18) - + v18_res_ag_burn(i2,kcr,pk18) + + vm_res_ag_burn(i2,kcr,pk18) ); -*' Costs of residues production are determined as factor costs per ton -*' assuming 15 USD per ton, using the lower range from -*' [this source](hwww1.agric.gov.ab.ca/$Department/deptdocs.nsf/All/faq7514), -*' 10USD baling costs per large round bale plus 2USD pro bale stocking and hauling, -*' 1 large round bale is approximately 500 kg, resulting in 24USD per ton, -*' for developing prices see [here](citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.557.5823&rep=rep1&type=pdf). -*' Tha calcuated factor costs per ton are therefore 24 for `res_cereals`, `res_fibrous` -*' and `res_nonfibrous`. +*' Costs of residue harvest are based on straw baling and hauling from +*' Budynski, Stephanie. 2020. Straw Manufacturing in Alberta (@budynski_straw_2020), +*' using the lower range of the US costs. q18_cost_prod_res(i2,kres) .. - vm_cost_prod(i2,kres) + vm_cost_prod_kres(i2,kres) =e= - vm_prod_reg(i2,kres)*f18_fac_req_kres(kres); + vm_prod_reg(i2,kres) * fm_attributes("wm",kres) * f18_fac_req_kres(kres); *' Trade of AG residues is not considered, so that all produced AG residues have *' to be assigned to uses within the respective world region. diff --git a/modules/18_residues/flexreg_apr16/input.gms b/modules/18_residues/flexreg_apr16/input.gms index 2381bbd576..b6c23e24f1 100644 --- a/modules/18_residues/flexreg_apr16/input.gms +++ b/modules/18_residues/flexreg_apr16/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -41,7 +41,7 @@ $include "./modules/18_residues/input/f18_res_combust_eff.cs4" $offdelim /; -parameter f18_fac_req_kres(kres) Factor requirements (USD05MER per tDM) +parameter f18_fac_req_kres(kres) Factor requirements (USD17MER per tDM) / $ondelim $include "./modules/18_residues/flexreg_apr16/input/f18_fac_req_kres.csv" diff --git a/modules/18_residues/flexreg_apr16/not_used.txt b/modules/18_residues/flexreg_apr16/not_used.txt index 4b81dfbae2..07cb618a78 100644 --- a/modules/18_residues/flexreg_apr16/not_used.txt +++ b/modules/18_residues/flexreg_apr16/not_used.txt @@ -1,8 +1,2 @@ -# | (C) 2008-2019 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 - name,type,reason +vm_prod,input,not needed \ No newline at end of file diff --git a/modules/18_residues/flexreg_apr16/postsolve.gms b/modules/18_residues/flexreg_apr16/postsolve.gms index ea6e2d5a42..4633ea69e2 100644 --- a/modules/18_residues/flexreg_apr16/postsolve.gms +++ b/modules/18_residues/flexreg_apr16/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,59 +10,71 @@ *** EOF postsolve.gms *** *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov18_prod_res(t,j,kres,"marginal") = v18_prod_res.m(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"marginal") = vm_res_biomass_ag.m(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"marginal") = vm_res_biomass_bg.m(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"marginal") = v18_res_ag_removal.m(i,kcr,attributes); ov18_res_ag_recycling(t,i,kcr,attributes,"marginal") = v18_res_ag_recycling.m(i,kcr,attributes); - ov18_res_ag_burn(t,i,kcr,attributes,"marginal") = v18_res_ag_burn.m(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"marginal") = vm_res_ag_burn.m(i,kcr,attributes); ov_res_recycling(t,i,npk,"marginal") = vm_res_recycling.m(i,npk); + ov_cost_prod_kres(t,i,kres,"marginal") = vm_cost_prod_kres.m(i,kres); oq18_prod_res_ag_reg(t,i,kcr,attributes,"marginal") = q18_prod_res_ag_reg.m(i,kcr,attributes); oq18_prod_res_bg_reg(t,i,kcr,dm_nr,"marginal") = q18_prod_res_bg_reg.m(i,kcr,dm_nr); oq18_res_field_balance(t,i,kcr,attributes,"marginal") = q18_res_field_balance.m(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"marginal") = q18_res_field_burn.m(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"marginal") = q18_translate.m(i,kres,attributes); + oq18_prod_res_reg(t,i,kres,"marginal") = q18_prod_res_reg.m(i,kres); oq18_res_recycling_nr(t,i,"marginal") = q18_res_recycling_nr.m(i); oq18_res_recycling_pk(t,i,pk18,"marginal") = q18_res_recycling_pk.m(i,pk18); oq18_cost_prod_res(t,i,kres,"marginal") = q18_cost_prod_res.m(i,kres); + ov18_prod_res(t,j,kres,"level") = v18_prod_res.l(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"level") = vm_res_biomass_ag.l(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"level") = vm_res_biomass_bg.l(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"level") = v18_res_ag_removal.l(i,kcr,attributes); ov18_res_ag_recycling(t,i,kcr,attributes,"level") = v18_res_ag_recycling.l(i,kcr,attributes); - ov18_res_ag_burn(t,i,kcr,attributes,"level") = v18_res_ag_burn.l(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"level") = vm_res_ag_burn.l(i,kcr,attributes); ov_res_recycling(t,i,npk,"level") = vm_res_recycling.l(i,npk); + ov_cost_prod_kres(t,i,kres,"level") = vm_cost_prod_kres.l(i,kres); oq18_prod_res_ag_reg(t,i,kcr,attributes,"level") = q18_prod_res_ag_reg.l(i,kcr,attributes); oq18_prod_res_bg_reg(t,i,kcr,dm_nr,"level") = q18_prod_res_bg_reg.l(i,kcr,dm_nr); oq18_res_field_balance(t,i,kcr,attributes,"level") = q18_res_field_balance.l(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"level") = q18_res_field_burn.l(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"level") = q18_translate.l(i,kres,attributes); + oq18_prod_res_reg(t,i,kres,"level") = q18_prod_res_reg.l(i,kres); oq18_res_recycling_nr(t,i,"level") = q18_res_recycling_nr.l(i); oq18_res_recycling_pk(t,i,pk18,"level") = q18_res_recycling_pk.l(i,pk18); oq18_cost_prod_res(t,i,kres,"level") = q18_cost_prod_res.l(i,kres); + ov18_prod_res(t,j,kres,"upper") = v18_prod_res.up(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"upper") = vm_res_biomass_ag.up(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"upper") = vm_res_biomass_bg.up(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"upper") = v18_res_ag_removal.up(i,kcr,attributes); ov18_res_ag_recycling(t,i,kcr,attributes,"upper") = v18_res_ag_recycling.up(i,kcr,attributes); - ov18_res_ag_burn(t,i,kcr,attributes,"upper") = v18_res_ag_burn.up(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"upper") = vm_res_ag_burn.up(i,kcr,attributes); ov_res_recycling(t,i,npk,"upper") = vm_res_recycling.up(i,npk); + ov_cost_prod_kres(t,i,kres,"upper") = vm_cost_prod_kres.up(i,kres); oq18_prod_res_ag_reg(t,i,kcr,attributes,"upper") = q18_prod_res_ag_reg.up(i,kcr,attributes); oq18_prod_res_bg_reg(t,i,kcr,dm_nr,"upper") = q18_prod_res_bg_reg.up(i,kcr,dm_nr); oq18_res_field_balance(t,i,kcr,attributes,"upper") = q18_res_field_balance.up(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"upper") = q18_res_field_burn.up(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"upper") = q18_translate.up(i,kres,attributes); + oq18_prod_res_reg(t,i,kres,"upper") = q18_prod_res_reg.up(i,kres); oq18_res_recycling_nr(t,i,"upper") = q18_res_recycling_nr.up(i); oq18_res_recycling_pk(t,i,pk18,"upper") = q18_res_recycling_pk.up(i,pk18); oq18_cost_prod_res(t,i,kres,"upper") = q18_cost_prod_res.up(i,kres); + ov18_prod_res(t,j,kres,"lower") = v18_prod_res.lo(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"lower") = vm_res_biomass_ag.lo(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"lower") = vm_res_biomass_bg.lo(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"lower") = v18_res_ag_removal.lo(i,kcr,attributes); ov18_res_ag_recycling(t,i,kcr,attributes,"lower") = v18_res_ag_recycling.lo(i,kcr,attributes); - ov18_res_ag_burn(t,i,kcr,attributes,"lower") = v18_res_ag_burn.lo(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"lower") = vm_res_ag_burn.lo(i,kcr,attributes); ov_res_recycling(t,i,npk,"lower") = vm_res_recycling.lo(i,npk); + ov_cost_prod_kres(t,i,kres,"lower") = vm_cost_prod_kres.lo(i,kres); oq18_prod_res_ag_reg(t,i,kcr,attributes,"lower") = q18_prod_res_ag_reg.lo(i,kcr,attributes); oq18_prod_res_bg_reg(t,i,kcr,dm_nr,"lower") = q18_prod_res_bg_reg.lo(i,kcr,dm_nr); oq18_res_field_balance(t,i,kcr,attributes,"lower") = q18_res_field_balance.lo(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"lower") = q18_res_field_burn.lo(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"lower") = q18_translate.lo(i,kres,attributes); + oq18_prod_res_reg(t,i,kres,"lower") = q18_prod_res_reg.lo(i,kres); oq18_res_recycling_nr(t,i,"lower") = q18_res_recycling_nr.lo(i); oq18_res_recycling_pk(t,i,pk18,"lower") = q18_res_recycling_pk.lo(i,pk18); oq18_cost_prod_res(t,i,kres,"lower") = q18_cost_prod_res.lo(i,kres); diff --git a/modules/18_residues/flexreg_apr16/preloop.gms b/modules/18_residues/flexreg_apr16/preloop.gms index ffaf91aea6..0cdaa826dc 100644 --- a/modules/18_residues/flexreg_apr16/preloop.gms +++ b/modules/18_residues/flexreg_apr16/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/18_residues/flexreg_apr16/presolve.gms b/modules/18_residues/flexreg_apr16/presolve.gms index 1a47403076..e30abe7706 100644 --- a/modules/18_residues/flexreg_apr16/presolve.gms +++ b/modules/18_residues/flexreg_apr16/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/18_residues/flexreg_apr16/realization.gms b/modules/18_residues/flexreg_apr16/realization.gms index 76bf33b67e..a42961deaf 100644 --- a/modules/18_residues/flexreg_apr16/realization.gms +++ b/modules/18_residues/flexreg_apr16/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -30,6 +30,7 @@ $Ifi "%phase%" == "sets" $include "./modules/18_residues/flexreg_apr16/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/18_residues/flexreg_apr16/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/18_residues/flexreg_apr16/input.gms" $Ifi "%phase%" == "equations" $include "./modules/18_residues/flexreg_apr16/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/18_residues/flexreg_apr16/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/18_residues/flexreg_apr16/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/18_residues/flexreg_apr16/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/18_residues/flexreg_apr16/postsolve.gms" diff --git a/modules/18_residues/flexreg_apr16/scaling.gms b/modules/18_residues/flexreg_apr16/scaling.gms new file mode 100644 index 0000000000..a54611a3a1 --- /dev/null +++ b/modules/18_residues/flexreg_apr16/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_cost_prod_kres.scale(i,kres) = 10e3; diff --git a/modules/18_residues/flexreg_apr16/sets.gms b/modules/18_residues/flexreg_apr16/sets.gms index fddae7e9ad..d7f8b76c4c 100644 --- a/modules/18_residues/flexreg_apr16/sets.gms +++ b/modules/18_residues/flexreg_apr16/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/18_residues/module.gms b/modules/18_residues/module.gms index a374b00d12..f44727ae6f 100644 --- a/modules/18_residues/module.gms +++ b/modules/18_residues/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,15 +8,16 @@ *' @title Residues *' *' @description The residues module calculates the production of crop residues -*' (straw etc.) and its subsequent use. Residues can be burned, used for feed, -*' recycled to soils or used for other purposes (construction, fuel etc). +*' (straw, etc.) and its subsequent use. Residues can be burned, used for feed, +*' recycled to soils or used for other purposes (construction, fuel, etc.). *' *' The module also calculates the costs of crop residue harvest when it is used *' for feed or material purposes. - +*' *' @authors Benjamin Leon Bodirsky *###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%residues%" == "flexcluster_jul23" $include "./modules/18_residues/flexcluster_jul23/realization.gms" $Ifi "%residues%" == "flexreg_apr16" $include "./modules/18_residues/flexreg_apr16/realization.gms" $Ifi "%residues%" == "off" $include "./modules/18_residues/off/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/18_residues/off/declarations.gms b/modules/18_residues/off/declarations.gms index 300df17e9f..8e99f755b8 100644 --- a/modules/18_residues/off/declarations.gms +++ b/modules/18_residues/off/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,8 +8,10 @@ positive variables vm_res_biomass_ag(i,kcr,attributes) production of aboveground residues in each region (mio. tDM) - vm_res_biomass_bg(i,kcr,dm_nr) production of belowground residues in each region (mio. tDM) - vm_res_recycling(i,npk) residues recycled to croplands (mio tons nutrients) + vm_res_biomass_bg(i,kcr,dm_nr) production of belowground residues in each region (mio. tDM) + vm_res_recycling(i,npk) residues recycled to croplands (mio tons nutrients) + vm_res_ag_burn(i,kcr,attributes) Residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + vm_cost_prod_kres(i,kres) Production costs of harvesting crop residues (mio. USD17MER per yr) ; @@ -18,6 +20,8 @@ parameters ov_res_biomass_ag(t,i,kcr,attributes,type) production of aboveground residues in each region (mio. tDM) ov_res_biomass_bg(t,i,kcr,dm_nr,type) production of belowground residues in each region (mio. tDM) ov_res_recycling(t,i,npk,type) residues recycled to croplands (mio tons nutrients) + ov_res_ag_burn(t,i,kcr,attributes,type) Residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov_cost_prod_kres(t,i,kres,type) Production costs of harvesting crop residues (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/18_residues/off/input.gms b/modules/18_residues/off/input.gms new file mode 100644 index 0000000000..063bb937bf --- /dev/null +++ b/modules/18_residues/off/input.gms @@ -0,0 +1,13 @@ +*** | (C) 2008-2025 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 + +table f18_multicropping(t_all,i) Multicropping indicator as ratio of area harvested by physical area (1) +$ondelim +$include "./modules/18_residues/input/f18_multicropping.csv" +$offdelim; + +*** EOF input.gms *** diff --git a/modules/18_residues/off/not_used.txt b/modules/18_residues/off/not_used.txt index a61cfad5bb..85051d6636 100644 --- a/modules/18_residues/off/not_used.txt +++ b/modules/18_residues/off/not_used.txt @@ -1,13 +1,6 @@ -# | (C) 2008-2019 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 - name,type,reason im_development_state,input,questionnaire fm_attributes,input,questionnaire vm_prod_reg,input,questionnaire vm_area,input,questionnaire -vm_cost_prod,input,questionnaire +vm_prod,input,questionnaire \ No newline at end of file diff --git a/modules/18_residues/off/postsolve.gms b/modules/18_residues/off/postsolve.gms index d956294c3c..bbc140e738 100644 --- a/modules/18_residues/off/postsolve.gms +++ b/modules/18_residues/off/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -9,13 +9,21 @@ ov_res_biomass_ag(t,i,kcr,attributes,"marginal") = vm_res_biomass_ag.m(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"marginal") = vm_res_biomass_bg.m(i,kcr,dm_nr); ov_res_recycling(t,i,npk,"marginal") = vm_res_recycling.m(i,npk); + ov_res_ag_burn(t,i,kcr,attributes,"marginal") = vm_res_ag_burn.m(i,kcr,attributes); + ov_cost_prod_kres(t,i,kres,"marginal") = vm_cost_prod_kres.m(i,kres); ov_res_biomass_ag(t,i,kcr,attributes,"level") = vm_res_biomass_ag.l(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"level") = vm_res_biomass_bg.l(i,kcr,dm_nr); ov_res_recycling(t,i,npk,"level") = vm_res_recycling.l(i,npk); + ov_res_ag_burn(t,i,kcr,attributes,"level") = vm_res_ag_burn.l(i,kcr,attributes); + ov_cost_prod_kres(t,i,kres,"level") = vm_cost_prod_kres.l(i,kres); ov_res_biomass_ag(t,i,kcr,attributes,"upper") = vm_res_biomass_ag.up(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"upper") = vm_res_biomass_bg.up(i,kcr,dm_nr); ov_res_recycling(t,i,npk,"upper") = vm_res_recycling.up(i,npk); + ov_res_ag_burn(t,i,kcr,attributes,"upper") = vm_res_ag_burn.up(i,kcr,attributes); + ov_cost_prod_kres(t,i,kres,"upper") = vm_cost_prod_kres.up(i,kres); ov_res_biomass_ag(t,i,kcr,attributes,"lower") = vm_res_biomass_ag.lo(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"lower") = vm_res_biomass_bg.lo(i,kcr,dm_nr); ov_res_recycling(t,i,npk,"lower") = vm_res_recycling.lo(i,npk); + ov_res_ag_burn(t,i,kcr,attributes,"lower") = vm_res_ag_burn.lo(i,kcr,attributes); + ov_cost_prod_kres(t,i,kres,"lower") = vm_cost_prod_kres.lo(i,kres); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/18_residues/off/preloop.gms b/modules/18_residues/off/preloop.gms index 79c1206e9b..039b71abcd 100644 --- a/modules/18_residues/off/preloop.gms +++ b/modules/18_residues/off/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,5 +8,7 @@ vm_res_biomass_ag.fx(i,kcr,attributes) = 0; -vm_res_biomass_bg.fx(i,kcr,dm_nr) = 0; -vm_res_recycling.fx(i,npk) = 0; +vm_res_biomass_bg.fx(i,kcr,dm_nr) = 0; +vm_res_recycling.fx(i,npk) = 0; +vm_res_ag_burn.fx(i,kcr,attributes) = 0; +vm_cost_prod_kres.fx(i,kres) = 0; diff --git a/modules/18_residues/off/realization.gms b/modules/18_residues/off/realization.gms index 3e8c1aaa44..ebe7c360e1 100644 --- a/modules/18_residues/off/realization.gms +++ b/modules/18_residues/off/realization.gms @@ -1,11 +1,15 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 No representation of crop residues in the model. +*' @description No representation of crop residues in the model. Residual biomass +*' aboveground (`vm_res_biomass_ag`) and belowground (`vm_res_biomass_bg`) are set to 0, +*' as well as biomass to be recycled (`vm_res_recycling`) or burned as agricultural +*' residues (`vm_res_ag_burn`). Therefore, these types of crop residues are left unaccounted +*' for within any modules using these interface variable. *' @limitations Should not be used if emission estimates are required or *' climate policies are activated. @@ -13,6 +17,7 @@ *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/18_residues/off/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/18_residues/off/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/18_residues/off/input.gms" $Ifi "%phase%" == "preloop" $include "./modules/18_residues/off/preloop.gms" $Ifi "%phase%" == "postsolve" $include "./modules/18_residues/off/postsolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/18_residues/off/sets.gms b/modules/18_residues/off/sets.gms index 2bb86e0305..5ec47281b4 100644 --- a/modules/18_residues/off/sets.gms +++ b/modules/18_residues/off/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/20_processing/input/files b/modules/20_processing/input/files index 780f09830f..9a7275e5e0 100644 --- a/modules/20_processing/input/files +++ b/modules/20_processing/input/files @@ -3,3 +3,6 @@ f20_processing_shares.cs3 f20_processing_conversion_factors.cs3 f20_processing_balanceflow.cs3 f20_processing_unitcosts.cs3 +f20_scp_processing_shares.csv +f20_scp_type_shr.csv +f20_scp_unitcosts.csv diff --git a/modules/20_processing/module.gms b/modules/20_processing/module.gms index b44336a2b4..02b724ed67 100644 --- a/modules/20_processing/module.gms +++ b/modules/20_processing/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -15,6 +15,5 @@ *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%processing%" == "off" $include "./modules/20_processing/off/realization.gms" -$Ifi "%processing%" == "substitution_dec18" $include "./modules/20_processing/substitution_dec18/realization.gms" +$Ifi "%processing%" == "substitution_may21" $include "./modules/20_processing/substitution_may21/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/20_processing/off/declarations.gms b/modules/20_processing/off/declarations.gms deleted file mode 100644 index 84c175e8a7..0000000000 --- a/modules/20_processing/off/declarations.gms +++ /dev/null @@ -1,28 +0,0 @@ -*** | (C) 2008-2019 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 - q20_processing_costs(i) processing costs (mio.USD05MER) -; - -positive variables - vm_dem_processing(i,kall) demand for processing use (mio.tDM) - vm_secondary_overproduction(i,kall,kpr) overproduction of secondary couple products (mio.tDM) - vm_cost_processing(i) processing costs (mio. USD05MER per yr) -; - - vm_processing_substitution_cost(i) - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_dem_processing(t,i,kall,type) demand for processing use (mio.tDM) - ov_secondary_overproduction(t,i,kall,kpr,type) overproduction of secondary couple products (mio.tDM) - ov_cost_processing(t,i,type) processing costs (mio. USD05MER per yr) - oq20_processing_costs(t,i,type) processing costs (mio.USD05MER) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/20_processing/off/equations.gms b/modules/20_processing/off/equations.gms deleted file mode 100644 index 1d1f3166f7..0000000000 --- a/modules/20_processing/off/equations.gms +++ /dev/null @@ -1,14 +0,0 @@ -*** | (C) 2008-2019 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 -*' The equation of this realization is straight forward. -*' Costs of processing are calculated by the product of the quantity of secondary products and the unit processing costs -*' and unit processing costs (which arbitrarily is set to be 5000 USD for all processing types and secondary products). - -q20_processing_costs(i2) .. - vm_cost_processing(i2) =e= sum(ksd, vm_prod_reg(i2,ksd) * 5000); diff --git a/modules/20_processing/off/not_used.txt b/modules/20_processing/off/not_used.txt deleted file mode 100644 index 8596e57fb0..0000000000 --- a/modules/20_processing/off/not_used.txt +++ /dev/null @@ -1,10 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason -vm_dem_food,input,questionnaire -fm_attributes,input,questionnaire diff --git a/modules/20_processing/off/postsolve.gms b/modules/20_processing/off/postsolve.gms deleted file mode 100644 index feaa0df8fd..0000000000 --- a/modules/20_processing/off/postsolve.gms +++ /dev/null @@ -1,27 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_dem_processing(t,i,kall,"marginal") = vm_dem_processing.m(i,kall); - ov_secondary_overproduction(t,i,kall,kpr,"marginal") = vm_secondary_overproduction.m(i,kall,kpr); - ov_cost_processing(t,i,"marginal") = vm_cost_processing.m(i); - oq20_processing_costs(t,i,"marginal") = q20_processing_costs.m(i); - ov_dem_processing(t,i,kall,"level") = vm_dem_processing.l(i,kall); - ov_secondary_overproduction(t,i,kall,kpr,"level") = vm_secondary_overproduction.l(i,kall,kpr); - ov_cost_processing(t,i,"level") = vm_cost_processing.l(i); - oq20_processing_costs(t,i,"level") = q20_processing_costs.l(i); - ov_dem_processing(t,i,kall,"upper") = vm_dem_processing.up(i,kall); - ov_secondary_overproduction(t,i,kall,kpr,"upper") = vm_secondary_overproduction.up(i,kall,kpr); - ov_cost_processing(t,i,"upper") = vm_cost_processing.up(i); - oq20_processing_costs(t,i,"upper") = q20_processing_costs.up(i); - ov_dem_processing(t,i,kall,"lower") = vm_dem_processing.lo(i,kall); - ov_secondary_overproduction(t,i,kall,kpr,"lower") = vm_secondary_overproduction.lo(i,kall,kpr); - ov_cost_processing(t,i,"lower") = vm_cost_processing.lo(i); - oq20_processing_costs(t,i,"lower") = q20_processing_costs.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/20_processing/off/presolve.gms b/modules/20_processing/off/presolve.gms deleted file mode 100644 index 1130cbe52a..0000000000 --- a/modules/20_processing/off/presolve.gms +++ /dev/null @@ -1,12 +0,0 @@ -*** | (C) 2008-2019 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_dem_processing.fx(i,kall)=0; -vm_secondary_overproduction.fx(i,ksd,kpr)=0; - -vm_processing_substitution_cost.fx(i)=0; diff --git a/modules/20_processing/off/realization.gms b/modules/20_processing/off/realization.gms deleted file mode 100644 index e211bc4f2a..0000000000 --- a/modules/20_processing/off/realization.gms +++ /dev/null @@ -1,26 +0,0 @@ -*** | (C) 2008-2019 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 This realization uses an arbitrary unit cost of processing -*' which is too high for many of the processing types and secondary products. -*' So doing is meant to discourage overproduction of secondary products. -*' Despite these limitations, however, the implementation is very simple -*' as it uses the same unit costs of processing for all second -*' products (e.g. alcohol, ethanol, molasses, brans) and -*' processing types (e.g. fermentation, ginning, milling, breeding). - -*' @limitations There is no empirical ground to use the same unit costs of processing -*' for all processing types and secondary products, -*' and to impose constraint on over production of secondary products. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/20_processing/off/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/20_processing/off/declarations.gms" -$Ifi "%phase%" == "equations" $include "./modules/20_processing/off/equations.gms" -$Ifi "%phase%" == "presolve" $include "./modules/20_processing/off/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/20_processing/off/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/20_processing/off/sets.gms b/modules/20_processing/off/sets.gms deleted file mode 100644 index 40a7f328f2..0000000000 --- a/modules/20_processing/off/sets.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 - -kpr(kall) Products that can be processed - /tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,oilpalm, - potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro,brans,begr,betr,foddr, - sugar,molasses/ - -knpr(kall) Plant-based products that cannot be processed - /alcohol,distillers_grain,ethanol,fibres,fish,livst_chick,livst_egg,livst_milk, - livst_pig,livst_rum,oils,oilcakes,pasture,puls_pro,res_cereals,res_fibrous, - res_nonfibrous,scp/ -; diff --git a/modules/20_processing/substitution_dec18/declarations.gms b/modules/20_processing/substitution_dec18/declarations.gms deleted file mode 100644 index 73922be5b5..0000000000 --- a/modules/20_processing/substitution_dec18/declarations.gms +++ /dev/null @@ -1,54 +0,0 @@ -*** | (C) 2008-2019 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 - - - -positive variables - vm_dem_processing(i,kall) Demand for processing use (mio. tDM per yr) - v20_dem_processing(i,processing_subst20,kpr) Demand for processing use by process (mio. tDM per yr) - v20_secondary_substitutes(i,ksd,kpr) Substitutes for inferior secondary products (mio. tDM per yr) - vm_secondary_overproduction(i,kall,kpr) Overproduction of secondary couple products (mio. tDM per yr) - vm_cost_processing(i) Processing costs (mio. USD05MER per yr) -; - -variables - vm_processing_substitution_cost(i) Costs or benefits of substituting one product by another (mio. USD05MER per yr) -; - -equations - q20_processing(i,kpr,ksd) Processing equation (mio. tDM per yr) - q20_processing_aggregation_nocereals(i,kpr) Connecting processing activity to processing flows (mio. tDM per yr) - q20_processing_aggregation_cereals(i,kcereals20) Connecting processing activity to food use for milling (mio. tDM per yr) - q20_processing_aggregation_cotton(i) Connecting processing activity to production for cotton ginning (mio. tDM per yr) - q20_processing_substitution_oils(i) Substitution of oils by other oils (mio. tDM per yr) - q20_processing_substitution_brans(i) Substitution of brans by cereals (mio. tNr per yr) - q20_processing_substitution_sugar(i) Substitution of molasses by sugar (mio. tDM per yr) - q20_processing_substitution_protein(i) Substitution of protein products by other protein products (mio. tNr per yr) - q20_processing_costs(i) Processing costs (mio. USD05MER per yr) - q20_substitution_utility_loss(i) Utility loss when one product has to be substituted by another (mio. t Nr per year) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_dem_processing(t,i,kall,type) Demand for processing use (mio. tDM per yr) - ov20_dem_processing(t,i,processing_subst20,kpr,type) Demand for processing use by process (mio. tDM per yr) - ov20_secondary_substitutes(t,i,ksd,kpr,type) Substitutes for inferior secondary products (mio. tDM per yr) - ov_secondary_overproduction(t,i,kall,kpr,type) Overproduction of secondary couple products (mio. tDM per yr) - ov_cost_processing(t,i,type) Processing costs (mio. USD05MER per yr) - ov_processing_substitution_cost(t,i,type) Costs or benefits of substituting one product by another (mio. USD05MER per yr) - oq20_processing(t,i,kpr,ksd,type) Processing equation (mio. tDM per yr) - oq20_processing_aggregation_nocereals(t,i,kpr,type) Connecting processing activity to processing flows (mio. tDM per yr) - oq20_processing_aggregation_cereals(t,i,kcereals20,type) Connecting processing activity to food use for milling (mio. tDM per yr) - oq20_processing_aggregation_cotton(t,i,type) Connecting processing activity to production for cotton ginning (mio. tDM per yr) - oq20_processing_substitution_oils(t,i,type) Substitution of oils by other oils (mio. tDM per yr) - oq20_processing_substitution_brans(t,i,type) Substitution of brans by cereals (mio. tNr per yr) - oq20_processing_substitution_sugar(t,i,type) Substitution of molasses by sugar (mio. tDM per yr) - oq20_processing_substitution_protein(t,i,type) Substitution of protein products by other protein products (mio. tNr per yr) - oq20_processing_costs(t,i,type) Processing costs (mio. USD05MER per yr) - oq20_substitution_utility_loss(t,i,type) Utility loss when one product has to be substituted by another (mio. t Nr per year) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/20_processing/substitution_dec18/equations.gms b/modules/20_processing/substitution_dec18/equations.gms deleted file mode 100644 index db05cf60b4..0000000000 --- a/modules/20_processing/substitution_dec18/equations.gms +++ /dev/null @@ -1,139 +0,0 @@ -*** | (C) 2008-2019 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 -*' The series of equations below show the aggregation of secondary products from -*' from non-cereals (through alcohol fermentation, single cell protein breeding, -*' oil extracting, sugar refining or ethanol distilling processes), -*' cereals (through milling process), and cotton (through ginning process). -*' The need to have such multiple equations (i.e., separate equations for each process) -*' is meant to replicate the structure of Commodity Balance Sheets in @FAOSTAT. -*' -*' In the first equation, the demand for processing use is calculated -*' by aggregating the demand for secondary (processed) products use by process type -*' (other than milling and ginning in this equation case). -*' The equation also calculates secondary products from non-cereals crops -*' such as bio-energy crops and oil crops. - -q20_processing_aggregation_nocereals(i2,kpr) .. - vm_dem_processing(i2,kpr) =e= - sum(no_milling_ginning20,v20_dem_processing(i2,no_milling_ginning20,kpr)); - -*' In the second equation, the demand for processed products by process type of milling -*' of cereal crops is calculated. The equation applies only to secondary products from cereal crops which, among others, -*' include maize, tropical and temperate cereals. -*' Nevertheless, as in Commodity Balance Sheets of @FAOSTAT, cereal milling here is -*' not counted as processing but derived from food use of cereals. - -q20_processing_aggregation_cereals(i2,kcereals20) .. - vm_dem_food(i2,kcereals20) =e= v20_dem_processing(i2,"milling",kcereals20); - -*' In the third equation, the demand for processing by process type `v20_dem_processing` of ginning of cotton is calculated. -*' Likewise, the Commodity Balance Sheets in @FAOSTAT do not account for processing of "seed cotton" -*' into "cotton seed" and "cotton lint". As MAgPIE only includes the product "cotton seed" and not "seed cotton", -*' the "cotton lint" is bound to the production of "cotton seed". - -q20_processing_aggregation_cotton(i2) .. - vm_prod_reg(i2,"cottn_pro") =e= v20_dem_processing(i2,"ginning","cottn_pro"); - - -*' The fourth equation below describes the transformation of primary products into secondary products. -*' The processing conversion factors (`f20_processing_conversion_factors_cf`) indicate how much secondary products -*' can be derived from one unit of a specific primary product. The conversion factors are globally -*' equal to avoid path-dependencies in future outlooks based on historical patterns. -*' Historical differences in conversion efficiencies are instead considered using -*' a static balanceflow. -*' To avoid perfect substitutability between different primary commodities being transformed into the same -*' secondary product (e.g. oil from sunflower or oil palm), we use share factor coefficients, `f20_processing_shares`, -*' which indicate how much of the secondary products comes from which primary products. -*' The parameter `f20_processing_balanceflow` accounts for differences in conversion efficiency among various countries -*' whereas the conversion factors remain global. The `v20_secondary_substitutes` are used to avoid overproduction of couple products: for each couple product, -*' there is one secondary product (usually the cheaper one) which can be substituted by other commodities -*' (see also equations below). The secondary product overproduction `vm_secondary_overproduction` is used to move overproduction -*' of secondary products into the waste category such that the demand balance is maintained (see also [16_demand]). - -q20_processing(i2,kpr,ksd) .. - sum(processing20, v20_dem_processing(i2,processing20,kpr) - * sum(ct,f20_processing_conversion_factors(ct,processing20,ksd,kpr))) =e= - (vm_prod_reg(i2,ksd) - sum(ct,f20_processing_balanceflow(ct,i2,ksd))) - * sum(ct,f20_processing_shares(ct,i2,ksd,kpr)) - - v20_secondary_substitutes(i2,ksd,kpr) - + vm_secondary_overproduction(i2,ksd,kpr); - -*' Oils from one crop can be substituted by different types of oils. -q20_processing_substitution_oils(i2) .. - v20_dem_processing(i2,"substitutes","oils") =g= - sum((kpr), v20_secondary_substitutes(i2,"oils",kpr) ); - -*' Molasses can be substituted by sugar, -q20_processing_substitution_sugar(i2) .. - v20_dem_processing(i2,"substitutes","sugar") =g= - sum((kpr), v20_secondary_substitutes(i2,"molasses",kpr) ); - -*' Different types of primary oilcrops or oilcakes from different origins -*' as well as distillers grains can be substituted for oilcakes and distillers -*' grains based on their protein content. - -q20_processing_substitution_protein(i2) .. - sum(oilcake_substitutes20, - v20_dem_processing(i2,"substitutes",oilcake_substitutes20) - * fm_attributes("nr",oilcake_substitutes20) - ) =g= - sum(kpr, - (v20_secondary_substitutes(i2,"distillers_grain",kpr) - + v20_secondary_substitutes(i2,"oilcakes",kpr) ) - * fm_attributes("nr",kpr)); - -*' Brans can be substituted by cereals of the same protein value. - -q20_processing_substitution_brans(i2) .. - sum(kcereals20, v20_dem_processing(i2,"substitutes",kcereals20) - * fm_attributes("nr",kcereals20)) =g= - sum((kcereals20), v20_secondary_substitutes(i2,"brans",kcereals20) - * fm_attributes("nr","brans")); - -*' The seventh equation in this realization calculates the costs of processing (or converting) -*' primary products to secondary products. -*' As shown in the equation, the costs of processing (converting from primary to secondary products) -*' depend on the type of the primary product (e.g. maize, sugar cane, cotton), -*' the type of the process (e.g. milling, refining, ginning), -*' and the type of secondary product (e.g. brans, sugar, fiber) product. -*' The unit costs of processing, `f20_processing_unitcosts`, -*' are specific for the different conversion routes and are collected, interpolated, -*' and extrapolated from the related literature (e.g. @adanacioglu_profitability_2011, @pikaar_decoupling_2018, @valco_thecost_2016) -*' complemented with best educated guess by the module authors. - - - -q20_processing_costs(i2) .. - vm_cost_processing(i2) =e= -sum((ksd,processing20,kpr), v20_dem_processing(i2,processing20,kpr) - *sum(ct,f20_processing_conversion_factors(ct,processing20,ksd,kpr)) - * ( - f20_processing_unitcosts(ksd,kpr) - )); - -*' Finally, we assume that any substitution of one product by another, -*' diverging from our initial demand estimates, comes at a loss of utility. -*' We assume a loss of utility in the magnitude of 200 USD to strongly -*' disincentivize substitution. -*' Moreover, to account for heterogeneity of different types of oil which -*' are traded based on the assumption of homogeneity, we include a cost term -*' for quality differences which make low-quality oils like palm oil more -*' expensive and high quality oils cheaper. The magnitude of the quality -*' adjustment is based on current price differences between different -*' types of oils, standardized on the price of soybean oil. - -q20_substitution_utility_loss(i2) .. - vm_processing_substitution_cost(i2) =e= - sum(kpr, - v20_dem_processing(i2,"substitutes",kpr) - * 200 - ) + - sum((ksd,processing20,kpr), v20_dem_processing(i2,processing20,kpr) - *sum(ct,f20_processing_conversion_factors(ct,processing20,ksd,kpr)) - * (f20_quality_cost(ksd,kpr)+f20_calibration(ksd,kpr))); diff --git a/modules/20_processing/substitution_dec18/input.gms b/modules/20_processing/substitution_dec18/input.gms deleted file mode 100644 index 8979b84d80..0000000000 --- a/modules/20_processing/substitution_dec18/input.gms +++ /dev/null @@ -1,38 +0,0 @@ -*** | (C) 2008-2019 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 - - - -table f20_processing_balanceflow(t_all,i,ksd) Processing balance flow (mio. tDM) -$ondelim -$include "./modules/20_processing/input/f20_processing_balanceflow.cs3" -$offdelim ; - -table f20_processing_conversion_factors(t_all,processing20,ksd,kpr) Conversion factors of primary products into secondary products (1) -$ondelim -$include "./modules/20_processing/input/f20_processing_conversion_factors.cs3" -$offdelim ; - -table f20_processing_shares(t_all,i,ksd,kpr) Shares of secondary products coming from a primary product (1) -$ondelim -$include "./modules/20_processing/input/f20_processing_shares.cs3" -$offdelim ; - -table f20_processing_unitcosts(ksd,kpr) Costs of transforming x units kpr into 1 unit ksd (USD05MER per tDM) -$ondelim -$include "./modules/20_processing/input/f20_processing_unitcosts.cs3" -$offdelim ; - -table f20_quality_cost(ksd,kpr) Costs for difference in quality between secondary products from diverging origins (USD per tDM) -$ondelim -$include "./modules/20_processing/substitution_dec18/input/f20_quality_cost.cs3" -$offdelim ; - -table f20_calibration(ksd,kpr) Additional calibration costs to avoid substitution in historical period (USD05 per tDM) -$ondelim -$include "./modules/20_processing/substitution_dec18/input/f20_calibration.cs3" -$offdelim ; diff --git a/modules/20_processing/substitution_dec18/input/files b/modules/20_processing/substitution_dec18/input/files deleted file mode 100644 index 6b280b1420..0000000000 --- a/modules/20_processing/substitution_dec18/input/files +++ /dev/null @@ -1,3 +0,0 @@ -* list of files that are required here -f20_quality_cost.cs3 -f20_calibration.cs3 diff --git a/modules/20_processing/substitution_dec18/not_used.txt b/modules/20_processing/substitution_dec18/not_used.txt deleted file mode 100644 index 4b81dfbae2..0000000000 --- a/modules/20_processing/substitution_dec18/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason diff --git a/modules/20_processing/substitution_dec18/postsolve.gms b/modules/20_processing/substitution_dec18/postsolve.gms deleted file mode 100644 index 9fcc697515..0000000000 --- a/modules/20_processing/substitution_dec18/postsolve.gms +++ /dev/null @@ -1,75 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_dem_processing(t,i,kall,"marginal") = vm_dem_processing.m(i,kall); - ov20_dem_processing(t,i,processing_subst20,kpr,"marginal") = v20_dem_processing.m(i,processing_subst20,kpr); - ov20_secondary_substitutes(t,i,ksd,kpr,"marginal") = v20_secondary_substitutes.m(i,ksd,kpr); - ov_secondary_overproduction(t,i,kall,kpr,"marginal") = vm_secondary_overproduction.m(i,kall,kpr); - ov_cost_processing(t,i,"marginal") = vm_cost_processing.m(i); - ov_processing_substitution_cost(t,i,"marginal") = vm_processing_substitution_cost.m(i); - oq20_processing(t,i,kpr,ksd,"marginal") = q20_processing.m(i,kpr,ksd); - oq20_processing_aggregation_nocereals(t,i,kpr,"marginal") = q20_processing_aggregation_nocereals.m(i,kpr); - oq20_processing_aggregation_cereals(t,i,kcereals20,"marginal") = q20_processing_aggregation_cereals.m(i,kcereals20); - oq20_processing_aggregation_cotton(t,i,"marginal") = q20_processing_aggregation_cotton.m(i); - oq20_processing_substitution_oils(t,i,"marginal") = q20_processing_substitution_oils.m(i); - oq20_processing_substitution_brans(t,i,"marginal") = q20_processing_substitution_brans.m(i); - oq20_processing_substitution_sugar(t,i,"marginal") = q20_processing_substitution_sugar.m(i); - oq20_processing_substitution_protein(t,i,"marginal") = q20_processing_substitution_protein.m(i); - oq20_processing_costs(t,i,"marginal") = q20_processing_costs.m(i); - oq20_substitution_utility_loss(t,i,"marginal") = q20_substitution_utility_loss.m(i); - ov_dem_processing(t,i,kall,"level") = vm_dem_processing.l(i,kall); - ov20_dem_processing(t,i,processing_subst20,kpr,"level") = v20_dem_processing.l(i,processing_subst20,kpr); - ov20_secondary_substitutes(t,i,ksd,kpr,"level") = v20_secondary_substitutes.l(i,ksd,kpr); - ov_secondary_overproduction(t,i,kall,kpr,"level") = vm_secondary_overproduction.l(i,kall,kpr); - ov_cost_processing(t,i,"level") = vm_cost_processing.l(i); - ov_processing_substitution_cost(t,i,"level") = vm_processing_substitution_cost.l(i); - oq20_processing(t,i,kpr,ksd,"level") = q20_processing.l(i,kpr,ksd); - oq20_processing_aggregation_nocereals(t,i,kpr,"level") = q20_processing_aggregation_nocereals.l(i,kpr); - oq20_processing_aggregation_cereals(t,i,kcereals20,"level") = q20_processing_aggregation_cereals.l(i,kcereals20); - oq20_processing_aggregation_cotton(t,i,"level") = q20_processing_aggregation_cotton.l(i); - oq20_processing_substitution_oils(t,i,"level") = q20_processing_substitution_oils.l(i); - oq20_processing_substitution_brans(t,i,"level") = q20_processing_substitution_brans.l(i); - oq20_processing_substitution_sugar(t,i,"level") = q20_processing_substitution_sugar.l(i); - oq20_processing_substitution_protein(t,i,"level") = q20_processing_substitution_protein.l(i); - oq20_processing_costs(t,i,"level") = q20_processing_costs.l(i); - oq20_substitution_utility_loss(t,i,"level") = q20_substitution_utility_loss.l(i); - ov_dem_processing(t,i,kall,"upper") = vm_dem_processing.up(i,kall); - ov20_dem_processing(t,i,processing_subst20,kpr,"upper") = v20_dem_processing.up(i,processing_subst20,kpr); - ov20_secondary_substitutes(t,i,ksd,kpr,"upper") = v20_secondary_substitutes.up(i,ksd,kpr); - ov_secondary_overproduction(t,i,kall,kpr,"upper") = vm_secondary_overproduction.up(i,kall,kpr); - ov_cost_processing(t,i,"upper") = vm_cost_processing.up(i); - ov_processing_substitution_cost(t,i,"upper") = vm_processing_substitution_cost.up(i); - oq20_processing(t,i,kpr,ksd,"upper") = q20_processing.up(i,kpr,ksd); - oq20_processing_aggregation_nocereals(t,i,kpr,"upper") = q20_processing_aggregation_nocereals.up(i,kpr); - oq20_processing_aggregation_cereals(t,i,kcereals20,"upper") = q20_processing_aggregation_cereals.up(i,kcereals20); - oq20_processing_aggregation_cotton(t,i,"upper") = q20_processing_aggregation_cotton.up(i); - oq20_processing_substitution_oils(t,i,"upper") = q20_processing_substitution_oils.up(i); - oq20_processing_substitution_brans(t,i,"upper") = q20_processing_substitution_brans.up(i); - oq20_processing_substitution_sugar(t,i,"upper") = q20_processing_substitution_sugar.up(i); - oq20_processing_substitution_protein(t,i,"upper") = q20_processing_substitution_protein.up(i); - oq20_processing_costs(t,i,"upper") = q20_processing_costs.up(i); - oq20_substitution_utility_loss(t,i,"upper") = q20_substitution_utility_loss.up(i); - ov_dem_processing(t,i,kall,"lower") = vm_dem_processing.lo(i,kall); - ov20_dem_processing(t,i,processing_subst20,kpr,"lower") = v20_dem_processing.lo(i,processing_subst20,kpr); - ov20_secondary_substitutes(t,i,ksd,kpr,"lower") = v20_secondary_substitutes.lo(i,ksd,kpr); - ov_secondary_overproduction(t,i,kall,kpr,"lower") = vm_secondary_overproduction.lo(i,kall,kpr); - ov_cost_processing(t,i,"lower") = vm_cost_processing.lo(i); - ov_processing_substitution_cost(t,i,"lower") = vm_processing_substitution_cost.lo(i); - oq20_processing(t,i,kpr,ksd,"lower") = q20_processing.lo(i,kpr,ksd); - oq20_processing_aggregation_nocereals(t,i,kpr,"lower") = q20_processing_aggregation_nocereals.lo(i,kpr); - oq20_processing_aggregation_cereals(t,i,kcereals20,"lower") = q20_processing_aggregation_cereals.lo(i,kcereals20); - oq20_processing_aggregation_cotton(t,i,"lower") = q20_processing_aggregation_cotton.lo(i); - oq20_processing_substitution_oils(t,i,"lower") = q20_processing_substitution_oils.lo(i); - oq20_processing_substitution_brans(t,i,"lower") = q20_processing_substitution_brans.lo(i); - oq20_processing_substitution_sugar(t,i,"lower") = q20_processing_substitution_sugar.lo(i); - oq20_processing_substitution_protein(t,i,"lower") = q20_processing_substitution_protein.lo(i); - oq20_processing_costs(t,i,"lower") = q20_processing_costs.lo(i); - oq20_substitution_utility_loss(t,i,"lower") = q20_substitution_utility_loss.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/20_processing/substitution_dec18/presolve.gms b/modules/20_processing/substitution_dec18/presolve.gms deleted file mode 100644 index 4b7ae452b9..0000000000 --- a/modules/20_processing/substitution_dec18/presolve.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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_dem_processing.fx(i,knpr)=0; - -vm_secondary_overproduction.fx(i2,kall,kpr)=0; -vm_secondary_overproduction.up(i2,ksd,kpr)=Inf; - -v20_secondary_substitutes.fx(i2,ksd,kpr)=0; -v20_secondary_substitutes.up(i2,"oils",kpr)=Inf; -v20_secondary_substitutes.up(i2,"molasses",kpr)=Inf; -v20_secondary_substitutes.up(i2,"distillers_grain",kpr)=Inf; -v20_secondary_substitutes.up(i2,"oilcakes",kpr)=Inf; -v20_secondary_substitutes.up(i2,"brans",kcereals20)=Inf; diff --git a/modules/20_processing/substitution_dec18/realization.gms b/modules/20_processing/substitution_dec18/realization.gms deleted file mode 100644 index e4b4b7d6a7..0000000000 --- a/modules/20_processing/substitution_dec18/realization.gms +++ /dev/null @@ -1,15 +0,0 @@ -*** | (C) 2008-2019 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 - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/20_processing/substitution_dec18/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/20_processing/substitution_dec18/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/20_processing/substitution_dec18/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/20_processing/substitution_dec18/equations.gms" -$Ifi "%phase%" == "presolve" $include "./modules/20_processing/substitution_dec18/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/20_processing/substitution_dec18/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/20_processing/substitution_dec18/sets.gms b/modules/20_processing/substitution_dec18/sets.gms deleted file mode 100644 index 217e0155cb..0000000000 --- a/modules/20_processing/substitution_dec18/sets.gms +++ /dev/null @@ -1,35 +0,0 @@ -*** | (C) 2008-2019 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 - - -kpr(kall) Products that can be processed - /tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,oilpalm, - potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro,brans,begr,betr,foddr, - sugar,molasses,oils,oilcakes/ - -knpr(kall) Products that cannot be processed - /alcohol,distillers_grain,ethanol,fibres,fish,livst_chick,livst_egg,livst_milk, - livst_pig,livst_rum,oilcakes,pasture,puls_pro,res_cereals,res_fibrous, - res_nonfibrous,scp/ - -processing_subst20 Processing activities -/ milling, refining, extracting, distilling, fermentation, breeding, ginning, substitutes / - -processing20(processing_subst20) Processing activities except substitution -/ milling, refining, extracting, distilling, fermentation, breeding, ginning / - -kcereals20(kpr) Cereals used for processing -/tece,maiz,trce,rice_pro/ - -no_milling_ginning20(processing_subst20) Processing activities without milling and ginning -/refining, extracting, distilling, fermentation, breeding, substitutes / - -oilcake_substitutes20(kpr) products that can be substituted for oilcakes - /soybean,rapeseed,groundnut,sunflower,oilpalm,cottn_pro,oilcakes/ -; diff --git a/modules/20_processing/substitution_may21/declarations.gms b/modules/20_processing/substitution_may21/declarations.gms new file mode 100644 index 0000000000..c3037966b2 --- /dev/null +++ b/modules/20_processing/substitution_may21/declarations.gms @@ -0,0 +1,59 @@ +*** | (C) 2008-2025 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 + i20_processing_shares(t_all,i,ksd,kpr) Shares of secondary products coming from a primary product (1) + i20_processing_conversion_factors(t_all,processing20,ksd,kpr) Conversion factors of primary products into secondary products (1) + i20_processing_unitcosts(ksd,kpr) Costs of transforming x units kpr into 1 unit ksd (USD17MER per tDM) + ; + + +positive variables + vm_dem_processing(i,kall) Demand for processing use (mio. tDM per yr) + v20_dem_processing(i,processing_subst20,kpr) Demand for processing use by process (mio. tDM per yr) + v20_secondary_substitutes(i,ksd,kpr) Substitutes for inferior secondary products (mio. tDM per yr) + vm_secondary_overproduction(i,kall,kpr) Overproduction of secondary couple products (mio. tDM per yr) + vm_cost_processing(i) Processing costs (mio. USD17MER per yr) +; + +variables + vm_processing_substitution_cost(i) Costs or benefits of substituting one product by another (mio. USD17MER per yr) +; + +equations + q20_processing(i,kpr,ksd) Processing equation (mio. tDM per yr) + q20_processing_aggregation_nocereals(i,kpr) Connecting processing activity to processing flows (mio. tDM per yr) + q20_processing_aggregation_cereals(i,kcereals20) Connecting processing activity to food use for milling (mio. tDM per yr) + q20_processing_aggregation_cotton(i) Connecting processing activity to production for cotton ginning (mio. tDM per yr) + q20_processing_substitution_oils(i) Substitution of oils by other oils (mio. tDM per yr) + q20_processing_substitution_brans(i) Substitution of brans by cereals (mio. tNr per yr) + q20_processing_substitution_sugar(i) Substitution of molasses by sugar (mio. tDM per yr) + q20_processing_substitution_protein(i) Substitution of protein products by other protein products (mio. tNr per yr) + q20_processing_costs(i) Processing costs (mio. USD17MER per yr) + q20_substitution_utility_loss(i) Utility loss when one product has to be substituted by another (mio. t Nr per year) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_dem_processing(t,i,kall,type) Demand for processing use (mio. tDM per yr) + ov20_dem_processing(t,i,processing_subst20,kpr,type) Demand for processing use by process (mio. tDM per yr) + ov20_secondary_substitutes(t,i,ksd,kpr,type) Substitutes for inferior secondary products (mio. tDM per yr) + ov_secondary_overproduction(t,i,kall,kpr,type) Overproduction of secondary couple products (mio. tDM per yr) + ov_cost_processing(t,i,type) Processing costs (mio. USD17MER per yr) + ov_processing_substitution_cost(t,i,type) Costs or benefits of substituting one product by another (mio. USD17MER per yr) + oq20_processing(t,i,kpr,ksd,type) Processing equation (mio. tDM per yr) + oq20_processing_aggregation_nocereals(t,i,kpr,type) Connecting processing activity to processing flows (mio. tDM per yr) + oq20_processing_aggregation_cereals(t,i,kcereals20,type) Connecting processing activity to food use for milling (mio. tDM per yr) + oq20_processing_aggregation_cotton(t,i,type) Connecting processing activity to production for cotton ginning (mio. tDM per yr) + oq20_processing_substitution_oils(t,i,type) Substitution of oils by other oils (mio. tDM per yr) + oq20_processing_substitution_brans(t,i,type) Substitution of brans by cereals (mio. tNr per yr) + oq20_processing_substitution_sugar(t,i,type) Substitution of molasses by sugar (mio. tDM per yr) + oq20_processing_substitution_protein(t,i,type) Substitution of protein products by other protein products (mio. tNr per yr) + oq20_processing_costs(t,i,type) Processing costs (mio. USD17MER per yr) + oq20_substitution_utility_loss(t,i,type) Utility loss when one product has to be substituted by another (mio. t Nr per year) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/20_processing/substitution_may21/equations.gms b/modules/20_processing/substitution_may21/equations.gms new file mode 100644 index 0000000000..d8d62860b2 --- /dev/null +++ b/modules/20_processing/substitution_may21/equations.gms @@ -0,0 +1,142 @@ +*** | (C) 2008-2025 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 +*' The series of equations below show the aggregation of secondary products +*' from non-cereals (through alcohol fermentation, single cell protein breeding, +*' oil extracting, sugar refining or ethanol distilling processes), +*' cereals (through milling process), and cotton (through ginning process). +*' The need to have such multiple equations (i.e., separate equations for each process) +*' is meant to replicate the structure of Commodity Balance Sheets in @FAOSTAT. +*' +*' In the first equation, the demand for processing use is calculated +*' by aggregating the demand for secondary (processed) products use by process type +*' (other than milling and ginning in this equation case). +*' The equation also calculates secondary products from non-cereals crops +*' such as bio-energy crops and oil crops. + +q20_processing_aggregation_nocereals(i2,kpr) .. + vm_dem_processing(i2,kpr) =e= + sum(no_milling_ginning20,v20_dem_processing(i2,no_milling_ginning20,kpr)); + +*' In the second equation, the demand for processed products by process type of milling +*' of cereal crops is calculated. The equation applies only to secondary products from cereal crops which, among others, +*' include maize, tropical and temperate cereals. +*' Nevertheless, as in Commodity Balance Sheets of @FAOSTAT, cereal milling here is +*' not counted as processing but derived from food use of cereals. + +q20_processing_aggregation_cereals(i2,kcereals20) .. + vm_dem_food(i2,kcereals20) =e= v20_dem_processing(i2,"milling",kcereals20); + +*' In the third equation, the demand for processing by process type `v20_dem_processing` of ginning of cotton is calculated. +*' Likewise, the Commodity Balance Sheets in @FAOSTAT do not account for processing of "seed cotton" +*' into "cotton seed" and "cotton lint". As MAgPIE only includes the product "cotton seed" and not "seed cotton", +*' the "cotton lint" is bound to the production of "cotton seed". + +q20_processing_aggregation_cotton(i2) .. + vm_prod_reg(i2,"cottn_pro") =e= v20_dem_processing(i2,"ginning","cottn_pro"); + + +*' The fourth equation below describes the transformation of primary products into secondary products. +*' The processing conversion factors (`i20_processing_conversion_factors_cf`) indicate how much secondary products +*' can be derived from one unit of a specific primary product. The conversion factors are globally +*' equal to avoid path-dependencies in future outlooks based on historical patterns. +*' Historical differences in conversion efficiencies are instead considered using +*' a static balanceflow. +*' To avoid perfect substitutability between different primary commodities being transformed into the same +*' secondary product (e.g. oil from sunflower or oil palm), we use share factor coefficients, `i20_processing_shares`, +*' which indicate how much of the secondary products comes from which primary products. +*' The parameter `f20_processing_balanceflow` accounts for differences in conversion efficiency among various countries +*' whereas the conversion factors remain global. The `v20_secondary_substitutes` are used to avoid overproduction of couple products: for each couple product, +*' there is one secondary product (usually the cheaper one) which can be substituted by other commodities +*' (see also equations below). The secondary product overproduction `vm_secondary_overproduction` is used to move overproduction +*' of secondary products into the waste category such that the demand balance is maintained (see also [16_demand]). + +q20_processing(i2,kpr,ksd) .. + sum(processing20, v20_dem_processing(i2,processing20,kpr) + * sum(ct,i20_processing_conversion_factors(ct,processing20,ksd,kpr))) =e= + (vm_prod_reg(i2,ksd) - sum(ct,f20_processing_balanceflow(ct,i2,ksd))) + * sum(ct,i20_processing_shares(ct,i2,ksd,kpr)) + - v20_secondary_substitutes(i2,ksd,kpr) + + vm_secondary_overproduction(i2,ksd,kpr); + +*' Oils from one crop can be substituted by different types of oils. +q20_processing_substitution_oils(i2) .. + v20_dem_processing(i2,"substitutes","oils") =g= + sum((kpr), v20_secondary_substitutes(i2,"oils",kpr) ); + +*' Molasses can be substituted by sugar, +q20_processing_substitution_sugar(i2) .. + v20_dem_processing(i2,"substitutes","sugar") =g= + sum((kpr), v20_secondary_substitutes(i2,"molasses",kpr) ); + +*' Different types of primary oilcrops or oilcakes from different origins +*' as well as distillers grains can be substituted for oilcakes and distillers +*' grains based on their protein content. + +q20_processing_substitution_protein(i2) .. + sum(oilcake_substitutes20, + v20_dem_processing(i2,"substitutes",oilcake_substitutes20) + * fm_attributes("nr",oilcake_substitutes20) + ) =g= + sum(kpr, + (v20_secondary_substitutes(i2,"distillers_grain",kpr) + + v20_secondary_substitutes(i2,"oilcakes",kpr) ) + * fm_attributes("nr",kpr)); + +*' Brans can be substituted by cereals of the same protein value. + +q20_processing_substitution_brans(i2) .. + sum(kcereals20, v20_dem_processing(i2,"substitutes",kcereals20) + * fm_attributes("nr",kcereals20)) =g= + sum((kcereals20), v20_secondary_substitutes(i2,"brans",kcereals20) + * fm_attributes("nr","brans")); + +*' The seventh equation in this realization calculates the costs of processing (or converting) +*' primary products to secondary products. +*' As shown in the equation, the costs of processing (converting from primary to secondary products) +*' depend on the type of the primary product (e.g. maize, sugar cane, cotton), +*' the type of the process (e.g. milling, refining, ginning), +*' and the type of secondary product (e.g. brans, sugar, fiber) product. +*' The unit costs of processing, `i20_processing_unitcosts`, +*' are specific for the different conversion routes and are collected, interpolated, +*' and extrapolated from the related literature (e.g. @adanacioglu_profitability_2011, @pikaar_decoupling_2018, @valco_thecost_2016) +*' complemented with best educated guess by the module authors. +*' Costs for single-cell protein production (scp) are handled differently because +*' scp production with hydrogen as substrate has no land requirements, and thus +*' would have no cost. +*' All other scp production routes (mixed, methane, sugar and cellulose) have land requirements +*' mapped to specific crops (`f20_scp_processing_shares`). + +q20_processing_costs(i2) .. + vm_cost_processing(i2) =e= +sum((ksd,processing20,kpr), v20_dem_processing(i2,processing20,kpr) + *sum(ct,i20_processing_conversion_factors(ct,processing20,ksd,kpr)) + * i20_processing_unitcosts(ksd,kpr)) + + (vm_prod_reg(i2,"scp") * sum(scptype, sum(ct, f20_scp_type_shr(scptype,"%c20_scp_type%")) * f20_scp_unitcosts(scptype))); + ; + +*' Finally, we assume that any substitution of one product by another, +*' diverging from our initial demand estimates, comes at a loss of utility. +*' We assume a loss of utility in the magnitude of 200 USD to strongly +*' disincentivize substitution. +*' Moreover, to account for heterogeneity of different types of oil which +*' are traded based on the assumption of homogeneity, we include a cost term +*' for quality differences which make low-quality oils like palm oil more +*' expensive and high quality oils cheaper. The magnitude of the quality +*' adjustment is based on current price differences between different +*' types of oils, standardized on the price of soybean oil. + +q20_substitution_utility_loss(i2) .. + vm_processing_substitution_cost(i2) =e= + sum(kpr, + v20_dem_processing(i2,"substitutes",kpr) + * 200 + ) + + sum((ksd,processing20,kpr), v20_dem_processing(i2,processing20,kpr) + * sum(ct,i20_processing_conversion_factors(ct,processing20,ksd,kpr)) + * f20_quality_cost(ksd,kpr)); diff --git a/modules/20_processing/substitution_may21/input.gms b/modules/20_processing/substitution_may21/input.gms new file mode 100644 index 0000000000..56ecc3330f --- /dev/null +++ b/modules/20_processing/substitution_may21/input.gms @@ -0,0 +1,50 @@ +*** | (C) 2008-2025 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 + +$setglobal c20_scp_type sugar + +table f20_processing_balanceflow(t_all,i,ksd) Processing balance flow (mio. tDM) +$ondelim +$include "./modules/20_processing/input/f20_processing_balanceflow.cs3" +$offdelim ; + +table f20_processing_conversion_factors(t_all,processing20,ksd,kpr) Conversion factors of primary products into secondary products (1) +$ondelim +$include "./modules/20_processing/input/f20_processing_conversion_factors.cs3" +$offdelim ; + +table f20_processing_shares(t_all,i,ksd,kpr) Shares of secondary products coming from a primary product (1) +$ondelim +$include "./modules/20_processing/input/f20_processing_shares.cs3" +$offdelim ; + +table f20_processing_unitcosts(ksd,kpr) Costs of transforming x units kpr into 1 unit ksd (USD17MER per tDM) +$ondelim +$include "./modules/20_processing/input/f20_processing_unitcosts.cs3" +$offdelim ; + +table f20_quality_cost(ksd,kpr) Costs for difference in quality between secondary products from diverging origins (USD17MER per tDM) +$ondelim +$include "./modules/20_processing/substitution_may21/input/f20_quality_cost.cs3" +$offdelim ; + +table f20_scp_type_shr(scptype,scen20) selected scenario values for scp type (1) +$ondelim +$include "./modules/20_processing/input/f20_scp_type_shr.csv" +$offdelim; + +table f20_scp_processing_shares(kpr,scen20) Feedstock processing shares for SCP in different scenarios (1) +$ondelim +$include "./modules/20_processing/input/f20_scp_processing_shares.csv" +$offdelim; + +parameter f20_scp_unitcosts(scptype) Costs of production of one unit of SCP exclusive of feedstock costs (USD17MER per tDM) +/ +$ondelim +$include "./modules/20_processing/input/f20_scp_unitcosts.csv" +$offdelim +/; diff --git a/modules/20_processing/substitution_may21/input/files b/modules/20_processing/substitution_may21/input/files new file mode 100644 index 0000000000..9e6ed21b06 --- /dev/null +++ b/modules/20_processing/substitution_may21/input/files @@ -0,0 +1,2 @@ +* list of files that are required here +f20_quality_cost.cs3 diff --git a/modules/20_processing/substitution_may21/postsolve.gms b/modules/20_processing/substitution_may21/postsolve.gms new file mode 100644 index 0000000000..a893e16d99 --- /dev/null +++ b/modules/20_processing/substitution_may21/postsolve.gms @@ -0,0 +1,75 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_dem_processing(t,i,kall,"marginal") = vm_dem_processing.m(i,kall); + ov20_dem_processing(t,i,processing_subst20,kpr,"marginal") = v20_dem_processing.m(i,processing_subst20,kpr); + ov20_secondary_substitutes(t,i,ksd,kpr,"marginal") = v20_secondary_substitutes.m(i,ksd,kpr); + ov_secondary_overproduction(t,i,kall,kpr,"marginal") = vm_secondary_overproduction.m(i,kall,kpr); + ov_cost_processing(t,i,"marginal") = vm_cost_processing.m(i); + ov_processing_substitution_cost(t,i,"marginal") = vm_processing_substitution_cost.m(i); + oq20_processing(t,i,kpr,ksd,"marginal") = q20_processing.m(i,kpr,ksd); + oq20_processing_aggregation_nocereals(t,i,kpr,"marginal") = q20_processing_aggregation_nocereals.m(i,kpr); + oq20_processing_aggregation_cereals(t,i,kcereals20,"marginal") = q20_processing_aggregation_cereals.m(i,kcereals20); + oq20_processing_aggregation_cotton(t,i,"marginal") = q20_processing_aggregation_cotton.m(i); + oq20_processing_substitution_oils(t,i,"marginal") = q20_processing_substitution_oils.m(i); + oq20_processing_substitution_brans(t,i,"marginal") = q20_processing_substitution_brans.m(i); + oq20_processing_substitution_sugar(t,i,"marginal") = q20_processing_substitution_sugar.m(i); + oq20_processing_substitution_protein(t,i,"marginal") = q20_processing_substitution_protein.m(i); + oq20_processing_costs(t,i,"marginal") = q20_processing_costs.m(i); + oq20_substitution_utility_loss(t,i,"marginal") = q20_substitution_utility_loss.m(i); + ov_dem_processing(t,i,kall,"level") = vm_dem_processing.l(i,kall); + ov20_dem_processing(t,i,processing_subst20,kpr,"level") = v20_dem_processing.l(i,processing_subst20,kpr); + ov20_secondary_substitutes(t,i,ksd,kpr,"level") = v20_secondary_substitutes.l(i,ksd,kpr); + ov_secondary_overproduction(t,i,kall,kpr,"level") = vm_secondary_overproduction.l(i,kall,kpr); + ov_cost_processing(t,i,"level") = vm_cost_processing.l(i); + ov_processing_substitution_cost(t,i,"level") = vm_processing_substitution_cost.l(i); + oq20_processing(t,i,kpr,ksd,"level") = q20_processing.l(i,kpr,ksd); + oq20_processing_aggregation_nocereals(t,i,kpr,"level") = q20_processing_aggregation_nocereals.l(i,kpr); + oq20_processing_aggregation_cereals(t,i,kcereals20,"level") = q20_processing_aggregation_cereals.l(i,kcereals20); + oq20_processing_aggregation_cotton(t,i,"level") = q20_processing_aggregation_cotton.l(i); + oq20_processing_substitution_oils(t,i,"level") = q20_processing_substitution_oils.l(i); + oq20_processing_substitution_brans(t,i,"level") = q20_processing_substitution_brans.l(i); + oq20_processing_substitution_sugar(t,i,"level") = q20_processing_substitution_sugar.l(i); + oq20_processing_substitution_protein(t,i,"level") = q20_processing_substitution_protein.l(i); + oq20_processing_costs(t,i,"level") = q20_processing_costs.l(i); + oq20_substitution_utility_loss(t,i,"level") = q20_substitution_utility_loss.l(i); + ov_dem_processing(t,i,kall,"upper") = vm_dem_processing.up(i,kall); + ov20_dem_processing(t,i,processing_subst20,kpr,"upper") = v20_dem_processing.up(i,processing_subst20,kpr); + ov20_secondary_substitutes(t,i,ksd,kpr,"upper") = v20_secondary_substitutes.up(i,ksd,kpr); + ov_secondary_overproduction(t,i,kall,kpr,"upper") = vm_secondary_overproduction.up(i,kall,kpr); + ov_cost_processing(t,i,"upper") = vm_cost_processing.up(i); + ov_processing_substitution_cost(t,i,"upper") = vm_processing_substitution_cost.up(i); + oq20_processing(t,i,kpr,ksd,"upper") = q20_processing.up(i,kpr,ksd); + oq20_processing_aggregation_nocereals(t,i,kpr,"upper") = q20_processing_aggregation_nocereals.up(i,kpr); + oq20_processing_aggregation_cereals(t,i,kcereals20,"upper") = q20_processing_aggregation_cereals.up(i,kcereals20); + oq20_processing_aggregation_cotton(t,i,"upper") = q20_processing_aggregation_cotton.up(i); + oq20_processing_substitution_oils(t,i,"upper") = q20_processing_substitution_oils.up(i); + oq20_processing_substitution_brans(t,i,"upper") = q20_processing_substitution_brans.up(i); + oq20_processing_substitution_sugar(t,i,"upper") = q20_processing_substitution_sugar.up(i); + oq20_processing_substitution_protein(t,i,"upper") = q20_processing_substitution_protein.up(i); + oq20_processing_costs(t,i,"upper") = q20_processing_costs.up(i); + oq20_substitution_utility_loss(t,i,"upper") = q20_substitution_utility_loss.up(i); + ov_dem_processing(t,i,kall,"lower") = vm_dem_processing.lo(i,kall); + ov20_dem_processing(t,i,processing_subst20,kpr,"lower") = v20_dem_processing.lo(i,processing_subst20,kpr); + ov20_secondary_substitutes(t,i,ksd,kpr,"lower") = v20_secondary_substitutes.lo(i,ksd,kpr); + ov_secondary_overproduction(t,i,kall,kpr,"lower") = vm_secondary_overproduction.lo(i,kall,kpr); + ov_cost_processing(t,i,"lower") = vm_cost_processing.lo(i); + ov_processing_substitution_cost(t,i,"lower") = vm_processing_substitution_cost.lo(i); + oq20_processing(t,i,kpr,ksd,"lower") = q20_processing.lo(i,kpr,ksd); + oq20_processing_aggregation_nocereals(t,i,kpr,"lower") = q20_processing_aggregation_nocereals.lo(i,kpr); + oq20_processing_aggregation_cereals(t,i,kcereals20,"lower") = q20_processing_aggregation_cereals.lo(i,kcereals20); + oq20_processing_aggregation_cotton(t,i,"lower") = q20_processing_aggregation_cotton.lo(i); + oq20_processing_substitution_oils(t,i,"lower") = q20_processing_substitution_oils.lo(i); + oq20_processing_substitution_brans(t,i,"lower") = q20_processing_substitution_brans.lo(i); + oq20_processing_substitution_sugar(t,i,"lower") = q20_processing_substitution_sugar.lo(i); + oq20_processing_substitution_protein(t,i,"lower") = q20_processing_substitution_protein.lo(i); + oq20_processing_costs(t,i,"lower") = q20_processing_costs.lo(i); + oq20_substitution_utility_loss(t,i,"lower") = q20_substitution_utility_loss.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/20_processing/substitution_may21/preloop.gms b/modules/20_processing/substitution_may21/preloop.gms new file mode 100644 index 0000000000..89ff7ba445 --- /dev/null +++ b/modules/20_processing/substitution_may21/preloop.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + + +i20_processing_conversion_factors(t_all,processing20,ksd,kpr) = f20_processing_conversion_factors(t_all,processing20,ksd,kpr); +i20_processing_shares(t_all,i,ksd,kpr) = f20_processing_shares(t_all,i,ksd,kpr); +i20_processing_unitcosts(ksd,kpr) = f20_processing_unitcosts(ksd,kpr); + +*Costs for single-cell protein production (scp) are accounted for separately in f20_scp_unitcosts (see 'q20_processing_costs'). +*Separate accounting is needed because scp_hydrogen has no land requirements, and thus otherwise would have no costs. +*To avoid double accounting the processing costs of scp_methane, scp_sugar and scp_cellulose are set to zero. +i20_processing_unitcosts("scp",kpr) = 0; + +*SCP can be produced via different routes. The processing shares for SCP are scenario dependent (c20_scp_type). +i20_processing_shares(t_all,i,"scp",kpr) = 0; +i20_processing_shares(t_all,i,"scp",kpr) = f20_scp_processing_shares(kpr,"%c20_scp_type%"); diff --git a/modules/20_processing/substitution_may21/presolve.gms b/modules/20_processing/substitution_may21/presolve.gms new file mode 100644 index 0000000000..2cbb5f9d23 --- /dev/null +++ b/modules/20_processing/substitution_may21/presolve.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2025 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_dem_processing.fx(i,knpr)=0; + +vm_secondary_overproduction.fx(i2,kall,kpr)=0; +vm_secondary_overproduction.up(i2,ksd,kpr)=Inf; + +v20_secondary_substitutes.fx(i2,ksd,kpr)=0; +v20_secondary_substitutes.up(i2,"oils",kpr)=Inf; +v20_secondary_substitutes.up(i2,"molasses",kpr)=Inf; +v20_secondary_substitutes.up(i2,"distillers_grain",kpr)=Inf; +v20_secondary_substitutes.up(i2,"oilcakes",kpr)=Inf; +v20_secondary_substitutes.up(i2,"brans",kcereals20)=Inf; diff --git a/modules/20_processing/substitution_may21/realization.gms b/modules/20_processing/substitution_may21/realization.gms new file mode 100644 index 0000000000..efe482d1b3 --- /dev/null +++ b/modules/20_processing/substitution_may21/realization.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2025 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 +*' The realization substitution_may21 excludes the calibration factors that are used in substitution_dec18 in order to reduce the substitution of oils by other oils. +*' +*' @authors Benjamin Leon Bodirsky, Florian Humpenöder, Edna Molina Bacca + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/20_processing/substitution_may21/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/20_processing/substitution_may21/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/20_processing/substitution_may21/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/20_processing/substitution_may21/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/20_processing/substitution_may21/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/20_processing/substitution_may21/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/20_processing/substitution_may21/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/20_processing/substitution_may21/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/20_processing/substitution_may21/scaling.gms b/modules/20_processing/substitution_may21/scaling.gms new file mode 100644 index 0000000000..c4a705c835 --- /dev/null +++ b/modules/20_processing/substitution_may21/scaling.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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_cost_processing.scale(i) = 10e5; +vm_processing_substitution_cost.scale(i) = 10e4; diff --git a/modules/20_processing/substitution_may21/sets.gms b/modules/20_processing/substitution_may21/sets.gms new file mode 100644 index 0000000000..b8e574465f --- /dev/null +++ b/modules/20_processing/substitution_may21/sets.gms @@ -0,0 +1,41 @@ +*** | (C) 2008-2025 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 + +kpr(kall) Products that can be processed + /tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,oilpalm, + potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro,brans,begr,betr,foddr, + sugar,molasses,oils,oilcakes/ + +knpr(kall) Products that cannot be processed + /alcohol,distillers_grain,ethanol,fibres,fish,livst_chick,livst_egg,livst_milk, + livst_pig,livst_rum,oilcakes,pasture,puls_pro,res_cereals,res_fibrous, + res_nonfibrous,scp,wood,woodfuel/ + +processing_subst20 Processing activities +/ milling, refining, extracting, distilling, fermentation, breeding, ginning, substitutes / + +processing20(processing_subst20) Processing activities except substitution +/ milling, refining, extracting, distilling, fermentation, breeding, ginning / + +kcereals20(kpr) Cereals used for processing +/tece,maiz,trce,rice_pro/ + +no_milling_ginning20(processing_subst20) Processing activities without milling and ginning +/refining, extracting, distilling, fermentation, breeding, substitutes / + +oilcake_substitutes20(kpr) products that can be substituted for oilcakes + /soybean,rapeseed,groundnut,sunflower,oilpalm,cottn_pro,oilcakes/ + + scptype different types of scp + /scp_methane,scp_sugar,scp_cellulose,scp_hydrogen/ + + scen20 scenario of type of scp + / mixed, methane, sugar, cellulose,hydrogen / + +; diff --git a/modules/21_trade/exo/declarations.gms b/modules/21_trade/exo/declarations.gms new file mode 100644 index 0000000000..180b6dc3bf --- /dev/null +++ b/modules/21_trade/exo/declarations.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2025 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 + i21_trade_margin(h,k_trade) Trade margins (USD17MER per tDM) + i21_trade_tariff(h,k_trade) Trade tariffs (USD17MER per tDM) +; + +positive variables + vm_cost_trade(i) Regional trade costs (mio. USD17MER per yr) + v21_cost_trade_reg(h,k_trade) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) +; + +equations + q21_notrade(h,kall) Superregional production constraint of non-tradable commodities (mio. tDM per yr) + q21_cost_trade(h) Superregional trade costs (mio. USD17MER per yr) + q21_cost_trade_reg(h,k_trade) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_trade(t,i,type) Regional trade costs (mio. USD17MER per yr) + ov21_cost_trade_reg(t,h,k_trade,type) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) + oq21_notrade(t,h,kall,type) Superregional production constraint of non-tradable commodities (mio. tDM per yr) + oq21_cost_trade(t,h,type) Superregional trade costs (mio. USD17MER per yr) + oq21_cost_trade_reg(t,h,k_trade,type) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/21_trade/exo/equations.gms b/modules/21_trade/exo/equations.gms new file mode 100644 index 0000000000..c7c6efd22e --- /dev/null +++ b/modules/21_trade/exo/equations.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 + +*' The regional production must be larger than the regional demand plus exports +*' from that region (or minus imports in case of a negative trade balance). + +q21_notrade(h2,kall).. + sum(supreg(h2,i2),vm_prod_reg(i2,kall)) =g= sum(supreg(h2,i2), vm_supply(i2,kall)) + + sum(ct,f21_trade_balance(ct,h2,kall)); + +* Trade costs are associated with exporting superregions. They are dependent on net exports, trade margin, and tariffs. + + q21_cost_trade_reg(h2,k_trade).. + v21_cost_trade_reg(h2,k_trade) =g= + (i21_trade_margin(h2,k_trade) + i21_trade_tariff(h2,k_trade)) + *sum(supreg(h2,i2), vm_prod_reg(i2,k_trade) - vm_supply(i2,k_trade)); + +* Superregional trade costs are the costs for each superregion aggregated over all the tradable commodities. + + q21_cost_trade(h2).. + sum(supreg(h2,i2),vm_cost_trade(i2)) =e= sum(k_trade,v21_cost_trade_reg(h2,k_trade)); diff --git a/modules/21_trade/exo/input.gms b/modules/21_trade/exo/input.gms new file mode 100644 index 0000000000..ccc5ccf904 --- /dev/null +++ b/modules/21_trade/exo/input.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2025 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 + s21_trade_tariff Trade tariff switch (1=on 0=off) (1) / 1 / + s21_min_trade_margin_forestry Minimum trade margin for forestry products (USD17MER per tDM) / 62 / +; + +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" +$offdelim; + +table f21_trade_margin(h,kall) Costs of freight and insurance (USD17MER per tDM) +$ondelim +$include "./modules/21_trade/input/f21_trade_margin.cs3" +$offdelim +; + +table f21_trade_tariff(h,kall) Specific duty tariffs (USD17MER per tDM) +$ondelim +$include "./modules/21_trade/input/f21_trade_tariff.cs3" +$offdelim +; diff --git a/modules/21_trade/exo/not_used.txt b/modules/21_trade/exo/not_used.txt new file mode 100644 index 0000000000..4dd79412da --- /dev/null +++ b/modules/21_trade/exo/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2,input,not needed diff --git a/modules/21_trade/exo/postsolve.gms b/modules/21_trade/exo/postsolve.gms new file mode 100644 index 0000000000..648e85f6c2 --- /dev/null +++ b/modules/21_trade/exo/postsolve.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2025 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 + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); + ov21_cost_trade_reg(t,h,k_trade,"marginal") = v21_cost_trade_reg.m(h,k_trade); + oq21_notrade(t,h,kall,"marginal") = q21_notrade.m(h,kall); + oq21_cost_trade(t,h,"marginal") = q21_cost_trade.m(h); + oq21_cost_trade_reg(t,h,k_trade,"marginal") = q21_cost_trade_reg.m(h,k_trade); + ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); + ov21_cost_trade_reg(t,h,k_trade,"level") = v21_cost_trade_reg.l(h,k_trade); + oq21_notrade(t,h,kall,"level") = q21_notrade.l(h,kall); + oq21_cost_trade(t,h,"level") = q21_cost_trade.l(h); + oq21_cost_trade_reg(t,h,k_trade,"level") = q21_cost_trade_reg.l(h,k_trade); + ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); + ov21_cost_trade_reg(t,h,k_trade,"upper") = v21_cost_trade_reg.up(h,k_trade); + oq21_notrade(t,h,kall,"upper") = q21_notrade.up(h,kall); + oq21_cost_trade(t,h,"upper") = q21_cost_trade.up(h); + oq21_cost_trade_reg(t,h,k_trade,"upper") = q21_cost_trade_reg.up(h,k_trade); + ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); + ov21_cost_trade_reg(t,h,k_trade,"lower") = v21_cost_trade_reg.lo(h,k_trade); + oq21_notrade(t,h,kall,"lower") = q21_notrade.lo(h,kall); + oq21_cost_trade(t,h,"lower") = q21_cost_trade.lo(h); + oq21_cost_trade_reg(t,h,k_trade,"lower") = q21_cost_trade_reg.lo(h,k_trade); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/21_trade/exo/preloop.gms b/modules/21_trade/exo/preloop.gms new file mode 100644 index 0000000000..fe777798e3 --- /dev/null +++ b/modules/21_trade/exo/preloop.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2025 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 + + +i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); + +if ((s21_trade_tariff=1), + i21_trade_tariff(h,k_trade) = f21_trade_tariff(h,k_trade); +elseif (s21_trade_tariff=0), + i21_trade_tariff(h,k_trade) = 0; +); + +i21_trade_margin(h,"wood")$(i21_trade_margin(h,"wood") < s21_min_trade_margin_forestry) = s21_min_trade_margin_forestry; +i21_trade_margin(h,"woodfuel")$(i21_trade_margin(h,"woodfuel") < s21_min_trade_margin_forestry) = s21_min_trade_margin_forestry; + diff --git a/modules/21_trade/exo/realization.gms b/modules/21_trade/exo/realization.gms new file mode 100644 index 0000000000..6640fc52b5 --- /dev/null +++ b/modules/21_trade/exo/realization.gms @@ -0,0 +1,24 @@ +*** | (C) 2008-2025 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, agricultural trade is fully prescribed +*' exogenously. This also means that there is no interaction between regions +*' as amounts of exports and imports are fix. + + +*' @limitations regions are completely separated and do not interact with +*' each other + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/21_trade/exo/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/21_trade/exo/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/21_trade/exo/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/21_trade/exo/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/21_trade/exo/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/21_trade/exo/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/21_trade/exo/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/21_trade/exo/scaling.gms b/modules/21_trade/exo/scaling.gms new file mode 100644 index 0000000000..0140087274 --- /dev/null +++ b/modules/21_trade/exo/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_cost_trade.scale(i) = 10e4; diff --git a/modules/21_trade/exo/sets.gms b/modules/21_trade/exo/sets.gms new file mode 100644 index 0000000000..3c06fc5489 --- /dev/null +++ b/modules/21_trade/exo/sets.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 + tstart21(t_all) Historic time steps + / y1995, y2000, y2005, y2010 / + +*sets need to be adopted to new categories + k_notrade(kall) Production activities of non-tradable commodites + / oilpalm, foddr, pasture, res_cereals, res_fibrous, res_nonfibrous,begr,betr / +* oilpalm not traded, only its oil and oilcake due to FAOSTAT complications, and as trade is little +* foddr is not traded as too bulky +* pasture it not traded as too bulky +* begr and betr are not traded because biomass is traded in REMIND + k_trade(kall) Production activities of tradable commodities + / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, + potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro, + oils,oilcakes,sugar,molasses,alcohol,ethanol,distillers_grain,brans,scp,fibres, + livst_rum, livst_pig,livst_chick, livst_egg, livst_milk, fish, wood, woodfuel / + +; diff --git a/modules/21_trade/free_apr16/declarations.gms b/modules/21_trade/free_apr16/declarations.gms deleted file mode 100644 index 6f945a5a8f..0000000000 --- a/modules/21_trade/free_apr16/declarations.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 - - -positive variables - vm_cost_trade(i) Regional trade costs (mio. USD05MER per yr) -; - -equations - q21_trade_glo(k_trade) Global production constraint (mio. tDM per yr) - q21_notrade(i,k_notrade) Regional production constraint of non-tradable commodities (mio. tDM per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_trade(t,i,type) Regional trade costs (mio. USD05MER per yr) - oq21_trade_glo(t,k_trade,type) Global production constraint (mio. tDM per yr) - oq21_notrade(t,i,k_notrade,type) Regional production constraint of non-tradable commodities (mio. tDM per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/21_trade/free_apr16/equations.gms b/modules/21_trade/free_apr16/equations.gms deleted file mode 100644 index acad8e056b..0000000000 --- a/modules/21_trade/free_apr16/equations.gms +++ /dev/null @@ -1,10 +0,0 @@ -*** | (C) 2008-2019 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 - - q21_trade_glo(k_trade).. sum(i2 ,vm_prod_reg(i2,k_trade)) =g= sum(i2, vm_supply(i2,k_trade)); - - q21_notrade(i2,k_notrade).. vm_prod_reg(i2,k_notrade) =g= vm_supply(i2,k_notrade); diff --git a/modules/21_trade/free_apr16/not_used.txt b/modules/21_trade/free_apr16/not_used.txt deleted file mode 100644 index d78901bb63..0000000000 --- a/modules/21_trade/free_apr16/not_used.txt +++ /dev/null @@ -1,7 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason diff --git a/modules/21_trade/free_apr16/postsolve.gms b/modules/21_trade/free_apr16/postsolve.gms deleted file mode 100644 index 065984e0eb..0000000000 --- a/modules/21_trade/free_apr16/postsolve.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); - oq21_trade_glo(t,k_trade,"marginal") = q21_trade_glo.m(k_trade); - oq21_notrade(t,i,k_notrade,"marginal") = q21_notrade.m(i,k_notrade); - ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); - oq21_trade_glo(t,k_trade,"level") = q21_trade_glo.l(k_trade); - oq21_notrade(t,i,k_notrade,"level") = q21_notrade.l(i,k_notrade); - ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); - oq21_trade_glo(t,k_trade,"upper") = q21_trade_glo.up(k_trade); - oq21_notrade(t,i,k_notrade,"upper") = q21_notrade.up(i,k_notrade); - ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); - oq21_trade_glo(t,k_trade,"lower") = q21_trade_glo.lo(k_trade); - oq21_notrade(t,i,k_notrade,"lower") = q21_notrade.lo(i,k_notrade); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/21_trade/free_apr16/preloop.gms b/modules/21_trade/free_apr16/preloop.gms deleted file mode 100644 index 04689a87ff..0000000000 --- a/modules/21_trade/free_apr16/preloop.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*set vm_cost_trade zero in order to avoid a free variable -vm_cost_trade.fx(i) = 0; diff --git a/modules/21_trade/free_apr16/realization.gms b/modules/21_trade/free_apr16/realization.gms deleted file mode 100644 index 7f1145f358..0000000000 --- a/modules/21_trade/free_apr16/realization.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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, agricultural trade is fully liberalized in all timesteps. - -*' @limitations This realization does not account for current trends in agricultural trade. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/21_trade/free_apr16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/21_trade/free_apr16/declarations.gms" -$Ifi "%phase%" == "equations" $include "./modules/21_trade/free_apr16/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/21_trade/free_apr16/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/21_trade/free_apr16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/21_trade/free_apr16/sets.gms b/modules/21_trade/free_apr16/sets.gms deleted file mode 100644 index 80c1071f41..0000000000 --- a/modules/21_trade/free_apr16/sets.gms +++ /dev/null @@ -1,17 +0,0 @@ -*** | (C) 2008-2019 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 - k_trade(k) Production activities of tradable commodities - / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - cottn_pro, livst_rum, livst_pig, - livst_chick, livst_egg, livst_milk / - - k_notrade(k) Production activities of non-tradable commodities - / begr, betr, foddr, pasture / -; diff --git a/modules/21_trade/input/files b/modules/21_trade/input/files index 47bd9569f4..5b70512a5d 100644 --- a/modules/21_trade/input/files +++ b/modules/21_trade/input/files @@ -1,9 +1,8 @@ * list of files that are required here f21_trade_self_suff.cs3 -f21_trade_export_share.cs3 +f21_trade_domestic_supply.cs3 f21_trade_balanceflow.cs3 f21_trade_margin.cs3 f21_trade_tariff.cs3 -f21_trade_tariff_export.cs3 -f21_trade_tariff_import.cs3 +f21_trade_balance.cs3 f21_trade_bal_reduction.cs3 diff --git a/modules/21_trade/module.gms b/modules/21_trade/module.gms index 80518d0021..0e62aed9df 100644 --- a/modules/21_trade/module.gms +++ b/modules/21_trade/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,7 +7,7 @@ *' @title Agricultural trade *' -*' @description This module represents agricutlural trade among world regions. +*' @description This module represents agricultural trade among world regions. *' It ensures that the regional demand is met by domestic production and imports from other regions. *' The global trade balance dictates that global production must be larger than or equal to global demand. *' For non-traded goods, the regional production must be larger than or equal to regional demand. @@ -15,7 +15,7 @@ *' *' @authors Xiaoxi Wang, Anne Biewald, Christoph Schmitz, Markus Bonsch *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%trade%" == "free_apr16" $include "./modules/21_trade/free_apr16/realization.gms" -$Ifi "%trade%" == "off" $include "./modules/21_trade/off/realization.gms" +$Ifi "%trade%" == "exo" $include "./modules/21_trade/exo/realization.gms" $Ifi "%trade%" == "selfsuff_reduced" $include "./modules/21_trade/selfsuff_reduced/realization.gms" +$Ifi "%trade%" == "selfsuff_reduced_bilateral22" $include "./modules/21_trade/selfsuff_reduced_bilateral22/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/21_trade/off/declarations.gms b/modules/21_trade/off/declarations.gms deleted file mode 100644 index 5398e1aba1..0000000000 --- a/modules/21_trade/off/declarations.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - - -positive variables - vm_cost_trade(i) Regional trade costs (mio. USD05MER per yr) -; - -equations - q21_notrade(i,k) Regional production constraint of non-tradable commodities (mio. tDM per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_trade(t,i,type) Regional trade costs (mio. USD05MER per yr) - oq21_notrade(t,i,k,type) Regional production constraint of non-tradable commodities (mio. tDM per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/21_trade/off/equations.gms b/modules/21_trade/off/equations.gms deleted file mode 100644 index 8aeedb6448..0000000000 --- a/modules/21_trade/off/equations.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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 - - q21_notrade(i2,k).. vm_prod_reg(i2,k) =g= vm_supply(i2,k); diff --git a/modules/21_trade/off/not_used.txt b/modules/21_trade/off/not_used.txt deleted file mode 100644 index d78901bb63..0000000000 --- a/modules/21_trade/off/not_used.txt +++ /dev/null @@ -1,7 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason diff --git a/modules/21_trade/off/postsolve.gms b/modules/21_trade/off/postsolve.gms deleted file mode 100644 index f1229689ca..0000000000 --- a/modules/21_trade/off/postsolve.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); - oq21_notrade(t,i,k,"marginal") = q21_notrade.m(i,k); - ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); - oq21_notrade(t,i,k,"level") = q21_notrade.l(i,k); - ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); - oq21_notrade(t,i,k,"upper") = q21_notrade.up(i,k); - ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); - oq21_notrade(t,i,k,"lower") = q21_notrade.lo(i,k); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/21_trade/off/preloop.gms b/modules/21_trade/off/preloop.gms deleted file mode 100644 index 04689a87ff..0000000000 --- a/modules/21_trade/off/preloop.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*set vm_cost_trade zero in order to avoid a free variable -vm_cost_trade.fx(i) = 0; diff --git a/modules/21_trade/off/realization.gms b/modules/21_trade/off/realization.gms deleted file mode 100644 index db8a2f062a..0000000000 --- a/modules/21_trade/off/realization.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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, there is no agricultural trade, i.e. regions -*' are fully self-sufficient and dependent on domestic production. - -*' @limitations This realization does not account for current trends in agricultural trade. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/21_trade/off/declarations.gms" -$Ifi "%phase%" == "equations" $include "./modules/21_trade/off/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/21_trade/off/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/21_trade/off/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/21_trade/selfsuff_reduced/declarations.gms b/modules/21_trade/selfsuff_reduced/declarations.gms index 633cd91ee2..ccf11f6a03 100644 --- a/modules/21_trade/selfsuff_reduced/declarations.gms +++ b/modules/21_trade/selfsuff_reduced/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,41 +7,46 @@ parameters i21_trade_bal_reduction(t_all,k_trade) Trade balance reduction (1) - i21_trade_margin(i,k_trade) Trade margins (USD05MER per tDM) - i21_trade_tariff(i,k_trade) Trade tariffs (USD05MER per tDM) + i21_exp_shr(t_all,h,k_trade) Trade export shr (1) + i21_trade_margin(h,k_trade) Trade margins (USD17MER per tDM) + i21_trade_tariff(h,k_trade) Trade tariffs (USD17MER per tDM) + i21_exports(t_all,h,k_trade) Total exports (tDM) + i21_exp_glo(t_all,k_trade) Total global exports (tDM) ; positive variables v21_excess_dem(k_trade) Global excess demand (mio. tDM per yr) - v21_excess_prod(i,k_trade) Regional excess production (mio. tDM per yr) - vm_cost_trade(i) Regional trade costs (mio. USD05MER per yr) - v21_cost_trade_reg(i,k_trade) Regional trade costs for each tradable commodity (mio. USD05MER per yr) + v21_excess_prod(h,k_trade) Superregional excess production (mio. tDM per yr) + vm_cost_trade(i) Regional trade costs (mio. USD17MER per yr) + v21_cost_trade_reg(h,k_trade) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) + v21_import_for_feasibility(h,k_trade) Additional imports to maintain feasibility (mio. tDM per yr) ; equations q21_trade_glo(k_trade) Global production constraint (mio. tDM per yr) - q21_notrade(i,k_notrade) Regional production constraint of non-tradable commodities (mio. tDM per yr) - q21_trade_reg(i,k_trade) Regional trade balances i.e. minimum self-sufficiency ratio (1) - q21_trade_reg_up(i,k_trade) Regional trade balances i.e. maximum self-sufficiency ratio (1) + q21_notrade(h,k_notrade) Superregional production constraint of non-tradable commodities (mio. tDM per yr) + q21_trade_reg(h,k_trade) Superregional trade balances i.e. minimum self-sufficiency ratio (1) + q21_trade_reg_up(h,k_trade) Superregional trade balances i.e. maximum self-sufficiency ratio (1) q21_excess_dem(k_trade) Global excess demand (mio. tDM per yr) - q21_excess_supply(i,k_trade) Regional excess production (mio. tDM per yr) - q21_cost_trade(i) Regional trade costs (mio. USD05MER per yr) - q21_cost_trade_reg(i,k_trade) Regional trade costs for each tradable commodity (mio. USD05MER per yr) + q21_excess_supply(h,k_trade) Superregional excess production (mio. tDM per yr) + q21_cost_trade(h) Superregional trade costs (mio. USD17MER per yr) + q21_cost_trade_reg(h,k_trade) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov21_excess_dem(t,k_trade,type) Global excess demand (mio. tDM per yr) - ov21_excess_prod(t,i,k_trade,type) Regional excess production (mio. tDM per yr) - ov_cost_trade(t,i,type) Regional trade costs (mio. USD05MER per yr) - ov21_cost_trade_reg(t,i,k_trade,type) Regional trade costs for each tradable commodity (mio. USD05MER per yr) - oq21_trade_glo(t,k_trade,type) Global production constraint (mio. tDM per yr) - oq21_notrade(t,i,k_notrade,type) Regional production constraint of non-tradable commodities (mio. tDM per yr) - oq21_trade_reg(t,i,k_trade,type) Regional trade balances i.e. minimum self-sufficiency ratio (1) - oq21_trade_reg_up(t,i,k_trade,type) Regional trade balances i.e. maximum self-sufficiency ratio (1) - oq21_excess_dem(t,k_trade,type) Global excess demand (mio. tDM per yr) - oq21_excess_supply(t,i,k_trade,type) Regional excess production (mio. tDM per yr) - oq21_cost_trade(t,i,type) Regional trade costs (mio. USD05MER per yr) - oq21_cost_trade_reg(t,i,k_trade,type) Regional trade costs for each tradable commodity (mio. USD05MER per yr) + ov21_excess_dem(t,k_trade,type) Global excess demand (mio. tDM per yr) + ov21_excess_prod(t,h,k_trade,type) Superregional excess production (mio. tDM per yr) + ov_cost_trade(t,i,type) Regional trade costs (mio. USD17MER per yr) + ov21_cost_trade_reg(t,h,k_trade,type) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) + ov21_import_for_feasibility(t,h,k_trade,type) Additional imports to maintain feasibility (mio. tDM per yr) + oq21_trade_glo(t,k_trade,type) Global production constraint (mio. tDM per yr) + oq21_notrade(t,h,k_notrade,type) Superregional production constraint of non-tradable commodities (mio. tDM per yr) + oq21_trade_reg(t,h,k_trade,type) Superregional trade balances i.e. minimum self-sufficiency ratio (1) + oq21_trade_reg_up(t,h,k_trade,type) Superregional trade balances i.e. maximum self-sufficiency ratio (1) + oq21_excess_dem(t,k_trade,type) Global excess demand (mio. tDM per yr) + oq21_excess_supply(t,h,k_trade,type) Superregional excess production (mio. tDM per yr) + oq21_cost_trade(t,h,type) Superregional trade costs (mio. USD17MER per yr) + oq21_cost_trade_reg(t,h,k_trade,type) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/21_trade/selfsuff_reduced/equations.gms b/modules/21_trade/selfsuff_reduced/equations.gms index cf08fc9cc5..0c387ac850 100644 --- a/modules/21_trade/selfsuff_reduced/equations.gms +++ b/modules/21_trade/selfsuff_reduced/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,65 +6,66 @@ *** | Contact: magpie@pik-potsdam.de *' @equations -*' In the comparative advantage pool, the only active constraint is that the global supply is larger or equal to demand. +*' In the comparative advantage pool, the main constraint is that the global supply is larger or equal to demand. *' This means that production can be freely allocated globally based on comparative advantages. q21_trade_glo(k_trade).. sum(i2 ,vm_prod_reg(i2,k_trade)) =g= sum(i2, vm_supply(i2,k_trade)) + sum(ct,f21_trade_balanceflow(ct,k_trade)); + *' -*' For non-tradable commodites, the regional supply should be larger or equal to the regional demand. - q21_notrade(i2,k_notrade).. - vm_prod_reg(i2,k_notrade) =g= vm_supply(i2,k_notrade); +*' For non-tradable commodites, the superregional supply should be larger or equal to the superregional demand. + q21_notrade(h2,k_notrade).. + sum(supreg(h2,i2),vm_prod_reg(i2,k_notrade)) =g= sum(supreg(h2,i2), vm_supply(i2,k_notrade)); -*' The following equation indicates the regional trade constraint for the self-sufficiency pool. -*' The share of regional demand that has to be fulfilled through the self-sufficiency pool is +*' +*' The following equations define the production band. +*' The share of demand that has to be fulfilled through the self-sufficiency pool is *' determined by a trade balance reduction factor for each commodity `i21_trade_bal_reduction(ct,k_trade)` -*' according to the following equations [@schmitz_trading_2012]. -*' If the trade balance reduction equals 1 (`f21_self_suff(ct,i2,k_trade) = 1`), all demand enters the self-sufficiency pool. +*' [@schmitz_trading_2012]. If the trade balance reduction equals 1, all demand enters the self-sufficiency pool. *' If it equals 0, all demand enters the comparative advantage pool. +*' Note that `m21_baseline_production` is a macro defined in core/macros.gms. +*' Lower bound for production. - q21_trade_reg(i2,k_trade).. - vm_prod_reg(i2,k_trade) =g= - (vm_supply(i2,k_trade) + v21_excess_prod(i2,k_trade)) - *sum(ct,i21_trade_bal_reduction(ct,k_trade)) - $(sum(ct,f21_self_suff(ct,i2,k_trade) >= 1)) - + vm_supply(i2,k_trade)*sum(ct,f21_self_suff(ct,i2,k_trade)) - *sum(ct,i21_trade_bal_reduction(ct,k_trade)) - $(sum(ct,f21_self_suff(ct,i2,k_trade) < 1)); - + q21_trade_reg(h2,k_trade).. + sum(supreg(h2,i2),vm_prod_reg(i2,k_trade)) =g= + m21_baseline_production(vm_supply, v21_excess_prod, f21_self_suff) + * sum(ct,i21_trade_bal_reduction(ct,k_trade)) + - v21_import_for_feasibility(h2,k_trade); +*' Upper bound for production. - q21_trade_reg_up(i2,k_trade).. - vm_prod_reg(i2,k_trade) =l= - ((vm_supply(i2,k_trade) + v21_excess_prod(i2,k_trade))/sum(ct,i21_trade_bal_reduction(ct,k_trade))) - $(sum(ct,f21_self_suff(ct,i2,k_trade) >= 1)) - + (vm_supply(i2,k_trade)*sum(ct,f21_self_suff(ct,i2,k_trade))/sum(ct,i21_trade_bal_reduction(ct,k_trade))) - $(sum(ct,f21_self_suff(ct,i2,k_trade) < 1)); + q21_trade_reg_up(h2,k_trade) .. + sum(supreg(h2,i2),vm_prod_reg(i2,k_trade)) =l= + m21_baseline_production(vm_supply, v21_excess_prod, f21_self_suff) + / sum(ct,i21_trade_bal_reduction(ct,k_trade)); *' The global excess demand of each tradable good `v21_excess_demad` equals to -*' the sum over all the imports of importing regions. +*' the sum over all the imports of importing superregions. q21_excess_dem(k_trade).. v21_excess_dem(k_trade) =g= - sum(i2, vm_supply(i2,k_trade)*(1 - sum(ct,f21_self_suff(ct,i2,k_trade))) - $(sum(ct,f21_self_suff(ct,i2,k_trade)) < 1)) - + sum(ct,f21_trade_balanceflow(ct,k_trade)); + sum(h2, sum(supreg(h2,i2),vm_supply(i2,k_trade))*(1 - sum(ct,f21_self_suff(ct,h2,k_trade))) + $(sum(ct,f21_self_suff(ct,h2,k_trade)) < 1)) + + sum(ct,f21_trade_balanceflow(ct,k_trade)) + sum(h2, v21_import_for_feasibility(h2,k_trade)); + +*' Distributing the global excess demand to exporting superregions is based on export shares [@schmitz_trading_2012]. +*' Export shares are derived from FAO data (see @schmitz_trading_2012 for details). They are 0 for importing superregions. + + q21_excess_supply(h2,k_trade).. + v21_excess_prod(h2,k_trade) =e= + v21_excess_dem(k_trade)*sum(ct,i21_exp_shr(ct,h2,k_trade)); -*' Distributing the global excess demand to exporting regions is based on regional export shares [@schmitz_trading_2012]. -*' Export shares are derived from FAO data (see @schmitz_trading_2012 for details). They are 0 for importing regions. +* Trade costs are associated with exporting superregions. They are dependent on net exports, trade margin, and tariffs. - q21_excess_supply(i2,k_trade).. - v21_excess_prod(i2,k_trade) =e= - v21_excess_dem(k_trade)*sum(ct,f21_exp_shr(ct,i2,k_trade)); + q21_cost_trade_reg(h2,k_trade).. + v21_cost_trade_reg(h2,k_trade) =g= + (i21_trade_margin(h2,k_trade) + i21_trade_tariff(h2,k_trade)) + *sum(supreg(h2,i2), vm_prod_reg(i2,k_trade)-vm_supply(i2,k_trade)) + + v21_import_for_feasibility(h2,k_trade) * s21_cost_import; -* Trade costs are associated with exporting regions. They are dependent on net exports, trade margin, and tariffs. - q21_cost_trade_reg(i2,k_trade).. - v21_cost_trade_reg(i2,k_trade) =g= - (i21_trade_margin(i2,k_trade) + i21_trade_tariff(i2,k_trade)) - *(vm_prod_reg(i2,k_trade)-vm_supply(i2,k_trade)); +* Superregional trade costs are the costs for each superregion aggregated over all the tradable commodities. -* Regional trade costs are the costs for each region aggregated over all the tradable commodities. - q21_cost_trade(i2).. - vm_cost_trade(i2) =e= sum(k_trade,v21_cost_trade_reg(i2,k_trade)); + q21_cost_trade(h2).. + sum(supreg(h2,i2),vm_cost_trade(i2)) =e= sum(k_trade,v21_cost_trade_reg(h2,k_trade)); diff --git a/modules/21_trade/selfsuff_reduced/input.gms b/modules/21_trade/selfsuff_reduced/input.gms index b9c491a893..6cfe28dffd 100644 --- a/modules/21_trade/selfsuff_reduced/input.gms +++ b/modules/21_trade/selfsuff_reduced/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,8 +8,15 @@ $setglobal c21_trade_liberalization l909090r808080 * options are "regionalized" and "globalized" and "fragmented" +sets + k_import21(k_trade) Commodities that can have additional imports to maintain feasibility + / wood, woodfuel / +; + scalars s21_trade_tariff Trade tariff switch (1=on 0=off) (1) / 1 / + s21_cost_import Cost for additional imports to maintain feasibility (USD17MER per tDM) / 1500 / + s21_min_trade_margin_forestry Minimum trade margin for forestry products (USD17MER per tDM) / 62 / ; table f21_trade_bal_reduction(t_all,trade_groups21,trade_regime21) Share of inelastic trade pool (1) @@ -17,14 +24,14 @@ $ondelim $include "./modules/21_trade/input/f21_trade_bal_reduction.cs3" $offdelim; -table f21_self_suff(t_all,i,kall) Regional self-sufficiency rates (1) +table f21_self_suff(t_all,h,kall) Superregional self-sufficiency rates (1) $ondelim $include "./modules/21_trade/input/f21_trade_self_suff.cs3" $offdelim; -table f21_exp_shr(t_all,i,kall) Regional and crop-specific export share (1) +table f21_dom_supply(t_all,h,kall) Superregional domestic supply (mio. tDM per yr) $ondelim -$include "./modules/21_trade/input/f21_trade_export_share.cs3" +$include "./modules/21_trade/input/f21_trade_domestic_supply.cs3" $offdelim; table f21_trade_balanceflow(t_all,kall) Domestic balance flows (mio. tDM per yr) @@ -32,13 +39,13 @@ $ondelim $include "./modules/21_trade/input/f21_trade_balanceflow.cs3" $offdelim; -table f21_trade_margin(i,kall) Costs of freight and insurance (USD05MER per tDM) +table f21_trade_margin(h,kall) Costs of freight and insurance (USD17MER per tDM) $ondelim $include "./modules/21_trade/input/f21_trade_margin.cs3" $offdelim ; -table f21_trade_tariff(i,kall) Specific duty tariffs (USD05MER per tDM) +table f21_trade_tariff(h,kall) Specific duty tariffs (USD17MER per tDM) $ondelim $include "./modules/21_trade/input/f21_trade_tariff.cs3" $offdelim diff --git a/modules/21_trade/selfsuff_reduced/postsolve.gms b/modules/21_trade/selfsuff_reduced/postsolve.gms index 4fe441c982..8a9e1fd690 100644 --- a/modules/21_trade/selfsuff_reduced/postsolve.gms +++ b/modules/21_trade/selfsuff_reduced/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,52 +6,56 @@ *** | Contact: magpie@pik-potsdam.de *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov21_excess_dem(t,k_trade,"marginal") = v21_excess_dem.m(k_trade); - ov21_excess_prod(t,i,k_trade,"marginal") = v21_excess_prod.m(i,k_trade); - ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); - ov21_cost_trade_reg(t,i,k_trade,"marginal") = v21_cost_trade_reg.m(i,k_trade); - oq21_trade_glo(t,k_trade,"marginal") = q21_trade_glo.m(k_trade); - oq21_notrade(t,i,k_notrade,"marginal") = q21_notrade.m(i,k_notrade); - oq21_trade_reg(t,i,k_trade,"marginal") = q21_trade_reg.m(i,k_trade); - oq21_trade_reg_up(t,i,k_trade,"marginal") = q21_trade_reg_up.m(i,k_trade); - oq21_excess_dem(t,k_trade,"marginal") = q21_excess_dem.m(k_trade); - oq21_excess_supply(t,i,k_trade,"marginal") = q21_excess_supply.m(i,k_trade); - oq21_cost_trade(t,i,"marginal") = q21_cost_trade.m(i); - oq21_cost_trade_reg(t,i,k_trade,"marginal") = q21_cost_trade_reg.m(i,k_trade); - ov21_excess_dem(t,k_trade,"level") = v21_excess_dem.l(k_trade); - ov21_excess_prod(t,i,k_trade,"level") = v21_excess_prod.l(i,k_trade); - ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); - ov21_cost_trade_reg(t,i,k_trade,"level") = v21_cost_trade_reg.l(i,k_trade); - oq21_trade_glo(t,k_trade,"level") = q21_trade_glo.l(k_trade); - oq21_notrade(t,i,k_notrade,"level") = q21_notrade.l(i,k_notrade); - oq21_trade_reg(t,i,k_trade,"level") = q21_trade_reg.l(i,k_trade); - oq21_trade_reg_up(t,i,k_trade,"level") = q21_trade_reg_up.l(i,k_trade); - oq21_excess_dem(t,k_trade,"level") = q21_excess_dem.l(k_trade); - oq21_excess_supply(t,i,k_trade,"level") = q21_excess_supply.l(i,k_trade); - oq21_cost_trade(t,i,"level") = q21_cost_trade.l(i); - oq21_cost_trade_reg(t,i,k_trade,"level") = q21_cost_trade_reg.l(i,k_trade); - ov21_excess_dem(t,k_trade,"upper") = v21_excess_dem.up(k_trade); - ov21_excess_prod(t,i,k_trade,"upper") = v21_excess_prod.up(i,k_trade); - ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); - ov21_cost_trade_reg(t,i,k_trade,"upper") = v21_cost_trade_reg.up(i,k_trade); - oq21_trade_glo(t,k_trade,"upper") = q21_trade_glo.up(k_trade); - oq21_notrade(t,i,k_notrade,"upper") = q21_notrade.up(i,k_notrade); - oq21_trade_reg(t,i,k_trade,"upper") = q21_trade_reg.up(i,k_trade); - oq21_trade_reg_up(t,i,k_trade,"upper") = q21_trade_reg_up.up(i,k_trade); - oq21_excess_dem(t,k_trade,"upper") = q21_excess_dem.up(k_trade); - oq21_excess_supply(t,i,k_trade,"upper") = q21_excess_supply.up(i,k_trade); - oq21_cost_trade(t,i,"upper") = q21_cost_trade.up(i); - oq21_cost_trade_reg(t,i,k_trade,"upper") = q21_cost_trade_reg.up(i,k_trade); - ov21_excess_dem(t,k_trade,"lower") = v21_excess_dem.lo(k_trade); - ov21_excess_prod(t,i,k_trade,"lower") = v21_excess_prod.lo(i,k_trade); - ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); - ov21_cost_trade_reg(t,i,k_trade,"lower") = v21_cost_trade_reg.lo(i,k_trade); - oq21_trade_glo(t,k_trade,"lower") = q21_trade_glo.lo(k_trade); - oq21_notrade(t,i,k_notrade,"lower") = q21_notrade.lo(i,k_notrade); - oq21_trade_reg(t,i,k_trade,"lower") = q21_trade_reg.lo(i,k_trade); - oq21_trade_reg_up(t,i,k_trade,"lower") = q21_trade_reg_up.lo(i,k_trade); - oq21_excess_dem(t,k_trade,"lower") = q21_excess_dem.lo(k_trade); - oq21_excess_supply(t,i,k_trade,"lower") = q21_excess_supply.lo(i,k_trade); - oq21_cost_trade(t,i,"lower") = q21_cost_trade.lo(i); - oq21_cost_trade_reg(t,i,k_trade,"lower") = q21_cost_trade_reg.lo(i,k_trade); + ov21_excess_dem(t,k_trade,"marginal") = v21_excess_dem.m(k_trade); + ov21_excess_prod(t,h,k_trade,"marginal") = v21_excess_prod.m(h,k_trade); + ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); + ov21_cost_trade_reg(t,h,k_trade,"marginal") = v21_cost_trade_reg.m(h,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"marginal") = v21_import_for_feasibility.m(h,k_trade); + oq21_trade_glo(t,k_trade,"marginal") = q21_trade_glo.m(k_trade); + oq21_notrade(t,h,k_notrade,"marginal") = q21_notrade.m(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"marginal") = q21_trade_reg.m(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"marginal") = q21_trade_reg_up.m(h,k_trade); + oq21_excess_dem(t,k_trade,"marginal") = q21_excess_dem.m(k_trade); + oq21_excess_supply(t,h,k_trade,"marginal") = q21_excess_supply.m(h,k_trade); + oq21_cost_trade(t,h,"marginal") = q21_cost_trade.m(h); + oq21_cost_trade_reg(t,h,k_trade,"marginal") = q21_cost_trade_reg.m(h,k_trade); + ov21_excess_dem(t,k_trade,"level") = v21_excess_dem.l(k_trade); + ov21_excess_prod(t,h,k_trade,"level") = v21_excess_prod.l(h,k_trade); + ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); + ov21_cost_trade_reg(t,h,k_trade,"level") = v21_cost_trade_reg.l(h,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"level") = v21_import_for_feasibility.l(h,k_trade); + oq21_trade_glo(t,k_trade,"level") = q21_trade_glo.l(k_trade); + oq21_notrade(t,h,k_notrade,"level") = q21_notrade.l(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"level") = q21_trade_reg.l(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"level") = q21_trade_reg_up.l(h,k_trade); + oq21_excess_dem(t,k_trade,"level") = q21_excess_dem.l(k_trade); + oq21_excess_supply(t,h,k_trade,"level") = q21_excess_supply.l(h,k_trade); + oq21_cost_trade(t,h,"level") = q21_cost_trade.l(h); + oq21_cost_trade_reg(t,h,k_trade,"level") = q21_cost_trade_reg.l(h,k_trade); + ov21_excess_dem(t,k_trade,"upper") = v21_excess_dem.up(k_trade); + ov21_excess_prod(t,h,k_trade,"upper") = v21_excess_prod.up(h,k_trade); + ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); + ov21_cost_trade_reg(t,h,k_trade,"upper") = v21_cost_trade_reg.up(h,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"upper") = v21_import_for_feasibility.up(h,k_trade); + oq21_trade_glo(t,k_trade,"upper") = q21_trade_glo.up(k_trade); + oq21_notrade(t,h,k_notrade,"upper") = q21_notrade.up(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"upper") = q21_trade_reg.up(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"upper") = q21_trade_reg_up.up(h,k_trade); + oq21_excess_dem(t,k_trade,"upper") = q21_excess_dem.up(k_trade); + oq21_excess_supply(t,h,k_trade,"upper") = q21_excess_supply.up(h,k_trade); + oq21_cost_trade(t,h,"upper") = q21_cost_trade.up(h); + oq21_cost_trade_reg(t,h,k_trade,"upper") = q21_cost_trade_reg.up(h,k_trade); + ov21_excess_dem(t,k_trade,"lower") = v21_excess_dem.lo(k_trade); + ov21_excess_prod(t,h,k_trade,"lower") = v21_excess_prod.lo(h,k_trade); + ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); + ov21_cost_trade_reg(t,h,k_trade,"lower") = v21_cost_trade_reg.lo(h,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"lower") = v21_import_for_feasibility.lo(h,k_trade); + oq21_trade_glo(t,k_trade,"lower") = q21_trade_glo.lo(k_trade); + oq21_notrade(t,h,k_notrade,"lower") = q21_notrade.lo(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"lower") = q21_trade_reg.lo(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"lower") = q21_trade_reg_up.lo(h,k_trade); + oq21_excess_dem(t,k_trade,"lower") = q21_excess_dem.lo(k_trade); + oq21_excess_supply(t,h,k_trade,"lower") = q21_excess_supply.lo(h,k_trade); + oq21_cost_trade(t,h,"lower") = q21_cost_trade.lo(h); + oq21_cost_trade_reg(t,h,k_trade,"lower") = q21_cost_trade_reg.lo(h,k_trade); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/21_trade/selfsuff_reduced/preloop.gms b/modules/21_trade/selfsuff_reduced/preloop.gms index 765c906874..8a1bfb2f5c 100644 --- a/modules/21_trade/selfsuff_reduced/preloop.gms +++ b/modules/21_trade/selfsuff_reduced/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,14 +6,33 @@ *** | Contact: magpie@pik-potsdam.de -i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","%c21_trade_liberalization%"); +*' Trade liberalization i.e. shift from self-sufficiency fixed pool to free pool begins +*' with sm_fix_SSP2 to keep values matching historical data until then. +loop(t_all, + if(m_year(t_all) <= sm_fix_SSP2, + i21_trade_bal_reduction(t_all,k_trade)=f21_trade_bal_reduction(t_all,"easytrade","l909090r808080"); + i21_trade_bal_reduction(t_all,k_hardtrade21)=f21_trade_bal_reduction(t_all,"hardtrade","l909090r808080"); + else + 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_exports(t_all,h,k_trade) = ((f21_self_suff(t_all,h,k_trade) * f21_dom_supply(t_all,h,k_trade)) - f21_dom_supply(t_all,h,k_trade))$(f21_self_suff(t_all,h,k_trade) > 1); +i21_exp_glo(t_all,k_trade) = sum(h, i21_exports(t_all,h,k_trade)); +i21_exp_shr(t_all,h,k_trade) = i21_exports(t_all,h,k_trade) / (i21_exp_glo(t_all,k_trade) + 0.001$(i21_exp_glo(t_all,k_trade) = 0)); -i21_trade_margin(i2,k_trade) = f21_trade_margin(i2,k_trade); +i21_trade_margin(h,k_trade) = f21_trade_margin(h,k_trade); if ((s21_trade_tariff=1), - i21_trade_tariff(i2,k_trade) = f21_trade_tariff(i2,k_trade); + i21_trade_tariff(h,k_trade) = f21_trade_tariff(h,k_trade); elseif (s21_trade_tariff=0), - i21_trade_tariff(i2,k_trade) = 0; + i21_trade_tariff(h,k_trade) = 0; ); +i21_trade_margin(h,"wood")$(i21_trade_margin(h,"wood") < s21_min_trade_margin_forestry) = s21_min_trade_margin_forestry; +i21_trade_margin(h,"woodfuel")$(i21_trade_margin(h,"woodfuel") < s21_min_trade_margin_forestry) = s21_min_trade_margin_forestry; + +v21_import_for_feasibility.fx(h,k_trade) = 0; +v21_import_for_feasibility.lo(h,k_import21) = 0; +v21_import_for_feasibility.up(h,k_import21) = Inf; diff --git a/modules/21_trade/selfsuff_reduced/realization.gms b/modules/21_trade/selfsuff_reduced/realization.gms index fe63c377ae..d506a989c4 100644 --- a/modules/21_trade/selfsuff_reduced/realization.gms +++ b/modules/21_trade/selfsuff_reduced/realization.gms @@ -1,20 +1,32 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 Within this realization, there are two ways for a region to fulfill -*' its demand for agricultural products: a self-sufficiency pool based on -*' historical region specific trade patterns, and a comparative advantage pool -*' based on most cost-efficient production. - -*' In the self-sufficiency pool, regional self-sufficiency ratios `f21_self_suff_seedred_1995(i,k)` defines -*' how much of the demand of each region `i` for each traded goods `k_trade` has to be met by domestic production. -*' Self sufficiency ratios smaller than one indicate that the region imports from the world market, -*' while self-sufficiencies greater than one indicate that the region produces for export. Trade costs, -*' inlucding trade margins and tariffs, are considered. +*' @description In this realization trade patterns defined by self-sufficiency ratios and export shares, +*' together with regional demands, establish a baseline value for the production of traded products in the superregions. +*' Production is then allowed to fluctuate freely within a band around this baseline value, +*' only being enforced to maintain the condition of global production exceeding global demand. +*' The width of the production band is determined by the `i21_trade_bal_reduction` (ptb) factor, which differentiates +*' itself by SSP after the year prescribed by sm_fix_SSP2. +*' +*' Effectively, this factor splits the global demand into two pools: The `ptb` share of demand goes +*' into a pool for which the origin of products is fixed by the self-sufficiency ratios and export shares. +*' This "self-sufficiency" pool thus implies minimum production levels in superregions, which are enforced by the +*' lower bound of the production band. +*' The remaining part of the demand can be allocated more freely based on comparative advantage +*' in production of different superregions, though still being constrained by the upper bounds of the production band. +*' +*' The superregional self-sufficiency ratios `f21_self_suff` define +*' how much of the demand of each superregion `h` for each traded good `k_trade` is met by domestic production. +*' Self-sufficiency ratios smaller than one indicate that the superregion imports from the world market, +*' while self-sufficiencies greater than one indicate that the superregion produces for export. +*' The superregional export shares `f21_exp_shr` distribute the total excess demand of the importing superregions +*' to the exporting superregions. +*' +*' Trade costs are the sum of trade margins (international transport costs) and trade tariffs. *' *' ![Implementation of trade.](trade_pools.png){ width=100% } @@ -26,6 +38,7 @@ $Ifi "%phase%" == "sets" $include "./modules/21_trade/selfsuff_reduced/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/21_trade/selfsuff_reduced/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/21_trade/selfsuff_reduced/input.gms" $Ifi "%phase%" == "equations" $include "./modules/21_trade/selfsuff_reduced/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/21_trade/selfsuff_reduced/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/21_trade/selfsuff_reduced/preloop.gms" $Ifi "%phase%" == "postsolve" $include "./modules/21_trade/selfsuff_reduced/postsolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/21_trade/selfsuff_reduced/scaling.gms b/modules/21_trade/selfsuff_reduced/scaling.gms new file mode 100644 index 0000000000..bb50ffd42d --- /dev/null +++ b/modules/21_trade/selfsuff_reduced/scaling.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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_cost_trade.scale(i) = 10e5; +v21_cost_trade_reg.scale(h,k_trade) = 10e4; diff --git a/modules/21_trade/selfsuff_reduced/sets.gms b/modules/21_trade/selfsuff_reduced/sets.gms index 9b36bf46fd..9f0bdbf00a 100644 --- a/modules/21_trade/selfsuff_reduced/sets.gms +++ b/modules/21_trade/selfsuff_reduced/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,20 +6,19 @@ *** | Contact: magpie@pik-potsdam.de sets - tstart21(t_all) Historic time steps - / y1995, y2000, y2005, y2010 / *sets need to be adopted to new categories k_notrade(kall) Production activities of non-tradable commodites - / oilpalm, foddr, pasture, res_cereals, res_fibrous, res_nonfibrous,wood,woodfuel / + / oilpalm, foddr, pasture, res_cereals, res_fibrous, res_nonfibrous,begr,betr / * oilpalm not traded, only its oil and oilcake due to FAOSTAT complications, and as trade is little * foddr is not traded as too bulky -* pasture ist not traded as too bulky +* pasture it not traded as too bulky +* begr and betr are not traded because biomass is traded in REMIND k_trade(kall) Production activities of tradable commodities / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, - potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro, begr, betr, + potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro, oils,oilcakes,sugar,molasses,alcohol,ethanol,distillers_grain,brans,scp,fibres, - livst_rum, livst_pig,livst_chick, livst_egg, livst_milk, fish / + livst_rum, livst_pig,livst_chick, livst_egg, livst_milk, fish, wood, woodfuel / * We limit trade of secondary products as this allows for extreme specialisation * in the implementation. Exception is sugar, where we allow the secondary product diff --git a/modules/21_trade/selfsuff_reduced/trade_pools.png b/modules/21_trade/selfsuff_reduced/trade_pools.png index 0ea617d49a..327aee8ad4 100644 Binary files a/modules/21_trade/selfsuff_reduced/trade_pools.png and b/modules/21_trade/selfsuff_reduced/trade_pools.png differ diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/declarations.gms b/modules/21_trade/selfsuff_reduced_bilateral22/declarations.gms new file mode 100644 index 0000000000..cefa169387 --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/declarations.gms @@ -0,0 +1,63 @@ +*** | (C) 2008-2025 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 + i21_trade_bal_reduction(t_all,k_trade) Trade balance reduction (1) + i21_trade_margin(i_ex,i_im,k_trade) Trade transport and admin costs (USD17MER per tDM) + i21_trade_tariff(t_all, i_ex,i_im,k_trade) Trade tariffs (USD17MER per tDM) +; + +positive variables + v21_excess_dem(k_trade) Demand exceeding the minimum self-sufficiency (mio. tDM per yr) + v21_excess_prod(h,k_trade) Superregional production exceeding the minimum self-sufficiency production (mio. tDM per yr) + v21_trade(i_ex,i_im,k_trade) Amounts traded bilaterally (mio. tDM per yr) + v21_cost_tariff_reg(i,k_trade) Regional trade tariffs for each tradable commodity (mio. USD17MER per yr) + v21_cost_margin_reg(i,k_trade) Rregional trade margins for each tradable commodity (mio. USD17MER per yr) + vm_cost_trade(i) Regional trade costs (mio. USD17MER per yr) + v21_cost_trade_reg(i,k_trade) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) + v21_import_for_feasibility(h,k_trade) Additional imports to maintain feasibility (mio. tDM per yr) +; + +equations + q21_trade_glo(k_trade) Global production constraint (mio. tDM per yr) + q21_notrade(h,k_notrade) Superregional production constraint of non-tradable commodities (mio. tDM per yr) + q21_trade_reg(h,k_trade) Superregional trade balances i.e. minimum self-sufficiency ratio (1) + q21_trade_reg_up(h,k_trade) Superregional trade balances i.e. maximum self-sufficiency ratio (1) + q21_excess_dem(k_trade) Global excess demand (mio. tDM per yr) + q21_excess_supply(h,k_trade) Superregional excess production (mio. tDM per yr) + q21_trade_bilat(h, k_trade) Superregional bilateral trade requirements (mio. tDM per yr) + q21_costs_tariffs(i, k_trade) Regional trade tariff costs (mio. USD17MER per yr) + q21_costs_margins(i,k_trade) Regional bilateral trade requirements + q21_cost_trade_reg(i,k_trade) Regional trade costs for each tradable commodity (mio. USD17MER per yr) + q21_cost_trade_reg(i,k_trade) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) + q21_cost_trade(i) Superregional trade costs (mio. USD17MER per yr) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov21_excess_dem(t,k_trade,type) Demand exceeding the minimum self-sufficiency (mio. tDM per yr) + ov21_excess_prod(t,h,k_trade,type) Superregional production exceeding the minimum self-sufficiency production (mio. tDM per yr) + ov21_trade(t,i_ex,i_im,k_trade,type) Amounts traded bilaterally (mio. tDM per yr) + ov21_cost_tariff_reg(t,i,k_trade,type) Regional trade tariffs for each tradable commodity (mio. USD17MER per yr) + ov21_cost_margin_reg(t,i,k_trade,type) Rregional trade margins for each tradable commodity (mio. USD17MER per yr) + ov_cost_trade(t,i,type) Regional trade costs (mio. USD17MER per yr) + ov21_cost_trade_reg(t,i,k_trade,type) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) + ov21_import_for_feasibility(t,h,k_trade,type) Additional imports to maintain feasibility (mio. tDM per yr) + oq21_trade_glo(t,k_trade,type) Global production constraint (mio. tDM per yr) + oq21_notrade(t,h,k_notrade,type) Superregional production constraint of non-tradable commodities (mio. tDM per yr) + oq21_trade_reg(t,h,k_trade,type) Superregional trade balances i.e. minimum self-sufficiency ratio (1) + oq21_trade_reg_up(t,h,k_trade,type) Superregional trade balances i.e. maximum self-sufficiency ratio (1) + oq21_excess_dem(t,k_trade,type) Global excess demand (mio. tDM per yr) + oq21_excess_supply(t,h,k_trade,type) Superregional excess production (mio. tDM per yr) + oq21_trade_bilat(t,h,k_trade,type) Superregional bilateral trade requirements (mio. tDM per yr) + oq21_costs_tariffs(t,i,k_trade,type) Regional trade tariff costs (mio. USD17MER per yr) + oq21_costs_margins(t,i,k_trade,type) Regional bilateral trade requirements + oq21_cost_trade_reg(t,i,k_trade,type) Regional trade costs for each tradable commodity (mio. USD17MER per yr) + oq21_cost_trade_reg(t,i,k_trade,type) Superregional trade costs for each tradable commodity (mio. USD17MER per yr) + oq21_cost_trade(t,i,type) Superregional trade costs (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/equations.gms b/modules/21_trade/selfsuff_reduced_bilateral22/equations.gms new file mode 100644 index 0000000000..2941c6f5df --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/equations.gms @@ -0,0 +1,87 @@ +*** | (C) 2008-2025 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 +*' In the comparative advantage pool, the active constraint ensures that superregional and thus global supply is larger or equal to demand. +*' This means that production can be freely allocated globally based on comparative advantages. + + q21_trade_glo(k_trade).. + sum(i2 ,vm_prod_reg(i2,k_trade)) =g= + sum(i2, vm_supply(i2,k_trade)) + sum(ct,f21_trade_balanceflow(ct,k_trade)); + +*' amount produced superregionally must be equal to supply + net trade +q21_trade_bilat(h2,k_trade).. + sum(supreg(h2, i2), vm_prod_reg(i2, k_trade)) =g= sum(supreg(h2,i2), vm_supply(i2, k_trade) - + sum(i_ex, v21_trade(i_ex, i2, k_trade)) + sum(i_im, v21_trade(i2, i_im, k_trade))); +*' +*' For non-tradable commodites, the regional supply should be larger or equal to the regional demand. + q21_notrade(h2,k_notrade).. + sum(supreg(h2,i2),vm_prod_reg(i2,k_notrade)) =g= sum(supreg(h2,i2), vm_supply(i2,k_notrade)); + +*' The following equation indicates the regional trade constraint for the self-sufficiency pool. +*' The share of regional demand that has to be fulfilled through the self-sufficiency pool is +*' determined by a trade balance reduction factor for each commodity `i21_trade_bal_reduction(ct,k_trade)` +*' according to the following equations [@schmitz_trading_2012]. +*' If the trade balance reduction equals 1 (`f21_self_suff(ct,i2,k_trade) = 1`), all demand enters the self-sufficiency pool. +*' If it equals 0, all demand enters the comparative advantage pool. + +*' Lower bound for production. + + q21_trade_reg(h2,k_trade).. + sum(supreg(h2,i2),vm_prod_reg(i2,k_trade)) =g= + ((sum(supreg(h2,i2),vm_supply(i2,k_trade)) + v21_excess_prod(h2,k_trade)) + *sum(ct,i21_trade_bal_reduction(ct,k_trade))) + $(sum(ct,f21_self_suff(ct,h2,k_trade) >= 1)) + + (sum(supreg(h2,i2),vm_supply(i2,k_trade))*sum(ct,f21_self_suff(ct,h2,k_trade)) + *sum(ct,i21_trade_bal_reduction(ct,k_trade))) + $(sum(ct,f21_self_suff(ct,h2,k_trade) < 1)) + - v21_import_for_feasibility(h2,k_trade); + +*' Upper bound for production. + + q21_trade_reg_up(h2,k_trade) .. + sum(supreg(h2,i2),vm_prod_reg(i2,k_trade)) =l= + ((sum(supreg(h2,i2),vm_supply(i2,k_trade)) + v21_excess_prod(h2,k_trade))/sum(ct,i21_trade_bal_reduction(ct,k_trade))) + $(sum(ct,f21_self_suff(ct,h2,k_trade) >= 1)) + + (sum(supreg(h2,i2),vm_supply(i2,k_trade))*sum(ct,f21_self_suff(ct,h2,k_trade))/sum(ct,i21_trade_bal_reduction(ct,k_trade))) + $(sum(ct,f21_self_suff(ct,h2,k_trade) < 1)); + +*' The global excess demand of each tradable good `v21_excess_demad` equals to +*' the sum over all the imports of importing regions. + + q21_excess_dem(k_trade).. + v21_excess_dem(k_trade) =g= + (sum(h2, sum(supreg(h2,i2),vm_supply(i2,k_trade))*(1 - sum(ct,f21_self_suff(ct,h2,k_trade))) + $(sum(ct,f21_self_suff(ct,h2,k_trade)) < 1)) + + sum(ct,f21_trade_balanceflow(ct,k_trade))) + sum(h2, v21_import_for_feasibility(h2,k_trade)); + +*' Distributing the global excess demand to exporting regions is based on regional export shares [@schmitz_trading_2012]. +*' Export shares are derived from FAO data (see @schmitz_trading_2012 for details). They are 0 for importing regions. + + q21_excess_supply(h2,k_trade).. + v21_excess_prod(h2,k_trade) =e= + v21_excess_dem(k_trade)*sum(ct,f21_exp_shr(ct,h2,k_trade)); + +*' Trade tariffs are associated with exporting regions. They are dependent on net exports and tariff levels. + q21_costs_tariffs(i2,k_trade).. + v21_cost_tariff_reg(i2,k_trade) =g= + sum(i_im, sum(ct, i21_trade_tariff(ct, i2,i_im,k_trade)) * v21_trade(i2,i_im,k_trade)); + +*' Trade margins costs assigned currently to exporting region. Margins at region level +q21_costs_margins(i2,k_trade).. + v21_cost_margin_reg(i2,k_trade) =g= + sum(i_im, i21_trade_margin(i2,i_im,k_trade) * v21_trade(i2,i_im,k_trade)); + +*' regional trade values are the sum of transport margin and tariff costs +q21_cost_trade_reg(i2,k_trade).. + v21_cost_trade_reg(i2,k_trade) =g= + v21_cost_tariff_reg(i2,k_trade) + v21_cost_margin_reg(i2,k_trade) + + sum(supreg(h2,i2), v21_import_for_feasibility(h2,k_trade)) * s21_cost_import; + +*' Regional trade costs are the costs for each region aggregated over all the tradable commodities. + q21_cost_trade(i2).. + vm_cost_trade(i2) =e= sum(k_trade, v21_cost_trade_reg(i2,k_trade)); diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/input.gms b/modules/21_trade/selfsuff_reduced_bilateral22/input.gms new file mode 100644 index 0000000000..00eccb6ea7 --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/input.gms @@ -0,0 +1,57 @@ +*** | (C) 2008-2025 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 + +$setglobal c21_trade_liberalization l909090r808080 +* options are "regionalized" and "globalized" and "fragmented" + +sets + k_import21(k_trade) Commodities that can have additional imports to maintain feasibility + / wood, woodfuel / +; + +scalars + s21_trade_tariff Trade tariff switch (1=on 0=off) (1) / 1 / + s21_trade_tariff_fadeout fadeout scenario setting for trade tariffs / 0 / + s21_trade_tariff_startyear year to start fading out trade tariffs / 2025 / + s21_trade_tariff_targetyear year to finish fading out trade tariffs / 2050 / + s21_cost_import Cost for additional imports to maintain feasibility (USD17MER per tDM) / 1500 / + s21_min_trade_margin_forestry Minimum trade margin for forestry products (USD17MER per tDM) / 62 / +; + +table f21_trade_bal_reduction(t_all,trade_groups21,trade_regime21) Share of inelastic trade pool (1) +$ondelim +$include "./modules/21_trade/input/f21_trade_bal_reduction.cs3" +$offdelim; + +table f21_self_suff(t_all,h,kall) Superregional self-sufficiency rates (1) +$ondelim +$include "./modules/21_trade/input/f21_trade_self_suff.cs3" +$offdelim; + +table f21_exp_shr(t_all,h,kall) Superregional and crop-specific export share (1) +$ondelim +$include "./modules/21_trade/input/f21_trade_export_share.cs3" +$offdelim; + +table f21_trade_balanceflow(t_all,kall) Domestic balance flows (mio. tDM per yr) +$ondelim +$include "./modules/21_trade/input/f21_trade_balanceflow.cs3" +$offdelim; + +parameter f21_trade_margin(i_ex,i_im,kall) Costs of freight and insurance (USD17MER per tDM) +/ +$ondelim +$include "./modules/21_trade/selfsuff_reduced_bilateral22/input/f21_trade_margin_bilat.cs5" +$offdelim +/; + +parameter f21_trade_tariff(i_ex,i_im,kall) Specific duty tariffs (USD17MER per tDM) +/ +$ondelim +$include "./modules/21_trade/selfsuff_reduced_bilateral22/input/f21_trade_tariff_bilat.cs5" +$offdelim +/; diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/input/files b/modules/21_trade/selfsuff_reduced_bilateral22/input/files new file mode 100644 index 0000000000..7993469cec --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/input/files @@ -0,0 +1,3 @@ +* list of files that are required here +f21_trade_margin_bilat.cs5 +f21_trade_tariff_bilat.cs5 diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/not_used.txt b/modules/21_trade/selfsuff_reduced_bilateral22/not_used.txt new file mode 100644 index 0000000000..4dd79412da --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2,input,not needed diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/postsolve.gms b/modules/21_trade/selfsuff_reduced_bilateral22/postsolve.gms new file mode 100644 index 0000000000..293160a929 --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/postsolve.gms @@ -0,0 +1,89 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov21_excess_dem(t,k_trade,"marginal") = v21_excess_dem.m(k_trade); + ov21_excess_prod(t,h,k_trade,"marginal") = v21_excess_prod.m(h,k_trade); + ov21_trade(t,i_ex,i_im,k_trade,"marginal") = v21_trade.m(i_ex,i_im,k_trade); + ov21_cost_tariff_reg(t,i,k_trade,"marginal") = v21_cost_tariff_reg.m(i,k_trade); + ov21_cost_margin_reg(t,i,k_trade,"marginal") = v21_cost_margin_reg.m(i,k_trade); + ov_cost_trade(t,i,"marginal") = vm_cost_trade.m(i); + ov21_cost_trade_reg(t,i,k_trade,"marginal") = v21_cost_trade_reg.m(i,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"marginal") = v21_import_for_feasibility.m(h,k_trade); + oq21_trade_glo(t,k_trade,"marginal") = q21_trade_glo.m(k_trade); + oq21_notrade(t,h,k_notrade,"marginal") = q21_notrade.m(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"marginal") = q21_trade_reg.m(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"marginal") = q21_trade_reg_up.m(h,k_trade); + oq21_excess_dem(t,k_trade,"marginal") = q21_excess_dem.m(k_trade); + oq21_excess_supply(t,h,k_trade,"marginal") = q21_excess_supply.m(h,k_trade); + oq21_trade_bilat(t,h,k_trade,"marginal") = q21_trade_bilat.m(h,k_trade); + oq21_costs_tariffs(t,i,k_trade,"marginal") = q21_costs_tariffs.m(i,k_trade); + oq21_costs_margins(t,i,k_trade,"marginal") = q21_costs_margins.m(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"marginal") = q21_cost_trade_reg.m(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"marginal") = q21_cost_trade_reg.m(i,k_trade); + oq21_cost_trade(t,i,"marginal") = q21_cost_trade.m(i); + ov21_excess_dem(t,k_trade,"level") = v21_excess_dem.l(k_trade); + ov21_excess_prod(t,h,k_trade,"level") = v21_excess_prod.l(h,k_trade); + ov21_trade(t,i_ex,i_im,k_trade,"level") = v21_trade.l(i_ex,i_im,k_trade); + ov21_cost_tariff_reg(t,i,k_trade,"level") = v21_cost_tariff_reg.l(i,k_trade); + ov21_cost_margin_reg(t,i,k_trade,"level") = v21_cost_margin_reg.l(i,k_trade); + ov_cost_trade(t,i,"level") = vm_cost_trade.l(i); + ov21_cost_trade_reg(t,i,k_trade,"level") = v21_cost_trade_reg.l(i,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"level") = v21_import_for_feasibility.l(h,k_trade); + oq21_trade_glo(t,k_trade,"level") = q21_trade_glo.l(k_trade); + oq21_notrade(t,h,k_notrade,"level") = q21_notrade.l(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"level") = q21_trade_reg.l(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"level") = q21_trade_reg_up.l(h,k_trade); + oq21_excess_dem(t,k_trade,"level") = q21_excess_dem.l(k_trade); + oq21_excess_supply(t,h,k_trade,"level") = q21_excess_supply.l(h,k_trade); + oq21_trade_bilat(t,h,k_trade,"level") = q21_trade_bilat.l(h,k_trade); + oq21_costs_tariffs(t,i,k_trade,"level") = q21_costs_tariffs.l(i,k_trade); + oq21_costs_margins(t,i,k_trade,"level") = q21_costs_margins.l(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"level") = q21_cost_trade_reg.l(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"level") = q21_cost_trade_reg.l(i,k_trade); + oq21_cost_trade(t,i,"level") = q21_cost_trade.l(i); + ov21_excess_dem(t,k_trade,"upper") = v21_excess_dem.up(k_trade); + ov21_excess_prod(t,h,k_trade,"upper") = v21_excess_prod.up(h,k_trade); + ov21_trade(t,i_ex,i_im,k_trade,"upper") = v21_trade.up(i_ex,i_im,k_trade); + ov21_cost_tariff_reg(t,i,k_trade,"upper") = v21_cost_tariff_reg.up(i,k_trade); + ov21_cost_margin_reg(t,i,k_trade,"upper") = v21_cost_margin_reg.up(i,k_trade); + ov_cost_trade(t,i,"upper") = vm_cost_trade.up(i); + ov21_cost_trade_reg(t,i,k_trade,"upper") = v21_cost_trade_reg.up(i,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"upper") = v21_import_for_feasibility.up(h,k_trade); + oq21_trade_glo(t,k_trade,"upper") = q21_trade_glo.up(k_trade); + oq21_notrade(t,h,k_notrade,"upper") = q21_notrade.up(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"upper") = q21_trade_reg.up(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"upper") = q21_trade_reg_up.up(h,k_trade); + oq21_excess_dem(t,k_trade,"upper") = q21_excess_dem.up(k_trade); + oq21_excess_supply(t,h,k_trade,"upper") = q21_excess_supply.up(h,k_trade); + oq21_trade_bilat(t,h,k_trade,"upper") = q21_trade_bilat.up(h,k_trade); + oq21_costs_tariffs(t,i,k_trade,"upper") = q21_costs_tariffs.up(i,k_trade); + oq21_costs_margins(t,i,k_trade,"upper") = q21_costs_margins.up(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"upper") = q21_cost_trade_reg.up(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"upper") = q21_cost_trade_reg.up(i,k_trade); + oq21_cost_trade(t,i,"upper") = q21_cost_trade.up(i); + ov21_excess_dem(t,k_trade,"lower") = v21_excess_dem.lo(k_trade); + ov21_excess_prod(t,h,k_trade,"lower") = v21_excess_prod.lo(h,k_trade); + ov21_trade(t,i_ex,i_im,k_trade,"lower") = v21_trade.lo(i_ex,i_im,k_trade); + ov21_cost_tariff_reg(t,i,k_trade,"lower") = v21_cost_tariff_reg.lo(i,k_trade); + ov21_cost_margin_reg(t,i,k_trade,"lower") = v21_cost_margin_reg.lo(i,k_trade); + ov_cost_trade(t,i,"lower") = vm_cost_trade.lo(i); + ov21_cost_trade_reg(t,i,k_trade,"lower") = v21_cost_trade_reg.lo(i,k_trade); + ov21_import_for_feasibility(t,h,k_trade,"lower") = v21_import_for_feasibility.lo(h,k_trade); + oq21_trade_glo(t,k_trade,"lower") = q21_trade_glo.lo(k_trade); + oq21_notrade(t,h,k_notrade,"lower") = q21_notrade.lo(h,k_notrade); + oq21_trade_reg(t,h,k_trade,"lower") = q21_trade_reg.lo(h,k_trade); + oq21_trade_reg_up(t,h,k_trade,"lower") = q21_trade_reg_up.lo(h,k_trade); + oq21_excess_dem(t,k_trade,"lower") = q21_excess_dem.lo(k_trade); + oq21_excess_supply(t,h,k_trade,"lower") = q21_excess_supply.lo(h,k_trade); + oq21_trade_bilat(t,h,k_trade,"lower") = q21_trade_bilat.lo(h,k_trade); + oq21_costs_tariffs(t,i,k_trade,"lower") = q21_costs_tariffs.lo(i,k_trade); + oq21_costs_margins(t,i,k_trade,"lower") = q21_costs_margins.lo(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"lower") = q21_cost_trade_reg.lo(i,k_trade); + oq21_cost_trade_reg(t,i,k_trade,"lower") = q21_cost_trade_reg.lo(i,k_trade); + oq21_cost_trade(t,i,"lower") = q21_cost_trade.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/preloop.gms b/modules/21_trade/selfsuff_reduced_bilateral22/preloop.gms new file mode 100644 index 0000000000..8b2fc36e73 --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/preloop.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2025 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 + +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_margin(i_ex,i_im,k_trade) = f21_trade_margin(i_ex,i_im,k_trade); + +if ((s21_trade_tariff=1), + i21_trade_tariff(t_all, i_ex,i_im,k_trade) = f21_trade_tariff(i_ex,i_im,k_trade); +elseif (s21_trade_tariff=0), + i21_trade_tariff(t_all, i_ex,i_im,k_trade) = 0; +); + +if ((s21_trade_tariff_fadeout=1), +loop(t_all, + i21_trade_tariff(t_all,i_ex,i_im,k_trade)$(m_year(t_all) > s21_trade_tariff_startyear AND m_year(t_all) < s21_trade_tariff_targetyear) = (1-((m_year(t_all)-s21_trade_tariff_startyear) / + (s21_trade_tariff_targetyear-s21_trade_tariff_startyear)) * + i21_trade_tariff(t_all,i_ex,i_im,k_trade)); +i21_trade_tariff(t_all,i_ex,i_im,k_trade)$(m_year(t_all) <= s21_trade_tariff_startyear) = i21_trade_tariff(t_all,i_ex,i_im,k_trade); +i21_trade_tariff(t_all,i_ex,i_im,k_trade)$(m_year(t_all) >= s21_trade_tariff_targetyear) = 0 ; +); +); + +i21_trade_margin(h,"wood")$(i21_trade_margin(h,"wood") < s21_min_trade_margin_forestry) = s21_min_trade_margin_forestry; +i21_trade_margin(h,"woodfuel")$(i21_trade_margin(h,"woodfuel") < s21_min_trade_margin_forestry) = s21_min_trade_margin_forestry; + +v21_import_for_feasibility.fx(h,k_trade) = 0; +v21_import_for_feasibility.lo(h,k_import21) = 0; +v21_import_for_feasibility.up(h,k_import21) = Inf; diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/realization.gms b/modules/21_trade/selfsuff_reduced_bilateral22/realization.gms new file mode 100644 index 0000000000..005402a256 --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/realization.gms @@ -0,0 +1,35 @@ +*** | (C) 2008-2025 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 Within this realization, there are two ways for a region to fulfill +*' its demand for agricultural products: a self-sufficiency pool based on +*' historical region specific trade patterns, and a comparative advantage pool +*' based on most cost-efficient production. + +*' In the self-sufficiency pool, regional self-sufficiency ratios `f21_self_suff_seedred_1995(i,k)` defines +*' how much of the demand of each region `i` for each traded goods `k_trade` has to be met by domestic production. +*' Self sufficiency ratios smaller than one indicate that the region imports from the world market, +*' while self-sufficiencies greater than one indicate that the region produces for export. + +*' This realization uses world-region-level bilateral trade margins and tariffs for traded goods. +*' +*' ![Implementation of trade.](trade_pools.png){ width=100% } + +*' @limitations This realization depends on predetermined self-sufficiency rates and export shares, +*' which leads to a relative fixed trade pattern. Bilateral trade happens within the above, based on bilateral tariffs and margins. +*' Other notable difference from selfsuff_reduced is that bilateral margins are now defined over regions (as these are transport costs) +*' as opposed to super-regions (which delimit free trade zones or similar large regions) + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/21_trade/selfsuff_reduced_bilateral22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/21_trade/selfsuff_reduced_bilateral22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/21_trade/selfsuff_reduced_bilateral22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/21_trade/selfsuff_reduced_bilateral22/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/21_trade/selfsuff_reduced_bilateral22/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/21_trade/selfsuff_reduced_bilateral22/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/21_trade/selfsuff_reduced_bilateral22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/scaling.gms b/modules/21_trade/selfsuff_reduced_bilateral22/scaling.gms new file mode 100644 index 0000000000..f8f1131c43 --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/scaling.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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_cost_trade.scale(i) = 10e5; +v21_cost_trade_reg.scale(i,k_trade) = 10e4; diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/sets.gms b/modules/21_trade/selfsuff_reduced_bilateral22/sets.gms new file mode 100644 index 0000000000..1675840b07 --- /dev/null +++ b/modules/21_trade/selfsuff_reduced_bilateral22/sets.gms @@ -0,0 +1,57 @@ +*** | (C) 2008-2025 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 + +*sets need to be adopted to new categories + k_notrade(kall) Production activities of non-tradable commodites + / oilpalm, foddr, pasture, res_cereals, res_fibrous, res_nonfibrous,begr,betr / +* oilpalm not traded, only its oil and oilcake due to FAOSTAT complications, and as trade is little +* foddr is not traded as too bulky +* pasture it not traded as too bulky +* begr and betr are not traded because biomass is traded in REMIND + k_trade(kall) Production activities of tradable commodities + / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, + potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro, + oils,oilcakes,sugar,molasses,alcohol,ethanol,distillers_grain,brans,scp,fibres, + livst_rum, livst_pig,livst_chick, livst_egg, livst_milk, fish, wood, woodfuel / + +* We limit trade of secondary products as this allows for extreme specialisation +* in the implementation. Exception is sugar, where we allow the secondary product +* trade but not the primary as primaries are hardly traded in reality + k_hardtrade21(k_trade) Products where trade should be limited + / sugr_cane,sugr_beet, + oils,oilcakes,alcohol,ethanol,distillers_grain,brans,scp,fibres, + livst_rum, livst_pig,livst_chick, livst_egg, livst_milk, fish / + + trade_regime21 Trade scenarios + / + free2000, + regionalized, + globalized, + fragmented, + a909090, + a908080, + a909595, + a808080, + a807070, + a809090, + l909090r808080, + l908080r807070, + l909595r809090 + / + + trade_groups21 Trade groups + / easytrade,hardtrade / + +; + +alias(h,h3); +alias(h,h_ex); +alias(h,h_im); +alias(i,i_ex); +alias(i,i_im); diff --git a/modules/21_trade/selfsuff_reduced_bilateral22/trade_pools.png b/modules/21_trade/selfsuff_reduced_bilateral22/trade_pools.png new file mode 100644 index 0000000000..327aee8ad4 Binary files /dev/null and b/modules/21_trade/selfsuff_reduced_bilateral22/trade_pools.png differ diff --git a/modules/22_land_conservation/area_based_apr22/declarations.gms b/modules/22_land_conservation/area_based_apr22/declarations.gms new file mode 100644 index 0000000000..dc35428ae4 --- /dev/null +++ b/modules/22_land_conservation/area_based_apr22/declarations.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 + s22_shift number of 5-year age-classes corresponding to current time step length (1) +; + +parameters + p22_wdpa_baseline(t,j,base22,land) Baseline protection (mio. ha) + p22_conservation_area(t,j,land) Total land conservation area for all land types (mio. ha) + pm_land_conservation(t,j,land,consv_type) Land protection and restoration for all land types (mio. ha) + p22_conservation_fader(t_all) Land conservation fader (1) + p22_add_consv(t,j,consv22_all,land) Additional land conservation in conservation priority areas (mio. ha) + p22_secdforest_restore_pot(t,j) Potential secondary forest restoration area (mio. ha) + p22_past_restore_pot(t,j) Potential pasture restoration area (mio. ha) + p22_other_restore_pot(t,j) Potential other land restoration area (mio. ha) + p22_country_weight(i) Land conservation country weight per region (1) + p22_country_switch(iso) Switch indicating whether country is affected by selected land conservation policy (1) + i22_land_iso(iso) Total land area at ISO level (mio. ha) +; + diff --git a/modules/22_land_conservation/area_based_apr22/input.gms b/modules/22_land_conservation/area_based_apr22/input.gms new file mode 100644 index 0000000000..269102e669 --- /dev/null +++ b/modules/22_land_conservation/area_based_apr22/input.gms @@ -0,0 +1,70 @@ +*** | (C) 2008-2025 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 + +$setglobal c22_base_protect WDPA +$setglobal c22_base_protect_noselect WDPA +$setglobal c22_protect_scenario none +$setglobal c22_protect_scenario_noselect none + +scalars +s22_restore_land If land restoration is allowed (0=no 1=yes) / 1 / +s22_conservation_start Land conservation start year / 2025 / +s22_conservation_target Land conservation target year / 2050 / +s22_base_protect_reversal Year in which base protection reversal should take place (1) / Inf / +; + +* Set-switch for countries affected by regional land conservation policy +* Default: all iso countries selected +sets + policy_countries22(iso) countries to be affected by land conservation policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + + + land_consv(land) land types to which in future conservation (protection and restoration) is applied + / primforest, secdforest, other / + +; + + +table f22_wdpa_baseline(t_all,j,wdpa_cat22,land) Initial protected area as derived from WDPA until 2020 (mio. ha) +$ondelim +$include "./modules/22_land_conservation/input/wdpa_baseline.cs3" +$offdelim +; +* fix to 2020 values for years after 2020 +m_fillmissingyears(f22_wdpa_baseline,"j,wdpa_cat22,land"); + +table f22_consv_prio(j,consv_prio22,land) Conservation priority areas (mio. ha) +$ondelim +$include "./modules/22_land_conservation/input/consv_prio_areas.cs3" +$offdelim +; + diff --git a/modules/22_land_conservation/area_based_apr22/preloop.gms b/modules/22_land_conservation/area_based_apr22/preloop.gms new file mode 100644 index 0000000000..2fb7942bc4 --- /dev/null +++ b/modules/22_land_conservation/area_based_apr22/preloop.gms @@ -0,0 +1,43 @@ +*** | (C) 2008-2025 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 + +* -------------------------- +* Calculate country weights +* -------------------------- + +* Regional share of land conservation policies in selective countries: +* Country switch to determine countries for which land conservation shall be applied. +* In the default case, the land conservation affects all countries when activated. +p22_country_switch(iso) = 0; +p22_country_switch(policy_countries22) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by total land area. +i22_land_iso(iso) = sum(land, fm_land_iso("y1995",iso,land)); +p22_country_weight(i) = sum(i_to_iso(i,iso), p22_country_switch(iso) * i22_land_iso(iso)) / sum(i_to_iso(i,iso), i22_land_iso(iso)); + +* --------------------------------------------------------------------- +* Initialise baseline protection and conservation priority areas +* --------------------------------------------------------------------- + +** Initialise baseline protection area +p22_wdpa_baseline(t,j,base22,land) = 0; + +* Get baseline protection in based on WDPA data +p22_wdpa_baseline(t,j,wdpa_cat22,land) = f22_wdpa_baseline(t,j,wdpa_cat22,land); + + +** Trajectory for implementation of land conservation +* sigmoidal interpolation between 2020 and target year +m_sigmoid_time_interpol(p22_conservation_fader,s22_conservation_start,s22_conservation_target,0,1); + +** Initialise additional conservation area +p22_add_consv(t,j,consv22_all,land) = 0; + +* Get additional conservation area in conservation priority areas +p22_add_consv(t,j,consv_prio22,land) = f22_consv_prio(j,consv_prio22,land)*p22_conservation_fader(t); + diff --git a/modules/22_land_conservation/area_based_apr22/presolve_ini.gms b/modules/22_land_conservation/area_based_apr22/presolve_ini.gms new file mode 100644 index 0000000000..a6277b4363 --- /dev/null +++ b/modules/22_land_conservation/area_based_apr22/presolve_ini.gms @@ -0,0 +1,124 @@ +*** | (C) 2008-2025 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 + +* ================== +* Land conservation +* ================== + +* Define natural vegetation conservation options based on +* remaining natural vegation in current time step + +* Include all remaining primary forest areas in IFL conservation target +p22_add_consv(t,j,"IFL","primforest") = pcm_land(j,"primforest") * p22_conservation_fader(t); +p22_add_consv(t,j,"BH_IFL","primforest") = pcm_land(j,"primforest") * p22_conservation_fader(t); + + +if(m_year(t) <= sm_fix_SSP2, +* from 1995 to 2020 land conservation is based on +* historic trends as derived from WDPA + p22_conservation_area(t,j,land) = sum(cell(i,j), + p22_wdpa_baseline(t,j,"%c22_base_protect%",land) * p22_country_weight(i) + + p22_wdpa_baseline(t,j,"%c22_base_protect_noselect%",land) * (1-p22_country_weight(i)) + ); + +else + +** Future land conservation +p22_conservation_area(t,j,land) = sum(cell(i,j), + p22_wdpa_baseline(t,j,"%c22_base_protect%",land) * p22_country_weight(i) + + p22_wdpa_baseline(t,j,"%c22_base_protect_noselect%",land) * (1-p22_country_weight(i)) + ); +* future options for land conservation are added to the WDPA baseline +p22_conservation_area(t,j,land_consv) = + sum(cell(i,j), + p22_wdpa_baseline(t,j,"%c22_base_protect%",land_consv) * p22_country_weight(i) + + p22_wdpa_baseline(t,j,"%c22_base_protect_noselect%",land_consv) * (1-p22_country_weight(i)) + ) + + sum(cell(i,j), + p22_add_consv(t,j,"%c22_protect_scenario%",land_consv) * p22_country_weight(i) + + p22_add_consv(t,j,"%c22_protect_scenario_noselect%",land_consv) * (1-p22_country_weight(i)) + ); +); + +* ----------------------- +* Protect remaining land +* ----------------------- + +* Note: The prescribed conservation area for each land pool can be smaller, equal or +* higher than the land pools of the previous time step. If the conservation area is +* larger and s22_restore_land = 1, missing land will be restored. +pm_land_conservation(t,j,land,"protect") = p22_conservation_area(t,j,land); +pm_land_conservation(t,j,land,"protect")$(pm_land_conservation(t,j,land,"protect") > pcm_land(j,land)) = pcm_land(j,land); + + +* ------------------- +* Land restoration +* ------------------- + +if(s22_restore_land = 1 OR m_year(t) <= sm_fix_SSP2, + +** Calculate restoration targets +* Grassland +pm_land_conservation(t,j,"past","restore")$(p22_conservation_area(t,j,"past") > pcm_land(j,"past")) = + p22_conservation_area(t,j,"past") - pcm_land(j,"past"); +* Forest land +* Total forest restoration requirements are attributed to +* secdforest, as primforest cannot be restored by definition +pm_land_conservation(t,j,"secdforest","restore") = + (p22_conservation_area(t,j,"primforest") + p22_conservation_area(t,j,"secdforest")) + - (pcm_land(j,"primforest") + pcm_land(j,"secdforest")); +pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") < 1e-6) = 0; +* Other land +pm_land_conservation(t,j,"other","restore")$(p22_conservation_area(t,j,"other") > pcm_land(j,"other")) = + p22_conservation_area(t,j,"other") - pcm_land(j,"other"); + +* Adjust forest, grassland and other land restoration depending on given land available for restoration (restoration potential) + +* Secondary forest restoration is limited by secondary forest restoration potential +p22_secdforest_restore_pot(t,j) = sum(land, pcm_land(j, land)) + - pcm_land(j, "urban") + - sum(land_timber, pcm_land(j, land_timber)) + - pm_land_conservation(t,j,"past","protect") + - vm_land.lo(j,"crop") + - vm_treecover.l(j); +p22_secdforest_restore_pot(t,j)$(p22_secdforest_restore_pot(t,j) < 1e-6) = 0; +pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") > p22_secdforest_restore_pot(t,j)) = p22_secdforest_restore_pot(t,j); + +* Grassland restoration is limited by grassland restoration potential +p22_past_restore_pot(t,j) = sum(land, pcm_land(j, land)) + - pcm_land(j, "urban") + - sum(land_timber, pcm_land(j, land_timber)) + - pm_land_conservation(t,j,"past","protect") + - pm_land_conservation(t,j,"secdforest","restore") + - vm_land.lo(j,"crop") + - vm_treecover.l(j); +p22_past_restore_pot(t,j)$(p22_past_restore_pot(t,j) < 1e-6) = 0; +pm_land_conservation(t,j,"past","restore")$(pm_land_conservation(t,j,"past","restore") > p22_past_restore_pot(t,j)) = p22_past_restore_pot(t,j); + +* Other land restoration is limited by other land restoration potential +p22_other_restore_pot(t,j) = sum(land, pcm_land(j, land)) + - pcm_land(j, "urban") + - sum(land_timber, pcm_land(j, land_timber)) + - sum(consv_type, pm_land_conservation(t,j,"past",consv_type)) + - pm_land_conservation(t,j,"secdforest","restore") + - vm_land.lo(j,"crop") + - vm_treecover.l(j); +p22_other_restore_pot(t,j)$(p22_other_restore_pot(t,j) < 1e-6) = 0; +pm_land_conservation(t,j,"other","restore")$(pm_land_conservation(t,j,"other","restore") > p22_other_restore_pot(t,j)) = p22_other_restore_pot(t,j); + +else + +* set restoration to zero +pm_land_conservation(t,j,land,"restore") = 0; + +); + +if (m_year(t) >= s22_base_protect_reversal, + pm_land_conservation(t,j,land,consv_type) = 0; +); + + diff --git a/modules/22_land_conservation/area_based_apr22/realization.gms b/modules/22_land_conservation/area_based_apr22/realization.gms new file mode 100644 index 0000000000..866aaed834 --- /dev/null +++ b/modules/22_land_conservation/area_based_apr22/realization.gms @@ -0,0 +1,38 @@ +*** | (C) 2008-2025 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 The realization initialises land stocks reserved for land conservation across +*' grassland, forest and other land pools. +*' Land reserved for area-based conservation is derived from WDPA and is based on observed +*' land conservation trends. In 1995, the total area under land conservation (across all land +*' types) in the input data set is 864.31 Mha and, by 5-year time steps, increases to +*' 1662.02 Mha in 2020 (13.06 % of the total land area, excluding inland water bodies under +*' protection). After 2020 land conservation is held constant at 2020 values. The protected area +*' based on WDPA includes all areas under legal protection meeting the IUCN and CBD protected +*' area definitions (including IUCN categories Ia, Ib, III, IV, V, VI and 'not assigned' but +*' legally designated areas). Natural vegetation (natveg) and grassland ('past') within protected +*' areas cannot be converted to other land types. On top of the WDPA baseline protection, there are +*' future options to protect different conservation priority areas such as biodiversity hotspots (BH), +*' centers of plant diversity (CBD), Intact Forest Landscapes (IFL) and last of the wild (LW), +*' taken from @brooks_global_2006. +*' Future land conservation is distributed proportionally across natural vegetation types +*' (primary forest, secondary forest and other natural land). +*' @stop + +*' +*' @limitations Land cover in the WDPA baseline data is estimated based on ESA-CCI +*' land-use/land-cover maps from 1995 to 2020, while land pools in MAgPIE are intialised +*' based on LUH data (forest areas are additionally harmonised with FAO data). +*' This leads to slight mismatches in some areas. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/22_land_conservation/area_based_apr22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/22_land_conservation/area_based_apr22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/22_land_conservation/area_based_apr22/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/22_land_conservation/area_based_apr22/preloop.gms" +$Ifi "%phase%" == "presolve_ini" $include "./modules/22_land_conservation/area_based_apr22/presolve_ini.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/22_land_conservation/area_based_apr22/sets.gms b/modules/22_land_conservation/area_based_apr22/sets.gms new file mode 100644 index 0000000000..c9a267d9bc --- /dev/null +++ b/modules/22_land_conservation/area_based_apr22/sets.gms @@ -0,0 +1,29 @@ +*** | (C) 2008-2025 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 + + base22 All baseline protection options + / none, WDPA, WDPA_I-II-III, WDPA_IV-V-VI / + + wdpa_cat22(base22) Protected area categories + / WDPA, WDPA_I-II-III, WDPA_IV-V-VI / + + consv22_all All conservation options + / none, 30by30, KBA, GSN_DSA, GSN_RarePhen, GSN_AreaIntct, GSN_ClimTier1, GSN_ClimTier2, + BH, IFL, BH_IFL, IrrC_50pc, IrrC_75pc, IrrC_95pc, IrrC_99pc, IrrC_75pc_30by30, + IrrC_95pc_30by30, IrrC_99pc_30by30, IrrC_100pc, CCA, GSN_HalfEarth, PBL_HalfEarth / + + consv_prio22(consv22_all) Conservation priority areas + / 30by30, KBA, GSN_DSA, GSN_RarePhen, GSN_AreaIntct, GSN_ClimTier1, GSN_ClimTier2, + BH, IFL, BH_IFL, IrrC_50pc, IrrC_75pc, IrrC_95pc, IrrC_99pc, IrrC_75pc_30by30, + IrrC_95pc_30by30, IrrC_99pc_30by30, IrrC_100pc, CCA, GSN_HalfEarth, PBL_HalfEarth / + + consv_type Type of land conservation + / protect, restore / + +; diff --git a/modules/22_land_conservation/input/files b/modules/22_land_conservation/input/files new file mode 100644 index 0000000000..d9408d439e --- /dev/null +++ b/modules/22_land_conservation/input/files @@ -0,0 +1,6 @@ +* list of files that are required here +avl_land_t_iso.cs3 +wdpa_baseline.cs3 +wdpa_baseline_0.5.mz +consv_prio_areas.cs3 +consv_prio_areas_0.5.mz diff --git a/modules/22_land_conservation/module.gms b/modules/22_land_conservation/module.gms new file mode 100644 index 0000000000..969e5fc07a --- /dev/null +++ b/modules/22_land_conservation/module.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2025 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 + +*' @title Land conservation +*' +*' @description The land conservation (land_conservation) module initialises +*' land under legal protection for all land types, and provides future +*' options for land conservation based on conservation priority areas. +*' Based on the land area of the different land-use types (`pcm_land`) +*' from the previous time step, this module also calculates restoration +*' requirements to fulfil land conservation targets. Both the information on +*' the protection of remaining land areas as well as information on restoration +*' is transferred to the other land modules via the interface `pm_land_conservation`. +*' @authors Patrick v. Jeetze + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%land_conservation%" == "area_based_apr22" $include "./modules/22_land_conservation/area_based_apr22/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/28_ageclass/input/files b/modules/28_ageclass/input/files new file mode 100644 index 0000000000..e53159813d --- /dev/null +++ b/modules/28_ageclass/input/files @@ -0,0 +1,2 @@ +* list of files that are required here +forestageclasses.cs3 diff --git a/modules/28_ageclass/module.gms b/modules/28_ageclass/module.gms new file mode 100644 index 0000000000..21125835d6 --- /dev/null +++ b/modules/28_ageclass/module.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2025 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 + +*' @title Age class + +*' @description The age-class module provides forest area in age-classes +*' to other modules. The interface `im_forest_ageclass` is used in +*' [35_natveg] for the initialization of secondary forest areas. + +*' @authors Abhijeet Mishra, Florian Humpenöder + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%ageclass%" == "oct24" $include "./modules/28_ageclass/oct24/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/28_ageclass/oct24/declarations.gms b/modules/28_ageclass/oct24/declarations.gms new file mode 100644 index 0000000000..00531e9a23 --- /dev/null +++ b/modules/28_ageclass/oct24/declarations.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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 + +parameter + im_forest_ageclass(j,ac) Forest area in 5-year age-classes based on GFAD (mio. ha) +; diff --git a/modules/28_ageclass/oct24/input.gms b/modules/28_ageclass/oct24/input.gms new file mode 100644 index 0000000000..a41baabf9d --- /dev/null +++ b/modules/28_ageclass/oct24/input.gms @@ -0,0 +1,12 @@ +*** | (C) 2008-2025 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 + +table f28_forestageclasses(j,ac_gfad) Forest area in 15 10-year age classes from GFAD (Mha) +$ondelim +$include "./modules/28_ageclass/input/forestageclasses.cs3" +$offdelim +; diff --git a/modules/28_ageclass/oct24/preloop.gms b/modules/28_ageclass/oct24/preloop.gms new file mode 100644 index 0000000000..28fc716093 --- /dev/null +++ b/modules/28_ageclass/oct24/preloop.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + +* Two age-classes in `ac` are mapped to one age-class in `ac_gfad`. +* Therefore, each age-class in `ac_gfad` is distributed equally to all belonging age-classes in `ac`. +im_forest_ageclass(j,ac) = 0; +im_forest_ageclass(j,ac) = sum(ac_gfad_to_ac(ac_gfad,ac),f28_forestageclasses(j,ac_gfad)) / 2; +* `class15` in GFAD1.1 includes forests that are 150 years or older, also including primary forest. +* Therefore, `class15` is mapped to the highest age-class `acx`. +im_forest_ageclass(j,"acx") = f28_forestageclasses(j,"class15"); diff --git a/modules/28_ageclass/oct24/presolve.gms b/modules/28_ageclass/oct24/presolve.gms new file mode 100644 index 0000000000..c0738cf9c7 --- /dev/null +++ b/modules/28_ageclass/oct24/presolve.gms @@ -0,0 +1,13 @@ +*** | (C) 2008-2025 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 ac_est and ac_sub +ac_est(ac) = no; +ac_est(ac) = yes$(ord(ac) <= (m_yeardiff_forestry(t)/5)); + +ac_sub(ac) = no; +ac_sub(ac) = yes$(ord(ac) > (m_yeardiff_forestry(t)/5)); diff --git a/modules/28_ageclass/oct24/realization.gms b/modules/28_ageclass/oct24/realization.gms new file mode 100644 index 0000000000..3d40709b4d --- /dev/null +++ b/modules/28_ageclass/oct24/realization.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2025 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 This realization provides forest area in age-classes `im_forest_ageclass` +*' based on the Global Forest Age Dataset (GFAD V1.1) from @poulter_global_2019. + +*' @limitations Disturbances such as forest fires change the age structure of forests over time. +*' GFAD V1.1 likely includes such disturbances in younger age-classes (`ac_young`). +*' Since forest disturbances are not modeled extensively in MAgPIE, +*' using these numbers directly in the model might generate biases. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/28_ageclass/oct24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/28_ageclass/oct24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/28_ageclass/oct24/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/28_ageclass/oct24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/28_ageclass/oct24/presolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/28_ageclass/oct24/sets.gms b/modules/28_ageclass/oct24/sets.gms new file mode 100644 index 0000000000..4eb89e647f --- /dev/null +++ b/modules/28_ageclass/oct24/sets.gms @@ -0,0 +1,38 @@ +*** | (C) 2008-2025 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 +ac_gfad Forest age classes in GFAD data set +/ class1, class2, class3, class4, class5, +class6, class7, class8, class9, class10, +class11, class12, class13, class14, class15 / + +ac_young(ac) Young age classes +/ ac0, ac5, ac10, ac15, ac20, ac25, ac30 / + +ac_gfad_to_ac(ac_gfad,ac) mapping between ac and ac_gfad +/ +class1 . (ac5,ac10) +class2 . (ac15,ac20) +class3 . (ac25,ac30) +class4 . (ac35,ac40) +class5 . (ac45,ac50) +class6 . (ac55,ac60) +class7 . (ac65,ac70) +class8 . (ac75,ac80) +class9 . (ac85,ac90) +class10 . (ac95,ac100) +class11 . (ac105,ac110) +class12 . (ac115,ac120) +class13 . (ac125,ac130) +class14 . (ac135,ac140) +/ + +; + +alias(ac_gfad,ac_gfad2); +alias(ac,ac2); diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms new file mode 100644 index 0000000000..830c3c30e5 --- /dev/null +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -0,0 +1,95 @@ +*** | (C) 2008-2025 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 + s29_shift number of 5-year age-classes corresponding to current time step length (1) +; + +parameters + p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) + p29_country_weight(i) Policy country weight per region (1) + p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) + i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) + p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) + p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) + p29_country_switch(iso) Switch indicating whether country is affected by selected cropland policy (1) + pm_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) + i29_snv_scenario_fader(t_all) SNV scenario fader (1) + + i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + i29_treecover_target(t,j) Target share for treecover on total cropland (1) + i29_treecover_penalty(t) Penalty for violation of treecover target (USD17MER per ha) + p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) + p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) + p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) + pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) + pc29_treecover_share(j) Share of treecover on total cropland (1) + + i29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) + i29_fallow_target(t) Target share for fallow land on total cropland (1) + i29_fallow_penalty(t) Penalty for violation of fallow target (USD17MER per ha) +; + +positive variables + vm_cost_cropland(j) Cost for total cropland (mio. USD17MER per yr) + vm_treecover(j) Cropland tree cover (mio. ha) + v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) + v29_treecover_missing(j) Missing treecover area towards target (mio. ha) + v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD17MER per yr) + v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD17MER per yr) + vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) + v29_fallow_missing(j) Missing fallow land towards target (mio. ha) +; + +equations + q29_cropland(j) Total cropland calculation (mio. ha) + q29_avl_cropland(j) Available cropland constraint (mio. ha) + q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD17MER per yr) + q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) + q29_fallow_min(j) Missing fallow land towards target (mio. ha) + q29_fallow_max(j) Maximum fallow land towards target (mio. ha) + q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) + q29_treecover(j) Cropland tree cover (mio. ha) + q29_treecover_min(j) Missing treecover area towards target (mio. ha) + q29_treecover_max(j) Maximum treecover area (mio. ha) + q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) + q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD17MER per yr) + q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD17MER per yr) + q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD17MER per yr) + ov_treecover(t,j,type) Cropland tree cover (mio. ha) + ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) + ov29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) + ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD17MER per yr) + ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD17MER per yr) + ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) + ov29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) + oq29_cropland(t,j,type) Total cropland calculation (mio. ha) + oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD17MER per yr) + oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) + oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) + oq29_fallow_min(t,j,type) Missing fallow land towards target (mio. ha) + oq29_fallow_max(t,j,type) Maximum fallow land towards target (mio. ha) + oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) + oq29_treecover(t,j,type) Cropland tree cover (mio. ha) + oq29_treecover_min(t,j,type) Missing treecover area towards target (mio. ha) + oq29_treecover_max(t,j,type) Maximum treecover area (mio. ha) + oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) + oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD17MER per yr) + oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD17MER per yr) + oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms new file mode 100644 index 0000000000..eb486b7610 --- /dev/null +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -0,0 +1,123 @@ +*** | (C) 2008-2025 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 +*' Total cropland is calculated as the sum of croparea, fallow land and tree cover area. + + q29_cropland(j2) .. + vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v29_treecover(j2,ac)); + +*' We assume that crop production can only take place on suitable cropland area. +*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas +*' from cropland production that have a low suitability, e.g. due to steep slopes, +*' to estimate the available cropland area. The cultivated area therefore has +*' to be smaller than the available cropland area. Moreover, the available cropland +*' can be reduced by constraining the cropland area in favour of other land types, +*' in order to increase compositional heterogeneity of land types at the cell level. + + q29_avl_cropland(j2) .. + vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); + + +*' Total cost for the cropland module. + + q29_cost_cropland(j2) .. + vm_cost_cropland(j2) =e= + v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) + + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)) + + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); + + +*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in +*' cropland, fallow land and tree cover area. + + q29_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + vm_carbon_stock_croparea(j2,ag_pools) + + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) + + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); + + +*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP +*' for agricultural production is added on top of land conserved for other reasons +*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). + + q29_land_snv(j2) .. + sum(land_snv, vm_land(j2,land_snv)) =g= + sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") + + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); + +*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square +*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from +*' exogeneous high-resolution land cover information from the Copernicus Global Land Service +*' (@buchhorn_copernicus_2020). + + q29_land_snv_trans(j2) .. + sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); + +*' A penalty is applied for the violation of fallow land rules. +*' The penalty applies to the missing fallow land, i.e. where fallow land +*' is lower than a certain fraction of total cropland. + + q29_fallow_min(j2)$(sum(ct, i29_fallow_penalty(ct)) > 0) .. + v29_fallow_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i29_fallow_target(ct)) - vm_fallow(j2); + + q29_fallow_max(j2) .. + vm_fallow(j2) =l= + vm_land(j2,"crop") * s29_fallow_max; + +*' Fallow land biodiversity value is based on perennial crops. + + q29_fallow_bv(j2,potnatveg) .. + vm_bv(j2,"crop_fallow",potnatveg) =e= + vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + +*' Interface vm_treecover for other modules. + + q29_treecover(j2) .. + vm_treecover(j2) =e= sum(ac, v29_treecover(j2,ac)); + +*' A penalty is applied for the violation of treecover rules. +*' The penalty applies to the missing treecover area, i.e. where treecover area +*' is lower than a certain fraction of total cropland. + + q29_treecover_min(j2)$(sum(ct, i29_treecover_penalty(ct)) > 0) .. + v29_treecover_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); + + q29_treecover_max(j2) .. + sum(ac, v29_treecover(j2,ac)) =l= + vm_land(j2,"crop") * s29_treecover_max; + +*' Depending on `s29_treecover_bii_coeff`, tree cover biodiversity value +*' is based on natural vegetation or plantation BII coefficients. + + q29_treecover_bv(j2,potnatveg) .. + vm_bv(j2,"crop_tree",potnatveg) =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * + p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + +*' Cropland tree cover annuity cost. + + q29_cost_treecover_est(j2) .. + v29_cost_treecover_est(j2) =e= + sum(ac_est, v29_treecover(j2,ac_est)) * s29_cost_treecover_est * + sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Cropland tree cover recurring cost. + + q29_cost_treecover_recur(j2) .. + v29_cost_treecover_recur(j2) =e= + sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; + +*' Cropland tree cover establishment rules for distributing areas equally to age-classes. +*' For a 5-year time step ac_est includes only ac0. But for a 10-year time step ac_est includes ac0 and ac5. + + q29_treecover_est(j2,ac_est) .. + v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms new file mode 100644 index 0000000000..22bf8b5e68 --- /dev/null +++ b/modules/29_cropland/detail_apr24/input.gms @@ -0,0 +1,103 @@ +*** | (C) 2008-2025 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 + +$setglobal c29_marginal_land q33_marginal +* options: all_marginal, q33_marginal, no_marginal + +scalars + s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_scenario_start SNV scenario start year / 2025 / + s29_snv_scenario_target SNV scenario target year / 2050 / + s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / + s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / + s29_cost_treecover_est Tree cover establishment cost (USD17MER per ha) / 2460 / + s29_cost_treecover_recur Tree cover recurring cost (USD17MER per ha) / 615 / + s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / + s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / + s29_treecover_scenario_start Cropland treecover scenario start year / 2025 / + s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / + s29_treecover_target Minimum share of treecover on total cropland in target year (1) / 0 / + s29_treecover_target_noselect Minimum share of treecover on total cropland in target year (1) / 0 / + s29_treecover_keep Avoid loss of existing treecover (1=yes 0=no) / 0 / + s29_treecover_max Maximum share of treecover on total cropland (1) / 1 / + s29_treecover_penalty_before Penalty for violation of treecover target before scenario start (USD17MER per ha) / 0 / + s29_treecover_penalty Penalty for violation of treecover target after sceanrio start (USD17MER per ha) / 6150 / + s29_fallow_scenario_start Fallow land scenario start year / 2025 / + s29_fallow_scenario_target Fallow land scenario target year / 2050 / + s29_fallow_target Minimum share of fallow land on total cropland in target year (1) / 0 / + s29_fallow_max Maximum share of fallow land on total cropland (1) / 0 / + s29_fallow_penalty Penalty for violation of fallow target (USD17MER per ha) / 615 / + s29_treecover_map Treecover map for initialization (binary) / 0 / + s29_fader_functional_form Switch for functional form of faders (1) / 2 / +; + + +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries29(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + +land_snv(land) land types allowed in the SNV policy / secdforest, other / +; + +********* AVAILABLE CROPLAND ******************************************* + +table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland.cs3" +$offdelim +; + +table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland_iso.cs3" +$offdelim +; + +********* SNV TARGET CROPLAND ******************************************* + +table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) +$ondelim +$include "./modules/29_cropland/input/SNVTargetCropland.cs3" +$offdelim +; + +********* Cropland tree cover ******************************************* + +parameter f29_treecover(j) Tree cover on cropland in 2015 (mio. ha) +/ +$ondelim +$include "./modules/29_cropland/input/CroplandTreecover.cs2" +$offdelim +/ +; diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms new file mode 100644 index 0000000000..91058e5880 --- /dev/null +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -0,0 +1,108 @@ +*** | (C) 2008-2025 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 + +pc29_treecover(j,ac) = v29_treecover.l(j,ac); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); + ov_treecover(t,j,"marginal") = vm_treecover.m(j); + ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); + ov29_treecover_missing(t,j,"marginal") = v29_treecover_missing.m(j); + ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); + ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); + ov_fallow(t,j,"marginal") = vm_fallow.m(j); + ov29_fallow_missing(t,j,"marginal") = v29_fallow_missing.m(j); + oq29_cropland(t,j,"marginal") = q29_cropland.m(j); + oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); + oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); + oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); + oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); + oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); + oq29_fallow_min(t,j,"marginal") = q29_fallow_min.m(j); + oq29_fallow_max(t,j,"marginal") = q29_fallow_max.m(j); + oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); + oq29_treecover(t,j,"marginal") = q29_treecover.m(j); + oq29_treecover_min(t,j,"marginal") = q29_treecover_min.m(j); + oq29_treecover_max(t,j,"marginal") = q29_treecover_max.m(j); + oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); + oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); + oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); + oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); + ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); + ov_treecover(t,j,"level") = vm_treecover.l(j); + ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); + ov29_treecover_missing(t,j,"level") = v29_treecover_missing.l(j); + ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); + ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); + ov_fallow(t,j,"level") = vm_fallow.l(j); + ov29_fallow_missing(t,j,"level") = v29_fallow_missing.l(j); + oq29_cropland(t,j,"level") = q29_cropland.l(j); + oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); + oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); + oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); + oq29_land_snv(t,j,"level") = q29_land_snv.l(j); + oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); + oq29_fallow_min(t,j,"level") = q29_fallow_min.l(j); + oq29_fallow_max(t,j,"level") = q29_fallow_max.l(j); + oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); + oq29_treecover(t,j,"level") = q29_treecover.l(j); + oq29_treecover_min(t,j,"level") = q29_treecover_min.l(j); + oq29_treecover_max(t,j,"level") = q29_treecover_max.l(j); + oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); + oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); + oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); + oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); + ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); + ov_treecover(t,j,"upper") = vm_treecover.up(j); + ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); + ov29_treecover_missing(t,j,"upper") = v29_treecover_missing.up(j); + ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); + ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); + ov_fallow(t,j,"upper") = vm_fallow.up(j); + ov29_fallow_missing(t,j,"upper") = v29_fallow_missing.up(j); + oq29_cropland(t,j,"upper") = q29_cropland.up(j); + oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); + oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); + oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); + oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); + oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); + oq29_fallow_min(t,j,"upper") = q29_fallow_min.up(j); + oq29_fallow_max(t,j,"upper") = q29_fallow_max.up(j); + oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); + oq29_treecover(t,j,"upper") = q29_treecover.up(j); + oq29_treecover_min(t,j,"upper") = q29_treecover_min.up(j); + oq29_treecover_max(t,j,"upper") = q29_treecover_max.up(j); + oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); + oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); + oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); + oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); + ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); + ov_treecover(t,j,"lower") = vm_treecover.lo(j); + ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); + ov29_treecover_missing(t,j,"lower") = v29_treecover_missing.lo(j); + ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); + ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); + ov_fallow(t,j,"lower") = vm_fallow.lo(j); + ov29_fallow_missing(t,j,"lower") = v29_fallow_missing.lo(j); + oq29_cropland(t,j,"lower") = q29_cropland.lo(j); + oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); + oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); + oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); + oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); + oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); + oq29_fallow_min(t,j,"lower") = q29_fallow_min.lo(j); + oq29_fallow_max(t,j,"lower") = q29_fallow_max.lo(j); + oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); + oq29_treecover(t,j,"lower") = q29_treecover.lo(j); + oq29_treecover_min(t,j,"lower") = q29_treecover_min.lo(j); + oq29_treecover_max(t,j,"lower") = q29_treecover_max.lo(j); + oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); + oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); + oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); + oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/29_cropland/detail_apr24/preloop.gms b/modules/29_cropland/detail_apr24/preloop.gms new file mode 100644 index 0000000000..f7a24e4bc9 --- /dev/null +++ b/modules/29_cropland/detail_apr24/preloop.gms @@ -0,0 +1,68 @@ +*** | (C) 2008-2025 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 + +** Trajectory for cropland scenarios +* linear or sigmoidal interpolation between start year and target year +if (s29_fader_functional_form = 1, + m_linear_time_interpol(i29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); + m_linear_time_interpol(i29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); + m_linear_time_interpol(i29_fallow_scenario_fader,s29_fallow_scenario_start,s29_fallow_scenario_target,0,1); +elseif s29_fader_functional_form = 2, + m_sigmoid_time_interpol(i29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); + m_sigmoid_time_interpol(i29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); + m_sigmoid_time_interpol(i29_fallow_scenario_fader,s29_fallow_scenario_start,s29_fallow_scenario_target,0,1); +); + +* linear interpolation to estimate the cropland that +* requires relocation due to SNV policy +if (s29_snv_shr = 0, + i29_snv_relocation_target(j) = 0; +elseif s29_snv_shr <= s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); +elseif s29_snv_shr > s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); +); + + +* Initial tree cover on cropland is assumed to be equally distributed among all age-classes +if (s29_treecover_map = 1, + pc29_treecover_share(j) = 0; + pc29_treecover_share(j)$(pm_land_hist("y2015",j,"crop") > 1e-10) = f29_treecover(j) / pm_land_hist("y2015",j,"crop"); + pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; + pc29_treecover(j,ac) = (pc29_treecover_share(j) * pm_land_hist("y1995",j,"crop")) / card(ac); +elseif s29_treecover_map = 0, + pc29_treecover(j,ac) = 0 +); +vm_treecover.l(j) = sum(ac, pc29_treecover(j,ac)); + +*' Switch for tree cover on cropland: +*' 0 = Use natveg growth curve towards LPJmL natural vegetation +*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation +if(s29_treecover_plantation = 0, + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_secdforest_ac(t,j,ac,ag_pools); +elseif s29_treecover_plantation = 1, + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_plantation_ac(t,j,ac,ag_pools); +); + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p29_country_switch(iso) = 0; +p29_country_switch(policy_countries29) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +pm_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); +p29_country_weight(i) = sum(i_to_iso(i,iso), p29_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); + +* Initialize biodiversity value +vm_fallow.l(j) = 0; +vm_bv.l(j,"crop_fallow",potnatveg) = + vm_fallow.l(j) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"crop_tree",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc29_treecover(j,ac)) * + fm_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms new file mode 100644 index 0000000000..1d9b8e0fbd --- /dev/null +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -0,0 +1,130 @@ +*** | (C) 2008-2025 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 + +* ------------------------------------------------------- +* Semi-Natural Vegetation (SNV) +* ------------------------------------------------------- + +*' @code +*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 +p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * + (s29_snv_shr * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); + +*' Cropland relocation in response to SNV policy is based on exogeneous land +*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). +*' The rate of the policy implementation is derived based +*' on the difference of scenario fader values in consecutive time steps +p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * + (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); +*' The following lines take care of mismatches in the input +*' data (derived from satellite imagery from the Copernicus +*' Global Land Service (@buchhorn_copernicus_2020)) and in +*' cases of cropland reduction +p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") + - sum(ac, pc29_treecover(j,ac)); +p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 1e-6) = 0; +p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); + +*' Area potentially available for cropping +p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv_shr(t,j)); +*' @stop + + +* ------------------------------------------------------- +* Tree cover on cropland +* ------------------------------------------------------- + +** set bii coefficients +if(m_year(t) <= sm_fix_SSP2, + p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) +else + if(s29_treecover_bii_coeff = 0, + p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) + elseif s29_treecover_bii_coeff = 1, + p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) + ); +); + +* Growth of trees on cropland is modelled by shifting age-classes according to time step length. +s29_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s29_shift = 1) + p29_treecover(t,j,ac)$(ord(ac) > s29_shift) = pc29_treecover(j,ac-s29_shift); +* account for cases at the end of the age class set (s29_shift > 1) which are not shifted by the above calculation + p29_treecover(t,j,"acx") = p29_treecover(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s29_shift), pc29_treecover(j,ac)); + +pc29_treecover(j,ac) = p29_treecover(t,j,ac); +v29_treecover.l(j,ac) = p29_treecover(t,j,ac); + +* create treecover target and penalty scenario +i29_treecover_target(t,j) = i29_treecover_scenario_fader(t) * + (s29_treecover_target * sum(cell(i,j), p29_country_weight(i)) + + s29_treecover_target_noselect * sum(cell(i,j), 1-p29_country_weight(i))); + +* calculate treecover share +pc29_treecover_share(j) = 0; +pc29_treecover_share(j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); +pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; +if (s29_treecover_keep = 1, + i29_treecover_target(t,j)$(i29_treecover_target(t,j) < pc29_treecover_share(j)) = pc29_treecover_share(j); +); + +* Bounds for treecover. Only ac_est can increase in optimization. ac_sub is fixed. +v29_treecover.lo(j,ac_est) = 0; +v29_treecover.up(j,ac_est) = Inf; +v29_treecover.fx(j,ac_sub) = pc29_treecover(j,ac_sub); +m_boundfix(v29_treecover,(j,ac_sub),l,1e-6); + +* set treecover penalty +if (m_year(t) <= s29_treecover_scenario_start, + i29_treecover_penalty(t) = s29_treecover_penalty_before; +else + i29_treecover_penalty(t) = s29_treecover_penalty; +); + +* fix missing tree cover variable to zero in case of no penalty +if (i29_treecover_penalty(t) > 0, + v29_treecover_missing.lo(j) = 0; + v29_treecover_missing.up(j) = Inf; +else + v29_treecover_missing.fx(j) = 0; +); + +* ------------------------------------------------------- +* Fallow land +* ------------------------------------------------------- + +* create fallow land target and penalty scenario +i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); + +if (m_year(t) <= s29_fallow_scenario_start, + i29_fallow_penalty(t) = 0; + v29_fallow_missing.fx(j) = 0; +else + i29_fallow_penalty(t) = s29_fallow_penalty; + if (i29_fallow_penalty(t) > 0, + v29_fallow_missing.lo(j) = 0; + v29_fallow_missing.up(j) = Inf; + else + v29_fallow_missing.fx(j) = 0; + ); +); + +* Bounds for fallow land +vm_fallow.lo(j) = 0; +vm_fallow.up(j) = p29_avl_cropland(t,j); +m_boundfix(vm_fallow,(j),l,1e-6); + +* Update biodiversity value +vm_bv.l(j,"crop_fallow",potnatveg) = + vm_fallow.l(j) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"crop_tree",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc29_treecover(j,ac)) * + p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); diff --git a/modules/29_cropland/detail_apr24/realization.gms b/modules/29_cropland/detail_apr24/realization.gms new file mode 100644 index 0000000000..cb212f6a7c --- /dev/null +++ b/modules/29_cropland/detail_apr24/realization.gms @@ -0,0 +1,31 @@ +*** | (C) 2008-2025 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, total cropland equals the sum of croparea, +*' fallow land and tree cover on cropland. Correspondingly, cropland carbon stocks consist +*' of carbons stocks for croparea, fallow land and tree cover on cropland. +*' The development of fallow land and tree cover on cropland depends on targets defined +*' as a certain fraction of total cropland. These targets can be either exogenously enforced +*' (rule-based) or endogenously incentivized by a penalty term, which enters the objective function. + +*' This realisation also includes the option to reserve a minimum semi-natural +*' vegetation share within the total available cropland for other land cover +*' classes, including grassland, forest, and other land (by a given target year), +*' in order to provide species habitats and to benefit from ecosystem ervices in +*' agricultural landscapes. + +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/29_cropland/detail_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/detail_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/29_cropland/detail_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/29_cropland/detail_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/detail_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/detail_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/detail_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/detail_apr24/sets.gms b/modules/29_cropland/detail_apr24/sets.gms new file mode 100644 index 0000000000..dd0c51463a --- /dev/null +++ b/modules/29_cropland/detail_apr24/sets.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 + + marginal_land29 Marginal land scenarios + / all_marginal, q33_marginal, no_marginal / + + relocation_target29 Cropland requiring relocation based on different SNV targets + / SNV20TargetCropland, SNV50TargetCropland / + +; diff --git a/modules/29_cropland/input/files b/modules/29_cropland/input/files new file mode 100644 index 0000000000..c4a894d426 --- /dev/null +++ b/modules/29_cropland/input/files @@ -0,0 +1,8 @@ +* list of files that are required here +avl_cropland.cs3 +avl_cropland_0.5.mz +avl_cropland_iso.cs3 +SNVTargetCropland.cs3 +SNVTargetCropland_0.5.mz +CroplandTreecover.cs2 +CroplandTreecover_0.5.mz diff --git a/modules/29_cropland/module.gms b/modules/29_cropland/module.gms new file mode 100644 index 0000000000..ba274decf6 --- /dev/null +++ b/modules/29_cropland/module.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + +*' @title Cropland + +*' @description Cropland is defined as the sum of croparea, fallow land and tree cover on cropland. +*' Croparea and corresponding carbon stocks are provided from [30_crop]. +*' Area and carbon stocks for fallow land and tree cover are defined in this module. + + +*' @authors Florian Humpenöder, Benjamin Bodirsky, Patrick v. Jeetze + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%cropland%" == "detail_apr24" $include "./modules/29_cropland/detail_apr24/realization.gms" +$Ifi "%cropland%" == "simple_apr24" $include "./modules/29_cropland/simple_apr24/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/29_cropland/simple_apr24/declarations.gms b/modules/29_cropland/simple_apr24/declarations.gms new file mode 100644 index 0000000000..d2e55e1017 --- /dev/null +++ b/modules/29_cropland/simple_apr24/declarations.gms @@ -0,0 +1,46 @@ +*** | (C) 2008-2025 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 + p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) + p29_country_weight(i) Policy country weight per region (1) + p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) + i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) + p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) + p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) + p29_country_switch(iso) Switch indicating whether country is affected by selected cropland policy (1) + pm_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) + i29_snv_scenario_fader(t_all) SNV scenario fader (1) +; + +positive variables + vm_cost_cropland(j) Cost for total cropland (mio. USD17MER per yr) + vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) + vm_treecover(j) Cropland tree cover (mio. ha) +; + +equations + q29_cropland(j) Total cropland calculation (mio. ha) + q29_avl_cropland(j) Available cropland constraint (mio. ha) + q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD17MER per yr) + ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) + ov_treecover(t,j,type) Cropland tree cover (mio. ha) + oq29_cropland(t,j,type) Total cropland calculation (mio. ha) + oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) + oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/29_cropland/simple_apr24/equations.gms b/modules/29_cropland/simple_apr24/equations.gms new file mode 100644 index 0000000000..874eb44f15 --- /dev/null +++ b/modules/29_cropland/simple_apr24/equations.gms @@ -0,0 +1,49 @@ +*** | (C) 2008-2025 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 +*' Total cropland equals croparea, because fallow land is fixed to zero +*' and tree cover on cropland does not exist in this realization. + + q29_cropland(j2) .. + vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)); + + +*' We assume that crop production can only take place on suitable cropland area. +*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas +*' from cropland production that have a low suitability, e.g. due to steep slopes, +*' to estimate the available cropland area. The cultivated area therefore has +*' to be smaller than the available cropland area. + + q29_avl_cropland(j2) .. + vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); + + +*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in +*' cropland, fallow land and tree cover area. + + q29_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + vm_carbon_stock_croparea(j2,ag_pools); + + +*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP +*' for agricultural production is added on top of land conserved for other reasons +*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). + + q29_land_snv(j2) .. + sum(land_snv, vm_land(j2,land_snv)) =g= + sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") + + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); + +*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square +*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from +*' exogeneous high-resolution land cover information from the Copernicus Global Land Service +*' (@buchhorn_copernicus_2020). + + q29_land_snv_trans(j2) .. + sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); diff --git a/modules/29_cropland/simple_apr24/input.gms b/modules/29_cropland/simple_apr24/input.gms new file mode 100644 index 0000000000..0aaa4375d0 --- /dev/null +++ b/modules/29_cropland/simple_apr24/input.gms @@ -0,0 +1,73 @@ +*** | (C) 2008-2025 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 + +$setglobal c29_marginal_land q33_marginal +* options: all_marginal, q33_marginal, no_marginal + +scalars + s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_scenario_start SNV scenario start year / 2025 / + s29_snv_scenario_target SNV scenario target year / 2050 / + s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / + s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / +; + +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries29(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + +land_snv(land) land types allowed in the SNV policy / secdforest, other / +; + +********* AVAILABLE CROPLAND ******************************************* + +table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland.cs3" +$offdelim +; + +table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland_iso.cs3" +$offdelim +; + +********* SNV TARGET CROPLAND ******************************************* + +table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) +$ondelim +$include "./modules/29_cropland/input/SNVTargetCropland.cs3" +$offdelim +; diff --git a/modules/29_cropland/simple_apr24/not_used.txt b/modules/29_cropland/simple_apr24/not_used.txt new file mode 100644 index 0000000000..db4af459ff --- /dev/null +++ b/modules/29_cropland/simple_apr24/not_used.txt @@ -0,0 +1,9 @@ +name,type,reason +pm_land_hist,input,not needed +fm_luh2_side_layers,input,not needed +pm_interest,input,not needed +fm_bii_coeff,input,not needed +pm_carbon_density_secdforest_ac,input,not needed +pm_carbon_density_plantation_ac,input,not needed +fm_carbon_density,input,not needed +sm_fix_SSP2,input,not needed diff --git a/modules/29_cropland/simple_apr24/postsolve.gms b/modules/29_cropland/simple_apr24/postsolve.gms new file mode 100644 index 0000000000..3e15387d39 --- /dev/null +++ b/modules/29_cropland/simple_apr24/postsolve.gms @@ -0,0 +1,42 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); + ov_fallow(t,j,"marginal") = vm_fallow.m(j); + ov_treecover(t,j,"marginal") = vm_treecover.m(j); + oq29_cropland(t,j,"marginal") = q29_cropland.m(j); + oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); + oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); + oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); + oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); + ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); + ov_fallow(t,j,"level") = vm_fallow.l(j); + ov_treecover(t,j,"level") = vm_treecover.l(j); + oq29_cropland(t,j,"level") = q29_cropland.l(j); + oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); + oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); + oq29_land_snv(t,j,"level") = q29_land_snv.l(j); + oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); + ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); + ov_fallow(t,j,"upper") = vm_fallow.up(j); + ov_treecover(t,j,"upper") = vm_treecover.up(j); + oq29_cropland(t,j,"upper") = q29_cropland.up(j); + oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); + oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); + oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); + oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); + ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); + ov_fallow(t,j,"lower") = vm_fallow.lo(j); + ov_treecover(t,j,"lower") = vm_treecover.lo(j); + oq29_cropland(t,j,"lower") = q29_cropland.lo(j); + oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); + oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); + oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); + oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/29_cropland/simple_apr24/preloop.gms b/modules/29_cropland/simple_apr24/preloop.gms new file mode 100644 index 0000000000..9690ef825c --- /dev/null +++ b/modules/29_cropland/simple_apr24/preloop.gms @@ -0,0 +1,36 @@ +*** | (C) 2008-2025 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_cost_cropland.fx(j) = 0; +vm_fallow.fx(j) = 0; +vm_treecover.fx(j) = 0; +vm_bv.fx(j,"crop_fallow",potnatveg) = 0; +vm_bv.fx(j,"crop_tree",potnatveg) = 0; + +** Trajectory for cropland scenarios +* sigmoidal interpolation between start year and target year +m_sigmoid_time_interpol(i29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); + +* linear interpolation to estimate the cropland that +* requires relocation due to SNV policy +if (s29_snv_shr = 0, + i29_snv_relocation_target(j) = 0; +elseif s29_snv_shr <= s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); +elseif s29_snv_shr > s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); +); + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p29_country_switch(iso) = 0; +p29_country_switch(policy_countries29) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +pm_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); +p29_country_weight(i) = sum(i_to_iso(i,iso), p29_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); diff --git a/modules/29_cropland/simple_apr24/presolve.gms b/modules/29_cropland/simple_apr24/presolve.gms new file mode 100644 index 0000000000..08b6102862 --- /dev/null +++ b/modules/29_cropland/simple_apr24/presolve.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2025 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 + + +*' @code +*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 +p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * + (s29_snv_shr * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); + +*' Cropland relocation in response to SNV policy is based on exogeneous land +*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). +*' The rate of the policy implementation is derived based +*' on the difference of scenario fader values in consecutive time steps +p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * + (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); +*' The following lines take care of mismatches in the input +*' data (derived from satellite imagery from the Copernicus +*' Global Land Service (@buchhorn_copernicus_2020)) and in +*' cases of cropland reduction +p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") + - vm_treecover.l(j); +p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 1e-6) = 0; +p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); + +*' Area potentially available for cropping +p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv_shr(t,j)); +*' @stop + diff --git a/modules/29_cropland/simple_apr24/realization.gms b/modules/29_cropland/simple_apr24/realization.gms new file mode 100644 index 0000000000..24cdc0ca35 --- /dev/null +++ b/modules/29_cropland/simple_apr24/realization.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2025 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, total cropland equals croparea because +*' fallow land and tree cover on cropland are fixed to zero. +*' Therefore, also cropland carbon stocks consist only of croparea carbon stocks. +*' Biodiversity BII values are fixed to zero. +*' Costs are fixed to zero. + +*' This realisation also includes the option to reserve a minimum semi-natural +*' vegetation share within the total available cropland for other land cover +*' classes, including grassland, forest, and other land (by a given target year), +*' in order to provide species habitats and to benefit from ecosystem ervices in +*' agricultural landscapes. + +*' @limitations Fallow land and tree cover on cropland are fixed to zero + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/29_cropland/simple_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/simple_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/29_cropland/simple_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/29_cropland/simple_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/simple_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/simple_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/simple_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/simple_apr24/sets.gms b/modules/29_cropland/simple_apr24/sets.gms new file mode 100644 index 0000000000..dd0c51463a --- /dev/null +++ b/modules/29_cropland/simple_apr24/sets.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 + + marginal_land29 Marginal land scenarios + / all_marginal, q33_marginal, no_marginal / + + relocation_target29 Cropland requiring relocation based on different SNV targets + / SNV20TargetCropland, SNV50TargetCropland / + +; diff --git a/modules/30_crop/endo_jun13/declarations.gms b/modules/30_crop/endo_jun13/declarations.gms deleted file mode 100644 index d1a819edca..0000000000 --- a/modules/30_crop/endo_jun13/declarations.gms +++ /dev/null @@ -1,33 +0,0 @@ -*** | (C) 2008-2019 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 - -positive variables - vm_area(j,kcr,w) Agricultural production area (mio. ha) -; - -equations - q30_cropland(j) Total cropland calculation (mio. ha) - q30_suitability(j) Suitability constraint (mio. ha) - q30_rotation_max(j,crp30,w) Local maximum rotational constraints (mio. ha) - q30_rotation_min(j,crp30,w) Local minimum rotational constraints (mio. ha) - q30_prod(j,kcr) Production of cropped products (mio. tDM) - q30_carbon(j,c_pools) Cropland carbon content calculation (mio. tC) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) - oq30_cropland(t,j,type) Total cropland calculation (mio. ha) - oq30_suitability(t,j,type) Suitability constraint (mio. ha) - oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) - oq30_rotation_min(t,j,crp30,w,type) Local minimum rotational constraints (mio. ha) - oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) - oq30_carbon(t,j,c_pools,type) Cropland carbon content calculation (mio. tC) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - -*** EOF declarations.gms *** diff --git a/modules/30_crop/endo_jun13/equations.gms b/modules/30_crop/endo_jun13/equations.gms deleted file mode 100644 index 61c620dc16..0000000000 --- a/modules/30_crop/endo_jun13/equations.gms +++ /dev/null @@ -1,54 +0,0 @@ -*** | (C) 2008-2019 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 -*' The total land requirements for cropland are calculated as -*' the sum of crop and water supply type specific land requirements: - - q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) =e= vm_land(j2,"crop"); - -*' We assume that crop production can only take place on suitable cropland area; -*' we use a suitability index (SI) map from @ramankutty_suitability_2002 to exclude areas -*' from cropland production that have low suitability, e.g. due to strong slopes. -*' The cultivated area therefore has to be smaller than the "si0" cropland area: - - q30_suitability(j2) .. - vm_land(j2,"crop") =l= f30_land_si(j2,"si0"); - -*' As additional constraints minimum and maximum rotational constraints limit -*' the placing of crops. On the one hand, these rotational constraints reflect -*' crop rotations limiting the share a specific crop can cover of the total area -*' of a cluster: - - q30_rotation_max(j2,crpmax30,w) .. - sum((crp_kcr30(crpmax30,kcr)), vm_area(j2,kcr,w)) =l= - sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_max_shr(crpmax30); - -*' On the other hand, it reflects boundary conditions such as minimum self -*' sufficiency constraints: - - q30_rotation_min(j2,crpmin30,w) .. - sum((crp_kcr30(crpmin30,kcr)), vm_area(j2,kcr,w)) =g= - sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_min_shr(crpmin30); - -*' Agricultural production is calculated by multiplying the area under -*' production with corresponding yields. Production from rainfed and irrigated -*' areas is summed up: - - q30_prod(j2,kcr) .. - vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); - -*' Due to the high uncertainty in 2nd generation bioenergy production, irrigated -*' production of bioenergy is deactivated (see presolve statements of crop -*' realization). - -*' The carbon content of the different carbon pools are calculated as a total -*' for all cropland : - q30_carbon(j2,c_pools) .. - vm_carbon_stock(j2,"crop",c_pools) =e= - vm_land(j2,"crop") * sum(ct,fm_carbon_density(ct,j2,"crop",c_pools)); diff --git a/modules/30_crop/endo_jun13/input.gms b/modules/30_crop/endo_jun13/input.gms deleted file mode 100644 index aa60911320..0000000000 --- a/modules/30_crop/endo_jun13/input.gms +++ /dev/null @@ -1,31 +0,0 @@ -*** | (C) 2008-2019 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 - -********* CROP-ROTATIONAL CONSTRAINT ******************************************* - -parameter f30_rotation_max_shr(crp30) Maximum allowed area shares for each crop type (1) -/ -$ondelim -$include "./modules/30_crop/endo_jun13/input/f30_rotation_max.csv" -$offdelim -/; - -parameter f30_rotation_min_shr(crp30) Minimum allowed area shares for each crop type (1) -/ -$ondelim -$include "./modules/30_crop/endo_jun13/input/f30_rotation_min.csv" -$offdelim -/; - - -********* SUITABILITY CONSTRAINT ******************************************* - -table f30_land_si(j,si) Land area suitable and non-suitable as cropland (mio. ha) -$ondelim -$include "./modules/30_crop/endo_jun13/input/avl_land_si.cs3" -$offdelim -; diff --git a/modules/30_crop/endo_jun13/input/files b/modules/30_crop/endo_jun13/input/files deleted file mode 100644 index ebeabf9276..0000000000 --- a/modules/30_crop/endo_jun13/input/files +++ /dev/null @@ -1,4 +0,0 @@ -* list of files that are required here -f30_rotation_max.csv -f30_rotation_min.csv -avl_land_si.cs3 \ No newline at end of file diff --git a/modules/30_crop/endo_jun13/postsolve.gms b/modules/30_crop/endo_jun13/postsolve.gms deleted file mode 100644 index 9f3974eb56..0000000000 --- a/modules/30_crop/endo_jun13/postsolve.gms +++ /dev/null @@ -1,38 +0,0 @@ -*** | (C) 2008-2019 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); - oq30_cropland(t,j,"marginal") = q30_cropland.m(j); - oq30_suitability(t,j,"marginal") = q30_suitability.m(j); - oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"marginal") = q30_rotation_min.m(j,crp30,w); - oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); - oq30_carbon(t,j,c_pools,"marginal") = q30_carbon.m(j,c_pools); - ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); - oq30_cropland(t,j,"level") = q30_cropland.l(j); - oq30_suitability(t,j,"level") = q30_suitability.l(j); - oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"level") = q30_rotation_min.l(j,crp30,w); - oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); - oq30_carbon(t,j,c_pools,"level") = q30_carbon.l(j,c_pools); - ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); - oq30_cropland(t,j,"upper") = q30_cropland.up(j); - oq30_suitability(t,j,"upper") = q30_suitability.up(j); - oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"upper") = q30_rotation_min.up(j,crp30,w); - oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); - oq30_carbon(t,j,c_pools,"upper") = q30_carbon.up(j,c_pools); - ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); - oq30_cropland(t,j,"lower") = q30_cropland.lo(j); - oq30_suitability(t,j,"lower") = q30_suitability.lo(j); - oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"lower") = q30_rotation_min.lo(j,crp30,w); - oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); - oq30_carbon(t,j,c_pools,"lower") = q30_carbon.lo(j,c_pools); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/endo_jun13/presolve.gms b/modules/30_crop/endo_jun13/presolve.gms deleted file mode 100644 index 49a3b67ae6..0000000000 --- a/modules/30_crop/endo_jun13/presolve.gms +++ /dev/null @@ -1,12 +0,0 @@ -*** | (C) 2008-2019 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_area.fx(j,"begr","irrigated")=0; -vm_area.fx(j,"betr","irrigated")=0; - -crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); -crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); diff --git a/modules/30_crop/endo_jun13/realization.gms b/modules/30_crop/endo_jun13/realization.gms deleted file mode 100644 index 888dd8a762..0000000000 --- a/modules/30_crop/endo_jun13/realization.gms +++ /dev/null @@ -1,28 +0,0 @@ -*** | (C) 2008-2019 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 The endo_jun13 realization calculates the crop specific -*' agricultural land use endogenously based on yield data coming from the -*' module [14_yields] and the rotational as well as suitability constrains -*' stated in the input data of the module. -*' -*' Cropland areas are linked to the crop specific production and the carbon -*' content of the different land carbon pools. The crop specific land use areas -*' are also used in [18_residues], [38_factor_costs], -*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], -*' [53_methane] and [59_som]. - -*' @limitations There are currently no known limitations of this realization. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/30_crop/endo_jun13/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/30_crop/endo_jun13/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/30_crop/endo_jun13/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/30_crop/endo_jun13/equations.gms" -$Ifi "%phase%" == "presolve" $include "./modules/30_crop/endo_jun13/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/30_crop/endo_jun13/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_crop/endo_jun13/sets.gms b/modules/30_crop/endo_jun13/sets.gms deleted file mode 100644 index bddb6294d7..0000000000 --- a/modules/30_crop/endo_jun13/sets.gms +++ /dev/null @@ -1,38 +0,0 @@ -*** | (C) 2008-2019 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 - crp30 Crop rotation types - / cereals_r, rice_r, cer_rice_r, fieldoil_r, soybean_r, rapeseed_r, - sunflower_r, groundnut_r, oilpalm_r, puls_r, potato_r, cassava_r, - roots_r, sugr_cane_r, sugr_beet_r, others_r, foddr_r, fiber_r, - begr_r, betr_r / - - crpmax30(crp30) Maximum crop rotation - crpmin30(crp30) Minimum crop rotation - - crp_kcr30(crp30,kcr) Mapping of crop types into crop rotation types - / cereals_r . (tece, maiz, trce) - rice_r . (rice_pro) - cer_rice_r . (tece, maiz, trce, rice_pro) - fieldoil_r . (soybean, rapeseed, groundnut, sunflower) - soybean_r . (soybean) - rapeseed_r . (rapeseed, sugr_beet) - sunflower_r . (sunflower) - groundnut_r . (groundnut) - oilpalm_r . (oilpalm) - puls_r . (puls_pro) - potato_r . (potato) - cassava_r . (cassav_sp) - sugr_cane_r . (sugr_cane) - sugr_beet_r . (sugr_beet) - others_r . (others) - foddr_r . (foddr) - fiber_r . (cottn_pro) - begr_r . (begr) - betr_r . (betr) / -; diff --git a/modules/30_crop/module.gms b/modules/30_crop/module.gms deleted file mode 100644 index 60d6444a4d..0000000000 --- a/modules/30_crop/module.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - - -*' @title Cropland - -*' @description The cropland module simulates the dynamics of cropland area and -*' agricultural crop production and calculates corresponding carbon contents of -*' the existing cropland. - -*' @authors Jan Philipp Dietrich, Florian Humpenöder, Benjamin Bodirsky - -*###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%crop%" == "endo_jun13" $include "./modules/30_crop/endo_jun13/realization.gms" -*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/30_croparea/detail_apr24/declarations.gms b/modules/30_croparea/detail_apr24/declarations.gms new file mode 100644 index 0000000000..d60c7a369b --- /dev/null +++ b/modules/30_croparea/detail_apr24/declarations.gms @@ -0,0 +1,69 @@ +*** | (C) 2008-2025 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 + i30_rotation_rules(t_all,rota30) Rotational constraints (1) + i30_rotation_incentives(t_all,rota30) Penalty for violating rotational constraints (USD17MER per ha) + i30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + i30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios + i30_betr_scenario_fader(t_all) Bioenergy land scenario fader (1) + i30_betr_target(t,j) Target share for bioenergy land on total cropland (1) + i30_betr_penalty(t) Penalty for violation of betr target (USD17MER per ha) + p30_country_weight(i) Policy country weight per region (1) + p30_country_switch(iso) Switch indicating whether country is affected by selected policy (1) +; + +positive variables + vm_area(j,kcr,w) Agricultural production area (mio. ha) + vm_rotation_penalty(i) Penalty for violating rotational constraints (mio. USD17MER) + vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) + v30_penalty_max_irrig(j,rotamax30) Penalty for violating max rotational constraints on irrigated land (mio. USD17MER) + v30_penalty(j,rota30) Penalty for violating rotational constraints (mio. USD17MER) + v30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) + v30_crop_area(i) Total regional crop production area (mio. ha) +; + +equations + q30_prod(j,kcr) Production of cropped products (mio. tDM) + q30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) + q30_rotation_penalty(i) Total penalty for rotational constraint violations (mio. USD17MER) + q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) + q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) + q30_rotation_max2(j,rotamax30) Local maximum rotational constraints (mio. ha) + q30_rotation_min2(j,rotamin30) Local minimum rotational constraints (mio. ha) + q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) + q30_carbon(j,ag_pools) Croplarea 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_crop_reg(i) Total regional crop production area (mio. ha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) + ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (mio. USD17MER) + ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) + ov30_penalty_max_irrig(t,j,rotamax30,type) Penalty for violating max rotational constraints on irrigated land (mio. USD17MER) + ov30_penalty(t,j,rota30,type) Penalty for violating rotational constraints (mio. USD17MER) + ov30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) + ov30_crop_area(t,i,type) Total regional crop production area (mio. ha) + oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) + oq30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) + oq30_rotation_penalty(t,i,type) Total penalty for rotational constraint violations (mio. USD17MER) + oq30_rotation_max(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) + oq30_rotation_min(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) + oq30_rotation_max2(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) + oq30_rotation_min2(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) + oq30_rotation_max_irrig(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) + oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) + 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_crop_reg(t,i,type) Total regional crop production area (mio. ha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + +*** EOF declarations.gms *** diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms new file mode 100644 index 0000000000..2f19a5fcf5 --- /dev/null +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -0,0 +1,107 @@ +*** | (C) 2008-2025 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 + +*' Agricultural production is calculated by multiplying the area under +*' production with corresponding yields. Production from rainfed and irrigated +*' areas is summed up: + + q30_prod(j2,kcr) .. + vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); + +*' A penalty is applied for the violation of bioenergy tree (betr) rules. +*' The penalty applies to the missing bioenergy tree land, i.e. where bioenergy tree land +*' is lower than a certain fraction of total cropland. + + q30_betr_missing(j2)$(sum(ct, i30_betr_penalty(ct)) > 0) .. + v30_betr_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i30_betr_target(ct,j2)) - vm_area(j2,"betr","rainfed"); + +*' Rotational constraints prevent over-specialization. In this realization, +*' they are either implemented via rules (i30_implementation = 1) or +*' a penalty payment if the constraints are violated (i30_implementation = 0). + +*' Rule-based rotational constraints (i30_implementation = 1): + +*' Minimum and maximum rotational constraints limit +*' the placing of crops. These rotational constraints reflect +*' crop rotations limiting the share a specific crop can cover of the total area +*' of a cluster. + + q30_rotation_max(j2,rotamax_red30)$(i30_implementation = 1) .. + sum((rota_kcr30(rotamax_red30,kcr),w), vm_area(j2,kcr,w)) =l= + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + + q30_rotation_min(j2,rotamin_red30)$(i30_implementation = 1) .. + sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)) =g= + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)); + +* 'Penalty-based rotational constraints (i30_implementation = 0): + + q30_rotation_penalty(i2) .. + vm_rotation_penalty(i2) =g= + sum(cell(i2,j2), + sum(rota30, v30_penalty(j2,rota30) * sum(ct, i30_rotation_incentives(ct,rota30))) + + sum(rotamax_red30, v30_penalty_max_irrig(j2,rotamax_red30) + * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) + + v30_betr_missing(j2) * sum(ct, i30_betr_penalty(ct)) + ); + +*' The penalty applies to the areas which exceed a certain maximum +*' share of the land. Below this share, negative benefits are +*' avoided by defining the penalty to be positive. + + q30_rotation_max2(j2,rotamax_red30)$(i30_implementation = 0) .. + v30_penalty(j2,rotamax_red30) =g= + sum((rota_kcr30(rotamax_red30,kcr),w),vm_area(j2,kcr,w)) + - sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + + +*' Minimum constraints apply penalties when a certain mimimum +*' share of a group is not achieved. This is used to guarantee a minimum +*' crop group diversity withing cells. + + q30_rotation_min2(j2,rotamin_red30)$(i30_implementation = 0) .. + v30_penalty(j2,rotamin_red30) =g= + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)) + - sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)); + + +*' The following maximum constraint avoids over-specialization in irrigated systems. +*' No minimum constraint is included for irrigated areas for computational +*' reasons. Minimum constraints just need to be met on total areas. + + q30_rotation_max_irrig(j2,rotamax_red30) .. + v30_penalty_max_irrig(j2,rotamax_red30) =g= + sum((rota_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) + - vm_AEI(j2) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + + +*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. + + q30_carbon(j2,ag_pools) .. + vm_carbon_stock_croparea(j2,ag_pools) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); + + +*' The biodiversity value for cropland is calculated separately for annual and perennial crops: + + q30_bv_ann(j2,potnatveg) .. + vm_bv(j2,"crop_ann",potnatveg) =e= + sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) + * fm_luh2_side_layers(j2,potnatveg); + + q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) =e= + sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) + * fm_luh2_side_layers(j2,potnatveg); + + +*' regional cropland area is calculated for the cropland growth constraint + q30_crop_reg(i2) .. v30_crop_area(i2) + =e= + sum((cell(i2,j2), kcr, w), vm_area(j2,kcr,w)); diff --git a/modules/30_croparea/detail_apr24/input.gms b/modules/30_croparea/detail_apr24/input.gms new file mode 100644 index 0000000000..b5d89bf8b4 --- /dev/null +++ b/modules/30_croparea/detail_apr24/input.gms @@ -0,0 +1,96 @@ +*** | (C) 2008-2025 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 + +$setglobal c30_bioen_type all +* options: begr, betr, all + +$setglobal c30_bioen_water rainfed +* options: rainfed, irrigated, all + +$setglobal c30_rotation_rules default +*options: min, default, good, good_20div, setaside, legumes, sixfoldrotation, agroecology, FSEC + +$setglobal c30_rotation_incentives none +*options: none, default, legumes, agroecology + + +scalars + s30_rotation_scenario_start Rotation scenario start year / 2025 / + s30_rotation_scenario_target Rotation scenario target year / 2050 / + s30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios / 1 / + s30_betr_scenario_start Bioenergy land scenario start year / 2025 / + s30_betr_scenario_target Bioenergy land scenario target year / 2050 / + s30_betr_start Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_start_noselect Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_target Share of bioenergy land on total cropland in target year (1) / 0 / + s30_betr_target_noselect Share of bioenergy land on total cropland in target year (1) / 0 / + s30_betr_penalty Penalty for violation of betr target (USD17MER per ha) / 2460 / + s30_annual_max_growth Max annual cropland growth as share of previous cropland (1) / Inf / +; + +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries30(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +$ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; +$else bioen_type_30("%c30_bioen_type%") = yes; +$endif + +$ifthen "%c30_bioen_water%" == "all" bioen_water_30(w) = yes; +$else bioen_water_30("%c30_bioen_water%") = yes; +$endif + +********* CROPAREA INITIALISATION ********************************************** + +table fm_croparea(t_all,j,w,kcr) Different croparea type areas (mio. ha) +$ondelim +$include "./modules/30_croparea/detail_apr24/input/f30_croparea_w_initialisation.cs3" +$offdelim +; +m_fillmissingyears(fm_croparea,"j,w,kcr"); + +********* CROP-ROTATIONAL CONSTRAINT ******************************************* + +table f30_rotation_incentives(rota30,incentscen30) penalties for violating rotation rules (USD17MER) +$ondelim +$include "./modules/30_croparea/detail_apr24/input/f30_rotation_incentives.csv" +$offdelim +; + +table f30_rotation_rules(rota30,rotascen30) Rotation min or max shares (1) +$ondelim +$include "./modules/30_croparea/detail_apr24/input/f30_rotation_rules.csv" +$offdelim +; + diff --git a/modules/30_croparea/detail_apr24/input/files b/modules/30_croparea/detail_apr24/input/files new file mode 100644 index 0000000000..5f3d3ac1e2 --- /dev/null +++ b/modules/30_croparea/detail_apr24/input/files @@ -0,0 +1,4 @@ +* list of files that are required here +f30_rotation_incentives.csv +f30_rotation_rules.csv +f30_croparea_w_initialisation.cs3 diff --git a/modules/30_croparea/detail_apr24/postsolve.gms b/modules/30_croparea/detail_apr24/postsolve.gms new file mode 100644 index 0000000000..e97dda0ca3 --- /dev/null +++ b/modules/30_croparea/detail_apr24/postsolve.gms @@ -0,0 +1,86 @@ +*** | (C) 2008-2025 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 + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); + ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); + ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); + ov30_penalty_max_irrig(t,j,rotamax30,"marginal") = v30_penalty_max_irrig.m(j,rotamax30); + ov30_penalty(t,j,rota30,"marginal") = v30_penalty.m(j,rota30); + ov30_betr_missing(t,j,"marginal") = v30_betr_missing.m(j); + ov30_crop_area(t,i,"marginal") = v30_crop_area.m(i); + oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); + oq30_betr_missing(t,j,"marginal") = q30_betr_missing.m(j); + oq30_rotation_penalty(t,i,"marginal") = q30_rotation_penalty.m(i); + oq30_rotation_max(t,j,rotamax30,"marginal") = q30_rotation_max.m(j,rotamax30); + oq30_rotation_min(t,j,rotamin30,"marginal") = q30_rotation_min.m(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"marginal") = q30_rotation_max2.m(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"marginal") = q30_rotation_min2.m(j,rotamin30); + oq30_rotation_max_irrig(t,j,rotamax30,"marginal") = q30_rotation_max_irrig.m(j,rotamax30); + oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); + 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_crop_reg(t,i,"marginal") = q30_crop_reg.m(i); + ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); + ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); + ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); + ov30_penalty_max_irrig(t,j,rotamax30,"level") = v30_penalty_max_irrig.l(j,rotamax30); + ov30_penalty(t,j,rota30,"level") = v30_penalty.l(j,rota30); + ov30_betr_missing(t,j,"level") = v30_betr_missing.l(j); + ov30_crop_area(t,i,"level") = v30_crop_area.l(i); + oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); + oq30_betr_missing(t,j,"level") = q30_betr_missing.l(j); + oq30_rotation_penalty(t,i,"level") = q30_rotation_penalty.l(i); + oq30_rotation_max(t,j,rotamax30,"level") = q30_rotation_max.l(j,rotamax30); + oq30_rotation_min(t,j,rotamin30,"level") = q30_rotation_min.l(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"level") = q30_rotation_max2.l(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"level") = q30_rotation_min2.l(j,rotamin30); + oq30_rotation_max_irrig(t,j,rotamax30,"level") = q30_rotation_max_irrig.l(j,rotamax30); + oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); + 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_crop_reg(t,i,"level") = q30_crop_reg.l(i); + ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); + ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); + ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); + ov30_penalty_max_irrig(t,j,rotamax30,"upper") = v30_penalty_max_irrig.up(j,rotamax30); + ov30_penalty(t,j,rota30,"upper") = v30_penalty.up(j,rota30); + ov30_betr_missing(t,j,"upper") = v30_betr_missing.up(j); + ov30_crop_area(t,i,"upper") = v30_crop_area.up(i); + oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); + oq30_betr_missing(t,j,"upper") = q30_betr_missing.up(j); + oq30_rotation_penalty(t,i,"upper") = q30_rotation_penalty.up(i); + oq30_rotation_max(t,j,rotamax30,"upper") = q30_rotation_max.up(j,rotamax30); + oq30_rotation_min(t,j,rotamin30,"upper") = q30_rotation_min.up(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"upper") = q30_rotation_max2.up(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"upper") = q30_rotation_min2.up(j,rotamin30); + oq30_rotation_max_irrig(t,j,rotamax30,"upper") = q30_rotation_max_irrig.up(j,rotamax30); + oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); + 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_crop_reg(t,i,"upper") = q30_crop_reg.up(i); + ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); + ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); + ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); + ov30_penalty_max_irrig(t,j,rotamax30,"lower") = v30_penalty_max_irrig.lo(j,rotamax30); + ov30_penalty(t,j,rota30,"lower") = v30_penalty.lo(j,rota30); + ov30_betr_missing(t,j,"lower") = v30_betr_missing.lo(j); + ov30_crop_area(t,i,"lower") = v30_crop_area.lo(i); + oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); + oq30_betr_missing(t,j,"lower") = q30_betr_missing.lo(j); + oq30_rotation_penalty(t,i,"lower") = q30_rotation_penalty.lo(i); + oq30_rotation_max(t,j,rotamax30,"lower") = q30_rotation_max.lo(j,rotamax30); + oq30_rotation_min(t,j,rotamin30,"lower") = q30_rotation_min.lo(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"lower") = q30_rotation_max2.lo(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"lower") = q30_rotation_min2.lo(j,rotamin30); + oq30_rotation_max_irrig(t,j,rotamax30,"lower") = q30_rotation_max_irrig.lo(j,rotamax30); + oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); + 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_crop_reg(t,i,"lower") = q30_crop_reg.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_croparea/detail_apr24/preloop.gms b/modules/30_croparea/detail_apr24/preloop.gms new file mode 100644 index 0000000000..73a33fc871 --- /dev/null +++ b/modules/30_croparea/detail_apr24/preloop.gms @@ -0,0 +1,50 @@ +*** | (C) 2008-2025 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 + +** Trajectory for cropland scenarios +* sigmoidal interpolation between start year and target year +m_sigmoid_time_interpol(i30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(i30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); + +** Fader for rotational constraints +i30_rotation_rules(t_all,rota30) = + f30_rotation_rules(rota30,"default") * (1-i30_rotation_scenario_fader(t_all)) + + f30_rotation_rules(rota30,"%c30_rotation_rules%") * (i30_rotation_scenario_fader(t_all)); + +** Fader for penalty for violating rotational constraints +i30_rotation_incentives(t_all,rota30) = + f30_rotation_incentives(rota30,"default") * (1-i30_rotation_scenario_fader(t_all)) + + f30_rotation_incentives(rota30,"%c30_rotation_incentives%") * (i30_rotation_scenario_fader(t_all)); + + +*due to some rounding errors the input data currently may contain in some cases +*very small, negative numbers. These numbers have to be set to 0 as area +*cannot be smaller than 0! +fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; + +* fix penalty to zero in case of rule-based rotational contraints +if(s30_implementation = 1, + v30_penalty.fx(j,rota30) = 0; +); + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p30_country_switch(iso) = 0; +p30_country_switch(policy_countries30) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +p30_country_weight(i) = sum(i_to_iso(i,iso), p30_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); + +* Initialize biodiversity value +vm_bv.l(j,"crop_ann",potnatveg) = + sum((crop_ann30,w), fm_croparea("y1995",j,w,crop_ann30)) * fm_bii_coeff("crop_ann",potnatveg) + * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"crop_per",potnatveg) = + sum((crop_per30,w), fm_croparea("y1995",j,w,crop_per30)) * fm_bii_coeff("crop_per",potnatveg) + * fm_luh2_side_layers(j,potnatveg); diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms new file mode 100644 index 0000000000..44873bb29f --- /dev/null +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -0,0 +1,61 @@ +*** | (C) 2008-2025 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 + +*' @code +*' First, all 2nd generation bioenergy area is fixed to zero, irrespective of type and +*' rainfed/irrigation. +vm_area.fx(j,kbe30,w)=0; +*' Second, the bounds for 2nd generation bioenergy area are released depending on +*' the dynamic sets bioen_type_30 and bioen_water_30. +*' SSP2 default settings are used for the historic period. +*' In addition, rule-based rotational constraints (i30_implementation = 1) +*' are assumed for the historic period. +if(m_year(t) <= sm_fix_SSP2, + vm_area.up(j,kbe30,"rainfed") = Inf; + i30_implementation = 1; +else + vm_area.up(j,bioen_type_30,bioen_water_30) = Inf; + i30_implementation = s30_implementation; +); +*' @stop + +* only activate constraints which are binding +if (i30_implementation = 1, + rotamax_red30(rotamax30) = yes$(i30_rotation_rules(t,rotamax30) < 1); + rotamin_red30(rotamin30) = yes$(i30_rotation_rules(t,rotamin30) > 0); +else + rotamax_red30(rotamax30) = yes$(i30_rotation_incentives(t,rotamax30) > 0); + rotamin_red30(rotamin30) = yes$(i30_rotation_incentives(t,rotamin30) > 0); +); + +* create betr target and penalty scenario +i30_betr_target(t,j) = (1-i30_betr_scenario_fader(t)) * + (s30_betr_start * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_start_noselect * sum(cell(i,j), 1-p30_country_weight(i))) + + i30_betr_scenario_fader(t) * + (s30_betr_target * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_target_noselect * sum(cell(i,j), 1-p30_country_weight(i))); + +if (m_year(t) <= s30_betr_scenario_start, + i30_betr_penalty(t) = 0; + v30_betr_missing.fx(j) = 0; +else + i30_betr_penalty(t) = s30_betr_penalty; + if (i30_betr_penalty(t) > 0, + v30_betr_missing.lo(j) = 0; + v30_betr_missing.up(j) = Inf; + else + v30_betr_missing.fx(j) = 0; + ); +); + +*' Cropland growth constraint after SSP2 fix +if(m_year(t) <= sm_fix_SSP2, + v30_crop_area.up(i) = Inf; +else + v30_crop_area.up(i) = v30_crop_area.l(i) * (1 + s30_annual_max_growth) ** m_yeardiff(t); +); diff --git a/modules/30_croparea/detail_apr24/realization.gms b/modules/30_croparea/detail_apr24/realization.gms new file mode 100644 index 0000000000..0f7af294d6 --- /dev/null +++ b/modules/30_croparea/detail_apr24/realization.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2025 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 This realization calculates the crop specific +*' agricultural crop area endogenously based on yield data provided by +*' module [14_yields] and detailed rotational constraints. +*' In addition, corresponding carbons stocks and BII values are calculated. +*' +*' The crop specific interface `vm_area` is used in many other modules, +*' including [18_residues], [38_factor_costs], +*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], +*' [53_methane] and [59_som]. +*' +*' This realization allows for different scenarios of rotational +*' constraints which are either implemented via hard constraints or penalty payments +*' if constraints are exceeded. Rotational constraints are defined for total croparea +*' as well as for irrigated areas only to avoid overspecialization on irrigated land. + +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/30_croparea/detail_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/30_croparea/detail_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/30_croparea/detail_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/30_croparea/detail_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/30_croparea/detail_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/30_croparea/detail_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/30_croparea/detail_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_croparea/detail_apr24/sets.gms b/modules/30_croparea/detail_apr24/sets.gms new file mode 100644 index 0000000000..16229cb559 --- /dev/null +++ b/modules/30_croparea/detail_apr24/sets.gms @@ -0,0 +1,109 @@ +*** | (C) 2008-2025 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 + incentscen30 rotation inventive scenarios + / none, default, legumes, agroecology / + + rotascen30 rotation constraint scenarios + / min, default, good, good_20div, setaside, legumes, sixfoldrotation, agroecology, FSEC / + + rota30 rotational rules + / cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, + resistant_max, oilcrops_max, + legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, + tece_max, maiz_max, trce_max, rice_max, + rapeseed_max, soybean_max, sunflower_max, groundnut_max, + oilpalm_max, puls_max, potato_max, cassava_max, + sugr_cane_max, sugr_beet_max, others_max, foddr_max, + fiber_max, begr_max, betr_max + biomass_min, legumes_min, stalk_min, others_min, + minor_min, cereals_min / + + rotamax30(rota30) rotational maximum rules + / cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, + resistant_max, oilcrops_max, + legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, + tece_max, maiz_max, trce_max, rice_max, + rapeseed_max, soybean_max, sunflower_max, groundnut_max, + oilpalm_max, puls_max, potato_max, cassava_max, + sugr_cane_max, sugr_beet_max, others_max, foddr_max, + fiber_max, begr_max, betr_max / + + rotamin30(rota30) rotational minimum rules + / biomass_min, legumes_min, stalk_min, others_min, minor_min, cereals_min / + + rotamax_red30(rotamax30) Maximum crop rotation reduced set + rotamin_red30(rotamin30) Minimum crop rotation reduced set + +* crop rotation groups: +* cereals or grasses are very favourable to loosen soils, therefore minimum constraint +* legumes need longer rotations, only soybean can and is cultivated every 2 years +* rapeseed and beets have same nematodes +* root crops have similar diseases + +* Sustainable practices: +* >=5% set-aside, >=5% biomass crops that approximate agroforestry systems +* six fold crop rotation of the remaining 90% +* at least one legume slot in crop rotation +* crop groups with multiple members like tece or foddr are allowed multiple slots +* one percent fruits and vegs in each cell for regional demand + + rota_kcr30(rota30, kcr) Mapping of crop types into crop rotation types + / cereals1_max . (tece, maiz, trce, rice_pro) + cereals2_max . (tece, maiz, trce, rice_pro) + cereals_excl_rice_max . (tece, maiz, trce) + stalk_max . (tece, maiz, trce, rice_pro, sugr_cane, begr, foddr) + resistant_max . (begr,betr,foddr,sugr_cane,cottn_pro,oilpalm,others) + oilcrops_max . (sunflower, rapeseed) + legumes_max . (foddr, puls_pro, soybean, groundnut) + rootsrape_max . (sugr_beet, cassav_sp, potato, rapeseed) + roots_max . (sugr_beet, cassav_sp, potato) + rape_sugr_max . (rapeseed, sugr_beet) + biomass_max . (sugr_cane, oilpalm, begr, betr) + + tece_max . (tece) + maiz_max . (maiz) + trce_max . (trce) + rice_max . (rice_pro) + rapeseed_max . (rapeseed) + soybean_max . (soybean) + sunflower_max . (sunflower) + groundnut_max . (groundnut) + oilpalm_max . (oilpalm) + puls_max . (puls_pro) + potato_max . (potato) + cassava_max . (cassav_sp) + sugr_cane_max . (sugr_cane) + sugr_beet_max . (sugr_beet) + others_max . (others) + foddr_max . (foddr) + fiber_max . (cottn_pro) + begr_max . (begr) + betr_max . (betr) + + biomass_min . (sugr_cane, oilpalm, begr, betr) + legumes_min . (soybean, groundnut, puls_pro, foddr) + minor_min . (sunflower, rapeseed, sugr_beet, cassav_sp, potato, others) + cereals_min . (tece, maiz, trce, rice_pro) + stalk_min . (tece, maiz, trce, rice_pro, sugr_cane, foddr) + others_min . (others) + / + + kbe30(kcr) bio energy activities + / betr, begr / + + bioen_type_30(kbe30) dynamic set bioen type + bioen_water_30(w) dynamic set bioen water + + crop_ann30(kcr) annual crops + / tece, maiz, trce, rice_pro, rapeseed, sunflower, potato, cassav_sp, sugr_beet, others, cottn_pro, foddr, soybean, groundnut, puls_pro / + + crop_per30(kcr) perennial crops + / oilpalm, begr, sugr_cane, betr / + +; diff --git a/modules/30_croparea/module.gms b/modules/30_croparea/module.gms new file mode 100644 index 0000000000..79492bca08 --- /dev/null +++ b/modules/30_croparea/module.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + + +*' @title Cropland + +*' @description The cropland module simulates the dynamics of cropland area and +*' agricultural crop production and calculates corresponding carbon contents and +*' the biodiversity value of the existing cropland. + +*' @authors Jan Philipp Dietrich, Florian Humpenöder, Benjamin Bodirsky + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%croparea%" == "detail_apr24" $include "./modules/30_croparea/detail_apr24/realization.gms" +$Ifi "%croparea%" == "simple_apr24" $include "./modules/30_croparea/simple_apr24/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/30_croparea/simple_apr24/declarations.gms b/modules/30_croparea/simple_apr24/declarations.gms new file mode 100644 index 0000000000..3430df82f6 --- /dev/null +++ b/modules/30_croparea/simple_apr24/declarations.gms @@ -0,0 +1,56 @@ +*** | (C) 2008-2025 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 + i30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + i30_betr_scenario_fader(t_all) Bioenergy land scenario fader (1) + i30_betr_target(t,j) Target share for bioenergy land on total cropland (1) + i30_betr_penalty(t) Penalty for violation of betr target (USD17MER per ha) + p30_country_weight(i) Policy country weight per region (1) + p30_country_switch(iso) Switch indicating whether country is affected by selected policy (1) +; + +positive variables + vm_area(j,kcr,w) Agricultural production area (mio. ha) + vm_rotation_penalty(i) Penalty for violating rotational constraints (mio. USD17MER) + vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) + v30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) + v30_crop_area(i) Total regional crop production area (mio. ha) +; + +equations + q30_prod(j,kcr) Production of cropped products (mio. tDM) + q30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) + q30_cost(i) Cost (mio. USD17MER) + q30_rotation_max(j,crp30,w) Local maximum rotational constraints (mio. ha) + q30_rotation_min(j,crp30,w) Local minimum rotational constraints (mio. ha) + q30_carbon(j,ag_pools) Croplarea 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_crop_reg(i) Total regional crop production area (mio. ha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) + ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (mio. USD17MER) + ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) + ov30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) + ov30_crop_area(t,i,type) Total regional crop production area (mio. ha) + oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) + oq30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) + oq30_cost(t,i,type) Cost (mio. USD17MER) + oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) + oq30_rotation_min(t,j,crp30,w,type) Local minimum rotational constraints (mio. ha) + oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) + 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_crop_reg(t,i,type) Total regional crop production area (mio. ha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + +*** EOF declarations.gms *** diff --git a/modules/30_croparea/simple_apr24/equations.gms b/modules/30_croparea/simple_apr24/equations.gms new file mode 100644 index 0000000000..0c9a633dd8 --- /dev/null +++ b/modules/30_croparea/simple_apr24/equations.gms @@ -0,0 +1,68 @@ +*** | (C) 2008-2025 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 + +*' Agricultural production is calculated by multiplying the area under +*' production with corresponding yields. Production from rainfed and irrigated +*' areas is summed up: + + q30_prod(j2,kcr) .. + vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); + +*' A penalty is applied for the violation of bioenergy tree (betr) rules. +*' The penalty applies to the missing bioenergy tree land, i.e. where bioenergy tree land +*' is lower than a certain fraction of total cropland. + + q30_betr_missing(j2)$(sum(ct, i30_betr_penalty(ct)) > 0) .. + v30_betr_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i30_betr_target(ct,j2)) - vm_area(j2,"betr","rainfed"); + + q30_cost(i2) .. + vm_rotation_penalty(i2) =g= + sum(cell(i2,j2), v30_betr_missing(j2) * sum(ct, i30_betr_penalty(ct))); + +*' As additional constraints minimum and maximum rotational constraints limit +*' the placing of crops. On the one hand, these rotational constraints reflect +*' crop rotations limiting the share a specific crop can cover of the total area +*' of a cluster: + + q30_rotation_max(j2,crpmax30,w) .. + sum((crp_kcr30(crpmax30,kcr)), vm_area(j2,kcr,w)) =l= + sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_max_shr(crpmax30); + + +*' On the other hand, it reflects boundary conditions such as minimum self +*' sufficiency constraints: + + q30_rotation_min(j2,crpmin30,w) .. + sum((crp_kcr30(crpmin30,kcr)), vm_area(j2,kcr,w)) =g= + sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_min_shr(crpmin30); + + +*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. + + q30_carbon(j2,ag_pools) .. + vm_carbon_stock_croparea(j2,ag_pools) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); + + +*' The biodiversity value for cropland is calculated separately for annual and perennial crops: + + q30_bv_ann(j2,potnatveg) .. + vm_bv(j2,"crop_ann",potnatveg) =e= + sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + q30_bv_per(j2,potnatveg) .. + vm_bv(j2,"crop_per",potnatveg) =e= + sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + +*' regional cropland area is calculated for the cropland growth constraint + q30_crop_reg(i2) .. v30_crop_area(i2) + =e= + sum((cell(i2,j2), kcr, w), vm_area(j2,kcr,w)); diff --git a/modules/30_croparea/simple_apr24/input.gms b/modules/30_croparea/simple_apr24/input.gms new file mode 100644 index 0000000000..72224a3f1f --- /dev/null +++ b/modules/30_croparea/simple_apr24/input.gms @@ -0,0 +1,96 @@ +*** | (C) 2008-2025 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 + +$setglobal c30_bioen_type all +* options: begr, betr, all + +$setglobal c30_bioen_water rainfed +* options: rainfed, irrigated, all + +$setglobal c30_rotation_constraints on +*options: on, off + +scalars + s30_rotation_scenario_start Rotation scenario start year / 2025 / + s30_rotation_scenario_target Rotation scenario target year / 2050 / + s30_betr_scenario_start Bioenergy land scenario start year / 2025 / + s30_betr_scenario_target Bioenergy land scenario target year / 2050 / + s30_betr_start Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_start_noselect Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_target Share of bioenergy land on total cropland in target year (1) / 0 / + s30_betr_target_noselect Share of bioenergy land on total cropland in target year (1) / 0 / + s30_betr_penalty Penalty for violation of betr target (USD17MER per ha) / 2460 / + s30_annual_max_growth Max annual cropland growth as share of previous cropland (1) / Inf / +; + +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries30(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +$ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; +$else bioen_type_30("%c30_bioen_type%") = yes; +$endif + +$ifthen "%c30_bioen_water%" == "all" bioen_water_30(w) = yes; +$else bioen_water_30("%c30_bioen_water%") = yes; +$endif + +********* CROPAREA INITIALISATION ********************************************** + +table fm_croparea(t_all,j,w,kcr) Different croparea type areas (mio. ha) +$ondelim +$include "./modules/30_croparea/simple_apr24/input/f30_croparea_w_initialisation.cs3" +$offdelim +; +m_fillmissingyears(fm_croparea,"j,w,kcr"); + +********* CROP-ROTATIONAL CONSTRAINT ******************************************* + +parameter f30_rotation_max_shr(crp30) Maximum allowed area shares for each crop type (1) +/ +$ondelim +$include "./modules/30_croparea/simple_apr24/input/f30_rotation_max.csv" +$offdelim +/; +$if "%c30_rotation_constraints%" == "off" f30_rotation_max_shr(crp30) = 1; + + +parameter f30_rotation_min_shr(crp30) Minimum allowed area shares for each crop type (1) +/ +$ondelim +$include "./modules/30_croparea/simple_apr24/input/f30_rotation_min.csv" +$offdelim +/; +$if "%c30_rotation_constraints%" == "off" f30_rotation_min_shr(crp30) = 0; + diff --git a/modules/30_croparea/simple_apr24/input/files b/modules/30_croparea/simple_apr24/input/files new file mode 100644 index 0000000000..f87525bfbd --- /dev/null +++ b/modules/30_croparea/simple_apr24/input/files @@ -0,0 +1,4 @@ +* list of files that are required here +f30_rotation_max.csv +f30_rotation_min.csv +f30_croparea_w_initialisation.cs3 diff --git a/modules/30_croparea/simple_apr24/not_used.txt b/modules/30_croparea/simple_apr24/not_used.txt new file mode 100644 index 0000000000..1fd7a8461c --- /dev/null +++ b/modules/30_croparea/simple_apr24/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +vm_AEI,input,questionnaire diff --git a/modules/30_croparea/simple_apr24/postsolve.gms b/modules/30_croparea/simple_apr24/postsolve.gms new file mode 100644 index 0000000000..b402e3eca0 --- /dev/null +++ b/modules/30_croparea/simple_apr24/postsolve.gms @@ -0,0 +1,66 @@ +*** | (C) 2008-2025 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 + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); + ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); + ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); + ov30_betr_missing(t,j,"marginal") = v30_betr_missing.m(j); + ov30_crop_area(t,i,"marginal") = v30_crop_area.m(i); + oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); + oq30_betr_missing(t,j,"marginal") = q30_betr_missing.m(j); + oq30_cost(t,i,"marginal") = q30_cost.m(i); + oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"marginal") = q30_rotation_min.m(j,crp30,w); + oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); + 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_crop_reg(t,i,"marginal") = q30_crop_reg.m(i); + ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); + ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); + ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); + ov30_betr_missing(t,j,"level") = v30_betr_missing.l(j); + ov30_crop_area(t,i,"level") = v30_crop_area.l(i); + oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); + oq30_betr_missing(t,j,"level") = q30_betr_missing.l(j); + oq30_cost(t,i,"level") = q30_cost.l(i); + oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"level") = q30_rotation_min.l(j,crp30,w); + oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); + 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_crop_reg(t,i,"level") = q30_crop_reg.l(i); + ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); + ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); + ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); + ov30_betr_missing(t,j,"upper") = v30_betr_missing.up(j); + ov30_crop_area(t,i,"upper") = v30_crop_area.up(i); + oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); + oq30_betr_missing(t,j,"upper") = q30_betr_missing.up(j); + oq30_cost(t,i,"upper") = q30_cost.up(i); + oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"upper") = q30_rotation_min.up(j,crp30,w); + oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); + 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_crop_reg(t,i,"upper") = q30_crop_reg.up(i); + ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); + ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); + ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); + ov30_betr_missing(t,j,"lower") = v30_betr_missing.lo(j); + ov30_crop_area(t,i,"lower") = v30_crop_area.lo(i); + oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); + oq30_betr_missing(t,j,"lower") = q30_betr_missing.lo(j); + oq30_cost(t,i,"lower") = q30_cost.lo(i); + oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"lower") = q30_rotation_min.lo(j,crp30,w); + oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); + 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_crop_reg(t,i,"lower") = q30_crop_reg.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_croparea/simple_apr24/preloop.gms b/modules/30_croparea/simple_apr24/preloop.gms new file mode 100644 index 0000000000..a20e9ccc86 --- /dev/null +++ b/modules/30_croparea/simple_apr24/preloop.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2025 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 + +** Trajectory for cropland scenarios +* sigmoidal interpolation between start year and target year +m_sigmoid_time_interpol(i30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(i30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); + +*due to some rounding errors the input data currently may contain in some cases +*very small, negative numbers. These numbers have to be set to 0 as area +*cannot be smaller than 0! +fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p30_country_switch(iso) = 0; +p30_country_switch(policy_countries30) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +p30_country_weight(i) = sum(i_to_iso(i,iso), p30_country_switch(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); + +* Initialize biodiversity value +vm_bv.l(j,"crop_ann",potnatveg) = + sum((crop_ann30,w), fm_croparea("y1995",j,w,crop_ann30)) * fm_bii_coeff("crop_ann",potnatveg) + * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"crop_per",potnatveg) = + sum((crop_per30,w), fm_croparea("y1995",j,w,crop_per30)) * fm_bii_coeff("crop_per",potnatveg) + * fm_luh2_side_layers(j,potnatveg); diff --git a/modules/30_croparea/simple_apr24/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms new file mode 100644 index 0000000000..14e8de86b8 --- /dev/null +++ b/modules/30_croparea/simple_apr24/presolve.gms @@ -0,0 +1,52 @@ +*** | (C) 2008-2025 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 + +*' @code +*' First, all 2nd generation bioenergy area is fixed to zero, irrespective of type and +*' rainfed/irrigation. +vm_area.fx(j,kbe30,w)=0; +*' Second, the bounds for 2nd generation bioenergy area are released depending on +*' the dynamic sets bioen_type_30 and bioen_water_30. +*' SSP2 default settings are used for the historic period. +if(m_year(t) <= sm_fix_SSP2, + vm_area.up(j,kbe30,"rainfed") = Inf; +else + vm_area.up(j,bioen_type_30,bioen_water_30) = Inf; +); + +*' @stop + +crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); +crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); + +* create betr target and penalty scenario +i30_betr_target(t,j) = (1-i30_betr_scenario_fader(t)) * + (s30_betr_start * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_start_noselect * sum(cell(i,j), 1-p30_country_weight(i))) + + i30_betr_scenario_fader(t) * + (s30_betr_target * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_target_noselect * sum(cell(i,j), 1-p30_country_weight(i))); + +if (m_year(t) <= s30_betr_scenario_start, + i30_betr_penalty(t) = 0; + v30_betr_missing.fx(j) = 0; +else + i30_betr_penalty(t) = s30_betr_penalty; + if (i30_betr_penalty(t) > 0, + v30_betr_missing.lo(j) = 0; + v30_betr_missing.up(j) = Inf; + else + v30_betr_missing.fx(j) = 0; + ); +); + +*' Cropland growth constraint after SSP2 fix +if(m_year(t) <= sm_fix_SSP2, + v30_crop_area.up(i) = Inf; +else + v30_crop_area.up(i) = v30_crop_area.l(i) * (1 + s30_annual_max_growth) ** m_yeardiff(t); +); diff --git a/modules/30_croparea/simple_apr24/realization.gms b/modules/30_croparea/simple_apr24/realization.gms new file mode 100644 index 0000000000..7412ab14ea --- /dev/null +++ b/modules/30_croparea/simple_apr24/realization.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2025 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 This realization calculates the crop specific +*' agricultural crop area endogenously based on yield data provided by +*' module [14_yields] and simplified rotational constraints. +*' In addition, corresponding carbons stocks and BII values are calculated. +*' +*' The crop specific interface `vm_area` is used in many other modules, +*' including [18_residues], [38_factor_costs], +*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], +*' [53_methane] and [59_som]. + +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/30_croparea/simple_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/30_croparea/simple_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/30_croparea/simple_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/30_croparea/simple_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/30_croparea/simple_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/30_croparea/simple_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/30_croparea/simple_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_croparea/simple_apr24/sets.gms b/modules/30_croparea/simple_apr24/sets.gms new file mode 100644 index 0000000000..17356a5179 --- /dev/null +++ b/modules/30_croparea/simple_apr24/sets.gms @@ -0,0 +1,51 @@ +*** | (C) 2008-2025 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 + crp30 Crop rotation types + / cereals_r, rice_r, cer_rice_r, fieldoil_r, soybean_r, rapeseed_r, + sunflower_r, groundnut_r, oilpalm_r, puls_r, potato_r, cassava_r, + roots_r, sugr_cane_r, sugr_beet_r, others_r, foddr_r, fiber_r, + begr_r, betr_r / + + crpmax30(crp30) Maximum crop rotation + crpmin30(crp30) Minimum crop rotation + + crp_kcr30(crp30,kcr) Mapping of crop types into crop rotation types + / cereals_r . (tece, maiz, trce) + rice_r . (rice_pro) + cer_rice_r . (tece, maiz, trce, rice_pro) + fieldoil_r . (soybean, rapeseed, groundnut, sunflower) + soybean_r . (soybean) + rapeseed_r . (rapeseed, sugr_beet) + sunflower_r . (sunflower) + groundnut_r . (groundnut) + oilpalm_r . (oilpalm) + puls_r . (puls_pro) + potato_r . (potato) + cassava_r . (cassav_sp) + sugr_cane_r . (sugr_cane) + sugr_beet_r . (sugr_beet) + others_r . (others) + foddr_r . (foddr) + fiber_r . (cottn_pro) + begr_r . (begr) + betr_r . (betr) / + + kbe30(kcr) bio energy activities + / betr, begr / + + bioen_type_30(kbe30) dynamic set bioen type + bioen_water_30(w) dynamic set bioen water + + crop_ann30(kcr) annual crops + / tece, maiz, trce, rice_pro, rapeseed, sunflower, potato, cassav_sp, sugr_beet, others, cottn_pro, foddr, soybean, groundnut, puls_pro / + + crop_per30(kcr) perennial crops + / oilpalm, begr, sugr_cane, betr / + +; diff --git a/modules/31_past/endo_jun13/declarations.gms b/modules/31_past/endo_jun13/declarations.gms index efc8e86820..7889f1e6aa 100644 --- a/modules/31_past/endo_jun13/declarations.gms +++ b/modules/31_past/endo_jun13/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,16 +8,23 @@ equations q31_prod(j) Cellular pasture production constraint (mio. tDM per yr) - q31_carbon(j,c_pools) Carbon content calculation for pasture (mio tC) - q31_cost_prod_past(i) Costs for putting animals on pastures (mio. USD05MER per yr) + q31_carbon(j,ag_pools,stockType) Above ground carbon content calculation for pasture (mio tC) + q31_cost_prod_past(i) Costs for putting animals on pastures (mio. USD17MER per yr) + q31_bv_manpast(j,potnatveg) Biodiversity value for managed pastures (Mha) + q31_bv_rangeland(j,potnatveg) Biodiversity value for rangeland (Mha) ; - +positive variables + vm_cost_prod_past(i) Costs for putting animals on pastures (mio. USD17MER per yr) +; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - oq31_prod(t,j,type) Cellular pasture production constraint (mio. tDM per yr) - oq31_carbon(t,j,c_pools,type) Carbon content calculation for pasture (mio tC) - oq31_cost_prod_past(t,i,type) Costs for putting animals on pastures (mio. USD05MER per yr) + ov_cost_prod_past(t,i,type) Costs for putting animals on pastures (mio. USD17MER per yr) + oq31_prod(t,j,type) Cellular pasture production constraint (mio. tDM per yr) + oq31_carbon(t,j,ag_pools,stockType,type) Above ground carbon content calculation for pasture (mio tC) + oq31_cost_prod_past(t,i,type) Costs for putting animals on pastures (mio. USD17MER per yr) + oq31_bv_manpast(t,j,potnatveg,type) Biodiversity value for managed pastures (Mha) + oq31_bv_rangeland(t,j,potnatveg,type) Biodiversity value for rangeland (Mha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/31_past/endo_jun13/equations.gms b/modules/31_past/endo_jun13/equations.gms index ebd9b49ffa..c915526996 100644 --- a/modules/31_past/endo_jun13/equations.gms +++ b/modules/31_past/endo_jun13/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -14,14 +14,14 @@ *' `vm_yld` which are delivered by the module [14_yields]: q31_prod(j2) .. - vm_prod(j2,"pasture") =e= vm_land(j2,"past") - * vm_yld(j2,"pasture","rainfed"); + vm_prod(j2,"pasture") =l= vm_land(j2,"past") + * vm_yld(j2,"pasture","rainfed"); -*' On the basis of the required pasture area, cellular carbon stocks are calculated: +*' On the basis of the required pasture area, cellular above ground carbon stocks are calculated: -q31_carbon(j2,c_pools) .. - vm_carbon_stock(j2,"past",c_pools) =e= - sum(ct, vm_land(j2,"past")*fm_carbon_density(ct,j2,"past",c_pools)); +q31_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"past",ag_pools,stockType) =e= + m_carbon_stock(vm_land,fm_carbon_density,"past"); *' In the initial calibration time step, where the pasture calibration factor *' is calculated that brings pasture biomass demand and pasture area in balance, @@ -29,10 +29,19 @@ q31_carbon(j2,c_pools) .. *' avoid overproduction of pasture in the model: q31_cost_prod_past(i2) .. - vm_cost_prod(i2,"pasture") =e= vm_prod_reg(i2,"pasture") - * s31_fac_req_past; + vm_cost_prod_past(i2) =e= sum(cell(i2,j2), vm_prod(j2,"pasture")) * s31_fac_req_past; *' For all following time steps, factor requriements `s31_fac_req_past` are set *' to zero. +*' By estimating the different area of managed pasture and rangeland via the luh2 side layers, the biodiversity value for pastures and rangeland is calculated in following: + q31_bv_manpast(j2,potnatveg) .. vm_bv(j2,"manpast",potnatveg) + =e= + vm_land(j2,"past") * fm_luh2_side_layers(j2,"manpast") * fm_bii_coeff("manpast",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + q31_bv_rangeland(j2,potnatveg) .. vm_bv(j2,"rangeland",potnatveg) + =e= + vm_land(j2,"past") * fm_luh2_side_layers(j2,"rangeland") * fm_bii_coeff("rangeland",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + *** EOF constraints.gms *** diff --git a/modules/31_past/endo_jun13/input.gms b/modules/31_past/endo_jun13/input.gms index fc1a5acddc..a8afecdc8b 100644 --- a/modules/31_past/endo_jun13/input.gms +++ b/modules/31_past/endo_jun13/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,5 +7,5 @@ scalars - s31_fac_req_past Factor requirements (USD05MER per tDM) / 1 / + s31_fac_req_past Factor requirements (USD17MER per tDM) / 1 / ; diff --git a/modules/31_past/endo_jun13/not_used.txt b/modules/31_past/endo_jun13/not_used.txt deleted file mode 100644 index ac1fbd03e2..0000000000 --- a/modules/31_past/endo_jun13/not_used.txt +++ /dev/null @@ -1,9 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason -pcm_land, input, not needed diff --git a/modules/31_past/endo_jun13/postsolve.gms b/modules/31_past/endo_jun13/postsolve.gms index cb178a1cb0..6344be6c5f 100644 --- a/modules/31_past/endo_jun13/postsolve.gms +++ b/modules/31_past/endo_jun13/postsolve.gms @@ -1,25 +1,39 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 +** Deactivate this in case you want to use pasture prodn +** Cost even after calibrartion phase s31_fac_req_past = 0; *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - oq31_prod(t,j,"marginal") = q31_prod.m(j); - oq31_carbon(t,j,c_pools,"marginal") = q31_carbon.m(j,c_pools); - oq31_cost_prod_past(t,i,"marginal") = q31_cost_prod_past.m(i); - oq31_prod(t,j,"level") = q31_prod.l(j); - oq31_carbon(t,j,c_pools,"level") = q31_carbon.l(j,c_pools); - oq31_cost_prod_past(t,i,"level") = q31_cost_prod_past.l(i); - oq31_prod(t,j,"upper") = q31_prod.up(j); - oq31_carbon(t,j,c_pools,"upper") = q31_carbon.up(j,c_pools); - oq31_cost_prod_past(t,i,"upper") = q31_cost_prod_past.up(i); - oq31_prod(t,j,"lower") = q31_prod.lo(j); - oq31_carbon(t,j,c_pools,"lower") = q31_carbon.lo(j,c_pools); - oq31_cost_prod_past(t,i,"lower") = q31_cost_prod_past.lo(i); + ov_cost_prod_past(t,i,"marginal") = vm_cost_prod_past.m(i); + oq31_prod(t,j,"marginal") = q31_prod.m(j); + oq31_carbon(t,j,ag_pools,stockType,"marginal") = q31_carbon.m(j,ag_pools,stockType); + oq31_cost_prod_past(t,i,"marginal") = q31_cost_prod_past.m(i); + oq31_bv_manpast(t,j,potnatveg,"marginal") = q31_bv_manpast.m(j,potnatveg); + oq31_bv_rangeland(t,j,potnatveg,"marginal") = q31_bv_rangeland.m(j,potnatveg); + ov_cost_prod_past(t,i,"level") = vm_cost_prod_past.l(i); + oq31_prod(t,j,"level") = q31_prod.l(j); + oq31_carbon(t,j,ag_pools,stockType,"level") = q31_carbon.l(j,ag_pools,stockType); + oq31_cost_prod_past(t,i,"level") = q31_cost_prod_past.l(i); + oq31_bv_manpast(t,j,potnatveg,"level") = q31_bv_manpast.l(j,potnatveg); + oq31_bv_rangeland(t,j,potnatveg,"level") = q31_bv_rangeland.l(j,potnatveg); + ov_cost_prod_past(t,i,"upper") = vm_cost_prod_past.up(i); + oq31_prod(t,j,"upper") = q31_prod.up(j); + oq31_carbon(t,j,ag_pools,stockType,"upper") = q31_carbon.up(j,ag_pools,stockType); + oq31_cost_prod_past(t,i,"upper") = q31_cost_prod_past.up(i); + oq31_bv_manpast(t,j,potnatveg,"upper") = q31_bv_manpast.up(j,potnatveg); + oq31_bv_rangeland(t,j,potnatveg,"upper") = q31_bv_rangeland.up(j,potnatveg); + ov_cost_prod_past(t,i,"lower") = vm_cost_prod_past.lo(i); + oq31_prod(t,j,"lower") = q31_prod.lo(j); + oq31_carbon(t,j,ag_pools,stockType,"lower") = q31_carbon.lo(j,ag_pools,stockType); + oq31_cost_prod_past(t,i,"lower") = q31_cost_prod_past.lo(i); + oq31_bv_manpast(t,j,potnatveg,"lower") = q31_bv_manpast.lo(j,potnatveg); + oq31_bv_rangeland(t,j,potnatveg,"lower") = q31_bv_rangeland.lo(j,potnatveg); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### *** EOF postsolve.gms *** diff --git a/modules/31_past/endo_jun13/preloop.gms b/modules/31_past/endo_jun13/preloop.gms new file mode 100644 index 0000000000..1894192b02 --- /dev/null +++ b/modules/31_past/endo_jun13/preloop.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + +* Initialize biodiversity value +vm_bv.l(j,"manpast",potnatveg) = + pcm_land(j,"past") * fm_luh2_side_layers(j,"manpast") * fm_bii_coeff("manpast",potnatveg) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"rangeland",potnatveg) = + pcm_land(j,"past") * fm_luh2_side_layers(j,"rangeland") * fm_bii_coeff("rangeland",potnatveg) * fm_luh2_side_layers(j,potnatveg); + diff --git a/modules/31_past/endo_jun13/presolve.gms b/modules/31_past/endo_jun13/presolve.gms new file mode 100644 index 0000000000..5200e86d3f --- /dev/null +++ b/modules/31_past/endo_jun13/presolve.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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 + +*' Total grassland area cannot be smaller than legally protected grassland area +vm_land.lo(j,"past") = sum(consv_type, pm_land_conservation(t,j,"past",consv_type)); diff --git a/modules/31_past/endo_jun13/realization.gms b/modules/31_past/endo_jun13/realization.gms index 19757d12ec..df0a30d36a 100644 --- a/modules/31_past/endo_jun13/realization.gms +++ b/modules/31_past/endo_jun13/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -21,5 +21,7 @@ $Ifi "%phase%" == "declarations" $include "./modules/31_past/endo_jun13/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/31_past/endo_jun13/input.gms" $Ifi "%phase%" == "equations" $include "./modules/31_past/endo_jun13/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/31_past/endo_jun13/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/31_past/endo_jun13/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/31_past/endo_jun13/postsolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/31_past/module.gms b/modules/31_past/module.gms index 291f04ef81..0bbc987e4f 100644 --- a/modules/31_past/module.gms +++ b/modules/31_past/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -12,9 +12,9 @@ *' of pasture biomass and the carbon content of pasture land. Therefore, the *' module requires cellular information about the carbon density related to the *' different pasture carbon pools. Furthermore, it delivers regional production -*' costs associated with pastures. +*' costs associated with pastures and biodiversity values for pasture and rangeland. *' -*' @authors Isabelle Weindl, Jan Philipp Dietrich +*' @authors Isabelle Weindl, Jan Philipp Dietrich, Marcos Alves *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%past%" == "endo_jun13" $include "./modules/31_past/endo_jun13/realization.gms" diff --git a/modules/31_past/static/not_used.txt b/modules/31_past/static/not_used.txt index 5c79c1e3a8..3b1a814ba5 100644 --- a/modules/31_past/static/not_used.txt +++ b/modules/31_past/static/not_used.txt @@ -1,11 +1,4 @@ -# | (C) 2008-2019 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 - name,type,reason vm_prod, input, not needed vm_yld, input, not needed -vm_prod_reg,input,questionnaire +pm_land_conservation,input,questionnaire diff --git a/modules/31_past/static/presolve.gms b/modules/31_past/static/presolve.gms index 8ce7afba73..9b7f45ef39 100644 --- a/modules/31_past/static/presolve.gms +++ b/modules/31_past/static/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,13 +10,21 @@ vm_land.fx(j,"past") = pcm_land(j,"past"); -*' Correspondingly, also the carbon stocks related to pasture areas are fixed. +*' Correspondingly, also the above ground carbon stocks related to pasture areas are fixed. -vm_carbon_stock.fx(j,"past",c_pools) = - pcm_land(j,"past")*fm_carbon_density(t,j,"past",c_pools); +vm_carbon_stock.fx(j,"past",ag_pools) = + pcm_land(j,"past")*fm_carbon_density(t,j,"past",ag_pools); + +*' Also the biodiversity value (BV) for pasture is fixed + +vm_bv.fx(j,"manpast",potnatveg) = + pcm_land(j,"past") * fm_luh2_side_layers(j,"manpast") * fm_bii_coeff("manpast",potnatveg) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.fx(j,"rangeland",potnatveg) = + pcm_land(j,"past") * fm_luh2_side_layers(j,"rangeland") * fm_bii_coeff("rangeland",potnatveg) * fm_luh2_side_layers(j,potnatveg); *' Regional costs associated with pasture management are set to zero. -vm_cost_prod.fx(i,"pasture") = 0; +vm_cost_prod_past.fx(i) = 0; *' @stop diff --git a/modules/31_past/static/realization.gms b/modules/31_past/static/realization.gms index 19b0307048..96dd8f7c7e 100644 --- a/modules/31_past/static/realization.gms +++ b/modules/31_past/static/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/32_forestry/affore_vegc_dec16/declarations.gms b/modules/32_forestry/affore_vegc_dec16/declarations.gms deleted file mode 100644 index caabbacc19..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/declarations.gms +++ /dev/null @@ -1,62 +0,0 @@ -*** | (C) 2008-2019 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 - s32_shift Number of 5-year age-classes corresponding to current time step length (1) -; - -parameters - p32_carbon_density(t,j,land32,c_pools) Carbon density for land32 and c_pools (tC per ha) - p32_land(t,j,ac,when) Forestry land for each cell wood type and age class before and after optimization (mio. ha) - pc32_land(j,land32) Forestry land per forestry land type initialization of the optimization (mio. ha) - p32_aff_pot(t,j) Potential afforestation area on cropland and pasture land (mio. ha) - p32_aff_pol(t,j) Exogenous afforestation target as stock (mio. ha) - p32_aff_pol_timestep(t,j) Exogenous afforestation target as flow per time step (mio. ha per timestep) - p32_aff_togo(t) Remaining exogenous afforestation wrt to the maximum exogenous target over time (mio. ha) -; - -positive variables - vm_cost_fore(i) Afforestation costs (mio. USD04MER per yr) - v32_land(j,land32) Forestry land pools (mio. ha) - vm_landdiff_forestry Aggregated difference in forestry land compared to previous timestep (mio. ha) - v32_land_expansion(j,land32) Forestry land expansion compared to previous timestep (mio. ha) - v32_land_reduction(j,land32) Forestry land reduction compared to previous timestep (mio. ha) - vm_cdr_aff(j) Total CDR from afforestation (new and existing areas) between t+1 and t=s32_planing_horizon CO2-C (mio. tC) -; - -equations - q32_cost_fore_ac(i) Total forestry costs constraint (mio. USD04MER) - q32_land(j) Land constraint (mio. ha) - q32_cdr_aff(j) Calculation of CDR from afforestation in terms of CO2-C (mio. tC) - q32_carbon(j,c_pools) Forestry carbon stock calculation C (mio. tC) - q32_land_diff Aggregated difference in forestry land compared to previous timestep (mio. ha) - q32_land_expansion(j,land32) Forestry land expansion (mio. ha) - q32_land_reduction(j,land32) Forestry land reduction (mio. ha) - q32_max_aff Maximum total global afforestation (mio. ha) - q32_aff_pol(j) Afforestation policy constraint (mio. ha) -; - - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_fore(t,i,type) Afforestation costs (mio. USD04MER per yr) - ov32_land(t,j,land32,type) Forestry land pools (mio. ha) - ov_landdiff_forestry(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) - ov32_land_expansion(t,j,land32,type) Forestry land expansion compared to previous timestep (mio. ha) - ov32_land_reduction(t,j,land32,type) Forestry land reduction compared to previous timestep (mio. ha) - ov_cdr_aff(t,j,type) Total CDR from afforestation (new and existing areas) between t+1 and t=s32_planing_horizon CO2-C (mio. tC) - oq32_cost_fore_ac(t,i,type) Total forestry costs constraint (mio. USD04MER) - oq32_land(t,j,type) Land constraint (mio. ha) - oq32_cdr_aff(t,j,type) Calculation of CDR from afforestation in terms of CO2-C (mio. tC) - oq32_carbon(t,j,c_pools,type) Forestry carbon stock calculation C (mio. tC) - oq32_land_diff(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) - oq32_land_expansion(t,j,land32,type) Forestry land expansion (mio. ha) - oq32_land_reduction(t,j,land32,type) Forestry land reduction (mio. ha) - oq32_max_aff(t,type) Maximum total global afforestation (mio. ha) - oq32_aff_pol(t,j,type) Afforestation policy constraint (mio. ha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/32_forestry/affore_vegc_dec16/equations.gms b/modules/32_forestry/affore_vegc_dec16/equations.gms deleted file mode 100644 index cf221e28f6..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/equations.gms +++ /dev/null @@ -1,75 +0,0 @@ -*** | (C) 2008-2019 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 - -*****Costs********************************************************************** - -*' The direct costs of afforestation `vm_cost_fore` include maintenance and monitoring -*' costs for newly established plantations [@sathaye_ghg_2005]. Note that "old" refers -*' to forestry plantations for wood production in 1995. -*' In addition, afforestation may cause costs in other parts of the model such -*' as costs for technological change [13_tc] or land expansion [39_landconversion]. - -q32_cost_fore_ac(i2) .. -vm_cost_fore(i2) =e= sum((cell(i2,j2),land32,fcosts32)$(not sameas(land32,"old")), - v32_land(j2,land32)*f32_fac_req_ha(i2,fcosts32)); - -*****forestry emissions seen in maccs module************************************ -*' The interface `vm_cdr_aff` provides the projected CDR of an afforestation -*' activity for a planning horizon of 30 years `s32_planing_horizon` to the [56_ghg_policy] module. - -q32_cdr_aff(j2) .. -vm_cdr_aff(j2) =e= -sum(ac$(ord(ac) > 1 -AND (ord(ac)-1) <= s32_planing_horizon/5), -v32_land(j2,"new") * -(sum(ct, pm_carbon_density_ac(ct,j2,ac,"vegc")) - -sum(ct, pm_carbon_density_ac(ct,j2,ac-1,"vegc")))); - -*****Land*************************************************** -*' The interface `vm_land` provides aggregated forestry land pools (`land32`) to other modules. - - q32_land(j2) .. - vm_land(j2,"forestry") =e= sum(land32, v32_land(j2,land32)); - -*' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. - - q32_aff_pol(j2) .. - v32_land(j2,"new_ndc") =e= sum(ct, p32_aff_pol_timestep(ct,j2)); - -*' The constraint `q32_max_aff` accounts for the allowed maximum global endogenous -*' afforestation defined in `s32_max_aff_area`. -*' Note that NPI/NDC afforestation policies are not counted towards the -*' maximum defined in `s32_max_aff_area`. Therefore, the constraint is -*' relaxed by the value of exogenously prescribed afforestation (`p32_aff_togo`). - - q32_max_aff .. sum((j2), vm_land(j2,"forestry")-pm_land_start(j2,"forestry")) - =l= s32_max_aff_area - sum(ct, p32_aff_togo(ct)); - -*****Carbon stocks************************************************************** -*' Forestry carbon stocks are calculated as the product of forestry land (`v32_land`) and the area -*' weighted mean of carbon density for carbon pools (`p32_carbon_density`). - - q32_carbon(j2,c_pools) .. vm_carbon_stock(j2,"forestry",c_pools) =e= - sum(land32, v32_land(j2,land32)* - sum(ct, p32_carbon_density(ct,j2,land32,c_pools))); - -*' Forestry land expansion and reduction is calculated as follows: - - q32_land_diff .. vm_landdiff_forestry =e= sum((j2,land32), - v32_land_expansion(j2,land32) - + v32_land_reduction(j2,land32)); - - q32_land_expansion(j2,land32) .. - v32_land_expansion(j2,land32) =g= v32_land(j2,land32) - pc32_land(j2,land32); - - q32_land_reduction(j2,land32) .. - v32_land_reduction(j2,land32) =g= pc32_land(j2,land32) - v32_land(j2,land32); - - -*** EOF equations.gms *** diff --git a/modules/32_forestry/affore_vegc_dec16/input.gms b/modules/32_forestry/affore_vegc_dec16/input.gms deleted file mode 100644 index 96c085dd73..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/input.gms +++ /dev/null @@ -1,36 +0,0 @@ -*** | (C) 2008-2019 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 -$setglobal c32_aff_mask noboreal -* options: unrestricted, noboreal, onlytropical -$setglobal c32_aff_policy npi -* options: none, npi, ndc - -scalars - s32_max_aff_area Maximum global endogenous afforestation (mio. ha) / Inf / - s32_planing_horizon Afforestation planing horizon (years) / 80 / -; - -parameter f32_aff_mask(j) Afforestation mask (1) -/ -$ondelim -$Ifi "%c32_aff_mask%" == "unrestricted" $include "./modules/32_forestry/input/aff_unrestricted.cs2" -$Ifi "%c32_aff_mask%" == "noboreal" $include "./modules/32_forestry/input/aff_noboreal.cs2" -$Ifi "%c32_aff_mask%" == "onlytropical" $include "./modules/32_forestry/input/aff_onlytropical.cs2" -$offdelim -/; - -table f32_fac_req_ha(i,fcosts32) Afforestation factor requirement costs per ha (USD04MER per ha) -$ondelim -$include "./modules/32_forestry/input/f32_fac_req_ha.csv" -$offdelim -; - -table f32_aff_pol(t_all,j,pol32) Exogenous afforestation scenario (mio. ha) -$ondelim -$include "./modules/32_forestry/input/npi_ndc_aff_pol.cs3" -$offdelim -; diff --git a/modules/32_forestry/affore_vegc_dec16/postsolve.gms b/modules/32_forestry/affore_vegc_dec16/postsolve.gms deleted file mode 100644 index 541572d681..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/postsolve.gms +++ /dev/null @@ -1,78 +0,0 @@ -*** | (C) 2008-2019 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 - -* Disaggregation of forestry land after optimization from `land32`to `ac`. -* after(ac) = growth_rate(flt)*before(ac) -p32_land(t,j,ac,"after") = - (v32_land.l(j,"new")+v32_land.l(j,"new_ndc"))$(ord(ac) = 1) - + sum(ac_land32(ac,land32)$(not sameas(land32,"new") - AND not sameas(land32,"new_ndc") - AND pc32_land(j,land32) > 0), - (v32_land.l(j,land32)/pc32_land(j,land32))*p32_land(t,j,ac,"before"))$(ord(ac) > 1); - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_fore(t,i,"marginal") = vm_cost_fore.m(i); - ov32_land(t,j,land32,"marginal") = v32_land.m(j,land32); - ov_landdiff_forestry(t,"marginal") = vm_landdiff_forestry.m; - ov32_land_expansion(t,j,land32,"marginal") = v32_land_expansion.m(j,land32); - ov32_land_reduction(t,j,land32,"marginal") = v32_land_reduction.m(j,land32); - ov_cdr_aff(t,j,"marginal") = vm_cdr_aff.m(j); - oq32_cost_fore_ac(t,i,"marginal") = q32_cost_fore_ac.m(i); - oq32_land(t,j,"marginal") = q32_land.m(j); - oq32_cdr_aff(t,j,"marginal") = q32_cdr_aff.m(j); - oq32_carbon(t,j,c_pools,"marginal") = q32_carbon.m(j,c_pools); - oq32_land_diff(t,"marginal") = q32_land_diff.m; - oq32_land_expansion(t,j,land32,"marginal") = q32_land_expansion.m(j,land32); - oq32_land_reduction(t,j,land32,"marginal") = q32_land_reduction.m(j,land32); - oq32_max_aff(t,"marginal") = q32_max_aff.m; - oq32_aff_pol(t,j,"marginal") = q32_aff_pol.m(j); - ov_cost_fore(t,i,"level") = vm_cost_fore.l(i); - ov32_land(t,j,land32,"level") = v32_land.l(j,land32); - ov_landdiff_forestry(t,"level") = vm_landdiff_forestry.l; - ov32_land_expansion(t,j,land32,"level") = v32_land_expansion.l(j,land32); - ov32_land_reduction(t,j,land32,"level") = v32_land_reduction.l(j,land32); - ov_cdr_aff(t,j,"level") = vm_cdr_aff.l(j); - oq32_cost_fore_ac(t,i,"level") = q32_cost_fore_ac.l(i); - oq32_land(t,j,"level") = q32_land.l(j); - oq32_cdr_aff(t,j,"level") = q32_cdr_aff.l(j); - oq32_carbon(t,j,c_pools,"level") = q32_carbon.l(j,c_pools); - oq32_land_diff(t,"level") = q32_land_diff.l; - oq32_land_expansion(t,j,land32,"level") = q32_land_expansion.l(j,land32); - oq32_land_reduction(t,j,land32,"level") = q32_land_reduction.l(j,land32); - oq32_max_aff(t,"level") = q32_max_aff.l; - oq32_aff_pol(t,j,"level") = q32_aff_pol.l(j); - ov_cost_fore(t,i,"upper") = vm_cost_fore.up(i); - ov32_land(t,j,land32,"upper") = v32_land.up(j,land32); - ov_landdiff_forestry(t,"upper") = vm_landdiff_forestry.up; - ov32_land_expansion(t,j,land32,"upper") = v32_land_expansion.up(j,land32); - ov32_land_reduction(t,j,land32,"upper") = v32_land_reduction.up(j,land32); - ov_cdr_aff(t,j,"upper") = vm_cdr_aff.up(j); - oq32_cost_fore_ac(t,i,"upper") = q32_cost_fore_ac.up(i); - oq32_land(t,j,"upper") = q32_land.up(j); - oq32_cdr_aff(t,j,"upper") = q32_cdr_aff.up(j); - oq32_carbon(t,j,c_pools,"upper") = q32_carbon.up(j,c_pools); - oq32_land_diff(t,"upper") = q32_land_diff.up; - oq32_land_expansion(t,j,land32,"upper") = q32_land_expansion.up(j,land32); - oq32_land_reduction(t,j,land32,"upper") = q32_land_reduction.up(j,land32); - oq32_max_aff(t,"upper") = q32_max_aff.up; - oq32_aff_pol(t,j,"upper") = q32_aff_pol.up(j); - ov_cost_fore(t,i,"lower") = vm_cost_fore.lo(i); - ov32_land(t,j,land32,"lower") = v32_land.lo(j,land32); - ov_landdiff_forestry(t,"lower") = vm_landdiff_forestry.lo; - ov32_land_expansion(t,j,land32,"lower") = v32_land_expansion.lo(j,land32); - ov32_land_reduction(t,j,land32,"lower") = v32_land_reduction.lo(j,land32); - ov_cdr_aff(t,j,"lower") = vm_cdr_aff.lo(j); - oq32_cost_fore_ac(t,i,"lower") = q32_cost_fore_ac.lo(i); - oq32_land(t,j,"lower") = q32_land.lo(j); - oq32_cdr_aff(t,j,"lower") = q32_cdr_aff.lo(j); - oq32_carbon(t,j,c_pools,"lower") = q32_carbon.lo(j,c_pools); - oq32_land_diff(t,"lower") = q32_land_diff.lo; - oq32_land_expansion(t,j,land32,"lower") = q32_land_expansion.lo(j,land32); - oq32_land_reduction(t,j,land32,"lower") = q32_land_reduction.lo(j,land32); - oq32_max_aff(t,"lower") = q32_max_aff.lo; - oq32_aff_pol(t,j,"lower") = q32_aff_pol.lo(j); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/32_forestry/affore_vegc_dec16/preloop.gms b/modules/32_forestry/affore_vegc_dec16/preloop.gms deleted file mode 100644 index 0e7f46e2ed..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/preloop.gms +++ /dev/null @@ -1,16 +0,0 @@ -*** | (C) 2008-2019 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 - -* Select afforestation policy depending on `c32_aff_policy`. -p32_aff_pol(t,j) = f32_aff_pol(t,j,"%c32_aff_policy%"); - -* Calculate the remaining exogenous afforestation with respect to the maximum exogenous target over time. -* `p32_aff_togo` is used to adjust `s32_max_aff_area` in the constraint `q32_max_aff`. -p32_aff_togo(t) = sum(j, smax(t2, p32_aff_pol(t2,j)) - p32_aff_pol(t,j)); - -*initialize parameter -p32_land(t,j,ac,when) = 0; diff --git a/modules/32_forestry/affore_vegc_dec16/presolve.gms b/modules/32_forestry/affore_vegc_dec16/presolve.gms deleted file mode 100644 index 781a2fad76..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/presolve.gms +++ /dev/null @@ -1,75 +0,0 @@ -*** | (C) 2008-2019 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 - -* Limit demand for prescribed NPI/NDC afforestation in `p32_aff_pol` if not enough suitable area (`p32_aff_pot`) for afforestation is available. - p32_aff_pot(t,j) = (vm_land.l(j,"crop") - vm_land.lo(j,"crop")) + (vm_land.l(j,"past") - vm_land.lo(j,"past")); - if((ord(t) > 1), - p32_aff_pol(t,j)$(p32_aff_pol(t,j) - p32_aff_pol(t-1,j) > p32_aff_pot(t,j)) = p32_aff_pol(t-1,j) + p32_aff_pot(t,j); - ); - -* Calculate NPI/NDC afforestation per time step based on stock changes. - p32_aff_pol_timestep("y1995",j) = 0; - p32_aff_pol_timestep(t,j)$(ord(t)>1) = p32_aff_pol(t,j) - p32_aff_pol(t-1,j); - -*' @code -*' Wood demand is set to zero because forestry is not modeled in this realization. -vm_supply.fx(i2,kforestry) = 0; - -*' Certain areas (e.g. the boreal zone) are excluded from endogenous afforestation. -v32_land.lo(j,"new") = 0; -v32_land.up(j,"new") = f32_aff_mask(j) * sum(land, pcm_land(j,land)); - -*' Endogenous afforestation is limited to cells with vegetation carbon density above 20 tC/ha. -v32_land.fx(j,"new")$(fm_carbon_density(t,j,"forestry","vegc") <= 20) = 0; -*' @stop - -* Mapping `ac_land32` between age classes `ac` and forest land types `land32` depending on -* the 30-year planning horizon `s32_planing_horizon`. The mapping `ac_land32` is used to -* aggregate age classes in `p32_land` for the optimization. Note that age-classes exist -* only between the optimization time steps (see below). -ac_land32(ac,land32) = no; -ac_land32(ac,"new") = yes$(ord(ac) = 1); -ac_land32(ac,"new_ndc") = yes$(ord(ac) = 1); -ac_land32(ac,"prot") = yes$(ord(ac) > 1 AND (ord(ac)-1) <= s32_planing_horizon/5); -ac_land32(ac,"grow") = yes$((ord(ac)-1) > s32_planing_horizon/5 AND ord(ac) < card(ac)); -ac_land32(ac,"old") = yes$(ord(ac) = card(ac)); - -* Regrowth of natural vegetation (natural succession) is modelled by shifting age-classes according to time step length. -s32_shift = m_yeardiff(t)/5; -if((ord(t) = 1), - p32_land(t,j,ac,"before") = 0$(not sameas(ac,"acx")) + pcm_land(j,"forestry")$(sameas(ac,"acx")); -else -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s32_shift = 1) - p32_land(t,j,ac,"before")$(ord(ac) > s32_shift) = p32_land(t-1,j,ac-s32_shift,"after"); -* account for cases at the end of the age class set (s32_shift > 1) which are not shifted by the above calculation - p32_land(t,j,"acx","before") = p32_land(t,j,"acx","before") - + sum(ac$(ord(ac) > card(ac)-s32_shift), p32_land(t-1,j,ac,"after")); -); - -* Age-classes exist only between the optimization time steps. -* For the optimization, we aggregate age-classes to 5 groups defined in `land32`. -v32_land.l(j,land32) = sum(ac_land32(ac,land32), p32_land(t,j,ac,"before")); -pc32_land(j,land32) = v32_land.l(j,land32); -vm_land.l(j,"forestry") = sum(land32, pc32_land(j,land32)); -pcm_land(j,"forestry") = sum(land32, pc32_land(j,land32)); - -* Fix forestry land to current levels, i.e. forestry land can not decrease in size within the optimization. -* Since there is no bound on `v32_land(j,"new")` forestry land can increase in size within the optimization. -v32_land.fx(j,"prot") = pc32_land(j,"prot"); -v32_land.fx(j,"grow") = pc32_land(j,"grow"); -v32_land.fx(j,"old") = pc32_land(j,"old"); - -* Aggregate carbon density from `ac` to `land32` for the optimization -p32_carbon_density(t,j,"new",c_pools) = pm_carbon_density_ac(t,j,"ac0",c_pools); -p32_carbon_density(t,j,"new_ndc",c_pools) = pm_carbon_density_ac(t,j,"ac0",c_pools); -p32_carbon_density(t,j,"prot",c_pools) = m_weightedmean(pm_carbon_density_ac(t,j,ac,c_pools),p32_land(t,j,ac,"before"),(ac_land32(ac,"prot"))); -p32_carbon_density(t,j,"grow",c_pools) = m_weightedmean(pm_carbon_density_ac(t,j,ac,c_pools),p32_land(t,j,ac,"before"),(ac_land32(ac,"grow"))); -p32_carbon_density(t,j,"old",c_pools) = pm_carbon_density_ac(t,j,"acx",c_pools); - - - -*** EOF presolve.gms *** diff --git a/modules/32_forestry/affore_vegc_dec16/realization.gms b/modules/32_forestry/affore_vegc_dec16/realization.gms deleted file mode 100644 index b4cc90c95d..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/realization.gms +++ /dev/null @@ -1,35 +0,0 @@ -*** | (C) 2008-2019 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 The main feature of the affore_vegc_dec16 realization is afforestation -*' for CDR. Afforestation can be modelled -*' exogenously (prescribed by NPI/NDC policies) and/or endogenously -*' (incentivized by a reward for CDR). National policies implemented (NPI) and -*' nationally determined contributions to the Paris agreement (NDC) for afforestation -*' are based on country reports. The reward for CDR from afforestation `vm_cdr_aff` -*' consists of the projected CDR within a planing horizon of 30 years -*' `s32_planing_horizon` multiplied -*' with the carbon price and annuity factor in the [56_ghg_policy] module. -*' Technically, the reward for CDR from afforestation is a negative cash flow -*' lowering the costs in the objective function of the model. -*' In this realization, afforestation is modeled as managed/assisted regrowth -*' of natural vegetation (@humpenoder_investigating_2014). The regrowth of natural -*' vegetation follows S-shaped growth curves. -*' Note that existing forestry plantations in 1995 dedicated to wood production are assumed constant throughout time. - -*' @limitations Forestry activities such as establishment or -*' harvest of plantations for wood production are not modeled. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/32_forestry/affore_vegc_dec16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/32_forestry/affore_vegc_dec16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/32_forestry/affore_vegc_dec16/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/32_forestry/affore_vegc_dec16/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/32_forestry/affore_vegc_dec16/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/32_forestry/affore_vegc_dec16/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/32_forestry/affore_vegc_dec16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/32_forestry/affore_vegc_dec16/sets.gms b/modules/32_forestry/affore_vegc_dec16/sets.gms deleted file mode 100644 index 9ab4a91c01..0000000000 --- a/modules/32_forestry/affore_vegc_dec16/sets.gms +++ /dev/null @@ -1,23 +0,0 @@ -*** | (C) 2008-2019 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 -***FORESTRY COST TYPES*** - fcosts32 Forestry factor cost types - / recur,mon / - - land32 Forestry land pools - / new, new_ndc, prot, grow, old/ - - pol32 Afforestation policy - / none, npi, ndc/ - - ac_land32(ac,land32) Mapping between age class and forestry land type - - kforestry(kall) Forestry products - / wood, woodfuel / -; -*** EOF sets.gms *** diff --git a/modules/32_forestry/dynamic_may24/declarations.gms b/modules/32_forestry/dynamic_may24/declarations.gms new file mode 100644 index 0000000000..86b337e97c --- /dev/null +++ b/modules/32_forestry/dynamic_may24/declarations.gms @@ -0,0 +1,172 @@ +*** | (C) 2008-2025 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 + s32_shift Number of 5-year age-classes corresponding to current time step length (1) + s32_establishment_dynamic If plantations should be dynamic (including establishment and harvest decsions) + s32_establishment_static Static plantations with no establishmnet no harvest no regrowth +; + +parameters + p32_aff_pol(t,j) NDC forest stock (mio. ha) + p32_aff_pol_timestep(t,j) NDC afforestation per time step (mio. ha) + p32_aff_pot(t,j) Potential afforestation area (mio. ha) + p32_max_aff_area_glo(t) Remaining afforestation area wrt to the maximum exogenous target over time (mio. ha) + p32_max_aff_area_reg(t,i) Remaining regional afforestation area wrt to the maximum exogenous target over time (mio. ha) + p32_carbon_density_ac(t,j,type32,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) + p32_carbon_density_ac_forestry(t_all,j,ac) Above ground carbon density for age classes and carbon pools (tC per ha) + p32_carbon_density_ac_marg(t_all,j,ac) Marginal above ground carbon density for age classes and carbon pools (tC per ha) + p32_land(t,j,type32,ac) Forestry land pools before optimization (mio. ha) + pc32_land(j,type32,ac) Forestry land pools in current time step (mio. ha) + p32_yield_forestry_future(t,j) Cellular timber yield expected in the future (m3 per ha per year) + p32_IGR(t_all,j,ac) Instantaneous growth rate or periodic annual increment of forest growth (1) + p32_rot_flg(t_all,j,ac) Identifier flag when calculating rotation length (1) + p32_rotation_regional(t_all,i) Regional average rotation length of plantations translated to age class equivalent for future (1) + p32_rot_length_ac_eqivalent(t_all,j) Cellular rotation length of plantations translated to age class equivalent for future (1) + p32_rotation_cellular_estb(t_all,j) Establishment rotation length translated to age classes on cellular level (1) + p32_rotation_cellular_harvesting(t_all,j) Harvesting rotation length of plantations translated to age class equivalent for future (1) + p32_cdr_ac(t,j,ac) Non-cumulative CDR from afforestation plantations for each age-class depending on planning horizon (tC per ha) + p32_rotation_offset Offset calc in age class equivalents (1) + p32_land_start_ac(j,type32,ac) Saving first value of starting land (mio. ha) + p32_time(ac) Time as a function of age-classes (yr) + p32_discount_factor(t_all,j,ac) Discount factor for each age class (1) + p32_net_present_value(t_all,j,ac) Net present value for a representative 1ha land of plantations (mio. USD) + p32_stand_value(t_all,j,ac) Stand value based on given prices (mio. USD) + p32_investment_returns_lost(t_all,j,ac) Present value of investment returns lost by not harvesting now and beginning a new series of rotations on the land (mio. USD) + p32_land_rent_weighted(t_all,j,ac) Land rent weighted by the value of the trees at harvest age-class (mio. USD) + p32_rot_flg_faustmann(t_all,j,ac) Identifier flag when calculating faustmann rotation length (1) + p32_rot_length_faustmann(t_all,j) Cellular Faustmann rotation length of plantations translated to age class equivalent (1) + p32_ncells(i) Number of cells in each region (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_avg_increment(t_all,j,ac) Mean annual increment (tC per ha per year) + p32_bii_coeff(type32,bii_class_secd,potnatveg) bii coeff (1) + 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) + pc32_prod_forestry_ini(i) Initial procution from timber plantations (mio. tDM per yr) + pc32_plant_contr_ini(i) Inital share of roundwood production coming from timber plantations (percent) + i32_plant_contr_growth_fader(t_all) Fader for growth rate of timber plantation share (percent) + p32_plant_contr(t,i) Share of roundwood production coming from timber plantations (percent) + p32_forestry_product_dist(t,i,kforestry) Distribution of wood products (1) + p32_future_to_current_demand_ratio(t,i) Ratio of future and current timber demand (1) + p32_demand_forestry_future(t,i,kforestry) Future forestry demand in current time step (tDM per yr) + p32_est_cost(type32) Establishment cost (USD17MER per ha) + i32_recurring_cost(type32) Recurring costs (USD17MER per ha) + p32_plantedforest(i) Planted forest (mio. ha) +; + +positive variables + vm_cost_fore(i) Forestry costs (Mio USD) + v32_cost_hvarea(i) Cost of harvesting timber from forests (mio. USD17MER per yr) + v32_land(j,type32,ac) Forestry land pools (mio. ha) + v32_land_missing(j) Technical area balance term for timber plantation 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 (USD17MER per 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) + 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) + v32_prod_forestry_future(i) Future expected production of woody biomass from commercial plantations (mio. tDM per yr) + v32_land_replant(j) Harvested and replanted area in timber plantations (mio. ha) + v32_ndc_area_missing(j) Technical variable reflecting missing area towards the NPI NDC re-afforestation target (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) + 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) + 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_ndc_aff_limit(j) Constraint for avoiding that NPI NDC re-afforestation happens at the cost of forests and other natural vegetation (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_prod_forestry_future(i) Future expected production of woody biomass from commercial plantations (mio. tDM per yr) + q32_establishment_demand(i) Future expected production of woody biomass from commercial plantations (mio. tDM per yr) + q32_establishment_hvarea(j) Establishment in current time step for future demand (mio. ha) + q32_establishment_fixed(j) Establishment in current time step for future demand (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) + 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. USD17MER 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_expansion_forestry(j,type32) Forestry land expansion (mio. ha) + q32_land_reduction_forestry(j,type32) Forestry land reduction (mio. ha) + q32_land_replant(j) Harvested and replanted area in timber plantations (mio. ha) + q32_co2p_aff_limit(j) Annual upper limit for re-afforestation (mio. ha per yr) +; + + +*#################### 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. USD17MER per yr) + ov32_land(t,j,type32,ac,type) Forestry land pools (mio. ha) + ov32_land_missing(t,j,type) Technical area balance term for timber plantation 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 (USD17MER per 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) + 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) + ov32_prod_forestry_future(t,i,type) Future expected production of woody biomass from commercial plantations (mio. tDM per yr) + ov32_land_replant(t,j,type) Harvested and replanted area in timber plantations (mio. ha) + ov32_ndc_area_missing(t,j,type) Technical variable reflecting missing area towards the NPI NDC re-afforestation target (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) + 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_ndc_aff_limit(t,j,type) Constraint for avoiding that NPI NDC re-afforestation happens at the cost of forests and other natural vegetation (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_prod_forestry_future(t,i,type) Future expected production of woody biomass from commercial plantations (mio. tDM per yr) + oq32_establishment_demand(t,i,type) Future expected production of woody biomass from commercial plantations (mio. tDM per yr) + oq32_establishment_hvarea(t,j,type) Establishment in current time step for future demand (mio. ha) + oq32_establishment_fixed(t,j,type) Establishment in current time step for future demand (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) + 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. USD17MER 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) + oq32_land_replant(t,j,type) Harvested and replanted area in timber plantations (mio. ha) + oq32_co2p_aff_limit(t,j,type) Annual upper limit for re-afforestation (mio. ha per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/32_forestry/dynamic_may24/equations.gms b/modules/32_forestry/dynamic_may24/equations.gms new file mode 100644 index 0000000000..1b2dfc9272 --- /dev/null +++ b/modules/32_forestry/dynamic_may24/equations.gms @@ -0,0 +1,251 @@ +*** | (C) 2008-2025 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 + +*------------------ +****** Costs ****** +*------------------ + +*' The direct costs for timber plantations and re/afforestation `vm_cost_fore` include +*' establishment cost for new forests, recurring maintenance and monitoring +*' costs for standing forests as well as harvesting costs for timber plantations. +*' In addition, this type of forest management +*' (including re/afforestation) may cause costs in other parts of the model such as costs +*' for technological change [13_tc] or land expansion [39_landconversion]. + +q32_cost_total(i2) .. vm_cost_fore(i2) =e= + v32_cost_recur(i2) + + v32_cost_establishment(i2) + + v32_cost_hvarea(i2) + + sum(cell(i2,j2), v32_land_missing(j2)) * s32_free_land_cost + + sum(cell(i2,j2), v32_ndc_area_missing(j2)) * s32_free_land_cost + ; + +*----------------------------------------------- +****** Carbon price induced afforestation ****** +*----------------------------------------------- +*' The interface `vm_cdr_aff` provides the projected biogeochemical (bgc) carbon sequestration +*' and the local biophysical (bph) warming/cooling effects of an afforestation +*' activity for a planning horizon of 50 years `s32_planning_horizon` to the [56_ghg_policy] module. + +q32_cdr_aff(j2,ac) .. +vm_cdr_aff(j2,ac,"bgc") =e= +sum(ac_est, v32_land(j2,"aff",ac_est)) * sum(ct, p32_cdr_ac(ct,j2,ac)) +; + +q32_bgp_aff(j2,ac) .. +vm_cdr_aff(j2,ac,"bph") =e= +sum(ac_est, v32_land(j2,"aff",ac_est)) * p32_aff_bgp(j2,ac); + +*' ac_est can only increase if total afforested land increases +q32_aff_est(j2) .. +sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum((ct,ac), p32_land(ct,j2,"aff",ac)); + +*----------------------------------------------- +****************** Land ************************ +*----------------------------------------------- + +*' The interface `vm_land` provides aggregated forestry land pools (`type32`) to other modules. + + 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= v32_land_expansion(j2,type32) - (v32_land_replant(j2))$sameas(type32,"plant"); + + q32_land_reduction_forestry(j2,type32) .. + vm_landreduction_forestry(j2,type32) =e= sum(ac_sub, v32_land_reduction(j2,type32,ac_sub)) - (v32_land_replant(j2))$sameas(type32,"plant"); + + q32_land_replant(j2) .. + v32_land_replant(j2) + =e= + sum(ac_sub, v32_hvarea_forestry(j2,ac_sub)) * sum(cell(i2,j2), min(1, sum(ct, p32_future_to_current_demand_ratio(ct,i2))))$s32_establishment_dynamic; + +*' The constraint `q32_aff_pol` accounts for the exogenous re/afforestation prescribed by NPI/NDC policies. + + q32_aff_pol(j2) .. + sum(ac_est, v32_land(j2,"ndc",ac_est)) + v32_ndc_area_missing(j2) =e= sum(ct, p32_aff_pol_timestep(ct,j2)); + +*' The constraint `q32_ndc_aff_limit` makes sure that NPI/NDC re/afforestation does not happen at the cost of forests and other natural vegetation. + + q32_ndc_aff_limit(j2) .. + sum(ct, p32_aff_pol_timestep(ct,j2)) * vm_natforest_reduction(j2) =e= 0; + +*' The annual upper limit for re-afforestation is based on an annual share (`s32_annual_aff_limit`) of the overall forest establishment potential (`pm_max_forest_est`). + + q32_co2p_aff_limit(j2) .. + vm_landexpansion_forestry(j2,"aff") / m_timestep_length =l= + s32_annual_aff_limit * sum(ct, pm_max_forest_est(ct,j2)); + +*' The constraint `q32_max_aff` accounts for the allowed maximum global endogenous +*' afforestation defined in `i32_max_aff_area_glo`. +*' The constraint `q32_max_aff_reg` accounts for the allowed maximum regional endogenous +*' afforestation defined in `i32_max_aff_area_reg`. +*' Only one of the two constraints is active, depending on `s32_max_aff_area_glo`. + + q32_max_aff$(s32_max_aff_area_glo=1) .. + sum((j2,ac), v32_land(j2,"aff",ac)) + =l= sum(ct, p32_max_aff_area_glo(ct)); + + q32_max_aff_reg(i2)$(s32_max_aff_area_glo=0) .. + sum((cell(i2,j2),ac), v32_land(j2,"aff",ac)) + =l= sum(ct, p32_max_aff_area_reg(ct,i2)); + +*----------------------------------------------- +************** Carbon stock ******************** +*----------------------------------------------- +*' Forestry above ground carbon stocks are calculated as the product of forestry land (`v32_land`) and the area +*' weighted mean of carbon density for carbon pools (`p32_carbon_density_ac`). + + q32_carbon(j2,ag_pools,stockType) .. vm_carbon_stock(j2,"forestry",ag_pools,stockType) =e= + m_carbon_stock_ac(v32_land,p32_carbon_density_ac,"type32,ac","type32,ac_sub"); + +*' Forestry land expansion and reduction is calculated as follows: + + 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) .. + v32_land_expansion(j2,type32) =e= + 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); + +*------------------------------------------ +*********** Biodiversity value ************ +*------------------------------------------ + +q32_bv_aff(j2,potnatveg) .. vm_bv(j2,"aff_co2p",potnatveg) + =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v32_land(j2,"aff",ac)) * + p32_bii_coeff("aff",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + +q32_bv_ndc(j2,potnatveg) .. vm_bv(j2,"aff_ndc",potnatveg) + =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v32_land(j2,"ndc",ac)) * + p32_bii_coeff("ndc",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + +q32_bv_plant(j2,potnatveg) .. vm_bv(j2,"plant",potnatveg) + =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v32_land(j2,"plant",ac)) * + p32_bii_coeff("plant",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + + +************************************************************ +**** Timber production related equations in plantations **** +************************************************************ + +**** Cost calculations +*--------------------- + +*' Cost of new plantations establishment `v32_cost_establishment` is the investment +*' made in setting up new plantations but also accounts for the expected value of +*' future harvesting costs. This makes sure that the model sticks to reasonable plantation +*' patterns over time. Present value of harvesting costs is (1+`pm_interest`)^`p32_rotation_regional` +*' and annuity factor of `pm_interest`/(1+`pm_interest`) averages the cost of this +*' investment over time. + +q32_cost_establishment(i2).. + v32_cost_establishment(i2) + =e= + (sum((cell(i2,j2),type32,ac_est), v32_land(j2,type32,ac_est) * p32_est_cost(type32))) + * sum(ct,pm_interest(ct,i2)/(1+pm_interest(ct,i2))) + + sum((ct,kforestry), v32_prod_forestry_future(i2) * p32_forestry_product_dist(ct,i2,kforestry) * im_timber_prod_cost(kforestry)) + / ((1+sum(ct,pm_interest(ct,i2)))**sum(ct, p32_rotation_regional(ct,i2)*5)); + + +*' Recurring costs are paid for plantations where the trees have to be regularly monitored +*' and maintained. These costs are only calculated because we see active human intervention +*' in commercial plantations. These costs are paid for trees used for timber production or +*' trees established for re/afforestation purposes. + +q32_cost_recur(i2) .. v32_cost_recur(i2) =e= + sum((cell(i2,j2),type32,ac_sub), v32_land(j2,type32,ac_sub) * i32_recurring_cost(type32)); + + +**** Plantation establishment decision +*------------------------------ +*' New plantations are established in the optimization step based on a certain +*' percentage (`p32_plant_contr`) of expected future demand (`p32_demand_forestry_future`). +*' As plantation establishment decisions should +*' also know some indication of expected future yields, we calculate how much yield +*' newly established plantation can realize based on rotation lengths. This is defined as +*' the expected future yield (`p32_yield_forestry_future`) at harvest. + +*' Future expected production is calculated for the establishment decision below and the costs above +*' based on newly established areas and expected future yields. + +q32_prod_forestry_future(i2) .. + v32_prod_forestry_future(i2) + =e= + sum(cell(i2,j2), (sum(ac_est, v32_land(j2,"plant",ac_est)) + v32_land_missing(j2)) * sum(ct, p32_yield_forestry_future(ct,j2))) / m_timestep_length_forestry + ; + +*' Future expected production has to be equal or larger than future demand multiplied with the plantation contribution factor. + +q32_establishment_demand(i2)$s32_establishment_dynamic .. + v32_prod_forestry_future(i2) + =g= + sum((ct,kforestry), p32_demand_forestry_future(ct,i2,kforestry)) * sum(ct, p32_plant_contr(ct,i2)) + ; + +*' Harvested areas are fully re-established at cell level, unless the ratio of future and current demand drops below 1. + +q32_establishment_hvarea(j2)$s32_establishment_dynamic .. + sum(ac_est, v32_land(j2,"plant",ac_est)) + =g= + sum(ac_sub, v32_hvarea_forestry(j2,ac_sub)) * sum(cell(i2,j2), min(1, sum(ct, p32_future_to_current_demand_ratio(ct,i2)))) + ; + +*' If plantations should be static (defined by `s32_establishment_static`) then +*' the model simply establishes the amount of plantations which are harvested. +*' this keeps the plantation area static but accounts for age-class changes and +*' regrowth during every time step. + +q32_establishment_fixed(j2)$s32_establishment_static .. + sum(ac, v32_land(j2,"plant",ac)) =e= sum(ac, pc32_land(j2,"plant",ac)); + + +*' This constraint distributes additions to forestry land over ac_est, +*' which depends on the time step length (e.g. ac0 and ac5 for a 10 year time step). + +q32_forestry_est(j2,type32,ac_est) .. +v32_land(j2,type32,ac_est) =e= sum(ac_est2, v32_land(j2,type32,ac_est2))/card(ac_est2); + +*' Change in forestry area is the difference between plantation area from previous time +*' step ('pc32_land') and optimized plantation area from current time step ('v32_land') + +q32_hvarea_forestry(j2,ac_sub) .. + v32_hvarea_forestry(j2,ac_sub) + =e= + v32_land_reduction(j2,"plant",ac_sub); + +** Timber plantation +*' Woody biomass production from timber plantations is calculated by multiplying the +*' area under production with corresponding yields of plantation forests, divided by the timestep length. + +q32_prod_forestry(j2).. + sum(kforestry, vm_prod_forestry(j2,kforestry)) + =e= + sum(ac_sub, v32_hvarea_forestry(j2,ac_sub) * sum(ct, pm_timber_yield(ct,j2,ac_sub,"forestry"))) / m_timestep_length_forestry; + +*' Harvesting cost in plantations is defined as the cost incurred while removing +*' biomass from such forests. + +q32_cost_hvarea(i2).. + v32_cost_hvarea(i2) + =e= + sum((ct,cell(i2,j2),ac_sub), v32_hvarea_forestry(j2,ac_sub)) * s32_harvesting_cost + ; + +*** EOF equations.gms *** diff --git a/modules/32_forestry/dynamic_may24/input.gms b/modules/32_forestry/dynamic_may24/input.gms new file mode 100644 index 0000000000..a3feffe9c7 --- /dev/null +++ b/modules/32_forestry/dynamic_may24/input.gms @@ -0,0 +1,99 @@ +*** | (C) 2008-2025 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 +$setglobal c32_aff_mask noboreal +* options: unrestricted, noboreal, onlytropical +$setglobal c32_aff_policy npi +* options: none, npi, ndc +$setglobal c32_aff_bgp nobgp +* options: ann,nobgp +$setglobal c32_tcre_ctrl ann_TCREmean +* options: ann_TCREmean, ann_TCREhigh, ann_TCRElow +$setglobal c32_rot_calc_type current_annual_increment +* options mean_annual_increment, current_annual_increment, instantaneous_growth_rate_reg, instantaneous_growth_rate_glo +$setglobal c32_shock_scenario none +* options none 002lin2030 004lin2030 008lin2030 016lin2030 + + +scalars + s32_hvarea Flag for harvested area and establishemt (0=zero 1=exognous 2=endogneous) / 2 / + s32_est_cost_plant Establishment cost for plantations (USD17MER per ha) / 2460 / + s32_est_cost_natveg Establishment cost for natural vegetation (USD17MER per ha) / 2460 / + s32_recurring_cost Recurring costs (USD17MER per ha) / 615 / + s32_harvesting_cost Harvesting cost (USD17MER per ha) / 1230 / + s32_planning_horizon Afforestation planing horizon (years) / 50 / + s32_rotation_extension Rotation extension factor 1=original rotations 2=100 percent increase in rotations etc (1) / 1 / + s32_faustmann_rotation Switch to activate faustmann rotations (1=on 0=off) / 0 / + s32_initial_distribution Switch to Activate ageclass distribution in plantations 0=off 1=equal distribution / 1 / + s32_price Price for timber (USD17MER) / 55 / + s32_free_land_cost Penalty for technial area balance term (USD17MER per ha) / 1e+06 / + s32_max_aff_area Maximum total global afforestation (mio. ha) / Inf / + s32_aff_plantation Switch for using growth curves for afforestation 0=natveg 1=plantations (1) / 0 / + s32_tcre_local Switch for local (1) or global (0) TRCE factors (1) / 1 / + s32_forestry_int_rate Global interest rate for plantations (percent) / 0.05 / + s32_max_self_suff Upper ceiling for the self sufficiency used in calculation for establishment decision (1) / 0.8 / + s32_aff_bii_coeff BII coefficent to be used for CO2 price driven afforestation 0=natural vegetation 1=plantation (1) / 0 / + s32_max_aff_area_glo Switch for global or regional afforestation constraint (1) / 1 / + s32_aff_prot Switch for protection of afforested areas (0=until end of planning horizon 1=forever) / 1 / + s32_plant_contr_growth_startyear Start year for plantation contribution growth fader (year) / 1995 / + s32_plant_contr_growth_endyear End year for plantation contribution growth fader (year) / 2025 / + s32_plant_contr_growth_startvalue Start value for plantation contribution growth fader (percent per year) / 0.07 / + s32_plant_contr_growth_endvalue End value for plantation contribution growth fader (percent per year) / 0 / + s32_plant_contr_max Maximum plantation contribution for establishment decision (percent) / 1 / + s32_demand_establishment Boolean switch for establishment demand assumption 1=forward looking 0=static (1) / 1 / + s32_npi_ndc_reversal Year in which NPI NDC reversal should take place (1) / Inf / + s32_min_plant_shr Minimum share of plantations in planted forests (1) / 0.05 / + s32_annual_aff_limit Annual upper limit for re-afforestation as share of overall forest establishment potential (1) / 0.03 / +; + +parameter f32_aff_mask(j) afforestation mask (binary) +/ +$ondelim +$Ifi "%c32_aff_mask%" == "unrestricted" $include "./modules/32_forestry/input/aff_unrestricted.cs2" +$Ifi "%c32_aff_mask%" == "noboreal" $include "./modules/32_forestry/input/aff_noboreal.cs2" +$Ifi "%c32_aff_mask%" == "onlytropical" $include "./modules/32_forestry/input/aff_onlytropical.cs2" +$offdelim +/; + +$onEmpty +parameter f32_max_aff_area(i) Maximum regional afforestation area (mio. ha) +/ +$ondelim +$if exist "./modules/32_forestry/input/f32_max_aff_area.cs4" $include "./modules/32_forestry/input/f32_max_aff_area.cs4" +$offdelim +/; +$offEmpty + +table f32_aff_pol(t_all,j,pol32) npi+ndc afforestation policy (Mha new forest wrt to 2010) +$ondelim +$include "./modules/32_forestry/input/npi_ndc_aff_pol.cs3" +$offdelim +; + +table f32_aff_bgp(j,bgp32) Biogeophysical temperature change of afforestation (degree C) +$ondelim +$include "./modules/32_forestry/input/f32_bph_effect_noTCRE.cs3" +$ondelim +; + +table f32_tcre(j,tcre32) Transient surface temperature response to CO2 emission (degree C per tC per ha) +$ondelim +$include "./modules/32_forestry/input/f32_localTCRE.cs3" +$ondelim +; + +parameter f32_plantedforest(i) Share of plantation forest in planted forest (1) +/ +$ondelim +$include "./modules/32_forestry/input/f32_plantedforest.cs4" +$offdelim +/; + +table f32_forest_shock(t_all, shock_scen32) Forest carbon shock scenarios (area share affected per year) +$ondelim +$include "./modules/32_forestry/input/f32_forest_shock.csv" +$offdelim +; diff --git a/modules/32_forestry/dynamic_may24/postsolve.gms b/modules/32_forestry/dynamic_may24/postsolve.gms new file mode 100644 index 0000000000..e3ad2703d0 --- /dev/null +++ b/modules/32_forestry/dynamic_may24/postsolve.gms @@ -0,0 +1,209 @@ +*** | (C) 2008-2025 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 +*' @code +*' Exchange land information after optimization +pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); +*' @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,"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); + 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); + ov32_prod_forestry_future(t,i,"marginal") = v32_prod_forestry_future.m(i); + ov32_land_replant(t,j,"marginal") = v32_land_replant.m(j); + ov32_ndc_area_missing(t,j,"marginal") = v32_ndc_area_missing.m(j); + 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; + 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_ndc_aff_limit(t,j,"marginal") = q32_ndc_aff_limit.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_prod_forestry_future(t,i,"marginal") = q32_prod_forestry_future.m(i); + oq32_establishment_demand(t,i,"marginal") = q32_establishment_demand.m(i); + oq32_establishment_hvarea(t,j,"marginal") = q32_establishment_hvarea.m(j); + oq32_establishment_fixed(t,j,"marginal") = q32_establishment_fixed.m(j); + 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); + 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); + oq32_land_replant(t,j,"marginal") = q32_land_replant.m(j); + oq32_co2p_aff_limit(t,j,"marginal") = q32_co2p_aff_limit.m(j); + 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,"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); + 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); + ov32_prod_forestry_future(t,i,"level") = v32_prod_forestry_future.l(i); + ov32_land_replant(t,j,"level") = v32_land_replant.l(j); + ov32_ndc_area_missing(t,j,"level") = v32_ndc_area_missing.l(j); + 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; + 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_ndc_aff_limit(t,j,"level") = q32_ndc_aff_limit.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_prod_forestry_future(t,i,"level") = q32_prod_forestry_future.l(i); + oq32_establishment_demand(t,i,"level") = q32_establishment_demand.l(i); + oq32_establishment_hvarea(t,j,"level") = q32_establishment_hvarea.l(j); + oq32_establishment_fixed(t,j,"level") = q32_establishment_fixed.l(j); + 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); + 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); + oq32_land_replant(t,j,"level") = q32_land_replant.l(j); + oq32_co2p_aff_limit(t,j,"level") = q32_co2p_aff_limit.l(j); + 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,"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); + 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); + ov32_prod_forestry_future(t,i,"upper") = v32_prod_forestry_future.up(i); + ov32_land_replant(t,j,"upper") = v32_land_replant.up(j); + ov32_ndc_area_missing(t,j,"upper") = v32_ndc_area_missing.up(j); + 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; + 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_ndc_aff_limit(t,j,"upper") = q32_ndc_aff_limit.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_prod_forestry_future(t,i,"upper") = q32_prod_forestry_future.up(i); + oq32_establishment_demand(t,i,"upper") = q32_establishment_demand.up(i); + oq32_establishment_hvarea(t,j,"upper") = q32_establishment_hvarea.up(j); + oq32_establishment_fixed(t,j,"upper") = q32_establishment_fixed.up(j); + 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); + 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); + oq32_land_replant(t,j,"upper") = q32_land_replant.up(j); + oq32_co2p_aff_limit(t,j,"upper") = q32_co2p_aff_limit.up(j); + 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,"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); + 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); + ov32_prod_forestry_future(t,i,"lower") = v32_prod_forestry_future.lo(i); + ov32_land_replant(t,j,"lower") = v32_land_replant.lo(j); + ov32_ndc_area_missing(t,j,"lower") = v32_ndc_area_missing.lo(j); + 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; + 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_ndc_aff_limit(t,j,"lower") = q32_ndc_aff_limit.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_prod_forestry_future(t,i,"lower") = q32_prod_forestry_future.lo(i); + oq32_establishment_demand(t,i,"lower") = q32_establishment_demand.lo(i); + oq32_establishment_hvarea(t,j,"lower") = q32_establishment_hvarea.lo(j); + oq32_establishment_fixed(t,j,"lower") = q32_establishment_fixed.lo(j); + 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); + 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); + oq32_land_replant(t,j,"lower") = q32_land_replant.lo(j); + oq32_co2p_aff_limit(t,j,"lower") = q32_co2p_aff_limit.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/32_forestry/dynamic_may24/preloop.gms b/modules/32_forestry/dynamic_may24/preloop.gms new file mode 100644 index 0000000000..81bd30ae48 --- /dev/null +++ b/modules/32_forestry/dynamic_may24/preloop.gms @@ -0,0 +1,225 @@ +*** | (C) 2008-2025 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 + +i32_recurring_cost(type32) = s32_recurring_cost; + +m_sigmoid_time_interpol(i32_plant_contr_growth_fader,s32_plant_contr_growth_startyear,s32_plant_contr_growth_endyear,s32_plant_contr_growth_startvalue,s32_plant_contr_growth_endvalue); + +p32_est_cost("plant") = s32_est_cost_plant; +p32_est_cost("ndc") = s32_est_cost_natveg; +p32_est_cost("aff") = s32_est_cost_natveg$(s32_aff_plantation = 0) + s32_est_cost_plant$(s32_aff_plantation = 1); + +** Calculation of Single rotation model rotation lengths +** Using forestry carbon densitiy here via carbon density data exchange from carbon module. +p32_carbon_density_ac_forestry(t_all,j,ac) = pm_carbon_density_plantation_ac(t_all,j,ac,"vegc"); + +** Calculating the marginal of carbon density i.e. change in carbon density over two time steps +** The carbon densities are tC/ha/year so we don't have to divide by timestep length. +loop(ac$(ord(ac) > 1), + p32_carbon_density_ac_marg(t_all,j,ac) = (p32_carbon_density_ac_forestry(t_all,j,ac) - p32_carbon_density_ac_forestry(t_all,j,ac-1))/5; + ); +p32_carbon_density_ac_marg(t_all,j,"ac0") = 0; + +** Calculating Instantaneous Growth Rates (IGR). +** This is a proxy number which can be compared against interest rate in the economy to +** make investment decisions in plantations (i.e. to keep it growing or to harvest it). +** This parameter is then used to calculate rotation lengths. +p32_IGR(t_all,j,ac) = (p32_carbon_density_ac_marg(t_all,j,ac)/p32_carbon_density_ac_forestry(t_all,j,ac))$(p32_carbon_density_ac_forestry(t_all,j,ac)>0) + + 1$(p32_carbon_density_ac_forestry(t_all,j,ac)=0); + +** Rotation length can be calculated based on Instantaneous Growth Rates (regional and global), current_annual_increment and mean_annual_increment. +** The binary parameter p32_rot_flg indicates if a plantation should be kept (1) or harvested (0). +** Example for Instantaneous Growth Rates (IGR): +** If IGR > interest rate, plantations should be kept (1). +** If IGR < interest rate, plantations should be harvested (0). + +$ifthen "%c32_rot_calc_type%" == "instantaneous_growth_rate_reg" + p32_rot_flg(t_all,j,ac) = 1$(p32_IGR(t_all,j,ac) - sum(cell(i,j),pm_interest("y1995",i)) > 0) + + 0$(p32_IGR(t_all,j,ac) - sum(cell(i,j),pm_interest("y1995",i)) <= 0); + display "Rotation lengths are calculated based on equating instantaneous growth rate to regional interest rate."; + +$elseif "%c32_rot_calc_type%" == "instantaneous_growth_rate_glo" + p32_rot_flg(t_all,j,ac) = 1$(p32_IGR(t_all,j,ac) - s32_forestry_int_rate > 0) + + 0$(p32_IGR(t_all,j,ac) - s32_forestry_int_rate <= 0); + display "Rotation lengths are calculated based on equating instantaneous growth rate to global interest rate."; + +$elseif "%c32_rot_calc_type%" == "current_annual_increment" + p32_rot_flg(t_all,j,ac) = 1$(p32_carbon_density_ac_marg(t_all,j,ac) - p32_carbon_density_ac_marg(t_all,j,ac-1) > 0) + + 0$(p32_carbon_density_ac_marg(t_all,j,ac) - p32_carbon_density_ac_marg(t_all,j,ac-1) <= 0); + display "Rotation lengths are calculated based on maximizing current annual increment in this run."; + +$elseif "%c32_rot_calc_type%" == "mean_annual_increment" + p32_avg_increment(t_all,j,ac) = pm_carbon_density_plantation_ac(t_all,j,ac,"vegc") / ((ord(ac)+1)*5); + p32_rot_flg(t_all,j,ac) = 1$(p32_carbon_density_ac_marg(t_all,j,ac) - p32_avg_increment(t_all,j,ac) > 0) + + 0$(p32_carbon_density_ac_marg(t_all,j,ac) - p32_avg_increment(t_all,j,ac) <= 0); + display "Rotation lengths are calculated based on maximizing mean annual increment in this run."; +$endif + +********************************************************************************* + +** Faustmann rotation lengths: + +p32_time(ac) = ord(ac); + +p32_discount_factor(t_all,j,ac) = 1/(exp(sum(cell(i,j),pm_interest(t_all,i))*p32_time(ac))); + +p32_net_present_value(t_all,j,ac) = ((s32_price * p32_carbon_density_ac_forestry(t_all,j,ac) * p32_discount_factor(t_all,j,ac)))/(1-p32_discount_factor(t_all,j,ac)); + +p32_stand_value(t_all,j,ac) = s32_price * p32_carbon_density_ac_forestry(t_all,j,ac); +p32_stand_value(t_all,j,ac)$(p32_stand_value(t_all,j,ac)<0.01) = 0.01; + +p32_investment_returns_lost(t_all,j,ac) = sum(cell(i,j),pm_interest(t_all,i)) * p32_net_present_value(t_all,j,ac); +p32_land_rent_weighted(t_all,j,ac) = p32_investment_returns_lost(t_all,j,ac)/p32_stand_value(t_all,j,ac) ; + +p32_rot_flg_faustmann(t_all,j,ac) = 1$(p32_IGR(t_all,j,ac) > sum(cell(i,j),pm_interest(t_all,i)) + p32_land_rent_weighted(t_all,j,ac)) + + 0$(p32_IGR(t_all,j,ac) <= sum(cell(i,j),pm_interest(t_all,i)) + p32_land_rent_weighted(t_all,j,ac)); + +p32_rot_length_faustmann(t_all,j) = sum(ac,p32_rot_flg_faustmann(t_all,j,ac)); + +********************************************************************************* + +** Change rotation based on switch. If not use calculation before faustmann +if(s32_faustmann_rotation = 0, + p32_rot_length_ac_eqivalent(t_all,j) = sum(ac,p32_rot_flg(t_all,j,ac)); +elseif s32_faustmann_rotation = 1, + p32_rot_length_ac_eqivalent(t_all,j) = sum(ac,p32_rot_flg_faustmann(t_all,j,ac)); +); + +** We provide a upper limit of 90 years for commercial plantations. +** 90 years translates to age-class 18 (90/5) +p32_rot_length_ac_eqivalent(t_all,j)$(p32_rot_length_ac_eqivalent(t_all,j)>18) = 18; +p32_rot_length_ac_eqivalent(t_historical,j) = p32_rot_length_ac_eqivalent("y1995",j); + +** Holding rotation lengths constant after the end of this century. +p32_rot_length_ac_eqivalent(t_future,j) = p32_rot_length_ac_eqivalent("y2100",j); + +** Number of cells in each region +p32_ncells(i) = sum(cell(i,j),1); + +**** Representative regional rotation +loop(t_all, + p32_rotation_regional(t_all,i) = ceil(sum(cell(i,j), p32_rot_length_ac_eqivalent(t_all,j))/p32_ncells(i)); + ); + +** Earlier we converted rotation lengths to absolute numbers, now we make the Conversion +** back to rotation length in age-classes. +p32_rotation_cellular_estb(t_all,j) = ceil(p32_rot_length_ac_eqivalent(t_all,j)); + +** Set harvesting rotations same as establishment rotations -- Don't move this line below extension of rotation. This is overwritten in the next loop anyways +p32_rotation_cellular_harvesting(t_all,j) = p32_rotation_cellular_estb(t_all,j); + +** RL Extension +p32_rotation_cellular_estb(t_all,j) = p32_rotation_cellular_estb(t_all,j) * s32_rotation_extension ; + +** With the following loop, harvesting rotations are updated based on the rotation length +** at which the establishment of plantations was made. For example, an establishment with +** 50 year rotation in mind in year 2000 shall be available for harvest when the age of +** this plantation is 50 years in 2050. The following loop makes sure that the harvesting +** age is updated correctly in the future. + +loop(j, + loop(t_all, + p32_rotation_offset = p32_rotation_cellular_estb(t_all,j); +* The harvest year is calculated for future based on current establishment decision + p32_rotation_cellular_harvesting(t_all+p32_rotation_offset,j) = p32_rotation_cellular_estb(t_all,j); + ); + ); + +** This loop fixes empty gaps. +** For example in 2035, if establishment length was 10 (50yrs) then it should be harvested in 2085 +** But in 2040, lets say if establishment length was 11 (55yrs) then the harvesting should happen in 2095. +** This leaves y2090 with a gap where model doesn't know which value to choose +** At this point, it takes the values which were initialized in lines above +** where we give harvested rotations the same value as establishment rotation to start with +** The loop below makes some educated guess based on jumps during these blind spots and fills them with proper numbers +loop(t_all, + p32_rotation_cellular_harvesting(t_all+1,j)$(abs(p32_rotation_cellular_harvesting(t_all+1,j) - p32_rotation_cellular_harvesting(t_all,j))>2 AND ord(t_all)= 1 AND ac.off < p32_rotation_cellular_harvesting("y1995",j)); + +** Set minimum share of plantations in planted forest +p32_plantedforest(i) = f32_plantedforest(i); +p32_plantedforest(i)$(p32_plantedforest(i) < s32_min_plant_shr) = s32_min_plant_shr; + +** divide initial forestry area by number of age classes within ini32 +if(s32_initial_distribution = 0, +** Initialize with highest age class + p32_land_start_ac(j,"plant","acx") = pcm_land(j,"forestry") * sum(cell(i,j),p32_plantedforest(i)); + p32_land_start_ac(j,"ndc","acx") = pcm_land(j,"forestry") * sum(cell(i,j),1-p32_plantedforest(i)); + +elseif s32_initial_distribution = 1, +** Initialize with equal distribution among rotation age classes +** Plantated forest area is divided into ndcs (other planted forest) and plantations + p32_land_start_ac(j,"plant",ac)$(ini32(j,ac)) = pm_land_start(j,"forestry") * sum(cell(i,j),p32_plantedforest(i))/p32_rotation_cellular_harvesting("y1995",j); + p32_land_start_ac(j,"ndc",ac)$(ini32(j,ac)) = pm_land_start(j,"forestry") * sum(cell(i,j),1- p32_plantedforest(i))/p32_rotation_cellular_harvesting("y1995",j); + +); + +** Redistribute to youngest age class in case the distribution to plantations and +** ndcs does not match fully with LUH initialized data +loop(j, + if(pm_land_start(j,"forestry") > sum((type32,ac),p32_land_start_ac(j,type32,ac)), + 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))); + ); +); + +** Initialize forestry land types +pc32_land(j,type32,ac) = p32_land_start_ac(j,type32,ac); + +** Afforestation policies NPI and NDCs +p32_aff_pol(t,j) = round(f32_aff_pol(t,j,"%c32_aff_policy%"),6); + + +*fix bph effect to zero for all age classes except the ac that is chosen for the bph effect to occur after planting (e.g. canopy closure) +*fade-in from ac10 to ac30. First effect in ac10 (ord 3), last effect in ac30 (ord 7). +ac_bph(ac) = no; +ac_bph(ac) = yes$(ord(ac) >= 3 AND ord(ac) <= 7); +display ac_bph; + +p32_aff_bgp(j,ac) = 0; +p32_tcre_glo(j) = 0; +if(s32_tcre_local = 1, + p32_aff_bgp(j,ac_bph) = f32_aff_bgp(j,"%c32_aff_bgp%")/f32_tcre(j,"%c32_tcre_ctrl%")/card(ac_bph); +else +*m_weightedmean returns a global value, which is then used assigned to all j. We use land area as weight. + p32_tcre_glo(j2) = m_weightedmean(f32_tcre(j,"%c32_tcre_ctrl%"),sum(land, pcm_land(j,land)),j); + p32_aff_bgp(j,ac_bph) = f32_aff_bgp(j,"%c32_aff_bgp%")/p32_tcre_glo(j)/card(ac_bph); +); + +** set bii coefficients +p32_bii_coeff(type32,bii_class_secd,potnatveg) = 0; +if(s32_aff_bii_coeff = 0, + p32_bii_coeff("aff",bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) +elseif s32_aff_bii_coeff = 1, + p32_bii_coeff("aff",bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) +); +p32_bii_coeff("ndc",bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg); +p32_bii_coeff("plant",bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg); + +* initialize parameter +p32_land(t,j,type32,ac) = 0; + +* initialize forest disturbance losses +p32_disturbance_loss_ftype32(t,j,"aff",ac) = 0; + +* Initialize biodiversity value +vm_bv.l(j,"aff_co2p",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc32_land(j,"aff",ac)) * + p32_bii_coeff("aff",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"aff_ndc",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc32_land(j,"ndc",ac)) * + p32_bii_coeff("ndc",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"plant",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc32_land(j,"plant",ac)) * + p32_bii_coeff("plant",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); diff --git a/modules/32_forestry/dynamic_may24/presolve.gms b/modules/32_forestry/dynamic_may24/presolve.gms new file mode 100644 index 0000000000..d38a5e430d --- /dev/null +++ b/modules/32_forestry/dynamic_may24/presolve.gms @@ -0,0 +1,231 @@ +*** | (C) 2008-2025 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 + +*Reduction of ac_est is not possible. +v32_hvarea_forestry.fx(j,ac_est) = 0; +v32_land_reduction.fx(j,type32,ac_est) = 0; + +** START ndc ** +* calc NPI/NDC afforestation per time step based on forest stock change + p32_aff_pol_timestep("y1995",j) = 0; + p32_aff_pol_timestep(t,j)$(ord(t)>1) = p32_aff_pol(t,j) - p32_aff_pol(t-1,j); +* Suitable area (`p32_aff_pot`) for NPI/NDC afforestation + p32_aff_pot(t,j) = 0.95 * (sum((kcr,w),vm_area.l(j,kcr,w) - vm_area.lo(j,kcr,w)) + + (vm_fallow.l(j) - vm_fallow.lo(j)) + + (vm_land.l(j,"past") - vm_land.lo(j,"past")) + - pm_land_conservation(t,j,"other","restore")); +*** NDC/NPI re/afforesation is further constrained by the remaining forest establishment potential + p32_aff_pot(t,j)$(p32_aff_pot(t,j) > pm_max_forest_est(t,j) * s32_annual_aff_limit * m_timestep_length) = + pm_max_forest_est(t,j) * s32_annual_aff_limit * m_timestep_length; +* suitable area `p32_aff_pot` can be negative, if land restoration is switched on (level smaller than lower bound), therefore set negative values to 0 + p32_aff_pot(t,j)$(p32_aff_pot(t,j) < 1e-6) = 0; +* Limit prescribed NPI/NDC afforestation in `p32_aff_pol_timestep` if not enough suitable area (`p32_aff_pot`) for afforestation is available + p32_aff_pol_timestep(t,j)$(p32_aff_pol_timestep(t,j) > p32_aff_pot(t,j)) = p32_aff_pot(t,j); + + +* Calculate the limit for endogenous afforestation +* The global (`s32_max_aff_area`) and regional limit (`f32_max_aff_area`) for total afforestation (sum of endogenous and exogenous) is reduced by exogenous NPI/NDC afforestation through (`p32_aff_pol_timestep(t,j)`). +if(s32_max_aff_area_glo = 1, + p32_max_aff_area_glo(t) = s32_max_aff_area + - sum((ac,j), pc32_land(j,"ndc",ac)) + - (smax(t2, sum(j, p32_aff_pol(t2,j))) - sum(j, p32_aff_pol(t-1,j))); + p32_max_aff_area_glo(t)$(p32_max_aff_area_glo(t) < 1e-06) = 0; + p32_max_aff_area_reg(t,i) = 0; +elseif s32_max_aff_area_glo = 0, + p32_max_aff_area_reg(t,i) = f32_max_aff_area(i) + - sum((ac,cell(i,j)), pc32_land(j,"ndc",ac)) + - (smax(t2, sum(cell(i,j), p32_aff_pol(t2,j))) - sum(cell(i,j), p32_aff_pol(t-1,j))); + p32_max_aff_area_reg(t,i)$(p32_max_aff_area_reg(t,i) < 1e-06) = 0; + p32_max_aff_area_glo(t) = 0; +); + +* make sure that the historic period is identical in all cases +if(m_year(t) <= sm_fix_SSP2, + p32_max_aff_area_reg(t,i) = 0; + p32_max_aff_area_glo(t) = 0; +); + +** END ndc ** + +*' @code +*' Afforestation switch: +*' 0 = Use natveg growth curve towards LPJmL natural vegetation +*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation +if(s32_aff_plantation = 0, + p32_carbon_density_ac(t,j,"aff",ac,ag_pools) = pm_carbon_density_secdforest_ac(t,j,ac,ag_pools); +elseif s32_aff_plantation = 1, + p32_carbon_density_ac(t,j,"aff",ac,ag_pools) = pm_carbon_density_plantation_ac(t,j,ac,ag_pools); +); + +*' Timber plantations carbon densities: +p32_carbon_density_ac(t,j,"plant",ac,ag_pools) = pm_carbon_density_plantation_ac(t,j,ac,ag_pools); + +*' NDC carbon densities are natveg carbon densities. +p32_carbon_density_ac(t,j,"ndc",ac,ag_pools) = pm_carbon_density_secdforest_ac(t,j,ac,ag_pools); + +*' CDR from afforestation for each age-class, depending on planning horizon. +p32_cdr_ac(t,j,ac)$(ord(ac) > 1 AND (ord(ac)-1) <= s32_planning_horizon/5) += p32_carbon_density_ac(t,j,"aff",ac,"vegc") - p32_carbon_density_ac(t,j,"aff",ac-1,"vegc"); + +* Disturbance from generic sources to managed and natural forests +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_est2); + +pc32_land(j,"aff",ac_sub) = pc32_land(j,"aff",ac_sub) - p32_disturbance_loss_ftype32(t,j,"aff",ac_sub); + +*' Regrowth of natural vegetation (natural succession) is modelled by shifting +*' age-classes according to time step length. For first year of simulation, the +*' shift is just 1. Division by 5 happends because the age-classes exist in 5 year steps +s32_shift = m_yeardiff_forestry(t)/5; +*' @stop + +*' Shifting of age-classes +*` @code +* Example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s32_shift = 1) +p32_land(t,j,type32,ac)$(ord(ac) > s32_shift) = pc32_land(j,type32,ac-s32_shift); +* Account for cases at the end of the age class set (s32_shift > 1) which are not shifted by the above calculation +p32_land(t,j,type32,"acx") = p32_land(t,j,type32,"acx") + sum(ac$(ord(ac) > card(ac)-s32_shift), pc32_land(j,type32,ac)); + +* set ac_est to zero +p32_land(t,j,type32,ac_est) = 0; +*' @stop + +** Calculate v32_land.l +v32_land.l(j,type32,ac) = p32_land(t,j,type32,ac); +pc32_land(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; +v32_land.up(j,type32,ac) = Inf; + +if(s32_hvarea = 0, +*** zero. Fixed timber plantations. No harvest. No establisment. + v32_hvarea_forestry.fx(j,ac_sub) = 0; + v32_land.fx(j,"plant",ac) = pc32_land(j,"plant",ac); + s32_establishment_static = 1; + s32_establishment_dynamic = 0; +elseif s32_hvarea = 1, +*** exogenous. All timber plantations are harvested at rotation age and are re-established such that the total plantation area remains constant. + v32_land.fx(j,"plant",ac)$(ac.off < p32_rotation_cellular_harvesting(t,j)) = pc32_land(j,"plant",ac); + v32_land.fx(j,"plant",ac)$(ac.off >= p32_rotation_cellular_harvesting(t,j)) = 0; + s32_establishment_static = 1; + s32_establishment_dynamic = 0; + +** Timber plantations can be harvested at rotation age (the economically +** optimal point in time harvesting usually natural forests would be preferred over harvest +** from timber plantations, mainly because the growing stock at rotation age (e.g. 50 years) +** in timber plantations is smaller compared to the growing stock of old-growth primary and +** secondary forest (> 100 years). + +elseif s32_hvarea = 2, +*** endogenous. All plantations are harvested at rotation age. Plantation establishment is endogenous. +** 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, all plantations can be harvested. + v32_land.lo(j,"plant",ac)$(ac.off >= p32_rotation_cellular_harvesting(t,j)) = 0; + s32_establishment_static = 0; + s32_establishment_dynamic = 1; +); +** 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; + + +** fix ndc afforestation forever, all age-classes are fixed except ac_est +v32_land.fx(j,"ndc",ac_sub) = pc32_land(j,"ndc",ac_sub); +v32_land.lo(j,"ndc",ac_est) = 0; +v32_land.up(j,"ndc",ac_est) = Inf; + +* release all bounds in case of NPI / NDC reversal and set recurring costs to zero +if (m_year(t) >= s32_npi_ndc_reversal, + v32_land.lo(j,"ndc",ac) = 0; + v32_land.up(j,"ndc",ac) = Inf; + i32_recurring_cost("ndc") = 0; +); + +** fix c price induced afforestation based on s32_planning_horizon, fixed only until end of s32_planning_horizon, ac_est is free +if(s32_aff_prot = 0, + v32_land.fx(j,"aff",ac)$(ac.off <= s32_planning_horizon/5) = pc32_land(j,"aff",ac); + v32_land.up(j,"aff",ac)$(ac.off > s32_planning_horizon/5) = pc32_land(j,"aff",ac); +elseif s32_aff_prot = 1, + v32_land.fx(j,"aff",ac) = pc32_land(j,"aff",ac); +); +v32_land.lo(j,"aff",ac_est) = 0; +v32_land.up(j,"aff",ac_est) = Inf; +v32_land.l(j,"aff",ac_est) = 0; + +** Certain areas (e.g. the boreal zone) are excluded from endogenous afforestation. +** DON'T USE TYPE32 SET HERE +if(m_year(t) <= sm_fix_SSP2, + v32_land.fx(j,"aff",ac_est) = 0; +else + v32_land.lo(j,"aff",ac_est) = 0; + v32_land.up(j,"aff",ac_est) = f32_aff_mask(j) * sum(land, pcm_land(j,land)); +); + +*' No afforestation is allowed if carbon density <= 20 tc/ha +v32_land.fx(j,"aff",ac_est)$(fm_carbon_density(t,j,"forestry","vegc") <= 20) = 0; + +m_boundfix(v32_land,(j,type32,ac_sub),up,1e-6); + +** Calculate future yield based on rotation length +p32_yield_forestry_future(t,j) = sum(ac$(ac.off = p32_rotation_cellular_estb(t,j)), pm_timber_yield(t,j,ac,"forestry")); + +* Fader for plantation share in establishment decision +if(ord(t) = 1, + pc32_prod_forestry_ini(i) = sum(cell(i,j), sum(ac$(ac.off = p32_rotation_cellular_harvesting(t,j)), pm_timber_yield(t,j,ac,"forestry") * p32_land(t,j,"plant",ac))) / m_timestep_length_forestry; + pc32_plant_contr_ini(i)$(sum(kforestry, pm_demand_forestry(t,i,kforestry)) > 0) = pc32_prod_forestry_ini(i) / sum(kforestry, pm_demand_forestry(t,i,kforestry)); + pc32_plant_contr_ini(i)$(sum(kforestry, pm_demand_forestry(t,i,kforestry)) = 0) = 0; + p32_plant_contr(t,i) = pc32_plant_contr_ini(i); +else + p32_plant_contr(t,i) = p32_plant_contr(t-1,i) * (1+i32_plant_contr_growth_fader(t))**m_timestep_length_forestry; +); +p32_plant_contr(t,i)$(p32_plant_contr(t,i) > s32_plant_contr_max) = s32_plant_contr_max; + +** demand for establishment decision depends on s32_demand_establishment: +** s32_demand_establishment = 0 static (establishment based on current demand) +** s32_demand_establishment = 1 forward looking (establishment based on future demand according to rotation length) +if(s32_demand_establishment = 1, + if(m_year(t) <= sm_fix_SSP2, + p32_demand_forestry_future(t,i,kforestry) = sum(t2$(m_year(t2) = sm_fix_SSP2), pm_demand_forestry(t2,i,kforestry)); + else + p32_demand_forestry_future(t,i,kforestry) = sum(t_ext$(t_ext.pos = t.pos + p32_rotation_regional(t,i)),pm_demand_forestry(t_ext,i,kforestry)); + ); +else + p32_demand_forestry_future(t,i,kforestry) = pm_demand_forestry(t,i,kforestry); + ); + +p32_forestry_product_dist(t,i,kforestry)$(p32_demand_forestry_future(t,i,kforestry) > 0) = p32_demand_forestry_future(t,i,kforestry) / sum(kforestry2, p32_demand_forestry_future(t,i,kforestry2)); +p32_forestry_product_dist(t,i,kforestry)$(p32_demand_forestry_future(t,i,kforestry) = 0) = 1/card(kforestry); + +p32_future_to_current_demand_ratio(t,i)$(sum(kforestry, pm_demand_forestry(t,i,kforestry)) > 0) = sum(kforestry, p32_demand_forestry_future(t,i,kforestry)) / sum(kforestry, pm_demand_forestry(t,i,kforestry)); +p32_future_to_current_demand_ratio(t,i)$(sum(kforestry, pm_demand_forestry(t,i,kforestry)) = 0) = 0; + +* Avoid conflict between afforestation for carbon uptake on land and secdforest restoration +pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") > sum(ac, p32_land(t,j,"ndc",ac) + v32_land.lo(j,"plant",ac) + p32_land(t,j,"aff",ac))+ p32_aff_pol_timestep(t,j)) + = pm_land_conservation(t,j,"secdforest","restore") - (sum(ac, p32_land(t,j,"ndc",ac) + p32_land(t,j,"aff",ac) + v32_land.lo(j,"plant",ac)) + p32_aff_pol_timestep(t,j)); +pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") <= sum(ac, p32_land(t,j,"ndc",ac) + p32_land(t,j,"aff",ac) + v32_land.lo(j,"plant",ac)) + p32_aff_pol_timestep(t,j)) = 0; + +* Update biodiversity value +vm_bv.l(j,"aff_co2p",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc32_land(j,"aff",ac)) * + p32_bii_coeff("aff",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"aff_ndc",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc32_land(j,"ndc",ac)) * + p32_bii_coeff("ndc",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"plant",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc32_land(j,"plant",ac)) * + p32_bii_coeff("plant",bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); + +*** EOF presolve.gms *** diff --git a/modules/32_forestry/dynamic_may24/realization.gms b/modules/32_forestry/dynamic_may24/realization.gms new file mode 100644 index 0000000000..d11137a71d --- /dev/null +++ b/modules/32_forestry/dynamic_may24/realization.gms @@ -0,0 +1,45 @@ +*** | (C) 2008-2025 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 The main features of the this realization are re/afforestation for CDR +*' and timber production. Re/afforestation can be modelled exogenously (prescribed +*' by NPI/NDC policies) and/or endogenously (incentivized by a reward for CDR). +*' National policies implemented (NPI) and nationally determined contributions to +*' the Paris agreement (NDC) for re/afforestation are based on country reports. The +*' interface `vm_cdr_aff` includes the expected CDR and local bph effects from +*' re/afforestation depending on the planning horizon `s32_planning_horizon`. The +*' reward for CDR and local bph effects from re/afforestation is calculated in the +*' [56_ghg_policy] module. In this realization, re/afforestation is modeled by default +*' as regrowth of natural vegetation (see @humpenoder_investigating_2014 for details on the implemenation). +*' The regrowth of natural vegetation follows S-shaped growth curves, which are +*' parametrized based on @braakhekke_modelling_2019. Additionally this module +*' handles the production of two timber products i.e., wood and woodfuel from +*' plantation forests while still accounting for afforestation policies. New plantations +*' are also established in the simulation step to account for future timber demand. +*' This module also calculates the rotation lengths before the solve loop by +*' maximizing current annual increment (CAI) based on @amacher2009economics. This rotation +*' length calculation decision can also be changed to maximization of mean annual increment (MAI) +*' or equating instantaneous growth rate (IGR) with interest rate. Rotation lengths +*' calculated by maximization of CAI are empirically closer to economically optimal Faustmann +*' rotation lengths (see @amacher2009economics). +*' For harvesting decisions we assume that land owners stick to their establishment decision, +*' e.g. if a plantation has been established with a rotation length of 30 years +*' it will be harvested after 30 years, even so the rotation length in the prevailing +*' time step, used for establishment, is shorter or longer. See @mishra_forestry_2021 for more details. + +*' @limitations Rotation lengths for timber plantations are not endogenous. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/32_forestry/dynamic_may24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/32_forestry/dynamic_may24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/32_forestry/dynamic_may24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/32_forestry/dynamic_may24/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/32_forestry/dynamic_may24/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/32_forestry/dynamic_may24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/32_forestry/dynamic_may24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/32_forestry/dynamic_may24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/32_forestry/dynamic_may24/scaling.gms b/modules/32_forestry/dynamic_may24/scaling.gms new file mode 100644 index 0000000000..2d6abb5104 --- /dev/null +++ b/modules/32_forestry/dynamic_may24/scaling.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +v32_cost_establishment.scale(i) = 10e4; +v32_cost_recur.scale(i) = 10e4; +vm_cost_fore.scale(i) = 10e5; +v32_cost_hvarea.scale(i)$(s32_hvarea = 1 OR s32_hvarea = 2) = 10e4; diff --git a/modules/32_forestry/dynamic_may24/sets.gms b/modules/32_forestry/dynamic_may24/sets.gms new file mode 100644 index 0000000000..b0a2a2a7e0 --- /dev/null +++ b/modules/32_forestry/dynamic_may24/sets.gms @@ -0,0 +1,50 @@ +*** | (C) 2008-2025 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 +***FORESTRY COST TYPES*** + + fcostsALL forestry factor cost types + / recur, mon, harv / + + fcosts32(fcostsALL) forestry factor cost per annum + / recur, mon / + + type32 plantation type + / aff, ndc, plant / + + pol32 afforestation policy type + / none, npi, ndc / + + ini32(j,ac) subset for initialization of timber plantations + + rotation_type Rotation type + / min, low, def, high, bio / + + bgp32 biogeophysical effect (degree C) of afforestation on local surface temperature +/ nobgp, ann_bph / + +tcre32 transient surface temperature response to CO2 emission (degree C per tC) +/ ann_TCREmean, ann_TCREhigh, ann_TCRElow / + +aff_effect biochemical and local biophysical effect of afforestation on climate +/ bgc, bph / + +ac_bph(ac) fade-in of bph effect over age-classes + +inter32 Interpolation of scenario from FAO study on proportion of roundwood production coming from plantations +/abare, brown/ + +scen32 Scenario for development of roundwood production share from plantations +/ constant,h5s5l5,h5s2l2,h5s2l1,h5s1l1,h5s1l05,h2s1l05 / + + shock_scen32 Scenario name of forest carbon shock + / none, 002lin2030,004lin2030,008lin2030,016lin2030 + / + +; + +*** EOF sets.gms *** diff --git a/modules/32_forestry/input/files b/modules/32_forestry/input/files index 47cb3ec86b..b4ae3f22af 100644 --- a/modules/32_forestry/input/files +++ b/modules/32_forestry/input/files @@ -2,5 +2,8 @@ aff_unrestricted.cs2 aff_noboreal.cs2 aff_onlytropical.cs2 -f32_fac_req_ha.csv npi_ndc_aff_pol.cs3 +f32_bph_effect_noTCRE.cs3 +f32_localTCRE.cs3 +f32_plantedforest.cs4 +f32_forest_shock.csv diff --git a/modules/32_forestry/module.gms b/modules/32_forestry/module.gms index 6b34dfd9ee..6ade5bdb81 100644 --- a/modules/32_forestry/module.gms +++ b/modules/32_forestry/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,15 +7,20 @@ *' @title Forestry *' -*' @description The forestry module describes the constraints under which managed -*' forest (age-class forest) exists. At the same time it calculates the corresponding -*' carbon stocks. The module provides carbon dioxide removal (CDR) from afforestation -*' to the GHG policy module ([56_ghg_policy]) as well as afforestation related costs -*' to the costs module ([11_costs]). +*' @description The forestry module describes the constraints under which three different +*' types of managed age-class forests exist: plantations used for wood harvesting (plant), +*' prescribed re/afforestation based on existing national policies (ndc) and endogenous +*' CO2-price driven re/afforestation (aff) (@humpenoeder_overcoming_2022). +*' These types of managed forests are made +*' available to other modules via the interface `vm_land_forestry`. At the same time, +*' the module calculates the corresponding carbon stocks and biodiversity values for all +*' three types of managed forest. The module provides expected carbon dioxide removal (CDR) +*' from endogenous re/afforestation to the GHG policy module ([56_ghg_policy]). +*' Costs related to managed forests, including costs for harvesting, establishment and +*' management, are provided to the cost module ([11_costs]). *' -*' @authors Florian Humpenöder +*' @authors Florian Humpenöder, Abhijeet Mishra *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%forestry%" == "affore_vegc_dec16" $include "./modules/32_forestry/affore_vegc_dec16/realization.gms" -$Ifi "%forestry%" == "static_sep16" $include "./modules/32_forestry/static_sep16/realization.gms" +$Ifi "%forestry%" == "dynamic_may24" $include "./modules/32_forestry/dynamic_may24/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/32_forestry/static_sep16/declarations.gms b/modules/32_forestry/static_sep16/declarations.gms deleted file mode 100644 index 05cd8389f8..0000000000 --- a/modules/32_forestry/static_sep16/declarations.gms +++ /dev/null @@ -1,26 +0,0 @@ -*** | (C) 2008-2019 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 - -positive variables - vm_cost_fore(i) Afforestation costs (mio. USD04MER per yr) - vm_landdiff_forestry Aggregated difference in forestry land compared to previous timestep (mio. ha) - v32_land(j,land32) Forestry land pools (mio. ha) - vm_cdr_aff(j) Total CDR from afforestation (new and existing areas) between t+1 and t=s32_planing_horizon (mio. tC) -; - -parameters - pc32_carbon_density(j,c_pools) Carbon density in optimization (tC per ha) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_fore(t,i,type) Afforestation costs (mio. USD04MER per yr) - ov_landdiff_forestry(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) - ov32_land(t,j,land32,type) Forestry land pools (mio. ha) - ov_cdr_aff(t,j,type) Total CDR from afforestation (new and existing areas) between t+1 and t=s32_planing_horizon (mio. tC) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/32_forestry/static_sep16/not_used.txt b/modules/32_forestry/static_sep16/not_used.txt deleted file mode 100644 index 92ce6161a2..0000000000 --- a/modules/32_forestry/static_sep16/not_used.txt +++ /dev/null @@ -1,9 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason -pm_carbon_density_ac, input,not used -pm_land_start, input, not used diff --git a/modules/32_forestry/static_sep16/postsolve.gms b/modules/32_forestry/static_sep16/postsolve.gms deleted file mode 100644 index eb622f1040..0000000000 --- a/modules/32_forestry/static_sep16/postsolve.gms +++ /dev/null @@ -1,25 +0,0 @@ -*** | (C) 2008-2019 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 - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_fore(t,i,"marginal") = vm_cost_fore.m(i); - ov_landdiff_forestry(t,"marginal") = vm_landdiff_forestry.m; - ov32_land(t,j,land32,"marginal") = v32_land.m(j,land32); - ov_cdr_aff(t,j,"marginal") = vm_cdr_aff.m(j); - ov_cost_fore(t,i,"level") = vm_cost_fore.l(i); - ov_landdiff_forestry(t,"level") = vm_landdiff_forestry.l; - ov32_land(t,j,land32,"level") = v32_land.l(j,land32); - ov_cdr_aff(t,j,"level") = vm_cdr_aff.l(j); - ov_cost_fore(t,i,"upper") = vm_cost_fore.up(i); - ov_landdiff_forestry(t,"upper") = vm_landdiff_forestry.up; - ov32_land(t,j,land32,"upper") = v32_land.up(j,land32); - ov_cdr_aff(t,j,"upper") = vm_cdr_aff.up(j); - ov_cost_fore(t,i,"lower") = vm_cost_fore.lo(i); - ov_landdiff_forestry(t,"lower") = vm_landdiff_forestry.lo; - ov32_land(t,j,land32,"lower") = v32_land.lo(j,land32); - ov_cdr_aff(t,j,"lower") = vm_cdr_aff.lo(j); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/32_forestry/static_sep16/preloop.gms b/modules/32_forestry/static_sep16/preloop.gms deleted file mode 100644 index f042dda687..0000000000 --- a/modules/32_forestry/static_sep16/preloop.gms +++ /dev/null @@ -1,27 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @code -*' Costs and CDR from afforestation are set to zero. -vm_cost_fore.fx(i) = 0; -vm_cdr_aff.fx(j) = 0; - -*' All forestry land pools (`land32`) except for "old" are set to zero, -*' whereas "old" refers to the forestry plantations at the level of 1995. -v32_land.fx(j,"new") = 0; -v32_land.fx(j,"prot") = 0; -v32_land.fx(j,"grow") = 0; -v32_land.fx(j,"old") = pcm_land(j,"forestry"); -*' @stop - -* Aggregation of forestry land pools (`land32`). -vm_land.fx(j,"forestry") = sum(land32, v32_land.l(j,land32)); - -* The change of forestry land is also set to zero. -vm_landdiff_forestry.fx = 0; - -*** EOF preloop.gms *** diff --git a/modules/32_forestry/static_sep16/presolve.gms b/modules/32_forestry/static_sep16/presolve.gms deleted file mode 100644 index 08c97f6b0d..0000000000 --- a/modules/32_forestry/static_sep16/presolve.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @code -*' Forestry carbon stocks are calculated by multiplying plantations in 1995 -*' with the forestry carbon density of the current time step (`pc32_carbon_density`). -pc32_carbon_density(j,c_pools) = fm_carbon_density(t,j,"forestry",c_pools); -vm_carbon_stock.fx(j,"forestry",c_pools) = vm_land.l(j,"forestry")*pc32_carbon_density(j,c_pools); - -*' Wood demand is also set to zero because forestry is not modeled in this realization. -vm_supply.fx(i2,kforestry) = 0; -*' @stop - -*** EOF presolve.gms *** diff --git a/modules/32_forestry/static_sep16/realization.gms b/modules/32_forestry/static_sep16/realization.gms deleted file mode 100644 index a8f3cd177f..0000000000 --- a/modules/32_forestry/static_sep16/realization.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2019 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 The static realisation is very simple and does not include any equation -*' because forestry land is assumed constant at the observed 1995 level throughout time. - -*' @limitations Forestry activities such as establishment or -*' harvest of plantations for wood production are not modeled. -*' Also afforestation for CDR is not included. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/32_forestry/static_sep16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/32_forestry/static_sep16/declarations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/32_forestry/static_sep16/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/32_forestry/static_sep16/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/32_forestry/static_sep16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/32_forestry/static_sep16/sets.gms b/modules/32_forestry/static_sep16/sets.gms deleted file mode 100644 index 1dde3fa6fb..0000000000 --- a/modules/32_forestry/static_sep16/sets.gms +++ /dev/null @@ -1,15 +0,0 @@ -*** | (C) 2008-2019 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 - land32 Forestry land pools - / new, prot, grow, old/ - - kforestry(kall) Forestry products - / wood, woodfuel / -; -*** EOF sets.gms *** diff --git a/modules/34_urban/exo_nov21/declarations.gms b/modules/34_urban/exo_nov21/declarations.gms new file mode 100644 index 0000000000..b281685739 --- /dev/null +++ b/modules/34_urban/exo_nov21/declarations.gms @@ -0,0 +1,37 @@ +*** | (C) 2008-2025 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 + i34_urban_area(t_all, j) Cellular urban area +; + +positive variables + vm_cost_urban(j) Technical adjustment costs + v34_cost1(j) Technical adjustment costs + v34_cost2(j) Technical adjustment costs +; + +equations + q34_urban_cell(j) Constraint for urban land + q34_urban_land(i) Prescribe total regional urban land + q34_urban_cost1(j) Technical punishment equation + q34_urban_cost2(j) Technical punishment equation + q34_bv_urban(j,potnatveg) Biodiversity value for urban land (Mha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_urban(t,j,type) Technical adjustment costs + ov34_cost1(t,j,type) Technical adjustment costs + ov34_cost2(t,j,type) Technical adjustment costs + oq34_urban_cell(t,j,type) Constraint for urban land + oq34_urban_land(t,i,type) Prescribe total regional urban land + oq34_urban_cost1(t,j,type) Technical punishment equation + oq34_urban_cost2(t,j,type) Technical punishment equation + oq34_bv_urban(t,j,potnatveg,type) Biodiversity value for urban land (Mha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/34_urban/exo_nov21/equations.gms b/modules/34_urban/exo_nov21/equations.gms new file mode 100644 index 0000000000..f45c423be3 --- /dev/null +++ b/modules/34_urban/exo_nov21/equations.gms @@ -0,0 +1,35 @@ +*** | (C) 2008-2025 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 +*' Cellular level land is prescribed via a very strong incentive not to deviate +*' from cellular input data. v34_cost1 and v34_cost2 are the cost variables that +*' implement this, for when vm_land(j2,"urban") is less than and greater than the input data +*' i.e. when reducing or establishing more urban land than in input. This safeguards against infeasible outcomes, +*' where urban land should expand but can not due to NPI or other protected land constraints. In this case it incurs the cost and shifts the land elsewhere in the region. + + + +q34_urban_cost1(j2) .. + v34_cost1(j2) =g= sum(ct, i34_urban_area(ct, j2)) - vm_land(j2,"urban"); + +q34_urban_cost2(j2) .. + v34_cost2(j2) =g= vm_land(j2,"urban") - sum(ct, i34_urban_area(ct, j2)); + +*' Sum up cost terms with high punishment + +q34_urban_cell(j2) .. + vm_cost_urban(j2) =e= (v34_cost1(j2) + v34_cost2(j2)) * s34_urban_deviation_cost; + +*' Regional level urban land must match + +q34_urban_land(i2) .. + sum(cell(i2,j2), vm_land(j2,"urban")) =e= sum((ct,cell(i2,j2)), i34_urban_area(ct,j2)); + +*' Biodiversity value (BV) + q34_bv_urban(j2,potnatveg) .. + vm_bv(j2,"urban", potnatveg) =e= vm_land(j2,"urban") * fm_bii_coeff("urban",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/34_urban/exo_nov21/input.gms b/modules/34_urban/exo_nov21/input.gms new file mode 100644 index 0000000000..b2667d9953 --- /dev/null +++ b/modules/34_urban/exo_nov21/input.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + +$setglobal c34_urban_scenario SSP2 +* options: SSP: "SSP1", "SSP2", "SSP3", "SSP4", "SSP5" + + +scalars + s34_urban_deviation_cost Artificial cost for urban deviation variables (USD17MER per ha) / 1e+06 / +; + +table f34_urbanland(t_all, j, urban_scen34) Urban land +$ondelim +$include "./modules/34_urban/exo_nov21/input/f34_urbanland.cs3" +$offdelim +; diff --git a/modules/34_urban/exo_nov21/input/files b/modules/34_urban/exo_nov21/input/files new file mode 100644 index 0000000000..62c8780165 --- /dev/null +++ b/modules/34_urban/exo_nov21/input/files @@ -0,0 +1,2 @@ +* list of files that are required here +f34_urbanland.cs3 diff --git a/modules/34_urban/exo_nov21/postsolve.gms b/modules/34_urban/exo_nov21/postsolve.gms new file mode 100644 index 0000000000..cf6bdee866 --- /dev/null +++ b/modules/34_urban/exo_nov21/postsolve.gms @@ -0,0 +1,42 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_urban(t,j,"marginal") = vm_cost_urban.m(j); + ov34_cost1(t,j,"marginal") = v34_cost1.m(j); + ov34_cost2(t,j,"marginal") = v34_cost2.m(j); + oq34_urban_cell(t,j,"marginal") = q34_urban_cell.m(j); + oq34_urban_land(t,i,"marginal") = q34_urban_land.m(i); + oq34_urban_cost1(t,j,"marginal") = q34_urban_cost1.m(j); + oq34_urban_cost2(t,j,"marginal") = q34_urban_cost2.m(j); + oq34_bv_urban(t,j,potnatveg,"marginal") = q34_bv_urban.m(j,potnatveg); + ov_cost_urban(t,j,"level") = vm_cost_urban.l(j); + ov34_cost1(t,j,"level") = v34_cost1.l(j); + ov34_cost2(t,j,"level") = v34_cost2.l(j); + oq34_urban_cell(t,j,"level") = q34_urban_cell.l(j); + oq34_urban_land(t,i,"level") = q34_urban_land.l(i); + oq34_urban_cost1(t,j,"level") = q34_urban_cost1.l(j); + oq34_urban_cost2(t,j,"level") = q34_urban_cost2.l(j); + oq34_bv_urban(t,j,potnatveg,"level") = q34_bv_urban.l(j,potnatveg); + ov_cost_urban(t,j,"upper") = vm_cost_urban.up(j); + ov34_cost1(t,j,"upper") = v34_cost1.up(j); + ov34_cost2(t,j,"upper") = v34_cost2.up(j); + oq34_urban_cell(t,j,"upper") = q34_urban_cell.up(j); + oq34_urban_land(t,i,"upper") = q34_urban_land.up(i); + oq34_urban_cost1(t,j,"upper") = q34_urban_cost1.up(j); + oq34_urban_cost2(t,j,"upper") = q34_urban_cost2.up(j); + oq34_bv_urban(t,j,potnatveg,"upper") = q34_bv_urban.up(j,potnatveg); + ov_cost_urban(t,j,"lower") = vm_cost_urban.lo(j); + ov34_cost1(t,j,"lower") = v34_cost1.lo(j); + ov34_cost2(t,j,"lower") = v34_cost2.lo(j); + oq34_urban_cell(t,j,"lower") = q34_urban_cell.lo(j); + oq34_urban_land(t,i,"lower") = q34_urban_land.lo(i); + oq34_urban_cost1(t,j,"lower") = q34_urban_cost1.lo(j); + oq34_urban_cost2(t,j,"lower") = q34_urban_cost2.lo(j); + oq34_bv_urban(t,j,potnatveg,"lower") = q34_bv_urban.lo(j,potnatveg); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/34_urban/exo_nov21/preloop.gms b/modules/34_urban/exo_nov21/preloop.gms new file mode 100644 index 0000000000..033c368cae --- /dev/null +++ b/modules/34_urban/exo_nov21/preloop.gms @@ -0,0 +1,21 @@ +*** | (C) 2008-2025 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 + +* get the scenario GDP & Populaiton data for iso countries +loop(t_all, + if(m_year(t_all) <= sm_fix_SSP2, + i34_urban_area(t_all, j) = f34_urbanland(t_all, j,"SSP2"); +else +i34_urban_area(t_all, j) = f34_urbanland(t_all, j,"%c34_urban_scenario%"); + ); +); + +pcm_land(j,"urban") = i34_urban_area("y1995",j); + +* Initialize biodiversity value +vm_bv.l(j2,"urban", potnatveg) = + pcm_land(j2,"urban") * fm_bii_coeff("urban",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/34_urban/exo_nov21/presolve.gms b/modules/34_urban/exo_nov21/presolve.gms new file mode 100644 index 0000000000..90c2613470 --- /dev/null +++ b/modules/34_urban/exo_nov21/presolve.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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_carbon_stock.fx(j,"urban",ag_pools,stockType) = 0; + +if(ord(t) = 1, + vm_land.fx(j,"urban") = i34_urban_area(t,j); +else + vm_land.lo(j,"urban") = 0; + vm_land.l(j,"urban") = i34_urban_area(t,j); + vm_land.up(j,"urban") = Inf; +); diff --git a/modules/34_urban/exo_nov21/realization.gms b/modules/34_urban/exo_nov21/realization.gms new file mode 100644 index 0000000000..05c5243fc9 --- /dev/null +++ b/modules/34_urban/exo_nov21/realization.gms @@ -0,0 +1,24 @@ +*** | (C) 2008-2025 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 Urban Land based on LUH3 (LUH2v2: Hurtt 2020, LUH3: publication not yet available) cellular (0.5 degree) input dataset, varying with SSP. +*' Cellular level is prescribed via a very high punishment term for deviating from original input values. +*' Regional sums of urban land must add be equal for both model and input data. + +*' @limitations Urban land is exogenous and does not interact with other model dynamics, except for reducing available non-urban land pool. +*' Cellular urban land may not exactly match input data due to other land needs in the same cell. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/34_urban/exo_nov21/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/34_urban/exo_nov21/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/34_urban/exo_nov21/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/34_urban/exo_nov21/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/34_urban/exo_nov21/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/34_urban/exo_nov21/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/34_urban/exo_nov21/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/34_urban/exo_nov21/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/34_urban/exo_nov21/scaling.gms b/modules/34_urban/exo_nov21/scaling.gms new file mode 100644 index 0000000000..130368cc3c --- /dev/null +++ b/modules/34_urban/exo_nov21/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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_cost_urban.scale(j) = 10e3; +*v34_cost1.scale(j) = 10e-4; +*v34_cost2.scale(j) = 10e-4; diff --git a/modules/34_urban/exo_nov21/sets.gms b/modules/34_urban/exo_nov21/sets.gms new file mode 100644 index 0000000000..009ee78c14 --- /dev/null +++ b/modules/34_urban/exo_nov21/sets.gms @@ -0,0 +1,12 @@ +*** | (C) 2008-2025 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 + + urban_scen34 Urban scenario + / SSP1, SSP2, SSP3, SSP4, SSP5 / + +; diff --git a/modules/34_urban/module.gms b/modules/34_urban/module.gms index a4c032ceb8..8246b25544 100644 --- a/modules/34_urban/module.gms +++ b/modules/34_urban/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,12 +7,13 @@ *' @title Urban Land *' -*' @description The urban land module is one of the land modules in MAgPIE -*' (see also the other land modules: [30_crop], [31_past], [32_forestry], [35_natveg]). -*' It describes urban settlement areas and estimates their corresponding carbon content. +*' @description The urban land module is one of the land modules in MAgPIE +*' (see also the other land modules: [30_crop], [31_past], [32_forestry], [35_natveg]). +*' It describes urban settlement areas and estimates their corresponding carbon content and biodiversity values. *' -*' @authors Jan Philipp Dietrich, Florian Humpenöder +*' @authors Jan Philipp Dietrich, Florian Humpenöder, David Meng-Chuen Chen, Benjamin Leon Bodirsky *###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%urban%" == "exo_nov21" $include "./modules/34_urban/exo_nov21/realization.gms" $Ifi "%urban%" == "static" $include "./modules/34_urban/static/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/34_urban/static/declarations.gms b/modules/34_urban/static/declarations.gms new file mode 100644 index 0000000000..48a82e7fd3 --- /dev/null +++ b/modules/34_urban/static/declarations.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2025 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 + + +positive variables + vm_cost_urban(j) Technical adjustment cost +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_urban(t,j,type) Technical adjustment cost +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/34_urban/static/not_used.txt b/modules/34_urban/static/not_used.txt new file mode 100644 index 0000000000..34cfdad4f1 --- /dev/null +++ b/modules/34_urban/static/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2, input, not needed diff --git a/modules/34_urban/static/postsolve.gms b/modules/34_urban/static/postsolve.gms new file mode 100644 index 0000000000..5d83667255 --- /dev/null +++ b/modules/34_urban/static/postsolve.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_urban(t,j,"marginal") = vm_cost_urban.m(j); + ov_cost_urban(t,j,"level") = vm_cost_urban.l(j); + ov_cost_urban(t,j,"upper") = vm_cost_urban.up(j); + ov_cost_urban(t,j,"lower") = vm_cost_urban.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/34_urban/static/presolve.gms b/modules/34_urban/static/presolve.gms index 84ae991160..daa842cd7a 100644 --- a/modules/34_urban/static/presolve.gms +++ b/modules/34_urban/static/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,4 +7,8 @@ vm_land.fx(j,"urban") = pcm_land(j,"urban"); -vm_carbon_stock.fx(j,"urban",c_pools) = 0; +vm_carbon_stock.fx(j,"urban",ag_pools,stockType) = 0; +* Biodiveristy value (BV) +vm_bv.fx(j,"urban", potnatveg) = pcm_land(j,"urban") * fm_bii_coeff("urban",potnatveg) * fm_luh2_side_layers(j,potnatveg); + +vm_cost_urban.fx(j) = 0; diff --git a/modules/34_urban/static/realization.gms b/modules/34_urban/static/realization.gms index 3b25cc7f54..e8e7295dfd 100644 --- a/modules/34_urban/static/realization.gms +++ b/modules/34_urban/static/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,12 +7,14 @@ *' @description In the static realization, urban land remains static over time *' with the spatial distribution of 1995 from the LUH2 data -*' set [@hurtt_harmonization_inprep]. Carbon stocks are fixed to zero because +*' set [@hurtt2018luh2]. Carbon stocks are fixed to zero because *' information on urban land carbon density is missing. *' @limitations Urban land is static over time and *' corresponding carbon stocks are assumed zero *####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/34_urban/static/declarations.gms" $Ifi "%phase%" == "presolve" $include "./modules/34_urban/static/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/34_urban/static/postsolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/35_natveg/dynamic_may18/declarations.gms b/modules/35_natveg/dynamic_may18/declarations.gms deleted file mode 100644 index 337f756a29..0000000000 --- a/modules/35_natveg/dynamic_may18/declarations.gms +++ /dev/null @@ -1,77 +0,0 @@ -*** | (C) 2008-2019 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 - s35_shift number of 5-year age-classes corresponding to current time step length (1) -; - -parameters - p35_carbon_density_secdforest(t,j,land35,c_pools) Carbon density secdforest (tC per ha) - p35_carbon_density_other(t,j,land35,c_pools) Carbon density other land (tC per ha) - i35_secdforest(j,ac) Inital secdforest (mio. ha) - i35_other(j,ac) Inital other land (mio. ha) - p35_secdforest(t,j,ac,when) Secdforest per age class before and after optimization (mio. ha) - p35_other(t,j,ac,when) Other land per age class before and after optimization (mio. ha) - pc35_secdforest(j,land35) Secdforest per aggregated age class (mio. ha) - pc35_other(j,land35) Other land per aggregated age class (mio. ha) - p35_protect_shr(t,j,prot_type) Protection share for primforest secdforest and other land (1) - p35_save_primforest(t,j) Primforest protection (mio. ha) - p35_save_secdforest(t,j) Secdforest protection (mio. ha) - p35_save_other(t,j) Other land protection (mio. ha) - p35_recovered_forest(t,j,ac) Recovered forest (mio. ha) - p35_min_forest(t,j) Minimum forest stock [land protection policies] (Mha) - p35_min_other(t,j) Minimum other land stock [land protection policies] (Mha) -; - -equations - q35_land_secdforest(j) Secdforest land pool calculation (mio. ha) - q35_land_other(j) Other land pool calculation (mio. ha) - q35_carbon_primforest(j,c_pools) Primforest carbon stock calculation (mio tC) - q35_carbon_secdforest(j,c_pools) Secdforest carbon stock calculation (mio tC) - q35_carbon_other(j,c_pools) Other land carbon stock calculation (mio tC) - q35_landdiff Difference in natveg land (mio. ha) - q35_other_expansion(j,land35) Other land expansion (mio. ha) - q35_other_reduction(j,land35) Other land reduction (mio. ha) - q35_secdforest_reduction(j,land35) Secdforest reduction (mio. ha) - q35_primforest_reduction(j) Primforest reduction (mio. ha) - q35_min_forest(j) Minimum forest land constraint (mio. ha) - q35_min_other(j) Minimum other land constraint (mio. ha) -; - -positive variables - v35_secdforest(j,land35) Detailed stock of secdforest (mio. ha) - v35_other(j,land35) 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,land35) Other land expansion compared to previous timestep (mio. ha) - v35_other_reduction(j,land35) Other land reduction compared to previous timestep (mio. ha) - v35_secdforest_reduction(j,land35) Secdforest reduction compared to previous timestep (mio. ha) - v35_primforest_reduction(j) Primforest reduction compared to previous timestep (mio. ha) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov35_secdforest(t,j,land35,type) Detailed stock of secdforest (mio. ha) - ov35_other(t,j,land35,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,land35,type) Other land expansion compared to previous timestep (mio. ha) - ov35_other_reduction(t,j,land35,type) Other land reduction compared to previous timestep (mio. ha) - ov35_secdforest_reduction(t,j,land35,type) Secdforest reduction compared to previous timestep (mio. ha) - ov35_primforest_reduction(t,j,type) Primforest reduction compared to previous timestep (mio. ha) - oq35_land_secdforest(t,j,type) Secdforest land pool calculation (mio. ha) - oq35_land_other(t,j,type) Other land pool calculation (mio. ha) - oq35_carbon_primforest(t,j,c_pools,type) Primforest carbon stock calculation (mio tC) - oq35_carbon_secdforest(t,j,c_pools,type) Secdforest carbon stock calculation (mio tC) - oq35_carbon_other(t,j,c_pools,type) Other land carbon stock calculation (mio tC) - oq35_landdiff(t,type) Difference in natveg land (mio. ha) - oq35_other_expansion(t,j,land35,type) Other land expansion (mio. ha) - oq35_other_reduction(t,j,land35,type) Other land reduction (mio. ha) - oq35_secdforest_reduction(t,j,land35,type) Secdforest reduction (mio. ha) - oq35_primforest_reduction(t,j,type) Primforest reduction (mio. ha) - oq35_min_forest(t,j,type) Minimum forest land constraint (mio. ha) - oq35_min_other(t,j,type) Minimum other land constraint (mio. ha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/35_natveg/dynamic_may18/equations.gms b/modules/35_natveg/dynamic_may18/equations.gms deleted file mode 100644 index 94c2426ba9..0000000000 --- a/modules/35_natveg/dynamic_may18/equations.gms +++ /dev/null @@ -1,68 +0,0 @@ -*** | (C) 2008-2019 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 -*' The interface `vm_land` provides aggregated natveg land pools (`land35`) to other modules. - - q35_land_secdforest(j2) .. vm_land(j2,"secdforest") =e= sum(land35, v35_secdforest(j2,land35)); - - q35_land_other(j2) .. vm_land(j2,"other") =e= sum(land35, v35_other(j2,land35)); - -*' Carbon stocks for primary forest, secondary forest or other natural land are calculated -*' as the product of respective area and carbon density. -*' Carbon stocks decline if the area decreases -*' (e.g. due to cropland expansion into forests). -*' In case of abandoned agricultural land (increase of other natural land), -*' natural succession, represented by age-class growth, results in increasing carbon stocks. - - q35_carbon_primforest(j2,c_pools) .. vm_carbon_stock(j2,"primforest",c_pools) =e= - vm_land(j2,"primforest") - *sum(ct, fm_carbon_density(ct,j2,"primforest",c_pools)); - - q35_carbon_secdforest(j2,c_pools) .. vm_carbon_stock(j2,"secdforest",c_pools) =e= - sum(land35, v35_secdforest(j2,land35) - *sum(ct, p35_carbon_density_secdforest(ct,j2,land35,c_pools))); - - q35_carbon_other(j2,c_pools) .. vm_carbon_stock(j2,"other",c_pools) =e= - sum(land35, v35_other(j2,land35) - *sum(ct, p35_carbon_density_other(ct,j2,land35,c_pools))); - - -*' NPI/NDC land protection policies are implemented as minium forest land and other land stock. - - q35_min_forest(j2) .. vm_land(j2,"primforest") + vm_land(j2,"secdforest") =g= - sum(ct, p35_min_forest(ct,j2)); - - q35_min_other(j2) .. vm_land(j2,"other") =g= sum(ct, p35_min_other(ct,j2)); - -*' The following technical calculations are needed for reducing differences in land-use patterns between time steps. -*' The gross change in natural vegetation is calculated based on land expansion and -*' land contraction of other land, and land reduction of primary and secondary forest. -*' This information is then passed to the land module ([10_land]): - - q35_landdiff .. vm_landdiff_natveg =e= - sum((j2,land35), - v35_other_expansion(j2,land35) - + v35_other_reduction(j2,land35) - + v35_secdforest_reduction(j2,land35) - + v35_primforest_reduction(j2)); - - q35_other_expansion(j2,land35) .. - v35_other_expansion(j2,land35) =g= - v35_other(j2,land35) - pc35_other(j2,land35); - - q35_other_reduction(j2,land35) .. - v35_other_reduction(j2,land35) =g= - pc35_other(j2,land35) - v35_other(j2,land35); - - q35_secdforest_reduction(j2,land35) .. - v35_secdforest_reduction(j2,land35) =g= - pc35_secdforest(j2,land35) - v35_secdforest(j2,land35); - - q35_primforest_reduction(j2) .. - v35_primforest_reduction(j2) =g= - pcm_land(j2,"primforest") - vm_land(j2,"primforest"); diff --git a/modules/35_natveg/dynamic_may18/input.gms b/modules/35_natveg/dynamic_may18/input.gms deleted file mode 100644 index 0ae44642c8..0000000000 --- a/modules/35_natveg/dynamic_may18/input.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - -$setglobal c35_protect_scenario WDPA -$setglobal c35_ad_policy npi -$setglobal c35_aolc_policy npi - -table f35_protect_area(j,prot_type) Conservation priority areas (mio. ha) -$ondelim -$include "./modules/35_natveg/input/protect_area.cs3" -$offdelim -; - -table f35_min_land_stock(t_all,j,pol35,pol_stock35) Land protection policies [minimum land stock] (Mha) -$ondelim -$include "./modules/35_natveg/input/npi_ndc_ad_aolc_pol.cs3" -$offdelim -; diff --git a/modules/35_natveg/dynamic_may18/not_used.txt b/modules/35_natveg/dynamic_may18/not_used.txt deleted file mode 100644 index d78901bb63..0000000000 --- a/modules/35_natveg/dynamic_may18/not_used.txt +++ /dev/null @@ -1,7 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason diff --git a/modules/35_natveg/dynamic_may18/postsolve.gms b/modules/35_natveg/dynamic_may18/postsolve.gms deleted file mode 100644 index 254d06dcfc..0000000000 --- a/modules/35_natveg/dynamic_may18/postsolve.gms +++ /dev/null @@ -1,105 +0,0 @@ -*** | (C) 2008-2019 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 - -if((ord(t) = 1), -* Reshuffling of agricultural land in the 1st timestep results in an artificial increase of v35_other(j,"new"). -* This would result in carbon uptake (negative emissions) due to regrowth of vegetation. -* To avoid this artificial effect on CO2 emissions we reset age-classes after the optimization of the 1st time step. - v35_other.l(j,land35) = 0; - v35_other.l(j,"old") = vm_land.l(j,"other"); - p35_other(t,j,ac,"after") = 0; - p35_other(t,j,"acx","after") = vm_land.l(j,"other"); -else -*other land age class calculation - p35_other(t,j,ac,"after") = - v35_other.l(j,"new")$(ord(ac) = 1) - + sum(ac_land35(ac,land35)$(not sameas(land35,"new") AND pc35_other(j,land35) > 0),(v35_other.l(j,land35)/pc35_other(j,land35))*p35_other(t,j,ac,"before"))$(ord(ac) > 1); -); - -*secdforest age class calculation -p35_secdforest(t,j,ac,"after") = - v35_secdforest.l(j,"new")$(ord(ac) = 1) - + sum(ac_land35(ac,land35)$(not sameas(land35,"new") AND pc35_secdforest(j,land35) > 0),(v35_secdforest.l(j,land35)/pc35_secdforest(j,land35))*p35_secdforest(t,j,ac,"before"))$(ord(ac) > 1); - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov35_secdforest(t,j,land35,"marginal") = v35_secdforest.m(j,land35); - ov35_other(t,j,land35,"marginal") = v35_other.m(j,land35); - ov_landdiff_natveg(t,"marginal") = vm_landdiff_natveg.m; - ov35_other_expansion(t,j,land35,"marginal") = v35_other_expansion.m(j,land35); - ov35_other_reduction(t,j,land35,"marginal") = v35_other_reduction.m(j,land35); - ov35_secdforest_reduction(t,j,land35,"marginal") = v35_secdforest_reduction.m(j,land35); - ov35_primforest_reduction(t,j,"marginal") = v35_primforest_reduction.m(j); - oq35_land_secdforest(t,j,"marginal") = q35_land_secdforest.m(j); - oq35_land_other(t,j,"marginal") = q35_land_other.m(j); - oq35_carbon_primforest(t,j,c_pools,"marginal") = q35_carbon_primforest.m(j,c_pools); - oq35_carbon_secdforest(t,j,c_pools,"marginal") = q35_carbon_secdforest.m(j,c_pools); - oq35_carbon_other(t,j,c_pools,"marginal") = q35_carbon_other.m(j,c_pools); - oq35_landdiff(t,"marginal") = q35_landdiff.m; - oq35_other_expansion(t,j,land35,"marginal") = q35_other_expansion.m(j,land35); - oq35_other_reduction(t,j,land35,"marginal") = q35_other_reduction.m(j,land35); - oq35_secdforest_reduction(t,j,land35,"marginal") = q35_secdforest_reduction.m(j,land35); - oq35_primforest_reduction(t,j,"marginal") = q35_primforest_reduction.m(j); - oq35_min_forest(t,j,"marginal") = q35_min_forest.m(j); - oq35_min_other(t,j,"marginal") = q35_min_other.m(j); - ov35_secdforest(t,j,land35,"level") = v35_secdforest.l(j,land35); - ov35_other(t,j,land35,"level") = v35_other.l(j,land35); - ov_landdiff_natveg(t,"level") = vm_landdiff_natveg.l; - ov35_other_expansion(t,j,land35,"level") = v35_other_expansion.l(j,land35); - ov35_other_reduction(t,j,land35,"level") = v35_other_reduction.l(j,land35); - ov35_secdforest_reduction(t,j,land35,"level") = v35_secdforest_reduction.l(j,land35); - ov35_primforest_reduction(t,j,"level") = v35_primforest_reduction.l(j); - oq35_land_secdforest(t,j,"level") = q35_land_secdforest.l(j); - oq35_land_other(t,j,"level") = q35_land_other.l(j); - oq35_carbon_primforest(t,j,c_pools,"level") = q35_carbon_primforest.l(j,c_pools); - oq35_carbon_secdforest(t,j,c_pools,"level") = q35_carbon_secdforest.l(j,c_pools); - oq35_carbon_other(t,j,c_pools,"level") = q35_carbon_other.l(j,c_pools); - oq35_landdiff(t,"level") = q35_landdiff.l; - oq35_other_expansion(t,j,land35,"level") = q35_other_expansion.l(j,land35); - oq35_other_reduction(t,j,land35,"level") = q35_other_reduction.l(j,land35); - oq35_secdforest_reduction(t,j,land35,"level") = q35_secdforest_reduction.l(j,land35); - oq35_primforest_reduction(t,j,"level") = q35_primforest_reduction.l(j); - oq35_min_forest(t,j,"level") = q35_min_forest.l(j); - oq35_min_other(t,j,"level") = q35_min_other.l(j); - ov35_secdforest(t,j,land35,"upper") = v35_secdforest.up(j,land35); - ov35_other(t,j,land35,"upper") = v35_other.up(j,land35); - ov_landdiff_natveg(t,"upper") = vm_landdiff_natveg.up; - ov35_other_expansion(t,j,land35,"upper") = v35_other_expansion.up(j,land35); - ov35_other_reduction(t,j,land35,"upper") = v35_other_reduction.up(j,land35); - ov35_secdforest_reduction(t,j,land35,"upper") = v35_secdforest_reduction.up(j,land35); - ov35_primforest_reduction(t,j,"upper") = v35_primforest_reduction.up(j); - oq35_land_secdforest(t,j,"upper") = q35_land_secdforest.up(j); - oq35_land_other(t,j,"upper") = q35_land_other.up(j); - oq35_carbon_primforest(t,j,c_pools,"upper") = q35_carbon_primforest.up(j,c_pools); - oq35_carbon_secdforest(t,j,c_pools,"upper") = q35_carbon_secdforest.up(j,c_pools); - oq35_carbon_other(t,j,c_pools,"upper") = q35_carbon_other.up(j,c_pools); - oq35_landdiff(t,"upper") = q35_landdiff.up; - oq35_other_expansion(t,j,land35,"upper") = q35_other_expansion.up(j,land35); - oq35_other_reduction(t,j,land35,"upper") = q35_other_reduction.up(j,land35); - oq35_secdforest_reduction(t,j,land35,"upper") = q35_secdforest_reduction.up(j,land35); - oq35_primforest_reduction(t,j,"upper") = q35_primforest_reduction.up(j); - oq35_min_forest(t,j,"upper") = q35_min_forest.up(j); - oq35_min_other(t,j,"upper") = q35_min_other.up(j); - ov35_secdforest(t,j,land35,"lower") = v35_secdforest.lo(j,land35); - ov35_other(t,j,land35,"lower") = v35_other.lo(j,land35); - ov_landdiff_natveg(t,"lower") = vm_landdiff_natveg.lo; - ov35_other_expansion(t,j,land35,"lower") = v35_other_expansion.lo(j,land35); - ov35_other_reduction(t,j,land35,"lower") = v35_other_reduction.lo(j,land35); - ov35_secdforest_reduction(t,j,land35,"lower") = v35_secdforest_reduction.lo(j,land35); - ov35_primforest_reduction(t,j,"lower") = v35_primforest_reduction.lo(j); - oq35_land_secdforest(t,j,"lower") = q35_land_secdforest.lo(j); - oq35_land_other(t,j,"lower") = q35_land_other.lo(j); - oq35_carbon_primforest(t,j,c_pools,"lower") = q35_carbon_primforest.lo(j,c_pools); - oq35_carbon_secdforest(t,j,c_pools,"lower") = q35_carbon_secdforest.lo(j,c_pools); - oq35_carbon_other(t,j,c_pools,"lower") = q35_carbon_other.lo(j,c_pools); - oq35_landdiff(t,"lower") = q35_landdiff.lo; - oq35_other_expansion(t,j,land35,"lower") = q35_other_expansion.lo(j,land35); - oq35_other_reduction(t,j,land35,"lower") = q35_other_reduction.lo(j,land35); - oq35_secdforest_reduction(t,j,land35,"lower") = q35_secdforest_reduction.lo(j,land35); - oq35_primforest_reduction(t,j,"lower") = q35_primforest_reduction.lo(j); - oq35_min_forest(t,j,"lower") = q35_min_forest.lo(j); - oq35_min_other(t,j,"lower") = q35_min_other.lo(j); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/35_natveg/dynamic_may18/preloop.gms b/modules/35_natveg/dynamic_may18/preloop.gms deleted file mode 100644 index 402cb00515..0000000000 --- a/modules/35_natveg/dynamic_may18/preloop.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2019 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 mapping between ac and land35 -ac_land35(ac,land35) = no; -ac_land35(ac,"new") = yes$(ord(ac) = 1); -ac_land35(ac,"grow") = yes$(ord(ac) > 1 AND ord(ac) < card(ac)); -ac_land35(ac,"old") = yes$(ord(ac) = card(ac)); - -i35_secdforest(j,ac) = 0; -i35_secdforest(j,"acx") = pcm_land(j,"secdforest"); - -i35_other(j,ac) = 0; -i35_other(j,"acx") = pcm_land(j,"other"); - -p35_protect_shr(t,j,prot_type) = 0; - -p35_recovered_forest(t,j,ac) = 0; - -p35_min_forest(t,j) = f35_min_land_stock(t,j,"%c35_ad_policy%","forest"); -p35_min_other(t,j) = f35_min_land_stock(t,j,"%c35_ad_policy%","other"); - -*initialize parameter -p35_other(t,j,ac,when) = 0; -p35_secdforest(t,j,ac,when) = 0; diff --git a/modules/35_natveg/dynamic_may18/presolve.gms b/modules/35_natveg/dynamic_may18/presolve.gms deleted file mode 100644 index 785cce3c5e..0000000000 --- a/modules/35_natveg/dynamic_may18/presolve.gms +++ /dev/null @@ -1,137 +0,0 @@ -*** | (C) 2008-2019 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 - -* Regrowth of natural vegetation (natural succession) is modelled by shifting age-classes according to time step length. -s35_shift = m_yeardiff(t)/5; -if((ord(t) = 1), - p35_secdforest(t,j,ac,"before") = i35_secdforest(j,ac); - p35_other(t,j,ac,"before") = i35_other(j,ac); -else -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s35_shift = 1) - p35_other(t,j,ac,"before")$(ord(ac) > s35_shift) = p35_other(t-1,j,ac-s35_shift,"after"); -* account for cases at the end of the age class set (s35_shift > 1) which are not shifted by the above calculation - p35_other(t,j,"acx","before") = p35_other(t,j,"acx","before") - + sum(ac$(ord(ac) > card(ac)-s35_shift), p35_other(t-1,j,ac,"after")); - -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s35_shift = 1) - p35_secdforest(t,j,ac,"before")$(ord(ac) > s35_shift) = p35_secdforest(t-1,j,ac-s35_shift,"after"); -* account for cases at the end of the age class set (s35_shift > 1) which are not shifted by the above calculation - p35_secdforest(t,j,"acx","before") = p35_secdforest(t,j,"acx","before") - + sum(ac$(ord(ac) > card(ac)-s35_shift), p35_secdforest(t-1,j,ac,"after")); -); - -*' @code -*' If the vegetation carbon density in a simulation unit due to regrowth -*' exceeds a threshold of 20 tC/ha the respective area is shifted from other natural land to secondary forest. -p35_recovered_forest(t,j,ac)$(not sameas(ac,"acx")) = - p35_other(t,j,ac,"before")$(pm_carbon_density_ac(t,j,ac,"vegc") > 20); -p35_other(t,j,ac,"before") = p35_other(t,j,ac,"before") - p35_recovered_forest(t,j,ac); -p35_secdforest(t,j,ac,"before") = - p35_secdforest(t,j,ac,"before") + p35_recovered_forest(t,j,ac); -*' @stop - -* Age-classes exist only between the optimization time steps. -* For the optimization, we aggregate age-classes to 3 group defined in `land35`. -pc35_secdforest(j,land35) = sum(ac_land35(ac,land35), p35_secdforest(t,j,ac,"before")); -v35_secdforest.l(j,land35) = pc35_secdforest(j,land35); -vm_land.l(j,"secdforest") = sum(land35, pc35_secdforest(j,land35)); -pcm_land(j,"secdforest") = sum(land35, pc35_secdforest(j,land35)); - -pc35_other(j,land35) = sum(ac_land35(ac,land35), p35_other(t,j,ac,"before")); -v35_other.l(j,land35) = pc35_other(j,land35); -vm_land.l(j,"other") = sum(land35, pc35_other(j,land35)); -pcm_land(j,"other") = sum(land35, pc35_other(j,land35)); - -*** Forest protection (WDPA areas and different conservation priority areas) -* calc protection share for primforest, secdforest and other land -p35_protect_shr(t,j,prot_type)$(sum(land_natveg, pm_land_start(j,land_natveg)) > 0) = f35_protect_area(j,prot_type)/sum(land_natveg, pm_land_start(j,land_natveg)); -p35_protect_shr(t,j,prot_type)$(p35_protect_shr(t,j,prot_type) > 1) = 1; -p35_protect_shr(t,j,prot_type)$(p35_protect_shr(t,j,prot_type) < 0) = 0; - -* protection scenarios -$ifthen "%c35_protect_scenario%" == "none" - p35_save_primforest(t,j) = 0; - p35_save_secdforest(t,j) = 0; - p35_save_other(t,j) = 0; -$elseif "%c35_protect_scenario%" == "full" - p35_save_primforest(t,j) = vm_land.l(j,"primforest"); - p35_save_secdforest(t,j) = pc35_secdforest(j,"old"); - p35_save_other(t,j) = pc35_other(j,"old"); -$elseif "%c35_protect_scenario%" == "forest" - p35_save_primforest(t,j) = vm_land.l(j,"primforest"); - p35_save_secdforest(t,j) = pc35_secdforest(j,"old"); - p35_save_other(t,j) = 0; -$elseif "%c35_protect_scenario%" == "WDPA" - p35_save_primforest(t,j) = p35_protect_shr(t,j,"WDPA")*pm_land_start(j,"primforest"); - p35_save_secdforest(t,j) = p35_protect_shr(t,j,"WDPA")*pm_land_start(j,"secdforest"); - p35_save_other(t,j) = p35_protect_shr(t,j,"WDPA")*pm_land_start(j,"other"); -$else -* conservation priority scenarios start in 2020, in addition to WDPA protection - if ((sameas(t,"y1995") or sameas(t,"y2000") or sameas(t,"y2005") or sameas(t,"y2010") or sameas(t,"y2015")), - p35_save_primforest(t,j) = p35_protect_shr(t,j,"WDPA")*pm_land_start(j,"primforest"); - p35_save_secdforest(t,j) = p35_protect_shr(t,j,"WDPA")*pm_land_start(j,"secdforest"); - p35_save_other(t,j) = p35_protect_shr(t,j,"WDPA")*pm_land_start(j,"other"); - else - p35_save_primforest(t,j) = (p35_protect_shr(t,j,"WDPA")+p35_protect_shr(t,j,"%c35_protect_scenario%"))*pm_land_start(j,"primforest"); - p35_save_secdforest(t,j) = (p35_protect_shr(t,j,"WDPA")+p35_protect_shr(t,j,"%c35_protect_scenario%"))*pm_land_start(j,"secdforest"); - p35_save_other(t,j) = (p35_protect_shr(t,j,"WDPA")+p35_protect_shr(t,j,"%c35_protect_scenario%"))*pm_land_start(j,"other"); - p35_save_primforest(t,j)$(p35_save_primforest(t,j) > vm_land.l(j,"primforest")) = vm_land.l(j,"primforest"); - p35_save_secdforest(t,j)$(p35_save_secdforest(t,j) > pc35_secdforest(j,"old")) = pc35_secdforest(j,"old"); - p35_save_other(t,j)$(p35_save_other(t,j) > pc35_other(j,"old")) = pc35_other(j,"old"); - ); -$endif - -* Within the optimization, primary and secondary forests can only decrease -* (e.g. for cropland expansion). -* In contrast, other natural land can decrease and increase within the optimization. -* For instance, other natural land increases if agricultural land is abandoned. -vm_land.lo(j,"primforest") = p35_save_primforest(t,j); -vm_land.up(j,"primforest") = vm_land.l(j,"primforest"); -m_boundfix(vm_land,(j,"primforest"),l,10e-5); - -v35_secdforest.fx(j,"new") = 0; -v35_secdforest.lo(j,"grow") = 0; -v35_secdforest.up(j,"grow") = pc35_secdforest(j,"grow"); -m_boundfix(v35_secdforest,(j,"grow"),l,10e-5); -v35_secdforest.lo(j,"old") = p35_save_secdforest(t,j); -v35_secdforest.up(j,"old") = pc35_secdforest(j,"old"); -m_boundfix(v35_secdforest,(j,"old"),l,10e-5); - -v35_other.lo(j,"new") = 0; -v35_other.up(j,"new") = Inf; -v35_other.lo(j,"grow") = 0; -v35_other.up(j,"grow") = pc35_other(j,"grow"); -m_boundfix(v35_other,(j,"grow"),l,10e-5); -v35_other.lo(j,"old") = p35_save_other(t,j); -v35_other.up(j,"old") = pc35_other(j,"old"); -m_boundfix(v35_other,(j,"old"),l,10e-5); - -* calculate carbon density -* highest carbon density 1st time step to account for reshuffling -if((ord(t) = 1), - p35_carbon_density_secdforest(t,j,land35,c_pools) = pm_carbon_density_ac(t,j,"acx",c_pools); - p35_carbon_density_other(t,j,land35,c_pools) = pm_carbon_density_ac(t,j,"acx",c_pools); -else - p35_carbon_density_secdforest(t,j,"new",c_pools) = pm_carbon_density_ac(t,j,"ac0",c_pools); - p35_carbon_density_secdforest(t,j,"grow",c_pools) = m_weightedmean(pm_carbon_density_ac(t,j,ac,c_pools),p35_secdforest(t,j,ac,"before"),(ac_land35(ac,"grow"))); - p35_carbon_density_secdforest(t,j,"old",c_pools) = pm_carbon_density_ac(t,j,"acx",c_pools); - p35_carbon_density_other(t,j,"new",c_pools) = pm_carbon_density_ac(t,j,"ac0",c_pools); - p35_carbon_density_other(t,j,"grow",c_pools) = m_weightedmean(pm_carbon_density_ac(t,j,ac,c_pools),p35_other(t,j,ac,"before"),(ac_land35(ac,"grow"))); - p35_carbon_density_other(t,j,"old",c_pools) = pm_carbon_density_ac(t,j,"acx",c_pools); -); - -* update pcm_carbon_stock. Needed for shifting from other land to secdforest (p35_recovered_forest). -pcm_carbon_stock(j,"secdforest",c_pools) = - sum(land35, pc35_secdforest(j,land35) - * p35_carbon_density_secdforest(t,j,land35,c_pools)); - -pcm_carbon_stock(j,"other",c_pools) = - sum(land35, pc35_other(j,land35) - * p35_carbon_density_other(t,j,land35,c_pools)); - -p35_min_forest(t,j)$(p35_min_forest(t,j) > vm_land.l(j,"primforest") + vm_land.l(j,"secdforest")) = vm_land.l(j,"primforest") + vm_land.l(j,"secdforest"); -p35_min_other(t,j)$(p35_min_other(t,j) > vm_land.l(j,"other")) = vm_land.l(j,"other"); diff --git a/modules/35_natveg/dynamic_may18/realization.gms b/modules/35_natveg/dynamic_may18/realization.gms deleted file mode 100644 index 69a792fa1c..0000000000 --- a/modules/35_natveg/dynamic_may18/realization.gms +++ /dev/null @@ -1,40 +0,0 @@ -*** | (C) 2008-2019 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 the dynamic_may18 realization, land and carbon stock dynamics of -*' natural vegetation are modeled endogenously. -*' The initial spatial distribution of the sub-land-types primary forest, -*' secondary forest and other natural land is based on the -*' LUH2 data set [@hurtt_harmonization_inprep]. -*' The realization includes 2 different kinds of land protection. a) Land protection based on -*' the World Database on Protected Areas (WDPA) maintained by the International -*' Union for Conservation of Nature (IUCN) and b) land protection based on national -*' policies implemented (NPI) and nationally determined contributions to the Paris agreement (NDC) -*' taken from individual country reports. -*' Land protection based on WDPA is static over time, -*' while the NPI/NDC polices ramp up until 2030 and are assumed constant thereafter. -*' For WDPA the level of land protection is based on IUCN catI+II, which reflect areas currently -*' under protection (e.g. strict nature reserves and national parks), -*' and distributed equally across all sub-land-types (primary forest, secondary forest and other natural land). -*' On top of the IUCN catI+II land protection, there are options to protect different conservation priority areas -*' such as biodiversity hotspots (BH), centers of plant diversity (CBD), frontier forests (FF) and last of the wild (LW). -*' NPI/NDC land protection polices are be applied on forest and other land, depending on individual country reports. -*' @stop - - -*' -*' @limitations Wood harvest in natural forests is not accounted for. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/35_natveg/dynamic_may18/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/35_natveg/dynamic_may18/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/35_natveg/dynamic_may18/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/35_natveg/dynamic_may18/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/35_natveg/dynamic_may18/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/35_natveg/dynamic_may18/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/35_natveg/dynamic_may18/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/35_natveg/dynamic_may18/sets.gms b/modules/35_natveg/dynamic_may18/sets.gms deleted file mode 100644 index f2fcc98543..0000000000 --- a/modules/35_natveg/dynamic_may18/sets.gms +++ /dev/null @@ -1,23 +0,0 @@ -*** | (C) 2008-2019 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 - land35 Natveg land pools - / new, grow, old / - - pol35 Land protection policy - / none, npi, ndc/ - - ac_land35(ac,land35) Mapping between age class and natveg land type - - prot_type Conservation priority areas - / BH, CPD, FF, LW, WDPA / - - pol_stock35 Land types for land protection policies - /forest, other/ - -; diff --git a/modules/35_natveg/input/files b/modules/35_natveg/input/files index c338e96678..dc39074a1e 100644 --- a/modules/35_natveg/input/files +++ b/modules/35_natveg/input/files @@ -1,3 +1,7 @@ * list of files that are required here -protect_area.cs3 npi_ndc_ad_aolc_pol.cs3 +f35_forest_disturbance_share.cs4 +f35_forest_lost_share.cs3 +f35_forest_shock.csv +pot_forest_area.cs2 +pot_forest_area_0.5.mz diff --git a/modules/35_natveg/module.gms b/modules/35_natveg/module.gms index efd7c06789..8d69d259df 100644 --- a/modules/35_natveg/module.gms +++ b/modules/35_natveg/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,15 +7,15 @@ *' @title Natural Vegetation *' -*' @description The natural vegetation (natveg) land module is one of the land modules in MAgPIE -*' (see also the other land modules: [30_crop], [31_past], [32_forestry], [34_urban]). -*' It calculates land and carbon stocks of natural vegetation, which consists of -*' primary forest, secondary forest and other natural land. -*' The module determines the availability of natural vegetation for land conversion. +*' @description The natural vegetation (natveg) land module is one of the land modules in MAgPIE +*' (see also the other land modules: [30_crop], [31_past], [32_forestry], [34_urban]). +*' It calculates land and carbon stocks, as well as the biodiversity value, of natural vegetation, +*' which consists of primary forest, secondary forest and other natural land. +*' The module considers land conservation and determines the availability of natural vegetation +*' for land conversion. *' -*' @authors Florian Humpenöder +*' @authors Florian Humpenöder, Abhijeet Mishra, Patrick v. Jeetze *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%natveg%" == "dynamic_may18" $include "./modules/35_natveg/dynamic_may18/realization.gms" -$Ifi "%natveg%" == "static" $include "./modules/35_natveg/static/realization.gms" +$Ifi "%natveg%" == "pot_forest_may24" $include "./modules/35_natveg/pot_forest_may24/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/35_natveg/pot_forest_may24/declarations.gms b/modules/35_natveg/pot_forest_may24/declarations.gms new file mode 100644 index 0000000000..7cb01dfd7e --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/declarations.gms @@ -0,0 +1,140 @@ +*** | (C) 2008-2025 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 + s35_shift number of 5-year age-classes corresponding to current time step length (1) +; + +parameters + i35_secdforest(j,ac) Initial secdforest (mio. ha) + i35_land_other(j,othertype35,ac) Initial other land (mio. ha) + p35_secdforest(t,j,ac) Secdforest per age class (mio. ha) + p35_land_other(t,j,othertype35,ac) Other land per age class (mio. ha) + pc35_secdforest(j,ac) Secdforest per age class in current time step (mio. ha) + pc35_land_other(j,othertype35,ac) Other land per age class in current time step (mio. ha) + p35_min_forest(t,j) Minimum forest and other stock based on NPI or NDC targets (mio. ha) + p35_min_other(t,j) Minimum forest and other stock based on NPI or NDC targets (mio. ha) + p35_damage_fader(t_all) Fader for forest damage (1) + pc35_forest_recovery_shr(j) Forest share in natveg recovery (1) + p35_forest_recovery_area(t,j,ac) Recovered forest (mio. ha) + p35_maturesecdf(t,j,ac) Matured secondary forest (mio. ha) + pm_max_forest_est(t,j) Overall forest establishment potential in current time step (mio. ha) + pc35_max_forest_recovery(j) Maximum forest recovery potential after land abandonement (mio. ha) + p35_carbon_density_other(t,j,othertype35,ac,ag_pools) Carbon density other land (tC per ha) + p35_disturbance_loss_secdf(t,j,ac) Loss due to disturbances in secondary forest (mio. ha) + p35_disturbance_loss_primf(t,j) Loss due to disturbances in primary forest (mio. ha) + p35_secdf_ageclass(j,ac) Secondadry forest area in 5-year age-classes (mio. ha) + p35_secdf_ageclass_dist(j,ac) Share of age-classes in secondary forest (1) + p35_land_start_ac(j,ac,land_natveg) Initial Natural vegetation area (mio. ha) + 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) + p35_restoration_shift(j) Restoration of other land instead of secdforest (mio. ha) +; + +equations + q35_land_secdforest(j) Secdforest land pool calculation (mio. ha) + q35_land_other(j) Other land pool calculation (mio. ha) + q35_carbon_primforest(j,ag_pools,stockType) Primforest carbon stock calculation (mio tC) + q35_carbon_secdforest(j,ag_pools,stockType) Secdforest carbon stock calculation (mio tC) + q35_carbon_other(j,ag_pools,stockType) Other land carbon stock calculation (mio tC) + q35_min_forest(j) Minimum forest land constraint (mio. ha) + q35_min_other(j) Minimum other land constraint (mio. ha) + q35_natforest_reduction(j) Natural forest reduction (mio. ha) + q35_landdiff Difference in natveg land (mio. ha) + q35_other_expansion(j,othertype35) Other land expansion (mio. ha) + q35_other_reduction(j,othertype35,ac) Other land reduction (mio. ha) + q35_secdforest_expansion(j) Secdforest expansion (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 regeneration (mio. ha) + q35_max_forest_establishment(j) Maximum forestry regeneration based on potential forest area (mio. ha) + q35_other_regeneration(j) Other land regeneration (mio. ha) + q35_other_est(j,ac) Distribution of other land additions over ac_est (mio. ha) + q35_secdforest_est(j,ac) Distribution of secdforest additions over ac_est (mio. ha) + q35_hvarea_other(j,othertype35,ac) Harvested area other land (mio. ha) + q35_hvarea_secdforest(j,ac) Harvested area secdforest (mio. ha) + q35_hvarea_primforest(j) Harvested area primforest (mio. ha) + q35_prod_secdforest(j) Production of woody biomass from secondary forests (mio. tDM per yr) + q35_prod_primforest(j) Production of woody biomass from primary forests (mio. tDM per yr) + q35_prod_other(j) Production of woody biomass from other land (mio. tDM per yr) + q35_cost_hvarea(i) Cost of harvesting natural vegetation (mio. USD17MER) + q35_bv_primforest(j,potnatveg) Biodiversity value of primary forest (mio. ha) + q35_bv_secdforest(j,potnatveg) Biodiversity value of secondary forest (mio. ha) + q35_bv_other(j,potnatveg) Biodiversity value of other land (mio. ha) + q35_natveg_conservation(j) Total natural vegetation conservation constraint (mio. ha) + q35_secdforest_restoration(j) Secondary forest restoration constraint (mio. ha) + q35_other_restoration(j) Other land restoration constraint (mio. ha) +; + +positive variables + v35_secdforest(j,ac) Detailed stock of secdforest (mio. ha) + vm_land_other(j,othertype35,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,othertype35) Other land expansion compared to previous timestep (mio. ha) + v35_other_reduction(j,othertype35,ac) Other land 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) + v35_hvarea_other(j,othertype35,ac) Harvested area from other land (mio. ha) + v35_hvarea_primforest(j) Harvested area from primary forest (mio. ha) + vm_prod_natveg(j,land_natveg,kforestry) Production of woody biomass from natural vegetation (mio. tDM per yr) + vm_cost_hvarea_natveg(i) Cost of harvesting natural vegetation (mio. USD17MER) + vm_natforest_reduction(j) Natural forest reduction (mio. ha) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov35_secdforest(t,j,ac,type) Detailed stock of secdforest (mio. ha) + ov_land_other(t,j,othertype35,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,othertype35,type) Other land expansion compared to previous timestep (mio. ha) + ov35_other_reduction(t,j,othertype35,ac,type) Other land 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) + ov35_hvarea_other(t,j,othertype35,ac,type) Harvested area from other land (mio. ha) + ov35_hvarea_primforest(t,j,type) Harvested area from primary forest (mio. ha) + ov_prod_natveg(t,j,land_natveg,kforestry,type) Production of woody biomass from natural vegetation (mio. tDM per yr) + ov_cost_hvarea_natveg(t,i,type) Cost of harvesting natural vegetation (mio. USD17MER) + ov_natforest_reduction(t,j,type) Natural forest reduction (mio. ha) + oq35_land_secdforest(t,j,type) Secdforest land pool calculation (mio. ha) + oq35_land_other(t,j,type) Other land pool calculation (mio. ha) + oq35_carbon_primforest(t,j,ag_pools,stockType,type) Primforest carbon stock calculation (mio tC) + oq35_carbon_secdforest(t,j,ag_pools,stockType,type) Secdforest carbon stock calculation (mio tC) + oq35_carbon_other(t,j,ag_pools,stockType,type) Other land carbon stock calculation (mio tC) + 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_natforest_reduction(t,j,type) Natural forest reduction (mio. ha) + oq35_landdiff(t,type) Difference in natveg land (mio. ha) + oq35_other_expansion(t,j,othertype35,type) Other land expansion (mio. ha) + oq35_other_reduction(t,j,othertype35,ac,type) Other land reduction (mio. ha) + oq35_secdforest_expansion(t,j,type) Secdforest expansion (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 regeneration (mio. ha) + oq35_max_forest_establishment(t,j,type) Maximum forestry regeneration based on potential forest area (mio. ha) + oq35_other_regeneration(t,j,type) Other land regeneration (mio. ha) + oq35_other_est(t,j,ac,type) Distribution of other land additions over ac_est (mio. ha) + oq35_secdforest_est(t,j,ac,type) Distribution of secdforest additions over ac_est (mio. ha) + oq35_hvarea_other(t,j,othertype35,ac,type) Harvested area other land (mio. ha) + oq35_hvarea_secdforest(t,j,ac,type) Harvested area secdforest (mio. ha) + oq35_hvarea_primforest(t,j,type) Harvested area primforest (mio. ha) + oq35_prod_secdforest(t,j,type) Production of woody biomass from secondary forests (mio. tDM per yr) + oq35_prod_primforest(t,j,type) Production of woody biomass from primary forests (mio. tDM per yr) + oq35_prod_other(t,j,type) Production of woody biomass from other land (mio. tDM per yr) + oq35_cost_hvarea(t,i,type) Cost of harvesting natural vegetation (mio. USD17MER) + oq35_bv_primforest(t,j,potnatveg,type) Biodiversity value of primary forest (mio. ha) + oq35_bv_secdforest(t,j,potnatveg,type) Biodiversity value of secondary forest (mio. ha) + oq35_bv_other(t,j,potnatveg,type) Biodiversity value of other land (mio. ha) + oq35_natveg_conservation(t,j,type) Total natural vegetation conservation constraint (mio. ha) + oq35_secdforest_restoration(t,j,type) Secondary forest restoration constraint (mio. ha) + oq35_other_restoration(t,j,type) Other land restoration constraint (mio. ha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/35_natveg/pot_forest_may24/equations.gms b/modules/35_natveg/pot_forest_may24/equations.gms new file mode 100644 index 0000000000..07d7e62471 --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/equations.gms @@ -0,0 +1,229 @@ +*** | (C) 2008-2025 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 +*' The interface `vm_land` provides aggregated natveg land pools (`ac`) to other modules. + + q35_land_secdforest(j2) .. vm_land(j2,"secdforest") =e= sum(ac, v35_secdforest(j2,ac)); + + q35_land_other(j2) .. vm_land(j2,"other") =e= sum((othertype35,ac), vm_land_other(j2,othertype35,ac)); + +*' The total natural land area cannot be smaller than the total natural land conservation target. +*' Area requirements for natural land conservation are derived from WDPA and formulated based on +*' conservation priority areas during future time steps. + + q35_natveg_conservation(j2) .. + sum(land_natveg, vm_land(j2,land_natveg)) + =g= + sum((ct,land_natveg), pm_land_conservation(ct,j2,land_natveg,"protect")); + + q35_secdforest_restoration(j2) .. + sum(land_ag, vm_lu_transitions(j2,land_ag,"secdforest")) + + vm_lu_transitions(j2,"forestry","secdforest") + =g= + p35_land_restoration(j2,"secdforest"); + + q35_other_restoration(j2) .. + sum(land_ag, vm_lu_transitions(j2,land_ag,"other")) + =g= + p35_land_restoration(j2,"other"); + +*' Carbon stocks for primary forest, secondary forest or other natural land are calculated +*' as the product of respective area and carbon density. +*' Carbon stocks decline if the area decreases +*' (e.g. due to cropland expansion into forests). +*' In case of abandoned agricultural land (increase of other natural land), +*' natural succession, represented by age-class growth, results in increasing carbon stocks. + + q35_carbon_primforest(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"primforest",ag_pools,stockType) =e= + m_carbon_stock(vm_land,fm_carbon_density,"primforest"); + + q35_carbon_secdforest(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"secdforest",ag_pools,stockType) =e= + m_carbon_stock_ac(v35_secdforest,pm_carbon_density_secdforest_ac,"ac","ac_sub"); + + q35_carbon_other(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"other",ag_pools,stockType) =e= + m_carbon_stock_ac(vm_land_other,p35_carbon_density_other,"othertype35,ac","othertype35,ac_sub"); + +*' The biodiversity value (BV) of primary forest, secondary forest and other land is computed by multiplying their respective land area with bii coefficients, which depend on the age class and whether the potential natural vegetation forest or non-forest (luh2 side layers). + + q35_bv_primforest(j2,potnatveg) .. vm_bv(j2,"primforest",potnatveg) + =e= + vm_land(j2,"primforest") * fm_bii_coeff("primary",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + q35_bv_secdforest(j2,potnatveg) .. vm_bv(j2,"secdforest",potnatveg) + =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v35_secdforest(j2,ac)) * + fm_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + + q35_bv_other(j2,potnatveg) .. vm_bv(j2,"other",potnatveg) + =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), sum(othertype35, vm_land_other(j2,othertype35,ac))) * + fm_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + +*' NPI/NDC land protection policies based on country reports are implemented as +*' minium forest and other land stocks. They are not interchangeable (as compared to +*' the natural land conservation constraint) and specifically formulated for forest and +*' other land stocks. + + q35_min_forest(j2) .. sum(land_forest, vm_land(j2,land_forest)) + =g= + sum(ct, p35_min_forest(ct,j2)); + + q35_min_other(j2) .. vm_land(j2,"other") =g= sum(ct, p35_min_other(ct,j2)); + + q35_natforest_reduction(j2) .. vm_natforest_reduction(j2) =e= + v35_primforest_reduction(j2) + sum(ac_sub, v35_secdforest_reduction(j2,ac_sub)); + +*' The following technical calculations are needed for reducing differences in land-use patterns between time steps. +*' The gross change in natural vegetation is calculated based on land expansion and +*' land contraction of other land, and land reduction of primary and secondary forest. +*' This information is then passed to the land module ([10_land]): + + q35_landdiff .. vm_landdiff_natveg =e= + sum(j2, + sum(othertype35,v35_other_expansion(j2,othertype35)) + + sum((othertype35,ac_sub), v35_other_reduction(j2,othertype35,ac_sub)) + + v35_secdforest_expansion(j2) + + sum((ac_sub), v35_secdforest_reduction(j2,ac_sub)) + + v35_primforest_reduction(j2)); + + q35_other_expansion(j2,othertype35) .. + v35_other_expansion(j2,othertype35) =e= + sum(ac_est, vm_land_other(j2,othertype35,ac_est)); + + q35_other_reduction(j2,othertype35,ac_sub) .. + v35_other_reduction(j2,othertype35,ac_sub) =e= + pc35_land_other(j2,othertype35,ac_sub) - vm_land_other(j2,othertype35,ac_sub); + + 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= + pc35_secdforest(j2,ac_sub) - v35_secdforest(j2,ac_sub); + + q35_primforest_reduction(j2) .. + v35_primforest_reduction(j2) =e= + pcm_land(j2,"primforest") - vm_land(j2,"primforest"); + +******************************************************************* +**** Timber production related equations in natural vegetation **** +******************************************************************* + +*' For natural forest, per-hectare harvesting costs are positive to make sure that older +*' forest with higher growing stock is preferred over younger forest. +*' To mimic the difficulties in accessing primary forest, per-hectare harvesting +*' costs for primary forest are higher than for secondary forest. Harvesting costs +*' are paid everytime natural vegetation is harvested. The "real" harvested area +*' are received from the timber module [73_timber]. + +q35_cost_hvarea(i2).. + vm_cost_hvarea_natveg(i2) + =e= + sum((ct,cell(i2,j2),ac_sub), v35_hvarea_secdforest(j2,ac_sub)) * s35_timber_harvest_cost_secdforest + + sum((ct,cell(i2,j2),othertype35,ac_sub), v35_hvarea_other(j2,othertype35,ac_sub)) * s35_timber_harvest_cost_other + + sum((ct,cell(i2,j2)), v35_hvarea_primforest(j2)) * s35_timber_harvest_cost_primforest + ; + +** Secondary forest +*' Woody biomass production from secondary forests is calculated by multiplying the +*' area under production with corresponding yields of secondary forests, divided by the timestep length. + +q35_prod_secdforest(j2).. + sum(kforestry, vm_prod_natveg(j2,"secdforest",kforestry)) + =e= + sum(ac_sub, v35_hvarea_secdforest(j2,ac_sub) * sum(ct,pm_timber_yield(ct,j2,ac_sub,"secdforest"))) / m_timestep_length_forestry; + +** Primary forest +*' Woody biomass production from primary forests is calculated by multiplying the +*' area under production with corresponding yields of primary forests, divided by the timestep length. + +q35_prod_primforest(j2).. + sum(kforestry, vm_prod_natveg(j2,"primforest",kforestry)) + =e= + v35_hvarea_primforest(j2) * sum(ct, pm_timber_yield(ct,j2,"acx","primforest")) / m_timestep_length_forestry; + +** Other land +*' Woody biomass production from other land is calculated by multiplying the area under +*' production with corresponding yields of other land, divided by the timestep length. + +q35_prod_other(j2).. + sum(kforestry, vm_prod_natveg(j2,"other",kforestry)) + =e= + (sum(ac_sub, v35_hvarea_other(j2,"othernat",ac_sub) * sum(ct, pm_timber_yield(ct,j2,ac_sub,"other"))) + + sum(ac_sub, v35_hvarea_other(j2,"youngsecdf",ac_sub) * sum(ct, pm_timber_yield(ct,j2,ac_sub,"secdforest")))) + / m_timestep_length_forestry + ; + +*' Following equations show the harvested area from natural vegetation i.e. primary +*' forests, secondary forests and other land. Important to note here that no wood +*' production should be realized from other land. Harvested area for production +*' purposes can be lower oe equal than land reduction in natural vegetation as +*' not all lost area is (or should be) used for production. + +q35_hvarea_secdforest(j2,ac_sub).. + v35_hvarea_secdforest(j2,ac_sub) + =l= + v35_secdforest_reduction(j2,ac_sub); + +q35_hvarea_primforest(j2).. + v35_hvarea_primforest(j2) + =l= + v35_primforest_reduction(j2); + +q35_hvarea_other(j2,othertype35,ac_sub).. + v35_hvarea_other(j2,othertype35,ac_sub) + =l= + v35_other_reduction(j2,othertype35,ac_sub); + + +*' The constraint for overall forest establishment, including forestry, is given +*' by the remaining potential forest area, which is derived from the potential +*' natural forestarea minus the recovering secondary forest area. + +q35_max_forest_establishment(j2).. + sum(land_forest, vm_landexpansion(j2,land_forest)) + =l= + sum(ct,pm_max_forest_est(ct,j2)) + - sum(ac, vm_land_other(j2,"youngsecdf",ac) ) + ; + +*' Harvested secondary forest is still considered secondary forests due to +*' restrictive NPI definitions. Also primary forest harvested will be considered +*' to be secondary forest i.e., harvested primary forest gets reclassified as +*' secondary forest and ends up in the youngest age-class (and follows regrowth) + +q35_secdforest_regeneration(j2).. + sum(ac_est, v35_secdforest(j2,ac_est)) + =e= + sum(ac_sub,v35_hvarea_secdforest(j2,ac_sub)) + + v35_hvarea_primforest(j2) + + p35_land_restoration(j2,"secdforest") + ; + +*' Harvested other land is still considered other land + +q35_other_regeneration(j2).. + sum(ac_est, vm_land_other(j2,"othernat",ac_est)) + =e= + sum((othertype35,ac_sub),v35_hvarea_other(j2,othertype35,ac_sub)) + + vm_landexpansion(j2,"other") + ; + +*' The following two constraints distribute additions to secdforest and other land +*' over ac_est, which depends on the time step length (e.g. ac0 and ac5 for a 10 year time step). + +q35_secdforest_est(j2,ac_est) .. +v35_secdforest(j2,ac_est) =e= sum(ac_est2, v35_secdforest(j2,ac_est2))/card(ac_est2); + +q35_other_est(j2,ac_est) .. +vm_land_other(j2,"othernat",ac_est) =e= sum(ac_est2, vm_land_other(j2,"othernat",ac_est2))/card(ac_est2); + diff --git a/modules/35_natveg/pot_forest_may24/input.gms b/modules/35_natveg/pot_forest_may24/input.gms new file mode 100644 index 0000000000..d62257987a --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/input.gms @@ -0,0 +1,66 @@ +*** | (C) 2008-2025 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 + +$setglobal c35_ad_policy npi +$setglobal c35_aolc_policy npi +$setglobal c35_shock_scenario none + +$setglobal c35_pot_forest_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + +scalars +s35_hvarea Flag for harvested area (0=zero 1=exognous 2=endogneous) / 2 / +s35_hvarea_secdforest annual secdforest harvest rate for s35_hvarea equals 1 (percent per year) / 0 / +s35_hvarea_primforest annual primforest harvest rate for s35_hvarea equals 1 (percent per year) / 0 / +s35_hvarea_other annual other land harvest rate for s35_hvarea equals 1 (percent per year) / 0 / +s35_timber_harvest_cost_secdforest Cost for harvesting from secondary forest (USD17MER per ha) / 2460/ +s35_timber_harvest_cost_other Cost for harvesting from other land (USD17MER per ha) / 3075 / +s35_timber_harvest_cost_primforest Cost for harvesting from primary forest (USD17MER per ha) / 3690/ +s35_natveg_harvest_shr Constrains the allowed wood harvest from natural vegetation (1=unconstrained) (1) /1/ +s35_secdf_distribution Flag for secdf initialization (0=all secondary forest in highest age class 1=Equal distribution among all age classes 2=Poulter distribution from MODIS satellite data) (1) / 2 / +s35_forest_damage Damage simulation in forests (0=none 1=shifting agriculture 2= Damage from shifting agriculture is faded out by c35_forest_damage_end 4= f35_forest_shock scenario) / 2 / +s35_forest_damage_end Year of forest damage end (1) / 2050 / +s35_npi_ndc_reversal Year in which NPI NDC reversal should take place (1) / Inf / +; + +table f35_forest_lost_share(i,driver_source) Share of area damanged by forest fires (1) +$ondelim +$include "./modules/35_natveg/input/f35_forest_lost_share.cs3" +$offdelim +; + +table f35_min_land_stock(t_all,j,pol35,pol_stock35) Avoided deforestation and land protection policies [minimum land stock] (Mha) +$ondelim +$include "./modules/35_natveg/input/npi_ndc_ad_aolc_pol.cs3" +$offdelim +; + +table f35_forest_shock(t_all, shock_scen) Forest carbon shock scenarios (area share affected per year) +$ondelim +$include "./modules/35_natveg/input/f35_forest_shock.csv" +$offdelim +; + +parameter f35_forest_disturbance_share(i) Share of area damanged by forest disturbances (1) +/ +$ondelim +$include "./modules/35_natveg/input/f35_forest_disturbance_share.cs4" +$offdelim +/; + +parameter f35_pot_forest_area(t_all,j) Potential forest area (mio. ha) +/ +$ondelim +$include "./modules/35_natveg/input/pot_forest_area.cs2" +$offdelim +/; + +$if "%c35_pot_forest_scenario%" == "nocc" f35_pot_forest_area(t_all,j) = f35_pot_forest_area("y1995",j); +$if "%c35_pot_forest_scenario%" == "nocc_hist" f35_pot_forest_area(t_all,j)$(m_year(t_all) > sm_fix_cc) = f35_pot_forest_area(t_all,j)$(m_year(t_all) = sm_fix_cc); +m_fillmissingyears(f35_pot_forest_area,"j"); diff --git a/modules/35_natveg/pot_forest_may24/postsolve.gms b/modules/35_natveg/pot_forest_may24/postsolve.gms new file mode 100644 index 0000000000..2fd39a119e --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/postsolve.gms @@ -0,0 +1,203 @@ +*** | (C) 2008-2025 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 + +*secdforest age class calculation +pc35_secdforest(j,ac) = v35_secdforest.l(j,ac); + +*other land age class calculation +pc35_land_other(j,othertype35,ac) = vm_land_other.l(j,othertype35,ac); + +* Set the forest establishment bound for the next time step +pm_max_forest_est(t+1,j) = f35_pot_forest_area(t+1,j) - sum(land_forest, vm_land.l(j,land_forest)); +pm_max_forest_est(t+1,j)$(pm_max_forest_est(t+1,j) < 1e-6) = 0; + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov35_secdforest(t,j,ac,"marginal") = v35_secdforest.m(j,ac); + ov_land_other(t,j,othertype35,ac,"marginal") = vm_land_other.m(j,othertype35,ac); + ov_landdiff_natveg(t,"marginal") = vm_landdiff_natveg.m; + ov35_other_expansion(t,j,othertype35,"marginal") = v35_other_expansion.m(j,othertype35); + ov35_other_reduction(t,j,othertype35,ac,"marginal") = v35_other_reduction.m(j,othertype35,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); + ov35_hvarea_other(t,j,othertype35,ac,"marginal") = v35_hvarea_other.m(j,othertype35,ac); + ov35_hvarea_primforest(t,j,"marginal") = v35_hvarea_primforest.m(j); + ov_prod_natveg(t,j,land_natveg,kforestry,"marginal") = vm_prod_natveg.m(j,land_natveg,kforestry); + ov_cost_hvarea_natveg(t,i,"marginal") = vm_cost_hvarea_natveg.m(i); + ov_natforest_reduction(t,j,"marginal") = vm_natforest_reduction.m(j); + oq35_land_secdforest(t,j,"marginal") = q35_land_secdforest.m(j); + oq35_land_other(t,j,"marginal") = q35_land_other.m(j); + oq35_carbon_primforest(t,j,ag_pools,stockType,"marginal") = q35_carbon_primforest.m(j,ag_pools,stockType); + oq35_carbon_secdforest(t,j,ag_pools,stockType,"marginal") = q35_carbon_secdforest.m(j,ag_pools,stockType); + oq35_carbon_other(t,j,ag_pools,stockType,"marginal") = q35_carbon_other.m(j,ag_pools,stockType); + oq35_min_forest(t,j,"marginal") = q35_min_forest.m(j); + oq35_min_other(t,j,"marginal") = q35_min_other.m(j); + oq35_natforest_reduction(t,j,"marginal") = q35_natforest_reduction.m(j); + oq35_landdiff(t,"marginal") = q35_landdiff.m; + oq35_other_expansion(t,j,othertype35,"marginal") = q35_other_expansion.m(j,othertype35); + oq35_other_reduction(t,j,othertype35,ac,"marginal") = q35_other_reduction.m(j,othertype35,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); + oq35_max_forest_establishment(t,j,"marginal") = q35_max_forest_establishment.m(j); + oq35_other_regeneration(t,j,"marginal") = q35_other_regeneration.m(j); + oq35_other_est(t,j,ac,"marginal") = q35_other_est.m(j,ac); + oq35_secdforest_est(t,j,ac,"marginal") = q35_secdforest_est.m(j,ac); + oq35_hvarea_other(t,j,othertype35,ac,"marginal") = q35_hvarea_other.m(j,othertype35,ac); + oq35_hvarea_secdforest(t,j,ac,"marginal") = q35_hvarea_secdforest.m(j,ac); + oq35_hvarea_primforest(t,j,"marginal") = q35_hvarea_primforest.m(j); + oq35_prod_secdforest(t,j,"marginal") = q35_prod_secdforest.m(j); + oq35_prod_primforest(t,j,"marginal") = q35_prod_primforest.m(j); + oq35_prod_other(t,j,"marginal") = q35_prod_other.m(j); + oq35_cost_hvarea(t,i,"marginal") = q35_cost_hvarea.m(i); + oq35_bv_primforest(t,j,potnatveg,"marginal") = q35_bv_primforest.m(j,potnatveg); + oq35_bv_secdforest(t,j,potnatveg,"marginal") = q35_bv_secdforest.m(j,potnatveg); + oq35_bv_other(t,j,potnatveg,"marginal") = q35_bv_other.m(j,potnatveg); + oq35_natveg_conservation(t,j,"marginal") = q35_natveg_conservation.m(j); + oq35_secdforest_restoration(t,j,"marginal") = q35_secdforest_restoration.m(j); + oq35_other_restoration(t,j,"marginal") = q35_other_restoration.m(j); + ov35_secdforest(t,j,ac,"level") = v35_secdforest.l(j,ac); + ov_land_other(t,j,othertype35,ac,"level") = vm_land_other.l(j,othertype35,ac); + ov_landdiff_natveg(t,"level") = vm_landdiff_natveg.l; + ov35_other_expansion(t,j,othertype35,"level") = v35_other_expansion.l(j,othertype35); + ov35_other_reduction(t,j,othertype35,ac,"level") = v35_other_reduction.l(j,othertype35,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); + ov35_hvarea_other(t,j,othertype35,ac,"level") = v35_hvarea_other.l(j,othertype35,ac); + ov35_hvarea_primforest(t,j,"level") = v35_hvarea_primforest.l(j); + ov_prod_natveg(t,j,land_natveg,kforestry,"level") = vm_prod_natveg.l(j,land_natveg,kforestry); + ov_cost_hvarea_natveg(t,i,"level") = vm_cost_hvarea_natveg.l(i); + ov_natforest_reduction(t,j,"level") = vm_natforest_reduction.l(j); + oq35_land_secdforest(t,j,"level") = q35_land_secdforest.l(j); + oq35_land_other(t,j,"level") = q35_land_other.l(j); + oq35_carbon_primforest(t,j,ag_pools,stockType,"level") = q35_carbon_primforest.l(j,ag_pools,stockType); + oq35_carbon_secdforest(t,j,ag_pools,stockType,"level") = q35_carbon_secdforest.l(j,ag_pools,stockType); + oq35_carbon_other(t,j,ag_pools,stockType,"level") = q35_carbon_other.l(j,ag_pools,stockType); + oq35_min_forest(t,j,"level") = q35_min_forest.l(j); + oq35_min_other(t,j,"level") = q35_min_other.l(j); + oq35_natforest_reduction(t,j,"level") = q35_natforest_reduction.l(j); + oq35_landdiff(t,"level") = q35_landdiff.l; + oq35_other_expansion(t,j,othertype35,"level") = q35_other_expansion.l(j,othertype35); + oq35_other_reduction(t,j,othertype35,ac,"level") = q35_other_reduction.l(j,othertype35,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); + oq35_max_forest_establishment(t,j,"level") = q35_max_forest_establishment.l(j); + oq35_other_regeneration(t,j,"level") = q35_other_regeneration.l(j); + oq35_other_est(t,j,ac,"level") = q35_other_est.l(j,ac); + oq35_secdforest_est(t,j,ac,"level") = q35_secdforest_est.l(j,ac); + oq35_hvarea_other(t,j,othertype35,ac,"level") = q35_hvarea_other.l(j,othertype35,ac); + oq35_hvarea_secdforest(t,j,ac,"level") = q35_hvarea_secdforest.l(j,ac); + oq35_hvarea_primforest(t,j,"level") = q35_hvarea_primforest.l(j); + oq35_prod_secdforest(t,j,"level") = q35_prod_secdforest.l(j); + oq35_prod_primforest(t,j,"level") = q35_prod_primforest.l(j); + oq35_prod_other(t,j,"level") = q35_prod_other.l(j); + oq35_cost_hvarea(t,i,"level") = q35_cost_hvarea.l(i); + oq35_bv_primforest(t,j,potnatveg,"level") = q35_bv_primforest.l(j,potnatveg); + oq35_bv_secdforest(t,j,potnatveg,"level") = q35_bv_secdforest.l(j,potnatveg); + oq35_bv_other(t,j,potnatveg,"level") = q35_bv_other.l(j,potnatveg); + oq35_natveg_conservation(t,j,"level") = q35_natveg_conservation.l(j); + oq35_secdforest_restoration(t,j,"level") = q35_secdforest_restoration.l(j); + oq35_other_restoration(t,j,"level") = q35_other_restoration.l(j); + ov35_secdforest(t,j,ac,"upper") = v35_secdforest.up(j,ac); + ov_land_other(t,j,othertype35,ac,"upper") = vm_land_other.up(j,othertype35,ac); + ov_landdiff_natveg(t,"upper") = vm_landdiff_natveg.up; + ov35_other_expansion(t,j,othertype35,"upper") = v35_other_expansion.up(j,othertype35); + ov35_other_reduction(t,j,othertype35,ac,"upper") = v35_other_reduction.up(j,othertype35,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); + ov35_hvarea_other(t,j,othertype35,ac,"upper") = v35_hvarea_other.up(j,othertype35,ac); + ov35_hvarea_primforest(t,j,"upper") = v35_hvarea_primforest.up(j); + ov_prod_natveg(t,j,land_natveg,kforestry,"upper") = vm_prod_natveg.up(j,land_natveg,kforestry); + ov_cost_hvarea_natveg(t,i,"upper") = vm_cost_hvarea_natveg.up(i); + ov_natforest_reduction(t,j,"upper") = vm_natforest_reduction.up(j); + oq35_land_secdforest(t,j,"upper") = q35_land_secdforest.up(j); + oq35_land_other(t,j,"upper") = q35_land_other.up(j); + oq35_carbon_primforest(t,j,ag_pools,stockType,"upper") = q35_carbon_primforest.up(j,ag_pools,stockType); + oq35_carbon_secdforest(t,j,ag_pools,stockType,"upper") = q35_carbon_secdforest.up(j,ag_pools,stockType); + oq35_carbon_other(t,j,ag_pools,stockType,"upper") = q35_carbon_other.up(j,ag_pools,stockType); + oq35_min_forest(t,j,"upper") = q35_min_forest.up(j); + oq35_min_other(t,j,"upper") = q35_min_other.up(j); + oq35_natforest_reduction(t,j,"upper") = q35_natforest_reduction.up(j); + oq35_landdiff(t,"upper") = q35_landdiff.up; + oq35_other_expansion(t,j,othertype35,"upper") = q35_other_expansion.up(j,othertype35); + oq35_other_reduction(t,j,othertype35,ac,"upper") = q35_other_reduction.up(j,othertype35,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); + oq35_max_forest_establishment(t,j,"upper") = q35_max_forest_establishment.up(j); + oq35_other_regeneration(t,j,"upper") = q35_other_regeneration.up(j); + oq35_other_est(t,j,ac,"upper") = q35_other_est.up(j,ac); + oq35_secdforest_est(t,j,ac,"upper") = q35_secdforest_est.up(j,ac); + oq35_hvarea_other(t,j,othertype35,ac,"upper") = q35_hvarea_other.up(j,othertype35,ac); + oq35_hvarea_secdforest(t,j,ac,"upper") = q35_hvarea_secdforest.up(j,ac); + oq35_hvarea_primforest(t,j,"upper") = q35_hvarea_primforest.up(j); + oq35_prod_secdforest(t,j,"upper") = q35_prod_secdforest.up(j); + oq35_prod_primforest(t,j,"upper") = q35_prod_primforest.up(j); + oq35_prod_other(t,j,"upper") = q35_prod_other.up(j); + oq35_cost_hvarea(t,i,"upper") = q35_cost_hvarea.up(i); + oq35_bv_primforest(t,j,potnatveg,"upper") = q35_bv_primforest.up(j,potnatveg); + oq35_bv_secdforest(t,j,potnatveg,"upper") = q35_bv_secdforest.up(j,potnatveg); + oq35_bv_other(t,j,potnatveg,"upper") = q35_bv_other.up(j,potnatveg); + oq35_natveg_conservation(t,j,"upper") = q35_natveg_conservation.up(j); + oq35_secdforest_restoration(t,j,"upper") = q35_secdforest_restoration.up(j); + oq35_other_restoration(t,j,"upper") = q35_other_restoration.up(j); + ov35_secdforest(t,j,ac,"lower") = v35_secdforest.lo(j,ac); + ov_land_other(t,j,othertype35,ac,"lower") = vm_land_other.lo(j,othertype35,ac); + ov_landdiff_natveg(t,"lower") = vm_landdiff_natveg.lo; + ov35_other_expansion(t,j,othertype35,"lower") = v35_other_expansion.lo(j,othertype35); + ov35_other_reduction(t,j,othertype35,ac,"lower") = v35_other_reduction.lo(j,othertype35,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); + ov35_hvarea_other(t,j,othertype35,ac,"lower") = v35_hvarea_other.lo(j,othertype35,ac); + ov35_hvarea_primforest(t,j,"lower") = v35_hvarea_primforest.lo(j); + ov_prod_natveg(t,j,land_natveg,kforestry,"lower") = vm_prod_natveg.lo(j,land_natveg,kforestry); + ov_cost_hvarea_natveg(t,i,"lower") = vm_cost_hvarea_natveg.lo(i); + ov_natforest_reduction(t,j,"lower") = vm_natforest_reduction.lo(j); + oq35_land_secdforest(t,j,"lower") = q35_land_secdforest.lo(j); + oq35_land_other(t,j,"lower") = q35_land_other.lo(j); + oq35_carbon_primforest(t,j,ag_pools,stockType,"lower") = q35_carbon_primforest.lo(j,ag_pools,stockType); + oq35_carbon_secdforest(t,j,ag_pools,stockType,"lower") = q35_carbon_secdforest.lo(j,ag_pools,stockType); + oq35_carbon_other(t,j,ag_pools,stockType,"lower") = q35_carbon_other.lo(j,ag_pools,stockType); + oq35_min_forest(t,j,"lower") = q35_min_forest.lo(j); + oq35_min_other(t,j,"lower") = q35_min_other.lo(j); + oq35_natforest_reduction(t,j,"lower") = q35_natforest_reduction.lo(j); + oq35_landdiff(t,"lower") = q35_landdiff.lo; + oq35_other_expansion(t,j,othertype35,"lower") = q35_other_expansion.lo(j,othertype35); + oq35_other_reduction(t,j,othertype35,ac,"lower") = q35_other_reduction.lo(j,othertype35,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); + oq35_max_forest_establishment(t,j,"lower") = q35_max_forest_establishment.lo(j); + oq35_other_regeneration(t,j,"lower") = q35_other_regeneration.lo(j); + oq35_other_est(t,j,ac,"lower") = q35_other_est.lo(j,ac); + oq35_secdforest_est(t,j,ac,"lower") = q35_secdforest_est.lo(j,ac); + oq35_hvarea_other(t,j,othertype35,ac,"lower") = q35_hvarea_other.lo(j,othertype35,ac); + oq35_hvarea_secdforest(t,j,ac,"lower") = q35_hvarea_secdforest.lo(j,ac); + oq35_hvarea_primforest(t,j,"lower") = q35_hvarea_primforest.lo(j); + oq35_prod_secdforest(t,j,"lower") = q35_prod_secdforest.lo(j); + oq35_prod_primforest(t,j,"lower") = q35_prod_primforest.lo(j); + oq35_prod_other(t,j,"lower") = q35_prod_other.lo(j); + oq35_cost_hvarea(t,i,"lower") = q35_cost_hvarea.lo(i); + oq35_bv_primforest(t,j,potnatveg,"lower") = q35_bv_primforest.lo(j,potnatveg); + oq35_bv_secdforest(t,j,potnatveg,"lower") = q35_bv_secdforest.lo(j,potnatveg); + oq35_bv_other(t,j,potnatveg,"lower") = q35_bv_other.lo(j,potnatveg); + oq35_natveg_conservation(t,j,"lower") = q35_natveg_conservation.lo(j); + oq35_secdforest_restoration(t,j,"lower") = q35_secdforest_restoration.lo(j); + oq35_other_restoration(t,j,"lower") = q35_other_restoration.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/35_natveg/pot_forest_may24/preloop.gms b/modules/35_natveg/pot_forest_may24/preloop.gms new file mode 100644 index 0000000000..fed6618d7d --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/preloop.gms @@ -0,0 +1,99 @@ +*** | (C) 2008-2025 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 + +** initialize other land +i35_land_other(j,othertype35,ac) = 0; +i35_land_other(j,"othernat","acx") = pcm_land(j,"other"); + +** initialize secdforest area depending on switch. +if(s35_secdf_distribution = 0, + i35_secdforest(j,"acx") = pcm_land(j,"secdforest"); +elseif s35_secdf_distribution = 1, +* ac0 is excluded here. Therefore no initial shifting is needed. + i35_secdforest(j,ac)$(not sameas(ac,"ac0")) = pcm_land(j,"secdforest")/(card(ac)-1); +elseif s35_secdf_distribution = 2, +*For the initialization of age-classes in secondary forest, forest area in 5-year age-classes based on GFAD is used + p35_secdf_ageclass(j,ac) = im_forest_ageclass(j,ac); +* Young forest (`ac_young`) includes plantations and might be (strongly) affected by disturbances such as fire. +* Therefore, young forest (`ac_young`) is disregarded for the initialization of age-classes in secondary forest. +* Instead, age-class areas from `ac35` are used as a proxy for `ac_young`. + p35_secdf_ageclass(j,ac_young) = p35_secdf_ageclass(j,"ac35"); +* `acx` includes primary forest. Therefore, primary forest is subtracted from `acx`. + p35_secdf_ageclass(j,"acx") = p35_secdf_ageclass(j,"acx") - pcm_land(j,"primforest"); + p35_secdf_ageclass(j,"acx")$(p35_secdf_ageclass(j,"acx") < 0) = 0; + +* Distribution of age-classes in secondary forest. In case of missing area information, `acx` is assumed. + p35_secdf_ageclass_dist(j,ac) = 0; + p35_secdf_ageclass_dist(j,"acx") = 1; + p35_secdf_ageclass_dist(j,ac)$(sum(ac2,p35_secdf_ageclass(j,ac2))>0) = + p35_secdf_ageclass(j,ac)/sum(ac2,p35_secdf_ageclass(j,ac2)); + i35_secdforest(j,ac)$(not sameas(ac,"ac0")) = pcm_land(j,"secdforest")*p35_secdf_ageclass_dist(j,ac); +); + +*use residual approach to avoid rounding errors +i35_secdforest(j,"acx") = i35_secdforest(j,"acx") + (pcm_land(j,"secdforest") - sum(ac, i35_secdforest(j,ac))); + +*initialize parameter +p35_land_other(t,j,othertype35,ac) = 0; +p35_secdforest(t,j,ac) = 0; + +* initialize forest disturbance losses +p35_disturbance_loss_secdf(t,j,ac) = 0; +p35_disturbance_loss_primf(t,j) = 0; + +* ------------------------------------------------------------- +* Initialize remaining potential forest establishment area +* ------------------------------------------------------------- + +* Forest establishment is constrained by the potential forest area in each cluster. +* Hence, the area for forest establishments is given by the potential forest +* area minus all forest areas in the previous time step. +pm_max_forest_est(t,j) = f35_pot_forest_area(t,j) - sum(land_forest, pcm_land(j,land_forest)); +pm_max_forest_est(t,j)$(pm_max_forest_est(t,j) < 1e-6) = 0; + +* ----------------------------------------- +* Land conservation for climate mitigation +* ----------------------------------------- + +p35_min_forest(t,j) = f35_min_land_stock(t,j,"%c35_ad_policy%","forest"); +p35_min_other(t,j) = f35_min_land_stock(t,j,"%c35_ad_policy%","other"); + + +* ---------------------------------------- +* Calibrate Natural vegetation yields +* ---------------------------------------- + +** Initialize with 0 cvalues +p35_land_start_ac(j,ac,land_natveg) = 0; +** Capture natural forest values (primary forest + secondary forest) +p35_land_start_ac(j,"acx","primforest") = pcm_land(j,"primforest"); +p35_land_start_ac(j,ac,"secdforest") = i35_secdforest(j,ac); + + +* ----------------------------- +* Set forest damage trajectory +* ----------------------------- +m_sigmoid_time_interpol(p35_damage_fader,sm_fix_SSP2,s35_forest_damage_end,0,1); + +* --------------------------------------- +* Initialise natveg in first time step +* --------------------------------------- + + pc35_secdforest(j,ac) = i35_secdforest(j,ac); + pc35_land_other(j,othertype35,ac) = i35_land_other(j,othertype35,ac); + +* Initialize biodiversity value +vm_bv.l(j,"primforest",potnatveg) = + pcm_land(j,"primforest") * fm_bii_coeff("primary",potnatveg) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"secdforest",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), i35_secdforest(j,ac)) * + fm_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"other",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), sum(othertype35, i35_land_other(j,othertype35,ac))) * + fm_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); diff --git a/modules/35_natveg/pot_forest_may24/presolve.gms b/modules/35_natveg/pot_forest_may24/presolve.gms new file mode 100644 index 0000000000..95dc31a683 --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/presolve.gms @@ -0,0 +1,262 @@ +*** | (C) 2008-2025 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 + +* ---------------------------------------------------- +* Shift ageclasses due to shifting agriculture fires +* ---------------------------------------------------- + +* first calculate damages +if(s35_forest_damage=1, + p35_disturbance_loss_secdf(t,j,ac_sub) = pc35_secdforest(j,ac_sub) * sum(cell(i,j),f35_forest_lost_share(i,"shifting_agriculture"))*m_timestep_length_forestry; + p35_disturbance_loss_primf(t,j) = pcm_land(j,"primforest") * sum(cell(i,j),f35_forest_lost_share(i,"shifting_agriculture"))*m_timestep_length_forestry; + ); + +* shifting cultivation is faded out +if(s35_forest_damage=2, + p35_disturbance_loss_secdf(t,j,ac_sub) = pc35_secdforest(j,ac_sub) * sum(cell(i,j),f35_forest_lost_share(i,"shifting_agriculture"))*m_timestep_length_forestry*(1 - p35_damage_fader(t)); + p35_disturbance_loss_primf(t,j) = pcm_land(j,"primforest") * sum(cell(i,j),f35_forest_lost_share(i,"shifting_agriculture"))*m_timestep_length_forestry*(1 - p35_damage_fader(t)); + ); + +if(s35_forest_damage=3, + p35_disturbance_loss_secdf(t,j,ac_sub) = pc35_secdforest(j,ac_sub) * sum((cell(i,j),combined_loss),f35_forest_lost_share(i,combined_loss))*m_timestep_length_forestry; + p35_disturbance_loss_primf(t,j) = pcm_land(j,"primforest") * sum((cell(i,j),combined_loss),f35_forest_lost_share(i,combined_loss))*m_timestep_length_forestry; + ); + +* generic disturbance scenarios +if(s35_forest_damage=4, + p35_disturbance_loss_secdf(t,j,ac_sub) = pc35_secdforest(j,ac_sub) * f35_forest_shock(t,"%c35_shock_scenario%") * m_timestep_length; + p35_disturbance_loss_primf(t,j) = pcm_land(j,"primforest") * f35_forest_shock(t,"%c35_shock_scenario%") * m_timestep_length; + ); + +* 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_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); +vm_land.l(j,"primforest") = pcm_land(j,"primforest"); + + +* ------------------------------------------------- +* Calculate area of secondary forest recovery +* ------------------------------------------------- + +*** Calculate the upper boundary for secondary forest recovery +pc35_max_forest_recovery(j) = pm_max_forest_est(t,j) - sum(ac, pc35_land_other(j,"youngsecdf",ac)); + +*** Distribute forestry abandonement +* Abandoned forestry is directly shifted into p35_forest_recovery_area(t,j,ac_est) because it is +* assumed that forestry was located in areas suitable to grow forests. +p35_forest_recovery_area(t,j,ac_est) = vm_lu_transitions.l(j,"forestry","other")/card(ac_est2); +p35_forest_recovery_area(t,j,ac_est)$(sum(ac_est2, p35_forest_recovery_area(t,j,ac_est2)) > pc35_max_forest_recovery(j)) = pc35_max_forest_recovery(j)/card(ac_est2); + +* The proportion of secondary forest recovery in total natveg +* recovery is derived from the remaining forest recovery area +pc35_forest_recovery_shr(j) = 0; +pc35_forest_recovery_shr(j)$((sum(land_ag, pcm_land(j,land_ag))+pcm_land(j,"urban")) > 0) = + (pc35_max_forest_recovery(j) - sum(ac_est, p35_forest_recovery_area(t,j,ac_est))) + / (sum(land_ag, pcm_land(j,land_ag))+pcm_land(j,"urban")); +pc35_forest_recovery_shr(j)$(pc35_forest_recovery_shr(j) < 1e-6) = 0; +pc35_forest_recovery_shr(j)$(pc35_forest_recovery_shr(j) > 1) = 1; +* Abandoned land pc35_land_other(j,"othernat",ac_est) that has not yet been allocated to +* p35_forest_recovery_area(t,j,ac_est) is then distributed proportionally using the forest recovery share. +p35_forest_recovery_area(t,j,ac_est) = p35_forest_recovery_area(t,j,ac_est) + + (pc35_land_other(j,"othernat",ac_est) - p35_forest_recovery_area(t,j,ac_est)) + * pc35_forest_recovery_shr(j); +p35_forest_recovery_area(t,j,ac_est)$(sum(ac_est2, p35_forest_recovery_area(t,j,ac_est2)) > pc35_max_forest_recovery(j)) = pc35_max_forest_recovery(j)/card(ac_est2); +p35_forest_recovery_area(t,j,ac_est)$(p35_forest_recovery_area(t,j,ac_est) > pc35_land_other(j,"othernat",ac_est)) = pc35_land_other(j,"othernat",ac_est); +p35_forest_recovery_area(t,j,ac_est)$(p35_forest_recovery_area(t,j,ac_est) < 1e-6) = 0; +pc35_land_other(j,"othernat",ac_est) = pc35_land_other(j,"othernat",ac_est) - p35_forest_recovery_area(t,j,ac_est); +pc35_land_other(j,"youngsecdf",ac_est) = pc35_land_other(j,"youngsecdf",ac_est) + p35_forest_recovery_area(t,j,ac_est); + +* ------------------------------------------------ +* Natural vegetation growth (age-class shift) +* ------------------------------------------------ + +* Regrowth of natural vegetation (natural succession) is modelled by shifting age-classes according to time step length. +s35_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s35_shift = 1) + p35_land_other(t,j,othertype35,ac)$(ord(ac) > s35_shift) = pc35_land_other(j,othertype35,ac-s35_shift); +* account for cases at the end of the age class set (s35_shift > 1) which are not shifted by the above calculation + p35_land_other(t,j,othertype35,"acx") = p35_land_other(t,j,othertype35,"acx") + + sum(ac$(ord(ac) > card(ac)-s35_shift), pc35_land_other(j,othertype35,ac)); + +* Usual shift +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s35_shift = 1) + p35_secdforest(t,j,ac)$(ord(ac) > s35_shift) = pc35_secdforest(j,ac-s35_shift); +* account for cases at the end of the age class set (s35_shift > 1) which are not shifted by the above calculation + p35_secdforest(t,j,"acx") = p35_secdforest(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s35_shift), pc35_secdforest(j,ac)); + + +* ------------------------------------------------------- +* Carbon threshold for secondary forest maturation +* ------------------------------------------------------- + +*' @code +*' If the vegetation carbon density in a simulation unit due to regrowth +*' exceeds a threshold of 20 tC/ha the respective area is shifted from young secondary +*' forest, which is still considered other land, to secondary forest land. +p35_maturesecdf(t,j,ac)$(not sameas(ac,"acx")) = + p35_land_other(t,j,"youngsecdf",ac)$(pm_carbon_density_secdforest_ac(t,j,ac,"vegc") > 20); +p35_land_other(t,j,"youngsecdf",ac) = p35_land_other(t,j,"youngsecdf",ac) - p35_maturesecdf(t,j,ac); +p35_secdforest(t,j,ac) = p35_secdforest(t,j,ac) + p35_maturesecdf(t,j,ac); +*' @stop + +pc35_secdforest(j,ac) = p35_secdforest(t,j,ac); +v35_secdforest.l(j,ac) = pc35_secdforest(j,ac); +vm_land.l(j,"secdforest") = sum(ac, pc35_secdforest(j,ac)); +pcm_land(j,"secdforest") = sum(ac, pc35_secdforest(j,ac)); + +pc35_land_other(j,othertype35,ac) = p35_land_other(t,j,othertype35,ac); +vm_land_other.l(j,othertype35,ac) = pc35_land_other(j,othertype35,ac); + +vm_land.l(j,"other") = sum((othertype35,ac), pc35_land_other(j,othertype35,ac)); +pcm_land(j,"other") = sum((othertype35,ac), pc35_land_other(j,othertype35,ac)); + +* ------------------------------------- +* Set bounds based on land conservation +* ------------------------------------- + +* Within the optimization, primary forests can only decrease +* (e.g. due to cropland expansion). +* In contrast, other natural land can decrease and increase within the optimization. +* For instance, other natural land increases if agricultural land is abandoned. + +* Correct land conservation for damage +pm_land_conservation(t,j,land_natveg,"protect")$(pm_land_conservation(t,j,land_natveg,"protect") > pcm_land(j,land_natveg)) = pcm_land(j,land_natveg); + +** Setting bounds for only allowing s35_natveg_harvest_shr percentage of available forest to be harvested (highest age class) + +* Primary forest + +** Allowing selective logging only after historical period +if (sum(sameas(t_past,t),1) = 1, +vm_land.lo(j,"primforest") = 0; +else +vm_land.lo(j,"primforest") = (1-s35_natveg_harvest_shr) * pcm_land(j,"primforest"); +); +* Primary forest conservation +vm_land.lo(j,"primforest")$(vm_land.lo(j,"primforest") < pm_land_conservation(t,j,"primforest","protect")) = pm_land_conservation(t,j,"primforest","protect"); +vm_land.up(j,"primforest") = pcm_land(j,"primforest"); + +* Secondary forest + +*reset bound +v35_secdforest.lo(j,ac) = 0; +v35_secdforest.up(j,ac) = Inf; + +* Secondary forest conservation +p35_protection_dist(j,ac_sub) = 0; +p35_protection_dist(j,ac_sub)$(sum(ac_sub2,pc35_secdforest(j,ac_sub2)) > 0) = pc35_secdforest(j,ac_sub) / sum(ac_sub2,pc35_secdforest(j,ac_sub2)); +pm_land_conservation(t,j,"secdforest","protect")$(pm_land_conservation(t,j,"secdforest","protect") > sum(ac_sub, pc35_secdforest(j,ac_sub))) = sum(ac_sub, pc35_secdforest(j,ac_sub)); +if (sum(sameas(t_past,t),1) = 1, +v35_secdforest.lo(j,ac_sub) = pm_land_conservation(t,j,"secdforest","protect") * p35_protection_dist(j,ac_sub); +else +v35_secdforest.lo(j,ac_sub) = max((1-s35_natveg_harvest_shr) * pc35_secdforest(j,ac_sub), pm_land_conservation(t,j,"secdforest","protect") * p35_protection_dist(j,ac_sub)); +); +* upper bound +v35_secdforest.up(j,ac_sub) = pc35_secdforest(j,ac_sub); +m_boundfix(v35_secdforest,(j,ac_sub),l,1e-6); + +* set restoration target +p35_land_restoration(j,"secdforest") = pm_land_conservation(t,j,"secdforest","restore"); +* Do not restore secdforest in areas where total natural +* land area meets the total natural land conservation target +p35_land_restoration(j,"secdforest")$(sum(land_natveg, pcm_land(j,land_natveg)) >= sum((land_natveg, consv_type), pm_land_conservation(t,j,land_natveg,consv_type))) = 0; + +* Since forest restoration cannot be bigger than the potential area for secdforest recovery, +* any remaining restoration area is substracted and shifted to other land restoration. +p35_restoration_shift(j) = p35_land_restoration(j,"secdforest") - pc35_max_forest_recovery(j); +p35_restoration_shift(j)$(p35_restoration_shift(j) < 1e-6) = 0; +p35_restoration_shift(j)$(p35_restoration_shift(j) > p35_land_restoration(j,"secdforest")) = p35_land_restoration(j,"secdforest"); +p35_land_restoration(j,"secdforest") = p35_land_restoration(j,"secdforest") - p35_restoration_shift(j); +pm_land_conservation(t,j,"secdforest","restore") = p35_land_restoration(j,"secdforest"); +pm_land_conservation(t,j,"other","restore") = pm_land_conservation(t,j,"other","restore") + p35_restoration_shift(j); + +* set conservation bound +vm_land.lo(j,"secdforest") = pm_land_conservation(t,j,"secdforest","protect") + p35_land_restoration(j,"secdforest"); + +** Other land + +*reset bounds +vm_land_other.lo(j,"othernat",ac) = 0; +vm_land_other.up(j,"othernat",ac) = Inf; +vm_land_other.lo(j,"youngsecdf",ac) = 0; +*set upper bound +vm_land_other.up(j,"othernat",ac_sub) = pc35_land_other(j,"othernat",ac_sub); +vm_land_other.up(j,"youngsecdf",ac_sub) = pc35_land_other(j,"youngsecdf",ac_sub); +vm_land_other.fx(j,"youngsecdf",ac_est) = 0; +m_boundfix(vm_land_other,(j,othertype35,ac_sub),l,1e-6); + +pm_max_forest_est(t,j)$(pm_max_forest_est(t,j) < sum(ac, pc35_land_other(j,"youngsecdf",ac))) = + sum(ac, pc35_land_other(j,"youngsecdf",ac)); + +* Other land conservation +* protection bound fix +pm_land_conservation(t,j,"other","protect")$(pm_land_conservation(t,j,"other","protect") > + sum((othertype35,ac_sub), pc35_land_other(j,othertype35,ac_sub))) = + sum((othertype35,ac_sub), pc35_land_other(j,othertype35,ac_sub)); +* set restoration target +p35_land_restoration(j,"other") = pm_land_conservation(t,j,"other","restore"); +* Do not restore other land in areas where total natural +* land area meets the total natural land conservation target +p35_land_restoration(j,"other")$(sum(land_natveg, pcm_land(j,land_natveg)) >= sum((land_natveg, consv_type), pm_land_conservation(t,j,land_natveg,consv_type))) = 0; +pm_land_conservation(t,j,"other","restore") = p35_land_restoration(j,"other"); +* set conservation bound +vm_land.lo(j,"other") = pm_land_conservation(t,j,"other","protect") + p35_land_restoration(j,"other"); + +* boundfix for land_natveg +m_boundfix(vm_land,(j,land_natveg),up,1e-6); + +* ---------------------------- +* Calculate carbon density +* ------------------------------ + +p35_carbon_density_other(t,j,"othernat",ac,ag_pools) = pm_carbon_density_other_ac(t,j,ac,ag_pools); +p35_carbon_density_other(t,j,"youngsecdf",ac,ag_pools) = pm_carbon_density_secdforest_ac(t,j,ac,ag_pools); + +* ---------------------------- +* NPI/NDC protection policy +* ---------------------------- + +p35_min_forest(t,j)$(p35_min_forest(t,j) > pcm_land(j,"primforest") + pcm_land(j,"secdforest") + pcm_land(j,"forestry")) + = pcm_land(j,"primforest") + pcm_land(j,"secdforest") + pcm_land(j,"forestry"); +p35_min_other(t,j)$(p35_min_other(t,j) > pcm_land(j,"other")) = pcm_land(j,"other"); + +* NPI / NDC reversal +if (m_year(t) >= s35_npi_ndc_reversal, + p35_min_forest(t,j) = 0; + p35_min_other(t,j) = 0; +); + +** Youngest age classes are not allowed to be harvested +v35_hvarea_secdforest.fx(j,ac_est) = 0; +v35_hvarea_other.fx(j,othertype35,ac_est) = 0; +v35_secdforest_reduction.fx(j,ac_est) = 0; +v35_other_reduction.fx(j,othertype35,ac_est) = 0; + +if(s35_hvarea = 0, + v35_hvarea_secdforest.fx(j,ac_sub) = 0; + v35_hvarea_primforest.fx(j) = 0; + v35_hvarea_other.fx(j,othertype35,ac_sub) = 0; +elseif s35_hvarea = 1, + v35_hvarea_secdforest.fx(j,ac_sub) = (v35_secdforest.l(j,ac_sub) - v35_secdforest.lo(j,ac_sub))*s35_hvarea_secdforest*m_timestep_length_forestry; + v35_hvarea_primforest.fx(j) = (vm_land.l(j,"primforest") - vm_land.lo(j,"primforest"))*s35_hvarea_primforest*m_timestep_length_forestry; + v35_hvarea_other.fx(j,othertype35,ac_sub) = (vm_land_other.l(j,othertype35,ac_sub) - vm_land_other.lo(j,othertype35,ac_sub))*s35_hvarea_other*m_timestep_length_forestry; +); + +* Update biodiversity value +vm_bv.l(j,"primforest",potnatveg) = + pcm_land(j,"primforest") * fm_bii_coeff("primary",potnatveg) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"secdforest",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), pc35_secdforest(j,ac)) * + fm_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); + +vm_bv.l(j,"other",potnatveg) = + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), sum(othertype35, pc35_land_other(j,othertype35,ac))) * + fm_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j,potnatveg); diff --git a/modules/35_natveg/pot_forest_may24/realization.gms b/modules/35_natveg/pot_forest_may24/realization.gms new file mode 100644 index 0000000000..00fe2788bc --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/realization.gms @@ -0,0 +1,48 @@ +*** | (C) 2008-2025 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 the pot_forest_may24 realization, land and carbon stock dynamics +*' of natural vegetation are modeled endogenously. +*' The initial spatial distribution of the sub-land-types primary forest, +*' secondary forest and other natural land is based on the +*' LUH2 data set [@hurtt2018luh2]. +*' Forest establishment is constrained by the potential forest area, which is defined by +*' areas with a potential carbon density of >20 tC/ha. The remaining forest establishment +*' area in the current time step is provided to the [32_forestry] module via the +*' interface parameter `pm_max_forest_est`. +*' This realization also includes national policies implemented (NPI) and nationally +*' determined contributions to the Paris agreement (NDC) with regard to forest and other +*' land protection. The NPI/NDC polices ramp up until 2030 and are assumed constant +*' thereafter. NPI/NDC land conservation polices are applied on forest and other land, +*' depending on individual country reports. The NPI/NDC policies are treated as minimum +*' constraints and therefore are non-additive, if the land protection targets as provided by +*' the module `22_land_conservation` and the interface `pm_land_conservation` are larger. +*' Additionally, this module includes forest damage and provides the ability to +*' harvest natural vegetation for timber. Both wood and woodfuel can be produceed +*' from primary and secondary forest but other land is only allowed to be harvested +*' for woodfuel. +*' @stop + +*' +*' @limitations Initialization of both primary and secondary forest in highest +*' age class or equal distrivution of such areas in all age classes. Data exists +*' on a more emperically obtained distribution in different age classes based +*' on satellite data but this results is highly negative land-use change emissions. +*' Inclusion of this data in MAgPIE remains work in progess and is not available for release yet. +*' Additionally, in this module realization, harvested secondary forest stays +*' secondary forest and harvested primary forest is reclassified as secondary forest. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/35_natveg/pot_forest_may24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/35_natveg/pot_forest_may24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/35_natveg/pot_forest_may24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/35_natveg/pot_forest_may24/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/35_natveg/pot_forest_may24/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/35_natveg/pot_forest_may24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/35_natveg/pot_forest_may24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/35_natveg/pot_forest_may24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/35_natveg/pot_forest_may24/scaling.gms b/modules/35_natveg/pot_forest_may24/scaling.gms new file mode 100644 index 0000000000..3e034dc437 --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_cost_hvarea_natveg.scale(i)$(s35_hvarea = 1 OR s35_hvarea = 2) = 10e4; diff --git a/modules/35_natveg/pot_forest_may24/sets.gms b/modules/35_natveg/pot_forest_may24/sets.gms new file mode 100644 index 0000000000..ad7b29f0f1 --- /dev/null +++ b/modules/35_natveg/pot_forest_may24/sets.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2025 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 + + driver_source Source of deforestation drivers + / overall, deforestation, shifting_agriculture, + forestry, wildfire, urbanization / + + combined_loss(driver_source) Combined loss from fire plus agriculture + / shifting_agriculture,wildfire / + + pol35 Land protection policy + / none, npi, ndc / + + pol_stock35 Land types for land protection policies + / forest, other / + + othertype35 Other land types + / othernat, youngsecdf / + + shock_scen Scenario name of forest carbon shock + / none, 002lin2030,004lin2030,008lin2030,016lin2030 + / + +; diff --git a/modules/35_natveg/static/declarations.gms b/modules/35_natveg/static/declarations.gms deleted file mode 100644 index cd4b48bbf8..0000000000 --- a/modules/35_natveg/static/declarations.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - -positive variables - v35_secdforest(j,land35) Secdforest (mio. ha) - v35_other(j,land35) Other land (mio. ha) - vm_landdiff_natveg Aggregated difference in other land compared to previous timestep (mio. ha) -; - - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov35_secdforest(t,j,land35,type) Secdforest (mio. ha) - ov35_other(t,j,land35,type) Other land (mio. ha) - ov_landdiff_natveg(t,type) Aggregated difference in other land compared to previous timestep (mio. ha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - diff --git a/modules/35_natveg/static/not_used.txt b/modules/35_natveg/static/not_used.txt deleted file mode 100644 index f9d405434d..0000000000 --- a/modules/35_natveg/static/not_used.txt +++ /dev/null @@ -1,10 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason -pcm_carbon_stock, input,not used -pm_carbon_density_ac, input,not used -pm_land_start, input,not used diff --git a/modules/35_natveg/static/postsolve.gms b/modules/35_natveg/static/postsolve.gms deleted file mode 100644 index 5827ed48dd..0000000000 --- a/modules/35_natveg/static/postsolve.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov35_secdforest(t,j,land35,"marginal") = v35_secdforest.m(j,land35); - ov35_other(t,j,land35,"marginal") = v35_other.m(j,land35); - ov_landdiff_natveg(t,"marginal") = vm_landdiff_natveg.m; - ov35_secdforest(t,j,land35,"level") = v35_secdforest.l(j,land35); - ov35_other(t,j,land35,"level") = v35_other.l(j,land35); - ov_landdiff_natveg(t,"level") = vm_landdiff_natveg.l; - ov35_secdforest(t,j,land35,"upper") = v35_secdforest.up(j,land35); - ov35_other(t,j,land35,"upper") = v35_other.up(j,land35); - ov_landdiff_natveg(t,"upper") = vm_landdiff_natveg.up; - ov35_secdforest(t,j,land35,"lower") = v35_secdforest.lo(j,land35); - ov35_other(t,j,land35,"lower") = v35_other.lo(j,land35); - ov_landdiff_natveg(t,"lower") = vm_landdiff_natveg.lo; -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/35_natveg/static/preloop.gms b/modules/35_natveg/static/preloop.gms deleted file mode 100644 index bc5eba3b70..0000000000 --- a/modules/35_natveg/static/preloop.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 - -*fix primforest -vm_land.fx(j,"primforest") = pcm_land(j,"primforest"); - -*fix secdforest -v35_secdforest.fx(j,"new") = 0; -v35_secdforest.fx(j,"grow") = 0; -v35_secdforest.fx(j,"old") = pcm_land(j,"secdforest"); -vm_land.fx(j,"secdforest") = sum(land35, v35_secdforest.l(j,land35)); - -*fix other land -v35_other.fx(j,"new") = 0; -v35_other.fx(j,"grow") = 0; -v35_other.fx(j,"old") = pcm_land(j,"other"); -vm_land.fx(j,"other") = sum(land35, v35_other.l(j,land35)); - -vm_landdiff_natveg.fx = 0; - diff --git a/modules/35_natveg/static/presolve.gms b/modules/35_natveg/static/presolve.gms deleted file mode 100644 index 77ebb45766..0000000000 --- a/modules/35_natveg/static/presolve.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @code -*' Carbon stocks for primary forest, secondary forest or other natural land are calculated -*' as the product of respective area and carbon density. -*' -vm_carbon_stock.fx(j,"primforest",c_pools) = - vm_land.l(j,"primforest")*fm_carbon_density(t,j,"primforest",c_pools); -*' -vm_carbon_stock.fx(j,"secdforest",c_pools) = - vm_land.l(j,"secdforest")*fm_carbon_density(t,j,"secdforest",c_pools); -*' -vm_carbon_stock.fx(j,"other",c_pools) = - vm_land.l(j,"other")*fm_carbon_density(t,j,"other",c_pools); -*' @stop diff --git a/modules/35_natveg/static/realization.gms b/modules/35_natveg/static/realization.gms deleted file mode 100644 index c085bbe55c..0000000000 --- a/modules/35_natveg/static/realization.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 the static realization natural vegetation is constant over time -*' with the spatial distribution of 1995 from the LUH2 data set [@hurtt_harmonization_inprep]. -*' Due to static land patterns also carbon stocks are static over time. - -*' @limitations Land and carbon stocks of natural vegetation are static over time. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/35_natveg/static/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/35_natveg/static/declarations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/35_natveg/static/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/35_natveg/static/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/35_natveg/static/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/35_natveg/static/sets.gms b/modules/35_natveg/static/sets.gms deleted file mode 100644 index 9460369c94..0000000000 --- a/modules/35_natveg/static/sets.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - land35 Natveg land pools - / new, grow, old/ -; diff --git a/modules/36_employment/exo_may22/declarations.gms b/modules/36_employment/exo_may22/declarations.gms new file mode 100644 index 0000000000..1abd331d92 --- /dev/null +++ b/modules/36_employment/exo_may22/declarations.gms @@ -0,0 +1,37 @@ +*** | (C) 2008-2025 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 + q36_employment(i) Regional employment in agricultural production (mio. people) + q36_employment_maccs(i) Additional regional employment for GHG mitigation in agriculture (mio. people) +; + +positive variables + v36_employment(i) Number of people employed in agricultural production (mio. people) + v36_employment_maccs(i) Number of people employed in GHG mitigation in agriculture (mio. people) +; + +parameters + p36_hourly_costs_iso(t_all,iso, wage_scen) Hourly labor costs in agriculture on iso level before and after including wage scenario (USD17MER per hour) + p36_hourly_costs_increase(iso) Difference between minimum hourly labor costs and actual hourly labor costs in 2050 (USD17MER per hour) + pm_hourly_costs(t,i, wage_scen) Hourly labor costs in agriculture on regional level before and after including wage scenario (USD17MER per hour) + pm_productivity_gain_from_wages(t,i) Multiplicative factor describing productivity gain related to higher wages (1) + p36_total_hours_worked(iso) Total hours worked by all employed people (mio. hours per year) + p36_calibration_hourly_costs(iso) Additive calibration term for hourly labor costs (USD17MER per hour) + p36_nonmagpie_labor_costs(t,i) Labor costs from subsidies and Value of Production not covered by MAgPIE (mio. USD17MER) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov36_employment(t,i,type) Number of people employed in agricultural production (mio. people) + ov36_employment_maccs(t,i,type) Number of people employed in GHG mitigation in agriculture (mio. people) + oq36_employment(t,i,type) Regional employment in agricultural production (mio. people) + oq36_employment_maccs(t,i,type) Additional regional employment for GHG mitigation in agriculture (mio. people) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/36_employment/exo_may22/equations.gms b/modules/36_employment/exo_may22/equations.gms new file mode 100644 index 0000000000..d68742e51d --- /dev/null +++ b/modules/36_employment/exo_may22/equations.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2025 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 + +*' Employment is calculated as total labor costs divided by hourly labor costs and average +*' hours worked per employed person per year. Employment for crop and livestock production +*' and employment for mitigation of GHG emissions are calclated in separate equaations. +*' For the former, total labor costs include labor costs from crop production +*' (see [38_factor_costs]), livestock production (see [70_livestock]), and some labor costs +*' for crop and livestock production which are not covered by MAgPIE. For employment from +*' mitigation of GHG emissions labor costs come from the marginal abatement cost curves (MACCs) +*' (see [57_maccs]). + +* excluding labor costs for crop residues (as this is not include in the +* data on agricultural employment by the International Labour Organization) +* and fish (as we cannot calibrate labor costs for fish to employment data) +q36_employment(i2) .. v36_employment(i2) + =e= (vm_cost_prod_crop(i2,"labor") + vm_cost_prod_livst(i2,"labor") + sum(ct,p36_nonmagpie_labor_costs(ct,i2))) * + (1 / sum(ct,f36_weekly_hours(ct,i2)*s36_weeks_in_year*pm_hourly_costs(ct,i2,"scenario"))); + +q36_employment_maccs(i2) .. v36_employment_maccs(i2) + =e= (vm_maccs_costs(i2,"labor")) * (1 / sum(ct,f36_weekly_hours(ct,i2)*s36_weeks_in_year*pm_hourly_costs(ct,i2,"scenario"))); diff --git a/modules/36_employment/exo_may22/input.gms b/modules/36_employment/exo_may22/input.gms new file mode 100644 index 0000000000..f984a55008 --- /dev/null +++ b/modules/36_employment/exo_may22/input.gms @@ -0,0 +1,56 @@ +*** | (C) 2008-2025 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 +s36_weeks_in_year number of weeks in a year (weeks per yr) / 52.1429 / +s36_minimum_wage global minimum wage (USD17MER per hour) / 0 / +s36_scale_productivity_with_wage how strong the wage increase should affect labor productivity (1) / 0 / +; + +table f36_weekly_hours(t_all,i) Historical values of average weekly hours worked per person in agriculture (h per week) +$ondelim +$include "./modules/36_employment/exo_may22/input/f36_weekly_hours.csv" +$offdelim +; + +table f36_weekly_hours_iso(t_all,iso) Historical values of average weekly hours worked per person in agriculture on iso level (h per week) +$ondelim +$include "./modules/36_employment/exo_may22/input/f36_weekly_hours_iso.csv" +$offdelim +; + +table f36_hist_hourly_costs(t_all,iso) Historical values of hourly labor costs in agriculture (USD17MER per h) +$ondelim +$include "./modules/36_employment/exo_may22/input/f36_historic_hourly_labor_costs.csv" +$offdelim +; + +parameter f36_regr_hourly_costs(reg36) Parameters for regression of hourly labor costs with GDPpcMER +/ +$ondelim +$include "./modules/36_employment/exo_may22/input/f36_regression_hourly_labor_costs.csv" +$offdelim +/ +; + +table f36_historic_ag_empl(t_all,iso) Historical values of people employed in agruculture (mio. people) +$ondelim +$include "./modules/36_employment/exo_may22/input/f36_historic_ag_employment.csv" +$offdelim +; + +table f36_unspecified_subsidies(t_all,i) Factor cost share of unspecified subsidies not included in MAgPIE labor costs (mio. USD17MER) +$ondelim +$include "./modules/36_employment/exo_may22/input/f36_unspecified_subsidies.csv" +$offdelim +; + +table f36_nonmagpie_factor_costs(t_all,i) Factor cost share of VoP from ag commodities not mapped to MAgPIE (mio. USD17MER) +$ondelim +$include "./modules/36_employment/exo_may22/input/f36_nonmagpie_factor_costs.csv" +$offdelim +; diff --git a/modules/36_employment/exo_may22/input/files b/modules/36_employment/exo_may22/input/files new file mode 100644 index 0000000000..adbd3d2b95 --- /dev/null +++ b/modules/36_employment/exo_may22/input/files @@ -0,0 +1,8 @@ +* list of files that are required here +f36_weekly_hours.csv +f36_weekly_hours_iso.csv +f36_historic_hourly_labor_costs.csv +f36_regression_hourly_labor_costs.csv +f36_historic_ag_employment.csv +f36_unspecified_subsidies.csv +f36_nonmagpie_factor_costs.csv diff --git a/modules/36_employment/exo_may22/postsolve.gms b/modules/36_employment/exo_may22/postsolve.gms new file mode 100644 index 0000000000..95e8ac37d7 --- /dev/null +++ b/modules/36_employment/exo_may22/postsolve.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov36_employment(t,i,"marginal") = v36_employment.m(i); + ov36_employment_maccs(t,i,"marginal") = v36_employment_maccs.m(i); + oq36_employment(t,i,"marginal") = q36_employment.m(i); + oq36_employment_maccs(t,i,"marginal") = q36_employment_maccs.m(i); + ov36_employment(t,i,"level") = v36_employment.l(i); + ov36_employment_maccs(t,i,"level") = v36_employment_maccs.l(i); + oq36_employment(t,i,"level") = q36_employment.l(i); + oq36_employment_maccs(t,i,"level") = q36_employment_maccs.l(i); + ov36_employment(t,i,"upper") = v36_employment.up(i); + ov36_employment_maccs(t,i,"upper") = v36_employment_maccs.up(i); + oq36_employment(t,i,"upper") = q36_employment.up(i); + oq36_employment_maccs(t,i,"upper") = q36_employment_maccs.up(i); + ov36_employment(t,i,"lower") = v36_employment.lo(i); + ov36_employment_maccs(t,i,"lower") = v36_employment_maccs.lo(i); + oq36_employment(t,i,"lower") = q36_employment.lo(i); + oq36_employment_maccs(t,i,"lower") = q36_employment_maccs.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/36_employment/exo_may22/preloop.gms b/modules/36_employment/exo_may22/preloop.gms new file mode 100644 index 0000000000..e66d669409 --- /dev/null +++ b/modules/36_employment/exo_may22/preloop.gms @@ -0,0 +1,65 @@ +*** | (C) 2008-2025 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 + +* get calibration factors and aggregation weight +p36_calibration_hourly_costs(iso) = sum(t_past$(ord(t_past) eq card(t_past)), log(f36_hist_hourly_costs(t_past,iso)) - (log(im_gdp_pc_mer_iso(t_past,iso)) + *f36_regr_hourly_costs("slope") + f36_regr_hourly_costs("intercept"))); +p36_total_hours_worked(iso) = sum(t_past$(ord(t_past) eq card(t_past)), f36_historic_ag_empl(t_past,iso)*f36_weekly_hours_iso(t_past,iso)*s36_weeks_in_year); + +*' @code + +*' Hourly labor costs are projected into the future by using a log-log regression with +*' GDPpcMER, which is calibrated such that historic values of agricultural employment +*' are met. +p36_hourly_costs_iso(t_all,iso,"baseline") = exp(log(im_gdp_pc_mer_iso(t_all,iso)) * f36_regr_hourly_costs("slope") + + f36_regr_hourly_costs("intercept") + p36_calibration_hourly_costs(iso)); + +*' @stop + +p36_hourly_costs_iso(t_all,iso,"baseline")$(sum(sameas(t_past,t_all),1) = 1) = f36_hist_hourly_costs(t_all,iso); + + +* necessary increase in hourly labor costs in target year (2050) to match minimum wage +p36_hourly_costs_increase(iso) = s36_minimum_wage - p36_hourly_costs_iso("y2050",iso,"baseline"); + +p36_hourly_costs_iso(t_all,iso,"scenario") = p36_hourly_costs_iso(t_all,iso,"baseline"); + +*' @code +*' In case of a scenario with an external global minimum wage we add a linear term to the baseline +*' hourly labor costs, starting from 0 zero in 2020 and increasing such that resulting hourly labor costs will match +*' the minimum wage in 2050. After 2050 the additional term is decreased again, reaching 0 in 2100 (where baseline +*' hourly labor costs and new hourly labor costs will match again). +*' In case this means that hourly labor costs would decrease again below the minimum wage after 2050, we keep them +*' at minimum wage. +*' If baseline hourly labor costs are already high enough to meet the minimum wage in 2050, they are not changed. +*' @stop + +p36_hourly_costs_iso(t_all,iso,"scenario")$((m_year(t_all) gt 2020) and (m_year(t_all) le 2050)) = p36_hourly_costs_iso(t_all,iso,"baseline") + max(0, ((m_year(t_all)-2020)/(2050-2020))*p36_hourly_costs_increase(iso)); + +p36_hourly_costs_iso(t_all,iso,"scenario")$((m_year(t_all) gt 2050) and (m_year(t_all) le 2100)) = max(s36_minimum_wage, p36_hourly_costs_iso(t_all,iso,"baseline") + max(0, p36_hourly_costs_increase(iso)-((m_year(t_all)-2050)/(2100-2050))*p36_hourly_costs_increase(iso))); + +p36_hourly_costs_iso(t_all,iso,"scenario")$(m_year(t_all) gt 2100) = max(s36_minimum_wage, p36_hourly_costs_iso(t_all,iso,"baseline")); + +* Hourly labor costs are then aggregated to regional level using the total hours worked in the last +* year of `t_past` as weight. +pm_hourly_costs(t,i,wage_scen) = sum(i_to_iso(i,iso), p36_hourly_costs_iso(t,iso,wage_scen)*p36_total_hours_worked(iso)) * (1/sum(i_to_iso(i,iso),p36_total_hours_worked(iso))); + +*' @code +*' A scenario that increases wages can either be fully related to productivity increase (leading to lower employment +*' for the same total labor costs), or keep productivity constant (leading to the same employment for higher total labor +*' costs), or show a mixture between productivity increase and total labor cost increase. +*' The scalar `s36_scale_productivity_with_wage` describes how high the labor productivity gain should be relative to +*' the increase in hourly labor costs and is used to calculate `pm_productivity_gain_from_wages`, which is applied to +*' labor costs for crop production ([38_factor_costs]), livestock production ([70_livestock]), mitigation costs +*' ([57_maccs]) and the non-MAgPIE labor costs. If `s36_scale_productivity_with_wage = 1` the productivity gain and +*' wage increase cancel out, leading to the same total labor costs as without wage scenario. +*' For `s36_scale_productivity_with_wage = 0` the total labor costs scale proportional to the hourly labor costs. For +*' other values, the total labor costs show a non-linear realtionship with `s36_scale_productivity_with_wage`. + +pm_productivity_gain_from_wages(t,i) = s36_scale_productivity_with_wage * (pm_hourly_costs(t,i,"scenario") / pm_hourly_costs(t,i,"baseline")) + (1 - s36_scale_productivity_with_wage); + +*' @stop diff --git a/modules/36_employment/exo_may22/presolve.gms b/modules/36_employment/exo_may22/presolve.gms new file mode 100644 index 0000000000..f9b1445f1b --- /dev/null +++ b/modules/36_employment/exo_may22/presolve.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2025 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 + + +*' @code + +*' Non-MAgPIE labor costs consist of the labor cost share of subsidies and from livestock +*' categories not covered by MAgPIE (i.e. wool, beeswax, honey, silk-worms), which +*' are both kept constant for future years. + +p36_nonmagpie_labor_costs(t,i) = (f36_unspecified_subsidies(t,i) + f36_nonmagpie_factor_costs(t,i)) * + (pm_factor_cost_shares(t,i,"labor")) * (1/pm_productivity_gain_from_wages(t,i)) * + (pm_hourly_costs(t,i,"scenario") / pm_hourly_costs(t,i,"baseline")); + +*' @stop diff --git a/modules/36_employment/exo_may22/realization.gms b/modules/36_employment/exo_may22/realization.gms new file mode 100644 index 0000000000..3c304df343 --- /dev/null +++ b/modules/36_employment/exo_may22/realization.gms @@ -0,0 +1,36 @@ +*** | (C) 2008-2025 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 This realization calculates agricultural employment based +*' on it's relation to total labor costs. It therefore depends +*' on the labor costs calculated in the modules [38_factor_costs], [57_maccs] and +*' [70_livestock]. Resulting total costs and production patterns can be affected +*' if an external wage scenario is used, which increases labor costs for +*' crop and livestock production in [38_factor_costs] and [70_livestock], and +*' for mitigation in [57_maccs]. + +*' @limitations Labor availability is not seen as a limiting factor for +*' agricultural production, as the number of people employed is directly linked +*' to labor costs which scale with the amount of production. Furthermore, +*' hourly labor costs are projected into the future based on a regression with +*' GDP pc, while factor requirements for crops (i.e. labor + capital costs per +*' production unit) are kept constant. This means, that the increase in the +*' baseline wages over time is assumed to be matched by a corresponding increase +*' in labor productivity. For external wage scenarios that lead to higher wages +*' the additional wage increase can be either related to productivity increase +*' or higher total labor costs. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/36_employment/exo_may22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/36_employment/exo_may22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/36_employment/exo_may22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/36_employment/exo_may22/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/36_employment/exo_may22/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/36_employment/exo_may22/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/36_employment/exo_may22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/36_employment/exo_may22/sets.gms b/modules/36_employment/exo_may22/sets.gms new file mode 100644 index 0000000000..9888d312f8 --- /dev/null +++ b/modules/36_employment/exo_may22/sets.gms @@ -0,0 +1,13 @@ +*** | (C) 2008-2025 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 + reg36 regression coefficients + / slope, intercept / + wage_scen version of wages + / baseline, scenario / +; diff --git a/modules/36_employment/module.gms b/modules/36_employment/module.gms new file mode 100644 index 0000000000..b7c02f20d2 --- /dev/null +++ b/modules/36_employment/module.gms @@ -0,0 +1,24 @@ +*** | (C) 2008-2025 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 + + +*' @title Employment + +*' @description This module is used to calculate hourly labor costs in agriculutre +*' and the number of people employed in crop and livestock production. +*' Hourly labor costs are calculated based on a regression with GDP pc from [09_drivers]. +*' They can be increased by an externally set global minimum wage. Wages as well as +*' productivity gain from higher wages are provided to [38_factor_costs], [70_livestock], +*' and [57_maccs] to scale total labor costs accordingly. +*' The calculation of employment then uses labor costs for crop and livestock production +*' and mitigation coming from [38_factor_costs], [70_livestock], and [57_maccs]. + +*' @authors Debbora Leip + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%employment%" == "exo_may22" $include "./modules/36_employment/exo_may22/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/37_labor_prod/exo/declarations.gms b/modules/37_labor_prod/exo/declarations.gms new file mode 100644 index 0000000000..466428dea7 --- /dev/null +++ b/modules/37_labor_prod/exo/declarations.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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 + pm_labor_prod(t,j) labor productivity factor (1) +; diff --git a/modules/37_labor_prod/exo/input.gms b/modules/37_labor_prod/exo/input.gms new file mode 100644 index 0000000000..4f5f6c2be4 --- /dev/null +++ b/modules/37_labor_prod/exo/input.gms @@ -0,0 +1,26 @@ +*** | (C) 2008-2025 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 + +$setglobal c37_labor_prod_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + +$setglobal c37_labor_rcp rcp119 +$setglobal c37_labor_metric ISO +$setglobal c37_labor_intensity 400W +$setglobal c37_labor_uncertainty ensmean + +table f37_labor_prod(t_all,j,rcp37,metric37,intensity37,uncertainty37) labor productivity factor (1) +$ondelim +$include "./modules/37_labor_prod/exo/input/f37_labourprodimpact.cs3" +$offdelim +; +m_fillmissingyears(f37_labor_prod,"j,rcp37,metric37,intensity37,uncertainty37"); +* set values in different data sets between 1995 and the year set by sm_fix_cc to values from the default setting. +f37_labor_prod(t_all,j,rcp37,metric37,intensity37,uncertainty37)$(m_year(t_all) <= sm_fix_cc) = +f37_labor_prod(t_all,j,"rcp119","ISO","400W","ensmean")$(m_year(t_all) <= sm_fix_cc); diff --git a/modules/37_labor_prod/exo/input/files b/modules/37_labor_prod/exo/input/files new file mode 100644 index 0000000000..941fcdc747 --- /dev/null +++ b/modules/37_labor_prod/exo/input/files @@ -0,0 +1,2 @@ +* list of files that are required here +f37_labourprodimpact.cs3 diff --git a/modules/37_labor_prod/exo/preloop.gms b/modules/37_labor_prod/exo/preloop.gms new file mode 100644 index 0000000000..e6a9981407 --- /dev/null +++ b/modules/37_labor_prod/exo/preloop.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +pm_labor_prod(t,j) = f37_labor_prod(t,j,"%c37_labor_rcp%","%c37_labor_metric%","%c37_labor_intensity%","%c37_labor_uncertainty%"); +* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used +$if "%c37_labor_prod_scenario%" == "nocc" pm_labor_prod(t,j) = pm_labor_prod("y1995",j); +$if "%c37_labor_prod_scenario%" == "nocc_hist" pm_labor_prod(t,j)$(m_year(t_all) > sm_fix_cc) = pm_labor_prod(t,j)$(m_year(t_all) = sm_fix_cc); diff --git a/modules/37_labor_prod/exo/realization.gms b/modules/37_labor_prod/exo/realization.gms new file mode 100644 index 0000000000..1eff53c9fb --- /dev/null +++ b/modules/37_labor_prod/exo/realization.gms @@ -0,0 +1,37 @@ +*** | (C) 2008-2025 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 This realization accounts for climate change impacts on +*' labor productivity, based on ESM experiments from the LAMACLIMA project +*' . +*' Heat‐induced impacts on labor productivity have been calculated using the +*' methodology described in @orlov_labor_2021. +*' Heat-induced impacts on labor productivity are available for two different metrics +*' (HOTHAPS and ISO) and work intensity levels (300W and 400W). +*' The Hothaps function describes the relationship between workability and the +*' wet bulb globe temperature (WBGT). +*' WBGT is a heat index that measures heat stress impacts of +*' temperature, humidity, wind speed, and solar radiation. +*' The ISO standards describe the frequency and duration of rest breaks at work +*' under different levels of heat stress. +*' Work intensity: 300W and 400W stand for the level of work intensity measured in +*' Watts (W), at which the impacts are estimated. The higher work intensity, +*' the stronger is the heat exposure. For instance, the impacts of heatstress +*' on labor productivity under 300W are less than under 400W. +*' In previous studies, the level of work intensity in agriculture is assumed to be 400W. +*' However, work intensity differs by region due to different levels of mechanization. +*' While 400W is plausible for manual work, mechanized work is less labor intensity. +*' +*' @limitations Climate change impacts on labor productivity are currently only +*' available for RCP1.9 and RCP8.5. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/37_labor_prod/exo/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/37_labor_prod/exo/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/37_labor_prod/exo/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/37_labor_prod/exo/preloop.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/37_labor_prod/exo/sets.gms b/modules/37_labor_prod/exo/sets.gms new file mode 100644 index 0000000000..b40b9dbb28 --- /dev/null +++ b/modules/37_labor_prod/exo/sets.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + rcp37 climate change impact scenarios + / rcp119, rcp585 / + + metric37 labor productivity impact metric + / ISO, HOTHAPS / + + intensity37 work intensity level + / 300W, 400W / + + uncertainty37 ESM uncertainty + / enslower,ensmean,ensupper / +; diff --git a/modules/37_labor_prod/module.gms b/modules/37_labor_prod/module.gms new file mode 100644 index 0000000000..8275eb2e22 --- /dev/null +++ b/modules/37_labor_prod/module.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + + +*' @title Labor Productivity + +*' @description This module provides a labor productivity factor, +*' which reflects the efficiency of labor under changing environmental conditions (1 = no change). + +*' @authors Florian Humpenöder, Michael Windisch + + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%labor_prod%" == "exo" $include "./modules/37_labor_prod/exo/realization.gms" +$Ifi "%labor_prod%" == "off" $include "./modules/37_labor_prod/off/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/37_labor_prod/off/declarations.gms b/modules/37_labor_prod/off/declarations.gms new file mode 100644 index 0000000000..466428dea7 --- /dev/null +++ b/modules/37_labor_prod/off/declarations.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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 + pm_labor_prod(t,j) labor productivity factor (1) +; diff --git a/modules/37_labor_prod/off/not_used.txt b/modules/37_labor_prod/off/not_used.txt new file mode 100644 index 0000000000..4e00cebf8c --- /dev/null +++ b/modules/37_labor_prod/off/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_cc,input,questionnaire diff --git a/modules/37_labor_prod/off/preloop.gms b/modules/37_labor_prod/off/preloop.gms new file mode 100644 index 0000000000..3576edf55d --- /dev/null +++ b/modules/37_labor_prod/off/preloop.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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 + +pm_labor_prod(t,j) = 1; diff --git a/modules/37_labor_prod/off/realization.gms b/modules/37_labor_prod/off/realization.gms new file mode 100644 index 0000000000..49f0f8981f --- /dev/null +++ b/modules/37_labor_prod/off/realization.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2025 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 labor productivity is fixed to a value of 1, +*' which implies no change over time. +*' +*' @limitations The impacts of changing environmental conditions on labor productivity +*' are not accounted for. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/37_labor_prod/off/declarations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/37_labor_prod/off/preloop.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/38_factor_costs/fixed_per_ton_mar18/declarations.gms b/modules/38_factor_costs/fixed_per_ton_mar18/declarations.gms deleted file mode 100644 index 9244a819a2..0000000000 --- a/modules/38_factor_costs/fixed_per_ton_mar18/declarations.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2019 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 - q38_cost_prod_crop(i,kcr) Regional factor input costs for plant production (mio. USD05MER per yr) -; - -positive variables - vm_cost_prod(i,kall) Factor costs (mio. USD05MER per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_prod(t,i,kall,type) Factor costs (mio. USD05MER per yr) - oq38_cost_prod_crop(t,i,kcr,type) Regional factor input costs for plant production (mio. USD05MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/38_factor_costs/fixed_per_ton_mar18/equations.gms b/modules/38_factor_costs/fixed_per_ton_mar18/equations.gms deleted file mode 100644 index cabf6a6706..0000000000 --- a/modules/38_factor_costs/fixed_per_ton_mar18/equations.gms +++ /dev/null @@ -1,25 +0,0 @@ -*** | (C) 2008-2019 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 - - - q38_cost_prod_crop(i2,kcr) .. - vm_cost_prod(i2,kcr) =e= vm_prod_reg(i2,kcr) * f38_fac_req_per_ton(kcr); - - -*' The factor requirement costs `vm_cost_prod` are calculated as product of -*' production quantity `vm_prod_reg` and crop-specific world average -*' factor costs of production per volume `f38_fac_req_per_ton`. -*' The volume depending factor costs, which remains fixed overtime, are obtained -*' from value-added costs which correspond to the factor of production included -*' in this module from GTAP7 (@narayanan_gtap7_2008). -*' It worth to mention again that the factor costs in this module -*' do not include land rents (as MAgPIE calculates land rents endogenously), -*' chemical fertilizer costs (as they are calculated in [50_nr_soil_budget] -*' module), and costs of agricultural intermediate inputs such as seeds -*' (to avoid double counting in the model). diff --git a/modules/38_factor_costs/fixed_per_ton_mar18/input.gms b/modules/38_factor_costs/fixed_per_ton_mar18/input.gms deleted file mode 100644 index ace6af205a..0000000000 --- a/modules/38_factor_costs/fixed_per_ton_mar18/input.gms +++ /dev/null @@ -1,15 +0,0 @@ -*** | (C) 2008-2019 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 - - - -parameter f38_fac_req_per_ton(kcr) Factor requirement costs (USD05MER per tDM) -/ -$ondelim -$include "./modules/38_factor_costs/input/f38_fac_req_per_ton.csv" -$offdelim -/; diff --git a/modules/38_factor_costs/fixed_per_ton_mar18/not_used.txt b/modules/38_factor_costs/fixed_per_ton_mar18/not_used.txt deleted file mode 100644 index a931fa68ba..0000000000 --- a/modules/38_factor_costs/fixed_per_ton_mar18/not_used.txt +++ /dev/null @@ -1,11 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason -vm_tau,input,questionnaire -fm_tau1995,input,questionnaire -vm_area,input,questionnaire diff --git a/modules/38_factor_costs/fixed_per_ton_mar18/postsolve.gms b/modules/38_factor_costs/fixed_per_ton_mar18/postsolve.gms deleted file mode 100644 index f371f89553..0000000000 --- a/modules/38_factor_costs/fixed_per_ton_mar18/postsolve.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_prod(t,i,kall,"marginal") = vm_cost_prod.m(i,kall); - oq38_cost_prod_crop(t,i,kcr,"marginal") = q38_cost_prod_crop.m(i,kcr); - ov_cost_prod(t,i,kall,"level") = vm_cost_prod.l(i,kall); - oq38_cost_prod_crop(t,i,kcr,"level") = q38_cost_prod_crop.l(i,kcr); - ov_cost_prod(t,i,kall,"upper") = vm_cost_prod.up(i,kall); - oq38_cost_prod_crop(t,i,kcr,"upper") = q38_cost_prod_crop.up(i,kcr); - ov_cost_prod(t,i,kall,"lower") = vm_cost_prod.lo(i,kall); - oq38_cost_prod_crop(t,i,kcr,"lower") = q38_cost_prod_crop.lo(i,kcr); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/38_factor_costs/fixed_per_ton_mar18/realization.gms b/modules/38_factor_costs/fixed_per_ton_mar18/realization.gms deleted file mode 100644 index e8ca629b32..0000000000 --- a/modules/38_factor_costs/fixed_per_ton_mar18/realization.gms +++ /dev/null @@ -1,26 +0,0 @@ -*** | (C) 2008-2019 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 This realization relates factor costs to volume of production of -*' a given crop. The latter [17_production] depends on area harvested -*' from [30_crop] and yields from [14_yields]. In other words, in this -*' implementation, factor costs entirely depend on the volume of production. -*' As such, there are no incentives to allocate and concentrate production -*' into more productive cells. - -*' @limitations This realization assumes that factor costs, within a region, -*' purely depend on the production and are independent of the area under cultivation. -*' By implication, cases in which the harvested area could significantly influence -*' factors costs are hardly accounted in this realization. - - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/38_factor_costs/fixed_per_ton_mar18/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/38_factor_costs/fixed_per_ton_mar18/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/38_factor_costs/fixed_per_ton_mar18/equations.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/38_factor_costs/fixed_per_ton_mar18/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/38_factor_costs/input/files b/modules/38_factor_costs/input/files index 4524fe4de5..fda8548a95 100644 --- a/modules/38_factor_costs/input/files +++ b/modules/38_factor_costs/input/files @@ -1,3 +1,6 @@ * list of files that are required here -f38_fac_req.csv -f38_fac_req_per_ton.csv +f38_historical_share_iso.csv +f38_regression_cap_share.csv +f38_fac_req_fao.csv +f38_fac_req_fao_regional.cs4 +f38_hist_factor_costs_iso.csv diff --git a/modules/38_factor_costs/mixed_feb17/declarations.gms b/modules/38_factor_costs/mixed_feb17/declarations.gms deleted file mode 100644 index 6486eae930..0000000000 --- a/modules/38_factor_costs/mixed_feb17/declarations.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2019 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 - q38_cost_prod_crop(i,kcr) Regional factor input costs for plant production (mio. USD05MER per yr) -; - -positive variables - vm_cost_prod(i,kall) Factor costs (mio. USD05MER per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_prod(t,i,kall,type) Factor costs (mio. USD05MER per yr) - oq38_cost_prod_crop(t,i,kcr,type) Regional factor input costs for plant production (mio. USD05MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/38_factor_costs/mixed_feb17/equations.gms b/modules/38_factor_costs/mixed_feb17/equations.gms deleted file mode 100644 index c0dd806a77..0000000000 --- a/modules/38_factor_costs/mixed_feb17/equations.gms +++ /dev/null @@ -1,34 +0,0 @@ -*** | (C) 2008-2019 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 - - - q38_cost_prod_crop(i2,kcr) .. - vm_cost_prod(i2,kcr) =e= sum((cell(i2,j2), w), vm_area(j2,kcr,w)*f38_region_yield(i2,kcr) - *vm_tau(i2)/fm_tau1995(i2)*f38_fac_req(kcr,w)); - - -*' The equation above shows that factor requirement costs `vm_cost_prod` mainly -*' depend on area harvested `vm_area` and average regional land-use intensity -*' levels `vm_tau`. Multiplying the land-use intensity increase increases -*' since 1995 with average regional yields `f38_region_yield` gives the -*' average regional yield. Multiplied with the area under production it gives -*' the production of this location assuming an average yield. Multiplied with -*' estimated factor requirement costs per volume `f38_fac_req` returns the -*' total factor costs. -*' -*' The crop-and-water specific factor costs per volume of crop production -*' `f38_fac_req` are obtained from @narayanan_gtap7_2008. Splitting factors -*' costs into costs under irrigation and under rainfed production was performed -*' based on the methodology described in @Calzadilla2011GTAP. -*' -*' In this realization, regardless of the cellular productivity, the factor -*' costs per area are identical for all cells within a region. This implicitly -*' gives an incentive to allocate and concentrate production to highly -*' productive cells. diff --git a/modules/38_factor_costs/mixed_feb17/input.gms b/modules/38_factor_costs/mixed_feb17/input.gms deleted file mode 100644 index d25db9cf06..0000000000 --- a/modules/38_factor_costs/mixed_feb17/input.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - - - -table f38_fac_req(kcr,w) Factor requirement costs (USD05MER per tDM) -$ondelim -$include "./modules/38_factor_costs/input/f38_fac_req.csv" -$offdelim; - -table f38_region_yield(i,kcr) Regional crop yields (tDM per ha) -$ondelim -$include "./modules/38_factor_costs/mixed_feb17/input/f38_region_yield.csv" -$offdelim; diff --git a/modules/38_factor_costs/mixed_feb17/input/files b/modules/38_factor_costs/mixed_feb17/input/files deleted file mode 100644 index 5619b98eb9..0000000000 --- a/modules/38_factor_costs/mixed_feb17/input/files +++ /dev/null @@ -1,2 +0,0 @@ -* list of files that are required here -f38_region_yield.csv diff --git a/modules/38_factor_costs/mixed_feb17/not_used.txt b/modules/38_factor_costs/mixed_feb17/not_used.txt deleted file mode 100644 index b65a784550..0000000000 --- a/modules/38_factor_costs/mixed_feb17/not_used.txt +++ /dev/null @@ -1,9 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason -vm_prod_reg,input,questionnaire diff --git a/modules/38_factor_costs/mixed_feb17/postsolve.gms b/modules/38_factor_costs/mixed_feb17/postsolve.gms deleted file mode 100644 index f371f89553..0000000000 --- a/modules/38_factor_costs/mixed_feb17/postsolve.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_prod(t,i,kall,"marginal") = vm_cost_prod.m(i,kall); - oq38_cost_prod_crop(t,i,kcr,"marginal") = q38_cost_prod_crop.m(i,kcr); - ov_cost_prod(t,i,kall,"level") = vm_cost_prod.l(i,kall); - oq38_cost_prod_crop(t,i,kcr,"level") = q38_cost_prod_crop.l(i,kcr); - ov_cost_prod(t,i,kall,"upper") = vm_cost_prod.up(i,kall); - oq38_cost_prod_crop(t,i,kcr,"upper") = q38_cost_prod_crop.up(i,kcr); - ov_cost_prod(t,i,kall,"lower") = vm_cost_prod.lo(i,kall); - oq38_cost_prod_crop(t,i,kcr,"lower") = q38_cost_prod_crop.lo(i,kcr); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/38_factor_costs/mixed_feb17/realization.gms b/modules/38_factor_costs/mixed_feb17/realization.gms deleted file mode 100644 index 3d23055181..0000000000 --- a/modules/38_factor_costs/mixed_feb17/realization.gms +++ /dev/null @@ -1,28 +0,0 @@ -*** | (C) 2008-2019 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 This 'mixed' realization specifies factors costs to depend on -*' area harvested and agricultural land use intensity and corresponding average -*' production volumes. -*' Consequently, factor costs in this realization react on both: area under -*' production and average productivity of a region as captured by the $\tau$ -*' factor. A detailed description of the approach can be found -*' in @dietrich_forecasting_2014 with background information about the used -*' intensity measure in @dietrich_measuring_2012. -*' -*' @limitations This realization assumes that factor costs only depend on area -*' and average productivity of a region. Productivity differences within a -*' region are ignored. Therefore, cases in which the cellular productivity -*' levels affect factors costs are only partially accounted for. - - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/38_factor_costs/mixed_feb17/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/38_factor_costs/mixed_feb17/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/38_factor_costs/mixed_feb17/equations.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/38_factor_costs/mixed_feb17/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/38_factor_costs/module.gms b/modules/38_factor_costs/module.gms index a559dc979c..bd46172f93 100644 --- a/modules/38_factor_costs/module.gms +++ b/modules/38_factor_costs/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -15,10 +15,11 @@ *' Thus, factor costs will contribute to and influence the choice of production *' pattern in the model. -*' @authors Jan Philipp Dietrich, Benjamin Bodirsky, Kristine Karstens +*' @authors Jan Philipp Dietrich, Benjamin Bodirsky, Kristine Karstens, Edna J. Molina Bacca, Debbora Leip *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%factor_costs%" == "fixed_per_ton_mar18" $include "./modules/38_factor_costs/fixed_per_ton_mar18/realization.gms" -$Ifi "%factor_costs%" == "mixed_feb17" $include "./modules/38_factor_costs/mixed_feb17/realization.gms" +$Ifi "%factor_costs%" == "per_ton_fao_may22" $include "./modules/38_factor_costs/per_ton_fao_may22/realization.gms" +$Ifi "%factor_costs%" == "sticky_feb18" $include "./modules/38_factor_costs/sticky_feb18/realization.gms" +$Ifi "%factor_costs%" == "sticky_labor" $include "./modules/38_factor_costs/sticky_labor/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/38_factor_costs/per_ton_fao_may22/declarations.gms b/modules/38_factor_costs/per_ton_fao_may22/declarations.gms new file mode 100644 index 0000000000..e60c6e597f --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/declarations.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2025 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 +q38_cost_prod_crop_labor(i) Regional labor costs for crop production (mio. USD17MER per yr) +q38_cost_prod_crop_capital(i) Regional capital costs for crop production (mio. USD17MER per yr) +; + +positive variables +vm_cost_prod_crop(i,factors) Regional factor costs of capital and labor for crop production (mio. USD17MER per yr) +; + +parameter +p38_capital_cost_shares_iso(t,iso) Capital shares of factor costs on iso level (1) +p38_capital_share_calibration(iso) Summation factor used to calibrate calculated capital shares with historical values (1) +pm_factor_cost_shares(t,i,factors) Capital and labor shares of factor costs on regional level (1) +i38_fac_req(t_all,i,kcr) Factor requirements (USD17MER per tDM) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_prod_crop(t,i,factors,type) Regional factor costs of capital and labor for crop production (mio. USD17MER per yr) + oq38_cost_prod_crop_labor(t,i,type) Regional labor costs for crop production (mio. USD17MER per yr) + oq38_cost_prod_crop_capital(t,i,type) Regional capital costs for crop production (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/38_factor_costs/per_ton_fao_may22/equations.gms b/modules/38_factor_costs/per_ton_fao_may22/equations.gms new file mode 100644 index 0000000000..e067bb5cd9 --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/equations.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2025 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 + + q38_cost_prod_crop_labor(i2) .. + vm_cost_prod_crop(i2,"labor") =e= sum(kcr, vm_prod_reg(i2,kcr) * sum(ct,i38_fac_req(ct,i2,kcr))) * + sum(ct,pm_factor_cost_shares(ct,i2,"labor") * (1/pm_productivity_gain_from_wages(ct,i2)) * + (pm_hourly_costs(ct,i2,"scenario") / pm_hourly_costs(ct,i2,"baseline"))); + + q38_cost_prod_crop_capital(i2) .. + vm_cost_prod_crop(i2,"capital") =e= sum(kcr, vm_prod_reg(i2,kcr) * sum(ct,i38_fac_req(ct,i2,kcr))) * + sum(ct,pm_factor_cost_shares(ct,i2,"capital")); + +*' The factor costs for crops `vm_cost_prod_crop` are calculated as product of +*' production quantity `vm_prod_reg` and crop-specific factor requirements +*' (either global or regional averages) per volume of production `i38_fac_req`. +*' The volume depending factor requirements, which remain fixed overtime, are obtained +*' from FAO Value of Production, to which the USDA factor cost share out of total +*' costs was applied. Labor and capital costs are split by applying the corresponding +*' share out of total factor costs. +*' To account for increased hourly labor costs and producitivity in case of an external +*' wage scenario, the total labor costs are scaled by the corresponding increase in hourly +*' labor costs and the related productivity gain from [36_employment]. +*' +*' It is worth to mention again that the factor costs in this module +*' do not include land rents (as MAgPIE calculates land rents endogenously), +*' chemical fertilizer costs (as they are calculated in [50_nr_soil_budget] +*' module), and costs of agricultural intermediate inputs such as seeds +*' (to avoid double counting in the model). diff --git a/modules/38_factor_costs/per_ton_fao_may22/input.gms b/modules/38_factor_costs/per_ton_fao_may22/input.gms new file mode 100644 index 0000000000..842ffa0a53 --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/input.gms @@ -0,0 +1,46 @@ +*** | (C) 2008-2025 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 + +$setglobal c38_fac_req glo +* spatial disaggregation of factor requirements (options: glo, reg) + +parameter f38_fac_req(kcr) Factor requirement costs in 2005 (USD17MER per tDM) +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_fac_req_fao.csv" +$offdelim +/ +; + +parameter f38_fac_req_fao_reg(t_all,i,kcr) Factor requirement costs (USD17MER per tDM) +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_fac_req_fao_regional.cs4" +$offdelim +/ +; + + +parameter f38_reg_parameters(reg) Parameters for regression +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_regression_cap_share.csv" +$offdelim +/ +; + +table f38_historical_share(t_all,iso) Historical capital share +$ondelim +$include "./modules/38_factor_costs/input/f38_historical_share_iso.csv" +$offdelim +; + +table f38_hist_factor_costs(t_all,iso) Historical factor costs for crop and livestock (mio USD17MER) +$ondelim +$include "./modules/38_factor_costs/input/f38_hist_factor_costs_iso.csv" +$offdelim +; diff --git a/modules/38_factor_costs/per_ton_fao_may22/not_used.txt b/modules/38_factor_costs/per_ton_fao_may22/not_used.txt new file mode 100644 index 0000000000..dcab778dc9 --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/not_used.txt @@ -0,0 +1,4 @@ +name,type,reason +pm_interest,input,questionnaire +vm_prod,input,questionnaire +pm_prod_init,par,questionnaire diff --git a/modules/38_factor_costs/per_ton_fao_may22/postsolve.gms b/modules/38_factor_costs/per_ton_fao_may22/postsolve.gms new file mode 100644 index 0000000000..e84b539118 --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/postsolve.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_prod_crop(t,i,factors,"marginal") = vm_cost_prod_crop.m(i,factors); + oq38_cost_prod_crop_labor(t,i,"marginal") = q38_cost_prod_crop_labor.m(i); + oq38_cost_prod_crop_capital(t,i,"marginal") = q38_cost_prod_crop_capital.m(i); + ov_cost_prod_crop(t,i,factors,"level") = vm_cost_prod_crop.l(i,factors); + oq38_cost_prod_crop_labor(t,i,"level") = q38_cost_prod_crop_labor.l(i); + oq38_cost_prod_crop_capital(t,i,"level") = q38_cost_prod_crop_capital.l(i); + ov_cost_prod_crop(t,i,factors,"upper") = vm_cost_prod_crop.up(i,factors); + oq38_cost_prod_crop_labor(t,i,"upper") = q38_cost_prod_crop_labor.up(i); + oq38_cost_prod_crop_capital(t,i,"upper") = q38_cost_prod_crop_capital.up(i); + ov_cost_prod_crop(t,i,factors,"lower") = vm_cost_prod_crop.lo(i,factors); + oq38_cost_prod_crop_labor(t,i,"lower") = q38_cost_prod_crop_labor.lo(i); + oq38_cost_prod_crop_capital(t,i,"lower") = q38_cost_prod_crop_capital.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/38_factor_costs/per_ton_fao_may22/preloop.gms b/modules/38_factor_costs/per_ton_fao_may22/preloop.gms new file mode 100644 index 0000000000..5a1f6aceef --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/preloop.gms @@ -0,0 +1,21 @@ +*** | (C) 2008-2025 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 + +* calculate capital cost shares from regression +p38_capital_share_calibration(iso) = sum(t_past$(ord(t_past) eq card(t_past)), f38_historical_share(t_past,iso) - (f38_reg_parameters("slope") * + log10(im_gdp_pc_ppp_iso(t_past,iso)) + f38_reg_parameters("intercept"))); + +p38_capital_cost_shares_iso(t,iso) = f38_reg_parameters("slope") * log10(im_gdp_pc_ppp_iso(t,iso)) + + f38_reg_parameters("intercept") + + p38_capital_share_calibration(iso); + +p38_capital_cost_shares_iso(t,iso)$(sum(sameas(t_past,t),1) = 1) = f38_historical_share(t,iso); +* aggregate factor cost shares +pm_factor_cost_shares(t,i,"capital") = sum(t_past$(ord(t_past) eq card(t_past)), + sum(i_to_iso(i,iso), f38_hist_factor_costs(t_past,iso) * p38_capital_cost_shares_iso(t,iso)) / + sum(i_to_iso(i,iso), f38_hist_factor_costs(t_past,iso))); +pm_factor_cost_shares(t,i,"labor") = 1 - pm_factor_cost_shares(t,i,"capital"); diff --git a/modules/38_factor_costs/per_ton_fao_may22/presolve.gms b/modules/38_factor_costs/per_ton_fao_may22/presolve.gms new file mode 100644 index 0000000000..e76ed3a975 --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/presolve.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2025 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 + +if (smax(j, pm_labor_prod(t,j)) <> 1 OR smin(j, pm_labor_prod(t,j)) <> 1, + abort "This factor cost realization cannot handle labor productivities != 1" +); + +* choosing between regional (+time dependent) or global (from 2005) factor requirements +$if "%c38_fac_req%" == "glo" i38_fac_req(t,i,kcr) = f38_fac_req(kcr); +$if "%c38_fac_req%" == "reg" i38_fac_req(t,i,kcr) = f38_fac_req_fao_reg(t,i,kcr); + +if (m_year(t)<=1995, + i38_fac_req(t,i,kcr) = i38_fac_req("y1995",i,kcr); +elseif m_year(t)>=2010, + i38_fac_req(t,i,kcr) = i38_fac_req("y2010",i,kcr); +else + i38_fac_req(t,i,kcr) = i38_fac_req(t,i,kcr); +); diff --git a/modules/38_factor_costs/per_ton_fao_may22/realization.gms b/modules/38_factor_costs/per_ton_fao_may22/realization.gms new file mode 100644 index 0000000000..c50e7bf3cf --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/realization.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2025 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 This realization relates factor costs to volume of production of +*' a given crop. The latter [17_production] depends on area harvested +*' from [30_crop] and yields from [14_yields]. In other words, in this +*' implementation, factor costs entirely depend on the volume of production. +*' As such, there are no incentives to allocate and concentrate production +*' into more productive cells. + +*' @limitations This realization assumes that factor costs, within a region, +*' purely depend on the production and are independent of the area under cultivation. +*' By implication, cases in which the harvested area could significantly influence +*' factors costs are hardly accounted in this realization. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/38_factor_costs/per_ton_fao_may22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/38_factor_costs/per_ton_fao_may22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/38_factor_costs/per_ton_fao_may22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/38_factor_costs/per_ton_fao_may22/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/38_factor_costs/per_ton_fao_may22/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/38_factor_costs/per_ton_fao_may22/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/38_factor_costs/per_ton_fao_may22/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/38_factor_costs/per_ton_fao_may22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/38_factor_costs/per_ton_fao_may22/scaling.gms b/modules/38_factor_costs/per_ton_fao_may22/scaling.gms new file mode 100644 index 0000000000..ebf6842ce9 --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/scaling.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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_cost_prod_crop.scale(i,factors) = 10e5; diff --git a/modules/38_factor_costs/per_ton_fao_may22/sets.gms b/modules/38_factor_costs/per_ton_fao_may22/sets.gms new file mode 100644 index 0000000000..ca2f7bf912 --- /dev/null +++ b/modules/38_factor_costs/per_ton_fao_may22/sets.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 +factors factors included in factor requirements +/ labor, capital / + + reg regression parameters for capital calculation + /slope, intercept/ + ; + +*** EOF sets.gms *** diff --git a/modules/38_factor_costs/sticky_feb18/declarations.gms b/modules/38_factor_costs/sticky_feb18/declarations.gms new file mode 100644 index 0000000000..e3d4d86102 --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/declarations.gms @@ -0,0 +1,47 @@ +*** | (C) 2008-2025 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 + q38_cost_prod_labor(i) Regional labor input costs for crop production (mio USD17MER) + q38_cost_prod_capital(i) Regional capital input costs for crop production (mio USD17MER) + q38_investment_immobile(j,kcr) Cellular immobile investments into farm capital (mio USD17MER) + q38_investment_mobile(j) Cellular mobile investments into farm capital (mio USD17MER) +; + +positive variables + vm_cost_prod_crop(i,factors) Regional factor costs of capital and labor for crop production (mio USD17MER per yr) + v38_investment_immobile(j,kcr) Investment costs in immobile farm capital (mio USD17MER per yr) + v38_investment_mobile(j) Investment costs in mobile farm capital (mio USD17MER per yr) +; + +parameters + p38_labor_need(t,i,kcr) Labor input costs per unit of output (USD17MER per ton DM) + p38_capital_need(t,i,kcr,mobil38) Capital requirements per unit of output (USD17MER per ton DM) + p38_capital_immobile(t,j,kcr) Preexisting immobile capital stocks before investment (mio USD17MER) + p38_capital_mobile(t,j) Preexisting mobile capital stocks before investment (mio USD17MER) + + p38_capital_cost_shares_iso(t,iso) Capital shares of factor costs on iso level (1) + p38_capital_share_calibration(iso) Summation factor used to calibrate calculated capital shares with historical values (1) + pm_factor_cost_shares(t,i,factors) Capital and labor shares of factor costs on regional level (1) + + p38_croparea_start(j,w,kcr) Agricultural land initialization area (mio. ha) + + i38_fac_req(t_all,i,kcr) Factor requirements (USD17MER per tDM) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_prod_crop(t,i,factors,type) Regional factor costs of capital and labor for crop production (mio USD17MER per yr) + ov38_investment_immobile(t,j,kcr,type) Investment costs in immobile farm capital (mio USD17MER per yr) + ov38_investment_mobile(t,j,type) Investment costs in mobile farm capital (mio USD17MER per yr) + oq38_cost_prod_labor(t,i,type) Regional labor input costs for crop production (mio USD17MER) + oq38_cost_prod_capital(t,i,type) Regional capital input costs for crop production (mio USD17MER) + oq38_investment_immobile(t,j,kcr,type) Cellular immobile investments into farm capital (mio USD17MER) + oq38_investment_mobile(t,j,type) Cellular mobile investments into farm capital (mio USD17MER) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/38_factor_costs/sticky_feb18/equations.gms b/modules/38_factor_costs/sticky_feb18/equations.gms new file mode 100644 index 0000000000..1b2cc3bbdb --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/equations.gms @@ -0,0 +1,45 @@ +*** | (C) 2008-2025 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 +*' Labor costs: The labor costs are calculated by multiplying regional aggregated production with labor requirments per output. +*' To account for increased hourly labor costs and producitivity in case of an external +*' wage scenario, the total labor costs are scaled by the corresponding increase in hourly +*' labor costs and the related productivity gain from [36_employment]. + +q38_cost_prod_labor(i2).. vm_cost_prod_crop(i2,"labor") + =e= sum(kcr,vm_prod_reg(i2,kcr) * sum(ct,p38_labor_need(ct,i2,kcr) * (1/pm_productivity_gain_from_wages(ct,i2)) * (pm_hourly_costs(ct,i2,"scenario") / pm_hourly_costs(ct,i2,"baseline")))) + ; + +*' Investment costs: Investment are the summation of investment in mobile and immobile capital. The costs are annuitized, +*' and corrected to make sure that the annual depreciation of the current time-step is accounted for. +q38_cost_prod_capital(i2).. vm_cost_prod_crop(i2,"capital")=e=(sum((cell(i2,j2),kcr),v38_investment_immobile(j2,kcr)) + + sum((cell(i2,j2)),v38_investment_mobile(j2))) + * sum(ct, (pm_interest(ct, i2) + s38_depreciation_rate) / (1+pm_interest(ct,i2))) + ; + + +*' Each cropping activity requires a certain capital stock that depends on the +*' production. The following equations make sure that new land expansion is equipped +*' with capital stock, and that depreciation of pre-existing capital is replaced. +*' Since the mobility of capital is defined over crop-type, immobile capital is set +*' over specific crop types and locations. + +q38_investment_immobile(j2,kcr).. v38_investment_immobile(j2,kcr) + =g= + vm_prod(j2,kcr)*sum(cell(i2,j2),sum(ct,p38_capital_need(ct,i2,kcr,"immobile")))- + sum(ct,p38_capital_immobile(ct,j2,kcr)); +* + +*' On the other hand, the mobile capital is needed by all crop activities in each location, so it is defined over each j2 cell. + +q38_investment_mobile(j2).. v38_investment_mobile(j2) + =g= + sum((cell(i2,j2),kcr),vm_prod(j2,kcr)*sum(ct,p38_capital_need(ct,i2,kcr,"mobile")))- + sum(ct,p38_capital_mobile(ct,j2)); +* diff --git a/modules/38_factor_costs/sticky_feb18/input.gms b/modules/38_factor_costs/sticky_feb18/input.gms new file mode 100644 index 0000000000..e7fe9b716f --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/input.gms @@ -0,0 +1,52 @@ +*** | (C) 2008-2025 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 + +$setglobal c38_fac_req glo +* spatial disaggregation of factor requirements (options: glo, reg) + +scalars +* Depreciation rate assuming roughly 20 years linear depreciation for invesment goods +s38_depreciation_rate depreciation rate (share of costs) / 0.05 / +* Share of immobile capital. +s38_immobile immobile capital (share) / 1 / +; + +parameter f38_fac_req(kcr) Factor requirement costs in 2005 (USD17MER per tDM) +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_fac_req_fao.csv" +$offdelim +/ +; + +parameter f38_fac_req_fao_reg(t_all,i,kcr) Factor requirement costs (USD17MER per tDM) +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_fac_req_fao_regional.cs4" +$offdelim +/ +; + +parameter f38_reg_parameters(reg) Parameters for dynamic regression +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_regression_cap_share.csv" +$offdelim +/ +; + +table f38_historical_share(t_all,iso) Historical capital share +$ondelim +$include "./modules/38_factor_costs/input/f38_historical_share_iso.csv" +$offdelim +; + +table f38_hist_factor_costs(t_all,iso) Historical factor costs for crop and livestock (mio USD17MER) +$ondelim +$include "./modules/38_factor_costs/input/f38_hist_factor_costs_iso.csv" +$offdelim +; diff --git a/modules/38_factor_costs/sticky_feb18/input/files b/modules/38_factor_costs/sticky_feb18/input/files new file mode 100644 index 0000000000..dbebab811f --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/input/files @@ -0,0 +1,6 @@ +* list of files that are required here +f38_region_yield.csv +f38_historical_share_iso.csv +f38_regression_cap_share.csv +f38_fac_req_fao.csv +f38_hist_factor_costs_iso.csv diff --git a/modules/38_factor_costs/sticky_feb18/postsolve.gms b/modules/38_factor_costs/sticky_feb18/postsolve.gms new file mode 100644 index 0000000000..6c472a2414 --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/postsolve.gms @@ -0,0 +1,42 @@ +*** | (C) 2008-2025 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 + +*' Capital update from the last investment +p38_capital_immobile(t+1,j,kcr) = p38_capital_immobile(t,j,kcr) + v38_investment_immobile.l(j,kcr); +p38_capital_mobile(t+1,j) = p38_capital_mobile(t,j) + v38_investment_mobile.l(j); + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_prod_crop(t,i,factors,"marginal") = vm_cost_prod_crop.m(i,factors); + ov38_investment_immobile(t,j,kcr,"marginal") = v38_investment_immobile.m(j,kcr); + ov38_investment_mobile(t,j,"marginal") = v38_investment_mobile.m(j); + oq38_cost_prod_labor(t,i,"marginal") = q38_cost_prod_labor.m(i); + oq38_cost_prod_capital(t,i,"marginal") = q38_cost_prod_capital.m(i); + oq38_investment_immobile(t,j,kcr,"marginal") = q38_investment_immobile.m(j,kcr); + oq38_investment_mobile(t,j,"marginal") = q38_investment_mobile.m(j); + ov_cost_prod_crop(t,i,factors,"level") = vm_cost_prod_crop.l(i,factors); + ov38_investment_immobile(t,j,kcr,"level") = v38_investment_immobile.l(j,kcr); + ov38_investment_mobile(t,j,"level") = v38_investment_mobile.l(j); + oq38_cost_prod_labor(t,i,"level") = q38_cost_prod_labor.l(i); + oq38_cost_prod_capital(t,i,"level") = q38_cost_prod_capital.l(i); + oq38_investment_immobile(t,j,kcr,"level") = q38_investment_immobile.l(j,kcr); + oq38_investment_mobile(t,j,"level") = q38_investment_mobile.l(j); + ov_cost_prod_crop(t,i,factors,"upper") = vm_cost_prod_crop.up(i,factors); + ov38_investment_immobile(t,j,kcr,"upper") = v38_investment_immobile.up(j,kcr); + ov38_investment_mobile(t,j,"upper") = v38_investment_mobile.up(j); + oq38_cost_prod_labor(t,i,"upper") = q38_cost_prod_labor.up(i); + oq38_cost_prod_capital(t,i,"upper") = q38_cost_prod_capital.up(i); + oq38_investment_immobile(t,j,kcr,"upper") = q38_investment_immobile.up(j,kcr); + oq38_investment_mobile(t,j,"upper") = q38_investment_mobile.up(j); + ov_cost_prod_crop(t,i,factors,"lower") = vm_cost_prod_crop.lo(i,factors); + ov38_investment_immobile(t,j,kcr,"lower") = v38_investment_immobile.lo(j,kcr); + ov38_investment_mobile(t,j,"lower") = v38_investment_mobile.lo(j); + oq38_cost_prod_labor(t,i,"lower") = q38_cost_prod_labor.lo(i); + oq38_cost_prod_capital(t,i,"lower") = q38_cost_prod_capital.lo(i); + oq38_investment_immobile(t,j,kcr,"lower") = q38_investment_immobile.lo(j,kcr); + oq38_investment_mobile(t,j,"lower") = q38_investment_mobile.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/38_factor_costs/sticky_feb18/preloop.gms b/modules/38_factor_costs/sticky_feb18/preloop.gms new file mode 100644 index 0000000000..0e61860d3a --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/preloop.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2025 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 + +* calculate capital cost shares from regression +p38_capital_share_calibration(iso) = sum(t_past$(ord(t_past) eq card(t_past)), f38_historical_share(t_past,iso) - (f38_reg_parameters("slope") * + log10(im_gdp_pc_ppp_iso(t_past,iso)) + f38_reg_parameters("intercept"))); + +p38_capital_cost_shares_iso(t,iso) = f38_reg_parameters("slope") * log10(im_gdp_pc_ppp_iso(t,iso)) + + f38_reg_parameters("intercept") + + p38_capital_share_calibration(iso); + +p38_capital_cost_shares_iso(t,iso)$(sum(sameas(t_past,t_all),1) = 1) = f38_historical_share(t,iso); + +* aggregate factor cost shares +pm_factor_cost_shares(t,i,"capital") = sum(t_past$(ord(t_past) eq card(t_past)), + sum(i_to_iso(i,iso), f38_hist_factor_costs(t_past,iso) * p38_capital_cost_shares_iso(t,iso)) / + sum(i_to_iso(i,iso), f38_hist_factor_costs(t_past,iso))); +pm_factor_cost_shares(t,i,"labor") = 1 - pm_factor_cost_shares(t,i,"capital"); diff --git a/modules/38_factor_costs/sticky_feb18/presolve.gms b/modules/38_factor_costs/sticky_feb18/presolve.gms new file mode 100644 index 0000000000..675f9ddffe --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/presolve.gms @@ -0,0 +1,41 @@ +*** | (C) 2008-2025 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 + +if (smax(j, pm_labor_prod(t,j)) <> 1 OR smin(j, pm_labor_prod(t,j)) <> 1, + abort "This factor cost realization cannot handle labor productivities != 1" +); + +* choosing between regional (+time dependent) or global (from 2005) factor requirements +$if "%c38_fac_req%" == "glo" i38_fac_req(t,i,kcr) = f38_fac_req(kcr); +$if "%c38_fac_req%" == "reg" i38_fac_req(t,i,kcr) = f38_fac_req_fao_reg(t,i,kcr); + +if (m_year(t)<=1995, + i38_fac_req(t,i,kcr) = i38_fac_req("y1995",i,kcr); +elseif m_year(t)>=2010, + i38_fac_req(t,i,kcr) = i38_fac_req("y2010",i,kcr); +else + i38_fac_req(t,i,kcr) = i38_fac_req(t,i,kcr); +); + +p38_labor_need(t,i,kcr) = i38_fac_req(t,i,kcr) * pm_factor_cost_shares(t,i,"labor"); +p38_capital_need(t,i,kcr,"mobile") = i38_fac_req(t,i,kcr) * pm_factor_cost_shares(t,i,"capital") / (pm_interest(t,i)+s38_depreciation_rate) * (1-s38_immobile); +p38_capital_need(t,i,kcr,"immobile") = i38_fac_req(t,i,kcr) * pm_factor_cost_shares(t,i,"capital") / (pm_interest(t,i)+s38_depreciation_rate) * s38_immobile; + +if (ord(t) = 1, + +*' Estimate capital stock based on capital remuneration. We assume that in 1994 and 1995 production is the same and the stocks gets depreciated from 1994. + p38_capital_immobile(t,j,kcr) = sum(cell(i,j), p38_capital_need(t,i,kcr,"immobile")*pm_prod_init(j,kcr))*(1-s38_depreciation_rate); + p38_capital_mobile(t,j) = sum((cell(i,j),kcr), p38_capital_need(t,i,kcr,"mobile")*pm_prod_init(j,kcr))*(1-s38_depreciation_rate); + +else + +*' Update of existing stocks + + p38_capital_immobile(t,j,kcr)=p38_capital_immobile(t,j,kcr)*(1-s38_depreciation_rate)**(m_timestep_length); + p38_capital_mobile(t,j)=p38_capital_mobile(t,j)*(1-s38_depreciation_rate)**(m_timestep_length); + +); diff --git a/modules/38_factor_costs/sticky_feb18/realization.gms b/modules/38_factor_costs/sticky_feb18/realization.gms new file mode 100644 index 0000000000..b1b51e36c6 --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/realization.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2025 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 The main goal of this realization is to improve crop patterns at different spatial +*' scales. Specifically, the goal is reached by reducing capital relocation flexibility between +*' crop types. In the "sticky" realization, the factor costs are separated into variable and +*' capital investment costs. Then, capital is furtherly divided into immobile and mobile, where +*' mobility is defined between crops. In this way, changes in cropland are favored in locations +*' with existing capital stocks. + +*' @limitations This realization assumes that factor costs, within a region, +*' purely depend on the production and are independent of the area under cultivation. +*' By implication, cases in which the harvested area could significantly influence +*' factors costs are hardly accounted in this realization. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/38_factor_costs/sticky_feb18/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/38_factor_costs/sticky_feb18/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/38_factor_costs/sticky_feb18/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/38_factor_costs/sticky_feb18/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/38_factor_costs/sticky_feb18/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/38_factor_costs/sticky_feb18/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/38_factor_costs/sticky_feb18/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/38_factor_costs/sticky_feb18/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/38_factor_costs/sticky_feb18/scaling.gms b/modules/38_factor_costs/sticky_feb18/scaling.gms new file mode 100644 index 0000000000..6503d239c4 --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/scaling.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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_cost_prod_crop.scale(i,factors) = 10e5; +v38_investment_immobile.scale(j,kcr) = 10e3; diff --git a/modules/38_factor_costs/sticky_feb18/sets.gms b/modules/38_factor_costs/sticky_feb18/sets.gms new file mode 100644 index 0000000000..c9f7509a23 --- /dev/null +++ b/modules/38_factor_costs/sticky_feb18/sets.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2025 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 + mobil38 types of capital + / mobile, immobile / + + reg regression parameters for dynamic sticky + /slope, intercept/ + +factors factors included in factor requirements + / labor, capital / + ; + +*** EOF sets.gms *** diff --git a/modules/38_factor_costs/sticky_labor/declarations.gms b/modules/38_factor_costs/sticky_labor/declarations.gms new file mode 100644 index 0000000000..a23c2ee1b1 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/declarations.gms @@ -0,0 +1,66 @@ +*** | (C) 2008-2025 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 + q38_cost_prod_labor(i) Regional labor input costs for crop production (mio USD17MER) + q38_cost_prod_capital(i) Regional capital input costs for crop production (mio USD17MER) + q38_investment_immobile(j,kcr) Cellular immobile investments into farm capital (mio USD17MER) + q38_investment_mobile(j) Cellular mobile investments into farm capital (mio USD17MER) + q38_ces_prodfun(j,kcr) CES production function for one unit of output (1) + q38_labor_share_target(j) Enforces minimum labor cost share out of factor costs (1) +; + +positive variables + vm_cost_prod_crop(i,factors) Regional factor costs of capital and labor for crop production (mio USD17MER per yr) + v38_investment_immobile(j,kcr) Investment costs in immobile farm capital (mio USD17MER per yr) + v38_investment_mobile(j) Investment costs in mobile farm capital (mio USD17MER per yr) + v38_laborhours_need(j,kcr) Labor required per unit of output (hours per ton DM) + v38_capital_need(j,kcr,mobil38) Captial required per unit of output (USD17MER per ton DM) + v38_relax_CES_lp(j,kcr) Variable to make CES function feasible in linearized model (1) +; + +parameters + p38_labor_need(t,i,kcr) Labor input costs per unit of output (USD17MER per ton DM) + p38_capital_need(t,i,kcr,mobil38) Capital requirements per unit of output (USD17MER per ton DM) + p38_capital_immobile(t,j,kcr) Preexisting immobile capital stocks before investment (mio USD17MER) + p38_capital_mobile(t,j) Preexisting mobile capital stocks before investment (mio USD17MER) + + p38_capital_cost_shares_iso(t,iso) Capital shares of factor costs on iso level (1) + p38_capital_share_calibration(iso) Summation factor used to calibrate calculated capital shares with historical values (1) + pm_factor_cost_shares(t,i,factors) Capital and labor shares of factor costs on regional level (1) + p38_min_labor_share(t,j) Minimum labor share out of labor plus capital needed (1) + + p38_croparea_start(j,w,kcr) Agricultural land initialization area (mio. ha) + + i38_ces_shr(j,kcr) Share parameter for CES function (1) + i38_ces_scale(j,kcr) Scaling factor for total factor productivity (1) + + p38_intr_depr(t,i) Factor from interest and depreciation rate (1) + + i38_fac_req(t_all,i,kcr) Factor requirements (USD17MER per tDM) +; + +scalars + s38_ces_elast_par Elasticity parameter for CES function (1) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_prod_crop(t,i,factors,type) Regional factor costs of capital and labor for crop production (mio USD17MER per yr) + ov38_investment_immobile(t,j,kcr,type) Investment costs in immobile farm capital (mio USD17MER per yr) + ov38_investment_mobile(t,j,type) Investment costs in mobile farm capital (mio USD17MER per yr) + ov38_laborhours_need(t,j,kcr,type) Labor required per unit of output (hours per ton DM) + ov38_capital_need(t,j,kcr,mobil38,type) Captial required per unit of output (USD17MER per ton DM) + ov38_relax_CES_lp(t,j,kcr,type) Variable to make CES function feasible in linearized model (1) + oq38_cost_prod_labor(t,i,type) Regional labor input costs for crop production (mio USD17MER) + oq38_cost_prod_capital(t,i,type) Regional capital input costs for crop production (mio USD17MER) + oq38_investment_immobile(t,j,kcr,type) Cellular immobile investments into farm capital (mio USD17MER) + oq38_investment_mobile(t,j,type) Cellular mobile investments into farm capital (mio USD17MER) + oq38_ces_prodfun(t,j,kcr,type) CES production function for one unit of output (1) + oq38_labor_share_target(t,j,type) Enforces minimum labor cost share out of factor costs (1) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/38_factor_costs/sticky_labor/equations.gms b/modules/38_factor_costs/sticky_labor/equations.gms new file mode 100644 index 0000000000..234f1a0cc2 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/equations.gms @@ -0,0 +1,95 @@ +*** | (C) 2008-2025 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 + +*' Constant elasticity of substitution (CES) production function for one unit of output. +*' The CES function accounts for capital `v38_capital_need` and labor `v38_laborhours_need` requirements. +*' The efficiency of labor is affected by the labor productivity factor `pm_labor_prod` based on climate +*' change impacts, which is provided by the labor productivity module [37_labor_prod], and by the factor +*' `pm_productivity_gain_from_wages` based on increased wages from [36_employment]. +*' The calculation of total capital and labor costs is covered by the equations `q38_cost_prod_crop` and `q38_cost_prod_inv`. +*' The conceptual and analytical details of the CES function including the labor productivity factor are documented in @orlov_ces_2021. + + q38_ces_prodfun(j2,kcr) .. + i38_ces_scale(j2,kcr) * + (i38_ces_shr(j2,kcr)*sum(mobil38, v38_capital_need(j2,kcr,mobil38))**(-s38_ces_elast_par) + + (1 - i38_ces_shr(j2,kcr))*(sum(ct, pm_labor_prod(ct,j2) * sum(cell(i2,j2), pm_productivity_gain_from_wages(ct,i2))) * v38_laborhours_need(j2,kcr))**(-s38_ces_elast_par))**(-1/s38_ces_elast_par) + =e= 1 + v38_relax_CES_lp(j2,kcr); + +*' As low labor shares can lead to low agricultural employment, which is not necessarily a desired output, a +*' minimum share of labor need can be set. + +q38_labor_share_target(j2) .. + sum(kcr, vm_prod(j2,kcr) * v38_laborhours_need(j2,kcr) * sum((ct, cell(i2,j2)), pm_hourly_costs(ct,i2,"scenario"))) =g= + sum(ct, p38_min_labor_share(ct,j2)) * + (sum(kcr, vm_prod(j2,kcr) * v38_laborhours_need(j2,kcr) * + sum((ct, cell(i2,j2)), pm_hourly_costs(ct,i2,"scenario"))) + + sum((mobil38, kcr), vm_prod(j2,kcr) * v38_capital_need(j2,kcr,mobil38)) * + sum((ct, cell(i2,j2)), pm_interest(ct,i2) + s38_depreciation_rate)); + +*' Labor costs: The labor costs are calculated by multiplying regional aggregated production with labor requirements +*' (in hours) per output unit and wages from [36_employment]. + +q38_cost_prod_labor(i2).. vm_cost_prod_crop(i2,"labor") + =e= sum(kcr,sum(cell(i2,j2), vm_prod(j2,kcr) * v38_laborhours_need(j2,kcr) * sum(ct, pm_hourly_costs(ct,i2,"scenario")))) + ; + +*' Investment costs: Investment are the summation of investment in mobile and immobile capital. The costs are annuitized, +*' and corrected to make sure that the annual depreciation of the current time-step is accounted for. + +q38_cost_prod_capital(i2).. vm_cost_prod_crop(i2,"capital")=e=(sum((cell(i2,j2),kcr),v38_investment_immobile(j2,kcr)) + + sum((cell(i2,j2)),v38_investment_mobile(j2))) + * sum(ct, (pm_interest(ct, i2) + s38_depreciation_rate) / (1+pm_interest(ct,i2))) + ; + +*' The logic behind the annuitization is the following: +*' MAgPIE should do an investment if the utility it gains from this investment over all future timesteps U_0..n exceeds the Investment costs I_0 +*' Lets assume the utility is a ratio z of the physical capital stock K, such that +*' (1) U_t = K_t * z +*' NOTE: A big assumption is that z is not time-dependent, so we assume that all future periods have the same benefit from the capital stock. + +*' The utility in the next timestep, t+1 should be lower, because the capital depreciates, and because future utility is discounted because +*' of time preference or opportunity costs. The result is +*' (2) U_t+1 = K_t * (1-d) * z / (1+r) +*' next, we want to sum up all utilities from now until forever, so +*' (3) U_0..n = U_0 + U_1 + ... U_n +*' we can enter (2) in (3) to get +*' (4) I_0 <= K_0 * z + K_0 * z*(1-d)/(1+r) + K_0 * z * (1-d)^2 / (1+r)^2 +...+ K_0 * z * (1-d)^n/((1+r)^n) +*' which is then, based on the gemoetric series above +*' (5) I_0 <= K_0 * z * (1+r) / (r+d) + +*' Now, we have the problem that MAgPIE does not see the future. It only sees the costs and the utility of the current period. +*' In MAgPIE, the invesment is done if the utiltiy of the current period U_0 exceeds the costs it sees in the current period, C_0. +*' We know based on equation (1) that U_0 = K_0 * z, which we can enter into (4) such that +*' (6) I_0 <= U_0 * (1+r) / (r+d) + +*' So, we can compare the investment costs to the utility U_0, the utility that the model gains in the current timestep from making the investement. +*' It should do the investment when +*' (7) U_0 >= I_0 * (r+d) / (1+r) = C_0 +*' The right hand of this equation is therefore the costs C_0 that the model should see to evaluate whether the utility U_0 is sufficient to justify the investment. + +*' Each cropping activity requires a certain capital stock that depends on the +*' production. The following equations make sure that new land expansion is equipped +*' with capital stock, and that depreciation of pre-existing capital is replaced. +*' Since the mobility of capital is defined over crop-type, immobile capital is set +*' over specific crop types and locations. + +q38_investment_immobile(j2,kcr).. v38_investment_immobile(j2,kcr) + =g= + vm_prod(j2,kcr) * v38_capital_need(j2,kcr,"immobile") - + sum(ct, p38_capital_immobile(ct,j2,kcr)); +* + +*' On the other hand, the mobile capital is needed by all crop activities in each location, so it is defined over each j2 cell. + +q38_investment_mobile(j2).. v38_investment_mobile(j2) + =g= + sum(kcr, vm_prod(j2,kcr) * v38_capital_need(j2,kcr,"mobile")) - + sum(ct, p38_capital_mobile(ct,j2)); +* diff --git a/modules/38_factor_costs/sticky_labor/input.gms b/modules/38_factor_costs/sticky_labor/input.gms new file mode 100644 index 0000000000..fa5ef2583b --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/input.gms @@ -0,0 +1,57 @@ +*** | (C) 2008-2025 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 + +$setglobal c38_fac_req glo +* spatial disaggregation of factor requirements (options: glo, reg) + +scalars +* Depreciation rate assuming roughly 20 years linear depreciation for invesment goods +s38_depreciation_rate depreciation rate (share of costs) / 0.05 / +* Share of immobile capital. +s38_immobile immobile capital (share) / 1 / +s38_ces_elast_subst Elasticity of substitution in CES function (1) / 0.3 / +s38_startyear_labor_substitution Year until which labor and capital requirements are fixed to historic values (year) / 2025 / +s38_target_labor_share Target labor share out of labor plus capital needed (1) / 0 / +s38_targetyear_labor_share Year for which the target labor share should be set (year) / 2050 / +s38_target_fulfillment Share by which a region moves from its baseline labor share towards the target value (1) / 0.5 / +; + +parameter f38_fac_req(kcr) Factor requirement costs in 2005 (USD17MER per tDM) +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_fac_req_fao.csv" +$offdelim +/ +; + +parameter f38_fac_req_fao_reg(t_all,i,kcr) Factor requirement costs (USD17MER per tDM) +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_fac_req_fao_regional.cs4" +$offdelim +/ +; + +parameter f38_reg_parameters(reg) Parameters for dynamic regression +/ +$ondelim +$include "./modules/38_factor_costs/input/f38_regression_cap_share.csv" +$offdelim +/ +; + +table f38_historical_share(t_all,iso) Historical capital share +$ondelim +$include "./modules/38_factor_costs/input/f38_historical_share_iso.csv" +$offdelim +; + +table f38_hist_factor_costs(t_all,iso) Historical factor costs for crop and livestock (mio USD17MER) +$ondelim +$include "./modules/38_factor_costs/input/f38_hist_factor_costs_iso.csv" +$offdelim +; diff --git a/modules/38_factor_costs/sticky_labor/input/files b/modules/38_factor_costs/sticky_labor/input/files new file mode 100644 index 0000000000..dbebab811f --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/input/files @@ -0,0 +1,6 @@ +* list of files that are required here +f38_region_yield.csv +f38_historical_share_iso.csv +f38_regression_cap_share.csv +f38_fac_req_fao.csv +f38_hist_factor_costs_iso.csv diff --git a/modules/38_factor_costs/sticky_labor/nl_fix.gms b/modules/38_factor_costs/sticky_labor/nl_fix.gms new file mode 100644 index 0000000000..d9e57b624c --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/nl_fix.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 + +* ### nl_fix ### + +v38_laborhours_need.fx(j,kcr) = v38_laborhours_need.l(j,kcr); +v38_capital_need.fx(j,kcr,mobil38) = v38_capital_need.l(j,kcr,mobil38); + +* release v38_relax_CES_lp for linear version of MAgPIE +v38_relax_CES_lp.l(j,kcr) = 0; +v38_relax_CES_lp.lo(j,kcr) = -Inf; +v38_relax_CES_lp.up(j,kcr) = Inf; diff --git a/modules/38_factor_costs/sticky_labor/nl_relax.gms b/modules/38_factor_costs/sticky_labor/nl_relax.gms new file mode 100644 index 0000000000..cb8d5abab6 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/nl_relax.gms @@ -0,0 +1,12 @@ +*** | (C) 2008-2025 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 + +* ### nl_relax ### + +v38_laborhours_need.l(j,kcr) = v38_laborhours_need.l(j,kcr) * 1.1; +v38_capital_need.l(j,kcr,"immobile") = sum(cell(i,j), (i38_ces_shr(j,kcr) / (i38_ces_scale(j,kcr)**s38_ces_elast_par - (1-i38_ces_shr(j,kcr))*(pm_labor_prod(t,j) * pm_productivity_gain_from_wages(t,i)*v38_laborhours_need.l(j,kcr)**(-s38_ces_elast_par))))**(1/s38_ces_elast_par)) * s38_immobile; +v38_capital_need.l(j,kcr,"mobile") = v38_capital_need.l(j,kcr,"immobile") * (1-s38_immobile) / s38_immobile; diff --git a/modules/38_factor_costs/sticky_labor/nl_release.gms b/modules/38_factor_costs/sticky_labor/nl_release.gms new file mode 100644 index 0000000000..7683b52be0 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/nl_release.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 + +* ### nl_release ### + +v38_laborhours_need.lo(j,kcr) = 0.1 * v38_laborhours_need.l(j,kcr); +v38_laborhours_need.up(j,kcr) = 10 * v38_laborhours_need.l(j,kcr); +v38_capital_need.lo(j,kcr,mobil38) = 0.1 * v38_capital_need.l(j,kcr,mobil38); +v38_capital_need.up(j,kcr,mobil38) = 10 * v38_capital_need.l(j,kcr,mobil38); + +* fix v38_relax_CES_lp to zero for non-linear version of MAgPIE +v38_relax_CES_lp.fx(j,kcr) = 0; diff --git a/modules/38_factor_costs/sticky_labor/not_used.txt b/modules/38_factor_costs/sticky_labor/not_used.txt new file mode 100644 index 0000000000..f9b97b10a0 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +vm_prod_reg,input,not used diff --git a/modules/38_factor_costs/sticky_labor/postsolve.gms b/modules/38_factor_costs/sticky_labor/postsolve.gms new file mode 100644 index 0000000000..d076731495 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/postsolve.gms @@ -0,0 +1,62 @@ +*** | (C) 2008-2025 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 + +*' Capital update from the last investment +p38_capital_immobile(t+1,j,kcr) = p38_capital_immobile(t,j,kcr) + v38_investment_immobile.l(j,kcr); +p38_capital_mobile(t+1,j) = p38_capital_mobile(t,j) + v38_investment_mobile.l(j); + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_prod_crop(t,i,factors,"marginal") = vm_cost_prod_crop.m(i,factors); + ov38_investment_immobile(t,j,kcr,"marginal") = v38_investment_immobile.m(j,kcr); + ov38_investment_mobile(t,j,"marginal") = v38_investment_mobile.m(j); + ov38_laborhours_need(t,j,kcr,"marginal") = v38_laborhours_need.m(j,kcr); + ov38_capital_need(t,j,kcr,mobil38,"marginal") = v38_capital_need.m(j,kcr,mobil38); + ov38_relax_CES_lp(t,j,kcr,"marginal") = v38_relax_CES_lp.m(j,kcr); + oq38_cost_prod_labor(t,i,"marginal") = q38_cost_prod_labor.m(i); + oq38_cost_prod_capital(t,i,"marginal") = q38_cost_prod_capital.m(i); + oq38_investment_immobile(t,j,kcr,"marginal") = q38_investment_immobile.m(j,kcr); + oq38_investment_mobile(t,j,"marginal") = q38_investment_mobile.m(j); + oq38_ces_prodfun(t,j,kcr,"marginal") = q38_ces_prodfun.m(j,kcr); + oq38_labor_share_target(t,j,"marginal") = q38_labor_share_target.m(j); + ov_cost_prod_crop(t,i,factors,"level") = vm_cost_prod_crop.l(i,factors); + ov38_investment_immobile(t,j,kcr,"level") = v38_investment_immobile.l(j,kcr); + ov38_investment_mobile(t,j,"level") = v38_investment_mobile.l(j); + ov38_laborhours_need(t,j,kcr,"level") = v38_laborhours_need.l(j,kcr); + ov38_capital_need(t,j,kcr,mobil38,"level") = v38_capital_need.l(j,kcr,mobil38); + ov38_relax_CES_lp(t,j,kcr,"level") = v38_relax_CES_lp.l(j,kcr); + oq38_cost_prod_labor(t,i,"level") = q38_cost_prod_labor.l(i); + oq38_cost_prod_capital(t,i,"level") = q38_cost_prod_capital.l(i); + oq38_investment_immobile(t,j,kcr,"level") = q38_investment_immobile.l(j,kcr); + oq38_investment_mobile(t,j,"level") = q38_investment_mobile.l(j); + oq38_ces_prodfun(t,j,kcr,"level") = q38_ces_prodfun.l(j,kcr); + oq38_labor_share_target(t,j,"level") = q38_labor_share_target.l(j); + ov_cost_prod_crop(t,i,factors,"upper") = vm_cost_prod_crop.up(i,factors); + ov38_investment_immobile(t,j,kcr,"upper") = v38_investment_immobile.up(j,kcr); + ov38_investment_mobile(t,j,"upper") = v38_investment_mobile.up(j); + ov38_laborhours_need(t,j,kcr,"upper") = v38_laborhours_need.up(j,kcr); + ov38_capital_need(t,j,kcr,mobil38,"upper") = v38_capital_need.up(j,kcr,mobil38); + ov38_relax_CES_lp(t,j,kcr,"upper") = v38_relax_CES_lp.up(j,kcr); + oq38_cost_prod_labor(t,i,"upper") = q38_cost_prod_labor.up(i); + oq38_cost_prod_capital(t,i,"upper") = q38_cost_prod_capital.up(i); + oq38_investment_immobile(t,j,kcr,"upper") = q38_investment_immobile.up(j,kcr); + oq38_investment_mobile(t,j,"upper") = q38_investment_mobile.up(j); + oq38_ces_prodfun(t,j,kcr,"upper") = q38_ces_prodfun.up(j,kcr); + oq38_labor_share_target(t,j,"upper") = q38_labor_share_target.up(j); + ov_cost_prod_crop(t,i,factors,"lower") = vm_cost_prod_crop.lo(i,factors); + ov38_investment_immobile(t,j,kcr,"lower") = v38_investment_immobile.lo(j,kcr); + ov38_investment_mobile(t,j,"lower") = v38_investment_mobile.lo(j); + ov38_laborhours_need(t,j,kcr,"lower") = v38_laborhours_need.lo(j,kcr); + ov38_capital_need(t,j,kcr,mobil38,"lower") = v38_capital_need.lo(j,kcr,mobil38); + ov38_relax_CES_lp(t,j,kcr,"lower") = v38_relax_CES_lp.lo(j,kcr); + oq38_cost_prod_labor(t,i,"lower") = q38_cost_prod_labor.lo(i); + oq38_cost_prod_capital(t,i,"lower") = q38_cost_prod_capital.lo(i); + oq38_investment_immobile(t,j,kcr,"lower") = q38_investment_immobile.lo(j,kcr); + oq38_investment_mobile(t,j,"lower") = q38_investment_mobile.lo(j); + oq38_ces_prodfun(t,j,kcr,"lower") = q38_ces_prodfun.lo(j,kcr); + oq38_labor_share_target(t,j,"lower") = q38_labor_share_target.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/38_factor_costs/sticky_labor/preloop.gms b/modules/38_factor_costs/sticky_labor/preloop.gms new file mode 100644 index 0000000000..5b1c5f9e1b --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/preloop.gms @@ -0,0 +1,24 @@ +*** | (C) 2008-2025 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 + +* Calibrate the CES function: +s38_ces_elast_par = (1/s38_ces_elast_subst) - 1 ; + +p38_intr_depr(t,i) = (pm_interest(t, i) + s38_depreciation_rate) / (1+pm_interest(t,i)); + +* calculate capital cost shares from regression +p38_capital_share_calibration(iso) = sum(t_past$(ord(t_past) eq card(t_past)), f38_historical_share(t_past,iso) - (f38_reg_parameters("slope") * + log10(im_gdp_pc_ppp_iso(t_past,iso)) + f38_reg_parameters("intercept"))); + +p38_capital_cost_shares_iso(t,iso)$(m_year(t)<2010) = f38_historical_share(t,iso); +p38_capital_cost_shares_iso(t,iso)$(m_year(t)>=2010) = f38_reg_parameters("slope") * log10(im_gdp_pc_ppp_iso(t,iso)) + f38_reg_parameters("intercept") + p38_capital_share_calibration(iso); + +* aggregate factor cost shares +pm_factor_cost_shares(t,i,"capital") = sum(t_past$(ord(t_past) eq card(t_past)), + sum(i_to_iso(i,iso), f38_hist_factor_costs(t_past,iso) * p38_capital_cost_shares_iso(t,iso)) / + sum(i_to_iso(i,iso), f38_hist_factor_costs(t_past,iso))); +pm_factor_cost_shares(t,i,"labor") = 1 - pm_factor_cost_shares(t,i,"capital"); diff --git a/modules/38_factor_costs/sticky_labor/presolve.gms b/modules/38_factor_costs/sticky_labor/presolve.gms new file mode 100644 index 0000000000..018d6fadcf --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/presolve.gms @@ -0,0 +1,97 @@ +*** | (C) 2008-2025 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 + +* choosing between regional (+time dependent) or global (from 2005) factor requirements +$if "%c38_fac_req%" == "glo" i38_fac_req(t,i,kcr) = f38_fac_req(kcr); +$if "%c38_fac_req%" == "reg" i38_fac_req(t,i,kcr) = f38_fac_req_fao_reg(t,i,kcr); + +if (m_year(t)<=1995, + i38_fac_req(t,i,kcr) = i38_fac_req("y1995",i,kcr); +elseif m_year(t)>=2010, + i38_fac_req(t,i,kcr) = i38_fac_req("y2010",i,kcr); +else + i38_fac_req(t,i,kcr) = i38_fac_req(t,i,kcr); +); + +p38_labor_need(t,i,kcr) = i38_fac_req(t,i,kcr) * pm_factor_cost_shares(t,i,"labor"); +p38_capital_need(t,i,kcr,"mobile") = i38_fac_req(t,i,kcr) * pm_factor_cost_shares(t,i,"capital") / (pm_interest(t,i)+s38_depreciation_rate) * (1-s38_immobile); +p38_capital_need(t,i,kcr,"immobile") = i38_fac_req(t,i,kcr) * pm_factor_cost_shares(t,i,"capital") / (pm_interest(t,i)+s38_depreciation_rate) * s38_immobile; + +* minimum labor share based on target and adjustment factor +if (m_year(t) <= s38_startyear_labor_substitution, + p38_min_labor_share(t,j) = 0; +elseif m_year(t) <= s38_targetyear_labor_share, + p38_min_labor_share(t,j) = sum(cell(i,j), + max(pm_factor_cost_shares(t,i,"labor"), pm_factor_cost_shares(t,i,"labor") + + ((m_year(t)-s38_startyear_labor_substitution)/(s38_targetyear_labor_share-s38_startyear_labor_substitution) * + (s38_target_fulfillment * (s38_target_labor_share - sum(t2$(m_year(t2) = s38_targetyear_labor_share), + pm_factor_cost_shares(t2,i,"labor"))))))); +else + p38_min_labor_share(t,j)$(sum(t2$(m_year(t2) = s38_targetyear_labor_share), + sum(cell(i,j), pm_factor_cost_shares(t2,i,"labor"))) <= s38_target_labor_share) + = sum(t2$(m_year(t2) = s38_targetyear_labor_share), p38_min_labor_share(t2,j)); + p38_min_labor_share(t,j)$(sum(t2$(m_year(t2) = s38_targetyear_labor_share), + sum(cell(i,j), pm_factor_cost_shares(t2,i,"labor"))) > s38_target_labor_share) + = max(sum(cell(i,j), pm_factor_cost_shares(t,i,"labor")), s38_target_labor_share); +); + +* overwrite with 0 in case target labor share is 0 (i.e. off) +if (s38_target_labor_share = 0, + p38_min_labor_share(t,j) = 0; +); + + +*** Variable labor costs BEGIN + +* baseline laborhours need and capital need +v38_laborhours_need.l(j,kcr) = sum(cell(i,j), p38_labor_need(t,i,kcr) / pm_hourly_costs(t,i,"baseline")); +v38_capital_need.l(j,kcr,mobil38) = sum(cell(i,j), p38_capital_need(t,i,kcr,mobil38)); + +* update CES parameters (calibrating to baseline labor and capital needs) +i38_ces_shr(j,kcr) = sum(cell(i,j), (p38_intr_depr(t,i) * sum(mobil38, v38_capital_need.l(j,kcr,mobil38))**(1 + s38_ces_elast_par)) / (p38_intr_depr(t,i) * sum(mobil38, v38_capital_need.l(j,kcr,mobil38))**(1 + s38_ces_elast_par) + pm_hourly_costs(t,i,"baseline") * v38_laborhours_need.l(j,kcr)**(1 + s38_ces_elast_par))); +i38_ces_scale(j,kcr) = sum(cell(i,j), 1/([i38_ces_shr(j,kcr) * sum(mobil38, v38_capital_need.l(j,kcr,mobil38))**(-s38_ces_elast_par) + (1 - i38_ces_shr(j,kcr)) * v38_laborhours_need.l(j,kcr)**(-s38_ces_elast_par)]**(-1/s38_ces_elast_par))); + +* in case of labor share target: initialize level by assuming that the regional target shares would be enforced in each cell +if ((m_year(t) > s38_startyear_labor_substitution) and (s38_target_labor_share <> 0), + v38_laborhours_need.l(j,kcr) = sum(cell(i,j), (1/i38_ces_scale(j,kcr)) * (i38_ces_shr(j,kcr) * (((1-p38_min_labor_share(t,j))*pm_hourly_costs(t,i,"scenario"))/(p38_min_labor_share(t,j)*(pm_interest(t,i)+s38_depreciation_rate)))**(-s38_ces_elast_par) + + (1-i38_ces_shr(j,kcr)) * (pm_labor_prod(t,j) * pm_productivity_gain_from_wages(t,i))**(-s38_ces_elast_par))**(1/s38_ces_elast_par)); +); +v38_laborhours_need.lo(j,kcr) = 0.1 * v38_laborhours_need.l(j,kcr); +v38_laborhours_need.up(j,kcr) = 10 * v38_laborhours_need.l(j,kcr); + +* fix capital need until startyear of labor substitution +if (m_year(t) <= s38_startyear_labor_substitution, + v38_capital_need.fx(j,kcr,mobil38) = sum(cell(i,j), p38_capital_need(t,i,kcr,mobil38)); +else +* in case of labor share target: initialize level by assuming that the regional target shares would be enforced in each cell + if (s38_target_labor_share <> 0, + v38_capital_need.l(j,kcr,"immobile") = sum(cell(i,j), ((1-p38_min_labor_share(t,j))*v38_laborhours_need.l(j,kcr)*pm_hourly_costs(t,i,"scenario")) / (p38_min_labor_share(t,j)*(pm_interest(t,i)+s38_depreciation_rate))) * s38_immobile; + v38_capital_need.l(j,kcr,"mobile") = v38_capital_need.l(j,kcr,"immobile") * (1-s38_immobile) / s38_immobile; + ); + v38_capital_need.lo(j,kcr,mobil38) = 0.1 * v38_capital_need.l(j,kcr,mobil38); + v38_capital_need.up(j,kcr,mobil38) = 10 * v38_capital_need.l(j,kcr,mobil38); +); + +*** Variable labor costs END + +if (ord(t) = 1, + +*' Estimate capital stock based on capital remuneration. We assume that in 1994 and 1995 production is the same and the stocks gets depreciated from 1994. + p38_capital_immobile(t,j,kcr) = sum(cell(i,j), p38_capital_need(t,i,kcr,"immobile")*pm_prod_init(j,kcr))*(1-s38_depreciation_rate); + p38_capital_mobile(t,j) = sum((cell(i,j),kcr), p38_capital_need(t,i,kcr,"mobile")*pm_prod_init(j,kcr))*(1-s38_depreciation_rate); + +else + +*' Update of existing stocks + + p38_capital_immobile(t,j,kcr)=p38_capital_immobile(t,j,kcr)*(1-s38_depreciation_rate)**(m_timestep_length); + p38_capital_mobile(t,j)=p38_capital_mobile(t,j)*(1-s38_depreciation_rate)**(m_timestep_length); + + ); + +* fix v38_relax_CES_lp to zero for non-linear version of MAgPIE +v38_relax_CES_lp.fx(j,kcr) = 0; diff --git a/modules/38_factor_costs/sticky_labor/realization.gms b/modules/38_factor_costs/sticky_labor/realization.gms new file mode 100644 index 0000000000..d2e00603be --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/realization.gms @@ -0,0 +1,37 @@ +*** | (C) 2008-2025 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 This realization is based on sticky_feb18, but in addition includes a +*' CES production function, which accounts for climate change impacts on labor productivity +*' provided by [37_labor_prod], and wage increase impact on labor productivity based on +*' wages in [36_employment]. +*' The main goal of this realization is to improve crop patterns at different spatial +*' scales. Specifically, the goal is reached by reducing capital relocation flexibility between +*' crop types. In the "sticky" realization, the factor costs are separated into variable labor cost and +*' capital investment cost. Then, capital is further divided into immobile and mobile, where +*' mobility is defined between crops. In this way, changes in cropland are favored in locations +*' with existing capital stocks. + +*' @limitations This realization assumes that factor costs, within a region, +*' purely depend on the production and are independent of the area under cultivation. +*' By implication, cases in which the harvested area could significantly influence +*' factors costs are hardly accounted in this realization. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/38_factor_costs/sticky_labor/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/38_factor_costs/sticky_labor/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/38_factor_costs/sticky_labor/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/38_factor_costs/sticky_labor/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/38_factor_costs/sticky_labor/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/38_factor_costs/sticky_labor/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/38_factor_costs/sticky_labor/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/38_factor_costs/sticky_labor/postsolve.gms" +$Ifi "%phase%" == "nl_fix" $include "./modules/38_factor_costs/sticky_labor/nl_fix.gms" +$Ifi "%phase%" == "nl_release" $include "./modules/38_factor_costs/sticky_labor/nl_release.gms" +$Ifi "%phase%" == "nl_relax" $include "./modules/38_factor_costs/sticky_labor/nl_relax.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/38_factor_costs/sticky_labor/scaling.gms b/modules/38_factor_costs/sticky_labor/scaling.gms new file mode 100644 index 0000000000..98289fb1c7 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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_cost_prod_crop.scale(i,factors) = 10e5; +v38_investment_immobile.scale(j,kcr) = 10e3; +v38_capital_need.scale(j,kcr,mobil38) = 10e3; diff --git a/modules/38_factor_costs/sticky_labor/sets.gms b/modules/38_factor_costs/sticky_labor/sets.gms new file mode 100644 index 0000000000..c9f7509a23 --- /dev/null +++ b/modules/38_factor_costs/sticky_labor/sets.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2025 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 + mobil38 types of capital + / mobile, immobile / + + reg regression parameters for dynamic sticky + /slope, intercept/ + +factors factors included in factor requirements + / labor, capital / + ; + +*** EOF sets.gms *** diff --git a/modules/39_landconversion/calib/declarations.gms b/modules/39_landconversion/calib/declarations.gms new file mode 100644 index 0000000000..f502d0ab53 --- /dev/null +++ b/modules/39_landconversion/calib/declarations.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 + q39_cost_landcon(j,land) Calculation of cellular landconversion costs (mio. USD17MER per yr) +; + +variables + vm_cost_landcon(j,land) Costs for land expansion and reduction (mio. USD17MER per yr) +; + +parameters + i39_cost_establish(t,i,land) Land expansion costs (USD17MER per hectare) + i39_reward_reduction(t,i,land) Reward for land reduction (USD17MER per hectare) + i39_calib(t,i,type39) Calibration factor for costs of cropland expansion and rewards for cropland reduction (1) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_landcon(t,j,land,type) Costs for land expansion and reduction (mio. USD17MER per yr) + oq39_cost_landcon(t,j,land,type) Calculation of cellular landconversion costs (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/39_landconversion/calib/equations.gms b/modules/39_landconversion/calib/equations.gms new file mode 100644 index 0000000000..3c4a001dc4 --- /dev/null +++ b/modules/39_landconversion/calib/equations.gms @@ -0,0 +1,15 @@ +*** | (C) 2008-2025 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 +*' The sum of costs for land expansion and land reduction +*' is multiplied with an annuity factor to distribute these costs over time. + +q39_cost_landcon(j2,land) .. vm_cost_landcon(j2,land) =e= + (vm_landexpansion(j2,land)*sum((ct,cell(i2,j2)), i39_cost_establish(ct,i2,land)) + - vm_landreduction(j2,land)*sum((ct,cell(i2,j2)), i39_reward_reduction(ct,i2,land))) + * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); diff --git a/modules/39_landconversion/calib/input.gms b/modules/39_landconversion/calib/input.gms new file mode 100644 index 0000000000..4779422e4b --- /dev/null +++ b/modules/39_landconversion/calib/input.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 + s39_cost_establish_crop Cost for cropland expansion before calibration (USD17MER per hectare) / 12300 / + s39_reward_crop_reduction Reward for cropland reduction before calibration (USD17MER per hectare) / 7380 / + s39_cost_establish_past Cost for pasture land expansion (USD17MER per hectare) / 9840 / + s39_cost_establish_forestry Cost for forestry land expansion (USD17MER per hectare) / 1230 / + s39_cost_establish_urban Cost for urban land expansion (USD17MER per hectare) / 12300 / + s39_ignore_calib Switch for ignoring calibration factors (1) / 0 / +; + +$onEmpty +table f39_calib(t_all,i,type39) Calibration factor for costs of cropland expansion (1) +$ondelim +$if exist "./modules/39_landconversion/input/f39_calib.csv" $include "./modules/39_landconversion/input/f39_calib.csv" +$offdelim +; +$offEmpty diff --git a/modules/39_landconversion/calib/postsolve.gms b/modules/39_landconversion/calib/postsolve.gms new file mode 100644 index 0000000000..506b821005 --- /dev/null +++ b/modules/39_landconversion/calib/postsolve.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_landcon(t,j,land,"marginal") = vm_cost_landcon.m(j,land); + oq39_cost_landcon(t,j,land,"marginal") = q39_cost_landcon.m(j,land); + ov_cost_landcon(t,j,land,"level") = vm_cost_landcon.l(j,land); + oq39_cost_landcon(t,j,land,"level") = q39_cost_landcon.l(j,land); + ov_cost_landcon(t,j,land,"upper") = vm_cost_landcon.up(j,land); + oq39_cost_landcon(t,j,land,"upper") = q39_cost_landcon.up(j,land); + ov_cost_landcon(t,j,land,"lower") = vm_cost_landcon.lo(j,land); + oq39_cost_landcon(t,j,land,"lower") = q39_cost_landcon.lo(j,land); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/39_landconversion/calib/preloop.gms b/modules/39_landconversion/calib/preloop.gms new file mode 100644 index 0000000000..0099e06e6c --- /dev/null +++ b/modules/39_landconversion/calib/preloop.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 + +i39_cost_establish(t,i,land) = 0; +i39_reward_reduction(t,i,land) = 0; + +i39_calib(t,i,type39) = f39_calib(t,i,type39); +* set default values in case of missing input file or s39_ignore_calib = 1 +if(sum((t,i,type39),i39_calib(t,i,type39)) = 0 OR s39_ignore_calib = 1, + i39_calib(t,i,"cost") = 1; + i39_calib(t,i,"reward") = 0; +); diff --git a/modules/39_landconversion/calib/presolve.gms b/modules/39_landconversion/calib/presolve.gms new file mode 100644 index 0000000000..642131e5ae --- /dev/null +++ b/modules/39_landconversion/calib/presolve.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 + +* Global cost for cropland expansion are scaled with a calibration factor (i39_calib). +* The calibration factor has been derived with the goal of matching regional cropland in 2015 with historic data. +* In addition, regions with a calibration factor > 1 and with a decline of cropland between 1995 and 2015 in historic data see a reward for cropland reduction. + +i39_cost_establish(t,i,"crop") = s39_cost_establish_crop * i39_calib(t,i,"cost"); +i39_reward_reduction(t,i,"crop") = s39_reward_crop_reduction * i39_calib(t,i,"reward"); +i39_cost_establish(t,i,"past") = s39_cost_establish_past; +i39_cost_establish(t,i,"forestry") = s39_cost_establish_forestry; +i39_cost_establish(t,i,"urban") = s39_cost_establish_urban; diff --git a/modules/39_landconversion/calib/realization.gms b/modules/39_landconversion/calib/realization.gms new file mode 100644 index 0000000000..615d347b7e --- /dev/null +++ b/modules/39_landconversion/calib/realization.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 +*' This realization accounts for land conversion costs of cropland, pasture, forestry and urban land. +*' Costs for expansion of pasture, forestry and urban land are global and static over time. +*' For cropland, a regional and time-dependent calibration factor is applied on +*' global costs for land expansion, complemented by a reward for cropland reduction in selected regions, +*' for a better match of regional cropland in 2015 with historic data. +*' The calibration factor for costs of cropland expansion is lifted to a minium of 1 in all regions by 2050. +*' +*' @limitations Data availability for land conversion costs is very limited. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/39_landconversion/calib/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/39_landconversion/calib/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/39_landconversion/calib/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/39_landconversion/calib/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/39_landconversion/calib/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/39_landconversion/calib/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/39_landconversion/calib/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/39_landconversion/calib/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/39_landconversion/calib/scaling.gms b/modules/39_landconversion/calib/scaling.gms new file mode 100644 index 0000000000..b07f13cda4 --- /dev/null +++ b/modules/39_landconversion/calib/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_cost_landcon.scale(j,land) = 10e3; diff --git a/modules/39_landconversion/calib/sets.gms b/modules/39_landconversion/calib/sets.gms new file mode 100644 index 0000000000..aba8f640a4 --- /dev/null +++ b/modules/39_landconversion/calib/sets.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + type39 Cost type + / cost, reward / +; diff --git a/modules/39_landconversion/global_static_aug18/declarations.gms b/modules/39_landconversion/global_static_aug18/declarations.gms deleted file mode 100644 index ef5d6e45a9..0000000000 --- a/modules/39_landconversion/global_static_aug18/declarations.gms +++ /dev/null @@ -1,41 +0,0 @@ -*** | (C) 2008-2019 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 - q39_cost_landcon_annuity(j,land) Calculation of cellular annuity costs of landconversion (mio. USD05MER per yr) - q39_cost_landcon(j,land) Calculation of cellular landconversion costs (mio. USD05MER per yr) -; - -variables - vm_cost_landcon(j,land) Land conversion costs (mio. USD05MER per yr) -; - -positive variable - v39_cost_landcon_annuity(j,land) Annuity costs of landconversion in the current timestep (mio. USD05MER per yr) -; - -scalar - s39_cost_establish Global land establishment costs (USD05MER per hectare) - s39_cost_clearing Global land clearing costs (USD05MER per ton C) -; - -parameters - i39_cost_establish(land) Global land establishment costs (USD05MER per hectare) - i39_cost_clearing(land) Global land clearing costs (USD05MER per ton C) - p39_cost_landcon_past(t,j,land) Costs for landconversion from the past (mio. USD05MER per yr) - pc39_cost_landcon_past(j,land) Costs for landconversion from the past in the current time step (mio. USD05MER per yr) -; - - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_landcon(t,j,land,type) Land conversion costs (mio. USD05MER per yr) - ov39_cost_landcon_annuity(t,j,land,type) Annuity costs of landconversion in the current timestep (mio. USD05MER per yr) - oq39_cost_landcon_annuity(t,j,land,type) Calculation of cellular annuity costs of landconversion (mio. USD05MER per yr) - oq39_cost_landcon(t,j,land,type) Calculation of cellular landconversion costs (mio. USD05MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/39_landconversion/global_static_aug18/equations.gms b/modules/39_landconversion/global_static_aug18/equations.gms deleted file mode 100644 index e7758b34de..0000000000 --- a/modules/39_landconversion/global_static_aug18/equations.gms +++ /dev/null @@ -1,23 +0,0 @@ -*** | (C) 2008-2019 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 establishment costs apply on expansion of cropland, pasture and forestry. -*' Land clearing costs apply on reduction of carbon stock in primary forest, secondary forest -*' and other natural land. -*' The sum of land establishment and land clearing costs in the current time step -*' is multiplied with an annuity factor to distribute these costs over time. -q39_cost_landcon_annuity(j2,land) .. v39_cost_landcon_annuity(j2,land) =e= - (vm_landexpansion(j2,land)*i39_cost_establish(land) - + vm_carbon_stock_reduction(j2,land,"vegc")*i39_cost_clearing(land)) - * sum(cell(i2,j2),pm_interest(i2)/(1+pm_interest(i2))); - -*' Land conversion costs in the current time step consist of -*' the annuitized costs for land conversion in the current time step `v39_cost_landcon_annuity` -*' and the land conversion costs from the past `pc39_cost_landcon_past`. -q39_cost_landcon(j2,land) .. vm_cost_landcon(j2,land) =e= - v39_cost_landcon_annuity(j2,land) + pc39_cost_landcon_past(j2,land); diff --git a/modules/39_landconversion/global_static_aug18/postsolve.gms b/modules/39_landconversion/global_static_aug18/postsolve.gms deleted file mode 100644 index 97f22814c2..0000000000 --- a/modules/39_landconversion/global_static_aug18/postsolve.gms +++ /dev/null @@ -1,27 +0,0 @@ -*** | (C) 2008-2019 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 - -p39_cost_landcon_past(t2,j,land) = p39_cost_landcon_past(t2,j,land) + v39_cost_landcon_annuity.l(j,land); - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_landcon(t,j,land,"marginal") = vm_cost_landcon.m(j,land); - ov39_cost_landcon_annuity(t,j,land,"marginal") = v39_cost_landcon_annuity.m(j,land); - oq39_cost_landcon_annuity(t,j,land,"marginal") = q39_cost_landcon_annuity.m(j,land); - oq39_cost_landcon(t,j,land,"marginal") = q39_cost_landcon.m(j,land); - ov_cost_landcon(t,j,land,"level") = vm_cost_landcon.l(j,land); - ov39_cost_landcon_annuity(t,j,land,"level") = v39_cost_landcon_annuity.l(j,land); - oq39_cost_landcon_annuity(t,j,land,"level") = q39_cost_landcon_annuity.l(j,land); - oq39_cost_landcon(t,j,land,"level") = q39_cost_landcon.l(j,land); - ov_cost_landcon(t,j,land,"upper") = vm_cost_landcon.up(j,land); - ov39_cost_landcon_annuity(t,j,land,"upper") = v39_cost_landcon_annuity.up(j,land); - oq39_cost_landcon_annuity(t,j,land,"upper") = q39_cost_landcon_annuity.up(j,land); - oq39_cost_landcon(t,j,land,"upper") = q39_cost_landcon.up(j,land); - ov_cost_landcon(t,j,land,"lower") = vm_cost_landcon.lo(j,land); - ov39_cost_landcon_annuity(t,j,land,"lower") = v39_cost_landcon_annuity.lo(j,land); - oq39_cost_landcon_annuity(t,j,land,"lower") = q39_cost_landcon_annuity.lo(j,land); - oq39_cost_landcon(t,j,land,"lower") = q39_cost_landcon.lo(j,land); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/39_landconversion/global_static_aug18/preloop.gms b/modules/39_landconversion/global_static_aug18/preloop.gms deleted file mode 100644 index d50f8cfaa8..0000000000 --- a/modules/39_landconversion/global_static_aug18/preloop.gms +++ /dev/null @@ -1,17 +0,0 @@ -*** | (C) 2008-2019 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 - -s39_cost_establish = 8000; -s39_cost_clearing = 5; - -i39_cost_establish(land) = 0; -i39_cost_establish(land_establish39) = s39_cost_establish; - -i39_cost_clearing(land) = 0; -i39_cost_clearing(land_clearing39) = s39_cost_clearing; - -p39_cost_landcon_past(t,j,land) = 0; diff --git a/modules/39_landconversion/global_static_aug18/presolve.gms b/modules/39_landconversion/global_static_aug18/presolve.gms deleted file mode 100644 index a9ace52ec4..0000000000 --- a/modules/39_landconversion/global_static_aug18/presolve.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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 - -pc39_cost_landcon_past(j,land) = p39_cost_landcon_past(t,j,land); - diff --git a/modules/39_landconversion/global_static_aug18/realization.gms b/modules/39_landconversion/global_static_aug18/realization.gms deleted file mode 100644 index 975598cd34..0000000000 --- a/modules/39_landconversion/global_static_aug18/realization.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 the global_static_aug18 realization, per hectare land conversion costs are separated into -*' costs for expansion of cropland, pasture and forestry (establishment costs) and -*' costs for clearing of primary forest, secondary forest and other natural land (clearing costs). -*' We assume a global cost factor of 8000 USD/ha (static over time) for establishment of managed land. -*' For clearing of natural vegetation we assume a global static cost factor of 5 USD/tC (based on @kreidenweis_pasture_2018). -*' -*' @limitations Data availability for land conversion costs is very limited. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/39_landconversion/global_static_aug18/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/39_landconversion/global_static_aug18/declarations.gms" -$Ifi "%phase%" == "equations" $include "./modules/39_landconversion/global_static_aug18/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/39_landconversion/global_static_aug18/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/39_landconversion/global_static_aug18/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/39_landconversion/global_static_aug18/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/39_landconversion/global_static_aug18/sets.gms b/modules/39_landconversion/global_static_aug18/sets.gms deleted file mode 100644 index 6e31109cf4..0000000000 --- a/modules/39_landconversion/global_static_aug18/sets.gms +++ /dev/null @@ -1,14 +0,0 @@ -*** | (C) 2008-2019 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 - land_establish39(land) Managed land pools - / crop, past, forestry / - - land_clearing39(land) Natural vegetation land pools - / primforest, secdforest, other / -; diff --git a/modules/39_landconversion/input/files b/modules/39_landconversion/input/files new file mode 100644 index 0000000000..79b754f587 --- /dev/null +++ b/modules/39_landconversion/input/files @@ -0,0 +1,2 @@ +* list of files that are required here +f39_calib.csv diff --git a/modules/39_landconversion/module.gms b/modules/39_landconversion/module.gms index f84cc20601..98d5e4827c 100644 --- a/modules/39_landconversion/module.gms +++ b/modules/39_landconversion/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -18,5 +18,5 @@ *' @authors Florian Humpenöder, Jan Philipp Dietrich, Ulrich Kreidenweis *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%landconversion%" == "global_static_aug18" $include "./modules/39_landconversion/global_static_aug18/realization.gms" +$Ifi "%landconversion%" == "calib" $include "./modules/39_landconversion/calib/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/40_transport/gtap_nov12/declarations.gms b/modules/40_transport/gtap_nov12/declarations.gms index 1e4bafcdeb..9a666eff29 100644 --- a/modules/40_transport/gtap_nov12/declarations.gms +++ b/modules/40_transport/gtap_nov12/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,16 +6,16 @@ *** | Contact: magpie@pik-potsdam.de equation -q40_cost_transport(j,k) Cellular transport costs for k (mio. USD05MER per yr) +q40_cost_transport(j,k) Cellular transport costs for k (mio. USD17MER per yr) ; variables - vm_cost_transp(j,k) Transportation costs (mio. USD05MER per yr) + vm_cost_transp(j,k) Transportation costs (mio. USD17MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_cost_transp(t,j,k,type) Transportation costs (mio. USD05MER per yr) - oq40_cost_transport(t,j,k,type) Cellular transport costs for k (mio. USD05MER per yr) + ov_cost_transp(t,j,k,type) Transportation costs (mio. USD17MER per yr) + oq40_cost_transport(t,j,k,type) Cellular transport costs for k (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/40_transport/gtap_nov12/equations.gms b/modules/40_transport/gtap_nov12/equations.gms index be2bda073f..82f9d10d2f 100644 --- a/modules/40_transport/gtap_nov12/equations.gms +++ b/modules/40_transport/gtap_nov12/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -30,7 +30,7 @@ q40_cost_transport(j2,k) .. *' *' ![Travel time to major cities (in hours and days) -*' [@nelson_transport_2008]](travel_time_map.png){ width=100% } +*' [@nelson_transport_2008]](travel_time_map.jpg){ width=100% } *' *' Relative transport costs `f40_transport_costs(k)` are calibrated using total *' agricultural transport costs taken from the GTAP 7 database (see @narayanan_gtap7_2008 diff --git a/modules/40_transport/gtap_nov12/input.gms b/modules/40_transport/gtap_nov12/input.gms index 8172502d79..ac58ff854e 100644 --- a/modules/40_transport/gtap_nov12/input.gms +++ b/modules/40_transport/gtap_nov12/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,7 +7,7 @@ scalars - s40_pasture_transport_costs Transport costs for pasture (USD05MER per tDM per min) / 0 / + s40_pasture_transport_costs Transport costs for pasture (USD17MER per tDM per min) / 0 / ; @@ -20,7 +20,7 @@ $offdelim / ; -parameter f40_transport_costs(k) Relative transport costs (USD05MER per tDM per min) +parameter f40_transport_costs(kall) Relative transport costs (USD17MER per tDM per min) / $ondelim $include "./modules/40_transport/gtap_nov12/input/f40_transport_costs.csv" diff --git a/modules/40_transport/gtap_nov12/postsolve.gms b/modules/40_transport/gtap_nov12/postsolve.gms index 543f1614d0..e6a0ff0833 100644 --- a/modules/40_transport/gtap_nov12/postsolve.gms +++ b/modules/40_transport/gtap_nov12/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/40_transport/gtap_nov12/realization.gms b/modules/40_transport/gtap_nov12/realization.gms index f740f2d062..13f358e89c 100644 --- a/modules/40_transport/gtap_nov12/realization.gms +++ b/modules/40_transport/gtap_nov12/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/40_transport/gtap_nov12/travel_time_map.jpg b/modules/40_transport/gtap_nov12/travel_time_map.jpg new file mode 100644 index 0000000000..439b158a41 Binary files /dev/null and b/modules/40_transport/gtap_nov12/travel_time_map.jpg differ diff --git a/modules/40_transport/gtap_nov12/travel_time_map.png b/modules/40_transport/gtap_nov12/travel_time_map.png deleted file mode 100644 index 4bc7a8bf7c..0000000000 Binary files a/modules/40_transport/gtap_nov12/travel_time_map.png and /dev/null differ diff --git a/modules/40_transport/gtap_nov12/travel_time_map.png.REMOVED.git-id b/modules/40_transport/gtap_nov12/travel_time_map.png.REMOVED.git-id deleted file mode 100644 index c85b19267e..0000000000 --- a/modules/40_transport/gtap_nov12/travel_time_map.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4bc7a8bf7c589ca490b72a563bbf296df5ce97fe \ No newline at end of file diff --git a/modules/40_transport/module.gms b/modules/40_transport/module.gms index 3810fb7936..be2a9a2354 100644 --- a/modules/40_transport/module.gms +++ b/modules/40_transport/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/40_transport/off/declarations.gms b/modules/40_transport/off/declarations.gms index acf7f8d41b..dd0ebd8675 100644 --- a/modules/40_transport/off/declarations.gms +++ b/modules/40_transport/off/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,11 +7,11 @@ variables - vm_cost_transp(j,k) Transportation costs (mio. USD05MER) + vm_cost_transp(j,k) Transportation costs (mio. USD17MER) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_cost_transp(t,j,k,type) Transportation costs (mio. USD05MER) + ov_cost_transp(t,j,k,type) Transportation costs (mio. USD17MER) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/40_transport/off/not_used.txt b/modules/40_transport/off/not_used.txt index a7b7909721..850fb5a2ef 100644 --- a/modules/40_transport/off/not_used.txt +++ b/modules/40_transport/off/not_used.txt @@ -1,9 +1,2 @@ -# | (C) 2008-2019 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 - name,type,reason vm_prod, input, not needed diff --git a/modules/40_transport/off/postsolve.gms b/modules/40_transport/off/postsolve.gms index ac82179215..a4229dd429 100644 --- a/modules/40_transport/off/postsolve.gms +++ b/modules/40_transport/off/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/40_transport/off/presolve.gms b/modules/40_transport/off/presolve.gms index 6a100018f5..0dbfb769d2 100644 --- a/modules/40_transport/off/presolve.gms +++ b/modules/40_transport/off/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/40_transport/off/realization.gms b/modules/40_transport/off/realization.gms index 9420d8f330..d705f4e6a7 100644 --- a/modules/40_transport/off/realization.gms +++ b/modules/40_transport/off/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms index 2c0963728f..d38cf6f781 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,35 +6,29 @@ *** | Contact: magpie@pik-potsdam.de parameters - p41_cost_AEI_past(t,i) Costs for AEI expansion from the past (mio. USD04MER) - pc41_cost_AEI_past(i) Current costs for AEI expansion from the past (mio. USD04MER) p41_AEI_start(t,j) Area equipped for irrigation at the beginning of each time step (mio. ha) pc41_AEI_start(j) Area equipped for irrigation at the beginning of current time step (mio. ha) - pc41_unitcost_AEI(i) Unit cost of AEI expansion (USD04MER per ha) -; + pc41_unitcost_AEI(i) Unit cost of AEI expansion (USD17MER per ha) + ; variables - vm_cost_AEI(i) Irrigation expansion costs (mio. USD04MER per yr) - v41_cost_AEI_annuity(i) Annuity costs of AEI expansion in the current time step (mio. USD04MER per yr) + vm_cost_AEI(i) Annuitized irrigation expansion costs (mio. USD17MER per yr) ; positive variables - v41_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) + vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) ; equations q41_area_irrig(j) Irrigation area constraint (mio. ha) - q41_cost_AEI_annuity(i) Calculation of annuity costs of AEI expansion (mio. USD04MER) - q41_cost_AEI(i) Calculation of costs of irrigation area expansion (mio. USD04MER) + q41_cost_AEI(i) Calculation of costs of irrigation area expansion (mio. USD17MER) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_cost_AEI(t,i,type) Irrigation expansion costs (mio. USD04MER per yr) - ov41_cost_AEI_annuity(t,i,type) Annuity costs of AEI expansion in the current time step (mio. USD04MER per yr) - ov41_AEI(t,j,type) Area equipped for irrigation in each grid cell (mio. ha) - oq41_area_irrig(t,j,type) Irrigation area constraint (mio. ha) - oq41_cost_AEI_annuity(t,i,type) Calculation of annuity costs of AEI expansion (mio. USD04MER) - oq41_cost_AEI(t,i,type) Calculation of costs of irrigation area expansion (mio. USD04MER) + ov_cost_AEI(t,i,type) Annuitized irrigation expansion costs (mio. USD17MER per yr) + ov_AEI(t,j,type) Area equipped for irrigation in each grid cell (mio. ha) + oq41_area_irrig(t,j,type) Irrigation area constraint (mio. ha) + oq41_cost_AEI(t,i,type) Calculation of costs of irrigation area expansion (mio. USD17MER) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/equations.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/equations.gms index bad1054c28..1e2bcaa0ed 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/equations.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,20 +8,16 @@ *' @equations q41_area_irrig(j2) .. - sum(kcr, vm_area(j2,kcr,"irrigated")) =l= v41_AEI(j2); - + sum(kcr, vm_area(j2,kcr,"irrigated")) =l= vm_AEI(j2); -q41_cost_AEI_annuity(i2).. - v41_cost_AEI_annuity(i2) =e= - sum(cell(i2,j2),(v41_AEI(j2)-pc41_AEI_start(j2))) - * pc41_unitcost_AEI(i2)*pm_interest(i2)/(1+pm_interest(i2)); *' Investment costs in the current time step for each region are calculated by multiplying the AEI expansion in each -*' cluster of the region by the regional unit cost per hectare. +*' cluster of the region by the regional unit cost per hectare and a depreciation rate. *' MAgPIE has a common planning horizon to which all one time investments are distributed using an annuity -*' approach. Due to this distribution, part of the costs from previous investments in AEI still entail costs -*' in the current time step. +*' approach. -q41_cost_AEI(i2).. - vm_cost_AEI(i2) =e= - v41_cost_AEI_annuity(i2) + pc41_cost_AEI_past(i2); +q41_cost_AEI(i2).. + vm_cost_AEI(i2) =e= + sum(cell(i2,j2),(vm_AEI(j2)-pc41_AEI_start(j2))) + * pc41_unitcost_AEI(i2) + * sum(ct, (pm_interest(ct, i2) + s41_AEI_depreciation) / (1+pm_interest(ct,i2))); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms index a75d16d322..bc9ca97a86 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms @@ -1,21 +1,25 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -table f41_c_irrig(t_all,i) Irrigation investment costs (USD04MER per ha) +$setglobal c41_initial_irrigation_area LUH3 + +scalars +s41_AEI_depreciation Depreciation rate in capital value of irrigation infrastructure (USD17PPP per USD17PPP) / 0 / +; + +table f41_c_irrig(t_all,i) Irrigation investment costs (USD17MER per ha) $ondelim $include "./modules/41_area_equipped_for_irrigation/endo_apr13/input/f41_c_irrig.csv" $offdelim ; -parameters -f41_irrig(j) Available area equipped for irrigation [AVL] (mio. ha) -/ +table +f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) $ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs2" +$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs3" $offdelim -/ ; diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms index eb1f1385bf..5a254d2eb6 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms @@ -1,37 +1,27 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -pc41_AEI_start(j)=v41_AEI.l(j); - -p41_cost_AEI_past(t2,i) = p41_cost_AEI_past(t2,i) + v41_cost_AEI_annuity.l(i); +pc41_AEI_start(j)=vm_AEI.l(j) ; *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_AEI(t,i,"marginal") = vm_cost_AEI.m(i); - ov41_cost_AEI_annuity(t,i,"marginal") = v41_cost_AEI_annuity.m(i); - ov41_AEI(t,j,"marginal") = v41_AEI.m(j); - oq41_area_irrig(t,j,"marginal") = q41_area_irrig.m(j); - oq41_cost_AEI_annuity(t,i,"marginal") = q41_cost_AEI_annuity.m(i); - oq41_cost_AEI(t,i,"marginal") = q41_cost_AEI.m(i); - ov_cost_AEI(t,i,"level") = vm_cost_AEI.l(i); - ov41_cost_AEI_annuity(t,i,"level") = v41_cost_AEI_annuity.l(i); - ov41_AEI(t,j,"level") = v41_AEI.l(j); - oq41_area_irrig(t,j,"level") = q41_area_irrig.l(j); - oq41_cost_AEI_annuity(t,i,"level") = q41_cost_AEI_annuity.l(i); - oq41_cost_AEI(t,i,"level") = q41_cost_AEI.l(i); - ov_cost_AEI(t,i,"upper") = vm_cost_AEI.up(i); - ov41_cost_AEI_annuity(t,i,"upper") = v41_cost_AEI_annuity.up(i); - ov41_AEI(t,j,"upper") = v41_AEI.up(j); - oq41_area_irrig(t,j,"upper") = q41_area_irrig.up(j); - oq41_cost_AEI_annuity(t,i,"upper") = q41_cost_AEI_annuity.up(i); - oq41_cost_AEI(t,i,"upper") = q41_cost_AEI.up(i); - ov_cost_AEI(t,i,"lower") = vm_cost_AEI.lo(i); - ov41_cost_AEI_annuity(t,i,"lower") = v41_cost_AEI_annuity.lo(i); - ov41_AEI(t,j,"lower") = v41_AEI.lo(j); - oq41_area_irrig(t,j,"lower") = q41_area_irrig.lo(j); - oq41_cost_AEI_annuity(t,i,"lower") = q41_cost_AEI_annuity.lo(i); - oq41_cost_AEI(t,i,"lower") = q41_cost_AEI.lo(i); + ov_cost_AEI(t,i,"marginal") = vm_cost_AEI.m(i); + ov_AEI(t,j,"marginal") = vm_AEI.m(j); + oq41_area_irrig(t,j,"marginal") = q41_area_irrig.m(j); + oq41_cost_AEI(t,i,"marginal") = q41_cost_AEI.m(i); + ov_cost_AEI(t,i,"level") = vm_cost_AEI.l(i); + ov_AEI(t,j,"level") = vm_AEI.l(j); + oq41_area_irrig(t,j,"level") = q41_area_irrig.l(j); + oq41_cost_AEI(t,i,"level") = q41_cost_AEI.l(i); + ov_cost_AEI(t,i,"upper") = vm_cost_AEI.up(i); + ov_AEI(t,j,"upper") = vm_AEI.up(j); + oq41_area_irrig(t,j,"upper") = q41_area_irrig.up(j); + oq41_cost_AEI(t,i,"upper") = q41_cost_AEI.up(i); + ov_cost_AEI(t,i,"lower") = vm_cost_AEI.lo(i); + ov_AEI(t,j,"lower") = vm_AEI.lo(j); + oq41_area_irrig(t,j,"lower") = q41_area_irrig.lo(j); + oq41_cost_AEI(t,i,"lower") = q41_cost_AEI.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms index b3d5cfd224..90c87c4785 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms @@ -1,10 +1,9 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -pc41_AEI_start(j)=f41_irrig(j); - -p41_cost_AEI_past(t,i) = 0; +*' Area equipped for irrigation in initialization year +pc41_AEI_start(j) = f41_irrig("y1995",j,"%c41_initial_irrigation_area%"); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms index 6b58922cf9..a85793c06b 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,7 +6,9 @@ *** | Contact: magpie@pik-potsdam.de p41_AEI_start(t,j) = pc41_AEI_start(j); -v41_AEI.lo(j) = pc41_AEI_start(j); -pc41_cost_AEI_past(i) = p41_cost_AEI_past(t,i); +*' Updating existing capital stocks to account for depreciation +vm_AEI.lo(j) = pc41_AEI_start(j) / ((1 - s41_AEI_depreciation)**(m_timestep_length)); + +*' Unit costs for irrigation expansion pc41_unitcost_AEI(i) = f41_c_irrig(t,i); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/realization.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/realization.gms index 31191a8e1c..05470f0f5f 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/realization.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,8 +7,9 @@ *' @description This realization allows the model to endogenously decide on investments to deploy additional -*' irrigation infrastructure, i.e. to increase the area equipped for irrigation (AEI). Initial values for AEI -*' in 1995 are taken from @siebert_FAO_2007. Contraction of AEI is not possible. +*' irrigation infrastructure, i.e. to increase the area equipped for irrigation (AEI). +*' Initial values for AEI are areas that are irrigated in the initial time step in LUH3. +*' Depreciation of AEI can be set via `s41_AEI_depreciation`. *' Irrigated crop production can only take place where irrigation infrastructure is present. *' *' Unit costs per hectare for AEI expansion are derived from a World Bank study (@worldbank_irrigation_1995) @@ -27,6 +28,7 @@ *####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/41_area_equipped_for_irrigation/endo_apr13/input.gms" $Ifi "%phase%" == "equations" $include "./modules/41_area_equipped_for_irrigation/endo_apr13/equations.gms" diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/scaling.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/scaling.gms index 97152ee588..5f00b39793 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/scaling.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/scaling.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,4 +6,3 @@ *** | Contact: magpie@pik-potsdam.de vm_cost_AEI.scale(i) = 10e4; -v41_cost_AEI_annuity.scale(i) = 10e3; diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms new file mode 100644 index 0000000000..d748ef313b --- /dev/null +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + t_ini41 Time periods with area equipped for irrigation initialization data + / y1995, y2000, y2005, y2010, y2015 / + + aei41 Data source for area equipped for irrigation + / LUH3, Mehta2024_Siebert2013, Mehta2024_Meier2018 / +; diff --git a/modules/41_area_equipped_for_irrigation/input/files b/modules/41_area_equipped_for_irrigation/input/files index 91b604379e..94f0346458 100644 --- a/modules/41_area_equipped_for_irrigation/input/files +++ b/modules/41_area_equipped_for_irrigation/input/files @@ -1,2 +1,2 @@ * list of files that are required here -avl_irrig.cs2 +avl_irrig.cs3 diff --git a/modules/41_area_equipped_for_irrigation/module.gms b/modules/41_area_equipped_for_irrigation/module.gms index 51d9b1ebbb..1510f54469 100644 --- a/modules/41_area_equipped_for_irrigation/module.gms +++ b/modules/41_area_equipped_for_irrigation/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/41_area_equipped_for_irrigation/static/declarations.gms b/modules/41_area_equipped_for_irrigation/static/declarations.gms index 89a7ed574d..3c60c9e457 100644 --- a/modules/41_area_equipped_for_irrigation/static/declarations.gms +++ b/modules/41_area_equipped_for_irrigation/static/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,11 +6,11 @@ *** | Contact: magpie@pik-potsdam.de variables - vm_cost_AEI(i) Irrigation expansion costs (mio. USD04MER) + vm_cost_AEI(i) Irrigation expansion costs (mio. USD17MER) ; positive variables - v41_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) + vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) ; equations @@ -19,8 +19,8 @@ equations *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_cost_AEI(t,i,type) Irrigation expansion costs (mio. USD04MER) - ov41_AEI(t,j,type) Area equipped for irrigation in each grid cell (mio. ha) + ov_cost_AEI(t,i,type) Irrigation expansion costs (mio. USD17MER) + ov_AEI(t,j,type) Area equipped for irrigation in each grid cell (mio. ha) oq41_area_irrig(t,j,type) Irrigation area constraint (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/41_area_equipped_for_irrigation/static/equations.gms b/modules/41_area_equipped_for_irrigation/static/equations.gms index dd18dd8390..65be2664bc 100644 --- a/modules/41_area_equipped_for_irrigation/static/equations.gms +++ b/modules/41_area_equipped_for_irrigation/static/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,11 +6,11 @@ *** | Contact: magpie@pik-potsdam.de *' @equations - - q41_area_irrig(j2) .. - sum(kcr, vm_area(j2,kcr,"irrigated")) =l= v41_AEI(j2); + + q41_area_irrig(j2) .. + sum(kcr, vm_area(j2,kcr,"irrigated")) =l= vm_AEI(j2); *' This realization assures that irrigated crop production can only take place where *' irrigation infrastructure is present, i.e. the sum of irrigated cropland `vm_area(j,kcr,"irrigated")` *' over all crops in each grid cell has to be less than or equal to the area in this grid cell that is -*' equipped with irrigation infrastructure (`v41_AEI(j)`). +*' equipped with irrigation infrastructure (`vm_AEI(j)`). diff --git a/modules/41_area_equipped_for_irrigation/static/input.gms b/modules/41_area_equipped_for_irrigation/static/input.gms index a3d28658c9..c0b96c5ff4 100644 --- a/modules/41_area_equipped_for_irrigation/static/input.gms +++ b/modules/41_area_equipped_for_irrigation/static/input.gms @@ -1,15 +1,15 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -f41_irrig(j) Available area equipped for irrigation [AVL] (mio. ha) -/ +$setglobal c41_initial_irrigation_area LUH3 + +table +f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) $ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs2" +$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs3" $offdelim -/ ; diff --git a/modules/41_area_equipped_for_irrigation/static/not_used.txt b/modules/41_area_equipped_for_irrigation/static/not_used.txt index 6e0f6d3344..2411592d7e 100644 --- a/modules/41_area_equipped_for_irrigation/static/not_used.txt +++ b/modules/41_area_equipped_for_irrigation/static/not_used.txt @@ -1,8 +1,2 @@ -# | (C) 2008-2019 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 name,type,reason pm_interest, input, not needed diff --git a/modules/41_area_equipped_for_irrigation/static/postsolve.gms b/modules/41_area_equipped_for_irrigation/static/postsolve.gms index 95d4ecb02d..be4ffa4c74 100644 --- a/modules/41_area_equipped_for_irrigation/static/postsolve.gms +++ b/modules/41_area_equipped_for_irrigation/static/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,16 +8,15 @@ *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_AEI(t,i,"marginal") = vm_cost_AEI.m(i); - ov41_AEI(t,j,"marginal") = v41_AEI.m(j); + ov_AEI(t,j,"marginal") = vm_AEI.m(j); oq41_area_irrig(t,j,"marginal") = q41_area_irrig.m(j); ov_cost_AEI(t,i,"level") = vm_cost_AEI.l(i); - ov41_AEI(t,j,"level") = v41_AEI.l(j); + ov_AEI(t,j,"level") = vm_AEI.l(j); oq41_area_irrig(t,j,"level") = q41_area_irrig.l(j); ov_cost_AEI(t,i,"upper") = vm_cost_AEI.up(i); - ov41_AEI(t,j,"upper") = v41_AEI.up(j); + ov_AEI(t,j,"upper") = vm_AEI.up(j); oq41_area_irrig(t,j,"upper") = q41_area_irrig.up(j); ov_cost_AEI(t,i,"lower") = vm_cost_AEI.lo(i); - ov41_AEI(t,j,"lower") = v41_AEI.lo(j); + ov_AEI(t,j,"lower") = vm_AEI.lo(j); oq41_area_irrig(t,j,"lower") = q41_area_irrig.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/41_area_equipped_for_irrigation/static/presolve.gms b/modules/41_area_equipped_for_irrigation/static/presolve.gms index 8be74d7184..2606608a45 100644 --- a/modules/41_area_equipped_for_irrigation/static/presolve.gms +++ b/modules/41_area_equipped_for_irrigation/static/presolve.gms @@ -1,9 +1,11 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -v41_AEI.fx(j) = f41_irrig(j); +*' Area equipped for irrigation in initialization year +vm_AEI.fx(j) = f41_irrig("y1995",j,"%c41_initial_irrigation_area%"); + vm_cost_AEI.fx(i) = 0; diff --git a/modules/41_area_equipped_for_irrigation/static/realization.gms b/modules/41_area_equipped_for_irrigation/static/realization.gms index 357b35119e..cda14ec110 100644 --- a/modules/41_area_equipped_for_irrigation/static/realization.gms +++ b/modules/41_area_equipped_for_irrigation/static/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,12 +7,13 @@ *' In this realization, area equipped for irrigation is fixed to input data (around the year 2000) -*' for all time steps. The source of the input data is @siebert_FAO_2007. +*' for all time steps. The sources of the input data are @siebert_FAO_2013 and @mehta_half_2024. *' *' @limitations No irrigation is possible on areas that have not been equipped for irrigation in the past. *' *####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/41_area_equipped_for_irrigation/static/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/41_area_equipped_for_irrigation/static/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/41_area_equipped_for_irrigation/static/input.gms" $Ifi "%phase%" == "equations" $include "./modules/41_area_equipped_for_irrigation/static/equations.gms" diff --git a/modules/41_area_equipped_for_irrigation/static/sets.gms b/modules/41_area_equipped_for_irrigation/static/sets.gms new file mode 100644 index 0000000000..d748ef313b --- /dev/null +++ b/modules/41_area_equipped_for_irrigation/static/sets.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + t_ini41 Time periods with area equipped for irrigation initialization data + / y1995, y2000, y2005, y2010, y2015 / + + aei41 Data source for area equipped for irrigation + / LUH3, Mehta2024_Siebert2013, Mehta2024_Meier2018 / +; diff --git a/modules/42_water_demand/agr_sector_aug13/declarations.gms b/modules/42_water_demand/agr_sector_aug13/declarations.gms index a9bf2cab21..f2c5a88e17 100644 --- a/modules/42_water_demand/agr_sector_aug13/declarations.gms +++ b/modules/42_water_demand/agr_sector_aug13/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,27 +6,37 @@ *** | Contact: magpie@pik-potsdam.de 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) + 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_switch(iso) Switch 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 (USD17MER per m^3) + i42_watdem_total(t,j,watdem_ineldo,wtype) Non-agricultural water demand for entire year used in post-processing (mio. m^3 per yr) ; equations - q42_water_demand(wat_dem,j) Water consumption in different sectors (mio. m^3 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 (USD17MER per yr) ; positive variables vm_watdem(wat_dem,j) Water demand from different sectors (mio. m^3 per yr) v42_irrig_eff(j) Irrigation efficiency (1) + vm_water_cost(i) Cost of irrigation water (USD17MER per m^3) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_watdem(t,wat_dem,j,type) Water demand from different sectors (mio. m^3 per yr) ov42_irrig_eff(t,j,type) Irrigation efficiency (1) - oq42_water_demand(t,wat_dem,j,type) Water consumption in different sectors (mio. m^3 per yr) + ov_water_cost(t,i,type) Cost of irrigation water (USD17MER per m^3) + oq42_water_demand(t,wat_dem,j,type) Water withdrawals of different sectors (mio. m^3 per yr) + oq42_water_cost(t,i,type) Total cost of pumping irrigation water (USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/42_water_demand/agr_sector_aug13/equations.gms b/modules/42_water_demand/agr_sector_aug13/equations.gms index 77dacea753..53f0fbfb0c 100644 --- a/modules/42_water_demand/agr_sector_aug13/equations.gms +++ b/modules/42_water_demand/agr_sector_aug13/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,13 +7,15 @@ *' @equations -q42_water_demand("agriculture",j2).. +q42_water_demand("agriculture",j2) .. + vm_watdem("agriculture",j2) * v42_irrig_eff(j2) =e= + sum(kcr, vm_area(j2,kcr,"irrigated") * + ic42_wat_req_k(j2,kcr)) + + sum(kli, vm_prod(j2,kli) * ic42_wat_req_k(j2,kli) * v42_irrig_eff(j2)); - vm_watdem("agriculture",j2)*v42_irrig_eff(j2) =e= - sum(kcr, vm_area(j2,kcr,"irrigated")*ic42_wat_req_k(j2,kcr)) - + sum(kli,vm_prod(j2,kli)*ic42_wat_req_k(j2,kli)*v42_irrig_eff(j2)); + q42_water_cost(i2) .. + vm_water_cost(i2) =e= sum(cell(i2,j2), vm_watdem("agriculture",j2)) * ic42_pumping_cost(i2); *' `vm_watdem` is composed by irrigation and livestock demand uses. *' The factor `v42_irrig_eff` corresponds to the amount of water that is used -*' inefficiently in the irrigation process. - +*' inefficiently in the irrigation process. diff --git a/modules/42_water_demand/agr_sector_aug13/input.gms b/modules/42_water_demand/agr_sector_aug13/input.gms index fd6d51864d..f162099c46 100644 --- a/modules/42_water_demand/agr_sector_aug13/input.gms +++ b/modules/42_water_demand/agr_sector_aug13/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,18 +6,17 @@ *** | Contact: magpie@pik-potsdam.de scalars +s42_reserved_fraction Fraction of available water that is reserved for manufacturing electricity and domestic use (1) / 0.5 / -s42_reserved_fraction Fraction of available water that is reserved for industry electricity and domestic use (1) / 0.5 / - -s42_irrig_eff_scenario Scenario for irrigation efficiency (1) / 1 / +s42_irrig_eff_scenario Scenario for irrigation efficiency (1) / 2 / * 1: global static value * 2: regional static values from CS * 3: gdp driven increase -s42_irrigation_efficiency Value of irrigation efficiency (1) / 0.66 / +s42_irrigation_efficiency Value of irrigation efficiency (1) / 0.66 / * Only if global static value is requested -s42_env_flow_scenario EFP scenario. (1) / 2 / +s42_env_flow_scenario EFP scenario. (1) / 2 / * 0: don't consider environmental flows. * s42_env_flow_base_fraction and * s42_env_flow_fraction have no effect. @@ -29,15 +28,21 @@ s42_env_flow_scenario EFP scenario. (1) / 2 / * results and a calculation algorithm by Smakhtin 2004. * s42_env_flow_fraction has no effect. +* Linear fading in of environmental flow policy between startyear and targetyear +s42_efp_startyear Environmental flow policy start year / 2025 / +s42_efp_targetyear Environmental flow policy target year / 2040 / + s42_env_flow_base_fraction Fraction of available water that is reserved for the environment where no EFP policy is implemented (1) / 0.05 / -* (determined in the file EFR_protection_policy.csv) s42_env_flow_fraction Fraction of available water that is reserved for under protection policies (1) / 0.2 / +s42_pumping Switch to activate pumping cost settings (1) / 0 / +s42_multiplier_startyear Year from which pumping costs multiplier will be implemented (1) / 1995 / +s42_multiplier multiplier to change pumping costs for sensitivity analysis takes numeric values (1) / 0 / ; -$setglobal c42_watdem_scenario nocc -* options: cc (climate change) -* nocc (no climate change) - +$setglobal c42_watdem_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) table f42_wat_req_kve(t_all,j,kve) LPJmL annual water demand for irrigation per ha (m^3 per yr) $ondelim @@ -45,6 +50,8 @@ $include "./modules/42_water_demand/input/lpj_airrig.cs2" $offdelim ; $if "%c42_watdem_scenario%" == "nocc" f42_wat_req_kve(t_all,j,kve) = f42_wat_req_kve("y1995",j,kve); +$if "%c42_watdem_scenario%" == "nocc_hist" f42_wat_req_kve(t_all,j,kve)$(m_year(t_all) > sm_fix_cc) = f42_wat_req_kve(t_all,j,kve)$(m_year(t_all) = sm_fix_cc); + m_fillmissingyears(f42_wat_req_kve,"j,kve"); @@ -56,6 +63,9 @@ $offdelim /; +* Environmental flow policy +$setglobal c42_env_flow_policy off + parameter f42_env_flows(t_all,j) Environmental flow requirements from LPJ and Smakhtin algorithm (mio. m^3) / $ondelim @@ -63,12 +73,46 @@ $include "./modules/42_water_demand/input/lpj_envflow_grper.cs2" $offdelim /; $if "%c42_watdem_scenario%" == "nocc" f42_env_flows(t_all,j) = f42_env_flows("y1995",j); +$if "%c42_watdem_scenario%" == "nocc_hist" f42_env_flows(t_all,j)$(m_year(t_all) > sm_fix_cc) = f42_env_flows(t_all,j)$(m_year(t_all) = sm_fix_cc); m_fillmissingyears(f42_env_flows,"j"); -$setglobal c42_env_flow_policy off +* Set-switch for countries affected by EFP +* Default: all iso countries selected +sets + EFP_countries(iso) countries to be affected by EFP / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + -table f42_env_flow_policy(t_all,scen42) EFP policies (1) +* Costs of pumping are calculated for India as per methodology in forthcoming paper by Singh et.al. +parameter +f42_pumping_cost(t_all,i) Cost of pumping irrigation water (USD17MER per m^3) +/ $ondelim -$include "./modules/42_water_demand/input/f42_env_flow_policy.cs3" +$include "./modules/42_water_demand/input/f42_pumping_cost.cs4" $offdelim +/ ; diff --git a/modules/42_water_demand/agr_sector_aug13/postsolve.gms b/modules/42_water_demand/agr_sector_aug13/postsolve.gms index 020e1402c7..6feb07ff01 100644 --- a/modules/42_water_demand/agr_sector_aug13/postsolve.gms +++ b/modules/42_water_demand/agr_sector_aug13/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,14 +8,22 @@ *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_watdem(t,wat_dem,j,"marginal") = vm_watdem.m(wat_dem,j); ov42_irrig_eff(t,j,"marginal") = v42_irrig_eff.m(j); + ov_water_cost(t,i,"marginal") = vm_water_cost.m(i); oq42_water_demand(t,wat_dem,j,"marginal") = q42_water_demand.m(wat_dem,j); + oq42_water_cost(t,i,"marginal") = q42_water_cost.m(i); ov_watdem(t,wat_dem,j,"level") = vm_watdem.l(wat_dem,j); ov42_irrig_eff(t,j,"level") = v42_irrig_eff.l(j); + ov_water_cost(t,i,"level") = vm_water_cost.l(i); oq42_water_demand(t,wat_dem,j,"level") = q42_water_demand.l(wat_dem,j); + oq42_water_cost(t,i,"level") = q42_water_cost.l(i); ov_watdem(t,wat_dem,j,"upper") = vm_watdem.up(wat_dem,j); ov42_irrig_eff(t,j,"upper") = v42_irrig_eff.up(j); + ov_water_cost(t,i,"upper") = vm_water_cost.up(i); oq42_water_demand(t,wat_dem,j,"upper") = q42_water_demand.up(wat_dem,j); + oq42_water_cost(t,i,"upper") = q42_water_cost.up(i); ov_watdem(t,wat_dem,j,"lower") = vm_watdem.lo(wat_dem,j); ov42_irrig_eff(t,j,"lower") = v42_irrig_eff.lo(j); + ov_water_cost(t,i,"lower") = vm_water_cost.lo(i); oq42_water_demand(t,wat_dem,j,"lower") = q42_water_demand.lo(wat_dem,j); + oq42_water_cost(t,i,"lower") = q42_water_cost.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/42_water_demand/agr_sector_aug13/preloop.gms b/modules/42_water_demand/agr_sector_aug13/preloop.gms index 84709e7c32..e5d1775eb5 100644 --- a/modules/42_water_demand/agr_sector_aug13/preloop.gms +++ b/modules/42_water_demand/agr_sector_aug13/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -9,3 +9,9 @@ i42_wat_req_k(t,j,kve) = f42_wat_req_kve(t,j,kve); i42_env_flows(t,j) = f42_env_flows(t,j); i42_wat_req_k(t,j,kli) = f42_wat_req_kli(kli); + +* Trajectory for environmental flow policy +* (linear interpolation from start year to target year) +p42_efp(t_all,"off") = 0; +m_linear_time_interpol(p42_efp_fader, s42_efp_startyear, s42_efp_targetyear, 0, 1); +p42_efp(t_all, "on") = p42_efp_fader(t_all); diff --git a/modules/42_water_demand/agr_sector_aug13/presolve.gms b/modules/42_water_demand/agr_sector_aug13/presolve.gms index 26a57d58a6..3c10c5ed1f 100644 --- a/modules/42_water_demand/agr_sector_aug13/presolve.gms +++ b/modules/42_water_demand/agr_sector_aug13/presolve.gms @@ -1,52 +1,77 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -if (sum(sameas(t_past,t),1) = 1, - -i42_env_flow_policy(t,i) = f42_env_flow_policy(t,"off"); +* Agricultural water demand +ic42_wat_req_k(j,k) = i42_wat_req_k(t,j,k); +* Irrigation efficiency +if (m_year(t) <= sm_fix_SSP2, + v42_irrig_eff.fx(j) = 1 / (1+2.718282**((-22160-sum(cell(i,j), im_gdp_pc_mer("y1995",i))) / 37767)); else - -$ifthen "%c42_env_flow_policy%" == "mixed" i42_env_flow_policy(t,i) = im_development_state(t,i) * f42_env_flow_policy(t,"on"); -$else i42_env_flow_policy(t,i) = f42_env_flow_policy(t,"%c42_env_flow_policy%"); -$endif - + if ((s42_irrig_eff_scenario = 1), + v42_irrig_eff.fx(j) = s42_irrigation_efficiency; + Elseif (s42_irrig_eff_scenario = 2), + v42_irrig_eff.fx(j) = 1 / (1+2.718282**((-22160-sum(cell(i,j), im_gdp_pc_mer("y1995",i))) / 37767)); + Elseif (s42_irrig_eff_scenario=3), + v42_irrig_eff.fx(j) = 1 / (1+2.718282**((-22160-sum(cell(i,j), im_gdp_pc_mer(t,i))) / 37767)); + ); ); +* Pumping cost in the current time step +ic42_pumping_cost(i) = 0; -* Agricultural water demand -ic42_wat_req_k(j,k) = i42_wat_req_k(t,j,k); -ic42_env_flow_policy(i) = i42_env_flow_policy(t,i); +* Pumping cost settings will be only executed when s42_pumping is set to 1 +if ((s42_pumping = 1), + ic42_pumping_cost(i) = f42_pumping_cost(t,i); +* Pumping cost sensitivity test implmentation + if (m_year(t) > s42_multiplier_startyear, + ic42_pumping_cost(i) = f42_pumping_cost(t,i) * s42_multiplier; + ); +); -* water consumption in industry, sanitation, ecosystem -* (assign s42_reserved_fraction to industry for simplicity) -vm_watdem.fx("industry",j) = sum(wat_src, im_wat_avail(t,wat_src,j)) * s42_reserved_fraction; +* Water withdrawals in other sectors (manufacturing, electricity, domestic, ecosystem) +* (assign s42_reserved_fraction to manufacturing for simplicity) +vm_watdem.fx("manufacturing",j) = sum(wat_src, im_wat_avail(t,wat_src,j)) * s42_reserved_fraction; vm_watdem.fx("electricity",j) = 0; vm_watdem.fx("domestic",j) = 0; -*Environmental flow scenarios depending on the switch s42_env_flow_scenario +* Fill non-agricultural water demand parameter of entire year for post-processing +i42_watdem_total(t,j,watdem_ineldo,wtype) = 0; +i42_watdem_total(t,j,"manufacturing","withdrawal") = 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_switch(iso) = 0; +p42_country_switch(EFP_countries) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p42_EFP_region_shr(t_all,i) = sum(i_to_iso(i,iso), p42_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + +* Environmental policy switch: +$ifthen "%c42_env_flow_policy%" == "mixed" + i42_env_flow_policy(t,i) = (im_development_state(t,i) * p42_efp(t,"on")) * p42_EFP_region_shr(t,i) + + p42_efp(t,"off") * (1-p42_EFP_region_shr(t,i)); +$else + i42_env_flow_policy(t,i) = p42_efp(t,"%c42_env_flow_policy%") * p42_EFP_region_shr(t,i) + + p42_efp(t,"off") * (1-p42_EFP_region_shr(t,i)); +$endif + +ic42_env_flow_policy(i) = i42_env_flow_policy(t,i); + +* Environmental flow scenarios depending on the switch s42_env_flow_scenario i42_env_flows_base(t,j) = s42_env_flow_base_fraction * sum(wat_src, im_wat_avail(t,wat_src,j)); -if((s42_env_flow_scenario=0), +if ((s42_env_flow_scenario = 0), i42_env_flows_base(t,j) = 0; i42_env_flows(t,j) = 0; -Elseif(s42_env_flow_scenario=1), +Elseif (s42_env_flow_scenario = 1), i42_env_flows(t,j) = s42_env_flow_fraction * sum(wat_src, im_wat_avail(t,wat_src,j)); ); -vm_watdem.fx("ecosystem",j) = sum(cell(i,j), i42_env_flows_base(t,j) * (1-ic42_env_flow_policy(i)) + - i42_env_flows(t,j) * ic42_env_flow_policy(i)); - - -* irrigation efficiency -if((s42_irrig_eff_scenario = 1), - v42_irrig_eff.fx(j) = s42_irrigation_efficiency; -Elseif (s42_irrig_eff_scenario=2), - v42_irrig_eff.fx(j) = 1/(1+2.718282**((-22160-sum(cell(i,j),im_gdp_pc_mer("y1995",i)))/37767)); -Elseif (s42_irrig_eff_scenario=3), - v42_irrig_eff.fx(j) = 1/(1+2.718282**((-22160-sum(cell(i,j),im_gdp_pc_mer(t,i)))/37767)); -); +vm_watdem.fx("ecosystem",j) = sum(cell(i,j), i42_env_flows_base(t,j) * (1 - ic42_env_flow_policy(i)) + + i42_env_flows(t,j) * ic42_env_flow_policy(i)); diff --git a/modules/42_water_demand/agr_sector_aug13/realization.gms b/modules/42_water_demand/agr_sector_aug13/realization.gms index a7b1f6bafc..87016efd6d 100644 --- a/modules/42_water_demand/agr_sector_aug13/realization.gms +++ b/modules/42_water_demand/agr_sector_aug13/realization.gms @@ -1,11 +1,11 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 +*' @description *' *' This realization models agricultural sector water demand endogenously, while other sectors are kept exogenous; *' Various settings for environmental water demand described below. @@ -33,6 +33,7 @@ *' efficiency times management factor") from @PIK_report104_2007. *' Here, irrigated area from @siebert_FAO_2007 has been used as aggregation *' weight. +*' Contraction of AEI happens if a depreciation rate is set in the switch `s41_AEI_depreciation`. *' *' * A regression of country values of the "conveyance efficiency times *' management factor" from @PIK_report104_2007 on GDP. @@ -68,6 +69,8 @@ *' *' Whether a potential EFP policy takes effect is determined by the parameter *' `f42_env_flow_policy`. +*' The speed of transitioning to full environmental flow protection is determined +*' by specifying the start (`s42_efp_startyear`) and target (`s42_efp_targetyear`) year. *' *' @limitations The module uses the "conveyance efficiency times management *' factor" for irrigation efficiency. Therefore, the management factor is diff --git a/modules/42_water_demand/agr_sector_aug13/scaling.gms b/modules/42_water_demand/agr_sector_aug13/scaling.gms index 265c36dc60..37b26d51c1 100644 --- a/modules/42_water_demand/agr_sector_aug13/scaling.gms +++ b/modules/42_water_demand/agr_sector_aug13/scaling.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/42_water_demand/agr_sector_aug13/sets.gms b/modules/42_water_demand/agr_sector_aug13/sets.gms index c0f52c07e8..717e97ed34 100644 --- a/modules/42_water_demand/agr_sector_aug13/sets.gms +++ b/modules/42_water_demand/agr_sector_aug13/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,13 +6,19 @@ *** | Contact: magpie@pik-potsdam.de sets - watdem_exo(wat_dem) Exogenous water demands - / industry, electricity, domestic, ecosystem / + 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 / scen42_to_dev(scen42,dev) Mapping between EFP and economic development status / off . (lic, mic) - on . (hic) / + on . (hic) / + + wtype Water abstraction type + / consumption, withdrawal / ; diff --git a/modules/42_water_demand/all_sectors_aug13/declarations.gms b/modules/42_water_demand/all_sectors_aug13/declarations.gms index 4d251c43e6..91bc5d2ea5 100644 --- a/modules/42_water_demand/all_sectors_aug13/declarations.gms +++ b/modules/42_water_demand/all_sectors_aug13/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,27 +6,37 @@ *** | Contact: magpie@pik-potsdam.de parameters - i42_wat_req_k(t,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) + 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_switch(iso) Switch 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 (USD17MER per m^3) + i42_watdem_total(t,j,watdem_ineldo,wtype) Non-agricultural water demand for entire year used in post-processing (mio. m^3 per yr) ; equations - q42_water_demand(wat_dem,j) Water consumption in different sectors (mio. m^3 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 (USD17MER per yr) ; positive variables vm_watdem(wat_dem,j) Amount of water needed in different sectors (mio. m^3 per yr) v42_irrig_eff(j) Irrigation efficiency (1) + vm_water_cost(i) Cost of irrigation water (USD17MER per m^3) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_watdem(t,wat_dem,j,type) Amount of water needed in different sectors (mio. m^3 per yr) ov42_irrig_eff(t,j,type) Irrigation efficiency (1) - oq42_water_demand(t,wat_dem,j,type) Water consumption in different sectors (mio. m^3 per yr) + ov_water_cost(t,i,type) Cost of irrigation water (USD17MER per m^3) + oq42_water_demand(t,wat_dem,j,type) Water withdrawals of different sectors (mio. m^3 per yr) + oq42_water_cost(t,i,type) Total cost of pumping irrigation water (USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/42_water_demand/all_sectors_aug13/equations.gms b/modules/42_water_demand/all_sectors_aug13/equations.gms index a318ea83a0..5b98aebc7c 100644 --- a/modules/42_water_demand/all_sectors_aug13/equations.gms +++ b/modules/42_water_demand/all_sectors_aug13/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,13 +7,15 @@ *' @equations -q42_water_demand("agriculture",j2).. +q42_water_demand("agriculture",j2) .. + vm_watdem("agriculture",j2) * v42_irrig_eff(j2) =e= + sum(kcr, vm_area(j2,kcr,"irrigated") * + ic42_wat_req_k(j2,kcr)) + + sum(kli, vm_prod(j2,kli) * ic42_wat_req_k(j2,kli) * v42_irrig_eff(j2)); - vm_watdem("agriculture",j2)*v42_irrig_eff(j2) =e= - sum(kcr, vm_area(j2,kcr,"irrigated")*ic42_wat_req_k(j2,kcr)) - + sum(kli,vm_prod(j2,kli)*ic42_wat_req_k(j2,kli)*v42_irrig_eff(j2)); +q42_water_cost(i2) .. + vm_water_cost(i2) =e= sum(cell(i2,j2), vm_watdem("agriculture",j2)) * ic42_pumping_cost(i2); - -*' `vm_watdem` is composed by irrigation and livestock demand uses. -*' The factor `v42_irrig_eff` corresponds to the amount of water that is used -*' inefficiently in the irrigation process. +*' Agricultural water demand is composed by livestock water demand and +*' demand for irrigation water withdrawals. +*' The factor `v42_irrig_eff` accounts for irrigation efficiency. diff --git a/modules/42_water_demand/all_sectors_aug13/input.gms b/modules/42_water_demand/all_sectors_aug13/input.gms index 7b31fe7fa9..8090ec1aae 100644 --- a/modules/42_water_demand/all_sectors_aug13/input.gms +++ b/modules/42_water_demand/all_sectors_aug13/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,21 +6,20 @@ *** | Contact: magpie@pik-potsdam.de scalars +s42_watdem_nonagr_scenario Scenario for non agricultural water demand from WATERGAP (1) / 2 / +* 1: SSP1 +* 2: SSP2 +* 3: SSP3 -s42_watdem_nonagr_scenario Scenario for non agricultural water demand from WATERGAP (1) / 1 / -* 1: SSP 2 -* 2: A2 -* 3: B1 - -s42_irrig_eff_scenario Scenario for irrigation efficiency (1) / 1 / +s42_irrig_eff_scenario Scenario for irrigation efficiency (1) / 2 / * 1: global static value * 2: regional static values from CS * 3: gdp driven increase -s42_irrigation_efficiency Value of irrigation efficiency. (1) / 0.66 / +s42_irrigation_efficiency Value of irrigation efficiency (1) / 0.66 / * Only if global static value is requested -s42_env_flow_scenario Environmental flow protection scenario. (1) / 2 / +s42_env_flow_scenario Environmental flow protection scenario (1) / 2 / * 0: don't consider environmental flows. * s42_env_flow_base_fraction and * s42_env_flow_fraction have no effect. @@ -32,15 +31,50 @@ s42_env_flow_scenario Environmental flow protection scenario. * results and a calculation algorithm by Smakhtin 2004. * s42_env_flow_fraction has no effect. +* Linear fading in of environmental flow policy between startyear and targetyear +s42_efp_startyear Environmental flow policy start year / 2025 / +s42_efp_targetyear Environmental flow policy target year / 2040 / s42_env_flow_base_fraction Fraction of available water that is reserved for the environment if no EFR protection policy is implemented (1) / 0.05 / -* (determined in the file -* EFR_protection_policy.csv) -s42_env_flow_fraction Fraction of available water that is reserved for under protection policies (1) / 0.2 / +s42_env_flow_fraction Fraction of available water that is reserved under protection policies (1) / 0.2 / +s42_pumping Switch to activate pumping cost settings (1) / 0 / +s42_multiplier_startyear Year from which pumping costs multiplier will be implemented (1) / 1995 / +s42_multiplier multiplier to change pumping costs for sensitivity analysis takes numeric values (1) / 0 / ; -$setglobal c42_watdem_scenario nocc -* options: cc (climate change) -* nocc (no climate change) +$setglobal c42_watdem_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + +* Set-switch for countries affected by EFP +* Default: all iso countries selected +sets + EFP_countries(iso) countries to be affected by EFP / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; table f42_wat_req_kve(t_all,j,kve) LPJ annual water demand for irrigation per ha (m^3 per yr) $ondelim @@ -48,6 +82,7 @@ $include "./modules/42_water_demand/input/lpj_airrig.cs2" $offdelim ; $if "%c42_watdem_scenario%" == "nocc" f42_wat_req_kve(t_all,j,kve) = f42_wat_req_kve("y1995",j,kve); +$if "%c42_watdem_scenario%" == "nocc_hist" f42_wat_req_kve(t_all,j,kve)$(m_year(t_all) > sm_fix_cc) = f42_wat_req_kve(t_all,j,kve)$(m_year(t_all) = sm_fix_cc); m_fillmissingyears(f42_wat_req_kve,"j,kve"); parameter f42_wat_req_kli(kli) Average water requirements of livestock commodities per region per tDM per year (m^3 per yr) @@ -57,12 +92,20 @@ $include "./modules/42_water_demand/input/f42_wat_req_fao.csv" $offdelim /; -table f42_watdem_ineldo(t_all,j,scen_watdem_nonagr,watdem_ineldo) Industry electricity and domestic water demand under our socioeconomic scenarios (mio. m^3) +table f42_watdem_ineldo(t_all,j,scen_watdem_nonagr,watdem_ineldo,wtype) 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"); +m_fillmissingyears(f42_watdem_ineldo,"j,scen_watdem_nonagr,watdem_ineldo,wtype"); + +* 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,wtype) 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,wtype"); parameter f42_env_flows(t_all,j) Environmental flow requirements from LPJ and Smakhtin algorithm (mio. m^3) @@ -73,12 +116,17 @@ $offdelim / ; $if "%c42_watdem_scenario%" == "nocc" f42_env_flows(t_all,j) = f42_env_flows("y1995",j); +$if "%c42_watdem_scenario%" == "nocc_hist" f42_env_flows(t_all,j)$(m_year(t_all) > sm_fix_cc) = f42_env_flows(t_all,j)$(m_year(t_all) = sm_fix_cc); m_fillmissingyears(f42_env_flows,"j"); $setglobal c42_env_flow_policy off -table f42_env_flow_policy(t_all,scen42) EFP policies (1) +* Costs of pumping are calculated for India as per methodology in forthcoming paper by Singh et.al. +parameter +f42_pumping_cost(t_all,i) Cost of pumping irrigation water (USD17MER per m^3) +/ $ondelim -$include "./modules/42_water_demand/input/f42_env_flow_policy.cs3" +$include "./modules/42_water_demand/input/f42_pumping_cost.cs4" $offdelim +/ ; diff --git a/modules/42_water_demand/all_sectors_aug13/postsolve.gms b/modules/42_water_demand/all_sectors_aug13/postsolve.gms index 020e1402c7..6feb07ff01 100644 --- a/modules/42_water_demand/all_sectors_aug13/postsolve.gms +++ b/modules/42_water_demand/all_sectors_aug13/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,14 +8,22 @@ *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_watdem(t,wat_dem,j,"marginal") = vm_watdem.m(wat_dem,j); ov42_irrig_eff(t,j,"marginal") = v42_irrig_eff.m(j); + ov_water_cost(t,i,"marginal") = vm_water_cost.m(i); oq42_water_demand(t,wat_dem,j,"marginal") = q42_water_demand.m(wat_dem,j); + oq42_water_cost(t,i,"marginal") = q42_water_cost.m(i); ov_watdem(t,wat_dem,j,"level") = vm_watdem.l(wat_dem,j); ov42_irrig_eff(t,j,"level") = v42_irrig_eff.l(j); + ov_water_cost(t,i,"level") = vm_water_cost.l(i); oq42_water_demand(t,wat_dem,j,"level") = q42_water_demand.l(wat_dem,j); + oq42_water_cost(t,i,"level") = q42_water_cost.l(i); ov_watdem(t,wat_dem,j,"upper") = vm_watdem.up(wat_dem,j); ov42_irrig_eff(t,j,"upper") = v42_irrig_eff.up(j); + ov_water_cost(t,i,"upper") = vm_water_cost.up(i); oq42_water_demand(t,wat_dem,j,"upper") = q42_water_demand.up(wat_dem,j); + oq42_water_cost(t,i,"upper") = q42_water_cost.up(i); ov_watdem(t,wat_dem,j,"lower") = vm_watdem.lo(wat_dem,j); ov42_irrig_eff(t,j,"lower") = v42_irrig_eff.lo(j); + ov_water_cost(t,i,"lower") = vm_water_cost.lo(i); oq42_water_demand(t,wat_dem,j,"lower") = q42_water_demand.lo(wat_dem,j); + oq42_water_cost(t,i,"lower") = q42_water_cost.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/42_water_demand/all_sectors_aug13/preloop.gms b/modules/42_water_demand/all_sectors_aug13/preloop.gms index 84709e7c32..e5d1775eb5 100644 --- a/modules/42_water_demand/all_sectors_aug13/preloop.gms +++ b/modules/42_water_demand/all_sectors_aug13/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -9,3 +9,9 @@ i42_wat_req_k(t,j,kve) = f42_wat_req_kve(t,j,kve); i42_env_flows(t,j) = f42_env_flows(t,j); i42_wat_req_k(t,j,kli) = f42_wat_req_kli(kli); + +* Trajectory for environmental flow policy +* (linear interpolation from start year to target year) +p42_efp(t_all,"off") = 0; +m_linear_time_interpol(p42_efp_fader, s42_efp_startyear, s42_efp_targetyear, 0, 1); +p42_efp(t_all, "on") = p42_efp_fader(t_all); diff --git a/modules/42_water_demand/all_sectors_aug13/presolve.gms b/modules/42_water_demand/all_sectors_aug13/presolve.gms index 3d7c8d4195..4773104822 100644 --- a/modules/42_water_demand/all_sectors_aug13/presolve.gms +++ b/modules/42_water_demand/all_sectors_aug13/presolve.gms @@ -1,56 +1,88 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -if (sum(sameas(t_past,t),1) = 1, - -i42_env_flow_policy(t,i) = f42_env_flow_policy(t,"off"); +* Agricultural water demand +ic42_wat_req_k(j,k) = i42_wat_req_k(t,j,k); +* Irrigation efficiency +if (m_year(t) <= sm_fix_SSP2, + v42_irrig_eff.fx(j) = 1 / (1 + 2.718282**((-22160-sum(cell(i,j),im_gdp_pc_mer("y1995",i)))/37767)); else + if ((s42_irrig_eff_scenario = 1), + v42_irrig_eff.fx(j) = s42_irrigation_efficiency; + Elseif (s42_irrig_eff_scenario = 2), + v42_irrig_eff.fx(j) = 1 / (1 + 2.718282**((-22160-sum(cell(i,j),im_gdp_pc_mer("y1995",i)))/37767)); + Elseif (s42_irrig_eff_scenario = 3), + v42_irrig_eff.fx(j) = 1 / (1 + 2.718282**((-22160-sum(cell(i,j),im_gdp_pc_mer(t,i)))/37767)); + ); +); -$ifthen "%c42_env_flow_policy%" == "mixed" i42_env_flow_policy(t,i) = im_development_state(t,i) * f42_env_flow_policy(t,"on"); -$else i42_env_flow_policy(t,i) = f42_env_flow_policy(t,"%c42_env_flow_policy%"); -$endif -); +* Pumping cost in the current time step +ic42_pumping_cost(i) = 0; +* Pumping cost settings will be only executed when s42_pumping is set to 1 +if ((s42_pumping = 1), + ic42_pumping_cost(i) = f42_pumping_cost(t,i); +* Pumping cost sensitivity test implmentation + if(m_year(t) > s42_multiplier_startyear, + ic42_pumping_cost(i) = f42_pumping_cost(t,i) * s42_multiplier; + ); +); -* Agricultural water demand -ic42_wat_req_k(j,k) = i42_wat_req_k(t,j,k); -ic42_env_flow_policy(i) = i42_env_flow_policy(t,i); -* water consumption in industry, sanitation, ecosystem -* depends on the socioeconomic scenario -if((s42_watdem_nonagr_scenario = 1), - vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"SSP2",watdem_ineldo); -Elseif(s42_watdem_nonagr_scenario = 2), - vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"A2",watdem_ineldo); -Elseif(s42_watdem_nonagr_scenario = 3), - vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"B1",watdem_ineldo); +* Water withdrawals in manufacturing, electricity, domestic, ecosystem +* depend 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,"withdrawal"); + i42_watdem_total(t,j,watdem_ineldo,wtype) = f42_watdem_ineldo_total(t,j,"ssp2",watdem_ineldo,wtype); +else + if ((s42_watdem_nonagr_scenario = 1), + vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"ssp1",watdem_ineldo,"withdrawal"); + i42_watdem_total(t,j,watdem_ineldo,wtype) = f42_watdem_ineldo_total(t,j,"ssp1",watdem_ineldo,wtype); + Elseif (s42_watdem_nonagr_scenario = 2), + vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"ssp2",watdem_ineldo,"withdrawal"); + i42_watdem_total(t,j,watdem_ineldo,wtype) = f42_watdem_ineldo_total(t,j,"ssp2",watdem_ineldo,wtype); + Elseif (s42_watdem_nonagr_scenario = 3), + vm_watdem.fx(watdem_ineldo,j) = f42_watdem_ineldo(t,j,"ssp3",watdem_ineldo,"withdrawal"); + i42_watdem_total(t,j,watdem_ineldo,wtype) = f42_watdem_ineldo_total(t,j,"ssp3",watdem_ineldo,wtype); + ); ); -*Environmental flow scenarios depending on the switch s42_env_flow_scenario + +* Environmental flow scenarios depending on the switch s42_env_flow_scenario i42_env_flows_base(t,j) = s42_env_flow_base_fraction * sum(wat_src, im_wat_avail(t,wat_src,j)); -if((s42_env_flow_scenario=0), - i42_env_flows_base(t,j) = 0; - i42_env_flows(t,j) = 0; -Elseif(s42_env_flow_scenario=1), +if ((s42_env_flow_scenario = 0), + i42_env_flows_base(t,j) = 0; + i42_env_flows(t,j) = 0; +Elseif (s42_env_flow_scenario = 1), i42_env_flows(t,j) = s42_env_flow_fraction * sum(wat_src, im_wat_avail(t,wat_src,j)); ); -vm_watdem.fx("ecosystem",j) = sum(cell(i,j), i42_env_flows_base(t,j) * (1-ic42_env_flow_policy(i)) + - i42_env_flows(t,j) * ic42_env_flow_policy(i)); +* Country switch to determine countries for which EFP holds. +* In the default case, the EFP affects all countries when activated. +p42_country_switch(iso) = 0; +p42_country_switch(EFP_countries) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p42_EFP_region_shr(t_all,i) = sum(i_to_iso(i,iso), p42_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); +* Environmental policy switch: +$ifthen "%c42_env_flow_policy%" == "mixed" + i42_env_flow_policy(t,i) = (im_development_state(t,i) * p42_efp(t,"on")) * p42_EFP_region_shr(t,i) + + p42_efp(t,"off") * (1-p42_EFP_region_shr(t,i)); +$else + i42_env_flow_policy(t,i) = p42_efp(t,"%c42_env_flow_policy%") * p42_EFP_region_shr(t,i) + + p42_efp(t,"off") * (1-p42_EFP_region_shr(t,i)); +$endif -* irrigation efficiency -if((s42_irrig_eff_scenario = 1), - v42_irrig_eff.fx(j) = s42_irrigation_efficiency; -Elseif (s42_irrig_eff_scenario=2), - v42_irrig_eff.fx(j) = 1/(1+2.718282**((-22160-sum(cell(i,j),im_gdp_pc_mer("y1995",i)))/37767)); -Elseif (s42_irrig_eff_scenario=3), - v42_irrig_eff.fx(j) = 1/(1+2.718282**((-22160-sum(cell(i,j),im_gdp_pc_mer(t,i)))/37767)); -); +ic42_env_flow_policy(i) = i42_env_flow_policy(t,i); + +vm_watdem.fx("ecosystem",j) = sum(cell(i,j), i42_env_flows_base(t,j) * (1 - ic42_env_flow_policy(i)) + + i42_env_flows(t,j) * ic42_env_flow_policy(i)); diff --git a/modules/42_water_demand/all_sectors_aug13/realization.gms b/modules/42_water_demand/all_sectors_aug13/realization.gms index 878583155a..3e00a0b19d 100644 --- a/modules/42_water_demand/all_sectors_aug13/realization.gms +++ b/modules/42_water_demand/all_sectors_aug13/realization.gms @@ -1,15 +1,16 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 +*' @description *' -*' This realization models agricultural sector water demand endogenously, as described in the first realization, -*' Industry, electricity and domestic demand are also modelled endogenously with various scenarios; -*' Various settings (same ias in previous realization) for environmental water demand described below. +*' This realization models agricultural sector water withdrawals endogenously, +*' as described in the first realization. +*' Manufacturing, electricity and domestic demand are explicitly accounted for in various scenarios; +*' Various settings (same as in previous realization) for environmental water demand described below. *' *' *Agricultural water demand*: *' @@ -17,14 +18,14 @@ *' cropland `vm_area(j,kcr,"irrigated")` and livestock production *' `vm_prod(j,kli)`. *' -*' *Non agricultural human water demand*: +*' *Non agricultural human water withdrawals*: *' -*' For industry, electricity and domestic demand, three scenarios are available -*' on cluster level from the model by @watergap_water_2003: +*' For manufacturing, electricity and domestic withdrawals, three scenarios of the +*' WATERGAP model provided by @wada_modeling_2016 are used: *' -*' * SRES A2 (WATCH Project) -*' * SRES B1 (WATCH Project) -*' * SSP2 (ISI-MIP Project) +*' * SSP1 +*' * SSP2 +*' * SSP3 *' *' Due to the fact that MAgPIE only considers available blue water during the *' growing period of the plants ([43_water_availability]), the fraction of this @@ -43,7 +44,7 @@ *' for environmental purposes and consequently not available for agricultural *' activities (in addition to `s42_reserved_fraction`). *' * Environmental flow requirements (EFR) are calculated from LPJmL inputs -*' according to an algorithm by @smakhtin_water_2004 on cluster level. Due to +*' according to an algorithm by @smakhtin_water_2004 on cluster level. Due to *' the fact that MAgPIE only considers available blue water during the growing *' period of the plants [43_water_availability], EFR are also only calculated *' during this growing period. These are reserved in addition to @@ -51,6 +52,9 @@ *' flow protection policy, a base protection can be specified: *' `s42_env_flow_base_fraction`. It defaults to 5 % of available water. *' +*' The speed of transitioning to full environmental flow protection is determined +*' by specifying the start (`s42_efp_startyear`) and target (`s42_efp_targetyear`) year. +*' *' @limitations The module uses the "conveyance efficiency times management *' factor" for irrigation efficiency. Therefore, the management factor is *' accounted twice, since it is already considered in LPJmL water quantity used diff --git a/modules/42_water_demand/all_sectors_aug13/scaling.gms b/modules/42_water_demand/all_sectors_aug13/scaling.gms index 265c36dc60..37b26d51c1 100644 --- a/modules/42_water_demand/all_sectors_aug13/scaling.gms +++ b/modules/42_water_demand/all_sectors_aug13/scaling.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/42_water_demand/all_sectors_aug13/sets.gms b/modules/42_water_demand/all_sectors_aug13/sets.gms index 0681b20aa0..8735203cc6 100644 --- a/modules/42_water_demand/all_sectors_aug13/sets.gms +++ b/modules/42_water_demand/all_sectors_aug13/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,19 +7,21 @@ sets watdem_exo(wat_dem) Exogenous water demand - / industry, electricity, domestic, ecosystem / + / domestic, manufacturing, electricity, ecosystem / watdem_ineldo(wat_dem) Exogenous water demand subset covering humanly induced demands - / industry, electricity, domestic / + / domestic, manufacturing, electricity / scen_watdem_nonagr Scenarios for non agricultural water demand - / A2 , B1 , SSP2 / + / ISIMIP, ssp1, ssp2, ssp3 / - scen42 Environmental Flow Policy (EFP) - / off, on / + scen42 Environmental Flow Policy (EFP) + / off, on / - scen42_to_dev(scen42,dev) Mapping between EFP and economic development status - / off . (lic, mic) - on . (hic) / + scen42_to_dev(scen42,dev) Mapping between EFP and economic development status + / off . (lic, mic) + on . (hic) / + wtype Water abstraction type + / consumption, withdrawal / ; diff --git a/modules/42_water_demand/input/files b/modules/42_water_demand/input/files index fa59c9be3a..26723d5a30 100644 --- a/modules/42_water_demand/input/files +++ b/modules/42_water_demand/input/files @@ -2,5 +2,6 @@ lpj_airrig.cs2 lpj_envflow_grper.cs2 watdem_nonagr_grper.cs3 -f42_env_flow_policy.cs3 +watdem_nonagr_total.cs3 f42_wat_req_fao.csv +f42_pumping_cost.cs4 diff --git a/modules/42_water_demand/module.gms b/modules/42_water_demand/module.gms index 1f1516aebb..d13f26c409 100644 --- a/modules/42_water_demand/module.gms +++ b/modules/42_water_demand/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,14 +8,14 @@ *' @title Water demand *' *' @description The water demand module determines the water demand in the following -*' sectors: agriculture, industry, electricity, domestic and ecosystem. +*' sectors: agriculture, manufacturing, electricity, domestic and ecosystem. *' Different scenarios for different water demand and environmental flow protection are *' possible. The module receives information from the [17_production], [30_crop], [09_drivers] *' and [43_water_availability] modules. It passes information to the module [43_water_availability] *' and [11_costs]. *' -*' -*' +*' +*' *' @authors Anne Biewald, Markus Bonsch *###################### R SECTION START (MODULETYPES) ########################## diff --git a/modules/43_water_availability/module.gms b/modules/43_water_availability/module.gms index c859f307ae..42c842c64a 100644 --- a/modules/43_water_availability/module.gms +++ b/modules/43_water_availability/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/43_water_availability/total_water_aug13/declarations.gms b/modules/43_water_availability/total_water_aug13/declarations.gms index 86c6a0bcbf..39bcb0f813 100644 --- a/modules/43_water_availability/total_water_aug13/declarations.gms +++ b/modules/43_water_availability/total_water_aug13/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -9,7 +9,7 @@ parameters im_wat_avail(t,wat_src,j) Water availability (mio. m^3 per yr) ; -variables +variables v43_watavail(wat_src,j) Water available from different sources (mio. m^3 per yr) ; @@ -23,4 +23,3 @@ parameters oq43_water(t,j,type) Local seasonal water constraints (mio. m^3 per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - diff --git a/modules/43_water_availability/total_water_aug13/equations.gms b/modules/43_water_availability/total_water_aug13/equations.gms index 1b8555ce88..513561e03b 100644 --- a/modules/43_water_availability/total_water_aug13/equations.gms +++ b/modules/43_water_availability/total_water_aug13/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -14,7 +14,7 @@ *' cluster, the sum of water withdrawals in all sectors `vm_watdem` *' does not exceed available water from all sources `v43_watavail`. *' The local seasonal water constraints is the sum of the amount of water needed -*' in the sectors defined by `wat_dem` (agriculture, industry, electricity, +*' in the sectors defined by `wat_dem` (agriculture, manufacturing, electricity, *' domestic and ecosystem). This value must be lower than the sum of the Amount of *' water available from different sources in the sectors defined by `wat_src` (surface, *' ground, technical and renewable groundwater). diff --git a/modules/43_water_availability/total_water_aug13/input.gms b/modules/43_water_availability/total_water_aug13/input.gms index 1b5110e29e..4a316c2675 100644 --- a/modules/43_water_availability/total_water_aug13/input.gms +++ b/modules/43_water_availability/total_water_aug13/input.gms @@ -1,13 +1,16 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -$setglobal c43_watavail_scenario nocc -* options: cc (climate change) -* nocc (no climate change) + +$setglobal c43_watavail_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + parameters f43_wat_avail(t_all,j) Surface water available for irrigation per cell from LPJmL (mio. m^3 per yr) @@ -17,5 +20,8 @@ $include "./modules/43_water_availability/input/lpj_watavail_grper.cs2" $offdelim / ; -$if "%c43_watavail_scenario%" == "nocc" f43_wat_avail(t_all,j) = f43_wat_avail("y1995",j); +* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used +$ifthen "%c43_watavail_scenario%" == "nocc" f43_wat_avail(t_all,j) = f43_wat_avail("y1995",j); +$elseif "%c43_watavail_scenario%" == "nocc_hist" f43_wat_avail(t_all,j)$(m_year(t_all) > sm_fix_cc) = f43_wat_avail(t_all,j)$(m_year(t_all) = sm_fix_cc); +$endif m_fillmissingyears(f43_wat_avail,"j"); diff --git a/modules/43_water_availability/total_water_aug13/postsolve.gms b/modules/43_water_availability/total_water_aug13/postsolve.gms index f53ce1562d..11499365a6 100644 --- a/modules/43_water_availability/total_water_aug13/postsolve.gms +++ b/modules/43_water_availability/total_water_aug13/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/43_water_availability/total_water_aug13/preloop.gms b/modules/43_water_availability/total_water_aug13/preloop.gms index 273f81ee29..977abf2a58 100644 --- a/modules/43_water_availability/total_water_aug13/preloop.gms +++ b/modules/43_water_availability/total_water_aug13/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/43_water_availability/total_water_aug13/presolve.gms b/modules/43_water_availability/total_water_aug13/presolve.gms index 20ee54d3a1..1964e6937d 100644 --- a/modules/43_water_availability/total_water_aug13/presolve.gms +++ b/modules/43_water_availability/total_water_aug13/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/43_water_availability/total_water_aug13/realization.gms b/modules/43_water_availability/total_water_aug13/realization.gms index 53079e77f7..5d9efb17cd 100644 --- a/modules/43_water_availability/total_water_aug13/realization.gms +++ b/modules/43_water_availability/total_water_aug13/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/43_water_availability/total_water_aug13/scaling.gms b/modules/43_water_availability/total_water_aug13/scaling.gms index ea24646d6e..61617589c1 100644 --- a/modules/43_water_availability/total_water_aug13/scaling.gms +++ b/modules/43_water_availability/total_water_aug13/scaling.gms @@ -1,8 +1,8 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -v43_watavail.scale(wat_src,j) = 10e5; +v43_watavail.scale(wat_src,j) = 10e4; diff --git a/modules/44_biodiversity/bii_target/declarations.gms b/modules/44_biodiversity/bii_target/declarations.gms new file mode 100644 index 0000000000..2c4a4068c3 --- /dev/null +++ b/modules/44_biodiversity/bii_target/declarations.gms @@ -0,0 +1,41 @@ +*** | (C) 2008-2025 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 + + +positive variables + vm_cost_bv_loss(j) Biodiversity cost (mio USD17MER) + vm_bv(j,landcover44,potnatveg) Biodiversity stock for all land cover classes (Mha) + v44_bii(i,biome44) Biodiversity Intactness Index BII (1) + v44_bii_missing(i,biome44) Missing BII increase for compliance with BII target (1) +; + +parameters + p44_bii_target(t,i,biome44) Interpolated target for BII over time (1) + p44_start_value(i,biome44) Start value for BII target (1) + i44_biome_share(j,biome44) Share of biome type in each spatial unit (1) + i44_biome_area_reg(i,biome44) Area of range-rarity weighted biome type in each region (mio. ha) +; + +equations + q44_bii(i,biome44) Biodiversity Intactness Index BII (1) + q44_bii_target(i,biome44) Missing BII increase for compliance with BII target (1) + q44_cost(i) Biodiversity cost (mio USD17MER) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_bv_loss(t,j,type) Biodiversity cost (mio USD17MER) + ov_bv(t,j,landcover44,potnatveg,type) Biodiversity stock for all land cover classes (Mha) + ov44_bii(t,i,biome44,type) Biodiversity Intactness Index BII (1) + ov44_bii_missing(t,i,biome44,type) Missing BII increase for compliance with BII target (1) + oq44_bii(t,i,biome44,type) Biodiversity Intactness Index BII (1) + oq44_bii_target(t,i,biome44,type) Missing BII increase for compliance with BII target (1) + oq44_cost(t,i,type) Biodiversity cost (mio USD17MER) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/44_biodiversity/bii_target/equations.gms b/modules/44_biodiversity/bii_target/equations.gms new file mode 100644 index 0000000000..ac3fcb3808 --- /dev/null +++ b/modules/44_biodiversity/bii_target/equations.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2025 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 + +*' 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)$(i44_biome_area_reg(i2,biome44) > 0) .. + v44_bii(i2,biome44) + =e= + sum((cell(i2,j2),landcover44,potnatveg), vm_bv(j2,landcover44,potnatveg) * i44_biome_share(j2,biome44)) + / i44_biome_area_reg(i2,biome44); + +*' For each of the 71 biomes, the BII has to meet a minium level based on `s44_bii_target`. +*' `v44_bii_missing` is a technical variable to maintain feasibility in case `v44_bii` cannot be increased. + + q44_bii_target(i2,biome44) .. + v44_bii_missing(i2,biome44) =g= sum(ct, p44_bii_target(ct,i2,biome44)) - v44_bii(i2,biome44); + +*' Costs accrue only for `v44_bii_missing`. In the best case costs should be zero or close to zero. +*' Costs strongly depend on the choice of `s44_bii_target`. + + q44_cost(i2) .. sum(cell(i2,j2), vm_cost_bv_loss(j2)) =e= + sum(biome44, v44_bii_missing(i2,biome44)) * s44_cost_bii_missing; + diff --git a/modules/44_biodiversity/bii_target/input.gms b/modules/44_biodiversity/bii_target/input.gms new file mode 100644 index 0000000000..53fbc00c10 --- /dev/null +++ b/modules/44_biodiversity/bii_target/input.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 + s44_bii_target Target value for BII in target year (1) / 0 / + c44_bii_decrease Implementation of target for BII (binary) / 1 / + s44_target_year Year in which the BII target is reached (1) / 2100 / + s44_start_year Start year for interpolation towards BII target (1) / 2030 / + s44_cost_bii_missing Technical costs for missing BII increase (USD17MER per unit of BII) / 1e+06 / +; + + +table fm_bii_coeff(bii_class44,potnatveg) Biodiversity Intactness Index coefficients (unitless) +$ondelim +$include "./modules/44_biodiversity/bii_target/input/f44_bii_coeff.cs3" +$offdelim +; + +table f44_biome_area(j,biome44) Area of biome type in each spatial unit (mio. ha) +$ondelim +$include "./modules/44_biodiversity/bii_target/input/biorealm_biome.cs3" +$offdelim +; diff --git a/modules/44_biodiversity/bii_target/input/files b/modules/44_biodiversity/bii_target/input/files new file mode 100644 index 0000000000..0ad61cf22c --- /dev/null +++ b/modules/44_biodiversity/bii_target/input/files @@ -0,0 +1,3 @@ +* list of files that are required here +f44_bii_coeff.cs3 +biorealm_biome.cs3 diff --git a/modules/44_biodiversity/bii_target/postsolve.gms b/modules/44_biodiversity/bii_target/postsolve.gms new file mode 100644 index 0000000000..6a1c3f6cb9 --- /dev/null +++ b/modules/44_biodiversity/bii_target/postsolve.gms @@ -0,0 +1,38 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_bv_loss(t,j,"marginal") = vm_cost_bv_loss.m(j); + ov_bv(t,j,landcover44,potnatveg,"marginal") = vm_bv.m(j,landcover44,potnatveg); + ov44_bii(t,i,biome44,"marginal") = v44_bii.m(i,biome44); + ov44_bii_missing(t,i,biome44,"marginal") = v44_bii_missing.m(i,biome44); + oq44_bii(t,i,biome44,"marginal") = q44_bii.m(i,biome44); + oq44_bii_target(t,i,biome44,"marginal") = q44_bii_target.m(i,biome44); + oq44_cost(t,i,"marginal") = q44_cost.m(i); + ov_cost_bv_loss(t,j,"level") = vm_cost_bv_loss.l(j); + ov_bv(t,j,landcover44,potnatveg,"level") = vm_bv.l(j,landcover44,potnatveg); + ov44_bii(t,i,biome44,"level") = v44_bii.l(i,biome44); + ov44_bii_missing(t,i,biome44,"level") = v44_bii_missing.l(i,biome44); + oq44_bii(t,i,biome44,"level") = q44_bii.l(i,biome44); + oq44_bii_target(t,i,biome44,"level") = q44_bii_target.l(i,biome44); + oq44_cost(t,i,"level") = q44_cost.l(i); + ov_cost_bv_loss(t,j,"upper") = vm_cost_bv_loss.up(j); + ov_bv(t,j,landcover44,potnatveg,"upper") = vm_bv.up(j,landcover44,potnatveg); + ov44_bii(t,i,biome44,"upper") = v44_bii.up(i,biome44); + ov44_bii_missing(t,i,biome44,"upper") = v44_bii_missing.up(i,biome44); + oq44_bii(t,i,biome44,"upper") = q44_bii.up(i,biome44); + oq44_bii_target(t,i,biome44,"upper") = q44_bii_target.up(i,biome44); + oq44_cost(t,i,"upper") = q44_cost.up(i); + ov_cost_bv_loss(t,j,"lower") = vm_cost_bv_loss.lo(j); + ov_bv(t,j,landcover44,potnatveg,"lower") = vm_bv.lo(j,landcover44,potnatveg); + ov44_bii(t,i,biome44,"lower") = v44_bii.lo(i,biome44); + ov44_bii_missing(t,i,biome44,"lower") = v44_bii_missing.lo(i,biome44); + oq44_bii(t,i,biome44,"lower") = q44_bii.lo(i,biome44); + oq44_bii_target(t,i,biome44,"lower") = q44_bii_target.lo(i,biome44); + oq44_cost(t,i,"lower") = q44_cost.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/44_biodiversity/bii_target/preloop.gms b/modules/44_biodiversity/bii_target/preloop.gms new file mode 100644 index 0000000000..b8ae22b426 --- /dev/null +++ b/modules/44_biodiversity/bii_target/preloop.gms @@ -0,0 +1,21 @@ +*** | (C) 2008-2025 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 + +* Calculate biome share +i44_biome_share(j,biome44) = 0; +i44_biome_share(j,biome44)$(sum(biome44_2, f44_biome_area(j,biome44_2)) > 0) = + f44_biome_area(j,biome44) / sum(biome44_2, f44_biome_area(j,biome44_2)); + +* Set i44_biome_area_reg +i44_biome_area_reg(i,biome44) = + sum((cell(i,j),land), pcm_land(j,land) * i44_biome_share(j,biome44)); + +p44_bii_target(t,i,biome44) = 0; + +if (s44_start_year <= sm_fix_SSP2, + abort "Start year for BII target interpolation has to be greater than sm_fix_SSP2" +); diff --git a/modules/44_biodiversity/bii_target/presolve.gms b/modules/44_biodiversity/bii_target/presolve.gms new file mode 100644 index 0000000000..09beb7aace --- /dev/null +++ b/modules/44_biodiversity/bii_target/presolve.gms @@ -0,0 +1,43 @@ +*** | (C) 2008-2025 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 v44_bii.l based on vm_bv.l +loop(i, + loop(biome44, + if(i44_biome_area_reg(i,biome44) <= 0, + v44_bii.fx(i,biome44) = 0; + v44_bii_missing.fx(i,biome44) = 0; + else + v44_bii.l(i,biome44) = + sum((cell(i,j),landcover44,potnatveg), vm_bv.l(j,landcover44,potnatveg) * i44_biome_share(j,biome44)) + / i44_biome_area_reg(i,biome44); + ); + ); +); + +if (m_year(t) = s44_start_year AND s44_bii_target > 0, +* The start value for the linear interpolation is the BII at biome level in the start year. + p44_start_value(i,biome44) = v44_bii.l(i,biome44); +* The target value for the linear interpolation is the lower bound defined in `s44_bii_target`. +* Linear increase of BII target values at biome level from start year to target year, and constant values thereafter. + p44_bii_target(t2,i,biome44) = p44_start_value(i,biome44) + ((m_year(t2) - s44_start_year) / (s44_target_year - s44_start_year)) * (s44_bii_target - p44_start_value(i,biome44)); + p44_bii_target(t2,i,biome44)$(m_year(t2) > s44_target_year) = s44_bii_target; +* Avoid implausible values + p44_bii_target(t2,i,biome44)$(p44_bii_target(t2,i,biome44) >= 1) = 1; + p44_bii_target(t2,i,biome44)$(m_year(t2) < s44_start_year) = 0; + p44_bii_target(t2,i,biome44)$(i44_biome_area_reg(i,biome44) <= 0) = 0; +); + +if (m_year(t) < s44_start_year, + p44_bii_target(t,i,biome44) = 0; +else + p44_bii_target(t,i,biome44) = p44_bii_target(t,i,biome44); + if(c44_bii_decrease = 0, + p44_bii_target(t,i,biome44)$(v44_bii.l(i,biome44) >= p44_bii_target(t,i,biome44)) = v44_bii.l(i,biome44); + ); +); + diff --git a/modules/44_biodiversity/bii_target/realization.gms b/modules/44_biodiversity/bii_target/realization.gms new file mode 100644 index 0000000000..bad38e3944 --- /dev/null +++ b/modules/44_biodiversity/bii_target/realization.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 realisation, the Biodiversity Intactness Index (BII) is +*' calculated separately for each biome type of each biogeographic realm, which results in 71 different spatial units (@olson_biome_2001). +*' The BII is a relative indicator, wich measures the intactness of local species assemblages (species richness) +*' compared to a reference state (space-for-time approach) (@purvis_chapter_2018). +*' The implementation uses the BII coefficients described in @leclere_biodiv_2018 and @leclere_bending_2020. +*' The realisation allows to set a lower bound for the BII in the future, based on an annual growth rate. + +*' @limitations + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/44_biodiversity/bii_target/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/44_biodiversity/bii_target/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/44_biodiversity/bii_target/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/44_biodiversity/bii_target/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/44_biodiversity/bii_target/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/44_biodiversity/bii_target/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/44_biodiversity/bii_target/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/44_biodiversity/bii_target/sets.gms b/modules/44_biodiversity/bii_target/sets.gms new file mode 100644 index 0000000000..87712f4395 --- /dev/null +++ b/modules/44_biodiversity/bii_target/sets.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2025 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 + + landcover44 land cover classes used in bii calculation + / crop_ann, crop_per, crop_tree, crop_fallow, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / + + bii_class44 bii coefficent land cover classes + / crop_ann, crop_per, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / + + bii_class_secd(bii_class44) bii coefficent land cover classes secondary vegetation + / secd_mature, secd_young / + + ac_to_bii_class_secd(ac,bii_class_secd) Mapping between forest ageclasses and bii coefficent land cover classes + / (ac0,ac5,ac10,ac15,ac20,ac25,ac30) . (secd_young) + (ac35,ac40,ac45,ac50,ac55,ac60, + ac65,ac70,ac75,ac80,ac85,ac90, + ac95,ac100,ac105,ac110,ac115, + ac120,ac125,ac130,ac135,ac140, + ac145,ac150,ac155,ac160,ac165, + ac170,ac175,ac180,ac185,ac190, + ac195,ac200,ac205,ac210,ac215, + ac220,ac225,ac230,ac235,ac240, + ac245,ac250,ac255,ac260,ac265, + ac270,ac275,ac280,ac285,ac290, + ac295,ac300,acx) . (secd_mature) / + + biome44 biomes + / AA1,AA2,AA4,AA7,AA8,AA10,AA11,AA14,AN11,AT1,AT2,AT7,AT8,AT9,AT10,AT12,AT13,AT14,IM1, + IM2,NA4,IM3,IM13,IM14,NA3,NA8,NA11,IM4,IM5,IM7,IM9,IM10,NT2,NA13,NT1,NT9,NT98,NT99, + OC1,OC2,OC7,NT3,NT4,NT7,NT8,NT10,NT12,NT13,NT14,PA11,PA12,PA13,NA5,PA1,PA4,PA5,PA6, + PA8,PA9,PA10,AN99,AT98,NA2,NA6,NA7,NA12,NA99,PA98,PA99,AA12,AA13 / +; + +alias(biome44,biome44_2); diff --git a/modules/44_biodiversity/bv_btc_mar21/declarations.gms b/modules/44_biodiversity/bv_btc_mar21/declarations.gms new file mode 100644 index 0000000000..c1b02e3341 --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/declarations.gms @@ -0,0 +1,41 @@ +*** | (C) 2008-2025 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 + p44_price_bv_loss(t_all) Price (subsidy) for biodiversity stock loss (gain) (USD17MER per ha) + pc44_bv_weighted(j) Range-rarity weighted biodiversity stock (Mha) +; + +variables + v44_bv_loss(j) Change in biodiversity stock (Mha per year) + vm_cost_bv_loss(j) Biodiversity cost (mio USD17MER) +; + +positive variables + vm_bv(j,landcover44,potnatveg) Biodiversity stock for all land cover classes (Mha) + v44_bv_weighted(j) Range-rarity weighted biodiversity stock (Mha) +; + +equations + q44_bv_loss(j) Change in biodiversity stock (Mha per year) + q44_bv_weighted(j) Range-rarity weighted biodiversity stock (Mha) + q44_cost_bv_loss(j) Cost of biodiversity loss (mio USD17MER) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov44_bv_loss(t,j,type) Change in biodiversity stock (Mha per year) + ov_cost_bv_loss(t,j,type) Biodiversity cost (mio USD17MER) + ov_bv(t,j,landcover44,potnatveg,type) Biodiversity stock for all land cover classes (Mha) + ov44_bv_weighted(t,j,type) Range-rarity weighted biodiversity stock (Mha) + oq44_bv_loss(t,j,type) Change in biodiversity stock (Mha per year) + oq44_bv_weighted(t,j,type) Range-rarity weighted biodiversity stock (Mha) + oq44_cost_bv_loss(t,j,type) Cost of biodiversity loss (mio USD17MER) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/44_biodiversity/bv_btc_mar21/equations.gms b/modules/44_biodiversity/bv_btc_mar21/equations.gms new file mode 100644 index 0000000000..be9f36385a --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/equations.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 + +*' The net biodiversity stock change is priced. + q44_cost_bv_loss(j2) .. vm_cost_bv_loss(j2) + =e= + v44_bv_loss(j2) * sum(ct, p44_price_bv_loss(ct)); + +*' Change in biodiversity stock compared to previous time step, divided by time step length. + q44_bv_loss(j2) .. v44_bv_loss(j2) + =e= + (pc44_bv_weighted(j2) - v44_bv_weighted(j2))/m_timestep_length; + +*' Biodiversity stock weighted by range-rarity restoration prioritization layer (`f44_rr_layer`) + q44_bv_weighted(j2) .. v44_bv_weighted(j2) + =e= + f44_rr_layer(j2) * sum((potnatveg,landcover44), vm_bv(j2,landcover44,potnatveg)); + +*** EOF constraints.gms *** diff --git a/modules/44_biodiversity/bv_btc_mar21/input.gms b/modules/44_biodiversity/bv_btc_mar21/input.gms new file mode 100644 index 0000000000..b751e9804c --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/input.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 + s44_start_year Start year of biodiversity price (1) / 2030 / + s44_target_year Target year of biodiversity price (1) / 2100 / + s44_start_price Price for biodiversity stock loss in start year (USD17MER per ha) / 0 / + s44_target_price Price for biodiversity stock loss in target year (USD17MER per ha) / 0 / +; + +table fm_bii_coeff(bii_class44,potnatveg) Biodiversity Intactness Index coefficients (unitless) +$ondelim +$include "./modules/44_biodiversity/bv_btc_mar21/input/f44_bii_coeff.cs3" +$offdelim +; + +parameters +f44_rr_layer(j) Range-rarity restoration prioritization layer (unitless) +/ +$ondelim +$include "./modules/44_biodiversity/bv_btc_mar21/input/rr_layer.cs2" +$offdelim +/ diff --git a/modules/44_biodiversity/bv_btc_mar21/input/files b/modules/44_biodiversity/bv_btc_mar21/input/files new file mode 100644 index 0000000000..a68d4ecebf --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/input/files @@ -0,0 +1,3 @@ +* list of files that are required here +rr_layer.cs2 +f44_bii_coeff.cs3 diff --git a/modules/44_biodiversity/bv_btc_mar21/not_used.txt b/modules/44_biodiversity/bv_btc_mar21/not_used.txt new file mode 100644 index 0000000000..2430a1919c --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/not_used.txt @@ -0,0 +1,3 @@ +name,type,reason +pcm_land, input, not used +sm_fix_SSP2, input, not used diff --git a/modules/44_biodiversity/bv_btc_mar21/postsolve.gms b/modules/44_biodiversity/bv_btc_mar21/postsolve.gms new file mode 100644 index 0000000000..222e6f858d --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/postsolve.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2025 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 + +pc44_bv_weighted(j) = v44_bv_weighted.l(j) + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov44_bv_loss(t,j,"marginal") = v44_bv_loss.m(j); + ov_cost_bv_loss(t,j,"marginal") = vm_cost_bv_loss.m(j); + ov_bv(t,j,landcover44,potnatveg,"marginal") = vm_bv.m(j,landcover44,potnatveg); + ov44_bv_weighted(t,j,"marginal") = v44_bv_weighted.m(j); + oq44_bv_loss(t,j,"marginal") = q44_bv_loss.m(j); + oq44_bv_weighted(t,j,"marginal") = q44_bv_weighted.m(j); + oq44_cost_bv_loss(t,j,"marginal") = q44_cost_bv_loss.m(j); + ov44_bv_loss(t,j,"level") = v44_bv_loss.l(j); + ov_cost_bv_loss(t,j,"level") = vm_cost_bv_loss.l(j); + ov_bv(t,j,landcover44,potnatveg,"level") = vm_bv.l(j,landcover44,potnatveg); + ov44_bv_weighted(t,j,"level") = v44_bv_weighted.l(j); + oq44_bv_loss(t,j,"level") = q44_bv_loss.l(j); + oq44_bv_weighted(t,j,"level") = q44_bv_weighted.l(j); + oq44_cost_bv_loss(t,j,"level") = q44_cost_bv_loss.l(j); + ov44_bv_loss(t,j,"upper") = v44_bv_loss.up(j); + ov_cost_bv_loss(t,j,"upper") = vm_cost_bv_loss.up(j); + ov_bv(t,j,landcover44,potnatveg,"upper") = vm_bv.up(j,landcover44,potnatveg); + ov44_bv_weighted(t,j,"upper") = v44_bv_weighted.up(j); + oq44_bv_loss(t,j,"upper") = q44_bv_loss.up(j); + oq44_bv_weighted(t,j,"upper") = q44_bv_weighted.up(j); + oq44_cost_bv_loss(t,j,"upper") = q44_cost_bv_loss.up(j); + ov44_bv_loss(t,j,"lower") = v44_bv_loss.lo(j); + ov_cost_bv_loss(t,j,"lower") = vm_cost_bv_loss.lo(j); + ov_bv(t,j,landcover44,potnatveg,"lower") = vm_bv.lo(j,landcover44,potnatveg); + ov44_bv_weighted(t,j,"lower") = v44_bv_weighted.lo(j); + oq44_bv_loss(t,j,"lower") = q44_bv_loss.lo(j); + oq44_bv_weighted(t,j,"lower") = q44_bv_weighted.lo(j); + oq44_cost_bv_loss(t,j,"lower") = q44_cost_bv_loss.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/44_biodiversity/bv_btc_mar21/preloop.gms b/modules/44_biodiversity/bv_btc_mar21/preloop.gms new file mode 100644 index 0000000000..cff95e2784 --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/preloop.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +pc44_bv_weighted(j) = 0.3; +m_linear_time_interpol(p44_price_bv_loss,s44_start_year,s44_target_year,s44_start_price,s44_target_price); +p44_price_bv_loss(t_all)$(m_year(t_all) < s44_start_year) = 0; +display p44_price_bv_loss; diff --git a/modules/44_biodiversity/bv_btc_mar21/realization.gms b/modules/44_biodiversity/bv_btc_mar21/realization.gms new file mode 100644 index 0000000000..ec2c7423ad --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/realization.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2025 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 realisation, biodiversity stocks are computed for each land cover type by +*' multiplication with Biodiversity Intactness Index (BII) coefficients from the PREDICTS database. +*' The BII is a relative indicator, wich measures the intactness of local species assemblages (species richness) +*' compared to a reference state (space-for-time approach) (@purvis_chapter_2018). +*' In addition, a range-rarity restoration prioritization layer is used in the optimization. +*' This layer is a spatially explicit indicator of the regional relative range-rarity weighted species richness. +*' derived from the IUCN Red List of Threatened Species (@iucn_iucn_2020). +*' It indicates the global importance of a given cell for species conservation, typically of smaller range, +*' as compared to other cells. +*' Conceptually, the range-rarity weighted biodiversity stock is the product of +*' land cover area (Mha), corresponding BII coefficient [0-1] (unitless) and range-rarity layer [0-1] (unitless). +*' The net biodiversity stock loss (resp. gain) of any land-use change decision, weighted by the range-rarity layer, +*' is taxed (resp. subsidized) within the optimization. +*' The implementation uses the methodology described in @leclere_biodiv_2018 and @leclere_bending_2020. + +*' @limitations The BII indicator has been proposed as a proxy for functional diversity, but here is weighted +*' by an aggegrated conservation priority (range-rarity) layer with no clear linkage to ecosystem functioning +*' outside the priority areas (including areas that stabilise the earth system such as the Amazonas basin or the +*' boreal forest). 'Biodiversity stocks' in this realisation are estimated at cluster level, but optimised at the +*' global scale without spatial reference (besides the range-rarity weight). They are therefore theoretically +*' interchangeable across biomes or other spatial units with different biophysical conditions. +*' Scenario design and results based on this realisation should be handled with special caution, in particular +*' when applied in policy contexts. It is strongly advised to complement a positive price on biodiversity loss +*' (resp. gain) in this realization with targeted protection measures ([35_natveg]). + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/44_biodiversity/bv_btc_mar21/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/44_biodiversity/bv_btc_mar21/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/44_biodiversity/bv_btc_mar21/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/44_biodiversity/bv_btc_mar21/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/44_biodiversity/bv_btc_mar21/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/44_biodiversity/bv_btc_mar21/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/44_biodiversity/bv_btc_mar21/sets.gms b/modules/44_biodiversity/bv_btc_mar21/sets.gms new file mode 100644 index 0000000000..9e02784e66 --- /dev/null +++ b/modules/44_biodiversity/bv_btc_mar21/sets.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2025 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 + + landcover44 land cover classes used in bii calculation + / crop_ann, crop_per, crop_tree, crop_fallow, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / + + bii_class44 bii coefficent land cover classes + / crop_ann, crop_per, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / + + bii_class_secd(bii_class44) bii coefficent land cover classes secondary vegetation + / secd_mature, secd_young / + + ac_to_bii_class_secd(ac,bii_class_secd) Mapping between forest ageclasses and bii coefficent land cover classes + / (ac0,ac5,ac10,ac15,ac20,ac25,ac30) . (secd_young) + (ac35,ac40,ac45,ac50,ac55,ac60, + ac65,ac70,ac75,ac80,ac85,ac90, + ac95,ac100,ac105,ac110,ac115, + ac120,ac125,ac130,ac135,ac140, + ac145,ac150,ac155,ac160,ac165, + ac170,ac175,ac180,ac185,ac190, + ac195,ac200,ac205,ac210,ac215, + ac220,ac225,ac230,ac235,ac240, + ac245,ac250,ac255,ac260,ac265, + ac270,ac275,ac280,ac285,ac290, + ac295,ac300,acx) . (secd_mature) / + +; diff --git a/modules/44_biodiversity/module.gms b/modules/44_biodiversity/module.gms new file mode 100644 index 0000000000..15b15b591f --- /dev/null +++ b/modules/44_biodiversity/module.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2025 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 + +*' @title Biodiversity +*' +*' @description The biodiversity module estimates terrestrial biodiversity stocks for +*' all land types in MAgPIE, based on Biodiversity Intactness Index (BII) coefficients. +*' +*' +*' @authors Patrick v. Jeetze, Florian Humpenöder + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%biodiversity%" == "bii_target" $include "./modules/44_biodiversity/bii_target/realization.gms" +$Ifi "%biodiversity%" == "bv_btc_mar21" $include "./modules/44_biodiversity/bv_btc_mar21/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/45_climate/module.gms b/modules/45_climate/module.gms index 8046d47b68..2ac177a605 100644 --- a/modules/45_climate/module.gms +++ b/modules/45_climate/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/45_climate/static/declarations.gms b/modules/45_climate/static/declarations.gms deleted file mode 100644 index a292bfa35c..0000000000 --- a/modules/45_climate/static/declarations.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - pm_climate_class(j,clcl) Koeppen-Geiger climate classification on the simulation cluster level (1) -; diff --git a/modules/45_climate/static/input.gms b/modules/45_climate/static/input.gms index 339a2ce866..fd9e74fbc5 100644 --- a/modules/45_climate/static/input.gms +++ b/modules/45_climate/static/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,7 +7,7 @@ -table f45_koeppengeiger(j,clcl) Koeppen-Geiger climate classification on the simulation cluster level (1) +table pm_climate_class(j,clcl) Koeppen-Geiger climate classification on the simulation cluster level (1) $ondelim $include "./modules/45_climate/static/input/koeppen_geiger.cs3" $offdelim; diff --git a/modules/45_climate/static/preloop.gms b/modules/45_climate/static/preloop.gms deleted file mode 100644 index fa30b028bb..0000000000 --- a/modules/45_climate/static/preloop.gms +++ /dev/null @@ -1,13 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @code -*' In each cell $j$, the climate class shares $clcl$ sum up to 1. - -pm_climate_class(j,clcl) = f45_koeppengeiger(j,clcl); - -*' @stop diff --git a/modules/45_climate/static/realization.gms b/modules/45_climate/static/realization.gms index 1eecb57f88..76d01bf8d5 100644 --- a/modules/45_climate/static/realization.gms +++ b/modules/45_climate/static/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -14,7 +14,5 @@ *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/45_climate/static/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/45_climate/static/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/45_climate/static/input.gms" -$Ifi "%phase%" == "preloop" $include "./modules/45_climate/static/preloop.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/45_climate/static/sets.gms b/modules/45_climate/static/sets.gms index 2cbab5d1d6..672c1ff819 100644 --- a/modules/45_climate/static/sets.gms +++ b/modules/45_climate/static/sets.gms @@ -1,47 +1,48 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 +* mappings to simplified climate regions exist in 58_peatland and 59_som *' @code sets clcl climate classification types / - BWh "arid desert hot arid" - As "equatorial summer dry" - BSh "arid steppe hot arid" - Aw "equatorial winter dry" - Am "equatorial monsoonal" - Af "equatorial fully humid" - BWk "arid desert cold arid" - BSk "arid steppe cold arid" - Cwb "warm temperate winter dry warm summer" - Cwa "warm temperate winter dry hot summer" - Csb "warm temperate summer dry warm summer" - Csa "warm temperate summer dry hot summer" - Cfa "warm temperate fully humid hot summer" - Cfb "warm temperate fully humid warm summer" - ET "polar polar tundra" - Dfc "snow fully humid cool summer" - Dfb "snow fully humid warm summer" - Dwb "snow winter dry warm summer" - Dwc "snow winter dry cool summer" - Dfa "snow fully humid hot summer" - Cwc "warm temperate winter dry cool summer" - Dwa "snow winter dry hot summer" - EF "polar polar frost" - Cfc "warm temperate fully humid cool summer" - Dsb "snow summer dry warm summer" - Dsa "snow summer dry hot summer" - Dsc "snow summer dry cool summer" - Dfd "snow fully humid extremely continental" - Dwd "snow winter dry extremely continental" - Dsd "snow summer dry extremely continental" - Csc "warm temperate summer dry cool summer" - / + Af "Tropical rainforest climate" + Am "Tropical monsoon climate" + As "Tropical dry savanna climate" + Aw "Tropical savanna, wet" + BSh "Hot semi-arid (steppe) climate" + BSk "Cold semi-arid (steppe) climate" + BWh "Hot deserts climate" + BWk "Cold desert climate" + Cfa "Humid subtropical climate" + Cfb "Temperate oceanic climate" + Cfc "Subpolar oceanic climate" + Csa "Hot-summer Mediterranean climate" + Csb "Warm-summer Mediterranean climate" + Csc "Cool-summer Mediterranean climate" + Cwa "Monsoon-influenced humid subtropical climate" + Cwb "Dry-winter subtropical highland climate" + Cwc "Dry-winter subpolar oceanic climate" + Dfa "Hot-summer humid continental climate" + Dfb "Warm-summer humid continental climate" + Dfc "Subarctic climate" + Dfd "Extremely cold subarctic climate" + Dsa "Hot, dry-summer continental climate" + Dsb "Warm, dry-summer continental climate" + Dsc "Dry-summer subarctic climate" + Dsd "snow summer dry extremely continental" + Dwa "Monsoon-influenced hot-summer humid continental climate" + Dwb "Monsoon-influenced warm-summer humid continental climate" + Dwc "Monsoon-influenced subarctic climate" + Dwd "Monsoon-influenced extremely cold subarctic climate" + EF "Ice cap climate" + ET "Tundra" + / ; *' @stop diff --git a/modules/50_nr_soil_budget/exoeff_aug16/declarations.gms b/modules/50_nr_soil_budget/exoeff_aug16/declarations.gms deleted file mode 100644 index 5d20f6bca1..0000000000 --- a/modules/50_nr_soil_budget/exoeff_aug16/declarations.gms +++ /dev/null @@ -1,44 +0,0 @@ -*** | (C) 2008-2019 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 - - -positive variables - vm_nr_inorg_fert_reg(i,land_ag) inorganic fertilizer application (Tg N per yr) - vm_nr_inorg_fert_costs(i) cost of inorganic fertilizers (mio. USD05MER per yr) - v50_nr_eff(i) cropland nutrient uptake efficiency (Tg N per yr) - v50_nr_eff_pasture(i) pasture nutrient uptake efficiency (Tg N per yr) - v50_nr_withdrawals(i,kcr) withdrawals of Nr from soils (Tg N per yr) - v50_nr_deposition(i,land) atmospheric deposition (Tg N per yr) -; - -equations - q50_nr_cost_fert(i) fertilizer costs (mio. USD05MER per yr) - q50_nr_bal_crp(i) cropland nutrient inputs have to equal withdrawals and losses (Tg N per yr) - q50_nr_withdrawals(i,kcr) calculating nr withdrawals (Tg N per yr) - q50_nr_bal_pasture(i) nitrogen balance pasture lands (Tg N per yr) - q50_nr_deposition(i,land) atmospheric deposition (Tg N per yr) -; - -parameters - ic50_atmospheric_deposition_rates(i,land) atmospheric deposition rate (t N per ha) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_nr_inorg_fert_reg(t,i,land_ag,type) inorganic fertilizer application (Tg N per yr) - ov_nr_inorg_fert_costs(t,i,type) cost of inorganic fertilizers (mio. USD05MER per yr) - ov50_nr_eff(t,i,type) cropland nutrient uptake efficiency (Tg N per yr) - ov50_nr_eff_pasture(t,i,type) pasture nutrient uptake efficiency (Tg N per yr) - ov50_nr_withdrawals(t,i,kcr,type) withdrawals of Nr from soils (Tg N per yr) - ov50_nr_deposition(t,i,land,type) atmospheric deposition (Tg N per yr) - oq50_nr_cost_fert(t,i,type) fertilizer costs (mio. USD05MER per yr) - oq50_nr_bal_crp(t,i,type) cropland nutrient inputs have to equal withdrawals and losses (Tg N per yr) - oq50_nr_withdrawals(t,i,kcr,type) calculating nr withdrawals (Tg N per yr) - oq50_nr_bal_pasture(t,i,type) nitrogen balance pasture lands (Tg N per yr) - oq50_nr_deposition(t,i,land,type) atmospheric deposition (Tg N per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/50_nr_soil_budget/exoeff_aug16/equations.gms b/modules/50_nr_soil_budget/exoeff_aug16/equations.gms deleted file mode 100644 index f5b6e1ad97..0000000000 --- a/modules/50_nr_soil_budget/exoeff_aug16/equations.gms +++ /dev/null @@ -1,63 +0,0 @@ -*** | (C) 2008-2019 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 - - -*' For cropland the equation `q50_nr_bal_crp` balances the withdrawls (see below) with the share of all -*' incoming fluxes that can be uptaken by the crop land. Since all other inflows except `vm_nr_inorg_fert_reg` -*' are given (by other modules) this equation defines the amount of inorganic fertilizer required. - q50_nr_bal_crp(i2) .. - v50_nr_eff(i2) * - ( vm_res_recycling(i2,"nr") - + sum((cell(i2,j2),kcr,w), vm_area(j2,kcr,w) * f50_nr_fix_area(kcr)) - + vm_manure_recycling(i2,"nr") - + sum(kli, vm_manure(i2, kli, "stubble_grazing","nr")) - + vm_nr_inorg_fert_reg(i2,"crop") - + sum(cell(i2,j2),vm_nr_som(j2)) - + sum(ct,f50_nitrogen_balanceflow(ct,i2)) - + v50_nr_deposition(i2,"crop")) - =g= sum(kcr,v50_nr_withdrawals(i2,kcr)); - - -*' Withdrawls from crop land consist of nitrogen that can not be fixed by crop production -*' or by residues (above and below ground), less the nitrogen inflow from seeds. - q50_nr_withdrawals(i2,kcr) .. - v50_nr_withdrawals(i2,kcr) =e= - (1-sum(ct,f50_nr_fix_ndfa(ct,i2,kcr))) * - (vm_prod_reg(i2,kcr) * fm_attributes("nr",kcr) - + vm_res_biomass_ag(i2,kcr,"nr") - + vm_res_biomass_bg(i2,kcr,"nr")) - - vm_dem_seed(i2,kcr) * fm_attributes("nr",kcr) - ; - - -*' For pasture land the equation `q50_nr_bal_pasture` balances nitrogen discharge from pasture production -*' with the share of all inflows that can be uptaken by pasture land such as manure, plant fixation, and atmospheric deposition. -*' In contrast to crop land where the nitrogen fixation rates are crop specific (applied to -*' ton dry matter of crops produces) for paste the fixation rates are given per area. -*' Again, this equation defines the amount of inorganic fertilizer required (`vm_nr_inorg_fert_reg`), -*' since all other influxes are given (by other modules). - q50_nr_bal_pasture(i2) .. - v50_nr_eff_pasture(i2) * - (sum(kli,vm_manure(i2, kli, "grazing", "nr")) - + vm_nr_inorg_fert_reg(i2,"past") - + sum((cell(i2,j2)), vm_land(j2,"past")) * sum(ct,f50_nr_fixation_rates_pasture(ct,i2)) - + v50_nr_deposition(i2,"past")) - =g= vm_prod_reg(i2,"pasture") * fm_attributes("nr","pasture"); - -*' For both crop land and pasture land, this equation gives the amount of nitrogen deposited from the atmosphere. - q50_nr_deposition(i2,land) .. - v50_nr_deposition(i2,land) =e= - sum(cell(i2,j2),ic50_atmospheric_deposition_rates(i2,land) * vm_land(j2,land)); - -*' Having calculated the amount of nitrogen fertilizer required (see above) now the resulting cost are derived. They -*' are part of the objective function. - q50_nr_cost_fert(i2) .. - vm_nr_inorg_fert_costs(i2) =e= - sum(land_ag,vm_nr_inorg_fert_reg(i2,land_ag)) * s50_fertilizer_costs - ; diff --git a/modules/50_nr_soil_budget/exoeff_aug16/input.gms b/modules/50_nr_soil_budget/exoeff_aug16/input.gms deleted file mode 100644 index 23c1efd4ef..0000000000 --- a/modules/50_nr_soil_budget/exoeff_aug16/input.gms +++ /dev/null @@ -1,78 +0,0 @@ -*** | (C) 2008-2019 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 - -$setglobal c50_scen_neff neff60_60_starty2010 -* options: neff55_55_starty1990,neff60_60_starty1990,neff65_70_starty1990, -* neff65_70_starty2010,neff60_60_starty2010,neff55_60_starty2010, -* neff70_75_starty2010,neff75_80_starty2010,neff80_85_starty2010 -* neff75_85_starty2010 - -$setglobal c50_dep_scen history -* options: history - -scalar - s50_fertilizer_costs Costs of fertilizer (USD05MER per tN) / 600 / -; - - -parameter f50_snupe(t_all,i,scen_neff50) selected scenario values for soil nitrogen uptake efficiency (1) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_snupe.cs4" -$offdelim -/; - -parameter f50_nue_pasture(t_all,i,scen_neff50) selected scenario values for soil nitrogen uptake efficiency (1) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_nue_pasture.cs4" -$offdelim -/; - - -parameter f50_nr_fix_ndfa(t_all,i,kcr) Nr fixation rates per Nr in plant biomass (tNr per tNr) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_ndfa.cs4" -$offdelim -/; - -parameter f50_nitrogen_balanceflow(t_all,i) Balancelfow to account for unrealistically high SNUpEs on croplands (mio. tNr per yr) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_nitrogen_balanceflow.cs4" -$offdelim -/; - -parameter f50_nitrogen_balanceflow_pasture(t_all,i) Balancelfow to account for unrealistically high NUE on pastures (mio. tNr per yr) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_nitrogen_balanceflow_pasture.cs4" -$offdelim -/; - - -parameter f50_nr_fix_area(kcr) Nr fixation rates per area (tNr per ha) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_fixation_freeliving.cs4" -$offdelim -/; - -parameter f50_nr_fixation_rates_pasture(t_all,i) Nr fixation rates per pasture area (tNr per ha) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_nitrogen_fixation_rates_pasture.cs4" -$offdelim -/; - -parameter f50_atmospheric_deposition_rates(t_all,i,land,dep_scen50) Nr deposition rates per area (tNr per ha) -/ -$ondelim -$include "./modules/50_nr_soil_budget/input/f50_atmospheric_deposition_rates.cs4" -$offdelim -/; diff --git a/modules/50_nr_soil_budget/exoeff_aug16/postsolve.gms b/modules/50_nr_soil_budget/exoeff_aug16/postsolve.gms deleted file mode 100644 index 3c96c5fb56..0000000000 --- a/modules/50_nr_soil_budget/exoeff_aug16/postsolve.gms +++ /dev/null @@ -1,56 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_nr_inorg_fert_reg(t,i,land_ag,"marginal") = vm_nr_inorg_fert_reg.m(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"marginal") = vm_nr_inorg_fert_costs.m(i); - ov50_nr_eff(t,i,"marginal") = v50_nr_eff.m(i); - ov50_nr_eff_pasture(t,i,"marginal") = v50_nr_eff_pasture.m(i); - ov50_nr_withdrawals(t,i,kcr,"marginal") = v50_nr_withdrawals.m(i,kcr); - ov50_nr_deposition(t,i,land,"marginal") = v50_nr_deposition.m(i,land); - oq50_nr_cost_fert(t,i,"marginal") = q50_nr_cost_fert.m(i); - oq50_nr_bal_crp(t,i,"marginal") = q50_nr_bal_crp.m(i); - oq50_nr_withdrawals(t,i,kcr,"marginal") = q50_nr_withdrawals.m(i,kcr); - oq50_nr_bal_pasture(t,i,"marginal") = q50_nr_bal_pasture.m(i); - oq50_nr_deposition(t,i,land,"marginal") = q50_nr_deposition.m(i,land); - ov_nr_inorg_fert_reg(t,i,land_ag,"level") = vm_nr_inorg_fert_reg.l(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"level") = vm_nr_inorg_fert_costs.l(i); - ov50_nr_eff(t,i,"level") = v50_nr_eff.l(i); - ov50_nr_eff_pasture(t,i,"level") = v50_nr_eff_pasture.l(i); - ov50_nr_withdrawals(t,i,kcr,"level") = v50_nr_withdrawals.l(i,kcr); - ov50_nr_deposition(t,i,land,"level") = v50_nr_deposition.l(i,land); - oq50_nr_cost_fert(t,i,"level") = q50_nr_cost_fert.l(i); - oq50_nr_bal_crp(t,i,"level") = q50_nr_bal_crp.l(i); - oq50_nr_withdrawals(t,i,kcr,"level") = q50_nr_withdrawals.l(i,kcr); - oq50_nr_bal_pasture(t,i,"level") = q50_nr_bal_pasture.l(i); - oq50_nr_deposition(t,i,land,"level") = q50_nr_deposition.l(i,land); - ov_nr_inorg_fert_reg(t,i,land_ag,"upper") = vm_nr_inorg_fert_reg.up(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"upper") = vm_nr_inorg_fert_costs.up(i); - ov50_nr_eff(t,i,"upper") = v50_nr_eff.up(i); - ov50_nr_eff_pasture(t,i,"upper") = v50_nr_eff_pasture.up(i); - ov50_nr_withdrawals(t,i,kcr,"upper") = v50_nr_withdrawals.up(i,kcr); - ov50_nr_deposition(t,i,land,"upper") = v50_nr_deposition.up(i,land); - oq50_nr_cost_fert(t,i,"upper") = q50_nr_cost_fert.up(i); - oq50_nr_bal_crp(t,i,"upper") = q50_nr_bal_crp.up(i); - oq50_nr_withdrawals(t,i,kcr,"upper") = q50_nr_withdrawals.up(i,kcr); - oq50_nr_bal_pasture(t,i,"upper") = q50_nr_bal_pasture.up(i); - oq50_nr_deposition(t,i,land,"upper") = q50_nr_deposition.up(i,land); - ov_nr_inorg_fert_reg(t,i,land_ag,"lower") = vm_nr_inorg_fert_reg.lo(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"lower") = vm_nr_inorg_fert_costs.lo(i); - ov50_nr_eff(t,i,"lower") = v50_nr_eff.lo(i); - ov50_nr_eff_pasture(t,i,"lower") = v50_nr_eff_pasture.lo(i); - ov50_nr_withdrawals(t,i,kcr,"lower") = v50_nr_withdrawals.lo(i,kcr); - ov50_nr_deposition(t,i,land,"lower") = v50_nr_deposition.lo(i,land); - oq50_nr_cost_fert(t,i,"lower") = q50_nr_cost_fert.lo(i); - oq50_nr_bal_crp(t,i,"lower") = q50_nr_bal_crp.lo(i); - oq50_nr_withdrawals(t,i,kcr,"lower") = q50_nr_withdrawals.lo(i,kcr); - oq50_nr_bal_pasture(t,i,"lower") = q50_nr_bal_pasture.lo(i); - oq50_nr_deposition(t,i,land,"lower") = q50_nr_deposition.lo(i,land); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/50_nr_soil_budget/exoeff_aug16/presolve.gms b/modules/50_nr_soil_budget/exoeff_aug16/presolve.gms deleted file mode 100644 index 3de3af993e..0000000000 --- a/modules/50_nr_soil_budget/exoeff_aug16/presolve.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - - -v50_nr_eff.fx(i) = f50_snupe(t,i,"%c50_scen_neff%"); -v50_nr_eff_pasture.fx(i) = f50_nue_pasture(t,i,"%c50_scen_neff%"); -ic50_atmospheric_deposition_rates(i,land)=f50_atmospheric_deposition_rates(t,i,land,"%c50_dep_scen%"); diff --git a/modules/50_nr_soil_budget/exoeff_aug16/realization.gms b/modules/50_nr_soil_budget/exoeff_aug16/realization.gms deleted file mode 100644 index 93057e8411..0000000000 --- a/modules/50_nr_soil_budget/exoeff_aug16/realization.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 This realization calculates the nitrogen balance for crop land and pasture land -*' using exogenous uptake efficiencies. Several scenarios are available for the efficiency. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/50_nr_soil_budget/exoeff_aug16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/50_nr_soil_budget/exoeff_aug16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/50_nr_soil_budget/exoeff_aug16/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/50_nr_soil_budget/exoeff_aug16/equations.gms" -$Ifi "%phase%" == "presolve" $include "./modules/50_nr_soil_budget/exoeff_aug16/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/50_nr_soil_budget/exoeff_aug16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/50_nr_soil_budget/exoeff_aug16/sets.gms b/modules/50_nr_soil_budget/exoeff_aug16/sets.gms deleted file mode 100644 index 8550a0fd0e..0000000000 --- a/modules/50_nr_soil_budget/exoeff_aug16/sets.gms +++ /dev/null @@ -1,23 +0,0 @@ -*** | (C) 2008-2019 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 - -deposition_source51 Source of atmospheric deposition -/ agricultural_magpie, other_exogenous / - -scen_neff50 Scenario for uptake efficiency -/constant, -neff55_55_starty1990,neff60_60_starty1990,neff65_70_starty1990, -neff65_70_starty2010,neff60_60_starty2010,neff55_60_starty2010, -neff70_75_starty2010,neff75_80_starty2010,neff80_85_starty2010, -neff75_85_starty2010 / - -dep_scen50 Scenario for atmospheric deposition -/history/ - -; diff --git a/modules/50_nr_soil_budget/input/files b/modules/50_nr_soil_budget/input/files index 3f29edf3ac..00b47652e6 100644 --- a/modules/50_nr_soil_budget/input/files +++ b/modules/50_nr_soil_budget/input/files @@ -1,9 +1,11 @@ * list of files that are required here -f50_snupe.cs4 +f50_snupe_base.cs4 f50_nitrogen_balanceflow.cs4 f50_ndfa.cs4 f50_fixation_freeliving.cs4 -f50_atmospheric_deposition_rates.cs4 -f50_nue_pasture.cs4 +f50_nue_base_pasture.cs4 f50_nitrogen_fixation_rates_pasture.cs4 f50_nitrogen_balanceflow_pasture.cs4 +f50_NitrogenFixationRateNatural_0.5.mz +f50_AtmosphericDepositionRates_0.5.mz +f50_AtmosphericDepositionRates.cs3 diff --git a/modules/50_nr_soil_budget/macceff_aug22/declarations.gms b/modules/50_nr_soil_budget/macceff_aug22/declarations.gms new file mode 100644 index 0000000000..eb294f28cc --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/declarations.gms @@ -0,0 +1,73 @@ +*** | (C) 2008-2025 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 + + +positive variables + vm_nr_inorg_fert_reg(i,land_ag) Inorganic fertilizer application (Tg N per yr) + vm_nr_inorg_fert_costs(i) Cost of inorganic fertilizers (mio. USD17MER per yr) + vm_nr_eff(i) Cropland nutrient uptake efficiency (Tg N per yr) + vm_nr_eff_pasture(i) Pasture nutrient uptake efficiency (Tg N per yr) + v50_nr_inputs(i) Total inputs to croplands (Tg N per yr) + v50_nr_withdrawals(i,kcr) Withdrawals of Nr from cropland soils (Tg N per yr) + v50_nr_surplus_cropland(i) Total Nr surplus on cropland soils (Tg N per yr) + v50_nr_inputs_pasture(i) Total inputs to croplands (Tg N per yr) + v50_nr_withdrawals_pasture(i) Withdrawals of Nr from pasture soils (Tg N per yr) + v50_nr_surplus_pasture(i) Total Nr surplus on pasture soils (Tg N per yr) + v50_nr_deposition(i,land) Atmospheric deposition (Tg N per yr) +; + +equations + q50_nr_cost_fert(i) Fertilizer costs (mio. USD17MER per yr) + q50_nr_bal_crp(i) Cropland nutrient inputs have to equal withdrawals and losses (Tg N per yr) + q50_nr_withdrawals(i,kcr) Calculating nr withdrawals (Tg N per yr) + q50_nr_inputs(i) Calculating nr withdrawals (Tg N per yr) + q50_nr_surplus(i) Calculating nr surplus (Tg N per yr) + q50_nr_bal_pasture(i) Nitrogen balance pasture lands (Tg N per yr) + q50_nr_inputs_pasture(i) Nitrogen inputs to pastures (Tg N per yr) + q50_nr_withdrawals_pasture(i) Nitrogen withdrawals from pastures (Tg N per yr) + q50_nr_surplus_pasture(i) Nitrogen surplus on pastures (Tg N per yr) + q50_nr_deposition(i,land) Atmospheric deposition (Tg N per yr) +; + +parameters + i50_atmospheric_deposition_rates(t,j,land) Atmospheric deposition rate (t N per ha) +* country-specific scenario switch + p50_country_switch_cropneff(iso) Switch indicating whether country is affected by crop neff scenario (1) + p50_country_switch_pastneff(iso) Switch indicating whether country is affected by pasture neff scenario (1) + p50_cropneff_region_shr(t,i) Weighted share of region with regards to crop neff scenario of countries (1) + p50_pastneff_region_shr(t,i) Weighted share of region with regards to pasture neff scenario of countries (1) + i50_nr_eff_bau(t_all,i) Business as usual soil nitrogen uptake efficiency before MACCs mitigation (1) + i50_nr_eff_pasture_bau(t_all,i) Business as usual pasture nitrogen use efficiency before MACCs mitigation (1) + i50_maccs_mitigation_transf(t,i) Transformed marginal abatement cost curves to be consistent with cropland SNuPE implementaton (1) + i50_maccs_mitigation_pasture_transf(t,i) Transformed marginal abatement cost curves to be consistent with pasture NUE implementaton (1) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_nr_inorg_fert_reg(t,i,land_ag,type) Inorganic fertilizer application (Tg N per yr) + ov_nr_inorg_fert_costs(t,i,type) Cost of inorganic fertilizers (mio. USD17MER per yr) + ov_nr_eff(t,i,type) Cropland nutrient uptake efficiency (Tg N per yr) + ov_nr_eff_pasture(t,i,type) Pasture nutrient uptake efficiency (Tg N per yr) + ov50_nr_inputs(t,i,type) Total inputs to croplands (Tg N per yr) + ov50_nr_withdrawals(t,i,kcr,type) Withdrawals of Nr from cropland soils (Tg N per yr) + ov50_nr_surplus_cropland(t,i,type) Total Nr surplus on cropland soils (Tg N per yr) + ov50_nr_inputs_pasture(t,i,type) Total inputs to croplands (Tg N per yr) + ov50_nr_withdrawals_pasture(t,i,type) Withdrawals of Nr from pasture soils (Tg N per yr) + ov50_nr_surplus_pasture(t,i,type) Total Nr surplus on pasture soils (Tg N per yr) + ov50_nr_deposition(t,i,land,type) Atmospheric deposition (Tg N per yr) + oq50_nr_cost_fert(t,i,type) Fertilizer costs (mio. USD17MER per yr) + oq50_nr_bal_crp(t,i,type) Cropland nutrient inputs have to equal withdrawals and losses (Tg N per yr) + oq50_nr_withdrawals(t,i,kcr,type) Calculating nr withdrawals (Tg N per yr) + oq50_nr_inputs(t,i,type) Calculating nr withdrawals (Tg N per yr) + oq50_nr_surplus(t,i,type) Calculating nr surplus (Tg N per yr) + oq50_nr_bal_pasture(t,i,type) Nitrogen balance pasture lands (Tg N per yr) + oq50_nr_inputs_pasture(t,i,type) Nitrogen inputs to pastures (Tg N per yr) + oq50_nr_withdrawals_pasture(t,i,type) Nitrogen withdrawals from pastures (Tg N per yr) + oq50_nr_surplus_pasture(t,i,type) Nitrogen surplus on pastures (Tg N per yr) + oq50_nr_deposition(t,i,land,type) Atmospheric deposition (Tg N per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/50_nr_soil_budget/macceff_aug22/equations.gms b/modules/50_nr_soil_budget/macceff_aug22/equations.gms new file mode 100644 index 0000000000..b0055f341f --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/equations.gms @@ -0,0 +1,97 @@ +*** | (C) 2008-2025 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 + + +*' For cropland the equation `q50_nr_bal_crp` balances the withdrawals of nitrogen with the share of all +*' incoming fluxes that can be uptaken by the crop. + + q50_nr_bal_crp(i2) .. + vm_nr_eff(i2) * v50_nr_inputs(i2) + =g= sum(kcr,v50_nr_withdrawals(i2,kcr)); + +*' q50_nr_inputs sums of all nitrogen inputs applied to croplands. Organic nitrogen inputs are +*' largely predefined by other modules. +*' Inorganic fertilizers are a free variable that allow to balance the nutrient inputs with requirements. + +q50_nr_inputs(i2) .. + v50_nr_inputs(i2) =e= + vm_res_recycling(i2,"nr") + + sum((cell(i2,j2),kcr,w), vm_area(j2,kcr,w) * f50_nr_fix_area(kcr)) + + sum(cell(i2,j2),vm_fallow(j2) * f50_nr_fix_area("tece")) + + vm_manure_recycling(i2,"nr") + + sum(kli, vm_manure(i2, kli, "stubble_grazing","nr")) + + vm_nr_inorg_fert_reg(i2,"crop") + + sum(cell(i2,j2),vm_nr_som_fertilizer(j2)) + + sum(ct,f50_nitrogen_balanceflow(ct,i2)) + + v50_nr_deposition(i2,"crop"); + +*' withdrawals from cropland consist of nitrogen in the harvested crop plus nitrogen in residues (above and below ground) +*' minus the part of nitrogen which is fixed within the crop, minus nitrogen inflow from seeds. + q50_nr_withdrawals(i2,kcr) .. + v50_nr_withdrawals(i2,kcr) =e= + (1-sum(ct,f50_nr_fix_ndfa(ct,i2,kcr))) * + (vm_prod_reg(i2,kcr) * fm_attributes("nr",kcr) + + vm_res_biomass_ag(i2,kcr,"nr") + + vm_res_biomass_bg(i2,kcr,"nr")) + - vm_dem_seed(i2,kcr) * fm_attributes("nr",kcr) + ; + +*' The nitrogen surplus is defined as inputs minus withdrawals + q50_nr_surplus(i2) .. + v50_nr_surplus_cropland(i2) + =e= v50_nr_inputs(i2) + - sum(kcr, v50_nr_withdrawals(i2,kcr)); + +*' For pasture land the equation `q50_nr_bal_pasture` balances nitrogen withdrawals from pasture production +*' with the nitrogen inputs, using a nitrogen use efficiency as scenario parameter +*' (or potentially an endogenous solution). + + q50_nr_bal_pasture(i2) .. + vm_nr_eff_pasture(i2) * + v50_nr_inputs_pasture(i2) + =g= + v50_nr_withdrawals_pasture(i2); + +*' The nitrogen surplus of pastures is the difference between inputs and withdrawals: +q50_nr_surplus_pasture(i2) .. + v50_nr_surplus_pasture(i2) + =e= + v50_nr_inputs_pasture(i2) + - v50_nr_withdrawals_pasture(i2); + +*' Inputs include manure excreted during grazing, inorganic fertilizers, atmospheric deposition and biological fixation +*' In contrast to crop land where the nitrogen fixation rates are crop specific and production-dependent (applied to +*' ton dry matter of crops produces) for pastures the fixation rates are given per area. +*' Again, this equation defines the amount of inorganic fertilizer required (`vm_nr_inorg_fert_reg`), +*' since all other influxes are given by other modules. + + q50_nr_inputs_pasture(i2) .. + v50_nr_inputs_pasture(i2) + =e= + sum(kli,vm_manure(i2, kli, "grazing", "nr")) + + vm_nr_inorg_fert_reg(i2,"past") + + sum((cell(i2,j2)), vm_land(j2,"past")) * sum(ct,f50_nr_fixation_rates_pasture(ct,i2)) + + v50_nr_deposition(i2,"past"); + +*' Withdrawals include gras harvest by grazing animals and mowing + q50_nr_withdrawals_pasture(i2) .. + v50_nr_withdrawals_pasture(i2) =e= + vm_prod_reg(i2,"pasture") * fm_attributes("nr","pasture"); + +*' For both crop land and pasture land, this equation gives the amount of nitrogen deposited from the atmosphere. + q50_nr_deposition(i2,land) .. + v50_nr_deposition(i2,land) =e= + sum((ct,cell(i2,j2)),i50_atmospheric_deposition_rates(ct,j2,land) * vm_land(j2,land)); + +*' Having calculated the amount of nitrogen fertilizer required (see above) now the resulting cost are derived. They +*' are part of the objective function. + q50_nr_cost_fert(i2) .. + vm_nr_inorg_fert_costs(i2) =e= + sum(land_ag,vm_nr_inorg_fert_reg(i2,land_ag)) * s50_fertilizer_costs + ; diff --git a/modules/50_nr_soil_budget/macceff_aug22/input.gms b/modules/50_nr_soil_budget/macceff_aug22/input.gms new file mode 100644 index 0000000000..3454ed6918 --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/input.gms @@ -0,0 +1,144 @@ +*** | (C) 2008-2025 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 + +* Scenario for nr efficiency on croplands or pastures for selected (and +* respectively non-selected) countries in cropneff_countries and pastneff_countries + +$setglobal c50_scen_neff baseeff_add3_add5_add10_max65 +$setglobal c50_scen_neff_noselect baseeff_add3_add5_add10_max65 +* constant, baseeff_add3_add15_add25_max75, +* baseeff_add3_add15_add25_max65, baseeff_add3_add10_add20_max75, +* baseeff_add3_add5_add10_max65, baseeff_add3_add0_add0_max55, +* baseeff_add3_add10_add15_max75, baseeff_add3_add5_add15_max75, +* maxeff_add3_glo75_glo85, maxeff_add3_glo75_glo80, +* maxeff_add3_glo60_glo65, maxeff_add3_glo65_glo75, +* maxeff_ZhangBy2030, maxeff_ZhangBy2050 / + +$setglobal c50_scen_neff_pasture constant_min55_min60_min65 +$setglobal c50_scen_neff_pasture_noselect constant_min55_min60_min65 +* constant, constant_min55_min60_min65 + +$setglobal c50_dep_scen history +* options: history + +scalar + s50_fertilizer_costs Costs of fertilizer (USD17MER per tN) / 738 / + s50_maccs_global_ef Do maccs assume global emission factor (binary) /1/ + s50_maccs_implicit_nue_glo Global nitrogen use efficiency implicit to MACCs /0.5/ +; + +* Set-switch for countries affected by country-specific neff scenarios +* Default: all iso countries selected +sets + cropneff_countries(iso) countries to be affected by chosen crop neff scenario / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + pastneff_countries(iso) countries to be affected by chosen pasture neff scenario / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +parameter f50_snupe_base(t_all,i,scen_neff_cropland50) selected scenario values for soil nitrogen uptake efficiency (1) +/ +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_snupe_base.cs4" +$offdelim +/; + +parameter f50_nue_base_pasture(t_all,i,scen_neff_pasture50) selected scenario values for soil nitrogen uptake efficiency (1) +/ +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_nue_base_pasture.cs4" +$offdelim +/; + + +parameter f50_nr_fix_ndfa(t_all,i,kcr) Nr fixation rates per Nr in plant biomass (tNr per tNr) +/ +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_ndfa.cs4" +$offdelim +/; + +parameter f50_nitrogen_balanceflow(t_all,i) Balancelfow to account for unrealistically high SNUpEs on croplands (mio. tNr per yr) +/ +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_nitrogen_balanceflow.cs4" +$offdelim +/; + +parameter f50_nitrogen_balanceflow_pasture(t_all,i) Balancelfow to account for unrealistically high NUE on pastures (mio. tNr per yr) +/ +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_nitrogen_balanceflow_pasture.cs4" +$offdelim +/; + + +parameter f50_nr_fix_area(kcr) Nr fixation rates per area (tNr per ha) +/ +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_fixation_freeliving.cs4" +$offdelim +/; + +parameter f50_nr_fixation_rates_pasture(t_all,i) Nr fixation rates per pasture area (tNr per ha) +/ +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_nitrogen_fixation_rates_pasture.cs4" +$offdelim +/; + +table f50_atmospheric_deposition_rates(t_all,j,land,dep_scen50) Nr deposition rates per area (tNr per ha) +$ondelim +$include "./modules/50_nr_soil_budget/input/f50_AtmosphericDepositionRates.cs3" +$offdelim +; diff --git a/modules/50_nr_soil_budget/macceff_aug22/postsolve.gms b/modules/50_nr_soil_budget/macceff_aug22/postsolve.gms new file mode 100644 index 0000000000..0b4d79f7b2 --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/postsolve.gms @@ -0,0 +1,96 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_nr_inorg_fert_reg(t,i,land_ag,"marginal") = vm_nr_inorg_fert_reg.m(i,land_ag); + ov_nr_inorg_fert_costs(t,i,"marginal") = vm_nr_inorg_fert_costs.m(i); + ov_nr_eff(t,i,"marginal") = vm_nr_eff.m(i); + ov_nr_eff_pasture(t,i,"marginal") = vm_nr_eff_pasture.m(i); + ov50_nr_inputs(t,i,"marginal") = v50_nr_inputs.m(i); + ov50_nr_withdrawals(t,i,kcr,"marginal") = v50_nr_withdrawals.m(i,kcr); + ov50_nr_surplus_cropland(t,i,"marginal") = v50_nr_surplus_cropland.m(i); + ov50_nr_inputs_pasture(t,i,"marginal") = v50_nr_inputs_pasture.m(i); + ov50_nr_withdrawals_pasture(t,i,"marginal") = v50_nr_withdrawals_pasture.m(i); + ov50_nr_surplus_pasture(t,i,"marginal") = v50_nr_surplus_pasture.m(i); + ov50_nr_deposition(t,i,land,"marginal") = v50_nr_deposition.m(i,land); + oq50_nr_cost_fert(t,i,"marginal") = q50_nr_cost_fert.m(i); + oq50_nr_bal_crp(t,i,"marginal") = q50_nr_bal_crp.m(i); + oq50_nr_withdrawals(t,i,kcr,"marginal") = q50_nr_withdrawals.m(i,kcr); + oq50_nr_inputs(t,i,"marginal") = q50_nr_inputs.m(i); + oq50_nr_surplus(t,i,"marginal") = q50_nr_surplus.m(i); + oq50_nr_bal_pasture(t,i,"marginal") = q50_nr_bal_pasture.m(i); + oq50_nr_inputs_pasture(t,i,"marginal") = q50_nr_inputs_pasture.m(i); + oq50_nr_withdrawals_pasture(t,i,"marginal") = q50_nr_withdrawals_pasture.m(i); + oq50_nr_surplus_pasture(t,i,"marginal") = q50_nr_surplus_pasture.m(i); + oq50_nr_deposition(t,i,land,"marginal") = q50_nr_deposition.m(i,land); + ov_nr_inorg_fert_reg(t,i,land_ag,"level") = vm_nr_inorg_fert_reg.l(i,land_ag); + ov_nr_inorg_fert_costs(t,i,"level") = vm_nr_inorg_fert_costs.l(i); + ov_nr_eff(t,i,"level") = vm_nr_eff.l(i); + ov_nr_eff_pasture(t,i,"level") = vm_nr_eff_pasture.l(i); + ov50_nr_inputs(t,i,"level") = v50_nr_inputs.l(i); + ov50_nr_withdrawals(t,i,kcr,"level") = v50_nr_withdrawals.l(i,kcr); + ov50_nr_surplus_cropland(t,i,"level") = v50_nr_surplus_cropland.l(i); + ov50_nr_inputs_pasture(t,i,"level") = v50_nr_inputs_pasture.l(i); + ov50_nr_withdrawals_pasture(t,i,"level") = v50_nr_withdrawals_pasture.l(i); + ov50_nr_surplus_pasture(t,i,"level") = v50_nr_surplus_pasture.l(i); + ov50_nr_deposition(t,i,land,"level") = v50_nr_deposition.l(i,land); + oq50_nr_cost_fert(t,i,"level") = q50_nr_cost_fert.l(i); + oq50_nr_bal_crp(t,i,"level") = q50_nr_bal_crp.l(i); + oq50_nr_withdrawals(t,i,kcr,"level") = q50_nr_withdrawals.l(i,kcr); + oq50_nr_inputs(t,i,"level") = q50_nr_inputs.l(i); + oq50_nr_surplus(t,i,"level") = q50_nr_surplus.l(i); + oq50_nr_bal_pasture(t,i,"level") = q50_nr_bal_pasture.l(i); + oq50_nr_inputs_pasture(t,i,"level") = q50_nr_inputs_pasture.l(i); + oq50_nr_withdrawals_pasture(t,i,"level") = q50_nr_withdrawals_pasture.l(i); + oq50_nr_surplus_pasture(t,i,"level") = q50_nr_surplus_pasture.l(i); + oq50_nr_deposition(t,i,land,"level") = q50_nr_deposition.l(i,land); + ov_nr_inorg_fert_reg(t,i,land_ag,"upper") = vm_nr_inorg_fert_reg.up(i,land_ag); + ov_nr_inorg_fert_costs(t,i,"upper") = vm_nr_inorg_fert_costs.up(i); + ov_nr_eff(t,i,"upper") = vm_nr_eff.up(i); + ov_nr_eff_pasture(t,i,"upper") = vm_nr_eff_pasture.up(i); + ov50_nr_inputs(t,i,"upper") = v50_nr_inputs.up(i); + ov50_nr_withdrawals(t,i,kcr,"upper") = v50_nr_withdrawals.up(i,kcr); + ov50_nr_surplus_cropland(t,i,"upper") = v50_nr_surplus_cropland.up(i); + ov50_nr_inputs_pasture(t,i,"upper") = v50_nr_inputs_pasture.up(i); + ov50_nr_withdrawals_pasture(t,i,"upper") = v50_nr_withdrawals_pasture.up(i); + ov50_nr_surplus_pasture(t,i,"upper") = v50_nr_surplus_pasture.up(i); + ov50_nr_deposition(t,i,land,"upper") = v50_nr_deposition.up(i,land); + oq50_nr_cost_fert(t,i,"upper") = q50_nr_cost_fert.up(i); + oq50_nr_bal_crp(t,i,"upper") = q50_nr_bal_crp.up(i); + oq50_nr_withdrawals(t,i,kcr,"upper") = q50_nr_withdrawals.up(i,kcr); + oq50_nr_inputs(t,i,"upper") = q50_nr_inputs.up(i); + oq50_nr_surplus(t,i,"upper") = q50_nr_surplus.up(i); + oq50_nr_bal_pasture(t,i,"upper") = q50_nr_bal_pasture.up(i); + oq50_nr_inputs_pasture(t,i,"upper") = q50_nr_inputs_pasture.up(i); + oq50_nr_withdrawals_pasture(t,i,"upper") = q50_nr_withdrawals_pasture.up(i); + oq50_nr_surplus_pasture(t,i,"upper") = q50_nr_surplus_pasture.up(i); + oq50_nr_deposition(t,i,land,"upper") = q50_nr_deposition.up(i,land); + ov_nr_inorg_fert_reg(t,i,land_ag,"lower") = vm_nr_inorg_fert_reg.lo(i,land_ag); + ov_nr_inorg_fert_costs(t,i,"lower") = vm_nr_inorg_fert_costs.lo(i); + ov_nr_eff(t,i,"lower") = vm_nr_eff.lo(i); + ov_nr_eff_pasture(t,i,"lower") = vm_nr_eff_pasture.lo(i); + ov50_nr_inputs(t,i,"lower") = v50_nr_inputs.lo(i); + ov50_nr_withdrawals(t,i,kcr,"lower") = v50_nr_withdrawals.lo(i,kcr); + ov50_nr_surplus_cropland(t,i,"lower") = v50_nr_surplus_cropland.lo(i); + ov50_nr_inputs_pasture(t,i,"lower") = v50_nr_inputs_pasture.lo(i); + ov50_nr_withdrawals_pasture(t,i,"lower") = v50_nr_withdrawals_pasture.lo(i); + ov50_nr_surplus_pasture(t,i,"lower") = v50_nr_surplus_pasture.lo(i); + ov50_nr_deposition(t,i,land,"lower") = v50_nr_deposition.lo(i,land); + oq50_nr_cost_fert(t,i,"lower") = q50_nr_cost_fert.lo(i); + oq50_nr_bal_crp(t,i,"lower") = q50_nr_bal_crp.lo(i); + oq50_nr_withdrawals(t,i,kcr,"lower") = q50_nr_withdrawals.lo(i,kcr); + oq50_nr_inputs(t,i,"lower") = q50_nr_inputs.lo(i); + oq50_nr_surplus(t,i,"lower") = q50_nr_surplus.lo(i); + oq50_nr_bal_pasture(t,i,"lower") = q50_nr_bal_pasture.lo(i); + oq50_nr_inputs_pasture(t,i,"lower") = q50_nr_inputs_pasture.lo(i); + oq50_nr_withdrawals_pasture(t,i,"lower") = q50_nr_withdrawals_pasture.lo(i); + oq50_nr_surplus_pasture(t,i,"lower") = q50_nr_surplus_pasture.lo(i); + oq50_nr_deposition(t,i,land,"lower") = q50_nr_deposition.lo(i,land); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/50_nr_soil_budget/macceff_aug22/preloop.gms b/modules/50_nr_soil_budget/macceff_aug22/preloop.gms new file mode 100644 index 0000000000..f4136a3901 --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/preloop.gms @@ -0,0 +1,44 @@ +*** | (C) 2008-2025 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 + + + +* Country switches to determine countries for which chosen Neff scenario +* shall be applied. +* In the default case, the scenarios affects all countries when activated. +p50_country_switch_cropneff(iso) = 0; +p50_country_switch_cropneff(cropneff_countries) = 1; +p50_country_switch_pastneff(iso) = 0; +p50_country_switch_pastneff(pastneff_countries) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p50_cropneff_region_shr(t,i) = sum(i_to_iso(i,iso), p50_country_switch_cropneff(iso) * im_pop_iso(t,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t,iso)); +p50_pastneff_region_shr(t,i) = sum(i_to_iso(i,iso), p50_country_switch_pastneff(iso) * im_pop_iso(t,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t,iso)); + +* Nitrogen use efficiency +loop(t, + + if(m_year(t) <= sm_fix_SSP2, + + i50_nr_eff_bau(t,i) = f50_snupe_base(t,i,"baseeff_add3_add5_add10_max65") * p50_cropneff_region_shr(t,i) + + f50_snupe_base(t,i,"baseeff_add3_add5_add10_max65") * (1-p50_cropneff_region_shr(t,i)); + i50_nr_eff_pasture_bau(t,i) = f50_nue_base_pasture(t,i,"constant_min55_min60_min65") * p50_pastneff_region_shr(t,i) + + f50_nue_base_pasture(t,i,"constant_min55_min60_min65") * (1-p50_pastneff_region_shr(t,i)); + + else + + i50_nr_eff_bau(t,i) = f50_snupe_base(t,i,"%c50_scen_neff%") * p50_cropneff_region_shr(t,i) + + f50_snupe_base(t,i,"%c50_scen_neff_noselect%") * (1-p50_cropneff_region_shr(t,i)); + i50_nr_eff_pasture_bau(t,i) = f50_nue_base_pasture(t,i,"%c50_scen_neff_pasture%") * p50_pastneff_region_shr(t,i) + + f50_nue_base_pasture(t,i,"%c50_scen_neff_pasture_noselect%") * (1-p50_pastneff_region_shr(t,i)); + + ); +); + +* selecting the scenario for atmospheric deposition + i50_atmospheric_deposition_rates(t,j,land)=f50_atmospheric_deposition_rates(t,j,land,"%c50_dep_scen%"); diff --git a/modules/50_nr_soil_budget/macceff_aug22/presolve.gms b/modules/50_nr_soil_budget/macceff_aug22/presolve.gms new file mode 100644 index 0000000000..88c804f96f --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/presolve.gms @@ -0,0 +1,79 @@ +*** | (C) 2008-2025 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 + +*' @code +*' We first need to transform the MACC curves from a format where they are a function +*' of inputs (approach 1, IPCC) to a function of losses (approach 2, MAgPIE). +*' Approach 2 is more consistent, as emissions can only come from losses, and +*' in the case of nitrogen use efficiency (NUE=I/H), losses (L=I-H) are zero, +*' but approach 1 would still come up with positive emissions. +*' The two approaches (see module 51_nitrogen) are +*' +*' (1) E_1 = I_1 * EF * (1 - MACCs_O) +*' +*' (2) E_2 = I_2 * (1 - NUE_2) / (1 - NUE_ef) * EF +*' +*' with the further condition: +*' +*' (3) H = I_i * NUE_i +*' +*' (4) (1 - NUE_2) = (1 - NUE_b) * (1 - MACCs_T) +*' +*' E: emissions, I: nutrient inputs, EF: emission factor, +*' NUE: nitrogen use efficiency, H: harvested N +*' NUE_ef: the nitrogen use efficiency for which the EF is made +*' NUE_2: nitrogen use efficiency in our model +*' NUE_b: baseline nitrogen use efficiency before application of MACCs +*' MACCs_O: original MACCs to be applied on fertilizer application +*' MACCs_T: transformed MACCs to be applied on nitrogen surplus +*' +*' We want to derive Maccs_T under the condition that the measured reduction of +*' emissions (R = E / Eb) in both approaches remains equal. +*' combining 1 + 3 and 2 + 3 + +*' (4) R_1 = H / NUE_b * EF * (1 - MACCs_O) / (H / NUE_b * EF) +*' (5) R_2 = (H / NUE2 * (1 - NUE2) / (1 - NUE_ef) * EF) / (H / NUE_b * (1 - NUE_b) / (1 - NUE_ef) * EF) +*' (4+5) MACCs_T = MACCs_O * NUE_b / (1 + MACCs_O * (NUE_b - 1)) + +*' If the MACCs are expressed relative to a changing emission factor, this could +*' be accomodated in equation 4. Currently we assume a constant emission factor +*' implicit to the MACCs. +*' The year of NUE_ef should be fixed to the baseyear efficiency, as +*' alternative "baseline" improvements would otherwise not reduce the +*' mitigation potential of the MACCs. +*' If the MACCs relate to a global emission factor NUE_ef should be the global +*' NUE, otherwise the regional NUE. +*' The name of the MACC category "inorg_fert_n2o" actually includes all types +*' of soil N2O emissions. Most of these measures also reduce general Nr surpluses. +*' We therefor apply it here to Nr soil efficiency more generally. + +if(s50_maccs_global_ef = 1, + i50_maccs_mitigation_transf(t,i) = + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct")*s50_maccs_implicit_nue_glo / (1 + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct") * (s50_maccs_implicit_nue_glo - 1)); + i50_maccs_mitigation_pasture_transf(t,i) = + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct")*s50_maccs_implicit_nue_glo / (1 + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct") * (s50_maccs_implicit_nue_glo - 1)); +else + i50_maccs_mitigation_transf(t,i) = + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct")*i50_nr_eff_bau("y2010",i) / (1 + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct") * (i50_nr_eff_bau("y2010",i) - 1)); + i50_maccs_mitigation_pasture_transf(t,i) = + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct")*i50_nr_eff_pasture_bau("y2010",i) / (1 + im_maccs_mitigation(t,i,"inorg_fert","n2o_n_direct") * (i50_nr_eff_pasture_bau("y2010",i) - 1)); +); + +*' After transformation of the MACCs, we can calculate NUE_2 (vm_nr_eff) as the +*' result of a baseline NUE improvement and an MACC-driven further increase of NUE. +*' The nitrogen use efficiency is the inverse of the nitrogen loss share. +*' The loss share is estimated as a baseline loss share that describes the +*' baseline technological improvement of NUE, and a reduction of this loss +*' share by technical mitigation. +*' We assume that the MACCs reduce the remaining losses proportional, so that +*' emissions cannot become negative, and the baseline improvement reduces the +*' mitigation potential of the MACCs. + + vm_nr_eff.fx(i) = 1 - (1-i50_nr_eff_bau(t,i)) * (1 - i50_maccs_mitigation_transf(t,i)); + vm_nr_eff_pasture.fx(i)= 1 - (1-i50_nr_eff_pasture_bau(t,i)) * (1 - i50_maccs_mitigation_pasture_transf(t,i)); + +*' @stop diff --git a/modules/50_nr_soil_budget/macceff_aug22/realization.gms b/modules/50_nr_soil_budget/macceff_aug22/realization.gms new file mode 100644 index 0000000000..39a05c2a40 --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/realization.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 This realization calculates the nitrogen balance for crop land and pasture land +*' using exogenous uptake efficiencies. Several scenarios are available for the efficiency. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/50_nr_soil_budget/macceff_aug22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/50_nr_soil_budget/macceff_aug22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/50_nr_soil_budget/macceff_aug22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/50_nr_soil_budget/macceff_aug22/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/50_nr_soil_budget/macceff_aug22/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/50_nr_soil_budget/macceff_aug22/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/50_nr_soil_budget/macceff_aug22/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/50_nr_soil_budget/macceff_aug22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/50_nr_soil_budget/macceff_aug22/scaling.gms b/modules/50_nr_soil_budget/macceff_aug22/scaling.gms new file mode 100644 index 0000000000..2929ec5cd7 --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_nr_inorg_fert_costs.scale(i) = 10e4; diff --git a/modules/50_nr_soil_budget/macceff_aug22/sets.gms b/modules/50_nr_soil_budget/macceff_aug22/sets.gms new file mode 100644 index 0000000000..1fa8c0dda6 --- /dev/null +++ b/modules/50_nr_soil_budget/macceff_aug22/sets.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2025 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 + +deposition_source51 Source of atmospheric deposition +/ agricultural_magpie, other_exogenous / + +scen_neff_cropland50 Scenario for SNUpE on croplands +/ constant, baseeff_add3_add15_add25_max75, +baseeff_add3_add15_add25_max65, baseeff_add3_add10_add20_max75, +baseeff_add3_add5_add10_max65, baseeff_add3_add0_add0_max55, +baseeff_add3_add10_add15_max75, baseeff_add3_add5_add15_max75, +maxeff_add3_glo75_glo85, maxeff_add3_glo75_glo80, +maxeff_add3_glo60_glo65, maxeff_add3_glo65_glo75, +maxeff_ZhangBy2030, maxeff_ZhangBy2050 / + +scen_neff_pasture50 Scenario for NUE on pastures +/constant, constant_min55_min60_min65/ + +dep_scen50 Scenario for atmospheric deposition +/history/ + +; diff --git a/modules/50_nr_soil_budget/module.gms b/modules/50_nr_soil_budget/module.gms index de1a390571..3fcb09fc3b 100644 --- a/modules/50_nr_soil_budget/module.gms +++ b/modules/50_nr_soil_budget/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -13,6 +13,5 @@ *' @authors Benjamin Bodirsky *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%nr_soil_budget%" == "exoeff_aug16" $include "./modules/50_nr_soil_budget/exoeff_aug16/realization.gms" -$Ifi "%nr_soil_budget%" == "off" $include "./modules/50_nr_soil_budget/off/realization.gms" +$Ifi "%nr_soil_budget%" == "macceff_aug22" $include "./modules/50_nr_soil_budget/macceff_aug22/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/50_nr_soil_budget/off/declarations.gms b/modules/50_nr_soil_budget/off/declarations.gms deleted file mode 100644 index 601711a496..0000000000 --- a/modules/50_nr_soil_budget/off/declarations.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 - -positive variables - - vm_nr_inorg_fert_reg(i,land_ag) inorganic fertilizer application (Tg N per yr) - vm_nr_inorg_fert_costs(i) cost of inorganic fertiliuers (mio. USD05MER per yr) - -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_nr_inorg_fert_reg(t,i,land_ag,type) inorganic fertilizer application (Tg N per yr) - ov_nr_inorg_fert_costs(t,i,type) cost of inorganic fertiliuers (mio. USD05MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/50_nr_soil_budget/off/not_used.txt b/modules/50_nr_soil_budget/off/not_used.txt deleted file mode 100644 index 3c321a35e4..0000000000 --- a/modules/50_nr_soil_budget/off/not_used.txt +++ /dev/null @@ -1,19 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason -vm_nr_som, input, not needed -vm_area,input,not needed -vm_manure,input, not needed -vm_manure_recycling,input, not needed -vm_res_recycling,input, not needed -vm_res_biomass_ag,input, not needed -vm_res_biomass_bg,input, not needed -fm_attributes,input, not needed -vm_prod_reg,input, not needed -vm_dem_seed,input, not needed -vm_land,input,questionnaire diff --git a/modules/50_nr_soil_budget/off/postsolve.gms b/modules/50_nr_soil_budget/off/postsolve.gms deleted file mode 100644 index b403fd214f..0000000000 --- a/modules/50_nr_soil_budget/off/postsolve.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_nr_inorg_fert_reg(t,i,land_ag,"marginal") = vm_nr_inorg_fert_reg.m(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"marginal") = vm_nr_inorg_fert_costs.m(i); - ov_nr_inorg_fert_reg(t,i,land_ag,"level") = vm_nr_inorg_fert_reg.l(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"level") = vm_nr_inorg_fert_costs.l(i); - ov_nr_inorg_fert_reg(t,i,land_ag,"upper") = vm_nr_inorg_fert_reg.up(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"upper") = vm_nr_inorg_fert_costs.up(i); - ov_nr_inorg_fert_reg(t,i,land_ag,"lower") = vm_nr_inorg_fert_reg.lo(i,land_ag); - ov_nr_inorg_fert_costs(t,i,"lower") = vm_nr_inorg_fert_costs.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/50_nr_soil_budget/off/preloop.gms b/modules/50_nr_soil_budget/off/preloop.gms deleted file mode 100644 index d6c1688407..0000000000 --- a/modules/50_nr_soil_budget/off/preloop.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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_nr_inorg_fert_reg.fx(i,land_ag) = 0; -vm_nr_inorg_fert_costs.fx(i) = 0; diff --git a/modules/50_nr_soil_budget/off/realization.gms b/modules/50_nr_soil_budget/off/realization.gms deleted file mode 100644 index ce949b4d8c..0000000000 --- a/modules/50_nr_soil_budget/off/realization.gms +++ /dev/null @@ -1,14 +0,0 @@ -*** | (C) 2008-2019 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 This realization sets the demand for inorganic fertilizer and associated costs to zero. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/50_nr_soil_budget/off/declarations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/50_nr_soil_budget/off/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/50_nr_soil_budget/off/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/51_nitrogen/input/files b/modules/51_nitrogen/input/files deleted file mode 100644 index 6ec7623e0c..0000000000 --- a/modules/51_nitrogen/input/files +++ /dev/null @@ -1,2 +0,0 @@ -* list of files that are required here -f51_ipcc_ef.csv diff --git a/modules/51_nitrogen/ipcc2006_sep16/declarations.gms b/modules/51_nitrogen/ipcc2006_sep16/declarations.gms deleted file mode 100644 index e0b30bd60c..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/declarations.gms +++ /dev/null @@ -1,28 +0,0 @@ -*** | (C) 2008-2019 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 - q51_emissions_inorg_fert(i,n_pollutants_direct) estimates various emission types X from inorganic fertilizer before technical mitigation (Mt X-N) - q51_emissions_man_crop(i,n_pollutants_direct) estimates various emission types X from manure on cropland before technical mitigation (Mt X-N) - q51_emissions_resid(i,n_pollutants_direct) estimates various emission types X from residues before technical mitigation (Mt X-N) - q51_emissions_som(i,n_pollutants_direct) estimates various emission types X from soil organic matter loss before technical mitigation (Mt X-N) - q51_emissionbal_man_past(i,n_pollutants_direct) estimates various emission types X from manure on pasture land before technical mitigation (Mt X-N) - q51_emissionbal_awms(i,n_pollutants_direct) estimates various emission types X from animal waste management systems before technical mitigation (Mt X-N) - q51_emissions_indirect_n2o(i,emis_source_n51) estimates various emission types X from volatilisation and leaching (Mt X-N) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - oq51_emissions_inorg_fert(t,i,n_pollutants_direct,type) estimates various emission types X from inorganic fertilizer before technical mitigation (Mt X-N) - oq51_emissions_man_crop(t,i,n_pollutants_direct,type) estimates various emission types X from manure on cropland before technical mitigation (Mt X-N) - oq51_emissions_resid(t,i,n_pollutants_direct,type) estimates various emission types X from residues before technical mitigation (Mt X-N) - oq51_emissions_som(t,i,n_pollutants_direct,type) estimates various emission types X from soil organic matter loss before technical mitigation (Mt X-N) - oq51_emissionbal_man_past(t,i,n_pollutants_direct,type) estimates various emission types X from manure on pasture land before technical mitigation (Mt X-N) - oq51_emissionbal_awms(t,i,n_pollutants_direct,type) estimates various emission types X from animal waste management systems before technical mitigation (Mt X-N) - oq51_emissions_indirect_n2o(t,i,emis_source_n51,type) estimates various emission types X from volatilisation and leaching (Mt X-N) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/51_nitrogen/ipcc2006_sep16/equations.gms b/modules/51_nitrogen/ipcc2006_sep16/equations.gms deleted file mode 100644 index 96ed8618a5..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/equations.gms +++ /dev/null @@ -1,67 +0,0 @@ -*** | (C) 2008-2019 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 - -*' Nitrogeneous emissions stem from manure applied to croplands, inorganic fertilizers, -*' crop residues decaying on fields, soil organic matter loss, animal waste management, and -*' manure excreted on pasture land. Additionally, part of the NH3 and NOx emissions -*' as well as leached NO3 later result in indirect emissions of N2O when they are redeposited, -*' nitrified and dinitrified. -*' -*' Manure applied to croplands: - q51_emissions_man_crop(i2,n_pollutants_direct).. - vm_btm_reg(i2,"man_crop",n_pollutants_direct) - =e= - vm_manure_recycling(i2,"nr") - * f51_ef_n_soil(n_pollutants_direct,"man_crop"); - -*' inorganic fertilizers: - q51_emissions_inorg_fert(i2,n_pollutants_direct).. - vm_btm_reg(i2,"inorg_fert",n_pollutants_direct) - =e= - sum(land_ag,vm_nr_inorg_fert_reg(i2,land_ag)) - * f51_ef_n_soil(n_pollutants_direct,"inorg_fert"); - -*' crop residues decaying on fields: - q51_emissions_resid(i2,n_pollutants_direct).. - vm_btm_reg(i2,"resid",n_pollutants_direct) - =e= - vm_res_recycling(i2,"nr") * f51_ef_n_soil(n_pollutants_direct,"resid"); - -*' soil organic matter loss: - q51_emissions_som(i2,n_pollutants_direct).. - vm_btm_reg(i2,"som",n_pollutants_direct) - =e= - sum(cell(i2,j2),vm_nr_som(j2)) * f51_ef_n_soil(n_pollutants_direct,"som"); - -*' animal waste management: - q51_emissionbal_awms(i2,n_pollutants_direct) .. - vm_btm_reg(i2,"awms",n_pollutants_direct) - =e= - sum((kli,awms_conf), - vm_manure_confinement(i2,kli,awms_conf,"nr") - * f51_ef3_confinement(i2,kli,awms_conf,n_pollutants_direct)); - -*' and manure excreted on pasture land: - q51_emissionbal_man_past(i2,n_pollutants_direct) .. - vm_btm_reg(i2,"man_past",n_pollutants_direct) - =e= - sum((awms_prp,kli), - vm_manure(i2, kli, awms_prp, "nr") - * f51_ef3_prp(i2,n_pollutants_direct,kli)); - -*' Indirect emissions from NH3, NOx and NO3: - q51_emissions_indirect_n2o(i2,emis_source_n51) .. - vm_btm_reg(i2,emis_source_n51,"n2o_n_indirect") - =e= - sum(pollutant_nh3no2_51,vm_emissions_reg(i2,emis_source_n51,pollutant_nh3no2_51)) - * f51_ipcc_ef("ef_4","best") - + vm_emissions_reg(i2,emis_source_n51,"no3_n") - * f51_ipcc_ef("ef_5","best"); - -*** EOF constraints.gms *** diff --git a/modules/51_nitrogen/ipcc2006_sep16/input.gms b/modules/51_nitrogen/ipcc2006_sep16/input.gms deleted file mode 100644 index 8cee12e235..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/input.gms +++ /dev/null @@ -1,35 +0,0 @@ -*** | (C) 2008-2019 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 - - - -table f51_ipcc_ef(ipcc_ef51,emis_uncertainty51) ipcc emission factors for various emission types X (tX-N per tN) -$ondelim -$include "./modules/51_nitrogen/input/f51_ipcc_ef.csv" -$offdelim -; - -table f51_ef_n_soil(n_pollutants_direct,emis_source_n_cropsoils51) ipcc emission factors for various emission types X (tX-N per tN) -$ondelim -$include "./modules/51_nitrogen/ipcc2006_sep16/input/f51_ef_n_soil.cs3" -$offdelim -; - -parameter f51_ef3_confinement(i,kli,awms_conf,n_pollutants_direct) emissions from manure managed in confinement for various emission types X (tX-N per tN) -/ -$ondelim -$include "./modules/51_nitrogen/ipcc2006_sep16/input/f51_ef3_confinement.cs4" -$offdelim -/ -; - -parameter f51_ef3_prp(i,n_pollutants_direct,kli) emissions from manure on pasture range and paddocks for various emission types X (tX-N per tN) -/ -$ondelim -$include "./modules/51_nitrogen/ipcc2006_sep16/input/f51_ef3_prp.cs4" -$offdelim -/; diff --git a/modules/51_nitrogen/ipcc2006_sep16/input/files b/modules/51_nitrogen/ipcc2006_sep16/input/files deleted file mode 100644 index 5026168742..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/input/files +++ /dev/null @@ -1,4 +0,0 @@ -* list of files that are required here -f51_ef_n_soil.cs3 -f51_ef3_confinement.cs4 -f51_ef3_prp.cs4 diff --git a/modules/51_nitrogen/ipcc2006_sep16/not_used.txt b/modules/51_nitrogen/ipcc2006_sep16/not_used.txt deleted file mode 100644 index d78901bb63..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/not_used.txt +++ /dev/null @@ -1,7 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason diff --git a/modules/51_nitrogen/ipcc2006_sep16/postsolve.gms b/modules/51_nitrogen/ipcc2006_sep16/postsolve.gms deleted file mode 100644 index 284d46cd7b..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/postsolve.gms +++ /dev/null @@ -1,39 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"marginal") = q51_emissions_inorg_fert.m(i,n_pollutants_direct); - oq51_emissions_man_crop(t,i,n_pollutants_direct,"marginal") = q51_emissions_man_crop.m(i,n_pollutants_direct); - oq51_emissions_resid(t,i,n_pollutants_direct,"marginal") = q51_emissions_resid.m(i,n_pollutants_direct); - oq51_emissions_som(t,i,n_pollutants_direct,"marginal") = q51_emissions_som.m(i,n_pollutants_direct); - oq51_emissionbal_man_past(t,i,n_pollutants_direct,"marginal") = q51_emissionbal_man_past.m(i,n_pollutants_direct); - oq51_emissionbal_awms(t,i,n_pollutants_direct,"marginal") = q51_emissionbal_awms.m(i,n_pollutants_direct); - oq51_emissions_indirect_n2o(t,i,emis_source_n51,"marginal") = q51_emissions_indirect_n2o.m(i,emis_source_n51); - oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"level") = q51_emissions_inorg_fert.l(i,n_pollutants_direct); - oq51_emissions_man_crop(t,i,n_pollutants_direct,"level") = q51_emissions_man_crop.l(i,n_pollutants_direct); - oq51_emissions_resid(t,i,n_pollutants_direct,"level") = q51_emissions_resid.l(i,n_pollutants_direct); - oq51_emissions_som(t,i,n_pollutants_direct,"level") = q51_emissions_som.l(i,n_pollutants_direct); - oq51_emissionbal_man_past(t,i,n_pollutants_direct,"level") = q51_emissionbal_man_past.l(i,n_pollutants_direct); - oq51_emissionbal_awms(t,i,n_pollutants_direct,"level") = q51_emissionbal_awms.l(i,n_pollutants_direct); - oq51_emissions_indirect_n2o(t,i,emis_source_n51,"level") = q51_emissions_indirect_n2o.l(i,emis_source_n51); - oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"upper") = q51_emissions_inorg_fert.up(i,n_pollutants_direct); - oq51_emissions_man_crop(t,i,n_pollutants_direct,"upper") = q51_emissions_man_crop.up(i,n_pollutants_direct); - oq51_emissions_resid(t,i,n_pollutants_direct,"upper") = q51_emissions_resid.up(i,n_pollutants_direct); - oq51_emissions_som(t,i,n_pollutants_direct,"upper") = q51_emissions_som.up(i,n_pollutants_direct); - oq51_emissionbal_man_past(t,i,n_pollutants_direct,"upper") = q51_emissionbal_man_past.up(i,n_pollutants_direct); - oq51_emissionbal_awms(t,i,n_pollutants_direct,"upper") = q51_emissionbal_awms.up(i,n_pollutants_direct); - oq51_emissions_indirect_n2o(t,i,emis_source_n51,"upper") = q51_emissions_indirect_n2o.up(i,emis_source_n51); - oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"lower") = q51_emissions_inorg_fert.lo(i,n_pollutants_direct); - oq51_emissions_man_crop(t,i,n_pollutants_direct,"lower") = q51_emissions_man_crop.lo(i,n_pollutants_direct); - oq51_emissions_resid(t,i,n_pollutants_direct,"lower") = q51_emissions_resid.lo(i,n_pollutants_direct); - oq51_emissions_som(t,i,n_pollutants_direct,"lower") = q51_emissions_som.lo(i,n_pollutants_direct); - oq51_emissionbal_man_past(t,i,n_pollutants_direct,"lower") = q51_emissionbal_man_past.lo(i,n_pollutants_direct); - oq51_emissionbal_awms(t,i,n_pollutants_direct,"lower") = q51_emissionbal_awms.lo(i,n_pollutants_direct); - oq51_emissions_indirect_n2o(t,i,emis_source_n51,"lower") = q51_emissions_indirect_n2o.lo(i,emis_source_n51); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/51_nitrogen/ipcc2006_sep16/preloop.gms b/modules/51_nitrogen/ipcc2006_sep16/preloop.gms deleted file mode 100644 index b361ded127..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/preloop.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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 - - - diff --git a/modules/51_nitrogen/ipcc2006_sep16/presolve.gms b/modules/51_nitrogen/ipcc2006_sep16/presolve.gms deleted file mode 100644 index 39cacee2f1..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/presolve.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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_btm_reg.fx(i,emis_source_nonitrogen51,n_pollutants) = 0; - -*** EOF solve.gms *** diff --git a/modules/51_nitrogen/ipcc2006_sep16/realization.gms b/modules/51_nitrogen/ipcc2006_sep16/realization.gms deleted file mode 100644 index 33e204f4fb..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/realization.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2019 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 -*' The nitrogen module calculates nitrogeneous emissions before technical -*' mitigation, including N2O, NOx, NH3, NO3- and N2. -*' The model receives information on nitrogen flows from [50_nr_soil_budget], -*' [55_awms], [18_residues], [59_som], and it provides the emissions to the -*' module [56_ghg_policy]. -*' Emissions factors estimates are largely based on the IPCC 2006 Guidelines for -*' National Greenhouse Gas Inventories (@ipcc_2006_2006.), -*' as described in (@bodirsky_current_2012.). -*' -*' @authors Benjamin Leon Bodirsky - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/51_nitrogen/ipcc2006_sep16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/51_nitrogen/ipcc2006_sep16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/51_nitrogen/ipcc2006_sep16/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/51_nitrogen/ipcc2006_sep16/equations.gms" -$Ifi "%phase%" == "scaling" $include "./modules/51_nitrogen/ipcc2006_sep16/scaling.gms" -$Ifi "%phase%" == "preloop" $include "./modules/51_nitrogen/ipcc2006_sep16/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/51_nitrogen/ipcc2006_sep16/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/51_nitrogen/ipcc2006_sep16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/51_nitrogen/ipcc2006_sep16/scaling.gms b/modules/51_nitrogen/ipcc2006_sep16/scaling.gms deleted file mode 100644 index 5963ccda1d..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/scaling.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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 - - diff --git a/modules/51_nitrogen/ipcc2006_sep16/sets.gms b/modules/51_nitrogen/ipcc2006_sep16/sets.gms deleted file mode 100644 index 153cb9ac5a..0000000000 --- a/modules/51_nitrogen/ipcc2006_sep16/sets.gms +++ /dev/null @@ -1,28 +0,0 @@ -*** | (C) 2008-2019 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 - emis_uncertainty51 Different estimates for emission parameters - /best,low, high/ - - ipcc_ef51 ipcc Emission factors - /frac_gasf,frac_gasm,frac_leach,frac_leach_h,ef_1,ef_1fr,ef_2,ef_4,ef_5/ - - emis_source_n51(emis_source) Emission sources from agriculture - / inorg_fert, man_crop, awms, resid, man_past, som, rice / - - emis_source_nonitrogen51(emis_source) Emission sources - / rice, ent_ferm, - resid_burn, - crop_vegc, crop_litc, crop_soilc, - past_vegc, past_litc, past_soilc, - forestry_vegc, forestry_litc, forestry_soilc, - primforest_vegc, primforest_litc, primforest_soilc, -secdforest_vegc, secdforest_litc, secdforest_soilc, urban_vegc, urban_litc, urban_soilc, - other_vegc, other_litc, other_soilc, - beccs/ -; diff --git a/modules/51_nitrogen/module.gms b/modules/51_nitrogen/module.gms index c3fef2d5fb..9b24c395b4 100644 --- a/modules/51_nitrogen/module.gms +++ b/modules/51_nitrogen/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,10 +8,12 @@ *' @title Nitrogen *' @description *' The nitrogen module calculates nitrogeneous emissions before technical -*' mitigation, including N2O, NOx, NH3, NO3- and N2. +*' mitigation, including N2O, NOx, NH3, NO3- and N2. Sources of these emissions include +*' manure, inorganic fertilizers, crop residues, soil organic matter, and indirect emissions. +*' *' @authors Benjamin Leon Bodirsky *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%nitrogen%" == "ipcc2006_sep16" $include "./modules/51_nitrogen/ipcc2006_sep16/realization.gms" $Ifi "%nitrogen%" == "off" $include "./modules/51_nitrogen/off/realization.gms" +$Ifi "%nitrogen%" == "rescaled_jan21" $include "./modules/51_nitrogen/rescaled_jan21/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/51_nitrogen/off/declarations.gms b/modules/51_nitrogen/off/declarations.gms index e74568bcea..e51f0dbc69 100644 --- a/modules/51_nitrogen/off/declarations.gms +++ b/modules/51_nitrogen/off/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/51_nitrogen/off/not_used.txt b/modules/51_nitrogen/off/not_used.txt index ebd23a7554..9b2518c015 100644 --- a/modules/51_nitrogen/off/not_used.txt +++ b/modules/51_nitrogen/off/not_used.txt @@ -1,14 +1,11 @@ -# | (C) 2008-2019 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 name,type,reason -vm_emissions_reg, input, no emission feedback on deposition vm_manure, input, new flexreg structure vm_manure_confinement, input, new flexreg structure vm_manure_recycling, input, new flexreg structure -vm_res_recycling,new flexreg structure, -vm_nr_inorg_fert_reg,input, not needed -vm_nr_som,input,questionnaire +vm_res_recycling, input, new flexreg structure +vm_res_ag_burn, input, not needed +vm_nr_inorg_fert_reg, input, not needed +vm_nr_som, input, questionnaire +vm_nr_eff, input, not needed +vm_nr_eff_pasture, input, not needed +im_maccs_mitigation,input,questionnaire diff --git a/modules/51_nitrogen/off/postsolve.gms b/modules/51_nitrogen/off/postsolve.gms index b16634c060..6e6146898d 100644 --- a/modules/51_nitrogen/off/postsolve.gms +++ b/modules/51_nitrogen/off/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/51_nitrogen/off/preloop.gms b/modules/51_nitrogen/off/preloop.gms new file mode 100644 index 0000000000..5737bcbe0e --- /dev/null +++ b/modules/51_nitrogen/off/preloop.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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,emis_source,n_pollutants) = 0; diff --git a/modules/51_nitrogen/off/presolve.gms b/modules/51_nitrogen/off/presolve.gms deleted file mode 100644 index 67e4307fad..0000000000 --- a/modules/51_nitrogen/off/presolve.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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_btm_reg.fx(i,emis_source,n_pollutants) = 0; - diff --git a/modules/51_nitrogen/off/realization.gms b/modules/51_nitrogen/off/realization.gms index 2708bc3b3c..7d760ea528 100644 --- a/modules/51_nitrogen/off/realization.gms +++ b/modules/51_nitrogen/off/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -12,6 +12,6 @@ *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "declarations" $include "./modules/51_nitrogen/off/declarations.gms" -$Ifi "%phase%" == "presolve" $include "./modules/51_nitrogen/off/presolve.gms" +$Ifi "%phase%" == "preloop" $include "./modules/51_nitrogen/off/preloop.gms" $Ifi "%phase%" == "postsolve" $include "./modules/51_nitrogen/off/postsolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/51_nitrogen/rescaled_jan21/declarations.gms b/modules/51_nitrogen/rescaled_jan21/declarations.gms new file mode 100644 index 0000000000..528cbf4df0 --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/declarations.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2025 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 + q51_emissions_inorg_fert(i,n_pollutants_direct) estimates various emission types X from inorganic fertilizer before technical mitigation (Mt X-N) + q51_emissions_man_crop(i,n_pollutants_direct) estimates various emission types X from manure on cropland before technical mitigation (Mt X-N) + q51_emissions_resid(i,n_pollutants_direct) estimates various emission types X from residues before technical mitigation (Mt X-N) + q51_emissions_resid_burn(i,n_pollutants_direct) estimates various emission types X from residues burning (Mt X-N) + q51_emissions_som(i,n_pollutants_direct) estimates various emission types X from soil organic matter loss before technical mitigation (Mt X-N) + q51_emissionbal_man_past(i,n_pollutants_direct) estimates various emission types X from manure on pasture land before technical mitigation (Mt X-N) + q51_emissionbal_awms(i,n_pollutants_direct) estimates various emission types X from animal waste management systems before technical mitigation (Mt X-N) + q51_emissions_indirect_n2o(i,emis_source_n51) estimates various emission types X from volatilisation and leaching (Mt X-N) +; + +parameters + i51_ef_n_soil(t,i,n_pollutants_direct,emis_source_n_cropsoils51) emission factors for nitrogen emissions from cropland soils (tX-N per tN) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + oq51_emissions_inorg_fert(t,i,n_pollutants_direct,type) estimates various emission types X from inorganic fertilizer before technical mitigation (Mt X-N) + oq51_emissions_man_crop(t,i,n_pollutants_direct,type) estimates various emission types X from manure on cropland before technical mitigation (Mt X-N) + oq51_emissions_resid(t,i,n_pollutants_direct,type) estimates various emission types X from residues before technical mitigation (Mt X-N) + oq51_emissions_resid_burn(t,i,n_pollutants_direct,type) estimates various emission types X from residues burning (Mt X-N) + oq51_emissions_som(t,i,n_pollutants_direct,type) estimates various emission types X from soil organic matter loss before technical mitigation (Mt X-N) + oq51_emissionbal_man_past(t,i,n_pollutants_direct,type) estimates various emission types X from manure on pasture land before technical mitigation (Mt X-N) + oq51_emissionbal_awms(t,i,n_pollutants_direct,type) estimates various emission types X from animal waste management systems before technical mitigation (Mt X-N) + oq51_emissions_indirect_n2o(t,i,emis_source_n51,type) estimates various emission types X from volatilisation and leaching (Mt X-N) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/51_nitrogen/rescaled_jan21/equations.gms b/modules/51_nitrogen/rescaled_jan21/equations.gms new file mode 100644 index 0000000000..2f04b0902d --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/equations.gms @@ -0,0 +1,91 @@ +*** | (C) 2008-2025 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 + +*' Nitrogeneous emissions stem from manure applied to croplands, inorganic fertilizers, +*' crop residues decaying on fields, the burning of agricultural residues, +*' soil organic matter loss, animal waste management, and manure excreted on pasture land. +*' Additionally, part of the NH3 and NOx emissions as well as leached NO3 later result +*' in indirect emissions of N2O when they are redeposited, nitrified and dinitrified. +*' +*' Emissions are rescaled using the nitrogen uptake efficiency. This is done to keep consistency +*' of emissions with nitrogen surplus and take account for improved emission factors when NUE increases. +*' The marginal abatement cost curves (MACCs) are already applied at the estimation +*' of the NUE in module 50_nr_soil_budget. +*' +*' Manure applied to croplands: + q51_emissions_man_crop(i2,n_pollutants_direct).. + vm_emissions_reg(i2,"man_crop",n_pollutants_direct) + =e= + vm_manure_recycling(i2,"nr") + / (1-s51_snupe_base) * (1-vm_nr_eff(i2)) + * sum(ct, i51_ef_n_soil(ct,i2,n_pollutants_direct,"man_crop")); + +*' inorganic fertilizers: + q51_emissions_inorg_fert(i2,n_pollutants_direct).. + vm_emissions_reg(i2,"inorg_fert",n_pollutants_direct) + =e= + vm_nr_inorg_fert_reg(i2,"crop") + / (1-s51_snupe_base) * (1-vm_nr_eff(i2)) + * sum(ct, i51_ef_n_soil(ct,i2,n_pollutants_direct,"inorg_fert")) + + vm_nr_inorg_fert_reg(i2,"past") + / (1-s51_nue_pasture_base) * (1-vm_nr_eff_pasture(i2)) + * sum(ct, i51_ef_n_soil(ct,i2,n_pollutants_direct,"inorg_fert")) + ; + +*' crop residues decaying on fields: + q51_emissions_resid(i2,n_pollutants_direct).. + vm_emissions_reg(i2,"resid",n_pollutants_direct) + =e= + vm_res_recycling(i2,"nr") * sum(ct, i51_ef_n_soil(ct,i2,n_pollutants_direct,"resid")) + / (1-s51_snupe_base) * (1-vm_nr_eff(i2)); + +*' emissions from burning crop residues, N2O and NOx + q51_emissions_resid_burn(i2,n_pollutants_direct).. + vm_emissions_reg(i2,"resid_burn",n_pollutants_direct) + =e= + sum(kcr, vm_res_ag_burn(i2,kcr,"dm")) * f51_ef_resid_burn(n_pollutants_direct); + +*' soil organic matter loss: + q51_emissions_som(i2,n_pollutants_direct).. + vm_emissions_reg(i2,"som",n_pollutants_direct) + =e= + sum(cell(i2,j2),vm_nr_som(j2)) * sum(ct, i51_ef_n_soil(ct,i2,n_pollutants_direct,"som")) + / (1-s51_snupe_base) * (1-vm_nr_eff(i2)); + +*' animal waste management +*' Here we apply the marginal abatement cost curves to the emissions of all +*' N pollutants. The measures (e.g. decreased storage time, coverage) are not +*' specific to N2O and assumed to apply also to NH3 and other losses. + q51_emissionbal_awms(i2,n_pollutants_direct) .. + vm_emissions_reg(i2,"awms",n_pollutants_direct) + =e= + sum((kli,awms_conf), + vm_manure_confinement(i2,kli,awms_conf,"nr") + * f51_ef3_confinement(i2,kli,awms_conf,n_pollutants_direct)) + * (1-sum(ct, im_maccs_mitigation(ct,i2,"awms","n2o_n_direct"))); + +*' and manure excreted on pasture land: + q51_emissionbal_man_past(i2,n_pollutants_direct) .. + vm_emissions_reg(i2,"man_past",n_pollutants_direct) + =e= + sum((awms_prp,kli), + vm_manure(i2, kli, awms_prp, "nr") + * f51_ef3_prp(i2,n_pollutants_direct,kli)) + / (1-s51_nue_pasture_base) * (1-vm_nr_eff_pasture(i2)); + +*' Indirect emissions from NH3, NOx and NO3: + q51_emissions_indirect_n2o(i2,emis_source_n51) .. + vm_emissions_reg(i2,emis_source_n51,"n2o_n_indirect") + =e= + sum(pollutant_nh3no2_51,vm_emissions_reg(i2,emis_source_n51,pollutant_nh3no2_51)) + * f51_ipcc_ef("ef_4","best") + + vm_emissions_reg(i2,emis_source_n51,"no3_n") + * f51_ipcc_ef("ef_5","best"); + +*** EOF constraints.gms *** diff --git a/modules/51_nitrogen/rescaled_jan21/input.gms b/modules/51_nitrogen/rescaled_jan21/input.gms new file mode 100644 index 0000000000..f39a4d22b8 --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/input.gms @@ -0,0 +1,43 @@ +*** | (C) 2008-2025 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 + +Scalar s51_snupe_base assumption on implicit SNuPE in ipcc guidelines (1) / 0.5 /; +Scalar s51_nue_pasture_base assumption on implicit SNuPE in ipcc guidelines (1) / 0.5 /; + +table f51_ipcc_ef(ipcc_ef51,emis_uncertainty51) ipcc emission factors for various emission types X (tX-N per tN) +$ondelim +$include "./modules/51_nitrogen/rescaled_jan21/input/f51_ipcc_ef.csv" +$offdelim +; + +table f51_ef_n_soil(t_all,i,n_pollutants_direct,emis_source_n_cropsoils51) ipcc emission factors for various emission types X (tX-N per tN) +$ondelim +$include "./modules/51_nitrogen/rescaled_jan21/input/f51_ef_n_soil_reg.cs3" +$offdelim +; + +parameter f51_ef3_confinement(i,kli,awms_conf,n_pollutants_direct) emissions from manure managed in confinement for various emission types X (tX-N per tN) +/ +$ondelim +$include "./modules/51_nitrogen/rescaled_jan21/input/f51_ef3_confinement.cs4" +$offdelim +/ +; + +parameter f51_ef3_prp(i,n_pollutants_direct,kli) emissions from manure on pasture range and paddocks for various emission types X (tX-N per tN) +/ +$ondelim +$include "./modules/51_nitrogen/rescaled_jan21/input/f51_ef3_prp.cs4" +$offdelim +/; + +parameter f51_ef_resid_burn(n_pollutants_direct) emission factor for residual burning (tX-N per t DM) +/ +$ondelim +$include "./modules/51_nitrogen/rescaled_jan21/input/f51_ef_resid_burn.cs4" +$offdelim +/; diff --git a/modules/51_nitrogen/rescaled_jan21/input/files b/modules/51_nitrogen/rescaled_jan21/input/files new file mode 100644 index 0000000000..e4798643b3 --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/input/files @@ -0,0 +1,6 @@ +* list of files that are required here +f51_ef3_confinement.cs4 +f51_ef3_prp.cs4 +f51_ef_resid_burn.cs4 +f51_ipcc_ef.csv +f51_ef_n_soil_reg.cs3 \ No newline at end of file diff --git a/modules/51_nitrogen/rescaled_jan21/postsolve.gms b/modules/51_nitrogen/rescaled_jan21/postsolve.gms new file mode 100644 index 0000000000..11292f1b2d --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/postsolve.gms @@ -0,0 +1,43 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"marginal") = q51_emissions_inorg_fert.m(i,n_pollutants_direct); + oq51_emissions_man_crop(t,i,n_pollutants_direct,"marginal") = q51_emissions_man_crop.m(i,n_pollutants_direct); + oq51_emissions_resid(t,i,n_pollutants_direct,"marginal") = q51_emissions_resid.m(i,n_pollutants_direct); + oq51_emissions_resid_burn(t,i,n_pollutants_direct,"marginal") = q51_emissions_resid_burn.m(i,n_pollutants_direct); + oq51_emissions_som(t,i,n_pollutants_direct,"marginal") = q51_emissions_som.m(i,n_pollutants_direct); + oq51_emissionbal_man_past(t,i,n_pollutants_direct,"marginal") = q51_emissionbal_man_past.m(i,n_pollutants_direct); + oq51_emissionbal_awms(t,i,n_pollutants_direct,"marginal") = q51_emissionbal_awms.m(i,n_pollutants_direct); + oq51_emissions_indirect_n2o(t,i,emis_source_n51,"marginal") = q51_emissions_indirect_n2o.m(i,emis_source_n51); + oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"level") = q51_emissions_inorg_fert.l(i,n_pollutants_direct); + oq51_emissions_man_crop(t,i,n_pollutants_direct,"level") = q51_emissions_man_crop.l(i,n_pollutants_direct); + oq51_emissions_resid(t,i,n_pollutants_direct,"level") = q51_emissions_resid.l(i,n_pollutants_direct); + oq51_emissions_resid_burn(t,i,n_pollutants_direct,"level") = q51_emissions_resid_burn.l(i,n_pollutants_direct); + oq51_emissions_som(t,i,n_pollutants_direct,"level") = q51_emissions_som.l(i,n_pollutants_direct); + oq51_emissionbal_man_past(t,i,n_pollutants_direct,"level") = q51_emissionbal_man_past.l(i,n_pollutants_direct); + oq51_emissionbal_awms(t,i,n_pollutants_direct,"level") = q51_emissionbal_awms.l(i,n_pollutants_direct); + oq51_emissions_indirect_n2o(t,i,emis_source_n51,"level") = q51_emissions_indirect_n2o.l(i,emis_source_n51); + oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"upper") = q51_emissions_inorg_fert.up(i,n_pollutants_direct); + oq51_emissions_man_crop(t,i,n_pollutants_direct,"upper") = q51_emissions_man_crop.up(i,n_pollutants_direct); + oq51_emissions_resid(t,i,n_pollutants_direct,"upper") = q51_emissions_resid.up(i,n_pollutants_direct); + oq51_emissions_resid_burn(t,i,n_pollutants_direct,"upper") = q51_emissions_resid_burn.up(i,n_pollutants_direct); + oq51_emissions_som(t,i,n_pollutants_direct,"upper") = q51_emissions_som.up(i,n_pollutants_direct); + oq51_emissionbal_man_past(t,i,n_pollutants_direct,"upper") = q51_emissionbal_man_past.up(i,n_pollutants_direct); + oq51_emissionbal_awms(t,i,n_pollutants_direct,"upper") = q51_emissionbal_awms.up(i,n_pollutants_direct); + oq51_emissions_indirect_n2o(t,i,emis_source_n51,"upper") = q51_emissions_indirect_n2o.up(i,emis_source_n51); + oq51_emissions_inorg_fert(t,i,n_pollutants_direct,"lower") = q51_emissions_inorg_fert.lo(i,n_pollutants_direct); + oq51_emissions_man_crop(t,i,n_pollutants_direct,"lower") = q51_emissions_man_crop.lo(i,n_pollutants_direct); + oq51_emissions_resid(t,i,n_pollutants_direct,"lower") = q51_emissions_resid.lo(i,n_pollutants_direct); + oq51_emissions_resid_burn(t,i,n_pollutants_direct,"lower") = q51_emissions_resid_burn.lo(i,n_pollutants_direct); + oq51_emissions_som(t,i,n_pollutants_direct,"lower") = q51_emissions_som.lo(i,n_pollutants_direct); + oq51_emissionbal_man_past(t,i,n_pollutants_direct,"lower") = q51_emissionbal_man_past.lo(i,n_pollutants_direct); + oq51_emissionbal_awms(t,i,n_pollutants_direct,"lower") = q51_emissionbal_awms.lo(i,n_pollutants_direct); + oq51_emissions_indirect_n2o(t,i,emis_source_n51,"lower") = q51_emissions_indirect_n2o.lo(i,emis_source_n51); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/51_nitrogen/rescaled_jan21/preloop.gms b/modules/51_nitrogen/rescaled_jan21/preloop.gms new file mode 100644 index 0000000000..d900593414 --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/preloop.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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,emis_source,n_pollutants) = 0; +vm_emissions_reg.lo(i,emis_source_n51,n_pollutants) = -Inf; +vm_emissions_reg.up(i,emis_source_n51,n_pollutants) = Inf; diff --git a/modules/51_nitrogen/rescaled_jan21/presolve.gms b/modules/51_nitrogen/rescaled_jan21/presolve.gms new file mode 100644 index 0000000000..0b3d246bb6 --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/presolve.gms @@ -0,0 +1,16 @@ +*** | (C) 2008-2025 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 + +* leaching emissions are dynamic with climate for the history; +* for the future, for now we keep them constant at 2010 levels. +if (sum(sameas(t_past,t),1) = 1, + i51_ef_n_soil(t,i,n_pollutants_direct,emis_source_n_cropsoils51) = + f51_ef_n_soil(t,i,n_pollutants_direct,emis_source_n_cropsoils51); +else + i51_ef_n_soil(t,i,n_pollutants_direct,emis_source_n_cropsoils51)= + i51_ef_n_soil(t-1,i,n_pollutants_direct,emis_source_n_cropsoils51); +); diff --git a/modules/51_nitrogen/rescaled_jan21/realization.gms b/modules/51_nitrogen/rescaled_jan21/realization.gms new file mode 100644 index 0000000000..9f799602ba --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/realization.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2025 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 +*' The nitrogen module calculates nitrogeneous emissions before technical +*' mitigation, including N2O, NOx, NH3, NO3- and N2. +*' The model receives information on nitrogen flows from [50_nr_soil_budget], +*' [55_awms], [18_residues], [59_som], and it provides the emissions to the +*' module [56_ghg_policy]. +*' Emissions factors estimates are largely based on the IPCC 2006 Guidelines for +*' National Greenhouse Gas Inventories (@ipcc_2006_2006.), +*' as described in (@bodirsky_current_2012.). +*' +*' @authors Benjamin Leon Bodirsky + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/51_nitrogen/rescaled_jan21/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/51_nitrogen/rescaled_jan21/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/51_nitrogen/rescaled_jan21/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/51_nitrogen/rescaled_jan21/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/51_nitrogen/rescaled_jan21/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/51_nitrogen/rescaled_jan21/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/51_nitrogen/rescaled_jan21/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/51_nitrogen/rescaled_jan21/sets.gms b/modules/51_nitrogen/rescaled_jan21/sets.gms new file mode 100644 index 0000000000..b7ddd04fcb --- /dev/null +++ b/modules/51_nitrogen/rescaled_jan21/sets.gms @@ -0,0 +1,21 @@ +*** | (C) 2008-2025 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 + emis_uncertainty51 Different estimates for emission parameters + /best,low, high/ + + ipcc_ef51 ipcc Emission factors + /frac_gasf,frac_gasm,frac_leach,frac_leach_h,ef_1,ef_1fr,ef_2,ef_4,ef_5/ + + emis_source_n51(emis_source) Emission sources from agriculture + / inorg_fert, man_crop, awms, resid, resid_burn, man_past, som / + + emis_source_n_cropsoils51(emis_source) activities that lead to emissions + / inorg_fert, man_crop, resid, som, rice / + +; diff --git a/modules/52_carbon/input/files b/modules/52_carbon/input/files index 397add8ec0..0a553eff92 100644 --- a/modules/52_carbon/input/files +++ b/modules/52_carbon/input/files @@ -2,3 +2,4 @@ lpj_carbon_stocks.cs3 lpj_carbon_stocks_0.5.mz f52_growth_par.csv +f52_land_carbon_sink_adjust_grassi.cs3 diff --git a/modules/52_carbon/module.gms b/modules/52_carbon/module.gms index bad3ab8d47..995f0fa1c8 100644 --- a/modules/52_carbon/module.gms +++ b/modules/52_carbon/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,17 +7,11 @@ *' @title Carbon *' -*' @description The carbon module provides annual land-related CO2 emissions for the -*' [56_ghg_policy] module. The carbon module provides carbon density information -*' on cellular level to all land modules ([30_crop], [31_past], [32_forestry], -*' [34_urban] and [35_natveg]), and in return it gets the current carbon stock -*' levels from respective land pools. The module also accounts for changes in -*' terrestrial carbon stocks cause by climate change effects on biosphere [45_climate]. +*' @description The carbon module provides carbon density information for different land types. *' *' -*' @authors Benjamin Leon Bodirsky, Florian Humpenoeder +*' @authors Benjamin Leon Bodirsky, Florian Humpenoeder, Abhijeet Mishra *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%carbon%" == "normal_dec17" $include "./modules/52_carbon/normal_dec17/realization.gms" -$Ifi "%carbon%" == "off" $include "./modules/52_carbon/off/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/52_carbon/normal_dec17/declarations.gms b/modules/52_carbon/normal_dec17/declarations.gms index be9a85cfc0..d9d775ed35 100644 --- a/modules/52_carbon/normal_dec17/declarations.gms +++ b/modules/52_carbon/normal_dec17/declarations.gms @@ -1,38 +1,24 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -variables - v52_carbon_stock_diff(j,land,c_pools) Change in carbon stocks compared to previous time step (mio. tC per time step) -; - -positive variables - vm_carbon_stock(j,land,c_pools) Carbon stock in vegetation soil and litter for different land types (mio. tC) - vm_carbon_stock_reduction(j,land,c_pools) Reduction in carbon stocks compared to previous time step (mio. tC per time step) -; - parameters - pm_carbon_density_ac(t,j,ac,c_pools) Carbon density for age classes and carbon pools (tC per ha) - pcm_carbon_stock(j,land,c_pools) Current carbon in vegetation soil and litter for different land types (mio. tC) - pc52_carbon_density_start(t,j,c_pools) Carbon density for new land in other land pool (tC per ha) + pm_carbon_density_secdforest_ac(t_all,j,ac,ag_pools) Above ground secondary forest carbon density for age classes and carbon pools (tC per ha) + pm_carbon_density_other_ac(t_all,j,ac,ag_pools) Above ground other land carbon density for age classes and carbon pools (tC per ha) + pm_carbon_density_plantation_ac(t_all,j,ac,ag_pools) Above ground plantation carbon density for age classes and carbon pools (tC per ha) + pc52_carbon_density_start(t_all,j,ag_pools) Above ground carbon density for new land in other land pool (tC per ha) + i52_land_carbon_sink(t_all,i) Land carbon sink adjustment factors from Grassi et al 2021 (GtCO2 per year) ; equations - q52_carbon_stock_diff(j,land,c_pools) Calculation net carbon stock change (mio. tC per time step) - q52_carbon_stock_reduction(j,land,c_pools) Calculation carbon stock reduction (mio. tC per time step) - q52_co2c_emis(j,emis_co2) Calculation of annual CO2 emissions (mio. tC per yr) + q52_emis_co2_actual(i,emis_oneoff) Calculation of annual CO2 emissions (Tg per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov52_carbon_stock_diff(t,j,land,c_pools,type) Change in carbon stocks compared to previous time step (mio. tC per time step) - ov_carbon_stock(t,j,land,c_pools,type) Carbon stock in vegetation soil and litter for different land types (mio. tC) - ov_carbon_stock_reduction(t,j,land,c_pools,type) Reduction in carbon stocks compared to previous time step (mio. tC per time step) - oq52_carbon_stock_diff(t,j,land,c_pools,type) Calculation net carbon stock change (mio. tC per time step) - oq52_carbon_stock_reduction(t,j,land,c_pools,type) Calculation carbon stock reduction (mio. tC per time step) - oq52_co2c_emis(t,j,emis_co2,type) Calculation of annual CO2 emissions (mio. tC per yr) + oq52_emis_co2_actual(t,i,emis_oneoff,type) Calculation of annual CO2 emissions (Tg per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/52_carbon/normal_dec17/equations.gms b/modules/52_carbon/normal_dec17/equations.gms index 48379f5a8e..0217efeb84 100644 --- a/modules/52_carbon/normal_dec17/equations.gms +++ b/modules/52_carbon/normal_dec17/equations.gms @@ -1,29 +1,19 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 - -*' Change of carbon stocks is calculated as a difference between the current and -*' the previous time step. - q52_carbon_stock_diff(j2,land,c_pools) .. - v52_carbon_stock_diff(j2,land,c_pools) =e= - pcm_carbon_stock(j2,land,c_pools) - vm_carbon_stock(j2,land,c_pools); - q52_carbon_stock_reduction(j2,land,c_pools) .. - vm_carbon_stock_reduction(j2,land,c_pools) =g= - pcm_carbon_stock(j2,land,c_pools) - vm_carbon_stock(j2,land,c_pools); +*' @equations -*' Annual CO2 emissions are obtained by dividing `v52_carbon_stock_diff` by -*' time step length (e.g. 5 or 10 years). +*** Emissions - q52_co2c_emis(j2,emis_co2) .. - vm_btm_cell(j2,emis_co2,"co2_c") =e= - sum(emis_land(emis_co2,land,c_pools), - v52_carbon_stock_diff(j2,land,c_pools)/m_timestep_length); +*' Actual CO2 emissions are calculated based on changes in carbon stocks between timesteps in the interface `vm_carbon_stock`. -*** EOF constraints.gms *** + q52_emis_co2_actual(i2,emis_oneoff) .. + vm_emissions_reg(i2,emis_oneoff,"co2_c") =e= + sum((cell(i2,j2),emis_land(emis_oneoff,land,c_pools)), + (pcm_carbon_stock(j2,land,c_pools,"actual") - vm_carbon_stock(j2,land,c_pools,"actual"))/m_timestep_length); diff --git a/modules/52_carbon/normal_dec17/input.gms b/modules/52_carbon/normal_dec17/input.gms index 1b9a250020..0ddd7c10a6 100644 --- a/modules/52_carbon/normal_dec17/input.gms +++ b/modules/52_carbon/normal_dec17/input.gms @@ -1,24 +1,66 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -$setglobal c52_carbon_scenario nocc -* options: cc (climate change) -* nocc (no climate change) +$setglobal c52_carbon_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + +$setglobal c52_land_carbon_sink_rcp RCPBU +* options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU table fm_carbon_density(t_all,j,land,c_pools) LPJmL carbon density for land and carbon pools (tC per ha) $ondelim $include "./modules/52_carbon/input/lpj_carbon_stocks.cs3" $offdelim ; + $if "%c52_carbon_scenario%" == "nocc" fm_carbon_density(t_all,j,land,c_pools) = fm_carbon_density("y1995",j,land,c_pools); +$if "%c52_carbon_scenario%" == "nocc_hist" fm_carbon_density(t_all,j,land,c_pools)$(m_year(t_all) > sm_fix_cc) = fm_carbon_density(t_all,j,land,c_pools)$(m_year(t_all) = sm_fix_cc); m_fillmissingyears(fm_carbon_density,"j,land,c_pools"); -table f52_growth_par(clcl,chap_par) Parameters for chapman-richards equation (1) +* Where no forest carbon density is reported, because the potential +* forest area is zero, use the carbon density of other land instead. +* This affects areas, where the land use intialisation reports some +* forest, although the forest potential is zero. Forest expansion in +* these cells is constrained by f35_pot_forest_area. +fm_carbon_density(t_all,j,land_forest,c_pools)$(fm_carbon_density(t_all,j,land_forest,c_pools) = 0) = fm_carbon_density(t_all,j,"other",c_pools); + +* Fix urban area soilc to natural land soilc as long as preprocessed +* fm_carbon_density does not provide meaningful numbers for urban. +fm_carbon_density(t_all,j,"urban","soilc") = fm_carbon_density(t_all,j,"other","soilc") + +parameter f52_growth_par(clcl,chap_par,forest_type) Parameters for chapman-richards equation (1) +/ $ondelim $include "./modules/52_carbon/input/f52_growth_par.csv" $offdelim +/ ; + +* Note: Land carbon sink adjustment factors from Grassie et al 2021 (DOI 10.1038/s41558-021-01033-6) +* are needed in the post-processing in https://github.com/pik-piam/magpie4/blob/master/R/reportEmissions.R +* To facilitate the choice of the corresponding RCP, the adjustment factors are read-in here and +* stored in i52_land_carbon_sink for use in the R post-processing. +* Land carbon sink adjustment factors are NOT used within MAgPIE. +$onEmpty +table f52_land_carbon_sink(t_all,i,rcp52) Land carbon sink adjustment factors from Grassi et al 2021 (GtCO2 per year) +$ondelim +$if exist "./modules/52_carbon/input/f52_land_carbon_sink_adjust_grassi.cs3" $include "./modules/52_carbon/input/f52_land_carbon_sink_adjust_grassi.cs3" +$offdelim +; +$offEmpty + +$ifthen "%c52_land_carbon_sink_rcp%" == "nocc" + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink("y1995",i,"RCPBU"); +$elseif "%c52_land_carbon_sink_rcp%" == "nocc_hist" + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"RCPBU"); + i52_land_carbon_sink(t_all,i)$(m_year(t_all) > sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) = sm_fix_cc); +$else + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); + i52_land_carbon_sink(t_all,i)$(m_year(t_all) <= sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) <= sm_fix_cc); +$endif diff --git a/modules/52_carbon/normal_dec17/postsolve.gms b/modules/52_carbon/normal_dec17/postsolve.gms index e91ec95b78..4b6427d08f 100644 --- a/modules/52_carbon/normal_dec17/postsolve.gms +++ b/modules/52_carbon/normal_dec17/postsolve.gms @@ -1,35 +1,14 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -pcm_carbon_stock(j,land,c_pools) = vm_carbon_stock.l(j,land,c_pools); - *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov52_carbon_stock_diff(t,j,land,c_pools,"marginal") = v52_carbon_stock_diff.m(j,land,c_pools); - ov_carbon_stock(t,j,land,c_pools,"marginal") = vm_carbon_stock.m(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"marginal") = vm_carbon_stock_reduction.m(j,land,c_pools); - oq52_carbon_stock_diff(t,j,land,c_pools,"marginal") = q52_carbon_stock_diff.m(j,land,c_pools); - oq52_carbon_stock_reduction(t,j,land,c_pools,"marginal") = q52_carbon_stock_reduction.m(j,land,c_pools); - oq52_co2c_emis(t,j,emis_co2,"marginal") = q52_co2c_emis.m(j,emis_co2); - ov52_carbon_stock_diff(t,j,land,c_pools,"level") = v52_carbon_stock_diff.l(j,land,c_pools); - ov_carbon_stock(t,j,land,c_pools,"level") = vm_carbon_stock.l(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"level") = vm_carbon_stock_reduction.l(j,land,c_pools); - oq52_carbon_stock_diff(t,j,land,c_pools,"level") = q52_carbon_stock_diff.l(j,land,c_pools); - oq52_carbon_stock_reduction(t,j,land,c_pools,"level") = q52_carbon_stock_reduction.l(j,land,c_pools); - oq52_co2c_emis(t,j,emis_co2,"level") = q52_co2c_emis.l(j,emis_co2); - ov52_carbon_stock_diff(t,j,land,c_pools,"upper") = v52_carbon_stock_diff.up(j,land,c_pools); - ov_carbon_stock(t,j,land,c_pools,"upper") = vm_carbon_stock.up(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"upper") = vm_carbon_stock_reduction.up(j,land,c_pools); - oq52_carbon_stock_diff(t,j,land,c_pools,"upper") = q52_carbon_stock_diff.up(j,land,c_pools); - oq52_carbon_stock_reduction(t,j,land,c_pools,"upper") = q52_carbon_stock_reduction.up(j,land,c_pools); - oq52_co2c_emis(t,j,emis_co2,"upper") = q52_co2c_emis.up(j,emis_co2); - ov52_carbon_stock_diff(t,j,land,c_pools,"lower") = v52_carbon_stock_diff.lo(j,land,c_pools); - ov_carbon_stock(t,j,land,c_pools,"lower") = vm_carbon_stock.lo(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"lower") = vm_carbon_stock_reduction.lo(j,land,c_pools); - oq52_carbon_stock_diff(t,j,land,c_pools,"lower") = q52_carbon_stock_diff.lo(j,land,c_pools); - oq52_carbon_stock_reduction(t,j,land,c_pools,"lower") = q52_carbon_stock_reduction.lo(j,land,c_pools); - oq52_co2c_emis(t,j,emis_co2,"lower") = q52_co2c_emis.lo(j,emis_co2); + oq52_emis_co2_actual(t,i,emis_oneoff,"marginal") = q52_emis_co2_actual.m(i,emis_oneoff); + oq52_emis_co2_actual(t,i,emis_oneoff,"level") = q52_emis_co2_actual.l(i,emis_oneoff); + oq52_emis_co2_actual(t,i,emis_oneoff,"upper") = q52_emis_co2_actual.up(i,emis_oneoff); + oq52_emis_co2_actual(t,i,emis_oneoff,"lower") = q52_emis_co2_actual.lo(i,emis_oneoff); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/52_carbon/normal_dec17/preloop.gms b/modules/52_carbon/normal_dec17/preloop.gms deleted file mode 100644 index b782b07c8e..0000000000 --- a/modules/52_carbon/normal_dec17/preloop.gms +++ /dev/null @@ -1,27 +0,0 @@ -*** | (C) 2008-2019 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 - - -* starting value of carbon stocks 1995 is only an estimate. -* ATTENTION: emissions in 1995 are not meaningful -vm_carbon_stock.l(j,land,c_pools) = fm_carbon_density("y1995",j,land,c_pools)*pcm_land(j,land); -pcm_carbon_stock(j,land,c_pools) = vm_carbon_stock.l(j,land,c_pools); - -*age-class carbon density start values -pc52_carbon_density_start(t,j,"vegc") = 0; -pc52_carbon_density_start(t,j,"litc") = fm_carbon_density(t,j,"past","litc"); -pc52_carbon_density_start(t,j,"soilc") = fm_carbon_density(t,j,"past","soilc"); - -*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")),sum(clcl,pm_climate_class(j,clcl)*f52_growth_par(clcl,"m")),(ord(ac)-1)); - -*calculate litter and soil 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,j,ac,"soilc") = m_growth_litc_soilc(pc52_carbon_density_start(t,j,"soilc"),fm_carbon_density(t,j,"other","soilc"),(ord(ac)-1)); - - -*** EOF pre.gms *** diff --git a/modules/52_carbon/normal_dec17/realization.gms b/modules/52_carbon/normal_dec17/realization.gms index f092040919..2dfd80a022 100644 --- a/modules/52_carbon/normal_dec17/realization.gms +++ b/modules/52_carbon/normal_dec17/realization.gms @@ -1,31 +1,25 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 This realization -*' calculates annual land-related CO2 emissions as -*' difference of carbon stocks between the current and the previous time step. -*' Land-related CO2 emissions include CO2 emissions from land-use change as well as -*' changes in carbon stocks in the terrestrial biosphere due to climate change -*' (the later is only included if `c52_carbon_scenario = "cc"`). -*' The realization provides carbon density information on cellular level to all -*' land modules ([30_crop], [31_past], [32_forestry], [34_urban] and [35_natveg]), -*' which return land type specific carbon stocks to the carbon module. The realization +*' @description +*' This realization provides carbon density information on cellular level to all +*' land modules ([30_crop], [31_past], [32_forestry], [34_urban] and [35_natveg]). +*' The realization *' also provides carbon density for different age-classes, based on a *' chapman-richards volume growth model, to the land modules [32_forestry] and [35_natveg] -*' [@humpenoder_investigating_2014]. +*' [@humpenoder_investigating_2014 and @braakhekke_modelling_2019]. -*' @limitations CO2 emissions in the 1st time step (1995) are not meaningful because -*' carbon stock information prior to 1995 is not available +*' @limitations *####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/52_carbon/normal_dec17/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/52_carbon/normal_dec17/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/52_carbon/normal_dec17/input.gms" $Ifi "%phase%" == "equations" $include "./modules/52_carbon/normal_dec17/equations.gms" -$Ifi "%phase%" == "scaling" $include "./modules/52_carbon/normal_dec17/scaling.gms" -$Ifi "%phase%" == "preloop" $include "./modules/52_carbon/normal_dec17/preloop.gms" +$Ifi "%phase%" == "start" $include "./modules/52_carbon/normal_dec17/start.gms" $Ifi "%phase%" == "postsolve" $include "./modules/52_carbon/normal_dec17/postsolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/52_carbon/normal_dec17/scaling.gms b/modules/52_carbon/normal_dec17/scaling.gms deleted file mode 100644 index 3168a7d3ce..0000000000 --- a/modules/52_carbon/normal_dec17/scaling.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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_carbon_stock.scale(j,land,c_pools) = 10e3; diff --git a/modules/52_carbon/normal_dec17/sets.gms b/modules/52_carbon/normal_dec17/sets.gms new file mode 100644 index 0000000000..8bdf6321f3 --- /dev/null +++ b/modules/52_carbon/normal_dec17/sets.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + rcp52 climate change impact sceanrios + / RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU / +; diff --git a/modules/52_carbon/normal_dec17/start.gms b/modules/52_carbon/normal_dec17/start.gms new file mode 100644 index 0000000000..1db7c3dddf --- /dev/null +++ b/modules/52_carbon/normal_dec17/start.gms @@ -0,0 +1,38 @@ +*** | (C) 2008-2025 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 + +*age-class carbon density start values +pc52_carbon_density_start(t_all,j,"vegc") = 0; +pc52_carbon_density_start(t_all,j,"litc") = fm_carbon_density(t_all,j,"past","litc"); + +* ---------------------------- +* Forestry +* ---------------------------- + +*calculate vegetation age-class carbon density in current time step with chapman richards equation +pm_carbon_density_plantation_ac(t_all,j,ac,"vegc") = m_growth_vegc(pc52_carbon_density_start(t_all,j,"vegc"),fm_carbon_density(t_all,j,"secdforest","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)); + +*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_plantation_ac(t_all,j,ac,"litc") = m_growth_litc_soilc(pc52_carbon_density_start(t_all,j,"litc"),fm_carbon_density(t_all,j,"secdforest","litc"),(ord(ac)-1)); + +* ----------------------------- +* Natveg +* ----------------------------- + +*** Secondary forest +*calculate vegetation age-class carbon density in current time step with chapman richards equation +pm_carbon_density_secdforest_ac(t_all,j,ac,"vegc") = m_growth_vegc(pc52_carbon_density_start(t_all,j,"vegc"),fm_carbon_density(t_all,j,"secdforest","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_secdforest_ac(t_all,j,ac,"litc") = m_growth_litc_soilc(pc52_carbon_density_start(t_all,j,"litc"),fm_carbon_density(t_all,j,"secdforest","litc"),(ord(ac)-1)); + +*** Other land +*calculate vegetation age-class carbon density in current time step with chapman richards equation +pm_carbon_density_other_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_other_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)); diff --git a/modules/52_carbon/off/declarations.gms b/modules/52_carbon/off/declarations.gms deleted file mode 100644 index 1c4279b693..0000000000 --- a/modules/52_carbon/off/declarations.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 - -* Here you can put your additional declarations -parameters - pm_carbon_density_ac(t,j,ac,c_pools) Carbon density for ac and c_pools (tC per ha) - pcm_carbon_stock(j,land,c_pools) Current carbon in vegetation soil and litter for different land types (mio tC) -; - -positive variables - vm_carbon_stock(j,land,c_pools) Carbon in vegetation soil and litter for different land types (mio tC) - vm_carbon_stock_reduction(j,land,c_pools) Reduction in carbon stocks compared to previous time step (mio tC per time step) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_carbon_stock(t,j,land,c_pools,type) Carbon in vegetation soil and litter for different land types (mio tC) - ov_carbon_stock_reduction(t,j,land,c_pools,type) Reduction in carbon stocks compared to previous time step (mio tC per time step) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/52_carbon/off/input.gms b/modules/52_carbon/off/input.gms deleted file mode 100644 index 375f6a7225..0000000000 --- a/modules/52_carbon/off/input.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - -$setglobal c52_carbon_scenario nocc -* options: cc (climate change) -* nocc (no climate change) - -table fm_carbon_density(t_all,j,land,c_pools) LPJmL carbon density for land and carbon pools (tC per ha) -$ondelim -$include "./modules/52_carbon/input/lpj_carbon_stocks.cs3" -$offdelim -; -$if "%c52_carbon_scenario%" == "nocc" fm_carbon_density(t_all,j,land,c_pools) = fm_carbon_density("y1995",j,land,c_pools); -m_fillmissingyears(fm_carbon_density,"j,land,c_pools"); diff --git a/modules/52_carbon/off/not_used.txt b/modules/52_carbon/off/not_used.txt deleted file mode 100644 index 4cb56f7ef2..0000000000 --- a/modules/52_carbon/off/not_used.txt +++ /dev/null @@ -1,9 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason -pm_climate_class,input,not needed -pcm_land,input,not needed diff --git a/modules/52_carbon/off/postsolve.gms b/modules/52_carbon/off/postsolve.gms deleted file mode 100644 index 2d4d366cdc..0000000000 --- a/modules/52_carbon/off/postsolve.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_carbon_stock(t,j,land,c_pools,"marginal") = vm_carbon_stock.m(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"marginal") = vm_carbon_stock_reduction.m(j,land,c_pools); - ov_carbon_stock(t,j,land,c_pools,"level") = vm_carbon_stock.l(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"level") = vm_carbon_stock_reduction.l(j,land,c_pools); - ov_carbon_stock(t,j,land,c_pools,"upper") = vm_carbon_stock.up(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"upper") = vm_carbon_stock_reduction.up(j,land,c_pools); - ov_carbon_stock(t,j,land,c_pools,"lower") = vm_carbon_stock.lo(j,land,c_pools); - ov_carbon_stock_reduction(t,j,land,c_pools,"lower") = vm_carbon_stock_reduction.lo(j,land,c_pools); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/52_carbon/off/preloop.gms b/modules/52_carbon/off/preloop.gms deleted file mode 100644 index aad4eaba4d..0000000000 --- a/modules/52_carbon/off/preloop.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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 - -pm_carbon_density_ac(t,j,ac,c_pools) = 0; diff --git a/modules/52_carbon/off/presolve.gms b/modules/52_carbon/off/presolve.gms deleted file mode 100644 index 26a18738e9..0000000000 --- a/modules/52_carbon/off/presolve.gms +++ /dev/null @@ -1,10 +0,0 @@ -*** | (C) 2008-2019 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_carbon_stock.fx(j,land,c_pools) = 0; -vm_carbon_stock_reduction.fx(j,land,c_pools) = 0; -vm_btm_cell.fx(j,emis_co2,"co2_c") = 0; diff --git a/modules/52_carbon/off/realization.gms b/modules/52_carbon/off/realization.gms deleted file mode 100644 index 5305a25756..0000000000 --- a/modules/52_carbon/off/realization.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 -*' annual land-related CO2 emissions are assumed zero. - -*' @limitations CO2 emissions are assumed zero - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/52_carbon/off/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/52_carbon/off/input.gms" -$Ifi "%phase%" == "preloop" $include "./modules/52_carbon/off/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/52_carbon/off/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/52_carbon/off/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/53_methane/ipcc2006_aug22/declarations.gms b/modules/53_methane/ipcc2006_aug22/declarations.gms new file mode 100644 index 0000000000..be1d386d97 --- /dev/null +++ b/modules/53_methane/ipcc2006_aug22/declarations.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 + q53_emissionbal_ch4_ent_ferm(i) Detailed ch4 constraint for enteric fermentation before technical mitigation (tCH4) + q53_emissionbal_ch4_awms(i) Detailed ch4 constraint for animal waste management systems before technical mitigation (tCH4) + q53_emissionbal_ch4_rice(i) Detailed ch4 constraint for rice before technical mitigation (tCH4) + q53_emissions_resid_burn(i) Estimates ch4 emissions from the burning of agricultural residues (Mt X-N) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + oq53_emissionbal_ch4_ent_ferm(t,i,type) Detailed ch4 constraint for enteric fermentation before technical mitigation (tCH4) + oq53_emissionbal_ch4_awms(t,i,type) Detailed ch4 constraint for animal waste management systems before technical mitigation (tCH4) + oq53_emissionbal_ch4_rice(t,i,type) Detailed ch4 constraint for rice before technical mitigation (tCH4) + oq53_emissions_resid_burn(t,i,type) Estimates ch4 emissions from the burning of agricultural residues (Mt X-N) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/53_methane/ipcc2006_aug22/equations.gms b/modules/53_methane/ipcc2006_aug22/equations.gms new file mode 100644 index 0000000000..e0c7e51373 --- /dev/null +++ b/modules/53_methane/ipcc2006_aug22/equations.gms @@ -0,0 +1,72 @@ +*** | (C) 2008-2025 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 +*' +*' We calculate methane emissions in each regions (reg) (`vm_emissions_reg`) +*' from the aforementioned four sources of emissions step-by-step in the following four equations. +*' +*' The first equation describes how CH4 emission from enteric fermentation is calculated. +*' The equation shows that total methane from enteric fermentation depends on +*' the animal feed demand type (`vm_feed_intake`) and +*' the purpose of raising livestock - either for meat (`livst_rum`) and/or milk (`livst_milk`). +*' The factor 1/55.65 t/GJ in the equation is the energy content of methane. +*' The other scalars - 0.065 and 0.03 - refer to the share of gross energy (ge) in feed +*' released as methane for dairy cattle and ruminants respectively. + + q53_emissionbal_ch4_ent_ferm(i2) .. + vm_emissions_reg(i2,"ent_ferm","ch4") =e= 1/55.65 * + (sum(k_conc53, vm_feed_intake(i2,"livst_rum",k_conc53) + *fm_attributes("ge",k_conc53)*0.03) + + sum(k_conc53, vm_feed_intake(i2,"livst_milk",k_conc53) + *fm_attributes("ge",k_conc53)*0.065) + + sum((k_noconc53,k_ruminants53),vm_feed_intake(i2,k_ruminants53,k_noconc53) + *fm_attributes("ge",k_noconc53)*0.065) + ) * (1-sum(ct, im_maccs_mitigation(ct,i2,"ent_ferm","ch4"))); + +*' As such, methane from enteric fermentation depends on the feed quality and the purpose of livestock farming. +*' The feed quality (measured by energy content of the feed type) can be `k_conc53` +*' (with high energy contents, for example, temperate and tropical cereals, maize,pulses) or `k_noconc53` +*' (for example, pasture, fodder,crop residues). The purpose of livestock raising `k_ruminants53` +*' can be either for meat (`livst_rum`) or for milk (`livst_milk`). The parameter `fm_attributes` +*' in MAgPIE captures a content of some thing (e.g. gross energy-ge, dry matter-dm, reactive nitrogen-nr) +*' in a given commodity. +*' These attributes or coefficients are then used in content conversions in many modules of the model. +*' +*' The second equation of this realization is meant to calculate CH4 emission from +*' animal waste management (AWM). In general, AWM depends on the amount of manure +*' excreted in confinements (such as stables or barns) (see [55_awms]) and its +*' subsequent storage. +*' We calculate the CH4 emission per unit of nitrogen in manure based on @ipcc_2006_2006 +*' and Manure Management Emissions from @FAOSTAT. +*' See the module for more on calculation of methane from animal waste(or manure). + + q53_emissionbal_ch4_awms(i2) .. + vm_emissions_reg(i2,"awms","ch4") =e= + sum(kli, vm_manure(i2, kli, "confinement", "nr") + * sum(ct, f53_ef_ch4_awms(ct,i2,kli))) + * (1-sum(ct, im_maccs_mitigation(ct,i2,"awms","ch4"))); + +*' The third equation of this realization calculates methane emissions from rice cultivation. +*' As presented below CH4 from rice is a function of harvested area of rice +*' and th CH4 emission intensity of rice (measured as CH4 per hectare of rice). +*' The calculation is based on @ipcc_2006_2006 and Rice Cultivation Emissions from @FAOSTAT. + + q53_emissionbal_ch4_rice(i2) .. + vm_emissions_reg(i2,"rice","ch4") =e= + sum((cell(i2,j2),w), vm_area(j2,"rice_pro",w) + * sum(ct,f53_ef_ch4_rice(ct,i2))) + * (1-sum(ct, im_maccs_mitigation(ct,i2,"rice","ch4"))); + + +*' The fourth equation calculates emissions from burning crop residues for CH4. +*' This calculation follows the 2019 Refinement to the 2006 IPPC Guidelines for +*' National Greenhouse Gas Inventories, Eq. 2.27. + + q53_emissions_resid_burn(i2) .. + vm_emissions_reg(i2,"resid_burn","ch4") =e= + sum(kcr, vm_res_ag_burn(i2,kcr,"dm")) * s53_ef_ch4_res_ag_burn; diff --git a/modules/53_methane/ipcc2006_aug22/input.gms b/modules/53_methane/ipcc2006_aug22/input.gms new file mode 100644 index 0000000000..441e3ef4d4 --- /dev/null +++ b/modules/53_methane/ipcc2006_aug22/input.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 + +parameter f53_ef_ch4_awms(t_all,i,kli) CH4 emission per livestock products (CH4 per tDM) +/ +$ondelim +$include "./modules/53_methane/input/f53_EFch4AWMS.cs4" +$offdelim +/ +; + +parameter f53_ef_ch4_rice(t_all,i) CH4 emission per ha rice (CH4 per ha) +/ +$ondelim +$include "./modules/53_methane/input/f53_EFch4Rice.cs4" +$offdelim +/ +; + +scalar + s53_ef_ch4_res_ag_burn CH4 emissions from the burning of agricultural residues (tCH4 per tDM) / 0.0027 / +; + diff --git a/modules/53_methane/ipcc2006_aug22/postsolve.gms b/modules/53_methane/ipcc2006_aug22/postsolve.gms new file mode 100644 index 0000000000..43f97d8062 --- /dev/null +++ b/modules/53_methane/ipcc2006_aug22/postsolve.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + oq53_emissionbal_ch4_ent_ferm(t,i,"marginal") = q53_emissionbal_ch4_ent_ferm.m(i); + oq53_emissionbal_ch4_awms(t,i,"marginal") = q53_emissionbal_ch4_awms.m(i); + oq53_emissionbal_ch4_rice(t,i,"marginal") = q53_emissionbal_ch4_rice.m(i); + oq53_emissions_resid_burn(t,i,"marginal") = q53_emissions_resid_burn.m(i); + oq53_emissionbal_ch4_ent_ferm(t,i,"level") = q53_emissionbal_ch4_ent_ferm.l(i); + oq53_emissionbal_ch4_awms(t,i,"level") = q53_emissionbal_ch4_awms.l(i); + oq53_emissionbal_ch4_rice(t,i,"level") = q53_emissionbal_ch4_rice.l(i); + oq53_emissions_resid_burn(t,i,"level") = q53_emissions_resid_burn.l(i); + oq53_emissionbal_ch4_ent_ferm(t,i,"upper") = q53_emissionbal_ch4_ent_ferm.up(i); + oq53_emissionbal_ch4_awms(t,i,"upper") = q53_emissionbal_ch4_awms.up(i); + oq53_emissionbal_ch4_rice(t,i,"upper") = q53_emissionbal_ch4_rice.up(i); + oq53_emissions_resid_burn(t,i,"upper") = q53_emissions_resid_burn.up(i); + oq53_emissionbal_ch4_ent_ferm(t,i,"lower") = q53_emissionbal_ch4_ent_ferm.lo(i); + oq53_emissionbal_ch4_awms(t,i,"lower") = q53_emissionbal_ch4_awms.lo(i); + oq53_emissionbal_ch4_rice(t,i,"lower") = q53_emissionbal_ch4_rice.lo(i); + oq53_emissions_resid_burn(t,i,"lower") = q53_emissions_resid_burn.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/53_methane/ipcc2006_aug22/preloop.gms b/modules/53_methane/ipcc2006_aug22/preloop.gms new file mode 100644 index 0000000000..901d7a168e --- /dev/null +++ b/modules/53_methane/ipcc2006_aug22/preloop.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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,emis_source,"ch4") = 0; +vm_emissions_reg.lo(i,emis_source_methane53,"ch4") = -Inf; +vm_emissions_reg.up(i,emis_source_methane53,"ch4") = Inf; diff --git a/modules/53_methane/ipcc2006_aug22/realization.gms b/modules/53_methane/ipcc2006_aug22/realization.gms new file mode 100644 index 0000000000..3f6e4bb76c --- /dev/null +++ b/modules/53_methane/ipcc2006_aug22/realization.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 This module realization calculates methane from different +*' agricultural sources based on the @ipcc_2006_2006. +*' Methane emission sources considered in the module are enteric fermentation, +*' animal waste management, and rice. Further, methane emissions from the burning +*' of agricultural residues is incorporated, with emissions factors taken +*' from the IPCC 2019 revision. + +*' @limitations CH4 emissions from animal waste management may be +*' inconsistent with CH4 emissions from enteric fermentation. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/53_methane/ipcc2006_aug22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/53_methane/ipcc2006_aug22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/53_methane/ipcc2006_aug22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/53_methane/ipcc2006_aug22/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/53_methane/ipcc2006_aug22/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/53_methane/ipcc2006_aug22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/53_methane/ipcc2006_aug22/sets.gms b/modules/53_methane/ipcc2006_aug22/sets.gms new file mode 100644 index 0000000000..b7a9792193 --- /dev/null +++ b/modules/53_methane/ipcc2006_aug22/sets.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2025 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 + +k_conc53(kall) feedstuff with high energy content + / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, + potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro, + oils,oilcakes,sugar,molasses,distillers_grain,brans,scp, + livst_rum, livst_pig,livst_chick, livst_egg, fish / + +k_noconc53(kall) non-concentrates + / pasture, foddr, res_cereals, res_fibrous, res_nonfibrous / + +k_ruminants53(kli) ruminant subset + / livst_rum, livst_milk / + +emis_source_methane53(emis_source) emission sources + / awms, rice, ent_ferm, resid_burn / + +; diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/declarations.gms b/modules/53_methane/ipcc2006_flexreg_apr16/declarations.gms deleted file mode 100644 index a35dcf0305..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/declarations.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2019 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 - q53_emissionbal_ch4_ent_ferm(i) Detailed ch4 constraint for enteric fermentation before technical mitigation (tCH4) - q53_emissionbal_ch4_awms(i) Detailed ch4 constraint for animal waste management systems before technical mitigation (tCH4) - q53_emissionbal_ch4_rice(i) Detailed ch4 constraint for rice before technical mitigation (tCH4) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - oq53_emissionbal_ch4_ent_ferm(t,i,type) Detailed ch4 constraint for enteric fermentation before technical mitigation (tCH4) - oq53_emissionbal_ch4_awms(t,i,type) Detailed ch4 constraint for animal waste management systems before technical mitigation (tCH4) - oq53_emissionbal_ch4_rice(t,i,type) Detailed ch4 constraint for rice before technical mitigation (tCH4) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/equations.gms b/modules/53_methane/ipcc2006_flexreg_apr16/equations.gms deleted file mode 100644 index 08e67c8fa1..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/equations.gms +++ /dev/null @@ -1,60 +0,0 @@ -*** | (C) 2008-2019 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 -*' -*' We calculate methane emissions before technical mitigation(btm) in each regions (reg) (`vm_btm_reg`) -*' from the aforementioned three sources of emissions step-by-step in the following three equations. -*' -*' The first equation describes how CH4 emission from enteric fermentation is calculated. -*' The equation shows that total methane from enteric fermentation depends on -*' the animal feed demand type (`vm_dem_feed`) and -*' the purpose of raising livestock - either for meat (`livst_rum`) and/or milk (`livst_milk`). -*' The factor 1/55.65 t/GJ in the equation is the energy content of methane. -*' The other scalars - 0.065 and 0.03 - refer to the share of gross energy (ge) in feed -*' released as methane for dairy cattle and ruminants respectively. - - q53_emissionbal_ch4_ent_ferm(i2) .. - vm_btm_reg(i2,"ent_ferm","ch4") =e= 1/55.65 * - (sum(k_conc53, vm_dem_feed(i2,"livst_rum",k_conc53) - *fm_attributes("ge",k_conc53)*0.03) - + sum(k_conc53, vm_dem_feed(i2,"livst_milk",k_conc53) - *fm_attributes("ge",k_conc53)*0.065) - + sum((k_noconc53,k_ruminants53),vm_dem_feed(i2,k_ruminants53,k_noconc53) - *fm_attributes("ge",k_noconc53)*0.065)); - -*' As such, methane from enteric fermentation depends on the feed quality and the purpose of livestock farming. -*' The feed quality (measured by energy content of the feed type) can be `k_conc53` -*' ( with high energy contents, for example, temperate and tropical cereals, maize,pulses) or `k_noconc53` -*' (for example, pasture, fodder,crop residues). The purpose of livestock raising `k_ruminants53` -*' can be either for meat (`livst_rum`) or for milk (`livst_milk`). The parameter `fm_attributes` -*' in MAgPIE captures a content of some thing (e.g. gross energy-ge, dry matter-dm, reactive nitrogen-nr) -*' in a given commodity. -*' These attributes or coefficients are then used in content conversions in may modules of the model. -*' -*' The second equation of this realization is meant to calculate CH4 emission from -*' animal waste management (AWM). In general, AWM depends on the amount of manure -*' excreted in confinements (such as stables or barns) (see [55_awms])and its -*' subsequent storage. -*' We calculate the CH4 emission per unit of nitrogen in manure based on @ipcc_2006_2006 -*' and Manure Management Emissions from @FAOSTAT . -*' See the module for more on calculation of methane from animal waste(or manure) . - - q53_emissionbal_ch4_awms(i2) .. - vm_btm_reg(i2,"awms","ch4") =e= - sum(kli, vm_manure(i2, kli, "confinement", "nr") - * sum(ct, f53_ef_ch4_awms(ct,i2,kli))); - -*' The third equation of this realization calculates methane emissions from rice cultivation. -*' As presented below CH4 from rice is a function of harvested area of rice -*' and th CH4 emission intensity of rice (measured as CH4 per hectare of rice). -*' The calculation is based on @ipcc_2006_2006 and Rice Cultivation Emissions from @FAOSTAT. - - q53_emissionbal_ch4_rice(i2) .. - vm_btm_reg(i2,"rice","ch4") =e= - sum((cell(i2,j2),w), vm_area(j2,"rice_pro",w) - * sum(ct,f53_ef_ch4_rice(ct,i2))); diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/input.gms b/modules/53_methane/ipcc2006_flexreg_apr16/input.gms deleted file mode 100644 index 429491a3d4..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/input.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2019 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 - -parameter f53_ef_ch4_awms(t_all,i,kli) CH4 emission per livestock products (CH4 per tDM) -/ -$ondelim -$include "./modules/53_methane/input/f53_EFch4AWMS.cs4" -$offdelim -/ -; - -parameter f53_ef_ch4_rice(t_all,i) CH4 emission per ha rice (CH4 per ha) - / -$ondelim -$include "./modules/53_methane/input/f53_EFch4Rice.cs4" -$offdelim - / -; diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/postsolve.gms b/modules/53_methane/ipcc2006_flexreg_apr16/postsolve.gms deleted file mode 100644 index 80e713c647..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/postsolve.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - oq53_emissionbal_ch4_ent_ferm(t,i,"marginal") = q53_emissionbal_ch4_ent_ferm.m(i); - oq53_emissionbal_ch4_awms(t,i,"marginal") = q53_emissionbal_ch4_awms.m(i); - oq53_emissionbal_ch4_rice(t,i,"marginal") = q53_emissionbal_ch4_rice.m(i); - oq53_emissionbal_ch4_ent_ferm(t,i,"level") = q53_emissionbal_ch4_ent_ferm.l(i); - oq53_emissionbal_ch4_awms(t,i,"level") = q53_emissionbal_ch4_awms.l(i); - oq53_emissionbal_ch4_rice(t,i,"level") = q53_emissionbal_ch4_rice.l(i); - oq53_emissionbal_ch4_ent_ferm(t,i,"upper") = q53_emissionbal_ch4_ent_ferm.up(i); - oq53_emissionbal_ch4_awms(t,i,"upper") = q53_emissionbal_ch4_awms.up(i); - oq53_emissionbal_ch4_rice(t,i,"upper") = q53_emissionbal_ch4_rice.up(i); - oq53_emissionbal_ch4_ent_ferm(t,i,"lower") = q53_emissionbal_ch4_ent_ferm.lo(i); - oq53_emissionbal_ch4_awms(t,i,"lower") = q53_emissionbal_ch4_awms.lo(i); - oq53_emissionbal_ch4_rice(t,i,"lower") = q53_emissionbal_ch4_rice.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/preloop.gms b/modules/53_methane/ipcc2006_flexreg_apr16/preloop.gms deleted file mode 100644 index b361ded127..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/preloop.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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 - - - diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/presolve.gms b/modules/53_methane/ipcc2006_flexreg_apr16/presolve.gms deleted file mode 100644 index 08cdf7de43..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/presolve.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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_btm_reg.fx(i,emis_source_nomethane53,"ch4") = 0; diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/realization.gms b/modules/53_methane/ipcc2006_flexreg_apr16/realization.gms deleted file mode 100644 index 579056b4e6..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/realization.gms +++ /dev/null @@ -1,24 +0,0 @@ -*** | (C) 2008-2019 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 This module realization calculates methane from different -*' agricultural sources based on the @ipcc_2006_2006. -*' Methane emission sources considered in the module are enteric fermentation, -*' animal waste management, and rice. - -*' @limitations CH4 emissions from animal waste management may be -*' inconsistent with CH4 emissions from enteric fermentation. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/53_methane/ipcc2006_flexreg_apr16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/53_methane/ipcc2006_flexreg_apr16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/53_methane/ipcc2006_flexreg_apr16/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/53_methane/ipcc2006_flexreg_apr16/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/53_methane/ipcc2006_flexreg_apr16/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/53_methane/ipcc2006_flexreg_apr16/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/53_methane/ipcc2006_flexreg_apr16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/53_methane/ipcc2006_flexreg_apr16/sets.gms b/modules/53_methane/ipcc2006_flexreg_apr16/sets.gms deleted file mode 100644 index caf213575f..0000000000 --- a/modules/53_methane/ipcc2006_flexreg_apr16/sets.gms +++ /dev/null @@ -1,34 +0,0 @@ -*** | (C) 2008-2019 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 - -k_conc53(kall) feedstuff with high energy content - / tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,puls_pro, - potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro, - oils,oilcakes,sugar,molasses,distillers_grain,brans,scp, - livst_rum, livst_pig,livst_chick, livst_egg, fish / - -k_noconc53(kall) non-concentrates - / pasture, foddr, res_cereals, res_fibrous, res_nonfibrous / - -k_ruminants53(kli) ruminant subset - / livst_rum, livst_milk / - -emis_source_nomethane53(emis_source) emission sources - / inorg_fert, man_crop, resid, man_past, som, - resid_burn, - crop_vegc, crop_litc, crop_soilc, - past_vegc, past_litc, past_soilc, - forestry_vegc, forestry_litc, forestry_soilc, - primforest_vegc, primforest_litc, primforest_soilc, - secdforest_vegc, secdforest_litc, secdforest_soilc, - urban_vegc, urban_litc, urban_soilc, - other_vegc, other_litc, other_soilc, - beccs / - -; diff --git a/modules/53_methane/module.gms b/modules/53_methane/module.gms index 1cc9948c96..835dfec337 100644 --- a/modules/53_methane/module.gms +++ b/modules/53_methane/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -9,11 +9,12 @@ *' @description This module calculates methane emissions according *' to 2006 IPCC Guidelines of National Greenhouse Gas Inventories. -*' See also @ipcc_2006_2006. - +*' See also @ipcc_2006_2006. Further, using the IPCC 2019 revision, +*' this module calculations CH4 emissions from the burning of +*' agricultural residues. *' @authors Benjamin Leon Bodirsky *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%methane%" == "ipcc2006_flexreg_apr16" $include "./modules/53_methane/ipcc2006_flexreg_apr16/realization.gms" +$Ifi "%methane%" == "ipcc2006_aug22" $include "./modules/53_methane/ipcc2006_aug22/realization.gms" $Ifi "%methane%" == "off" $include "./modules/53_methane/off/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/53_methane/off/not_used.txt b/modules/53_methane/off/not_used.txt index 41907e68e8..28d8c7978a 100644 --- a/modules/53_methane/off/not_used.txt +++ b/modules/53_methane/off/not_used.txt @@ -1,12 +1,7 @@ -# | (C) 2008-2019 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 - name,type,reason vm_area,input,not needed -vm_dem_feed,input,not needed -fm_attributes,input, not needed +vm_feed_intake,input,not needed +fm_attributes,input,not needed vm_manure,input,questionnaire +vm_res_ag_burn,input,not needed +im_maccs_mitigation,input,questionnaire diff --git a/modules/53_methane/off/preloop.gms b/modules/53_methane/off/preloop.gms new file mode 100644 index 0000000000..aeec738dcd --- /dev/null +++ b/modules/53_methane/off/preloop.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +*' @code +*' Methane emission from agricultural sources equals to zero. + +vm_emissions_reg.fx(i,emis_source,"ch4") = 0; diff --git a/modules/53_methane/off/presolve.gms b/modules/53_methane/off/presolve.gms deleted file mode 100644 index 145fb01de6..0000000000 --- a/modules/53_methane/off/presolve.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @code -*' Methane emission from agricultural sources equals to zero. - - vm_btm_reg.fx(i,emis_source,"ch4") = 0; diff --git a/modules/53_methane/off/realization.gms b/modules/53_methane/off/realization.gms index 4eec2e4018..733a89927c 100644 --- a/modules/53_methane/off/realization.gms +++ b/modules/53_methane/off/realization.gms @@ -1,17 +1,19 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 This realization is simple and accounts no methane emissions. -*' We acknowledge this is unrealistic. It is presented here for mere comparison and completeness. -*' +*' @description No representation of methane emissions within the model. While unrealistic, this +*' realization may be useful for comparisons and completeness. When used, this realization +*' sets all emissions from enteric fermentation, animal waste management, rice cultivation, and +*' agricultural residue burning to 0. + *' @limitations It is unrealistic to consider zero methane emissions and to ignore it from a model *' such as MAgPIE which is meant to assess impacts of agricultural production on environment. *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/53_methane/off/sets.gms" -$Ifi "%phase%" == "presolve" $include "./modules/53_methane/off/presolve.gms" +$Ifi "%phase%" == "preloop" $include "./modules/53_methane/off/preloop.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/53_methane/off/sets.gms b/modules/53_methane/off/sets.gms index e9b4d1b843..4132949d03 100644 --- a/modules/53_methane/off/sets.gms +++ b/modules/53_methane/off/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/54_phosphorus/module.gms b/modules/54_phosphorus/module.gms index 06176e67cc..10c75a265e 100644 --- a/modules/54_phosphorus/module.gms +++ b/modules/54_phosphorus/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/54_phosphorus/off/declarations.gms b/modules/54_phosphorus/off/declarations.gms index 704bb9aeb8..0d33e46f6c 100644 --- a/modules/54_phosphorus/off/declarations.gms +++ b/modules/54_phosphorus/off/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,11 +7,11 @@ variables - vm_p_fert_costs(i) costs for mineral fertilizers (mio. USD05MER per yr) + vm_p_fert_costs(i) costs for mineral fertilizers (mio. USD17MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_p_fert_costs(t,i,type) costs for mineral fertilizers (mio. USD05MER per yr) + ov_p_fert_costs(t,i,type) costs for mineral fertilizers (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/54_phosphorus/off/not_used.txt b/modules/54_phosphorus/off/not_used.txt deleted file mode 100644 index 4b81dfbae2..0000000000 --- a/modules/54_phosphorus/off/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason diff --git a/modules/54_phosphorus/off/postsolve.gms b/modules/54_phosphorus/off/postsolve.gms index fd12d3b13f..301cf53fa8 100644 --- a/modules/54_phosphorus/off/postsolve.gms +++ b/modules/54_phosphorus/off/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/54_phosphorus/off/preloop.gms b/modules/54_phosphorus/off/preloop.gms index 75f31dff3f..9987bb2193 100644 --- a/modules/54_phosphorus/off/preloop.gms +++ b/modules/54_phosphorus/off/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/54_phosphorus/off/realization.gms b/modules/54_phosphorus/off/realization.gms index edcce13e58..3d2ab2017d 100644 --- a/modules/54_phosphorus/off/realization.gms +++ b/modules/54_phosphorus/off/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/ipcc2006_aug16/declarations.gms b/modules/55_awms/ipcc2006_aug16/declarations.gms index fd4eecfaa9..ac803b8de6 100644 --- a/modules/55_awms/ipcc2006_aug16/declarations.gms +++ b/modules/55_awms/ipcc2006_aug16/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,28 +7,30 @@ parameters - i55_manure_recycling_share(i,kli,awms_conf,npk) Share of manure recycled (tNr per tNr) - ic55_manure_fuel_shr(i,kli) Share of manure excreted on pastures used for fuel (tNr per tNr) - ic55_awms_shr(i,kli,awms_conf) Share of manure Nr managed in each animal waste management systems (tNr per tNr) + i55_manure_recycling_share(i,kli,awms_conf,npk) Share of manure recycled (tNr per tNr) + ic55_manure_fuel_shr(i,kli) Share of manure excreted on pastures used for fuel (tNr per tNr) + ic55_awms_shr(i,kli,awms_conf) Share of manure Nr managed in each animal waste management systems (tNr per tNr) + p55_region_shr(t_all,i) AWM scenario share of the region (1) + p55_country_switch(iso) Switch indicating whether country is affected by selected awm scenario (1) ; + positive variables - vm_manure(i, kli, awms, npk) Calculation of manure excreted in confinements (mio t X) - v55_feed_intake(i, kli, awms, npk) Calculation of manure excreted in confinements (mio t X) - vm_manure_recycling(i, npk) Manure being recycled to croplands (mio t X) - vm_manure_confinement(i,kli,awms_conf,npk) Manure excreted in confinements managed in different awms (mio t X) + vm_manure(i, kli, awms, npk) Calculation of manure excreted in confinements (mio t X) + v55_feed_intake(i, kli, awms, npk) Calculation of manure excreted in confinements (mio t X) + vm_manure_recycling(i, npk) Manure being recycled to croplands (mio t X) + vm_manure_confinement(i,kli,awms_conf,npk) Manure excreted in confinements managed in different awms (mio t X) ; equations - q55_bal_intake_grazing_pasture(i,kli, npk) Nutrient balance for intake of grazing animals on pastures (mio t X) - q55_bal_intake_confinement(i,kli, npk) Nutrient balance for intake in confinement (mio t X) - q55_bal_intake_grazing_cropland(i,kli, npk) Nutrient balance for intake of grazing animals on cropland (mio t X) - q55_bal_intake_fuel(i,kli, npk) Nutrient balance for intake of grazing animals on pasture whose excreate are collected for household fuel (mio t X) - - q55_bal_manure(i,kli,awms,npk) Calculation of manure (mio t X) - q55_manure_confinement(i,kli,awms_conf,npk) Manure from animals in confinement managed in different awms (mio t X) - q55_manure_recycling(i, npk) Manure from animals in confinement recycling to cropland (mio t X) + q55_bal_intake_grazing_pasture(i,kli, npk) Nutrient balance for intake of grazing animals on pastures (mio t X) + q55_bal_intake_confinement(i,kli, npk) Nutrient balance for intake in confinement (mio t X) + q55_bal_intake_grazing_cropland(i,kli, npk) Nutrient balance for intake of grazing animals on cropland (mio t X) + q55_bal_intake_fuel(i,kli, npk) Nutrient balance for intake of grazing animals on pasture whose excreate are collected for household fuel (mio t X) + q55_bal_manure(i,kli,awms,npk) Calculation of manure (mio t X) + q55_manure_confinement(i,kli,awms_conf,npk) Manure from animals in confinement managed in different awms (mio t X) + q55_manure_recycling(i, npk) Manure from animals in confinement recycling to cropland (mio t X) ; diff --git a/modules/55_awms/ipcc2006_aug16/equations.gms b/modules/55_awms/ipcc2006_aug16/equations.gms index ac002ec1a2..cb48533db2 100644 --- a/modules/55_awms/ipcc2006_aug16/equations.gms +++ b/modules/55_awms/ipcc2006_aug16/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -25,25 +25,25 @@ q55_bal_intake_confinement(i2,kli,npk) .. v55_feed_intake(i2, kli, "confinement",npk) =e= - sum(kcr,vm_dem_feed(i2,kli,kcr) * fm_attributes(npk,kcr)) - + sum(kap,vm_dem_feed(i2,kli,kap) * fm_attributes(npk,kap)) - + sum(ksd,vm_dem_feed(i2,kli,ksd) * fm_attributes(npk,ksd)) - + sum(kres,vm_dem_feed(i2,kli,kres) * fm_attributes(npk,kres) - *(1-(1-sum(ct,im_development_state(ct,i2))))*0.25) + sum(kcr,vm_feed_intake(i2,kli,kcr) * fm_attributes(npk,kcr)) + + sum(kap,vm_feed_intake(i2,kli,kap) * fm_attributes(npk,kap)) + + sum(ksd,vm_feed_intake(i2,kli,ksd) * fm_attributes(npk,ksd)) + + sum(kres,vm_feed_intake(i2,kli,kres) * fm_attributes(npk,kres) + *(1-(1-sum(ct,im_development_state(ct,i2)))*0.25)) ; *' b) grazing animals on pastures where the manure stays on pastures q55_bal_intake_grazing_pasture(i2,kli,npk) .. v55_feed_intake(i2, kli, "grazing",npk) =e= - (vm_dem_feed(i2,kli,"pasture")) * fm_attributes(npk,"pasture") + (vm_feed_intake(i2,kli,"pasture")) * fm_attributes(npk,"pasture") *(1-ic55_manure_fuel_shr(i2,kli)) ; *' c) grazing animals on pastures where the manure is collected as household fuel q55_bal_intake_fuel(i2,kli,npk) .. v55_feed_intake(i2, kli, "fuel",npk) =e= - (vm_dem_feed(i2,kli,"pasture")) * fm_attributes(npk,"pasture") + (vm_feed_intake(i2,kli,"pasture")) * fm_attributes(npk,"pasture") *sum(ct,ic55_manure_fuel_shr(i2,kli)) ; @@ -51,7 +51,7 @@ q55_bal_intake_grazing_cropland(i2,kli,npk) .. v55_feed_intake(i2, kli, "stubble_grazing",npk) =e= - sum(kres,vm_dem_feed(i2,kli,kres) * fm_attributes(npk,kres) + sum(kres,vm_feed_intake(i2,kli,kres) * fm_attributes(npk,kres) *(1 - sum(ct,im_development_state(ct,i2)))*0.25) ; @@ -59,7 +59,7 @@ *' on the development state and has to be subtracted from the residues fed to confined animals. *' We assume that in developing regions 25% of residues are grazed by animals on stubble fields, *' whereas stubble grazing is assumed to not occur in developed regions. - + *' The manure is estimated by subtracting from feed a certain share which is *' incorporated into animal biomass. This share depends on the productivity of *' the animal and is calculated in the preprocessing, also for computational diff --git a/modules/55_awms/ipcc2006_aug16/input.gms b/modules/55_awms/ipcc2006_aug16/input.gms index 330f7ecd21..f1fa312d1b 100644 --- a/modules/55_awms/ipcc2006_aug16/input.gms +++ b/modules/55_awms/ipcc2006_aug16/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,8 +7,40 @@ $setglobal c55_scen_conf ssp2 +$setglobal c55_scen_conf_noselect ssp2 * options: SSP: "ssp1", "ssp2", "ssp3", "ssp4", "ssp5", "constant" * SRES: "a1", "a2", "b1", "b2" +* GoodPractice: "GoodPractice" + +* Set-switch for countries affected by regional ghg policy +* Default: all iso countries selected +sets + scen_countries55(iso) countries to be affected by awm scenario / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; parameter f55_awms_recycling_share(i,kli,awms_conf) share of Nr in confinement recycled (tNr per tNr) / @@ -26,7 +58,7 @@ $offdelim / ; -parameter f55_manure_fuel_shr(t_all,i,kli,gdp_scen09) share of Nr in confinement recycled (tNr per tNr) +parameter f55_manure_fuel_shr(t_all,i,kli,pop_gdp_scen09) share of Nr in confinement recycled (tNr per tNr) / $ondelim $include "./modules/55_awms/ipcc2006_aug16/input/f55_manure_fuel_shr.cs4" diff --git a/modules/55_awms/ipcc2006_aug16/nl_fix.gms b/modules/55_awms/ipcc2006_aug16/nl_fix.gms index 5963ccda1d..c95943825e 100644 --- a/modules/55_awms/ipcc2006_aug16/nl_fix.gms +++ b/modules/55_awms/ipcc2006_aug16/nl_fix.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/ipcc2006_aug16/nl_relax.gms b/modules/55_awms/ipcc2006_aug16/nl_relax.gms index 5963ccda1d..c95943825e 100644 --- a/modules/55_awms/ipcc2006_aug16/nl_relax.gms +++ b/modules/55_awms/ipcc2006_aug16/nl_relax.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/ipcc2006_aug16/nl_release.gms b/modules/55_awms/ipcc2006_aug16/nl_release.gms index 5963ccda1d..c95943825e 100644 --- a/modules/55_awms/ipcc2006_aug16/nl_release.gms +++ b/modules/55_awms/ipcc2006_aug16/nl_release.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/ipcc2006_aug16/postsolve.gms b/modules/55_awms/ipcc2006_aug16/postsolve.gms index 5808c22b79..1f75951f70 100644 --- a/modules/55_awms/ipcc2006_aug16/postsolve.gms +++ b/modules/55_awms/ipcc2006_aug16/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/ipcc2006_aug16/preloop.gms b/modules/55_awms/ipcc2006_aug16/preloop.gms index 25ec35da12..e80d7a9a32 100644 --- a/modules/55_awms/ipcc2006_aug16/preloop.gms +++ b/modules/55_awms/ipcc2006_aug16/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/ipcc2006_aug16/presolve.gms b/modules/55_awms/ipcc2006_aug16/presolve.gms index 4271374794..e2a906bcb5 100644 --- a/modules/55_awms/ipcc2006_aug16/presolve.gms +++ b/modules/55_awms/ipcc2006_aug16/presolve.gms @@ -1,9 +1,26 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -ic55_manure_fuel_shr(i,kli)=f55_manure_fuel_shr(t,i,kli,"%c09_gdp_scenario%"); -ic55_awms_shr(i,kli,awms_conf)= f55_awms_shr(t,i,"%c55_scen_conf%",kli,awms_conf); +****** Region price share for awm scenario of selective countries: +* Country switch to determine countries for which awm scenario shall be applied. +* In the default case, the awm scenario affects all countries when activated. +p55_country_switch(iso) = 0; +p55_country_switch(scen_countries55) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p55_region_shr(t_all,i) = sum(i_to_iso(i,iso), p55_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + + +if(m_year(t) <= sm_fix_SSP2, + ic55_awms_shr(i,kli,awms_conf) = f55_awms_shr(t,i,"ssp2",kli,awms_conf); + ic55_manure_fuel_shr(i,kli)=f55_manure_fuel_shr(t,i,kli,"SSP2"); +else + ic55_awms_shr(i,kli,awms_conf) = f55_awms_shr(t,i,"%c55_scen_conf%",kli,awms_conf) * p55_region_shr(t,i) + + f55_awms_shr(t,i,"%c55_scen_conf_noselect%",kli,awms_conf) * (1-p55_region_shr(t,i)); + ic55_manure_fuel_shr(i,kli)=f55_manure_fuel_shr(t,i,kli,"%c09_gdp_scenario%"); +); diff --git a/modules/55_awms/ipcc2006_aug16/realization.gms b/modules/55_awms/ipcc2006_aug16/realization.gms index 7dfda90d0d..30b5fb8f9d 100644 --- a/modules/55_awms/ipcc2006_aug16/realization.gms +++ b/modules/55_awms/ipcc2006_aug16/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/ipcc2006_aug16/sets.gms b/modules/55_awms/ipcc2006_aug16/sets.gms index 18e6beac9a..1d72959a25 100644 --- a/modules/55_awms/ipcc2006_aug16/sets.gms +++ b/modules/55_awms/ipcc2006_aug16/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -17,6 +17,6 @@ sets / lagoon, liquid_slurry, solid_storage, drylot, daily_spread, digester, other, pit_short, pit_long / scen_conf55 awms scenarios - / constant,ssp1,ssp2,ssp3,ssp4,ssp5,a1,a2,b1,b2 / + / constant,ssp1,ssp2,ssp3,ssp4,ssp5,sdp,a1,a2,b1,b2,GoodPractice/ ; diff --git a/modules/55_awms/module.gms b/modules/55_awms/module.gms index e442535dc7..7aaf10fdec 100644 --- a/modules/55_awms/module.gms +++ b/modules/55_awms/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/off/declarations.gms b/modules/55_awms/off/declarations.gms index 40a0303a54..86ee226470 100644 --- a/modules/55_awms/off/declarations.gms +++ b/modules/55_awms/off/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/off/not_used.txt b/modules/55_awms/off/not_used.txt index 04cb67f6a3..08a1b7ef34 100644 --- a/modules/55_awms/off/not_used.txt +++ b/modules/55_awms/off/not_used.txt @@ -1,12 +1,7 @@ -# | (C) 2008-2019 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 - name,type,reason -vm_dem_feed,input,not needed +vm_feed_intake,input,not needed fm_attributes, input, not needed im_development_state, input, new flexreg structure im_slaughter_feed_share,input,questionnaire +sm_fix_SSP2, input, not used +im_pop_iso, input, not used diff --git a/modules/55_awms/off/postsolve.gms b/modules/55_awms/off/postsolve.gms index 802e6f92cf..2976401a91 100644 --- a/modules/55_awms/off/postsolve.gms +++ b/modules/55_awms/off/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/off/preloop.gms b/modules/55_awms/off/preloop.gms index 7c234759bf..e83652e55a 100644 --- a/modules/55_awms/off/preloop.gms +++ b/modules/55_awms/off/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/off/realization.gms b/modules/55_awms/off/realization.gms index 4cb3defc12..520069ecaf 100644 --- a/modules/55_awms/off/realization.gms +++ b/modules/55_awms/off/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/55_awms/off/sets.gms b/modules/55_awms/off/sets.gms index b18e6ccd79..e007f087de 100644 --- a/modules/55_awms/off/sets.gms +++ b/modules/55_awms/off/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/56_ghg_policy/input/files b/modules/56_ghg_policy/input/files index fe80b6d060..c7c9754430 100644 --- a/modules/56_ghg_policy/input/files +++ b/modules/56_ghg_policy/input/files @@ -1,4 +1,3 @@ * list of files that are required here f56_pollutant_prices.cs3 -f56_aff_policy.csv f56_emis_policy.csv diff --git a/modules/56_ghg_policy/module.gms b/modules/56_ghg_policy/module.gms index 0a9d1d39c1..45029c3f6e 100644 --- a/modules/56_ghg_policy/module.gms +++ b/modules/56_ghg_policy/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -15,7 +15,8 @@ *' Technically, every ton of emission is multiplied with an emission price to *' determine emission costs. Emission sources can be excluded from pricing by switches *' defined in config/default.cfg. -*' +*' The module collects carbon stock information in the interface `vm_carbon_stock` +*' from all land modules ([30_crop], [31_past], [32_forestry], [34_urban] and [35_natveg]). *' Please note that emissions that occur only once (e.g. CO2 emissions from deforestation) *' are handled differently than emissions that occur in every timestep *' (e.g. CH4 and N2O emissions from agricultural production). @@ -23,5 +24,5 @@ *' @authors Benjamin Bodirsky, Florian Humpenoeder *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%ghg_policy%" == "price_jan19" $include "./modules/56_ghg_policy/price_jan19/realization.gms" +$Ifi "%ghg_policy%" == "price_aug22" $include "./modules/56_ghg_policy/price_aug22/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/56_ghg_policy/price_aug22/declarations.gms b/modules/56_ghg_policy/price_aug22/declarations.gms new file mode 100644 index 0000000000..104e30e236 --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/declarations.gms @@ -0,0 +1,64 @@ +*** | (C) 2008-2025 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 + im_pollutant_prices(t_all,i,pollutants,emis_source) Certificate prices for N2O-N CH4 CO2-C used in the model (USD17MER per Mg) + p56_pollutant_prices_input(t_all,i,pollutants,emis_source) Certificate prices for N2O-N CH4 CO2-C from input files (USD17MER per Mg) + p56_c_price_aff(t_all,i,ac) C price used for afforestation decision-making (USD17MER per tC) + pc56_c_price_induced_aff Helper for fixing C price driven afforestation to zero for historic time steps (binary) + p56_region_price_shr(t_all,i) GHG price share of the region (1) + p56_country_switch(iso) Switch indicating whether country is affected by selected GHG policy (1) + p56_region_fader_shr(t_all,i) GHG policy fader share of the region (1) + p56_country_switch2(iso) Switch indicating whether country is affected by selected GHG policy fader (1) + p56_fader(t_all) GHG policy fader (1) + p56_fader_reg(t_all,i) Regional GHG policy fader (1) + pcm_carbon_stock(j,land,c_pools,stockType) Carbon stock in vegetation soil and litter for different land types (mio. tC) + p56_fader_cpriceaff(t_all) Fader for C price induced afforestation (1) +; + +equations + q56_emission_costs(i) Calculation of total emission costs (mio. USD17MER per yr) + q56_emission_cost_annual(i,emis_annual) Calculation of regional costs for annual emissions (mio. USD17MER per yr) + q56_emission_cost_oneoff(i,emis_oneoff) Calculation of regional costs for emissions occuring only once in time (mio. USD17MER per yr) + q56_reward_cdr_aff_reg(i) Regional revenues for carbon captured by afforestation (mio. USD17MER per yr) + q56_reward_cdr_aff(j) Cellular revenues for carbon captured by afforestation (mio. USD17MER per yr) + q56_emis_pricing(i,pollutants,emis_source) Calculation of annual CO2 emissions for pricing (Tg per yr) + q56_emis_pricing_co2(i,emis_oneoff) Calculation of annual CO2 emissions for pricing (Tg per yr) +; + +positive variables + vm_carbon_stock(j,land,c_pools,stockType) Carbon stock in vegetation soil and litter for different land types (mio. tC) +; + + +variables + vm_emission_costs(i) Costs for emission rights for pollutants and greenhouse gases (mio. USD17MER per yr) + vm_emissions_reg(i,emis_source,pollutants) Regional emissions by source and gas after technical mitigation N CH4 C (Tg per yr) + v56_emis_pricing(i,emis_source,pollutants) Regional emissions by source and gas after technical mitigation N CH4 C (Tg per yr) + v56_emission_cost(i,emis_source) GHG emissions cost (mio. USD17MER per yr) + vm_reward_cdr_aff(i) Regional average annual expected revenue from afforestation (mio. USD17MER per yr) + v56_reward_cdr_aff(j) Cellular average annual expected revenue from afforestation (mio. USD17MER per yr) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_carbon_stock(t,j,land,c_pools,stockType,type) Carbon stock in vegetation soil and litter for different land types (mio. tC) + ov_emission_costs(t,i,type) Costs for emission rights for pollutants and greenhouse gases (mio. USD17MER per yr) + ov_emissions_reg(t,i,emis_source,pollutants,type) Regional emissions by source and gas after technical mitigation N CH4 C (Tg per yr) + ov56_emis_pricing(t,i,emis_source,pollutants,type) Regional emissions by source and gas after technical mitigation N CH4 C (Tg per yr) + ov56_emission_cost(t,i,emis_source,type) GHG emissions cost (mio. USD17MER per yr) + ov_reward_cdr_aff(t,i,type) Regional average annual expected revenue from afforestation (mio. USD17MER per yr) + ov56_reward_cdr_aff(t,j,type) Cellular average annual expected revenue from afforestation (mio. USD17MER per yr) + oq56_emission_costs(t,i,type) Calculation of total emission costs (mio. USD17MER per yr) + oq56_emission_cost_annual(t,i,emis_annual,type) Calculation of regional costs for annual emissions (mio. USD17MER per yr) + oq56_emission_cost_oneoff(t,i,emis_oneoff,type) Calculation of regional costs for emissions occuring only once in time (mio. USD17MER per yr) + oq56_reward_cdr_aff_reg(t,i,type) Regional revenues for carbon captured by afforestation (mio. USD17MER per yr) + oq56_reward_cdr_aff(t,j,type) Cellular revenues for carbon captured by afforestation (mio. USD17MER per yr) + oq56_emis_pricing(t,i,pollutants,emis_source,type) Calculation of annual CO2 emissions for pricing (Tg per yr) + oq56_emis_pricing_co2(t,i,emis_oneoff,type) Calculation of annual CO2 emissions for pricing (Tg per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/56_ghg_policy/price_aug22/equations.gms b/modules/56_ghg_policy/price_aug22/equations.gms new file mode 100644 index 0000000000..ad4cf189ac --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/equations.gms @@ -0,0 +1,79 @@ +*** | (C) 2008-2025 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 + + +*' GHG emissions for pricing can differ for CO2 emissions from land-use change depending on `c56_carbon_stock_pricing`. +*' CO2 emission subject to emission pricing are calculated based on changes in carbon stocks between timesteps in the interface `vm_carbon_stock`, depending on `c56_carbon_stock_pricing`. + + q56_emis_pricing(i2,pollutants,emis_annual) .. + v56_emis_pricing(i2,emis_annual,pollutants) =e= + vm_emissions_reg(i2,emis_annual,pollutants); + + q56_emis_pricing_co2(i2,emis_oneoff) .. + v56_emis_pricing(i2,emis_oneoff,"co2_c") =e= + sum((cell(i2,j2),emis_land(emis_oneoff,land,c_pools)), + (pcm_carbon_stock(j2,land,c_pools,"actual") - vm_carbon_stock(j2,land,c_pools,"%c56_carbon_stock_pricing%"))/m_timestep_length); + +*** Emission costs + +*' **Emission costs** are calculated by multiplying regional emissions with the emission price `im_pollutant_prices`, +*' taking into account the price policy that was defined above in `c56_emis_policy`. + + q56_emission_cost_annual(i2,emis_annual) .. + v56_emission_cost(i2,emis_annual) =e= + sum(pollutants, + v56_emis_pricing(i2,emis_annual,pollutants) * + sum(ct, im_pollutant_prices(ct,i2,pollutants,emis_annual))); + +*' As MAgPIE is a recursive dynamic model, within the optimization of the current time step it does not account for benefits or costs in future time steps. +*' This can be problematic for the treatment of emissions that occur only once under continuous management (such as deforestation, +*' where the forest has been cut down the cropland can be continuously cultivated without further deforestation emissions) versus +*' emissions that occur continously (such as fertilization emissions, that will re-occur every year for continuously management). +*' We therefore distinguish one-off and yearly emissions, and discount one-off emissions assuming an infinite time-horizon to +*' level them with yearly emissions. Since one-off emissions in `vm_emissions_reg` and `v56_emis_cell_pricing` are expressed as annual emissions +*' they are converted back into emissions of the entire timestep by multiplication with `m_timestep_length`, and are then +*' transformed into annual costs by multiplication with the emission price (`im_pollutant_prices`) +*' and an annuity (annuity due with infinite time horizon) factor that depends on `pm_interest`. + + q56_emission_cost_oneoff(i2,emis_oneoff) .. + v56_emission_cost(i2,emis_oneoff) =e= + sum(pollutants, + v56_emis_pricing(i2,emis_oneoff,pollutants) + * m_timestep_length + * sum(ct, + im_pollutant_prices(ct,i2,pollutants,emis_oneoff) + * pm_interest(ct,i2)/(1+pm_interest(ct,i2)))); + +*' **Total regional emission costs** consist of costs from yearly and one-off emissions. + + q56_emission_costs(i2) .. + vm_emission_costs(i2) =e= + sum(emis_source, v56_emission_cost(i2,emis_source)); + +*' The value of CDR from C-price induced afforestation enters the objective function as negative costs. +*' The reward, which serves as incentive for afforestation, is calculated in 3 steps: +*' First, the sum of the expected CDR for each 5-year age-class and the carbon equivalent of local biophysical effects (`vm_cdr_aff`) +*' are multiplied by the corresponding future C price (`p56_c_price_aff`). +*' Second, these future cash flows are discounted to present value, depending on `pm_interest`. +*' Third, an annuity factor (annuity due with infinite time horizon) is used to obtain average annual rewards + + q56_reward_cdr_aff_reg(i2) .. + vm_reward_cdr_aff(i2) =e= + sum(cell(i2,j2), + v56_reward_cdr_aff(j2) + ); + + q56_reward_cdr_aff(j2) .. + v56_reward_cdr_aff(j2) =e= + sum(ct, p56_fader_cpriceaff(ct)) * + sum(ac, + (sum(aff_effect,(1-s56_buffer_aff)*vm_cdr_aff(j2,ac,aff_effect)) * sum((cell(i2,j2),ct), p56_c_price_aff(ct,i2,ac))) + / ((1+sum((cell(i2,j2),ct),pm_interest(ct,i2)))**(ac.off*5))) + *sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); diff --git a/modules/56_ghg_policy/price_aug22/input.gms b/modules/56_ghg_policy/price_aug22/input.gms new file mode 100644 index 0000000000..7c64696d06 --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/input.gms @@ -0,0 +1,117 @@ +*** | (C) 2008-2025 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 + +* Set-switch for countries affected by regional ghg policy +* Default: all iso countries selected +sets + policy_countries56(iso) countries to be affected by ghg policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + + fader_countries56(iso) countries to be affected by ghg policy fader + / ABW,AFG,AGO,AIA,ALA,AND,ARE,ARG,ARM,ASM,ATA, + ATF,ATG,AZE,BDI,BEN,BES,BFA,BGD,BHR,BHS,BLM, + BLR,BLZ,BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF, + CCK,CHN,CHL,CIV,CMR,COD,COG,COK,COL,COM,CPV, + CRI,CUB,CUW,CXR,CYM,DJI,DMA,DOM,DZA,ECU,EGY, + ERI,ESH,ETH,FJI,FLK,FRO,FSM,GAB,GEO,GGY,GHA, + GIB,GIN,GLP,GMB,GNB,GNQ,GRD,GRL,GTM,GUF,GUM, + GUY,HKG,HMD,HND,HTI,IDN,IMN,IND,IOT,IRN,IRQ, + ISR,JAM,JEY,JOR,KAZ,KEN,KGZ,KHM,KIR,KNA,KOR, + KWT,LAO,LBN,LBR,LBY,LCA,LIE,LKA,LSO,MAC,MAF, + MAR,MCO,MDA,MDG,MDV,MEX,MHL,MLI,MMR,MNG,MNP, + MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM,NCL,NER, + NFK,NGA,NIC,NIU,NPL,NRU,OMN,PAK,PAN,PCN,PER, + PHL,PLW,PNG,PRI,PRK,PRY,PSE,PYF,QAT,REU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE,SLV, + SMR,SOM,SPM,SSD,STP,SUR,SWZ,SXM,SYC,SYR,TCA, + TCD,TGO,THA,TJK,TKL,TKM,TLS,TON,TTO,TUN,TUV, + TWN,TZA,UGA,UKR,UMI,URY,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + +pollutants_fader(pollutants) pollutants affected by GHG policy fader + / co2_c, ch4, n2o_n_direct, n2o_n_indirect, nh3_n, no2_n, no3_n / + +; + +scalars + s56_limit_ch4_n2o_price Upper limit for CH4 and N2O GHG prices (USD17MER per tC) / 4920 / + s56_cprice_red_factor Reduction factor for CO2 price (-) / 1 / + s56_minimum_cprice Minium C price (USD17MER per tC) / 3.67 / + s56_ghgprice_devstate_scaling Switch for scaling GHG price with development state (1=on 0=off) / 0 / + s56_c_price_induced_aff Switch for C price driven re-afforestation (1=on 0=off) / 1 / + s56_c_price_exp_aff Time horizon of CO2 price expectation for re-afforestation (years) / 50 / + s56_buffer_aff Share of carbon credits for re-afforestation projects pooled in a buffer (1) / 0.5 / + s56_counter Counter for C price interpolation (1) / 0 / + s56_timesteps Number of time steps for C price interpolation (1) / 0 / + s56_offset Helper for C price interpolation (1) / 0 / + s56_ghgprice_fader Switch for GHG policy fader (1=on 0=off) / 0 / + s56_fader_start Start year of GHG policy fade-in (1) / 2035 / + s56_fader_end End year of GHG policy fade-in (1) / 2050 / + s56_fader_target Target value of GHG policy fade-in in end year / 1 / + s56_fader_functional_form Switch for functional form of GHG policy fader (1=linear 2=sigmoid) / 1 / + s56_fader_cpriceaff_start Start year of C price induced afforestation fade-in (1) / 2030 / + s56_fader_cpriceaff_end End year of C price induced afforestation fade-in (1) / 2030 / +; + +$setglobal c56_pollutant_prices R34M410-SSP2-NPi2025 +$setglobal c56_pollutant_prices_noselect R34M410-SSP2-NPi2025 +$setglobal c56_emis_policy reddnatveg_nosoil +$setglobal c56_cprice_aff secdforest_vegc +$setglobal c56_mute_ghgprices_until y2030 + +$setglobal c56_carbon_stock_pricing actualNoAcEst +* options: actual, actualNoAcEst + +table f56_pollutant_prices(t_all,i,pollutants,ghgscen56) GHG certificate prices for N2O-N CH4 CO2-C (USD17MER per t) +$ondelim +$include "./modules/56_ghg_policy/input/f56_pollutant_prices.cs3" +$offdelim +; + +$if "%c56_pollutant_prices%" == "coupling" table f56_pollutant_prices_coupling(t_all,i,pollutants) Regional ghg certificate prices for N2O-N CH4 CO2-C (USD17MER per t) +$if "%c56_pollutant_prices%" == "coupling" $ondelim +$if "%c56_pollutant_prices%" == "coupling" $include "./modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3" +$if "%c56_pollutant_prices%" == "coupling" $offdelim +$if "%c56_pollutant_prices%" == "coupling" ; + +$if "%c56_pollutant_prices%" == "emulator" table f56_pollutant_prices_emulator(t_all,i,pollutants) Global ghg certificate prices for N2O-N CH4 CO2-C (USD17MER per t) +$if "%c56_pollutant_prices%" == "emulator" $ondelim +$if "%c56_pollutant_prices%" == "emulator" $include "./modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3" +$if "%c56_pollutant_prices%" == "emulator" $offdelim +$if "%c56_pollutant_prices%" == "emulator" ; + +* f56_emis_policy contains scenarios determining for each gas and source whether it is priced or not + +table f56_emis_policy(scen56,pollutants_all,emis_source) GHG emission policy scenarios (1) +$ondelim +$include "./modules/56_ghg_policy/input/f56_emis_policy.csv" +$offdelim +; diff --git a/modules/56_ghg_policy/price_aug22/postsolve.gms b/modules/56_ghg_policy/price_aug22/postsolve.gms new file mode 100644 index 0000000000..e985488dd8 --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/postsolve.gms @@ -0,0 +1,67 @@ +*** | (C) 2008-2025 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 + +pcm_carbon_stock(j,land,ag_pools,stockType) = vm_carbon_stock.l(j,land,ag_pools,stockType); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_carbon_stock(t,j,land,c_pools,stockType,"marginal") = vm_carbon_stock.m(j,land,c_pools,stockType); + ov_emission_costs(t,i,"marginal") = vm_emission_costs.m(i); + ov_emissions_reg(t,i,emis_source,pollutants,"marginal") = vm_emissions_reg.m(i,emis_source,pollutants); + ov56_emis_pricing(t,i,emis_source,pollutants,"marginal") = v56_emis_pricing.m(i,emis_source,pollutants); + ov56_emission_cost(t,i,emis_source,"marginal") = v56_emission_cost.m(i,emis_source); + ov_reward_cdr_aff(t,i,"marginal") = vm_reward_cdr_aff.m(i); + ov56_reward_cdr_aff(t,j,"marginal") = v56_reward_cdr_aff.m(j); + oq56_emission_costs(t,i,"marginal") = q56_emission_costs.m(i); + oq56_emission_cost_annual(t,i,emis_annual,"marginal") = q56_emission_cost_annual.m(i,emis_annual); + oq56_emission_cost_oneoff(t,i,emis_oneoff,"marginal") = q56_emission_cost_oneoff.m(i,emis_oneoff); + oq56_reward_cdr_aff_reg(t,i,"marginal") = q56_reward_cdr_aff_reg.m(i); + oq56_reward_cdr_aff(t,j,"marginal") = q56_reward_cdr_aff.m(j); + oq56_emis_pricing(t,i,pollutants,emis_source,"marginal") = q56_emis_pricing.m(i,pollutants,emis_source); + oq56_emis_pricing_co2(t,i,emis_oneoff,"marginal") = q56_emis_pricing_co2.m(i,emis_oneoff); + ov_carbon_stock(t,j,land,c_pools,stockType,"level") = vm_carbon_stock.l(j,land,c_pools,stockType); + ov_emission_costs(t,i,"level") = vm_emission_costs.l(i); + ov_emissions_reg(t,i,emis_source,pollutants,"level") = vm_emissions_reg.l(i,emis_source,pollutants); + ov56_emis_pricing(t,i,emis_source,pollutants,"level") = v56_emis_pricing.l(i,emis_source,pollutants); + ov56_emission_cost(t,i,emis_source,"level") = v56_emission_cost.l(i,emis_source); + ov_reward_cdr_aff(t,i,"level") = vm_reward_cdr_aff.l(i); + ov56_reward_cdr_aff(t,j,"level") = v56_reward_cdr_aff.l(j); + oq56_emission_costs(t,i,"level") = q56_emission_costs.l(i); + oq56_emission_cost_annual(t,i,emis_annual,"level") = q56_emission_cost_annual.l(i,emis_annual); + oq56_emission_cost_oneoff(t,i,emis_oneoff,"level") = q56_emission_cost_oneoff.l(i,emis_oneoff); + oq56_reward_cdr_aff_reg(t,i,"level") = q56_reward_cdr_aff_reg.l(i); + oq56_reward_cdr_aff(t,j,"level") = q56_reward_cdr_aff.l(j); + oq56_emis_pricing(t,i,pollutants,emis_source,"level") = q56_emis_pricing.l(i,pollutants,emis_source); + oq56_emis_pricing_co2(t,i,emis_oneoff,"level") = q56_emis_pricing_co2.l(i,emis_oneoff); + ov_carbon_stock(t,j,land,c_pools,stockType,"upper") = vm_carbon_stock.up(j,land,c_pools,stockType); + ov_emission_costs(t,i,"upper") = vm_emission_costs.up(i); + ov_emissions_reg(t,i,emis_source,pollutants,"upper") = vm_emissions_reg.up(i,emis_source,pollutants); + ov56_emis_pricing(t,i,emis_source,pollutants,"upper") = v56_emis_pricing.up(i,emis_source,pollutants); + ov56_emission_cost(t,i,emis_source,"upper") = v56_emission_cost.up(i,emis_source); + ov_reward_cdr_aff(t,i,"upper") = vm_reward_cdr_aff.up(i); + ov56_reward_cdr_aff(t,j,"upper") = v56_reward_cdr_aff.up(j); + oq56_emission_costs(t,i,"upper") = q56_emission_costs.up(i); + oq56_emission_cost_annual(t,i,emis_annual,"upper") = q56_emission_cost_annual.up(i,emis_annual); + oq56_emission_cost_oneoff(t,i,emis_oneoff,"upper") = q56_emission_cost_oneoff.up(i,emis_oneoff); + oq56_reward_cdr_aff_reg(t,i,"upper") = q56_reward_cdr_aff_reg.up(i); + oq56_reward_cdr_aff(t,j,"upper") = q56_reward_cdr_aff.up(j); + oq56_emis_pricing(t,i,pollutants,emis_source,"upper") = q56_emis_pricing.up(i,pollutants,emis_source); + oq56_emis_pricing_co2(t,i,emis_oneoff,"upper") = q56_emis_pricing_co2.up(i,emis_oneoff); + ov_carbon_stock(t,j,land,c_pools,stockType,"lower") = vm_carbon_stock.lo(j,land,c_pools,stockType); + ov_emission_costs(t,i,"lower") = vm_emission_costs.lo(i); + ov_emissions_reg(t,i,emis_source,pollutants,"lower") = vm_emissions_reg.lo(i,emis_source,pollutants); + ov56_emis_pricing(t,i,emis_source,pollutants,"lower") = v56_emis_pricing.lo(i,emis_source,pollutants); + ov56_emission_cost(t,i,emis_source,"lower") = v56_emission_cost.lo(i,emis_source); + ov_reward_cdr_aff(t,i,"lower") = vm_reward_cdr_aff.lo(i); + ov56_reward_cdr_aff(t,j,"lower") = v56_reward_cdr_aff.lo(j); + oq56_emission_costs(t,i,"lower") = q56_emission_costs.lo(i); + oq56_emission_cost_annual(t,i,emis_annual,"lower") = q56_emission_cost_annual.lo(i,emis_annual); + oq56_emission_cost_oneoff(t,i,emis_oneoff,"lower") = q56_emission_cost_oneoff.lo(i,emis_oneoff); + oq56_reward_cdr_aff_reg(t,i,"lower") = q56_reward_cdr_aff_reg.lo(i); + oq56_reward_cdr_aff(t,j,"lower") = q56_reward_cdr_aff.lo(j); + oq56_emis_pricing(t,i,pollutants,emis_source,"lower") = q56_emis_pricing.lo(i,pollutants,emis_source); + oq56_emis_pricing_co2(t,i,emis_oneoff,"lower") = q56_emis_pricing_co2.lo(i,emis_oneoff); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/56_ghg_policy/price_aug22/preloop.gms b/modules/56_ghg_policy/price_aug22/preloop.gms new file mode 100644 index 0000000000..5dc2b1e300 --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/preloop.gms @@ -0,0 +1,123 @@ +*** | (C) 2008-2025 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 + +* starting value of above ground carbon stocks 1995 is only an estimate. +* ATTENTION: emissions in 1995 are not meaningful +pcm_carbon_stock(j,land,ag_pools,stockType) = fm_carbon_density("y1995",j,land,ag_pools)*pcm_land(j,land); +vm_carbon_stock.l(j,land,ag_pools,stockType) = pcm_carbon_stock(j,land,ag_pools,stockType); + +v56_emis_pricing.fx(i,emis_oneoff,pollutants)$(not sameas(pollutants,"co2_c")) = 0; + +****** Region price share for ghg policy of selective countries: +* Country switch to determine countries for which ghg policy shall be applied. +* In the default case, the ghg policy affects all countries when activated. +p56_country_switch(iso) = 0; +p56_country_switch(policy_countries56) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p56_region_price_shr(t_all,i) = sum(i_to_iso(i,iso), p56_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + +****** Regional fader share for ghg policy fader of selective countries: +* Country switch to determine countries for which ghg policy fader shall be applied. +* In the default case, the ghg policy fader affects all countries when activated. +p56_country_switch2(iso) = 0; +p56_country_switch2(fader_countries56) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p56_region_fader_shr(t_all,i) = sum(i_to_iso(i,iso), p56_country_switch2(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + +****select ghg prices +$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)); +$endif + +***save im_pollutant_prices to parameter +p56_pollutant_prices_input(t_all,i,pollutants,emis_source) = im_pollutant_prices(t_all,i,pollutants,emis_source); + +***multiply GHG prices with development state to account for institutional requirements needed for implementing a GHG pricing scheme +im_pollutant_prices(t_all,i,pollutants,emis_source)$(s56_ghgprice_devstate_scaling = 1) = im_pollutant_prices(t_all,i,pollutants,emis_source)*im_development_state(t_all,i); + +***build and apply temporal fader for GHG policy +if (s56_fader_functional_form = 1, + m_linear_time_interpol(p56_fader,s56_fader_start,s56_fader_end,0,s56_fader_target); +elseif s56_fader_functional_form = 2, + m_sigmoid_time_interpol(p56_fader,s56_fader_start,s56_fader_end,0,s56_fader_target); +); + +m_linear_time_interpol(p56_fader_cpriceaff,s56_fader_cpriceaff_start,s56_fader_cpriceaff_end,0,s56_c_price_induced_aff); + +p56_fader_reg(t_all,i) = p56_fader(t_all) * p56_region_fader_shr(t_all,i) + p56_fader(t_all) * (1-p56_region_fader_shr(t_all,i)); +im_pollutant_prices(t_all,i,pollutants_fader,emis_source)$(s56_ghgprice_fader = 1) = im_pollutant_prices(t_all,i,pollutants_fader,emis_source) * p56_fader_reg(t_all,i); + +***apply reduction factor on CO2 price to account for potential negative side effects +***lowers the economic incentive for CO2 emission reduction (avoided deforestation) and afforestation +im_pollutant_prices(t_all,i,"co2_c",emis_source) = im_pollutant_prices(t_all,i,"co2_c",emis_source)*s56_cprice_red_factor; + +** set GHG prices to zero for historic period +im_pollutant_prices(t_all,i,pollutants,emis_source)$(m_year(t_all) <= sm_fix_SSP2) = 0; +** set GHG prices to zero for all future time steps until the year defined by `c56_mute_ghgprices_until` or `s56_fader_start` +im_pollutant_prices(t_all,i,pollutants,emis_source)$(m_year(t_all) > sm_fix_SSP2 AND m_year(t_all) <= max(m_year("%c56_mute_ghgprices_until%"),s56_fader_start*s56_ghgprice_fader)) = 0; +** Exception for C price, which can be set to a minium price for all time steps +im_pollutant_prices(t_all,i,"co2_c",emis_source)$(im_pollutant_prices(t_all,i,"co2_c",emis_source) < s56_minimum_cprice) = s56_minimum_cprice; + +***limit CH4 and N2O GHG prices based on s56_limit_ch4_n2o_price +*12/44 conversion from USD17MER per tC to USD17MER per tCO2 +*28 and 265 Global Warming Potentials from AR5 WG1 CH08 Table 8.7, conversion from USD17MER per tCO2 to USD17MER per tCH4 and USD17MER per tN2O +*44/28 conversion from USD17MER per tN2O to USD17MER per tN +im_pollutant_prices(t_all,i,"ch4",emis_source)$(im_pollutant_prices(t_all,i,"ch4",emis_source) > s56_limit_ch4_n2o_price*12/44*28) = s56_limit_ch4_n2o_price*12/44*28; +im_pollutant_prices(t_all,i,"n2o_n_direct",emis_source)$(im_pollutant_prices(t_all,i,"n2o_n_direct",emis_source) > s56_limit_ch4_n2o_price*12/44*265*44/28) = s56_limit_ch4_n2o_price*12/44*265*44/28; +im_pollutant_prices(t_all,i,"n2o_n_indirect",emis_source)$(im_pollutant_prices(t_all,i,"n2o_n_indirect",emis_source) > s56_limit_ch4_n2o_price*12/44*265*44/28) = s56_limit_ch4_n2o_price*12/44*265*44/28; + +***GHG emission policy +loop(t_all, + if(m_year(t_all) <= sm_fix_SSP2, + im_pollutant_prices(t_all,i,pollutants,emis_source) = im_pollutant_prices(t_all,i,pollutants,emis_source) * f56_emis_policy("reddnatveg_nosoil",pollutants,emis_source); + else + im_pollutant_prices(t_all,i,pollutants,emis_source) = im_pollutant_prices(t_all,i,pollutants,emis_source) * f56_emis_policy("%c56_emis_policy%",pollutants,emis_source); + ); +); + +***construct age-class dependent C price for afforestation incentive +***this is needed because time steps (t) and age-classes (ac) can differ. ac and t_all are always in 5-year time steps. +*For missing years in t_all use C price of previous time step. This step makes sure that C prices for every 5-year time step are available. +loop(t_all$(m_year(t_all) > max(m_year("%c56_mute_ghgprices_until%"),s56_fader_start*s56_ghgprice_fader)), + im_pollutant_prices(t_all,i,"co2_c",emis_source)$(im_pollutant_prices(t_all,i,"co2_c",emis_source) = 0) = im_pollutant_prices(t_all-1,i,"co2_c",emis_source); +); +*Linear interpolation of C price for missing time steps +loop(t, + s56_timesteps = m_yeardiff(t)/5; + if (s56_timesteps > 1, + s56_counter = 0; + repeat( + s56_counter = s56_counter + 1; + s56_offset = s56_timesteps-s56_counter; + im_pollutant_prices(t_all-s56_offset,i,"co2_c",emis_source)$(m_year(t_all) = m_year(t)) = + im_pollutant_prices(t-1,i,"co2_c",emis_source) + + (im_pollutant_prices(t,i,"co2_c",emis_source) - im_pollutant_prices(t-1,i,"co2_c",emis_source))*s56_counter/(s56_timesteps); + until s56_counter = s56_timesteps-1); + ); +); + +*initialize age-class dependent C price with same C price for all age-classes +p56_c_price_aff(t_all,i,ac) = im_pollutant_prices(t_all,i,"co2_c","%c56_cprice_aff%"); +*Shift C prices in age-classes for reflecting foresight. +*e.g. ac5 in 2020 should have the C price of ac0 in 2025, and ac20 in 2020 equals to ac0 in 2040 +p56_c_price_aff(t_all,i,ac)$(ord(t_all)+ac.off= s56_c_price_exp_aff/5) = sum(ac_exp, p56_c_price_aff(t_all,i,ac_exp)); +*zero C price before starting year +p56_c_price_aff(t_all,i,ac)$(m_year(t_all) <= max(m_year("%c56_mute_ghgprices_until%"),s56_fader_start*s56_ghgprice_fader)) = 0; diff --git a/modules/56_ghg_policy/price_aug22/realization.gms b/modules/56_ghg_policy/price_aug22/realization.gms new file mode 100644 index 0000000000..69af93d2bb --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/realization.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2025 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 This realization applies pollutant prices to different +*' emission types in Agriculture, Forestry and Other Land Use (AFOLU), +*' depending on the GHG emission pricing policy defined in `c56_emis_policy`. +*' CO2 emissions from Land Use, Land-Use Change and Forestry (LULUCF) are calculated +*' based on carbon stock changes between timesteps in the interface `vm_carbon_stock`. +*' Note that the CO2 emissions subject to pricing can differ from the actual CO2 emissions, +*' depending on the choice of `c56_carbon_stock_pricing`. +*' In addition, the average annual reward for carbon dioxide removal (CDR) +*' and the reward or penalty of local biophysical effects +*' from afforestation [32_forestry] is calculated as the present value (PV) of all +*' future cash flows multiplied with an annuity factor. The PV is obtained by +*' multiplication of `vm_cdr_aff` with the corresponding carbon price and subsequent +*' discouting based on the given discount rate `pm_interest`. +*' Technically, the reward for CDR and bph effects from afforestation is a negative cash flow +*' lowering the costs in the objective function of the model. +*' If pollutant prices are zero, which is the default for reference scenarios without +*' mitigation, total emission costs entering the objective function are zero. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/56_ghg_policy/price_aug22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/56_ghg_policy/price_aug22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/56_ghg_policy/price_aug22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/56_ghg_policy/price_aug22/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/56_ghg_policy/price_aug22/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/56_ghg_policy/price_aug22/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/56_ghg_policy/price_aug22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/56_ghg_policy/price_aug22/scaling.gms b/modules/56_ghg_policy/price_aug22/scaling.gms new file mode 100644 index 0000000000..7031ea70e3 --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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_emission_costs.scale(i) = 10e5; +v56_emission_cost.scale(i,emis_source) = 10e4; +vm_carbon_stock.scale(j,land,c_pools,stockType) = 10e3; diff --git a/modules/56_ghg_policy/price_aug22/sets.gms b/modules/56_ghg_policy/price_aug22/sets.gms new file mode 100644 index 0000000000..3cf489603a --- /dev/null +++ b/modules/56_ghg_policy/price_aug22/sets.gms @@ -0,0 +1,214 @@ +*** | (C) 2008-2025 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 + +*############################################################################### +*######################## R SECTION START (SETS) ############################### +* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY +* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! + +sets + + ghgscen56 ghg price scenarios + / PIK_GDP, + PIK_H2C, + PIK_HBL, + PIK_HOS, + PIK_LIN, + PIK_NPI, + PIK_OPT, + R21M42-SDP-NDC, + R21M42-SDP-NPi, + R21M42-SDP-PkBudg1000, + R21M42-SDP-PkBudg1100, + R21M42-SDP-PkBudg900, + R21M42-SSP1-NDC, + R21M42-SSP1-NPi, + R21M42-SSP1-PkBudg1100, + R21M42-SSP1-PkBudg1300, + R21M42-SSP1-PkBudg900, + R21M42-SSP2-NDC, + R21M42-SSP2-NPi, + R21M42-SSP2-PkBudg1100, + R21M42-SSP2-PkBudg1300, + R21M42-SSP2-PkBudg900, + R21M42-SSP5-NDC, + R21M42-SSP5-NPi, + R21M42-SSP5-PkBudg1100, + R21M42-SSP5-PkBudg1300, + R21M42-SSP5-PkBudg900, + R2M41-SSP2-Budg1300, + R2M41-SSP2-Budg600, + 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, + R34BC-SSP2-PkBudg650-BCdef, + R34BC-SSP2-PkBudg650-BCdef-CTS01, + R34BC-SSP2-PkBudg650-BCdef-CTS01-BM70, + R34BC-SSP2-PkBudg650-BCpess-CTS01-BM70, + R34M410-SSP1-NPi2025, + R34M410-SSP1-PkBudg1000, + R34M410-SSP1-PkBudg650, + R34M410-SSP2_lowEn-NPi2025, + R34M410-SSP2_lowEn-PkBudg1000, + R34M410-SSP2_lowEn-PkBudg650, + R34M410-SSP2-NPi2025, + R34M410-SSP2-PkBudg1000, + R34M410-SSP2-PkBudg650, + R34M410-SSP3-NPi2025, + R34M410-SSP3-PkBudg1000, + R34M410-SSP3-rollBack, + R34M410-SSP5-NPi2025, + R34M410-SSP5-PkBudg1000, + R34M410-SSP5-PkBudg650, + SSPDB-SSP1-19-IMAGE, + SSPDB-SSP1-19-REMIND-MAGPIE, + SSPDB-SSP1-26-IMAGE, + SSPDB-SSP1-26-REMIND-MAGPIE, + SSPDB-SSP1-34-IMAGE, + SSPDB-SSP1-34-REMIND-MAGPIE, + SSPDB-SSP1-45-IMAGE, + SSPDB-SSP1-45-REMIND-MAGPIE, + SSPDB-SSP1-Ref-IMAGE, + SSPDB-SSP1-Ref-REMIND-MAGPIE, + SSPDB-SSP2-19-MESSAGE-GLOBIOM, + SSPDB-SSP2-19-REMIND-MAGPIE, + SSPDB-SSP2-26-MESSAGE-GLOBIOM, + SSPDB-SSP2-26-REMIND-MAGPIE, + SSPDB-SSP2-34-MESSAGE-GLOBIOM, + SSPDB-SSP2-34-REMIND-MAGPIE, + SSPDB-SSP2-45-MESSAGE-GLOBIOM, + SSPDB-SSP2-45-REMIND-MAGPIE, + SSPDB-SSP2-60-MESSAGE-GLOBIOM, + SSPDB-SSP2-60-REMIND-MAGPIE, + SSPDB-SSP2-Ref-MESSAGE-GLOBIOM, + SSPDB-SSP2-Ref-REMIND-MAGPIE, + SSPDB-SSP3-34-AIM-CGE, + SSPDB-SSP3-45-AIM-CGE, + SSPDB-SSP3-60-AIM-CGE, + SSPDB-SSP4-26-GCAM4, + SSPDB-SSP4-34-GCAM4, + SSPDB-SSP4-45-GCAM4, + SSPDB-SSP4-60-GCAM4, + SSPDB-SSP4-Ref-GCAM4, + SSPDB-SSP5-19-REMIND-MAGPIE, + SSPDB-SSP5-26-REMIND-MAGPIE, + SSPDB-SSP5-34-REMIND-MAGPIE, + SSPDB-SSP5-45-REMIND-MAGPIE, + SSPDB-SSP5-60-REMIND-MAGPIE, + SSPDB-SSP5-Ref-REMIND-MAGPIE / + + scen56 emission policy scenarios + / none, + all, + all_nosoil, + redd_nosoil, + redd_nosoil_CH4GWP20, + redd_nosoil_nopeat, + redd_nosoil_peatCO2only, + reddnatveg_nosoil, + reddnatveg_nosoil_CH4GWP20, + reddnatveg_nosoil_nopeat, + reddnatveg_nosoil_peatCO2only, + redd+_nosoil, + redd+_nosoil_CH4GWP20, + redd+_nosoil_nopeat, + redd+_nosoil_peatCO2only, + redd+natveg_nosoil, + redd+natveg_nosoil_CH4GWP20, + redd+natveg_nosoil_nopeat, + redd+natveg_nosoil_peatCO2only, + all_vegc, + redd_vegc, + reddnatveg_vegc, + redd+_vegc, + redd+natveg_vegc, + sdp_cropeff, + sdp_livestock, + sdp_redd, + sdp_soil, + sdp_peatland, + sdp_redd_soil, + sdp_redd_soil_peat, + sdp_all, + gcs_lbs, + gcs_res, + ecoSysProtAll, + ecoSysProtForest, + ecoSysProtPrimForest, + ecoSysProtOff, + ecoSysProtAll_agMgmtExclN2O, + ecoSysProtAll_agMgmtExclCH4, + ecoSysProtAll_agMgmtOff, + co2_reddnatveg_nosoil, + co2_peatland, + co2_reddnatveg_nosoil_peatland / + +; +*######################### R SECTION END (SETS) ################################ +*############################################################################### + +sets + + pollutants_all all pollutants + / co2_c, + ch4, + n2o_n_direct, nh3_n, no2_n, + no3_n, + n2o_n_indirect, + co, + nmhc, + h2, + pm2_5, + tpm, + tc, + oc, + bc, + so2 / + + pollutants(pollutants_all) subset of pollutants_all that can be taxed + / co2_c, + ch4, + n2o_n_direct, n2o_n_indirect, + nh3_n, no2_n, + no3_n / + + n_pollutants(pollutants) subset of n pollutants + / n2o_n_direct,n2o_n_indirect, + nh3_n, no2_n, + no3_n / + + n_pollutants_direct(n_pollutants) subset of n pollutants + / n2o_n_direct, + nh3_n, no2_n, + no3_n / + + pollutant_nh3no2_51(n_pollutants_direct) nitrogen emissions relevant for deposition + / nh3_n, no2_n / + + ac_exp(ac) age-class corresponding to planning horizon + + ag_pools(c_pools) Above ground carbon pools + / vegc, litc / + + stockType Carbon stock types + / actual, actualNoAcEst / +; diff --git a/modules/56_ghg_policy/price_jan19/declarations.gms b/modules/56_ghg_policy/price_jan19/declarations.gms deleted file mode 100644 index 26ffaff38e..0000000000 --- a/modules/56_ghg_policy/price_jan19/declarations.gms +++ /dev/null @@ -1,70 +0,0 @@ -*** | (C) 2008-2019 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 - im_pollutant_prices(t,i,pollutants) Certificate prices for N2O-N CH4 CO2-C used in the model (USD05MER per Mg) - p56_pollutant_prices_input(t,i,pollutants) Certificate prices for N2O-N CH4 CO2-C from input files (USD05MER per Mg) - p56_ghg_price_growth_rate(t,i,pollutants) Growth rate of certificate price (% per yr) - p56_ghg_price_growth_rate_avg(i,pollutants) Average over time of growth rate of certificate price (% per yr) - p56_emis_policy(t,i,pollutants,emis_source) GHG emission policy scenarios (binary) -; - -equations - q56_technical_mitigation_reg(i,pollutants,emis_source) Application of maccs on emissions (Tg per yr) - q56_technical_mitigation_cell(j,pollutants,emis_source) Application of maccs on emissions (Tg per yr) - q56_cell_to_reg(i,pollutants,emis_source) Aggregation to regional emissions (Tg per yr) - q56_emission_costs(i) Calculation of total emission costs (mio. USD05MER per yr) - q56_emission_costs_reg_yearly(i,emis_reg_yr56) Calculation of regional costs for annual emissions (mio. USD05MER per yr) - q56_emission_costs_reg_oneoff(i,emis_reg_one56) Calculation of regional costs for emissions occuring only once in time (mio. USD05MER per yr) - q56_emission_costs_cell_yearly(j,emis_cell_yr56) Calculation of cellular costs for annual emissions (mio. USD05MER per yr) - q56_emission_costs_cell_oneoff(j,emis_cell_one56) Calculation of cellular costs for emissions occuring only once in time (mio. USD05MER per yr) - q56_reward_cdr_aff_reg(i) Regional revenues for carbon captured by afforestation (mio. USD05MER per yr) - q56_reward_cdr_aff(j) Cellular revenues for carbon captured by afforestation (mio. USD05MER per yr) -; - -positive variables - v56_reward_cdr_aff(j) Cellular revenues for carbon captured by afforestation (mio. USD05MER per yr) - vm_reward_cdr_aff(i) Regional revenues for carbon captured by afforestation (mio. USD05MER per yr) -; - -variables - vm_btm_reg(i,emis_source,pollutants) Regional emissions before technical mitigation (Tg per yr) - vm_btm_cell(j,emis_source,pollutants) Cellular emissions before technical mitigation (Tg per yr) - vm_emission_costs(i) Costs for emission rights for pollutants and greenhouse gases (mio. USD05MER per yr) - vm_emissions_reg(i,emis_source,pollutants) Regional emissions by source and gas after technical mitigation N CH4 C (Tg per yr) - v56_emis_cell(j,emis_source,pollutants) Cellular emissions by source and gas after technical mitigation N CH4 C (Tg per yr) - v56_emission_costs_reg_yearly(i,emis_reg_yr56) Costs for emissions occuring yearly (mio. USD05MER per yr) - v56_emission_costs_reg_oneoff(i,emis_reg_one56) Costs for emissions occuring only once in time (mio. USD05MER per yr) - v56_emission_costs_cell_yearly(j,emis_cell_yr56) Costs for emissions occuring yearly (mio. USD05MER per yr) - v56_emission_costs_cell_oneoff(j,emis_cell_one56) Costs for emissions occuring only once in time (mio. USD05MER per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov56_reward_cdr_aff(t,j,type) Cellular revenues for carbon captured by afforestation (mio. USD05MER per yr) - ov_reward_cdr_aff(t,i,type) Regional revenues for carbon captured by afforestation (mio. USD05MER per yr) - ov_btm_reg(t,i,emis_source,pollutants,type) Regional emissions before technical mitigation (Tg per yr) - ov_btm_cell(t,j,emis_source,pollutants,type) Cellular emissions before technical mitigation (Tg per yr) - ov_emission_costs(t,i,type) Costs for emission rights for pollutants and greenhouse gases (mio. USD05MER per yr) - ov_emissions_reg(t,i,emis_source,pollutants,type) Regional emissions by source and gas after technical mitigation N CH4 C (Tg per yr) - ov56_emis_cell(t,j,emis_source,pollutants,type) Cellular emissions by source and gas after technical mitigation N CH4 C (Tg per yr) - ov56_emission_costs_reg_yearly(t,i,emis_reg_yr56,type) Costs for emissions occuring yearly (mio. USD05MER per yr) - ov56_emission_costs_reg_oneoff(t,i,emis_reg_one56,type) Costs for emissions occuring only once in time (mio. USD05MER per yr) - ov56_emission_costs_cell_yearly(t,j,emis_cell_yr56,type) Costs for emissions occuring yearly (mio. USD05MER per yr) - ov56_emission_costs_cell_oneoff(t,j,emis_cell_one56,type) Costs for emissions occuring only once in time (mio. USD05MER per yr) - oq56_technical_mitigation_reg(t,i,pollutants,emis_source,type) Application of maccs on emissions (Tg per yr) - oq56_technical_mitigation_cell(t,j,pollutants,emis_source,type) Application of maccs on emissions (Tg per yr) - oq56_cell_to_reg(t,i,pollutants,emis_source,type) Aggregation to regional emissions (Tg per yr) - oq56_emission_costs(t,i,type) Calculation of total emission costs (mio. USD05MER per yr) - oq56_emission_costs_reg_yearly(t,i,emis_reg_yr56,type) Calculation of regional costs for annual emissions (mio. USD05MER per yr) - oq56_emission_costs_reg_oneoff(t,i,emis_reg_one56,type) Calculation of regional costs for emissions occuring only once in time (mio. USD05MER per yr) - oq56_emission_costs_cell_yearly(t,j,emis_cell_yr56,type) Calculation of cellular costs for annual emissions (mio. USD05MER per yr) - oq56_emission_costs_cell_oneoff(t,j,emis_cell_one56,type) Calculation of cellular costs for emissions occuring only once in time (mio. USD05MER per yr) - oq56_reward_cdr_aff_reg(t,i,type) Regional revenues for carbon captured by afforestation (mio. USD05MER per yr) - oq56_reward_cdr_aff(t,j,type) Cellular revenues for carbon captured by afforestation (mio. USD05MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/56_ghg_policy/price_jan19/equations.gms b/modules/56_ghg_policy/price_jan19/equations.gms deleted file mode 100644 index c2d26e08e0..0000000000 --- a/modules/56_ghg_policy/price_jan19/equations.gms +++ /dev/null @@ -1,113 +0,0 @@ -*** | (C) 2008-2019 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 - -*** Calculate emissions for the core - -*** Emissions - -*' Total **regional GHG emissions** `vm_emissions_reg` are the sum of emissions from different regional and cellular sources less -*' the fraction `im_maccs_mitigation` that can be abated by technicial mitigation measures (see module [57_maccs]). The emisssions before technical mitigation -*' are calculated in the respective modules ([51_nitrogen], [52_carbon], [53_methane]) and delivered to this module through the -*' interface variables `vm_btm_reg` and `vm_btm_cell`. - -q56_technical_mitigation_reg(i2,pollutants,emis_source) .. - vm_emissions_reg(i2,emis_source,pollutants) =e= - vm_btm_reg(i2,emis_source,pollutants) - * (1 - sum(ct, im_maccs_mitigation(ct,i2,emis_source,pollutants))) - ; - -q56_technical_mitigation_cell(j2,pollutants,emis_source) .. - v56_emis_cell(j2,emis_source,pollutants) =e= - sum(cell(i2,j2), - vm_btm_cell(j2,emis_source,pollutants) - * (1 - sum(ct, im_maccs_mitigation(ct,i2,emis_source,pollutants)))); - -q56_cell_to_reg(i2,pollutants,emis_source) .. - vm_emissions_reg(i2,emis_source,pollutants) =e= - sum(cell(i2,j2),v56_emis_cell(j2,emis_source,pollutants)); - - -*** Emission costs - -*' **Emission costs** are calculated by multiplying regional and cellular emissions by the emission price `im_pollutant_prices` -*' taking into account the price policy that was defined above in `f56_emis_policy`. - - q56_emission_costs_reg_yearly(i2,emis_reg_yr56) .. - v56_emission_costs_reg_yearly(i2,emis_reg_yr56) =e= - sum(pollutants, - vm_emissions_reg(i2,emis_reg_yr56,pollutants) * - sum(ct, p56_emis_policy(ct,i2,pollutants,emis_reg_yr56) * - im_pollutant_prices(ct,i2,pollutants))); - - - q56_emission_costs_cell_yearly(j2,emis_cell_yr56) .. - v56_emission_costs_cell_yearly(j2,emis_cell_yr56) =e= - sum(pollutants, - v56_emis_cell(j2,emis_cell_yr56,pollutants) * - sum((ct,cell(i2,j2)), p56_emis_policy(ct,i2,pollutants,emis_cell_yr56) * - im_pollutant_prices(ct,i2,pollutants))); - -*' As MAgPIE is a recursive dynamic model, within the optimization of the current time step it does not account for benefits or costs in future time steps. -*' This can be problematic for the treatment of emissions that occur only once under continuous management (such as deforestation, -*' where the forest has been cut down the cropland can be continuously cultivated without further deforestation emissions) versus -*' emissions that occur continously (such as fertilization emissions, that will re-occur every year for continuously management). -*' We therefore distinguish one-off and yearly emissions, and discount one-off emissions assuming an infinite time-horizon to -*' level them with yearly emissions. Since one-off emissions are delivered by the [52_carbon] module as annual emissions they are -*' multiplied here by the timestep length `m_timestep_length` to obtain emissions for the entire timestep and are then -*' transformed back into annual costs by multiplying by the emission price and a discount factor `p56_ghg_price_growth_rate` -*' that is equal to the growth rate of the emissions price. - - q56_emission_costs_reg_oneoff(i2,emis_reg_one56) .. - v56_emission_costs_reg_oneoff(i2,emis_reg_one56) =g= - sum(pollutants, - vm_emissions_reg(i2,emis_reg_one56,pollutants) - * m_timestep_length - * sum(ct, - p56_emis_policy(ct,i2,pollutants,emis_reg_one56) - * im_pollutant_prices(ct,i2,pollutants) - * p56_ghg_price_growth_rate(ct,i2,pollutants)/(1+p56_ghg_price_growth_rate(ct,i2,pollutants))) - ); - - q56_emission_costs_cell_oneoff(j2,emis_cell_one56) .. - v56_emission_costs_cell_oneoff(j2,emis_cell_one56) =g= - sum(pollutants, - v56_emis_cell(j2,emis_cell_one56,pollutants) - * m_timestep_length - * sum((ct,cell(i2,j2)), - p56_emis_policy(ct,i2,pollutants,emis_cell_one56) - * im_pollutant_prices(ct,i2,pollutants) - * p56_ghg_price_growth_rate(ct,i2,pollutants)/(1+p56_ghg_price_growth_rate(ct,i2,pollutants))) - ); - -*' **Total regional emission costs** consist of costs from yearly and one-off emissions occuring in this region and its cells. - q56_emission_costs(i2) .. - vm_emission_costs(i2) =e= - sum(emis_reg_yr56, v56_emission_costs_reg_yearly(i2,emis_reg_yr56)) - + sum(emis_reg_one56, v56_emission_costs_reg_oneoff(i2,emis_reg_one56)) - + sum((emis_cell_yr56, cell(i2,j2)), v56_emission_costs_cell_yearly(j2,emis_cell_yr56)) - + sum((emis_cell_one56, cell(i2,j2)), v56_emission_costs_cell_oneoff(j2,emis_cell_one56)) - ; - -*' **Benefits** from carbon removal (from afforestation) are also calculated in this module taking into account the policy that was -*' defined above in `f56_aff_policy`. Cost and benefits are however not summed here but in [11_costs]. - - q56_reward_cdr_aff_reg(i2) .. - vm_reward_cdr_aff(i2) =e= - sum(cell(i2,j2), - v56_reward_cdr_aff(j2) - ); - - q56_reward_cdr_aff(j2) .. - v56_reward_cdr_aff(j2) =e= - vm_cdr_aff(j2) * - sum((ct,cell(i2,j2)), - im_pollutant_prices(ct,i2,"co2_c") - * p56_ghg_price_growth_rate(ct,i2,"co2_c")/(1+p56_ghg_price_growth_rate(ct,i2,"co2_c")) - ); diff --git a/modules/56_ghg_policy/price_jan19/input.gms b/modules/56_ghg_policy/price_jan19/input.gms deleted file mode 100644 index 293abbe2d1..0000000000 --- a/modules/56_ghg_policy/price_jan19/input.gms +++ /dev/null @@ -1,42 +0,0 @@ -*** | (C) 2008-2019 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 - s56_reward_neg_emis reward CDR from all sources (-Inf) or only from afforestation (0) (1) / 0 / - s56_limit_ch4_n2o_price upper limit for CH4 and N2O GHG prices (USD05MER per tC) / 1000 / - s56_cprice_red_factor reduction factor for CO2 price (-) / 0.5 / - s56_ghgprice_start start year for ghg price phase in / 2025 / -; - -$setglobal c56_pollutant_prices R2M41-SSP2-NPi -$setglobal c56_emis_policy ssp - -table f56_pollutant_prices(t_all,i,pollutants,ghgscen56) GHG certificate prices for N2O-N CH4 CO2-C (USD05MER per t) -$ondelim -$include "./modules/56_ghg_policy/input/f56_pollutant_prices.cs3" -$offdelim -; - -$if "%c56_pollutant_prices%" == "coupling" table f56_pollutant_prices_coupling(t_all,i,pollutants) Regional ghg certificate prices for N2O-N CH4 CO2-C (USD05MER per t) -$if "%c56_pollutant_prices%" == "coupling" $ondelim -$if "%c56_pollutant_prices%" == "coupling" $include "./modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3" -$if "%c56_pollutant_prices%" == "coupling" $offdelim -$if "%c56_pollutant_prices%" == "coupling" ; - -$if "%c56_pollutant_prices%" == "emulator" table f56_pollutant_prices_emulator(t_all,pollutants) Global ghg certificate prices for N2O-N CH4 CO2-C (USD05MER per t) -$if "%c56_pollutant_prices%" == "emulator" $ondelim -$if "%c56_pollutant_prices%" == "emulator" $include "./modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3" -$if "%c56_pollutant_prices%" == "emulator" $offdelim -$if "%c56_pollutant_prices%" == "emulator" ; - -*' `f56_emis_policy` contains scenarios determining for each gas and source whether it is priced or not. - -table f56_emis_policy(scen56,pollutants_all,emis_source) GHG emission policy scenarios (1) -$ondelim -$include "./modules/56_ghg_policy/input/f56_emis_policy.csv" -$offdelim -; diff --git a/modules/56_ghg_policy/price_jan19/not_used.txt b/modules/56_ghg_policy/price_jan19/not_used.txt deleted file mode 100644 index 4b81dfbae2..0000000000 --- a/modules/56_ghg_policy/price_jan19/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason diff --git a/modules/56_ghg_policy/price_jan19/postsolve.gms b/modules/56_ghg_policy/price_jan19/postsolve.gms deleted file mode 100644 index 2d9ecebeef..0000000000 --- a/modules/56_ghg_policy/price_jan19/postsolve.gms +++ /dev/null @@ -1,95 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov56_reward_cdr_aff(t,j,"marginal") = v56_reward_cdr_aff.m(j); - ov_reward_cdr_aff(t,i,"marginal") = vm_reward_cdr_aff.m(i); - ov_btm_reg(t,i,emis_source,pollutants,"marginal") = vm_btm_reg.m(i,emis_source,pollutants); - ov_btm_cell(t,j,emis_source,pollutants,"marginal") = vm_btm_cell.m(j,emis_source,pollutants); - ov_emission_costs(t,i,"marginal") = vm_emission_costs.m(i); - ov_emissions_reg(t,i,emis_source,pollutants,"marginal") = vm_emissions_reg.m(i,emis_source,pollutants); - ov56_emis_cell(t,j,emis_source,pollutants,"marginal") = v56_emis_cell.m(j,emis_source,pollutants); - ov56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"marginal") = v56_emission_costs_reg_yearly.m(i,emis_reg_yr56); - ov56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"marginal") = v56_emission_costs_reg_oneoff.m(i,emis_reg_one56); - ov56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"marginal") = v56_emission_costs_cell_yearly.m(j,emis_cell_yr56); - ov56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"marginal") = v56_emission_costs_cell_oneoff.m(j,emis_cell_one56); - oq56_technical_mitigation_reg(t,i,pollutants,emis_source,"marginal") = q56_technical_mitigation_reg.m(i,pollutants,emis_source); - oq56_technical_mitigation_cell(t,j,pollutants,emis_source,"marginal") = q56_technical_mitigation_cell.m(j,pollutants,emis_source); - oq56_cell_to_reg(t,i,pollutants,emis_source,"marginal") = q56_cell_to_reg.m(i,pollutants,emis_source); - oq56_emission_costs(t,i,"marginal") = q56_emission_costs.m(i); - oq56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"marginal") = q56_emission_costs_reg_yearly.m(i,emis_reg_yr56); - oq56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"marginal") = q56_emission_costs_reg_oneoff.m(i,emis_reg_one56); - oq56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"marginal") = q56_emission_costs_cell_yearly.m(j,emis_cell_yr56); - oq56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"marginal") = q56_emission_costs_cell_oneoff.m(j,emis_cell_one56); - oq56_reward_cdr_aff_reg(t,i,"marginal") = q56_reward_cdr_aff_reg.m(i); - oq56_reward_cdr_aff(t,j,"marginal") = q56_reward_cdr_aff.m(j); - ov56_reward_cdr_aff(t,j,"level") = v56_reward_cdr_aff.l(j); - ov_reward_cdr_aff(t,i,"level") = vm_reward_cdr_aff.l(i); - ov_btm_reg(t,i,emis_source,pollutants,"level") = vm_btm_reg.l(i,emis_source,pollutants); - ov_btm_cell(t,j,emis_source,pollutants,"level") = vm_btm_cell.l(j,emis_source,pollutants); - ov_emission_costs(t,i,"level") = vm_emission_costs.l(i); - ov_emissions_reg(t,i,emis_source,pollutants,"level") = vm_emissions_reg.l(i,emis_source,pollutants); - ov56_emis_cell(t,j,emis_source,pollutants,"level") = v56_emis_cell.l(j,emis_source,pollutants); - ov56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"level") = v56_emission_costs_reg_yearly.l(i,emis_reg_yr56); - ov56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"level") = v56_emission_costs_reg_oneoff.l(i,emis_reg_one56); - ov56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"level") = v56_emission_costs_cell_yearly.l(j,emis_cell_yr56); - ov56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"level") = v56_emission_costs_cell_oneoff.l(j,emis_cell_one56); - oq56_technical_mitigation_reg(t,i,pollutants,emis_source,"level") = q56_technical_mitigation_reg.l(i,pollutants,emis_source); - oq56_technical_mitigation_cell(t,j,pollutants,emis_source,"level") = q56_technical_mitigation_cell.l(j,pollutants,emis_source); - oq56_cell_to_reg(t,i,pollutants,emis_source,"level") = q56_cell_to_reg.l(i,pollutants,emis_source); - oq56_emission_costs(t,i,"level") = q56_emission_costs.l(i); - oq56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"level") = q56_emission_costs_reg_yearly.l(i,emis_reg_yr56); - oq56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"level") = q56_emission_costs_reg_oneoff.l(i,emis_reg_one56); - oq56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"level") = q56_emission_costs_cell_yearly.l(j,emis_cell_yr56); - oq56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"level") = q56_emission_costs_cell_oneoff.l(j,emis_cell_one56); - oq56_reward_cdr_aff_reg(t,i,"level") = q56_reward_cdr_aff_reg.l(i); - oq56_reward_cdr_aff(t,j,"level") = q56_reward_cdr_aff.l(j); - ov56_reward_cdr_aff(t,j,"upper") = v56_reward_cdr_aff.up(j); - ov_reward_cdr_aff(t,i,"upper") = vm_reward_cdr_aff.up(i); - ov_btm_reg(t,i,emis_source,pollutants,"upper") = vm_btm_reg.up(i,emis_source,pollutants); - ov_btm_cell(t,j,emis_source,pollutants,"upper") = vm_btm_cell.up(j,emis_source,pollutants); - ov_emission_costs(t,i,"upper") = vm_emission_costs.up(i); - ov_emissions_reg(t,i,emis_source,pollutants,"upper") = vm_emissions_reg.up(i,emis_source,pollutants); - ov56_emis_cell(t,j,emis_source,pollutants,"upper") = v56_emis_cell.up(j,emis_source,pollutants); - ov56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"upper") = v56_emission_costs_reg_yearly.up(i,emis_reg_yr56); - ov56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"upper") = v56_emission_costs_reg_oneoff.up(i,emis_reg_one56); - ov56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"upper") = v56_emission_costs_cell_yearly.up(j,emis_cell_yr56); - ov56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"upper") = v56_emission_costs_cell_oneoff.up(j,emis_cell_one56); - oq56_technical_mitigation_reg(t,i,pollutants,emis_source,"upper") = q56_technical_mitigation_reg.up(i,pollutants,emis_source); - oq56_technical_mitigation_cell(t,j,pollutants,emis_source,"upper") = q56_technical_mitigation_cell.up(j,pollutants,emis_source); - oq56_cell_to_reg(t,i,pollutants,emis_source,"upper") = q56_cell_to_reg.up(i,pollutants,emis_source); - oq56_emission_costs(t,i,"upper") = q56_emission_costs.up(i); - oq56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"upper") = q56_emission_costs_reg_yearly.up(i,emis_reg_yr56); - oq56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"upper") = q56_emission_costs_reg_oneoff.up(i,emis_reg_one56); - oq56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"upper") = q56_emission_costs_cell_yearly.up(j,emis_cell_yr56); - oq56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"upper") = q56_emission_costs_cell_oneoff.up(j,emis_cell_one56); - oq56_reward_cdr_aff_reg(t,i,"upper") = q56_reward_cdr_aff_reg.up(i); - oq56_reward_cdr_aff(t,j,"upper") = q56_reward_cdr_aff.up(j); - ov56_reward_cdr_aff(t,j,"lower") = v56_reward_cdr_aff.lo(j); - ov_reward_cdr_aff(t,i,"lower") = vm_reward_cdr_aff.lo(i); - ov_btm_reg(t,i,emis_source,pollutants,"lower") = vm_btm_reg.lo(i,emis_source,pollutants); - ov_btm_cell(t,j,emis_source,pollutants,"lower") = vm_btm_cell.lo(j,emis_source,pollutants); - ov_emission_costs(t,i,"lower") = vm_emission_costs.lo(i); - ov_emissions_reg(t,i,emis_source,pollutants,"lower") = vm_emissions_reg.lo(i,emis_source,pollutants); - ov56_emis_cell(t,j,emis_source,pollutants,"lower") = v56_emis_cell.lo(j,emis_source,pollutants); - ov56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"lower") = v56_emission_costs_reg_yearly.lo(i,emis_reg_yr56); - ov56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"lower") = v56_emission_costs_reg_oneoff.lo(i,emis_reg_one56); - ov56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"lower") = v56_emission_costs_cell_yearly.lo(j,emis_cell_yr56); - ov56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"lower") = v56_emission_costs_cell_oneoff.lo(j,emis_cell_one56); - oq56_technical_mitigation_reg(t,i,pollutants,emis_source,"lower") = q56_technical_mitigation_reg.lo(i,pollutants,emis_source); - oq56_technical_mitigation_cell(t,j,pollutants,emis_source,"lower") = q56_technical_mitigation_cell.lo(j,pollutants,emis_source); - oq56_cell_to_reg(t,i,pollutants,emis_source,"lower") = q56_cell_to_reg.lo(i,pollutants,emis_source); - oq56_emission_costs(t,i,"lower") = q56_emission_costs.lo(i); - oq56_emission_costs_reg_yearly(t,i,emis_reg_yr56,"lower") = q56_emission_costs_reg_yearly.lo(i,emis_reg_yr56); - oq56_emission_costs_reg_oneoff(t,i,emis_reg_one56,"lower") = q56_emission_costs_reg_oneoff.lo(i,emis_reg_one56); - oq56_emission_costs_cell_yearly(t,j,emis_cell_yr56,"lower") = q56_emission_costs_cell_yearly.lo(j,emis_cell_yr56); - oq56_emission_costs_cell_oneoff(t,j,emis_cell_one56,"lower") = q56_emission_costs_cell_oneoff.lo(j,emis_cell_one56); - oq56_reward_cdr_aff_reg(t,i,"lower") = q56_reward_cdr_aff_reg.lo(i); - oq56_reward_cdr_aff(t,j,"lower") = q56_reward_cdr_aff.lo(j); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/56_ghg_policy/price_jan19/preloop.gms b/modules/56_ghg_policy/price_jan19/preloop.gms deleted file mode 100644 index 724f65556b..0000000000 --- a/modules/56_ghg_policy/price_jan19/preloop.gms +++ /dev/null @@ -1,65 +0,0 @@ -*** | (C) 2008-2019 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 - - -****select ghg prices -$ifthen "%c56_pollutant_prices%" == "coupling" im_pollutant_prices(t,i,pollutants) = f56_pollutant_prices_coupling(t,i,pollutants); -$elseif "%c56_pollutant_prices%" == "emulator" im_pollutant_prices(t,i,pollutants) = f56_pollutant_prices_emulator(t,pollutants); -$else im_pollutant_prices(t,i,pollutants) = f56_pollutant_prices(t,i,pollutants,"%c56_pollutant_prices%"); -$endif - -***save im_pollutant_prices to parameter -p56_pollutant_prices_input(t,i,pollutants) = im_pollutant_prices(t,i,pollutants); - -***limit CH4 and N2O GHG prices based on s56_limit_ch4_n2o_price -*12/44 conversion from USD per tC to USD per tCO2 -*28 and 265 Global Warming Potentials from AR5 WG1 CH08 Table 8.7, conversion from USD per tCO2 to USD per tCH4 and USD per tN2O -*44/28 conversion from USD per tN2O to USD per tN -im_pollutant_prices(t,i,"ch4")$(im_pollutant_prices(t,i,"ch4") > s56_limit_ch4_n2o_price*12/44*28) = s56_limit_ch4_n2o_price*12/44*28; -im_pollutant_prices(t,i,"n2o_n_direct")$(im_pollutant_prices(t,i,"n2o_n_direct") > s56_limit_ch4_n2o_price*12/44*265*44/28) = s56_limit_ch4_n2o_price*12/44*265*44/28; -im_pollutant_prices(t,i,"n2o_n_indirect")$(im_pollutant_prices(t,i,"n2o_n_indirect") > s56_limit_ch4_n2o_price*12/44*265*44/28) = s56_limit_ch4_n2o_price*12/44*265*44/28; - -***apply reduction factor on CO2 price to account for potential negative side effects -***lowers the economic incentive for CO2 emission reduction (avoided deforestation) and afforestation -im_pollutant_prices(t,i,"co2_c") = im_pollutant_prices(t,i,"co2_c")*s56_cprice_red_factor; - -***phase-in of GHG price over 20 year period; start depends on s56_ghgprice_start -im_pollutant_prices(t,i,pollutants)$(m_year(t) < s56_ghgprice_start) = 0; -im_pollutant_prices(t,i,pollutants)$(m_year(t) = s56_ghgprice_start) = 0.1*im_pollutant_prices(t,i,pollutants); -im_pollutant_prices(t,i,pollutants)$(m_year(t) = s56_ghgprice_start+5) = 0.2*im_pollutant_prices(t,i,pollutants); -im_pollutant_prices(t,i,pollutants)$(m_year(t) = s56_ghgprice_start+10) = 0.4*im_pollutant_prices(t,i,pollutants); -im_pollutant_prices(t,i,pollutants)$(m_year(t) = s56_ghgprice_start+15) = 0.8*im_pollutant_prices(t,i,pollutants); -im_pollutant_prices(t,i,pollutants)$(m_year(t) >= s56_ghgprice_start+20) = im_pollutant_prices(t,i,pollutants); - -***multiply GHG prices with development state to account for institutional requirements needed for implementing a GHG pricing scheme -im_pollutant_prices(t,i,pollutants) = im_pollutant_prices(t,i,pollutants)*im_development_state(t,i); - -display im_pollutant_prices; - -***GHG emission policy -p56_emis_policy(t,i,pollutants,emis_source) = f56_emis_policy("%c56_emis_policy%",pollutants,emis_source); - -*reward neg emissions depending on s56_reward_neg_emis -v56_emission_costs_cell_oneoff.lo(j2,emis_cell_one56) = s56_reward_neg_emis; - -*calculate ghg price growth rate -*http://de.wikihow.com/Berechnung-einer-Wachstumsrate#/Bild:Calculate-Growth-Rate-Step-6.jpg -p56_ghg_price_growth_rate(t,i,pollutants) = 0; -p56_ghg_price_growth_rate(t,i,pollutants)$(ord(t)>1 AND im_pollutant_prices(t-1,i,pollutants) > 0) = (im_pollutant_prices(t,i,pollutants)/im_pollutant_prices(t-1,i,pollutants))**(1/m_yeardiff(t))-1; -*remove negative values -p56_ghg_price_growth_rate(t,i,pollutants)$(p56_ghg_price_growth_rate(t,i,pollutants) <= 0) = 0; -*remove values exceeding 10% -p56_ghg_price_growth_rate(t,i,pollutants)$(p56_ghg_price_growth_rate(t,i,pollutants) > 0.1) = 0.1; -*calculate average growth rate over time -p56_ghg_price_growth_rate_avg(i,pollutants) = sum(t, p56_ghg_price_growth_rate(t,i,pollutants))/card(t); -*limit deviation from average growth rate over time to 1% -p56_ghg_price_growth_rate(t,i,pollutants)$(p56_ghg_price_growth_rate(t,i,pollutants) > p56_ghg_price_growth_rate_avg(i,pollutants)+0.01) = p56_ghg_price_growth_rate_avg(i,pollutants)+0.01; -p56_ghg_price_growth_rate(t,i,pollutants)$(p56_ghg_price_growth_rate(t,i,pollutants) < p56_ghg_price_growth_rate_avg(i,pollutants)-0.01) = p56_ghg_price_growth_rate_avg(i,pollutants)-0.01; -*account for special case if average growth rate is very low (<= 1%) -p56_ghg_price_growth_rate(t,i,pollutants)$(p56_ghg_price_growth_rate(t,i,pollutants) = 0) = p56_ghg_price_growth_rate_avg(i,pollutants); -*if average growth rate is zero use 5% as default -p56_ghg_price_growth_rate(t,i,pollutants)$(p56_ghg_price_growth_rate(t,i,pollutants) = 0) = 0.05; diff --git a/modules/56_ghg_policy/price_jan19/realization.gms b/modules/56_ghg_policy/price_jan19/realization.gms deleted file mode 100644 index 2565ef9cff..0000000000 --- a/modules/56_ghg_policy/price_jan19/realization.gms +++ /dev/null @@ -1,26 +0,0 @@ -*** | (C) 2008-2019 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 The price_sep16 realization applies pollutant prices to different -*' emission types depending on the emission pricing policy defined in `f56_emis_policy`. -*' In addition, carbon dioxide removal (CDR) from afforestation [32_forestry] is -*' rewarded depending on the afforestation incentive policy defined in `f56_aff_policy`. -*' For CO2 emissions from land-use change and CDR from afforestation, the growth rate -*' of the CO2 price is used to annuitize associated emission costs. -*' If pollutant prices are zero, which is the default for reference scenarios without -*' mitigation, total emission costs entering the objective function are zero. - - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/56_ghg_policy/price_jan19/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/56_ghg_policy/price_jan19/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/56_ghg_policy/price_jan19/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/56_ghg_policy/price_jan19/equations.gms" -$Ifi "%phase%" == "scaling" $include "./modules/56_ghg_policy/price_jan19/scaling.gms" -$Ifi "%phase%" == "preloop" $include "./modules/56_ghg_policy/price_jan19/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/56_ghg_policy/price_jan19/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/56_ghg_policy/price_jan19/scaling.gms b/modules/56_ghg_policy/price_jan19/scaling.gms deleted file mode 100644 index 493ddd7142..0000000000 --- a/modules/56_ghg_policy/price_jan19/scaling.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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 - -v56_emission_costs_reg_yearly.scale(i,emis_reg_yr56) = 10e5; diff --git a/modules/56_ghg_policy/price_jan19/sets.gms b/modules/56_ghg_policy/price_jan19/sets.gms deleted file mode 100644 index 6052edfe09..0000000000 --- a/modules/56_ghg_policy/price_jan19/sets.gms +++ /dev/null @@ -1,97 +0,0 @@ -*** | (C) 2008-2019 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 - - pollutants_all all pollutants - / co2_c, - ch4, - n2o_n_direct, nh3_n, no2_n, - no3_n, - n2o_n_indirect, - co, - nmhc, - h2, - pm2_5, - tpm, - tc, - oc, - bc, - so2 / - - pollutants(pollutants_all) subset of pollutants_all that can be taxed - / co2_c, - ch4, - n2o_n_direct, n2o_n_indirect, - nh3_n, no2_n, - no3_n / - - n_pollutants(pollutants) subset of n pollutants - / n2o_n_direct,n2o_n_indirect, - nh3_n, no2_n, - no3_n / - - n_pollutants_direct(n_pollutants) subset of n pollutants - / n2o_n_direct, - nh3_n, no2_n, - no3_n / - - pollutant_nh3no2_51(n_pollutants_direct) nitrogen emissions relevant for deposition - / nh3_n, no2_n / - - emis_source_n_cropsoils51(emis_source) activities that lead to emissions - / inorg_fert, man_crop, resid, som, rice / - - ghgscen56 ghg price scenarios - /R2M41-SSP2-Budg1300,R2M41-SSP2-Budg600, - R2M41-SSP2-Budg950,R2M41-SSP2-NDC,R2M41-SSP2-NPi, - SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, - SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, - SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, - SSPDB-SSP1-37-REMIND-MAGPIE, - SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, - SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, - SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, - SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, - SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, - SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, - SSPDB-SSP2-37-REMIND-MAGPIE, - SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, - SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, - SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, - SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, - SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, - SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, - SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, - SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, - SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, - SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, - SSPDB-SSP5-Ref-REMIND-MAGPIE/ - - scen56 emission policy scenarios - / none, all, ssp / - - emis_cell_one56(emis_source_cell) cellular oneoff emission sources - /crop_vegc, crop_litc, crop_soilc, past_vegc, past_litc, past_soilc, forestry_vegc, - forestry_litc, forestry_soilc, primforest_vegc, primforest_litc, primforest_soilc, - secdforest_vegc, secdforest_litc, secdforest_soilc, - urban_vegc, urban_litc, urban_soilc, other_vegc, other_litc, other_soilc/ - - emis_reg_yr56(emis_source_reg) regional yearly emission sources - /inorg_fert, man_crop, awms, resid, man_past, som, - rice, ent_ferm, beccs/ -; - -$onempty -sets - emis_cell_yr56(emis_source_cell) cellular yearly emission sources - / / - - emis_reg_one56(emis_source_reg) regional oneoff emission sources - / / - ; -$offempty diff --git a/modules/57_maccs/input/files b/modules/57_maccs/input/files index 4f7b06710f..cf9a7e8723 100644 --- a/modules/57_maccs/input/files +++ b/modules/57_maccs/input/files @@ -1,3 +1,7 @@ * list of files that are required here f57_maccs_n2o.cs3 f57_maccs_ch4.cs3 +f57_maccs_n2o_2019.cs3 +f57_maccs_ch4_2019.cs3 +f57_maccs_n2o_2022.cs3 +f57_maccs_ch4_2022.cs3 diff --git a/modules/57_maccs/module.gms b/modules/57_maccs/module.gms index a6d7662c6a..30c9a05773 100644 --- a/modules/57_maccs/module.gms +++ b/modules/57_maccs/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -17,13 +17,12 @@ *' Their direct consequences on biophysical values like yields or water requirements is ignored at the moment. *' *' Mitigation costs are estimated using marginal abatement cost curves (MACCs). -*' The curves are applied on the original emissions before technical mitigation (btm), +*' The curves are applied on the original emissions, *' and reduce them by a certain percentage in exchange for additional costs. -*' The MACCs used in this module are based on the data from @LUCAS200785. +*' The MACCs used in this module are based on the data from @LUCAS200785. *' *' @authors Benjamin Leon Bodirsky, Florian Humpenoeder *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%maccs%" == "off_jul16" $include "./modules/57_maccs/off_jul16/realization.gms" -$Ifi "%maccs%" == "on_sep16" $include "./modules/57_maccs/on_sep16/realization.gms" +$Ifi "%maccs%" == "on_aug22" $include "./modules/57_maccs/on_aug22/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/57_maccs/off_jul16/declarations.gms b/modules/57_maccs/off_jul16/declarations.gms deleted file mode 100644 index a1c90f6590..0000000000 --- a/modules/57_maccs/off_jul16/declarations.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2019 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 - im_maccs_mitigation(t,i,emis_source,pollutants) Technical mitigation of GHG emissions (percent) -; - -positive variables - vm_maccs_costs(i) Costs of technical mitigation of GHG emissions (mio. USD95MER per yr) -; - - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_maccs_costs(t,i,type) Costs of technical mitigation of GHG emissions (mio. USD95MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/57_maccs/off_jul16/not_used.txt b/modules/57_maccs/off_jul16/not_used.txt deleted file mode 100644 index 5bfd774649..0000000000 --- a/modules/57_maccs/off_jul16/not_used.txt +++ /dev/null @@ -1,10 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason -vm_btm_reg,input,not needed -im_pollutant_prices,input,not needed diff --git a/modules/57_maccs/off_jul16/postsolve.gms b/modules/57_maccs/off_jul16/postsolve.gms deleted file mode 100644 index e60d8026fa..0000000000 --- a/modules/57_maccs/off_jul16/postsolve.gms +++ /dev/null @@ -1,15 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_maccs_costs(t,i,"marginal") = vm_maccs_costs.m(i); - ov_maccs_costs(t,i,"level") = vm_maccs_costs.l(i); - ov_maccs_costs(t,i,"upper") = vm_maccs_costs.up(i); - ov_maccs_costs(t,i,"lower") = vm_maccs_costs.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/57_maccs/off_jul16/presolve.gms b/modules/57_maccs/off_jul16/presolve.gms deleted file mode 100644 index 4a54de80fa..0000000000 --- a/modules/57_maccs/off_jul16/presolve.gms +++ /dev/null @@ -1,13 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @code -*' Accordingly, this implementation sets the cost of technical mitigation of GHG emissions (`vm_maccs_costs`) -*' to zero. Please see and compare this with the equation in the next realization. - -vm_maccs_costs.fx(i) = 0; -im_maccs_mitigation(t,i,emis_source,pollutants) = 0; diff --git a/modules/57_maccs/off_jul16/realization.gms b/modules/57_maccs/off_jul16/realization.gms deleted file mode 100644 index e175007439..0000000000 --- a/modules/57_maccs/off_jul16/realization.gms +++ /dev/null @@ -1,17 +0,0 @@ -*** | (C) 2008-2019 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 Technical mitigation is not considered in this realization. - -*' @limitations It is unrealistic to assume no technical mitigation attempts. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/57_maccs/off_jul16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/57_maccs/off_jul16/declarations.gms" -$Ifi "%phase%" == "presolve" $include "./modules/57_maccs/off_jul16/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/57_maccs/off_jul16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/57_maccs/off_jul16/sets.gms b/modules/57_maccs/off_jul16/sets.gms deleted file mode 100644 index 5963ccda1d..0000000000 --- a/modules/57_maccs/off_jul16/sets.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2019 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 - - diff --git a/modules/57_maccs/on_aug22/declarations.gms b/modules/57_maccs/on_aug22/declarations.gms new file mode 100644 index 0000000000..6abdd88c98 --- /dev/null +++ b/modules/57_maccs/on_aug22/declarations.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2025 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 + s57_step_length Step length in MACC data (USD17MER) +; + +parameters + im_maccs_mitigation(t,i,emis_source,pollutants) Technical mitigation of GHG emissions (percent) + i57_mac_step_n2o(t,i,emis_source) Helper to map N2O prices and maccs_steps (1) + i57_mac_step_ch4(t,i,emis_source) Helper to map CH4 prices and maccs_steps (1) + p57_maccs_costs_integral(t,i,emis_source,pollutants) Costs of technical mitigation (USD17MER per Tg N CH4 C) +; + +equations + q57_labor_costs(i) Calculation of labor costs of technical mitigation (mio. USD17MER per yr) + q57_capital_costs(i) Calculation of capital costs of technical mitigation (mio. USD17MER per yr) +; + +positive variables + vm_maccs_costs(i,factors) Costs of technical mitigation of GHG emissions (mio. USD17MER per yr) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_maccs_costs(t,i,factors,type) Costs of technical mitigation of GHG emissions (mio. USD17MER per yr) + oq57_labor_costs(t,i,type) Calculation of labor costs of technical mitigation (mio. USD17MER per yr) + oq57_capital_costs(t,i,type) Calculation of capital costs of technical mitigation (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/57_maccs/on_aug22/equations.gms b/modules/57_maccs/on_aug22/equations.gms new file mode 100644 index 0000000000..20fa6ff178 --- /dev/null +++ b/modules/57_maccs/on_aug22/equations.gms @@ -0,0 +1,52 @@ +*** | (C) 2008-2025 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 +*' Therefore, the equation below is used to estimate the mitigation costs. +*' MACC costs are calculated based on emissions BEFORE technical mitigation. +*' These emissions are here calculated back from the final emissions, using +*' the mitigated shares. Please note that in some cases (e.g. N2O emissions +*' from soils) there is an intended mismatch between the actual mitigated +*' quantities, and the quantities for which abatement has to be paid. As can +*' be seen in the respective emission module (e.g. 50_nr_soil_budget), the +*' mitigation quantity is reduced if baseline efficiencies are already high, +*' but the mitigation costs still apply fully, as the mitigation "effort" +*' is the same. +*' Mitigation costs are then calculated as the product of GHG emissions +*' before technical mitigation, and the costs per unit of technical mitigation. +*' The mitigation costs will go into the objective function of the model. + +*' To avoid double-accounting, the fertilizer savings that reduce the costs of +*' the MACCs have to be added again to the MACCs, as the fertilizer costs are +*' endogenous in our model and fall with rising MACCs. We ex-post replicate +*' these implicit cost savings by assuming that they calculate the MACCs emission +*' savings proportional to fertilizer savings. Fertilization quantity is derived by +*' calculating emissions back to fertilization using the default emission factor +*' by the IPCC that is likely the basis for their estimates (E=F*EF, F= E/EF). + +*' Costs are assumed to be factor costs and split into a labor and a capital part. +*' The labor share is scaled according to the changes in wages and corresponding +*' productivity change. + +q57_labor_costs(i2) .. + vm_maccs_costs(i2,"labor") =e= + (sum((ct,emis_source,pollutants_maccs57), p57_maccs_costs_integral(ct,i2,emis_source,pollutants_maccs57) + * vm_emissions_reg(i2,emis_source,pollutants_maccs57) / (1 - im_maccs_mitigation(ct,i2,emis_source,pollutants_maccs57))) + + sum(emis_source_inorg_fert_n2o, + (vm_emissions_reg(i2,emis_source_inorg_fert_n2o,"n2o_n_direct") / s57_implicit_emis_factor) * + sum(ct,im_maccs_mitigation(ct,i2,emis_source_inorg_fert_n2o,"n2o_n_direct")) * s57_implicit_fert_cost)) + * sum(ct, pm_factor_cost_shares(ct ,i2,"labor") * (1/pm_productivity_gain_from_wages(ct,i2)) * + (pm_hourly_costs(ct,i2,"scenario") / pm_hourly_costs(ct,i2,"baseline"))); + +q57_capital_costs(i2) .. + vm_maccs_costs(i2,"capital") =e= + (sum((ct,emis_source,pollutants_maccs57), p57_maccs_costs_integral(ct,i2,emis_source,pollutants_maccs57) + * vm_emissions_reg(i2,emis_source,pollutants_maccs57) / (1 - im_maccs_mitigation(ct,i2,emis_source,pollutants_maccs57))) + + sum(emis_source_inorg_fert_n2o, + (vm_emissions_reg(i2,emis_source_inorg_fert_n2o,"n2o_n_direct") / s57_implicit_emis_factor) * + sum(ct,im_maccs_mitigation(ct,i2,emis_source_inorg_fert_n2o,"n2o_n_direct")) * s57_implicit_fert_cost)) + * sum(ct, pm_factor_cost_shares(ct ,i2,"capital")); diff --git a/modules/57_maccs/on_aug22/input.gms b/modules/57_maccs/on_aug22/input.gms new file mode 100644 index 0000000000..19132524a2 --- /dev/null +++ b/modules/57_maccs/on_aug22/input.gms @@ -0,0 +1,54 @@ +*** | (C) 2008-2025 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 + +* option: PBL_2007, PBL_2019, PBL_2022 +$setglobal c57_macc_version PBL_2022 +* option: Default, Optimistic, Pessimistic; only applicable for PBL_2022 +$setglobal c57_macc_scenario Default + +scalars + s57_maxmac_n_soil activate soil N mitigation independent of pollutant price (step of MACC and -1 is inactive) / -1 / + s57_maxmac_n_awms activate awms N mitigation independent of pollutant price (step of MACC and -1 is inactive) / -1 / + s57_maxmac_ch4_rice activate rice CH4 mitigation independent of pollutant price (step of MACC and -1 is inactive)/ -1 / + s57_maxmac_ch4_entferm activate enteric fermentation CH4 mitigation independent of pollutant price (step of MACC and -1 is inactive) / -1 / + s57_maxmac_ch4_awms activate awms CH4 mitigation independent of pollutant price (step of MACC and -1 is inactive) / -1 / + s57_implicit_emis_factor emission factor for direct soil emissions implicit to MACC curves (tN2ON per tN) / 0.01 / + s57_implicit_fert_cost fertilizer costs implicit to MACC curves (USD17MER per ton N) / 738 / +; + +$onEmpty +table f57_maccs_n2o(t_all,i,maccs_n2o,maccs_steps) N2O MACC from Image model (percent) +$ondelim +$if "%c57_macc_version%" == "PBL_2007" $include "./modules/57_maccs/input/f57_maccs_n2o.cs3" +$if "%c57_macc_version%" == "PBL_2019" $include "./modules/57_maccs/input/f57_maccs_n2o_2019.cs3" +$offdelim +; +$offEmpty + +table f57_maccs_n2o_2022(t_all,i,maccs_n2o,scen57,maccs_steps) N2O MACC from Image model (percent) +$ondelim +$include "./modules/57_maccs/input/f57_maccs_n2o_2022.cs3" +$offdelim +; +$if "%c57_macc_version%" == "PBL_2022" f57_maccs_n2o(t_all,i,maccs_n2o,maccs_steps) = f57_maccs_n2o_2022(t_all,i,maccs_n2o,"%c57_macc_scenario%",maccs_steps) + + +$onEmpty +table f57_maccs_ch4(t_all,i,maccs_ch4,maccs_steps) CH4 MACC from Image model (percent) +$ondelim +$if "%c57_macc_version%" == "PBL_2007" $include "./modules/57_maccs/input/f57_maccs_ch4.cs3" +$if "%c57_macc_version%" == "PBL_2019" $include "./modules/57_maccs/input/f57_maccs_ch4_2019.cs3" +$offdelim +; +$offEmpty + +table f57_maccs_ch4_2022(t_all,i,maccs_ch4,scen57,maccs_steps) N2O MACC from Image model (percent) +$ondelim +$include "./modules/57_maccs/input/f57_maccs_ch4_2022.cs3" +$offdelim +; +$if "%c57_macc_version%" == "PBL_2022" f57_maccs_ch4(t_all,i,maccs_ch4,maccs_steps) = f57_maccs_ch4_2022(t_all,i,maccs_ch4,"%c57_macc_scenario%",maccs_steps) diff --git a/modules/57_maccs/on_aug22/postsolve.gms b/modules/57_maccs/on_aug22/postsolve.gms new file mode 100644 index 0000000000..cac8a76a1e --- /dev/null +++ b/modules/57_maccs/on_aug22/postsolve.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_maccs_costs(t,i,factors,"marginal") = vm_maccs_costs.m(i,factors); + oq57_labor_costs(t,i,"marginal") = q57_labor_costs.m(i); + oq57_capital_costs(t,i,"marginal") = q57_capital_costs.m(i); + ov_maccs_costs(t,i,factors,"level") = vm_maccs_costs.l(i,factors); + oq57_labor_costs(t,i,"level") = q57_labor_costs.l(i); + oq57_capital_costs(t,i,"level") = q57_capital_costs.l(i); + ov_maccs_costs(t,i,factors,"upper") = vm_maccs_costs.up(i,factors); + oq57_labor_costs(t,i,"upper") = q57_labor_costs.up(i); + oq57_capital_costs(t,i,"upper") = q57_capital_costs.up(i); + ov_maccs_costs(t,i,factors,"lower") = vm_maccs_costs.lo(i,factors); + oq57_labor_costs(t,i,"lower") = q57_labor_costs.lo(i); + oq57_capital_costs(t,i,"lower") = q57_capital_costs.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/57_maccs/on_aug22/preloop.gms b/modules/57_maccs/on_aug22/preloop.gms new file mode 100644 index 0000000000..294223064c --- /dev/null +++ b/modules/57_maccs/on_aug22/preloop.gms @@ -0,0 +1,110 @@ +*** | (C) 2008-2025 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 + +* inflated using USD05 --> USD17 MER rate: 5 * 1.23 +$if "%c57_macc_version%" == "PBL_2007" s57_step_length = 6.15; +* inflated using USD10 --> USD17 MER rate: 20 * 1.12 +$if "%c57_macc_version%" == "PBL_2019" s57_step_length = 22.4; +* inflated using USD10 --> USD17 MER rate: 20 * 1.12 +$if "%c57_macc_version%" == "PBL_2022" s57_step_length = 22.4; + +$ontext +Determine level of GHG emission abatement depending on GHG prices. +There are 201 abatement steps. Each step is 6.15 USD17MER per tC eq in case of PBL_2007 and +22.4 USD17MER per tC eq in case of PBL_2019. +Since the GHG prices are in USD per ton N and USD per ton CH4, conversion to USD per ton C eq is needed. +In this realization, the IPCC AR4 global warming potential factor for N2O (298) and CH4 (25) are used because +PBL used these parameters to convert USD per ton N2O and USD per ton CH4 into USD per ton C eq. +$offtext + +i57_mac_step_n2o(t,i,emis_source) = min(201, ceil(im_pollutant_prices(t,i,"n2o_n_direct",emis_source)/298*28/44*44/12 / s57_step_length) + 1); +i57_mac_step_ch4(t,i,emis_source) = min(201, ceil(im_pollutant_prices(t,i,"ch4",emis_source)/25*44/12 / s57_step_length) + 1); + + +loop(t, + + if(m_year(t) > sm_fix_SSP2, + + if (s57_maxmac_n_soil >= 0, i57_mac_step_n2o(t,i,emis_source_inorg_fert_n2o) = s57_maxmac_n_soil); + if (s57_maxmac_n_awms >= 0, i57_mac_step_n2o(t,i,emis_source_awms_n2o) = s57_maxmac_n_awms); + if (s57_maxmac_ch4_rice >= 0, i57_mac_step_ch4(t,i,emis_source_rice_ch4) = s57_maxmac_ch4_rice); + if (s57_maxmac_ch4_entferm >= 0, i57_mac_step_ch4(t,i,emis_source_ent_ferm_ch4) = s57_maxmac_ch4_entferm); + if (s57_maxmac_ch4_awms >= 0, i57_mac_step_ch4(t,i,emis_source_awms_ch4) = s57_maxmac_ch4_awms); + + ); +); + +*Calculate technical mitigation depending on i57_mac_step_n2o and i57_mac_step_ch4. +*At zero GHG prices i57_mac_step_n2o and i57_mac_step_ch4 are set to 1. +*Technical mitigation should be zero at zero GHG prices. +*There the following calculations are only executed for ord(maccs_steps) > 1 + +im_maccs_mitigation(t,i,emis_source,pollutants) = 0; + +im_maccs_mitigation(t,i,emis_source_inorg_fert_n2o,"n2o_n_direct") = + sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_n2o(t,i,emis_source_inorg_fert_n2o) AND ord(maccs_steps) > 1), + f57_maccs_n2o(t,i,"inorg_fert_n2o",maccs_steps)); + +im_maccs_mitigation(t,i,emis_source_awms_n2o,"n2o_n_direct") = + sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_n2o(t,i,emis_source_awms_n2o) AND ord(maccs_steps) > 1), + f57_maccs_n2o(t,i,"awms_manure_n2o",maccs_steps)); + +im_maccs_mitigation(t,i,emis_source_rice_ch4,"ch4") = + sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_ch4(t,i,emis_source_rice_ch4) AND ord(maccs_steps) > 1), + f57_maccs_ch4(t,i,"rice_ch4",maccs_steps)); + +im_maccs_mitigation(t,i,emis_source_ent_ferm_ch4,"ch4") = + sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_ch4(t,i,emis_source_ent_ferm_ch4) AND ord(maccs_steps) > 1), + f57_maccs_ch4(t,i,"ent_ferm_ch4",maccs_steps)); + +im_maccs_mitigation(t,i,emis_source_awms_ch4,"ch4") = + sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_ch4(t,i,emis_source_awms_ch4) AND ord(maccs_steps) > 1), + f57_maccs_ch4(t,i,"awms_ch4",maccs_steps)); + +$ontext +The costs associated with technical abatement of GHG emissions are reflected by the area under the mac curve, i.e. the integral. +Abatement options at zero cost are in the first step. Therefore an offset of -1 is used. +Note that the emissions before mitigation, which need to be part of the integral calculation but are not available in preloop, +are multiplied with p57_maccs_costs_integral during optimization (see equations). + +Illustrative example for CH4: Abatement is 0.14 percent at 0$/tC, 0.15 percent at 5 and 10 $/tC, and 0.16 percent at 15 $/tC. +Emissions before technical mitigation are assumed 1 t CH4. + +step 1 0 mio $ 0 mio $ +step 2 (0.15-0.14) * 1 tCH4 * 5$/tC*12/44*28 0.38 mio $ 0.38 mio $ +step 3 (0.15-0.15) * 1 tCH4 * 10$/tC*12/44*28 0 mio $ 0.38 mio $ +step 4 (0.16-0.15) * 1 tCH4 * 15$/tC*12/44*28 1.15 mio $ 1.53 mio $ + +$offtext + +p57_maccs_costs_integral(t,i,emis_source,pollutants) = 0; + +loop(maccs_steps$(ord(maccs_steps) > 1), + p57_maccs_costs_integral(t,i,emis_source_inorg_fert_n2o,"n2o_n_direct")$(ord(maccs_steps) <= i57_mac_step_n2o(t,i,emis_source_inorg_fert_n2o)) = + p57_maccs_costs_integral(t,i,emis_source_inorg_fert_n2o,"n2o_n_direct") + + (f57_maccs_n2o(t,i,"inorg_fert_n2o",maccs_steps) - f57_maccs_n2o(t,i,"inorg_fert_n2o",maccs_steps-1))*(ord(maccs_steps)-1)*s57_step_length; + + p57_maccs_costs_integral(t,i,emis_source_awms_n2o,"n2o_n_direct")$(ord(maccs_steps) <= i57_mac_step_n2o(t,i,emis_source_awms_n2o)) = + p57_maccs_costs_integral(t,i,emis_source_awms_n2o,"n2o_n_direct") + + (f57_maccs_n2o(t,i,"awms_manure_n2o",maccs_steps) - f57_maccs_n2o(t,i,"awms_manure_n2o",maccs_steps-1))*(ord(maccs_steps)-1)*s57_step_length; + + p57_maccs_costs_integral(t,i,emis_source_rice_ch4,"ch4")$(ord(maccs_steps) <= i57_mac_step_ch4(t,i,emis_source_rice_ch4)) = + p57_maccs_costs_integral(t,i,emis_source_rice_ch4,"ch4") + + (f57_maccs_ch4(t,i,"rice_ch4",maccs_steps) - f57_maccs_ch4(t,i,"rice_ch4",maccs_steps-1))*(ord(maccs_steps)-1)*s57_step_length; + + p57_maccs_costs_integral(t,i,emis_source_ent_ferm_ch4,"ch4")$(ord(maccs_steps) <= i57_mac_step_ch4(t,i,emis_source_ent_ferm_ch4)) = + p57_maccs_costs_integral(t,i,emis_source_ent_ferm_ch4,"ch4") + + (f57_maccs_ch4(t,i,"ent_ferm_ch4",maccs_steps) - f57_maccs_ch4(t,i,"ent_ferm_ch4",maccs_steps-1))*(ord(maccs_steps)-1)*s57_step_length; + + p57_maccs_costs_integral(t,i,emis_source_awms_ch4,"ch4")$(ord(maccs_steps) <= i57_mac_step_ch4(t,i,emis_source_awms_ch4)) = + p57_maccs_costs_integral(t,i,emis_source_awms_ch4,"ch4") + + (f57_maccs_ch4(t,i,"awms_ch4",maccs_steps) - f57_maccs_ch4(t,i,"awms_ch4",maccs_steps-1))*(ord(maccs_steps)-1)*s57_step_length; +); + +*Conversion from USD per ton C to USD per ton N and USD per ton CH4, using the old IPCC AR4 GWP factors. +p57_maccs_costs_integral(t,i,emis_source,"n2o_n_direct") = p57_maccs_costs_integral(t,i,emis_source,"n2o_n_direct")*12/44*298*44/28; +p57_maccs_costs_integral(t,i,emis_source,"ch4") = p57_maccs_costs_integral(t,i,emis_source,"ch4")*12/44*25; diff --git a/modules/57_maccs/on_aug22/realization.gms b/modules/57_maccs/on_aug22/realization.gms new file mode 100644 index 0000000000..dc6f67a2ea --- /dev/null +++ b/modules/57_maccs/on_aug22/realization.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 Unlike the previous realization, this implementation allows for the possibility +*' that non-CO2 emissions can be reduced by technical mitigation at additional costs. +*' The following MACC data sets are available in this module: +*' @LUCAS200785 (PBL_2007) and @Harmsen2019 (PBL_2019). +*' +*' @limitations The data set PBL_2007 is outdated and only kept for backward compatibility + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/57_maccs/on_aug22/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/57_maccs/on_aug22/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/57_maccs/on_aug22/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/57_maccs/on_aug22/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/57_maccs/on_aug22/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/57_maccs/on_aug22/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/57_maccs/on_aug22/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/57_maccs/on_aug22/scaling.gms b/modules/57_maccs/on_aug22/scaling.gms new file mode 100644 index 0000000000..d3683dd20d --- /dev/null +++ b/modules/57_maccs/on_aug22/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_maccs_costs.scale(i,factors) = 10e4; diff --git a/modules/57_maccs/on_aug22/sets.gms b/modules/57_maccs/on_aug22/sets.gms new file mode 100644 index 0000000000..05a22ec5da --- /dev/null +++ b/modules/57_maccs/on_aug22/sets.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2025 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 + + emis_source_inorg_fert_n2o(emis_source) subset inorg_fert_n2o emissions + /inorg_fert, resid, som, rice, man_crop, man_past/ + + emis_source_awms_n2o(emis_source) subset awms_manure_n2o + /awms/ + + emis_source_rice_ch4(emis_source) subset rice emissions + /rice/ + + emis_source_ent_ferm_ch4(emis_source) subset ent_ferm emissions + /ent_ferm/ + + emis_source_awms_ch4(emis_source) subset awms emissions + /awms/ + + pollutants_maccs57(pollutants) pollutants via which MAC costs are calculated + / ch4, n2o_n_direct / + + maccs_ch4 ch4 mitigation categories with MACCS + / rice_ch4, ent_ferm_ch4, awms_ch4 / + + maccs_n2o n2o mitigation categories with MACCS + / inorg_fert_n2o, awms_manure_n2o / + + maccs_steps maccs tax level steps + / 1*201 / + + scen57 scenarios + / Default, Optimistic, Pessimistic / + +; diff --git a/modules/57_maccs/on_sep16/declarations.gms b/modules/57_maccs/on_sep16/declarations.gms deleted file mode 100644 index 2eed64ed35..0000000000 --- a/modules/57_maccs/on_sep16/declarations.gms +++ /dev/null @@ -1,28 +0,0 @@ -*** | (C) 2008-2019 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 - im_maccs_mitigation(t,i,emis_source,pollutants) Technical mitigation of GHG emissions (percent) - i57_mac_step_n2o(t,i) Helper to map N2O prices and maccs_steps (1) - i57_mac_step_ch4(t,i) Helper to map CH4 prices and maccs_steps (1) - p57_maccs_costs_integral(t,i,emis_source,pollutants) Costs of technical mitigation (USD95MER per Tg N CH4 C) -; - -equations - q57_total_costs(i) Calculation of total costs of technical mitigation (mio. USD95MER per yr) -; - -positive variables - vm_maccs_costs(i) Costs of technical mitigation of GHG emissions (mio. USD95MER per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_maccs_costs(t,i,type) Costs of technical mitigation of GHG emissions (mio. USD95MER per yr) - oq57_total_costs(t,i,type) Calculation of total costs of technical mitigation (mio. USD95MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/57_maccs/on_sep16/equations.gms b/modules/57_maccs/on_sep16/equations.gms deleted file mode 100644 index 6260ebf50d..0000000000 --- a/modules/57_maccs/on_sep16/equations.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 -*' Therefore, the equation below is used to estimate the mitigation costs. -*' It is simply calculated as a product of GHG emissions before technical mitigation (`vm_btm_reg`), -*' and the costs per unit of technical mitigation (`p57_maccs_costs_integral`). -*' The mitigation costs will go into the objective function of the model. - -q57_total_costs(i2) .. - vm_maccs_costs(i2) =g= - sum((ct,emis_source), p57_maccs_costs_integral(ct,i2,emis_source,"n2o_n_direct") - * vm_btm_reg(i2,emis_source,"n2o_n_direct") - + p57_maccs_costs_integral(ct,i2,emis_source,"ch4") - * vm_btm_reg(i2,emis_source,"ch4") - ); diff --git a/modules/57_maccs/on_sep16/input.gms b/modules/57_maccs/on_sep16/input.gms deleted file mode 100644 index 735da7a751..0000000000 --- a/modules/57_maccs/on_sep16/input.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - -table f57_maccs_n2o(t_all,i,maccs_n2o,maccs_steps) N2O MACC from Image model (percent) -$ondelim -$include "./modules/57_maccs/input/f57_maccs_n2o.cs3" -$offdelim -; - -table f57_maccs_ch4(t_all,i,maccs_ch4,maccs_steps) CH4 MACC from Image model (percent) -$ondelim -$include "./modules/57_maccs/input/f57_maccs_ch4.cs3" -$offdelim -; diff --git a/modules/57_maccs/on_sep16/not_used.txt b/modules/57_maccs/on_sep16/not_used.txt deleted file mode 100644 index 4b81dfbae2..0000000000 --- a/modules/57_maccs/on_sep16/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason diff --git a/modules/57_maccs/on_sep16/postsolve.gms b/modules/57_maccs/on_sep16/postsolve.gms deleted file mode 100644 index e79a63c1ec..0000000000 --- a/modules/57_maccs/on_sep16/postsolve.gms +++ /dev/null @@ -1,19 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_maccs_costs(t,i,"marginal") = vm_maccs_costs.m(i); - oq57_total_costs(t,i,"marginal") = q57_total_costs.m(i); - ov_maccs_costs(t,i,"level") = vm_maccs_costs.l(i); - oq57_total_costs(t,i,"level") = q57_total_costs.l(i); - ov_maccs_costs(t,i,"upper") = vm_maccs_costs.up(i); - oq57_total_costs(t,i,"upper") = q57_total_costs.up(i); - ov_maccs_costs(t,i,"lower") = vm_maccs_costs.lo(i); - oq57_total_costs(t,i,"lower") = q57_total_costs.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/57_maccs/on_sep16/preloop.gms b/modules/57_maccs/on_sep16/preloop.gms deleted file mode 100644 index 9a5060a7ad..0000000000 --- a/modules/57_maccs/on_sep16/preloop.gms +++ /dev/null @@ -1,96 +0,0 @@ -*** | (C) 2008-2019 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 - -$ontext -Determine level of GHG emission abatement depending on GHG prices. -There are 200 abatement steps. Each step is 5 USD per tC eq. Options at zero cost are in the first step. -Since the GHG prices are in USD per ton N and USD per ton CH4, conversion to USD per ton C eq is needed. -In this realization, the old IPCC AR4 global warming potential factor for N2O (298) and CH4 (25) MUST be used because -Lucas et al used these parameters to convert USD per ton N2O and USD per ton CH4 into USD per ton C eq. -$offtext - -i57_mac_step_n2o(t,i) = min(201, ceil(im_pollutant_prices(t,i,"n2o_n_direct")/298*28/44*44/12 / 5) + 1); -i57_mac_step_ch4(t,i) = min(201, ceil(im_pollutant_prices(t,i,"ch4")/25*44/12 / 5) + 1); - -*Calculate technical mitigation depending on i57_mac_step_n2o and i57_mac_step_ch4. -*At zero GHG prices i57_mac_step_n2o/i57_mac_step_ch4 are set to 1. -*Technical mitigation should be zero at zero GHG prices. -*There the following calculations are only executed for ord(maccs_steps) > 1 - -im_maccs_mitigation(t,i,emis_source,pollutants) = 0; - -im_maccs_mitigation(t,i,emis_source_inorg_fert_n2o,"n2o_n_direct") = - sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_n2o(t,i) AND ord(maccs_steps) > 1), - f57_maccs_n2o(t,i,"inorg_fert_n2o",maccs_steps)); - -im_maccs_mitigation(t,i,emis_source_awms_manure_n2o,"n2o_n_direct") = - sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_n2o(t,i) AND ord(maccs_steps) > 1), - f57_maccs_n2o(t,i,"awms_manure_n2o",maccs_steps)); - -im_maccs_mitigation(t,i,emis_source_rice_ch4,"ch4") = - sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_ch4(t,i) AND ord(maccs_steps) > 1), - f57_maccs_ch4(t,i,"rice_ch4",maccs_steps)); - -im_maccs_mitigation(t,i,emis_source_ent_ferm_ch4,"ch4") = - sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_ch4(t,i) AND ord(maccs_steps) > 1), - f57_maccs_ch4(t,i,"ent_ferm_ch4",maccs_steps)); - -im_maccs_mitigation(t,i,emis_source_awms_ch4,"ch4") = - sum(maccs_steps$(ord(maccs_steps) eq i57_mac_step_ch4(t,i) AND ord(maccs_steps) > 1), - f57_maccs_ch4(t,i,"awms_ch4",maccs_steps)); - -$ontext -The costs associated with technical abatement of GHG emissions are reflected by the area under the mac curve, i.e. the integral. -Abatement options at zero cost are in the first step. Therefore an offset of -1 is used. -Note that vm_btm_reg, which needs to be part of the integral calculation but is not available in preloop, -is multiplied with p57_maccs_costs_integral during optimization (see equations). - -Illustrative example for CH4: Abatement is 0.14 percent at 0$/tC, 0.15 percent at 5 and 10 $/tC, and 0.16 percent at 15 $/tC. -Emissions before technical mitigation are assumed 1 t CH4. - -step 1 0 mio $ 0 mio $ -step 2 (0.15-0.14) * 1 tCH4 * 5$/tC*12/44*28 0.38 mio $ 0.38 mio $ -step 3 (0.15-0.15) * 1 tCH4 * 10$/tC*12/44*28 0 mio $ 0.38 mio $ -step 4 (0.16-0.15) * 1 tCH4 * 15$/tC*12/44*28 1.15 mio $ 1.53 mio $ - -$offtext - -p57_maccs_costs_integral(t,i,emis_source,pollutants) = 0; - -loop(maccs_steps$(ord(maccs_steps) > 1), - p57_maccs_costs_integral(t,i,emis_source_inorg_fert_n2o,"n2o_n_direct")$(ord(maccs_steps) <= i57_mac_step_n2o(t,i)) = - p57_maccs_costs_integral(t,i,emis_source_inorg_fert_n2o,"n2o_n_direct") + - (f57_maccs_n2o(t,i,"inorg_fert_n2o",maccs_steps) - f57_maccs_n2o(t,i,"inorg_fert_n2o",maccs_steps-1))*(ord(maccs_steps)-1)*5; - - p57_maccs_costs_integral(t,i,emis_source_awms_manure_n2o,"n2o_n_direct")$(ord(maccs_steps) <= i57_mac_step_n2o(t,i)) = - p57_maccs_costs_integral(t,i,emis_source_awms_manure_n2o,"n2o_n_direct") + - (f57_maccs_n2o(t,i,"awms_manure_n2o",maccs_steps) - f57_maccs_n2o(t,i,"awms_manure_n2o",maccs_steps-1))*(ord(maccs_steps)-1)*5; - - p57_maccs_costs_integral(t,i,emis_source_rice_ch4,"ch4")$(ord(maccs_steps) <= i57_mac_step_ch4(t,i)) = - p57_maccs_costs_integral(t,i,emis_source_rice_ch4,"ch4") + - (f57_maccs_ch4(t,i,"rice_ch4",maccs_steps) - f57_maccs_ch4(t,i,"rice_ch4",maccs_steps-1))*(ord(maccs_steps)-1)*5; - - p57_maccs_costs_integral(t,i,emis_source_ent_ferm_ch4,"ch4")$(ord(maccs_steps) <= i57_mac_step_ch4(t,i)) = - p57_maccs_costs_integral(t,i,emis_source_ent_ferm_ch4,"ch4") + - (f57_maccs_ch4(t,i,"ent_ferm_ch4",maccs_steps) - f57_maccs_ch4(t,i,"ent_ferm_ch4",maccs_steps-1))*(ord(maccs_steps)-1)*5; - - p57_maccs_costs_integral(t,i,emis_source_awms_ch4,"ch4")$(ord(maccs_steps) <= i57_mac_step_ch4(t,i)) = - p57_maccs_costs_integral(t,i,emis_source_awms_ch4,"ch4") + - (f57_maccs_ch4(t,i,"awms_ch4",maccs_steps) - f57_maccs_ch4(t,i,"awms_ch4",maccs_steps-1))*(ord(maccs_steps)-1)*5; -); - -*Conversion from USD per ton C to USD per ton N and USD per ton CH4, using the old IPCC AR4 GWP factors. -p57_maccs_costs_integral(t,i,emis_source,"n2o_n_direct") = p57_maccs_costs_integral(t,i,emis_source,"n2o_n_direct")*12/44*298*44/28; -p57_maccs_costs_integral(t,i,emis_source,"ch4") = p57_maccs_costs_integral(t,i,emis_source,"ch4")*12/44*25; - - -display -i57_mac_step_n2o -i57_mac_step_ch4 -im_maccs_mitigation -p57_maccs_costs_integral -; diff --git a/modules/57_maccs/on_sep16/realization.gms b/modules/57_maccs/on_sep16/realization.gms deleted file mode 100644 index 1879dd0083..0000000000 --- a/modules/57_maccs/on_sep16/realization.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 Unlike the previous realization, this implementation allows for the possibility -*' that non-CO2 emissions can be reduced by technical mitigation at additional costs. -*' -*' @limitations There are still issues related to data quality used by our source. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/57_maccs/on_sep16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/57_maccs/on_sep16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/57_maccs/on_sep16/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/57_maccs/on_sep16/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/57_maccs/on_sep16/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/57_maccs/on_sep16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/57_maccs/on_sep16/sets.gms b/modules/57_maccs/on_sep16/sets.gms deleted file mode 100644 index 4ef7b21114..0000000000 --- a/modules/57_maccs/on_sep16/sets.gms +++ /dev/null @@ -1,34 +0,0 @@ -*** | (C) 2008-2019 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 - - emis_source_inorg_fert_n2o(emis_source) subset inorg_fert_n2o emissions - /inorg_fert,resid,som,rice/ - - emis_source_awms_manure_n2o(emis_source) subset awms_manure_n2o - /man_crop,man_past,awms/ - - emis_source_rice_ch4(emis_source) subset rice emissions - /rice/ - - emis_source_ent_ferm_ch4(emis_source) subset ent_ferm emissions - /ent_ferm/ - - emis_source_awms_ch4(emis_source) subset awms emissions - /awms/ - - maccs_ch4 ch4 mitigation categories with MACCS - / rice_ch4, ent_ferm_ch4, awms_ch4 / - - maccs_n2o n2o mitigation categories with MACCS - / inorg_fert_n2o, awms_manure_n2o / - - maccs_steps maccs tax level steps - / 1*201 / - -; diff --git a/modules/58_peatland/input/files b/modules/58_peatland/input/files new file mode 100644 index 0000000000..9af5876c07 --- /dev/null +++ b/modules/58_peatland/input/files @@ -0,0 +1,4 @@ +* list of files that are required here +f58_ipcc_wetland_ef2.cs3 +f58_peatland_area.cs3 +f58_peatland_area_iso.cs3 diff --git a/modules/58_peatland/module.gms b/modules/58_peatland/module.gms new file mode 100644 index 0000000000..8ba7ed5c70 --- /dev/null +++ b/modules/58_peatland/module.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2025 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 + +*' @title Peatland +*' +*' @description The peatland module calculates GHG emissions from degrading/drained peatlands. +*' +*' @authors Florian Humpenöder, Debbora Leip + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%peatland%" == "off" $include "./modules/58_peatland/off/realization.gms" +$Ifi "%peatland%" == "v2" $include "./modules/58_peatland/v2/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/58_peatland/off/declarations.gms b/modules/58_peatland/off/declarations.gms new file mode 100644 index 0000000000..ff96386ae0 --- /dev/null +++ b/modules/58_peatland/off/declarations.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2025 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 + +positive variables + vm_peatland_cost(j) One-time and recurring cost of managed peatland (mio. USD17MER per yr) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_peatland_cost(t,j,type) One-time and recurring cost of managed peatland (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/58_peatland/off/not_used.txt b/modules/58_peatland/off/not_used.txt new file mode 100644 index 0000000000..0297c16bec --- /dev/null +++ b/modules/58_peatland/off/not_used.txt @@ -0,0 +1,11 @@ +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 +vm_landreduction, input, not used +vm_landexpansion_forestry, input, not used +vm_landreduction_forestry, input, not used diff --git a/modules/58_peatland/off/postsolve.gms b/modules/58_peatland/off/postsolve.gms new file mode 100644 index 0000000000..98e966bbc9 --- /dev/null +++ b/modules/58_peatland/off/postsolve.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); + ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); + ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); + ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/58_peatland/off/preloop.gms b/modules/58_peatland/off/preloop.gms new file mode 100644 index 0000000000..676ab96f13 --- /dev/null +++ b/modules/58_peatland/off/preloop.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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_peatland_cost.fx(j) = 0; diff --git a/modules/58_peatland/off/realization.gms b/modules/58_peatland/off/realization.gms new file mode 100644 index 0000000000..8993da216a --- /dev/null +++ b/modules/58_peatland/off/realization.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2025 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, peatlands do not exist. Therefore, +*' GHG emissions from degrading peatlands are assumed zero. + +*' @limitations Peatland area and associated GHG emissions are fixed to zero. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/58_peatland/off/declarations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/58_peatland/off/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/58_peatland/off/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms new file mode 100644 index 0000000000..ed33c47a38 --- /dev/null +++ b/modules/58_peatland/v2/declarations.gms @@ -0,0 +1,85 @@ +*** | (C) 2008-2025 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 + pc58_peatland(j,land58) Peatland area (mio. ha) + pc58_manLand(j,manPeat58) Managed land area (mio. ha) + p58_scalingFactorExp(t,j) Scaling factor for peatland expansion (1) + 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 (USD17MER per ha) + i58_cost_drain_recur(t) Recurring costs for drained and managed peatlands (USD17MER per ha) + i58_cost_onetime(t,cost58) One-time costs for peatland rewetting and drainage (USD17MER per ha) + p58_availPeatlandExp(t,j) Available area for expansion of drained peatland (mio. ha) + p58_availLandExp(t,j) Available area for expansion of managed land (mio. ha) + i58_peatland_rewetting_fader(t_all) Temporal fader for exogenous peatland rewetting (1) + p58_peatland_ref(j,land58) Peatland area in reference period (mio. ha) + p58_country_switch(iso) Switch indicating whether country is affected by exogenous peatland rewetting (1) + p58_country_weight(i) Policy country weight per region (1) + i58_rewetting_exo(t,j) Cellular share of drained peatland in reference period to be rewetted (1) + i58_intact_protection_exo(j) Cellular share of intact peatland that should be protected (1) +; + +equations + 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_peatlandMan2(j,manPeat58) Contraint for managed peatland area (mio. ha) + q58_rewetting_exo(j,manPeat58) Constraint for exogenous peatland rewetting (mio. ha) + q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD17MER per yr) + q58_peatland_cost_annuity(j,cost58) Annuity costs for peatland conversion in the current timestep (mio. USD17MER 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_peatlandReductionLimit(j) Annual limit for peatland rewetting (mio. ha 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 (mio. USD17MER per yr) + v58_peatland_emis(j,land58,emis58) Detailed GHG peatland GHG emissions (Tg per yr) +; + +positive variables + v58_peatland(j,land58) Peatland area (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_balance(j,manPeat58) Technical balance term for peatland scaling factor (1) + v58_balance2(j,manPeat58) Technical balance term for peatland scaling factor (1) + v58_peatland_cost_annuity(j,cost58) Annuity costs for peatland conversion in the current timestep (mio. USD17MER 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 (mio. USD17MER 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_balance(t,j,manPeat58,type) Technical balance term for peatland scaling factor (1) + ov58_balance2(t,j,manPeat58,type) Technical balance term for peatland scaling factor (1) + ov58_peatland_cost_annuity(t,j,cost58,type) Annuity costs for peatland conversion in the current timestep (mio. USD17MER 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_peatlandMan2(t,j,manPeat58,type) Contraint for managed peatland area (mio. ha) + oq58_rewetting_exo(t,j,manPeat58,type) Constraint for exogenous peatland rewetting (mio. ha) + oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD17MER per yr) + oq58_peatland_cost_annuity(t,j,cost58,type) Annuity costs for peatland conversion in the current timestep (mio. USD17MER 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_peatlandReductionLimit(t,j,type) Annual limit for peatland rewetting (mio. ha per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms new file mode 100644 index 0000000000..223924c5a1 --- /dev/null +++ b/modules/58_peatland/v2/equations.gms @@ -0,0 +1,94 @@ +*** | (C) 2008-2025 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 + +*' Constraint for constant total peatland area over time: + + q58_peatland(j2) .. + sum(land58, v58_peatland(j2,land58)) =e= sum(land58, pc58_peatland(j2,land58)); + +*' Peatland area change: + + 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= m58_LandMerge(vm_land,vm_land_forestry,"j2"); + +*' Managed land area expansion and reduction: + + q58_manLandExp(j2,manPeat58) .. + v58_manLandExp(j2,manPeat58) =e= m58_LandMerge(vm_landexpansion,vm_landexpansion_forestry,"j2"); + + q58_manLandRed(j2,manPeat58) .. + v58_manLandRed(j2,manPeat58) =e= m58_LandMerge(vm_landreduction,vm_landreduction_forestry,"j2"); + +*' Future peatland dynamics (`v58_peatland`) for drained peatlands used as cropland, pasture or forestry (`manPeat58`) +*' depend on changes in managed agricultural and forestry land (`v58_manLandExp`, `v58_manLandRed`), +*' multiplied with corresponding scaling factors for expansion (`p58_scalingFactorExp`) and reduction (`p58_scalingFactorRed`). +*' Both scaling factors are time-dynamic, i.e. the scaling factors vary depending on changes in drained peatland and managed land. +*' The scaling factor for expansion reflects the ratio of available area for peatland drainage and managed land expansion, +*' based on the assumption that the expansion of drained peatland is proportional to the expansion of managed land. +*' The scaling factor for reduction reflects the ratio of drained peatland and total peatland area, +*' based on the assumption that the likelihood of peatland rewetting increases with a higher share of +*' drained peatland over total peatland area. +*' Therefore, the scaling factor for peatland reduction increases with an increasing share of drained peatland +*' and decreases with a decreasing share of drained peatland. +*' In case managed land remains unchanged, also drained peatland remains unchanged. + + q58_peatlandMan(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatland(j2,manPeat58) =e= + pc58_peatland(j2,manPeat58) + + v58_manLandExp(j2,manPeat58) * sum(ct, p58_scalingFactorExp(ct,j2)) - v58_balance(j2,manPeat58) + - v58_manLandRed(j2,manPeat58) * sum(ct, p58_scalingFactorRed(ct,j2,manPeat58)) + v58_balance2(j2,manPeat58); + +*' Annual limit for peatland rewetting based on `s58_annual_rewetting_limit`. + + q58_peatlandReductionLimit(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatlandChange(j2,"rewetted") / m_timestep_length =l= + s58_annual_rewetting_limit * sum(drained58, pc58_peatland(j2,drained58)); + +*' Drained peatland used for agriculture and forestry cannot exceed corresponding managed land. + + q58_peatlandMan2(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatland(j2,manPeat58) =l= v58_manLand(j2,manPeat58); + +*' Constraint for optional exogenous peatland rewetting + + q58_rewetting_exo(j2,manPeat58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatland(j2,"rewetted") =g= + sum(drained58, p58_peatland_ref(j2,drained58)) * sum(ct, i58_rewetting_exo(ct,j2)); + +*' Costs for peatland degradation and rewetting + + q58_peatland_cost(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_drain_recur(ct)) + + sum(manPeat58, v58_balance(j2,manPeat58)+v58_balance2(j2,manPeat58)) * s58_balance_penalty; + + q58_peatland_cost_annuity(j2,cost58) .. + v58_peatland_cost_annuity(j2,cost58) =g= + sum(map_cost58(intact58,cost58), v58_peatlandChange(j2,intact58)) * sum(ct, i58_cost_onetime(ct,cost58)) + * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Detailed peatland GHG emissions + + q58_peatland_emis_detail(j2,land58,emis58) .. + v58_peatland_emis(j2,land58,emis58) =e= + sum(clcl58, v58_peatland(j2,land58) * + p58_mapping_cell_climate(j2,clcl58) * f58_ipcc_wetland_ef(clcl58,land58,emis58)); + +*' Aggregation of detailed peatland GHG emissions for interface `vm_emissions_reg` + + q58_peatland_emis(i2,poll58) .. + vm_emissions_reg(i2,"peatland",poll58) =e= + sum((cell(i2,j2),land58,emisSub58_to_poll58(emisSub58,poll58)), + v58_peatland_emis(j2,land58,emisSub58)); diff --git a/modules/58_peatland/v2/input.gms b/modules/58_peatland/v2/input.gms new file mode 100644 index 0000000000..511a75999e --- /dev/null +++ b/modules/58_peatland/v2/input.gms @@ -0,0 +1,78 @@ +*** | (C) 2008-2025 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 (USD17MER per ha) / 37 / + s58_cost_rewet_onetime One-time costs for peatland rewetting (USD17MER per ha) / 1230 / + s58_cost_drain_recur Recurring costs for drained and managed peatlands (USD17MER per ha) / 0 / + s58_cost_drain_intact_onetime One-time costs for drainage of intact peatland (USD17MER per ha) / 1230 / + s58_cost_drain_rewet_onetime One-time costs for drainage of rewetted peatland (USD17MER 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 / + s58_balance_penalty Penalty for technical peatland balance term (USD17MER) / 1e+06 / + s58_rewetting_exo Switch for exogenous peatland rewetting for selected countries (1) / 0 / + s58_rewetting_exo_noselect Switch for exogenous peatland rewetting for all other countries (1) / 0 / + s58_rewet_exo_start_year Start year for exogenous peatland rewetting (1) / 2025 / + s58_rewet_exo_target_year Target year for exogenous peatland rewetting (1) / 2050 / + s58_rewet_exo_start_value Start value for exogenous peatland rewetting as share of drained peatland in reference period (1) / 0 / + s58_rewet_exo_target_value Target value for exogenous peatland rewetting as share of drained peatland in reference period (1) / 0.5 / + s58_intact_prot_exo Switch for exogenous protection of intact peatland for selected countries (1) / 0 / + s58_intact_prot_exo_noselect Switch for exogenous protection of intact peatland for all other countries (1) / 0 / + s58_annual_rewetting_limit Share of drained peatland that can be rewetted per year (1) / 0.02 / +; + +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries58(iso) countries to be affected by exogenous peatland rewetting + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +*Peatland area based on Global Peatland Map 2.0 and Global Peatland Database +table f58_peatland_area(j,land58) Peatland area (mio. ha) +$ondelim +$include "./modules/58_peatland/input/f58_peatland_area.cs3" +$offdelim +; + +*Peatland area based on Global Peatland Map 2.0 and Global Peatland Database +table f58_peatland_area_iso(iso,land58) Peatland area (mio. ha) +$ondelim +$include "./modules/58_peatland/input/f58_peatland_area_iso.cs3" +$offdelim +; + +*Wetland GHG emission factors based on IPCC Wetlands 2014 and Tiemeyer et al. 2020 +table f58_ipcc_wetland_ef(clcl58,land58,emis58) Wetland emission factors (Tg per ha per yr) +$ondelim +$include "./modules/58_peatland/input/f58_ipcc_wetland_ef2.cs3" +$offdelim +; diff --git a/modules/58_peatland/v2/postsolve.gms b/modules/58_peatland/v2/postsolve.gms new file mode 100644 index 0000000000..cd55943756 --- /dev/null +++ b/modules/58_peatland/v2/postsolve.gms @@ -0,0 +1,104 @@ +*** | (C) 2008-2025 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 + +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_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_balance(t,j,manPeat58,"marginal") = v58_balance.m(j,manPeat58); + ov58_balance2(t,j,manPeat58,"marginal") = v58_balance2.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_peatlandMan2(t,j,manPeat58,"marginal") = q58_peatlandMan2.m(j,manPeat58); + oq58_rewetting_exo(t,j,manPeat58,"marginal") = q58_rewetting_exo.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); + oq58_peatlandReductionLimit(t,j,"marginal") = q58_peatlandReductionLimit.m(j); + 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_balance(t,j,manPeat58,"level") = v58_balance.l(j,manPeat58); + ov58_balance2(t,j,manPeat58,"level") = v58_balance2.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_peatlandMan2(t,j,manPeat58,"level") = q58_peatlandMan2.l(j,manPeat58); + oq58_rewetting_exo(t,j,manPeat58,"level") = q58_rewetting_exo.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); + oq58_peatlandReductionLimit(t,j,"level") = q58_peatlandReductionLimit.l(j); + 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_balance(t,j,manPeat58,"upper") = v58_balance.up(j,manPeat58); + ov58_balance2(t,j,manPeat58,"upper") = v58_balance2.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_peatlandMan2(t,j,manPeat58,"upper") = q58_peatlandMan2.up(j,manPeat58); + oq58_rewetting_exo(t,j,manPeat58,"upper") = q58_rewetting_exo.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); + oq58_peatlandReductionLimit(t,j,"upper") = q58_peatlandReductionLimit.up(j); + 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_balance(t,j,manPeat58,"lower") = v58_balance.lo(j,manPeat58); + ov58_balance2(t,j,manPeat58,"lower") = v58_balance2.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_peatlandMan2(t,j,manPeat58,"lower") = q58_peatlandMan2.lo(j,manPeat58); + oq58_rewetting_exo(t,j,manPeat58,"lower") = q58_rewetting_exo.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); + oq58_peatlandReductionLimit(t,j,"lower") = q58_peatlandReductionLimit.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms new file mode 100644 index 0000000000..bcc59ad6f0 --- /dev/null +++ b/modules/58_peatland/v2/preloop.gms @@ -0,0 +1,43 @@ +*** | (C) 2008-2025 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 + +* linear fader for exogenous peatland rewetting +m_linear_time_interpol(i58_peatland_rewetting_fader,s58_rewet_exo_start_year,s58_rewet_exo_target_year,s58_rewet_exo_start_value,s58_rewet_exo_target_value); + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p58_country_switch(iso) = 0; +p58_country_switch(policy_countries58) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by total peatland area. +p58_country_weight(i) = 0; +p58_country_weight(i)$(sum(i_to_iso(i,iso), sum(land58, f58_peatland_area_iso(iso,land58))) > 0) = sum(i_to_iso(i,iso), p58_country_switch(iso) * sum(land58, f58_peatland_area_iso(iso,land58))) + / sum(i_to_iso(i,iso), sum(land58, f58_peatland_area_iso(iso,land58))); + +* construct exogenous peatland rewetting scenario +i58_rewetting_exo(t,j) = i58_peatland_rewetting_fader(t) * + (s58_rewetting_exo * sum(cell(i,j), p58_country_weight(i)) + + s58_rewetting_exo_noselect * sum(cell(i,j), 1-p58_country_weight(i))); + +i58_intact_protection_exo(j) = s58_intact_prot_exo * sum(cell(i,j), p58_country_weight(i)) + + s58_intact_prot_exo_noselect * sum(cell(i,j), 1-p58_country_weight(i)); + +* fix uncontrolled pollutants to zero +vm_emissions_reg.fx(i,"peatland",pollutants) = 0; +vm_emissions_reg.lo(i,"peatland",poll58) = -Inf; +vm_emissions_reg.up(i,"peatland",poll58) = Inf; + +* Mapping between detailed and simple climate classes +p58_mapping_cell_climate(j,clcl58) = sum(clcl_mapping(clcl,clcl58),pm_climate_class(j,clcl)); + +* Initialization of peatland area +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); diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms new file mode 100644 index 0000000000..090d2783ab --- /dev/null +++ b/modules/58_peatland/v2/presolve.gms @@ -0,0 +1,77 @@ +*** | (C) 2008-2025 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 + + +if (m_year(t) <= s58_fix_peatland, +* Managed land area + 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)); +* 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 + pc58_peatland(j,"peatExtract") = f58_peatland_area(j,"peatExtract"); +* Intact peatland area + pc58_peatland(j,"intact") = f58_peatland_area(j,"intact"); + +* Peatland area is fixed to `pc58_peatland` until the year given by s58_fix_peatland + v58_peatland.fx(j,land58) = pc58_peatland(j,land58); + v58_balance.fx(j,manPeat58) = 0; + v58_balance2.fx(j,manPeat58) = 0; + + i58_cost_rewet_recur(t) = 0; + i58_cost_drain_recur(t) = 0; + i58_cost_onetime(t,cost58) = 0; + +* save area in reference period + p58_peatland_ref(j,land58)$(m_year(t) = s58_fix_peatland) = pc58_peatland(j,land58); +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,drained58) = sum(land58, pc58_peatland(j,land58)); + v58_peatland.up(j,"rewetted") = s58_rewetting_switch; + v58_peatland.lo(j,"intact") = pc58_peatland(j,"intact") * i58_intact_protection_exo(j); + v58_peatland.up(j,"intact") = pc58_peatland(j,"intact"); + v58_peatland.fx(j,"peatExtract") = pc58_peatland(j,"peatExtract"); + v58_balance.lo(j,manPeat58) = 0; + v58_balance.up(j,manPeat58) = Inf; + v58_balance2.lo(j,manPeat58) = 0; + v58_balance2.up(j,manPeat58) = Inf; + + i58_cost_rewet_recur(t) = s58_cost_rewet_recur; + i58_cost_drain_recur(t) = s58_cost_drain_recur; + i58_cost_onetime(t,"drain_intact") = -s58_cost_drain_intact_onetime; + i58_cost_onetime(t,"drain_rewetted") = -s58_cost_drain_rewet_onetime; + i58_cost_onetime(t,"rewetted") = s58_cost_rewet_onetime; +); + +*' @code +*' Peatland scaling factor for expansion: (totalPeatland - manPeatland) / (totalLand - manLand) +*' +*' * p58_availPeatlandExp = totalPeatland - manPeatland +*' * p58_availLandExp = totalLand - manLand + +p58_availPeatlandExp(t,j) = sum(land58, pc58_peatland(j,land58)) - sum(manPeat58, pc58_peatland(j,manPeat58)); +p58_availLandExp(t,j) = sum(land, pcm_land(j,land)) - sum(manPeat58, pc58_manLand(j,manPeat58)); + +p58_scalingFactorExp(t,j) = + (p58_availPeatlandExp(t,j) / p58_availLandExp(t,j)) + $(p58_availPeatlandExp(t,j) > 1e-4 AND p58_availLandExp(t,j) > 1e-4) + + 0$(p58_availPeatlandExp(t,j) <= 1e-4 OR p58_availLandExp(t,j) <= 1e-4); +p58_scalingFactorExp(t,j)$(p58_scalingFactorExp(t,j) > 1) = 1; + +*' Peatland scaling factor for reduction: manPeatland / totalPeatland + +p58_scalingFactorRed(t,j,manPeat58) = + (pc58_peatland(j,manPeat58) / sum(land58, pc58_peatland(j,land58))) + $(pc58_peatland(j,manPeat58) > 1e-4 AND sum(land58, pc58_peatland(j,land58)) > 1e-4) + + 0$(pc58_peatland(j,manPeat58) <= 1e-4 OR sum(land58, pc58_peatland(j,land58)) <= 1e-4); +p58_scalingFactorRed(t,j,manPeat58)$(p58_scalingFactorRed(t,j,manPeat58) > 1) = 1; + +*' @stop diff --git a/modules/58_peatland/v2/realization.gms b/modules/58_peatland/v2/realization.gms new file mode 100644 index 0000000000..0b34536e8f --- /dev/null +++ b/modules/58_peatland/v2/realization.gms @@ -0,0 +1,42 @@ +*** | (C) 2008-2025 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 based on the +*' 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 2022. +*' 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. +*' Peatland GHG emission factors for temperate climates are based on more recent estimates from @tiemeyer_peatland_2020. +*' +*' Assumed rules for changes in peatland area: +*' +*' * Sum over total peatland area (degraded, intact, rewetted) is assumed constant. +*' * 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 and intact peatland have the same GHG emission factors, which avoids that intact is converted to rewetted peatland area. +*' +*' @stop + + +*' +*' @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) ############################## +$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%" == "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" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/58_peatland/v2/sets.gms b/modules/58_peatland/v2/sets.gms new file mode 100644 index 0000000000..a892c39c5d --- /dev/null +++ b/modules/58_peatland/v2/sets.gms @@ -0,0 +1,85 @@ +*** | (C) 2008-2025 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 + + land58 Peatland categories + / intact, crop, past, forestry, peatExtract, unused, rewetted / + + drained58(land58) Drained peatland categories + / crop, past, forestry, unused / + + manPeat58(land58) Drained and managed peatland categories + / crop, past, forestry / + + intact58(land58) intact and rewetted peatland categories + / intact, rewetted / + + cost58 annunity cost categories + / drain_intact, drain_rewetted, rewetted / + + map_cost58(intact58,cost58) Mapping between intact58 and cost58 + / intact .(drain_intact) + rewetted .(drain_rewetted) + rewetted .(rewetted) / + + emis58 Wetland emission types + / co2, doc, ch4, n2o / + + emisSub58(emis58) Wetland emission types + / co2, doc, 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) + doc .(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 (manPeat58,manPeat58_alias); diff --git a/modules/59_som/cellpool_aug16/declarations.gms b/modules/59_som/cellpool_aug16/declarations.gms deleted file mode 100644 index fec6f3a6e7..0000000000 --- a/modules/59_som/cellpool_aug16/declarations.gms +++ /dev/null @@ -1,59 +0,0 @@ -*** | (C) 2008-2019 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 - i59_lossrate(t) Rate of loss or recovery of SOM pool per timestep (1) - p59_carbon_density(t_all,j,pools59) Carbon density of a hectare of land (tC per ha) - i59_tillage_share(i,tillage59) Share of land under tillage class (1) - i59_input_share(i,inputs59) Share of land under input class (1) - i59_cratio(j,kcr) Ratio of carbon density of land relative to natural vegetaion (1) - p59_som_pool(j,pools59) Actual C pool (mio. tC) -; - -equations - q59_som_target_cropland(j) Estimates the long-term target state of cropland (mio. tC) - q59_som_target_noncropland(j) Estimates the long-term target state of noncropland (mio. tC) - q59_som_transfer_to_cropland(j) Estimates the transfer of carbon pools due to land conversion (mio. tC) - q59_som_pool_cropland(j) Actual C pool in croplands (mio. tC) - q59_som_pool_noncropland(j) Actual C pool in non-croplands (mio. tC) - q59_nr_som(j) Soil organic matter loss (Tg N per yr) - q59_crop_diff(j) Cropland difference (mio. ha) - q59_crop_diff_constraint(i) Cropland difference constraint (mio. USD05MER per yr) -; - -positive variables - v59_som_target(j,pools59) Long-term target state of C pool (mio. tC) - v59_som_pool(j,pools59) Soil organic matter pool (mio. tC) - v59_crop_expansion(j) Crop land expansion (mio. ha) - v59_crop_reduction(j) Land reduction (mio. ha) -; - -variables - v59_som_transfer_to_cropland(j) Transfer of SOM from other land to cropland (mio. tC) - vm_nr_som(j) Release of soil organic matter (Tg N per yr) - vm_costs_overrate_cropdiff(i) Punishment costs for overrated cropland difference (mio. USD05MER per yr) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov59_som_target(t,j,pools59,type) Long-term target state of C pool (mio. tC) - ov59_som_pool(t,j,pools59,type) Soil organic matter pool (mio. tC) - ov59_crop_expansion(t,j,type) Crop land expansion (mio. ha) - ov59_crop_reduction(t,j,type) Land reduction (mio. ha) - ov59_som_transfer_to_cropland(t,j,type) Transfer of SOM from other land to cropland (mio. tC) - ov_nr_som(t,j,type) Release of soil organic matter (Tg N per yr) - ov_costs_overrate_cropdiff(t,i,type) Punishment costs for overrated cropland difference (mio. USD05MER per yr) - oq59_som_target_cropland(t,j,type) Estimates the long-term target state of cropland (mio. tC) - oq59_som_target_noncropland(t,j,type) Estimates the long-term target state of noncropland (mio. tC) - oq59_som_transfer_to_cropland(t,j,type) Estimates the transfer of carbon pools due to land conversion (mio. tC) - oq59_som_pool_cropland(t,j,type) Actual C pool in croplands (mio. tC) - oq59_som_pool_noncropland(t,j,type) Actual C pool in non-croplands (mio. tC) - oq59_nr_som(t,j,type) Soil organic matter loss (Tg N per yr) - oq59_crop_diff(t,j,type) Cropland difference (mio. ha) - oq59_crop_diff_constraint(t,i,type) Cropland difference constraint (mio. USD05MER per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/59_som/cellpool_aug16/equations.gms b/modules/59_som/cellpool_aug16/equations.gms deleted file mode 100644 index d8ae7d1cbf..0000000000 --- a/modules/59_som/cellpool_aug16/equations.gms +++ /dev/null @@ -1,87 +0,0 @@ -*** | (C) 2008-2019 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 -*' For every cell a new equilibrium value for the soil organic carbon -*' pool on cropland as the sum over all crop types is calculated - - -q59_som_target_cropland(j2) .. - v59_som_target(j2,"cropland") - =e= sum((kcr,w), vm_area(j2,kcr,w) * i59_cratio(j2,kcr)) * sum(ct,f59_topsoilc_density(ct,j2)) - ; -*' as well as for all non cropland given by - -q59_som_target_noncropland(j2) .. - v59_som_target(j2,"noncropland") - =e= sum((noncropland59), vm_land(j2,noncropland59)) * sum(ct,f59_topsoilc_density(ct,j2)) - ; - -*' Depending on the setting of `c59_som_scenario `climate impacts (`cc`) are taken into account or not (`nocc`). -*' For a static climate `f59_topsoilc_density` is set to the value of 1995 within the input of the module realization. - -*' To account for the transfer of carbon rich soils from natural vegetation to cropland as well as the transfer of -*' depleted soils from cropland to regrowing natural land, the cropland expansion and reduction of each cell is calculated via - -q59_crop_diff(j2) .. - - v59_crop_reduction(j2) - v59_crop_expansion(j2) - =e= pcm_land(j2,"crop") - vm_land(j2,"crop") - ; - -*' The following nonlinear constraint - -q59_crop_diff_constraint(i2) .. - vm_costs_overrate_cropdiff(i2) - =e= s59_punish_cropdiff - * sum(cell(i2,j2),v59_crop_reduction(j2)*v59_crop_expansion(j2)) - ; - -*' ensures that no extra cropland reduction and expansion at the same time is happening. Note that this nonlinear realization -*' needs two to three times longer runtime and is thus by default not switch on. - -*' The actually carbon transfer from cropland as well as to cropland soils is then given by - -q59_som_transfer_to_cropland(j2) .. - v59_som_transfer_to_cropland(j2) - =e= sum(ct, - v59_crop_expansion(j2) * p59_carbon_density(ct,j2,"noncropland") - - v59_crop_reduction(j2) * p59_carbon_density(ct,j2,"cropland")) - ; - -*' To get the current size of the soil organic carbon pool, the pool of the previous timestep corrected by the carbon transfer -*' is developing into the direction of the above calculated target values taken the timestep depending lossrate into account by - -q59_som_pool_cropland(j2) .. - v59_som_pool(j2,"cropland") - =e= sum(ct, i59_lossrate(ct)) - * (v59_som_target(j2,"cropland") - - (p59_som_pool(j2,"cropland") + v59_som_transfer_to_cropland(j2))) - + (p59_som_pool(j2,"cropland") + v59_som_transfer_to_cropland(j2)) - ; - -*' and - -q59_som_pool_noncropland(j2) .. - v59_som_pool(j2,"noncropland") - =e= sum(ct,i59_lossrate(ct)) - * (v59_som_target(j2,"noncropland") - - (p59_som_pool(j2,"noncropland") - v59_som_transfer_to_cropland(j2))) - + (p59_som_pool(j2,"noncropland") - v59_som_transfer_to_cropland(j2)) - ; - -*' The annual nitrogen release (or sink) for cropland soils is than calculated by the loss of soil organic carbon given by - -q59_nr_som(j2) .. - vm_nr_som(j2) - =e= sum(ct,i59_lossrate(ct))/m_timestep_length*1/15 - * (p59_som_pool(j2,"cropland") - + v59_som_transfer_to_cropland(j2) - v59_som_target(j2,"cropland")) - ; - -*' with the carbon to nitrogen ratio of soils assumed to be 15:1. diff --git a/modules/59_som/cellpool_aug16/input.gms b/modules/59_som/cellpool_aug16/input.gms deleted file mode 100644 index 4348da3570..0000000000 --- a/modules/59_som/cellpool_aug16/input.gms +++ /dev/null @@ -1,51 +0,0 @@ -*** | (C) 2008-2019 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 - s59_punish_cropdiff Punishment costs per croparea squared (USD05MER per mio. per ha^2) / 10000 / -; - -table f59_cratio_landuse(climate59,kcr) Ratio of soil carbon relative to potential natural vegetation soil carbon for different landuse (1) -$ondelim -$include "./modules/59_som/cellpool_aug16/input/f59_ch5_F_LU.csv" -$offdelim -; - -table f59_cratio_tillage(climate59,tillage59) Ratio of soil carbon relative to potential natural vegetation soil carbon for different soil management (1) -$ondelim -$include "./modules/59_som/cellpool_aug16/input/f59_ch5_F_MG.csv" -$offdelim -; - -table f59_cratio_inputs(climate59,inputs59) Ratio of soil carbon relative to potential natural vegetation soil carbon for different input intensity (1) -$ondelim -$include "./modules/59_som/cellpool_aug16/input/f59_ch5_F_I.csv" -$offdelim -; - -table f59_som_initialisation_pools(t_all,j, pools59) Initialisation pools for soil organic carbon (mio. tC) -$ondelim -$include "./modules/59_som/cellpool_aug16/input/f59_som_initialisation_pools.cs3" -$offdelim -; - -$setglobal c59_som_scenario nocc -* options: cc (climate change) -* nocc (no climate change) - -parameters f59_topsoilc_density(t_all,j) LPJ topsoil carbon density for natural vegetation (tC per ha) -/ -$ondelim -$include "./modules/59_som/cellpool_aug16/input/lpj_carbon_topsoil.cs2" -$offdelim -/ -; -$if "%c59_som_scenario%" == "nocc" f59_topsoilc_density(t_all,j) = f59_topsoilc_density("y1995",j); -m_fillmissingyears(f59_topsoilc_density,"j"); - - - diff --git a/modules/59_som/cellpool_aug16/input/files b/modules/59_som/cellpool_aug16/input/files deleted file mode 100644 index 772f860fab..0000000000 --- a/modules/59_som/cellpool_aug16/input/files +++ /dev/null @@ -1,6 +0,0 @@ -* list of files that are required here -f59_ch5_F_I.csv -f59_ch5_F_LU.csv -f59_ch5_F_MG.csv -f59_som_initialisation_pools.cs3 -lpj_carbon_topsoil.cs2 diff --git a/modules/59_som/cellpool_aug16/postsolve.gms b/modules/59_som/cellpool_aug16/postsolve.gms deleted file mode 100644 index ec2c167f37..0000000000 --- a/modules/59_som/cellpool_aug16/postsolve.gms +++ /dev/null @@ -1,73 +0,0 @@ -*** | (C) 2008-2019 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 - -p59_som_pool(j,pools59) = v59_som_pool.l(j,pools59); - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov59_som_target(t,j,pools59,"marginal") = v59_som_target.m(j,pools59); - ov59_som_pool(t,j,pools59,"marginal") = v59_som_pool.m(j,pools59); - ov59_crop_expansion(t,j,"marginal") = v59_crop_expansion.m(j); - ov59_crop_reduction(t,j,"marginal") = v59_crop_reduction.m(j); - ov59_som_transfer_to_cropland(t,j,"marginal") = v59_som_transfer_to_cropland.m(j); - ov_nr_som(t,j,"marginal") = vm_nr_som.m(j); - ov_costs_overrate_cropdiff(t,i,"marginal") = vm_costs_overrate_cropdiff.m(i); - oq59_som_target_cropland(t,j,"marginal") = q59_som_target_cropland.m(j); - oq59_som_target_noncropland(t,j,"marginal") = q59_som_target_noncropland.m(j); - oq59_som_transfer_to_cropland(t,j,"marginal") = q59_som_transfer_to_cropland.m(j); - oq59_som_pool_cropland(t,j,"marginal") = q59_som_pool_cropland.m(j); - oq59_som_pool_noncropland(t,j,"marginal") = q59_som_pool_noncropland.m(j); - oq59_nr_som(t,j,"marginal") = q59_nr_som.m(j); - oq59_crop_diff(t,j,"marginal") = q59_crop_diff.m(j); - oq59_crop_diff_constraint(t,i,"marginal") = q59_crop_diff_constraint.m(i); - ov59_som_target(t,j,pools59,"level") = v59_som_target.l(j,pools59); - ov59_som_pool(t,j,pools59,"level") = v59_som_pool.l(j,pools59); - ov59_crop_expansion(t,j,"level") = v59_crop_expansion.l(j); - ov59_crop_reduction(t,j,"level") = v59_crop_reduction.l(j); - ov59_som_transfer_to_cropland(t,j,"level") = v59_som_transfer_to_cropland.l(j); - ov_nr_som(t,j,"level") = vm_nr_som.l(j); - ov_costs_overrate_cropdiff(t,i,"level") = vm_costs_overrate_cropdiff.l(i); - oq59_som_target_cropland(t,j,"level") = q59_som_target_cropland.l(j); - oq59_som_target_noncropland(t,j,"level") = q59_som_target_noncropland.l(j); - oq59_som_transfer_to_cropland(t,j,"level") = q59_som_transfer_to_cropland.l(j); - oq59_som_pool_cropland(t,j,"level") = q59_som_pool_cropland.l(j); - oq59_som_pool_noncropland(t,j,"level") = q59_som_pool_noncropland.l(j); - oq59_nr_som(t,j,"level") = q59_nr_som.l(j); - oq59_crop_diff(t,j,"level") = q59_crop_diff.l(j); - oq59_crop_diff_constraint(t,i,"level") = q59_crop_diff_constraint.l(i); - ov59_som_target(t,j,pools59,"upper") = v59_som_target.up(j,pools59); - ov59_som_pool(t,j,pools59,"upper") = v59_som_pool.up(j,pools59); - ov59_crop_expansion(t,j,"upper") = v59_crop_expansion.up(j); - ov59_crop_reduction(t,j,"upper") = v59_crop_reduction.up(j); - ov59_som_transfer_to_cropland(t,j,"upper") = v59_som_transfer_to_cropland.up(j); - ov_nr_som(t,j,"upper") = vm_nr_som.up(j); - ov_costs_overrate_cropdiff(t,i,"upper") = vm_costs_overrate_cropdiff.up(i); - oq59_som_target_cropland(t,j,"upper") = q59_som_target_cropland.up(j); - oq59_som_target_noncropland(t,j,"upper") = q59_som_target_noncropland.up(j); - oq59_som_transfer_to_cropland(t,j,"upper") = q59_som_transfer_to_cropland.up(j); - oq59_som_pool_cropland(t,j,"upper") = q59_som_pool_cropland.up(j); - oq59_som_pool_noncropland(t,j,"upper") = q59_som_pool_noncropland.up(j); - oq59_nr_som(t,j,"upper") = q59_nr_som.up(j); - oq59_crop_diff(t,j,"upper") = q59_crop_diff.up(j); - oq59_crop_diff_constraint(t,i,"upper") = q59_crop_diff_constraint.up(i); - ov59_som_target(t,j,pools59,"lower") = v59_som_target.lo(j,pools59); - ov59_som_pool(t,j,pools59,"lower") = v59_som_pool.lo(j,pools59); - ov59_crop_expansion(t,j,"lower") = v59_crop_expansion.lo(j); - ov59_crop_reduction(t,j,"lower") = v59_crop_reduction.lo(j); - ov59_som_transfer_to_cropland(t,j,"lower") = v59_som_transfer_to_cropland.lo(j); - ov_nr_som(t,j,"lower") = vm_nr_som.lo(j); - ov_costs_overrate_cropdiff(t,i,"lower") = vm_costs_overrate_cropdiff.lo(i); - oq59_som_target_cropland(t,j,"lower") = q59_som_target_cropland.lo(j); - oq59_som_target_noncropland(t,j,"lower") = q59_som_target_noncropland.lo(j); - oq59_som_transfer_to_cropland(t,j,"lower") = q59_som_transfer_to_cropland.lo(j); - oq59_som_pool_cropland(t,j,"lower") = q59_som_pool_cropland.lo(j); - oq59_som_pool_noncropland(t,j,"lower") = q59_som_pool_noncropland.lo(j); - oq59_nr_som(t,j,"lower") = q59_nr_som.lo(j); - oq59_crop_diff(t,j,"lower") = q59_crop_diff.lo(j); - oq59_crop_diff_constraint(t,i,"lower") = q59_crop_diff_constraint.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/59_som/cellpool_aug16/preloop.gms b/modules/59_som/cellpool_aug16/preloop.gms deleted file mode 100644 index d9bc2cd169..0000000000 --- a/modules/59_som/cellpool_aug16/preloop.gms +++ /dev/null @@ -1,39 +0,0 @@ -*** | (C) 2008-2019 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 - -*' @code The cellpool_aug16 calculates the carbon loss with the assumption -*' of a lossrate of 15% per year resulting in 44% in 5 years, 80% in 10 years -*' and 96% in 20 years. The lossrate for a given timestep is than calculate by - -i59_lossrate(t)=1-0.85**m_yeardiff(t); - -*' The stock change factors are implemented for cropland subsystems divided by -*' MAgPIE crop types as well as potentially for tillage and input management. -*' So far it just tracks the subsystem component due to missing data for the -*' other categories. They are set to the following default values: - -i59_tillage_share(i,tillage59)=0; -i59_tillage_share(i,"full_tillage")=1; -i59_input_share(i,inputs59)=0; -i59_input_share(i,"medium_input")=1; - -*' The stock change factor in each cell for every crop type also takes into account -*' the climate variability of these factors and is therefor given by: - -i59_cratio(j,kcr) = sum((cell(i,j),tillage59,inputs59,climate59), - sum(clcl_climate59(clcl,climate59),pm_climate_class(j,clcl)) - * f59_cratio_landuse(climate59,kcr) - * i59_tillage_share(i,tillage59) - * f59_cratio_tillage(climate59,tillage59) - * i59_input_share(i,inputs59) - * f59_cratio_inputs(climate59,inputs59)); - -*' @stop - -p59_som_pool(j,pools59) = f59_som_initialisation_pools("y1995",j, pools59); - -p59_carbon_density(t,j,pools59)=0; diff --git a/modules/59_som/cellpool_aug16/presolve.gms b/modules/59_som/cellpool_aug16/presolve.gms deleted file mode 100644 index 69d548462d..0000000000 --- a/modules/59_som/cellpool_aug16/presolve.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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 - -p59_carbon_density(t,j,"noncropland")$(sum(noncropland59,pcm_land(j,noncropland59))>0) = p59_som_pool(j,"noncropland")/sum(noncropland59,pcm_land(j,noncropland59)); -p59_carbon_density(t,j,"cropland")$(pcm_land(j,"crop")>0)= p59_som_pool(j,"cropland") / pcm_land(j,"crop"); diff --git a/modules/59_som/cellpool_aug16/realization.gms b/modules/59_som/cellpool_aug16/realization.gms deleted file mode 100644 index cded1bae39..0000000000 --- a/modules/59_som/cellpool_aug16/realization.gms +++ /dev/null @@ -1,29 +0,0 @@ -*** | (C) 2008-2019 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 -*' The cellpool_aug16 realization is built on the IPCC 2006 Guidelines for -*' National Greenhouse Gas Inventories (@ipcc_2006_2006.). It calculates based -*' on the idea of stock change factors regarding the potential natural vegetation -*' the loss of soil carbon due to cropping activities and management. -*' This approach also accounts for the temporal dimension of soil organic carbon change, -*' since it assumes a gradual step of 15% in the direction of the new equilibrium soil -*' organic carbon pool each year. - -*' @authors Benjamin Leon Bodirsky, Kristine Karstens - - - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/59_som/cellpool_aug16/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/59_som/cellpool_aug16/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/59_som/cellpool_aug16/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/59_som/cellpool_aug16/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/59_som/cellpool_aug16/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/59_som/cellpool_aug16/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/59_som/cellpool_aug16/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/59_som/cellpool_aug16/sets.gms b/modules/59_som/cellpool_aug16/sets.gms deleted file mode 100644 index ff71be6ec0..0000000000 --- a/modules/59_som/cellpool_aug16/sets.gms +++ /dev/null @@ -1,59 +0,0 @@ -*** | (C) 2008-2019 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 - -noncropland59(land) Soil carbon conserving landuse types -/past, forestry, primforest, secdforest, urban, other/ - -pools59 Carbon differentiating landuse types -/cropland,noncropland/ - -tillage59 Tillage categories of IPCC -/full_tillage,reduced_tillage,no_tillage/ - -inputs59 Input management categories of IPCC -/low_input,medium_input,high_input_nomanure,high_input_manure/ - -climate59 Climate classes of IPCC 2006 -/temperate_dry,temperate_moist,tropical_dry,tropical_moist/ - -clcl_climate59(clcl,climate59) Climate classification types - / - Af .(tropical_moist) "equatorial fully humid" - Am .(tropical_moist) "equatorial monsoonal" - As .(tropical_moist) "equatorial summer dry" - Aw .(tropical_moist) "equatorial winter dry" - BSh .(tropical_dry) "arid steppe hot arid" - BSk .(temperate_dry) "arid steppe cold arid" - BWh .(tropical_dry) "arid desert hot arid" - BWk .(temperate_dry) "arid desert cold arid" - Cfa .(temperate_moist) "warm temperate fully humid hot summer" - Cfb .(temperate_moist) "warm temperate fully humid warm summer" - Cfc .(temperate_moist) "warm temperate fully humid cool summer" - Csa .(temperate_moist) "warm temperate summer dry hot summer" - Csb .(temperate_moist) "warm temperate summer dry warm summer" - Csc .(temperate_moist) "warm temperate summer dry cool summer" - Cwa .(temperate_moist) "warm temperate winter dry hot summer" - Cwb .(temperate_moist) "warm temperate winter dry warm summer" - Cwc .(temperate_moist) "warm temperate winter dry cool summer" - Dfa .(temperate_moist) "snow fully humid hot summer" - Dfb .(temperate_moist) "snow fully humid warm summer" - Dfc .(temperate_moist) "snow fully humid cool summer" - Dfd .(temperate_moist) "snow fully humid extremely continental" - Dsa .(temperate_moist) "snow summer dry hot summer" - Dsb .(temperate_moist) "snow summer dry warm summer" - Dsc .(temperate_moist) "snow summer dry cool summer" - Dsd .(temperate_dry) "snow summer dry extremely continental" - Dwa .(temperate_moist) "snow winter dry hot summer" - Dwb .(temperate_moist) "snow winter dry warm summer" - Dwc .(temperate_moist) "snow winter dry cool summer" - Dwd .(temperate_dry) "snow winter dry extremely continental" - EF .(temperate_dry) "polar polar frost" - ET .(temperate_moist) "polar polar tundra" - / -; diff --git a/modules/59_som/cellpool_jan23/declarations.gms b/modules/59_som/cellpool_jan23/declarations.gms new file mode 100644 index 0000000000..fd21f13631 --- /dev/null +++ b/modules/59_som/cellpool_jan23/declarations.gms @@ -0,0 +1,65 @@ +*** | (C) 2008-2025 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 + i59_lossrate(t) Rate of loss or recovery of SOM pool per timestep (1) + p59_carbon_density(t_all,j,land) Soil carbon density of a hectare of land (tC per ha) + pc59_carbon_density(j,land) Soil carbon density of a hectare of land between time steps (tC per ha) + i59_tillage_share(i,tillage59) Share of land under tillage class (1) + i59_input_share(i,inputs59) Share of land under input class (1) + i59_scm_target(t,j) Target for the share of cropland under soil carbon managament (1) + i59_cratio(j,kcr,w) Ratio of carbon density of land relative to natural vegetaion (1) + i59_cratio_fallow(j) Ratio of carbon density of fallow land relative to natural vegetation (1) + i59_cratio_treecover Ratio of carbon density of tree cover on cropland relative to natural vegetation (1) + i59_cratio_scm(j) Ratio of carbon density of cropland under soil carbon managament relative to natural vegetation (1) + i59_scm_scenario_fader(t_all) Cropland soil carbon management scenario fader (1) + p59_scm_country_switch(iso) Switch indicating whether country is affected by selected soil carbon management policy (1) + p59_country_weight(i) Soil carbon management policy country weight per region (1) + pc59_som_pool(j,land) Actual C pool (mio. tC) + i59_subsoilc_density(t_all,j) Subsoil carbon density of a hectare of land (tC per ha) + pc59_land_before(j,land) Land area in previous time step (mio. ha) +; + +equations + q59_som_target_cropland(j) Estimates the long-term target state of cropland (mio. tC) + q59_som_target_noncropland(j,noncropland59) Estimates the long-term target state of noncropland (mio. tC) + q59_som_pool(j,land) Actual C pool (mio. tC) + q59_nr_som(j) Soil organic matter loss (Mt N per yr) + q59_nr_som_fertilizer(j) Bound of nitrogen fertilizer of soil organic matter loss (Mt N per yr) + q59_nr_som_fertilizer2(j) Fraction of soil organic matter loss take is taken up by plants (Mt N per yr) + q59_carbon_soil(j,land,stockType) Soil carbon content calculation (mio. tC) + q59_cost_scm(j) Recurring cost for soil carbon management on cropland (mio. USD17MER per yr) +; + +positive variables + v59_som_target(j,land) Long-term target state of C pool (mio. tC) + v59_som_pool(j,land) Soil organic matter pool (mio. tC) + vm_cost_scm(j) Recurring cost for soil carbon management on cropland (mio. USD17MER per yr) +; + +variables + vm_nr_som(j) Release of soil organic matter (Mt N per yr) + vm_nr_som_fertilizer(j) Uptake of soil organic matter from plants (Mt N per yr) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov59_som_target(t,j,land,type) Long-term target state of C pool (mio. tC) + ov59_som_pool(t,j,land,type) Soil organic matter pool (mio. tC) + ov_cost_scm(t,j,type) Recurring cost for soil carbon management on cropland (mio. USD17MER per yr) + ov_nr_som(t,j,type) Release of soil organic matter (Mt N per yr) + ov_nr_som_fertilizer(t,j,type) Uptake of soil organic matter from plants (Mt N per yr) + oq59_som_target_cropland(t,j,type) Estimates the long-term target state of cropland (mio. tC) + oq59_som_target_noncropland(t,j,noncropland59,type) Estimates the long-term target state of noncropland (mio. tC) + oq59_som_pool(t,j,land,type) Actual C pool (mio. tC) + oq59_nr_som(t,j,type) Soil organic matter loss (Mt N per yr) + oq59_nr_som_fertilizer(t,j,type) Bound of nitrogen fertilizer of soil organic matter loss (Mt N per yr) + oq59_nr_som_fertilizer2(t,j,type) Fraction of soil organic matter loss take is taken up by plants (Mt N per yr) + oq59_carbon_soil(t,j,land,stockType,type) Soil carbon content calculation (mio. tC) + oq59_cost_scm(t,j,type) Recurring cost for soil carbon management on cropland (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/59_som/cellpool_jan23/equations.gms b/modules/59_som/cellpool_jan23/equations.gms new file mode 100644 index 0000000000..f9de344608 --- /dev/null +++ b/modules/59_som/cellpool_jan23/equations.gms @@ -0,0 +1,102 @@ +*** | (C) 2008-2025 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 +*' For every cell a new equilibrium value for the soil organic carbon pool on cropland +*' as the sum over all crop types and management regimes is calculated by taking +*' carbon shares (`cratio`) of the natural reference `f59_topsoilc_density` with +*' (1) crop and irrigation type specific assumptions `i59_cratio` for all cropareas, +*' (2) based on the share of dedicated soil carbon managament (SCM) `i59_scm_target` +*' on cropareas an additional increase of `i59_cratio_scm - 1` for these areas, +*' (3+4) dedicated factors `i59_cratio_fallow` and `i59_cratio_treecover` for fallow +*' and treecover areas +*' leading to on overall target stock given by + +q59_som_target_cropland(j2) .. + v59_som_target(j2,"crop") + =e= (sum((kcr,w), vm_area(j2,kcr,w) * i59_cratio(j2,kcr,w)) + + sum((kcr,w,ct), vm_area(j2,kcr,w) * i59_scm_target(ct,j2) * + i59_cratio(j2,kcr,w) * (i59_cratio_scm(j2) - 1)) + + vm_fallow(j2) * i59_cratio_fallow(j2) + + vm_treecover(j2) * i59_cratio_treecover) + * sum(ct,f59_topsoilc_density(ct,j2)); + +*' as well as for all non cropland given by + +q59_som_target_noncropland(j2,noncropland59) .. + v59_som_target(j2,noncropland59) + =e= vm_land(j2,noncropland59) * sum(ct,f59_topsoilc_density(ct,j2)) + ; + +*' Depending on the setting of `c59_som_scenario `climate impacts (`cc`) +*' are taken into account or not (`nocc` and `nocc_hist`). +*' For a static climate `f59_topsoilc_density` is set to the value of 1995 +*' within the input of the module realization. + +*' To get the current size of the soil organic carbon pool, the carbon +*' pool of the previous timestep is developing into the direction of the +*' above calculated target values taken the timestep depending lossrate +*' into account by + +q59_som_pool(j2,land) .. + v59_som_pool(j2,land) + =e= sum(ct,i59_lossrate(ct)) * v59_som_target(j2,land) + + (1 - sum(ct,i59_lossrate(ct))) * + sum((ct,land_from), p59_carbon_density(ct,j2,land_from) * + vm_lu_transitions(j2,land_from,land)) + ; + +*' Note that to account correctly for land-use transitions, carbon densities +*' multiplied by the land-use transition matrix of the current timestep +*' is used. + +*' The soil carbon content is calculated as sum of actual topsoil pool +*' and the reference soil carbon pool of the subsoil + +q59_carbon_soil(j2,land,stockType) .. + vm_carbon_stock(j2, land,"soilc",stockType) + =e= v59_som_pool(j2, land) + vm_land(j2, land) * + sum(ct,i59_subsoilc_density(ct,j2)); + +*' The annual nitrogen release (or sink) for cropland soils is than +*' calculated by the loss of soil organic carbon given by + +q59_nr_som(j2) .. + vm_nr_som(j2) + =e= sum(ct,i59_lossrate(ct))/m_timestep_length*1/15 + * (sum((ct,land_from), p59_carbon_density(ct,j2,land_from) * + vm_lu_transitions(j2,land_from,"crop")) + - v59_som_target(j2,"crop")) + ; +*' with the carbon to nitrogen ratio of soils assumed to be 15:1. + +*' The amount of nitrogen that becomes available to cropland farming is +*' limited by loss of soil organic matter by + +q59_nr_som_fertilizer(j2) .. + vm_nr_som_fertilizer(j2) + =l= + vm_nr_som(j2); + +*' as well as by the amount that crops can take up + +q59_nr_som_fertilizer2(j2) .. + vm_nr_som_fertilizer(j2) + =l= + vm_landexpansion(j2,"crop") * s59_nitrogen_uptake; + +*' Here we assume a maximum of 200 kg on the expanded area. + + +*' Cost for soil carbon management are based on a per hectare value + + q59_cost_scm(j2) .. + vm_cost_scm(j2) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * + sum(ct, i59_scm_target(ct,j2)) * s59_cost_scm_recur; + diff --git a/modules/59_som/cellpool_jan23/input.gms b/modules/59_som/cellpool_jan23/input.gms new file mode 100644 index 0000000000..1a6cfeafef --- /dev/null +++ b/modules/59_som/cellpool_jan23/input.gms @@ -0,0 +1,117 @@ +*** | (C) 2008-2025 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 + s59_nitrogen_uptake Maximum plant available nitrogen from soil organic matter loss (tN per ha) / 0.2 / + s59_fader_functional_form Switch for functional form of faders (1) / 1 / + s59_scm_target Share of soil carbon management on total cropland in target year (1) / 0 / + s59_scm_target_noselect Share of soil carbon management on total cropland in target year (1) / 0 / + s59_scm_scenario_start Soil carbon management scenario start year / 2025 / + s59_scm_scenario_target Soil carbon management scenario target year / 2050 / + s59_cost_scm_recur Soil carbon management recurring cost (USD17MER per ha) / 65 / +; + +*' @code + +*' The implementation of soil carbon management on cropland refers to a diverse set of +*' practices. According to IPCC guidelines 2006, they represent "significantly greater +*' crop residue inputs over medium C input cropping systems due to additional practices, +*' such as production of high residue yielding crops, use of green manures, cover crops, +*' improved vegetated fallows, irrigation, frequent use of perennial grasses in annual +*' crop rotations, but without manure applied." + +*' Literature estimates for the costs of these agronomic practices vary widely. Whereas +*' Smith et al. 2008 estimates the costs of various agronomic practices at around 20 +*' USD06MER (= ~25 USD17MER) per ha, Uludere Aragon et al. 2024 found much higher costs +*' for the individual practice of cover cropping, around 90-115 USD21MER (= ~80-105 +*' USD17MER) per ha. Uludere Aragon et al. 2024 highlights that changes in production +*' costs—due to reduced fertilizer use or increased herbicide costs—as well as yield +*' impacts can either raise or lower net overall farm costs. Given these uncertainties, +*' we adopt an estimated cost of 65 USD17MER per ha, representing the midpoint between +*' 25 and 105 USD17MER. Due to the lack of comprehensive cost data across all regions +*' and the potential for cost changes over time in response to general economic trends, +*' we apply a uniform cost assumption to avoid introducing large initial biases. Costs +*' can be changed in the configuration file via `s59_cost_scm_recur` for using other +*' assumptions. + +*' @stop + +table f59_cratio_landuse(i,climate59_2019,kcr) Ratio of soil carbon relative to potential natural vegetation soil carbon for different landuse (1) +$ondelim +$include "./modules/59_som/cellpool_jan23/input/f59_ch5_F_LU_2019reg.cs3" +$offdelim +; + +table f59_cratio_tillage(climate59,tillage59) Ratio of soil carbon relative to potential natural vegetation soil carbon for different soil management (1) +$ondelim +$include "./modules/59_som/cellpool_jan23/input/f59_ch5_F_MG.csv" +$offdelim +; + +table f59_cratio_inputs(climate59,inputs59) Ratio of soil carbon relative to potential natural vegetation soil carbon for different input intensity (1) +$ondelim +$include "./modules/59_som/cellpool_jan23/input/f59_ch5_F_I.csv" +$offdelim +; + +$setglobal c59_irrigation_scenario on +* options: on (higher carbon sequestration under irrigation) +* off (no carbon sequestration under irrigation) + +table f59_cratio_irrigation(climate59,w,kcr) Ratio of soil carbon relative to potential natural vegetation soil carbon for different irrigation schemes (1) +$ondelim +$include "./modules/59_som/cellpool_jan23/input/f59_ch5_F_IRR.cs3" +$offdelim +; +$if "%c59_irrigation_scenario%" == "off" f59_cratio_irrigation(climate59,w,kcr) = 1; + +$setglobal c59_som_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + +parameters f59_topsoilc_density(t_all,j) LPJ topsoil carbon density for natural vegetation (tC per ha) +/ +$ondelim +$include "./modules/59_som/input/lpj_carbon_topsoil.cs2b" +$offdelim +/ +; +$if "%c59_som_scenario%" == "nocc" f59_topsoilc_density(t_all,j) = f59_topsoilc_density("y1995",j); +$if "%c59_som_scenario%" == "nocc_hist" f59_topsoilc_density(t_all,j)$(m_year(t_all) > sm_fix_cc) = f59_topsoilc_density(t_all,j)$(m_year(t_all) = sm_fix_cc); +m_fillmissingyears(f59_topsoilc_density,"j"); + +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries59(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; diff --git a/modules/59_som/cellpool_jan23/input/files b/modules/59_som/cellpool_jan23/input/files new file mode 100644 index 0000000000..76fd6cae23 --- /dev/null +++ b/modules/59_som/cellpool_jan23/input/files @@ -0,0 +1,5 @@ +* list of files that are required here +f59_ch5_F_I.csv +f59_ch5_F_MG.csv +f59_ch5_F_LU_2019reg.cs3 +f59_ch5_F_IRR.cs3 diff --git a/modules/59_som/cellpool_jan23/not_used.txt b/modules/59_som/cellpool_jan23/not_used.txt new file mode 100644 index 0000000000..a62a4ec738 --- /dev/null +++ b/modules/59_som/cellpool_jan23/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +vm_land_other,input,not needed diff --git a/modules/59_som/cellpool_jan23/postsolve.gms b/modules/59_som/cellpool_jan23/postsolve.gms new file mode 100644 index 0000000000..ea42e490a4 --- /dev/null +++ b/modules/59_som/cellpool_jan23/postsolve.gms @@ -0,0 +1,65 @@ +*** | (C) 2008-2025 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 + +pc59_som_pool(j,land) = v59_som_pool.l(j,land); +pc59_land_before(j,land) = vm_land.l(j,land); +pc59_carbon_density(j,land)$(pc59_land_before(j,land) > 1e-10) = pc59_som_pool(j,land) / pc59_land_before(j,land); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov59_som_target(t,j,land,"marginal") = v59_som_target.m(j,land); + ov59_som_pool(t,j,land,"marginal") = v59_som_pool.m(j,land); + ov_cost_scm(t,j,"marginal") = vm_cost_scm.m(j); + ov_nr_som(t,j,"marginal") = vm_nr_som.m(j); + ov_nr_som_fertilizer(t,j,"marginal") = vm_nr_som_fertilizer.m(j); + oq59_som_target_cropland(t,j,"marginal") = q59_som_target_cropland.m(j); + oq59_som_target_noncropland(t,j,noncropland59,"marginal") = q59_som_target_noncropland.m(j,noncropland59); + oq59_som_pool(t,j,land,"marginal") = q59_som_pool.m(j,land); + oq59_nr_som(t,j,"marginal") = q59_nr_som.m(j); + oq59_nr_som_fertilizer(t,j,"marginal") = q59_nr_som_fertilizer.m(j); + oq59_nr_som_fertilizer2(t,j,"marginal") = q59_nr_som_fertilizer2.m(j); + oq59_carbon_soil(t,j,land,stockType,"marginal") = q59_carbon_soil.m(j,land,stockType); + oq59_cost_scm(t,j,"marginal") = q59_cost_scm.m(j); + ov59_som_target(t,j,land,"level") = v59_som_target.l(j,land); + ov59_som_pool(t,j,land,"level") = v59_som_pool.l(j,land); + ov_cost_scm(t,j,"level") = vm_cost_scm.l(j); + ov_nr_som(t,j,"level") = vm_nr_som.l(j); + ov_nr_som_fertilizer(t,j,"level") = vm_nr_som_fertilizer.l(j); + oq59_som_target_cropland(t,j,"level") = q59_som_target_cropland.l(j); + oq59_som_target_noncropland(t,j,noncropland59,"level") = q59_som_target_noncropland.l(j,noncropland59); + oq59_som_pool(t,j,land,"level") = q59_som_pool.l(j,land); + oq59_nr_som(t,j,"level") = q59_nr_som.l(j); + oq59_nr_som_fertilizer(t,j,"level") = q59_nr_som_fertilizer.l(j); + oq59_nr_som_fertilizer2(t,j,"level") = q59_nr_som_fertilizer2.l(j); + oq59_carbon_soil(t,j,land,stockType,"level") = q59_carbon_soil.l(j,land,stockType); + oq59_cost_scm(t,j,"level") = q59_cost_scm.l(j); + ov59_som_target(t,j,land,"upper") = v59_som_target.up(j,land); + ov59_som_pool(t,j,land,"upper") = v59_som_pool.up(j,land); + ov_cost_scm(t,j,"upper") = vm_cost_scm.up(j); + ov_nr_som(t,j,"upper") = vm_nr_som.up(j); + ov_nr_som_fertilizer(t,j,"upper") = vm_nr_som_fertilizer.up(j); + oq59_som_target_cropland(t,j,"upper") = q59_som_target_cropland.up(j); + oq59_som_target_noncropland(t,j,noncropland59,"upper") = q59_som_target_noncropland.up(j,noncropland59); + oq59_som_pool(t,j,land,"upper") = q59_som_pool.up(j,land); + oq59_nr_som(t,j,"upper") = q59_nr_som.up(j); + oq59_nr_som_fertilizer(t,j,"upper") = q59_nr_som_fertilizer.up(j); + oq59_nr_som_fertilizer2(t,j,"upper") = q59_nr_som_fertilizer2.up(j); + oq59_carbon_soil(t,j,land,stockType,"upper") = q59_carbon_soil.up(j,land,stockType); + oq59_cost_scm(t,j,"upper") = q59_cost_scm.up(j); + ov59_som_target(t,j,land,"lower") = v59_som_target.lo(j,land); + ov59_som_pool(t,j,land,"lower") = v59_som_pool.lo(j,land); + ov_cost_scm(t,j,"lower") = vm_cost_scm.lo(j); + ov_nr_som(t,j,"lower") = vm_nr_som.lo(j); + ov_nr_som_fertilizer(t,j,"lower") = vm_nr_som_fertilizer.lo(j); + oq59_som_target_cropland(t,j,"lower") = q59_som_target_cropland.lo(j); + oq59_som_target_noncropland(t,j,noncropland59,"lower") = q59_som_target_noncropland.lo(j,noncropland59); + oq59_som_pool(t,j,land,"lower") = q59_som_pool.lo(j,land); + oq59_nr_som(t,j,"lower") = q59_nr_som.lo(j); + oq59_nr_som_fertilizer(t,j,"lower") = q59_nr_som_fertilizer.lo(j); + oq59_nr_som_fertilizer2(t,j,"lower") = q59_nr_som_fertilizer2.lo(j); + oq59_carbon_soil(t,j,land,stockType,"lower") = q59_carbon_soil.lo(j,land,stockType); + oq59_cost_scm(t,j,"lower") = q59_cost_scm.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/59_som/cellpool_jan23/preloop.gms b/modules/59_som/cellpool_jan23/preloop.gms new file mode 100644 index 0000000000..170993ddba --- /dev/null +++ b/modules/59_som/cellpool_jan23/preloop.gms @@ -0,0 +1,116 @@ +*** | (C) 2008-2025 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 + +***************************** +*** SOM initialisation *** +***************************** + +i59_subsoilc_density(t_all,j) = fm_carbon_density(t_all,j,"other","soilc") - f59_topsoilc_density(t_all,j); + +pc59_som_pool(j,"crop") = + sum((climate59,kcr),sum(clcl_climate59(clcl,climate59), + pm_climate_class(j,clcl)) * sum(cell(i,j), f59_cratio_landuse(i,climate59,kcr)) + * f59_topsoilc_density("y1995",j) * sum(w, fm_croparea("y1995",j,w,kcr))); + +pc59_som_pool(j,noncropland59) = + f59_topsoilc_density("y1995",j) * pm_land_start(j,noncropland59); + + +***************************** +*** carbon initialisation *** +**************************** + +* starting value of carbon stocks 1995 is only an estimate. +* ATTENTION: emissions in 1995 are not meaningful + +pcm_carbon_stock(j,"crop","soilc",stockType) = + pc59_som_pool(j,"crop") + i59_subsoilc_density("y1995",j) * pm_land_start(j,"crop"); +vm_carbon_stock.l(j,"crop","soilc",stockType) = pcm_carbon_stock(j,"crop","soilc",stockType); +pcm_carbon_stock(j,noncropland59,"soilc",stockType) = + fm_carbon_density("y1995",j,noncropland59,"soilc") * pm_land_start(j,noncropland59); +vm_carbon_stock.l(j,noncropland59,"soilc",stockType) = pcm_carbon_stock(j,noncropland59,"soilc",stockType); + +***************************** +*** cshare calculation *** +***************************** + +*' @code This realization calculates the carbon loss with the assumption +*' of a lossrate of 15% per year resulting in 44% in 5 years, 80% in 10 years +*' and 96% in 20 years. The lossrate for a given timestep is than calculate by + +i59_lossrate(t)=1-0.85**m_yeardiff(t); + +*' The stock change factors are implemented for cropland subsystems divided by +*' MAgPIE crop types as well as potentially for tillage and input management. +*' So far it just tracks the subsystem component due to missing data for the +*' other categories. They are set to the following default values: + +i59_tillage_share(i,tillage59)=0; +i59_tillage_share(i,"full_tillage")=1; +i59_input_share(i,inputs59)=0; +i59_input_share(i,"medium_input")=1; + +*' The stock change factor in each cell for every crop type also takes into account +*' the climate variability of these factors and is therefor given by: + +i59_cratio(j,kcr,w) = sum((cell(i,j),tillage59,inputs59,climate59), + sum(clcl_climate59(clcl,climate59),pm_climate_class(j,clcl)) + * f59_cratio_landuse(i,climate59,kcr) + * i59_tillage_share(i,tillage59) + * f59_cratio_tillage(climate59,tillage59) + * i59_input_share(i,inputs59) + * f59_cratio_inputs(climate59,inputs59) + * f59_cratio_irrigation(climate59,w,kcr)); + +*' For fallow we assume annual crops with bare fallow - therefor low input - +*' and reduced tillage. Assumed to have no irrigation, so irrigation multiplier +*' is 1. + +i59_cratio_fallow(j) = sum((cell(i,j),climate59), + sum(clcl_climate59(clcl,climate59),pm_climate_class(j,clcl)) + * f59_cratio_landuse(i,climate59,"maiz") + * f59_cratio_tillage(climate59,"reduced_tillage") + * f59_cratio_inputs(climate59,"low_input")); + +*' For treecover in cropland (e.g. agroforestry areas) we assume natural soil carbon +*' values as target value, and thus set the value to `1`: + +i59_cratio_treecover = 1; + + +*' For dedicated soil carbon management we use the `high_input_nomanure` values from the IPCC guidelines, +*' as the refer to the usage of dedicated SCM measures such as cover crops, improved residue management etc. + +i59_cratio_scm(j) = sum(climate59, sum(clcl_climate59(clcl,climate59), + pm_climate_class(j,clcl)) * + f59_cratio_inputs(climate59,"high_input_nomanure")); + +*' @stop + +** Trajectory for cropland scenarios +* linear or sigmoidal interpolation between start year and target year +if (s59_fader_functional_form = 1, + m_linear_time_interpol(i59_scm_scenario_fader,s59_scm_scenario_start,s59_scm_scenario_target,0,1); +elseif s59_fader_functional_form = 2, + m_sigmoid_time_interpol(i59_scm_scenario_fader,s59_scm_scenario_start,s59_scm_scenario_target,0,1); +); + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p59_scm_country_switch(iso) = 0; +p59_scm_country_switch(policy_countries59) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area `pm_avl_cropland_iso` +p59_country_weight(i) = sum(i_to_iso(i,iso), p59_scm_country_switch(iso) * + pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); + +pc59_land_before(j,land) = pm_land_start(j,land); + +p59_carbon_density(t,j,land) = 0; +pc59_carbon_density(j,land) = 0; +pc59_carbon_density(j,land)$(pc59_land_before(j,land) > 1e-10) = pc59_som_pool(j,land) / pc59_land_before(j,land); diff --git a/modules/59_som/cellpool_jan23/presolve.gms b/modules/59_som/cellpool_jan23/presolve.gms new file mode 100644 index 0000000000..7af9d64fff --- /dev/null +++ b/modules/59_som/cellpool_jan23/presolve.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2025 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 + +* SOM pools and densities will be updated after natural regrowth and disturbance loss accounting. +* The secondary forest pool will receive carbon from primary forest (due to natural disturbance) +* and from other land (due to regrowth). +* Note: This will only account for transitions of primary forest to secondary forest and +* other land to secondary forest. See current version of 35_natveg to check consistency. + +pc59_som_pool(j,"secdforest") = pc59_som_pool(j,"secdforest") + + (pc59_land_before(j,"primforest") - pcm_land(j,"primforest")) * + pc59_carbon_density(j,"primforest") + + (pc59_land_before(j,"other") - pcm_land(j,"other")) * + pc59_carbon_density(j,"other"); + +pc59_som_pool(j,"other") = pc59_som_pool(j,"other") - + (pc59_land_before(j,"other") - pcm_land(j,"other")) * + pc59_carbon_density(j,"other"); + +pc59_som_pool(j,"primforest") = pc59_som_pool(j,"primforest") - + (pc59_land_before(j,"primforest") - pcm_land(j,"primforest")) * + pc59_carbon_density(j,"primforest"); + +p59_carbon_density(t,j,land)$(pcm_land(j,land) > 1e-10) = pc59_som_pool(j,land) / pcm_land(j,land); + +* create soil carbon management target scenario +i59_scm_target(t,j) = i59_scm_scenario_fader(t) * + (s59_scm_target * sum(cell(i,j), p59_country_weight(i)) + + s59_scm_target_noselect * sum(cell(i,j), 1-p59_country_weight(i))); diff --git a/modules/59_som/cellpool_jan23/realization.gms b/modules/59_som/cellpool_jan23/realization.gms new file mode 100644 index 0000000000..c33cc6253a --- /dev/null +++ b/modules/59_som/cellpool_jan23/realization.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2025 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 +*' The cellpool_aug23 realization is built on revised IPCC 2019 Guidelines for +*' National Greenhouse Gas Inventories (@calvo_buendia_ipcc_2019). It calculates the loss of +*' soil carbon due to cropping activities and management based on stock change factors, +*' compared to potential natural vegetation. +*' This approach also accounts for the temporal dimension of soil organic carbon change, +*' since it assumes a gradual step of 15% in the direction of the new equilibrium soil +*' organic carbon pool each year. Stock change factors tracks crop types as well as +*' management (e.g. irrigation) and input differences on cropland. +*' Dedicated soil carbon management can be switched on for a share of cropland, characterized +*' by a higher input factor, which according to the IPCC guidelines reflects improved agronomic +*' practices. Target shares are set exogenously and are phased in over time. + +*' @limitations It is assumed that pastures and rangelandes as well as managed forests +*' do not change in soil carbon compared to the natural reference state. Moreover only +*' transitions from other land and primary forest to secondary forest between optimization +*' steps (due to natural regrowth and disturbance loss) are accounted for. + + +*' @authors Kristine Karstens, Benjamin Leon Bodirsky + + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/59_som/cellpool_jan23/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/59_som/cellpool_jan23/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/59_som/cellpool_jan23/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/59_som/cellpool_jan23/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/59_som/cellpool_jan23/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/59_som/cellpool_jan23/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/59_som/cellpool_jan23/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/59_som/cellpool_jan23/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/59_som/cellpool_jan23/scaling.gms b/modules/59_som/cellpool_jan23/scaling.gms new file mode 100644 index 0000000000..49320b8394 --- /dev/null +++ b/modules/59_som/cellpool_jan23/scaling.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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 + +v59_som_target.scale(j,land) = 10e3; +v59_som_pool.scale(j,land) = 10e3; diff --git a/modules/59_som/cellpool_jan23/sets.gms b/modules/59_som/cellpool_jan23/sets.gms new file mode 100644 index 0000000000..e728db3331 --- /dev/null +++ b/modules/59_som/cellpool_jan23/sets.gms @@ -0,0 +1,63 @@ +*** | (C) 2008-2025 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 + +noncropland59(land) Soil carbon conserving landuse types +/past, forestry, primforest, secdforest, other, urban/ + +tillage59 Tillage categories of IPCC +/full_tillage,reduced_tillage,no_tillage/ + +inputs59 Input management categories of IPCC +/low_input,medium_input,high_input_nomanure,high_input_manure/ + +climate59_2019 Climate classes of IPCC 2019 +/temperate_dry,temperate_moist,tropical_dry,tropical_moist,boreal_dry,boreal_moist/ + +climate59(climate59_2019) Climate classes of IPCC 2006 +/temperate_dry,temperate_moist,tropical_dry,tropical_moist/ + +*** Csa, Dwa should be dry (maybe others as well) + +clcl_climate59(clcl,climate59) Climate classification types + / + Af .(tropical_moist) "equatorial fully humid" + Am .(tropical_moist) "equatorial monsoonal" + As .(tropical_moist) "equatorial summer dry" + Aw .(tropical_moist) "equatorial winter dry" + BSh .(tropical_dry) "arid steppe hot arid" + BSk .(temperate_dry) "arid steppe cold arid" + BWh .(tropical_dry) "arid desert hot arid" + BWk .(temperate_dry) "arid desert cold arid" + Cfa .(temperate_moist) "warm temperate fully humid hot summer" + Cfb .(temperate_moist) "warm temperate fully humid warm summer" + Cfc .(temperate_moist) "warm temperate fully humid cool summer" + Csa .(temperate_moist) "warm temperate winter dry hot summer" + Csb .(temperate_moist) "warm temperate winter dry warm summer" + Csc .(temperate_moist) "warm temperate winter dry cool summer" + Cwa .(temperate_moist) "warm temperate winter dry hot summer" + Cwb .(temperate_moist) "warm temperate winter dry warm summer" + Cwc .(temperate_moist) "warm temperate winter dry cool summer" + Dfa .(temperate_moist) "snow fully humid hot summer" + Dfb .(temperate_moist) "snow fully humid warm summer" + Dfc .(temperate_moist) "snow fully humid cool summer" + Dfd .(temperate_moist) "snow fully humid extremely continental" + Dsa .(temperate_moist) "snow winter dry hot summer" + Dsb .(temperate_moist) "snow winter dry warm summer" + Dsc .(temperate_moist) "snow winter dry cool summer" + Dsd .(temperate_dry) "snow winder dry extremely continental" + Dwa .(temperate_moist) "snow winter dry hot summer" + Dwb .(temperate_moist) "snow winter dry warm summer" + Dwc .(temperate_moist) "snow winter dry cool summer" + Dwd .(temperate_dry) "snow winter dry extremely continental" + EF .(temperate_dry) "polar polar frost" + ET .(temperate_moist) "polar polar tundra" + / +; + +alias(noncropland59,noncropland59_2); diff --git a/modules/59_som/input/files b/modules/59_som/input/files new file mode 100644 index 0000000000..4f4ac2c34e --- /dev/null +++ b/modules/59_som/input/files @@ -0,0 +1,3 @@ +* list of files that are required here +lpj_carbon_topsoil.cs2b +lpj_carbon_topsoil_0.5.mz diff --git a/modules/59_som/module.gms b/modules/59_som/module.gms index ca2d3e8f79..d73e072cfc 100644 --- a/modules/59_som/module.gms +++ b/modules/59_som/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -17,6 +17,6 @@ *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%som%" == "cellpool_aug16" $include "./modules/59_som/cellpool_aug16/realization.gms" -$Ifi "%som%" == "off" $include "./modules/59_som/off/realization.gms" +$Ifi "%som%" == "cellpool_jan23" $include "./modules/59_som/cellpool_jan23/realization.gms" +$Ifi "%som%" == "static_jan19" $include "./modules/59_som/static_jan19/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/59_som/off/declarations.gms b/modules/59_som/off/declarations.gms deleted file mode 100644 index 9a604cc9a5..0000000000 --- a/modules/59_som/off/declarations.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2019 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 - -variables - vm_nr_som(j) Release of soil organic matter (Tg N per yr) - vm_costs_overrate_cropdiff(i) Punishment costs for overrated cropland difference (mio. USD05 per yr) -; -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_nr_som(t,j,type) Release of soil organic matter (Tg N per yr) - ov_costs_overrate_cropdiff(t,i,type) Punishment costs for overrated cropland difference (mio. USD05 per yr) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - diff --git a/modules/59_som/off/not_used.txt b/modules/59_som/off/not_used.txt deleted file mode 100644 index 33881c0f88..0000000000 --- a/modules/59_som/off/not_used.txt +++ /dev/null @@ -1,11 +0,0 @@ -# | (C) 2008-2019 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 -name,type,reason -vm_land,input,questionnaire -pcm_land,input,questionnaire -vm_area,input,questionnaire -pm_climate_class,input,questionnaire diff --git a/modules/59_som/off/postsolve.gms b/modules/59_som/off/postsolve.gms deleted file mode 100644 index a30e94ab32..0000000000 --- a/modules/59_som/off/postsolve.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2019 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 - - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_nr_som(t,j,"marginal") = vm_nr_som.m(j); - ov_costs_overrate_cropdiff(t,i,"marginal") = vm_costs_overrate_cropdiff.m(i); - ov_nr_som(t,j,"level") = vm_nr_som.l(j); - ov_costs_overrate_cropdiff(t,i,"level") = vm_costs_overrate_cropdiff.l(i); - ov_nr_som(t,j,"upper") = vm_nr_som.up(j); - ov_costs_overrate_cropdiff(t,i,"upper") = vm_costs_overrate_cropdiff.up(i); - ov_nr_som(t,j,"lower") = vm_nr_som.lo(j); - ov_costs_overrate_cropdiff(t,i,"lower") = vm_costs_overrate_cropdiff.lo(i); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/59_som/off/presolve.gms b/modules/59_som/off/presolve.gms deleted file mode 100644 index 05bda92cfd..0000000000 --- a/modules/59_som/off/presolve.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2019 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_nr_som.fx(j)=0; -vm_costs_overrate_cropdiff.fx(i)=0; diff --git a/modules/59_som/off/realization.gms b/modules/59_som/off/realization.gms deleted file mode 100644 index 8957d97181..0000000000 --- a/modules/59_som/off/realization.gms +++ /dev/null @@ -1,16 +0,0 @@ -*** | (C) 2008-2019 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 This realization does not track soil organic matter turnover. - -*' @limitations The release of nitrogen due to soil organic matter loss is not calculated. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/59_som/off/declarations.gms" -$Ifi "%phase%" == "presolve" $include "./modules/59_som/off/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/59_som/off/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/59_som/static_jan19/declarations.gms b/modules/59_som/static_jan19/declarations.gms new file mode 100644 index 0000000000..5d83f75915 --- /dev/null +++ b/modules/59_som/static_jan19/declarations.gms @@ -0,0 +1,36 @@ +*** | (C) 2008-2025 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 + i59_topsoilc_density(t_all,j) Topsoil carbon density of a hectare of cropland (tC per ha) + i59_subsoilc_density(t_all,j) Subsoil carbon density of a hectare of land (tC per ha) + i59_nr_som_exogenous_per_ha(t_all,i) Exogenous nr release due to som release per ha (tN per ha) +; + +variables + vm_nr_som(j) Release of soil organic matter (Mt N per yr) + vm_nr_som_fertilizer(j) Uptake of soil organic matter from plants (Mt N per yr) + vm_cost_scm(j) Recurring cost for soil carbon management on cropland (mio. USD17MER per yr) + +; + +equations + q59_soilcarbon_cropland(j,stockType) Cropland soil carbon content calculation (mio. tC) + q59_soilcarbon_regular(j,regularland59,stockType) Regular soil carbon content calculation (mio. tC) + q59_soilcarbon_other(j,stockType) Other land soil carbon content calculation (mio. tC) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_nr_som(t,j,type) Release of soil organic matter (Mt N per yr) + ov_nr_som_fertilizer(t,j,type) Uptake of soil organic matter from plants (Mt N per yr) + ov_cost_scm(t,j,type) Recurring cost for soil carbon management on cropland (mio. USD17MER per yr) + oq59_soilcarbon_cropland(t,j,stockType,type) Cropland soil carbon content calculation (mio. tC) + oq59_soilcarbon_regular(t,j,regularland59,stockType,type) Regular soil carbon content calculation (mio. tC) + oq59_soilcarbon_other(t,j,stockType,type) Other land soil carbon content calculation (mio. tC) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/59_som/static_jan19/equations.gms b/modules/59_som/static_jan19/equations.gms new file mode 100644 index 0000000000..140d8a01f6 --- /dev/null +++ b/modules/59_som/static_jan19/equations.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 +*' The soil carbon content for cropland is calculated as sum of reduced topsoil density +*' and the reference soil carbon densities of the subsoil. + q59_soilcarbon_cropland(j2,stockType) .. + vm_carbon_stock(j2,"crop","soilc",stockType) =e= + (sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2)) * sum(ct, i59_topsoilc_density(ct,j2) + i59_subsoilc_density(ct,j2)) + + vm_treecover(j2) * sum(ct, fm_carbon_density(ct,j2,"secdforest","soilc")); + +*' The soil carbon content for all other land use types is calculated based on the full profile soil carbon density: + q59_soilcarbon_regular(j2,regularland59,stockType) .. + vm_carbon_stock(j2,regularland59,"soilc",stockType) =e= + sum(ct, vm_land(j2,regularland59) * fm_carbon_density(ct,j2,regularland59,"soilc")); + +q59_soilcarbon_other(j2,stockType) .. + vm_carbon_stock(j2,"other","soilc",stockType) =e= + sum((ct,ac), vm_land_other(j2,"othernat",ac) * fm_carbon_density(ct,j2,"other","soilc")) + + sum((ct,ac), vm_land_other(j2,"youngsecdf",ac) * fm_carbon_density(ct,j2,"secdforest","soilc")) ; + + + diff --git a/modules/59_som/static_jan19/input.gms b/modules/59_som/static_jan19/input.gms new file mode 100644 index 0000000000..8919f74886 --- /dev/null +++ b/modules/59_som/static_jan19/input.gms @@ -0,0 +1,45 @@ +*** | (C) 2008-2025 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 + +$setglobal c59_static_spatial_level cellular +* options: cellular (use preprocessed cellular stock change factors) +* cluster (use cshare_released on cluster within gams) + +$setglobal c59_som_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + +* Exogenous nr release through som loss (only in static realization) +$setglobal c59_exo_scen constant +* options: constant (constant from 2020) +* fadeout_2050 (fading out till 2050) + +parameters f59_topsoilc_density(t_all,j) LPJ topsoil carbon density for natural vegetation (tC per ha) +/ +$ondelim +$include "./modules/59_som/input/lpj_carbon_topsoil.cs2b" +$offdelim +/ +; +$if "%c59_som_scenario%" == "nocc" f59_topsoilc_density(t_all,j) = f59_topsoilc_density("y1995",j); +$if "%c59_som_scenario%" == "nocc_hist" f59_topsoilc_density(t_all,j)$(m_year(t_all) > sm_fix_cc) = f59_topsoilc_density(t_all,j)$(m_year(t_all) = sm_fix_cc); +m_fillmissingyears(f59_topsoilc_density,"j"); + +parameters f59_cshare_released(j) Share of soil carbon that is released on cropland compared to natural vegetation after 20 years (1) +/ +$ondelim +$include "./modules/59_som/static_jan19/input/cshare_released.cs2b" +$offdelim +/ +; + +table f59_som_exogenous(t_all,i,exo_scen59) Nr released through changing soil organic matter +$ondelim +$include "./modules/59_som/static_jan19/input/f59_som_exogenous.cs3" +$offdelim +; diff --git a/modules/59_som/static_jan19/input/files b/modules/59_som/static_jan19/input/files new file mode 100644 index 0000000000..7ce5a95ad7 --- /dev/null +++ b/modules/59_som/static_jan19/input/files @@ -0,0 +1,3 @@ +* list of files that are required here +cshare_released.cs2b +f59_som_exogenous.cs3 \ No newline at end of file diff --git a/modules/59_som/static_jan19/not_used.txt b/modules/59_som/static_jan19/not_used.txt new file mode 100644 index 0000000000..c99b479c30 --- /dev/null +++ b/modules/59_som/static_jan19/not_used.txt @@ -0,0 +1,7 @@ +name,type,reason +pm_land_start,input,questionnaire +fm_croparea,input,questionnaire +pm_avl_cropland_iso,input,questionnaire +vm_landexpansion,input,questionnaire +vm_lu_transitions,input,questionnaire +pm_climate_class,input,questionnaire diff --git a/modules/59_som/static_jan19/postsolve.gms b/modules/59_som/static_jan19/postsolve.gms new file mode 100644 index 0000000000..32fda876c4 --- /dev/null +++ b/modules/59_som/static_jan19/postsolve.gms @@ -0,0 +1,36 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_nr_som(t,j,"marginal") = vm_nr_som.m(j); + ov_nr_som_fertilizer(t,j,"marginal") = vm_nr_som_fertilizer.m(j); + ov_cost_scm(t,j,"marginal") = vm_cost_scm.m(j); + oq59_soilcarbon_cropland(t,j,stockType,"marginal") = q59_soilcarbon_cropland.m(j,stockType); + oq59_soilcarbon_regular(t,j,regularland59,stockType,"marginal") = q59_soilcarbon_regular.m(j,regularland59,stockType); + oq59_soilcarbon_other(t,j,stockType,"marginal") = q59_soilcarbon_other.m(j,stockType); + ov_nr_som(t,j,"level") = vm_nr_som.l(j); + ov_nr_som_fertilizer(t,j,"level") = vm_nr_som_fertilizer.l(j); + ov_cost_scm(t,j,"level") = vm_cost_scm.l(j); + oq59_soilcarbon_cropland(t,j,stockType,"level") = q59_soilcarbon_cropland.l(j,stockType); + oq59_soilcarbon_regular(t,j,regularland59,stockType,"level") = q59_soilcarbon_regular.l(j,regularland59,stockType); + oq59_soilcarbon_other(t,j,stockType,"level") = q59_soilcarbon_other.l(j,stockType); + ov_nr_som(t,j,"upper") = vm_nr_som.up(j); + ov_nr_som_fertilizer(t,j,"upper") = vm_nr_som_fertilizer.up(j); + ov_cost_scm(t,j,"upper") = vm_cost_scm.up(j); + oq59_soilcarbon_cropland(t,j,stockType,"upper") = q59_soilcarbon_cropland.up(j,stockType); + oq59_soilcarbon_regular(t,j,regularland59,stockType,"upper") = q59_soilcarbon_regular.up(j,regularland59,stockType); + oq59_soilcarbon_other(t,j,stockType,"upper") = q59_soilcarbon_other.up(j,stockType); + ov_nr_som(t,j,"lower") = vm_nr_som.lo(j); + ov_nr_som_fertilizer(t,j,"lower") = vm_nr_som_fertilizer.lo(j); + ov_cost_scm(t,j,"lower") = vm_cost_scm.lo(j); + oq59_soilcarbon_cropland(t,j,stockType,"lower") = q59_soilcarbon_cropland.lo(j,stockType); + oq59_soilcarbon_regular(t,j,regularland59,stockType,"lower") = q59_soilcarbon_regular.lo(j,regularland59,stockType); + oq59_soilcarbon_other(t,j,stockType,"lower") = q59_soilcarbon_other.lo(j,stockType); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/59_som/static_jan19/preloop.gms b/modules/59_som/static_jan19/preloop.gms new file mode 100644 index 0000000000..928cc7db98 --- /dev/null +++ b/modules/59_som/static_jan19/preloop.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 + + +* starting value of carbon stocks 1995 is only an estimate. +* ATTENTION: emissions in 1995 are not meaningful +pcm_carbon_stock(j,land,"soilc","actual") = fm_carbon_density("y1995",j,land,"soilc") * pcm_land(j,land); +vm_carbon_stock.l(j,land,"soilc","actual") = pcm_carbon_stock(j,land,"soilc","actual"); + +* Soilc is not different for all non cropland vegetated land types +* No age-class soil carbon density distribution is nessessary + +*' @code Cropland topsoil carbon densities are calculated based on simple IPCC stock change factors +*' (if not done in cellular preprocessing). We assume following the IPCC assumptions that cropland activities +*' will only change the topsoil (here 30 cm) carbon density. +i59_subsoilc_density(t_all,j) = fm_carbon_density(t_all,j,"secdforest","soilc") - f59_topsoilc_density(t_all,j); +$ifthen "%c59_static_spatial_level%" == "cellular" i59_topsoilc_density(t_all,j) = fm_carbon_density(t_all,j,"crop","soilc") - i59_subsoilc_density(t_all,j); +$elseif "%c59_static_spatial_level%" == "cluster" i59_topsoilc_density(t_all,j) = f59_topsoilc_density(t_all,j) * (1- f59_cshare_released(j)); +$endif diff --git a/modules/59_som/static_jan19/presolve.gms b/modules/59_som/static_jan19/presolve.gms new file mode 100644 index 0000000000..d6dc9d883d --- /dev/null +++ b/modules/59_som/static_jan19/presolve.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2025 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_nr_som.fx(j) = 0; +vm_nr_som_fertilizer.fx(j) = 0; + +i59_nr_som_exogenous_per_ha(t,i) = 0; +$if "%c59_exo_scen%" == "constant" i59_nr_som_exogenous_per_ha(t,i)$(sum(cell(i,j),pcm_land(j,"crop")) > 0) = f59_som_exogenous(t,i,"constant")/sum(cell(i,j),pcm_land(j,"crop")); +$if "%c59_exo_scen%" == "fadeout_2050" i59_nr_som_exogenous_per_ha(t,i)$(sum(cell(i,j),pcm_land(j,"crop")) > 0) = f59_som_exogenous(t,i,"fadeout_2050")/sum(cell(i,j),pcm_land(j,"crop")); + +vm_nr_som.fx(j) = sum(cell(i,j),i59_nr_som_exogenous_per_ha(t,i)*pcm_land(j,"crop")); +vm_nr_som_fertilizer.fx(j) = sum(cell(i,j),i59_nr_som_exogenous_per_ha(t,i)*pcm_land(j,"crop")); + +vm_cost_scm.fx(j) = 0; diff --git a/modules/59_som/static_jan19/realization.gms b/modules/59_som/static_jan19/realization.gms new file mode 100644 index 0000000000..43354debb0 --- /dev/null +++ b/modules/59_som/static_jan19/realization.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2025 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 The static_jan19 realization is built on the IPCC 2006 Guidelines for +*' National Greenhouse Gas Inventories (@ipcc_2006_2006.). It calculates the loss of +*' soil carbon due to cropping activities based on stock change factors, compared to +*' potential natural vegetation. +*' This approach does not account for the temporal dimension of soil organic carbon change, +*' since it assumes a complete loss of carbon directly after land conversion to cropland. +*' Therefore, no release of nitrogen due to soil organic matter loss is calculated. +*' Moreover only one stock change factor for all crop types is used, neglecting +*' e.g. differences for annual and perennial crops. + +*' @limitations The soil carbon dynamics are instantaneous and do not account +*' for any time dependent release of soil carbon. +*' The soil carbon pools on cropland are not crop type specific. +*' The release of nitrogen due to soil organic matter loss is not calculated. +*' It is assumed that pastures and rangelands as well as managed forests +*' do not change in soil carbon compared to the natural reference state. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/59_som/static_jan19/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/59_som/static_jan19/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/59_som/static_jan19/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/59_som/static_jan19/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/59_som/static_jan19/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/59_som/static_jan19/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/59_som/static_jan19/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/59_som/static_jan19/sets.gms b/modules/59_som/static_jan19/sets.gms new file mode 100644 index 0000000000..291a6dac2c --- /dev/null +++ b/modules/59_som/static_jan19/sets.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 +regularland59(land) Soil carbon conserving landuse types +/ past, forestry, primforest, secdforest, urban / + +exo_scen59 exogenous scenarios for soil organic matter loss +/constant, fadeout_2050/ +; diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/declarations.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/declarations.gms new file mode 100644 index 0000000000..477a756276 --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/declarations.gms @@ -0,0 +1,49 @@ +*** | (C) 2008-2025 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 + i60_bioenergy_dem(t,i) Regional bioenergy demand per year (mio. GJ per yr) + i60_res_2ndgenBE_dem(t,i) Regional residue demand for 2nd generation bioenergy per year (mio. GJ per yr) + i60_1stgen_bioenergy_dem(t,i,kall) Regional 1st generation bioenergy demand (mio. GJ per yr) + i60_1stgen_bioenergy_subsidy(t) Global 1st generation bioenergy subsidy per GJ (USD17MER per GJ) + i60_2ndgen_bioenergy_subsidy(t) Global 2nd generation bioenergy subsidy (USD17MER per GHJ) + p60_region_BE_shr(t_all,i) Bioenergy demand share of the region (1) + p60_country_switch(iso) Switch indicating whether country is selected for selected bioenergy demand scenario (1) +; + +positive variables + vm_dem_bioen(i,kall) Regional bioenergy demand (mio. tDM per yr) + v60_2ndgen_bioenergy_dem_dedicated(i,kall) Bioenergy demand which can come from different regions (mio. GJ per yr) + v60_2ndgen_bioenergy_dem_residues(i,kall) Bioenergy demand which can come from different product types (mio. GJ per yr) +; + +variables + vm_bioenergy_utility(i) Utility as negative costs for producing bioenergy (USD17MER per yr) +; + +equations + q60_bioenergy(i,kall) Global total bioenergy demand (mio. GJ per yr) + q60_bioenergy_glo Global 2nd generation dedicated bioenergy demand (mio. GJ per yr) + q60_bioenergy_reg(i) Regional 2nd generation dedicated bioenergy demand (mio. GJ per yr) + q60_res_2ndgenBE(i) Regional residue demand for 2nd generation bioenergy (mio. GJ per yr) + q60_bioenergy_incentive(i) Incentive to produce bioenergy (mio. USD17MER per yr) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_dem_bioen(t,i,kall,type) Regional bioenergy demand (mio. tDM per yr) + ov60_2ndgen_bioenergy_dem_dedicated(t,i,kall,type) Bioenergy demand which can come from different regions (mio. GJ per yr) + ov60_2ndgen_bioenergy_dem_residues(t,i,kall,type) Bioenergy demand which can come from different product types (mio. GJ per yr) + ov_bioenergy_utility(t,i,type) Utility as negative costs for producing bioenergy (USD17MER per yr) + oq60_bioenergy(t,i,kall,type) Global total bioenergy demand (mio. GJ per yr) + oq60_bioenergy_glo(t,type) Global 2nd generation dedicated bioenergy demand (mio. GJ per yr) + oq60_bioenergy_reg(t,i,type) Regional 2nd generation dedicated bioenergy demand (mio. GJ per yr) + oq60_res_2ndgenBE(t,i,type) Regional residue demand for 2nd generation bioenergy (mio. GJ per yr) + oq60_bioenergy_incentive(t,i,type) Incentive to produce bioenergy (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/equations.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/equations.gms new file mode 100644 index 0000000000..a2d35cb788 --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/equations.gms @@ -0,0 +1,75 @@ +*** | (C) 2008-2025 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 +*' Total demand for bioenergy comes from different origins +*' 1st generation bioenergy demand is a fixed trajectory of minimum production +*' requirements. Second generation bioenergy splits into a demand +*' for dedicated bioenergy crops, which are fully substitutable based on their +*' energy content, and residues which are also fully substitutable based on +*' their energy content. + +q60_bioenergy(i2,kall) .. + vm_dem_bioen(i2,kall) * fm_attributes("ge",kall) =g= + sum(ct, i60_1stgen_bioenergy_dem(ct,i2,kall)) + + v60_2ndgen_bioenergy_dem_dedicated(i2,kall) + + v60_2ndgen_bioenergy_dem_residues(i2,kall) + ; + +*' The used first generation bioenergy trajectory contains demand until 2050 +*' based on currently established and planned bioenergy policies +*' (@lotze-campen_impacts_2014). For the time +*' after 2050 it is assumed that bioenergy production will be fully transformed +*' to 2nd generation bioenergy crops and residues because of their higher +*' estimated efficiency respectively their low costs. +*' +*' For second generation bioenergy from dedicated bioenergy crops +*' (`kbe60` = bioenergy grasses and bioenergy +*' trees), input is given either on regional or global level (defined via switch +*' $c60\_biodem\_level$). As the bioenergy demand for all crop types was fixed in the +*' first step it now has to be released again for second generation bioenergy +*' crops (`kbe60`). +*' +*' The bioenergy demand calculation for second generation bioenergy is based on +*' the following two equations from which always only one is active: +*' If $c60\_biodem\_level$ is 1 (regional) the right hand side of the first equation +*' is set to 0, if it is 0 (global) the right hand side of the second equation +*' is set to 0. + +q60_bioenergy_glo.. sum((kbe60,i2), v60_2ndgen_bioenergy_dem_dedicated(i2,kbe60)) + =g= sum((ct,i2),i60_bioenergy_dem(ct,i2))*(1-c60_biodem_level); + +q60_bioenergy_reg(i2).. sum(kbe60, v60_2ndgen_bioenergy_dem_dedicated(i2,kbe60)) + =g= sum(ct,i60_bioenergy_dem(ct,i2))*c60_biodem_level; + +*' Except the implementation of the switches and the fact that in the first +*' equation the bioenergy demand is summed up to a global demand both equations +*' act the same way: In both cases the equation just makes sure that the sum +*' over all second generation energy crop of the bioenergy demand is greater or +*' equal to the demand actually given by the input file $i60\_bioenergy\_dem$. + +*' There is additionally some demand of residues for second generation bioenergy +*' $i60\_res\_2ndgenBE\_dem$, which is exogenously provided by the estimation that +*' roughly 33% of available residues for recycling on cropland can be used for 2nd +*' generation bioenergy depending on the SSP scenario, since residue stock and use +*' is mainly driven by population and GDP. + +q60_res_2ndgenBE(i2) .. + sum(kres, v60_2ndgen_bioenergy_dem_residues(i2,kres)) + =g= + sum(ct,i60_res_2ndgenBE_dem(ct,i2)); + +*' Finally, an incentive is provided for the production of 1st and 2nd generation +*' bioenergy beyond the exogeneous minimum demand. 1st generation bioenergy can be incentivized +*' mass- or energy-based. For comparability, the former is in line with other realizations and constant over time. +*' The energy-based incentive can take different forms and is applied to both 1st and 2nd generation. +*' Combined with low or fade-out exogenous demands, this is useful to assess bioenergy production potentials, however +*' the endogenous technological change in [13_tc] may react very strongly and create a positive feedback loop. + +q60_bioenergy_incentive(i2).. vm_bioenergy_utility(i2) + =e= sum((ct,k1st60), vm_dem_bioen(i2,k1st60) * fm_attributes("ge",k1st60) * (-i60_1stgen_bioenergy_subsidy(ct))) + + sum((ct,kbe60), vm_dem_bioen(i2,kbe60) * fm_attributes("ge",kbe60) * (-i60_2ndgen_bioenergy_subsidy(ct))); diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/input.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/input.gms new file mode 100644 index 0000000000..31d4986aeb --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/input.gms @@ -0,0 +1,86 @@ +*** | (C) 2008-2025 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 + scen_countries60(iso) countries to be affected by 2nd generation bionergy demand scenario / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + +scalars + c60_biodem_level bioenergy demand level indicator 1 for regional and 0 for global demand (1) / 1 / + s60_bioenergy_1st_subsidy first generation bioenergy subsidy (USD17MER per GJ) / 6.5 / + s60_bioenergy_1st_price first generation bioenergy per-GJ price (USD17MER per GJ) / 0 / + s60_bioenergy_2nd_price second generation bioenergy price (USD17MER per GJ) / 0 / + s60_2ndgen_bioenergy_dem_min Minimum dedicated 2nd generation bioenergy demand assumed in each region during SSP2-fix (mio. GJ per yr) / 1 / +; + +$setglobal c60_price_implementation lin +$setglobal c60_2ndgen_biodem R34M410-SSP2-NPi2025 +$setglobal c60_2ndgen_biodem_noselect R34M410-SSP2-NPi2025 + + +$if "%c60_2ndgen_biodem%" == "coupling" table f60_bioenergy_dem_coupling(t_all,i) Bioenergy demand (regional) (mio. GJ per yr) +$if "%c60_2ndgen_biodem%" == "coupling" $ondelim +$if "%c60_2ndgen_biodem%" == "coupling" $include "./modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv" +$if "%c60_2ndgen_biodem%" == "coupling" $offdelim +$if "%c60_2ndgen_biodem%" == "coupling" ; + +$if "%c60_2ndgen_biodem%" == "emulator" parameter f60_bioenergy_dem_emulator(t_all) Bioenergy demand (global) (mio. GJ per yr) +$if "%c60_2ndgen_biodem%" == "emulator" / +$if "%c60_2ndgen_biodem%" == "emulator" $ondelim +$if "%c60_2ndgen_biodem%" == "emulator" $include "./modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv" +$if "%c60_2ndgen_biodem%" == "emulator" $offdelim +$if "%c60_2ndgen_biodem%" == "emulator" / +$if "%c60_2ndgen_biodem%" == "emulator" ; + +table f60_bioenergy_dem(t_all,i,scen2nd60) annual bioenergy demand (regional) (mio. GJ per yr) +$ondelim +$include "./modules/60_bioenergy/input/f60_bioenergy_dem.cs3" +$offdelim +; + +$setglobal c60_res_2ndgenBE_dem ssp2 +* options: ssp1,ssp2,ssp3,ssp4,ssp5,off + +table f60_res_2ndgenBE_dem(t_all,i,scen2ndres60) annual residue demand for 2nd generation bioenergy(regional) (mio. GJ per yr) +$ondelim +$include "./modules/60_bioenergy/input/f60_2ndgenBE_residue_dem.cs3" +$offdelim +; + + +$setglobal c60_1stgen_biodem const2020 +* options: "const2020", "const2030", "phaseout2020" + +table f60_1stgen_bioenergy_dem(t_all,i,scen1st60,kall) annual 1st generation bioenergy demand (mio. GJ per yr) +$ondelim +$include "./modules/60_bioenergy/input/f60_1stgen_bioenergy_dem.cs3" +$offdelim +; diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/postsolve.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/postsolve.gms new file mode 100644 index 0000000000..4172d2bb17 --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/postsolve.gms @@ -0,0 +1,48 @@ +*** | (C) 2008-2025 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 + + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_dem_bioen(t,i,kall,"marginal") = vm_dem_bioen.m(i,kall); + ov60_2ndgen_bioenergy_dem_dedicated(t,i,kall,"marginal") = v60_2ndgen_bioenergy_dem_dedicated.m(i,kall); + ov60_2ndgen_bioenergy_dem_residues(t,i,kall,"marginal") = v60_2ndgen_bioenergy_dem_residues.m(i,kall); + ov_bioenergy_utility(t,i,"marginal") = vm_bioenergy_utility.m(i); + oq60_bioenergy(t,i,kall,"marginal") = q60_bioenergy.m(i,kall); + oq60_bioenergy_glo(t,"marginal") = q60_bioenergy_glo.m; + oq60_bioenergy_reg(t,i,"marginal") = q60_bioenergy_reg.m(i); + oq60_res_2ndgenBE(t,i,"marginal") = q60_res_2ndgenBE.m(i); + oq60_bioenergy_incentive(t,i,"marginal") = q60_bioenergy_incentive.m(i); + ov_dem_bioen(t,i,kall,"level") = vm_dem_bioen.l(i,kall); + ov60_2ndgen_bioenergy_dem_dedicated(t,i,kall,"level") = v60_2ndgen_bioenergy_dem_dedicated.l(i,kall); + ov60_2ndgen_bioenergy_dem_residues(t,i,kall,"level") = v60_2ndgen_bioenergy_dem_residues.l(i,kall); + ov_bioenergy_utility(t,i,"level") = vm_bioenergy_utility.l(i); + oq60_bioenergy(t,i,kall,"level") = q60_bioenergy.l(i,kall); + oq60_bioenergy_glo(t,"level") = q60_bioenergy_glo.l; + oq60_bioenergy_reg(t,i,"level") = q60_bioenergy_reg.l(i); + oq60_res_2ndgenBE(t,i,"level") = q60_res_2ndgenBE.l(i); + oq60_bioenergy_incentive(t,i,"level") = q60_bioenergy_incentive.l(i); + ov_dem_bioen(t,i,kall,"upper") = vm_dem_bioen.up(i,kall); + ov60_2ndgen_bioenergy_dem_dedicated(t,i,kall,"upper") = v60_2ndgen_bioenergy_dem_dedicated.up(i,kall); + ov60_2ndgen_bioenergy_dem_residues(t,i,kall,"upper") = v60_2ndgen_bioenergy_dem_residues.up(i,kall); + ov_bioenergy_utility(t,i,"upper") = vm_bioenergy_utility.up(i); + oq60_bioenergy(t,i,kall,"upper") = q60_bioenergy.up(i,kall); + oq60_bioenergy_glo(t,"upper") = q60_bioenergy_glo.up; + oq60_bioenergy_reg(t,i,"upper") = q60_bioenergy_reg.up(i); + oq60_res_2ndgenBE(t,i,"upper") = q60_res_2ndgenBE.up(i); + oq60_bioenergy_incentive(t,i,"upper") = q60_bioenergy_incentive.up(i); + ov_dem_bioen(t,i,kall,"lower") = vm_dem_bioen.lo(i,kall); + ov60_2ndgen_bioenergy_dem_dedicated(t,i,kall,"lower") = v60_2ndgen_bioenergy_dem_dedicated.lo(i,kall); + ov60_2ndgen_bioenergy_dem_residues(t,i,kall,"lower") = v60_2ndgen_bioenergy_dem_residues.lo(i,kall); + ov_bioenergy_utility(t,i,"lower") = vm_bioenergy_utility.lo(i); + oq60_bioenergy(t,i,kall,"lower") = q60_bioenergy.lo(i,kall); + oq60_bioenergy_glo(t,"lower") = q60_bioenergy_glo.lo; + oq60_bioenergy_reg(t,i,"lower") = q60_bioenergy_reg.lo(i); + oq60_res_2ndgenBE(t,i,"lower") = q60_res_2ndgenBE.lo(i); + oq60_bioenergy_incentive(t,i,"lower") = q60_bioenergy_incentive.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/preloop.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/preloop.gms new file mode 100644 index 0000000000..00ceae3f5b --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/preloop.gms @@ -0,0 +1,36 @@ +*** | (C) 2008-2025 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 + +****** Region price share for 2nd generation bioenergy demand scenario: +* Country switch to determine countries for which scenario shall be applied. +* In the default case, the selected scneario (c60_2ndgen_biodem) affects +* all countries. +p60_country_switch(iso) = 0; +p60_country_switch(scen_countries60) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p60_region_BE_shr(t_all,i) = sum(i_to_iso(i,iso), p60_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + +$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; +** Harmonize until sm_fix_SSP2 if not coupled or emulator +loop(t$(m_year(t) <= sm_fix_SSP2), + i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"R34M410-SSP2-NPi2025"); +); +$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 until sm_fix_SSP2 if not coupled or emulator +loop(t$(m_year(t) <= sm_fix_SSP2), + i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"R34M410-SSP2-NPi2025"); +); +$endif diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/presolve.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/presolve.gms new file mode 100644 index 0000000000..cf417d4621 --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/presolve.gms @@ -0,0 +1,62 @@ +*** | (C) 2008-2025 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_dem_bioen.fx(i,kap) = 0; +v60_2ndgen_bioenergy_dem_dedicated.fx(i,kall) = 0; +v60_2ndgen_bioenergy_dem_dedicated.up(i,kbe60) = Inf; +v60_2ndgen_bioenergy_dem_residues.fx(i,kall) = 0; +v60_2ndgen_bioenergy_dem_residues.up(i,kres) = Inf; + +if(m_year(t) <= sm_fix_SSP2, + i60_1stgen_bioenergy_dem(t,i,kall) = + f60_1stgen_bioenergy_dem(t,i,"const2020",kall); + i60_res_2ndgenBE_dem(t,i) = + f60_res_2ndgenBE_dem(t,i,"ssp2"); + i60_1stgen_bioenergy_subsidy(t) = + s60_bioenergy_1st_subsidy; + i60_2ndgen_bioenergy_subsidy(t) = 0; +else + i60_1stgen_bioenergy_dem(t,i,kall) = + f60_1stgen_bioenergy_dem(t,i,"%c60_1stgen_biodem%",kall); + i60_res_2ndgenBE_dem(t,i) = + f60_res_2ndgenBE_dem(t,i,"%c60_res_2ndgenBE_dem%"); +); + +* for residues used as bioenergy feedstock switch off +* overwrite the scenario harmonization for the historical period +* and set the residue demand to "off" for the whole period +$if "%c60_res_2ndgenBE_dem%" == "off" i60_res_2ndgenBE_dem(t,i) = f60_res_2ndgenBE_dem(t,i,"off"); + +$ifthen "%c60_price_implementation%" == "exp" + if(m_year(t) > sm_fix_SSP2, + i60_1stgen_bioenergy_subsidy(t) = + (s60_bioenergy_1st_price / 8) * (8 ** (1 / (2100 - sm_fix_SSP2))) ** (m_year(t) - sm_fix_SSP2); + i60_2ndgen_bioenergy_subsidy(t) = + (s60_bioenergy_2nd_price / 8) * (8 ** (1 / (2100 - sm_fix_SSP2))) ** (m_year(t) - sm_fix_SSP2); + ); +$elseif "%c60_price_implementation%" == "const" + if(m_year(t) > sm_fix_SSP2, + i60_1stgen_bioenergy_subsidy(t) = + s60_bioenergy_1st_price; + i60_2ndgen_bioenergy_subsidy(t) = + s60_bioenergy_2nd_price; + ); +$else + if(m_year(t) > sm_fix_SSP2, + i60_1stgen_bioenergy_subsidy(t) = + s60_bioenergy_1st_price / (2100 - sm_fix_SSP2) * (m_year(t) - sm_fix_SSP2); + i60_2ndgen_bioenergy_subsidy(t) = + s60_bioenergy_2nd_price / (2100 - sm_fix_SSP2) * (m_year(t) - sm_fix_SSP2); + ); +$endif + +* Enforce floor for first generation bioenergy subsidy +i60_1stgen_bioenergy_subsidy(t)$(i60_1stgen_bioenergy_subsidy(t) < s60_bioenergy_1st_subsidy) + = s60_bioenergy_1st_subsidy; + +* Add minimal bioenergy demand in case of zero demand or very small demand to avoid zero prices +i60_bioenergy_dem(t,i)$(i60_bioenergy_dem(t,i) < s60_2ndgen_bioenergy_dem_min) = s60_2ndgen_bioenergy_dem_min; diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/realization.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/realization.gms new file mode 100644 index 0000000000..fc85865968 --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/realization.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2025 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 + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/scaling.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/scaling.gms new file mode 100644 index 0000000000..3614620d04 --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_bioenergy_utility.scale(i) = 10e4; diff --git a/modules/60_bioenergy/1st2ndgen_priced_feb24/sets.gms b/modules/60_bioenergy/1st2ndgen_priced_feb24/sets.gms new file mode 100644 index 0000000000..ce043a67d3 --- /dev/null +++ b/modules/60_bioenergy/1st2ndgen_priced_feb24/sets.gms @@ -0,0 +1,123 @@ +*** | (C) 2008-2025 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 + +*############################################################################### +*######################## R SECTION START (SETS) ############################### +* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY +* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! + +sets + + scen2nd60 second generation bioenergy scenarios + / PIK_GDP, + PIK_H2C, + PIK_HBL, + PIK_HOS, + PIK_LIN, + PIK_NPI, + PIK_OPT, + R21M42-SDP-NDC, + R21M42-SDP-NPi, + R21M42-SDP-PkBudg1000, + R21M42-SDP-PkBudg1100, + R21M42-SDP-PkBudg900, + R21M42-SSP1-NDC, + R21M42-SSP1-NPi, + R21M42-SSP1-PkBudg1100, + R21M42-SSP1-PkBudg1300, + R21M42-SSP1-PkBudg900, + R21M42-SSP2-NDC, + R21M42-SSP2-NPi, + R21M42-SSP2-PkBudg1100, + R21M42-SSP2-PkBudg1300, + R21M42-SSP2-PkBudg900, + R21M42-SSP5-NDC, + R21M42-SSP5-NPi, + R21M42-SSP5-PkBudg1100, + R21M42-SSP5-PkBudg1300, + R21M42-SSP5-PkBudg900, + R2M41-SSP2-Budg1300, + R2M41-SSP2-Budg600, + 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, + R34BC-SSP2-PkBudg650-BCdef, + R34BC-SSP2-PkBudg650-BCdef-CTS01, + R34BC-SSP2-PkBudg650-BCdef-CTS01-BM70, + R34BC-SSP2-PkBudg650-BCpess-CTS01-BM70, + R34M410-SSP1-NPi2025, + R34M410-SSP1-PkBudg1000, + R34M410-SSP1-PkBudg650, + R34M410-SSP2_lowEn-NPi2025, + R34M410-SSP2_lowEn-PkBudg1000, + R34M410-SSP2_lowEn-PkBudg650, + R34M410-SSP2-NPi2025, + R34M410-SSP2-PkBudg1000, + R34M410-SSP2-PkBudg650, + R34M410-SSP3-NPi2025, + R34M410-SSP3-PkBudg1000, + R34M410-SSP3-rollBack, + R34M410-SSP5-NPi2025, + R34M410-SSP5-PkBudg1000, + R34M410-SSP5-PkBudg650, + SSPDB-SSP1-19-IMAGE, + SSPDB-SSP1-19-REMIND-MAGPIE, + SSPDB-SSP1-26-IMAGE, + SSPDB-SSP1-26-REMIND-MAGPIE, + SSPDB-SSP1-34-IMAGE, + SSPDB-SSP1-34-REMIND-MAGPIE, + SSPDB-SSP1-45-IMAGE, + SSPDB-SSP1-45-REMIND-MAGPIE, + SSPDB-SSP1-Ref-IMAGE, + SSPDB-SSP1-Ref-REMIND-MAGPIE, + SSPDB-SSP2-19-REMIND-MAGPIE, + SSPDB-SSP2-26-REMIND-MAGPIE, + SSPDB-SSP2-34-REMIND-MAGPIE, + SSPDB-SSP2-45-REMIND-MAGPIE, + SSPDB-SSP2-60-REMIND-MAGPIE, + SSPDB-SSP2-Ref-REMIND-MAGPIE, + SSPDB-SSP5-19-REMIND-MAGPIE, + SSPDB-SSP5-26-REMIND-MAGPIE, + SSPDB-SSP5-34-REMIND-MAGPIE, + SSPDB-SSP5-45-REMIND-MAGPIE, + SSPDB-SSP5-60-REMIND-MAGPIE, + SSPDB-SSP5-Ref-REMIND-MAGPIE / + +; +*######################### R SECTION END (SETS) ################################ +*############################################################################### + +sets + + kbe60(kall) bio energy activities + / betr, begr / + + k1st60(kall) 1st generation bioenergy carriers + / oils, ethanol / + + scen1st60 first generation bioenergy scenarios + / const2020, const2030, phaseout2020 / + + scen2ndres60 residues for second generation bioenergy scenarios + / ssp1, ssp2, ssp3, ssp4, ssp5, sdp, off / + +; diff --git a/modules/60_bioenergy/1stgen_priced_dec18/declarations.gms b/modules/60_bioenergy/1stgen_priced_dec18/declarations.gms index e067d6a72e..1a9b0b6d3f 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/declarations.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,16 +10,18 @@ parameters i60_bioenergy_dem(t,i) Regional bioenergy demand per year (mio. GJ per yr) i60_res_2ndgenBE_dem(t,i) Regional residue demand for 2nd generation bioenergy per year (mio. GJ per yr) i60_1stgen_bioenergy_dem(t,i,kall) Regional 1st generation bioenergy demand (mio. GJ per yr) + p60_region_BE_shr(t_all,i) Bioenergy demand share of the region (1) + p60_country_switch(iso) Switch indicating whether country is selected for selected bioenergy demand scenario (1) ; positive variables - vm_dem_bioen(i,kall) Regional bioenergy demand (mio. tDM per yr) - v60_2ndgen_bioenergy_dem_dedicated(i,kall) bioenergy demand which can come from different regions (mio. GJ per yr) - v60_2ndgen_bioenergy_dem_residues(i,kall) bioenergy demand which can come from different product types (mio. GJ per yr) + vm_dem_bioen(i,kall) Regional bioenergy demand (mio. tDM per yr) + v60_2ndgen_bioenergy_dem_dedicated(i,kall) Bioenergy demand which can come from different regions (mio. GJ per yr) + v60_2ndgen_bioenergy_dem_residues(i,kall) Bioenergy demand which can come from different product types (mio. GJ per yr) ; variables - vm_bioenergy_utility(i) Utility as negative costs for producing bioenergy (USD05MER per yr) + vm_bioenergy_utility(i) Utility as negative costs for producing bioenergy (USD17MER per yr) ; equations @@ -27,19 +29,19 @@ equations q60_bioenergy_glo Global 2nd generation dedicated bioenergy demand (mio. GJ per yr) q60_bioenergy_reg(i) Regional 2nd generation dedicated bioenergy demand (mio. GJ per yr) q60_res_2ndgenBE(i) Regional residue demand for 2nd generation bioenergy (mio. GJ per yr) - q60_bioenergy_incentive(i) Incentive to produce bioenergy (mio. USD05MER per yr) + q60_bioenergy_incentive(i) Incentive to produce bioenergy (mio. USD17MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_dem_bioen(t,i,kall,type) Regional bioenergy demand (mio. tDM per yr) - ov60_2ndgen_bioenergy_dem_dedicated(t,i,kall,type) bioenergy demand which can come from different regions (mio. GJ per yr) - ov60_2ndgen_bioenergy_dem_residues(t,i,kall,type) bioenergy demand which can come from different product types (mio. GJ per yr) - ov_bioenergy_utility(t,i,type) Utility as negative costs for producing bioenergy (USD05MER per yr) + ov60_2ndgen_bioenergy_dem_dedicated(t,i,kall,type) Bioenergy demand which can come from different regions (mio. GJ per yr) + ov60_2ndgen_bioenergy_dem_residues(t,i,kall,type) Bioenergy demand which can come from different product types (mio. GJ per yr) + ov_bioenergy_utility(t,i,type) Utility as negative costs for producing bioenergy (USD17MER per yr) oq60_bioenergy(t,i,kall,type) Global total bioenergy demand (mio. GJ per yr) oq60_bioenergy_glo(t,type) Global 2nd generation dedicated bioenergy demand (mio. GJ per yr) oq60_bioenergy_reg(t,i,type) Regional 2nd generation dedicated bioenergy demand (mio. GJ per yr) oq60_res_2ndgenBE(t,i,type) Regional residue demand for 2nd generation bioenergy (mio. GJ per yr) - oq60_bioenergy_incentive(t,i,type) Incentive to produce bioenergy (mio. USD05MER per yr) + oq60_bioenergy_incentive(t,i,type) Incentive to produce bioenergy (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/60_bioenergy/1stgen_priced_dec18/equations.gms b/modules/60_bioenergy/1stgen_priced_dec18/equations.gms index 1df8c1213b..72177c04fd 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/equations.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,9 +6,6 @@ *** | Contact: magpie@pik-potsdam.de *' @equations - - -*' @code *' Total demand for bioenergy comes from different origins *' 1st generation bioenergy demand is a fixed trajectory of minimum production *' requirements. Second generation bioenergy splits into a Demand @@ -18,7 +15,7 @@ q60_bioenergy(i2,kall) .. vm_dem_bioen(i2,kall) * fm_attributes("ge",kall) =g= - sum(ct,i60_1stgen_bioenergy_dem(ct,i2,kall) ) + + sum(ct, i60_1stgen_bioenergy_dem(ct,i2,kall)) + v60_2ndgen_bioenergy_dem_dedicated(i2,kall) + v60_2ndgen_bioenergy_dem_residues(i2,kall) ; @@ -66,10 +63,10 @@ q60_res_2ndgenBE(i2) .. =g= sum(ct,i60_res_2ndgenBE_dem(ct,i2)); -*' Finally, an incentive of 300 USD05MER per ton is provided for the production of 1st generation +*' Finally, an incentive is provided for the production of 1st generation *' bioenergy from oils and ethanol even beyond the exogeneous minimum demand. *' The incentive is kept low, but should provide a more realistic *' overproduction from couple products. q60_bioenergy_incentive(i2).. vm_bioenergy_utility(i2) - =e= sum(k1st60, vm_dem_bioen(i2,k1st60) * (-300)); + =e= sum(k1st60, vm_dem_bioen(i2,k1st60) * fm_attributes("ge",k1st60) * (-s60_bioenergy_1st_subsidy)); diff --git a/modules/60_bioenergy/1stgen_priced_dec18/input.gms b/modules/60_bioenergy/1stgen_priced_dec18/input.gms index e514be6ffe..9509116688 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/input.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/input.gms @@ -1,16 +1,47 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 + scen_countries60(iso) countries to be affected by 2nd generation bionergy demand scenario / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; scalars c60_biodem_level bioenergy demand level indicator 1 for regional and 0 for global demand (1) / 1 / + s60_bioenergy_1st_subsidy first generation bioenergy subsidy (USD17MER per GJ) / 6.5 / + s60_2ndgen_bioenergy_dem_min Minimum dedicated 2nd generation bioenergy demand assumed in each region (mio. GJ per yr) / 1 / ; -$setglobal c60_2ndgen_biodem R2M41-SSP2-NPi +$setglobal c60_2ndgen_biodem R34M410-SSP2-NPi2025 +$setglobal c60_2ndgen_biodem_noselect R34M410-SSP2-NPi2025 + $if "%c60_2ndgen_biodem%" == "coupling" table f60_bioenergy_dem_coupling(t_all,i) Bioenergy demand (regional) (mio. GJ per yr) $if "%c60_2ndgen_biodem%" == "coupling" $ondelim diff --git a/modules/60_bioenergy/1stgen_priced_dec18/not_used.txt b/modules/60_bioenergy/1stgen_priced_dec18/not_used.txt deleted file mode 100644 index 4b81dfbae2..0000000000 --- a/modules/60_bioenergy/1stgen_priced_dec18/not_used.txt +++ /dev/null @@ -1,8 +0,0 @@ -# | (C) 2008-2019 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 - -name,type,reason diff --git a/modules/60_bioenergy/1stgen_priced_dec18/postsolve.gms b/modules/60_bioenergy/1stgen_priced_dec18/postsolve.gms index bd0be2de15..4172d2bb17 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/postsolve.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms b/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms index e0cf540850..00ceae3f5b 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms @@ -1,19 +1,36 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -$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); -$else i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"%c60_2ndgen_biodem%"); -$endif -* Add minimal bioenergy demand in case of zero demand to avoid zero prices -i60_bioenergy_dem(t,i)$(i60_bioenergy_dem(t,i) = 0) = 0.01; - -i60_res_2ndgenBE_dem(t,i) = - f60_res_2ndgenBE_dem(t,i,"%c60_res_2ndgenBE_dem%"); +****** Region price share for 2nd generation bioenergy demand scenario: +* Country switch to determine countries for which scenario shall be applied. +* In the default case, the selected scneario (c60_2ndgen_biodem) affects +* all countries. +p60_country_switch(iso) = 0; +p60_country_switch(scen_countries60) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p60_region_BE_shr(t_all,i) = sum(i_to_iso(i,iso), p60_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); -i60_1stgen_bioenergy_dem(t,i,kall) = - f60_1stgen_bioenergy_dem(t,i,"%c60_1stgen_biodem%",kall); +$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; +** Harmonize until sm_fix_SSP2 if not coupled or emulator +loop(t$(m_year(t) <= sm_fix_SSP2), + i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"R34M410-SSP2-NPi2025"); +); +$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 until sm_fix_SSP2 if not coupled or emulator +loop(t$(m_year(t) <= sm_fix_SSP2), + i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"R34M410-SSP2-NPi2025"); +); +$endif diff --git a/modules/60_bioenergy/1stgen_priced_dec18/presolve.gms b/modules/60_bioenergy/1stgen_priced_dec18/presolve.gms index 22fc241776..6f24b3fb4f 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/presolve.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/presolve.gms @@ -1,8 +1,32 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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_dem_bioen.fx(i2,kap)=0; +vm_dem_bioen.fx(i,kap) = 0; +v60_2ndgen_bioenergy_dem_dedicated.fx(i,kall) = 0; +v60_2ndgen_bioenergy_dem_dedicated.up(i,kbe60) = Inf; +v60_2ndgen_bioenergy_dem_residues.fx(i,kall) = 0; +v60_2ndgen_bioenergy_dem_residues.up(i,kres) = Inf; + +if(m_year(t) <= sm_fix_SSP2, + i60_1stgen_bioenergy_dem(t,i,kall) = + f60_1stgen_bioenergy_dem(t,i,"const2020",kall); + i60_res_2ndgenBE_dem(t,i) = + f60_res_2ndgenBE_dem(t,i,"ssp2"); +else + i60_1stgen_bioenergy_dem(t,i,kall) = + f60_1stgen_bioenergy_dem(t,i,"%c60_1stgen_biodem%",kall); + i60_res_2ndgenBE_dem(t,i) = + f60_res_2ndgenBE_dem(t,i,"%c60_res_2ndgenBE_dem%"); +); + +* for residues used as bioenergy feedstock switch off +* overwrite the scenario harmonization for the historical period +* and set the residue demand to "off" for the whole period +$if "%c60_res_2ndgenBE_dem%" == "off" i60_res_2ndgenBE_dem(t,i) = f60_res_2ndgenBE_dem(t,i,"off"); + +* Add minimal bioenergy demand in case of zero demand or very small demand to avoid zero prices +i60_bioenergy_dem(t,i)$(i60_bioenergy_dem(t,i) < s60_2ndgen_bioenergy_dem_min) = s60_2ndgen_bioenergy_dem_min; diff --git a/modules/60_bioenergy/1stgen_priced_dec18/realization.gms b/modules/60_bioenergy/1stgen_priced_dec18/realization.gms index 3cea85cd8d..978995901d 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/realization.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,6 +10,7 @@ $Ifi "%phase%" == "sets" $include "./modules/60_bioenergy/1stgen_priced_dec18/se $Ifi "%phase%" == "declarations" $include "./modules/60_bioenergy/1stgen_priced_dec18/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/60_bioenergy/1stgen_priced_dec18/input.gms" $Ifi "%phase%" == "equations" $include "./modules/60_bioenergy/1stgen_priced_dec18/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/60_bioenergy/1stgen_priced_dec18/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/60_bioenergy/1stgen_priced_dec18/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/60_bioenergy/1stgen_priced_dec18/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/60_bioenergy/1stgen_priced_dec18/postsolve.gms" diff --git a/modules/60_bioenergy/1stgen_priced_dec18/scaling.gms b/modules/60_bioenergy/1stgen_priced_dec18/scaling.gms new file mode 100644 index 0000000000..3614620d04 --- /dev/null +++ b/modules/60_bioenergy/1stgen_priced_dec18/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_bioenergy_utility.scale(i) = 10e4; diff --git a/modules/60_bioenergy/1stgen_priced_dec18/sets.gms b/modules/60_bioenergy/1stgen_priced_dec18/sets.gms index dce6a52c85..ce043a67d3 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/sets.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/sets.gms @@ -1,13 +1,114 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 +*############################################################################### +*######################## R SECTION START (SETS) ############################### +* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY +* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! + sets - kbe60(kcr) bio energy activities + scen2nd60 second generation bioenergy scenarios + / PIK_GDP, + PIK_H2C, + PIK_HBL, + PIK_HOS, + PIK_LIN, + PIK_NPI, + PIK_OPT, + R21M42-SDP-NDC, + R21M42-SDP-NPi, + R21M42-SDP-PkBudg1000, + R21M42-SDP-PkBudg1100, + R21M42-SDP-PkBudg900, + R21M42-SSP1-NDC, + R21M42-SSP1-NPi, + R21M42-SSP1-PkBudg1100, + R21M42-SSP1-PkBudg1300, + R21M42-SSP1-PkBudg900, + R21M42-SSP2-NDC, + R21M42-SSP2-NPi, + R21M42-SSP2-PkBudg1100, + R21M42-SSP2-PkBudg1300, + R21M42-SSP2-PkBudg900, + R21M42-SSP5-NDC, + R21M42-SSP5-NPi, + R21M42-SSP5-PkBudg1100, + R21M42-SSP5-PkBudg1300, + R21M42-SSP5-PkBudg900, + R2M41-SSP2-Budg1300, + R2M41-SSP2-Budg600, + 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, + R34BC-SSP2-PkBudg650-BCdef, + R34BC-SSP2-PkBudg650-BCdef-CTS01, + R34BC-SSP2-PkBudg650-BCdef-CTS01-BM70, + R34BC-SSP2-PkBudg650-BCpess-CTS01-BM70, + R34M410-SSP1-NPi2025, + R34M410-SSP1-PkBudg1000, + R34M410-SSP1-PkBudg650, + R34M410-SSP2_lowEn-NPi2025, + R34M410-SSP2_lowEn-PkBudg1000, + R34M410-SSP2_lowEn-PkBudg650, + R34M410-SSP2-NPi2025, + R34M410-SSP2-PkBudg1000, + R34M410-SSP2-PkBudg650, + R34M410-SSP3-NPi2025, + R34M410-SSP3-PkBudg1000, + R34M410-SSP3-rollBack, + R34M410-SSP5-NPi2025, + R34M410-SSP5-PkBudg1000, + R34M410-SSP5-PkBudg650, + SSPDB-SSP1-19-IMAGE, + SSPDB-SSP1-19-REMIND-MAGPIE, + SSPDB-SSP1-26-IMAGE, + SSPDB-SSP1-26-REMIND-MAGPIE, + SSPDB-SSP1-34-IMAGE, + SSPDB-SSP1-34-REMIND-MAGPIE, + SSPDB-SSP1-45-IMAGE, + SSPDB-SSP1-45-REMIND-MAGPIE, + SSPDB-SSP1-Ref-IMAGE, + SSPDB-SSP1-Ref-REMIND-MAGPIE, + SSPDB-SSP2-19-REMIND-MAGPIE, + SSPDB-SSP2-26-REMIND-MAGPIE, + SSPDB-SSP2-34-REMIND-MAGPIE, + SSPDB-SSP2-45-REMIND-MAGPIE, + SSPDB-SSP2-60-REMIND-MAGPIE, + SSPDB-SSP2-Ref-REMIND-MAGPIE, + SSPDB-SSP5-19-REMIND-MAGPIE, + SSPDB-SSP5-26-REMIND-MAGPIE, + SSPDB-SSP5-34-REMIND-MAGPIE, + SSPDB-SSP5-45-REMIND-MAGPIE, + SSPDB-SSP5-60-REMIND-MAGPIE, + SSPDB-SSP5-Ref-REMIND-MAGPIE / + +; +*######################### R SECTION END (SETS) ################################ +*############################################################################### + +sets + + kbe60(kall) bio energy activities / betr, begr / k1st60(kall) 1st generation bioenergy carriers @@ -16,33 +117,7 @@ sets scen1st60 first generation bioenergy scenarios / const2020, const2030, phaseout2020 / - scen2nd60 second generation bioenergy scenarios - /R2M41-SSP2-Budg1300,R2M41-SSP2-Budg600, - R2M41-SSP2-Budg950,R2M41-SSP2-NDC,R2M41-SSP2-NPi, - SSPDB-SSP1-20-IMAGE,SSPDB-SSP1-20-REMIND-MAGPIE, - SSPDB-SSP1-26-IMAGE,SSPDB-SSP1-26-REMIND-MAGPIE, - SSPDB-SSP1-34-IMAGE,SSPDB-SSP1-34-REMIND-MAGPIE, - SSPDB-SSP1-37-REMIND-MAGPIE, - SSPDB-SSP1-45-IMAGE,SSPDB-SSP1-45-REMIND-MAGPIE, - SSPDB-SSP1-Ref-IMAGE,SSPDB-SSP1-Ref-REMIND-MAGPIE, - SSPDB-SSP2-18-MESSAGE-GLOBIOM,SSPDB-SSP2-19-MESSAGE-GLOBIOM, - SSPDB-SSP2-20-MESSAGE-GLOBIOM,SSPDB-SSP2-20-REMIND-MAGPIE, - SSPDB-SSP2-26-MESSAGE-GLOBIOM,SSPDB-SSP2-26-REMIND-MAGPIE, - SSPDB-SSP2-34-MESSAGE-GLOBIOM,SSPDB-SSP2-34-REMIND-MAGPIE, - SSPDB-SSP2-37-REMIND-MAGPIE, - SSPDB-SSP2-45-MESSAGE-GLOBIOM,SSPDB-SSP2-45-REMIND-MAGPIE, - SSPDB-SSP2-60-MESSAGE-GLOBIOM,SSPDB-SSP2-60-REMIND-MAGPIE, - SSPDB-SSP2-Ref-MESSAGE-GLOBIOM,SSPDB-SSP2-Ref-REMIND-MAGPIE, - SSPDB-SSP3-34-AIM-CGE,SSPDB-SSP3-45-AIM-CGE, - SSPDB-SSP3-60-AIM-CGE,SSPDB-SSP4-26-GCAM4, - SSPDB-SSP4-34-GCAM4,SSPDB-SSP4-45-GCAM4, - SSPDB-SSP4-60-GCAM4,SSPDB-SSP4-Ref-GCAM4, - SSPDB-SSP5-20-REMIND-MAGPIE,SSPDB-SSP5-26-REMIND-MAGPIE, - SSPDB-SSP5-34-REMIND-MAGPIE,SSPDB-SSP5-37-REMIND-MAGPIE, - SSPDB-SSP5-45-REMIND-MAGPIE,SSPDB-SSP5-60-REMIND-MAGPIE, - SSPDB-SSP5-Ref-REMIND-MAGPIE/ - scen2ndres60 residues for second generation bioenergy scenarios - / ssp1, ssp2, ssp3, ssp4, ssp5, off / + / ssp1, ssp2, ssp3, ssp4, ssp5, sdp, off / ; diff --git a/modules/60_bioenergy/module.gms b/modules/60_bioenergy/module.gms index a7838c67f8..78d753c458 100644 --- a/modules/60_bioenergy/module.gms +++ b/modules/60_bioenergy/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -15,9 +15,10 @@ *' In addition to calculation of bioenergy quantities, the costs associated with *' the production are provided to the objective function in the [11_costs] module. *' -*' @authors Jan Philipp Dietrich +*' @authors Jan Philipp Dietrich, Jan Steinhauser *###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%bioenergy%" == "1st2ndgen_priced_feb24" $include "./modules/60_bioenergy/1st2ndgen_priced_feb24/realization.gms" $Ifi "%bioenergy%" == "1stgen_priced_dec18" $include "./modules/60_bioenergy/1stgen_priced_dec18/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/62_material/exo_flexreg_apr16/declarations.gms b/modules/62_material/exo_flexreg_apr16/declarations.gms index 9223622cf2..f423d5e0b3 100644 --- a/modules/62_material/exo_flexreg_apr16/declarations.gms +++ b/modules/62_material/exo_flexreg_apr16/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,11 +8,17 @@ scalar s62_historical Switch for turning off historical material demand (1) / 1 / + s62_growth_rate_bioplastic Logistic growth rate of bioplastic demand (1); ; parameters - p62_dem_material_lh(i,kall) Material demand in last historical timestep (mio. tDM per yr) - p62_dem_food_lh(i) Food demand in last historical timestep (mio. tDM per yr) + p62_dem_material_lastcalibyear(i,kall) Material demand in last historical timestep (mio. tDM per yr) + p62_dem_food_lastcalibyear(i) Food demand in last historical timestep (mio. tDM per yr) + p62_scaling_factor(i) Scaling factor for material demand (1) + p62_dem_bioplastic(t,i) Demand for bioplastic (mio. t per yr) + p62_bioplastic_substrate(t,i,kall) Regional biomass needed as substrate for bioplastic production (mio. tDM per yr) + p62_bioplastic_substrate_lastcalibyear(i,kall) Bioplastic substrate in last historical timestep (mio. tDM per yr) + p62_bioplastic_substrate_double_counted(t,i,kall) Bioplastic substrate counted both in general material demand and demand for bioplastic (mio. tDM per yr) ; positive variables @@ -20,12 +26,14 @@ positive variables ; equations - q62_dem_material(i,kall) Estimating material demand (mio. tDM per yr) + q62_dem_material(i,kall_excl_kforestry) Estimating material demand (mio. tDM per yr) + q62_dem_material_forestry(i,kforestry) Demand for forestry products (mio. tDM per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_dem_material(t,i,kall,type) Demand for material usage (mio. tDM per yr) - oq62_dem_material(t,i,kall,type) Estimating material demand (mio. tDM per yr) + ov_dem_material(t,i,kall,type) Demand for material usage (mio. tDM per yr) + oq62_dem_material(t,i,kall_excl_kforestry,type) Estimating material demand (mio. tDM per yr) + oq62_dem_material_forestry(t,i,kforestry,type) Demand for forestry products (mio. tDM per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/62_material/exo_flexreg_apr16/equations.gms b/modules/62_material/exo_flexreg_apr16/equations.gms index f8c1358162..12af43033b 100644 --- a/modules/62_material/exo_flexreg_apr16/equations.gms +++ b/modules/62_material/exo_flexreg_apr16/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -14,19 +14,25 @@ *' as the scaled version of material demand in last historical timestep *' depending on a scaling factor. This scaling factor is calculated as the *' ratio beween the food demand from last timestep and the food demand from -*' the last historical time step. +*' the last historical time step. If an exogenous target for bioplastic production +*' is set, increasing material demand (substrate) for bioplastic production is included. +*' For historic years it is assumed that this demand is already part of the +*' general material demand, therefore the double-counted demand is subtracted. - q62_dem_material(i2,kall) .. - vm_dem_material(i2,kall) + q62_dem_material(i2,kall_excl_kforestry) .. + vm_dem_material(i2,kall_excl_kforestry) =e= - sum(ct,f62_dem_material(ct,i2,kall))*s62_historical + sum(ct,f62_dem_material(ct,i2,kall_excl_kforestry))*s62_historical + - (p62_dem_material_lh(i2,kall)* - sum(kfo, vm_dem_food.l(i2,kfo)) - /(p62_dem_food_lh(i2))) - *(1-s62_historical) + (p62_dem_material_lastcalibyear(i2,kall_excl_kforestry) * p62_scaling_factor(i2)) + *(1-s62_historical) + sum(ct, p62_bioplastic_substrate(ct, i2, kall_excl_kforestry)) - + sum(ct, p62_bioplastic_substrate_double_counted(ct,i2,kall_excl_kforestry)) ; -*' Results are stored in the interface `vm_dem_material` and this interface -*' is then used in demand([16_demand]) module as a part of global supply-demand -*' balance for crop, livestock, secondary products and residues. +*' Demand for forestry products (wood and woodfuel) is provided by the timber module. + + q62_dem_material_forestry(i2,kforestry) .. + vm_dem_material(i2,kforestry) + =e= + sum(ct, pm_demand_forestry(ct,i2,kforestry)); + ; diff --git a/modules/62_material/exo_flexreg_apr16/input.gms b/modules/62_material/exo_flexreg_apr16/input.gms index 581e7f2751..b3504722ea 100644 --- a/modules/62_material/exo_flexreg_apr16/input.gms +++ b/modules/62_material/exo_flexreg_apr16/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,3 +10,23 @@ table f62_dem_material(t_all,i,kall) Historical material demand (mio. tDM) $ondelim $include "./modules/62_material/input/f62_dem_material.cs3" $offdelim; + +parameter f62_biomass2bioplastic_conversion_ratio(kall) Biomass demand for one unit of bioplastics (tDM biomass per tDM bioplastic) +/ +$ondelim +$include "./modules/62_material/input/f62_bioplastic2biomass.csv" +$offdelim +/ +; + +parameter f62_hist_dem_bioplastic(t_all) Historic demand for bioplastics (mio. tDM) +/ +$ondelim +$include "./modules/62_material/input/f62_hist_dem_bioplastic.csv" +$offdelim +/ +; + +scalar s62_include_bioplastic switch whether future bioplastic demand should be included (0 or 1) / 1 /; +scalar s62_max_dem_bioplastic maximum demand for bioplastics (mio. tDM per yr) / 0 /; +scalar s62_midpoint_dem_bioplastic midpoint of logistic function for bioplastic demand (yr) / 2050 /; diff --git a/modules/62_material/exo_flexreg_apr16/postsolve.gms b/modules/62_material/exo_flexreg_apr16/postsolve.gms index 207d51ea5a..ad93b8fa8f 100644 --- a/modules/62_material/exo_flexreg_apr16/postsolve.gms +++ b/modules/62_material/exo_flexreg_apr16/postsolve.gms @@ -1,28 +1,33 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 *' @code -*' The parameters `p62_dem_material_lh` and `p62_dem_food_lh` are overwritten -*' based on each time step optimization, in order to be used in next step. +*' The parameters `p62_dem_material_lastcalibyear` and `p62_dem_food_lastcalibyear` +*' are overwritten based on each time step optimization, in order to be used in next step. *' This is only carried out when the model is still running in the time period *' before (and including) y2010 with this model version. if (sum(sameas(t_past,t),1) = 1, - p62_dem_material_lh(i,kall) = f62_dem_material(t,i,kall); - p62_dem_food_lh(i)= sum(kfo, vm_dem_food.l(i,kfo)); + p62_dem_material_lastcalibyear(i,kall) = f62_dem_material(t,i,kall); + p62_dem_food_lastcalibyear(i) = sum(kfo, vm_dem_food.l(i,kfo)); ); + *' @stop *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_dem_material(t,i,kall,"marginal") = vm_dem_material.m(i,kall); - oq62_dem_material(t,i,kall,"marginal") = q62_dem_material.m(i,kall); - ov_dem_material(t,i,kall,"level") = vm_dem_material.l(i,kall); - oq62_dem_material(t,i,kall,"level") = q62_dem_material.l(i,kall); - ov_dem_material(t,i,kall,"upper") = vm_dem_material.up(i,kall); - oq62_dem_material(t,i,kall,"upper") = q62_dem_material.up(i,kall); - ov_dem_material(t,i,kall,"lower") = vm_dem_material.lo(i,kall); - oq62_dem_material(t,i,kall,"lower") = q62_dem_material.lo(i,kall); + ov_dem_material(t,i,kall,"marginal") = vm_dem_material.m(i,kall); + oq62_dem_material(t,i,kall_excl_kforestry,"marginal") = q62_dem_material.m(i,kall_excl_kforestry); + oq62_dem_material_forestry(t,i,kforestry,"marginal") = q62_dem_material_forestry.m(i,kforestry); + ov_dem_material(t,i,kall,"level") = vm_dem_material.l(i,kall); + oq62_dem_material(t,i,kall_excl_kforestry,"level") = q62_dem_material.l(i,kall_excl_kforestry); + oq62_dem_material_forestry(t,i,kforestry,"level") = q62_dem_material_forestry.l(i,kforestry); + ov_dem_material(t,i,kall,"upper") = vm_dem_material.up(i,kall); + oq62_dem_material(t,i,kall_excl_kforestry,"upper") = q62_dem_material.up(i,kall_excl_kforestry); + oq62_dem_material_forestry(t,i,kforestry,"upper") = q62_dem_material_forestry.up(i,kforestry); + ov_dem_material(t,i,kall,"lower") = vm_dem_material.lo(i,kall); + oq62_dem_material(t,i,kall_excl_kforestry,"lower") = q62_dem_material.lo(i,kall_excl_kforestry); + oq62_dem_material_forestry(t,i,kforestry,"lower") = q62_dem_material_forestry.lo(i,kforestry); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/62_material/exo_flexreg_apr16/preloop.gms b/modules/62_material/exo_flexreg_apr16/preloop.gms index 574ba9989f..4ae4c8c0fc 100644 --- a/modules/62_material/exo_flexreg_apr16/preloop.gms +++ b/modules/62_material/exo_flexreg_apr16/preloop.gms @@ -1,9 +1,30 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 - p62_dem_material_lh(i,kall) =0; - p62_dem_food_lh(i)=1; + p62_dem_material_lastcalibyear(i,kall) = 0; + p62_dem_food_lastcalibyear(i) = 1; + p62_dem_bioplastic(t,i) = 0; + +* Bioplastic demand is based on historic values up to 2020, and either set to zero for +* future years, kept constant at the value of 2020, or following a logistic function with +* given midpoint and maximum if a bioplastic production target is exogenously set. +* Global bioplastic demand is distributed to regions proportional to population due to lack of better data. + +p62_dem_bioplastic(t,i) = f62_hist_dem_bioplastic(t) * (im_pop(t,i) / sum(i2, im_pop(t,i2))); +p62_dem_bioplastic(t,i)$(m_year(t)>2020) = f62_hist_dem_bioplastic("y2020") * (im_pop("y2020",i) / sum(i2, im_pop("y2020",i2))); + +if (s62_max_dem_bioplastic <> 0, + s62_growth_rate_bioplastic = log((s62_max_dem_bioplastic/f62_hist_dem_bioplastic("y2020")) - 1)/(s62_midpoint_dem_bioplastic-2020); + p62_dem_bioplastic(t,i)$(m_year(t)>2020) = s62_max_dem_bioplastic / (1 + exp(-s62_growth_rate_bioplastic*(m_year(t)-s62_midpoint_dem_bioplastic))) * (im_pop(t,i) / sum(i2, im_pop(t,i2))); +); + +if (s62_include_bioplastic = 0, + p62_dem_bioplastic(t,i)$(m_year(t)>2020) = 0; +); + +* translate bioplastic demand to biomass demand using conversion factors between bioplastic and the different biomass sources +p62_bioplastic_substrate(t,i,kall) = p62_dem_bioplastic(t,i) * f62_biomass2bioplastic_conversion_ratio(kall); diff --git a/modules/62_material/exo_flexreg_apr16/presolve.gms b/modules/62_material/exo_flexreg_apr16/presolve.gms index e9bd1c982c..526c3af713 100644 --- a/modules/62_material/exo_flexreg_apr16/presolve.gms +++ b/modules/62_material/exo_flexreg_apr16/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -18,4 +18,28 @@ else s62_historical=0; ); +p62_scaling_factor(i) = 1; +p62_scaling_factor(i)$(p62_dem_food_lastcalibyear(i) > 0) = sum(kfo, vm_dem_food.l(i,kfo)) / p62_dem_food_lastcalibyear(i); + *' @stop + +* In t_past, biomass demand for bioplastic is already included in the general material demand, which is +* scaled for future years. Therefore we calculate the amount of biomass that is counted twice, and subtract +* it in the final biomass demand equation. +if (sum(sameas(t_past,t),1) = 1, + p62_bioplastic_substrate_double_counted(t,i,kall) = p62_bioplastic_substrate(t,i,kall); + p62_bioplastic_substrate_lastcalibyear(i,kall) = min(p62_bioplastic_substrate(t,i,kall), f62_dem_material(t,i,kall)); +else + if (s62_include_bioplastic = 0, + p62_bioplastic_substrate_double_counted(t,i,kall) = 0; + else + p62_bioplastic_substrate_double_counted(t,i,kall) = p62_bioplastic_substrate_lastcalibyear(i,kall) * p62_scaling_factor(i); + ); +); + +* FAO data for material demand does not cover begr and betr. +* Therefore, in contrast to the other crops, begr and betr demand as bioplastic substrate +* is not already included in the general material demand. +* Thus, we set the double counted demand to zero for begr and betr. +p62_bioplastic_substrate_double_counted(t,i,"begr") = 0; +p62_bioplastic_substrate_double_counted(t,i,"betr") = 0; diff --git a/modules/62_material/exo_flexreg_apr16/realization.gms b/modules/62_material/exo_flexreg_apr16/realization.gms index c48e6f03fa..dd7899e05f 100644 --- a/modules/62_material/exo_flexreg_apr16/realization.gms +++ b/modules/62_material/exo_flexreg_apr16/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -12,6 +12,9 @@ *' material module based on historical data. The assumption that material demand *' grows proportional to food demand is a simplification that can be justified *' by the minor importance of non-bioenergy material usage of agricultural products. +*' In addition, biomass demand for bioplastic production is included, with +*' future bioplastic production kept constant or following a logistic curve +*' if a bioplastic production target is exogenously set. *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/62_material/exo_flexreg_apr16/sets.gms" diff --git a/modules/62_material/exo_flexreg_apr16/sets.gms b/modules/62_material/exo_flexreg_apr16/sets.gms index 3a0f70f6a5..97c8f76074 100644 --- a/modules/62_material/exo_flexreg_apr16/sets.gms +++ b/modules/62_material/exo_flexreg_apr16/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -13,4 +13,14 @@ sets a1,a2,b1,b2, history, SSP2_lowls,SSP2_lowcal / + + kall_excl_kforestry(kall) All products in the sectoral version excluding wood and woodfuel + / + tece,maiz,trce,rice_pro,soybean,rapeseed,groundnut,sunflower,oilpalm,puls_pro, + potato,cassav_sp,sugr_cane,sugr_beet,others,cottn_pro,foddr, pasture, begr, betr, + oils,oilcakes,sugar,molasses,alcohol,ethanol,distillers_grain,brans,scp,fibres, + livst_rum, livst_pig,livst_chick, livst_egg, livst_milk, fish, + res_cereals, res_fibrous, res_nonfibrous + / + ; diff --git a/modules/62_material/input/files b/modules/62_material/input/files index 7da2fb95c9..066a7ebcfd 100644 --- a/modules/62_material/input/files +++ b/modules/62_material/input/files @@ -1,2 +1,4 @@ * list of files that are required here f62_dem_material.cs3 +f62_bioplastic2biomass.csv +f62_hist_dem_bioplastic.csv \ No newline at end of file diff --git a/modules/62_material/module.gms b/modules/62_material/module.gms index 553c43aa9a..a74f3cce60 100644 --- a/modules/62_material/module.gms +++ b/modules/62_material/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -15,8 +15,10 @@ *' category, the use for bioenergy (oils and ethanol) has been excluded *' and is accounted for in the demand for bioenergy. Material demand in this *' context can be considered as a subset of "other utils" category of FAO. +*' In addition, increasing material demand for bioplastic production can be +*' included by setting a target bioplastic demand. -*' @authors Benjamin Bodirsky +*' @authors Benjamin Bodirsky, Debbora Leip *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%material%" == "exo_flexreg_apr16" $include "./modules/62_material/exo_flexreg_apr16/realization.gms" diff --git a/modules/70_livestock/fbask_jan16/declarations.gms b/modules/70_livestock/fbask_jan16/declarations.gms index 75e55626be..9ae26fa9fd 100644 --- a/modules/70_livestock/fbask_jan16/declarations.gms +++ b/modules/70_livestock/fbask_jan16/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,30 +7,63 @@ positive variables - vm_dem_feed(i,kap,kall) Regional feed demand including byproducts (mio. tDM per yr) + v70_feed_intake_pre(i,kap,kall) Regional feed intake (pre-calculation) including byproducts (mio. tDM per yr) + vm_dem_feed(i,kap,kall) Regional feed demand including byproducts (mio. tDM per yr) + vm_cost_prod_livst(i,factors) Livestock factor costs (mio. USD17MER per yr) + vm_cost_prod_fish(i) Fish factor costs (mio. USD17MER per yr) +; + +variables + vm_feed_balanceflow(i,kap,kall) Regional feed balance flows (mio. tDM) + vm_feed_intake(i,kap,kall) Regional feed intake including byproducts (mio. tDM per yr) ; equations - q70_feed(i,kap,kall) Regional feed demand - q70_cost_prod_liv(i,kall) Regional factor input costs for livestock production - q70_cost_prod_fish(i) Regional factor input costs for fish production + q70_feed_intake_pre(i,kap,kall) Regional feed intake pre-calculation + q70_feed_intake(i,kap,kall) Regional feed intake + q70_feed(i,kap,kall) Regional feed demand + q70_feed_balanceflow(i,kli_rum) Regional feed balance flow calculations for ruminant products + q70_cost_prod_liv_labor(i) Regional labor costs for livestock production + q70_cost_prod_liv_capital(i) Regional capital costs for livestock production + q70_cost_prod_fish(i) Regional factor input costs for fish production ; parameters + p70_endo_scavenging_flag(i,kli_rum) Flag indicating regions where pasture balance flows (e.g., due to scavenging) exceed threshold relative to pasture demand (1) + pc70_dem_feed_pasture(i,kli_rum) Pasture feed demand of the previous time step (mio. tDM per yr) im_slaughter_feed_share(t_all,i,kap,attributes) Share of feed that is incorporated in animal biomass (1) i70_livestock_productivity(t_all,i,sys) Productivity indicator for livestock production (t FM per animal per yr) im_feed_baskets(t_all,i,kap,kall) Feed baskets in tDM per tDM livestock product (1) - p70_cattle_stock_proxy(t,i) Proxy for cattle stocks needed to fullfil domestic food demand (mio. animals per yr) + p70_cattle_stock_proxy(t,i) Proxy for cattle stocks needed to fullfil food demand for ruminant meat (mio. animals per yr) + p70_milk_cow_proxy(t,i) Proxy for milk cows needed to fullfil food demand for milk (mio. animals per yr) + p70_cattle_feed_pc_proxy(t,i,kli_rd) Proxy for daily per capita feed demand for pasture biomass driven by demand for beef and dairy products (tDM per capita per day) p70_incr_cattle(t,i) Change in estimated cattle stocks attributed to food demand projections (1) pm_past_mngmnt_factor(t,i) Regional pasture management intensification factor (1) + i70_cereal_scp_fadeout(t_all,i) Cereal feed fadeout (share 0-1) to be replaced by SCP (1) + i70_foddr_scp_fadeout(t_all,i) Fodder fadeout (share 0-1) to be replaced by SCP (1) + p70_country_switch(iso) Switch indicating whether country is affected by feed scenarios (1) + p70_feedscen_region_shr(t_all,i) Weighted share of region with regards to feed scenario of countries (1) + i70_cost_regr(i,kap,cost_regr) Regression coefficients for livestock factor requirements (1) + i70_fac_req_livst(t_all,i,kli) Factor requirements (USD17MER per tDM) + p70_cereal_subst_fader(t_all) Cereal feed substitution with SCP fader (1) + p70_foddr_subst_fader(t_all) Foddr substitution with SCP fader (1) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_dem_feed(t,i,kap,kall,type) Regional feed demand including byproducts (mio. tDM per yr) - oq70_feed(t,i,kap,kall,type) Regional feed demand - oq70_cost_prod_liv(t,i,kall,type) Regional factor input costs for livestock production - oq70_cost_prod_fish(t,i,type) Regional factor input costs for fish production + ov70_feed_intake_pre(t,i,kap,kall,type) Regional feed intake (pre-calculation) including byproducts (mio. tDM per yr) + ov_dem_feed(t,i,kap,kall,type) Regional feed demand including byproducts (mio. tDM per yr) + ov_cost_prod_livst(t,i,factors,type) Livestock factor costs (mio. USD17MER per yr) + ov_cost_prod_fish(t,i,type) Fish factor costs (mio. USD17MER per yr) + ov_feed_balanceflow(t,i,kap,kall,type) Regional feed balance flows (mio. tDM) + ov_feed_intake(t,i,kap,kall,type) Regional feed intake including byproducts (mio. tDM per yr) + oq70_feed_intake_pre(t,i,kap,kall,type) Regional feed intake pre-calculation + oq70_feed_intake(t,i,kap,kall,type) Regional feed intake + oq70_feed(t,i,kap,kall,type) Regional feed demand + oq70_feed_balanceflow(t,i,kli_rum,type) Regional feed balance flow calculations for ruminant products + oq70_cost_prod_liv_labor(t,i,type) Regional labor costs for livestock production + oq70_cost_prod_liv_capital(t,i,type) Regional capital costs for livestock production + oq70_cost_prod_fish(t,i,type) Regional factor input costs for fish production ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/70_livestock/fbask_jan16/equations.gms b/modules/70_livestock/fbask_jan16/equations.gms index 75c7d75ab0..3c594fb25b 100644 --- a/modules/70_livestock/fbask_jan16/equations.gms +++ b/modules/70_livestock/fbask_jan16/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -12,12 +12,35 @@ *' inconsistencies with the FAO inventory of national feed use in the case of *' crops as well as consideration of alternative feed sources that reduce e.g. *' the demand for grazed biomass like scavenging and roadside grazing are -*' balanced out by the parameter `fm_feed_balanceflow`. +*' balanced out by the variable `vm_feed_balanceflow`. q70_feed(i2,kap,kall) .. vm_dem_feed(i2,kap,kall) =g= vm_prod_reg(i2,kap) - *sum(ct,f70_feed_baskets(ct,i2,kap,kall,"%c70_feed_scen%")) - +sum(ct,fm_feed_balanceflow(ct,i2,kap,kall)); + *sum(ct,im_feed_baskets(ct,i2,kap,kall)) + +sum(ct,vm_feed_balanceflow(i2,kap,kall)); + +*' Feed balance flows from feed sources that reduce the demand for grazed biomass +*' like scavenging are for future time steps assumed to depend on pasture feed demand: + +q70_feed_balanceflow(i2,kli_rum) .. + vm_feed_balanceflow(i2,kli_rum,"pasture") =e= + (sum(ct,fm_feed_balanceflow(ct,i2,kli_rum,"pasture")))$(p70_endo_scavenging_flag(i2,kli_rum)=0) + - (vm_prod_reg(i2,kli_rum)*sum(ct,im_feed_baskets(ct,i2,kli_rum,"pasture")) + *s70_scavenging_ratio)$(p70_endo_scavenging_flag(i2,kli_rum)>0); + +*' In contrast to feed demand, which always accounts for feed balance flows, the inclusion +*' of feed balance flows to feed intake is reduced or switched off by the use of +*' `s70_feed_intake_weight_balanceflow`: + +q70_feed_intake_pre(i2,kap,kall) .. + v70_feed_intake_pre(i2,kap,kall) =e= vm_prod_reg(i2,kap) + *sum(ct,im_feed_baskets(ct,i2,kap,kall)); + +q70_feed_intake(i2,kap,kall) .. + vm_feed_intake(i2,kap,kall) =e= + v70_feed_intake_pre(i2,kap,kall)*(1-s70_feed_intake_weight_balanceflow) + + vm_dem_feed(i2,kap,kall)*s70_feed_intake_weight_balanceflow; + *' Factor requirement costs (e.g. labour, capital, but without costs for feed) *' of livestock production depend on the amount of production and the per-unit @@ -26,14 +49,22 @@ q70_feed(i2,kap,kall) .. *' productivity. Here, factor costs rise with intensification. The per-unit *' costs for non-ruminants and fish are assumed to be independent from *' productivity trajectories for simplification. Therefore, -*' `f70_cost_regr(kli,"cost_regr_b")` is set to zero in the case of livestock +*' `i70_cost_regr(i,kli,"cost_regr_b")` is set to zero in the case of livestock *' products generated in monogastric systems. -q70_cost_prod_liv(i2,kli) .. - vm_cost_prod(i2,kli) =e= vm_prod_reg(i2,kli) - *(f70_cost_regr(kli,"cost_regr_a") + f70_cost_regr(kli,"cost_regr_b") - *sum((ct, sys_to_kli(sys,kli)),f70_livestock_productivity(ct,i2,sys,"%c70_feed_scen%"))); +*' To account for increased hourly labor costs and producitivity in case of an external +*' wage scenario, the total labor costs are scaled by the corresponding increase in hourly +*' labor costs and the related productivity gain from [36_employment]. + +q70_cost_prod_liv_labor(i2) .. + vm_cost_prod_livst(i2,"labor") =e= sum(kli, vm_prod_reg(i2,kli) * sum(ct, i70_fac_req_livst(ct,i2,kli))) + *sum(ct, pm_factor_cost_shares(ct,i2,"labor")) + *sum(ct, (1/pm_productivity_gain_from_wages(ct,i2)) * (pm_hourly_costs(ct,i2,"scenario") / pm_hourly_costs(ct,i2,"baseline"))); + +q70_cost_prod_liv_capital(i2) .. + vm_cost_prod_livst(i2,"capital") =e= sum(kli, vm_prod_reg(i2,kli) * sum(ct, i70_fac_req_livst(ct,i2,kli))) + *sum(ct, pm_factor_cost_shares(ct,i2,"capital")); q70_cost_prod_fish(i2) .. - vm_cost_prod(i2,"fish") =e= - vm_prod_reg(i2,"fish")*f70_cost_regr("fish","cost_regr_a"); + vm_cost_prod_fish(i2) =e= + vm_prod_reg(i2,"fish")*i70_cost_regr(i2,"fish","cost_regr_a"); diff --git a/modules/70_livestock/fbask_jan16/feed_comp_beef.jpg b/modules/70_livestock/fbask_jan16/feed_comp_beef.jpg index af38c52eff..446ec0eecb 100644 Binary files a/modules/70_livestock/fbask_jan16/feed_comp_beef.jpg and b/modules/70_livestock/fbask_jan16/feed_comp_beef.jpg differ diff --git a/modules/70_livestock/fbask_jan16/feed_comp_dairy.jpg b/modules/70_livestock/fbask_jan16/feed_comp_dairy.jpg index a83b6df1f2..59588cd361 100644 Binary files a/modules/70_livestock/fbask_jan16/feed_comp_dairy.jpg and b/modules/70_livestock/fbask_jan16/feed_comp_dairy.jpg differ diff --git a/modules/70_livestock/fbask_jan16/feed_conv.jpg b/modules/70_livestock/fbask_jan16/feed_conv.jpg index 121a2f9965..04849ddb35 100644 Binary files a/modules/70_livestock/fbask_jan16/feed_conv.jpg and b/modules/70_livestock/fbask_jan16/feed_conv.jpg differ diff --git a/modules/70_livestock/fbask_jan16/input.gms b/modules/70_livestock/fbask_jan16/input.gms index 23462f0c7a..8d6cb33625 100644 --- a/modules/70_livestock/fbask_jan16/input.gms +++ b/modules/70_livestock/fbask_jan16/input.gms @@ -1,16 +1,36 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 - $setglobal c70_feed_scen ssp2 -* options: ssp1,ssp2,ssp3,ssp4,ssp5,constant +* options: SSP: ssp1, ssp2, ssp3, ssp4, ssp5 +* SDP: SDP, SDP_EI, SDP_MC, SDP_RC +* other: constant + +* Feed substitution scenarios including functional forms, targets and transition periods +* options: constant, +* lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, +* lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, +* lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 +$setglobal c70_cereal_scp_scen constant +$setglobal c70_foddr_scp_scen constant + +$setglobal c70_fac_req_regr glo +* options: glo, reg scalars - s70_pyld_intercept Intercept of linear relationship determining pasture intensification (1) / 0.24 / + s70_pyld_intercept Intercept of linear relationship determining pasture intensification (1) / 0.24 / + s70_past_mngmnt_factor_fix Year until the pasture management factor is fixed to 1 / 2005 / + s70_scavenging_ratio Ratio to adjust estimated pasture feed demand using scavenged feed sources (1) / 0.385 / + s70_feed_intake_weight_balanceflow Weight for including feed balance flows in future feed intake calculation (1) / 1 / + s70_subst_functional_form Switch for functional form of feed substitution scenario fader (1) / 1 / + s70_feed_substitution_start Feed substitution start year / 2025 / + s70_feed_substitution_target Feed substitution target year / 2050 / + s70_cereal_scp_substitution Cereal feed substitution with SCP share (1) / 0 / + s70_foddr_scp_substitution Fodder substitution with SCP share (1) / 0 / ; table f70_feed_baskets(t_all,i,kap,kall,feed_scen70) Feed baskets in tDM per tDM livestock product (1) @@ -28,7 +48,7 @@ $ondelim $include "./modules/70_livestock/fbask_jan16/input/f70_livestock_productivity.cs3" $offdelim; -table f70_cost_regr(kap,cost_regr) Factor requirements livestock (USD04 per tDM (A) and USD (B)) +table f70_cost_regr(kap,cost_regr) Factor requirements livestock (USD17MER per tDM (A) and USD17MER (B)) $ondelim $include "./modules/70_livestock/fbask_jan16/input/f70_capit_liv_regr.csv" $offdelim @@ -48,3 +68,46 @@ $ondelim $include "./modules/70_livestock/fbask_jan16/input/f70_pyld_slope_reg.cs4" $offdelim /; + +table f70_hist_factor_costs_livst(t_all,i,kli) Historical factor costs in livestock production (mio. USD17MER) +$ondelim +$include "./modules/70_livestock/fbask_jan16/input/f70_hist_factor_costs_livst.cs3" +$offdelim +; + +table f70_hist_prod_livst(t_all,i,kli,attributes) Historical production quantity of livestock products (mio. t) +$ondelim +$include "./modules/70_livestock/fbask_jan16/input/f70_hist_prod_livst.cs3" +$offdelim +; + +* Set-switch for countries affected by country-specific exogenous diet scenario +* Default: all iso countries selected +sets + scen_countries70(iso) countries to be affected by selected feed sceanrio / + ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; diff --git a/modules/70_livestock/fbask_jan16/input/files b/modules/70_livestock/fbask_jan16/input/files index a2fde6f429..8de709636b 100644 --- a/modules/70_livestock/fbask_jan16/input/files +++ b/modules/70_livestock/fbask_jan16/input/files @@ -5,3 +5,5 @@ f70_livestock_productivity.cs3 f70_capit_liv_regr.csv f70_slaughter_feed_share.cs4 f70_pyld_slope_reg.cs4 +f70_hist_factor_costs_livst.cs3 +f70_hist_prod_livst.cs3 diff --git a/modules/70_livestock/fbask_jan16/not_used.txt b/modules/70_livestock/fbask_jan16/not_used.txt index 4b81dfbae2..c6ba37d1b9 100644 --- a/modules/70_livestock/fbask_jan16/not_used.txt +++ b/modules/70_livestock/fbask_jan16/not_used.txt @@ -1,8 +1,2 @@ -# | (C) 2008-2019 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 - name,type,reason +pm_interest,input,Since no capital stocks are implemented there is no need to consider interest rates. diff --git a/modules/70_livestock/fbask_jan16/postsolve.gms b/modules/70_livestock/fbask_jan16/postsolve.gms index fd6dd07f07..c4d70b684b 100644 --- a/modules/70_livestock/fbask_jan16/postsolve.gms +++ b/modules/70_livestock/fbask_jan16/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,22 +6,60 @@ *** | Contact: magpie@pik-potsdam.de +pc70_dem_feed_pasture(i,kli_rum) = max(vm_dem_feed.l(i,kli_rum,"pasture"), 0.001); + *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_dem_feed(t,i,kap,kall,"marginal") = vm_dem_feed.m(i,kap,kall); - oq70_feed(t,i,kap,kall,"marginal") = q70_feed.m(i,kap,kall); - oq70_cost_prod_liv(t,i,kall,"marginal") = q70_cost_prod_liv.m(i,kall); - oq70_cost_prod_fish(t,i,"marginal") = q70_cost_prod_fish.m(i); - ov_dem_feed(t,i,kap,kall,"level") = vm_dem_feed.l(i,kap,kall); - oq70_feed(t,i,kap,kall,"level") = q70_feed.l(i,kap,kall); - oq70_cost_prod_liv(t,i,kall,"level") = q70_cost_prod_liv.l(i,kall); - oq70_cost_prod_fish(t,i,"level") = q70_cost_prod_fish.l(i); - ov_dem_feed(t,i,kap,kall,"upper") = vm_dem_feed.up(i,kap,kall); - oq70_feed(t,i,kap,kall,"upper") = q70_feed.up(i,kap,kall); - oq70_cost_prod_liv(t,i,kall,"upper") = q70_cost_prod_liv.up(i,kall); - oq70_cost_prod_fish(t,i,"upper") = q70_cost_prod_fish.up(i); - ov_dem_feed(t,i,kap,kall,"lower") = vm_dem_feed.lo(i,kap,kall); - oq70_feed(t,i,kap,kall,"lower") = q70_feed.lo(i,kap,kall); - oq70_cost_prod_liv(t,i,kall,"lower") = q70_cost_prod_liv.lo(i,kall); - oq70_cost_prod_fish(t,i,"lower") = q70_cost_prod_fish.lo(i); + ov70_feed_intake_pre(t,i,kap,kall,"marginal") = v70_feed_intake_pre.m(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"marginal") = vm_dem_feed.m(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"marginal") = vm_cost_prod_livst.m(i,factors); + ov_cost_prod_fish(t,i,"marginal") = vm_cost_prod_fish.m(i); + ov_feed_balanceflow(t,i,kap,kall,"marginal") = vm_feed_balanceflow.m(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"marginal") = vm_feed_intake.m(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"marginal") = q70_feed_intake_pre.m(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"marginal") = q70_feed_intake.m(i,kap,kall); + oq70_feed(t,i,kap,kall,"marginal") = q70_feed.m(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"marginal") = q70_feed_balanceflow.m(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"marginal") = q70_cost_prod_liv_labor.m(i); + oq70_cost_prod_liv_capital(t,i,"marginal") = q70_cost_prod_liv_capital.m(i); + oq70_cost_prod_fish(t,i,"marginal") = q70_cost_prod_fish.m(i); + ov70_feed_intake_pre(t,i,kap,kall,"level") = v70_feed_intake_pre.l(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"level") = vm_dem_feed.l(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"level") = vm_cost_prod_livst.l(i,factors); + ov_cost_prod_fish(t,i,"level") = vm_cost_prod_fish.l(i); + ov_feed_balanceflow(t,i,kap,kall,"level") = vm_feed_balanceflow.l(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"level") = vm_feed_intake.l(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"level") = q70_feed_intake_pre.l(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"level") = q70_feed_intake.l(i,kap,kall); + oq70_feed(t,i,kap,kall,"level") = q70_feed.l(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"level") = q70_feed_balanceflow.l(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"level") = q70_cost_prod_liv_labor.l(i); + oq70_cost_prod_liv_capital(t,i,"level") = q70_cost_prod_liv_capital.l(i); + oq70_cost_prod_fish(t,i,"level") = q70_cost_prod_fish.l(i); + ov70_feed_intake_pre(t,i,kap,kall,"upper") = v70_feed_intake_pre.up(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"upper") = vm_dem_feed.up(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"upper") = vm_cost_prod_livst.up(i,factors); + ov_cost_prod_fish(t,i,"upper") = vm_cost_prod_fish.up(i); + ov_feed_balanceflow(t,i,kap,kall,"upper") = vm_feed_balanceflow.up(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"upper") = vm_feed_intake.up(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"upper") = q70_feed_intake_pre.up(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"upper") = q70_feed_intake.up(i,kap,kall); + oq70_feed(t,i,kap,kall,"upper") = q70_feed.up(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"upper") = q70_feed_balanceflow.up(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"upper") = q70_cost_prod_liv_labor.up(i); + oq70_cost_prod_liv_capital(t,i,"upper") = q70_cost_prod_liv_capital.up(i); + oq70_cost_prod_fish(t,i,"upper") = q70_cost_prod_fish.up(i); + ov70_feed_intake_pre(t,i,kap,kall,"lower") = v70_feed_intake_pre.lo(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"lower") = vm_dem_feed.lo(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"lower") = vm_cost_prod_livst.lo(i,factors); + ov_cost_prod_fish(t,i,"lower") = vm_cost_prod_fish.lo(i); + ov_feed_balanceflow(t,i,kap,kall,"lower") = vm_feed_balanceflow.lo(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"lower") = vm_feed_intake.lo(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"lower") = q70_feed_intake_pre.lo(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"lower") = q70_feed_intake.lo(i,kap,kall); + oq70_feed(t,i,kap,kall,"lower") = q70_feed.lo(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"lower") = q70_feed_balanceflow.lo(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"lower") = q70_cost_prod_liv_labor.lo(i); + oq70_cost_prod_liv_capital(t,i,"lower") = q70_cost_prod_liv_capital.lo(i); + oq70_cost_prod_fish(t,i,"lower") = q70_cost_prod_fish.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/70_livestock/fbask_jan16/preloop.gms b/modules/70_livestock/fbask_jan16/preloop.gms index f53c7ec5cc..245328fc0b 100644 --- a/modules/70_livestock/fbask_jan16/preloop.gms +++ b/modules/70_livestock/fbask_jan16/preloop.gms @@ -1,15 +1,90 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 -im_slaughter_feed_share(t_all,i,kap,attributes) = - f70_slaughter_feed_share(t_all,i,kap,attributes,"%c70_feed_scen%"); -i70_livestock_productivity(t_all,i,sys) = - f70_livestock_productivity(t_all,i,sys,"%c70_feed_scen%"); +* assignment for the first time step: +pc70_dem_feed_pasture(i,kli_rum) = 0.001; -im_feed_baskets(t_all,i,kap,kall) = - f70_feed_baskets(t_all,i,kap,kall,"%c70_feed_scen%"); + +loop(t_all, + if(m_year(t_all) <= sm_fix_SSP2, + im_slaughter_feed_share(t_all,i,kap,attributes) = f70_slaughter_feed_share(t_all,i,kap,attributes,"ssp2"); + i70_livestock_productivity(t_all,i,sys) = f70_livestock_productivity(t_all,i,sys,"ssp2"); + im_feed_baskets(t_all,i,kap,kall) = f70_feed_baskets(t_all,i,kap,kall,"ssp2"); + else + im_slaughter_feed_share(t_all,i,kap,attributes) = f70_slaughter_feed_share(t_all,i,kap,attributes,"%c70_feed_scen%"); + i70_livestock_productivity(t_all,i,sys) = f70_livestock_productivity(t_all,i,sys,"%c70_feed_scen%"); + im_feed_baskets(t_all,i,kap,kall) = f70_feed_baskets(t_all,i,kap,kall,"%c70_feed_scen%"); + ); +); + +* set default livestock productivity to avoid division of zero in presolve.gms +i70_livestock_productivity(t_all,i,sys)$(i70_livestock_productivity(t_all,i,sys)=0) = 0.02; + +* Switch to determine countries for which feed substitution scenarios shall be applied. +* In the default case, the food scenario affects all countries when activated. +p70_country_switch(iso) = 0; +p70_country_switch(scen_countries70) = 1; + + +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p70_feedscen_region_shr(t_all,i) = sum(i_to_iso(i,iso), p70_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + + +if (s70_subst_functional_form = 1, + + m_linear_time_interpol(p70_cereal_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_cereal_scp_substitution); + m_linear_time_interpol(p70_foddr_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_foddr_scp_substitution); + +elseif s70_subst_functional_form = 2, + + m_sigmoid_time_interpol(p70_cereal_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_cereal_scp_substitution); + m_sigmoid_time_interpol(p70_foddr_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_foddr_scp_substitution); + +); + +* Feed substitution scenarios including functional forms, targets and transition periods +* Note: p70_feedscen_region_shr(t,i) is 1 in the default case) +i70_cereal_scp_fadeout(t_all,i) = 1 - p70_feedscen_region_shr(t_all,i)*p70_cereal_subst_fader(t_all); +i70_foddr_scp_fadeout(t_all,i) = 1 - p70_feedscen_region_shr(t_all,i)*p70_foddr_subst_fader(t_all); + + +*** Substitution of cereal feed (kcer70) with single-cell protein (SCP) based on Nr +* Before the substitution, kcer70 is converted from DM to Nr +* using fm_attributes("nr",kcer70). +* After the substitution of kcer70 with SCP (1-i70_cereal_scp_fadeout), SCP is converted +* back DM fm_attributes("nr","scp"). +im_feed_baskets(t_all,i,kap,"scp") = im_feed_baskets(t_all,i,kap,"scp") + + sum(kcer70, im_feed_baskets(t_all,i,kap,kcer70) * (1-i70_cereal_scp_fadeout(t_all,i)) * + fm_attributes("nr",kcer70)) / fm_attributes("nr","scp"); +im_feed_baskets(t_all,i,kap,kcer70) = + im_feed_baskets(t_all,i,kap,kcer70) * i70_cereal_scp_fadeout(t_all,i); + +*** Substitution of foddr feed with single-cell protein (SCP) based on Nr +* Before the substitution, foddr is converted from DM to Nr +* using fm_attributes("nr","foddr"). +* After the substitution of foddr with SCP (1-i70_foddr_scp_fadeout), SCP is converted +* back DM fm_attributes("nr","scp"). +im_feed_baskets(t_all,i,kap,"scp") = im_feed_baskets(t_all,i,kap,"scp") + + (im_feed_baskets(t_all,i,kap,"foddr") * (1-i70_foddr_scp_fadeout(t_all,i)) * + fm_attributes("nr","foddr")) / fm_attributes("nr","scp"); +im_feed_baskets(t_all,i,kap,"foddr") = + im_feed_baskets(t_all,i,kap,"foddr") * i70_foddr_scp_fadeout(t_all,i); + + +*** choosing between reginal and global factor requirements +$if "%c70_fac_req_regr%" == "glo" i70_cost_regr(i,kli,"cost_regr_a") = f70_cost_regr(kli,"cost_regr_a"); +$if "%c70_fac_req_regr%" == "reg" i70_cost_regr(i,kli,"cost_regr_a") = sum(t_past$(ord(t_past) eq card(t_past)), (f70_hist_factor_costs_livst(t_past,i,kli) / f70_hist_prod_livst(t_past,i,kli,"dm")) - f70_cost_regr(kli,"cost_regr_b") * sum(sys_to_kli(sys,kli),i70_livestock_productivity(t_past,i,sys))); + +i70_cost_regr(i,"fish",cost_regr) = f70_cost_regr("fish",cost_regr); +i70_cost_regr(i,kap,"cost_regr_b") = f70_cost_regr(kap,"cost_regr_b"); + +i70_fac_req_livst(t_all,i,kli) = i70_cost_regr(i,kli,"cost_regr_b") * sum(sys_to_kli(sys,kli), i70_livestock_productivity(t_all,i,sys)) + i70_cost_regr(i,kli,"cost_regr_a"); +* use historic livestock factor requirements for t_past if regional switch is on. Once regression has been updated this could also be included for global factor requirements +$if "%c70_fac_req_regr%" == "reg" i70_fac_req_livst(t_all,i,kli)$(m_year(t_all) <= sum(t_past$(ord(t_past) eq card(t_past)), m_year(t_past)) and m_year(t_all) > 1990) = (f70_hist_factor_costs_livst(t_all,i,kli) / f70_hist_prod_livst(t_all,i,kli,"dm")); diff --git a/modules/70_livestock/fbask_jan16/presolve.gms b/modules/70_livestock/fbask_jan16/presolve.gms index f32c77f105..94cccf1d7f 100644 --- a/modules/70_livestock/fbask_jan16/presolve.gms +++ b/modules/70_livestock/fbask_jan16/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,41 +6,65 @@ *** | Contact: magpie@pik-potsdam.de +vm_feed_balanceflow.fx(i,kap,kall) = fm_feed_balanceflow(t,i,kap,kall); +vm_feed_balanceflow.up(i,kli_rum,"pasture") = Inf; +vm_feed_balanceflow.lo(i,kli_rum,"pasture") = -Inf; + + +if (sum(sameas(t_past,t),1) = 1, + p70_endo_scavenging_flag(i,kli_rum) = 0; + if (ord(t) = smax(t2, ord(t2)$(t_past(t2))) AND card(t) > sum(t_all$(t(t_all) and t_past(t_all)), 1), + p70_endo_scavenging_flag(i,kli_rum) = - fm_feed_balanceflow(t-1,i,kli_rum,"pasture")/pc70_dem_feed_pasture(i,kli_rum); + p70_endo_scavenging_flag(i,kli_rum)$(p70_endo_scavenging_flag(i,kli_rum) < s70_scavenging_ratio) = 0; + ); +); + + *' @code -*' The fbask_jan16 realization of the livestock module also estimates an exogenous +*' The fbask_jan16 realization of the livestock module also estimates an exogenous *' pasture management factor `pm_past_mngmnt_factor` that is used to scale *' biophysical pasture yields in the module [14_yields]. *' The exogenous calculation of pasture management requires information on -*' the number of cattle reared to fulfil the domestic demand for ruminant -*' livestock products: +*' changes in the number of cattle reared to fulfil the food demand for ruminant +*' livestock products: p70_cattle_stock_proxy(t,i) = im_pop(t,i)*pm_kcal_pc_initial(t,i,"livst_rum") - /i70_livestock_productivity(t,i,"sys_beef"); + /i70_livestock_productivity(t,i,"sys_beef"); + +p70_milk_cow_proxy(t,i) = im_pop(t,i)*pm_kcal_pc_initial(t,i,"livst_milk") + /i70_livestock_productivity(t,i,"sys_dairy"); -*' The lower bound for `p70_cattle_stock_proxy` is set to 20% of initial cattle -*' stocks in 1995: +*' The lower bound for `p70_cattle_stock_proxy` and `p70_milk_cow_proxy` is +*' set to 20% of initial values in 1995: p70_cattle_stock_proxy(t,i)$(p70_cattle_stock_proxy(t,i) < 0.2*p70_cattle_stock_proxy("y1995",i)) = 0.2*p70_cattle_stock_proxy("y1995",i); +p70_milk_cow_proxy(t,i)$(p70_milk_cow_proxy(t,i) < 0.2*p70_milk_cow_proxy("y1995",i)) = 0.2*p70_milk_cow_proxy("y1995",i); -*' The parameter `p70_incr_cattle` describes the changes in cattle stocks +*' The parameter `p70_cattle_feed_pc_proxy` is a proxy for regional daily per capita +*' feed demand for pasture biomass driven by demand for beef and dairy products, +*' which is later used for weighted aggregation. +p70_cattle_feed_pc_proxy(t,i,kli_rd) = pm_kcal_pc_initial(t,i,kli_rd)*im_feed_baskets(t,i,kli_rd,"pasture")/(fm_nutrition_attributes(t,kli_rd,"kcal") * 10**6); + +*' The parameter `p70_incr_cattle` describes the changes in the number of cattle *' relative to the previous time step: -p70_incr_cattle(t,i) = 1$(ord(t)=1) - + (p70_cattle_stock_proxy(t,i)/p70_cattle_stock_proxy(t-1,i))$(ord(t)>1); +if (ord(t)>1, + p70_incr_cattle(t,i) = ( (p70_cattle_feed_pc_proxy(t,i,"livst_rum") + 10**(-6))* (p70_cattle_stock_proxy(t,i)/p70_cattle_stock_proxy(t-1,i)) + + (p70_cattle_feed_pc_proxy(t,i,"livst_milk") + 10**(-6)) * (p70_milk_cow_proxy(t,i)/p70_milk_cow_proxy(t-1,i)) ) + / sum(kli_rd, p70_cattle_feed_pc_proxy(t,i,kli_rd) + 10**(-6)); +else + p70_incr_cattle(t,i) = 1; +); -*' The pasture management factor is calculated by applying a linear relationship -*' that links changes in pasture management with changes in cattle stocks: +*' The pasture management factor is calculated by applying a linear relationship +*' that links changes in pasture management with changes in the number of cattle: -if (sum(sameas(t_past,t),1) = 1, +if (m_year(t) <= s70_past_mngmnt_factor_fix, pm_past_mngmnt_factor(t,i) = 1; -else - pm_past_mngmnt_factor(t,i) = ( (s70_pyld_intercept + f70_pyld_slope_reg(i)*p70_incr_cattle(t,i)**(5/(m_year(t)-m_year(t-1))) - )**((m_year(t)-m_year(t-1))/5) )*pm_past_mngmnt_factor(t-1,i); +else + pm_past_mngmnt_factor(t,i) = ( (s70_pyld_intercept + f70_pyld_slope_reg(i)*p70_incr_cattle(t,i)**(5/(m_year(t)-m_year(t-1))) + )**((m_year(t)-m_year(t-1))/5) )*pm_past_mngmnt_factor(t-1,i); ); *' @stop - - - - diff --git a/modules/70_livestock/fbask_jan16/realization.gms b/modules/70_livestock/fbask_jan16/realization.gms index 698dcf4d20..84eb6ab8ce 100644 --- a/modules/70_livestock/fbask_jan16/realization.gms +++ b/modules/70_livestock/fbask_jan16/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -84,6 +84,7 @@ $Ifi "%phase%" == "sets" $include "./modules/70_livestock/fbask_jan16/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/70_livestock/fbask_jan16/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/70_livestock/fbask_jan16/input.gms" $Ifi "%phase%" == "equations" $include "./modules/70_livestock/fbask_jan16/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/70_livestock/fbask_jan16/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/70_livestock/fbask_jan16/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/70_livestock/fbask_jan16/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/70_livestock/fbask_jan16/postsolve.gms" diff --git a/modules/70_livestock/fbask_jan16/scaling.gms b/modules/70_livestock/fbask_jan16/scaling.gms new file mode 100644 index 0000000000..20a556904d --- /dev/null +++ b/modules/70_livestock/fbask_jan16/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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_cost_prod_livst.scale(i,factors) = 10e5; +vm_cost_prod_fish.scale(i) = 10e5; diff --git a/modules/70_livestock/fbask_jan16/sets.gms b/modules/70_livestock/fbask_jan16/sets.gms index 37156bc508..83c2ff1e90 100644 --- a/modules/70_livestock/fbask_jan16/sets.gms +++ b/modules/70_livestock/fbask_jan16/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,11 +6,16 @@ *** | Contact: magpie@pik-potsdam.de sets + cost_regr Cost regression parameters /cost_regr_a,cost_regr_b/ + share_regr regression parameters for capital share calculation + /slope, intercept/ + feed_scen70 scenarios - / ssp1,ssp2,ssp3,ssp4,ssp5,constant / + / ssp1, ssp2, ssp3, ssp4, ssp5, constant, + SDP, SDP_EI, SDP_MC, SDP_RC / sys Livestock production systems /sys_pig, sys_beef, sys_chicken, sys_hen, sys_dairy/ @@ -30,4 +35,12 @@ sets sys_dairy .livst_milk / + kcer70(kall) Cereals + / tece, maiz, trce, rice_pro / + + fadeoutscen70 Feed substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, + lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / ; diff --git a/modules/70_livestock/fbask_jan16_sticky/declarations.gms b/modules/70_livestock/fbask_jan16_sticky/declarations.gms new file mode 100644 index 0000000000..e40a5fd9c4 --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/declarations.gms @@ -0,0 +1,76 @@ +*** | (C) 2008-2025 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 + + +positive variables + v70_feed_intake_pre(i,kap,kall) Regional feed intake (pre-calculation) including byproducts (mio. tDM per yr) + vm_dem_feed(i,kap,kall) Regional feed demand including byproducts (mio. tDM per yr) + vm_cost_prod_livst(i,factors) Livestock factor costs (mio. USD17MER per yr) + vm_cost_prod_fish(i) Fish factor costs (mio. USD17MER per yr) + v70_investment(i,kli) Investment in immobile farm capital (mio USD17MER per yr) +; + +variables + vm_feed_balanceflow(i,kap,kall) Regional feed balance flows (mio. tDM) + vm_feed_intake(i,kap,kall) Regional feed intake including byproducts (mio. tDM per yr) +; + +equations + q70_feed_intake_pre(i,kap,kall) Regional feed intake pre-calculation + q70_feed_intake(i,kap,kall) Regional feed intake + q70_feed(i,kap,kall) Regional feed demand + q70_feed_balanceflow(i,kli_rum) Regional feed balance flow calculations for ruminant products + q70_cost_prod_liv_labor(i) Regional labor costs for livestock production + q70_cost_prod_liv_capital(i) Regional investment costs in farm capital + q70_investment(i,kli) Regional investments into farm capital + q70_cost_prod_fish(i) Regional factor input costs for fish production +; + +parameters + p70_endo_scavenging_flag(i,kli_rum) Flag indicating regions where pasture balance flows (e.g., due to scavenging) exceed threshold relative to pasture demand (1) + pc70_dem_feed_pasture(i,kli_rum) Pasture feed demand of the previous time step (mio. tDM per yr) + im_slaughter_feed_share(t_all,i,kap,attributes) Share of feed that is incorporated in animal biomass (1) + i70_livestock_productivity(t_all,i,sys) Productivity indicator for livestock production (t FM per animal per yr) + im_feed_baskets(t_all,i,kap,kall) Feed baskets in tDM per tDM livestock product (1) + p70_cattle_stock_proxy(t,i) Proxy for cattle stocks needed to fullfil food demand for ruminant meat (mio. animals per yr) + p70_milk_cow_proxy(t,i) Proxy for milk cows needed to fullfil food demand for milk (mio. animals per yr) + p70_cattle_feed_pc_proxy(t,i,kli_rd) Proxy for daily per capita feed demand for pasture biomass driven by demand for beef and dairy products (tDM per capita per day) + p70_incr_cattle(t,i) Change in estimated cattle stocks attributed to food demand projections (1) + pm_past_mngmnt_factor(t,i) Regional pasture management intensification factor (1) + i70_cereal_scp_fadeout(t_all,i) Cereal feed fadeout (share 0-1) to be replaced by SCP (1) + i70_foddr_scp_fadeout(t_all,i) Fodder fadeout (share 0-1) to be replaced by SCP (1) + p70_country_switch(iso) Switch indicating whether country is affected by feed scenarios (1) + p70_feedscen_region_shr(t_all,i) Weighted share of region with regards to feed scenario of countries (1) + i70_cost_regr(i,kap,cost_regr) Regression coefficients for livestock factor requirements (1) + i70_fac_req_livst(t_all,i,kli) Factor requirements (USD17MER per tDM) + p70_cereal_subst_fader(t_all) Cereal feed substitution with SCP fader (1) + p70_foddr_subst_fader(t_all) Foddr substitution with SCP fader (1) + p70_capital_need(t,i,kli) Capital requirements per unit of output (USD17MER per ton DM) + p70_capital(t,i,kli) Preexisting immobile capital stocks before investment (mio USD17MER) + p70_initial_1995_prod(i,kli) Initial regional production of livestock products taken from 1995 (mio ton DM) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov70_feed_intake_pre(t,i,kap,kall,type) Regional feed intake (pre-calculation) including byproducts (mio. tDM per yr) + ov_dem_feed(t,i,kap,kall,type) Regional feed demand including byproducts (mio. tDM per yr) + ov_cost_prod_livst(t,i,factors,type) Livestock factor costs (mio. USD17MER per yr) + ov_cost_prod_fish(t,i,type) Fish factor costs (mio. USD17MER per yr) + ov70_investment(t,i,kli,type) Investment in immobile farm capital (mio USD17MER per yr) + ov_feed_balanceflow(t,i,kap,kall,type) Regional feed balance flows (mio. tDM) + ov_feed_intake(t,i,kap,kall,type) Regional feed intake including byproducts (mio. tDM per yr) + oq70_feed_intake_pre(t,i,kap,kall,type) Regional feed intake pre-calculation + oq70_feed_intake(t,i,kap,kall,type) Regional feed intake + oq70_feed(t,i,kap,kall,type) Regional feed demand + oq70_feed_balanceflow(t,i,kli_rum,type) Regional feed balance flow calculations for ruminant products + oq70_cost_prod_liv_labor(t,i,type) Regional labor costs for livestock production + oq70_cost_prod_liv_capital(t,i,type) Regional investment costs in farm capital + oq70_investment(t,i,kli,type) Regional investments into farm capital + oq70_cost_prod_fish(t,i,type) Regional factor input costs for fish production +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/70_livestock/fbask_jan16_sticky/equations.gms b/modules/70_livestock/fbask_jan16_sticky/equations.gms new file mode 100644 index 0000000000..3b84059825 --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/equations.gms @@ -0,0 +1,82 @@ +*** | (C) 2008-2025 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 + +*' Demand for different feed items is derived by multiplying the regional +*' livestock production with the respective feed baskets. Additionally, +*' inconsistencies with the FAO inventory of national feed use in the case of +*' crops as well as consideration of alternative feed sources that reduce e.g. +*' the demand for grazed biomass like scavenging and roadside grazing are +*' balanced out by the variable `vm_feed_balanceflow`. + +q70_feed(i2,kap,kall) .. + vm_dem_feed(i2,kap,kall) =g= vm_prod_reg(i2,kap) + *sum(ct,im_feed_baskets(ct,i2,kap,kall)) + +sum(ct,vm_feed_balanceflow(i2,kap,kall)); + +*' Feed balance flows from feed sources that reduce the demand for grazed biomass +*' like scavenging are for future time steps assumed to depend on pasture feed demand: + +q70_feed_balanceflow(i2,kli_rum) .. + vm_feed_balanceflow(i2,kli_rum,"pasture") =e= + (sum(ct,fm_feed_balanceflow(ct,i2,kli_rum,"pasture")))$(p70_endo_scavenging_flag(i2,kli_rum)=0) + - (vm_prod_reg(i2,kli_rum)*sum(ct,im_feed_baskets(ct,i2,kli_rum,"pasture")) + *s70_scavenging_ratio)$(p70_endo_scavenging_flag(i2,kli_rum)>0); + +*' In contrast to feed demand, which always accounts for feed balance flows, the inclusion +*' of feed balance flows to feed intake is reduced or switched off by the use of +*' `s70_feed_intake_weight_balanceflow`: + +q70_feed_intake_pre(i2,kap,kall) .. + v70_feed_intake_pre(i2,kap,kall) =e= vm_prod_reg(i2,kap) + *sum(ct,im_feed_baskets(ct,i2,kap,kall)); + +q70_feed_intake(i2,kap,kall) .. + vm_feed_intake(i2,kap,kall) =e= + v70_feed_intake_pre(i2,kap,kall)*(1-s70_feed_intake_weight_balanceflow) + + vm_dem_feed(i2,kap,kall)*s70_feed_intake_weight_balanceflow; + + +*' Factor requirement costs (e.g. labour, capital, but without costs for feed) +*' of livestock production depend on the amount of production and the per-unit +*' costs. For ruminant products (milk and meet), we use a regression of per-unit +*' factor costs from the GTAP database [@narayanan_gtap7_2008] and livestock +*' productivity. Here, factor costs rise with intensification. The per-unit +*' costs for non-ruminants and fish are assumed to be independent from +*' productivity trajectories for simplification. Therefore, +*' `i70_cost_regr(i,kli,"cost_regr_b")` is set to zero in the case of livestock +*' products generated in monogastric systems. + +*' To account for increased hourly labor costs and producitivity in case of an external +*' wage scenario, the total labor costs are scaled by the corresponding increase in hourly +*' labor costs and the related productivity gain from [36_employment]. + +q70_cost_prod_liv_labor(i2) .. + vm_cost_prod_livst(i2,"labor") =e= sum(kli, vm_prod_reg(i2,kli) * sum(ct, i70_fac_req_livst(ct,i2,kli))) + *sum(ct, pm_factor_cost_shares(ct,i2,"labor")) + *sum(ct, (1/pm_productivity_gain_from_wages(ct,i2)) * (pm_hourly_costs(ct,i2,"scenario") / pm_hourly_costs(ct,i2,"baseline"))); + + +q70_cost_prod_fish(i2) .. + vm_cost_prod_fish(i2) =e= + vm_prod_reg(i2,"fish")*i70_cost_regr(i2,"fish","cost_regr_a"); + +*** Section implementing the "sticky" part of the realization +*' Investment costs are calculated analogously to the `sticky_feb18` realization. The costs are annuitized, +*' and corrected to make sure that the annual depreciation of the current time-step is accounted for. +q70_cost_prod_liv_capital(i2).. + vm_cost_prod_livst(i2,"capital") =e= sum(kli,v70_investment(i2,kli)) + * ((1-s70_depreciation_rate)*sum(ct,pm_interest(ct,i2)/(1+pm_interest(ct,i2))) + s70_depreciation_rate); + +*' Each livestock activity requires a certain capital stock that depends on the production. +*' The following equations make sure that new land expansion is equipped +*' with capital stock, and that depreciation of pre-existing capital is replaced. +q70_investment(i2,kli).. + v70_investment(i2,kli) =g= vm_prod_reg(i2,kli) + * sum(ct, p70_capital_need(ct,i2,kli)) + - sum(ct, p70_capital(ct,i2,kli)); diff --git a/modules/70_livestock/fbask_jan16_sticky/input.gms b/modules/70_livestock/fbask_jan16_sticky/input.gms new file mode 100644 index 0000000000..11ad5edac5 --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/input.gms @@ -0,0 +1,115 @@ +*** | (C) 2008-2025 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 + +$setglobal c70_feed_scen ssp2 +* options: SSP: ssp1, ssp2, ssp3, ssp4, ssp5 +* SDP: SDP, SDP_EI, SDP_MC, SDP_RC +* other: constant + +* Feed substitution scenarios including functional forms, targets and transition periods +* options: constant, +* lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, +* lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, +* lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 +$setglobal c70_cereal_scp_scen constant +$setglobal c70_foddr_scp_scen constant + +$setglobal c70_fac_req_regr glo +* options: glo, reg + +scalars + s70_pyld_intercept Intercept of linear relationship determining pasture intensification (1) / 0.24 / + s70_past_mngmnt_factor_fix Year until the pasture management factor is fixed to 1 / 2005 / + s70_scavenging_ratio Ratio to adjust estimated pasture feed demand using scavenged feed sources (1) / 0.385 / + s70_feed_intake_weight_balanceflow Weight for including feed balance flows in future feed intake calculation (1) / 1 / + s70_subst_functional_form Switch for functional form of feed substitution scenario fader (1) / 1 / + s70_feed_substitution_start Feed substitution start year / 2025 / + s70_feed_substitution_target Feed substitution target year / 2050 / + s70_cereal_scp_substitution Cereal feed substitution with SCP share (1) / 0 / + s70_foddr_scp_substitution Fodder substitution with SCP share (1) / 0 / + s70_depreciation_rate Yearly depreciation rate for capital stocks / 0.05 / + s70_multiplicator_capital_need Multiplicator for capital need in livestock production / 1 / +; + +table f70_feed_baskets(t_all,i,kap,kall,feed_scen70) Feed baskets in tDM per tDM livestock product (1) +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_feed_baskets.cs3" +$offdelim; + +table fm_feed_balanceflow(t_all,i,kap,kall) Balanceflow balance difference between estimated feed baskets and FAO (mio. tDM) +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_feed_balanceflow.cs3" +$offdelim; + +table f70_livestock_productivity(t_all,i,sys,feed_scen70) Productivity indicator for livestock production (t FM per animal) +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_livestock_productivity.cs3" +$offdelim; + +table f70_cost_regr(kap,cost_regr) Factor requirements livestock (USD17MER per tDM (A) and USD17MER (B)) +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_capit_liv_regr.csv" +$offdelim +; + +parameter f70_slaughter_feed_share(t_all,i,kap,attributes,feed_scen70) Share of feed that is incorprated in animal biomass (1) +/ +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_slaughter_feed_share.cs4" +$offdelim +/ +; + +parameter f70_pyld_slope_reg(i) Regional slope of linear relationship determining pasture intensification (1) +/ +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_pyld_slope_reg.cs4" +$offdelim +/; + +table f70_hist_factor_costs_livst(t_all,i,kli) Historical factor costs in livestock production (mio. USD17MER) +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_hist_factor_costs_livst.cs3" +$offdelim +; + +table f70_hist_prod_livst(t_all,i,kli,attributes) Historical production quantity of livestock products (mio. t) +$ondelim +$include "./modules/70_livestock/fbask_jan16_sticky/input/f70_hist_prod_livst.cs3" +$offdelim +; + +* Set-switch for countries affected by country-specific exogenous diet scenario +* Default: all iso countries selected +sets + scen_countries70(iso) countries to be affected by selected feed sceanrio / + ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; diff --git a/modules/70_livestock/fbask_jan16_sticky/input/files b/modules/70_livestock/fbask_jan16_sticky/input/files new file mode 100644 index 0000000000..8de709636b --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/input/files @@ -0,0 +1,9 @@ +* list of files that are required here +f70_feed_baskets.cs3 +f70_feed_balanceflow.cs3 +f70_livestock_productivity.cs3 +f70_capit_liv_regr.csv +f70_slaughter_feed_share.cs4 +f70_pyld_slope_reg.cs4 +f70_hist_factor_costs_livst.cs3 +f70_hist_prod_livst.cs3 diff --git a/modules/70_livestock/fbask_jan16_sticky/postsolve.gms b/modules/70_livestock/fbask_jan16_sticky/postsolve.gms new file mode 100644 index 0000000000..ae0f1b6a2a --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/postsolve.gms @@ -0,0 +1,78 @@ +*** | (C) 2008-2025 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 + + +pc70_dem_feed_pasture(i,kli_rum) = max(vm_dem_feed.l(i,kli_rum,"pasture"), 0.001); + + +*' Capital update from the last investment +p70_capital(t+1,i,kli) = p70_capital(t,i,kli) + v70_investment.l(i,kli); + + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov70_feed_intake_pre(t,i,kap,kall,"marginal") = v70_feed_intake_pre.m(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"marginal") = vm_dem_feed.m(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"marginal") = vm_cost_prod_livst.m(i,factors); + ov_cost_prod_fish(t,i,"marginal") = vm_cost_prod_fish.m(i); + ov70_investment(t,i,kli,"marginal") = v70_investment.m(i,kli); + ov_feed_balanceflow(t,i,kap,kall,"marginal") = vm_feed_balanceflow.m(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"marginal") = vm_feed_intake.m(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"marginal") = q70_feed_intake_pre.m(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"marginal") = q70_feed_intake.m(i,kap,kall); + oq70_feed(t,i,kap,kall,"marginal") = q70_feed.m(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"marginal") = q70_feed_balanceflow.m(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"marginal") = q70_cost_prod_liv_labor.m(i); + oq70_cost_prod_liv_capital(t,i,"marginal") = q70_cost_prod_liv_capital.m(i); + oq70_investment(t,i,kli,"marginal") = q70_investment.m(i,kli); + oq70_cost_prod_fish(t,i,"marginal") = q70_cost_prod_fish.m(i); + ov70_feed_intake_pre(t,i,kap,kall,"level") = v70_feed_intake_pre.l(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"level") = vm_dem_feed.l(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"level") = vm_cost_prod_livst.l(i,factors); + ov_cost_prod_fish(t,i,"level") = vm_cost_prod_fish.l(i); + ov70_investment(t,i,kli,"level") = v70_investment.l(i,kli); + ov_feed_balanceflow(t,i,kap,kall,"level") = vm_feed_balanceflow.l(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"level") = vm_feed_intake.l(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"level") = q70_feed_intake_pre.l(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"level") = q70_feed_intake.l(i,kap,kall); + oq70_feed(t,i,kap,kall,"level") = q70_feed.l(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"level") = q70_feed_balanceflow.l(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"level") = q70_cost_prod_liv_labor.l(i); + oq70_cost_prod_liv_capital(t,i,"level") = q70_cost_prod_liv_capital.l(i); + oq70_investment(t,i,kli,"level") = q70_investment.l(i,kli); + oq70_cost_prod_fish(t,i,"level") = q70_cost_prod_fish.l(i); + ov70_feed_intake_pre(t,i,kap,kall,"upper") = v70_feed_intake_pre.up(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"upper") = vm_dem_feed.up(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"upper") = vm_cost_prod_livst.up(i,factors); + ov_cost_prod_fish(t,i,"upper") = vm_cost_prod_fish.up(i); + ov70_investment(t,i,kli,"upper") = v70_investment.up(i,kli); + ov_feed_balanceflow(t,i,kap,kall,"upper") = vm_feed_balanceflow.up(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"upper") = vm_feed_intake.up(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"upper") = q70_feed_intake_pre.up(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"upper") = q70_feed_intake.up(i,kap,kall); + oq70_feed(t,i,kap,kall,"upper") = q70_feed.up(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"upper") = q70_feed_balanceflow.up(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"upper") = q70_cost_prod_liv_labor.up(i); + oq70_cost_prod_liv_capital(t,i,"upper") = q70_cost_prod_liv_capital.up(i); + oq70_investment(t,i,kli,"upper") = q70_investment.up(i,kli); + oq70_cost_prod_fish(t,i,"upper") = q70_cost_prod_fish.up(i); + ov70_feed_intake_pre(t,i,kap,kall,"lower") = v70_feed_intake_pre.lo(i,kap,kall); + ov_dem_feed(t,i,kap,kall,"lower") = vm_dem_feed.lo(i,kap,kall); + ov_cost_prod_livst(t,i,factors,"lower") = vm_cost_prod_livst.lo(i,factors); + ov_cost_prod_fish(t,i,"lower") = vm_cost_prod_fish.lo(i); + ov70_investment(t,i,kli,"lower") = v70_investment.lo(i,kli); + ov_feed_balanceflow(t,i,kap,kall,"lower") = vm_feed_balanceflow.lo(i,kap,kall); + ov_feed_intake(t,i,kap,kall,"lower") = vm_feed_intake.lo(i,kap,kall); + oq70_feed_intake_pre(t,i,kap,kall,"lower") = q70_feed_intake_pre.lo(i,kap,kall); + oq70_feed_intake(t,i,kap,kall,"lower") = q70_feed_intake.lo(i,kap,kall); + oq70_feed(t,i,kap,kall,"lower") = q70_feed.lo(i,kap,kall); + oq70_feed_balanceflow(t,i,kli_rum,"lower") = q70_feed_balanceflow.lo(i,kli_rum); + oq70_cost_prod_liv_labor(t,i,"lower") = q70_cost_prod_liv_labor.lo(i); + oq70_cost_prod_liv_capital(t,i,"lower") = q70_cost_prod_liv_capital.lo(i); + oq70_investment(t,i,kli,"lower") = q70_investment.lo(i,kli); + oq70_cost_prod_fish(t,i,"lower") = q70_cost_prod_fish.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/70_livestock/fbask_jan16_sticky/preloop.gms b/modules/70_livestock/fbask_jan16_sticky/preloop.gms new file mode 100644 index 0000000000..8dd81acbb3 --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/preloop.gms @@ -0,0 +1,94 @@ +*** | (C) 2008-2025 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 + + +* assignment for the first time step: +pc70_dem_feed_pasture(i,kli_rum) = 0.001; + + +loop(t_all, + if(m_year(t_all) <= sm_fix_SSP2, + im_slaughter_feed_share(t_all,i,kap,attributes) = f70_slaughter_feed_share(t_all,i,kap,attributes,"ssp2"); + i70_livestock_productivity(t_all,i,sys) = f70_livestock_productivity(t_all,i,sys,"ssp2"); + im_feed_baskets(t_all,i,kap,kall) = f70_feed_baskets(t_all,i,kap,kall,"ssp2"); + else + im_slaughter_feed_share(t_all,i,kap,attributes) = f70_slaughter_feed_share(t_all,i,kap,attributes,"%c70_feed_scen%"); + i70_livestock_productivity(t_all,i,sys) = f70_livestock_productivity(t_all,i,sys,"%c70_feed_scen%"); + im_feed_baskets(t_all,i,kap,kall) = f70_feed_baskets(t_all,i,kap,kall,"%c70_feed_scen%"); + ); +); + +* set default livestock productivity to avoid division of zero in presolve.gms +i70_livestock_productivity(t_all,i,sys)$(i70_livestock_productivity(t_all,i,sys)=0) = 0.02; + +* Switch to determine countries for which feed substitution scenarios shall be applied. +* In the default case, the food scenario affects all countries when activated. +p70_country_switch(iso) = 0; +p70_country_switch(scen_countries70) = 1; + + +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by their population size. +p70_feedscen_region_shr(t_all,i) = sum(i_to_iso(i,iso), p70_country_switch(iso) * im_pop_iso(t_all,iso)) / sum(i_to_iso(i,iso), im_pop_iso(t_all,iso)); + + +if (s70_subst_functional_form = 1, + + m_linear_time_interpol(p70_cereal_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_cereal_scp_substitution); + m_linear_time_interpol(p70_foddr_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_foddr_scp_substitution); + +elseif s70_subst_functional_form = 2, + + m_sigmoid_time_interpol(p70_cereal_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_cereal_scp_substitution); + m_sigmoid_time_interpol(p70_foddr_subst_fader,s70_feed_substitution_start,s70_feed_substitution_target,0,s70_foddr_scp_substitution); + +); + +* Feed substitution scenarios including functional forms, targets and transition periods +* Note: p70_feedscen_region_shr(t,i) is 1 in the default case) +i70_cereal_scp_fadeout(t_all,i) = 1 - p70_feedscen_region_shr(t_all,i)*p70_cereal_subst_fader(t_all); +i70_foddr_scp_fadeout(t_all,i) = 1 - p70_feedscen_region_shr(t_all,i)*p70_foddr_subst_fader(t_all); + + +*** Substitution of cereal feed (kcer70) with single-cell protein (SCP) based on Nr +* Before the substitution, kcer70 is converted from DM to Nr +* using fm_attributes("nr",kcer70). +* After the substitution of kcer70 with SCP (1-i70_cereal_scp_fadeout), SCP is converted +* back DM fm_attributes("nr","scp"). +im_feed_baskets(t_all,i,kap,"scp") = im_feed_baskets(t_all,i,kap,"scp") + + sum(kcer70, im_feed_baskets(t_all,i,kap,kcer70) * (1-i70_cereal_scp_fadeout(t_all,i)) * + fm_attributes("nr",kcer70)) / fm_attributes("nr","scp"); +im_feed_baskets(t_all,i,kap,kcer70) = + im_feed_baskets(t_all,i,kap,kcer70) * i70_cereal_scp_fadeout(t_all,i); + +*** Substitution of foddr feed with single-cell protein (SCP) based on Nr +* Before the substitution, foddr is converted from DM to Nr +* using fm_attributes("nr","foddr"). +* After the substitution of foddr with SCP (1-i70_foddr_scp_fadeout), SCP is converted +* back DM fm_attributes("nr","scp"). +im_feed_baskets(t_all,i,kap,"scp") = im_feed_baskets(t_all,i,kap,"scp") + + (im_feed_baskets(t_all,i,kap,"foddr") * (1-i70_foddr_scp_fadeout(t_all,i)) * + fm_attributes("nr","foddr")) / fm_attributes("nr","scp"); +im_feed_baskets(t_all,i,kap,"foddr") = + im_feed_baskets(t_all,i,kap,"foddr") * i70_foddr_scp_fadeout(t_all,i); + + +*** choosing between reginal and global factor requirements +$if "%c70_fac_req_regr%" == "glo" i70_cost_regr(i,kli,"cost_regr_a") = f70_cost_regr(kli,"cost_regr_a"); +$if "%c70_fac_req_regr%" == "reg" i70_cost_regr(i,kli,"cost_regr_a") = sum(t_past$(ord(t_past) eq card(t_past)), (f70_hist_factor_costs_livst(t_past,i,kli) / f70_hist_prod_livst(t_past,i,kli,"dm")) - f70_cost_regr(kli,"cost_regr_b") * sum(sys_to_kli(sys,kli),i70_livestock_productivity(t_past,i,sys))); + +i70_cost_regr(i,"fish",cost_regr) = f70_cost_regr("fish",cost_regr); +i70_cost_regr(i,kap,"cost_regr_b") = f70_cost_regr(kap,"cost_regr_b"); + +i70_fac_req_livst(t_all,i,kli) = i70_cost_regr(i,kli,"cost_regr_b") * sum(sys_to_kli(sys,kli), i70_livestock_productivity(t_all,i,sys)) + i70_cost_regr(i,kli,"cost_regr_a"); +* use historic livestock factor requirements for t_past if regional switch is on. Once regression has been updated this could also be included for global factor requirements +$if "%c70_fac_req_regr%" == "reg" i70_fac_req_livst(t_all,i,kli)$(m_year(t_all) <= sum(t_past$(ord(t_past) eq card(t_past)), m_year(t_past)) and m_year(t_all) > 1990) = (f70_hist_factor_costs_livst(t_all,i,kli) / f70_hist_prod_livst(t_all,i,kli,"dm")); + +*** Section implementing the "sticky" part of the realization +* Get the initial production from the historic data +p70_initial_1995_prod(i,kli) = f70_hist_prod_livst("y1995",i,kli,"dm"); diff --git a/modules/70_livestock/fbask_jan16_sticky/presolve.gms b/modules/70_livestock/fbask_jan16_sticky/presolve.gms new file mode 100644 index 0000000000..2ac9a4bfe1 --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/presolve.gms @@ -0,0 +1,95 @@ +*** | (C) 2008-2025 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_feed_balanceflow.fx(i,kap,kall) = fm_feed_balanceflow(t,i,kap,kall); +vm_feed_balanceflow.up(i,kli_rum,"pasture") = Inf; +vm_feed_balanceflow.lo(i,kli_rum,"pasture") = -Inf; + + +if (sum(sameas(t_past,t),1) = 1, + p70_endo_scavenging_flag(i,kli_rum) = 0; + if (ord(t) = smax(t2, ord(t2)$(t_past(t2))) AND card(t) > sum(t_all$(t(t_all) and t_past(t_all)), 1), + p70_endo_scavenging_flag(i,kli_rum) = - fm_feed_balanceflow(t-1,i,kli_rum,"pasture")/pc70_dem_feed_pasture(i,kli_rum); + p70_endo_scavenging_flag(i,kli_rum)$(p70_endo_scavenging_flag(i,kli_rum) < s70_scavenging_ratio) = 0; + ); +); + + +*' @code +*' This realization of the livestock module also estimates an exogenous +*' pasture management factor `pm_past_mngmnt_factor` that is used to scale +*' biophysical pasture yields in the module [14_yields]. + +*' The exogenous calculation of pasture management requires information on +*' changes in the number of cattle reared to fulfil the food demand for ruminant +*' livestock products: + +p70_cattle_stock_proxy(t,i) = im_pop(t,i)*pm_kcal_pc_initial(t,i,"livst_rum") + /i70_livestock_productivity(t,i,"sys_beef"); + +p70_milk_cow_proxy(t,i) = im_pop(t,i)*pm_kcal_pc_initial(t,i,"livst_milk") + /i70_livestock_productivity(t,i,"sys_dairy"); + +*' The lower bound for `p70_cattle_stock_proxy` and `p70_milk_cow_proxy` is +*' set to 20% of initial values in 1995: + +p70_cattle_stock_proxy(t,i)$(p70_cattle_stock_proxy(t,i) < 0.2*p70_cattle_stock_proxy("y1995",i)) = 0.2*p70_cattle_stock_proxy("y1995",i); +p70_milk_cow_proxy(t,i)$(p70_milk_cow_proxy(t,i) < 0.2*p70_milk_cow_proxy("y1995",i)) = 0.2*p70_milk_cow_proxy("y1995",i); + +*' The parameter `p70_cattle_feed_pc_proxy` is a proxy for regional daily per capita +*' feed demand for pasture biomass driven by demand for beef and dairy products, +*' which is later used for weighted aggregation. +p70_cattle_feed_pc_proxy(t,i,kli_rd) = pm_kcal_pc_initial(t,i,kli_rd)*im_feed_baskets(t,i,kli_rd,"pasture")/(fm_nutrition_attributes(t,kli_rd,"kcal") * 10**6); + +*' The parameter `p70_incr_cattle` describes the changes in the number of cattle +*' relative to the previous time step: + +if (ord(t)>1, + p70_incr_cattle(t,i) = ( (p70_cattle_feed_pc_proxy(t,i,"livst_rum") + 10**(-6))* (p70_cattle_stock_proxy(t,i)/p70_cattle_stock_proxy(t-1,i)) + + (p70_cattle_feed_pc_proxy(t,i,"livst_milk") + 10**(-6)) * (p70_milk_cow_proxy(t,i)/p70_milk_cow_proxy(t-1,i)) ) + / sum(kli_rd, p70_cattle_feed_pc_proxy(t,i,kli_rd) + 10**(-6)); +else + p70_incr_cattle(t,i) = 1; +); + +*' The pasture management factor is calculated by applying a linear relationship +*' that links changes in pasture management with changes in the number of cattle: + +if (m_year(t) <= s70_past_mngmnt_factor_fix, + pm_past_mngmnt_factor(t,i) = 1; +else + pm_past_mngmnt_factor(t,i) = ( (s70_pyld_intercept + f70_pyld_slope_reg(i)*p70_incr_cattle(t,i)**(5/(m_year(t)-m_year(t-1))) + )**((m_year(t)-m_year(t-1))/5) )*pm_past_mngmnt_factor(t-1,i); + ); + +*' @stop + + +*** Section implementing the "sticky" part of the realization +*' The capital need per unit of production is based on the capital share of the factor requirements, +*' as well as the interest and the depreciation rates, analogously to the `sticky_feb18` realization. +*' In addition `s70_multiplicator_capital_need` can be used to increase the capital need. + +p70_capital_need(t,i,kli) = i70_fac_req_livst(t,i,kli) + * pm_factor_cost_shares(t,i,"capital") + / (pm_interest(t,i)+s70_depreciation_rate) + * s70_multiplicator_capital_need; + +if (ord(t) = 1, + +*' Estimate capital stock based on initial production. + + p70_capital(t,i,kli) = p70_capital_need(t,i,kli) * p70_initial_1995_prod(i,kli); + +else + +*' Update of existing stocks due to depreciation + + p70_capital(t,i,kli) = p70_capital(t,i,kli) * (1-s70_depreciation_rate)**(m_timestep_length); + +); diff --git a/modules/70_livestock/fbask_jan16_sticky/realization.gms b/modules/70_livestock/fbask_jan16_sticky/realization.gms new file mode 100644 index 0000000000..c390cc512c --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/realization.gms @@ -0,0 +1,109 @@ +*** | (C) 2008-2025 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 The fbask_jan16_sticky realization of the livestock module is based on +*' the fbask_jan16 realization, and only differs from it by implementing capital stocks +*' as introduced in the `sticky_feb18` factor cost module realization. +*' +*' The methodology of fbask_jan16 is described in @weindl_livestock_2017 and +*' @weindl_livestock_2017-1. An important part of the feed demand calculations +*' is conducted outside of the core MAgPIE-GAMS code. Livestock products +*' (ruminant meat, whole-milk, pork, poultry meat and eggs) are supplied by five +*' animal food systems (beef cattle, dairy cattle, pigs, broilers and laying +*' hens). The parameterization of the livestock sector in the initial year is +*' consistent with FAO statistics regarding livestock production, livestock +*' productivity and concentrate feed use. + +*' The fbask_jan16 realization requires regional and product-specific feed +*' baskets that are calculated by a set of preprocessing routines outside of the +*' MAgPIE-GAMS code. Following the methodology of @wirsenius_human_2000, feed +*' conversion (total feed input per product output in dry matter) and feed +*' baskets (demand for different feed types per product output in dry matter) +*' are derived by compiling system-specific feed energy balances. For the +*' establishment of these balances, we apply feed energy requirements per output, +*' as estimated by wirsenius_human_2000 for each animal function and animal food +*' system. These estimates are based on standardized bio-energetic equations and +*' include the minimum energy requirements for maintenance, growth, lactation, +*' reproduction and other basic biological functions of the animals. Moreover, +*' they comprise a general allowance for basic activity and temperature effects. + +*' By distributing the available feed at country level to animal food systems +*' according to their feed energy demand and dividing resulting dry matter feed +*' use by the production volume of the respective systems, we obtain both +*' estimates for feed conversion and feed baskets across different animal food +*' systems and countries. + +*' To facilitate projections of feed conversion and feed baskets, we create +*' regression models with livestock productivity (annual production per animal +*' [ton fresh matter/animal/year]) as predictor, which permit the construction +*' of livestock feeding scenarios. Currently, feeding scenarios are derived +*' based on exogenous livestock productivity scenarios consistent with the +*' storylines of the Shared Socioeconomic Pathways (SSPs). For beef cattle, pigs +*' and broilers, livestock productivity is defined as meat production per +*' animals in stock (e.g. total cattle herd) and for dairy cattle and laying hen +*' as milk or egg production per producing animals (e.g. milk cows). + +*' A power function is used to describe the functional relation between feed +*' conversion and livestock productivity: + +*' ![Relationship between feed conversion and livestock productivity +*' [@weindl_livestock_2017].](feed_conv.jpg){ width=100% } + +*' In the case of feed composition, we use an additional proxy parameter in our +*' analysis. What type of biomass is used to feed animals is to a certain extent +*' influenced by universal aspects (e.g. the need for more energy-rich feed at +*' higher productivity levels), whereas other aspects are strongly influenced by +*' geographical location (e.g. availability and costs of permanent pasture +*' compared to cropland feed, agro-ecological and climatic conditions that +*' favour selected feed items; socio-cultural determinants etc.). For cattle +*' systems the proxy (climate-zone specific factor) was determined by +*' calculating the share of the national population living in arid and cold +*' climate zones. + +*' ![Relationship between the share of crop residues, occasional feed and grazed +*' biomass in feed baskets and livestock productivity for beef cattle systems +*' [@weindl_livestock_2017].](feed_comp_beef.jpg){ width=60% } + +*' ![Relationship between the share of crop residues, occasional feed and grazed +*' biomass in feed baskets and livestock productivity for diary cattle systems +*' [@weindl_livestock_2017].](feed_comp_dairy.jpg){ width=60% } + +*' These relationships between feed baskets and livestock productivity are used +*' to construct feeding scenarios that reflect the narratives of the SSPs. The +*' resulting feed baskets enter the MAgPIE model as scenario-dependent input data +*' and are crucial for the feed demand calculations in the livestock module. + +*' +*' In this realization the capital share of livestock production cost does not have +*' to be paid every timestep, but is fulfilled by having a corresponding capital stock, +*' which mostly persists across timesteps. (See `s70_depreciation_rate`) +*' This means that the production becomes cheaper in regions with +*' higher capital shares and existing corresponding capital stocks, +*' which makes the livestock production "stick" to some degree to existing levels. +*' Another effect is that production increases are more likely to occur in regions +*' of more capital intensive livestock systems with already established stocks. +*' +*' The realization is based on the `sticky_feb18` factor cost realization, but +*' also differs from it in some ways. At the creation time the main differences were: +*' 1. capital stocks are on the regional level not on cluster level +*' 2. no differentiation of mobile and immobile capital - all capital stocks are immobile +*' +*' @limitations Intensification of livestock production and related changes in +*' livestock feeding are modelled exogenously. Therefore, the livestock sector +*' does not endogenously respond to demand and climate shocks and policies, e.g. +*' targeting climate protection. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/70_livestock/fbask_jan16_sticky/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/70_livestock/fbask_jan16_sticky/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/70_livestock/fbask_jan16_sticky/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/70_livestock/fbask_jan16_sticky/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/70_livestock/fbask_jan16_sticky/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/70_livestock/fbask_jan16_sticky/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/70_livestock/fbask_jan16_sticky/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/70_livestock/fbask_jan16_sticky/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/70_livestock/fbask_jan16_sticky/scaling.gms b/modules/70_livestock/fbask_jan16_sticky/scaling.gms new file mode 100644 index 0000000000..20a556904d --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/scaling.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2025 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_cost_prod_livst.scale(i,factors) = 10e5; +vm_cost_prod_fish.scale(i) = 10e5; diff --git a/modules/70_livestock/fbask_jan16_sticky/sets.gms b/modules/70_livestock/fbask_jan16_sticky/sets.gms new file mode 100644 index 0000000000..83c2ff1e90 --- /dev/null +++ b/modules/70_livestock/fbask_jan16_sticky/sets.gms @@ -0,0 +1,46 @@ +*** | (C) 2008-2025 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 + + cost_regr Cost regression parameters + /cost_regr_a,cost_regr_b/ + + share_regr regression parameters for capital share calculation + /slope, intercept/ + + feed_scen70 scenarios + / ssp1, ssp2, ssp3, ssp4, ssp5, constant, + SDP, SDP_EI, SDP_MC, SDP_RC / + + sys Livestock production systems + /sys_pig, sys_beef, sys_chicken, sys_hen, sys_dairy/ + + sys_meat(sys) Livestock meat production systems + /sys_pig, sys_beef, sys_chicken/ + + sys_nonmeat(sys) Livestock non-meat production systems + /sys_hen, sys_dairy/ + + + sys_to_kli(sys,kli) Mapping between livestock producton systems and livestock products + /sys_pig . livst_pig + sys_beef . livst_rum + sys_chicken . livst_chick + sys_hen . livst_egg + sys_dairy .livst_milk + / + + kcer70(kall) Cereals + / tece, maiz, trce, rice_pro / + + fadeoutscen70 Feed substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, + lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / +; diff --git a/modules/70_livestock/module.gms b/modules/70_livestock/module.gms index b87501bd5e..739a2f2d63 100644 --- a/modules/70_livestock/module.gms +++ b/modules/70_livestock/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -24,4 +24,5 @@ *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%livestock%" == "fbask_jan16" $include "./modules/70_livestock/fbask_jan16/realization.gms" +$Ifi "%livestock%" == "fbask_jan16_sticky" $include "./modules/70_livestock/fbask_jan16_sticky/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index 889ed7b3dd..9fc3069639 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,21 +7,20 @@ positive variables v71_prod_rum(j,kli_rum,kforage) Production of forage fed ruminants within a cell (mio. tDM per yr) - v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) - vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD17MER per yr) ; variables - v71_feed_balanceflow(j,kli_rum,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + v71_feed_balanceflow_share(j,kli_rum,kforage) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (1) ; equations q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) - q71_balanceflow_constraint_nlp(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - q71_balanceflow_constraint_lp(i,kli_rum,kforage) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) + q71_balanceflow_constraint(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) q71_sum_rum_liv(j,kli_rum) Total production of forage fed ruminants (mio. tDM per yr) q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) - q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD17MER per yr) ; parameters @@ -29,22 +28,20 @@ parameters ; scalars - s71_lp_fix Switch to fix equations to linear relation (Logical) s71_scale_mon Scalar for flexible distribution of monogastrics (1) - s71_punish_additional_mon Scaling factor for transport punishment (USD05MER per tDM) + s71_punish_additional_mon Scaling factor for transport punishment (USD17MER per tDM) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) - ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) - ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) - ov71_feed_balanceflow(t,j,kli_rum,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) - oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,type) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) - oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) - oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) - oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) + ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD17MER per yr) + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,type) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (1) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_balanceflow_constraint(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) + oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index 9b79710b8f..c8ccd74b9c 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -11,48 +11,28 @@ *' feed items grazed pasture and fodder. These must be larger than the ruminant feed requirements *' that are given by the product of ruminant production and the respective feed baskets: -q71_feed_rum_liv(j2,kforage) .. - vm_prod(j2,kforage) =g= - sum(kli_rum, v71_prod_rum(j2,kli_rum,kforage) - * sum((ct,cell(i2,j2),kforage2),im_feed_baskets(ct,i2,kli_rum,kforage2)) - * (1 + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=0)) - + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=1)) - ; - +q71_feed_rum_liv(j2, kforage) .. + vm_prod(j2, kforage) =g= + sum(kli_rum, v71_prod_rum(j2, kli_rum, kforage) + * sum((ct, cell(i2,j2), kforage2), im_feed_baskets(ct, i2, kli_rum,kforage2)) * + v71_feed_balanceflow_share(j2, kli_rum, kforage)) + ; *' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending *' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) *' or will be fed via harvested fodder crops (intensive systems). -*' Please note that `s71_lp_fix` is set to zero (for more information please look into the source code). - -*' The balance flow for pasture and fodder (summarized with forage) production, accounts as in -*' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. -*' @stop - -* If module is fixed to linear behaviour the balance flow is allowed to be used in any cell -* containing pasture or cropland area in the previous time step ensured by the restrictions -* in the nl_fix statement. The balance flow within a region is then determined by - -q71_balanceflow_constraint_lp(i2,kli_rum,kforage)$(s71_lp_fix=1) .. - sum(ct, fm_feed_balanceflow(ct,i2,kli_rum,kforage)) =e= - sum(cell(i2,j2), v71_feed_balanceflow(j2,kli_rum,kforage)) - ; +*' A regional balance flow accounts in [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with +*' the FAO inventory of national feed use. On cellular level we distribute the regional balance flow as +*' a multiplicative correction term (introduced in `q71_feed_rum_liv`) that is given by -* Note that for fixation to linear behaviour `q71_balanceflow_constraint_lp` replaces `q71_balanceflow_constraint_nlp`. - -*' @equations - -*' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by - -q71_balanceflow_constraint_nlp(j2,kli_rum,kforage)$(s71_lp_fix=0) .. - v71_feed_balanceflow(j2,kli_rum,kforage) =e= - sum((ct,cell(i2,j2)),fm_feed_balanceflow(ct,i2,kli_rum,kforage) - /(im_feed_baskets(ct,i2,kli_rum,kforage)*vm_prod_reg(i2,kli_rum) + 10**(-6))) - ; +q71_balanceflow_constraint(j2, kli_rum, kforage) .. + v71_feed_balanceflow_share(j2, kli_rum, kforage) =e= + 1 + sum((ct, cell(i2,j2)), vm_feed_balanceflow(i2, kli_rum, kforage) / + (im_feed_baskets(ct, i2, kli_rum, kforage) * vm_prod_reg(i2, kli_rum) + 10**(-10))) + ; -*' Note that $10^{-6}$ is required to avoid division by zero. -*' The regional ruminant production is then given by +*' The total cellular ruminant production is then given by q71_sum_rum_liv(j2,kli_rum) .. vm_prod(j2,kli_rum) =e= sum(kforage,v71_prod_rum(j2,kli_rum,kforage)) diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms deleted file mode 100644 index 13da9f3cbd..0000000000 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms +++ /dev/null @@ -1,16 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_fix ### - -v71_feed_balanceflow.lo(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; -v71_feed_balanceflow.up(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"pasture")$(pcm_land(j,"past")=0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"foddr")$(pcm_land(j,"crop")=0) = 0; - -s71_lp_fix=1; diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms deleted file mode 100644 index bb40e99eb6..0000000000 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms +++ /dev/null @@ -1,13 +0,0 @@ -*** | (C) 2008-2019 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 - -* ### nl_release ### - -v71_feed_balanceflow.lo(j,kli_rum,kforage)= -Inf; -v71_feed_balanceflow.up(j,kli_rum,kforage)= Inf; - -s71_lp_fix=0; diff --git a/modules/71_disagg_lvst/foragebased_aug18/not_used.txt b/modules/71_disagg_lvst/foragebased_aug18/not_used.txt new file mode 100644 index 0000000000..aaa6cfb65e --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_aug18/not_used.txt @@ -0,0 +1,3 @@ +name,type,reason +pcm_land,input,questionnaire +fm_feed_balanceflow,input,questionnaire diff --git a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms index 50c346a651..66458962c8 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,44 +6,40 @@ *** | Contact: magpie@pik-potsdam.de *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); - ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow.m(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_nlp.m(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_lp.m(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); - oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); - ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); - ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow.l(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint_nlp.l(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"level") = q71_balanceflow_constraint_lp.l(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); - oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); - ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); - ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow.up(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint_nlp.up(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"upper") = q71_balanceflow_constraint_lp.up(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); - oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); - ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); - ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow.lo(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint_nlp.lo(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"lower") = q71_balanceflow_constraint_lp.lo(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); - oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); + ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow_share.m(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint.m(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow_share.l(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint.l(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow_share.up(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint.up(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow_share.lo(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint.lo(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms index 093d6ae0ec..5139723473 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -7,8 +7,11 @@ i71_urban_area_share(j) = pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) - ; + ; -s71_lp_fix = 0; s71_scale_mon = 1.10; s71_punish_additional_mon = 15000; + +* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow`. +vm_prod_reg.lo(i,kli_rum) = 10**(-6); + diff --git a/modules/71_disagg_lvst/foragebased_aug18/realization.gms b/modules/71_disagg_lvst/foragebased_aug18/realization.gms index 3a723108e7..026627e0a7 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/realization.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -8,12 +8,17 @@ *' @description The foragebased_aug18 realization constrains the cellular ruminant livestock production by *' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder *' (summarized with forage) feed stuff is usually not transported over long distances and at the same time -*' is very essential in livestock diets. The monogastric livestock is distributed following the idea -*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock -*' distribution see @robinson_mapping_2014, which inspired this realization. +*' is very essential in livestock diets. Internally it distinguishs between extensively and intensively fed ruminants. +*' The monogastric livestock is distributed following the idea that these animals are held close to densely populated +*' areas. For more detailed information on cellular livestock distribution see @robinson_mapping_2014, which inspired +*' this realization. -*' @limitations Distribution of monogastrics do not account for feed availability within a cell. Crop residue feed stuff -*' for ruminant production is also not considered to restrict livestock production. +*' This realization includes a minimal lower bound for ruminant production to avoid avoid GAMS corner solutions at +*' higher spatial resolutions. + +*' @limitations Distribution of monogastrics do not account for feed availability within a cell. +*' Crop residue feed stuff for ruminant production is also not considered to restrict livestock +*' production. Forage feed stuff is consider not to be transported, but is in reality. *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/foragebased_aug18/sets.gms" @@ -21,6 +26,4 @@ $Ifi "%phase%" == "declarations" $include "./modules/71_disagg_lvst/foragebased_ $Ifi "%phase%" == "equations" $include "./modules/71_disagg_lvst/foragebased_aug18/equations.gms" $Ifi "%phase%" == "preloop" $include "./modules/71_disagg_lvst/foragebased_aug18/preloop.gms" $Ifi "%phase%" == "postsolve" $include "./modules/71_disagg_lvst/foragebased_aug18/postsolve.gms" -$Ifi "%phase%" == "nl_fix" $include "./modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms" -$Ifi "%phase%" == "nl_release" $include "./modules/71_disagg_lvst/foragebased_aug18/nl_release.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/sets.gms b/modules/71_disagg_lvst/foragebased_aug18/sets.gms index a41abbe580..d7d0f67935 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/sets.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/sets.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -18,7 +18,7 @@ sets kforage(k) Forage feed categories / - pasture, foddr + pasture, foddr / ; diff --git a/modules/71_disagg_lvst/foragebased_jul23/declarations.gms b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms new file mode 100644 index 0000000000..325bf4175c --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms @@ -0,0 +1,50 @@ +*** | (C) 2008-2025 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 + +positive variables + v71_feed_forage(j, kforage) Production of forage within a cell (mio. tDM per yr) + v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD17MER per yr) +; + +variables + v71_feed_balanceflow(j, kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) +; + +equations + q71_feed_rum_liv(j, kforage) Production constraint for ruminant livestock products (mio. tDM per yr) + q71_feed_forage(j) Forage feed constraint (mio. tDM per yr) + q71_feed_balanceflow_nlp(j) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_feed_balanceflow_lp(i) Linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD17MER per yr) +; + +parameters + i71_urban_area_share(j) Share of urban area within a region (1) +; + +scalars + s71_lp_fix Switch to fix equations to linear relation (Logical) + s71_scale_mon Scalar for flexible distribution of monogastrics (1) + s71_punish_additional_mon Scaling factor for transport punishment (USD17MER per tDM) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov71_feed_forage(t,j,kforage,type) Production of forage within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD17MER per yr) + ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_feed_forage(t,j,type) Forage feed constraint (mio. tDM per yr) + oq71_feed_balanceflow_nlp(t,j,type) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_feed_balanceflow_lp(t,i,type) Linear balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD17MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/equations.gms b/modules/71_disagg_lvst/foragebased_jul23/equations.gms new file mode 100644 index 0000000000..4f23a3dc8a --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/equations.gms @@ -0,0 +1,72 @@ +*** | (C) 2008-2025 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 + +*' Ruminant livestock production within a cell is determined by the production of the non-transportable +*' feed items grazed pasture and fodder (`kforage`). Forage production must be larger than the ruminant feed requirements +*' (`v71_feed_forage`) adjusted by a balance flow (`v71_feed_forage`). + +q71_feed_rum_liv(j2,kforage) .. + vm_prod(j2,kforage) =g= + v71_feed_forage(j2,kforage) + + v71_feed_balanceflow(j2,kforage); + +*' Ruminant feed requirements are given by the product of ruminant production and the respective feed baskets. + +q71_feed_forage(j2) .. + sum(kforage, v71_feed_forage(j2,kforage)) =e= + sum((kli_rum,kforage), vm_prod(j2,kli_rum) + * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))); + +*' The above equation contains a split of pasture and fodder fed ruminant feed requirements, since we assume +*' that depending on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) +*' or will be fed via harvested fodder crops (intensive systems). + +*' The balance flow for pasture and fodder production (`kforage`) accounts as in [70_livestock] `q70_feed(i2,kap,kall)` +*' for inconsistencies with the FAO inventory of national feed use. In each cluster the balance flow is constrained by +*' its share of livestock production regarding the regional level by + +q71_feed_balanceflow_nlp(j2)$(s71_lp_fix=0) .. + sum(kforage, v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,cell(i2,j2),kli_rum,kforage), vm_feed_balanceflow(i2,kli_rum,kforage) + * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum)))); + +*' @stop + +* If fixed to linear behaviour (`s71_lp_fix=1`) the balance flow for pasture and fodder production (`kforage`) +* can be freely distributed among all cells beloning to a region. + +q71_feed_balanceflow_lp(i2)$(s71_lp_fix=1) .. + sum((cell(i2,j2),kforage), v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,kli_rum,kforage), vm_feed_balanceflow(i2,kli_rum,kforage)); + +* Note that for fixation to linear behaviour `q71_feed_balanceflow_lp` replaces `q71_feed_balanceflow_nlp`. + +*' @equations + +*' To account for the above mentioned fact that monogastric livestock are held close to the population, it is +*' distributed based on urban area by the formula + +q71_prod_mon_liv(j2,kli_mon) .. + vm_prod(j2,kli_mon) =l= + i71_urban_area_share(j2) * s71_scale_mon * sum(cell(i2,j2),vm_prod_reg(i2,kli_mon)) + + v71_additional_mon(j2,kli_mon) + ; + +*' Note that s71_scale_mon relaxes the constraint (per default by 10%) and v71_additional_mon ensures +*' feasability by punishing additonal monogastric production within a cluster. + +*' The punishmment of additional monogastric livestock production are calculated via + +q71_punishment_mon(i2) .. + vm_costs_additional_mon(i2) =e= + sum((cell(i2,j2),kli_mon), v71_additional_mon(j2,kli_mon)) * s71_punish_additional_mon + ; + +*' Note that the punishment costs are based on transport costs and scaled up by one order of magnitude +*' of the average transport costs to account for additional transport between clusters. diff --git a/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms b/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms new file mode 100644 index 0000000000..d8dfc63127 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2025 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 + +* ### nl_fix ### + +v71_feed_balanceflow.lo(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; +v71_feed_balanceflow.up(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; +v71_feed_balanceflow.fx(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; +v71_feed_balanceflow.fx(j,"pasture")$(pcm_land(j,"past")=0) = 0; +v71_feed_balanceflow.fx(j,"foddr")$(pcm_land(j,"crop")=0) = 0; diff --git a/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms b/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms new file mode 100644 index 0000000000..e7808856f5 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2025 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 + +* ### nl_release ### + +v71_feed_balanceflow.lo(j,kforage)= -Inf; +v71_feed_balanceflow.up(j,kforage)= Inf; diff --git a/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms b/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms new file mode 100644 index 0000000000..94f63afb82 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms @@ -0,0 +1,49 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov71_feed_forage(t,j,kforage,"marginal") = v71_feed_forage.m(j,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_feed_forage(t,j,"marginal") = q71_feed_forage.m(j); + oq71_feed_balanceflow_nlp(t,j,"marginal") = q71_feed_balanceflow_nlp.m(j); + oq71_feed_balanceflow_lp(t,i,"marginal") = q71_feed_balanceflow_lp.m(i); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_feed_forage(t,j,kforage,"level") = v71_feed_forage.l(j,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_feed_forage(t,j,"level") = q71_feed_forage.l(j); + oq71_feed_balanceflow_nlp(t,j,"level") = q71_feed_balanceflow_nlp.l(j); + oq71_feed_balanceflow_lp(t,i,"level") = q71_feed_balanceflow_lp.l(i); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_feed_forage(t,j,kforage,"upper") = v71_feed_forage.up(j,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_feed_forage(t,j,"upper") = q71_feed_forage.up(j); + oq71_feed_balanceflow_nlp(t,j,"upper") = q71_feed_balanceflow_nlp.up(j); + oq71_feed_balanceflow_lp(t,i,"upper") = q71_feed_balanceflow_lp.up(i); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_feed_forage(t,j,kforage,"lower") = v71_feed_forage.lo(j,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_feed_forage(t,j,"lower") = q71_feed_forage.lo(j); + oq71_feed_balanceflow_nlp(t,j,"lower") = q71_feed_balanceflow_nlp.lo(j); + oq71_feed_balanceflow_lp(t,i,"lower") = q71_feed_balanceflow_lp.lo(i); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/preloop.gms b/modules/71_disagg_lvst/foragebased_jul23/preloop.gms new file mode 100644 index 0000000000..8fba734224 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/preloop.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2025 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 + +i71_urban_area_share(j) = + pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) + ; + +s71_lp_fix = 0; +s71_scale_mon = 1.10; +s71_punish_additional_mon = 15000; + +* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow_nlp`. +vm_prod_reg.lo(i,kli_rum)$(s71_lp_fix=0) = 10**(-6); diff --git a/modules/71_disagg_lvst/foragebased_jul23/realization.gms b/modules/71_disagg_lvst/foragebased_jul23/realization.gms new file mode 100644 index 0000000000..f4db4e3365 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/realization.gms @@ -0,0 +1,31 @@ +*** | (C) 2008-2025 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 The foragebased_jul23 realization constrains the cellular ruminant livestock production by +*' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder +*' (summarized with forage) feed stuff is usually not transported over long distances and at the same time +*' is very essential in livestock diets. The monogastric livestock is distributed following the idea +*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock +*' distribution see @robinson_mapping_2014, which inspired this realization. + +*' This realization includes a minimal lower bound for ruminant production to avoid avoid GAMS corner solutions at +*' higher spatial resolutions. It also has a linearized version, which can be switch on via `s71_lp_fix`. + +*' @limitations Distribution of monogastrics do not account for feed availability within a cell. +*' Crop residue feed stuff for ruminant production is also not considered to restrict livestock +*' production. Forage feed stuff is consider not to be transported, but is in reality. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/foragebased_jul23/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/71_disagg_lvst/foragebased_jul23/declarations.gms" +$Ifi "%phase%" == "equations" $include "./modules/71_disagg_lvst/foragebased_jul23/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/71_disagg_lvst/foragebased_jul23/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/71_disagg_lvst/foragebased_jul23/postsolve.gms" +$Ifi "%phase%" == "nl_fix" $include "./modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms" +$Ifi "%phase%" == "nl_release" $include "./modules/71_disagg_lvst/foragebased_jul23/nl_release.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/sets.gms b/modules/71_disagg_lvst/foragebased_jul23/sets.gms new file mode 100644 index 0000000000..d7d0f67935 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/sets.gms @@ -0,0 +1,27 @@ +*** | (C) 2008-2025 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 + kli_rum(kli) Ruminant livestock + / + livst_rum, livst_milk + / + + kli_mon(kli) Monogastric livestock + / + livst_pig, livst_chick, livst_egg + / + + kforage(k) Forage feed categories + / + pasture, foddr + / +; + +alias(j,j3); +alias(cell,cell2); +alias(kforage,kforage2); diff --git a/modules/71_disagg_lvst/module.gms b/modules/71_disagg_lvst/module.gms index e60797783d..7a0e156342 100644 --- a/modules/71_disagg_lvst/module.gms +++ b/modules/71_disagg_lvst/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -16,5 +16,6 @@ *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%disagg_lvst%" == "foragebased_aug18" $include "./modules/71_disagg_lvst/foragebased_aug18/realization.gms" +$Ifi "%disagg_lvst%" == "foragebased_jul23" $include "./modules/71_disagg_lvst/foragebased_jul23/realization.gms" $Ifi "%disagg_lvst%" == "off" $include "./modules/71_disagg_lvst/off/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/71_disagg_lvst/off/declarations.gms b/modules/71_disagg_lvst/off/declarations.gms index e5969fef59..4b17c94a2b 100644 --- a/modules/71_disagg_lvst/off/declarations.gms +++ b/modules/71_disagg_lvst/off/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,10 +6,10 @@ *** | Contact: magpie@pik-potsdam.de positive variables - vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD17MER per yr) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD17MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/off/not_used.txt b/modules/71_disagg_lvst/off/not_used.txt index 617d0ccc76..00e417bad4 100644 --- a/modules/71_disagg_lvst/off/not_used.txt +++ b/modules/71_disagg_lvst/off/not_used.txt @@ -1,13 +1,7 @@ -# | (C) 2008-2019 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 - name,type,reason im_feed_baskets,input,questionnaire -fm_feed_balanceflow,input,questionnaire +fm_feed_balanceflow,input,questionnaire +vm_feed_balanceflow,input,questionnaire vm_prod,input,questionnaire vm_prod_reg,input,questionnaire pm_land_start,input,questionnaire diff --git a/modules/71_disagg_lvst/off/postsolve.gms b/modules/71_disagg_lvst/off/postsolve.gms index ef7d8210a2..a77764f6d3 100644 --- a/modules/71_disagg_lvst/off/postsolve.gms +++ b/modules/71_disagg_lvst/off/postsolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/71_disagg_lvst/off/presolve.gms b/modules/71_disagg_lvst/off/presolve.gms index 78bbfebc8f..eb70ed3fac 100644 --- a/modules/71_disagg_lvst/off/presolve.gms +++ b/modules/71_disagg_lvst/off/presolve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/modules/71_disagg_lvst/off/realization.gms b/modules/71_disagg_lvst/off/realization.gms index 14c81779be..c8ca0ada36 100644 --- a/modules/71_disagg_lvst/off/realization.gms +++ b/modules/71_disagg_lvst/off/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -10,6 +10,7 @@ *' @limitations This realization underestimates real world drivers for livestock distribution. *####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/off/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/71_disagg_lvst/off/declarations.gms" $Ifi "%phase%" == "presolve" $include "./modules/71_disagg_lvst/off/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/71_disagg_lvst/off/postsolve.gms" diff --git a/modules/71_disagg_lvst/off/sets.gms b/modules/71_disagg_lvst/off/sets.gms new file mode 100644 index 0000000000..4cb97bf31c --- /dev/null +++ b/modules/71_disagg_lvst/off/sets.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 + kli_rum(kli) Ruminant livestock + / + livst_rum, livst_milk + / + + kli_mon(kli) Monogastric livestock + / + livst_pig, livst_chick, livst_egg + / + + kforage(k) Forage feed categories + / + pasture, foddr + / +; diff --git a/modules/73_timber/default/declarations.gms b/modules/73_timber/default/declarations.gms new file mode 100644 index 0000000000..51d8ed1ddf --- /dev/null +++ b/modules/73_timber/default/declarations.gms @@ -0,0 +1,45 @@ +*** | (C) 2008-2025 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 +p73_timber_demand_gdp_pop(t_all,i,kforestry) Timber demand based on lauri et al 2019 (mio. m3 per yr) +p73_forestry_demand_prod_specific(t_all,iso,total_wood_products) End product specific timber demand (mio. m3 per yr) +pm_demand_forestry(t_ext,i,kforestry) Extended demand for timber beyound simulation (mio. tDM per yr) +p73_glo_wood(t_all,kforestry) Global wood demand (mio. tDM per yr) +p73_demand_modifier(t_all) Simple demand modifier for construction wood (mio. tDM per yr) +p73_fraction(t_all) Fraction over which construction wood demand is spread out (1) +p73_demand_constr_wood(t_all,i) Demand for construction wood (mio. tDM per yr) +p73_fraction_sm_fix Modifier fraction at sm_fix_SSP2 time step (1) +im_timber_prod_cost(kforestry) Cost for producing one unit of wood and woodfuel (USD17MER per tDM) +p73_income_elasticity(t_all,iso,total_wood_products) Income elasticities of wood products (1) +; + +positive variables +vm_cost_timber(i) Actual cost of harvesting timber from forests (mio. USD17MER per yr) +v73_prod_heaven_timber(j,kforestry) Production of woody biomass from heaven (mio. tDM per yr) +v73_prod_residues(j) Production of residues from industrial roundwood harvest (mio. tDM per yr) +; + +equations +q73_cost_timber(i) Actual cost of harvesting timber from forests (mio. USD17MER per yr) +q73_prod_wood(j) Production of industrial roundwood (mio. tDM per yr) +q73_prod_woodfuel(j) Production of wood fuel (mio. tDM per yr) +q73_prod_residues(j) Production of residues from industrial roundwood harvest (mio. tDM per yr) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_timber(t,i,type) Actual cost of harvesting timber from forests (mio. USD17MER per yr) + ov73_prod_heaven_timber(t,j,kforestry,type) Production of woody biomass from heaven (mio. tDM per yr) + ov73_prod_residues(t,j,type) Production of residues from industrial roundwood harvest (mio. tDM per yr) + oq73_cost_timber(t,i,type) Actual cost of harvesting timber from forests (mio. USD17MER per yr) + oq73_prod_wood(t,j,type) Production of industrial roundwood (mio. tDM per yr) + oq73_prod_woodfuel(t,j,type) Production of wood fuel (mio. tDM per yr) + oq73_prod_residues(t,j,type) Production of residues from industrial roundwood harvest (mio. tDM per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/73_timber/default/equations.gms b/modules/73_timber/default/equations.gms new file mode 100644 index 0000000000..35dd9dbcf5 --- /dev/null +++ b/modules/73_timber/default/equations.gms @@ -0,0 +1,69 @@ +*** | (C) 2008-2025 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 + +*' Timber production cost include the cost for producing wood, woodfuel and residues, +*' and technical costs for a slack variable ('v73_prod_heaven_timber'). +*' The slack variable (high costs) +*' is only used as a last resort when there is no other way to meet the timber +*' demand. The purpose of the slack variable is to assure technically feasibility +*' of the model under all conditions and to indicate shortage of wood supply, if any. + +q73_cost_timber(i2).. + vm_cost_timber(i2) + =e= + sum((cell(i2,j2),kforestry), vm_prod(j2,kforestry) * im_timber_prod_cost(kforestry)) + + sum(cell(i2,j2), v73_prod_residues(j2)) * s73_reisdue_removal_cost + + sum((cell(i2,j2),kforestry), v73_prod_heaven_timber(j2,kforestry) * s73_free_prod_cost) + ; + +*' The following equations describes cellular level production (in dry matter) of +*' woody biomass `vm_prod` as the sum of the cluster level production of +*' timber coming from 'vm_prod_forestry' and 'vm_prod_natveg'. When production +*' capabilities are exhausted, the model can produce roundwood without using any +*' land resources but by paying a very high cost ('s73_free_prod_cost'). +*' Timber production equation is split in two parts, one each for industrial roundwood +*' and wood fuel production. Woodfuel production, in addition to usual production +*' channels, can also use residues left from industrial roundwood harvest for meeting +*' overall wood fuel production targets. + +q73_prod_wood(j2).. + vm_prod(j2,"wood") + =e= + vm_prod_forestry(j2,"wood") + + + sum((land_natveg),vm_prod_natveg(j2,land_natveg,"wood")) + + + v73_prod_heaven_timber(j2,"wood"); + +q73_prod_woodfuel(j2).. + vm_prod(j2,"woodfuel") + =e= + vm_prod_forestry(j2,"woodfuel") + + + sum((land_natveg),vm_prod_natveg(j2,land_natveg,"woodfuel")) + + + v73_prod_residues(j2) + + + v73_prod_heaven_timber(j2,"woodfuel"); + +*' Production of residues is calculated based on `s73_residue_ratio`. This fraction +*' of industrial roundwood production is assumed to be lost during harvesting processes. +*' USDA reports that ca. 30% of roundwood harvested are residues (@oswalt2019forest). +*' Not all of this residue is recovered from forest and we assume 50% of residue +*' removal based on @pokharel2017factors. These numbers (residue levels and residude +*' removals vary strongly among different studies, the numbers used here are from +*' a USDA report on state of forests in USA which has consistent reporting over years) + +q73_prod_residues(j2).. + v73_prod_residues(j2) + =l= + vm_prod(j2,"wood") * s73_residue_ratio + ; + +*** EOF equations.gms *** diff --git a/modules/73_timber/default/input.gms b/modules/73_timber/default/input.gms new file mode 100644 index 0000000000..3e6de95c30 --- /dev/null +++ b/modules/73_timber/default/input.gms @@ -0,0 +1,71 @@ +*** | (C) 2008-2025 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 + + +$setglobal c73_wood_scen default +* options default, construction +$setglobal c73_build_demand BAU +* options BAU, 10pc, 50pc, 90pc + +scalars +* 60 EUR/m3 = 72 USD/m3 +* 72 USD/m3 / 0.6 = 120 USD/tDM +* https://unece.org/forests/prices +* inflated using USD05 --> USD17 rate of 1.23 + s73_timber_prod_cost_wood Cost for producing one unit of wood (USD17MER per tDM) / 148 / + s73_timber_prod_cost_woodfuel Cost for prodcing one unit of woodfuel (USD17MER per tDM) / 74 / + s73_free_prod_cost Very high cost for settling demand without production (USD17MER per tDM) / 1e+06 / + s73_timber_demand_switch Logical switch to turn on or off timber demand 1=on 0=off (1) / 1 / + s73_income_threshold Threshold for income-elastic industrial roundwood demand (USD17PPP per cap per yr) / 10000 / + s73_residue_ratio Proportion of overall industrial roundwood production which ends up as residue during harvest (1) / 0.15 / + s73_reisdue_removal_cost Cost of removing residues left after industrial roundwood harvest (USD17MER per tDM) / 2.5 / + s73_expansion Construction wood demand expansion factor by end of century based on industrial roundwood demand as base (1=100 percent increase) / 0 / +; + +** Residue numbers from +** "Spatially explicit assessment of roundwood and logging residues availability and costs for the EU28" +** "The total potential volume of logging residues in the “Reference scenario” is estimated to be 79 Mm3, corresponding to 13.5% of the roundwood potential volume. " + +table f73_prod_specific_timber(t_all,iso,total_wood_products) End use timber product demand (mio. m3 per yr) +$ondelim +$include "./modules/73_timber/input/f73_prod_specific_timber.csv" +$offdelim +; + +parameter f73_income_elasticity(total_wood_products) Income elasticities of wood products (1) +/ +$ondelim +$include "./modules/73_timber/input/f73_income_elasticity.csv" +$offdelim +/ +; + +parameter f73_volumetric_conversion(kforestry) Volumetric conversion from mio t to m3 of wood (1) +/ +$ondelim +$include "./modules/73_timber/input/f73_volumetric_conversion.csv" +$offdelim +/ +; + +table f73_demand_modifier(t_ext,scen_73) Factor diminishing paper use (1) +$ondelim +$include "./modules/73_timber/input/f73_demand_modifier.csv" +$offdelim +; + +table f73_regional_timber_demand(t_all,i,total_wood_products) End use timber product demand (mio. m3 per yr) +$ondelim +$include "./modules/73_timber/input/f73_regional_timber_demand.csv" +$offdelim +; + +table f73_construction_wood_demand(t_all,i,pop_gdp_scen09,build_scen) Construction wood demand (mio. tDM) +$ondelim +$include "./modules/73_timber/input/f73_construction_wood_demand.cs3" +$offdelim +; diff --git a/modules/73_timber/default/postsolve.gms b/modules/73_timber/default/postsolve.gms new file mode 100644 index 0000000000..d79647a320 --- /dev/null +++ b/modules/73_timber/default/postsolve.gms @@ -0,0 +1,37 @@ +*** | (C) 2008-2025 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_timber(t,i,"marginal") = vm_cost_timber.m(i); + ov73_prod_heaven_timber(t,j,kforestry,"marginal") = v73_prod_heaven_timber.m(j,kforestry); + ov73_prod_residues(t,j,"marginal") = v73_prod_residues.m(j); + oq73_cost_timber(t,i,"marginal") = q73_cost_timber.m(i); + oq73_prod_wood(t,j,"marginal") = q73_prod_wood.m(j); + oq73_prod_woodfuel(t,j,"marginal") = q73_prod_woodfuel.m(j); + oq73_prod_residues(t,j,"marginal") = q73_prod_residues.m(j); + ov_cost_timber(t,i,"level") = vm_cost_timber.l(i); + ov73_prod_heaven_timber(t,j,kforestry,"level") = v73_prod_heaven_timber.l(j,kforestry); + ov73_prod_residues(t,j,"level") = v73_prod_residues.l(j); + oq73_cost_timber(t,i,"level") = q73_cost_timber.l(i); + oq73_prod_wood(t,j,"level") = q73_prod_wood.l(j); + oq73_prod_woodfuel(t,j,"level") = q73_prod_woodfuel.l(j); + oq73_prod_residues(t,j,"level") = q73_prod_residues.l(j); + ov_cost_timber(t,i,"upper") = vm_cost_timber.up(i); + ov73_prod_heaven_timber(t,j,kforestry,"upper") = v73_prod_heaven_timber.up(j,kforestry); + ov73_prod_residues(t,j,"upper") = v73_prod_residues.up(j); + oq73_cost_timber(t,i,"upper") = q73_cost_timber.up(i); + oq73_prod_wood(t,j,"upper") = q73_prod_wood.up(j); + oq73_prod_woodfuel(t,j,"upper") = q73_prod_woodfuel.up(j); + oq73_prod_residues(t,j,"upper") = q73_prod_residues.up(j); + ov_cost_timber(t,i,"lower") = vm_cost_timber.lo(i); + ov73_prod_heaven_timber(t,j,kforestry,"lower") = v73_prod_heaven_timber.lo(j,kforestry); + ov73_prod_residues(t,j,"lower") = v73_prod_residues.lo(j); + oq73_cost_timber(t,i,"lower") = q73_cost_timber.lo(i); + oq73_prod_wood(t,j,"lower") = q73_prod_wood.lo(j); + oq73_prod_woodfuel(t,j,"lower") = q73_prod_woodfuel.lo(j); + oq73_prod_residues(t,j,"lower") = q73_prod_residues.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/73_timber/default/preloop.gms b/modules/73_timber/default/preloop.gms new file mode 100644 index 0000000000..511d13a29e --- /dev/null +++ b/modules/73_timber/default/preloop.gms @@ -0,0 +1,84 @@ +*** | (C) 2008-2025 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 + +** Plausible cost for balance variable in case of s73_timber_demand_switch = 0 to avoid distortion of cost +s73_free_prod_cost$(s73_timber_demand_switch = 0) = s73_timber_prod_cost_wood; + +** Set historical values to FAO values +p73_forestry_demand_prod_specific(t_past_forestry,iso,total_wood_products) = f73_prod_specific_timber(t_past_forestry,iso,total_wood_products); + +p73_income_elasticity(t_all,iso,total_wood_products) = f73_income_elasticity(total_wood_products); +p73_income_elasticity(t_all,iso,total_wood_products)$(im_gdp_pc_ppp_iso(t_all,iso) > s73_income_threshold) = 0; +p73_income_elasticity(t_all,iso,"wood_fuel") = f73_income_elasticity("wood_fuel"); + +** Loop over time to calculate future demand +** Calculations based on Lauri et al. 2019 +loop(t_all$(m_year(t_all) > 1995 AND m_year(t_all) <= 2150), + p73_forestry_demand_prod_specific(t_all,iso,total_wood_products)$(im_gdp_pc_ppp_iso(t_all,iso)>0 AND im_pop_iso(t_all,iso)>0) + = p73_forestry_demand_prod_specific(t_all-1,iso,total_wood_products) + * + (im_pop_iso(t_all,iso)/im_pop_iso(t_all-1,iso)) + * + ((im_gdp_pc_ppp_iso(t_all,iso)/im_gdp_pc_ppp_iso(t_all-1,iso))**p73_income_elasticity(t_all,iso,total_wood_products)) + ; +); + +** Aggregate from ISO country level to MAgPIE region level +p73_timber_demand_gdp_pop(t_all,i,kforestry) = sum((i_to_iso(i,iso),kforestry_to_woodprod(kforestry,total_wood_products)),p73_forestry_demand_prod_specific(t_all,iso,total_wood_products)) * s73_timber_demand_switch ; + +** Alternative wood use scenarios +$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 + +** Convert to tDM from mio m3 +** p73_timber_demand_gdp_pop is in mio m^3 +** pm_demand_forestry in mio ton DM +** Hold constraint beyond 2150 - First every time step gets 2150 values +**** Extend for Churkina et al 2020 demand scenarios +pm_demand_forestry(t_ext,i,kforestry) = round(p73_timber_demand_gdp_pop("y2150",i,kforestry) * f73_volumetric_conversion(kforestry),3); +** overwrite timesteps below 2150 with actual values +pm_demand_forestry(t_all,i,kforestry) = round(p73_timber_demand_gdp_pop(t_all,i,kforestry) * f73_volumetric_conversion(kforestry),3); + +** Initialize fraction +p73_fraction(t_all) = s73_expansion/(m_year("y2100") - sm_fix_SSP2); + +** Populate the fraction for each time step +loop(t_all$(m_year(t_all) > 1995), + p73_fraction(t_all) = s73_expansion/(m_year("y2100") - sm_fix_SSP2) * m_yeardiff(t_all) + p73_fraction(t_all-1); + ); + +** Remove equally the values from sm_fix_SSP2 (we want the construction wood demand to only start after sm_fix_SSP2) +loop(t_all$(m_year(t_all)=sm_fix_SSP2), + p73_fraction_sm_fix = p73_fraction(t_all); + ); +p73_fraction(t_all) = p73_fraction(t_all) - p73_fraction_sm_fix; +** Set negative values to 0 +p73_fraction(t_all)$(p73_fraction(t_all)<0) = 0; +** Set values after 2100 to values from 2100 +p73_fraction(t_all)$(m_year(t_all)>2100) = p73_fraction("y2100"); + +** In case using demand from Churkina et al. 2020 +if(s73_expansion = 0, + p73_demand_constr_wood(t_all,i) = f73_construction_wood_demand(t_all,i,"%c09_pop_scenario%","%c73_build_demand%"); + p73_demand_constr_wood(t_all,i)$(m_year(t_all)<=sm_fix_SSP2) = f73_construction_wood_demand("y2025",i,"%c09_pop_scenario%","BAU"); + ); + +** In case using simple assumption for construction wood demand (based on industrial_roundwood demand) +if(s73_expansion > 0, + p73_demand_constr_wood(t_all,i) = pm_demand_forestry(t_all,i,"wood") * p73_fraction(t_all); + ); + +** Adjust industrial roundwood demand (construction wood demand is added on top) +pm_demand_forestry(t_all,i,"wood") = pm_demand_forestry(t_all,i,"wood") + p73_demand_constr_wood(t_all,i); +** Keep demand after 2100 constant +pm_demand_forestry(t_all,i,kforestry)$(m_year(t_all)>2100) = pm_demand_forestry("y2100",i,kforestry); +** Calculate global demand +p73_glo_wood(t_all,kforestry) = sum(i,pm_demand_forestry(t_all,i,kforestry)); + +im_timber_prod_cost("wood") = s73_timber_prod_cost_wood; +im_timber_prod_cost("woodfuel") = s73_timber_prod_cost_woodfuel; diff --git a/modules/73_timber/default/realization.gms b/modules/73_timber/default/realization.gms new file mode 100644 index 0000000000..8804a1ba16 --- /dev/null +++ b/modules/73_timber/default/realization.gms @@ -0,0 +1,26 @@ +*** | (C) 2008-2025 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, aggregated timber demand for wood and woodfuel +*' `pm_demand_forestry` is calculated based on demand equation from @lauri_timber_demand +*' and income elasticities from @morland2018supply. See @mishra_forestry_2021 for more details. +*' This realization can also account for construction wood demand based on +*' @churkina2020buildings which is added on top of industrial roundwood demand (see @mishra_timbercities_2022). +*' Timber can be produced from both timber plantations `vm_prod_forestry` provided by [32_forestry] +*' and natural vegetation `vm_prod_natveg` provided by [35_natveg]. + +*' @limitations Timber demand cannot be determined endogenously + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/73_timber/default/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/73_timber/default/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/73_timber/default/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/73_timber/default/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/73_timber/default/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/73_timber/default/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/73_timber/default/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/73_timber/default/scaling.gms b/modules/73_timber/default/scaling.gms new file mode 100644 index 0000000000..03928e766b --- /dev/null +++ b/modules/73_timber/default/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2025 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_cost_timber.scale(i)$(s73_timber_demand_switch = 1) = 10e4; diff --git a/modules/73_timber/default/sets.gms b/modules/73_timber/default/sets.gms new file mode 100644 index 0000000000..0606140918 --- /dev/null +++ b/modules/73_timber/default/sets.gms @@ -0,0 +1,54 @@ +*** | (C) 2008-2025 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 + +total_wood_products End use wood product category from FAO +/ +roundwood, +industrial_roundwood,wood_fuel,other_industrial_roundwood, +pulpwood,sawlogs_and_veneer_logs,fibreboard,particle_board_and_osb, +wood_pulp,sawnwood, plywood, veneer_sheets, +wood_based_panels,other_sawnwood +/ + +wood_products(total_wood_products) Major 2nd level products from wood processing +/ +fibreboard,particle_board_and_osb,plywood,veneer_sheets, +wood_pulp, +sawnwood, +other_industrial_roundwood +/ + +construction_wood(total_wood_products) Wood products used for building construction +/ +fibreboard,particle_board_and_osb,plywood,veneer_sheets,sawnwood +/ + +wood_panels(wood_products) Wood products used for panels construction +/ +fibreboard,particle_board_and_osb,plywood,veneer_sheets +/ + +kforestry_to_woodprod(kforestry,total_wood_products) Mapping between intermediate and end use wood products +/ +wood . (industrial_roundwood) +woodfuel . (wood_fuel) +/ + +scen_73 Forestry future scenario +/ +nopaper, construction +/ + +build_scen Building wood scenario +/ +BAU, 10pc, 50pc, 90pc +/ + +; +*** EOF sets.gms *** diff --git a/modules/73_timber/input/files b/modules/73_timber/input/files new file mode 100644 index 0000000000..5be5323d64 --- /dev/null +++ b/modules/73_timber/input/files @@ -0,0 +1,7 @@ +* list of files that are required here +f73_prod_specific_timber.csv +f73_income_elasticity.csv +f73_volumetric_conversion.csv +f73_demand_modifier.csv +f73_regional_timber_demand.csv +f73_construction_wood_demand.cs3 diff --git a/modules/73_timber/module.gms b/modules/73_timber/module.gms new file mode 100644 index 0000000000..307a7568d2 --- /dev/null +++ b/modules/73_timber/module.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2025 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 + +*' @title Timber +*' +*' @description This module provides demand for forestry products via the interface `pm_demand_forestry` +*' to the modules [32_forestry] and [62_material], and merges production of timber from +*' different sources into the interface `vm_prod`, which is used in the [17_production] and +*' [21_trade] modules. +*' +*' @authors Abhijeet Mishra, Florian Humpenöder + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%timber%" == "default" $include "./modules/73_timber/default/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/80_optimization/lp_nlp_apr17/declarations.gms b/modules/80_optimization/lp_nlp_apr17/declarations.gms index 2cc1dfdf7f..bf0790b651 100644 --- a/modules/80_optimization/lp_nlp_apr17/declarations.gms +++ b/modules/80_optimization/lp_nlp_apr17/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,11 +6,11 @@ *** | Contact: magpie@pik-potsdam.de parameters - p80_modelstat(t) modelstat indicator (1) - p80_num_nonopt(t) numNOpt indicator (1) + p80_modelstat(t) modelstat indicator (1) + p80_num_nonopt(t) numNOpt indicator (1) ; scalars s80_counter counter (1) - s80_obj_linear linear objective value (mio. USD05MER per yr) + s80_obj_linear linear objective value (mio. USD17MER per yr) ; diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index 16a42017bf..1486c3a2a0 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,17 +6,8 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / - s80_optfile switch to use specfied solver settings (1) / 0 / - s80_add_cplex add cplex optimization after conopt4 (1) / 0 / - s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / - s80_num_nonopt_allowed number of allowed non-optimal variables (1) / Inf / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_optfile switch to use specfied solver settings (1) / 1 / + s80_secondsolve second solve statement (binary) / 0 / + s80_toloptimal value for CONOPT4 Tol_Optimality / 1e-08 / ; - - -$setglobal c80_nlp_solver conopt4 -* options: (conopt3): conopt3 -* (conopt4): conopt4 -* (conopt4+cplex): conopt4 followed by cplex with landdiff optimization -* (conopt4+conopt3): conopt4 followed by conopt3 - diff --git a/modules/80_optimization/lp_nlp_apr17/preloop.gms b/modules/80_optimization/lp_nlp_apr17/preloop.gms new file mode 100644 index 0000000000..115c631cc6 --- /dev/null +++ b/modules/80_optimization/lp_nlp_apr17/preloop.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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 + +File optfile /conopt4.opt/; + diff --git a/modules/80_optimization/lp_nlp_apr17/realization.gms b/modules/80_optimization/lp_nlp_apr17/realization.gms index 432d9ec671..2de255020b 100644 --- a/modules/80_optimization/lp_nlp_apr17/realization.gms +++ b/modules/80_optimization/lp_nlp_apr17/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -22,5 +22,6 @@ *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "declarations" $include "./modules/80_optimization/lp_nlp_apr17/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/80_optimization/lp_nlp_apr17/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/80_optimization/lp_nlp_apr17/preloop.gms" $Ifi "%phase%" == "solve" $include "./modules/80_optimization/lp_nlp_apr17/solve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index 1ddbbaa3aa..a8a3db3dca 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -19,13 +19,12 @@ magpie.holdfixed = 1 ; * linear solver option lp = cplex ; option qcp = cplex ; +option threads = 1; $onecho > cplex.opt $offecho * non-linear solver -$ifthen "%c80_nlp_solver%" == "conopt3" - option nlp = conopt ; -$elseif "%c80_nlp_solver%" == "conopt4" +$ifthen "%c80_nlp_solver%" == "conopt4" option nlp = conopt4; $elseif "%c80_nlp_solver%" == "conopt4+cplex" option nlp = conopt4; @@ -35,10 +34,13 @@ $elseif "%c80_nlp_solver%" == "conopt4+conopt3" s80_add_conopt3 = 1; $endif -$onecho > conopt4.opt -Tol_Obj_Change = 3.0e-7 -$offecho +put optfile; +put 'Tol_Optimality = ', s80_toloptimal:12:11 /; +putclose optfile; +$onecho > conopt4.op2 +Lim_Variable = 1.e25 +$offecho repeat( @@ -57,8 +59,11 @@ $batinclude "./modules/include.gms" nl_fix *' linear optimization if no non-linearities remain in the model (Please note *' that the solve statement still declares a nonlinear / nlp problem even *' though we expect it to be linear!). +*' Solve statement is put twice for improved model results, +*' in particular for matching LHS and RHS of equations. solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); *' A second optimization makes sure that in case of a flat optimum that solution *' is chosen for which the difference in land changes compared to the previous @@ -66,9 +71,10 @@ $batinclude "./modules/include.gms" nl_fix *' of the previous optimization as upper bound and minimizing the land *' differences. - if((magpie.modelstat=1 or magpie.modelstat = 7), + if ((magpie.modelstat=1 or magpie.modelstat = 7), vm_cost_glo.up = vm_cost_glo.l; solve magpie USING nlp MINIMIZING vm_landdiff; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_landdiff; ); vm_cost_glo.up = Inf; ); @@ -122,24 +128,37 @@ $batinclude "./modules/include.gms" nl_relax *' the nonlinear optimization of the model in its full complexity. solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); *' @stop * if s80_add_conopt3 is 1 add additional solve statement for conopt3 if((s80_add_conopt3 = 1), display "Additional solve with CONOPT3!"; - option nlp = conopt; + option nlp = conopt3; solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); + option nlp = conopt4; + ); + +* if solve stopped with an error, try it again with CONOPT4 and OPTFILE + if((magpie.modelstat = 13), + display "WARNING: Modelstat 13 | Retry solve with CONOPT4 increasing largest allowable value"; option nlp = conopt4; + magpie.optfile = 2 + solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); + magpie.optfile = s80_optfile ; ); * if solve stopped with an error, try it again with conopt3 - if((magpie.modelstat = 13), - display "WARNING: Modelstat 13 | retry with CONOPT3!"; - option nlp = conopt; - solve magpie USING nlp MINIMIZING vm_cost_glo; - option nlp = conopt4; - ); + if ((magpie.modelstat = 13), + display "WARNING: Modelstat 13 | retry with CONOPT3!"; + option nlp = conopt3; + solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); + option nlp = conopt4; + ); p80_modelstat(t) = magpie.modelstat; p80_num_nonopt(t) = magpie.numNOpt; @@ -151,13 +170,13 @@ $batinclude "./modules/include.gms" nl_relax * write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= s80_maxiter and p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), + if ((s80_counter >= s80_maxiter and p80_modelstat(t) > 2), magpie.solprint = 1 ); display s80_counter; - until ((p80_modelstat(t) <= 2 and p80_num_nonopt(t) <= s80_num_nonopt_allowed) or s80_counter >= s80_maxiter) + until (p80_modelstat(t) <= 2 or s80_counter >= s80_maxiter) ); * if s80_add_cplex is 1 add additional solve statement for cplex @@ -168,12 +187,14 @@ magpie.trylinear = 1; $batinclude "./modules/include.gms" nl_fix solve magpie USING nlp MINIMIZING vm_cost_glo; +if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); $batinclude "./modules/include.gms" nl_release if((magpie.modelstat=1 or magpie.modelstat = 7), vm_cost_glo.up = vm_cost_glo.l; solve magpie USING nlp MINIMIZING vm_landdiff; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_landdiff; ); vm_cost_glo.up = Inf; ); diff --git a/modules/80_optimization/module.gms b/modules/80_optimization/module.gms index e32f8e83bb..0fe62ee516 100644 --- a/modules/80_optimization/module.gms +++ b/modules/80_optimization/module.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -23,4 +23,5 @@ *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%optimization%" == "lp_nlp_apr17" $include "./modules/80_optimization/lp_nlp_apr17/realization.gms" $Ifi "%optimization%" == "nlp_apr17" $include "./modules/80_optimization/nlp_apr17/realization.gms" +$Ifi "%optimization%" == "nlp_par" $include "./modules/80_optimization/nlp_par/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/80_optimization/nlp_apr17/declarations.gms b/modules/80_optimization/nlp_apr17/declarations.gms index ff51ac3c33..d3776321e1 100644 --- a/modules/80_optimization/nlp_apr17/declarations.gms +++ b/modules/80_optimization/nlp_apr17/declarations.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,10 +6,11 @@ *** | Contact: magpie@pik-potsdam.de parameters - p80_modelstat(t) modelstat indicator (1) - p80_num_nonopt(t) numNOpt indicator (1) + p80_modelstat(t) modelstat indicator (1) + p80_num_nonopt(t) numNOpt indicator (1) ; scalars - s80_counter counter (1) + s80_counter counter (1) + s80_resolve_option option for resolve (1) ; diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index 3ac14f63a1..1486c3a2a0 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,11 +6,8 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / - s80_optfile switch to use specfied solver settings (1) / 0 / - s80_num_nonopt_allowed number of allowed non-optimal variables (1) / Inf / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_optfile switch to use specfied solver settings (1) / 1 / + s80_secondsolve second solve statement (binary) / 0 / + s80_toloptimal value for CONOPT4 Tol_Optimality / 1e-08 / ; - -$setglobal c80_nlp_solver conopt4 -* options: (conopt3): conopt3 -* (conopt4): conopt4 diff --git a/modules/80_optimization/nlp_apr17/not_used.txt b/modules/80_optimization/nlp_apr17/not_used.txt index 2d9f82bd02..ea605f3b35 100644 --- a/modules/80_optimization/nlp_apr17/not_used.txt +++ b/modules/80_optimization/nlp_apr17/not_used.txt @@ -1,8 +1,2 @@ -# | (C) 2008-2019 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 name,type,reason vm_landdiff,input,questionnaire diff --git a/modules/80_optimization/nlp_apr17/preloop.gms b/modules/80_optimization/nlp_apr17/preloop.gms new file mode 100644 index 0000000000..115c631cc6 --- /dev/null +++ b/modules/80_optimization/nlp_apr17/preloop.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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 + +File optfile /conopt4.opt/; + diff --git a/modules/80_optimization/nlp_apr17/realization.gms b/modules/80_optimization/nlp_apr17/realization.gms index 9a8c446553..dd35745758 100644 --- a/modules/80_optimization/nlp_apr17/realization.gms +++ b/modules/80_optimization/nlp_apr17/realization.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -14,5 +14,6 @@ *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "declarations" $include "./modules/80_optimization/nlp_apr17/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/80_optimization/nlp_apr17/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/80_optimization/nlp_apr17/preloop.gms" $Ifi "%phase%" == "solve" $include "./modules/80_optimization/nlp_apr17/solve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index e2704eb2d5..d9facfe83a 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -6,66 +6,102 @@ *** | Contact: magpie@pik-potsdam.de **************start solve loop************** -$ifthen "%c80_nlp_solver%" == "conopt3" - option nlp = conopt ; -$elseif "%c80_nlp_solver%" == "conopt4" - option nlp = conopt4; -$else - abort "c80_nlp_solver setting not supported in nlp_apr17 realization!"; -$endif - s80_counter = 0; -p80_modelstat(t) = 1; +p80_modelstat(t) = 14; +s80_resolve_option = 0; *** solver settings - -magpie.optfile = s80_optfile ; +option nlp = conopt4; +option threads = 1; +magpie.optfile = s80_optfile; magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; -$onecho > conopt4.opt -Tol_Obj_Change = 3.0e-6 +put optfile; +put 'Tol_Optimality = ', s80_toloptimal:12:11 /; +putclose optfile; + +$onecho > conopt4.op2 +Lim_Variable = 1.e25 $offecho -repeat( - s80_counter = s80_counter + 1 ; +if(execerror > 0, + abort "Execution error. Check your .lst file."; +); *' @code - solve magpie USING nlp MINIMIZING vm_cost_glo; +solve magpie USING nlp MINIMIZING vm_cost_glo; +*' Optional second solve statement +if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); *' @stop -* if solve stopped with an error, try it again with conopt3 - if((magpie.modelstat = 13), - display "WARNING: Modelstat 13 | retry with CONOPT3!"; - option nlp = conopt; - solve magpie USING nlp MINIMIZING vm_cost_glo; +display "vm_cost_glo.l"; +display vm_cost_glo.l; +display magpie.modelstat; + +* set modelstat to 13 in case of NA for continuation +magpie.modelStat$(magpie.modelStat=NA) = 13; + +* in case of problems try different solvers and optfile settings +if (magpie.modelstat > 2, + repeat( + s80_counter = s80_counter + 1 ; + s80_resolve_option = s80_resolve_option + 1; + + if(s80_resolve_option = 1, + display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; + option nlp = conopt4; + magpie.optfile = 0; + elseif s80_resolve_option = 2, + display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE"; + option nlp = conopt4; + magpie.optfile = 1; + elseif s80_resolve_option = 3, + display "Modelstat > 2 | Retry solve with CONOPT4 increasing largest allowable value"; option nlp = conopt4; + magpie.optfile = 2; + elseif s80_resolve_option = 4, + display "Modelstat > 2 | Retry solve with CONOPT3"; + option nlp = conopt3; + magpie.optfile = 0; + ); + + solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); + option nlp = conopt4; + magpie.optfile = s80_optfile; + + display "vm_cost_glo.l"; + display vm_cost_glo.l; + +* write extended run information in list file in the case that the final solution is infeasible + if ((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2), + magpie.solprint = 1 ); - p80_modelstat(t) = magpie.modelstat; - p80_num_nonopt(t) = magpie.numNOpt; + display s80_counter; + display magpie.modelstat; +* Set modelstat to 13 in case of NA for the `until` check of the repeat loop. +* Otherwise, the repeat loop will never end. + magpie.modelStat$(magpie.modelStat=NA) = 13; - display "vm_cost_glo.l"; - display vm_cost_glo.l; + s80_resolve_option$(s80_resolve_option >= 4) = 0; -* write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= s80_maxiter and p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), - magpie.solprint = 1 + until (magpie.modelstat <= 2 or s80_counter >= s80_maxiter) ); - - display s80_counter; - - until ((p80_modelstat(t) <= 2 and p80_num_nonopt(t) <= s80_num_nonopt_allowed) or s80_counter >= s80_maxiter) ); -*' @stop +p80_modelstat(t) = magpie.modelstat; +p80_num_nonopt(t) = magpie.numNOpt; -if ((p80_modelstat(t) < 3), +if ((p80_modelstat(t) <= 2), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), + execute 'gmszip -r magpie_problem.zip "%gams.scrdir%"' + put_utility 'shell' / 'mv -f magpie_problem.zip magpie_problem_' t.tl:0'.zip'; Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms new file mode 100644 index 0000000000..2b45f5f256 --- /dev/null +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2025 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 + p80_modelstat(t,h) modelstat indicator (1) + p80_counter(h) counter (1) + p80_handle(h) parallel mode handle parameter (1) + p80_extra_solve(h) indicator for extra solve (1) + p80_counter_modelstat(h) counter for modelstat <= 2 (1) + p80_resolve_option(h) option for resolve (1) +; + +scalars + s80_counter counter (1) + s80_resolve_option option for resolve (1) +; diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms new file mode 100644 index 0000000000..1486c3a2a0 --- /dev/null +++ b/modules/80_optimization/nlp_par/input.gms @@ -0,0 +1,13 @@ +*** | (C) 2008-2025 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 + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_optfile switch to use specfied solver settings (1) / 1 / + s80_secondsolve second solve statement (binary) / 0 / + s80_toloptimal value for CONOPT4 Tol_Optimality / 1e-08 / +; diff --git a/modules/80_optimization/nlp_par/not_used.txt b/modules/80_optimization/nlp_par/not_used.txt new file mode 100644 index 0000000000..ea605f3b35 --- /dev/null +++ b/modules/80_optimization/nlp_par/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +vm_landdiff,input,questionnaire diff --git a/modules/80_optimization/nlp_par/preloop.gms b/modules/80_optimization/nlp_par/preloop.gms new file mode 100644 index 0000000000..115c631cc6 --- /dev/null +++ b/modules/80_optimization/nlp_par/preloop.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2025 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 + +File optfile /conopt4.opt/; + diff --git a/modules/80_optimization/nlp_par/realization.gms b/modules/80_optimization/nlp_par/realization.gms new file mode 100644 index 0000000000..397caff86d --- /dev/null +++ b/modules/80_optimization/nlp_par/realization.gms @@ -0,0 +1,23 @@ +*** | (C) 2008-2025 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 model is solved directly using nonlinear optimization. +*' However, the regions are solved in parallel. This allows to use higher spatial +*' resolution, but works only with fixed trade patterns (exo trade realization). +*' To derive these trade patterns a normal run with global optimization is needed. +*' The start script highres.R illustrates how this can be used. +*' If the optimization returns an infeasible solution the solve is repeated, +*' either until a feasible solution is found or the maximum number of iterations +*' as defined in `s80_maxiter` is reached. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/80_optimization/nlp_par/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/80_optimization/nlp_par/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/80_optimization/nlp_par/preloop.gms" +$Ifi "%phase%" == "solve" $include "./modules/80_optimization/nlp_par/solve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms new file mode 100644 index 0000000000..198a2c48eb --- /dev/null +++ b/modules/80_optimization/nlp_par/solve.gms @@ -0,0 +1,146 @@ +*** | (C) 2008-2025 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 +**************start solve loop************** + +p80_counter(h) = 0; +p80_modelstat(t,h) = 14; +p80_counter_modelstat(h) = 0; +p80_resolve_option(h) = 0; + +*** solver settings +option nlp = conopt4; +option threads = 1; +magpie.solvelink = 3; +magpie.optfile = s80_optfile ; +magpie.scaleopt = 1 ; +magpie.solprint = 0 ; +magpie.holdfixed = 1 ; +magpie.savepoint = 0; + +put optfile; +put 'Tol_Optimality = ', s80_toloptimal:12:11 /; +putclose optfile; + +$onecho > conopt4.op2 +Lim_Variable = 1.e25 +$offecho + +h2(h) = no; +i2(i) = no; +j2(j) = no; + +*submission loop +loop(h, + h2(h) = yes; + i2(i)$supreg(h,i) = yes; + loop(i2, j2(j)$cell(i2,j) = yes); + solve magpie USING nlp MINIMIZING vm_cost_glo; + h2(h) = no; + i2(i) = no; + j2(j) = no; + p80_handle(h) = magpie.handle; +); + +*collection loop +repeat + loop(h$p80_handle(h), + if(handleStatus(p80_handle(h)) = 2, + p80_counter(h) = p80_counter(h) + 1; + p80_extra_solve(h) = 1; + + magpie.handle = p80_handle(h); + execute_loadhandle magpie; + + h2(h) = yes; + i2(i)$supreg(h,i) = yes; + loop(i2, j2(j)$cell(i2,j) = yes); + display h2; + s80_counter = sum(h2,p80_counter(h2)); + display s80_counter; + display magpie.modelStat; + display vm_cost_glo.l; + magpie.modelStat$(magpie.modelStat=NA) = 13; + + p80_modelstat(t,h) = magpie.modelStat; + + if(p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2, + execute 'gmszip -r magpie_problem.zip "%gams.scrdir%"' + put_utility 'shell' / 'mv -f magpie_problem.zip magpie_problem_' h.tl:0'_' t.tl:0'.zip'; + display "No feasible solution found. Writing LST file."; + option AsyncSolLst=1; + display$handlecollect(p80_handle(h)) 're-collect'; + option AsyncSolLst=0; + p80_extra_solve(h) = 0; + ); + + display$handledelete(p80_handle(h)) 'trouble deleting handles' ; + + if(p80_modelstat(t,h) <= 2, + p80_counter_modelstat(h) = p80_counter_modelstat(h) + 1; + if(p80_counter_modelstat(h) < 2 AND s80_secondsolve = 1, + display "Model status <= 2. Starting second solve"; + solve magpie USING nlp MINIMIZING vm_cost_glo; + p80_handle(h) = magpie.handle; + p80_extra_solve(h) = 0; + else + display "Model status <= 2. Handle cleared."; + p80_extra_solve(h) = 0; + p80_handle(h) = 0; + ); + ); + + if(p80_extra_solve(h) = 1, + display "Resolve"; + p80_resolve_option(h) = p80_resolve_option(h) + 1; + s80_resolve_option = sum(h2,p80_resolve_option(h2)); + display s80_resolve_option; + if(p80_resolve_option(h) = 1, + display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; + option nlp = conopt4; + magpie.optfile = 0; + elseif p80_resolve_option(h) = 2, + display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE"; + option nlp = conopt4; + magpie.optfile = 1; + elseif p80_resolve_option(h) = 3, + display "Modelstat > 2 | Retry solve with CONOPT4 increasing largest allowable value"; + option nlp = conopt4; + magpie.optfile = 2; + elseif p80_resolve_option(h) = 4, + display "Modelstat > 2 | Retry solve with CONOPT3"; + option nlp = conopt3; + magpie.optfile = 0; + ); + if(execerror > 0, execerror = 0); + + solve magpie USING nlp MINIMIZING vm_cost_glo; + magpie.handle$(magpie.handle = 0) = 1; + p80_handle(h) = magpie.handle; + option nlp = conopt4; + magpie.optfile = s80_optfile; + + p80_resolve_option(h)$(p80_resolve_option(h) >= 4) = 0; + ); + h2(h) = no; + i2(i) = no; + j2(j) = no; + ); + ); +display$sleep(card(p80_handle)*0.2) 'sleep some time'; +display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; +until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; + +if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, + Execute_Unload "fulldata.gdx"; + abort "No feasible solution found!"; +); + +* handleSubmit does not work because it requires the script `gmsrerun.cmd` or `gmsrerun.run` in the grid directory. +* Therefore, solve statements are used. +* display$handleSubmit(p80_handle(h)) 'trouble resubmitting handles' ; + +***************end solve loop*************** diff --git a/modules/include.gms b/modules/include.gms index 1c9b532ba9..21c3a22fc6 100644 --- a/modules/include.gms +++ b/modules/include.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -21,17 +21,23 @@ $include "./modules/17_production/module.gms" $include "./modules/18_residues/module.gms" $include "./modules/20_processing/module.gms" $include "./modules/21_trade/module.gms" -$include "./modules/30_crop/module.gms" +$include "./modules/22_land_conservation/module.gms" +$include "./modules/28_ageclass/module.gms" +$include "./modules/29_cropland/module.gms" +$include "./modules/30_croparea/module.gms" $include "./modules/31_past/module.gms" $include "./modules/32_forestry/module.gms" $include "./modules/34_urban/module.gms" $include "./modules/35_natveg/module.gms" +$include "./modules/36_employment/module.gms" +$include "./modules/37_labor_prod/module.gms" $include "./modules/38_factor_costs/module.gms" $include "./modules/39_landconversion/module.gms" $include "./modules/40_transport/module.gms" $include "./modules/41_area_equipped_for_irrigation/module.gms" $include "./modules/42_water_demand/module.gms" $include "./modules/43_water_availability/module.gms" +$include "./modules/44_biodiversity/module.gms" $include "./modules/45_climate/module.gms" $include "./modules/50_nr_soil_budget/module.gms" $include "./modules/51_nitrogen/module.gms" @@ -41,11 +47,13 @@ $include "./modules/54_phosphorus/module.gms" $include "./modules/55_awms/module.gms" $include "./modules/56_ghg_policy/module.gms" $include "./modules/57_maccs/module.gms" +$include "./modules/58_peatland/module.gms" $include "./modules/59_som/module.gms" $include "./modules/60_bioenergy/module.gms" $include "./modules/62_material/module.gms" $include "./modules/70_livestock/module.gms" $include "./modules/71_disagg_lvst/module.gms" +$include "./modules/73_timber/module.gms" $include "./modules/80_optimization/module.gms" *######################## R SECTION END (MODULES) ############################## $offrecurse diff --git a/output.R b/output.R index 137affefdc..c024b32e5e 100644 --- a/output.R +++ b/output.R @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -9,63 +9,65 @@ #### MAgPIE output generation #### ########################################################## -library(lucode) - -runOutputs <- function(comp=NULL, output=NULL, outputdirs=NULL, submit=NULL) { +if (!is.null(renv::project()) && !exists("source_include") && Sys.getenv("SLURM_JOB_ID") == "") { + ask <- function(question) { + message(question, appendLF = FALSE) + return(tolower(gms::getLine()) %in% c("", "y", "yes")) + } - get_line <- function(){ - # gets characters (line) from the terminal or from a connection - # and returns it - if(interactive()){ - s <- readline() - } else { - con <- file("stdin") - s <- readLines(con, 1, warn=FALSE) - on.exit(close(con)) - } - return(s); + message("Checking for updates... ", appendLF = FALSE) + if (getOption("autoRenvUpdates", FALSE) || + (!is.null(piamenv::showUpdates()) && ask("Update now? (Y/n): "))) { + updates <- piamenv::updateRenv() + piamenv::stopIfLoaded(names(updates)) } + message("Update check done.") - choose_folder <- function(title="Please choose a folder") { - # try to use find because it is significantly quicker than list.dirs - tmp <- try(system("find ./output -name 'fulldata.gdx'", intern=TRUE, ignore.stderr = TRUE), silent=TRUE) - if("try-error" %in% class(tmp) | length(tmp)==0) { - tmp <- base::list.dirs("./output/",recursive=TRUE) - dirs <- NULL - for (i in 1:length(tmp)) { - if (file.exists(path(tmp[i],"fulldata.gdx"))) dirs <- c(dirs,sub("./output/","",tmp[i])) - } - } else { - dirs <- sub("fulldata.gdx","",sub("./output/","",tmp, fixed=TRUE), fixed=TRUE) - } + message("Checking package version requirements... ", appendLF = FALSE) + updates <- piamenv::fixDeps(ask = TRUE) + piamenv::stopIfLoaded(names(updates)) + message("Requirements check done.") +} + +library(lucode2) +library(gms) +source("scripts/helper.R") + +runOutputs <- function(comp=NULL, output=NULL, outputdir=NULL, submit=NULL) { + chooseFolder <- function(title="Please choose a folder") { + dirs <- c(Sys.glob("./output/*/full.gms"), Sys.glob("./output/HR*/*/full.gms")) + dirs <- sub("^\\./output/", "", dirs) + dirs <- sub("/full\\.gms$", "", dirs) dirs <- sort(dirs) dirs <- c("all",dirs) cat("\n",title,":\n", sep="") - cat(paste(1:length(dirs), dirs, sep=": " ),sep="\n") + cat(paste(seq_along(dirs), dirs, sep=": " ),sep="\n") cat(paste(length(dirs)+1, "Search by the pattern.\n", sep=": ")) cat("Number: ") - identifier <- get_line() + identifier <- gms::getLine() identifier <- strsplit(identifier,",")[[1]] tmp <- NULL - for (i in 1:length(identifier)) { - if (length(strsplit(identifier,":")[[i]]) > 1) tmp <- c(tmp,as.numeric(strsplit(identifier,":")[[i]])[1]:as.numeric(strsplit(identifier,":")[[i]])[2]) + for (i in seq_along(identifier)) { + if (length(strsplit(identifier,":")[[i]]) > 1) { + tmp <- c(tmp,as.numeric(strsplit(identifier,":")[[i]])[1]:as.numeric(strsplit(identifier,":")[[i]])[2]) + } else tmp <- c(tmp,as.numeric(identifier[i])) } identifier <- tmp # PATTERN - if(length(identifier==1) && identifier==(length(dirs)+1)){ + if(length(identifier) == 1 && identifier == length(dirs) + 1) { cat("\nInsert the search pattern or the regular expression: ") - pattern <- get_line() - id <- grep(pattern=pattern, dirs[-1]) + pattern <- gms::getLine() + id <- grep(pattern=pattern, dirs[-1], perl=TRUE) # lists all directories matching the pattern and ask for confirmation cat("\n\nYou have chosen the following directories:\n") - cat(paste(1:length(id), dirs[id+1], sep=": "), sep="\n") + cat(paste(seq_along(id), dirs[id+1], sep=": "), sep="\n") cat("\nAre you sure these are the right directories?(y/n): ") - answer <- get_line() + answer <- gms::getLine() if(answer=="y"){ return(paste0("./output/",dirs[id+1])) } else { - choose_folder(title) + chooseFolder(title) } } else if(any(dirs[identifier] == "all")){ identifier <- 2:length(dirs) @@ -75,129 +77,120 @@ runOutputs <- function(comp=NULL, output=NULL, outputdirs=NULL, submit=NULL) { } } - choose_module <- function(Rfolder,title="Please choose an outputmodule") { - module <- gsub("\\.R$","",grep("\\.R$",list.files(Rfolder), value=TRUE)) - cat("\n",title,":\n",sep="") - cat(paste(1: length(module), module, sep=": " ),sep="\n") - cat("Number: ") - identifier <- get_line() - identifier <- as.numeric(strsplit(identifier,",")[[1]]) - if (any(!(identifier %in% 1:length(module)))) stop("This choice (",identifier,") is not possible. Please type in a number between 1 and ",length(module)) - return(module[identifier]) - } - - choose_mode <- function(title="Please choose the output mode") { - modes <- c("Output for single run ","Comparison across runs") - cat("\n",title,":\n",sep="") - cat(paste(1:length(modes), modes, sep=": " ),sep="\n") - cat("Number: ") - identifier <- get_line() - identifier <- as.numeric(strsplit(identifier,",")[[1]]) - if (identifier==1) { - return(FALSE) - } else if (identifier==2) { - return(TRUE) - } else { - stop("This mode is invalid. Please choose a valid mode") - } - } - - choose_submit <- function(title="Please choose run submission type") { - slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE)) - modes <- c("SLURM (default)", "SLURM priority","Direct execution", "Background execution", "Debug mode") - if(slurm) { - cat("\nCurrent cluster utilization:\n") - system("sclass") - cat("\n") - } else { - modes <- modes[-1:-2] - } - cat("\n",title,":\n",sep="") - cat(paste(1:length(modes), modes, sep=": " ),sep="\n") - cat("Number: ") - identifier <- get_line() - identifier <- as.numeric(strsplit(identifier,",")[[1]]) - if(slurm) { - system("sclass") - comp <- switch(identifier, - "1" = "slurm default", - "2" = "slurm priority", - "3" = "direct", - "4" = "background", - "5" = "debug") - - } else { - comp <- switch(identifier, - "1" = "direct", - "2" = "background", - "3" = "debug") - } - if(is.null(comp)) stop("This type is invalid. Please choose a valid type") - return(comp) - } - - runsubmit <- function(output, outputdirs, comp, script_path) { + runsubmit <- function(output, alloutputdirs, submit, scriptPath, slurmModes) { + if(!dir.exists("logs")) dir.create("logs") + #Set value source_include so that loaded scripts know, that they are + #included as source (instead of a load from command line) + source_include <- TRUE # nolint # run output scripts over all choosen folders for(rout in output){ - name <- paste0(rout,".R") - script <- paste0(script_path,name) + name <- ifelse(file.exists(paste0(scriptPath, rout)), rout, paste0(rout, ".R")) + script <- paste0(scriptPath, name) if(!file.exists(script)) { warning("Script ",name, " could not be found. Skip execution!") next } - if(!comp) outputdir <- outputdirs - cat(" -> ",name) - if(submit=="direct") { - tmp.env <- new.env() - tmp.error <- try(sys.source(script,envir=tmp.env)) - if(!is.null(tmp.error)) warning("Script ",name," was stopped by an error and not executed properly!") - rm(tmp.env) - } else if(submit=="background") { - system(paste0("Rscript output.R outputdirs=",paste(outputdirs,collapse=",")," comp=",comp," output=",rout," submit=direct &> ",format(Sys.time(), "blog_out-%Y-%H-%M-%S-%OS3.log")," &")) - } else if(submit=="slurm default") { - system(paste0("srun --qos=standby --job-name=scripts-output --output=log_out-%j.out --error=log_out-%j.err --mail-type=END --time=200 --mem-per-cpu=8000 Rscript output.R outputdirs=",paste(outputdirs,collapse=",")," comp=",comp," output=",rout," submit=direct &")) - Sys.sleep(1) - } else if(submit=="slurm priority") { - system(paste0("srun --qos=priority --job-name=scripts-output --output=log_out-%j.out --error=log_out-%j.err --mail-type=END --mem-per-cpu=8000 Rscript output.R outputdirs=",paste(outputdirs,collapse=",")," comp=",comp," output=",rout," submit=direct &")) - Sys.sleep(1) - } else if(submit=="debug") { - tmp.env <- new.env() - sys.source(script,envir=tmp.env) - rm(tmp.env) + header <- read_yaml_header(script) + comp <- (!is.null(header[["comparison script"]]) && isTRUE(header[["comparison script"]])) + if(comp) { + loop <- list(alloutputdirs) } else { - stop("Unknown submission type") + loop <- alloutputdirs + } + rout_name <- sub("\\.R$","",sub("/","_",rout)) + for(outputdir in loop) { + message("\n# ",name, " -> ", outputdir) + rCommand <- paste0("output.R outputdir=",paste(outputdir,collapse=",")," output=",rout," submit=direct") + if(submit %in% c("Direct execution", "direct")) { + tmp.env <- new.env() + tmp.error <- try(sys.source(script,envir=tmp.env)) + if(!is.null(tmp.error)) warning("Script ",name," was stopped by an error and not executed properly!") + rm(tmp.env) + } else if(submit %in% c("Background execution", "background")) { + log <- format(Sys.time(), paste0("logs/out-",rout_name,"-%Y-%H-%M-%S-%OS3.log")) + system2("Rscript", rCommand, stderr = log, stdout = log, wait=FALSE) + } else if(submit %in% c("Debug mode", "debug")) { + tmp.env <- new.env() + sys.source(script,envir=tmp.env) + rm(tmp.env) + } else { + slurm <- yaml::read_yaml(slurmModes)$slurmjobs + if(submit %in% names(slurm)) { + command <- slurm[submit] + command <- gsub("%NAME", rout_name, command) + command <- gsub("%SCRIPT", rCommand, command) + message(command) + system(command) + } else { + stop("Unknown submission type") + } + } } } } + if (is.null(outputdir)) outputdir <- chooseFolder("Choose runs") + if (is.null(output)) output <- gms::selectScript("./scripts/output") + if (is.null(submit)) submit <- chooseSubmit("Choose submission type", + slurmModes = "scripts/slurmOutput.yml") + if (is.null(output)) { + message("No output script selected! Stop here.") + return(invisible(NULL)) + } + if(is.null(outputdir)) { + message("No output folder selected! Stop here.") + return(invisible(NULL)) + } + + # Write a separate lockfile called {datetime}_{outputscript}_renv.lock into outputdir + # unless the renv from outputdir itself was used to run output.R + if (!is.null(renv::project())) { + freshLockfile <- withr::local_tempfile() + + message("Generating lockfile... ", appendLF = FALSE) + errorMessage1 <- utils::capture.output({ + errorMessage2 <- utils::capture.output({ + snapshotSuccess <- tryCatch({ + renv::snapshot(lockfile = freshLockfile, prompt = FALSE) + TRUE + }, error = function(error) FALSE) + }, type = "message") + }) + if (!snapshotSuccess) { + warning(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) + } + message("done.") - if(is.null(comp)) comp <- choose_mode("Choose output type") - if(is.null(outputdirs)) outputdirs <- choose_folder("Choose runs") - if(is.null(output)) output <- choose_module(ifelse(comp,"./scripts/output/comparison","./scripts/output/single"), - "Choose output scripts") - if(is.null(submit)) submit <- choose_submit("Choose submission type") + datetime <- format(Sys.time(), "%Y-%m-%dT%H%M%S") + scriptName <- gsub("/", "-", paste(sub("\\.R$", "", output), collapse = "--")) - #Set value source_include so that loaded scripts know, that they are - #included as source (instead of a load from command line) - source_include <- TRUE + for (runFolder in setdiff(normalizePath(outputdir), normalizePath(renv::project()))) { + newLockfile <- file.path(runFolder, paste0(datetime, "__", scriptName, "__renv.lock")) + file.copy(freshLockfile, newLockfile) - if (comp) { - cat("Output comparsion mode\n") - runsubmit(output, outputdirs, TRUE, "scripts/output/comparison/") - } else { - cat("Run postprocessing mode\n") - for (outputdir in outputdirs) { - cat(paste("\nSubmit",outputdir)) - runsubmit(output, outputdir, FALSE, "scripts/output/single/") + if (!file.exists(file.path(runFolder, "renv.lock"))) { + warning(normalizePath(runFolder), "/renv.lock does not exist.") + message("Lockfile written to ", newLockfile) + } else if (!file.exists(newLockfile)) { + message("Could not write lockfile, see warning thrown earlier.") + } else if (identical(readLines(file.path(runFolder, "renv.lock")), readLines(newLockfile))) { + file.remove(newLockfile) + } else { + message("Lockfile written to ", newLockfile) + } } } - cat("\n\n") + + runsubmit(output = output, alloutputdirs = outputdir, + submit = submit, scriptPath = "scripts/output/", + slurmModes = "scripts/slurmOutput.yml") + message("") } -if(!exists("source_include")) { - comp <- output <- outputdirs <- submit <- NULL - readArgs("comp","output","outputdirs","submit", .silent=TRUE) +if (!exists("source_include")) { + output <- outputdir <- submit <- NULL + lucode2::readArgs("output", "outputdir", "submit", .silent = TRUE) } -runOutputs(comp=comp, output=output, outputdirs = outputdirs, submit=submit) +runOutputs(output = output, outputdir = outputdir, submit = submit) diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 0000000000..7b56d7001f --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,8 @@ +library/ +local/ +cellar/ +lock/ +python/ +sandbox/ +staging/ +archive/ diff --git a/renv/activate.R b/renv/activate.R new file mode 100644 index 0000000000..2753ae544b --- /dev/null +++ b/renv/activate.R @@ -0,0 +1,1334 @@ + +local({ + + # the requested version of renv + version <- "1.1.5" + attr(version, "sha") <- NULL + + # the project directory + project <- Sys.getenv("RENV_PROJECT") + if (!nzchar(project)) + project <- getwd() + + # use start-up diagnostics if enabled + diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE") + if (diagnostics) { + start <- Sys.time() + profile <- tempfile("renv-startup-", fileext = ".Rprof") + utils::Rprof(profile) + on.exit({ + utils::Rprof(NULL) + elapsed <- signif(difftime(Sys.time(), start, units = "auto"), digits = 2L) + writeLines(sprintf("- renv took %s to run the autoloader.", format(elapsed))) + writeLines(sprintf("- Profile: %s", profile)) + print(utils::summaryRprof(profile)) + }, add = TRUE) + } + + # figure out whether the autoloader is enabled + enabled <- local({ + + # first, check config option + override <- getOption("renv.config.autoloader.enabled") + if (!is.null(override)) + return(override) + + # if we're being run in a context where R_LIBS is already set, + # don't load -- presumably we're being run as a sub-process and + # the parent process has already set up library paths for us + rcmd <- Sys.getenv("R_CMD", unset = NA) + rlibs <- Sys.getenv("R_LIBS", unset = NA) + if (!is.na(rlibs) && !is.na(rcmd)) + return(FALSE) + + # next, check environment variables + # prefer using the configuration one in the future + envvars <- c( + "RENV_CONFIG_AUTOLOADER_ENABLED", + "RENV_AUTOLOADER_ENABLED", + "RENV_ACTIVATE_PROJECT" + ) + + for (envvar in envvars) { + envval <- Sys.getenv(envvar, unset = NA) + if (!is.na(envval)) + return(tolower(envval) %in% c("true", "t", "1")) + } + + # enable by default + TRUE + + }) + + # bail if we're not enabled + if (!enabled) { + + # if we're not enabled, we might still need to manually load + # the user profile here + profile <- Sys.getenv("R_PROFILE_USER", unset = "~/.Rprofile") + if (file.exists(profile)) { + cfg <- Sys.getenv("RENV_CONFIG_USER_PROFILE", unset = "TRUE") + if (tolower(cfg) %in% c("true", "t", "1")) + sys.source(profile, envir = globalenv()) + } + + return(FALSE) + + } + + # avoid recursion + if (identical(getOption("renv.autoloader.running"), TRUE)) { + warning("ignoring recursive attempt to run renv autoloader") + return(invisible(TRUE)) + } + + # signal that we're loading renv during R startup + options(renv.autoloader.running = TRUE) + on.exit(options(renv.autoloader.running = NULL), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # unload renv if it's already been loaded + if ("renv" %in% loadedNamespaces()) + unloadNamespace("renv") + + # load bootstrap tools + ansify <- function(text) { + if (renv_ansify_enabled()) + renv_ansify_enhanced(text) + else + renv_ansify_default(text) + } + + renv_ansify_enabled <- function() { + + override <- Sys.getenv("RENV_ANSIFY_ENABLED", unset = NA) + if (!is.na(override)) + return(as.logical(override)) + + pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE", unset = NA) + if (identical(pane, "build")) + return(FALSE) + + testthat <- Sys.getenv("TESTTHAT", unset = "false") + if (tolower(testthat) %in% "true") + return(FALSE) + + iderun <- Sys.getenv("R_CLI_HAS_HYPERLINK_IDE_RUN", unset = "false") + if (tolower(iderun) %in% "false") + return(FALSE) + + TRUE + + } + + renv_ansify_default <- function(text) { + text + } + + renv_ansify_enhanced <- function(text) { + + # R help links + pattern <- "`\\?(renv::(?:[^`])+)`" + replacement <- "`\033]8;;x-r-help:\\1\a?\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # runnable code + pattern <- "`(renv::(?:[^`])+)`" + replacement <- "`\033]8;;x-r-run:\\1\a\\1\033]8;;\a`" + text <- gsub(pattern, replacement, text, perl = TRUE) + + # return ansified text + text + + } + + renv_ansify_init <- function() { + + envir <- renv_envir_self() + if (renv_ansify_enabled()) + assign("ansify", renv_ansify_enhanced, envir = envir) + else + assign("ansify", renv_ansify_default, envir = envir) + + } + + `%||%` <- 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) + + } + + heredoc <- function(text, leave = 0) { + + # remove leading, trailing whitespace + trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text) + + # split into lines + lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]] + + # compute common indent + indent <- regexpr("[^[:space:]]", lines) + common <- min(setdiff(indent, -1L)) - leave + text <- paste(substring(lines, common), collapse = "\n") + + # substitute in ANSI links for executable renv code + ansify(text) + + } + + 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) + + # 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("") + + return(invisible()) + } + + renv_bootstrap_tests_running <- function() { + getOption("renv.tests.running", default = FALSE) + } + + 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) + + return(repos) + + } + + # check for lockfile repositories + repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) + if (!inherits(repos, "error") && length(repos)) + return(repos) + + # retrieve current repos + repos <- getOption("repos") + + # ensure @CRAN@ entries are resolved + repos[repos == "@CRAN@"] <- cran + + # add in renv.bootstrap.repos if set + default <- c(FALLBACK = "https://cloud.r-project.org") + extra <- getOption("renv.bootstrap.repos", default = default) + repos <- c(repos, extra) + + # remove duplicates that might've snuck in + dupes <- duplicated(repos) | duplicated(names(repos)) + repos[!dupes] + + } + + renv_bootstrap_repos_lockfile <- function() { + + lockpath <- Sys.getenv("RENV_PATHS_LOCKFILE", unset = "renv.lock") + if (!file.exists(lockpath)) + return(NULL) + + lockfile <- tryCatch(renv_json_read(lockpath), error = identity) + if (inherits(lockfile, "error")) { + warning(lockfile) + return(NULL) + } + + repos <- lockfile$R$Repositories + if (length(repos) == 0) + return(NULL) + + keys <- vapply(repos, `[[`, "Name", FUN.VALUE = character(1)) + vals <- vapply(repos, `[[`, "URL", FUN.VALUE = character(1)) + names(vals) <- keys + + return(vals) + + } + + 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) + ) + + } 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) + if (is.character(path) && file.exists(path)) + return(path) + } + + stop("All download methods failed") + + } + + renv_bootstrap_download_impl <- function(url, destfile) { + + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) + mode <- "w+b" + + args <- list( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + + if ("headers" %in% names(formals(utils::download.file))) { + headers <- renv_bootstrap_download_custom_headers(url) + if (length(headers) && is.character(headers)) + args$headers <- headers + } + + do.call(utils::download.file, args) + + } + + renv_bootstrap_download_custom_headers <- function(url) { + + headers <- getOption("renv.download.headers") + if (is.null(headers)) + return(character()) + + if (!is.function(headers)) + stopf("'renv.download.headers' is not a function") + + headers <- headers(url) + if (length(headers) == 0L) + return(character()) + + if (is.list(headers)) + headers <- unlist(headers, recursive = FALSE, use.names = TRUE) + + ok <- + is.character(headers) && + is.character(names(headers)) && + all(nzchar(names(headers))) + + if (!ok) + stop("invocation of 'renv.download.headers' did not return a named character vector") + + headers + + } + + renv_bootstrap_download_cran_latest <- function(version) { + + spec <- renv_bootstrap_download_cran_latest_find(version) + type <- spec$type + repos <- spec$repos + + baseurl <- utils::contrib.url(repos = repos, type = type) + ext <- if (identical(type, "source")) + ".tar.gz" + else if (Sys.info()[["sysname"]] == "Windows") + ".zip" + else + ".tgz" + name <- sprintf("renv_%s%s", version, ext) + url <- paste(baseurl, name, sep = "/") + + destfile <- file.path(tempdir(), name) + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (inherits(status, "condition")) + return(FALSE) + + # report success and return + destfile + + } + + renv_bootstrap_download_cran_latest_find <- function(version) { + + # check whether binaries are supported on this system + binary <- + getOption("renv.bootstrap.binary", default = TRUE) && + !identical(.Platform$pkgType, "source") && + !identical(getOption("pkgType"), "source") && + Sys.info()[["sysname"]] %in% c("Darwin", "Windows") + + types <- c(if (binary) "binary", "source") + + # iterate over types + repositories + for (type in types) { + for (repos in renv_bootstrap_repos()) { + + # build arguments for utils::available.packages() call + args <- list(type = type, repos = repos) + + # add custom headers if available -- note that + # utils::available.packages() will pass this to download.file() + if ("headers" %in% names(formals(utils::download.file))) { + headers <- renv_bootstrap_download_custom_headers(repos) + if (length(headers) && is.character(headers)) + args$headers <- headers + } + + # retrieve package database + db <- tryCatch( + as.data.frame( + do.call(utils::available.packages, args), + stringsAsFactors = FALSE + ), + error = identity + ) + + if (inherits(db, "error")) + next + + # check for compatible entry + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) + next + + # found it; return spec to caller + spec <- list(entry = entry, type = type, repos = repos) + return(spec) + + } + } + + # if we got here, we failed to find renv + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + + } + + renv_bootstrap_download_cran_archive <- function(version) { + + name <- sprintf("renv_%s.tar.gz", version) + repos <- renv_bootstrap_repos() + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + for (url in urls) { + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) + return(destfile) + + } + + return(FALSE) + + } + + renv_bootstrap_download_tarball <- function(version) { + + # if the user has provided the path to a tarball via + # an environment variable, then use it + tarball <- Sys.getenv("RENV_BOOTSTRAP_TARBALL", unset = NA) + if (is.na(tarball)) + return() + + # allow directories + if (dir.exists(tarball)) { + name <- sprintf("renv_%s.tar.gz", version) + tarball <- file.path(tarball, name) + } + + # bail if it doesn't exist + 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." + msg <- sprintf(fmt, tarball) + warning(msg) + + # bail + return() + + } + + catf("- Using local tarball '%s'.", tarball) + tarball + + } + + renv_bootstrap_github_token <- function() { + for (envvar in c("GITHUB_TOKEN", "GITHUB_PAT", "GH_TOKEN")) { + envval <- Sys.getenv(envvar, unset = NA) + if (!is.na(envval)) + return(envval) + } + } + + renv_bootstrap_download_github <- function(version) { + + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) + return(FALSE) + + # prepare download options + token <- renv_bootstrap_github_token() + if (is.null(token)) + token <- "" + + if (nzchar(Sys.which("curl")) && nzchar(token)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, token) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(token)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, token) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) + 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() + } + + # 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 + 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) + + args <- c( + "--vanilla", "CMD", "INSTALL", "--no-multiarch", + "-l", shQuote(path.expand(library)), + shQuote(path.expand(tarball)) + ) + + system2(R, args, stdout = TRUE, stderr = TRUE) + + } + + renv_bootstrap_platform_prefix_default <- function() { + + # read version component + version <- Sys.getenv("RENV_PATHS_VERSION", unset = "R-%v") + + # expand placeholders + placeholders <- list( + list("%v", format(getRversion()[1, 1:2])), + list("%V", format(getRversion()[1, 1:3])) + ) + + for (placeholder in placeholders) + version <- gsub(placeholder[[1L]], placeholder[[2L]], version, fixed = TRUE) + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) + version <- paste(version, R.version[["svn rev"]], sep = "-r") + + version + + } + + renv_bootstrap_platform_prefix <- function() { + + # construct version prefix + version <- renv_bootstrap_platform_prefix_default() + + # build list of path components + components <- c(version, R.version$platform) + + # include prefix if provided by user + prefix <- renv_bootstrap_platform_prefix_impl() + if (!is.na(prefix) && nzchar(prefix)) + components <- c(prefix, components) + + # build prefix + paste(components, collapse = "/") + + } + + renv_bootstrap_platform_prefix_impl <- function() { + + # if an explicit prefix has been supplied, use it + prefix <- Sys.getenv("RENV_PATHS_PREFIX", unset = NA) + if (!is.na(prefix)) + return(prefix) + + # if the user has requested an automatic prefix, generate it + auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) + if (is.na(auto) && getRversion() >= "4.4.0") + auto <- "TRUE" + + if (auto %in% c("TRUE", "True", "true", "1")) + return(renv_bootstrap_platform_prefix_auto()) + + # empty string on failure + "" + + } + + renv_bootstrap_platform_prefix_auto <- function() { + + prefix <- tryCatch(renv_bootstrap_platform_os(), error = identity) + if (inherits(prefix, "error") || prefix %in% "unknown") { + + msg <- paste( + "failed to infer current operating system", + "please file a bug report at https://github.com/rstudio/renv/issues", + sep = "; " + ) + + warning(msg) + + } + + prefix + + } + + renv_bootstrap_platform_os <- function() { + + sysinfo <- Sys.info() + sysname <- sysinfo[["sysname"]] + + # handle Windows + macOS up front + if (sysname == "Windows") + return("windows") + else if (sysname == "Darwin") + return("macos") + + # check for os-release files + for (file in c("/etc/os-release", "/usr/lib/os-release")) + if (file.exists(file)) + return(renv_bootstrap_platform_os_via_os_release(file, sysinfo)) + + # check for redhat-release files + if (file.exists("/etc/redhat-release")) + return(renv_bootstrap_platform_os_via_redhat_release()) + + "unknown" + + } + + renv_bootstrap_platform_os_via_os_release <- function(file, sysinfo) { + + # read /etc/os-release + release <- utils::read.table( + file = file, + sep = "=", + quote = c("\"", "'"), + col.names = c("Key", "Value"), + comment.char = "#", + stringsAsFactors = FALSE + ) + + vars <- as.list(release$Value) + names(vars) <- release$Key + + # get os name + os <- tolower(sysinfo[["sysname"]]) + + # read id + id <- "unknown" + for (field in c("ID", "ID_LIKE")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + id <- vars[[field]] + break + } + } + + # read version + version <- "unknown" + for (field in c("UBUNTU_CODENAME", "VERSION_CODENAME", "VERSION_ID", "BUILD_ID")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + version <- vars[[field]] + break + } + } + + # join together + paste(c(os, id, version), collapse = "-") + + } + + renv_bootstrap_platform_os_via_redhat_release <- function() { + + # read /etc/redhat-release + contents <- readLines("/etc/redhat-release", warn = FALSE) + + # infer id + id <- if (grepl("centos", contents, ignore.case = TRUE)) + "centos" + else if (grepl("redhat", contents, ignore.case = TRUE)) + "redhat" + else + "unknown" + + # try to find a version component (very hacky) + version <- "unknown" + + parts <- strsplit(contents, "[[:space:]]")[[1L]] + for (part in parts) { + + nv <- tryCatch(numeric_version(part), error = identity) + if (inherits(nv, "error")) + next + + version <- nv[1, 1] + break + + } + + paste(c("linux", id, version), collapse = "-") + + } + + renv_bootstrap_library_root_name <- function(project) { + + # use project name as-is if requested + asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") + if (asis) + return(basename(project)) + + # otherwise, disambiguate based on project's path + id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) + paste(basename(project), id, sep = "-") + + } + + renv_bootstrap_library_root <- function(project) { + + prefix <- renv_bootstrap_profile_prefix() + + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) + return(paste(c(path, prefix), collapse = "/")) + + path <- renv_bootstrap_library_root_impl(project) + if (!is.null(path)) { + name <- renv_bootstrap_library_root_name(project) + return(paste(c(path, prefix, name), collapse = "/")) + } + + renv_bootstrap_paths_renv("library", project = project) + + } + + renv_bootstrap_library_root_impl <- function(project) { + + root <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(root)) + return(root) + + type <- renv_bootstrap_project_type(project) + if (identical(type, "package")) { + userdir <- renv_bootstrap_user_dir() + return(file.path(userdir, "library")) + } + + } + + renv_bootstrap_validate_version <- function(version, description = NULL) { + + # resolve description file + # + # avoid passing lib.loc to `packageDescription()` below, since R will + # use the loaded version of the package by default anyhow. note that + # this function should only be called after 'renv' is loaded + # https://github.com/rstudio/renv/issues/1625 + description <- description %||% packageDescription("renv") + + # 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) + + if (valid) + return(TRUE) + + # the loaded version of renv doesn't match the requested version; + # give the user instructions on how to proceed + dev <- identical(description[["RemoteType"]], "github") + remote <- if (dev) + 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 = if (dev) description[["RemoteSha"]] + ) + + fmt <- heredoc(" + 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. + ") + catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) + + FALSE + + } + + renv_bootstrap_validate_version_dev <- function(version, description) { + + expected <- description[["RemoteSha"]] + if (!is.character(expected)) + return(FALSE) + + pattern <- sprintf("^\\Q%s\\E", version) + grepl(pattern, expected, perl = TRUE) + + } + + 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-") + on.exit(unlink(hashfile), add = TRUE) + + writeLines(text, con = hashfile) + tools::md5sum(hashfile) + + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) + return(FALSE) + + # 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 = warnify) + + # load the project + renv::load(project) + + TRUE + + } + + renv_bootstrap_profile_load <- function(project) { + + # if RENV_PROFILE is already set, just use that + profile <- Sys.getenv("RENV_PROFILE", unset = NA) + if (!is.na(profile) && nzchar(profile)) + return(profile) + + # check for a profile file (nothing to do if it doesn't exist) + path <- renv_bootstrap_paths_renv("profile", profile = FALSE, project = project) + if (!file.exists(path)) + return(NULL) + + # read the profile, and set it if it exists + contents <- readLines(path, warn = FALSE) + if (length(contents) == 0L) + return(NULL) + + # set RENV_PROFILE + profile <- contents[[1L]] + if (!profile %in% c("", "default")) + Sys.setenv(RENV_PROFILE = profile) + + profile + + } + + renv_bootstrap_profile_prefix <- function() { + profile <- renv_bootstrap_profile_get() + if (!is.null(profile)) + return(file.path("profiles", profile, "renv")) + } + + renv_bootstrap_profile_get <- function() { + profile <- Sys.getenv("RENV_PROFILE", unset = "") + renv_bootstrap_profile_normalize(profile) + } + + renv_bootstrap_profile_set <- function(profile) { + profile <- renv_bootstrap_profile_normalize(profile) + if (is.null(profile)) + Sys.unsetenv("RENV_PROFILE") + else + Sys.setenv(RENV_PROFILE = profile) + } + + renv_bootstrap_profile_normalize <- function(profile) { + + if (is.null(profile) || profile %in% c("", "default")) + return(NULL) + + profile + + } + + renv_bootstrap_path_absolute <- function(path) { + + substr(path, 1L, 1L) %in% c("~", "/", "\\") || ( + substr(path, 1L, 1L) %in% c(letters, LETTERS) && + substr(path, 2L, 3L) %in% c(":/", ":\\") + ) + + } + + renv_bootstrap_paths_renv <- function(..., profile = TRUE, project = NULL) { + renv <- Sys.getenv("RENV_PATHS_RENV", unset = "renv") + root <- if (renv_bootstrap_path_absolute(renv)) NULL else project + prefix <- if (profile) renv_bootstrap_profile_prefix() + components <- c(root, renv, prefix, ...) + paste(components, collapse = "/") + } + + renv_bootstrap_project_type <- function(path) { + + descpath <- file.path(path, "DESCRIPTION") + if (!file.exists(descpath)) + return("unknown") + + desc <- tryCatch( + read.dcf(descpath, all = TRUE), + error = identity + ) + + if (inherits(desc, "error")) + return("unknown") + + type <- desc$Type + if (!is.null(type)) + return(tolower(type)) + + package <- desc$Package + if (!is.null(package)) + return("package") + + "unknown" + + } + + renv_bootstrap_user_dir <- function() { + dir <- renv_bootstrap_user_dir_impl() + path.expand(chartr("\\", "/", dir)) + } + + renv_bootstrap_user_dir_impl <- function() { + + # use local override if set + override <- getOption("renv.userdir.override") + if (!is.null(override)) + return(override) + + # use R_user_dir if available + tools <- asNamespace("tools") + if (is.function(tools$R_user_dir)) + return(tools$R_user_dir("renv", "cache")) + + # try using our own backfill for older versions of R + envvars <- c("R_USER_CACHE_DIR", "XDG_CACHE_HOME") + for (envvar in envvars) { + root <- Sys.getenv(envvar, unset = NA) + if (!is.na(root)) + return(file.path(root, "R/renv")) + } + + # use platform-specific default fallbacks + if (Sys.info()[["sysname"]] == "Windows") + file.path(Sys.getenv("LOCALAPPDATA"), "R/cache/R/renv") + else if (Sys.info()[["sysname"]] == "Darwin") + "~/Library/Caches/org.R-project.R/R/renv" + else + "~/.cache/R/renv" + + } + + renv_bootstrap_version_friendly <- function(version, shafmt = NULL, sha = NULL) { + sha <- sha %||% attr(version, "sha", exact = TRUE) + parts <- c(version, sprintf(shafmt %||% " [sha: %s]", substring(sha, 1L, 7L))) + paste(parts, collapse = "") + } + + renv_bootstrap_exec <- function(project, libpath, version) { + if (!renv_bootstrap_load(project, libpath, version)) + renv_bootstrap_run(project, libpath, version) + } + + renv_bootstrap_run <- function(project, libpath, version) { + + # 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 = project)) + } + + # 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_json_read <- function(file = NULL, text = NULL) { + + jlerr <- NULL + + # if jsonlite is loaded, use that instead + if ("jsonlite" %in% loadedNamespaces()) { + + json <- tryCatch(renv_json_read_jsonlite(file, text), error = identity) + if (!inherits(json, "error")) + return(json) + + jlerr <- json + + } + + # otherwise, fall back to the default JSON reader + json <- tryCatch(renv_json_read_default(file, text), error = identity) + if (!inherits(json, "error")) + return(json) + + # report an error + if (!is.null(jlerr)) + stop(jlerr) + else + stop(json) + + } + + renv_json_read_jsonlite <- function(file = NULL, text = NULL) { + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") + jsonlite::fromJSON(txt = text, simplifyVector = FALSE) + } + + renv_json_read_patterns <- function() { + + list( + + # objects + list("{", "\t\n\tobject(\t\n\t", TRUE), + list("}", "\t\n\t)\t\n\t", TRUE), + + # arrays + list("[", "\t\n\tarray(\t\n\t", TRUE), + list("]", "\n\t\n)\n\t\n", TRUE), + + # maps + list(":", "\t\n\t=\t\n\t", TRUE), + + # newlines + list("\\u000a", "\n", FALSE) + + ) + + } + + renv_json_read_envir <- function() { + + envir <- new.env(parent = emptyenv()) + + envir[["+"]] <- `+` + envir[["-"]] <- `-` + + envir[["object"]] <- function(...) { + result <- list(...) + names(result) <- as.character(names(result)) + result + } + + envir[["array"]] <- list + + envir[["true"]] <- TRUE + envir[["false"]] <- FALSE + envir[["null"]] <- NULL + + envir + + } + + renv_json_read_remap <- function(object, patterns) { + + # repair names if necessary + if (!is.null(names(object))) { + + nms <- names(object) + for (pattern in patterns) + nms <- gsub(pattern[[2L]], pattern[[1L]], nms, fixed = TRUE) + names(object) <- nms + + } + + # repair strings if necessary + if (is.character(object)) { + for (pattern in patterns) + object <- gsub(pattern[[2L]], pattern[[1L]], object, fixed = TRUE) + } + + # recurse for other objects + if (is.recursive(object)) + for (i in seq_along(object)) + object[i] <- list(renv_json_read_remap(object[[i]], patterns)) + + # return remapped object + object + + } + + renv_json_read_default <- function(file = NULL, text = NULL) { + + # read json text + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") + + # convert into something the R parser will understand + patterns <- renv_json_read_patterns() + transformed <- text + for (pattern in patterns) + transformed <- gsub(pattern[[1L]], pattern[[2L]], transformed, fixed = TRUE) + + # parse it + rfile <- tempfile("renv-json-", fileext = ".R") + on.exit(unlink(rfile), add = TRUE) + writeLines(transformed, con = rfile) + json <- parse(rfile, keep.source = FALSE, srcfile = NULL)[[1L]] + + # evaluate in safe environment + result <- eval(json, envir = renv_json_read_envir()) + + # fix up strings if necessary -- do so only with reversible patterns + patterns <- Filter(function(pattern) pattern[[3L]], patterns) + renv_json_read_remap(result, patterns) + + } + + + # load the renv profile, if any + renv_bootstrap_profile_load(project) + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_platform_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + # run bootstrap code + renv_bootstrap_exec(project, libpath, version) + + invisible() + +}) diff --git a/renv/archive/4.13.0_renv.lock b/renv/archive/4.13.0_renv.lock new file mode 100644 index 0000000000..8ab5ad9870 --- /dev/null +++ b/renv/archive/4.13.0_renv.lock @@ -0,0 +1,9937 @@ +{ + "R": { + "Version": "4.3.2", + "Repositories": [ + { + "Name": "CRAN", + "URL": "https://cran.rstudio.com" + }, + { + "Name": "pik", + "URL": "https://rse.pik-potsdam.de/r/packages" + } + ] + }, + "Packages": { + "DBI": { + "Package": "DBI", + "Version": "1.2.3", + "Source": "Repository", + "Title": "R Database Interface", + "Date": "2024-06-02", + "Authors@R": "c( person(\"R Special Interest Group on Databases (R-SIG-DB)\", role = \"aut\"), person(\"Hadley\", \"Wickham\", role = \"aut\"), person(\"Kirill\", \"Müller\", , \"kirill@cynkra.com\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-1416-3412\")), person(\"R Consortium\", role = \"fnd\") )", + "Description": "A database interface definition for communication between R and relational database management systems. All classes in this package are virtual and need to be extended by the various R/DBMS implementations.", + "License": "LGPL (>= 2.1)", + "URL": "https://dbi.r-dbi.org, https://github.com/r-dbi/DBI", + "BugReports": "https://github.com/r-dbi/DBI/issues", + "Depends": [ + "methods", + "R (>= 3.0.0)" + ], + "Suggests": [ + "arrow", + "blob", + "covr", + "DBItest", + "dbplyr", + "downlit", + "dplyr", + "glue", + "hms", + "knitr", + "magrittr", + "nanoarrow (>= 0.3.0.1)", + "RMariaDB", + "rmarkdown", + "rprojroot", + "RSQLite (>= 1.1-2)", + "testthat (>= 3.0.0)", + "vctrs", + "xml2" + ], + "VignetteBuilder": "knitr", + "Config/autostyle/scope": "line_breaks", + "Config/autostyle/strict": "false", + "Config/Needs/check": "r-dbi/DBItest", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "Config/Needs/website": "r-dbi/DBItest, r-dbi/dbitemplate, adbi, AzureKusto, bigrquery, DatabaseConnector, dittodb, duckdb, implyr, lazysf, odbc, pool, RAthena, IMSMWU/RClickhouse, RH2, RJDBC, RMariaDB, RMySQL, RPostgres, RPostgreSQL, RPresto, RSQLite, sergeant, sparklyr, withr", + "Config/testthat/edition": "3", + "NeedsCompilation": "no", + "Author": "R Special Interest Group on Databases (R-SIG-DB) [aut], Hadley Wickham [aut], Kirill Müller [aut, cre] (), R Consortium [fnd]", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "DT": { + "Package": "DT", + "Version": "0.33", + "Source": "Repository", + "Type": "Package", + "Title": "A Wrapper of the JavaScript Library 'DataTables'", + "Authors@R": "c( person(\"Yihui\", \"Xie\", role = \"aut\"), person(\"Joe\", \"Cheng\", email = \"joe@posit.co\", role = c(\"aut\", \"cre\")), person(\"Xianying\", \"Tan\", role = \"aut\"), person(\"JJ\", \"Allaire\", role = \"ctb\"), person(\"Maximilian\", \"Girlich\", role = \"ctb\"), person(\"Greg\", \"Freedman Ellis\", role = \"ctb\"), person(\"Johannes\", \"Rauh\", role = \"ctb\"), person(\"SpryMedia Limited\", role = c(\"ctb\", \"cph\"), comment = \"DataTables in htmlwidgets/lib\"), person(\"Brian\", \"Reavis\", role = c(\"ctb\", \"cph\"), comment = \"selectize.js in htmlwidgets/lib\"), person(\"Leon\", \"Gersen\", role = c(\"ctb\", \"cph\"), comment = \"noUiSlider in htmlwidgets/lib\"), person(\"Bartek\", \"Szopka\", role = c(\"ctb\", \"cph\"), comment = \"jquery.highlight.js in htmlwidgets/lib\"), person(\"Alex\", \"Pickering\", role = c(\"ctb\")), person(\"William\", \"Holmes\", role = c(\"ctb\")), person(\"Mikko\", \"Marttila\", role = c(\"ctb\")), person(\"Andres\", \"Quintero\", role = c(\"ctb\")), person(\"Stéphane\", \"Laurent\", role = c(\"ctb\")), person(given = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Data objects in R can be rendered as HTML tables using the JavaScript library 'DataTables' (typically via R Markdown or Shiny). The 'DataTables' library has been included in this R package. The package name 'DT' is an abbreviation of 'DataTables'.", + "URL": "https://github.com/rstudio/DT", + "BugReports": "https://github.com/rstudio/DT/issues", + "License": "GPL-3 | file LICENSE", + "Imports": [ + "htmltools (>= 0.3.6)", + "htmlwidgets (>= 1.3)", + "httpuv", + "jsonlite (>= 0.9.16)", + "magrittr", + "crosstalk", + "jquerylib", + "promises" + ], + "Suggests": [ + "knitr (>= 1.8)", + "rmarkdown", + "shiny (>= 1.6)", + "bslib", + "future", + "testit", + "tibble" + ], + "VignetteBuilder": "knitr", + "RoxygenNote": "7.3.1", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Author": "Yihui Xie [aut], Joe Cheng [aut, cre], Xianying Tan [aut], JJ Allaire [ctb], Maximilian Girlich [ctb], Greg Freedman Ellis [ctb], Johannes Rauh [ctb], SpryMedia Limited [ctb, cph] (DataTables in htmlwidgets/lib), Brian Reavis [ctb, cph] (selectize.js in htmlwidgets/lib), Leon Gersen [ctb, cph] (noUiSlider in htmlwidgets/lib), Bartek Szopka [ctb, cph] (jquery.highlight.js in htmlwidgets/lib), Alex Pickering [ctb], William Holmes [ctb], Mikko Marttila [ctb], Andres Quintero [ctb], Stéphane Laurent [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Joe Cheng ", + "Repository": "CRAN" + }, + "FNN": { + "Package": "FNN", + "Version": "1.1.4.1", + "Source": "Repository", + "Date": "2023-12-31", + "Title": "Fast Nearest Neighbor Search Algorithms and Applications", + "Authors@R": "c(person(\"Alina\", \"Beygelzimer\", role = \"aut\", comment = \"cover tree library\"), person(\"Sham\", \"Kakadet\", role = \"aut\", comment = \"cover tree library\"), person(\"John\", \"Langford\", role = \"aut\", comment = \"cover tree library\"), person(\"Sunil\", \"Arya\", role = \"aut\", comment = \"ANN library 1.1.2 for the kd-tree approach\"), person(\"David\", \"Mount\", role = \"aut\", comment = \"ANN library 1.1.2 for the kd-tree approach\"), person(\"Shengqiao\", \"Li\", role = c(\"aut\", \"cre\"), email = \"lishengqiao@yahoo.com\"))", + "Copyright": "ANN Copyright (c) 1997-2010 University of Maryland and Sunil Arya and David Mount. All Rights Reserved.", + "Depends": [ + "R (>= 4.0.0)" + ], + "Suggests": [ + "chemometrics", + "mvtnorm" + ], + "Description": "Cover-tree and kd-tree fast k-nearest neighbor search algorithms and related applications including KNN classification, regression and information measures are implemented.", + "License": "GPL (>= 2)", + "NeedsCompilation": "yes", + "Repository": "CRAN", + "Author": "Alina Beygelzimer [aut] (cover tree library), Sham Kakadet [aut] (cover tree library), John Langford [aut] (cover tree library), Sunil Arya [aut] (ANN library 1.1.2 for the kd-tree approach), David Mount [aut] (ANN library 1.1.2 for the kd-tree approach), Shengqiao Li [aut, cre]", + "Maintainer": "Shengqiao Li " + }, + "Formula": { + "Package": "Formula", + "Version": "1.2-5", + "Source": "Repository", + "Date": "2023-02-23", + "Title": "Extended Model Formulas", + "Description": "Infrastructure for extended formulas with multiple parts on the right-hand side and/or multiple responses on the left-hand side (see ).", + "Authors@R": "c(person(given = \"Achim\", family = \"Zeileis\", role = c(\"aut\", \"cre\"), email = \"Achim.Zeileis@R-project.org\", comment = c(ORCID = \"0000-0003-0918-3766\")), person(given = \"Yves\", family = \"Croissant\", role = \"aut\", email = \"Yves.Croissant@univ-reunion.fr\"))", + "Depends": [ + "R (>= 2.0.0)", + "stats" + ], + "License": "GPL-2 | GPL-3", + "NeedsCompilation": "no", + "Author": "Achim Zeileis [aut, cre] (), Yves Croissant [aut]", + "Maintainer": "Achim Zeileis ", + "Repository": "CRAN" + }, + "GDPuc": { + "Package": "GDPuc", + "Version": "1.5.3", + "Source": "Repository", + "Title": "Easily Convert GDP Data", + "Date": "2025-09-18", + "Authors@R": "person(\"Johannes\", \"Koch\", , \"jokoch@pik-potsdam.de\", role = c(\"aut\", \"cre\"))", + "Description": "Convert GDP time series data from one unit to another. All common GDP units are included, i.e. current and constant local currency units, US$ via market exchange rates and international dollars via purchasing power parities.", + "License": "GPL (>= 3)", + "URL": "https://github.com/pik-piam/GDPuc, https://pik-piam.github.io/GDPuc/", + "BugReports": "https://github.com/pik-piam/GDPuc/issues", + "Depends": [ + "R (>= 2.10)" + ], + "Imports": [ + "cli (>= 2.4.0)", + "crayon", + "dplyr", + "glue", + "magrittr", + "rlang (>= 1.0.0)", + "tibble", + "tidyr", + "tidyselect", + "withr" + ], + "Suggests": [ + "countrycode", + "covr", + "knitr", + "magclass", + "madrat (>= 3.6.4)", + "purrr", + "rmarkdown", + "stringr", + "testthat (>= 3.0.0)", + "usethis", + "WDI", + "zoo" + ], + "VignetteBuilder": "knitr", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "Roxygen": "list(markdown = TRUE)", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "git@github.com:pik-piam/GDPuc", + "RemoteRef": "HEAD", + "RemoteSha": "7077dcda8ca2cac4ae47e053d09325615d0da9bc", + "NeedsCompilation": "no", + "Author": "Johannes Koch [aut, cre]", + "Maintainer": "Johannes Koch " + }, + "Hmisc": { + "Package": "Hmisc", + "Version": "5.1-3", + "Source": "Repository", + "Date": "2024-05-18", + "Title": "Harrell Miscellaneous", + "Authors@R": "c(person(given = \"Frank E\", family = \"Harrell Jr\", role = c(\"aut\", \"cre\"), email = \"fh@fharrell.com\", comment = c(ORCID = \"0000-0002-8271-5493\")), person(given = \"Charles\", family = \"Dupont\", role = \"ctb\", email = \"charles.dupont@vumc.org\", comment = \"contributed several functions and maintains latex functions\"))", + "Maintainer": "Frank E Harrell Jr ", + "Depends": [ + "R (>= 4.1.0)" + ], + "Imports": [ + "methods", + "ggplot2", + "cluster", + "rpart", + "nnet", + "foreign", + "gtable", + "grid", + "gridExtra", + "data.table", + "htmlTable (>= 1.11.0)", + "viridis", + "htmltools", + "base64enc", + "colorspace", + "rmarkdown", + "knitr", + "Formula" + ], + "Suggests": [ + "survival", + "qreport", + "acepack", + "chron", + "rms", + "mice", + "rstudioapi", + "tables", + "plotly (>= 4.5.6)", + "rlang", + "plyr", + "VGAM", + "leaps", + "pcaPP", + "digest", + "parallel", + "polspline", + "abind", + "kableExtra", + "rio", + "lattice", + "latticeExtra", + "gt", + "sparkline", + "jsonlite", + "htmlwidgets", + "qs", + "getPass", + "keyring", + "safer", + "htm2txt" + ], + "Description": "Contains many functions useful for data analysis, high-level graphics, utility operations, functions for computing sample size and power, simulation, importing and annotating datasets, imputing missing values, advanced table making, variable clustering, character string manipulation, conversion of R objects to LaTeX and html code, recoding variables, caching, simplified parallel computing, encrypting and decrypting data using a safe workflow, general moving window statistical estimation, and assistance in interpreting principal component analysis.", + "License": "GPL (>= 2)", + "LazyLoad": "Yes", + "URL": "https://hbiostat.org/R/Hmisc/", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "yes", + "Author": "Frank E Harrell Jr [aut, cre] (), Charles Dupont [ctb] (contributed several functions and maintains latex functions)", + "Repository": "CRAN" + }, + "KernSmooth": { + "Package": "KernSmooth", + "Version": "2.23-22", + "Source": "Repository", + "Priority": "recommended", + "Date": "2023-07-10", + "Title": "Functions for Kernel Smoothing Supporting Wand & Jones (1995)", + "Authors@R": "c(person(\"Matt\", \"Wand\", role = \"aut\", email = \"Matt.Wand@uts.edu.au\"), person(\"Cleve\", \"Moler\", role = \"ctb\", comment = \"LINPACK routines in src/d*\"), person(\"Brian\", \"Ripley\", role = c(\"trl\", \"cre\", \"ctb\"), email = \"ripley@stats.ox.ac.uk\", comment = \"R port and updates\"))", + "Note": "Maintainers are not available to give advice on using a package they did not author.", + "Depends": [ + "R (>= 2.5.0)", + "stats" + ], + "Suggests": [ + "MASS", + "carData" + ], + "Description": "Functions for kernel smoothing (and density estimation) corresponding to the book: Wand, M.P. and Jones, M.C. (1995) \"Kernel Smoothing\".", + "License": "Unlimited", + "ByteCompile": "yes", + "NeedsCompilation": "yes", + "Author": "Matt Wand [aut], Cleve Moler [ctb] (LINPACK routines in src/d*), Brian Ripley [trl, cre, ctb] (R port and updates)", + "Maintainer": "Brian Ripley ", + "Repository": "CRAN" + }, + "Lmoments": { + "Package": "Lmoments", + "Version": "1.3-1", + "Source": "Repository", + "Date": "2019-03-13", + "Title": "L-Moments and Quantile Mixtures", + "Authors@R": "c(person(\"Juha\", \"Karvanen\", email = \"juha.karvanen@iki.fi\", role = c(\"cre\", \"aut\")), person(\"Santeri\", \"Karppinen\", email = \"santeri.j.karppinen@jyu.fi\", role = \"aut\"))", + "Maintainer": "Juha Karvanen ", + "Description": "Contains functions to estimate L-moments and trimmed L-moments from the data. Also contains functions to estimate the parameters of the normal polynomial quantile mixture and the Cauchy polynomial quantile mixture from L-moments and trimmed L-moments.", + "Imports": [ + "stats", + "Rcpp" + ], + "LinkingTo": [ + "Rcpp", + "RcppArmadillo" + ], + "License": "GPL-2", + "URL": "http://users.jyu.fi/~jutakarv/", + "NeedsCompilation": "yes", + "Repository": "CRAN", + "RoxygenNote": "6.1.1", + "Author": "Juha Karvanen [cre, aut], Santeri Karppinen [aut]" + }, + "MASS": { + "Package": "MASS", + "Version": "7.3-60", + "Source": "Repository", + "Priority": "recommended", + "Date": "2023-05-02", + "Revision": "$Rev: 3621 $", + "Depends": [ + "R (>= 4.0)", + "grDevices", + "graphics", + "stats", + "utils" + ], + "Imports": [ + "methods" + ], + "Suggests": [ + "lattice", + "nlme", + "nnet", + "survival" + ], + "Authors@R": "c(person(\"Brian\", \"Ripley\", role = c(\"aut\", \"cre\", \"cph\"), email = \"ripley@stats.ox.ac.uk\"), person(\"Bill\", \"Venables\", role = \"ctb\"), person(c(\"Douglas\", \"M.\"), \"Bates\", role = \"ctb\"), person(\"Kurt\", \"Hornik\", role = \"trl\", comment = \"partial port ca 1998\"), person(\"Albrecht\", \"Gebhardt\", role = \"trl\", comment = \"partial port ca 1998\"), person(\"David\", \"Firth\", role = \"ctb\"))", + "Description": "Functions and datasets to support Venables and Ripley, \"Modern Applied Statistics with S\" (4th edition, 2002).", + "Title": "Support Functions and Datasets for Venables and Ripley's MASS", + "LazyData": "yes", + "ByteCompile": "yes", + "License": "GPL-2 | GPL-3", + "URL": "http://www.stats.ox.ac.uk/pub/MASS4/", + "Contact": "", + "NeedsCompilation": "yes", + "Author": "Brian Ripley [aut, cre, cph], Bill Venables [ctb], Douglas M. Bates [ctb], Kurt Hornik [trl] (partial port ca 1998), Albrecht Gebhardt [trl] (partial port ca 1998), David Firth [ctb]", + "Maintainer": "Brian Ripley ", + "Repository": "CRAN" + }, + "MagpieNCGains": { + "Package": "MagpieNCGains", + "Version": "1.0.3", + "Source": "Repository", + "Title": "Easy conversion MAgPIE nc to GAINS mapping", + "Date": "2020-12-03", + "Authors@R": "person(\"David Meng-Chuen\", \"Chen\", email = \"david.chen@pik-potsdam.de\", role = c(\"aut\",\"cre\"))", + "Description": "Converts NC generated from MAgPIE outputs to GAINS mapping.", + "License": "GPL-3", + "Encoding": "UTF-8", + "Roxygen": "list(markdown = TRUE)", + "RoxygenNote": "7.2.3", + "Imports": [ + "dplyr", + "ncdf4", + "raster", + "data.table", + "tidyr", + "readxl", + "methods", + "tibble" + ], + "Repository": "pik", + "NeedsCompilation": "no", + "Author": "David Meng-Chuen Chen [aut, cre]", + "Maintainer": "David Meng-Chuen Chen " + }, + "Matrix": { + "Package": "Matrix", + "Version": "1.6-5", + "Source": "Repository", + "VersionNote": "do also bump src/version.h, inst/include/Matrix/version.h", + "Date": "2024-01-06", + "Priority": "recommended", + "Title": "Sparse and Dense Matrix Classes and Methods", + "Description": "A rich hierarchy of sparse and dense matrix classes, including general, symmetric, triangular, and diagonal matrices with numeric, logical, or pattern entries. Efficient methods for operating on such matrices, often wrapping the 'BLAS', 'LAPACK', and 'SuiteSparse' libraries.", + "License": "GPL (>= 2) | file LICENCE", + "URL": "https://Matrix.R-forge.R-project.org", + "BugReports": "https://R-forge.R-project.org/tracker/?atid=294&group_id=61", + "Contact": "Matrix-authors@R-project.org", + "Authors@R": "c(person(\"Douglas\", \"Bates\", role = \"aut\", comment = c(ORCID = \"0000-0001-8316-9503\")), person(\"Martin\", \"Maechler\", role = c(\"aut\", \"cre\"), email = \"mmaechler+Matrix@gmail.com\", comment = c(ORCID = \"0000-0002-8685-9910\")), person(\"Mikael\", \"Jagan\", role = \"aut\", comment = c(ORCID = \"0000-0002-3542-2938\")), person(\"Timothy A.\", \"Davis\", role = \"ctb\", comment = c(ORCID = \"0000-0001-7614-6899\", \"SuiteSparse libraries, notably CHOLMOD and AMD\", \"collaborators listed in dir(pattern=\\\"^[A-Z]+[.]txt$\\\", full.names=TRUE, system.file(\\\"doc\\\", \\\"SuiteSparse\\\", package=\\\"Matrix\\\"))\")), person(\"Jens\", \"Oehlschlägel\", role = \"ctb\", comment = \"initial nearPD()\"), person(\"Jason\", \"Riedy\", role = \"ctb\", comment = c(ORCID = \"0000-0002-4345-4200\", \"GNU Octave's condest() and onenormest()\", \"Copyright: Regents of the University of California\")), person(\"R Core Team\", role = \"ctb\", comment = \"base R's matrix implementation\"))", + "Depends": [ + "R (>= 3.5.0)", + "methods" + ], + "Imports": [ + "grDevices", + "graphics", + "grid", + "lattice", + "stats", + "utils" + ], + "Suggests": [ + "MASS", + "datasets", + "sfsmisc", + "tools" + ], + "Enhances": [ + "SparseM", + "graph" + ], + "LazyData": "no", + "LazyDataNote": "not possible, since we use data/*.R and our S4 classes", + "BuildResaveData": "no", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Douglas Bates [aut] (), Martin Maechler [aut, cre] (), Mikael Jagan [aut] (), Timothy A. Davis [ctb] (, SuiteSparse libraries, notably CHOLMOD and AMD, collaborators listed in dir(pattern=\"^[A-Z]+[.]txt$\", full.names=TRUE, system.file(\"doc\", \"SuiteSparse\", package=\"Matrix\"))), Jens Oehlschlägel [ctb] (initial nearPD()), Jason Riedy [ctb] (, GNU Octave's condest() and onenormest(), Copyright: Regents of the University of California), R Core Team [ctb] (base R's matrix implementation)", + "Maintainer": "Martin Maechler ", + "Repository": "CRAN" + }, + "R.methodsS3": { + "Package": "R.methodsS3", + "Version": "1.8.2", + "Source": "Repository", + "Depends": [ + "R (>= 2.13.0)" + ], + "Imports": [ + "utils" + ], + "Suggests": [ + "codetools" + ], + "Title": "S3 Methods Simplified", + "Authors@R": "c(person(\"Henrik\", \"Bengtsson\", role=c(\"aut\", \"cre\", \"cph\"), email = \"henrikb@braju.com\"))", + "Author": "Henrik Bengtsson [aut, cre, cph]", + "Maintainer": "Henrik Bengtsson ", + "Description": "Methods that simplify the setup of S3 generic functions and S3 methods. Major effort has been made in making definition of methods as simple as possible with a minimum of maintenance for package developers. For example, generic functions are created automatically, if missing, and naming conflict are automatically solved, if possible. The method setMethodS3() is a good start for those who in the future may want to migrate to S4. This is a cross-platform package implemented in pure R that generates standard S3 methods.", + "License": "LGPL (>= 2.1)", + "LazyLoad": "TRUE", + "URL": "https://github.com/HenrikBengtsson/R.methodsS3", + "BugReports": "https://github.com/HenrikBengtsson/R.methodsS3/issues", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "R.oo": { + "Package": "R.oo", + "Version": "1.26.0", + "Source": "Repository", + "Depends": [ + "R (>= 2.13.0)", + "R.methodsS3 (>= 1.8.2)" + ], + "Imports": [ + "methods", + "utils" + ], + "Suggests": [ + "tools" + ], + "Title": "R Object-Oriented Programming with or without References", + "Authors@R": "c(person(\"Henrik\", \"Bengtsson\", role=c(\"aut\", \"cre\", \"cph\"), email = \"henrikb@braju.com\"))", + "Author": "Henrik Bengtsson [aut, cre, cph]", + "Maintainer": "Henrik Bengtsson ", + "Description": "Methods and classes for object-oriented programming in R with or without references. Large effort has been made on making definition of methods as simple as possible with a minimum of maintenance for package developers. The package has been developed since 2001 and is now considered very stable. This is a cross-platform package implemented in pure R that defines standard S3 classes without any tricks.", + "License": "LGPL (>= 2.1)", + "LazyLoad": "TRUE", + "URL": "https://github.com/HenrikBengtsson/R.oo", + "BugReports": "https://github.com/HenrikBengtsson/R.oo/issues", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "R.utils": { + "Package": "R.utils", + "Version": "2.12.3", + "Source": "Repository", + "Depends": [ + "R (>= 2.14.0)", + "R.oo" + ], + "Imports": [ + "methods", + "utils", + "tools", + "R.methodsS3" + ], + "Suggests": [ + "datasets", + "digest (>= 0.6.10)" + ], + "Title": "Various Programming Utilities", + "Authors@R": "c(person(\"Henrik\", \"Bengtsson\", role=c(\"aut\", \"cre\", \"cph\"), email = \"henrikb@braju.com\"))", + "Author": "Henrik Bengtsson [aut, cre, cph]", + "Maintainer": "Henrik Bengtsson ", + "Description": "Utility functions useful when programming and developing R packages.", + "License": "LGPL (>= 2.1)", + "LazyLoad": "TRUE", + "URL": "https://henrikbengtsson.github.io/R.utils/, https://github.com/HenrikBengtsson/R.utils", + "BugReports": "https://github.com/HenrikBengtsson/R.utils/issues", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "R6": { + "Package": "R6", + "Version": "2.6.1", + "Source": "Repository", + "Title": "Encapsulated Classes with Reference Semantics", + "Authors@R": "c( person(\"Winston\", \"Chang\", , \"winston@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Creates classes with reference semantics, similar to R's built-in reference classes. Compared to reference classes, R6 classes are simpler and lighter-weight, and they are not built on S4 classes so they do not require the methods package. These classes allow public and private members, and they support inheritance, even when the classes are defined in different packages.", + "License": "MIT + file LICENSE", + "URL": "https://r6.r-lib.org, https://github.com/r-lib/R6", + "BugReports": "https://github.com/r-lib/R6/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Suggests": [ + "lobstr", + "testthat (>= 3.0.0)" + ], + "Config/Needs/website": "tidyverse/tidytemplate, ggplot2, microbenchmark, scales", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "no", + "Author": "Winston Chang [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "RColorBrewer": { + "Package": "RColorBrewer", + "Version": "1.1-3", + "Source": "Repository", + "Date": "2022-04-03", + "Title": "ColorBrewer Palettes", + "Authors@R": "c(person(given = \"Erich\", family = \"Neuwirth\", role = c(\"aut\", \"cre\"), email = \"erich.neuwirth@univie.ac.at\"))", + "Author": "Erich Neuwirth [aut, cre]", + "Maintainer": "Erich Neuwirth ", + "Depends": [ + "R (>= 2.0.0)" + ], + "Description": "Provides color schemes for maps (and other graphics) designed by Cynthia Brewer as described at http://colorbrewer2.org.", + "License": "Apache License 2.0", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "Rcpp": { + "Package": "Rcpp", + "Version": "1.0.14", + "Source": "Repository", + "Title": "Seamless R and C++ Integration", + "Date": "2025-01-11", + "Authors@R": "c(person(\"Dirk\", \"Eddelbuettel\", role = c(\"aut\", \"cre\"), email = \"edd@debian.org\", comment = c(ORCID = \"0000-0001-6419-907X\")), person(\"Romain\", \"Francois\", role = \"aut\", comment = c(ORCID = \"0000-0002-2444-4226\")), person(\"JJ\", \"Allaire\", role = \"aut\", comment = c(ORCID = \"0000-0003-0174-9868\")), person(\"Kevin\", \"Ushey\", role = \"aut\", comment = c(ORCID = \"0000-0003-2880-7407\")), person(\"Qiang\", \"Kou\", role = \"aut\", comment = c(ORCID = \"0000-0001-6786-5453\")), person(\"Nathan\", \"Russell\", role = \"aut\"), person(\"Iñaki\", \"Ucar\", role = \"aut\", comment = c(ORCID = \"0000-0001-6403-5550\")), person(\"Doug\", \"Bates\", role = \"aut\", comment = c(ORCID = \"0000-0001-8316-9503\")), person(\"John\", \"Chambers\", role = \"aut\"))", + "Description": "The 'Rcpp' package provides R functions as well as C++ classes which offer a seamless integration of R and C++. Many R data types and objects can be mapped back and forth to C++ equivalents which facilitates both writing of new code as well as easier integration of third-party libraries. Documentation about 'Rcpp' is provided by several vignettes included in this package, via the 'Rcpp Gallery' site at , the paper by Eddelbuettel and Francois (2011, ), the book by Eddelbuettel (2013, ) and the paper by Eddelbuettel and Balamuta (2018, ); see 'citation(\"Rcpp\")' for details.", + "Imports": [ + "methods", + "utils" + ], + "Suggests": [ + "tinytest", + "inline", + "rbenchmark", + "pkgKitten (>= 0.1.2)" + ], + "URL": "https://www.rcpp.org, https://dirk.eddelbuettel.com/code/rcpp.html, https://github.com/RcppCore/Rcpp", + "License": "GPL (>= 2)", + "BugReports": "https://github.com/RcppCore/Rcpp/issues", + "MailingList": "rcpp-devel@lists.r-forge.r-project.org", + "RoxygenNote": "6.1.1", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Dirk Eddelbuettel [aut, cre] (), Romain Francois [aut] (), JJ Allaire [aut] (), Kevin Ushey [aut] (), Qiang Kou [aut] (), Nathan Russell [aut], Iñaki Ucar [aut] (), Doug Bates [aut] (), John Chambers [aut]", + "Maintainer": "Dirk Eddelbuettel ", + "Repository": "CRAN" + }, + "RcppArmadillo": { + "Package": "RcppArmadillo", + "Version": "0.12.8.4.0", + "Source": "Repository", + "Type": "Package", + "Title": "'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library", + "Date": "2024-05-30", + "Author": "Dirk Eddelbuettel, Romain Francois, Doug Bates, Binxiang Ni, and Conrad Sanderson", + "Maintainer": "Dirk Eddelbuettel ", + "Description": "'Armadillo' is a templated C++ linear algebra library (by Conrad Sanderson) that aims towards a good balance between speed and ease of use. Integer, floating point and complex numbers are supported, as well as a subset of trigonometric and statistics functions. Various matrix decompositions are provided through optional integration with LAPACK and ATLAS libraries. The 'RcppArmadillo' package includes the header files from the templated 'Armadillo' library. Thus users do not need to install 'Armadillo' itself in order to use 'RcppArmadillo'. From release 7.800.0 on, 'Armadillo' is licensed under Apache License 2; previous releases were under licensed as MPL 2.0 from version 3.800.0 onwards and LGPL-3 prior to that; 'RcppArmadillo' (the 'Rcpp' bindings/bridge to Armadillo) is licensed under the GNU GPL version 2 or later, as is the rest of 'Rcpp'.", + "License": "GPL (>= 2)", + "LazyLoad": "yes", + "Depends": [ + "R (>= 3.3.0)" + ], + "LinkingTo": [ + "Rcpp" + ], + "Imports": [ + "Rcpp (>= 1.0.8)", + "stats", + "utils", + "methods" + ], + "Suggests": [ + "tinytest", + "Matrix (>= 1.3.0)", + "pkgKitten", + "reticulate", + "slam" + ], + "URL": "https://github.com/RcppCore/RcppArmadillo, https://dirk.eddelbuettel.com/code/rcpp.armadillo.html", + "BugReports": "https://github.com/RcppCore/RcppArmadillo/issues", + "RoxygenNote": "6.0.1", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "RcppProgress": { + "Package": "RcppProgress", + "Version": "0.4.2", + "Source": "Repository", + "Maintainer": "Karl Forner ", + "License": "GPL (>= 3)", + "Title": "An Interruptible Progress Bar with OpenMP Support for C++ in R Packages", + "Type": "Package", + "LazyLoad": "yes", + "Author": "Karl Forner ", + "Description": "Allows to display a progress bar in the R console for long running computations taking place in c++ code, and support for interrupting those computations even in multithreaded code, typically using OpenMP.", + "URL": "https://github.com/kforner/rcpp_progress", + "BugReports": "https://github.com/kforner/rcpp_progress/issues", + "Date": "2020-02-06", + "Suggests": [ + "RcppArmadillo", + "devtools", + "roxygen2", + "testthat" + ], + "RoxygenNote": "6.1.1", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "S7": { + "Package": "S7", + "Version": "0.2.0", + "Source": "Repository", + "Title": "An Object Oriented System Meant to Become a Successor to S3 and S4", + "Authors@R": "c( person(\"Object-Oriented Programming Working Group\", role = \"cph\"), person(\"Davis\", \"Vaughan\", role = \"aut\"), person(\"Jim\", \"Hester\", role = \"aut\", comment = c(ORCID = \"0000-0002-2739-7082\")), person(\"Tomasz\", \"Kalinowski\", role = \"aut\"), person(\"Will\", \"Landau\", role = \"aut\"), person(\"Michael\", \"Lawrence\", role = \"aut\"), person(\"Martin\", \"Maechler\", role = \"aut\", comment = c(ORCID = \"0000-0002-8685-9910\")), person(\"Luke\", \"Tierney\", role = \"aut\"), person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-4757-117X\")) )", + "Description": "A new object oriented programming system designed to be a successor to S3 and S4. It includes formal class, generic, and method specification, and a limited form of multiple dispatch. It has been designed and implemented collaboratively by the R Consortium Object-Oriented Programming Working Group, which includes representatives from R-Core, 'Bioconductor', 'Posit'/'tidyverse', and the wider R community.", + "License": "MIT + file LICENSE", + "URL": "https://rconsortium.github.io/S7/, https://github.com/RConsortium/S7", + "BugReports": "https://github.com/RConsortium/S7/issues", + "Depends": [ + "R (>= 3.5.0)" + ], + "Imports": [ + "utils" + ], + "Suggests": [ + "bench", + "callr", + "covr", + "knitr", + "methods", + "rmarkdown", + "testthat (>= 3.2.0)", + "tibble" + ], + "VignetteBuilder": "knitr", + "Config/build/compilation-database": "true", + "Config/Needs/website": "sloop", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "TRUE", + "Config/testthat/start-first": "external-generic", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "yes", + "Author": "Object-Oriented Programming Working Group [cph], Davis Vaughan [aut], Jim Hester [aut] (), Tomasz Kalinowski [aut], Will Landau [aut], Michael Lawrence [aut], Martin Maechler [aut] (), Luke Tierney [aut], Hadley Wickham [aut, cre] ()", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "SPEI": { + "Package": "SPEI", + "Version": "1.8.1", + "Source": "Repository", + "Type": "Package", + "Title": "Calculation of the Standardized Precipitation-Evapotranspiration Index", + "Authors@R": "c( person('Santiago', 'Beguería', role=c('aut','cre'), email='santiago.begueria@csic.es'), person(c('Sergio','M.'), 'Vicente-Serrano', role='aut', email='svicen@ipe.csic.es'))", + "Description": "A set of functions for computing potential evapotranspiration and several widely used drought indices including the Standardized Precipitation-Evapotranspiration Index (SPEI).", + "Depends": [ + "R (>= 3.5.0)" + ], + "Imports": [ + "lmomco", + "lmom", + "TLMoments", + "reshape", + "ggplot2", + "checkmate", + "zoo", + "lubridate" + ], + "License": "GPL-2", + "URL": "https://spei.csic.es, https://github.com/sbegueria/SPEI", + "Language": "en-US", + "BugReports": "https://github.com/sbegueria/SPEI/issues", + "LazyLoad": "true", + "Encoding": "UTF-8", + "Suggests": [ + "covr", + "testthat" + ], + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Santiago Beguería [aut, cre], Sergio M. Vicente-Serrano [aut]", + "Maintainer": "Santiago Beguería ", + "Repository": "CRAN" + }, + "TLMoments": { + "Package": "TLMoments", + "Version": "0.7.5.3", + "Source": "Repository", + "Type": "Package", + "Title": "Calculate TL-Moments and Convert Them to Distribution Parameters", + "Date": "2022-03-27", + "Author": "Jona Lilienthal", + "Maintainer": "Jona Lilienthal ", + "Description": "Calculates empirical TL-moments (trimmed L-moments) of arbitrary order and trimming, and converts them to distribution parameters.", + "License": "GPL (>= 2)", + "Depends": [ + "R (>= 2.10)", + "Rcpp (>= 0.12.12)" + ], + "Imports": [ + "hypergeo", + "ggplot2", + "stats", + "lmomco" + ], + "Suggests": [ + "evd", + "knitr", + "magrittr", + "lmom", + "Lmoments", + "rmarkdown" + ], + "VignetteBuilder": "knitr", + "LinkingTo": [ + "Rcpp" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.1.2", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "abind": { + "Package": "abind", + "Version": "1.4-8", + "Source": "Repository", + "Date": "2024-09-08", + "Title": "Combine Multidimensional Arrays", + "Authors@R": "c(person(\"Tony\", \"Plate\", email = \"tplate@acm.org\", role = c(\"aut\", \"cre\")), person(\"Richard\", \"Heiberger\", role = c(\"aut\")))", + "Maintainer": "Tony Plate ", + "Description": "Combine multidimensional arrays into a single array. This is a generalization of 'cbind' and 'rbind'. Works with vectors, matrices, and higher-dimensional arrays (aka tensors). Also provides functions 'adrop', 'asub', and 'afill' for manipulating, extracting and replacing data in arrays.", + "Depends": [ + "R (>= 1.5.0)" + ], + "Imports": [ + "methods", + "utils" + ], + "License": "MIT + file LICENSE", + "NeedsCompilation": "no", + "Author": "Tony Plate [aut, cre], Richard Heiberger [aut]", + "Repository": "CRAN" + }, + "askpass": { + "Package": "askpass", + "Version": "1.2.0", + "Source": "Repository", + "Type": "Package", + "Title": "Password Entry Utilities for R, Git, and SSH", + "Authors@R": "person(\"Jeroen\", \"Ooms\", role = c(\"aut\", \"cre\"), email = \"jeroen@berkeley.edu\", comment = c(ORCID = \"0000-0002-4035-0289\"))", + "Description": "Cross-platform utilities for prompting the user for credentials or a passphrase, for example to authenticate with a server or read a protected key. Includes native programs for MacOS and Windows, hence no 'tcltk' is required. Password entry can be invoked in two different ways: directly from R via the askpass() function, or indirectly as password-entry back-end for 'ssh-agent' or 'git-credential' via the SSH_ASKPASS and GIT_ASKPASS environment variables. Thereby the user can be prompted for credentials or a passphrase if needed when R calls out to git or ssh.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/askpass", + "BugReports": "https://github.com/r-lib/askpass/issues", + "Encoding": "UTF-8", + "Imports": [ + "sys (>= 2.1)" + ], + "RoxygenNote": "7.2.3", + "Suggests": [ + "testthat" + ], + "Language": "en-US", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] ()", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "backports": { + "Package": "backports", + "Version": "1.5.0", + "Source": "Repository", + "Type": "Package", + "Title": "Reimplementations of Functions Introduced Since R-3.0.0", + "Authors@R": "c( person(\"Michel\", \"Lang\", NULL, \"michellang@gmail.com\", role = c(\"cre\", \"aut\"), comment = c(ORCID = \"0000-0001-9754-0393\")), person(\"Duncan\", \"Murdoch\", NULL, \"murdoch.duncan@gmail.com\", role = c(\"aut\")), person(\"R Core Team\", role = \"aut\"))", + "Maintainer": "Michel Lang ", + "Description": "Functions introduced or changed since R v3.0.0 are re-implemented in this package. The backports are conditionally exported in order to let R resolve the function name to either the implemented backport, or the respective base version, if available. Package developers can make use of new functions or arguments by selectively importing specific backports to support older installations.", + "URL": "https://github.com/r-lib/backports", + "BugReports": "https://github.com/r-lib/backports/issues", + "License": "GPL-2 | GPL-3", + "NeedsCompilation": "yes", + "ByteCompile": "yes", + "Depends": [ + "R (>= 3.0.0)" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "Author": "Michel Lang [cre, aut] (), Duncan Murdoch [aut], R Core Team [aut]", + "Repository": "CRAN" + }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Title": "Tools for base64 encoding", + "Author": "Simon Urbanek ", + "Maintainer": "Simon Urbanek ", + "Depends": [ + "R (>= 2.9.0)" + ], + "Enhances": [ + "png" + ], + "Description": "This package provides tools for handling base64 encoding. It is more flexible than the orphaned base64 package.", + "License": "GPL-2 | GPL-3", + "URL": "http://www.rforge.net/base64enc", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "bit": { + "Package": "bit", + "Version": "4.0.5", + "Source": "Repository", + "Type": "Package", + "Title": "Classes and Methods for Fast Memory-Efficient Boolean Selections", + "Date": "2022-11-13", + "Author": "Jens Oehlschlägel [aut, cre], Brian Ripley [ctb]", + "Maintainer": "Jens Oehlschlägel ", + "Depends": [ + "R (>= 2.9.2)" + ], + "Suggests": [ + "testthat (>= 0.11.0)", + "roxygen2", + "knitr", + "rmarkdown", + "microbenchmark", + "bit64 (>= 4.0.0)", + "ff (>= 4.0.0)" + ], + "Description": "Provided are classes for boolean and skewed boolean vectors, fast boolean methods, fast unique and non-unique integer sorting, fast set operations on sorted and unsorted sets of integers, and foundations for ff (range index, compression, chunked processing).", + "License": "GPL-2 | GPL-3", + "LazyLoad": "yes", + "ByteCompile": "yes", + "Encoding": "UTF-8", + "URL": "https://github.com/truecluster/bit", + "VignetteBuilder": "knitr, rmarkdown", + "RoxygenNote": "7.2.0", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "bit64": { + "Package": "bit64", + "Version": "4.0.5", + "Source": "Repository", + "Type": "Package", + "Title": "A S3 Class for Vectors of 64bit Integers", + "Date": "2020-08-29", + "Author": "Jens Oehlschlägel [aut, cre], Leonardo Silvestri [ctb]", + "Maintainer": "Jens Oehlschlägel ", + "Depends": [ + "R (>= 3.0.1)", + "bit (>= 4.0.0)", + "utils", + "methods", + "stats" + ], + "Description": "Package 'bit64' provides serializable S3 atomic 64bit (signed) integers. These are useful for handling database keys and exact counting in +-2^63. WARNING: do not use them as replacement for 32bit integers, integer64 are not supported for subscripting by R-core and they have different semantics when combined with double, e.g. integer64 + double => integer64. Class integer64 can be used in vectors, matrices, arrays and data.frames. Methods are available for coercion from and to logicals, integers, doubles, characters and factors as well as many elementwise and summary functions. Many fast algorithmic operations such as 'match' and 'order' support inter- active data exploration and manipulation and optionally leverage caching.", + "License": "GPL-2 | GPL-3", + "LazyLoad": "yes", + "ByteCompile": "yes", + "URL": "https://github.com/truecluster/bit64", + "Encoding": "UTF-8", + "Repository": "CRAN", + "Repository/R-Forge/Project": "ff", + "Repository/R-Forge/Revision": "177", + "Repository/R-Forge/DateTimeStamp": "2018-08-17 17:45:18", + "NeedsCompilation": "yes" + }, + "blackmagicc": { + "Package": "blackmagicc", + "Version": "0.7.1", + "Source": "Repository", + "Type": "Package", + "Title": "MAgPIE-MAGICC Integration", + "Date": "2024-07-05", + "Authors@R": "person(\"Michael\", \"Crawford\", , \"crawford@pik-potsdam.de\", role = c(\"cre\", \"aut\"))", + "Description": "Enables MAgPIE runs to project global surface area temperatures with MAGICC, using reference REMIND scenarios to represent emissions from the energy sector.", + "License": "BSD_2_clause + file LICENSE", + "URL": "", + "BugReports": "https://github.com/pik-piam/blackmagicc/issues", + "Depends": [ + "R (>= 3.6.3.0)" + ], + "Imports": [ + "dplyr", + "gms", + "magclass", + "purrr", + "quitte", + "readr", + "rlang", + "stringr", + "tidyr", + "utils", + "withr" + ], + "Suggests": [ + "covr", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/blackmagicc", + "RemoteRef": "HEAD", + "RemoteSha": "df72371883a5affc23ec502908f5362024a97bcc", + "NeedsCompilation": "no", + "Author": "Michael Crawford [cre, aut]", + "Maintainer": "Michael Crawford " + }, + "brew": { + "Package": "brew", + "Version": "1.0-10", + "Source": "Repository", + "Type": "Package", + "Title": "Templating Framework for Report Generation", + "Authors@R": "c( person(\"Jeffrey\", \"Horner\", role = c(\"aut\", \"cph\")), person(\"Greg\", \"Hunt\", , \"greg@firmansyah.com\", role = c(\"aut\", \"cre\", \"cph\")) )", + "Description": "Implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server Pages, and Python's psp module.", + "License": "GPL (>= 2)", + "URL": "https://github.com/gregfrog/brew", + "BugReports": "https://github.com/gregfrog/brew/issues", + "Suggests": [ + "testthat (>= 3.0.0)" + ], + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "Repository": "CRAN", + "NeedsCompilation": "no", + "Author": "Jeffrey Horner [aut, cph], Greg Hunt [aut, cre, cph]", + "Maintainer": "Greg Hunt " + }, + "brio": { + "Package": "brio", + "Version": "1.1.5", + "Source": "Repository", + "Title": "Basic R Input Output", + "Authors@R": "c( person(\"Jim\", \"Hester\", role = \"aut\", comment = c(ORCID = \"0000-0002-2739-7082\")), person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(given = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Functions to handle basic input output, these functions always read and write UTF-8 (8-bit Unicode Transformation Format) files and provide more explicit control over line endings.", + "License": "MIT + file LICENSE", + "URL": "https://brio.r-lib.org, https://github.com/r-lib/brio", + "BugReports": "https://github.com/r-lib/brio/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Suggests": [ + "covr", + "testthat (>= 3.0.0)" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Jim Hester [aut] (), Gábor Csárdi [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "bslib": { + "Package": "bslib", + "Version": "0.9.0", + "Source": "Repository", + "Title": "Custom 'Bootstrap' 'Sass' Themes for 'shiny' and 'rmarkdown'", + "Authors@R": "c( person(\"Carson\", \"Sievert\", , \"carson@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Joe\", \"Cheng\", , \"joe@posit.co\", role = \"aut\"), person(\"Garrick\", \"Aden-Buie\", , \"garrick@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0002-7111-0077\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(, \"Bootstrap contributors\", role = \"ctb\", comment = \"Bootstrap library\"), person(, \"Twitter, Inc\", role = \"cph\", comment = \"Bootstrap library\"), person(\"Javi\", \"Aguilar\", role = c(\"ctb\", \"cph\"), comment = \"Bootstrap colorpicker library\"), person(\"Thomas\", \"Park\", role = c(\"ctb\", \"cph\"), comment = \"Bootswatch library\"), person(, \"PayPal\", role = c(\"ctb\", \"cph\"), comment = \"Bootstrap accessibility plugin\") )", + "Description": "Simplifies custom 'CSS' styling of both 'shiny' and 'rmarkdown' via 'Bootstrap' 'Sass'. Supports 'Bootstrap' 3, 4 and 5 as well as their various 'Bootswatch' themes. An interactive widget is also provided for previewing themes in real time.", + "License": "MIT + file LICENSE", + "URL": "https://rstudio.github.io/bslib/, https://github.com/rstudio/bslib", + "BugReports": "https://github.com/rstudio/bslib/issues", + "Depends": [ + "R (>= 2.10)" + ], + "Imports": [ + "base64enc", + "cachem", + "fastmap (>= 1.1.1)", + "grDevices", + "htmltools (>= 0.5.8)", + "jquerylib (>= 0.1.3)", + "jsonlite", + "lifecycle", + "memoise (>= 2.0.1)", + "mime", + "rlang", + "sass (>= 0.4.9)" + ], + "Suggests": [ + "bsicons", + "curl", + "fontawesome", + "future", + "ggplot2", + "knitr", + "magrittr", + "rappdirs", + "rmarkdown (>= 2.7)", + "shiny (> 1.8.1)", + "testthat", + "thematic", + "tools", + "utils", + "withr", + "yaml" + ], + "Config/Needs/deploy": "BH, chiflights22, colourpicker, commonmark, cpp11, cpsievert/chiflights22, cpsievert/histoslider, dplyr, DT, ggplot2, ggridges, gt, hexbin, histoslider, htmlwidgets, lattice, leaflet, lubridate, markdown, modelr, plotly, reactable, reshape2, rprojroot, rsconnect, rstudio/shiny, scales, styler, tibble", + "Config/Needs/routine": "chromote, desc, renv", + "Config/Needs/website": "brio, crosstalk, dplyr, DT, ggplot2, glue, htmlwidgets, leaflet, lorem, palmerpenguins, plotly, purrr, rprojroot, rstudio/htmltools, scales, stringr, tidyr, webshot2", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "zzzz-bs-sass, fonts, zzz-precompile, theme-*, rmd-*", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Collate": "'accordion.R' 'breakpoints.R' 'bs-current-theme.R' 'bs-dependencies.R' 'bs-global.R' 'bs-remove.R' 'bs-theme-layers.R' 'bs-theme-preset-bootswatch.R' 'bs-theme-preset-brand.R' 'bs-theme-preset-builtin.R' 'bs-theme-preset.R' 'utils.R' 'bs-theme-preview.R' 'bs-theme-update.R' 'bs-theme.R' 'bslib-package.R' 'buttons.R' 'card.R' 'deprecated.R' 'files.R' 'fill.R' 'imports.R' 'input-dark-mode.R' 'input-switch.R' 'layout.R' 'nav-items.R' 'nav-update.R' 'navbar_options.R' 'navs-legacy.R' 'navs.R' 'onLoad.R' 'page.R' 'popover.R' 'precompiled.R' 'print.R' 'shiny-devmode.R' 'sidebar.R' 'staticimports.R' 'tooltip.R' 'utils-deps.R' 'utils-shiny.R' 'utils-tags.R' 'value-box.R' 'version-default.R' 'versions.R'", + "NeedsCompilation": "no", + "Author": "Carson Sievert [aut, cre] (), Joe Cheng [aut], Garrick Aden-Buie [aut] (), Posit Software, PBC [cph, fnd], Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Javi Aguilar [ctb, cph] (Bootstrap colorpicker library), Thomas Park [ctb, cph] (Bootswatch library), PayPal [ctb, cph] (Bootstrap accessibility plugin)", + "Maintainer": "Carson Sievert ", + "Repository": "CRAN" + }, + "cachem": { + "Package": "cachem", + "Version": "1.1.0", + "Source": "Repository", + "Title": "Cache R Objects with Automatic Pruning", + "Description": "Key-value stores with automatic pruning. Caches can limit either their total size or the age of the oldest object (or both), automatically pruning objects to maintain the constraints.", + "Authors@R": "c( person(\"Winston\", \"Chang\", , \"winston@posit.co\", c(\"aut\", \"cre\")), person(family = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")))", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "ByteCompile": "true", + "URL": "https://cachem.r-lib.org/, https://github.com/r-lib/cachem", + "Imports": [ + "rlang", + "fastmap (>= 1.2.0)" + ], + "Suggests": [ + "testthat" + ], + "RoxygenNote": "7.2.3", + "Config/Needs/routine": "lobstr", + "Config/Needs/website": "pkgdown", + "NeedsCompilation": "yes", + "Author": "Winston Chang [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "callr": { + "Package": "callr", + "Version": "3.7.6", + "Source": "Repository", + "Title": "Call R from R", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\", \"cph\"), comment = c(ORCID = \"0000-0001-7098-9676\")), person(\"Winston\", \"Chang\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"Ascent Digital Services\", role = c(\"cph\", \"fnd\")) )", + "Description": "It is sometimes useful to perform a computation in a separate R process, without affecting the current R process at all. This packages does exactly that.", + "License": "MIT + file LICENSE", + "URL": "https://callr.r-lib.org, https://github.com/r-lib/callr", + "BugReports": "https://github.com/r-lib/callr/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Imports": [ + "processx (>= 3.6.1)", + "R6", + "utils" + ], + "Suggests": [ + "asciicast (>= 2.3.1)", + "cli (>= 1.1.0)", + "mockery", + "ps", + "rprojroot", + "spelling", + "testthat (>= 3.2.0)", + "withr (>= 2.3.0)" + ], + "Config/Needs/website": "r-lib/asciicast, glue, htmlwidgets, igraph, tibble, tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.3.1.9000", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre, cph] (), Winston Chang [aut], Posit Software, PBC [cph, fnd], Ascent Digital Services [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "cartogram": { + "Package": "cartogram", + "Version": "0.3.0", + "Source": "Repository", + "Title": "Create Cartograms with R", + "Authors@R": "c( person(\"Sebastian\", \"Jeworutzki\", email = \"sebastian.jeworutzki@ruhr-uni-bochum.de\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-2671-5253\")), person(\"Timothee\", \"Giraud\", role = \"ctb\"), person(\"Nicolas\", \"Lambert\", role = \"ctb\"), person(\"Roger\", \"Bivand\", role = c(\"cph\"), email = \"Roger.Bivand@nhh.no\"), person(\"Edzer\", \"Pebesma\", role = \"cph\"), person(\"Jakub\", \"Nowosad\", email = \"nowosad.jakub@gmail.com\", role = \"ctb\", comment = c(ORCID = \"0000-0002-1057-3721\")) )", + "Description": "Construct continuous and non-contiguous area cartograms.", + "URL": "https://github.com/sjewo/cartogram", + "BugReports": "https://github.com/sjewo/cartogram/issues", + "Imports": [ + "methods", + "sf", + "packcircles" + ], + "Suggests": [], + "License": "GPL-3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Sebastian Jeworutzki [aut, cre] (), Timothee Giraud [ctb], Nicolas Lambert [ctb], Roger Bivand [cph], Edzer Pebesma [cph], Jakub Nowosad [ctb] ()", + "Maintainer": "Sebastian Jeworutzki ", + "Repository": "CRAN" + }, + "cellranger": { + "Package": "cellranger", + "Version": "1.1.0", + "Source": "Repository", + "Title": "Translate Spreadsheet Cell Ranges to Rows and Columns", + "Authors@R": "c( person(\"Jennifer\", \"Bryan\", , \"jenny@stat.ubc.ca\", c(\"cre\", \"aut\")), person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", \"ctb\") )", + "Description": "Helper functions to work with spreadsheets and the \"A1:D10\" style of cell range specification.", + "Depends": [ + "R (>= 3.0.0)" + ], + "License": "MIT + file LICENSE", + "LazyData": "true", + "URL": "https://github.com/rsheets/cellranger", + "BugReports": "https://github.com/rsheets/cellranger/issues", + "Suggests": [ + "covr", + "testthat (>= 1.0.0)", + "knitr", + "rmarkdown" + ], + "RoxygenNote": "5.0.1.9000", + "VignetteBuilder": "knitr", + "Imports": [ + "rematch", + "tibble" + ], + "NeedsCompilation": "no", + "Author": "Jennifer Bryan [cre, aut], Hadley Wickham [ctb]", + "Maintainer": "Jennifer Bryan ", + "Repository": "CRAN" + }, + "checkmate": { + "Package": "checkmate", + "Version": "2.3.1", + "Source": "Repository", + "Type": "Package", + "Title": "Fast and Versatile Argument Checks", + "Description": "Tests and assertions to perform frequent argument checks. A substantial part of the package was written in C to minimize any worries about execution time overhead.", + "Authors@R": "c( person(\"Michel\", \"Lang\", NULL, \"michellang@gmail.com\", role = c(\"cre\", \"aut\"), comment = c(ORCID = \"0000-0001-9754-0393\")), person(\"Bernd\", \"Bischl\", NULL, \"bernd_bischl@gmx.net\", role = \"ctb\"), person(\"Dénes\", \"Tóth\", NULL, \"toth.denes@kogentum.hu\", role = \"ctb\", comment = c(ORCID = \"0000-0003-4262-3217\")) )", + "URL": "https://mllg.github.io/checkmate/, https://github.com/mllg/checkmate", + "URLNote": "https://github.com/mllg/checkmate", + "BugReports": "https://github.com/mllg/checkmate/issues", + "NeedsCompilation": "yes", + "ByteCompile": "yes", + "Encoding": "UTF-8", + "Depends": [ + "R (>= 3.0.0)" + ], + "Imports": [ + "backports (>= 1.1.0)", + "utils" + ], + "Suggests": [ + "R6", + "fastmatch", + "data.table (>= 1.9.8)", + "devtools", + "ggplot2", + "knitr", + "magrittr", + "microbenchmark", + "rmarkdown", + "testthat (>= 3.0.4)", + "tinytest (>= 1.1.0)", + "tibble" + ], + "License": "BSD_3_clause + file LICENSE", + "VignetteBuilder": "knitr", + "RoxygenNote": "7.2.3", + "Collate": "'AssertCollection.R' 'allMissing.R' 'anyInfinite.R' 'anyMissing.R' 'anyNaN.R' 'asInteger.R' 'assert.R' 'helper.R' 'makeExpectation.R' 'makeTest.R' 'makeAssertion.R' 'checkAccess.R' 'checkArray.R' 'checkAtomic.R' 'checkAtomicVector.R' 'checkCharacter.R' 'checkChoice.R' 'checkClass.R' 'checkComplex.R' 'checkCount.R' 'checkDataFrame.R' 'checkDataTable.R' 'checkDate.R' 'checkDirectoryExists.R' 'checkDisjunct.R' 'checkDouble.R' 'checkEnvironment.R' 'checkFALSE.R' 'checkFactor.R' 'checkFileExists.R' 'checkFlag.R' 'checkFormula.R' 'checkFunction.R' 'checkInt.R' 'checkInteger.R' 'checkIntegerish.R' 'checkList.R' 'checkLogical.R' 'checkMatrix.R' 'checkMultiClass.R' 'checkNamed.R' 'checkNames.R' 'checkNull.R' 'checkNumber.R' 'checkNumeric.R' 'checkOS.R' 'checkPOSIXct.R' 'checkPathForOutput.R' 'checkPermutation.R' 'checkR6.R' 'checkRaw.R' 'checkScalar.R' 'checkScalarNA.R' 'checkSetEqual.R' 'checkString.R' 'checkSubset.R' 'checkTRUE.R' 'checkTibble.R' 'checkVector.R' 'coalesce.R' 'isIntegerish.R' 'matchArg.R' 'qassert.R' 'qassertr.R' 'vname.R' 'wfwl.R' 'zzz.R'", + "Author": "Michel Lang [cre, aut] (), Bernd Bischl [ctb], Dénes Tóth [ctb] ()", + "Maintainer": "Michel Lang ", + "Repository": "CRAN" + }, + "citation": { + "Package": "citation", + "Version": "0.12.0", + "Source": "Repository", + "Type": "Package", + "Title": "Software Citation Tools", + "Date": "2024-12-16", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-4309-6431\"), role = c(\"aut\",\"cre\")), person(\"Waldir\", \"Leoncio\", email = \"w.l.netto@medisin.uio.no\", comment = c(affiliation = \"University of Oslo\"), role = c(\"aut\")))", + "Description": "A collection of functions to extract citation information from 'R' packages and to deal with files in 'citation file format' (), extending the functionality already provided by the citation() function in the 'utils' package.", + "Imports": [ + "desc", + "jsonlite", + "utils", + "withr", + "yaml" + ], + "Suggests": [ + "covr", + "testthat" + ], + "URL": "https://github.com/pik-piam/citation, https://doi.org/10.5281/zenodo.3813429", + "BugReports": "https://github.com/pik-piam/citation/issues", + "License": "BSD_2_clause + file LICENSE", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Config/Keywords": "tool", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/citation", + "RemoteRef": "HEAD", + "RemoteSha": "92394879832dc974562101212eda7b83d1ee9ad4", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre] (Potsdam Institute for Climate Impact Research, ), Waldir Leoncio [aut] (University of Oslo)", + "Maintainer": "Jan Philipp Dietrich " + }, + "class": { + "Package": "class", + "Version": "7.3-22", + "Source": "Repository", + "Priority": "recommended", + "Date": "2023-05-02", + "Depends": [ + "R (>= 3.0.0)", + "stats", + "utils" + ], + "Imports": [ + "MASS" + ], + "Authors@R": "c(person(\"Brian\", \"Ripley\", role = c(\"aut\", \"cre\", \"cph\"), email = \"ripley@stats.ox.ac.uk\"), person(\"William\", \"Venables\", role = \"cph\"))", + "Description": "Various functions for classification, including k-nearest neighbour, Learning Vector Quantization and Self-Organizing Maps.", + "Title": "Functions for Classification", + "ByteCompile": "yes", + "License": "GPL-2 | GPL-3", + "URL": "http://www.stats.ox.ac.uk/pub/MASS4/", + "NeedsCompilation": "yes", + "Author": "Brian Ripley [aut, cre, cph], William Venables [cph]", + "Maintainer": "Brian Ripley ", + "Repository": "CRAN" + }, + "classInt": { + "Package": "classInt", + "Version": "0.4-10", + "Source": "Repository", + "Date": "2023-08-24", + "Title": "Choose Univariate Class Intervals", + "Authors@R": "c( person(\"Roger\", \"Bivand\", role=c(\"aut\", \"cre\"), email=\"Roger.Bivand@nhh.no\", comment=c(ORCID=\"0000-0003-2392-6140\")), person(\"Bill\", \"Denney\", role=\"ctb\", comment=c(ORCID=\"0000-0002-5759-428X\")), person(\"Richard\", \"Dunlap\", role=\"ctb\"), person(\"Diego\", \"Hernangómez\", role=\"ctb\", comment=c(ORCID=\"0000-0001-8457-4658\")), person(\"Hisaji\", \"Ono\", role=\"ctb\"), person(\"Josiah\", \"Parry\", role = \"ctb\", comment = c(ORCID = \"0000-0001-9910-865X\")), person(\"Matthieu\", \"Stigler\", role=\"ctb\", comment =c(ORCID=\"0000-0002-6802-4290\")))", + "Depends": [ + "R (>= 2.2)" + ], + "Imports": [ + "grDevices", + "stats", + "graphics", + "e1071", + "class", + "KernSmooth" + ], + "Suggests": [ + "spData (>= 0.2.6.2)", + "units", + "knitr", + "rmarkdown", + "tinytest" + ], + "NeedsCompilation": "yes", + "Description": "Selected commonly used methods for choosing univariate class intervals for mapping or other graphics purposes.", + "License": "GPL (>= 2)", + "URL": "https://r-spatial.github.io/classInt/, https://github.com/r-spatial/classInt/", + "BugReports": "https://github.com/r-spatial/classInt/issues/", + "RoxygenNote": "6.1.1", + "Encoding": "UTF-8", + "VignetteBuilder": "knitr", + "Author": "Roger Bivand [aut, cre] (), Bill Denney [ctb] (), Richard Dunlap [ctb], Diego Hernangómez [ctb] (), Hisaji Ono [ctb], Josiah Parry [ctb] (), Matthieu Stigler [ctb] ()", + "Maintainer": "Roger Bivand ", + "Repository": "CRAN" + }, + "cli": { + "Package": "cli", + "Version": "3.6.5", + "Source": "Repository", + "Title": "Helpers for Developing Command Line Interfaces", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"gabor@posit.co\", role = c(\"aut\", \"cre\")), person(\"Hadley\", \"Wickham\", role = \"ctb\"), person(\"Kirill\", \"Müller\", role = \"ctb\"), person(\"Salim\", \"Brüggemann\", , \"salim-b@pm.me\", role = \"ctb\", comment = c(ORCID = \"0000-0002-5329-5987\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A suite of tools to build attractive command line interfaces ('CLIs'), from semantic elements: headings, lists, alerts, paragraphs, etc. Supports custom themes via a 'CSS'-like language. It also contains a number of lower level 'CLI' elements: rules, boxes, trees, and 'Unicode' symbols with 'ASCII' alternatives. It support ANSI colors and text styles as well.", + "License": "MIT + file LICENSE", + "URL": "https://cli.r-lib.org, https://github.com/r-lib/cli", + "BugReports": "https://github.com/r-lib/cli/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Imports": [ + "utils" + ], + "Suggests": [ + "callr", + "covr", + "crayon", + "digest", + "glue (>= 1.6.0)", + "grDevices", + "htmltools", + "htmlwidgets", + "knitr", + "methods", + "processx", + "ps (>= 1.3.4.9000)", + "rlang (>= 1.0.2.9003)", + "rmarkdown", + "rprojroot", + "rstudioapi", + "testthat (>= 3.2.0)", + "tibble", + "whoami", + "withr" + ], + "Config/Needs/website": "r-lib/asciicast, bench, brio, cpp11, decor, desc, fansi, prettyunits, sessioninfo, tidyverse/tidytemplate, usethis, vctrs", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "yes", + "Author": "Gábor Csárdi [aut, cre], Hadley Wickham [ctb], Kirill Müller [ctb], Salim Brüggemann [ctb] (), Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "clipr": { + "Package": "clipr", + "Version": "0.8.0", + "Source": "Repository", + "Type": "Package", + "Title": "Read and Write from the System Clipboard", + "Authors@R": "c( person(\"Matthew\", \"Lincoln\", , \"matthew.d.lincoln@gmail.com\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-4387-3384\")), person(\"Louis\", \"Maddox\", role = \"ctb\"), person(\"Steve\", \"Simpson\", role = \"ctb\"), person(\"Jennifer\", \"Bryan\", role = \"ctb\") )", + "Description": "Simple utility functions to read from and write to the Windows, OS X, and X11 clipboards.", + "License": "GPL-3", + "URL": "https://github.com/mdlincoln/clipr, http://matthewlincoln.net/clipr/", + "BugReports": "https://github.com/mdlincoln/clipr/issues", + "Imports": [ + "utils" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown", + "rstudioapi (>= 0.5)", + "testthat (>= 2.0.0)" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.1.2", + "SystemRequirements": "xclip (https://github.com/astrand/xclip) or xsel (http://www.vergenet.net/~conrad/software/xsel/) for accessing the X11 clipboard, or wl-clipboard (https://github.com/bugaevc/wl-clipboard) for systems using Wayland.", + "NeedsCompilation": "no", + "Author": "Matthew Lincoln [aut, cre] (), Louis Maddox [ctb], Steve Simpson [ctb], Jennifer Bryan [ctb]", + "Maintainer": "Matthew Lincoln ", + "Repository": "CRAN" + }, + "cluster": { + "Package": "cluster", + "Version": "2.1.4", + "Source": "Repository", + "Date": "2022-08-19", + "Priority": "recommended", + "Title": "\"Finding Groups in Data\": Cluster Analysis Extended Rousseeuw et al.", + "Description": "Methods for Cluster analysis. Much extended the original from Peter Rousseeuw, Anja Struyf and Mia Hubert, based on Kaufman and Rousseeuw (1990) \"Finding Groups in Data\".", + "Maintainer": "Martin Maechler ", + "Authors@R": "c(person(\"Martin\",\"Maechler\", role = c(\"aut\",\"cre\"), email=\"maechler@stat.math.ethz.ch\", comment = c(ORCID = \"0000-0002-8685-9910\")) ,person(\"Peter\", \"Rousseeuw\", role=\"aut\", email=\"peter.rousseeuw@kuleuven.be\", comment = c(\"Fortran original\", ORCID = \"0000-0002-3807-5353\")) ,person(\"Anja\", \"Struyf\", role=\"aut\", comment= \"S original\") ,person(\"Mia\", \"Hubert\", role=\"aut\", email= \"Mia.Hubert@uia.ua.ac.be\", comment = c(\"S original\", ORCID = \"0000-0001-6398-4850\")) ,person(\"Kurt\", \"Hornik\", role=c(\"trl\", \"ctb\"), email=\"Kurt.Hornik@R-project.org\", comment=c(\"port to R; maintenance(1999-2000)\", ORCID=\"0000-0003-4198-9911\")) ,person(\"Matthias\", \"Studer\", role=\"ctb\") ,person(\"Pierre\", \"Roudier\", role=\"ctb\") ,person(\"Juan\", \"Gonzalez\", role=\"ctb\") ,person(\"Kamil\", \"Kozlowski\", role=\"ctb\") ,person(\"Erich\", \"Schubert\", role=\"ctb\", comment = c(\"fastpam options for pam()\", ORCID = \"0000-0001-9143-4880\")) ,person(\"Keefe\", \"Murphy\", role=\"ctb\", comment = \"volume.ellipsoid({d >= 3})\") )", + "Depends": [ + "R (>= 3.5.0)" + ], + "Imports": [ + "graphics", + "grDevices", + "stats", + "utils" + ], + "Suggests": [ + "MASS", + "Matrix" + ], + "SuggestsNote": "MASS: two examples using cov.rob() and mvrnorm(); Matrix tools for testing", + "LazyLoad": "yes", + "LazyData": "yes", + "ByteCompile": "yes", + "BuildResaveData": "no", + "License": "GPL (>= 2)", + "URL": "https://svn.r-project.org/R-packages/trunk/cluster/", + "NeedsCompilation": "yes", + "Author": "Martin Maechler [aut, cre] (), Peter Rousseeuw [aut] (Fortran original, ), Anja Struyf [aut] (S original), Mia Hubert [aut] (S original, ), Kurt Hornik [trl, ctb] (port to R; maintenance(1999-2000), ), Matthias Studer [ctb], Pierre Roudier [ctb], Juan Gonzalez [ctb], Kamil Kozlowski [ctb], Erich Schubert [ctb] (fastpam options for pam(), ), Keefe Murphy [ctb] (volume.ellipsoid({d >= 3}))", + "Repository": "CRAN" + }, + "codetools": { + "Package": "codetools", + "Version": "0.2-19", + "Source": "Repository", + "Priority": "recommended", + "Author": "Luke Tierney ", + "Description": "Code analysis tools for R.", + "Title": "Code Analysis Tools for R", + "Depends": [ + "R (>= 2.1)" + ], + "Maintainer": "Luke Tierney ", + "URL": "https://gitlab.com/luke-tierney/codetools", + "License": "GPL", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "collections": { + "Package": "collections", + "Version": "0.3.7", + "Source": "Repository", + "Type": "Package", + "Title": "High Performance Container Data Types", + "Date": "2023-01-03", + "Authors@R": "c(person(given = \"Randy\", family = \"Lai\", role = c(\"aut\", \"cre\"), email = \"randy.cs.lai@gmail.com\"), person(given = \"Andrea\", family = \"Mazzoleni\", role = \"cph\", comment = \"tommy hash table library\"), person(given = \"Yann\", family = \"Collet\", role = \"cph\", comment = \"xxhash algorithm\"))", + "Description": "Provides high performance container data types such as queues, stacks, deques, dicts and ordered dicts. Benchmarks have shown that these containers are asymptotically more efficient than those offered by other packages.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/randy3k/collections/", + "Suggests": [ + "testthat (>= 2.3.1)" + ], + "ByteCompile": "yes", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "RoxygenNote": "7.1.0", + "Author": "Randy Lai [aut, cre], Andrea Mazzoleni [cph] (tommy hash table library), Yann Collet [cph] (xxhash algorithm)", + "Maintainer": "Randy Lai ", + "Repository": "CRAN" + }, + "colorspace": { + "Package": "colorspace", + "Version": "2.1-0", + "Source": "Repository", + "Date": "2023-01-23", + "Title": "A Toolbox for Manipulating and Assessing Colors and Palettes", + "Authors@R": "c(person(given = \"Ross\", family = \"Ihaka\", role = \"aut\", email = \"ihaka@stat.auckland.ac.nz\"), person(given = \"Paul\", family = \"Murrell\", role = \"aut\", email = \"paul@stat.auckland.ac.nz\", comment = c(ORCID = \"0000-0002-3224-8858\")), person(given = \"Kurt\", family = \"Hornik\", role = \"aut\", email = \"Kurt.Hornik@R-project.org\", comment = c(ORCID = \"0000-0003-4198-9911\")), person(given = c(\"Jason\", \"C.\"), family = \"Fisher\", role = \"aut\", email = \"jfisher@usgs.gov\", comment = c(ORCID = \"0000-0001-9032-8912\")), person(given = \"Reto\", family = \"Stauffer\", role = \"aut\", email = \"Reto.Stauffer@uibk.ac.at\", comment = c(ORCID = \"0000-0002-3798-5507\")), person(given = c(\"Claus\", \"O.\"), family = \"Wilke\", role = \"aut\", email = \"wilke@austin.utexas.edu\", comment = c(ORCID = \"0000-0002-7470-9261\")), person(given = c(\"Claire\", \"D.\"), family = \"McWhite\", role = \"aut\", email = \"claire.mcwhite@utmail.utexas.edu\", comment = c(ORCID = \"0000-0001-7346-3047\")), person(given = \"Achim\", family = \"Zeileis\", role = c(\"aut\", \"cre\"), email = \"Achim.Zeileis@R-project.org\", comment = c(ORCID = \"0000-0003-0918-3766\")))", + "Description": "Carries out mapping between assorted color spaces including RGB, HSV, HLS, CIEXYZ, CIELUV, HCL (polar CIELUV), CIELAB, and polar CIELAB. Qualitative, sequential, and diverging color palettes based on HCL colors are provided along with corresponding ggplot2 color scales. Color palette choice is aided by an interactive app (with either a Tcl/Tk or a shiny graphical user interface) and shiny apps with an HCL color picker and a color vision deficiency emulator. Plotting functions for displaying and assessing palettes include color swatches, visualizations of the HCL space, and trajectories in HCL and/or RGB spectrum. Color manipulation functions include: desaturation, lightening/darkening, mixing, and simulation of color vision deficiencies (deutanomaly, protanomaly, tritanomaly). Details can be found on the project web page at and in the accompanying scientific paper: Zeileis et al. (2020, Journal of Statistical Software, ).", + "Depends": [ + "R (>= 3.0.0)", + "methods" + ], + "Imports": [ + "graphics", + "grDevices", + "stats" + ], + "Suggests": [ + "datasets", + "utils", + "KernSmooth", + "MASS", + "kernlab", + "mvtnorm", + "vcd", + "tcltk", + "shiny", + "shinyjs", + "ggplot2", + "dplyr", + "scales", + "grid", + "png", + "jpeg", + "knitr", + "rmarkdown", + "RColorBrewer", + "rcartocolor", + "scico", + "viridis", + "wesanderson" + ], + "VignetteBuilder": "knitr", + "License": "BSD_3_clause + file LICENSE", + "URL": "https://colorspace.R-Forge.R-project.org/, https://hclwizard.org/", + "BugReports": "https://colorspace.R-Forge.R-project.org/contact.html", + "LazyData": "yes", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Ross Ihaka [aut], Paul Murrell [aut] (), Kurt Hornik [aut] (), Jason C. Fisher [aut] (), Reto Stauffer [aut] (), Claus O. Wilke [aut] (), Claire D. McWhite [aut] (), Achim Zeileis [aut, cre] ()", + "Maintainer": "Achim Zeileis ", + "Repository": "CRAN" + }, + "commonmark": { + "Package": "commonmark", + "Version": "1.9.1", + "Source": "Repository", + "Type": "Package", + "Title": "High Performance CommonMark and Github Markdown Rendering in R", + "Authors@R": "c( person(\"Jeroen\", \"Ooms\", ,\"jeroen@berkeley.edu\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"John MacFarlane\", role = \"cph\", comment = \"Author of cmark\"))", + "URL": "https://docs.ropensci.org/commonmark/ https://r-lib.r-universe.dev/commonmark https://github.github.com/gfm/ (spec)", + "BugReports": "https://github.com/r-lib/commonmark/issues", + "Description": "The CommonMark specification defines a rationalized version of markdown syntax. This package uses the 'cmark' reference implementation for converting markdown text into various formats including html, latex and groff man. In addition it exposes the markdown parse tree in xml format. Also includes opt-in support for GFM extensions including tables, autolinks, and strikethrough text.", + "License": "BSD_2_clause + file LICENSE", + "Suggests": [ + "curl", + "testthat", + "xml2" + ], + "RoxygenNote": "7.2.3", + "Language": "en-US", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] (), John MacFarlane [cph] (Author of cmark)", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "contfrac": { + "Package": "contfrac", + "Version": "1.1-12", + "Source": "Repository", + "Title": "Continued Fractions", + "Author": "Robin K. S. Hankin", + "Description": "Various utilities for evaluating continued fractions.", + "Maintainer": "Robin K. S. Hankin ", + "License": "GPL-2", + "URL": "https://github.com/RobinHankin/contfrac.git", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "countrycode": { + "Package": "countrycode", + "Version": "1.6.0", + "Source": "Repository", + "Type": "Package", + "Title": "Convert Country Names and Country Codes", + "Authors@R": "c(person(given = \"Vincent\", family = \"Arel-Bundock\", role = c(\"aut\", \"cre\"), email = \"vincent.arel-bundock@umontreal.ca\", comment = c(ORCID = \"0000-0003-2042-7063\")), person(given = \"CJ\", family = \"Yetman\", role = \"ctb\", email = \"cj@cjyetman.com\", comment = c(ORCID = \"0000-0001-5099-9500\")), person(given = \"Nils\", family = \"Enevoldsen\", role = \"ctb\", email = \"nils@wlonk.com\", comment = c(ORCID = \"0000-0001-7195-4117\")), person(\"Etienne\", \"Bacher\", email = \"etienne.bacher@protonmail.com\", role = \"ctb\", comment = c(ORCID = \"0000-0002-9271-5075\")), person(given = \"Samuel\", family = \"Meichtry\", role = \"ctb\", email = \"samuel.meichtry@bj.admin.ch\", comment = c(ORCID = \"0000-0003-2165-791X\")))", + "Description": "Standardize country names, convert them into one of 40 different coding schemes, convert between coding schemes, and assign region descriptors.", + "License": "GPL-3", + "URL": "https://vincentarelbundock.github.io/countrycode/", + "BugReports": "https://github.com/vincentarelbundock/countrycode/issues", + "Depends": [ + "R (>= 2.10)" + ], + "Suggests": [ + "altdoc", + "eurostat", + "testthat", + "tibble", + "ISOcodes", + "utf8" + ], + "Encoding": "UTF-8", + "LazyData": "yes", + "LazyLoad": "yes", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "no", + "Author": "Vincent Arel-Bundock [aut, cre] (), CJ Yetman [ctb] (), Nils Enevoldsen [ctb] (), Etienne Bacher [ctb] (), Samuel Meichtry [ctb] ()", + "Maintainer": "Vincent Arel-Bundock ", + "Repository": "CRAN" + }, + "cpp11": { + "Package": "cpp11", + "Version": "0.5.0", + "Source": "Repository", + "Title": "A C++11 Interface for R's C Interface", + "Authors@R": "c( person(\"Davis\", \"Vaughan\", email = \"davis@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-4777-038X\")), person(\"Jim\",\"Hester\", role = \"aut\", comment = c(ORCID = \"0000-0002-2739-7082\")), person(\"Romain\", \"François\", role = \"aut\", comment = c(ORCID = \"0000-0002-2444-4226\")), person(\"Benjamin\", \"Kietzman\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides a header only, C++11 interface to R's C interface. Compared to other approaches 'cpp11' strives to be safe against long jumps from the C API as well as C++ exceptions, conform to normal R function semantics and supports interaction with 'ALTREP' vectors.", + "License": "MIT + file LICENSE", + "URL": "https://cpp11.r-lib.org, https://github.com/r-lib/cpp11", + "BugReports": "https://github.com/r-lib/cpp11/issues", + "Depends": [ + "R (>= 3.6.0)" + ], + "Suggests": [ + "bench", + "brio", + "callr", + "cli", + "covr", + "decor", + "desc", + "ggplot2", + "glue", + "knitr", + "lobstr", + "mockery", + "progress", + "rmarkdown", + "scales", + "Rcpp", + "testthat (>= 3.2.0)", + "tibble", + "utils", + "vctrs", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/Needs/cpp11/cpp_register": "brio, cli, decor, desc, glue, tibble, vctrs", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Davis Vaughan [aut, cre] (), Jim Hester [aut] (), Romain François [aut] (), Benjamin Kietzman [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Davis Vaughan ", + "Repository": "CRAN" + }, + "crayon": { + "Package": "crayon", + "Version": "1.5.3", + "Source": "Repository", + "Title": "Colored Terminal Output", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Brodie\", \"Gaslam\", , \"brodie.gaslam@yahoo.com\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "The crayon package is now superseded. Please use the 'cli' package for new projects. Colored terminal output on terminals that support 'ANSI' color and highlight codes. It also works in 'Emacs' 'ESS'. 'ANSI' color support is automatically detected. Colors and highlighting can be combined and nested. New styles can also be created easily. This package was inspired by the 'chalk' 'JavaScript' project.", + "License": "MIT + file LICENSE", + "URL": "https://r-lib.github.io/crayon/, https://github.com/r-lib/crayon", + "BugReports": "https://github.com/r-lib/crayon/issues", + "Imports": [ + "grDevices", + "methods", + "utils" + ], + "Suggests": [ + "mockery", + "rstudioapi", + "testthat", + "withr" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "Collate": "'aaa-rstudio-detect.R' 'aaaa-rematch2.R' 'aab-num-ansi-colors.R' 'aac-num-ansi-colors.R' 'ansi-256.R' 'ansi-palette.R' 'combine.R' 'string.R' 'utils.R' 'crayon-package.R' 'disposable.R' 'enc-utils.R' 'has_ansi.R' 'has_color.R' 'link.R' 'styles.R' 'machinery.R' 'parts.R' 'print.R' 'style-var.R' 'show.R' 'string_operations.R'", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre], Brodie Gaslam [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "credentials": { + "Package": "credentials", + "Version": "2.0.1", + "Source": "Repository", + "Type": "Package", + "Title": "Tools for Managing SSH and Git Credentials", + "Authors@R": "person(\"Jeroen\", \"Ooms\", role = c(\"aut\", \"cre\"), email = \"jeroen@berkeley.edu\", comment = c(ORCID = \"0000-0002-4035-0289\"))", + "Description": "Setup and retrieve HTTPS and SSH credentials for use with 'git' and other services. For HTTPS remotes the package interfaces the 'git-credential' utility which 'git' uses to store HTTP usernames and passwords. For SSH remotes we provide convenient functions to find or generate appropriate SSH keys. The package both helps the user to setup a local git installation, and also provides a back-end for git/ssh client libraries to authenticate with existing user credentials.", + "License": "MIT + file LICENSE", + "SystemRequirements": "git (optional)", + "Encoding": "UTF-8", + "Imports": [ + "openssl (>= 1.3)", + "sys (>= 2.1)", + "curl", + "jsonlite", + "askpass" + ], + "Suggests": [ + "testthat", + "knitr", + "rmarkdown" + ], + "RoxygenNote": "7.2.1", + "VignetteBuilder": "knitr", + "Language": "en-US", + "URL": "https://docs.ropensci.org/credentials/ https://r-lib.r-universe.dev/credentials", + "BugReports": "https://github.com/r-lib/credentials/issues", + "NeedsCompilation": "no", + "Author": "Jeroen Ooms [aut, cre] ()", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "crosstalk": { + "Package": "crosstalk", + "Version": "1.2.1", + "Source": "Repository", + "Type": "Package", + "Title": "Inter-Widget Interactivity for HTML Widgets", + "Authors@R": "c( person(\"Joe\", \"Cheng\", role = \"aut\", email = \"joe@posit.co\"), person(\"Carson\", \"Sievert\", role = c(\"aut\", \"cre\"), email = \"carson@posit.co\", comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(family = \"jQuery Foundation\", role = \"cph\", comment = \"jQuery library and jQuery UI library\"), person(family = \"jQuery contributors\", role = c(\"ctb\", \"cph\"), comment = \"jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt\"), person(\"Mark\", \"Otto\", role = \"ctb\", comment = \"Bootstrap library\"), person(\"Jacob\", \"Thornton\", role = \"ctb\", comment = \"Bootstrap library\"), person(family = \"Bootstrap contributors\", role = \"ctb\", comment = \"Bootstrap library\"), person(family = \"Twitter, Inc\", role = \"cph\", comment = \"Bootstrap library\"), person(\"Brian\", \"Reavis\", role = c(\"ctb\", \"cph\"), comment = \"selectize.js library\"), person(\"Kristopher Michael\", \"Kowal\", role = c(\"ctb\", \"cph\"), comment = \"es5-shim library\"), person(family = \"es5-shim contributors\", role = c(\"ctb\", \"cph\"), comment = \"es5-shim library\"), person(\"Denis\", \"Ineshin\", role = c(\"ctb\", \"cph\"), comment = \"ion.rangeSlider library\"), person(\"Sami\", \"Samhuri\", role = c(\"ctb\", \"cph\"), comment = \"Javascript strftime library\") )", + "Description": "Provides building blocks for allowing HTML widgets to communicate with each other, with Shiny or without (i.e. static .html files). Currently supports linked brushing and filtering.", + "License": "MIT + file LICENSE", + "Imports": [ + "htmltools (>= 0.3.6)", + "jsonlite", + "lazyeval", + "R6" + ], + "Suggests": [ + "shiny", + "ggplot2", + "testthat (>= 2.1.0)", + "sass", + "bslib" + ], + "URL": "https://rstudio.github.io/crosstalk/, https://github.com/rstudio/crosstalk", + "BugReports": "https://github.com/rstudio/crosstalk/issues", + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Author": "Joe Cheng [aut], Carson Sievert [aut, cre] (), Posit Software, PBC [cph, fnd], jQuery Foundation [cph] (jQuery library and jQuery UI library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt), Mark Otto [ctb] (Bootstrap library), Jacob Thornton [ctb] (Bootstrap library), Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Brian Reavis [ctb, cph] (selectize.js library), Kristopher Michael Kowal [ctb, cph] (es5-shim library), es5-shim contributors [ctb, cph] (es5-shim library), Denis Ineshin [ctb, cph] (ion.rangeSlider library), Sami Samhuri [ctb, cph] (Javascript strftime library)", + "Maintainer": "Carson Sievert ", + "Repository": "CRAN" + }, + "curl": { + "Package": "curl", + "Version": "5.2.1", + "Source": "Repository", + "Type": "Package", + "Title": "A Modern and Flexible Web Client for R", + "Authors@R": "c( person(\"Jeroen\", \"Ooms\", role = c(\"aut\", \"cre\"), email = \"jeroen@berkeley.edu\", comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", role = \"ctb\"), person(\"RStudio\", role = \"cph\") )", + "Description": "The curl() and curl_download() functions provide highly configurable drop-in replacements for base url() and download.file() with better performance, support for encryption (https, ftps), gzip compression, authentication, and other 'libcurl' goodies. The core of the package implements a framework for performing fully customized requests where data can be processed either in memory, on disk, or streaming via the callback or connection interfaces. Some knowledge of 'libcurl' is recommended; for a more-user-friendly web client see the 'httr' package which builds on this package with http specific tools and logic.", + "License": "MIT + file LICENSE", + "SystemRequirements": "libcurl: libcurl-devel (rpm) or libcurl4-openssl-dev (deb).", + "URL": "https://jeroen.r-universe.dev/curl https://curl.se/libcurl/", + "BugReports": "https://github.com/jeroen/curl/issues", + "Suggests": [ + "spelling", + "testthat (>= 1.0.0)", + "knitr", + "jsonlite", + "later", + "rmarkdown", + "httpuv (>= 1.4.4)", + "webutils" + ], + "VignetteBuilder": "knitr", + "Depends": [ + "R (>= 3.0.0)" + ], + "RoxygenNote": "7.3.0", + "Encoding": "UTF-8", + "Language": "en-US", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] (), Hadley Wickham [ctb], RStudio [cph]", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "data.table": { + "Package": "data.table", + "Version": "1.15.4", + "Source": "Repository", + "Title": "Extension of `data.frame`", + "Depends": [ + "R (>= 3.1.0)" + ], + "Imports": [ + "methods" + ], + "Suggests": [ + "bit64 (>= 4.0.0)", + "bit (>= 4.0.4)", + "R.utils", + "xts", + "zoo (>= 1.8-1)", + "yaml", + "knitr", + "markdown" + ], + "Description": "Fast aggregation of large data (e.g. 100GB in RAM), fast ordered joins, fast add/modify/delete of columns by group using no copies at all, list columns, friendly and fast character-separated-value read/write. Offers a natural and flexible syntax, for faster development.", + "License": "MPL-2.0 | file LICENSE", + "URL": "https://r-datatable.com, https://Rdatatable.gitlab.io/data.table, https://github.com/Rdatatable/data.table", + "BugReports": "https://github.com/Rdatatable/data.table/issues", + "VignetteBuilder": "knitr", + "ByteCompile": "TRUE", + "Authors@R": "c( person(\"Tyson\",\"Barrett\", role=c(\"aut\",\"cre\"), email=\"t.barrett88@gmail.com\"), person(\"Matt\",\"Dowle\", role=\"aut\", email=\"mattjdowle@gmail.com\"), person(\"Arun\",\"Srinivasan\", role=\"aut\", email=\"asrini@pm.me\"), person(\"Jan\",\"Gorecki\", role=\"aut\"), person(\"Michael\",\"Chirico\", role=\"aut\"), person(\"Toby\",\"Hocking\", role=\"aut\", comment = c(ORCID=\"0000-0002-3146-0865\")), person(\"Pasha\",\"Stetsenko\", role=\"ctb\"), person(\"Tom\",\"Short\", role=\"ctb\"), person(\"Steve\",\"Lianoglou\", role=\"ctb\"), person(\"Eduard\",\"Antonyan\", role=\"ctb\"), person(\"Markus\",\"Bonsch\", role=\"ctb\"), person(\"Hugh\",\"Parsonage\", role=\"ctb\"), person(\"Scott\",\"Ritchie\", role=\"ctb\"), person(\"Kun\",\"Ren\", role=\"ctb\"), person(\"Xianying\",\"Tan\", role=\"ctb\"), person(\"Rick\",\"Saporta\", role=\"ctb\"), person(\"Otto\",\"Seiskari\", role=\"ctb\"), person(\"Xianghui\",\"Dong\", role=\"ctb\"), person(\"Michel\",\"Lang\", role=\"ctb\"), person(\"Watal\",\"Iwasaki\", role=\"ctb\"), person(\"Seth\",\"Wenchel\", role=\"ctb\"), person(\"Karl\",\"Broman\", role=\"ctb\"), person(\"Tobias\",\"Schmidt\", role=\"ctb\"), person(\"David\",\"Arenburg\", role=\"ctb\"), person(\"Ethan\",\"Smith\", role=\"ctb\"), person(\"Francois\",\"Cocquemas\", role=\"ctb\"), person(\"Matthieu\",\"Gomez\", role=\"ctb\"), person(\"Philippe\",\"Chataignon\", role=\"ctb\"), person(\"Nello\",\"Blaser\", role=\"ctb\"), person(\"Dmitry\",\"Selivanov\", role=\"ctb\"), person(\"Andrey\",\"Riabushenko\", role=\"ctb\"), person(\"Cheng\",\"Lee\", role=\"ctb\"), person(\"Declan\",\"Groves\", role=\"ctb\"), person(\"Daniel\",\"Possenriede\", role=\"ctb\"), person(\"Felipe\",\"Parages\", role=\"ctb\"), person(\"Denes\",\"Toth\", role=\"ctb\"), person(\"Mus\",\"Yaramaz-David\", role=\"ctb\"), person(\"Ayappan\",\"Perumal\", role=\"ctb\"), person(\"James\",\"Sams\", role=\"ctb\"), person(\"Martin\",\"Morgan\", role=\"ctb\"), person(\"Michael\",\"Quinn\", role=\"ctb\"), person(\"@javrucebo\",\"\", role=\"ctb\"), person(\"@marc-outins\",\"\", role=\"ctb\"), person(\"Roy\",\"Storey\", role=\"ctb\"), person(\"Manish\",\"Saraswat\", role=\"ctb\"), person(\"Morgan\",\"Jacob\", role=\"ctb\"), person(\"Michael\",\"Schubmehl\", role=\"ctb\"), person(\"Davis\",\"Vaughan\", role=\"ctb\"), person(\"Leonardo\",\"Silvestri\", role=\"ctb\"), person(\"Jim\",\"Hester\", role=\"ctb\"), person(\"Anthony\",\"Damico\", role=\"ctb\"), person(\"Sebastian\",\"Freundt\", role=\"ctb\"), person(\"David\",\"Simons\", role=\"ctb\"), person(\"Elliott\",\"Sales de Andrade\", role=\"ctb\"), person(\"Cole\",\"Miller\", role=\"ctb\"), person(\"Jens Peder\",\"Meldgaard\", role=\"ctb\"), person(\"Vaclav\",\"Tlapak\", role=\"ctb\"), person(\"Kevin\",\"Ushey\", role=\"ctb\"), person(\"Dirk\",\"Eddelbuettel\", role=\"ctb\"), person(\"Benjamin\",\"Schwendinger\", role=\"ctb\"), person(\"Tony\",\"Fischetti\", role=\"ctb\"), person(\"Ofek\",\"Shilon\", role=\"ctb\"), person(\"Vadim\",\"Khotilovich\", role=\"ctb\"), person(\"Hadley\",\"Wickham\", role=\"ctb\"), person(\"Bennet\",\"Becker\", role=\"ctb\"), person(\"Kyle\",\"Haynes\", role=\"ctb\"), person(\"Boniface Christian\",\"Kamgang\", role=\"ctb\"), person(\"Olivier\",\"Delmarcell\", role=\"ctb\"), person(\"Josh\",\"O'Brien\", role=\"ctb\"), person(\"Dereck\",\"de Mezquita\", role=\"ctb\"), person(\"Michael\",\"Czekanski\", role=\"ctb\") )", + "NeedsCompilation": "yes", + "Author": "Tyson Barrett [aut, cre], Matt Dowle [aut], Arun Srinivasan [aut], Jan Gorecki [aut], Michael Chirico [aut], Toby Hocking [aut] (), Pasha Stetsenko [ctb], Tom Short [ctb], Steve Lianoglou [ctb], Eduard Antonyan [ctb], Markus Bonsch [ctb], Hugh Parsonage [ctb], Scott Ritchie [ctb], Kun Ren [ctb], Xianying Tan [ctb], Rick Saporta [ctb], Otto Seiskari [ctb], Xianghui Dong [ctb], Michel Lang [ctb], Watal Iwasaki [ctb], Seth Wenchel [ctb], Karl Broman [ctb], Tobias Schmidt [ctb], David Arenburg [ctb], Ethan Smith [ctb], Francois Cocquemas [ctb], Matthieu Gomez [ctb], Philippe Chataignon [ctb], Nello Blaser [ctb], Dmitry Selivanov [ctb], Andrey Riabushenko [ctb], Cheng Lee [ctb], Declan Groves [ctb], Daniel Possenriede [ctb], Felipe Parages [ctb], Denes Toth [ctb], Mus Yaramaz-David [ctb], Ayappan Perumal [ctb], James Sams [ctb], Martin Morgan [ctb], Michael Quinn [ctb], @javrucebo [ctb], @marc-outins [ctb], Roy Storey [ctb], Manish Saraswat [ctb], Morgan Jacob [ctb], Michael Schubmehl [ctb], Davis Vaughan [ctb], Leonardo Silvestri [ctb], Jim Hester [ctb], Anthony Damico [ctb], Sebastian Freundt [ctb], David Simons [ctb], Elliott Sales de Andrade [ctb], Cole Miller [ctb], Jens Peder Meldgaard [ctb], Vaclav Tlapak [ctb], Kevin Ushey [ctb], Dirk Eddelbuettel [ctb], Benjamin Schwendinger [ctb], Tony Fischetti [ctb], Ofek Shilon [ctb], Vadim Khotilovich [ctb], Hadley Wickham [ctb], Bennet Becker [ctb], Kyle Haynes [ctb], Boniface Christian Kamgang [ctb], Olivier Delmarcell [ctb], Josh O'Brien [ctb], Dereck de Mezquita [ctb], Michael Czekanski [ctb]", + "Maintainer": "Tyson Barrett ", + "Repository": "CRAN" + }, + "deSolve": { + "Package": "deSolve", + "Version": "1.40", + "Source": "Repository", + "Title": "Solvers for Initial Value Problems of Differential Equations ('ODE', 'DAE', 'DDE')", + "Authors@R": "c(person(\"Karline\",\"Soetaert\", role = c(\"aut\"), email = \"karline.soetaert@nioz.nl\", comment = c(ORCID = \"0000-0003-4603-7100\")), person(\"Thomas\",\"Petzoldt\", role = c(\"aut\", \"cre\"), email = \"thomas.petzoldt@tu-dresden.de\", comment = c(ORCID = \"0000-0002-4951-6468\")), person(\"R. Woodrow\",\"Setzer\", role = c(\"aut\"), email = \"setzer.woodrow@epa.gov\", comment = c(ORCID = \"0000-0002-6709-9186\")), person(\"Peter N.\",\"Brown\", role = \"ctb\", comment = \"files ddaspk.f, dvode.f, zvode.f\"), person(\"George D.\",\"Byrne\", role = \"ctb\", comment = \"files dvode.f, zvode.f\"), person(\"Ernst\",\"Hairer\", role = \"ctb\", comment = \"files radau5.f, radau5a\"), person(\"Alan C.\",\"Hindmarsh\", role = \"ctb\", comment = \"files ddaspk.f, dlsode.f, dvode.f, zvode.f, opdkmain.f, opdka1.f\"), person(\"Cleve\",\"Moler\", role = \"ctb\", comment = \"file dlinpck.f\"), person(\"Linda R.\",\"Petzold\", role = \"ctb\", comment = \"files ddaspk.f, dlsoda.f\"), person(\"Youcef\", \"Saad\", role = \"ctb\", comment = \"file dsparsk.f\"), person(\"Clement W.\",\"Ulrich\", role = \"ctb\", comment = \"file ddaspk.f\") )", + "Author": "Karline Soetaert [aut] (), Thomas Petzoldt [aut, cre] (), R. Woodrow Setzer [aut] (), Peter N. Brown [ctb] (files ddaspk.f, dvode.f, zvode.f), George D. Byrne [ctb] (files dvode.f, zvode.f), Ernst Hairer [ctb] (files radau5.f, radau5a), Alan C. Hindmarsh [ctb] (files ddaspk.f, dlsode.f, dvode.f, zvode.f, opdkmain.f, opdka1.f), Cleve Moler [ctb] (file dlinpck.f), Linda R. Petzold [ctb] (files ddaspk.f, dlsoda.f), Youcef Saad [ctb] (file dsparsk.f), Clement W. Ulrich [ctb] (file ddaspk.f)", + "Maintainer": "Thomas Petzoldt ", + "Depends": [ + "R (>= 3.3.0)" + ], + "Imports": [ + "methods", + "graphics", + "grDevices", + "stats" + ], + "Suggests": [ + "scatterplot3d", + "FME" + ], + "Description": "Functions that solve initial value problems of a system of first-order ordinary differential equations ('ODE'), of partial differential equations ('PDE'), of differential algebraic equations ('DAE'), and of delay differential equations. The functions provide an interface to the FORTRAN functions 'lsoda', 'lsodar', 'lsode', 'lsodes' of the 'ODEPACK' collection, to the FORTRAN functions 'dvode', 'zvode' and 'daspk' and a C-implementation of solvers of the 'Runge-Kutta' family with fixed or variable time steps. The package contains routines designed for solving 'ODEs' resulting from 1-D, 2-D and 3-D partial differential equations ('PDE') that have been converted to 'ODEs' by numerical differencing.", + "License": "GPL (>= 2)", + "URL": "http://desolve.r-forge.r-project.org/", + "LazyData": "yes", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "desc": { + "Package": "desc", + "Version": "1.4.3", + "Source": "Repository", + "Title": "Manipulate DESCRIPTION Files", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Kirill\", \"Müller\", role = \"aut\"), person(\"Jim\", \"Hester\", , \"james.f.hester@gmail.com\", role = \"aut\"), person(\"Maëlle\", \"Salmon\", role = \"ctb\", comment = c(ORCID = \"0000-0002-2815-0399\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Maintainer": "Gábor Csárdi ", + "Description": "Tools to read, write, create, and manipulate DESCRIPTION files. It is intended for packages that create or manipulate other packages.", + "License": "MIT + file LICENSE", + "URL": "https://desc.r-lib.org/, https://github.com/r-lib/desc", + "BugReports": "https://github.com/r-lib/desc/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Imports": [ + "cli", + "R6", + "utils" + ], + "Suggests": [ + "callr", + "covr", + "gh", + "spelling", + "testthat", + "whoami", + "withr" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.2.3", + "Collate": "'assertions.R' 'authors-at-r.R' 'built.R' 'classes.R' 'collate.R' 'constants.R' 'deps.R' 'desc-package.R' 'description.R' 'encoding.R' 'find-package-root.R' 'latex.R' 'non-oo-api.R' 'package-archives.R' 'read.R' 'remotes.R' 'str.R' 'syntax_checks.R' 'urls.R' 'utils.R' 'validate.R' 'version.R'", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre], Kirill Müller [aut], Jim Hester [aut], Maëlle Salmon [ctb] (), Posit Software, PBC [cph, fnd]", + "Repository": "CRAN" + }, + "devtools": { + "Package": "devtools", + "Version": "2.4.5", + "Source": "Repository", + "Title": "Tools to Make Developing R Packages Easier", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", role = \"aut\"), person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Winston\", \"Chang\", role = \"aut\"), person(\"Jennifer\", \"Bryan\", , \"jenny@rstudio.com\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-6983-2759\")), person(\"RStudio\", role = c(\"cph\", \"fnd\")) )", + "Description": "Collection of package development tools.", + "License": "MIT + file LICENSE", + "URL": "https://devtools.r-lib.org/, https://github.com/r-lib/devtools", + "BugReports": "https://github.com/r-lib/devtools/issues", + "Depends": [ + "R (>= 3.0.2)", + "usethis (>= 2.1.6)" + ], + "Imports": [ + "cli (>= 3.3.0)", + "desc (>= 1.4.1)", + "ellipsis (>= 0.3.2)", + "fs (>= 1.5.2)", + "lifecycle (>= 1.0.1)", + "memoise (>= 2.0.1)", + "miniUI (>= 0.1.1.1)", + "pkgbuild (>= 1.3.1)", + "pkgdown (>= 2.0.6)", + "pkgload (>= 1.3.0)", + "profvis (>= 0.3.7)", + "rcmdcheck (>= 1.4.0)", + "remotes (>= 2.4.2)", + "rlang (>= 1.0.4)", + "roxygen2 (>= 7.2.1)", + "rversions (>= 2.1.1)", + "sessioninfo (>= 1.2.2)", + "stats", + "testthat (>= 3.1.5)", + "tools", + "urlchecker (>= 1.0.1)", + "utils", + "withr (>= 2.5.0)" + ], + "Suggests": [ + "BiocManager (>= 1.30.18)", + "callr (>= 3.7.1)", + "covr (>= 3.5.1)", + "curl (>= 4.3.2)", + "digest (>= 0.6.29)", + "DT (>= 0.23)", + "foghorn (>= 1.4.2)", + "gh (>= 1.3.0)", + "gmailr (>= 1.0.1)", + "httr (>= 1.4.3)", + "knitr (>= 1.39)", + "lintr (>= 3.0.0)", + "MASS", + "mockery (>= 0.4.3)", + "pingr (>= 2.0.1)", + "rhub (>= 1.1.1)", + "rmarkdown (>= 2.14)", + "rstudioapi (>= 0.13)", + "spelling (>= 2.2)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.2.1", + "Config/testthat/edition": "3", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut], Jim Hester [aut], Winston Chang [aut], Jennifer Bryan [aut, cre] (), RStudio [cph, fnd]", + "Maintainer": "Jennifer Bryan ", + "Repository": "CRAN" + }, + "diffobj": { + "Package": "diffobj", + "Version": "0.3.5", + "Source": "Repository", + "Type": "Package", + "Title": "Diffs for R Objects", + "Description": "Generate a colorized diff of two R objects for an intuitive visualization of their differences.", + "Authors@R": "c( person( \"Brodie\", \"Gaslam\", email=\"brodie.gaslam@yahoo.com\", role=c(\"aut\", \"cre\")), person( \"Michael B.\", \"Allen\", email=\"ioplex@gmail.com\", role=c(\"ctb\", \"cph\"), comment=\"Original C implementation of Myers Diff Algorithm\"))", + "Depends": [ + "R (>= 3.1.0)" + ], + "License": "GPL-2 | GPL-3", + "URL": "https://github.com/brodieG/diffobj", + "BugReports": "https://github.com/brodieG/diffobj/issues", + "RoxygenNote": "7.1.1", + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "Suggests": [ + "knitr", + "rmarkdown" + ], + "Collate": "'capt.R' 'options.R' 'pager.R' 'check.R' 'finalizer.R' 'misc.R' 'html.R' 'styles.R' 's4.R' 'core.R' 'diff.R' 'get.R' 'guides.R' 'hunks.R' 'layout.R' 'myerssimple.R' 'rdiff.R' 'rds.R' 'set.R' 'subset.R' 'summmary.R' 'system.R' 'text.R' 'tochar.R' 'trim.R' 'word.R'", + "Imports": [ + "crayon (>= 1.3.2)", + "tools", + "methods", + "utils", + "stats" + ], + "NeedsCompilation": "yes", + "Author": "Brodie Gaslam [aut, cre], Michael B. Allen [ctb, cph] (Original C implementation of Myers Diff Algorithm)", + "Maintainer": "Brodie Gaslam ", + "Repository": "CRAN" + }, + "digest": { + "Package": "digest", + "Version": "0.6.37", + "Source": "Repository", + "Authors@R": "c(person(\"Dirk\", \"Eddelbuettel\", role = c(\"aut\", \"cre\"), email = \"edd@debian.org\", comment = c(ORCID = \"0000-0001-6419-907X\")), person(\"Antoine\", \"Lucas\", role=\"ctb\"), person(\"Jarek\", \"Tuszynski\", role=\"ctb\"), person(\"Henrik\", \"Bengtsson\", role=\"ctb\", comment = c(ORCID = \"0000-0002-7579-5165\")), person(\"Simon\", \"Urbanek\", role=\"ctb\", comment = c(ORCID = \"0000-0003-2297-1732\")), person(\"Mario\", \"Frasca\", role=\"ctb\"), person(\"Bryan\", \"Lewis\", role=\"ctb\"), person(\"Murray\", \"Stokely\", role=\"ctb\"), person(\"Hannes\", \"Muehleisen\", role=\"ctb\"), person(\"Duncan\", \"Murdoch\", role=\"ctb\"), person(\"Jim\", \"Hester\", role=\"ctb\"), person(\"Wush\", \"Wu\", role=\"ctb\", comment = c(ORCID = \"0000-0001-5180-0567\")), person(\"Qiang\", \"Kou\", role=\"ctb\", comment = c(ORCID = \"0000-0001-6786-5453\")), person(\"Thierry\", \"Onkelinx\", role=\"ctb\", comment = c(ORCID = \"0000-0001-8804-4216\")), person(\"Michel\", \"Lang\", role=\"ctb\", comment = c(ORCID = \"0000-0001-9754-0393\")), person(\"Viliam\", \"Simko\", role=\"ctb\"), person(\"Kurt\", \"Hornik\", role=\"ctb\", comment = c(ORCID = \"0000-0003-4198-9911\")), person(\"Radford\", \"Neal\", role=\"ctb\", comment = c(ORCID = \"0000-0002-2473-3407\")), person(\"Kendon\", \"Bell\", role=\"ctb\", comment = c(ORCID = \"0000-0002-9093-8312\")), person(\"Matthew\", \"de Queljoe\", role=\"ctb\"), person(\"Dmitry\", \"Selivanov\", role=\"ctb\"), person(\"Ion\", \"Suruceanu\", role=\"ctb\"), person(\"Bill\", \"Denney\", role=\"ctb\"), person(\"Dirk\", \"Schumacher\", role=\"ctb\"), person(\"András\", \"Svraka\", role=\"ctb\"), person(\"Sergey\", \"Fedorov\", role=\"ctb\"), person(\"Will\", \"Landau\", role=\"ctb\", comment = c(ORCID = \"0000-0003-1878-3253\")), person(\"Floris\", \"Vanderhaeghe\", role=\"ctb\", comment = c(ORCID = \"0000-0002-6378-6229\")), person(\"Kevin\", \"Tappe\", role=\"ctb\"), person(\"Harris\", \"McGehee\", role=\"ctb\"), person(\"Tim\", \"Mastny\", role=\"ctb\"), person(\"Aaron\", \"Peikert\", role=\"ctb\", comment = c(ORCID = \"0000-0001-7813-818X\")), person(\"Mark\", \"van der Loo\", role=\"ctb\", comment = c(ORCID = \"0000-0002-9807-4686\")), person(\"Chris\", \"Muir\", role=\"ctb\", comment = c(ORCID = \"0000-0003-2555-3878\")), person(\"Moritz\", \"Beller\", role=\"ctb\", comment = c(ORCID = \"0000-0003-4852-0526\")), person(\"Sebastian\", \"Campbell\", role=\"ctb\"), person(\"Winston\", \"Chang\", role=\"ctb\", comment = c(ORCID = \"0000-0002-1576-2126\")), person(\"Dean\", \"Attali\", role=\"ctb\", comment = c(ORCID = \"0000-0002-5645-3493\")), person(\"Michael\", \"Chirico\", role=\"ctb\", comment = c(ORCID = \"0000-0003-0787-087X\")), person(\"Kevin\", \"Ushey\", role=\"ctb\"))", + "Date": "2024-08-19", + "Title": "Create Compact Hash Digests of R Objects", + "Description": "Implementation of a function 'digest()' for the creation of hash digests of arbitrary R objects (using the 'md5', 'sha-1', 'sha-256', 'crc32', 'xxhash', 'murmurhash', 'spookyhash', 'blake3', 'crc32c', 'xxh3_64', and 'xxh3_128' algorithms) permitting easy comparison of R language objects, as well as functions such as'hmac()' to create hash-based message authentication code. Please note that this package is not meant to be deployed for cryptographic purposes for which more comprehensive (and widely tested) libraries such as 'OpenSSL' should be used.", + "URL": "https://github.com/eddelbuettel/digest, https://dirk.eddelbuettel.com/code/digest.html", + "BugReports": "https://github.com/eddelbuettel/digest/issues", + "Depends": [ + "R (>= 3.3.0)" + ], + "Imports": [ + "utils" + ], + "License": "GPL (>= 2)", + "Suggests": [ + "tinytest", + "simplermarkdown" + ], + "VignetteBuilder": "simplermarkdown", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Dirk Eddelbuettel [aut, cre] (), Antoine Lucas [ctb], Jarek Tuszynski [ctb], Henrik Bengtsson [ctb] (), Simon Urbanek [ctb] (), Mario Frasca [ctb], Bryan Lewis [ctb], Murray Stokely [ctb], Hannes Muehleisen [ctb], Duncan Murdoch [ctb], Jim Hester [ctb], Wush Wu [ctb] (), Qiang Kou [ctb] (), Thierry Onkelinx [ctb] (), Michel Lang [ctb] (), Viliam Simko [ctb], Kurt Hornik [ctb] (), Radford Neal [ctb] (), Kendon Bell [ctb] (), Matthew de Queljoe [ctb], Dmitry Selivanov [ctb], Ion Suruceanu [ctb], Bill Denney [ctb], Dirk Schumacher [ctb], András Svraka [ctb], Sergey Fedorov [ctb], Will Landau [ctb] (), Floris Vanderhaeghe [ctb] (), Kevin Tappe [ctb], Harris McGehee [ctb], Tim Mastny [ctb], Aaron Peikert [ctb] (), Mark van der Loo [ctb] (), Chris Muir [ctb] (), Moritz Beller [ctb] (), Sebastian Campbell [ctb], Winston Chang [ctb] (), Dean Attali [ctb] (), Michael Chirico [ctb] (), Kevin Ushey [ctb]", + "Maintainer": "Dirk Eddelbuettel ", + "Repository": "CRAN" + }, + "doParallel": { + "Package": "doParallel", + "Version": "1.0.17", + "Source": "Repository", + "Type": "Package", + "Title": "Foreach Parallel Adaptor for the 'parallel' Package", + "Authors@R": "c(person(\"Folashade\", \"Daniel\", role=\"cre\", email=\"fdaniel@microsoft.com\"), person(\"Microsoft\", \"Corporation\", role=c(\"aut\", \"cph\")), person(\"Steve\", \"Weston\", role=\"aut\"), person(\"Dan\", \"Tenenbaum\", role=\"ctb\"))", + "Description": "Provides a parallel backend for the %dopar% function using the parallel package.", + "Depends": [ + "R (>= 2.14.0)", + "foreach (>= 1.2.0)", + "iterators (>= 1.0.0)", + "parallel", + "utils" + ], + "Suggests": [ + "caret", + "mlbench", + "rpart", + "RUnit" + ], + "Enhances": [ + "compiler" + ], + "License": "GPL-2", + "URL": "https://github.com/RevolutionAnalytics/doparallel", + "BugReports": "https://github.com/RevolutionAnalytics/doparallel/issues", + "NeedsCompilation": "no", + "Author": "Folashade Daniel [cre], Microsoft Corporation [aut, cph], Steve Weston [aut], Dan Tenenbaum [ctb]", + "Maintainer": "Folashade Daniel ", + "Repository": "CRAN" + }, + "dotCall64": { + "Package": "dotCall64", + "Version": "1.1-1", + "Source": "Repository", + "Type": "Package", + "Title": "Enhanced Foreign Function Interface Supporting Long Vectors", + "Date": "2023-11-28", + "Authors@R": "c(person(\"Kaspar\", \"Moesinger\", role = c(\"aut\"), email = \"kaspar.moesinger@gmail.com\"), person(\"Florian\", \"Gerber\", role = c(\"aut\"), email = \"flora.fauna.gerber@gmail.com\", comment = c(ORCID = \"0000-0001-8545-5263\")), person(\"Reinhard\", \"Furrer\", role = c(\"cre\", \"ctb\"), email = \"reinhard.furrer@math.uzh.ch\", comment = c(ORCID = \"0000-0002-6319-2332\")))", + "Description": "Provides .C64(), which is an enhanced version of .C() and .Fortran() from the foreign function interface. .C64() supports long vectors, arguments of type 64-bit integer, and provides a mechanism to avoid unnecessary copies of read-only and write-only arguments. This makes it a convenient and fast interface to C/C++ and Fortran code.", + "License": "GPL (>= 2)", + "URL": "https://git.math.uzh.ch/reinhard.furrer/dotCall64", + "BugReports": "https://git.math.uzh.ch/reinhard.furrer/dotCall64/-/issues", + "Depends": [ + "R (>= 3.1)" + ], + "Suggests": [ + "microbenchmark", + "RhpcBLASctl", + "RColorBrewer", + "roxygen2", + "spam", + "testthat" + ], + "Collate": "'vector_dc.R' 'dotCall64.R' 'zzz.R'", + "RoxygenNote": "7.1.1", + "NeedsCompilation": "yes", + "Author": "Kaspar Moesinger [aut], Florian Gerber [aut] (), Reinhard Furrer [cre, ctb] ()", + "Maintainer": "Reinhard Furrer ", + "Repository": "CRAN" + }, + "downlit": { + "Package": "downlit", + "Version": "0.4.4", + "Source": "Repository", + "Title": "Syntax Highlighting and Automatic Linking", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Syntax highlighting of R code, specifically designed for the needs of 'RMarkdown' packages like 'pkgdown', 'hugodown', and 'bookdown'. It includes linking of function calls to their documentation on the web, and automatic translation of ANSI escapes in output to the equivalent HTML.", + "License": "MIT + file LICENSE", + "URL": "https://downlit.r-lib.org/, https://github.com/r-lib/downlit", + "BugReports": "https://github.com/r-lib/downlit/issues", + "Depends": [ + "R (>= 4.0.0)" + ], + "Imports": [ + "brio", + "desc", + "digest", + "evaluate", + "fansi", + "memoise", + "rlang", + "vctrs", + "withr", + "yaml" + ], + "Suggests": [ + "covr", + "htmltools", + "jsonlite", + "MASS", + "MassSpecWavelet", + "pkgload", + "rmarkdown", + "testthat (>= 3.0.0)", + "xml2" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "dplyr": { + "Package": "dplyr", + "Version": "1.1.4", + "Source": "Repository", + "Type": "Package", + "Title": "A Grammar of Data Manipulation", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Romain\", \"François\", role = \"aut\", comment = c(ORCID = \"0000-0002-2444-4226\")), person(\"Lionel\", \"Henry\", role = \"aut\"), person(\"Kirill\", \"Müller\", role = \"aut\", comment = c(ORCID = \"0000-0002-1416-3412\")), person(\"Davis\", \"Vaughan\", , \"davis@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-4777-038X\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A fast, consistent tool for working with data frame like objects, both in memory and out of memory.", + "License": "MIT + file LICENSE", + "URL": "https://dplyr.tidyverse.org, https://github.com/tidyverse/dplyr", + "BugReports": "https://github.com/tidyverse/dplyr/issues", + "Depends": [ + "R (>= 3.5.0)" + ], + "Imports": [ + "cli (>= 3.4.0)", + "generics", + "glue (>= 1.3.2)", + "lifecycle (>= 1.0.3)", + "magrittr (>= 1.5)", + "methods", + "pillar (>= 1.9.0)", + "R6", + "rlang (>= 1.1.0)", + "tibble (>= 3.2.0)", + "tidyselect (>= 1.2.0)", + "utils", + "vctrs (>= 0.6.4)" + ], + "Suggests": [ + "bench", + "broom", + "callr", + "covr", + "DBI", + "dbplyr (>= 2.2.1)", + "ggplot2", + "knitr", + "Lahman", + "lobstr", + "microbenchmark", + "nycflights13", + "purrr", + "rmarkdown", + "RMySQL", + "RPostgreSQL", + "RSQLite", + "stringi (>= 1.7.6)", + "testthat (>= 3.1.5)", + "tidyr (>= 1.3.0)", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse, shiny, pkgdown, tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre] (), Romain François [aut] (), Lionel Henry [aut], Kirill Müller [aut] (), Davis Vaughan [aut] (), Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "e1071": { + "Package": "e1071", + "Version": "1.7-14", + "Source": "Repository", + "Title": "Misc Functions of the Department of Statistics, Probability Theory Group (Formerly: E1071), TU Wien", + "Imports": [ + "graphics", + "grDevices", + "class", + "stats", + "methods", + "utils", + "proxy" + ], + "Suggests": [ + "cluster", + "mlbench", + "nnet", + "randomForest", + "rpart", + "SparseM", + "xtable", + "Matrix", + "MASS", + "slam" + ], + "Authors@R": "c(person(given = \"David\", family = \"Meyer\", role = c(\"aut\", \"cre\"), email = \"David.Meyer@R-project.org\", comment = c(ORCID = \"0000-0002-5196-3048\")), person(given = \"Evgenia\", family = \"Dimitriadou\", role = c(\"aut\",\"cph\")), person(given = \"Kurt\", family = \"Hornik\", role = \"aut\", email = \"Kurt.Hornik@R-project.org\", comment = c(ORCID = \"0000-0003-4198-9911\")), person(given = \"Andreas\", family = \"Weingessel\", role = \"aut\"), person(given = \"Friedrich\", family = \"Leisch\", role = \"aut\"), person(given = \"Chih-Chung\", family = \"Chang\", role = c(\"ctb\",\"cph\"), comment = \"libsvm C++-code\"), person(given = \"Chih-Chen\", family = \"Lin\", role = c(\"ctb\",\"cph\"), comment = \"libsvm C++-code\"))", + "Description": "Functions for latent class analysis, short time Fourier transform, fuzzy clustering, support vector machines, shortest path computation, bagged clustering, naive Bayes classifier, generalized k-nearest neighbour ...", + "License": "GPL-2 | GPL-3", + "LazyLoad": "yes", + "NeedsCompilation": "yes", + "Author": "David Meyer [aut, cre] (), Evgenia Dimitriadou [aut, cph], Kurt Hornik [aut] (), Andreas Weingessel [aut], Friedrich Leisch [aut], Chih-Chung Chang [ctb, cph] (libsvm C++-code), Chih-Chen Lin [ctb, cph] (libsvm C++-code)", + "Maintainer": "David Meyer ", + "Repository": "CRAN" + }, + "ellipsis": { + "Package": "ellipsis", + "Version": "0.3.2", + "Source": "Repository", + "Title": "Tools for Working with ...", + "Description": "The ellipsis is a powerful tool for extending functions. Unfortunately this power comes at a cost: misspelled arguments will be silently ignored. The ellipsis package provides a collection of functions to catch problems and alert the user.", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", role = c(\"aut\", \"cre\")), person(\"RStudio\", role = \"cph\") )", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "RoxygenNote": "7.1.1", + "URL": "https://ellipsis.r-lib.org, https://github.com/r-lib/ellipsis", + "BugReports": "https://github.com/r-lib/ellipsis/issues", + "Depends": [ + "R (>= 3.2)" + ], + "Imports": [ + "rlang (>= 0.3.0)" + ], + "Suggests": [ + "covr", + "testthat" + ], + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre], RStudio [cph]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "elliptic": { + "Package": "elliptic", + "Version": "1.4-0", + "Source": "Repository", + "Title": "Weierstrass and Jacobi Elliptic Functions", + "Authors@R": "person(given=c(\"Robin\", \"K. S.\"), family=\"Hankin\", role = c(\"aut\",\"cre\"), email=\"hankin.robin@gmail.com\", comment = c(ORCID = \"0000-0001-5982-0415\"))", + "Depends": [ + "R (>= 2.5.0)" + ], + "Imports": [ + "MASS" + ], + "Suggests": [ + "emulator", + "calibrator (>= 1.2-8)" + ], + "SystemRequirements": "pari/gp", + "Description": "A suite of elliptic and related functions including Weierstrass and Jacobi forms. Also includes various tools for manipulating and visualizing complex functions.", + "Maintainer": "Robin K. S. Hankin ", + "License": "GPL-2", + "URL": "https://github.com/RobinHankin/elliptic.git", + "BugReports": "https://github.com/RobinHankin/elliptic/issues", + "NeedsCompilation": "no", + "Author": "Robin K. S. Hankin [aut, cre] ()", + "Repository": "CRAN" + }, + "evaluate": { + "Package": "evaluate", + "Version": "1.0.5", + "Source": "Repository", + "Type": "Package", + "Title": "Parsing and Evaluation Tools that Provide More Details than the Default", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Yihui\", \"Xie\", role = \"aut\", comment = c(ORCID = \"0000-0003-0645-5666\")), person(\"Michael\", \"Lawrence\", role = \"ctb\"), person(\"Thomas\", \"Kluyver\", role = \"ctb\"), person(\"Jeroen\", \"Ooms\", role = \"ctb\"), person(\"Barret\", \"Schloerke\", role = \"ctb\"), person(\"Adam\", \"Ryczkowski\", role = \"ctb\"), person(\"Hiroaki\", \"Yutani\", role = \"ctb\"), person(\"Michel\", \"Lang\", role = \"ctb\"), person(\"Karolis\", \"Koncevičius\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Parsing and evaluation tools that make it easy to recreate the command line behaviour of R.", + "License": "MIT + file LICENSE", + "URL": "https://evaluate.r-lib.org/, https://github.com/r-lib/evaluate", + "BugReports": "https://github.com/r-lib/evaluate/issues", + "Depends": [ + "R (>= 3.6.0)" + ], + "Suggests": [ + "callr", + "covr", + "ggplot2 (>= 3.3.6)", + "lattice", + "methods", + "pkgload", + "ragg (>= 1.4.0)", + "rlang (>= 1.1.5)", + "knitr", + "testthat (>= 3.0.0)", + "withr" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], Yihui Xie [aut] (ORCID: ), Michael Lawrence [ctb], Thomas Kluyver [ctb], Jeroen Ooms [ctb], Barret Schloerke [ctb], Adam Ryczkowski [ctb], Hiroaki Yutani [ctb], Michel Lang [ctb], Karolis Koncevičius [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "fansi": { + "Package": "fansi", + "Version": "1.0.6", + "Source": "Repository", + "Title": "ANSI Control Sequence Aware String Functions", + "Description": "Counterparts to R string manipulation functions that account for the effects of ANSI text formatting control sequences.", + "Authors@R": "c( person(\"Brodie\", \"Gaslam\", email=\"brodie.gaslam@yahoo.com\", role=c(\"aut\", \"cre\")), person(\"Elliott\", \"Sales De Andrade\", role=\"ctb\"), person(family=\"R Core Team\", email=\"R-core@r-project.org\", role=\"cph\", comment=\"UTF8 byte length calcs from src/util.c\" ))", + "Depends": [ + "R (>= 3.1.0)" + ], + "License": "GPL-2 | GPL-3", + "URL": "https://github.com/brodieG/fansi", + "BugReports": "https://github.com/brodieG/fansi/issues", + "VignetteBuilder": "knitr", + "Suggests": [ + "unitizer", + "knitr", + "rmarkdown" + ], + "Imports": [ + "grDevices", + "utils" + ], + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "Collate": "'constants.R' 'fansi-package.R' 'internal.R' 'load.R' 'misc.R' 'nchar.R' 'strwrap.R' 'strtrim.R' 'strsplit.R' 'substr2.R' 'trimws.R' 'tohtml.R' 'unhandled.R' 'normalize.R' 'sgr.R'", + "NeedsCompilation": "yes", + "Author": "Brodie Gaslam [aut, cre], Elliott Sales De Andrade [ctb], R Core Team [cph] (UTF8 byte length calcs from src/util.c)", + "Maintainer": "Brodie Gaslam ", + "Repository": "CRAN" + }, + "farver": { + "Package": "farver", + "Version": "2.1.2", + "Source": "Repository", + "Type": "Package", + "Title": "High Performance Colour Space Manipulation", + "Authors@R": "c( person(\"Thomas Lin\", \"Pedersen\", , \"thomas.pedersen@posit.co\", role = c(\"cre\", \"aut\"), comment = c(ORCID = \"0000-0002-5147-4711\")), person(\"Berendea\", \"Nicolae\", role = \"aut\", comment = \"Author of the ColorSpace C++ library\"), person(\"Romain\", \"François\", , \"romain@purrple.cat\", role = \"aut\", comment = c(ORCID = \"0000-0002-2444-4226\")), person(\"Posit, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "The encoding of colour can be handled in many different ways, using different colour spaces. As different colour spaces have different uses, efficient conversion between these representations are important. The 'farver' package provides a set of functions that gives access to very fast colour space conversion and comparisons implemented in C++, and offers speed improvements over the 'convertColor' function in the 'grDevices' package.", + "License": "MIT + file LICENSE", + "URL": "https://farver.data-imaginist.com, https://github.com/thomasp85/farver", + "BugReports": "https://github.com/thomasp85/farver/issues", + "Suggests": [ + "covr", + "testthat (>= 3.0.0)" + ], + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "yes", + "Author": "Thomas Lin Pedersen [cre, aut] (), Berendea Nicolae [aut] (Author of the ColorSpace C++ library), Romain François [aut] (), Posit, PBC [cph, fnd]", + "Maintainer": "Thomas Lin Pedersen ", + "Repository": "CRAN" + }, + "fastmap": { + "Package": "fastmap", + "Version": "1.2.0", + "Source": "Repository", + "Title": "Fast Data Structures", + "Authors@R": "c( person(\"Winston\", \"Chang\", email = \"winston@posit.co\", role = c(\"aut\", \"cre\")), person(given = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(given = \"Tessil\", role = \"cph\", comment = \"hopscotch_map library\") )", + "Description": "Fast implementation of data structures, including a key-value store, stack, and queue. Environments are commonly used as key-value stores in R, but every time a new key is used, it is added to R's global symbol table, causing a small amount of memory leakage. This can be problematic in cases where many different keys are used. Fastmap avoids this memory leak issue by implementing the map using data structures in C++.", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "Suggests": [ + "testthat (>= 2.1.1)" + ], + "URL": "https://r-lib.github.io/fastmap/, https://github.com/r-lib/fastmap", + "BugReports": "https://github.com/r-lib/fastmap/issues", + "NeedsCompilation": "yes", + "Author": "Winston Chang [aut, cre], Posit Software, PBC [cph, fnd], Tessil [cph] (hopscotch_map library)", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "fields": { + "Package": "fields", + "Version": "15.2", + "Source": "Repository", + "Date": "2023-08-17", + "Title": "Tools for Spatial Data", + "Authors@R": "c( person(\"Douglas\", \"Nychka\", role = c(\"aut\", \"cre\"), email = \"douglasnychka@gmail.com\"), person(\"Reinhard\", \"Furrer\", role = c(\"aut\"), email = \"reinhard.furrer@math.uzh.ch\"), person(\"John\", \"Paige\", role = c(\"aut\"), email = \"paigejo@uw.edu\"), person(\"Stephan\", \"Sain\", role = \"aut\", email = \"sainsr2@gmail.com\"), person(\"Florian\", \"Gerber\", role = \"aut\", email = \"flora.fauna.gerber@gmail.com\"), person(\"Matthew\", \"Iverson\", role = \"aut\", email = \"miverson@mymail.mines.edu\"), person(\"University Corporation for Atmospheric Research\", role=\"cph\", email=\"nychka@ucar.edu\") )", + "Maintainer": "Douglas Nychka ", + "Description": "For curve, surface and function fitting with an emphasis on splines, spatial data, geostatistics, and spatial statistics. The major methods include cubic, and thin plate splines, Kriging, and compactly supported covariance functions for large data sets. The splines and Kriging methods are supported by functions that can determine the smoothing parameter (nugget and sill variance) and other covariance function parameters by cross validation and also by restricted maximum likelihood. For Kriging there is an easy to use function that also estimates the correlation scale (range parameter). A major feature is that any covariance function implemented in R and following a simple format can be used for spatial prediction. There are also many useful functions for plotting and working with spatial data as images. This package also contains an implementation of sparse matrix methods for large spatial data sets and currently requires the sparse matrix (spam) package. Use help(fields) to get started and for an overview. The fields source code is deliberately commented and provides useful explanations of numerical details as a companion to the manual pages. The commented source code can be viewed by expanding the source code version and looking in the R subdirectory. The reference for fields can be generated by the citation function in R and has DOI . Development of this package was supported in part by the National Science Foundation Grant 1417857, the National Center for Atmospheric Research, and Colorado School of Mines. See the Fields URL for a vignette on using this package and some background on spatial statistics.", + "License": "GPL (>= 2)", + "URL": "https://github.com/dnychka/fieldsRPackage", + "Depends": [ + "R (>= 3.5.0)", + "methods", + "spam", + "viridisLite" + ], + "Imports": [ + "maps" + ], + "NeedsCompilation": "yes", + "Repository": "CRAN", + "Author": "Douglas Nychka [aut, cre], Reinhard Furrer [aut], John Paige [aut], Stephan Sain [aut], Florian Gerber [aut], Matthew Iverson [aut], University Corporation for Atmospheric Research [cph]" + }, + "filelock": { + "Package": "filelock", + "Version": "1.0.3", + "Source": "Repository", + "Title": "Portable File Locking", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Place an exclusive or shared lock on a file. It uses 'LockFile' on Windows and 'fcntl' locks on Unix-like systems.", + "License": "MIT + file LICENSE", + "URL": "https://r-lib.github.io/filelock/, https://github.com/r-lib/filelock", + "BugReports": "https://github.com/r-lib/filelock/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Suggests": [ + "callr (>= 2.0.0)", + "covr", + "testthat (>= 3.0.0)" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Gábor Csárdi [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "fontawesome": { + "Package": "fontawesome", + "Version": "0.5.3", + "Source": "Repository", + "Type": "Package", + "Title": "Easily Work with 'Font Awesome' Icons", + "Description": "Easily and flexibly insert 'Font Awesome' icons into 'R Markdown' documents and 'Shiny' apps. These icons can be inserted into HTML content through inline 'SVG' tags or 'i' tags. There is also a utility function for exporting 'Font Awesome' icons as 'PNG' images for those situations where raster graphics are needed.", + "Authors@R": "c( person(\"Richard\", \"Iannone\", , \"rich@posit.co\", c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-3925-190X\")), person(\"Christophe\", \"Dervieux\", , \"cderv@posit.co\", role = \"ctb\", comment = c(ORCID = \"0000-0003-4474-2498\")), person(\"Winston\", \"Chang\", , \"winston@posit.co\", role = \"ctb\"), person(\"Dave\", \"Gandy\", role = c(\"ctb\", \"cph\"), comment = \"Font-Awesome font\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "License": "MIT + file LICENSE", + "URL": "https://github.com/rstudio/fontawesome, https://rstudio.github.io/fontawesome/", + "BugReports": "https://github.com/rstudio/fontawesome/issues", + "Encoding": "UTF-8", + "ByteCompile": "true", + "RoxygenNote": "7.3.2", + "Depends": [ + "R (>= 3.3.0)" + ], + "Imports": [ + "rlang (>= 1.0.6)", + "htmltools (>= 0.5.1.1)" + ], + "Suggests": [ + "covr", + "dplyr (>= 1.0.8)", + "gt (>= 0.9.0)", + "knitr (>= 1.31)", + "testthat (>= 3.0.0)", + "rsvg" + ], + "Config/testthat/edition": "3", + "NeedsCompilation": "no", + "Author": "Richard Iannone [aut, cre] (), Christophe Dervieux [ctb] (), Winston Chang [ctb], Dave Gandy [ctb, cph] (Font-Awesome font), Posit Software, PBC [cph, fnd]", + "Maintainer": "Richard Iannone ", + "Repository": "CRAN" + }, + "forcats": { + "Package": "forcats", + "Version": "1.0.0", + "Source": "Repository", + "Title": "Tools for Working with Categorical Variables (Factors)", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", role = c(\"aut\", \"cre\")), person(\"RStudio\", role = c(\"cph\", \"fnd\")) )", + "Description": "Helpers for reordering factor levels (including moving specified levels to front, ordering by first appearance, reversing, and randomly shuffling), and tools for modifying factor levels (including collapsing rare levels into other, 'anonymising', and manually 'recoding').", + "License": "MIT + file LICENSE", + "URL": "https://forcats.tidyverse.org/, https://github.com/tidyverse/forcats", + "BugReports": "https://github.com/tidyverse/forcats/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Imports": [ + "cli (>= 3.4.0)", + "glue", + "lifecycle", + "magrittr", + "rlang (>= 1.0.0)", + "tibble" + ], + "Suggests": [ + "covr", + "dplyr", + "ggplot2", + "knitr", + "readr", + "rmarkdown", + "testthat (>= 3.0.0)", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], RStudio [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "foreach": { + "Package": "foreach", + "Version": "1.5.2", + "Source": "Repository", + "Type": "Package", + "Title": "Provides Foreach Looping Construct", + "Authors@R": "c(person(\"Folashade\", \"Daniel\", role=\"cre\", email=\"fdaniel@microsoft.com\"), person(\"Hong\", \"Ooi\", role=\"ctb\"), person(\"Rich\", \"Calaway\", role=\"ctb\"), person(\"Microsoft\", role=c(\"aut\", \"cph\")), person(\"Steve\", \"Weston\", role=\"aut\"))", + "Description": "Support for the foreach looping construct. Foreach is an idiom that allows for iterating over elements in a collection, without the use of an explicit loop counter. This package in particular is intended to be used for its return value, rather than for its side effects. In that sense, it is similar to the standard lapply function, but doesn't require the evaluation of a function. Using foreach without side effects also facilitates executing the loop in parallel.", + "License": "Apache License (== 2.0)", + "URL": "https://github.com/RevolutionAnalytics/foreach", + "BugReports": "https://github.com/RevolutionAnalytics/foreach/issues", + "Depends": [ + "R (>= 2.5.0)" + ], + "Imports": [ + "codetools", + "utils", + "iterators" + ], + "Suggests": [ + "randomForest", + "doMC", + "doParallel", + "testthat", + "knitr", + "rmarkdown" + ], + "VignetteBuilder": "knitr", + "RoxygenNote": "7.1.1", + "Collate": "'callCombine.R' 'foreach.R' 'do.R' 'foreach-ext.R' 'foreach-pkg.R' 'getDoPar.R' 'getDoSeq.R' 'getsyms.R' 'iter.R' 'nextElem.R' 'onLoad.R' 'setDoPar.R' 'setDoSeq.R' 'times.R' 'utils.R'", + "NeedsCompilation": "no", + "Author": "Folashade Daniel [cre], Hong Ooi [ctb], Rich Calaway [ctb], Microsoft [aut, cph], Steve Weston [aut]", + "Maintainer": "Folashade Daniel ", + "Repository": "CRAN" + }, + "foreign": { + "Package": "foreign", + "Version": "0.8-85", + "Source": "Repository", + "Priority": "recommended", + "Date": "2023-09-09", + "Title": "Read Data Stored by 'Minitab', 'S', 'SAS', 'SPSS', 'Stata', 'Systat', 'Weka', 'dBase', ...", + "Depends": [ + "R (>= 4.0.0)" + ], + "Imports": [ + "methods", + "utils", + "stats" + ], + "Authors@R": "c( person(\"R Core Team\", email = \"R-core@R-project.org\", role = c(\"aut\", \"cph\", \"cre\")), person(\"Roger\", \"Bivand\", role = c(\"ctb\", \"cph\")), person(c(\"Vincent\", \"J.\"), \"Carey\", role = c(\"ctb\", \"cph\")), person(\"Saikat\", \"DebRoy\", role = c(\"ctb\", \"cph\")), person(\"Stephen\", \"Eglen\", role = c(\"ctb\", \"cph\")), person(\"Rajarshi\", \"Guha\", role = c(\"ctb\", \"cph\")), person(\"Swetlana\", \"Herbrandt\", role = \"ctb\"), person(\"Nicholas\", \"Lewin-Koh\", role = c(\"ctb\", \"cph\")), person(\"Mark\", \"Myatt\", role = c(\"ctb\", \"cph\")), person(\"Michael\", \"Nelson\", role = \"ctb\"), person(\"Ben\", \"Pfaff\", role = \"ctb\"), person(\"Brian\", \"Quistorff\", role = \"ctb\"), person(\"Frank\", \"Warmerdam\", role = c(\"ctb\", \"cph\")), person(\"Stephen\", \"Weigand\", role = c(\"ctb\", \"cph\")), person(\"Free Software Foundation, Inc.\", role = \"cph\"))", + "Contact": "see 'MailingList'", + "Copyright": "see file COPYRIGHTS", + "Description": "Reading and writing data stored by some versions of 'Epi Info', 'Minitab', 'S', 'SAS', 'SPSS', 'Stata', 'Systat', 'Weka', and for reading and writing some 'dBase' files.", + "ByteCompile": "yes", + "Biarch": "yes", + "License": "GPL (>= 2)", + "BugReports": "https://bugs.r-project.org", + "MailingList": "R-help@r-project.org", + "URL": "https://svn.r-project.org/R-packages/trunk/foreign/", + "NeedsCompilation": "yes", + "Author": "R Core Team [aut, cph, cre], Roger Bivand [ctb, cph], Vincent J. Carey [ctb, cph], Saikat DebRoy [ctb, cph], Stephen Eglen [ctb, cph], Rajarshi Guha [ctb, cph], Swetlana Herbrandt [ctb], Nicholas Lewin-Koh [ctb, cph], Mark Myatt [ctb, cph], Michael Nelson [ctb], Ben Pfaff [ctb], Brian Quistorff [ctb], Frank Warmerdam [ctb, cph], Stephen Weigand [ctb, cph], Free Software Foundation, Inc. [cph]", + "Maintainer": "R Core Team ", + "Repository": "CRAN" + }, + "fs": { + "Package": "fs", + "Version": "1.6.6", + "Source": "Repository", + "Title": "Cross-Platform File System Operations Based on 'libuv'", + "Authors@R": "c( person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"libuv project contributors\", role = \"cph\", comment = \"libuv library\"), person(\"Joyent, Inc. and other Node contributors\", role = \"cph\", comment = \"libuv library\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A cross-platform interface to file system operations, built on top of the 'libuv' C library.", + "License": "MIT + file LICENSE", + "URL": "https://fs.r-lib.org, https://github.com/r-lib/fs", + "BugReports": "https://github.com/r-lib/fs/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "methods" + ], + "Suggests": [ + "covr", + "crayon", + "knitr", + "pillar (>= 1.0.0)", + "rmarkdown", + "spelling", + "testthat (>= 3.0.0)", + "tibble (>= 1.1.0)", + "vctrs (>= 0.3.0)", + "withr" + ], + "VignetteBuilder": "knitr", + "ByteCompile": "true", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Copyright": "file COPYRIGHTS", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.2.3", + "SystemRequirements": "GNU make", + "NeedsCompilation": "yes", + "Author": "Jim Hester [aut], Hadley Wickham [aut], Gábor Csárdi [aut, cre], libuv project contributors [cph] (libuv library), Joyent, Inc. and other Node contributors [cph] (libuv library), Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "gamstransfer": { + "Package": "gamstransfer", + "Version": "3.0.3", + "Source": "Repository", + "Type": "Package", + "Title": "A Data Interface Between 'GAMS' and R", + "Date": "2024-06-13", + "Authors@R": "c( person(\"Atharv\", \"Bhosekar\", email = \"abhosekar@gams.com\", role = c(\"aut\", \"cre\")), person(\"GAMS Development Corp.\", email = \"support@gams.com\", role=c(\"cph\", \"fnd\")), person(\"GAMS Software GmbH\", email = \"support@gams.com\", role=c(\"cph\", \"fnd\")) )", + "Maintainer": "Atharv Bhosekar ", + "Description": "Read, analyze, modify, and write 'GAMS' (General Algebraic Modeling System) data. The main focus of 'gamstransfer' is the highly efficient transfer of data with 'GAMS' , while keeping these operations as simple as possible for the user. The transfer of data usually takes place via an intermediate GDX (GAMS Data Exchange) file. Additionally, 'gamstransfer' provides utility functions to get an overview of 'GAMS' data and to check its validity.", + "License": "MIT + file LICENSE", + "Imports": [ + "Rcpp (>= 1.0.6)", + "R6 (>= 2.5.1)", + "R.utils (>= 2.11.0)", + "collections(>= 0.3.6)" + ], + "LinkingTo": [ + "Rcpp" + ], + "Suggests": [ + "testthat (>= 3.0.0)" + ], + "URL": "https://github.com/GAMS-dev/transfer-r/tree/main/gamstransfer", + "BugReports": "https://github.com/GAMS-dev/transfer-r/issues", + "Config/testthat/edition": "3", + "RoxygenNote": "7.3.1", + "SystemRequirements": "C++17", + "Encoding": "UTF-8", + "Collate": "'Alias.R' 'BaseAlias.R' 'Container.R' 'DomainViolation.R' 'SpecialValues.R' 'Equation.R' 'Parameter.R' 'RcppExports.R' 'Set.R' 'Super.R' 'Symbol.R' 'UniverseAlias.R' 'Variable.R' 'gamstransfer-package.R' 'symbolTypes.R' 'utility.R'", + "NeedsCompilation": "yes", + "Author": "Atharv Bhosekar [aut, cre], GAMS Development Corp. [cph, fnd], GAMS Software GmbH [cph, fnd]", + "Repository": "CRAN" + }, + "gdx2": { + "Package": "gdx2", + "Version": "0.3.3", + "Source": "Repository", + "Type": "Package", + "Title": "Interface package for GDX files in R", + "Date": "2025-07-03", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-4309-6431\"), role = c(\"aut\",\"cre\")))", + "Description": "A wrapper package for the gamstransfer package extending its functionality and allowing to read GDX files directly in R. It is emulating the basic features of the readGDX function in the gdx package but now based on gamstransfer instead of gdxrrw which served as a basis for gdx.", + "License": "BSD_2_clause + file LICENSE", + "URL": "https://github.com/pik-piam/gdx2", + "BugReports": "https://github.com/pik-piam/gdx2/issues", + "Imports": [ + "gamstransfer", + "magclass (>= 6.0)" + ], + "Suggests": [ + "covr" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Config/Keywords": "tool", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "git@github.com:pik-piam/gdx2", + "RemoteRef": "HEAD", + "RemoteSha": "155bd496d5f3a237159aedb8dc9be38782f7bd5e", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre] (Potsdam Institute for Climate Impact Research, )", + "Maintainer": "Jan Philipp Dietrich " + }, + "gdxrrw": { + "Package": "gdxrrw", + "Version": "1.0.10", + "Source": "Repository", + "Title": "An Interface Between 'GAMS' and R", + "Depends": [ + "R (>= 3.0)" + ], + "Date": "2021-04-02", + "SystemRequirements": "GAMS (>= 33.0.0)", + "Authors@R": "c(person(\"Steve\",\"Dirkse\", role=c(\"aut\",\"cre\"), email=\"R@gams.com\"), person(\"Michael\",\"Ferris\", role=c(\"aut\")), person(\"Rishabh\",\"Jain\", role=c(\"aut\")) )", + "Description": "A data interface between 'GAMS' and R. The 'GAMS' (General Algebraic Modeling System) software includes a data specification called 'GDX' that is the preferred way to store and exchange 'GAMS' data. This package includes several functions to transfer data between 'GDX' and R, and some related utility functions.", + "URL": "http://www.gams.com", + "License": "EPL2 with Secondary License GPL-2.0 or greater", + "Imports": [ + "reshape2" + ], + "LazyData": "no", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/GAMS-dev/gdxrrw", + "RemoteRef": "HEAD", + "RemoteSha": "64310f04e68f05d6bba2bd0159c81499a48898bc", + "NeedsCompilation": "yes", + "Author": "Steve Dirkse [aut, cre], Michael Ferris [aut], Rishabh Jain [aut]", + "Maintainer": "Steve Dirkse " + }, + "generics": { + "Package": "generics", + "Version": "0.1.3", + "Source": "Repository", + "Title": "Common S3 Generics not Provided by Base R Methods Related to Model Fitting", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", role = c(\"aut\", \"cre\")), person(\"Max\", \"Kuhn\", , \"max@rstudio.com\", role = \"aut\"), person(\"Davis\", \"Vaughan\", , \"davis@rstudio.com\", role = \"aut\"), person(\"RStudio\", role = \"cph\") )", + "Description": "In order to reduce potential package dependencies and conflicts, generics provides a number of commonly used S3 generics.", + "License": "MIT + file LICENSE", + "URL": "https://generics.r-lib.org, https://github.com/r-lib/generics", + "BugReports": "https://github.com/r-lib/generics/issues", + "Depends": [ + "R (>= 3.2)" + ], + "Imports": [ + "methods" + ], + "Suggests": [ + "covr", + "pkgload", + "testthat (>= 3.0.0)", + "tibble", + "withr" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.0", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], Max Kuhn [aut], Davis Vaughan [aut], RStudio [cph]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "geometry": { + "Package": "geometry", + "Version": "0.4.7", + "Source": "Repository", + "License": "GPL (>= 3)", + "Title": "Mesh Generation and Surface Tessellation", + "Authors@R": "c( person(\"Jean-Romain\", \"Roussel\" , role=c(\"cph\", \"ctb\"), comment = \"wrote tsearch function with QuadTrees\"), person(\"C. B.\", \"Barber\" , role=\"cph\"), person(\"Kai\", \"Habel\", role=c(\"cph\",\"aut\")), person(\"Raoul\", \"Grasman\", role=c(\"cph\",\"aut\")), person(\"Robert B.\", \"Gramacy\", role=c(\"cph\",\"aut\")), person(\"Pavlo\", \"Mozharovskyi\", role=c(\"cph\",\"aut\")), person(\"David C.\", \"Sterratt\", role=c(\"cph\",\"aut\",\"cre\"), email=\"david.c.sterratt@ed.ac.uk\", comment=c(ORCID=\"0000-0001-9092-9099\")))", + "Description": "Makes the 'Qhull' library available in R, in a similar manner as in Octave and MATLAB. Qhull computes convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. It runs in 2D, 3D, 4D, and higher dimensions. It implements the Quickhull algorithm for computing the convex hull. Qhull does not support constrained Delaunay triangulations, or mesh generation of non-convex objects, but the package does include some R functions that allow for this.", + "URL": "https://davidcsterratt.github.io/geometry/", + "Date": "2023-02-03", + "BugReports": "https://github.com/davidcsterratt/geometry/issues", + "Depends": [ + "R (>= 3.0.0)" + ], + "Imports": [ + "magic", + "Rcpp", + "lpSolve", + "linprog" + ], + "Suggests": [ + "spelling", + "testthat", + "rgl", + "R.matlab", + "interp" + ], + "LinkingTo": [ + "Rcpp", + "RcppProgress" + ], + "Encoding": "UTF-8", + "Language": "en-GB", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Jean-Romain Roussel [cph, ctb] (wrote tsearch function with QuadTrees), C. B. Barber [cph], Kai Habel [cph, aut], Raoul Grasman [cph, aut], Robert B. Gramacy [cph, aut], Pavlo Mozharovskyi [cph, aut], David C. Sterratt [cph, aut, cre] ()", + "Maintainer": "David C. Sterratt ", + "Repository": "CRAN" + }, + "gert": { + "Package": "gert", + "Version": "2.0.1", + "Source": "Repository", + "Type": "Package", + "Title": "Simple Git Client for R", + "Authors@R": "c( person(\"Jeroen\", \"Ooms\", role = c(\"aut\", \"cre\"), email = \"jeroen@berkeley.edu\", comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"Jennifer\", \"Bryan\", role = \"ctb\", email = \"jenny@rstudio.com\", comment = c(ORCID = \"0000-0002-6983-2759\")))", + "Description": "Simple git client for R based on 'libgit2' with support for SSH and HTTPS remotes. All functions in 'gert' use basic R data types (such as vectors and data-frames) for their arguments and return values. User credentials are shared with command line 'git' through the git-credential store and ssh keys stored on disk or ssh-agent.", + "License": "MIT + file LICENSE", + "URL": "https://docs.ropensci.org/gert/ https://ropensci.r-universe.dev/gert", + "BugReports": "https://github.com/r-lib/gert/issues", + "Imports": [ + "askpass", + "credentials (>= 1.2.1)", + "openssl (>= 2.0.3)", + "rstudioapi (>= 0.11)", + "sys", + "zip (>= 2.1.0)" + ], + "Suggests": [ + "spelling", + "knitr", + "rmarkdown", + "testthat" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "SystemRequirements": "libgit2 (>= 1.0): libgit2-devel (rpm) or libgit2-dev (deb)", + "Language": "en-US", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] (), Jennifer Bryan [ctb] ()", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "ggh4x": { + "Package": "ggh4x", + "Version": "0.2.8", + "Source": "Repository", + "Title": "Hacks for 'ggplot2'", + "Authors@R": "person(given = \"Teun\", family = \"van den Brand\", role = c(\"aut\", \"cre\"), email = \"tahvdbrand@gmail.com\", comment = c(ORCID = \"0000-0002-9335-7468\"))", + "Description": "A 'ggplot2' extension that does a variety of little helpful things. The package extends 'ggplot2' facets through customisation, by setting individual scales per panel, resizing panels and providing nested facets. Also allows multiple colour and fill scales per plot. Also hosts a smaller collection of stats, geoms and axis guides.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/teunbrand/ggh4x, https://teunbrand.github.io/ggh4x/", + "BugReports": "https://github.com/teunbrand/ggh4x/issues", + "Depends": [ + "ggplot2 (>= 3.4.2)" + ], + "Imports": [ + "grid", + "gtable", + "scales", + "vctrs (>= 0.5.0)", + "rlang (>= 1.1.0)", + "lifecycle", + "stats", + "cli" + ], + "Suggests": [ + "covr", + "fitdistrplus", + "ggdendro", + "vdiffr", + "knitr", + "MASS", + "rmarkdown", + "testthat (>= 3.0.0)", + "utils" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.0", + "Config/testthat/edition": "3", + "Collate": "'borrowed_ggplot2.R' 'conveniences.R' 'ggh4x_extensions.R' 'coord_axes_inside.R' 'element_part_rect.R' 'facet_grid2.R' 'facet_wrap2.R' 'facet_manual.R' 'facet_nested.R' 'facet_nested_wrap.R' 'facetted_pos_scales.R' 'force_panelsize.R' 'geom_box.R' 'geom_outline_point.R' 'geom_pointpath.R' 'geom_polygonraster.R' 'geom_rectrug.R' 'geom_text_aimed.R' 'ggh4x-package.R' 'guide_axis_logticks.R' 'guide_axis_manual.R' 'guide_axis_minor.R' 'guide_axis_nested.R' 'guide_axis_scalebar.R' 'guide_axis_truncated.R' 'guide_axis_utils.R' 'guide_dendrogram.R' 'guide_stringlegend.R' 'help_secondary.R' 'position_disjoint_ranges.R' 'position_lineartrans.R' 'scale_dendrogram.R' 'scale_facet.R' 'scale_listed.R' 'scale_manual.R' 'scale_multi.R' 'stat_difference.R' 'stat_funxy.R' 'stat_rle.R' 'stat_roll.R' 'stat_theodensity.R' 'strip_vanilla.R' 'strip_themed.R' 'strip_nested.R' 'strip_split.R' 'themes.R' 'utils.R' 'utils_grid.R' 'utils_gtable.R'", + "NeedsCompilation": "no", + "Author": "Teun van den Brand [aut, cre] ()", + "Maintainer": "Teun van den Brand ", + "Repository": "CRAN" + }, + "ggiraph": { + "Package": "ggiraph", + "Version": "0.8.10", + "Source": "Repository", + "Type": "Package", + "Title": "Make 'ggplot2' Graphics Interactive", + "Authors@R": "c( person(\"David\", \"Gohel\", , \"david.gohel@ardata.fr\", role = c(\"aut\", \"cre\")), person(\"Panagiotis\", \"Skintzos\", , \"sigmapi@posteo.net\", role = \"aut\"), person(\"Mike\", \"Bostock\", role = \"cph\", comment = \"d3.js\"), person(\"Speros\", \"Kokenes\", role = \"cph\", comment = \"d3-lasso\"), person(\"Eric\", \"Shull\", role = \"cph\", comment = \"saveSvgAsPng js library\"), person(\"Lee\", \"Thomason\", role = \"cph\", comment = \"TinyXML2\"), person(\"Vladimir\", \"Agafonkin\", role = \"cph\", comment = \"Flatbush\"), person(\"Eric\", \"Book\", role = \"ctb\", comment = \"hline and vline geoms\") )", + "Description": "Create interactive 'ggplot2' graphics using 'htmlwidgets'.", + "License": "GPL-3", + "URL": "https://davidgohel.github.io/ggiraph/", + "BugReports": "https://github.com/davidgohel/ggiraph/issues", + "Imports": [ + "cli", + "ggplot2 (>= 3.5.0)", + "grid", + "htmltools", + "htmlwidgets (>= 1.5)", + "purrr", + "Rcpp (>= 1.0)", + "rlang", + "stats", + "systemfonts", + "uuid", + "vctrs" + ], + "Suggests": [ + "dplyr", + "gdtools (>= 0.3.0)", + "ggrepel (>= 0.9.1)", + "hexbin", + "knitr", + "maps", + "quantreg", + "rmarkdown", + "sf (>= 1.0)", + "shiny", + "tinytest", + "xml2 (>= 1.0)" + ], + "LinkingTo": [ + "Rcpp", + "systemfonts" + ], + "VignetteBuilder": "knitr", + "Copyright": "See file COPYRIGHTS.", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "SystemRequirements": "libpng", + "Collate": "'RcppExports.R' 'ipar.R' 'utils_ggplot2_performance.R' 'utils_ggplot2.R' 'utils.R' 'annotate_interactive.R' 'annotation_raster_interactive.R' 'utils_css.R' 'fonts.R' 'girafe_options.R' 'default.R' 'dsvg.R' 'dsvg_view.R' 'element_interactive.R' 'facet_interactive.R' 'geom_abline_interactive.R' 'geom_path_interactive.R' 'geom_polygon_interactive.R' 'geom_rect_interactive.R' 'geom_bar_interactive.R' 'geom_bin_2d_interactive.R' 'geom_boxplot_interactive.R' 'geom_col_interactive.R' 'geom_contour_interactive.R' 'geom_count_interactive.R' 'geom_crossbar_interactive.R' 'geom_curve_interactive.R' 'geom_density_2d_interactive.R' 'geom_density_interactive.R' 'geom_dotplot_interactive.R' 'geom_errorbar_interactive.R' 'geom_errorbarh_interactive.R' 'geom_freqpoly_interactive.R' 'geom_hex_interactive.R' 'geom_histogram_interactive.R' 'geom_hline_interactive.R' 'geom_jitter_interactive.R' 'geom_label_interactive.R' 'geom_linerange_interactive.R' 'geom_map_interactive.R' 'geom_point_interactive.R' 'geom_pointrange_interactive.R' 'geom_quantile_interactive.R' 'geom_raster_interactive.R' 'geom_ribbon_interactive.R' 'geom_segment_interactive.R' 'geom_sf_interactive.R' 'geom_smooth_interactive.R' 'geom_spoke_interactive.R' 'geom_text_interactive.R' 'geom_text_repel_interactive.R' 'geom_tile_interactive.R' 'geom_violin_interactive.R' 'geom_vline_interactive.R' 'ggiraph.R' 'girafe.R' 'grob_interactive.R' 'guide_bins_interactive.R' 'guide_colourbar_interactive.R' 'guide_coloursteps_interactive.R' 'guide_interactive.R' 'guide_legend_interactive.R' 'interactive_circle_grob.R' 'interactive_curve_grob.R' 'interactive_path_grob.R' 'interactive_points_grob.R' 'interactive_polygon_grob.R' 'interactive_polyline_grob.R' 'interactive_raster_grob.R' 'interactive_rect_grob.R' 'interactive_roundrect_grob.R' 'interactive_segments_grob.R' 'interactive_text_grob.R' 'labeller_interactive.R' 'layer_interactive.R' 'scale_alpha_interactive.R' 'scale_brewer_interactive.R' 'scale_colour_interactive.R' 'scale_gradient_interactive.R' 'scale_interactive.R' 'scale_linetype_interactive.R' 'scale_manual_interactive.R' 'scale_shape_interactive.R' 'scale_size_interactive.R' 'scale_steps_interactive.R' 'scale_viridis_interactive.R' 'tracers.R'", + "NeedsCompilation": "yes", + "Author": "David Gohel [aut, cre], Panagiotis Skintzos [aut], Mike Bostock [cph] (d3.js), Speros Kokenes [cph] (d3-lasso), Eric Shull [cph] (saveSvgAsPng js library), Lee Thomason [cph] (TinyXML2), Vladimir Agafonkin [cph] (Flatbush), Eric Book [ctb] (hline and vline geoms)", + "Maintainer": "David Gohel ", + "Repository": "CRAN" + }, + "ggplot2": { + "Package": "ggplot2", + "Version": "4.0.0", + "Source": "Repository", + "Title": "Create Elegant Data Visualisations Using the Grammar of Graphics", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Winston\", \"Chang\", role = \"aut\", comment = c(ORCID = \"0000-0002-1576-2126\")), person(\"Lionel\", \"Henry\", role = \"aut\"), person(\"Thomas Lin\", \"Pedersen\", , \"thomas.pedersen@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-5147-4711\")), person(\"Kohske\", \"Takahashi\", role = \"aut\"), person(\"Claus\", \"Wilke\", role = \"aut\", comment = c(ORCID = \"0000-0002-7470-9261\")), person(\"Kara\", \"Woo\", role = \"aut\", comment = c(ORCID = \"0000-0002-5125-4188\")), person(\"Hiroaki\", \"Yutani\", role = \"aut\", comment = c(ORCID = \"0000-0002-3385-7233\")), person(\"Dewey\", \"Dunnington\", role = \"aut\", comment = c(ORCID = \"0000-0002-9415-4582\")), person(\"Teun\", \"van den Brand\", role = \"aut\", comment = c(ORCID = \"0000-0002-9335-7468\")), person(\"Posit, PBC\", role = c(\"cph\", \"fnd\"), comment = c(ROR = \"03wc8by49\")) )", + "Description": "A system for 'declaratively' creating graphics, based on \"The Grammar of Graphics\". You provide the data, tell 'ggplot2' how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details.", + "License": "MIT + file LICENSE", + "URL": "https://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2", + "BugReports": "https://github.com/tidyverse/ggplot2/issues", + "Depends": [ + "R (>= 4.1)" + ], + "Imports": [ + "cli", + "grDevices", + "grid", + "gtable (>= 0.3.6)", + "isoband", + "lifecycle (> 1.0.1)", + "rlang (>= 1.1.0)", + "S7", + "scales (>= 1.4.0)", + "stats", + "vctrs (>= 0.6.0)", + "withr (>= 2.5.0)" + ], + "Suggests": [ + "broom", + "covr", + "dplyr", + "ggplot2movies", + "hexbin", + "Hmisc", + "knitr", + "mapproj", + "maps", + "MASS", + "mgcv", + "multcomp", + "munsell", + "nlme", + "profvis", + "quantreg", + "ragg (>= 1.2.6)", + "RColorBrewer", + "rmarkdown", + "roxygen2", + "rpart", + "sf (>= 0.7-3)", + "svglite (>= 2.1.2)", + "testthat (>= 3.1.5)", + "tibble", + "vdiffr (>= 1.0.6)", + "xml2" + ], + "Enhances": [ + "sp" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "ggtext, tidyr, forcats, tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/usethis/last-upkeep": "2025-04-23", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.3.2", + "Collate": "'ggproto.R' 'ggplot-global.R' 'aaa-.R' 'aes-colour-fill-alpha.R' 'aes-evaluation.R' 'aes-group-order.R' 'aes-linetype-size-shape.R' 'aes-position.R' 'all-classes.R' 'compat-plyr.R' 'utilities.R' 'aes.R' 'annotation-borders.R' 'utilities-checks.R' 'legend-draw.R' 'geom-.R' 'annotation-custom.R' 'annotation-logticks.R' 'scale-type.R' 'layer.R' 'make-constructor.R' 'geom-polygon.R' 'geom-map.R' 'annotation-map.R' 'geom-raster.R' 'annotation-raster.R' 'annotation.R' 'autolayer.R' 'autoplot.R' 'axis-secondary.R' 'backports.R' 'bench.R' 'bin.R' 'coord-.R' 'coord-cartesian-.R' 'coord-fixed.R' 'coord-flip.R' 'coord-map.R' 'coord-munch.R' 'coord-polar.R' 'coord-quickmap.R' 'coord-radial.R' 'coord-sf.R' 'coord-transform.R' 'data.R' 'docs_layer.R' 'facet-.R' 'facet-grid-.R' 'facet-null.R' 'facet-wrap.R' 'fortify-map.R' 'fortify-models.R' 'fortify-spatial.R' 'fortify.R' 'stat-.R' 'geom-abline.R' 'geom-rect.R' 'geom-bar.R' 'geom-tile.R' 'geom-bin2d.R' 'geom-blank.R' 'geom-boxplot.R' 'geom-col.R' 'geom-path.R' 'geom-contour.R' 'geom-point.R' 'geom-count.R' 'geom-crossbar.R' 'geom-segment.R' 'geom-curve.R' 'geom-defaults.R' 'geom-ribbon.R' 'geom-density.R' 'geom-density2d.R' 'geom-dotplot.R' 'geom-errorbar.R' 'geom-freqpoly.R' 'geom-function.R' 'geom-hex.R' 'geom-histogram.R' 'geom-hline.R' 'geom-jitter.R' 'geom-label.R' 'geom-linerange.R' 'geom-pointrange.R' 'geom-quantile.R' 'geom-rug.R' 'geom-sf.R' 'geom-smooth.R' 'geom-spoke.R' 'geom-text.R' 'geom-violin.R' 'geom-vline.R' 'ggplot2-package.R' 'grob-absolute.R' 'grob-dotstack.R' 'grob-null.R' 'grouping.R' 'properties.R' 'margins.R' 'theme-elements.R' 'guide-.R' 'guide-axis.R' 'guide-axis-logticks.R' 'guide-axis-stack.R' 'guide-axis-theta.R' 'guide-legend.R' 'guide-bins.R' 'guide-colorbar.R' 'guide-colorsteps.R' 'guide-custom.R' 'guide-none.R' 'guide-old.R' 'guides-.R' 'guides-grid.R' 'hexbin.R' 'import-standalone-obj-type.R' 'import-standalone-types-check.R' 'labeller.R' 'labels.R' 'layer-sf.R' 'layout.R' 'limits.R' 'performance.R' 'plot-build.R' 'plot-construction.R' 'plot-last.R' 'plot.R' 'position-.R' 'position-collide.R' 'position-dodge.R' 'position-dodge2.R' 'position-identity.R' 'position-jitter.R' 'position-jitterdodge.R' 'position-nudge.R' 'position-stack.R' 'quick-plot.R' 'reshape-add-margins.R' 'save.R' 'scale-.R' 'scale-alpha.R' 'scale-binned.R' 'scale-brewer.R' 'scale-colour.R' 'scale-continuous.R' 'scale-date.R' 'scale-discrete-.R' 'scale-expansion.R' 'scale-gradient.R' 'scale-grey.R' 'scale-hue.R' 'scale-identity.R' 'scale-linetype.R' 'scale-linewidth.R' 'scale-manual.R' 'scale-shape.R' 'scale-size.R' 'scale-steps.R' 'scale-view.R' 'scale-viridis.R' 'scales-.R' 'stat-align.R' 'stat-bin.R' 'stat-summary-2d.R' 'stat-bin2d.R' 'stat-bindot.R' 'stat-binhex.R' 'stat-boxplot.R' 'stat-connect.R' 'stat-contour.R' 'stat-count.R' 'stat-density-2d.R' 'stat-density.R' 'stat-ecdf.R' 'stat-ellipse.R' 'stat-function.R' 'stat-identity.R' 'stat-manual.R' 'stat-qq-line.R' 'stat-qq.R' 'stat-quantilemethods.R' 'stat-sf-coordinates.R' 'stat-sf.R' 'stat-smooth-methods.R' 'stat-smooth.R' 'stat-sum.R' 'stat-summary-bin.R' 'stat-summary-hex.R' 'stat-summary.R' 'stat-unique.R' 'stat-ydensity.R' 'summarise-plot.R' 'summary.R' 'theme.R' 'theme-defaults.R' 'theme-current.R' 'theme-sub.R' 'utilities-break.R' 'utilities-grid.R' 'utilities-help.R' 'utilities-patterns.R' 'utilities-resolution.R' 'utilities-tidy-eval.R' 'zxx.R' 'zzz.R'", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut] (ORCID: ), Winston Chang [aut] (ORCID: ), Lionel Henry [aut], Thomas Lin Pedersen [aut, cre] (ORCID: ), Kohske Takahashi [aut], Claus Wilke [aut] (ORCID: ), Kara Woo [aut] (ORCID: ), Hiroaki Yutani [aut] (ORCID: ), Dewey Dunnington [aut] (ORCID: ), Teun van den Brand [aut] (ORCID: ), Posit, PBC [cph, fnd] (ROR: )", + "Maintainer": "Thomas Lin Pedersen ", + "Repository": "CRAN" + }, + "ggrepel": { + "Package": "ggrepel", + "Version": "0.9.5", + "Source": "Repository", + "Authors@R": "c( person(\"Kamil\", \"Slowikowski\", email = \"kslowikowski@gmail.com\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-2843-6370\")), person(\"Alicia\", \"Schep\", role = \"ctb\", comment = c(ORCID = \"0000-0002-3915-0618\")), person(\"Sean\", \"Hughes\", role = \"ctb\", comment = c(ORCID = \"0000-0002-9409-9405\")), person(\"Trung Kien\", \"Dang\", role = \"ctb\", comment = c(ORCID = \"0000-0001-7562-6495\")), person(\"Saulius\", \"Lukauskas\", role = \"ctb\"), person(\"Jean-Olivier\", \"Irisson\", role = \"ctb\", comment = c(ORCID = \"0000-0003-4920-3880\")), person(\"Zhian N\", \"Kamvar\", role = \"ctb\", comment = c(ORCID = \"0000-0003-1458-7108\")), person(\"Thompson\", \"Ryan\", role = \"ctb\", comment = c(ORCID = \"0000-0002-0450-8181\")), person(\"Dervieux\", \"Christophe\", role = \"ctb\", comment = c(ORCID = \"0000-0003-4474-2498\")), person(\"Yutani\", \"Hiroaki\", role = \"ctb\"), person(\"Pierre\", \"Gramme\", role = \"ctb\"), person(\"Amir Masoud\", \"Abdol\", role = \"ctb\"), person(\"Malcolm\", \"Barrett\", role = \"ctb\", comment = c(ORCID = \"0000-0003-0299-5825\")), person(\"Robrecht\", \"Cannoodt\", role = \"ctb\", comment = c(ORCID = \"0000-0003-3641-729X\")), person(\"Michał\", \"Krassowski\", role = \"ctb\", comment = c(ORCID = \"0000-0002-9638-7785\")), person(\"Michael\", \"Chirico\", role = \"ctb\", comment = c(ORCID = \"0000-0003-0787-087X\")), person(\"Pedro\", \"Aphalo\", role = \"ctb\", comment = c(ORCID = \"0000-0003-3385-972X\")), person(\"Francis\", \"Barton\", role = \"ctb\") )", + "Title": "Automatically Position Non-Overlapping Text Labels with 'ggplot2'", + "Description": "Provides text and label geoms for 'ggplot2' that help to avoid overlapping text labels. Labels repel away from each other and away from the data points.", + "Depends": [ + "R (>= 3.0.0)", + "ggplot2 (>= 2.2.0)" + ], + "Imports": [ + "grid", + "Rcpp", + "rlang (>= 0.3.0)", + "scales (>= 0.5.0)", + "withr (>= 2.5.0)" + ], + "Suggests": [ + "knitr", + "rmarkdown", + "testthat", + "svglite", + "vdiffr", + "gridExtra", + "ggpp", + "patchwork", + "devtools", + "prettydoc", + "ggbeeswarm", + "dplyr", + "magrittr", + "readr", + "stringr" + ], + "VignetteBuilder": "knitr", + "License": "GPL-3 | file LICENSE", + "URL": "https://ggrepel.slowkow.com/, https://github.com/slowkow/ggrepel", + "BugReports": "https://github.com/slowkow/ggrepel/issues", + "RoxygenNote": "7.2.3", + "LinkingTo": [ + "Rcpp" + ], + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Kamil Slowikowski [aut, cre] (), Alicia Schep [ctb] (), Sean Hughes [ctb] (), Trung Kien Dang [ctb] (), Saulius Lukauskas [ctb], Jean-Olivier Irisson [ctb] (), Zhian N Kamvar [ctb] (), Thompson Ryan [ctb] (), Dervieux Christophe [ctb] (), Yutani Hiroaki [ctb], Pierre Gramme [ctb], Amir Masoud Abdol [ctb], Malcolm Barrett [ctb] (), Robrecht Cannoodt [ctb] (), Michał Krassowski [ctb] (), Michael Chirico [ctb] (), Pedro Aphalo [ctb] (), Francis Barton [ctb]", + "Maintainer": "Kamil Slowikowski ", + "Repository": "CRAN" + }, + "ggtext": { + "Package": "ggtext", + "Version": "0.1.2", + "Source": "Repository", + "Type": "Package", + "Title": "Improved Text Rendering Support for 'ggplot2'", + "Authors@R": "c( person( given = \"Claus O.\", family = \"Wilke\", role = c(\"aut\"), email = \"wilke@austin.utexas.edu\", comment = c(ORCID = \"0000-0002-7470-9261\") ), person( given = \"Brenton M.\", family = \"Wiernik\", role = c(\"aut\", \"cre\"), email = \"brenton@wiernik.org\", comment = c(ORCID = \"0000-0001-9560-6336\", Twitter = \"@bmwiernik\") ) )", + "Description": "A 'ggplot2' extension that enables the rendering of complex formatted plot labels (titles, subtitles, facet labels, axis labels, etc.). Text boxes with automatic word wrap are also supported.", + "URL": "https://wilkelab.org/ggtext/", + "BugReports": "https://github.com/wilkelab/ggtext/issues", + "License": "GPL-2", + "Depends": [ + "R (>= 3.5)" + ], + "Imports": [ + "ggplot2 (>= 3.3.0)", + "grid", + "gridtext", + "rlang", + "scales" + ], + "Suggests": [ + "cowplot", + "dplyr", + "glue", + "knitr", + "rmarkdown", + "testthat", + "vdiffr" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.1.1", + "VignetteBuilder": "knitr", + "NeedsCompilation": "no", + "Author": "Claus O. Wilke [aut] (), Brenton M. Wiernik [aut, cre] (, @bmwiernik)", + "Maintainer": "Brenton M. Wiernik ", + "Repository": "CRAN" + }, + "gh": { + "Package": "gh", + "Version": "1.4.1", + "Source": "Repository", + "Title": "'GitHub' 'API'", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"cre\", \"ctb\")), person(\"Jennifer\", \"Bryan\", role = \"aut\"), person(\"Hadley\", \"Wickham\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Minimal client to access the 'GitHub' 'API'.", + "License": "MIT + file LICENSE", + "URL": "https://gh.r-lib.org/, https://github.com/r-lib/gh#readme", + "BugReports": "https://github.com/r-lib/gh/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli (>= 3.0.1)", + "gitcreds", + "glue", + "httr2", + "ini", + "jsonlite", + "lifecycle", + "rlang (>= 1.0.0)" + ], + "Suggests": [ + "covr", + "knitr", + "mockery", + "rmarkdown", + "rprojroot", + "spelling", + "testthat (>= 3.0.0)", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.3.1.9000", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [cre, ctb], Jennifer Bryan [aut], Hadley Wickham [aut], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "gitcreds": { + "Package": "gitcreds", + "Version": "0.1.2", + "Source": "Repository", + "Title": "Query 'git' Credentials from 'R'", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"RStudio\", role = c(\"cph\", \"fnd\")) )", + "Description": "Query, set, delete credentials from the 'git' credential store. Manage 'GitHub' tokens and other 'git' credentials. This package is to be used by other packages that need to authenticate to 'GitHub' and/or other 'git' repositories.", + "License": "MIT + file LICENSE", + "URL": "https://gitcreds.r-lib.org/, https://github.com/r-lib/gitcreds", + "BugReports": "https://github.com/r-lib/gitcreds/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Suggests": [ + "codetools", + "covr", + "knitr", + "mockery", + "oskeyring", + "rmarkdown", + "testthat (>= 3.0.0)", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.1.9000", + "SystemRequirements": "git", + "Config/testthat/edition": "3", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre], RStudio [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "glue": { + "Package": "glue", + "Version": "1.8.0", + "Source": "Repository", + "Title": "Interpreted String Literals", + "Authors@R": "c( person(\"Jim\", \"Hester\", role = \"aut\", comment = c(ORCID = \"0000-0002-2739-7082\")), person(\"Jennifer\", \"Bryan\", , \"jenny@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-6983-2759\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "An implementation of interpreted string literals, inspired by Python's Literal String Interpolation and Docstrings and Julia's Triple-Quoted String Literals .", + "License": "MIT + file LICENSE", + "URL": "https://glue.tidyverse.org/, https://github.com/tidyverse/glue", + "BugReports": "https://github.com/tidyverse/glue/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "methods" + ], + "Suggests": [ + "crayon", + "DBI (>= 1.2.0)", + "dplyr", + "knitr", + "magrittr", + "rlang", + "rmarkdown", + "RSQLite", + "testthat (>= 3.2.0)", + "vctrs (>= 0.3.0)", + "waldo (>= 0.5.3)", + "withr" + ], + "VignetteBuilder": "knitr", + "ByteCompile": "true", + "Config/Needs/website": "bench, forcats, ggbeeswarm, ggplot2, R.utils, rprintf, tidyr, tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "yes", + "Author": "Jim Hester [aut] (), Jennifer Bryan [aut, cre] (), Posit Software, PBC [cph, fnd]", + "Maintainer": "Jennifer Bryan ", + "Repository": "CRAN" + }, + "gms": { + "Package": "gms", + "Version": "0.33.6", + "Source": "Repository", + "Type": "Package", + "Title": "'GAMS' Modularization Support Package", + "Date": "2025-07-15", + "Authors@R": "c(person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-4309-6431\"), role = c(\"aut\",\"cre\")), person(\"David\", \"Klein\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Anastasis\", \"Giannousakis\", role = \"aut\"), person(\"Felicitas\", \"Beier\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Johannes\", \"Koch\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Lavinia\", \"Baumstark\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Mika\", \"Pflüger\", role = \"aut\"), person(\"Oliver\", \"Richters\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"))", + "Description": "A collection of tools to create, use and maintain modularized model code written in the modeling language 'GAMS' (). Out-of-the-box 'GAMS' does not come with support for modularized model code. This package provides the tools necessary to convert a standard 'GAMS' model to a modularized one by introducing a modularized code structure together with a naming convention which emulates local environments. In addition, this package provides tools to monitor the compliance of the model code with modular coding guidelines.", + "Imports": [ + "dplyr", + "rlang", + "stringr", + "withr", + "yaml", + "filelock", + "stats" + ], + "Suggests": [ + "covr", + "curl", + "magclass", + "qgraph", + "testthat", + "callr" + ], + "URL": "https://github.com/pik-piam/gms, https://doi.org/10.5281/zenodo.4390032", + "BugReports": "https://github.com/pik-piam/gms/issues", + "License": "BSD_2_clause + file LICENSE", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Config/Keywords": "tool", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/gms", + "RemoteRef": "HEAD", + "RemoteSha": "1df85e4c6301429c31bf81ec655d2f9c189143e0", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre] (Potsdam Institute for Climate Impact Research, ), David Klein [aut] (Potsdam Institute for Climate Impact Research), Anastasis Giannousakis [aut], Felicitas Beier [aut] (Potsdam Institute for Climate Impact Research), Johannes Koch [aut] (Potsdam Institute for Climate Impact Research), Lavinia Baumstark [aut] (Potsdam Institute for Climate Impact Research), Mika Pflüger [aut], Oliver Richters [aut] (Potsdam Institute for Climate Impact Research)", + "Maintainer": "Jan Philipp Dietrich " + }, + "goftest": { + "Package": "goftest", + "Version": "1.2-3", + "Source": "Repository", + "Type": "Package", + "Title": "Classical Goodness-of-Fit Tests for Univariate Distributions", + "Date": "2021-10-07", + "Authors@R": "c(person(\"Julian\", \"Faraway\", role = \"aut\"), person(\"George\", \"Marsaglia\", role = \"aut\"), person(\"John\", \"Marsaglia\", role = \"aut\"), person(\"Adrian\", \"Baddeley\", role = c(\"aut\", \"cre\"), email = \"Adrian.Baddeley@curtin.edu.au\"))", + "Depends": [ + "R (>= 3.3)" + ], + "Imports": [ + "stats" + ], + "Description": "Cramer-Von Mises and Anderson-Darling tests of goodness-of-fit for continuous univariate distributions, using efficient algorithms.", + "URL": "https://github.com/baddstats/goftest", + "BugReports": "https://github.com/baddstats/goftest/issues", + "License": "GPL (>= 2)", + "NeedsCompilation": "yes", + "Author": "Julian Faraway [aut], George Marsaglia [aut], John Marsaglia [aut], Adrian Baddeley [aut, cre]", + "Maintainer": "Adrian Baddeley ", + "Repository": "CRAN" + }, + "goxygen": { + "Package": "goxygen", + "Version": "1.4.6", + "Source": "Repository", + "Type": "Package", + "Title": "In-Code Documentation for 'GAMS'", + "Date": "2025-04-10", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Kristine\", \"Karstens\", , \"karstens@pik-potsdam.de\", role = \"aut\"), person(\"David\", \"Klein\", , \"dklein@pik-potsdam.de\", role = \"aut\"), person(\"Lavinia\", \"Baumstark\", , \"lavinia@pik-potsdam.de\", role = \"aut\"), person(\"Falk\", \"Benke\", , \"benke@pik-potsdam.de\", role = \"aut\") )", + "Description": "A collection of tools which extract a model documentation from GAMS code and comments. In order to use the package you need to install pandoc first (see pandoc.org).", + "License": "BSD_2_clause + file LICENSE", + "URL": "https://github.com/pik-piam/goxygen, https://doi.org/10.5281/zenodo.1411404", + "BugReports": "https://github.com/pik-piam/goxygen/issues", + "Imports": [ + "citation", + "gms (>= 0.26.3)", + "pander", + "stringi", + "withr", + "yaml" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown", + "testthat" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "SystemRequirements": "pandoc", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/goxygen", + "RemoteRef": "HEAD", + "RemoteSha": "00c0b83aaa33f21ec6882314d7a3751bede3d10b", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre], Kristine Karstens [aut], David Klein [aut], Lavinia Baumstark [aut], Falk Benke [aut]", + "Maintainer": "Jan Philipp Dietrich " + }, + "gridExtra": { + "Package": "gridExtra", + "Version": "2.3", + "Source": "Repository", + "Authors@R": "c(person(\"Baptiste\", \"Auguie\", email = \"baptiste.auguie@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Anton\", \"Antonov\", email = \"tonytonov@gmail.com\", role = c(\"ctb\")))", + "License": "GPL (>= 2)", + "Title": "Miscellaneous Functions for \"Grid\" Graphics", + "Type": "Package", + "Description": "Provides a number of user-level functions to work with \"grid\" graphics, notably to arrange multiple grid-based plots on a page, and draw tables.", + "VignetteBuilder": "knitr", + "Imports": [ + "gtable", + "grid", + "grDevices", + "graphics", + "utils" + ], + "Suggests": [ + "ggplot2", + "egg", + "lattice", + "knitr", + "testthat" + ], + "RoxygenNote": "6.0.1", + "NeedsCompilation": "no", + "Author": "Baptiste Auguie [aut, cre], Anton Antonov [ctb]", + "Maintainer": "Baptiste Auguie ", + "Repository": "CRAN" + }, + "gridtext": { + "Package": "gridtext", + "Version": "0.1.5", + "Source": "Repository", + "Type": "Package", + "Title": "Improved Text Rendering Support for 'Grid' Graphics", + "Authors@R": "c( person( given = \"Claus O.\", family = \"Wilke\", role = c(\"aut\"), email = \"wilke@austin.utexas.edu\", comment = c(ORCID = \"0000-0002-7470-9261\") ), person( given = \"Brenton M.\", family = \"Wiernik\", role = c(\"aut\", \"cre\"), email = \"brenton@wiernik.org\", comment = c(ORCID = \"0000-0001-9560-6336\", Twitter = \"@bmwiernik\") ) )", + "Description": "Provides support for rendering of formatted text using 'grid' graphics. Text can be formatted via a minimal subset of 'Markdown', 'HTML', and inline 'CSS' directives, and it can be rendered both with and without word wrap.", + "URL": "https://wilkelab.org/gridtext/", + "BugReports": "https://github.com/wilkelab/gridtext/issues", + "License": "MIT + file LICENSE", + "Depends": [ + "R (>= 3.5)" + ], + "Imports": [ + "curl", + "grid", + "grDevices", + "markdown", + "rlang", + "Rcpp", + "png", + "jpeg", + "stringr", + "xml2" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown", + "testthat", + "vdiffr" + ], + "LinkingTo": [ + "Rcpp" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.1.1", + "SystemRequirements": "C++11", + "NeedsCompilation": "yes", + "Author": "Claus O. Wilke [aut] (), Brenton M. Wiernik [aut, cre] (, @bmwiernik)", + "Maintainer": "Brenton M. Wiernik ", + "Repository": "CRAN" + }, + "gstat": { + "Package": "gstat", + "Version": "2.1-3", + "Source": "Repository", + "Title": "Spatial and Spatio-Temporal Geostatistical Modelling, Prediction and Simulation", + "Authors@R": "c(person(given = \"Edzer\", family = \"Pebesma\", role = c(\"aut\", \"cre\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(\"Benedikt\", \"Graeler\", role = \"aut\"))", + "Description": "Variogram modelling; simple, ordinary and universal point or block (co)kriging; spatio-temporal kriging; sequential Gaussian or indicator (co)simulation; variogram and variogram map plotting utility functions; supports sf and stars.", + "Depends": [ + "R (>= 2.10)" + ], + "Imports": [ + "utils", + "stats", + "graphics", + "methods", + "lattice", + "sp (>= 0.9-72)", + "zoo", + "sf (>= 0.7-2)", + "sftime", + "spacetime (>= 1.2-8)", + "stars", + "FNN" + ], + "Suggests": [ + "fields", + "maps", + "mapdata", + "xts", + "raster", + "future", + "future.apply", + "RColorBrewer", + "geoR", + "ggplot2" + ], + "License": "GPL (>= 2.0)", + "URL": "https://github.com/r-spatial/gstat/, https://r-spatial.github.io/gstat/", + "Encoding": "UTF-8", + "BugReports": "https://github.com/r-spatial/gstat/issues/", + "NeedsCompilation": "yes", + "RoxygenNote": "6.1.1", + "Author": "Edzer Pebesma [aut, cre] (), Benedikt Graeler [aut]", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "gtable": { + "Package": "gtable", + "Version": "0.3.6", + "Source": "Repository", + "Title": "Arrange 'Grobs' in Tables", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Thomas Lin\", \"Pedersen\", , \"thomas.pedersen@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Tools to make it easier to work with \"tables\" of 'grobs'. The 'gtable' package defines a 'gtable' grob class that specifies a grid along with a list of grobs and their placement in the grid. Further the package makes it easy to manipulate and combine 'gtable' objects so that complex compositions can be built up sequentially.", + "License": "MIT + file LICENSE", + "URL": "https://gtable.r-lib.org, https://github.com/r-lib/gtable", + "BugReports": "https://github.com/r-lib/gtable/issues", + "Depends": [ + "R (>= 4.0)" + ], + "Imports": [ + "cli", + "glue", + "grid", + "lifecycle", + "rlang (>= 1.1.0)", + "stats" + ], + "Suggests": [ + "covr", + "ggplot2", + "knitr", + "profvis", + "rmarkdown", + "testthat (>= 3.0.0)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/usethis/last-upkeep": "2024-10-25", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut], Thomas Lin Pedersen [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Thomas Lin Pedersen ", + "Repository": "CRAN" + }, + "hdf5r": { + "Package": "hdf5r", + "Version": "1.3.11", + "Source": "Repository", + "Type": "Package", + "Title": "Interface to the 'HDF5' Binary Data Format", + "Authors@R": "c( person(\"Holger\", \"Hoefling\", email = \"hhoeflin@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Mario\", \"Annau\", email = \"mario.annau@gmail.com\", role = \"aut\"), person(\"Novartis Institute for BioMedical Research (NIBR)\", role = \"cph\") )", + "Description": "'HDF5' is a data model, library and file format for storing and managing large amounts of data. This package provides a nearly feature complete, object oriented wrapper for the 'HDF5' API using R6 classes. Additionally, functionality is added so that 'HDF5' objects behave very similar to their corresponding R counterparts.", + "URL": "https://hhoeflin.github.io/hdf5r/, https://github.com/hhoeflin/hdf5r/", + "BugReports": "https://github.com/hhoeflin/hdf5r/issues", + "License": "Apache License 2.0 | file LICENSE", + "Copyright": "For the hdf5r package: Novartis Institute for BioMedical Research Inc. For HDF5: see the HDF5_COPYRIGHTS file.", + "LazyLoad": "true", + "Depends": [ + "R (>= 3.2.2)", + "methods" + ], + "Imports": [ + "R6", + "bit64", + "utils" + ], + "Suggests": [ + "testthat", + "knitr", + "rmarkdown", + "nycflights13", + "reshape2", + "formatR" + ], + "SystemRequirements": "HDF5 (>= 1.8.13)", + "VignetteBuilder": "knitr", + "NeedsCompilation": "yes", + "RoxygenNote": "6.1.1.9000", + "Collate": "'Common_functions.R' 'Compound.R' 'H5constants.R' 'Helper_functions.R' 'Misc.R' 'R6Classes.R' 'R6Classes_H5A.R' 'R6Classes_H5D.R' 'R6Classes_H5File.R' 'R6Classes_H5Group.R' 'R6Classes_H5P.R' 'R6Classes_H5R.R' 'R6Classes_H5S.R' 'R6Classes_H5T.R' 'adapt_during_onLoad.R' 'convert.R' 'factor_ext.R' 'globalVariables.R' 'h5errorHandling.R' 'h5wrapper.R' 'hdf5r.R' 'high_level_UI.R' 'open_objs.R' 'zzz.R'", + "Author": "Holger Hoefling [aut, cre], Mario Annau [aut], Novartis Institute for BioMedical Research (NIBR) [cph]", + "Maintainer": "Holger Hoefling ", + "Repository": "CRAN" + }, + "here": { + "Package": "here", + "Version": "1.0.1", + "Source": "Repository", + "Title": "A Simpler Way to Find Your Files", + "Date": "2020-12-13", + "Authors@R": "c(person(given = \"Kirill\", family = \"M\\u00fcller\", role = c(\"aut\", \"cre\"), email = \"krlmlr+r@mailbox.org\", comment = c(ORCID = \"0000-0002-1416-3412\")), person(given = \"Jennifer\", family = \"Bryan\", role = \"ctb\", email = \"jenny@rstudio.com\", comment = c(ORCID = \"0000-0002-6983-2759\")))", + "Description": "Constructs paths to your project's files. Declare the relative path of a file within your project with 'i_am()'. Use the 'here()' function as a drop-in replacement for 'file.path()', it will always locate the files relative to your project root.", + "License": "MIT + file LICENSE", + "URL": "https://here.r-lib.org/, https://github.com/r-lib/here", + "BugReports": "https://github.com/r-lib/here/issues", + "Imports": [ + "rprojroot (>= 2.0.2)" + ], + "Suggests": [ + "conflicted", + "covr", + "fs", + "knitr", + "palmerpenguins", + "plyr", + "readr", + "rlang", + "rmarkdown", + "testthat", + "uuid", + "withr" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.1.1.9000", + "Config/testthat/edition": "3", + "NeedsCompilation": "no", + "Author": "Kirill Müller [aut, cre] (), Jennifer Bryan [ctb] ()", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "highr": { + "Package": "highr", + "Version": "0.11", + "Source": "Repository", + "Type": "Package", + "Title": "Syntax Highlighting for R Source Code", + "Authors@R": "c( person(\"Yihui\", \"Xie\", role = c(\"aut\", \"cre\"), email = \"xie@yihui.name\", comment = c(ORCID = \"0000-0003-0645-5666\")), person(\"Yixuan\", \"Qiu\", role = \"aut\"), person(\"Christopher\", \"Gandrud\", role = \"ctb\"), person(\"Qiang\", \"Li\", role = \"ctb\") )", + "Description": "Provides syntax highlighting for R source code. Currently it supports LaTeX and HTML output. Source code of other languages is supported via Andre Simon's highlight package ().", + "Depends": [ + "R (>= 3.3.0)" + ], + "Imports": [ + "xfun (>= 0.18)" + ], + "Suggests": [ + "knitr", + "markdown", + "testit" + ], + "License": "GPL", + "URL": "https://github.com/yihui/highr", + "BugReports": "https://github.com/yihui/highr/issues", + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "no", + "Author": "Yihui Xie [aut, cre] (), Yixuan Qiu [aut], Christopher Gandrud [ctb], Qiang Li [ctb]", + "Maintainer": "Yihui Xie ", + "Repository": "CRAN" + }, + "hms": { + "Package": "hms", + "Version": "1.1.3", + "Source": "Repository", + "Title": "Pretty Time of Day", + "Date": "2023-03-21", + "Authors@R": "c( person(\"Kirill\", \"Müller\", role = c(\"aut\", \"cre\"), email = \"kirill@cynkra.com\", comment = c(ORCID = \"0000-0002-1416-3412\")), person(\"R Consortium\", role = \"fnd\"), person(\"RStudio\", role = \"fnd\") )", + "Description": "Implements an S3 class for storing and formatting time-of-day values, based on the 'difftime' class.", + "Imports": [ + "lifecycle", + "methods", + "pkgconfig", + "rlang (>= 1.0.2)", + "vctrs (>= 0.3.8)" + ], + "Suggests": [ + "crayon", + "lubridate", + "pillar (>= 1.1.0)", + "testthat (>= 3.0.0)" + ], + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "URL": "https://hms.tidyverse.org/, https://github.com/tidyverse/hms", + "BugReports": "https://github.com/tidyverse/hms/issues", + "RoxygenNote": "7.2.3", + "Config/testthat/edition": "3", + "Config/autostyle/scope": "line_breaks", + "Config/autostyle/strict": "false", + "Config/Needs/website": "tidyverse/tidytemplate", + "NeedsCompilation": "no", + "Author": "Kirill Müller [aut, cre] (), R Consortium [fnd], RStudio [fnd]", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "htmlTable": { + "Package": "htmlTable", + "Version": "2.4.2", + "Source": "Repository", + "Title": "Advanced Tables for Markdown/HTML", + "Authors@R": "c( person(\"Max\", \"Gordon\", email = \"max@gforge.se\", role = c(\"aut\", \"cre\")), person(\"Stephen\", \"Gragg\", role=c(\"aut\")), person(\"Peter\", \"Konings\", role=c(\"aut\")))", + "Maintainer": "Max Gordon ", + "Description": "Tables with state-of-the-art layout elements such as row spanners, column spanners, table spanners, zebra striping, and more. While allowing advanced layout, the underlying css-structure is simple in order to maximize compatibility with common word processors. The package also contains a few text formatting functions that help outputting text compatible with HTML/LaTeX.", + "License": "GPL (>= 3)", + "URL": "https://gforge.se/packages/", + "BugReports": "https://github.com/gforge/htmlTable/issues", + "Biarch": "yes", + "Depends": [ + "R (>= 4.1)" + ], + "Imports": [ + "stringr", + "knitr (>= 1.6)", + "magrittr (>= 1.5)", + "methods", + "checkmate", + "htmlwidgets", + "htmltools", + "rstudioapi (>= 0.6)" + ], + "Suggests": [ + "testthat", + "XML", + "xml2", + "Hmisc", + "rmarkdown", + "chron", + "lubridate", + "tibble", + "purrr", + "tidyselect", + "glue", + "rlang", + "tidyr (>= 0.7.2)", + "dplyr (>= 0.7.4)" + ], + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "VignetteBuilder": "knitr", + "RoxygenNote": "7.2.2", + "Author": "Max Gordon [aut, cre], Stephen Gragg [aut], Peter Konings [aut]", + "Repository": "CRAN" + }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.8.1", + "Source": "Repository", + "Type": "Package", + "Title": "Tools for HTML", + "Authors@R": "c( person(\"Joe\", \"Cheng\", , \"joe@posit.co\", role = \"aut\"), person(\"Carson\", \"Sievert\", , \"carson@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Barret\", \"Schloerke\", , \"barret@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0001-9986-114X\")), person(\"Winston\", \"Chang\", , \"winston@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0002-1576-2126\")), person(\"Yihui\", \"Xie\", , \"yihui@posit.co\", role = \"aut\"), person(\"Jeff\", \"Allen\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Tools for HTML generation and output.", + "License": "GPL (>= 2)", + "URL": "https://github.com/rstudio/htmltools, https://rstudio.github.io/htmltools/", + "BugReports": "https://github.com/rstudio/htmltools/issues", + "Depends": [ + "R (>= 2.14.1)" + ], + "Imports": [ + "base64enc", + "digest", + "fastmap (>= 1.1.0)", + "grDevices", + "rlang (>= 1.0.0)", + "utils" + ], + "Suggests": [ + "Cairo", + "markdown", + "ragg", + "shiny", + "testthat", + "withr" + ], + "Enhances": [ + "knitr" + ], + "Config/Needs/check": "knitr", + "Config/Needs/website": "rstudio/quillt, bench", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "Collate": "'colors.R' 'fill.R' 'html_dependency.R' 'html_escape.R' 'html_print.R' 'htmltools-package.R' 'images.R' 'known_tags.R' 'selector.R' 'staticimports.R' 'tag_query.R' 'utils.R' 'tags.R' 'template.R'", + "NeedsCompilation": "yes", + "Author": "Joe Cheng [aut], Carson Sievert [aut, cre] (), Barret Schloerke [aut] (), Winston Chang [aut] (), Yihui Xie [aut], Jeff Allen [aut], Posit Software, PBC [cph, fnd]", + "Maintainer": "Carson Sievert ", + "Repository": "CRAN" + }, + "htmlwidgets": { + "Package": "htmlwidgets", + "Version": "1.6.4", + "Source": "Repository", + "Type": "Package", + "Title": "HTML Widgets for R", + "Authors@R": "c( person(\"Ramnath\", \"Vaidyanathan\", role = c(\"aut\", \"cph\")), person(\"Yihui\", \"Xie\", role = \"aut\"), person(\"JJ\", \"Allaire\", role = \"aut\"), person(\"Joe\", \"Cheng\", , \"joe@posit.co\", role = \"aut\"), person(\"Carson\", \"Sievert\", , \"carson@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Kenton\", \"Russell\", role = c(\"aut\", \"cph\")), person(\"Ellis\", \"Hughes\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A framework for creating HTML widgets that render in various contexts including the R console, 'R Markdown' documents, and 'Shiny' web applications.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/ramnathv/htmlwidgets", + "BugReports": "https://github.com/ramnathv/htmlwidgets/issues", + "Imports": [ + "grDevices", + "htmltools (>= 0.5.7)", + "jsonlite (>= 0.9.16)", + "knitr (>= 1.8)", + "rmarkdown", + "yaml" + ], + "Suggests": [ + "testthat" + ], + "Enhances": [ + "shiny (>= 1.1)" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Ramnath Vaidyanathan [aut, cph], Yihui Xie [aut], JJ Allaire [aut], Joe Cheng [aut], Carson Sievert [aut, cre] (), Kenton Russell [aut, cph], Ellis Hughes [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Carson Sievert ", + "Repository": "CRAN" + }, + "httpuv": { + "Package": "httpuv", + "Version": "1.6.15", + "Source": "Repository", + "Type": "Package", + "Title": "HTTP and WebSocket Server Library", + "Authors@R": "c( person(\"Joe\", \"Cheng\", , \"joe@posit.co\", role = \"aut\"), person(\"Winston\", \"Chang\", , \"winston@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit, PBC\", \"fnd\", role = \"cph\"), person(\"Hector\", \"Corrada Bravo\", role = \"ctb\"), person(\"Jeroen\", \"Ooms\", role = \"ctb\"), person(\"Andrzej\", \"Krzemienski\", role = \"cph\", comment = \"optional.hpp\"), person(\"libuv project contributors\", role = \"cph\", comment = \"libuv library, see src/libuv/AUTHORS file\"), person(\"Joyent, Inc. and other Node contributors\", role = \"cph\", comment = \"libuv library, see src/libuv/AUTHORS file; and http-parser library, see src/http-parser/AUTHORS file\"), person(\"Niels\", \"Provos\", role = \"cph\", comment = \"libuv subcomponent: tree.h\"), person(\"Internet Systems Consortium, Inc.\", role = \"cph\", comment = \"libuv subcomponent: inet_pton and inet_ntop, contained in src/libuv/src/inet.c\"), person(\"Alexander\", \"Chemeris\", role = \"cph\", comment = \"libuv subcomponent: stdint-msvc2008.h (from msinttypes)\"), person(\"Google, Inc.\", role = \"cph\", comment = \"libuv subcomponent: pthread-fixes.c\"), person(\"Sony Mobile Communcations AB\", role = \"cph\", comment = \"libuv subcomponent: pthread-fixes.c\"), person(\"Berkeley Software Design Inc.\", role = \"cph\", comment = \"libuv subcomponent: android-ifaddrs.h, android-ifaddrs.c\"), person(\"Kenneth\", \"MacKay\", role = \"cph\", comment = \"libuv subcomponent: android-ifaddrs.h, android-ifaddrs.c\"), person(\"Emergya (Cloud4all, FP7/2007-2013, grant agreement no 289016)\", role = \"cph\", comment = \"libuv subcomponent: android-ifaddrs.h, android-ifaddrs.c\"), person(\"Steve\", \"Reid\", role = \"aut\", comment = \"SHA-1 implementation\"), person(\"James\", \"Brown\", role = \"aut\", comment = \"SHA-1 implementation\"), person(\"Bob\", \"Trower\", role = \"aut\", comment = \"base64 implementation\"), person(\"Alexander\", \"Peslyak\", role = \"aut\", comment = \"MD5 implementation\"), person(\"Trantor Standard Systems\", role = \"cph\", comment = \"base64 implementation\"), person(\"Igor\", \"Sysoev\", role = \"cph\", comment = \"http-parser\") )", + "Description": "Provides low-level socket and protocol support for handling HTTP and WebSocket requests directly from within R. It is primarily intended as a building block for other packages, rather than making it particularly easy to create complete web applications using httpuv alone. httpuv is built on top of the libuv and http-parser C libraries, both of which were developed by Joyent, Inc. (See LICENSE file for libuv and http-parser license information.)", + "License": "GPL (>= 2) | file LICENSE", + "URL": "https://github.com/rstudio/httpuv", + "BugReports": "https://github.com/rstudio/httpuv/issues", + "Depends": [ + "R (>= 2.15.1)" + ], + "Imports": [ + "later (>= 0.8.0)", + "promises", + "R6", + "Rcpp (>= 1.0.7)", + "utils" + ], + "Suggests": [ + "callr", + "curl", + "testthat", + "websocket" + ], + "LinkingTo": [ + "later", + "Rcpp" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "SystemRequirements": "GNU make, zlib", + "Collate": "'RcppExports.R' 'httpuv.R' 'random_port.R' 'server.R' 'staticServer.R' 'static_paths.R' 'utils.R'", + "NeedsCompilation": "yes", + "Author": "Joe Cheng [aut], Winston Chang [aut, cre], Posit, PBC fnd [cph], Hector Corrada Bravo [ctb], Jeroen Ooms [ctb], Andrzej Krzemienski [cph] (optional.hpp), libuv project contributors [cph] (libuv library, see src/libuv/AUTHORS file), Joyent, Inc. and other Node contributors [cph] (libuv library, see src/libuv/AUTHORS file; and http-parser library, see src/http-parser/AUTHORS file), Niels Provos [cph] (libuv subcomponent: tree.h), Internet Systems Consortium, Inc. [cph] (libuv subcomponent: inet_pton and inet_ntop, contained in src/libuv/src/inet.c), Alexander Chemeris [cph] (libuv subcomponent: stdint-msvc2008.h (from msinttypes)), Google, Inc. [cph] (libuv subcomponent: pthread-fixes.c), Sony Mobile Communcations AB [cph] (libuv subcomponent: pthread-fixes.c), Berkeley Software Design Inc. [cph] (libuv subcomponent: android-ifaddrs.h, android-ifaddrs.c), Kenneth MacKay [cph] (libuv subcomponent: android-ifaddrs.h, android-ifaddrs.c), Emergya (Cloud4all, FP7/2007-2013, grant agreement no 289016) [cph] (libuv subcomponent: android-ifaddrs.h, android-ifaddrs.c), Steve Reid [aut] (SHA-1 implementation), James Brown [aut] (SHA-1 implementation), Bob Trower [aut] (base64 implementation), Alexander Peslyak [aut] (MD5 implementation), Trantor Standard Systems [cph] (base64 implementation), Igor Sysoev [cph] (http-parser)", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "httr": { + "Package": "httr", + "Version": "1.4.7", + "Source": "Repository", + "Title": "Tools for Working with URLs and HTTP", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Useful tools for working with HTTP organised by HTTP verbs (GET(), POST(), etc). Configuration functions make it easy to control additional request components (authenticate(), add_headers() and so on).", + "License": "MIT + file LICENSE", + "URL": "https://httr.r-lib.org/, https://github.com/r-lib/httr", + "BugReports": "https://github.com/r-lib/httr/issues", + "Depends": [ + "R (>= 3.5)" + ], + "Imports": [ + "curl (>= 5.0.2)", + "jsonlite", + "mime", + "openssl (>= 0.8)", + "R6" + ], + "Suggests": [ + "covr", + "httpuv", + "jpeg", + "knitr", + "png", + "readr", + "rmarkdown", + "testthat (>= 0.8.0)", + "xml2" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], Posit, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "httr2": { + "Package": "httr2", + "Version": "1.0.1", + "Source": "Repository", + "Title": "Perform HTTP Requests and Process the Responses", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", role = c(\"aut\", \"cre\")), person(\"RStudio\", role = c(\"cph\", \"fnd\")), person(\"Maximilian\", \"Girlich\", role = \"ctb\") )", + "Description": "Tools for creating and modifying HTTP requests, then performing them and processing the results. 'httr2' is a modern re-imagining of 'httr' that uses a pipe-based interface and solves more of the problems that API wrapping packages face.", + "License": "MIT + file LICENSE", + "URL": "https://httr2.r-lib.org, https://github.com/r-lib/httr2", + "BugReports": "https://github.com/r-lib/httr2/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli (>= 3.0.0)", + "curl (>= 5.1.0)", + "glue", + "lifecycle", + "magrittr", + "openssl", + "R6", + "rappdirs", + "rlang (>= 1.1.0)", + "vctrs (>= 0.6.3)", + "withr" + ], + "Suggests": [ + "askpass", + "bench", + "clipr", + "covr", + "docopt", + "httpuv", + "jose", + "jsonlite", + "knitr", + "rmarkdown", + "testthat (>= 3.1.8)", + "tibble", + "webfakes", + "xml2" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], RStudio [cph, fnd], Maximilian Girlich [ctb]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "hypergeo": { + "Package": "hypergeo", + "Version": "1.2-13", + "Source": "Repository", + "Title": "The Gauss Hypergeometric Function", + "Author": "Robin K. S. Hankin", + "Depends": [ + "R (>= 3.1.0)" + ], + "Imports": [ + "elliptic (>= 1.3-5)", + "contfrac (>= 1.1-9)", + "deSolve" + ], + "Description": "The Gaussian hypergeometric function for complex numbers.", + "Maintainer": "Robin K. S. Hankin ", + "License": "GPL-2", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "iamc": { + "Package": "iamc", + "Version": "0.29.8", + "Source": "Repository", + "Type": "Package", + "Title": "IAMC Tools", + "Date": "2023-07-06", + "Authors@R": "c(person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", role = c(\"aut\",\"cre\")), person(\"Cornelia\", \"Auer\", role = \"aut\"), person(\"Anastasis\", \"Giannousakis\", role = \"aut\"), person(\"Christoph\", \"Bertram\", role = \"aut\"), person(\"Falk\", \"Benke\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", role = \"aut\"), person(\"Lavinia\", \"Baumstark\", role = \"aut\"))", + "Description": "A collection of R tools provided by the Integrated Assessment Modeling Consortium (IAMC) for data analysis and diagnostics.", + "License": "MIT + file LICENSE", + "Depends": [ + "R(>= 2.10.0)" + ], + "Imports": [ + "quitte(>= 0.3066)", + "magclass(>= 4.40)", + "mip(>= 0.97)", + "lusweave", + "dplyr", + "utils", + "methods", + "reshape2", + "readxl", + "writexl" + ], + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "Suggests": [ + "covr", + "knitr", + "rmarkdown" + ], + "VignetteBuilder": "knitr", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/IAMconsortium/iamc", + "RemoteRef": "HEAD", + "RemoteSha": "c418a3d89b0a2fbf8b095d7653ce108b19fb2b09", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre], Cornelia Auer [aut], Anastasis Giannousakis [aut], Christoph Bertram [aut], Falk Benke [aut], Florian Humpenoeder [aut], Lavinia Baumstark [aut]", + "Maintainer": "Jan Philipp Dietrich " + }, + "igraph": { + "Package": "igraph", + "Version": "2.1.1", + "Source": "Repository", + "Title": "Network Analysis and Visualization", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = \"aut\", comment = c(ORCID = \"0000-0001-7098-9676\")), person(\"Tamás\", \"Nepusz\", , \"ntamas@gmail.com\", role = \"aut\", comment = c(ORCID = \"0000-0002-1451-338X\")), person(\"Vincent\", \"Traag\", role = \"aut\", comment = c(ORCID = \"0000-0003-3170-3879\")), person(\"Szabolcs\", \"Horvát\", , \"szhorvat@gmail.com\", role = \"aut\", comment = c(ORCID = \"0000-0002-3100-523X\")), person(\"Fabio\", \"Zanini\", , \"fabio.zanini@unsw.edu.au\", role = \"aut\", comment = c(ORCID = \"0000-0001-7097-8539\")), person(\"Daniel\", \"Noom\", role = \"aut\"), person(\"Kirill\", \"Müller\", , \"kirill@cynkra.com\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-1416-3412\")), person(\"Maëlle\", \"Salmon\", role = \"ctb\"), person(\"Michael\", \"Antonov\", role = \"ctb\"), person(\"Chan Zuckerberg Initiative\", role = \"fnd\") )", + "Description": "Routines for simple graphs and network analysis. It can handle large graphs very well and provides functions for generating random and regular graphs, graph visualization, centrality methods and much more.", + "License": "GPL (>= 2)", + "URL": "https://r.igraph.org/, https://igraph.org/, https://igraph.discourse.group/", + "BugReports": "https://github.com/igraph/rigraph/issues", + "Depends": [ + "methods", + "R (>= 3.5.0)" + ], + "Imports": [ + "cli", + "graphics", + "grDevices", + "lifecycle", + "magrittr", + "Matrix", + "pkgconfig (>= 2.0.0)", + "rlang", + "stats", + "utils", + "vctrs" + ], + "Suggests": [ + "ape (>= 5.7-0.1)", + "callr", + "decor", + "digest", + "igraphdata", + "knitr", + "rgl", + "rmarkdown", + "scales", + "stats4", + "tcltk", + "testthat", + "vdiffr", + "withr" + ], + "Enhances": [ + "graph" + ], + "LinkingTo": [ + "cpp11 (>= 0.5.0)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/build": "roxygen2, devtools, irlba, pkgconfig, igraph/igraph.r2cdocs, moodymudskipper/devtag", + "Config/Needs/coverage": "covr", + "Config/Needs/website": "readr", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "vs-es, scan, vs-operators, weakref, watts.strogatz.game", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "SystemRequirements": "libxml2 (optional), glpk (>= 4.57, optional)", + "NeedsCompilation": "yes", + "Author": "Gábor Csárdi [aut] (), Tamás Nepusz [aut] (), Vincent Traag [aut] (), Szabolcs Horvát [aut] (), Fabio Zanini [aut] (), Daniel Noom [aut], Kirill Müller [aut, cre] (), Maëlle Salmon [ctb], Michael Antonov [ctb], Chan Zuckerberg Initiative [fnd]", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "ini": { + "Package": "ini", + "Version": "0.3.1", + "Source": "Repository", + "Type": "Package", + "Title": "Read and Write '.ini' Files", + "Date": "2018-05-19", + "Author": "David Valentim Dias", + "Maintainer": "David Valentim Dias ", + "Description": "Parse simple '.ini' configuration files to an structured list. Users can manipulate this resulting list with lapply() functions. This same structured list can be used to write back to file after modifications.", + "License": "GPL-3", + "URL": "https://github.com/dvdscripter/ini", + "BugReports": "https://github.com/dvdscripter/ini/issues", + "LazyData": "FALSE", + "RoxygenNote": "6.0.1", + "Suggests": [ + "testthat" + ], + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "intervals": { + "Package": "intervals", + "Version": "0.15.5", + "Source": "Repository", + "Type": "Package", + "Title": "Tools for Working with Points and Intervals", + "Authors@R": "c(person(given = \"Richard\", family = \"Bourgon\", role = \"aut\", email = \"bourgon.richard@gene.com\"), person(given = \"Edzer\", family = \"Pebesma\", role = \"cre\", email = \"edzer.pebesma@uni-muenster.de\"))", + "Depends": [ + "R (>= 2.9.0)" + ], + "Imports": [ + "utils", + "graphics", + "methods" + ], + "Description": "Tools for working with and comparing sets of points and intervals.", + "License": "Artistic-2.0", + "LazyLoad": "yes", + "URL": "https://github.com/edzer/intervals", + "NeedsCompilation": "yes", + "Author": "Richard Bourgon [aut], Edzer Pebesma [cre]", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "isoband": { + "Package": "isoband", + "Version": "0.2.7", + "Source": "Repository", + "Title": "Generate Isolines and Isobands from Regularly Spaced Elevation Grids", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Claus O.\", \"Wilke\", , \"wilke@austin.utexas.edu\", role = \"aut\", comment = c(\"Original author\", ORCID = \"0000-0002-7470-9261\")), person(\"Thomas Lin\", \"Pedersen\", , \"thomasp85@gmail.com\", role = \"aut\", comment = c(ORCID = \"0000-0002-5147-4711\")) )", + "Description": "A fast C++ implementation to generate contour lines (isolines) and contour polygons (isobands) from regularly spaced grids containing elevation data.", + "License": "MIT + file LICENSE", + "URL": "https://isoband.r-lib.org", + "BugReports": "https://github.com/r-lib/isoband/issues", + "Imports": [ + "grid", + "utils" + ], + "Suggests": [ + "covr", + "ggplot2", + "knitr", + "magick", + "microbenchmark", + "rmarkdown", + "sf", + "testthat", + "xml2" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "SystemRequirements": "C++11", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre] (), Claus O. Wilke [aut] (Original author, ), Thomas Lin Pedersen [aut] ()", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "iterators": { + "Package": "iterators", + "Version": "1.0.14", + "Source": "Repository", + "Type": "Package", + "Title": "Provides Iterator Construct", + "Authors@R": "c(person(\"Folashade\", \"Daniel\", role=\"cre\", email=\"fdaniel@microsoft.com\"), person(\"Revolution\", \"Analytics\", role=c(\"aut\", \"cph\")), person(\"Steve\", \"Weston\", role=\"aut\"))", + "Description": "Support for iterators, which allow a programmer to traverse through all the elements of a vector, list, or other collection of data.", + "URL": "https://github.com/RevolutionAnalytics/iterators", + "Depends": [ + "R (>= 2.5.0)", + "utils" + ], + "Suggests": [ + "RUnit", + "foreach" + ], + "License": "Apache License (== 2.0)", + "NeedsCompilation": "no", + "Author": "Folashade Daniel [cre], Revolution Analytics [aut, cph], Steve Weston [aut]", + "Maintainer": "Folashade Daniel ", + "Repository": "CRAN" + }, + "jpeg": { + "Package": "jpeg", + "Version": "0.1-10", + "Source": "Repository", + "Title": "Read and write JPEG images", + "Author": "Simon Urbanek ", + "Maintainer": "Simon Urbanek ", + "Depends": [ + "R (>= 2.9.0)" + ], + "Description": "This package provides an easy and simple way to read, write and display bitmap images stored in the JPEG format. It can read and write both files and in-memory raw vectors.", + "License": "GPL-2 | GPL-3", + "SystemRequirements": "libjpeg", + "URL": "https://www.rforge.net/jpeg/", + "BugReports": "https://github.com/s-u/jpeg/issues", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "jquerylib": { + "Package": "jquerylib", + "Version": "0.1.4", + "Source": "Repository", + "Title": "Obtain 'jQuery' as an HTML Dependency Object", + "Authors@R": "c( person(\"Carson\", \"Sievert\", role = c(\"aut\", \"cre\"), email = \"carson@rstudio.com\", comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Joe\", \"Cheng\", role = \"aut\", email = \"joe@rstudio.com\"), person(family = \"RStudio\", role = \"cph\"), person(family = \"jQuery Foundation\", role = \"cph\", comment = \"jQuery library and jQuery UI library\"), person(family = \"jQuery contributors\", role = c(\"ctb\", \"cph\"), comment = \"jQuery library; authors listed in inst/lib/jquery-AUTHORS.txt\") )", + "Description": "Obtain any major version of 'jQuery' () and use it in any webpage generated by 'htmltools' (e.g. 'shiny', 'htmlwidgets', and 'rmarkdown'). Most R users don't need to use this package directly, but other R packages (e.g. 'shiny', 'rmarkdown', etc.) depend on this package to avoid bundling redundant copies of 'jQuery'.", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "Config/testthat/edition": "3", + "RoxygenNote": "7.0.2", + "Imports": [ + "htmltools" + ], + "Suggests": [ + "testthat" + ], + "NeedsCompilation": "no", + "Author": "Carson Sievert [aut, cre] (), Joe Cheng [aut], RStudio [cph], jQuery Foundation [cph] (jQuery library and jQuery UI library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/lib/jquery-AUTHORS.txt)", + "Maintainer": "Carson Sievert ", + "Repository": "CRAN" + }, + "jsonlite": { + "Package": "jsonlite", + "Version": "2.0.0", + "Source": "Repository", + "Title": "A Simple and Robust JSON Parser and Generator for R", + "License": "MIT + file LICENSE", + "Depends": [ + "methods" + ], + "Authors@R": "c( person(\"Jeroen\", \"Ooms\", role = c(\"aut\", \"cre\"), email = \"jeroenooms@gmail.com\", comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"Duncan\", \"Temple Lang\", role = \"ctb\"), person(\"Lloyd\", \"Hilaiel\", role = \"cph\", comment=\"author of bundled libyajl\"))", + "URL": "https://jeroen.r-universe.dev/jsonlite https://arxiv.org/abs/1403.2805", + "BugReports": "https://github.com/jeroen/jsonlite/issues", + "Maintainer": "Jeroen Ooms ", + "VignetteBuilder": "knitr, R.rsp", + "Description": "A reasonably fast JSON parser and generator, optimized for statistical data and the web. Offers simple, flexible tools for working with JSON in R, and is particularly powerful for building pipelines and interacting with a web API. The implementation is based on the mapping described in the vignette (Ooms, 2014). In addition to converting JSON data from/to R objects, 'jsonlite' contains functions to stream, validate, and prettify JSON data. The unit tests included with the package verify that all edge cases are encoded and decoded consistently for use with dynamic data in systems and applications.", + "Suggests": [ + "httr", + "vctrs", + "testthat", + "knitr", + "rmarkdown", + "R.rsp", + "sf" + ], + "RoxygenNote": "7.3.2", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] (), Duncan Temple Lang [ctb], Lloyd Hilaiel [cph] (author of bundled libyajl)", + "Repository": "CRAN" + }, + "knitr": { + "Package": "knitr", + "Version": "1.50", + "Source": "Repository", + "Type": "Package", + "Title": "A General-Purpose Package for Dynamic Report Generation in R", + "Authors@R": "c( person(\"Yihui\", \"Xie\", role = c(\"aut\", \"cre\"), email = \"xie@yihui.name\", comment = c(ORCID = \"0000-0003-0645-5666\", URL = \"https://yihui.org\")), person(\"Abhraneel\", \"Sarma\", role = \"ctb\"), person(\"Adam\", \"Vogt\", role = \"ctb\"), person(\"Alastair\", \"Andrew\", role = \"ctb\"), person(\"Alex\", \"Zvoleff\", role = \"ctb\"), person(\"Amar\", \"Al-Zubaidi\", role = \"ctb\"), person(\"Andre\", \"Simon\", role = \"ctb\", comment = \"the CSS files under inst/themes/ were derived from the Highlight package http://www.andre-simon.de\"), person(\"Aron\", \"Atkins\", role = \"ctb\"), person(\"Aaron\", \"Wolen\", role = \"ctb\"), person(\"Ashley\", \"Manton\", role = \"ctb\"), person(\"Atsushi\", \"Yasumoto\", role = \"ctb\", comment = c(ORCID = \"0000-0002-8335-495X\")), person(\"Ben\", \"Baumer\", role = \"ctb\"), person(\"Brian\", \"Diggs\", role = \"ctb\"), person(\"Brian\", \"Zhang\", role = \"ctb\"), person(\"Bulat\", \"Yapparov\", role = \"ctb\"), person(\"Cassio\", \"Pereira\", role = \"ctb\"), person(\"Christophe\", \"Dervieux\", role = \"ctb\"), person(\"David\", \"Hall\", role = \"ctb\"), person(\"David\", \"Hugh-Jones\", role = \"ctb\"), person(\"David\", \"Robinson\", role = \"ctb\"), person(\"Doug\", \"Hemken\", role = \"ctb\"), person(\"Duncan\", \"Murdoch\", role = \"ctb\"), person(\"Elio\", \"Campitelli\", role = \"ctb\"), person(\"Ellis\", \"Hughes\", role = \"ctb\"), person(\"Emily\", \"Riederer\", role = \"ctb\"), person(\"Fabian\", \"Hirschmann\", role = \"ctb\"), person(\"Fitch\", \"Simeon\", role = \"ctb\"), person(\"Forest\", \"Fang\", role = \"ctb\"), person(c(\"Frank\", \"E\", \"Harrell\", \"Jr\"), role = \"ctb\", comment = \"the Sweavel package at inst/misc/Sweavel.sty\"), person(\"Garrick\", \"Aden-Buie\", role = \"ctb\"), person(\"Gregoire\", \"Detrez\", role = \"ctb\"), person(\"Hadley\", \"Wickham\", role = \"ctb\"), person(\"Hao\", \"Zhu\", role = \"ctb\"), person(\"Heewon\", \"Jeon\", role = \"ctb\"), person(\"Henrik\", \"Bengtsson\", role = \"ctb\"), person(\"Hiroaki\", \"Yutani\", role = \"ctb\"), person(\"Ian\", \"Lyttle\", role = \"ctb\"), person(\"Hodges\", \"Daniel\", role = \"ctb\"), person(\"Jacob\", \"Bien\", role = \"ctb\"), person(\"Jake\", \"Burkhead\", role = \"ctb\"), person(\"James\", \"Manton\", role = \"ctb\"), person(\"Jared\", \"Lander\", role = \"ctb\"), person(\"Jason\", \"Punyon\", role = \"ctb\"), person(\"Javier\", \"Luraschi\", role = \"ctb\"), person(\"Jeff\", \"Arnold\", role = \"ctb\"), person(\"Jenny\", \"Bryan\", role = \"ctb\"), person(\"Jeremy\", \"Ashkenas\", role = c(\"ctb\", \"cph\"), comment = \"the CSS file at inst/misc/docco-classic.css\"), person(\"Jeremy\", \"Stephens\", role = \"ctb\"), person(\"Jim\", \"Hester\", role = \"ctb\"), person(\"Joe\", \"Cheng\", role = \"ctb\"), person(\"Johannes\", \"Ranke\", role = \"ctb\"), person(\"John\", \"Honaker\", role = \"ctb\"), person(\"John\", \"Muschelli\", role = \"ctb\"), person(\"Jonathan\", \"Keane\", role = \"ctb\"), person(\"JJ\", \"Allaire\", role = \"ctb\"), person(\"Johan\", \"Toloe\", role = \"ctb\"), person(\"Jonathan\", \"Sidi\", role = \"ctb\"), person(\"Joseph\", \"Larmarange\", role = \"ctb\"), person(\"Julien\", \"Barnier\", role = \"ctb\"), person(\"Kaiyin\", \"Zhong\", role = \"ctb\"), person(\"Kamil\", \"Slowikowski\", role = \"ctb\"), person(\"Karl\", \"Forner\", role = \"ctb\"), person(c(\"Kevin\", \"K.\"), \"Smith\", role = \"ctb\"), person(\"Kirill\", \"Mueller\", role = \"ctb\"), person(\"Kohske\", \"Takahashi\", role = \"ctb\"), person(\"Lorenz\", \"Walthert\", role = \"ctb\"), person(\"Lucas\", \"Gallindo\", role = \"ctb\"), person(\"Marius\", \"Hofert\", role = \"ctb\"), person(\"Martin\", \"Modrák\", role = \"ctb\"), person(\"Michael\", \"Chirico\", role = \"ctb\"), person(\"Michael\", \"Friendly\", role = \"ctb\"), person(\"Michal\", \"Bojanowski\", role = \"ctb\"), person(\"Michel\", \"Kuhlmann\", role = \"ctb\"), person(\"Miller\", \"Patrick\", role = \"ctb\"), person(\"Nacho\", \"Caballero\", role = \"ctb\"), person(\"Nick\", \"Salkowski\", role = \"ctb\"), person(\"Niels Richard\", \"Hansen\", role = \"ctb\"), person(\"Noam\", \"Ross\", role = \"ctb\"), person(\"Obada\", \"Mahdi\", role = \"ctb\"), person(\"Pavel N.\", \"Krivitsky\", role = \"ctb\", comment=c(ORCID = \"0000-0002-9101-3362\")), person(\"Pedro\", \"Faria\", role = \"ctb\"), person(\"Qiang\", \"Li\", role = \"ctb\"), person(\"Ramnath\", \"Vaidyanathan\", role = \"ctb\"), person(\"Richard\", \"Cotton\", role = \"ctb\"), person(\"Robert\", \"Krzyzanowski\", role = \"ctb\"), person(\"Rodrigo\", \"Copetti\", role = \"ctb\"), person(\"Romain\", \"Francois\", role = \"ctb\"), person(\"Ruaridh\", \"Williamson\", role = \"ctb\"), person(\"Sagiru\", \"Mati\", role = \"ctb\", comment = c(ORCID = \"0000-0003-1413-3974\")), person(\"Scott\", \"Kostyshak\", role = \"ctb\"), person(\"Sebastian\", \"Meyer\", role = \"ctb\"), person(\"Sietse\", \"Brouwer\", role = \"ctb\"), person(c(\"Simon\", \"de\"), \"Bernard\", role = \"ctb\"), person(\"Sylvain\", \"Rousseau\", role = \"ctb\"), person(\"Taiyun\", \"Wei\", role = \"ctb\"), person(\"Thibaut\", \"Assus\", role = \"ctb\"), person(\"Thibaut\", \"Lamadon\", role = \"ctb\"), person(\"Thomas\", \"Leeper\", role = \"ctb\"), person(\"Tim\", \"Mastny\", role = \"ctb\"), person(\"Tom\", \"Torsney-Weir\", role = \"ctb\"), person(\"Trevor\", \"Davis\", role = \"ctb\"), person(\"Viktoras\", \"Veitas\", role = \"ctb\"), person(\"Weicheng\", \"Zhu\", role = \"ctb\"), person(\"Wush\", \"Wu\", role = \"ctb\"), person(\"Zachary\", \"Foster\", role = \"ctb\"), person(\"Zhian N.\", \"Kamvar\", role = \"ctb\", comment = c(ORCID = \"0000-0003-1458-7108\")), person(given = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides a general-purpose tool for dynamic report generation in R using Literate Programming techniques.", + "Depends": [ + "R (>= 3.6.0)" + ], + "Imports": [ + "evaluate (>= 0.15)", + "highr (>= 0.11)", + "methods", + "tools", + "xfun (>= 0.51)", + "yaml (>= 2.1.19)" + ], + "Suggests": [ + "bslib", + "codetools", + "DBI (>= 0.4-1)", + "digest", + "formatR", + "gifski", + "gridSVG", + "htmlwidgets (>= 0.7)", + "jpeg", + "JuliaCall (>= 0.11.1)", + "magick", + "litedown", + "markdown (>= 1.3)", + "png", + "ragg", + "reticulate (>= 1.4)", + "rgl (>= 0.95.1201)", + "rlang", + "rmarkdown", + "sass", + "showtext", + "styler (>= 1.2.0)", + "targets (>= 0.6.0)", + "testit", + "tibble", + "tikzDevice (>= 0.10)", + "tinytex (>= 0.56)", + "webshot", + "rstudioapi", + "svglite" + ], + "License": "GPL", + "URL": "https://yihui.org/knitr/", + "BugReports": "https://github.com/yihui/knitr/issues", + "Encoding": "UTF-8", + "VignetteBuilder": "litedown, knitr", + "SystemRequirements": "Package vignettes based on R Markdown v2 or reStructuredText require Pandoc (http://pandoc.org). The function rst2pdf() requires rst2pdf (https://github.com/rst2pdf/rst2pdf).", + "Collate": "'block.R' 'cache.R' 'citation.R' 'hooks-html.R' 'plot.R' 'utils.R' 'defaults.R' 'concordance.R' 'engine.R' 'highlight.R' 'themes.R' 'header.R' 'hooks-asciidoc.R' 'hooks-chunk.R' 'hooks-extra.R' 'hooks-latex.R' 'hooks-md.R' 'hooks-rst.R' 'hooks-textile.R' 'hooks.R' 'output.R' 'package.R' 'pandoc.R' 'params.R' 'parser.R' 'pattern.R' 'rocco.R' 'spin.R' 'table.R' 'template.R' 'utils-conversion.R' 'utils-rd2html.R' 'utils-string.R' 'utils-sweave.R' 'utils-upload.R' 'utils-vignettes.R' 'zzz.R'", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "no", + "Author": "Yihui Xie [aut, cre] (, https://yihui.org), Abhraneel Sarma [ctb], Adam Vogt [ctb], Alastair Andrew [ctb], Alex Zvoleff [ctb], Amar Al-Zubaidi [ctb], Andre Simon [ctb] (the CSS files under inst/themes/ were derived from the Highlight package http://www.andre-simon.de), Aron Atkins [ctb], Aaron Wolen [ctb], Ashley Manton [ctb], Atsushi Yasumoto [ctb] (), Ben Baumer [ctb], Brian Diggs [ctb], Brian Zhang [ctb], Bulat Yapparov [ctb], Cassio Pereira [ctb], Christophe Dervieux [ctb], David Hall [ctb], David Hugh-Jones [ctb], David Robinson [ctb], Doug Hemken [ctb], Duncan Murdoch [ctb], Elio Campitelli [ctb], Ellis Hughes [ctb], Emily Riederer [ctb], Fabian Hirschmann [ctb], Fitch Simeon [ctb], Forest Fang [ctb], Frank E Harrell Jr [ctb] (the Sweavel package at inst/misc/Sweavel.sty), Garrick Aden-Buie [ctb], Gregoire Detrez [ctb], Hadley Wickham [ctb], Hao Zhu [ctb], Heewon Jeon [ctb], Henrik Bengtsson [ctb], Hiroaki Yutani [ctb], Ian Lyttle [ctb], Hodges Daniel [ctb], Jacob Bien [ctb], Jake Burkhead [ctb], James Manton [ctb], Jared Lander [ctb], Jason Punyon [ctb], Javier Luraschi [ctb], Jeff Arnold [ctb], Jenny Bryan [ctb], Jeremy Ashkenas [ctb, cph] (the CSS file at inst/misc/docco-classic.css), Jeremy Stephens [ctb], Jim Hester [ctb], Joe Cheng [ctb], Johannes Ranke [ctb], John Honaker [ctb], John Muschelli [ctb], Jonathan Keane [ctb], JJ Allaire [ctb], Johan Toloe [ctb], Jonathan Sidi [ctb], Joseph Larmarange [ctb], Julien Barnier [ctb], Kaiyin Zhong [ctb], Kamil Slowikowski [ctb], Karl Forner [ctb], Kevin K. Smith [ctb], Kirill Mueller [ctb], Kohske Takahashi [ctb], Lorenz Walthert [ctb], Lucas Gallindo [ctb], Marius Hofert [ctb], Martin Modrák [ctb], Michael Chirico [ctb], Michael Friendly [ctb], Michal Bojanowski [ctb], Michel Kuhlmann [ctb], Miller Patrick [ctb], Nacho Caballero [ctb], Nick Salkowski [ctb], Niels Richard Hansen [ctb], Noam Ross [ctb], Obada Mahdi [ctb], Pavel N. Krivitsky [ctb] (), Pedro Faria [ctb], Qiang Li [ctb], Ramnath Vaidyanathan [ctb], Richard Cotton [ctb], Robert Krzyzanowski [ctb], Rodrigo Copetti [ctb], Romain Francois [ctb], Ruaridh Williamson [ctb], Sagiru Mati [ctb] (), Scott Kostyshak [ctb], Sebastian Meyer [ctb], Sietse Brouwer [ctb], Simon de Bernard [ctb], Sylvain Rousseau [ctb], Taiyun Wei [ctb], Thibaut Assus [ctb], Thibaut Lamadon [ctb], Thomas Leeper [ctb], Tim Mastny [ctb], Tom Torsney-Weir [ctb], Trevor Davis [ctb], Viktoras Veitas [ctb], Weicheng Zhu [ctb], Wush Wu [ctb], Zachary Foster [ctb], Zhian N. Kamvar [ctb] (), Posit Software, PBC [cph, fnd]", + "Maintainer": "Yihui Xie ", + "Repository": "CRAN" + }, + "labeling": { + "Package": "labeling", + "Version": "0.4.3", + "Source": "Repository", + "Type": "Package", + "Title": "Axis Labeling", + "Date": "2023-08-29", + "Author": "Justin Talbot,", + "Maintainer": "Nuno Sempere ", + "Description": "Functions which provide a range of axis labeling algorithms.", + "License": "MIT + file LICENSE | Unlimited", + "Collate": "'labeling.R'", + "NeedsCompilation": "no", + "Imports": [ + "stats", + "graphics" + ], + "Repository": "CRAN" + }, + "later": { + "Package": "later", + "Version": "1.3.2", + "Source": "Repository", + "Type": "Package", + "Title": "Utilities for Scheduling Functions to Execute Later with Event Loops", + "Authors@R": "c( person(\"Winston\", \"Chang\", role = c(\"aut\", \"cre\"), email = \"winston@posit.co\"), person(\"Joe\", \"Cheng\", role = c(\"aut\"), email = \"joe@posit.co\"), person(family = \"Posit Software, PBC\", role = \"cph\"), person(\"Marcus\", \"Geelnard\", role = c(\"ctb\", \"cph\"), comment = \"TinyCThread library, https://tinycthread.github.io/\"), person(\"Evan\", \"Nemerson\", role = c(\"ctb\", \"cph\"), comment = \"TinyCThread library, https://tinycthread.github.io/\") )", + "Description": "Executes arbitrary R or C functions some time after the current time, after the R execution stack has emptied. The functions are scheduled in an event loop.", + "URL": "https://r-lib.github.io/later/, https://github.com/r-lib/later", + "BugReports": "https://github.com/r-lib/later/issues", + "License": "MIT + file LICENSE", + "Imports": [ + "Rcpp (>= 0.12.9)", + "rlang" + ], + "LinkingTo": [ + "Rcpp" + ], + "RoxygenNote": "7.2.3", + "Suggests": [ + "knitr", + "rmarkdown", + "testthat (>= 2.1.0)" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Winston Chang [aut, cre], Joe Cheng [aut], Posit Software, PBC [cph], Marcus Geelnard [ctb, cph] (TinyCThread library, https://tinycthread.github.io/), Evan Nemerson [ctb, cph] (TinyCThread library, https://tinycthread.github.io/)", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "lattice": { + "Package": "lattice", + "Version": "0.21-9", + "Source": "Repository", + "Date": "2023-09-30", + "Priority": "recommended", + "Title": "Trellis Graphics for R", + "Authors@R": "c(person(\"Deepayan\", \"Sarkar\", role = c(\"aut\", \"cre\"), email = \"deepayan.sarkar@r-project.org\", comment = c(ORCID = \"0000-0003-4107-1553\")), person(\"Felix\", \"Andrews\", role = \"ctb\"), person(\"Kevin\", \"Wright\", role = \"ctb\", comment = \"documentation\"), person(\"Neil\", \"Klepeis\", role = \"ctb\"), person(\"Johan\", \"Larsson\", role = \"ctb\", comment = \"miscellaneous improvements\"), person(\"Zhijian (Jason)\", \"Wen\", role = \"cph\", comment = \"filled contour code\"), person(\"Paul\", \"Murrell\", role = \"ctb\", email = \"paul@stat.auckland.ac.nz\"), person(\"Stefan\", \"Eng\", role = \"ctb\", comment = \"violin plot improvements\"), person(\"Achim\", \"Zeileis\", role = \"ctb\", comment = \"modern colors\") )", + "Description": "A powerful and elegant high-level data visualization system inspired by Trellis graphics, with an emphasis on multivariate data. Lattice is sufficient for typical graphics needs, and is also flexible enough to handle most nonstandard requirements. See ?Lattice for an introduction.", + "Depends": [ + "R (>= 4.0.0)" + ], + "Suggests": [ + "KernSmooth", + "MASS", + "latticeExtra", + "colorspace" + ], + "Imports": [ + "grid", + "grDevices", + "graphics", + "stats", + "utils" + ], + "Enhances": [ + "chron" + ], + "LazyLoad": "yes", + "LazyData": "yes", + "License": "GPL (>= 2)", + "URL": "https://lattice.r-forge.r-project.org/", + "BugReports": "https://github.com/deepayan/lattice/issues", + "NeedsCompilation": "yes", + "Author": "Deepayan Sarkar [aut, cre] (), Felix Andrews [ctb], Kevin Wright [ctb] (documentation), Neil Klepeis [ctb], Johan Larsson [ctb] (miscellaneous improvements), Zhijian (Jason) Wen [cph] (filled contour code), Paul Murrell [ctb], Stefan Eng [ctb] (violin plot improvements), Achim Zeileis [ctb] (modern colors)", + "Maintainer": "Deepayan Sarkar ", + "Repository": "CRAN" + }, + "lazyeval": { + "Package": "lazyeval", + "Version": "0.2.2", + "Source": "Repository", + "Title": "Lazy (Non-Standard) Evaluation", + "Description": "An alternative approach to non-standard evaluation using formulas. Provides a full implementation of LISP style 'quasiquotation', making it easier to generate code with other code.", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", ,\"hadley@rstudio.com\", c(\"aut\", \"cre\")), person(\"RStudio\", role = \"cph\") )", + "License": "GPL-3", + "LazyData": "true", + "Depends": [ + "R (>= 3.1.0)" + ], + "Suggests": [ + "knitr", + "rmarkdown (>= 0.2.65)", + "testthat", + "covr" + ], + "VignetteBuilder": "knitr", + "RoxygenNote": "6.1.1", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre], RStudio [cph]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "lifecycle": { + "Package": "lifecycle", + "Version": "1.0.4", + "Source": "Repository", + "Title": "Manage the Life Cycle of your Package Functions", + "Authors@R": "c( person(\"Lionel\", \"Henry\", , \"lionel@posit.co\", role = c(\"aut\", \"cre\")), person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Manage the life cycle of your exported functions with shared conventions, documentation badges, and user-friendly deprecation warnings.", + "License": "MIT + file LICENSE", + "URL": "https://lifecycle.r-lib.org/, https://github.com/r-lib/lifecycle", + "BugReports": "https://github.com/r-lib/lifecycle/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli (>= 3.4.0)", + "glue", + "rlang (>= 1.1.0)" + ], + "Suggests": [ + "covr", + "crayon", + "knitr", + "lintr", + "rmarkdown", + "testthat (>= 3.0.1)", + "tibble", + "tidyverse", + "tools", + "vctrs", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate, usethis", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.1", + "NeedsCompilation": "no", + "Author": "Lionel Henry [aut, cre], Hadley Wickham [aut] (), Posit Software, PBC [cph, fnd]", + "Maintainer": "Lionel Henry ", + "Repository": "CRAN" + }, + "linprog": { + "Package": "linprog", + "Version": "0.9-4", + "Source": "Repository", + "Date": "2022-03-09", + "Title": "Linear Programming / Optimization", + "Author": "Arne Henningsen", + "Maintainer": "Arne Henningsen ", + "Depends": [ + "R (>= 2.4.0)", + "lpSolve" + ], + "Description": "Can be used to solve Linear Programming / Linear Optimization problems by using the simplex algorithm.", + "License": "GPL (>= 2)", + "URL": "http://linprog.r-forge.r-project.org/", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "lintr": { + "Package": "lintr", + "Version": "3.2.0", + "Source": "Repository", + "Title": "A 'Linter' for R Code", + "Authors@R": "c( person(\"Jim\", \"Hester\", , role = \"aut\"), person(\"Florent\", \"Angly\", role = \"aut\", comment = \"fangly\"), person(\"Russ\", \"Hyde\", role = \"aut\"), person(\"Michael\", \"Chirico\", email = \"michaelchirico4@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Kun\", \"Ren\", role = \"aut\"), person(\"Alexander\", \"Rosenstock\", role = \"aut\", comment = \"AshesITR\"), person(\"Indrajeet\", \"Patil\", , \"patilindrajeet.science@gmail.com\", role = \"aut\", comment = c(ORCID = \"0000-0003-1995-6531\", Twitter = \"@patilindrajeets\")) )", + "Description": "Checks adherence to a given style, syntax errors and possible semantic issues. Supports on the fly checking of R code edited with 'RStudio IDE', 'Emacs', 'Vim', 'Sublime Text', 'Atom' and 'Visual Studio Code'.", + "License": "MIT + file LICENSE", + "URL": "https://lintr.r-lib.org, https://github.com/r-lib/lintr", + "BugReports": "https://github.com/r-lib/lintr/issues", + "Depends": [ + "R (>= 4.0)" + ], + "Imports": [ + "backports (>= 1.4.0)", + "cli (>= 3.4.0)", + "codetools", + "digest", + "glue", + "knitr", + "rex", + "stats", + "utils", + "xml2 (>= 1.0.0)", + "xmlparsedata (>= 1.0.5)" + ], + "Suggests": [ + "bookdown", + "cyclocomp", + "jsonlite", + "patrick (>= 0.2.0)", + "rlang", + "rmarkdown", + "rstudioapi (>= 0.2)", + "testthat (>= 3.2.1)", + "tibble", + "tufte", + "withr (>= 2.5.0)" + ], + "Enhances": [ + "data.table" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/Needs/development": "pkgload, cli, testthat, patrick", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Collate": "'make_linter_from_xpath.R' 'xp_utils.R' 'utils.R' 'AAA.R' 'T_and_F_symbol_linter.R' 'absolute_path_linter.R' 'actions.R' 'addins.R' 'any_duplicated_linter.R' 'any_is_na_linter.R' 'assignment_linter.R' 'backport_linter.R' 'boolean_arithmetic_linter.R' 'brace_linter.R' 'cache.R' 'class_equals_linter.R' 'commas_linter.R' 'commented_code_linter.R' 'comparison_negation_linter.R' 'condition_call_linter.R' 'condition_message_linter.R' 'conjunct_test_linter.R' 'consecutive_assertion_linter.R' 'consecutive_mutate_linter.R' 'cyclocomp_linter.R' 'declared_functions.R' 'deprecated.R' 'duplicate_argument_linter.R' 'empty_assignment_linter.R' 'equals_na_linter.R' 'exclude.R' 'expect_comparison_linter.R' 'expect_identical_linter.R' 'expect_length_linter.R' 'expect_lint.R' 'expect_named_linter.R' 'expect_not_linter.R' 'expect_null_linter.R' 'expect_s3_class_linter.R' 'expect_s4_class_linter.R' 'expect_true_false_linter.R' 'expect_type_linter.R' 'extract.R' 'fixed_regex_linter.R' 'for_loop_index_linter.R' 'function_argument_linter.R' 'function_left_parentheses_linter.R' 'function_return_linter.R' 'get_source_expressions.R' 'ids_with_token.R' 'if_not_else_linter.R' 'if_switch_linter.R' 'ifelse_censor_linter.R' 'implicit_assignment_linter.R' 'implicit_integer_linter.R' 'indentation_linter.R' 'infix_spaces_linter.R' 'inner_combine_linter.R' 'is_lint_level.R' 'is_numeric_linter.R' 'keyword_quote_linter.R' 'length_levels_linter.R' 'length_test_linter.R' 'lengths_linter.R' 'library_call_linter.R' 'line_length_linter.R' 'lint.R' 'linter_tag_docs.R' 'linter_tags.R' 'lintr-deprecated.R' 'lintr-package.R' 'list_comparison_linter.R' 'literal_coercion_linter.R' 'make_linter_from_regex.R' 'matrix_apply_linter.R' 'methods.R' 'missing_argument_linter.R' 'missing_package_linter.R' 'namespace.R' 'namespace_linter.R' 'nested_ifelse_linter.R' 'nested_pipe_linter.R' 'nonportable_path_linter.R' 'shared_constants.R' 'nrow_subset_linter.R' 'numeric_leading_zero_linter.R' 'nzchar_linter.R' 'object_length_linter.R' 'object_name_linter.R' 'object_overwrite_linter.R' 'object_usage_linter.R' 'one_call_pipe_linter.R' 'outer_negation_linter.R' 'package_hooks_linter.R' 'paren_body_linter.R' 'paste_linter.R' 'path_utils.R' 'pipe_call_linter.R' 'pipe_consistency_linter.R' 'pipe_continuation_linter.R' 'pipe_return_linter.R' 'print_linter.R' 'quotes_linter.R' 'redundant_equals_linter.R' 'redundant_ifelse_linter.R' 'regex_subset_linter.R' 'rep_len_linter.R' 'repeat_linter.R' 'return_linter.R' 'routine_registration_linter.R' 'sample_int_linter.R' 'scalar_in_linter.R' 'semicolon_linter.R' 'seq_linter.R' 'settings.R' 'settings_utils.R' 'sort_linter.R' 'source_utils.R' 'spaces_inside_linter.R' 'spaces_left_parentheses_linter.R' 'sprintf_linter.R' 'stopifnot_all_linter.R' 'string_boundary_linter.R' 'strings_as_factors_linter.R' 'system_file_linter.R' 'terminal_close_linter.R' 'todo_comment_linter.R' 'trailing_blank_lines_linter.R' 'trailing_whitespace_linter.R' 'tree_utils.R' 'undesirable_function_linter.R' 'undesirable_operator_linter.R' 'unnecessary_concatenation_linter.R' 'unnecessary_lambda_linter.R' 'unnecessary_nesting_linter.R' 'unnecessary_placeholder_linter.R' 'unreachable_code_linter.R' 'unused_import_linter.R' 'use_lintr.R' 'vector_logic_linter.R' 'which_grepl_linter.R' 'whitespace_linter.R' 'with.R' 'with_id.R' 'xml_nodes_to_lints.R' 'xml_utils.R' 'yoda_test_linter.R' 'zzz.R'", + "Language": "en-US", + "NeedsCompilation": "no", + "Author": "Jim Hester [aut], Florent Angly [aut] (fangly), Russ Hyde [aut], Michael Chirico [aut, cre], Kun Ren [aut], Alexander Rosenstock [aut] (AshesITR), Indrajeet Patil [aut] (, @patilindrajeets)", + "Maintainer": "Michael Chirico ", + "Repository": "CRAN" + }, + "lmom": { + "Package": "lmom", + "Version": "3.0", + "Source": "Repository", + "Date": "2023-08-29", + "Title": "L-Moments", + "Author": "J. R. M. Hosking", + "Maintainer": "J. R. M. Hosking ", + "Description": "Functions related to L-moments: computation of L-moments and trimmed L-moments of distributions and data samples; parameter estimation; L-moment ratio diagram; plot vs. quantiles of an extreme-value distribution.", + "Depends": [ + "R (>= 3.0.0)" + ], + "Imports": [ + "stats", + "graphics" + ], + "License": "Common Public License Version 1.0", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "lmomco": { + "Package": "lmomco", + "Version": "2.5.1", + "Source": "Repository", + "Type": "Package", + "Title": "L-Moments, Censored L-Moments, Trimmed L-Moments, L-Comoments, and Many Distributions", + "Depends": [ + "R (>= 3.5.0)", + "utils" + ], + "Imports": [ + "goftest", + "Lmoments", + "MASS" + ], + "Suggests": [ + "copBasic" + ], + "Date": "2024-05-02", + "Author": "William Asquith", + "Description": "Extensive functions for Lmoments (LMs) and probability-weighted moments (PWMs), distribution parameter estimation, LMs for distributions, LM ratio diagrams, multivariate Lcomoments, and asymmetric (asy) trimmed LMs (TLMs). Maximum likelihood and maximum product spacings estimation are available. Right-tail and left-tail LM censoring by threshold or indicator variable are available. LMs of residual (resid) and reversed (rev) residual life are implemented along with 13 quantile operators for reliability analyses. Exact analytical bootstrap estimates of order statistics, LMs, and LM var-covars are available. Harri-Coble Tau34-squared Normality Test is available. Distributions with L, TL, and added (+) support for right-tail censoring (RC) encompass: Asy Exponential (Exp) Power [L], Asy Triangular [L], Cauchy [TL], Eta-Mu [L], Exp. [L], Gamma [L], Generalized (Gen) Exp Poisson [L], Gen Extreme Value [L], Gen Lambda [L, TL], Gen Logistic [L], Gen Normal [L], Gen Pareto [L+RC, TL], Govindarajulu [L], Gumbel [L], Kappa [L], Kappa-Mu [L], Kumaraswamy [L], Laplace [L], Linear Mean Residual Quantile Function [L], Normal [L], 3p log-Normal [L], Pearson Type III [L], Polynomial Density-Quantile 3 and 4 [L], Rayleigh [L], Rev-Gumbel [L+RC], Rice [L], Singh Maddala [L], Slash [TL], 3p Student t [L], Truncated Exponential [L], Wakeby [L], and Weibull [L].", + "Maintainer": "William Asquith ", + "Repository": "CRAN", + "License": "GPL", + "URL": "https://www.amazon.com/dp/1463508417/", + "NeedsCompilation": "no", + "LazyData": "true" + }, + "lpSolve": { + "Package": "lpSolve", + "Version": "5.6.20", + "Source": "Repository", + "Title": "Interface to 'Lp_solve' v. 5.5 to Solve Linear/Integer Programs", + "Author": "Michel Berkelaar and others", + "Maintainer": "Gábor Csárdi ", + "Description": "Lp_solve is freely available (under LGPL 2) software for solving linear, integer and mixed integer programs. In this implementation we supply a \"wrapper\" function in C and some R functions that solve general linear/integer problems, assignment problems, and transportation problems. This version calls lp_solve version 5.5.", + "License": "LGPL-2", + "URL": "https://github.com/gaborcsardi/lpSolve", + "BugReports": "https://github.com/gaborcsardi/lpSolve/issues", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "lpjclass": { + "Package": "lpjclass", + "Version": "1.19.7", + "Source": "Repository", + "Type": "Package", + "Title": "LPJ Class Functions", + "Date": "2023-06-27", + "Authors@R": "c(person(\"Katharina\", \"Waha\", role = \"aut\"), person(\"Benjamin\", \"Bodirsky\", role = \"aut\"), person(\"Susanne\", \"Roliniski\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", role = c(\"aut\",\"cre\")), person(\"Marcos\", \"P. P. Alves\", role = \"aut\"))", + "Description": "Package containing the LPJ-Object-Class together with relevant functions and methods.", + "Depends": [ + "R (>= 2.10)", + "methods" + ], + "Imports": [ + "magclass", + "utils" + ], + "Suggests": [ + "covr" + ], + "License": "LGPL-3 | file LICENSE", + "LazyData": "no", + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "Repository": "https://pik-piam.r-universe.dev", + "RemoteUrl": "https://github.com/pik-piam/lpjclass", + "RemoteRef": "HEAD", + "RemoteSha": "f94f0a3504c3b09c6dff49a64547aaed023edbe2", + "NeedsCompilation": "no", + "Author": "Katharina Waha [aut], Benjamin Bodirsky [aut], Susanne Roliniski [aut], Jan Philipp Dietrich [aut, cre], Marcos P. P. Alves [aut]", + "Maintainer": "Jan Philipp Dietrich " + }, + "lpjmlkit": { + "Package": "lpjmlkit", + "Version": "1.7.11", + "Source": "Repository", + "Type": "Package", + "Title": "Toolkit for Basic LPJmL Handling", + "Authors@R": "c( person(\"Jannes\", \"Breier\", , \"jannesbr@pik-potsdam.de\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-9055-6904\")), person(\"Sebastian\",\"Ostberg\", , \"ostberg@pik-potsdam.de\", role = \"aut\", comment = c(ORCID = \"0000-0002-2368-7015\")), person(\"Stephen Björn\", \"Wirth\", , \"wirth@pik-potsdam.de\", role = \"aut\", comment = c(ORCID = \"0000-0003-3090-3318\")), person(\"Sara\",\"Minoli\", , \"minoli@pik-potsdam.de\", role = \"aut\", comment = c(ORCID = \"0000-0001-7920-3107\")), person(\"Fabian\", \"Stenzel\", , \"stenzel@pik-potsdam.de\", role = \"aut\", comment = c(ORCID = \"0000-0002-5109-0048\")), person(\"David\",\"Hötten\", , \"davidho@pik-potsdam.de\", role = c(\"aut\")), person(\"Christoph\", \"Müller\", , \"cmueller@pik-potsdam.de\", role = \"aut\", comment = c(ORCID = \"0000-0002-9491-3550\")) )", + "Description": "A collection of basic functions to facilitate the work with the Dynamic Global Vegetation Model (DGVM) Lund-Potsdam-Jena managed Land (LPJmL) hosted at the Potsdam Institute for Climate Impact Research (PIK). It provides functions for performing LPJmL simulations, as well as reading, processing and writing model-related data such as inputs and outputs or configuration files.", + "License": "AGPL-3", + "RoxygenNote": "7.3.3", + "Roxygen": "list(markdown = TRUE, r6 = TRUE)", + "Encoding": "UTF-8", + "Depends": [ + "R (>= 3.5.0)" + ], + "URL": "https://github.com/PIK-LPJmL/lpjmlkit, https://doi.org/10.5281/zenodo.7773134", + "BugReports": "https://github.com/PIK-LPJmL/lpjmlkit/issues", + "Imports": [ + "magrittr", + "dplyr", + "processx", + "tibble", + "jsonlite", + "doParallel", + "foreach", + "utils", + "methods", + "abind", + "rlang", + "withr", + "grDevices", + "cli", + "stringi" + ], + "Suggests": [ + "rmarkdown", + "knitr", + "testthat (>= 3.0.0)", + "terra", + "raster", + "reshape2", + "maps", + "sf", + "R6" + ], + "Config/testthat/edition": "3", + "VignetteBuilder": "knitr", + "Date": "2025-10-15", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/PIK-LPJmL/lpjmlkit", + "RemoteRef": "HEAD", + "RemoteSha": "7b90c60862891675919afba9aa8f69b2fc0570dd", + "NeedsCompilation": "no", + "Author": "Jannes Breier [aut, cre] (), Sebastian Ostberg [aut] (), Stephen Björn Wirth [aut] (), Sara Minoli [aut] (), Fabian Stenzel [aut] (), David Hötten [aut], Christoph Müller [aut] ()", + "Maintainer": "Jannes Breier " + }, + "lubridate": { + "Package": "lubridate", + "Version": "1.9.4", + "Source": "Repository", + "Type": "Package", + "Title": "Make Dealing with Dates a Little Easier", + "Authors@R": "c( person(\"Vitalie\", \"Spinu\", , \"spinuvit@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Garrett\", \"Grolemund\", role = \"aut\"), person(\"Hadley\", \"Wickham\", role = \"aut\"), person(\"Davis\", \"Vaughan\", role = \"ctb\"), person(\"Ian\", \"Lyttle\", role = \"ctb\"), person(\"Imanuel\", \"Costigan\", role = \"ctb\"), person(\"Jason\", \"Law\", role = \"ctb\"), person(\"Doug\", \"Mitarotonda\", role = \"ctb\"), person(\"Joseph\", \"Larmarange\", role = \"ctb\"), person(\"Jonathan\", \"Boiser\", role = \"ctb\"), person(\"Chel Hee\", \"Lee\", role = \"ctb\") )", + "Maintainer": "Vitalie Spinu ", + "Description": "Functions to work with date-times and time-spans: fast and user friendly parsing of date-time data, extraction and updating of components of a date-time (years, months, days, hours, minutes, and seconds), algebraic manipulation on date-time and time-span objects. The 'lubridate' package has a consistent and memorable syntax that makes working with dates easy and fun.", + "License": "GPL (>= 2)", + "URL": "https://lubridate.tidyverse.org, https://github.com/tidyverse/lubridate", + "BugReports": "https://github.com/tidyverse/lubridate/issues", + "Depends": [ + "methods", + "R (>= 3.2)" + ], + "Imports": [ + "generics", + "timechange (>= 0.3.0)" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown", + "testthat (>= 2.1.0)", + "vctrs (>= 0.6.5)" + ], + "Enhances": [ + "chron", + "data.table", + "timeDate", + "tis", + "zoo" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "SystemRequirements": "C++11, A system with zoneinfo data (e.g. /usr/share/zoneinfo). On Windows the zoneinfo included with R is used.", + "Collate": "'Dates.r' 'POSIXt.r' 'util.r' 'parse.r' 'timespans.r' 'intervals.r' 'difftimes.r' 'durations.r' 'periods.r' 'accessors-date.R' 'accessors-day.r' 'accessors-dst.r' 'accessors-hour.r' 'accessors-minute.r' 'accessors-month.r' 'accessors-quarter.r' 'accessors-second.r' 'accessors-tz.r' 'accessors-week.r' 'accessors-year.r' 'am-pm.r' 'time-zones.r' 'numeric.r' 'coercion.r' 'constants.r' 'cyclic_encoding.r' 'data.r' 'decimal-dates.r' 'deprecated.r' 'format_ISO8601.r' 'guess.r' 'hidden.r' 'instants.r' 'leap-years.r' 'ops-addition.r' 'ops-compare.r' 'ops-division.r' 'ops-integer-division.r' 'ops-m+.r' 'ops-modulo.r' 'ops-multiplication.r' 'ops-subtraction.r' 'package.r' 'pretty.r' 'round.r' 'stamp.r' 'tzdir.R' 'update.r' 'vctrs.R' 'zzz.R'", + "NeedsCompilation": "yes", + "Author": "Vitalie Spinu [aut, cre], Garrett Grolemund [aut], Hadley Wickham [aut], Davis Vaughan [ctb], Ian Lyttle [ctb], Imanuel Costigan [ctb], Jason Law [ctb], Doug Mitarotonda [ctb], Joseph Larmarange [ctb], Jonathan Boiser [ctb], Chel Hee Lee [ctb]", + "Repository": "CRAN" + }, + "lucode2": { + "Package": "lucode2", + "Version": "0.52.0", + "Source": "Repository", + "Type": "Package", + "Title": "Code Manipulation and Analysis Tools", + "Date": "2025-08-26", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = c(\"aut\", \"cre\"), comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-4309-6431\")), person(\"Pascal\", \"Sauer\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"David\", \"Klein\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Anastasis\", \"Giannousakis\", role = \"aut\"), person(\"Markus\", \"Bonsch\", role = \"aut\"), person(\"Benjamin Leon\", \"Bodirsky\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Lavinia\", \"Baumstark\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Oliver\", \"Richters\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Mika\", \"Pflüger\", role = \"aut\") )", + "Description": "A collection of tools which allow to manipulate and analyze code.", + "License": "BSD_2_clause + file LICENSE", + "URL": "https://github.com/pik-piam/lucode2, https://doi.org/10.5281/zenodo.4389418", + "BugReports": "https://github.com/pik-piam/lucode2/issues", + "Imports": [ + "callr", + "citation (>= 0.11.3)", + "data.table", + "desc", + "devtools", + "dplyr", + "lintr (>= 3.1.0)", + "rlang", + "tools", + "usethis (>= 2.1.0)", + "withr", + "yaml" + ], + "Suggests": [ + "covr", + "gdx", + "gdxrrw", + "gert", + "ggplot2", + "knitr", + "lusweave", + "magclass", + "poorman", + "renv", + "rmarkdown", + "styler", + "testthat" + ], + "Config/Keywords": "tool", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "checkRequiredPackages, updateRepo", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/lucode2", + "RemoteRef": "HEAD", + "RemoteSha": "b50cf04679785966cb082834c8397efbf6ce5d5a", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre] (Potsdam Institute for Climate Impact Research, ), Pascal Sauer [aut] (Potsdam Institute for Climate Impact Research), David Klein [aut] (Potsdam Institute for Climate Impact Research), Anastasis Giannousakis [aut], Markus Bonsch [aut], Benjamin Leon Bodirsky [aut] (Potsdam Institute for Climate Impact Research), Lavinia Baumstark [aut] (Potsdam Institute for Climate Impact Research), Oliver Richters [aut] (Potsdam Institute for Climate Impact Research), Mika Pflüger [aut]", + "Maintainer": "Jan Philipp Dietrich " + }, + "luplot": { + "Package": "luplot", + "Version": "4.1.3", + "Source": "Repository", + "Type": "Package", + "Title": "Landuse Plot Library", + "Date": "2025-09-24", + "Authors@R": "c( person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\"), person(\"Michael\", \"Krause\", , \"krause@pik-potsdam.de\", role = \"aut\"), person(\"Miodrag\", \"Stevanovic\", , \"miodrag@pik-potsdam.de\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\"), person(\"Isabelle\", \"Weindl\", , \"weindl@pik-potsdam.de\", role = \"aut\"), person(\"Lavinia\", \"Baumstark\", , \"baumstark@pik-potsdam.de\", role = \"aut\"), person(\"David\", \"Klein\", , \"klein@pik-potsdam.de\", role = \"aut\"), person(\"Susanne\", \"Rolinski\", , \"rolinski@pik-potsdam.de\", role = \"aut\"), person(\"Xiaoxi\", \"Wang\", , \"wang@pik-potsdam.de\", role = \"aut\"), person(\"David\", \"Chen\", , \"davidch@pik-potsdam.de\", role = \"aut\"), person(\"Pascal\", \"Sauer\", , \"pascal.sauer@pik-potsdam.de\", role = \"aut\") )", + "Maintainer": "Benjamin Bodirsky ", + "Description": "Some useful functions to plot data such as a map plot function for MAgPIE objects.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/luplot", + "Depends": [ + "magclass", + "R (>= 2.15.1)" + ], + "Imports": [ + "data.table", + "ggplot2", + "graphics", + "grDevices", + "gridExtra", + "lusweave", + "mip", + "mstools (>= 0.6.0)", + "quitte", + "RColorBrewer", + "reshape2", + "rlang", + "utils" + ], + "Suggests": [ + "covr", + "rworldmap (>= 1.3.8)", + "lemon" + ], + "Encoding": "UTF-8", + "LazyData": "no", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/luplot.git", + "RemoteRef": "HEAD", + "RemoteSha": "abc6e469bbe2afdd9acd633634acbd0e03b4af0a", + "NeedsCompilation": "no", + "Author": "Benjamin Leon Bodirsky [aut, cre], Jan Philipp Dietrich [aut], Michael Krause [aut], Miodrag Stevanovic [aut], Florian Humpenoeder [aut], Isabelle Weindl [aut], Lavinia Baumstark [aut], David Klein [aut], Susanne Rolinski [aut], Xiaoxi Wang [aut], David Chen [aut], Pascal Sauer [aut]" + }, + "luscale": { + "Package": "luscale", + "Version": "3.1.4", + "Source": "Repository", + "Type": "Package", + "Date": "2025-05-14", + "Title": "PIK Landuse Group Data Scaling Tools", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = \"aut\"), person(\"Markus\", \"Bonsch\", role = \"aut\"), person(\"Patrick, von Jeetze\", role = \"aut\"), person(\"Ulrich\", \"Kreidenweiss\", role = \"aut\"), person(\"Roman Julius\", \"Hennig\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\") )", + "Description": "A collection of tools which allow to aggregate and disaggregate data in various ways.", + "License": "BSD_2_clause + file LICENSE", + "URL": "https://github.com/pik-piam/luscale, https://doi.org/10.5281/zenodo.1158584", + "BugReports": "https://github.com/pik-piam/luscale/issues", + "Depends": [ + "magclass", + "methods", + "R (>= 2.10.0)" + ], + "Imports": [ + "madrat", + "spam", + "utils" + ], + "Suggests": [ + "covr" + ], + "Encoding": "UTF-8", + "LazyData": "no", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/luscale", + "RemoteRef": "HEAD", + "RemoteSha": "9478fb4640507a9c1a5ce8a68cef441640227acd", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre], Benjamin Leon Bodirsky [aut], Markus Bonsch [aut], Patrick, von Jeetze [aut], Ulrich Kreidenweiss [aut], Roman Julius Hennig [aut], Florian Humpenoeder [aut]", + "Maintainer": "Jan Philipp Dietrich " + }, + "lusweave": { + "Package": "lusweave", + "Version": "1.46.5", + "Source": "Repository", + "Type": "Package", + "Title": "Sweave/Knitr Utilities", + "Date": "2025-07-16", + "Authors@R": "c( person(\"Markus\", \"Bonsch\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"David\", \"Klein\", , \"dklein@pik-potsdam.de\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\") )", + "Description": "Set of tools which simplify the usage of SWeave/Knitr in R and allow to easily create PDF files from within R.", + "License": "BSD_2_clause + file LICENSE", + "URL": "https://github.com/pik-piam/lusweave, https://doi.org/10.5281/zenodo.1158594", + "BugReports": "https://github.com/pik-piam/lusweave/issues", + "Depends": [ + "methods", + "R (>= 2.10.0)" + ], + "Imports": [ + "knitr (>= 1.38)", + "withr", + "xtable" + ], + "Suggests": [ + "covr", + "testthat (>= 3.0.0)" + ], + "Encoding": "UTF-8", + "LazyData": "no", + "RoxygenNote": "7.3.2", + "Config/testthat/edition": "3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/lusweave", + "RemoteRef": "HEAD", + "RemoteSha": "271ad4eda26c50e13b85e1bdd27a981327a73a1a", + "NeedsCompilation": "no", + "Author": "Markus Bonsch [aut], Jan Philipp Dietrich [aut, cre], David Klein [aut], Florian Humpenoeder [aut]", + "Maintainer": "Jan Philipp Dietrich " + }, + "m4fsdp": { + "Package": "m4fsdp", + "Version": "0.58.29", + "Source": "Repository", + "Type": "Package", + "Title": "MAgPIE outputs R package for MAgPIE version 4.x to create outputs for FSDP project", + "Date": "2025-10-10", + "Authors@R": "c( person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"David\", \"Chen\", , \"davidch@pik-potsdam.de\", role = \"aut\"), person(\"Michael\", \"Crawford\", , \"crawford@pik-potsdam.de\", role = \"aut\"), person(\"Debbora\", \"Leip\", , \"leip@pik-potsdam.de\", role = \"aut\"), person(\"Patrick\", \"von Jeetze\", , \"vjeetze@pik-potsdam.de\", role = \"aut\"), person(\"Felicitas\", \"Beier\", , \"beier@pik-potsdam.de\", role = \"aut\"), person(\"Edna\", \"Molina Bacca\", , \"mbacca@pik-potsdan.de\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\") )", + "Description": "Output routines for extracting results from the MAgPIE framework (versions 4.x) for the FSDP project.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/m4fsdp, https://doi.org/10.5281/zenodo.7899913", + "BugReports": "https://github.com/pik-piam/m4fsdp/issues", + "Depends": [ + "R (>= 3.5.0)", + "gdx2 (>= 0.3.2)", + "magclass (>= 2.40)" + ], + "Imports": [ + "RColorBrewer", + "cartogram", + "data.table", + "dplyr", + "DT", + "ggh4x", + "ggiraph", + "ggplot2", + "ggtext", + "htmlwidgets", + "luplot", + "madrat", + "magpie4", + "magpiesets", + "knitr", + "patchwork", + "quitte", + "rlang", + "rnaturalearth", + "rmarkdown", + "scales", + "sf", + "stats", + "stringr", + "terra", + "tidyr", + "readxl", + "withr" + ], + "Suggests": [ + "covr", + "flexdashboard", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/m4fsdp", + "RemoteRef": "HEAD", + "RemoteSha": "d3ca2ac59ff200a7b6aff776fa7826da34c92444", + "NeedsCompilation": "no", + "Author": "Benjamin Leon Bodirsky [aut, cre], David Chen [aut], Michael Crawford [aut], Debbora Leip [aut], Patrick von Jeetze [aut], Felicitas Beier [aut], Edna Molina Bacca [aut], Jan Philipp Dietrich [aut], Florian Humpenoeder [aut]", + "Maintainer": "Benjamin Leon Bodirsky " + }, + "madrat": { + "Package": "madrat", + "Version": "3.25.1", + "Source": "Repository", + "Type": "Package", + "Title": "May All Data be Reproducible and Transparent (MADRaT) *", + "Date": "2025-10-14", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = c(\"aut\", \"cre\"), comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-4309-6431\")), person(\"Pascal\", \"Sauer\", , \"pascal.sauer@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Lavinia\", \"Baumstark\", , \"lavinia@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Stephen\", \"Wirth\", , \"wirth@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Anastasis\", \"Giannousakis\", , \"giannou@pik-potsdam.de\", role = \"aut\"), person(\"Renato\", \"Rodrigues\", , \"Renato.Rodrigues@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Debbora\", \"Leip\", , \"leip@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Michael\", \"Crawford\", , \"crawford@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Ulrich\", \"Kreidenweis\", , \"kreidenweis@pik-potsdam.de\", role = \"aut\"), person(\"David\", \"Klein\", , \"dklein@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\")), person(\"Patrick\", \"Rein\", , \"patrick.rein@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0001-9454-8381\")) )", + "Description": "Provides a framework which should improve reproducibility and transparency in data processing. It provides functionality such as automatic meta data creation and management, rudimentary quality management, data caching, work-flow management and data aggregation. * The title is a wish not a promise. By no means we expect this package to deliver everything what is needed to achieve full reproducibility and transparency, but we believe that it supports efforts in this direction.", + "License": "BSD_2_clause + file LICENSE", + "URL": "https://github.com/pik-piam/madrat, https://doi.org/10.5281/zenodo.1115490", + "BugReports": "https://github.com/pik-piam/madrat/issues", + "Depends": [ + "magclass (>= 5.7.0)", + "R (>= 2.10.0)" + ], + "Imports": [ + "callr", + "digest", + "igraph (>= 2.1.1)", + "Matrix", + "methods", + "pkgload", + "renv", + "stringi", + "tools", + "utils", + "withr", + "yaml" + ], + "Suggests": [ + "covr", + "ggplot2", + "graphics", + "grDevices", + "knitr", + "rmarkdown", + "terra", + "testthat", + "tibble" + ], + "VignetteBuilder": "knitr", + "Config/Keywords": "tool", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/madrat", + "RemoteRef": "HEAD", + "RemoteSha": "ee3107e617ce228d127582815893537c6e7706e3", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre] (Potsdam Institute for Climate Impact Research, ), Pascal Sauer [aut] (Potsdam Institute for Climate Impact Research), Lavinia Baumstark [aut] (Potsdam Institute for Climate Impact Research), Stephen Wirth [aut] (Potsdam Institute for Climate Impact Research), Anastasis Giannousakis [aut], Renato Rodrigues [aut] (Potsdam Institute for Climate Impact Research), Benjamin Leon Bodirsky [aut] (Potsdam Institute for Climate Impact Research), Debbora Leip [aut] (Potsdam Institute for Climate Impact Research), Michael Crawford [aut] (Potsdam Institute for Climate Impact Research), Ulrich Kreidenweis [aut], David Klein [aut] (Potsdam Institute for Climate Impact Research), Patrick Rein [aut] (Potsdam Institute for Climate Impact Research, )", + "Maintainer": "Jan Philipp Dietrich " + }, + "magclass": { + "Package": "magclass", + "Version": "6.21.0", + "Source": "Repository", + "Type": "Package", + "Title": "Data Class and Tools for Handling Spatial-Temporal Data", + "Date": "2025-10-06", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-4309-6431\"), role = c(\"aut\", \"cre\")), person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Markus\", \"Bonsch\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Stephen\", \"Bi\", role = \"aut\"), person(\"Kristine\", \"Karstens\", , \"karstens@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Debbora\", \"Leip\", , \"leip@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Pascal\", \"Sauer\", , \"pascal.sauer@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"aut\"), person(\"Lavinia\", \"Baumstark\", , \"lavinia@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"ctb\"), person(\"Christoph\", \"Bertram\", , \"bertram@pik-potsdam.de\", role = \"ctb\"), person(\"Anastasis\", \"Giannousakis\", , \"giannou@pik-potsdam.de\", role = \"ctb\"), person(\"David\", \"Klein\", , \"dklein@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"ctb\"), person(\"Ina\", \"Neher\", role = \"ctb\"), person(\"Michaja\", \"Pehl\", , \"pehl@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"ctb\"), person(\"Anselm\", \"Schultes\", role = \"ctb\"), person(\"Miodrag\", \"Stevanovic\", , \"miodrag@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"ctb\"), person(\"Xiaoxi\", \"Wang\", , \"wang@pik-potsdam.de\", role = \"ctb\"), person(\"Felicitas\", \"Beier\", , \"beier@pik-potsdam.de\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"ctb\"), person(\"Mika\", \"Pflüger\", role = \"ctb\"), person(\"Oliver\", \"Richters\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\"), role = \"ctb\"), person(\"Patrick\", \"Rein\", , \"patrick.rein@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0001-9454-8381\")) )", + "Description": "Data class for increased interoperability working with spatial-temporal data together with corresponding functions and methods (conversions, basic calculations and basic data manipulation). The class distinguishes between spatial, temporal and other dimensions to facilitate the development and interoperability of tools build for it. Additional features are name-based addressing of data and internal consistency checks (e.g. checking for the right data order in calculations).", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/magclass, https://doi.org/10.5281/zenodo.1158580", + "BugReports": "https://github.com/pik-piam/magclass/issues", + "Depends": [ + "R (>= 2.10.0)", + "methods" + ], + "Imports": [ + "abind", + "data.table", + "rlang", + "stats" + ], + "Suggests": [ + "covr", + "ggplot2", + "lpjmlkit", + "knitr", + "ncdf4", + "pkgconfig", + "quitte", + "raster", + "rmarkdown", + "terra", + "testthat (>= 3.1.5)", + "tibble", + "withr" + ], + "Additional_repositories": "https://pik-piam.r-universe.dev", + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.3.3", + "Config/Keywords": "tool", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/magclass", + "RemoteRef": "HEAD", + "RemoteSha": "8abb7420ebca465d32c51033be21e391810bd2de", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre] (Potsdam Institute for Climate Impact Research, ), Benjamin Leon Bodirsky [aut] (Potsdam Institute for Climate Impact Research), Markus Bonsch [aut], Florian Humpenoeder [aut] (Potsdam Institute for Climate Impact Research), Stephen Bi [aut], Kristine Karstens [aut] (Potsdam Institute for Climate Impact Research), Debbora Leip [aut] (Potsdam Institute for Climate Impact Research), Pascal Sauer [aut] (Potsdam Institute for Climate Impact Research), Lavinia Baumstark [ctb] (Potsdam Institute for Climate Impact Research), Christoph Bertram [ctb], Anastasis Giannousakis [ctb], David Klein [ctb] (Potsdam Institute for Climate Impact Research), Ina Neher [ctb], Michaja Pehl [ctb] (Potsdam Institute for Climate Impact Research), Anselm Schultes [ctb], Miodrag Stevanovic [ctb] (Potsdam Institute for Climate Impact Research), Xiaoxi Wang [ctb], Felicitas Beier [ctb] (Potsdam Institute for Climate Impact Research), Mika Pflüger [ctb], Oliver Richters [ctb] (Potsdam Institute for Climate Impact Research), Patrick Rein [aut] (Potsdam Institute for Climate Impact Research, )", + "Maintainer": "Jan Philipp Dietrich " + }, + "magic": { + "Package": "magic", + "Version": "1.6-1", + "Source": "Repository", + "Title": "Create and Investigate Magic Squares", + "Authors@R": "person(given=c(\"Robin\", \"K. S.\"), family=\"Hankin\", role = c(\"aut\",\"cre\"), email=\"hankin.robin@gmail.com\", comment = c(ORCID = \"0000-0001-5982-0415\"))", + "Depends": [ + "R (>= 2.10)", + "abind" + ], + "Description": "A collection of functions for the manipulation and analysis of arbitrarily dimensioned arrays. The original motivation for the package was the development of efficient, vectorized algorithms for the creation and investigation of magic squares and high-dimensional magic hypercubes.", + "Maintainer": "Robin K. S. Hankin ", + "License": "GPL-2", + "URL": "https://github.com/RobinHankin/magic", + "BugReports": "https://github.com/RobinHankin/magic/issues", + "NeedsCompilation": "no", + "Author": "Robin K. S. Hankin [aut, cre] ()", + "Repository": "CRAN" + }, + "magpie4": { + "Package": "magpie4", + "Version": "2.42.3", + "Source": "Repository", + "Type": "Package", + "Title": "MAgPIE outputs R package for MAgPIE version 4.x", + "Date": "2025-10-21", + "Authors@R": "c( person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\"), person(\"Miodrag\", \"Stevanovic\", , \"miodrag@pik-potsdam.de\", role = \"aut\"), person(\"Isabelle\", \"Weindl\", , \"weindl@pik-potsdam.de\", role = \"aut\"), person(\"Kristine\", \"Karstens\", , \"karstens@pik-potsdam.de\", role = \"aut\"), person(\"Xiaoxi\", \"Wang\", , \"wang@pik-potsdam.de\", role = \"aut\"), person(\"Abhijeet\", \"Mishra\", , \"mishra@pik-potsdam.de\", role = \"aut\"), person(\"Felicitas\", \"Beier\", , \"beier@pik-potsdam.de\", role = \"aut\"), person(\"Jannes\", \"Breier\", , \"breier@pik-potsdam.de\", role = \"aut\"), person(\"Amsalu Woldie\", \"Yalew\", , \"yalew@pik-potsdam.de\", role = \"aut\"), person(\"David\", \"Chen\", , \"David.Chen@pik-potsdam.de\", role = \"aut\"), person(\"Anne\", \"Biewald\", role = \"aut\"), person(\"Stephen\", \"Wirth\", , \"wirth@pik-potsdam.de\", role = \"aut\"), person(\"Patrick\", \"von Jeetze\", , \"vjeetze@pik-potsdam.de\", role = \"aut\"), person(\"Debbora\", \"Leip\", , \"leip@pik-potsdam.de\", role = \"aut\"), person(\"Michael\", \"Crawford\", , \"crawford@pik-potsdam.de\", role = \"aut\"), person(\"Marcos\", \"Alves\", , \"pedrosa@pik-potsdam.de\", role = \"aut\"), person(\"Pascal\", \"Sauer\", role = \"aut\"), person(\"Markus\", \"Bonsch\", role = \"ctb\"), person(\"Singh\", \"Vartika\", role = \"ctb\") )", + "Description": "Common output routines for extracting results from the MAgPIE framework (versions 4.x).", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/magpie4, https://doi.org/10.5281/zenodo.1158582", + "BugReports": "https://github.com/pik-piam/magpie4/issues", + "Depends": [ + "magclass (>= 2.40)", + "R (>= 3.5.0)" + ], + "Imports": [ + "dplyr", + "gdx2 (>= 0.1.6)", + "gms", + "luplot", + "luscale", + "lusweave", + "madrat (>= 3.10.0)", + "magpiesets", + "methods", + "memoise", + "mip", + "mstools (>= 0.12.1)", + "nonparaeff", + "reshape2", + "rlang", + "rworldmap (>= 1.3.8)", + "stats", + "stringr", + "utils", + "tidyr", + "GDPuc" + ], + "Suggests": [ + "covr", + "FRACTION", + "ncdf4", + "terra", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/magpie4", + "RemoteRef": "HEAD", + "RemoteSha": "cda968969be423629074d7191df62e9c2c79c53d", + "NeedsCompilation": "no", + "Author": "Benjamin Leon Bodirsky [aut, cre], Florian Humpenoeder [aut], Jan Philipp Dietrich [aut], Miodrag Stevanovic [aut], Isabelle Weindl [aut], Kristine Karstens [aut], Xiaoxi Wang [aut], Abhijeet Mishra [aut], Felicitas Beier [aut], Jannes Breier [aut], Amsalu Woldie Yalew [aut], David Chen [aut], Anne Biewald [aut], Stephen Wirth [aut], Patrick von Jeetze [aut], Debbora Leip [aut], Michael Crawford [aut], Marcos Alves [aut], Pascal Sauer [aut], Markus Bonsch [ctb], Singh Vartika [ctb]", + "Maintainer": "Benjamin Leon Bodirsky " + }, + "magpiesets": { + "Package": "magpiesets", + "Version": "0.47.0", + "Source": "Repository", + "Type": "Package", + "Title": "MAgPIE sets for R", + "Date": "2025-08-25", + "Authors@R": "c( person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\"), person(\"Abhijeet\", \"Mishra\", , \"mishra@pik-potsdam.de\", role = \"aut\"), person(\"Kristine\", \"Karstens\", , \"karstens@pik-potsdam.de\", role = \"aut\"), person(\"Isabelle\", \"Weindl\", , \"weindl@pik-potsdam.de\", role = \"aut\"), person(\"Edna\", \"Molina Bacca\", , \"mbacca@pik-potsdam.de\", role = \"aut\"), person(\"Patrick\", \"von Jeetze\", , \"vjeetze@pik-potsdam.de\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\") )", + "Description": "A library containing MAgPIE sets and other support functions.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/magpiesets, https://doi.org/10.5281/zenodo.1158588", + "BugReports": "https://github.com/pik-piam/magpiesets/issues", + "Depends": [ + "magclass (>= 6.0.3)" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "LazyLoad": "yes", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/magpiesets", + "RemoteRef": "HEAD", + "RemoteSha": "d47156c41ea2bbdcdb8125b183e6b50115b35256", + "NeedsCompilation": "no", + "Author": "Benjamin Leon Bodirsky [aut, cre], Florian Humpenoeder [aut], Abhijeet Mishra [aut], Kristine Karstens [aut], Isabelle Weindl [aut], Edna Molina Bacca [aut], Patrick von Jeetze [aut], Jan Philipp Dietrich [aut]", + "Maintainer": "Benjamin Leon Bodirsky " + }, + "magrittr": { + "Package": "magrittr", + "Version": "2.0.3", + "Source": "Repository", + "Type": "Package", + "Title": "A Forward-Pipe Operator for R", + "Authors@R": "c( person(\"Stefan Milton\", \"Bache\", , \"stefan@stefanbache.dk\", role = c(\"aut\", \"cph\"), comment = \"Original author and creator of magrittr\"), person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", role = \"aut\"), person(\"Lionel\", \"Henry\", , \"lionel@rstudio.com\", role = \"cre\"), person(\"RStudio\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides a mechanism for chaining commands with a new forward-pipe operator, %>%. This operator will forward a value, or the result of an expression, into the next function call/expression. There is flexible support for the type of right-hand side expressions. For more information, see package vignette. To quote Rene Magritte, \"Ceci n'est pas un pipe.\"", + "License": "MIT + file LICENSE", + "URL": "https://magrittr.tidyverse.org, https://github.com/tidyverse/magrittr", + "BugReports": "https://github.com/tidyverse/magrittr/issues", + "Depends": [ + "R (>= 3.4.0)" + ], + "Suggests": [ + "covr", + "knitr", + "rlang", + "rmarkdown", + "testthat" + ], + "VignetteBuilder": "knitr", + "ByteCompile": "Yes", + "Config/Needs/website": "tidyverse/tidytemplate", + "Encoding": "UTF-8", + "RoxygenNote": "7.1.2", + "NeedsCompilation": "yes", + "Author": "Stefan Milton Bache [aut, cph] (Original author and creator of magrittr), Hadley Wickham [aut], Lionel Henry [cre], RStudio [cph, fnd]", + "Maintainer": "Lionel Henry ", + "Repository": "CRAN" + }, + "maps": { + "Package": "maps", + "Version": "3.4.2", + "Source": "Repository", + "Title": "Draw Geographical Maps", + "Date": "2023-12-14", + "Author": "Original S code by Richard A. Becker and Allan R. Wilks. R version by Ray Brownrigg. Enhancements by Thomas P Minka and Alex Deckmyn.", + "Description": "Display of maps. Projection code and larger maps are in separate packages ('mapproj' and 'mapdata').", + "Depends": [ + "R (>= 3.5.0)" + ], + "Imports": [ + "graphics", + "utils" + ], + "LazyData": "yes", + "Suggests": [ + "mapproj (>= 1.2-0)", + "mapdata (>= 2.3.0)", + "sp", + "rnaturalearth" + ], + "License": "GPL-2", + "Maintainer": "Alex Deckmyn ", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "markdown": { + "Package": "markdown", + "Version": "1.13", + "Source": "Repository", + "Type": "Package", + "Title": "Render Markdown with 'commonmark'", + "Authors@R": "c( person(\"Yihui\", \"Xie\", role = c(\"aut\", \"cre\"), email = \"xie@yihui.name\", comment = c(ORCID = \"0000-0003-0645-5666\")), person(\"JJ\", \"Allaire\", role = \"aut\"), person(\"Jeffrey\", \"Horner\", role = \"aut\"), person(\"Henrik\", \"Bengtsson\", role = \"ctb\"), person(\"Jim\", \"Hester\", role = \"ctb\"), person(\"Yixuan\", \"Qiu\", role = \"ctb\"), person(\"Kohske\", \"Takahashi\", role = \"ctb\"), person(\"Adam\", \"November\", role = \"ctb\"), person(\"Nacho\", \"Caballero\", role = \"ctb\"), person(\"Jeroen\", \"Ooms\", role = \"ctb\"), person(\"Thomas\", \"Leeper\", role = \"ctb\"), person(\"Joe\", \"Cheng\", role = \"ctb\"), person(\"Andrzej\", \"Oles\", role = \"ctb\"), person(given = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Render Markdown to full and lightweight HTML/LaTeX documents with the 'commonmark' package. This package has been superseded by 'litedown'.", + "Depends": [ + "R (>= 2.11.1)" + ], + "Imports": [ + "utils", + "commonmark (>= 1.9.0)", + "xfun (>= 0.38)" + ], + "Suggests": [ + "knitr", + "rmarkdown (>= 2.18)", + "yaml", + "RCurl" + ], + "License": "MIT + file LICENSE", + "URL": "https://github.com/rstudio/markdown", + "BugReports": "https://github.com/rstudio/markdown/issues", + "RoxygenNote": "7.3.1", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Author": "Yihui Xie [aut, cre] (), JJ Allaire [aut], Jeffrey Horner [aut], Henrik Bengtsson [ctb], Jim Hester [ctb], Yixuan Qiu [ctb], Kohske Takahashi [ctb], Adam November [ctb], Nacho Caballero [ctb], Jeroen Ooms [ctb], Thomas Leeper [ctb], Joe Cheng [ctb], Andrzej Oles [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Yihui Xie ", + "Repository": "CRAN" + }, + "memoise": { + "Package": "memoise", + "Version": "2.0.1", + "Source": "Repository", + "Title": "'Memoisation' of Functions", + "Authors@R": "c(person(given = \"Hadley\", family = \"Wickham\", role = \"aut\", email = \"hadley@rstudio.com\"), person(given = \"Jim\", family = \"Hester\", role = \"aut\"), person(given = \"Winston\", family = \"Chang\", role = c(\"aut\", \"cre\"), email = \"winston@rstudio.com\"), person(given = \"Kirill\", family = \"Müller\", role = \"aut\", email = \"krlmlr+r@mailbox.org\"), person(given = \"Daniel\", family = \"Cook\", role = \"aut\", email = \"danielecook@gmail.com\"), person(given = \"Mark\", family = \"Edmondson\", role = \"ctb\", email = \"r@sunholo.com\"))", + "Description": "Cache the results of a function so that when you call it again with the same arguments it returns the previously computed value.", + "License": "MIT + file LICENSE", + "URL": "https://memoise.r-lib.org, https://github.com/r-lib/memoise", + "BugReports": "https://github.com/r-lib/memoise/issues", + "Imports": [ + "rlang (>= 0.4.10)", + "cachem" + ], + "Suggests": [ + "digest", + "aws.s3", + "covr", + "googleAuthR", + "googleCloudStorageR", + "httr", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.1.2", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut], Jim Hester [aut], Winston Chang [aut, cre], Kirill Müller [aut], Daniel Cook [aut], Mark Edmondson [ctb]", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "mime": { + "Package": "mime", + "Version": "0.13", + "Source": "Repository", + "Type": "Package", + "Title": "Map Filenames to MIME Types", + "Authors@R": "c( person(\"Yihui\", \"Xie\", role = c(\"aut\", \"cre\"), email = \"xie@yihui.name\", comment = c(ORCID = \"0000-0003-0645-5666\", URL = \"https://yihui.org\")), person(\"Jeffrey\", \"Horner\", role = \"ctb\"), person(\"Beilei\", \"Bian\", role = \"ctb\") )", + "Description": "Guesses the MIME type from a filename extension using the data derived from /etc/mime.types in UNIX-type systems.", + "Imports": [ + "tools" + ], + "License": "GPL", + "URL": "https://github.com/yihui/mime", + "BugReports": "https://github.com/yihui/mime/issues", + "RoxygenNote": "7.3.2", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Yihui Xie [aut, cre] (, https://yihui.org), Jeffrey Horner [ctb], Beilei Bian [ctb]", + "Maintainer": "Yihui Xie ", + "Repository": "CRAN" + }, + "miniUI": { + "Package": "miniUI", + "Version": "0.1.1.1", + "Source": "Repository", + "Type": "Package", + "Title": "Shiny UI Widgets for Small Screens", + "Authors@R": "c( person(\"Joe\", \"Cheng\", role = c(\"cre\", \"aut\"), email = \"joe@rstudio.com\"), person(family = \"RStudio\", role = \"cph\") )", + "Description": "Provides UI widget and layout functions for writing Shiny apps that work well on small screens.", + "License": "GPL-3", + "LazyData": "TRUE", + "Imports": [ + "shiny (>= 0.13)", + "htmltools (>= 0.3)", + "utils" + ], + "RoxygenNote": "5.0.1", + "NeedsCompilation": "no", + "Author": "Joe Cheng [cre, aut], RStudio [cph]", + "Maintainer": "Joe Cheng ", + "Repository": "CRAN" + }, + "mip": { + "Package": "mip", + "Version": "0.155.3", + "Source": "Repository", + "Type": "Package", + "Title": "Comparison of multi-model runs", + "Date": "2025-09-16", + "Authors@R": "c( person(\"David\", \"Klein\", , \"dklein@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\"), person(\"Lavinia\", \"Baumstark\", , \"baumstark@pik-potsdam.de\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\"), person(\"Miodrag\", \"Stevanovic\", , \"miodrag@pik-potsdam.de\", role = \"aut\"), person(\"Stephen\", \"Wirth\", , \"wirth@pik-potsdam.de\", role = \"aut\"), person(\"Pascal\", \"Führlich\", , \"pascal.fuehrlich@pik-potsdam.de\", role = \"aut\"), person(\"Oliver\", \"Richters\", role = \"aut\"), person(\"Tonn\", \"Rüter\", , \"tonn.rueter@pik-potsdam.de\", role = \"aut\"), person(\"Robert\", \"Salzwedel\", , \"robert.salzwedel@pik-potsdam.de\", role = \"aut\"), person(\"Fabrice\", \"Lécuyer\", , \"fabrice.lecuyer@pik-potsdam.de\", role = \"aut\") )", + "Description": "Package contains generic functions to produce comparison plots of multi-model runs.", + "License": "BSD_2_clause + file LICENSE", + "URL": "https://github.com/pik-piam/mip, https://doi.org/10.5281/zenodo.1158586", + "BugReports": "https://github.com/pik-piam/mip/issues", + "Depends": [ + "R (>= 2.10.0)", + "magclass", + "quitte (>= 0.3072)" + ], + "Imports": [ + "data.table", + "dplyr", + "ggplot2", + "gridExtra", + "htmltools", + "lusweave (>= 1.43.2)", + "plotly", + "RColorBrewer", + "reshape2", + "rlang", + "shiny", + "stringr", + "tidyr", + "trafficlight", + "withr" + ], + "Suggests": [ + "gdxrrw", + "knitr", + "rmarkdown", + "testthat" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "LazyData": "yes", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mip", + "RemoteRef": "HEAD", + "RemoteSha": "0dfa057da57edc228f48b985dbbbaba4f55a471c", + "NeedsCompilation": "no", + "Author": "David Klein [aut, cre], Jan Philipp Dietrich [aut], Lavinia Baumstark [aut], Florian Humpenoeder [aut], Miodrag Stevanovic [aut], Stephen Wirth [aut], Pascal Führlich [aut], Oliver Richters [aut], Tonn Rüter [aut], Robert Salzwedel [aut], Fabrice Lécuyer [aut]", + "Maintainer": "David Klein " + }, + "mrcommons": { + "Package": "mrcommons", + "Version": "1.64.0", + "Source": "Repository", + "Type": "Package", + "Title": "MadRat commons Input Data Library", + "Date": "2025-10-10", + "Authors@R": "c( person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = \"aut\"), person(\"Kristine\", \"Karstens\", role = \"aut\"), person(\"Lavinia\", \"Baumstark\", role = \"aut\"), person(\"Isabelle\", \"Weindl\", role = \"aut\"), person(\"Xiaoxi\", \"Wang\", role = \"aut\"), person(\"Abhijeet\", \"Mishra\", role = \"aut\"), person(\"Stephen\", \"Wirth\", role = \"aut\"), person(\"Mishko\", \"Stevanovic\", role = \"aut\"), person(\"Nele\", \"Steinmetz\", role = \"aut\"), person(\"Ulrich\", \"Kreidenweis\", role = \"aut\"), person(\"Renato\", \"Rodrigues\", role = \"aut\"), person(\"Roman\", \"Popov\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", role = \"aut\"), person(\"Anastasis\", \"Giannousakis\", role = \"aut\"), person(\"Antoine\", \"Levesque\", role = \"aut\"), person(\"David\", \"Klein\", role = \"aut\"), person(\"Ewerton\", \"Araujo\", role = \"aut\"), person(\"Eva\", \"Bleidorn\", role = \"aut\"), person(\"Felicitas\", \"Beier\", role = \"aut\"), person(\"Julian\", \"Oeser\", role = \"aut\"), person(\"Michaja\", \"Pehl\", role = \"aut\"), person(\"Debbora\", \"Leip\", role = \"aut\"), person(\"Michael\", \"Crawford\", role = \"aut\"), person(\"Edna\", \"Molina Bacca\", role = \"aut\"), person(\"Patrick\", \"von Jeetze\", role = \"aut\"), person(\"Eleonora\", \"Martinelli\", role = \"aut\"), person(\"Felix\", \"Schreyer\", role = \"aut\"), person(\"Bjoern\", \"Soergel\", role = \"aut\"), person(\"Pascal\", \"Sauer\", role = \"aut\"), person(\"David\", \"Hötten\", role = \"aut\"), person(\"Robin\", \"Hasse\", role = \"aut\"), person(\"Gabriel\", \"Abrahão\", role = \"aut\"), person(\"Pascal\", \"Weigmann\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = c(\"aut\", \"cre\")) )", + "Description": "Provides useful functions and a common structure to all the input data required to run models like MAgPIE and REMIND of model input data.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/mrcommons, https://doi.org/10.5281/zenodo.3822009", + "BugReports": "https://github.com/pik-piam/mrcommons/issues", + "Depends": [ + "GDPuc (>= 1.3.0)", + "madrat (>= 3.10.0)", + "magclass (>= 3.17)", + "mrdrivers (>= 7.1.1)", + "mrfaocore (>= 1.0.0)", + "mrlandcore (>= 1.0.0)", + "mstools (>= 0.6.0)", + "R (>= 2.10.0)" + ], + "Imports": [ + "countrycode", + "data.table", + "dplyr", + "hdf5r", + "luscale", + "magpiesets (>= 0.44.2)", + "methods", + "ncdf4", + "openxlsx", + "purrr", + "quitte", + "raster", + "readxl", + "reshape2", + "rlang", + "stringr", + "terra", + "tibble", + "tidyr", + "withr", + "zoo" + ], + "Suggests": [ + "covr", + "HARr", + "rmarkdown", + "testthat", + "XML" + ], + "Encoding": "UTF-8", + "Roxygen": "list(markdown = TRUE)", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrcommons", + "RemoteRef": "HEAD", + "RemoteSha": "848d599de23a9e3f3ff55ef84232e1e2df812d44", + "NeedsCompilation": "no", + "Author": "Benjamin Leon Bodirsky [aut], Kristine Karstens [aut], Lavinia Baumstark [aut], Isabelle Weindl [aut], Xiaoxi Wang [aut], Abhijeet Mishra [aut], Stephen Wirth [aut], Mishko Stevanovic [aut], Nele Steinmetz [aut], Ulrich Kreidenweis [aut], Renato Rodrigues [aut], Roman Popov [aut], Florian Humpenoeder [aut], Anastasis Giannousakis [aut], Antoine Levesque [aut], David Klein [aut], Ewerton Araujo [aut], Eva Bleidorn [aut], Felicitas Beier [aut], Julian Oeser [aut], Michaja Pehl [aut], Debbora Leip [aut], Michael Crawford [aut], Edna Molina Bacca [aut], Patrick von Jeetze [aut], Eleonora Martinelli [aut], Felix Schreyer [aut], Bjoern Soergel [aut], Pascal Sauer [aut], David Hötten [aut], Robin Hasse [aut], Gabriel Abrahão [aut], Pascal Weigmann [aut], Jan Philipp Dietrich [aut, cre]", + "Maintainer": "Jan Philipp Dietrich " + }, + "mrdownscale": { + "Package": "mrdownscale", + "Version": "0.42.0", + "Source": "Repository", + "Type": "Package", + "Title": "Downscale and harmonize land use data", + "Date": "2025-10-16", + "Authors@R": "c( person(\"Pascal\", \"Sauer\", , \"pascal.sauer@pik-potsdam.de\", role = c(\"aut\", \"cre\"), comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-6856-8239\")), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\", comment = c(affiliation = \"Potsdam Institute for Climate Impact Research\", ORCID = \"0000-0002-4309-6431\")) )", + "Description": "Downscale and harmonize land use data (e.g. MAgPIE or WITCH) using high resolution reference data (e.g. LUH2v2h or LUH3).", + "License": "LGPL (>= 3)", + "URL": "https://github.com/pik-piam/mrdownscale, https://doi.org/10.5281/zenodo.11244475", + "BugReports": "https://github.com/pik-piam/mrdownscale/issues", + "Depends": [ + "madrat (>= 3.23.0)", + "magclass (>= 6.19.1)", + "mstools (>= 0.8.0)", + "R (>= 4.0.0)" + ], + "Imports": [ + "luscale (>= 3.1.4)", + "magpie4 (>= 2.34.1)", + "mip", + "ncdf4", + "terra", + "utils", + "withr" + ], + "Suggests": [ + "covr", + "knitr", + "mrcommons", + "rmarkdown", + "testthat", + "usethis" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "git@github.com:pik-piam/mrdownscale", + "RemoteRef": "HEAD", + "RemoteSha": "3bdf19fc7fee446cfb506b555b7c440cb8f6ce9d", + "NeedsCompilation": "no", + "Author": "Pascal Sauer [aut, cre] (Potsdam Institute for Climate Impact Research, ), Jan Philipp Dietrich [aut] (Potsdam Institute for Climate Impact Research, )", + "Maintainer": "Pascal Sauer " + }, + "mrdrivers": { + "Package": "mrdrivers", + "Version": "7.2.0", + "Source": "Repository", + "Type": "Package", + "Title": "Create GDP and Population Scenarios", + "Authors@R": "c(person(given = \"Johannes\", family = \"Koch\", email = \"jokoch@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Bjoern\", \"Soergel\", role = \"aut\"), person(\"Deborra\", \"Leip\", role = \"aut\"), person(\"Falk\", \"Benke\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", role = \"aut\"))", + "Description": "Create GDP and population scenarios This package constructs the GDP and population scenarios used as drivers in both the REMIND and MAgPIE models.", + "License": "LGPL (>= 3)", + "URL": "https://pik-piam.github.io/mrdrivers, https://github.com/pik-piam/mrdrivers", + "BugReports": "https://github.com/pik-piam/mrdrivers/issues", + "Depends": [ + "madrat (>= 2.5.1)", + "magclass (>= 6.0.3)" + ], + "Imports": [ + "countrycode", + "dplyr", + "GDPuc (>= 1.3.0)", + "glue", + "magrittr", + "purrr", + "readr", + "readxl", + "rlang", + "tibble", + "tidyr", + "tidyselect" + ], + "Suggests": [ + "covr", + "crayon", + "knitr", + "rmarkdown", + "testthat (>= 3.0.0)", + "WDI", + "withr (>= 2.4.2)", + "yaml", + "zoo" + ], + "Encoding": "UTF-8", + "Roxygen": "list(markdown = TRUE)", + "RoxygenNote": "7.3.2", + "Date": "2025-06-06", + "Config/testthat/edition": "3", + "VignetteBuilder": "knitr", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrdrivers", + "RemoteRef": "HEAD", + "RemoteSha": "d89cf5899b2bc16e9f7f827954af1e3292001f75", + "NeedsCompilation": "no", + "Author": "Johannes Koch [aut, cre], Bjoern Soergel [aut], Deborra Leip [aut], Falk Benke [aut], Jan Philipp Dietrich [aut]", + "Maintainer": "Johannes Koch " + }, + "mrfable": { + "Package": "mrfable", + "Version": "1.6.3", + "Source": "Repository", + "Type": "Package", + "Title": "FABLE project data", + "Date": "2024-01-02", + "Authors@R": "person(\"Anastasis\", \"Giannousakis\", , \"giannou@pik-potsdam.de\", role = c(\"aut\", \"cre\"))", + "Description": "Tool for easy downloading, cleaning, and sorting foodcrop data for India taken from here: https://eands.dacnet.nic.in/APY_96_To_07.htm .", + "License": "LGPL-3 | file LICENSE", + "Depends": [ + "R (>= 2.10.0)", + "madrat (>= 2.5.0)" + ], + "Imports": [ + "dplyr", + "magclass", + "readxl", + "tidyr", + "utils" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "Repository": "https://pik-piam.r-universe.dev", + "NeedsCompilation": "no", + "Author": "Anastasis Giannousakis [aut, cre]", + "Maintainer": "Anastasis Giannousakis " + }, + "mrfactors": { + "Package": "mrfactors", + "Version": "0.9.0", + "Source": "Repository", + "Type": "Package", + "Title": "MADRaT based package on factor inputs", + "Date": "2025-08-11", + "Authors@R": "c(person(\"Debbora\", \"Leip\", , \"leip@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Edna\", \"Molina Bacca\", role = \"aut\"))", + "Description": "This package provides functions for MAgPIE input data on factor inputs to agricultural production (with a focus on capital and labor).", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/mrfactors", + "Depends": [ + "R (>= 2.10.0)", + "GDPuc (>= 1.3.0)", + "magclass (>= 3.17)", + "madrat (>= 3.10.0)", + "mrdrivers (>= 1.0.0)", + "mstools (>= 0.6.0)", + "mrcommons (>= 1.41.0)", + "mrlandcore (>= 1.2.0)" + ], + "Imports": [ + "dplyr", + "magpiesets", + "readxl", + "stringr", + "luscale" + ], + "Suggests": [ + "covr", + "Rilostat", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "git@github.com:pik-piam/mrfactors", + "RemoteRef": "HEAD", + "RemoteSha": "e0f3556b49154c7f2423fa1915bde83f4392bbb7", + "NeedsCompilation": "no", + "Author": "Debbora Leip [aut, cre], Edna Molina Bacca [aut]", + "Maintainer": "Debbora Leip " + }, + "mrfaocore": { + "Package": "mrfaocore", + "Version": "1.4.3", + "Source": "Repository", + "Type": "Package", + "Title": "madrat-based package providing core FAO-related preprocessing functions", + "Date": "2025-09-24", + "Authors@R": "c( person(\"David\", \"Chen\", , \"david.chen@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Ulrich\", \"Kreidenweis\", role = \"aut\"), person(\"Abhijeet\", \"Mishra\", role = \"aut\"), person(\"Kristine\", \"Karstens\", role = \"aut\"), person(\"Benjamin\", \"Leon Bodirsky\", role = \"aut\"), person(\"Debbora\", \"Leip\", role = \"aut\"), person(\"Mishko\", \"Stevanovic\", role = \"aut\"), person(\"Benjamin\", \"Leon Bodrisky\", role = \"aut\"), person(\"David\", \"Klein\", role = \"aut\"), person(\"Edna\", \"Molina Bacca\", role = \"aut\") )", + "Description": "This madrat-based package provides core FAO-related preprocessing functions.", + "License": "LGPL-3", + "URL": "https://github.com/pik-piam/mrfaocore", + "Depends": [ + "madrat (>= 2.20.9)", + "magclass (>= 3.17)", + "mrdrivers (>= 1.0.0)", + "mstools (>= 0.6.0)", + "GDPuc (>= 1.3.0)", + "R (>= 4.1.0)" + ], + "Imports": [ + "data.table", + "dplyr", + "magpiesets (>= 0.44.2)", + "tidyr", + "withr" + ], + "Suggests": [ + "testthat", + "XML" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrfaocore", + "RemoteRef": "HEAD", + "RemoteSha": "baeae96ae705d899f2cb407a66a518272fd8e2c2", + "NeedsCompilation": "no", + "Author": "David Chen [aut, cre], Ulrich Kreidenweis [aut], Abhijeet Mishra [aut], Kristine Karstens [aut], Benjamin Leon Bodirsky [aut], Debbora Leip [aut], Mishko Stevanovic [aut], Benjamin Leon Bodrisky [aut], David Klein [aut], Edna Molina Bacca [aut]", + "Maintainer": "David Chen " + }, + "mrland": { + "Package": "mrland", + "Version": "0.69.2", + "Source": "Repository", + "Type": "Package", + "Title": "MadRaT land data package", + "Date": "2025-10-13", + "Authors@R": "c( person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Abhijeet\", \"Mishra\", role = \"aut\"), person(\"Isabelle\", \"Weindl\", role = \"aut\"), person(\"Benjamin Leon\", \"Bodirsky\", role = \"aut\"), person(\"Xiaoxi\", \"Wang\", role = \"aut\"), person(\"Lavinia\", \"Baumstark\", role = \"aut\"), person(\"Ulrich\", \"Kreidenweis\", role = \"aut\"), person(\"David\", \"Klein\", role = \"aut\"), person(\"Nele\", \"Steinmetz\", role = \"aut\"), person(\"David\", \"Chen\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", role = \"aut\"), person(\"Patrick\", \"von Jeetze\", role = \"aut\"), person(\"Stephen\", \"Wirth\", role = \"aut\"), person(\"Felicitas\", \"Beier\", role = \"aut\"), person(\"David\", \"Hoetten\", role = \"aut\"), person(\"Pascal\", \"Sauer\", role = \"aut\"), person(\"Jake\", \"Tommey\", role = \"aut\") )", + "Description": "The package provides land related data via the madrat framework.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/mrland, https://doi.org/10.5281/zenodo.3822083", + "BugReports": "https://github.com/pik-piam/mrland/issues", + "Depends": [ + "GDPuc (>= 1.3.0)", + "madrat (>= 1.30)", + "magclass (>= 6.13.1)", + "mrcommons (>= 1.41.0)", + "mrdrivers (>= 6.0.0)", + "mrfactors (>= 0.4.0)", + "mrfaocore (>= 1.0.0)", + "mrlandcore (>= 1.0.0)", + "R (>= 2.10.0)" + ], + "Imports": [ + "countrycode", + "data.table", + "dplyr", + "magpiesets", + "mstools (>= 0.6.0)", + "ncdf4", + "raster", + "readxl", + "reshape2", + "SPEI", + "stringr", + "terra", + "withr" + ], + "Suggests": [ + "covr", + "ggplot2", + "rmarkdown", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrland", + "RemoteRef": "HEAD", + "RemoteSha": "5db7b0c7e1e73f1977bb706a43c7899f8f6c37ad", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre], Abhijeet Mishra [aut], Isabelle Weindl [aut], Benjamin Leon Bodirsky [aut], Xiaoxi Wang [aut], Lavinia Baumstark [aut], Ulrich Kreidenweis [aut], David Klein [aut], Nele Steinmetz [aut], David Chen [aut], Florian Humpenoeder [aut], Patrick von Jeetze [aut], Stephen Wirth [aut], Felicitas Beier [aut], David Hoetten [aut], Pascal Sauer [aut], Jake Tommey [aut]", + "Maintainer": "Jan Philipp Dietrich " + }, + "mrlandcore": { + "Package": "mrlandcore", + "Version": "1.6.2", + "Source": "Repository", + "Type": "Package", + "Title": "One-line description of this awesome package", + "Date": "2025-10-14", + "Authors@R": "c( person(\"Felicitas\", \"Beier\", , \"beier@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Kristine\", \"Karstens\", role = \"aut\"), person(\"Marcos\", \"Alves\", role = \"aut\"), person(\"Jan\", \"Philipp Dietrich\", role = \"aut\"), person(\"Benjamin\", \"Leon Bodirsky\", role = \"aut\"), person(\"David\", \"Hoetten\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", role = \"aut\"), person(\"Jens\", \"Heinke\", role = \"aut\"), person(\"Patrick\", \"v. Jeetze\", role = \"aut\"), person(\"Abhijeet\", \"Mishra\", role = \"aut\"), person(\"Felcitas\", \"Beier\", role = \"aut\"), person(\"Stephen\", \"Wirth\", role = \"aut\"), person(\"David\", \"Chen\", role = \"aut\"), person(\"Ulrich\", \"Kreidenweis\", role = \"aut\") )", + "Description": "One-paragraph description of this awesome package.", + "License": "LGPL-3", + "URL": "https://github.com/pik-piam/mrlandcore", + "Depends": [ + "madrat (>= 2.20.9)", + "magclass (>= 3.17)", + "mrdownscale (>= 0.41.7)", + "mrdrivers (>= 1.0.0)", + "mrfaocore (>= 1.0.0)", + "mstools (>= 0.6.0)", + "R (>= 2.10.0)" + ], + "Imports": [ + "dplyr", + "lpjclass", + "lpjmlkit", + "luscale", + "magpiesets (>= 0.44.2)", + "ncdf4", + "nleqslv", + "raster", + "SPEI", + "stringr", + "terra", + "withr" + ], + "Suggests": [ + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrlandcore", + "RemoteRef": "HEAD", + "RemoteSha": "95008885210668dd309b604e1d2341601f51c810", + "NeedsCompilation": "no", + "Author": "Felicitas Beier [aut, cre], Kristine Karstens [aut], Marcos Alves [aut], Jan Philipp Dietrich [aut], Benjamin Leon Bodirsky [aut], David Hoetten [aut], Florian Humpenoeder [aut], Jens Heinke [aut], Patrick v. Jeetze [aut], Abhijeet Mishra [aut], Felcitas Beier [aut], Stephen Wirth [aut], David Chen [aut], Ulrich Kreidenweis [aut]", + "Maintainer": "Felicitas Beier " + }, + "mrmagpie": { + "Package": "mrmagpie", + "Version": "1.64.0", + "Source": "Repository", + "Type": "Package", + "Title": "madrat based MAgPIE Input Data Library", + "Date": "2025-10-15", + "Authors@R": "c( person(\"Kristine\", \"Karstens\", , \"karstens@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\"), person(\"David\", \"Chen\", role = \"aut\"), person(\"Michael\", \"Windisch\", role = \"aut\"), person(\"Marcos\", \"Alves\", role = \"aut\"), person(\"Felicitas\", \"Beier\", , \"beier@pik-potsdam.de\", role = \"aut\"), person(\"Alexandre\", \"Köberle\", , \"alexkob@pik-potsdam.de\", role = \"aut\"), person(\"Patrick\", \"v. Jeetze\", , \"vjeetze@pik-potsdam.de\", role = \"aut\"), person(\"Abhijeet\", \"Mishra\", , \"mishra@pik-potsdam.de\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", , \"humpenoeder@pik-potsdam.de\", role = \"aut\"), person(\"Pascal\", \"Sauer\", , \"pascal.sauer@pik-potsdam.de\", role = \"aut\"), person(\"Patrick\", \"Rein\", , \"patrick.rein@pik-potsdam.de\", role = \"aut\") )", + "Description": "Provides functions for MAgPIE country and cellular input data generation.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/mrmagpie, https://doi.org/10.5281/zenodo.4319612", + "BugReports": "https://github.com/pik-piam/mrmagpie/issues", + "Depends": [ + "madrat (>= 2.8.0)", + "magclass (>= 3.17)", + "mrcommons (>= 1.41.0)", + "mrdrivers (>= 7.1.1)", + "mrland (>= 0.59.0)", + "mrlandcore (>= 1.1.0)", + "mrsoil (>= 2.0.0)", + "mrwater (>= 1.13.0)", + "R (>= 3.5.0)" + ], + "Imports": [ + "digest", + "dplyr", + "ggplot2", + "gstat", + "luplot (>= 3.64.0)", + "magpiesets", + "mstools (>= 0.6.0)", + "ncdf4", + "raster", + "readxl", + "rlang", + "sp", + "stats", + "terra (>= 1.7.18)", + "tidyr", + "withr" + ], + "Suggests": [ + "archive", + "covr", + "rmarkdown", + "zip" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrmagpie", + "RemoteRef": "HEAD", + "RemoteSha": "3172e2a981b99e7c75345c702d677c2fb0c0f182", + "NeedsCompilation": "no", + "Author": "Kristine Karstens [aut, cre], Jan Philipp Dietrich [aut], David Chen [aut], Michael Windisch [aut], Marcos Alves [aut], Felicitas Beier [aut], Alexandre Köberle [aut], Patrick v. Jeetze [aut], Abhijeet Mishra [aut], Florian Humpenoeder [aut], Pascal Sauer [aut], Patrick Rein [aut]", + "Maintainer": "Kristine Karstens " + }, + "mrsoil": { + "Package": "mrsoil", + "Version": "2.3.6", + "Source": "Repository", + "Type": "Package", + "Title": "MadRat Soil Organic Carbon Budget Library", + "Date": "2025-04-09", + "Authors@R": "c(person(\"Kristine\", \"Karstens\", email = \"karstens@pik-potsdam.de\", role = c(\"aut\",\"cre\")), person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", role = \"aut\"))", + "Description": "This packages provides functions for soil organic carbon budget for mineral soils using the steady-state method (Tier 2) of the 2019 Refinement to the 2006 IPP Guidelines for National Greenhouse Gas Inventories.", + "Depends": [ + "R(>= 2.10.0)", + "magclass(>= 5.15.4)", + "madrat(>= 1.86.0)", + "mrcommons(>= 0.11.9)", + "mrlandcore (>= 1.0.0)", + "mrdrivers(>= 1.0.0)" + ], + "Imports": [ + "magpiesets", + "mstools (>= 0.6.0)", + "readxl", + "lpjclass", + "utils", + "jsonlite" + ], + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/mrsoil, https://doi.org/10.5281/zenodo.4317933", + "BugReports": "https://github.com/pik-piam/mrsoil/issues", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Suggests": [ + "rmarkdown", + "ggplot2", + "covr" + ], + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrsoil", + "RemoteRef": "HEAD", + "RemoteSha": "16bd720b67fca2d7adb1acb5fef1a5613546e252", + "NeedsCompilation": "no", + "Author": "Kristine Karstens [aut, cre], Jan Philipp Dietrich [aut]", + "Maintainer": "Kristine Karstens " + }, + "mrvalidation": { + "Package": "mrvalidation", + "Version": "2.63.0", + "Source": "Repository", + "Type": "Package", + "Title": "madrat data preparation for validation purposes", + "Date": "2025-09-09", + "Authors@R": "c( person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Stephen\", \"Wirth\", role = \"aut\"), person(\"Kristine\", \"Karstens\", role = \"aut\"), person(\"Florian\", \"Humpenoeder\", role = \"aut\"), person(\"Mishko\", \"Stevanovic\", role = \"aut\"), person(\"Abhijeet\", \"Mishra\", role = \"aut\"), person(\"Anne\", \"Biewald\", role = \"aut\"), person(\"Isabelle\", \"Weindl\", role = \"aut\"), person(\"Felicitas\", \"Beier\", role = \"aut\"), person(\"David\", \"Chen\", role = \"aut\"), person(\"Michael\", \"Crawford\", role = \"aut\"), person(\"Debbora\", \"Leip\", role = \"aut\"), person(\"Edna\", \"Molina Bacca\", role = \"aut\"), person(\"Ulrich\", \"Kreidenweis\", role = \"aut\"), person(\"Amsalu\", \"W. Yalew\", role = \"aut\"), person(\"Patrick\", \"von Jeetze\", role = \"aut\"), person(\"Xiaoxi\", \"Wang\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", role = \"aut\"), person(\"Marcos\", \"Alves\", role = \"aut\") )", + "Description": "Package contains routines to prepare data for validation exercises.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/mrvalidation, https://doi.org/10.5281/zenodo.4317826", + "BugReports": "https://github.com/pik-piam/mrvalidation/issues", + "Depends": [ + "madrat (>= 2.11.3)", + "magclass (>= 3.17)", + "mrcommons (>= 1.41.0)", + "mrdrivers (>= 4.0.0)", + "mrfactors (>= 0.4.0)", + "mrfaocore (>= 1.0.0)", + "mrlandcore (>= 1.0.0)", + "mrmagpie (>= 1.48.0)", + "GDPuc (>= 1.3.0)", + "R (>= 2.10.0)" + ], + "Imports": [ + "dplyr", + "magpiesets", + "mstools (>= 0.5.1)", + "ncdf4", + "openxlsx", + "purrr", + "raster", + "readxl", + "reshape2", + "rlang", + "stringr", + "tidyr", + "utils", + "withr", + "rvest" + ], + "Suggests": [ + "covr" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrvalidation", + "RemoteRef": "HEAD", + "RemoteSha": "184f6f344438388859dda8c533102a192aba95de", + "NeedsCompilation": "no", + "Author": "Benjamin Leon Bodirsky [aut, cre], Stephen Wirth [aut], Kristine Karstens [aut], Florian Humpenoeder [aut], Mishko Stevanovic [aut], Abhijeet Mishra [aut], Anne Biewald [aut], Isabelle Weindl [aut], Felicitas Beier [aut], David Chen [aut], Michael Crawford [aut], Debbora Leip [aut], Edna Molina Bacca [aut], Ulrich Kreidenweis [aut], Amsalu W. Yalew [aut], Patrick von Jeetze [aut], Xiaoxi Wang [aut], Jan Philipp Dietrich [aut], Marcos Alves [aut]", + "Maintainer": "Benjamin Leon Bodirsky " + }, + "mrwater": { + "Package": "mrwater", + "Version": "1.13.8", + "Source": "Repository", + "Type": "Package", + "Title": "madrat based MAgPIE water Input Data Library", + "URL": "https://github.com/pik-piam/mrwater,", + "https": "//doi.org/10.5281/zenodo.5801680", + "License": "LGPL-3 | file LICENSE", + "Date": "2025-08-26", + "Authors@R": "c(person(\"Felicitas\", \"Beier\", email = \"beier@pik-potsdam.de\", role = c(\"aut\",\"cre\")), person(\"Jens\", \"Heinke\", email = \"heinke@pik-potsdam.de\", role = \"aut\"), person(\"Kristine\", \"Karstens\", email = \"karstens@pik-potsdam.de\", role = \"aut\"), person(\"Benjamin Leon\", \"Bodirsky\", email = \"bodirsky@pik-potsdam.de\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", role = \"aut\"))", + "Description": "Provides functions for MAgPIE cellular input data generation and stand-alone water calculations.", + "Depends": [ + "R (>= 2.10.0)", + "madrat (>= 1.72)", + "magclass (>= 6.0.0)", + "mrcommons (>= 1.41.0)", + "mrlandcore (>= 1.0.0)", + "mrland (>= 0.59.0)" + ], + "Imports": [ + "magpiesets", + "mstools (>= 0.6.0)", + "raster", + "stats", + "stringr", + "utils", + "withr" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown", + "testthat" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mrwater", + "RemoteRef": "HEAD", + "RemoteSha": "23bb96f76ce04377be120bbb3024cb6ea8ab25f4", + "NeedsCompilation": "no", + "Author": "Felicitas Beier [aut, cre], Jens Heinke [aut], Kristine Karstens [aut], Benjamin Leon Bodirsky [aut], Jan Philipp Dietrich [aut]", + "Maintainer": "Felicitas Beier " + }, + "mstools": { + "Package": "mstools", + "Version": "0.12.3", + "Source": "Repository", + "Type": "Package", + "Title": "Tool functions that can be used by several madrat-dependent or magpie4 output functions", + "Date": "2025-08-20", + "Authors@R": "c( person(\"Benjamin Leon\", \"Bodirsky\", , \"bodirsky@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Kristine\", \"Karstens\", role = \"aut\"), person(\"Felicitas\", \"Beier\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\") )", + "Description": "Tool functions that can be used by several madrat-dependent or magpie4 output functions.", + "License": "LGPL-3 | file LICENSE", + "URL": "https://github.com/pik-piam/magpie4, https://doi.org/10.5281/zenodo.1158582", + "BugReports": "https://github.com/pik-piam/magpie4/issues", + "Depends": [ + "madrat", + "magclass (>= 2.40)" + ], + "Imports": [ + "magpiesets", + "stringr", + "yaml" + ], + "Suggests": [ + "covr", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/mstools", + "RemoteRef": "HEAD", + "RemoteSha": "bdc71bc7ee6d0b0bc3e3e5663e98a5e340241186", + "NeedsCompilation": "no", + "Author": "Benjamin Leon Bodirsky [aut, cre], Kristine Karstens [aut], Felicitas Beier [aut], Jan Philipp Dietrich [aut]", + "Maintainer": "Benjamin Leon Bodirsky " + }, + "ncdf4": { + "Package": "ncdf4", + "Version": "1.22", + "Source": "Repository", + "Date": "2023-11-27", + "Title": "Interface to Unidata netCDF (Version 4 or Earlier) Format Data Files", + "Author": "David Pierce ", + "Maintainer": "David Pierce ", + "Description": "Provides a high-level R interface to data files written using Unidata's netCDF library (version 4 or earlier), which are binary data files that are portable across platforms and include metadata information in addition to the data sets. Using this package, netCDF files (either version 4 or \"classic\" version 3) can be opened and data sets read in easily. It is also easy to create new netCDF dimensions, variables, and files, in either version 3 or 4 format, and manipulate existing netCDF files. This package replaces the former ncdf package, which only worked with netcdf version 3 files. For various reasons the names of the functions have had to be changed from the names in the ncdf package. The old ncdf package is still available at the URL given below, if you need to have backward compatibility. It should be possible to have both the ncdf and ncdf4 packages installed simultaneously without a problem. However, the ncdf package does not provide an interface for netcdf version 4 files.", + "SystemRequirements": "netcdf library version 4.1 or later", + "License": "GPL (>= 3)", + "URL": "https://cirrus.ucsd.edu/~pierce/ncdf/", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "nleqslv": { + "Package": "nleqslv", + "Version": "3.3.5", + "Source": "Repository", + "Title": "Solve Systems of Nonlinear Equations", + "Date": "2023-11-25", + "Author": "Berend Hasselman", + "Maintainer": "Berend Hasselman ", + "Description": "Solve a system of nonlinear equations using a Broyden or a Newton method with a choice of global strategies such as line search and trust region. There are options for using a numerical or user supplied Jacobian, for specifying a banded numerical Jacobian and for allowing a singular or ill-conditioned Jacobian.", + "License": "GPL (>= 2)", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "nnet": { + "Package": "nnet", + "Version": "7.3-19", + "Source": "Repository", + "Priority": "recommended", + "Date": "2023-05-02", + "Depends": [ + "R (>= 3.0.0)", + "stats", + "utils" + ], + "Suggests": [ + "MASS" + ], + "Authors@R": "c(person(\"Brian\", \"Ripley\", role = c(\"aut\", \"cre\", \"cph\"), email = \"ripley@stats.ox.ac.uk\"), person(\"William\", \"Venables\", role = \"cph\"))", + "Description": "Software for feed-forward neural networks with a single hidden layer, and for multinomial log-linear models.", + "Title": "Feed-Forward Neural Networks and Multinomial Log-Linear Models", + "ByteCompile": "yes", + "License": "GPL-2 | GPL-3", + "URL": "http://www.stats.ox.ac.uk/pub/MASS4/", + "NeedsCompilation": "yes", + "Author": "Brian Ripley [aut, cre, cph], William Venables [cph]", + "Maintainer": "Brian Ripley ", + "Repository": "CRAN" + }, + "nonparaeff": { + "Package": "nonparaeff", + "Version": "0.5-13", + "Source": "Repository", + "Date": "2022-06-21", + "Title": "Nonparametric Methods for Measuring Efficiency and Productivity", + "Author": "Dong-hyun Oh , Dukrok Suh ", + "Maintainer": "Dong-hyun Oh ", + "Description": "Efficiency and productivity indices are measured using this package. This package contains functions for measuring efficiency and productivity of decision making units (DMUs) under the framework of Data Envelopment Analysis (DEA) and its variations.", + "Imports": [ + "geometry", + "Hmisc", + "lpSolve" + ], + "Suggests": [ + "pwt", + "psych" + ], + "License": "GPL (>= 2)", + "URL": "https://www.r-project.org", + "Repository": "CRAN", + "NeedsCompilation": "no" + }, + "openssl": { + "Package": "openssl", + "Version": "2.2.0", + "Source": "Repository", + "Type": "Package", + "Title": "Toolkit for Encryption, Signatures and Certificates Based on OpenSSL", + "Authors@R": "c(person(\"Jeroen\", \"Ooms\", role = c(\"aut\", \"cre\"), email = \"jeroen@berkeley.edu\", comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"Oliver\", \"Keyes\", role = \"ctb\"))", + "Description": "Bindings to OpenSSL libssl and libcrypto, plus custom SSH key parsers. Supports RSA, DSA and EC curves P-256, P-384, P-521, and curve25519. Cryptographic signatures can either be created and verified manually or via x509 certificates. AES can be used in cbc, ctr or gcm mode for symmetric encryption; RSA for asymmetric (public key) encryption or EC for Diffie Hellman. High-level envelope functions combine RSA and AES for encrypting arbitrary sized data. Other utilities include key generators, hash functions (md5, sha1, sha256, etc), base64 encoder, a secure random number generator, and 'bignum' math methods for manually performing crypto calculations on large multibyte integers.", + "License": "MIT + file LICENSE", + "URL": "https://jeroen.r-universe.dev/openssl", + "BugReports": "https://github.com/jeroen/openssl/issues", + "SystemRequirements": "OpenSSL >= 1.0.2", + "VignetteBuilder": "knitr", + "Imports": [ + "askpass" + ], + "Suggests": [ + "curl", + "testthat (>= 2.1.0)", + "digest", + "knitr", + "rmarkdown", + "jsonlite", + "jose", + "sodium" + ], + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] (), Oliver Keyes [ctb]", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "openxlsx": { + "Package": "openxlsx", + "Version": "4.2.5.2", + "Source": "Repository", + "Type": "Package", + "Title": "Read, Write and Edit xlsx Files", + "Date": "2023-02-06", + "Authors@R": "c(person(given = \"Philipp\", family = \"Schauberger\", role = c(\"aut\", \"cre\"), email = \"philipp@schauberger.co.at\"), person(given = \"Alexander\", family = \"Walker\", role = \"aut\", email = \"Alexander.Walker1989@gmail.com\"), person(given = \"Luca\", family = \"Braglia\", role = \"ctb\"), person(given = \"Joshua\", family = \"Sturm\", role = \"ctb\"), person(given = \"Jan Marvin\", family = \"Garbuszus\", role = \"ctb\", email = \"jan.garbuszus@ruhr-uni-bochum.de\"), person(given = \"Jordan Mark\", family = \"Barbone\", role = \"ctb\", email = \"jmbarbone@gmail.com\", comment = c(ORCID = \"0000-0001-9788-3628\")))", + "Description": "Simplifies the creation of Excel .xlsx files by providing a high level interface to writing, styling and editing worksheets. Through the use of 'Rcpp', read/write times are comparable to the 'xlsx' and 'XLConnect' packages with the added benefit of removing the dependency on Java.", + "License": "MIT + file LICENSE", + "URL": "https://ycphs.github.io/openxlsx/index.html, https://github.com/ycphs/openxlsx", + "BugReports": "https://github.com/ycphs/openxlsx/issues", + "Depends": [ + "R (>= 3.3.0)" + ], + "Imports": [ + "grDevices", + "methods", + "Rcpp", + "stats", + "stringi", + "utils", + "zip" + ], + "Suggests": [ + "knitr", + "rmarkdown", + "roxygen2", + "testthat" + ], + "LinkingTo": [ + "Rcpp" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.1.2", + "Collate": "'CommentClass.R' 'HyperlinkClass.R' 'RcppExports.R' 'class_definitions.R' 'StyleClass.R' 'WorkbookClass.R' 'asserts.R' 'baseXML.R' 'borderFunctions.R' 'build_workbook.R' 'chartsheet_class.R' 'conditional_formatting.R' 'data-fontSizeLookupTables.R' 'helperFunctions.R' 'loadWorkbook.R' 'onUnload.R' 'openXL.R' 'openxlsx-package.R' 'openxlsx.R' 'openxlsxCoerce.R' 'readWorkbook.R' 'sheet_data_class.R' 'utils.R' 'workbook_column_widths.R' 'workbook_read_workbook.R' 'workbook_write_data.R' 'worksheet_class.R' 'wrappers.R' 'writeData.R' 'writeDataTable.R' 'writexlsx.R' 'zzz.R'", + "NeedsCompilation": "yes", + "Author": "Philipp Schauberger [aut, cre], Alexander Walker [aut], Luca Braglia [ctb], Joshua Sturm [ctb], Jan Marvin Garbuszus [ctb], Jordan Mark Barbone [ctb] ()", + "Maintainer": "Philipp Schauberger ", + "Repository": "CRAN" + }, + "packcircles": { + "Package": "packcircles", + "Version": "0.3.6", + "Source": "Repository", + "Type": "Package", + "Title": "Circle Packing", + "Description": "Algorithms to find arrangements of non-overlapping circles.", + "Date": "2023-09-05", + "Authors@R": "c( person(\"Michael\", \"Bedward\", role = c(\"aut\", \"cre\"), email = \"michael.bedward@gmail.com\"), person(\"David\", \"Eppstein\", role = \"aut\", email = \"david.eppstein@gmail.com\", comment = \"Author of Python code for graph-based circle packing ported to C++ for this package\"), person(\"Peter\", \"Menzel\", role = \"aut\", email = \"pmenzel@gmail.com\", comment = \"Author of C code for progressive circle packing ported to C++ for this package\") )", + "URL": "https://github.com/mbedward/packcircles", + "BugReports": "https://github.com/mbedward/packcircles/issues", + "Depends": [ + "R (>= 3.2)" + ], + "Imports": [ + "Rcpp (>= 1.0.0)" + ], + "Suggests": [ + "ggiraph (>= 0.8.4)", + "ggplot2", + "knitr", + "rmarkdown", + "lpSolve" + ], + "VignetteBuilder": "knitr", + "LinkingTo": [ + "Rcpp (>= 1.0.0)" + ], + "LazyData": "true", + "License": "MIT + file LICENSE", + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Michael Bedward [aut, cre], David Eppstein [aut] (Author of Python code for graph-based circle packing ported to C++ for this package), Peter Menzel [aut] (Author of C code for progressive circle packing ported to C++ for this package)", + "Maintainer": "Michael Bedward ", + "Repository": "CRAN" + }, + "pander": { + "Package": "pander", + "Version": "0.6.5", + "Source": "Repository", + "Authors@R": "c( person(\"Gergely\", \"Daróczi\", , \"daroczig@rapporter.net\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-3149-8537\")), person(\"Roman\", \"Tsegelskyi\", , \"roman.tsegelskyi@gmail.com\", role = c(\"aut\")))", + "Title": "An R 'Pandoc' Writer", + "Type": "Package", + "Encoding": "UTF-8", + "Description": "Contains some functions catching all messages, 'stdout' and other useful information while evaluating R code and other helpers to return user specified text elements (like: header, paragraph, table, image, lists etc.) in 'pandoc' markdown or several type of R objects similarly automatically transformed to markdown format. Also capable of exporting/converting (the resulting) complex 'pandoc' documents to e.g. HTML, 'PDF', 'docx' or 'odt'. This latter reporting feature is supported in brew syntax or with a custom reference class with a smarty caching 'backend'.", + "Date": "2022-03-17", + "URL": "https://rapporter.github.io/pander/", + "BugReports": "https://github.com/rapporter/pander/issues", + "License": "AGPL-3 | file LICENSE", + "Depends": [ + "R (>= 2.15.0)" + ], + "Imports": [ + "grDevices", + "graphics", + "methods", + "utils", + "stats", + "digest", + "tools", + "Rcpp" + ], + "Suggests": [ + "grid", + "lattice", + "ggplot2 (>= 0.9.2)", + "sylly", + "sylly.en", + "logger", + "survival", + "microbenchmark", + "zoo", + "nlme", + "descr", + "MASS", + "knitr", + "rmarkdown", + "tables", + "reshape", + "memisc", + "Epi", + "randomForest", + "tseries", + "gtable", + "rms", + "forecast", + "data.table" + ], + "SystemRequirements": "pandoc (https://johnmacfarlane.net/pandoc) for exporting markdown files to other formats.", + "LinkingTo": [ + "Rcpp" + ], + "VignetteBuilder": "knitr", + "RoxygenNote": "7.1.1", + "NeedsCompilation": "yes", + "Author": "Gergely Daróczi [aut, cre] (), Roman Tsegelskyi [aut]", + "Maintainer": "Gergely Daróczi ", + "Repository": "CRAN" + }, + "patchwork": { + "Package": "patchwork", + "Version": "1.2.0", + "Source": "Repository", + "Type": "Package", + "Title": "The Composer of Plots", + "Authors@R": "person(given = \"Thomas Lin\", family = \"Pedersen\", role = c(\"cre\", \"aut\"), email = \"thomasp85@gmail.com\", comment = c(ORCID = \"0000-0002-5147-4711\"))", + "Maintainer": "Thomas Lin Pedersen ", + "Description": "The 'ggplot2' package provides a strong API for sequentially building up a plot, but does not concern itself with composition of multiple plots. 'patchwork' is a package that expands the API to allow for arbitrarily complex composition of plots by, among others, providing mathematical operators for combining multiple plots. Other packages that try to address this need (but with a different approach) are 'gridExtra' and 'cowplot'.", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "Imports": [ + "ggplot2 (>= 3.0.0)", + "gtable", + "grid", + "stats", + "grDevices", + "utils", + "graphics", + "rlang", + "cli" + ], + "RoxygenNote": "7.2.3", + "URL": "https://patchwork.data-imaginist.com, https://github.com/thomasp85/patchwork", + "BugReports": "https://github.com/thomasp85/patchwork/issues", + "Suggests": [ + "knitr", + "rmarkdown", + "gridGraphics", + "gridExtra", + "ragg", + "testthat (>= 2.1.0)", + "vdiffr", + "covr", + "png" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "gifski", + "NeedsCompilation": "no", + "Author": "Thomas Lin Pedersen [cre, aut] ()", + "Repository": "CRAN" + }, + "piamInterfaces": { + "Package": "piamInterfaces", + "Version": "0.55.1", + "Source": "Repository", + "Type": "Package", + "Title": "Project specific interfaces to REMIND / MAgPIE", + "Date": "2025-09-30", + "Authors@R": "c( person(\"Falk\", \"Benke\", , \"benke@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Oliver\", \"Richters\", role = \"aut\") )", + "Description": "Project specific interfaces to REMIND / MAgPIE.", + "License": "LGPL-3", + "URL": "https://github.com/pik-piam/piamInterfaces", + "Imports": [ + "dplyr (>= 1.1.1)", + "GDPuc", + "gms", + "jsonlite", + "magclass (>= 6.17.2)", + "mip (>= 0.150.0)", + "readxl", + "quitte (>= 0.3137.1)", + "piamutils (>= 0.0.12)", + "rlang", + "stringr", + "tibble", + "tidyr", + "tidyselect", + "yaml" + ], + "Suggests": [ + "covr", + "testthat (>= 3.2.3)", + "withr", + "writexl" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.3", + "Config/testthat/parallel": "true", + "Config/testthat/edition": "3", + "Config/testthat/start-first": "plotIntercomparison, generateIIASASubmission, checkSummations", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/piamInterfaces.git", + "RemoteRef": "HEAD", + "RemoteSha": "962c6923c4b98a00983ea00526391dc69b49105c", + "NeedsCompilation": "no", + "Author": "Falk Benke [aut, cre], Oliver Richters [aut]", + "Maintainer": "Falk Benke " + }, + "piamenv": { + "Package": "piamenv", + "Version": "0.7.2", + "Source": "Repository", + "Type": "Package", + "Title": "Package environment support for PIAM", + "Date": "2025-04-10", + "Authors@R": "c( person(\"Pascal\", \"Sauer\", , \"pascal.sauer@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Tonn\", \"Rüter\", , \"tonn.rueter@pik-potsdam.de\", role = c(\"aut\")))", + "Description": "Enables easier management of package environments, based on renv and conda.", + "License": "LGPL-3", + "URL": "https://github.com/pik-piam/piamenv", + "Imports": [ + "desc", + "methods", + "renv", + "withr" + ], + "Suggests": [ + "covr", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/piamenv", + "RemoteRef": "HEAD", + "RemoteSha": "b540807252ac35cde55657346fdf093cc89f3bf7", + "NeedsCompilation": "no", + "Author": "Pascal Sauer [aut, cre], Tonn Rüter [aut]", + "Maintainer": "Pascal Sauer " + }, + "piamutils": { + "Package": "piamutils", + "Version": "0.1.1", + "Source": "Repository", + "Type": "Package", + "Title": "Utilities for the piam-verse", + "Date": "2025-07-17", + "Authors@R": "c( person(\"Falk\", \"Benke\", , \"benke@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Christof\", \"Schötz\", role = \"aut\") )", + "Description": "This package contains utilities and helpers needed in various piam libraries.", + "License": "LGPL-3", + "URL": "https://github.com/pik-piam/piamutils", + "Imports": [ + "dplyr", + "magclass", + "magrittr", + "pkgload", + "quitte", + "rlang" + ], + "Suggests": [ + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/piamutils", + "RemoteRef": "HEAD", + "RemoteSha": "67f835400f49a619816ad02c3c797db3c0e2257a", + "NeedsCompilation": "no", + "Author": "Falk Benke [aut, cre], Christof Schötz [aut]", + "Maintainer": "Falk Benke " + }, + "pillar": { + "Package": "pillar", + "Version": "1.9.0", + "Source": "Repository", + "Title": "Coloured Formatting for Columns", + "Authors@R": "c(person(given = \"Kirill\", family = \"M\\u00fcller\", role = c(\"aut\", \"cre\"), email = \"kirill@cynkra.com\", comment = c(ORCID = \"0000-0002-1416-3412\")), person(given = \"Hadley\", family = \"Wickham\", role = \"aut\"), person(given = \"RStudio\", role = \"cph\"))", + "Description": "Provides 'pillar' and 'colonnade' generics designed for formatting columns of data using the full range of colours provided by modern terminals.", + "License": "MIT + file LICENSE", + "URL": "https://pillar.r-lib.org/, https://github.com/r-lib/pillar", + "BugReports": "https://github.com/r-lib/pillar/issues", + "Imports": [ + "cli (>= 2.3.0)", + "fansi", + "glue", + "lifecycle", + "rlang (>= 1.0.2)", + "utf8 (>= 1.1.0)", + "utils", + "vctrs (>= 0.5.0)" + ], + "Suggests": [ + "bit64", + "DBI", + "debugme", + "DiagrammeR", + "dplyr", + "formattable", + "ggplot2", + "knitr", + "lubridate", + "nanotime", + "nycflights13", + "palmerpenguins", + "rmarkdown", + "scales", + "stringi", + "survival", + "testthat (>= 3.1.1)", + "tibble", + "units (>= 0.7.2)", + "vdiffr", + "withr" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "format_multi_fuzz, format_multi_fuzz_2, format_multi, ctl_colonnade, ctl_colonnade_1, ctl_colonnade_2", + "Config/autostyle/scope": "line_breaks", + "Config/autostyle/strict": "true", + "Config/gha/extra-packages": "DiagrammeR=?ignore-before-r=3.5.0", + "Config/Needs/website": "tidyverse/tidytemplate", + "NeedsCompilation": "no", + "Author": "Kirill Müller [aut, cre] (), Hadley Wickham [aut], RStudio [cph]", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.4.4", + "Source": "Repository", + "Title": "Find Tools Needed to Build R Packages", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", role = \"aut\"), person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides functions used to build R packages. Locates compilers needed to build R packages on various platforms and ensures the PATH is configured appropriately so R can use them.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/pkgbuild, https://pkgbuild.r-lib.org", + "BugReports": "https://github.com/r-lib/pkgbuild/issues", + "Depends": [ + "R (>= 3.5)" + ], + "Imports": [ + "callr (>= 3.2.0)", + "cli (>= 3.4.0)", + "desc", + "processx", + "R6" + ], + "Suggests": [ + "covr", + "cpp11", + "knitr", + "mockery", + "Rcpp", + "rmarkdown", + "testthat (>= 3.0.0)", + "withr (>= 2.3.0)" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut], Jim Hester [aut], Gábor Csárdi [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "pkgconfig": { + "Package": "pkgconfig", + "Version": "2.0.3", + "Source": "Repository", + "Title": "Private Configuration for 'R' Packages", + "Author": "Gábor Csárdi", + "Maintainer": "Gábor Csárdi ", + "Description": "Set configuration options on a per-package basis. Options set by a given package only apply to that package, other packages are unaffected.", + "License": "MIT + file LICENSE", + "LazyData": "true", + "Imports": [ + "utils" + ], + "Suggests": [ + "covr", + "testthat", + "disposables (>= 1.0.3)" + ], + "URL": "https://github.com/r-lib/pkgconfig#readme", + "BugReports": "https://github.com/r-lib/pkgconfig/issues", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "pkgdown": { + "Package": "pkgdown", + "Version": "2.0.9", + "Source": "Repository", + "Title": "Make Static HTML Documentation for a Package", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Jay\", \"Hesselberth\", role = \"aut\", comment = c(ORCID = \"0000-0002-6299-179X\")), person(\"Maëlle\", \"Salmon\", role = \"aut\", comment = c(ORCID = \"0000-0002-2815-0399\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Generate an attractive and useful website from a source package. 'pkgdown' converts your documentation, vignettes, 'README', and more to 'HTML' making it easy to share information about your package online.", + "License": "MIT + file LICENSE", + "URL": "https://pkgdown.r-lib.org, https://github.com/r-lib/pkgdown", + "BugReports": "https://github.com/r-lib/pkgdown/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "bslib (>= 0.5.1)", + "callr (>= 3.7.3)", + "cli (>= 3.6.1)", + "desc (>= 1.4.0)", + "digest", + "downlit (>= 0.4.0)", + "fs (>= 1.4.0)", + "httr (>= 1.4.2)", + "jsonlite", + "magrittr", + "memoise", + "purrr (>= 1.0.0)", + "ragg", + "rlang (>= 1.1.0)", + "rmarkdown (>= 1.1.9007)", + "tibble", + "whisker", + "withr (>= 2.4.3)", + "xml2 (>= 1.3.1)", + "yaml" + ], + "Suggests": [ + "covr", + "diffviewer", + "evaluate", + "gert", + "htmltools", + "htmlwidgets", + "knitr", + "lifecycle", + "methods", + "openssl", + "pkgload (>= 1.0.2)", + "rsconnect", + "rstudioapi", + "rticles", + "rvest", + "sass", + "testthat (>= 3.1.3)", + "tools" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "usethis, servr", + "Config/potools/style": "explicit", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "build-articles, build-reference", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "SystemRequirements": "pandoc", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre] (), Jay Hesselberth [aut] (), Maëlle Salmon [aut] (), Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "pkgload": { + "Package": "pkgload", + "Version": "1.3.4", + "Source": "Repository", + "Title": "Simulate Package Installation and Attach", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", role = \"aut\"), person(\"Winston\", \"Chang\", role = \"aut\"), person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Lionel\", \"Henry\", , \"lionel@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"R Core team\", role = \"ctb\", comment = \"Some namespace and vignette code extracted from base R\") )", + "Description": "Simulates the process of installing a package and then attaching it. This is a key part of the 'devtools' package as it allows you to rapidly iterate while developing a package.", + "License": "GPL-3", + "URL": "https://github.com/r-lib/pkgload, https://pkgload.r-lib.org", + "BugReports": "https://github.com/r-lib/pkgload/issues", + "Depends": [ + "R (>= 3.4.0)" + ], + "Imports": [ + "cli (>= 3.3.0)", + "crayon", + "desc", + "fs", + "glue", + "methods", + "pkgbuild", + "rlang (>= 1.1.1)", + "rprojroot", + "utils", + "withr (>= 2.4.3)" + ], + "Suggests": [ + "bitops", + "covr", + "mathjaxr", + "mockr", + "pak", + "Rcpp", + "remotes", + "rstudioapi", + "testthat (>= 3.1.0)" + ], + "Config/Needs/website": "tidyverse/tidytemplate, ggplot2", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "TRUE", + "Config/testthat/start-first": "dll", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut], Winston Chang [aut], Jim Hester [aut], Lionel Henry [aut, cre], Posit Software, PBC [cph, fnd], R Core team [ctb] (Some namespace and vignette code extracted from base R)", + "Maintainer": "Lionel Henry ", + "Repository": "CRAN" + }, + "plotly": { + "Package": "plotly", + "Version": "4.10.4", + "Source": "Repository", + "Title": "Create Interactive Web Graphics via 'plotly.js'", + "Authors@R": "c(person(\"Carson\", \"Sievert\", role = c(\"aut\", \"cre\"), email = \"cpsievert1@gmail.com\", comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Chris\", \"Parmer\", role = \"aut\", email = \"chris@plot.ly\"), person(\"Toby\", \"Hocking\", role = \"aut\", email = \"tdhock5@gmail.com\"), person(\"Scott\", \"Chamberlain\", role = \"aut\", email = \"myrmecocystus@gmail.com\"), person(\"Karthik\", \"Ram\", role = \"aut\", email = \"karthik.ram@gmail.com\"), person(\"Marianne\", \"Corvellec\", role = \"aut\", email = \"marianne.corvellec@igdore.org\", comment = c(ORCID = \"0000-0002-1994-3581\")), person(\"Pedro\", \"Despouy\", role = \"aut\", email = \"pedro@plot.ly\"), person(\"Salim\", \"Brüggemann\", role = \"ctb\", email = \"salim-b@pm.me\", comment = c(ORCID = \"0000-0002-5329-5987\")), person(\"Plotly Technologies Inc.\", role = \"cph\"))", + "License": "MIT + file LICENSE", + "Description": "Create interactive web graphics from 'ggplot2' graphs and/or a custom interface to the (MIT-licensed) JavaScript library 'plotly.js' inspired by the grammar of graphics.", + "URL": "https://plotly-r.com, https://github.com/plotly/plotly.R, https://plotly.com/r/", + "BugReports": "https://github.com/plotly/plotly.R/issues", + "Depends": [ + "R (>= 3.2.0)", + "ggplot2 (>= 3.0.0)" + ], + "Imports": [ + "tools", + "scales", + "httr (>= 1.3.0)", + "jsonlite (>= 1.6)", + "magrittr", + "digest", + "viridisLite", + "base64enc", + "htmltools (>= 0.3.6)", + "htmlwidgets (>= 1.5.2.9001)", + "tidyr (>= 1.0.0)", + "RColorBrewer", + "dplyr", + "vctrs", + "tibble", + "lazyeval (>= 0.2.0)", + "rlang (>= 0.4.10)", + "crosstalk", + "purrr", + "data.table", + "promises" + ], + "Suggests": [ + "MASS", + "maps", + "hexbin", + "ggthemes", + "GGally", + "ggalluvial", + "testthat", + "knitr", + "shiny (>= 1.1.0)", + "shinytest (>= 1.3.0)", + "curl", + "rmarkdown", + "Cairo", + "broom", + "webshot", + "listviewer", + "dendextend", + "sf", + "png", + "IRdisplay", + "processx", + "plotlyGeoAssets", + "forcats", + "withr", + "palmerpenguins", + "rversions", + "reticulate", + "rsvg" + ], + "LazyData": "true", + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "Config/Needs/check": "tidyverse/ggplot2, rcmdcheck, devtools, reshape2", + "NeedsCompilation": "no", + "Author": "Carson Sievert [aut, cre] (), Chris Parmer [aut], Toby Hocking [aut], Scott Chamberlain [aut], Karthik Ram [aut], Marianne Corvellec [aut] (), Pedro Despouy [aut], Salim Brüggemann [ctb] (), Plotly Technologies Inc. [cph]", + "Maintainer": "Carson Sievert ", + "Repository": "CRAN" + }, + "plyr": { + "Package": "plyr", + "Version": "1.8.9", + "Source": "Repository", + "Title": "Tools for Splitting, Applying and Combining Data", + "Authors@R": "person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", role = c(\"aut\", \"cre\"))", + "Description": "A set of tools that solves a common set of problems: you need to break a big problem down into manageable pieces, operate on each piece and then put all the pieces back together. For example, you might want to fit a model to each spatial location or time point in your study, summarise data by panels or collapse high-dimensional arrays to simpler summary statistics. The development of 'plyr' has been generously supported by 'Becton Dickinson'.", + "License": "MIT + file LICENSE", + "URL": "http://had.co.nz/plyr, https://github.com/hadley/plyr", + "BugReports": "https://github.com/hadley/plyr/issues", + "Depends": [ + "R (>= 3.1.0)" + ], + "Imports": [ + "Rcpp (>= 0.11.0)" + ], + "Suggests": [ + "abind", + "covr", + "doParallel", + "foreach", + "iterators", + "itertools", + "tcltk", + "testthat" + ], + "LinkingTo": [ + "Rcpp" + ], + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "png": { + "Package": "png", + "Version": "0.1-8", + "Source": "Repository", + "Title": "Read and write PNG images", + "Author": "Simon Urbanek ", + "Maintainer": "Simon Urbanek ", + "Depends": [ + "R (>= 2.9.0)" + ], + "Description": "This package provides an easy and simple way to read, write and display bitmap images stored in the PNG format. It can read and write both files and in-memory raw vectors.", + "License": "GPL-2 | GPL-3", + "SystemRequirements": "libpng", + "URL": "http://www.rforge.net/png/", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "praise": { + "Package": "praise", + "Version": "1.0.0", + "Source": "Repository", + "Title": "Praise Users", + "Author": "Gabor Csardi, Sindre Sorhus", + "Maintainer": "Gabor Csardi ", + "Description": "Build friendly R packages that praise their users if they have done something good, or they just need it to feel better.", + "License": "MIT + file LICENSE", + "LazyData": "true", + "URL": "https://github.com/gaborcsardi/praise", + "BugReports": "https://github.com/gaborcsardi/praise/issues", + "Suggests": [ + "testthat" + ], + "Collate": "'adjective.R' 'adverb.R' 'exclamation.R' 'verb.R' 'rpackage.R' 'package.R'", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "prettyunits": { + "Package": "prettyunits", + "Version": "1.2.0", + "Source": "Repository", + "Title": "Pretty, Human Readable Formatting of Quantities", + "Authors@R": "c( person(\"Gabor\", \"Csardi\", email=\"csardi.gabor@gmail.com\", role=c(\"aut\", \"cre\")), person(\"Bill\", \"Denney\", email=\"wdenney@humanpredictions.com\", role=c(\"ctb\"), comment=c(ORCID=\"0000-0002-5759-428X\")), person(\"Christophe\", \"Regouby\", email=\"christophe.regouby@free.fr\", role=c(\"ctb\")) )", + "Description": "Pretty, human readable formatting of quantities. Time intervals: '1337000' -> '15d 11h 23m 20s'. Vague time intervals: '2674000' -> 'about a month ago'. Bytes: '1337' -> '1.34 kB'. Rounding: '99' with 3 significant digits -> '99.0' p-values: '0.00001' -> '<0.0001'. Colors: '#FF0000' -> 'red'. Quantities: '1239437' -> '1.24 M'.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/prettyunits", + "BugReports": "https://github.com/r-lib/prettyunits/issues", + "Depends": [ + "R(>= 2.10)" + ], + "Suggests": [ + "codetools", + "covr", + "testthat" + ], + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Author": "Gabor Csardi [aut, cre], Bill Denney [ctb] (), Christophe Regouby [ctb]", + "Maintainer": "Gabor Csardi ", + "Repository": "CRAN" + }, + "processx": { + "Package": "processx", + "Version": "3.8.4", + "Source": "Repository", + "Title": "Execute and Control System Processes", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\", \"cph\"), comment = c(ORCID = \"0000-0001-7098-9676\")), person(\"Winston\", \"Chang\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"Ascent Digital Services\", role = c(\"cph\", \"fnd\")) )", + "Description": "Tools to run system processes in the background. It can check if a background process is running; wait on a background process to finish; get the exit status of finished processes; kill background processes. It can read the standard output and error of the processes, using non-blocking connections. 'processx' can poll a process for standard output or error, with a timeout. It can also poll several processes at once.", + "License": "MIT + file LICENSE", + "URL": "https://processx.r-lib.org, https://github.com/r-lib/processx", + "BugReports": "https://github.com/r-lib/processx/issues", + "Depends": [ + "R (>= 3.4.0)" + ], + "Imports": [ + "ps (>= 1.2.0)", + "R6", + "utils" + ], + "Suggests": [ + "callr (>= 3.7.3)", + "cli (>= 3.3.0)", + "codetools", + "covr", + "curl", + "debugme", + "parallel", + "rlang (>= 1.0.2)", + "testthat (>= 3.0.0)", + "webfakes", + "withr" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1.9000", + "NeedsCompilation": "yes", + "Author": "Gábor Csárdi [aut, cre, cph] (), Winston Chang [aut], Posit Software, PBC [cph, fnd], Ascent Digital Services [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "profvis": { + "Package": "profvis", + "Version": "0.3.8", + "Source": "Repository", + "Title": "Interactive Visualizations for Profiling R Code", + "Authors@R": "c( person(\"Winston\", \"Chang\", email = \"winston@rstudio.com\", role = c(\"aut\", \"cre\")), person(\"Javier\", \"Luraschi\", email = \"javier@rstudio.com\", role = \"aut\"), person(\"Timothy\", \"Mastny\", role = \"aut\"), person(family = \"RStudio\", role = \"cph\"), person(family = \"jQuery Foundation\", role = \"cph\", comment = \"jQuery library\"), person(family = \"jQuery contributors\", role = c(\"ctb\", \"cph\"), comment = \"jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt\"), person(\"Mike\", \"Bostock\", role = c(\"ctb\", \"cph\"), comment = \"D3 library\"), person(family = \"D3 contributors\", role = \"ctb\", comment = \"D3 library\"), person(\"Ivan\", \"Sagalaev\", role = c(\"ctb\", \"cph\"), comment = \"highlight.js library\") )", + "Description": "Interactive visualizations for profiling R code.", + "Depends": [ + "R (>= 3.0)" + ], + "Imports": [ + "htmlwidgets (>= 0.3.2)", + "purrr", + "rlang (>= 0.4.9)", + "stringr", + "vctrs" + ], + "License": "GPL-3 | file LICENSE", + "Suggests": [ + "knitr", + "ggplot2", + "rmarkdown", + "testthat (>= 3.0.0)", + "devtools", + "shiny", + "htmltools" + ], + "RoxygenNote": "7.2.3", + "URL": "https://rstudio.github.io/profvis/", + "Encoding": "UTF-8", + "Config/testthat/edition": "3", + "NeedsCompilation": "yes", + "Author": "Winston Chang [aut, cre], Javier Luraschi [aut], Timothy Mastny [aut], RStudio [cph], jQuery Foundation [cph] (jQuery library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt), Mike Bostock [ctb, cph] (D3 library), D3 contributors [ctb] (D3 library), Ivan Sagalaev [ctb, cph] (highlight.js library)", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "progress": { + "Package": "progress", + "Version": "1.2.3", + "Source": "Repository", + "Title": "Terminal Progress Bars", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Rich\", \"FitzJohn\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Configurable Progress bars, they may include percentage, elapsed time, and/or the estimated completion time. They work in terminals, in 'Emacs' 'ESS', 'RStudio', 'Windows' 'Rgui' and the 'macOS' 'R.app'. The package also provides a 'C++' 'API', that works with or without 'Rcpp'.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/progress#readme, http://r-lib.github.io/progress/", + "BugReports": "https://github.com/r-lib/progress/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "crayon", + "hms", + "prettyunits", + "R6" + ], + "Suggests": [ + "Rcpp", + "testthat (>= 3.0.0)", + "withr" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre], Rich FitzJohn [aut], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "promises": { + "Package": "promises", + "Version": "1.3.0", + "Source": "Repository", + "Type": "Package", + "Title": "Abstractions for Promise-Based Asynchronous Programming", + "Authors@R": "c( person(\"Joe\", \"Cheng\", , \"joe@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides fundamental abstractions for doing asynchronous programming in R using promises. Asynchronous programming is useful for allowing a single R process to orchestrate multiple tasks in the background while also attending to something else. Semantics are similar to 'JavaScript' promises, but with a syntax that is idiomatic R.", + "License": "MIT + file LICENSE", + "URL": "https://rstudio.github.io/promises/, https://github.com/rstudio/promises", + "BugReports": "https://github.com/rstudio/promises/issues", + "Imports": [ + "fastmap (>= 1.1.0)", + "later", + "magrittr (>= 1.5)", + "R6", + "Rcpp", + "rlang", + "stats" + ], + "Suggests": [ + "future (>= 1.21.0)", + "knitr", + "purrr", + "rmarkdown", + "spelling", + "testthat", + "vembedr" + ], + "LinkingTo": [ + "later", + "Rcpp" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "rsconnect", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "yes", + "Author": "Joe Cheng [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Joe Cheng ", + "Repository": "CRAN" + }, + "proxy": { + "Package": "proxy", + "Version": "0.4-27", + "Source": "Repository", + "Type": "Package", + "Title": "Distance and Similarity Measures", + "Authors@R": "c(person(given = \"David\", family = \"Meyer\", role = c(\"aut\", \"cre\"), email = \"David.Meyer@R-project.org\"), person(given = \"Christian\", family = \"Buchta\", role = \"aut\"))", + "Description": "Provides an extensible framework for the efficient calculation of auto- and cross-proximities, along with implementations of the most popular ones.", + "Depends": [ + "R (>= 3.4.0)" + ], + "Imports": [ + "stats", + "utils" + ], + "Suggests": [ + "cba" + ], + "Collate": "registry.R database.R dist.R similarities.R dissimilarities.R util.R seal.R", + "License": "GPL-2", + "NeedsCompilation": "yes", + "Author": "David Meyer [aut, cre], Christian Buchta [aut]", + "Maintainer": "David Meyer ", + "Repository": "CRAN" + }, + "ps": { + "Package": "ps", + "Version": "1.7.6", + "Source": "Repository", + "Title": "List, Query, Manipulate System Processes", + "Authors@R": "c( person(\"Jay\", \"Loden\", role = \"aut\"), person(\"Dave\", \"Daeschler\", role = \"aut\"), person(\"Giampaolo\", \"Rodola'\", role = \"aut\"), person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "List, query and manipulate all system processes, on 'Windows', 'Linux' and 'macOS'.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/ps, https://ps.r-lib.org/", + "BugReports": "https://github.com/r-lib/ps/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Imports": [ + "utils" + ], + "Suggests": [ + "callr", + "covr", + "curl", + "pillar", + "pingr", + "processx (>= 3.1.0)", + "R6", + "rlang", + "testthat (>= 3.0.0)", + "webfakes" + ], + "Biarch": "true", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Jay Loden [aut], Dave Daeschler [aut], Giampaolo Rodola' [aut], Gábor Csárdi [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "purrr": { + "Package": "purrr", + "Version": "1.0.4", + "Source": "Repository", + "Title": "Functional Programming Tools", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Lionel\", \"Henry\", , \"lionel@posit.co\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\"), comment = c(ROR = \"03wc8by49\")) )", + "Description": "A complete and consistent functional programming toolkit for R.", + "License": "MIT + file LICENSE", + "URL": "https://purrr.tidyverse.org/, https://github.com/tidyverse/purrr", + "BugReports": "https://github.com/tidyverse/purrr/issues", + "Depends": [ + "R (>= 4.0)" + ], + "Imports": [ + "cli (>= 3.6.1)", + "lifecycle (>= 1.0.3)", + "magrittr (>= 1.5.0)", + "rlang (>= 1.1.1)", + "vctrs (>= 0.6.3)" + ], + "Suggests": [ + "covr", + "dplyr (>= 0.7.8)", + "httr", + "knitr", + "lubridate", + "rmarkdown", + "testthat (>= 3.0.0)", + "tibble", + "tidyselect" + ], + "LinkingTo": [ + "cli" + ], + "VignetteBuilder": "knitr", + "Biarch": "true", + "Config/build/compilation-database": "true", + "Config/Needs/website": "tidyverse/tidytemplate, tidyr", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "TRUE", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre] (), Lionel Henry [aut], Posit Software, PBC [cph, fnd] (03wc8by49)", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "qualV": { + "Package": "qualV", + "Version": "0.3-5", + "Source": "Repository", + "Title": "Qualitative Validation Methods", + "Authors@R": "c(person(\"K. Gerald\", \"van den Boogaart\", role = c(\"aut\", \"ths\"), comment = c(ORCID = \"0000-0003-4646-943X\")), person(\"Stefanie\", \"Rost\", role = \"aut\"), person(\"Thomas\", \"Petzoldt\", role = c(\"aut\", \"ths\", \"cre\"), comment=c(ORCID = \"0000-0002-4951-6468\"), email = \"thomas.petzoldt@tu-dresden.de\"))", + "Author": "K. Gerald van den Boogaart [aut, ths] (), Stefanie Rost [aut], Thomas Petzoldt [aut, ths, cre] ()", + "Description": "Qualitative methods for the validation of dynamic models. It contains (i) an orthogonal set of deviance measures for absolute, relative and ordinal scale and (ii) approaches accounting for time shifts. The first approach transforms time to take time delays and speed differences into account. The second divides the time series into interval units according to their main features and finds the longest common subsequence (LCS) using a dynamic programming algorithm.", + "Maintainer": "Thomas Petzoldt ", + "Depends": [ + "R (>= 2.0.0)", + "KernSmooth" + ], + "Imports": [ + "graphics", + "grDevices", + "stats", + "utils" + ], + "License": "GPL (>= 2)", + "URL": "http://qualV.R-Forge.R-Project.org/", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "quitte": { + "Package": "quitte", + "Version": "0.3146.2", + "Source": "Repository", + "Type": "Package", + "Title": "Bits and pieces of code to use with quitte-style data frames", + "Date": "2025-09-24", + "Authors@R": "c( person(\"Michaja\", \"Pehl\", , \"pehl@pik-potsdam.de\", role = c(\"aut\", \"cre\")), person(\"Nico\", \"Bauer\", , \"nicolasb@pik-potsdam.de\", role = \"aut\"), person(\"Jérôme\", \"Hilaire\", , \"jeromehilaire@pik-potsdam.de\", role = \"aut\"), person(\"Antoine\", \"Levesque\", , \"levesque@pik-potsdam.de\", role = \"aut\"), person(\"Gunnar\", \"Luderer\", , \"luderer@pik-potsdam.de\", role = \"aut\"), person(\"Anselm\", \"Schultes\", , \"schultes@pik-potsdam.de\", role = \"aut\"), person(\"Jan Philipp\", \"Dietrich\", , \"dietrich@pik-potsdam.de\", role = \"aut\"), person(\"Oliver\", \"Richters\", role = \"aut\"), person(\"Tonn\", \"Rüter\", , \"tonn.rueter@pik-potsdam.de\", role = \"aut\") )", + "Maintainer": "Falk Benke ", + "Description": "A collection of functions for easily dealing with quitte-style data frames, doing multi-model comparisons and plots.", + "License": "GPL-2", + "URL": "https://github.com/pik-piam/quitte", + "BugReports": "https://github.com/pik-piam/quitte/issues", + "Depends": [ + "R (>= 4.0)" + ], + "Imports": [ + "cli", + "countrycode", + "dplyr (>= 1.1.1)", + "forcats (>= 1.0.0)", + "ggplot2 (>= 4.0.0)", + "gms (>= 0.17.0)", + "glue", + "lazyeval", + "lifecycle", + "lubridate", + "magclass", + "magrittr", + "methods", + "plyr", + "purrr", + "readr", + "readxl", + "reshape2", + "rlang", + "stats", + "stringr", + "tibble", + "tidyr", + "tidyselect", + "writexl", + "zoo" + ], + "Suggests": [ + "covr", + "gamstransfer", + "gdxrrw", + "knitr", + "mip", + "rmarkdown", + "testthat (>= 3.2.0)", + "tidyverse", + "withr" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "LazyData": "TRUE", + "RoxygenNote": "7.3.3", + "Roxygen": "list(markdown = TRUE)", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/quitte", + "RemoteRef": "HEAD", + "RemoteSha": "72995223999439b0a4f95ccf30bdd9540549b4eb", + "NeedsCompilation": "no", + "Author": "Michaja Pehl [aut, cre], Nico Bauer [aut], Jérôme Hilaire [aut], Antoine Levesque [aut], Gunnar Luderer [aut], Anselm Schultes [aut], Jan Philipp Dietrich [aut], Oliver Richters [aut], Tonn Rüter [aut]" + }, + "ragg": { + "Package": "ragg", + "Version": "1.5.0", + "Source": "Repository", + "Type": "Package", + "Title": "Graphic Devices Based on AGG", + "Authors@R": "c( person(\"Thomas Lin\", \"Pedersen\", , \"thomas.pedersen@posit.co\", role = c(\"cre\", \"aut\"), comment = c(ORCID = \"0000-0002-5147-4711\")), person(\"Maxim\", \"Shemanarev\", role = c(\"aut\", \"cph\"), comment = \"Author of AGG\"), person(\"Tony\", \"Juricic\", , \"tonygeek@yahoo.com\", role = c(\"ctb\", \"cph\"), comment = \"Contributor to AGG\"), person(\"Milan\", \"Marusinec\", , \"milan@marusinec.sk\", role = c(\"ctb\", \"cph\"), comment = \"Contributor to AGG\"), person(\"Spencer\", \"Garrett\", role = \"ctb\", comment = \"Contributor to AGG\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\"), comment = c(ROR = \"03wc8by49\")) )", + "Maintainer": "Thomas Lin Pedersen ", + "Description": "Anti-Grain Geometry (AGG) is a high-quality and high-performance 2D drawing library. The 'ragg' package provides a set of graphic devices based on AGG to use as alternative to the raster devices provided through the 'grDevices' package.", + "License": "MIT + file LICENSE", + "URL": "https://ragg.r-lib.org, https://github.com/r-lib/ragg", + "BugReports": "https://github.com/r-lib/ragg/issues", + "Imports": [ + "systemfonts (>= 1.0.3)", + "textshaping (>= 0.3.0)" + ], + "Suggests": [ + "covr", + "graphics", + "grid", + "testthat (>= 3.0.0)" + ], + "LinkingTo": [ + "systemfonts", + "textshaping" + ], + "Config/build/compilation-database": "true", + "Config/Needs/website": "ggplot2, devoid, magick, bench, tidyr, ggridges, hexbin, sessioninfo, pkgdown, tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/usethis/last-upkeep": "2025-04-25", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "SystemRequirements": "freetype2, libpng, libtiff, libjpeg, libwebp, libwebpmux", + "NeedsCompilation": "yes", + "Author": "Thomas Lin Pedersen [cre, aut] (ORCID: ), Maxim Shemanarev [aut, cph] (Author of AGG), Tony Juricic [ctb, cph] (Contributor to AGG), Milan Marusinec [ctb, cph] (Contributor to AGG), Spencer Garrett [ctb] (Contributor to AGG), Posit Software, PBC [cph, fnd] (ROR: )", + "Repository": "CRAN" + }, + "rappdirs": { + "Package": "rappdirs", + "Version": "0.3.3", + "Source": "Repository", + "Type": "Package", + "Title": "Application Directories: Determine Where to Save Data, Caches, and Logs", + "Authors@R": "c(person(given = \"Hadley\", family = \"Wickham\", role = c(\"trl\", \"cre\", \"cph\"), email = \"hadley@rstudio.com\"), person(given = \"RStudio\", role = \"cph\"), person(given = \"Sridhar\", family = \"Ratnakumar\", role = \"aut\"), person(given = \"Trent\", family = \"Mick\", role = \"aut\"), person(given = \"ActiveState\", role = \"cph\", comment = \"R/appdir.r, R/cache.r, R/data.r, R/log.r translated from appdirs\"), person(given = \"Eddy\", family = \"Petrisor\", role = \"ctb\"), person(given = \"Trevor\", family = \"Davis\", role = c(\"trl\", \"aut\")), person(given = \"Gabor\", family = \"Csardi\", role = \"ctb\"), person(given = \"Gregory\", family = \"Jefferis\", role = \"ctb\"))", + "Description": "An easy way to determine which directories on the users computer you should use to save data, caches and logs. A port of Python's 'Appdirs' () to R.", + "License": "MIT + file LICENSE", + "URL": "https://rappdirs.r-lib.org, https://github.com/r-lib/rappdirs", + "BugReports": "https://github.com/r-lib/rappdirs/issues", + "Depends": [ + "R (>= 3.2)" + ], + "Suggests": [ + "roxygen2", + "testthat (>= 3.0.0)", + "covr", + "withr" + ], + "Copyright": "Original python appdirs module copyright (c) 2010 ActiveState Software Inc. R port copyright Hadley Wickham, RStudio. See file LICENSE for details.", + "Encoding": "UTF-8", + "RoxygenNote": "7.1.1", + "Config/testthat/edition": "3", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [trl, cre, cph], RStudio [cph], Sridhar Ratnakumar [aut], Trent Mick [aut], ActiveState [cph] (R/appdir.r, R/cache.r, R/data.r, R/log.r translated from appdirs), Eddy Petrisor [ctb], Trevor Davis [trl, aut], Gabor Csardi [ctb], Gregory Jefferis [ctb]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "raster": { + "Package": "raster", + "Version": "3.6-26", + "Source": "Repository", + "Type": "Package", + "Title": "Geographic Data Analysis and Modeling", + "Date": "2023-10-12", + "Imports": [ + "Rcpp", + "methods", + "terra (>= 1.7-29)" + ], + "LinkingTo": [ + "Rcpp" + ], + "Depends": [ + "sp (>= 1.4-5)", + "R (>= 3.5.0)" + ], + "Suggests": [ + "ncdf4", + "igraph", + "tcltk", + "parallel", + "rasterVis", + "MASS", + "sf", + "tinytest", + "gstat", + "fields", + "exactextractr" + ], + "Description": "Reading, writing, manipulating, analyzing and modeling of spatial data. This package has been superseded by the \"terra\" package .", + "License": "GPL (>= 3)", + "URL": "https://rspatial.org/raster", + "BugReports": "https://github.com/rspatial/raster/issues/", + "Authors@R": "c( person(\"Robert J.\", \"Hijmans\", role = c(\"cre\", \"aut\"), email = \"r.hijmans@gmail.com\", comment = c(ORCID = \"0000-0001-5872-2872\")), person(\"Jacob\", \"van Etten\", role = \"ctb\"), person(\"Michael\", \"Sumner\", role = \"ctb\"), person(\"Joe\", \"Cheng\", role = \"ctb\"), person(\"Dan\", \"Baston\", role = \"ctb\"), person(\"Andrew\", \"Bevan\", role = \"ctb\"), person(\"Roger\", \"Bivand\", role = \"ctb\"), person(\"Lorenzo\", \"Busetto\", role = \"ctb\"), person(\"Mort\", \"Canty\", role = \"ctb\"), person(\"Ben\", \"Fasoli\", role = \"ctb\"), person(\"David\", \"Forrest\", role = \"ctb\"), person(\"Aniruddha\", \"Ghosh\", role = \"ctb\"), person(\"Duncan\", \"Golicher\", role = \"ctb\"), person(\"Josh\", \"Gray\", role = \"ctb\"), person(\"Jonathan A.\", \"Greenberg\", role = \"ctb\"), person(\"Paul\", \"Hiemstra\", role = \"ctb\"), person(\"Kassel\", \"Hingee\", role = \"ctb\"), person(\"Alex\", \"Ilich\", role = \"ctb\"), person(\"Institute for Mathematics Applied Geosciences\", role=\"cph\"), person(\"Charles\", \"Karney\", role = \"ctb\"), person(\"Matteo\", \"Mattiuzzi\", role = \"ctb\"), person(\"Steven\", \"Mosher\", role = \"ctb\"), person(\"Babak\", \"Naimi\", role = \"ctb\"),\t person(\"Jakub\", \"Nowosad\", role = \"ctb\"), person(\"Edzer\", \"Pebesma\", role = \"ctb\"), person(\"Oscar\", \"Perpinan Lamigueiro\", role = \"ctb\"), person(\"Etienne B.\", \"Racine\", role = \"ctb\"), person(\"Barry\", \"Rowlingson\", role = \"ctb\"), person(\"Ashton\", \"Shortridge\", role = \"ctb\"), person(\"Bill\", \"Venables\", role = \"ctb\"), person(\"Rafael\", \"Wueest\", role = \"ctb\") )", + "NeedsCompilation": "yes", + "Author": "Robert J. Hijmans [cre, aut] (), Jacob van Etten [ctb], Michael Sumner [ctb], Joe Cheng [ctb], Dan Baston [ctb], Andrew Bevan [ctb], Roger Bivand [ctb], Lorenzo Busetto [ctb], Mort Canty [ctb], Ben Fasoli [ctb], David Forrest [ctb], Aniruddha Ghosh [ctb], Duncan Golicher [ctb], Josh Gray [ctb], Jonathan A. Greenberg [ctb], Paul Hiemstra [ctb], Kassel Hingee [ctb], Alex Ilich [ctb], Institute for Mathematics Applied Geosciences [cph], Charles Karney [ctb], Matteo Mattiuzzi [ctb], Steven Mosher [ctb], Babak Naimi [ctb], Jakub Nowosad [ctb], Edzer Pebesma [ctb], Oscar Perpinan Lamigueiro [ctb], Etienne B. Racine [ctb], Barry Rowlingson [ctb], Ashton Shortridge [ctb], Bill Venables [ctb], Rafael Wueest [ctb]", + "Maintainer": "Robert J. Hijmans ", + "Repository": "CRAN" + }, + "rcmdcheck": { + "Package": "rcmdcheck", + "Version": "1.4.0", + "Source": "Repository", + "Title": "Run 'R CMD check' from 'R' and Capture Results", + "Authors@R": "person(given = \"Gábor\", family = \"Csárdi\", role = c(\"cre\", \"aut\"), email = \"csardi.gabor@gmail.com\")", + "Description": "Run 'R CMD check' from 'R' and capture the results of the individual checks. Supports running checks in the background, timeouts, pretty printing and comparing check results.", + "License": "MIT + file LICENSE", + "URL": "https://r-lib.github.io/rcmdcheck/, https://github.com/r-Lib/rcmdcheck#readme", + "BugReports": "https://github.com/r-Lib/rcmdcheck/issues", + "Imports": [ + "callr (>= 3.1.1.9000)", + "cli (>= 3.0.0)", + "curl", + "desc (>= 1.2.0)", + "digest", + "pkgbuild", + "prettyunits", + "R6", + "rprojroot", + "sessioninfo (>= 1.1.1)", + "utils", + "withr", + "xopen" + ], + "Suggests": [ + "covr", + "knitr", + "mockery", + "processx", + "ps", + "rmarkdown", + "svglite", + "testthat", + "webfakes" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.1.2", + "Config/testthat/edition": "3", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [cre, aut]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "readr": { + "Package": "readr", + "Version": "2.1.5", + "Source": "Repository", + "Title": "Read Rectangular Text Data", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Romain\", \"Francois\", role = \"ctb\"), person(\"Jennifer\", \"Bryan\", , \"jenny@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-6983-2759\")), person(\"Shelby\", \"Bearrows\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"https://github.com/mandreyel/\", role = \"cph\", comment = \"mio library\"), person(\"Jukka\", \"Jylänki\", role = c(\"ctb\", \"cph\"), comment = \"grisu3 implementation\"), person(\"Mikkel\", \"Jørgensen\", role = c(\"ctb\", \"cph\"), comment = \"grisu3 implementation\") )", + "Description": "The goal of 'readr' is to provide a fast and friendly way to read rectangular data (like 'csv', 'tsv', and 'fwf'). It is designed to flexibly parse many types of data found in the wild, while still cleanly failing when data unexpectedly changes.", + "License": "MIT + file LICENSE", + "URL": "https://readr.tidyverse.org, https://github.com/tidyverse/readr", + "BugReports": "https://github.com/tidyverse/readr/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli (>= 3.2.0)", + "clipr", + "crayon", + "hms (>= 0.4.1)", + "lifecycle (>= 0.2.0)", + "methods", + "R6", + "rlang", + "tibble", + "utils", + "vroom (>= 1.6.0)" + ], + "Suggests": [ + "covr", + "curl", + "datasets", + "knitr", + "rmarkdown", + "spelling", + "stringi", + "testthat (>= 3.2.0)", + "tzdb (>= 0.1.1)", + "waldo", + "withr", + "xml2" + ], + "LinkingTo": [ + "cpp11", + "tzdb (>= 0.1.1)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse, tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "false", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut], Jim Hester [aut], Romain Francois [ctb], Jennifer Bryan [aut, cre] (), Shelby Bearrows [ctb], Posit Software, PBC [cph, fnd], https://github.com/mandreyel/ [cph] (mio library), Jukka Jylänki [ctb, cph] (grisu3 implementation), Mikkel Jørgensen [ctb, cph] (grisu3 implementation)", + "Maintainer": "Jennifer Bryan ", + "Repository": "CRAN" + }, + "readxl": { + "Package": "readxl", + "Version": "1.4.5", + "Source": "Repository", + "Title": "Read Excel Files", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Jennifer\", \"Bryan\", , \"jenny@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-6983-2759\")), person(\"Posit, PBC\", role = c(\"cph\", \"fnd\"), comment = \"Copyright holder of all R code and all C/C++ code without explicit copyright attribution\"), person(\"Marcin\", \"Kalicinski\", role = c(\"ctb\", \"cph\"), comment = \"Author of included RapidXML code\"), person(\"Komarov Valery\", role = c(\"ctb\", \"cph\"), comment = \"Author of included libxls code\"), person(\"Christophe Leitienne\", role = c(\"ctb\", \"cph\"), comment = \"Author of included libxls code\"), person(\"Bob Colbert\", role = c(\"ctb\", \"cph\"), comment = \"Author of included libxls code\"), person(\"David Hoerl\", role = c(\"ctb\", \"cph\"), comment = \"Author of included libxls code\"), person(\"Evan Miller\", role = c(\"ctb\", \"cph\"), comment = \"Author of included libxls code\") )", + "Description": "Import excel files into R. Supports '.xls' via the embedded 'libxls' C library and '.xlsx' via the embedded 'RapidXML' C++ library . Works on Windows, Mac and Linux without external dependencies.", + "License": "MIT + file LICENSE", + "URL": "https://readxl.tidyverse.org, https://github.com/tidyverse/readxl", + "BugReports": "https://github.com/tidyverse/readxl/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cellranger", + "tibble (>= 2.0.1)", + "utils" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown", + "testthat (>= 3.1.6)", + "withr" + ], + "LinkingTo": [ + "cpp11 (>= 0.4.0)", + "progress" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate, tidyverse", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "Note": "libxls v1.6.3 c199d13", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut] (), Jennifer Bryan [aut, cre] (), Posit, PBC [cph, fnd] (Copyright holder of all R code and all C/C++ code without explicit copyright attribution), Marcin Kalicinski [ctb, cph] (Author of included RapidXML code), Komarov Valery [ctb, cph] (Author of included libxls code), Christophe Leitienne [ctb, cph] (Author of included libxls code), Bob Colbert [ctb, cph] (Author of included libxls code), David Hoerl [ctb, cph] (Author of included libxls code), Evan Miller [ctb, cph] (Author of included libxls code)", + "Maintainer": "Jennifer Bryan ", + "Repository": "CRAN" + }, + "rematch": { + "Package": "rematch", + "Version": "2.0.0", + "Source": "Repository", + "Title": "Match Regular Expressions with a Nicer 'API'", + "Author": "Gabor Csardi", + "Maintainer": "Gabor Csardi ", + "Description": "A small wrapper on 'regexpr' to extract the matches and captured groups from the match of a regular expression to a character vector.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/gaborcsardi/rematch", + "BugReports": "https://github.com/gaborcsardi/rematch/issues", + "RoxygenNote": "5.0.1.9000", + "Suggests": [ + "covr", + "testthat" + ], + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "remotes": { + "Package": "remotes", + "Version": "2.5.0", + "Source": "Repository", + "Title": "R Package Installation from Remote Repositories, Including 'GitHub'", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Hadley\", \"Wickham\", role = \"aut\"), person(\"Winston\", \"Chang\", role = \"aut\"), person(\"Martin\", \"Morgan\", role = \"aut\"), person(\"Dan\", \"Tenenbaum\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"Ascent Digital Services\", role = \"cph\") )", + "Description": "Download and install R packages stored in 'GitHub', 'GitLab', 'Bitbucket', 'Bioconductor', or plain 'subversion' or 'git' repositories. This package provides the 'install_*' functions in 'devtools'. Indeed most of the code was copied over from 'devtools'.", + "License": "MIT + file LICENSE", + "URL": "https://remotes.r-lib.org, https://github.com/r-lib/remotes#readme", + "BugReports": "https://github.com/r-lib/remotes/issues", + "Depends": [ + "R (>= 3.0.0)" + ], + "Imports": [ + "methods", + "stats", + "tools", + "utils" + ], + "Suggests": [ + "brew", + "callr", + "codetools", + "covr", + "curl", + "git2r (>= 0.23.0)", + "knitr", + "mockery", + "pingr", + "pkgbuild (>= 1.0.1)", + "rmarkdown", + "rprojroot", + "testthat (>= 3.0.0)", + "webfakes", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "SystemRequirements": "Subversion for install_svn, git for install_git", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre], Jim Hester [aut], Hadley Wickham [aut], Winston Chang [aut], Martin Morgan [aut], Dan Tenenbaum [aut], Posit Software, PBC [cph, fnd], Ascent Digital Services [cph]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "remulator": { + "Package": "remulator", + "Version": "1.22.0", + "Source": "Repository", + "Type": "Package", + "Title": "R emulator", + "Date": "2023-10-19", + "Authors@R": "c(person(\"David\", \"Klein\", email = \"dklein@pik-potsdam.de\", role = c(\"aut\",\"cre\")))", + "Description": "A collection of R tools for fitting model results.", + "License": "LGPL-3 | file LICENSE", + "Depends": [ + "R(>= 2.10.0)" + ], + "Imports": [ + "gms", + "ggplot2", + "luplot", + "lusweave", + "madrat", + "magclass(>= 4.40)", + "magpie4" + ], + "URL": "https://github.com/pik-piam/remulator, https://doi.org/10.5281/zenodo.2546517", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "Suggests": [ + "covr", + "knitr", + "rmarkdown" + ], + "VignetteBuilder": "knitr", + "Repository": "https://pik-piam.r-universe.dev", + "NeedsCompilation": "no", + "Author": "David Klein [aut, cre]", + "Maintainer": "David Klein " + }, + "renv": { + "Package": "renv", + "Version": "1.1.5", + "Source": "Repository", + "Type": "Package", + "Title": "Project Environments", + "Authors@R": "c( person(\"Kevin\", \"Ushey\", role = c(\"aut\", \"cre\"), email = \"kevin@rstudio.com\", comment = c(ORCID = \"0000-0003-2880-7407\")), person(\"Hadley\", \"Wickham\", role = c(\"aut\"), email = \"hadley@rstudio.com\", comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A dependency management toolkit for R. Using 'renv', you can create and manage project-local R libraries, save the state of these libraries to a 'lockfile', and later restore your library as required. Together, these tools can help make your projects more isolated, portable, and reproducible.", + "License": "MIT + file LICENSE", + "URL": "https://rstudio.github.io/renv/, https://github.com/rstudio/renv", + "BugReports": "https://github.com/rstudio/renv/issues", + "Imports": [ + "utils" + ], + "Suggests": [ + "BiocManager", + "cli", + "compiler", + "covr", + "cpp11", + "devtools", + "generics", + "gitcreds", + "jsonlite", + "jsonvalidate", + "knitr", + "miniUI", + "modules", + "packrat", + "pak", + "R6", + "remotes", + "reticulate", + "rmarkdown", + "rstudioapi", + "shiny", + "testthat", + "uuid", + "waldo", + "yaml", + "webfakes" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "bioconductor,python,install,restore,snapshot,retrieve,remotes", + "NeedsCompilation": "no", + "Author": "Kevin Ushey [aut, cre] (ORCID: ), Hadley Wickham [aut] (ORCID: ), Posit Software, PBC [cph, fnd]", + "Maintainer": "Kevin Ushey ", + "Repository": "CRAN" + }, + "reshape": { + "Package": "reshape", + "Version": "0.8.9", + "Source": "Repository", + "Title": "Flexibly Reshape Data", + "Description": "Flexibly restructure and aggregate data using just two functions: melt and cast.", + "Authors@R": "person(\"Hadley\", \"Wickham\", , \"hadley@rstudio.com\", c(\"aut\", \"cre\"))", + "URL": "http://had.co.nz/reshape", + "Depends": [ + "R (>= 2.6.1)" + ], + "Imports": [ + "plyr" + ], + "License": "MIT + file LICENSE", + "LazyData": "true", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "reshape2": { + "Package": "reshape2", + "Version": "1.4.4", + "Source": "Repository", + "Title": "Flexibly Reshape Data: A Reboot of the Reshape Package", + "Author": "Hadley Wickham ", + "Maintainer": "Hadley Wickham ", + "Description": "Flexibly restructure and aggregate data using just two functions: melt and 'dcast' (or 'acast').", + "License": "MIT + file LICENSE", + "URL": "https://github.com/hadley/reshape", + "BugReports": "https://github.com/hadley/reshape/issues", + "Depends": [ + "R (>= 3.1)" + ], + "Imports": [ + "plyr (>= 1.8.1)", + "Rcpp", + "stringr" + ], + "Suggests": [ + "covr", + "lattice", + "testthat (>= 0.8.0)" + ], + "LinkingTo": [ + "Rcpp" + ], + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.1.0", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "rex": { + "Package": "rex", + "Version": "1.2.1", + "Source": "Repository", + "Type": "Package", + "Title": "Friendly Regular Expressions", + "Authors@R": "c( person(\"Kevin\", \"Ushey\", , \"kevinushey@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Jim\", \"Hester\", , \"james.f.hester@gmail.com\", role = \"aut\"), person(\"Robert\", \"Krzyzanowski\", , \"rkrzyzanowski@gmail.com\", role = \"aut\") )", + "Description": "A friendly interface for the construction of regular expressions.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/kevinushey/rex", + "BugReports": "https://github.com/kevinushey/rex/issues", + "Imports": [ + "lazyeval" + ], + "Suggests": [ + "covr", + "dplyr", + "ggplot2", + "Hmisc", + "knitr", + "magrittr", + "rmarkdown", + "roxygen2", + "rvest", + "stringr", + "testthat" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.1.2", + "Collate": "'aaa.R' 'utils.R' 'escape.R' 'capture.R' 'character_class.R' 'counts.R' 'lookarounds.R' 'match.R' 'or.R' 'rex-mode.R' 'rex.R' 'shortcuts.R' 'wildcards.R' 'zzz.R'", + "NeedsCompilation": "no", + "Author": "Kevin Ushey [aut, cre], Jim Hester [aut], Robert Krzyzanowski [aut]", + "Maintainer": "Kevin Ushey ", + "Repository": "CRAN" + }, + "rlang": { + "Package": "rlang", + "Version": "1.1.6", + "Source": "Repository", + "Title": "Functions for Base Types and Core R and 'Tidyverse' Features", + "Description": "A toolbox for working with base types, core R features like the condition system, and core 'Tidyverse' features like tidy evaluation.", + "Authors@R": "c( person(\"Lionel\", \"Henry\", ,\"lionel@posit.co\", c(\"aut\", \"cre\")), person(\"Hadley\", \"Wickham\", ,\"hadley@posit.co\", \"aut\"), person(given = \"mikefc\", email = \"mikefc@coolbutuseless.com\", role = \"cph\", comment = \"Hash implementation based on Mike's xxhashlite\"), person(given = \"Yann\", family = \"Collet\", role = \"cph\", comment = \"Author of the embedded xxHash library\"), person(given = \"Posit, PBC\", role = c(\"cph\", \"fnd\")) )", + "License": "MIT + file LICENSE", + "ByteCompile": "true", + "Biarch": "true", + "Depends": [ + "R (>= 3.5.0)" + ], + "Imports": [ + "utils" + ], + "Suggests": [ + "cli (>= 3.1.0)", + "covr", + "crayon", + "desc", + "fs", + "glue", + "knitr", + "magrittr", + "methods", + "pillar", + "pkgload", + "rmarkdown", + "stats", + "testthat (>= 3.2.0)", + "tibble", + "usethis", + "vctrs (>= 0.2.3)", + "withr" + ], + "Enhances": [ + "winch" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "URL": "https://rlang.r-lib.org, https://github.com/r-lib/rlang", + "BugReports": "https://github.com/r-lib/rlang/issues", + "Config/build/compilation-database": "true", + "Config/testthat/edition": "3", + "Config/Needs/website": "dplyr, tidyverse/tidytemplate", + "NeedsCompilation": "yes", + "Author": "Lionel Henry [aut, cre], Hadley Wickham [aut], mikefc [cph] (Hash implementation based on Mike's xxhashlite), Yann Collet [cph] (Author of the embedded xxHash library), Posit, PBC [cph, fnd]", + "Maintainer": "Lionel Henry ", + "Repository": "CRAN" + }, + "rmarkdown": { + "Package": "rmarkdown", + "Version": "2.30", + "Source": "Repository", + "Type": "Package", + "Title": "Dynamic Documents for R", + "Authors@R": "c( person(\"JJ\", \"Allaire\", , \"jj@posit.co\", role = \"aut\"), person(\"Yihui\", \"Xie\", , \"xie@yihui.name\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0003-0645-5666\")), person(\"Christophe\", \"Dervieux\", , \"cderv@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-4474-2498\")), person(\"Jonathan\", \"McPherson\", , \"jonathan@posit.co\", role = \"aut\"), person(\"Javier\", \"Luraschi\", role = \"aut\"), person(\"Kevin\", \"Ushey\", , \"kevin@posit.co\", role = \"aut\"), person(\"Aron\", \"Atkins\", , \"aron@posit.co\", role = \"aut\"), person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Joe\", \"Cheng\", , \"joe@posit.co\", role = \"aut\"), person(\"Winston\", \"Chang\", , \"winston@posit.co\", role = \"aut\"), person(\"Richard\", \"Iannone\", , \"rich@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-3925-190X\")), person(\"Andrew\", \"Dunning\", role = \"ctb\", comment = c(ORCID = \"0000-0003-0464-5036\")), person(\"Atsushi\", \"Yasumoto\", role = c(\"ctb\", \"cph\"), comment = c(ORCID = \"0000-0002-8335-495X\", cph = \"Number sections Lua filter\")), person(\"Barret\", \"Schloerke\", role = \"ctb\"), person(\"Carson\", \"Sievert\", role = \"ctb\", comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Devon\", \"Ryan\", , \"dpryan79@gmail.com\", role = \"ctb\", comment = c(ORCID = \"0000-0002-8549-0971\")), person(\"Frederik\", \"Aust\", , \"frederik.aust@uni-koeln.de\", role = \"ctb\", comment = c(ORCID = \"0000-0003-4900-788X\")), person(\"Jeff\", \"Allen\", , \"jeff@posit.co\", role = \"ctb\"), person(\"JooYoung\", \"Seo\", role = \"ctb\", comment = c(ORCID = \"0000-0002-4064-6012\")), person(\"Malcolm\", \"Barrett\", role = \"ctb\"), person(\"Rob\", \"Hyndman\", , \"Rob.Hyndman@monash.edu\", role = \"ctb\"), person(\"Romain\", \"Lesur\", role = \"ctb\"), person(\"Roy\", \"Storey\", role = \"ctb\"), person(\"Ruben\", \"Arslan\", , \"ruben.arslan@uni-goettingen.de\", role = \"ctb\"), person(\"Sergio\", \"Oller\", role = \"ctb\"), person(given = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(, \"jQuery UI contributors\", role = c(\"ctb\", \"cph\"), comment = \"jQuery UI library; authors listed in inst/rmd/h/jqueryui/AUTHORS.txt\"), person(\"Mark\", \"Otto\", role = \"ctb\", comment = \"Bootstrap library\"), person(\"Jacob\", \"Thornton\", role = \"ctb\", comment = \"Bootstrap library\"), person(, \"Bootstrap contributors\", role = \"ctb\", comment = \"Bootstrap library\"), person(, \"Twitter, Inc\", role = \"cph\", comment = \"Bootstrap library\"), person(\"Alexander\", \"Farkas\", role = c(\"ctb\", \"cph\"), comment = \"html5shiv library\"), person(\"Scott\", \"Jehl\", role = c(\"ctb\", \"cph\"), comment = \"Respond.js library\"), person(\"Ivan\", \"Sagalaev\", role = c(\"ctb\", \"cph\"), comment = \"highlight.js library\"), person(\"Greg\", \"Franko\", role = c(\"ctb\", \"cph\"), comment = \"tocify library\"), person(\"John\", \"MacFarlane\", role = c(\"ctb\", \"cph\"), comment = \"Pandoc templates\"), person(, \"Google, Inc.\", role = c(\"ctb\", \"cph\"), comment = \"ioslides library\"), person(\"Dave\", \"Raggett\", role = \"ctb\", comment = \"slidy library\"), person(, \"W3C\", role = \"cph\", comment = \"slidy library\"), person(\"Dave\", \"Gandy\", role = c(\"ctb\", \"cph\"), comment = \"Font-Awesome\"), person(\"Ben\", \"Sperry\", role = \"ctb\", comment = \"Ionicons\"), person(, \"Drifty\", role = \"cph\", comment = \"Ionicons\"), person(\"Aidan\", \"Lister\", role = c(\"ctb\", \"cph\"), comment = \"jQuery StickyTabs\"), person(\"Benct Philip\", \"Jonsson\", role = c(\"ctb\", \"cph\"), comment = \"pagebreak Lua filter\"), person(\"Albert\", \"Krewinkel\", role = c(\"ctb\", \"cph\"), comment = \"pagebreak Lua filter\") )", + "Description": "Convert R Markdown documents into a variety of formats.", + "License": "GPL-3", + "URL": "https://github.com/rstudio/rmarkdown, https://pkgs.rstudio.com/rmarkdown/", + "BugReports": "https://github.com/rstudio/rmarkdown/issues", + "Depends": [ + "R (>= 3.0)" + ], + "Imports": [ + "bslib (>= 0.2.5.1)", + "evaluate (>= 0.13)", + "fontawesome (>= 0.5.0)", + "htmltools (>= 0.5.1)", + "jquerylib", + "jsonlite", + "knitr (>= 1.43)", + "methods", + "tinytex (>= 0.31)", + "tools", + "utils", + "xfun (>= 0.36)", + "yaml (>= 2.1.19)" + ], + "Suggests": [ + "digest", + "dygraphs", + "fs", + "rsconnect", + "downlit (>= 0.4.0)", + "katex (>= 1.4.0)", + "sass (>= 0.4.0)", + "shiny (>= 1.6.0)", + "testthat (>= 3.0.3)", + "tibble", + "vctrs", + "cleanrmd", + "withr (>= 2.4.2)", + "xml2" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "rstudio/quillt, pkgdown", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "SystemRequirements": "pandoc (>= 1.14) - http://pandoc.org", + "NeedsCompilation": "no", + "Author": "JJ Allaire [aut], Yihui Xie [aut, cre] (ORCID: ), Christophe Dervieux [aut] (ORCID: ), Jonathan McPherson [aut], Javier Luraschi [aut], Kevin Ushey [aut], Aron Atkins [aut], Hadley Wickham [aut], Joe Cheng [aut], Winston Chang [aut], Richard Iannone [aut] (ORCID: ), Andrew Dunning [ctb] (ORCID: ), Atsushi Yasumoto [ctb, cph] (ORCID: , cph: Number sections Lua filter), Barret Schloerke [ctb], Carson Sievert [ctb] (ORCID: ), Devon Ryan [ctb] (ORCID: ), Frederik Aust [ctb] (ORCID: ), Jeff Allen [ctb], JooYoung Seo [ctb] (ORCID: ), Malcolm Barrett [ctb], Rob Hyndman [ctb], Romain Lesur [ctb], Roy Storey [ctb], Ruben Arslan [ctb], Sergio Oller [ctb], Posit Software, PBC [cph, fnd], jQuery UI contributors [ctb, cph] (jQuery UI library; authors listed in inst/rmd/h/jqueryui/AUTHORS.txt), Mark Otto [ctb] (Bootstrap library), Jacob Thornton [ctb] (Bootstrap library), Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Alexander Farkas [ctb, cph] (html5shiv library), Scott Jehl [ctb, cph] (Respond.js library), Ivan Sagalaev [ctb, cph] (highlight.js library), Greg Franko [ctb, cph] (tocify library), John MacFarlane [ctb, cph] (Pandoc templates), Google, Inc. [ctb, cph] (ioslides library), Dave Raggett [ctb] (slidy library), W3C [cph] (slidy library), Dave Gandy [ctb, cph] (Font-Awesome), Ben Sperry [ctb] (Ionicons), Drifty [cph] (Ionicons), Aidan Lister [ctb, cph] (jQuery StickyTabs), Benct Philip Jonsson [ctb, cph] (pagebreak Lua filter), Albert Krewinkel [ctb, cph] (pagebreak Lua filter)", + "Maintainer": "Yihui Xie ", + "Repository": "CRAN" + }, + "rnaturalearth": { + "Package": "rnaturalearth", + "Version": "1.0.1", + "Source": "Repository", + "Title": "World Map Data from Natural Earth", + "Authors@R": "c( person( family = \"Massicotte\", given = \"Philippe\", email = \"pmassicotte@hotmail.com\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-5919-4116\") ), person( family = \"South\", given = \"Andy\", email = \"southandy@gmail.com\", role = c(\"aut\") ), person( family = \"Hufkens\", given = \"Koen\", email = \"koen.hufkens@gmail.com\", role = c(\"ctb\"), comment = c(ORCID = \"0000-0002-5070-8109\") ))", + "Description": "Facilitates mapping by making natural earth map data from more easily available to R users.", + "License": "MIT + file LICENSE", + "LazyData": "true", + "LazyDataCompression": "xz", + "Encoding": "UTF-8", + "URL": "https://docs.ropensci.org/rnaturalearth/, https://github.com/ropensci/rnaturalearth, https://docs.ropensci.org/rnaturalearthhires/", + "BugReports": "https://github.com/ropensci/rnaturalearth/issues", + "Additional_repositories": "http://packages.ropensci.org", + "Depends": [ + "R (>= 3.1.1)" + ], + "Imports": [ + "httr (>= 1.1.0)", + "jsonlite", + "sf (>= 0.3-4)", + "terra", + "utils (>= 3.2.3)" + ], + "Suggests": [ + "devtools (>= 1.10.0)", + "dplyr", + "ggplot2", + "ggrepel", + "knitr (>= 1.12.3)", + "lifecycle (>= 1.0.3)", + "pbapply", + "purrr", + "rlang", + "rmarkdown", + "rnaturalearthdata (>= 0.1.0)", + "rnaturalearthhires (>= 0.1.0)", + "testthat (>= 0.9.1)", + "tmap" + ], + "Config/Needs/website": "ropensci/rnaturalearthhires", + "VignetteBuilder": "knitr", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Philippe Massicotte [aut, cre] (), Andy South [aut], Koen Hufkens [ctb] ()", + "Maintainer": "Philippe Massicotte ", + "Repository": "CRAN" + }, + "roxygen2": { + "Package": "roxygen2", + "Version": "7.3.2", + "Source": "Repository", + "Title": "In-Line Documentation for R", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\", \"cph\"), comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Peter\", \"Danenberg\", , \"pcd@roxygen.org\", role = c(\"aut\", \"cph\")), person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = \"aut\"), person(\"Manuel\", \"Eugster\", role = c(\"aut\", \"cph\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Generate your Rd documentation, 'NAMESPACE' file, and collation field using specially formatted comments. Writing documentation in-line with code makes it easier to keep your documentation up-to-date as your requirements change. 'roxygen2' is inspired by the 'Doxygen' system for C++.", + "License": "MIT + file LICENSE", + "URL": "https://roxygen2.r-lib.org/, https://github.com/r-lib/roxygen2", + "BugReports": "https://github.com/r-lib/roxygen2/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "brew", + "cli (>= 3.3.0)", + "commonmark", + "desc (>= 1.2.0)", + "knitr", + "methods", + "pkgload (>= 1.0.2)", + "purrr (>= 1.0.0)", + "R6 (>= 2.1.2)", + "rlang (>= 1.0.6)", + "stringi", + "stringr (>= 1.0.0)", + "utils", + "withr", + "xml2" + ], + "Suggests": [ + "covr", + "R.methodsS3", + "R.oo", + "rmarkdown (>= 2.16)", + "testthat (>= 3.1.2)", + "yaml" + ], + "LinkingTo": [ + "cpp11" + ], + "VignetteBuilder": "knitr", + "Config/Needs/development": "testthat", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "TRUE", + "Encoding": "UTF-8", + "Language": "en-GB", + "RoxygenNote": "7.3.1.9000", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre, cph] (), Peter Danenberg [aut, cph], Gábor Csárdi [aut], Manuel Eugster [aut, cph], Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "rpart": { + "Package": "rpart", + "Version": "4.1.21", + "Source": "Repository", + "Priority": "recommended", + "Date": "2023-10-09", + "Authors@R": "c(person(\"Terry\", \"Therneau\", role = \"aut\", email = \"therneau@mayo.edu\"), person(\"Beth\", \"Atkinson\", role = c(\"aut\", \"cre\"), email = \"atkinson@mayo.edu\"), person(\"Brian\", \"Ripley\", role = \"trl\", email = \"ripley@stats.ox.ac.uk\", comment = \"producer of the initial R port, maintainer 1999-2017\"))", + "Description": "Recursive partitioning for classification, regression and survival trees. An implementation of most of the functionality of the 1984 book by Breiman, Friedman, Olshen and Stone.", + "Title": "Recursive Partitioning and Regression Trees", + "Depends": [ + "R (>= 2.15.0)", + "graphics", + "stats", + "grDevices" + ], + "Suggests": [ + "survival" + ], + "License": "GPL-2 | GPL-3", + "LazyData": "yes", + "ByteCompile": "yes", + "NeedsCompilation": "yes", + "Author": "Terry Therneau [aut], Beth Atkinson [aut, cre], Brian Ripley [trl] (producer of the initial R port, maintainer 1999-2017)", + "Maintainer": "Beth Atkinson ", + "Repository": "CRAN", + "URL": "https://github.com/bethatkinson/rpart, https://cran.r-project.org/package=rpart", + "BugReports": "https://github.com/bethatkinson/rpart/issues" + }, + "rprojroot": { + "Package": "rprojroot", + "Version": "2.0.4", + "Source": "Repository", + "Title": "Finding Files in Project Subdirectories", + "Authors@R": "person(given = \"Kirill\", family = \"M\\u00fcller\", role = c(\"aut\", \"cre\"), email = \"kirill@cynkra.com\", comment = c(ORCID = \"0000-0002-1416-3412\"))", + "Description": "Robust, reliable and flexible paths to files below a project root. The 'root' of a project is defined as a directory that matches a certain criterion, e.g., it contains a certain regular file.", + "License": "MIT + file LICENSE", + "URL": "https://rprojroot.r-lib.org/, https://github.com/r-lib/rprojroot", + "BugReports": "https://github.com/r-lib/rprojroot/issues", + "Depends": [ + "R (>= 3.0.0)" + ], + "Suggests": [ + "covr", + "knitr", + "lifecycle", + "mockr", + "rlang", + "rmarkdown", + "testthat (>= 3.0.0)", + "withr" + ], + "VignetteBuilder": "knitr", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Kirill Müller [aut, cre] ()", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "rstudioapi": { + "Package": "rstudioapi", + "Version": "0.16.0", + "Source": "Repository", + "Title": "Safely Access the RStudio API", + "Description": "Access the RStudio API (if available) and provide informative error messages when it's not.", + "Authors@R": "c( person(\"Kevin\", \"Ushey\", role = c(\"aut\", \"cre\"), email = \"kevin@rstudio.com\"), person(\"JJ\", \"Allaire\", role = c(\"aut\"), email = \"jj@posit.co\"), person(\"Hadley\", \"Wickham\", role = c(\"aut\"), email = \"hadley@posit.co\"), person(\"Gary\", \"Ritchie\", role = c(\"aut\"), email = \"gary@posit.co\"), person(family = \"RStudio\", role = \"cph\") )", + "Maintainer": "Kevin Ushey ", + "License": "MIT + file LICENSE", + "URL": "https://rstudio.github.io/rstudioapi/, https://github.com/rstudio/rstudioapi", + "BugReports": "https://github.com/rstudio/rstudioapi/issues", + "RoxygenNote": "7.3.1", + "Suggests": [ + "testthat", + "knitr", + "rmarkdown", + "clipr", + "covr" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Author": "Kevin Ushey [aut, cre], JJ Allaire [aut], Hadley Wickham [aut], Gary Ritchie [aut], RStudio [cph]", + "Repository": "CRAN" + }, + "rversions": { + "Package": "rversions", + "Version": "2.1.2", + "Source": "Repository", + "Title": "Query 'R' Versions, Including 'r-release' and 'r-oldrel'", + "Authors@R": "c(person(given = \"Gábor\", family = \"Csárdi\", role = c(\"aut\", \"cre\"), email = \"csardi.gabor@gmail.com\"), person(given = \"Jeroen\", family = \"Ooms\", role = \"ctb\", email = \"jeroen.ooms@stat.ucla.edu\"), person(given = \"R Consortium\", role = \"fnd\"))", + "Description": "Query the main 'R' 'SVN' repository to find the versions 'r-release' and 'r-oldrel' refer to, and also all previous 'R' versions and their release dates.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-hub/rversions, https://r-hub.github.io/rversions/", + "BugReports": "https://github.com/r-hub/rversions/issues", + "Imports": [ + "curl", + "utils", + "xml2 (>= 1.0.0)" + ], + "Suggests": [ + "covr", + "mockery", + "testthat" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.2.1.9000", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre], Jeroen Ooms [ctb], R Consortium [fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "rvest": { + "Package": "rvest", + "Version": "1.0.4", + "Source": "Repository", + "Title": "Easily Harvest (Scrape) Web Pages", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Wrappers around the 'xml2' and 'httr' packages to make it easy to download, then manipulate, HTML and XML.", + "License": "MIT + file LICENSE", + "URL": "https://rvest.tidyverse.org/, https://github.com/tidyverse/rvest", + "BugReports": "https://github.com/tidyverse/rvest/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli", + "glue", + "httr (>= 0.5)", + "lifecycle (>= 1.0.3)", + "magrittr", + "rlang (>= 1.1.0)", + "selectr", + "tibble", + "xml2 (>= 1.3)" + ], + "Suggests": [ + "chromote", + "covr", + "knitr", + "R6", + "readr", + "repurrrsive", + "rmarkdown", + "spelling", + "stringi (>= 0.3.1)", + "testthat (>= 3.0.2)", + "webfakes" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "rworldmap": { + "Package": "rworldmap", + "Version": "1.3-8", + "Source": "Repository", + "Type": "Package", + "Title": "Mapping Global Data", + "Date": "2023-10-15", + "Authors@R": "person(given = \"Andy\", family = \"South\", role = c(\"aut\", \"cre\"), email = \"southandy@gmail.com\", comment = c(ORCID = \"0000-0003-4051-6135\"))", + "Description": "Enables mapping of country level and gridded user datasets.", + "License": "GPL (>= 2)", + "Depends": [ + "R (>= 2.10.0)", + "sp" + ], + "Imports": [ + "fields", + "methods", + "raster", + "terra" + ], + "Suggests": [ + "rworldxtra", + "RColorBrewer", + "classInt", + "sf" + ], + "LazyData": "true", + "URL": "https://github.com/AndySouth/rworldmap/, https://groups.google.com/forum/#!forum/rworldmap", + "BugReports": "https://github.com/AndySouth/rworldmap/issues", + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Author": "Andy South [aut, cre] ()", + "Maintainer": "Andy South ", + "Repository": "CRAN" + }, + "s2": { + "Package": "s2", + "Version": "1.1.6", + "Source": "Repository", + "Title": "Spherical Geometry Operators Using the S2 Geometry Library", + "Authors@R": "c( person(given = \"Dewey\", family = \"Dunnington\", role = c(\"aut\"), email = \"dewey@fishandwhistle.net\", comment = c(ORCID = \"0000-0002-9415-4582\")), person(given = \"Edzer\", family = \"Pebesma\", role = c(\"aut\", \"cre\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(\"Ege\", \"Rubak\", email=\"rubak@math.aau.dk\", role = c(\"aut\")), person(\"Jeroen\", \"Ooms\", , \"jeroen.ooms@stat.ucla.edu\", role = \"ctb\", comment = \"configure script\"), person(family = \"Google, Inc.\", role = \"cph\", comment = \"Original s2geometry.io source code\") )", + "Description": "Provides R bindings for Google's s2 library for geometric calculations on the sphere. High-performance constructors and exporters provide high compatibility with existing spatial packages, transformers construct new geometries from existing geometries, predicates provide a means to select geometries based on spatial relationships, and accessors extract information about geometries.", + "License": "Apache License (== 2.0)", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "SystemRequirements": "OpenSSL >= 1.0.1", + "LinkingTo": [ + "Rcpp", + "wk" + ], + "Imports": [ + "Rcpp", + "wk (>= 0.6.0)" + ], + "Suggests": [ + "bit64", + "testthat (>= 3.0.0)", + "vctrs" + ], + "URL": "https://r-spatial.github.io/s2/, https://github.com/r-spatial/s2, http://s2geometry.io/", + "BugReports": "https://github.com/r-spatial/s2/issues", + "Depends": [ + "R (>= 3.0.0)" + ], + "Config/testthat/edition": "3", + "NeedsCompilation": "yes", + "Author": "Dewey Dunnington [aut] (), Edzer Pebesma [aut, cre] (), Ege Rubak [aut], Jeroen Ooms [ctb] (configure script), Google, Inc. [cph] (Original s2geometry.io source code)", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "sass": { + "Package": "sass", + "Version": "0.4.10", + "Source": "Repository", + "Type": "Package", + "Title": "Syntactically Awesome Style Sheets ('Sass')", + "Description": "An 'SCSS' compiler, powered by the 'LibSass' library. With this, R developers can use variables, inheritance, and functions to generate dynamic style sheets. The package uses the 'Sass CSS' extension language, which is stable, powerful, and CSS compatible.", + "Authors@R": "c( person(\"Joe\", \"Cheng\", , \"joe@rstudio.com\", \"aut\"), person(\"Timothy\", \"Mastny\", , \"tim.mastny@gmail.com\", \"aut\"), person(\"Richard\", \"Iannone\", , \"rich@rstudio.com\", \"aut\", comment = c(ORCID = \"0000-0003-3925-190X\")), person(\"Barret\", \"Schloerke\", , \"barret@rstudio.com\", \"aut\", comment = c(ORCID = \"0000-0001-9986-114X\")), person(\"Carson\", \"Sievert\", , \"carson@rstudio.com\", c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Christophe\", \"Dervieux\", , \"cderv@rstudio.com\", c(\"ctb\"), comment = c(ORCID = \"0000-0003-4474-2498\")), person(family = \"RStudio\", role = c(\"cph\", \"fnd\")), person(family = \"Sass Open Source Foundation\", role = c(\"ctb\", \"cph\"), comment = \"LibSass library\"), person(\"Greter\", \"Marcel\", role = c(\"ctb\", \"cph\"), comment = \"LibSass library\"), person(\"Mifsud\", \"Michael\", role = c(\"ctb\", \"cph\"), comment = \"LibSass library\"), person(\"Hampton\", \"Catlin\", role = c(\"ctb\", \"cph\"), comment = \"LibSass library\"), person(\"Natalie\", \"Weizenbaum\", role = c(\"ctb\", \"cph\"), comment = \"LibSass library\"), person(\"Chris\", \"Eppstein\", role = c(\"ctb\", \"cph\"), comment = \"LibSass library\"), person(\"Adams\", \"Joseph\", role = c(\"ctb\", \"cph\"), comment = \"json.cpp\"), person(\"Trifunovic\", \"Nemanja\", role = c(\"ctb\", \"cph\"), comment = \"utf8.h\") )", + "License": "MIT + file LICENSE", + "URL": "https://rstudio.github.io/sass/, https://github.com/rstudio/sass", + "BugReports": "https://github.com/rstudio/sass/issues", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "SystemRequirements": "GNU make", + "Imports": [ + "fs (>= 1.2.4)", + "rlang (>= 0.4.10)", + "htmltools (>= 0.5.1)", + "R6", + "rappdirs" + ], + "Suggests": [ + "testthat", + "knitr", + "rmarkdown", + "withr", + "shiny", + "curl" + ], + "VignetteBuilder": "knitr", + "Config/testthat/edition": "3", + "NeedsCompilation": "yes", + "Author": "Joe Cheng [aut], Timothy Mastny [aut], Richard Iannone [aut] (), Barret Schloerke [aut] (), Carson Sievert [aut, cre] (), Christophe Dervieux [ctb] (), RStudio [cph, fnd], Sass Open Source Foundation [ctb, cph] (LibSass library), Greter Marcel [ctb, cph] (LibSass library), Mifsud Michael [ctb, cph] (LibSass library), Hampton Catlin [ctb, cph] (LibSass library), Natalie Weizenbaum [ctb, cph] (LibSass library), Chris Eppstein [ctb, cph] (LibSass library), Adams Joseph [ctb, cph] (json.cpp), Trifunovic Nemanja [ctb, cph] (utf8.h)", + "Maintainer": "Carson Sievert ", + "Repository": "CRAN" + }, + "scales": { + "Package": "scales", + "Version": "1.4.0", + "Source": "Repository", + "Title": "Scale Functions for Visualization", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Thomas Lin\", \"Pedersen\", , \"thomas.pedersen@posit.co\", role = c(\"cre\", \"aut\"), comment = c(ORCID = \"0000-0002-5147-4711\")), person(\"Dana\", \"Seidel\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\"), comment = c(ROR = \"03wc8by49\")) )", + "Description": "Graphical scales map data to aesthetics, and provide methods for automatically determining breaks and labels for axes and legends.", + "License": "MIT + file LICENSE", + "URL": "https://scales.r-lib.org, https://github.com/r-lib/scales", + "BugReports": "https://github.com/r-lib/scales/issues", + "Depends": [ + "R (>= 4.1)" + ], + "Imports": [ + "cli", + "farver (>= 2.0.3)", + "glue", + "labeling", + "lifecycle", + "R6", + "RColorBrewer", + "rlang (>= 1.1.0)", + "viridisLite" + ], + "Suggests": [ + "bit64", + "covr", + "dichromat", + "ggplot2", + "hms (>= 0.5.0)", + "stringi", + "testthat (>= 3.0.0)" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/usethis/last-upkeep": "2025-04-23", + "Encoding": "UTF-8", + "LazyLoad": "yes", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut], Thomas Lin Pedersen [cre, aut] (), Dana Seidel [aut], Posit Software, PBC [cph, fnd] (03wc8by49)", + "Maintainer": "Thomas Lin Pedersen ", + "Repository": "CRAN" + }, + "selectr": { + "Package": "selectr", + "Version": "0.4-2", + "Source": "Repository", + "Type": "Package", + "Title": "Translate CSS Selectors to XPath Expressions", + "Date": "2019-11-20", + "Authors@R": "c(person(\"Simon\", \"Potter\", role = c(\"aut\", \"trl\", \"cre\"), email = \"simon@sjp.co.nz\"), person(\"Simon\", \"Sapin\", role = \"aut\"), person(\"Ian\", \"Bicking\", role = \"aut\"))", + "License": "BSD_3_clause + file LICENCE", + "Depends": [ + "R (>= 3.0)" + ], + "Imports": [ + "methods", + "stringr", + "R6" + ], + "Suggests": [ + "testthat", + "XML", + "xml2" + ], + "URL": "https://sjp.co.nz/projects/selectr", + "BugReports": "https://github.com/sjp/selectr/issues", + "Description": "Translates a CSS3 selector into an equivalent XPath expression. This allows us to use CSS selectors when working with the XML package as it can only evaluate XPath expressions. Also provided are convenience functions useful for using CSS selectors on XML nodes. This package is a port of the Python package 'cssselect' ().", + "NeedsCompilation": "no", + "Author": "Simon Potter [aut, trl, cre], Simon Sapin [aut], Ian Bicking [aut]", + "Maintainer": "Simon Potter ", + "Repository": "CRAN" + }, + "sessioninfo": { + "Package": "sessioninfo", + "Version": "1.2.2", + "Source": "Repository", + "Title": "R Session Information", + "Authors@R": "c(person(given = \"Gábor\", family = \"Csárdi\", role = \"cre\", email = \"csardi.gabor@gmail.com\"), person(given = \"Hadley\", family = \"Wickham\", role = \"aut\"), person(given = \"Winston\", family = \"Chang\", role = \"aut\"), person(given = \"Robert\", family = \"Flight\", role = \"aut\"), person(given = \"Kirill\", family = \"Müller\", role = \"aut\"), person(given = \"Jim\", family = \"Hester\", role = \"aut\"), person(given = \"R Core team\", role = \"ctb\"))", + "Maintainer": "Gábor Csárdi ", + "Description": "Query and print information about the current R session. It is similar to 'utils::sessionInfo()', but includes more information about packages, and where they were installed from.", + "License": "GPL-2", + "URL": "https://github.com/r-lib/sessioninfo#readme, https://r-lib.github.io/sessioninfo/", + "BugReports": "https://github.com/r-lib/sessioninfo/issues", + "Depends": [ + "R (>= 2.10)" + ], + "Imports": [ + "cli (>= 3.1.0)", + "tools", + "utils" + ], + "Suggests": [ + "callr", + "covr", + "mockery", + "reticulate", + "rmarkdown", + "testthat", + "withr" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.1.2.9000", + "Config/testthat/edition": "3", + "Config/Needs/website": "pkgdown", + "Config/testthat/parallel": "true", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [cre], Hadley Wickham [aut], Winston Chang [aut], Robert Flight [aut], Kirill Müller [aut], Jim Hester [aut], R Core team [ctb]", + "Repository": "CRAN" + }, + "sf": { + "Package": "sf", + "Version": "1.0-19", + "Source": "Repository", + "Title": "Simple Features for R", + "Authors@R": "c(person(given = \"Edzer\", family = \"Pebesma\", role = c(\"aut\", \"cre\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(given = \"Roger\", family = \"Bivand\", role = \"ctb\", comment = c(ORCID = \"0000-0003-2392-6140\")), person(given = \"Etienne\", family = \"Racine\", role = \"ctb\"), person(given = \"Michael\", family = \"Sumner\", role = \"ctb\"), person(given = \"Ian\", family = \"Cook\", role = \"ctb\"), person(given = \"Tim\", family = \"Keitt\", role = \"ctb\"), person(given = \"Robin\", family = \"Lovelace\", role = \"ctb\"), person(given = \"Hadley\", family = \"Wickham\", role = \"ctb\"), person(given = \"Jeroen\", family = \"Ooms\", role = \"ctb\", comment = c(ORCID = \"0000-0002-4035-0289\")), person(given = \"Kirill\", family = \"M\\u00fcller\", role = \"ctb\"), person(given = \"Thomas Lin\", family = \"Pedersen\", role = \"ctb\"), person(given = \"Dan\", family = \"Baston\", role = \"ctb\"), person(given = \"Dewey\", family = \"Dunnington\", role = \"ctb\", comment = c(ORCID = \"0000-0002-9415-4582\")) )", + "Description": "Support for simple features, a standardized way to encode spatial vector data. Binds to 'GDAL' for reading and writing data, to 'GEOS' for geometrical operations, and to 'PROJ' for projection conversions and datum transformations. Uses by default the 's2' package for spherical geometry operations on ellipsoidal (long/lat) coordinates.", + "License": "GPL-2 | MIT + file LICENSE", + "URL": "https://r-spatial.github.io/sf/, https://github.com/r-spatial/sf", + "BugReports": "https://github.com/r-spatial/sf/issues", + "Depends": [ + "methods", + "R (>= 3.3.0)" + ], + "Imports": [ + "classInt (>= 0.4-1)", + "DBI (>= 0.8)", + "graphics", + "grDevices", + "grid", + "magrittr", + "s2 (>= 1.1.0)", + "stats", + "tools", + "units (>= 0.7-0)", + "utils" + ], + "Suggests": [ + "blob", + "nanoarrow", + "covr", + "dplyr (>= 1.0.0)", + "ggplot2", + "knitr", + "lwgeom (>= 0.2-14)", + "maps", + "mapview", + "Matrix", + "microbenchmark", + "odbc", + "pbapply", + "pillar", + "pool", + "raster", + "rlang", + "rmarkdown", + "RPostgres (>= 1.1.0)", + "RPostgreSQL", + "RSQLite", + "sp (>= 1.2-4)", + "spatstat (>= 2.0-1)", + "spatstat.geom", + "spatstat.random", + "spatstat.linnet", + "spatstat.utils", + "stars (>= 0.2-0)", + "terra", + "testthat (>= 3.0.0)", + "tibble (>= 1.4.1)", + "tidyr (>= 1.2.0)", + "tidyselect (>= 1.0.0)", + "tmap (>= 2.0)", + "vctrs", + "wk (>= 0.9.0)" + ], + "LinkingTo": [ + "Rcpp" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Config/testthat/edition": "2", + "Config/needs/coverage": "XML", + "SystemRequirements": "GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0), sqlite3", + "Collate": "'RcppExports.R' 'init.R' 'import-standalone-s3-register.R' 'crs.R' 'bbox.R' 'read.R' 'db.R' 'sfc.R' 'sfg.R' 'sf.R' 'bind.R' 'wkb.R' 'wkt.R' 'plot.R' 'geom-measures.R' 'geom-predicates.R' 'geom-transformers.R' 'transform.R' 'proj.R' 'sp.R' 'grid.R' 'arith.R' 'tidyverse.R' 'tidyverse-vctrs.R' 'cast_sfg.R' 'cast_sfc.R' 'graticule.R' 'datasets.R' 'aggregate.R' 'agr.R' 'maps.R' 'join.R' 'sample.R' 'valid.R' 'collection_extract.R' 'jitter.R' 'sgbp.R' 'spatstat.R' 'stars.R' 'crop.R' 'gdal_utils.R' 'nearest.R' 'normalize.R' 'sf-package.R' 'defunct.R' 'z_range.R' 'm_range.R' 'shift_longitude.R' 'make_grid.R' 's2.R' 'terra.R' 'geos-overlayng.R' 'break_antimeridian.R'", + "NeedsCompilation": "yes", + "Author": "Edzer Pebesma [aut, cre] (), Roger Bivand [ctb] (), Etienne Racine [ctb], Michael Sumner [ctb], Ian Cook [ctb], Tim Keitt [ctb], Robin Lovelace [ctb], Hadley Wickham [ctb], Jeroen Ooms [ctb] (), Kirill Müller [ctb], Thomas Lin Pedersen [ctb], Dan Baston [ctb], Dewey Dunnington [ctb] ()", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "sftime": { + "Package": "sftime", + "Version": "0.3.0", + "Source": "Repository", + "Title": "Classes and Methods for Simple Feature Objects that Have a Time Column", + "Description": "Classes and methods for spatial objects that have a registered time column, in particular for irregular spatiotemporal data. The time column can be of any type, but needs to be ordinal. Regularly laid out spatiotemporal data (vector or raster data cubes) are handled by package 'stars'.", + "Depends": [ + "sf (>= 1.0.9)" + ], + "Imports": [ + "methods" + ], + "Suggests": [ + "knitr", + "spacetime", + "rmarkdown", + "dplyr (>= 0.8-3)", + "trajectories (>= 0.2.2)", + "stars", + "ncmeta", + "tidyr", + "ggplot2", + "magrittr", + "sp", + "rlang", + "vctrs", + "spatstat.geom", + "spatstat.linnet", + "sftrack", + "cubble (>= 0.3.0)" + ], + "Authors@R": "c(person(given = \"Henning\", family = \"Teickner\", role = c(\"aut\", \"cre\", \"cph\"), email = \"henning.teickner@uni-muenster.de\", comment = c(ORCID = \"0000-0002-3993-1182\")), person(given = \"Edzer\", family = \"Pebesma\", role = c(\"aut\", \"cph\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(given = \"Benedikt\", family = \"Graeler\", role = c(\"aut\", \"cph\"), email = \"b.graeler@52north.org\", comment = c(ORCID = \"0000-0001-5443-4304\")))", + "License": "Apache License", + "Type": "Package", + "Encoding": "UTF-8", + "VignetteBuilder": "knitr", + "RoxygenNote": "7.2.3", + "URL": "https://r-spatial.github.io/sftime/, https://github.com/r-spatial/sftime", + "BugReports": "https://github.com/r-spatial/sftime/issues/", + "Collate": "sftime.R init.R join.R plot.R st_cast.R st_geometry.R st_time.R tidyverse.R bind.R crop.R geom-transformers.R", + "NeedsCompilation": "no", + "Author": "Henning Teickner [aut, cre, cph] (), Edzer Pebesma [aut, cph] (), Benedikt Graeler [aut, cph] ()", + "Maintainer": "Henning Teickner ", + "Repository": "CRAN" + }, + "shiny": { + "Package": "shiny", + "Version": "1.8.1.1", + "Source": "Repository", + "Type": "Package", + "Title": "Web Application Framework for R", + "Authors@R": "c( person(\"Winston\", \"Chang\", role = c(\"aut\", \"cre\"), email = \"winston@posit.co\", comment = c(ORCID = \"0000-0002-1576-2126\")), person(\"Joe\", \"Cheng\", role = \"aut\", email = \"joe@posit.co\"), person(\"JJ\", \"Allaire\", role = \"aut\", email = \"jj@posit.co\"), person(\"Carson\", \"Sievert\", role = \"aut\", email = \"carson@posit.co\", comment = c(ORCID = \"0000-0002-4958-2844\")), person(\"Barret\", \"Schloerke\", role = \"aut\", email = \"barret@posit.co\", comment = c(ORCID = \"0000-0001-9986-114X\")), person(\"Yihui\", \"Xie\", role = \"aut\", email = \"yihui@posit.co\"), person(\"Jeff\", \"Allen\", role = \"aut\"), person(\"Jonathan\", \"McPherson\", role = \"aut\", email = \"jonathan@posit.co\"), person(\"Alan\", \"Dipert\", role = \"aut\"), person(\"Barbara\", \"Borges\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(family = \"jQuery Foundation\", role = \"cph\", comment = \"jQuery library and jQuery UI library\"), person(family = \"jQuery contributors\", role = c(\"ctb\", \"cph\"), comment = \"jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt\"), person(family = \"jQuery UI contributors\", role = c(\"ctb\", \"cph\"), comment = \"jQuery UI library; authors listed in inst/www/shared/jqueryui/AUTHORS.txt\"), person(\"Mark\", \"Otto\", role = \"ctb\", comment = \"Bootstrap library\"), person(\"Jacob\", \"Thornton\", role = \"ctb\", comment = \"Bootstrap library\"), person(family = \"Bootstrap contributors\", role = \"ctb\", comment = \"Bootstrap library\"), person(family = \"Twitter, Inc\", role = \"cph\", comment = \"Bootstrap library\"), person(\"Prem Nawaz\", \"Khan\", role = \"ctb\", comment = \"Bootstrap accessibility plugin\"), person(\"Victor\", \"Tsaran\", role = \"ctb\", comment = \"Bootstrap accessibility plugin\"), person(\"Dennis\", \"Lembree\", role = \"ctb\", comment = \"Bootstrap accessibility plugin\"), person(\"Srinivasu\", \"Chakravarthula\", role = \"ctb\", comment = \"Bootstrap accessibility plugin\"), person(\"Cathy\", \"O'Connor\", role = \"ctb\", comment = \"Bootstrap accessibility plugin\"), person(family = \"PayPal, Inc\", role = \"cph\", comment = \"Bootstrap accessibility plugin\"), person(\"Stefan\", \"Petre\", role = c(\"ctb\", \"cph\"), comment = \"Bootstrap-datepicker library\"), person(\"Andrew\", \"Rowls\", role = c(\"ctb\", \"cph\"), comment = \"Bootstrap-datepicker library\"), person(\"Brian\", \"Reavis\", role = c(\"ctb\", \"cph\"), comment = \"selectize.js library\"), person(\"Salmen\", \"Bejaoui\", role = c(\"ctb\", \"cph\"), comment = \"selectize-plugin-a11y library\"), person(\"Denis\", \"Ineshin\", role = c(\"ctb\", \"cph\"), comment = \"ion.rangeSlider library\"), person(\"Sami\", \"Samhuri\", role = c(\"ctb\", \"cph\"), comment = \"Javascript strftime library\"), person(family = \"SpryMedia Limited\", role = c(\"ctb\", \"cph\"), comment = \"DataTables library\"), person(\"John\", \"Fraser\", role = c(\"ctb\", \"cph\"), comment = \"showdown.js library\"), person(\"John\", \"Gruber\", role = c(\"ctb\", \"cph\"), comment = \"showdown.js library\"), person(\"Ivan\", \"Sagalaev\", role = c(\"ctb\", \"cph\"), comment = \"highlight.js library\"), person(family = \"R Core Team\", role = c(\"ctb\", \"cph\"), comment = \"tar implementation from R\") )", + "Description": "Makes it incredibly easy to build interactive web applications with R. Automatic \"reactive\" binding between inputs and outputs and extensive prebuilt widgets make it possible to build beautiful, responsive, and powerful applications with minimal effort.", + "License": "GPL-3 | file LICENSE", + "Depends": [ + "R (>= 3.0.2)", + "methods" + ], + "Imports": [ + "utils", + "grDevices", + "httpuv (>= 1.5.2)", + "mime (>= 0.3)", + "jsonlite (>= 0.9.16)", + "xtable", + "fontawesome (>= 0.4.0)", + "htmltools (>= 0.5.4)", + "R6 (>= 2.0)", + "sourcetools", + "later (>= 1.0.0)", + "promises (>= 1.1.0)", + "tools", + "crayon", + "rlang (>= 0.4.10)", + "fastmap (>= 1.1.1)", + "withr", + "commonmark (>= 1.7)", + "glue (>= 1.3.2)", + "bslib (>= 0.3.0)", + "cachem", + "lifecycle (>= 0.2.0)" + ], + "Suggests": [ + "datasets", + "DT", + "Cairo (>= 1.5-5)", + "testthat (>= 3.0.0)", + "knitr (>= 1.6)", + "markdown", + "rmarkdown", + "ggplot2", + "reactlog (>= 1.0.0)", + "magrittr", + "yaml", + "future", + "dygraphs", + "ragg", + "showtext", + "sass" + ], + "URL": "https://shiny.posit.co/, https://github.com/rstudio/shiny", + "BugReports": "https://github.com/rstudio/shiny/issues", + "Collate": "'globals.R' 'app-state.R' 'app_template.R' 'bind-cache.R' 'bind-event.R' 'bookmark-state-local.R' 'bookmark-state.R' 'bootstrap-deprecated.R' 'bootstrap-layout.R' 'conditions.R' 'map.R' 'utils.R' 'bootstrap.R' 'cache-utils.R' 'deprecated.R' 'devmode.R' 'diagnose.R' 'extended-task.R' 'fileupload.R' 'graph.R' 'reactives.R' 'reactive-domains.R' 'history.R' 'hooks.R' 'html-deps.R' 'image-interact-opts.R' 'image-interact.R' 'imageutils.R' 'input-action.R' 'input-checkbox.R' 'input-checkboxgroup.R' 'input-date.R' 'input-daterange.R' 'input-file.R' 'input-numeric.R' 'input-password.R' 'input-radiobuttons.R' 'input-select.R' 'input-slider.R' 'input-submit.R' 'input-text.R' 'input-textarea.R' 'input-utils.R' 'insert-tab.R' 'insert-ui.R' 'jqueryui.R' 'knitr.R' 'middleware-shiny.R' 'middleware.R' 'timer.R' 'shiny.R' 'mock-session.R' 'modal.R' 'modules.R' 'notifications.R' 'priorityqueue.R' 'progress.R' 'react.R' 'reexports.R' 'render-cached-plot.R' 'render-plot.R' 'render-table.R' 'run-url.R' 'runapp.R' 'serializers.R' 'server-input-handlers.R' 'server-resource-paths.R' 'server.R' 'shiny-options.R' 'shiny-package.R' 'shinyapp.R' 'shinyui.R' 'shinywrappers.R' 'showcase.R' 'snapshot.R' 'staticimports.R' 'tar.R' 'test-export.R' 'test-server.R' 'test.R' 'update-input.R' 'utils-lang.R' 'version_bs_date_picker.R' 'version_ion_range_slider.R' 'version_jquery.R' 'version_jqueryui.R' 'version_selectize.R' 'version_strftime.R' 'viewer.R'", + "RoxygenNote": "7.3.1", + "Encoding": "UTF-8", + "RdMacros": "lifecycle", + "Config/testthat/edition": "3", + "Config/Needs/check": "shinytest2", + "NeedsCompilation": "no", + "Author": "Winston Chang [aut, cre] (), Joe Cheng [aut], JJ Allaire [aut], Carson Sievert [aut] (), Barret Schloerke [aut] (), Yihui Xie [aut], Jeff Allen [aut], Jonathan McPherson [aut], Alan Dipert [aut], Barbara Borges [aut], Posit Software, PBC [cph, fnd], jQuery Foundation [cph] (jQuery library and jQuery UI library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt), jQuery UI contributors [ctb, cph] (jQuery UI library; authors listed in inst/www/shared/jqueryui/AUTHORS.txt), Mark Otto [ctb] (Bootstrap library), Jacob Thornton [ctb] (Bootstrap library), Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Prem Nawaz Khan [ctb] (Bootstrap accessibility plugin), Victor Tsaran [ctb] (Bootstrap accessibility plugin), Dennis Lembree [ctb] (Bootstrap accessibility plugin), Srinivasu Chakravarthula [ctb] (Bootstrap accessibility plugin), Cathy O'Connor [ctb] (Bootstrap accessibility plugin), PayPal, Inc [cph] (Bootstrap accessibility plugin), Stefan Petre [ctb, cph] (Bootstrap-datepicker library), Andrew Rowls [ctb, cph] (Bootstrap-datepicker library), Brian Reavis [ctb, cph] (selectize.js library), Salmen Bejaoui [ctb, cph] (selectize-plugin-a11y library), Denis Ineshin [ctb, cph] (ion.rangeSlider library), Sami Samhuri [ctb, cph] (Javascript strftime library), SpryMedia Limited [ctb, cph] (DataTables library), John Fraser [ctb, cph] (showdown.js library), John Gruber [ctb, cph] (showdown.js library), Ivan Sagalaev [ctb, cph] (highlight.js library), R Core Team [ctb, cph] (tar implementation from R)", + "Maintainer": "Winston Chang ", + "Repository": "CRAN" + }, + "sourcetools": { + "Package": "sourcetools", + "Version": "0.1.7-1", + "Source": "Repository", + "Type": "Package", + "Title": "Tools for Reading, Tokenizing and Parsing R Code", + "Author": "Kevin Ushey", + "Maintainer": "Kevin Ushey ", + "Description": "Tools for the reading and tokenization of R code. The 'sourcetools' package provides both an R and C++ interface for the tokenization of R code, and helpers for interacting with the tokenized representation of R code.", + "License": "MIT + file LICENSE", + "Depends": [ + "R (>= 3.0.2)" + ], + "Suggests": [ + "testthat" + ], + "RoxygenNote": "5.0.1", + "BugReports": "https://github.com/kevinushey/sourcetools/issues", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "sp": { + "Package": "sp", + "Version": "2.1-4", + "Source": "Repository", + "Title": "Classes and Methods for Spatial Data", + "Authors@R": "c(person(\"Edzer\", \"Pebesma\", role = c(\"aut\", \"cre\"), email = \"edzer.pebesma@uni-muenster.de\"), person(\"Roger\", \"Bivand\", role = \"aut\", email = \"Roger.Bivand@nhh.no\"), person(\"Barry\", \"Rowlingson\", role = \"ctb\"), person(\"Virgilio\", \"Gomez-Rubio\", role = \"ctb\"), person(\"Robert\", \"Hijmans\", role = \"ctb\"), person(\"Michael\", \"Sumner\", role = \"ctb\"), person(\"Don\", \"MacQueen\", role = \"ctb\"), person(\"Jim\", \"Lemon\", role = \"ctb\"), person(\"Finn\", \"Lindgren\", role = \"ctb\"), person(\"Josh\", \"O'Brien\", role = \"ctb\"), person(\"Joseph\", \"O'Rourke\", role = \"ctb\"), person(\"Patrick\", \"Hausmann\", role = \"ctb\"))", + "Depends": [ + "R (>= 3.5.0)", + "methods" + ], + "Imports": [ + "utils", + "stats", + "graphics", + "grDevices", + "lattice", + "grid" + ], + "Suggests": [ + "RColorBrewer", + "gstat", + "deldir", + "knitr", + "rmarkdown", + "sf", + "terra", + "raster" + ], + "Description": "Classes and methods for spatial data; the classes document where the spatial location information resides, for 2D or 3D data. Utility functions are provided, e.g. for plotting data as maps, spatial selection, as well as methods for retrieving coordinates, for subsetting, print, summary, etc. From this version, 'rgdal', 'maptools', and 'rgeos' are no longer used at all, see for details.", + "License": "GPL (>= 2)", + "URL": "https://github.com/edzer/sp/ https://edzer.github.io/sp/", + "BugReports": "https://github.com/edzer/sp/issues", + "Collate": "bpy.colors.R AAA.R Class-CRS.R CRS-methods.R Class-Spatial.R Spatial-methods.R projected.R Class-SpatialPoints.R SpatialPoints-methods.R Class-SpatialPointsDataFrame.R SpatialPointsDataFrame-methods.R Class-SpatialMultiPoints.R SpatialMultiPoints-methods.R Class-SpatialMultiPointsDataFrame.R SpatialMultiPointsDataFrame-methods.R Class-GridTopology.R Class-SpatialGrid.R Class-SpatialGridDataFrame.R Class-SpatialLines.R SpatialLines-methods.R Class-SpatialLinesDataFrame.R SpatialLinesDataFrame-methods.R Class-SpatialPolygons.R Class-SpatialPolygonsDataFrame.R SpatialPolygons-methods.R SpatialPolygonsDataFrame-methods.R GridTopology-methods.R SpatialGrid-methods.R SpatialGridDataFrame-methods.R SpatialPolygons-internals.R point.in.polygon.R SpatialPolygons-displayMethods.R zerodist.R image.R stack.R bubble.R mapasp.R select.spatial.R gridded.R asciigrid.R spplot.R over.R spsample.R recenter.R dms.R gridlines.R spdists.R rbind.R flipSGDF.R chfids.R loadmeuse.R compassRose.R surfaceArea.R spOptions.R subset.R disaggregate.R sp_spat1.R merge.R aggregate.R elide.R sp2Mondrian.R", + "VignetteBuilder": "knitr", + "NeedsCompilation": "yes", + "Author": "Edzer Pebesma [aut, cre], Roger Bivand [aut], Barry Rowlingson [ctb], Virgilio Gomez-Rubio [ctb], Robert Hijmans [ctb], Michael Sumner [ctb], Don MacQueen [ctb], Jim Lemon [ctb], Finn Lindgren [ctb], Josh O'Brien [ctb], Joseph O'Rourke [ctb], Patrick Hausmann [ctb]", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "spacetime": { + "Package": "spacetime", + "Version": "1.3-2", + "Source": "Repository", + "Title": "Classes and Methods for Spatio-Temporal Data", + "Authors@R": "c(person(\"Edzer\", \"Pebesma\", role = c(\"aut\", \"cre\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(\"Benedikt\", \"Graeler\", role = \"ctb\"), person(\"Tom\", \"Gottfried\", role = \"ctb\"), person(\"Robert J.\", \"Hijmans\", role = \"ctb\"))", + "Depends": [ + "R (>= 3.0.0)" + ], + "Imports": [ + "graphics", + "utils", + "stats", + "methods", + "lattice", + "sp (>= 1.1-0)", + "zoo (>= 1.7-9)", + "xts (>= 0.8-8)", + "intervals" + ], + "Suggests": [ + "adehabitatLT", + "cshapes (>= 2.0)", + "foreign", + "gstat (>= 1.0-16)", + "maps", + "mapdata", + "plm", + "raster", + "RColorBrewer", + "rmarkdown", + "RPostgreSQL", + "knitr", + "ISOcodes", + "markdown", + "sf", + "sftime" + ], + "LazyData": "no", + "Description": "Classes and methods for spatio-temporal data, including space-time regular lattices, sparse lattices, irregular data, and trajectories; utility functions for plotting data as map sequences (lattice or animation) or multiple time series; methods for spatial and temporal selection and subsetting, as well as for spatial/temporal/spatio-temporal matching or aggregation, retrieving coordinates, print, summary, etc.", + "License": "GPL (>= 2)", + "URL": "https://github.com/edzer/spacetime", + "BugReports": "https://github.com/edzer/spacetime/issues", + "Encoding": "UTF-8", + "VignetteBuilder": "knitr", + "Collate": "Class-xts.R Class-ST.R Class-STFDF.R Class-STSDF.R Class-STIDF.R Class-STTDF.R interval.R endtime.R ST-methods.R STFDF-methods.R STSDF-methods.R STIDF-methods.R STTDF-methods.R apply.R coerce.R stconstruct.R plot.R stplot.R timematch.R over.R aggregate.R eof.R mnf.R bind.R na.R raster.R tgrass.R stinteraction.R", + "NeedsCompilation": "no", + "Author": "Edzer Pebesma [aut, cre] (), Benedikt Graeler [ctb], Tom Gottfried [ctb], Robert J. Hijmans [ctb]", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "spam": { + "Package": "spam", + "Version": "2.10-0", + "Source": "Repository", + "Type": "Package", + "Title": "SPArse Matrix", + "Date": "2023-10-23", + "Authors@R": "c(person(\"Reinhard\", \"Furrer\", role = c(\"aut\", \"cre\"), email = \"reinhard.furrer@math.uzh.ch\", comment = c(ORCID = \"0000-0002-6319-2332\")), person(\"Florian\", \"Gerber\", role = c(\"aut\"), email = \"florian.gerber@math.uzh.ch\", comment = c(ORCID = \"0000-0001-8545-5263\")), person(\"Roman\", \"Flury\", role = c(\"aut\"), email = \"roman.flury@math.uzh.ch\", comment = c(ORCID = \"0000-0002-0349-8698\")), person(\"Daniel\", \"Gerber\", role = \"ctb\", email = \"daniel_gerber_2222@hotmail.com\"), person(\"Kaspar\", \"Moesinger\", role = \"ctb\", email = \"kaspar.moesinger@gmail.com\"), person(\"Cincera\", \"Annina\", email = \"annina.cincera@math.uzh.ch\", role = \"ctb\"), person(\"Youcef\", \"Saad\", role = \"ctb\", comment = \"SPARSEKIT http://www-users.cs.umn.edu/~saad/software/SPARSKIT/\"), person(c(\"Esmond\", \"G.\"), \"Ng\", role = \"ctb\", comment = \"Fortran Cholesky routines\"), person(c(\"Barry\", \"W.\"), \"Peyton\", role = \"ctb\", comment = \"Fortran Cholesky routines\"), person(c(\"Joseph\", \"W.H.\"), \"Liu\", role = \"ctb\", comment = \"Fortran Cholesky routines\"), person(c(\"Alan\", \"D.\"), \"George\", role = \"ctb\", comment = \"Fortran Cholesky routines\"), person(c(\"Lehoucq\", \"B.\"), \"Rich\", role = \"ctb\", comment = \"ARPACK\"), person(c(\"Maschhoff\"), \"Kristi\", role = \"ctb\", comment = \"ARPACK\"), person(c(\"Sorensen\", \"C.\"), \"Danny\", role = \"ctb\", comment = \"ARPACK\"), person(c(\"Yang\"), \"Chao\", role = \"ctb\", comment = \"ARPACK\"))", + "Depends": [ + "R (>= 3.5)" + ], + "Imports": [ + "dotCall64", + "grid", + "methods", + "Rcpp (>= 1.0.8.3)" + ], + "LinkingTo": [ + "Rcpp" + ], + "Suggests": [ + "spam64", + "fields", + "Matrix", + "testthat", + "R.rsp", + "truncdist", + "knitr", + "rmarkdown" + ], + "VignetteBuilder": "R.rsp, knitr", + "Description": "Set of functions for sparse matrix algebra. Differences with other sparse matrix packages are: (1) we only support (essentially) one sparse matrix format, (2) based on transparent and simple structure(s), (3) tailored for MCMC calculations within G(M)RF. (4) and it is fast and scalable (with the extension package spam64). Documentation about 'spam' is provided by vignettes included in this package, see also Furrer and Sain (2010) ; see 'citation(\"spam\")' for details.", + "LazyData": "true", + "License": "LGPL-2 | BSD_3_clause + file LICENSE", + "URL": "https://www.math.uzh.ch/pages/spam/", + "BugReports": "https://git.math.uzh.ch/reinhard.furrer/spam/-/issues", + "NeedsCompilation": "yes", + "Author": "Reinhard Furrer [aut, cre] (), Florian Gerber [aut] (), Roman Flury [aut] (), Daniel Gerber [ctb], Kaspar Moesinger [ctb], Cincera Annina [ctb], Youcef Saad [ctb] (SPARSEKIT http://www-users.cs.umn.edu/~saad/software/SPARSKIT/), Esmond G. Ng [ctb] (Fortran Cholesky routines), Barry W. Peyton [ctb] (Fortran Cholesky routines), Joseph W.H. Liu [ctb] (Fortran Cholesky routines), Alan D. George [ctb] (Fortran Cholesky routines), Lehoucq B. Rich [ctb] (ARPACK), Maschhoff Kristi [ctb] (ARPACK), Sorensen C. Danny [ctb] (ARPACK), Yang Chao [ctb] (ARPACK)", + "Maintainer": "Reinhard Furrer ", + "Repository": "CRAN" + }, + "stars": { + "Package": "stars", + "Version": "0.6-8", + "Source": "Repository", + "Title": "Spatiotemporal Arrays, Raster and Vector Data Cubes", + "Authors@R": "c(person(given = \"Edzer\", family = \"Pebesma\", role = c(\"aut\", \"cre\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(given = \"Michael\", family = \"Sumner\", role = \"ctb\", comment=c(ORCID = \"0000-0002-2471-7511\")), person(given = \"Etienne\", family = \"Racine\", role = \"ctb\"), person(given = \"Adriano\", family = \"Fantini\", role = \"ctb\"), person(given = \"David\", family = \"Blodgett\", role = \"ctb\"), person(given = \"Krzysztof\", family = \"Dyba\", role = \"ctb\", comment=c(ORCID = \"0000-0002-8614-3816\")))", + "Description": "Reading, manipulating, writing and plotting spatiotemporal arrays (raster and vector data cubes) in 'R', using 'GDAL' bindings provided by 'sf', and 'NetCDF' bindings by 'ncmeta' and 'RNetCDF'.", + "License": "Apache License", + "URL": "https://r-spatial.github.io/stars/, https://github.com/r-spatial/stars/", + "BugReports": "https://github.com/r-spatial/stars/issues/", + "Additional_repositories": "https://cran.uni-muenster.de/pebesma/", + "LazyData": "true", + "Depends": [ + "R (>= 3.3.0)", + "abind", + "sf (>= 1.0-19)" + ], + "Imports": [ + "methods", + "parallel", + "classInt (>= 0.4-1)", + "rlang", + "units" + ], + "Suggests": [ + "Cairo", + "OpenStreetMap", + "PCICt", + "RNetCDF (>= 1.8-2)", + "clue", + "covr", + "cubble (>= 0.3.0)", + "cubelyr", + "digest", + "dplyr (>= 0.7-0)", + "exactextractr", + "FNN", + "future.apply", + "ggforce", + "ggplot2", + "ggthemes", + "gstat", + "httr", + "jsonlite", + "knitr", + "lwgeom", + "maps", + "mapdata", + "ncdfgeom", + "ncmeta (>= 0.0.3)", + "pbapply", + "plm", + "randomForest", + "raster", + "rmarkdown", + "sp", + "spacetime", + "spatstat (>= 2.0-1)", + "spatstat.geom", + "starsdata", + "terra (>= 1.4-22)", + "testthat", + "tibble", + "tidyr", + "tsibble", + "viridis", + "xts", + "zoo" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Collate": "'aggregate.R' 'cubble.R' 'datasets.R' 'dimensions.R' 'extract.R' 'factors.R' 'geom.R' 'gt.R' 'init.R' 'intervals.R' 'mdim.R' 'mosaic.R' 'ncdf.R' 'ncproxy.R' 'OpenStreetMap.R' 'ops.R' 'plot.R' 'prcomp.R' 'proxy.R' 'rasterize.R' 'raster.R' 'read.R' 'rotate.R' 'sample.R' 'sf.R' 'spacetime.R' 'spatstat.R' 'sp.R' 'stars.R' 'subset.R' 'tidyverse.R' 'tile.R' 'transform.R' 'values.R' 'warp.R' 'write.R' 'xts.R'", + "NeedsCompilation": "no", + "Author": "Edzer Pebesma [aut, cre] (), Michael Sumner [ctb] (), Etienne Racine [ctb], Adriano Fantini [ctb], David Blodgett [ctb], Krzysztof Dyba [ctb] ()", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "stringi": { + "Package": "stringi", + "Version": "1.8.4", + "Source": "Repository", + "Date": "2024-05-06", + "Title": "Fast and Portable Character String Processing Facilities", + "Description": "A collection of character string/text/natural language processing tools for pattern searching (e.g., with 'Java'-like regular expressions or the 'Unicode' collation algorithm), random string generation, case mapping, string transliteration, concatenation, sorting, padding, wrapping, Unicode normalisation, date-time formatting and parsing, and many more. They are fast, consistent, convenient, and - thanks to 'ICU' (International Components for Unicode) - portable across all locales and platforms. Documentation about 'stringi' is provided via its website at and the paper by Gagolewski (2022, ).", + "URL": "https://stringi.gagolewski.com/, https://github.com/gagolews/stringi, https://icu.unicode.org/", + "BugReports": "https://github.com/gagolews/stringi/issues", + "SystemRequirements": "ICU4C (>= 61, optional)", + "Type": "Package", + "Depends": [ + "R (>= 3.4)" + ], + "Imports": [ + "tools", + "utils", + "stats" + ], + "Biarch": "TRUE", + "License": "file LICENSE", + "Author": "Marek Gagolewski [aut, cre, cph] (), Bartek Tartanus [ctb], and others (stringi source code); Unicode, Inc. and others (ICU4C source code, Unicode Character Database)", + "Maintainer": "Marek Gagolewski ", + "RoxygenNote": "7.2.3", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "License_is_FOSS": "yes", + "Repository": "CRAN" + }, + "stringr": { + "Package": "stringr", + "Version": "1.5.1", + "Source": "Repository", + "Title": "Simple, Consistent Wrappers for Common String Operations", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\", \"cph\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A consistent, simple and easy to use set of wrappers around the fantastic 'stringi' package. All function and argument names (and positions) are consistent, all functions deal with \"NA\"'s and zero length vectors in the same way, and the output from one function is easy to feed into the input of another.", + "License": "MIT + file LICENSE", + "URL": "https://stringr.tidyverse.org, https://github.com/tidyverse/stringr", + "BugReports": "https://github.com/tidyverse/stringr/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli", + "glue (>= 1.6.1)", + "lifecycle (>= 1.0.3)", + "magrittr", + "rlang (>= 1.0.0)", + "stringi (>= 1.5.3)", + "vctrs (>= 0.4.0)" + ], + "Suggests": [ + "covr", + "dplyr", + "gt", + "htmltools", + "htmlwidgets", + "knitr", + "rmarkdown", + "testthat (>= 3.0.0)", + "tibble" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre, cph], Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "sys": { + "Package": "sys", + "Version": "3.4.2", + "Source": "Repository", + "Type": "Package", + "Title": "Powerful and Reliable Tools for Running System Commands in R", + "Authors@R": "c(person(\"Jeroen\", \"Ooms\", role = c(\"aut\", \"cre\"), email = \"jeroen@berkeley.edu\", comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = \"ctb\"))", + "Description": "Drop-in replacements for the base system2() function with fine control and consistent behavior across platforms. Supports clean interruption, timeout, background tasks, and streaming STDIN / STDOUT / STDERR over binary or text connections. Arguments on Windows automatically get encoded and quoted to work on different locales.", + "License": "MIT + file LICENSE", + "URL": "https://jeroen.r-universe.dev/sys", + "BugReports": "https://github.com/jeroen/sys/issues", + "Encoding": "UTF-8", + "RoxygenNote": "7.1.1", + "Suggests": [ + "unix (>= 1.4)", + "spelling", + "testthat" + ], + "Language": "en-US", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] (), Gábor Csárdi [ctb]", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "systemfonts": { + "Package": "systemfonts", + "Version": "1.1.0", + "Source": "Repository", + "Type": "Package", + "Title": "System Native Font Finding", + "Authors@R": "c( person(\"Thomas Lin\", \"Pedersen\", , \"thomas.pedersen@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-5147-4711\")), person(\"Jeroen\", \"Ooms\", , \"jeroen@berkeley.edu\", role = \"aut\", comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"Devon\", \"Govett\", role = \"aut\", comment = \"Author of font-manager\"), person(\"Posit, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides system native access to the font catalogue. As font handling varies between systems it is difficult to correctly locate installed fonts across different operating systems. The 'systemfonts' package provides bindings to the native libraries on Windows, macOS and Linux for finding font files that can then be used further by e.g. graphic devices. The main use is intended to be from compiled code but 'systemfonts' also provides access from R.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/systemfonts, https://systemfonts.r-lib.org", + "BugReports": "https://github.com/r-lib/systemfonts/issues", + "Depends": [ + "R (>= 3.2.0)" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown", + "testthat (>= 2.1.0)", + "tools" + ], + "LinkingTo": [ + "cpp11 (>= 0.2.1)" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "SystemRequirements": "fontconfig, freetype2", + "Config/Needs/website": "tidyverse/tidytemplate", + "Imports": [ + "lifecycle" + ], + "NeedsCompilation": "yes", + "Author": "Thomas Lin Pedersen [aut, cre] (), Jeroen Ooms [aut] (), Devon Govett [aut] (Author of font-manager), Posit, PBC [cph, fnd]", + "Maintainer": "Thomas Lin Pedersen ", + "Repository": "CRAN" + }, + "terra": { + "Package": "terra", + "Version": "1.8-21", + "Source": "Repository", + "Type": "Package", + "Title": "Spatial Data Analysis", + "Date": "2025-02-09", + "Depends": [ + "R (>= 3.5.0)" + ], + "Suggests": [ + "parallel", + "tinytest", + "ncdf4", + "sf (>= 0.9-8)", + "deldir", + "XML", + "leaflet (>= 2.2.1)", + "htmlwidgets" + ], + "LinkingTo": [ + "Rcpp" + ], + "Imports": [ + "methods", + "Rcpp (>= 1.0-10)" + ], + "SystemRequirements": "C++17, GDAL (>= 2.2.3), GEOS (>= 3.4.0), PROJ (>= 4.9.3), sqlite3", + "Encoding": "UTF-8", + "Language": "en-US", + "Maintainer": "Robert J. Hijmans ", + "Description": "Methods for spatial data analysis with vector (points, lines, polygons) and raster (grid) data. Methods for vector data include geometric operations such as intersect and buffer. Raster methods include local, focal, global, zonal and geometric operations. The predict and interpolate methods facilitate the use of regression type (interpolation, machine learning) models for spatial prediction, including with satellite remote sensing data. Processing of very large files is supported. See the manual and tutorials on to get started. 'terra' replaces the 'raster' package ('terra' can do more, and it is faster and easier to use).", + "License": "GPL (>= 3)", + "URL": "https://rspatial.org/, https://rspatial.github.io/terra/", + "BugReports": "https://github.com/rspatial/terra/issues/", + "LazyLoad": "yes", + "Authors@R": "c( person(\"Robert J.\", \"Hijmans\", role=c(\"cre\", \"aut\"), email=\"r.hijmans@gmail.com\", comment=c(ORCID=\"0000-0001-5872-2872\")),\t\t\t person(\"Márcia\", \"Barbosa\", role=\"ctb\"), person(\"Roger\", \"Bivand\", role=\"ctb\", comment=c(ORCID=\"0000-0003-2392-6140\")), person(\"Andrew\", \"Brown\", role=\"ctb\"), person(\"Michael\", \"Chirico\", role=\"ctb\"), person(\"Emanuele\", \"Cordano\", role=\"ctb\",comment=c(ORCID=\"0000-0002-3508-5898\")), person(\"Krzysztof\", \"Dyba\", role=\"ctb\", comment=c(ORCID=\"0000-0002-8614-3816\")), person(\"Edzer\", \"Pebesma\", role=\"ctb\", comment=c(ORCID=\"0000-0001-8049-7069\")), person(\"Barry\", \"Rowlingson\", role=\"ctb\"), person(\"Michael D.\", \"Sumner\", role=\"ctb\"))", + "NeedsCompilation": "yes", + "Author": "Robert J. Hijmans [cre, aut] (), Márcia Barbosa [ctb], Roger Bivand [ctb] (), Andrew Brown [ctb], Michael Chirico [ctb], Emanuele Cordano [ctb] (), Krzysztof Dyba [ctb] (), Edzer Pebesma [ctb] (), Barry Rowlingson [ctb], Michael D. Sumner [ctb]", + "Repository": "CRAN" + }, + "testthat": { + "Package": "testthat", + "Version": "3.2.3", + "Source": "Repository", + "Title": "Unit Testing for R", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"R Core team\", role = \"ctb\", comment = \"Implementation of utils::recover()\") )", + "Description": "Software testing is important, but, in part because it is frustrating and boring, many of us avoid it. 'testthat' is a testing framework for R that is easy to learn and use, and integrates with your existing 'workflow'.", + "License": "MIT + file LICENSE", + "URL": "https://testthat.r-lib.org, https://github.com/r-lib/testthat", + "BugReports": "https://github.com/r-lib/testthat/issues", + "Depends": [ + "R (>= 3.6.0)" + ], + "Imports": [ + "brio (>= 1.1.3)", + "callr (>= 3.7.3)", + "cli (>= 3.6.1)", + "desc (>= 1.4.2)", + "digest (>= 0.6.33)", + "evaluate (>= 1.0.1)", + "jsonlite (>= 1.8.7)", + "lifecycle (>= 1.0.3)", + "magrittr (>= 2.0.3)", + "methods", + "pkgload (>= 1.3.2.1)", + "praise (>= 1.0.0)", + "processx (>= 3.8.2)", + "ps (>= 1.7.5)", + "R6 (>= 2.5.1)", + "rlang (>= 1.1.1)", + "utils", + "waldo (>= 0.6.0)", + "withr (>= 3.0.2)" + ], + "Suggests": [ + "covr", + "curl (>= 0.9.5)", + "diffviewer (>= 0.1.0)", + "knitr", + "rmarkdown", + "rstudioapi", + "S7", + "shiny", + "usethis", + "vctrs (>= 0.1.0)", + "xml2" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "watcher, parallel*", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre], Posit Software, PBC [cph, fnd], R Core team [ctb] (Implementation of utils::recover())", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "textshaping": { + "Package": "textshaping", + "Version": "0.4.0", + "Source": "Repository", + "Title": "Bindings to the 'HarfBuzz' and 'Fribidi' Libraries for Text Shaping", + "Authors@R": "c( person(\"Thomas Lin\", \"Pedersen\", , \"thomas.pedersen@posit.co\", role = c(\"cre\", \"aut\"), comment = c(ORCID = \"0000-0002-5147-4711\")), person(\"Posit, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides access to the text shaping functionality in the 'HarfBuzz' library and the bidirectional algorithm in the 'Fribidi' library. 'textshaping' is a low-level utility package mainly for graphic devices that expands upon the font tool-set provided by the 'systemfonts' package.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/textshaping", + "BugReports": "https://github.com/r-lib/textshaping/issues", + "Depends": [ + "R (>= 3.2.0)" + ], + "Imports": [ + "lifecycle", + "systemfonts (>= 1.1.0)" + ], + "Suggests": [ + "covr", + "knitr", + "rmarkdown" + ], + "LinkingTo": [ + "cpp11 (>= 0.2.1)", + "systemfonts (>= 1.0.0)" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.1", + "SystemRequirements": "freetype2, harfbuzz, fribidi", + "NeedsCompilation": "yes", + "Author": "Thomas Lin Pedersen [cre, aut] (), Posit, PBC [cph, fnd]", + "Maintainer": "Thomas Lin Pedersen ", + "Repository": "CRAN" + }, + "tibble": { + "Package": "tibble", + "Version": "3.2.1", + "Source": "Repository", + "Title": "Simple Data Frames", + "Authors@R": "c(person(given = \"Kirill\", family = \"M\\u00fcller\", role = c(\"aut\", \"cre\"), email = \"kirill@cynkra.com\", comment = c(ORCID = \"0000-0002-1416-3412\")), person(given = \"Hadley\", family = \"Wickham\", role = \"aut\", email = \"hadley@rstudio.com\"), person(given = \"Romain\", family = \"Francois\", role = \"ctb\", email = \"romain@r-enthusiasts.com\"), person(given = \"Jennifer\", family = \"Bryan\", role = \"ctb\", email = \"jenny@rstudio.com\"), person(given = \"RStudio\", role = c(\"cph\", \"fnd\")))", + "Description": "Provides a 'tbl_df' class (the 'tibble') with stricter checking and better formatting than the traditional data frame.", + "License": "MIT + file LICENSE", + "URL": "https://tibble.tidyverse.org/, https://github.com/tidyverse/tibble", + "BugReports": "https://github.com/tidyverse/tibble/issues", + "Depends": [ + "R (>= 3.4.0)" + ], + "Imports": [ + "fansi (>= 0.4.0)", + "lifecycle (>= 1.0.0)", + "magrittr", + "methods", + "pillar (>= 1.8.1)", + "pkgconfig", + "rlang (>= 1.0.2)", + "utils", + "vctrs (>= 0.4.2)" + ], + "Suggests": [ + "bench", + "bit64", + "blob", + "brio", + "callr", + "cli", + "covr", + "crayon (>= 1.3.4)", + "DiagrammeR", + "dplyr", + "evaluate", + "formattable", + "ggplot2", + "here", + "hms", + "htmltools", + "knitr", + "lubridate", + "mockr", + "nycflights13", + "pkgbuild", + "pkgload", + "purrr", + "rmarkdown", + "stringi", + "testthat (>= 3.0.2)", + "tidyr", + "withr" + ], + "VignetteBuilder": "knitr", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "true", + "Config/testthat/start-first": "vignette-formats, as_tibble, add, invariants", + "Config/autostyle/scope": "line_breaks", + "Config/autostyle/strict": "true", + "Config/autostyle/rmd": "false", + "Config/Needs/website": "tidyverse/tidytemplate", + "NeedsCompilation": "yes", + "Author": "Kirill Müller [aut, cre] (), Hadley Wickham [aut], Romain Francois [ctb], Jennifer Bryan [ctb], RStudio [cph, fnd]", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "tidyr": { + "Package": "tidyr", + "Version": "1.3.1", + "Source": "Repository", + "Title": "Tidy Messy Data", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Davis\", \"Vaughan\", , \"davis@posit.co\", role = \"aut\"), person(\"Maximilian\", \"Girlich\", role = \"aut\"), person(\"Kevin\", \"Ushey\", , \"kevin@posit.co\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Tools to help to create tidy data, where each column is a variable, each row is an observation, and each cell contains a single value. 'tidyr' contains tools for changing the shape (pivoting) and hierarchy (nesting and 'unnesting') of a dataset, turning deeply nested lists into rectangular data frames ('rectangling'), and extracting values out of string columns. It also includes tools for working with missing values (both implicit and explicit).", + "License": "MIT + file LICENSE", + "URL": "https://tidyr.tidyverse.org, https://github.com/tidyverse/tidyr", + "BugReports": "https://github.com/tidyverse/tidyr/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli (>= 3.4.1)", + "dplyr (>= 1.0.10)", + "glue", + "lifecycle (>= 1.0.3)", + "magrittr", + "purrr (>= 1.0.1)", + "rlang (>= 1.1.1)", + "stringr (>= 1.5.0)", + "tibble (>= 2.1.1)", + "tidyselect (>= 1.2.0)", + "utils", + "vctrs (>= 0.5.2)" + ], + "Suggests": [ + "covr", + "data.table", + "knitr", + "readr", + "repurrrsive (>= 1.1.0)", + "rmarkdown", + "testthat (>= 3.0.0)" + ], + "LinkingTo": [ + "cpp11 (>= 0.4.0)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "LazyData": "true", + "RoxygenNote": "7.3.0", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre], Davis Vaughan [aut], Maximilian Girlich [aut], Kevin Ushey [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "tidyselect": { + "Package": "tidyselect", + "Version": "1.2.1", + "Source": "Repository", + "Title": "Select from a Set of Strings", + "Authors@R": "c( person(\"Lionel\", \"Henry\", , \"lionel@posit.co\", role = c(\"aut\", \"cre\")), person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A backend for the selecting functions of the 'tidyverse'. It makes it easy to implement select-like functions in your own packages in a way that is consistent with other 'tidyverse' interfaces for selection.", + "License": "MIT + file LICENSE", + "URL": "https://tidyselect.r-lib.org, https://github.com/r-lib/tidyselect", + "BugReports": "https://github.com/r-lib/tidyselect/issues", + "Depends": [ + "R (>= 3.4)" + ], + "Imports": [ + "cli (>= 3.3.0)", + "glue (>= 1.3.0)", + "lifecycle (>= 1.0.3)", + "rlang (>= 1.0.4)", + "vctrs (>= 0.5.2)", + "withr" + ], + "Suggests": [ + "covr", + "crayon", + "dplyr", + "knitr", + "magrittr", + "rmarkdown", + "stringr", + "testthat (>= 3.1.1)", + "tibble (>= 2.1.3)" + ], + "VignetteBuilder": "knitr", + "ByteCompile": "true", + "Config/testthat/edition": "3", + "Config/Needs/website": "tidyverse/tidytemplate", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.0.9000", + "NeedsCompilation": "yes", + "Author": "Lionel Henry [aut, cre], Hadley Wickham [aut], Posit Software, PBC [cph, fnd]", + "Maintainer": "Lionel Henry ", + "Repository": "CRAN" + }, + "timechange": { + "Package": "timechange", + "Version": "0.3.0", + "Source": "Repository", + "Title": "Efficient Manipulation of Date-Times", + "Authors@R": "c(person(\"Vitalie\", \"Spinu\", email = \"spinuvit@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Google Inc.\", role = c(\"ctb\", \"cph\")))", + "Description": "Efficient routines for manipulation of date-time objects while accounting for time-zones and daylight saving times. The package includes utilities for updating of date-time components (year, month, day etc.), modification of time-zones, rounding of date-times, period addition and subtraction etc. Parts of the 'CCTZ' source code, released under the Apache 2.0 License, are included in this package. See for more details.", + "Depends": [ + "R (>= 3.3)" + ], + "License": "GPL (>= 3)", + "Encoding": "UTF-8", + "LinkingTo": [ + "cpp11 (>= 0.2.7)" + ], + "Suggests": [ + "testthat (>= 0.7.1.99)", + "knitr" + ], + "SystemRequirements": "A system with zoneinfo data (e.g. /usr/share/zoneinfo) as well as a recent-enough C++11 compiler (such as g++-4.8 or later). On Windows the zoneinfo included with R is used.", + "BugReports": "https://github.com/vspinu/timechange/issues", + "URL": "https://github.com/vspinu/timechange/", + "RoxygenNote": "7.2.1", + "NeedsCompilation": "yes", + "Author": "Vitalie Spinu [aut, cre], Google Inc. [ctb, cph]", + "Maintainer": "Vitalie Spinu ", + "Repository": "CRAN" + }, + "tinytex": { + "Package": "tinytex", + "Version": "0.57", + "Source": "Repository", + "Type": "Package", + "Title": "Helper Functions to Install and Maintain TeX Live, and Compile LaTeX Documents", + "Authors@R": "c( person(\"Yihui\", \"Xie\", role = c(\"aut\", \"cre\", \"cph\"), email = \"xie@yihui.name\", comment = c(ORCID = \"0000-0003-0645-5666\")), person(given = \"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"Christophe\", \"Dervieux\", role = \"ctb\", comment = c(ORCID = \"0000-0003-4474-2498\")), person(\"Devon\", \"Ryan\", role = \"ctb\", email = \"dpryan79@gmail.com\", comment = c(ORCID = \"0000-0002-8549-0971\")), person(\"Ethan\", \"Heinzen\", role = \"ctb\"), person(\"Fernando\", \"Cagua\", role = \"ctb\"), person() )", + "Description": "Helper functions to install and maintain the 'LaTeX' distribution named 'TinyTeX' (), a lightweight, cross-platform, portable, and easy-to-maintain version of 'TeX Live'. This package also contains helper functions to compile 'LaTeX' documents, and install missing 'LaTeX' packages automatically.", + "Imports": [ + "xfun (>= 0.48)" + ], + "Suggests": [ + "testit", + "rstudioapi" + ], + "License": "MIT + file LICENSE", + "URL": "https://github.com/rstudio/tinytex", + "BugReports": "https://github.com/rstudio/tinytex/issues", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "no", + "Author": "Yihui Xie [aut, cre, cph] (), Posit Software, PBC [cph, fnd], Christophe Dervieux [ctb] (), Devon Ryan [ctb] (), Ethan Heinzen [ctb], Fernando Cagua [ctb]", + "Maintainer": "Yihui Xie ", + "Repository": "CRAN" + }, + "trafficlight": { + "Package": "trafficlight", + "Version": "1.15.1", + "Source": "Repository", + "Type": "Package", + "Title": "traffic light - Tools for data validation", + "Date": "2024-01-16", + "Authors@R": "c(person(\"Jan Philipp\", \"Dietrich\", email = \"dietrich@pik-potsdam.de\", role = c(\"aut\",\"cre\")), person(\"Markus Bonsch\", \"Bonsch\", role = c(\"aut\")))", + "Maintainer": "Jan Philipp Dietrich ", + "Description": "The package contains tools for data validation and aggregation of validation results.", + "Depends": [ + "R(>= 2.10.0)" + ], + "Imports": [ + "magclass", + "ggplot2", + "qualV" + ], + "License": "LGPL-3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.0", + "Repository": "https://rse.pik-potsdam.de/r/packages", + "RemoteUrl": "https://github.com/pik-piam/trafficlight", + "RemoteRef": "HEAD", + "RemoteSha": "3ff25cf3c1c9a9d60f1e92c5de0714e44ac923a3", + "NeedsCompilation": "no", + "Author": "Jan Philipp Dietrich [aut, cre], Markus Bonsch Bonsch [aut]" + }, + "txtplot": { + "Package": "txtplot", + "Version": "1.0-4", + "Source": "Repository", + "Type": "Package", + "Title": "Text Based Plots", + "Date": "2020-04-04", + "Authors@R": "c(person(\"Bjoern\", \"Bornkamp\", email = \"bbnkmp@mail.de\", role = c(\"aut\", \"cre\")), person(\"Ivan\", \"Krylov\", email = \"krylov.r00t@gmail.com\", role = c(\"ctb\"), comment = \"txtimage\"))", + "Description": "Provides functions to produce rudimentary ascii graphics directly in the terminal window. Provides a basic plotting function (and equivalents of curve, density, acf and barplot) as well as boxplot and image functions.", + "License": "LGPL", + "LazyLoad": "yes", + "Repository": "CRAN", + "NeedsCompilation": "no", + "Author": "Bjoern Bornkamp [aut, cre], Ivan Krylov [ctb] (txtimage)", + "Maintainer": "Bjoern Bornkamp " + }, + "tzdb": { + "Package": "tzdb", + "Version": "0.4.0", + "Source": "Repository", + "Title": "Time Zone Database Information", + "Authors@R": "c( person(\"Davis\", \"Vaughan\", , \"davis@posit.co\", role = c(\"aut\", \"cre\")), person(\"Howard\", \"Hinnant\", role = \"cph\", comment = \"Author of the included date library\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provides an up-to-date copy of the Internet Assigned Numbers Authority (IANA) Time Zone Database. It is updated periodically to reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight saving time rules. Additionally, this package provides a C++ interface for working with the 'date' library. 'date' provides comprehensive support for working with dates and date-times, which this package exposes to make it easier for other R packages to utilize. Headers are provided for calendar specific calculations, along with a limited interface for time zone manipulations.", + "License": "MIT + file LICENSE", + "URL": "https://tzdb.r-lib.org, https://github.com/r-lib/tzdb", + "BugReports": "https://github.com/r-lib/tzdb/issues", + "Depends": [ + "R (>= 3.5.0)" + ], + "Suggests": [ + "covr", + "testthat (>= 3.0.0)" + ], + "LinkingTo": [ + "cpp11 (>= 0.4.2)" + ], + "Biarch": "yes", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Davis Vaughan [aut, cre], Howard Hinnant [cph] (Author of the included date library), Posit Software, PBC [cph, fnd]", + "Maintainer": "Davis Vaughan ", + "Repository": "CRAN" + }, + "units": { + "Package": "units", + "Version": "0.8-7", + "Source": "Repository", + "Title": "Measurement Units for R Vectors", + "Authors@R": "c(person(\"Edzer\", \"Pebesma\", role = c(\"aut\", \"cre\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(\"Thomas\", \"Mailund\", role = \"aut\", email = \"mailund@birc.au.dk\"), person(\"Tomasz\", \"Kalinowski\", role = \"aut\"), person(\"James\", \"Hiebert\", role = \"ctb\"), person(\"Iñaki\", \"Ucar\", role = \"aut\", email = \"iucar@fedoraproject.org\", comment = c(ORCID = \"0000-0001-6403-5550\")), person(\"Thomas Lin\", \"Pedersen\", role = \"ctb\") )", + "Depends": [ + "R (>= 3.0.2)" + ], + "Imports": [ + "Rcpp" + ], + "LinkingTo": [ + "Rcpp (>= 0.12.10)" + ], + "Suggests": [ + "NISTunits", + "measurements", + "xml2", + "magrittr", + "pillar (>= 1.3.0)", + "dplyr (>= 1.0.0)", + "vctrs (>= 0.3.1)", + "ggplot2 (> 3.2.1)", + "testthat (>= 3.0.0)", + "vdiffr", + "knitr", + "rvest", + "rmarkdown" + ], + "VignetteBuilder": "knitr", + "Description": "Support for measurement units in R vectors, matrices and arrays: automatic propagation, conversion, derivation and simplification of units; raising errors in case of unit incompatibility. Compatible with the POSIXct, Date and difftime classes. Uses the UNIDATA udunits library and unit database for unit compatibility checking and conversion. Documentation about 'units' is provided in the paper by Pebesma, Mailund & Hiebert (2016, ), included in this package as a vignette; see 'citation(\"units\")' for details.", + "SystemRequirements": "udunits-2", + "License": "GPL-2", + "URL": "https://r-quantities.github.io/units/, https://github.com/r-quantities/units", + "BugReports": "https://github.com/r-quantities/units/issues", + "RoxygenNote": "7.3.2", + "Encoding": "UTF-8", + "Config/testthat/edition": "3", + "NeedsCompilation": "yes", + "Author": "Edzer Pebesma [aut, cre] (), Thomas Mailund [aut], Tomasz Kalinowski [aut], James Hiebert [ctb], Iñaki Ucar [aut] (), Thomas Lin Pedersen [ctb]", + "Maintainer": "Edzer Pebesma ", + "Repository": "CRAN" + }, + "urlchecker": { + "Package": "urlchecker", + "Version": "1.0.1", + "Source": "Repository", + "Title": "Run CRAN URL Checks from Older R Versions", + "Authors@R": "c( person(\"R Core team\", role = \"aut\", comment = \"The code in urltools.R adapted from the tools package\"), person(\"Jim\", \"Hester\", role = \"aut\", comment = c(ORCID = \"0000-0002-2739-7082\")), person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"RStudio\", role = c(\"cph\", \"fnd\")) )", + "Description": "Provide the URL checking tools available in R 4.1+ as a package for earlier versions of R. Also uses concurrent requests so can be much faster than the serial versions.", + "License": "GPL-3", + "URL": "https://github.com/r-lib/urlchecker", + "BugReports": "https://github.com/r-lib/urlchecker/issues", + "Depends": [ + "R (>= 3.3)" + ], + "Imports": [ + "cli", + "curl", + "tools", + "xml2" + ], + "Suggests": [ + "covr" + ], + "Encoding": "UTF-8", + "RoxygenNote": "7.1.2", + "NeedsCompilation": "no", + "Author": "R Core team [aut] (The code in urltools.R adapted from the tools package), Jim Hester [aut] (), Gábor Csárdi [aut, cre], RStudio [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "usethis": { + "Package": "usethis", + "Version": "2.2.3", + "Source": "Repository", + "Title": "Automate Package and Project Setup", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Jennifer\", \"Bryan\", , \"jenny@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-6983-2759\")), person(\"Malcolm\", \"Barrett\", , \"malcolmbarrett@gmail.com\", role = \"aut\", comment = c(ORCID = \"0000-0003-0299-5825\")), person(\"Andy\", \"Teucher\", , \"andy.teucher@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0002-7840-692X\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Automate package and project setup tasks that are otherwise performed manually. This includes setting up unit testing, test coverage, continuous integration, Git, 'GitHub', licenses, 'Rcpp', 'RStudio' projects, and more.", + "License": "MIT + file LICENSE", + "URL": "https://usethis.r-lib.org, https://github.com/r-lib/usethis", + "BugReports": "https://github.com/r-lib/usethis/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "cli (>= 3.0.1)", + "clipr (>= 0.3.0)", + "crayon", + "curl (>= 2.7)", + "desc (>= 1.4.2)", + "fs (>= 1.3.0)", + "gert (>= 1.4.1)", + "gh (>= 1.2.1)", + "glue (>= 1.3.0)", + "jsonlite", + "lifecycle (>= 1.0.0)", + "purrr", + "rappdirs", + "rlang (>= 1.1.0)", + "rprojroot (>= 1.2)", + "rstudioapi", + "stats", + "utils", + "whisker", + "withr (>= 2.3.0)", + "yaml" + ], + "Suggests": [ + "covr", + "knitr", + "magick", + "pkgload (>= 1.3.2.1)", + "rmarkdown", + "roxygen2 (>= 7.1.2)", + "spelling (>= 1.2)", + "styler (>= 1.2.0)", + "testthat (>= 3.1.8)" + ], + "Config/Needs/website": "tidyverse/tidytemplate, xml2", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "TRUE", + "Config/testthat/start-first": "github-actions, release", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut] (), Jennifer Bryan [aut, cre] (), Malcolm Barrett [aut] (), Andy Teucher [aut] (), Posit Software, PBC [cph, fnd]", + "Maintainer": "Jennifer Bryan ", + "Repository": "CRAN" + }, + "utf8": { + "Package": "utf8", + "Version": "1.2.4", + "Source": "Repository", + "Title": "Unicode Text Processing", + "Authors@R": "c(person(given = c(\"Patrick\", \"O.\"), family = \"Perry\", role = c(\"aut\", \"cph\")), person(given = \"Kirill\", family = \"M\\u00fcller\", role = \"cre\", email = \"kirill@cynkra.com\"), person(given = \"Unicode, Inc.\", role = c(\"cph\", \"dtc\"), comment = \"Unicode Character Database\"))", + "Description": "Process and print 'UTF-8' encoded international text (Unicode). Input, validate, normalize, encode, format, and display.", + "License": "Apache License (== 2.0) | file LICENSE", + "URL": "https://ptrckprry.com/r-utf8/, https://github.com/patperry/r-utf8", + "BugReports": "https://github.com/patperry/r-utf8/issues", + "Depends": [ + "R (>= 2.10)" + ], + "Suggests": [ + "cli", + "covr", + "knitr", + "rlang", + "rmarkdown", + "testthat (>= 3.0.0)", + "withr" + ], + "VignetteBuilder": "knitr, rmarkdown", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Patrick O. Perry [aut, cph], Kirill Müller [cre], Unicode, Inc. [cph, dtc] (Unicode Character Database)", + "Maintainer": "Kirill Müller ", + "Repository": "CRAN" + }, + "uuid": { + "Package": "uuid", + "Version": "1.2-0", + "Source": "Repository", + "Title": "Tools for Generating and Handling of UUIDs", + "Author": "Simon Urbanek (R package), Theodore Ts'o (libuuid)", + "Maintainer": "Simon Urbanek ", + "Depends": [ + "R (>= 2.9.0)" + ], + "Description": "Tools for generating and handling of UUIDs (Universally Unique Identifiers).", + "License": "MIT + file LICENSE", + "URL": "https://www.rforge.net/uuid", + "BugReports": "https://github.com/s-u/uuid", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "vctrs": { + "Package": "vctrs", + "Version": "0.6.5", + "Source": "Repository", + "Title": "Vector Helpers", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Lionel\", \"Henry\", , \"lionel@posit.co\", role = \"aut\"), person(\"Davis\", \"Vaughan\", , \"davis@posit.co\", role = c(\"aut\", \"cre\")), person(\"data.table team\", role = \"cph\", comment = \"Radix sort based on data.table's forder() and their contribution to R's order()\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Defines new notions of prototype and size that are used to provide tools for consistent and well-founded type-coercion and size-recycling, and are in turn connected to ideas of type- and size-stability useful for analysing function interfaces.", + "License": "MIT + file LICENSE", + "URL": "https://vctrs.r-lib.org/, https://github.com/r-lib/vctrs", + "BugReports": "https://github.com/r-lib/vctrs/issues", + "Depends": [ + "R (>= 3.5.0)" + ], + "Imports": [ + "cli (>= 3.4.0)", + "glue", + "lifecycle (>= 1.0.3)", + "rlang (>= 1.1.0)" + ], + "Suggests": [ + "bit64", + "covr", + "crayon", + "dplyr (>= 0.8.5)", + "generics", + "knitr", + "pillar (>= 1.4.4)", + "pkgdown (>= 2.0.1)", + "rmarkdown", + "testthat (>= 3.0.0)", + "tibble (>= 3.1.3)", + "waldo (>= 0.2.0)", + "withr", + "xml2", + "zeallot" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "Language": "en-GB", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut], Lionel Henry [aut], Davis Vaughan [aut, cre], data.table team [cph] (Radix sort based on data.table's forder() and their contribution to R's order()), Posit Software, PBC [cph, fnd]", + "Maintainer": "Davis Vaughan ", + "Repository": "CRAN" + }, + "viridis": { + "Package": "viridis", + "Version": "0.6.5", + "Source": "Repository", + "Type": "Package", + "Title": "Colorblind-Friendly Color Maps for R", + "Date": "2024-01-28", + "Authors@R": "c( person(\"Simon\", \"Garnier\", email = \"garnier@njit.edu\", role = c(\"aut\", \"cre\")), person(\"Noam\", \"Ross\", email = \"noam.ross@gmail.com\", role = c(\"ctb\", \"cph\")), person(\"Bob\", \"Rudis\", email = \"bob@rud.is\", role = c(\"ctb\", \"cph\")), person(\"Marco\", \"Sciaini\", email = \"sciaini.marco@gmail.com\", role = c(\"ctb\", \"cph\")), person(\"Antônio Pedro\", \"Camargo\", role = c(\"ctb\", \"cph\")), person(\"Cédric\", \"Scherer\", email = \"scherer@izw-berlin.de\", role = c(\"ctb\", \"cph\")) )", + "Maintainer": "Simon Garnier ", + "Description": "Color maps designed to improve graph readability for readers with common forms of color blindness and/or color vision deficiency. The color maps are also perceptually-uniform, both in regular form and also when converted to black-and-white for printing. This package also contains 'ggplot2' bindings for discrete and continuous color and fill scales. A lean version of the package called 'viridisLite' that does not include the 'ggplot2' bindings can be found at .", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "Depends": [ + "R (>= 2.10)", + "viridisLite (>= 0.4.0)" + ], + "Imports": [ + "ggplot2 (>= 1.0.1)", + "gridExtra" + ], + "Suggests": [ + "hexbin (>= 1.27.0)", + "scales", + "MASS", + "knitr", + "dichromat", + "colorspace", + "httr", + "mapproj", + "vdiffr", + "svglite (>= 1.2.0)", + "testthat", + "covr", + "rmarkdown", + "maps", + "terra" + ], + "LazyData": "true", + "VignetteBuilder": "knitr", + "URL": "https://sjmgarnier.github.io/viridis/, https://github.com/sjmgarnier/viridis/", + "BugReports": "https://github.com/sjmgarnier/viridis/issues", + "RoxygenNote": "7.3.1", + "NeedsCompilation": "no", + "Author": "Simon Garnier [aut, cre], Noam Ross [ctb, cph], Bob Rudis [ctb, cph], Marco Sciaini [ctb, cph], Antônio Pedro Camargo [ctb, cph], Cédric Scherer [ctb, cph]", + "Repository": "CRAN" + }, + "viridisLite": { + "Package": "viridisLite", + "Version": "0.4.2", + "Source": "Repository", + "Type": "Package", + "Title": "Colorblind-Friendly Color Maps (Lite Version)", + "Date": "2023-05-02", + "Authors@R": "c( person(\"Simon\", \"Garnier\", email = \"garnier@njit.edu\", role = c(\"aut\", \"cre\")), person(\"Noam\", \"Ross\", email = \"noam.ross@gmail.com\", role = c(\"ctb\", \"cph\")), person(\"Bob\", \"Rudis\", email = \"bob@rud.is\", role = c(\"ctb\", \"cph\")), person(\"Marco\", \"Sciaini\", email = \"sciaini.marco@gmail.com\", role = c(\"ctb\", \"cph\")), person(\"Antônio Pedro\", \"Camargo\", role = c(\"ctb\", \"cph\")), person(\"Cédric\", \"Scherer\", email = \"scherer@izw-berlin.de\", role = c(\"ctb\", \"cph\")) )", + "Maintainer": "Simon Garnier ", + "Description": "Color maps designed to improve graph readability for readers with common forms of color blindness and/or color vision deficiency. The color maps are also perceptually-uniform, both in regular form and also when converted to black-and-white for printing. This is the 'lite' version of the 'viridis' package that also contains 'ggplot2' bindings for discrete and continuous color and fill scales and can be found at .", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "Depends": [ + "R (>= 2.10)" + ], + "Suggests": [ + "hexbin (>= 1.27.0)", + "ggplot2 (>= 1.0.1)", + "testthat", + "covr" + ], + "URL": "https://sjmgarnier.github.io/viridisLite/, https://github.com/sjmgarnier/viridisLite/", + "BugReports": "https://github.com/sjmgarnier/viridisLite/issues/", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Simon Garnier [aut, cre], Noam Ross [ctb, cph], Bob Rudis [ctb, cph], Marco Sciaini [ctb, cph], Antônio Pedro Camargo [ctb, cph], Cédric Scherer [ctb, cph]", + "Repository": "CRAN" + }, + "vroom": { + "Package": "vroom", + "Version": "1.6.5", + "Source": "Repository", + "Title": "Read and Write Rectangular Text Data Quickly", + "Authors@R": "c( person(\"Jim\", \"Hester\", role = \"aut\", comment = c(ORCID = \"0000-0002-2739-7082\")), person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\", comment = c(ORCID = \"0000-0003-4757-117X\")), person(\"Jennifer\", \"Bryan\", , \"jenny@posit.co\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-6983-2759\")), person(\"Shelby\", \"Bearrows\", role = \"ctb\"), person(\"https://github.com/mandreyel/\", role = \"cph\", comment = \"mio library\"), person(\"Jukka\", \"Jylänki\", role = \"cph\", comment = \"grisu3 implementation\"), person(\"Mikkel\", \"Jørgensen\", role = \"cph\", comment = \"grisu3 implementation\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "The goal of 'vroom' is to read and write data (like 'csv', 'tsv' and 'fwf') quickly. When reading it uses a quick initial indexing step, then reads the values lazily , so only the data you actually use needs to be read. The writer formats the data in parallel and writes to disk asynchronously from formatting.", + "License": "MIT + file LICENSE", + "URL": "https://vroom.r-lib.org, https://github.com/tidyverse/vroom", + "BugReports": "https://github.com/tidyverse/vroom/issues", + "Depends": [ + "R (>= 3.6)" + ], + "Imports": [ + "bit64", + "cli (>= 3.2.0)", + "crayon", + "glue", + "hms", + "lifecycle (>= 1.0.3)", + "methods", + "rlang (>= 0.4.2)", + "stats", + "tibble (>= 2.0.0)", + "tidyselect", + "tzdb (>= 0.1.1)", + "vctrs (>= 0.2.0)", + "withr" + ], + "Suggests": [ + "archive", + "bench (>= 1.1.0)", + "covr", + "curl", + "dplyr", + "forcats", + "fs", + "ggplot2", + "knitr", + "patchwork", + "prettyunits", + "purrr", + "rmarkdown", + "rstudioapi", + "scales", + "spelling", + "testthat (>= 2.1.0)", + "tidyr", + "utils", + "waldo", + "xml2" + ], + "LinkingTo": [ + "cpp11 (>= 0.2.0)", + "progress (>= 1.2.1)", + "tzdb (>= 0.1.1)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "nycflights13, tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Config/testthat/parallel": "false", + "Copyright": "file COPYRIGHTS", + "Encoding": "UTF-8", + "Language": "en-US", + "RoxygenNote": "7.2.3.9000", + "NeedsCompilation": "yes", + "Author": "Jim Hester [aut] (), Hadley Wickham [aut] (), Jennifer Bryan [aut, cre] (), Shelby Bearrows [ctb], https://github.com/mandreyel/ [cph] (mio library), Jukka Jylänki [cph] (grisu3 implementation), Mikkel Jørgensen [cph] (grisu3 implementation), Posit Software, PBC [cph, fnd]", + "Maintainer": "Jennifer Bryan ", + "Repository": "CRAN" + }, + "waldo": { + "Package": "waldo", + "Version": "0.6.1", + "Source": "Repository", + "Title": "Find Differences Between R Objects", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Compare complex R objects and reveal the key differences. Designed particularly for use in testing packages where being able to quickly isolate key differences makes understanding test failures much easier.", + "License": "MIT + file LICENSE", + "URL": "https://waldo.r-lib.org, https://github.com/r-lib/waldo", + "BugReports": "https://github.com/r-lib/waldo/issues", + "Depends": [ + "R (>= 4.0)" + ], + "Imports": [ + "cli", + "diffobj (>= 0.3.4)", + "glue", + "methods", + "rlang (>= 1.1.0)" + ], + "Suggests": [ + "bit64", + "R6", + "S7", + "testthat (>= 3.0.0)", + "withr", + "xml2" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "NeedsCompilation": "no", + "Author": "Hadley Wickham [aut, cre], Posit Software, PBC [cph, fnd]", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "whisker": { + "Package": "whisker", + "Version": "0.4.1", + "Source": "Repository", + "Maintainer": "Edwin de Jonge ", + "License": "GPL-3", + "Title": "{{mustache}} for R, Logicless Templating", + "Type": "Package", + "LazyLoad": "yes", + "Author": "Edwin de Jonge", + "Description": "Implements 'Mustache' logicless templating.", + "URL": "https://github.com/edwindj/whisker", + "Suggests": [ + "markdown" + ], + "RoxygenNote": "6.1.1", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "withr": { + "Package": "withr", + "Version": "3.0.2", + "Source": "Repository", + "Title": "Run Code 'With' Temporarily Modified Global State", + "Authors@R": "c( person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Lionel\", \"Henry\", , \"lionel@posit.co\", role = c(\"aut\", \"cre\")), person(\"Kirill\", \"Müller\", , \"krlmlr+r@mailbox.org\", role = \"aut\"), person(\"Kevin\", \"Ushey\", , \"kevinushey@gmail.com\", role = \"aut\"), person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = \"aut\"), person(\"Winston\", \"Chang\", role = \"aut\"), person(\"Jennifer\", \"Bryan\", role = \"ctb\"), person(\"Richard\", \"Cotton\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "A set of functions to run code 'with' safely and temporarily modified global state. Many of these functions were originally a part of the 'devtools' package, this provides a simple package with limited dependencies to provide access to these functions.", + "License": "MIT + file LICENSE", + "URL": "https://withr.r-lib.org, https://github.com/r-lib/withr#readme", + "BugReports": "https://github.com/r-lib/withr/issues", + "Depends": [ + "R (>= 3.6.0)" + ], + "Imports": [ + "graphics", + "grDevices" + ], + "Suggests": [ + "callr", + "DBI", + "knitr", + "methods", + "rlang", + "rmarkdown (>= 2.12)", + "RSQLite", + "testthat (>= 3.0.0)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "Collate": "'aaa.R' 'collate.R' 'connection.R' 'db.R' 'defer-exit.R' 'standalone-defer.R' 'defer.R' 'devices.R' 'local_.R' 'with_.R' 'dir.R' 'env.R' 'file.R' 'language.R' 'libpaths.R' 'locale.R' 'makevars.R' 'namespace.R' 'options.R' 'par.R' 'path.R' 'rng.R' 'seed.R' 'wrap.R' 'sink.R' 'tempfile.R' 'timezone.R' 'torture.R' 'utils.R' 'with.R'", + "NeedsCompilation": "no", + "Author": "Jim Hester [aut], Lionel Henry [aut, cre], Kirill Müller [aut], Kevin Ushey [aut], Hadley Wickham [aut], Winston Chang [aut], Jennifer Bryan [ctb], Richard Cotton [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Lionel Henry ", + "Repository": "CRAN" + }, + "wk": { + "Package": "wk", + "Version": "0.9.1", + "Source": "Repository", + "Title": "Lightweight Well-Known Geometry Parsing", + "Authors@R": "c( person(given = \"Dewey\", family = \"Dunnington\", role = c(\"aut\", \"cre\"), email = \"dewey@fishandwhistle.net\", comment = c(ORCID = \"0000-0002-9415-4582\")), person(given = \"Edzer\", family = \"Pebesma\", role = c(\"aut\"), email = \"edzer.pebesma@uni-muenster.de\", comment = c(ORCID = \"0000-0001-8049-7069\")), person(given = \"Anthony\", family = \"North\", email = \"anthony.jl.north@gmail.com\", role = c(\"ctb\")) )", + "Maintainer": "Dewey Dunnington ", + "Description": "Provides a minimal R and C++ API for parsing well-known binary and well-known text representation of geometries to and from R-native formats. Well-known binary is compact and fast to parse; well-known text is human-readable and is useful for writing tests. These formats are useful in R only if the information they contain can be accessed in R, for which high-performance functions are provided here.", + "License": "MIT + file LICENSE", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "Suggests": [ + "testthat (>= 3.0.0)", + "vctrs (>= 0.3.0)", + "sf", + "tibble", + "readr" + ], + "URL": "https://paleolimbot.github.io/wk/, https://github.com/paleolimbot/wk", + "BugReports": "https://github.com/paleolimbot/wk/issues", + "Config/testthat/edition": "3", + "Depends": [ + "R (>= 2.10)" + ], + "LazyData": "true", + "NeedsCompilation": "yes", + "Author": "Dewey Dunnington [aut, cre] (), Edzer Pebesma [aut] (), Anthony North [ctb]", + "Repository": "CRAN" + }, + "writexl": { + "Package": "writexl", + "Version": "1.5.0", + "Source": "Repository", + "Type": "Package", + "Title": "Export Data Frames to Excel 'xlsx' Format", + "Authors@R": "c( person(\"Jeroen\", \"Ooms\", ,\"jeroen@berkeley.edu\", role = c(\"aut\", \"cre\"), comment = c(ORCID = \"0000-0002-4035-0289\")), person(\"John McNamara\", role = \"cph\", comment = \"Author of libxlsxwriter (see AUTHORS and COPYRIGHT files for details)\"))", + "Description": "Zero-dependency data frame to xlsx exporter based on 'libxlsxwriter'. Fast and no Java or Excel required.", + "License": "BSD_2_clause + file LICENSE", + "Encoding": "UTF-8", + "URL": "https://docs.ropensci.org/writexl/ (website) https://github.com/ropensci/writexl (devel) https://libxlsxwriter.github.io (upstream)", + "BugReports": "https://github.com/ropensci/writexl/issues", + "RoxygenNote": "7.0.2", + "Suggests": [ + "spelling", + "readxl", + "nycflights13", + "testthat", + "bit64" + ], + "Language": "en-US", + "SystemRequirements": "zlib", + "NeedsCompilation": "yes", + "Author": "Jeroen Ooms [aut, cre] (), John McNamara [cph] (Author of libxlsxwriter (see AUTHORS and COPYRIGHT files for details))", + "Maintainer": "Jeroen Ooms ", + "Repository": "CRAN" + }, + "xfun": { + "Package": "xfun", + "Version": "0.53", + "Source": "Repository", + "Type": "Package", + "Title": "Supporting Functions for Packages Maintained by 'Yihui Xie'", + "Authors@R": "c( person(\"Yihui\", \"Xie\", role = c(\"aut\", \"cre\", \"cph\"), email = \"xie@yihui.name\", comment = c(ORCID = \"0000-0003-0645-5666\", URL = \"https://yihui.org\")), person(\"Wush\", \"Wu\", role = \"ctb\"), person(\"Daijiang\", \"Li\", role = \"ctb\"), person(\"Xianying\", \"Tan\", role = \"ctb\"), person(\"Salim\", \"Brüggemann\", role = \"ctb\", email = \"salim-b@pm.me\", comment = c(ORCID = \"0000-0002-5329-5987\")), person(\"Christophe\", \"Dervieux\", role = \"ctb\"), person() )", + "Description": "Miscellaneous functions commonly used in other packages maintained by 'Yihui Xie'.", + "Depends": [ + "R (>= 3.2.0)" + ], + "Imports": [ + "grDevices", + "stats", + "tools" + ], + "Suggests": [ + "testit", + "parallel", + "codetools", + "methods", + "rstudioapi", + "tinytex (>= 0.30)", + "mime", + "litedown (>= 0.6)", + "commonmark", + "knitr (>= 1.50)", + "remotes", + "pak", + "curl", + "xml2", + "jsonlite", + "magick", + "yaml", + "data.table", + "qs" + ], + "License": "MIT + file LICENSE", + "URL": "https://github.com/yihui/xfun", + "BugReports": "https://github.com/yihui/xfun/issues", + "Encoding": "UTF-8", + "RoxygenNote": "7.3.2", + "VignetteBuilder": "litedown", + "NeedsCompilation": "yes", + "Author": "Yihui Xie [aut, cre, cph] (ORCID: , URL: https://yihui.org), Wush Wu [ctb], Daijiang Li [ctb], Xianying Tan [ctb], Salim Brüggemann [ctb] (ORCID: ), Christophe Dervieux [ctb]", + "Maintainer": "Yihui Xie ", + "Repository": "CRAN" + }, + "xml2": { + "Package": "xml2", + "Version": "1.3.6", + "Source": "Repository", + "Title": "Parse XML", + "Authors@R": "c( person(\"Hadley\", \"Wickham\", , \"hadley@posit.co\", role = c(\"aut\", \"cre\")), person(\"Jim\", \"Hester\", role = \"aut\"), person(\"Jeroen\", \"Ooms\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")), person(\"R Foundation\", role = \"ctb\", comment = \"Copy of R-project homepage cached as example\") )", + "Description": "Work with XML files using a simple, consistent interface. Built on top of the 'libxml2' C library.", + "License": "MIT + file LICENSE", + "URL": "https://xml2.r-lib.org/, https://github.com/r-lib/xml2", + "BugReports": "https://github.com/r-lib/xml2/issues", + "Depends": [ + "R (>= 3.6.0)" + ], + "Imports": [ + "cli", + "methods", + "rlang (>= 1.1.0)" + ], + "Suggests": [ + "covr", + "curl", + "httr", + "knitr", + "magrittr", + "mockery", + "rmarkdown", + "testthat (>= 3.0.0)" + ], + "VignetteBuilder": "knitr", + "Config/Needs/website": "tidyverse/tidytemplate", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "SystemRequirements": "libxml2: libxml2-dev (deb), libxml2-devel (rpm)", + "Collate": "'S4.R' 'as_list.R' 'xml_parse.R' 'as_xml_document.R' 'classes.R' 'format.R' 'import-standalone-obj-type.R' 'import-standalone-purrr.R' 'import-standalone-types-check.R' 'init.R' 'nodeset_apply.R' 'paths.R' 'utils.R' 'xml2-package.R' 'xml_attr.R' 'xml_children.R' 'xml_document.R' 'xml_find.R' 'xml_missing.R' 'xml_modify.R' 'xml_name.R' 'xml_namespaces.R' 'xml_node.R' 'xml_nodeset.R' 'xml_path.R' 'xml_schema.R' 'xml_serialize.R' 'xml_structure.R' 'xml_text.R' 'xml_type.R' 'xml_url.R' 'xml_write.R' 'zzz.R'", + "Config/testthat/edition": "3", + "NeedsCompilation": "yes", + "Author": "Hadley Wickham [aut, cre], Jim Hester [aut], Jeroen Ooms [aut], Posit Software, PBC [cph, fnd], R Foundation [ctb] (Copy of R-project homepage cached as example)", + "Maintainer": "Hadley Wickham ", + "Repository": "CRAN" + }, + "xmlparsedata": { + "Package": "xmlparsedata", + "Version": "1.0.5", + "Source": "Repository", + "Title": "Parse Data of 'R' Code as an 'XML' Tree", + "Author": "Gábor Csárdi", + "Maintainer": "Gábor Csárdi ", + "Description": "Convert the output of 'utils::getParseData()' to an 'XML' tree, that one can search via 'XPath', and easier to manipulate in general.", + "License": "MIT + file LICENSE", + "LazyData": "true", + "URL": "https://github.com/r-lib/xmlparsedata#readme", + "BugReports": "https://github.com/r-lib/xmlparsedata/issues", + "RoxygenNote": "6.0.1", + "Suggests": [ + "covr", + "testthat", + "xml2" + ], + "Depends": [ + "R (>= 3.0.0)" + ], + "Encoding": "UTF-8", + "NeedsCompilation": "no", + "Repository": "CRAN" + }, + "xopen": { + "Package": "xopen", + "Version": "1.0.1", + "Source": "Repository", + "Title": "Open System Files, 'URLs', Anything", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Fathi\", \"Boudra\", role = \"aut\"), person(\"Rex\", \"Dieter\", role = \"aut\"), person(\"Kevin\", \"Krammer\", role = \"aut\"), person(\"Jeremy\", \"White\", role = \"aut\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Cross platform solution to open files, directories or 'URLs' with their associated programs.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/xopen#readme, https://r-lib.github.io/xopen/", + "BugReports": "https://github.com/r-lib/xopen/issues", + "Depends": [ + "R (>= 3.1)" + ], + "Imports": [ + "processx" + ], + "Suggests": [ + "ps", + "testthat (>= 3.0.0)" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "no", + "Author": "Gábor Csárdi [aut, cre], Fathi Boudra [aut], Rex Dieter [aut], Kevin Krammer [aut], Jeremy White [aut], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "xtable": { + "Package": "xtable", + "Version": "1.8-4", + "Source": "Repository", + "Date": "2019-04-08", + "Title": "Export Tables to LaTeX or HTML", + "Authors@R": "c(person(\"David B.\", \"Dahl\", role=\"aut\"), person(\"David\", \"Scott\", role=c(\"aut\",\"cre\"), email=\"d.scott@auckland.ac.nz\"), person(\"Charles\", \"Roosen\", role=\"aut\"), person(\"Arni\", \"Magnusson\", role=\"aut\"), person(\"Jonathan\", \"Swinton\", role=\"aut\"), person(\"Ajay\", \"Shah\", role=\"ctb\"), person(\"Arne\", \"Henningsen\", role=\"ctb\"), person(\"Benno\", \"Puetz\", role=\"ctb\"), person(\"Bernhard\", \"Pfaff\", role=\"ctb\"), person(\"Claudio\", \"Agostinelli\", role=\"ctb\"), person(\"Claudius\", \"Loehnert\", role=\"ctb\"), person(\"David\", \"Mitchell\", role=\"ctb\"), person(\"David\", \"Whiting\", role=\"ctb\"), person(\"Fernando da\", \"Rosa\", role=\"ctb\"), person(\"Guido\", \"Gay\", role=\"ctb\"), person(\"Guido\", \"Schulz\", role=\"ctb\"), person(\"Ian\", \"Fellows\", role=\"ctb\"), person(\"Jeff\", \"Laake\", role=\"ctb\"), person(\"John\", \"Walker\", role=\"ctb\"), person(\"Jun\", \"Yan\", role=\"ctb\"), person(\"Liviu\", \"Andronic\", role=\"ctb\"), person(\"Markus\", \"Loecher\", role=\"ctb\"), person(\"Martin\", \"Gubri\", role=\"ctb\"), person(\"Matthieu\", \"Stigler\", role=\"ctb\"), person(\"Robert\", \"Castelo\", role=\"ctb\"), person(\"Seth\", \"Falcon\", role=\"ctb\"), person(\"Stefan\", \"Edwards\", role=\"ctb\"), person(\"Sven\", \"Garbade\", role=\"ctb\"), person(\"Uwe\", \"Ligges\", role=\"ctb\"))", + "Maintainer": "David Scott ", + "Imports": [ + "stats", + "utils" + ], + "Suggests": [ + "knitr", + "plm", + "zoo", + "survival" + ], + "VignetteBuilder": "knitr", + "Description": "Coerce data to LaTeX and HTML tables.", + "URL": "http://xtable.r-forge.r-project.org/", + "Depends": [ + "R (>= 2.10.0)" + ], + "License": "GPL (>= 2)", + "Repository": "CRAN", + "NeedsCompilation": "no", + "Author": "David B. Dahl [aut], David Scott [aut, cre], Charles Roosen [aut], Arni Magnusson [aut], Jonathan Swinton [aut], Ajay Shah [ctb], Arne Henningsen [ctb], Benno Puetz [ctb], Bernhard Pfaff [ctb], Claudio Agostinelli [ctb], Claudius Loehnert [ctb], David Mitchell [ctb], David Whiting [ctb], Fernando da Rosa [ctb], Guido Gay [ctb], Guido Schulz [ctb], Ian Fellows [ctb], Jeff Laake [ctb], John Walker [ctb], Jun Yan [ctb], Liviu Andronic [ctb], Markus Loecher [ctb], Martin Gubri [ctb], Matthieu Stigler [ctb], Robert Castelo [ctb], Seth Falcon [ctb], Stefan Edwards [ctb], Sven Garbade [ctb], Uwe Ligges [ctb]" + }, + "xts": { + "Package": "xts", + "Version": "0.14.1", + "Source": "Repository", + "Type": "Package", + "Title": "eXtensible Time Series", + "Authors@R": "c( person(given=c(\"Jeffrey\",\"A.\"), family=\"Ryan\", role=c(\"aut\",\"cph\")), person(given=c(\"Joshua\",\"M.\"), family=\"Ulrich\", role=c(\"cre\",\"aut\"), email=\"josh.m.ulrich@gmail.com\"), person(given=\"Ross\", family=\"Bennett\", role=\"ctb\"), person(given=\"Corwin\", family=\"Joy\", role=\"ctb\") )", + "Depends": [ + "R (>= 3.6.0)", + "zoo (>= 1.7-12)" + ], + "Imports": [ + "methods" + ], + "LinkingTo": [ + "zoo" + ], + "Suggests": [ + "timeSeries", + "timeDate", + "tseries", + "chron", + "tinytest" + ], + "LazyLoad": "yes", + "Description": "Provide for uniform handling of R's different time-based data classes by extending zoo, maximizing native format information preservation and allowing for user level customization and extension, while simplifying cross-class interoperability.", + "License": "GPL (>= 2)", + "URL": "https://joshuaulrich.github.io/xts/, https://github.com/joshuaulrich/xts", + "BugReports": "https://github.com/joshuaulrich/xts/issues", + "Encoding": "UTF-8", + "NeedsCompilation": "yes", + "Author": "Jeffrey A. Ryan [aut, cph], Joshua M. Ulrich [cre, aut], Ross Bennett [ctb], Corwin Joy [ctb]", + "Maintainer": "Joshua M. Ulrich ", + "Repository": "CRAN" + }, + "yaml": { + "Package": "yaml", + "Version": "2.3.10", + "Source": "Repository", + "Type": "Package", + "Title": "Methods to Convert R Data to YAML and Back", + "Date": "2024-07-22", + "Suggests": [ + "RUnit" + ], + "Author": "Shawn P Garbett [aut], Jeremy Stephens [aut, cre], Kirill Simonov [aut], Yihui Xie [ctb], Zhuoer Dong [ctb], Hadley Wickham [ctb], Jeffrey Horner [ctb], reikoch [ctb], Will Beasley [ctb], Brendan O'Connor [ctb], Gregory R. Warnes [ctb], Michael Quinn [ctb], Zhian N. Kamvar [ctb], Charlie Gao [ctb]", + "Maintainer": "Shawn Garbett ", + "License": "BSD_3_clause + file LICENSE", + "Description": "Implements the 'libyaml' 'YAML' 1.1 parser and emitter () for R.", + "URL": "https://github.com/vubiostat/r-yaml/", + "BugReports": "https://github.com/vubiostat/r-yaml/issues", + "NeedsCompilation": "yes", + "Repository": "CRAN" + }, + "zip": { + "Package": "zip", + "Version": "2.3.1", + "Source": "Repository", + "Title": "Cross-Platform 'zip' Compression", + "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"csardi.gabor@gmail.com\", role = c(\"aut\", \"cre\")), person(\"Kuba\", \"Podgórski\", role = \"ctb\"), person(\"Rich\", \"Geldreich\", role = \"ctb\"), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )", + "Description": "Cross-Platform 'zip' Compression Library. A replacement for the 'zip' function, that does not require any additional external tools on any platform.", + "License": "MIT + file LICENSE", + "URL": "https://github.com/r-lib/zip, https://r-lib.github.io/zip/", + "BugReports": "https://github.com/r-lib/zip/issues", + "Suggests": [ + "covr", + "processx", + "R6", + "testthat", + "withr" + ], + "Config/Needs/website": "tidyverse/tidytemplate", + "Config/testthat/edition": "3", + "Encoding": "UTF-8", + "RoxygenNote": "7.2.3", + "NeedsCompilation": "yes", + "Author": "Gábor Csárdi [aut, cre], Kuba Podgórski [ctb], Rich Geldreich [ctb], Posit Software, PBC [cph, fnd]", + "Maintainer": "Gábor Csárdi ", + "Repository": "CRAN" + }, + "zoo": { + "Package": "zoo", + "Version": "1.8-12", + "Source": "Repository", + "Date": "2023-04-11", + "Title": "S3 Infrastructure for Regular and Irregular Time Series (Z's Ordered Observations)", + "Authors@R": "c(person(given = \"Achim\", family = \"Zeileis\", role = c(\"aut\", \"cre\"), email = \"Achim.Zeileis@R-project.org\", comment = c(ORCID = \"0000-0003-0918-3766\")), person(given = \"Gabor\", family = \"Grothendieck\", role = \"aut\", email = \"ggrothendieck@gmail.com\"), person(given = c(\"Jeffrey\", \"A.\"), family = \"Ryan\", role = \"aut\", email = \"jeff.a.ryan@gmail.com\"), person(given = c(\"Joshua\", \"M.\"), family = \"Ulrich\", role = \"ctb\", email = \"josh.m.ulrich@gmail.com\"), person(given = \"Felix\", family = \"Andrews\", role = \"ctb\", email = \"felix@nfrac.org\"))", + "Description": "An S3 class with methods for totally ordered indexed observations. It is particularly aimed at irregular time series of numeric vectors/matrices and factors. zoo's key design goals are independence of a particular index/date/time class and consistency with ts and base R by providing methods to extend standard generics.", + "Depends": [ + "R (>= 3.1.0)", + "stats" + ], + "Suggests": [ + "AER", + "coda", + "chron", + "ggplot2 (>= 3.0.0)", + "mondate", + "scales", + "stinepack", + "strucchange", + "timeDate", + "timeSeries", + "tis", + "tseries", + "xts" + ], + "Imports": [ + "utils", + "graphics", + "grDevices", + "lattice (>= 0.20-27)" + ], + "License": "GPL-2 | GPL-3", + "URL": "https://zoo.R-Forge.R-project.org/", + "NeedsCompilation": "yes", + "Author": "Achim Zeileis [aut, cre] (), Gabor Grothendieck [aut], Jeffrey A. Ryan [aut], Joshua M. Ulrich [ctb], Felix Andrews [ctb]", + "Maintainer": "Achim Zeileis ", + "Repository": "CRAN" + } + } +} diff --git a/renv/settings.json b/renv/settings.json new file mode 100644 index 0000000000..3331ef2535 --- /dev/null +++ b/renv/settings.json @@ -0,0 +1,17 @@ +{ + "bioconductor.version": [], + "external.libraries": [], + "ignored.packages": [], + "package.dependency.fields": [ + "Imports", + "Depends", + "LinkingTo" + ], + "r.version": [], + "snapshot.type": "implicit", + "use.cache": true, + "vcs.ignore.cellar": true, + "vcs.ignore.library": true, + "vcs.ignore.local": true, + "vcs.manage.ignores": true +} diff --git a/scripts/calibration/calc_calib.R b/scripts/calibration/calc_calib.R index 45c323a825..5b132a31ba 100644 --- a/scripts/calibration/calc_calib.R +++ b/scripts/calibration/calc_calib.R @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -10,121 +10,178 @@ # *** based on a pre run of magpie *** # ********************************************************************* -calibration_run<-function(putfolder,calib_magpie_name,logoption=3){ +calibration_run <- function(putfolder, calib_magpie_name, logoption = 3) { - require(lucode) + require(lucode2) # create putfolder for the calib run - unlink(putfolder,recursive=TRUE) + unlink(putfolder, recursive = TRUE) dir.create(putfolder) # create a modified magpie.gms for the calibration run - unlink(paste(calib_magpie_name,".gms",sep="")) + unlink(paste(calib_magpie_name, ".gms", sep = "")) unlink("fulldata.gdx") - if(!file.copy("main.gms",paste(calib_magpie_name,".gms",sep=""))){ - stop(paste("Unable to create",paste(calib_magpie_name,".gms",sep=""))) + if (!file.copy("main.gms", paste(calib_magpie_name, ".gms", sep = ""))) { + stop(paste("Unable to create", paste(calib_magpie_name, ".gms", sep = ""))) } - manipulateConfig(paste(calib_magpie_name,".gms",sep=""),c_timesteps=1) - manipulateConfig(paste(calib_magpie_name,".gms",sep=""),s_use_gdx=0) - file.copy(paste(calib_magpie_name,".gms",sep=""),putfolder) + lucode2::manipulateConfig(paste(calib_magpie_name, ".gms", sep = ""), c_timesteps = 1) + lucode2::manipulateConfig(paste(calib_magpie_name, ".gms", sep = ""), s_use_gdx = 0) + file.copy(paste(calib_magpie_name, ".gms", sep = ""), putfolder) # execute calibration run - system(paste("gams ",calib_magpie_name,".gms"," -errmsg=1 -PUTDIR ./",putfolder," -LOGOPTION=",logoption,sep=""),wait=TRUE) - file.copy("fulldata.gdx",putfolder) + system(paste("gams ", calib_magpie_name, ".gms", " -errmsg=1 -PUTDIR ./", putfolder, " -LOGOPTION=", logoption, + sep = ""), wait = TRUE) + file.copy("fulldata.gdx", putfolder) } # get ratio between modelled area and reference area get_areacalib <- function(gdx_file) { require(magclass) require(magpie4) - require(gdx) - require(luscale) - data <- readGDX(gdx_file,"pm_land_start")[,,c("crop","past")] - data <- superAggregate(data,"sum",level="reg") - magpie <- land(gdx_file)[,,c("crop","past")] - if(nregions(magpie)!=nregions(data) | !all(getRegions(magpie) %in% getRegions(data))) { + require(gdx2) + data <- readGDX(gdx_file, "pm_land_start")[, , c("crop", "past")] + data <- dimSums(data, dim = 1.2) + magpie <- land(gdx_file)[, , c("crop", "past")] + if (nregions(magpie) != nregions(data) || !all(getCells(magpie) %in% getCells(data))) { stop("Regions in MAgPIE do not agree with regions in reference calibration area data set!") } - out <- magpie/data - out[out==0] <- 1 + out <- magpie / data + out[out == 0] <- 1 + out[is.na(out)] <- 1 return(magpiesort(out)) } get_yieldcalib <- function(gdx_file) { require(magclass) - require(gdx) + require(gdx2) require(luscale) prep <- function(x) { # use maiz as surrogate for all crops - elem <- c("maiz","pasture") - y <- collapseNames(x[,,"rainfed"][,,elem]) - getNames(y) <- c("crop","past") - return(superAggregate(y,level="reg",aggr_type="mean", na.rm=TRUE)) + elem <- c("maiz", "pasture") + y <- collapseNames(x[, , "rainfed"][, , elem]) + getNames(y) <- c("crop", "past") + return(superAggregate(y, level = "reg", aggr_type = "mean", na.rm = TRUE)) } - y_ini <- prep(readGDX(gdx_file,"i14_yields")) - y <- prep(readGDX(gdx_file,"vm_yld")[,,"l"]) + y_ini <- prep(readGDX(gdx_file, "i14_yields", "i14_yields_calib", + format = "first_found", react = "silent")) + y <- prep(readGDX(gdx_file, "vm_yld")[, , "level"]) - out <- y/y_ini - out[out==0] <- 1 + out <- y / y_ini + out[out == 0] <- 1 + out[is.na(out)] <- 1 return(magpiesort(out)) } # Calculate the correction factor and save it -update_calib<-function(gdx_file, calib_accuracy=0.1, calibrate_pasture=TRUE,calibrate_cropland=TRUE,damping_factor=0.8, calib_file, crop_max=1, calibration_step=""){ +update_calib <- function(gdx_file, calib_accuracy = 0.1, calibrate_pasture = TRUE, calibrate_cropland = TRUE, + damping_factor = 0.8, calib_file, crop_max = 2, calibration_step = "", + n_maxcalib = 20, best_calib = FALSE) { require(magclass) require(magpie4) - if(!(modelstat(gdx_file)[1,1,1]%in%c(1,2,7))) stop("Calibration run infeasible") + require(gdx2) + if (!(modelstat(gdx_file)[1, 1, 1] %in% c(1, 2, 7))) stop("Calibration run infeasible") area_factor <- get_areacalib(gdx_file) tc_factor <- get_yieldcalib(gdx_file) calib_correction <- area_factor * tc_factor - calib_divergence <- abs(calib_correction-1) + calib_divergence <- abs(calib_correction - 1) - old_calib <- magpiesort(read.magpie(calib_file)) - calib_factor <- old_calib * (damping_factor*(calib_correction-1) + 1) + calib_factor <- readGDX(gdx_file, "f14_yld_calib") + calib_factor_calc <- calib_factor * (damping_factor * (calib_correction - 1) + 1) - if(!is.null(crop_max)) { - above_limit <- (calib_factor[,,"crop"] > crop_max) - calib_factor[,,"crop"][above_limit] <- crop_max - calib_divergence[getRegions(calib_factor),,"crop"][above_limit] <- 0 + if (!is.null(crop_max)) { + above_limit <- (calib_factor[, , "crop"] > crop_max) + calib_factor[, , "crop"][above_limit] <- crop_max + calib_divergence[getCells(calib_factor), , "crop"][above_limit] <- calib_accuracy } - if(!calibrate_pasture) { - calib_factor[,,"past"] <- 1 - calib_divergence[,,"past"] <- 0 + if (!calibrate_pasture) { + calib_factor[, , "past"] <- 1 + calib_divergence[, , "past"] <- 0 } - if(!calibrate_cropland) { - calib_factor[,,"crop"] <- 1 - calib_divergence[,,"crop"] <- 0 + if (!calibrate_cropland) { + calib_factor[, , "crop"] <- 1 + calib_divergence[, , "crop"] <- 0 } ### write down current calib factors (and area_factors) for tracking - write_log <- function(x,file,calibration_step) { - x <- add_dimension(x, dim=3.1, add="iteration", nm=calibration_step) - try(write.magpie(round(setYears(x,NULL),2), file, append = (calibration_step!=1))) + write_log <- function(x, file, calibration_step) { + x <- add_dimension(x, dim = 3.1, add = "iteration", nm = calibration_step) + try(write.magpie(round(setYears(x, NULL), 3), file, append = (calibration_step != 1))) } - write_log(calib_correction, "calib_correction.cs3" , calibration_step) - write_log(calib_divergence, "calib_divergence.cs3" , calibration_step) - write_log(area_factor, "calib_area_factor.cs3", calibration_step) - write_log(tc_factor, "calib_tc_factor.cs3" , calibration_step) + write_log(calib_correction, "calib_correction.cs3", calibration_step) + write_log(calib_divergence, "calib_divergence.cs3", calibration_step) + write_log(area_factor, "calib_area_factor.cs3", calibration_step) + write_log(tc_factor, "calib_tc_factor.cs3", calibration_step) + write_log(calib_factor, "calib_factor.cs3", calibration_step) # in case of sufficient convergence, stop here (no additional update of # calibration factors!) - if(all(calib_divergence < calib_accuracy)) return(TRUE) - - comment <- c(" description: Regional yield calibration file", - " unit: -", - paste0(" note: Calibration step ",calibration_step), - " origin: scripts/calibration/calc_calib.R (path relative to model main directory)", - paste0(" creation date: ",date())) - write.magpie(round(setYears(calib_factor,NULL),2), calib_file, comment = comment) + if (all(calib_divergence <= calib_accuracy) || calibration_step == n_maxcalib) { + ### Depending on the selected calibration selection type (best_calib FALSE or TRUE) + # the reported and used regional calibration factors can be either the ones of the last iteration, + # or the "best" based on the iteration value with the lowest divergence. + if (best_calib == TRUE) { + + calib_best <- new.magpie(cells_and_regions = getCells(calib_divergence), + years = getYears(calib_divergence), names = c("crop", "past")) + calib_best_div <- new.magpie(cells_and_regions = getCells(calib_divergence), + years = getYears(calib_divergence), names = c("crop", "past")) + divergence_data <- read.magpie("calib_divergence.cs3") + factors_data <- read.magpie("calib_factor.cs3") + + for (i in getCells(calib_best)) { + + factors_data_sub_crop <- as.data.frame(factors_data[i, , "crop"]) + n_iterations <- nrow(factors_data_sub_crop) + factors_data_sub_crop <- factors_data_sub_crop[2:n_iterations, ] + divergence_data_sub_crop <- as.data.frame(divergence_data[i, , "crop"])[2:n_iterations, ] + factors_data_sub_past <- as.data.frame(factors_data[i, , "past"])[2:n_iterations, ] + divergence_data_sub_past <- as.data.frame(divergence_data[i, , "past"])[2:n_iterations, ] + + + min_index_crop <- max(which(divergence_data_sub_crop$Value == min(divergence_data_sub_crop$Value, + na.rm = TRUE))) + min_index_past <- max(which(divergence_data_sub_past$Value == min(divergence_data_sub_past$Value, + na.rm = TRUE))) + + calib_best[i, NULL, "crop"] <- factors_data_sub_crop[min_index_crop, "Value"] + calib_best[i, NULL, "past"] <- factors_data_sub_past[min_index_past, "Value"] + calib_best_div[i, NULL, "crop"] <- divergence_data_sub_crop[min_index_crop, "Value"] + calib_best_div[i, NULL, "past"] <- divergence_data_sub_crop[min_index_past, "Value"] + } + comment <- c(" description: Regional yield calibration file", + " unit: -", + paste0(" note: Best calibration factor from the run"), + " origin: scripts/calibration/calc_calib.R (path relative to model main directory)", + paste0(" creation date: ", date())) + write.magpie(round(setYears(calib_best, NULL), 2), calib_file, comment = comment) + + write_log(calib_best, "calib_factor.cs3", "best") + write_log(calib_best_div, "calib_divergence.cs3", "best") + #### + if (any(calib_best) == crop_max) message("Note: A region or a few regions have a calibration factor equal to the maximum possible. + Check for possible reasons/inconsistencies.") + return(TRUE) + } else { + if (any(calib_factor) == crop_max) message("Note: A region or a few regions have a calibration factor equal to the maximum possible. + Check for possible reasons/inconsistencies.") + return(TRUE) + } + } else { + comment <- c(" description: Regional yield calibration file", + " unit: -", + paste0(" note: Calibration step ", calibration_step), + " origin: scripts/calibration/calc_calib.R (path relative to model main directory)", + paste0(" creation date: ", date())) + write.magpie(round(setYears(calib_factor_calc, NULL), 2), calib_file, comment = comment) + return(FALSE) + } - write_log(calib_factor, "calib_factor.cs3" , calibration_step) - return(FALSE) } @@ -132,29 +189,35 @@ calibrate_magpie <- function(n_maxcalib = 1, calib_accuracy = 0.1, calibrate_pasture = FALSE, calibrate_cropland = TRUE, + crop_max = 2, calib_magpie_name = "magpie_calib", damping_factor = 0.6, calib_file = "modules/14_yields/input/f14_yld_calib.csv", putfolder = "calib_run", data_workspace = NULL, logoption = 3, - debug = FALSE) { + debug = FALSE, + best_calib = FALSE) { require(magclass) - for(i in 1:n_maxcalib){ - cat(paste("\nStarting calibration iteration",i,"\n")) - calibration_run(putfolder=putfolder, calib_magpie_name=calib_magpie_name, logoption=logoption) - if(debug) file.copy(paste0(putfolder,"/fulldata.gdx"),paste0("fulldata_calib",i,".gdx")) - done <- update_calib(gdx_file=paste0(putfolder,"/fulldata.gdx"),calib_accuracy=calib_accuracy, calibrate_pasture=calibrate_pasture,calibrate_cropland=calibrate_cropland,damping_factor=damping_factor, calib_file=calib_file, calibration_step=i) - if(done){ + if (file.exists(calib_file)) file.remove(calib_file) + for (i in 1:n_maxcalib) { + cat(paste("\nStarting yield calibration iteration", i, "\n")) + calibration_run(putfolder = putfolder, calib_magpie_name = calib_magpie_name, logoption = logoption) + if (debug) file.copy(paste0(putfolder, "/fulldata.gdx"), paste0("fulldata_calib", i, ".gdx")) + done <- update_calib(gdx_file = paste0(putfolder, "/fulldata.gdx"), calib_accuracy = calib_accuracy, + calibrate_pasture = calibrate_pasture, calibrate_cropland = calibrate_cropland, + crop_max = crop_max, damping_factor = damping_factor, calib_file = calib_file, + calibration_step = i, n_maxcalib = n_maxcalib, best_calib = best_calib) + if (done) { break } } # delete calib_magpie_gms in the main folder - unlink(paste0(calib_magpie_name,".*")) + unlink(paste0(calib_magpie_name, ".*")) unlink("fulldata.gdx") - cat("\ncalibration finished\n") + cat("\nYield calibration finished\n") } diff --git a/scripts/calibration/landconversion_cost.R b/scripts/calibration/landconversion_cost.R new file mode 100644 index 0000000000..bf3356d864 --- /dev/null +++ b/scripts/calibration/landconversion_cost.R @@ -0,0 +1,305 @@ +# | (C) 2008-2025 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 script calculates a regional calibration factor *** +# *** based on a pre run of magpie *** +# ********************************************************************* + +calibration_run <- function(putfolder, calib_magpie_name, logoption = 3, s_use_gdx = 0) { + require(lucode2) + + # create putfolder for the calib run + unlink(putfolder, recursive = TRUE) + dir.create(putfolder) + + # create a modified magpie.gms for the calibration run + unlink(paste(calib_magpie_name, ".gms", sep = "")) + unlink("fulldata.gdx") + + if (!file.copy("main.gms", paste(calib_magpie_name, ".gms", sep = ""))) { + stop(paste("Unable to create", paste(calib_magpie_name, ".gms", sep = ""))) + } + lucode2::manipulateConfig(paste(calib_magpie_name, ".gms", sep = ""), c_timesteps = "calib") + lucode2::manipulateConfig(paste(calib_magpie_name, ".gms", sep = ""), s_use_gdx = s_use_gdx) + file.copy(paste(calib_magpie_name, ".gms", sep = ""), putfolder) + + # execute calibration run + system(paste("gams ", calib_magpie_name, ".gms", " -errmsg=1 -PUTDIR ./", putfolder, " -LOGOPTION=", logoption, sep = ""), wait = TRUE) + file.copy("fulldata.gdx", putfolder) +} + +# get ratio between modelled area and reference area + +getCalibFactor <- function(gdx_file, mode = "cost", calib_accuracy = 0.05, lowpass_filter = 1, histData = "FAO", cost_min = 0.2) { + require(magclass) + require(magpie4) + require(gdx2) + y <- readGDX(gdx_file,"t") + magpie <- land(gdx_file)[, y, "crop"] + if (histData == "MAgPIEown") { + hist <- dimSums(readGDX(gdx_file, "f10_land")[, , "crop"], dim = 1.2) + data <- hist[, y, "crop"] + } else if (histData == "FAO") { + if(file.exists("calib_data.rds")) { + val <- readRDS("calib_data.rds") + } else { + val <- read.report("input/validation.mif", as.list = FALSE) + val <- val[getRegions(magpie),getYears(magpie),"historical.FAO_crop_past.Resources|Land Cover|+|Cropland (million ha)"] + names(dimnames(val)) <- names(dimnames(magpie)) + getNames(val) <- "crop" + saveRDS(val, file = "calib_data.rds") + } + data <- val + } + if (nregions(magpie) != nregions(data) | !all(getRegions(magpie) %in% getRegions(data))) { + stop("Regions in MAgPIE do not agree with regions in reference calibration area data set!") + } + if (mode == "cost") { + out <- magpie / data + out[out == 0] <- 1 + out[is.na(out)] <- 1 + getNames(out) <- NULL + out[out < 0] <- 1 + out <- lowpass(out,i = lowpass_filter) + } else if (mode == "reward") { + shrLostHist <- new.magpie(getRegions(magpie), getYears(magpie), fill = 0) + for (i in 2:length(y)) { + shrLostHist[ , y[i], ] <- (setYears(data[, y[i], ], NULL) - setYears(data[, y[i-1], ], NULL)) / setYears(data[, y[i-1], ], NULL) + } + + out <- magpie / data - 1 + out[is.na(out)] <- 0 + out[is.infinite(out)] <- 0 + getNames(out) <- NULL + + # set reward to 0 if no cropland was lost in historic data set + out[shrLostHist < -calib_accuracy] <- 0 + out[out < 0] <- 0 + out <- lowpass(out,i = lowpass_filter) + out[,1,] <- 0 + } + return(magpiesort(out)) +} + +time_series_cost <- function(calib_factor) { + out2 <- new.magpie(getRegions(calib_factor), years = c(seq(1995, 2015, by = 5), seq(2050, 2150, by = 5)), fill = 1) + out2[, getYears(calib_factor), ] <- calib_factor + out2050 <- setYears(calib_factor[,2015,],NULL) + out2050[out2050 < 1] <- 1 + out2[, seq(2050, 2150, by = 5), ] <- out2050 + out2 <- time_interpolate(out2, seq(2020, 2050, by = 5), integrate_interpolated_years = T) + return(out2) +} + +time_series_reward <- function(calib_factor) { + out2 <- new.magpie(getRegions(calib_factor), years = c(seq(1995, 2015, by = 5), seq(2050, 2150, by = 5)), fill = 0) + out2[, getYears(calib_factor), ] <- calib_factor + out2 <- time_interpolate(out2, seq(2020, 2050, by = 5), integrate_interpolated_years = T) + return(out2) +} + +# Calculate the correction factor and save it +update_calib <- function(gdx_file, calib_accuracy = 0.01, lowpass_filter = 1, calib_file, cost_max = 2.5, cost_min = 0.2, calibration_step = "", n_maxcalib = 20, best_calib = FALSE, histData = "FAO") { + require(magclass) + require(magpie4) + require(gdx2) + if (!(modelstat(gdx_file)[1, 1, 1] %in% c(1, 2, 7))) stop("Calibration run infeasible") + + y <- readGDX(gdx_file,"t") + + calib_correction_cost <- getCalibFactor(gdx_file, mode = "cost", calib_accuracy = calib_accuracy, lowpass_filter = lowpass_filter) + calib_divergence_cost <- abs(calib_correction_cost - 1) + + calib_correction_reward <- getCalibFactor(gdx_file, mode = "reward", calib_accuracy = calib_accuracy, lowpass_filter = lowpass_filter) + calib_divergence_reward <- abs(calib_correction_reward) + calib_divergence_reward[calib_correction_reward == 0] <- 0 + + ### -> in case it is the first step, it forces the initial factors to be equal to 1 + if (file.exists(calib_file)) { + old_calib <- magpiesort(read.magpie(calib_file))[,y,] + start_flag <- FALSE + } else { + old_calib <- new.magpie(cells_and_regions = getCells(calib_divergence_cost), years = y, names = c("cost", "reward"), fill = 1) + old_calib[,,"reward"] <- 0 + start_flag <- TRUE + } + + calib_factor_cost <- setNames(old_calib[, , "cost"], NULL) * calib_correction_cost + calib_factor_reward <- setNames(old_calib[, , "reward"], NULL) + calib_correction_reward + calib_factor_reward[calib_factor_reward < 0] <- 0 + + if (!start_flag) { + # use calibration factors where accuracy was reached + # use stricter divergence threshold in first 5 calibration_step steps + cost_acc_reached <- calib_divergence_cost <= ifelse(calibration_step < 6, 0.01, calib_accuracy) + calib_factor_cost[cost_acc_reached] <- setNames(old_calib[, , "cost"], NULL)[cost_acc_reached] + calib_correction_cost[cost_acc_reached] <- 1 + + reward_acc_reached <- calib_divergence_reward <= ifelse(calibration_step < 6, 0.01, calib_accuracy) + calib_factor_reward[reward_acc_reached] <- setNames(old_calib[, , "reward"], NULL)[reward_acc_reached] + calib_correction_reward[reward_acc_reached] <- 0 + } + + if (!is.null(cost_max)) { + + # set value for India to cost_max for better convergence + if ("IND" %in% getRegions(calib_factor_cost)) { + calib_factor_cost["IND", -1 , ] <- cost_max + } + + # set value for CAZ to cost_max for better convergence; only needed for LUH2 due to mismatch between LUH2 and FAO historical data for cropland. + if (histData == "MAgPIEown") { + if ("CAZ" %in% getRegions(calib_factor_cost)) { + calib_factor_cost["CAZ", -1 , ] <- cost_max + } + } + + above_limit <- (calib_factor_cost >= cost_max) + calib_factor_cost[above_limit] <- cost_max + calib_divergence_cost[getRegions(calib_factor_cost), , ][above_limit] <- 0 + + } + + if (!is.null(cost_min)) { + below_limit <- (calib_factor_cost <= cost_min) + calib_factor_cost[below_limit] <- cost_min + calib_divergence_cost[getRegions(calib_factor_cost), , ][below_limit] <- 0 + } + + ### write down current calib factors (and area_factors) for tracking + write_log <- function(x, file, calibration_step) { + x <- add_dimension(x, dim = 3.1, add = "iteration", nm = paste0("iter", calibration_step)) + try(write.magpie(round(x, 3), file, append = (calibration_step != 1))) + } + + write_log(calib_correction_cost, "land_conversion_cost_calib_correction.cs3", calibration_step) + write_log(calib_divergence_cost, "land_conversion_cost_calib_divergence.cs3", calibration_step) + write_log(calib_factor_cost, "land_conversion_cost_calib_factor.cs3", calibration_step) + + write_log(calib_correction_reward, "land_conversion_reward_calib_correction.cs3", calibration_step) + write_log(calib_divergence_reward, "land_conversion_reward_calib_divergence.cs3", calibration_step) + write_log(calib_factor_reward, "land_conversion_reward_calib_factor.cs3", calibration_step) + + # in case of sufficient convergence, stop here (no additional update of + # calibration factors!) + + if (all(all(calib_divergence_cost <= calib_accuracy) & all(calib_divergence_reward <= calib_accuracy)) | calibration_step == n_maxcalib) { + + ### Depending on the selected calibration selection type (best_calib FALSE or TRUE) + # the reported and used regional calibration factors can be either the ones of the last iteration, + # or the "best" based on the iteration value with the lowest standard deviation of regional divergence. + if (best_calib == TRUE) { + divergence_data <- read.magpie("land_conversion_cost_calib_divergence.cs3") + factors_data <- read.magpie("land_conversion_cost_calib_factor.cs3") + calib_cost_best <- factors_data[, , which.min(apply(as.array(divergence_data), c(3), sd))] + getNames(calib_cost_best) <- NULL + calib_cost_best <- time_series_cost(calib_cost_best) + + divergence_data <- read.magpie("land_conversion_reward_calib_divergence.cs3") + factors_data <- read.magpie("land_conversion_reward_calib_factor.cs3") + calib_reward_best <- factors_data[, , which.min(apply(as.array(divergence_data), c(3), sd))] + getNames(calib_reward_best) <- NULL + calib_reward_best <- time_series_reward(calib_reward_best) + + calib_best_full <- mbind( + add_dimension(calib_cost_best, dim = 3.1, nm = "cost"), + add_dimension(calib_reward_best, dim = 3.1, nm = "reward") + ) + calib_best_full[is.na(calib_best_full)] <- 1 + + comment <- c( + " description: Regional land conversion cost calibration file", + " unit: -", + paste0(" note: Best calibration factor from the run"), + " origin: scripts/calibration/landconversion_cost.R (path relative to model main directory)", + paste(" Calibration settings:", "calib_accuracy=", calib_accuracy, "lowpass_filter=", lowpass_filter, "cost_max=", cost_max, "cost_min=", cost_min, "n_maxcalib=",n_maxcalib, "best_calib=",best_calib, "histData=",histData), + paste0(" creation date: ", date()) + ) + write.magpie(round(calib_best_full, 3), calib_file, comment = comment) + + write_log(calib_best_full[, , "cost"], "land_conversion_cost_calib_factor.cs3", "best") + write_log(calib_best_full[, , "reward"], "land_conversion_reward_calib_factor.cs3", "best") + #### + return(TRUE) + } else { + return(TRUE) + } + } else { + calib_factor_cost <- time_series_cost(calib_factor_cost) + calib_factor_reward <- time_series_reward(calib_factor_reward) + + calib_full <- mbind( + add_dimension(calib_factor_cost, dim = 3.1, nm = "cost"), + add_dimension(calib_factor_reward, dim = 3.1, nm = "reward") + ) + calib_full[is.na(calib_full)] <- 1 + + comment <- c( + " description: Regional land conversion cost calibration file", + " unit: -", + paste0(" note: Calibration step ", calibration_step), + " origin: scripts/calibration/landconversion_cost.R (path relative to model main directory)", + paste(" Calibration settings:", "calib_accuracy=", calib_accuracy, "lowpass_filter=", lowpass_filter, "cost_max=", cost_max, "cost_min=", cost_min, "n_maxcalib=",n_maxcalib, "best_calib=",best_calib, "histData=",histData), + paste0(" creation date: ", date()) + ) + + write.magpie(round(calib_full, 3), calib_file, comment = comment) + return(FALSE) + } +} + + + + +calibrate_magpie <- function(n_maxcalib = 20, + restart = FALSE, + calib_accuracy = 0.01, + cost_max = 2.5, + cost_min = 0.2, + calib_magpie_name = "magpie_calib", + lowpass_filter = 1, + calib_file = "modules/39_landconversion/input/f39_calib.csv", + putfolder = "land_conversion_cost_calib_run", + data_workspace = NULL, + logoption = 3, + debug = FALSE, + best_calib = FALSE, + histData = "FAO") { + require(magclass) + + if (!restart) { + cat(paste0("\nStarting land conversion cost calibration from default values\n")) + if (file.exists(calib_file)) file.remove(calib_file) + } else { + if (file.exists(calib_file)) cat(paste0("\nStarting land conversion cost calibration from existing values\n")) else cat(paste0("\nStarting land conversion cost calibration from default values\n")) + } + + for (i in 1:n_maxcalib) { + if (i == 1) s_use_gdx <- 0 + cat(paste("\nStarting land conversion cost calibration iteration", i, "with s_use_gdx =", s_use_gdx, "\n")) + calibration_run(putfolder = putfolder, calib_magpie_name = calib_magpie_name, logoption = logoption, s_use_gdx = s_use_gdx) + if (debug) file.copy(paste0(putfolder, "/fulldata.gdx"), paste0("fulldata_calib", i, ".gdx")) + done <- update_calib(gdx_file = paste0(putfolder, "/fulldata.gdx"), calib_accuracy = calib_accuracy, cost_max = cost_max, cost_min = cost_min, lowpass_filter = lowpass_filter, calib_file = calib_file, calibration_step = i, n_maxcalib = n_maxcalib, best_calib = best_calib) + if (done & s_use_gdx == 2) { + s_use_gdx <- 0 + next + } else if (done & s_use_gdx == 0) { + break + } else { + s_use_gdx <- 2 + } + } + + + # delete calib_magpie_gms in the main folder + unlink(paste0(calib_magpie_name, ".*")) + unlink("fulldata.gdx") + unlink("calib_data.rds") + + cat("\nLand conversion cost calibration finished\n") +} diff --git a/scripts/downloader/inputdelete.cfg b/scripts/downloader/inputdelete.cfg index e0eb563209..176abe74a9 100644 --- a/scripts/downloader/inputdelete.cfg +++ b/scripts/downloader/inputdelete.cfg @@ -1,11 +1,11 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 file;destination -*-to-*_*.spam;input +clustermap_rev*.rds;input avl_land_*.mz;input diagnostics.log;input diagnostics.csv;input @@ -13,9 +13,9 @@ diagnostics_full.log;input file2destination.csv;input info.txt;input ready.rdy;input -spamplot.pdf;input spatial_header.rda;input validation.mif;input rr_layer_*.mz;input luh2_side_layers_*.mz;input *_mapping.rds;input +spamplot_rev*.pdf;input diff --git a/scripts/helper.R b/scripts/helper.R new file mode 100644 index 0000000000..82c086f2c3 --- /dev/null +++ b/scripts/helper.R @@ -0,0 +1,27 @@ +# Collection of helper functions + +chooseSubmit <- function(title, slurmModes) { + modes <- c("Direct execution", + "Background execution", + "Debug mode") + + #Is SLURM available? + slurm <- lucode2::SystemCommandAvailable("srun") + if(slurm) { + slurmModes <- yaml::read_yaml(slurmModes)$slurmjobs + modes <- c(modes, names(slurmModes)) + if(lucode2::SystemCommandAvailable("sclass")) { + cat("\nCurrent cluster utilization:\n") + system("sclass") + cat("\n") + } + } + cat("\n",title,":\n", sep="") + cat(paste(seq_along(modes), modes, sep=": " ),sep="\n") + cat("Number: ") + identifier <- gms::getLine() + identifier <- as.integer(strsplit(identifier,",")[[1]]) + comp <- modes[identifier] + if(is.null(comp) || is.na(comp)) stop("This type is invalid. Please choose a valid type") + return(comp) +} diff --git a/scripts/insertheader/insertheader.R b/scripts/insertheader/insertheader.R index babe69434b..21b427c8b5 100644 --- a/scripts/insertheader/insertheader.R +++ b/scripts/insertheader/insertheader.R @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -6,20 +6,19 @@ # | Contact: magpie@pik-potsdam.de insertheader <- function(maindir=".", - header=c("(C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK)", + header=c("(C) 2008-2025 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"), donottouch=c("AUTHORS","README","LICENSE",".lhd",".mz",".rda",".opt", - ".spam",".xlsx",".sh","files",".md",".RData", ".jpg", + ".xlsx",".sh","files",".md",".RData", ".jpg", ".png",".cff", ".rds", ".aux", ".log", ".out", ".pdf", ".tex", ".htm", ".css", ".bib", ".ref", ".mif", ".gdx", - ".lst", ".git-id", ".csv", ".Rdata"), + ".lst", ".git-id", ".csv", ".Rdata", ".txt"), comments=c(".R"="#",".gms"="***",".cfg"="#",".csv"="*",".cs2"="*", ".cs3"="*",".cs4"="*",".sh"="#",".txt"="#"), - line_endings="notwin", key = "| ", oldkey = NULL, test_only=FALSE) { @@ -34,9 +33,7 @@ insertheader <- function(maindir=".", return(gsub(".*(\\..*)","\\1",basename(file))) } - cwd <- getwd() - on.exit(setwd(cwd)) - setwd(maindir) + withr::local_dir(maindir) if(is.null(oldkey)) oldkey <- key @@ -88,13 +85,7 @@ insertheader <- function(maindir=".", done <- c(done,file) # Write file only if it was modified - if (writefile & !test_only) { - if (line_endings == "win") { - lucode:::writeLinesDOS(f,file) - } else { - writeLines(f,file) - } - } + if (writefile & !test_only) writeLines(f,file) } cat("Files ommitted:\n") diff --git a/scripts/npi_ndc/start_npi_ndc.R b/scripts/npi_ndc/start_npi_ndc.R old mode 100755 new mode 100644 index fd6f07dace..0d932e40cb --- a/scripts/npi_ndc/start_npi_ndc.R +++ b/scripts/npi_ndc/start_npi_ndc.R @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -6,37 +6,57 @@ # | Contact: magpie@pik-potsdam.de ## Functions for the policy targets calculations -get_info <- function(file, grep_expression, sep, pattern="", replacement=""){ - if(!file.exists(file)) return("#MISSING#") - file <- readLines(file, warn=FALSE) - tmp <- grep(grep_expression, file, value=TRUE) - tmp <- strsplit(tmp, sep) - tmp <- sapply(tmp, "[[", 2) - tmp <- gsub(pattern, replacement ,tmp) - if(all(!is.na(as.logical(tmp)))) return(as.vector(sapply(tmp, as.logical))) - if (all(!(regexpr("[a-zA-Z]",tmp) > 0))){ - tmp <- as.numeric(tmp) - } - return(tmp) -} - ## calculates policy for protecting different land pools from land use change -calc_NPI_NDC <- function(policyregions="iso"){ +calc_NPI_NDC <- function(policyregions = "iso", + pol_def_file = "policies/policy_definitions.csv", + cellmapping = "policies/country2cell.rds", + land_stock_file = "../../modules/10_land/input/avl_land_t_0.5.mz", + map_file = Sys.glob("../../input/clustermap_rev*.rds"), + outfolder_ad_aolc = c("policies/","../../modules/35_natveg/input/"), + outfolder_aff = c("policies/","../../modules/32_forestry/input/"), + out_ad_file = "npi_ndc_ad_aolc_pol.cs3", + out_aff_file = "npi_ndc_aff_pol.cs3"){ require(magclass) - require(luscale) - require(lucode) + require(madrat) # load the cell mapping policy - pol_mapping <- readRDS("policies/country2cell.rds")[,policyregions] + pol_mapping <- readRDS(cellmapping) + if(!(policyregions %in% names(pol_mapping))) stop("No cell mapping available for policyregions = ",policyregions) + pol_mapping$policyregions <- pol_mapping[[policyregions]] ############################################################################## ########## Information from the reference observed data ########### ############################################################################## #read in cellular land cover (stock) from landuse initialization - land_stock <- read.magpie("../../modules/10_land/input/avl_land_t_0.5.mz") - getRegions(land_stock) <- paste(pol_mapping,1:59199,sep=".") + land_stock <- read.magpie(land_stock_file) + + # use pol_mapping to update spatial mapping of cells to regions + # so that not only countries can be used for policies but also smaller + # units such as provinces + if(dim(land_stock)[1] == 59199) { # 59199 cells + if(dim(pol_mapping)[1] > 59199) { + pol_mapping <- pol_mapping[order(pol_mapping$cell),] + pol_mapping <- pol_mapping[!is.na(pol_mapping$cell),] + } + getItems(land_stock, dim = 1, raw = TRUE) <- paste(pol_mapping$policyregions,1:59199,sep=".") + } else { + coords <- getCoords(land_stock) + names(coords) <- c("lon","lat") + m <- merge(coords, pol_mapping, sort =FALSE) + getItems(land_stock, dim = "iso") <- m$policyregions + } + + # select map_file if more than one has been found + if(length(map_file) > 1) { + if(dim(land_stock)[1] == 67420) { + map_file <- grep("67420", map_file, value = TRUE) + } else { + map_file <- grep("67420", map_file, value = TRUE, invert = TRUE) + } + } + stopifnot(length(map_file) == 1) forest_stock <- dimSums(land_stock[,,c("primforest","secdforest","forestry")], dim=3) getNames(forest_stock) <- "forest" @@ -65,7 +85,7 @@ calc_NPI_NDC <- function(policyregions="iso"){ capture.output(print(x, print.gap=3, row.names=FALSE), file=fname, append=TRUE) } - pol_def <- read.csv("policies/policy_definitions.csv") + pol_def <- read.csv(pol_def_file) addline("NPI/NDC policies") addline("MAgPIE") @@ -77,28 +97,33 @@ calc_NPI_NDC <- function(policyregions="iso"){ addline("## percentage protection: 0 = no protection, 1 = full protection") addline("## Ref: BaseYear (1), Baseline (2)") - cat("NPI AD policy\n") + ptm <- proc.time()["elapsed"] + cat("Compute NPI AD policy") addline("") addline("##############") addline("### NPI AD ###") addline("##############") npi_ad <- droplevels(subset(pol_def, policy=="npi" & landpool=="forest")) addtable(npi_ad[,c(-2,-3)]) - npi_ad <- calc_policy(npi_ad,forest_stock,pol_type="ad",pol_mapping=pol_mapping) + npi_ad <- calc_policy(npi_ad, forest_stock, pol_type="ad", pol_mapping=pol_mapping, + map_file=map_file) getNames(npi_ad) <- "npi.forest" + cat(paste0(" (time elapsed: ",format(proc.time()["elapsed"]-ptm,width=6,nsmall=2,digits=2),"s)\n")) - cat("NDC AD policy\n") + cat("Compute NDC AD policy") addline("") addline("##############") addline("### NDC AD ###") addline("##############") ndc_ad <- droplevels(subset(pol_def, policy=="ndc" & landpool=="forest")) addtable(ndc_ad[,c(-2,-3)]) - ndc_ad <- calc_policy(ndc_ad,forest_stock,pol_type="ad",pol_mapping=pol_mapping) + ndc_ad <- calc_policy(ndc_ad, forest_stock, pol_type="ad", pol_mapping=pol_mapping, + map_file=map_file) getNames(ndc_ad) <- "ndc.forest" #Set all values before 2015 to NPI values; copy the values til 2010 from the NPI data - ndc_ad[,which(getYears(ndc_ad,as.integer=TRUE)<=2020),] <- - npi_ad[,which(getYears(npi_ad,as.integer=TRUE)<=2020),] + ndc_ad[,which(getYears(ndc_ad,as.integer=TRUE)<=2025),] <- + npi_ad[,which(getYears(npi_ad,as.integer=TRUE)<=2025),] + cat(paste0(" (time elapsed: ",format(proc.time()["elapsed"]-ptm,width=6,nsmall=2,digits=2),"s)\n")) addline("") @@ -107,171 +132,203 @@ calc_NPI_NDC <- function(policyregions="iso"){ addline("## percentage protection: 0 = no protection, 1 = full protection") addline("## Ref: BaseYear (1), Baseline (2)") - cat("NPI AOLC policy\n") + cat("Compute NPI AOLC policy") addline("") addline("################") addline("### NPI AOLC ###") addline("################") npi_aolc <- droplevels(subset(pol_def, policy=="npi" & landpool=="other")) addtable(npi_aolc[,c(-2,-3)]) - npi_aolc <- calc_policy(npi_aolc,land_stock[,,"other"],pol_type="ad",pol_mapping=pol_mapping) + npi_aolc <- calc_policy(npi_aolc, land_stock[,,"other"], pol_type="ad", + pol_mapping=pol_mapping, map_file=map_file) getNames(npi_aolc) <- "npi.other" + cat(paste0(" (time elapsed: ",format(proc.time()["elapsed"]-ptm,width=6,nsmall=2,digits=2),"s)\n")) - cat("NDC AOLC policy\n") + cat("Compute NDC AOLC policy") addline("") addline("################") addline("### NDC AOLC ###") addline("################") ndc_aolc <- droplevels(subset(pol_def, policy=="ndc" & landpool=="other")) addtable(ndc_aolc[,c(-2,-3)]) - ndc_aolc <- calc_policy(ndc_aolc,land_stock[,,"other"],pol_type="ad",pol_mapping=pol_mapping) + ndc_aolc <- calc_policy(ndc_aolc, land_stock[,,"other"], pol_type="ad", + pol_mapping=pol_mapping, map_file=map_file) getNames(ndc_aolc) <- "ndc.other" #Set all values before 2015 to NPI values; copy the values til 2010 from the NPI data - ndc_aolc[,which(getYears(ndc_aolc,as.integer=TRUE)<=2020),] <- - npi_aolc[,which(getYears(npi_aolc,as.integer=TRUE)<=2020),] + ndc_aolc[,which(getYears(ndc_aolc,as.integer=TRUE)<=2025),] <- + npi_aolc[,which(getYears(npi_aolc,as.integer=TRUE)<=2025),] #write AD and AOLC policies together none_ad_aolc_pol <- mbind(npi_ad,npi_aolc) none_ad_aolc_pol[] <- 0 getNames(none_ad_aolc_pol) <- c("none.forest","none.other") ad_aolc_pol <- mbind(none_ad_aolc_pol,npi_ad,npi_aolc,ndc_ad,ndc_aolc) - write.magpie(ad_aolc_pol, "policies/npi_ndc_ad_aolc_pol.cs3") + + adfiles <- paste0(outfolder_ad_aolc, out_ad_file) + write.magpie(floor(ad_aolc_pol*1e6)/1e6, adfiles[1]) + if(length(adfiles >1)) for(i in 2:length(adfiles)) file.copy(adfiles[1],adfiles[i], overwrite=TRUE) + cat(paste0(" (time elapsed: ",format(proc.time()["elapsed"]-ptm,width=6,nsmall=2,digits=2),"s)\n")) addline("") addline("##----------------------------------------------------------------------------") addline("## Afforestation - AFF (Mha)") addline("## Ref: BaseYear (1), Baseline (2)") - cat("NPI AFF policy\n") + cat("Compute NPI AFF policy") addline("") addline("###############") addline("### NPI AFF ###") addline("###############") npi_aff <- droplevels(subset(pol_def, policy=="npi" & landpool=="affore")) addtable(npi_aff[,c(-2,-3)]) - npi_aff <- calc_policy(npi_aff,land_stock,pol_type="aff",pol_mapping=pol_mapping, - weight=dimSums(land_stock[,2005,c("crop","past")])) + npi_aff <- calc_policy(npi_aff, land_stock, pol_type="aff", pol_mapping=pol_mapping, + weight=dimSums(land_stock[,2005,c("crop","past")]) + 10^-10, + map_file=map_file) getNames(npi_aff) <- "npi" + cat(paste0(" (time elapsed: ",format(proc.time()["elapsed"]-ptm,width=6,nsmall=2,digits=2),"s)\n")) - cat("NDC AFF policy\n") + cat("Compute NDC AFF policy") addline("") addline("###############") addline("### NDC AFF ###") addline("###############") ndc_aff <- droplevels(subset(pol_def, policy=="ndc" & landpool=="affore")) addtable(ndc_aff[,c(-2,-3)]) - ndc_aff <- calc_policy(ndc_aff,land_stock,pol_type="aff",pol_mapping=pol_mapping, - weight=dimSums(land_stock[,2005,c("crop","past")])) + ndc_aff <- calc_policy(ndc_aff, land_stock, pol_type="aff", pol_mapping=pol_mapping, + weight=dimSums(land_stock[,2005,c("crop","past")]) + 10^-10, + map_file=map_file) getNames(ndc_aff) <- "ndc" #set all values before 2015 to NPI values; copy the values til 2010 from the NPI data - ndc_aff[,which(getYears(ndc_aff,as.integer=TRUE)<=2020),] <- - npi_aff[,which(getYears(npi_aff,as.integer=TRUE)<=2020),] + ndc_aff[,which(getYears(ndc_aff,as.integer=TRUE)<=2025),] <- + npi_aff[,which(getYears(npi_aff,as.integer=TRUE)<=2025),] #write AFF policies none_aff_pol <- npi_aff none_aff_pol[] <- 0 getNames(none_aff_pol) <- "none" aff_pol <- mbind(none_aff_pol,npi_aff,ndc_aff) - write.magpie(aff_pol, "policies/npi_ndc_aff_pol.cs3") + afffiles <- paste0(outfolder_aff, out_aff_file) + write.magpie(floor(aff_pol*1e6)/1e6, afffiles[1]) + if(length(afffiles >1)) for(i in 2:length(afffiles)) file.copy(afffiles[1],afffiles[i], overwrite=TRUE) - #copy files - file.copy("policies/npi_ndc_ad_aolc_pol.cs3", - "../../modules/35_natveg/input/npi_ndc_ad_aolc_pol.cs3",overwrite = TRUE) - file.copy("policies/npi_ndc_aff_pol.cs3", - "../../modules/32_forestry/input/npi_ndc_aff_pol.cs3",overwrite = TRUE) + cat(paste0(" (time elapsed: ",format(proc.time()["elapsed"]-ptm,width=6,nsmall=2,digits=2),"s)\n")) } -### calc flow function -calc_flows <- function(stock,t_periods) { - flow <- stock - flow[,,] <- 0 - for (y in 2:nyears(stock)) { - flow[,y,] <- (setYears(stock[,y-1,],NULL) - stock[,y,])/t_periods[y] - } - return(flow) +calc_tperiods <- function(y) { + t_periods <- c(1,y[3:length(y)]-y[2:(length(y)-1)]) + names(t_periods) <- paste0("y",y[2:length(y)]) + return(as.magpie(t_periods)) +} + +### calc annual flow function +calc_flows <- function(stock) { + stock <- stock[,c(1,1:nyears(stock)),] + y <- getYears(stock,as.integer = TRUE) + t_periods <- calc_tperiods(y) + out <- (setYears(stock[,1:(nyears(stock)-1),],getYears(stock)[2:nyears(stock)]) + - stock[,2:nyears(stock),])/t_periods + return(out) } ### calc npi & ndc policy -calc_policy <- function(policy,stock,pol_type="aff",pol_mapping, weight=NULL) { +calc_policy <- function(policy, stock, pol_type="aff", pol_mapping=pol_mapping, + weight=NULL, map_file = Sys.glob("../../input/clustermap_rev*.rds")) { ## pol_type = {"aff","ad"} + require(madrat) + #extent stock beyond last observed value with constant values from the last year ly <- tail(getYears(stock,as.integer=TRUE),1) ly <- ly - ly%%5 - stock <- stock[,seq(1995,ly,5),] - stock_extent <- new.magpie(getCells(stock), seq(ly+5,2150,5), - getNames(stock), stock[,ly,]) - stock <- mbind(stock, stock_extent) - rm(stock_extent) + year_extension <- seq(ly+5,2150,5) + stock <- stock[,c(seq(1995,ly,5),rep(ly,length(year_extension))),] + getYears(stock) <- c(seq(1995,ly,5), year_extension) - #the the years and periods + #full years tp <- getYears(stock, as.integer=TRUE) - t_periods <- c(1, sapply(seq_along(tp[-1]), function(i) tp[i+1] - tp[i])) #select and filter countries that exist in the chosen policy mapping - policy_countries <- intersect(policy$dummy,unique(pol_mapping)) + policy_countries <- intersect(policy$dummy,unique(pol_mapping$policyregions)) + policy <- policy[policy$dummy %in% policy_countries,] + + #create key to distinguish different cases of baseyear, targetyear combinations + policy$key <- paste(policy$baseyear,policy$targetyear) + #set stock to zero or Inf for countries without policies # (representing no constraint for min and max constraints) if(pol_type=="ad"){ - stock[setdiff(getRegions(stock),policy_countries),,] <- 0 + if(dim(stock)[1] == 59199) { + stock[!(sub("\\..*$","",getCells(stock)) %in% policy_countries),,] <- 0 + } else { + stock[!(getItems(stock, "iso", full = TRUE) %in% policy_countries),,] <- 0 + } #calculate flows - flow <- calc_flows(stock,t_periods) - #account only for positive flows + flow <- calc_flows(stock) + #account only for positive flows, i.e. deforestation flow[flow < 0] <- 0 } #Initialize magpie_policy with 0 (country level) #This is a return object of this function and contains policy targets at #cluster level - magpie_policy <- new.magpie(unique(pol_mapping),tp,NULL,0) - for (i in policy_countries) { - cat(i,round(which(policy_countries==i)/length(policy_countries)*100),"%\n") + magpie_policy <- new.magpie(unique(pol_mapping$policyregions),tp,NULL,0) + keys <- unique(policy$key) + for (i in keys) { #get baseyear and targetyear - baseyear <- policy[which(policy$dummy==i),"baseyear"] - targetyear <- policy[which(policy$dummy==i),"targetyear"] - y_pol <- tp[tp>= baseyear & tp<=targetyear] - y_pol_forever <- tp[tp>= targetyear] + tmp <- as.integer(strsplit(i," ")[[1]]) + baseyear <- tmp[1] + targetyear <- tmp[2] + countries <- policy$dummy[policy$key==i] + y_full <- tp[tp >= baseyear] #set target in targetyear #percentage: 0 = no reduction, 1 = full reduction of deforestation #Mha if pol_type=="aff" - magpie_policy[i,targetyear,] <- policy[which(policy$dummy==i),"target"] + magpie_policy[countries,targetyear,] <- policy[policy$key==i,"target"] #interpolate between baseyear and targetyear - magpie_policy[i,y_pol,] <- time_interpolate(magpie_policy[i,c(baseyear,targetyear),],y_pol) #set same target for all years after targetyear - magpie_policy[i,y_pol_forever,] <- setYears(magpie_policy[i,targetyear,],NULL) - #get target type - targettype <- policy[which(policy$dummy==i),"targettype"] #1 baseyear target #2 baseline target - + if(targetyear==baseyear) { + magpie_policy[countries,y_full,] <- setYears(magpie_policy[countries,baseyear,],NULL) + } else { + magpie_policy[countries,y_full,] <- time_interpolate(magpie_policy[countries,c(baseyear,targetyear),],y_full, + extrapolation_type = "constant") + } #set reference flow based on target type if(pol_type=="ad") { - stock[i,tp>targetyear,] <- setYears(stock[i,targetyear,],NULL) - ref_flow <- new.magpie(getCells(stock),getYears(stock),NULL,0) - if (targettype == 1) { - ref_flow[i,,] <- setYears(flow[i,baseyear,],NULL) - } else if (targettype == 2) { - ref_flow[i,,] <- flow[i,,] - } else stop("unknow targettype; needs to be 1 or 2") + c_index <- (sub("\\..*$","",getCells(stock)) %in% countries) + stock[c_index,tp>targetyear,] <- setYears(stock[c_index,targetyear,],NULL) + targettypes <- unique(policy[policy$key==i,"targettype"]) + if(!all(targettypes %in% 1:2)) stop("unknow targettype; needs to be 1 or 2") + if (any(targettypes == 1)) { + t1countries <- policy$dummy[policy$key==i & policy$targettype==1] + t1c_index <- (sub("\\..*$","",getCells(flow)) %in% t1countries) + flow[t1c_index,,] <- setYears(flow[t1c_index,baseyear,],NULL) + } } } #calculate the reduction target in absolute numbers - rel <- data.frame(from=pol_mapping,to=paste(pol_mapping,1:length(pol_mapping),sep=".")) + if(dim(pol_mapping)[1] == 59199) { + rel <- data.frame(from=pol_mapping$policyregions,to=paste(pol_mapping$policyregions,1:59199,sep="."), stringsAsFactors = FALSE) + countryCell <- paste(pol_mapping$iso,1:59199,sep=".") + } else { + lon <- sub(".", "p", pol_mapping$lon, fixed = TRUE) + lat <- sub(".", "p", pol_mapping$lat, fixed = TRUE) + rel <- data.frame(from=pol_mapping$policyregions,to=paste(lon, lat, pol_mapping$policyregions,sep="."), stringsAsFactors = FALSE) + countryCell <- paste(lon, lat, pol_mapping$iso,sep=".") + } if(pol_type=="aff") { - magpie_policy <- speed_aggregate(x=magpie_policy, rel=rel, weight=weight) + magpie_policy <- madrat::toolAggregate(x=magpie_policy, rel=rel, weight=weight) } else if(pol_type=="ad") { - magpie_policy <- speed_aggregate(x=magpie_policy, rel=rel) - magpie_policy <- magpie_policy * ref_flow * t_periods + stock + magpie_policy <- madrat::toolAggregate(x=magpie_policy, rel=rel) + t_periods <- calc_tperiods(c(tp[1],tp)) + magpie_policy <- magpie_policy * flow * t_periods + stock } - load("../../input/spatial_header.rda") - getCells(magpie_policy) <- spatial_header - - res_out <- get_info("../../input/info.txt","^\\* Output ?resolution:",": ") - res_high <- get_info("../../input/info.txt","^\\* Input ?resolution:",": ") - spam_file <- path("../../input",paste0(res_high,"-to-",res_out,"_sum.spam")) - magpie_policy <- speed_aggregate(magpie_policy,spam_file) + map <- readRDS(map_file) + getItems(magpie_policy, dim = 1, raw = TRUE) <- map$cell + magpie_policy <- madrat::toolAggregate(magpie_policy,map) return(magpie_policy) } diff --git a/scripts/output/INFO.yml b/scripts/output/INFO.yml new file mode 100644 index 0000000000..38cf82e019 --- /dev/null +++ b/scripts/output/INFO.yml @@ -0,0 +1,4 @@ +type: output script +description: Main selection of MAgPIE output scripts +note: Scripts in this selection are actively managed and work out of the box. Please provide a yml header to your script specifying "description" and "comparison script", otherwise it may not be processed correctly. +position: 1.0 diff --git a/scripts/output/comparison/forestmaps.R b/scripts/output/comparison/forestmaps.R deleted file mode 100644 index 86c9eb71be..0000000000 --- a/scripts/output/comparison/forestmaps.R +++ /dev/null @@ -1,55 +0,0 @@ -# | (C) 2008-2019 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 - -######################### -#### check modelstat #### -######################### -# Version 1.0, Florian Humpenoeder -# -library(lucode) -library(magclass) -library(luplot) -library(quitte) - -options(error=function()traceback(2)) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdirs <- path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) - #Define arguments that can be read from command line - readArgs("outputdirs") -} -############################################################################### -cat("\nStarting output generation\n") - -defor <- NULL -missing <- NULL - -for (i in 1:length(outputdirs)) { - print(paste("Processing",outputdirs[i])) - #gdx file - rep<-path(outputdirs[i],"cell.land_0.5.mz") - if(file.exists(rep)) { - #get scenario name - load(path(outputdirs[i],"config.Rdata")) - scen <- cfg$title - #read-in reporting file - land_hr <- read.magpie(rep) - land_hr <- dimSums(land_hr[,c(2020,2050,2100),c("primforest","secdforest")],dim=3) - dimSums(setYears(land_hr[,1995,c("primforest","secdforest")],NULL),dim=3) - getCells(land_hr) <- paste("GLO",1:59199,sep=".") - getNames(land_hr) <- scen - defor <- mbind(defor,land_hr) - } else missing <- c(missing,outputdirs[i]) -} -if (!is.null(missing)) { - cat("\nList of folders with missing report.mif\n") - print(missing) -} - -plotmap2(defor,"output/defor_area.pdf",legend_range = c(-0.1,0.1),title = "Diff forest area compared to 1995",legendname = "Mha",midpoint = 0,lowcol = "darkred",midcol = "grey95",highcol = "darkgreen",plot_height=10,plot_width=30,legend_height = NULL) -# plotmap2(defor[,2050,],"defor_2050_area.pdf",ncol=6,legend_range = c(-0.5,0.5),title = "Diff 2050",midpoint = 0,lowcol = "darkred",midcol = "grey95",highcol = "darkgreen",plot_height=10,plot_width=30,legend_height = NULL) -# plotmap2(defor[,2100,],"defor_2100_area.pdf",ncol=6,legend_range = c(-0.5,0.5),title = "Diff 2100",midpoint = 0,lowcol = "darkred",midcol = "grey95",highcol = "darkgreen",plot_height=10,plot_width=30,legend_height = NULL) diff --git a/scripts/output/comparison/merge_report.R b/scripts/output/comparison/merge_report.R deleted file mode 100644 index 9b1c7baa1e..0000000000 --- a/scripts/output/comparison/merge_report.R +++ /dev/null @@ -1,53 +0,0 @@ -# | (C) 2008-2019 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 - - -######################### -#### check modelstat #### -######################### -# Version 1.0, Florian Humpenoeder -# -library(lucode) -library(magclass) -library(quitte) - -options(error=function()traceback(2)) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdirs <- path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) - #Define arguments that can be read from command line - readArgs("outputdirs") -} -############################################################################### -cat("\nStarting output generation\n") - -missing <- NULL - -if(file.exists("output/report_comp.csv")) file.rename("output/report_comp.csv","output/report_comp.bak") - -for (i in 1:length(outputdirs)) { - print(paste("Processing",outputdirs[i])) - #gdx file - rep<-path(outputdirs[i],"report.mif") - if(file.exists(rep)) { - #get scenario name - load(path(outputdirs[i],"config.Rdata")) - scen <- cfg$title - #read-in reporting file - a <- read.report(rep,as.list = FALSE) - getNames(a,dim=1) <- scen - #add to reporting csv file - write.report2(a,file="output/report_comp.csv",append=TRUE,ndigit = 4,skipempty = FALSE) - } else missing <- c(missing,outputdirs[i]) -} -if (!is.null(missing)) { - cat("\nList of folders with missing report.mif\n") - print(missing) -} - -if(file.exists("output/report_comp.csv")) saveRDS(read.quitte("output/report_comp.csv"),file = "output/report_comp.rds") diff --git a/scripts/output/comparison/modelstat.R b/scripts/output/comparison/modelstat.R deleted file mode 100644 index ae07775ede..0000000000 --- a/scripts/output/comparison/modelstat.R +++ /dev/null @@ -1,52 +0,0 @@ -# | (C) 2008-2019 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 - -######################### -#### check modelstat #### -######################### -# Version 1.0, Florian Humpenoeder -# -library(lucode) -library(magpie4) - -options(error=function()traceback(2)) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdirs <- path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) - #Define arguments that can be read from command line - readArgs("outputdirs") -} -############################################################################### -cat("\nStarting output generation\n") - -out <- NULL -missing <- NULL - -for (i in 1:length(outputdirs)) { - print(paste("Processing",outputdirs[i])) - #gdx file - gdx<-path(outputdirs[i],"fulldata.gdx") - if(file.exists(gdx)) { - tmp <- modelstat(gdx) - dimnames(tmp)[[3]] <- paste(outputdirs[i],dimnames(tmp)[[3]],sep=".") - out <- mbind(out,tmp) - } else missing <- c(missing,outputdirs[i]) -} -write.magpie(out,paste("./output/modelstat_",basename(getwd()),".csv",sep="")) -if (!is.null(missing)) { - cat("\nList of folders with missing fulldata.gdx\n") - print(missing) -} -if (all(out==2)) { - cat("\nGood news! No time steps with modelstat different from 2 found!\n") -} else { - cat("\nTime steps with modelstat different from 2 found!\n") - for (i in c(1,3:19)) { - if (any(out==i)) warning("Time steps with modelstat ",i," found!") - } -} diff --git a/scripts/output/comparison/resubmit.R b/scripts/output/comparison/resubmit.R deleted file mode 100644 index e168cff8fb..0000000000 --- a/scripts/output/comparison/resubmit.R +++ /dev/null @@ -1,42 +0,0 @@ -# | (C) 2008-2019 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 - -###################### -#### resubmit run #### -###################### -# Version 1.0, Florian Humpenoeder -# -library(lucode) -library(magpie4) - -options(error=function()traceback(2)) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdirs <- path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) - #Define arguments that can be read from command line - readArgs("outputdirs") -} -############################################################################### -cat("\nStarting output generation\n") - -out <- NULL -missing <- NULL - -for (i in 1:length(outputdirs)) { - print(paste("Checking",outputdirs[i])) - #gdx file - gdx<-path(outputdirs[i],"fulldata.gdx") - if(file.exists(gdx)) tmp <- modelstat(gdx) else tmp <- 0 - if (any(tmp!=2)) { - current <- getwd() - setwd(outputdirs[i]) - if (file.exists("magpie_y1995.gdx")) file.remove("magpie_y1995.gdx") - system("sbatch submit.sh") - setwd(current) - } -} diff --git a/scripts/output/comparison/runtime.R b/scripts/output/comparison/runtime.R deleted file mode 100644 index 9d7e231b5e..0000000000 --- a/scripts/output/comparison/runtime.R +++ /dev/null @@ -1,19 +0,0 @@ -# | (C) 2008-2019 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 - -############################# LOAD LIBRARIES ############################# -library(lucode, quietly = TRUE, warn.conflicts =FALSE) - -if(!exists("source_include")) { - outputdirs <- c("output/default_2015-01-14_11.41.17", - "output/default_2015-01-14_12.28.56", - "output/default_2015-01-14_15.00.13", - "output/default_2015-01-14_15.36.12"); - readArgs("outputdirs") -} - -print(readRuntime(outputdirs,plot=TRUE)) diff --git a/scripts/output/comparison/validation.R b/scripts/output/comparison/validation.R deleted file mode 100644 index dbb3f8b368..0000000000 --- a/scripts/output/comparison/validation.R +++ /dev/null @@ -1,40 +0,0 @@ -# | (C) 2008-2019 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 - -library(mip) -library(magpie4) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdirs <-"." -} -hist <- "input/validation.mif" -file <- paste0("comparison_validation_",format(Sys.time(), "%Y%H%M%S"),".pdf") -############################################################################### - -x <- NULL; i <- 1 -for(outputdir in outputdirs) { - config <- path(outputdir,"config.Rdata") - if(file.exists(config)) { - load(config) - title <- cfg$title - } else { - title <- paste0("run",i) - } - gdx <- paste0(outputdir, "/fulldata.gdx") - if(!is.null(x)) { - scenarios <- getNames(x,dim=2) - if(title %in% scenarios) { - title <- tail(make.unique(c(scenarios,title),sep=""),n=1) - } - } - tmp <- getReport(gdx, scenario=sub(".","_",title,fixed = TRUE)) - x <- mbind(x,tmp) - i <- i+1 -} - -validationpdf(x=x, hist=hist, file = file, style="comparison") diff --git a/scripts/output/comparison_validation.R b/scripts/output/comparison_validation.R new file mode 100644 index 0000000000..12b8d2e5b0 --- /dev/null +++ b/scripts/output/comparison_validation.R @@ -0,0 +1,46 @@ +# | (C) 2008-2025 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: Creates an validation pdf out of several runs +# comparison script: TRUE +# --------------------------------------------------------------- + +library(mip) +library(magpie4) +library(gms) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <-"." +} +hist <- "input/validation.mif" +file <- paste0("comparison_validation_",format(Sys.time(), "%Y%H%M%S"),".pdf") +############################################################################### + +x <- NULL; i <- 1 +for(outputdir in outputdirs) { + config <- file.path(outputdir,"config.yml") + if(file.exists(config)) { + cfg <- gms::loadConfig(config) + title <- cfg$title + } else { + title <- paste0("run",i) + } + gdx <- paste0(outputdir_x, "/fulldata.gdx") + if(!is.null(x)) { + scenarios <- getNames(x,dim=2) + if(title %in% scenarios) { + title <- tail(make.unique(c(scenarios,title),sep=""),n=1) + } + } + tmp <- getReport(gdx, scenario=sub(".","_",title,fixed = TRUE)) + x <- mbind(x,tmp) + i <- i+1 +} + +validationpdf(x=x, hist=hist, file = file, style="comparison") diff --git a/scripts/output/deprecated/INFO.yml b/scripts/output/deprecated/INFO.yml new file mode 100644 index 0000000000..f711492864 --- /dev/null +++ b/scripts/output/deprecated/INFO.yml @@ -0,0 +1,4 @@ +type: output script +description: Deprecated scripts +note: Scripts in this selection are deprecated and will soon be removed. +position: 10.0 diff --git a/scripts/output/extra/ForestChangeCluster.R b/scripts/output/extra/ForestChangeCluster.R new file mode 100644 index 0000000000..cf061eb920 --- /dev/null +++ b/scripts/output/extra/ForestChangeCluster.R @@ -0,0 +1,64 @@ +# | (C) 2008-2025 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: Compares Forest Area Change at Cluster Level +# comparison script: TRUE +# --------------------------------------------------------------- + +# Version 1.0, Florian Humpenoeder +# +library(lucode2) +library(magclass) +library(luplot) +library(magpie4) +library(ggplot2) +library(gms) +library(dplyr) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + +forest <- NULL +missing <- NULL + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + #gdx file + gdx<-file.path(outputdir[i],"fulldata.gdx") + if(file.exists(gdx)) { + #get scenario name + cfg <- gms::loadConfig(file.path(outputdir[i], "config.yml")) + scen <- cfg$title + #read-in reporting file + x <- dimSums(land(gdx,level="cell")[,,c("forestry","primforest","secdforest")],dim=3) + x <- x-setYears(x[,2020,],NULL) + x <- x[,getYears(x,as.integer = T)>=2020 & getYears(x,as.integer = T)<=2100,] + getNames(x) <- scen + forest <- mbind(forest,x) + } else missing <- c(missing,outputdir[i]) +} +if (!is.null(missing)) { + cat("\nList of folders with missing fulldata.gdx\n") + print(missing) +} + +forest <- as.data.frame(forest) +saveRDS(forest,"output/ForestChangeCluster.rds") +write.csv(forest, "output/ForestChangeCluster.csv",quote=F, row.names=F) + +p <- ggplot(forest,aes(x=Year,y=Value)) + geom_line(aes(color=Cell,group=Cell)) + facet_wrap(vars(Data1),ncol = 4) + scale_color_viridis_c() + ggtitle("Forest Cover Change") + ylab("Mha compared to 2020") + theme_bw() + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) +ggsave("output/ForestChangeCluster.pdf",p,bg = "white",width = 12,height = 5) +ggsave("output/ForestChangeCluster.png",p,bg = "white",width = 12,height = 5) diff --git a/scripts/output/extra/INFO.yml b/scripts/output/extra/INFO.yml new file mode 100644 index 0000000000..be526f50a4 --- /dev/null +++ b/scripts/output/extra/INFO.yml @@ -0,0 +1,3 @@ +description: Additional MAgPIE output scripts +note: Scripts in this selection might require some manual adjustments before they work with the given MAgPIE version as they are not necessarily updated along with changes in the model code. Please provide a yml header to your script specifying "description" and "comparison script", otherwise it may not be processed correctly. +position: 2.0 diff --git a/scripts/output/extra/aff_area.R b/scripts/output/extra/aff_area.R new file mode 100644 index 0000000000..01cca7250b --- /dev/null +++ b/scripts/output/extra/aff_area.R @@ -0,0 +1,57 @@ +# | (C) 2008-2025 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: extracts afforstation area from multiple runs and creates a PDF (useful template for other variables) +# comparison script: TRUE +# --------------------------------------------------------------- + +# Version 1.0, Florian Humpenoeder +# +library(lucode2) +library(magclass) +library(luplot) +library(magpie4) +library(ggplot2) +library(gms) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdirs <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdirs") +} +############################################################################### +cat("\nStarting output generation\n") + +forestry <- NULL +missing <- NULL + +for (i in 1:length(outputdirs)) { + print(paste("Processing",outputdirs[i])) + #gdx file + gdx<-file.path(outputdirs[i],"fulldata.gdx") + if(file.exists(gdx)) { + #get scenario name + cfg <- gms::loadConfig(file.path(outputdirs[i], "config.yml")) + scen <- cfg$title + #read-in reporting file + x <- collapseNames(land(gdx,level="glo")[,,"forestry"]) + x <- x-setYears(x[,1,],NULL) + getNames(x) <- scen + forestry <- mbind(forestry,x) + } else missing <- c(missing,outputdirs[i]) +} +if (!is.null(missing)) { + cat("\nList of folders with missing fulldata.gdx\n") + print(missing) +} + +p <- magpie2ggplot2(forestry,scenario = 1,ylab = "Mha",title = "Afforestation",legend_position = "bottom",group = NULL,legend_ncol = 1) +ggsave(plot = p,filename = "output/aff_area.pdf",width = 8,height = 7) diff --git a/scripts/output/extra/checkSummation.R b/scripts/output/extra/checkSummation.R new file mode 100644 index 0000000000..ad51a86423 --- /dev/null +++ b/scripts/output/extra/checkSummation.R @@ -0,0 +1,31 @@ +# | (C) 2008-2025 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: check that summations add up in report.mif file +# comparison script: FALSE +# --------------------------------------------------------------- + +## Load necessary libraries +library(quitte) +library(piamInterfaces) +options(width = 180) + +## Check outputdir +if (!exists("source_include")) { + outputdir <- "." +} + +f <- file.path(outputdir, "report.mif") + +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")) +} diff --git a/scripts/output/extra/convertToNetCDF.R b/scripts/output/extra/convertToNetCDF.R new file mode 100644 index 0000000000..872022d186 --- /dev/null +++ b/scripts/output/extra/convertToNetCDF.R @@ -0,0 +1,43 @@ +# | (C) 2008-2025 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: Convert all .mz files to NetCDF (.nc) for a magpie directory +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(magclass) + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Converting all .mz outputs to .nc for output directory: ", outputdir) + +mzFiles <- list.files(path = outputdir, pattern = "0\\.5(_share)?\\.mz$", full.names = TRUE) + +lapply(X = mzFiles, FUN = function(x) { + tryCatch({ + magObj <- magclass::read.magpie(x) + newName <- sub("\\.[^.]+$", "", x) + write.magpie(x = magObj, file_name = paste0(newName, ".nc"), file_folder = outputdir, append = FALSE) + }, error = function(e) { + message("Error processing file: ", x, " - ", e$message) + }) +}) diff --git a/scripts/output/extra/convertValidation.R b/scripts/output/extra/convertValidation.R new file mode 100644 index 0000000000..c6513e53c8 --- /dev/null +++ b/scripts/output/extra/convertValidation.R @@ -0,0 +1,44 @@ +# | (C) 2008-2025 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: converts validation.mif file into validation.rds for use in shinyresults +# comparison script: FALSE +# --------------------------------------------------------------- + +######################### +#### convert validation.mif #### +######################### +# Version 1.0, Florian Humpenoeder +# +library(quitte) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + val<-file.path(outputdir[i],"validation.mif") + rds <- file.path(outputdir[i],"validation.rds") + if(file.exists(val)) { + q <- read.quitte(val) + # as.quitte converts "World" into "GLO". But we want to keep "World" and therefore undo these changes + q <- droplevels(q) + levels(q$region)[levels(q$region) == "GLO"] <- "World" + q$region <- factor(q$region,levels = sort(levels(q$region))) + saveRDS(q, file = rds, version = 2) + } +} diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R new file mode 100644 index 0000000000..6580d7b508 --- /dev/null +++ b/scripts/output/extra/disaggregation.R @@ -0,0 +1,521 @@ +# | (C) 2008-2025 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: Interpolates land pools to 0.5 degree resolution +# comparison script: FALSE +# --------------------------------------------------------------- + +library(lucode2) +library(magpie4) +library(luscale) +library(madrat) +library(dplyr) +library(gms) +library(gdx2) +library(mstools) + +# ============================================= +# Basic configuration +# ============================================= +if (!exists("source_include")) { + outputdir <- "output/default_2024-06-01_15.40.24/" + readArgs("outputdir") +} +map_file <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) +gdx <- file.path(outputdir, "fulldata.gdx") +land_hr_file <- file.path(outputdir, "avl_land_full_t_0.5.mz") +urban_land_hr_file <- file.path(outputdir, "f34_urbanland_0.5.mz") +wdpa_hr_file <- file.path(outputdir, "wdpa_baseline_0.5.mz") +consv_prio_hr_file <- file.path(outputdir, "consv_prio_areas_0.5.mz") +land_consv_hr_out_file <- file.path(outputdir, "cell.conservation_land_0.5.mz") +land_hr_out_file <- file.path(outputdir, "cell.land_0.5.mz") +land_hr_share_out_file <- file.path(outputdir, "cell.land_0.5_share.mz") +croparea_hr_share_out_file <- file.path(outputdir, "cell.croparea_0.5_share.mz") +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") + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) + +withr::local_options(list(magclass_sizeLimit = 1e+12)) + +if (length(map_file) == 0) stop("Could not find map file!") +if (length(map_file) > 1) { + warning("More than one map file found. First occurrence will be used!") + map_file <- map_file[1] +} + +# ----------------------------------------- +# Output functions +# ----------------------------------------- + +.fixCoords <- function(x) { + getSets(x, fulldim = FALSE)[1] <- "x.y.iso" + return(x) +} + +.writeDisagg <- function(x, file, comment, message) { + base::message(message) + x <- .fixCoords(x) + write.magpie(x, file, comment = comment) +} + +.dissagcrop <- function(gdx, land_hr, map_file) { + area <- croparea(gdx, + level = "cell", products = "kcr", + product_aggr = FALSE, water_aggr = FALSE + ) + area_shr <- area / (dimSums(area, dim = 3) + 10^-10) + + # calculate share of crop land on total cell area + crop_shr <- land_hr / dimSums(land_hr, dim = 3) + crop_shr <- setNames(crop_shr[, getYears(area_shr), "crop_area"], NULL) + + # calculate crop area as share of total cell area + area_shr_hr <- madrat::toolAggregate(area_shr, map_file, to = "cell") * crop_shr + return(area_shr_hr) +} + +.dissagBII <- function(gdx, map_file) { + # Biodiversity intactness indicator (BII) at cluster level + bii_lr <- BII(gdx, + file = NULL, level = "cell", mode = "auto", landClass = "all", + bii_coeff = NULL, side_layers = NULL + ) + + # add BII values for primary other land (BII = 1) + bii_lr <- mbind( + bii_lr[, , "other", invert = TRUE], + setNames(bii_lr[, , "other"], c("primother.forested", "primother.nonforested")), + setNames(bii_lr[, , "other"], c("secdother.forested", "secdother.nonforested")) + ) + bii_lr[, , c("primother.forested", "primother.nonforested")] <- 1 + + # Disaggregate BII coefficients to grid cell level + bii_hr <- toolAggregate(x = bii_lr, rel = map_file, from = "cluster", to = "cell") + return(bii_hr) +} + +.extend2luhv2 <- function(x, land = deparse(substitute(x))) { + if (land == "land_lr") { + grassland_areas <- readGDX(gdx, "ov31_grass_area")[, , "level"] + grassland_areas <- collapseNames(grassland_areas) + land_lr <- mbind(x, grassland_areas) + drop_past <- !grepl("past$", getNames(land_lr)) + land_lr <- land_lr[, , drop_past] + getNames(land_lr) <- gsub("pastr", "past", getNames(land_lr)) + return(land_lr) + } + + if (land == "land_ini_lr") { + grassland_areas <- readGDX(gdx, "ov31_grass_area")[, "y1995", "level"] + grassland_areas <- collapseNames(grassland_areas) + land_ini_lr <- mbind(x, grassland_areas) + drop_past <- !grepl("past$", getNames(land_ini_lr)) + land_ini_lr <- land_ini_lr[, , drop_past] + getNames(land_ini_lr) <- gsub("pastr", "past", getNames(land_ini_lr)) + return(land_ini_lr) + } +} + +# ======================================== +# Prepare data for disaggregation +# ======================================== + +# ---------------------- +# Load input data +# ---------------------- +land_ini_lr <- readGDX(gdx, "f10_land", "f_land", format = "first_found")[, "y1995", ] +land_lr <- land(gdx, sum = FALSE, level = "cell") +land_ini_hr <- read.magpie(land_hr_file)[, "y1995", ] + +### Make sure grassland types are consistent +magpie2luh2 <- data.frame(matrix(nrow = 4, ncol = 2)) +names(magpie2luh2) <- c("MAgPIE", "LUH2") +magpie2luh2[1, ] <- c("crop", "crop") +magpie2luh2[4, ] <- c("urban", "urban") +magpie2luh2[5, ] <- c("primforest", "primforest") +magpie2luh2[6, ] <- c("secdforest", "secdforest") +magpie2luh2[7, ] <- c("forestry", "forestry") +magpie2luh2[8, ] <- c("other", "primother") +magpie2luh2[9, ] <- c("other", "secdother") + +if (grepl("grass", cfg$gms$past)) { + land_lr <- .extend2luhv2(land_lr) + land_ini_lr <- .extend2luhv2(land_ini_lr) + magpie2luh2[3, ] <- c("range", "range") + magpie2luh2[2, ] <- c("past", "past") +} else { + magpie2luh2[3, ] <- c("past", "range") + magpie2luh2[2, ] <- c("past", "past") +} + +land_ini_hr <- madrat::toolAggregate(land_ini_hr, magpie2luh2, from = "LUH2", to = "MAgPIE", dim = 3.1) +land_ini_hr <- land_ini_hr[, , getNames(land_lr)] +if (any(land_ini_hr < 0)) { + warning(paste0("Negative values in inital high resolution dataset detected and set to 0. Check the file ", land_hr_file)) + land_ini_hr[which(land_ini_hr < 0, arr.ind = T)] <- 0 +} + +# ----------------------------- +# Read in hr urban land +# ----------------------------- +if (cfg$gms$urban == "exo_nov21") { + urban_land_hr <- read.magpie(urban_land_hr_file) + ssp <- cfg$gms$c34_urban_scenario + urban_land_hr <- urban_land_hr[, , ssp] + getNames(urban_land_hr) <- "urban" +} else if (cfg$gms$urban == "static") { + urban_land_hr <- "static" +} + +# ---------------------------------------- +# Prepare land conservation data +# ---------------------------------------- + +message("Disaggregating conservation land") + +land_consv_hr <- NULL +if (file.exists(wdpa_hr_file)) { + if (file.exists(consv_prio_hr_file)) { + conservationPrioHr <- read.magpie(consv_prio_hr_file) + } else { + warning("Future land conservation used in MAgPIE run but high resolution ", + "conservation priority data for disaggregation not found.") + conservationPrioHr <- NULL + } + land_consv_hr <- magpie4::disaggregateLandConservation(gdx, cfg, + mapping = readRDS(map_file), + wdpaHr = read.magpie(wdpa_hr_file), + conservationPrioHr = conservationPrioHr) + + # Write gridded conservation land + .writeDisagg(land_consv_hr, land_consv_hr_out_file, + comment = "unit: Mha per grid-cell", + message = "Write outputs cell.conservation_land" + ) +} + +# ------------------------------------------------------------- +# Account for country-specific SNV shares in post-processing +# ------------------------------------------------------------- +iso <- readGDX(gdx, "iso") +snv_pol_iso <- readGDX(gdx, "policy_countries29") +snv_pol_select <- readGDX(gdx, "s29_snv_shr") +snv_pol_noselect <- readGDX(gdx, "s29_snv_shr_noselect") +snv_pol_shr <- new.magpie(iso, fill = snv_pol_noselect) +snv_pol_shr[snv_pol_iso, , ] <- snv_pol_select + +avl_cropland_hr <- file.path(outputdir, "avl_cropland_0.5.mz") # available cropland (at high resolution) +marginal_land <- cfg$gms$c29_marginal_land # marginal land scenario +snv_pol_fader <- readGDX(gdx, "i29_snv_scenario_fader") + + +# -------------------------------- +# Disaggregate peatland +# -------------------------------- + +message("Disaggregating 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 <- 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, ] +} 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, ] +} +peat_hr <- .fixCoords(peat_hr) + +# ============================================ +# Start disaggregation +# ============================================ + +# --------------------------------- +# Disaggregate MAgPIE land pools +# --------------------------------- + +# Start interpolation (use interpolateAvlCroplandWeighted from luscale) +message("Disaggregating MAgPIE land pools") +land_hr <- interpolateAvlCroplandWeighted( + x = land_lr, + x_ini_lr = land_ini_lr, + x_ini_hr = land_ini_hr, + map = map_file, + avl_cropland_hr = avl_cropland_hr, + marginal_land = marginal_land, + urban_land_hr = urban_land_hr, + land_consv_hr = land_consv_hr, + peat_hr = peat_hr, + 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, + comment = "unit: Mha per grid-cell", + message = "Write outputs cell.land" +) +.writeDisagg(land_hr / dimSums(land_hr, dim = 3.1), land_hr_share_out_file, + comment = "unit: grid-cell land area fraction", + message = "Write outputs cell.land_share" +) +gc() + +# ----------------------------------- +# Write peatland outputs +# ----------------------------------- + +# Write output +.writeDisagg(peat_hr, peatland_hr_out_file, + comment = "unit: Mha per grid-cell", + message = "Write outputs peatland Mha" +) +gc() + +# grid cell area as magclass object +calArea <- function(ix,iy,res=0.5,mha=1) { # pixelarea in m2, mha as factor + mha*(111.263*1000*res)*(111.263*1000*res)*cos(iy*pi/180) +} +map <- toolGetMappingCoord2Country(pretty = TRUE) +grarea <- new.magpie(cells_and_regions = map$coords, + fill = calArea(map$lon, map$lat, mha = 10^-10)) + +out <- peat_hr / grarea +out[is.nan(out)] <- 0 +out[is.infinite(out)] <- 0 + +.writeDisagg(out, peatland_hr_share_out_file, + comment = "unit: grid-cell area fraction", + message = "Write outputs peatland share" +) +gc() + + +# --------------------------------- +# Split land pools +# --------------------------------- +t <- readGDX(gdx,"t") +land_split_hr <- land_hr[ ,t , ] + +# split "crop" into crop_area, crop_fallow and crop_treecover +message("Disaggregating cropland") +carea <- land(gdx, level = "cell", subcategories = c("crop"))[,,c("crop_area","crop_fallow","crop_treecover")] +carea_shr <- carea / (dimSums(carea, dim = 3) + 10^-10) +# calculate crop area as share of total cell area +carea_hr <- madrat::toolAggregate(carea_shr, map_file, to = "cell") * setNames(land_split_hr[, , "crop"], NULL) +# check +if (abs(sum(dimSums(carea_hr, dim = 3) - setNames(land_split_hr[, , "crop"], NULL), na.rm = T)) > 0.1) warning("large Difference in crop disaggregation detected!") + +# drop crop +land_split_hr <- land_split_hr[, , "crop", invert = TRUE] +# combine land_split_hr with carea_hr +land_split_hr <- mbind(carea_hr, land_split_hr) + +rm(carea, carea_shr, carea_hr) +gc() + +# --------------------------------- +# Disaggregate MAgPIE crop types +# --------------------------------- + +message("Disaggregating MAgPIE crop types") +area_shr_hr <- .dissagcrop(gdx, land_split_hr, map_file = map_file) + +# Write output +.writeDisagg(area_shr_hr, croparea_hr_share_out_file, + comment = "unit: croparea fractions of total grid-cell", + message = "Write outputs cell.croparea_share" +) +gc() + +area_hr <- area_shr_hr * dimSums(land_split_hr, dim = 3) + +rm(area_shr_hr) +gc() + +# replace crop_area in land_hr in with crop_kfo_rf, crop_kfo_ir, crop_kbe_rf +# and crop_kbe_ir +kbe <- c("betr", "begr") +kfo <- setdiff(getNames(area_hr, dim = 1), kbe) +crop_kfo_rf <- setNames( + dimSums(area_hr[, , kfo][, , "rainfed"], dim = 3), + "crop_kfo_rf" +) +crop_kfo_ir <- setNames( + dimSums(area_hr[, , kfo][, , "irrigated"], dim = 3), + "crop_kfo_ir" +) +crop_kbe_rf <- setNames( + dimSums(area_hr[, , kbe][, , "rainfed"], dim = 3), + "crop_kbe_rf" +) +crop_kbe_ir <- setNames( + dimSums(area_hr[, , kbe][, , "irrigated"], dim = 3), + "crop_kbe_ir" +) +crop_hr <- mbind(crop_kfo_rf, crop_kfo_ir, crop_kbe_rf, crop_kbe_ir) +# drop crop_area +land_split_hr <- land_split_hr[, , "crop_area", invert = TRUE] +# combine land_split_hr with crop_hr. +land_split_hr <- mbind(crop_hr, land_split_hr) + +rm(crop_kfo_rf, crop_kfo_ir, crop_kbe_rf, crop_kbe_ir, crop_hr, 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") +farea_shr <- farea / (dimSums(farea, dim = 3) + 10^-10) +# calculate forestry area as share of total cell area +farea_hr <- madrat::toolAggregate(farea_shr, map_file, to = "cell") * setNames(land_split_hr[, , "forestry"], NULL) +# check +if (abs(sum(dimSums(farea_hr, dim = 3) - setNames(land_split_hr[, , "forestry"], NULL), na.rm = T)) > 0.1) warning("large Difference in forestry disaggregation detected!") +# rename +df <- data.frame(matrix(nrow = 3, ncol = 2)) +names(df) <- c("internal", "output") +df[1, ] <- c("aff", "PlantedForest_Afforestation") +df[2, ] <- c("ndc", "PlantedForest_NPiNDC") +df[3, ] <- c("plant", "PlantedForest_Timber") +farea_hr <- madrat::toolAggregate(farea_hr, df, from = "internal", to = "output", dim = 3.1) + +# drop forestry +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", + message = "Write cropsplit land area" +) +.writeDisagg(land_split_hr / dimSums(land_split_hr, dim = 3), land_hr_shr_split_file, + comment = "unit: grid-cell land area fraction", + message = "Write cropsplit land area share" +) +rm(land_split_hr) +gc() + +# -------------------------------- +# Disaggregate BII +# -------------------------------- + +message("Disaggregating BII values") + +# Load input data for BII disaggregation +land_ini_hr <- read.magpie(land_hr_file)[, "y1995", ] +side_layers_hr <- read.magpie(luh_side_layers) +landArea <- dimSums(land_ini_hr, dim = 3) + 10^-10 +side_layers_lr <- toolAggregate(x = side_layers_hr, rel = map_file, weight = landArea, from = "cell", to = "cluster") + +# Convert land types for BII disaggregation +land_ini_hr <- mbind( + land_ini_hr[, , c("primother", "secdother"), invert = TRUE], + setNames(dimSums(land_ini_hr[, , c("primother", "secdother")], dim = 3), + nm = "other" + ) +) +getNames(land_ini_hr) <- gsub( + "past", "manpast", + gsub("range", "rangeland", getNames(land_ini_hr)) +) + +if (grepl("grass", cfg$gms$past)) { + getNames(land_ini_lr) <- gsub( + "past", "manpast", + gsub("range", "rangeland", getNames(land_ini_lr)) + ) + getNames(land_lr) <- gsub( + "past", "manpast", + gsub("range", "rangeland", getNames(land_lr)) + ) + getNames(land_consv_hr) <- gsub( + "past", "manpast", + gsub("range", "rangeland", getNames(land_consv_hr)) + ) +} else { + # Disaggregate pasture + land_ini_lr <- mbind( + land_ini_lr[, , c("past"), invert = TRUE], + collapseNames(land_ini_lr[, , "past"]) * side_layers_lr[, , c("manpast", "rangeland")] + ) + + land_lr <- mbind( + land_lr[, , c("past"), invert = TRUE], + collapseNames(land_lr[, , "past"]) * side_layers_lr[, , c("manpast", "rangeland")] + ) + + land_consv_hr <- mbind( + land_consv_hr[, , c("past"), invert = TRUE], + collapseNames(land_consv_hr[, , "past"]) * side_layers_hr[, , c("manpast", "rangeland")] + ) +} + +# Sort and rename +land_ini_hr <- land_ini_hr[, , getNames(land_ini_lr)] +getSets(land_ini_hr)["d3.1"] <- "land" + +# Disaggregate BII values to high resolution +bii_hr <- .dissagBII(gdx, map_file = map_file) + +# Disaggregate land pools for BII estimation +land_bii_hr <- interpolateAvlCroplandWeighted( + x = land_lr, + x_ini_lr = land_ini_lr, + x_ini_hr = land_ini_hr, + map = map_file, + avl_cropland_hr = avl_cropland_hr, + marginal_land = marginal_land, + urban_land_hr = urban_land_hr, + land_consv_hr = land_consv_hr, + peat_hr = peat_hr, + snv_pol_shr = snv_pol_shr, + 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 secondary other land +land_bii_hr <- PrimSecdOtherLand(land_bii_hr, land_hr_file) + +# specify potential natural vegetation +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() + + +message("Finished disaggregation") diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R new file mode 100644 index 0000000000..76a3c39470 --- /dev/null +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -0,0 +1,539 @@ +# | (C) 2008-2025 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: Downscale MAgPIE results to 0.25 degree resolution in LUH2 format for ISIMIP 3b +# comparison script: FALSE +# ------------------------------------------------------------------------------------------------ + +library(lucode2) +library(magpie4) +library(luscale) +library(madrat) +library(raster) +library(mrcommons) +library(mstools) + +############################# BASIC CONFIGURATION ############################## +if(!exists("source_include")) { + outputdir <- "output/weeklyTests_SSP2-Ref/" + + readArgs("outputdir") +} + +map_file <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) +gdx <- file.path(outputdir,"fulldata.gdx") +land_hr_file <- file.path(outputdir,"avl_land_full_t_0.5.mz") +urban_land_hr_file <- file.path(outputdir,"f34_urbanland_0.5.mz") +land_hr_out_file <- file.path(outputdir,"cell.land_0.5.mz") +croparea_hr_share_out_file <- file.path(outputdir,"cell.croparea_0.5_share.mz") + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +if (!file.exists(file.path(outputdir,"cell.land_0.5.mz"))) stop('No disaggrated land use patterns found. Run "disaggregation.R" first!') +################################################################################ + + +#### Folder for saving results +out_dir<-paste0(outputdir,"/disaggregation_LUH2") + if(!dir.exists(out_dir)) dir.create(out_dir) + + +#### Year interpolation and re-projection from 0.5 to 0.25 degree + +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(raster::projectRaster(x_aux,raster::raster(res=c(0.25,0.25)),method = "ngb")) + crs(x) <- "+proj=utm +zone=1 +datum=WGS84" + return(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, filePath, 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::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]) { + 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))) + } + } + ncdf4::nc_close(nc) +} + +withr::local_options(list(magclass_sizeLimit = 1e+12)) + + +#### Spatial mapping +if(length(map_file)==0) stop("Could not find map file!") +if(length(map_file)>1) { + warning("More than one map file found. First occurrence will be used!") + map_file <- map_file[1] +} + +#### Crops mapping and grid to cell mapping +mapping_spatial<-readRDS(map_file) +gdx<-paste0(outputdir,"/fulldata.gdx") +mapping<-calcOutput(type = "LUH2MAgPIE", aggregate = FALSE, share = "LUHofMAG", bioenergy = "fix", missing = "fill",rice="total")[,2010,] +if(!dir.exists(paste0(out_dir,"/mappingLUH2MAgPIE/"))) dir.create(paste0(out_dir,"/mappingLUH2MAgPIE")) +if(!file.exists(paste0(out_dir,"/mappingLUH2MAgPIE/LUH2MAgPIE.csv"))) write.csv(as.data.frame(mapping),file=paste0(out_dir,"/mappingLUH2MAgPIE/LUH2MAgPIE.csv")) +countries<-intersect(getCells(mapping),unique(mapping_spatial$country)) +mapping_spatial<-subset(mapping_spatial,country %in% countries) +map_LUHMAg_grid<-setYears(madrat::toolAggregate(mapping[countries,,],rel=mapping_spatial,weight=NULL,from="country",to="cell",dim=1),NULL) + +#### calculates grid cell area of the earths sphere +land_hr <- read.magpie(land_hr_out_file) +land_hr <- land_hr[,-1,] +calArea <- function(ix,iy,res=0.5,mha=1) { # pixelarea in m2, mha as factor + mha*(111.263*1000*res)*(111.263*1000*res)*cos(iy*pi/180) +} + +# grid cell area as magclass object +map <- toolGetMappingCoord2Country(pretty = TRUE) +grarea <- new.magpie(cells_and_regions = map$coords, + fill = calArea(map$lon, map$lat, mha = 10^-10)) + +# adjust total grid land area so that it is smaller than the gridcell area (some cells have a larger area actually; should be investigated) +frac <- grarea/dimSums(land_hr, dim=3) +frac[frac>1] <- 1 +land_hr <- land_hr*frac + +land_hr_shr <- land_hr/dimSums(land_hr, dim=3) +land_hr_shr[is.na(land_hr_shr)] <- 0 + +#### Crops including bioenergy crops +crop_hr_shr<- read.magpie(croparea_hr_share_out_file) +crop_hr_shr[!is.finite(crop_hr_shr)]<-0 +crop_hr<-crop_hr_shr*dimSums(land_hr,dim=3) +crop_hr[!is.finite(crop_hr)]<-0 +bioener<-c("begr","betr") +noBioener<-getNames(crop_hr,dim=1)[!(getNames(crop_hr,dim=1)%in%bioener)] +crop_hr_noBio<-crop_hr[,,noBioener]*map_LUHMAg_grid[,,noBioener] + +names<-unique(getNames(collapseNames(crop_hr_noBio[,,"tece"]))) +crop_hr_LUH<-new.magpie(cells_and_regions=getCells(crop_hr_noBio),years=getYears(crop_hr_noBio),names=names) + +for(n in names){ +crop_hr_LUH[,,n]<-dimSums(crop_hr_noBio[,,n],dim=3.1) +} + +crop_hr_Bio<-setNames(crop_hr[,,bioener],c("c4per.rainfed","c4per.irrigated","c3per.rainfed","c3per.irrigated")) +crop_hr_LUH<-dimOrder(crop_hr_LUH,perm=c(2,1),dim=3) + +for (n in getNames(crop_hr_Bio)){ + crop_hr_LUH[,,n]<- crop_hr_LUH[,,n]+crop_hr_Bio[,,n] +} + +crop_hr_shr_LUH2_FAO<-round(crop_hr_LUH/dimSums(land_hr,dim=3),3) +crop_hr_shr_LUH2_FAO[!is.finite(crop_hr_shr_LUH2_FAO)]<-0 + +rm(crop_hr_Bio,crop_hr_noBio) + +#### Disaggregation Forestry +forestry_hr_shr <- land_hr_shr[,,"forestry"] +.dissagForestry <- function(gdx, forestry_hr_shr, map) { + message("Disaggregation Forestry") + area <- dimSums(landForestry(gdx, level="cell"),dim="ac") + area_shr <- area/(dimSums(area,dim=3) + 10^-10) + + # calculate forestry area as share of total cell area + forestry_hr_shr <- forestry_hr_shr[,getYears(area_shr),] + area_shr_hr <- madrat::toolAggregate(area_shr, map, to="cell") * setNames(forestry_hr_shr,NULL) + + #check + if (abs(sum(dimSums(area_shr_hr,dim=3)-forestry_hr_shr,na.rm=T)) > 0.1) warning("large Difference in crop disaggregation detected!") + + return(area_shr_hr) +} +forestry_hr_shr <- .dissagForestry(gdx, forestry_hr_shr, map=map_file) + +#### Split pasture into pasture and rangeland +avl_land_full_his <- read.magpie(land_hr_file) +past_range <- c("past","range") +past_range_his_shr <- avl_land_full_his[,,past_range]/dimSums(avl_land_full_his[,,past_range],dim=3) +past_range_his_shr[!is.finite(past_range_his_shr)] <- 0.5 +past_range_hr_shr<- new.magpie(cells_and_regions=getCells(past_range_his_shr),years=getYears(land_hr), + names=past_range) +past_range_land<- new.magpie(cells_and_regions=getCells(past_range_his_shr),years=getYears(land_hr), + names=past_range) +past_range_land[,getYears(past_range_his_shr),]<-past_range_his_shr*land_hr[,getYears(past_range_his_shr),"past"] +range_land_2015<-setYears(past_range_land[,2015,"range"],NULL) + +yer<-getYears(past_range_land,as.integer=TRUE)[getYears(past_range_land,as.integer=TRUE)>2015] +past_range_land[,yer,"range"]<-range_land_2015[,,"range"] +past_range_land[,yer,"range"]<-magpply(X = mbind(past_range_land[,yer,"range"],land_hr[,yer,"past"]), FUN = min, DIM = 3) +past_range_land[,yer,"past"]<-land_hr[,yer,"past"]-past_range_land[,yer,"range"] +past_range_hr_shr<-round(past_range_land/dimSums(land_hr,dim=3),3) +past_range_hr_shr[!is.finite(past_range_hr_shr)]<-0 +rm(past_range_his_shr,past_range_land,range_land_2015) + +#### Split other land into primary and secondary other land +other <- c("primother","secdother") +avl_land_full <- setYears(avl_land_full_his[,1995,],NULL) +other_hr_shr <- avl_land_full[,,other]/dimSums(avl_land_full[,,other],dim=3) +other_hr_shr[is.na(other_hr_shr)] <- 0.5 +other_hr_shr <- other_hr_shr * setNames(land_hr_shr[,,"other"],NULL) + +if(!file.exists(paste0(out_dir,"/LUH2_states.nc"))){ +states <- mbind(dimSums(crop_hr_shr_LUH2_FAO,dim=3.2), + setNames(dimSums(crop_hr_shr_LUH2_FAO, dim = 3), "cropland"), + setNames(past_range_hr_shr[,,"past"],"pastr"), + setNames(past_range_hr_shr[,,"range"],"range"), + setNames(dimSums(past_range_hr_shr,dim=3),"grazing"), + setNames(land_hr_shr[,,"primforest"],"primf"), + setNames(forestry_hr_shr[,,"plant"],"timber"), + setNames(land_hr_shr[,,"secdforest"]+forestry_hr_shr[,,"ndc"]+forestry_hr_shr[,,"aff"],"secdf"), + setNames(other_hr_shr[,,"primother"],"primn"), + setNames(other_hr_shr[,,"secdother"],"secdn"), + setNames(land_hr_shr[,,"urban"],"urban") +) + +rm(avl_land_full,past_range_hr_shr,forestry_hr_shr,other_hr_shr) +gc() +saveRDS(states,paste0(outputdir,"/states.rds")) +gc() +states <- convertLUH2(states) +gc() +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() +} + +#### Protected areas + +b <- landConservation(gdx,level = "grid",dir=outputdir) / dimSums(land_hr, dim=3) +b[is.na(b)] <- 0 +luh2 <- data.frame(matrix(nrow=7,ncol=2)) +names(luh2) <- c("LUH2","MAgPIE") +luh2[1,] <- c("crop_prot","crop") +luh2[2,] <- c("past_prot","past") +luh2[3,] <- c("timber_prot","forestry") +luh2[4,] <- c("primf_prot","primforest") +luh2[5,] <- c("secdf_prot","secdforest") +luh2[6,] <- c("urban_prot","urban") +luh2[7,] <- c("primn_secdn_prot","other") +b <- madrat::toolAggregate(b, luh2, from="MAgPIE", to="LUH2",dim = 3) +gc() +if(!file.exists(paste0(out_dir,"/LUH2_protected_area.nc"))){ +b <- convertLUH2(b) +gc() +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() +} + +####### ONLY DYNAMIC FORESTRY ON############# +#check for dynamic forestry +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 + b <- madrat::toolAggregate(b, map_file, from = "cluster",to = "cell") + luh2 <- data.frame(matrix(nrow=4,ncol=2)) + names(luh2) <- c("LUH2","MAgPIE") + luh2[1,] <- c("timber_harv","Forestry") + luh2[2,] <- c("primf_harv","Primary forest") + luh2[3,] <- c("secdf_harv","Secondary forest") + luh2[4,] <- c("primn_secdn_harv","Other land") + b <- b[,,luh2[,2]] + b <- madrat::toolAggregate(b, luh2, from="MAgPIE", to="LUH2",dim = 3) + gc() + if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_area.nc"))){ + b <- convertLUH2(b) + gc() + 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() + } + + #### 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,])) + a[a>500]<-a_fix[a>500] + b <- madrat::toolAggregate(a, map_file, from = "cluster",to = "cell") + luh2 <- data.frame(matrix(nrow=4,ncol=2)) + names(luh2) <- c("LUH2","MAgPIE") + luh2[1,] <- c("timber_bioh","Forestry") + luh2[2,] <- c("primf_bioh","Primary forest") + luh2[3,] <- c("secdf_bioh","Secondary forest") + luh2[4,] <- c("primn_secdn_bioh","Other land") + b <- b[,,luh2[,2]] + b <- madrat::toolAggregate(b, luh2, from="MAgPIE", to="LUH2",dim = 3) + gc() + if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_yields.nc"))){ + b <- convertLUH2(b) + gc() + 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() + } + + #### Wood: Harvested Biomass Product Split + b <- TimberProductionVolumetric(gdx,level = "cell",sumSource = FALSE,sumProduct = FALSE) + b <- dimSums(b,dim=3.1) + b <- b/dimSums(b,dim=3) + getNames(b) <- c("rndwd","fulwd") + b <- madrat::toolAggregate(b, map_file, from = "cluster",to = "cell") + if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_biomass_split.nc"))){ + b <- convertLUH2(b) + gc() + 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() + } +} else warning("DYNAMIC FORESTRY was NOT active in this MAgPIE run. Therefore wood harvest variables cannot be report in LUH2 format.") + +####### ONLY DYNAMIC FORESTRY ON############# + +#### Irrigation +irrig_hr_shr <- collapseNames(crop_hr_shr_LUH2_FAO[,,"irrigated"],collapsedim = 3.2) +getNames(irrig_hr_shr) <- paste("irrig",getNames(irrig_hr_shr),sep="_") +irrig_hr_shr <- collapseNames(irrig_hr_shr/(round(setNames(land_hr_shr[,,"crop"],NULL),3))) +irrig_hr_shr[!is.finite(irrig_hr_shr)]<-0 +d <- dimSums(irrig_hr_shr*dimSums(land_hr[,,"crop"],dim=3),dim=c(1,3))-croparea(gdx,level="glo",product_aggr = T,water_aggr = FALSE)[,,"irrigated"] +if (any(abs(d) > 0.1 )) message(paste0("Difference between cluster and grid cell production > 0.1 detected!")) + +if(!file.exists(paste0(out_dir,"/LUH2_irrigation.nc"))){ +irrig_hr_shr <- convertLUH2(irrig_hr_shr) +gc() +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() +} + +#### Flood + +rice <- dimSums(crop_hr[, , "rice_pro"], dim = 3.2) +crop_hr_c3ann <- dimSums(crop_hr_LUH[, , "c3ann"], dim = 3.2) + +flooded <- rice / crop_hr_c3ann +flooded[!is.finite(flooded)] <- 0 + +d <- dimSums(flooded * dimSums(crop_hr_shr_LUH2_FAO[, , "c3ann"], dim = 3) * dimSums(land_hr, dim = 3), dim = c(1, 3)) - croparea(gdx, level = "glo", product_aggr = F, water_aggr = T)[, , "rice_pro"] +if (any(abs(d) > 0.1)) message(paste0("Difference between cluster and grid cell production > 0.1 detected!")) +if (!file.exists(paste0(out_dir, "/LUH2_flood.nc"))) { + flooded <- convertLUH2(flooded) + gc() + 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() +} + + +#### Bioenergy +bio_hr_shr <- dimSums(crop_hr_shr[,,c("begr","betr")],dim=3.2) +getNames(bio_hr_shr,dim=1) <- c("c4per","c3per") +bio_hr_shr[bio_hr_shr<0.01]<-0 +bio_hr_shr <- round(bio_hr_shr,3) / dimSums(crop_hr_shr_LUH2_FAO[,,c("c4per","c3per")],dim=3.2) +bio_hr_shr[!is.finite(bio_hr_shr)]<-0 +d<-dimSums((bio_hr_shr[,,c("c4per","c3per")])*dimSums(crop_hr_shr_LUH2_FAO[,,c("c4per","c3per")],dim=3.2)*dimSums(land_hr,dim=3),dim=c(1,3))-croparea(gdx,level="glo",products = c("begr","betr"),product_aggr = T) +if (any(abs(d) > 0.1 )) message(paste0("Difference between cluster and grid cell production > 0.1 detected!")) +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() +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() +} + +#Croparea from LUH to avoid re-mapping LUH and magpie +crop_threshold <- 0.0001 +crop<- crop_hr_LUH +crop_hr<-dimSums(crop,dim=3.2) +crop_hr_shr <- dimSums(crop_hr_shr_LUH2_FAO,dim=3.2) + +crop_hr_rf <- collapseNames(crop[,,"rainfed"],collapsedim = 3.2) +crop_hr_rf_shr <- collapseNames(crop_hr_shr_LUH2_FAO[,,"rainfed"]) + +crop_hr_ir <- collapseNames(crop[,,"irrigated"],collapsedim = 3.2) +crop_hr_ir_shr <- collapseNames(crop_hr_shr_LUH2_FAO[,,"irrigated"]) + +#### Nitrogen budget + +if(file.exists(paste0(outputdir,"/NitrogenBudget.rds")) & file.exists(paste0(outputdir,"/NitrogenBudgetWeight.rds"))) { + a <- readRDS(paste0(outputdir,"/NitrogenBudget.rds")) + weight_kr <- readRDS(paste0(outputdir,"/NitrogenBudgetWeight.rds")) +} else { + #read-in NR budget in mio t N + a <- NitrogenBudget(gdx,level="grid",dir = outputdir) + saveRDS(a,paste0(outputdir,"/NitrogenBudget.rds")) + #read-in crop specific weight + weight_kr <- NitrogenBudgetWithdrawals(gdx,kcr="kcr",level="grid",net=TRUE,dir=outputdir) + saveRDS(weight_kr,paste0(outputdir,"/NitrogenBudgetWeight.rds")) +} + +#Rename and aggregate crop types in weight from MAgPIE to LUH2 +weight_kr_luh<-weight_kr*map_LUHMAg_grid +rm(weight_kr) +names<-unique(getNames(dimSums(map_LUHMAg_grid,dim=3.2))) +weight<-new.magpie(cells_and_regions=getCells(weight_kr_luh),years=getYears(weight_kr_luh),names=names) + +for(n in names){ +weight[,,n]<-dimSums(weight_kr_luh[,,n],dim=3.1) +} + +#subset +a <- a[,,c("fertilizer","manure","surplus")] +a[a<0] <- 0 +#make it crop specific +a <- ((a * weight) / dimSums(weight,dim=3,na.rm = TRUE)) +#filter +a[crop_hr tN/ha; convert from tN/ha to kgN/ha: tN/ha*1000kg/t = 1000 kgN/ha + +a <- (a/crop_hr)*1000 +x <- NULL + +if(!file.exists(paste0(out_dir,"/LUH2_Nitrogen_fertilizer.nc"))){ +x <- convertLUH2(clean_magpie(collapseNames(a[,,"fertilizer"],collapsedim = 3.1))) +gc() +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() +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() +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) +gc() + +#### Yields DM +yield_kr <- collapseNames(yields(gdx,level="cell",products = "kcr",product_aggr = FALSE,water_aggr = TRUE,attributes = "dm")) +yield_kr <-gdxAggregate(gdx,yield_kr,weight=NULL, absolute=FALSE,to="grid",dir=outputdir) +yield_kr_su <- yield_kr*map_LUHMAg_grid + +a<-new.magpie(cells_and_regions=getCells(yield_kr_su),years=getYears(yield_kr_su), + names=unique(getNames(collapseNames(yield_kr_su[,,"tece"])))) +for(n in names){ +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() +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() +} + +#### Yields DM rainfed +#read-in production in mio tDM +yield_kr <- collapseNames(yields(gdx,level="cell",products = "kcr",product_aggr = FALSE,water_aggr = FALSE,attributes = "dm")[,,"rainfed"]) +yield_kr <-gdxAggregate(gdx,yield_kr,weight=NULL, absolute=FALSE,to="grid",dir=outputdir) +yield_kr_su <- yield_kr*map_LUHMAg_grid +a<-new.magpie(cells_and_regions=getCells(yield_kr_su),years=getYears(yield_kr_su), + names=unique(getNames(collapseNames(yield_kr_su[,,"tece"])))) +for(n in names){ +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() +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() +} + +#### Yields DM irrigated +#read-in production in mio tDM +yield_kr <- collapseNames(yields(gdx,level="cell",products = "kcr",product_aggr = FALSE,water_aggr = FALSE,attributes = "dm")[,,"irrigated"]) +yield_kr <-gdxAggregate(gdx,yield_kr,weight=NULL, absolute=FALSE,to="grid",dir=outputdir) +yield_kr_su <- yield_kr*map_LUHMAg_grid +a<-new.magpie(cells_and_regions=getCells(yield_kr_su),years=getYears(yield_kr_su), + names=unique(getNames(collapseNames(yield_kr_su[,,"tece"])))) +for(n in names){ +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() +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() +} + +#### Yields Nr +#read-in production in mio tN +yield_kr <- collapseNames(yields(gdx,level="cell",products = "kcr",product_aggr = FALSE,water_aggr = TRUE,attributes = "nr"))*1000 +yield_kr <-gdxAggregate(gdx,yield_kr,weight=NULL, absolute=FALSE,to="grid",dir=outputdir) +yield_kr_su <- yield_kr*map_LUHMAg_grid + +a<-new.magpie(cells_and_regions=getCells(yield_kr_su),years=getYears(yield_kr_su), + names=unique(getNames(collapseNames(yield_kr_su[,,"tece"])))) +for(n in names){ +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() +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() +} diff --git a/scripts/output/extra/emulator.R b/scripts/output/extra/emulator.R new file mode 100644 index 0000000000..3da663b96c --- /dev/null +++ b/scripts/output/extra/emulator.R @@ -0,0 +1,184 @@ +# | (C) 2008-2025 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: +# comparison script: FALSE +# --------------------------------------------------------------- + + +library(magclass) +library(lucode2) +library(lusweave) +library(magpie4) +library(luplot) +library(ggplot2) +library(remulator) +library(gms) + +######################################################################################################## +######################################## Define function ############################################### +######################################################################################################## + +collect_data_and_make_emulator <- function(outputdir,name_of_fit="linear") { + require(gms) + cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) + + #setwd("~/Documents/0_GIT/magpie") + #cfg<-list(title="SSP2-26-1") + + # lock the model (other emulaotr scripts have to wait until this one finished) + lock_id <- gms::model_lock(file=".lockemu") + withr::defer(gms::model_unlock(lock_id,file=".lockemu")) + + results_path <- "output" + + emu_path <- file.path(results_path,"emulator") + if(!dir.exists(emu_path)) dir.create(emu_path) + + ####################################################### + ############# C O L L E C T D A T A ################# + ####################################################### + + # extract scenario name by removing number at the end of run name: "CDL_base-base-9" -> "CDL_base-base" + scenarios <- gsub("(.*)-[0-9]{1,2}$","\\1",cfg$title) + # if user chose multiple runs from the same scenario remove duplicated scenarios + scenarios <- unique(scenarios) + + # create empty object that will take all results + x <- NULL + + # For all scenarios read data of all runs and compile into the single magpie object "x" + for (scen in scenarios) { + + if(!dir.exists(file.path(emu_path,scen))) dir.create(file.path(emu_path,scen)) + + outfile <- paste0(emu_path,"/",scen,"/data_raw_magpie_output_",scen,".Rdata") + + # If all 73 MAgPIE runs for this scenario are finished: + # Read MAgPIE reports and modelstat for all runs of the list of scenarios, + # combine into one object, and save to Rdata file + raw_data_available <- FALSE + + cat("Checking if results have already been compiled and saved to",outfile,"\n") + if(file.exists(outfile)) { + # if results have already been collected and saved for this scenario load them + cat("Results found. Loading them.\n") + load(outfile) # expecting mag_res as the only object in this file + raw_data_available <- TRUE + } else { + cat("No previously compiled results found.\nChecking if all runs for",scen,"have finished\n") + # otherwise check if all runs are finished and if yes collect the results and save them to a Rdata file + # list all subdirectories of results_path + #single_scenario_paths <- base::list.dirs(results_path,recursive=FALSE,full.names=TRUE) + + # Find paths to all finished runs for this scenario. Use existence of fulldata.gdx as indicator. + # Remove fulldata.gdx from paths + # Pick only those that are like scenario followed by one ore two digits, i.e. "scenario_name-xx", with xx = 1...73 + single_scenario_paths <- Sys.glob(paste0(results_path,"/",scen,"-*/report.mif")) + single_scenario_paths <- gsub("\\/report\\.mif","",single_scenario_paths) + needle <- paste0(scen,"-([0-9]{1,2}$)") + single_scenario_paths <- single_scenario_paths[grepl(needle,single_scenario_paths)] + print(single_scenario_paths) + if (emulator_runs_complete(single_scenario_paths,runnumbers = c(1:73))) { # c(6,7,59:60,64:73) + cat("All 73 runs for",scen,"have finished.\n") + mag_res <- read_and_combine(single_scenario_paths,outfile = outfile) + raw_data_available <- TRUE + } else { + cat("NOT all 73 runs for",scen,"have finished yet. Nothing will be done.") + } + } + + # check if emulator has already been generated for this scenario + fitted_data_available <- file.exists(paste0(emu_path,"/",scen,"/",name_of_fit,"/data_postfit_",scen,".Rdata")) + if (fitted_data_available) { + cat("Emulator has already been generated for",scen,"and will not be regenerated.\n") + } else if (raw_data_available) { + # compile data of mutiple scenarios in x + x <- mbind(x,mag_res) + } + } + + # If for one of the scenarios raw data was available but no fit x is not NULL anymore and contains the + # raw data of the missing scenario for which the fits will be generated below. + if (!is.null(x)) { + ################################################################ + ############# Prepare data for bioenergy emulator ############## + ################################################################ + + # Bring object to format that is required by emulator + # add sample dimension by replacing -63 with .63 + getNames(x,dim=1) <- gsub("-([0-9]{1,2}$)",".\\1",getNames(x,dim=1)) + getSets(x) <- c("region","year","scenario","sample","model","variable") + + x <- x[,"y1995",,invert=TRUE] + + # Demand|Bioenergy|++|2nd generation (EJ/yr) + # Prices|Bioenergy (US$05/GJ) + + # Clean data + "Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)" + "Prices|Bioenergy (US$05/GJ)" + # 1. Exclude points with zero production (there are cases where production is zero but there is a price) + x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"][x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"]==0] <- NA + x[,,"Prices|Bioenergy (US$05/GJ)"][is.na(x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"])] <- NA + + # 2. Normally, where production (x) is zero resulting prices (y) are NA -> set production to NA where prices are NA + x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"][is.na(x[,,"Prices|Bioenergy (US$05/GJ)"])] <- NA + + x[,,"Modelstatus (-)"] <- x["GLO",,"Modelstatus (-)"] + + # Convert units to REMIND units + TWa_2_EJ <- 365.25*24*3600/1E6 + tmp1 <- x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"] / TWa_2_EJ # EJ -> TWa + tmp2 <- x[,,"Prices|Bioenergy (US$05/GJ)"] * TWa_2_EJ/1000 # $/GJ -> T$/TWa + getNames(tmp1,dim=4) <- gsub("EJ/yr","TWa/yr", getNames(tmp1,dim=4),fixed=TRUE) + getNames(tmp2,dim=4) <- gsub("US$05/GJ","T$/TWa",getNames(tmp2,dim=4),fixed=TRUE) + x <- mbind(x,tmp1,tmp2) + + # transfer regionscode from mag_res to x since it was erased above everywhere where x was 'mbind'ed + regionscode <- attributes(mag_res)$regionscode + attributes(x)$regionscode <- regionscode + + ############################################################### + ############# C A L C U L A T E E M U L A T O R ############# + ############################################################### + + # Calculate emulator + fc <- emulator(data=x, + name_x="Demand|Bioenergy|2nd generation|++|Bioenergy crops (TWa/yr)", + name_y="Prices|Bioenergy (T$/TWa)", + name_modelstat="Modelstatus (-)", + userfun=function(param,x)return(param[[1]] + param[[2]] * x), + treat_as_feasible = c(2,7), + n_suff = 5, + fill = TRUE, + output_path = emu_path, + fitname = name_of_fit, + create_pdf=TRUE, + initial_values = c(0,0), + lower=c(0,0)) + print(fc) + print(attributes(fc)) + + # write fit coefficients to REMIND input file + for (scen in getNames(fc,dim="scenario")) { + write.magpie(fc,file_name = paste0("f30_bioen_price_",scen,"_",regionscode,".cs4r"), file_folder = file.path(emu_path,scen,name_of_fit)) + } + } +} + + +######################################################################################################## +######################################## Execute function ############################################## +######################################################################################################## + if(!exists("source_include")) { + outputdir <- NULL + lucode2::readArgs("outputdir") + } + +collect_data_and_make_emulator(outputdir,name_of_fit="linear") diff --git a/scripts/output/extra/force_runstatistics.R b/scripts/output/extra/force_runstatistics.R new file mode 100644 index 0000000000..6fc6f89673 --- /dev/null +++ b/scripts/output/extra/force_runstatistics.R @@ -0,0 +1,44 @@ +# | (C) 2008-2025 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: Forces runstatistics submission in central repo +# comparison script: FALSE +# --------------------------------------------------------------- + +### version.0.1: Abhi - Forces runstatistics submission in central repo + +## Load necessary libraries +library(lucode2) +library(magpie4) +library(gms) + +## Check outputdir +if(!exists("source_include")) { + outputdir <-"." +} + +## Create path to runstatistics +runstatistics <- paste0(outputdir,"/runstatistics.rda") +## Create path to fulldata gdx +gdx <- paste0(outputdir,"/fulldata.gdx") + +## Load run config +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) + +## Load runstatistics +load(runstatistics) + +## Check if runstatistics are null and force submission if yes. Print a message if no. +if(is.null(stats$id)){ +runstatistics(file= runstatistics, + modelstat = modelstat(gdx), + config = cfg, + runtime = 0, + setup_info = setup_info(), + submit = cfg$runstatistics) +} else {cat("\nRunstatistics is not NULL.\nThis result should already appear in appResults.")} diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R new file mode 100644 index 0000000000..cc66e3da8e --- /dev/null +++ b/scripts/output/extra/highres.R @@ -0,0 +1,197 @@ +# | (C) 2008-2025 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: starts a run with higher resolution in parallel mode (each region is solved individually) using trade patterns from an existing run +# comparison script: FALSE +# --------------------------------------------------------------- + +# Author: Florian Humpenoeder + +library(magclass) +library(gdx2) +library(magpie4) +library(lucode2) +library(gms) +library(madrat) +library(gms) +options("magclass.verbosity" = 1) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- "output/LAMA86_Sustainability" + readArgs("outputdir") +} + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +gdx <- file.path(outputdir,"fulldata.gdx") +rds <- paste0(outputdir, "/report.rds") +runstatistics <- paste0(outputdir,"/runstatistics.rda") +resultsarchive <- "/p/projects/rd3mod/models/results/magpie" +############################################################################### + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Plausible values for "res" (high resolution): "c1000" and "c2000" +# Options for "tc" (13_tc realization): NULL (no change), "exo" and "endo_jan22" + +highres <- function(cfg = cfg, res = "c1000", tc = NULL) { + #lock the model folder + 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") + + cfg$output <- cfg$output[cfg$output!="extra/highres"] + + # search for matching high resolution file in repositories + # pattern: "rev4.65_h12_*_cellularmagpie_c2000_MRI-ESM2-0-ssp370_lpjml-3eb70376.tgz" + x <- unlist(strsplit(cfg$input["cellular"],"_")) + x[3] <- "*" + x[5] <- res + file <- paste0(x,collapse = "_") + message(paste0("Searching for ",file," in repositories")) + repositories <- cfg$repositories + found <- NULL + debug <- FALSE + for (repo in names(repositories)) { + if (grepl("https://|http://", repo)) { + #read html index file and extract file names + h <- try(curl::new_handle(verbose = debug, .list = repositories[[repo]]), silent = !debug) + con <- curl::curl(paste0(repo,"/"), handle = h) + suppressSpecificWarnings({ + dat <- try(readLines(con), silent = TRUE) + }, "Failed to connect to") + close(con) + dat <- grep("href",dat,value = T) + dat <- unlist(lapply(strsplit(dat, "\\]\\] "),function(x) x[2])) + dat <- gsub(" 1) { + found <- found[1] + warning("More than one file found that matches the pattern. Only the first one will be used.") + } else found <- found[1] + message(paste0("Matching file with ",res," resolution found: ",found)) + } + + #update cellular input files + cfg$input["cellular"] <- found + + #copy gdx file for 1st time step from low resolution run for better starting point + #note: using gdx files for more than the 1st time step sometimes pushes the model into corner solutions, which might result in infeasibilites. + cfg$files2export$start <- c(cfg$files2export$start, + paste0(cfg$results_folder, "/", "magpie_y*.gdx")) + cfg$gms$s_use_gdx <- 0 + + #max resources for parallel runs + cfg$qos <- "standby_highMem" + + # set force download to FALSE + # otherwise data is download again when calling start_run(), which overwrites + # f21_trade_balance.cs3, f13_tau_scenario.csv, f32_max_aff_area.cs4 etc + cfg$force_download <- FALSE + + #download input files with high resolution + download_and_update(cfg) + + # set title + tmp <- unlist(strsplit(cfg$title, "_")) + tmp[1] <- paste0(tmp[1], paste0("HR", res)) + cfg$title <- paste(tmp, collapse = "_") + + if(!is.null(cfg$results_folder_highres)) { + cfg$results_folder <- file.path(cfg$results_folder_highres,":title:") + } else { + cfg$results_folder <- paste0("output/HR", res, "/:title:") + } + cfg$force_replace <- TRUE + cfg$recalc_npi_ndc <- TRUE + + #get trade pattern from low resolution run with c200 + k_trade <- readGDX(gdx, "k_trade") + ov_prod_reg <- readGDX(gdx, "ov_prod_reg", select = list(type = "level"))[,,k_trade] + ov_supply <- readGDX(gdx, "ov_supply", select = list(type = "level"))[,,k_trade] + import_for_feasibility <- readGDX(gdx, "ov21_import_for_feasibility", select = list(type = "level"), react = "silent") + if(is.null(import_for_feasibility)) { + import_for_feasibility <- new.magpie(getCells(ov_supply),getYears(ov_supply),getNames(ov_supply),fill = 0) + } + supreg <- readGDX(gdx, "supreg") + f21_trade_balance <- toolAggregate(ov_prod_reg - (ov_supply + import_for_feasibility), supreg) + write.magpie(f21_trade_balance, paste0("modules/21_trade/input/f21_trade_balance.cs3")) + + if(!is.null(tc)) { + #get tau from low resolution run with c200 + ov_tau <- readGDX(gdx, "ov_tau",select=list(type="level")) + write.magpie(ov_tau,"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- tc + } + + #use exo trade and parallel optimization + cfg$gms$trade <- "exo" + 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 + a <- readGDX(gdx,"f56_pollutant_prices_coupling", react = "silent") + if(!is.null(a)) write.magpie(a,"modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3") + a <- readGDX(gdx,"f56_pollutant_prices_emulator", react = "silent") + if(!is.null(a)) write.magpie(a,"modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") + a <- readGDX(gdx,"f60_bioenergy_dem_coupling", react = "silent") + if(!is.null(a)) write.magpie(a,"modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv") + a <- readGDX(gdx,"f60_bioenergy_dem_emulator", react = "silent") + if(!is.null(a)) write.magpie(a,"modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv") + + #get regional afforestation/reforestation (AR) 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 AR limit + aff <- aff-setYears(aff[,1,],NULL) + #calculate maximum regional AR over time + aff_max <- setYears(aff[,1,],NULL) + for (r in getRegions(aff)) { + aff_max[r,,] <- max(aff[r,,]) + } + aff_max[aff_max < 0] <- 0 + withr::defer({ + if (file.exists("modules/32_forestry/input/f32_max_aff_area.cs4")) { + file.remove("modules/32_forestry/input/f32_max_aff_area.cs4") + } + }) + write.magpie(aff_max,"modules/32_forestry/input/f32_max_aff_area.cs4") + cfg$gms$s32_max_aff_area_glo <- 0 + #check if regional AR exceeds global AR limit + if(cfg$gms$s32_max_aff_area < Inf) { + indicator <- sum(aff_max)-cfg$gms$s32_max_aff_area + if(indicator > 1e-06) warning(paste("Regional AR exceeds global AR limit by",indicator,"Mha")) + } + + # sleep to prevent issues with creating full.gms + Sys.sleep(2) + + start_run(cfg, codeCheck = FALSE, lock_model = FALSE) + + # sleep to prevent issues with creating full.gms + Sys.sleep(1) +} +highres(cfg) diff --git a/scripts/output/extra/land_cluster.R b/scripts/output/extra/land_cluster.R new file mode 100644 index 0000000000..a3659ef5a0 --- /dev/null +++ b/scripts/output/extra/land_cluster.R @@ -0,0 +1,44 @@ +# | (C) 2008-2025 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: Write land use information on cluster level to land_cluster.gpkg (GeoPackage) +# comparison script: FALSE +# --------------------------------------------------------------- + +if (packageVersion("magpie4") < "1.180.0") { + stop("land_cluster.R requires magpie4 >= 1.180.0, please update magpie4") +} + +if (!exists("source_include")) { + outputdir <- utils::tail(Sys.glob("output/default_*"), 1) + lucode2::readArgs("outputdir") +} + +landUse <- magpie4::land(file.path(outputdir, "fulldata.gdx"), level = "cell") +cropArea <- magpie4::croparea(file.path(outputdir, "fulldata.gdx"), level = "cell", product_aggr = FALSE) +x <- magclass::mbind(landUse, cropArea) +if (!isTRUE(all.equal(x[, , "crop"], + magclass::dimSums(x[, , dimnames(cropArea)[[3]]]), + check.attributes = FALSE))) { + stop("Summing up crop area for all crops from magpie4::croparea != crop area from magpie4::land") +} + +clustermap <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) +if (length(clustermap) == 0) { + stop("no clustermap file found") +} else if (length(clustermap) > 1) { + warning("found multiple clustermaps, using ", clustermap[[1]]) + clustermap <- clustermap[[1]] +} +clustermap <- readRDS(clustermap) + +clusterPolygons <- magpie4::clusterOutputToTerraVector(x, clustermap) + +outfile <- file.path(outputdir, "land_cluster.gpkg") +message("Writing ", outfile) +terra::writeVector(clusterPolygons, outfile, overwrite = TRUE) diff --git a/scripts/output/extra/modelstat.R b/scripts/output/extra/modelstat.R new file mode 100644 index 0000000000..209ead1782 --- /dev/null +++ b/scripts/output/extra/modelstat.R @@ -0,0 +1,57 @@ +# | (C) 2008-2025 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: checks the modelstat of several runs +# comparison script: TRUE +# --------------------------------------------------------------- + +######################### +#### check modelstat #### +######################### +# Version 1.0, Florian Humpenoeder +# +library(lucode2) +library(magpie4) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + +out <- NULL +missing <- NULL + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + #gdx file + gdx<-file.path(outputdir[i],"fulldata.gdx") + if(file.exists(gdx)) { + tmp <- modelstat(gdx) + dimnames(tmp)[[3]] <- paste(outputdir[i],dimnames(tmp)[[3]],sep=".") + out <- mbind(out,tmp) + } else missing <- c(missing,outputdir[i]) +} +write.magpie(out,paste("./output/modelstat_",basename(getwd()),".csv",sep="")) +if (!is.null(missing)) { + cat("\nList of folders with missing fulldata.gdx\n") + print(missing) +} +if (all(out==2)) { + cat("\nGood news! No time steps with modelstat different from 2 found!\n") +} else { + cat("\nTime steps with modelstat different from 2 found!\n") + for (i in c(1,3:19)) { + if (any(out==i)) warning("Time steps with modelstat ",i," found!") + } +} diff --git a/scripts/output/extra/mrdownscale.R b/scripts/output/extra/mrdownscale.R new file mode 100644 index 0000000000..4605c948a0 --- /dev/null +++ b/scripts/output/extra/mrdownscale.R @@ -0,0 +1,13 @@ +# | (C) 2008-2025 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: Downscale MAgPIE results to 0.5 degree resolution using landuseinit as reference data +# comparison script: FALSE +# ------------------------------------------------------------------------------------------------ +library(mrdownscale) +downscaleRun(outputdir, "DOWNSCALEDMAGPIE") diff --git a/scripts/output/extra/mrdownscale_LUH2.R b/scripts/output/extra/mrdownscale_LUH2.R new file mode 100644 index 0000000000..0e793508f9 --- /dev/null +++ b/scripts/output/extra/mrdownscale_LUH2.R @@ -0,0 +1,13 @@ +# | (C) 2008-2025 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: Downscale MAgPIE results to 0.25 degree resolution in LUH2 format for ESMs +# comparison script: FALSE +# ------------------------------------------------------------------------------------------------ +library(mrdownscale) +downscaleRunESM(outputdir) diff --git a/scripts/output/extra/out_of_bounds_check.R b/scripts/output/extra/out_of_bounds_check.R new file mode 100644 index 0000000000..8579eaa29e --- /dev/null +++ b/scripts/output/extra/out_of_bounds_check.R @@ -0,0 +1,55 @@ +# | (C) 2008-2025 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: checks variables for constraint violations +# comparison script: FALSE +# --------------------------------------------------------------- + +######################### +#### check obb #### +######################### +# Version 1.0, Florian Humpenoeder +# +library(gdx2) +library(lucode2) +library(magclass) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + gdx<-file.path(outputdir[i],"fulldata.gdx") + if(file.exists(gdx)) { + x <- readGDX(gdx, "ov*", types="parameters", field = "All") + for(i in names(x)) { + print(i) + try(z <- where(x[[i]][,,"level"] < x[[i]][,,"lower"] | x[[i]][,,"level"] > x[[i]][,,"upper"])$true, silent = TRUE) + if(exists("z")) { + if (length(z$individual) > 0) { + for (r in z$regions) { + for (y in z$years) { + print(paste(i,r,y)) + print(x[[i]][r,y,]) + } + } + } + rm(z) + } + } + } +} diff --git a/scripts/output/extra/reportMAgPIE2REMIND.R b/scripts/output/extra/reportMAgPIE2REMIND.R new file mode 100644 index 0000000000..0fff9fd44c --- /dev/null +++ b/scripts/output/extra/reportMAgPIE2REMIND.R @@ -0,0 +1,30 @@ +# | (C) 2008-2025 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: Write only those variables into a report that are relevant for the REMIND coupling +# comparison script: FALSE +# --------------------------------------------------------------- + +local ({ + withr::local_options("magclass.verbosity" = 1) + + ############################# BASIC CONFIGURATION ############################# + if(!exists("source_include")) { + outputdir <- "/p/projects/remind/runs/REMIND-MAgPIE-2022-10-12/magpie/output/C_SDP-PkBudg1150-mag-4" + lucode2::readArgs("outputdir") + } + + cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) + gdx <- file.path(outputdir, "fulldata.gdx") + mif <- file.path(outputdir, "report.mif") + ############################################################################### + + report <- magpie4::getReportMAgPIE2REMIND(gdx, scenario = cfg$title) + magclass::write.report(report, file = mif) + +}) diff --git a/scripts/output/extra/reportMAgPIE2SEALS.R b/scripts/output/extra/reportMAgPIE2SEALS.R new file mode 100644 index 0000000000..aeb85125df --- /dev/null +++ b/scripts/output/extra/reportMAgPIE2SEALS.R @@ -0,0 +1,57 @@ +# | (C) 2008-2025 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: Modifies gridded MAgPIE land use patterns so that they can be read in by the Spatial Economic Allocation Landscape Simulator (SEALS) +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Patrick v. Jeetze +# 1.00: first working version + +library(gms) +library(gdx2) +library(magpie4) + +message("Starting to report gridded MAgPIE land use for SEALS") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + + +# Restructure data to conform to SEALS +reportLandUseForSEALS( + magCellLand = "cell.land_0.5_share.mz", + outFile = paste0("cell.land_0.5_SEALS_", title, ".nc"), + dir = outputdir, selectyears = c(2020, 2030, 2040, 2050) +) + +# In case of reforestation using plantation growth curves set forestry to zero +# in order to calculated the difference in forest allocation between two SEALS runs +plantation <- readGDX(file.path(outputdir, "fulldata.gdx"), "s32_aff_plantation") + +if (plantation) { + land_hr <- read.magpie(file.path(outputdir, "cell.land_0.5_share.mz")) + land_hr[, , "forestry"] <- 0 + + reportLandUseForSEALS( + magCellLand = land_hr, + outFile = paste0("cell.land_0.5_SEALS_", title, "_noForestry.nc"), + dir = outputdir, selectyears = c(2020, 2030, 2040, 2050) + ) +} diff --git a/scripts/output/extra/resubmit.R b/scripts/output/extra/resubmit.R new file mode 100644 index 0000000000..337b43e639 --- /dev/null +++ b/scripts/output/extra/resubmit.R @@ -0,0 +1,51 @@ +# | (C) 2008-2025 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: re-submits runs to different queues (e.g. priority) +# comparison script: TRUE +# --------------------------------------------------------------- + +###################### +#### resubmit run #### +###################### +# Version 1.0, Florian Humpenoeder +# +library(lucode2) +library(magpie4) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + +out <- NULL +missing <- NULL + +for (i in 1:length(outputdir)) { + print(paste("Checking",outputdir[i])) + #gdx file + gdx<-file.path(outputdir[i],"fulldata.gdx") + if(file.exists(gdx)) { + tmp <- try(modelstat(gdx),silent = TRUE) + if(!is.magpie(tmp)) tmp <- 0 + } else tmp <- 0 + if (any(tmp>2) | any(tmp==0)) { + file.copy(from = "scripts/run_submit/submit_standby.sh",to = file.path(outputdir[i],"submit_standby.sh"),overwrite = TRUE) + current <- getwd() + setwd(outputdir[i]) + if (file.exists("magpie_y1995.gdx")) file.remove("magpie_y1995.gdx") + system("sbatch submit_standby.sh") + setwd(current) + } +} diff --git a/scripts/output/extra/runSEALSallocation.R b/scripts/output/extra/runSEALSallocation.R new file mode 100644 index 0000000000..189c780549 --- /dev/null +++ b/scripts/output/extra/runSEALSallocation.R @@ -0,0 +1,344 @@ +# | (C) 2008-2025 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: Starts SEALS allocation run based on gridded MAgPIE land cover projections +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.1.0 - Patrick v. Jeetze, Pascal Sauer +# 1.0.0: first working version +# 1.1.0: SEALS coefficients are modified based on scenario settings + +library(gms) +library(gdx2) +library(magpie4) +library(filelock) + +message("Initialising SEALS allocation run") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") +} +######################################################################################### + +# ======================== +# User settings +# ======================== + +### SEALS python environment name +# see https://justinandrewjohnson.com/earth_economy_devstack/installation.html +# for instructions on how to set up a python environment for SEALS +sealsEnv <- "seals_dev" + +### Path to SEALS base input file directory +dirBaseFiles <- "/p/projects/magpie/users/vjeetze/seals/files" + +### Path to SEALS code base +dirSEALS <- "/p/projects/magpie/users/vjeetze/seals/files/seals/seals_dev" + + +# ======================== +# Prepare MAgPIE output +# ======================== + +message("Script started for output directory: ", outputdir) + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +if (length(cfg$seals_years) != 0) { + rep_years <- cfg$seals_years[cfg$seals_years > 2020] + rep_years <- c(2020, rep_years) +} else { + rep_years <- seq(2020, 2050, 5) +} + +# Restructure data to conform to SEALS +sealsInput <- paste0("cell.land_0.5_SEALS_", title, ".nc") +reportLandUseForSEALS( + magCellLand = "cell.land_0.5_share.mz", + outFile = sealsInput, + dir = outputdir, selectyears = rep_years +) + + +# ======================== +# Setup SEALS run +# ======================== + +# Check whether base data and local SEALS code repo exist +if (length(list.files(dirBaseFiles)) == 0) { + stop(paste( + "Please set the path to the SEALS base data", + "directory under 'User settings' of the", + "extra/runSEALSallocation.R script." + )) +} else if (length(list.files(dirSEALS)) == 0) { + stop(paste( + "Please set the path to your local clone", + "of the SEALS code under 'User settings' of the", + "extra/runSEALSallocation.R script." + )) +} + +### Path to miniforge installation +miniforgePath <- "/p/projects/rd3mod/miniforge3/v25-3-0_3/bin/activate" + +# create output directory +dirProject <- "./output/seals" + +if (!dir.exists(file.path(dirProject))) { + dir.create(file.path(dirProject), recursive = TRUE) +} + +iniLock <- file.path(dirProject, ".lock") +lockOn <- filelock::lock(iniLock, exclusive = TRUE, timeout = Inf) +Sys.chmod(iniLock, mode = "0664") + + +# -------------------------------- +# Prepare SEALS start script +# -------------------------------- + +.setupSEALSrun <- function(cfg, sealsInput, dir, dirProject, dirSEALS, dirBaseFiles) { + if (!dir.exists(file.path(dirProject, "scripts"))) { + dir.create(file.path(dirProject, "scripts"), recursive = TRUE) + } + + title <- cfg$title + + file.copy( + from = list.files(file.path(dirSEALS, "seals"), full.names = TRUE), + to = file.path(dirProject, "scripts"), + overwrite = TRUE, + recursive = TRUE + ) + + if (!dir.exists(file.path(dirProject, "inputs"))) { + dir.create(file.path(dirProject, "inputs"), recursive = TRUE) + } + + rcp <- unlist(strsplit(cfg$input["cellular"], "_"))[6] + rcp <- paste0("rcp", substr(rcp, nchar(rcp) - 1, nchar(rcp))) + + ssp <- tolower(cfg$gms$c09_pop_scenario) + + if (length(cfg$seals_years) != 0) { + sealsYears <- cfg$seals_years[cfg$seals_years > 2020] + sealsYears <- paste(sealsYears, collapse = " ") + } else { + sealsYears <- "2050" + } + + scenarioType <- ifelse(grepl("default|bau|ssp\\d-ref", tolower(title)), "bau", "policy") + + if (cfg$gms$c22_protect_scenario == "none") { + consv <- cfg$gms$c22_base_protect + } else { + consv <- cfg$gms$c22_protect_scenario + } + + ### Modify SEALS model coefficients based on scenario settings + + message("Updating SEALS model coefficients based on scenario settings") + + sealsCoeff <- paste0(c("./", "../", "../../"), "input/seals_global_coefficients.csv") + sealsCoeff <- Find(file.exists, sealsCoeff) + + if (!is.null(sealsCoeff)) { + sealsCoeff <- read.csv(sealsCoeff) + consvRow <- which(sealsCoeff[, "spatial_regressor_name"] == "land_conservation") + sealsCoeff[consvRow, "data_location"] <- sub( + "WDPA", consv, sealsCoeff[consvRow, "data_location"] + ) + + if (cfg$gms$s29_snv_shr != 0) { + if (cfg$gms$s29_snv_shr == 0.2) { + # snv policy reallocation incentive + snvRow1 <- which(sealsCoeff[, "spatial_regressor_name"] == "snv20_realloc") + sealsCoeff[snvRow1, c("forest", "othernat")] <- -100 + # snv policy expansion constraint + snvRow2 <- which(sealsCoeff[, "spatial_regressor_name"] == "snv20_expan") + sealsCoeff[snvRow2, "cropland"] <- 0 + } else { + warning("Only if s29_snv_shr is 0.2 can it be explicitly considered at the 1x1km scale during the SEALS allocation.") + } + } + + peatArea <- PeatlandArea(file.path(dir, "fulldata.gdx"))[, as.numeric(sealsYears), ] + rewetSwitch <- dimSums(peatArea[, , "rewet"], dim = 1) / dimSums(peatArea, dim = c(1, 3)) > 0.01 + if (any(c(rewetSwitch))) { + peatRow <- which(sealsCoeff[, "spatial_regressor_name"] == "peatland_rewetting") + # SEALS rewetting coefficient + rewetCoeff <- 10000 + # disincentivise agricultural expansion + sealsCoeff[peatRow, c("cropland", "grassland")] <- rewetCoeff + # peatland rewetting incentive + sealsCoeff[peatRow, c("forest", "othernat")] <- -rewetCoeff + } + + sealsCoeffPath <- file.path( + dirProject, "inputs", + paste0("seals_global_coefficients_", title, ".csv") + ) + + write.csv(sealsCoeff, sealsCoeffPath, + row.names = FALSE, na = "", quote = FALSE # quote = FALSE is critical here! + ) + } else { + stop("Could not find seals_global_coefficients.csv file") + } + + + ### Create SEALS scenario definitions CSV + + message("Creating SEALS scenario definitions CSV") + + sealsConfig <- paste0(c("./", "../", "../../"), "input/seals_scenario_config.csv") + sealsConfig <- Find(file.exists, sealsConfig) + + if (!is.null(sealsConfig)) { + sealsConfig <- read.csv(sealsConfig) + sealsConfig[nrow(sealsConfig), "scenario_label"] <- title + sealsConfig[nrow(sealsConfig), "scenario_type"] <- scenarioType + sealsConfig[nrow(sealsConfig), "exogenous_label"] <- ssp + sealsConfig[nrow(sealsConfig), "climate_label"] <- rcp + sealsConfig[nrow(sealsConfig), "counterfactual_label"] <- title + sealsConfig[nrow(sealsConfig), "comparison_counterfactual_labels"] <- ifelse(scenarioType == "bau", "", "bau") + sealsConfig[, "coarse_projections_input_path"] <- normalizePath(file.path(dir, sealsInput)) + sealsConfig[nrow(sealsConfig), "years"] <- sealsYears + sealsConfig[nrow(sealsConfig), "calibration_parameters_source"] <- normalizePath(sealsCoeffPath) + write.csv(sealsConfig, file.path(dirProject, "inputs", paste0("seals_scenario_config_", title, ".csv")), + row.names = FALSE, na = "", quote = FALSE # quote = FALSE is critical here! + ) + } else { + stop("Could not find seals_scenario_config.csv file template") + } + + main <- readLines(file.path(dirProject, "scripts", "run_test_standard.py")) + + main[min(which(grepl(" p.user_dir =", main)))] <- paste0(" p.user_dir = \'", dirBaseFiles, "\'") + main[min(which(grepl(" p.extra_dirs", main)))] <- paste0(" p.extra_dirs = '.'") + main[min(which(grepl(" p.project_name =", main)))] <- paste0(" p.project_name = \'", title, "\'") + main[min(which(grepl(" p.project_dir =", main)))] <- paste0( + " p.project_dir = \'", normalizePath(dirProject), "\'" + ) + main[min(which(grepl("hb.pretty_time()", main)))] <- " " + main[min(which(grepl(" p.base_data_dir =", main)))] <- paste0( + " p.base_data_dir = \'", dirBaseFiles, "/base_data\'" + ) + main[min(which(grepl(" p.scenario_definitions_filename =", main)))] <- paste0( + " p.scenario_definitions_filename = \'", paste0("seals_scenario_config_", title, ".csv"), "\'" + ) + + writeLines(main, file.path(dirProject, "scripts", paste0("run_seals_", title, ".py"))) + + + if (!dir.exists(file.path(dirProject, "run_submit"))) { + dir.create(file.path(dirProject, "run_submit"), recursive = TRUE) + } +} + +# -------------------------------- +# Submit run +# -------------------------------- + +.submitSEALS <- function(title, dirProject, miniforgePath, sealsEnv, qos = "short", + slurmID = FALSE, dependsID = NULL) { + submitFile <- file.path(dirProject, "run_submit", paste0("submit_seals_", title, ".sh")) + + submit <- c( + "#!/bin/bash", "\n", + paste0("#SBATCH --qos=", qos), + if (qos %in% c("priority", "standby")) "#SBATCH --partition=priority" else "#SBATCH --partition=standard", + "#SBATCH --job-name=seals_allocation", + paste0("#SBATCH --chdir=", normalizePath(file.path(dirProject, "scripts"))), + "#SBATCH --output=outfile_%j.out", + "#SBATCH --error=outfile_%j.err", + "#SBATCH --mail-type=END,FAIL", + ifelse(!is.null(dependsID), "#SBATCH --time=5:00:00", "#SBATCH --time=0:20:00"), "\n", + "#SBATCH --nodes=1", + "#SBATCH --ntasks=1", + ifelse(!is.null(dependsID), paste0( + "#SBATCH --dependency=afterok:", dependsID, + "\n#SBATCH --kill-on-invalid-dep=yes" + ), + "#SBATCH --dependency=singleton" + ), "\n", + "#SBATCH --cpus-per-task=64", "\n", + paste("source", miniforgePath), + paste("conda activate", sealsEnv), "\n", + paste("python", paste0("run_seals_", title, ".py")) + ) + writeLines(submit, submitFile) + + id <- system(paste("sbatch --parsable", submitFile), intern = TRUE) + if (slurmID) { + return(id) + } +} + +# -------------------------------- +# Run SEALS allocation +# -------------------------------- + +if (!is.null(lockOn)) { + sealsLock <- file.path(dirProject, "seals.lock") + + .setupSEALSrun( + cfg = cfg, + sealsInput = sealsInput, + dir = outputdir, + dirProject = dirProject, + dirSEALS = dirSEALS, + dirBaseFiles = dirBaseFiles + ) + + if (!file.exists(sealsLock) || file.size(sealsLock) == 0) { + message(paste( + "Starting SEALS allocation with input data creation.\n", + "Stitched SEALS allocation outputs will be written to", + "'./output/seals/intermediate/stitched_lulc_simplified_scenarios'" + )) + + id <- .submitSEALS( + title = title, + dirProject = dirProject, + miniforgePath = miniforgePath, + sealsEnv = sealsEnv, + qos = "short", + slurmID = TRUE + ) + + writeLines(id, sealsLock) + } else { + id <- readLines(sealsLock) + + message(paste( + "Starting SEALS allocation using existing input data.\n", + "Stitched SEALS allocation outputs will be written to", + "'./output/seals/intermediate/stitched_lulc_simplified_scenarios'" + )) + + .submitSEALS( + title = title, + dirProject = dirProject, + miniforgePath = miniforgePath, + sealsEnv = sealsEnv, + qos = "short", + slurmID = FALSE, + dependsID = id + ) + } + unlink(iniLock) +} diff --git a/scripts/output/extra/runtime.R b/scripts/output/extra/runtime.R new file mode 100644 index 0000000000..4e461aa6d7 --- /dev/null +++ b/scripts/output/extra/runtime.R @@ -0,0 +1,24 @@ +# | (C) 2008-2025 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: Checks the runtime of several runs +# comparison script: TRUE +# --------------------------------------------------------------- + +############################# LOAD LIBRARIES ############################# +library(lucode2, quietly = TRUE, warn.conflicts =FALSE) + +if(!exists("source_include")) { + outputdir <- c("output/default_2015-01-14_11.41.17", + "output/default_2015-01-14_12.28.56", + "output/default_2015-01-14_15.00.13", + "output/default_2015-01-14_15.36.12"); + lucode2::readArgs("outputdir") +} + +print(lucode2::readRuntime(outputdir,plot=TRUE)) diff --git a/scripts/output/extra/runtimePR.R b/scripts/output/extra/runtimePR.R new file mode 100644 index 0000000000..271814c517 --- /dev/null +++ b/scripts/output/extra/runtimePR.R @@ -0,0 +1,128 @@ +# | (C) 2008-2025 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: Compiles model run time for PR +# comparison script: TRUE +# --------------------------------------------------------------- + +############################# LOAD LIBRARIES ############################# +library(lucode2, quietly = TRUE, warn.conflicts =FALSE) + +if(!exists("source_include")) { + outputdir <- file.path("output",list.dirs("output", full.names = FALSE, recursive = FALSE)) + lucode2::readArgs("outputdir") +} + +runtime <- NULL +maindir <- getwd() + +# ---- Read runtime data ---- + +cat("\nReading runtime for", length(outputdir), "runs\n") +for (d in outputdir) { + splittedpath <- strsplit(d, "/")[[1]] + runfolder <- splittedpath[length(splittedpath)] + datafile <- paste0(d, "/runstatistics.rda") + + # try to read runtime data from runstatistics.rda + tmp <- NULL + start <- NULL + end <- NULL + timePrepareStart <- NULL + timePrepareEnd <- NULL + timeGAMSStart <- NULL + timeGAMSEnd <- NULL + timeOutputStart <- NULL + timeOutputEnd <- NULL + + if (!file.exists(datafile)) { + cat("No file found ", datafile, "\n") + } else if (file.info(datafile)$size == 0) { + cat("Empty file ", datafile, "\n") + } else { + # if file exists and it's file size is >0: load it + stats <- NULL + load(datafile) + # try to load detailed runtime information + if (!is.null(stats) && !is.null(stats$timePrepareStart)) { + timePrepareStart <- stats$timePrepareStart + timePrepareEnd <- stats$timePrepareEnd + timeGAMSStart <- stats$timeGAMSStart + timeGAMSEnd <- stats$timeGAMSEnd + timeOutputStart <- stats$timeOutputStart + timeOutputEnd <- stats$timeOutputEnd + } else if (!is.null(stats) && !is.null(stats$starttime)) { + # if no detailed information is available load the old one (it's only the gams runtime) + start <- stats$starttime + end <- stats$endtime + } + } + + # if no start and end was extractable from runstatistics.rda + # conclude it from timestamps of the files in the results folder + if (is.null(end) && is.null(timePrepareEnd) && is.null(timeGAMSEnd) && is.null(timeOutputEnd)) { + local_dir(d) + # find all files + info <- file.info(dir()) + # sort files in info by mtime + info <- info[order(info$mtime), ] + # save time of first file in the list (oldest) + start <- info[1, ]$mtime + # save time if last file in the list (newest) + + if ("report.rds" %in% rownames(info)) { + # if run has finished normally the report.rds file should exist. In this case take the newest file + cat("Using the newest file in", runfolder, "as end\n") + end <- tail(info$mtime, n = 1) + } else { + # if report.rds does not exist, this indicates that the run did not finish properly and the mif file has been + # generated manually later without also producing the report.rds + # In this case do not take the newest file (which is the manually and belated produced mif file) but take the + # full.lst which is the newest file before the mif file + cat("Using", runfolder, "full.lst as end\n") + end <- info["full.lst", ]$mtime + } + local_dir(maindir) + } + + # if (total) runtime data was found + if (all(c(!is.null(start), !is.null(end)))) { + # need to be transformed to NA otherwise rbind would not work if one of them is NULL + tmp <- end - start + units(tmp) <- "hours" + if (is.null(start)) start <- NA + if (is.null(end)) end <- NA + new <- data.frame(section = "total", run = runfolder, mins = round(tmp,1), stringsAsFactors = FALSE) + runtime <- rbind(runtime, new) + } + + # if detailed runtime data was found append it + if (!is.null(timePrepareEnd)) { + tmp <- timePrepareEnd - timePrepareStart + units(tmp) <- "mins" + new <- data.frame(section = "prep", run = runfolder, mins = round(tmp,1), stringsAsFactors = FALSE) + runtime <- rbind(runtime, new) + } + + if (!is.null(timeGAMSEnd)) { + tmp <- timeGAMSEnd - timeGAMSStart + units(tmp) <- "mins" + new <- data.frame(section = "GAMS", run = runfolder, mins = round(tmp,1), stringsAsFactors = FALSE) + runtime <- rbind(runtime, new) + } + + if (!is.null(timeOutputEnd)) { + tmp <- timeOutputEnd - timeOutputStart + units(tmp) <- "mins" + new <- data.frame(section = "output", run = runfolder, mins = round(tmp,1), stringsAsFactors = FALSE) + runtime <- rbind(runtime, new) + } +} + +runtime <- runtime[order(runtime$section,runtime$run),] +write.csv(runtime, file = "output/runtimePR.csv", quote = FALSE,row.names = FALSE) diff --git a/scripts/output/extra/timestep_duration.R b/scripts/output/extra/timestep_duration.R new file mode 100644 index 0000000000..10c13bf7ce --- /dev/null +++ b/scripts/output/extra/timestep_duration.R @@ -0,0 +1,53 @@ +# | (C) 2008-2025 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: Makes a png file containing solve time for each step +# comparison script: FALSE +# --------------------------------------------------------------- + +#Version 1.00 - Abhijeet Mishra +# 1.00: first working version [AM] +# 1.10: Bugfix to calculate all times in single units [AM] + +library(magpie4) +library(magpiesets) +library(lusweave) +library(magclass) +library(ggplot2) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <-"." +} + +filenames <- list.files(outputdir,full.names = TRUE) +filenames <- grep(x=filenames,pattern="gdx",value=T) + +infor <- file.info(filenames) + +infor$filename = basename(rownames(infor)) +rownames(infor) = NULL + +infor <- infor[order(infor$mtime),] +infor$Tdiff <- 0 + +for(i in 2:nrow(infor)){ + infor$Tdiff[i] <- round(difftime(infor$mtime[i], infor$mtime[i-1], units='mins'),2) +} + +infor <- infor[order(infor$mtime),] + +p <- ggplot(infor, aes(x = factor(filename, levels = filename), y = Tdiff)) + + geom_bar(aes(fill=Tdiff), stat = 'identity',position="dodge",colour="black", width = 0.8) + + theme(axis.text.x = element_text(angle = 90)) + + xlab("GDX files in order of creation") + + ylab("Minutes") + + labs(fill = "Minutes") + + +ggsave(plot = p,filename = paste0(outputdir,"/timestep_solve_duration.png"),width = 12,height = 6) diff --git a/scripts/output/extra/validation_existing_report.R b/scripts/output/extra/validation_existing_report.R new file mode 100644 index 0000000000..cda5f1087b --- /dev/null +++ b/scripts/output/extra/validation_existing_report.R @@ -0,0 +1,46 @@ +# | (C) 2008-2025 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: Creates a validation pdf out of an existing mif file, speeding up the process. +# comparison script: FALSE +# --------------------------------------------------------------- + +library(mip) +library(magpie4) +library(gms) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdirs <-"." +} +file <- paste0("comparison_validation_",format(Sys.time(), "%Y%H%M%S"),".pdf") +############################################################################### + +x <- NULL; i <- 1 +for(outputdir in outputdirs) { + config <- file.path(outputdir,"config.yml") + if(file.exists(config)) { + cfg <- gms::loadConfig(config) + title <- cfg$title + } else { + title <- paste0("run",i) + } + report <- paste0(outputdir, "/report.mif") + if(!is.null(x)) { + scenarios <- getNames(x,dim=2) + if(title %in% scenarios) { + title <- tail(make.unique(c(scenarios,title),sep=""),n=1) + } + } + tmp <- read.report(report,as.list = FALSE) + x <- mbind(x,tmp) + i <- i+1 + hist <- paste0(outputdir, "/validation.mif") +} + +validationpdf(x=x, hist=hist, file = file, style="comparison") diff --git a/scripts/output/merge_report.R b/scripts/output/merge_report.R new file mode 100644 index 0000000000..f78a3c4130 --- /dev/null +++ b/scripts/output/merge_report.R @@ -0,0 +1,53 @@ +# | (C) 2008-2025 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: Merges report.mif files from several runs into a single mif file +# comparison script: TRUE +# position: 3 +# --------------------------------------------------------------- + +# Version 1.0, Florian Humpenoeder +# +library(lucode2) +library(magclass) +library(quitte) +library(gms) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + +missing <- NULL +out <- NULL + +if(file.exists("output/report_all.rds")) file.rename("output/report_all.rds","output/report_all_bak.rds") +if(file.exists("output/report_all.mif")) file.rename("output/report_all.mif","output/report_all_bak.mif") + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + rep<-file.path(outputdir[i],"report.rds") + if(file.exists(rep)) { + a <- readRDS(rep) + out <- rbind(out,a) + } else missing <- c(missing,outputdir[i]) +} + +saveRDS(out,file="output/report_all.rds") +write.mif(out,"output/report_all.mif") + +if (!is.null(missing)) { + cat("\nList of folders with missing report.mif\n") + print(missing) +} diff --git a/scripts/output/output_check.R b/scripts/output/output_check.R new file mode 100644 index 0000000000..c0da3a809e --- /dev/null +++ b/scripts/output/output_check.R @@ -0,0 +1,26 @@ +# | (C) 2008-2025 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: check output for known problems +# comparison script: FALSE +# position: 1 +# --------------------------------------------------------------- + + +library(magpie4, quietly = TRUE) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- "" + readArgs("outputdir") +} + +gdx <- file.path(outputdir,"fulldata.gdx") +############################################################################### + +magpie4::outputCheck(gdx) diff --git a/scripts/output/projects/BEST_merge_report.R b/scripts/output/projects/BEST_merge_report.R new file mode 100644 index 0000000000..4073766ac0 --- /dev/null +++ b/scripts/output/projects/BEST_merge_report.R @@ -0,0 +1,53 @@ +# | (C) 2008-2025 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: Merges single report files into one file +# comparison script: TRUE +# position: 3 +# --------------------------------------------------------------- + +library(lucode2) +library(magclass) +library(quitte) +library(iamc) +library(magpie4) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + +file_name <- "output/BEST_V13.csv" + +missing <- NULL + +if(file.exists(file_name)) file.rename(file_name,(sub(".csv",".bak",file_name))) + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + #gdx file + rep<-path(outputdir[i],"report.mif") + if(file.exists(rep)) { + #read-in reporting file + a <- read.report(rep,as.list = FALSE) + #add to reporting csv file + mapfile <- system.file("extdata", "variablemappingBEST.csv", package="magpie4") + write.reportProject(a,mapping=mapfile,file=file_name,append=TRUE,ndigit = 4,skipempty = FALSE) + } else missing <- c(missing,outputdir[i]) +} +if (!is.null(missing)) { + cat("\nList of folders with missing report.mif\n") + print(missing) +} diff --git a/scripts/output/projects/BtC2_reportDisaggLandUse.R b/scripts/output/projects/BtC2_reportDisaggLandUse.R new file mode 100644 index 0000000000..32c53bef1a --- /dev/null +++ b/scripts/output/projects/BtC2_reportDisaggLandUse.R @@ -0,0 +1,220 @@ +# | (C) 2008-2025 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: Creates a NetCDF file with disaggregated land pools, +# reclassified to land types used in the Bending the Curve 2.0 project +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Patrick v. Jeetze +# 1.00: first working version + +library(lucode2) +library(magpie4) +library(madrat) +library(gms) +library(gdx2) +library(mstools) +library(ncdf4) + +############################# BASIC CONFIGURATION ############################# +if (!exists("source_include")) { + outputdir <- NULL + # Define arguments that can be read from command line + readArgs("outputdir") +} +############################################################################### + +suffix <- "firstruns" + + +mapFile <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) +gdx <- file.path(outputdir, "fulldata.gdx") +landHrFile <- file.path(outputdir, "cell.land_0.5.mz") +landConsvHrFile <- file.path(outputdir, "cell.conservation_land_0.5.mz") +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) + +# ----------------------------------------- +# Helper functions +# ----------------------------------------- +.calcDiffLand <- function(landPool) { + dlandPool <- landPool[, 2:nyears(landPool), ] - setYears(landPool[, 1:nyears(landPool) - 1, ], tail(getYears(landPool), -1)) + return(dlandPool) +} + + +# ---------------------- +# Read input data +# ---------------------- + +# Read disaggregated MAgPIE outputs +landHr <- read.magpie(landHrFile)[, 1985, , invert = TRUE] +landConsvHr <- read.magpie(landConsvHrFile) + + +# ---------------------- +# Cropland classes +# ---------------------- + +carea <- magpie4::croparea(gdx, + level = "cell", products = "kcr", + product_aggr = FALSE, water_aggr = TRUE + ) +cropOtherLr <- setNames(dimSums(carea[, , c("begr", "betr"), invert = TRUE], dim = 3), "crop_other") +cropBELr <- setNames(dimSums(carea[, , c("begr", "betr")], dim = 3), "crop_2G_bioen") + + +careaShr <- mbind(cropOtherLr, cropBELr) / (dimSums(carea, dim = 3) + 10^-10) +careaShrHr <- madrat::toolAggregate(careaShr, mapFile, to = "cell") + + +careaHr <- careaShrHr * setNames(landHr[, , "crop"], NULL) + + +# ---------------------- +# Grassland class +# ---------------------- + +# Grassland share +grassHr <- setNames(landHr[, , "past"], "grass") + +# ----------------------------------- +# Recovered land +# ----------------------------------- + +# unmanaged land recovered after 2020 needs to be +# distributed among restored and abandoned land +landRecovrdHr <- landHr[,,c("primforest", "secdforest", "other")] - setYears(landHr[, "y2020", c("primforest", "secdforest", "other")], NULL) +landRecovrdHr[landRecovrdHr < 0] <- 0 +# only consider recovered land after 2015 +landRecovrdHr[, seq(1995, 2015, 5), ] <- 0 + +# for restoration only consider unmanaged vegetation classes +landConsvHr <- landConsvHr[, , c("primforest", "secdforest", "other")] +# only consider land conservation after 2015 +landConsvHr[, seq(1995, 2015, 5), ] <- 0 + +# subtract restoration area from remaining unmanaged vegetation +landRestorHr <- pmin(landConsvHr, landRecovrdHr[, , c("primforest", "secdforest", "other")]) +# Restored land +landRestorHr <- setNames(dimSums(landRestorHr, dim = 3), "rest") + +# +landUnmgdHr <- landHr[, , c("primforest", "secdforest", "other")] - landRecovrdHr + + +# ---------------------- +# Forest classes +# ---------------------- + +forestHr <- setNames(dimSums(landUnmgdHr[, , c("primforest", "secdforest")], dim = 3), "forest_unmanaged") +forestryHr <- setNames(dimSums(landHr[, , "forestry"], dim = 3), "forest_managed") + +# ---------------------- +# Non-forest land +# ---------------------- + +otherHr <- setNames(landUnmgdHr[, , "other"], "other") + +# ---------------------- +# Urban land +# ---------------------- + +urbanHr <- setNames(landHr[, , "urban"], "built_up_areas") + +# ---------------------- +# Abandonend land +# ---------------------- + +landAbnHr <- setNames(dimSums(landRecovrdHr, dim = 3) - landRestorHr, "abn_land") + + +# ---------------------- +# Combine classes +# ---------------------- + +landOut <- mbind( + careaHr, + grassHr, + forestHr, + forestryHr, + landRestorHr, + otherHr, + urbanHr, + landAbnHr +) + +# land cover share output +landOutShr <- landOut / dimSums(landOut, dim = 3) +landOutShr <- toolConditionalReplace(landOutShr, "is.na()") + +# caculate total land area +landArea <- dimSums(landOut, dim = 3) + +# ----------------------------------- +# Write NetCDF in requested format +# ----------------------------------- + +# create dimensions +lon <- seq(-179.75, 179.75, by = 0.5) +lat <- -seq(-89.75, 89.75, by = 0.5) +time <- as.numeric(sub("y","",getYears(landOutShr))) +lcClass <- 1:9 +dimLon <- ncdf4::ncdim_def("lon", "degrees_east",lon) +dimLat <- ncdf4::ncdim_def("lat", "degrees_north",lat) +dimTime <- ncdf4::ncdim_def("time", "years", calendar="standard",time,unlim=TRUE) +dimLandClass <- ncdf4::ncdim_def("lc_class", "1=cropland_other/2=cropland_2Gbioen/3=grassland/4=forest_unmanaged/5=forest_managed/6=restored/7=other/8=built-up/9=abn_land",lcClass) + +# create variables +fillvalue <- NaN +varNameLandShr <- 'share of pixel occupied by various land covers' +LandCoverVar <- ncvar_def(name = "LC_area_share",units = "share of pixel area",longname = varNameLandShr,dim = list(dimLon,dimLat,dimLandClass,dimTime), missval=fillvalue,prec = "double",compression = 9) +varNameTotArea<- 'total area of the pixel' +totAreaVar <- ncvar_def(name = "pixel_area",units = "million ha", longname = varNameTotArea, + dim = list(dimLon,dimLat), missval=fillvalue, prec = "double",compression = 9) + +### Land cover share + +# create the empty data array for land cover share +LandCoverVarArray <- array(NA, dim = c(length(lon), length(lat), length(lcClass), length(time)),dimnames = list(lon, lat, lcClass, time)) + +# convert magclass object to array +landOutShr <- as.array(landOutShr) +landOutShr <- aperm(landOutShr, c(1,3,2)) + +coord <- toolGetMappingCoord2Country(pretty = TRUE) +for (i in 1:ncells(landOutShr)) { + LandCoverVarArray[which(coord[i, "lon"] == lon), which(coord[i, "lat"] == lat), , ] <- landOutShr[i, , , drop = FALSE] +} + +### Land area + +# create the empty data array for land area +totAreaVarArray <- array(NA, dim = c(length(lon), length(lat)), dimnames = list(lon, lat)) + +# convert magclass object to array +landArea <- as.array(landArea) +landArea <- aperm(landArea, c(1,3,2)) + +for (i in 1:ncells(landArea)) { + totAreaVarArray[which(coord[i, "lon"] == lon), which(coord[i, "lat"] == lat)] <- landArea[i, ,"y1995", drop = FALSE] +} + +# create & fill netcdf with two variables +ncnew <- nc_create(file.path(outputdir, paste0("BendingTheCurve2_LCproj_MAgPIE_",cfg$title,"_",suffix,".nc")), list(LandCoverVar,totAreaVar),force_v4=TRUE) +ncvar_put(ncnew,totAreaVar,totAreaVarArray) +ncvar_put(ncnew,LandCoverVar,LandCoverVarArray) +# add attributes +ncatt_put(ncnew,0,"title",'MAgPIE land cover projections') +ncatt_put(ncnew,0,"scenario",cfg$title) +ncatt_put(ncnew,0,"institution",'PIK') +ncatt_put(ncnew,0,"contact","F. Humpenöder, humpenoeder@pik-potsdam.de; P. v. Jeetze, vjeetze@pik-potsdam.de") +ncatt_put(ncnew,0,"history",date()) +# close +nc_close(ncnew) + diff --git a/scripts/output/projects/BtC2_reportDisaggLandUse_draft.R b/scripts/output/projects/BtC2_reportDisaggLandUse_draft.R new file mode 100644 index 0000000000..2d0563019b --- /dev/null +++ b/scripts/output/projects/BtC2_reportDisaggLandUse_draft.R @@ -0,0 +1,309 @@ +# | (C) 2008-2025 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: Creates a NetCDF file with disaggregated land pools, +# reclassified to land types used in the Bending the Curve 2.0 project +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Patrick v. Jeetze +# 1.00: first working version + +library(lucode2) +library(magpie4) +library(madrat) +library(gms) +library(gdx2) +library(mstools) +library(ncdf4) + +############################# BASIC CONFIGURATION ############################# +if (!exists("source_include")) { + outputdir <- NULL + # Define arguments that can be read from command line + readArgs("outputdir") +} +############################################################################### + +suffix <- "firstruns" + + +mapFile <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) +gdx <- file.path(outputdir, "fulldata.gdx") +landHrFile <- file.path(outputdir, "cell.land_0.5.mz") +landConsvHrFile <- file.path(outputdir, "cell.conservation_land_0.5.mz") +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) + +# ----------------------------------------- +# Helper functions +# ----------------------------------------- +.calcDiffLand <- function(landPool) { + dlandPool <- landPool[, 2:nyears(landPool), ] - setYears(landPool[, 1:nyears(landPool) - 1, ], tail(getYears(landPool), -1)) + return(dlandPool) +} + + +# ---------------------- +# Read input data +# ---------------------- + +# Read disaggregated MAgPIE outputs +landHr <- read.magpie(landHrFile)[, 1985, , invert = TRUE] +landConsvHr <- read.magpie(landConsvHrFile) + + +# ---------------------- +# Cropland classes +# ---------------------- + +carea <- magpie4::croparea(gdx, + level = "cell", products = "kcr", + product_aggr = FALSE, water_aggr = TRUE + ) +cropOtherLr <- setNames(dimSums(carea[, , c("begr", "betr"), invert = TRUE], dim = 3), "crop_other") +cropBELr <- setNames(dimSums(carea[, , c("begr", "betr")], dim = 3), "crop_2G_bioen") + + +careaShr <- mbind(cropOtherLr, cropBELr) / (dimSums(carea, dim = 3) + 10^-10) +careaShrHr <- madrat::toolAggregate(careaShr, mapFile, to = "cell") + + +careaHr <- careaShrHr * setNames(landHr[, , "crop"], NULL) + + +# ---------------------- +# Grassland class +# ---------------------- + +# Grassland share +grassHr <- setNames(landHr[, , "past"], "grass") + +# ----------------------------------- +# Recovered land +# ----------------------------------- + +# unmanaged land recovered after 2020 needs to be +# distributed among restored and abandoned land +landRecovrdHr <- landHr[,,c("primforest", "secdforest", "other")] - setYears(landHr[, "y2020", c("primforest", "secdforest", "other")], NULL) +landRecovrdHr[landRecovrdHr < 0] <- 0 +# only consider recovered land after 2015 +landRecovrdHr[, seq(1995, 2015, 5), ] <- 0 + +# for restoration only consider unmanaged vegetation classes +landConsvHr <- landConsvHr[, , c("primforest", "secdforest", "other")] +# only consider land conservation after 2015 +landConsvHr[, seq(1995, 2015, 5), ] <- 0 + +# subtract restoration area from remaining unmanaged vegetation +landRestorHr <- pmin(landConsvHr, landRecovrdHr[, , c("primforest", "secdforest", "other")]) +# Restored land +landRestorHr <- setNames(dimSums(landRestorHr, dim = 3), "rest") + +# +landUnmgdHr <- landHr[, , c("primforest", "secdforest", "other")] - landRecovrdHr + + +# ---------------------- +# Forest classes +# ---------------------- + +forestHr <- setNames(dimSums(landUnmgdHr[, , c("primforest", "secdforest")], dim = 3), "forest_unmanaged") +forestryHr <- setNames(dimSums(landHr[, , "forestry"], dim = 3), "forest_managed") + +# ---------------------- +# Non-forest land +# ---------------------- + +otherHr <- setNames(landUnmgdHr[, , "other"], "other") + +# ---------------------- +# Urban land +# ---------------------- + +urbanHr <- setNames(landHr[, , "urban"], "built_up_areas") + +# ---------------------- +# Abandonend land +# ---------------------- + +landAbnHr <- setNames(dimSums(landRecovrdHr, dim = 3) - landRestorHr, "abn_land") + + +# ---------------------- +# Combine classes +# ---------------------- + +landOut <- mbind( + careaHr, + grassHr, + forestHr, + forestryHr, + landRestorHr, + otherHr, + urbanHr, + landAbnHr +) + +landOutShr <- landOut / dimSums(landOut, dim = 3) +landOutShr <- toolConditionalReplace(landOutShr, "is.na()") + +landArea <- dimSums(landOut, dim = 3) + +# ----------------------------------- +# Write NetCDF in requested format +# ----------------------------------- + +# create dimensions +lon <- seq(-179.75, 179.75, by = 0.5) +lat <- -seq(-89.75, 89.75, by = 0.5) +time <- as.numeric(sub("y","",getYears(landOutShr))) +lcClass <- 1:9 +dimLon <- ncdf4::ncdim_def("lon", "degrees_east",lon) +dimLat <- ncdf4::ncdim_def("lat", "degrees_north",lat) +dimTime <- ncdf4::ncdim_def("time", "years", calendar="standard",time,unlim=TRUE) +dimLandClass <- ncdf4::ncdim_def("lc_class", "1=cropland_other/2=cropland_2Gbioen/3=grassland/4=forest_unmanaged/5=forest_managed/6=restored/7=other/8=built-up/9=abn_land",lcClass) + +# create variables +fillvalue <- NaN +varNameLandShr <- 'share of pixel occupied by various land covers' +LandCoverVar <- ncvar_def(name = "LC_area_share",units = "share of pixel area",longname = varNameLandShr,dim = list(dimLon,dimLat,dimLandClass,dimTime), missval=fillvalue,prec = "double",compression = 9) +varNameTotArea<- 'total area of the pixel' +totAreaVar <- ncvar_def(name = "pixel_area",units = "million ha", longname = varNameTotArea, + dim = list(dimLon,dimLat), missval=fillvalue, prec = "double",compression = 9) + +### Land cover share + +# create the empty data array for land cover share +LandCoverVarArray <- array(NA, dim = c(length(lon), length(lat), length(lcClass), length(time)),dimnames = list(lon, lat, lcClass, time)) + +# convert magclass object to array +landOutShr <- as.array(landOutShr) +landOutShr <- aperm(landOutShr, c(1,3,2)) + +coord <- toolGetMappingCoord2Country(pretty = TRUE) +for (i in 1:ncells(landOutShr)) { + LandCoverVarArray[which(coord[i, "lon"] == lon), which(coord[i, "lat"] == lat), , ] <- landOutShr[i, , , drop = FALSE] +} + +### Land area + +# create the empty data array for land area +totAreaVarArray <- array(NA, dim = c(length(lon), length(lat)), dimnames = list(lon, lat)) + +# convert magclass object to array +landArea <- as.array(landArea) +landArea <- aperm(landArea, c(1,3,2)) + +for (i in 1:ncells(landArea)) { + totAreaVarArray[which(coord[i, "lon"] == lon), which(coord[i, "lat"] == lat)] <- landArea[i, ,"y1995", drop = FALSE] +} + +# create & fill netcdf with two variables +ncnew <- nc_create(file.path(outputdir, paste0("BendingTheCurve2_LCproj_MAgPIE_",cfg$title,"_",suffix,".nc")), list(LandCoverVar,totAreaVar),force_v4=TRUE) +ncvar_put(ncnew,totAreaVar,totAreaVarArray) +ncvar_put(ncnew,LandCoverVar,LandCoverVarArray) +# add attributes +ncatt_put(ncnew,0,"title",'MAgPIE land cover projections') +ncatt_put(ncnew,0,"scenario",cfg$title) +ncatt_put(ncnew,0,"institution",'PIK') +ncatt_put(ncnew,0,"contact","F. Humpenöder humpenoeder@pik-potsdam.de") +ncatt_put(ncnew,0,"history",date()) +# close +nc_close(ncnew) + + +# ----------------------------------------------------------- + + +library(luplot) + +plotmap2(landOutShr[, 2050, "rest"],legend_range = c(0,1)) + +plotmap2(dimSums(landOutShr, dim = 3)[, 2050,],legend_range = c(0,1)) + + +# a <- readGDX(gdx, "ov_lu_transitions", select = list(type = "level"), react = "silent") +# b <- dimSums(a[,,c("primforest.urban","secdforest.urban","other.urban")], c(1,3)) + +# d <- dimSums(landRestorHr, c(1,3)) + +# print(round(b+d,2)) + +# print(round(dimSums(.calcDiffLand(forestHr), c(1,3)),2)) + +# otherLandLr <- magpie4::OtherLand(gdx, level = "cell") + +# cropLr <- magpie4::land(gdx, level = "cell", types = "crop") +# dCrop <- -.calcDiffLand(cropLr) +# dCrop[dCrop < 0] <- 0 + + +# # grassland at cluster level +# grassLr <- magpie4::land(gdx, level = "cell", types = "past") +# careaShr + +# dOtherLand <- .calcDiffLand(dimSums(otherLandLr[,,c("other_recovered")],dim=3)) +# dOtherLand[dOtherLand < 0] <- 0 +# print(dimSums(dOtherLand, dim = c(1,3), na.rm = TRUE)) +# print(dimSums((dCrop+dgrass),dim=c(1,3))) + +# print(dimSums(dOtherLand, dim = c(1,3), na.rm = TRUE)) +# print(dimSums(dcropOther, dim = c(1,3), na.rm = TRUE)) +# print(dimSums(dcropBE, dim = c(1,3), na.rm = TRUE)) +# print(dimSums(dgrass, dim = c(1,3), na.rm = TRUE)) + +# print(dimSums(dCrop, dim = c(1,3), na.rm = TRUE)) + +# # derive reduction of cropland and grassland pools over time +# dcropOther <- -.calcDiffLand(cropOtherLr) +# dcropOther[dcropOther < 0] <- 0 + +# dcropBE <- -.calcDiffLand(cropBELr) +# dcropBE[dcropBE < 0] <- 0 + +# dgrass <- -.calcDiffLand(grassLr) +# dgrass[dgrass < 0] <- 0 + +# summary(dimSums((dCrop+dgrass),dim=c(1,3))/dimSums(dOtherLand, dim = c(1,3))) +# print(dimSums((dCrop+dgrass),dim=c(1,3))/dimSums(dOtherLand, dim = c(1,3))) + + +# # calculate share of recovered other land in total other land +# otherLandRecShr <- otherLandLr[, , "other_recovered"] / dimSums(otherLandLr[, , c("other_initial", "other_recovered")], dim = 3) +# otherLandRecShr[is.na(otherLandRecShr)] <- 0 + + + +# # other land expansion due to abandonment of cropland and grassland +# # restoration area has already been subtracted from other land +# dOtherLand <- -.calcDiffLand(landUnmgdShr[, , "other"]) +# dOtherLand[dOtherLand < 0] <- 0 + +# print(dimSums(dOtherLand, dim = c(1,3), na.rm = TRUE)) + + +# # derive reduction of cropland and grassland pools over time +# dcropOther <- -.calcDiffLand(cropOtherShr) +# dcropOther[dcropOther < 0] <- 0 + +# dcropBE <- -.calcDiffLand(cropBEShr) +# dcropBE[dcropBE < 0] <- 0 + +# dgrass <- -.calcDiffLand(grassShr) +# dgrass[dgrass < 0] <- 0 + + +# summary((dcropOther+dcropBE+dgrass)/dOtherLand) + +# # ---------------------- +# # Other land class +# # ---------------------- + + + +# otherShr <- setNames(landUnmgdShr[, , c("other")], "other") diff --git a/scripts/output/projects/EU_report.R b/scripts/output/projects/EU_report.R new file mode 100644 index 0000000000..0eec8d917d --- /dev/null +++ b/scripts/output/projects/EU_report.R @@ -0,0 +1,3 @@ +readArgs("outputdir") +rmarkdown::render("./scripts/output/projects/EU_report.Rmd", + output_dir = outputdir) diff --git a/scripts/output/projects/EU_report.Rmd b/scripts/output/projects/EU_report.Rmd new file mode 100644 index 0000000000..3037e1706f --- /dev/null +++ b/scripts/output/projects/EU_report.Rmd @@ -0,0 +1,251 @@ +--- +title: "Compare EU results with LUH Data" +output: + html_document: + df_print: paged + code_folding: hide +--- + + + + +This output report validates spatial pattern of the EU regions against LUH2v2 data. + +# Setup data and plot functions +```{r, setup, include=FALSE} +knitr::opts_knit$set(root.dir = dirname(dirname(dirname(getwd())))) +``` + +```{r load-libraries, echo = T, results = 'hide', message=FALSE, warning=FALSE} +# setup working dir and packages, read outputdir +readArgs("outputdir") +library(madrat) +library(mrcommons) +library(magpie4) + +library(ggplot2) +library(plotly) +library(gridExtra) +library(patchwork) + +library(dplyr) +library(tidyr) +library(stringr) +``` + +```{r} +print(paste0("Script started for output directory: ", outputdir)) +``` + +```{r read-data, echo = T, results = 'hide', message = FALSE, warning = FALSE} +compareYears <- c(1995, 2000, 2005, 2010) +# ----- Read and process model output and luh2v2 data; then bind data to a validation object ----- +# load and process reference data to match with model data +luh2v2 <- calcOutput("LanduseInitialisation", aggregate = FALSE, cellular = TRUE, + nclasses = "seven", cells = "lpjmlcell") +luh2v2 <- luh2v2[, compareYears, ] +# add subdimension for reference data +getNames(luh2v2) <- paste0(getNames(luh2v2), ".ref") + +# load and process model data to match with reference data +path2landoutput <- file.path(outputdir, "cell.land_0.5.mz") +cellLand <- read.magpie(path2landoutput) +cellLand <- cellLand[, compareYears, ] +# add subdimension for model data +getNames(cellLand) <- paste0(getNames(cellLand), ".mod") +load(file.path(outputdir, "spatial_header.rda")) + +# bind model and reference data +validationObj <- mbind(cellLand, luh2v2) + +# get EU countries +mapping <- toolGetMapping("regionmappingH12.csv") +countriesEU <- mapping$CountryCode[mapping$RegionCode == "EUR"] +``` + +```{r, load-plot-functions, echo = T, results = 'hide'} +# ----- Create a plotting functions ----- +# helper function to convert magclass obj to wide dataframe +convertToWideDataframe <- function(magclassObj) { + as.data.frame(magclassObj) %>% + pivot_wider(names_from = "Data2", values_from = "Value") +} + +# helper function to subset all cluster of a country +subsetCountryCluster <- function(magclassObj, countries) { + magclassObj[intersect(countries, getItems(magclassObj, split=TRUE)[[1]][[1]]), , ] +} + +# function combines a scatter plot with maps such that facets are aligned +plotCombined <- function(validationObj) { + # create the plots + p1 <- plotScatter(validationObj) + p2 <- plotMaps(validationObj) + + # combine and align the plots using patchwork + combinedPlot <- p1 / p2 + + # print the combined plot + print(combinedPlot) +} + +# create scatter plot for eu countries faceted by year +plotScatter <- function(validationObj) { + validationObj <- toolCoord2Isocell(validationObj, "lpjcell") + validationObj <- subsetCountryCluster(validationObj, countriesEU) + + # create quality measure dataframe with RMSE, MAE a.o. + qualityMeasuresDf <- NULL # list of dataframes, one for each year + numericYears <- as.numeric(gsub("y", "", getItems(validationObj, 2))) + for (year in numericYears) { + # get a vector with the quality measures + qualityMeasures <- luplot::qualityMeasure( + validationObj[, year, "mod"], validationObj[, year, "ref"], + measures = c("Willmott", "Willmott refined", "Nash Sutcliffe", "RMSE", "MAE") + ) + + # create text for the year facet + text <- "" + for (i in seq_along(qualityMeasures)) { + text <- paste0(text, stringr::str_trunc(names(qualityMeasures)[i], 12, ellipsis = "."), + " : ", qualityMeasures[i], "\n") + } + + # create dataframe for that year + qualityMeasuresDf[[year]] <- data.frame( + Year = year, + text = text + ) + } + qualityMeasBinded <- dplyr::bind_rows(qualityMeasuresDf) # bind all year dataframes + + # create the plot with facets + validationDF <- convertToWideDataframe(validationObj) + + p <- ggplot(validationDF, + aes(x = mod, y = ref, reg = Region, cell = Cell, relativeErr = (mod - ref) / ref)) + + geom_point(size = 0.5) + + geom_abline(color = "#663939", size = 1.5) + + facet_wrap(~ Year, scales = "free", ncol = 4) + # Create facets based on 'Year' + labs(x = "MAgPIE output", y = "luh2v2") + + theme(panel.background = element_rect(fill = "gray55"), + panel.grid.major = element_line(color = "gray62"), + panel.grid.minor = element_line(color = "grey58")) + + # add quality measure text + p <- p + geom_text(x = 0, y = Inf, aes(label = text), color = "#ffb5b5", # bright color contrasting dark background + hjust = 0, vjust = 1.1, nudge_x = 10, size = 2.6, family = "sans", fontface = "bold", + data = qualityMeasBinded, inherit.aes = FALSE) + + return(p) +} + +# create EU maps faceted by year +plotMaps <- function(validationObj) { + # create a ggplot object using luplot + relErr <- (validationObj[, , paste0("mod")] - validationObj[, , paste0("ref")]) / + (validationObj[, , paste0("ref")]) + + p <- luplot::plotmap2(relErr, + legend_range = c(-2, 2), legendname = "relative\n diff \n to \n LUH2v2", ncol = 4, + midcol = "#ffffff", lowcol = "blue", highcol = "red", midpoint = 0, + title = "" + ) + + # adjust the plot + p <- p + coord_sf(xlim = c(-10, 40), ylim = c(35, 70)) + facet_wrap(~ Year, ncol = 4) + + theme(aspect.ratio = 1, legend.title = element_text(size = 8)) + + p <- p + guides(fill = guide_colorbar(barheight = 5, barwidth = 0.2)) + return(p) +} + +# create an interactive scatterplot for eu countries of a year +plotInteractiveSub <- function(validationObj, year) { + p <- plotScatter(validationObj[, year, ]) + p <- p + ggtitle(paste0("EU Countries ", year)) + p <- plotly::ggplotly(p) + return(p) +} +``` + +# Plot data + +## crop +```{r crop,message=FALSE, warning=FALSE, out.width="100%"} +type <- "crop" +plotCombined(validationObj[, , type]) +``` + +```{r crop2, message=FALSE, warning=FALSE, fig.align="center"} +plotInteractiveSub(validationObj[, , type], 2010) +``` + +## pasture +```{r past,message=FALSE, warning=FALSE, out.width="100%"} +type <- "past" +plotCombined(validationObj[, , type]) +``` + +```{r past2, message=FALSE, warning=FALSE, fig.align="center"} +plotInteractiveSub(validationObj[, , type], 2010) +``` + +## forestry +```{r forestry,message=FALSE, warning=FALSE, out.width="100%"} +type <- "forestry" +plotCombined(validationObj[, , type]) +``` + +```{r forestry2, message=FALSE, warning=FALSE, fig.align="center"} +plotInteractiveSub(validationObj[, , type], 2010) +``` + +## primforest +```{r primforest,message=FALSE, warning=FALSE, out.width="100%"} +type <- "primforest" +plotCombined(validationObj[, , type]) +``` + +```{r primforest2, message=FALSE, warning=FALSE, fig.align="center"} +plotInteractiveSub(validationObj[, , type], 2010) +``` + +## secdforest +```{r secdforest,message=FALSE, warning=FALSE, out.width="100%"} +type <- "secdforest" +plotCombined(validationObj[, , type]) +``` + +```{r secdforest2, message=FALSE, warning=FALSE, fig.align="center"} +plotInteractiveSub(validationObj[, , type], 2010) +``` + +## urban + +```{r urban,message=FALSE, warning=FALSE, out.width="100%"} +type <- "urban" +plotCombined(validationObj[, , type]) +``` + +```{r urban2, message=FALSE, warning=FALSE, fig.align="center"} +plotInteractiveSub(validationObj[, , type], 2010) +``` + +## other +```{r other, message=FALSE, warning=FALSE, out.width="100%"} +type <- "other" +plotCombined(validationObj[, , type]) +``` + +```{r other2, message=FALSE, warning=FALSE, fig.align="center"} +plotInteractiveSub(validationObj[, , type], 2010) +``` diff --git a/scripts/output/projects/FABLE_India_subnational_validation.R b/scripts/output/projects/FABLE_India_subnational_validation.R new file mode 100644 index 0000000000..2d5c507c1d --- /dev/null +++ b/scripts/output/projects/FABLE_India_subnational_validation.R @@ -0,0 +1,104 @@ +# | (C) 2008-2025 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: India subnational validation +# comparison script: FALSE +# --------------------------------------------------------------- + +#Version 1.00 - Miodrag Stevanovic, Prantika Das +# 1.00: first working version + +library(lucode2) +library(magpie4) +library(madrat) +library(mrfable) +library(mip) +library(mrvalidation) +library(magpiesets) +library(lusweave) + +print("Start India state level validation output runscript") + +############################# BASIC CONFIGURATION ####################################### + +if(!exists("source_include")) { + + outputdir <- "output/v4p77/h12_2022-12-15_22.09.46" + + ###Define arguments that can be read from command line + readArgs("outputdir") +} +file <- file.path(outputdir,paste0("India_subnational_validation_",format(Sys.time(), "%Y%H%M%S"),".pdf")) +######################################################################################### + +print(paste0("Script started for output directory: ",outputdir)) + +# Determine cells for India +mapping <- toolGetMapping("scripts/npi_ndc/policies/country2cell.rds") +mapping$iso_mag <- paste(mapping$iso,mapping$cell,sep=".") +# load Indian states +indStates <- toolGetMapping(system.file("extdata", "regional/india_state_code.csv", package = "mrfable")) +indCells <- which(mapping$ind %in% indStates$State_code) + +# Subnational validation data of specific crops +landHr <- read.magpie(file.path(outputdir,"cell.land_0.5.mz"))[indCells,,] +cropareaHrShare <- read.magpie(file.path(outputdir,"cell.croparea_0.5_share.mz"))[indCells,,] +cellHr <- dimSums(landHr, dim=3) +cropareaHr <- cropareaHrShare[,,]*setItems(cell_hr[,1,], dim=2, NULL) +cropareaHr <- dimSums(cropareaHr, dim=3.2) + +# aggregate land from grid to state level +mappingInd <- mapping[indCells,] +cropareaState <- toolAggregate(cropareaHr, rel=mappingInd, from="iso_mag", to="ind") + +# Observed data from mrfable +setConfig(extramappings = "mappingIndiaAPY.csv") +indApyMapping <- toolGetMapping(system.file("extdata", "regional/mappingIndiaAPY.csv", package = "mrfable")) +h <- calcOutput("IndiaFoodcrop", subtype = "Area", aggregate = "Region") +# Data cleaning: +h <- h[indStates$State_code,,] +h <- collapseNames(h) +h <- collapseNames(h[,,"total"]) +h <- h/1000 +# Crops in the APY database: +mappingCropsAPY <- as.matrix(data.frame(APYcrop=c("Bajra", "Barley", "Gram", + "Jowar", "Tur", "Maize", + "Wheat", "Ragi", "Rice"), + k=c("trce", "tece", "puls_pro", + "trce", "puls_pro", "maiz", + "tece", "trce", "rice_pro"))) +# Aggregate to magpie crops: +h <- toolAggregate(h, rel=mappingCropsAPY, from="APYcrop", to="k", dim=3) +h <- add_dimension(h, dim=3.1, add="scenario", nm="historical") +h <- add_dimension(h, dim=3.2, add="model", nm="APY") +h <- setItems(h, dim=3.3, reportingnames(getItems(h,dim=3.3))) + +cropareaState <- cropareaState[,,unique(mappingCropsAPY[,"k"])] +names(dimnames(cropareaState)) <- c("state","year","crop") +cropareaState <- add_dimension(cropareaState, dim=3.1, add="scenario", nm="") +cropareaState <- add_dimension(cropareaState, dim=3.2, add="model", nm="MAgPIE") +cropareaState <- setItems(cropareaState, dim=3.3, reportingnames(getItems(cropareaState,dim=3.3))) + +sw <- swopen(file) +swlatex(sw,"\\huge") +swlatex(sw,"\\textbf{MAgPIE state level croparea comparison for India}\\newline") +swlatex(sw,"\\normalsize") +swlatex(sw,"\\newline") +swlatex(sw,"\\tableofcontents") + +for(k in getItems(h, dim=3.3)){ + for(state in getItems(h, dim=1)){ + swlatex(sw,"\\newpage") + swlatex(sw,paste0("\\section{Croparea ",k," in ",indStates[which(indStates$State_code==state),"State_name"],"}")) + swfigure(sw, print, mipLineHistorical(cropareaState[state,,k],h[state,,k],ylab="Mha")) + } +} + +swclose(sw,clean_output=TRUE) + + diff --git a/scripts/output/projects/FSDP_collect.R b/scripts/output/projects/FSDP_collect.R new file mode 100644 index 0000000000..4ff1bf25a4 --- /dev/null +++ b/scripts/output/projects/FSDP_collect.R @@ -0,0 +1,871 @@ +# | (C) 2008-2025 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: Collect reg, iso and grid level data from multiple FSDP runs (requires LR or HR runs) +# comparison script: TRUE +# --------------------------------------------------------------- + +# Version 1.0, Florian Humpenoeder + +library(lucode2) +library(magclass) +library(gms) +library(magpiesets) +library(data.table) +library(gdx2) +library(quitte) +library(m4fsdp) +library(stringr) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/", list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### + +# For case of sub-folder structure write to the respective folder +title <- basename(outputdir) + +# Select runs to be displayed +x <- unlist(lapply(strsplit(basename(outputdir), "_"), function(x) x[2])) +outputdir <- outputdir[which(x %in% c("FSECa", "FSECb", "FSECc", "FSECd", "FSECe"))] + +# Get revision number +x <- unlist(lapply(strsplit(basename(outputdir), "_"), function(x) x[1])) +if (length(unique(x)) == 1) rev <- unique(x) else stop("version prefix is not identical. Check your selection of runs") + +########## +# Append health impacts reports +hi_datasets_path <- "/p/projects/magpie/data/FSEC_healthImpactsDatasets_raw" +if (dir.exists(hi_datasets_path)) { + + hi_datasets <- list.files(hi_datasets_path) + hi_versionToUse <- grep(rev, hi_datasets, value = TRUE) + + if (length(hi_versionToUse) == 0) { + + message("No corresponding version ID was found within the health impacts datasets. Using the latest available.") + + highestVersionNr <- max(as.numeric(str_extract(hi_datasets, "(?<=v)(.*?)(?=_)"))) + hi_versionToUse <- grep(paste0("v", highestVersionNr), hi_datasets, value = TRUE) + + } else if (length(hi_versionToUse) >= 2) { + stop("Duplicated version IDs were found in the health impacts datasets, only one is expected.") + } + + hi_versionToUse_path <- file.path(hi_datasets_path, hi_versionToUse) + hi_gdx <- suppressWarnings(readGDX(hi_versionToUse_path)) + + .appendHealthImpacts <- function(.x) { + cfg <- gms::loadConfig(file.path(.x, "config.yml")) + title <- cfg$title + + message("Appending health impact report: ", title) + tryCatch( + expr = { + appendReportHealthImpacts(healthImpacts_gdx = hi_gdx, scenario = title, dir = .x) + }, error = function(e) { + message("Unable to append health impacts for scenario: ", title, ". Likely it is non-dietary.") + } + ) + } + lapply(X = outputdir, FUN = .appendHealthImpacts) + +} else { + message("The directory storing health impacts datasets wasn't found. Skipping health impacts.") +} + +magicc7_datasets_path <- "/p/projects/magpie/data/FSEC_magicc7Datasets_raw" +if (dir.exists(magicc7_datasets_path)) { + + magicc7_datasets <- list.files(magicc7_datasets_path) + magicc7_versionToUse <- grep(rev, magicc7_datasets, value = TRUE) + + if (length(magicc7_versionToUse) == 0) { + + message("No corresponding version ID was found within the MAGICC7 datasets. Using the latest available.") + + highestVersionNr <- max(as.numeric(str_extract(magicc7_datasets, "(?<=v)(.*?)(?=_)"))) + magicc7_versionToUse <- grep(paste0("v", highestVersionNr), magicc7_datasets, value = TRUE) + + } else if (length(magicc7_versionToUse) >= 2) { + stop("Duplicated version IDs were found in the MAGICC7 datasets, only one is expected.") + } + + magicc7_versionToUse_path <- file.path(magicc7_datasets_path, magicc7_versionToUse) + + .appendMAGICC7 <- function(.x) { + cfg <- gms::loadConfig(file.path(.x, "config.yml")) + title <- cfg$title + + tryCatch( + expr = { + appendReportMAGICC7(resultsPath = magicc7_versionToUse_path, scenario = title, dir = .x) + }, error = function(e) { + message("Unable to append MAGICC7 dataset for scenario: ", title) + } + ) + } + lapply(X = outputdir, FUN = .appendMAGICC7) + +} else { + message("The directory storing MAGICC7 datasets wasn't found. Skipping AR6 global warming calculations.") +} + + +########## +# Generate output files +cat("\nStarting output generation\n") + +reg <- NULL +iso <- NULL +grid <- NULL +missing <- NULL + +saveRDS(outputdir,"outputdir.rds") + +indicators_main <- getVariables() +names(indicators_main) <- NULL +var_reg <- c(indicators_main, + ### Validation + "Biodiversity|Agricultural landscape intactness", + "Biodiversity|Biodiversity hotspot intactness", + "Biodiversity|BII in areas outside Biodiversity Hotspots, Intact Forest & Cropland Landscapes", + "Biodiversity|Biodiversity Hotspot and Intact Forest Landscapes BII", + "Biodiversity|Biodiversity Hotspot BII", + "Biodiversity|BII in 30x30 Landscapes", + "Biodiversity|Cropland Landscapes BII", + "Biodiversity|Key Biodiversity Area BII", + "Biodiversity|Inverted Simpson crop area diversity index", + "Population", + "Income", + "Nutrition|Calorie Supply|+|Crops", + "Nutrition|Calorie Supply|+|Livestock products", + "Demand|++|Crops", + "Demand|Food|+|Crops", + "Demand|Feed|+|Crops", + "Demand|Feed|+|Pasture", + "Demand|Feed|+|Secondary products", + "Demand|Feed|+|Crop residues", + "Demand|Seed|+|Crops", + "Demand|Material|+|Crops", + "Demand|Processing|+|Crops", + "Demand|++|Livestock products", + "Production|+|Crops", + "Production|Crops|+|Cereals", + "Production|Crops|+|Oil crops", + "Production|Crops|+|Sugar crops", + "Production|Crops|Other crops|+|Fruits Vegetables Nuts", + "Production|+|Livestock products", + "Production|+|Secondary products", + "Production|+|Pasture", + "Production|+|Bioenergy crops", + "Timber|Volumetric|Production|Roundwood", + "Resources|Land Cover", + "Resources|Land Cover|+|Cropland", + "Resources|Land Cover|+|Pastures and Rangelands", + "Resources|Land Cover|+|Forest", + "Resources|Land Cover|Forest|+|Managed Forest", + "Resources|Land Cover|Forest|Natural Forest|+|Primary Forest", + "Resources|Land Cover|Forest|Natural Forest|+|Secondary Forest", + "Resources|Land Cover|+|Other Land", + "Resources|Land Cover|+|Urban Area", + "Resources|Land Cover|Cropland|+|Croparea", + "Resources|Land Cover|Cropland|+|Fallow Cropland", + "Resources|Land Cover|Cropland|Croparea|Crops|+|Cereals", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Maize", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Rice", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Temperate cereals", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Tropical cereals", + "Resources|Land Cover|Cropland|Croparea|Crops|+|Oil crops", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Cotton seed", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Groundnuts", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Oilpalms", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Soybean", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Sunflower", + "Resources|Land Cover|Cropland|Croparea|Crops|+|Sugar crops", + "Resources|Land Cover|Cropland|Croparea|Crops|Sugar crops|+|Sugar beet", + "Resources|Land Cover|Cropland|Croparea|Crops|Sugar crops|+|Sugar cane", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Fruits Vegetables Nuts", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Potatoes", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Pulses", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Tropical roots", + "Resources|Land Cover|Cropland|Croparea|+|Bioenergy crops", + "Productivity|Landuse Intensity Indicator Tau", + "Productivity|Feed conversion", + "Productivity|Feed conversion|Ruminant meat and dairy", + "Productivity|Feed conversion|Poultry meat and eggs", + "Productivity|Feed conversion|Monogastric meat", + "Productivity|Feed conversion|+|Cereal Intensity", + "Productivity|Feed conversion|+|Oilcrop intensity", + "Productivity|Feed conversion|+|Pasture intensity", + "Productivity|Roughage share|Ruminant meat and dairy", + "Productivity|Pasture share|Ruminant meat and dairy", + "Productivity|Yield by physical area|Crops", + "Productivity|Yield by physical area|Crops|Cereals", + "Productivity|Yield by physical area|Crops|Oil crops", + "Productivity|Yield by physical area|Crops|Sugar crops", + "Productivity|Yield by physical area|Crops|Other crops", + "Productivity|Yield by physical area|Crops|Other crops|Fruits Vegetables Nuts", + "Productivity|Yield by physical area|Pasture", + "Productivity|Yield by physical area|Bioenergy crops", + "Productivity|Yield by physical area|Forage", + "Resources|Nitrogen|Cropland Budget|Inputs", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Fertilizer", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Biological Fixation Symbiotic Crops", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Manure Recycled from Confinements", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Recycled Aboveground Crop Residues", + "Resources|Nitrogen|Cropland Budget|Withdrawals|+|Harvested Crops", + "Resources|Nitrogen|Cropland Budget|Withdrawals|+|Aboveground Crop Residues", + "Resources|Nitrogen|Cropland Budget|Balance|+|Nutrient Surplus", + "Resources|Nitrogen|Cropland Budget|Balance|+|Soil Organic Matter", + "Resources|Nitrogen|Pollution|Surplus|+|Cropland", + "Resources|Nitrogen|Pollution|Surplus|+|Pasture", + "Resources|Nitrogen|Pollution|Surplus|+|Animal Waste Management", + "Resources|Nitrogen|Pollution|Surplus|+|Non-agricultural land", + "Resources|Water|Withdrawal|Agriculture", + "Resources|Land Cover|Cropland|Area equipped for irrigation", + "Value|Bioeconomy Demand", + "Production|Bioenergy|2nd generation|++|Bioenergy crops", + ### Maps + "Costs", + "Population", + "Labor|Employment|Share of working age population employed in agriculture", + "Labor|Wages|Hourly labor costs", + ### Suppl plots + "Population", + "Prices|Index2020|Agriculture|Food products", + "Prices|Index2020|Agriculture|Food products|Livestock", + "Prices|Index2020|Agriculture|Food products|Plant-based", + "SDG|SDG02|Investment in AgR&D", + "Household Expenditure|Food|Expenditure|Crops", + "Household Expenditure|Food|Expenditure|Crops|Cereals", + "Household Expenditure|Food|Expenditure|Crops|Oil crops", + "Household Expenditure|Food|Expenditure|Crops|Other crops", + "Household Expenditure|Food|Expenditure|Crops|Sugar crops", + "Household Expenditure|Food|Expenditure|Fish", + "Household Expenditure|Food|Expenditure|Livestock products", + "Household Expenditure|Food|Expenditure|Secondary products", + "Household Expenditure|Food|Food Expenditure Share", + "SDG|SDG02|Food expenditure share", + "Value|Agriculture GDP", + "Costs|TC", + "Agricultural Research Intensity", + "Nutrition|Calorie Intake", + "Nutrition|Calorie Intake|+|Crops", + "Nutrition|Calorie Intake|+|Fish", + "Nutrition|Calorie Intake|+|Livestock products", + "Nutrition|Calorie Intake|+|Secondary products", + "Nutrition|Calorie Intake|Crops|+|Cereals", + "Nutrition|Calorie Intake|Crops|+|Oil crops", + "Nutrition|Calorie Intake|Crops|+|Other crops", + "Nutrition|Calorie Intake|Crops|+|Sugar crops", + "Nutrition|Calorie Intake|Crops|Cereals|+|Maize", + "Nutrition|Calorie Intake|Crops|Cereals|+|Rice", + "Nutrition|Calorie Intake|Crops|Cereals|+|Temperate cereals", + "Nutrition|Calorie Intake|Crops|Cereals|+|Tropical cereals", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Groundnuts", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Soybean", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Sunflower", + "Nutrition|Calorie Intake|Crops|Other crops|+|Fruits Vegetables Nuts", + "Nutrition|Calorie Intake|Crops|Other crops|+|Potatoes", + "Nutrition|Calorie Intake|Crops|Other crops|+|Pulses", + "Nutrition|Calorie Intake|Crops|Other crops|+|Tropical roots", + "Nutrition|Calorie Intake|Crops|Sugar crops|+|Sugar beet", + "Nutrition|Calorie Intake|Crops|Sugar crops|+|Sugar cane", + "Nutrition|Calorie Intake|Livestock products|+|Dairy", + "Nutrition|Calorie Intake|Livestock products|+|Eggs", + "Nutrition|Calorie Intake|Livestock products|+|Monogastric meat", + "Nutrition|Calorie Intake|Livestock products|+|Poultry meat", + "Nutrition|Calorie Intake|Livestock products|+|Ruminant meat", + "Nutrition|Calorie Intake|Secondary products|+|Alcoholic beverages", + "Nutrition|Calorie Intake|Secondary products|+|Brans", + "Nutrition|Calorie Intake|Secondary products|+|Molasses", + "Nutrition|Calorie Intake|Secondary products|+|Oils", + "Nutrition|Calorie Intake|Secondary products|+|Sugar", + "Nutrition|Calorie Supply", + "Nutrition|Calorie Supply|+|Crops", + "Nutrition|Calorie Supply|+|Fish", + "Nutrition|Calorie Supply|+|Livestock products", + "Nutrition|Calorie Supply|+|Secondary products", + "Nutrition|Calorie Supply|Crops|+|Cereals", + "Nutrition|Calorie Supply|Crops|+|Oil crops", + "Nutrition|Calorie Supply|Crops|+|Other crops", + "Nutrition|Calorie Supply|Crops|+|Sugar crops", + "Nutrition|Calorie Supply|Crops|Cereals|+|Maize", + "Nutrition|Calorie Supply|Crops|Cereals|+|Rice", + "Nutrition|Calorie Supply|Crops|Cereals|+|Temperate cereals", + "Nutrition|Calorie Supply|Crops|Cereals|+|Tropical cereals", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Groundnuts", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Soybean", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Sunflower", + "Nutrition|Calorie Supply|Crops|Other crops|+|Fruits Vegetables Nuts", + "Nutrition|Calorie Supply|Crops|Other crops|+|Potatoes", + "Nutrition|Calorie Supply|Crops|Other crops|+|Pulses", + "Nutrition|Calorie Supply|Crops|Other crops|+|Tropical roots", + "Nutrition|Calorie Supply|Crops|Sugar crops|+|Sugar beet", + "Nutrition|Calorie Supply|Crops|Sugar crops|+|Sugar cane", + "Nutrition|Calorie Supply|Livestock products|+|Dairy", + "Nutrition|Calorie Supply|Livestock products|+|Eggs", + "Nutrition|Calorie Supply|Livestock products|+|Monogastric meat", + "Nutrition|Calorie Supply|Livestock products|+|Poultry meat", + "Nutrition|Calorie Supply|Livestock products|+|Ruminant meat", + "Nutrition|Calorie Supply|Secondary products|+|Alcoholic beverages", + "Nutrition|Calorie Supply|Secondary products|+|Brans", + "Nutrition|Calorie Supply|Secondary products|+|Molasses", + "Nutrition|Calorie Supply|Secondary products|+|Oils", + "Nutrition|Calorie Supply|Secondary products|+|Sugar", + "Demand|+|Agricultural Supply Chain Loss", + "Demand|+|Bioenergy", + "Demand|+|Feed", + "Demand|+|Food", + "Demand|+|Material", + "Demand|+|Processing", + "Demand|+|Seed", + "Demand|+|Roundwood", + "Demand|+|Domestic Balanceflow", + "Trade|+|Net-Trade", + "Trade|Net-Trade|+|Crops", + "Trade|Net-Trade|+|Fish", + "Trade|Net-Trade|+|Forest products", + "Trade|Net-Trade|+|Livestock products", + "Trade|Net-Trade|+|Secondary products", + "Trade|Net-Trade|Crops|+|Cereals", + "Trade|Net-Trade|Crops|+|Oil crops", + "Trade|Net-Trade|Crops|+|Other crops", + "Trade|Net-Trade|Crops|+|Sugar crops", + "Trade|Net-Trade|Crops|Cereals|+|Maize", + "Trade|Net-Trade|Crops|Cereals|+|Rice", + "Trade|Net-Trade|Crops|Cereals|+|Temperate cereals", + "Trade|Net-Trade|Crops|Cereals|+|Tropical cereals", + "Trade|Net-Trade|Crops|Oil crops|+|Cotton seed", + "Trade|Net-Trade|Crops|Oil crops|+|Groundnuts", + "Trade|Net-Trade|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Trade|Net-Trade|Crops|Oil crops|+|Soybean", + "Trade|Net-Trade|Crops|Oil crops|+|Sunflower", + "Trade|Net-Trade|Crops|Other crops|+|Fruits Vegetables Nuts", + "Trade|Net-Trade|Crops|Other crops|+|Potatoes", + "Trade|Net-Trade|Crops|Other crops|+|Pulses", + "Trade|Net-Trade|Crops|Other crops|+|Tropical roots", + "Trade|Net-Trade|Crops|Sugar crops|+|Sugar beet", + "Trade|Net-Trade|Crops|Sugar crops|+|Sugar cane", + "Trade|Net-Trade|Forest products|+|Industrial roundwood", + "Trade|Net-Trade|Forest products|+|Wood fuel", + "Trade|Net-Trade|Livestock products|+|Dairy", + "Trade|Net-Trade|Livestock products|+|Eggs", + "Trade|Net-Trade|Livestock products|+|Monogastric meat", + "Trade|Net-Trade|Livestock products|+|Poultry meat", + "Trade|Net-Trade|Livestock products|+|Ruminant meat", + "Trade|Net-Trade|Secondary products|+|Sugar", + "Trade|Self-sufficiency|Crops|Cereals", + "Trade|Self-sufficiency|Crops|Cereals|Maize", + "Trade|Self-sufficiency|Crops|Cereals|Rice", + "Trade|Self-sufficiency|Crops|Cereals|Temperate cereals", + "Trade|Self-sufficiency|Crops|Cereals|Tropical cereals", + "Trade|Self-sufficiency|Crops|Other crops", + "Trade|Self-sufficiency|Crops|Other crops|Fruits Vegetables Nuts", + "Trade|Self-sufficiency|Crops|Other crops|Potatoes", + "Trade|Self-sufficiency|Crops|Other crops|Pulses", + "Trade|Self-sufficiency|Crops|Other crops|Tropical roots", + "Trade|Self-sufficiency|Crops|Sugar crops|Sugar cane", + "Trade|Self-sufficiency|Fish", + "Trade|Self-sufficiency|Livestock products", + "Trade|Self-sufficiency|Livestock products|Dairy", + "Trade|Self-sufficiency|Livestock products|Eggs", + "Trade|Self-sufficiency|Livestock products|Monogastric meat", + "Trade|Self-sufficiency|Livestock products|Poultry meat", + "Trade|Self-sufficiency|Livestock products|Ruminant meat", + "Trade|Self-sufficiency|Secondary products", + "Trade|Self-sufficiency|Secondary products|Alcoholic beverages", + "Trade|Self-sufficiency|Secondary products|Brans", + "Trade|Self-sufficiency|Secondary products|Cotton lint", + "Trade|Self-sufficiency|Secondary products|Distillers grains", + "Trade|Self-sufficiency|Secondary products|Ethanol", + "Trade|Self-sufficiency|Secondary products|Microbial protein", + "Trade|Self-sufficiency|Secondary products|Molasses", + "Trade|Self-sufficiency|Secondary products|Oilcakes", + "Trade|Self-sufficiency|Secondary products|Oils", + "Trade|Self-sufficiency|Secondary products|Sugar", + "Emissions|CO2|Land|+|Land-use Change", + "Emissions|CH4|Land|+|Agriculture", + "Emissions|N2O|Land|+|Agriculture", + "Resources|Land Cover|+|Cropland", + "Resources|Land Cover|+|Pastures and Rangelands", + "Resources|Land Cover|Forest|Natural Forest|+|Primary Forest", + "Resources|Land Cover|Forest|Natural Forest|+|Secondary Forest", + "Resources|Land Cover|Forest|Managed Forest|+|Plantations", + "Resources|Land Cover|Forest|Managed Forest|+|NPI/NDC", + "Resources|Land Cover|Forest|Managed Forest|+|Afforestation", + "Resources|Land Cover|Cropland|+|Bioenergy crops", + "Resources|Land Cover|+|Other Land", + "Resources|Land Cover|+|Urban Area", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Maize", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Rice", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Temperate cereals", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Tropical cereals", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Cotton seed", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Groundnuts", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Oilpalms", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Soybean", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Sunflower", + "Resources|Land Cover|Cropland|Crops|Sugar crops|+|Sugar beet", + "Resources|Land Cover|Cropland|Crops|Sugar crops|+|Sugar cane", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Fruits Vegetables Nuts", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Potatoes", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Pulses", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Tropical roots", + "Resources|Land Cover|Cropland|Crops|Cereals|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Maize|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Maize|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|Rice|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Rice|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|Temperate cereals|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Temperate cereals|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|Tropical cereals|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Tropical cereals|rainfed", + "Resources|Land Cover|Cropland|Crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Groundnuts|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Groundnuts|rainfed", + "Resources|Land Cover|Cropland|Crops|Oil crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Other oil crops incl rapeseed|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Other oil crops incl rapeseed|rainfed", + "Resources|Land Cover|Cropland|Crops|Oil crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|Fruits Vegetables Nuts|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Fruits Vegetables Nuts|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Potatoes|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Potatoes|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|Pulses|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Pulses|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|Tropical roots|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Tropical roots|rainfed", + "Resources|Land Cover|Cropland|Crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Sugar crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Sugar crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar beet|irrigated", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar beet|rainfed", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar cane|irrigated", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar cane|rainfed", + "Resources|Land Cover|Cropland|Forage|irrigated", + "Resources|Land Cover|Cropland|Forage|rainfed", + "Resources|Land Cover|Cropland|+|Bioenergy crops", + "Resources|Land Cover|Cropland|+|Fallow Cropland", + + "SDG|SDG15|Biological nitrogen fixation on cropland", + "SDG|SDG15|Non-agricultural land share", + "SDG|SDG15|Other natural land share", + + "Resources|Nitrogen|Pollution|Surplus|+|Cropland", + "Resources|Nitrogen|Pollution|Surplus|+|Pasture", + "Resources|Nitrogen|Pollution|Surplus|+|Animal Waste Management", + "Resources|Nitrogen|Pollution|Surplus|+|Non-agricultural land", + "Resources|Water|Withdrawal|Agriculture", + + "Resources|Nitrogen|Cropland Budget|Soil Nitrogen Uptake Efficiency", + + "Emissions|CH4_GWP*AR6|Land", + "Emissions|CH4_GWP*AR6|Land|+|Agriculture", + "Emissions|CH4_GWP*AR6|Land|+|Biomass Burning", + "Emissions|CH4_GWP*AR6|Land|+|Peatland", + "Emissions|CH4_GWP*AR6|Land|Agriculture|+|Animal waste management", + "Emissions|CH4_GWP*AR6|Land|Agriculture|+|Enteric fermentation", + "Emissions|CH4_GWP*AR6|Land|Agriculture|+|Rice", + "Emissions|CH4_GWP*AR6|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|CH4_GWP*AR6|Land|Peatland|+|Managed", + "Emissions|CH4_GWP100AR6|Land", + "Emissions|CH4_GWP100AR6|Land|+|Agriculture", + "Emissions|CH4_GWP100AR6|Land|+|Biomass Burning", + "Emissions|CH4_GWP100AR6|Land|+|Peatland", + "Emissions|CH4_GWP100AR6|Land|Agriculture|+|Animal waste management", + "Emissions|CH4_GWP100AR6|Land|Agriculture|+|Enteric fermentation", + "Emissions|CH4_GWP100AR6|Land|Agriculture|+|Rice", + "Emissions|CH4_GWP100AR6|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|CH4_GWP100AR6|Land|Peatland|+|Managed", + "Emissions|CH4|Land", + "Emissions|CH4|Land|+|Agriculture", + "Emissions|CH4|Land|+|Biomass Burning", + "Emissions|CH4|Land|+|Peatland", + "Emissions|CH4|Land|Agriculture|+|Animal waste management", + "Emissions|CH4|Land|Agriculture|+|Enteric fermentation", + "Emissions|CH4|Land|Agriculture|+|Rice", + "Emissions|CH4|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|CH4|Land|Peatland|+|Managed", + "Emissions|CO2|Land", + "Emissions|CO2|Land RAW", + "Emissions|CO2|Land RAW|+|Indirect RAW", + "Emissions|CO2|Land RAW|+|Land-use Change RAW", + "Emissions|CO2|Land|+|Indirect", + "Emissions|CO2|Land|+|Land-use Change", + "Emissions|CO2|Land|Cumulative", + "Emissions|CO2|Land|Cumulative|+|Indirect", + "Emissions|CO2|Land|Cumulative|+|Land-use Change", + "Emissions|CO2|Land|Cumulative|Land-use Change|+|Gross LUC", + "Emissions|CO2|Land|Cumulative|Land-use Change|+|Peatland", + "Emissions|CO2|Land|Cumulative|Land-use Change|+|Regrowth", + "Emissions|CO2|Land|Cumulative|Land-use Change|Gross LUC|+|Forest Degradation", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|CO2-price AR", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|NPI_NDC AR", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|Other Land", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|Secondary Forest", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|Timber Plantations", + "Emissions|CO2|Land|Land-use Change|++|Above Ground Carbon", + "Emissions|CO2|Land|Land-use Change|++|Below Ground Carbon", + "Emissions|CO2|Land|Land-use Change|+|Gross LUC", + "Emissions|CO2|Land|Land-use Change|+|Peatland", + "Emissions|CO2|Land|Land-use Change|+|Regrowth", + "Emissions|CO2|Land|Land-use Change|Gross LUC|+|Forest Degradation", + "Emissions|CO2|Land|Land-use Change|Regrowth|CO2-price AR", + "Emissions|CO2|Land|Land-use Change|Regrowth|NPI_NDC AR", + "Emissions|CO2|Land|Land-use Change|Regrowth|Other Land", + "Emissions|CO2|Land|Land-use Change|Regrowth|Secondary Forest", + "Emissions|CO2|Land|Land-use Change|Regrowth|Timber Plantations", + "Emissions|GWP100AR6|Land", + "Emissions|GWP100AR6|Land|Cumulative", + "Emissions|N2O_GWP100AR6|Land", + "Emissions|N2O_GWP100AR6|Land|+|Agriculture", + "Emissions|N2O_GWP100AR6|Land|+|Biomass Burning", + "Emissions|N2O_GWP100AR6|Land|+|Peatland", + "Emissions|N2O_GWP100AR6|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O_GWP100AR6|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O_GWP100AR6|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O_GWP100AR6|Land|Peatland|+|Managed", + "Emissions|N2O|Direct|Land", + "Emissions|N2O|Direct|Land|+|Agriculture", + "Emissions|N2O|Direct|Land|+|Biomass Burning", + "Emissions|N2O|Direct|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O|Direct|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O|Direct|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O|Indirect|Land", + "Emissions|N2O|Indirect|Land|+|Agriculture", + "Emissions|N2O|Indirect|Land|+|Biomass Burning", + "Emissions|N2O|Indirect|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O|Indirect|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O|Indirect|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O|Land", + "Emissions|N2O|Land|+|Agriculture", + "Emissions|N2O|Land|+|Biomass Burning", + "Emissions|N2O|Land|+|Peatland", + "Emissions|N2O|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O|Land|Peatland|+|Managed", + "Emissions|NH3|Land", + "Emissions|NH3|Land|+|Agriculture", + "Emissions|NH3|Land|+|Biomass Burning", + "Emissions|NH3|Land|Agriculture|+|Agricultural Soils", + "Emissions|NH3|Land|Agriculture|+|Animal Waste Management", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|NH3|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|NO2|Land", + "Emissions|NO2|Land|+|Agriculture", + "Emissions|NO2|Land|+|Biomass Burning", + "Emissions|NO2|Land|Agriculture|+|Agricultural Soils", + "Emissions|NO2|Land|Agriculture|+|Animal Waste Management", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|NO2|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|NO3-|Land", + "Emissions|NO3-|Land|+|Agriculture", + "Emissions|NO3-|Land|+|Biomass Burning", + "Emissions|NO3-|Land|Agriculture|+|Agricultural Soils", + "Emissions|NO3-|Land|Agriculture|+|Animal Waste Management", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|NO3-|Land|Biomass Burning|+|Burning of Crop Residues", + + "SDG|SDG15|Afforestation", + + + "Nutrition|Anthropometrics|People normalweight", + "Nutrition|Anthropometrics|People obese", + "Nutrition|Anthropometrics|People overweight", + "Nutrition|Anthropometrics|People underweight", + "Labor|Employment|Agricultural employment", + "Labor|Employment|Agricultural employment|+|Crop products", + "Labor|Employment|Agricultural employment|+|Livestock products", + "Labor|Employment|Agricultural employment|+|MACCS", + "Labor|Wages|Hourly labor costs", + "Labor|Total Hours Worked", + "Income|Gini Coefficient", + "Income|Average Income of Lower 40% of Population", + "Income|Fraction of Population below half of Median Income", + "Income|Number of People Below 1p90 USDppp11/day", + "Income|Number of People Below 3p20 USDppp11/day", + "Income|Number of People Below 5p50 USDppp11/day", + "Health|Years of life lost|Disease", + "Health|Years of life lost|Disease|+|Congenital Heart Disease", + "Health|Years of life lost|Disease|+|Stroke", + "Health|Years of life lost|Disease|+|Cancer", + "Health|Years of life lost|Disease|+|Type-2 Diabetes", + "Health|Years of life lost|Disease|+|Respiratory Disease", + "Health|Attributable deaths|Disease" +) +var_reg <- unique(var_reg) + +var_iso <- c("Population", + "Health|Years of life lost|Disease", + "Labor|Employment|Agricultural employment", + "Nutrition|Anthropometrics|People underweight", + "Nutrition|Anthropometrics|People obese", + "Household Expenditure|Food|Expenditure", + "Income|Number of People Below 3p20 USDppp11/day", + "Income|Gini Coefficient") +var_iso <- unique(var_iso) + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + cfg <- gms::loadConfig(file.path(outputdir[i], "config.yml")) + + ### regional level outputs + rep <- file.path(outputdir[i], "report.rds") + if(file.exists(rep)) { + a <- as.data.table(readRDS(rep)) + a <- a[variable %in% var_reg,] + a <- droplevels(a) + reg <- rbind(reg, a) + } else missing <- c(missing,rep) + + ### ISO and Grid level outputs + ## only for BAU and SDP in 2020 and 2050 to save time and storage + years <- c(2020, 2050) + scen <- c("BAU", "FSDP", "SSP2fsdp") + thisScen <- unlist(strsplit(cfg$title, "_"))[3] + if (thisScen %in% scen) { + + ### ISO level outputs + rep <- file.path(outputdir[i], "report_iso.rds") + if(file.exists(rep)) { + a <- as.data.table(readRDS(rep)) + a <- a[variable %in% var_iso & period %in% years,] + a <- droplevels(a) + iso <- rbind(iso, a) + } else missing <- c(missing,rep) + } + + scen <- c("BAU", "FSDP", "SSP2fsdp") + #scen <- c("ERROR") + thisScen <- unlist(strsplit(cfg$title, "_"))[3] + if (thisScen %in% scen) { + ###Grid level outputs + y <- NULL + + ## BII + nc_file <- file.path(outputdir[i], "cell.bii_0.5.mz") #Note the "_" instead of "-" + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + getNames(a) <- "BII (index)" + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## Gridded temperature data from ISIMIP archive for relevant SSP/RCP + rcp <- switch(thisScen, + "BAU" = "ssp460", + "FSDP" = "ssp119", + "SSP2fsdp" = "ssp245", + "Invalid case") + + + nc_file <- "./input/FSEC_GlobalSurfaceTempPerRCP_v4_19-03-24/FSEC_GlobalSurfaceTempPerRCP_v4_19-03-24.mz" + + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, rcp] + getNames(a) <- "Global Surface Temperature (C)" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + ## Crop diversity + nc_file <- file.path(outputdir[i], paste0(cfg$title, "-CropDiversityGridded.mz")) + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years, "ShannonCropDiversity"] + getNames(a) <- "Shannon crop diversity (index)" + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## land patterns Mha + nc_file <- file.path(outputdir[i], "cell.land_0.5.mz") + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + getNames(a) <- paste0(getNames(a)," (Mha)") + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## land patterns share + nc_file <- file.path(outputdir[i], "cell.land_0.5_share.mz") + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + land_hr_shr <- a #needed for croparea shares + getNames(a) <- paste0(getNames(a)," (area share)") + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## croparea shares + nc_file <- file.path(outputdir[i], "cell.croparea_0.5_share.mz") + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + a <- dimSums(a,dim = "w") + getNames(a) <- reportingnames(getNames(a)) + a <- mbind(a, setNames(collapseNames(land_hr_shr[,,"crop"]) - dimSums(a, dim = 3), "Fallow")) + a[a < 0] <- 0 + getNames(a) <- paste0("Cropland|",getNames(a)," (area share)") + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## Nitrogen + nc_file <- file.path(outputdir[i], paste(cfg$title, "nutrientSurplus_intensity.mz", sep = "-")) + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + getNames(a) <- "nutrientSurplus (kg N per ha)" + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing, nc_file) + + ## Water + nc_file <- file.path(outputdir[i], "watStressViolations.mz") + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, ] + getNames(a) <- "water stress and violations" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + nc_file <- file.path(outputdir[i], "efvVolume.mz") + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, ] + getNames(a) <- "water environmental flow violations volume (km3)" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + nc_file <- file.path(outputdir[i], "efvVolume_ha.mz") + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, ] + getNames(a) <- "water environmental flow violations volume (m3/ha)" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + #add dimensions + + if (is.null(y)) { + message("Scenario: ", cfg$title, " contained none of the cellular output data.") + } else { + y <- add_dimension(y, dim = 3.1, add = "scenario", nm = gsub(".", "_", cfg$title, fixed = TRUE)) + y <- add_dimension(y, dim = 3.1, add = "model", nm = "MAgPIE") + getSets(y, fulldim = FALSE)[2] <- "period" + + #save as data.frame with xy coordinates + y <- as.data.table(as.data.frame(y, rev = 3)) + + #bind together + grid <- rbind(grid, y) + } + } +} + +if (!is.null(missing)) { + cat("\nList of folders with missing report files\n") + print(missing) +} + +renameScenario <- function(rep) { + rep <- rep[!get("scenario") %like% "calibration_FSEC", ] + rep[, c("version", "scenset", "scenario") := tstrsplit(scenario, "_", fixed = TRUE)] + return(rep) +} + +message("Saving rds files ...") + +reg <- renameScenario(reg) +saveRDS(reg, file = file.path("output", paste0(rev, "_FSDP_reg.rds")), version = 2, compress = "xz") +iso <- renameScenario(iso) +saveRDS(iso, file = file.path("output", paste0(rev, "_FSDP_iso.rds")), version = 2, compress = "xz") +if(!is.null(grid)){ + grid <- renameScenario(grid) + saveRDS(grid, file = file.path("output", paste0(rev, "_FSDP_grid.rds")), version = 2, compress = "xz") +} + +# save i_to_iso mapping +gdx <- file.path(outputdir[1], "fulldata.gdx") +reg2iso <- readGDX(gdx, "i_to_iso") +names(reg2iso) <- c("region", "iso_a3") +write.csv(reg2iso, file.path("output", "reg2iso.csv")) +saveRDS(reg2iso, file = file.path("output", "reg2iso.rds"), version = 2, compress = "xz") + +# save validation file +val <- file.path("input", "validation.mif") +val <- as.data.table(read.quitte(val)) +saveRDS(val, file = file.path("output", paste0(rev, "_FSDP_validation.rds")), version = 2, compress = "xz") + +message("Plotting figures ...") +#Add new plots here: +#https://github.com/pik-piam/m4fsdp/blob/master/R/plotFSDP.R +plotFSDP(outputfolder = "output", + reg = reg, + iso = iso, + grid = grid, + val = val, + reg2iso = reg2iso, + rev = rev) diff --git a/scripts/output/projects/FSDP_collect2.R b/scripts/output/projects/FSDP_collect2.R new file mode 100644 index 0000000000..0c5efade14 --- /dev/null +++ b/scripts/output/projects/FSDP_collect2.R @@ -0,0 +1,926 @@ +# | (C) 2008-2025 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: Collect reg, iso and grid level data from multiple FSDP runs (requires LR and HR runs) +# comparison script: TRUE +# --------------------------------------------------------------- + +# Version 1.0, Florian Humpenoeder + +library(lucode2) +library(magclass) +library(gms) +library(magpiesets) +library(data.table) +library(gdx2) +library(quitte) +library(m4fsdp) +library(stringr) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/", list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### + +# Report biophyiscal indicators from HR runs and economic indicators from LR runs + +split_resolutions = TRUE + +# For case of sub-folder structure write to the respective folder +title <- basename(outputdir) + +# Select runs to be displayed +x <- unlist(lapply(strsplit(basename(outputdir), "_"), function(x) x[2])) +outputdir <- outputdir[which(x %in% c("FSECa", "FSECb", "FSECc", "FSECd", "FSECe"))] + +# Get revision number +x <- unlist(lapply(strsplit(basename(outputdir), "_"), function(x) x[1])) +x <- sub("HRc1000","",x) +if (length(unique(x)) == 1) rev <- unique(x) else stop("version prefix is not identical. Check your selection of runs") + +########## +# Append health impacts reports +hi_datasets_path <- "/p/projects/magpie/data/FSEC_healthImpactsDatasets_raw" +if (dir.exists(hi_datasets_path)) { + + hi_datasets <- list.files(hi_datasets_path) + hi_versionToUse <- grep(rev, hi_datasets, value = TRUE) + + if (length(hi_versionToUse) == 0) { + + message("No corresponding version ID was found within the health impacts datasets. Using the latest available.") + + highestVersionNr <- max(as.numeric(str_extract(hi_datasets, "(?<=v)(.*?)(?=_)"))) + hi_versionToUse <- grep(paste0("v", highestVersionNr), hi_datasets, value = TRUE) + + } else if (length(hi_versionToUse) >= 2) { + stop("Duplicated version IDs were found in the health impacts datasets, only one is expected.") + } + + hi_versionToUse_path <- file.path(hi_datasets_path, hi_versionToUse) + hi_gdx <- suppressWarnings(readGDX(hi_versionToUse_path)) + + .appendHealthImpacts <- function(.x) { + cfg <- gms::loadConfig(file.path(.x, "config.yml")) + title <- cfg$title + + message("Appending health impact report: ", title) + tryCatch( + expr = { + appendReportHealthImpacts(healthImpacts_gdx = hi_gdx, scenario = title, dir = .x) + }, error = function(e) { + message("Unable to append health impacts for scenario: ", title, ". Likely it is non-dietary.") + } + ) + } + lapply(X = outputdir, FUN = .appendHealthImpacts) + +} else { + message("The directory storing health impacts datasets wasn't found. Skipping health impacts.") +} + +magicc7_datasets_path <- "/p/projects/magpie/data/FSEC_magicc7Datasets_raw" +if (dir.exists(magicc7_datasets_path)) { + + magicc7_datasets <- list.files(magicc7_datasets_path) + magicc7_versionToUse <- grep(rev, magicc7_datasets, value = TRUE) + + if (length(magicc7_versionToUse) == 0) { + + message("No corresponding version ID was found within the MAGICC7 datasets. Using the latest available.") + + highestVersionNr <- max(as.numeric(str_extract(magicc7_datasets, "(?<=v)(.*?)(?=_)"))) + magicc7_versionToUse <- grep(paste0("v", highestVersionNr), magicc7_datasets, value = TRUE) + + } else if (length(magicc7_versionToUse) >= 2) { + stop("Duplicated version IDs were found in the MAGICC7 datasets, only one is expected.") + } + + magicc7_versionToUse_path <- file.path(magicc7_datasets_path, magicc7_versionToUse) + + .appendMAGICC7 <- function(.x) { + cfg <- gms::loadConfig(file.path(.x, "config.yml")) + title <- cfg$title + + tryCatch( + expr = { + appendReportMAGICC7(resultsPath = magicc7_versionToUse_path, scenario = title, dir = .x) + }, error = function(e) { + message("Unable to append MAGICC7 dataset for scenario: ", title) + } + ) + } + lapply(X = outputdir, FUN = .appendMAGICC7) + +} else { + message("The directory storing MAGICC7 datasets wasn't found. Skipping AR6 global warming calculations.") +} + + +########## +# Generate output files +cat("\nStarting output generation\n") + +reg <- NULL +iso <- NULL +grid <- NULL +missing <- NULL + +saveRDS(outputdir,"outputdir.rds") + +var_reg_LR <- c( + # main indicators + "SDG|SDG02|Prevalence of underweight", + "SDG|SDG03|Prevalence of obesity", + "Health|Years of life lost|Disease", + "Household Expenditure|Food|Expenditure", + "Income|Number of People Below 3p20 USDppp11/day", + "Labor|Employment|Agricultural employment", + "Agricultural employment|Crop and livestock products", + "Labor|Wages|Hourly labor costs relative to 2010", + "Value|Bioeconomy Demand", + "Costs Without Incentives", + #further indicators + "Population", + "Income", + "Nutrition|Calorie Supply|+|Crops", + "Nutrition|Calorie Supply|+|Livestock products", + "Demand|++|Crops", + "Demand|Food|+|Crops", + "Demand|Feed|+|Crops", + "Demand|Feed|+|Pasture", + "Demand|Feed|+|Secondary products", + "Demand|Feed|+|Crop residues", + "Demand|Seed|+|Crops", + "Demand|Material|+|Crops", + "Demand|Processing|+|Crops", + "Demand|++|Livestock products", + "Demand|+|Agricultural Supply Chain Loss", + "Demand|+|Bioenergy", + "Demand|+|Feed", + "Demand|+|Food", + "Demand|+|Material", + "Demand|+|Processing", + "Demand|+|Seed", + "Demand|+|Roundwood", + "Demand|+|Domestic Balanceflow", + "Production|+|Crops", + "Production|Crops|+|Cereals", + "Production|Crops|+|Oil crops", + "Production|Crops|+|Sugar crops", + "Production|Crops|Other crops|+|Fruits Vegetables Nuts", + "Production|+|Livestock products", + "Production|+|Secondary products", + "Production|+|Pasture", + "Production|+|Bioenergy crops", + "Timber|Volumetric|Production|Roundwood", + "Production|Bioenergy|2nd generation|++|Bioenergy crops", + + "Costs", + "Value|Bioeconomy Demand", + "Population", + "Labor|Employment|Share of working age population employed in agriculture", + "Labor|Wages|Hourly labor costs", + ### Suppl plots + "Population", + "Prices|Index2020|Agriculture|Food products", + "Prices|Index2020|Agriculture|Food products|Livestock", + "Prices|Index2020|Agriculture|Food products|Plant-based", + "Household Expenditure|Food|Expenditure|Crops", + "Household Expenditure|Food|Expenditure|Crops|Cereals", + "Household Expenditure|Food|Expenditure|Crops|Oil crops", + "Household Expenditure|Food|Expenditure|Crops|Other crops", + "Household Expenditure|Food|Expenditure|Crops|Sugar crops", + "Household Expenditure|Food|Expenditure|Fish", + "Household Expenditure|Food|Expenditure|Livestock products", + "Household Expenditure|Food|Expenditure|Secondary products", + "Household Expenditure|Food|Food Expenditure Share", + "SDG|SDG02|Food expenditure share", + "Value|Agriculture GDP", + "Costs|TC", + "Agricultural Research Intensity", + "Nutrition|Calorie Intake", + "Nutrition|Calorie Intake|+|Crops", + "Nutrition|Calorie Intake|+|Fish", + "Nutrition|Calorie Intake|+|Livestock products", + "Nutrition|Calorie Intake|+|Secondary products", + "Nutrition|Calorie Intake|Crops|+|Cereals", + "Nutrition|Calorie Intake|Crops|+|Oil crops", + "Nutrition|Calorie Intake|Crops|+|Other crops", + "Nutrition|Calorie Intake|Crops|+|Sugar crops", + "Nutrition|Calorie Intake|Crops|Cereals|+|Maize", + "Nutrition|Calorie Intake|Crops|Cereals|+|Rice", + "Nutrition|Calorie Intake|Crops|Cereals|+|Temperate cereals", + "Nutrition|Calorie Intake|Crops|Cereals|+|Tropical cereals", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Groundnuts", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Soybean", + "Nutrition|Calorie Intake|Crops|Oil crops|+|Sunflower", + "Nutrition|Calorie Intake|Crops|Other crops|+|Fruits Vegetables Nuts", + "Nutrition|Calorie Intake|Crops|Other crops|+|Potatoes", + "Nutrition|Calorie Intake|Crops|Other crops|+|Pulses", + "Nutrition|Calorie Intake|Crops|Other crops|+|Tropical roots", + "Nutrition|Calorie Intake|Crops|Sugar crops|+|Sugar beet", + "Nutrition|Calorie Intake|Crops|Sugar crops|+|Sugar cane", + "Nutrition|Calorie Intake|Livestock products|+|Dairy", + "Nutrition|Calorie Intake|Livestock products|+|Eggs", + "Nutrition|Calorie Intake|Livestock products|+|Monogastric meat", + "Nutrition|Calorie Intake|Livestock products|+|Poultry meat", + "Nutrition|Calorie Intake|Livestock products|+|Ruminant meat", + "Nutrition|Calorie Intake|Secondary products|+|Alcoholic beverages", + "Nutrition|Calorie Intake|Secondary products|+|Brans", + "Nutrition|Calorie Intake|Secondary products|+|Molasses", + "Nutrition|Calorie Intake|Secondary products|+|Oils", + "Nutrition|Calorie Intake|Secondary products|+|Sugar", + "Nutrition|Calorie Supply", + "Nutrition|Calorie Supply|+|Crops", + "Nutrition|Calorie Supply|+|Fish", + "Nutrition|Calorie Supply|+|Livestock products", + "Nutrition|Calorie Supply|+|Secondary products", + "Nutrition|Calorie Supply|Crops|+|Cereals", + "Nutrition|Calorie Supply|Crops|+|Oil crops", + "Nutrition|Calorie Supply|Crops|+|Other crops", + "Nutrition|Calorie Supply|Crops|+|Sugar crops", + "Nutrition|Calorie Supply|Crops|Cereals|+|Maize", + "Nutrition|Calorie Supply|Crops|Cereals|+|Rice", + "Nutrition|Calorie Supply|Crops|Cereals|+|Temperate cereals", + "Nutrition|Calorie Supply|Crops|Cereals|+|Tropical cereals", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Groundnuts", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Soybean", + "Nutrition|Calorie Supply|Crops|Oil crops|+|Sunflower", + "Nutrition|Calorie Supply|Crops|Other crops|+|Fruits Vegetables Nuts", + "Nutrition|Calorie Supply|Crops|Other crops|+|Potatoes", + "Nutrition|Calorie Supply|Crops|Other crops|+|Pulses", + "Nutrition|Calorie Supply|Crops|Other crops|+|Tropical roots", + "Nutrition|Calorie Supply|Crops|Sugar crops|+|Sugar beet", + "Nutrition|Calorie Supply|Crops|Sugar crops|+|Sugar cane", + "Nutrition|Calorie Supply|Livestock products|+|Dairy", + "Nutrition|Calorie Supply|Livestock products|+|Eggs", + "Nutrition|Calorie Supply|Livestock products|+|Monogastric meat", + "Nutrition|Calorie Supply|Livestock products|+|Poultry meat", + "Nutrition|Calorie Supply|Livestock products|+|Ruminant meat", + "Nutrition|Calorie Supply|Secondary products|+|Alcoholic beverages", + "Nutrition|Calorie Supply|Secondary products|+|Brans", + "Nutrition|Calorie Supply|Secondary products|+|Molasses", + "Nutrition|Calorie Supply|Secondary products|+|Oils", + "Nutrition|Calorie Supply|Secondary products|+|Sugar", + "Trade|+|Net-Trade", + "Trade|Net-Trade|+|Crops", + "Trade|Net-Trade|+|Fish", + "Trade|Net-Trade|+|Forest products", + "Trade|Net-Trade|+|Livestock products", + "Trade|Net-Trade|+|Secondary products", + "Trade|Net-Trade|Crops|+|Cereals", + "Trade|Net-Trade|Crops|+|Oil crops", + "Trade|Net-Trade|Crops|+|Other crops", + "Trade|Net-Trade|Crops|+|Sugar crops", + "Trade|Net-Trade|Crops|Cereals|+|Maize", + "Trade|Net-Trade|Crops|Cereals|+|Rice", + "Trade|Net-Trade|Crops|Cereals|+|Temperate cereals", + "Trade|Net-Trade|Crops|Cereals|+|Tropical cereals", + "Trade|Net-Trade|Crops|Oil crops|+|Cotton seed", + "Trade|Net-Trade|Crops|Oil crops|+|Groundnuts", + "Trade|Net-Trade|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Trade|Net-Trade|Crops|Oil crops|+|Soybean", + "Trade|Net-Trade|Crops|Oil crops|+|Sunflower", + "Trade|Net-Trade|Crops|Other crops|+|Fruits Vegetables Nuts", + "Trade|Net-Trade|Crops|Other crops|+|Potatoes", + "Trade|Net-Trade|Crops|Other crops|+|Pulses", + "Trade|Net-Trade|Crops|Other crops|+|Tropical roots", + "Trade|Net-Trade|Crops|Sugar crops|+|Sugar beet", + "Trade|Net-Trade|Crops|Sugar crops|+|Sugar cane", + "Trade|Net-Trade|Forest products|+|Industrial roundwood", + "Trade|Net-Trade|Forest products|+|Wood fuel", + "Trade|Net-Trade|Livestock products|+|Dairy", + "Trade|Net-Trade|Livestock products|+|Eggs", + "Trade|Net-Trade|Livestock products|+|Monogastric meat", + "Trade|Net-Trade|Livestock products|+|Poultry meat", + "Trade|Net-Trade|Livestock products|+|Ruminant meat", + "Trade|Net-Trade|Secondary products|+|Sugar", + "Trade|Self-sufficiency|Crops|Cereals", + "Trade|Self-sufficiency|Crops|Cereals|Maize", + "Trade|Self-sufficiency|Crops|Cereals|Rice", + "Trade|Self-sufficiency|Crops|Cereals|Temperate cereals", + "Trade|Self-sufficiency|Crops|Cereals|Tropical cereals", + "Trade|Self-sufficiency|Crops|Other crops", + "Trade|Self-sufficiency|Crops|Other crops|Fruits Vegetables Nuts", + "Trade|Self-sufficiency|Crops|Other crops|Potatoes", + "Trade|Self-sufficiency|Crops|Other crops|Pulses", + "Trade|Self-sufficiency|Crops|Other crops|Tropical roots", + "Trade|Self-sufficiency|Crops|Sugar crops|Sugar cane", + "Trade|Self-sufficiency|Fish", + "Trade|Self-sufficiency|Livestock products", + "Trade|Self-sufficiency|Livestock products|Dairy", + "Trade|Self-sufficiency|Livestock products|Eggs", + "Trade|Self-sufficiency|Livestock products|Monogastric meat", + "Trade|Self-sufficiency|Livestock products|Poultry meat", + "Trade|Self-sufficiency|Livestock products|Ruminant meat", + "Trade|Self-sufficiency|Secondary products", + "Trade|Self-sufficiency|Secondary products|Alcoholic beverages", + "Trade|Self-sufficiency|Secondary products|Brans", + "Trade|Self-sufficiency|Secondary products|Cotton lint", + "Trade|Self-sufficiency|Secondary products|Distillers grains", + "Trade|Self-sufficiency|Secondary products|Ethanol", + "Trade|Self-sufficiency|Secondary products|Microbial protein", + "Trade|Self-sufficiency|Secondary products|Molasses", + "Trade|Self-sufficiency|Secondary products|Oilcakes", + "Trade|Self-sufficiency|Secondary products|Oils", + "Trade|Self-sufficiency|Secondary products|Sugar", + + "Nutrition|Anthropometrics|People normalweight", + "Nutrition|Anthropometrics|People obese", + "Nutrition|Anthropometrics|People overweight", + "Nutrition|Anthropometrics|People underweight", + "Labor|Employment|Agricultural employment", + "Labor|Employment|Agricultural employment|+|Crop products", + "Labor|Employment|Agricultural employment|+|Livestock products", + "Labor|Employment|Agricultural employment|+|MACCS", + "Labor|Wages|Hourly labor costs", + "Labor|Total Hours Worked", + "Income|Gini Coefficient", + "Income|Average Income of Lower 40% of Population", + "Income|Fraction of Population below half of Median Income", + "Income|Number of People Below 1p90 USDppp11/day", + "Income|Number of People Below 3p20 USDppp11/day", + "Income|Number of People Below 5p50 USDppp11/day", + "Health|Years of life lost|Disease", + "Health|Years of life lost|Disease|+|Congenital Heart Disease", + "Health|Years of life lost|Disease|+|Stroke", + "Health|Years of life lost|Disease|+|Cancer", + "Health|Years of life lost|Disease|+|Type-2 Diabetes", + "Health|Years of life lost|Disease|+|Respiratory Disease", + "Health|Attributable deaths|Disease" +) + +var_reg_HR <- c( + # main indicators + "Biodiversity|BII", + "Biodiversity|BII in 30x30 Landscapes", + "Biodiversity|Cropland Landscapes BII", + "Biodiversity|Biodiversity Hotspot BII", + "Biodiversity|Shannon crop area diversity index", + "Resources|Nitrogen|Nutrient surplus from land and manure management", + "Water|Environmental flow violation volume", + "Emissions|GWP100AR6|Land", + "Global Surface Temperature", + # further indicators + "Biodiversity|Agricultural landscape intactness", + "Biodiversity|Biodiversity hotspot intactness", + "Biodiversity|Biodiversity hotspot intactness (unitless)", + "Biodiversity|BII in areas outside Biodiversity Hotspots, Intact Forest & Cropland Landscapes", + "Biodiversity|Biodiversity Hotspot and Intact Forest Landscapes BII", + "Biodiversity|Biodiversity Hotspot BII", + "Biodiversity|Cropland Landscapes BII", + "Biodiversity|Key Biodiversity Area BII", + "Biodiversity|Inverted Simpson crop area diversity index", + "Resources|Land Cover", + "Resources|Land Cover|+|Cropland", + "Resources|Land Cover|+|Pastures and Rangelands", + "Resources|Land Cover|+|Forest", + "Resources|Land Cover|Forest|+|Managed Forest", + "Resources|Land Cover|Forest|Natural Forest|+|Primary Forest", + "Resources|Land Cover|Forest|Natural Forest|+|Secondary Forest", + "Resources|Land Cover|+|Other Land", + "Resources|Land Cover|+|Urban Area", + "Resources|Land Cover|Cropland|+|Croparea", + "Resources|Land Cover|Cropland|+|Fallow Cropland", + "Resources|Land Cover|Cropland|Croparea|Crops|+|Cereals", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Maize", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Rice", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Temperate cereals", + "Resources|Land Cover|Cropland|Croparea|Crops|Cereals|+|Tropical cereals", + "Resources|Land Cover|Cropland|Croparea|Crops|+|Oil crops", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Cotton seed", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Groundnuts", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Oilpalms", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Soybean", + "Resources|Land Cover|Cropland|Croparea|Crops|Oil crops|+|Sunflower", + "Resources|Land Cover|Cropland|Croparea|Crops|+|Sugar crops", + "Resources|Land Cover|Cropland|Croparea|Crops|Sugar crops|+|Sugar beet", + "Resources|Land Cover|Cropland|Croparea|Crops|Sugar crops|+|Sugar cane", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Fruits Vegetables Nuts", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Potatoes", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Pulses", + "Resources|Land Cover|Cropland|Croparea|Crops|Other crops|+|Tropical roots", + "Resources|Land Cover|Cropland|Croparea|+|Bioenergy crops", + "Productivity|Landuse Intensity Indicator Tau", + "Productivity|Feed conversion", + "Productivity|Feed conversion|Ruminant meat and dairy", + "Productivity|Feed conversion|Poultry meat and eggs", + "Productivity|Feed conversion|Monogastric meat", + "Productivity|Feed conversion|+|Cereal Intensity", + "Productivity|Feed conversion|+|Oilcrop intensity", + "Productivity|Feed conversion|+|Pasture intensity", + "Productivity|Roughage share|Ruminant meat and dairy", + "Productivity|Pasture share|Ruminant meat and dairy", + "Productivity|Yield by physical area|Crops", + "Productivity|Yield by physical area|Crops|Cereals", + "Productivity|Yield by physical area|Crops|Oil crops", + "Productivity|Yield by physical area|Crops|Sugar crops", + "Productivity|Yield by physical area|Crops|Other crops", + "Productivity|Yield by physical area|Crops|Other crops|Fruits Vegetables Nuts", + "Productivity|Yield by physical area|Pasture", + "Productivity|Yield by physical area|Bioenergy crops", + "Productivity|Yield by physical area|Forage", + "Resources|Nitrogen|Cropland Budget|Inputs", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Fertilizer", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Biological Fixation Symbiotic Crops", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Manure Recycled from Confinements", + "Resources|Nitrogen|Cropland Budget|Inputs|+|Recycled Aboveground Crop Residues", + "Resources|Nitrogen|Cropland Budget|Withdrawals|+|Harvested Crops", + "Resources|Nitrogen|Cropland Budget|Withdrawals|+|Aboveground Crop Residues", + "Resources|Nitrogen|Cropland Budget|Balance|+|Nutrient Surplus", + "Resources|Nitrogen|Cropland Budget|Balance|+|Soil Organic Matter", + "Resources|Nitrogen|Pollution|Surplus|+|Cropland", + "Resources|Nitrogen|Pollution|Surplus|+|Pasture", + "Resources|Nitrogen|Pollution|Surplus|+|Animal Waste Management", + "Resources|Nitrogen|Pollution|Surplus|+|Non-agricultural land", + "Resources|Nitrogen|Cropland Budget|Soil Nitrogen Uptake Efficiency", + "Resources|Water|Withdrawal|Agriculture", + "Resources|Land Cover|Cropland|Area equipped for irrigation", + "SDG|SDG02|Investment in AgR&D", + + "Emissions|CO2|Land|+|Land-use Change", + "Emissions|CH4|Land|+|Agriculture", + "Emissions|N2O|Land|+|Agriculture", + "Resources|Land Cover|+|Cropland", + "Resources|Land Cover|+|Pastures and Rangelands", + "Resources|Land Cover|Forest|Natural Forest|+|Primary Forest", + "Resources|Land Cover|Forest|Natural Forest|+|Secondary Forest", + "Resources|Land Cover|Forest|Managed Forest|+|Plantations", + "Resources|Land Cover|Forest|Managed Forest|+|NPI/NDC", + "Resources|Land Cover|Forest|Managed Forest|+|Afforestation", + "Resources|Land Cover|Cropland|+|Bioenergy crops", + "Resources|Land Cover|+|Other Land", + "Resources|Land Cover|+|Urban Area", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Maize", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Rice", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Temperate cereals", + "Resources|Land Cover|Cropland|Crops|Cereals|+|Tropical cereals", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Cotton seed", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Groundnuts", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Oilpalms", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Other oil crops incl rapeseed", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Soybean", + "Resources|Land Cover|Cropland|Crops|Oil crops|+|Sunflower", + "Resources|Land Cover|Cropland|Crops|Sugar crops|+|Sugar beet", + "Resources|Land Cover|Cropland|Crops|Sugar crops|+|Sugar cane", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Fruits Vegetables Nuts", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Potatoes", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Pulses", + "Resources|Land Cover|Cropland|Crops|Other crops|+|Tropical roots", + "Resources|Land Cover|Cropland|Crops|Cereals|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Maize|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Maize|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|Rice|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Rice|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|Temperate cereals|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Temperate cereals|rainfed", + "Resources|Land Cover|Cropland|Crops|Cereals|Tropical cereals|irrigated", + "Resources|Land Cover|Cropland|Crops|Cereals|Tropical cereals|rainfed", + "Resources|Land Cover|Cropland|Crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Groundnuts|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Groundnuts|rainfed", + "Resources|Land Cover|Cropland|Crops|Oil crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Other oil crops incl rapeseed|irrigated", + "Resources|Land Cover|Cropland|Crops|Oil crops|Other oil crops incl rapeseed|rainfed", + "Resources|Land Cover|Cropland|Crops|Oil crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|Fruits Vegetables Nuts|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Fruits Vegetables Nuts|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Potatoes|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Potatoes|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|Pulses|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Pulses|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Other crops|Tropical roots|irrigated", + "Resources|Land Cover|Cropland|Crops|Other crops|Tropical roots|rainfed", + "Resources|Land Cover|Cropland|Crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Sugar crops|irrigated", + "Resources|Land Cover|Cropland|Crops|Sugar crops|rainfed", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar beet|irrigated", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar beet|rainfed", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar cane|irrigated", + "Resources|Land Cover|Cropland|Crops|Sugar crops|Sugar cane|rainfed", + "Resources|Land Cover|Cropland|Forage|irrigated", + "Resources|Land Cover|Cropland|Forage|rainfed", + "Resources|Land Cover|Cropland|+|Bioenergy crops", + "Resources|Land Cover|Cropland|+|Fallow Cropland", + + "SDG|SDG15|Biological nitrogen fixation on cropland", + "SDG|SDG15|Non-agricultural land share", + "SDG|SDG15|Other natural land share", + "SDG|SDG15|Afforestation", + + "Resources|Nitrogen|Pollution|Surplus|+|Cropland", + "Resources|Nitrogen|Pollution|Surplus|+|Pasture", + "Resources|Nitrogen|Pollution|Surplus|+|Animal Waste Management", + "Resources|Nitrogen|Pollution|Surplus|+|Non-agricultural land", + "Resources|Water|Withdrawal|Agriculture", + + "Emissions|CH4_GWP*AR6|Land", + "Emissions|CH4_GWP*AR6|Land|+|Agriculture", + "Emissions|CH4_GWP*AR6|Land|+|Biomass Burning", + "Emissions|CH4_GWP*AR6|Land|+|Peatland", + "Emissions|CH4_GWP*AR6|Land|Agriculture|+|Animal waste management", + "Emissions|CH4_GWP*AR6|Land|Agriculture|+|Enteric fermentation", + "Emissions|CH4_GWP*AR6|Land|Agriculture|+|Rice", + "Emissions|CH4_GWP*AR6|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|CH4_GWP*AR6|Land|Peatland|+|Managed", + "Emissions|CH4_GWP100AR6|Land", + "Emissions|CH4_GWP100AR6|Land|+|Agriculture", + "Emissions|CH4_GWP100AR6|Land|+|Biomass Burning", + "Emissions|CH4_GWP100AR6|Land|+|Peatland", + "Emissions|CH4_GWP100AR6|Land|Agriculture|+|Animal waste management", + "Emissions|CH4_GWP100AR6|Land|Agriculture|+|Enteric fermentation", + "Emissions|CH4_GWP100AR6|Land|Agriculture|+|Rice", + "Emissions|CH4_GWP100AR6|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|CH4_GWP100AR6|Land|Peatland|+|Managed", + "Emissions|CH4|Land", + "Emissions|CH4|Land|+|Agriculture", + "Emissions|CH4|Land|+|Biomass Burning", + "Emissions|CH4|Land|+|Peatland", + "Emissions|CH4|Land|Agriculture|+|Animal waste management", + "Emissions|CH4|Land|Agriculture|+|Enteric fermentation", + "Emissions|CH4|Land|Agriculture|+|Rice", + "Emissions|CH4|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|CH4|Land|Peatland|+|Managed", + "Emissions|CO2|Land", + "Emissions|CO2|Land RAW", + "Emissions|CO2|Land RAW|+|Indirect RAW", + "Emissions|CO2|Land RAW|+|Land-use Change RAW", + "Emissions|CO2|Land|+|Indirect", + "Emissions|CO2|Land|+|Land-use Change", + "Emissions|CO2|Land|Cumulative", + "Emissions|CO2|Land|Cumulative|+|Indirect", + "Emissions|CO2|Land|Cumulative|+|Land-use Change", + "Emissions|CO2|Land|Cumulative|Land-use Change|+|Gross LUC", + "Emissions|CO2|Land|Cumulative|Land-use Change|+|Peatland", + "Emissions|CO2|Land|Cumulative|Land-use Change|+|Regrowth", + "Emissions|CO2|Land|Cumulative|Land-use Change|Gross LUC|+|Forest Degradation", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|CO2-price AR", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|NPI_NDC AR", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|Other Land", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|Secondary Forest", + "Emissions|CO2|Land|Cumulative|Land-use Change|Regrowth|Timber Plantations", + "Emissions|CO2|Land|Land-use Change|++|Above Ground Carbon", + "Emissions|CO2|Land|Land-use Change|++|Below Ground Carbon", + "Emissions|CO2|Land|Land-use Change|+|Gross LUC", + "Emissions|CO2|Land|Land-use Change|+|Peatland", + "Emissions|CO2|Land|Land-use Change|+|Regrowth", + "Emissions|CO2|Land|Land-use Change|Gross LUC|+|Forest Degradation", + "Emissions|CO2|Land|Land-use Change|Regrowth|CO2-price AR", + "Emissions|CO2|Land|Land-use Change|Regrowth|NPI_NDC AR", + "Emissions|CO2|Land|Land-use Change|Regrowth|Other Land", + "Emissions|CO2|Land|Land-use Change|Regrowth|Secondary Forest", + "Emissions|CO2|Land|Land-use Change|Regrowth|Timber Plantations", + "Emissions|GWP100AR6|Land", + "Emissions|GWP100AR6|Land|Cumulative", + "Emissions|N2O_GWP100AR6|Land", + "Emissions|N2O_GWP100AR6|Land|+|Agriculture", + "Emissions|N2O_GWP100AR6|Land|+|Biomass Burning", + "Emissions|N2O_GWP100AR6|Land|+|Peatland", + "Emissions|N2O_GWP100AR6|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O_GWP100AR6|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O_GWP100AR6|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O_GWP100AR6|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O_GWP100AR6|Land|Peatland|+|Managed", + "Emissions|N2O|Direct|Land", + "Emissions|N2O|Direct|Land|+|Agriculture", + "Emissions|N2O|Direct|Land|+|Biomass Burning", + "Emissions|N2O|Direct|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O|Direct|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O|Direct|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O|Direct|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O|Indirect|Land", + "Emissions|N2O|Indirect|Land|+|Agriculture", + "Emissions|N2O|Indirect|Land|+|Biomass Burning", + "Emissions|N2O|Indirect|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O|Indirect|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O|Indirect|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O|Indirect|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O|Land", + "Emissions|N2O|Land|+|Agriculture", + "Emissions|N2O|Land|+|Biomass Burning", + "Emissions|N2O|Land|+|Peatland", + "Emissions|N2O|Land|Agriculture|+|Agricultural Soils", + "Emissions|N2O|Land|Agriculture|+|Animal Waste Management", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|N2O|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|N2O|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|N2O|Land|Peatland|+|Managed", + "Emissions|NH3|Land", + "Emissions|NH3|Land|+|Agriculture", + "Emissions|NH3|Land|+|Biomass Burning", + "Emissions|NH3|Land|Agriculture|+|Agricultural Soils", + "Emissions|NH3|Land|Agriculture|+|Animal Waste Management", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|NH3|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|NH3|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|NO2|Land", + "Emissions|NO2|Land|+|Agriculture", + "Emissions|NO2|Land|+|Biomass Burning", + "Emissions|NO2|Land|Agriculture|+|Agricultural Soils", + "Emissions|NO2|Land|Agriculture|+|Animal Waste Management", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|NO2|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|NO2|Land|Biomass Burning|+|Burning of Crop Residues", + "Emissions|NO3-|Land", + "Emissions|NO3-|Land|+|Agriculture", + "Emissions|NO3-|Land|+|Biomass Burning", + "Emissions|NO3-|Land|Agriculture|+|Agricultural Soils", + "Emissions|NO3-|Land|Agriculture|+|Animal Waste Management", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Decay of Crop Residues", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Inorganic Fertilizers", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Manure applied to Croplands", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Pasture", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|+|Soil Organic Matter Loss", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Cropland", + "Emissions|NO3-|Land|Agriculture|Agricultural Soils|Inorganic Fertilizers|+|Pasture", + "Emissions|NO3-|Land|Biomass Burning|+|Burning of Crop Residues" +) + +# make sure there are no duplicates +var_reg_LR <- unique(var_reg_LR) +var_reg_HR <- unique(var_reg_HR) +var_reg_HR <- setdiff(var_reg_HR, var_reg_LR) +var_reg_LR <- setdiff(var_reg_LR, var_reg_HR) + +var_iso <- c("Population", + "Health|Years of life lost|Disease", + "Labor|Employment|Agricultural employment", + "Nutrition|Anthropometrics|People underweight", + "Nutrition|Anthropometrics|People obese", + "Household Expenditure|Food|Expenditure", + "Income|Number of People Below 3p20 USDppp11/day", + "Income|Gini Coefficient") +var_iso <- unique(var_iso) + +if(split_resolutions){ + outputdirHR <- outputdir[grep(pattern = "HRc1000", x=outputdir)] + outputdirLR <- setdiff(outputdir, outputdirHR) +} else { + outputdirLR <- outputdir +} + +for (i in 1:length(outputdirLR)) { + print(paste("Processing",outputdirLR[i])) + cfg <- gms::loadConfig(file.path(outputdirLR[i], "config.yml")) + + if (split_resolutions){ + this_outputdirHR <- outputdirHR[grep(cfg$title, gsub(pattern="HRc1000",replacement="", x=outputdirHR))] + if(length(this_outputdirHR)==1){ + print(paste("Found HR folder",this_outputdirHR)) + } else { + warning(paste("HR folder",this_outputdirHR, "not found. using LR folder")) + missing <- c(missing,this_outputdirHR) + this_outputdirHR <- outputdirLR[i] + } + } else { + this_outputdirHR <- outputdirLR[i] + } + + cfgHR <- gms::loadConfig(file.path(this_outputdirHR, "config.yml")) + + ### regional level outputs + ## read in from LR runs + repLR <- file.path(outputdirLR[i], "report.rds") + if(file.exists(repLR)) { + a <- as.data.table(readRDS(repLR)) + a <- a[variable %in% var_reg_LR,] + a <- droplevels(a) + reg <- rbind(reg, a) + } else missing <- c(missing,repLR) + ### read in from HR runs + repHR <- file.path(this_outputdirHR, "report.rds") + if(file.exists(repHR)) { + a <- as.data.table(readRDS(repHR)) + a <- a[variable %in% var_reg_HR,] + a <- droplevels(a) + levels(a$scenario) <- cfg$title + reg <- rbind(reg, a) + } else missing <- c(missing,repHR) + + ### ISO and Grid level outputs + ## only for BAU and SDP in 2020 and 2050 to save time and storage + years <- c(2020, 2050) + scen <- c("BAU", "FSDP", "SSP2fsdp") + thisScen <- unlist(strsplit(cfg$title, "_"))[3] + if (thisScen %in% scen) { + print(paste("grid level processing for run",outputdirLR[i])) + + ### ISO level outputs + rep <- file.path(outputdirLR[i], "report_iso.rds") + if(file.exists(rep)) { + a <- as.data.table(readRDS(rep)) + a <- a[variable %in% var_iso & period %in% years,] + a <- droplevels(a) + iso <- rbind(iso, a) + } else missing <- c(missing,rep) + + ###Grid level outputs + y <- NULL + + ## BII + nc_file <- file.path(this_outputdirHR, "cell.bii_0.5.mz") #Note the "_" instead of "-" + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + getNames(a) <- "BII (index)" + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## Gridded temperature data from ISIMIP archive for relevant SSP/RCP + rcp <- switch(thisScen, + "BAU" = "ssp460", + "FSDP" = "ssp119", + "SSP2fsdp" = "ssp245", + "Invalid case") + + nc_file <- "./input/FSEC_GlobalSurfaceTempPerRCP_v4_19-03-24/FSEC_GlobalSurfaceTempPerRCP_v4_19-03-24.mz" + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, rcp] + getNames(a) <- "Global Surface Temperature (C)" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + ## Crop diversity + nc_file <- file.path(this_outputdirHR, paste0(cfgHR$title, "-CropDiversityGridded.mz")) + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years, "ShannonCropDiversity"] + getNames(a) <- "Shannon crop diversity (index)" + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## land patterns Mha + nc_file <- file.path(this_outputdirHR, "cell.land_0.5.mz") + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + getNames(a) <- paste0(getNames(a)," (Mha)") + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## land patterns share + nc_file <- file.path(this_outputdirHR, "cell.land_0.5_share.mz") + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + land_hr_shr <- a #needed for croparea shares + getNames(a) <- paste0(getNames(a)," (area share)") + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## croparea shares + nc_file <- file.path(this_outputdirHR, "cell.croparea_0.5_share.mz") + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + a <- dimSums(a,dim = "w") + getNames(a) <- reportingnames(getNames(a)) + a <- mbind(a, setNames(collapseNames(land_hr_shr[,,"crop"]) - dimSums(a, dim = 3), "Fallow")) + a[a < 0] <- 0 + getNames(a) <- paste0("Cropland|",getNames(a)," (area share)") + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing,nc_file) + + ## Nitrogen + nc_file <- file.path(this_outputdirHR, paste(cfgHR$title, "nutrientSurplus_intensity.mz", sep = "-")) + if(file.exists(nc_file)) { + a <- read.magpie(nc_file)[,years,] + getNames(a) <- "nutrientSurplus (kg N per ha)" + getSets(a,fulldim = F)[3] <- "variable" + y <- mbind(y,a) + } else missing <- c(missing, nc_file) + + ## Water + nc_file <- file.path(this_outputdirHR, "watStressViolations.mz") + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, ] + getNames(a) <- "water stress and violations" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + nc_file <- file.path(this_outputdirHR, "efvVolume.mz") + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, ] + getNames(a) <- "water environmental flow violations volume (km3)" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + nc_file <- file.path(this_outputdirHR, "efvVolume_ha.mz") + if (file.exists(nc_file)) { + a <- read.magpie(nc_file)[, years, ] + getNames(a) <- "water environmental flow violations volume (m3/ha)" + getSets(a, fulldim = FALSE)[3] <- "variable" + y <- mbind(y, a) + } else missing <- c(missing, nc_file) + + #add dimensions + + if (is.null(y)) { + message("Scenario: ", cfg$title, " contained none of the cellular output data.") + } else { + y <- add_dimension(y, dim = 3.1, add = "scenario", nm = gsub(".", "_", cfg$title, fixed = TRUE)) + y <- add_dimension(y, dim = 3.1, add = "model", nm = "MAgPIE") + getSets(y, fulldim = FALSE)[2] <- "period" + + #save as data.frame with xy coordinates + y <- as.data.table(as.data.frame(y, rev = 3)) + + #bind together + grid <- rbind(grid, y) + } + } +} + +if (!is.null(missing)) { + cat("\nList of folders with missing report files\n") + print(missing) +} + +renameScenario <- function(rep) { + rep <- rep[!get("scenario") %like% "calibration_FSEC", ] + rep[, c("version", "scenset", "scenario") := tstrsplit(scenario, "_", fixed = TRUE)] + return(rep) +} + +message("Saving rds files ...") + +reg <- renameScenario(reg) +saveRDS(reg, file = file.path("output", paste0(rev, "_FSDP_reg.rds")), version = 2, compress = "xz") +iso <- renameScenario(iso) +saveRDS(iso, file = file.path("output", paste0(rev, "_FSDP_iso.rds")), version = 2, compress = "xz") +grid <- renameScenario(grid) +saveRDS(grid, file = file.path("output", paste0(rev, "_FSDP_grid.rds")), version = 2, compress = "xz") + +# save i_to_iso mapping +gdx <- file.path(outputdirLR[1], "fulldata.gdx") +reg2iso <- readGDX(gdx, "i_to_iso") +names(reg2iso) <- c("region", "iso_a3") +write.csv(reg2iso, file.path("output", "reg2iso.csv")) +saveRDS(reg2iso, file = file.path("output", "reg2iso.rds"), version = 2, compress = "xz") + +# save validation file +val <- file.path("input", "validation.mif") +val <- as.data.table(read.quitte(val)) +saveRDS(val, file = file.path("output", paste0(rev, "_FSDP_validation.rds")), version = 2, compress = "xz") + +message("Plotting figures ...") +#Add new plots here: +#https://github.com/pik-piam/m4fsdp/blob/master/R/plotFSDP.R +plotFSDP(outputfolder = "output", + reg = reg, + iso = iso, + grid = grid, + val = val, + reg2iso = reg2iso, + rev = rev) diff --git a/scripts/output/projects/FSDP_process.R b/scripts/output/projects/FSDP_process.R new file mode 100644 index 0000000000..d4ea76db9b --- /dev/null +++ b/scripts/output/projects/FSDP_process.R @@ -0,0 +1,124 @@ +# | (C) 2008-2025 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: Post-processing of FSEC scenarios, specifically generating dietary data +# comparison script: TRUE +# ------------------------------------------------------------------------------------------------- + +# Version 1.00 - Michael Crawford + +library(gms) +library(gdxrrw) +library(withr) +library(dplyr) +library(tidyr) + +message("Starting FSDP_process output runscript") + +############################# BASIC CONFIGURATION ####################################### + +if (!exists("source_include")) { + + outputdir <- file.path("output/", list.dirs("output/", full.names = FALSE, recursive = FALSE)) + lucode2::readArgs("outputdir") + +} + +######################################################################################### + +# ----------------------------------------------------------------------------------------------------------------- +# Merge dietary outputs from multiple FSEC scenarios into two .csv files + +message("Merging dietary outputs into \"caloricSupply.csv\" and \"dietaryIndicators.csv\"") + +caloricSupply_mergePath <- file.path("output", "caloricSupply.csv") +dietaryIndicators_mergePath <- file.path("output", "dietaryIndicators.csv") + +if (file.exists(caloricSupply_mergePath) || file.exists(dietaryIndicators_mergePath)) { + message("Merge files are already present for these runs. Removing these old files.") + file.remove(caloricSupply_mergePath, dietaryIndicators_mergePath) +} + +file.create(caloricSupply_mergePath, dietaryIndicators_mergePath) + +.writeDietaryIndicators <- function(.dir) { + + cfg <- gms::loadConfig(file.path(.dir, "config.yml")) + title <- cfg$title + + caloricSupply <- read.csv(file.path(.dir, paste0(title, "_caloricSupply.csv")), check.names = FALSE) + dietaryIndicators <- read.csv(file.path(.dir, paste0(title, "_dietaryIndicators.csv")), check.names = FALSE) + + dietaryIndicators <- dietaryIndicators %>% + pivot_longer(cols = c("population", + "bodyweight", + "bodyheight", + "PAL", + "intake"), + names_to = "Data", + values_to = "Value") + + if (file.info(caloricSupply_mergePath)$size == 0) { + # Include the header + write.table(caloricSupply, file = caloricSupply_mergePath, + quote = TRUE, sep = ",", row.names = FALSE, col.names = TRUE) + } else { + # Otherwise simply append + write.table(caloricSupply, file = caloricSupply_mergePath, + quote = TRUE, sep = ",", row.names = FALSE, col.names = FALSE, + append = TRUE) + } + + if (file.info(dietaryIndicators_mergePath)$size == 0) { + # Include the header + write.table(dietaryIndicators, file = dietaryIndicators_mergePath, + quote = TRUE, sep = ",", row.names = FALSE, col.names = TRUE) + } else { + # Otherwise simply append + write.table(dietaryIndicators, file = dietaryIndicators_mergePath, + quote = TRUE, sep = ",", row.names = FALSE, col.names = FALSE, + append = TRUE) + } +} + +# Only merge dietary indicators from selected, dietary-related, scenarios +dietRelatedScenarios <- c("c_BAU", + "d_SSP1bau", "d_SSP1PLUSbau", "d_SSP2bau", "d_SSP3bau", "d_SSP4bau", "d_SSP5bau", + "d_SSP1fsdp", "d_SSP1PLUSfsdp", "d_SSP2fsdp", "d_SSP3fsdp", "d_SSP4fsdp", "d_SSP5fsdp", + "a_NoUnderweight", "a_HalfOverweight", "a_NoOverweight", + "a_DietVegFruitsNutsSeeds", "a_DietMonogastrics", "a_DietRuminants", + "a_DietLegumes", "a_DietEmptyCals", "a_DietFish", + "a_LessFoodWaste", + "a_Population", "a_EconDevelop", + "e_FSDP", + "b_REDDaffRuminants", "b_Diet", "b_DietRotations", "b_MonogastricsRotations", + "b_ExternalPressures", "b_TradeMonogastrics", "b_TradeRuminants", "b_TradeVeggies", + "b_MonogastricsVeggies", "b_SoilMonogastric_", "b_SoilMonogastricRuminants_", + "b_AllNitrogen", "b_AllHealth", "b_Efficiency", "b_Sufficiency") + +outputdir_diets <- lapply(X = dietRelatedScenarios, FUN = function(.x) grep(x = outputdir, pattern = .x, value = TRUE)) +outputdir_diets <- unlist(outputdir_diets) + +lapply(X = outputdir_diets, FUN = .writeDietaryIndicators) + + +# ----------------------------------------------------------------------------------------------------------------- +# Produce .gdx files from two .csv files for Marco Springmann + +with_dir(file.path("output"), { + gamsScript <- "csv2gdx_dietaryIndicators.gms" + gamsScriptLst <- "csv2gdx_dietaryIndicators.lst" + file.create(gamsScript) + cat("$call csv2gdx dietaryIndicators.csv output=dietaryIndicators.gdx id=dietaryIndicators index=1..7 values=8 useHeader=y\n", + file = gamsScript, append = TRUE) + cat("$call csv2gdx caloricSupply.csv output=caloricSupply.gdx id=caloricSupply index=1..4 values=5 useHeader=y", + file = gamsScript, append = TRUE) + gams(gamsScript) + file.remove(gamsScript) + file.remove(gamsScriptLst) +}) diff --git a/scripts/output/projects/FSEC_AlessandroPassaro.R b/scripts/output/projects/FSEC_AlessandroPassaro.R new file mode 100644 index 0000000000..1f7c783b7a --- /dev/null +++ b/scripts/output/projects/FSEC_AlessandroPassaro.R @@ -0,0 +1,54 @@ +# | (C) 2008-2025 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: Create FSEC outputs for use by Alessandro Passaro +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC_AlessandroPassaro output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Creating an output directory for Alessandro Passaro's datasets") +alessandroPassaroDir <- file.path(".", "output", "AlessandroPassaro") +if (!dir.exists(alessandroPassaroDir)) { + dir.create(alessandroPassaroDir) +} + +reportOutputDir <- file.path(alessandroPassaroDir, title) +if (dir.exists(reportOutputDir)) { + message("Warning in FSEC_AlessandroPassaro: Output directory for " , title, " already exists. Results will be overwritten.") +} +suppressWarnings(dir.create(reportOutputDir)) + +message("Generating Alessandro Passaro's output for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") + +out <- getReportFSECAlessandroPassaro(gdx = gdx, + reportOutputDir = reportOutputDir, + scenario = title) diff --git a/scripts/output/projects/FSEC_SimonDietz.R b/scripts/output/projects/FSEC_SimonDietz.R new file mode 100644 index 0000000000..7a81f699a3 --- /dev/null +++ b/scripts/output/projects/FSEC_SimonDietz.R @@ -0,0 +1,55 @@ +# | (C) 2008-2025 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: Create FSEC outputs for use by Simon Dietz +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC_SimonDietz output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Creating an output directory for Simon Dietz's datasets") +simonDietzDir <- file.path(".", "output", "SimonDietz") +if (!dir.exists(simonDietzDir)) { + dir.create(simonDietzDir) +} + +reportOutputDir <- file.path(simonDietzDir, title) +if (dir.exists(reportOutputDir)) { + message("Warning in FSEC_SimonDietz: Output directory for " , title, " already exists. Results will be overwritten.") +} +suppressWarnings(dir.create(reportOutputDir)) + +message("Generating Simon Dietz's output for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") + +out <- getReportFSECSimonDietz(gdx = gdx, + reportOutputDir = reportOutputDir, + scenario = title) + diff --git a/scripts/output/projects/FSEC_StevenLord.R b/scripts/output/projects/FSEC_StevenLord.R new file mode 100644 index 0000000000..0c75bfdf82 --- /dev/null +++ b/scripts/output/projects/FSEC_StevenLord.R @@ -0,0 +1,54 @@ +# | (C) 2008-2025 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: Create FSEC output dataset for Steven Lord +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC_StevenLord output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Creating an output directory for Steven Lord's datasets") +stevenLordDir <- file.path(".", "output", "StevenLord") +if (!dir.exists(stevenLordDir)) { + dir.create(stevenLordDir) +} + +reportOutputDir <- file.path(stevenLordDir, title) +if (dir.exists(reportOutputDir)) { + message("Warning in FSEC_StevenLord: Output directory for " , title, " already exists. Results will be overwritten.") +} +suppressWarnings(dir.create(reportOutputDir)) + +message("Generating Steven Lord's output for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") + +out <- getReportFSECStevenLord(gdx = gdx, + reportOutputDir = reportOutputDir, + scenario = title) diff --git a/scripts/output/projects/FSEC_costs.R b/scripts/output/projects/FSEC_costs.R new file mode 100644 index 0000000000..2bf253e44a --- /dev/null +++ b/scripts/output/projects/FSEC_costs.R @@ -0,0 +1,42 @@ +# | (C) 2008-2025 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: Create FSEC costs output dataset +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC costs output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Generating costs output for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") + +out <- getReportFSECCosts(gdx = gdx, + reportOutputDir = outputdir, + scenario = title) diff --git a/scripts/output/projects/FSEC_cropDiversityGrid.R b/scripts/output/projects/FSEC_cropDiversityGrid.R new file mode 100644 index 0000000000..a5843530c0 --- /dev/null +++ b/scripts/output/projects/FSEC_cropDiversityGrid.R @@ -0,0 +1,43 @@ +# | (C) 2008-2025 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: Create FSEC Crop Diversity Map +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Patrick v. Jeetze +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC gridded crop diversity output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Generating crop diversity map for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") + +# Grid-level nitrogen pollution +out <- getReportFSECCropDiversityGrid(gdx = gdx, + reportOutputDir = outputdir, + scenario = title) diff --git a/scripts/output/projects/FSEC_dietaryIndicators.R b/scripts/output/projects/FSEC_dietaryIndicators.R new file mode 100644 index 0000000000..8929ec1fb0 --- /dev/null +++ b/scripts/output/projects/FSEC_dietaryIndicators.R @@ -0,0 +1,45 @@ +# | (C) 2008-2025 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 population-level dietary information and consumption data from a MAgPIE run +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC_DietaryIndicators output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +baseDir <- getwd() +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Generating DietaryIndicators output for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") +report <- getReportDietaryIndicators(gdx = gdx, scenario = title) + +Map(f = function(x, i) write.csv(x, file = file.path(outputdir, paste0(title, "_", i, ".csv")), + row.names = FALSE, quote = TRUE), + x = report, + i = names(report)) diff --git a/scripts/output/projects/FSEC_nitrogenPollution.R b/scripts/output/projects/FSEC_nitrogenPollution.R new file mode 100644 index 0000000000..1834f2b98b --- /dev/null +++ b/scripts/output/projects/FSEC_nitrogenPollution.R @@ -0,0 +1,43 @@ +# | (C) 2008-2025 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: Create FSEC environmental pollutants output dataset +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC nitrogen pollution output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Generating nitrogen pollution output for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") + +# Grid-level nitrogen pollution +out <- getReportFSECPollution(gdx = gdx, + reportOutputDir = outputdir, + scenario = title) diff --git a/scripts/output/projects/FSEC_water.R b/scripts/output/projects/FSEC_water.R new file mode 100644 index 0000000000..df3187ae03 --- /dev/null +++ b/scripts/output/projects/FSEC_water.R @@ -0,0 +1,65 @@ +# | (C) 2008-2025 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: Create FSEC water indicator gridded outputs for map +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Felicitas Beier +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting FSEC water output runscript") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +message("Generating water indicators output for the run: ", title) +gdx <- file.path(outputdir, "fulldata.gdx") + +### Grid-level water indicators ### +# Volume of environmental flow violations (EFV) (in km^3) +efvViolation <- waterEFViolation(gdx, level = "grid") +write.magpie(efvViolation, file_name = file.path(outputdir, "efvVolume.mz")) + +# Total land (in mio. ha) +gridLand <- reportGridLand(gdx) +# transform to ha +totalLand <- dimSums(gridLand, dim = 3) * 1e6 +# Environmental flow violations per hectare of total area (in m3/ha) +efvViolation_ha <- ifelse(totalLand > 10, (efvViolation * 1e9) / totalLand, 0) +write.magpie(efvViolation_ha, file_name = file.path(outputdir, "efvVolume_ha.mz")) + +# Binary indicator of EFV +efvViolation[efvViolation > 0] <- 1 + +# Water stress indicator (use-to-availability ratio) +watStress <- waterStressRatio(gdx, level = "grid") +watStressViolations <- watStress +# mark violations in different color +watStressViolations[efvViolation == 1] <- 100 +write.magpie(watStressViolations, file_name = file.path(outputdir, "watStressViolations.mz")) + +# Water EFV ratio (EFV to EFR) +watEFVratio <- waterEFVratio(gdx, level = "grid") +write.magpie(watEFVratio, file_name = file.path(outputdir, "watEFVratio.mz")) diff --git a/scripts/output/projects/INFO.yml b/scripts/output/projects/INFO.yml new file mode 100644 index 0000000000..503bc1be33 --- /dev/null +++ b/scripts/output/projects/INFO.yml @@ -0,0 +1,3 @@ +description: Project-specific MAgPIE output scripts +note: Scripts in this selection might require some manual adjustments before they work with the given MAgPIE version as they are not necessarily updated along with changes in the model code. Please provide a yml header to your script specifying "description" and "comparison script", otherwise it may not be processed correctly. +position: 3.0 diff --git a/scripts/output/projects/MAgPIE2GAINS.R b/scripts/output/projects/MAgPIE2GAINS.R new file mode 100644 index 0000000000..274cf9746c --- /dev/null +++ b/scripts/output/projects/MAgPIE2GAINS.R @@ -0,0 +1,71 @@ +# | (C) 2008-2025 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: create cellular cropland management data +# comparison script: FALSE +# --------------------------------------------------------------- + +#Version 1.00 - Benjamin Leon Bodirsky, David M Chen +# 1.00: first working version + +library(lucode2) +library(magpie4) +library(MagpieNCGains) +library(gms) + +print("Start GAINS reporting reg runscript") + +############################# BASIC CONFIGURATION ####################################### + +if(!exists("source_include")) { + + title <- "inms_SSP2_RCP4p5_PolicyLow_v4" + outputdir <- "output/inms_SSP2_RCP4p5_PolicyLow_v4_2020-07-13_15.37.07" + + ###Define arguments that can be read from command line + readArgs("outputdir","title") +} +######################################################################################### + +print(paste0("script started for output directory ",outputdir)) + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title +print("generating GAINS outputs for the run: ") +print(title) + +gdx <- paste0(outputdir,"/fulldata.gdx") + +#tgz <- paste0("/p/projects/landuse/data/input/archive/",strsplit(cfg$input[1],split = "c200")[[1]][[1]],"0.5.tgz") +#print(paste0("trying to extract lpj_yields_0.5.mz from ",tgz)) +#untar(tarfile = tgz, files = "lpj_yields_0.5.mz", exdir=outputdir) + + +print("create an separate output directory for cellular results") +outputpath<-paste0("./output/",title,"_GAINS", "/") +dir.create(outputpath) +write.table(x = outputdir,file = paste0(outputpath,"origin_folder.txt"),row.names = FALSE,col.names = FALSE) + + +print("starting cellular output generation using getReportMAgPIE2GAINS") + +a <- getReportMAgPIE2GAINS(gdx = gdx, + folder=outputpath, + dir=outputdir) + +print(".nc outputs generated, now converting to GAINs mapping") + + +files <- file.path(paste0(outputpath, c("NitrogenBudgetNonagland", + "NitrogenBudgetPasture", + "NitrogenBudgetCropland", + "CroplandAreaPhysical", + "LandAreaPhysical", + "NitrogenExcretion"), ".nc")) + +lapply(X=files, FUN=nc2gains, check=TRUE) diff --git a/scripts/output/projects/MAgPIE2LPJmL.R b/scripts/output/projects/MAgPIE2LPJmL.R new file mode 100644 index 0000000000..4a013e8320 --- /dev/null +++ b/scripts/output/projects/MAgPIE2LPJmL.R @@ -0,0 +1,57 @@ +# | (C) 2008-2025 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: create cellular cropland management data +# comparison script: FALSE +# --------------------------------------------------------------- + +#Version 1.00 - Benjamin Leon Bodirsky +# 1.00: first working version + +library(lucode2) +library(magpie4) +library(gms) + +print("Start inms reporting reg runscript") + +############################# BASIC CONFIGURATION ####################################### + +if(!exists("source_include")) { + + title <- "inms_SSP2_RCP4p5_PolicyLow_v4" + outputdir <- "output/inms_SSP2_RCP4p5_PolicyLow_v4_2020-07-13_15.37.07" + + ###Define arguments that can be read from command line + readArgs("outputdir","title") +} +######################################################################################### + +print(paste0("script started for output directory ",outputdir)) + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title +print("generating INMS output for the run: ") +print(title) + +gdx <- paste0(outputdir,"/fulldata.gdx") + +tgz <- paste0("/p/projects/landuse/data/input/archive/",strsplit(cfg$input[1],split = "c200")[[1]][[1]],"0.5.tgz") +print(paste0("trying to extract lpj_yields_0.5.mz from ",tgz)) +untar(tarfile = tgz, files = "lpj_yields_0.5.mz", exdir=outputdir) + +print("create an separate output directory for cellular results") +outputpath<-paste0("./output/",title,"/") +dir.create(outputpath) +print("save origin path in folder so that original run data can be found") +write.table(x = outputdir,file = paste0(outputpath,"origin_folder.txt"),row.names = FALSE,col.names = FALSE) + +print("starting cellular output generation using getReportMAgPIE2LPJmL") + +a <- getReportMAgPIE2LPJmL(gdx = gdx, + folder=outputpath, + dir = outputdir) diff --git a/scripts/output/projects/agmip_merge_report.R b/scripts/output/projects/agmip_merge_report.R new file mode 100644 index 0000000000..9657ef0619 --- /dev/null +++ b/scripts/output/projects/agmip_merge_report.R @@ -0,0 +1,96 @@ +# | (C) 2008-2025 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: merge agmip-reports of single runs into one project-report +# comparison script: TRUE +# --------------------------------------------------------------- + +library(lucode2) +library(magclass) +library(quitte) +library(madrat) +library(piamInterfaces) +library(gms) +library(dplyr) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + readArgs("outputdir") +} +############################################################################### +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") +} + +for (i in 1:length(outputdir)) { + print(paste("Processing", outputdir[i])) + #gdx file + 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 = "_") + } + #read-in reporting file + a <- read.report(rep,as.list = FALSE) + 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]) + } +} +if (!is.null(missing)) { + cat("\nList of folders with missing agmip_report.mif\n") + print(missing) +} + +if (file.exists("output/agmip_report_full.csv")) { + submission <- generateIIASASubmission( + mifs = "output/agmip_report_full.csv", + mapping = "AgMIP", + model = "MAgPIE", + outputFilename = NULL, + timesteps = c(seq(1995, 2100, 1)), + naAction = "na.pass" + ) + submission <- submission %>% + mutate( + "item" := gsub(".*\\.", "", variable), + "variable" := gsub("\\..*", "", variable) + ) %>% + select( + "Model" = "model", + "Scenario" = "scenario", + "Region" = "region", + "Item" = "item", + "Variable" = "variable", + "Year" = "period", + "Unit" = "unit", + "Value" = "value" + ) + write.csv(submission, + quote = FALSE, + file = "output/agmip_submission_report.csv", + row.names = FALSE + ) +} diff --git a/scripts/output/projects/agmip_report.R b/scripts/output/projects/agmip_report.R new file mode 100644 index 0000000000..5a8bb7f55b --- /dev/null +++ b/scripts/output/projects/agmip_report.R @@ -0,0 +1,47 @@ +# | (C) 2008-2025 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) +library(piamInterfaces) +library(piamutils) +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, "/agmip_report.mif") +rds <- paste0(outputdir, "/agmip_report.rds") +############################################################################### + +report <- getReportAgMIP(gdx, scenario = cfg$title) + +for (mapping in c("AgMIP")) { + missingVariables <- sort(setdiff(unique(deletePlus(getMappingVariables(mapping,"M"))),unique(deletePlus(getNames(report,dim="variable"))))) + if (length(missingVariables) > 0) { + warning("# The following ", length(missingVariables), " variables are expected in the piamInterfaces package ", + "for mapping ", mapping, ", but cannot be found in the MAgPIE report.\nPlease either fix in magpie4 or adjust the mapping in piamInterfaces.\n- ", + paste(missingVariables, collapse = ",\n- "), "\n") + } +} + +### regional aggregation +write.report(report, file = mif, skipempty = FALSE) +saveRDS(as.quitte(report), file = rds) diff --git a/scripts/output/projects/inms_merge_report.R b/scripts/output/projects/inms_merge_report.R new file mode 100644 index 0000000000..3a4d38ec77 --- /dev/null +++ b/scripts/output/projects/inms_merge_report.R @@ -0,0 +1,60 @@ +# | (C) 2008-2025 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: merges several inms report files into one mif +# comparison script: TRUE +# --------------------------------------------------------------- + +# Version 1.0, merge_report script by Florian Humpeblder +# Version 1.01, adaptted to merge inms script by Benjamin Leon Bodirsky +# +library(lucode2) +library(magclass) +library(quitte) +library(gms) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + lucode2::readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + +missing <- NULL + +combined <- "output/inms.csv" + +if(file.exists(combined)) file.rename(combined,"output/inms.bak") + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + #gdx file + rep <- file.path(outputdir[i], "report_inms.mif") + if(file.exists(rep)) { + #get scenario name + cfg <- gms::loadConfig(file.path(outputdir[i], "config.yml")) + scen <- cfg$title + #read-in reporting file + a <- read.report(rep,as.list = FALSE) + getNames(a,dim=1) <- scen + #add to reporting csv file + write.report(a, file = combined, append = TRUE, ndigit = 4, skipempty = FALSE) + } else { + missing <- c(missing,outputdir[i]) + } +} +if (!is.null(missing)) { + cat("\nList of folders with missing report.mif\n") + print(missing) +} + +if(file.exists(combined)) saveRDS(read.quitte(combined),file = "output/inms.rds") diff --git a/scripts/output/projects/inms_reporting_cell.R b/scripts/output/projects/inms_reporting_cell.R new file mode 100644 index 0000000000..cf28d967b0 --- /dev/null +++ b/scripts/output/projects/inms_reporting_cell.R @@ -0,0 +1,61 @@ +# | (C) 2008-2025 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: create cellular cropland management data +# comparison script: FALSE +# --------------------------------------------------------------- + +#Version 1.00 - Benjamin Leon Bodirsky +# 1.00: first working version + +library(lucode2) +library(magpie4) +library(gms) + +print("Start inms reporting reg runscript") + +############################# BASIC CONFIGURATION ####################################### + +if(!exists("source_include")) { + + title <- "inms_SSP2_RCP4p5_PolicyLow_v4" + outputdir <- "output/inms_SSP2_RCP4p5_PolicyLow_v4_2020-07-13_15.37.07" + + ###Define arguments that can be read from command line + readArgs("outputdir","title") +} +######################################################################################### + +print(paste0("script started for output directory ",outputdir)) + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title +print("generating INMS output for the run: ") +print(title) +title=strsplit(title,"_v") + +gdx <- paste0(outputdir,"/fulldata.gdx") + +tgz <- paste0("/p/projects/landuse/data/input/archive/",strsplit(cfg$input[1],split = "c200")[[1]][[1]],"0.5.tgz") +print(paste0("trying to extract lpj_yields_0.5.mz from ",tgz)) +untar(tarfile = tgz, files = "lpj_yields_0.5.mz", exdir=outputdir) + +print("create an separate output directory for cellular results") +outputpath<-paste0("./output/inms/") +if(!dir.exists(outputpath)) {dir.create(outputpath)} +#print("save origin path in folder so that original run data can be found") +#write.table(x = outputdir,file = paste0(outputpath,"origin_folder.txt"),row.names = FALSE,col.names = FALSE) + +print("starting cellular output generation using getReportMAgPIE2LPJmL") + +a <- getReportGridINMS(gdx = gdx, + folder=outputpath, + dir = outputdir, + scenario=paste0("v",title[[1]][1]), + versionnr=paste0("v",title[[1]][2]) + ) diff --git a/scripts/output/projects/inms_reporting_reg.R b/scripts/output/projects/inms_reporting_reg.R new file mode 100644 index 0000000000..4a42a802ee --- /dev/null +++ b/scripts/output/projects/inms_reporting_reg.R @@ -0,0 +1,66 @@ +# | (C) 2008-2025 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 inms-report in mif format from run +# comparison script: FALSE +# --------------------------------------------------------------- + +#Version 1.00 - Benjamin Leon Bodirsky +# 1.00: first working version + +library(lucode2) +library(magpie4) +library(magpiesets) +library(iamc) +library(gms) +print("Start inms reporting reg runscript") + +############################# BASIC CONFIGURATION ####################################### + +if(!exists("source_include")) { + + title <- "inms_SSP2_RCP4p5_PolicyLow_v4" + outputdir <- "output/inms_SSP2_RCP4p5_PolicyLow_v4_2020-07-13_15.37.07" + + ###Define arguments that can be read from command line + readArgs("outputdir", "title") +} +######################################################################################### + +print(paste0("script started for output directory", outputdir)) + +withr::local_dir(outputdir) + +cfg <- gms::loadConfig("config.yml") +title <- cfg$title +print("generating INMS output for the run: ") +print(title) + +filename <- paste0("report_", title, ".mif") +gdx <- paste0("fulldata.gdx") +a <- getReportINMS(gdx, file = filename, scenario = title, dir = ".") + +print(filename) +mif <- read.report(filename) + + +missingyears <- function(x) { + history <- paste0("y", 1965 + ((0:5) * 5)) + x[[1]][[1]] <- time_interpolate(x[[1]][[1]], + interpolated_year = c(history,paste0("y",2005+((0:9)*10))), + integrate_interpolated_years = TRUE) + x[[1]][[1]][, history, ] <- 0 + return(x) +} + +#a=c(missingyears(ssp1),missingyears(ssp2)) +a <- missingyears(mif) + +write.reportProject(a, mapping = paste0(wdbefore, "/mapping_inms.csv"), file = "report_inms.mif") +#write.report(a,file="magpie_results_nov2019.mif") +warnings() diff --git a/scripts/output/projects/peatland.R b/scripts/output/projects/peatland.R new file mode 100644 index 0000000000..8c5cc8ce8b --- /dev/null +++ b/scripts/output/projects/peatland.R @@ -0,0 +1,174 @@ +# | (C) 2008-2025 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: Output script for peatland paper (might be useful as template for other papers) +# comparison script: TRUE +# --------------------------------------------------------------- + +######################### +#### check modelstat #### +######################### +# Version 1.0, Florian Humpenoeder +# +library(lucode2) +library(magpie4) +library(luscale) +library(gdx2) +library(luplot) +library(ggplot2) +library(luscale) +library(data.table) +library(ggrepel) +library(patchwork) +library(quitte) +library(gms) + +options(error=function()traceback(2)) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <- file.path("output/",list.dirs("output/", full.names = FALSE, recursive = FALSE)) + #Define arguments that can be read from command line + readArgs("outputdir") +} +############################################################################### +cat("\nStarting output generation\n") + +vars <- c("Population","Income","Demand|+|Food","Demand|Food|+|Crops","Demand|Food|+|Livestock products","Trade|Net-Trade|+|Crops","Productivity|Yield|Crops|+|Cereals") + +all <- NULL + +x <- list() +x$LandCover <- NULL +x$PeatlandArea <- NULL +x$PeatlandAreaReg <- NULL +x$EmissionCO2 <- NULL +x$PeatlandEmission <- NULL +x$fprice_index <- NULL +x$income <- NULL +x$kcal <- NULL +x$demand_bioen <- NULL +x$c_price <- NULL +x$cost <- NULL + +missing <- NULL + +for (i in 1:length(outputdir)) { + print(paste("Processing",outputdir[i])) + gdx<-file.path(outputdir[i],"fulldata.gdx") + rep<-file.path(outputdir[i],"report.rds") + if(file.exists(gdx)) { + cfg <- gms::loadConfig(file.path(outputdir[i], "config.yml")) + scen <- cfg$title + prefix <- substring(scen, 1, 4) + + map_cell_clim <- readGDX(gdx,"p58_mapping_cell_climate") + + #LandCover + a <- land(gdx,level="glo") + forest <- setNames(dimSums(a[,,c("forestry","primforest","secdforest")],dim=3),"forest") + bio <- setNames(croparea(gdx,level="glo",products = c("betr","begr"),product_aggr = TRUE),"bio") + a <- mbind(a,bio,forest) + a[,,"crop"] <- a[,,"crop"]-setNames(a[,,"bio"],"crop") + a <- a[,,c("crop","bio","past","forest","other","urban")] + a <- add_dimension(a,dim = 3.1,add = "scenario",nm = scen) + x$LandCover <- mbind(x$LandCover,a) + + #PeatlandArea + a <- PeatlandArea(gdx,level="climate") + a <- add_dimension(a,dim = 3.1,add = "scenario",nm = scen) + x$PeatlandArea <- mbind(x$PeatlandArea,a) + + #PeatlandAreaReg + a <- PeatlandArea(gdx,level="reg") + a <- add_dimension(a,dim = 3.1,add = "scenario",nm = scen) + x$PeatlandAreaReg <- mbind(x$PeatlandAreaReg,a) + + #EmissionCO2 + a <- collapseNames(emisCO2(gdx,level = "cell",unit="gas")) + a <- dimSums(a*map_cell_clim,dim=1) + names(dimnames(a))[3] <- names(dimnames(map_cell_clim))[3] + a <- add_dimension(a,dim = 3.2,add = "GHG emission","Vegetation") + b <- collapseNames(PeatlandEmissions(gdx,level="climate")[,,"co2"]) + b <- add_dimension(b,dim = 3.2,add = "GHG emission","Peatland") + a <- mbind(a,b)/1000 + a <- add_dimension(a,dim = 3.1,add = "scenario",nm = scen) + x$EmissionCO2 <- mbind(x$EmissionCO2,a) + + #PeatlandEmission + a <- collapseNames(PeatlandEmissions(gdx,level="climate")) + a <- add_dimension(a,dim = 3.1,add = "scenario",nm = scen) + x$PeatlandEmission <- mbind(x$PeatlandEmission,a) + + #fprice_index + a <- priceIndex(gdx,level="regglo", products="kfo", baseyear = "y2015") + a <- collapseNames(add_dimension(a,dim = 3.1,add = "scenario",nm = scen),collapsedim = "data") + x$fprice_index <- mbind(x$fprice_index,a) + + #income + a <- collapseNames(income(gdx,level="reg",per_capita = FALSE,type = "mer")) + a <- collapseNames(add_dimension(a,dim = 3.1,add = "scenario",nm = scen),collapsedim = "data") + x$income <- mbind(x$income,a) + + #kcal + a <- collapseNames(Kcal(gdx, level = "glo")) + a <- collapseNames(add_dimension(a,dim = 3.1,add = "scenario",nm = scen),collapsedim = "data") + x$kcal <- mbind(x$kcal,a) + + #bioen + a <- demandBioenergy(gdx,level="reg") + a <- add_dimension(a,dim = 3.1,add = "scenario",nm = scen) + x$demand_bioen <- mbind(x$demand_bioen,a) + + #ghg price + a <- PriceGHG(gdx,level="glo",aggr="weight") + a <- add_dimension(a,dim = 3.1,add = "scenario",nm = scen) + x$c_price <- mbind(x$c_price,a) + + #costs + a <- collapseNames(readGDX(gdx,"ov11_cost_reg",select = list(type="level"))) + b <- collapseNames(superAggregate(readGDX(gdx,"ov_peatland_emis_cost",select = list(type="level")),level="reg",aggr_type = "sum")) + a <- a-b + a <- collapseNames(add_dimension(a,dim = 3.1,add = "scenario",nm = scen),collapsedim = "data") + x$cost <- mbind(x$cost,a) + + } else missing <- c(missing,outputdir[i]) + a <- as.data.table(readRDS(rep)) + a <- a[variable %in% vars,] + all <- rbind(all,a) +} +#remove 1995 +x <- lapply(x, function(x) {x[,getYears(x,as.integer = T)>=2015,]}) + +x$LandCoverChange <- x$LandCover-setYears(x$LandCover[,1,],NULL) +x$PeatlandAreaChange <- x$PeatlandArea-setYears(x$PeatlandArea[,1,],NULL) + +# files <- list.files(path="output", pattern="^(peatland)_.*(.rds)$") +# nums <- as.numeric(gsub(paste("peatland_", ".rds", sep="|"), "", files)) +# if(length(nums)==0) last=0 else last <- max(nums) +# newFile <- paste0("output/peatland_", sprintf("%02d", last + 1), ".rds") + +saveRDS(x,file = paste0("output/peatland_",prefix,".rds"),compress = "xz") + +saveRDS(all,paste0("output/report_",prefix,".rds")) + +if(!file.exists(paste0("output/validation_",prefix,".rds"))) { + val <- as.data.table(read.quitte("input/validation.mif")) + val <- val[variable %in% vars,] + saveRDS(val,paste0("output/validation_",prefix,".rds")) +} + +map_clim <- readGDX(gdx,"clcl_mapping") +saveRDS(map_clim,"output/map_clim.rds") + + + +if (!is.null(missing)) { + cat("\nList of folders with missing fulldata.gdx\n") + print(missing) +} diff --git a/scripts/output/rds_report.R b/scripts/output/rds_report.R new file mode 100644 index 0000000000..4d77f86f01 --- /dev/null +++ b/scripts/output/rds_report.R @@ -0,0 +1,91 @@ +# | (C) 2008-2025 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 report in rds and mif format from run +# comparison script: FALSE +# position: 2 +# --------------------------------------------------------------- + + +library(magclass) +library(magpie4) +library(lucode2) +library(quitte) +library(gms) +library(piamInterfaces) +library(piamutils) +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") +rds <- paste0(outputdir, "/report.rds") +mif <- paste0(outputdir, "/report.mif") +runstatistics <- paste0(outputdir, "/runstatistics.rda") +resultsarchive <- "/p/projects/rd3mod/models/results/magpie" +############################################################################### + + +report <- getReport(gdx, scenario = cfg$title) +if (!all(grepl(" \\(([^\\()]*)\\)($|\\.)", getNames(report, fulldim = TRUE)$variable))) { + warning("Variables should be in the format 'name (unit)' (the space between name and unit is important), ", + "but the following are not:\n", + paste(grep(" \\(([^\\()]*)\\)($|\\.)", getNames(report, fulldim = TRUE)$variable, + invert = TRUE, value = TRUE), collapse = "\n")) +} + +for (mapping in c("AR6", "NAVIGATE", "SHAPE", "AR6_MAgPIE")) { + missingVariables <- sort(setdiff(unique(deletePlus(getMappingVariables(mapping, "M"))), + unique(deletePlus(getNames(report, dim = "variable"))))) + if (length(missingVariables) > 0) { + warning("# The following ", length(missingVariables), " variables are expected in the piamInterfaces package ", + "for mapping ", mapping, ", but cannot be found in the MAgPIE report.\n", + "Please either fix in magpie4 or adjust the mapping in piamInterfaces.\n- ", + paste(missingVariables, collapse = ",\n- "), "\n") + } +} + +write.report(report, file = mif) + +qu <- as.quitte(report) +# as.quitte converts "World" into "GLO". But we want to keep "World" and therefore undo these changes +qu <- droplevels(qu) +levels(qu$region)[levels(qu$region) == "GLO"] <- "World" +qu$region <- factor(qu$region,levels = sort(levels(qu$region))) + +if (all(is.na(qu$value))) { + stop("No values in reporting!") +} + +saveRDS(qu, file = rds, version = 2) + +if (file.exists(runstatistics) && dir.exists(resultsarchive)) { + stats <- list() + load(runstatistics) + if (is.null(stats$id)) { + # create an id if it does not exist (which means that statistics have not + # been saved to the archive before) and save statistics to the archive + message("No id found in runstatistics.rda. Calling lucode2::runstatistics() to create one.") + stats <- lucode2::runstatistics(file = runstatistics, submit = cfg$runstatistics) + message("Created the id ", stats$id) + # save stats locally (including id) otherwise it would generate a new id (and + # resubmit the results and the statistics) next time rds_report is executed + save(stats, file = runstatistics, compress = "xz") + } + + # Save report to results archive + saveRDS(qu, file = paste0(resultsarchive, "/", stats$id, ".rds"), version = 2) + withr::with_dir(resultsarchive, { + system("find -type f -name '1*.rds' -printf '%f\n' | sort > fileListForShinyresults") + }) +} diff --git a/scripts/output/rds_report_iso.R b/scripts/output/rds_report_iso.R new file mode 100644 index 0000000000..86df4410d4 --- /dev/null +++ b/scripts/output/rds_report_iso.R @@ -0,0 +1,49 @@ +# | (C) 2008-2025 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 report in rds format from run +# comparison script: FALSE +# position: 3 +# --------------------------------------------------------------- + + +library(magclass) +library(magpie4) +library(lucode2) +library(quitte) +library(gms) +options("magclass.verbosity" = 1) + +############################# BASIC CONFIGURATION ############################# +if (!exists("source_include")) { + outputdir <- NULL + readArgs("outputdir") +} + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +gdx <- file.path(outputdir,"fulldata.gdx") +rds_iso <- paste0(outputdir, "/report_iso.rds") +############################################################################### + +report <- getReportIso(gdx, scenario = cfg$title) + +mif <- sub(".rds",".mif",rds_iso) +write.report(report, file = mif, scenario = cfg$title) +report <- read.report(file = mif, as.list = FALSE) + +q <- as.quitte(report) +# as.quitte converts "World" into "GLO". But we want to keep "World" and therefore undo these changes +q <- droplevels(q) +levels(q$region)[levels(q$region) == "GLO"] <- "World" +q$region <- factor(q$region,levels = sort(levels(q$region))) + +if (all(is.na(q$value))) { + stop("No values in reporting!") +} + +saveRDS(q, file = rds_iso, version = 2, compress = "xz") diff --git a/scripts/output/runBlackmagicc.R b/scripts/output/runBlackmagicc.R new file mode 100644 index 0000000000..04e55bb955 --- /dev/null +++ b/scripts/output/runBlackmagicc.R @@ -0,0 +1,35 @@ +# | (C) 2008-2025 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: Append MAGICC7 warming pathways to a MAgPIE run's report.mif +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Michael Crawford +# 1.00: first working version + +library(gms) +library(blackmagicc) + +message("Starting Blackmagicc output script") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") + +} +######################################################################################### + +message("Script started for output directory: ", outputdir) + +blackmagicc(dir = outputdir, append = TRUE) diff --git a/scripts/output/single/ForestMaps.R b/scripts/output/single/ForestMaps.R deleted file mode 100644 index b57f0ca939..0000000000 --- a/scripts/output/single/ForestMaps.R +++ /dev/null @@ -1,31 +0,0 @@ -# | (C) 2008-2019 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 - -library(magclass) -library(luplot) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdir <-"." -} - -load(paste0(outputdir, "/config.Rdata")) -title <- cfg$title -land_hr_file <- paste0(outputdir, "/cell.land_0.5.mz") - -############################################################################### - -land_hr <- read.magpie(land_hr_file) - -defor_primforest <- land_hr[,c(2020,2050,2100),"primforest"] - setYears(land_hr[,1995,"primforest"],NULL) -plotmap2(defor_primforest,paste0(outputdir,"/",title,"_defor_primforest.pdf"),legend_range = c(-0.1,0.1),title = paste(title,"diff map area"),midpoint = 0,lowcol = "darkred",midcol = "grey95",highcol = "darkgreen",plot_height=15,plot_width=10) - -defor_secdforest <- land_hr[,c(2020,2050,2100),"secdforest"] - setYears(land_hr[,1995,"secdforest"],NULL) -plotmap2(defor_secdforest,paste0(outputdir,"/",title,"_defor_secdforest.pdf"),legend_range = c(-0.1,0.1),title = paste(title,"diff map area"),midpoint = 0,lowcol = "darkred",midcol = "grey95",highcol = "darkgreen",plot_height=15,plot_width=10) - -defor <- dimSums(land_hr[,c(2020,2050,2100),c("primforest","secdforest")],dim=3) - dimSums(setYears(land_hr[,1995,c("primforest","secdforest")],NULL),dim=3) -plotmap2(defor,paste0(outputdir,"/",title,"_defor.pdf"),legend_range = c(-0.1,0.1),title = paste(title,"diff map area"),midpoint = 0,lowcol = "darkred",midcol = "grey95",highcol = "darkgreen",plot_height=15,plot_width=10) diff --git a/scripts/output/single/LandusePlots.R b/scripts/output/single/LandusePlots.R deleted file mode 100644 index 7fcb458158..0000000000 --- a/scripts/output/single/LandusePlots.R +++ /dev/null @@ -1,57 +0,0 @@ -# | (C) 2008-2019 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 - -library(magpie4) -library(magpiesets) -library(lusweave) -library(magclass) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdir <-"." -} - -gdx <- paste0(outputdir, "/fulldata.gdx") - -############################################################################### - -## Model output -modout_landuse <- land(gdx,level="grid",spamfiledirectory = outputdir) -getNames(modout_landuse,dim=1) <- reportingnames(getNames(modout_landuse,dim = 1)) - -sw<-swopen(paste0(outputdir,"/AreaPlots_LU.pdf")) - -swlatex(sw,c("\\title{LU plots}","\\author{PIK Landuse Group}")) -swlatex(sw,"\\huge") -swlatex(sw,"\\textbf{LU plots}\\newline") -swlatex(sw,"\\normalsize") -swlatex(sw,"\\newline") -swlatex(sw,"\\tableofcontents") -swlatex(sw,"\\newpage") - -LU <- getNames(modout_landuse,dim = 1) - -for (i in LU) { - swlatex(sw,"\\section{",i,"}") - breakpoints <- c(0,0.1,0.2,0.3) - for (j in getYears(modout_landuse)) { - cat(paste0(":::",LU," ",j,"\n")) - if("luplot" %in% rownames(installed.packages())){ - library(luplot) - swfigure(sw,"plotmap2",sw_option="width=10,height=6", - modout_landuse[,j,i], title = paste0(i),legend_breaks = breakpoints, - lowcol = "white",midcol = "red",highcol = "green", - legendname = "m ha", - legend_range = c(0,0.3),land_colour = "grey",sea=F) - } else { - swlatex(sw,"This functionality requires the package luplot to be loaded. Send an email to magpie[at]pik-potsdam.de for more details.") - break - } - } -} - -swclose(sw) diff --git a/scripts/output/single/coupling_report.R b/scripts/output/single/coupling_report.R deleted file mode 100644 index 6ae55edded..0000000000 --- a/scripts/output/single/coupling_report.R +++ /dev/null @@ -1,43 +0,0 @@ -# | (C) 2008-2019 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 - - -library(gdx) -library(magclass) -library(magpie4) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - - gdx_file <-'fulldata.gdx' - output_folder <- '.' - - title <- "EMF27G1" - - - #Define arguments that can be read from command line - readArgs("gdx_file","output_folder","title") -} else{ - output_folder<-outputdir - gdx_file<-path(outputdir,"fulldata.gdx") - title <- title -} - -############################################################################### - -x <- getReport(gdx_file) - -# Low-pass-filter CO2LUC data, leave out 1995 values since they are all NA -a<-x[,,"Emissions|CO2|Land Use (Mt CO2/yr)"] -a_1995<-a[,1,] -a_rest<-a[,-1,] -a_rest<-lowpass(a_rest,i=1,fix=NULL) -a<-mbind(a_1995,a_rest) -x[,,"Emissions|CO2|Land Use (Mt CO2/yr)"]<-a - -write.report(x,file=path(output_folder,"coupling.mif"),scenario=title) -write.report(x,file=path(output_folder,"..","coupling.mif"),scenario=title,append=TRUE) diff --git a/scripts/output/single/demandtest.R b/scripts/output/single/demandtest.R deleted file mode 100644 index 41bb91ba27..0000000000 --- a/scripts/output/single/demandtest.R +++ /dev/null @@ -1,268 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -library(lucode) -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 - -#specify the title flag for all the scenarios -flag <- "anthro" - -#SSPs -for (ssp in c("SSP2","SSP1","SSP3","SSP4","SSP5")) { - for(rcp in c("Ref","26")){ - cfg <- setScenario(cfg,c(ssp,if(rcp=="Ref") "NPI" else "NDC")) - - if(rcp=="Ref"){spa="SPA0"}else{spa=paste0("SPA",substring(ssp,4,5))} - if(ssp%in%c("SSP1","SSP2","SSP5")){ - model="REMIND-MAgPIE" - } else if (ssp=="SSP3"){ - model="AIM-CGE" - } else if (ssp=="SSP4"){ - model="GCAM4" - } - - cfg$title <- paste(if(rcp=="26" & ssp %in% c("SSP3","SSP4")) next else ssp,rcp,flag,sep="_") - cfg$gms$c56_pollutant_prices <- paste(if(rcp=="Ref" & ssp=="SSP3") "SSP2" else ssp,rcp,spa,"V15",if(rcp=="Ref" & ssp=="SSP3") "REMIND-MAGPIE" else model,sep="-") - cfg$gms$c60_2ndgen_biodem <- paste(if(ssp %in% c("SSP3","SSP4")) "SSP2" else ssp,rcp,spa,sep="-") - start_run(cfg,codeCheck=FALSE) - cfg$recalibrate <- FALSE - } -} - -#CC -cfg$gms$c14_yields_scenario <- "cc" -cfg$gms$c42_watdem_scenario <- "cc" -cfg$gms$c43_watavail_scenario <- "cc" -cfg$gms$c52_carbon_scenario <- "cc" - -##SSP1 -# cfg$title <- paste("SSP1_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP1-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NPI")) -cfg$gms$c56_pollutant_prices <- "SSP1-Ref-SPA0-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP1-Ref-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP1_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP1-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NDC")) -cfg$gms$c56_pollutant_prices <- "SSP1-26-SPA1-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP1-26-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP2 -# cfg$title <- paste("SSP2_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NPI")) -cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP2_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NDC")) -cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA2-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP3 -# cfg$title <- paste("SSP3_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) -# -cfg$title <- paste("SSP3_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP3","NPI")) -cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_co2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - - - - - -#start MAgPIE run -source("config/default.cfg") -cfg$results_folder <- "output/:title:" -cfg$recalibrate <- TRUE - -#specify the title flag for all the scenarios -flag <- "bmi" -cfg$gms$food <- "bmi_share_jul18" - -#SSPs -for (ssp in c("SSP2","SSP1","SSP3","SSP4","SSP5")) { - for(rcp in c("Ref","26")){ - cfg <- setScenario(cfg,c(ssp,if(rcp=="Ref") "NPI" else "NDC")) - - if(rcp=="Ref"){spa="SPA0"}else{spa=paste0("SPA",substring(ssp,4,5))} - if(ssp%in%c("SSP1","SSP2","SSP5")){ - model="REMIND-MAgPIE" - } else if (ssp=="SSP3"){ - model="AIM-CGE" - } else if (ssp=="SSP4"){ - model="GCAM4" - } - - cfg$title <- paste(if(rcp=="26" & ssp %in% c("SSP3","SSP4")) next else ssp,rcp,flag,sep="_") - cfg$gms$c56_pollutant_prices <- paste(if(rcp=="Ref" & ssp=="SSP3") "SSP2" else ssp,rcp,spa,"V15",if(rcp=="Ref" & ssp=="SSP3") "REMIND-MAGPIE" else model,sep="-") - cfg$gms$c60_2ndgen_biodem <- paste(if(ssp %in% c("SSP3","SSP4")) "SSP2" else ssp,rcp,spa,sep="-") - start_run(cfg,codeCheck=FALSE) - cfg$recalibrate <- FALSE - } -} - -#CC -cfg$gms$c14_yields_scenario <- "cc" -cfg$gms$c42_watdem_scenario <- "cc" -cfg$gms$c43_watavail_scenario <- "cc" -cfg$gms$c52_carbon_scenario <- "cc" - -##SSP1 -# cfg$title <- paste("SSP1_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP1-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NPI")) -cfg$gms$c56_pollutant_prices <- "SSP1-Ref-SPA0-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP1-Ref-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP1_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP1-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NDC")) -cfg$gms$c56_pollutant_prices <- "SSP1-26-SPA1-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP1-26-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP2 -# cfg$title <- paste("SSP2_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NPI")) -cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP2_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NDC")) -cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA2-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP3 -# cfg$title <- paste("SSP3_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) -# -cfg$title <- paste("SSP3_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP3","NPI")) -cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_co2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) diff --git a/scripts/output/single/emulator.R b/scripts/output/single/emulator.R deleted file mode 100644 index 84db0554e1..0000000000 --- a/scripts/output/single/emulator.R +++ /dev/null @@ -1,202 +0,0 @@ -# | (C) 2008-2019 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 -library(magclass) -library(lucode) -library(lusweave) -library(magpie) -library(luplot) -library(ggplot2) -library(remulator) - -######################################################################################################## -######################################## Define function ############################################### -######################################################################################################## - -collect_data_and_make_emulator <- function(outputdir,name_of_fit="linear") { - load(paste0(outputdir, "/config.Rdata")) - - #setwd("~/Documents/0_GIT/magpie") - #cfg<-list(title="SSP2-26-1") - - # lock the model (other emulaotr scripts have to wait until this one finished) - lock_id <- lucode::model_lock(file=".lockemu") - on.exit(lucode::model_unlock(lock_id,file=".lockemu")) - - results_path <- "output" - - emu_path <- file.path(results_path,"emulator") - if(!dir.exists(emu_path)) dir.create(emu_path) - - ####################################################### - ############# C O L L E C T D A T A ################# - ####################################################### - - # extract scenario name by removing number at the end of run name: "CDL_base-base-9" -> "CDL_base-base" - scenarios <- gsub("(.*)-[0-9]{1,2}$","\\1",cfg$title) - # if user chose multiple runs from the same scenario remove duplicated scenarios - scenarios <- unique(scenarios) - - # create empty object that will take all results - x <- NULL - - # For all scenarios read data of all runs and compile into the single magpie object "x" - for (scen in scenarios) { - - if(!dir.exists(file.path(emu_path,scen))) dir.create(file.path(emu_path,scen)) - - outfile <- paste0(emu_path,"/",scen,"/data_raw_magpie_output_",scen,".Rdata") - - # If all 73 MAgPIE runs for this scenario are finished: - # Read MAgPIE reports and modelstat for all runs of the list of scenarios, - # combine into one object, and save to Rdata file - raw_data_available <- FALSE - - cat("Checking if results have already been compiled and saved to",outfile,"\n") - if(file.exists(outfile)) { - # if results have already been collected and saved for this scenario load them - cat("Results found. Loading them.\n") - load(outfile) # expecting mag_res as the only object in this file - raw_data_available <- TRUE - } else { - cat("No previously compiled results found.\nChecking if all runs for",scen,"have finished\n") - # otherwise check if all runs are finished and if yes collect the results and save them to a Rdata file - # list all subdirectories of results_path - #single_scenario_paths <- base::list.dirs(results_path,recursive=FALSE,full.names=TRUE) - - # Find paths to all finished runs for this scenario. Use existence of fulldata.gdx as indicator. - # Remove fulldata.gdx from paths - # Pick only those that are like scenario followed by one ore two digits, i.e. "scenario_name-xx", with xx = 1...73 - single_scenario_paths <- Sys.glob(paste0(results_path,"/",scen,"-*/report.mif")) - single_scenario_paths <- gsub("\\/report\\.mif","",single_scenario_paths) - needle <- paste0(scen,"-([0-9]{1,2}$)") - single_scenario_paths <- single_scenario_paths[grepl(needle,single_scenario_paths)] - print(single_scenario_paths) - if (emulator_runs_complete(single_scenario_paths,runnumbers = c(1:73))) { # c(6,7,59:60,64:73) - cat("All 73 runs for",scen,"have finished.\n") - mag_res <- read_and_combine(single_scenario_paths,outfile = outfile) - raw_data_available <- TRUE - } else { - cat("NOT all 73 runs for",scen,"have finished yet. Nothing will be done.") - } - } - - # check if emulator has already been generated for this scenario - fitted_data_available <- file.exists(paste0(emu_path,"/",scen,"/",name_of_fit,"/data_postfit_",scen,".Rdata")) - if (fitted_data_available) { - cat("Emulator has already been generated for",scen,"and will not be regenerated.\n") - } else if (raw_data_available) { - # compile data of mutiple scenarios in x - x <- mbind(x,mag_res) - } - } - - # If for one of the scenarios raw data was available but no fit x is not NULL anymore and contains the - # raw data of the missing scenario for which the fits will be generated below. - if (!is.null(x)) { - ################################################################ - ############# Prepare data for bioenergy emulator ############## - ################################################################ - - # Bring object to format that is required by emulator - # add sample dimension by replacing -63 with .63 - getNames(x,dim=1) <- gsub("-([0-9]{1,2}$)",".\\1",getNames(x,dim=1)) - getSets(x) <- c("region","year","scenario","sample","model","variable") - - x <- x[,"y1995",,invert=TRUE] - - # Demand|Bioenergy|++|2nd generation (EJ/yr) - # Prices|Bioenergy (US$05/GJ) - - # Clean data - # 1. Exclude points with zero production (there are cases where production is zero but there is a price) - x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"][x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"]==0] <- NA - x[,,"Prices|Bioenergy (US$05/GJ)"][is.na(x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"])] <- NA - - # 2. Normally, where production (x) is zero resulting prices (y) are NA -> set production to NA where prices are NA - x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"][is.na(x[,,"Prices|Bioenergy (US$05/GJ)"])] <- NA - - x[,,"Modelstatus (-)"] <- x["GLO",,"Modelstatus (-)"] - - # Convert units to REMIND units - TWa_2_EJ <- 365.25*24*3600/1E6 - tmp1 <- x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"] / TWa_2_EJ # EJ -> TWa - tmp2 <- x[,,"Prices|Bioenergy (US$05/GJ)"] * TWa_2_EJ/1000 # $/GJ -> T$/TWa - getNames(tmp1,dim=4) <- gsub("EJ/yr","TWa/yr", getNames(tmp1,dim=4),fixed=TRUE) - getNames(tmp2,dim=4) <- gsub("US$05/GJ","T$/TWa",getNames(tmp2,dim=4),fixed=TRUE) - x <- mbind(x,tmp1,tmp2) - - ############################################################### - ############# C A L C U L A T E E M U L A T O R ############# - ############################################################### - - # vars <- c("Demand|Bioenergy|++|2nd generation (EJ/yr)", - # "Prices|Bioenergy (US$05/GJ)", - # "Modelstatus (-)") - # - # y <- x[,,vars] - # - # # Make up model data for fitting: If in current year not enough data is availalbe copy it from other years - # # Criteria for "enough" data available: - # # number of - # # 1. non-zero and - # # 2. feasible and - # # 3. unique and - # # 4. non-NA elements - # # > n - # - # # 1. non-zero: set zero elements to NA - # # has been done before -> does not have to be checked here - # - # # 2. feasible: set data to NA in infeasible years and the years after - # y <- mute_infes(data = y, name="Modelstatus (-)", infeasible = 5) - # - # # 3. unique elements: set duplicated samples to NA - # y <- mute_duplicated(y) - # - # # 4. non-NA: find number of non-NA elements - # n_exist <- as.magpie(apply(unwrap(y),c(1,2,3,5,6),function(x)sum(!is.na(x)))) - # nodata <- n_exist[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"]<1 - # - # # Finally: Copy data from other years where data is not availalbe - # z <- fill_missing_years(y,nodata) - - # Calculate emulator - fc <- emulator(data=x, - name_x="Demand|Bioenergy|++|2nd generation (TWa/yr)", - name_y="Prices|Bioenergy (T$/TWa)", - name_modelstat="Modelstatus (-)", - userfun=function(param,x)return(param[[1]] + param[[2]] * x), - treat_as_feasible = c(2,7), - n_suff = 5, - fill = TRUE, - output_path = emu_path, - fitname = name_of_fit, - create_pdf=TRUE, - initial_values = c(0,0), - lower=c(0,0)) - print(fc) - print(attributes(fc)) - - regionscode <- attributes(mag_res)$regionscode - - # write fit coefficients to REMIND input file - for (scen in getNames(fc,dim="scenario")) { - write.magpie(fc,file_name = paste0("f30_bioen_price_",scen,"_",regionscode,".cs4r"), file_folder = file.path(emu_path,scen,name_of_fit)) - } - } -} - - -######################################################################################################## -######################################## Execute function ############################################## -######################################################################################################## - if(!exists("source_include")) { - outputdir <- NULL - readArgs("outputdir") - } - -collect_data_and_make_emulator(outputdir,name_of_fit="linear") diff --git a/scripts/output/single/interpolation.R b/scripts/output/single/interpolation.R deleted file mode 100644 index 5515008b24..0000000000 --- a/scripts/output/single/interpolation.R +++ /dev/null @@ -1,134 +0,0 @@ -# | (C) 2008-2019 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 - -######################################################################### -#### Interpolates land pools from low to high resolution, calculates #### -#### corresponding spam-files for following disaggregations ############# -######################################################################### - -#Version 1.03 - Jan Philipp Dietrich -# 1.00: first working version -# 1.01: execution of reshape_folder function added at the end -# 1.02: uses now the land function to read the simulated land input -# 1.03: introduced function interpolate, all possible input is read from the GDX file now - -library(lucode) -library(magpie4) -library(luscale) - -############################# BASIC CONFIGURATION ####################################### -land_lr_file <- "avl_land_t.cs3" -land_hr_file <- "avl_land_t_0.5.mz" -land_hr_out_file <- "cell.land_0.5.mz" -land_hr_share_out_file <- "cell.land_0.5_share.mz" -croparea_hr_share_out_file <- "cell.croparea_0.5_share.mz" - -prev_year <- "y1985" #timestep before calculations in MAgPIE -in_folder <- "modules/10_land/input" - -if(!exists("source_include")) { - sum_spam_file <- "0.5-to-n200_sum.spam" - title <- "base_run" - outputdir <- "output/SSP2_Ref_c200" - - ###Define arguments that can be read from command line - readArgs("sum_spam_file","outputdir","title") -} -######################################################################################### - -load(paste0(outputdir, "/config.Rdata")) -title <- cfg$title -print(title) - -# Function to extract information from info.txt -get_info <- function(file, grep_expression, sep, pattern="", replacement="") { - if(!file.exists(file)) return("#MISSING#") - file <- readLines(file, warn=FALSE) - tmp <- grep(grep_expression, file, value=TRUE) - tmp <- strsplit(tmp, sep) - tmp <- sapply(tmp, "[[", 2) - tmp <- gsub(pattern, replacement ,tmp) - if(all(!is.na(as.logical(tmp)))) return(as.vector(sapply(tmp, as.logical))) - if (all(!(regexpr("[a-zA-Z]",tmp) > 0))) { - tmp <- as.numeric(tmp) - } - return(tmp) -} -low_res <- get_info(paste0(outputdir,"/info.txt"),"^\\* Output ?resolution:",": ") -sum_spam_file <- paste0("0.5-to-",low_res,"_sum.spam") -print(sum_spam_file) - - -# Load input data -gdx <- path(outputdir,"fulldata.gdx") -land_ini_lr <- readGDX(gdx,"f10_land","f_land", format="first_found")[,"y1995",] -land_lr <- land(gdx,sum=FALSE,level="cell") -land_ini_hr <- read.magpie(path(in_folder,land_hr_file))[,"y1995",] -land_ini_hr <- land_ini_hr[,,getNames(land_lr)] -if(any(land_ini_hr < 0)) { - warning(paste0("Negative values in inital high resolution dataset detected and set to 0. Check the file ",land_hr_file)) - land_ini_hr[which(land_ini_hr < 0,arr.ind = T)] <- 0 -} - -# Start interpolation (use interpolate from luscale) -print("Interpolation") -land_hr <- interpolate( x = land_lr, - x_ini_lr = land_ini_lr, - x_ini_hr = land_ini_hr, - spam = path(outputdir,sum_spam_file), - prev_year = prev_year) - - -# Write outputs - -print("Write outputs cell.land") -# write landpool -write.magpie(land_hr,path(outputdir,paste(land_hr_out_file,sep="_")),comment="unit: Mha per grid-cell") -write.magpie(land_hr,path(outputdir,paste(sub(".mz",".nc",land_hr_out_file),sep="_")),comment="unit: Mha per grid-cell", verbose=FALSE) - -print("Write outputs cell.land_share") -# calculate share of land pools in terms of tatal cell size -land_shr_hr <- land_hr/dimSums(land_hr,dim=3.1) -# write landpool shares -write.magpie(land_shr_hr,path(outputdir,paste(land_hr_share_out_file,sep="_")),comment="unit: grid-cell land area fraction") -write.magpie(land_shr_hr,path(outputdir,paste(sub(".mz",".nc",land_hr_share_out_file),sep="_")),comment="unit: grid-cell land area fraction", verbose=FALSE) - -# Write spam files (crop weighted for each time step) -for(y in getYears(land_hr)) create_spam(land_hr[,y,"crop"],read.spam(path(outputdir,sum_spam_file)),fname=path(outputdir,sub("sum",paste("crop_weighted_mean",y,sep="_"),sum_spam_file))) - -# Disaggregate other cellular files -reshape_folder(outputdir) - -print("Disaggregation crop types") -# detailed output (crop types, rf + if), disaggregate shares of cropland within cluster level to cellular level -# get rid of y1985 -land_hr <- land_hr[,-1,] - -# total crop tpye specific croparea -area <- croparea(gdx,level="cell",products="kcr",product_aggr=FALSE,water_aggr = FALSE) - -# share of crop types in terms of croparea -area_shr <- area/dimSums(area,dim=c(3.1,3.2)) - -# set inf to 0 -area_shr[is.na(area_shr)] <- 0 -area_shr[is.nan(area_shr)] <- 0 -area_shr[is.infinite(area_shr)] <- 0 - -# disaggregate share of crop types in terms of croparea to 0.5 resolution -area_shr_hr <- speed_aggregate(area_shr,t(read.spam(path(outputdir,sum_spam_file)))) - -# calculate crop tpye specific croparea in 0.5 resolution -area_hr <- area_shr_hr*setNames(land_hr[,,"crop"],NULL) - -# calculate share of crop types in terms of total cell size -area_shr_hr <- area_hr/dimSums(land_hr,dim=3.1) - -print("Write outputs cell.cropara_share") -# write share of crop types in terms of total cell size -write.magpie(area_shr_hr,path(outputdir,paste(croparea_hr_share_out_file,sep="_")),comment="unit: grid-cell land area fraction") -write.magpie(area_shr_hr,path(outputdir,paste(sub(".mz",".nc",croparea_hr_share_out_file),sep="_")),comment="unit: grid-cell land area fraction", verbose=FALSE) diff --git a/scripts/output/single/interpolation_cropsplit.R b/scripts/output/single/interpolation_cropsplit.R deleted file mode 100644 index 9d81410655..0000000000 --- a/scripts/output/single/interpolation_cropsplit.R +++ /dev/null @@ -1,138 +0,0 @@ -# | (C) 2008-2019 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 - -######################################################################### -#### Interpolates land pools from low to high resolution, calculates #### -#### corresponding spam-files for following disaggregations ############# -######################################################################### - -#Version 1.03 - Jan Philipp Dietrich -# 1.00: first working version -# 1.01: execution of reshape_folder function added at the end -# 1.02: uses now the land function to read the simulated land input -# 1.03: introduced function interpolate, all possible input is read from the GDX file now - -library(lucode) -library(magpie4) -library(luscale) - -############################# BASIC CONFIGURATION ####################################### -land_lr_file <- "avl_land_t.cs3" -land_hr_file <- "avl_land_t_0.5.mz" -land_hr_out_file <- "cell_land_cropsplit_0.5.mz" -land_hr_share_out_file <- "cell_land_cropsplit_0.5_share.mz" - -prev_year <- "y1985" #timestep before calculations in MAgPIE -in_folder <- "modules/10_land/input" - -if(!exists("source_include")) { - sum_spam_file <- "0.5-to-n200_sum.spam" - title <- "base_run" - outputdir <- "output/SSP2_Ref_c200" - - ###Define arguments that can be read from command line - readArgs("sum_spam_file","outputdir","title") -} -######################################################################################### - -load(paste0(outputdir, "/config.Rdata")) -title <- cfg$title -print(title) - -# Function to extract information from info.txt -get_info <- function(file, grep_expression, sep, pattern="", replacement="") { - if(!file.exists(file)) return("#MISSING#") - file <- readLines(file, warn=FALSE) - tmp <- grep(grep_expression, file, value=TRUE) - tmp <- strsplit(tmp, sep) - tmp <- sapply(tmp, "[[", 2) - tmp <- gsub(pattern, replacement ,tmp) - if(all(!is.na(as.logical(tmp)))) return(as.vector(sapply(tmp, as.logical))) - if (all(!(regexpr("[a-zA-Z]",tmp) > 0))) { - tmp <- as.numeric(tmp) - } - return(tmp) -} -low_res <- get_info(paste0(outputdir,"/info.txt"),"^\\* Output ?resolution:",": ") -sum_spam_file <- paste0("0.5-to-",low_res,"_sum.spam") -print(sum_spam_file) - - -# Load input data -gdx <- path(outputdir,"fulldata.gdx") -land_ini_lr <- readGDX(gdx,"f10_land","f_land", format="first_found")[,"y1995",] -land_lr <- land(gdx,sum=FALSE,level="cell") -land_ini_hr <- read.magpie(path(in_folder,land_hr_file))[,"y1995",] -land_ini_hr <- land_ini_hr[,,getNames(land_lr)] -if(any(land_ini_hr < 0)) { - warning(paste0("Negative values in inital high resolution dataset detected and set to 0. Check the file ",land_hr_file)) - land_ini_hr[which(land_ini_hr < 0,arr.ind = T)] <- 0 -} - -# Start interpolation (use interpolate from luscale) -print("Interpolation") -land_hr <- interpolate( x = land_lr, - x_ini_lr = land_ini_lr, - x_ini_hr = land_ini_hr, - spam = path(outputdir,sum_spam_file), - prev_year = prev_year) - - -# Write outputs - -# Write spam files (crop weighted for each time step) -for(y in getYears(land_hr)) create_spam(land_hr[,y,"crop"],read.spam(path(outputdir,sum_spam_file)),fname=path(outputdir,sub("sum",paste("crop_weighted_mean",y,sep="_"),sum_spam_file))) - -# Disaggregate other cellular files -reshape_folder(outputdir) - - -print("Disaggregation crop types") -# detailed output (crop types, rf + if), disaggregate shares of cropland within cluster level to cellular level -# get rid of y1985 -land_hr <- land_hr[,-1,] - -# total crop tpye specific croparea -area <- croparea(gdx,level="cell",products="kcr",product_aggr=FALSE,water_aggr = FALSE) - -# share of crop types in terms of croparea -area_shr <- area/dimSums(area,dim=c(3.1,3.2)) - -# set inf to 0 -area_shr[is.na(area_shr)] <- 0 -area_shr[is.nan(area_shr)] <- 0 -area_shr[is.infinite(area_shr)] <- 0 - -# disaggregate share of crop types in terms of croparea to 0.5 resolution -area_shr_hr <- speed_aggregate(area_shr,t(read.spam(path(outputdir,sum_spam_file)))) - -# calculate crop tpye specific croparea in 0.5 resolution -area_hr <- area_shr_hr*setNames(land_hr[,,"crop"],NULL) - -print("Write netCDF outputs #1") -### replace crop in land_hr in with crop_kfo_rf, crop_kfo_ir, crop_kbe_rf and crop_kbe_ir -kbe <- c("betr","begr") -kfo <- setdiff(getNames(area_hr,dim=1),kbe) -crop_kfo_rf <- setNames(dimSums(area_hr[,,kfo][,,"rainfed"],dim=3),"crop_kfo_rf") -crop_kfo_ir <- setNames(dimSums(area_hr[,,kfo][,,"irrigated"],dim=3),"crop_kfo_ir") -crop_kbe_rf <- setNames(dimSums(area_hr[,,kbe][,,"rainfed"],dim=3),"crop_kbe_rf") -crop_kbe_ir <- setNames(dimSums(area_hr[,,kbe][,,"irrigated"],dim=3),"crop_kbe_ir") -crop_hr <- mbind(crop_kfo_rf,crop_kfo_ir,crop_kbe_rf,crop_kbe_ir) -#drop crop -land_hr <- land_hr[,,"crop",invert=TRUE] -#combine land_hr with crop_hr. -land_hr <- mbind(crop_hr,land_hr) -#write landpool -write.magpie(land_hr,path(outputdir,paste(land_hr_out_file,sep="_")),comment="unit: Mha per grid-cell") -write.magpie(land_hr,path(outputdir,paste(sub(".mz",".nc",land_hr_out_file),sep="_")),comment="unit: Mha per grid-cell", verbose=FALSE) - -print("Write netCDF outputs #2") -#calculate share of land pools in terms of tatal cell size -land_shr_hr <- land_hr/dimSums(land_hr,dim=3.1) -#write landpool shares -write.magpie(land_shr_hr,path(outputdir,paste(land_hr_share_out_file,sep="_")),comment="unit: grid-cell land area fraction") -write.magpie(land_shr_hr,path(outputdir,paste(sub(".mz",".nc",land_hr_share_out_file),sep="_")),comment="unit: grid-cell land area fraction", verbose=FALSE) diff --git a/scripts/output/single/rds_report.R b/scripts/output/single/rds_report.R deleted file mode 100644 index ceade894af..0000000000 --- a/scripts/output/single/rds_report.R +++ /dev/null @@ -1,44 +0,0 @@ -# | (C) 2008-2019 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 - -library(magclass) -library(magpie4) -library(lucode) -library(quitte) -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") -} - -load(paste0(outputdir, "/config.Rdata")) -gdx <- path(outputdir,"fulldata.gdx") -rds <- paste0(outputdir, "/report.rds") -runstatistics <- paste0(outputdir,"/runstatistics.rda") -resultsarchive <- "/p/projects/rd3mod/models/results/magpie" -############################################################################### - - -report <- getReport(gdx,scenario = cfg$title) -q <- as.quitte(report) -if(all(is.na(q$value))) stop("No values in reporting!") - -saveRDS(q,file=rds) - -if(file.exists(runstatistics) & dir.exists(resultsarchive)) { - stats <- list() - load(runstatistics) - if(!is.null(stats$id)) { - saveRDS(q,file=paste0(resultsarchive,"/",stats$id,".rds")) - cwd <- getwd() - setwd(resultsarchive) - system("ls 1*.rds > files") - setwd(cwd) - } -} diff --git a/scripts/output/single/report.R b/scripts/output/single/report.R deleted file mode 100644 index bbf2c93dbc..0000000000 --- a/scripts/output/single/report.R +++ /dev/null @@ -1,30 +0,0 @@ -# | (C) 2008-2019 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 - -library(magclass) -library(magpie4) -library(lucode) -library(quitte) -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") -} - -load(paste0(outputdir, "/config.Rdata")) -gdx <- path(outputdir,"fulldata.gdx") -mif <- paste0(outputdir, "/report.mif") -rda <- paste0(outputdir, "/report.rda") -############################################################################### - - -report <- getReport(gdx,scenario = cfg$title) -write.report2(report, file=mif) -saveRDS(as.quitte(report),file=rda) - diff --git a/scripts/output/single/scp.R b/scripts/output/single/scp.R deleted file mode 100644 index 5854fdfaa7..0000000000 --- a/scripts/output/single/scp.R +++ /dev/null @@ -1,255 +0,0 @@ -# | (C) 2008-2019 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 - - -library(gdx) -library(magclass) -library(magpie4) -library(lucode) -options("magclass.verbosity" = 1) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - - gdx <-'fulldata.gdx' - output_folder <- 'output/SSP5_Baseline' - output_folder <- 'output/ssp5_sugar_cons__2016-01-28_18.39.43' - gdx<-path(output_folder,"fulldata.gdx") - title <- "TEST" - - #Define arguments that can be read from command line - readArgs("gdx_file","output_folder","title") -} else{ - output_folder<-outputdir - gdx<-path(outputdir,"fulldata.gdx") -} -print("---") -print(paste0("Starting SCP report for ",title)) -############################################################################### - -sourceDir <- function(path, trace = TRUE, ...) { - for (nm in list.files(path, pattern = "\\.[RrSsQq]$")) { - if(trace) cat(nm,":") - source(file.path(path, nm), ...) - if(trace) cat("\n") - } -} - -sourceDir("/p/projects/landuse/users/florianh/magpie/libraries/nitrogen/R") - -#function to generate SSP variables based on MIF variables -MIF2SSP <- function(x) { - new <- NULL - - ### Land cover - ssp_name <- "Land Cover (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Cropland (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Cropland (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Cropland|Energy Crops (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Cropland|Energy Crops (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Forest (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Forest (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Forest|Forestry (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Forest|Managed (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Forest|Natural Forest (million ha)" - new <- mbind(new,setNames(new[,,"Land Cover|Forest (million ha)"],ssp_name) - setNames(x[,,"Land Cover|Forest|Managed (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Other Natural Land (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Other Arable Land (million Ha/yr)"],ssp_name) + setNames(x[,,"Land Cover|Other Land (million Ha/yr)"],ssp_name) - setNames(x[,,"Land Cover|Other Land|Urban (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Pasture (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Pasture (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Built-up Area (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Other Land|Urban (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Cropland|Irrigated (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Cropland|Irrigated (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Cropland|Energy Crops|Irrigated (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Cropland|Energy Crops|Irrigated (million Ha/yr)"],ssp_name)) - ssp_name <- "Land Cover|Cropland|Cereals (million ha)" - new <- mbind(new,setNames(x[,,"Land Cover|Cropland|Cereals (million Ha/yr)"],ssp_name)) - - #Emissions - ssp_name <- "Emissions|CO2|Land Use (Mt CO2/yr)" - tmp1<-x[,"y1995","Emissions|CO2|Land Use (Mt CO2/yr)"] - tmp2<-setNames(lowpass(x[,2:length(getYears(x)),"Emissions|CO2|Land Use (Mt CO2/yr)"],i=1,fix=NULL),ssp_name) - tmp3<-mbind(tmp1,tmp2) - new <- mbind(new,tmp3) - - ssp_name <- "Emissions|CH4|Land Use|Agriculture (Mt CH4/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CH4|Land Use (Mt CH4/yr)"],ssp_name)) - ssp_name <- "Emissions|CH4|Land Use|Agriculture|Rice (Mt CH4/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CH4|Land Use|Rice (Mt CH4/yr)"],ssp_name)) - ssp_name <- "Emissions|CH4|Land Use|Agriculture|AWM (Mt CH4/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CH4|Land Use|AWM (Mt CH4/yr)"],ssp_name)) - ssp_name <- "Emissions|CH4|Land Use|Agriculture|Enteric Fermentation (Mt CH4/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CH4|Land Use|Enteric Fermentation (Mt CH4/yr)"],ssp_name)) - - ssp_name <- "Emissions|N2O|Land Use|Agriculture (kt N2O/yr)" - new <- mbind(new,setNames(x[,,"Emissions|N2O|Land Use (kt N2O/yr)"],ssp_name)) - ssp_name <- "Emissions|N2O|Land Use|Agriculture|AWM (kt N2O/yr)" - new <- mbind(new,setNames(x[,,"Emissions|N2O|Land Use|AWM (kt N2O/yr)"],ssp_name)) - ssp_name <- "Emissions|N2O|Land Use|Agriculture|Cropland Soils (kt N2O/yr)" - new <- mbind(new,setNames(x[,,"Emissions|N2O|Land Use|Cropland Soils (kt N2O/yr)"],ssp_name)) - ssp_name <- "Emissions|N2O|Land Use|Agriculture|Pasture (kt N2O/yr)" - new <- mbind(new,setNames(x[,,"Emissions|N2O|Land Use|Pasture (kt N2O/yr)"],ssp_name)) - - #Prices - new <- mbind(new,x[,,c("Price|Primary Energy|Biomass (US$2005/GJ)","Price|Agriculture|Non-Energy Crops|Index (Index (2005 = 1))","Price|Agriculture|Non-Energy Crops and Livestock|Index (Index (2005 = 1))")]) - - #Yields - ssp_name <- c("Yield|Cereal (t DM/ha/yr)","Yield|Oilcrops (t DM/ha/yr)","Yield|Sugarcrops (t DM/ha/yr)") - new <- mbind(new,setNames(x[,,c("Yield|Cereal (tDM/ha/yr)","Yield|Oilcrops (tDM/ha/yr)","Yield|Sugarcrops (tDM/ha/yr)")],ssp_name)) - - #Water - new <- mbind(new,x[,,c("Water|Withdrawal|Irrigation (million m3/yr)")]) - - #Fertilizer use - ssp_name <- "Fertilizer Use|Nitrogen (Tg N/yr)" - new <- mbind(new,setNames(x[,,"Fertilizer Use|Nitrogen (Tg Nr/yr)"],ssp_name)) - - #Food Demand (EJ/yr) - new <- mbind(new,x[,,"Food Energy Demand (EJ/yr)"]) - new <- mbind(new,x[,,"Food Energy Demand|Livestock (EJ/yr)"]) - - #Food Demand (kcal/cap/day) - new <- mbind(new,setNames((x[,,"Food Energy Demand (EJ/yr)"] / setNames(x[,,"Population (million cap)"],NULL)) * 10^9 * 1/4.1868 / 365.25,"Food Demand (kcal/cap/day)")) - new <- mbind(new,setNames((x[,,"Food Energy Demand|Livestock (EJ/yr)"] / setNames(x[,,"Population (million cap)"],NULL)) * 10^9 * 1/4.1868 / 365.25,"Food Demand|Livestock (kcal/cap/day)")) - new <- mbind(new,setNames(new[,,"Food Demand (kcal/cap/day)"] - setNames(new[,,"Food Demand|Livestock (kcal/cap/day)"],NULL),"Food Demand|Crops (kcal/cap/day)")) - - #Agricultural Demand - new <- mbind(new,x[,,c("Agricultural Demand (million t DM/yr)", - "Agricultural Demand|Food (million t DM/yr)", - "Agricultural Demand|Food|Crops (million t DM/yr)", - "Agricultural Demand|Food|Livestock (million t DM/yr)", - "Agricultural Demand|Non-Food (million t DM/yr)", - "Agricultural Demand|Non-Food|Crops (million t DM/yr)", - "Agricultural Demand|Non-Food|Livestock (million t DM/yr)", - "Agricultural Demand|Feed (million t DM/yr)", - "Agricultural Demand|Feed|Crops (million t DM/yr)", - "Agricultural Demand|Feed|Livestock (million t DM/yr)", - "Agricultural Demand|Bioenergy (million t DM/yr)", - "Agricultural Demand|Bioenergy|1st generation (million t DM/yr)", - "Agricultural Demand|Bioenergy|2nd generation (million t DM/yr)")]) - - #Agricultural Production - new <- mbind(new,x[,,c("Agricultural Production (million t DM/yr)","Agricultural Production|Livestock (million t DM/yr)","Agricultural Production|Non-Energy Crops (million t DM/yr)","Agricultural Production|Non-Energy Crops|Cereals (million t DM/yr)","Agricultural Production|Energy Crops (million t DM/yr)")]) - - ssp_name <- "Primary Energy|Biomass|1st Generation (EJ/yr)" - reg <- bioenergy(gdx,level = "reg",unit = "EJ")[,,"1st generation bioenergy"] - glo <- bioenergy(gdx,level = "glo",unit = "EJ")[,,"1st generation bioenergy"] - new <- mbind(new,setNames(mbind(reg,glo),ssp_name)) - - ssp_name <- "Primary Energy|Biomass|Energy Crops (EJ/yr)" - reg <- production(gdx,level = "reg",unit = "EJ",crops=c("begr","betr"),crop_aggr = TRUE) - glo <- production(gdx,level = "glo",unit = "EJ",crops=c("begr","betr"),crop_aggr = TRUE) - new <- mbind(new,setNames(mbind(reg,glo),ssp_name)) - - #cumulative CO2 emissions - ssp_name <- "Emissions|CO2|Land Use|cumulative (Mt CO2 cumulative)" - reg <- emissions(gdx, cumulative=T, type="co2_c",level="reg",y1995=T)* 44/12 - glo <- emissions(gdx, cumulative=T, type="co2_c",level="glo",y1995=T)* 44/12 - new <- mbind(new,setNames(mbind(reg,glo),ssp_name)) - - #cumulative CH4 emissions - ssp_name <- "Emissions|CH4|Land Use|cumulative (Mt CH4 cumulative)" - reg <- emissions(gdx, cumulative=T, type="ch4",level="reg",y1995=T) - glo <- emissions(gdx, cumulative=T, type="ch4",level="glo",y1995=T) - new <- mbind(new,setNames(mbind(reg,glo),ssp_name)) - - #cumulative N2O emissions - ssp_name <- "Emissions|N2O|Land Use|cumulative (Mt N2O cumulative)" - reg <- emissions(gdx, cumulative=T, type="n2o_n",level="reg",y1995=T) * 44/28 - glo <- emissions(gdx, cumulative=T, type="n2o_n",level="glo",y1995=T) * 44/28 - new <- mbind(new,setNames(mbind(reg,glo),ssp_name)) - - return(new) -} - -#Get report from MAgPIE run -rep_magpie <- getReport(gdx) - -#generate SSP variables based on MIF variables -rep_magpie <- MIF2SSP(rep_magpie) - -kcr <- readGDX(gdx,"kcr") - -#add nitrogen variables -reg <- nr_cropland_budget(gdx) -reg <- setNames(reg,paste0("Nitrogen Budget|",getNames(reg)," (Tg Nr)")) -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(nr_cropland_budget(gdx),dim=3) -getNames(reg) <- "Nitrogen Budget|Cropland Losses (Tg Nr)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_dem_convby_substitutes")[,,"level"],dim=3) -getNames(reg) <- "Benni|Conversion byproduct substitutes in DM (Tg DM)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_dem_scp")[,,"level"],dim=3) -getNames(reg) <- "Benni|MP substrate in DM (Mt DM)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_dem_scp")[,,kcr][,,"level"]*readGDX(gdx,"im_attributes_harvest")[,,"nr"][,,kcr],dim=3) -getNames(reg) <- "Benni|MP substrate in Nr (Mt Nr)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -kli <- readGDX(gdx,"kli") -reg <- dimSums(readGDX(gdx,"ov_dem_feed")[,,"level"][,,kcr],dim=3) -getNames(reg) <- "Benni|Feed DM (Mt DM)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_dem_feed")[,,"level"][,,"scp"],dim=3) -getNames(reg) <- "Benni|Feed MP DM (Mt DM)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_dem_feed")[,,"level"][,,kcr]*readGDX(gdx,"im_attributes_harvest")[,,"nr"][,,kcr],dim=3) -getNames(reg) <- "Benni|Feed Nr (Mt Nr)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_scp_feed")[,,"level"][,,"nr"],dim=3) -getNames(reg) <- "Benni|Feed MP Nr (Mt Nr)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_dem_feed")[,,"level"][,,"foddr"],dim=3) -getNames(reg) <- "Benni|Feed Forage DM (Mt DM)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(readGDX(gdx,"ov_dem_feed")[,,"level"][,,"foddr"]*readGDX(gdx,"im_attributes_harvest")[,,"nr"][,,"foddr"],dim=3) -getNames(reg) <- "Benni|Feed Forage Nr (Mt Nr)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -kcr <- readGDX(gdx,"kcr") -reg <- dimSums(readGDX(gdx,"ov_dem_convby_substitutes",select = list(type="level"))*collapseNames(readGDX(gdx,"im_attributes_harvest")[,,kcr][,,"nr"]),dim=3) -getNames(reg) <- "Benni|Conversion byproduct substitutes in Nr (Tg Nr)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - -reg <- dimSums(collapseNames(readGDX(gdx,"ov20_convby_use",select = list(type="level"))[,,"feed"])*collapseNames(readGDX(gdx,"f20_attributes_convby")[,,"nr"]),dim=3) -getNames(reg) <- "Benni|Conversion byproduct feeduse (Tg Nr)" -glo <- dimSums(reg,dim=1) -rep_magpie <- mbind(rep_magpie,mbind(reg,glo)) - - - -rep_magpie <- rep_magpie[,c(2005,2010,2030,2050),] - -#write report -write.report(rep_magpie,file=path("output/scp_jun16.csv"),scenario=title,model="MAgPIE",append=TRUE) - -print(paste0("Finished SCP report for ",title)) -print("---") diff --git a/scripts/output/single/scp_feed.R b/scripts/output/single/scp_feed.R deleted file mode 100644 index 8886ebfb4d..0000000000 --- a/scripts/output/single/scp_feed.R +++ /dev/null @@ -1,110 +0,0 @@ -# | (C) 2008-2019 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 - - -library(gdx) -library(magclass) -library(magpie4) -library(lucode) -options("magclass.verbosity" = 1) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - - gdx <-'fulldata.gdx' - output_folder <- 'output/SSP5_Baseline' - output_folder <- 'output/ssp5_sugar_cons__2016-01-28_18.39.43' - gdx<-path(output_folder,"fulldata.gdx") - title <- "TEST" - - #Define arguments that can be read from command line - readArgs("gdx_file","output_folder","title") -} else{ - output_folder<-outputdir - gdx<-path(outputdir,"fulldata.gdx") -} -print("---") -print(paste0("Starting SCP report for ",title)) -############################################################################### - - - - - -library(magpiesets) - - - -kcr<-readGDX(gdx,"kcr") -kli<-readGDX(gdx,"kli") -cereals<-findset("cereals") -conc<-setdiff(kcr,c(cereals,"foddr")) -attributes<-readGDX(gdx,"im_attributes_harvest")[,,c("dm","nr")] -attributes<-readGDX(gdx,"im_attributes_harvest")[,,c("dm","nr")] -attributes_kcr<-attributes[,,kcr] -attributes_pasture<-attributes[,,"pasture"] -attributes_scp<-readGDX(gdx,"fm_attributes_scp")[,,c("dm","nr")] -attributes_kli<-readGDX(gdx,"f55_attributes_livstproducts")[,,c("dm","nr")] -feed<-collapseNames(readGDX(gdx,"ov_dem_feed")[,,"level"]) -feed_convby<-collapseNames(readGDX(gdx,"ov_convby_feed")[,,"level"])[,,c("dm","nr")] -feed_res<-collapseNames(readGDX(gdx,"ov_res_use_feed")[,,"level"])[,,c("dm","nr")] -scav<-collapseNames(readGDX(gdx,"fm_scavenging_1995")) - -feed_pasture <-add_dimension(dimSums((feed[,,"pasture"]+scav)*attributes_pasture,dim=3.2),dim = 3.1,add = "feed",nm="Grazing") -feed_conc <-add_dimension(dimSums(feed[,,conc]*attributes_kcr[,,conc],dim=3.2),dim = 3.1,add = "feed",nm="Other concentrates") -feed_foddr <-add_dimension(dimSums(feed[,,"foddr"]*attributes_kcr[,,"foddr"],dim=3.2),dim = 3.1,add = "feed",nm="Forage") -feed_cer <-add_dimension(dimSums(feed[,,cereals]*attributes_kcr[,,cereals],dim=3.2),dim = 3.1,add = "feed",nm="Cereals") -feed_scp <-add_dimension(dimSums(feed[,,"scp"]*attributes_scp,dim=3.2),dim = 3.1,add = "feed",nm="Microbial Protein") -feed_convby <-add_dimension(feed_convby,dim = 3.1,add = "feed",nm="Conversion Byproducts") -feed_res <-add_dimension(feed_res,dim = 3.1,add = "feed",nm="Crop residues") -feed_food <-add_dimension(add_dimension(collapseNames(feed[,,"non_eaten_food"]),dim=3.2,add="attributes",nm="dm"),dim = 3.1,add = "feed",nm="Non eaten food") -feed_food <-add_columns(feed_food,addnm = "nr",dim = 3.3) -feed_food[,,"nr"]<-feed_food[,,"dm"]*0.02 # based on wirsenius - - -kli2<-paste0(kli,2) -feed2<-feed -getNames(feed2,dim=2)<-paste0(getNames(feed2,dim=2),"2") -feed2<-feed2[,,kli2] -attributes_kli2<-attributes_kli -getNames(attributes_kli2)<-paste0(getNames(attributes_kli2),2) -feed_kli <-add_dimension(dimSums(feed2[,,kli2]*attributes_kli2,dim=3.2),dim = 3.1,add = "feed",nm="Animal Feed") - - -out<-mbind(feed_scp,feed_cer) -out<-mbind(out,feed_convby) -out<-mbind(out,feed_conc) -out<-mbind(out,feed_foddr) -out<-mbind(out,feed_res) -out<-mbind(out,feed_kli) -out<-mbind(out,feed_pasture) -out<-mbind(out,feed_food) -out<-mbind(out,colSums(out)) -out<-as.magpie(aperm(unwrap(out),perm = c(1,2,4,3,5))) -tmp<-dimSums(out,dim=3.1) -out<-add_columns(out,addnm = "livst_all",dim = 3.1) -out[,,"livst_all"]<-tmp - -out2<-round(out,4)[,c("y2005","y2050")] -write.magpie(collapseNames(out2[,,"nr"]),file_name = "feed_nr.csv",file_type = "cs3") -out3<-round(out,2)[,c("y2005","y2050")] -write.magpie(collapseNames(out3[,,"dm"]),file_name = "feed_dm.csv",file_type = "cs3") - -products<-collapseNames(readGDX(gdx,"ov_prod_reg")[,,"level"][,,kli])*attributes_kli -products<-mbind(products,colSums(products)) -tmp<-dimSums(products,dim=3.1) -products<-add_columns(products,addnm = "livst_all",dim = 3.1) -products[,,"livst_all"]<-tmp - -fbask<-out/products -fbask2<-round(fbask,2)[,c("y2005","y2050")] - -#write report -write.report(fbask2,file=path("output/scp_feed_jun16.csv"),scenario=title,model="MAgPIE",append=TRUE) - -print(paste0("Finished SCP report for ",title)) -print("---") diff --git a/scripts/output/single/sustag_report.R b/scripts/output/single/sustag_report.R deleted file mode 100644 index 88743e7e35..0000000000 --- a/scripts/output/single/sustag_report.R +++ /dev/null @@ -1,391 +0,0 @@ -# | (C) 2008-2019 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 - - -library(gdx) -library(magclass) -library(magpie4) -library(lucode) -options("magclass.verbosity" = 1) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - - gdx <-'fulldata.gdx' - output_folder <- '/p/projects/landuse/users/weindl/1SUSTAg/magpie/output/default_2018-05-25_22.29.24' - gdx<-path(output_folder,"fulldata.gdx") - title <- "TEST" - - #Define arguments that can be read from command line - readArgs("gdx_file","output_folder","title") -} else{ - load(paste0(outputdir, "/config.Rdata")) - gdx <- path(outputdir,"fulldata.gdx") - output_folder <- outputdir - title <- cfg$title - -} -print("---") -print(paste0("Starting SUSTAg report for ",title)) - -############################################################################### - -#function to generate SUSTAg indicators based on MIF variables -MIF2SUSTAg <- function(x,model="MAgPIE",scenario="default") { - x <- x[,-1,] - new <- NULL - - - #Emissions - name <- "Emissions|N2O|Agriculture (Mt N2O/yr)" - new <- mbind(new,setNames(x[,,"Emissions|N2O|Land|+|Agriculture (Mt N2O/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|CH4|Agriculture (Mt CH4/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CH4|Land|+|Agriculture (Mt CH4/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|CO2|AFOLU (Mt CO2/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CO2|Land (Mt CO2/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|CO2|AFOLU|Land-use Change (Mt CO2/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CO2|Land|+|Land-use Change (Mt CO2/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|CO2|AFOLU|Climate Change (Mt CO2/yr)" - new <- mbind(new,setNames(x[,,"Emissions|CO2|Land|+|Climate Change (Mt CO2/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|NH3|Agriculture (Mt NH3/yr)" - new <- mbind(new,setNames(x[,,"Emissions|NH3|Land|+|Agriculture (Mt NH3/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|NOx|Agriculture (Mt NO2/yr)" - new <- mbind(new,setNames(x[,,"Emissions|NO2|Land|+|Agriculture (Mt NO2/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|NO3-|Agriculture (Mt NO3/yr)" - new <- mbind(new,setNames(x[,,"Emissions|NO3-|Land|+|Agriculture (Mt NO3-/yr)"],paste(model,scenario,name,sep="."))) - - #Cumulative - name <- "Emissions|CO2|AFOLU|Cumulative (Gt CO2)" - new <- mbind(new,setNames(x[,,"Emissions|CO2|Land|Cumulative (Gt CO2)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|CO2|AFOLU|Cumulative|Land-use Change (Gt CO2)" - new <- mbind(new,setNames(x[,,"Emissions|CO2|Land|Cumulative|+|Land-use Change (Gt CO2)"],paste(model,scenario,name,sep="."))) - - name <- "Emissions|CO2|AFOLU|Cumulative|Climate Change (Gt CO2)" - new <- mbind(new,setNames(x[,,"Emissions|CO2|Land|Cumulative|+|Climate Change (Gt CO2)"],paste(model,scenario,name,sep="."))) - - - - ### Land cover - name <- "Land Cover|Cropland (million ha)" - new <- mbind(new,setNames(x[,,"Resources|Land Cover|+|Cropland (million ha)"],paste(model,scenario,name,sep="."))) - - name <- "Land Cover|Pasture (million ha)" - new <- mbind(new,setNames(x[,,"Resources|Land Cover|+|Pastures and Rangelands (million ha)"],paste(model,scenario,name,sep="."))) - - name <- "Land Cover|Forest (million ha)" - new <- mbind(new,setNames(x[,,"Resources|Land Cover|+|Forest (million ha)"],paste(model,scenario,name,sep="."))) - - name <- "Land Cover|Other Land (million ha)" - new <- mbind(new,setNames(x[,,"Resources|Land Cover|+|Other Land (million ha)"],paste(model,scenario,name,sep="."))) - - - ### Water - name <- "Land Cover|Cropland|Area actually irrigated (million ha)" - new <- mbind(new,setNames(x[,,"Resources|Land Cover|Cropland|Area actually irrigated (million ha)"],paste(model,scenario,name,sep="."))) - - name <- "Land Cover|Cropland|Area equipped for irrigation (million ha)" - new <- mbind(new,setNames(x[,,"Resources|Land Cover|Cropland|Area equipped for irrigation (million ha)"],paste(model,scenario,name,sep="."))) - - name <- "Water|Water Withdrawal|Irrigation (km3/yr)" - new <- mbind(new,setNames(x[,,"Resources|Water|Withdrawal|Agriculture (km3/yr)"],paste(model,scenario,name,sep="."))) - - #????# - #????# - #????# - #????# - #????# - - - ### Nitrogen - name <- "Nitrogen|Cropland Budget|Inputs (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Inputs (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Nitrogen|Cropland Budget|Inputs|Fertilizer (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Inputs|+|Fertilizer (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Nitrogen|Cropland Budget|Inputs|Manure (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Inputs|+|Manure From Stubble Grazing (Mt Nr/yr)"] - + x[,,"Resources|Nitrogen|Cropland Budget|Inputs|+|Manure Recycled from Confinements (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Nitrogen|Cropland Budget|Inputs|Other nitrogen inputs (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Inputs (Mt Nr/yr)"] - - x[,,"Resources|Nitrogen|Cropland Budget|Inputs|+|Fertilizer (Mt Nr/yr)"] - - x[,,"Resources|Nitrogen|Cropland Budget|Inputs|+|Manure From Stubble Grazing (Mt Nr/yr)"] - - x[,,"Resources|Nitrogen|Cropland Budget|Inputs|+|Manure Recycled from Confinements (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Nitrogen|Cropland Budget|Withdrawal (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Withdrawals (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Nitrogen|Cropland Budget|Withdrawal|Harvested Crops (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Withdrawals|+|Harvested Crops (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Nitrogen|Cropland Budget|Surplus (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Balance|+|Nutrient Surplus (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - #!!Benni!# #????# different name ???????????????????????????????????????????????????? - name <- "Nitrogen|Cropland Budget|Balance|Soil Organic Matter Loss (Mt Nr/yr)" - new <- mbind(new,setNames(x[,,"Resources|Nitrogen|Cropland Budget|Balance|+|Soil Organic Matter Loss (Mt Nr/yr)"],paste(model,scenario,name,sep="."))) - - - -# ### Phosphorus -# name <- "Phosphorus|Cropland Budget|Inputs (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Inputs (Mt P/yr)"],paste(model,scenario,name,sep="."))) -# -# name <- "Phosphorus|Cropland Budget|Inputs|Fertilizer (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Inputs|+|Fertilizer (Mt P/yr)"],paste(model,scenario,name,sep="."))) -# -# name <- "Phosphorus|Cropland Budget|Inputs|Manure (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Inputs|+|Manure From Stubble Grazing (Mt P/yr)"] -# + x[,,"Resources|Phosphorus|Cropland Budget|Inputs|+|Manure Recycled from Confinements (Mt P/yr)"],paste(model,scenario,name,sep="."))) -# -# name <- "Phosphorus|Cropland Budget|Inputs|Other Phosphorus inputs (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Inputs (Mt P/yr)"] -# - x[,,"Resources|Phosphorus|Cropland Budget|Inputs|+|Fertilizer (Mt P/yr)"] -# - x[,,"Resources|Phosphorus|Cropland Budget|Inputs|+|Manure From Stubble Grazing (Mt P/yr)"] -# - x[,,"Resources|Phosphorus|Cropland Budget|Inputs|+|Manure Recycled from Confinements (Mt P/yr)"],paste(model,scenario,name,sep="."))) -# -# name <- "Phosphorus|Cropland Budget|Withdrawal (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Withdrawals (Mt P/yr)"],paste(model,scenario,name,sep="."))) -# -# name <- "Phosphorus|Cropland Budget|Withdrawal|Harvested Crops (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Withdrawals|+|Harvested Crops (Mt P/yr)"],paste(model,scenario,name,sep="."))) -# -# name <- "Phosphorus|Cropland Budget|Surplus (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Balance|+|Nutrient Surplus (Mt P/yr)"],paste(model,scenario,name,sep="."))) -# -# #????# different name ???????????????????????????????????????????????????? -# name <- "Phosphorus|Cropland Budget|Balance|Soil Organic Matter Loss (Mt P/yr)" -# new <- mbind(new,setNames(x[,,"Resources|Phosphorus|Cropland Budget|Balance|+|Soil Organic Matter Loss (Mt P/yr)"],paste(model,scenario,name,sep="."))) - - - ### Production - name <- "Production|Bioenergy crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Bioenergy crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Forestry (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Forest products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Crop residues (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Crop residues (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Forage (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Forage (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Livestock products (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Livestock products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Pasture (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Pasture (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Secondary products (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|+|Secondary products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Secondary products|Oil (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|Secondary products|+|Oils (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Secondary products|Ethanol (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|Secondary products|+|Ethanol (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Production|Secondary products|Sugar (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Production|Secondary products|+|Sugar (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - - - ### Prices - - - #????# aktuell nur aggregiert verfgbar fr alle food items ?????????????? - name <- "Prices|Producer Price Index|Food (index relative to 2010)" - new <- mbind(new,setNames(x[,,"Prices|Food Price Index (Index 2010=100)"],paste(model,scenario,name,sep="."))) - -# #????# Index fr food crops fehlt ?????????????????????????????????????? -# name <- "Prices|Producer Price Index|Crops (index relative to 2010)" -# new <- mbind(new,setNames(x[,,"Prices|Food Price Index (Index 2010=100)"],paste(model,scenario,name,sep="."))) - -# #????# Index fr livestock fehlt ????????????????????????????????????????? -# name <- "Prices|Producer Price Index|Livestock (index relative to 2010)" -# new <- mbind(new,setNames(x[,,"Prices|Food Price Index (Index 2010=100)"],paste(model,scenario,name,sep="."))) - - - name <- "Prices|Producer Prices|Ethanol (US$05/tDM)" - new <- mbind(new,setNames(x[,,"Prices|Agriculture|Ethanol (US$05/tDM)"],paste(model,scenario,name,sep="."))) - - name <- "Prices|Producer Prices|Biodiesel (US$05/tDM)" - new <- mbind(new,setNames(x[,,"Prices|Agriculture|Oils (US$05/tDM)"],paste(model,scenario,name,sep="."))) - - - - ### Costs - - #crops!!!!!!!!!!!! - name <- "Costs|Total production costs|Factor costs|Crops (million US$05/yr)" - new <- mbind(new,setNames(x[,,"Costs|MainSolve|Input Factors (million US$05/yr)"],paste(model,scenario,name,sep="."))) - - #???# livestock excl feed!!!!!!!!!!! - name <- "Costs|Total production costs|Factor costs|Livestock excluding feed (million US$05/yr)" - new <- mbind(new,setNames(x[,,"Costs|MainSolve|Input Factors (million US$05/yr)"],paste(model,scenario,name,sep="."))) - - - - ### Demand - name <- "Demand|Agricultural Supply Chain Loss|Crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Agricultural Supply Chain Loss|+|Crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Feed|Crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Feed|+|Crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Food|Crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Food|+|Crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Material|Crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Material|+|Crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Processing|Crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Processing|+|Crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Seed|Crops (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Seed|+|Crops (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - - name <- "Demand|Agricultural Supply Chain Loss|Livestock products (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Agricultural Supply Chain Loss|+|Livestock products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Feed|Livestock products (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Feed|+|Livestock products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Food|Livestock products (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Food|+|Livestock products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Material|Livestock products (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Material|+|Livestock products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Seed|Livestock products (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Seed|+|Livestock products (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - - name <- "Demand|Bioenergy|Secondary products|Oil (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Bioenergy|Secondary products|+|Oils (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - name <- "Demand|Bioenergy|Secondary products|Ethanol (Mt DM/yr)" - new <- mbind(new,setNames(x[,,"Demand|Bioenergy|Secondary products|+|Ethanol (Mt DM/yr)"],paste(model,scenario,name,sep="."))) - - - - ### Food availability - - name <- "Food availability (kcal/cap/day)" - reg.foodkcal <- Kcal(gdx,level = "reg",products = "kfo",product_aggr = TRUE,calibrated=TRUE, attributes = "kcal", per_capita = TRUE) - glo.foodkcal <- Kcal(gdx,level = "glo",products = "kfo",product_aggr = TRUE,calibrated=TRUE, attributes = "kcal", per_capita = TRUE) - new <- mbind(new,setNames(mbind(reg.foodkcal,glo.foodkcal)[,-1,],paste(model,scenario,name,sep="."))) - - # name <- "Food availability (protein/cap/day)" - # reg.foodprot <- Kcal(gdx,level = "reg",products = "kfo",product_aggr = TRUE,calibrated=TRUE, attributes = "protein", per_capita = TRUE) - # glo.foodprot <- Kcal(gdx,level = "glo",products = "kfo",product_aggr = TRUE,calibrated=TRUE, attributes = "protein", per_capita = TRUE) - # new <- mbind(new,setNames(mbind(reg.foodprot,glo.foodprot)[,-1,],paste(model,scenario,name,sep="."))) - # Hinweis kcal-Funktion kann bei attributes "proteins" die produkte nicht agregieren - -###################################################### - - ### Food Intake - name <- "Food Intake (kcal/cap/day)" - reg.intake <- Intake(gdx,level = "reg",calibrated=TRUE, pregnancy = TRUE, per_capita = TRUE, age = FALSE) - glo.intake <- Intake(gdx,level = "glo",calibrated=TRUE, pregnancy = TRUE, per_capita = TRUE, age = FALSE) - new <- mbind(new,setNames(mbind(reg.intake,glo.intake)[,-1,],paste(model,scenario,name,sep="."))) - - name <- "Food Intake|Staple products (kcal/cap/day)" - reg <- (Kcal(gdx,level = "reg",products = "kfo_st",product_aggr = TRUE,attributes = "kcal")/reg.foodkcal)*reg.intake - glo <- (Kcal(gdx,level = "glo",products = "kfo_st",product_aggr = TRUE,attributes = "kcal")/glo.foodkcal)*glo.intake - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - - name <- "Food Intake|Crops|Fruits, Vegetables & Nuts (kcal/cap/day)" - reg <- (Kcal(gdx,level = "reg",products = "others",product_aggr = FALSE,attributes = "kcal")/reg.foodkcal)*reg.intake - glo <- (Kcal(gdx,level = "glo",products = "others",product_aggr = FALSE,attributes = "kcal")/glo.foodkcal)*glo.intake - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - - name <- "Food Intake|Livestock products (kcal/cap/day)" - reg <- (Kcal(gdx,level = "reg",products = "kfo_ap",product_aggr = TRUE,attributes = "kcal")/reg.foodkcal)*reg.intake - glo <- (Kcal(gdx,level = "glo",products = "kfo_ap",product_aggr = TRUE,attributes = "kcal")/glo.foodkcal)*glo.intake - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - - name <- "Food Intake|Empty calories (kcal/cap/day)" - reg <- (Kcal(gdx,level = "reg",products = "kfo_pf",product_aggr = TRUE,attributes = "kcal")/reg.foodkcal)*reg.intake - glo <- (Kcal(gdx,level = "glo",products = "kfo_pf",product_aggr = TRUE,attributes = "kcal")/glo.foodkcal)*glo.intake - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - - - ### Food Expenditure - name <- "Food Expenditure (US$05/cap/yr)" - reg <- FoodExpenditure(gdx,level = "reg",products = "kfo",product_aggr = TRUE, per_capita = TRUE) - glo <- FoodExpenditure(gdx,level = "glo",products = "kfo",product_aggr = TRUE, per_capita = TRUE) - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - -###################################################### - - ### Bioenergy Production - name <- "Energy|Bioenergy (EJ/yr)" - reg <- collapseNames(demand(gdx,level="reg",products = "kall",product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 - glo <- collapseNames(demand(gdx,level="glo",products = "kall",product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - - name <- "Energy|Bioenergy|2nd generation bioenergy crops (EJ/yr)" - reg <- collapseNames(demand(gdx,level="reg",products = c("betr","begr"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 - glo <- collapseNames(demand(gdx,level="glo",products = c("betr","begr"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - - name <- "Energy|Bioenergy|Residues (EJ/yr)" - reg <- collapseNames(demand(gdx,level="reg",products = c("res_cereals","res_fibrous","res_nonfibrous"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 - glo <- collapseNames(demand(gdx,level="glo",products = c("res_cereals","res_fibrous","res_nonfibrous"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 - new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - -# name <- "Energy|Bioenerg|1st generation bioenergy (EJ/yr)" -# reg <- collapseNames(demand(gdx,level="reg",products = "kall",product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 -# - collapseNames(demand(gdx,level="reg",products = c("betr","begr"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 -# - collapseNames(demand(gdx,level="reg",products = c("res_cereals","res_fibrous","res_nonfibrous"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 -# glo <- collapseNames(demand(gdx,level="glo",products = "kall",product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 -# - collapseNames(demand(gdx,level="glo",products = c("betr","begr"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 -# - collapseNames(demand(gdx,level="glo",products = c("res_cereals","res_fibrous","res_nonfibrous"),product_aggr = TRUE,attributes = "ge")[,,"bioenergy"])/1000 -# new <- mbind(new,setNames(mbind(reg,glo)[,-1,],paste(model,scenario,name,sep="."))) - - - return(new) -} - -#Get report from MAgPIE run -rep_magpie_raw <- getReport(gdx,scenario=title) -write.report2(rep_magpie_raw,file=path(outputdir,"report_magpie.csv"),scenario=title,model="MAgPIE",append=F) - - -#generate SUSTAg indicators based on MIF variables -rep_magpie <- MIF2SUSTAg(rep_magpie_raw,scenario=title) - - - -#rep_magpie <- rep_magpie[,c(2005,2010,2015,2020,2030,2040,2050,2060,2070,2080,2090,2100),] -rep_magpie <- rep_magpie[,c(2000,2010,2020,2030,2040,2050,2060,2070,2080),] - - -#set infinite values to NA -rep_magpie[is.infinite(rep_magpie)] <- NA - - -#write report -write.report2(rep_magpie,file=path(outputdir,"sustag.csv"),scenario=title,model="MAgPIE",append=F) - -print(paste0("Finished SUSTAg report for ",title)) -print("---") diff --git a/scripts/output/single/validation.R b/scripts/output/single/validation.R deleted file mode 100644 index 85c9d6d33e..0000000000 --- a/scripts/output/single/validation.R +++ /dev/null @@ -1,38 +0,0 @@ -# | (C) 2008-2019 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 - -library(magpie4) - -############################# BASIC CONFIGURATION ############################# -if(!exists("source_include")) { - outputdir <-"." -} - -load(paste0(outputdir, "/config.Rdata")) -hist <- c(paste0(outputdir, "/validation.mif"), "input/validation.mif") -file <- paste0(outputdir, "/", cfg$title, "_validation.pdf") -reportfile <- paste0(outputdir, "/report.mif") -gdx <- paste0(outputdir, "/fulldata.gdx") -runinfo <- paste0(outputdir, "/", cfg$title, "_*.RData") -############################################################################### - -#### Choose validation data ### -# Use first hist file that can be found - -for(h in hist) { - if(file.exists(h)) break -} - -runinfo <- Sys.glob(runinfo) -if(length(runinfo)>1) { - runinfo <- runinfo[1] - warnings("More than one runinfo file found. The first one will be used.") -} else if (length(runinfo)==0) { - runinfo <- NULL -} - -validation(gdx=gdx, hist=h, file = file, runinfo=runinfo, reportfile=reportfile, scenario=cfg$title) diff --git a/scripts/output/validation.R b/scripts/output/validation.R new file mode 100644 index 0000000000..c8e7f24d89 --- /dev/null +++ b/scripts/output/validation.R @@ -0,0 +1,49 @@ +# | (C) 2008-2025 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: creates a validation pdf file for a run (long version - single crop types) +# comparison script: FALSE +# position: 4 +# --------------------------------------------------------------- + + +library(magpie4) +library(gms) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <-"." +} + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +hist <- c(paste0(outputdir, "/validation.mif"), "input/validation.mif") +file <- paste0(outputdir, "/", cfg$title, "_validation.pdf") +reportrds <- paste0(outputdir, "/report.rds") +gdx <- paste0(outputdir, "/fulldata.gdx") +runinfo <- paste0(outputdir, "/", cfg$title, "_*.RData") +############################################################################### + +#### Choose validation data ### +# Use first hist file that can be found + +for(h in hist) { + if(file.exists(h)) break +} + +runinfo <- Sys.glob(runinfo) +if(length(runinfo)>1) { + runinfo <- runinfo[1] + warnings("More than one runinfo file found. The first one will be used.") +} else if (length(runinfo)==0) { + runinfo <- NULL +} + +getReport <- NULL +if(file.exists(reportrds)) getReport <- readRDS(reportrds) + +validation(gdx=gdx, hist=h, file = file, runinfo=runinfo, scenario=cfg$title, getReport=getReport) diff --git a/scripts/output/validation_cell.R b/scripts/output/validation_cell.R new file mode 100644 index 0000000000..9c6e5fab09 --- /dev/null +++ b/scripts/output/validation_cell.R @@ -0,0 +1,219 @@ +# | (C) 2008-2025 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: Comparison at cellular level of land and crop types with LUH3 and MAPSPAM +# comparison script: FALSE +# --------------------------------------------------------------- + +library(magpie4) +library(luscale) +library(luplot) +library(lusweave) +library(magpiesets) +library(gdx2) + +############################# BASIC CONFIGURATION ############################## +if (!file.exists(paste0(outputdir, "/LUH3_croparea_0.5.mz"))) stop("Cell validation is not possible. LUH3_croparea_0.5.mz and MAPSPAM_croparea_0.5.mz files are missing") +map_file <- Sys.glob(file.path(outputdir, "/clustermap_*.rds")) +gdx <- file.path(outputdir, "/fulldata.gdx") +cfg <- gms::loadConfig(file.path(outputdir, "/config.yml")) +crops <- c("maiz", "rice_pro", "soybean", "tece") +mapping <- readRDS(map_file) +################################################################################ + +#### Folder for saving results +out_dir <- paste0(outputdir, "/CellularValidation/") +if (!dir.exists(out_dir)) dir.create(out_dir) + +######## Land use types comparison with LUH ######## +magpie_LU <- land(gdx, level = "cell") +historical_LU <- readGDX(gdx, "f10_land") + +LU <- plotCorrHist2D( + x = historical_LU, y = magpie_LU, xlab = "LUH3 \n (mio.ha)", ylab = "MAgPIE \n (mio.ha)", bins = 35, + folder = out_dir, file = "/validationLUcell", breaks = c(1, 10, 100), nrows = 2, ncols = 2, axisFont = 10, + axisTitleFont = 11, TitleFontSize = 12, legendTitleFont = 10, legendTextFont = 8, statFont = 2, stat = FALSE, table = TRUE, tag = "year" +) + +######## Crop types ("maiz","rice_pro","soybean","tece") comparison with LUH ######## +magpie <- croparea(gdx, level = "cell", product_aggr = FALSE, water_aggr = TRUE)[, , crops] +historical1 <- read.magpie(paste0(outputdir, "/LUH3_croparea_0.5.mz")) +historical1 <- magpiesort((gdxAggregate(gdx, historical1, to = "cell", absolute = TRUE)))[, , crops] +historical1 <- dimSums(historical1, dim = 3.1) + +intYears <- intersect(getYears(magpie, as.integer = TRUE), getYears(historical1, as.integer = TRUE)) +Crops <- plotCorrHist2D( + x = historical1[,intYears,], y = magpie[,intYears,], xlab = "LUH3 \n (mio.ha)", ylab = "MAgPIE \n (mio.ha)", bins = 35, + folder = out_dir, file = "/validationCropCell", breaks = c(1, 10, 50), nrows = 2, ncols = 2, axisFont = 10, + axisTitleFont = 11, TitleFontSize = 12, legendTitleFont = 10, legendTextFont = 8, statFont = 2, stat = FALSE, table = TRUE, tag = "year" +) + +######## Crop types ("maiz","rice_pro","soybean","tece") comparison with MAPSPAM ######## +historical <- read.magpie(paste0(outputdir, "/MAPSPAM_croparea_0.5.mz")) +historical <- magpiesort(gdxAggregate(gdx, historical, to = "cell", absolute = TRUE))[,,crops] +historical <- dimSums(historical, dim = 3.2) +intYears2 <- intersect(getYears(magpie, as.integer = TRUE), getYears(historical, as.integer = TRUE)) + +CropsSPAM <- plotCorrHist2D( + x = historical, y = magpie[, intYears2, ], xlab = "MAPSPAM \n (mio.ha)", ylab = "MAgPIE \n (mio.ha)", bins = 35, + folder = out_dir, file = "/validationCropCellSPAM", breaks = c(1, 10, 50), nrows = 2, ncols = 2, axisFont = 10, + axisTitleFont = 11, TitleFontSize = 12, legendTitleFont = 10, legendTextFont = 8, statFont = 2, stat = FALSE, table = TRUE, + palette = "PiYG", tag = "year" +) + +######################################### Generates document ############################################## +template <- c( + "\\documentclass[a4paper, portrait ]{article}", + "\\setlength{\\parindent}{0in}", + "\\usepackage{float}", + "\\usepackage[bookmarksopenlevel=section]{hyperref}", + "\\hypersetup{bookmarks=true,pdfauthor={PIK Landuse group}}", + "\\usepackage{graphicx}", + "\\usepackage{rotating}", + "\\usepackage[strings]{underscore}", + "\\usepackage[margin=2cm]{geometry}", + "\\usepackage{fancyhdr}", + "\\pagestyle{fancy}", + "\\begin{document}", + "<>=", + "options(width=90)", + "@" +) + +############################## Plots LUH vs. magpie land use types #################################################### +x <- LU[[1]] +y <- as.data.frame(LU[[2]]) +colnames(y) <- y[1, ] +rownames(y) <- NULL +y <- (y[2:(nrow(y)), ]) +y[, 3:ncol(y)] <- round(as.numeric(unlist(y[, 3:ncol(y)])), 3) +colnames(y) <- c("Year", "Variable", "R2", "MAE", "MPE", "MAPE") + +tmpplot <- function(x, range) { + plotLU <- function(x, range) { + print(gridExtra::marrangeGrob(x[range], nrow = 3, ncol = 2, top = NULL)) + } + a <- capture.output(plotLU(x, range)) +} + +namesReport <- as.character(magpiesets::reportingnames(getNames(magpie_LU))) + +sw <- swopen(outfile = paste0(outputdir, "/CellValidation.pdf"), template = template) +swlatex(sw, c("\\title{MAgPIE Validation on Cellular level}", "\\maketitle", "\\tableofcontents")) +swlatex(sw, "\\section{Land use between 1995-2020 compared to LUH3}") + +b <- 0 + +for (i in 1:length(namesReport)) { + swlatex(sw, paste0("\\subsection{", namesReport[i], "}")) + a <- b + 1 + b <- a + length(getYears(historical_LU)) - 1 + swfigure(sw, tmpplot, x = x, c(a:b)) + swtable(sw, collapseNames(as.magpie(y[a:b, ])), + table.placement = "H", caption.placement = "top", + transpose = FALSE, caption = paste0("Compilation of error measurements for ", namesReport[i], " data comparing MAgPIE outputs \\& the LUH3 set at cluster level"), vert.lines = 0, align = "c" + ) + swlatex(sw, "\\newpage") +} + + +############################## Plots LUH vs. magpie crop types ########################################################## +swlatex(sw, "\\section{", paste0("MAgPIE crop types compared to LUH3 (", intYears[1], "-", intYears[length(intYears)], ")"), "}") + +namesReport1 <- as.character(magpiesets::reportingnames(getNames(magpie))) +x1 <- Crops[[1]] +y1 <- as.data.frame(Crops[[2]]) +colnames(y1) <- y1[1, ] +rownames(y1) <- NULL +y1 <- (y1[2:(nrow(y1)), ]) +y1[, 3:ncol(y1)] <- round(as.numeric(unlist(y1[, 3:ncol(y1)])), 3) +colnames(y1) <- c("Year", "Variable", "R2", "MAE", "MPE", "MAPE") + +tmpplot1 <- function(x1, range) { + plotLU1 <- function(x1, range) { + print(gridExtra::marrangeGrob(x1[range], nrow = 3, ncol = 2, top = NULL)) + } + a <- capture.output(plotLU1(x1, range)) +} + +b1 <- 0 +for (i in 1:length(namesReport1)) { + swlatex(sw, paste0("\\subsection{", namesReport1[i], "}")) + a1 <- b1 + 1 + b1 <- a1 + length(intYears) - 1 + swfigure(sw, tmpplot1, x = x1, c(a1:b1)) + swtable(sw, collapseNames(as.magpie(y1[a1:b1, ])), + table.placement = "H", caption.placement = "top", + transpose = FALSE, caption = paste0("Compilation of error measurements for ", namesReport1[i], " data comparing MAgPIE outputs \\& the LUH3 set at cluster level"), vert.lines = 0, align = "c" + ) + swlatex(sw, "\\newpage") +} + + +############################## Plots MAPSPAM vs. magpie crop types ########################################################## + + + swlatex(sw, "\\newpage") + swlatex(sw, "\\section{", paste0("MAgPIE crop types compared to MAPSPAM (", intYears2[1], "-", intYears2[length(intYears2)], ")"), "}") + + x2 <- CropsSPAM[[1]] + names(x2) <- paste0(names(x2), "MAP") + x3 <- Crops[[1]][names(CropsSPAM[[1]])] + y2 <- as.data.frame(CropsSPAM[[2]]) + colnames(y2) <- y2[1, ] + rownames(y2) <- NULL + y2 <- (y2[2:(nrow(y2)), ]) + y2[, 3:ncol(y2)] <- round(as.numeric(unlist(y2[, 3:ncol(y2)])), 3) + colnames(y2) <- c("Year", "Variable", "R2", "MAE", "MPE", "MAPE") + + tmpplot2 <- function(x2, x3, range) { + plotLU2 <- function(x2, x3, range) { + print(gridExtra::marrangeGrob(c(x2[range], x3[range]), nrow = 3, ncol = 2, top = NULL)) + } + a <- capture.output(plotLU2(x2, x3, range)) + } + + b2 <- 0 + for (i in 1:length(namesReport1)) { + swlatex(sw, paste0("\\subsection{", namesReport1[i], "}")) + swlatex(sw, "\\qquad \\textbf{MAPSPAM} \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\qquad \\textbf{LUH3}") + a2 <- b2 + 1 + b2 <- a2 + length(intYears2) - 1 + swfigure(sw, tmpplot2, x2 = x2, x3 = x3, range = c(a2:b2)) + swtable(sw, collapseNames(as.magpie(y2[a2:b2, ])), + table.placement = "H", caption.placement = "top", + transpose = FALSE, caption = paste0("Compilation of error measurements for ", namesReport[i], " data comparing MAgPIE outputs \\& the MAPSPAM set at cluster level"), vert.lines = 0, align = "c" + ) + swlatex(sw, "\\newpage") + } + +########## Details about statistics ########## +swlatex(sw, "\\newpage") +swlatex(sw, "\\section{Details about statistical measuremens of error and goodness of fit}") +swlatex(sw, "\\begin{itemize} \\item R2 represents the coefficient of determination. \\end{itemize}") +swlatex(sw, "\\begin{itemize} \\item MAE stands for mean absolute error and is calculated as $MAE=\\frac{1}{n}\\sum(|error|)$. Where, error represents the difference between LUH/MAPSPAM values and MAgPIE Outputs. \\end{itemize}") +swlatex(sw, "\\begin{itemize} \\item MPE stands for mean percentage error (a measure of bias) and is calculated as $MPE=\\frac{100\\%}{n}\\sum(RE)$. Where, RE (relative error) represents the relative difference between LUH/MAPSPAM values and MAgPIE Outputs. \\end{itemize}") +swlatex(sw, "\\begin{itemize} \\item Finally, MAPE stands for mean absolute percentage error and is calculated as $MAPE=\\frac{100\\%}{n}\\sum(|RE|)$. Where, RE (relative error) represents the relative difference between LUH/MAPSPAM values and MAgPIE Outputs. \\end{itemize}") + +####### Closes the pdf document +swclose(sw, clean_output = FALSE, engine = "knitr") + +########################################################################################################################### + +##### Erase latex style and output files + +fileErase <- c( + Sys.glob(file.path(outputdir, "/CellValidation.*")), + Sys.glob(file.path(outputdir, "/Sweave.sty")), + Sys.glob(file.path(outputdir, "figure/*")), + Sys.glob(file.path(outputdir, "figure")) +) +fileErase <- fileErase[!(fileErase %in% paste0(outputdir, "//CellValidation.pdf"))] + + +unlink(fileErase, recursive = TRUE) diff --git a/scripts/output/validation_short.R b/scripts/output/validation_short.R new file mode 100644 index 0000000000..d03a7db03b --- /dev/null +++ b/scripts/output/validation_short.R @@ -0,0 +1,48 @@ +# | (C) 2008-2025 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: creates a validation pdf file for a run (short version - aggregated crop types) +# comparison script: FALSE +# position: 5 +# --------------------------------------------------------------- + + +library(magpie4) +library(gms) + +############################# BASIC CONFIGURATION ############################# +if(!exists("source_include")) { + outputdir <-"." +} + +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +hist <- c(paste0(outputdir, "/validation.mif"), "input/validation.mif") +file <- paste0(outputdir, "/", cfg$title, "_validation.pdf") +reportrds <- paste0(outputdir, "/report.rds") +gdx <- paste0(outputdir, "/fulldata.gdx") +runinfo <- paste0(outputdir, "/", cfg$title, "_*.RData") +############################################################################### + +#### Choose validation data ### +# Use first hist file that can be found + +for(h in hist) { + if(file.exists(h)) break +} + +runinfo <- Sys.glob(runinfo) +if(length(runinfo)>1) { + runinfo <- runinfo[1] + warnings("More than one runinfo file found. The first one will be used.") +} else if (length(runinfo)==0) { + runinfo <- NULL +} + +getReport <- getReport(gdx,scenario = cfg$title,detail=FALSE) + +validation(gdx=gdx, hist=h, file = file, runinfo=runinfo, scenario=cfg$title, getReport=getReport) diff --git a/scripts/performance_test.R b/scripts/performance_test.R index ae9c784508..bc1645664c 100644 --- a/scripts/performance_test.R +++ b/scripts/performance_test.R @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -9,11 +9,11 @@ source("scripts/start_functions.R") performance_start <- function(cfg="default.cfg",modulepath="modules/",id="performance",sequential=NA) { - require(lucode) + require(lucode2) if(!is.list(cfg)) { if(is.character(cfg)) { - source(path("config",cfg),local=TRUE) + source(file.path("config",cfg),local=TRUE) if(!is.list(cfg)) stop("Wrong input file format: config file does not contain a cfg list!") } else { stop("Wrong input format: cfg is neither a list nor a character!") @@ -35,7 +35,7 @@ performance_start <- function(cfg="default.cfg",modulepath="modules/",id="perfor try(start_run(cfg)) m <- getModules(modulepath) - for(i in 1:dim(m)[1]) { + for(i in 1:dim(m)[1]) { default <- cfg$gms[[m[i,"name"]]] r <- strsplit(m[i,"realizations"],",")[[1]] r <- r[r!=default] #remove default case @@ -51,10 +51,8 @@ performance_start <- function(cfg="default.cfg",modulepath="modules/",id="perfor performance_collect <- function(id="performance",results_folder="output/",plot=TRUE) { require(magpie4) - require(lucode) - maindir <- getwd() - on.exit(setwd(maindir)) - setwd(results_folder) + require(lucode2) + withr::local_dir(results_folder) folders <- grep(paste("^",id,"__",sep=""),list.dirs(full.names = FALSE, recursive = FALSE),value=TRUE) tmp <- grep(paste("^",id,"__default",sep=""),folders) default <- folders[tmp] @@ -63,7 +61,7 @@ performance_collect <- function(id="performance",results_folder="output/",plot=T if(length(folders)==0) stop("No folders found which fit to the given id (",id,")") .modelstats <- function(f,colMeans=TRUE) { - logfile <- path(f,"full.log") + logfile <- file.path(f,"full.log") if(file.exists(logfile)) { tmp <- readLines(logfile) p1 <- "--- ([^ ]*) rows ([^ ]*) columns ([^ ]*) non-zeroes" @@ -112,14 +110,14 @@ performance_collect <- function(id="performance",results_folder="output/",plot=T for(f in folders){ tmp <- strsplit(f,"__")[[1]] ms <- .modelstats(f,colMeans=TRUE) - tmp2 <- data.frame(module=tmp[2],realization=tmp[3],default=FALSE,runtime=.gettime(path(f,f,ftype="RData")),infes=.infescheck(path(f,"fulldata.gdx")), + tmp2 <- data.frame(module=tmp[2],realization=tmp[3],default=FALSE,runtime=.gettime(file.path(f,paste0(f,".RData"))),infes=.infescheck(file.path(f,"fulldata.gdx")), rows=ms["rows"],columns=ms["columns"],nonzeroes=ms["nonzeroes"],nlcode=ms["nlcode"],nlnonzeroes=ms["nlnonzeroes"]) results <- rbind(results,tmp2) } - load(path(default,"config.Rdata")) + cfg <- gms::loadConfig(file.path(default, "config.yml")) for(n in unique(results$module)) { ms <- .modelstats(default,colMeans=TRUE) - tmp <- data.frame(module=n,realization=cfg$gms[[n]],default=TRUE,runtime=.gettime(path(default,default,ftype="RData")),infes=.infescheck(path(default,"fulldata.gdx")), + tmp <- data.frame(module=n,realization=cfg$gms[[n]],default=TRUE,runtime=.gettime(file.path(default,paste0(default,".RData"))),infes=.infescheck(file.path(default,"fulldata.gdx")), rows=ms["rows"],columns=ms["columns"],nonzeroes=ms["nonzeroes"],nlcode=ms["nlcode"],nlnonzeroes=ms["nlnonzeroes"]) results <- rbind(results,tmp) } @@ -138,8 +136,8 @@ performance_collect <- function(id="performance",results_folder="output/",plot=T attr(results,"default_cfg") <- cfg attr(results,"id") <- id - if(file.exists(path(default,"git.rda"))) { - load(path(default,"git.rda")) + if(file.exists(file.path(default,"git.rda"))) { + load(file.path(default,"git.rda")) attr(results,"git") <- git } diff --git a/scripts/postRelease.R b/scripts/postRelease.R new file mode 100644 index 0000000000..5330da3fca --- /dev/null +++ b/scripts/postRelease.R @@ -0,0 +1,46 @@ +postRelease <- function() { + gert::git_fetch("upstream") + gert::git_merge("upstream/master") + + pattern <- "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)." + stopifnot(any(grepl(pattern, readLines("CHANGELOG.md"), fixed = TRUE))) + textToAdd <- paste("", + "", + "", + "## [Unreleased]", + "", + "### changed", + "-", + "", + "### added", + "-", + "", + "### removed", + "-", + "", + "### fixed", + "-", + sep = "\n") + + readLines("CHANGELOG.md") |> + sub(pattern = pattern, replacement = paste0(pattern, textToAdd), fixed = TRUE) |> + writeLines("CHANGELOG.md") + + readLines("CITATION.cff") |> + sub(pattern = "^(version:.*)$", replacement = "\\1dev") |> + writeLines("CITATION.cff") + + citation::cff2zenodo("CITATION.cff") + + message("TODO: git add -p\n", + "Press enter when done to commit, push and create PR") + gms::getLine() + + gert::git_commit("merge master into develop") + gert::git_push() + system(paste0("gh pr create --base develop --title 'merge master into develop' --body ''")) +} + +postRelease() +message("warnings:") +print(warnings()) diff --git a/scripts/projects/fsec.R b/scripts/projects/fsec.R new file mode 100644 index 0000000000..83d0cb4b3a --- /dev/null +++ b/scripts/projects/fsec.R @@ -0,0 +1,233 @@ +# | (C) 2008-2025 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 internal functions +################################################################################ + +fsecScenario <- function(scenario, + highres = TRUE) { # run highres output script afterwards? + + source("config/default.cfg") + + # Version number + v <- "v39k_FSEC" + + x <- list(c_BAU = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "RCP60")), + f_BAUlabor8p5 = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "RCP60", "labor8p5")), + d_SSP1bau = list(standard = c("cc", "SSP1", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP1", "RCP45")), + d_SSP1PLUSbau = list(standard = c("cc", "SSP1", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP1", + "energy", "bioplastics", "population", "institutions", "timberCities", "RCP26")), + d_SSP3bau = list(standard = c("cc", "SSP3", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP3", "RCP70")), + d_SSP4bau = list(standard = c("cc", "SSP4", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP4", "RCP60")), + d_SSP5bau = list(standard = c("cc", "SSP5", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP5", "RCP85")), + # FSDP (all transformations active) + e_FSDP = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", + "energy", "bioplastics", "population", "institutions", "timberCities", + "awms", "livestock", "nueMAC", "riceMAC", "biodiversity", "fairTrade", "capitalSubst", "minWage", + "REDDaff", "REDD", "landscapeElements", "landSharing", "landSparing", "waterSparing", "peatland", + "soil", "allDietAndWaste", "allEnvPrice", "SDPenergy", "RCP19")), + f_FSDPlabor1p9 = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", + "energy", "bioplastics", "population", "institutions", "timberCities", + "awms", "livestock", "nueMAC", "riceMAC", "biodiversity", "fairTrade", "capitalSubst", "minWage", + "REDDaff", "REDD", "landscapeElements", "landSharing", "landSparing", "waterSparing", "peatland", + "soil", "allDietAndWaste", "allEnvPrice", "SDPenergy", "RCP19", "labor1p9")), + # FSDPs (without external) + d_SSP1fsdp = list(standard = c("cc", "SSP1", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP1", + "awms", "livestock", "nueMAC", "riceMAC", "biodiversity", "fairTrade", "capitalSubst", "minWage", + "REDDaff", "REDD", "landscapeElements", "landSharing", "landSparing", "waterSparing", "peatland", + "soil", "allDietAndWaste", "allEnvPrice", "RCP26")), + d_SSP2fsdp = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP2", + "awms", "livestock", "nueMAC", "riceMAC", "biodiversity", "fairTrade", "capitalSubst", "minWage", + "REDDaff", "REDD", "landscapeElements", "landSharing", "landSparing", "waterSparing", "peatland", + "soil", "allDietAndWaste", "allEnvPrice", "RCP45")), + d_SSP3fsdp = list(standard = c("cc", "SSP3", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP3", + "awms", "livestock", "nueMAC", "riceMAC", "biodiversity", "fairTrade", "capitalSubst", "minWage", + "REDDaff", "REDD", "landscapeElements", "landSharing", "landSparing", "waterSparing", "peatland", + "soil", "allDietAndWaste", "allEnvPrice", "RCP45")), + d_SSP4fsdp = list(standard = c("cc", "SSP4", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP4", + "awms", "livestock", "nueMAC", "riceMAC", "biodiversity", "fairTrade", "capitalSubst", "minWage", + "REDDaff", "REDD", "landscapeElements", "landSharing", "landSparing", "waterSparing", "peatland", + "soil", "allDietAndWaste", "allEnvPrice", "RCP26")), + d_SSP5fsdp = list(standard = c("cc", "SSP5", "NDC", "ForestryEndo"), + fsec = c("FSEC", "SSP5", + "awms", "livestock", "nueMAC", "riceMAC", "biodiversity", "fairTrade", "capitalSubst", "minWage", + "REDDaff", "REDD", "landscapeElements", "landSharing", "landSparing", "waterSparing", "peatland", + "soil", "allDietAndWaste", "allEnvPrice", "RCP60")), + # Individual transformation clusters: + a_Population = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "population", "RCP60")), + a_EconDevelop = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "institutions", "RCP60")), + a_EnergyTrans = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "energy", "RCP26")), + a_Bioplastics = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "bioplastics", "RCP60")), + a_CapitalSubst = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "capitalSubst", "RCP60")), + a_MinWage = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "minWage", "RCP60")), + a_NoUnderweight = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "noUnderweight", "RCP60")), + a_HalfOverweight = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "halfOverweight", "RCP60")), + a_DietVegFruitsNutsSeeds = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fruitsNutsVegSeeds", "RCP60")), + a_DietMonogastrics = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "monogastrics", "RCP60")), + a_DietRuminants = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "ruminants", "RCP45")), + a_DietLegumes = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "pulses", "RCP60")), + a_DietEmptyCals = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "processed", "RCP60")), + a_DietFish = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fish", "RCP60")), + a_LessFoodWaste = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "waste", "RCP60")), + a_ManureMngmt = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "awms", "RCP60")), + a_LivestockMngmt = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "livestock", "RCP60")), + a_CropeffTax = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "cropefficiency", "RCP60")), + a_NitrogenEff = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "nueMAC", "RCP60")), + a_RiceMit = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "riceMAC", "RCP60")), + a_BiodivSparing = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "biodiversity", "RCP60")), + a_LiberalizedTrade = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "RCP60")), + a_TimberCities = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "timberCities", "RCP60")), + a_REDDaff = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "REDDaff", "RCP60")), + a_REDD = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "REDD", "RCP60")), + a_CropRotations = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landSharing", "RCP60")), + a_LandscapeElements = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landscapeElements", "RCP60")), + a_LandSparing = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landSparing", "RCP60")), + a_WaterSparing = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "waterSparing", "RCP60")), + a_PeatlandSparing = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "peatland", "RCP60")), + a_SoilCarbon = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "soil", "RCP60")), + # Scenarios (combinations of transformation clusters) + b_ExternalPressures = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "population", "institutions", "energy", "bioplastics", "timberCities", "SDPenergy", "RCP26")), + b_WaterSoil = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "waterSparing", "soil", "RCP60")), + b_REDDaffRuminants = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "ruminants", "REDDaff", "RCP60")), + b_DietRotations = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landSharing", "allDiet", "RCP60")), + b_MonogastricsRotations = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landSharing", "monogastrics", "RCP60")), + b_TradeRotations = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landSharing", "fairTrade", "RCP60")), + b_TradeREDDaff = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "REDDaff", "RCP60")), + b_TradeSoil = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "soil", "RCP60")), + b_TradeMonogastrics = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "monogastrics", "RCP60")), + b_TradeRuminants = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "ruminants", "RCP60")), + b_TradeVeggies = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "fruitsNutsVegSeeds", "RCP60")), + b_MonogastricsVeggies = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "monogastrics", "fruitsNutsVegSeeds", "RCP60")), + b_SoilMonogastric = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "monogastrics", "soil", "RCP60")), + b_SoilMonogastricRuminants = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "monogastrics", "ruminants","soil", "RCP60")), + b_SoilRotations = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landSharing", "soil", "RCP60")), + b_LivestockManureMngmt = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "livestock", "awms", "RCP60")), + b_LivestockNUEMngmt = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "livestock", "nueMAC", "RCP60")), + b_AllNitrogen = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "awms", "nueMAC", "monogastrics", "ruminants", "waste", "RCP60")), + b_AllClimate = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "nueMAC", "riceMAC", "awms", "allEnvPrice", "RCP60")), + b_FullBiodiv = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "biodiversity", "landSharing", "RCP60")), + b_AllEnvironment = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "biodiversity", "REDDaff", + "landSparing", "waterSparing", "peatland", "soil", "allEnvPrice", "RCP60")), + b_AllHealth = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "allDiet", "RCP60")), + b_AllInclusion = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "population", "institutions", "timberCities", "fairTrade", "capitalSubst", "minWage", "RCP60")), + b_Livelihoods = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "capitalSubst", "minWage", "RCP60")), + b_LivelihoodsExt = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "fairTrade", "capitalSubst", "minWage", "bioplastics", "energy", "timberCities", "RCP60")), + b_Bioeconomy = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "bioplastics", "energy", "timberCities", "RCP60")), + b_AgroMngmt = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "landSharing", "landscapeElements", "nueMAC", "riceMAC", "livestock", "awms", "soil", "RCP45")), + b_Efficiency = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "awms", "waste", "fairTrade", "nueMAC", "RCP60")), + b_Diet = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "allDietAndWaste", "RCP45")), + b_Protection = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "waterSparing", "landSparing", "peatland", "RCP60")), + b_NatureSparing = list(standard = c("cc", "SSP2", "NDC", "ForestryEndo"), + fsec = c("FSEC", "waterSparing", "landSparing", "peatland", "biodiversity", "REDDaff", "RCP60")) + ) + # Assign selected scenario to cfg + cfg <- setScenario(cfg, x[[scenario]]$standard) + cfg <- setScenario(cfg, x[[scenario]]$fsec, scenario_config = "config/projects/scenario_config_fsec.csv") + + # Download gridded population data + gms::download_unpack(input = "FSEC_populationScenarios_v2_22-08-22.tgz", + targetdir = "./input", + repositories = cfg$repositories) + # Download gridded RCP temperature data + gms::download_unpack(input = "FSEC_GlobalSurfaceTempPerRCP_v4_19-03-24.tgz", + targetdir = "./input", + repositories = cfg$repositories) + + # general + cfg$title <- paste(v, scenario, sep = "") + cfg$recalibrate <- FALSE + cfg$qos <- "standby_highMem" + cfg$output <- c(if (highres) "extra/highres", + "extra/disaggregation", + "projects/FSEC_nitrogenPollution", + "projects/FSEC_cropDiversityGrid", + "projects/FSEC_dietaryIndicators", + "projects/FSEC_costs", + "projects/FSEC_water", + "rds_report_iso", + "rds_report") + cfg$force_download <- TRUE + cfg$gms$s80_optfile <- 0 + cfg$gms$s80_maxiter <- 30 + + return(cfg) +} diff --git a/scripts/release.R b/scripts/release.R new file mode 100644 index 0000000000..09592136f9 --- /dev/null +++ b/scripts/release.R @@ -0,0 +1,75 @@ +checkInputDataRevs <- function() { + source("config/default.cfg") + targetRev <- sub("_.+$", "", cfg$input["regional"]) + if (!startsWith(cfg$input["cellular"], targetRev) || !startsWith(cfg$input["validation"], targetRev)) { + stop("in 'config/default.cfg' cellular/validation input data rev does not match regional input data rev") + } + + scenarioConfig <- read.csv2("config/scenario_config.csv", row.names = 1) + rcps <- paste0("rcp", c("1p9", "2p6", "4p5", "6p0", "7p0", "8p5")) + rcpInput <- t(scenarioConfig)[rcps, "input['cellular']"] + if (!all(startsWith(rcpInput, targetRev))) { + stop("config/scenario_config.csv rcps do not use same input data revision as default.cfg") + } +} + +release <- function(newVersion) { + if (Sys.which("sbatch") == "") { + stop("release must be created on cluster") + } + + releaseDate <- format(Sys.time(), "%Y-%m-%d") + oldVersion <- readLines("CITATION.cff") |> + grep(pattern = "^version: (.*)$", value = TRUE) |> + sub(pattern = "^version: (.*)$", replacement = "\\1") |> + sub(pattern = "dev", replacement = "") + + githubUrl <- "https://github.com/magpiemodel/magpie/compare/" + readLines("CHANGELOG.md") |> + sub(pattern = "## [Unreleased]", replacement = paste0("## [", newVersion, "] - ", releaseDate), fixed = TRUE) |> + sub(pattern = paste0("\\[Unreleased\\]: ", githubUrl, "v(.+)\\.\\.\\.develop"), + replacement = paste0("[Unreleased]: ", githubUrl, "v", newVersion, "...develop\n", + "[", newVersion, "]: ", githubUrl, "v\\1...v", newVersion)) |> + writeLines("CHANGELOG.md") + + readLines("CITATION.cff") |> + sub(pattern = "^version:.*$", replacement = paste("version:", newVersion)) |> + sub(pattern = "^date-released:.*$", replacement = paste("date-released:", releaseDate)) |> + writeLines("CITATION.cff") + + readLines("README.md") |> + gsub(pattern = oldVersion, replacement = newVersion) |> + writeLines("README.md") + + citation::cff2zenodo("CITATION.cff") + + message("creating documentation using goxygen...") + goxygen::goxygen() + message("uploading documentation to RSE server") + exitCode <- system(paste0("rsync -e ssh -avz doc/html/* ", + "rse@rse.pik-potsdam.de:/webservice/doc/magpie/", newVersion)) + stopifnot(exitCode == 0) + + message("uploading input data to RSE server") + sys.source("scripts/start/extra/publish_data.R", envir = new.env()) # only works on cluster + + message("TODO:\n", + "- CHANGELOG.md: sort lines in each category: changed, added, removed, fixed; remove empty categories\n", + "- git add -p\n", + "Press enter when done to commit, push and create PR") + gms::getLine() + + gert::git_commit(paste("magpie release", newVersion)) + gert::git_push() + system(paste0("gh pr create --base master --title 'magpie release ", newVersion, "' --body ''")) +} + +arguments <- commandArgs(TRUE) +if (length(arguments) != 1) { + stop("Please pass the new version number, e.g. `Rscript scripts/release.R 4.6.2`") +} + +checkInputDataRevs() +release(arguments) +message("warnings:") +print(warnings()) diff --git a/scripts/run_submit/submit.R b/scripts/run_submit/submit.R index 01901095d2..2e39a09f1b 100644 --- a/scripts/run_submit/submit.R +++ b/scripts/run_submit/submit.R @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -6,31 +6,82 @@ # | Contact: magpie@pik-potsdam.de library(magclass) -library(lucode) +library(lucode2) library(magpie4) +library(gms) #options(error=function()traceback(2)) -load("config.Rdata") +.getRestartFiles <- function() { + restartFiles <- dir(pattern="restart_.*\\.g00") + names(restartFiles) <- gsub("restart_y([0-9]*)\\.g00", "\\1", restartFiles) + return(restartFiles) +} + +.getRestartCode <- function() { + restartFiles <- .getRestartFiles() + if (length(restartFiles) == 0) return("") + restartFiles <- tail(restartFiles, 1) + return(paste0(" --RESTARTPOINT=TimeLoop --TIMESTEP=", names(restartFiles), " r=", restartFiles)) +} + +cfg <- gms::loadConfig("config.yml") maindir <- cfg$magpie_folder -# write the config file in the output_folder: config.log -write(capture.output(cfg), file="config.log") +# Capture start time +timeGAMSStart <- Sys.time() cat("\nStarting MAgPIE...\n") -begin<-Sys.time() -system(paste("gams full.gms -errmsg=1 -lf=full.log -lo=",cfg$logoption,sep="")) -gams_runtime<-Sys.time()-begin #calculate runtime info +system(paste0("gams full.gms -errmsg=1 -lf=full.log -lo=",cfg$logoption, .getRestartCode())) + +if (isFALSE(cfg$keep_restarts)) unlink(.getRestartFiles()) + +# Capture runtimes +timeGAMSEnd <- Sys.time() +gams_runtime <- timeGAMSEnd - timeGAMSStart +timeOutputStart <- Sys.time() + if(!file.exists("fulldata.gdx")) stop("MAgPIE model run did not finish properly (fulldata.gdx is missing). Please check full.lst for further information!") cat("\nMAgPIE run finished!\n") -lucode::runstatistics(file = "runstatistics.rda", - modelstat = magpie4::modelstat("fulldata.gdx"), - config = cfg, - runtime = gams_runtime, - setup_info = lucode::setup_info(), - submit = cfg$runstatistics) +gams_modelstats <- c("1" ="Optimal solution achieved.", + "2" ="Local optimal solution achieved.", + "3" ="Unbounded model found.", + "4" ="Infeasible model found.", + "5" ="Locally infeasible model found.", + "6" ="Solver terminated early and model was still infeasible. ", + "7" ="Solver terminated early and model was feasible but not yet optimal.", + "8" ="Integer solution found.", + "9" ="Solver terminated early with a non integer solution found.", + "10"="No feasible integer solution could be found.", + "11"="Licensing problem. Check if you correctly applied solver licence for MAgPIE in GAMS.", + "12"="Error - No cause known.", + "13"="Error - No solution attained.", + "14"="No solution returned.", + "15"="Unique solution in a CNS models.", + "16"="Feasible solution in a CNS models.", + "17"="Singular in a CNS models.", + "18"="Unbounded - no solution.", + "19"="Infeasible - no solution.") + +ms_all <- as.numeric(magpie4::modelstat("fulldata.gdx")) +ms <- unique(ms_all[ms_all!=0]) + +if(length(ms)== 1) message("Model finished with modelstat ",ms,":",gams_modelstats[as.numeric(names(gams_modelstats)) %in% ms]) +if(length(ms) > 1){ + message("Following modelstats were observed during simulation:") + for(i in 1:length(ms)){ + message(ms[i],":",gams_modelstats[as.numeric(names(gams_modelstats)) %in% ms[i]]) + } +} + +lucode2::runstatistics(file = "runstatistics.rda", + modelstat = magpie4::modelstat("fulldata.gdx"), + config = cfg, + runtime = gams_runtime, + setup_info = lucode2::setup_info(), + submit = cfg$runstatistics) runfolder <- getwd() setwd(maindir) @@ -49,9 +100,9 @@ for (file in cfg$files2export$end) { #update validation.RData #### Collect technical information for validation ############################## # info on the used dataset -input_data<-readLines(path(cfg$results_folder,"info.txt")) +input_data<-readLines(file.path(cfg$results_folder,"info.txt")) # extract module info from full.gms -tmp<-readLines(path(cfg$results_folder,"full.gms"),warn=FALSE,encoding="ASCII") +tmp<-readLines(file.path(cfg$results_folder,"full.gms"),warn=FALSE,encoding="ASCII") lines<-grep(".*MODULE SETUP.*",tmp)[1]:grep(".*MODULE SETUP.*",tmp)[2] module_setup<-c("","","### MODULE SETUP ###",grep("\\$",tmp[lines],value=TRUE)) @@ -64,7 +115,7 @@ if (exists("last.warning")) { validation$technical$last.warning <- c(validation$technical$last.warning, last.warning) } -validation$technical$setup_info$model_run <- setup_info() +validation$technical$setup_info$model_run <- lucode2::setup_info() save(validation,file=cfg$val_workspace, compress="xz") rm(gams_runtime,input_data,module_setup,validation) @@ -73,7 +124,29 @@ rm(gams_runtime,input_data,module_setup,validation) comp <- FALSE submit <- "direct" output <- cfg$output -outputdirs <- runfolder +outputdir <- runfolder sys.source("output.R",envir=new.env()) +# get runtime for output +timeOutputEnd <- Sys.time() + +# Save run statistics to local file +cat("Saving timeGAMSStart, timeGAMSEnd, timeOutputStart and timeOutputStart to runstatistics.rda\n") +lucode2::runstatistics(file = paste0(cfg$results_folder, "/runstatistics.rda"), + timeGAMSStart = timeGAMSStart, + timeGAMSEnd = timeGAMSEnd, + timeOutputStart = timeOutputStart, + timeOutputEnd = timeOutputEnd) + print(warnings()) + +# quit with gams status as exit code unless model completed locally optimal everywhere +gamsCode <- Find(function(code) !code %in% c(2, 7), ms_all) +if (is.null(gamsCode) && 7 %in% ms_all) { + gamsCode <- 7 +} +if (!is.null(gamsCode)) { + exitCode <- gamsCode + 200 # low numbered exit codes are used by R, add 200 to avoid confusion + message("gams status was ", gamsCode, ", exiting with code ", exitCode) + quit(status = exitCode) +} diff --git a/scripts/run_submit/submit.sh b/scripts/run_submit/submit.sh deleted file mode 100644 index e8012090ac..0000000000 --- a/scripts/run_submit/submit.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -#SBATCH --qos=standby -#SBATCH --job-name=mag-run -#SBATCH --output=full.log -#SBATCH --mail-type=END -#SBATCH --cpus-per-task=3 -#SBATCH --partition=standard - -Rscript submit.R - diff --git a/scripts/run_submit/submit_medium.sh b/scripts/run_submit/submit_medium.sh new file mode 100644 index 0000000000..bedbe5db04 --- /dev/null +++ b/scripts/run_submit/submit_medium.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +#SBATCH --qos=medium +#SBATCH --job-name=mag-run +#SBATCH --output=slurm.log +#SBATCH --mail-type=END,FAIL +#SBATCH --cpus-per-task=3 + +Rscript submit.R diff --git a/scripts/run_submit/submit_priority.sh b/scripts/run_submit/submit_priority.sh new file mode 100644 index 0000000000..60d00a38e0 --- /dev/null +++ b/scripts/run_submit/submit_priority.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +#SBATCH --qos=priority +#SBATCH --job-name=mag-run +#SBATCH --output=slurm.log +#SBATCH --mail-type=END,FAIL +#SBATCH --cpus-per-task=3 +#SBATCH --mem-per-cpu=5G +#SBATCH --time=24:00:00 + +Rscript submit.R diff --git a/scripts/run_submit/submit_priority_highMem.sh b/scripts/run_submit/submit_priority_highMem.sh new file mode 100644 index 0000000000..cf749a944f --- /dev/null +++ b/scripts/run_submit/submit_priority_highMem.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +#SBATCH --qos=priority +#SBATCH --job-name=mag-run +#SBATCH --output=slurm.log +#SBATCH --mail-type=END,FAIL +#SBATCH --cpus-per-task=16 +#SBATCH --mem-per-cpu=5G +#SBATCH --time=24:00:00 + +Rscript submit.R diff --git a/scripts/run_submit/submit_short.sh b/scripts/run_submit/submit_short.sh new file mode 100644 index 0000000000..9092201c63 --- /dev/null +++ b/scripts/run_submit/submit_short.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +#SBATCH --qos=short +#SBATCH --job-name=mag-run +#SBATCH --output=slurm.log +#SBATCH --mail-type=END,FAIL +#SBATCH --cpus-per-task=3 +#SBATCH --mem-per-cpu=5G +#SBATCH --time=24:00:00 + +Rscript submit.R diff --git a/scripts/run_submit/submit_short_highMem.sh b/scripts/run_submit/submit_short_highMem.sh new file mode 100644 index 0000000000..37be642e5b --- /dev/null +++ b/scripts/run_submit/submit_short_highMem.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#SBATCH --qos=short +#SBATCH --job-name=mag-run +#SBATCH --output=slurm.log +#SBATCH --mail-type=END,FAIL +#SBATCH --cpus-per-task=16 +#SBATCH --mem-per-cpu=5G +#SBATCH --time=24:00:00 + +Rscript submit.R + diff --git a/scripts/run_submit/submit_standby.sh b/scripts/run_submit/submit_standby.sh new file mode 100644 index 0000000000..aa6b3673d0 --- /dev/null +++ b/scripts/run_submit/submit_standby.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +#SBATCH --qos=standby +#SBATCH --job-name=mag-run +#SBATCH --output=slurm.log +#SBATCH --mail-type=END,FAIL +#SBATCH --cpus-per-task=3 +#SBATCH --mem-per-cpu=5G +#SBATCH --time=24:00:00 + +Rscript submit.R diff --git a/scripts/run_submit/submit_standby_highMem.sh b/scripts/run_submit/submit_standby_highMem.sh new file mode 100644 index 0000000000..674bc10f5a --- /dev/null +++ b/scripts/run_submit/submit_standby_highMem.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +#SBATCH --qos=standby +#SBATCH --job-name=mag-run +#SBATCH --output=slurm.log +#SBATCH --mail-type=END,FAIL +#SBATCH --cpus-per-task=16 +#SBATCH --mem-per-cpu=5G +#SBATCH --time=24:00:00 + +Rscript submit.R diff --git a/scripts/slurmOutput.yml b/scripts/slurmOutput.yml new file mode 100644 index 0000000000..55d858c990 --- /dev/null +++ b/scripts/slurmOutput.yml @@ -0,0 +1,5 @@ +slurmjobs: + SLURM standby: "sbatch --job-name=scripts-output --output=logs/out-%NAME-%j.out --error=logs/out-%NAME-%j.err --mail-type=END,FAIL --wrap=\"Rscript %SCRIPT\" --mem-per-cpu=5G --cpus-per-task=3 --qos=standby --time=200" + SLURM standby highMem: "sbatch --job-name=scripts-output --output=logs/out-%NAME-%j.out --error=logs/out-%NAME-%j.err --mail-type=END,FAIL --wrap=\"Rscript %SCRIPT\" --mem-per-cpu=5G --cpus-per-task=16 --qos=standby --time=24:00:00" + SLURM priority: "sbatch --job-name=scripts-output --output=logs/out-%NAME-%j.out --error=logs/out-%NAME-%j.err --mail-type=END,FAIL --wrap=\"Rscript %SCRIPT\" --mem-per-cpu=5G --cpus-per-task=3 --qos=priority --time=200" + SLURM priority highMem: "sbatch --job-name=scripts-output --output=logs/out-%NAME-%j.out --error=logs/out-%NAME-%j.err --mail-type=END,FAIL --wrap=\"Rscript %SCRIPT\" --mem-per-cpu=5G --cpus-per-task=16 --qos=priority --time=24:00:00" diff --git a/scripts/slurmStart.yml b/scripts/slurmStart.yml new file mode 100644 index 0000000000..5810795470 --- /dev/null +++ b/scripts/slurmStart.yml @@ -0,0 +1,4 @@ +slurmjobs: + SLURM priority: "sbatch --job-name=%NAME --output=logs/%NAME-%j.out --mail-type=END,FAIL --wrap=\"Rscript %SCRIPT\" --cpus-per-task=3 --time=24:00:00 --qos=priority" + SLURM standby: "sbatch --job-name=%NAME --output=logs/%NAME-%j.out --mail-type=END,FAIL --wrap=\"Rscript %SCRIPT\" --cpus-per-task=3 --time=24:00:00 --qos=standby" + SLURM medium: "sbatch --job-name=%NAME --output=logs/%NAME-%j.out --mail-type=END,FAIL --wrap=\"Rscript %SCRIPT\" --cpus-per-task=3 --qos=medium" diff --git a/scripts/start/INFO.yml b/scripts/start/INFO.yml new file mode 100644 index 0000000000..7dc4727fba --- /dev/null +++ b/scripts/start/INFO.yml @@ -0,0 +1,5 @@ +type: start script +description: Main selection of MAgPIE start scripts +note: Scripts in this selection are actively managed and work out of the + box +position: 1.0 diff --git a/scripts/start/bmi_shr.R b/scripts/start/bmi_shr.R deleted file mode 100644 index 4c088549f1..0000000000 --- a/scripts/start/bmi_shr.R +++ /dev/null @@ -1,20 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -source("config/default.cfg") -cfg$gms$food <- "bmi_share_jul18" - -#start MAgPIE run -start_run(cfg=cfg) diff --git a/scripts/start/bra_comp.R b/scripts/start/bra_comp.R deleted file mode 100644 index 4f257ec015..0000000000 --- a/scripts/start/bra_comp.R +++ /dev/null @@ -1,59 +0,0 @@ -# | (C) 2008-2019 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 - - -########################################################## -#### Script to MAgPIE test runs #### -########################################################## - -library(lucode) -library(magpie4) - -source("scripts/start_functions.R") -source("scripts/performance_test.R") -source("config/default.cfg") - -#### MAgPIE Brazil comparison tests - - - -## Default MAgPIE ## - -cfg$title <- "default" -cfg$input <- c("isimip_rcp-IPSL_CM5A_LR-rcp8p5-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz", - "rev4_690d3718e151be1b450b394c1064b1c5_magpie.tgz", - "rev4_690d3718e151be1b450b394c1064b1c5_validation.tgz", - "additional_data_rev3.45.tgz") -cfg$gms$c_timesteps <- "5year2050" -start_run(cfg=cfg,codeCheck=codeCheck) - - - -## Regionalized MAgPIE ## - - - -cfg$title <- "MAgPIE_Brasil" -cfg$input <- c("isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_BRA4_e90458394d5302941049f44b72ff08dc.tgz", - "rev4_e90458394d5302941049f44b72ff08dc_magpie.tgz", - "rev4_e90458394d5302941049f44b72ff08dc_validation.tgz", - "additional_data_rev3.45.tgz") -start_run(cfg=cfg,codeCheck=codeCheck) - - -#USA test# - - - -cfg$title <- "USA_focused" -cfg$input <- c("isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_USA4_2b409196626ee246982f5ec87323c01a.tgz", - "rev4_2b409196626ee246982f5ec87323c01a_magpie.tgz", - "rev4_2b409196626ee246982f5ec87323c01a_validation.tgz", - "additional_data_rev3.45.tgz") -start_run(cfg=cfg,codeCheck=codeCheck) - - diff --git a/scripts/start/cemics2.R b/scripts/start/cemics2.R deleted file mode 100644 index 3c89d294f2..0000000000 --- a/scripts/start/cemics2.R +++ /dev/null @@ -1,65 +0,0 @@ -# | (C) 2008-2019 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 - - -########################################################## -#### Script to MAgPIE test runs #### -########################################################## - -library(lucode) -source("scripts/start_functions.R") -source("scripts/performance_test.R") -source("config/default.cfg") - -#set defaults -codeCheck <- FALSE - -buildInputVector <- function(regionmapping = "h11", - project_name = "isimip_rcp", - climatescen_name= "rcp2p6", - co2 = "noco2", - climate_model = "IPSL_CM5A_LR", - resolution = "h200", - archive_rev = "24", - madrat_rev = "3.3", - validation_rev = "3.3", - additional_data = "additional_data_rev3.16.tgz") { - mappings <- c(h11="8a828c6ed5004e77d1ba2025e8ea2261", - h12="690d3718e151be1b450b394c1064b1c5", - mag="c30c1c580039c2b300d86cc46ff4036a") - archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") - archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") - madrat <- paste0("magpie_", mappings[regionmapping], "_rev", madrat_rev, ".tgz") - validation <- paste0("validation_", mappings[regionmapping], "_rev", validation_rev, ".tgz") - return(c(archive,madrat,validation,additional_data)) -} - - -### Single runs ### -#general settings -cfg$gms$c_timesteps <- 11 -cfg$gms$s15_elastic_demand <- 1 - -cfg$title <- "CEMICS2_SSP2_RCP45" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$force_download <- TRUE -cfg$input <- buildInputVector() -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-REMIND-MAGPIE" -cfg$recalibrate <- TRUE -start_run(cfg=cfg,codeCheck=codeCheck) - -cfg$title <- "CEMICS2_SSP2_RCP26" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$force_download <- TRUE -cfg$input <- buildInputVector() -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-26-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-26-REMIND-MAGPIE" -cfg$recalibrate <- TRUE -start_run(cfg=cfg,codeCheck=codeCheck) diff --git a/scripts/start/check_code.R b/scripts/start/check_code.R index 44c7b131ab..2e450d9af6 100644 --- a/scripts/start/check_code.R +++ b/scripts/start/check_code.R @@ -1,14 +1,16 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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: Checking code for consistency issues +# position: 2 +# ------------------------------------------------- -###################################### -#### Script to check MAgPIE code #### -###################################### -library(lucode) -codeCheck() + +library(gms) +gms::codeCheck() diff --git a/scripts/start/compilation_check.R b/scripts/start/compilation_check.R new file mode 100644 index 0000000000..bdf61a0633 --- /dev/null +++ b/scripts/start/compilation_check.R @@ -0,0 +1,18 @@ +# | (C) 2008-2025 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: download input and compile main.gms +# position: 7 +# ------------------------------------------------ + +source("scripts/start_functions.R") +source("config/default.cfg") +download_and_update(cfg) + +# compile main.gms +system("gams main.gms action=c") diff --git a/scripts/start/default.R b/scripts/start/default.R index 87a0ab3816..ff72009e8a 100644 --- a/scripts/start/default.R +++ b/scripts/start/default.R @@ -1,14 +1,14 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 - -###################################### -#### Script to start a MAgPIE run #### -###################################### +# ------------------------------------------------ +# description: start run with default.cfg settings +# position: 1 +# ------------------------------------------------ # Load start_run(cfg) function which is needed to start MAgPIE runs source("scripts/start_functions.R") diff --git a/scripts/start/demandtest.R b/scripts/start/demandtest.R deleted file mode 100644 index ed4a8ed8b8..0000000000 --- a/scripts/start/demandtest.R +++ /dev/null @@ -1,268 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -library(lucode) -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 - -#specify the title flag for all the scenarios -flag <- "bmi" - -#SSPs -for (ssp in c("SSP2","SSP1","SSP3","SSP4","SSP5")) { - for(rcp in c("Ref","26")){ - cfg <- setScenario(cfg,c(ssp,if(rcp=="Ref") "NPI" else "NDC")) - - if(rcp=="Ref"){spa="SPA0"}else{spa=paste0("SPA",substring(ssp,4,5))} - if(ssp%in%c("SSP1","SSP2","SSP5")){ - model="REMIND-MAgPIE" - } else if (ssp=="SSP3"){ - model="AIM-CGE" - } else if (ssp=="SSP4"){ - model="GCAM4" - } - - cfg$title <- paste(if(rcp=="26" & ssp %in% c("SSP3","SSP4")) next else ssp,rcp,flag,sep="_") - cfg$gms$c56_pollutant_prices <- paste("SSPDB",ssp,rcp,model,sep="-") - cfg$gms$c60_2ndgen_biodem <- paste("SSPDB",ssp,rcp,model,sep="-") - start_run(cfg,codeCheck=FALSE) - cfg$recalibrate <- FALSE - } -} - -#CC -cfg$gms$c14_yields_scenario <- "cc" -cfg$gms$c42_watdem_scenario <- "cc" -cfg$gms$c43_watavail_scenario <- "cc" -cfg$gms$c52_carbon_scenario <- "cc" - -##SSP1 -# cfg$title <- paste("SSP1_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP1-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NPI")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-Ref-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP1_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP1-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NDC")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-26-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-26-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP2 -# cfg$title <- paste("SSP2_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NPI")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP2_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NDC")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-26-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-26-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP3 -# cfg$title <- paste("SSP3_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) -# -cfg$title <- paste("SSP3_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP3","NPI")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_co2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - - - - - -#start MAgPIE run -source("config/default.cfg") -cfg$results_folder <- "output/:title:" -cfg$recalibrate <- TRUE - -#specify the title flag for all the scenarios -flag <- "anthro" -cfg$gms$food <- "anthropometrics_jan18" - -#SSPs -for (ssp in c("SSP2","SSP1","SSP3","SSP4","SSP5")) { - for(rcp in c("Ref","26")){ - cfg <- setScenario(cfg,c(ssp,if(rcp=="Ref") "NPI" else "NDC")) - - if(rcp=="Ref"){spa="SPA0"}else{spa=paste0("SPA",substring(ssp,4,5))} - if(ssp%in%c("SSP1","SSP2","SSP5")){ - model="REMIND-MAgPIE" - } else if (ssp=="SSP3"){ - model="AIM-CGE" - } else if (ssp=="SSP4"){ - model="GCAM4" - } - - cfg$title <- paste(if(rcp=="26" & ssp %in% c("SSP3","SSP4")) next else ssp,rcp,flag,sep="_") - cfg$gms$c56_pollutant_prices <- paste("SSPDB",ssp,rcp,model,sep="-") - cfg$gms$c60_2ndgen_biodem <- paste("SSPDB",ssp,rcp,model,sep="-") - start_run(cfg,codeCheck=FALSE) - cfg$recalibrate <- FALSE - } -} - -#CC -cfg$gms$c14_yields_scenario <- "cc" -cfg$gms$c42_watdem_scenario <- "cc" -cfg$gms$c43_watavail_scenario <- "cc" -cfg$gms$c52_carbon_scenario <- "cc" - -##SSP1 -# cfg$title <- paste("SSP1_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP1-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NPI")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-Ref-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP1_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP1","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP1-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP1-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP1_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP1","NDC")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-26-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-26-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP2 -# cfg$title <- paste("SSP2_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NPI")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP2_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP2","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA0-V15-REMIND-MAGPIE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -cfg$title <- paste("SSP2_26_RCP26_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP2","NDC")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-26-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-26-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -##SSP3 -# cfg$title <- paste("SSP3_Ref_RCP60_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NPI")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) -# -cfg$title <- paste("SSP3_Ref_RCP60_co2",flag,sep="_") -cfg <- setScenario(cfg,c("SSP3","NPI")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp6p0-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_noco2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) - -# cfg$title <- paste("SSP3_26_RCP26_co2",flag,sep="_") -# cfg <- setScenario(cfg,c("SSP3","NDC")) -# cfg$gms$c56_pollutant_prices <- "SSP3-Ref-SPA0-V15-AIM-CGE" -# cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA0" -# cfg$input[1] <- "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev33_h200_690d3718e151be1b450b394c1064b1c5.tgz" -# start_run(cfg,codeCheck=FALSE) diff --git a/scripts/start/deprecated/INFO.yml b/scripts/start/deprecated/INFO.yml new file mode 100644 index 0000000000..5517c039f0 --- /dev/null +++ b/scripts/start/deprecated/INFO.yml @@ -0,0 +1,4 @@ +type: start script +description: Deprecated scripts +note: Scripts in this selection are deprecated and will soon be removed. +position: 10.0 diff --git a/scripts/start/disagg.R b/scripts/start/disagg.R deleted file mode 100644 index 8c079327e5..0000000000 --- a/scripts/start/disagg.R +++ /dev/null @@ -1,32 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -library(lucode) -source("scripts/start_functions.R") -source("config/default.cfg") - - -test <- c("foragebased_aug18","simple_oct17","foragebased_sep18_nocalib","foragebased_sep18") - -for(i in (1:4)){ - cfg$title <- paste0("SSP2_REF_",test[i]) - if(i==3) cfg$gms$disagg_lvst <- "foragebased_sep18" - if(i==3) cfg$recalibrate <- FALSE - cfg <- setScenario(cfg,c("SSP2","NPI")) - cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" - cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" - start_run(cfg=cfg,codeCheck=FALSE) - cfg$recalibrate <- TRUE -} - - - diff --git a/scripts/start/download_data.R b/scripts/start/download_data.R new file mode 100644 index 0000000000..f3ffe0d818 --- /dev/null +++ b/scripts/start/download_data.R @@ -0,0 +1,15 @@ +# | (C) 2008-2025 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: just download default.cfg input data +# position: 3 +# ------------------------------------------------- + +source("scripts/start_functions.R") +source("config/default.cfg") +download_and_update(cfg) diff --git a/scripts/start/download_data_only.R b/scripts/start/download_data_only.R deleted file mode 100644 index 796d9585ca..0000000000 --- a/scripts/start/download_data_only.R +++ /dev/null @@ -1,16 +0,0 @@ -# | (C) 2008-2019 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 - - -require(lucode) - -source("config/default.cfg") -lucode::download_distribute(files = cfg$input, - repositories = cfg$repositories, - modelfolder = ".", - additionalDelete = "scripts/downloader/inputdelete.cfg", - debug = cfg$debug) diff --git a/scripts/start/emulator.R b/scripts/start/emulator.R deleted file mode 100644 index 0c87cc9215..0000000000 --- a/scripts/start/emulator.R +++ /dev/null @@ -1,149 +0,0 @@ -# | (C) 2008-2019 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 -######################################################### -#### Start MAgPIE runs to derive price emulator from #### -######################################################### - -library(lucode) -library(magpie4) -library(txtplot) - -source("scripts/start_functions.R") -source("config/default.cfg") - -############################################################### -##################### General settings ######################## -############################################################### - -cfg$results_folder <- "output/:title:" -cfg$output <- c("report","emulator") #unique(c(cfg$output,"remind","bioenergy","coupling_report","david")) - -# use old regions: c30c1c580039c2b300d86cc46ff4036a -# use H12 regions: 690d3718e151be1b450b394c1064b1c5 -#cfg$input <- c("isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev29_h200_690d3718e151be1b450b394c1064b1c5.tgz", -# "rev3.15_690d3718e151be1b450b394c1064b1c5_magpie.tgz", -# "rev3.15_690d3718e151be1b450b394c1064b1c5_validation.tgz", -# "additional_data_rev3.28.tgz", -# "npi_ndc_base_SSP2_fixed.tgz") - -# Download bioenergy demand scenarios -filemap <- lucode::download_unpack(input="emulator.tgz", targetdir="input", repositories=list("/p/projects/landuse/data/input/archive"=NULL), debug=FALSE) -d <- readRDS("input/emulator.Rdata") -demand <- time_interpolate(d,interpolated_year=seq(1995,2100,5),extrapolation_type="constant") -getSets(demand) <- getSets(d) -# add years after 2100 -demand <- add_columns(demand,dim = 2.1,addnm = c("y2110","y2130","y2150")) -# keep demand constant after 2100 -demand[,c("y2110","y2130","y2150"),] <- setYears(demand[,"y2100",]) - -#reg <- read.csv2(cfg$regionmapping) # read regional resolution, used for ghg tax -reg <- list(RegionCode = "GLO") - -scenarios <- read.csv2("config/scenario_config_emulator.csv",strip.white=TRUE,stringsAsFactors=FALSE) -scenarios <- subset(scenarios, subset=(start == "1")) - -############################################################### -######################## Functions ############################ -############################################################### - -# calculate expoLinear tax with transition in 2060 -write.ghgtax <- function(co2tax_2025=NULL,regions=NULL,out="./modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") { - - # First year with global uniform CO2 price is 2025 - # Values taken from reporting in /p/projects/remind/runs/r7034/ - # SSP1-26-load_2017-02-03_19.27.43: 48.1662949 US$2005/tCO2 - # SSP2-26-load_2017-02-03_21.28.48: 61.6774368 US$2005/tCO2 - - if(is.null(co2tax_2025)) stop("No initial value for ghg tax supplied.") - if(is.null(regions)) stop("Please supply regions for ghg tax.") - - # construct combination of exponential tax (5% increase) until 2050 and linear continuation thereafter (using the slope of 2045-2050) - time <- seq(1995,2100,5) - co2tax <- as.numeric(co2tax_2025) * 1.05 ^(time-2025) - names(co2tax)<-time - slope <- (co2tax["2050"] - co2tax["2045"]) / (2050 - 2045) - co2tax[names(co2tax)>"2050"] <- co2tax["2050"] + slope * (time[time>2050] - 2050) - - ghgtax <- new.magpie(cells_and_regions = regions,years = time,fill = NA,sets = c("regions","years","gas"),names = c("n2o_n_direct","n2o_n_indirect","ch4","co2_c")) - - # unit defined in modules/56_ghg_policy/input/f56_pollutant_prices.cs3: US$ 2005 per Mg N2O-N CH4 and CO2-C - ghgtax[,,"co2_c"] <- as.magpie(co2tax) * 44/12 # US$2005/tCO2 -> US$2005/tC - ghgtax[,,"ch4"] <- as.magpie(co2tax) * 28 # US$2005/tCO2 -> US$2005/tCH4 (using Global Warming Potentials from AR5 WG1 CH08 Table 8.7) - ghgtax[,,"n2o_n_direct"] <- as.magpie(co2tax) * 44/28 * 265 # US$2005/tCO2 -> US$2005/tN (using Global Warming Potentials from AR5 WG1 CH08 Table 8.7) - ghgtax[,,"n2o_n_indirect"] <- as.magpie(co2tax) * 44/28 * 265 # US$2005/tCO2 -> US$2005/tN (using Global Warming Potentials from AR5 WG1 CH08 Table 8.7) - - # set ghg prices before and in 2020 to zero - ghgtax[,getYears(ghgtax)<="y2020",] <- 0 - # add years after 2100 - ghgtax <- add_columns(ghgtax,dim = 2.1,addnm = c("y2110","y2130","y2150")) - # keep ghgtax constant after 2100 - ghgtax[,c("y2110","y2130","y2150"),] <- setYears(ghgtax[,"y2100",]) - - # create textplot - cat("CO2 price in 2025:",as.numeric(co2tax_2025),"\n") - for_plot <- ghgtax[1,,"co2_c"] * 12/44 # convert unit back just for plotting - #for_plot <- for_plot[,c("y1995","y2110","y2130","y2150"),,invert=TRUE] - txtplot(as.numeric(gsub("y","",getYears(for_plot))),for_plot,ylab="US$2005/tCO2") - - write.magpie(ghgtax,file_name = out) - - #library(ggplot2) - #library(luplot) - #ggplot(gginput(as.magpie(co2tax)), aes(x=year, y=.value)) + geom_line() -} - -############################################################### -################# Individual scenarios ######################## -############################################################### - -for (scen in rownames(scenarios)) { - - cat("\n################ Scenario",scen,"################\n") - # Configure MAgPIE - # Set scenario - cfg<-setScenario(cfg,scenario = c(trimws(unlist(strsplit(scenarios[scen,"mag_scen"],split=","))))) - # emulator has to be set AFTER SSP because SSP would set bioenergy demand to predefined scenario and not to input from this script - cfg<-setScenario(cfg,scenario="emulator") - - # Choose GHG tax scenario - if (scenarios[scen,"co2tax_2025"] == "built-in") { - # see magpie/config/default.cfg for available scenarios - cfg$gms$c56_pollutant_prices <- scenarios[scen,"co2tax_name"] - } else { - # If none of the built-in GHG price scenarios was chosen, provide GHG prices - cfg$gms$c56_pollutant_prices <- "emulator" - cat("Writing GHG tax scenario",scenarios[scen,"co2tax_name"],"\n") - write.ghgtax(co2tax_2025=scenarios[scen,"co2tax_2025"],regions=unique(reg$RegionCode)) - } - - # Compose string with scenario name - expname <- paste0(gsub(",","-",scenarios[scen,"mag_scen"]),"-",scenarios[scen,"co2tax_name"]) - - # run numbers sorted in descending by runtime (taken from former SSP2-26 emulator runs) - runtime_order <- c("4","17","34","12","11","22","32","15","21","2","58","18","20","16","19", - "31","67","41","48","54","65","47","13","44","70","28","52","53","62","36","40","9","14","46", - "10","29","38","71","57","50","60","37","64","69","68","51","61","5","27","7","66","6","49", - "35","45","59","56","24","72","25","63","42","30","1","55","43","26","3","39","73","23","33","8") - # the intersect command in the for-loop below keeps the order of the vector given first - - # Copy bioenergy demand files and start runs - for(r in intersect(runtime_order,getNames(demand))) { - #for(r in as.character(c(1))) { - cfg$title <- paste(expname,r,sep="-") - cat(cfg$title,"Writing bioenergy demand scenario",r,"\n") - # create text plot - dem <- dimSums(demand[,,r],dim=1) - for_plot <- dem/1000 - #for_plot <- for_plot[,c("y1995","y2110","y2130","y2150"),,invert=TRUE] - txtplot(as.numeric(gsub("y","",getYears(for_plot))),for_plot,ylab="EJ/yr") - write.magpie(setNames(dem,NULL), file_name = "./modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv") - manipulateConfig("scripts/run_submit/submit.sh","--job-name"=cfg$title,line_endings = "NOTwin") - start_run(cfg,codeCheck=FALSE) - } -} - -cat("Finished starting of emulator runs!\n") diff --git a/scripts/start/extra/INFO.yml b/scripts/start/extra/INFO.yml new file mode 100644 index 0000000000..5f32c01753 --- /dev/null +++ b/scripts/start/extra/INFO.yml @@ -0,0 +1,3 @@ +description: Additional MAgPIE start scripts +note: Scripts in this selection might require some manual adjustments before they work with the given MAgPIE version as they are not necessarily updated along with changes in the model code. +position: 2.0 diff --git a/scripts/start/extra/calc_residuePot2ndBE.R b/scripts/start/extra/calc_residuePot2ndBE.R new file mode 100644 index 0000000000..8bc42b9336 --- /dev/null +++ b/scripts/start/extra/calc_residuePot2ndBE.R @@ -0,0 +1,86 @@ +# | (C) 2008-2025 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 residue potential for 2nd generation bioenergy for multiple SSP/NPi2025 scenarios +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +#download default input data +download_and_update(cfg) + +cfg$info$flag <- "residuePot" + +# support function to create standardized title +.title <- function(cfg, ...) return(paste(cfg$info$flag, sep = "_", ...)) + +# Define scenarios and their specific parameters, then iterate over them +scenarios <- list( + list( + name = "SSP1", + titleSuffix = "NPi2025", + scen = c("SSP1", "NPI", "nocc_hist"), + pollString = "R34M410-SSP1-NPi2025", + bioString = "R34M410-SSP1-NPi2025" + ), + list( + name = "SSP2", + titleSuffix = "NPi2025", + scen = c("SSP2", "NPI", "nocc_hist"), + pollString = "R34M410-SSP2-NPi2025", + bioString = "R34M410-SSP2-NPi2025" + ), + list( + name = "SSP3", + titleSuffix = "NPi2025", + scen = c("SSP3", "NPI", "nocc_hist"), + pollString = "R34M410-SSP3-NPi2025", + bioString = "R34M410-SSP3-NPi2025" + ), + list( + name = "SSP4", + titleSuffix = "NPi2025", + scen = c("SSP4", "NPI", "nocc_hist"), + # Note: pollString and bioString intentionally match original SSP4 block (SSP2 strings) + pollString = "R34M410-SSP2-NPi2025", + bioString = "R34M410-SSP2-NPi2025" + ), + list( + name = "SSP5", + titleSuffix = "NPi2025", + scen = c("SSP5", "NPI", "nocc_hist"), + pollString = "R34M410-SSP5-NPi2025", + bioString = "R34M410-SSP5-NPi2025" + ), + list( + name = "SDP", + titleSuffix = "NPi2025", + scen = c("SDP", "NPI", "nocc_hist"), + pollString = "R32M46-SDP_MC-NPi", + bioString = "R32M46-SDP_MC-NPi" + ) +) + +for (s in scenarios) { + cfg$title <- .title(cfg, paste(s$name, s$titleSuffix, sep = "-")) + cfg <- setScenario(cfg, s$scen) + cfg$gms$c60_res_2ndgenBE_dem <- "off" + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- s$pollString + cfg$gms$c60_2ndgen_biodem <- s$bioString + start_run(cfg, codeCheck = FALSE) +} diff --git a/scripts/start/extra/empty_model.R b/scripts/start/extra/empty_model.R new file mode 100644 index 0000000000..9cd98c4979 --- /dev/null +++ b/scripts/start/extra/empty_model.R @@ -0,0 +1,25 @@ +# | (C) 2008-2025 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: run an empty model, output is the latest AMT run +# ------------------------------------------------------------- + +source("scripts/start_functions.R") +source("config/default.cfg") + +# Find latest fulldata.gdx from automated model test (AMT) runs +amtRunDirs <- list.files("/p/projects/landuse/tests/magpie/output", + pattern = "default_\\d{4}-\\d{2}-\\d{2}_\\d{2}\\.\\d{2}.\\d{2}", + full.names = TRUE) +fullDataGdxs <- file.path(amtRunDirs, "fulldata.gdx") +latestFullData <- sort(fullDataGdxs[file.exists(fullDataGdxs)], decreasing = TRUE)[[1]] + +cfg <- configureEmptyModel(cfg, latestFullData) +cfg$title <- "empty_model" + +start_run(cfg = cfg, codeCheck = FALSE) diff --git a/scripts/start/extra/emulator.R b/scripts/start/extra/emulator.R new file mode 100644 index 0000000000..c2d0ea3c7d --- /dev/null +++ b/scripts/start/extra/emulator.R @@ -0,0 +1,151 @@ +# | (C) 2008-2025 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: run simulations for calculation of MAgPIE emulators +# --------------------------------------------------------------- + +######################################################### +#### Start MAgPIE runs to derive price emulator from #### +######################################################### + +library(gms) +library(magpie4) +library(txtplot) +library(lucode2) + +source("scripts/start_functions.R") +source("config/default.cfg") + +############################################################### +##################### General settings ######################## +############################################################### + +cfg$qos <- "standby" +cfg$results_folder <- "output/:title:" +cfg$output <- c("rds_report","extra/emulator") #unique(c(cfg$output,"remind","bioenergy","coupling_report","david")) +cfg$gms$s60_2ndgen_bioenergy_dem_min <- 0 + +# Download bioenergy demand scenarios +filemap <- gms::download_unpack(input="emulator.tgz", targetdir="input", repositories=list("/p/projects/landuse/data/input/archive"=NULL), debug=FALSE) +d <- readRDS("input/emulator.Rdata") +demand <- time_interpolate(d,interpolated_year=seq(1995,2100,5),extrapolation_type="constant") +getSets(demand) <- getSets(d) +# add years after 2100 +demand <- add_columns(demand,dim = 2.1,addnm = c("y2110","y2130","y2150")) +# keep demand constant after 2100 +demand[,c("y2110","y2130","y2150"),] <- setYears(demand[,"y2100",]) + +scenarios <- read.csv2("config/scenario_config_emulator.csv",strip.white=TRUE,stringsAsFactors=FALSE) +scenarios <- subset(scenarios, subset=(start == "1")) + +############################################################### +######################## Functions ############################ +############################################################### + +# Read GHG prices from REMIND or coupled mif file +write.ghgtax <- function(mifname, outfile) { + + fname <- paste0(mifname, ".mif") + + if(!file.exists(fname)) stop("Could not find ",fname) + + # If there is a REMIND report with the name, read the GHG prices from the file, otherwise calculate expo-linear tax + cat("Loading GHG prices from",fname,"\n") + tmp <- read.report(fname, as.list = FALSE) + + # Select variables from REMIND report + ghg_price_names <- c("Price|Carbon (US$2017/t CO2)", + "Price|N2O (US$2017/t N2O)", + "Price|CH4 (US$2017/t CH4)") + tmp <- collapseNames(tmp[,,ghg_price_names]) + # remove global dimension + tmp <- tmp["GLO",,,invert=TRUE] + + # interpolate missing years (REMIND has less_TS only, emulator script need 5 year time steps) + time <- seq(1995,2100,5) + tmp <- time_interpolate(tmp,interpolated_year=time,extrapolation_type="constant") + + ghgtax <- new.magpie(cells_and_regions = getRegions(tmp),years = time,fill = NA,sets = c("regions","years","gas"),names = c("n2o_n_direct","n2o_n_indirect","ch4","co2_c")) + + # unit defined in modules/56_ghg_policy/input/f56_pollutant_prices.cs3: US$ 2017 per Mg N2O-N CH4 and CO2-C + ghgtax[,,"co2_c"] <- tmp[,,"Price|Carbon (US$2017/t CO2)"] * 44/12 # US$2017/tCO2 -> US$2017/tC + ghgtax[,,"ch4"] <- tmp[,,"Price|CH4 (US$2017/t CH4)"] + ghgtax[,,"n2o_n_direct"] <- tmp[,,"Price|N2O (US$2017/t N2O)"] * 44/28 # US$2017/tN2O -> US$2017/tN + ghgtax[,,"n2o_n_indirect"] <- tmp[,,"Price|N2O (US$2017/t N2O)"] * 44/28 # US$2017/tN2O -> US$2017/tN + + # set ghg prices before and in 2020 to zero + ghgtax[,getYears(ghgtax)<="y2020",] <- 0 + # add years after 2100 + ghgtax <- add_columns(ghgtax,dim = 2.1,addnm = c("y2110","y2130","y2150")) + # keep ghgtax constant after 2100 + ghgtax[,c("y2110","y2130","y2150"),] <- setYears(ghgtax[,"y2100",]) + + # create textplot + cat("CO2 price in 2025:",ghgtax[,2025,"co2_c"],"\n") + for_plot <- ghgtax[1,,"co2_c"] * 12/44 # convert unit back just for plotting + #for_plot <- for_plot[,c("y1995","y2110","y2130","y2150"),,invert=TRUE] + txtplot(as.numeric(gsub("y","",getYears(for_plot))),for_plot,ylab="US$2017/tCO2") + + cat("Writing GHG tax scenario",scenarios[scen,"ghgtax_name"],"\n\n") + write.magpie(ghgtax, file_name = outfile) + + #library(ggplot2) + #library(luplot) + #ggplot(gginput(as.magpie(co2tax)), aes(x=year, y=.value)) + geom_line() +} + +############################################################### +################# Individual scenarios ######################## +############################################################### + +for (scen in rownames(scenarios)) { + + cat("\n################ Scenario",scen,"################\n") + # Configure MAgPIE + # Set scenario + cfg<-setScenario(cfg,scenario = c(trimws(unlist(strsplit(scenarios[scen,"mag_scen"],split="\\|"))))) + # emulator has to be set AFTER SSP because SSP would set bioenergy demand to predefined scenario and not to input from this script + cfg<-setScenario(cfg,scenario="emulator") + + # Choose GHG tax scenario + if (scenarios[scen,"mifname"] == "built-in") { + # see magpie/config/default.cfg for available scenarios + cfg$gms$c56_pollutant_prices <- scenarios[scen,"ghgtax_name"] + } else { + # If no built-in GHG price scenario was chosen, take GHG prices from REMIND report + cfg$gms$c56_pollutant_prices <- "emulator" + cfg$gms$c56_mute_ghgprices_until <- scenarios[scen, "no_ghgprices_land_until"] + write.ghgtax(mifname = scenarios[scen, "mifname"], outfile = "./modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") + } + + # Compose string with scenario name + expname <- paste0(gsub("\\|","-",scenarios[scen,"mag_scen"]),"-",scenarios[scen,"ghgtax_name"]) + + # run numbers sorted descending by runtime (determined with script sort_runtimes.R from dklein) + runtime_order <- c('32','68','5','46','22','58','41','53','65','11','10','12','47','70','17','34','56','18','54','29', + '62','57','2','26','48','51','20','8','15','52','21','44','16','30','71','38','13','50','67','35','45','1','37','6','31', + '49','40','24','60','69','14','4','9','33','66','61','64','25','42','55','28','23','19','7','43','59','63','39','3','72','73','36','27') + # the intersect command in the for-loop below keeps the order of the vector given first + + # Copy bioenergy demand files and start runs + for(r in intersect(runtime_order,getNames(demand))) { + #for(r in as.character(c(1))) { + cfg$title <- paste(expname,r,sep="-") + cat(cfg$title,"Writing bioenergy demand scenario",r,"\n") + # create text plot + dem <- dimSums(demand[,,r],dim=1) + for_plot <- dem/1000 + #for_plot <- for_plot[,c("y1995","y2110","y2130","y2150"),,invert=TRUE] + txtplot(as.numeric(gsub("y","",getYears(for_plot))),for_plot,ylab="EJ/yr") + write.magpie(setNames(dem,NULL), file_name = "./modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv") + manipulateConfig(paste0("scripts/run_submit/submit_", cfg$qos, ".sh"), "--job-name" = cfg$title, line_endings = "NOTwin") + start_run(cfg,codeCheck=FALSE) + } +} + +cat("Finished starting of emulator runs!\n") diff --git a/scripts/start/extra/input_REMIND.R b/scripts/start/extra/input_REMIND.R new file mode 100644 index 0000000000..27d8c4bfc3 --- /dev/null +++ b/scripts/start/extra/input_REMIND.R @@ -0,0 +1,56 @@ +# | (C) 2008-2025 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: uses bioenergy demand and GHG prices from REMIND as input for a run +# ---------------------------------------------------------- + +library(gms) +library(magclass) +library(gdx2) + +# 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$force_download <- TRUE + +cfg$results_folder <- "output/:title:" + +getInput <- function(gdx,ghg_price=TRUE,biodem=TRUE) { + if(ghg_price) { + a <- readGDX(gdx,"f56_pollutant_prices_coupling") + write.magpie(a,"modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3") + } + if(biodem) { + a <- readGDX(gdx,"f60_bioenergy_dem_coupling") + write.magpie(a,"modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv") + } +} + +cfg$output <- c("rds_report") + +cfg$gms$sm_fix_SSP2 <- 2020 + +prefix <- "RM01_" + +cfg$title <- paste0(prefix,"SSP2_NPI") +cfg <- setScenario(cfg,c("SSP2","NPI")) +cfg$gms$c56_pollutant_prices <- "coupling" +cfg$gms$c60_2ndgen_biodem <- "coupling" +getInput("/p/projects/piam/SDP_runs/SDP_round1/magpie_SDP/output/C_SSP2-NPi-mag-4/fulldata.gdx") +start_run(cfg,codeCheck=FALSE) + +cfg$title <- paste0(prefix,"SSP2_PkBudg900") +cfg <- setScenario(cfg,c("SSP2","NDC")) +cfg$gms$c56_pollutant_prices <- "coupling" +cfg$gms$c60_2ndgen_biodem <- "coupling" +getInput("/p/projects/piam/SDP_runs/SDP_round1/magpie_SDP/output/C_SSP2-PkBudg900-mag-4/fulldata.gdx") +start_run(cfg,codeCheck=FALSE) diff --git a/scripts/start/extra/irrig_dep_test.R b/scripts/start/extra/irrig_dep_test.R new file mode 100644 index 0000000000..a170d3f5d0 --- /dev/null +++ b/scripts/start/extra/irrig_dep_test.R @@ -0,0 +1,53 @@ +# | (C) 2008-2025 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: Test irrigation depreciation settings +# ------------------------------------------------ + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") +source("config/default.cfg") + +# short description of the actual run +cfg$title <- "develop_default" + +# Should input data be downloaded from source even if cfg$input did not change? +cfg$force_download <- TRUE + +#Selection of QOS to be used for submitted runs on cluster. +cfg$qos <- "priority" + +#Setting value for depreciation rate in 41_area_equipped_for_irrigation +cfg$gms$s41_AEI_depreciation <- 0 # def = 0 + +#start MAgPIE run +start_run(cfg) + +##dep rate as 0.05## + +## Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") +source("config/default.cfg") + +# short description of the actual run +cfg$title <- "develop_dep05" + +# Should input data be downloaded from source even if cfg$input did not change? +cfg$force_download <- TRUE + +#Selection of QOS to be used for submitted runs on cluster. +cfg$qos <- "priority" + +#Setting value for depreciation rate in 41_area_equipped_for_irrigation +cfg$gms$s41_AEI_depreciation <- 0.05 # def = 0 + + +#start MAgPIE run +start_run(cfg) +# +# diff --git a/scripts/start/extra/publish_data.R b/scripts/start/extra/publish_data.R new file mode 100644 index 0000000000..8c9495e835 --- /dev/null +++ b/scripts/start/extra/publish_data.R @@ -0,0 +1,17 @@ +# | (C) 2008-2025 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: publish data set as input in default.cfg on a server +# ----------------------------------------------------------------- + +require(gms) + +# publish data which is defined in default.cfg on https://rse.pik-potsdam.de/data/magpie/intern or magpie/public + +source("config/default.cfg") +gms::publish_data(cfg,target = "dataupload@rse.pik-potsdam.de:/magpie/intern|dataupload@rse.pik-potsdam.de:/magpie/public") diff --git a/scripts/start/extra/recalibrateH16.R b/scripts/start/extra/recalibrateH16.R new file mode 100644 index 0000000000..4f267913f7 --- /dev/null +++ b/scripts/start/extra/recalibrateH16.R @@ -0,0 +1,33 @@ +# | (C) 2008-2025 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 land conversion cost calibration factors for default setup (time consuming; up to 40 model runs with 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$input['regional'] <- "rev4.119_36f73207_magpie.tgz" +cfg$input['validation'] <- "rev4.119_36f73207_validation.tgz" +cfg$input['calibration'] <- "calibration_H16_FAO_03Feb25.tgz" +cfg$input['cellular'] <- "rev4.119_36f73207_44a213b6_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" + +cfg$results_folder <- "output/:title:" +cfg$recalibrate <- FALSE +cfg$recalibrate_landconversion_cost <- TRUE +cfg$title <- "calib_run_H16" +cfg$output <- c("rds_report") +cfg$force_replace <- TRUE +cfg$qos <- "priority" +start_run(cfg,codeCheck=FALSE) +magpie4::submitCalibration("H16_FAO") diff --git a/scripts/start/extra/recalibrate_FSEC.R b/scripts/start/extra/recalibrate_FSEC.R new file mode 100644 index 0000000000..b4fd187ed8 --- /dev/null +++ b/scripts/start/extra/recalibrate_FSEC.R @@ -0,0 +1,32 @@ +# | (C) 2008-2025 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 +# land conversion costs for FSEC regional setup +# (time consuming; up to 40 model runs with 5 time steps) +# -------------------------------------------------------- + +library(magpie4) +library(magclass) +library(gms) + +source("scripts/start_functions.R") +source("scripts/projects/fsec.R") + +# Calibration run +cfg <- fsecScenario(scenario = "c_BAU") +cfg$title <- "calib_run_FSEC" +cfg$results_folder <- "output/:title:" +cfg$recalibrate <- TRUE # required when penality_apr22 activated +cfg$best_calib <- TRUE +cfg$recalibrate_landconversion_cost <- TRUE +cfg$output <- c("rds_report") +cfg$force_replace <- TRUE +cfg$qos <- "priority" +start_run(cfg, codeCheck = FALSE) +magpie4::submitCalibration("FSEC_FAO") diff --git a/scripts/start/extra/recalibrate_default.R b/scripts/start/extra/recalibrate_default.R new file mode 100644 index 0000000000..b792deb4ef --- /dev/null +++ b/scripts/start/extra/recalibrate_default.R @@ -0,0 +1,28 @@ +# | (C) 2008-2025 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 land conversion cost calibration factors for default setup (time consuming; up to 40 model runs with 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:" +cfg$recalibrate <- FALSE +cfg$recalibrate_landconversion_cost <- TRUE +cfg$title <- "calib_run_H12" +cfg$output <- c("rds_report") +cfg$force_replace <- TRUE +cfg$qos <- "priority" +start_run(cfg,codeCheck=FALSE) +magpie4::submitCalibration("H12_FAO") diff --git a/scripts/start/extra/recalibrate_realizations.R b/scripts/start/extra/recalibrate_realizations.R new file mode 100644 index 0000000000..4a21ede321 --- /dev/null +++ b/scripts/start/extra/recalibrate_realizations.R @@ -0,0 +1,46 @@ +# | (C) 2008-2025 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 land conversion cost calibration factors for all factor cost module realizations (time consuming; up to 40 model runs with 5 time steps) +# -------------------------------------------------------- + +library(magpie4) +library(magclass) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# get default settings +source("config/default.cfg") + +realizations <- c("per_ton_fao_may22", "sticky_feb18") # "sticky_labor" is very similar to sticky_feb18. No extra calibration needed. +type <- NULL + +cfg$results_folder <- "output/:title:" +cfg$recalibrate <- FALSE +cfg$recalibrate_landconversion_cost <- TRUE + +cfg$output <- c("rds_report") +cfg$force_download <- TRUE + +cfg$gms$c_timesteps <- "calib" + +for (r in realizations) { + cfg$gms$factor_costs <- r + + cfg$best_calib <- TRUE + + for (fac_req in c("reg", "glo")) { + cfg$gms$c38_fac_req <- fac_req + cfg$gms$c70_fac_req_regr <- fac_req + cfg$title <- paste("calib_run", r, fac_req, sep = "_") + cfg$qos <- "priority" + start_run(cfg) + magpie4::submitCalibration(paste("H12", r, fac_req, sep = "_")) + } +} diff --git a/scripts/start/extra/test_maccs.R b/scripts/start/extra/test_maccs.R new file mode 100644 index 0000000000..a8ee204562 --- /dev/null +++ b/scripts/start/extra/test_maccs.R @@ -0,0 +1,51 @@ +# | (C) 2008-2025 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: Test marginal abatement costs +# ---------------------------------------------------------- + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +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") + +prefix <- "maccs_test_v10" + +for(ssp in c("SSP1","SSP2","SSP3","SSP4","SSP5")){ + source("config/default.cfg") + cfg=setScenario(cfg=cfg,scenario=ssp) + cfg$title <- paste(prefix,"newdefault",ssp,sep="_") + start_run(cfg,codeCheck=FALSE) + + source("config/default.cfg") + cfg=setScenario(cfg=cfg,scenario=ssp) + cfg$title <- paste(prefix,"newdefault_mitigation",ssp,sep="_") + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" # def = R21M42-SSP2-NPi + cfg$gms$c56_pollutant_prices_noselect <- "R21M42-SSP2-PkBudg900" # def = R21M42-SSP2-NPi + start_run(cfg,codeCheck=FALSE) + + source("config/default.cfg") + cfg=setScenario(cfg=cfg,scenario=ssp) + cfg$title <- paste(prefix,"newsetup_maxmaccs",ssp,sep="_") + cfg$gms$s57_maxmac_n_soil <- 201 # def = -1 + cfg$gms$s57_maxmac_n_awms <- 201 # def = -1 + cfg$gms$s57_maxmac_ch4_rice <- 201 # def = -1 + cfg$gms$s57_maxmac_ch4_entferm <- 201 # def = -1 + cfg$gms$s57_maxmac_ch4_awms <- 201 # def = -1 + start_run(cfg,codeCheck=FALSE) +} diff --git a/scripts/start/extra/test_n.R b/scripts/start/extra/test_n.R new file mode 100644 index 0000000000..069634716f --- /dev/null +++ b/scripts/start/extra/test_n.R @@ -0,0 +1,33 @@ +# | (C) 2008-2025 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: start run with default.cfg settings +# position: 1 +# ------------------------------------------------ + +# 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$gms$nitrogen="ipcc2006_sep16" +cfg$title="default_high_nue" +cfg$gms$c50_scen_neff <- "neff85_85_starty2010" # def = neff60_60_starty2010 +cfg$gms$c50_scen_neff_noselect <- "neff85_85_starty2010" # def = neff60_60_starty2010 +cfg$gms$c50_scen_neff_pasture <- "neff80_85_starty2010" # def = constant +cfg$gms$c50_scen_neff_pasture_noselect <- "neff80_85_starty2010" +start_run(cfg) + +cfg$gms$nitrogen="rescaled_jan21" +cfg$title="rescaled_high_nue" +cfg$gms$c50_scen_neff <- "neff85_85_starty2010" # def = neff60_60_starty2010 +cfg$gms$c50_scen_neff_noselect <- "neff85_85_starty2010" # def = neff60_60_starty2010 +cfg$gms$c50_scen_neff_pasture <- "neff80_85_starty2010" # def = constant +cfg$gms$c50_scen_neff_pasture_noselect <- "neff80_85_starty2010" +start_run(cfg) + diff --git a/scripts/start/fable_prep.R b/scripts/start/fable_prep.R deleted file mode 100644 index 8fe3eaf150..0000000000 --- a/scripts/start/fable_prep.R +++ /dev/null @@ -1,58 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") -source("config/default.cfg") - -library(magpie4) -library(lucode) - -buildInputVector <- function(regionmapping = "aus", - project_name = "isimip_rcp", - climatescen_name= "rcp2p6", - co2 = "co2", - climate_model = "IPSL_CM5A_LR", - resolution = "c200", - archive_rev = "34", - madrat_rev = "4.18", - validation_rev = "4.18", - calibration = NULL, - additional_data = "additional_data_rev3.66.tgz") { - mappings <- c(h12="690d3718e151be1b450b394c1064b1c5") - archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") - if(regionmapping=="h12") archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings["h12"], ".tgz") - else archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", toupper(regionmapping),"4_",mappings["h12"], ".tgz") - madrat <- paste0("rev", madrat_rev, "_", mappings["h12"], "_magpie.tgz") - validation <- paste0("rev", validation_rev, "_", mappings["h12"], "_validation.tgz") - return(c(archive,madrat,validation,calibration,additional_data)) -} - -calib_date <- "21Mar19" - -for(x in c("h12","ind","cha")) { - if(exists("calib_date") && !is.null(calib_date)) { - calibration <- paste0("calibration_",x,"_",calib_date,".tgz") - if(x=="h12") calibration <- "calibration_H12_c200_12Sep18.tgz" - } else { - calibration <- NULL - } - cfg$title <- x - cfg$input <- buildInputVector(regionmapping=x, calibration=calibration) - if(is.null(calibration)){ - start_run(cfg=cfg) - calib <- submitCalibration(x) - cfg$input <- c(cfg$input,calib) - } - if(x=="h12") x <- "default" - publish_data(input=cfg, name=paste0("magpie4.1_",x,"_apr19"), target=".") -} diff --git a/scripts/start/fable_start.R b/scripts/start/fable_start.R deleted file mode 100644 index 96becc52b0..0000000000 --- a/scripts/start/fable_start.R +++ /dev/null @@ -1,17 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -# Load start_run(cfg) function which is needed to start MAgPIE runs -source("scripts/start_functions.R") - -#start MAgPIE run -start_run(cfg="fable.cfg") diff --git a/scripts/start/fix_som.R b/scripts/start/fix_som.R deleted file mode 100644 index cb78696d19..0000000000 --- a/scripts/start/fix_som.R +++ /dev/null @@ -1,56 +0,0 @@ -# | (C) 2008-2019 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 - - -########################################################## -#### Script to MAgPIE test runs #### -########################################################## - -library(lucode) -source("scripts/start_functions.R") -source("config/default.cfg") - - -buildInputVector <- function(regionmapping = "h12", - project_name = "isimip_rcp", - climatescen_name= "rcp2p6", - co2 = "noco2", - climate_model = "IPSL_CM5A_LR", - resolution = "h200", - archive_rev = "33", - madrat_rev = "3.33", - validation_rev = "3.33", - calibration = NULL, - additional_data = "additional_data_rev3.40.tgz", - npi_base = "calibration_H12_29Jun18.tgz") { - mappings <- c(h11="8a828c6ed5004e77d1ba2025e8ea2261", - h12="690d3718e151be1b450b394c1064b1c5", - mag="c30c1c580039c2b300d86cc46ff4036a") - archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") - archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") - madrat <- paste0("rev", madrat_rev, "_", mappings[regionmapping], "_magpie.tgz") - validation <- paste0("rev", validation_rev, "_", mappings[regionmapping], "_validation.tgz") - return(c(archive,madrat,validation,calibration,additional_data,npi_base)) -} - - -cfg$title <- "new_carbon_som_on" -cfg$input <- buildInputVector() -cfg$gms$som <- "cellpool_aug16" -cfg$gms$c59_som_scenario <- "nocc" # def = "nocc" -start_run(cfg=cfg,codeCheck=FALSE) - -cfg$title <- "new_carbon_som_off" -cfg$input <- buildInputVector() -cfg$gms$som <- "off" -start_run(cfg=cfg,codeCheck=FALSE) - - -cfg$title <- "old_carbon_som_off" -cfg$input <- buildInputVector(archive_rev="32") -cfg$gms$som <- "off" -start_run(cfg=cfg,codeCheck=FALSE) diff --git a/scripts/start/forestry.R b/scripts/start/forestry.R new file mode 100644 index 0000000000..d5c5b57682 --- /dev/null +++ b/scripts/start/forestry.R @@ -0,0 +1,28 @@ +# | (C) 2008-2025 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: start run with Forestry (Endogenous) +# position: 6 +# ------------------------------------------------ + + +library(gms) + +# 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 <- setScenario(cfg,c("SSP2","NPI","ForestryEndo")) +#cfg <- setScenario(cfg,c("SSP2","NPI","ForestryExo")) +#cfg <- setScenario(cfg,c("SSP2","NPI","ForestryOff")) + +cfg$title <- "forestry" +start_run(cfg,codeCheck = FALSE) diff --git a/scripts/start/inms.R b/scripts/start/inms.R deleted file mode 100644 index 2fa7950231..0000000000 --- a/scripts/start/inms.R +++ /dev/null @@ -1,84 +0,0 @@ -# | (C) 2008-2019 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 - - -########################################################## -#### Script to MAgPIE test runs #### -########################################################## - -library(lucode) -source("scripts/start_functions.R") -source("scripts/performance_test.R") -source("config/default.cfg") - -#set defaults -codeCheck <- FALSE - -buildInputVector <- function(regionmapping = "h11", - project_name = "isimip_rcp", - climatescen_name= "rcp2p6", - co2 = "noco2", - climate_model = "IPSL_CM5A_LR", - resolution = "h200", - archive_rev = "29", - madrat_rev = "3.15", - validation_rev = "3.15", - additional_data = "additional_data_rev3.26.tgz", - npi="npi_ndc_base_SSP2_fixed.tgz") { - mappings <- c(h11="8a828c6ed5004e77d1ba2025e8ea2261", - h12="690d3718e151be1b450b394c1064b1c5", - mag="c30c1c580039c2b300d86cc46ff4036a", - inms="69c65bb3c88e8033cf8df6b5ac5d52a9", - inms2="ef2ae7cd6110d5d142a9f8bd7d5a68f2") - archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") - archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") - madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie.tgz") - validation <- paste0("rev",validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") - return(c(archive,madrat,validation,additional_data,npi)) -} - - - -### Single runs ### -#general settings -cfg$gms$c_timesteps <- 12 - -# clalibration runs - -cfg$title <- "INMS2_casestudies" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$gms$s15_elastic_demand = 1 -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-60-MESSAGE-GLOBIOM" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-60-MESSAGE-GLOBIOM" -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp6p0",regionmapping="inms") -#cfg$gms$som<-"cellpool_aug16" -cfg$gms$factor_costs <- "sticky_feb18" -cfg$recalc_npi_ndc <- FALSE -cfg$gms$c32_aff_policy <- "none" -cfg$gms$c35_ad_policy <- "none" -cfg$recalibrate <- TRUE -start_run(cfg=cfg,codeCheck=codeCheck) -cfg$recalibrate <- FALSE - - -#SSP1,5 family - - -cfg$title <- "INMS1_casestudies" -cfg<-lucode::setScenario(cfg,"SUSTAg1") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6",regionmapping="inms") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP5-26-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP5-26-REMIND-MAGPIE" -start_run(cfg=cfg,codeCheck=codeCheck) - -cfg$title <- "INMS5_casestudies" -cfg<-lucode::setScenario(cfg,"SUSTAg5") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-45-IMAGE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-45-IMAGE" -start_run(cfg=cfg,codeCheck=codeCheck) diff --git a/scripts/start/inms2.R b/scripts/start/inms2.R deleted file mode 100644 index ffffb92d4a..0000000000 --- a/scripts/start/inms2.R +++ /dev/null @@ -1,122 +0,0 @@ -# | (C) 2008-2019 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 - - -########################################################## -#### Script to MAgPIE test runs #### -########################################################## - -library(lucode) -source("scripts/start_functions.R") -source("scripts/performance_test.R") -source("config/default.cfg") - -#set defaults -codeCheck <- FALSE - -buildInputVector <- function(regionmapping = "agmip", - project_name = "isimip_rcp", - climatescen_name= "rcp2p6", - co2 = "noco2", - climate_model = "IPSL_CM5A_LR", - resolution = "c200", - archive_rev = "34", - madrat_rev = "4.14", - validation_rev = "4.14", - calibration = "calibration_agmip_c200_19Dec18.tgz", - additional_data = "additional_data_rev3.65.tgz") { - mappings <- c(h11="8a828c6ed5004e77d1ba2025e8ea2261", - h12="690d3718e151be1b450b394c1064b1c5", - mag="c30c1c580039c2b300d86cc46ff4036a", - inms="69c65bb3c88e8033cf8df6b5ac5d52a9", - inms2="ef2ae7cd6110d5d142a9f8bd7d5a68f2", - agmip="c77f075908c3bc29bdbe1976165eccaf") - archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") - archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") - madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie.tgz") - validation <- paste0("rev",validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") - return(c(archive,madrat,validation,additional_data)) -} - - - -### Single runs ### -#general settings -cfg$gms$c_timesteps <- 12 - -# clalibration runs - -cfg$title <- "INMS_SSP2_RCP45_Nmed" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="agmip") -cfg$gms$som<-"cellpool_aug16" -#cfg$gms$factor_costs <- "sticky_feb18" -start_run(cfg=cfg,codeCheck=codeCheck) - - -#SSP1,5 family - -cfg$title <- "INMS_SSP1_RCP26_Nhigh_diet" - -cfg$title <- "INMS_SSP1_RCP26_Nhigh" -cfg<-lucode::setScenario(cfg,"SUSTAg1") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-26-IMAGE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-26-IMAGE" -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6",regionmapping="agmip") -cfg$gms$som<-"cellpool_aug16" -#cfg$gms$factor_costs <- "sticky_feb18" -cfg$gms$c50_scen_neff <- "neff80_85_starty2010" -start_run(cfg=cfg,codeCheck=codeCheck) - -cfg$title <- "INMS_SSP1_RCP45_Nhigh" -cfg<-lucode::setScenario(cfg,"SUSTAg1") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-45-IMAGE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-45-IMAGE" -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="agmip") -cfg$gms$som<-"cellpool_aug16" -#cfg$gms$factor_costs <- "sticky_feb18" -cfg$gms$c50_scen_neff <- "neff80_85_starty2010" -start_run(cfg=cfg,codeCheck=codeCheck) - - -cfg$title <- "INMS_SSP2_RCP45_Nlow" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="agmip") -cfg$gms$som<-"cellpool_aug16" -cfg$gms$c50_scen_neff <- "constant" -#cfg$gms$factor_costs <- "sticky_feb18" -start_run(cfg=cfg,codeCheck=codeCheck) - -cfg$title <- "INMS_SSP2_RCP45_Nhigh" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="agmip") -cfg$gms$som<-"cellpool_aug16" -cfg$gms$c50_scen_neff <- "neff80_85_starty2010" -#cfg$gms$factor_costs <- "sticky_feb18" -start_run(cfg=cfg,codeCheck=codeCheck) - -cfg$title <- "SSP5_RCP85_Nlow" -cfg<-lucode::setScenario(cfg,"SUSTAg5") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP5-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP5-Ref-REMIND-MAGPIE" -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp8p5",regionmapping="agmip") -cfg$gms$som<-"cellpool_aug16" -cfg$gms$c50_scen_neff <- "constant" -#cfg$gms$factor_costs <- "sticky_feb18" -start_run(cfg=cfg,codeCheck=codeCheck) diff --git a/scripts/start/order.cfg b/scripts/start/order.cfg deleted file mode 100644 index 054b1d8108..0000000000 --- a/scripts/start/order.cfg +++ /dev/null @@ -1,14 +0,0 @@ -# | (C) 2008-2019 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 - -# Order of start scripts...Scripts not mentioned here will be shown alphabetically -# after the ones specified below - -default -check_code -download_data_only -recalibrate diff --git a/scripts/start/projects/GENIE_0_default.R b/scripts/start/projects/GENIE_0_default.R new file mode 100644 index 0000000000..ae32c585aa --- /dev/null +++ b/scripts/start/projects/GENIE_0_default.R @@ -0,0 +1,51 @@ +# | (C) 2008-2025 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: GENIE project MESSAGE-MAgPIE Emulator Default script +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) +library(stringr) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") #nolinter +# Source the default config and then over-write it before starting the run. +source("config/default.cfg") #nolinter + +cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public" = NULL, + "./patch_input" = NULL), + getOption("magpie_repos")) + +cfg$input <- c(regional = "rev4.96_26df900e_magpie.tgz", + cellular = "rev4.96_26df900e_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96_26df900e_validation.tgz", + additional = "additional_data_rev4.47.tgz", + patch = "MMEmuR12_rev4.96.tgz") + + +cfg$output <- c("output_check", "rds_report") + +#load config presetswrite it before starting the run. +preset <- "GENIE_SCP" +cfg <- setScenario(cfg, c(preset), scenario_config = "config/projects/scenario_config_genie.csv") + +### Identifier and folder +############################################### +identifierFlag <- "MMEmu_default" +cfg$title <- "Default_rev4.96-preset" +############################################### +cfg$info$flag <- identifierFlag + +########################################################## +start_run(cfg, codeCheck = FALSE) diff --git a/scripts/start/projects/GENIE_1_tau-export.R b/scripts/start/projects/GENIE_1_tau-export.R new file mode 100644 index 0000000000..b949cc4b97 --- /dev/null +++ b/scripts/start/projects/GENIE_1_tau-export.R @@ -0,0 +1,65 @@ +# | (C) 2008-2025 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: GENIE project MESSAGE-MAgPIE Emulator - Step 1 - export tau +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) +library(stringr) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") #nolinter +# Source the default config and then over-write it before starting the run. +source("config/default.cfg") #nolinter + +cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public" = NULL, + "./patch_input" = NULL), + getOption("magpie_repos")) + +cfg$input <- c(regional = "rev4.96_26df900e_magpie.tgz", + cellular = "rev4.96_26df900e_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96_26df900e_validation.tgz", + additional = "additional_data_rev4.47.tgz", + patch = "MMEmuR12_rev4.96.tgz") + + +cfg$output <- c("output_check", "rds_report") + +preset <- "GENIE_SCP" +cfg <- setScenario(cfg, c(preset)) #load config presets + +cfg$force_replace <- FALSE +cfg$qos <- "priority" + +### Identifier and folder +############################################### +identifierFlag <- "SCP_24_02_29" +cfg$title <- "Default_rev4.96-preset" +############################################### + +cfg$info$flag <- identifierFlag +cfg$results_folder <- paste0("output/", identifierFlag, "/:title:") + +cfg$gms$c44_bii_decrease <- 0 +cfg$gms$c22_protect_scenario <- "BH" + +cfg$gms$s60_2ndgen_bioenergy_dem_min <- 0 +cfg$gms$s60_bioenergy_1st_subsidy <- 0 + +cfg$gms$c60_2ndgen_biodem <- "R32M46-SSP2EU-NPi" + +cfg$title <- "Tau" + +#start MAgPIE run +start_run(cfg, codeCheck = FALSE) diff --git a/scripts/start/projects/GENIE_2_bm-priced.R b/scripts/start/projects/GENIE_2_bm-priced.R new file mode 100644 index 0000000000..24de015f40 --- /dev/null +++ b/scripts/start/projects/GENIE_2_bm-priced.R @@ -0,0 +1,101 @@ +# | (C) 2008-2025 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: GENIE project MESSAGE-MAgPIE Emulator - Step 2 - price-based biomass potential +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) +library(stringr) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") #nolinter +# Source the default config and then over-write it before starting the run. +source("config/default.cfg") #nolinter + +cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public" = NULL, + "./patch_input" = NULL), + getOption("magpie_repos")) + +cfg$input <- c(regional = "rev4.96_26df900e_magpie.tgz", + cellular = "rev4.96_26df900e_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96_26df900e_validation.tgz", + additional = "additional_data_rev4.47.tgz", + patch = "MMEmuR12_rev4.96.tgz") + + +cfg$output <- c("output_check", "rds_report") + +#load config presetswrite it before starting the run. +preset <- "GENIE_SCP" +cfg <- setScenario(cfg, c(preset), scenario_config = "config/projects/scenario_config_genie.csv") + +cfg$force_replace <- FALSE +cfg$qos <- "priority" +cfg$partition <- "priority" + +### Identifier and folder +############################################### +identifierFlag <- "SCP_24_02_29" +############################################### +cfg$info$flag <- identifierFlag +cfg$results_folder <- paste0("output/", identifierFlag, "/:title:") + + +### BE +cfg$gms$s60_2ndgen_bioenergy_dem_min <- 0 +cfg$gms$s60_bioenergy_1st_subsidy <- 0 +beV <- c(0, 5, 7, 10, 15, 25, 45) + +### Tau / Yield +cfg$gms$tc <- "exo" + +### Biodiv +blV <- c(0, 0.7, 0.74, 0.78) #BII lower bound (0-1), default 0 + +### Food +mpV <- c(0, 25, 50, 75) + + +for (bl in blV) { + bd <- 0 + pa <- "BH" + if (bl == 0) { + bd <- 1 + pa <- "none" + } + + cfg$gms$c44_bii_decrease <- bd + cfg$gms$s44_bii_target <- bl + cfg$gms$c22_protect_scenario <- pa + + for (mp in mpV) { + preflag <- paste0("MP", str_pad(mp, 2, pad = "0"), "BI", str_pad(bl * 100, 2, pad = "0")) + cfg$results_folder <- paste("output", identifierFlag, preflag, ":title:", sep = "/") + cfg$info$flag2 <- preflag + + cfg$gms$s15_rumdairy_scp_substitution <- mp / 100 + + for (be in beV) { + cfg$gms$s60_bioenergy_1st_price <- be + cfg$gms$s60_bioenergy_2nd_price <- be + + ############################################## + runflag <- "price" + cfg$title <- paste0(preflag, "E", str_pad(be, 2, pad = "0"), "G0000", runflag) + + start_run(cfg, codeCheck = FALSE) + + } # BE + } # MP replacement +} # BII lower bound diff --git a/scripts/start/projects/GENIE_3_bm-demand.R b/scripts/start/projects/GENIE_3_bm-demand.R new file mode 100644 index 0000000000..f9f2723b72 --- /dev/null +++ b/scripts/start/projects/GENIE_3_bm-demand.R @@ -0,0 +1,116 @@ +# | (C) 2008-2025 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: GENIE project MESSAGE-MAgPIE Emulator - Step 3 - ghg price sensitivity for step 2 biomass demands +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) +library(stringr) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") #nolinter +# Source the default config and then over-write it before starting the run. +source("config/default.cfg") #nolinter + +cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public" = NULL, + "./patch_input" = NULL), + getOption("magpie_repos")) + +cfg$input <- c(regional = "rev4.96_26df900e_magpie.tgz", + cellular = "rev4.96_26df900e_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96_26df900e_validation.tgz", + additional = "additional_data_rev4.47.tgz", + patch = "MMEmuR12_rev4.96.tgz") + + +cfg$output <- c("output_check", "extra/disaggregation", "rds_report") + +#load config presetswrite it before starting the run. +preset <- "GENIE_SCP" +cfg <- setScenario(cfg, c(preset), scenario_config = "config/projects/scenario_config_genie.csv") + +cfg$force_replace <- TRUE +cfg$qos <- "standby" + +### Identifier and folder +############################################### +identifierFlag <- "SCP_24_02_29" +############################################### +cfg$info$flag <- identifierFlag +cfg$results_folder <- paste0("output/", identifierFlag, "/:title:") + + +### BE +cfg$gms$s60_2ndgen_bioenergy_dem_min <- 0 +cfg$gms$s60_bioenergy_1st_subsidy <- 0 +beV <- c(0, 5, 7, 10, 15, 25, 45) + +### GHG +gV <- c(0, 10, 20, 50, 100, 200, 400, 600, 1000, 2000, 3000, 4000) + +### Biodiv +blV <- c(0, 0.7, 0.74, 0.78) #BII lower bound (0-1), default 0 + +### Food +mpV <- c(0, 25, 50, 75) + +### Forest +cfg$gms$s32_max_aff_cell_2025 <- 0.005 + + +for (bl in blV) { + bd <- 0 + pa <- "BH" + if (bl == 0) { + bd <- 1 + pa <- "none" + } + + cfg$gms$c44_bii_decrease <- bd + cfg$gms$s44_bii_target <- bl + cfg$gms$c22_protect_scenario <- pa + + for (mp in mpV) { + cfg$gms$s15_rumdairy_scp_substitution <- mp / 100 + + preflag <- paste0("MP", str_pad(mp, 2, pad = "0"), + "BI", str_pad(bl * 100, 2, pad = "0") + ) + cfg$results_folder <- paste( + "output", identifierFlag, preflag, ":title:", sep = "/" + ) + cfg$info$flag2 <- preflag + + for (be in beV) { + + be <- paste0("E", str_pad(be, 2, pad = "0")) + cfg$gms$c60_2ndgen_biodem <- paste0(preflag, be) + + for (g in gV){ + + g <- paste0("G", str_pad(g, 4, pad = "0")) + + cfg$gms$c56_pollutant_prices <- paste0(g, "exp2110") + + ############################################## + runflag <- "demand" + + cfg$title <- paste0(preflag, be, g, runflag) + + start_run(cfg, codeCheck = FALSE) + + } # GHG + } # BE + } # MP replacement +} # BII lower bound diff --git a/scripts/start/projects/GENIE_4_feedback.R b/scripts/start/projects/GENIE_4_feedback.R new file mode 100644 index 0000000000..88b19a26a0 --- /dev/null +++ b/scripts/start/projects/GENIE_4_feedback.R @@ -0,0 +1,107 @@ +# | (C) 2008-2025 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: GENIE project MESSAGE-MAgPIE Emulator - emulator feedback run +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) +library(stringr) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") #nolinter +# Source the default config and then over-write it before starting the run. +source("config/default.cfg") #nolinter + +cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public" = NULL, + "./patch_input" = NULL), + getOption("magpie_repos")) + +cfg$input <- c(regional = "rev4.96_26df900e_magpie.tgz", + cellular = "rev4.96_26df900e_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.96_26df900e_validation.tgz", + additional = "additional_data_rev4.47.tgz", + patch = "MMEmuR12_rev4.96.tgz") + + +cfg$output <- c("output_check", "extra/disaggregation", "rds_report") + +#load config presetswrite it before starting the run. +preset <- "GENIE_SCP" +cfg <- setScenario(cfg, c(preset), scenario_config = "config/projects/scenario_config_genie.csv") + +cfg$force_replace <- FALSE + +### Identifier and folder +############################################### +identifierFlag <- "SCP_24_02_29" +############################################### +cfg$info$flag <- identifierFlag +cfg$results_folder <- paste0("output/", identifierFlag, "/:title:") + + +### BE +cfg$gms$s60_2ndgen_bioenergy_dem_min <- 0 +cfg$gms$s60_bioenergy_1st_subsidy <- 0 + +### Tau / Yield +cfg$gms$tc <- "exo" + +### Biodiv +blV <- c(0) #BII lower bound (0-1), default 0 +#0, 0.7, 0.74, 0.78 + +### Food +mpV <- c(0) #0, 25, 50, 75 + + +for (bl in blV) { + bd <- 0 + pa <- "BH" + if (bl == 0) { + bd <- 1 + pa <- "none" + } + + cfg$gms$c44_bii_decrease <- bd + cfg$gms$s44_bii_target <- bl + cfg$gms$c22_protect_scenario <- pa + + for (mp in mpV) { + cfg$gms$s15_rumdairy_scp_substitution <- mp / 100 + + preflag <- paste0("MP", str_pad(mp, 2, pad = "0"), + "BD", bd, "BI", str_pad(bl * 100, 2, pad = "0") + ) + cfg$results_folder <- paste( + # "output", identifierFlag, preflag, ":title:", sep = "/" + "output", identifierFlag, ":title:", sep = "/" + ) + + n <- "Feedback_step13_400f" + m <- n + cfg$gms$c60_2ndgen_biodem <- n + cfg$gms$c56_pollutant_prices <- m + + + ############################################## + #runflag <- paste("feedback", f_flag, sep = "_") + runflag <- paste0(m, "") + + cfg$title <- paste0(preflag, runflag) + + start_run(cfg, codeCheck = FALSE) + + + } # MP replacement +} # BII lower bound diff --git a/scripts/start/projects/INFO.yml b/scripts/start/projects/INFO.yml new file mode 100644 index 0000000000..9f8c67a364 --- /dev/null +++ b/scripts/start/projects/INFO.yml @@ -0,0 +1,3 @@ +description: Project-specific MAgPIE start scripts +note: Scripts in this selection might require some manual adjustments before they work with the given MAgPIE version as they are not necessarily updated along with changes in the model code. +position: 3.0 diff --git a/scripts/start/projects/TAUhistfree.R b/scripts/start/projects/TAUhistfree.R new file mode 100644 index 0000000000..794e16152f --- /dev/null +++ b/scripts/start/projects/TAUhistfree.R @@ -0,0 +1,83 @@ +# | (C) 2008-2025 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: TAUhistfree +# ---------------------------------------------------------- + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +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$force_download <- TRUE + +cfg$results_folder <- "output/:title:" +cfg$output <- c("rds_report") + +prefix <- "THF02" +cfg$qos <- "priority" + +cfg$gms$s80_optfile <- 1 +cfg$gms$s80_maxiter <- 30 + +# cfg$gms$s32_planning_horizon <- 100 +# cfg$gms$c35_protect_scenario <- "WDPA" +# cfg$gms$c56_emis_policy <- "redd+_nosoil" + +#ref +for (scen in c("REF","POL")) { + if (scen == "REF") { + cfg <- setScenario(cfg,c("SSP2","NPI")) + cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-NPi" + cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-NPi" + } else if (scen == "POL") { + cfg <- setScenario(cfg,c("SSP2","NDC")) + cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg600" + cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg600" + } + for (sec in c("Ag","AgF","AgFsecdini0")) { + if (sec == "Ag") { + cfg <- setScenario(cfg,c("ForestryOff")) + } else if (sec == "AgF") { + cfg <- setScenario(cfg,c("ForestryEndo")) + } else if (sec == "AgFsecdini0") { + cfg <- setScenario(cfg,c("ForestryEndo")) + cfg$gms$s35_secdf_distribution <- 0 + } + for (TC in c("TCfix","TCfree")) { + if (TC == "TCfix") { + cfg$gms$s13_tau_hist_lower_bound <- 1 + } else if (TC == "TCfree") { + cfg$gms$s13_tau_hist_lower_bound <- 0 + } + for (LC in c("LC888","LC881")) { + if (LC == "LC888") { + cfg$gms$s39_cost_establish_crop <- 8000 + cfg$gms$s39_cost_establish_past <- 8000 + cfg$gms$s39_cost_establish_forestry <- 8000 + } else if (LC == "LC881") { + cfg$gms$s39_cost_establish_crop <- 8000 + cfg$gms$s39_cost_establish_past <- 8000 + cfg$gms$s39_cost_establish_forestry <- 1000 + } + cfg$title <- paste(prefix,"SSP2",scen,sec,TC,LC,sep="_") + start_run(cfg,codeCheck=FALSE) + } + } + } +} diff --git a/scripts/start/projects/aff_bgp.R b/scripts/start/projects/aff_bgp.R new file mode 100644 index 0000000000..74959241f1 --- /dev/null +++ b/scripts/start/projects/aff_bgp.R @@ -0,0 +1,107 @@ +# | (C) 2008-2025 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 + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) + +# Switch between control and experiment, "exp", "ctr" +run_setting <- "ctr" + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source the default config and then over-write it before starting the run. +source("config/default.cfg") + +# Change results folder name +cfg$results_folder <- "output/:title:" + +# Change input datasource to include my personal preprocessing +cfg$input <- c("isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev46_0.5.tgz", + "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev46_c200_690d3718e151be1b450b394c1064b1c5.tgz", + "isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev44_c200_690d3718e151be1b450b394c1064b1c5.tgz", + "rev4.47_h12_magpie.tgz", + "rev4.47_h12_validation.tgz", + "calibration_H12_c200_26Feb20.tgz", + "additional_data_rev3.85.tgz") + + # Should input data be downloaded from source even if cfg$input did not change? +#cfg$force_download <- TRUE + + # Should an existing output folder be replaced if a new run with the same name is started? +cfg$force_replace <- TRUE + + + +# Enable CO2 Pricing +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-26-REMIND-MAGPIE" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-26-REMIND-MAGPIE" + +# Set relevant policies to NDC +cfg$gms$c22_ad_policy <- "ndc" +cfg$gms$c22_aolc_policy <- "ndc" +cfg$gms$c32_aff_policy <- "ndc" + +# Afforestation restrictions "unrestricted" "noboreal" +cfg$gms$c32_aff_mask <- "unrestricted" + +# SSP loop +for(ssp_setting in c("SSP1","SSP2","SSP3")){ + cfg <- setScenario(cfg,c(ssp_setting,"NDC")) + +if(run_setting=="exp") bgp_setting="ann_bph" +if(run_setting=="ctr") bgp_setting="nobgp" + + #Change BGP setting + cfg$gms$c32_aff_bgp <- bgp_setting + + #Set title flag + if(bgp_setting == "nobgp") bgp_flag="nobgp" + if(bgp_setting == "ann_bph") bgp_flag="ann_bph" + if(ssp_setting == "SSP1") ssp_flag="SSP1" + if(ssp_setting == "SSP2") ssp_flag="SSP2" + if(ssp_setting == "SSP3") ssp_flag="SSP3" + + if (run_setting=="exp"){ + for(tcrearea_setting in c(0,1)){ + for(tcreuncert_setting in c("ann_TCREmean","ann_TCREhigh","ann_TCRElow")){ + + #Change TCRE settings + cfg$gms$s32_tcre_local <- tcrearea_setting #0<-global;1<-local + cfg$gms$c32_tcre_ctrl <- tcreuncert_setting + + #Set title flags + if(tcrearea_setting == 0) area_flag="global" + if(tcrearea_setting == 1) area_flag="local" + if(tcreuncert_setting == "ann_TCREmean") uncertainty_flag="meanTCRE" + if(tcreuncert_setting == "ann_TCREhigh") uncertainty_flag="highTCRE" + if(tcreuncert_setting == "ann_TCRElow") uncertainty_flag="lowTCRE" + + # Update title + cfg$title <- paste0("BPHexp","_",bgp_flag,"_",ssp_flag,"_",area_flag,"_",uncertainty_flag,"_","afforunrestricted","_","ac10to30") + + # Start the run + start_run(cfg=cfg,codeCheck=FALSE) + + }# TCRE uncertainty loop + }# TCRE local vs global loop + }# BGP set to ON loop + else if (run_setting=="ctr"){ + # Update title + cfg$title <- paste0("BPHexp","_",bgp_flag,"_",ssp_flag,"_","afforunrestricted") + + # Start the run + start_run(cfg=cfg,codeCheck=FALSE) + }# BGP set to OFF loop + + +}# Closing SSP settings loop diff --git a/scripts/start/projects/duallayer.R b/scripts/start/projects/duallayer.R new file mode 100644 index 0000000000..b7d12f2d93 --- /dev/null +++ b/scripts/start/projects/duallayer.R @@ -0,0 +1,47 @@ +# | (C) 2008-2025 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: test routine for duallayer implementation +# ---------------------------------------------------------- + + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +# choose a meaningful Pull Request (PR) flag. +# example for high risk modification requiring runs from the current develop and the feature branch to be merged: PR276_develop, PR276_TAUhistfree +pr_flag <- "PR282test" + +# Grab user name +user <- Sys.info()[["user"]] + +cfg$results_folder <- "output/:title:" + +## Create a set of runs based on default.cfg + +for(tc in c("endo_jun18","exo")) { + for (trade in c("exo","free_apr16","selfsuff_reduced","off")) { + #cfg <- setScenario(cfg,c(ssp,"NPI")) + cfg$gms$tc <- tc + cfg$gms$trade <- trade + + cfg$title <- paste0(pr_flag,"_",user,"_",tc,"-",trade) #Create easily distinguishable run title + + cfg$output <- c("rds_report") # Only run rds_report after model run + + start_run(cfg,codeCheck=TRUE) # Start MAgPIE run + #cat(cfg$title) + } +} diff --git a/scripts/start/projects/fable_india.R b/scripts/start/projects/fable_india.R new file mode 100644 index 0000000000..a03a255c4b --- /dev/null +++ b/scripts/start/projects/fable_india.R @@ -0,0 +1,43 @@ +# | (C) 2008-2025 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: Default script for all India-specific runs +# ------------------------------------------------ + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +source("scripts/start_functions.R") +source("config/default.cfg") + + +##Input data files to be used for India-specific analysis +cfg$input <- c(cellular = "rev4.732706_indiaYields_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + regional = "rev4.732706_indiaYields_h12_magpie.tgz", + validation = "rev4.732706_indiaYields_h12_validation.tgz", + calibration = "calibration_Indiacalibration_473_27Jun22.tgz", + additional = "additional_data_rev4.26.tgz") + +##Please always use the updated `calibration` and `additional` files from the main default.cfg file + +cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public"=NULL), + getOption("magpie_repos")) + +#Download input data +cfg$force_download <- TRUE + +#Setting pumping to 1 +cfg$gms$s42_pumping <- 1 +#Setting year from which pumping costs will be implemented + cfg$gms$s42_multiplier_startyear <- 1995 +##Pumping cost value to default value for India +cfg$gms$s42_multiplier <- 1 + +cfg$recalibrate <- TRUE diff --git a/scripts/start/projects/forestry.R b/scripts/start/projects/forestry.R new file mode 100644 index 0000000000..676cf50396 --- /dev/null +++ b/scripts/start/projects/forestry.R @@ -0,0 +1,110 @@ +# | (C) 2008-2025 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: Forestry simulations +# ---------------------------------------------------------- + +###################################### +#### 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") + +log_folder = "run_details" +dir.create(log_folder,showWarnings = FALSE) + +identifier_flag = "AUG04" +cat(paste0("BH_IFL and WDPA runs"), file=paste0(log_folder,"/",identifier_flag,".txt"),append=F) + +xx <- c() +all_configs <- list() + +#scen_vector <- c("ForestryOff","ForestryEndo","ForestryExo") +scen_vector <- c("ForestryEndo") + +for(c73_wood_scen in c("default")){ + + for(s80_maxiter in c(30)){ + for(scen in scen_vector){ + + for(ssp in c("SSP2")){ + + for(pol_scen in c("NPI")){ + source("config/default.cfg") + + cfg$gms$c52_carbon_scenario <- "nocc" + cfg$gms$c59_som_scenario <- "nocc" + + cfg$gms$s80_maxiter = s80_maxiter + + cfg = setScenario(cfg,c(ssp,pol_scen,scen)) + + for(c21_trade_liberalization in c("l909090r808080")) { + + cfg$gms$c21_trade_liberalization <- c21_trade_liberalization + + if(cfg$gms$c21_trade_liberalization=="l909090r808080") trade_flag="DefTrade" + if(cfg$gms$c21_trade_liberalization=="l908080r807070") trade_flag="LibTrade" + + for (c73_build_demand in c("BAU","10pc","50pc","90pc")) { + + for(c35_protect_scenario in c("BH_IFL","WDPA")){ + + for(s73_expansion in c(0)){ + + cfg$gms$c35_protect_scenario <- c35_protect_scenario + + cfg$gms$s73_expansion <- s73_expansion + + #cfg$gms$tc <- "exo" + + cfg$gms$c73_build_demand <- c73_build_demand + cfg$gms$s15_elastic_demand <- 0 + + if(cfg$gms$s73_foresight == 1) foresight_flag = "Forward" + if(cfg$gms$s73_foresight != 1) foresight_flag = "Myopic" + + cfg$force_download <- TRUE + cfg$recalibrate <- "ifneeded" # def = "ifneeded" + + if(scen=="ForestryOff") scen_flag="Default" + if(scen=="ForestryEndo") scen_flag="Forestry" + if(scen=="ForestryExo") scen_flag="ForestryExo" + + cfg$gms$c73_wood_scen = c73_wood_scen + + pol_flg = "Baseline" + + if(pol_scen == "NDC"){ + cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg600" + cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg600" + pol_flg = "Mitigation" + } + + cfg$title = paste0(identifier_flag,"_",c73_build_demand,"_",gsub(pattern="_",replacement="",x=c35_protect_scenario)) + cfg$output = c("extra/timestep_duration") + + xx = c(xx,cfg$title) + all_configs[[cfg$title]] <- cfg + #cfg$gms$s80_optfile <- 1 + cfg$results_folder = "output/:title:" + start_run(cfg,codeCheck=FALSE) + } + } + } + } + } + } + } + } +} diff --git a/scripts/start/projects/forestry_co2.R b/scripts/start/projects/forestry_co2.R new file mode 100644 index 0000000000..ca16f85c4c --- /dev/null +++ b/scripts/start/projects/forestry_co2.R @@ -0,0 +1,58 @@ +# | (C) 2008-2025 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: start run with Forestry (Endogenous) +# position: 6 +# ------------------------------------------------ + + +library(gms) + +# 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 <- setScenario(cfg,c("SSP2","NPI","ForestryEndo")) + +run_flag <- "AFF01" + +xx <- c() + +for(c56_pollutant_prices in c("R2M41-SSP2-NPi","SSPDB-SSP2-26-REMIND-MAGPIE")){ + # Enable CO2 Pricing + cfg$gms$c56_pollutant_prices <- c56_pollutant_prices + cfg$gms$c60_2ndgen_biodem <- cfg$gms$c56_pollutant_prices + + for(s32_aff_plantation in c(0,1)){ + # Enable afforestation via plantation growth curve + cfg$gms$s32_aff_plantation <- s32_aff_plantation + + #cfg <- setScenario(cfg,c("SSP2","NPI","ForestryExo")) + #cfg <- setScenario(cfg,c("SSP2","NPI","ForestryOff")) + + if(cfg$gms$s32_aff_plantation == 1) aff_flag <- "AffPlant" + if(cfg$gms$s32_aff_plantation == 0) aff_flag <- "AffNatVeg" + + if(cfg$gms$c56_pollutant_prices == "SSPDB-SSP2-26-REMIND-MAGPIE") { + co2_flag = "CO2p" + cfg <- setScenario(cfg,"NDC") + } + if(cfg$gms$c56_pollutant_prices == "R2M41-SSP2-NPi") { + co2_flag = "Baseline" + cfg <- setScenario(cfg,"NPI") + } + + cfg$title <- paste0(run_flag,"_","ForestryEndo","_",co2_flag,"_",aff_flag) + xx = c(xx,cfg$title) + cfg$results_folder = "output/:title:" + start_run(cfg,codeCheck=FALSE) + } +} diff --git a/scripts/start/projects/gmd-2021-76.R b/scripts/start/projects/gmd-2021-76.R new file mode 100644 index 0000000000..0448e9c699 --- /dev/null +++ b/scripts/start/projects/gmd-2021-76.R @@ -0,0 +1,82 @@ +# | (C) 2008-2025 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: gmd-2021-76 forestry paper +# ---------------------------------------------------------- + +###################################### +#### 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") + +log_folder = "run_details" +dir.create(log_folder,showWarnings = FALSE) + +identifier_flag = "gmd-2021-76_03" +cat(paste0("Higher rotation, more share from EUR."), file=paste0(log_folder,"/",identifier_flag,".txt"),append=F) + +xx <- c() + +#scen_vector <- c("ForestryOff","ForestryEndo","ForestryExo") +scen_vector <- c("ForestryOff","ForestryEndo") + +for(c73_wood_scen in c("default")){ + + for(s80_maxiter in c(30)){ + for(scen in scen_vector){ + + for(ssp in c("SSP2")){ + source("config/default.cfg") + + cfg$gms$s80_maxiter = s80_maxiter + + cfg = setScenario(cfg,c(ssp,"NPI",scen)) + + # Should input data be downloaded from source even if cfg$input did not change? + cfg$force_download <- TRUE + + #cfg$gms$c_timesteps <- "5year" + + for(c32_rot_calc_type in c("mean_annual_increment","current_annual_increment","instantaneous_growth_rate")){ + cfg$gms$s15_elastic_demand <- 0 + cfg$gms$c32_rot_calc_type <- c32_rot_calc_type + + if(cfg$gms$s73_foresight == 1) foresight_flag = "Forward" + if(cfg$gms$s73_foresight != 1) foresight_flag = "Myopic" + + # cfg$gms$c57_macc_version = "PBL_2019" + + if(scen=="ForestryOff") scen_flag="Default" + if(scen=="ForestryEndo") scen_flag="Forestry" + if(scen=="ForestryExo") scen_flag="ForestryExo" + + if(c32_rot_calc_type=="mean_annual_increment") rl_flag="MAI" + if(c32_rot_calc_type=="current_annual_increment") rl_flag="CAI" + if(c32_rot_calc_type=="instantaneous_growth_rate") rl_flag="IGR" + + cfg$gms$c73_wood_scen = c73_wood_scen + + cfg$title = paste0(identifier_flag,"_",scen_flag,"_",rl_flag) + cfg$output = c("extra/timestep_duration") + + xx = c(xx,cfg$title) + cfg$gms$s80_optfile <- 0 + cfg$results_folder = "output/:title:" + start_run(cfg,codeCheck=FALSE) + } + } + } + } + +} diff --git a/scripts/start/projects/paper_ClimNat.R b/scripts/start/projects/paper_ClimNat.R new file mode 100644 index 0000000000..b1f95b46d5 --- /dev/null +++ b/scripts/start/projects/paper_ClimNat.R @@ -0,0 +1,110 @@ +# | (C) 2008-2025 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: Paper Climate vs. Nature +# ---------------------------------------------------------- + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +library(magclass) + +source("scripts/start_functions.R") + +source("config/default.cfg") + +#cfg$force_download <- TRUE +cfg$force_replace <- TRUE + +cfg$results_folder <- "output/:title:" +cfg$output <- c("rds_report","extra/disaggregation")#"extra/highres" + +prefix <- "CN72" + + +cfg$qos <- "priority" + +cfg$gms$c_timesteps <- "5year" +cfg$gms$biodiversity <- "bii_target" + +for (pol in c("CurPol","Carbon","Biodiversity","Integrated")) { + for (ssp in c("SSP2")) { + if (pol == "CurPol") { + cfg <- setScenario(cfg,c(ssp,"NPI","rcp4p5")) + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi"#"PIK_NPI" + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi"#"PIK_NPI" + cfg$gms$s15_exo_diet <- 0 + cfg$gms$s15_exo_waste <- 0 + cfg$gms$c60_biodem_level <- 1 + cfg$gms$s32_aff_plantation <- 0 + cfg$gms$s32_aff_bii_coeff <- 0 + cfg$gms$s32_max_aff_area <- Inf + cfg$gms$s44_target_price <- 0 + cfg$gms$s44_bii_target <- 0 + cfg$gms$c35_protect_scenario <- "WDPA" + cfg$gms$c30_snv_target <- "none" + cfg$gms$s30_snv_shr <- 0 + cfg$gms$s56_c_price_induced_aff <- 0 + } else if (pol == "Carbon") { + cfg <- setScenario(cfg,c(ssp,"NPI","rcp1p9")) + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900"#"PIK_LIN" + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi"#"PIK_NPI" + cfg$gms$s15_exo_diet <- 0 + cfg$gms$s15_exo_waste <- 0 + cfg$gms$c60_biodem_level <- 1 + cfg$gms$s32_aff_plantation <- 0 + cfg$gms$s32_aff_bii_coeff <- 0 + cfg$gms$s32_max_aff_area <- Inf + cfg$gms$c35_forest_damage_end <- "by2030" + cfg$gms$s44_target_price <- 0 + cfg$gms$s44_bii_target <- 0 + cfg$gms$c35_protect_scenario <- "WDPA" + cfg$gms$c30_snv_target <- "none" + cfg$gms$s30_snv_shr <- 0 + cfg$gms$s56_c_price_induced_aff <- 1 + } else if (pol == "Biodiversity") { + cfg <- setScenario(cfg,c(ssp,"NPI","rcp4p5")) + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi"#"PIK_NPI" + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi"#"PIK_NPI" + cfg$gms$s15_exo_diet <- 0 + cfg$gms$s15_exo_waste <- 0 + cfg$gms$c60_biodem_level <- 1 + cfg$gms$s32_aff_plantation <- 0 + cfg$gms$s32_aff_bii_coeff <- 0 + cfg$gms$s32_max_aff_area <- Inf + cfg$gms$c35_forest_damage_end <- "by2030" + cfg$gms$s44_bii_target <- 0.81 + cfg$gms$c35_protect_scenario <- "BH_IFL" + cfg$gms$c30_snv_target <- "by2030" + cfg$gms$s30_snv_shr <- 0.2 + cfg$gms$s56_c_price_induced_aff <- 0 + } else if (pol == "Integrated") { + cfg <- setScenario(cfg,c(ssp,"NPI","rcp1p9")) + cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900"#"PIK_LIN" + cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi"#"PIK_NPI" + cfg$gms$s15_exo_diet <- 0 + cfg$gms$s15_exo_waste <- 0 + cfg$gms$c60_biodem_level <- 1 + cfg$gms$s32_aff_plantation <- 0 + cfg$gms$s32_aff_bii_coeff <- 0 + cfg$gms$s32_max_aff_area <- Inf + cfg$gms$c35_forest_damage_end <- "by2030" + cfg$gms$s44_bii_target <- 0.81 + cfg$gms$c35_protect_scenario <- "BH_IFL" + cfg$gms$c30_snv_target <- "by2030" + cfg$gms$s30_snv_shr <- 0.2 + cfg$gms$s56_c_price_induced_aff <- 1 + } + cfg$title <- paste(prefix,paste0(ssp,"-",pol),sep="_") + start_run(cfg,codeCheck=FALSE) + } +} diff --git a/scripts/start/projects/paper_MitiConsv.R b/scripts/start/projects/paper_MitiConsv.R new file mode 100644 index 0000000000..9f6365fba9 --- /dev/null +++ b/scripts/start/projects/paper_MitiConsv.R @@ -0,0 +1,155 @@ +# | (C) 2008-2025 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: Land-based mitigation and habitat conservation +# ------------------------------------------------------------- + +rev <- "rev21" + +cres <- "c200" + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +library(magclass) +library(gdx2) + +# Load start functions +source("scripts/start_functions.R") + +# ==================== +# Calibration +# ==================== + +source("config/default.cfg") + +cfg$title <- paste0(rev, "_calib_MitiConsv") +cfg$output <- c("rds_report", "validation_short") +cfg$force_replace <- TRUE + +# land conversion cost calibration settings +cfg$recalibrate_landconversion_cost <- TRUE + +# cc is new default +cfg <- setScenario(cfg, c("SSP2", "nocc_hist", "NPI", "ForestryExo")) +cfg <- setScenario(cfg, c("MitiConsv"), scenario_config = "config/projects/scenario_config_miti_consv.csv") + +# sticky +cfg$gms$factor_costs <- "sticky_feb18" + +# SNV habitat defintion +cfg$gms$land_snv <- "secdforest, other" + +start_run(cfg = cfg) +calib_tgz <- magpie4::submitCalibration(paste(rev, "MitiConsv", sep = "_")) + +# ==================== +# Scenario runs +# ==================== + +prefix <- paste(rev, "MitiConsv", cres, sep = "_") + +scenarios <- c( + "SSP2-PB750-NPi", "SSP2-PB750-NDC", + "SSP2-PB750-AR150", "SSP2-PB750-AR250", "SSP2-PB750-AR350", + "SSP2-PB750-NPi-BH", "SSP2-PB750-NDC-BH", + "SSP2-PB750-AR250-BH", "SSP2-PB750-AR350-BH", "SSP2-PB750-AR150-BH", + "SSP2-PB750-NPi-KBA", "SSP2-PB750-NDC-KBA", + "SSP2-PB750-AR250-KBA", "SSP2-PB750-AR350-KBA", "SSP2-PB750-AR150-KBA", + "SSP2-REF" +) + +for (scen in scenarios) { + scen <- unlist(strsplit(scen, "-")) + ssp <- scen[grepl("SSP", scen)] + + source("config/default.cfg") + + cfg$qos <- "short_highMem" + + cfg$results_folder <- "output/:title::date:" + + cfg$output <- c( + "output_check", "extra/disaggregation", "rds_report", "extra/runSEALSallocation" + ) + + # Climate change switched off for these runs + cfg <- setScenario(cfg, c(ssp, "nocc_hist", "NPI", "ForestryExo")) + cfg <- setScenario(cfg, "MitiConsv", scenario_config = "config/projects/scenario_config_miti_consv.csv") + + # Calibration settings + cfg$input["calibration"] <- calib_tgz + + # sticky + cfg$gms$factor_costs <- "sticky_feb18" + + # SNV habitat defintion + cfg$gms$land_snv <- "secdforest, other" + + # Set path to coupled output + pathToCoupledOutput <- "/p/projects/magpie/users/vjeetze/magpie/projects/MitiConsv/C_MitiConsv_Jun25/remind/output/C_rev11_MitiConsv_SSP2-NPi-rem-9/REMIND_generic_C_rev11_MitiConsv_SSP2-NPi-rem-9.mif" + + # No ghg price in NPI run + cfg$gms$c56_mute_ghgprices_until <- "y2100" + + if ("NPi" %in% scen) { + cfg <- setScenario(cfg, "NPI") + pathToCoupledOutput <- "/p/projects/magpie/users/vjeetze/magpie/projects/MitiConsv/C_MitiConsv_Jun25/remind/output/C_rev11_MitiConsv_SSP2-PB750-NPi-rem-9/REMIND_generic_C_rev11_MitiConsv_SSP2-PB750-NPi-rem-9.mif" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg <- setScenario(cfg, "AR0", scenario_config = "config/projects/scenario_config_miti_consv.csv") + } + + if ("NDC" %in% scen) { + cfg <- setScenario(cfg, "NDC") + # Update path to coupled output + pathToCoupledOutput <- "/p/projects/magpie/users/vjeetze/magpie/projects/MitiConsv/C_MitiConsv_Jun25/remind/output/C_rev11_MitiConsv_SSP2-PB750-NDC-rem-9/REMIND_generic_C_rev11_MitiConsv_SSP2-PB750-NDC-rem-9.mif" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg <- setScenario(cfg, "AR0", scenario_config = "config/projects/scenario_config_miti_consv.csv") + } + + if ("AR150" %in% scen) { + cfg <- setScenario(cfg, "NDC") + pathToCoupledOutput <- "/p/projects/magpie/users/vjeetze/magpie/projects/MitiConsv/C_MitiConsv_Jun25/remind/output/C_rev11_MitiConsv_SSP2-PB750-AR150-rem-9/REMIND_generic_C_rev11_MitiConsv_SSP2-PB750-AR150-rem-9.mif" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg <- setScenario(cfg, "AR150", scenario_config = "config/projects/scenario_config_miti_consv.csv") + } + + if ("AR250" %in% scen) { + cfg <- setScenario(cfg, "NDC") + pathToCoupledOutput <- "/p/projects/magpie/users/vjeetze/magpie/projects/MitiConsv/C_MitiConsv_Jun25/remind/output/C_rev11_MitiConsv_SSP2-PB750-AR250-rem-9/REMIND_generic_C_rev11_MitiConsv_SSP2-PB750-AR250-rem-9.mif" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg <- setScenario(cfg, "AR250", scenario_config = "config/projects/scenario_config_miti_consv.csv") + } + + if ("AR350" %in% scen) { + cfg <- setScenario(cfg, "NDC") + pathToCoupledOutput <- "/p/projects/magpie/users/vjeetze/magpie/projects/MitiConsv/C_MitiConsv_Jun25/remind/output/C_rev11_MitiConsv_SSP2-PB750-AR350-rem-9/REMIND_generic_C_rev11_MitiConsv_SSP2-PB750-AR350-rem-9.mif" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg <- setScenario(cfg, "AR350", scenario_config = "config/projects/scenario_config_miti_consv.csv") + } + + if ("BH" %in% scen) { + cfg <- setScenario(cfg, "BH", scenario_config = "config/projects/scenario_config_miti_consv.csv") + } + + if ("KBA" %in% scen) { + cfg$gms$c22_protect_scenario <- "KBA" + } + + # Settings taken from coupled runs + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$gms$c60_2ndgen_biodem <- "coupling" + cfg$path_to_report_ghgprices <- pathToCoupledOutput + cfg$path_to_report_bioenergy <- pathToCoupledOutput + + cfg$title <- paste0(prefix, "_", paste(scen, collapse = "-")) + start_run(cfg = cfg, codeCheck = FALSE) +} diff --git a/scripts/start/projects/paper_fooddemand_standalone.R b/scripts/start/projects/paper_fooddemand_standalone.R new file mode 100644 index 0000000000..f69caa9c9e --- /dev/null +++ b/scripts/start/projects/paper_fooddemand_standalone.R @@ -0,0 +1,105 @@ +# | (C) 2008-2025 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 Paper simulations (overweight, underweight, food demand) +# ---------------------------------------------------------- + +#setwd("C:/Users/bodirsky/Desktop/articles/demand model/manuscript_from_starved_to_stuffed/magpie") + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# download supplementary data, if not yet available +if(!dir.exists("crossvalidation")) { + dir.create("crossvalidation") + download.file("http://rse.pik-potsdam.de/data/magpie/public/crossvalidation_trade_paper.tgz","crossvalidation/data.tgz") + setwd("crossvalidation") + untar("data.tgz") + unlink("data.tgz") + setwd("..") +} + +#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 + +from <- "crossvalidation/k_default/" +to <- "modules/15_food/input/" + +files <- list.files(from, pattern="*.*") +file.copy(from=paste0(from,files),to=to, overwrite=TRUE) + +cfg$title <- "demand_ssp1" +cfg$gms$c09_pop_scenario <- "SSP1" # def = SSP2 +cfg$gms$c09_gdp_scenario <- "SSP1" # def = SSP2 +start_run(cfg=cfg) + +cfg$title <- "demand_ssp2" +cfg$gms$c09_pop_scenario <- "SSP2" # def = SSP2 +cfg$gms$c09_gdp_scenario <- "SSP2" # def = SSP2 +start_run(cfg=cfg,codeCheck = FALSE) + +cfg$title <- "demand_ssp3" +cfg$gms$c09_pop_scenario <- "SSP3" # def = SSP2 +cfg$gms$c09_gdp_scenario <- "SSP3" # def = SSP2 +start_run(cfg=cfg,codeCheck = FALSE) + +cfg$title <- "demand_ssp4" +cfg$gms$c09_pop_scenario <- "SSP4" # def = SSP2 +cfg$gms$c09_gdp_scenario <- "SSP4" # def = SSP2 +start_run(cfg=cfg,codeCheck = FALSE) + +cfg$title <- "demand_ssp5" +cfg$gms$c09_pop_scenario <- "SSP5" # def = SSP2 +cfg$gms$c09_gdp_scenario <- "SSP5" # def = SSP2 +start_run(cfg=cfg,codeCheck = FALSE) + +### k-fold cross validation for historical period + +crossvalid <- c("k1","k2","k3","k4","k5","k_default") + +### calib till 1975 + +cfg$gms$c_past <- "till_1975" +cfg$gms$c09_pop_scenario <- "SSP2" # def = SSP2 +cfg$gms$c09_gdp_scenario <- "SSP2" # def = SSP2 + +for (i in crossvalid){ + cfg$title <- paste0("demand_ssp2_calib1975_",i) + from <- paste0("crossvalidation/",i,"/") + to <- "modules/15_food/input/" + files <- list.files(from, pattern="*.*") + file.copy(from=paste0(from,files),to = to, overwrite = TRUE) + cat(paste0(from,files)) + start_run(cfg=cfg,codeCheck = FALSE) +} +### no calib + +cfg$gms$s15_calibrate = 0 + +cfg$title <- "demand_ssp2_nocalib" +cfg$gms$c09_pop_scenario <- "SSP2" # def = SSP2 +cfg$gms$c09_gdp_scenario <- "SSP2" # def = SSP2 + +for (i in crossvalid){ + cfg$title <- paste0("demand_ssp2_nocalib_",i) + from <- paste0("crossvalidation/",i,"/") + to <- "modules/15_food/input/" + files <- list.files(from, pattern="*.*") + file.copy(from=paste0(from,files),to = to, overwrite = TRUE) + start_run(cfg=cfg,codeCheck = FALSE) +} + +cfg$gms$s15_calibrate <- 1 + +cfg$gms$c_past <- "till_2010" diff --git a/scripts/start/projects/paper_healthyLscps.R b/scripts/start/projects/paper_healthyLscps.R new file mode 100644 index 0000000000..59b723a2ba --- /dev/null +++ b/scripts/start/projects/paper_healthyLscps.R @@ -0,0 +1,164 @@ +# | (C) 2008-2025 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: Healthy Landscapes Paper +# ---------------------------------------------------------- + +rev <- "rev9" + +# Note: rev4 used MAgPIE 4.6.9 +# Note: rev6 used MAgPIE 4.6.10 +# Note: rev7 used MAgPIE 4.6.11 +# Note: rev8 used MAgPIE dev 16 Sep 2024 +# Note: rev9 used MAgPIE 4.8.2 + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +library(magclass) +library(gdx2) + +# Load start functions +source("scripts/start_functions.R") + +# ==================== +# Calibration +# ==================== + +source("config/default.cfg") + +cfg$title <- "calib_run" +cfg$output <- c("rds_report", "validation_short") +cfg$force_replace <- TRUE + +cfg$recalibrate <- TRUE +cfg$recalibrate_landconversion_cost <- TRUE + +cfg$best_calib <- TRUE +cfg$best_calib_landconversion_cost <- FALSE + +# cc is new default +cfg <- setScenario(cfg, "nocc_hist") + +# New iso food realisation +cfg$gms$food <- "anthro_iso_jun22" + +cfg$gms$s14_use_yield_calib <- 1 + +# sticky +cfg$gms$factor_costs <- "sticky_feb18" + +# marginal land scenario +cfg$gms$c30_marginal_land <- "q33_marginal" + +start_run(cfg = cfg) +calib_tgz <- magpie4::submitCalibration(paste(rev, "healthyLscps", sep = "_")) + +# ==================== +# Scenario runs +# ==================== + +prefix <- paste(rev, "healthyLscps", sep = "_") + +SSPs <- c("SSP2", "SSP1", "SSP3") + +scenarios <- c( + "REF", "DIET100", "DIET50", + "BIOS", "DIET100-BIOS", "DIET50-BIOS", + "landConservation", "DIET100-landConservation", "DIET50-landConservation", + "noNatureLoss2030", "DIET100-noNatureLoss2030", "DIET50-noNatureLoss2030", + "SNV20", "DIET100-SNV20", "DIET50-SNV20" +) + +for (ssp in SSPs) { + for (scen in scenarios) { + actions <- unlist(strsplit(scen, "-")) + + source("config/default.cfg") + + cfg$qos <- "short_highMem" + + cfg$results_folder <- "output/:title::date:" + + cfg$output <- c( + "output_check", "extra/disaggregation", "rds_report", "extra/runSEALSallocation" + ) + + cfg$input["calibration"] <- calib_tgz + + # Climate change switched off for these runs + cfg <- setScenario(cfg, "nocc_hist") + + # New iso food realisation + cfg$gms$food <- "anthro_iso_jun22" + + cfg$gms$s14_use_yield_calib <- 1 + + # sticky + cfg$gms$factor_costs <- "sticky_feb18" + + # SNV habitat defintion + cfg$gms$land_snv <- "secdforest, other" + + cfg <- setScenario(cfg, c(ssp, "NPI")) + cfg$gms$c15_food_scenario <- ssp + + cfg$seals_years <- c(2020, 2050) + + # --- Dietary transitions --- + + # 50 % convergence towards EAT lancet diet + if ("DIET50" %in% actions) { + cfg <- setScenario(cfg, "eat_lancet_diet_v1") + cfg$gms$s15_exo_foodscen_start <- 2020 + cfg$gms$s15_exo_foodscen_target <- 2050 + cfg$gms$s15_exo_foodscen_convergence <- 0.5 + cfg$gms$s15_exo_waste <- 1 + } + + # 100% convergence towards EAT lancet diet + if ("DIET100" %in% actions) { + cfg <- setScenario(cfg, "eat_lancet_diet_v1") + cfg$gms$s15_exo_foodscen_start <- 2020 + cfg$gms$s15_exo_foodscen_target <- 2050 + cfg$gms$s15_exo_foodscen_convergence <- 1 + cfg$gms$s15_exo_waste <- 1 + } + + # --- Ecosystem stewarship actions --- + + # 30by30 land conservation + if (any(actions %in% c("BIOS", "landConservation"))) { + cfg$gms$c22_protect_scenario <- "30by30" + cfg$gms$s22_conservation_start <- 2020 + cfg$gms$s22_conservation_target <- 2030 + } + + # no net nature loss + if (any(actions %in% c("BIOS", "noNatureLoss2030"))) { + cfg$gms$c44_bii_decrease <- 0 + cfg$gms$s44_start_year <- 2030 + } + + # permanent habitats in agricultural landscapes + if (any(actions %in% c("BIOS", "SNV20"))) { + cfg$gms$s29_snv_shr <- 0.2 + cfg$gms$s29_snv_scenario_start <- 2020 + cfg$gms$s29_snv_scenario_target <- 2030 + } + + # parameters are fixed to SSP2 values until 2020 + cfg <- setScenario(cfg, "fix_2020", scenario_config = "config/projects/scenario_config_year_fix.csv") + + cfg$title <- paste0(prefix, "_", ssp, "-", scen) + start_run(cfg = cfg, codeCheck = FALSE) + } +} diff --git a/scripts/start/projects/paper_peatland.R b/scripts/start/projects/paper_peatland.R new file mode 100644 index 0000000000..6edc4ba114 --- /dev/null +++ b/scripts/start/projects/paper_peatland.R @@ -0,0 +1,108 @@ +# | (C) 2008-2025 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: runs for peatland paper (might be useful as draft for other papers/projects) +# ---------------------------------------------------------- + +library(gms) +library(magclass) +library(gdx2) +library(luscale) +library(magpie4) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +getInput <- function(gdx,ghg_price=TRUE,biodem=TRUE) { + if(ghg_price) { + a <- readGDX(gdx,"f56_pollutant_prices_coupling") + write.magpie(a,"modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3") + } + if(biodem) { + a <- readGDX(gdx,"f60_bioenergy_dem_coupling") + write.magpie(a,"modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv") + } +} + + +#start MAgPIE run +source("config/default.cfg") +cfg$results_folder <- "output/:title:" + +cfg$gms$peatland <- "on" +cfg$gms$c60_biodem_level <- 0 +cfg$gms$s56_c_price_induced_aff <- 0 +cfg$gms$s80_optfile <- 1 + +cfg$output <- c("rds_report") +download_and_update(cfg) + +#T141 full set final SSPDB bugfix + highres +prefix <- "T143" + +for (ssp in c("SSP1","SSP2","SSP3","SSP4","SSP5")) { +#for (ssp in c("SSP2")) { + pcost <- "default" + #reset restor costs to default values + cfg$gms$s58_rewet_cost_onetime <- 7000 + cfg$gms$s58_rewet_cost_recur <- 200 + + #Ref + cfg$title <- paste(prefix,ssp,"Ref",pcost,sep="_") + cfg <- setScenario(cfg,c(ssp,"NPI")) + #getInput("/p/projects/remind/runs/magpie4-2019-04-02-develop/output/r8473-trunk-C_NPi-mag-4/fulldata.gdx") + cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" + cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" + cfg$gms$s15_elastic_demand <- 1 + cfg$gms$c12_interest_rate <- "gdp_dependent" # def = "gdp_dependent" + + cfg$gms$s56_peatland_policy <- 0 + cfg$gms$s58_rewetting_switch <- 0 + start_run(cfg,codeCheck=FALSE) + + #Pol + #getInput("/p/projects/remind/runs/magpie4-2019-04-02-develop/output/r8473-trunk-C_Budg600-mag-4/fulldata.gdx") + cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-26-REMIND-MAGPIE" + cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-26-REMIND-MAGPIE" + cfg <- setScenario(cfg,c(ssp,"NDC")) + cfg$gms$s15_elastic_demand <- 1 + cfg$gms$c12_interest_rate <- "gdp_dependent" # def = "gdp_dependent" + + cfg$title <- paste(prefix,ssp,"RCP2p6",pcost,sep="_") + cfg$gms$s56_peatland_policy <- 0 + cfg$gms$s58_rewetting_switch <- 0 + start_run(cfg,codeCheck=FALSE) + + cfg$title <- paste(prefix,ssp,"RCP2p6+PeatProt",pcost,sep="_") + cfg$gms$s56_peatland_policy <- 1 + cfg$gms$s58_rewetting_switch <- 0 + start_run(cfg,codeCheck=FALSE) + + cfg$title <- paste(prefix,ssp,"RCP2p6+PeatRestor",pcost,sep="_") + cfg$gms$s56_peatland_policy <- 1 + cfg$gms$s58_rewetting_switch <- Inf + start_run(cfg,codeCheck=FALSE) + + for (pcost in c("low","medium","high")) { + if (pcost == "low") { + cfg$gms$s58_rewet_cost_onetime <- 875 + cfg$gms$s58_rewet_cost_recur <- 25 + } else if (pcost == "medium") { + cfg$gms$s58_rewet_cost_onetime <- 7000 + cfg$gms$s58_rewet_cost_recur <- 200 + } else if (pcost == "high") { + cfg$gms$s58_rewet_cost_onetime <- 14000 + cfg$gms$s58_rewet_cost_recur <- 400 + } + cfg$title <- paste(prefix,ssp,"RCP2p6+PeatRestor",pcost,sep="_") + cfg$gms$s56_peatland_policy <- 1 + cfg$gms$s58_rewetting_switch <- Inf + start_run(cfg,codeCheck=FALSE) + } +} diff --git a/scripts/start/projects/paper_peatlandTax.R b/scripts/start/projects/paper_peatlandTax.R new file mode 100644 index 0000000000..25ac2b68ba --- /dev/null +++ b/scripts/start/projects/paper_peatlandTax.R @@ -0,0 +1,238 @@ +# | (C) 2008-2025 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: paper peatlandTax +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) +library(gdx2) +library(magpie4) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +# create additional information to describe the runs +cfg$info$flag <- "PTax49" + +cfg$results_folder <- "output/:title:" +cfg$results_folder_highres <- "output" +cfg$force_replace <- TRUE +cfg$force_download <- FALSE +cfg$qos <- "standby" + +# support function to create standardized title +.title <- function(cfg, ...) + return(paste(cfg$info$flag, sep = "_", ...)) + +cfg$repositories <- append( + list( + "https://rse.pik-potsdam.de/data/magpie/public" = NULL, + "./patch_inputdata" = NULL + ), + getOption("magpie_repos") +) + +download_and_update(cfg) + +## Create patch file for GHG prices +calc_ghgprice <- function() { + T0 <- read.magpie("modules/56_ghg_policy/input/f56_pollutant_prices.cs3") + T0 <- collapseNames(T0[, , getNames(T0, dim = 2)[1]]) + T0[, , ] <- 0 + + #T200 200 USD/tCO2 in 2050 + T200 <- new.magpie(getRegions(T0), c(seq(1995, 2025, by = 5), 2050, 2100, 2150), getNames(T0), fill = 0) + T200[, "y2025", "co2_c"] <- 0 + T200[, "y2050", "co2_c"] <- 200 + T200[, "y2100", "co2_c"] <- 200 + T200[, "y2150", "co2_c"] <- 200 + T200 <- time_interpolate(T200, seq(2015, 2100, by = 5), TRUE) + T200 <- time_interpolate(T200, seq(2100, 2150, by = 5), TRUE) + T200[, , "ch4"] <- T200[, , "co2_c"] * 28 + T200[, , "n2o_n_direct"] <- T200[, , "co2_c"] * 265 * 44 / 28 + T200[, , "n2o_n_indirect"] <- T200[, , "co2_c"] * 265 * 44 / 28 + T200[, , "co2_c"] <- T200[, , "co2_c"] * 44 / 12 + + T25 <- T200 * 0.125 + T50 <- T200 * 0.25 + T100 <- T200 * 0.5 + T400 <- T200 * 2 + T800 <- T200 * 4 + + GHG <- mbind( + add_dimension(T0, dim = 3.2, add = "scen", nm = "T0-GHG"), + add_dimension( + T25, + dim = 3.2, + add = "scen", + nm = "T25-GHG" + ), + add_dimension( + T50, + dim = 3.2, + add = "scen", + nm = "T50-GHG" + ), + add_dimension( + T100, + dim = 3.2, + add = "scen", + nm = "T100-GHG" + ), + add_dimension( + T200, + dim = 3.2, + add = "scen", + nm = "T200-GHG" + ), + add_dimension( + T400, + dim = 3.2, + add = "scen", + nm = "T400-GHG" + ), + add_dimension( + T800, + dim = 3.2, + add = "scen", + nm = "T800-GHG" + ) + ) + + CO2 <- GHG + CO2[, , c("ch4", "n2o_n_direct", "n2o_n_indirect")] <- 0 + getNames(CO2, dim = 2) <- gsub("GHG", "CO2", getNames(CO2, dim = 2)) + + GHGCH4GWP20 <- GHG + GHGCH4GWP20[, , "ch4"] <- GHGCH4GWP20[, , "ch4"] / 28 * 84 + getNames(GHGCH4GWP20, dim = 2) <- gsub("GHG", "GHG-GWP20", getNames(GHGCH4GWP20, dim = + 2)) + + GHG <- mbind(CO2, GHG, GHGCH4GWP20) + if (!dir.exists("./patch_inputdata")) + dir.create("./patch_inputdata") + if (dir.exists("./patch_inputdata/patchGHGprices")) + unlink("./patch_inputdata/patchGHGprices", recursive = TRUE) + dir.create("./patch_inputdata/patchGHGprices") + write.magpie(GHG, file_name = "patch_inputdata/patchGHGprices/f56_pollutant_prices.cs3") + tardir("patch_inputdata/patchGHGprices", + "patch_inputdata/patchGHGprices.tgz") + + unlink("patch_inputdata/patchGHGprices", recursive = TRUE) + return(getNames(GHG, dim = 2)) +} +ghgscen56 <- calc_ghgprice() +cfg$input['zzzpatchGHGprices'] <- "patchGHGprices.tgz" + +## General settings +cfg$gms$c_timesteps <- "5year" +ssp <- "SSP2" +cfg <- setScenario(cfg, c(ssp, "NPI", "rcp7p0")) +cfg$gms$c56_pollutant_prices_noselect <- "T0-CO2" +cfg$gms$policy_countries56 <- isoCountriesEUR +cfg$gms$policy_countries58 <- isoCountriesEUR +cfg$gms$c56_emis_policy <- "sdp_peatland" +cfg$gms$s56_c_price_induced_aff <- 0 + +## Start scenarios +## Ref scenario +cfg$title <- .title(cfg, paste("TAU",ssp, "Ref", sep = "-")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$gms$c56_pollutant_prices <- "T0-CO2" +cfg$gms$s58_rewetting_exo <- 0 +cfg$gms$s58_intact_prot_exo <- 0 +x <- try(modelstat(file.path("output",cfg$title,"fulldata.gdx")),silent = TRUE) +if(is.null(x) | (is.magpie(x) & any(!x %in% c(2,7)))) { + download_and_update(cfg) + start_run(cfg, codeCheck = FALSE) + message(paste0("TAU run started: ",cfg$title)) + Sys.sleep(10) +} + + +### wait until model runs with endogenous TAU are finished, check is performed every 10 minutes +success <- FALSE +while (!success) { + z <- NULL + x <- try(modelstat(file.path("output",cfg$title,"fulldata.gdx")),silent = TRUE) + if (is.magpie(x) & all(x %in% c(2,7))) { + x <- x + } else x <- NULL + z <- mbind(z,x) + if (is.null(z)) { + message("Not any model run with endogenous TAU finished. Sleeping for 10 minutes.") + Sys.sleep(60*10) + } else { + if (all(z %in% c(2,7))) success <- TRUE else stop("Modelstat different from 2 or 7 detected") + } +} + +# use exo TC in all following runs +download_and_update(cfg) +write.magpie(magpie4::tau(file.path("output",cfg$title,"fulldata.gdx"), type = "both"), "modules/13_tc/input/f13_tau_scenario.csv") +cfg$gms$tc <- "exo" + +## GHG policy scenarios +for (tax in c("T0-CO2", + "T25-CO2", + "T50-CO2", + "T100-CO2", + "T200-CO2", + "T400-CO2", + "T400-GHG", + "T400-GHG-GWP20")) { + cfg$title <- .title(cfg, paste(ssp, tax, sep = "-")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- tax + start_run(cfg, codeCheck = FALSE) +} + +cfg$gms$s58_annual_rewetting_limit <- 1 + +## Exo rewet scenarios +# 15% of currently drained peatland rewetted by 2050 (0.3 * 0.5) +cfg$title <- .title(cfg, paste(ssp, "NRL15", sep = "-")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$gms$c56_pollutant_prices <- "T0-CO2" +cfg$gms$s58_rewetting_exo <- 0.3 +cfg$gms$s58_rewet_exo_target_value <- 0.5 +cfg$gms$s58_intact_prot_exo <- 1 +start_run(cfg, codeCheck = FALSE) + +# 25% of currently drained peatland rewetted by 2050 (0.5 * 0.5) +cfg$title <- .title(cfg, paste(ssp, "NRL25", sep = "-")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$gms$c56_pollutant_prices <- "T0-CO2" +cfg$gms$s58_rewetting_exo <- 0.5 +cfg$gms$s58_rewet_exo_target_value <- 0.5 +cfg$gms$s58_intact_prot_exo <- 1 +start_run(cfg, codeCheck = FALSE) + +# 50% of currently drained peatland rewetted by 2050 (1 * 0.5) +cfg$title <- .title(cfg, paste(ssp, "NRL50", sep = "-")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$gms$c56_pollutant_prices <- "T0-CO2" +cfg$gms$s58_rewetting_exo <- 1 +cfg$gms$s58_rewet_exo_target_value <- 0.5 +cfg$gms$s58_intact_prot_exo <- 1 +start_run(cfg, codeCheck = FALSE) + +# 100% of currently drained peatland rewetted by 2050 (2 * 0.5) +cfg$title <- .title(cfg, paste(ssp, "NRL100", sep = "-")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$gms$c56_pollutant_prices <- "T0-CO2" +cfg$gms$s58_rewetting_exo <- 2 +cfg$gms$s58_rewet_exo_target_value <- 0.5 +cfg$gms$s58_intact_prot_exo <- 1 +start_run(cfg, codeCheck = FALSE) diff --git a/scripts/start/projects/paper_scp.R b/scripts/start/projects/paper_scp.R new file mode 100644 index 0000000000..e99c55a24c --- /dev/null +++ b/scripts/start/projects/paper_scp.R @@ -0,0 +1,58 @@ +# | (C) 2008-2025 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: SCP/MP paper runs +# ---------------------------------------------------------- + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +library(magclass) + +source("scripts/start_functions.R") + +source("config/default.cfg") + +# prefix, added in front of title +prefix <- "SCP44" + +# naming of result folders +cfg$results_folder <- "output/:title:" + +# output scripts +cfg$output <- c("rds_report","extra/disaggregation") + +### Scenario setup +# SSP2 as basis +cfg <- setScenario(cfg,c("SSP2","NPI")) +# single-cell microbial protein production route +cfg$gms$c20_scp_type <- "sugar" +# replacement of ruminant meat with MP +cfg$gms$kfo_rd <- "livst_rum" + +# Start MAgPIE runs with varying substitution targets of ruminant meat with MP by 2050, based on protein/cap/day basis +for (MP in c(0,20,50,80)) { + cfg$title <- paste(prefix,paste0("SSP2-Ref-MP",MP),sep="_") + if (MP == 0) { + cfg$gms$s15_rumdairy_scp_substitution <- 0 + } else if (MP == 20) { + cfg$gms$s15_rumdairy_scp_substitution <- 0.2 + } else if (MP == 50) { + cfg$gms$s15_rumdairy_scp_substitution <- 0.5 + }else if (MP == 80) { + cfg$gms$s15_rumdairy_scp_substitution <- 0.8 + } + cfg$gms$s15_food_substitution_start <- 2020 + cfg$gms$s15_food_substitution_target <- 2050 + cfg$gms$s15_food_subst_functional_form <- 2 + start_run(cfg,codeCheck=FALSE) +} diff --git a/scripts/start/projects/project_ABCDR.R b/scripts/start/projects/project_ABCDR.R new file mode 100644 index 0000000000..3161d733f5 --- /dev/null +++ b/scripts/start/projects/project_ABCDR.R @@ -0,0 +1,82 @@ +# ---------------------------------------------------------- +# description: ABCDR Project runs +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) +library(magclass) +library(gdx2) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +#download default input data +#download_and_update(cfg) + +# create additional information to describe the runs +cfg$info$flag <- "ABCDR20" + +cfg$results_folder <- "output/:title:" +cfg$force_replace <- TRUE +cfg$force_download <- FALSE + +cfg$qos <- "standby" + +# support function to create standardized title +.title <- function(cfg, ...) return(paste(cfg$info$flag, sep="_",...)) + + +cfg$input['regional'] <- "rev4.119_36f73207_magpie.tgz" +cfg$input['validation'] <- "rev4.119_36f73207_validation.tgz" +cfg$input['calibration'] <- "calibration_H16_FAO_03Feb25.tgz" +cfg$input['cellular'] <- "rev4.119_36f73207_bd86374e_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" + +ssp <- "SSP2" + +cfg$gms$cropland <- "detail_apr24" + +cfg$gms$scen_countries15 <- isoCountriesEUR +cfg$gms$policy_countries29 <- isoCountriesEUR +cfg$gms$policy_countries30 <- isoCountriesEUR + +cfg$gms$s29_fader_functional_form <- 1 # linear fader +cfg$gms$s29_treecover_scenario_start <- 2025 +cfg$gms$s29_treecover_scenario_target <- 2060 + +for (pol in c("NDC","1p5deg","1p5deg-Diet")) { + for (shr in c(0, 0.005, 0.01, 0.02)) { # share in 2045 + for (growth in c(0,1)) { + cfg$title <- .title(cfg, paste(ssp,pol,ifelse(growth==0,"natveg","plant"),paste0("AFS_tree_",sub("\\.","p",as.character(shr*100))),sep="-")) + if (pol == "NDC") { + cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) + cfg$input['cellular'] <- "rev4.119_36f73207_582d657c_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") + } else if (pol == "1p5deg") { + cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9")) + cfg$input['cellular'] <- "rev4.119_36f73207_ab632bd4_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + } else if (pol == "1p5deg-Diet") { + cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","eat_lancet_diet_v1")) + cfg$input['cellular'] <- "rev4.119_36f73207_ab632bd4_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + } + cfg$gms$s29_treecover_target <- shr / (2045 - 2025) * (2060 - 2025) # Continue linear increase after 2045 until 2060 + cfg$gms$s30_betr_target <- 0 + cfg$gms$s30_betr_penalty <- 0 + cfg$gms$s29_treecover_plantation <- growth + cfg$gms$s29_treecover_bii_coeff <- growth + start_run(cfg, codeCheck = FALSE) + } + } +} diff --git a/scripts/start/projects/project_BEST.R b/scripts/start/projects/project_BEST.R new file mode 100644 index 0000000000..307c952429 --- /dev/null +++ b/scripts/start/projects/project_BEST.R @@ -0,0 +1,180 @@ +# | (C) 2008-2025 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: BEST project bioenergy runs +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +version <- "V14" + +library(lucode2) +library(magclass) +library(gdx2) +library(magpie4) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +### define functions + +calc_bioen <- function(x) { + #B0 + B0 <- new.magpie("GLO",seq(1995,2150,by=5),NULL,fill = 0) + + #B50 + #50 EJ in 2050 globally, linear interpolation + B50 <- new.magpie("GLO",c(seq(1995,2020,by=5),2050,2100,2150),NULL,fill = 0) + B50[,"y2050",] <- 50*1000 + B50[,"y2100",] <- 50/30*80*1000 + B50[,"y2150",] <- 50/30*80*1000#50/40*90 + B50 <- time_interpolate(B50,seq(2020,2050,by=5),TRUE) + B50 <- time_interpolate(B50,seq(2050,2100,by=5),TRUE) + B50 <- time_interpolate(B50,seq(2100,2150,by=5),TRUE) + + #B100 + #100 EJ in 2050 globally, linear interpolation + B100 <- B50*2 + + if (x == "B0") { + return(B0) + } else if (x == "B50") { + return(B50) + } else if (x == "B100") { + return(B100) + } else stop("Not defined") +} +calc_ghgprice <- function(x) { + T0 <- read.magpie("modules/56_ghg_policy/input/f56_pollutant_prices.cs3") + T0 <- collapseNames(T0[,,getNames(T0,dim=2)[1]]) + T0[,,] <- 0 + + #T200 200 USD/tCO2 in 2050 + T200 <- new.magpie(getRegions(T0),c(seq(1995,2025,by=5),2050,2100,2150),getNames(T0),fill = 0) + T200[,"y2025","co2_c"] <- 25 + T200[,"y2050","co2_c"] <- 200 + T200[,"y2100","co2_c"] <- 525 + T200[,"y2150","co2_c"] <- 525 + T200 <- time_interpolate(T200,seq(2015,2100,by=5),TRUE) + T200 <- time_interpolate(T200,seq(2100,2150,by=5),TRUE) + T200[,,"ch4"] <- T200[,,"co2_c"]*28 + T200[,,"n2o_n_direct"] <- T200[,,"co2_c"]*265*44/28 + T200[,,"n2o_n_indirect"] <- T200[,,"co2_c"]*265*44/28 + T200[,,"co2_c"] <- T200[,,"co2_c"]*44/12 + + T40 <- T200*0.2 + + if (x == "T0") { + return(T0) + } else if (x == "T40") { + return(T40) + } else if (x == "T200") { + return(T200) + } else stop("Not defined") +} + +### source config +source("config/default.cfg") + +# overall setup +cfg$force_replace <- TRUE +cfg$results_folder <- "output/:title:" +cfg$gms$c60_biodem_level <- 0.01 +cfg$gms$c60_2ndgen_biodem <- "emulator" +cfg$gms$c56_pollutant_prices <- "emulator" + + +# define ssp scenarios +rcps <- c("rcp2p6","rcp6p0") +ssps <- c("SSP1","SSP2","SSP5") + +# define setup for TAU Reference run +biodem <- "B0" +ghgprice <- "T0" +bioen_type <- "all" +bioen_water <- "all" +tau_scen <- paste(biodem,ghgprice,paste0("Type",toupper(bioen_type)),paste0("Water",toupper(bioen_water)),sep="-") + +### start model runs with endogenous TAU +for (rcp in rcps) { + for (ssp in ssps) { + cfg$title <- paste("TAU",ssp,rcp,tau_scen,sep="-") + cfg <- setScenario(cfg,c(ssp,"NPI",rcp)) + cfg <- setScenario(cfg, "fix_2020", scenario_config = "config/projects/scenario_config_year_fix.csv") + cfg$gms$s32_max_aff_area <- 0 + cfg$gms$s56_c_price_induced_aff <- 0 + cfg$gms$c30_bioen_type <- bioen_type + cfg$gms$c30_bioen_water <- bioen_water + cfg$gms$tc <- "endo_jan22" + x <- try(modelstat(file.path("output",cfg$title,"fulldata.gdx")),silent = TRUE) + if(is.null(x) | (is.magpie(x) & any(!x %in% c(2,7)))) { + download_and_update(cfg) + write.magpie(calc_bioen(biodem),"modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv") + write.magpie(calc_ghgprice(ghgprice),"modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") + start_run(cfg,codeCheck=FALSE) + message(paste0("TAU run started: ",cfg$title)) + Sys.sleep(10) + } + } +} + + +### wait until model runs with endogenous TAU are finished, check is performed every 10 minutes +success <- FALSE +while (!success) { + z <- NULL + for (rcp in rcps) { + for (ssp in ssps) { + x <- try(modelstat(file.path("output",paste("TAU",ssp,rcp,tau_scen,sep="-"),"fulldata.gdx")),silent = TRUE) + if (is.magpie(x) & all(x %in% c(2,7))) { + x <- add_dimension(collapseNames(x),dim = 3.1,add = "scen",nm = paste0(ssp,rcp)) + } else x <- NULL + z <- mbind(z,x) + } + } + if (is.null(z)) { + message("Not any model run with endogenous TAU finished. Sleeping for 10 minutes.") + Sys.sleep(60*10) + } else if (dim(z)[3] < length(ssps) * length(rcps)) { + message("At least on model run with endogenous TAU not yet finished. Sleeping for 10 minutes.") + Sys.sleep(60*10) + } else if (dim(z)[3] == length(ssps) * length(rcps)) { + if (all(z %in% c(2,7))) success <- TRUE else stop("Modelstat different from 2 or 7 detected") + } +} + +### start model runs with exogenous TAU +message("Starting model runs with exogenous TAU") +for (rcp in rcps) { + for (ssp in ssps) { + for (biodem in c("B0","B50","B100")) { + for (ghgprice in c("T0","T40","T200")) { + for (bioen_type in c("all","begr","betr")) { + for (bioen_water in c("all","rainfed")) { + cfg <- setScenario(cfg,c(ssp,"NPI",rcp)) + cfg <- setScenario(cfg, "fix_2020", scenario_config = "config/projects/scenario_config_year_fix.csv") + cfg$title <- paste(version,ssp,rcp,biodem,ghgprice,paste0("Type",toupper(bioen_type)),paste0("Water",toupper(bioen_water)),sep="-") + cfg$gms$s32_max_aff_area <- 0 + cfg$gms$s56_c_price_induced_aff <- 0 + cfg$gms$tc <- "exo" + cfg$gms$c30_bioen_type <- bioen_type + cfg$gms$c30_bioen_water <- bioen_water + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",paste("TAU",ssp,rcp,tau_scen,sep="-"),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + write.magpie(calc_bioen(biodem),"modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv") + write.magpie(calc_ghgprice(ghgprice),"modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") + start_run(cfg,codeCheck=FALSE) + } + } + } + } + } +} diff --git a/scripts/start/projects/project_EAT2p0.R b/scripts/start/projects/project_EAT2p0.R new file mode 100644 index 0000000000..7c01d2c9da --- /dev/null +++ b/scripts/start/projects/project_EAT2p0.R @@ -0,0 +1,316 @@ +# | (C) 2008-2025 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 2024 +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) + +# Load start function needed to start MAgPIE runs +source("scripts/start_functions.R") +# obtain settings from default config +source("config/default.cfg") + +# set title and date +cfg$results_folder <- "output/:title::date:" +cfg$force_download <- TRUE + +# Special outputs required for Deep Dive +cfg$qos <- "standby_highMem" +cfg$output <- c( + "output_check", + # "extra/highres", # do manually on last magpie run + "extra/disaggregation", + # "projects/FSEC_nitrogenPollution", # do manually on last (high-res) magpie run + # "projects/FSEC_water", # do manually on last (high-res) magpie run + "projects/agmip_report", + # add output file: pb_report (magpie (special mif created by getReportPBindicators & remind mif (REMIND_generic_scenName.mif)) + "rds_report" +) + +# Set path to own coupled runs: +path2MitigationRun <- "/p/projects/magpie/users/beier/EL2_DeepDive_release_v3/remind/output/C_SSP2EU-DSPkB650-DS_betax_AgMIP-rem-12/REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_AgMIP-rem-12.mif" + + +####################### +# SCENARIO DEFINITION # +####################### +cfg <- setScenario(cfg, c("cc", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") + +### 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: 7p0 shocks on crops, livestock, labor +# Trade: BAU +bau <- function(cfg) { + + # for feasibility + cfg$gms$s80_optfile <- 1 + + ### General settings ### + # For impacts of CC on labor: + cfg$gms$factor_costs <- "sticky_labor" + cfg$gms$labor_prod <- "exo" + 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 + cfg$gms$s15_exo_diet <- 0 # default + cfg$gms$c09_pal_scenario <- "SSP2" # 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) + # 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 + 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 + + # Allow irrigated and rainfed bioenergy production + cfg$gms$c30_bioen_water <- "all" + + # Climate Change + cfg$input["cellular"] <- "rev4.119EL2_h12_c6a7458f_cellularmagpie_c200_IPSL-CM6A-LR-ssp370_lpjml-8e6c5eb1.tgz" + + return(cfg) +} + +### Diet component ## +# Globally achieves EL2 diet by 2050 +diet <- function(cfg) { + # EAT Lancet dietary recommendations + cfg$gms$s15_exo_diet <- 3 + # Physical inactivity levels are reduced to 0 from 2020 to 2050 + cfg$gms$c09_pal_scenario <- "SDP" + + 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 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 (both efficiency and feed basket) follows SSP1 + # (mainly for ruminant products because SSP2 already high) + cfg$gms$c70_feed_scen <- "ssp1" + 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 +# Note on our implementation: +# We use a GHG pricing pathway based on a peak budget of 650 with overshoot +# starting from 2020. +miti <- function(cfg) { + # Mitigation: consistent with 1.5C considering diet change + cfg$path_to_report_ghgprices <- path2MitigationRun + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_bioenergy <- path2MitigationRun + cfg$gms$c60_2ndgen_biodem <- "coupling" + + 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" +# standard setting +cfg <- setScenario(cfg, c("cc", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_DIET # +# Decomposition scenario. Adds EL2.0 Diet to BAU: +# Globally achieves EL2 diet by 2050 +cfg$title <- "BAU_DIET" +# standard setting +cfg <- setScenario(cfg, c("cc", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_PROD # +# Decomposition scenario adds high productivity to BAU +cfg$title <- "BAU_PROD" +# standard setting +cfg <- setScenario(cfg, c("cc", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +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" +# standard setting +cfg <- setScenario(cfg, c("cc", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- waste(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" +# standard setting, but without CC +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +# deactivate labor productivity climate impacts +cfg$gms$labor_prod <- "off" +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" +# standard setting +cfg <- setScenario(cfg, c("cc", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(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" +# standard setting, but with NDC activated (for miti) +cfg <- setScenario(cfg, c("cc", "SSP2", "NDC")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- miti(cfg = cfg) +cfg <- bau(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" +# standard setting, but with NDC activated (for miti) +cfg <- setScenario(cfg, c("cc", "SSP2", "NDC")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_Diet # +# Decomposition Scenario. Removes Diet from ELM +cfg$title <- "ELM_DIET" +# standard setting, but with NDC activated (for miti) +cfg <- setScenario(cfg, c("cc", "SSP2", "NDC")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_PROD # +# Decomposition Scenario. Removed productivity trend from ELM +cfg$title <- "ELM_PROD" +# standard setting, but with NDC activated (for miti) +cfg <- setScenario(cfg, c("cc", "SSP2", "NDC")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_WAST # +# Decomposition Scenario. Removes FLW from ELM +cfg$title <- "ELM_WAST" +# standard setting, but with NDC activated (for miti) +cfg <- setScenario(cfg, c("cc", "SSP2", "NDC")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_NoCC # +# Decomposition Scenario. Removes climate impacts (NoCC) from ELM +cfg$title <- "ELM_NoCC" +# standard setting, but with NDC activated (for miti) and without CC +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NDC")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- miti(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# ELM_MITI # +# Decomposition Scenario. Removes climate mitigation and LUC policies from ELM +cfg$title <- "ELM_MITI" +# standard setting, but with NDC activated (for miti) +cfg <- setScenario(cfg, c("cc", "SSP2", "NDC")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# scenario settings +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- prod(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) diff --git a/scripts/start/projects/project_EAT2p0_DeepDive.R b/scripts/start/projects/project_EAT2p0_DeepDive.R new file mode 100644 index 0000000000..ecb377d052 --- /dev/null +++ b/scripts/start/projects/project_EAT2p0_DeepDive.R @@ -0,0 +1,390 @@ +# | (C) 2008-2025 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 simulations for Beier et al. 2025 +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) + +# Load start function needed to start MAgPIE runs +source("scripts/start_functions.R") +# obtain settings from default config +source("config/default.cfg") + +# set title and date +cfg$results_folder <- "output/:title::date:" +cfg$force_download <- TRUE + +# Special outputs required for Deep Dive +cfg$qos <- "standby_highMem" +cfg$output <- c( + "output_check", + "extra/highres", + "extra/disaggregation", + "projects/FSEC_nitrogenPollution", + "projects/FSEC_water", + "projects/agmip_report", + "rds_report", + "runBlackmagicc" + # add output file: pb_report (magpie (special mif created by getReportPBindicators & remind mif (REMIND_generic_scenName.mif)) +) + +# Set path to own coupled runs: +path2MitigationRun <- "/p/projects/magpie/users/beier/EL2_DeepDive_release_v3/remind/output/C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12/REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12.mif" + + +####################### +# SCENARIO DEFINITION # +####################### +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") + +# Note: The climate change impacts setting differs from the global AgMIP model comparision set-up. +# We do not include climate change impacts in the coupled REMIND-MAgPIE runs for the PB Deep Dive +# because we focus exclusively on the mitigation aspect without climate change impacts. + +### 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: 7p0 shocks on crops, livestock, labor +# Trade: BAU +bau <- function(cfg) { + + # time steps until 2150 + cfg$gms$c_timesteps <- "less_TS" + + # for feasibility + cfg$gms$s80_optfile <- 1 + + cfg$gms$factor_costs <- "sticky_labor" + ### 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) + cfg$gms$c09_pal_scenario <- "SSP2" # default + # 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) + # 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" # default + # Mitigation: no mitigation beyond NPI + 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 + # Allow irrigated and rainfed bioenergy production + cfg$gms$c30_bioen_water <- "all" + + # Setting REMIND scenario for blackmagicc + cfg$magicc_emis_scen <- "REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12.mif" + + return(cfg) +} + +### Diet component ## +# Globally achieves EL2 diet by 2050 +diet <- function(cfg) { + # Transition towards EL2 food intake recommendations until 2050 + cfg$gms$s15_exo_diet <- 3 + # Physical inactivity levels are reduced to 0 from 2020 to 2050 + cfg$gms$c09_pal_scenario <- "SDP" + 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 +# Note on our implementation: +# We use a GHG pricing pathway based on a peak budget of 500 with overshoot +# starting from 2020 and diet shift. +miti <- function(cfg) { + # Mitigation: consistent with 1.5C considering Diet change + cfg$path_to_report_ghgprices <- path2MitigationRun + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_bioenergy <- path2MitigationRun + cfg$gms$c60_2ndgen_biodem <- "coupling" + # ecoSysProtAll: (Above ground CO2 emis from LUC in forest, forestry, natveg; All types of emis from peatland; All CH4 and N2O emis), + cfg$gms$c56_emis_policy <- "ecoSysProtAll" + + return(cfg) +} + +# Bioenergy demand only. No carbon price on land included. +bioenergy <- function(cfg) { + # Mitigation: only Bioenergy demand from coupled REMIND-MAgPIE run where 1.5 is reached with ghg prices on land and considering diet shift + cfg$path_to_report_bioenergy <- path2MitigationRun + cfg$gms$c60_2ndgen_biodem <- "coupling" + + return(cfg) +} + +# CO2 from land use change is priced. +priceCO2 <- function(cfg) { + # Mitigation: only price land CO2 + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_ghgprices <- path2MitigationRun + cfg$gms$c56_emis_policy <- "ecoSysProtAll_agMgmtOff" #### double-check Florian or Leon + + return(cfg) +} + +# Pricing of all CH4 and N2O emissions except for peatland +priceNonCO2 <- function(cfg) { + # Mitigation: only CH4 and N2O price + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_ghgprices <- path2MitigationRun + cfg$gms$c56_emis_policy <- "ecoSysProtOff" ### double-check Florian or Leon + + return(cfg) +} + + +################# +# SCENARIO RUNS # +################# +# BAU # +# Business as usual scenario based on SSP2 (NPis) +cfg$title <- "BAU_NPi" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (1b) BAU + Bioenergy # +# Decomposition Scenario. Adds bioenergy demand from coupled run with land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "BAU_Bioenergy" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- bioenergy(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (1c) BAU + NonCO2 pricing in land sector # +# Decomposition Scenario. Adds non-CO2 pricing with ghg price from coupled run with land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "BAU_NonCO2" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- priceNonCO2(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (1d) BAU + pricing of CO2 in land sector # +# Decomposition Scenario. Adds CO2 pricing on land-use change emissions with ghg price from coupled run with land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "BAU_CO2" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- priceCO2(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (1a,b,c,d) BAU_MIT # +# All production-side land-based mitigation measures +cfg$title <- "BAU_Miti" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation (CO2, non-CO2, bioenergy) +cfg <- miti(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# BAU_MITI - bioenergy # +# (1e) CO2 and non-CO2 pricing, but no bioenergy demand from REMIND +cfg$title <- "BAUMITI_Bioenergy" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation +cfg <- miti(cfg = cfg) +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default +cfg$path_to_report_bioenergy <- NA + +start_run(cfg, codeCheck = FALSE) + +# BAU_MITI - non-CO2 # +# (1f) CO2 pricing and bioenergy demand from REMIND, but no non-CO2 pricing in land-system +cfg$title <- "BAUMITI_nonCO2" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation +cfg <- miti(cfg = cfg) +# 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 <- "ecoSysProtAll_agMgmtOff" +start_run(cfg, codeCheck = FALSE) + +# MITI_CO2 (mitigation - CO2) # +# (1g) non-CO2 pricing and bioenergy demand from REMIND, but no CO2 pricing in land-system +cfg$title <- "BAUMITI_CO2" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation +cfg <- miti(cfg = cfg) +# ecoSysProtOff: +# (All CH4 and N2O emis except peatland), +cfg$gms$c56_emis_policy <- "ecoSysProtOff" +start_run(cfg, codeCheck = FALSE) + +# (1e,f,g) Demand-side options (Diet+Waste) by 2050 +cfg$title <- "BAU_Dem" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# MITI_Bioenergy (mitigation - bioenergy) # +# (2b) CO2 and non-CO2 pricing and demand-side mitigation (diet change), but no bioenergy demand from REMIND +cfg$title <- "MITI_Bioenergy" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation +cfg <- miti(cfg = cfg) +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" # default +cfg$path_to_report_bioenergy <- NA +# PHD +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# MITI_nonCO2 (mitigation - non-CO2) # +# (2c) CO2 pricing and bioenergy demand from REMIND and demand-side mitigation (diet change), but no non-CO2 pricing in land-system +cfg$title <- "MITI_nonCO2" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation +cfg <- miti(cfg = cfg) +# 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 <- "ecoSysProtAll_agMgmtOff" +# PHD +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# MITI_CO2 (mitigation - CO2) # +# (2d) non-CO2 pricing and bioenergy demand from REMIND and demand-side mitigation (diet change), but no CO2 pricing in land-system +cfg$title <- "MITI_CO2" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation +cfg <- miti(cfg = cfg) +# ecoSysProtOff: +# (All CH4 and N2O emis except peatland), +cfg$gms$c56_emis_policy <- "ecoSysProtOff" +# PHD +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# MITI_PHD (mitigation - PHD) # +# (2e,f,g) All production-side land-based mitigation measures, but no demand-side mitigation +cfg$title <- "MITI_Dem" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation +cfg <- miti(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +### Combining demand-side changes with single mitigation measures ### +# (3b) Demand-side change + Bioenergy # +# Decomposition Scenario with demand-side changes. Adds bioenergy demand from coupled run with land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "DEM_Bioenergy" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- bioenergy(cfg = cfg) +# Demand-side change (diet, waste) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (3c) Demand-side + NonCO2 pricing in land sector # +# Decomposition Scenario with demand-side changes. Adds non-CO2 pricing with ghg price from coupled run with land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "DEM_NonCO2" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- priceNonCO2(cfg = cfg) +# Demand-side change (diet, waste) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (3d) Demand-side + pricing of CO2 in land sector # +# Decomposition Scenario with demand-side changes. Adds CO2 pricing on land-use change emissions with ghg price from coupled run with land-use policies consistent with 1.5C by 2050 to BAU +cfg$title <- "DEM_CO2" +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- priceCO2(cfg = cfg) +# Demand-side change (diet, waste) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +### All measures ### +# MITI_All # +# All production-side land-based mitigation measures and demand-side mitigation (diet change) +cfg$title <- "MITI_All" +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", "SSP2", "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation (CO2, non-CO2, bioenergy) +cfg <- miti(cfg = cfg) +# PHD (diet, waste) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) diff --git a/scripts/start/projects/project_EAT2p0_DeepDive_Sensitivity.R b/scripts/start/projects/project_EAT2p0_DeepDive_Sensitivity.R new file mode 100644 index 0000000000..072b256c70 --- /dev/null +++ b/scripts/start/projects/project_EAT2p0_DeepDive_Sensitivity.R @@ -0,0 +1,223 @@ +# | (C) 2008-2025 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 sensitivity simulations for Beier et al. 2025 +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(lucode2) +library(magclass) +library(gms) + +# Load start function needed to start MAgPIE runs +source("scripts/start_functions.R") +# obtain settings from default config +source("config/default.cfg") + +# set title and date +cfg$results_folder <- "output/:title::date:" +cfg$force_download <- TRUE + +# Special outputs required for Deep Dive +cfg$qos <- "standby_highMem" +cfg$output <- c( + "output_check", + "extra/disaggregation", + "projects/FSEC_nitrogenPollution", + "projects/FSEC_water", + "projects/agmip_report", + "rds_report", + "runBlackmagicc" + # add output file: pb_report (magpie (special mif created by getReportPBindicators & remind mif (REMIND_generic_scenName.mif)) +) + +# Set path to own coupled runs: +path2MitigationRun <- "/p/projects/magpie/users/beier/EL2_DeepDive_release_v3/remind/output/C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12/REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12.mif" + +##################################### +### Sensitivity Settings and Runs ### +##################################### + +for (ssp in c("SSP1", "SSP2", "SSP3", "SSP4", "SSP5")) { + +####################### +# SCENARIO DEFINITION # +####################### +cfg <- setScenario(cfg, c("nocc_hist", ssp, "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") + +# Note: The climate change impacts setting differs from the global AgMIP model comparision set-up. +# We do not include climate change impacts in the coupled REMIND-MAgPIE runs for the PB Deep Dive +# because we focus exclusively on the mitigation aspect without climate change impacts. + +### 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: 7p0 shocks on crops, livestock, labor +# Trade: BAU +bau <- function(cfg) { + + # time steps until 2150 + cfg$gms$c_timesteps <- "less_TS" + + # for feasibility + cfg$gms$s80_optfile <- 1 + + cfg$gms$factor_costs <- "sticky_labor" + ### 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) + cfg$gms$c09_pal_scenario <- ssp + # 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) + # 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 <- ssp + # Mitigation: no mitigation beyond NPI + 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 + + # Allow irrigated and rainfed bioenergy production + cfg$gms$c30_bioen_water <- "all" + + # Setting REMIND scenario for blackmagicc + cfg$magicc_emis_scen <- "REMIND_generic_C_SSP2EU-DSPkB650-DS_betax_DeepDive_noNDC-rem-12.mif" + + return(cfg) +} + +### Diet component ## +# Globally achieves EL2 diet by 2050 +diet <- function(cfg) { + # Transition towards EL2 food intake recommendations until 2050 + cfg$gms$s15_exo_diet <- 3 + # Physical inactivity levels are reduced to 0 from 2020 to 2050 + cfg$gms$c09_pal_scenario <- "SDP" + 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 +# Note on our implementation: +# We use a GHG pricing pathway based on a peak budget of 500 with overshoot +# starting from 2020 and diet shift. +miti <- function(cfg) { + # Mitigation: consistent with 1.5C considering Diet change + cfg$path_to_report_ghgprices <- path2MitigationRun + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_bioenergy <- path2MitigationRun + cfg$gms$c60_2ndgen_biodem <- "coupling" + # ecoSysProtAll: (Above ground CO2 emis from LUC in forest, forestry, natveg; All types of emis from peatland; All CH4 and N2O emis), + cfg$gms$c56_emis_policy <- "ecoSysProtAll" + + return(cfg) +} + +# Bioenergy demand only. No carbon price on land included. +bioenergy <- function(cfg) { + # Mitigation: only Bioenergy demand from coupled REMIND-MAgPIE run where 1.5 is reached with ghg prices on land and considering diet shift + cfg$path_to_report_bioenergy <- path2MitigationRun + cfg$gms$c60_2ndgen_biodem <- "coupling" + + return(cfg) +} + +# CO2 from land use change is priced. +priceCO2 <- function(cfg) { + # Mitigation: only price land CO2 + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_ghgprices <- path2MitigationRun + cfg$gms$c56_emis_policy <- "ecoSysProtAll_agMgmtOff" #### double-check Florian or Leon + + return(cfg) +} + +# Pricing of all CH4 and N2O emissions except for peatland +priceNonCO2 <- function(cfg) { + # Mitigation: only CH4 and N2O price + cfg$gms$c56_pollutant_prices <- "coupling" + cfg$path_to_report_ghgprices <- path2MitigationRun + cfg$gms$c56_emis_policy <- "ecoSysProtOff" ### double-check Florian or Leon + + return(cfg) +} + + +################# +# SCENARIO RUNS # +################# +# BAU # +# Business as usual scenario based on SSP2 (NPis) +cfg$title <- paste0(ssp, "_BAU_NPi") +cfg <- setScenario(cfg, c("nocc_hist", ssp, "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (1a,b,c,d) BAU_MIT # +# All production-side land-based mitigation measures +cfg$title <- paste0(ssp, "_BAU_Miti") +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", ssp, "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation (CO2, non-CO2, bioenergy) +cfg <- miti(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +# (1e,f,g) Demand-side options (Diet+Waste) by 2050 +cfg$title <- paste0(ssp, "_BAU_Dem") +cfg <- setScenario(cfg, c("nocc_hist", ssp, "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +cfg <- bau(cfg = cfg) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +### All measures ### +# MITI_All # +# All production-side land-based mitigation measures and demand-side mitigation (diet change) +cfg$title <- paste0(ssp, "_MITI_All") +# standard setting, but with NDC for miti +cfg <- setScenario(cfg, c("nocc_hist", ssp, "NPI")) +cfg <- setScenario(cfg, c("EL2_default"), scenario_config = "config/projects/scenario_config_el2.csv") +# BAU settings +cfg <- bau(cfg = cfg) +# Mitigation (CO2, non-CO2, bioenergy) +cfg <- miti(cfg = cfg) +# PHD (diet, waste) +cfg <- diet(cfg = cfg) +cfg <- waste(cfg = cfg) +start_run(cfg, codeCheck = FALSE) + +} diff --git a/scripts/start/projects/project_FSEC_Scenarios.R b/scripts/start/projects/project_FSEC_Scenarios.R new file mode 100644 index 0000000000..58b4886665 --- /dev/null +++ b/scripts/start/projects/project_FSEC_Scenarios.R @@ -0,0 +1,43 @@ +# | (C) 2008-2025 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: Scenarios for FSEC +# ---------------------------------------------------------- + +library(gms) +source("scripts/start_functions.R") +source("scripts/projects/fsec.R") + +codeCheck <- FALSE + +for (scenarioName in c( + # Scenario combination runs + "c_BAU", + "d_SSP2fsdp", + "e_FSDP", + "b_Diet", "b_Livelihoods", "b_NatureSparing", "b_AgroMngmt", "b_ExternalPressures", + # Single transformation runs + "a_Population", "a_EconDevelop", "a_EnergyTrans", + "a_NoUnderweight", "a_HalfOverweight", "a_DietVegFruitsNutsSeeds", "a_DietLegumes", + "a_DietMonogastrics", "a_DietRuminants", "a_DietEmptyCals", "a_LessFoodWaste", + "a_ManureMngmt", "a_LivestockMngmt", "a_BiodivSparing", + "a_NitrogenEff", "a_RiceMit", "a_CropeffTax", + "a_CapitalSubst", "a_MinWage", "a_Bioplastics", "a_LandscapeElements", + "a_LiberalizedTrade", "a_TimberCities", "a_REDDaff", "a_REDD", "a_CropRotations", + "a_LandSparing", "a_WaterSparing", "a_PeatlandSparing", "a_SoilCarbon", + # Other SSPs + "d_SSP1fsdp", "d_SSP3fsdp", "d_SSP4fsdp", "d_SSP5fsdp", + "d_SSP1bau", "d_SSP3bau", "d_SSP4bau", "d_SSP5bau", + # Sensitivity checks + "f_BAUlabor8p5", "f_FSDPlabor1p9", "d_SSP1PLUSbau" +)) { + + # Start runs + cfg <- fsecScenario(scenario = scenarioName) + start_run(cfg = cfg, codeCheck = codeCheck, lock_timeout = 6) +} diff --git a/scripts/start/projects/project_GCS.R b/scripts/start/projects/project_GCS.R new file mode 100644 index 0000000000..681ab43d04 --- /dev/null +++ b/scripts/start/projects/project_GCS.R @@ -0,0 +1,139 @@ +# | (C) 2008-2025 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: Test of scenario design for the GCS project +# position: 5 +# ---------------------------------------------------------- + + +##### Version log (YYYYMMDD - Description - Author(s)) +## v0.1 - 20210927 - GCS scenarios - IW + +library(lucode2) +library(magclass) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Sources the default configuration file +source("config/default.cfg") + + + + +################################################################# +# SSP1 and SSP2 variants without carbon pricing # +################################################################# + + +### SSP2 NDC rcp7p0 ########################## +cfg$title <- "SSP2_NDC_rcp7p0" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp7p0")) +start_run(cfg,codeCheck=FALSE) + +### SSP2 NDC rcp6p0 ########################## +cfg$title <- "SSP2_NDC_rcp6p0" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp6p0")) +start_run(cfg,codeCheck=FALSE) + +### SSP2 NDC rcp2p6 ########################## +cfg$title <- "SSP2_NDC_rcp2p6" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp2p6")) +start_run(cfg,codeCheck=FALSE) + +### SSP2 NDC nocc ############################ +cfg$title <- "SSP2_NDC_nocc" +cfg <- setScenario(cfg,c("SSP2","NDC","nocc")) +start_run(cfg,codeCheck=FALSE) + +### SSP2-Tland NDC rcp2p6 ########################## +cfg$title <- "SSP2-Tland_NDC_rcp2p6" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp2p6")) +cfg <- setScenario(cfg, c("Tland"), scenario_config = "config/projects/scenario_config_gcs.csv") +start_run(cfg,codeCheck=FALSE) + +### SSP1 NDC rcp2p6 ########################## +cfg$title <- "SSP1_NDC_rcp2p6" +cfg <- setScenario(cfg,c("SSP1","NDC","cc","rcp2p6")) +start_run(cfg,codeCheck=FALSE) + + + +################################################################# +# SSP2 with two carbon pricing variants # +################################################################# + + +### SSP2 with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- "SSP2_ssp2pkbudg900_rcp2p6" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp2p6")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + +### SSP2 with climate policy parametrized from R21M42-SDP-PkBudg1000 +cfg$title <- "SSP2_sdppkbudg1000_rcp2p6" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp2p6")) +cfg$gms$c56_pollutant_prices <- "R21M42-SDP-PkBudg1000" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SDP-PkBudg1000" +start_run(cfg,codeCheck=FALSE) + + + +################################################################# +# SSP2 with sustainable land transformation (Tland) +# and with two carbon pricing variants # +################################################################# + + +### SSP2-Tland with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- "SSP2-Tland_ssp2pkbudg900_rcp2p6" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp2p6")) +cfg <- setScenario(cfg, c("Tland"), scenario_config = "config/projects/scenario_config_gcs.csv") +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + +### SSP2-Tland with climate policy parametrized from R21M42-SDP-PkBudg1000 +cfg$title <- "SSP2-Tland_sdppkbudg1000_rcp2p6" +cfg <- setScenario(cfg,c("SSP2","NDC","cc","rcp2p6")) +cfg <- setScenario(cfg, c("Tland"), scenario_config = "config/projects/scenario_config_gcs.csv") +cfg$gms$c56_pollutant_prices <- "R21M42-SDP-PkBudg1000" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SDP-PkBudg1000" +start_run(cfg,codeCheck=FALSE) + + +################################################################# +# SSP1 with sustainable land transformation (Tland) +# and with two carbon pricing variants # +################################################################# + + +### SSP1-Tland with climate policy parametrized from R21M42-SSP1-PkBudg900 +cfg$title <- "SSP1-Tland_ssp1pkbudg900_rcp2p6" +cfg <- setScenario(cfg,c("SSP1","NDC","cc","rcp2p6")) +cfg <- setScenario(cfg, c("Tland"), scenario_config = "config/projects/scenario_config_gcs.csv") +cfg$gms$c56_pollutant_prices <- "R21M42-SSP1-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP1-PkBudg900" +start_run(cfg,codeCheck=FALSE) + +### SSP1-Tland with climate policy parametrized from R21M42-SDP-PkBudg1000 +cfg$title <- "SSP1-Tland_sdppkbudg1000_rcp2p6" +cfg <- setScenario(cfg,c("SSP1","NDC","cc","rcp2p6")) +cfg <- setScenario(cfg, c("Tland"), scenario_config = "config/projects/scenario_config_gcs.csv") +cfg$gms$c56_pollutant_prices <- "R21M42-SDP-PkBudg1000" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SDP-PkBudg1000" +start_run(cfg,codeCheck=FALSE) + + +##revert +cfg <- setScenario(cfg,c("SSP2","NPI","cc","rcp7p0")) +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-NPi" + diff --git a/scripts/start/projects/project_LAMACLIMA_WP4.R b/scripts/start/projects/project_LAMACLIMA_WP4.R new file mode 100644 index 0000000000..f90bac034b --- /dev/null +++ b/scripts/start/projects/project_LAMACLIMA_WP4.R @@ -0,0 +1,120 @@ +# | (C) 2008-2025 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: LAMACLIMA WP4 runs +# ---------------------------------------------------------- + +###################################### +#### Script to start a MAgPIE run #### +###################################### + + +library(gms) +library(magclass) +library(gdx2) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +#start MAgPIE run +source("config/default.cfg") + +prefix <- "LAMA91" +cfg$force_replace <- TRUE + +cfg$gms$factor_costs <- "sticky_labor" +cfg$input["calibration"] <- "calibration_H12_sticky_feb18_dynamic_30Nov21.tgz" +cfg$gms$c17_prod_init <- "off" + +cfg$gms$labor_prod <- "exo" +cfg$gms$c37_labor_rcp <- "rcp119" +cfg$gms$c37_labor_metric <- "ISO" +cfg$gms$c37_labor_intensity <- "400W" +cfg$gms$c37_labor_uncertainty <- "ensmean" + +cfg$results_folder <- "output/:title:" +cfg$output <- c("rds_report","extra/disaggregation","extra/disaggregation_LUH2","extra/highres") +cfg$qos <- "priority_highMem" + +#### Main scenarios + +### Global Sustainability, largely based on SDP +cfg$title <- paste(prefix, "Sustainability", sep = "_") +cfg <- setScenario(cfg, c("rcp1p9")) +cfg <- setScenario(cfg, c("LAMA_Sustainability"), scenario_config = "config/projects/scenario_config_lama.csv") + +cfg$gms$policy_countries30 <- all_iso_countries +cfg$gms$policy_countries22 <- all_iso_countries +cfg$gms$EFP_countries <- all_iso_countries +cfg$gms$cropneff_countries <- all_iso_countries +cfg$gms$scen_countries55 <- all_iso_countries +cfg$gms$policy_countries56 <- all_iso_countries +start_run(cfg,codeCheck=FALSE) + +### Global Inequality, largely based on SSP4 +cfg$title <- paste(prefix, "Inequality", sep = "_") +cfg <- setScenario(cfg, c("rcp1p9")) +cfg <- setScenario(cfg, c("LAMA_Inequal"), scenario_config = "config/projects/scenario_config_lama.csv") +cfg$gms$policy_countries30 <- oecd90andEU +cfg$gms$policy_countries22 <- oecd90andEU +cfg$gms$EFP_countries <- oecd90andEU +cfg$gms$cropneff_countries <- oecd90andEU +cfg$gms$scen_countries55 <- oecd90andEU +cfg$gms$policy_countries56 <- oecd90andEU +start_run(cfg,codeCheck=FALSE) + +#### Sensitivity scenarios + +### LAMA_Inequal-SustDemand +cfg$title <- paste(prefix, "Inequality-SustDemand", sep = "_") +cfg <- setScenario(cfg, c("rcp1p9")) +cfg <- setScenario(cfg, c("LAMA_Inequal-SustDemand"), scenario_config = "config/projects/scenario_config_lama.csv") +cfg$gms$policy_countries30 <- oecd90andEU +cfg$gms$policy_countries22 <- oecd90andEU +cfg$gms$EFP_countries <- oecd90andEU +cfg$gms$cropneff_countries <- oecd90andEU +cfg$gms$scen_countries55 <- oecd90andEU +cfg$gms$policy_countries56 <- oecd90andEU +start_run(cfg,codeCheck=FALSE) + +### LAMA_Inequal-EnvirProt +cfg$title <- paste(prefix, "Inequality-EnvirProt", sep = "_") +cfg <- setScenario(cfg, c("rcp1p9")) +cfg <- setScenario(cfg, c("LAMA_Inequal-EnvirProt"), scenario_config = "config/projects/scenario_config_lama.csv") +cfg$gms$policy_countries30 <- all_iso_countries +cfg$gms$policy_countries22 <- all_iso_countries +cfg$gms$EFP_countries <- all_iso_countries +cfg$gms$cropneff_countries <- all_iso_countries +cfg$gms$scen_countries55 <- all_iso_countries +cfg$gms$policy_countries56 <- oecd90andEU +start_run(cfg,codeCheck=FALSE) + +### LAMA_Inequal-GHGPrice +cfg$title <- paste(prefix, "Inequality-GHGPrice", sep = "_") +cfg <- setScenario(cfg, c("rcp1p9")) +cfg <- setScenario(cfg, c("LAMA_Inequal-GHGPrice"), scenario_config = "config/projects/scenario_config_lama.csv") +cfg$gms$policy_countries30 <- oecd90andEU +cfg$gms$policy_countries22 <- oecd90andEU +cfg$gms$EFP_countries <- oecd90andEU +cfg$gms$cropneff_countries <- oecd90andEU +cfg$gms$scen_countries55 <- oecd90andEU +cfg$gms$policy_countries56 <- all_iso_countries +start_run(cfg,codeCheck=FALSE) + +### Global Inequality with higher climate impacts +cfg$title <- paste(prefix, "Inequality-rcp7p0", sep = "_") +cfg <- setScenario(cfg, c("rcp7p0")) +cfg <- setScenario(cfg, c("LAMA_Inequal"), scenario_config = "config/projects/scenario_config_lama.csv") +cfg$gms$policy_countries30 <- oecd90andEU +cfg$gms$policy_countries22 <- oecd90andEU +cfg$gms$EFP_countries <- oecd90andEU +cfg$gms$cropneff_countries <- oecd90andEU +cfg$gms$scen_countries55 <- oecd90andEU +cfg$gms$policy_countries56 <- oecd90andEU +cfg$gms$c37_labor_rcp <- "rcp585" +start_run(cfg,codeCheck=FALSE) diff --git a/scripts/start/projects/project_SHAPE.R b/scripts/start/projects/project_SHAPE.R new file mode 100644 index 0000000000..c30476b813 --- /dev/null +++ b/scripts/start/projects/project_SHAPE.R @@ -0,0 +1,164 @@ +# | (C) 2008-2025 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: SHAPE scenarios +# position: 5 +# ---------------------------------------------------------- + + +##### Version log (YYYYMMDD - Description - Author(s)) +## 20220106 - SHAPE Baseline and Policy runs. For climate policy parametrization, indentical inputs are used across all scenarios ("R21M42-SSP2-PkBudg900") - IW + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) +library(magclass) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + + +### General configurations + +prefix <- "R5_SHAPE" +cfg$results_folder <- "output/:title:" +cfg$output <- c("rds_report") # Only run rds_report after model run + + + +################################################################# +# SSP2: NPI and climate policy runs # +################################################################# + +### SSP2 Base (NPI) +cfg$title <- paste(prefix,"SSP2_Base",sep="_") +cfg <- setScenario(cfg,c("SSP2","NPI")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" +start_run(cfg,codeCheck=FALSE) + +### SSP2 with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- paste(prefix,"SSP2_Cpol",sep="_") +cfg <- setScenario(cfg,c("SSP2","NDC")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + + +################################################################# +# SDP-RC: NPI and climate policy runs # +################################################################# + +#### SDP-RC Base (NPI) +cfg$title <- paste(prefix,"SDP-RC_Base",sep="_") +cfg <- setScenario(cfg,c("SDP-RC","NPI")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" +start_run(cfg,codeCheck=FALSE) + +### SDP-RC with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- paste(prefix,"SDP-RC_Cpol",sep="_") +cfg <- setScenario(cfg,c("SDP-RC","NDC")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + + +################################################################# +# SDP-MC: NPI and climate policy runs # +################################################################# + +#### SDP-MC Base (NPI) +cfg$title <- paste(prefix,"SDP-MC_Base",sep="_") +cfg <- setScenario(cfg,c("SDP-MC","NPI")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" +start_run(cfg,codeCheck=FALSE) + +### SDP-MC with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- paste(prefix,"SDP-MC_Cpol",sep="_") +cfg <- setScenario(cfg,c("SDP-MC","NDC")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + + +################################################################# +# SDP-EI: NPI and climate policy runs # +################################################################# + + +#### SDP-EI Base (NPI) +cfg$title <- paste(prefix,"SDP-EI_Base",sep="_") +cfg <- setScenario(cfg,c("SDP-EI","NPI")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" +start_run(cfg,codeCheck=FALSE) + +### SDP-EI with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- paste(prefix,"SDP-EI_Cpol",sep="_") +cfg <- setScenario(cfg,c("SDP-EI","NDC")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + + +#reset: +cfg$gms$kfo_rd <- "livst_rum,livst_milk" + + + + + +##################################################################### +# Additional scenarios # +##################################################################### + +############################### +# SSP1: NPI and climate policy runs # + +### SSP1 Base (NPI) +cfg$title <- paste(prefix,"SSP1_Base",sep="_") +cfg <- setScenario(cfg,c("SSP1","NPI")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" +start_run(cfg,codeCheck=FALSE) + +### SSP1 with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- paste(prefix,"SSP1_Cpol",sep="_") +cfg <- setScenario(cfg,c("SSP1","NDC")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + + +############################### +# SDP: NPI and climate policy runs # + +### SDP Base (NPI) +cfg$title <- paste(prefix,"SDP_Base",sep="_") +cfg <- setScenario(cfg,c("SDP","NPI")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" +start_run(cfg,codeCheck=FALSE) + +### SDP with climate policy parametrized from R21M42-SSP2-PkBudg900 +cfg$title <- paste(prefix,"SDP_Cpol",sep="_") +cfg <- setScenario(cfg,c("SDP","NDC")) +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-PkBudg900" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-PkBudg900" +start_run(cfg,codeCheck=FALSE) + + + +#reset: +cfg$gms$c56_pollutant_prices <- "R21M42-SSP2-NPi" +cfg$gms$c60_2ndgen_biodem <- "R21M42-SSP2-NPi" diff --git a/scripts/start/projects/project_ScenarioMIP.R b/scripts/start/projects/project_ScenarioMIP.R new file mode 100644 index 0000000000..c70c72589e --- /dev/null +++ b/scripts/start/projects/project_ScenarioMIP.R @@ -0,0 +1,216 @@ +# | (C) 2008-2025 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: ScenarioMIP runs +# position: 1 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +# create additional information to describe the runs +cfg$info$flag <- "SMIP65" +cfg$qos <- "standby" + +cfg$results_folder <- "output/:title:" +cfg$force_replace <- TRUE + +# support function to create standardized title +.title <- function(cfg, ...) return(paste(cfg$info$flag, sep="_",...)) + +#download default input data +cfg$input[["report_coupling"]] <- "SMIPv06_report_coupling.tgz" +download_and_update(cfg) + +cfg$gms$c56_pollutant_prices <- "coupling" +cfg$gms$c60_2ndgen_biodem <- "coupling" +cfg$gms$cropland <- "detail_apr24" +cfg$gms$som <- "cellpool_jan23" +cfg$gms$s15_elastic_demand <- 1 +cfg$gms$s56_limit_ch4_n2o_price <- 734 +cfg$gms$s32_annual_aff_limit <- 0.03 + +### Main scenarios + +#H-SSP3-rollBack +cfg$title <- .title(cfg, "H-SSP3-rollBack") +cfg <- setScenario(cfg,c("SSP3","NPI-revert","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-H-SSP3-rollBack-def-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-H-SSP3-rollBack-def-rem-7.mif" +cfg$gms$c15_food_scenario <- "SSP2" +cfg$gms$s32_npi_ndc_reversal <- 2030 +cfg$gms$s35_npi_ndc_reversal <- 2030 +cfg$gms$s29_treecover_target <- 0 +cfg$gms$s44_bii_target <- 0 +cfg$gms$c44_bii_decrease <- 1 +cfg$gms$s44_start_year <- 2030 +cfg$gms$s56_fader_cpriceaff_start <- 2030 +cfg$gms$s56_fader_cpriceaff_end <- 2030 +cfg$gms$s59_scm_target <- 0 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +#M-SSP2-NPi2025 +cfg$title <- .title(cfg, "M-SSP2-NPi2025") +cfg <- setScenario(cfg,c("SSP2","NPI","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-M-SSP2-NPi2025-def-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-M-SSP2-NPi2025-def-rem-7.mif" +cfg$gms$s29_treecover_target <- 0 +cfg$gms$s44_bii_target <- 0 +cfg$gms$c44_bii_decrease <- 1 +cfg$gms$s44_start_year <- 2030 +cfg$gms$s56_fader_cpriceaff_start <- 2030 +cfg$gms$s56_fader_cpriceaff_end <- 2030 +cfg$gms$s59_scm_target <- 0 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +#ML-SSP2-PkBudg1500 +cfg$title <- .title(cfg, "ML-SSP2-PkBudg1500") +cfg <- setScenario(cfg,c("SSP2","NPI","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2040" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-ML-SSP2-EcPrice310-var-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-ML-SSP2-EcPrice310-var-rem-7.mif" +cfg$gms$s29_treecover_target <- 0 +cfg$gms$s44_bii_target <- 0 +cfg$gms$c44_bii_decrease <- 1 +cfg$gms$s44_start_year <- 2030 +cfg$gms$s56_fader_cpriceaff_start <- 2030 +cfg$gms$s56_fader_cpriceaff_end <- 2030 +cfg$gms$s59_scm_target <- 0 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +#L-SSP2-PkBudg1000 +cfg$title <- .title(cfg, "L-SSP2-PkBudg1000") +cfg <- setScenario(cfg,c("SSP2","NDC","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-L-SSP2-PkPrice400-var-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-L-SSP2-PkPrice400-var-rem-7.mif" +cfg$gms$s29_treecover_scenario_start <- 2030 +cfg$gms$s29_treecover_scenario_target <- 2050 +cfg$gms$s29_treecover_target <- 0.01 +cfg$gms$s44_bii_target <- 0 +cfg$gms$c44_bii_decrease <- 0 +cfg$gms$s44_start_year <- 2030 +cfg$gms$s56_fader_cpriceaff_start <- 2030 +cfg$gms$s56_fader_cpriceaff_end <- 2030 +cfg$gms$s59_scm_scenario_start <- 2030 +cfg$gms$s59_scm_scenario_target <- 2050 +cfg$gms$s59_scm_target <- 0.1 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +#VLHO-SSP2-EcBudg400 +cfg$title <- .title(cfg, "VLHO-SSP2-EcBudg400") +cfg <- setScenario(cfg,c("SSP2","NPI","AR-plant","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-VLHO-SSP2-EcPrice1250-var-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-VLHO-SSP2-EcPrice1250-var-rem-7.mif" +cfg$gms$s29_treecover_scenario_start <- 2050 +cfg$gms$s29_treecover_scenario_target <- 2070 +cfg$gms$s29_treecover_target <- 0.02 +cfg$gms$s44_bii_target <- 0 +cfg$gms$c44_bii_decrease <- 0 +cfg$gms$s44_start_year <- 2050 +cfg$gms$s56_fader_cpriceaff_start <- 2040 +cfg$gms$s56_fader_cpriceaff_end <- 2050 +cfg$gms$s59_scm_scenario_start <- 2050 +cfg$gms$s59_scm_scenario_target <- 2070 +cfg$gms$s59_scm_target <- 0.2 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +#VLLO-SSP1-PkBudg650 +cfg$title <- .title(cfg, "VLLO-SSP1-PkBudg650") +cfg <- setScenario(cfg,c("VLLO","NDC","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-VLLO-SSP1-PkPrice500-def-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-VLLO-SSP1-PkPrice500-def-rem-7.mif" +cfg$gms$s29_treecover_scenario_start <- 2025 +cfg$gms$s29_treecover_scenario_target <- 2050 +cfg$gms$s29_treecover_target <- 0.03 +cfg$gms$s44_bii_target <- 0.7 +cfg$gms$c44_bii_decrease <- 1 +cfg$gms$s44_start_year <- 2030 +cfg$gms$s56_fader_cpriceaff_start <- 2030 +cfg$gms$s56_fader_cpriceaff_end <- 2030 +cfg$gms$s59_scm_scenario_start <- 2025 +cfg$gms$s59_scm_scenario_target <- 2050 +cfg$gms$s59_scm_target <- 0.3 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +### Variants + +#H-SSP3-NPi2025 - no rollback +cfg$title <- .title(cfg, "H-SSP3-NPi2025") +cfg <- setScenario(cfg,c("SSP3","NPI","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-M-SSP3-NPi2025-def-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-M-SSP3-NPi2025-def-rem-7.mif" +cfg$gms$c15_food_scenario <- "SSP2" +cfg$gms$s29_treecover_target <- 0 +cfg$gms$s44_bii_target <- 0 +cfg$gms$c44_bii_decrease <- 1 +cfg$gms$s44_start_year <- 2030 +cfg$gms$s56_fader_cpriceaff_start <- 2030 +cfg$gms$s56_fader_cpriceaff_end <- 2030 +cfg$gms$s59_scm_target <- 0 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +#VLHO-SSP2-EcBudg400-ARnatveg +cfg$title <- .title(cfg, "VLHO-SSP2-EcBudg400-ARnatveg") +cfg <- setScenario(cfg,c("SSP2","NPI","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-VLHO-SSP2-EcBudg400-var_natveg-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-VLHO-SSP2-EcBudg400-var_natveg-rem-7.mif" +cfg$gms$s29_treecover_scenario_start <- 2050 +cfg$gms$s29_treecover_scenario_target <- 2070 +cfg$gms$s29_treecover_target <- 0.02 +cfg$gms$s44_bii_target <- 0 +cfg$gms$c44_bii_decrease <- 0 +cfg$gms$s44_start_year <- 2050 +cfg$gms$s56_fader_cpriceaff_start <- 2040 +cfg$gms$s56_fader_cpriceaff_end <- 2050 +cfg$gms$s59_scm_scenario_start <- 2050 +cfg$gms$s59_scm_scenario_target <- 2070 +cfg$gms$s59_scm_target <- 0.2 +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg, codeCheck = FALSE) + +#VLLO-SSP1-PkBudg650-noAnnualAffLimit +cfg$title <- .title(cfg, "VLLO-SSP1-PkBudg650-noAnnualAffLimit") +cfg <- setScenario(cfg,c("VLLO","NDC","AR-natveg","nocc_hist")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$path_to_report_ghgprices <- "input/REMIND_generic_C_SMIPv06-VLLO-SSP1-PkPrice500-def-rem-7.mif" +cfg$path_to_report_bioenergy <- "input/REMIND_generic_C_SMIPv06-VLLO-SSP1-PkPrice500-def-rem-7.mif" +cfg$gms$s29_treecover_scenario_start <- 2025 +cfg$gms$s29_treecover_scenario_target <- 2050 +cfg$gms$s29_treecover_target <- 0.03 +cfg$gms$s44_bii_target <- 0.7 +cfg$gms$c44_bii_decrease <- 1 +cfg$gms$s44_start_year <- 2030 +cfg$gms$s56_fader_cpriceaff_start <- 2030 +cfg$gms$s56_fader_cpriceaff_end <- 2030 +cfg$gms$s59_scm_scenario_start <- 2025 +cfg$gms$s59_scm_scenario_target <- 2050 +cfg$gms$s59_scm_target <- 0.3 +cfg$gms$c60_1stgen_biodem <- "const2030" +cfg$gms$s32_annual_aff_limit <- 1 +start_run(cfg, codeCheck = FALSE) diff --git a/scripts/start/projects/project_WetHorizons.R b/scripts/start/projects/project_WetHorizons.R new file mode 100644 index 0000000000..51e8aa5df9 --- /dev/null +++ b/scripts/start/projects/project_WetHorizons.R @@ -0,0 +1,309 @@ +# | (C) 2008-2025 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: Project WetHorizons Peatland +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(magclass) +library(gdx2) +library(magpie4) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +# create additional information to describe the runs +cfg$info$flag <- "WH07" + +cfg$results_folder <- "output/:title:" +cfg$results_folder_highres <- "output" +cfg$force_replace <- TRUE +cfg$force_download <- FALSE +cfg$qos <- "standby" + +# support function to create standardized title +.title <- function(cfg, ...) + return(paste(cfg$info$flag, sep = "_", ...)) + +cfg$repositories <- append( + list( + "https://rse.pik-potsdam.de/data/magpie/public" = NULL, + "./patch_inputdata" = NULL + ), + getOption("magpie_repos") +) + +cfg$gms$c_timesteps <- "5year" + +ssps <- c("SSP1","SSP2","SSP3","SSP5") + +for (ssp in ssps) { + if (ssp %in% c("SSP1","SSP2","SSP5")) { + cfg$title <- .title(cfg, paste(ssp, "1p5deg", "noPeatland", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp1p9")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg650") + } else { + cfg$title <- .title(cfg, paste(ssp, "2deg", "noPeatland", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg1000") + } + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 0 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.5 + cfg$gms$s58_annual_rewetting_limit <- 0.02 + cfg$gms$s58_intact_prot_exo <- 0 + cfg$gms$tc <- "endo_jan22" + x <- try(modelstat(file.path("output",cfg$title,"fulldata.gdx")),silent = TRUE) + if(is.null(x) | (is.magpie(x) & any(!x %in% c(2,7)))) { + download_and_update(cfg) + start_run(cfg,codeCheck=FALSE) + message(paste0("TAU run started: ",cfg$title)) + Sys.sleep(10) + } +} + +### wait until model runs with endogenous TAU are finished, check is performed every 10 minutes +success <- FALSE +while (!success) { + z <- NULL + for (ssp in ssps) { + if (ssp %in% c("SSP1","SSP2","SSP5")) { + x <- try(modelstat(file.path("output",.title(cfg, paste(ssp, "1p5deg", "noPeatland", sep = "-")),"fulldata.gdx")),silent = TRUE) + } else { + x <- try(modelstat(file.path("output",.title(cfg, paste(ssp, "2deg", "noPeatland", sep = "-")),"fulldata.gdx")),silent = TRUE) + } + if (is.magpie(x) & all(x %in% c(2,7))) { + x <- add_dimension(collapseNames(x),dim = 3.1,add = "scen",nm = paste0(ssp)) + } else x <- NULL + z <- mbind(z,x) + } + if (is.null(z)) { + message("Not any model run with endogenous TAU finished. Sleeping for 10 minutes.") + Sys.sleep(60*10) + } else if (dim(z)[3] < length(ssps)) { + message("At least on model run with endogenous TAU not yet finished. Sleeping for 10 minutes.") + Sys.sleep(60*10) + } else if (dim(z)[3] == length(ssps)) { + if (all(z %in% c(2,7))) success <- TRUE else stop("Modelstat different from 2 or 7 detected") + } +} + +for (ssp in ssps) { + + # Ref + cfg$title <- .title(cfg, paste(ssp, "Ref", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NPI", "rcp4p5")) + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-NPi2025") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-NPi2025") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil" + cfg$gms$s58_rewetting_exo <- 0 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.5 + cfg$gms$s58_annual_rewetting_limit <- 0.02 + cfg$gms$s58_intact_prot_exo <- 0 + cfg$gms$tc <- "endo_jan22" + start_run(cfg, codeCheck = FALSE) +} + +for (ssp in ssps) { + + if (ssp %in% c("SSP1","SSP2","SSP5")) { + + # PkBudg650 + cfg$title <- .title(cfg, paste(ssp, "1p5deg", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp1p9")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil" + cfg$gms$s58_rewetting_exo <- 0 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.5 + cfg$gms$s58_annual_rewetting_limit <- 0.02 + cfg$gms$s58_intact_prot_exo <- 0 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "1p5deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 15% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "1p5deg", "NRL15", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp1p9")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.15 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "1p5deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 25% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "1p5deg", "NRL25", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp1p9")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.25 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "1p5deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 50% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "1p5deg", "NRL50", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp1p9")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.5 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "1p5deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 100% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "1p5deg", "NRL100", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp1p9")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg650") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 1 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "1p5deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + } else { + # PkBudg1000 + cfg$title <- .title(cfg, paste(ssp, "2deg", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil" + cfg$gms$s58_rewetting_exo <- 0 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.5 + cfg$gms$s58_annual_rewetting_limit <- 0.02 + cfg$gms$s58_intact_prot_exo <- 0 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "2deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 15% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "2deg", "NRL15", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.15 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "2deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 25% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "2deg", "NRL25", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.25 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "2deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 50% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "2deg", "NRL50", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 0.5 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "2deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + ## Exo rewet scenarios + # 100% of currently drained peatland rewetted by 2050 + cfg$title <- .title(cfg, paste(ssp, "2deg", "NRL100", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2025" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-",ssp,"-PkBudg1000") + cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" + cfg$gms$s58_rewetting_exo <- 1 + cfg$gms$s58_rewet_exo_start_value <- 0 + cfg$gms$s58_rewet_exo_target_value <- 1 + cfg$gms$s58_annual_rewetting_limit <- 1 + cfg$gms$s58_intact_prot_exo <- 1 + download_and_update(cfg) + write.magpie(magpie4::tau(file.path("output",.title(cfg, paste(ssp, "2deg", "noPeatland", sep = "-")),"fulldata.gdx"), type = "both"),"modules/13_tc/input/f13_tau_scenario.csv") + cfg$gms$tc <- "exo" + start_run(cfg, codeCheck = FALSE) + + } +} diff --git a/scripts/start/projects/project_agmip.R b/scripts/start/projects/project_agmip.R new file mode 100644 index 0000000000..95dd01fe2e --- /dev/null +++ b/scripts/start/projects/project_agmip.R @@ -0,0 +1,188 @@ +# | (C) 2008-2025 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: AgMIP GlobEcon simulations 2020 +# ---------------------------------------------------------- + + +###################################### +#### 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:" + +cfg$output <- c("rds_report","projects/agmip_report","validation","extra/disaggregation") + + + +################################################################# +# 1 Baseline SSP1-3 simulations "_NoMt_NoCC" # +################################################################# + + +### SSPs w/o mitigation ################ +cfg$title <- "SSP1_NoMt_NoCC" +cfg <- gms::setScenario(cfg,c("SSP1","NPI")) +start_run(cfg,codeCheck=FALSE) + +cfg$title <- "SSP2_NoMt_NoCC" +cfg <- gms::setScenario(cfg,c("SSP2","NPI")) +start_run(cfg,codeCheck=FALSE) + +cfg$title <- "SSP3_NoMt_NoCC" +cfg <- gms::setScenario(cfg,c("SSP3","NPI")) +start_run(cfg,codeCheck=FALSE) + + + +#reset: +cfg <- gms::setScenario(cfg,c("SSP2","NPI")) + + + + +################################################################# +# 2 AgMIP diet scenarios based on SSP2 "SSP2_NoMt_NoCC_" # +################################################################# + + +################################################################# +# 2A EAT Lancet scenarios "FlexA_": + +### settings: +cfg <- setScenario(cfg,c("SSP2","NPI")) +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" + + + +cfg$title <- "SSP2_NoMt_NoCC_FlexA_WLD" +cfg$gms$scen_countries15 <- all_iso_countries +start_run(cfg,codeCheck=FALSE) + + +cfg$title <- "SSP2_NoMt_NoCC_FlexA_USA" +#region: USA +cfg$gms$scen_countries15 <- "USA" +start_run(cfg,codeCheck=FALSE) + + +cfg$title <- "SSP2_NoMt_NoCC_FlexA_LAM" +#region: LAM +cfg$gms$scen_countries15 <- "ABW,AIA,ARG,ATA,ATG,BES,BHS,BLM,BLZ,BMU, + BOL,BRA,BRB,BVT,CHL,COL,CRI,CUB,CUW,CYM, + DMA,DOM,ECU,FLK,GLP,GRD,GTM,GUF,GUY,HND, + HTI,JAM,KNA,LCA,MAF,MEX,MSR,MTQ,NIC,PAN, + PER,PRI,PRY,SGS,SLV,SUR,SXM,TCA,TTO,URY, + VCT,VEN,VGB,VIR" +start_run(cfg,codeCheck=FALSE) + + +cfg$title <- "SSP2_NoMt_NoCC_FlexA_EUR" +#region: EUR +cfg$gms$scen_countries15 <- "ALA,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST, + FIN,FRA,FRO,GBR,GGY,GIB,GRC,HRV,HUN,IMN, + IRL,ITA,JEY,LTU,LUX,LVA,MLT,NLD,POL,PRT, + ROU,SVK,SVN,SWE" +start_run(cfg,codeCheck=FALSE) + + +cfg$title <- "SSP2_NoMt_NoCC_FlexA_CHN" +#region: CHA +cfg$gms$scen_countries15 <- "CHN,HKG,MAC,TWN" +start_run(cfg,codeCheck=FALSE) + + +cfg$title <- "SSP2_NoMt_NoCC_FlexA_DEV" +#region: CAZ, EUR, NEU, USA +cfg$gms$scen_countries15 <- "AUS,CAN,HMD,NZL,SPM, + ALA,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST, + FIN,FRA,FRO,GBR,GGY,GIB,GRC,HRV,HUN,IMN, + IRL,ITA,JEY,LTU,LUX,LVA,MLT,NLD,POL,PRT, + ROU,SVK,SVN,SWE, + ALB,AND,BIH,CHE,GRL,ISL,LIE,MCO,MKD,MNE, + NOR,SJM,SMR,SRB,TUR,VAT, + USA" +start_run(cfg,codeCheck=FALSE) + + + +#reset: +cfg$gms$s15_elastic_demand <- 1 +cfg$gms$s15_exo_diet <- 0 +cfg$gms$scen_countries15 <- all_iso_countries +cfg <- setScenario(cfg,c("SSP2","NPI")) + + + + +################################################################# +# 2B Livestock diet scenarios "HalfRDoM_DEV" and "HalfRD_DEV": + +### settings: + + +cfg$title <- "SSP2_NoMt_NoCC_HalfRDoM_DEV" +cfg <- setScenario(cfg,c("SSP2","NPI")) +cfg$gms$s15_livestock_substitution <- 0.5 +cfg$gms$s15_food_substitution_start <- 2020 +cfg$gms$s15_food_substitution_target <- 2050 +cfg$gms$s15_food_subst_functional_form <- 1 + +#region: CAZ, EUR, NEU, USA +cfg$gms$scen_countries15 <- "AUS,CAN,HMD,NZL,SPM, + ALA,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST, + FIN,FRA,FRO,GBR,GGY,GIB,GRC,HRV,HUN,IMN, + IRL,ITA,JEY,LTU,LUX,LVA,MLT,NLD,POL,PRT, + ROU,SVK,SVN,SWE, + ALB,AND,BIH,CHE,GRL,ISL,LIE,MCO,MKD,MNE, + NOR,SJM,SMR,SRB,TUR,VAT, + USA" +start_run(cfg,codeCheck=FALSE) +#reset: +cfg$gms$s15_livestock_substitution <- 0 + + +cfg$title <- "SSP2_NoMt_NoCC_HalfRD_DEV" +cfg <- setScenario(cfg,c("SSP2","NPI")) +cfg$gms$s15_rumdairy_substitution <- 0.5 +cfg$gms$s15_food_substitution_start <- 2020 +cfg$gms$s15_food_substitution_target <- 2050 +cfg$gms$s15_food_subst_functional_form <- 1 +#region: CAZ, EUR, NEU, USA +cfg$gms$scen_countries15 <- "AUS,CAN,HMD,NZL,SPM, + ALA,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST, + FIN,FRA,FRO,GBR,GGY,GIB,GRC,HRV,HUN,IMN, + IRL,ITA,JEY,LTU,LUX,LVA,MLT,NLD,POL,PRT, + ROU,SVK,SVN,SWE, + ALB,AND,BIH,CHE,GRL,ISL,LIE,MCO,MKD,MNE, + NOR,SJM,SMR,SRB,TUR,VAT, + USA" +start_run(cfg,codeCheck=FALSE) +#reset: +cfg$gms$s15_livestock_substitution <- 0 + + + +#reset: +cfg$gms$scen_countries15 <- all_iso_countries +cfg <- setScenario(cfg,c("SSP2","NPI")) diff --git a/scripts/start/projects/project_coacch.R b/scripts/start/projects/project_coacch.R new file mode 100644 index 0000000000..6d3c1ec464 --- /dev/null +++ b/scripts/start/projects/project_coacch.R @@ -0,0 +1,185 @@ +# | (C) 2008-2025 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: COACCH simulations (climate-impacts, Europe focus) +# ---------------------------------------------------------- + +library(gms) +source("scripts/start_functions.R") +source("scripts/performance_test.R") +source("config/default.cfg") + +#set defaults +codeCheck <- FALSE + +#isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev34_c200_690d3718e151be1b450b394c1064b1c5.tgz +#rev4.14_690d3718e151be1b450b394c1064b1c5_magpie.tgz +#rev4.14_690d3718e151be1b450b394c1064b1c5_validation.tgz +#calibration_H12_c200_12Sep18.tgz + +#isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev34_c200_690d3718e151be1b450b394c1064b1c5.tgz +#rev4.18_690d3718e151be1b450b394c1064b1c5_magpie.tgz +#rev4.18_690d3718e151be1b450b394c1064b1c5_validation.tgz +#calibration_H12_c200_12Sep18.tgz +#additional_data_rev3.66.tgz + + +buildInputVector <- function(regionmapping = "H12", + project_name = "isimip_rcp", + climatescen_name= "rcp2p6", + co2 = "co2", + climate_model = "IPSL_CM5A_LR", + resolution = "c400", + archive_rev = "38", + madrat_rev = "4.18", + validation_rev = "4.18", + calibration = "calibration_coacch_08Oct19.tgz", + additional_data = "additional_data_rev3.68.tgz") { + mappings <- c(H11="8a828c6ed5004e77d1ba2025e8ea2261", + H12="690d3718e151be1b450b394c1064b1c5", + coacch="c2a48c5eae535d4b8fe9c953d9986f1b", + mag="c30c1c580039c2b300d86cc46ff4036a", + agmip="c77f075908c3bc29bdbe1976165eccaf", + sim4nexus="25dd7264e8e145385b3bd0b89ec5f3fc", + inms="44f1e181a3da765729f2f1bfc926425a", + capri="e7e72fddc44cc3d546af7b038c651f51") + archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") + archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") + madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie", ".tgz") + validation <- paste0("rev", validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") + return(c(archive,madrat,validation,calibration,additional_data)) +} + +### COACCH runs ### +#general settings +cfg$gms$c_timesteps <- "coup2100" +cfg$input <- buildInputVector() +cfg$output <- c(cfg$output,"sustag_report") +cfg$recalibrate <- FALSE + +# SSP control runs############################################### + +# SSP2 +general_settings<-function(title) { + source("config/default.cfg") + cfg$gms$c_timesteps <- "coup2100" + cfg$input <- buildInputVector() + cfg$output <- c(cfg$output,"sustag_report") + cfg$recalibrate <- FALSE + cfg<-gms::setScenario(cfg,"cc") + cfg$gms$c56_emis_policy <- "all" + cfg$gms$forestry <- "affore_vegc_dec16" + cfg$gms$maccs <- "on_sep16" + cfg$title <- paste0("v1_",title) + return(cfg) +} + + +# SSP2 +cfg<-general_settings(title="SSP2_nocc_newregion") +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"nocc") +cfg$input <- buildInputVector(regionmapping = "coacch") +cfg$recalibrate=TRUE +start_run(cfg=cfg,codeCheck=codeCheck) +calib<-magpie4::submitCalibration(name = "calibration_coacch") +cfg$recalibrate <- "ifneeded" + +#COACCH standard runs############################################# + +#SSP2 family + +# SSP2 * RCP2.6 * Mit26 * 3 climate models (HADGEM, IPSL, GFDL) (3) + + + +start_the_run<-function(ssp,mit,rcp,gcm,co2,cc){ + # select alias names for reporting + if(gcm=="IPSL_CM5A_LR"){gcm_alias="IPSL-CM5A-LR"} + if(gcm=="HadGEM2_ES"){gcm_alias="HadGEM2-ES"} + if(gcm=="GFDL_ESM2M"){gcm_alias="GFDL-ESM2M"} + if(gcm=="NorESM1_M"){gcm_alias="NNorESM1-M"} + if(rcp=="NoCC"){gcm_alias="NoCC"} + if(mit=="26"){mit_alias="2p6"} + if(mit=="45"){mit_alias="4p5"} + if(mit=="Ref"){mit_alias="NoMit"} + + # create runname + if(co2=="co2") { + title=paste(ssp,gcm_alias,substring(rcp,4),mit_alias,sep="_") + } else { + title=paste(ssp,gcm_alias,substring("rcp2p6",4),mit_alias,"NoCO2",sep="_") + } + cat(paste(title)) + + + cfg<-general_settings(title=title) + cfg<-gms::setScenario(cfg,ssp) + cfg$input <- buildInputVector(climatescen_name=rcp,climate_model = gcm, regionmapping = "coacch",calibration=calib) + mitigation=paste0("SSPDB-",ssp,"-",mit,"-",model) + cfg$gms$c56_pollutant_prices <- mitigation + cfg$gms$c60_2ndgen_biodem <- mitigation + if(cc==FALSE){ + cfg<-gms::setScenario(cfg,"nocc") + } else { + cfg<-gms::setScenario(cfg,"cc") + } + start_run(cfg=cfg,codeCheck=codeCheck) +} + +for (ssp in c("SSP1","SSP2","SSP3","SSP4","SSP5")){ + if(ssp=="SSP1"){ + model="IMAGE" + mitopt = c("Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","NoCC") + gcmopt = c("HadGEM2_ES") + } + if(ssp=="SSP2"){ + model="MESSAGE-GLOBIOM" + mitopt = c("26","45","Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","NoCC") + gcmopt = c("IPSL_CM5A_LR","HadGEM2_ES","GFDL_ESM2M","NorESM1_M") + } + if(ssp=="SSP3"){ + model="AIM-CGE" + mitopt = c("Ref") + rcpopt = c("rcp4p5","rcp6p0","NoCC") + gcmopt = c("HadGEM2_ES") + } + if(ssp=="SSP4"){ + model="GCAM4" + mitopt = c("Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","NoCC") + gcmopt = c("HadGEM2_ES") + } + if(ssp=="SSP5"){ + model="REMIND-MAGPIE" + mitopt = c("Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","rcp8p5","NoCC") + gcmopt = c("HadGEM2_ES") + } + for(mit in mitopt){ + for (rcp in rcpopt) { + co2="co2" + if(rcp=="NoCC"){ + gcm = c("HadGEM2_ES") + rcp= c("rcp4p5") + start_the_run(ssp,mit,rcp,gcm,co2,cc=FALSE) + } else { + for(gcm in gcmopt){ + start_the_run(ssp,mit,rcp,gcm,co2,cc=TRUE) + } + if (rcp == "rcp8p5"){ + co2="noco2" + start_the_run(ssp,mit,rcp,gcm,co2,cc=TRUE) + } + } + } + } +} diff --git a/scripts/start/projects/project_coacch_lpjml5.R b/scripts/start/projects/project_coacch_lpjml5.R new file mode 100644 index 0000000000..a676200bb9 --- /dev/null +++ b/scripts/start/projects/project_coacch_lpjml5.R @@ -0,0 +1,189 @@ +# | (C) 2008-2025 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: COACCH simulations (climate-impacts, Europe-focus) using LPJmL 5 inputs +# ---------------------------------------------------------- + +library(gms) +source("scripts/start_functions.R") +source("scripts/performance_test.R") +source("config/default.cfg") + +#set defaults +codeCheck <- FALSE + +#isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev34_c200_690d3718e151be1b450b394c1064b1c5.tgz +#rev4.14_690d3718e151be1b450b394c1064b1c5_magpie.tgz +#rev4.14_690d3718e151be1b450b394c1064b1c5_validation.tgz +#calibration_H12_c200_12Sep18.tgz + +#isimip_rcp-IPSL_CM5A_LR-rcp2p6-co2_rev34_c200_690d3718e151be1b450b394c1064b1c5.tgz +#rev4.18_690d3718e151be1b450b394c1064b1c5_magpie.tgz +#rev4.18_690d3718e151be1b450b394c1064b1c5_validation.tgz +#calibration_H12_c200_12Sep18.tgz +#additional_data_rev3.66.tgz + + +buildInputVector <- function(regionmapping = "H12", + project_name = "LPJmL5", + climatescen_name= "rcp2p6", + co2 = "co2", + climate_model = "IPSL_CM5A_LR", + resolution = "c400", + archive_rev = "40.1", + madrat_rev = "4.18", + validation_rev = "4.18", + calibration = "calibration_coacch_08Oct19.tgz", + additional_data = "additional_data_rev3.68.tgz") { + mappings <- c(H11="8a828c6ed5004e77d1ba2025e8ea2261", + H12="690d3718e151be1b450b394c1064b1c5", + coacch="c2a48c5eae535d4b8fe9c953d9986f1b", + mag="c30c1c580039c2b300d86cc46ff4036a", + agmip="c77f075908c3bc29bdbe1976165eccaf", + sim4nexus="25dd7264e8e145385b3bd0b89ec5f3fc", + inms="44f1e181a3da765729f2f1bfc926425a", + capri="e7e72fddc44cc3d546af7b038c651f51") + archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") + archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") + madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie", ".tgz") + validation <- paste0("rev", validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") + return(c(archive,madrat,validation,calibration,additional_data)) +} + +### COACCH runs ### +#general settings +cfg$gms$c_timesteps <- "coup2100" +cfg$input <- buildInputVector() +cfg$output <- c(cfg$output,"sustag_report") +cfg$recalibrate <- FALSE + +# SSP control runs############################################### + +# SSP2 +general_settings<-function(title) { + source("config/default.cfg") + cfg$gms$c_timesteps <- "coup2100" + cfg$input <- buildInputVector() + cfg$output <- c(cfg$output,"sustag_report") + cfg$recalibrate <- FALSE + cfg<-gms::setScenario(cfg,"cc") + cfg$gms$c56_emis_policy <- "all" + cfg$gms$forestry <- "affore_vegc_dec16" + cfg$gms$maccs <- "on_sep16" + cfg$title <- paste0("v1_",title) + return(cfg) +} + + +# SSP2 +cfg<-general_settings(title="SSP2_nocc_newregion") +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"nocc") +cfg$input <- buildInputVector(regionmapping = "coacch") +cfg$recalibrate=TRUE +start_run(cfg=cfg,codeCheck=codeCheck) +calib<-magpie4::submitCalibration(name = "calibration_coacch") +cfg$recalibrate <- "ifneeded" + +#COACCH standard runs############################################# + +#SSP2 family + +# SSP2 * RCP2.6 * Mit26 * 3 climate models (HADGEM, IPSL, GFDL) (3) + + + +start_the_run<-function(ssp,mit,rcp,gcm,co2,cc){ + # select alias names for reporting + if(gcm=="IPSL_CM5A_LR"){gcm_alias="IPSL-CM5A-LR"} + if(gcm=="HadGEM2_ES"){gcm_alias="HadGEM2-ES"} + if(gcm=="GFDL_ESM2G"){gcm_alias="GFDL-ESM2G"} + if(gcm=="NorESM1_M"){gcm_alias="NNorESM1-M"} + rcp_alias=substring(rcp,4) + if(cc==FALSE){ + gcm_alias="NoCC" + rcp_alias="NoCC" + } + if(mit=="26"){mit_alias="2p6"} + if(mit=="45"){mit_alias="4p5"} + if(mit=="Ref"){mit_alias="NoMit"} + + # create runname + if(co2=="co2") { + title=paste(ssp,gcm_alias,rcp_alias,mit_alias,sep="_") + } else { + title=paste(ssp,gcm_alias,rcp_alias,mit_alias,"NoCO2",sep="_") + } + cat(paste(title)) + + + cfg<-general_settings(title=title) + cfg<-gms::setScenario(cfg,ssp) + cfg$input <- buildInputVector(climatescen_name=rcp,climate_model = gcm, regionmapping = "coacch",co2=co2,calibration=calib) + mitigation=paste0("SSPDB-",ssp,"-",mit,"-",model) + cfg$gms$c56_pollutant_prices <- mitigation + cfg$gms$c60_2ndgen_biodem <- mitigation + if(cc==FALSE){ + cfg<-gms::setScenario(cfg,"nocc") + } else { + cfg<-gms::setScenario(cfg,"cc") + } + start_run(cfg=cfg,codeCheck=codeCheck) +} + +for (ssp in c("SSP1","SSP2","SSP3","SSP4","SSP5")){ + if(ssp=="SSP1"){ + model="IMAGE" + mitopt = c("Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","NoCC") + gcmopt = c("HadGEM2_ES") + } + if(ssp=="SSP2"){ + model="MESSAGE-GLOBIOM" + mitopt = c("26","45","Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","NoCC") + gcmopt = c("IPSL_CM5A_LR","HadGEM2_ES","GFDL_ESM2G","NorESM1_M") + } + if(ssp=="SSP3"){ + model="AIM-CGE" + mitopt = c("60") + rcpopt = c("rcp4p5","rcp6p0","NoCC") + gcmopt = c("HadGEM2_ES") + } + if(ssp=="SSP4"){ + model="GCAM4" + mitopt = c("Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","NoCC") + gcmopt = c("HadGEM2_ES") + } + if(ssp=="SSP5"){ + model="REMIND-MAGPIE" + mitopt = c("Ref") + rcpopt = c("rcp2p6","rcp4p5","rcp6p0","rcp8p5","NoCC") + gcmopt = c("HadGEM2_ES") + } + for(mit in mitopt){ + for (rcp in rcpopt) { + co2="co2" + if(rcp=="NoCC"){ + gcm = c("HadGEM2_ES") + rcp= c("rcp4p5") + start_the_run(ssp,mit,rcp,gcm,co2,cc=FALSE) + } else { + for(gcm in gcmopt){ + start_the_run(ssp,mit,rcp,gcm,co2,cc=TRUE) + } + if (rcp == "rcp8p5"){ + co2="noco2" + start_the_run(ssp,mit,rcp,gcm,co2,cc=TRUE) + } + } + } + } +} diff --git a/scripts/start/projects/project_inms2.R b/scripts/start/projects/project_inms2.R new file mode 100644 index 0000000000..f7acabecf2 --- /dev/null +++ b/scripts/start/projects/project_inms2.R @@ -0,0 +1,266 @@ +# | (C) 2008-2025 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: INMS simulations (nitrogen) +# ---------------------------------------------------------- + +library(gms) +source("scripts/start_functions.R") +source("scripts/performance_test.R") +source("config/default.cfg") + +### Set defaults +codeCheck <- FALSE + +buildInputVector <- function(regionmapping = "agmip", + project_name = "isimip_rcp", + climatescen_name= "rcp2p6", + co2 = "co2", + climate_model = "IPSL_CM5A_LR", + resolution = "c200", + archive_rev = "52", + madrat_rev = "4.57bb4", + validation_rev = "4.57bb4", + calibration = "calibration_INMS_v6_16Feb21.tgz", + additional_data = "additional_data_rev3.95.tgz") { + mappings <- c(h11="8a828c6ed5004e77d1ba2025e8ea2261", + h12="690d3718e151be1b450b394c1064b1c5", + mag="c30c1c580039c2b300d86cc46ff4036a", + inms="1ffb3a6fd3ac74779d7fb03a215fbec6", + inms2="ef2ae7cd6110d5d142a9f8bd7d5a68f2", + agmip="c77f075908c3bc29bdbe1976165eccaf") + archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") + archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") + madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie.tgz") + validation <- paste0("rev",validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") + return(c(archive,madrat,validation,calibration,additional_data)) +} + + + +### General settings ### +general_settings<-function(title) { + source("config/default.cfg") + cfg<-setScenario(cfg,"cc") + cfg$force_download <- TRUE + cfg$gms$c_timesteps <- 12 + cfg$gms$som <- "cellpool_jan23" + cfg$gms$factor_costs <- "sticky_feb18" + cfg$gms$s15_elastic_demand <- 0 + cfg$gms$nitrogen <- "rescaled_jan21" + cfg$gms$som <- "static_jan19" + cfg$title <- paste0(title,"_v10") + cfg$gms$maccs <- "on_sep16" + cfg$gms$c56_emis_policy <- "maccs_excl_cropland_n2o" + #cfg$calib_cropland <- FALSE + cfg$recalibrate <- FALSE + return(cfg) +} + +############################################################################### +########## Calibration run ########## +cfg<-general_settings(title="SSP2_RCP4p5_Calib") +cfg<-setScenario(cfg,"SSP2") +cfg<-setScenario(cfg,"cc") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration="calibration_inms_c200_08Jul2020.tgz") +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$force_download <- TRUE +cfg$recalibrate <- FALSE +start_run(cfg=cfg,codeCheck=codeCheck) +calib<-magpie4::submitCalibration(name = "INMS_v6") + +calib<- "calibration_INMS_v6_16Feb21.tgz" + + +############################################################################### +########## Scenario runs ########## +### Business-as-usual +cfg<-general_settings(title="SSP5_RCP8p5_PolicyLow") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp8p5",regionmapping="inms",calibration=calib) +# Development: fossil-fuel driven (SSP5) +# Land Use: medium regulation, high productivity +# Diet: meat and dairy-rich +cfg<-setScenario(cfg,"SSP5") +# Climate: no mitigation (RCP8.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP5-Ref-REMIND-MAGPIE" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP5-Ref-REMIND-MAGPIE" +# N policy: low ambition +cfg$gms$c50_scen_neff <- "constant" +cfg$gms$c50_scen_neff_pasture <- "constant" +cfg$gms$c70_feed_scen <- "ssp2" ##### or ssp5? or not necessary to specify when scenario config selected? +cfg$gms$c55_scen_conf <- "ssp2" ##### or ssp5? or not necessary to specify when scenario config selected? +start_run(cfg=cfg,codeCheck=codeCheck) + +### Low N regulation +cfg<-general_settings(cfg$title <- "SSP2_RCP4p5_PolicyLow") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: historical trends (SSP2) +# Land Use: medium regulation, medium productivity +# Diet: medium meat and dairy +cfg<-setScenario(cfg,"SSP2") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +# N policy: low ambition +cfg$gms$c50_scen_neff <- "constant" +cfg$gms$c50_scen_neff_pasture <- "constant" +cfg$gms$c70_feed_scen <- "ssp2" +cfg$gms$c55_scen_conf <- "ssp2" +start_run(cfg=cfg,codeCheck=codeCheck) + +### Medium N regulation +cfg<-general_settings(cfg$title <- "SSP2_RCP4p5_PolicyMed") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: historical trends (SSP2) +# Land Use: medium regulation, medium productivity +# Diet: medium meat and dairy +cfg<-setScenario(cfg,"SSP2") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +# N policy: moderate ambition +cfg$gms$c50_scen_neff <- "neff_ZhangBy2050_start2010" +cfg$gms$c50_scen_neff_pasture <- "constant" +cfg$gms$c70_feed_scen <- "ssp1" +cfg$gms$c55_scen_conf <- "ssp1" +start_run(cfg=cfg,codeCheck=codeCheck) + +### High N regulation +cfg<-general_settings(cfg$title <- "SSP2_RCP4p5_PolicyHigh") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: historical trends (SSP2) +# Land Use: medium regulation, medium productivity +# Diet: medium meat and dairy +cfg<-setScenario(cfg,"SSP2") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +# N policy: high ambition +cfg$gms$c50_scen_neff <- "neff_ZhangBy2030_start2010" +cfg$gms$c50_scen_neff_pasture <- "constant" +cfg$gms$c70_feed_scen <- "ssp1" +cfg$gms$c55_scen_conf <- "GoodPractice" +start_run(cfg=cfg,codeCheck=codeCheck) + +### Best-case +cfg<-general_settings(cfg$title <- "SSP1_RCP4p5_PolicyHigh") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: sustainable development (SSP1) +# Land Use: strong regulation, high productivity (SSP1) +# Diet: low meat and dairy +cfg<-setScenario(cfg,"SSP1") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-26-IMAGE" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-26-IMAGE" +# N policy: high ambition +cfg$gms$c50_scen_neff <- "neff_ZhangBy2030_start2010" +cfg$gms$c50_scen_neff_pasture <- "constant" +cfg$gms$c70_feed_scen <- "ssp1" +cfg$gms$c55_scen_conf <- "GoodPractice" +start_run(cfg=cfg,codeCheck=codeCheck) + +### Best-case+ +cfg<-general_settings(cfg$title <- "SSP1_RCP4p5_PolicyHighDiet") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: sustainable development (SSP1) +# Land Use: strong regulation, high productivity (SSP1) +cfg<-setScenario(cfg,"SSP1") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-26-IMAGE" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-26-IMAGE" +# Diet: ambitious diet shift and food loss/waste reductions (EATLancet) +cfg$gms$c15_food_scenario <- "SSP1" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +# N policy: high ambition +cfg$gms$c50_scen_neff <- "neff_ZhangBy2030_start2010" +cfg$gms$c50_scen_neff_pasture <- "constant" +cfg$gms$c70_feed_scen <- "ssp1" +cfg$gms$c55_scen_conf <- "GoodPractice" +start_run(cfg=cfg,codeCheck=codeCheck) + +### Bioenergy +cfg<-general_settings(cfg$title <- "SSP1_RCP2p6_PolicyHigh") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6",regionmapping="inms",calibration=calib) +# Development: sustainable development (SSP1) +# Land Use: strong regulation, high productivity (SSP1) +# Diet: low meat and dairy +cfg<-setScenario(cfg,"SSP1") +# Climate: high mitigation (RCP2.6) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP1-26-IMAGE" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP1-26-IMAGE" +# N policy: high ambition +cfg$gms$c50_scen_neff <- "neff_ZhangBy2030_start2010" +cfg$gms$c50_scen_neff_pasture <- "constant" +cfg$gms$c70_feed_scen <- "ssp1" +cfg$gms$c55_scen_conf <- "GoodPractice" +start_run(cfg=cfg,codeCheck=codeCheck) + +############################################################################### +########## Sensitivity runs ########## +### Sensitivity 1: Only NUE (high ambition) +cfg<-general_settings(cfg$title <- "SSP2_RCP4p5_SensitivityNUEhigh") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: historical trends (SSP2) +# Land Use: medium regulation, medium productivity (SSP2) +# Diet: medium meat and dairy +cfg<-setScenario(cfg,"SSP2") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +# N policy: Only NUE +cfg$gms$c50_scen_neff <- "neff_ZhangBy2030_start2010" +cfg$gms$c50_scen_neff_pasture <- "constant" +start_run(cfg=cfg,codeCheck=codeCheck) + +### Sensitivity 2: Only NUE (moderate ambition) +cfg<-general_settings(cfg$title <- "SSP2_RCP4p5_SensitivityNUEhigh") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: historical trends (SSP2) +# Land Use: medium regulation, medium productivity (SSP2) +# Diet: medium meat and dairy +cfg<-setScenario(cfg,"SSP2") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +# N policy: Only NUE +cfg$gms$c50_scen_neff <- "neff_ZhangBy2050_start2010" +cfg$gms$c50_scen_neff_pasture <- "constant" +start_run(cfg=cfg,codeCheck=codeCheck) + +### Sensitivity 2: Only AWS (high ambition) +cfg<-general_settings(cfg$title <- "SSP2_RCP4p5_SensitivityAWShigh") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: historical trends (SSP2) +# Land Use: medium regulation, medium productivity (SSP2) +cfg<-setScenario(cfg,"SSP2") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +# N policy: Best +cfg$gms$c70_feed_scen <- "ssp1" +cfg$gms$c55_scen_conf <- "GoodPractice" +start_run(cfg=cfg,codeCheck=codeCheck) + +### Sensitivity 3: Only AWS (moderate ambition) +cfg<-general_settings(cfg$title <- "SSP2_RCP4p5_SensitivityAWSmoderate") ### +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5",regionmapping="inms",calibration=calib) +# Development: historical trends (SSP2) +# Land Use: medium regulation, medium productivity (SSP2) +cfg<-setScenario(cfg,"SSP2") +# Climate: moderate mitigation (RCP4.5) +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-45-MESSAGE-GLOBIOM" +# N policy: Only AWS +cfg$gms$c70_feed_scen <- "ssp1" +cfg$gms$c55_scen_conf <- "ssp1" +start_run(cfg=cfg,codeCheck=codeCheck) diff --git a/scripts/start/projects/project_sim4nexus.R b/scripts/start/projects/project_sim4nexus.R new file mode 100644 index 0000000000..b04a05bb7e --- /dev/null +++ b/scripts/start/projects/project_sim4nexus.R @@ -0,0 +1,451 @@ +# | (C) 2008-2025 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: SIM4NEXUS simulations (water-land-climate-energy) +# ---------------------------------------------------------- + +library(gms) +source("scripts/start_functions.R") +source("scripts/performance_test.R") + +# Set defaults +codeCheck <- FALSE + +buildInputVector <- function(regionmapping = "H12", + project_name = "isimip_rcp", + climatescen_name= "rcp2p6", + co2 = "co2", + climate_model = "IPSL_CM5A_LR", + resolution = "c200", + archive_rev = "42", + madrat_rev = "4.42", + validation_rev = "4.42", + calibration = "calibration_sim4nexus_may2019.tgz", + additional_data = "additional_data_rev3.77.tgz") { + mappings <- c(H11="8a828c6ed5004e77d1ba2025e8ea2261", + H12="690d3718e151be1b450b394c1064b1c5", + mag="c30c1c580039c2b300d86cc46ff4036a", + agmip="c77f075908c3bc29bdbe1976165eccaf", + sim4nexus="25dd7264e8e145385b3bd0b89ec5f3fc", + inms="44f1e181a3da765729f2f1bfc926425a", + capri="e7e72fddc44cc3d546af7b038c651f51", + coacch="c2a48c5eae535d4b8fe9c953d9986f1b") + archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") + archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") + madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie", ".tgz") + validation <- paste0("rev", validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") + return(c(archive,madrat,validation,calibration,additional_data)) +} + +### SIM4NEXUS runs ### +#general settings +general_settings<-function(title) { + source("config/default.cfg") + cfg$gms$c_timesteps <- "5year" + cfg$input <- buildInputVector() + cfg$output <- c(cfg$output,"sustag_report") + cfg$recalibrate <- FALSE + cfg<-gms::setScenario(cfg,"cc") + cfg$gms$c56_emis_policy <- "all" + cfg$gms$som <- "cellpool_jan23" + cfg$gms$c59_som_scenario <- "cc" + cfg$gms$forestry <- "dynamic_oct19" + cfg$gms$maccs <- "on_sep16" + cfg$title <- paste0("sim4nexus_v2_",title) + # include costs per-ton + return(cfg) +} + +# Switches for EU28-only runs: +EU28 <- "AUT,BEL,BGR,HRV,CYP,CZE,DNK,EST,FIN,FRA,DEU,GRC,HUN,IRL,ITA,LVA,LTU,LUX,MLT,NLD,POL,PRT,ROU,SVK,SVN,ESP,SWE,GBR" + +# SSP control runs ############################################### +# SSP2 +cfg<-general_settings(title="SSP2_NoCC_NoCC_NoMit_base") +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"nocc") +cfg$input <- buildInputVector(regionmapping = "coacch",calibration=NULL) +cfg$gms$c59_som_scenario <- "nocc" +cfg$recalibrate <- TRUE +start_run(cfg=cfg,codeCheck=codeCheck) +calib<-magpie4::submitCalibration(name = "calibration_sim4nexus_may2019") +cfg$recalibrate <- "ifneeded" + +# Three baseline scenarios ############################################### +# Three baselines: + # baseline (SSP2_IPSL-CM5A-LR_6p0_NoMit_base), + # GLO_2degree (SSP2_IPSL-CM5A-LR_2p6_Mit2p6_base), + # EUR_2degree (SSP2_IPSL-CM5A-LR_6p0_onlyEUR2p6_base) + +# Baseline +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_base") +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) +start_run(cfg=cfg,codeCheck=codeCheck) + +# Global 2 degree scenario +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_2p6_Mit2p6_base") +# CC mitigation (2degree scenario): cost-optimal mitigation pathway based on endogenous trade and fertilization patterns, MAC-curves from Lucas et al. (2007) for non-co2 ghg emissions, and endogenous mitigation for CO2 emissions from landuse change and afforestation + # RCP 2.6 + # CO2 emissions based on CO2 price + # non-CO2 ghg emissions based on CO2 eq price + # carbon price according to SSP2 RCP2.6 scenario + # bioenergy demand from SSP2 RCP 2.6 scenario + # afforestation/avoided deforestation: all based on CO2 price and NDC + # 65% NUE croplands +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg<-gms::setScenario(cfg,"NDC") +cfg$input <- buildInputVector(climatescen_name="rcp2p6",regionmapping = "coacch",calibration=calib) +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c50_scen_neff <- "neff65_70_starty2010" +start_run(cfg=cfg,codeCheck=codeCheck) + +# Third "baseline/reference": GHG policy for EU28 only: +# EU: CC mitigation (2degree scenario): + # CO2 emissions based on CO2 price + # non-CO2 ghg emissions based on CO2 eq price + # carbon price according to SSP2 RCP2.6 scenario + # bioenergy demand from SSP2 RCP 2.6 scenario + # 65% NUE croplands +# RoW: baseline scenario +# RCP 6.0 +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_onlyEUR2p6_base") +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) # RCP2p6 when only EU28???? +cfg$gms$ghg_policy_countries <- EU28 +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c56_pollutant_prices_noselect <- "R2M41-SSP2-NPi" +cfg$gms$scen_countries60 <- EU28 +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem_noselect <- "R2M41-SSP2-NPi" +cfg$gms$cropneff_countries <- EU28 +cfg$gms$c50_scen_neff <- "neff65_70_starty2010" +cfg$gms$c50_scen_neff_noselect <- "neff60_60_starty2010" +start_run(cfg=cfg,codeCheck=codeCheck) + + +# Global scenario runs ############################################### +# Global water +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_water") +# Irrigation efficiency + # Irrigation expansion remains endogenous + # Irrigation efficiency increased +# Water demand: + # Environmental flow requirements are met +# Water quality: + # 70% NUE croplands + # (LATER: max. N concentration) + # (LATER: improved wastewater treatment for N) +# Fisheries: + # (LATER: Ocean catches below max sustainable yields) +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) +cfg$gms$s42_irrig_eff_scenario <- 1 +cfg$gms$s42_irrigation_efficiency <- 0.76 +cfg$gms$c42_env_flow_policy <- "on" +cfg$gms$c50_scen_neff <- "neff70_75_starty2010" +start_run(cfg=cfg,codeCheck=codeCheck) + +# Global biodiversity +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_biodiversity") +# WDPA IUCN categories I + II, protected biodiversity hotspots from Brookes et al (2006) + # Land protection + # land productivity increase (lower interest rate) + # protection of biodiversity hotspots and WDPA + # Increased fertilizer efficiency (70% NUE of croplands) + # Improved animal waste management + # (LATER: Improved wastewater treatment) + # RCP6.0 +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) +cfg$gms$s12_hist_interest_lic <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic <- "0.04" # def = 0.04 +cfg$gms$s12_interest_lic <- "0.05" # def = 0.1 +cfg$gms$s12_interest_hic <- "0.02" # def = 0.04 +cfg$gms$c35_protect_scenario <- "BH" +cfg$gms$c50_scen_neff <- "neff70_75_starty2010" +cfg$gms$c55_scen_conf <- "SSP1" +start_run(cfg=cfg,codeCheck=codeCheck) + +# Global diet shift +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_diet") +# Sustainable food production + # Healthy and sufficient diet: Transformation towards a flexetarian healthy diet (similar to Lancet diet) with reduced meat consumption. Transformation pathway takes place until 2050 + # Waste: max waste of 15% + # Agricultural efficiency: Crop production reduced interest risk premium for interest rate, increasing investments in yield-increasing technological change + # Livestock production improved animal waste management systems (Bodirsky et al 2014) + # Fertilizer: 70%NUE croplands +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) +cfg$gms$c15_food_scenario <- "SSP1" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$c50_scen_neff <- "neff70_75_starty2010" +cfg$gms$s12_hist_interest_lic <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic <- "0.04" # def = 0.04 +cfg$gms$s12_interest_lic <- "0.05" # def = 0.1 +cfg$gms$s12_interest_hic <- "0.02" # def = 0.04 +cfg$gms$c55_scen_conf <- "SSP1" +start_run(cfg=cfg,codeCheck=codeCheck) + +# Combination of all global scenarios +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_combined") +# All scenarios: combination of all scenarios +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp2p6",regionmapping = "coacch",calibration=calib) +cfg$gms$s12_hist_interest_lic <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic <- "0.04" # def = 0.04 +cfg$gms$s12_interest_lic <- "0.05" # def = 0.1 +cfg$gms$s12_interest_hic <- "0.02" # def = 0.04 +cfg$gms$c15_food_scenario <- "SSP1" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$c32_aff_policy <- "ndc" +cfg$gms$c35_protect_scenario <- "BH" +cfg$gms$c42_env_flow_policy <- "on" +cfg$gms$s42_irrig_eff_scenario <- 1 +cfg$gms$s42_irrigation_efficiency <- 0.76 +cfg$gms$c50_scen_neff <- "neff75_80_starty2010" +cfg$gms$c55_scen_conf <- "SSP1" +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +start_run(cfg=cfg,codeCheck=codeCheck) + + +#SIM4NEXUS regional runs############################################# + +### Scenario runs: + +### Resource efficiency: +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_EURreseff") +# In addition to global baseline scenario assumptions (SSP2_IPSL-CM5A-LR_6p0_NoMit_base), +# resource efficiency policies and technology trends implemented in Europe. + # increased fertilizer efficiency in Europe (switch for 70% NUE of croplands in EU28) + # increased crop yields in Europe (switch lower interest rates in EU28, rest: interest rate depends on development state) +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) +# EUR specific +cfg$gms$c50_scen_neff <- "neff70_75_starty2010" +cfg$gms$cropneff_countries <- EU28 +cfg$gms$select_countries12 <- EU28 +# Interest rate coefficients for selected countries: +cfg$gms$s12_interest_lic <- "0.02" # def = 0.1 +cfg$gms$s12_interest_hic <- "0.02" # def = 0.04 +cfg$gms$s12_hist_interest_lic <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic <- "0.04" # def = 0.04 +# Interest rate coefficients for non-selected countries (default): +cfg$gms$s12_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_interest_hic_noselect <- "0.04" # def = 0.04 +cfg$gms$s12_hist_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic_noselect <- "0.04" # def = 0.04 +start_run(cfg=cfg,codeCheck=codeCheck) + +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_2p6_Mit2p6_EURreseff") +# In addition to global 2 degree scenario assumptions (GLO_2deg_ssp2_rcp26_mit26), +# resource efficiency policies and technology trends implemented in Europe. + # increased fertilizer efficiency in Europe (switch for 70% NUE of croplands in EU28) + # increased crop yields in Europe (switch lower interest rates in EU28, rest: default) +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg<-gms::setScenario(cfg,"NDC") +cfg$input <- buildInputVector(climatescen_name="rcp2p6",regionmapping = "coacch",calibration=calib) +# 2 degree global baseline +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c50_scen_neff_noselect <- "neff65_70_starty2010" +# EUR specific +cfg$gms$c50_scen_neff <- "neff70_75_starty2010" +cfg$gms$cropneff_countries <- EU28 +cfg$gms$select_countries12 <- EU28 +# Interest rate coefficients for selected countries: +cfg$gms$s12_interest_lic <- "0.02" # def = 0.1 +cfg$gms$s12_interest_hic <- "0.02" # def = 0.04 +cfg$gms$s12_hist_interest_lic <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic <- "0.04" # def = 0.04 +# Interest rate coefficients for non-selected countries (default): +cfg$gms$s12_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_interest_hic_noselect <- "0.04" # def = 0.04 +cfg$gms$s12_hist_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic_noselect <- "0.04" # def = 0.04 +start_run(cfg=cfg,codeCheck=codeCheck) + +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_onlyEUR2p6_EURreseff") +# In addition to European 2 degree scenario assumptions (EUR_2deg_ssp2_rcp26_mit26), +# resource efficiency policies and technology trends implemented in Europe. + # increased fertilizer efficiency in Europe (switch for 70% NUE of croplands in EU28) + # increased crop yields in Europe (switch lower interest rates in EU28, rest: default) +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) # RCP2p6 when only EU28???? +cfg$gms$ghg_policy_countries <- EU28 +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c56_pollutant_prices_noselect <- "R2M41-SSP2-NPi" +cfg$gms$scen_countries60 <- EU28 +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem_noselect <- "R2M41-SSP2-NPi" +cfg$gms$c50_scen_neff_noselect <- "neff60_60_starty2010" +# EUR specific +cfg$gms$c50_scen_neff <- "neff70_75_starty2010" +cfg$gms$cropneff_countries <- EU28 +cfg$gms$select_countries12 <- EU28 +# Interest rate coefficients for selected countries: +cfg$gms$s12_interest_lic <- "0.02" # def = 0.1 +cfg$gms$s12_interest_hic <- "0.02" # def = 0.04 +cfg$gms$s12_hist_interest_lic <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic <- "0.04" # def = 0.04 +# Interest rate coefficients for non-selected countries (default): +cfg$gms$s12_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_interest_hic_noselect <- "0.04" # def = 0.04 +cfg$gms$s12_hist_interest_lic_noselect <- "0.1" # def = 0.1 +cfg$gms$s12_hist_interest_hic_noselect <- "0.04" # def = 0.04 +start_run(cfg=cfg,codeCheck=codeCheck) + +### Diets: +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_EURdiet") +# In addition to global baseline scenario assumptions (SSP2_IPSL-CM5A-LR_6p0_NoMit_base), +# a shift to sustainable diets takes place in Europe. + # max food waste of 15% + # healthy and sufficient (flexitarian) diet and more sustainable food scenario in Europe + # more efficient animal waste mangement in Europe +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) +# EUR specific +cfg$gms$c15_food_scenario <- "SSP1" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$scen_countries15 <- EU28 +cfg$gms$c55_scen_conf <- "SSP1" +cfg$gms$scen_countries55 <- EU28 +start_run(cfg=cfg,codeCheck=codeCheck) + + +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_2p6_Mit2p6_EURdiet") +# In addition to global 2 degree scenario assumptions (SSP2_IPSL-CM5A-LR_2p6_Mit2p6_base), +# a shift to sustainable diets takes place in Europe. + # max food waste of 15% + # healthy and sufficient (flexitarian) diet in Europe + # both implemented via "fader switch"! +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg<-gms::setScenario(cfg,"NDC") +cfg$input <- buildInputVector(climatescen_name="rcp2p6",regionmapping = "coacch",calibration=calib) +# Global 2 degree baseline +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c50_scen_neff <- "neff65_70_starty2010" +# EUR specific +cfg$gms$c15_food_scenario <- "SSP1" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$scen_countries15 <- EU28 +cfg$gms$c55_scen_conf <- "SSP1" +cfg$gms$scen_countries55 <- EU28 +start_run(cfg=cfg,codeCheck=codeCheck) + +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_onlyEUR2p6_EURdiet") +# In addition to European 2 degree scenario assumptions (SSP2_IPSL-CM5A-LR_6p0_onlyEUR2p6_base)), +# a shift to sustainable diets takes place in Europe. + # max food waste of 15% + # healthy and sufficient (flexitarian) diet in Europe +# both implemented via "fader switch"! +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) # RCP2p6 when only EU28???? +cfg$gms$ghg_policy_countries <- EU28 +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c56_pollutant_prices_noselect <- "R2M41-SSP2-NPi" +cfg$gms$scen_countries60 <- EU28 +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem_noselect <- "R2M41-SSP2-NPi" +cfg$gms$cropneff_countries <- EU28 +cfg$gms$c50_scen_neff <- "neff65_70_starty2010" +cfg$gms$c50_scen_neff_noselect <- "neff60_60_starty2010" +# EUR specific +cfg$gms$c15_food_scenario <- "SSP1" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_waste_scen <- 1.2 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "healthy_BMI" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$scen_countries15 <- EU28 +cfg$gms$c55_scen_conf <- "SSP1" +cfg$gms$scen_countries55 <- EU28 +start_run(cfg=cfg,codeCheck=codeCheck) + +### Push for renewables: +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_NoMit_EURwater") +# In addition to global baseline scenario assumptions (SSP2_IPSL-CM5A-LR_6p0_NoMit_base), +# irrigation water withdrawals in Europe are at sustainable level. + # EFP in Europe (switch for EFRs to be met in EU28) +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) +# EUR specific +cfg$gms$c42_env_flow_policy <- "on" +cfg$gms$EFP_countries <- EU28 +start_run(cfg=cfg,codeCheck=codeCheck) + +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_2p6_Mit2p6_EURwater") +# In addition to global 2 degree scenario assumptions (SSP2_IPSL-CM5A-LR_2p6_Mit2p6_base), +# irrigation water withdrawals in Europe are at sustainable level. + # EFP in Europe (switch for EFRs to be met in EU28) +# Global baseline +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg<-gms::setScenario(cfg,"NDC") +cfg$input <- buildInputVector(climatescen_name="rcp2p6",regionmapping = "coacch",calibration=calib) +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c50_scen_neff <- "neff65_70_starty2010" +# EUR specific +cfg$gms$c42_env_flow_policy <- "on" +cfg$gms$EFP_countries <- EU28 +start_run(cfg=cfg,codeCheck=codeCheck) + +cfg<-general_settings(title="SSP2_IPSL-CM5A-LR_6p0_onlyEUR2p6_EURwater") +# In addition to European 2 degree scenario assumptions (SSP2_IPSL-CM5A-LR_6p0_onlyEUR2p6_base), +# irrigation water withdrawals in Europe are at sustainable level. + # EFP in Europe (switch for EFRs to be met in EU28) +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"cc") +cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "coacch",calibration=calib) # RCP2p6 when only EU28???? +cfg$gms$ghg_policy_countries <- EU28 +cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg1300" +cfg$gms$c56_pollutant_prices_noselect <- "R2M41-SSP2-NPi" +cfg$gms$scen_countries60 <- EU28 +cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg1300" +cfg$gms$c60_2ndgen_biodem_noselect <- "R2M41-SSP2-NPi" +cfg$gms$cropneff_countries <- EU28 +cfg$gms$c50_scen_neff <- "neff65_70_starty2010" +cfg$gms$c50_scen_neff_noselect <- "neff60_60_starty2010" +# EUR specific +cfg$gms$c42_env_flow_policy <- "on" +cfg$gms$EFP_countries <- EU28 +start_run(cfg=cfg,codeCheck=codeCheck) diff --git a/scripts/start/projects/project_sustag.R b/scripts/start/projects/project_sustag.R new file mode 100644 index 0000000000..821e624e5d --- /dev/null +++ b/scripts/start/projects/project_sustag.R @@ -0,0 +1,185 @@ +# | (C) 2008-2025 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: SUSTAg simulations (bioenergy and mitigation in Europe) +# ---------------------------------------------------------- + +library(gms) +source("scripts/start_functions.R") +source("scripts/performance_test.R") +source("config/default.cfg") + +#set defaults +codeCheck <- FALSE + +buildInputVector <- function(regionmapping = "agmip", + project_name = "isimip_rcp", + climatescen_name= "rcp2p6", + co2 = "noco2", + climate_model = "IPSL_CM5A_LR", + resolution = "c200", + archive_rev = "34", + madrat_rev = "4.14", + validation_rev = "4.14", + calibration = "calibration_agmip_c200_19Dec18.tgz", + additional_data = "additional_data_rev3.58.tgz") { + mappings <- c(H11="8a828c6ed5004e77d1ba2025e8ea2261", + H12="690d3718e151be1b450b394c1064b1c5", + mag="c30c1c580039c2b300d86cc46ff4036a", + agmip="c77f075908c3bc29bdbe1976165eccaf", + sim4nexus="270870819da5607e288b6d0e5a5e6594", + inms="69c65bb3c88e8033cf8df6b5ac5d52a9", + inms2="ef2ae7cd6110d5d142a9f8bd7d5a68f2", + capri="e7e72fddc44cc3d546af7b038c651f51") + archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") + archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") + madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie", ".tgz") + validation <- paste0("rev", validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") + return(c(archive,madrat,validation,calibration,additional_data)) +} + +### SUSTAg runs ### +#general settings +cfg$gms$c_timesteps <- 12 +cfg$input <- buildInputVector() +cfg$output <- c(cfg$output,"sustag_report") +cfg$recalibrate <- FALSE + + +# SSP control runs############################################### + +# SSP2 +cfg$title <- "SSP2" +cfg<-gms::setScenario(cfg,"SSP2") +cfg<-gms::setScenario(cfg,"nocc") +cfg$force_download <- TRUE +cfg$input <- buildInputVector(co2="co2") +#cfg$recalibrate <- TRUE +start_run(cfg=cfg,codeCheck=codeCheck) +#cfg$recalibrate <- FALSE + +# SSP1 +cfg$title <- "SSP1" +cfg<-gms::setScenario(cfg,"SSP1") +cfg<-gms::setScenario(cfg,"nocc") +cfg$input <- buildInputVector(co2="co2") +start_run(cfg=cfg,codeCheck=codeCheck) + +# SSP3 +cfg$title <- "SSP3" +cfg<-gms::setScenario(cfg,"SSP3") +cfg<-gms::setScenario(cfg,"nocc") +cfg$input <- buildInputVector(co2="co2") +start_run(cfg=cfg,codeCheck=codeCheck) + +# SSP4 +cfg$title <- "SSP4" +cfg<-gms::setScenario(cfg,"SSP4") +cfg<-gms::setScenario(cfg,"nocc") +cfg$input <- buildInputVector(co2="co2") +start_run(cfg=cfg,codeCheck=codeCheck) + +# SSP5 +cfg$title <- "SSP5" +cfg<-gms::setScenario(cfg,"SSP5") +cfg<-gms::setScenario(cfg,"nocc") +cfg$input <- buildInputVector(co2="co2") +start_run(cfg=cfg,codeCheck=codeCheck) + + + + + +#SUSTAg standard runs############################################# + +# SSP1 family +cfg$title <- "SUSTAg1" +cfg<-gms::setScenario(cfg,"SUSTAg1") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") +start_run(cfg=cfg,codeCheck=codeCheck) + +# SSP2 family +cfg$title <- "SUSTAg2" +cfg<-gms::setScenario(cfg,"SUSTAg2") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") +start_run(cfg=cfg,codeCheck=codeCheck) + +# SSP3 family +cfg$title <- "SUSTAg3" +cfg<-gms::setScenario(cfg,"SUSTAg3") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp6p0") +start_run(cfg=cfg,codeCheck=codeCheck) + +# SSP4 family +cfg$title <- "SUSTAg4" +cfg<-gms::setScenario(cfg,"SUSTAg4") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5") +start_run(cfg=cfg,codeCheck=codeCheck) + +# SSP5 family +cfg$title <- "SUSTAg5" +cfg<-gms::setScenario(cfg,"SUSTAg5") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5") +start_run(cfg=cfg,codeCheck=codeCheck) + + + +#Sensitivity tests based on SUSTAg2############################### + +#SUSTAg2 scenario without global CC mitigation policy +cfg$title <- "SUSTAg2_Ref" +cfg<-gms::setScenario(cfg,"SUSTAg2") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp6p0") +cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" +cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" +start_run(cfg=cfg,codeCheck=codeCheck) + +#SUSTAg2 scenario without CC impacts +cfg$title <- "SUSTAg2_nocc" +cfg<-gms::setScenario(cfg,"SUSTAg2") +cfg$input <- buildInputVector(co2="co2") +cfg<-gms::setScenario(cfg,"nocc") +start_run(cfg=cfg,codeCheck=codeCheck) + + +#cfg$title <- "SUSTAg2_co2fix" +#cfg<-gms::setScenario(cfg,"SUSTAg2") +#cfg$input <- buildInputVector(co2="noco2") +#start_run(cfg=cfg,codeCheck=codeCheck) +# +#cfg$title <- "SUSTAg2_Ref_co2fix" +#cfg<-gms::setScenario(cfg,"SUSTAg2") +#cfg$input <- buildInputVector(co2="noco2",climatescen_name="rcp6p0") +#cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" +#cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" +#start_run(cfg=cfg,codeCheck=codeCheck) + +# SUSTAg2 scenario with variation of 1st gen. bioenergy: phaseout2020 +cfg$title <- "SUSTAg2_1stgenbio_phaseout" +cfg<-gms::setScenario(cfg,"SUSTAg2") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") +cfg$gms$c60_1stgen_biodem <- "phaseout2020" +start_run(cfg=cfg,codeCheck=codeCheck) + +# SUSTAg2 scenario with variation of 1st gen. bioenergy: const2030 +cfg$title <- "SUSTAg2_1stgenbio_const2030" +cfg<-gms::setScenario(cfg,"SUSTAg2") +cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") +cfg$gms$c60_1stgen_biodem <- "const2030" +start_run(cfg=cfg,codeCheck=codeCheck) + + + + + + + + + +### bioenergy experiments diff --git a/scripts/start/projects/rcTest_default.R b/scripts/start/projects/rcTest_default.R new file mode 100644 index 0000000000..d8b4ac5d63 --- /dev/null +++ b/scripts/start/projects/rcTest_default.R @@ -0,0 +1,62 @@ +# | (C) 2008-2025 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: test routine to run for new pull requests +# position: 5 +# ---------------------------------------------------------- + + +##### Version log (YYYYMMDD - Description - Author(s)) +## 20200527 - Default SSP2 Baseline and Policy runs - FH,AM,EMJB,JPD + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +# choose a meaningful Pull Request (PR) flag +pr_flag <- "PR214_def01" + +# Grab user name +user <- Sys.info()[["user"]] + +cfg$results_folder <- "output/:title:" + +## Create a set of runs based on default.cfg + +for(ssp in c("SSP2")) { ## Add SSP* here for testing other SSPs. Basic test should be for SSP2 + for(macc in c("PBL_2019")) { + for (co2_price_path in c("Baseline","Policy")) { + + cfg$gms$c57_macc_version <- macc + + if (co2_price_path == "Baseline") { + cfg <- setScenario(cfg,c(ssp,"NPI")) + cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-NPi" #update to most recent coupled runs asap + cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-NPi" ##update to most recent coupled runs asap + + } else if (co2_price_path == "Policy"){ + cfg <- setScenario(cfg,c(ssp,"NDC")) + cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-26-REMIND-MAGPIE" #update to most recent coupled runs asap + cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-26-REMIND-MAGPIE" ##update to most recent coupled runs asap + } + + cfg$title <- paste0(pr_flag,"_",user,"_",ssp,"-",co2_price_path) #Create easily distinguishable run title + + cfg$output <- c("rds_report") # Only run rds_report after model run + + start_run(cfg,codeCheck=TRUE) # Start MAgPIE run + #cat(cfg$title) + } + } +} diff --git a/scripts/start/projects/sticky.R b/scripts/start/projects/sticky.R new file mode 100644 index 0000000000..03097982f6 --- /dev/null +++ b/scripts/start/projects/sticky.R @@ -0,0 +1,47 @@ +# | (C) 2008-2025 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: Sticky cost runs +# position: 5 +# ---------------------------------------------------------- + + +##### Version log (YYYYMMDD - Description - Author(s)) +## v0.1 - 20200923 - Sticky cost runs - EMJB,AM + +library(lucode2) +library(magclass) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Sources the default configuration file +source("config/default.cfg") + +for(cc in c("cc")){ + + cfg$force_download <- TRUE + # Set cc + cfg<-gms::setScenario(cfg,cc) + + cfg$input <- c(regional = "rev4.69_h12_magpie.tgz", + cellular = "rev4.69_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.69_h12_validation.tgz", + additional = "additional_data_rev4.17.tgz", + calibration = "calibration_H12_sticky_feb18_08May22.tgz") + + # Set factor costs + cfg$gms$factor_costs <- "sticky_feb18" + + #Change the results folder name + cfg$title<-paste0("sticky_",cc) + + # Start run + start_run(cfg=cfg) +} diff --git a/scripts/start/projects/test_bii.R b/scripts/start/projects/test_bii.R new file mode 100644 index 0000000000..9e51b10641 --- /dev/null +++ b/scripts/start/projects/test_bii.R @@ -0,0 +1,54 @@ +# | (C) 2008-2025 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: Test Biodiversity Prices +# ---------------------------------------------------------- + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +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$output <- c("rds_report","extra/disaggregation")#"extra/highres" + +prefix <- "BII07" + +cfg$qos <- "priority" + +ssp <- "SSP2" + +for (price in c(0,100,1000,2000,3000)) { + for (pol in c("Ref","Nature")) { + if (pol == "Ref") { + cfg <- setScenario(cfg,c(ssp,"NDC","rcp7p0")) + cfg$gms$s44_target_price <- price + cfg$gms$c35_protect_scenario <- "WDPA" + cfg$gms$c30_snv_target <- "by2030" + cfg$gms$s30_snv_shr <- 0 + } else if (pol == "Nature") { + cfg <- setScenario(cfg,c(ssp,"NDC","rcp7p0")) + cfg$gms$s44_target_price <- price + cfg$gms$c35_protect_scenario <- "BH_IFL" + cfg$gms$c30_snv_target <- "by2030" + cfg$gms$s30_snv_shr <- 0.2 + } + cfg$title <- paste(prefix,paste0(pol,"-BV",price),sep="_") + start_run(cfg,codeCheck=FALSE) + } +} diff --git a/scripts/start/projects/test_country.R b/scripts/start/projects/test_country.R new file mode 100644 index 0000000000..885e160e46 --- /dev/null +++ b/scripts/start/projects/test_country.R @@ -0,0 +1,69 @@ +# | (C) 2008-2025 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: Test routine for standardized test runs +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +#download default input data +#download_and_update(cfg) + +# create additional information to describe the runs +cfg$info$flag <- "H100" + +cfg$output <- c("rds_report") # "extra/highres_country" +cfg$results_folder <- "output/:title:" +cfg$force_replace <- TRUE + +# support function to create standardized title +.title <- function(...) return(paste(cfg$info$flag, sep="_",...)) + +#Reference and Policy run for SSP1, SSP2 and SSP5 +for(ssp in c("SSP2")) { + cfg$title <- .title(paste(ssp,"Ref",sep="-")) + cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) + cfg$gms$c56_pollutant_prices <- paste0("R21M42-",ssp,"-NPi") + cfg$gms$c60_2ndgen_biodem <- paste0("R21M42-",ssp,"-NPi") + + cfg$gms$processing <- "off" + cfg$gms$residues <- "off" +# cfg$gms$nr_soil_budget <- nr_soil_budget + cfg$gms$disagg_lvst <- "off" + # #H40 + # cfg$input["cellular"] <- "rev4.65_76adaf1c_1998ea10_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + # cfg$input["validation"] <- "rev4.65_76adaf1c_validation.tgz" + # cfg$input["regional"] <- "rev4.65_76adaf1c_magpie.tgz" + # cfg$input["calibration"] <- "calibration_H40_23Dec21.tgz" + #H100 + cfg$input["cellular"] <- "rev4.65_6755efa7_1998ea10_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + cfg$input["validation"] <- "rev4.65_6755efa7_validation.tgz" + cfg$input["regional"] <- "rev4.65_6755efa7_magpie.tgz" + cfg$input["calibration"] <- "calibration_H100_26Dec21.tgz" + + cfg$recalibrate_landconversion_cost <- TRUE + cfg$recalibrate <- TRUE + # cfg$calib_maxiter <- 5 + # cfg$calib_maxiter_landconversion_cost <- 5 + + download_and_update(cfg) + Sys.sleep(3) + if (file.exists("modules/14_yields/input/f14_yld_calib.csv")) file.remove("modules/14_yields/input/f14_yld_calib.csv") + Sys.sleep(2) + + start_run(cfg, codeCheck = FALSE) +} diff --git a/scripts/start/projects/test_diets.R b/scripts/start/projects/test_diets.R new file mode 100644 index 0000000000..3273d7ac7b --- /dev/null +++ b/scripts/start/projects/test_diets.R @@ -0,0 +1,345 @@ +# | (C) 2008-2025 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: Test diet scenarios +# ---------------------------------------------------------- + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +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:" +prefix <- "diet_change_v11" + +cfg$title <- paste(prefix,"olddefault",sep="_") +start_run(cfg,codeCheck=FALSE) + +cfg$title <- paste(prefix,"olddefaultEATlancet",sep="_") +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "no_underweight_half_overweight" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 1 +cfg$gms$s15_exo_ruminant <- 1 +cfg$gms$s15_exo_fish <- 1 +cfg$gms$s15_exo_fruitvegnut <- 1 +cfg$gms$s15_exo_pulses <- 1 +cfg$gms$s15_exo_sugar <- 1 +cfg$gms$s15_exo_oils <- 1 +cfg$gms$s15_exo_brans <- 1 +cfg$gms$s15_exo_scp <- 1 +cfg$gms$s15_exo_alcohol <- 1 +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"newdefault",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"EATlancet",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "no_underweight_half_overweight" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 1 +cfg$gms$s15_exo_ruminant <- 1 +cfg$gms$s15_exo_fish <- 1 +cfg$gms$s15_exo_fruitvegnut <- 1 +cfg$gms$s15_exo_pulses <- 1 +cfg$gms$s15_exo_sugar <- 1 +cfg$gms$s15_exo_oils <- 1 +cfg$gms$s15_exo_brans <- 1 +cfg$gms$s15_exo_scp <- 1 +cfg$gms$s15_exo_alcohol <- 1 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"NoUnderweightHalfOverweight",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "no_underweight_half_overweight" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"noUnderweight",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "no_underweight" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"HalfOverweight",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "half_overweight" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"waste",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_exo_diet <- 0 +cfg$gms$c15_kcal_scen <- "no_underweight_half_overweight" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"monogastric",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 1 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"ruminant",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 1 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"fish",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 1 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"fruitvegnutseed",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 1 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"pulses",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 1 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"sugar",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 1 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + + +source("config/default.cfg") +cfg$title <- paste(prefix,"oils",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 1 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 0 +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"alcohol",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 0 +cfg$gms$s15_exo_oils <- 0 +cfg$gms$s15_exo_brans <- 0 +cfg$gms$s15_exo_scp <- 0 +cfg$gms$s15_exo_alcohol <- 1 +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"processed",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$c15_kcal_scen <- "endo" +cfg$gms$c15_EAT_scen <- "FLX" +cfg$gms$s15_exo_monogastric <- 0 +cfg$gms$s15_exo_ruminant <- 0 +cfg$gms$s15_exo_fish <- 0 +cfg$gms$s15_exo_fruitvegnut <- 0 +cfg$gms$s15_exo_pulses <- 0 +cfg$gms$s15_exo_sugar <- 1 +cfg$gms$s15_exo_oils <- 1 +cfg$gms$s15_exo_brans <- 1 +cfg$gms$s15_exo_scp <- 1 +cfg$gms$s15_exo_alcohol <- 1 +start_run(cfg,codeCheck=FALSE) + +source("config/default.cfg") +cfg$title <- paste(prefix,"elastic",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 0 +cfg$gms$s15_exo_diet <- 0 +cfg$gms$s15_elastic_demand <- 1 +start_run(cfg,codeCheck=FALSE) + + +# should show no change +source("config/default.cfg") +cfg$title <- paste(prefix,"elasticEAT",sep="_") +cfg$gms$food <- "anthro_iso_jun22" +cfg$gms$s15_exo_waste <- 1 +cfg$gms$s15_exo_diet <- 1 +cfg$gms$s15_elastic_demand <- 1 +start_run(cfg,codeCheck=FALSE) diff --git a/scripts/start/projects/test_elastic_demand.R b/scripts/start/projects/test_elastic_demand.R new file mode 100644 index 0000000000..3a396bf556 --- /dev/null +++ b/scripts/start/projects/test_elastic_demand.R @@ -0,0 +1,71 @@ +# | (C) 2008-2025 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: Test routine for standardized test runs +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +#download default input data +download_and_update(cfg) + +# create additional information to describe the runs +cfg$info$flag <- "elastic_demand" + +cfg$results_folder <- "output/:title:" +cfg$force_replace <- TRUE + +# support function to create standardized title +.title <- function(cfg, ...) return(paste(cfg$info$flag, sep="_",...)) + +# Reference and Policy run for various shares of tax recycling +for(s15_tax_recycling in c(0,0.5,1)) { + + ssp="SSP2" + + cfg$title <- .title(cfg, paste(ssp,"PkBudg650","recycling",s15_tax_recycling,sep="-")) + cfg$gms$s15_elastic_demand <- 1 + cfg$gms$s15_tax_recycling <- s15_tax_recycling + cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9")) + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + start_run(cfg, codeCheck = FALSE) + + +} + +s15_tax_recycling=1 + cfg$title <- .title(cfg, paste(ssp,"Ref",s15_tax_recycling,sep="-")) + cfg$gms$s15_elastic_demand <- 1 + cfg$gms$s15_tax_recycling <- s15_tax_recycling + cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NPi") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NPi") + start_run(cfg, codeCheck = FALSE) + +s15_tax_recycling=1 + cfg$title <- .title(cfg, paste(ssp,"Ref_inelastic",sep="-")) + cfg$gms$s15_elastic_demand <- 0 + cfg$gms$s15_tax_recycling <- s15_tax_recycling + cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NPi") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NPi") + start_run(cfg, codeCheck = FALSE) + diff --git a/scripts/start/projects/test_rotations.R b/scripts/start/projects/test_rotations.R new file mode 100644 index 0000000000..f72713c3eb --- /dev/null +++ b/scripts/start/projects/test_rotations.R @@ -0,0 +1,67 @@ +# | (C) 2008-2025 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: Test new rotational constraint scenarios +# ---------------------------------------------------------- + + +###################################### +#### Script to start a MAgPIE run #### +###################################### + +library(gms) +library(lucode2) +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$gms$s13_max_gdp_shr <- 0.01 + +cfg$results_folder <- "output/:title:" +#cfg$output <- c("rds_report","extra/disaggregation")#"extra/highres" +prefix <- "rota_penalty18" + +cfg$title <- paste(prefix,"olddefault",sep="_") +start_run(cfg,codeCheck=FALSE) + +#cfg$title <- paste(prefix,"olddefault_stickydynamic",sep="_") +#cfg$input <- c(regional = "rev4.68_h12_magpie.tgz", +# cellular = "rev4.68_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", +# validation = "rev4.68_h12_validation.tgz", +# additional = "additional_data_rev4.18.tgz", +# calibration = "calibration_H12_sticky_feb18_dynamic_rotation_14Jun22.tgz") + +#cfg$gms$c38_sticky_mode <- "dynamic" +#start_run(cfg,codeCheck=FALSE) + +cfg$title <- paste(prefix,"newdefault",sep="_") +cfg$gms$crop <- "penalty_apr22" +cfg$gms$som <- "cellpool_jan23" +cfg$gms$c30_rotation_scenario = "default" + + +#cfg$qos <- "priority" +cfg$recalibrate <- TRUE +cfg$recalibrate_landconversion_cost <- TRUE +start_run(cfg,codeCheck=FALSE) +magpie4::submitCalibration("H12_sticky_feb18_dynamic_rotation2") +cfg$recalibrate <- FALSE +cfg$recalibrate_landconversion_cost <- FALSE + +for (scenario in c("none","default","fallow","legumes","agroforestry","agroecology")){ + for (byyear in c("by2030","by2050")){ + cfg$gms$c30_rotation_scenario = scenario + cfg$gms$c30_rotation_scenario_speed = byyear + cfg$title <- paste(prefix,scenario,byyear,sep="_") + start_run(cfg,codeCheck=FALSE) + } + +} diff --git a/scripts/start/recalibrate.R b/scripts/start/recalibrate.R deleted file mode 100644 index 76ff87e31c..0000000000 --- a/scripts/start/recalibrate.R +++ /dev/null @@ -1,29 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -library(lucode) -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$title <- "calib_run" -cfg$gms$c_timesteps <- 1 -cfg$output <- c("report") -cfg$sequential <- TRUE -start_run(cfg,codeCheck=FALSE) -submitCalibration("H12") diff --git a/scripts/start/sim4nexus.R b/scripts/start/sim4nexus.R deleted file mode 100644 index 8fa14e01b3..0000000000 --- a/scripts/start/sim4nexus.R +++ /dev/null @@ -1,133 +0,0 @@ -# | (C) 2008-2019 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 - - -############################################################ -#### Script for the generation of SIM4NEXUS simulations #### -############################################################ - -library(lucode) -source("scripts/start_functions.R") -source("scripts/performance_test.R") - - -#set defaults -codeCheck <- FALSE - -buildInputVector <- function(regionmapping = "H12", - project_name = "isimip_rcp", - climatescen_name= "rcp2p6", - co2 = "co2", - climate_model = "IPSL_CM5A_LR", - resolution = "h200", - archive_rev = "37", - madrat_rev = "4.14", - validation_rev = "4.14", - calibration = "calibration_sim4nexus_may2019.tgz", - additional_data = "additional_data_rev3.67.tgz") { - mappings <- c(H11="8a828c6ed5004e77d1ba2025e8ea2261", - H12="690d3718e151be1b450b394c1064b1c5", - mag="c30c1c580039c2b300d86cc46ff4036a", - agmip="c77f075908c3bc29bdbe1976165eccaf", - sim4nexus="25dd7264e8e145385b3bd0b89ec5f3fc", - inms="44f1e181a3da765729f2f1bfc926425a", - capri="e7e72fddc44cc3d546af7b038c651f51") - archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") - archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") - madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie", ".tgz") - validation <- paste0("rev", validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") - return(c(archive,madrat,validation,calibration,additional_data)) -} - -### SIM4NEXUS runs ### -#general settings -general_settings<-function(title) { - source("config/default.cfg") - cfg$gms$c_timesteps <- "coup2100" - cfg$input <- buildInputVector() - cfg$output <- c(cfg$output,"sustag_report") - cfg$recalibrate <- FALSE - cfg<-lucode::setScenario(cfg,"cc") - cfg$gms$c56_emis_policy <- "all" - cfg$gms$forestry <- "affore_vegc_dec16" - cfg$gms$maccs <- "on_sep16" - cfg$title <- paste0("v1_",title) -# include costs per-ton - return(cfg) -} - - -# SSP control runs############################################### - - -# SSP2 -cfg<-general_settings(title="SSP2") -cfg<-lucode::setScenario(cfg,"SSP2") -cfg<-lucode::setScenario(cfg,"nocc") -cfg$input <- buildInputVector(regionmapping = "sim4nexus") -cfg$recalibrate <- TRUE -start_run(cfg=cfg,codeCheck=codeCheck) -calib<-magpie4::submitCalibration(name = "calibration_sim4nexus_may2019") -cfg$recalibrate <- "ifneeded" - - -#SIM4NEXUS standard runs############################################# - -#SSP2 family - -cfg<-general_settings(title="SSP2_base_rcp6p0") -cfg<-lucode::setScenario(cfg,"SSP2") -cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "sim4nexus",calibration=calib) -start_run(cfg=cfg,codeCheck=codeCheck) - - -cfg<-general_settings(title="SSP2_food") -cfg<-lucode::setScenario(cfg,"SSP2") -cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "sim4nexus",calibration=calib) -start_run(cfg=cfg,codeCheck=codeCheck) - - -cfg<-general_settings(title="SSP2_climate") -cfg<-lucode::setScenario(cfg,"SSP2") -cfg$input <- buildInputVector(climatescen_name="rcp2p6",regionmapping = "sim4nexus",calibration=calib) -cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA2-V15-MESSAGE-GLOBIOM" -cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA2" -cfg$c50_scen_neff <- "neff65_70_starty2010" -start_run(cfg=cfg,codeCheck=codeCheck) - - - -cfg<-general_settings(title="SSP2_water") -cfg<-lucode::setScenario(cfg,"SSP2") -cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "sim4nexus",calibration=calib) -cfg$c50_scen_neff <- "neff70_75_starty2010" -start_run(cfg=cfg,codeCheck=codeCheck) - - -cfg<-general_settings(title="SSP2_biodiversity") -cfg<-lucode::setScenario(cfg,"SSP2") -cfg<-lucode::setScenario(cfg,"cc") -cfg$input <- buildInputVector(climatescen_name="rcp6p0",regionmapping = "sim4nexus",calibration=calib) -cfg$c50_scen_neff <- "neff70_75_starty2010" -cfg$c55_scen_conf <- "SSP1" -cfg$gms$c12_interest_rate <- "low" -cfg$gms$c35_protect_scenario <- "BH" -start_run(cfg=cfg,codeCheck=codeCheck) - - -cfg<-general_settings(title="SSP2_all") -cfg<-lucode::setScenario(cfg,"SSP2") -cfg$input <- buildInputVector(climatescen_name="rcp2p6",regionmapping = "sim4nexus",calibration=calib) -cfg$gms$c56_pollutant_prices <- "SSP2-26-SPA2-V15-MESSAGE-GLOBIOM" -cfg$gms$c60_2ndgen_biodem <- "SSP2-26-SPA2" -cfg$gms$c42_env_flow_policy <- "on" -cfg$c50_scen_neff <- "neff75_80_starty2010" -cfg$gms$c12_interest_rate <- "low" -cfg$c55_scen_conf <- "SSP1" -cfg$gms$c35_protect_scenario <- "BH" -start_run(cfg=cfg,codeCheck=codeCheck) - diff --git a/scripts/start/ssp2.R b/scripts/start/ssp2.R deleted file mode 100644 index 9ca0be1d31..0000000000 --- a/scripts/start/ssp2.R +++ /dev/null @@ -1,48 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -library(lucode) -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$force_download <- TRUE - -cfg$results_folder <- "output/:title:" - -cfg$title <- "R2M41_SSP2_NPi_v5" -cfg <- setScenario(cfg,c("SSP2","NPI")) -cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-NPi" -cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-NPi" -start_run(cfg,codeCheck=FALSE) - -cfg$title <- "R2M41_SSP2_NDC_v5" -cfg <- setScenario(cfg,c("SSP2","NDC")) -cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-NDC" -cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-NDC" -start_run(cfg,codeCheck=FALSE) - -cfg$title <- "R2M41_SSP2_Budg600_v5" -cfg <- setScenario(cfg,c("SSP2","NDC")) -cfg$gms$c56_pollutant_prices <- "R2M41-SSP2-Budg600" -cfg$gms$c60_2ndgen_biodem <- "R2M41-SSP2-Budg600" -start_run(cfg,codeCheck=FALSE) - -cfg$title <- "SSPDB_SSP2_26_v5" -cfg <- setScenario(cfg,c("SSP2","NDC")) -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-26-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-26-REMIND-MAGPIE" -start_run(cfg,codeCheck=FALSE) diff --git a/scripts/start/ssp_deforestation.R b/scripts/start/ssp_deforestation.R deleted file mode 100644 index 4ce8ed08a1..0000000000 --- a/scripts/start/ssp_deforestation.R +++ /dev/null @@ -1,112 +0,0 @@ -# | (C) 2008-2019 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 - - -###################################### -#### Script to start a MAgPIE run #### -###################################### - -library(lucode) -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$force_download <- TRUE - -#specify the title flag for all the scenarios -#flag <- "" - -#SSPs -for(reg in c("BRA","H12")) { - if(reg=="BRA"){ - ## Brazil run with 500 clusters and extra weight to region BRA - cellcode <- "n500_BRA18_LAM26_ROW01" - regionscode <- "d49a7a8baaab0edc754ebfc09462be0a" - } else if(reg=="H12") { - ## 12 region run with 200 clusters - cellcode <- "h200" - regionscode <- "690d3718e151be1b450b394c1064b1c5" - } else { - stop("Unknown region setting!") - } - - ## Test for artificial NPI policy for Japan. - ## forest_pro is forest protection in JPN - ## forest_nopro is no NPI in JPN with older version of additional_data_rev3.43 - - forest_pro <- c(paste0("isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_",cellcode,"_",regionscode,".tgz"), - paste0("rev3.35_",regionscode,"_magpie.tgz"), - paste0("rev3.35_",regionscode,"_validation.tgz"), - "additional_data_rev3.44.tgz") - forest_nopro <- c(paste0("isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev33_",cellcode,"_",regionscode,".tgz"), - paste0("rev3.35_",regionscode,"_magpie.tgz"), - paste0("rev3.35_",regionscode,"_validation.tgz"), - "additional_data_rev3.43.tgz") - - ## Three SSP scenarios to analyse - for (ssp in c("SSP2","SSP1","SSP5")) { - ## reference and mitigation runs (without co2 fertilization) - for (rcp in c("ref","26")){ - #if(rcp=="26" && ssp %in% c("SSP3","SSP4")) next - - ## lg is livestock gridded implementation by Kristine. ptc15 is pasture transport cost of 0.15 by Geanderson - for(tc in c("lg","ptc15")) { - - ## JPNfp is forest protection in JPN related to forest_pro - ## JPNdf is no forest protection in JPN related to forest_nopro - for(jpn in c("JPNfp","JPNdf")){ - - ## Two realization for Tau implementation. - for(tau in c("endo_JUN16","endo_jun18")){ - - cfg$title <- paste(reg,tc,jpn,tau,ssp,rcp,sep="_") - - cfg <- setScenario(cfg,c(ssp,if(rcp=="ref") "NPI" else "NDC")) - - if(rcp=="Ref"){spa="SPA0"}else{spa=paste0("SPA",substring(ssp,4,5))} - if(ssp%in%c("SSP1","SSP2","SSP5")){ - model="REMIND-MAgPIE" - } else if (ssp=="SSP3"){ - model="AIM-CGE" - } else { - model="GCAM4" - } - cfg$gms$c56_pollutant_prices <- paste("SSPDB",ssp,rcp,model,sep="-") - cfg$gms$c60_2ndgen_biodem <- paste("SSPDB",ssp,rcp,model,sep="-") - - cfg$gms$tc <- tau - - if(jpn=="JPNdf"){ - cfg$input <- forest_nopro - } else if(jpn=="JPNfp"){ - cfg$input <- forest_pro - } else stop("Unknown transport cost setting!") - - if(tc=="ptc15") { - cfg$gms$s40_pasture_transport_costs <- 0.15 #ptc15 - cfg$damping_factor <- 0.7 - cfg$gms$disagg_lvst <- "off" - } else if(tc=="lg") { - cfg$gms$s40_pasture_transport_costs <- 0 - cfg$damping_factor <- 0.98 - cfg$gms$disagg_lvst <- "simple_oct17" - } else stop("Unknown transport cost setting!") - - ## Submit the runs - start_run(cfg,codeCheck=FALSE) - } - } - } - } - } -} diff --git a/scripts/start/sustag.R b/scripts/start/sustag.R deleted file mode 100644 index a0abac052a..0000000000 --- a/scripts/start/sustag.R +++ /dev/null @@ -1,185 +0,0 @@ -# | (C) 2008-2019 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 - - -########################################################## -#### Script for the generation of SUSTAg simulations #### -########################################################## - -library(lucode) -source("scripts/start_functions.R") -source("scripts/performance_test.R") -source("config/default.cfg") - -#set defaults -codeCheck <- FALSE - -buildInputVector <- function(regionmapping = "agmip", - project_name = "isimip_rcp", - climatescen_name= "rcp2p6", - co2 = "noco2", - climate_model = "IPSL_CM5A_LR", - resolution = "c200", - archive_rev = "34", - madrat_rev = "4.14", - validation_rev = "4.14", - calibration = "calibration_agmip_c200_19Dec18.tgz", - additional_data = "additional_data_rev3.58.tgz") { - mappings <- c(H11="8a828c6ed5004e77d1ba2025e8ea2261", - H12="690d3718e151be1b450b394c1064b1c5", - mag="c30c1c580039c2b300d86cc46ff4036a", - agmip="c77f075908c3bc29bdbe1976165eccaf", - sim4nexus="270870819da5607e288b6d0e5a5e6594", - inms="69c65bb3c88e8033cf8df6b5ac5d52a9", - inms2="ef2ae7cd6110d5d142a9f8bd7d5a68f2", - capri="e7e72fddc44cc3d546af7b038c651f51") - archive_name=paste(project_name,climate_model,climatescen_name,co2,sep="-") - archive <- paste0(archive_name, "_rev", archive_rev, "_", resolution, "_", mappings[regionmapping], ".tgz") - madrat <- paste0("rev", madrat_rev,"_", mappings[regionmapping], "_magpie", ".tgz") - validation <- paste0("rev", validation_rev,"_", mappings[regionmapping], "_validation", ".tgz") - return(c(archive,madrat,validation,calibration,additional_data)) -} - -### SUSTAg runs ### -#general settings -cfg$gms$c_timesteps <- 12 -cfg$input <- buildInputVector() -cfg$output <- c(cfg$output,"sustag_report") -cfg$recalibrate <- FALSE - - -# SSP control runs############################################### - -# SSP2 -cfg$title <- "SSP2" -cfg<-lucode::setScenario(cfg,"SSP2") -cfg<-lucode::setScenario(cfg,"nocc") -cfg$force_download <- TRUE -cfg$input <- buildInputVector(co2="co2") -#cfg$recalibrate <- TRUE -start_run(cfg=cfg,codeCheck=codeCheck) -#cfg$recalibrate <- FALSE - -# SSP1 -cfg$title <- "SSP1" -cfg<-lucode::setScenario(cfg,"SSP1") -cfg<-lucode::setScenario(cfg,"nocc") -cfg$input <- buildInputVector(co2="co2") -start_run(cfg=cfg,codeCheck=codeCheck) - -# SSP3 -cfg$title <- "SSP3" -cfg<-lucode::setScenario(cfg,"SSP3") -cfg<-lucode::setScenario(cfg,"nocc") -cfg$input <- buildInputVector(co2="co2") -start_run(cfg=cfg,codeCheck=codeCheck) - -# SSP4 -cfg$title <- "SSP4" -cfg<-lucode::setScenario(cfg,"SSP4") -cfg<-lucode::setScenario(cfg,"nocc") -cfg$input <- buildInputVector(co2="co2") -start_run(cfg=cfg,codeCheck=codeCheck) - -# SSP5 -cfg$title <- "SSP5" -cfg<-lucode::setScenario(cfg,"SSP5") -cfg<-lucode::setScenario(cfg,"nocc") -cfg$input <- buildInputVector(co2="co2") -start_run(cfg=cfg,codeCheck=codeCheck) - - - - - -#SUSTAg standard runs############################################# - -# SSP1 family -cfg$title <- "SUSTAg1" -cfg<-lucode::setScenario(cfg,"SUSTAg1") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") -start_run(cfg=cfg,codeCheck=codeCheck) - -# SSP2 family -cfg$title <- "SUSTAg2" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") -start_run(cfg=cfg,codeCheck=codeCheck) - -# SSP3 family -cfg$title <- "SUSTAg3" -cfg<-lucode::setScenario(cfg,"SUSTAg3") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp6p0") -start_run(cfg=cfg,codeCheck=codeCheck) - -# SSP4 family -cfg$title <- "SUSTAg4" -cfg<-lucode::setScenario(cfg,"SUSTAg4") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5") -start_run(cfg=cfg,codeCheck=codeCheck) - -# SSP5 family -cfg$title <- "SUSTAg5" -cfg<-lucode::setScenario(cfg,"SUSTAg5") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp4p5") -start_run(cfg=cfg,codeCheck=codeCheck) - - - -#Sensitivity tests based on SUSTAg2############################### - -#SUSTAg2 scenario without global CC mitigation policy -cfg$title <- "SUSTAg2_Ref" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp6p0") -cfg$gms$c56_pollutant_prices <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -cfg$gms$c60_2ndgen_biodem <- "SSPDB-SSP2-Ref-REMIND-MAGPIE" -start_run(cfg=cfg,codeCheck=codeCheck) - -#SUSTAg2 scenario without CC impacts -cfg$title <- "SUSTAg2_nocc" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$input <- buildInputVector(co2="co2") -cfg<-lucode::setScenario(cfg,"nocc") -start_run(cfg=cfg,codeCheck=codeCheck) - - -#cfg$title <- "SUSTAg2_co2fix" -#cfg<-lucode::setScenario(cfg,"SUSTAg2") -#cfg$input <- buildInputVector(co2="noco2") -#start_run(cfg=cfg,codeCheck=codeCheck) -# -#cfg$title <- "SUSTAg2_Ref_co2fix" -#cfg<-lucode::setScenario(cfg,"SUSTAg2") -#cfg$input <- buildInputVector(co2="noco2",climatescen_name="rcp6p0") -#cfg$gms$c56_pollutant_prices <- "SSP2-Ref-SPA0-V15-REMIND-MAGPIE" -#cfg$gms$c60_2ndgen_biodem <- "SSP2-Ref-SPA0" -#start_run(cfg=cfg,codeCheck=codeCheck) - -# SUSTAg2 scenario with variation of 1st gen. bioenergy: phaseout2020 -cfg$title <- "SUSTAg2_1stgenbio_phaseout" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") -cfg$gms$c60_1stgen_biodem <- "phaseout2020" -start_run(cfg=cfg,codeCheck=codeCheck) - -# SUSTAg2 scenario with variation of 1st gen. bioenergy: const2030 -cfg$title <- "SUSTAg2_1stgenbio_const2030" -cfg<-lucode::setScenario(cfg,"SUSTAg2") -cfg$input <- buildInputVector(co2="co2",climatescen_name="rcp2p6") -cfg$gms$c60_1stgen_biodem <- "const2030" -start_run(cfg=cfg,codeCheck=codeCheck) - - - - - - - - - -### bioenergy experiments diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R new file mode 100644 index 0000000000..efdc83c34b --- /dev/null +++ b/scripts/start/test_runs.R @@ -0,0 +1,125 @@ +# | (C) 2008-2025 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: Test routine for standardized test runs +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +#download default input data +download_and_update(cfg) + +# create additional information to describe the runs +arguments <- commandArgs(trailingOnly = TRUE) +if (length(arguments) == 1) { + cfg$info$flag <- paste0("release-", arguments) +} else { + cfg$info$flag <- "weeklyTests" +} + +cfg$results_folder <- "output/:title:" +cfg$force_replace <- TRUE + +# support function to create standardized title +.title <- function(cfg, ...) return(paste(cfg$info$flag, sep = "_", ...)) + +# Single time step run +timeSteps <- cfg$gms$c_timesteps +cfg$gms$c_timesteps <- 1 +cfg$title <- .title(cfg, "singleTimeStep") +start_run(cfg, codeCheck = TRUE) +cfg$gms$c_timesteps <- timeSteps + +# Reference and Policy run for SSP1, SSP2 and SSP3 +# NPi2025: continuation of current climate polices +# PkBudg1000: ambitious climate policy broadly in line with 2deg C Paris target +# PkBudg650: ambitious climate policy broadly in line with 1.5deg C Paris target +# SSP3-PkBudg650 is not feasible, therefore only PkBudg1000 is used. +for (ssp in c("SSP1", "SSP2", "SSP3")) { + if (ssp %in% c("SSP1", "SSP2")) { + cfg$title <- .title(cfg, paste(ssp, "NPi2025", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NPI", "rcp4p5")) + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-", ssp, "-NPi2025") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-", ssp, "-NPi2025") + start_run(cfg, codeCheck = FALSE) + + cfg$title <- .title(cfg, paste(ssp, "PkBudg1000", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-", ssp, "-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-", ssp, "-PkBudg1000") + start_run(cfg, codeCheck = FALSE) + + 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("R34M410-", ssp, "-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-", ssp, "-PkBudg650") + start_run(cfg, codeCheck = FALSE) + } else if (ssp == "SSP3") { + cfg$title <- .title(cfg, paste(ssp, "NPi2025", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NPI", "rcp6p0")) + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-", ssp, "-NPi2025") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-", ssp, "-NPi2025") + start_run(cfg, codeCheck = FALSE) + + cfg$title <- .title(cfg, paste(ssp, "rollBack", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NPI-revert", "rcp7p0")) + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-", ssp, "-rollBack") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-", ssp, "-rollBack") + start_run(cfg, codeCheck = FALSE) + + cfg$title <- .title(cfg, paste(ssp, "PkBudg1000", sep = "-")) + cfg <- setScenario(cfg, c(ssp, "NDC", "rcp2p6")) + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg$gms$c56_pollutant_prices <- paste0("R34M410-", ssp, "-PkBudg1000") + cfg$gms$c60_2ndgen_biodem <- paste0("R34M410-", ssp, "-PkBudg1000") + start_run(cfg, codeCheck = FALSE) + } +} + +# test FSEC setup (even though FSEC is no longer ongoing) as that checks many important switches +source("scripts/projects/fsec.R") + +codeCheck <- FALSE + +### Business-as-usual +cfg <- fsecScenario(scenario = "c_BAU", highres = FALSE) +cfg$force_replace <- TRUE +cfg$results_folder <- "output/:title:" +start_run(cfg = cfg, codeCheck = codeCheck) + +### NatureSparing +cfg <- fsecScenario(scenario = "b_NatureSparing", highres = FALSE) +cfg$force_replace <- TRUE +cfg$results_folder <- "output/:title:" +start_run(cfg = cfg, codeCheck = codeCheck) + +### LandscapeElements +cfg <- fsecScenario(scenario = "a_LandscapeElements", highres = FALSE) +cfg$force_replace <- TRUE +cfg$results_folder <- "output/:title:" +start_run(cfg = cfg, codeCheck = codeCheck) + +### FSDP Scenario +cfg <- fsecScenario(scenario = "e_FSDP", highres = FALSE) +cfg$force_replace <- TRUE +cfg$results_folder <- "output/:title:" +start_run(cfg = cfg, codeCheck = codeCheck) diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 63b50ff15d..c6aca3ae17 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -1,35 +1,253 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 -start_run <- function(cfg,scenario=NULL,codeCheck=TRUE, - report=NULL,sceninreport=NULL,LU_pricing="y2010", lock_model=TRUE) { +################################################################################ +# Define internal functions +################################################################################ - if (!requireNamespace("lucode", quietly = TRUE)) { - stop("Package \"lucode\" needed for this function to work. Please install it.", - call. = FALSE) +.calcClusterCells <- function(x) { + cells <- noCells <- NULL + for (i in magclass::getItems(x, dim = 1.1)) { + max <- max(as.numeric(magclass::getItems(x[i, , ], dim = 1.2))) + min <- min(as.numeric(magclass::getItems(x[i, , ], dim = 1.2))) + count <- length(magclass::getItems(x[i, , ], dim = 1.2)) + + tmp <- paste0(paste(i, min, sep = "_"), "*" , paste(i, max, sep = "_")) + cells <- c(cells, tmp) + noCells <- c(noCells, count) } + out <- data.frame(i = magclass::getItems(x, dim = 1.1), + j = cells, + n = noCells) + return(out) +} - if (!requireNamespace("magclass", quietly = TRUE)) { - stop("Package \"magclass\" needed for this function to work. Please install it.", - call. = FALSE) +.update_sets_core <- function(x, map) { + require(gms) + + if (!("region" %in% names(map))) map$region <- map$RegionCode + if (!("country" %in% names(map))) map$country <- map$CountryCode + if (!("superregion" %in% names(map))) map$superregion <- map$region + + reg1 <- unique(as.character(map$region)) + reg2 <- magclass::getItems(x, dim = 1.1) + if (!all(union(reg1,reg2) %in% intersect(reg1, reg2))) { + stop("Inconsistent region information!", + "\n cpr info: ", paste(reg2, collapse = ", "), + "\n spatial header info: ", paste(reg1, collapse = ", ")) + } + + ij <- .calcClusterCells(x = x)[c("i", "j")] + + hi <- unique(map[c("superregion", "region")]) + hi <- hi[order(hi$superregion),] + + sets <- list(list(name = "h", + desc = "all superregional economic regions", + items = sort(unique(as.character(map$superregion)))), + list(name = "i", + desc = "all economic regions", + items = ij[["i"]]), + list(name = "supreg(h,i)", + desc = "mapping of superregions to its regions", + items = hi), + list(name = "iso", + desc = "list of iso countries", + items = as.character(map$country)), + list(name = "j", + desc = "number of LPJ cells", + items = ij[["j"]]), + list(name = "cell(i,j)", + desc = "number of LPJ cells per region i", + items = ij), + list(name = "i_to_iso(i,iso)", + desc = "mapping regions to iso countries", + items = map[c("region","country")][order(map$region),])) + + gms::writeSets(sets, "core/sets.gms") +} + +.update_sets_modules <- function() { + require(gms) + + ### 56_ghg_policy + ghgscen56 <- magclass::read.magpie("modules/56_ghg_policy/input/f56_pollutant_prices.cs3") + ghgscen56 <- magclass::getNames(ghgscen56,dim=2) + + scen56 <- magclass::read.magpie("modules/56_ghg_policy/input/f56_emis_policy.csv",file_type = "cs3") + scen56 <- magclass::getNames(scen56,dim=1) + + sets <- list(list(name = "ghgscen56", + desc = "ghg price scenarios", + items = ghgscen56), + list(name = "scen56", + desc = "emission policy scenarios", + items = scen56)) + + gms::writeSets(sets, "modules/56_ghg_policy/price_aug22/sets.gms") + + ### 60_bioenergy + scen2nd60 <- magclass::read.magpie("modules/60_bioenergy/input/f60_bioenergy_dem.cs3") + scen2nd60 <- magclass::getNames(scen2nd60,dim=1) + + sets <- list(list(name = "scen2nd60", + desc = "second generation bioenergy scenarios", + items = scen2nd60)) + + gms::writeSets(sets , "modules/60_bioenergy/1stgen_priced_dec18/sets.gms") + gms::writeSets(sets , "modules/60_bioenergy/1st2ndgen_priced_feb24/sets.gms") +} + +# Function to extract information from info.txt +.get_info <- function(file, grep_expression, sep, pattern = "", replacement = "") { + if(!file.exists(file)) return("#MISSING#") + file <- readLines(file, warn=FALSE) + tmp <- grep(grep_expression, file, value=TRUE) + tmp <- strsplit(tmp, sep) + tmp <- sapply(tmp, "[[", 2) + tmp <- gsub(pattern, replacement, tmp) + if(all(!is.na(as.logical(tmp)))) return(as.vector(sapply(tmp, as.logical))) + if (all(!(regexpr("[a-zA-Z]", tmp) > 0))) { + tmp <- as.numeric(tmp) + } + return(tmp) +} + +# Define routine to update info file in input folder and info in main.gms +.update_info <- function(datasets, x, regionscode, reg_revision, warnings = NULL) { + + # extract cluster information from file: + ijn <- .calcClusterCells(x = x) + + low_res <- .get_info("input/info.txt", "^\\* Output ?resolution:", ": ") + high_res <- .get_info("input/info.txt", "^\\* Input ?resolution:", ": ") + + info <- readLines('input/info.txt') + subject <- 'VERSION INFO' + + useddata <- NULL + for(dataset in rownames(datasets)) { + useddata <- c(useddata, + '', + paste('Used data set:', dataset), + paste('md5sum:', datasets[dataset, "md5"]), + paste('Repository:', datasets[dataset, "repo"])) + } + + warnings <- attr(datasets,"warnings") + if(!is.null(warnings)) { + warnings <- capture.output(warnings) + } + + content <- c(useddata, + '', + paste('Low resolution:', low_res), + paste('High resolution:', high_res), + '', + paste('Total number of cells:', sum(ijn["n"])), + '', + 'Number of cells per region:', + paste(format(ijn[["i"]], width = 5, justify = "right"), collapse = ""), + paste(format(ijn[["n"]], width = 5), collapse = ""), + '', + paste('Regionscode:', regionscode), + '', + paste('Regions data revision:', reg_revision), + '', + info, + '', + warnings, + '', + paste('Last modification (input data):',date()), + '') + writeLines(content,'input/info.txt') + contentShort <- c(paste('Low resolution:', low_res), + paste('High resolution:', high_res), + '', + paste('Total number of cells:', sum(ijn["n"])), + '', + 'Number of cells per region:', + paste(format(ijn[["i"]], width = 5, justify = "right"), collapse = ""), + paste(format(ijn[["n"]], width = 5), collapse = ""), + '', + paste('Regionscode:', regionscode)) + + gms::replace_in_file("main.gms",paste('*',contentShort),subject) +} + +################################################################################ +######################### MAIN FUNCTIONS ####################################### +################################################################################ + +download_and_update <- function(cfg) { + # Download data and update code + + # Delete previously downloaded files, download new files and distribute + # them within the model. + filemap <- gms::download_distribute(files = cfg$input, + repositories = cfg$repositories, # defined in your local .Rprofile or on the cluster /p/projects/rd3mod/R/.Rprofile + modelfolder = ".", + additionalDelete="scripts/downloader/inputdelete.cfg", + debug = cfg$debug) + + # In the following the GAMS sourcecode files magpie.gms and core/sets.gms + # are manipulated. Therefore some information about the number of cells per + # region is required (CPR). This information is gained by extracting it from + # the avl_land.cs3 input file (any other cellular file could be used as well). + # This information is then transfered to .update_info, which is + # updating the general information in magpie.gms and input/info.txt + # and .update_sets, which is updating the resolution- and region-depending + # sets in core/sets.gms + tmp <- magclass::read.magpie("modules/10_land/input/avl_land_t.cs3") + tmp2 <- magclass::read.magpie("modules/10_land/input/avl_land_t_0.5.mz") + cel <- magclass::getItems(tmp2, dim = 1) + # read spatial_header, map, reg_revision and regionscode + load("input/spatial_header.rda") + .update_info(filemap, x = tmp, regionscode, reg_revision, warnings) + .update_sets_core(x = tmp, map = map) + .update_sets_modules() +} + + +start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE, lock_timeout = 1) { + + timePrepareStart <- Sys.time() + + checkNamespace <- function(...) { + for(package in c(...)) { + if (!requireNamespace(package, quietly = TRUE)) { + stop("Package \"",package,"\" needed for this function to work. Please install it.", + call. = FALSE) + } + } } + checkNamespace("gms", "lucode2", "magclass") - Sys.setlocale(locale="C") + Sys.setlocale(locale = "C") maindir <- getwd() - on.exit(setwd(maindir)) + withr::defer(setwd(maindir)) if(lock_model) { - lock_id <- lucode::model_lock(timeout1=1) - on.exit(lucode::model_unlock(lock_id), add=TRUE) + lock_id <- gms::model_lock(timeout1 = lock_timeout) + withr::defer(gms::model_unlock(lock_id)) } - if(!is.null(scenario)) cfg <- lucode::setScenario(cfg,scenario) - cfg <- lucode::check_config(cfg) + # Apply scenario settings ans check configuration file for consistency + if(!is.null(scenario)) cfg <- gms::setScenario(cfg,scenario) + cfg <- gms::check_config(cfg, extras = c("info", "repositories", "gms$c_input_gdx_path", + "val_workspace", "magpie_folder", "gms$c_title"), + saveCheck = TRUE) + + # save model version + cfg$info$version <- citation::read_cff("CITATION.cff")$version + + # Make 'title' a setglobal in gams to include it in the gdx + cfg$gms$c_title <- sub(".", "p", cfg$title, fixed = TRUE) rundate <- Sys.time() date <- format(rundate, "_%Y-%m-%d_%H.%M.%S") @@ -37,43 +255,94 @@ start_run <- function(cfg,scenario=NULL,codeCheck=TRUE, cfg$results_folder <- gsub(":title:", cfg$title, cfg$results_folder, fixed=TRUE) # Create output folder - if (!file.exists(cfg$results_folder)) { - dir.create(cfg$results_folder, recursive=TRUE, showWarnings=FALSE) - } else if (cfg$force_replace) { - cat("Deleting results folder because it alreay exists:",cfg$results_folder,"\n") - unlink(cfg$results_folder, recursive = TRUE) - dir.create(cfg$results_folder, recursive = TRUE, showWarnings = FALSE) - } else { - stop(paste0("Results folder ",cfg$results_folder, - " could not be created because is already exists.")) + if (file.exists(cfg$results_folder)) { + if (cfg$force_replace) { + message("Deleting results folder because it already exists:", cfg$results_folder) + unlink(cfg$results_folder, recursive = TRUE) + } else { + stop(paste0("Results folder ", cfg$results_folder, + " could not be created because it already exists.")) + } } - # If report and scenname are available the data of this scenario in the report - # will be converted to MAgPIE input, saved to the respective input folders - # and used as input by the model - if (!is.null(report) && !is.null(sceninreport)) { - getReportData(report, sceninreport, LU_pricing) - cfg <- lucode::setScenario(cfg,"coupling") + dir.create(cfg$results_folder, recursive = TRUE) + + if (is.null(renv::project())) { + message("No active renv project found, not using renv.") + } else { + if (!is.null(cfg$renv_lock)) { + message("Copying cfg$renv_lock (= '", normalizePath(cfg$renv_lock, mustWork = TRUE), "') into '", + cfg$results_folder, "'") + file.copy(cfg$renv_lock, file.path(cfg$results_folder, "_renv.lock")) + } else if (normalizePath(renv::project()) == normalizePath(".")) { + # the main renv is loaded + message("Generating lockfile in '", cfg$results_folder, "'... ", appendLF = FALSE) + # suppress output of renv::snapshot + errorMessage1 <- utils::capture.output({ + errorMessage2 <- utils::capture.output({ + snapshotSuccess <- tryCatch({ + # snapshot current main renv into run folder + renv::snapshot(lockfile = file.path(cfg$results_folder, "_renv.lock"), prompt = FALSE) + TRUE + }, error = function(error) FALSE) + }, type = "message") + }) + if (!snapshotSuccess) { + stop(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) + } + message("done.") + } else { + # a run renv is loaded + message("Copying lockfile into '", cfg$results_folder, "'") + file.copy(renv::paths$lockfile(), file.path(cfg$results_folder, "_renv.lock")) + } + + createResultsfolderRenv <- function() { + renv::init() # will overwrite renv.lock if existing... + if (!identical(Sys.info()[["sysname"]], "Windows")) { + # the renv package installation folder is copied from the renv cache, where it might + # be write protected, but we don't want write protection in the results folder + system("chmod ug+w -R renv/library/R-*/*") + } + file.rename("_renv.lock", "renv.lock") # so we need this rename + renv::restore(prompt = FALSE) + message("renv creation done.") + } + + renvLogPath <- file.path(cfg$results_folder, "log_renv.txt") + message("Initializing run renv, see '", renvLogPath, "'...", appendLF = FALSE) + # init renv in a separate session so the libPaths of the current session remain unchanged + callr::r(createResultsfolderRenv, + wd = cfg$results_folder, + env = c(RENV_PATHS_LIBRARY = "renv/library"), + stdout = renvLogPath, stderr = "2>&1") + message("done.") } + # If available (i.e. paths are set) extract bioenergy and/or GHG prices + # from REMIND report and save them to the respective input folders + # Please note: For them to be used by the model, either the 'coupling' scenario + # must be selected or the corresponding switches must be set individually. + getReportData(cfg$path_to_report_bioenergy, cfg$path_to_report_ghgprices) + # update all parameters which contain the levels and marginals # of all variables and equations - lucode::update_fulldataOutput() + gms::update_fulldataOutput() # Update module paths in GAMS code - lucode::update_modules_embedding() + gms::update_modules_embedding() apply_cfg <- function(cfg) { if(is.null(cfg$model)) cfg$model <- "main.gms" # configure main model gms file (cfg$model) based on settings of cfg file - lucode::manipulateConfig(cfg$model, cfg$gms) + lucode2::manipulateConfig(cfg$model, cfg$gms) # configure input.gms in all modules based on settings of cfg file - l1 <- lucode::path("modules", list.dirs("modules/", full.names = FALSE, + l1 <- file.path("modules", list.dirs("modules/", full.names = FALSE, recursive = FALSE)) for(l in l1) { - l2 <- lucode::path(l, list.dirs(l, full.names = FALSE, recursive = FALSE)) + l2 <- file.path(l, list.dirs(l, full.names = FALSE, recursive = FALSE)) for(ll in l2) { - if(file.exists(lucode::path(ll, "input.gms"))) { - lucode::manipulateConfig(lucode::path(ll, "input.gms"), cfg$gms) + if(file.exists(file.path(ll, "input.gms"))) { + lucode2::manipulateConfig(file.path(ll, "input.gms"), cfg$gms) } } } @@ -81,168 +350,21 @@ start_run <- function(cfg,scenario=NULL,codeCheck=TRUE, apply_cfg(cfg) #check all setglobal settings for consistency - lucode::settingsCheck() + gms::settingsCheck() - ########################################################################################################### - ############# PROCESSING INPUT DATA ###################### START ########################################## - ########################################################################################################### - ################################################################################ - # Define internal functions + ############# PROCESSING INPUT DATA ###################### START ############### ################################################################################ - .update_sets <- function(cpr,map) { - - reg1 <- unique(map$RegionCode) - reg2 <- names(cpr) - if(!all(union(reg1,reg2) %in% intersect(reg1,reg2))) { - stop("Inconsistent region information!", - "\n cpr info: ",paste(reg2,collapse=", "), - "\n spatial header info: ", paste(reg1,collapse=", ")) - } - - - j <- 0; cells <- NULL - for(i in 1:length(cpr)) { - cells <- c(cells,paste(names(cpr)[i],"_",j+1,"*",names(cpr)[i],"_",j+cpr[i],sep="")) - j <- j+cpr[i] - } - - .tmp <- function(x,prefix="", suffix1="", suffix2=" /", collapse=",", n=10) { - content <- NULL - tmp <- lapply(split(x, ceiling(seq_along(x)/n)),paste,collapse=collapse) - end <- suffix1 - for(i in 1:length(tmp)) { - if(i==length(tmp)) end <- suffix2 - content <- c(content,paste0(' ',prefix,tmp[[i]],end)) - } - return(content) - } - - subject <- 'SETS' - modification_warning <- c( - '*THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY', - '*ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT INPUT DOWNLOAD', - '*CHANGES CAN BE DONE USING THE INPUT DOWNLOADER UNDER SCRIPTS/DOWNLOAD', - '*THERE YOU CAN ALSO FIND ADDITIONAL INFORMATION') - content <- c(modification_warning,'','sets','') - - content <- c(content,paste(' i all economic regions /',paste(names(cpr),collapse=','),'/',sep=''),'') - - # write iso set with nice formatting (10 countries per line) - tmp <- lapply(split(map$CountryCode, ceiling(seq_along(map$CountryCode)/10)),paste,collapse=",") - content <- c(content,' iso list of iso countries /') - content <- c(content, .tmp(map$CountryCode, suffix1=",", suffix2=" /")) - - content <- c(content, '', paste(' j number of LPJ cells /\n ',paste(cells,collapse=',\n '),'/',sep=''),'', - ' cell(i,j) number of LPJ cells per region i',' /') - for(i in 1:length(cpr)) { - content <- c(content,paste(' ',names(cpr)[i],' . ',cells[i],sep='')) - } - content <- c(content,' /','') - - content <- c(content,' i_to_iso(i,iso) mapping regions to iso countries',' /') - map$RegionCode <- as.factor(map$RegionCode) - for(i in levels(map$RegionCode)) { - content <- c(content, .tmp(map$CountryCode[map$RegionCode==i], prefix=paste0(i," . ("), suffix1=")", suffix2=")")) - - } - content <- c(content,' /',';') - lucode::replace_in_file("core/sets.gms",content,subject) - } - - # Function to extract information from info.txt - .get_info <- function(file, grep_expression, sep, pattern="", replacement="") { - if(!file.exists(file)) return("#MISSING#") - file <- readLines(file, warn=FALSE) - tmp <- grep(grep_expression, file, value=TRUE) - tmp <- strsplit(tmp, sep) - tmp <- sapply(tmp, "[[", 2) - tmp <- gsub(pattern, replacement ,tmp) - if(all(!is.na(as.logical(tmp)))) return(as.vector(sapply(tmp, as.logical))) - if (all(!(regexpr("[a-zA-Z]",tmp) > 0))) { - tmp <- as.numeric(tmp) - } - return(tmp) - } - - #Define routine to update info file in input folder and info in main.gms - .update_info <- function(datasets, cpr, regionscode, reg_revision, warnings=NULL) { - - low_res <- .get_info("input/info.txt","^\\* Output ?resolution:",": ") - high_res <- .get_info("input/info.txt","^\\* Input ?resolution:",": ") - - info <- readLines('input/info.txt') - subject <- 'VERSION INFO' - - useddata <- NULL - for(dataset in rownames(datasets)) { - useddata <- c(useddata, - '', - paste('Used data set:',dataset), - paste('md5sum:',datasets[dataset,"md5"]), - paste('Repository:',datasets[dataset,"repo"])) - } - - warnings <- attr(datasets,"warnings") - if(!is.null(warnings)) { - warnings <- capture.output(warnings) - } - - content <- c(useddata, - '', - paste('Low resolution:',low_res), - paste('High resolution:',high_res), - '', - paste('Total number of cells:',sum(cpr)), - '', - 'Number of cells per region:', - paste(format(names(cpr),width=5,justify="right"),collapse=""), - paste(format(cpr,width=5),collapse=""), - '', - paste('Regionscode:',regionscode), - '', - paste('Regions data revision:',reg_revision), - '', - info, - '', - warnings, - '', - paste('Last modification (input data):',date()), - '') - writeLines(content,'input/info.txt') - lucode::replace_in_file("main.gms",paste('*',content),subject) - } ################################################################################ ########## DOWNLOAD INPUT FILES and MANIPULATE GAMS FILES ###################### ################################################################################ input_old <- .get_info("input/info.txt", "^Used data set:", ": ") - input_new <- cfg$input - - if(!setequal(input_new, input_old) | cfg$force_download) { - # Delete previously downloaded files, download new files and distribute - # them within the model. - filemap <- lucode::download_distribute(files = input_new, - repositories = cfg$repositories, # defined in your local .Rprofile or on the cluster /p/projects/rd3mod/R/.Rprofile - modelfolder = ".", - additionalDelete="scripts/downloader/inputdelete.cfg", - debug = cfg$debug) - - # In the following the GAMS sourcecode files magpie.gms and core/sets.gms - # are manipulated. Therefore some information about the number of cells per - # region is required (CPR). This information is gained by extracting it from - # the avl_land.cs3 input file (any other cellular file could be used as well). - # This information is then transfered to .update_info, which is - # updating the general information in magpie.gms and input/info.txt - # and .update_sets, which is updating the resolution- and region-depending - # sets in core/sets.gms - tmp <- magclass::read.magpie("modules/10_land/input/avl_land_t.cs3") - cpr <- magclass::getCPR(tmp) - # read spatial_header, map, reg_revision and regionscode - load("input/spatial_header.rda") - .update_info(filemap,cpr,regionscode,reg_revision, warnings) - .update_sets(cpr,map) + + if(!setequal(cfg$input, input_old) | cfg$force_download) { + # download data and update code + download_and_update(cfg) } ########################################################################################################### @@ -272,9 +394,9 @@ start_run <- function(cfg,scenario=NULL,codeCheck=TRUE, "", "### Modifications ###", try(system("git status", intern=TRUE), silent=TRUE)) if(codeCheck) { - codeCheck <- lucode::codeCheck(core_files=c("core/*.gms",cfg$model), - test_switches=(cfg$model=="main.gms"), - strict=!cfg$developer_mode) + codeCheck <- gms::codeCheck(core_files=c("core/*.gms",cfg$model), + test_switches=(cfg$model=="main.gms"), + strict=!cfg$developer_mode) } else codeCheck <- NULL # Create the workspace for validation @@ -286,17 +408,17 @@ start_run <- function(cfg,scenario=NULL,codeCheck=TRUE, modules = codeCheck, input_data = list(), yield_calib = list(), - setup_info = list(start_functions = lucode::setup_info()), + setup_info = list(start_functions = lucode2::setup_info()), last.warning = attr(codeCheck,"last.warning"))) save(validation, file= cfg$val_workspace, compress="xz") - lucode::runstatistics(file = paste0(cfg$results_folder,"/runstatistics.rda"), - user = Sys.info()[["user"]], - date = rundate, - version_management = "git", - revision = try(system("git rev-parse HEAD", intern=TRUE), silent=TRUE), - revision_date = try(as.POSIXct(system("git show -s --format=%ci", intern=TRUE), silent=TRUE)), - status = try(system("git status", intern=TRUE), silent=TRUE)) + lucode2::runstatistics(file = paste0(cfg$results_folder,"/runstatistics.rda"), + user = Sys.info()[["user"]], + date = rundate, + version_management = "git", + revision = try(system("git rev-parse HEAD", intern = TRUE), silent=TRUE), + revision_date = try(as.POSIXct(system("git show -s --format=%ci", intern = TRUE), silent = TRUE)), + status = try(system("git status", intern = TRUE), silent = TRUE)) ############################################################################## @@ -312,59 +434,121 @@ start_run <- function(cfg,scenario=NULL,codeCheck=TRUE, } # Yield calibration + + # check for inconsistent settings + if((cfg$recalibrate == TRUE || cfg$recalibrate == "ifneeded") + && cfg$gms$s14_use_yield_calib == 0) { + 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. + 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(!file.exists(calib_file)) stop("Yield calibration file missing!") if(cfg$recalibrate=="ifneeded") { - # recalibrate if all calibration factors are 1, otherwise don't - cfg$recalibrate <- all(magclass::read.magpie(calib_file)==1) + if(!file.exists(calib_file)) { + # recalibrate if file does not exist + cfg$recalibrate <- TRUE + } else { + # recalibrate if all calibration factors are 1, otherwise don't + cfg$recalibrate <- all(magclass::read.magpie(calib_file)==1) + } } + if(cfg$recalibrate){ - cat("Starting calibration factor calculation!\n") + cat("Starting yield calibration factor calculation!\n") source("scripts/calibration/calc_calib.R") calibrate_magpie(n_maxcalib = cfg$calib_maxiter, calib_accuracy = cfg$calib_accuracy, - calibrate_pasture = (cfg$gms$past!="static"), + calibrate_pasture = (cfg$gms$past!="static" & cfg$gms$past!="grasslands_apr22"), calibrate_cropland = (cfg$calib_cropland), damping_factor = cfg$damping_factor, + crop_max = cfg$crop_calib_max, calib_file = calib_file, data_workspace = cfg$val_workspace, logoption = 3, - debug = cfg$debug) + debug = cfg$debug, + best_calib = cfg$best_calib) file.copy("calibration_results.pdf", cfg$results_folder, overwrite=TRUE) - cat("Calibration factor calculated!\n") + cat("Yield calibration factor calculated!\n") } - # copy important files into output_folder (before MAgPIE execution) - for(file in cfg$files2export$start) { - try(file.copy(Sys.glob(file), cfg$results_folder, overwrite=TRUE)) + land_calib_file <- "modules/39_landconversion/input/f39_calib.csv" + if(cfg$recalibrate_landconversion_cost=="ifneeded") { + # recalibrate if file does not exist + if(!file.exists(land_calib_file)) cfg$recalibrate_landconversion_cost <- TRUE else cfg$recalibrate_landconversion_cost <- FALSE + } + if(cfg$recalibrate_landconversion_cost){ + #if(cfg$gms$landconversion!="devstate") stop("Land conversion cost calibration works only with realization devstate") + cat("Starting land conversion cost calibration factor calculation!\n") + source("scripts/calibration/landconversion_cost.R") + calibrate_magpie(n_maxcalib = cfg$calib_maxiter_landconversion_cost, + restart = cfg$restart_landconversion_cost, + calib_accuracy = cfg$calib_accuracy_landconversion_cost, + lowpass_filter = cfg$lowpass_filter_landconversion_cost, + cost_max = cfg$cost_calib_max_landconversion_cost, + cost_min = cfg$cost_calib_min_landconversion_cost, + calib_file = land_calib_file, + data_workspace = cfg$val_workspace, + logoption = 3, + debug = cfg$debug, + best_calib = cfg$best_calib_landconversion_cost, + histData = cfg$cost_calib_hist_data) + cat("Land conversion cost calibration factor calculated!\n") } - # copy spam files to output folder - cfg$files2export$spam <- list.files(path="input/cellular", pattern = "*.spam", - full.names=TRUE) - for(file in cfg$files2export$spam) { - file.copy(file, cfg$results_folder, overwrite=TRUE) + # copy important files into output_folder (before MAgPIE execution) + for(file in cfg$files2export$start) { + try(file.copy(Sys.glob(file), cfg$results_folder, overwrite = TRUE)) } cfg$magpie_folder <- getwd() + # only store repository paths, not their credentials + cfg$repositories <- sapply(names(cfg$repositories), function(x) NULL) + # store config in human and machine readable form + gms::saveConfig(cfg, file.path(cfg$results_folder, "config.yml")) - save(cfg, file=lucode::path(cfg$results_folder, "config.Rdata")) - - lucode::singleGAMSfile(mainfile=cfg$model, output=lucode::path(cfg$results_folder, "full.gms")) + gms::singleGAMSfile(mainfile=cfg$model, output=file.path(cfg$results_folder, "full.gms")) if(lock_model) { - lucode::model_unlock(lock_id) - on.exit(setwd(maindir)) + gms::model_unlock(lock_id) + withr::defer(setwd(maindir)) } setwd(cfg$results_folder) + # Save run statistics to local file + cat("Saving timePrepareStart and timePrepareEnd to runstatistics.rda\n") + timePrepareEnd <- Sys.time() + lucode2::runstatistics(file = "runstatistics.rda", + timePrepareStart = timePrepareStart, + timePrepareEnd = timePrepareEnd) + #Is SLURM available? - slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE)) + slurm <- lucode2::SystemCommandAvailable("srun") if(is.na(cfg$sequential)) cfg$sequential <- !slurm - if(slurm & !cfg$sequential) { - system("sbatch submit.sh") + if(slurm && !cfg$sequential) { + if(is.null(cfg$qos)) { + # try to select best QOS based on available resources + # and available information + load <- lucode2::getClusterLoad() + if(is.null(load)) { + cfg$qos <- "standby" + } else if(all(load > 80)) { + cfg$qos <- "priority" + } else if(all(c("priority", "standard") %in% names(load)) && load["priority"] < load["standard"]) { + cfg$qos <- "standby" + } else { + cfg$qos <- "short" + } + } + submitfile <- paste0("submit_",cfg$qos,".sh") + if(!file.exists(submitfile)) stop("Submit script ",submitfile," not found!") + system(paste("sbatch",submitfile)) + cat("Run submitted with ",submitfile,"!\n",sep="") } else { system("Rscript submit.R", wait=cfg$sequential) } @@ -372,80 +556,112 @@ start_run <- function(cfg,scenario=NULL,codeCheck=TRUE, return(cfg$results_folder) } -getReportData <- function(rep,scen,LU_pricing="y2010") { +getReportData <- function(path_to_report_bioenergy, path_to_report_ghgprices = NA) { if (!requireNamespace("magclass", quietly = TRUE)) { stop("Package \"magclass\" needed for this function to work. Please install it.", call. = FALSE) } - .bioenergy_demand <- function(mag){ + .bioenergyDemand <- function(mag){ notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")] out <- mag[,,"Primary Energy Production|Biomass|Energy Crops (EJ/yr)"]*10^3 dimnames(out)[[3]] <- NULL - write.magpie(out[notGLO,,],"./modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv") + # delete old input file before updating it + f <- "./modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv" + suppressWarnings(unlink(f)) + write.magpie(out[notGLO,,],f) } - .emission_prices <- function(mag){ - out_c <- mag[,,"Price|Carbon (US$2005/t CO2)"]*44/12 # US$2005/tCO2 -> US$2005/tC + + .emissionPrices <- function(mag){ + out_c <- mag[,,"Price|Carbon (US$2017/t CO2)"]*44/12 # US$2017/tCO2 -> US$2017/tC dimnames(out_c)[[3]] <- "co2_c" - out_n2o_direct <- mag[,,"Price|N2O (US$2005/t N2O)"]*44/28 # US$2005/tN2O -> US$2005/tN + out_n2o_direct <- mag[,,"Price|N2O (US$2017/t N2O)"]*44/28 # US$2017/tN2O -> US$2017/tN dimnames(out_n2o_direct)[[3]] <- "n2o_n_direct" - out_n2o_indirect <- mag[,,"Price|N2O (US$2005/t N2O)"]*44/28 # US$2005/tN2O -> US$2005/tN + out_n2o_indirect <- mag[,,"Price|N2O (US$2017/t N2O)"]*44/28 # US$2017/tN2O -> US$2017/tN dimnames(out_n2o_indirect)[[3]] <- "n2o_n_indirect" - out_ch4 <- mag[,,"Price|CH4 (US$2005/t CH4)"] + out_ch4 <- mag[,,"Price|CH4 (US$2017/t CH4)"] dimnames(out_ch4)[[3]] <- "ch4" out <- mbind(out_n2o_direct,out_n2o_indirect,out_ch4,out_c) - # Set prices to zero before and in the year given in LU_pricing - y_zeroprices <- getYears(mag)<=LU_pricing - out[,y_zeroprices,]<-0 - # Remove GLO region notGLO <- getRegions(mag)[!(getRegions(mag)=="GLO")] - write.magpie(out[notGLO,,],"./modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3") + # delete old input file before updating it + f <- "./modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3" + suppressWarnings(unlink(f)) + write.magpie(out[notGLO,,],f) } - if (length(scen)!=1) stop("getReportData: 'scen' does not contain exactly one scenario.") - if (length(intersect(scen,names(rep)))!=1) stop("getReportData: 'scen not contained in 'rep'.") - - files <- c("./modules/56_ghg_policy/input/f56_pollutant_prices_coupling.cs3","./modules/60_bioenergy/input/reg.2ndgen_bioenergy_demand.csv") - years <- 1990+5*(1:32) - for(f in files) suppressWarnings(unlink(f)) - mag <- rep[[scen]][["MAgPIE"]] - if(!("y1995" %in% getYears(mag))){ - empty95<-mag[,1,];empty95[,,]<-0;dimnames(empty95)[[2]] <- "y1995" - mag <- mbind(empty95,mag) + .readAndPrepare <- function(mifPath) { + require(magclass) + rep <- read.report(mifPath, as.list = FALSE) + if (length(getNames(rep, dim = "scenario")) != 1) stop("getReportData: report contains more or less than 1 scenario.") + mag <- collapseNames(rep) # get rid of scenario and model dimension if they exist + + if(!("y1995" %in% getYears(mag))){ + empty95 <- mag[, 1,] + empty95[,,] <- 0 + dimnames(empty95)[[2]] <- "y1995" + mag <- mbind(empty95, mag) + } + years <- 1990 + 5 * seq_len(32) + mag <- time_interpolate(mag, years) + return(mag) } - mag <- time_interpolate(mag,years) - .bioenergy_demand(mag) - .emission_prices(mag) -} - -start_reportrun <- function (cfg, path_report, inmodel=NULL, sceninreport=NULL, codeCheck=FALSE){ - if (!requireNamespace("magclass", quietly = TRUE)) { - stop("Package \"magclass\" needed for this function to work. Please install it.", - call. = FALSE) - } - if (!requireNamespace("lucode", quietly = TRUE)) { - stop("Package \"lucode\" needed for this function to work. Please install it.", - call. = FALSE) + # if paths are provided, read bioenergy demand and ghg prices from REMIND reports + if (!is.na(path_to_report_bioenergy)) { + message("Reading bioenergy_demand from ", path_to_report_bioenergy) + mag <- .readAndPrepare(path_to_report_bioenergy) + .bioenergyDemand(mag) + + if (path_to_report_ghgprices %in% path_to_report_bioenergy) { + message("Reading ghg prices from the same file (", path_to_report_bioenergy, ")") + .emissionPrices(mag) + } } - rep <- magclass::convert.report(path_report,inmodel=inmodel,outmodel="MAgPIE") - magclass::write.report(rep,"report.mif") - if (!is.null(sceninreport)) - sceninreport <- intersect(sceninreport,names(rep)) - else - sceninreport <- names(rep) - - for(scen in sceninreport) { - cfg$title <- scen - # extract scenario from scenarioname and apply it - cfg <- lucode::setScenario(cfg,substring(scen,first=1,last=4)) - start_run(cfg, report=rep, sceninreport=scen, codeCheck=codeCheck) + + # read ghg prices from another REMIND report because path_to_report_bioenergy + # is different from path_to_report_ghgprices (including NA) + if (!is.na(path_to_report_ghgprices) && ! path_to_report_ghgprices %in% path_to_report_bioenergy) { + message("Reading ghg prices from ", path_to_report_ghgprices) + ghgmag <- .readAndPrepare(path_to_report_ghgprices) + .emissionPrices(ghgmag) } } + +# Will not actually solve the model: after compilation, this just copies the results +# of a previous run, useful for testing compilation and input/output handling. +# Used in scripts/start/extra/empty_model.R and tests for REMIND-MAgPIE coupling. +configureEmptyModel <- function(cfg, inputGdxPath) { + message("Configuring to use empty MAgPIE model, reproduces prior run ", inputGdxPath) + originalModel <- withr::local_connection(file(cfg$model, "r")) + emptyModelFile <- "standalone/empty_test_model.gms" + emptyModel <- withr::local_connection(file(emptyModelFile, "w")) + while (TRUE) { + originalLine <- readLines(originalModel, n = 1) + if (length(originalLine) == 0) { + break + } + writeLines(originalLine, emptyModel) + if (grepl("*END MODULE SETUP*", originalLine)) { + # add code for short-circuiting the model + writeLines(c( + "***********************TEST USING EMPTY MODEL***********************************", + "*** empty model just uses input gdx as the result", + "*** rest of the model is compiled, but not executed", + "$setglobal c_input_gdx_path path", + "execute \"cp %c_input_gdx_path% fulldata.gdx\";", + "abort.noerror \"cp %c_input_gdx_path% fulldata.gdx\";", + "********************************************************************************"), + emptyModel) + } + } + cfg$model <- emptyModelFile + cfg$gms$c_input_gdx_path <- inputGdxPath + return(cfg) +} diff --git a/standalone/.gitignore b/standalone/.gitignore new file mode 100644 index 0000000000..f836b512c0 --- /dev/null +++ b/standalone/.gitignore @@ -0,0 +1 @@ +empty_test_model.gms 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. diff --git a/standalone/demand_model.gms b/standalone/demand_model.gms index bf951b1b48..8b23152a89 100644 --- a/standalone/demand_model.gms +++ b/standalone/demand_model.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 @@ -13,6 +13,12 @@ $offsymlist $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 @@ -26,15 +32,28 @@ $include "./core/sets.gms" $batinclude "./modules/include.gms" sets sets - kap(kall) + kap(kall) animal products including fish / livst_rum,livst_pig,livst_chick, livst_egg, livst_milk, fish / - kli(kap) + kli(kap) livestock products / 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 + / + ; diff --git a/standalone/template.gms b/standalone/template.gms index 48261810a3..bd4395ffa4 100644 --- a/standalone/template.gms +++ b/standalone/template.gms @@ -1,4 +1,4 @@ -*** | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +*** | (C) 2008-2025 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 diff --git a/start.R b/start.R index c3ad8a6210..8270270884 100644 --- a/start.R +++ b/start.R @@ -1,4 +1,4 @@ -# | (C) 2008-2019 Potsdam Institute for Climate Impact Research (PIK) +# | (C) 2008-2025 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 @@ -9,125 +9,90 @@ #### MAgPIE output generation #### ########################################################## -library(lucode) - -runOutputs <- function(runscripts=NULL, submit=NULL) { +if (!is.null(renv::project())) { + ask <- function(question) { + message(question, appendLF = FALSE) + return(tolower(gms::getLine()) %in% c("", "y", "yes")) + } - get_line <- function(){ - # gets characters (line) from the terminal or from a connection - # and returns it - if(interactive()){ - s <- readline() - } else { - con <- file("stdin") - s <- readLines(con, 1, warn=FALSE) - on.exit(close(con)) - } - return(s); + message("Checking for updates... ", appendLF = FALSE) + if (getOption("autoRenvUpdates", FALSE) || + (!is.null(piamenv::showUpdates()) && ask("Update now? (Y/n): "))) { + updates <- piamenv::updateRenv() + piamenv::stopIfLoaded(names(updates)) } + message("Update check done.") + message("Checking package version requirements... ", appendLF = FALSE) + updates <- piamenv::fixDeps(ask = TRUE) + piamenv::stopIfLoaded(names(updates)) + message("Requirements check done.") +} - choose_module <- function(Rfolder,title="Please choose an outputmodule") { - forder <- paste0(Rfolder,"/order.cfg") - if(file.exists(forder)) { - order <- grep("(#|^$)",readLines(forder),invert=TRUE,value=TRUE) - if(length(order)==0) order <- NULL - } else { - order <- NULL - } - module <- gsub("\\.R$","",grep("\\.R$",list.files(Rfolder), value=TRUE)) - #sort modules based on order.cfg - module <- intersect(union(order,module),module) - cat("\n",title,":\n", sep="") - cat(paste(1: length(module), gsub("_"," ",module,fixed=TRUE), sep=": " ),sep="\n") - cat("Number: ") - identifier <- get_line() - identifier <- as.numeric(strsplit(identifier,",")[[1]]) - if (any(!(identifier %in% 1:length(module)))) stop("This choice (",identifier,") is not possible. Please type in a number between 1 and ",length(module)) - return(module[identifier]) - } +library(lucode2) +library(gms) +source("scripts/helper.R") - choose_submit <- function(title="Please choose run submission type") { - slurm <- suppressWarnings(ifelse(system2("srun",stdout=FALSE,stderr=FALSE) != 127, TRUE, FALSE)) - modes <- c("SLURM priority", - "SLURM standby", - "Direct execution", - "Background execution", - "Debug mode") - if(slurm) { - cat("\nCurrent cluster utilization:\n") - system("sclass") - cat("\n") - } else { - modes <- grep("SLURM",modes,invert=TRUE,value=TRUE) - } - cat("\n",title,":\n", sep="") - cat(paste(1:length(modes), modes, sep=": " ),sep="\n") - cat("Number: ") - identifier <- get_line() - identifier <- as.numeric(strsplit(identifier,",")[[1]]) - if(slurm) { - comp <- switch(identifier, - "1" = "slurmpriority", - "2" = "slurmstandby", - "3" = "direct", - "4" = "background", - "5" = "debug") - } else { - comp <- switch(identifier, - "1" = "direct", - "2" = "background", - "3" = "debug") - } - if(is.null(comp)) stop("This type is invalid. Please choose a valid type") - return(comp) - } +runOutputs <- function(runscripts=NULL, submit=NULL) { - runsubmit <- function(runscripts, submit) { + runSubmit <- function(runscripts, submit, + slurmModes="scripts/slurmStart.yml") { + if(!dir.exists("logs")) dir.create("logs") + for(rout in runscripts){ - name <- paste0("./scripts/start/",rout,".R") - - if(!file.exists(name)) { - warning("Script ",name, " could not be found. Skip execution!") - next + script <- paste0("./scripts/start/",rout) + if(!file.exists(script)) { + script <- paste0(script,".R") + if(!file.exists(script)) { + warning("Script ",script, " could not be found. Skip execution!") + next + } } - cat("Executing",name,"\n") - srun_command <- paste0("srun --job-name=",rout," --output=",rout,"-%j.out --mail-type=END") - if(submit=="direct") { + cat("Executing",script,"\n") + name <- sub("\\.R$","",sub("/","_",rout)) + if(submit %in% c("Direct execution", "direct")) { tmp.env <- new.env() - tmp.error <- try(sys.source(name,envir=tmp.env)) - if(!is.null(tmp.error)) warning("Script ",name," was stopped by an error and not executed properly!") + tmp.error <- try(sys.source(script, envir=tmp.env)) + if(!is.null(tmp.error)) warning("Script ",script," was stopped by an error and not executed properly!") rm(tmp.env) - } else if(submit=="background") { - log <- format(Sys.time(), paste0(rout,"-%Y-%H-%M-%S-%OS3.log")) - system2("Rscript",name, stderr = log, stdout = log, wait=FALSE) - } else if(submit=="slurmpriority") { - system(paste0(srun_command," --qos=priority Rscript ",name), wait=FALSE) - Sys.sleep(1) - } else if(submit=="slurmstandby") { - system(paste0(srun_command," --qos=standby Rscript ",name), wait=FALSE) - Sys.sleep(1) - } else if(submit=="debug") { + } else if(submit %in% c("Background execution", "background")) { + log <- format(Sys.time(), paste0("logs/", name, "-%Y-%H-%M-%S-%OS3.log")) + system2("Rscript",script, stderr = log, stdout = log, wait=FALSE) + } else if(submit %in% c("Debug mode", "debug")) { tmp.env <- new.env() - sys.source(name,envir=tmp.env) + sys.source(script,envir=tmp.env) rm(tmp.env) } else { - stop("Unknown submission type") + slurm <- yaml::read_yaml(slurmModes)$slurmjobs + if(submit %in% names(slurm)) { + command <- slurm[submit] + command <- gsub("%NAME", name, command) + command <- gsub("%SCRIPT", script, command) + message(command) + system(command) + Sys.sleep(1) + } else { + stop("Unknown submission type") + } } } } - - - if(is.null(runscripts)) runscripts <- choose_module("./scripts/start", - "Choose start script") - if(is.null(submit)) submit <- choose_submit("Choose submission type") - - runsubmit(runscripts, submit) + if(is.null(runscripts)) runscripts <- gms::selectScript("./scripts/start") + if(is.null(runscripts)) { + message("No start script selected! Stop here.") + return(invisible(NULL)) + } + if(is.null(submit)) submit <- chooseSubmit("Choose submission type", + slurmModes = "scripts/slurmStart.yml") + runSubmit(runscripts, submit) } -runscripts <- submit <- NULL -readArgs("runscripts","submit", .silent=TRUE) -runOutputs(runscripts=runscripts, submit=submit) +system("git config core.hooksPath .githooks") + +submit <- NULL +runscripts <- NULL +lucode2::readArgs("runscripts", "submit", .silent = TRUE) +runOutputs(runscripts = runscripts, submit = submit)