+ Show code- Hide code
library(OpasnetUtils)
library(ggplot2)
#Data tables are converted into ovariables and stored
u.factor <- Ovariable(name= "u.factor", ddata = "Op_en5397", subset = "u.factor", getddata = FALSE)
surface.area <- Ovariable(name= "surface.area", ddata = "Op_en5397", subset = "surface.area", getddata = FALSE)
ventilation.rate <- Ovariable(name= "ventilation.rate", ddata = "Op_en5397", subset = "ventilation.rate", getddata = FALSE)
ventilation.heat.recovery <- Ovariable(name= "ventilation.heat.recovery", ddata = "Op_en5397", subset = "ventilation.heat.recovery", getddata = FALSE)
air.leak.factor <- Ovariable(name= "air.leak.factor", ddata = "Op_en5397", subset = "air.leak.factor", getddata = FALSE)
building.characteristics <- Ovariable(name= "building.characteristics", ddata = "Op_en5397", subset = "building.characteristics", getddata = FALSE)
total.floor.area <- Ovariable(name= "total.floor.area", ddata = "Op_en5397", subset = "total.floor.area", getddata = FALSE)
outdoor.temperature <- Ovariable(name= "outdoor.temperature", ddata = "Op_en5397", subset = "outdoor.temperature", getddata = FALSE)
residential.building.location <- Ovariable(name= "residential.building.location", ddata = "Op_en5397", subset = "residential.building.location", getddata = FALSE)
period.length <- Ovariable(name= "period.length", ddata = "Op_en5397", subset = "period.length", getddata = FALSE)
soil.temperature.difference <- Ovariable(name= "soil.temperature.difference", ddata = "Op_en5397", subset = "soil.temperature.difference", getddata = FALSE)
heating.season <- Ovariable(name= "heating.season", ddata = "Op_en5397", subset = "heating.season", getddata = FALSE)
sun.radiation.vertical.surface <- Ovariable(name= "sun.radiation.vertical.surface", ddata = "Op_en5397", subset = "sun.radiation.vertical.surface", getddata = FALSE)
window.direction <- Ovariable(name= "window.direction", ddata = "Op_en5397", subset = "window.direction", getddata = FALSE)
sun.heat.absorption.parameters <- Ovariable(name= "sun.heat.absorption.parameters", ddata = "Op_en5397", subset = "sun.heat.absorption.parameters", getddata = FALSE)
heat.production.efficiency <- Ovariable(name= "heat.production.efficiency", ddata = "Op_en5397", subset = "heat.production.efficiency", getddata = FALSE)
objects.store(u.factor, surface.area, ventilation.rate, ventilation.heat.recovery, air.leak.factor, building.characteristics, total.floor.area, outdoor.temperature, residential.building.location, period.length, soil.temperature.difference, heating.season, sun.radiation.vertical.surface, window.direction, sun.heat.absorption.parameters, heat.production.efficiency)
cat("Ovariablet tallennettu.\n")
#oprint(u.factor)
#oprint(surface.area)
#oprint(air.exchange)
#oprint(building.characteristics)
#oprint(outdoor.temperature)
#oprint(residential.building.location)
#oprint(ventilation.rate)
#Average monthly outdoor temperature for a residential building in Finland. Calculated based on monthly average temperatures and location of residential buildings in different parts of Finland
average.outdoor.temperature.month <- Ovariable(
name="average.outdoor.temperature.month",
dependencies = data.frame(
Name=c("outdoor.temperature", "residential.building.location"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
out <- outdoor.temperature * residential.building.location
out <- out@output[ , c("Location", "Month", "Construction.year", "Result")]
out <- aggregate(out[,colnames(out)=='Result'],by=list(out$Month, out$Construction.year),FUN="sum", na.rm="TRUE")
names(out) <- c("Month","Construction.year", "Result")
#out <- aggregate(out[,colnames(out)=='Result'],by=list(out$Construction.year),FUN="mean",na.rm="TRUE")
#names(out) <- c("Construction.year", "Result")
return(out)
}
)
#oprint(EvalOutput(average.outdoor.temperature.month))
#Average annual outdoor temperature for a residential building in Finland. Calculated based on monthly average temperatures.
average.outdoor.temperature.year <- Ovariable(
name="average.outdoor.temperature.year",
dependencies = data.frame(
Name=c("outdoor.temperature", "residential.building.location"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
#cat("Average outdoor temperature for a residential building in Finland. Calculated based on monthly average temperatures and location of residential buildings in different parts of Finland \n")
out <- outdoor.temperature * residential.building.location
#out@output <- out@output[ , c("Location", "Month", "Construction.year", "Result")]
#out@output <- aggregate(out@output[,4],by=list(out@output$Month, out@output$Construction.year),FUN="sum", na.rm="TRUE")
#names(out@output) <- c("Month","Construction.year", "average.outdoor.temperatureResult")
out <- out@output[ , c("Location", "Month", "Construction.year", "Result")]
out <- aggregate(out[,colnames(out)=='Result'],by=list(out$Month, out$Construction.year),FUN="sum", na.rm="TRUE")
names(out) <- c("Month","Construction.year", "Result")
out <- aggregate(out[,colnames(out)=='Result'],by=list(out$Construction.year),FUN="mean",na.rm="TRUE")
names(out) <- c("Construction.year", "Result")
return(out)
}
)
#oprint(average.outdoor.temperature.year)
cat("Total heat loss via heat conduction through outside walls, roof, ground floor, windows, and doors, kWh/month.\n")
conduction.heat.loss <- Ovariable(
name="conduction.heat.loss",
dependencies = data.frame(
Name=c("u.factor", "surface.area", "average.outdoor.temperature.month", "average.outdoor.temperature.year", "period.length", "soil.temperature.difference"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
building.characteristics <- opbase.data("Op_en5397.building_characteristics")
indoor.temperature <- Ovariable(name = "indoor.temperature")
indoor.temperature@output <- tidy(subset(building.characteristics, Parameter=="Indoor air temperature"), direction="long", objname="indoor.temperature")
indoor.temperature@output$Parameter <- NULL
#Conduction heat loss for outside walls, roof, windows, and outer doors:
temp1 <- u.factor * surface.area * (indoor.temperature - average.outdoor.temperature.month) * period.length / 1000
temp1 <- subset(temp1@output, Surface=="Outside wall" | Surface=="Roof" | Surface=="Window" | Surface=="Outer door")
temp1 <- aggregate(temp1[,colnames(temp1)=='Result'],by=list(temp1$Construction.year, temp1$Surface, temp1$Month),FUN="sum",na.rm="TRUE")
names(temp1) <- c("Construction.year", "Surface", "Month", "Result")
#Conduction heat loss for ground floor:
temp2 <- u.factor * surface.area * (indoor.temperature - (average.outdoor.temperature.year + 5 + soil.temperature.difference)) * period.length / 1000
temp2 <- subset(temp2@output, Surface=="Ground floor")
temp2 <- aggregate(temp2[,colnames(temp2)=='Result'],by=list(temp2$Construction.year, temp2$Surface, temp2$Month),FUN="sum",na.rm="TRUE")
names(temp2) <- c("Construction.year", "Surface", "Month", "Result")
#Combination of all heat conduction routes into a single value (kWh/month):
out <- rbind(temp1, temp2)
out <- aggregate(out[,colnames(temp2)=='Result'],by=list(out$Construction.year, out$Month),FUN="sum",na.rm="TRUE")
names(out) <- c("Construction.year", "Month", "Result")
return(out)
}
)
oprint(conduction.heat.loss)
cat("Total heat loss via active air ventilation, kWh/month. \n")
ventilation.heat.loss <- Ovariable(
name="ventilation.heat.loss",
dependencies = data.frame(
Name=c("ventilation.rate", "ventilation.heat.recovery", "total.floor.area", "average.outdoor.temperature.month", "period.length"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
building.characteristics <- opbase.data("Op_en5397.building_characteristics")
indoor.temperature <- Ovariable(name = "indoor.temperature")
indoor.temperature@output <- tidy(subset(building.characteristics, Parameter=="Indoor air temperature"), direction="long", objname="indoor.temperature")
indoor.temperature@output$Parameter <- NULL
#Building air removal rate (m3/s):
temp1 <- ventilation.rate * total.floor.area / 1000
#ventilation unit heat loss (W/K):
temp2 <- 1.2 * 1000 * temp1 * (1 - ventilation.heat.recovery)
#total heat loss (kWh/month):
out <- temp2 * (indoor.temperature - average.outdoor.temperature.month) * period.length / 1000
vars <- names(out@output) %in% c("Month", "Construction.year", "Result", "Source")
out <- out@output[vars]
return(out)
}
)
oprint(ventilation.heat.loss)
cat("Total heat loss via involuntary air leak, kWh/month.\n")
air.leak.heat.loss <- Ovariable(
name="air.leak.heat.loss",
dependencies = data.frame(
Name=c("air.leak.factor", "total.floor.area", "building.characteristics", "average.outdoor.temperature.month", "period.length"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
building.characteristics@output <- subset(building.characteristics@output, Parameter=="Room height")
room.height <- building.characteristics
building.characteristics <- opbase.data("Op_en5397.building_characteristics")
indoor.temperature <- Ovariable(name = "indoor.temperature")
indoor.temperature@output <- tidy(subset(building.characteristics, Parameter=="Indoor air temperature"), direction="long", objname="indoor.temperature")
indoor.temperature@output$Parameter <- NULL
#Building air leak rate (m3/s):
temp1 <- air.leak.factor * total.floor.area * room.height / 3600
#air leak unit heat loss (W/K):
temp2 <- 1.2 * 1000 * temp1
#total heat loss (kWh/month):
out <- temp2 * (indoor.temperature - average.outdoor.temperature.month) * period.length / 1000
vars <- names(out@output) %in% c("Month", "Construction.year", "Result", "Source")
out <- out@output[vars]
return(out)
}
)
oprint(EvalOutput(air.leak.heat.loss))
cat("Total heat loss due to household water heating, kWh/month.\n")
household.water.heating <- Ovariable(
name="household.water.heating",
dependencies = data.frame(
Name=c("period.length"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
building.characteristics <- opbase.data("Op_en5397.building_characteristics")
inhabitants <- Ovariable(name = "inhabitants")
inhabitants@output <- tidy(subset(building.characteristics, Parameter=="Inhabitants"), direction="long", objname="inhabitants")
inhabitants@output$Parameter <- NULL
hot.water.use <- Ovariable(name = "hot.water.use")
hot.water.use@output <- tidy(subset(building.characteristics, Parameter=="Hot water use"), direction="long", objname="hot.water.use")
hot.water.use@output$Parameter <- NULL
#Hot water use (m3/a/building):
temp1 <- hot.water.use * period.length / 24 * inhabitants / 1000
#total heat consumption (kWh/month):
out <- 1000 * 4.2 * temp1 * 50 / 3600
vars <- names(out@output) %in% c("Month", "Result", "Source")
out <- out@output[vars]
return(out)
}
)
oprint(household.water.heating)
cat("Internal heat sources - total heat gain due to sun heat absorption through windows, kWh/month.\n")
sun.heat.absorption <- Ovariable(
name="sun.heat.absorption",
dependencies = data.frame(
Name=c("sun.radiation.vertical.surface", "window.direction", "surface.area"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
sun.heat.absorption.parameters <- opbase.data("Op_en5397.sun_heat_absorption_parameters")
permeability.factor <- Ovariable(name = "permeability.factor")
permeability.factor@output <- tidy(subset(sun.heat.absorption.parameters, Parameter=="Permeability factor"), direction="long", objname="permeability.factor")
permeability.factor@output$Parameter <- NULL
frame.factor <- Ovariable(name="frame.factor")
frame.factor@output <- tidy(subset(sun.heat.absorption.parameters, Parameter=="Frame factor"), direction="long", objname="frame.factor")
frame.factor@output$Parameter <- NULL
curtain.factor <- Ovariable(name="curtain.factor")
curtain.factor@output <- tidy(subset(sun.heat.absorption.parameters, Parameter=="Curtain factor"), direction="long", objname="curtain.factor")
curtain.factor@output$Parameter <- NULL
shading.factor <- Ovariable(name="shading.factor")
shading.factor@output <- tidy(subset(sun.heat.absorption.parameters, Parameter=="Shading factor"), direction="long", objname="shading.factor")
shading.factor@output$Parameter <- NULL
surface.area@output <- subset(surface.area@output, Surface=="Window")
#Sun radiation on windows (kWh/m2 per month):
temp1 <- surface.area * window.direction * sun.radiation.vertical.surface
#Sun heat absorption (kWh/month):
out <- temp1 * frame.factor * curtain.factor * shading.factor * 0.9 * permeability.factor
out <- aggregate(out@output[,colnames(out@output)=='Result'],by=list(out@output$Construction.year, out@output$Month),FUN="sum",na.rm="TRUE")
names(out) <- c("Construction.year", "Month", "Result")
return(out)
}
)
oprint(sun.heat.absorption)
cat("Internal heat sources - total heat gain due to heat radiance from inhabitants, kWh/month.\n")
inhabitant.heat.radiance <- Ovariable(
name="inhabitant.heat.radiance",
dependencies = data.frame(
Name=c("building.characteristics", "period.length"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
building.characteristics <- opbase.data("Op_en5397.building_characteristics")
internal.heat.source.parameters <- opbase.data("Op_en5397.internal_heat_source_parameters")
inhabitants <- Ovariable(name = "inhabitants")
inhabitants@output <- tidy(subset(building.characteristics, Parameter=="Inhabitants"), direction="long", objname="inhabitants")
inhabitants@output$Parameter <- NULL
person.heat.radiance <- Ovariable(name = "person.heat.radiance")
person.heat.radiance@output <- tidy(subset(internal.heat.source.parameters, Parameter=="Person heat radiance"), direction="long", objname="person.heat.radiance")
person.heat.radiance@output$Parameter <- NULL
time.inside <- Ovariable(name = "time.inside")
time.inside@output <- tidy(subset(internal.heat.source.parameters, Parameter=="Time inside"), direction="long", objname="time.inside")
time.inside@output$Parameter <- NULL
#total heat gain from inhabitants (kWh/month):
out <- inhabitants * person.heat.radiance * time.inside * period.length / 1000
vars <- names(out@output) %in% c("Month", "Result", "Source")
out <- out@output[vars]
return(out)
}
)
oprint(inhabitant.heat.radiance)
cat("Internal heat sources - total heat gain due to heat radiance from electric equipment, kWh/month.\n")
electric.eqp.heat.radiance <- Ovariable(
name="electric.eqp.heat.radiance",
dependencies = data.frame(
Name=c("total.floor.area"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
internal.heat.source.parameters <- opbase.data("Op_en5397.internal_heat_source_parameters")
electrical.eqp.heat.release <- Ovariable(name = "electrical.eqp.heat.release")
electrical.eqp.heat.release@output <- tidy(subset(internal.heat.source.parameters, Parameter=="Electrical equipment heat"), direction="long", objname="electrical.eqp.heat.release")
electrical.eqp.heat.release@output$Parameter <- NULL
#total heat gain from electrical equipment (kWh/month):
out <- electrical.eqp.heat.release * total.floor.area / 12
vars <- names(out@output) %in% c("Construction.year", "Result", "Source")
out <- out@output[vars]
return(out)
}
)
oprint(electric.eqp.heat.radiance)
cat("Annual net heat consumption (kWh/year) in a single-family detached house. Includes heat loss via conduction, ventilation, air leak, and household water heating, and heat gain from internal heat sources (sun heat absorption through windows, heat radiance from inhabitants and electrical equipment. Excludes heat losses from the heat distribution (water radiators). However, heat loss from the heat distribution is largely utilised as an internal heat source and, hence, does not contribute significantly to the overall net heat consumption\n")
net.heat.consumption <- Ovariable(
name="net.heat.consumption",
dependencies = data.frame(
Name=c("conduction.heat.loss", "ventilation.heat.loss", "air.leak.heat.loss", "household.water.heating", "sun.heat.absorption", "inhabitant.heat.radiance", "electric.eqp.heat.radiance", "average.outdoor.temperature.month", "period.length", "heating.season"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
internal.heat.source.parameters <- opbase.data("Op_en5397.internal_heat_source_parameters")
building.characteristics <- opbase.data("Op_en5397.building_characteristics")
internal.heat.capacity <- Ovariable(name = "internal.heat.capacity")
internal.heat.capacity@output <- tidy(subset(internal.heat.source.parameters, Parameter=="Internal heat capacity"), direction="long", objname="internal.heat.capacity")
internal.heat.capacity@output$Parameter <- NULL
indoor.temperature <- Ovariable(name = "indoor.temperature")
indoor.temperature@output <- tidy(subset(building.characteristics, Parameter=="Indoor air temperature"), direction="long", objname="indoor.temperature")
indoor.temperature@output$Parameter <- NULL
heat.loss <- conduction.heat.loss + ventilation.heat.loss + air.leak.heat.loss
internal.heat.gain <- sun.heat.absorption + inhabitant.heat.radiance + electric.eqp.heat.radiance
#Utilisation of heat from internal heat sources:
temp1 <- internal.heat.capacity / (heat.loss / (indoor.temperature - average.outdoor.temperature.month) * period.length * 1000)
temp2 <- (1 - (internal.heat.gain / heat.loss)^(1 + temp1 / 15)) / (1 - (internal.heat.gain / heat.loss)^((1 + temp1 / 15) + 1))
temp3 <- temp2 * heating.season
#Building net heat consumption (kWh/month):
out <- heat.loss + household.water.heating - internal.heat.gain * temp3
out <- aggregate(out@output[,colnames(out@output)=='Result'],by=list(out@output$Construction.year),FUN="sum",na.rm="TRUE")
names(out) <- c("Construction.year", "Result")
return(out)
}
)
oprint(net.heat.consumption)
cat("Annual total energy purchase for heating in a single-family detached house(kWh/year). Takes into account the heat production efficiency of the house heating device\n")
heating.energy.purchase <- Ovariable(
name="heating.energy.purchase",
dependencies = data.frame(
Name=c("net.heat.consumption", "heat.production.efficiency"),
Ident= c("Op_en5397")
),
formula = function(dependencies, ...) {
#Building net heat consumption (kWh/month):
out <- heat.loss + household.water.heating - internal.heat.gain * temp3
#out <- aggregate(out@output[,colnames(out@output)=='Result'],by=list(out@output$Construction.year),FUN="sum",na.rm="TRUE")
#names(out) <- c("Construction.year", "Result")
return(out)
oprint(heating.energy.purchase)
| |