Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sosorior committed Nov 8, 2023
1 parent 01c7fec commit d7880a2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
56 changes: 30 additions & 26 deletions R/reportElectricityPrices.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ reportElectricityPrices <- function(gdx, reporting_tau = FALSE) {
o_restargetrelativegross_tech_disc <- mbind(o_restargetrelativegross_tech_disc, m_restargetrelativegross_tech[, t2, ] / f_npv[t2]) #[Geur 2010/GWh-RES]
o_restargetrelativedem_tech_disc <- mbind(o_restargetrelativedem_tech_disc, m_restargetrelativedem_tech[, t2, ] / f_npv[t2]) #[Geur 2010/GWh-RES]

#Subsidies
o_subsidRES_disc <- (o_restargetrelativegross_tech_disc + o_restargetrelativedem_tech_disc + o_restarget_disc) #[Geur/GWh]

#Heat prices
if(heating == "fullDH") {
if(split_DH_decP2H == 0) { #no split berween DH and decP2H
Expand All @@ -211,38 +214,39 @@ reportElectricityPrices <- function(gdx, reporting_tau = FALSE) {
} else {
o_restargetrelative_DE_disc <- mbind(o_restargetrelative_DE_disc, m_restargetrelative_DE[, t2, ]/f_npv[t2]) #[Geur 2010/GWh-RES]
o_restargetrelative_disc <- mbind(o_restargetrelative_disc, m_restargetrelative[, t2, ]/f_npv[t2]) #[Geur 2010/GWh-RES]

#Subsidies
o_subsidRES_disc <- (o_restarget_disc + o_restargetrelative_DE_disc + o_restargetrelative_disc) #[Geur/GWh]
}
}

##Some price aggregation
#Heat prices at EU ETS level. The variable v_exdemand_DH includes also other sectors (industry and agriculture)
o_heatprices_EUETS_disc <-
(o_heatprices_DH_disc * v_exdemand_DH + o_heatprices_decP2H_disc * v_exdemand_decP2H) /
(v_exdemand_DH + v_exdemand_decP2H)
o_fullheprices_EUETS_disc <-
(o_fullheprices_DH_disc * v_exdemand_DH + o_fullheprices_decP2H_disc * v_exdemand_decP2H) /
(v_exdemand_DH + v_exdemand_decP2H)
#Heat prices in buildings (only for sources covered by EU ETS)
#First estimate buildings load supplied by DH (at every tau)
p_othersec_exdemand_DH <- readGDX(gdx, name = "p_othersec_exdemand_DH", field = "l", format = "first_found") # heat that is provided by DH to other sectors (industry and agriculture) [annual data per sector]
p_othersec_exdemand_DH <- limesMapping(p_othersec_exdemand_DH)[,getYears(v_exdemand_DH),]
o_bd_exdemand_DH <- v_exdemand_DH - p_othersec_exdemand_DH
o_heatprices_bd_EUETS_disc <-
(o_heatprices_DH_disc * o_bd_exdemand_DH + o_heatprices_decP2H_disc * v_exdemand_decP2H) /
(o_bd_exdemand_DH + v_exdemand_decP2H)
o_fullheprices_bd_EUETS_disc <-
(o_fullheprices_DH_disc * o_bd_exdemand_DH + o_fullheprices_decP2H_disc * v_exdemand_decP2H) /
(o_bd_exdemand_DH + v_exdemand_decP2H)


#Subsidies

#Some price aggregation when heat demand split between DH and decP2H
if(c_LIMESversion >= 2.28) {
o_subsidRES_disc <- (o_restargetrelativegross_tech_disc + o_restargetrelativedem_tech_disc + o_restarget_disc) #[Geur/GWh]
} else {
o_subsidRES_disc <- (o_restarget_disc + o_restargetrelative_DE_disc + o_restargetrelative_disc) #[Geur/GWh]
if(heating == "fullDH") {
if(split_DH_decP2H == 1) {
#Heat prices at EU ETS level. The variable v_exdemand_DH includes also other sectors (industry and agriculture)
o_heatprices_EUETS_disc <-
(o_heatprices_DH_disc * v_exdemand_DH + o_heatprices_decP2H_disc * v_exdemand_decP2H) /
(v_exdemand_DH + v_exdemand_decP2H)
o_fullheprices_EUETS_disc <-
(o_fullheprices_DH_disc * v_exdemand_DH + o_fullheprices_decP2H_disc * v_exdemand_decP2H) /
(v_exdemand_DH + v_exdemand_decP2H)
#Heat prices in buildings (only for sources covered by EU ETS)
#First estimate buildings load supplied by DH (at every tau)
p_othersec_exdemand_DH <- readGDX(gdx, name = "p_othersec_exdemand_DH", field = "l", format = "first_found", react = 'silent') # heat that is provided by DH to other sectors (industry and agriculture) [annual data per sector]
p_othersec_exdemand_DH <- limesMapping(p_othersec_exdemand_DH)[,getYears(v_exdemand_DH),]
o_bd_exdemand_DH <- v_exdemand_DH - p_othersec_exdemand_DH
o_heatprices_bd_EUETS_disc <-
(o_heatprices_DH_disc * o_bd_exdemand_DH + o_heatprices_decP2H_disc * v_exdemand_decP2H) /
(o_bd_exdemand_DH + v_exdemand_decP2H)
o_fullheprices_bd_EUETS_disc <-
(o_fullheprices_DH_disc * o_bd_exdemand_DH + o_fullheprices_decP2H_disc * v_exdemand_decP2H) /
(o_bd_exdemand_DH + v_exdemand_decP2H)
}
}
}


# Standard Reporting ------------------------------------------------------
if (!reporting_tau) { # for normal reporting}
##Electricity prices
Expand Down
10 changes: 6 additions & 4 deletions R/reportGeneration.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ reportGeneration <- function(gdx, output = NULL, reporting_tau = FALSE) {
v_storeout <- readGDX(gdx, name = "v_storeout", field = "l", format = "first_found", restore_zeros = FALSE)[, , tau]
v_storein <- readGDX(gdx, name = "v_storein", field = "l", format = "first_found", restore_zeros = FALSE)[, , tau]
v_exdemand <- readGDX(gdx, name = "v_exdemand", field = "l", format = "first_found", restore_zeros = FALSE)[, , tau] # demand
p_othersec_exdemand_DH <- readGDX(gdx, name = "p_othersec_exdemand_DH", field = "l", format = "first_found") # heat demand provided by DH to other sectors (industry and agriculture) [annual data per sector]
p_othersec_exdemand_DH <- readGDX(gdx, name = "p_othersec_exdemand_DH", field = "l", format = "first_found", react = 'silent') # heat demand provided by DH to other sectors (industry and agriculture) [annual data per sector]

# Make sure only the sets -> to reduce the size of the variables
v_seprod <- v_seprod[, , pety]
Expand All @@ -87,7 +87,10 @@ reportGeneration <- function(gdx, output = NULL, reporting_tau = FALSE) {
if (!is.null(o_netimports_tau)) {
o_netimports_tau <- limesMapping(o_netimports_tau)
}
p_othersec_exdemand_DH <- limesMapping(p_othersec_exdemand_DH)[,getYears(v_seprod),]
if (!is.null(p_othersec_exdemand_DH)) {
p_othersec_exdemand_DH <- limesMapping(p_othersec_exdemand_DH)[,getYears(v_seprod),]
}


# give explicit set names
getSets(v_storeout) <- c("region", "t", "tau", "enty2", "te")
Expand Down Expand Up @@ -243,8 +246,7 @@ reportGeneration <- function(gdx, output = NULL, reporting_tau = FALSE) {
collapseNames(v_storein_he) +
collapseNames(v_storeout_he)
#Total useful energy generate by DH to buildings
o_bd_seprodtotalDH_UE <- o_seprodtotalDH_UE -
p_othersec_exdemand_DH
o_bd_seprodtotalDH_UE <- o_seprodtotalDH_UE - p_othersec_exdemand_DH

# 1 (cont) Decentralized heat
if (c_buildings == 1) {
Expand Down

0 comments on commit d7880a2

Please sign in to comment.