Class: Honeybee::VentilationControlAbridged
- Inherits:
-
ModelObject
- Object
- ModelObject
- Honeybee::VentilationControlAbridged
show all
- Defined in:
- lib/honeybee/ventcool/control.rb,
lib/to_openstudio/ventcool/control.rb
Constant Summary
collapse
- @@outdoor_node =
nil
- @@program_manager =
nil
- @@sensor_count =
1
- @@actuator_count =
1
- @@program_count =
1
Instance Attribute Summary
Attributes inherited from ModelObject
#errors, #openstudio_object, #warnings
Instance Method Summary
collapse
Methods inherited from ModelObject
#allowable_types, clean_identifier, clean_name, #find_existing_openstudio_object, #initialize, #method_missing, read_from_disk, truncate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Honeybee::ModelObject
Instance Method Details
#defaults ⇒ Object
37
38
39
|
# File 'lib/honeybee/ventcool/control.rb', line 37
def defaults
@@schema[:components][:schemas][:VentilationControlAbridged][:properties]
end
|
#get_outdoor_node(openstudio_model) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/to_openstudio/ventcool/control.rb', line 44
def get_outdoor_node(openstudio_model)
if @@outdoor_node.nil?
out_var = OpenStudio::Model::OutputVariable.new(
'Site Outdoor Air Drybulb Temperature', openstudio_model)
out_var.setReportingFrequency('Timestep')
out_var.setKeyValue('Environment')
@@outdoor_node = OpenStudio::Model::EnergyManagementSystemSensor.new(
openstudio_model, out_var)
@@outdoor_node.setName('Outdoor_Sensor')
end
@@outdoor_node
end
|
#get_program_manager(openstudio_model) ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/to_openstudio/ventcool/control.rb', line 58
def get_program_manager(openstudio_model)
if @@program_manager.nil?
@@program_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(
openstudio_model)
@@program_manager.setName('Temperature_Controlled_Window_Opening')
@@program_manager.setCallingPoint('BeginTimestepBeforePredictor')
end
@@program_manager
end
|
#replace_ems_special_characters(ems_variable_name) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/to_openstudio/ventcool/control.rb', line 69
def replace_ems_special_characters(ems_variable_name)
new_name = ems_variable_name.to_s
new_name.gsub!(/[^A-Za-z]/, '')
new_name
end
|
#to_openstudio(openstudio_model, parent_zone, vent_opening_surfaces, vent_opening_factors) ⇒ Object
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/to_openstudio/ventcool/control.rb', line 76
def to_openstudio(openstudio_model, parent_zone, vent_opening_surfaces, vent_opening_factors)
out_air_temp = get_outdoor_node(openstudio_model)
in_var = OpenStudio::Model::OutputVariable.new('Zone Air Temperature', openstudio_model)
in_var.setReportingFrequency('Timestep')
zone_name = parent_zone.name
os_zone_name = 'Indoor'
unless zone_name.empty?
os_zone_name = zone_name.get
in_var.setKeyValue(os_zone_name)
end
in_air_temp = OpenStudio::Model::EnergyManagementSystemSensor.new(openstudio_model, in_var)
in_sensor_name = replace_ems_special_characters(os_zone_name) + 'Sensor' + @@sensor_count.to_s
@@sensor_count = @@sensor_count + 1
in_air_temp.setName(in_sensor_name)
if @hash[:schedule]
vent_sch = openstudio_model.getScheduleByName(@hash[:schedule])
unless vent_sch.empty? sch_var = OpenStudio::Model::OutputVariable.new('Schedule Value', openstudio_model)
sch_var.setReportingFrequency('Timestep')
sch_var.setKeyValue(@hash[:schedule])
sch_sens = OpenStudio::Model::EnergyManagementSystemSensor.new(openstudio_model, sch_var)
sch_sensor_name = replace_ems_special_characters(os_zone_name) + 'Sensor' + @@sensor_count.to_s
@@sensor_count = @@sensor_count + 1
sch_sens.setName(sch_sensor_name)
end
end
actuator_names = []
vent_opening_surfaces.each do |vent_srf|
window_act = OpenStudio::Model::EnergyManagementSystemActuator.new(
vent_srf, 'AirFlow Network Window/Door Opening', 'Venting Opening Factor')
act_name = replace_ems_special_characters(vent_srf.nameString) + \
'OpenFactor' + @@actuator_count.to_s
@@actuator_count = @@actuator_count + 1
window_act.setName(act_name)
actuator_names << act_name
end
logic_statements = []
min_in = @hash[:min_indoor_temperature]
if min_in && min_in != defaults[:min_indoor_temperature][:default]
logic_statements << '(' + in_sensor_name + ' > ' + min_in.to_s + ')'
end
max_in = @hash[:max_indoor_temperature]
if max_in && max_in != defaults[:max_indoor_temperature][:default]
logic_statements << '(' + in_sensor_name + ' < ' + max_in.to_s + ')'
end
min_out = @hash[:min_outdoor_temperature]
if min_out && min_out != defaults[:min_outdoor_temperature][:default]
logic_statements << '(Outdoor_Sensor > ' + min_out.to_s + ')'
end
max_out = @hash[:max_outdoor_temperature]
if max_out && max_out != defaults[:max_outdoor_temperature][:default]
logic_statements << '(Outdoor_Sensor < ' + max_out.to_s + ')'
end
delta_in_out = @hash[:delta_temperature]
if delta_in_out && delta_in_out != defaults[:delta_temperature][:default]
logic_statements << '((' + in_sensor_name + ' - Outdoor_Sensor) > ' + delta_in_out.to_s + ')'
end
if sch_sensor_name
logic_statements << '(' + sch_sensor_name + ' > 0)'
end
if logic_statements.empty?
complete_logic = 'IF (Outdoor_Sensor < 100)' else
complete_logic = 'IF ' + logic_statements.join(' && ')
end
ems_program = OpenStudio::Model::EnergyManagementSystemProgram.new(openstudio_model)
prog_name = replace_ems_special_characters(os_zone_name) + 'WindowOpening' + @@program_count.to_s
@@program_count = @@program_count + 1
ems_program.setName(prog_name)
ems_program.addLine(complete_logic)
actuator_names.zip(vent_opening_factors).each do |act_name, open_factor|
ems_program.addLine('SET ' + act_name + ' = ' + open_factor.to_s)
end
ems_program.addLine('ELSE')
actuator_names.each do |act_name|
ems_program.addLine('SET ' + act_name + ' = 0')
end
ems_program.addLine('ENDIF')
prog_manager = get_program_manager(openstudio_model)
prog_manager.addProgram(ems_program)
ems_program
end
|