Commit 13093ce1 authored by Toni's avatar Toni
Browse files

Added a program that prepares data for R to be plotted from backbone output

See plot_building.gms
parent 4a9b7777
......@@ -33,6 +33,7 @@ $endif
* === Libraries ===============================================================
$libinclude scenred2
$onlisting
* === Definitions, sets, parameters and input data=============================
$include 'inc/1a_definitions.gms' // Definitions for possible model settings
......
......@@ -185,7 +185,10 @@ $if defined scenario
node_building_envelope_mass(node),
node_building_interior_air_and_furniture(node),
node_building_internal_mass(node)
node2node_building(node_building,node)
node_building2node(node_building,node)
unit_heat_and_cool(unit)
unit_DHW(unit)
node_building2unit(node_building,unit)
* --- Set of timeseries that will be read from files between solves -----------
mTimeseries_loop_read(mType, timeseries) "Those time series that will be read between solves"
......
......@@ -214,6 +214,7 @@ Parameters
* --- Energy modelling for buildings -----------------------------------------
Parameters
ts_priceElspot(t) "Elspot prices (EUR/MWh)"
building_squares(node_building) "Building square meters (m2)"
ts_priceElspot(t) "Elspot prices (EUR/MWh)"
building_squares(node_building) "Building square meters (m2)"
c2k "Convert celcius to kelvin degrees"
;
......@@ -92,9 +92,16 @@ $loaddc gnss_bound
$loaddc uss_bound
* Energy modelling for buildings
$loaddc ts_priceElspot
$loaddc node_building node_building_DHWT node_building_envelope_mass node_building_interior_air_and_furniture node_building_internal_mass
$loaddc node2node_building
$loaddc building_squares
$loaddc node_building
$loaddc node_building_DHWT
$loaddc node_building_envelope_mass
$loaddc node_building_interior_air_and_furniture
$loaddc node_building_internal_mass
$loaddc node_building2node
$loaddc unit_heat_and_cool
$loaddc unit_DHW
$loaddc node_building2unit
$loaddc building_squares c2k
$gdxin
......
......@@ -9,8 +9,9 @@ Solvelink = %Solvelink.ChainScript%
threads = 1 // How many cores the solver can use: 0 = all cores; negative values = all cores - n
*solprint = silent // Don't print a lot of stuff into .lst?
option limrow=9, limcol=99;
option solver=cbc;
limrow=9,
limcol=99
solver=cbc;
;
$onInclude
......
......@@ -37,37 +37,46 @@ $load ts_influx p_gnBoundaryPropertiesForStates p_gnu_io p_gn p_unit p_gnn p_s_d
$gdxin
* Modify Input (optional)
Scalars
Parameters
modify_input "Modify input (0=no, 1=yes: to set new limits)" / 1 /
c2k "Convert celcius to kelvin degrees" / 275.15 /
;
display unit;
Sets
dir "Direction: lo ,reference ,up" / lo, ref, up/
place "Measurement place in building" / DHWT, envelope_mass, internal_mass, interior_air_and_furniture /
place "Measurement place in building" / interior_air_and_furniture, internal_mass, envelope_mass, DHWT /
node_building / IDA_ESBO_DH1, IDA_ESBO_DH2, IDA_ESBO_AB /
node_building_DHWT(node) / "IDA_ESBO_DH1.DHWT1000", "IDA_ESBO_DH2.DHWT1000", "IDA_ESBO_AB.DHWT1000" /
node_building_envelope_mass(node) / "IDA_ESBO_DH1.envelope_mass", "IDA_ESBO_DH2.envelope_mass", "IDA_ESBO_AB.envelope_mass" /
node_building_internal_mass(node) / "IDA_ESBO_DH1.internal_mass", "IDA_ESBO_DH2.internal_mass", "IDA_ESBO_AB.internal_mass" /
node_building_interior_air_and_furniture(node) / "IDA_ESBO_DH1.interior_air_and_furniture", "IDA_ESBO_DH2.interior_air_and_furniture", "IDA_ESBO_AB.interior_air_and_furniture" /
node2node_building(node_building,node) /
IDA_ESBO_DH1.("IDA_ESBO_DH1.DHWT1000", "IDA_ESBO_DH1.envelope_mass", "IDA_ESBO_DH1.internal_mass","IDA_ESBO_DH1.interior_air_and_furniture")
IDA_ESBO_DH2.("IDA_ESBO_DH2.DHWT1000", "IDA_ESBO_DH2.envelope_mass", "IDA_ESBO_DH2.internal_mass","IDA_ESBO_DH2.interior_air_and_furniture")
IDA_ESBO_AB.("IDA_ESBO_AB.DHWT1000", "IDA_ESBO_AB.envelope_mass", "IDA_ESBO_AB.internal_mass","IDA_ESBO_AB.interior_air_and_furniture")
/;
node_building_internal_mass(node) / "IDA_ESBO_DH1.internal_mass", "IDA_ESBO_DH2.internal_mass", "IDA_ESBO_AB.internal_mass" /
node_building_envelope_mass(node) / "IDA_ESBO_DH1.envelope_mass", "IDA_ESBO_DH2.envelope_mass", "IDA_ESBO_AB.envelope_mass" /
node_building_DHWT(node) / "IDA_ESBO_DH1.DHWT1000", "IDA_ESBO_DH2.DHWT1000", "IDA_ESBO_AB.DHWT1000" /
node_building2node(node_building,node) /
IDA_ESBO_DH1.("IDA_ESBO_DH1.interior_air_and_furniture", "IDA_ESBO_DH1.internal_mass", "IDA_ESBO_DH1.envelope_mass" ,"IDA_ESBO_DH1.DHWT1000")
IDA_ESBO_DH2.("IDA_ESBO_DH2.interior_air_and_furniture", "IDA_ESBO_DH2.internal_mass", "IDA_ESBO_DH2.envelope_mass" ,"IDA_ESBO_DH2.DHWT1000")
IDA_ESBO_AB .("IDA_ESBO_AB.interior_air_and_furniture" , "IDA_ESBO_AB.internal_mass" , "IDA_ESBO_AB.envelope_mass" ,"IDA_ESBO_AB.DHWT1000")
/
unit_heat_and_cool(unit) /
"IDA_ESBO_DH1.ideal_heating", "IDA_ESBO_DH2.ideal_heating", "IDA_ESBO_AB.ideal_heating",
"IDA_ESBO_DH1.ideal_cooling", "IDA_ESBO_DH2.ideal_cooling", "IDA_ESBO_AB.ideal_cooling"
/
unit_DHW(unit) /
"IDA_ESBO_DH1.ideal_DHW", "IDA_ESBO_DH2.ideal_DHW", "IDA_ESBO_AB.ideal_DHW"
/
node_building2unit(node_building,unit) /
IDA_ESBO_DH1.("IDA_ESBO_DH1.ideal_heating","IDA_ESBO_DH1.ideal_cooling","IDA_ESBO_DH1.ideal_DHW")
IDA_ESBO_DH2.("IDA_ESBO_DH2.ideal_heating","IDA_ESBO_DH2.ideal_cooling","IDA_ESBO_DH2.ideal_DHW")
IDA_ESBO_AB .("IDA_ESBO_AB.ideal_heating" ,"IDA_ESBO_AB.ideal_cooling" ,"IDA_ESBO_AB.ideal_DHW")
/
;
Table
temp(place,dir) "Limit temperatures in Celcius"
lo ref up
DHWT 60 60 80
envelope_mass 0 20 50
interior_air_and_furniture 20 20 24
internal_mass 20 20 24
envelope_mass 0 20 50
DHWT 60 60 80
;
*TODO
Parameter building_squares (node_building) Building square meters /
"IDA_ESBO_DH1" 135.56
"IDA_ESBO_DH2" 145.33
......@@ -77,28 +86,28 @@ Parameter building_squares (node_building) Building square meters /
if(modify_input=1,
* Defintion: p_gnBoundaryPropertiesForStates(grid,node,param_gnBoundaryTypes,param_gnBoundaryProperties)
display grid,node,node_building_DHWT,node_building_envelope_mass,node_building_interior_air_and_furniture,node_building_internal_mass,param_gnBoundaryTypes,param_gnBoundaryProperties,p_gnBoundaryPropertiesForStates;
* Set temperature (Celcius) limits for building_interior_air_and_furniture in Celcius
p_gnBoundaryPropertiesForStates('building',node_building_interior_air_and_furniture,'downwardLimit','constant') = c2k + temp('interior_air_and_furniture' ,'lo');
p_gnBoundaryPropertiesForStates('building',node_building_interior_air_and_furniture,'reference','constant') = c2k + temp('interior_air_and_furniture' ,'ref');
p_gnBoundaryPropertiesForStates('building',node_building_interior_air_and_furniture,'upwardLimit','constant') = c2k + temp('interior_air_and_furniture' ,'up');
* Set temperature (Celcius) limits for building_internal_mass in Celcius
p_gnBoundaryPropertiesForStates('building',node_building_internal_mass,'downwardLimit','constant') = c2k + temp('internal_mass','lo');
p_gnBoundaryPropertiesForStates('building',node_building_internal_mass,'reference','constant') = c2k + temp('internal_mass','ref');
p_gnBoundaryPropertiesForStates('building',node_building_internal_mass,'upwardLimit','constant') = c2k + temp('internal_mass','up');
* Set temperature limits for building_envelope_mass in Celcius
p_gnBoundaryPropertiesForStates('building',node_building_envelope_mass,'downwardLimit','constant') = c2k + temp('envelope_mass' ,'lo ');
p_gnBoundaryPropertiesForStates('building',node_building_envelope_mass,'reference','constant') = c2k + temp('envelope_mass' ,'ref');
p_gnBoundaryPropertiesForStates('building',node_building_envelope_mass,'upwardLimit','constant') = c2k +temp('envelope_mass' ,'up');;
* Set temperature limits for Domestic Hot Water Tank (DHWT)
p_gn(grid, node_building_DHWT, 'boundStart') = 1;
p_gnBoundaryPropertiesForStates('building',node_building_DHWT,'reference','useConstant') = 1;
p_gnBoundaryPropertiesForStates('building',node_building_DHWT,'downwardLimit','constant') = c2k + temp('DHWT' ,'lo');
p_gnBoundaryPropertiesForStates('building',node_building_DHWT,'reference','constant') = c2k + temp('DHWT' ,'ref');
p_gnBoundaryPropertiesForStates('building',node_building_DHWT,'upwardLimit','constant')= c2k + temp('DHWT' ,'up');
* Set temperature limits for building_envelope_mass in Celcius
p_gnBoundaryPropertiesForStates('building',node_building_envelope_mass,'downwardLimit','constant') = c2k + temp('envelope_mass' ,'lo ');
p_gnBoundaryPropertiesForStates('building',node_building_envelope_mass,'reference','constant') = c2k + temp('envelope_mass' ,'ref');
p_gnBoundaryPropertiesForStates('building',node_building_envelope_mass,'upwardLimit','constant') = c2k +temp('envelope_mass' ,'up');;
* Set temperature (Celcius) limits for building_internal_mass in Celcius
p_gnBoundaryPropertiesForStates('building',node_building_internal_mass,'downwardLimit','constant') = c2k + temp('internal_mass','lo');
p_gnBoundaryPropertiesForStates('building',node_building_internal_mass,'reference','constant') = c2k + temp('internal_mass','ref');
p_gnBoundaryPropertiesForStates('building',node_building_internal_mass,'upwardLimit','constant') = c2k + temp('internal_mass','up');
* Set temperature (Celcius) limits for building_interior_air_and_furniture in Celcius
p_gnBoundaryPropertiesForStates('building',node_building_interior_air_and_furniture,'downwardLimit','constant') = c2k + temp('interior_air_and_furniture' ,'lo');
p_gnBoundaryPropertiesForStates('building',node_building_interior_air_and_furniture,'reference','constant') = c2k + temp('interior_air_and_furniture' ,'ref');
p_gnBoundaryPropertiesForStates('building',node_building_interior_air_and_furniture,'upwardLimit','constant') = c2k + temp('interior_air_and_furniture' ,'up');
) ;
* Read elspot prices
* Adding exogenous commodity electricity prices : ts_priceElspot
Set
tsIso Time-stamp in ISO8601 format
;
......@@ -110,10 +119,7 @@ $gdxIn input\elspot_prices_2013.gdx
$load tsIso elspotIsoBB ts_priceElspot=elspotBB
$gdxin
* Adding exogenous commodity electricity that can be bought
* Write input with domains at execution time to take in consideration modifications
execute_unloaddi "input\inputDataAdjusted1.gdx";
execute_unloaddi "input\inputDataAdjusted1Squuezed.gdx" node2node_building ts_priceElspot ts_influx effLevelGroupUnit p_gnBoundaryPropertiesForStates p_gnu_io p_gn p_unit node p_gnn unit unitUnittype grid p_s_discountFactor unittype
execute_unloaddi "input\inputDataAdjusted1Squuezed.gdx" node_building2node, node_building2unit, ts_priceElspot ts_influx effLevelGroupUnit p_gnBoundaryPropertiesForStates p_gnu_io p_gn p_unit node p_gnn unit unitUnittype grid p_s_discountFactor unittype
MODEL RUN DETAILS
User tltoni
Date 01/07/22
Time 14:16:58
GAMS version 37.1
GAMS system GAMS Base Module 37.1.0 r07954d5 Released Nov 11, 2021 WEI x86 64bit/MS Window
version v1.5-60-g04e5406+
time (s)
Compilation 0
Execution 19
Total 52
MODEL FEATURES
Model: building
-----------------------------------------------------------------------
Active features:
storageValue Use storage value instead of fixed control
Start time: 1
Length of forecasts: 0
Model horizon: 336
Model jumps after solve: 168
Last time period to solve: 8904
Number of samples: 1
......@@ -23,6 +23,8 @@ library(optparse)
library(tools)
library(rlang)
library(forcats)
library(reshape)
suppressMessages(library(rapportools))
#CMD Line Option Management and Error Checking
......@@ -31,8 +33,12 @@ option_list = list(
help="Input file name (GDX) [default= %default]", metavar="character"),
make_option(c("-o", "--output"), type="character", default="Rplots.pdf",
help="Output file name (PDF) [default= %default]", metavar="character"),
make_option(c("-p", "--parameter"), type="character", default="p",
make_option(c("-p", "--parameter"), type="character", default="p_r_gen",
help="parameter name in gdx, expects 3-dimensional, e.g. p(x,y) [default= %default]", metavar="character"),
make_option(c("-x", "--xlabel"), type="character", default="",
help="Optional X-axis label for plot [default= %default]", metavar="character"),
make_option(c("-y", "--ylabel"), type="character", default="",
help="Optional Y-axis label for plot [default= %default]", metavar="character"),
make_option(c("-w", "--window"), type="integer", default="",
help="do additional plots by splitting x (x-axis) to the specified time step length [default= %default]", metavar="integer"),
make_option(c("-a", "--archive"), type="logical", default=FALSE,
......@@ -66,7 +72,7 @@ if (0 == igdx(silent=TRUE)) stop ("the gdx shared library has not been loaded")
tryCatch({
gdxName <- opt$input
symName <- opt$parameter
df_p <- rgdx.param(gdxName,symName, ts=TRUE)
df_p <- rgdx.param(gdxName,symName, ts=TRUE, squeeze=FALSE)
}
, error = function(ex) { print(ex) ; stop("FAILED: see above message", call.=FALSE) }
)
......@@ -77,27 +83,35 @@ if(ncol(df_p)!=3){
stop(sprintf("Symbol %s has %d columns, expected 3 (third column holds values)", symName, ncol(df_p)), call.=FALSE)
}
# read set x and y from parameter p(x,y)
# read set x and y from parameter p(x,y) if not set by swithches -x and -y
xvar_desc <- vector("character")
tryCatch({
gdxName <- opt$input
symName <- opt$parameter
xvar=as_string(sym(colnames(df_p)[1]))
df_x <- rgdx.set(gdxName, xvar, names=xvar, ts=TRUE)
xvar_desc = paste(attr(df_x,"ts"), " ")
if(is.empty(opt$xlabel)){
tryCatch({
gdxName <- opt$input
symName <- opt$parameter
xvar=as_string(sym(colnames(df_p)[1]))
df_x <- rgdx.set(gdxName, xvar, names=xvar, ts=TRUE)
xvar_desc = paste(attr(df_x,"ts"), " ")
}
, error = function(ex) { xvar_desc="" ; print(ex) ; print("FAILED to read set description: see above message", call.=FALSE) }
)
}else{
xvar_desc = opt$xlabel
}
, error = function(ex) { yvar_desc="" ; print(ex) ; print("FAILED to read set description: see above message", call.=FALSE) }
)
yvar_desc <- vector("character")
tryCatch({
gdxName <- opt$input
symName <- opt$parameter
yvar=as_string(sym(colnames(df_p)[2]))
df_y <- rgdx.set(gdxName, yvar, names=yvar, ts=TRUE)
yvar_desc = paste(attr(df_y,"ts"), " ")
}
, error = function(ex) { yvar_desc="" ; print(ex) ; print("FAILED to read set description: see above message", call.=FALSE) }
)
if(is.empty(opt$ylabel)){
tryCatch({
gdxName <- opt$input
symName <- opt$parameter
yvar=as_string(sym(colnames(df_p)[2]))
df_y <- rgdx.set(gdxName, yvar, names=yvar, ts=TRUE)
yvar_desc = paste(attr(df_y,"ts"), " ")
}
, error = function(ex) { yvar_desc="" ; print(ex) ; print("FAILED to read set description: see above message", call.=FALSE) }
)
}else{
yvar_desc = opt$ylabel
}
# store data from gdx
xvar_labels <- unique(df_p[1])
......@@ -132,7 +146,12 @@ yvar <- sym(colnames(df_p)[2])
value <- sym(colnames(df_p)[3])
xlabel <- paste(xvar_desc,xvar,"(",xvar_labels[1,1],"=1, ...,",xvar_labels[window_end,1],"=",window_end,")")
ylabel <- paste(yvar_desc,yvar)
g <- ggplot(df_p, aes(x=!!xvar, y=!!value, group=!!yvar, color=fct_reorder2(df_p[,2],df_p[,1],df_p[,3]))) + labs(colour = yvar) + geom_line() + theme(text = element_text(size=6))+ scale_color_brewer(palette = "Dark2") + ggtitle(ptitle) + xlab(xlabel) + ylab(ylabel) + theme(legend.position="bottom", legend.text = element_text(size=6))
nr_colors <- nrow(unique(df_p[2]))
mypalette="Set3"
if(nr_colors<=8){
mypalette="Dark2"
}
g <- ggplot(df_p, aes(x=!!xvar, y=!!value, group=!!yvar, color=fct_reorder2(df_p[,2],df_p[,1],df_p[,3]))) + labs(colour = yvar) + geom_line() + theme(text = element_text(size=6))+ scale_color_brewer(palette = mypalette) + ggtitle(ptitle) + xlab(xlabel) + ylab(ylabel) + theme(legend.position="bottom", legend.text = element_text(size=6))
# create PDF
pdf(file = pdf_name, width = 6.25, height = 4, family = "Times", pointsize = 6, onefile = TRUE)
......
$title Plot backbone output with R
$ontext
Plot backbone output with R for energy modelling of buildings
1. Reads backbones full output, e.g. debug.gdx
2. Uses do_r_plot.r do create figures of seleceted parameters
Toni Lastusilta (VTT) , 2022-01-09
$offtext
* Load sets and parameter definition from backbone
$set input_file_gdx inputDataAdjusted1.gdx
$batinclude backbone_definitions_4plots.gms
* Script to call R for making plots
$onechoV > runR.inc
$$log runR.inc creates line graphs with R from a two-dimensional parameter in a GDX file
$$log The file uses compile time variables %Ylabel% and %Xlabel% in case they are set ($set)
$$log Usage: $batInclude runR.gms GDXfile GDXparam
$$log Example: $batInclude runR.gms plot4r.gdx p value time
$$log Now: $batInclude runR.gms %1 %2 %3 %4
$$set r_ylabel
$$if set Ylabel $set r_ylabel -y "%Ylabel%"
$$set r_xlabel
$$if set Xlabel $set r_xlabel -x "%Xlabel%"
execute 'Rscript "%gams.wDir%plots\do_r_plot.r" -i "%gams.wDir%plots/%1" -o "%gams.wDir%output/%2.pdf" -p %2 -w 720 -a FALSE %r_ylabel% %r_xlabel% ';
myerrorlevel = errorlevel;
if(myerrorlevel=0,
Execute.ASyncNC 'SumatraPDF.exe "%gams.wDir%output/%2.pdf"';
else
abort "Execution error in Rscript with input argument %1 )";
)
$offecho
* Define sets and parameters to be used to prepare data for plots or in ggplots in R
Set
tparam(t) "Temporary: Time steps used for a parameter"
;
Parameter
myerrorlevel Stop execution if error in external call / 0 /
w2kw Convert whatt to kilowhatt / 0.001 /
sign Switch sign / -1 /
;
* Define source GDX for plotting data
$set backbone_output_GDX "output\archive\out_alt_obj.gdx"
* CREATE PLOTS:
* %GDXfile% for R, %GDXparam% parameter to plot, %TMPParam% two-dimensional counterpart to %GDXparam%
* Plots 1 : ts_influx
* The influence of external power (weather) on building, namely envelope_mass due outside temperature changes and interior air due to ventilation
* Plot ts_influx_absolute *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam ts_influx
$set TMPparam ts_influx_absolute
$set Ylabel "Track exogenous commodities (kWh) :"
Parameter %TMPparam%(t,node) "External power (weather) influencing building" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),node)=sum((grid,f)$(sameas(grid,"building") and sameas(f,'f00')),w2kw*%GDXparam%(grid,node,f,t) + eps);
execute_unload 'plots/%GDXfile%', tparam=t, node, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plot ts_influx_normalized *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam ts_influx
$set TMPparam ts_influx_normalized
$set Ylabel "Track exogenous commodities per m2 (kWh) :"
Parameter %TMPparam%(t,node) "External power (weather) influencing building - normalized by bulding m2" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),node)=sum((grid,node_building2node(node_building,node),f)$(sameas(grid,"building") and sameas(f,'f00')), w2kw*%GDXparam%(grid,node,f,t)/building_squares(node_building) + eps);
execute_unload 'plots/%GDXfile%', tparam=t, node, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plots 2 : r_gen
* Electric power consumption for heating and cooling of air and heating of domestic hot water
* Plot r_gen heat absolute *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_gen
$set TMPparam r_gen_heat_absolute
$set Ylabel Electricity usage (kW) :
Parameter %TMPparam%(t,unit) "Electric power consumption for heating and cooling of air" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),unit_heat_and_cool(unit))=sum((grid,node,f)$(sameas(grid,"elec") and sameas(node,'link_node') and sameas(f,'f00')),sign* w2kw* %GDXparam%(grid,node,unit,f,t) + eps);
execute_unload 'plots/%GDXfile%', tparam=t, unit, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plot r_gen_heat_normalized *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_gen
$set TMPparam r_gen_heat_normalized
$set Ylabel Electricity usage per m2(kW) :
Parameter %TMPparam%(t,unit) "Electric power consumption for heating and cooling of air - normalized by bulding m2" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),unit_heat_and_cool(unit))=sum((grid,node,node_building2unit(node_building,unit),f)$(sameas(grid,"elec") and sameas(node,'link_node') and sameas(f,'f00')),sign* w2kw* %GDXparam%(grid,node,unit,f,t)/building_squares(node_building) + eps);
execute_unload 'plots/%GDXfile%', tparam=t, unit, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plot r_gen DHW absolute *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_gen
$set TMPparam r_gen_dhw_absolute
$set Ylabel Electricity usage (kW) :
Parameter %TMPparam%(t,unit) "Electric power consumption for domestic hot water" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),unit_DHW(unit))=sum((grid,node,f)$(sameas(grid,"elec") and sameas(node,'link_node') and sameas(f,'f00')),sign* w2kw* %GDXparam%(grid,node,unit,f,t) + eps);
execute_unload 'plots/%GDXfile%', tparam=t, unit, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plot r_gen DHW normalized *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_gen
$set TMPparam r_gen_dhw_normalized
$set Ylabel Electricity usage per m2(kW) :
Parameter %TMPparam%(t,unit) "Electric power consumption for domestic hot water - normalized by bulding m2" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),unit_DHW(unit))=sum((grid,node,node_building2unit(node_building,unit),f)$(sameas(grid,"elec") and sameas(node,'link_node') and sameas(f,'f00')),sign* w2kw* %GDXparam%(grid,node,unit,f,t)/building_squares(node_building) + eps);
execute_unload 'plots/%GDXfile%', tparam=t, unit, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plots 3 r_state
* Current building temperature for interior_air_and_furniture, internal_mass, envelope_mass and DHWT
* Plot r_state(interior_air) *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_state
$set TMPparam r_state_interior_air
$set Ylabel Temperture (Celcius) :
Parameter %TMPparam%(t,node) "Temperature at interior_air_and_furniture (Celcius)" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),node_building_interior_air_and_furniture(node))=sum((grid,f)$(sameas(grid,"building") and sameas(f,'f00')),%GDXparam%(grid,node,f,t) - c2k + eps);
execute_unload 'plots/%GDXfile%', tparam=t, node, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plot r_state(internal_mass) *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_state
$set TMPparam r_state_internal_mass
$set Ylabel Temperture (Celcius) :
Parameter %TMPparam%(t,node) "Temperature at internal_mass: inside walls (Celcius)" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),node_building_internal_mass(node))=sum((grid,f)$(sameas(grid,"building") and sameas(f,'f00')),%GDXparam%(grid,node,f,t) - c2k + eps);
execute_unload 'plots/%GDXfile%', tparam=t, node, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plot r_state(envelope_mass) *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_state
$set TMPparam r_state_envelope_mass
$set Ylabel Temperture (Celcius) :
Parameter %TMPparam%(t,node) "Temperature at envelope_mass: outside walls (Celcius)" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),node_building_envelope_mass(node))=sum((grid,f)$(sameas(grid,"building") and sameas(f,'f00')),%GDXparam%(grid,node,f,t) - c2k + eps);
execute_unload 'plots/%GDXfile%', tparam=t, node, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
* Plot r_state(DHWT) *******************************************************
$set GDXfile plot4r.gdx
$set GDXparam r_state
$set TMPparam r_state_DHWT
$set Ylabel Temperture (Celcius) :
Parameter %TMPparam%(t,node) "Temperature at Domestic Hot Water Tank (Celcius)" ;
execute_loaddc "%backbone_output_GDX%", tparam=t_realized, %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),node_building_DHWT(node))=sum((grid,f)$(sameas(grid,"building") and sameas(f,'f00')),%GDXparam%(grid,node,f,t) - c2k + eps);
execute_unload 'plots/%GDXfile%', tparam=t, node, %TMPparam%;
$batInclude runR.inc %GDXfile% %TMPparam%
$title Plot backbone output with R
$ontext
Plot backbone output with R
1. Reads backbones full output, e.g. debug.gdx
2. Uses do_r_plot.r do create figures of seleceted parameters
Toni Lastusilta (VTT) , 2021-12-31
$offtext
Set
t "Model time steps (in hours)"
node "Track exogenous commodities (MWh/h)"
nodeP "Track exogenous commodities by m2 (MWh/h)"
node_building
node2node_building(node_building,node)
;
Parameter
ext(t,node) "External power (weather) influencing building"
ext2(t,nodeP) "External power (weather) influencing building - normalized by bulding m2"
;
$batinclude backbone_definitions_4plots.gms
$onlisting
* CREATE PLOTS
$onmultiR
$gdxin output\archive\out_alt_obj.gdx
$load node nodeP=node node_building
$load ts_influx node2node_building building_squares
$gdxin
ext(t,node)=sum((grid,f)$(ord(f)=1 and sameas(grid,"building")),ts_influx(grid,node,f,t)$(ord(f)=1 and ord(grid)=1));
ext2(t,nodeP)=sum((node2node_building(node_building,node))$sameas(node,nodeP),ext(t,node)/building_squares(node_building));
execute_unload 'plots/plot4r.gdx', t, node, nodeP, ext, ext2;
execute 'Rscript "%gams.wDir%plots\do_r_plot.r" -i "%gams.wDir%plots/plot4r.gdx" -o "%gams.wDir%output/ts_influx1.pdf" -p ext -w 1000 -a FALSE';
scalar myerrorlevel;
myerrorlevel = errorlevel;
if(myerrorlevel=0,
execute.async 'SumatraPDF.exe "%gams.wDir%output/ts_influx1.pdf"';
)
execute 'Rscript "%gams.wDir%plots\do_r_plot.r" -i "%gams.wDir%plots/plot4r.gdx" -o "%gams.wDir%output/ts_influx2.pdf" -p ext2 -w 1000 -a FALSE';
myerrorlevel = errorlevel;
if(myerrorlevel=0,
execute.async 'SumatraPDF.exe "%gams.wDir%output/ts_influx2.pdf"';
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment