diff --git a/.buildlibrary b/.buildlibrary index 8a0bb389..913bd9e5 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '2246836734' +ValidationKey: '2246856528' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 30a59642..786ee459 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'remind2: The REMIND R package (2nd generation)' -version: 1.135.11 +version: 1.135.12 date-released: '2024-03-12' abstract: Contains the REMIND-specific routines for data and model output manipulation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 981c5733..c16b571a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: remind2 Title: The REMIND R package (2nd generation) -Version: 1.135.11 +Version: 1.135.12 Date: 2024-03-12 Authors@R: c( person("Renato", "Rodrigues", , "renato.rodrigues@pik-potsdam.de", role = c("aut", "cre")), diff --git a/R/reportEmi.R b/R/reportEmi.R index 55168c33..13e022a5 100644 --- a/R/reportEmi.R +++ b/R/reportEmi.R @@ -25,7 +25,8 @@ #' @importFrom tibble as_tibble -reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(2005, 2060, 5), seq(2070, 2110, 10), 2130, 2150)) { +reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, + t = c(seq(2005, 2060, 5), seq(2070, 2110, 10), 2130, 2150)) { # emissions calculation requires information from other reporting functions if (is.null(output)) { @@ -44,8 +45,6 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200 # unit conversion parameters needed - sm_TWa_2_MWh <- readGDX(gdx, "sm_TWa_2_MWh") # conversion of TWa (native REMIND energy units) to MWh - pm_conv_TWa_EJ <- readGDX(gdx, "pm_conv_TWa_EJ") # conversion of TWa (native REMIND energy units) to EJ sm_c_2_co2 <- readGDX(gdx, "sm_c_2_co2") GtC_2_MtCO2 <- sm_c_2_co2 * 1000 # conversion of GtC to MtCO2 sm_tgn_2_pgc <- readGDX(gdx, "sm_tgn_2_pgc") # conversion of GtN of N2 to GtC Co2eq @@ -59,12 +58,9 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200 cm_multigasscen <- readGDX(gdx, "cm_multigasscen") # sets required - emiTe <- readGDX(gdx, "emiTe") # emission gases emi2te <- readGDX(gdx, "emi2te") # conversions to emissions pe2se <- readGDX(gdx, "pe2se") # pe2se conversions se2fe <- readGDX(gdx, "se2fe") # se2fe conversions - emiMacSector2emiMac <- readGDX(gdx, "emiMacSector2emiMac") # MAC sector to emissions gas - peFos <- readGDX(gdx, "peFos") # fossil PE carriers emiInd37_fuel <- readGDX(gdx, "emiInd37_fuel") # energy-related industry CCS categories (excl. co2 cement CCS) emiMac2sector <- readGDX(gdx, "emiMac2sector") # mapping of MAC sectors to emissions sectors and gases macSector2emiMkt <- readGDX(gdx, "macSector2emiMkt") # mapping of MAC sectors to emissions markets @@ -79,8 +75,6 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200 teBio <- readGDX(gdx, "teBio") teFosCCS <- readGDX(gdx, "teFosCCS") - - # additional sets needed # SE carriers for solids, liquids, gases if ("seliqsyn" %in% se2fe$all_enty) { @@ -473,9 +467,9 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200 ) - # CO2 emissions from the end-of-life of carbon-bearing products + # CO2 emissions from the end-of-life of carbon-bearing products -if (!is.null(v37_plasticsCarbon)) { + if (!is.null(v37_plasticsCarbon)) { out <- mbind(out, setNames(dimSums(vm_feedstockEmiUnknownFate, dim=3)* GtC_2_MtCO2, "Emi|CO2|Energy|Waste|+|Feedstocks unknown fate (Mt CO2/yr)"), @@ -487,7 +481,7 @@ if (!is.null(v37_plasticsCarbon)) { + out[, , "Emi|CO2|Energy|Waste|+|Plastics Incineration (Mt CO2/yr)"], "Emi|CO2|Energy|+|Waste (Mt CO2/yr)") ) -} + } #### 2.1.2 Energy Supply ---- #### calculations required for coupled production @@ -523,19 +517,6 @@ if (!is.null(v37_plasticsCarbon)) { p_weights_cp <- p_weights_cp[, , emi.te.cp] p_weights_cp[is.na(p_weights_cp)] <- 0 - # # TODO: refactor this to a more elegant way at some point - # # assign 1 to those elements not in p_weight_cp - # - # df.emi.te.cp <- data.frame(all_enty=getItems(EmiPe2Se, dim="all_enty", full = T), - # all_enty1=getItems(EmiPe2Se, dim="all_enty1", full = T), - # all_te=getItems(EmiPe2Se, dim="all_te", full = T)) - # - # p_weights_test <- p_weights_cp[df.emi.te.cp] - # p_weights_test[is.na(p_weights_test)] <- 1 - # - # test <- p_weights_test*EmiPe2Se - - out <- mbind(out, @@ -596,14 +577,15 @@ if (!is.null(v37_plasticsCarbon)) { out <- mbind(out, setNames(dimSums(v_emiEnFuelEx[, , "co2"], dim = 3) * GtC_2_MtCO2, "Emi|CO2|Energy|Supply|Extraction (Mt CO2/yr)") - ) + ) # split into electric and non-electric energy supply emissions out <- mbind(out, # total gross non-eletric energy supply emissions setNames(out[, , "Emi|CO2|Energy|+|Supply (Mt CO2/yr)"] - out[, , "Emi|CO2|Energy|Supply|+|Electricity w/ couple prod (Mt CO2/yr)"], - "Emi|CO2|Energy|Supply|Non-electric (Mt CO2/yr)")) + "Emi|CO2|Energy|Supply|Non-electric (Mt CO2/yr)") + ) #### 2.1.3 Energy Demand ---- @@ -632,8 +614,6 @@ if (!is.null(v37_plasticsCarbon)) { # split of demand-side emissions into FE carriers and industry-specific reporting - - # reporting if FE per industry subsector o37_demFeIndSub exists if (!is.null(o37_demFeIndSub)) { @@ -668,8 +648,8 @@ if (!is.null(v37_plasticsCarbon)) { EmiIndSubSec <- pm_emifac.fe.indst * o37_demFeIndSub_woNonEn[, , getNames(pm_emifac.fe.indst)] # calculate demand-side Solids, Liquids and gases emissions (after industry CO2 Capture) - if (!is.null(v37_plasticsCarbon)){ - out <- mbind(out, + if (!is.null(v37_plasticsCarbon)) { + out <- mbind(out, # solids emissions: direct solids emissions of all sectors - industry CCS of solids setNames((dimSums(mselect(EmiFeCarrier, all_enty1 = "fesos"), dim = 3) @@ -691,7 +671,7 @@ if (!is.null(v37_plasticsCarbon)) { # substract synthetic and biogenic carbon contained in non-incinerated plastics - dimSums(mselect(vm_nonIncineratedPlastics, all_enty=c("segabio","segasyn"), all_enty1 = "fegas"), dim=3)) * GtC_2_MtCO2, "Emi|CO2|Energy|Demand|++|Gases (Mt CO2/yr)") - ) + ) } else { out <- mbind(out, @@ -709,7 +689,7 @@ if (!is.null(v37_plasticsCarbon)) { setNames((dimSums(mselect(EmiFeCarrier, all_enty1 = c("fegas", "fegat")), dim = 3) - dimSums(mselect(vm_emiIndCCS_Sub, all_enty1 = "fegas")*p_share_CCS, dim = 3)) * GtC_2_MtCO2, "Emi|CO2|Energy|Demand|++|Gases (Mt CO2/yr)") - ) + ) } # sectoral demand-side emissions across energy carriers @@ -728,11 +708,9 @@ if (!is.null(v37_plasticsCarbon)) { "Emi|CO2|Energy|Demand|Transport|+|Liquids (Mt CO2/yr)"), setNames((dimSums(mselect(EmiFeCarrier, all_enty1 = c("fegat"), emi_sectors = "trans"), dim = 3)) * GtC_2_MtCO2, "Emi|CO2|Energy|Demand|Transport|+|Gases (Mt CO2/yr)") + ) - - ) - - ##### industry ---- + ##### industry ---- variable_prefix <- 'Emi|CO2|Energy|Demand|Industry|' variable_postfix <- ' (Mt CO2/yr)' @@ -797,41 +775,40 @@ if (!is.null(v37_plasticsCarbon)) { 'Other Industry|Liquids|+|Fossil', 'otherInd', 'seliqfos', 'fehos', 'Other Industry|+|Gases', 'otherInd', NULL, 'fegas', 'Other Industry|Gases|+|Fossil', 'otherInd', 'segafos', 'fegas' -) %>% - mutate( - variable = paste0(variable_prefix, .data$variable, variable_postfix)) - - # if feedstocks are represented in REMIND - if (!is.null(v37_plasticsCarbon)){ + ) %>% + mutate( + variable = paste0(variable_prefix, .data$variable, variable_postfix)) + # if feedstocks are represented in REMIND + if (!is.null(v37_plasticsCarbon)) { plastic_CDR_SubSec <- add_dimension(plastic_CDR, dim = 3.1, add = 'secInd37', nm = 'chemicals') out <- mbind( - out, - lapply(.mixer_to_selector(mixer), function(x) { - setNames( - # extract relevant portions from EmiIndSubSec and vm_emiIndCCS_Sub, - # call mselect(), but without the 'variable' column - ( dimSums(mselect(EmiIndSubSec, x[setdiff(names(x), 'variable')]), - dim = 3) - - dimSums( - ( mselect(pm_IndstCO2Captured, x[setdiff(names(x), 'variable')]) - * p_share_CCS - ), - dim = 3) - # subtract carbon contained in plastics that are not incinerated - - dimSums( - ( mselect(plastic_CDR_SubSec, x[setdiff(names(x), 'variable')]) - ), - dim = 3) - ) * GtC_2_MtCO2, - x[['variable']]) - }) %>% + out, + lapply(.mixer_to_selector(mixer), function(x) { + setNames( + # extract relevant portions from EmiIndSubSec and vm_emiIndCCS_Sub, + # call mselect(), but without the 'variable' column + ( dimSums(mselect(EmiIndSubSec, x[setdiff(names(x), 'variable')]), + dim = 3) + - dimSums( + ( mselect(pm_IndstCO2Captured, x[setdiff(names(x), 'variable')]) + * p_share_CCS + ), + dim = 3) + # subtract carbon contained in plastics that are not incinerated + - dimSums( + ( mselect(plastic_CDR_SubSec, x[setdiff(names(x), 'variable')]) + ), + dim = 3) + ) * GtC_2_MtCO2, + x[['variable']]) + }) %>% mbind()) # Baseline emission before CCS, corresponds to energy carbon content - out <- mbind( + out <- mbind( # energy emissions - subsector_emissions %>% + subsector_emissions %>% mutate( secInd37 = case_when( 'cement' == .data$secInd37 ~ 'Cement', @@ -870,90 +847,89 @@ if (!is.null(v37_plasticsCarbon)) { `getNames<-`( value = 'Emi|CO2|pre-CCS|Industrial Processes|Cement (Mt CO2/yr)'), - out) - } - else { - out <- mbind( - out, + out + ) + } else { + out <- mbind( + out, + lapply(.mixer_to_selector(mixer), function(x) { + setNames( + # extract relevant portions from EmiIndSubSec and vm_emiIndCCS_Sub, + # call mselect(), but without the 'variable' column + ( dimSums(mselect(EmiIndSubSec, x[setdiff(names(x), 'variable')]), + dim = 3) + - dimSums( + ( mselect(pm_IndstCO2Captured, x[setdiff(names(x), 'variable')]) + * p_share_CCS + ), + dim = 3) + ) * GtC_2_MtCO2, + x[['variable']]) + }) %>% + mbind() + ) - lapply(.mixer_to_selector(mixer), function(x) { - setNames( - # extract relevant portions from EmiIndSubSec and vm_emiIndCCS_Sub, - # call mselect(), but without the 'variable' column - ( dimSums(mselect(EmiIndSubSec, x[setdiff(names(x), 'variable')]), - dim = 3) - - dimSums( - ( mselect(pm_IndstCO2Captured, x[setdiff(names(x), 'variable')]) - * p_share_CCS - ), - dim = 3) - ) * GtC_2_MtCO2, - x[['variable']]) - }) %>% - mbind() + # Baseline emission before CCS, corresponds to energy carbon content + out <- mbind( + # energy emissions + subsector_emissions %>% + mutate( + secInd37 = case_when( + 'cement' == .data$secInd37 ~ 'Cement', + 'chemicals' == .data$secInd37 ~ 'Chemicals', + 'steel' == .data$secInd37 ~ 'Steel', + 'otherInd' == .data$secInd37 ~ 'Other Industry', + TRUE ~ NA_character_), + fety = case_when( + 'fesos' == .data$fety ~ 'Solids', + 'fehos' == .data$fety ~ 'Liquids', + 'fegas' == .data$fety ~ 'Gases', + TRUE ~ NA_character_), + origin = case_when( + grepl('fos$', .data$sety) ~ 'Fossil', + grepl('bio$', .data$sety) ~ 'Biomass', + grepl('syn$', .data$sety) ~ 'Hydrogen', + TRUE ~ NA_character_)) %>% + assert(not_na, everything()) %>% + group_by(.data$t, .data$regi, .data$secInd37, .data$fety, + .data$origin) %>% + summarise(value = sum(.data$subsector_emissions) + * as.numeric(GtC_2_MtCO2), + .groups = 'drop') %>% + mutate(d3 = paste0('Emi|CO2|pre-CCS|Energy|Demand|Industry|', + .data$secInd37, '|', .data$fety, '|', .data$origin, + ' (Mt CO2/yr)')) %>% + select('t', 'regi', 'd3', 'value') %>% + as.magpie(spatial = 2, temporal = 1, datacol = ncol(.)) %>% + `getSets<-`(fulldim = FALSE, value = getSets(out)), + + out ) - # Baseline emission before CCS, corresponds to energy carbon content - out <- mbind( - # energy emissions - subsector_emissions %>% - mutate( - secInd37 = case_when( - 'cement' == .data$secInd37 ~ 'Cement', - 'chemicals' == .data$secInd37 ~ 'Chemicals', - 'steel' == .data$secInd37 ~ 'Steel', - 'otherInd' == .data$secInd37 ~ 'Other Industry', - TRUE ~ NA_character_), - fety = case_when( - 'fesos' == .data$fety ~ 'Solids', - 'fehos' == .data$fety ~ 'Liquids', - 'fegas' == .data$fety ~ 'Gases', - TRUE ~ NA_character_), - origin = case_when( - grepl('fos$', .data$sety) ~ 'Fossil', - grepl('bio$', .data$sety) ~ 'Biomass', - grepl('syn$', .data$sety) ~ 'Hydrogen', - TRUE ~ NA_character_)) %>% - assert(not_na, everything()) %>% - group_by(.data$t, .data$regi, .data$secInd37, .data$fety, - .data$origin) %>% - summarise(value = sum(.data$subsector_emissions) - * as.numeric(GtC_2_MtCO2), - .groups = 'drop') %>% - mutate(d3 = paste0('Emi|CO2|pre-CCS|Energy|Demand|Industry|', - .data$secInd37, '|', .data$fety, '|', .data$origin, - ' (Mt CO2/yr)')) %>% - select('t', 'regi', 'd3', 'value') %>% - as.magpie(spatial = 2, temporal = 1, datacol = ncol(.)) %>% - `getSets<-`(fulldim = FALSE, value = getSets(out)), - - out) - - # process emissions - emiIndBase <- readGDX(gdx, c('vm_emiIndBase', 'vm_macBaseInd'), field = 'l', restore_zeros = FALSE) - out <- mbind( - emiIndBase %>% - `[`(,,'co2cement_process.cement') %>% - `*`(as.numeric(GtC_2_MtCO2)) %>% - `getSets<-`(fulldim = FALSE, value = getSets(out)) %>% - `getNames<-`( - value = 'Emi|CO2|pre-CCS|Industrial Processes|Cement (Mt CO2/yr)'), + # process emissions + emiIndBase <- readGDX(gdx, c('vm_emiIndBase', 'vm_macBaseInd'), field = 'l', restore_zeros = FALSE) - out) - } + out <- mbind( + emiIndBase %>% + `[`(,,'co2cement_process.cement') %>% + `*`(as.numeric(GtC_2_MtCO2)) %>% + `getSets<-`(fulldim = FALSE, value = getSets(out)) %>% + `getNames<-`( + value = 'Emi|CO2|pre-CCS|Industrial Processes|Cement (Mt CO2/yr)'), + + out + ) + } } else { # if o37_demFeIndSub not existing in GDX, calculate reporting parameter here, note: works for industry fixed_shares only if (module2realisation["industry", 2] == "fixed_shares") { - - # fixed share of FE demand of industry subsector p37_shIndFE <- readGDX(gdx, "p37_shIndFE", restore_zeros = F) - # mapping of industry subsectors to industry CCS sectors - + # mapping of industry subsectors to industry CCS sectors # map from pffen to entyFE p37_shIndFE <- toolAggregate(p37_shIndFE, rel = fe2ppfEn %>% filter(all_in %in% getNames(p37_shIndFE, dim = 1)), @@ -966,21 +942,14 @@ if (!is.null(v37_plasticsCarbon)) { # set NAs in vm_demFeIndSub to zero vm_demFeIndSub[is.na(vm_demFeIndSub)] <- 0 - - # relabel industry energy CC from CCS sectors to industry sectors emiInd37 <- NULL vm_emiIndCCS_Mapped <- toolAggregate(vm_emiIndCCS[, , emiInd37_fuel], rel = secInd37_2_emiInd37 %>% filter(emiInd37 %in% emiInd37_fuel), from = "emiInd37", to = "secInd37", dim = 3) - # calculate captured CO2 per subsector and FE carrier by multiplying subsectoral share of fesos, fehos, fegas in total FE from fesos, fehos and fegas with the captured CO2 by subsector vm_emiIndCCS_Sub <- vm_emiIndCCS_Mapped * dimSums(mselect(vm_demFeIndSub, all_enty1 = c("fesos", "fehos", "fegas")), dim = c(3.1, 3.3, 3.4)) / dimSums(mselect(vm_demFeIndSub, all_enty1 = c("fesos", "fehos", "fegas")), dim = c(3.1, 3.2, 3.3, 3.4)) - - - - # calculate industry emissions by subsector (before industry CO2 Capture) sel_pm_emifac_feIndst_co2 <- if(getSets(pm_emifac)[[6]] == "emiAll"){ mselect(pm_emifac, all_enty1 = getNames(vm_demFeIndSub, dim = 2), emiAll = "co2") @@ -990,10 +959,6 @@ if (!is.null(v37_plasticsCarbon)) { pm_emifac.fe.indst <- dimSums(sel_pm_emifac_feIndst_co2, dim = c(3.3, 3.4)) EmiIndSubSec <- pm_emifac.fe.indst * vm_demFeIndSub[, , getNames(pm_emifac.fe.indst)] - - - - # calculate demand-side Solids, Liquids and gases emissions (after industry CO2 Capture) out <- mbind(out, @@ -1013,9 +978,7 @@ if (!is.null(v37_plasticsCarbon)) { "Emi|CO2|Energy|Demand|++|Gases (Mt CO2/yr)") ) - # sectoral demand-side emissions across energy carriers - out <- mbind(out, # industry solids emissions: direct solids emissions - industry CCS of solids @@ -1052,8 +1015,6 @@ if (!is.null(v37_plasticsCarbon)) { } - - } # emissions from international transport bunkers @@ -1074,9 +1035,6 @@ if (!is.null(v37_plasticsCarbon)) { setNames(bunkersEmi * (1-intraRegionFactor), "Emi|CO2|Energy|Demand|Transport|International Bunkers|+|Extra-region (Mt CO2/yr)") ) - # TODO: detailed transport, industry and buildings emissions could be appended here - # following e.g. "Emi|CO2|Energy|Demand|Transport|Passenger|+|Liquids" etc. - #### Total energy CO2 emissions sel_vm_emiTeMkt_co2 <- if (getSets(vm_emiTeMkt)[[3]] == "emiTe") { mselect(vm_emiTeMkt, emiTe = "co2") @@ -1093,7 +1051,8 @@ if (!is.null(v37_plasticsCarbon)) { # -> gets accounted in industrial process emissions - vm_emiIndCCS[, , "co2cement_process"]*(1-p_share_CCS) ) * GtC_2_MtCO2, - "Emi|CO2|+|Energy (Mt CO2/yr)")) + "Emi|CO2|+|Energy (Mt CO2/yr)") + ) ### 2.2 Non-energy CO2 emissions ---- # (following q_emiAllMkt) @@ -1108,8 +1067,7 @@ if (!is.null(v37_plasticsCarbon)) { } else { # otherwise chemical process emissions are 0 EmiProcess_Feedstocks <- vm_co2eq * 0 - } - + } # add industrial process emissions in steel and chemicals specifically for ARIADNE project where those emissions are included for Germany if (any(vm_emiMacSector[,,"co2steel"] > 0)) { @@ -1142,13 +1100,10 @@ if (!is.null(v37_plasticsCarbon)) { setNames((vm_emiCdrTeDetail[, , "weathering"] + vm_emiCdrTeDetail[, , "dac"] * p_share_CCS) * GtC_2_MtCO2, "Emi|CO2|+|non-BECCS CDR (Mt CO2/yr)") ) - - # in standard runs no steel and chemicals process emissions } else { - + # in standard runs no steel and chemicals process emissions # (following q_emiAllMkt) - out <- mbind(out, # industrial process CO2 (so far only cement process emissions in REMIND) setNames((dimSums(vm_emiMacSector[, , "co2cement_process"], dim = 3) @@ -1165,7 +1120,7 @@ if (!is.null(v37_plasticsCarbon)) { # chemical process emissions from feedstocks treatment setNames(dimSums(EmiProcess_Feedstocks, dim = 3)*GtC_2_MtCO2, "Emi|CO2|Industrial Processes|+|Chemicals (Mt CO2/yr)") - ) + ) out <- mbind(out, # land-use change CO2 @@ -1174,18 +1129,17 @@ if (!is.null(v37_plasticsCarbon)) { # negative emissions from (non-BECCS) CDR (DACCS, EW) setNames((vm_emiCdrTeDetail[, , "weathering"] + vm_emiCdrTeDetail[, , "dac"] * p_share_CCS) * GtC_2_MtCO2, "Emi|CO2|+|non-BECCS CDR (Mt CO2/yr)") - ) - + ) } - #### total energy and industry CO2 emissions # Emi|CO2|Energy|Waste|+|Plastics Incineration and Emi|CO2|Energy|Waste|+|Feedstocks unknown fate # are accounted for in vm_emiTeMkt and therefore in Emi|CO2|+|Energy (Mt CO2/yr) out <- mbind(out, setNames(out[, , "Emi|CO2|+|Energy (Mt CO2/yr)"] + out[, , "Emi|CO2|+|Industrial Processes (Mt CO2/yr)"], - "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)")) + "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)") + ) #### total CO2 emissions sel_vm_emiAllMkt_co2 <- if (getSets(vm_emiAllMkt)[[3]] == "emiTe") { @@ -1195,7 +1149,8 @@ if (!is.null(v37_plasticsCarbon)) { } out <- mbind(out, setNames(dimSums(sel_vm_emiAllMkt_co2, dim = 3) * GtC_2_MtCO2, - "Emi|CO2 (Mt CO2/yr)")) + "Emi|CO2 (Mt CO2/yr)") + ) ## 3. Carbon Management and CDR ---- @@ -1213,7 +1168,9 @@ if (!is.null(v37_plasticsCarbon)) { } else { mselect(pm_emifac, all_te = pe2se$all_te, all_enty2 = "cco2") } + pm_emifac.cco2.pe <- dimSums(sel_pm_emifac_pe2seCCO2, dim = c(3.4)) + CCO2Pe2Se <- pm_emifac.cco2.pe * vm_demPE[,,getNames(pm_emifac.cco2.pe)] # calculate weights of emissions distribution for coupled production @@ -1230,8 +1187,6 @@ if (!is.null(v37_plasticsCarbon)) { getItems(p_weights_cp_cco2, dim = 3, split = T, full = T)$all_te, sep = "."), getItems(CCO2Pe2Se, dim = 3)) - - # pe2se emissions technologies without coupled production cco2.te.nocp <- setdiff(getNames(CCO2Pe2Se), cco2.te.cp) @@ -1239,8 +1194,6 @@ if (!is.null(v37_plasticsCarbon)) { p_weights_cp_cco2 <- p_weights_cp_cco2[, , cco2.te.cp] p_weights_cp_cco2[is.na(p_weights_cp_cco2)] <- 0 - - # all pe2se BECC technologies te.becc <- intersect(teBio, teCCS) @@ -1291,7 +1244,6 @@ if (!is.null(v37_plasticsCarbon)) { "Carbon Management|Carbon Capture|Biomass|Pe2Se|+|Gases w/ couple prod (Mt CO2/yr)") ) - # pe2se fossil capture by SE carrier out <- mbind(out, @@ -1339,9 +1291,6 @@ if (!is.null(v37_plasticsCarbon)) { "Carbon Management|Carbon Capture|Fossil|Pe2Se|+|Gases w/ couple prod (Mt CO2/yr)") ) - - - # aggregate carbon capture/source variables out <- mbind(out, @@ -1369,9 +1318,8 @@ if (!is.null(v37_plasticsCarbon)) { # add materials-related carbon management variables only if available if (!is.null(v37_plasticsCarbon)){ - # carbon management: flows of carbon going into materials - out <- mbind(out, - + # carbon management: flows of carbon going into materials + out <- mbind(out, # carbon in plastics setNames(dimSums(v37_plasticsCarbon, dim = 3) * GtC_2_MtCO2, "Carbon Management|Materials|+|Plastics (Mt CO2/yr)"), @@ -1382,10 +1330,10 @@ if (!is.null(v37_plasticsCarbon)) { # other materials need to be added here setNames(dimSums(v37_plasticsCarbon, dim = 3) * GtC_2_MtCO2, "Carbon Management|Materials (Mt CO2/yr)") - ) + ) - # carbon management: fate of plastics - out <- mbind(out, + # carbon management: fate of plastics + out <- mbind(out, # carbon in plastics that are incinerated setNames(dimSums(vm_incinerationEmi, dim = 3) * GtC_2_MtCO2, @@ -1394,22 +1342,22 @@ if (!is.null(v37_plasticsCarbon)) { setNames(dimSums(vm_nonIncineratedPlastics, dim = 3) * GtC_2_MtCO2, "Carbon Management|Materials|Plastics|Waste|++|Other destination (Mt CO2/yr)") - ) - - # # carbon management: origin of plastics + ) - out <- mbind(out, + # carbon management: origin of plastics + out <- mbind(out, setNames(dimSums(mselect(v37_plasticsCarbon, all_enty=c("seliqsyn","sesosyn","segasyn")))* GtC_2_MtCO2, "Carbon Management|Materials|Plastics|+|Synfuels (Mt CO2/yr)"), setNames(dimSums(mselect(v37_plasticsCarbon, all_enty=c("seliqbio","sesobio","segabio")))* GtC_2_MtCO2, "Carbon Management|Materials|Plastics|+|Biomass (Mt CO2/yr)"), setNames(dimSums(mselect(v37_plasticsCarbon, all_enty=c("seliqfos","sesofos","segafos")))* GtC_2_MtCO2, "Carbon Management|Materials|Plastics|+|Fossil (Mt CO2/yr)") - ) + ) } ### report industry captured CO2 ---- if (!is.null(pm_IndstCO2Captured)) { + variable_prefix <- 'Carbon Management|Carbon Capture|Industry Energy|' variable_postfix <- ' (Mt CO2/yr)' @@ -1484,11 +1432,11 @@ if (!is.null(v37_plasticsCarbon)) { x[['variable']]) }) %>% mbind()) + } else { if (!is.null(o37_demFeIndSub)) { - # calculate bioenergy shares in industry solids, liquids and gases per subsector BioShare.FE.Indst <- dimSums(mselect(dimSums(o37_demFeIndSub, dim = c(3.4)) / dimSums(o37_demFeIndSub, dim = c(3.1, 3.4)), all_enty = c("sesobio", "seliqbio", "segabio"), all_enty1 = c("fesos", "fehos", "fegas")), dim = c(3.1)) # calculate synfuel shares in industry liquids and gases per subsector, only liquids and gases synfuels exist @@ -1496,7 +1444,6 @@ if (!is.null(v37_plasticsCarbon)) { # calculate fossil shares in industry solids, liquids and gases per subsector FosShare.FE.Indst <- dimSums(mselect(dimSums(o37_demFeIndSub, dim = c(3.4)) / dimSums(o37_demFeIndSub, dim = c(3.1, 3.4)), all_enty = c("sesofos", "seliqfos", "segafos"), all_enty1 = c("fesos", "fehos", "fegas")), dim = c(3.1)) - # if no solids/liquids/gases in subsector -> NaN, set share to zero BioShare.FE.Indst[is.nan(BioShare.FE.Indst)] <- 0 SynShare.FE.Indst[is.nan(SynShare.FE.Indst)] <- 0 @@ -1511,12 +1458,12 @@ if (!is.null(v37_plasticsCarbon)) { setNames(dimSums(FosShare.FE.Indst * vm_emiIndCCS_Sub, dim = 3) * GtC_2_MtCO2, "Carbon Management|Carbon Capture|Industry Energy|+|Fossil (Mt CO2/yr)")) - dimSums(vm_emiIndCCS[, , emiInd37_fuel], dim = 3) * GtC_2_MtCO2 } else { if (module2realisation["industry", 2] == "fixed_shares") { + # calculate bioenergy shares in industry solids, liquids and gases per subsector BioShare.FE.Indst <- dimSums(mselect(dimSums(vm_demFeIndSub, dim = c(3.4)) / dimSums(vm_demFeIndSub, dim = c(3.1, 3.4)), all_enty = c("sesobio", "seliqbio", "segabio"), all_enty1 = c("fesos", "fehos", "fegas")), dim = c(3.1, 3.3)) # calculate synfuel shares in industry liquids and gases per subsector, only liquids and gases synfuels exist @@ -1524,7 +1471,6 @@ if (!is.null(v37_plasticsCarbon)) { # calculate fossil shares in industry solids, liquids and gases per subsector FosShare.FE.Indst <- dimSums(mselect(dimSums(vm_demFeIndSub, dim = c(3.4)) / dimSums(vm_demFeIndSub, dim = c(3.1, 3.4)), all_enty = c("sesofos", "seliqfos", "segafos"), all_enty1 = c("fesos", "fehos", "fegas")), dim = c(3.1, 3.3)) - # if no solids/liquids/gases in subsector -> NaN, set share to zero BioShare.FE.Indst[is.nan(BioShare.FE.Indst)] <- 0 SynShare.FE.Indst[is.nan(SynShare.FE.Indst)] <- 0 @@ -1555,12 +1501,7 @@ if (!is.null(v37_plasticsCarbon)) { } - - - } - - } ### venting of captured carbon ---- @@ -1570,8 +1511,8 @@ if (!is.null(v37_plasticsCarbon)) { out <- mbind(out, # venting of captured carbon setNames(dimSums(v_co2capturevalve, dim = 3, na.rm = T) * GtC_2_MtCO2, - "Carbon Management|Venting of Captured Carbon (Mt CO2/yr)")) - + "Carbon Management|Venting of Captured Carbon (Mt CO2/yr)") + ) ### carbon usage ---- @@ -1605,6 +1546,7 @@ if (!is.null(v37_plasticsCarbon)) { setNames(dimSums(max_geolStorage, dim = 3, na.rm = T) * GtC_2_MtCO2, "Carbon Management|Storage|Maximum annual CO2 storage potential (Mt CO2/yr)") ) + # share of annual storage potential used out <- mbind(out, @@ -1675,8 +1617,8 @@ if (!is.null(v37_plasticsCarbon)) { "Carbon Management|Storage|Fossil|Pe2Se|+|Liquids w/ couple prod (Mt CO2/yr)"), setNames(out[, , "Carbon Management|Carbon Capture|Fossil|Pe2Se|+|Gases w/ couple prod (Mt CO2/yr)"] * p_share_CCS, - "Carbon Management|Storage|Fossil|Pe2Se|+|Gases w/ couple prod (Mt CO2/yr)")) - + "Carbon Management|Storage|Fossil|Pe2Se|+|Gases w/ couple prod (Mt CO2/yr)") + ) #### calculate corresponding negative emissions variables by CDR for bar plots with gross emissions # same as "Carbon Management|Storage|+|DAC (Mt CO2/yr)" etc. but negative @@ -1694,22 +1636,25 @@ if (!is.null(v37_plasticsCarbon)) { + out[, , "Carbon Management|Carbon Capture|Industry Energy|+|Biomass (Mt CO2/yr)"] + out[, , "Carbon Management|Carbon Capture|+|Fossil|Pe2Se (Mt CO2/yr)"] + out[, , "Carbon Management|Carbon Capture|Industry Energy|+|Fossil (Mt CO2/yr)"] - + out[, , "Carbon Management|Carbon Capture|+|Industry Process (Mt CO2/yr)"]) ,dim=3) + + out[, , "Carbon Management|Carbon Capture|+|Industry Process (Mt CO2/yr)"]) ,dim=3 + ) + p_share_atmosco2[is.infinite(p_share_atmosco2)] <- 0 p_share_atmosco2[is.na(p_share_atmosco2)] <- 0 # CDR reporting if plastic-removals are considered - if (!is.null(v37_plasticsCarbon)){ - # calculate share of atmospheric and biogenic carbon contained in plastic products - p_share_atmBiogco2 <- dimSums( - ( out[,,"Carbon Management|Materials|Plastics|+|Biomass (Mt CO2/yr)"] - +out[,,"Carbon Management|Materials|Plastics|+|Synfuels (Mt CO2/yr)"]*p_share_atmosco2) - /(out[,,"Carbon Management|Materials|+|Plastics (Mt CO2/yr)"]) - ) + if (!is.null(v37_plasticsCarbon)) { - # Emi|CO2|CDR is defined negative + # calculate share of atmospheric and biogenic carbon contained in plastic products + p_share_atmBiogco2 <- dimSums( + (out[, , "Carbon Management|Materials|Plastics|+|Biomass (Mt CO2/yr)"] + + out[, , "Carbon Management|Materials|Plastics|+|Synfuels (Mt CO2/yr)"] * p_share_atmosco2) / + out[, , "Carbon Management|Materials|+|Plastics (Mt CO2/yr)"] + ) - out <- mbind(out, + # Emi|CO2|CDR is defined negative + + out <- mbind(out, # total negative land-use change emissions setNames(EmiCDR.LUC, "Emi|CO2|CDR|Land-Use Change (Mt CO2/yr)"), @@ -1737,9 +1682,10 @@ if (!is.null(v37_plasticsCarbon)) { # total EW # total co2 captured by EW setNames(vm_emiCdrTeDetail[, , "weathering"] * GtC_2_MtCO2, - "Emi|CO2|CDR|EW (Mt CO2/yr)")) + "Emi|CO2|CDR|EW (Mt CO2/yr)") + ) - out <- mbind(out, + out <- mbind(out, # total CDR # double-check: if we don't account for fossil content in plastics, the emissions might not add up? setNames( out[, , "Emi|CO2|CDR|Land-Use Change (Mt CO2/yr)"] @@ -1748,9 +1694,13 @@ if (!is.null(v37_plasticsCarbon)) { + out[, , "Emi|CO2|CDR|EW (Mt CO2/yr)"] + out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] + out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], - "Emi|CO2|CDR (Mt CO2/yr)")) - #CDR reporting if plastic-removals are not considered - } else{ + "Emi|CO2|CDR (Mt CO2/yr)") + ) + + + } else { + # CDR reporting if plastic-removals are not considered + # Emi|CO2|CDR is defined negative out <- mbind(out, @@ -1776,7 +1726,8 @@ if (!is.null(v37_plasticsCarbon)) { # total EW # total co2 captured by EW setNames(vm_emiCdrTeDetail[, , "weathering"] * GtC_2_MtCO2, - "Emi|CO2|CDR|EW (Mt CO2/yr)")) + "Emi|CO2|CDR|EW (Mt CO2/yr)") + ) out <- mbind(out, # total CDR @@ -1786,7 +1737,8 @@ if (!is.null(v37_plasticsCarbon)) { + out[, , "Emi|CO2|CDR|DACCS (Mt CO2/yr)"] + out[, , "Emi|CO2|CDR|EW (Mt CO2/yr)"] + out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"], - "Emi|CO2|CDR (Mt CO2/yr)")) + "Emi|CO2|CDR (Mt CO2/yr)") + ) } ## 4. Gross Emissions (excl. negative emissions from storing non-fossil carbon from bioenergy or synthetic fuels) ---- @@ -1829,7 +1781,8 @@ if (!is.null(v37_plasticsCarbon)) { # total gross supply emissions setNames(out[, , "Emi|CO2|Energy|+|Supply (Mt CO2/yr)"] + out[, , "Carbon Management|Storage|+|Biomass|Pe2Se (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy|+|Supply (Mt CO2/yr)")) + "Emi|CO2|Gross|Energy|+|Supply (Mt CO2/yr)") + ) # calculate gross emissions in energy demand sectors out <- mbind(out, @@ -1848,78 +1801,79 @@ if (!is.null(v37_plasticsCarbon)) { setNames(out[, , "Emi|CO2|Energy|+|Demand (Mt CO2/yr)"] - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] - out[, , "Emi|CO2|CDR|BECCS|Industry (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy|+|Demand (Mt CO2/yr)")) - -########################################### -## Gross emissions in Energy|Waste sector## -########################################### - -if (!is.null(v37_plasticsCarbon)){ -# calculate gross emissions in energy waste sector - out <- mbind(out, - # total gross energy waste emissions - setNames(out[, , "Emi|CO2|Energy|+|Waste (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy|+|Waste (Mt CO2/yr)")) -} - -########################### -## total gross variables ## -########################### -# if feedstocks are available -if (!is.null(v37_plasticsCarbon)){ - out <- mbind(out, - # total gross energy emissions - setNames(out[, , "Emi|CO2|+|Energy (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy (Mt CO2/yr)"), - - # total gross energy and industrial process emissions - setNames(out[, , "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)"), - - # total gross emissions - setNames(out[, , "Emi|CO2 (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR (Mt CO2/yr)"], - "Emi|CO2|Gross (Mt CO2/yr)")) -} else { - # total gross variables if feedstocks are not available - out <- mbind(out, - # total gross energy emissions - setNames(out[, , "Emi|CO2|+|Energy (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy (Mt CO2/yr)"), + "Emi|CO2|Gross|Energy|+|Demand (Mt CO2/yr)") + ) - # total gross energy and industrial process emissions - setNames(out[, , "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)"), + ########################################### + ## Gross emissions in Energy|Waste sector## + ########################################### - # total gross emissions - setNames(out[, , "Emi|CO2 (Mt CO2/yr)"] - - out[, , "Emi|CO2|CDR (Mt CO2/yr)"], - "Emi|CO2|Gross (Mt CO2/yr)")) -} + if (!is.null(v37_plasticsCarbon)) { + # calculate gross emissions in energy waste sector + out <- mbind(out, + # total gross energy waste emissions + setNames(out[, , "Emi|CO2|Energy|+|Waste (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], + "Emi|CO2|Gross|Energy|+|Waste (Mt CO2/yr)")) + } + ########################### + ## total gross variables ## + ########################### + # if feedstocks are available + if (!is.null(v37_plasticsCarbon)) { + out <- mbind(out, + # total gross energy emissions + setNames(out[, , "Emi|CO2|+|Energy (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], + "Emi|CO2|Gross|Energy (Mt CO2/yr)"), + + # total gross energy and industrial process emissions + setNames(out[, , "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], + "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)"), + + # total gross emissions + setNames(out[, , "Emi|CO2 (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR (Mt CO2/yr)"], + "Emi|CO2|Gross (Mt CO2/yr)") + ) + } else { + # total gross variables if feedstocks are not available + out <- mbind(out, + # total gross energy emissions + setNames(out[, , "Emi|CO2|+|Energy (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"], + "Emi|CO2|Gross|Energy (Mt CO2/yr)"), + + # total gross energy and industrial process emissions + setNames(out[, , "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"], + "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)"), + + # total gross emissions + setNames(out[, , "Emi|CO2 (Mt CO2/yr)"] + - out[, , "Emi|CO2|CDR (Mt CO2/yr)"], + "Emi|CO2|Gross (Mt CO2/yr)") + ) + } # split into electric and non-electric energy supply emissions out <- mbind(out, # total gross non-eletric energy supply emissions setNames(out[, , "Emi|CO2|Gross|Energy|+|Supply (Mt CO2/yr)"] - out[, , "Emi|CO2|Gross|Energy|Supply|+|Electricity (Mt CO2/yr)"], - "Emi|CO2|Gross|Energy|Supply|Non-electric (Mt CO2/yr)")) - + "Emi|CO2|Gross|Energy|Supply|Non-electric (Mt CO2/yr)") + ) ## 5. Non-CO2 GHG Emissions ---- - # join mac mapping of sectors and markets mac.map <- right_join(emiMac2sector, macSector2emiMkt, by = "all_enty") @@ -1937,7 +1891,6 @@ if (!is.null(v37_plasticsCarbon)){ getSets(EmiMAC) <- c("region", "year", "macsector", "sector", "emiMkt", "gas") # rename dimensions for sake of understanding EmiMAC[, , mac.map$all_enty] <- vm_emiMacSector[, , mac.map$all_enty] - ### 5.1 non-CO2 GHG by sector ---- sel_vm_emiTeDetailMkt_ch4 <- if (getSets(vm_emiTeDetailMkt)[[6]] == "emiAll") { @@ -1951,6 +1904,7 @@ if (!is.null(v37_plasticsCarbon)){ } else { mselect(vm_emiTeDetailMkt, all_enty2 = "n2o") } + # CH4 and N2O Emissions by sector in native MtCH4 and kt N2O units out <- mbind(out, @@ -2072,8 +2026,6 @@ if (!is.null(v37_plasticsCarbon)){ ) } - - # CH4 and N2O Emissions by sector in MtCO2eq # convert to MAC emissions to Mt CO2eq @@ -2082,7 +2034,6 @@ if (!is.null(v37_plasticsCarbon)){ EmiMACEq[, , "ch4"] <- EmiMAC[, , "ch4"] * sm_tgch4_2_pgc * GtC_2_MtCO2 EmiMACEq[, , "n2o"] <- EmiMAC[, , "n2o"] * sm_tgn_2_pgc * GtC_2_MtCO2 - out <- mbind(out, # CH4 Emissions @@ -2124,16 +2075,12 @@ if (!is.null(v37_plasticsCarbon)){ "Emi|GHG|N2O|+|Energy Supply (Mt CO2eq/yr)") ) - - ### 5.2 Total GHG across sectors ---- ## GHG emissions across sectors # noting which IPCC sector it comes close to - - # Energy GHG Emissions incl. fugitive emissions (IPCC category 1) # Note: non-BECCS CDR is outside of our energy emissions, not clear how IPCC categories go about that out <- mbind(out, @@ -2142,39 +2089,46 @@ if (!is.null(v37_plasticsCarbon)){ + out[, , "Emi|GHG|CH4|+|Energy Supply (Mt CO2eq/yr)"] + out[, , "Emi|GHG|CH4|+|Extraction (Mt CO2eq/yr)"] + out[, , "Emi|GHG|N2O|+|Transport (Mt CO2eq/yr)"], - "Emi|GHG|+++|Energy (Mt CO2eq/yr)")) + "Emi|GHG|+++|Energy (Mt CO2eq/yr)") + ) # Industrial Process GHG Emissions (IPCC category 2) out <- mbind(out, setNames(out[, , "Emi|CO2|+|Industrial Processes (Mt CO2/yr)"] + out[, , "Emi|GHG|N2O|+|Industry (Mt CO2eq/yr)"] + out[, , "Emi|GHG|+|F-Gases (Mt CO2eq/yr)"] , - "Emi|GHG|+++|Industrial Processes (Mt CO2eq/yr)")) + "Emi|GHG|+++|Industrial Processes (Mt CO2eq/yr)") + ) out <- mbind(out, setNames(out[, , "Emi|CO2|+|Industrial Processes (Mt CO2/yr)"], - "Emi|GHG|Industrial Processes|+|CO2 (Mt CO2eq/yr)")) + "Emi|GHG|Industrial Processes|+|CO2 (Mt CO2eq/yr)") + ) out <- mbind(out, setNames(out[, , "Emi|GHG|N2O|+|Industry (Mt CO2eq/yr)"], - "Emi|GHG|Industrial Processes|+|N2O (Mt CO2eq/yr)")) + "Emi|GHG|Industrial Processes|+|N2O (Mt CO2eq/yr)") + ) out <- mbind(out, setNames(out[, , "Emi|GHG|+|F-Gases (Mt CO2eq/yr)"], - "Emi|GHG|Industrial Processes|+|F-Gases (Mt CO2eq/yr)")) + "Emi|GHG|Industrial Processes|+|F-Gases (Mt CO2eq/yr)") + ) # agriculture GHG Emissions (without energy-use in agriculture) (IPCC category 3) out <- mbind(out, setNames(out[, , "Emi|GHG|CH4|+|Agriculture (Mt CO2eq/yr)"] + out[, , "Emi|GHG|N2O|+|Agriculture (Mt CO2eq/yr)"], - "Emi|GHG|+++|Agriculture (Mt CO2eq/yr)")) + "Emi|GHG|+++|Agriculture (Mt CO2eq/yr)") + ) # LULUCF GHG Emissions (IPCC category 4) out <- mbind(out, setNames(out[, , "Emi|CO2|+|Land-Use Change (Mt CO2/yr)"] + out[, , "Emi|GHG|N2O|+|Land-Use Change (Mt CO2eq/yr)"] + out[, , "Emi|GHG|CH4|+|Land-Use Change (Mt CO2eq/yr)"], - "Emi|GHG|+++|Land-Use Change (Mt CO2eq/yr)")) + "Emi|GHG|+++|Land-Use Change (Mt CO2eq/yr)") + ) # Waste Emissions (IPCC category 5), # note: waste CO2 emissions from combustion of waste in incineration plants are accounted here but in industry energy demand emimssions @@ -2182,12 +2136,14 @@ if (!is.null(v37_plasticsCarbon)){ out <- mbind(out, setNames(out[, , "Emi|GHG|CH4|+|Waste (Mt CO2eq/yr)"] + out[, , "Emi|GHG|N2O|+|Waste (Mt CO2eq/yr)"], - "Emi|GHG|+++|Waste (Mt CO2eq/yr)")) + "Emi|GHG|+++|Waste (Mt CO2eq/yr)") + ) # non-BECCS CDR from CDR module out <- mbind(out, setNames(out[, , "Emi|CO2|+|non-BECCS CDR (Mt CO2/yr)"], - "Emi|GHG|+++|non-BECCS CDR (Mt CO2eq/yr)")) + "Emi|GHG|+++|non-BECCS CDR (Mt CO2eq/yr)") + ) ## GHG emissions within energy sector @@ -2197,14 +2153,15 @@ if (!is.null(v37_plasticsCarbon)){ + out[, , "Emi|GHG|N2O|+|Energy Supply (Mt CO2eq/yr)"] + out[, , "Emi|GHG|CH4|+|Energy Supply (Mt CO2eq/yr)"] + out[, , "Emi|GHG|CH4|+|Extraction (Mt CO2eq/yr)"], - "Emi|GHG|Energy|+|Supply (Mt CO2eq/yr)")) + "Emi|GHG|Energy|+|Supply (Mt CO2eq/yr)") + ) # GHG energy demand emissions out <- mbind(out, setNames(out[, , "Emi|CO2|Energy|+|Demand (Mt CO2/yr)"] + out[, , "Emi|GHG|N2O|+|Transport (Mt CO2eq/yr)"], - "Emi|GHG|Energy|+|Demand (Mt CO2eq/yr)")) - + "Emi|GHG|Energy|+|Demand (Mt CO2eq/yr)") + ) out <- mbind(out, setNames(out[, , "Emi|CO2|Energy|Demand|+|Buildings (Mt CO2/yr)"], @@ -2215,18 +2172,19 @@ if (!is.null(v37_plasticsCarbon)){ + out[, , "Emi|GHG|N2O|+|Transport (Mt CO2eq/yr)"], "Emi|GHG|Energy|Demand|+|Transport (Mt CO2eq/yr)"), setNames(out[, , "Emi|CO2|Energy|Demand|+|CDR (Mt CO2/yr)"], - "Emi|GHG|Energy|Demand|+|CDR (Mt CO2eq/yr)")) - -############################### -## GHG energy waste emissions## -############################### -# note that Emi|GHG|Energy|Waste corresponds to end-of-life emissions of products of the chemicals sector -# and it is different to Emi|GHG|+++|Waste -if (!is.null(v37_plasticsCarbon)){ - out <- mbind(out, - setNames(out[, , "Emi|CO2|Energy|+|Waste (Mt CO2/yr)"], - "Emi|GHG|Energy|+|Waste (Mt CO2eq/yr)")) -} + "Emi|GHG|Energy|Demand|+|CDR (Mt CO2eq/yr)") + ) + + ############################### + ## GHG energy waste emissions## + ############################### + # note that Emi|GHG|Energy|Waste corresponds to end-of-life emissions of products of the chemicals sector + # and it is different to Emi|GHG|+++|Waste + if (!is.null(v37_plasticsCarbon)) { + out <- mbind(out, + setNames(out[, , "Emi|CO2|Energy|+|Waste (Mt CO2/yr)"], + "Emi|GHG|Energy|+|Waste (Mt CO2eq/yr)")) + } ## gross GHG variables (ecxl. negative emissions from BECCS and carbon storage of carbon-neutral synthetic fuels) ## note Emi|CO2|CDR|... variables are negative. That's why we substract them to get from net to gross emissions. @@ -2237,7 +2195,6 @@ if (!is.null(v37_plasticsCarbon)){ - out[, , "Emi|CO2|CDR|BECCS|Pe2Se (Mt CO2/yr)"], "Emi|GHG|Gross|Energy|+|Supply (Mt CO2eq/yr)"), - # total gross demand emissions setNames(out[, , "Emi|GHG|Energy|+|Demand (Mt CO2eq/yr)"] - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] @@ -2249,27 +2206,24 @@ if (!is.null(v37_plasticsCarbon)){ - out[, , "Emi|CO2|CDR|BECCS|Industry (Mt CO2/yr)"], "Emi|GHG|Gross|Energy|Demand|+|Industry (Mt CO2eq/yr)"), - setNames(out[, , "Emi|GHG|Energy|Demand|+|Buildings (Mt CO2eq/yr)"], "Emi|GHG|Gross|Energy|Demand|+|Buildings (Mt CO2eq/yr)"), - setNames(out[, , "Emi|GHG|Energy|Demand|+|Transport (Mt CO2eq/yr)"], "Emi|GHG|Gross|Energy|Demand|+|Transport (Mt CO2eq/yr)"), - setNames(out[, , "Emi|GHG|Energy|Demand|+|CDR (Mt CO2eq/yr)"], "Emi|GHG|Gross|Energy|Demand|+|CDR (Mt CO2eq/yr)") ) -############################################# -## gross GHG variables if feedstocks exist ## -############################################# + ############################################# + ## gross GHG variables if feedstocks exist ## + ############################################# ##(ecxl. negative emissions from BECCS and carbon storage of carbon-neutral synthetic fuels) ## note Emi|CO2|CDR|... variables are negative. That's why we substract them to get from net to gross emissions. -if (!is.null(v37_plasticsCarbon)){ + if (!is.null(v37_plasticsCarbon)) { out <- mbind(out, # total gross waste emissions @@ -2283,30 +2237,29 @@ if (!is.null(v37_plasticsCarbon)){ - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"] - out[, , "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)"], "Emi|GHG|Gross|Energy (Mt CO2eq/yr)") - ) -} else { - # total gross energy emissions - out <- mbind(out, + ) + } else { + # total gross energy emissions + out <- mbind(out, setNames(out[, , "Emi|GHG|+++|Energy (Mt CO2eq/yr)"] - out[, , "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)"] - out[, , "Emi|CO2|CDR|BECCS (Mt CO2/yr)"], - "Emi|GHG|Gross|Energy (Mt CO2eq/yr)")) -} -## END of gross GHG variables if feedstocks exist ############################ + "Emi|GHG|Gross|Energy (Mt CO2eq/yr)") + ) + } + ## END of gross GHG variables if feedstocks exist ############################ # electric and non-electric supply GHG emissions (needed for total GHG stacked plots with gross emissions) - # split into electric and non-electric energy supply emissions out <- mbind(out, setNames(out[, , "Emi|CO2|Gross|Energy|Supply|+|Electricity (Mt CO2/yr)"], "Emi|GHG|Gross|Energy|Supply|Electricity (Mt CO2eq/yr)"), setNames(out[, , "Emi|GHG|Gross|Energy|+|Supply (Mt CO2eq/yr)"] - out[, , "Emi|CO2|Gross|Energy|Supply|+|Electricity (Mt CO2/yr)"], - "Emi|GHG|Gross|Energy|Supply|Non-electric (Mt CO2eq/yr)")) - - + "Emi|GHG|Gross|Energy|Supply|Non-electric (Mt CO2eq/yr)") + ) ## further GHG emissions variables per sector that are often needed @@ -2316,8 +2269,8 @@ if (!is.null(v37_plasticsCarbon)){ + out[, , "Emi|CO2|+|Industrial Processes (Mt CO2/yr)"] + out[, , "Emi|GHG|N2O|+|Industry (Mt CO2eq/yr)"] + out[, , "Emi|GHG|+|F-Gases (Mt CO2eq/yr)"] , - "Emi|GHG|Industry (Mt CO2eq/yr)")) - + "Emi|GHG|Industry (Mt CO2eq/yr)") + ) # AFOLU (agriculture and lulucf) GHG emissions (IPCC category 3 and 4) out <- mbind(out, @@ -2326,8 +2279,8 @@ if (!is.null(v37_plasticsCarbon)){ + out[, , "Emi|GHG|CH4|+|Land-Use Change (Mt CO2eq/yr)"] + out[, , "Emi|GHG|CH4|+|Agriculture (Mt CO2eq/yr)"] + out[, , "Emi|GHG|N2O|+|Agriculture (Mt CO2eq/yr)"], - "Emi|GHG|AFOLU (Mt CO2eq/yr)")) - + "Emi|GHG|AFOLU (Mt CO2eq/yr)") + ) ### 5.3 PFCs ---- out <- mbind(out, @@ -2335,9 +2288,8 @@ if (!is.null(v37_plasticsCarbon)){ setNames(vm_emiFgas[, , "emiFgasC2F6"], "Emi|C2F6 (kt C2F6/yr)"), setNames(vm_emiFgas[, , "emiFgasC6F14"], "Emi|C6F14 (kt C6F14/yr)"), setNames(vm_emiFgas[, , "emiFgasHFC"], "Emi|HFC (kt HFC134a-equiv/yr)"), - setNames(vm_emiFgas[, , "emiFgasSF6"], "Emi|SF6 (kt SF6/yr)")) - - + setNames(vm_emiFgas[, , "emiFgasSF6"], "Emi|SF6 (kt SF6/yr)") + ) ## 6. Emissions across markets ---- if (getSets(vm_emiAllMkt)[[3]] == "emiTe") { @@ -2375,7 +2327,8 @@ if (!is.null(v37_plasticsCarbon)){ + dimSums(sel_vm_emiAllMkt_CH4_other, dim = 3) * sm_tgch4_2_pgc * GtC_2_MtCO2 + dimSums(sel_vm_emiAllMkt_N2O_other, dim = 3) * sm_tgn_2_pgc * GtC_2_MtCO2 + dimSums(vm_emiFgas[, , "emiFgasTotal"], dim = 3), - "Emi|GHG|++|Outside ETS and ESR (Mt CO2eq/yr)")) + "Emi|GHG|++|Outside ETS and ESR (Mt CO2eq/yr)") + ) # market emissions across gases out <- mbind(out, @@ -2399,15 +2352,16 @@ if (!is.null(v37_plasticsCarbon)){ setNames(dimSums(sel_vm_emiAllMkt_N2O_ES, dim = 3) * MtN2_to_ktN2O, "Emi|N2O|++|ESR (kt N2O/yr)"), setNames(dimSums(sel_vm_emiAllMkt_N2O_other, dim = 3) * MtN2_to_ktN2O, - "Emi|N2O|++|Outside ETS and ESR (kt N2O/yr)")) + "Emi|N2O|++|Outside ETS and ESR (kt N2O/yr)") + ) # market GHG emissions across sectors ################################### ## When feedstocks are available ## ################################### - if(!is.null(v37_plasticsCarbon)){ - out <- mbind(out, + if (!is.null(v37_plasticsCarbon)) { + out <- mbind(out, # energy supply setNames( out[, , "Emi|CO2|Energy|+|Supply (Mt CO2/yr)"] @@ -2508,12 +2462,12 @@ if (!is.null(v37_plasticsCarbon)){ out[, , "Emi|GHG|+|F-Gases (Mt CO2eq/yr)"], "Emi|GHG|Outside ETS and ESR|+|F-Gases (Mt CO2eq/yr)") - ) - }else{ - ####################################### - ## When feedstocks are not available ## - ####################################### -out <- mbind(out, + ) + } else { + ####################################### + ## When feedstocks are not available ## + ####################################### + out <- mbind(out, # energy supply setNames( out[, , "Emi|CO2|Energy|+|Supply (Mt CO2/yr)"] @@ -2604,50 +2558,44 @@ out <- mbind(out, out[, , "Emi|GHG|+|F-Gases (Mt CO2eq/yr)"], "Emi|GHG|Outside ETS and ESR|+|F-Gases (Mt CO2eq/yr)") - ) + ) } - - - ## 7. Further Variables used for comparisons or in other scripts ---- - # required for aggregation of carbon price in reportPrices.R out <- mbind(out, setNames((vm_co2eq - vm_emiMacSector[, , "co2luc"] * (as.vector(cm_multigasscen) != 3)) * GtC_2_MtCO2, - "Internal|Emi|GHG|Emissions to which global CO2 tax is applied (Mt CO2eq/yr)")) + "Internal|Emi|GHG|Emissions to which global CO2 tax is applied (Mt CO2eq/yr)") + ) # required for NDC realizations of carbonprice module to run out <- mbind(out, setNames(out[, , "Emi|GHG (Mt CO2eq/yr)"] - out[, , "Emi|CO2|+|Land-Use Change (Mt CO2/yr)"], - "Emi|GHG|w/o Land-Use Change (Mt CO2eq/yr)")) - + "Emi|GHG|w/o Land-Use Change (Mt CO2eq/yr)") + ) out <- mbind(out, setNames(out[, , "Emi|CO2 (Mt CO2/yr)"] - out[, , "Emi|CO2|+|Land-Use Change (Mt CO2/yr)"], - "Emi|CO2|w/o Land-Use Change (Mt CO2/yr)")) - - - + "Emi|CO2|w/o Land-Use Change (Mt CO2/yr)") + ) # total co2 emissions industry: energy emissions + process emissions (IPCC 1A2 + 2) out <- mbind(out, setNames(out[, , "Emi|CO2|Energy|Demand|+|Industry (Mt CO2/yr)"] + out[, , "Emi|CO2|+|Industrial Processes (Mt CO2/yr)"], - "Emi|CO2|Industry (Mt CO2/yr)")) - + "Emi|CO2|Industry (Mt CO2/yr)") + ) # energy supply emissions disaggregated into IPCC sectors (electricity and heat, fuels, fugitive emissions) - # # CO2 emissions # electricity and heat (IPCC 1A1a) out <- mbind(out, setNames( out[, , "Emi|CO2|Energy|Supply|+|Electricity w/ couple prod (Mt CO2/yr)"] + out[, , "Emi|CO2|Energy|Supply|+|Heat w/ couple prod (Mt CO2/yr)"], - "Emi|CO2|Energy|Supply|++|Electricity and Heat (Mt CO2/yr)")) - + "Emi|CO2|Energy|Supply|++|Electricity and Heat (Mt CO2/yr)") + ) # fuels (IPCC 1A1b+c) (refineries and other fuel transformations) out <- mbind(out, @@ -2655,7 +2603,8 @@ out <- mbind(out, + out[, , "Emi|CO2|Energy|Supply|+|Liquids w/ couple prod (Mt CO2/yr)"] + out[, , "Emi|CO2|Energy|Supply|+|Gases w/ couple prod (Mt CO2/yr)"] + out[, , "Emi|CO2|Energy|Supply|+|Hydrogen w/ couple prod (Mt CO2/yr)"], - "Emi|CO2|Energy|Supply|++|Fuels (Mt CO2/yr)")) + "Emi|CO2|Energy|Supply|++|Fuels (Mt CO2/yr)") + ) # calculate autoproducer emissions based on CEDS value for 2015 and scale with Emi|...|Electricity and Heat to correct # an inconsistency in attribution of emissions between energy supply and industry @@ -2670,7 +2619,6 @@ out <- mbind(out, as.numeric(out["DEU", "y2015", "Emi|CO2|Energy|Supply|++|Electricity and Heat (Mt CO2/yr)"]) } - # emissions with Grassi Correction (LULUCF emissions adjusted to national LULUCF accounting) p47_LULUCFEmi_GrassiShift <- readGDX(gdx, "p47_LULUCFEmi_GrassiShift", restore_zeros = T, react = "silent")[getRegions(out), getYears(out),] @@ -2707,128 +2655,122 @@ out <- mbind(out, # TODO: add non-energy use variables for all regionmappings and sector realizations if (is.null(vm_demFENonEnergySector)) { - # Note: Non-energy use emissions should not be confused with process emissions. Non-energy use emissions are emissions/carbon flow of FE carriers which are used as feedstocks in industry. - if ("FE|Non-energy Use|Industry (EJ/yr)" %in% getNames(output) && - "FE|Non-energy Use|Industry|+|Liquids (EJ/yr)" %in% getNames(output) && - "FE|Non-energy Use|Industry|+|Gases (EJ/yr)" %in% getNames(output) && - "FE|Non-energy Use|Industry|+|Solids (EJ/yr)" %in% getNames(output)) { + # Note: Non-energy use emissions should not be confused with process emissions. Non-energy use emissions are emissions/carbon flow of FE carriers which are used as feedstocks in industry. + if ("FE|Non-energy Use|Industry (EJ/yr)" %in% getNames(output) && + "FE|Non-energy Use|Industry|+|Liquids (EJ/yr)" %in% getNames(output) && + "FE|Non-energy Use|Industry|+|Gases (EJ/yr)" %in% getNames(output) && + "FE|Non-energy Use|Industry|+|Solids (EJ/yr)" %in% getNames(output)) { + # calculate non-energy use emissions (= feedstock carbon content) as industry emissions before CCS per energy carrier * share of feedstocks in final energy + # take industry emissions before CCS as feedstocks cannot be used for CCS + # this is a temporary approximation in the reporting, but should eventually be adapted in REMIND by having a seperate feedstock FE of which the carbon cannot be captured + out <- mbind(out, + # liquids + setNames(dimSums(mselect(EmiFeCarrier, all_enty1 = c("fehos"), emi_sectors = "indst"), dim = 3) * GtC_2_MtCO2 * output[getRegions(out), , "FE|Non-energy Use|Industry|+|Liquids (EJ/yr)"] / output[getRegions(out), , "FE|Industry|+|Liquids (EJ/yr)"], + "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Liquids (Mt CO2/yr)"), + # gases + setNames(dimSums(mselect(EmiFeCarrier, all_enty1 = c("fegas"), emi_sectors = "indst"), dim = 3) * GtC_2_MtCO2 * output[getRegions(out), , "FE|Non-energy Use|Industry|+|Gases (EJ/yr)"] / output[getRegions(out), , "FE|Industry|+|Gases (EJ/yr)"], + "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Gases (Mt CO2/yr)"), + # solids + setNames(dimSums(mselect(EmiFeCarrier, all_enty1 = c("fesos"), emi_sectors = "indst"), dim = 3) * GtC_2_MtCO2 * output[getRegions(out), , "FE|Non-energy Use|Industry|+|Solids (EJ/yr)"] / output[getRegions(out), , "FE|Industry|+|Solids (EJ/yr)"], + "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Solids (Mt CO2/yr)") + ) - # calculate non-energy use emissions (= feedstock carbon content) as industry emissions before CCS per energy carrier * share of feedstocks in final energy - # take industry emissions before CCS as feedstocks cannot be used for CCS - # this is a temporary approximation in the reporting, but should eventually be adapted in REMIND by having a seperate feedstock FE of which the carbon cannot be captured - out <- mbind(out, - # liquids - setNames(dimSums(mselect(EmiFeCarrier, all_enty1 = c("fehos"), emi_sectors = "indst"), dim = 3) * GtC_2_MtCO2 * output[getRegions(out), , "FE|Non-energy Use|Industry|+|Liquids (EJ/yr)"] / output[getRegions(out), , "FE|Industry|+|Liquids (EJ/yr)"], - "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Liquids (Mt CO2/yr)"), - # gases - setNames(dimSums(mselect(EmiFeCarrier, all_enty1 = c("fegas"), emi_sectors = "indst"), dim = 3) * GtC_2_MtCO2 * output[getRegions(out), , "FE|Non-energy Use|Industry|+|Gases (EJ/yr)"] / output[getRegions(out), , "FE|Industry|+|Gases (EJ/yr)"], - "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Gases (Mt CO2/yr)"), - # solids - setNames(dimSums(mselect(EmiFeCarrier, all_enty1 = c("fesos"), emi_sectors = "indst"), dim = 3) * GtC_2_MtCO2 * output[getRegions(out), , "FE|Non-energy Use|Industry|+|Solids (EJ/yr)"] / output[getRegions(out), , "FE|Industry|+|Solids (EJ/yr)"], - "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Solids (Mt CO2/yr)")) - - # total non-energy use emissions - out <- mbind(out, - setNames(out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Solids (Mt CO2/yr)"] + - out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Liquids (Mt CO2/yr)"] + - out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Gases (Mt CO2/yr)"], - "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)")) + # total non-energy use emissions + out <- mbind(out, + setNames(out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Solids (Mt CO2/yr)"] + + out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Liquids (Mt CO2/yr)"] + + out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry|Gases (Mt CO2/yr)"], + "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)") + ) + # calculate emissions variables w/o non-energy use + # TODO: once proper accounting of non-energy use/feedstocks has been done for all cases, consider making the standard "Emi|CO2 (Mt CO2/yr)" etc. variables + # the ones without non-energy use and add an extra set "w/ Non-energy use" as this is likely a more sensible default + ### reattribution of a fraction of non-energy use carbon as waste emissions (plastic products that get combusted in waste incineration plants within the region) + # set to zero for now to avoid inconsistencies with historic data sources on industry and power emissions + WasteFraction <- 0 + out <- mbind(out, + setNames(WasteFraction * out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)"], + "Emi|CO2|w/o Non-energy Use|Waste Incineration (Mt CO2/yr)") + ) - # calculate emissions variables w/o non-energy use - # TODO: once proper accounting of non-energy use/feedstocks has been done for all cases, consider making the standard "Emi|CO2 (Mt CO2/yr)" etc. variables - # the ones without non-energy use and add an extra set "w/ Non-energy use" as this is likely a more sensible default + ### variables for which non-energy emissions should be substracted but waste fraction added + emi.vars.wNonEn.inclWaste <- c( + # GHG emissions + "Emi|GHG (Mt CO2eq/yr)", + "Emi|GHG|+|CO2 (Mt CO2eq/yr)", + "Emi|GHG|w/o Land-Use Change (Mt CO2eq/yr)", + "Emi|GHG|++|ETS (Mt CO2eq/yr)", + + # CO2 Emissions + "Emi|CO2 (Mt CO2/yr)", + "Emi|CO2|++|ETS (Mt CO2/yr)" + ) + # add emissions variables with LULUCF national accounting + if (!is.null(p47_LULUCFEmi_GrassiShift)) { - ### reattribution of a fraction of non-energy use carbon as waste emissions (plastic products that get combusted in waste incineration plants within the region) - # set to zero for now to avoid inconsistencies with historic data sources on industry and power emissions - WasteFraction <- 0 + emi.vars.wNonEn.inclWaste <- c(emi.vars.wNonEn.inclWaste, + "Emi|GHG|LULUCF national accounting (Mt CO2eq/yr)", + "Emi|CO2|LULUCF national accounting (Mt CO2/yr)" ) + } - out <- mbind(out, - setNames(WasteFraction * out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)"], - "Emi|CO2|w/o Non-energy Use|Waste Incineration (Mt CO2/yr)")) + ### variables for which non-energy emissions should be subtracted (and no waste fraction added) + emi.vars.wNonEn.exclWaste <- c( + # GHG emissions + "Emi|GHG|+++|Energy (Mt CO2eq/yr)", + "Emi|GHG|Energy|+|Demand (Mt CO2eq/yr)", + "Emi|GHG|Energy|Demand|+|Industry (Mt CO2eq/yr)", + "Emi|GHG|Industry (Mt CO2eq/yr)", + "Emi|GHG|ETS|+|Industry (Mt CO2eq/yr)", + + # Gross GHG Emissions + "Emi|GHG|Gross|Energy (Mt CO2eq/yr)", + "Emi|GHG|Gross|Energy|+|Demand (Mt CO2eq/yr)", + "Emi|GHG|Gross|Energy|Demand|+|Industry (Mt CO2eq/yr)", + + # CO2 Emissions + "Emi|CO2|+|Energy (Mt CO2/yr)", + "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)", + "Emi|CO2|Energy|+|Demand (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|Industry (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|Industry|++|Chemicals (Mt CO2/yr)", + + # Gross CO2 Emissions + "Emi|CO2|Gross|Energy|+|Demand (Mt CO2/yr)", + "Emi|CO2|Gross|Energy (Mt CO2/yr)", + "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|Demand|+|Industry (Mt CO2/yr)" + ) - ### variables for which non-energy emissions should be substracted but waste fraction added - emi.vars.wNonEn.inclWaste <- c( - # GHG emissions - "Emi|GHG (Mt CO2eq/yr)", - "Emi|GHG|+|CO2 (Mt CO2eq/yr)", - "Emi|GHG|w/o Land-Use Change (Mt CO2eq/yr)", - "Emi|GHG|++|ETS (Mt CO2eq/yr)", + # variable names, insert w/o non-energy use + emi.vars.wNonEn <- c(emi.vars.wNonEn.inclWaste, emi.vars.wNonEn.exclWaste) + names.wNonEn <- emi.vars.wNonEn + names.wNonEn <- gsub("Emi\\|CO2", "Emi|CO2|w/o Non-energy Use", names.wNonEn) + names.wNonEn <- gsub("Emi\\|GHG", "Emi|GHG|w/o Non-energy Use", names.wNonEn) - # CO2 Emissions - "Emi|CO2 (Mt CO2/yr)", - "Emi|CO2|++|ETS (Mt CO2/yr)") + # remove all pluses from the "Emi w/o Non-energy Use" variables as they do not cover sectors in which non-energy use not relevant and checking aggregation does not make sense + names.wNonEn <- gsub("\\|\\+\\|", "\\|", names.wNonEn) + names.wNonEn <- gsub("\\|\\++\\|", "\\|", names.wNonEn) + # calculate emissions variables with non-energy use + out.wNonEn <- out[, , emi.vars.wNonEn] + # for aggregate emissions: subtract non-energy use carbon and add waste incineration emissions + out.wNonEn[, , emi.vars.wNonEn.inclWaste] <- out.wNonEn[, , emi.vars.wNonEn.inclWaste] - out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)"] + out[, , "Emi|CO2|w/o Non-energy Use|Waste Incineration (Mt CO2/yr)"] + # for energy related emissions: subtract non-energy use carbon + # (waste incineration emissions are treated as a separate category here outside of energy emissions to avoid attribution complications down the energy emissions tree) + out.wNonEn[, , emi.vars.wNonEn.exclWaste] <- out.wNonEn[, , emi.vars.wNonEn.exclWaste] - out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)"] - # add emissions variables with LULUCF national accounting - if (!is.null(p47_LULUCFEmi_GrassiShift)) { + # insert "w/o Non-energy Use" label in variable names + out.wNonEn <- setNames(out.wNonEn[, , emi.vars.wNonEn], names.wNonEn) - emi.vars.wNonEn.inclWaste <- c(emi.vars.wNonEn.inclWaste, - "Emi|GHG|LULUCF national accounting (Mt CO2eq/yr)", - "Emi|CO2|LULUCF national accounting (Mt CO2/yr)" ) + out <- mbind(out, out.wNonEn) } - - ### variables for which non-energy emissions should be subtracted (and no waste fraction added) - emi.vars.wNonEn.exclWaste <- c( - # GHG emissions - "Emi|GHG|+++|Energy (Mt CO2eq/yr)", - "Emi|GHG|Energy|+|Demand (Mt CO2eq/yr)", - "Emi|GHG|Energy|Demand|+|Industry (Mt CO2eq/yr)", - "Emi|GHG|Industry (Mt CO2eq/yr)", - "Emi|GHG|ETS|+|Industry (Mt CO2eq/yr)", - - # Gross GHG Emissions - "Emi|GHG|Gross|Energy (Mt CO2eq/yr)", - "Emi|GHG|Gross|Energy|+|Demand (Mt CO2eq/yr)", - "Emi|GHG|Gross|Energy|Demand|+|Industry (Mt CO2eq/yr)", - - # CO2 Emissions - "Emi|CO2|+|Energy (Mt CO2/yr)", - "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)", - "Emi|CO2|Energy|+|Demand (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|Industry (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|Industry|++|Chemicals (Mt CO2/yr)", - - - # Gross CO2 Emissions - "Emi|CO2|Gross|Energy|+|Demand (Mt CO2/yr)", - "Emi|CO2|Gross|Energy (Mt CO2/yr)", - "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Demand|+|Industry (Mt CO2/yr)") - - - - - # variable names, insert w/o non-energy use - emi.vars.wNonEn <- c(emi.vars.wNonEn.inclWaste, emi.vars.wNonEn.exclWaste) - names.wNonEn <- emi.vars.wNonEn - names.wNonEn <- gsub("Emi\\|CO2", "Emi|CO2|w/o Non-energy Use", names.wNonEn) - names.wNonEn <- gsub("Emi\\|GHG", "Emi|GHG|w/o Non-energy Use", names.wNonEn) - - # remove all pluses from the "Emi w/o Non-energy Use" variables as they do not cover sectors in which non-energy use not relevant and checking aggregation does not make sense - names.wNonEn <- gsub("\\|\\+\\|", "\\|", names.wNonEn) - names.wNonEn <- gsub("\\|\\++\\|", "\\|", names.wNonEn) - - # calculate emissions variables with non-energy use - out.wNonEn <- out[, , emi.vars.wNonEn] - # for aggregate emissions: subtract non-energy use carbon and add waste incineration emissions - out.wNonEn[, , emi.vars.wNonEn.inclWaste] <- out.wNonEn[, , emi.vars.wNonEn.inclWaste] - out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)"] + out[, , "Emi|CO2|w/o Non-energy Use|Waste Incineration (Mt CO2/yr)"] - # for energy related emissions: subtract non-energy use carbon - # (waste incineration emissions are treated as a separate category here outside of energy emissions to avoid attribution complications down the energy emissions tree) - out.wNonEn[, , emi.vars.wNonEn.exclWaste] <- out.wNonEn[, , emi.vars.wNonEn.exclWaste] - out[, , "Emi|CO2|Non-energy Use|Energy|Demand|Industry (Mt CO2/yr)"] - - - # insert "w/o Non-energy Use" label in variable names - out.wNonEn <- setNames(out.wNonEn[, , emi.vars.wNonEn], names.wNonEn) - - out <- mbind(out, out.wNonEn) - } -} + # add global values out <- mbind(out, dimSums(out, dim = 1)) # add other region aggregations @@ -2859,7 +2801,6 @@ out <- mbind(out, ifelse(is.finite(.), ., 0) # set NaN (division by 0) to 0 } - # Bunker Correction ---- ### variables for which bunker emissions should be subtracted @@ -2897,13 +2838,13 @@ out <- mbind(out, "Emi|CO2|Gross|Energy|+|Demand (Mt CO2/yr)", "Emi|CO2|Gross|Energy (Mt CO2/yr)", "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Demand|+|Transport (Mt CO2/yr)") + "Emi|CO2|Gross|Energy|Demand|+|Transport (Mt CO2/yr)" + ) # TODO: remove this if clause once the below variable are there for industry subsectors if ((module2realisation["industry", 2] == "fixed_shares") | (!is.null(o37_demFeIndSub))) { # Note: this assumes that all bunker fuels are liquids emi.vars.wBunkers <- c(emi.vars.wBunkers, "Emi|CO2|Energy|Demand|Transport|+|Liquids (Mt CO2/yr)", "Emi|CO2|Energy|Demand|++|Liquids (Mt CO2/yr)") - } # if non-energy use variables exist, also do bunker correction for variables @@ -2927,7 +2868,6 @@ out <- mbind(out, } - # add emissions variables with LULUCF national accounting if (!is.null(p47_LULUCFEmi_GrassiShift)) { @@ -2996,58 +2936,61 @@ out <- mbind(out, return(tmp) } - -# emissions variables for which we want to calculate cumulative values -if (!is.null(v37_plasticsCarbon)) { - vars.cumulate <- c("Emi|GHG (Mt CO2eq/yr)", - "Emi|CO2 (Mt CO2/yr)", - "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)", - "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)", - "Emi|CO2|+|Energy (Mt CO2/yr)", - "Emi|CO2|+|Land-Use Change (Mt CO2/yr)", - "Emi|CO2|+|Industrial Processes (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|Transport (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|Industry (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|Buildings (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|CDR (Mt CO2/yr)", - "Emi|CO2|Energy|+|Waste (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Demand|+|Industry (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Supply|Non-electric (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Supply|+|Electricity (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|+|Waste (Mt CO2/yr)", - "Emi|CO2|CDR (Mt CO2/yr)", - "Emi|CO2|CDR|BECCS (Mt CO2/yr)", - "Emi|CO2|CDR|BECCS|Pe2Se (Mt CO2/yr)", - "Emi|CO2|CDR|BECCS|Industry (Mt CO2/yr)", - "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)", - "Emi|CO2|CDR|DACCS (Mt CO2/yr)", - "Emi|CO2|CDR|EW (Mt CO2/yr)", - "Emi|CO2|CDR|Land-Use Change (Mt CO2/yr)", - "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)") -}else{ - vars.cumulate <- c("Emi|GHG (Mt CO2eq/yr)", - "Emi|CO2 (Mt CO2/yr)", - "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)", - "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)", - "Emi|CO2|+|Energy (Mt CO2/yr)", - "Emi|CO2|+|Land-Use Change (Mt CO2/yr)", - "Emi|CO2|+|Industrial Processes (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|Transport (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|Industry (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|Buildings (Mt CO2/yr)", - "Emi|CO2|Energy|Demand|+|CDR (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Demand|+|Industry (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Supply|Non-electric (Mt CO2/yr)", - "Emi|CO2|Gross|Energy|Supply|+|Electricity (Mt CO2/yr)", - "Emi|CO2|CDR (Mt CO2/yr)", - "Emi|CO2|CDR|BECCS (Mt CO2/yr)", - "Emi|CO2|CDR|BECCS|Pe2Se (Mt CO2/yr)", - "Emi|CO2|CDR|BECCS|Industry (Mt CO2/yr)", - "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)", - "Emi|CO2|CDR|DACCS (Mt CO2/yr)", - "Emi|CO2|CDR|EW (Mt CO2/yr)", - "Emi|CO2|CDR|Land-Use Change (Mt CO2/yr)") -} + # emissions variables for which we want to calculate cumulative values + if (!is.null(v37_plasticsCarbon)) { + vars.cumulate <- c( + "Emi|GHG (Mt CO2eq/yr)", + "Emi|CO2 (Mt CO2/yr)", + "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)", + "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)", + "Emi|CO2|+|Energy (Mt CO2/yr)", + "Emi|CO2|+|Land-Use Change (Mt CO2/yr)", + "Emi|CO2|+|Industrial Processes (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|Transport (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|Industry (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|Buildings (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|CDR (Mt CO2/yr)", + "Emi|CO2|Energy|+|Waste (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|Demand|+|Industry (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|Supply|Non-electric (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|Supply|+|Electricity (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|+|Waste (Mt CO2/yr)", + "Emi|CO2|CDR (Mt CO2/yr)", + "Emi|CO2|CDR|BECCS (Mt CO2/yr)", + "Emi|CO2|CDR|BECCS|Pe2Se (Mt CO2/yr)", + "Emi|CO2|CDR|BECCS|Industry (Mt CO2/yr)", + "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)", + "Emi|CO2|CDR|DACCS (Mt CO2/yr)", + "Emi|CO2|CDR|EW (Mt CO2/yr)", + "Emi|CO2|CDR|Land-Use Change (Mt CO2/yr)", + "Emi|CO2|CDR|Materials|+|Plastics (Mt CO2/yr)" + ) + } else { + vars.cumulate <- c( + "Emi|GHG (Mt CO2eq/yr)", + "Emi|CO2 (Mt CO2/yr)", + "Emi|CO2|Energy and Industrial Processes (Mt CO2/yr)", + "Emi|CO2|Gross|Energy and Industrial Processes (Mt CO2/yr)", + "Emi|CO2|+|Energy (Mt CO2/yr)", + "Emi|CO2|+|Land-Use Change (Mt CO2/yr)", + "Emi|CO2|+|Industrial Processes (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|Transport (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|Industry (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|Buildings (Mt CO2/yr)", + "Emi|CO2|Energy|Demand|+|CDR (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|Demand|+|Industry (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|Supply|Non-electric (Mt CO2/yr)", + "Emi|CO2|Gross|Energy|Supply|+|Electricity (Mt CO2/yr)", + "Emi|CO2|CDR (Mt CO2/yr)", + "Emi|CO2|CDR|BECCS (Mt CO2/yr)", + "Emi|CO2|CDR|BECCS|Pe2Se (Mt CO2/yr)", + "Emi|CO2|CDR|BECCS|Industry (Mt CO2/yr)", + "Emi|CO2|CDR|Industry CCS|Synthetic Fuels (Mt CO2/yr)", + "Emi|CO2|CDR|DACCS (Mt CO2/yr)", + "Emi|CO2|CDR|EW (Mt CO2/yr)", + "Emi|CO2|CDR|Land-Use Change (Mt CO2/yr)" + ) + } # variable names for cumulated emissions variables names.cumul <- vars.cumulate diff --git a/README.md b/README.md index c449e7d8..5e165ea7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # The REMIND R package (2nd generation) -R package **remind2**, version **1.135.11** +R package **remind2**, version **1.135.12** [![CRAN status](https://www.r-pkg.org/badges/version/remind2)](https://cran.r-project.org/package=remind2) [![R build status](https://github.com/pik-piam/remind2/workflows/check/badge.svg)](https://github.com/pik-piam/remind2/actions) [![codecov](https://codecov.io/gh/pik-piam/remind2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/remind2) [![r-universe](https://pik-piam.r-universe.dev/badges/remind2)](https://pik-piam.r-universe.dev/builds) @@ -49,7 +49,7 @@ In case of questions / problems please contact Renato Rodrigues . +Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, Duerrwaechter J, Führlich P, Giannousakis A, Hasse R, Hilaire J, Klein D, Koch J, Kowalczyk K, Levesque A, Malik A, Merfort A, Merfort L, Morena-Leiva S, Pehl M, Pietzcker R, Rauner S, Richters O, Rottoli M, Schötz C, Schreyer F, Siala K, Sörgel B, Spahr M, Strefler J, Verpoort P, Weigmann P (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.135.12, . A BibTeX entry for LaTeX users is @@ -58,7 +58,7 @@ A BibTeX entry for LaTeX users is title = {remind2: The REMIND R package (2nd generation)}, author = {Renato Rodrigues and Lavinia Baumstark and Falk Benke and Jan Philipp Dietrich and Alois Dirnaichner and Jakob Duerrwaechter and Pascal Führlich and Anastasis Giannousakis and Robin Hasse and Jérome Hilaire and David Klein and Johannes Koch and Katarzyna Kowalczyk and Antoine Levesque and Aman Malik and Anne Merfort and Leon Merfort and Simón Morena-Leiva and Michaja Pehl and Robert Pietzcker and Sebastian Rauner and Oliver Richters and Marianna Rottoli and Christof Schötz and Felix Schreyer and Kais Siala and Björn Sörgel and Mike Spahr and Jessica Strefler and Philipp Verpoort and Pascal Weigmann}, year = {2024}, - note = {R package version 1.135.11}, + note = {R package version 1.135.12}, url = {https://github.com/pik-piam/remind2}, } ```