diff --git a/R/reportCosts.R b/R/reportCosts.R index 2b123387..b95208df 100644 --- a/R/reportCosts.R +++ b/R/reportCosts.R @@ -1,9 +1,9 @@ #' Read in GDX and calculate costs, used in convGDX2MIF.R for the reporting -#' +#' #' Read in cost information from GDX file, information used in convGDX2MIF.R #' for the reporting -#' -#' +#' +#' #' @param gdx a GDX object as created by readGDX, or the path to a gdx #' @param output a magpie object containing all needed variables generated by other report*.R functions #' @param regionSubsetList a list containing regions to create report variables region @@ -11,14 +11,14 @@ #' be created. #' @param t temporal resolution of the reporting, default: #' t=c(seq(2005,2060,5),seq(2070,2110,10),2130,2150) -#' +#' #' @return MAgPIE object - contains the cost variables #' @author David Klein #' @seealso \code{\link{convGDX2MIF}} #' @examples -#' +#' #' \dontrun{reportCosts(gdx)} -#' +#' #' @export #' @importFrom rlang .data #' @importFrom magclass mbind getYears collapseNames setNames @@ -26,7 +26,7 @@ #' @importFrom dplyr filter reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060,5),seq(2070,2110,10),2130,2150)) { - + # Cost calculation requires information from other reportings if(is.null(output)){ message("reportCosts executes reportExtraction ", appendLF = FALSE) @@ -36,11 +36,11 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, message("- reportEnergyInvestments") output <- mbind(output, reportEnergyInvestment(gdx, regionSubsetList, t)[, getYears(output), ]) } - + ######################################################################################## ############# R E A D I N G I N P U T ############################################### ######################################################################################## - + # module realisations module2realisation <- readGDX(gdx, "module2realisation", react = "silent") industry_module <- module2realisation['industry' == module2realisation$modules, 2] @@ -52,7 +52,7 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, pe2se <- readGDX(gdx,"pe2se") se2fe <- readGDX(gdx,"se2fe") se2se <- readGDX(gdx,c("se2se"),format="first_found") - + # Sets tenoccs <- readGDX(gdx,c("teNoCCS","tenoccs"),format="first_found") temapall <- readGDX(gdx,c("en2en","temapall"),format="first_found") @@ -68,15 +68,15 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, se_Liq <- intersect(potentialseLiq,sety) teccs <- readGDX(gdx,c("teCCS","teccs"),format="first_found") pebio <- readGDX(gdx,c("peBio","pebio"),format="first_found") - fe2ppfen37 <- readGDX(gdx, 'fe2ppfen37', react = 'silent') + fe2ppfen37 <- readGDX(gdx, c("fe2ppfen37", "fe2ppfEn37"), react = 'silent') emiMacMagpie <- readGDX(gdx,c("emiMacMagpie"),format="first_found") emiMacMagpieN2O <- readGDX(gdx,c("emiMacMagpieN2O"),format="first_found") emiMacMagpieCH4 <- readGDX(gdx,c("emiMacMagpieCH4"),format="first_found") emiMacMagpieCO2 <- readGDX(gdx,c("emiMacMagpieCO2"),format="first_found") - + # Parameters - pm_conv_TWa_EJ <- 31.536 - sm_tdptwyr2dpgj <- 31.71 #TerraDollar per TWyear to Dollar per + pm_conv_TWa_EJ <- 31.536 + sm_tdptwyr2dpgj <- 31.71 #TerraDollar per TWyear to Dollar per pm_data <- readGDX(gdx,name="pm_data",format="first_found") pm_petradecost2_Mp_fin <- readGDX(gdx,name="pm_petradecost2_Mp_fin",format="first_found", react = "silent") if(is.null(pm_petradecost2_Mp_fin)){ @@ -92,8 +92,8 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, costsLuMACLookup <- readGDX(gdx,name=c("p26_macCostLu"),format="first_found")[,getYears(cost_emu_pre),] costsMAC <- readGDX(gdx,name=c("pm_macCost","p_macCost"),format="first_found")[,getYears(cost_emu_pre),] p_eta_conv <- readGDX(gdx,name=c("pm_eta_conv","p_eta_conv"),format = "first_found") - - # Variables + + # Variables Xport <- readGDX(gdx,name=c("vm_Xport"), field = "l",format = "first_found") Mport <- readGDX(gdx,name=c("vm_Mport"), field = "l",format = "first_found") vm_fuelex <- readGDX(gdx,name=c("vm_fuExtr","vm_fuelex"), field="l",restore_zeros=FALSE,format="first_found")[enty2rlf] @@ -127,12 +127,12 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, budget.m <- readGDX(gdx,name='qm_budget', types="equations",field="m",format="first_found") # alternative: calcPrice sebal.m <- readGDX(gdx,name=c("q_balSe","q_sebal"), types="equations",field="m",format="first_found") balfinen.m <- readGDX(gdx,name=c("qm_balFeForCesAndEs","qm_balFeForCes","q_balFeForCes","q_balfinen"),types="equations",field="m",format="first_found", react = "silent")[finenbal] - + if(is.null(balfinen.m)){ vm_demFeSector <- readGDX(gdx,name=c("vm_demFeSector"),field="l",restore_zeros=FALSE,format="first_found") demFeIndst.m <- readGDX(gdx,name=c("q37_demFeIndst"),types="equations",restore_zeros=FALSE,field="m",format="first_found") demFeBuild.m <- readGDX(gdx,name=c("q36_demFeBuild"),types="equations",restore_zeros=FALSE,field="m",format="first_found") - balFe.m <- readGDX(gdx,name=c("q_balFe","qm_balFe"),types="equations",restore_zeros=FALSE,field="m",format="first_found") + balFe.m <- readGDX(gdx,name=c("q_balFe","qm_balFe"),types="equations",restore_zeros=FALSE,field="m",format="first_found") #balFeCDR.m <- readGDX(gdx,name=c("q33_balFeCDR"),types="equations",restore_zeros=FALSE,field="m",format="first_found") #febalForUe.m <- dimReduce(febalForUe.m, dim_exclude = 2) demFeTrans.m <- readGDX(gdx,name=c("q35_demFeTrans"),types="equations",restore_zeros=FALSE,field="m",format="first_found") @@ -142,9 +142,9 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, price_fe_trans <- dimSums(price_fe_trans_emiMkt*quant_fe_trans_emiMkt,dim=3.2,na.rm=T) / dimSums(quant_fe_trans_emiMkt,dim=3,na.rm=T) # price of final energy in transportation (US$2005/GJ) febalForUe.m <- price_fe_trans } else { - febalForUe.m <- readGDX(gdx,name=c("q_balFeForUe","q_balFe","q_febal"),types="equations",field="m",format="first_found",restore_zeros=FALSE) + febalForUe.m <- readGDX(gdx,name=c("q_balFeForUe","q_balFe","q_febal"),types="equations",field="m",format="first_found",restore_zeros=FALSE) } - + # Find common years y <- Reduce(intersect,list(getYears(vm_fuelex), getYears(vm_costfu_ex), @@ -152,12 +152,12 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, getYears(v_investcost), getYears(vm_cap), getYears(vm_prodSe))) - + # Reduce to common years - p_dataeta <- p_dataeta[,y,] + p_dataeta <- p_dataeta[,y,] pm_pvp <- pm_pvp[,y,] - vm_fuelex <- vm_fuelex[,y,] - Xport <- Xport[,y,] + vm_fuelex <- vm_fuelex[,y,] + Xport <- Xport[,y,] Mport <- Mport[,y,] vm_costfu_ex <- vm_costfu_ex[,y,] v_costfu <- v_costfu[,y,] @@ -165,7 +165,7 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, v_costin <- v_costin[,y,] CDR_FEdemand <- CDR_FEdemand[,y,] v_investcost <- v_investcost[,y,] - vm_cap <- vm_cap[,y,] + vm_cap <- vm_cap[,y,] vm_prodSe <- vm_prodSe[,y,] pebal.m <- pebal.m[,y,] budget.m <- budget.m[,y,] @@ -175,7 +175,7 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, vm_omcosts_cdr <- vm_omcosts_cdr[,y,] output <- output[,y,] p_eta_conv <- p_eta_conv[,y,] - + y <- Reduce(intersect,list(getYears(febalForUe.m),getYears(vm_prodFe),getYears(sebal.m),getYears(vm_prodSe))) febalForUe.m <- febalForUe.m[,y,] if(!(is.null(balfinen.m))) { @@ -186,7 +186,7 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, balFe.m <- balFe.m[,y,] vm_demFeSector <- vm_demFeSector[,y,] } - + # Gather efficiency data in only one magpie object to enable generic structure of below defined functions: # Take values from pm_data (constant efficiency over time) for technologies where p_dataeta (time variant efficiencies) has no values. # Thus, in the below defined formulas time variant efficiencies will be used if available otherwise time invariant @@ -195,26 +195,26 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, for (year in getYears(p_dataeta)) { p_dataeta[,year,te] <- pm_data[,,"eta"][,,te] } - } + } } - + ######################################################################################## ############# F U N C T I O N S D E F I N I T I O N ################################# ######################################################################################## - + op_costs_part2_foss <- function(pe,se,te,vm_prodSe,i_pe2se,p_dataeta,vm_costfu_ex,vm_fuelex,sm_tdptwyr2dpgj,pm_conv_TWa_EJ) { sub_pe2se <- i_pe2se[(pe2se$all_enty %in% pe) & (i_pe2se$all_enty1 %in% se) & (i_pe2se$all_te %in% te),] out <- dimSums( vm_costfu_ex[,,pe] / dimSums(vm_fuelex[,,pe],dim=3), dim = 3, na.rm = T) * sm_tdptwyr2dpgj * # Average supply costs - dimSums( vm_prodSe[sub_pe2se] / p_dataeta[,,sub_pe2se$all_te], dim = 3, na.rm = T) * pm_conv_TWa_EJ + dimSums( vm_prodSe[sub_pe2se] / p_dataeta[,,sub_pe2se$all_te], dim = 3, na.rm = T) * pm_conv_TWa_EJ return(out) } op_costs_part2_bio_nuc <- function(pe,se,te,vm_prodSe,i_pe2se,p_dataeta,pm_conv_TWa_EJ) { sub_pe2se <- i_pe2se[(pe2se$all_enty %in% pe) & (i_pe2se$all_enty1 %in% se) & (i_pe2se$all_te %in% te),] - out <- dimSums( vm_prodSe[sub_pe2se] / p_dataeta[,,sub_pe2se$all_te], dim = 3, na.rm = T) * pm_conv_TWa_EJ + out <- dimSums( vm_prodSe[sub_pe2se] / p_dataeta[,,sub_pe2se$all_te], dim = 3, na.rm = T) * pm_conv_TWa_EJ return(out) } - + # operation and maintenance costs op_costs <- function(ei,eo,te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=NULL,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) { # Check whether a mapping with energy transfering technologies is given or just technologies @@ -225,21 +225,21 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, } else { e2e_allte <- te } - + vm_cap <- dimSums(vm_cap,dim=3.2,na.rm = T) # get rid of grades which are not used in calculations below because all other variables dont have them neither - + out <- dimSums( # sum OMF over technologies - collapseNames(pm_data[,,"omf"])[,,e2e_allte] * - (dimSums((v_investcost[,,e2e_allte] * vm_cap[,,e2e_allte])[teall2rlf],dim=3.2,na.rm=T) # sum over rlf - )[,, e2e_allte],dim=3, na.rm=T) - + collapseNames(pm_data[,,"omf"])[,,e2e_allte] * + (dimSums((v_investcost[,,e2e_allte] * vm_cap[,,e2e_allte])[teall2rlf],dim=3.2,na.rm=T) # sum over rlf + )[,, e2e_allte],dim=3, na.rm=T) + if(!is.null(vm_prodE) & !length(e2e_allte)==0) { # if either SE or FE is produced, then variable O&M is added out <- out + dimSums(collapseNames(pm_data[,,"omv"])[,,sub_e2e$all_te] * dimSums(vm_prodE[sub_e2e],dim=c(3.1,3.2),na.rm=T) - , dim=3,na.rm=T) + , dim=3,na.rm=T) } - + out <- out * 1000 - + return(out) } @@ -247,25 +247,25 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, out <- dimSums((pm_petradecost2_Mp_fin[,,pety] + (pm_pvp[,,pety] / (budget.m + 1.e-10))) * Mport[,,pety], dim=3,na.rm=T) * 1000 return(out) } - + ######################################################################################## ############# O U T P U T G E N E R A T I O N ######################################## ######################################################################################## - + # Initialize empty object that will be filled with reporting results tmp <- NULL - + # Calculate and append new variables to magpie object - + ####################################### ########## Biomass costs ############## ####################################### - + if(!is.null(cost_mag)) {tmp <- mbind(tmp,setNames(cost_mag * 1000, "Costs|Biomass|MAgPIE (billion US$2005/yr)"))} tmp <- mbind(tmp,setNames(cost_emu_pre * 1000, "Costs|Biomass|Price integral presolve (billion US$2005/yr)")) tmp <- mbind(tmp,setNames(cost_emu * 1000, "Costs|Biomass|Price integral (billion US$2005/yr)")) tmp <- mbind(tmp,setNames(bio_cost_adjfac, "Costs|Biomass|Adjfactor (-)")) - + if(!is.null(totLUcosts)) {tmp <- mbind(tmp,setNames(totLUcosts * 1000, "Costs|Land Use (billion US$2005/yr)"))} if(!is.null(totLUcostsWithMAC)) {tmp <- mbind(tmp,setNames(totLUcostsWithMAC * 1000, "Costs|Land Use with MAC-costs from MAgPIE (billion US$2005/yr)"))} if(!is.null(costsLuMACLookup)) {tmp <- mbind(tmp,setNames(costsLuMACLookup * 1000, "Costs|Land Use|MAC-costs Lookup (billion US$2005/yr)"))} @@ -273,46 +273,46 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, if(!is.null(getNames(costsMAC))) tmp <- mbind(tmp,setNames(dimSums(costsMAC[,,emiMacMagpieN2O],dim=3,na.rm=T) * 1000, "Costs|Land Use|MAC-costs|N2O (billion US$2005/yr)")) if(!is.null(getNames(costsMAC))) tmp <- mbind(tmp,setNames(dimSums(costsMAC[,,emiMacMagpieCH4],dim=3,na.rm=T) * 1000, "Costs|Land Use|MAC-costs|CH4 (billion US$2005/yr)")) if(!is.null(getNames(costsMAC))) tmp <- mbind(tmp,setNames(dimSums(costsMAC[,,emiMacMagpieCO2],dim=3,na.rm=T) * 1000, "Costs|Land Use|MAC-costs|CO2 (billion US$2005/yr)")) - + tmp <- tmp[,y,] - + ####################################### ########## Fuel Costs ################# ####################################### - + ##### Total - tmp <- mbind(tmp,setNames(v_costfu * 1000, "Fuel supply costs (billion US$2005/yr)")) - + tmp <- mbind(tmp,setNames(v_costfu * 1000, "Fuel supply costs (billion US$2005/yr)")) + ##### Fuel costs for own ESM regi_on_gdx <- unique(readGDX(gdx, name = "regi2iso")[,1]) - + # v_costfu: these costs are the total fuel extraction costs, even the ones for export # Supply costs: exports valued at supply cost (else the ESM costs would be greatly underestimated for a resource-exporting country that makes large profits from the export), except for biomass where supply costs are not yet reported cost <- v_costfu * 1000 - setNames(output[regi_on_gdx,,"Res|Average Supply Costs|Coal ($/GJ)"] * Xport[,,"pecoal"] * pm_conv_TWa_EJ,NULL) - - setNames(output[regi_on_gdx,,"Res|Average Supply Costs|Gas ($/GJ)"] * Xport[,,"pegas"] * pm_conv_TWa_EJ,NULL) - - setNames(output[regi_on_gdx,,"Res|Average Supply Costs|Oil ($/GJ)"] * Xport[,,"peoil"] * pm_conv_TWa_EJ,NULL) - + setNames(output[regi_on_gdx,,"Res|Average Supply Costs|Gas ($/GJ)"] * Xport[,,"pegas"] * pm_conv_TWa_EJ,NULL) - + setNames(output[regi_on_gdx,,"Res|Average Supply Costs|Oil ($/GJ)"] * Xport[,,"peoil"] * pm_conv_TWa_EJ,NULL) - setNames(output[regi_on_gdx,,"Price|Primary Energy|Biomass|Modern|Rawdata (US$2005/GJ)"] * Xport[,,"pebiolc"] * pm_conv_TWa_EJ,NULL) - setNames(output[regi_on_gdx,,"Res|Average Supply Costs|Uranium ($/GJ)"] * Xport[,,"peur"] * pm_conv_TWa_EJ * 4.43,NULL) + dimSums(Mport[,,trade_pe] * pebal.m[,,trade_pe] / (budget.m + 1.e-10), dim=3,na.rm=T) * 1000 # imports valued with domestic market price - + tmp <- mbind(tmp,setNames(cost, "Fuel costs for own ESM (billion US$2005/yr)")) - + ##### Import fuel costs cost<- cost_Mport(trade_pe,pm_petradecost2_Mp_fin,pm_pvp,budget.m,Mport) tmp <- mbind(tmp,setNames(cost, "Import Fuel costs (billion US$2005/yr)")) - - ###### Import fuel costs|Coal + + ###### Import fuel costs|Coal cost<- cost_Mport("pecoal",pm_petradecost2_Mp_fin,pm_pvp,budget.m,Mport) tmp <- mbind(tmp,setNames(cost, "Import Fuel costs|Coal (billion US$2005/yr)")) - + ###### Import fuel costs|Gas cost<- cost_Mport("pegas",pm_petradecost2_Mp_fin,pm_pvp,budget.m,Mport) tmp <- mbind(tmp,setNames(cost, "Import Fuel costs|Gas (billion US$2005/yr)")) - + ###### Import fuel costs|Oil cost<- cost_Mport("peoil",pm_petradecost2_Mp_fin,pm_pvp,budget.m,Mport) tmp <- mbind(tmp,setNames(cost, "Import Fuel costs|Oil (billion US$2005/yr)")) - + ###### Import fuel costs|Uranium cost<- cost_Mport("peur",pm_petradecost2_Mp_fin,pm_pvp,budget.m,Mport) tmp <- mbind(tmp,setNames(cost, "Import Fuel costs|Uranium (billion US$2005/yr)")) @@ -324,69 +324,69 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, ###### Export Fuel Costs|Coal cost <- output[regi_on_gdx,,"Res|Average Supply Costs|Coal ($/GJ)"] * Xport[,,"pecoal"] * pm_conv_TWa_EJ tmp <- mbind(tmp,setNames(cost, "Export Fuel costs|Coal (billion US$2005/yr)")) - - ###### Export Fuel Costs|Gas + + ###### Export Fuel Costs|Gas cost <- output[regi_on_gdx,,"Res|Average Supply Costs|Gas ($/GJ)"] * Xport[,,"pegas"] * pm_conv_TWa_EJ tmp <- mbind(tmp,setNames(cost, "Export Fuel costs|Gas (billion US$2005/yr)")) - + ###### Export Fuel Costs|Oil cost <- output[regi_on_gdx,,"Res|Average Supply Costs|Oil ($/GJ)"] * Xport[,,"peoil"] * pm_conv_TWa_EJ tmp <- mbind(tmp,setNames(cost, "Export Fuel costs|Oil (billion US$2005/yr)")) - + ###### Export Fuel Costs|Biomass #cost <- output[regi_on_gdx,,"Res|Average Supply Costs|Biomass ($/GJ)"] * Xport[,,"pebiolc"] #tmp <- mbind(tmp,setNames(cost, "Export Fuel costs|Biomass (billion US$2005/yr)")) - + ###### Export Fuel Costs|Uranium cost <- output[regi_on_gdx,,"Res|Average Supply Costs|Uranium ($/GJ)"] * Xport[,,"peur"] * p_eta_conv[,,"tnrs"] * pm_conv_TWa_EJ tmp <- mbind(tmp,setNames(cost, "Export Fuel costs|Uranium (billion US$2005/yr)")) - + ####################################### ########## Energy System costs ######## ####################################### - + cost <- (v_costin + v_costom) * 1000 + tmp[,,"Fuel costs for own ESM (billion US$2005/yr)"] tmp <- mbind(tmp,setNames(cost,"Energy system costs (billion US$2005/yr)")) - + ####################################### ########## Energy costs ############### ####################################### if (!is.null(balfinen.m)) { - + if ('subsectors' == industry_module) { fe2ppfen37_feels <- filter(fe2ppfen37, 'feels' == .data$all_enty) fe2ppfen37_fegas <- filter(fe2ppfen37, 'fegas' == .data$all_enty) fe2ppfen37_feh2s <- filter(fe2ppfen37, 'feh2s' == .data$all_enty) - - + + # "Price|Final Energy|Electricity|Industry (US$2005/GJ)") price_feeli <- abs( ( dimSums( - mselect(balfinen.m, fe2ppfen37_feels) + mselect(balfinen.m, fe2ppfen37_feels) * vm_cesIO[,y,fe2ppfen37_feels$all_in], - dim = 3, na.rm = T) + dim = 3, na.rm = T) / dimSums(vm_cesIO[,y,fe2ppfen37_feels$all_in], dim = 3, na.rm = T) ) / (budget.m + 1e-10) * 1000 / pm_conv_TWa_EJ ) - + # "Price|Final Energy|Gases|Industry (US$2005/GJ)") price_fegai <- abs( ( dimSums( - mselect(balfinen.m, fe2ppfen37_fegas) + mselect(balfinen.m, fe2ppfen37_fegas) * vm_cesIO[,y,fe2ppfen37_fegas$all_in], - dim = 3, na.rm = T) + dim = 3, na.rm = T) / dimSums(vm_cesIO[,y,fe2ppfen37_fegas$all_in], dim = 3, na.rm = T) ) / (budget.m + 1e-10) * 1000 / pm_conv_TWa_EJ ) - + # "Price|Final Energy|Hydrogen|Industry (US$2005/GJ)") price_feh2i <- abs( ( dimSums( - mselect(balfinen.m, fe2ppfen37_feh2s) + mselect(balfinen.m, fe2ppfen37_feh2s) * vm_cesIO[,y,fe2ppfen37_feh2s$all_in], - dim = 3, na.rm = T) + dim = 3, na.rm = T) / dimSums(vm_cesIO[,y,fe2ppfen37_feh2s$all_in], dim = 3, na.rm = T) ) / (budget.m + 1e-10) * 1000 / pm_conv_TWa_EJ @@ -395,13 +395,13 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, price_feeli <- abs(balfinen.m[,,"feels.feeli"]/(budget.m+1e-10)) * 1000 / pm_conv_TWa_EJ # "Price|Final Energy|Electricity|Industry (US$2005/GJ)") price_fegai <- abs(balfinen.m[,,"fegas.fegai"]/(budget.m+1e-10)) * 1000 / pm_conv_TWa_EJ # "Price|Final Energy|Gases|Industry (US$2005/GJ)") price_feh2i <- abs(balfinen.m[,,"feh2s.feh2i"]/(budget.m+1e-10)) * 1000 / pm_conv_TWa_EJ # "Price|Final Energy|Hydrogen|Industry (US$2005/GJ)") - } - + } + # reduce names in 3rd dimension price_feeli <- setNames(price_feeli,"feeli") # reduce feels.feels to feels price_fegai <- setNames(price_fegai,"fegai") # reduce fehes.fehes to fehes price_feh2i <- setNames(price_feh2i,"feh2i") # reduce fehes.fehes to fehes - + } else { # industry final energy price price_fe_indst_emiMkt <- abs(demFeIndst.m/(budget.m+1e-10)) * 1000 / pm_conv_TWa_EJ # price of final energy in industry per emission market (US$2005/GJ) @@ -411,7 +411,7 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, price_fe_build_emiMkt <- abs(demFeBuild.m/(budget.m+1e-10)) * 1000 / pm_conv_TWa_EJ # price of final energy in buildings per emission market (US$2005/GJ) quant_fe_build_emiMkt <- dimSums(dimSums(vm_demFeSector[,,"build"],dim=c(3.1),na.rm=T),dim=c(3.2),na.rm=T)[,,getNames(price_fe_build_emiMkt)] price_fe_build <- dimSums(price_fe_build_emiMkt*quant_fe_build_emiMkt,dim=3.2,na.rm=T) / dimSums(quant_fe_build_emiMkt,dim=3,na.rm=T) # price of final energy in buildings (US$2005/GJ) - + # reduce names in 3rd dimension price_feeli <- price_fe_indst[,,"feels"] price_fegai <- price_fe_indst[,,"fegas"] @@ -420,14 +420,14 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, price_fegai <- setNames(price_fegai,"fegai") # reduce fehes.fehes to fehes price_feh2i <- setNames(price_feh2i,"feh2i") # reduce fehes.fehes to fehes } - + price_fedie <- abs(febalForUe.m[,,"fedie"]/(budget.m+1e-10)) * 1000 / pm_conv_TWa_EJ # "Price|Final Energy|Diesel (US$2005/GJ)") tmp <- mbind(tmp, setNames(price_feeli * CDR_FEdemand[,,"feels"] * pm_conv_TWa_EJ, "Energy costs CDR|Electricity (billion US$2005/yr)")) tmp <- mbind(tmp, setNames(price_fedie * CDR_FEdemand[,,"fedie"] * pm_conv_TWa_EJ, "Energy costs CDR|Diesel (billion US$2005/yr)")) tmp <- mbind(tmp, setNames((price_fegai * CDR_FEdemand[,,"fegas"] + price_feh2i * CDR_FEdemand[,,"feh2s"]) * pm_conv_TWa_EJ, "Energy costs CDR|Heat (billion US$2005/yr)")) - + tmp <- mbind(tmp, setNames((price_feeli * CDR_FEdemand[,,"feels"] + price_fedie * CDR_FEdemand[,,"fedie"] + price_fegai * CDR_FEdemand[,,"fegas"] + price_feh2i * CDR_FEdemand[,,"feh2s"]) * pm_conv_TWa_EJ, "Energy costs CDR (billion US$2005/yr)")) @@ -435,152 +435,152 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, ####################################### ########## Total Energy costs ######### ####################################### - - ##### Total + + ##### Total cost1 <- op_costs(ei=temapall$all_enty,eo=sety,te=teall2rlf$all_te,e2e=temapall,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs(ei=temapall$all_enty,eo=fety,te=teall2rlf$all_te,e2e=temapall,teall2rlf=teall2rlf,vm_prodE=vm_prodFe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost3 <- op_costs(ei=NULL,eo=NULL,te=tenotransform,e2e=NULL,teall2rlf=teall2rlf,vm_prodE=NULL,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost1 + cost2 + cost3 + output[regi_on_gdx,,"Energy Investments|Supply (billion US$2005/yr)"], "Total Energy costs (billion US$2005/yr)")) - - ##### Electricity + + ##### Electricity cost1 <- op_costs(ei=pe2se$all_enty,eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs(ei="seel",eo=se2fe$all_enty1,te=se2fe$all_te,e2e=se2fe,teall2rlf=teall2rlf,vm_prodE=vm_prodFe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost3 <- op_costs(ei=NULL,eo=NULL,te=tenotransform,e2e=NULL,teall2rlf=teall2rlf,vm_prodE=NULL,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost1 + cost2 + cost3 + output[regi_on_gdx,,"Energy Investments|Electricity (billion US$2005/yr)"], "Total Energy costs|Electricity (billion US$2005/yr)")) - + ##### Elec|Fossil cost <- op_costs(ei=petyf,eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Fossil (billion US$2005/yr)"], "Total Energy costs|Elec|Fossil (billion US$2005/yr)")) - - ##### Elec|Non-fossil + + ##### Elec|Non-fossil cost <- op_costs(ei=setdiff(pe2se$all_enty,petyf),eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Non-Fossil (billion US$2005/yr)"], "Total Energy costs|Elec|Non-Fossil (billion US$2005/yr)")) - + ##### Elec|Biomass cost <- op_costs(ei="pebiolc",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Biomass (billion US$2005/yr)"], "Total Energy costs|Elec|Biomass (billion US$2005/yr)")) - + cost <- op_costs(ei="pebiolc",eo="seel",te=teccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Biomass|w/ CC (billion US$2005/yr)"], "Total Energy costs|Elec|Biomass|w/ CC (billion US$2005/yr)")) - + cost <- op_costs(ei="pebiolc",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Biomass|w/o CC (billion US$2005/yr)"], "Total Energy costs|Elec|Biomass|w/o CC (billion US$2005/yr)")) - + ##### Elec|Coal cost <- op_costs(ei="pecoal",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost <- cost + output[regi_on_gdx,,"Energy Investments|Elec|Coal (billion US$2005/yr)"] tmp <- mbind(tmp,setNames(cost, "Total Energy costs|Elec|Coal (billion US$2005/yr)")) - + cost <- op_costs(ei="pecoal",eo="seel",te=teccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost <- cost + output[regi_on_gdx,,"Energy Investments|Elec|Coal|w/ CC (billion US$2005/yr)"] tmp <- mbind(tmp,setNames(cost, "Total Energy costs|Elec|Coal|w/ CC (billion US$2005/yr)")) - + cost <- op_costs(ei="pecoal",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost <- cost + output[regi_on_gdx,,"Energy Investments|Elec|Coal|w/o CC (billion US$2005/yr)"] tmp <- mbind(tmp,setNames(cost, "Total Energy costs|Elec|Coal|w/o CC (billion US$2005/yr)")) - + ##### Elec|Gas cost <- op_costs(ei="pegas",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Gas (billion US$2005/yr)"], "Total Energy costs|Elec|Gas (billion US$2005/yr)")) - + cost <- op_costs(ei="pegas",eo="seel",te=teccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Gas|w/ CC (billion US$2005/yr)"], "Total Energy costs|Elec|Gas|w/ CC (billion US$2005/yr)")) - + cost <- op_costs(ei="pegas",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Gas|w/o CC (billion US$2005/yr)"], "Total Energy costs|Elec|Gas|w/o CC (billion US$2005/yr)")) - + ##### Elec|Oil cost <- op_costs(ei="peoil",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Oil (billion US$2005/yr)"], "Total Energy costs|Elec|Oil (billion US$2005/yr)")) - + cost <- op_costs(ei="peoil",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Oil|w/o CC (billion US$2005/yr)"], "Total Energy costs|Elec|Oil|w/o CC (billion US$2005/yr)")) - - ##### Elec|Nuclear + + ##### Elec|Nuclear cost <- op_costs(ei="peur",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Nuclear (billion US$2005/yr)"], "Total Energy costs|Elec|Nuclear (billion US$2005/yr)")) - + ##### Elec|Non-biomass renewables cost <- op_costs(ei=setdiff(perenew,pebio),eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Non-Bio Re (billion US$2005/yr)"], "Total Energy costs|Elec|Non-Bio Re (billion US$2005/yr)")) - + ##### Elec|Solar cost <- op_costs(ei="pesol",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Solar (billion US$2005/yr)"], "Total Energy costs|Elec|Solar (billion US$2005/yr)")) - + ##### Elec|Wind cost <- op_costs(ei="pewin",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Wind (billion US$2005/yr)"], "Total Energy costs|Elec|Wind (billion US$2005/yr)")) - + ##### Elec|Hydro cost <- op_costs(ei="pehyd",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Hydro (billion US$2005/yr)"], "Total Energy costs|Elec|Hydro (billion US$2005/yr)")) - + ##### Elec|Geothermal cost <- op_costs(ei="pegeo",eo="seel",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Geothermal (billion US$2005/yr)"], "Total Energy costs|Elec|Geothermal (billion US$2005/yr)")) - + ##### Elec|Hydrogen if ("h2turb" %in% se2se$all_te) { cost <- op_costs(ei="seh2",eo="seel",te=se2se$all_te,e2e=se2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Hydrogen (billion US$2005/yr)"], "Total Energy costs|Elec|Hydrogen (billion US$2005/yr)")) } - + ##### Elec|Storage cost <- op_costs(ei=NULL,eo=NULL,te=stor,e2e=NULL,teall2rlf=teall2rlf,vm_prodE=NULL,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Elec|Storage (billion US$2005/yr)"], "Total Energy costs|Elec|Storage (billion US$2005/yr)")) - + ##### Elec|Grid cost1 <- op_costs(ei=NULL,eo=NULL,te=grid,e2e=NULL,teall2rlf=teall2rlf,vm_prodE=NULL,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs(ei="seel",eo=se2fe$all_enty1,te=se2fe$all_te,e2e=se2fe,teall2rlf=teall2rlf,vm_prodE=NULL,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost1 + cost2 + output[regi_on_gdx,,"Energy Investments|Elec|Grid (billion US$2005/yr)"], "Total Energy costs|Elec|Grid (billion US$2005/yr)")) - + ##### Heat #TiA: including investments, and operation and maintenance, BUT excluding input fuel costs cost_pe2se <- op_costs(ei=pe2se$all_enty,eo="sehe",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost_se2fe <- op_costs(ei="sehe",eo=se2fe$all_enty1,te=se2fe$all_te,e2e=se2fe,teall2rlf=teall2rlf,vm_prodE=vm_prodFe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost_pe2se + cost_se2fe + output[regi_on_gdx,,"Energy Investments|Heat (billion US$2005/yr)"], "Total Energy costs|Heat (billion US$2005/yr)")) - + ##### Hydrogen #TiA: including investments, and operation and maintenance, BUT excluding input fuel costs cost_pe2se <- op_costs(ei=pe2se$all_enty,eo="seh2",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost_se2fe <- op_costs(ei="seh2",eo=se2fe$all_enty1,te=se2fe$all_te,e2e=se2fe,teall2rlf=teall2rlf,vm_prodE=vm_prodFe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost_pe2se + cost_se2fe + output[regi_on_gdx,,"Energy Investments|Hydrogen (billion US$2005/yr)"], "Total Energy costs|Hydrogen (billion US$2005/yr)")) - + ##### Hydrogen|Fossil cost <- op_costs(ei=petyf,eo="seh2",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Hydrogen|Fossil (billion US$2005/yr)"], "Total Energy costs|Hydrogen|Fossil (billion US$2005/yr)")) - + ##### Hydrogen|RE cost <- op_costs(ei=perenew,eo="seh2",te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Hydrogen|RE (billion US$2005/yr)"], "Total Energy costs|Hydrogen|RE (billion US$2005/yr)")) - + ##### Liquids #TiA: including investments, and operation and maintenance, BUT excluding input fuel costs cost_pe2se <- op_costs(ei=pe2se$all_enty,eo=se_Liq,te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost_se2fe <- op_costs(ei=se_Liq,eo=se2fe$all_enty1,te=se2fe$all_te,e2e=se2fe,teall2rlf=teall2rlf,vm_prodE=vm_prodFe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost_pe2se + cost_se2fe + output[regi_on_gdx,,"Energy Investments|Liquids (billion US$2005/yr)"], "Total Energy costs|Liquids (billion US$2005/yr)")) - + ##### Liquids|Oil Ref costoil <- op_costs(ei="peoil",eo=se_Liq,te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(costoil + output[regi_on_gdx,,"Energy Investments|Liquids|Oil Ref (billion US$2005/yr)"], "Total Energy costs|Liquids|Oil Ref (billion US$2005/yr)")) - + ##### Liquids|Fossil cost <- op_costs(ei=petyf,eo=se_Liq,te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Liquids|Fossil (billion US$2005/yr)"], "Total Energy costs|Liquids|Fossil (billion US$2005/yr)")) ##### Liquids|Fossil|w/o oil tmp <- mbind(tmp,setNames(cost - costoil + output[regi_on_gdx,,"Energy Investments|Liquids|Fossil|w/o oil (billion US$2005/yr)"], "Total Energy costs|Liquids|Fossil|w/o oil (billion US$2005/yr)")) - + ##### Liquids|Bio cost <- op_costs(ei=perenew,eo=se_Liq,te=pe2se$all_te,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|Liquids|Bio (billion US$2005/yr)"], "Total Energy costs|Liquids|Bio (billion US$2005/yr)")) - + ##### CO2 Trans&Stor cost <- op_costs(ei=ccs2te$all_enty,eo=ccs2te$all_enty1,te=ccs2te$all_te,e2e=ccs2te,teall2rlf=teall2rlf,vm_prodE=NULL,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost + output[regi_on_gdx,,"Energy Investments|CO2 Trans&Stor (billion US$2005/yr)"], "Total Energy costs|CO2 Trans&Stor (billion US$2005/yr)")) - - ##### Other + + ##### Other tmp <- mbind(tmp,setNames(tmp[,,"Total Energy costs (billion US$2005/yr)"]- tmp[,,"Total Energy costs|Electricity (billion US$2005/yr)"]- tmp[,,"Total Energy costs|Hydrogen (billion US$2005/yr)"]- @@ -588,69 +588,69 @@ reportCosts <- function(gdx,output=NULL,regionSubsetList=NULL,t=c(seq(2005,2060, tmp[,,"Total Energy costs|Heat (billion US$2005/yr)"]- tmp[,,"Total Energy costs|CO2 Trans&Stor (billion US$2005/yr)"], "Total Energy costs|Other (billion US$2005/yr)")) - + ##################################### ########## O & M costs ############## ##################################### - + ei=temapall$all_enty eo=sety te=teall2rlf$all_te e2e=temapall - + ##### Total tmp <- mbind(tmp,setNames(v_costom * 1000, "OandM costs (billion US$2005/yr)")) - + ##### CDR - tmp <- mbind(tmp,setNames(vm_omcosts_cdr * 1000, "OandM costs CDR (billion US$2005/yr)")) - + tmp <- mbind(tmp,setNames(vm_omcosts_cdr * 1000, "OandM costs CDR (billion US$2005/yr)")) + ##################################### ########## Operational costs ######## ##################################### - + ##### Fossils cost1 <- op_costs(ei="pecoal",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs_part2_foss(pe="pecoal",se="seel",te=tenoccs,vm_prodSe,pe2se,p_dataeta,vm_costfu_ex,vm_fuelex,sm_tdptwyr2dpgj,pm_conv_TWa_EJ) tmp <- mbind(tmp,setNames(cost1+cost2, "Operational costs|Elec|Coal|w/o CC (billion US$2005/yr)")) - + cost1 <- op_costs(ei="pecoal",eo="seel",te=teccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs_part2_foss(pe="pecoal",se="seel",te=teccs,vm_prodSe,pe2se,p_dataeta,vm_costfu_ex,vm_fuelex,sm_tdptwyr2dpgj,pm_conv_TWa_EJ) tmp <- mbind(tmp,setNames(cost1+cost2, "Operational costs|Elec|Coal|w/ CC (billion US$2005/yr)")) - + cost1 <- op_costs(ei="pegas",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs_part2_foss(pe="pegas",se="seel",te=tenoccs,vm_prodSe,pe2se,p_dataeta,vm_costfu_ex,vm_fuelex,sm_tdptwyr2dpgj,pm_conv_TWa_EJ) tmp <- mbind(tmp,setNames(cost1+cost2, "Operational costs|Elec|Gas|w/o CC (billion US$2005/yr)")) - + cost1 <- op_costs(ei="pegas",eo="seel",te=teccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs_part2_foss(pe="pegas",se="seel",te=teccs,vm_prodSe,pe2se,p_dataeta,vm_costfu_ex,vm_fuelex,sm_tdptwyr2dpgj,pm_conv_TWa_EJ) tmp <- mbind(tmp,setNames(cost1+cost2, "Operational costs|Elec|Gas|w/ CC (billion US$2005/yr)")) - + ##### Biomass price_pebiolc <- pebal.m[,,"pebiolc"] / (budget.m+1e-10) * 1000 / pm_conv_TWa_EJ - + cost1 <- op_costs(ei="pebiolc",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- price_pebiolc * op_costs_part2_bio_nuc(pe="pebiolc",se="seel",te=tenoccs,vm_prodSe,pe2se,p_dataeta,pm_conv_TWa_EJ) tmp <- mbind(tmp,setNames(cost1+cost2, "Operational costs|Elec|Biomass|w/o CC (billion US$2005/yr)")) - + cost1 <- op_costs(ei="pebiolc",eo="seel",te=teccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- price_pebiolc * op_costs_part2_bio_nuc(pe="pebiolc",se="seel",te=teccs,vm_prodSe,pe2se,p_dataeta,pm_conv_TWa_EJ) tmp <- mbind(tmp,setNames(cost1+cost2, "Operational costs|Elec|Biomass|w/ CC (billion US$2005/yr)")) - - ##### Nuclear + + ##### Nuclear cost1 <- op_costs(ei="peur",eo="seel",te="tnrs",e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) cost2 <- op_costs_part2_bio_nuc(pe="peur",se="seel",te="tnrs",vm_prodSe,pe2se,p_dataeta,pm_conv_TWa_EJ) tmp <- mbind(tmp,setNames(cost1*cost2, "Operational costs|Elec|Nuclear (billion US$2005/yr)")) - + ##### Renewables cost1 <- op_costs(ei=setdiff(perenew,pebio),eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost1, "Operational costs|Elec|Non-Bio Re (billion US$2005/yr)")) - + cost1 <- op_costs(ei="pesol",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost1, "Operational costs|Elec|Solar (billion US$2005/yr)")) - + cost1 <- op_costs(ei="pewin",eo="seel",te=tenoccs,e2e=pe2se,teall2rlf=teall2rlf,vm_prodE=vm_prodSe,pm_data=pm_data,vm_cap=vm_cap,v_investcost=v_investcost) tmp <- mbind(tmp,setNames(cost1, "Operational costs|Elec|wind (billion US$2005/yr)")) - + # add global values tmp <- mbind(tmp, dimSums(tmp,dim=1)) # add other region aggregations diff --git a/tests/testthat/test-convGDX2mif.R b/tests/testthat/test-convGDX2mif.R index 1088413c..06ea957a 100644 --- a/tests/testthat/test-convGDX2mif.R +++ b/tests/testthat/test-convGDX2mif.R @@ -11,7 +11,7 @@ library(dplyr) library(gdx) test_that("Test if REMIND reporting is produced as it should and check data integrity", { - skip_if_not(as.logical(gdxrrw::igdx(silent = TRUE)), "gdxrrw is not initialized properly") + skip_on_ci() # add GDXs for comparison here: gdxPaths <- NULL diff --git a/tests/testthat/test-piamInterfaces-Ariadne.R b/tests/testthat/test-piamInterfaces-Ariadne.R index 4739a5ad..905121ef 100644 --- a/tests/testthat/test-piamInterfaces-Ariadne.R +++ b/tests/testthat/test-piamInterfaces-Ariadne.R @@ -1,7 +1,7 @@ library(gdx) test_that("Test if REMIND reporting produces mandatory variables for Ariadne reporting", { - skip_if_not(as.logical(gdxrrw::igdx(silent = TRUE)), "gdxrrw is not initialized properly") + skip_on_ci() gdxPath <- file.path(tempdir(), "fulldata.gdx") diff --git a/tests/testthat/test-piamInterfaces-ECEMF.R b/tests/testthat/test-piamInterfaces-ECEMF.R index bef3ed61..2217d341 100644 --- a/tests/testthat/test-piamInterfaces-ECEMF.R +++ b/tests/testthat/test-piamInterfaces-ECEMF.R @@ -1,7 +1,7 @@ library(gdx) test_that("Test if REMIND reporting produces mandatory variables for ECEMF reporting", { - skip_if_not(as.logical(gdxrrw::igdx(silent = TRUE)), "gdxrrw is not initialized properly") + skip_on_ci() gdxPath <- file.path(tempdir(), "fulldata.gdx") diff --git a/tests/testthat/test-piamInterfaces-NAVIGATE.R b/tests/testthat/test-piamInterfaces-NAVIGATE.R index 87326016..4ea8e282 100644 --- a/tests/testthat/test-piamInterfaces-NAVIGATE.R +++ b/tests/testthat/test-piamInterfaces-NAVIGATE.R @@ -1,7 +1,7 @@ library(gdx) test_that("Test if REMIND reporting produces mandatory variables for NAVIGATE reporting", { - skip_if_not(as.logical(gdxrrw::igdx(silent = TRUE)), "gdxrrw is not initialized properly") + skip_on_ci() gdxPath <- file.path(tempdir(), "fulldata.gdx")