Class: BuildingSync::Site
- Inherits:
-
LocationElement
- Object
- SpatialElement
- LocationElement
- BuildingSync::Site
- Defined in:
- lib/buildingsync/model_articulation/site.rb
Overview
Site class
Instance Attribute Summary
Attributes inherited from SpatialElement
#space_types, #standards_building_type, #system_type, #total_floor_area
Instance Method Summary collapse
-
#build_zone_hash ⇒ hash<string, array<OpenStudio::Model::ThermalZone>>
build zone hash that stores zone lists for buildings and building sections.
-
#determine_open_studio_standard(standard_to_be_used) ⇒ Standard
determine the open studio standard and call the set_all function.
-
#determine_open_studio_system_standard ⇒ Standard
determine the open studio system standard and call the set_all function.
-
#generate_baseline_osm(epw_file_path, standard_to_be_used, ddy_file = nil) ⇒ Object
generate baseline model in osm file format.
-
#get_building ⇒ Array<BuildingSync::Building>
get building.
-
#get_building_sections ⇒ array<BuildingSection>
get building sections.
-
#get_building_type ⇒ String
get building type.
-
#get_climate_zone ⇒ String
get climate zone.
-
#get_epw_file_path ⇒ String
get full path to epw file.
-
#get_floor_area ⇒ hash<string, float>
get floor area.
-
#get_model ⇒ OpenStudio::Model
get the model.
-
#get_peak_occupancy ⇒ hash<string, float>
get peak occupancy.
-
#get_space_types ⇒ array<OpenStudio::Model::SpaceType>
get space types.
-
#get_space_types_from_hash(id) ⇒ hash<string, array<hash<string, string>>]
get space types from hash.
-
#get_standard_template ⇒ String
get @standard_template.
-
#get_system_type ⇒ String
get system type.
-
#initialize(base_xml, ns) ⇒ Site
constructor
initialize.
-
#prepare_final_xml ⇒ Object
write parameters to xml file.
-
#read_xml ⇒ Object
read xml.
-
#set_all ⇒ Object
set all function to set all parameters for each building.
-
#write_osm(dir) ⇒ hash<string, string>
write model to osm file.
Methods inherited from LocationElement
#determine_climate_zone, #read_city_and_state_name, #read_climate_zone, #read_location_values
Methods inherited from SpatialElement
#add_user_defined_field_to_xml_file, #create_space_types, #prepare_final_xml_for_spatial_element, #process_bldg_and_system_type, #read_floor_areas, #set_bldg_and_system_type, #sets_occupancy_bldg_system_types, #validate_positive_number_excluding_zero, #validate_positive_number_including_zero
Methods included from XmlGetSet
#get_prefix, #xget_attribute_for_element, #xget_element, #xget_id, #xget_idrefs, #xget_linked_premises, #xget_name, #xget_or_create, #xget_plurals_text_value, #xget_text, #xget_text_as_bool, #xget_text_as_date, #xget_text_as_dt, #xget_text_as_float, #xget_text_as_integer, #xset_or_create, #xset_text
Methods included from Helper
#help_calculate_hours, #help_convert, #help_count_number_of_days, #help_element_class_type_check, #help_get_attribute_value, #help_get_default_schedule_set, #help_get_duration, #help_get_end_time, #help_get_end_time_sat, #help_get_end_time_sun, #help_get_end_time_weekday, #help_get_or_create, #help_get_schedule_rule_set_from_schedule, #help_get_start_time, #help_get_start_time_sat, #help_get_start_time_sun, #help_get_start_time_weekday, #help_get_text_value, #help_get_text_value_as_bool, #help_get_text_value_as_date, #help_get_text_value_as_datetime, #help_get_text_value_as_float, #help_get_text_value_as_integer, #help_get_zone_name_list, #help_load_doc, #help_print_all_schedules, #help_print_schedule, #help_write_profile
Constructor Details
#initialize(base_xml, ns) ⇒ Site
initialize
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/buildingsync/model_articulation/site.rb', line 46 def initialize(base_xml, ns) super(base_xml, ns) @base_xml = base_xml @ns = ns help_element_class_type_check(base_xml, 'Site') @building = nil @all_set = false # using the XML snippet to search for the buildings on the site read_xml end |
Instance Method Details
#build_zone_hash ⇒ hash<string, array<OpenStudio::Model::ThermalZone>>
build zone hash that stores zone lists for buildings and building sections
91 92 93 |
# File 'lib/buildingsync/model_articulation/site.rb', line 91 def build_zone_hash return @building.build_zone_hash end |
#determine_open_studio_standard(standard_to_be_used) ⇒ Standard
determine the open studio standard and call the set_all function
128 129 130 131 |
# File 'lib/buildingsync/model_articulation/site.rb', line 128 def determine_open_studio_standard(standard_to_be_used) set_all return @building.determine_open_studio_standard(standard_to_be_used) end |
#determine_open_studio_system_standard ⇒ Standard
determine the open studio system standard and call the set_all function
135 136 137 138 |
# File 'lib/buildingsync/model_articulation/site.rb', line 135 def determine_open_studio_system_standard set_all return Standard.build(get_standard_template) end |
#generate_baseline_osm(epw_file_path, standard_to_be_used, ddy_file = nil) ⇒ Object
generate baseline model in osm file format
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/buildingsync/model_articulation/site.rb', line 195 def generate_baseline_osm(epw_file_path, standard_to_be_used, ddy_file = nil) set_all determine_climate_zone(standard_to_be_used) # If we can't get the CZ from the site, we attempt to get from the building @climate_zone = @building.get_climate_zone if @climate_zone.nil? OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Site.generate_baseline_osm', 'Could not find a climate zone in the BuildingSync file.') if @climate_zone.nil? lat = @building.xget_text('Latitude').nil? ? xget_text('Latitude') : @building.xget_text('Latitude') long = @building.xget_text('Longitude').nil? ? xget_text('Longitude') : @building.xget_text('Longitude') weather_station_name = @building.xget_text('WeatherStationName').nil? ? xget_text('WeatherStationName') : @building.xget_text('WeatherStationName') weather_station_id = @building.xget_text('WeatherDataStationID').nil? ? xget_text('WeatherDataStationID') : @building.xget_text('WeatherDataStationID') @building.set_weather_and_climate_zone(@climate_zone, epw_file_path, standard_to_be_used, lat, long, ddy_file, weather_station_name, weather_station_id, @state_name, @city_name) @building.generate_baseline_osm end |
#get_building ⇒ Array<BuildingSync::Building>
get building
181 182 183 |
# File 'lib/buildingsync/model_articulation/site.rb', line 181 def get_building return @building end |
#get_building_sections ⇒ array<BuildingSection>
get building sections
121 122 123 |
# File 'lib/buildingsync/model_articulation/site.rb', line 121 def get_building_sections return @building.building_sections end |
#get_building_type ⇒ String
get building type
161 162 163 164 165 166 167 |
# File 'lib/buildingsync/model_articulation/site.rb', line 161 def get_building_type if @standards_building_type.nil? return @building.get_building_type else return @standards_building_type end end |
#get_climate_zone ⇒ String
get climate zone
171 172 173 174 175 176 177 |
# File 'lib/buildingsync/model_articulation/site.rb', line 171 def get_climate_zone if @climate_zone.nil? return @building.get_climate_zone else return @climate_zone end end |
#get_epw_file_path ⇒ String
get full path to epw file
187 188 189 |
# File 'lib/buildingsync/model_articulation/site.rb', line 187 def get_epw_file_path return @building.get_epw_file_path end |
#get_floor_area ⇒ hash<string, float>
get floor area
115 116 117 |
# File 'lib/buildingsync/model_articulation/site.rb', line 115 def get_floor_area return @building.get_floor_area end |
#get_model ⇒ OpenStudio::Model
get the model
97 98 99 |
# File 'lib/buildingsync/model_articulation/site.rb', line 97 def get_model return @building.get_model end |
#get_peak_occupancy ⇒ hash<string, float>
get peak occupancy
109 110 111 |
# File 'lib/buildingsync/model_articulation/site.rb', line 109 def get_peak_occupancy return @building.get_peak_occupancy end |
#get_space_types ⇒ array<OpenStudio::Model::SpaceType>
get space types
103 104 105 |
# File 'lib/buildingsync/model_articulation/site.rb', line 103 def get_space_types return @building.get_space_types end |
#get_space_types_from_hash(id) ⇒ hash<string, array<hash<string, string>>]
get space types from hash
149 150 151 |
# File 'lib/buildingsync/model_articulation/site.rb', line 149 def get_space_types_from_hash(id) return @building.build_space_type_hash[id] end |
#get_standard_template ⇒ String
get @standard_template
142 143 144 |
# File 'lib/buildingsync/model_articulation/site.rb', line 142 def get_standard_template return @building.get_standard_template end |
#get_system_type ⇒ String
get system type
155 156 157 |
# File 'lib/buildingsync/model_articulation/site.rb', line 155 def get_system_type return @building.get_system_type end |
#prepare_final_xml ⇒ Object
write parameters to xml file
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/buildingsync/model_articulation/site.rb', line 226 def prepare_final_xml @base_xml.elements["#{@ns}:ClimateZoneType/#{@ns}:ASHRAE/#{@ns}:ClimateZone"].text = @climate_zone_ashrae if !@climate_zone_ashrae.nil? @base_xml.elements["#{@ns}:ClimateZoneType/#{@ns}:CaliforniaTitle24/#{@ns}:ClimateZone"].text = @climate_zone_ca_t24 if !@climate_zone_ca_t24.nil? @base_xml.elements["#{@ns}:Address/#{@ns}:City"].text = @city_name if !@city_name.nil? @base_xml.elements["#{@ns}:Address/#{@ns}:State"].text = @state_name if !@state_name.nil? # TODO: probably set these as UDFs from actual openstudio model @base_xml.elements["#{@ns}:WeatherStationName"].text = @weather_file_name if !@weather_file_name.nil? @base_xml.elements["#{@ns}:WeatherDataStationID"].text = @weather_station_id if !@weather_station_id.nil? prepare_final_xml_for_spatial_element @building.prepare_final_xml end |
#read_xml ⇒ Object
read xml
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/buildingsync/model_articulation/site.rb', line 60 def read_xml # first we check if the number of buildings is ok building_xml_temp = @base_xml.get_elements("#{@ns}:Buildings/#{@ns}:Building") if building_xml_temp.nil? || building_xml_temp.empty? OpenStudio.logFree(OpenStudio::Error, 'BuildingSync.Site.read_xml', "Site with ID: #{xget_id} has no Building elements. Cannot initialize Site.") raise StandardError, "Site with ID: #{xget_id} has no Building elements. Cannot initialize Site." elsif building_xml_temp.size > 1 @building_xml = building_xml_temp.first OpenStudio.logFree(OpenStudio::Error, 'BuildingSync.Site.read_xml', "Site ID: #{xget_id}. There is more than one (#{building_xml_temp.size}) Building elements. Only the first Building will be considered (ID: #{@building_xml.attributes['ID']}.") else @building_xml = building_xml_temp.first end # read other data @total_floor_area = read_floor_areas(nil) read_location_values @building = BuildingSync::Building.new(@building_xml, xget_text('OccupancyClassification'), @total_floor_area, @ns) end |
#set_all ⇒ Object
set all function to set all parameters for each building
82 83 84 85 86 87 |
# File 'lib/buildingsync/model_articulation/site.rb', line 82 def set_all if !@all_set @all_set = true @building.set_all end end |
#write_osm(dir) ⇒ hash<string, string>
write model to osm file
214 215 216 217 218 219 220 221 |
# File 'lib/buildingsync/model_articulation/site.rb', line 214 def write_osm(dir) @building.write_osm(dir) scenario_types = {} scenario_types['system_type'] = get_system_type scenario_types['bldg_type'] = get_building_type scenario_types['template'] = get_standard_template return scenario_types end |