How to perform sensitivity analysis using eplusr? #553
-
Transferred from one user's email:
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 82 replies
-
Here I use the
Below is a code snippet showcasing the whole workflow: # use an example file from EnergyPlus v22.1 for demonstration here
path_idf <- eplusr::path_eplus_example(22.1, "5Zone_Transformer.idf")
path_epw <- eplusr::path_eplus_weather(22.1, "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw")
# create a parametric job
param <- eplusr::param_job(path_idf, path_epw)
# define a measure about how to modify the IDF
measure <- function(idf, efficiency, thickness, conductivity) {
idf$set(
`Supply Fan 1` = list(Fan_Total_Efficiency = efficiency),
Material := list(Thickness = thickness, Conductivity = conductivity)
)
idf
}
# define parameter ranges and levels
vars <- tibble::tribble(
~name, ~min, ~max, ~levels,
"efficiency", 0.1, 1.0, 5,
"thickness", 0.01, 0.08, 6,
"conductivity", 0.1, 0.6, 6
)
# use {sensitivity} package to create parameters
mo <- sensitivity::morris(
model = NULL, factors = vars$name, r = 12,
design = list(type = "oat", levels = vars$levels, grid.jump = 4),
binf = vars$min, bsup = vars$max, scale = TRUE
)
#> Registered S3 method overwritten by 'sensitivity':
#> method from
#> print.src dplyr
# create parametric models
param$apply_measure(
measure,
efficiency = mo$X[, "efficiency"],
thickness = mo$X[, "thickness"],
conductivity = mo$X[, "conductivity"]
)
#> [7/48] | 15% ■■■■■ [Elapsed: 1.1s]
#> [25/48] | 52% ■■■■■■■■■■■■■■■■■ [Elapsed: 3.7s]
#> [44/48] | 92% ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ [Elapsed: 6.6s]
#> [48/48] | 100% ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ [Elapsed: 7.2s]
#> Measure 'measure' has been applied with 48 new models created:
#> [01]: measure_1
#> [02]: measure_2
#> [03]: measure_3
#> [04]: measure_4
#> [05]: measure_5
#> [06]: measure_6
#> [07]: measure_7
#> [08]: measure_8
#> [09]: measure_9
#> [10]: measure_10
#> [11]: measure_11
#> [12]: measure_12
#> [13]: measure_13
#> [14]: measure_14
#> [15]: measure_15
#> [16]: measure_16
#> [17]: measure_17
#> [18]: measure_18
#> [19]: measure_19
#> [20]: measure_20
#> [21]: measure_21
#> [22]: measure_22
#> [23]: measure_23
#> [24]: measure_24
#> [25]: measure_25
#> [26]: measure_26
#> [27]: measure_27
#> [28]: measure_28
#> [29]: measure_29
#> [30]: measure_30
#> [31]: measure_31
#> [32]: measure_32
#> [33]: measure_33
#> [34]: measure_34
#> [35]: measure_35
#> [36]: measure_36
#> [37]: measure_37
#> [38]: measure_38
#> [39]: measure_39
#> [40]: measure_40
#> [41]: measure_41
#> [42]: measure_42
#> [43]: measure_43
#> [44]: measure_44
#> [45]: measure_45
#> [46]: measure_46
#> [47]: measure_47
#> [48]: measure_48
# run parametric simulations (in a temporary folder for demonstration)
param$run(dir = tempdir())
#> ── EnergPlus Parametric Simulation Job ─────────────────────────────────────────
#> • Path: 'C:\EnergyPlusV22-1-0\ExampleFiles\5Zone_Transformer.idf'
#> • Version: 'C:\EnergyPlusV22-1-0\WeatherData\USA_CA_San.Francisco.Intl.AP.7249…
#> • EnergyPlus Version: '22.1.0'
#> • EnergyPlus Path: 'C:\EnergyPlusV22-1-0'
#> Applied Measure: 'measure'
#> Parametric Models [48]:
#> [01]: 'measure_1.idf' <-- SUCCEEDED
#> [02]: 'measure_2.idf' <-- SUCCEEDED
#> [03]: 'measure_3.idf' <-- SUCCEEDED
#> [04]: 'measure_4.idf' <-- SUCCEEDED
#> [05]: 'measure_5.idf' <-- SUCCEEDED
#> [06]: 'measure_6.idf' <-- SUCCEEDED
#> [07]: 'measure_7.idf' <-- SUCCEEDED
#> [08]: 'measure_8.idf' <-- SUCCEEDED
#> [09]: 'measure_9.idf' <-- SUCCEEDED
#> [10]: 'measure_10.idf' <-- SUCCEEDED
#> [11]: 'measure_11.idf' <-- SUCCEEDED
#> [12]: 'measure_12.idf' <-- SUCCEEDED
#> [13]: 'measure_13.idf' <-- SUCCEEDED
#> [14]: 'measure_14.idf' <-- SUCCEEDED
#> [15]: 'measure_15.idf' <-- SUCCEEDED
#> [16]: 'measure_16.idf' <-- SUCCEEDED
#> [17]: 'measure_17.idf' <-- SUCCEEDED
#> [18]: 'measure_18.idf' <-- SUCCEEDED
#> [19]: 'measure_19.idf' <-- SUCCEEDED
#> [20]: 'measure_20.idf' <-- SUCCEEDED
#> [21]: 'measure_21.idf' <-- SUCCEEDED
#> [22]: 'measure_22.idf' <-- SUCCEEDED
#> [23]: 'measure_23.idf' <-- SUCCEEDED
#> [24]: 'measure_24.idf' <-- SUCCEEDED
#> [25]: 'measure_25.idf' <-- SUCCEEDED
#> [26]: 'measure_26.idf' <-- SUCCEEDED
#> [27]: 'measure_27.idf' <-- SUCCEEDED
#> [28]: 'measure_28.idf' <-- SUCCEEDED
#> [29]: 'measure_29.idf' <-- SUCCEEDED
#> [30]: 'measure_30.idf' <-- SUCCEEDED
#> [31]: 'measure_31.idf' <-- SUCCEEDED
#> [32]: 'measure_32.idf' <-- SUCCEEDED
#> [33]: 'measure_33.idf' <-- SUCCEEDED
#> [34]: 'measure_34.idf' <-- SUCCEEDED
#> [35]: 'measure_35.idf' <-- SUCCEEDED
#> [36]: 'measure_36.idf' <-- SUCCEEDED
#> [37]: 'measure_37.idf' <-- SUCCEEDED
#> [38]: 'measure_38.idf' <-- SUCCEEDED
#> [39]: 'measure_39.idf' <-- SUCCEEDED
#> [40]: 'measure_40.idf' <-- SUCCEEDED
#> [41]: 'measure_41.idf' <-- SUCCEEDED
#> [42]: 'measure_42.idf' <-- SUCCEEDED
#> [43]: 'measure_43.idf' <-- SUCCEEDED
#> [44]: 'measure_44.idf' <-- SUCCEEDED
#> [45]: 'measure_45.idf' <-- SUCCEEDED
#> [46]: 'measure_46.idf' <-- SUCCEEDED
#> [47]: 'measure_47.idf' <-- SUCCEEDED
#> [48]: 'measure_48.idf' <-- SUCCEEDED
#> Simulation started at '2023-05-15 19:06:02.362011' and completed successfully after 7.68 secs.
# extract output
# here use total site energy for demonstration
eng <- param$tabular_data(
table_name = "site and source energy",
column_name = "energy per total building area",
row_name = "total site energy")
eng <- as.numeric(eng$value)
# calculate sensitivity metrics
mo <- sensitivity::tell(mo, eng)
sen <- data.frame(
mu = apply(mo$ee, 2, mean),
mu.star = apply(mo$ee, 2, function(x) mean(abs(x))),
sigma = apply(mo$ee, 2, sd)
)
# plot the results
plot(mo) Created on 2023-05-15 with reprex v2.0.2 |
Beta Was this translation helpful? Give feedback.
-
Thank you again for the scripts. Following the script you demonstrated on modifying the IDF. I want to ask if it's possible to modify the IDF, thesame way you did, but with measures/material properties, like the thermal transmittance, thermal capacitance which are not included in EnergyPlus IDD and IDF editor (contrary to conductivity, and thickness you used which are present in Energyplus IDF editor). |
Beta Was this translation helpful? Give feedback.
-
That's right!
For this one, I am not sure. In EnergyPlus, it does not use thermal transmittance to calculate thermal heat gains and cooling/heating loads. Each component of heat transfer for surfaces is calculated separately, e.g. convection, conduction and radiation. The actual used value of the convection coefficient value of the inside and outside surface is based on the algorithm defined in However, EnergyPlus does report construction U values in the HTML tabular report under "Envelope Summary" section. Those values are calculated based on the conductivity of each material of construction and a fixed value of convection heat transfer coefficient value of 0.5 W/m2.K, if I recall correctly. Those values are just for demonstration and are not used in the actual calculation. If you want to specify the thermal transmittance of a construction, what you will normally do is modify the corresponding material of the wall/roof/floor, plus consider a fixed convection heat transfer coefficient. You can use the same value as in EnergyPlus tabular report. |
Beta Was this translation helpful? Give feedback.
-
Dear Hongyuanjia,
I want to apologize for my persistent emails to you lately. I have been
finding your efforts on github truly helpful, and very much fit my learning
process in EnergyPlus and R. I understand your very tight schedule which
has most probably caused you not responding to all my questions there.
I eagerly await your valuable responses soon.
Thanks once again.
Best regards,
Ibrahim
…On Fri, May 19, 2023, 8:01 AM Hongyuan Jia ***@***.***> wrote:
It should be quoted if it is not a valid R object name. Supply Fan 1 is
not a valid R object name and should be quoted using `, since it contains
spaces. WindowMaterial:SingleGlazingSystem is not a valid R object name,
since it contains a :. If you are not familiar with the naming rules in
R, you can check Names and values
<https://adv-r.hadley.nz/names-values.html#non-syntactic> chapter in
Hadley's *Advanced R* book.
—
Reply to this email directly, view it on GitHub
<#553 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3UH7YXUZU2PVAW7SOOO4YLXG4LETANCNFSM6AAAAAAYBS4ZF4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much.
I will try the codes and get back to you on the outcome.
Much appreciated.
…On Fri, May 19, 2023, 4:09 PM Hongyuan Jia ***@***.***> wrote:
So in total, I am passing at least 15 variables for modification.
Then you could write a measure function in some way like this:
measure <- function(
wall_trans, wall_thick, wall_solar_abs, wall_therm_capacity,
roof_trans, roof_thick, roof_solar_abs, roof_therm_capacity,
win_trans, win_shgc,
...
) {
# calculate corresponding material conductivity here using wall_thick and
# wall_trans
wall_conduct <- ...
# calculate corresponding material specific heat using wall_therm_capacity
# wall_thick, wall area and the material density
wall_specific_heat <- ...
wall_condct <- wall_trans /
idf$set(
YourWallMaterialName = list(
thickness = wall_thick,
conductivity = wall_conduct,
specific_heat = wall_specific_heat,
solar_absorptance = wall_solar_abs
),
YourRoofMaterialName = list(
# similar process
)
)
}
—
Reply to this email directly, view it on GitHub
<#553 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3UH7YXTRGAFDQVF4XVYY5LXG6ELXANCNFSM6AAAAAAYBS4ZF4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Here I use the
morris()
function from {sensitivity} package for demonstration. There are 5 steps to perform sensitivity analyses using {eplusr}ParametricJob
object usingeplusr::param_job()
by specifying a seed model and a weather fileBelow is a code snippet showcasing the whole workflow: