src/isomodel/ForwardTranslator.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "ForwardTranslator.hpp" | ||
| 7 | #include "UserModel.hpp" | ||
| 8 | |||
| 9 | #include "../utilities/time/Date.hpp" | ||
| 10 | |||
| 11 | #include "../model/Model.hpp" | ||
| 12 | #include "../model/Building.hpp" | ||
| 13 | #include "../model/Building_Impl.hpp" | ||
| 14 | #include "../model/ModelObject.hpp" | ||
| 15 | #include "../model/Facility.hpp" | ||
| 16 | #include "../model/Facility_Impl.hpp" | ||
| 17 | #include "../model/AirGap.hpp" | ||
| 18 | #include "../model/AirGap_Impl.hpp" | ||
| 19 | #include "../model/AirLoopHVAC.hpp" | ||
| 20 | #include "../model/AirLoopHVAC_Impl.hpp" | ||
| 21 | #include "../model/AirLoopHVACUnitaryHeatPumpAirToAir.hpp" | ||
| 22 | #include "../model/AirLoopHVACUnitaryHeatPumpAirToAir_Impl.hpp" | ||
| 23 | #include "../model/BoilerHotWater.hpp" | ||
| 24 | #include "../model/BoilerHotWater_Impl.hpp" | ||
| 25 | #include "../model/BoilerSteam.hpp" | ||
| 26 | #include "../model/BoilerSteam_Impl.hpp" | ||
| 27 | #include "../model/ChillerElectricEIR.hpp" | ||
| 28 | #include "../model/ChillerElectricEIR_Impl.hpp" | ||
| 29 | #include "../model/CoilCoolingDXSingleSpeed.hpp" | ||
| 30 | #include "../model/CoilCoolingDXSingleSpeed_Impl.hpp" | ||
| 31 | #include "../model/CoilCoolingDXTwoSpeed.hpp" | ||
| 32 | #include "../model/CoilCoolingDXTwoSpeed_Impl.hpp" | ||
| 33 | #include "../model/CoilCoolingWater.hpp" | ||
| 34 | #include "../model/CoilCoolingWater_Impl.hpp" | ||
| 35 | #include "../model/CoilHeatingDXSingleSpeed.hpp" | ||
| 36 | #include "../model/CoilHeatingDXSingleSpeed_Impl.hpp" | ||
| 37 | #include "../model/CoilHeatingElectric.hpp" | ||
| 38 | #include "../model/CoilHeatingElectric_Impl.hpp" | ||
| 39 | #include "../model/CoilHeatingGas.hpp" | ||
| 40 | #include "../model/CoilHeatingGas_Impl.hpp" | ||
| 41 | #include "../model/CoilHeatingWater.hpp" | ||
| 42 | #include "../model/CoilHeatingWater_Impl.hpp" | ||
| 43 | #include "../model/ConnectorMixer.hpp" | ||
| 44 | #include "../model/ConnectorMixer_Impl.hpp" | ||
| 45 | #include "../model/ConnectorSplitter.hpp" | ||
| 46 | #include "../model/ConnectorSplitter_Impl.hpp" | ||
| 47 | #include "../model/Construction.hpp" | ||
| 48 | #include "../model/Construction_Impl.hpp" | ||
| 49 | #include "../model/DaylightingControl.hpp" | ||
| 50 | #include "../model/DaylightingControl_Impl.hpp" | ||
| 51 | #include "../model/DesignSpecificationOutdoorAir.hpp" | ||
| 52 | #include "../model/DesignSpecificationOutdoorAir_Impl.hpp" | ||
| 53 | #include "../model/ElectricEquipment.hpp" | ||
| 54 | #include "../model/ElectricEquipment_Impl.hpp" | ||
| 55 | #include "../model/ExteriorLights.hpp" | ||
| 56 | #include "../model/ExteriorLights_Impl.hpp" | ||
| 57 | #include "../model/ExteriorLightsDefinition.hpp" | ||
| 58 | #include "../model/ExteriorLightsDefinition_Impl.hpp" | ||
| 59 | #include "../model/Gas.hpp" | ||
| 60 | #include "../model/Gas_Impl.hpp" | ||
| 61 | #include "../model/GasEquipment.hpp" | ||
| 62 | #include "../model/GasEquipment_Impl.hpp" | ||
| 63 | #include "../model/GasMixture.hpp" | ||
| 64 | #include "../model/GasMixture_Impl.hpp" | ||
| 65 | #include "../model/InternalMassDefinition.hpp" | ||
| 66 | #include "../model/InternalMassDefinition_Impl.hpp" | ||
| 67 | #include "../model/Lights.hpp" | ||
| 68 | #include "../model/Lights_Impl.hpp" | ||
| 69 | #include "../model/Luminaire.hpp" | ||
| 70 | #include "../model/Luminaire_Impl.hpp" | ||
| 71 | #include "../model/MasslessOpaqueMaterial.hpp" | ||
| 72 | #include "../model/MasslessOpaqueMaterial_Impl.hpp" | ||
| 73 | #include "../model/Node.hpp" | ||
| 74 | #include "../model/Node_Impl.hpp" | ||
| 75 | #include "../model/OpaqueMaterial.hpp" | ||
| 76 | #include "../model/OpaqueMaterial_Impl.hpp" | ||
| 77 | #include "../model/People.hpp" | ||
| 78 | #include "../model/People_Impl.hpp" | ||
| 79 | #include "../model/PipeAdiabatic.hpp" | ||
| 80 | #include "../model/PipeAdiabatic_Impl.hpp" | ||
| 81 | #include "../model/PlantLoop.hpp" | ||
| 82 | #include "../model/PlantLoop_Impl.hpp" | ||
| 83 | #include "../model/RefractionExtinctionGlazing.hpp" | ||
| 84 | #include "../model/RefractionExtinctionGlazing_Impl.hpp" | ||
| 85 | #include "../model/RoofVegetation.hpp" | ||
| 86 | #include "../model/RoofVegetation_Impl.hpp" | ||
| 87 | #include "../model/ScheduleDay.hpp" | ||
| 88 | #include "../model/ScheduleDay_Impl.hpp" | ||
| 89 | #include "../model/ScheduleRuleset.hpp" | ||
| 90 | #include "../model/ScheduleRuleset_Impl.hpp" | ||
| 91 | #include "../model/SimpleGlazing.hpp" | ||
| 92 | #include "../model/SimpleGlazing_Impl.hpp" | ||
| 93 | #include "../model/Site.hpp" | ||
| 94 | #include "../model/Site_Impl.hpp" | ||
| 95 | #include "../model/Space.hpp" | ||
| 96 | #include "../model/Space_Impl.hpp" | ||
| 97 | #include "../model/SpaceInfiltrationDesignFlowRate.hpp" | ||
| 98 | #include "../model/SpaceInfiltrationDesignFlowRate_Impl.hpp" | ||
| 99 | #include "../model/SpaceInfiltrationEffectiveLeakageArea.hpp" | ||
| 100 | #include "../model/SpaceInfiltrationEffectiveLeakageArea_Impl.hpp" | ||
| 101 | #include "../model/SpaceType.hpp" | ||
| 102 | #include "../model/SpaceType_Impl.hpp" | ||
| 103 | #include "../model/StandardGlazing.hpp" | ||
| 104 | #include "../model/StandardGlazing_Impl.hpp" | ||
| 105 | #include "../model/StandardOpaqueMaterial.hpp" | ||
| 106 | #include "../model/StandardOpaqueMaterial_Impl.hpp" | ||
| 107 | #include "../model/SubSurface.hpp" | ||
| 108 | #include "../model/SubSurface_Impl.hpp" | ||
| 109 | #include "../model/Surface.hpp" | ||
| 110 | #include "../model/Surface_Impl.hpp" | ||
| 111 | #include "../model/ThermalZone.hpp" | ||
| 112 | #include "../model/ThermalZone_Impl.hpp" | ||
| 113 | #include "../model/ThermochromicGlazing.hpp" | ||
| 114 | #include "../model/ThermochromicGlazing_Impl.hpp" | ||
| 115 | #include "../model/ThermostatSetpointDualSetpoint.hpp" | ||
| 116 | #include "../model/ThermostatSetpointDualSetpoint_Impl.hpp" | ||
| 117 | #include "../model/WaterHeaterMixed.hpp" | ||
| 118 | #include "../model/WaterHeaterMixed_Impl.hpp" | ||
| 119 | #include "../model/WaterUseConnections.hpp" | ||
| 120 | #include "../model/WaterUseConnections_Impl.hpp" | ||
| 121 | #include "../model/WaterUseEquipment.hpp" | ||
| 122 | #include "../model/WaterUseEquipment_Impl.hpp" | ||
| 123 | #include "../model/WaterUseEquipmentDefinition.hpp" | ||
| 124 | #include "../model/WaterUseEquipmentDefinition_Impl.hpp" | ||
| 125 | #include "../model/YearDescription.hpp" | ||
| 126 | #include "../model/YearDescription_Impl.hpp" | ||
| 127 | |||
| 128 | #include "../model/ZoneHVACPackagedTerminalAirConditioner.hpp" | ||
| 129 | #include "../model/ZoneHVACPackagedTerminalAirConditioner_Impl.hpp" | ||
| 130 | #include "../model/ZoneHVACPackagedTerminalHeatPump.hpp" | ||
| 131 | #include "../model/ZoneHVACPackagedTerminalHeatPump_Impl.hpp" | ||
| 132 | #include "../model/ZoneHVACUnitHeater.hpp" | ||
| 133 | #include "../model/ZoneHVACUnitHeater_Impl.hpp" | ||
| 134 | #include "../model/ZoneHVACWaterToAirHeatPump.hpp" | ||
| 135 | #include "../model/ZoneHVACWaterToAirHeatPump_Impl.hpp" | ||
| 136 | |||
| 137 | #include <cmath> | ||
| 138 | |||
| 139 | namespace openstudio { | ||
| 140 | namespace isomodel { | ||
| 141 | |||
| 142 | ✗ | ForwardTranslator::ForwardTranslator() { | |
| 143 | ✗ | m_logSink.setLogLevel(Warn); | |
| 144 | ✗ | m_logSink.setChannelRegex(boost::regex("openstudio\\.isomodel()\\.ForwardTranslator()")); | |
| 145 | ✗ | } | |
| 146 | |||
| 147 | ✗ | UserModel ForwardTranslator::translateModel(const openstudio::model::Model& t_model) { | |
| 148 | ✗ | m_logSink.resetStringStream(); | |
| 149 | |||
| 150 | /// \todo this should probably be a clone in case the uniqueModelObject calls manipulate the model? | ||
| 151 | ✗ | openstudio::model::Model model = t_model; | |
| 152 | |||
| 153 | ✗ | LOG(Debug, "...Setting() Defaults"); | |
| 154 | ✗ | LOG(Debug, "*****************************"); | |
| 155 | ✗ | LOG(Debug, " Setting Defaults"); | |
| 156 | ✗ | LOG(Debug, "*****************************"); | |
| 157 | |||
| 158 | // set the flags below to true or false to try to get info from OSM file or simply use defaults below | ||
| 159 | ✗ | bool OSM_extract_occupancy = true; // extract days and hours of occupancy | |
| 160 | ✗ | bool OSM_extract_temp_setpoint = true; // extract temperature setpoints | |
| 161 | ✗ | bool OSM_extract_dhw = true; // extract dhw info | |
| 162 | ✗ | bool OSM_extract_vent_rate = true; // extract the ventilation rate | |
| 163 | ✗ | bool OSM_extract_infil_rate = true; // extract infiltration rate info | |
| 164 | ✗ | bool OSM_extract_HVAC = true; // extract HVAC info like cooling COP, heating efficiencies, fuel type. | |
| 165 | /// \todo unused | ||
| 166 | //bool OSM_extract_glazing_info = true; // extract glazing info (U & SHGC) | ||
| 167 | //bool OSM_extract_wallroof_info = true; // extract the wall and roof U and other info | ||
| 168 | |||
| 169 | // NOTE YOU *MUST* SET HVAC SYSTEM TYPE and IPLV/COP ratio below | ||
| 170 | |||
| 171 | // set fan and pump control factors; (1.0 = no energy saving features) | ||
| 172 | // start the strings with a floating point as that's what is stripped off to set the falue | ||
| 173 | // fan control 1 = no control, 0.75 = inlet blade adjuct, 0.65= variable speed see NEN 2916 7.3.3.4 | ||
| 174 | ✗ | double fan_flow_control_factor_default = 1.0; // set default fan flow control factor to 1.0 (no energy savings) | |
| 175 | // pump control 0 = no pump, 0.5 = auto pump controls for more 50% of pumps, 1.0 = all other cases. See NEN 2914 9.4.3 | ||
| 176 | ✗ | double heating_pump_control_factor_default = 1.0; // set default heating pump control factor to 1.0 (no control or vfd) | |
| 177 | ✗ | double cooling_pump_control_factor_default = 1.0; // set default cooling pump control factor to 1.0 (no control or vfd) | |
| 178 | |||
| 179 | // until we can extract HVAC inputs and guess at HVAC type, set these defaults | ||
| 180 | // give the HVAC type number first and a descriptive string after | ||
| 181 | ✗ | int hvac_type_default = 24; // set default HVAC type to VAV | |
| 182 | ✗ | double cooling_IPLVToCop_ratio = 1.0; // set default system partial load ratio | |
| 183 | ✗ | int ventilation_type_default = 1; //set ventilation type (1 = mech only, 2 = natural, 3 = mixed) | |
| 184 | ✗ | int bem_type_default = 1; // set bem_type=1 (1 = none or minimal BEM, 2 = modern BEM, 3 = advanced BEM w/ FDD) | |
| 185 | |||
| 186 | // HVAC settings that are hard to extract but might be changed | ||
| 187 | ✗ | double exhaust_recirculation_fraction = 0.0; // set fraction of air recirculated to 0.0 (i.e. total outside air) | |
| 188 | ✗ | double heat_recovery_fraction = 0.0; // set ventilation heat recovery fraction to 0 since OS doesn't support heat recovery yet | |
| 189 | |||
| 190 | //these are items that aren't modeled in OS or are hard to extract so set default values | ||
| 191 | ✗ | int occupancy_sensors_default = 1; // occupancy sensors: false = none or minimal true > if 60% of floor space has it | |
| 192 | ✗ | int const_illum_ctrl_default = 1; //constant illumination control: false = none, true | |
| 193 | |||
| 194 | // this can be changed within OS, but it is often not sent. | ||
| 195 | ✗ | double specific_fan_power = 1 / 0.7733; // set default specific fan power (L/W) to match EnergyPlus default | |
| 196 | |||
| 197 | // set default SCF and SDF for all windows. | ||
| 198 | ✗ | double solar_control_factor = 1.0; | |
| 199 | ✗ | double shading_device_factor = 1.0; | |
| 200 | |||
| 201 | // set fall through defaults in case extraction fails or we decide not to extract | ||
| 202 | |||
| 203 | // default occupancy info if we can't extract | ||
| 204 | ✗ | int occupancy_day_start = 1; // set default starting day of occupancy as monday (Su=0, Mon=1 Sa=6) | |
| 205 | ✗ | int occupancy_day_end = 5; // set the default ending day of occupancy | |
| 206 | ✗ | int occupancy_hour_start = 8; // set the default starting hour for occupancy for an occupied day | |
| 207 | ✗ | int occupancy_hour_end = 18; // set the default ending hour for occupancy for an unoccupied day | |
| 208 | |||
| 209 | // temperature setpoint defaults | ||
| 210 | ✗ | double heating_setpoint_occ_default = 21; // set the default temperature setpoint for heating during occupied times | |
| 211 | ✗ | double heating_setpoint_unocc_default = 15; // set the default temperature setpoint for heating during unccupied times | |
| 212 | ✗ | double cooling_setpoint_occ_default = 25; // set the default temp setpoint for cooling during occupied times | |
| 213 | ✗ | double cooling_setpoint_unocc_default = 28; // set the default temp setpoint for cooling during unoccupied times | |
| 214 | |||
| 215 | // HVAC defaults | ||
| 216 | ✗ | double cooling_COP_default = 3.2; | |
| 217 | ✗ | double heating_system_efficiency_default = 0.8; | |
| 218 | ✗ | int heating_fuel_type_default = 2; // set default fuel type to 2 = gas | |
| 219 | |||
| 220 | // Ventilation defaults | ||
| 221 | ✗ | double vent_rate_per_person_default = 10; // set default ventilation rate (10 L/s/persoin ~ 20 cfm/person is good for offices) | |
| 222 | |||
| 223 | // DHW defaults | ||
| 224 | //set dhw distribution type 0, close to taps, 1 far from taps, 2 = circulation/other/ unknown) | ||
| 225 | ✗ | int dhw_dist_type_default = 2; | |
| 226 | ✗ | double dhw_rate_per_person_default = 3.8; // set default dhw rate at 3.8 L/person/day from ASHRAE HVAC Apps chapter 50 | |
| 227 | ✗ | int dhw_fuel_type_default = 2; // set default DHW fuel to gas (1 = electric, 2 = gas) | |
| 228 | ✗ | double dhw_system_efficiency_default = 0.8; | |
| 229 | |||
| 230 | // Infiltration defaults | ||
| 231 | ✗ | double infil_rate_default = 7.0; // set default infiltration rate to 7 m3/m2/hr@ 75 Pa by default to match normal EnergyPlus default values | |
| 232 | |||
| 233 | // set envelope defaults U in W/m2/K | ||
| 234 | ✗ | double glazing_U_default = 3.0; // default is simple IGU | |
| 235 | ✗ | double glazing_SHGC_default = 0.7; // default is clear IGU | |
| 236 | |||
| 237 | // set default inside and outside air film R values | ||
| 238 | ✗ | double outside_air_film_R = 0.04; // set the outside air film coefficient R value in m2*K/W | |
| 239 | ✗ | double inside_air_film_R = 0.13; // set the inside air film coefficient R value in m2*K/W | |
| 240 | |||
| 241 | // convert strings to integers and floats | ||
| 242 | ✗ | int bem_type = bem_type_default; | |
| 243 | ✗ | int hvac_type = hvac_type_default; | |
| 244 | ✗ | int ventilation_type = ventilation_type_default; | |
| 245 | |||
| 246 | ✗ | double fan_flow_control_factor = fan_flow_control_factor_default; | |
| 247 | ✗ | double heating_pump_control_factor = heating_pump_control_factor_default; | |
| 248 | ✗ | double cooling_pump_control_factor = cooling_pump_control_factor_default; | |
| 249 | ✗ | int dhw_dist_type = dhw_dist_type_default; | |
| 250 | |||
| 251 | ✗ | int occupancy_sensors = occupancy_sensors_default; | |
| 252 | ✗ | int const_illum_ctrl = const_illum_ctrl_default; | |
| 253 | |||
| 254 | // set SCF (external solar control) and SDF (shading) these for all directions N, NE, E, SE, S, SW, W, NW | ||
| 255 | ✗ | std::vector<double> window_SCF(8, solar_control_factor); // set default window solar control factor = 1.0 (no overhang solar control) | |
| 256 | ✗ | std::vector<double> window_SDF(8, shading_device_factor); // set default window shading device factor = 1.0 (no shades) | |
| 257 | |||
| 258 | ✗ | LOG(Debug, "*****************************"); | |
| 259 | ✗ | LOG(Debug, " Setting Defaults"); | |
| 260 | ✗ | LOG(Debug, "*****************************"); | |
| 261 | |||
| 262 | ✗ | LOG(Debug, "Occupancy Sensors set to " << occupancy_sensors_default); | |
| 263 | ✗ | LOG(Debug, "Constant Illumination Control set to " << const_illum_ctrl_default); | |
| 264 | |||
| 265 | ✗ | LOG(Debug, "HVAC system type set to " << hvac_type_default); | |
| 266 | ✗ | LOG(Debug, "HVAC set IPLV/COP, mean partial load fraction, to " << cooling_IPLVToCop_ratio); | |
| 267 | ✗ | LOG(Debug, "Heat recovery set to " << heat_recovery_fraction); | |
| 268 | ✗ | LOG(Debug, "Exhaust air recirculation fraction set to " << exhaust_recirculation_fraction); | |
| 269 | ✗ | LOG(Debug, "Ventilation type set to " << ventilation_type_default); | |
| 270 | ✗ | LOG(Debug, "BAS/BEM set to " << bem_type_default); | |
| 271 | |||
| 272 | ✗ | LOG(Debug, "Specific fan power set to " << specific_fan_power << " (L/s/W)"); | |
| 273 | ✗ | LOG(Debug, "DHW distribution system set " << dhw_dist_type_default); | |
| 274 | ✗ | LOG(Debug, "Fan Flow Control Factor set " << fan_flow_control_factor_default); | |
| 275 | ✗ | LOG(Debug, "Heating Pump Control Factor set " << heating_pump_control_factor_default); | |
| 276 | ✗ | LOG(Debug, "Cooling pump Control Factor set " << cooling_pump_control_factor_default); | |
| 277 | ✗ | LOG(Debug, "Setting window SCF=" << solar_control_factor << ", SDF=" << shading_device_factor); | |
| 278 | |||
| 279 | ✗ | LOG(Debug, "*****************************"); | |
| 280 | ✗ | LOG(Debug, "Setting Fall Through Defaults"); | |
| 281 | ✗ | LOG(Debug, "*****************************"); | |
| 282 | |||
| 283 | ✗ | LOG(Debug, "Occupancy Start Day = " << occupancy_day_start << " with Sun = 0, Sat = 6"); | |
| 284 | ✗ | LOG(Debug, "Occupancy End Day = " << occupancy_day_end << " with Sun = 0, Sat = 6"); | |
| 285 | ✗ | LOG(Debug, "Occupancy Start Hour = " << occupancy_hour_start << " "); | |
| 286 | ✗ | LOG(Debug, "Occupancy End Hour = " << occupancy_hour_end); | |
| 287 | |||
| 288 | ✗ | LOG(Debug, "Heating Temp Set Point During Occupied Times = " << heating_setpoint_occ_default << " C"); | |
| 289 | ✗ | LOG(Debug, "Heating Temp Set Point During Unccupied Times = " << heating_setpoint_unocc_default << " C"); | |
| 290 | ✗ | LOG(Debug, "Cooling Temp Set Point During Occupied Times = " << cooling_setpoint_occ_default << " C"); | |
| 291 | ✗ | LOG(Debug, "Cooling Temp Set Point During Unccupied Times = " << cooling_setpoint_unocc_default << " C"); | |
| 292 | |||
| 293 | ✗ | LOG(Debug, "Default Cooling Cop = " << cooling_COP_default << " W/W"); | |
| 294 | ✗ | LOG(Debug, "Default Heating System Efficiency = " << heating_system_efficiency_default); | |
| 295 | ✗ | LOG(Debug, "Default Heating Fuel Type = " << heating_fuel_type_default); | |
| 296 | |||
| 297 | ✗ | LOG(Debug, "Default outside air film resistance = " << outside_air_film_R << " W/m2/K"); | |
| 298 | ✗ | LOG(Debug, "Default inside air film resistance = " << inside_air_film_R << " W/m2/K"); | |
| 299 | |||
| 300 | ✗ | LOG(Debug, "...Parsing() Model"); | |
| 301 | |||
| 302 | ✗ | LOG(Debug, "*****************************"); | |
| 303 | ✗ | LOG(Debug, " Parsing Model"); | |
| 304 | ✗ | LOG(Debug, "*****************************"); | |
| 305 | |||
| 306 | // get the weatherfile if one is defined in the OSM and convert to a string; | ||
| 307 | // wfu = model.getWeatherFile().url().to_s(); | ||
| 308 | // if wfu.empty(); | ||
| 309 | // LOG(Debug, "Warning: A Weather file !defined in the OSM"); | ||
| 310 | // weather_file_path="none"; | ||
| 311 | // } else { | ||
| 312 | |||
| 313 | // strip off the file: part of the URL, only save the stuff after file:; | ||
| 314 | // weather_file_path=wfu.split(':').last(); | ||
| 315 | // LOG(Debug, "Weather file " << weather_file_path << " found"); | ||
| 316 | // } | ||
| 317 | |||
| 318 | // get some important objects from the building model; | ||
| 319 | ✗ | openstudio::model::Building building = model.getUniqueModelObject<openstudio::model::Building>(); | |
| 320 | ✗ | openstudio::model::Facility facility = model.getUniqueModelObject<openstudio::model::Facility>(); | |
| 321 | ✗ | std::vector<openstudio::model::Surface> surfaces = model.getConcreteModelObjects<openstudio::model::Surface>(); | |
| 322 | ✗ | std::vector<openstudio::model::SubSurface> sub_surfaces = model.getConcreteModelObjects<openstudio::model::SubSurface>(); | |
| 323 | ✗ | std::vector<openstudio::model::Space> spaces = model.getConcreteModelObjects<openstudio::model::Space>(); | |
| 324 | ✗ | std::vector<openstudio::model::ThermalZone> thermal_zones = model.getConcreteModelObjects<openstudio::model::ThermalZone>(); | |
| 325 | ✗ | std::vector<openstudio::model::SpaceType> space_types = model.getConcreteModelObjects<openstudio::model::SpaceType>(); | |
| 326 | ✗ | std::vector<openstudio::model::Construction> constructions = model.getConcreteModelObjects<openstudio::model::Construction>(); | |
| 327 | std::vector<openstudio::model::InternalMassDefinition> internal_masses = | ||
| 328 | ✗ | model.getConcreteModelObjects<openstudio::model::InternalMassDefinition>(); | |
| 329 | ✗ | std::vector<openstudio::model::AirLoopHVAC> air_loops = model.getConcreteModelObjects<openstudio::model::AirLoopHVAC>(); | |
| 330 | ✗ | std::vector<openstudio::model::PlantLoop> plant_loops = model.getConcreteModelObjects<openstudio::model::PlantLoop>(); | |
| 331 | |||
| 332 | ✗ | LOG(Debug, "Found " << surfaces.size() << " surfaces"); | |
| 333 | ✗ | LOG(Debug, "Found " << sub_surfaces.size() << " sub surfaces"); | |
| 334 | ✗ | LOG(Debug, "Found " << spaces.size() << " spaces"); | |
| 335 | ✗ | LOG(Debug, "Found " << thermal_zones.size() << " thermal zones"); | |
| 336 | ✗ | LOG(Debug, "Found " << space_types.size() << " space types"); | |
| 337 | ✗ | LOG(Debug, "Found " << constructions.size() << " constructions"); | |
| 338 | ✗ | LOG(Debug, "Found " << internal_masses.size() << " Internal Mass Definitions"); | |
| 339 | ✗ | LOG(Debug, "Found " << air_loops.size() << " Air Loops"); | |
| 340 | ✗ | LOG(Debug, "Found " << plant_loops.size() << " Plant Loops"); | |
| 341 | |||
| 342 | // get the terrain class from the site object or assign default if none given; | ||
| 343 | ✗ | std::string terrain; | |
| 344 | ✗ | openstudio::model::Site site = model.getUniqueModelObject<openstudio::model::Site>(); | |
| 345 | ✗ | if (!site.terrain().empty()) { | |
| 346 | ✗ | terrain = site.terrain(); | |
| 347 | ✗ | LOG(Debug, "Terrain Type " << terrain << " in OSM"); | |
| 348 | } else { | ||
| 349 | ✗ | LOG(Debug, "Site Terrain Not Defined in OpenStudio Model - Set to Urban Terrain By Default"); | |
| 350 | ✗ | terrain = "Urban"; | |
| 351 | } | ||
| 352 | |||
| 353 | ✗ | double terrain_class = 0; | |
| 354 | // when we have ocean or country, there are no blocks so terrain_class=1.0; | ||
| 355 | ✗ | if (terrain == "Ocean" || terrain == "Country") { | |
| 356 | ✗ | terrain_class = 1.0; | |
| 357 | ✗ | } else if (terrain == "Suburbs") { | |
| 358 | ✗ | terrain_class = 0.9; | |
| 359 | } else { | ||
| 360 | // when city or urban set to 0.8; | ||
| 361 | ✗ | terrain_class = 0.8; | |
| 362 | } | ||
| 363 | |||
| 364 | ✗ | LOG(Debug, "Terrain class value set to " << terrain_class); | |
| 365 | |||
| 366 | ✗ | int number_of_people = (int)building.numberOfPeople(); | |
| 367 | // get the total nominal population; | ||
| 368 | ✗ | LOG(Debug, "Nominal Number of people = " << number_of_people); | |
| 369 | |||
| 370 | ✗ | LOG(Debug, "*****************************"); | |
| 371 | ✗ | LOG(Debug, " Analyzing Construction"); | |
| 372 | ✗ | LOG(Debug, "*****************************"); | |
| 373 | |||
| 374 | ✗ | std::vector<std::string> const_names; | |
| 375 | ✗ | std::map<std::string, double> const_solarAbsorptance; | |
| 376 | ✗ | std::map<std::string, double> const_thermalAbsorptance; | |
| 377 | ✗ | std::map<std::string, double> const_heatCapacity; | |
| 378 | ✗ | std::map<std::string, double> const_U; | |
| 379 | ✗ | std::map<std::string, double> const_SHGC; | |
| 380 | |||
| 381 | ✗ | for (const openstudio::model::Construction& construction : constructions) { | |
| 382 | ✗ | std::string name = construction.name().get(); | |
| 383 | ✗ | std::vector<openstudio::model::Material> layers = construction.layers(); | |
| 384 | ✗ | const_names.push_back(name); | |
| 385 | |||
| 386 | // assign 0.0 as default values in case we can!assign it by searching through the construction; | ||
| 387 | ✗ | const_U[name] = 0.0; | |
| 388 | ✗ | const_heatCapacity[name] = 0.0; | |
| 389 | ✗ | const_thermalAbsorptance[name] = 0.0; | |
| 390 | ✗ | const_solarAbsorptance[name] = 0.0; | |
| 391 | ✗ | const_SHGC[name] = 0.0; | |
| 392 | |||
| 393 | // first find the opaque constructions - these could be exterior walls and roofs; | ||
| 394 | ✗ | if (construction.isOpaque()) { | |
| 395 | |||
| 396 | // get the 1st layer of construction (outside layer), convert to opaque material and get the thermal & solar Absorptance; | ||
| 397 | // store them in an array indexed by the name of the construction; | ||
| 398 | |||
| 399 | ✗ | if (layers[0].optionalCast<openstudio::model::OpaqueMaterial>()) { | |
| 400 | ✗ | const_thermalAbsorptance[name] = layers[0].optionalCast<openstudio::model::OpaqueMaterial>().get().thermalAbsorptance(); | |
| 401 | } | ||
| 402 | ✗ | if (layers[0].optionalCast<openstudio::model::OpaqueMaterial>()) { | |
| 403 | ✗ | const_solarAbsorptance[name] = layers[0].optionalCast<openstudio::model::OpaqueMaterial>().get().solarAbsorptance(); | |
| 404 | } | ||
| 405 | |||
| 406 | //set the starting R at 0.04 + 0.13 = avg outside film coeff + inside film coeff for walls; | ||
| 407 | ✗ | double const_R = outside_air_film_R + inside_air_film_R; | |
| 408 | ✗ | double const_heat_capacity = 0.0; | |
| 409 | ✗ | for (const openstudio::model::Material& layer : layers) { | |
| 410 | ✗ | double layer_R = 0; | |
| 411 | ✗ | double layer_heat_capacity = 0; | |
| 412 | |||
| 413 | ✗ | if (layer.optionalCast<openstudio::model::StandardOpaqueMaterial>()) { | |
| 414 | // do this stuff if the material can convert to StandardOpaqueMaterial; | ||
| 415 | ✗ | openstudio::model::StandardOpaqueMaterial material = layer.optionalCast<openstudio::model::StandardOpaqueMaterial>().get(); | |
| 416 | // get the R value of the layer; | ||
| 417 | ✗ | layer_R = material.thermalResistance(); | |
| 418 | ✗ | if (material.heatCapacity()) { | |
| 419 | // get the heat capacity directly; | ||
| 420 | ✗ | layer_heat_capacity = material.heatCapacity().get(); | |
| 421 | } else { | ||
| 422 | // if heat capacity is !defined, calculated it as thickness*density*specific heat; | ||
| 423 | ✗ | layer_heat_capacity = material.specificHeat() * material.density() * material.thickness(); | |
| 424 | } | ||
| 425 | ✗ | } else if (layer.optionalCast<openstudio::model::MasslessOpaqueMaterial>()) { | |
| 426 | // do this stuff if the material can convert to a MasslessOpaqueMaterial; | ||
| 427 | ✗ | openstudio::model::MasslessOpaqueMaterial material = layer.optionalCast<openstudio::model::MasslessOpaqueMaterial>().get(); | |
| 428 | // get the R value of the layer; | ||
| 429 | ✗ | layer_R = material.thermalResistance(); | |
| 430 | // heat capacity is !defined for this material; | ||
| 431 | ✗ | layer_heat_capacity = 0.0; | |
| 432 | ✗ | } else if (layer.optionalCast<openstudio::model::RoofVegetation>()) { | |
| 433 | ✗ | openstudio::model::RoofVegetation material = layer.optionalCast<openstudio::model::RoofVegetation>().get(); | |
| 434 | ✗ | layer_R = material.thermalResistance(); | |
| 435 | ✗ | layer_heat_capacity = material.specificHeat() * material.density() * material.thickness(); | |
| 436 | ✗ | } else { | |
| 437 | ✗ | layer_R = 0.0; | |
| 438 | ✗ | layer_heat_capacity = 0.0; | |
| 439 | } | ||
| 440 | ✗ | const_R += layer_R; | |
| 441 | ✗ | const_heat_capacity += layer_heat_capacity; | |
| 442 | } | ||
| 443 | ✗ | const_heatCapacity[name] = const_heat_capacity; | |
| 444 | ✗ | const_U[name] = 1.0 / const_R; | |
| 445 | |||
| 446 | // next find the fenestration/window constructions find U value, heat capcity and SHGC of assembly; | ||
| 447 | // this is somewhat flaky and nowhere near as good as extracting from an EnergyPlus file after running OS/EP, but it will have to do for now | ||
| 448 | ✗ | } else if (construction.isFenestration()) { | |
| 449 | // assume windows have no heat capacity; | ||
| 450 | ✗ | const_heatCapacity[name] = 0.0; | |
| 451 | // assume windows have an effective thermal emissivity of 0; | ||
| 452 | ✗ | const_thermalAbsorptance[name] = 0.0; | |
| 453 | // assume windows have an effective solar absorption of 0; | ||
| 454 | ✗ | const_solarAbsorptance[name] = 0.0; | |
| 455 | |||
| 456 | //set the starting R at 0.04 + 0.13 = avg outside film coeff + inside film coeff for walls; | ||
| 457 | ✗ | double const_R = outside_air_film_R + inside_air_film_R; | |
| 458 | |||
| 459 | // first check if the construction is a single layer; | ||
| 460 | //simple glazing, if so pull off U factor and SHGC directly, set heat capacity to 0; | ||
| 461 | ✗ | if (layers.size() == 1) { | |
| 462 | |||
| 463 | ✗ | openstudio::model::Material layer = layers[0]; | |
| 464 | ✗ | if (layer.optionalCast<openstudio::model::SimpleGlazing>()) { | |
| 465 | // check to see if the layer is simple glazing; | ||
| 466 | //convert to a simple glazing material; | ||
| 467 | ✗ | openstudio::model::SimpleGlazing material = layer.optionalCast<openstudio::model::SimpleGlazing>().get(); | |
| 468 | // U factor is directly defined; | ||
| 469 | ✗ | const_U[name] = material.uFactor(); | |
| 470 | ✗ | const_SHGC[name] = material.solarHeatGainCoefficient(); | |
| 471 | ✗ | } else if (layer.optionalCast<openstudio::model::StandardGlazing>()) { | |
| 472 | // check to see if the layer is standard glazing; | ||
| 473 | // convert the layer to a standard glazing; | ||
| 474 | ✗ | openstudio::model::StandardGlazing material = layer.optionalCast<openstudio::model::StandardGlazing>().get(); | |
| 475 | // U value = thermal conductance + film resistance; | ||
| 476 | ✗ | const_U[name] = 1.0 / (1.0 / material.thermalConductance() + const_R); | |
| 477 | // SHGC = solar transmittance - ignore frame; | ||
| 478 | ✗ | const_SHGC[name] = material.solarTransmittance(); | |
| 479 | ✗ | } else if (layer.optionalCast<openstudio::model::ThermochromicGlazing>()) { | |
| 480 | ✗ | LOG(Debug, "thermochromic Glazing Not Converted - only estimating U value, SHGC set to 0.3"); | |
| 481 | ✗ | openstudio::model::ThermochromicGlazing material = layer.optionalCast<openstudio::model::ThermochromicGlazing>().get(); | |
| 482 | // \todo this material type doesn't have a thermalConductance | ||
| 483 | //const_U[name] = 1.0/(1.0/ material.thermalConductance() + const_R); | ||
| 484 | ✗ | const_SHGC[name] = 0.3; | |
| 485 | ✗ | } else if (layer.optionalCast<openstudio::model::RefractionExtinctionGlazing>()) { | |
| 486 | ✗ | LOG(Debug, "Refraction Extinction Glazing Not Converted - only estimating U value, others set to clear glass values"); | |
| 487 | ✗ | openstudio::model::RefractionExtinctionGlazing material = layer.optionalCast<openstudio::model::RefractionExtinctionGlazing>().get(); | |
| 488 | ✗ | const_U[name] = 1.0 / (1.0 / material.thermalConductance() + const_R); | |
| 489 | ✗ | const_SHGC[name] = 0.8; | |
| 490 | ✗ | } | |
| 491 | ✗ | } else if (layers.size() == 3) { | |
| 492 | // double glaze window. assume glass - gas - glass layers; | ||
| 493 | // assume that a layer is !simple glazing; | ||
| 494 | ✗ | if (layers[0].optionalCast<openstudio::model::StandardGlazing>()) { // check to see if layer 1 is standard glazing; | |
| 495 | // get layer 1 properties; | ||
| 496 | // convert the 1st layer to a standard glazing; | ||
| 497 | ✗ | openstudio::model::StandardGlazing material1 = layers[0].optionalCast<openstudio::model::StandardGlazing>().get(); | |
| 498 | ✗ | double norm_ST1 = material1.solarTransmittanceatNormalIncidence().get(); | |
| 499 | ✗ | double uValue1 = material1.thermalConductance(); | |
| 500 | ✗ | double norm_back_SR1 = material1.backSideSolarReflectanceatNormalIncidence().get(); | |
| 501 | |||
| 502 | /// \todo these are set but not used | ||
| 503 | ✗ | double norm_ST2 = 0; | |
| 504 | ✗ | double uValue2 = 0; | |
| 505 | |||
| 506 | // Now get layer 2 properties; | ||
| 507 | ✗ | if (layers[1].optionalCast<openstudio::model::StandardGlazing>()) { // check to see if layer 2 is standard glazing; | |
| 508 | // convert the 2nd layer to a gas mixture; | ||
| 509 | ✗ | openstudio::model::StandardGlazing material2 = layers[1].optionalCast<openstudio::model::StandardGlazing>().get(); | |
| 510 | ✗ | norm_ST2 = material2.solarTransmittanceatNormalIncidence().get(); | |
| 511 | ✗ | uValue2 = material2.thermalConductance(); | |
| 512 | ✗ | } else if (layers[1].optionalCast<openstudio::model::AirGap>()) { // check to see if layer 1 is an air gap; | |
| 513 | // convert the 2nd layer to an air gap; | ||
| 514 | ✗ | openstudio::model::AirGap material2 = layers[1].optionalCast<openstudio::model::AirGap>().get(); | |
| 515 | ✗ | norm_ST2 = 1.0; | |
| 516 | ✗ | uValue2 = 1.0 / material2.thermalResistance(); | |
| 517 | ✗ | } else if (layers[1].optionalCast<openstudio::model::Gas>()) { // check to see if layer 1 is a gas; | |
| 518 | // convert the 2nd layer to a simple gas layer; | ||
| 519 | ✗ | openstudio::model::Gas material2 = layers[1].optionalCast<openstudio::model::Gas>().get(); | |
| 520 | ✗ | norm_ST2 = 1.0; | |
| 521 | // get U value at 290 K; | ||
| 522 | ✗ | uValue2 = material2.getThermalConductance(290); | |
| 523 | ✗ | } else if (layers[1].optionalCast<openstudio::model::GasMixture>()) { // check to see if layer 1 is a gas; | |
| 524 | // convert the 2nd layer to a simple gas layer; | ||
| 525 | ✗ | openstudio::model::GasMixture material2 = layers[1].optionalCast<openstudio::model::GasMixture>().get(); | |
| 526 | ✗ | norm_ST2 = 1.0; | |
| 527 | // get U value at 290 K; | ||
| 528 | ✗ | uValue2 = material2.getThermalConductance(290); | |
| 529 | ✗ | } else { | |
| 530 | // we can't figure out what it is so assume properties of simple 12 mm air gap w/ U~6.0 from ASHRAE 2009; | ||
| 531 | ✗ | norm_ST2 = 1.0; | |
| 532 | ✗ | uValue2 = 6.0; | |
| 533 | } | ||
| 534 | |||
| 535 | ✗ | double norm_ST3 = 0; | |
| 536 | ✗ | double norm_front_SR3 = 0; | |
| 537 | ✗ | double uValue3 = 0; | |
| 538 | |||
| 539 | // now get layer 3 properties; | ||
| 540 | ✗ | if (layers[2].optionalCast<openstudio::model::StandardGlazing>()) { | |
| 541 | // check to see if layer 2 is standard glazing; | ||
| 542 | ✗ | openstudio::model::StandardGlazing material3 = layers[2].optionalCast<openstudio::model::StandardGlazing>().get(); | |
| 543 | // convert the 2nd layer to a gas mixture; | ||
| 544 | ✗ | norm_ST3 = material3.solarTransmittanceatNormalIncidence().get(); | |
| 545 | ✗ | uValue3 = material3.thermalConductance(); | |
| 546 | ✗ | norm_front_SR3 = material3.frontSideSolarReflectanceatNormalIncidence().get(); | |
| 547 | ✗ | } else { | |
| 548 | // If it isn't standard glazing we don't know what it might be so assume properties of simple 3 mm clear glazing; | ||
| 549 | ✗ | norm_ST3 = 0.87; | |
| 550 | ✗ | uValue3 = 6.0; | |
| 551 | /// \note this value is impossible to get here, there is no material3 in this context, so I'm commenting it out | ||
| 552 | // norm_front_SR3 = material3.frontSideSolarReflectanceatNormalIncidence().get(); | ||
| 553 | } | ||
| 554 | // compute SHGC of a 3 layer window as ST1 * ST3 / (1 - R1 *R3); | ||
| 555 | ✗ | const_SHGC[name] = norm_ST1 * norm_ST3 / (1.0 - norm_back_SR1 * norm_front_SR3) * norm_ST2; | |
| 556 | // for U value = 1/ (sum R values for each layer + film coefficients); | ||
| 557 | ✗ | const_U[name] = 1.0 / (1.0 / uValue1 + 1.0 / uValue2 + 1.0 / uValue3 + const_R); | |
| 558 | |||
| 559 | ✗ | } else if (layers[0].optionalCast<openstudio::model::ThermochromicGlazing>()) { | |
| 560 | ✗ | LOG(Debug, "thermochromic Glazing Not Converted - only estimating U value, SHGC set to 0.3"); | |
| 561 | ✗ | openstudio::model::ThermochromicGlazing material = layers[0].optionalCast<openstudio::model::ThermochromicGlazing>().get(); | |
| 562 | // \todo this material type doesn't have a thermalConductance | ||
| 563 | // const_U[name] = 1.0/(1.0/ material.thermalConductance() + const_R); | ||
| 564 | ✗ | const_SHGC[name] = 0.3; | |
| 565 | ✗ | } else if (!layers[0].optionalCast<openstudio::model::RefractionExtinctionGlazing>()) { | |
| 566 | ✗ | LOG(Debug, "Refraction Extinction Glazing Not Converted - only estimating U value, others set to 0.7"); | |
| 567 | ✗ | openstudio::model::RefractionExtinctionGlazing material = layers[0].optionalCast<openstudio::model::RefractionExtinctionGlazing>().get(); | |
| 568 | ✗ | const_U[name] = 1.0 / (1.0 / material.thermalConductance() + const_R); | |
| 569 | ✗ | const_SHGC[name] = 0.7; | |
| 570 | ✗ | } | |
| 571 | } else { | ||
| 572 | ✗ | LOG(Debug, "Only 1 and 3 layer windows are supported at this time, values set to a standard clear, double glaze window"); | |
| 573 | ✗ | const_U[name] = glazing_U_default; | |
| 574 | ✗ | const_SHGC[name] = glazing_SHGC_default; | |
| 575 | } | ||
| 576 | } | ||
| 577 | ✗ | } | |
| 578 | |||
| 579 | ✗ | for (const std::string& name : const_names) { | |
| 580 | ✗ | LOG(Debug, "Construction: " << name); | |
| 581 | ✗ | LOG(Debug, "Ufactor = " << const_U[name] << " W/K/m2, Heat Capacity = " << const_heatCapacity[name] << " J/K/m2"); | |
| 582 | ✗ | LOG(Debug, "Solar Absorption = " << const_solarAbsorptance[name] << ", Thermal Absorption = " << const_thermalAbsorptance[name] | |
| 583 | << ", SHGC = " << const_SHGC[name]); | ||
| 584 | } | ||
| 585 | |||
| 586 | // parse the schedules to find the average schedule value for occupied and unoccupied times; | ||
| 587 | ✗ | LOG(Debug, "...Parsing Schedules"); | |
| 588 | |||
| 589 | ✗ | std::vector<openstudio::model::ScheduleRuleset> schedule_rulesets = model.getConcreteModelObjects<openstudio::model::ScheduleRuleset>(); | |
| 590 | ✗ | LOG(Debug, "Found " << schedule_rulesets.size() << " schedules in the OSM"); | |
| 591 | |||
| 592 | // get the year description from the model and set the calendar year to 2007 | ||
| 593 | // we use 2006 because Jan 1 is a sunday and it makes day 1 = sunday | ||
| 594 | ✗ | openstudio::model::YearDescription yd = model.getUniqueModelObject<openstudio::model::YearDescription>(); | |
| 595 | ✗ | yd.setCalendarYear(2006); | |
| 596 | |||
| 597 | ✗ | std::vector<openstudio::Time> t(24); | |
| 598 | |||
| 599 | ✗ | for (size_t i = 0; i <= 23; ++i) { | |
| 600 | ✗ | t[i] = openstudio::Time(i / 24.0); | |
| 601 | } | ||
| 602 | |||
| 603 | ✗ | if (OSM_extract_occupancy) { | |
| 604 | // create a hash with all the schedule_ruleset since we can't access dayschedules directly from | ||
| 605 | // the schedule stored in the space_type, we need to find the associated schedule_ruleset | ||
| 606 | |||
| 607 | ✗ | std::map<std::string, openstudio::model::ScheduleRuleset> sched_rulesets; | |
| 608 | |||
| 609 | ✗ | for (const openstudio::model::ScheduleRuleset& ruleset : schedule_rulesets) { | |
| 610 | ✗ | std::string name = ruleset.name().get(); | |
| 611 | ✗ | sched_rulesets.insert(std::make_pair(name, ruleset)); | |
| 612 | ✗ | } | |
| 613 | |||
| 614 | ✗ | std::vector<std::vector<double>> occupancy_schedules_ave(7, std::vector<double>(24, 0)); | |
| 615 | ✗ | [[maybe_unused]] int nscheds = 0; | |
| 616 | ✗ | double space_area_total = 0.0; | |
| 617 | |||
| 618 | // get an area weighted average over all the space types. | ||
| 619 | |||
| 620 | ✗ | for (const openstudio::model::SpaceType& space_type : space_types) { | |
| 621 | ✗ | double space_area = space_type.floorArea(); | |
| 622 | ✗ | space_area_total += space_area; | |
| 623 | |||
| 624 | ✗ | for (const openstudio::model::People& people : space_type.people()) { | |
| 625 | // look for an occupancy schedule | ||
| 626 | |||
| 627 | ✗ | if (people.numberofPeopleSchedule()) { | |
| 628 | // get the schedule. Unfortuntately we need to find the associated sched ruleset to get the day schedule | ||
| 629 | ✗ | openstudio::model::Schedule sched = people.numberofPeopleSchedule().get(); | |
| 630 | |||
| 631 | ✗ | openstudio::model::ScheduleRuleset ruleset = sched_rulesets.find(sched.name().get())->second; | |
| 632 | |||
| 633 | ✗ | for (size_t week = 0; week <= 51; ++week) { | |
| 634 | ✗ | openstudio::Date startDate = yd.makeDate(week * 7 + 1); | |
| 635 | ✗ | openstudio::Date endDate = yd.makeDate(week * 7 + 8); | |
| 636 | |||
| 637 | ✗ | nscheds += 1; | |
| 638 | ✗ | space_area_total += space_area; | |
| 639 | |||
| 640 | std::vector<openstudio::model::ScheduleDay> dayschedule = | ||
| 641 | ✗ | ruleset.getDaySchedules(startDate, endDate); // get the day schedules for the week | |
| 642 | |||
| 643 | ✗ | for (size_t day = 0; day <= 6; ++day) { | |
| 644 | ✗ | for (size_t hour = 0; hour <= 23; ++hour) { | |
| 645 | ✗ | double value = dayschedule[day].getValue(t[hour]); | |
| 646 | ✗ | occupancy_schedules_ave[day][hour] += value * space_area; // add in area weighted value | |
| 647 | } | ||
| 648 | } | ||
| 649 | ✗ | } | |
| 650 | ✗ | } | |
| 651 | ✗ | } | |
| 652 | } | ||
| 653 | |||
| 654 | // now get the area weighted average values for the schedules by dividing by the number of schedules averaged | ||
| 655 | // also get the total daily fractional occupancy (i.e. equivalent hours of full time occupancy) | ||
| 656 | |||
| 657 | ✗ | double threshold = 7.0; | |
| 658 | ✗ | int num_occ_days = 0; | |
| 659 | |||
| 660 | ✗ | std::vector<double> occ_frac_sum(7, 0); | |
| 661 | ✗ | std::vector<int> day_occ(7, 0); | |
| 662 | |||
| 663 | ✗ | for (size_t day = 0; day <= 6; ++day) { | |
| 664 | ✗ | for (size_t hour = 0; hour <= 23; ++hour) { | |
| 665 | ✗ | occupancy_schedules_ave[day][hour] = occupancy_schedules_ave[day][hour] / space_area_total; | |
| 666 | ✗ | occ_frac_sum[day] += occupancy_schedules_ave[day][hour]; | |
| 667 | } | ||
| 668 | |||
| 669 | ✗ | if (occ_frac_sum[day] > threshold) { | |
| 670 | ✗ | day_occ[day] = 1; | |
| 671 | ✗ | num_occ_days += 1; | |
| 672 | } | ||
| 673 | } | ||
| 674 | |||
| 675 | // now find the first and last occupied day of the week assuming a continuous stream | ||
| 676 | int first_occ_day = | ||
| 677 | ✗ | (int)std::distance(day_occ.begin(), std::find(day_occ.begin(), day_occ.end(), 1)); //find the first instance of 1 in the day_occ array | |
| 678 | int last_occ_day = | ||
| 679 | 6 | ||
| 680 | ✗ | - (int)std::distance(day_occ.rbegin(), | |
| 681 | ✗ | std::find(day_occ.rbegin(), day_occ.rend(), | |
| 682 | ✗ | 1)); // find the last instance of 1 by reversing array to find how far from the end the last occupied day is | |
| 683 | |||
| 684 | // now, for the days considered occupied, find an "average" occupancy schedule to estimate the best starting and stopping times | ||
| 685 | |||
| 686 | // find an "average" schedule during the occupied days (i.e. do not include unoccupied days in this average) | ||
| 687 | |||
| 688 | ✗ | std::vector<double> avg_occupied_schedule(24, 0); | |
| 689 | ✗ | double avg_occ_sum = 0.0; | |
| 690 | |||
| 691 | ✗ | for (size_t hour = 0; hour <= 23; ++hour) { | |
| 692 | ✗ | avg_occupied_schedule[hour] = 0.0; | |
| 693 | |||
| 694 | ✗ | for (int day = first_occ_day; day <= last_occ_day; ++day) { | |
| 695 | ✗ | avg_occupied_schedule[hour] += occupancy_schedules_ave[day][hour]; | |
| 696 | } | ||
| 697 | |||
| 698 | ✗ | if (num_occ_days > 0) { | |
| 699 | |||
| 700 | ✗ | avg_occupied_schedule[hour] = avg_occupied_schedule[hour] / num_occ_days; | |
| 701 | } | ||
| 702 | ✗ | avg_occ_sum += avg_occupied_schedule[hour]; | |
| 703 | |||
| 704 | //printf("%1.1f, ",avg_occupied_schedule[hour]) | ||
| 705 | } | ||
| 706 | //print "\n" | ||
| 707 | |||
| 708 | // now estimate the average number of fully occupied hours per day by rounding down the sum to the nearest number of hours | ||
| 709 | ✗ | int num_occ_hours = (int)std::floor(avg_occ_sum); | |
| 710 | |||
| 711 | // now we find the best start time for the occupancy by matching a sliding window of full occupancy to the average occupancy | ||
| 712 | // we maximize the sum of the product of actual occupancy and the sliding window to get the best hours of operation | ||
| 713 | // find the start time by maximizing the sum of the product of the start-to-end sliding window and the average hourly occupancy | ||
| 714 | |||
| 715 | ✗ | double max_sum = 0.0; | |
| 716 | ✗ | int max_index = 0; | |
| 717 | |||
| 718 | ✗ | for (int start_hour = 0; start_hour <= 23 - num_occ_hours; ++start_hour) { | |
| 719 | ✗ | double temp_sum = 0.0; | |
| 720 | |||
| 721 | ✗ | for (int i = start_hour; i <= start_hour + num_occ_hours; ++i) { | |
| 722 | ✗ | temp_sum += avg_occupied_schedule[i]; | |
| 723 | } | ||
| 724 | |||
| 725 | ✗ | if (temp_sum > max_sum) { | |
| 726 | |||
| 727 | ✗ | max_sum = temp_sum; | |
| 728 | |||
| 729 | ✗ | max_index = start_hour; | |
| 730 | } | ||
| 731 | } | ||
| 732 | |||
| 733 | ✗ | occupancy_day_start = first_occ_day; // set starting day for occupancy | |
| 734 | ✗ | occupancy_day_end = last_occ_day; // set the ending day for occupancy | |
| 735 | ✗ | occupancy_hour_start = max_index; // set starting hour for occupied day | |
| 736 | ✗ | occupancy_hour_end = | |
| 737 | ✗ | max_index + num_occ_hours + 1; // set ending hour for an occupied day. Add one because we want occupancy to drop at that time | |
| 738 | ✗ | } | |
| 739 | |||
| 740 | ✗ | LOG(Debug, "*******************************"); | |
| 741 | ✗ | LOG(Debug, " Calculating Schedule Averages"); | |
| 742 | ✗ | LOG(Debug, "*******************************"); | |
| 743 | |||
| 744 | ✗ | std::vector<std::string> sched_names; | |
| 745 | ✗ | std::map<std::string, double> occ_aves; | |
| 746 | ✗ | std::map<std::string, double> unocc_aves; | |
| 747 | |||
| 748 | ✗ | openstudio::Date startDate = yd.makeDate(1); | |
| 749 | ✗ | openstudio::Date endDate = yd.makeDate(365); | |
| 750 | |||
| 751 | // compute the number of occupied days in a year for water use calculations | ||
| 752 | |||
| 753 | ✗ | double number_days_occupied_per_year = 52 * (occupancy_day_end - occupancy_day_start + 1); | |
| 754 | ✗ | double occupied_hours = number_days_occupied_per_year * (occupancy_hour_end - occupancy_hour_start + 1); | |
| 755 | ✗ | double unoccupied_hours = 8760 - occupied_hours; | |
| 756 | |||
| 757 | // gets all the schedule for each day of the year in one array | ||
| 758 | |||
| 759 | ✗ | for (const openstudio::model::ScheduleRuleset& schedule : schedule_rulesets) { | |
| 760 | ✗ | double occupied_sum = 0; | |
| 761 | ✗ | double unoccupied_sum = 0; | |
| 762 | |||
| 763 | // get the day of the week of the starting day of the schedule and subtract 1 from it because we increment before we compare | ||
| 764 | ✗ | int day_of_week = startDate.dayOfWeek().value() - 1; | |
| 765 | |||
| 766 | ✗ | std::vector<openstudio::model::ScheduleDay> daySchedules = schedule.getDaySchedules(startDate, endDate); | |
| 767 | |||
| 768 | // loop over the schedule for each day of the year | ||
| 769 | ✗ | for (const openstudio::model::ScheduleDay& daySchedule : daySchedules) { | |
| 770 | ✗ | day_of_week += 1; // increment the day of week counter wrapping around at 7 | |
| 771 | |||
| 772 | ✗ | if (day_of_week > 6) { | |
| 773 | ✗ | day_of_week = 0; | |
| 774 | } | ||
| 775 | |||
| 776 | // loop over each hour of the day | ||
| 777 | ✗ | for (int hour = 0; hour <= 23; ++hour) { | |
| 778 | ✗ | double value = daySchedule.getValue(t[hour]); // get the schedule value at this hour | |
| 779 | |||
| 780 | // check if the day of the week is an occupied day or not | ||
| 781 | ✗ | if ((day_of_week >= occupancy_day_start) && (day_of_week <= occupancy_day_end)) { | |
| 782 | |||
| 783 | // check if the hour is also an occupied hour | ||
| 784 | // if so, add value to occupied sum and increment occupied counter | ||
| 785 | ✗ | if ((hour >= occupancy_hour_start) && (hour < occupancy_hour_end)) { | |
| 786 | ✗ | occupied_sum += value; | |
| 787 | } else { // if hour not occupied, add value to unoccupied and increment unoccupied counter | ||
| 788 | ✗ | unoccupied_sum += value; | |
| 789 | } | ||
| 790 | } else { // if day is not occupied, add the hour value to unoccupied | ||
| 791 | ✗ | unoccupied_sum += value; | |
| 792 | } | ||
| 793 | } | ||
| 794 | } | ||
| 795 | |||
| 796 | ✗ | sched_names.push_back(schedule.name().get()); | |
| 797 | ✗ | occ_aves[schedule.name().get()] = occupied_sum / occupied_hours; | |
| 798 | ✗ | unocc_aves[schedule.name().get()] = unoccupied_sum / unoccupied_hours; | |
| 799 | |||
| 800 | ✗ | LOG(Debug, "Schedule " << schedule.name().get() << " has occupied ave = " << occ_aves[schedule.name().get()] | |
| 801 | << " and unoccupied ave = " << unocc_aves[schedule.name().get()]); | ||
| 802 | ✗ | } | |
| 803 | |||
| 804 | // at this point we have an array with the schedule names and two arrays with the averages; | ||
| 805 | // that are indexed by the schedule names.; | ||
| 806 | |||
| 807 | // define what fraction of the year are occupied and unoccupied; | ||
| 808 | ✗ | double frac_year_occ = occupied_hours / 8760.0; | |
| 809 | ✗ | double frac_year_unocc = unoccupied_hours / 8760.0; | |
| 810 | |||
| 811 | ✗ | LOG(Debug, "Fraction of year occupied = " << frac_year_occ << " and Fraction of year unoccupied = " << frac_year_unocc); | |
| 812 | |||
| 813 | ✗ | LOG(Debug, "...Calculating() Electric and Gas Loads"); | |
| 814 | ✗ | LOG(Debug, "*****************************"); | |
| 815 | ✗ | LOG(Debug, " Calculating Electric and Gas Loads"); | |
| 816 | ✗ | LOG(Debug, "*****************************"); | |
| 817 | |||
| 818 | // get the light, electrical, and gas power densities and people densities; | ||
| 819 | // overall nominal lighting power density; | ||
| 820 | ✗ | double nominal_lpd = building.lightingPowerPerFloorArea(); | |
| 821 | // overall nominal electric equipment power density W/m2; | ||
| 822 | ✗ | double nominal_epd = building.electricEquipmentPowerPerFloorArea(); | |
| 823 | // overall nominal gas equipment power density W/m2; | ||
| 824 | ✗ | double nominal_gpd = building.gasEquipmentPowerPerFloorArea(); | |
| 825 | |||
| 826 | // loop over the lighting, equipment, and occupancy schedules to get the occupied and unoccupied values; | ||
| 827 | // and compute the area weighted averages; | ||
| 828 | // set this to a tiny number to avoid divide by zero but to also avoid skewing the area; | ||
| 829 | ✗ | double light_total_area = 0; | |
| 830 | ✗ | double light_occ_total = 0; | |
| 831 | ✗ | double light_unocc_total = 0; | |
| 832 | ✗ | double elec_total_area = 0; | |
| 833 | ✗ | double elec_occ_total = 0; | |
| 834 | ✗ | double elec_unocc_total = 0; | |
| 835 | ✗ | double gas_total_area = 0; | |
| 836 | ✗ | double gas_occ_total = 0; | |
| 837 | ✗ | double gas_unocc_total = 0; | |
| 838 | ✗ | double people_total_area = 0; | |
| 839 | ✗ | double people_occ_total = 0; | |
| 840 | ✗ | double people_unocc_total = 0; | |
| 841 | ✗ | double activity_total_area = 0; | |
| 842 | ✗ | double activity_occ_total = 0; | |
| 843 | ✗ | double activity_unocc_total = 0; | |
| 844 | |||
| 845 | //std::vector<double> light_areas=[]; | ||
| 846 | //light_scheds=[]; | ||
| 847 | |||
| 848 | ✗ | for (const openstudio::model::SpaceType& space_type : space_types) { | |
| 849 | // work with the lighting schedule - luminaires are !supported at this time; | ||
| 850 | ✗ | double space_area = space_type.floorArea(); | |
| 851 | ✗ | for (const openstudio::model::Lights& light : space_type.lights()) { | |
| 852 | ✗ | if (light.schedule()) { | |
| 853 | // look for a lighting schedule; | ||
| 854 | // get the schedule; | ||
| 855 | ✗ | openstudio::model::Schedule sched = light.schedule().get(); | |
| 856 | ✗ | light_total_area += space_area; | |
| 857 | ✗ | light_occ_total += occ_aves[sched.name().get()] * space_area; | |
| 858 | ✗ | light_unocc_total += unocc_aves[sched.name().get()] * space_area; | |
| 859 | ✗ | } | |
| 860 | ✗ | } | |
| 861 | |||
| 862 | ✗ | for (const openstudio::model::ElectricEquipment& electric : space_type.electricEquipment()) { | |
| 863 | // look for an electric equipment schedule; | ||
| 864 | ✗ | if (electric.schedule()) { | |
| 865 | ✗ | openstudio::model::Schedule sched = electric.schedule().get(); | |
| 866 | ✗ | elec_total_area += space_area; | |
| 867 | ✗ | elec_occ_total += occ_aves[sched.name().get()] * space_area; | |
| 868 | ✗ | elec_unocc_total += unocc_aves[sched.name().get()] * space_area; | |
| 869 | ✗ | } | |
| 870 | ✗ | } | |
| 871 | |||
| 872 | ✗ | for (const openstudio::model::GasEquipment& gas : space_type.gasEquipment()) { | |
| 873 | // look for a gas equipment schedule; | ||
| 874 | ✗ | if (gas.schedule()) { | |
| 875 | ✗ | openstudio::model::Schedule sched = gas.schedule().get(); | |
| 876 | ✗ | gas_total_area += space_area; | |
| 877 | ✗ | gas_occ_total += occ_aves[sched.name().get()] * space_area; | |
| 878 | ✗ | gas_unocc_total += unocc_aves[sched.name().get()] * space_area; | |
| 879 | ✗ | } | |
| 880 | ✗ | } | |
| 881 | |||
| 882 | ✗ | for (const openstudio::model::People& people : space_type.people()) { | |
| 883 | // look for an occupancy schedule; | ||
| 884 | ✗ | if (people.numberofPeopleSchedule()) { | |
| 885 | ✗ | openstudio::model::Schedule sched = people.numberofPeopleSchedule().get(); | |
| 886 | ✗ | people_total_area += space_area; | |
| 887 | ✗ | people_occ_total += occ_aves[sched.name().get()] * space_area; | |
| 888 | ✗ | people_unocc_total += unocc_aves[sched.name().get()] * space_area; | |
| 889 | ✗ | } | |
| 890 | |||
| 891 | // look for an occupant activity level schedule; | ||
| 892 | ✗ | if (people.activityLevelSchedule()) { | |
| 893 | ✗ | openstudio::model::Schedule sched = people.activityLevelSchedule().get(); | |
| 894 | ✗ | activity_total_area += space_area; | |
| 895 | ✗ | activity_occ_total += occ_aves[sched.name().get()] * space_area; | |
| 896 | ✗ | activity_unocc_total += unocc_aves[sched.name().get()] * space_area; | |
| 897 | ✗ | } | |
| 898 | ✗ | } | |
| 899 | } | ||
| 900 | |||
| 901 | // compute the fractional multipliers from the schedule data; | ||
| 902 | ✗ | double lpd_occ_mult = 0; | |
| 903 | ✗ | double lpd_unocc_mult = 0; | |
| 904 | ✗ | double epd_occ_mult = 0; | |
| 905 | ✗ | double epd_unocc_mult = 0; | |
| 906 | ✗ | double gpd_occ_mult = 0; | |
| 907 | ✗ | double gpd_unocc_mult = 0; | |
| 908 | ✗ | double people_occ_mult = 0; | |
| 909 | ✗ | double people_unocc_mult = 0; | |
| 910 | |||
| 911 | ✗ | if (light_total_area > 0) { | |
| 912 | ✗ | lpd_occ_mult = light_occ_total / light_total_area; | |
| 913 | ✗ | lpd_unocc_mult = light_unocc_total / light_total_area; | |
| 914 | } else { | ||
| 915 | ✗ | lpd_occ_mult = 1; | |
| 916 | ✗ | lpd_unocc_mult = 1; | |
| 917 | } | ||
| 918 | ✗ | if (elec_total_area > 0) { | |
| 919 | ✗ | epd_occ_mult = elec_occ_total / elec_total_area; | |
| 920 | ✗ | epd_unocc_mult = elec_unocc_total / elec_total_area; | |
| 921 | } else { | ||
| 922 | ✗ | epd_occ_mult = 1; | |
| 923 | ✗ | epd_unocc_mult = 1; | |
| 924 | } | ||
| 925 | ✗ | if (gas_total_area > 0) { | |
| 926 | ✗ | gpd_occ_mult = gas_occ_total / gas_total_area; | |
| 927 | ✗ | gpd_unocc_mult = gas_unocc_total / gas_total_area; | |
| 928 | } else { | ||
| 929 | ✗ | gpd_occ_mult = 1; | |
| 930 | ✗ | gpd_unocc_mult = 1; | |
| 931 | } | ||
| 932 | ✗ | if (people_total_area > 0) { | |
| 933 | ✗ | people_occ_mult = people_occ_total / people_total_area; | |
| 934 | ✗ | people_unocc_mult = people_unocc_total / people_total_area; | |
| 935 | } else { | ||
| 936 | ✗ | people_occ_mult = 1; | |
| 937 | ✗ | people_unocc_mult = 1; | |
| 938 | } | ||
| 939 | |||
| 940 | // compute the activity level (heat gain per person) from schedule data; | ||
| 941 | ✗ | double activity_level_occ = activity_occ_total / activity_total_area; | |
| 942 | ✗ | double activity_level_unocc = activity_unocc_total / activity_total_area; | |
| 943 | |||
| 944 | // compute the occupied and unoccupied lighting and equipment power densities; | ||
| 945 | ✗ | double lpd_unoccupied = nominal_lpd * lpd_unocc_mult; | |
| 946 | |||
| 947 | // when computing occupied, subtract the occupied because the isomodel calc adds unoccupied to occupied to account for parasitic lighting; | ||
| 948 | // that people often forget; | ||
| 949 | ✗ | double lpd_occupied = nominal_lpd * lpd_occ_mult - lpd_unoccupied; | |
| 950 | ✗ | double epd_occupied = nominal_epd * epd_occ_mult; | |
| 951 | ✗ | double epd_unoccupied = nominal_epd * epd_unocc_mult; | |
| 952 | ✗ | double gpd_occupied = nominal_gpd * gpd_occ_mult; | |
| 953 | ✗ | double gpd_unoccupied = nominal_gpd * gpd_unocc_mult; | |
| 954 | |||
| 955 | ✗ | LOG(Debug, "Lighting Power Density: Occupied= " << lpd_occupied << " W/m2, Unoccupied = " << lpd_unoccupied << " W/m2"); | |
| 956 | ✗ | LOG(Debug, "Electric Equipment Power Density: Occupied= " << epd_occupied << " W/m2, Unoccupied = " << epd_unoccupied << " W/m2"); | |
| 957 | ✗ | LOG(Debug, "Gas Equipment Power Density: Occupied= " << gpd_occupied << " W/m2, Unoccupied = " << gpd_unoccupied << " W/m2\n"); | |
| 958 | |||
| 959 | // compute the nominal area per person info; | ||
| 960 | ✗ | double nominal_app = 1.0 / building.peoplePerFloorArea(); | |
| 961 | // nominal area per person m^2/person; | ||
| 962 | |||
| 963 | // set the heat gain per person to be the average occupied value; | ||
| 964 | ✗ | double heat_gain_per_person_occ = activity_level_occ; | |
| 965 | ✗ | double heat_gain_per_person_unocc = activity_level_unocc; | |
| 966 | |||
| 967 | // get the area per person scaled by occupancy multiplier; | ||
| 968 | ✗ | double area_per_person_occupied = nominal_app / people_occ_mult; | |
| 969 | ✗ | double area_per_person_unoccupied = nominal_app / people_unocc_mult; | |
| 970 | |||
| 971 | ✗ | LOG(Debug, | |
| 972 | "Occupant Heat Gain: Occupied= " << heat_gain_per_person_occ << " W/person, Unoccupied = " << heat_gain_per_person_unocc << " W/person"); | ||
| 973 | ✗ | LOG(Debug, | |
| 974 | "Area per person: Occupied= " << area_per_person_occupied << " m2/person, Unoccupied = " << area_per_person_unoccupied << " m2/person"); | ||
| 975 | |||
| 976 | // compute exterior lighting power; | ||
| 977 | ✗ | double exterior_lighting_power = 0.0; | |
| 978 | ✗ | if (!facility.exteriorLights().empty()) { | |
| 979 | // get the vector of exterior lights; | ||
| 980 | ✗ | std::vector<openstudio::model::ExteriorLights> ext_lights = facility.exteriorLights(); | |
| 981 | // loop over the lights; | ||
| 982 | ✗ | for (const openstudio::model::ExteriorLights& exlight : ext_lights) { | |
| 983 | ✗ | double ext_light_mult = exlight.multiplier(); | |
| 984 | ✗ | double ext_light_base = exlight.exteriorLightsDefinition().designLevel(); | |
| 985 | ✗ | exterior_lighting_power += ext_light_base * ext_light_mult; | |
| 986 | } | ||
| 987 | ✗ | LOG(Debug, "Found " << ext_lights.size() << " Exterior Lights"); | |
| 988 | ✗ | } | |
| 989 | ✗ | LOG(Debug, "Exterior Lighting Power = " << exterior_lighting_power << " W"); | |
| 990 | |||
| 991 | // check for luminaire definitions and print a warning if they are defined; | ||
| 992 | ✗ | std::vector<openstudio::model::Luminaire> luminaires = model.getConcreteModelObjects<openstudio::model::Luminaire>(); | |
| 993 | ✗ | if (!luminaires.empty()) { | |
| 994 | ✗ | LOG(Debug, "Warning: Luminaires defined in OSM but not currently translated into ISO"); | |
| 995 | } | ||
| 996 | |||
| 997 | ✗ | LOG(Debug, "...Calculating() Thermostats"); | |
| 998 | ✗ | LOG(Debug, "*****************************"); | |
| 999 | ✗ | LOG(Debug, " Calculating Thermostats"); | |
| 1000 | ✗ | LOG(Debug, "*****************************"); | |
| 1001 | |||
| 1002 | ✗ | double cooling_setpoint_occ = 0; | |
| 1003 | ✗ | double cooling_setpoint_unocc = 0; | |
| 1004 | ✗ | double heating_setpoint_occ = 0; | |
| 1005 | ✗ | double heating_setpoint_unocc = 0; | |
| 1006 | |||
| 1007 | ✗ | if (OSM_extract_temp_setpoint) { | |
| 1008 | // set the occupied and unoccupied temperature setpoint by finding average setpoint over the occupied and unoccupied times | ||
| 1009 | |||
| 1010 | // set the occupied and unoccupied temperature setpoint by finding average setpoint over the occupied and unoccupied times; | ||
| 1011 | //std::vector<openstudio::model::ThermostatSetpointDualSetpoint> thermostats = model.getConcreteModelObjects<openstudio::model::ThermostatSetpointDualSetpoint>(); | ||
| 1012 | |||
| 1013 | ✗ | double total_zone_area = 0; | |
| 1014 | ✗ | double heat_setpoint_occ_total = 0; | |
| 1015 | ✗ | double heat_setpoint_unocc_total = 0; | |
| 1016 | ✗ | double cool_setpoint_occ_total = 0; | |
| 1017 | ✗ | double cool_setpoint_unocc_total = 0; | |
| 1018 | |||
| 1019 | // loop through the zones and find the thermostats rather than use the thermostat vector we can get from the model; | ||
| 1020 | // we want to do a zone area weighted average in case the different zones have different; | ||
| 1021 | //loop through the zones; | ||
| 1022 | ✗ | for (const openstudio::model::ThermalZone& zone : thermal_zones) { | |
| 1023 | ✗ | double zone_area = zone.floorArea() * zone.multiplier(); | |
| 1024 | ✗ | total_zone_area += zone_area; | |
| 1025 | |||
| 1026 | ✗ | if (zone.thermostatSetpointDualSetpoint()) { | |
| 1027 | ✗ | openstudio::model::ThermostatSetpointDualSetpoint thermostat = zone.thermostatSetpointDualSetpoint().get(); | |
| 1028 | ✗ | if (thermostat.coolingSetpointTemperatureSchedule()) { | |
| 1029 | ✗ | openstudio::model::Schedule cool_sched = thermostat.coolingSetpointTemperatureSchedule().get(); | |
| 1030 | ✗ | cool_setpoint_occ_total += occ_aves[cool_sched.name().get()] * zone_area; | |
| 1031 | ✗ | cool_setpoint_unocc_total += unocc_aves[cool_sched.name().get()] * zone_area; | |
| 1032 | ✗ | } else { | |
| 1033 | // if we have no schedule, use the default values for thiz zone; | ||
| 1034 | ✗ | cool_setpoint_occ_total += cooling_setpoint_occ_default * zone_area; | |
| 1035 | ✗ | cool_setpoint_unocc_total += cooling_setpoint_unocc_default * zone_area; | |
| 1036 | } | ||
| 1037 | ✗ | if (thermostat.heatingSetpointTemperatureSchedule()) { | |
| 1038 | ✗ | openstudio::model::Schedule heat_sched = thermostat.heatingSetpointTemperatureSchedule().get(); | |
| 1039 | ✗ | heat_setpoint_occ_total += occ_aves[heat_sched.name().get()] * zone_area; | |
| 1040 | ✗ | heat_setpoint_unocc_total += unocc_aves[heat_sched.name().get()] * zone_area; | |
| 1041 | ✗ | } else { | |
| 1042 | ✗ | heat_setpoint_occ_total += heating_setpoint_occ_default * zone_area; | |
| 1043 | ✗ | heat_setpoint_unocc_total += heating_setpoint_unocc_default * zone_area; | |
| 1044 | } | ||
| 1045 | ✗ | } else { | |
| 1046 | ✗ | cool_setpoint_occ_total += cooling_setpoint_occ_default * zone_area; | |
| 1047 | ✗ | heat_setpoint_occ_total += heating_setpoint_occ_default * zone_area; | |
| 1048 | ✗ | cool_setpoint_unocc_total += cooling_setpoint_unocc_default * zone_area; | |
| 1049 | ✗ | heat_setpoint_unocc_total += heating_setpoint_unocc_default * zone_area; | |
| 1050 | } | ||
| 1051 | } | ||
| 1052 | ✗ | cooling_setpoint_occ = cool_setpoint_occ_total / total_zone_area; | |
| 1053 | ✗ | cooling_setpoint_unocc = cool_setpoint_unocc_total / total_zone_area; | |
| 1054 | ✗ | heating_setpoint_occ = heat_setpoint_occ_total / total_zone_area; | |
| 1055 | ✗ | heating_setpoint_unocc = heat_setpoint_unocc_total / total_zone_area; | |
| 1056 | } else { | ||
| 1057 | ✗ | cooling_setpoint_occ = cooling_setpoint_occ_default; | |
| 1058 | ✗ | cooling_setpoint_unocc = cooling_setpoint_unocc_default; | |
| 1059 | ✗ | heating_setpoint_occ = heating_setpoint_occ_default; | |
| 1060 | ✗ | heating_setpoint_unocc = heating_setpoint_unocc_default; | |
| 1061 | } | ||
| 1062 | |||
| 1063 | ✗ | LOG(Debug, "Cooling Setpoint Occupied = " << cooling_setpoint_occ << " C, Cooling Setpoint Unoccupied = " << cooling_setpoint_unocc << " C"); | |
| 1064 | ✗ | LOG(Debug, "Heating Setpoint Occupied = " << heating_setpoint_occ << " C, Heating Setpoint Unoccupied = " << heating_setpoint_unocc << " C"); | |
| 1065 | |||
| 1066 | // try to find if >60% of floor area has daylight control; | ||
| 1067 | // loop through spaces, get area and check for any daylighting controls; | ||
| 1068 | ✗ | double daylight_area = 0.0; | |
| 1069 | ✗ | double total_area = 0; | |
| 1070 | |||
| 1071 | ✗ | for (const openstudio::model::Space& s : spaces) { | |
| 1072 | // add up the total floor area; | ||
| 1073 | ✗ | total_area += s.floorArea() * s.multiplier(); | |
| 1074 | ✗ | std::vector<openstudio::model::DaylightingControl> daylight_ctrls = s.daylightingControls(); | |
| 1075 | // check for a daylighting control of any kind, assume it's turned on; | ||
| 1076 | ✗ | if (daylight_ctrls.size() != 0) { | |
| 1077 | // add up the total daylighting control area; | ||
| 1078 | ✗ | daylight_area += s.floorArea() * s.multiplier(); | |
| 1079 | } | ||
| 1080 | ✗ | } | |
| 1081 | ✗ | double frac_daylight = 0; | |
| 1082 | |||
| 1083 | ✗ | if (total_area > 0) { | |
| 1084 | ✗ | frac_daylight = daylight_area / total_area; | |
| 1085 | } else { | ||
| 1086 | ✗ | frac_daylight = 0; | |
| 1087 | } | ||
| 1088 | |||
| 1089 | ✗ | LOG(Debug, "Calculated " << frac_daylight << " of total area has daylighting controls"); | |
| 1090 | ✗ | int daylight_sensors = 0; | |
| 1091 | ✗ | if (frac_daylight > 0.6) { | |
| 1092 | // turn on daylighting controls in ISO model; | ||
| 1093 | ✗ | daylight_sensors = 2; | |
| 1094 | } else { | ||
| 1095 | // turn off daylighting controls in ISO model; | ||
| 1096 | ✗ | daylight_sensors = 1; | |
| 1097 | } | ||
| 1098 | |||
| 1099 | ✗ | LOG(Debug, "...Parsing() Geometry"); | |
| 1100 | |||
| 1101 | ✗ | LOG(Debug, "*****************************"); | |
| 1102 | ✗ | LOG(Debug, " Parsing Geometry"); | |
| 1103 | ✗ | LOG(Debug, "*****************************"); | |
| 1104 | |||
| 1105 | // get the overall floor area from the building object; | ||
| 1106 | // first see if conditioned floor area is set and use that if it is, otherwise use regular floor area; | ||
| 1107 | ✗ | double floor_area = 0; | |
| 1108 | ✗ | if (building.conditionedFloorArea()) { | |
| 1109 | ✗ | floor_area = building.conditionedFloorArea().get(); | |
| 1110 | } else { | ||
| 1111 | ✗ | floor_area = building.floorArea(); | |
| 1112 | } | ||
| 1113 | ✗ | LOG(Debug, "Floor Area = " << floor_area << " m2"); | |
| 1114 | |||
| 1115 | // Compute the building height as the difference from max and min vertex height; | ||
| 1116 | ✗ | double maxz = -1000.0; | |
| 1117 | ✗ | double minz = 1000.0; | |
| 1118 | ✗ | for (const openstudio::model::Space& sp : spaces) { | |
| 1119 | // loop through space surfaces to find max z value; | ||
| 1120 | ✗ | for (const openstudio::model::Surface& s : sp.surfaces()) { | |
| 1121 | ✗ | std::vector<double> z_points; | |
| 1122 | ✗ | for (const openstudio::Point3d& vertex : s.vertices()) { | |
| 1123 | ✗ | z_points.push_back(vertex.z()); | |
| 1124 | ✗ | } | |
| 1125 | |||
| 1126 | /// \todo shouldn't there be some test to make sure there was > 0 vertices? | ||
| 1127 | |||
| 1128 | // find the min z for the surface and add the space origin offset; | ||
| 1129 | ✗ | double minsz = *std::min_element(z_points.begin(), z_points.end()) + sp.zOrigin(); | |
| 1130 | // find the max z for the surface and add the space origin offset; | ||
| 1131 | ✗ | double maxsz = *std::max_element(z_points.begin(), z_points.end()) + sp.zOrigin(); | |
| 1132 | ✗ | if (maxsz > maxz) maxz = maxsz; | |
| 1133 | ✗ | if (minsz < minz) minz = minsz; | |
| 1134 | ✗ | } | |
| 1135 | } | ||
| 1136 | |||
| 1137 | ✗ | double building_height = maxz - minz; | |
| 1138 | |||
| 1139 | ✗ | LOG(Debug, "Building Height = " << building_height << " m"); | |
| 1140 | |||
| 1141 | // find the areas of wall, roofs, and windows; | ||
| 1142 | // create arrays for the walls and windows; | ||
| 1143 | ✗ | static const std::string direction_names[] = {"N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"}; | |
| 1144 | static const double dirLimit[] = {0, 45, 90, 135, 180, 225, 270, 315, 360}; | ||
| 1145 | // generate an 8x1 array filled with zeros; | ||
| 1146 | ✗ | std::vector<double> wall_areas(8, 0.0); | |
| 1147 | ✗ | std::vector<double> window_areas(8, 0.0); | |
| 1148 | ✗ | std::vector<double> wall_U(8, 0.0); | |
| 1149 | ✗ | std::vector<double> window_U(8, 0.0); | |
| 1150 | ✗ | std::vector<double> wall_solar_absorption(8, 0.0); | |
| 1151 | ✗ | std::vector<double> wall_thermal_emissivity(8, 0.0); | |
| 1152 | ✗ | std::vector<double> window_SHGC(8, 0.0); | |
| 1153 | |||
| 1154 | ✗ | double wall_HC_sum = 0.0; | |
| 1155 | ✗ | std::vector<double> wall_U_area(8, 0.0); | |
| 1156 | ✗ | std::vector<double> wall_U_sum(8, 0.0); | |
| 1157 | ✗ | std::vector<double> wall_abs_sum(8, 0.0); | |
| 1158 | ✗ | std::vector<double> wall_emiss_sum(8, 0.0); | |
| 1159 | ✗ | std::vector<double> wall_abs_area(8, 0.0); | |
| 1160 | |||
| 1161 | ✗ | double window_HC_sum = 0.0; | |
| 1162 | ✗ | std::vector<double> window_U_sum(8, 0.0); | |
| 1163 | ✗ | std::vector<double> window_U_area(8, 0.0); | |
| 1164 | ✗ | std::vector<double> window_SHGC_sum(8, 0.0); | |
| 1165 | |||
| 1166 | // extract outside walls and windows, and add up areas and add up weighted surface properties; | ||
| 1167 | ✗ | LOG(Debug, "Found " << building.exteriorWalls().size() << " exterior wall surfaces"); | |
| 1168 | ✗ | for (const openstudio::model::Surface& s : building.exteriorWalls()) { | |
| 1169 | |||
| 1170 | ✗ | double absorption = const_solarAbsorptance[s.construction().get().name().get()]; | |
| 1171 | ✗ | double emissivity = const_thermalAbsorptance[s.construction().get().name().get()]; | |
| 1172 | ✗ | double heatcapacity = const_heatCapacity[s.construction().get().name().get()]; | |
| 1173 | |||
| 1174 | // get the surface azimuth and convert from radians to degrees; | ||
| 1175 | ✗ | double azimuth = s.azimuth() * 180 / 3.141592654; | |
| 1176 | // rotate the coordinate system 22.5 degrees so N is 0 to 45 instead of -22.5 to 22.5; | ||
| 1177 | ✗ | double az = azimuth + 22.5; | |
| 1178 | ✗ | if (az > 360) { | |
| 1179 | // remap anything between 360 and 382.5 back to 0 to 22.5; | ||
| 1180 | ✗ | az = az - 360; | |
| 1181 | } | ||
| 1182 | ✗ | for (int i = 0; i <= 7; ++i) { | |
| 1183 | ✗ | if ((az > dirLimit[i]) && (az <= dirLimit[i + 1])) { | |
| 1184 | |||
| 1185 | // add in the wall area without window; | ||
| 1186 | ✗ | wall_areas[i] += s.netArea(); | |
| 1187 | ✗ | wall_abs_sum[i] += absorption * s.netArea(); | |
| 1188 | ✗ | wall_emiss_sum[i] += emissivity * s.netArea(); | |
| 1189 | ✗ | wall_HC_sum += heatcapacity * s.netArea(); | |
| 1190 | |||
| 1191 | ✗ | double wallU = const_U[s.construction().get().name().get()]; | |
| 1192 | // if the U value is !NaN add in the U value and area for weighting; | ||
| 1193 | // keep a separate area sum for wall U in case there are some segments with undefined U values | ||
| 1194 | // we don't want them to be averaged in | ||
| 1195 | #ifdef _MSC_VER | ||
| 1196 | if (!_isnan(wallU)) { | ||
| 1197 | #else | ||
| 1198 | ✗ | if (!std::isnan(wallU)) { | |
| 1199 | #endif | ||
| 1200 | ✗ | wall_U_area[i] += s.netArea(); | |
| 1201 | ✗ | wall_U_sum[i] += wallU * s.netArea(); | |
| 1202 | } | ||
| 1203 | ✗ | std::vector<openstudio::model::SubSurface> subsurface = s.subSurfaces(); | |
| 1204 | ✗ | for (const openstudio::model::SubSurface& ss : subsurface) { | |
| 1205 | ✗ | double windowU = const_U[ss.construction().get().name().get()]; | |
| 1206 | ✗ | double windowSHGC = const_SHGC[ss.construction().get().name().get()]; | |
| 1207 | #ifdef _MSC_VER | ||
| 1208 | if (!_isnan(windowU)) { | ||
| 1209 | #else | ||
| 1210 | ✗ | if (!std::isnan(windowU)) { | |
| 1211 | #endif | ||
| 1212 | ✗ | window_U_area[i] += ss.surface().get().netArea(); | |
| 1213 | ✗ | window_U_sum[i] += windowU * ss.surface().get().netArea(); | |
| 1214 | ✗ | window_SHGC_sum[i] += windowSHGC * ss.surface().get().netArea(); | |
| 1215 | } | ||
| 1216 | } | ||
| 1217 | // get just the window area; | ||
| 1218 | ✗ | window_areas[i] += s.grossArea() - s.netArea(); | |
| 1219 | |||
| 1220 | // add in lines to compute SCF, and SDF in each direction; | ||
| 1221 | ✗ | } | |
| 1222 | } | ||
| 1223 | ✗ | } | |
| 1224 | |||
| 1225 | // Get the area weighted average of wall absorption, emissivity, U and window U and SHGC; | ||
| 1226 | // If areas are zero then all values are set to zero | ||
| 1227 | ✗ | for (int i = 0; i <= 7; ++i) { | |
| 1228 | ✗ | if (wall_areas[i] > 0.0) { | |
| 1229 | ✗ | wall_solar_absorption[i] = wall_abs_sum[i] / wall_areas[i]; | |
| 1230 | ✗ | wall_thermal_emissivity[i] = wall_emiss_sum[i] / wall_areas[i]; | |
| 1231 | |||
| 1232 | } else { | ||
| 1233 | ✗ | wall_solar_absorption[i] = 0; | |
| 1234 | ✗ | wall_thermal_emissivity[i] = 0; | |
| 1235 | } | ||
| 1236 | ✗ | if (wall_U_area[i] > 0.0) { // if any wall surfaces have a U value defined, use the weighted average of U values | |
| 1237 | ✗ | wall_U[i] = wall_U_sum[i] / wall_U_area[i]; | |
| 1238 | } else { | ||
| 1239 | ✗ | wall_U[i] = 0; | |
| 1240 | } | ||
| 1241 | ✗ | if (window_areas[i] > 0.0) { | |
| 1242 | ✗ | window_U[i] = window_U_sum[i] / window_areas[i]; | |
| 1243 | ✗ | window_SHGC[i] = window_SHGC_sum[i] / window_areas[i]; | |
| 1244 | } else { | ||
| 1245 | ✗ | window_U[i] = 0; | |
| 1246 | ✗ | window_SHGC[i] = 0; | |
| 1247 | ✗ | window_SCF[i] = 0; | |
| 1248 | |||
| 1249 | /// \todo window_SDF seems to always be 0 | ||
| 1250 | ✗ | window_SDF[i] = 0; | |
| 1251 | } | ||
| 1252 | } | ||
| 1253 | |||
| 1254 | ✗ | double total_wall_area = 0.0; | |
| 1255 | ✗ | for (double a : wall_areas) { | |
| 1256 | ✗ | total_wall_area += a; | |
| 1257 | } | ||
| 1258 | |||
| 1259 | ✗ | double total_window_area = 0.0; | |
| 1260 | ✗ | for (double a : window_areas) { | |
| 1261 | ✗ | total_window_area += a; | |
| 1262 | } | ||
| 1263 | |||
| 1264 | ✗ | LOG(Debug, "Total Wall Area = " << total_wall_area << " m2"); | |
| 1265 | ✗ | LOG(Debug, "Total Window Area = " << total_window_area << " m2"); | |
| 1266 | |||
| 1267 | // set the loop sums to 0 before the loop | ||
| 1268 | ✗ | double roof_area = 0.0; | |
| 1269 | ✗ | double skylight_area = 0.0; | |
| 1270 | |||
| 1271 | ✗ | double roof_abs_sum = 0.0; | |
| 1272 | ✗ | double roof_emiss_sum = 0.0; | |
| 1273 | ✗ | double roof_U_sum = 0.0; | |
| 1274 | ✗ | double roof_HC_sum = 0.0; | |
| 1275 | ✗ | double skylight_U_sum = 0.0; | |
| 1276 | ✗ | double skylight_SHGC_sum = 0.0; | |
| 1277 | ✗ | int roof_count = 0; | |
| 1278 | |||
| 1279 | // the building.roofs() variable does !seem to return the roof surfaces in a vector as it supposed to; | ||
| 1280 | // so we search through all surfaces and find the outside roof surfaces ourselves; | ||
| 1281 | // calculate area and average solar absorption and thermal emissivity; | ||
| 1282 | ✗ | for (const openstudio::model::Surface& s : surfaces) { | |
| 1283 | // skip surface if !labeled roof; | ||
| 1284 | ✗ | if (s.surfaceType() != "RoofCeiling") { | |
| 1285 | ✗ | continue; | |
| 1286 | } | ||
| 1287 | // skip surface if !outside; | ||
| 1288 | ✗ | if (s.outsideBoundaryCondition() != "Outdoors") { | |
| 1289 | ✗ | continue; | |
| 1290 | } | ||
| 1291 | ✗ | roof_count += 1; | |
| 1292 | ✗ | double absorption = const_solarAbsorptance[s.construction().get().name().get()]; | |
| 1293 | ✗ | double emissivity = const_thermalAbsorptance[s.construction().get().name().get()]; | |
| 1294 | ✗ | double heatcapacity = const_heatCapacity[s.construction().get().name().get()]; | |
| 1295 | ✗ | double roofU = const_U[s.construction().get().name().get()]; | |
| 1296 | |||
| 1297 | ✗ | roof_abs_sum += absorption * s.netArea(); | |
| 1298 | ✗ | roof_emiss_sum += emissivity * s.netArea(); | |
| 1299 | ✗ | roof_HC_sum += heatcapacity * s.netArea(); | |
| 1300 | ✗ | roof_U_sum += roofU * s.netArea(); | |
| 1301 | |||
| 1302 | // get the roof area without skylights; | ||
| 1303 | ✗ | roof_area += s.netArea(); | |
| 1304 | // get the skylight area; | ||
| 1305 | ✗ | skylight_area += s.grossArea() - s.netArea(); | |
| 1306 | |||
| 1307 | ✗ | std::vector<openstudio::model::SubSurface> subsurface = s.subSurfaces(); | |
| 1308 | ✗ | for (const openstudio::model::SubSurface& ss : subsurface) { | |
| 1309 | ✗ | skylight_U_sum += const_U[ss.construction().get().name().get()] * ss.surface().get().netArea(); | |
| 1310 | ✗ | skylight_SHGC_sum += const_SHGC[ss.construction().get().name().get()] * ss.surface().get().netArea(); | |
| 1311 | } | ||
| 1312 | ✗ | } | |
| 1313 | ✗ | LOG(Debug, "Found " << roof_count << " roof surfaces"); | |
| 1314 | |||
| 1315 | ✗ | double roof_solar_absorption = 0; | |
| 1316 | ✗ | double roof_thermal_emissivity = 0; | |
| 1317 | ✗ | double roof_U = 0; | |
| 1318 | |||
| 1319 | ✗ | if (roof_area > 0.0) { | |
| 1320 | // compute roof absorption as area weighted average; | ||
| 1321 | ✗ | roof_solar_absorption = roof_abs_sum / roof_area; | |
| 1322 | // compute roof emissivity as an area weighted average; | ||
| 1323 | ✗ | roof_thermal_emissivity = roof_emiss_sum / roof_area; | |
| 1324 | // compute roof U as area weighted average; | ||
| 1325 | ✗ | roof_U = roof_U_sum / roof_area; | |
| 1326 | } else { | ||
| 1327 | ✗ | roof_solar_absorption = 0; | |
| 1328 | ✗ | roof_thermal_emissivity = 0; | |
| 1329 | ✗ | roof_U = 0; | |
| 1330 | } | ||
| 1331 | |||
| 1332 | ✗ | double skylight_U = 0; | |
| 1333 | ✗ | double skylight_SHGC = 0; | |
| 1334 | |||
| 1335 | ✗ | if (skylight_area > 0.0) { | |
| 1336 | ✗ | skylight_U = skylight_U_sum / skylight_area; | |
| 1337 | ✗ | skylight_SHGC = skylight_SHGC_sum / skylight_area; | |
| 1338 | } else { | ||
| 1339 | ✗ | skylight_U = 0; | |
| 1340 | ✗ | skylight_SHGC = 0; | |
| 1341 | } | ||
| 1342 | |||
| 1343 | ✗ | for (int i = 0; i <= 7; ++i) { | |
| 1344 | ✗ | LOG(Debug, "Wall" << direction_names[i] << ": Area=" << wall_areas[i] << " m2, U=" << wall_U[i] | |
| 1345 | << " W/m2/K, Absorption=" << wall_solar_absorption[i] << ", Emissivity=" << wall_thermal_emissivity[i]); | ||
| 1346 | } | ||
| 1347 | ✗ | for (int i = 0; i <= 7; ++i) { | |
| 1348 | ✗ | LOG(Debug, "Window" << direction_names[i] << ": Area=" << window_areas[i] << " m2, U=" << window_U[i] << " W/m2/K, SHGC=" << window_SHGC[i] | |
| 1349 | << ", SCF=" << window_SCF[i] << ", SDF=" << window_SDF[i]); | ||
| 1350 | } | ||
| 1351 | |||
| 1352 | ✗ | LOG(Debug, "Roof: Area=" << roof_area << " m2, U=" << roof_U << " W/m2/K, Absorption=" << roof_solar_absorption | |
| 1353 | << ", Emissivity=" << roof_thermal_emissivity); | ||
| 1354 | ✗ | LOG(Debug, "Skylight: Area=" << skylight_area << " m2, U=" << skylight_U << " W/m2/K, SHGC=" << skylight_SHGC); | |
| 1355 | |||
| 1356 | // compute exterior heat capacity; | ||
| 1357 | ✗ | double exterior_heat_capacity = (roof_HC_sum + wall_HC_sum + window_HC_sum) / (total_wall_area + roof_area + total_window_area); | |
| 1358 | ✗ | LOG(Debug, "Exterior Heat Capacity = " << exterior_heat_capacity << " J/K/m2 based on surface area"); | |
| 1359 | |||
| 1360 | // add up the heat capacity of the defined interior surfaces including any internal mass elements; | ||
| 1361 | // compute as normalized to floor area and !surface area; | ||
| 1362 | ✗ | double interior_HC_sum = 0.0; | |
| 1363 | ✗ | for (const openstudio::model::Surface& s : surfaces) { | |
| 1364 | // skip surface if outside; | ||
| 1365 | ✗ | if (s.outsideBoundaryCondition() == "Outdoors") { | |
| 1366 | ✗ | continue; | |
| 1367 | } | ||
| 1368 | ✗ | interior_HC_sum += const_heatCapacity[s.construction().get().name().get()] * s.netArea(); | |
| 1369 | } | ||
| 1370 | |||
| 1371 | // get and add in the heat capacity of any defined internal masses; | ||
| 1372 | ✗ | double internal_mass_HC_sum = 0.0; | |
| 1373 | ✗ | for (const openstudio::model::InternalMassDefinition& mass : internal_masses) { | |
| 1374 | ✗ | internal_mass_HC_sum += mass.surfaceArea().get() * const_heatCapacity[mass.construction().get().name().get()]; | |
| 1375 | } | ||
| 1376 | ✗ | double interior_heat_capacity = (interior_HC_sum + internal_mass_HC_sum) / building.floorArea(); | |
| 1377 | ✗ | LOG(Debug, "Interior Heat Capacity = " << interior_heat_capacity << " J/K/m2 based on floor area"); | |
| 1378 | |||
| 1379 | ✗ | LOG(Debug, "...Calculating() Infiltration"); | |
| 1380 | ✗ | LOG(Debug, "*****************************"); | |
| 1381 | ✗ | LOG(Debug, " Calculating Infiltration"); | |
| 1382 | ✗ | LOG(Debug, "*****************************"); | |
| 1383 | |||
| 1384 | ✗ | double infiltration_rate = 0; | |
| 1385 | |||
| 1386 | // compute infiltration; | ||
| 1387 | |||
| 1388 | ✗ | if (OSM_extract_infil_rate) { | |
| 1389 | //first check to see if there effective leakage areas defined and if !those, then design flow rates; | ||
| 1390 | ✗ | if (!model.getConcreteModelObjects<openstudio::model::SpaceInfiltrationEffectiveLeakageArea>().empty()) { | |
| 1391 | //std::vector<openstudio::model::SpaceInfiltrationEffectiveLeakageArea> infiltration = model.getConcreteModelObjects<openstudio::model::SpaceInfiltrationEffectiveLeakageArea>(); | ||
| 1392 | |||
| 1393 | /// \todo no reason for this to be in a loop | ||
| 1394 | // for (const openstudio::model::SpaceInfiltrationEffectiveLeakageArea &infil : infiltration) { | ||
| 1395 | // set default average envelope air leakage (infiltration) as 7 m3/h/m2 which is about the EnergyPlus defaults; | ||
| 1396 | ✗ | LOG(Debug, "EffectiveLeakageArea !Implemented Yet, Infiltration Rate Set to 7.0 m3/m2/h @ 75 Pa"); | |
| 1397 | ✗ | infiltration_rate = infil_rate_default; | |
| 1398 | // } | ||
| 1399 | |||
| 1400 | ✗ | } else if (!model.getConcreteModelObjects<openstudio::model::SpaceInfiltrationDesignFlowRate>().empty()) { | |
| 1401 | std::vector<openstudio::model::SpaceInfiltrationDesignFlowRate> infiltration = | ||
| 1402 | ✗ | model.getConcreteModelObjects<openstudio::model::SpaceInfiltrationDesignFlowRate>(); | |
| 1403 | ✗ | LOG(Debug, "Found " << infiltration.size() << " SpaceInfiltrationDesignFlowRate objects"); | |
| 1404 | |||
| 1405 | /// \todo this is not used | ||
| 1406 | //double infil_frac_sum = 0.0; | ||
| 1407 | ✗ | double infil_rate_sum = 0.0; | |
| 1408 | ✗ | int count = 0; | |
| 1409 | ✗ | for (const openstudio::model::SpaceInfiltrationDesignFlowRate& infil : infiltration) { | |
| 1410 | ✗ | count += 1; | |
| 1411 | ✗ | std::string rate_type = infil.designFlowRateCalculationMethod(); | |
| 1412 | ✗ | double infil_rate_temp = 0; | |
| 1413 | |||
| 1414 | ✗ | if (infil.space()) { | |
| 1415 | ✗ | LOG(Debug, "Space defined for Infiltration object #" << count); | |
| 1416 | ✗ | if (rate_type == "Flow/Space") { | |
| 1417 | // add in the design flow rate per space * number of spaces; | ||
| 1418 | ✗ | infil_rate_temp = infil.designFlowRate().get(); | |
| 1419 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is Flow/Space, " << infil_rate_temp << " m3/s added"); | |
| 1420 | ✗ | } else if (rate_type == "Flow/ExteriorArea" || rate_type == "Flow/ExteriorWallArea") { | |
| 1421 | // add in the flow/exterior area * the exterior area; | ||
| 1422 | ✗ | infil_rate_temp = infil.flowperExteriorSurfaceArea().get() * infil.space()->exteriorArea(); | |
| 1423 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is Flow/ExteriorArea, " << infil_rate_temp << " m3/s added"); | |
| 1424 | ✗ | } else if (rate_type == "Flow/Area") { | |
| 1425 | ✗ | infil_rate_temp = infil.flowperSpaceFloorArea().get() * infil.space()->floorArea(); | |
| 1426 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is Flow/Area, " << infil_rate_temp << " m3/s added"); | |
| 1427 | ✗ | } else if (rate_type == "AirChanges/Hour") { | |
| 1428 | ✗ | infil_rate_temp = 0; | |
| 1429 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is Flow/Space, Not implemented yet so nothing added"); | |
| 1430 | } else { | ||
| 1431 | ✗ | infil_rate_temp = 0; | |
| 1432 | ✗ | LOG(Debug, "Infiltration Ojbect #" << count << " has no calc method defined, so nothing added"); | |
| 1433 | } | ||
| 1434 | ✗ | } else if (infil.spaceType()) { | |
| 1435 | ✗ | LOG(Debug, "No space defined in Infiltration object #" << count << ", using spacetype object instead"); | |
| 1436 | ✗ | openstudio::model::SpaceType st = infil.spaceType().get(); | |
| 1437 | ✗ | double st_volume = 0.0; | |
| 1438 | ✗ | double st_exterior_area = 0.0; | |
| 1439 | /// \todo this is not used | ||
| 1440 | //int st_num = st.spaces().size(); | ||
| 1441 | ✗ | for (const openstudio::model::Space& s : st.spaces()) { | |
| 1442 | ✗ | st_volume += s.volume(); | |
| 1443 | ✗ | st_exterior_area += s.exteriorArea(); | |
| 1444 | ✗ | } | |
| 1445 | ✗ | LOG(Debug, "Found " << st.spaces().size() << " spaces in spacetype for Infiltration object " << count); | |
| 1446 | ✗ | LOG(Debug, "Infiltration design flow rate found of type " << rate_type); | |
| 1447 | |||
| 1448 | ✗ | if (rate_type == "Flow/Space") { | |
| 1449 | // add in the design flow rate per space * number of spaces; | ||
| 1450 | ✗ | infil_rate_temp = infil.designFlowRate().get() * st.spaces().size(); | |
| 1451 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is Flow/Space, " << infil_rate_temp << " m3/s added"); | |
| 1452 | ✗ | } else if (rate_type == "Flow/ExteriorArea" || rate_type == "Flow/ExteriorWallArea") { | |
| 1453 | // add in the flow/exterior area * the exterior area; | ||
| 1454 | ✗ | infil_rate_temp = infil.flowperExteriorSurfaceArea().get() * st_exterior_area; | |
| 1455 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is Flow/ExteriorArea, " << infil_rate_temp << " m3/s added"); | |
| 1456 | ✗ | } else if (rate_type == "Flow/Area") { | |
| 1457 | // add in the flow/floor area * floor area; | ||
| 1458 | ✗ | infil_rate_temp = infil.flowperSpaceFloorArea().get() * st.floorArea(); | |
| 1459 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is Flow/Area, " << infil_rate_temp << " m3/s added"); | |
| 1460 | ✗ | } else if (rate_type == "AirChanges/Hour") { | |
| 1461 | ✗ | infil_rate_temp = infil.flowperSpaceFloorArea().get() * st.floorArea(); | |
| 1462 | ✗ | LOG(Debug, "Infiltration Object #" << count << " is AirChanges/Hour, " << infil_rate_temp << " m3/s added"); | |
| 1463 | } else { | ||
| 1464 | ✗ | infil_rate_temp = infil.airChangesperHour().get() * st_volume; | |
| 1465 | ✗ | LOG(Debug, "Infiltration Ojbect #" << count << " has no calc method defined, so nothing added"); | |
| 1466 | } | ||
| 1467 | ✗ | } else { | |
| 1468 | ✗ | LOG(Debug, "No space or spacetype defined for Infiltration object #" << count << ", skipping analysis"); | |
| 1469 | } | ||
| 1470 | |||
| 1471 | ✗ | double infil_frac = 0; | |
| 1472 | |||
| 1473 | // now look for the schedule for the infil object and add up the fraction; | ||
| 1474 | ✗ | if (infil.schedule()) { | |
| 1475 | ✗ | std::string sched = infil.schedule().get().name().get(); | |
| 1476 | // if a schedule exists, get the average yearly fraction by a time weighted average of occupied and unoccupied averages; | ||
| 1477 | ✗ | infil_frac = occ_aves[sched] * frac_year_occ + unocc_aves[sched] * frac_year_unocc; | |
| 1478 | ✗ | LOG(Debug, "Infiltration schedule found for Infiltration object #" << count << ", scaling by " << infil_frac); | |
| 1479 | ✗ | } else { | |
| 1480 | ✗ | LOG(Debug, "No Infiltration schedule found for Infiltration object #" << count << ", assuming always on"); | |
| 1481 | ✗ | infil_frac = 1.0; | |
| 1482 | } | ||
| 1483 | ✗ | infil_rate_sum += infil_rate_temp * infil_frac; | |
| 1484 | ✗ | } | |
| 1485 | ✗ | LOG(Debug, "Total Infiltration = " << infil_rate_sum << " m3/s at 4 Pa (natural pressure difference)"); | |
| 1486 | |||
| 1487 | // get avg infiltration rate and convert to from m3/m2/min @ 4 Pa to m3/m2/h @ 75 Pa with a .67 pressure exponent; | ||
| 1488 | // assume constant infilration rate is based on a nominal 4 Pa pressure difference; | ||
| 1489 | ✗ | infiltration_rate = infil_rate_sum / (total_wall_area + roof_area) * 3600 * ::pow((75 / 4), 0.67); | |
| 1490 | ✗ | } else { | |
| 1491 | ✗ | LOG(Debug, "No Infiltration Design Flow Rates Found"); | |
| 1492 | ✗ | infiltration_rate = infil_rate_default; | |
| 1493 | } | ||
| 1494 | } else { | ||
| 1495 | ✗ | LOG(Debug, "No Infiltration Extraction from OSM File"); | |
| 1496 | ✗ | infiltration_rate = infil_rate_default; | |
| 1497 | } | ||
| 1498 | |||
| 1499 | ✗ | LOG(Debug, "Infiltration rate set to " << infiltration_rate << " m3/h/m2 @ 75 Pa"); | |
| 1500 | |||
| 1501 | ✗ | LOG(Debug, "...Parsing() HVAC Info"); | |
| 1502 | ✗ | LOG(Debug, "*****************************"); | |
| 1503 | ✗ | LOG(Debug, " Parsing HVAC Info"); | |
| 1504 | ✗ | LOG(Debug, "*****************************"); | |
| 1505 | |||
| 1506 | ✗ | LOG(Debug, "*****************************"); | |
| 1507 | ✗ | LOG(Debug, " Analyzing HVAC"); | |
| 1508 | ✗ | LOG(Debug, "*****************************"); | |
| 1509 | ✗ | LOG(Debug, "...Analyzing() HVAC"); | |
| 1510 | |||
| 1511 | ✗ | double cooling_COP = 0; | |
| 1512 | ✗ | double heating_system_efficiency = 0; | |
| 1513 | ✗ | int heating_fuel_type = 0; | |
| 1514 | |||
| 1515 | ✗ | size_t num_ideal_air_loads = 0; | |
| 1516 | ✗ | for (const openstudio::model::ThermalZone& z : thermal_zones) { | |
| 1517 | ✗ | if (z.useIdealAirLoads()) ++num_ideal_air_loads; | |
| 1518 | } | ||
| 1519 | |||
| 1520 | ✗ | bool uses_ideal_air_loads = false; | |
| 1521 | |||
| 1522 | ✗ | if (num_ideal_air_loads > 0 && num_ideal_air_loads != thermal_zones.size()) { | |
| 1523 | ✗ | throw std::runtime_error("cannot translate model, only some zones use ideal air loads"); | |
| 1524 | ✗ | } else if (num_ideal_air_loads == thermal_zones.size()) { | |
| 1525 | ✗ | uses_ideal_air_loads = true; | |
| 1526 | } | ||
| 1527 | |||
| 1528 | ✗ | if (OSM_extract_HVAC && !uses_ideal_air_loads) { | |
| 1529 | ✗ | std::vector<openstudio::model::ModelObject> hvac_component_array; | |
| 1530 | ✗ | std::vector<double> hvac_component_area_array; | |
| 1531 | |||
| 1532 | ✗ | std::vector<openstudio::model::PlantLoop> plant_loops_array; | |
| 1533 | ✗ | std::vector<double> plant_loops_area_array; | |
| 1534 | |||
| 1535 | // look through the air loops and extract the components; | ||
| 1536 | // for components that can connect to a plant water loop (namely things with water heating and cooling coils); | ||
| 1537 | ✗ | for (openstudio::model::AirLoopHVAC& air_loop : air_loops) { | |
| 1538 | ✗ | std::vector<openstudio::model::ModelObject> supply_components = air_loop.supplyComponents(); | |
| 1539 | |||
| 1540 | ✗ | double zone_area = 0.0; | |
| 1541 | // get the total area of all the zones connected through the loop; | ||
| 1542 | ✗ | for (const openstudio::model::ThermalZone& z : air_loop.thermalZones()) { | |
| 1543 | ✗ | zone_area += z.floorArea(); | |
| 1544 | ✗ | } | |
| 1545 | |||
| 1546 | // loop through the components and store them all in a single array; | ||
| 1547 | // if; | ||
| 1548 | ✗ | for (const openstudio::model::ModelObject& component : supply_components) { | |
| 1549 | // skip if the component is a node; | ||
| 1550 | ✗ | if (component.optionalCast<openstudio::model::Node>()) continue; | |
| 1551 | // skip of component is a mixer connector; | ||
| 1552 | ✗ | if (component.optionalCast<openstudio::model::ConnectorMixer>()) continue; | |
| 1553 | // skip if component is a splitter; | ||
| 1554 | ✗ | if (component.optionalCast<openstudio::model::ConnectorSplitter>()) continue; | |
| 1555 | // skip if component is a pipe; | ||
| 1556 | ✗ | if (component.optionalCast<openstudio::model::PipeAdiabatic>()) continue; | |
| 1557 | |||
| 1558 | // if the component is a water cooling coil, do !save, but instead save the attached plant loop; | ||
| 1559 | ✗ | if ((component | |
| 1560 | ✗ | .optionalCast<openstudio::model::CoilCoolingWater>())) { // if the component is a cooling coil, don't save the attached plant loop; | |
| 1561 | ✗ | plant_loops_array.push_back(component.optionalCast<openstudio::model::CoilCoolingWater>().get().plantLoop().get()); | |
| 1562 | ✗ | plant_loops_area_array.push_back(zone_area); | |
| 1563 | // if the component is a water cooling coil, do !save but instead save the attached plant loop; | ||
| 1564 | ✗ | } else if (component.optionalCast<openstudio::model::CoilHeatingWater>()) { | |
| 1565 | // if the component is a heating coil, don't save and search the attached plant loop; | ||
| 1566 | //std::vector<openstudio::model::ModelObject> plant_loop_components = component.optionalCast<openstudio::model::CoilHeatingWater>().get().plantLoop().get().supplyComponents(); | ||
| 1567 | // get the cooling coil plant loop; | ||
| 1568 | ✗ | plant_loops_array.push_back(component.optionalCast<openstudio::model::CoilHeatingWater>().get().plantLoop().get()); | |
| 1569 | ✗ | plant_loops_area_array.push_back(zone_area); | |
| 1570 | } else { | ||
| 1571 | // otherwise this component is !hooked to a water loop so save it for later parsing; | ||
| 1572 | ✗ | hvac_component_array.push_back(component); | |
| 1573 | ✗ | hvac_component_area_array.push_back(zone_area); | |
| 1574 | } | ||
| 1575 | } | ||
| 1576 | ✗ | } | |
| 1577 | |||
| 1578 | ✗ | for (size_t i = 0; i < plant_loops_array.size(); ++i) { | |
| 1579 | ✗ | std::vector<openstudio::model::ModelObject> supply_components = plant_loops_array[i].supplyComponents(); | |
| 1580 | ✗ | double zone_area = plant_loops_area_array[i]; | |
| 1581 | |||
| 1582 | ✗ | for (const openstudio::model::ModelObject& component : supply_components) { | |
| 1583 | // skip if the component is a node; | ||
| 1584 | ✗ | if (component.optionalCast<openstudio::model::Node>()) continue; | |
| 1585 | // skip of component is a mixer connector; | ||
| 1586 | ✗ | if (component.optionalCast<openstudio::model::ConnectorMixer>()) continue; | |
| 1587 | // skip if component is a splitter; | ||
| 1588 | ✗ | if (component.optionalCast<openstudio::model::ConnectorSplitter>()) continue; | |
| 1589 | // skip if component is a pipe; | ||
| 1590 | ✗ | if (component.optionalCast<openstudio::model::PipeAdiabatic>()) continue; | |
| 1591 | |||
| 1592 | ✗ | hvac_component_array.push_back(component); | |
| 1593 | ✗ | hvac_component_area_array.push_back(zone_area); | |
| 1594 | } | ||
| 1595 | ✗ | } | |
| 1596 | |||
| 1597 | // now add in any HVAC components !part of an air loop (PTAC, PTHP, unit heaters, etc); | ||
| 1598 | ✗ | for (openstudio::model::ThermalZone& zone : thermal_zones) { | |
| 1599 | ✗ | for (const openstudio::model::ModelObject& component : zone.equipment()) { | |
| 1600 | ✗ | hvac_component_array.push_back(component); | |
| 1601 | ✗ | hvac_component_area_array.push_back(zone.floorArea()); | |
| 1602 | ✗ | } | |
| 1603 | } | ||
| 1604 | |||
| 1605 | ✗ | std::vector<openstudio::model::HVACComponent> cooling_coil_array; | |
| 1606 | ✗ | std::vector<double> cooling_coil_area_array; | |
| 1607 | ✗ | std::vector<openstudio::model::HVACComponent> heating_coil_array; | |
| 1608 | ✗ | std::vector<double> heating_coil_area_array; | |
| 1609 | ✗ | for (size_t i = 0; i < hvac_component_array.size(); ++i) { | |
| 1610 | ✗ | openstudio::model::ModelObject component = hvac_component_array[i]; | |
| 1611 | ✗ | double area = hvac_component_area_array[i]; | |
| 1612 | |||
| 1613 | // first check for PTAC; | ||
| 1614 | ✗ | if (component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalAirConditioner>()) { | |
| 1615 | openstudio::model::ZoneHVACPackagedTerminalAirConditioner ptac = | ||
| 1616 | ✗ | component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalAirConditioner>().get(); | |
| 1617 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalAirConditioner>().get().coolingCoil()); | |
| 1618 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1619 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalAirConditioner>().get().heatingCoil()); | |
| 1620 | ✗ | heating_coil_area_array.push_back(area); | |
| 1621 | // next check for PTHP; | ||
| 1622 | ✗ | } else if (component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalHeatPump>()) { | |
| 1623 | openstudio::model::ZoneHVACPackagedTerminalHeatPump pthp = | ||
| 1624 | ✗ | component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalHeatPump>().get(); | |
| 1625 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalHeatPump>().get().coolingCoil()); | |
| 1626 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1627 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::ZoneHVACPackagedTerminalHeatPump>().get().heatingCoil()); | |
| 1628 | ✗ | heating_coil_area_array.push_back(area); | |
| 1629 | // next check for water to air heat pump; | ||
| 1630 | ✗ | } else if (component.optionalCast<openstudio::model::ZoneHVACWaterToAirHeatPump>()) { | |
| 1631 | ✗ | openstudio::model::ZoneHVACWaterToAirHeatPump wahp = component.optionalCast<openstudio::model::ZoneHVACWaterToAirHeatPump>().get(); | |
| 1632 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::ZoneHVACWaterToAirHeatPump>().get().coolingCoil()); | |
| 1633 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1634 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::ZoneHVACWaterToAirHeatPump>().get().heatingCoil()); | |
| 1635 | ✗ | heating_coil_area_array.push_back(area); | |
| 1636 | // next check for a component Heater; | ||
| 1637 | ✗ | } else if (component.optionalCast<openstudio::model::ZoneHVACUnitHeater>()) { | |
| 1638 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::ZoneHVACUnitHeater>().get().heatingCoil()); | |
| 1639 | ✗ | heating_coil_area_array.push_back(area); | |
| 1640 | //check for unitary air-to-air heat pump; | ||
| 1641 | ✗ | } else if (component.optionalCast<openstudio::model::AirLoopHVACUnitaryHeatPumpAirToAir>()) { | |
| 1642 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::AirLoopHVACUnitaryHeatPumpAirToAir>().get().coolingCoil()); | |
| 1643 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1644 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::AirLoopHVACUnitaryHeatPumpAirToAir>().get().heatingCoil()); | |
| 1645 | ✗ | heating_coil_area_array.push_back(area); | |
| 1646 | // next check for the cooling and heating coils themselves and save them to the lists; | ||
| 1647 | ✗ | } else if (component.optionalCast<openstudio::model::CoilCoolingDXSingleSpeed>()) { | |
| 1648 | // check for single speed DX coil; | ||
| 1649 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1650 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1651 | ✗ | } else if (component.optionalCast<openstudio::model::CoilCoolingDXTwoSpeed>()) { | |
| 1652 | // check for a two speed DX coil; | ||
| 1653 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1654 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1655 | ✗ | } else if (component.optionalCast<openstudio::model::CoilCoolingWater>()) { | |
| 1656 | // check for plain cooling water coil; | ||
| 1657 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1658 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1659 | ✗ | } else if (component.optionalCast<openstudio::model::ChillerElectricEIR>()) { | |
| 1660 | // check for electric chiller; | ||
| 1661 | ✗ | cooling_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1662 | ✗ | cooling_coil_area_array.push_back(area); | |
| 1663 | ✗ | } else if (component.optionalCast<openstudio::model::CoilHeatingWater>()) { | |
| 1664 | // check for plain heating water coil; | ||
| 1665 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1666 | ✗ | heating_coil_area_array.push_back(area); | |
| 1667 | ✗ | } else if (component.optionalCast<openstudio::model::CoilHeatingElectric>()) { | |
| 1668 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1669 | ✗ | heating_coil_area_array.push_back(area); | |
| 1670 | ✗ | } else if (component.optionalCast<openstudio::model::CoilHeatingGas>()) { | |
| 1671 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1672 | ✗ | heating_coil_area_array.push_back(area); | |
| 1673 | ✗ | } else if (component.optionalCast<openstudio::model::BoilerHotWater>()) { | |
| 1674 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1675 | ✗ | heating_coil_area_array.push_back(area); | |
| 1676 | ✗ | } else if (component.optionalCast<openstudio::model::BoilerSteam>()) { | |
| 1677 | ✗ | heating_coil_array.push_back(component.optionalCast<openstudio::model::HVACComponent>().get()); | |
| 1678 | ✗ | heating_coil_area_array.push_back(area); | |
| 1679 | } | ||
| 1680 | ✗ | } | |
| 1681 | |||
| 1682 | ✗ | LOG(Debug, "Found " << cooling_coil_array.size() << " cooling elements"); | |
| 1683 | ✗ | LOG(Debug, "Found " << heating_coil_array.size() << " heating elements"); | |
| 1684 | |||
| 1685 | // go through the cooling coil array list and add up the COP*zone area and zone area to compute zonearea weighted COP; | ||
| 1686 | ✗ | double cop_sum = 0.0; | |
| 1687 | ✗ | double cop_area_sum = 0.0; | |
| 1688 | |||
| 1689 | ✗ | for (size_t i = 0; i < cooling_coil_array.size(); ++i) { | |
| 1690 | ✗ | openstudio::model::HVACComponent coil = cooling_coil_array[i]; | |
| 1691 | ✗ | double area = cooling_coil_area_array[i]; | |
| 1692 | ✗ | if (coil.optionalCast<openstudio::model::CoilCoolingDXSingleSpeed>()) { | |
| 1693 | // check for single speed DX coil; | ||
| 1694 | ✗ | cop_sum += coil.optionalCast<openstudio::model::CoilCoolingDXSingleSpeed>().get().ratedCOP() * area; | |
| 1695 | ✗ | cop_area_sum += area; | |
| 1696 | ✗ | } else if (coil.optionalCast<openstudio::model::CoilCoolingDXTwoSpeed>()) { | |
| 1697 | // check for two speed DX coil; | ||
| 1698 | ✗ | cop_sum += coil.optionalCast<openstudio::model::CoilCoolingDXTwoSpeed>().get().ratedHighSpeedCOP() * area; | |
| 1699 | ✗ | cop_area_sum += area; | |
| 1700 | ✗ | } else if (coil.optionalCast<openstudio::model::AirLoopHVACUnitaryHeatPumpAirToAir>()) { | |
| 1701 | // check for heat pump; | ||
| 1702 | ✗ | cop_sum += coil.optionalCast<openstudio::model::AirLoopHVACUnitaryHeatPumpAirToAir>() | |
| 1703 | ✗ | .get() | |
| 1704 | ✗ | .coolingCoil() | |
| 1705 | ✗ | .optionalCast<openstudio::model::CoilCoolingDXSingleSpeed>() | |
| 1706 | ✗ | .get() | |
| 1707 | ✗ | .ratedCOP() | |
| 1708 | ✗ | * area; | |
| 1709 | ✗ | cop_area_sum += area; | |
| 1710 | ✗ | } else if (coil.optionalCast<openstudio::model::ChillerElectricEIR>()) { | |
| 1711 | ✗ | cop_sum += coil.optionalCast<openstudio::model::ChillerElectricEIR>().get().referenceCOP() * area; | |
| 1712 | |||
| 1713 | ✗ | cop_area_sum += area; | |
| 1714 | } | ||
| 1715 | ✗ | } | |
| 1716 | |||
| 1717 | // if the COP sum is 0 but the cooling coil array is non-zero, check the plant loop for a chiller; | ||
| 1718 | ✗ | if ((cop_sum == 0.0) && (cooling_coil_array.size() > 0)) { | |
| 1719 | ✗ | LOG(Debug, "checking plant loop for chiller"); | |
| 1720 | |||
| 1721 | ✗ | for (openstudio::model::PlantLoop& plant_loop : plant_loops) { | |
| 1722 | ✗ | std::vector<openstudio::model::ModelObject> supply_components = plant_loop.supplyComponents(); | |
| 1723 | // loop through the components and get the efficiency; | ||
| 1724 | ✗ | double area = building.floorArea(); | |
| 1725 | ✗ | for (const openstudio::model::ModelObject& component : supply_components) { | |
| 1726 | // if we are here then we don't have a specific area assigned to the cooling unit so use the full building floor area; | ||
| 1727 | ✗ | if (component.optionalCast<openstudio::model::CoilCoolingDXSingleSpeed>()) { | |
| 1728 | // check for single speed DX coil; | ||
| 1729 | ✗ | cop_sum += component.optionalCast<openstudio::model::CoilCoolingDXSingleSpeed>().get().ratedCOP(); | |
| 1730 | ✗ | cop_area_sum += building.floorArea(); | |
| 1731 | ✗ | } else if (component.optionalCast<openstudio::model::CoilCoolingDXTwoSpeed>()) { | |
| 1732 | // check for two speed DX coil; | ||
| 1733 | ✗ | cop_sum += component.optionalCast<openstudio::model::CoilCoolingDXTwoSpeed>().get().ratedHighSpeedCOP(); | |
| 1734 | ✗ | cop_area_sum += area; | |
| 1735 | ✗ | } else if (component.optionalCast<openstudio::model::ChillerElectricEIR>()) { | |
| 1736 | // check for a chiller; | ||
| 1737 | /// \todo coil must be wrong here, there's no coil in scope, changing to component | ||
| 1738 | ✗ | cop_sum += component.optionalCast<openstudio::model::ChillerElectricEIR>().get().referenceCOP() * area; | |
| 1739 | ✗ | cop_area_sum += area; | |
| 1740 | } | ||
| 1741 | } | ||
| 1742 | ✗ | } | |
| 1743 | } | ||
| 1744 | |||
| 1745 | ✗ | if (cop_area_sum > 0.0) { | |
| 1746 | ✗ | cooling_COP = cop_sum / cop_area_sum; | |
| 1747 | ✗ | LOG(Debug, "Area Weighted Average Cooling COP = " << cooling_COP); | |
| 1748 | } else { | ||
| 1749 | ✗ | cooling_COP = 1E+12; // set cooling COP to huge number so cooling energy is zero if cooling was found | |
| 1750 | ✗ | LOG(Debug, "No Cooling Equipment Found, set COP = " << cooling_COP); | |
| 1751 | } | ||
| 1752 | |||
| 1753 | // go through the heating coil array list and add up the COP*zone area for gas and electic heating coils; | ||
| 1754 | ✗ | double elec_sum = 0.0; | |
| 1755 | ✗ | double elec_area_sum = 0.0; | |
| 1756 | ✗ | double gas_sum = 0.0; | |
| 1757 | ✗ | double gas_area_sum = 0.0; | |
| 1758 | |||
| 1759 | ✗ | for (size_t i = 0; i < heating_coil_array.size(); ++i) { | |
| 1760 | ✗ | openstudio::model::HVACComponent coil = heating_coil_array[i]; | |
| 1761 | ✗ | double area = heating_coil_area_array[i]; | |
| 1762 | |||
| 1763 | // check for gas heating coil; | ||
| 1764 | ✗ | if (coil.optionalCast<openstudio::model::CoilHeatingGas>()) { | |
| 1765 | ✗ | gas_sum += coil.optionalCast<openstudio::model::CoilHeatingGas>().get().gasBurnerEfficiency() * area; | |
| 1766 | ✗ | gas_area_sum += area; | |
| 1767 | // check for electric heating coil; | ||
| 1768 | ✗ | } else if (coil.optionalCast<openstudio::model::CoilHeatingElectric>()) { | |
| 1769 | ✗ | elec_sum += coil.optionalCast<openstudio::model::CoilHeatingElectric>().get().efficiency() * area; | |
| 1770 | ✗ | elec_area_sum += area; | |
| 1771 | // check for single speed DX heating coil; | ||
| 1772 | ✗ | } else if (coil.optionalCast<openstudio::model::CoilHeatingDXSingleSpeed>()) { | |
| 1773 | ✗ | elec_sum += coil.optionalCast<openstudio::model::CoilHeatingDXSingleSpeed>().get().ratedCOP() * area; | |
| 1774 | ✗ | elec_area_sum += area; | |
| 1775 | // check for unitary heat pump, extract coil and get; | ||
| 1776 | ✗ | } else if (coil.optionalCast<openstudio::model::AirLoopHVACUnitaryHeatPumpAirToAir>()) { | |
| 1777 | ✗ | elec_sum += coil.optionalCast<openstudio::model::AirLoopHVACUnitaryHeatPumpAirToAir>() | |
| 1778 | ✗ | .get() | |
| 1779 | ✗ | .heatingCoil() | |
| 1780 | ✗ | .optionalCast<openstudio::model::CoilHeatingDXSingleSpeed>() | |
| 1781 | ✗ | .get() | |
| 1782 | ✗ | .ratedCOP() | |
| 1783 | ✗ | * area; | |
| 1784 | ✗ | elec_area_sum += area; | |
| 1785 | ✗ | } else if (coil.optionalCast<openstudio::model::BoilerHotWater>()) { | |
| 1786 | ✗ | openstudio::model::BoilerHotWater boiler = coil.optionalCast<openstudio::model::BoilerHotWater>().get(); | |
| 1787 | ✗ | if (boiler.fuelType() == "NaturalGas") { | |
| 1788 | ✗ | gas_sum += boiler.nominalThermalEfficiency() * area; | |
| 1789 | ✗ | gas_area_sum += area; | |
| 1790 | } else { | ||
| 1791 | ✗ | elec_sum += boiler.nominalThermalEfficiency() * area; | |
| 1792 | ✗ | elec_area_sum += area; | |
| 1793 | } | ||
| 1794 | ✗ | } | |
| 1795 | // else if (!coil) | ||
| 1796 | ✗ | } | |
| 1797 | |||
| 1798 | // if there seems to be no heating energy used but there are heating elements detected, check the plant loop for a boiler; | ||
| 1799 | ✗ | if (((gas_sum + elec_sum) == 0.0) && (heating_coil_array.size() > 0)) { | |
| 1800 | ✗ | for (openstudio::model::PlantLoop& plant_loop : plant_loops) { | |
| 1801 | ✗ | std::vector<openstudio::model::ModelObject> supply_components = plant_loop.supplyComponents(); | |
| 1802 | // loop through the components and get the efficiency; | ||
| 1803 | ✗ | double area = building.floorArea(); | |
| 1804 | ✗ | for (const openstudio::model::ModelObject& component : supply_components) { | |
| 1805 | // check for a hot water boiler; | ||
| 1806 | ✗ | if (component.optionalCast<openstudio::model::BoilerHotWater>()) { | |
| 1807 | ✗ | openstudio::model::BoilerHotWater boiler = component.optionalCast<openstudio::model::BoilerHotWater>().get(); | |
| 1808 | ✗ | if (boiler.fuelType() == "NaturalGas") { | |
| 1809 | ✗ | gas_sum += boiler.nominalThermalEfficiency() * area; | |
| 1810 | ✗ | gas_area_sum += area; | |
| 1811 | } else { | ||
| 1812 | ✗ | elec_sum += boiler.nominalThermalEfficiency() * area; | |
| 1813 | ✗ | elec_area_sum += area; | |
| 1814 | } | ||
| 1815 | ✗ | } | |
| 1816 | } | ||
| 1817 | ✗ | } | |
| 1818 | } | ||
| 1819 | |||
| 1820 | ✗ | if (gas_sum > elec_sum) { | |
| 1821 | ✗ | heating_fuel_type = 2; | |
| 1822 | // set heating fuel type to gas if heating_gas_area is larger than electric area; | ||
| 1823 | ✗ | LOG(Debug, "Fuel Type Determined to be Mostly or All Gas, HVAC Fuel Type = 2"); | |
| 1824 | } else { | ||
| 1825 | ✗ | LOG(Debug, "Fuel Type Determined to be Mostly or All Electric, HVAC Fuel Type = 1"); | |
| 1826 | ✗ | heating_fuel_type = 1; | |
| 1827 | } | ||
| 1828 | |||
| 1829 | ✗ | if ((gas_sum + elec_sum) > 0.0) { | |
| 1830 | ✗ | heating_system_efficiency = (elec_sum + gas_sum) / (elec_area_sum + gas_area_sum); | |
| 1831 | ✗ | LOG(Debug, "Average Heating Efficiency = " << heating_system_efficiency); | |
| 1832 | } else { | ||
| 1833 | ✗ | LOG(Debug, "No heating elements found - using HVAC defaults"); | |
| 1834 | ✗ | heating_system_efficiency = heating_system_efficiency_default; | |
| 1835 | ✗ | heating_fuel_type = heating_fuel_type_default; | |
| 1836 | } | ||
| 1837 | ✗ | } else if (uses_ideal_air_loads) { | |
| 1838 | ✗ | LOG(Warn, "Using ideal airloads, which should use district heating and cooling, but we don't have that option yet"); | |
| 1839 | ✗ | cooling_COP = 1.0; | |
| 1840 | ✗ | heating_system_efficiency = 1.0; | |
| 1841 | ✗ | heating_fuel_type = 2; // gas | |
| 1842 | // hvac_type = 0; // perfect efficiencies | ||
| 1843 | } else { | ||
| 1844 | ✗ | cooling_COP = cooling_COP_default; | |
| 1845 | ✗ | heating_system_efficiency = heating_system_efficiency_default; | |
| 1846 | ✗ | heating_fuel_type = heating_fuel_type_default; | |
| 1847 | } | ||
| 1848 | |||
| 1849 | // set up the HVAC loss tables; | ||
| 1850 | // hvac type 0 1 2 3 4 5 6 7 8 9; | ||
| 1851 | // 10 11 12 13 14 15 16 17 18 19; | ||
| 1852 | // 20 21 22 23 24 25 26 27 28 29; | ||
| 1853 | // 30 31 32 33 34 35 36 37 38 39; | ||
| 1854 | ✗ | double hvac_waste_table[] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.03, 0.00, 0.00, 0.04, 0.00, 0.03, 0.00, 0.00, 0.08, 0.03, 0.00, 0.00, 0.03, 0.00, | |
| 1855 | 0.00, 0.04, 0.00, 0.03, 0.00, 0.00, 0.04, 0.00, 0.00, 0.08, 0.04, 0.00, 0.00, 0.04, 0.00, 0.04, 0.00, 0.00}; | ||
| 1856 | |||
| 1857 | ✗ | double hvac_hot_table[] = {0.00, 0.08, 0.25, 0.00, 0.36, 0.08, 0.08, 0.25, 0.00, 0.36, 0.08, 0.08, 0.25, 0.00, 0.08, 0.08, 0.25, 0.08, 0.08, | |
| 1858 | 0.25, 0.00, 0.36, 0.08, 0.08, 0.25, 0.08, 0.00, 0.00, 0.00, 0.08, 0.00, 0.00, 0.08, 0.00, 0.08, 0.00, 0.00}; | ||
| 1859 | |||
| 1860 | ✗ | double hvac_cold_table[] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.01, 0.00, 0.00, 0.00, 0.00, 0.01, 0.00, 0.00, 0.01, 0.01, 0.00, 0.00, 0.01, 0.00, | |
| 1861 | 0.00, 0.00, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.00, 0.01, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00}; | ||
| 1862 | |||
| 1863 | //extract losses from loss tables based on hvac type; | ||
| 1864 | ✗ | double hvac_waste_factor = hvac_waste_table[hvac_type]; | |
| 1865 | ✗ | double hvac_heating_loss_factor = hvac_hot_table[hvac_type]; | |
| 1866 | ✗ | double hvac_cooling_loss_factor = hvac_cold_table[hvac_type]; | |
| 1867 | |||
| 1868 | ✗ | LOG(Debug, "#HVAC type was " << hvac_type); | |
| 1869 | ✗ | LOG(Debug, "HVAC Waste Factor = " << hvac_waste_factor); | |
| 1870 | ✗ | LOG(Debug, "HVAC Heating Loss Factor = " << hvac_heating_loss_factor); | |
| 1871 | ✗ | LOG(Debug, "HVAC Cooling Loss Factor = " << hvac_cooling_loss_factor); | |
| 1872 | |||
| 1873 | // print out efficiencies; | ||
| 1874 | ✗ | LOG(Debug, "Cooling System COP = " << cooling_COP); | |
| 1875 | ✗ | LOG(Debug, "Cooling System IPLV/COP Ratio =" << cooling_IPLVToCop_ratio); | |
| 1876 | // heating energy, 1=electric, 0=gas); | ||
| 1877 | ✗ | LOG(Debug, "Heating Fuel Type = " << heating_fuel_type); | |
| 1878 | ✗ | LOG(Debug, "Heating System Efficiency = " << heating_system_efficiency); | |
| 1879 | |||
| 1880 | // calculate fresh air ventilation rates; | ||
| 1881 | ✗ | double freshair_flow_rate = 0.0; | |
| 1882 | ✗ | if (OSM_extract_vent_rate) { | |
| 1883 | ✗ | for (const openstudio::model::Space& s : spaces) { | |
| 1884 | ✗ | double space_air_rate = 0; | |
| 1885 | ✗ | if (s.designSpecificationOutdoorAir()) { | |
| 1886 | ✗ | openstudio::model::DesignSpecificationOutdoorAir outdoor_air = s.designSpecificationOutdoorAir().get(); | |
| 1887 | |||
| 1888 | // these methods will return 0.0 if nothing is defined; | ||
| 1889 | // get ACH and convert to L/s; | ||
| 1890 | ✗ | double air_ach = outdoor_air.outdoorAirFlowAirChangesperHour() * s.volume() / 3.6; | |
| 1891 | // get air flow rate in L/s; | ||
| 1892 | ✗ | double air_rate = outdoor_air.outdoorAirFlowRate() * 1000; | |
| 1893 | // get in m3/s/person and convert to L/s; | ||
| 1894 | ✗ | double air_per_person = outdoor_air.outdoorAirFlowperPerson() * s.numberOfPeople() * 1000; | |
| 1895 | // get in m3/s/m2 and convert to L/s; | ||
| 1896 | ✗ | double air_per_area = outdoor_air.outdoorAirFlowperFloorArea() * s.floorArea() * 1000; | |
| 1897 | |||
| 1898 | ✗ | double sched_mult = 0; | |
| 1899 | ✗ | if (outdoor_air.outdoorAirFlowRateFractionSchedule()) { | |
| 1900 | ✗ | std::string sched = outdoor_air.outdoorAirFlowRateFractionSchedule().get().name().get(); | |
| 1901 | ✗ | sched_mult = occ_aves[sched] * frac_year_occ + unocc_aves[sched] * frac_year_unocc; | |
| 1902 | ✗ | } else { | |
| 1903 | // if no schedule is defined set multiplier to 1.0; | ||
| 1904 | ✗ | sched_mult = 1.0; | |
| 1905 | } | ||
| 1906 | |||
| 1907 | ✗ | if (outdoor_air.outdoorAirMethod() == "Maximum") { | |
| 1908 | ✗ | std::vector<double> vals; | |
| 1909 | ✗ | vals.push_back(air_per_person); | |
| 1910 | ✗ | vals.push_back(air_per_area); | |
| 1911 | ✗ | vals.push_back(air_rate); | |
| 1912 | ✗ | vals.push_back(air_ach); | |
| 1913 | ✗ | space_air_rate = (*std::max_element(vals.begin(), vals.end())) * s.multiplier() * sched_mult; | |
| 1914 | ✗ | } else { | |
| 1915 | // if maximum is !selected, assume sum is selected; | ||
| 1916 | ✗ | space_air_rate = (air_per_person + air_per_area + air_rate + air_ach) * s.multiplier() * sched_mult; | |
| 1917 | } | ||
| 1918 | |||
| 1919 | ✗ | } else { | |
| 1920 | // if no outdoor air rate is defined for space, default to 20 cfm/nominal person and convert to L/S from cfm; | ||
| 1921 | ✗ | LOG(Debug, " No outdoor air rate define for space " << s.name() << " , default of 20cm/nominal person used"); | |
| 1922 | ✗ | space_air_rate = 20 * s.numberOfPeople() / 2.12; | |
| 1923 | } | ||
| 1924 | |||
| 1925 | ✗ | freshair_flow_rate += space_air_rate; | |
| 1926 | } | ||
| 1927 | } else { | ||
| 1928 | ✗ | freshair_flow_rate = number_of_people * vent_rate_per_person_default; | |
| 1929 | } | ||
| 1930 | |||
| 1931 | ✗ | double supply_exhaust_rate = freshair_flow_rate; | |
| 1932 | // set exhaust = supply rate as default (i.e(). no pressurization); | ||
| 1933 | ✗ | LOG(Debug, "Total ventilation fresh air flow rate = " << freshair_flow_rate << "L/s"); | |
| 1934 | ✗ | LOG(Debug, "No exhaust rate extraction - set air exhaust rate to ventilation rate"); | |
| 1935 | |||
| 1936 | ✗ | double dhw_system_efficiency = 0; | |
| 1937 | ✗ | double dhw_demand = 0.0; | |
| 1938 | ✗ | int dhw_fuel_type = 0; | |
| 1939 | |||
| 1940 | ✗ | if (OSM_extract_dhw) { | |
| 1941 | // Try to find DHW water components and get the water use; | ||
| 1942 | |||
| 1943 | // search plant loops for water heaters; | ||
| 1944 | ✗ | std::vector<double> dhw_gas_array; | |
| 1945 | ✗ | std::vector<double> dhw_elec_array; | |
| 1946 | ✗ | for (openstudio::model::PlantLoop& plant_loop : plant_loops) { | |
| 1947 | ✗ | std::vector<openstudio::model::ModelObject> supply_components = plant_loop.supplyComponents(); | |
| 1948 | // loop through the components and find the components that are water heaters; | ||
| 1949 | ✗ | for (const openstudio::model::ModelObject& component : supply_components) { | |
| 1950 | // enter here if the item is a water heater; | ||
| 1951 | ✗ | if (component.optionalCast<openstudio::model::WaterHeaterMixed>()) { | |
| 1952 | // convert component to water heater type; | ||
| 1953 | ✗ | openstudio::model::WaterHeaterMixed heater = component.optionalCast<openstudio::model::WaterHeaterMixed>().get(); | |
| 1954 | // check to see if the heater is gas or electric; | ||
| 1955 | ✗ | if (heater.heaterFuelType() == "NaturalGas") { | |
| 1956 | // store the efficiency; | ||
| 1957 | ✗ | dhw_gas_array.push_back(heater.heaterThermalEfficiency().get()); | |
| 1958 | } else { | ||
| 1959 | // store the efficiency; | ||
| 1960 | ✗ | dhw_elec_array.push_back(heater.heaterThermalEfficiency().get()); | |
| 1961 | } | ||
| 1962 | ✗ | } | |
| 1963 | } | ||
| 1964 | ✗ | } | |
| 1965 | |||
| 1966 | // add up all the uses from the individual components; | ||
| 1967 | ✗ | double dhw_gas_sum = 0.0; | |
| 1968 | ✗ | for (double gas : dhw_gas_array) { | |
| 1969 | ✗ | dhw_gas_sum += gas; | |
| 1970 | } | ||
| 1971 | ✗ | double dhw_elec_sum = 0.0; | |
| 1972 | ✗ | for (double elec : dhw_elec_array) { | |
| 1973 | ✗ | dhw_elec_sum += elec; | |
| 1974 | } | ||
| 1975 | |||
| 1976 | // find the average efficiency of water heaters; | ||
| 1977 | ✗ | size_t n_dhw_units = dhw_gas_array.size() + dhw_elec_array.size(); | |
| 1978 | |||
| 1979 | // if the number of water heaters is > 0; | ||
| 1980 | ✗ | if (n_dhw_units > 0) { | |
| 1981 | ✗ | dhw_system_efficiency = (dhw_gas_sum + dhw_elec_sum) / (dhw_gas_array.size() + dhw_elec_array.size()); | |
| 1982 | } else { | ||
| 1983 | ✗ | dhw_system_efficiency = 1.0; | |
| 1984 | } | ||
| 1985 | |||
| 1986 | // if there are more gas DHW water heaters, fuel type is gas; | ||
| 1987 | ✗ | if (dhw_gas_sum > dhw_elec_sum) { | |
| 1988 | ✗ | dhw_fuel_type = 2; | |
| 1989 | } else { | ||
| 1990 | ✗ | dhw_fuel_type = 1; | |
| 1991 | } | ||
| 1992 | |||
| 1993 | // extract the water usage by starting with the water use connections and then finding equipment; | ||
| 1994 | ✗ | std::vector<openstudio::model::WaterUseConnections> water_connects = model.getConcreteModelObjects<openstudio::model::WaterUseConnections>(); | |
| 1995 | ✗ | for (const openstudio::model::WaterUseConnections& connect : water_connects) { | |
| 1996 | ✗ | std::vector<openstudio::model::WaterUseEquipment> equipments = connect.waterUseEquipment(); | |
| 1997 | ✗ | for (const openstudio::model::WaterUseEquipment& equip : equipments) { | |
| 1998 | ✗ | std::string frac_sched; | |
| 1999 | double mult; | ||
| 2000 | ✗ | if (equip.flowRateFractionSchedule()) { | |
| 2001 | // get multiplier by doing a weighted average of occupied and unoccupied times; | ||
| 2002 | ✗ | std::string frac_sched = equip.flowRateFractionSchedule().get().name().get(); | |
| 2003 | ✗ | mult = (occ_aves[frac_sched] * frac_year_occ) + (unocc_aves[frac_sched] * frac_year_unocc); | |
| 2004 | ✗ | } else { | |
| 2005 | ✗ | mult = 1.0; | |
| 2006 | } | ||
| 2007 | // get peak value and convert from m3/s to m3/yr; | ||
| 2008 | ✗ | double peak = equip.waterUseEquipmentDefinition().peakFlowRate() * 3600 * 8760; | |
| 2009 | ✗ | LOG(Debug, "DHW: " << frac_sched << ", peak use = " << peak << " m3/yr, mult = " << mult); | |
| 2010 | ✗ | dhw_demand += peak * mult; | |
| 2011 | ✗ | } | |
| 2012 | ✗ | } | |
| 2013 | |||
| 2014 | ✗ | if ((dhw_gas_sum + dhw_elec_sum) == 0.0) { | |
| 2015 | // if the gas + electric sum = 0 then there were no DHW heaters, so set demand to 0 no matter what; | ||
| 2016 | ✗ | dhw_demand = 0.0; | |
| 2017 | } | ||
| 2018 | ✗ | } else { | |
| 2019 | ✗ | dhw_fuel_type = dhw_fuel_type_default; | |
| 2020 | ✗ | dhw_system_efficiency = dhw_system_efficiency_default; | |
| 2021 | // demand is # of people * # days * dhw rate/person/day in L/person/day /1000 to get m3/year | ||
| 2022 | ✗ | dhw_demand = number_of_people * dhw_rate_per_person_default * number_days_occupied_per_year / 1000; | |
| 2023 | } | ||
| 2024 | |||
| 2025 | // use DHW distribution type to set DHW distribution efficiency; | ||
| 2026 | // create lookup table; | ||
| 2027 | ✗ | double dhw_dist_eff_table[] = {1.0, 0.8, 0.6}; | |
| 2028 | ✗ | double dhw_distribution_efficiency = dhw_dist_eff_table[dhw_dist_type]; | |
| 2029 | |||
| 2030 | // print out the DHW fuel type, system efficiency, distribution efficiency; | ||
| 2031 | ✗ | LOG(Debug, "DHW: Fuel Type = " << dhw_fuel_type << ", System Efficiency = " << dhw_system_efficiency | |
| 2032 | << " Distribution Efficiency = " << dhw_distribution_efficiency << ", Demand = " << dhw_demand << " m3/yr"); | ||
| 2033 | |||
| 2034 | // create output file and start writing out; | ||
| 2035 | |||
| 2036 | // get the current system clock time; | ||
| 2037 | ✗ | openstudio::Time time; | |
| 2038 | // File.open(osm2iso_output_file, 'w') do |file|; | ||
| 2039 | |||
| 2040 | // file.LOG(Debug, "#" << osm2iso_output_file << " generated by osm2iso.rb() on " << input_file << " on " << time.ctime()); | ||
| 2041 | |||
| 2042 | ✗ | openstudio::isomodel::UserModel userModel = openstudio::isomodel::UserModel(); | |
| 2043 | |||
| 2044 | //userModel.setWeatherFilePath(weather_file_path); | ||
| 2045 | |||
| 2046 | // file.LOG(Debug, "# Terrain class urban/city = 0.8, suburban/some shielding = 0.9, country/open = 1.0"); | ||
| 2047 | ✗ | userModel.setTerrainClass(terrain_class); | |
| 2048 | // file.LOG(Debug, "# building height is in m, floor area is in m^2, people density is m2/person"); | ||
| 2049 | ✗ | userModel.setBuildingHeight(building_height); | |
| 2050 | ✗ | userModel.setFloorArea(floor_area); | |
| 2051 | ✗ | userModel.setPeopleDensityOccupied(area_per_person_occupied); | |
| 2052 | ✗ | userModel.setPeopleDensityUnoccupied(area_per_person_unoccupied); | |
| 2053 | |||
| 2054 | ✗ | userModel.setBuildingOccupancyFrom(occupancy_day_start); | |
| 2055 | ✗ | userModel.setBuildingOccupancyTo(occupancy_day_end); | |
| 2056 | ✗ | userModel.setEquivFullLoadOccupancyFrom(occupancy_hour_start); | |
| 2057 | ✗ | userModel.setEquivFullLoadOccupancyTo(occupancy_hour_end); | |
| 2058 | |||
| 2059 | // file.LOG(Debug, "# LPD, EPD, GPD all in W/m2, ext light power in W, an heat gain is W/person"); | ||
| 2060 | ✗ | userModel.setLightingPowerIntensityOccupied(lpd_occupied); | |
| 2061 | ✗ | userModel.setLightingPowerIntensityUnoccupied(lpd_unoccupied); | |
| 2062 | ✗ | userModel.setElecPowerAppliancesOccupied(epd_occupied); | |
| 2063 | ✗ | userModel.setElecPowerAppliancesUnoccupied(epd_unoccupied); | |
| 2064 | ✗ | userModel.setGasPowerAppliancesOccupied(gpd_occupied); | |
| 2065 | ✗ | userModel.setGasPowerAppliancesUnoccupied(gpd_unoccupied); | |
| 2066 | ✗ | userModel.setExteriorLightingPower(exterior_lighting_power); | |
| 2067 | ✗ | userModel.setHeatGainPerPerson(activity_level_occ); | |
| 2068 | // when we implement occupied and unoccupied heat gain per person, we comment above and uncomment below; | ||
| 2069 | //userModel.setHeatGainPerPersonOccupied(activity_level_occ); | ||
| 2070 | //userModel.setHeatGainPerPersonUnoccupied(activity_level_unocc); | ||
| 2071 | |||
| 2072 | // file.LOG(Debug, "# daylight sensors, occupancy sensors, illum control are set to 1 if there is no control. See iso 15193 Annex F/G for values"); | ||
| 2073 | ✗ | userModel.setDaylightSensorSystem(daylight_sensors); | |
| 2074 | ✗ | userModel.setLightingOccupancySensorSystem(occupancy_sensors); | |
| 2075 | ✗ | userModel.setConstantIlluminationControl(const_illum_ctrl); | |
| 2076 | |||
| 2077 | // file.LOG(Debug, "# Temp set points in degrees C"); | ||
| 2078 | ✗ | userModel.setHeatingOccupiedSetpoint(heating_setpoint_occ); | |
| 2079 | ✗ | userModel.setHeatingUnoccupiedSetpoint(heating_setpoint_unocc); | |
| 2080 | ✗ | userModel.setCoolingOccupiedSetpoint(cooling_setpoint_occ); | |
| 2081 | ✗ | userModel.setCoolingUnoccupiedSetpoint(cooling_setpoint_unocc); | |
| 2082 | |||
| 2083 | // file.puts "\#HVAC type was set to #{hvac_type_default}" | ||
| 2084 | // file.LOG(Debug, "# HVAC waste, heating and cooling loss factors set by HVAC type from EN 15243"); | ||
| 2085 | ✗ | userModel.setHvacWasteFactor(hvac_waste_factor); | |
| 2086 | ✗ | userModel.setHvacHeatingLossFactor(hvac_heating_loss_factor); | |
| 2087 | ✗ | userModel.setHvacCoolingLossFactor(hvac_cooling_loss_factor); | |
| 2088 | |||
| 2089 | // file.LOG(Debug, "# COP is W/W, coolingSystemIPLV is the ratio of IPLV/COP"); | ||
| 2090 | ✗ | userModel.setCoolingSystemCOP(cooling_COP); | |
| 2091 | ✗ | userModel.setCoolingSystemIPLVToCOPRatio(cooling_IPLVToCop_ratio); | |
| 2092 | |||
| 2093 | // file.LOG(Debug, "#energycarrier is 1 if electric, 2 if gas"); | ||
| 2094 | ✗ | userModel.setHeatingEnergyCarrier(heating_fuel_type); | |
| 2095 | // heating energy, 1=electric, 0=gas); | ||
| 2096 | ✗ | userModel.setHeatingSystemEfficiency(heating_system_efficiency); | |
| 2097 | |||
| 2098 | // file.LOG(Debug, "# vent type is 1 if mech, 2 if natural, 3 if mixed"); | ||
| 2099 | ✗ | userModel.setVentilationType(ventilation_type); | |
| 2100 | // file.LOG(Debug, "# ventilation flow rates in L/s"); | ||
| 2101 | ✗ | userModel.setFreshAirFlowRate(freshair_flow_rate); | |
| 2102 | ✗ | userModel.setSupplyExhaustRate(supply_exhaust_rate); | |
| 2103 | |||
| 2104 | // file.LOG(Debug, "# heatRecover = efficiency of heat recovery (0 for none), exhaustAirRecir = fraction of supply air recirculated"); | ||
| 2105 | ✗ | userModel.setHeatRecovery(heat_recovery_fraction); | |
| 2106 | // heat recovery efficiency, 0 for no heat recovery); | ||
| 2107 | ✗ | userModel.setExhaustAirRecirculation(exhaust_recirculation_fraction); | |
| 2108 | // fraction of supply air that is recirculated); | ||
| 2109 | |||
| 2110 | // file.LOG(Debug, "# DHW demand in m3/yr use 10 m3/yr/person as a default for offices"); | ||
| 2111 | ✗ | userModel.setDhwDemand(dhw_demand); | |
| 2112 | //); | ||
| 2113 | // when we implement occupied and unoccupied dhw demand, we comment above and uncomment below; | ||
| 2114 | //userModel.setDhwDemandOccupied(dhw_demand_occ); | ||
| 2115 | //userModel.setDhwDemandUnoccupied(dhw_demand_unocc); | ||
| 2116 | |||
| 2117 | // file.LOG(Debug, "# dhwDistribution efficiency all taps w/i 3m = 1, taps more than 3m = 0.8, circulation or unknown = 0.6, see NEN 2916 12.6, "); | ||
| 2118 | ✗ | userModel.setDhwEfficiency(dhw_system_efficiency); | |
| 2119 | ✗ | userModel.setDhwDistributionEfficiency(dhw_distribution_efficiency); | |
| 2120 | ✗ | userModel.setDhwEnergyCarrier(dhw_fuel_type); | |
| 2121 | |||
| 2122 | // file.LOG(Debug, "# Surface Heat capacity in J/K/m2"); | ||
| 2123 | ✗ | userModel.setInteriorHeatCapacity(interior_heat_capacity); | |
| 2124 | ✗ | userModel.setExteriorHeatCapacity(exterior_heat_capacity); | |
| 2125 | |||
| 2126 | // file.LOG(Debug, "# BEM type 1= none, 2 = simple, 3=advanced with FDD"); | ||
| 2127 | ✗ | userModel.setBemType(bem_type); | |
| 2128 | |||
| 2129 | // file.LOG(Debug, "# specific fan power in L/s/W, flow control factor is energy reduction from fan control measures"); | ||
| 2130 | ✗ | userModel.setSpecificFanPower(specific_fan_power); | |
| 2131 | |||
| 2132 | // file.LOG(Debug, "# fan flow control 1= no control, 0.75 = inlet blade adjuct, 0.65= variable speed see NEN 2916 7.3.3.4 "); | ||
| 2133 | ✗ | userModel.setFanFlowControlFactor(fan_flow_control_factor); | |
| 2134 | |||
| 2135 | // file.LOG(Debug, "# infiltration in m3/m2/hr @ 75 Pa based on surface area"); | ||
| 2136 | ✗ | userModel.setInfiltration(infiltration_rate); | |
| 2137 | // leakage per unit surface area in m^3/m^2/hr); | ||
| 2138 | // when we implement occupied and unoccupied infiltration, we comment above and uncomment below; | ||
| 2139 | //userModel.setInfiltrationOccupied(infiltration_rate_occ); | ||
| 2140 | //userModel.setInfiltrationUnoccupied(infiltration_rate_unocc); | ||
| 2141 | |||
| 2142 | // file.LOG(Debug, "# pump control 0= no pump, 0.5 = auto pump controls for more 50% of pumps, 1.0 = all other cases. See NEN 2914 9.4.3"); | ||
| 2143 | ✗ | userModel.setHeatingPumpControl(heating_pump_control_factor); | |
| 2144 | ✗ | userModel.setCoolingPumpControl(cooling_pump_control_factor); | |
| 2145 | |||
| 2146 | // write out roof and skylight info; | ||
| 2147 | // file.LOG(Debug, "# Areas in m2, U values in W/m2/K"); | ||
| 2148 | // file.LOG(Debug, "# SCF = solar control factor (external control), SDF = shading device factor = internal shading"); | ||
| 2149 | ✗ | userModel.setRoofArea(roof_area); | |
| 2150 | ✗ | userModel.setRoofUValue(roof_U); | |
| 2151 | ✗ | userModel.setRoofSolarAbsorption(roof_solar_absorption); | |
| 2152 | ✗ | userModel.setRoofThermalEmissivity(roof_thermal_emissivity); | |
| 2153 | |||
| 2154 | ✗ | userModel.setSkylightArea(skylight_area); | |
| 2155 | ✗ | userModel.setSkylightUvalue(skylight_U); | |
| 2156 | ✗ | userModel.setSkylightSHGC(skylight_SHGC); | |
| 2157 | |||
| 2158 | //static const std::string direction_names[] = {"N","NE","E","SE","S","SW","W","NW","N"}; | ||
| 2159 | |||
| 2160 | ✗ | userModel.setWallAreaN(wall_areas[0]); | |
| 2161 | ✗ | userModel.setWallUvalueN(wall_U[0]); | |
| 2162 | ✗ | userModel.setWallSolarAbsorptionN(wall_solar_absorption[0]); | |
| 2163 | ✗ | userModel.setWallThermalEmissivityN(wall_thermal_emissivity[0]); | |
| 2164 | ✗ | userModel.setWindowAreaN(window_areas[0]); | |
| 2165 | ✗ | userModel.setWindowUvalueN(window_U[0]); | |
| 2166 | ✗ | userModel.setWindowSHGCN(window_SHGC[0]); | |
| 2167 | ✗ | userModel.setWindowSCFN(window_SDF[0]); | |
| 2168 | ✗ | userModel.setWindowSDFN(window_SDF[0]); | |
| 2169 | |||
| 2170 | ✗ | userModel.setWallAreaNE(wall_areas[1]); | |
| 2171 | ✗ | userModel.setWallUvalueNE(wall_U[1]); | |
| 2172 | ✗ | userModel.setWallSolarAbsorptionNE(wall_solar_absorption[1]); | |
| 2173 | ✗ | userModel.setWallThermalEmissivityNE(wall_thermal_emissivity[1]); | |
| 2174 | ✗ | userModel.setWindowAreaNE(window_areas[1]); | |
| 2175 | ✗ | userModel.setWindowUvalueNE(window_U[1]); | |
| 2176 | ✗ | userModel.setWindowSHGCNE(window_SHGC[1]); | |
| 2177 | ✗ | userModel.setWindowSCFNE(window_SDF[1]); | |
| 2178 | ✗ | userModel.setWindowSDFNE(window_SDF[1]); | |
| 2179 | |||
| 2180 | ✗ | userModel.setWallAreaE(wall_areas[2]); | |
| 2181 | ✗ | userModel.setWallUvalueE(wall_U[2]); | |
| 2182 | ✗ | userModel.setWallSolarAbsorptionE(wall_solar_absorption[2]); | |
| 2183 | ✗ | userModel.setWallThermalEmissivityE(wall_thermal_emissivity[2]); | |
| 2184 | ✗ | userModel.setWindowAreaE(window_areas[2]); | |
| 2185 | ✗ | userModel.setWindowUvalueE(window_U[2]); | |
| 2186 | ✗ | userModel.setWindowSHGCE(window_SHGC[2]); | |
| 2187 | ✗ | userModel.setWindowSCFE(window_SDF[2]); | |
| 2188 | ✗ | userModel.setWindowSDFE(window_SDF[2]); | |
| 2189 | |||
| 2190 | ✗ | userModel.setWallAreaSE(wall_areas[3]); | |
| 2191 | ✗ | userModel.setWallUvalueSE(wall_U[3]); | |
| 2192 | ✗ | userModel.setWallSolarAbsorptionSE(wall_solar_absorption[3]); | |
| 2193 | ✗ | userModel.setWallThermalEmissivitySE(wall_thermal_emissivity[3]); | |
| 2194 | ✗ | userModel.setWindowAreaSE(window_areas[3]); | |
| 2195 | ✗ | userModel.setWindowUvalueSE(window_U[3]); | |
| 2196 | ✗ | userModel.setWindowSHGCSE(window_SHGC[3]); | |
| 2197 | ✗ | userModel.setWindowSCFSE(window_SDF[3]); | |
| 2198 | ✗ | userModel.setWindowSDFSE(window_SDF[3]); | |
| 2199 | |||
| 2200 | ✗ | userModel.setWallAreaS(wall_areas[4]); | |
| 2201 | ✗ | userModel.setWallUvalueS(wall_U[4]); | |
| 2202 | ✗ | userModel.setWallSolarAbsorptionS(wall_solar_absorption[4]); | |
| 2203 | ✗ | userModel.setWallThermalEmissivityS(wall_thermal_emissivity[4]); | |
| 2204 | ✗ | userModel.setWindowAreaS(window_areas[4]); | |
| 2205 | ✗ | userModel.setWindowUvalueS(window_U[4]); | |
| 2206 | ✗ | userModel.setWindowSHGCS(window_SHGC[4]); | |
| 2207 | ✗ | userModel.setWindowSCFS(window_SDF[4]); | |
| 2208 | ✗ | userModel.setWindowSDFS(window_SDF[4]); | |
| 2209 | |||
| 2210 | ✗ | userModel.setWallAreaSW(wall_areas[5]); | |
| 2211 | ✗ | userModel.setWallUvalueSW(wall_U[5]); | |
| 2212 | ✗ | userModel.setWallSolarAbsorptionSW(wall_solar_absorption[5]); | |
| 2213 | ✗ | userModel.setWallThermalEmissivitySW(wall_thermal_emissivity[5]); | |
| 2214 | ✗ | userModel.setWindowAreaSW(window_areas[5]); | |
| 2215 | ✗ | userModel.setWindowUvalueSW(window_U[5]); | |
| 2216 | ✗ | userModel.setWindowSHGCSW(window_SHGC[5]); | |
| 2217 | ✗ | userModel.setWindowSCFSW(window_SDF[5]); | |
| 2218 | ✗ | userModel.setWindowSDFSW(window_SDF[5]); | |
| 2219 | |||
| 2220 | ✗ | userModel.setWallAreaW(wall_areas[6]); | |
| 2221 | ✗ | userModel.setWallUvalueW(wall_U[6]); | |
| 2222 | ✗ | userModel.setWallSolarAbsorptionW(wall_solar_absorption[6]); | |
| 2223 | ✗ | userModel.setWallThermalEmissivityW(wall_thermal_emissivity[6]); | |
| 2224 | ✗ | userModel.setWindowAreaW(window_areas[6]); | |
| 2225 | ✗ | userModel.setWindowUvalueW(window_U[6]); | |
| 2226 | ✗ | userModel.setWindowSHGCW(window_SHGC[6]); | |
| 2227 | ✗ | userModel.setWindowSCFW(window_SDF[6]); | |
| 2228 | ✗ | userModel.setWindowSDFW(window_SDF[6]); | |
| 2229 | |||
| 2230 | ✗ | userModel.setWallAreaNW(wall_areas[7]); | |
| 2231 | ✗ | userModel.setWallUvalueNW(wall_U[7]); | |
| 2232 | ✗ | userModel.setWallSolarAbsorptionNW(wall_solar_absorption[7]); | |
| 2233 | ✗ | userModel.setWallThermalEmissivityNW(wall_thermal_emissivity[7]); | |
| 2234 | ✗ | userModel.setWindowAreaNW(window_areas[7]); | |
| 2235 | ✗ | userModel.setWindowUvalueNW(window_U[7]); | |
| 2236 | ✗ | userModel.setWindowSHGCNW(window_SHGC[7]); | |
| 2237 | ✗ | userModel.setWindowSCFNW(window_SDF[7]); | |
| 2238 | ✗ | userModel.setWindowSDFNW(window_SDF[7]); | |
| 2239 | |||
| 2240 | ✗ | LOG(Debug, "Done Converting!"); | |
| 2241 | ✗ | return userModel; | |
| 2242 | ✗ | } | |
| 2243 | |||
| 2244 | ✗ | std::vector<LogMessage> ForwardTranslator::warnings() const { | |
| 2245 | ✗ | std::vector<LogMessage> result; | |
| 2246 | |||
| 2247 | ✗ | for (const LogMessage& logMessage : m_logSink.logMessages()) { | |
| 2248 | ✗ | if (logMessage.logLevel() == Warn) { | |
| 2249 | ✗ | result.push_back(logMessage); | |
| 2250 | } | ||
| 2251 | ✗ | } | |
| 2252 | |||
| 2253 | ✗ | return result; | |
| 2254 | ✗ | } | |
| 2255 | |||
| 2256 | ✗ | std::vector<LogMessage> ForwardTranslator::errors() const { | |
| 2257 | ✗ | std::vector<LogMessage> result; | |
| 2258 | |||
| 2259 | ✗ | for (const LogMessage& logMessage : m_logSink.logMessages()) { | |
| 2260 | ✗ | if (logMessage.logLevel() > Warn) { | |
| 2261 | ✗ | result.push_back(logMessage); | |
| 2262 | } | ||
| 2263 | ✗ | } | |
| 2264 | |||
| 2265 | ✗ | return result; | |
| 2266 | ✗ | } | |
| 2267 | |||
| 2268 | } // namespace isomodel | ||
| 2269 | // isomodel | ||
| 2270 | } // namespace openstudio | ||
| 2271 | // openstudio | ||
| 2272 |