-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.R
163 lines (121 loc) · 6.15 KB
/
master.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
library(plyr)
library(tidyverse)
library(stringr)
library(lubridate)
library(readr)
library(devtools)
# FOR DJ ONLY
# document("residential_loadshapes")
# install("residential_loadshapes")
# FOR OTHER USERS, if there are code updates:
install_github("07engineer/residential_loadshapes")
library(residential)
rm(list = ls())
# Set your working directory to the location of this file.
setwd("L:/P/1631/Task 4 - Baseline Profiles/Residential Calibrated Models 06252018")
# setwd("L:/P/1631/Task 4 - Baseline Profiles/Residential Calibrated Models 09182017/FCZ1_FCZ11")
# setwd("~/2016-11-08 Load Shapes 1631/2017-11-29 residential FCZ12 update")
# setwd("L:/P/1631/Task 4 - Baseline Profiles/Residential Calibrated Models 09182017/2017-11-29 residential FCZ12 update")
# analytic_schedule_path <- "L:/P/1631/Task 4 - Baseline Profiles/Residential Pre-Processor 062518/Results/Schedules/Misc-Blended"
analytic_schedule_path <- "L:/P/1631/Task 4 - Baseline Profiles/Residential Pre-Processor 062518/Results/Schedules/Misc-Subtracted"
# analytic_schedule_path <- "L:/P/1631/Task 4 - Baseline Profiles/Residential Pre-Processor 062518/Results/Schedules/Misc-Original"
#analytic_schedule_path <- "L:/P/1631/Task 4 - Baseline Profiles/Residential Pre-Processor 020118/Results/Schedules"
#analytic_schedule_path <- "L:/P/1631/Task 4 - Baseline Profiles/Residential Pre-Processor 091417/Results/Schedules/Final"
coefficients_path <- "L:/P/1631/Task 4 - Baseline Profiles/Residential Pre-Processor 020118/Results/EUIs"
#coefficients_path <- "L:/P/1631/Task 4 - Baseline Profiles/Residential Pre-Processor 091417/Data/Constrained Regression Coefficients"
pre_processor_path = "C:\\EnergyPlusV8-5-0\\PreProcess\\ParametricPreProcessor\\parametricpreprocessor"
EP_runs_path = "L:/EnergyPlus/2018-07-03 residential subtracted/"
#EP_runs_path = "L:/EnergyPlus/2018-07-03 residential miscOrig/"
#EP_runs_path = "L:/EnergyPlus/2018-07-03 residential blended/"
# EP_schedule_path = "L:/EnergyPlus/schedules_res/"
# EP_schedule_path = "L:/EnergyPlus/schedules_miscOrig/"
EP_schedule_path = "L:/EnergyPlus/schedules_subtracted/"
# EP_schedule_path = "L:/EnergyPlus/schedules_blended/"
# # For debugging or individual runs:
# family = "MULTIFAMILY" # "SINGLEFAMILY" or "MULTIFAMILY" or "ALL" for FCZ12
# fuel = "ELECTRIC" # Must be "GAS" or "ELECTRIC" or "ALL"
# size = "HIGH" #Must be "LOW" or "MEDIUM" or "HIGH" or "ALL"
# climate_zone = "FCZ2"
# Clean out batch folder if you want
batch_files_to_delete <- dir("EP_input_batch")[!dir("EP_input_batch") %in% "RunDirMulti.bat"]
file.remove(str_c("EP_input_batch", batch_files_to_delete, sep = "/"))
# For batch runs
families = c("SINGLEFAMILY", "MULTIFAMILY")
fuels = c("GAS", "ELECTRIC")
#sizes = c("LOW", "MEDIUM", "HIGH", "ALL")
sizes = "ALL"
# climate_zones = str_c("FCZ", 1:11)
climate_zones = str_c("FCZ", 2:11)
for(m in seq_along(climate_zones)){
climate_zone = climate_zones[m]
# batch_folder <- climate_zone
batch_folder <- str_c(EP_runs_path, climate_zone)
for(i in seq_along(families)){
for(j in seq_along(fuels)){
for(k in seq_along(sizes)){
family = families[i]
fuel = fuels[j]
size = sizes[k]
if(family == "SINGLEFAMILY" & fuel == "GAS") {
file_00 <- "00_SF_Model_gasfurnace_crawlspace.idf"
} else if(family == "SINGLEFAMILY" & fuel == "ELECTRIC"){
file_00 <- "00_SF_Model_hp_crawlspace.idf"
} else if(family == "MULTIFAMILY" & fuel == "GAS"){
file_00 <- "00_MF_Model_gasfurnace_crawlspace.idf"
} else if(family == "MULTIFAMILY" & fuel == "ELECTRIC"){
file_00 <- "00_MF_Model_hp_crawlspace.idf"
} else {
file_00 <- "00_SF_Model_gasfurnace_crawlspace.idf"
}
building_subcategory = str_c(climate_zone, family, fuel, size, sep = "_")
building_subcategory_schedule = str_c(climate_zone, family, "ALL", size, sep = "_")
cat("\nBUILDING SUBCATEGORY: ", building_subcategory, "\n")
#analytic_schedule_file <- str_c(climate_zone, family,"Usage_Level", size, fuel, "Schedules.csv", sep = "_")
analytic_schedule_file <- str_c(climate_zone, family,"Usage_Level", "ALL", "ALL", "Schedules.csv", sep = "_")
#coefficients_file <- str_c(climate_zone, family,"Usage_Level", size, fuel, "coefficients.csv", sep = "_")
coefficients_file <- str_c(climate_zone, family,"Usage_Level", "ALL", "ALL", "coefficients.csv", sep = "_")
file.remove(str_c("EP_input" , dir("EP_input") , sep = "/"))
#########################################
#### Update Schedule Section References #
#########################################
cat("Updating schedule references in .idf file. \n")
update_schedule_section_references(building_subcategory_schedule)
#########################################
#### Update Enduse Coefficients #########
#########################################
cat("Updating end use coefficients in .idf file. \n")
update_enduse_coefficients(coefficients_path, coefficients_file, file_00)
#########################################
#### Combine Sections ###################
#########################################
cat("Combining sections of .idf file. \n")
combine_sections(building_subcategory, file_00)
#########################################
#### Run Parametric Pre-processor #######
#########################################
cat("Running parametric pre-processor. \n")
files_before_PP = dir("EP_input")
system(str_c(pre_processor_path, " EP_input", "\\", building_subcategory, ".idf"))
files_after_PP = dir("EP_input")
runs <- files_after_PP %>%
str_subset(str_c(building_subcategory, "-"))
file.copy(str_c("EP_input", runs, sep = "/"), str_c(batch_folder, runs, sep = "/"), overwrite = TRUE)
#########################################
#### Update EnergyPlus Schedules ########
#########################################
# cat("Update energy plus schedule with analytic schedule values. \n")
# update_schedule()
#########################################
#### Update Setpoint Schedules ##########
#########################################
# cat("Change setpoint schedule. \n")
# change_setpoint_schedules(anamoly_changepoint = 70, max_drop = 20, cooling_setpoint = 24, heating_set_delta = 2)
}
}
}
}
#########################################
#### Update RunEPlus.bat ########
#########################################
#cat("Update batch file")
#update_RunEPlus_batch()