Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

update highres parallel opmization tc #720

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **config** initial treecover on cropland starts from zero
- **config** additional data update additional_data_rev4.53.tgz
- **29_cropland** added option for linear and sigmoidal faders
- **scripts** output/extra/highres.R use default 13_tc realization


### added
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Imports:
m4fsdp,
madrat,
magclass (>= 6.14.0),
magpie4 (>= 2.10.3),
magpie4 (>= 2.11.0),
MagpieNCGains,
magpiesets,
mip,
Expand Down
2 changes: 1 addition & 1 deletion modules/73_timber/default/equations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ q73_prod_woodfuel(j2)..
*' 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 recoverwed from forest and we assume 50% of residue
*' 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)
Expand Down
18 changes: 10 additions & 8 deletions scripts/output/extra/highres.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ resultsarchive <- "/p/projects/rd3mod/models/results/magpie"
# Load start_run(cfg) function which is needed to start MAgPIE runs
source("scripts/start_functions.R")

highres <- function(cfg) {
# 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))
Expand All @@ -46,9 +49,6 @@ highres <- function(cfg) {

cfg$output <- cfg$output[cfg$output!="extra/highres"]

# set high resolution, available options are c1000 and c2000
res <- "c1000"

# 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"],"_"))
Expand Down Expand Up @@ -139,10 +139,12 @@ highres <- function(cfg) {
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"))

#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 <- "exo"
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"
Expand Down
Loading