src/energyplus/ForwardTranslator/ForwardTranslateThermalZone.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 | |||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | |||
| 10 | #include "../../model/ThermalZone.hpp" | ||
| 11 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 12 | #include "../../model/Node.hpp" | ||
| 13 | #include "../../model/Node_Impl.hpp" | ||
| 14 | #include "../../model/PortList.hpp" | ||
| 15 | #include "../../model/PortList_Impl.hpp" | ||
| 16 | #include "../../model/ZoneHVACEquipmentList.hpp" | ||
| 17 | #include "../../model/ZoneHVACEquipmentList_Impl.hpp" | ||
| 18 | #include "../../model/ZoneHVACIdealLoadsAirSystem.hpp" | ||
| 19 | #include "../../model/ZoneHVACIdealLoadsAirSystem_Impl.hpp" | ||
| 20 | #include "../../model/ZoneVentilationDesignFlowRate.hpp" | ||
| 21 | #include "../../model/ZoneVentilationDesignFlowRate_Impl.hpp" | ||
| 22 | #include "../../model/ZoneVentilationWindandStackOpenArea.hpp" | ||
| 23 | #include "../../model/ZoneVentilationWindandStackOpenArea_Impl.hpp" | ||
| 24 | #include "../../model/ZoneMRTCalculation.hpp" | ||
| 25 | #include "../../model/ZoneMRTCalculation_Impl.hpp" | ||
| 26 | #include "../../model/SizingZone.hpp" | ||
| 27 | #include "../../model/SizingZone_Impl.hpp" | ||
| 28 | #include "../../model/Schedule.hpp" | ||
| 29 | #include "../../model/Schedule_Impl.hpp" | ||
| 30 | #include "../../model/ScheduleCompact.hpp" | ||
| 31 | #include "../../model/ScheduleCompact_Impl.hpp" | ||
| 32 | #include "../../model/SetpointManagerMixedAir.hpp" | ||
| 33 | #include "../../model/SetpointManagerSingleZoneReheat.hpp" | ||
| 34 | #include "../../model/AirLoopHVAC.hpp" | ||
| 35 | #include "../../model/AirLoopHVAC_Impl.hpp" | ||
| 36 | #include "../../model/AirLoopHVACReturnPlenum.hpp" | ||
| 37 | #include "../../model/AirLoopHVACReturnPlenum_Impl.hpp" | ||
| 38 | #include "../../model/Thermostat.hpp" | ||
| 39 | #include "../../model/Thermostat_Impl.hpp" | ||
| 40 | #include "../../model/ThermostatSetpointDualSetpoint.hpp" | ||
| 41 | #include "../../model/ThermostatSetpointDualSetpoint_Impl.hpp" | ||
| 42 | #include "../../model/ZoneControlContaminantController.hpp" | ||
| 43 | #include "../../model/ZoneControlHumidistat.hpp" | ||
| 44 | #include "../../model/ZoneControlThermostatStagedDualSetpoint.hpp" | ||
| 45 | #include "../../model/DesignSpecificationOutdoorAir.hpp" | ||
| 46 | #include "../../model/DesignSpecificationOutdoorAir_Impl.hpp" | ||
| 47 | #include "../../model/SizingPeriod.hpp" | ||
| 48 | #include "../../model/SizingPeriod_Impl.hpp" | ||
| 49 | #include "../../model/ModelObject.hpp" | ||
| 50 | #include "../../model/ModelObject_Impl.hpp" | ||
| 51 | |||
| 52 | #include "../../model/Space.hpp" | ||
| 53 | #include "../../model/Space_Impl.hpp" | ||
| 54 | #include "../../model/SpaceType.hpp" | ||
| 55 | #include "../../model/SpaceType_Impl.hpp" | ||
| 56 | #include "../../model/ShadingSurfaceGroup.hpp" | ||
| 57 | #include "../../model/ShadingSurfaceGroup_Impl.hpp" | ||
| 58 | #include "../../model/ShadingSurface.hpp" | ||
| 59 | #include "../../model/ShadingSurface_Impl.hpp" | ||
| 60 | #include "../../model/InteriorPartitionSurfaceGroup.hpp" | ||
| 61 | #include "../../model/InteriorPartitionSurfaceGroup_Impl.hpp" | ||
| 62 | #include "../../model/InteriorPartitionSurface.hpp" | ||
| 63 | #include "../../model/InteriorPartitionSurface_Impl.hpp" | ||
| 64 | #include "../../model/Surface.hpp" | ||
| 65 | #include "../../model/Surface_Impl.hpp" | ||
| 66 | #include "../../model/SubSurface.hpp" | ||
| 67 | #include "../../model/SubSurface_Impl.hpp" | ||
| 68 | #include "../../model/ConstructionBase.hpp" | ||
| 69 | #include "../../model/ConstructionBase_Impl.hpp" | ||
| 70 | #include "../../model/InternalMass.hpp" | ||
| 71 | #include "../../model/InternalMass_Impl.hpp" | ||
| 72 | #include "../../model/InternalMassDefinition.hpp" | ||
| 73 | #include "../../model/InternalMassDefinition_Impl.hpp" | ||
| 74 | #include "../../model/People.hpp" | ||
| 75 | #include "../../model/People_Impl.hpp" | ||
| 76 | #include "../../model/PeopleDefinition.hpp" | ||
| 77 | #include "../../model/PeopleDefinition_Impl.hpp" | ||
| 78 | #include "../../model/Lights.hpp" | ||
| 79 | #include "../../model/Lights_Impl.hpp" | ||
| 80 | #include "../../model/LightsDefinition.hpp" | ||
| 81 | #include "../../model/LightsDefinition_Impl.hpp" | ||
| 82 | #include "../../model/Luminaire.hpp" | ||
| 83 | #include "../../model/Luminaire_Impl.hpp" | ||
| 84 | #include "../../model/LuminaireDefinition.hpp" | ||
| 85 | #include "../../model/LuminaireDefinition_Impl.hpp" | ||
| 86 | #include "../../model/ElectricEquipment.hpp" | ||
| 87 | #include "../../model/ElectricEquipment_Impl.hpp" | ||
| 88 | #include "../../model/ElectricEquipmentDefinition.hpp" | ||
| 89 | #include "../../model/ElectricEquipmentDefinition_Impl.hpp" | ||
| 90 | #include "../../model/ElectricEquipmentITEAirCooled.hpp" | ||
| 91 | #include "../../model/ElectricEquipmentITEAirCooled_Impl.hpp" | ||
| 92 | #include "../../model/ElectricEquipmentITEAirCooledDefinition.hpp" | ||
| 93 | #include "../../model/ElectricEquipmentITEAirCooledDefinition_Impl.hpp" | ||
| 94 | #include "../../model/GasEquipment.hpp" | ||
| 95 | #include "../../model/GasEquipment_Impl.hpp" | ||
| 96 | #include "../../model/GasEquipmentDefinition.hpp" | ||
| 97 | #include "../../model/GasEquipmentDefinition_Impl.hpp" | ||
| 98 | #include "../../model/HotWaterEquipment.hpp" | ||
| 99 | #include "../../model/HotWaterEquipment_Impl.hpp" | ||
| 100 | #include "../../model/SteamEquipment.hpp" | ||
| 101 | #include "../../model/SteamEquipment_Impl.hpp" | ||
| 102 | #include "../../model/OtherEquipment.hpp" | ||
| 103 | #include "../../model/OtherEquipment_Impl.hpp" | ||
| 104 | #include "../../model/DaylightingControl.hpp" | ||
| 105 | #include "../../model/DaylightingControl_Impl.hpp" | ||
| 106 | #include "../../model/IlluminanceMap.hpp" | ||
| 107 | #include "../../model/IlluminanceMap_Impl.hpp" | ||
| 108 | #include "../../model/SpaceInfiltrationDesignFlowRate.hpp" | ||
| 109 | #include "../../model/SpaceInfiltrationDesignFlowRate_Impl.hpp" | ||
| 110 | #include "../../model/SpaceInfiltrationEffectiveLeakageArea.hpp" | ||
| 111 | #include "../../model/SpaceInfiltrationEffectiveLeakageArea_Impl.hpp" | ||
| 112 | #include "../../model/SpaceInfiltrationFlowCoefficient.hpp" | ||
| 113 | #include "../../model/SpaceInfiltrationFlowCoefficient_Impl.hpp" | ||
| 114 | #include "../../model/GlareSensor.hpp" | ||
| 115 | #include "../../model/GlareSensor_Impl.hpp" | ||
| 116 | #include "../../model/LifeCycleCost.hpp" | ||
| 117 | #include "../../model/ZoneMixing.hpp" | ||
| 118 | #include "../../model/ConstructionAirBoundary.hpp" | ||
| 119 | |||
| 120 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 121 | #include "../../utilities/idf/Workspace.hpp" | ||
| 122 | #include "../../utilities/idf/WorkspaceObjectOrder.hpp" | ||
| 123 | #include "../../utilities/core/Logger.hpp" | ||
| 124 | #include "../../utilities/core/Assert.hpp" | ||
| 125 | |||
| 126 | #include <utilities/idd/OS_ThermalZone_FieldEnums.hxx> | ||
| 127 | #include <utilities/idd/Zone_FieldEnums.hxx> | ||
| 128 | #include <utilities/idd/HVACTemplate_Zone_IdealLoadsAirSystem_FieldEnums.hxx> | ||
| 129 | #include <utilities/idd/Daylighting_Controls_FieldEnums.hxx> | ||
| 130 | #include <utilities/idd/Daylighting_ReferencePoint_FieldEnums.hxx> | ||
| 131 | #include <utilities/idd/Output_IlluminanceMap_FieldEnums.hxx> | ||
| 132 | #include <utilities/idd/Schedule_Compact_FieldEnums.hxx> | ||
| 133 | #include <utilities/idd/ZoneHVAC_EquipmentConnections_FieldEnums.hxx> | ||
| 134 | #include <utilities/idd/ZoneControl_Thermostat_FieldEnums.hxx> | ||
| 135 | #include <utilities/idd/ZoneControl_Humidistat_FieldEnums.hxx> | ||
| 136 | #include <utilities/idd/Sizing_Zone_FieldEnums.hxx> | ||
| 137 | #include <utilities/idd/DesignSpecification_OutdoorAir_FieldEnums.hxx> | ||
| 138 | #include <utilities/idd/ZoneVentilation_DesignFlowRate_FieldEnums.hxx> | ||
| 139 | |||
| 140 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 141 | #include <utilities/idd/IddEnums.hxx> | ||
| 142 | #include <utilities/idd/IddFactory.hxx> | ||
| 143 | #include "../../utilities/geometry/Geometry.hpp" | ||
| 144 | |||
| 145 | #include <algorithm> | ||
| 146 | #include <numeric> | ||
| 147 | |||
| 148 | using namespace openstudio::model; | ||
| 149 | |||
| 150 | namespace openstudio { | ||
| 151 | |||
| 152 | namespace energyplus { | ||
| 153 | |||
| 154 | 548 | boost::optional<IdfObject> ForwardTranslator::translateThermalZone(ThermalZone& modelObject) { | |
| 155 | |||
| 156 |
1/1✓ Branch 1 taken 548 times.
|
548 | std::string tzName = modelObject.nameString(); |
| 157 | |||
| 158 |
1/1✓ Branch 1 taken 548 times.
|
548 | std::vector<Space> spaces = modelObject.spaces(); |
| 159 | // INCLUDE SPACE TRANSLATION (new behavior) | ||
| 160 |
2/2✓ Branch 1 taken 112 times.
✓ Branch 2 taken 436 times.
|
548 | if (spaces.empty()) { |
| 161 |
7/7✓ Branch 1 taken 112 times.
✓ Branch 4 taken 112 times.
✓ Branch 7 taken 112 times.
✓ Branch 10 taken 112 times.
✓ Branch 13 taken 112 times.
✓ Branch 16 taken 112 times.
✓ Branch 19 taken 112 times.
|
112 | LOG(Warn, "ThermalZone " << tzName << " does not have any geometry or loads associated with it. It will not be translated"); |
| 162 | 112 | return boost::none; | |
| 163 | } | ||
| 164 | |||
| 165 | // ThermalZone | ||
| 166 | |||
| 167 | // create, register, and name object | ||
| 168 |
2/2✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
|
436 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Zone, modelObject); |
| 169 | |||
| 170 |
2/4✓ Branch 1 taken 436 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 436 times.
|
436 | for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) { |
| 171 | ✗ | translateAndMapModelObject(lifeCycleCost); | |
| 172 | 436 | } | |
| 173 | |||
| 174 |
2/2✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
|
436 | idfObject.setString(openstudio::ZoneFields::Type, ""); |
| 175 | |||
| 176 |
2/2✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
|
436 | idfObject.setInt(openstudio::ZoneFields::Multiplier, modelObject.multiplier()); |
| 177 | |||
| 178 |
3/3✓ Branch 1 taken 436 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 430 times.
|
872 | if (modelObject.ceilingHeight()) { |
| 179 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | idfObject.setDouble(openstudio::ZoneFields::CeilingHeight, modelObject.ceilingHeight().get()); |
| 180 | } | ||
| 181 | |||
| 182 |
3/3✓ Branch 1 taken 436 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 430 times.
|
872 | if (modelObject.volume()) { |
| 183 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | idfObject.setDouble(openstudio::ZoneFields::Volume, modelObject.volume().get()); |
| 184 | } | ||
| 185 | |||
| 186 | // DLM: currently there is no setter for floorArea and the getter does not return the value from this field | ||
| 187 |
2/3✓ Branch 1 taken 436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 436 times.
|
872 | if (modelObject.getDouble(openstudio::OS_ThermalZoneFields::FloorArea)) { |
| 188 | ✗ | idfObject.setDouble(openstudio::ZoneFields::FloorArea, modelObject.getDouble(openstudio::OS_ThermalZoneFields::FloorArea).get()); | |
| 189 | } | ||
| 190 | |||
| 191 |
2/3✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
✗ Branch 5 not taken.
|
872 | if (modelObject.zoneInsideConvectionAlgorithm()) { |
| 192 |
3/3✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
✓ Branch 7 taken 436 times.
|
436 | idfObject.setString(openstudio::ZoneFields::ZoneInsideConvectionAlgorithm, modelObject.zoneInsideConvectionAlgorithm().get()); |
| 193 | } | ||
| 194 | |||
| 195 |
2/3✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
✗ Branch 5 not taken.
|
872 | if (modelObject.zoneOutsideConvectionAlgorithm()) { |
| 196 |
3/3✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
✓ Branch 7 taken 436 times.
|
436 | idfObject.setString(openstudio::ZoneFields::ZoneOutsideConvectionAlgorithm, modelObject.zoneOutsideConvectionAlgorithm().get()); |
| 197 | } | ||
| 198 | |||
| 199 | // Spaces | ||
| 200 | |||
| 201 | // Figure out the x, y, z and whether we write floor area or not | ||
| 202 |
3/3✓ Branch 1 taken 436 times.
✓ Branch 3 taken 73 times.
✓ Branch 4 taken 363 times.
|
436 | if (m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 203 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 73 times.
✗ Branch 4 not taken.
|
73 | OS_ASSERT(spaces.size() == 1); |
| 204 | 73 | auto& space = spaces[0]; | |
| 205 | |||
| 206 |
2/2✓ Branch 2 taken 73 times.
✓ Branch 5 taken 73 times.
|
73 | idfObject.setDouble(openstudio::ZoneFields::DirectionofRelativeNorth, spaces[0].directionofRelativeNorth()); |
| 207 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | idfObject.setDouble(openstudio::ZoneFields::XOrigin, space.xOrigin()); |
| 208 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | idfObject.setDouble(openstudio::ZoneFields::YOrigin, space.yOrigin()); |
| 209 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
73 | idfObject.setDouble(openstudio::ZoneFields::ZOrigin, space.zOrigin()); |
| 210 | |||
| 211 |
2/3✓ Branch 1 taken 73 times.
✓ Branch 3 taken 73 times.
✗ Branch 4 not taken.
|
73 | if (space.partofTotalFloorArea()) { |
| 212 |
2/2✓ Branch 1 taken 73 times.
✓ Branch 4 taken 73 times.
|
146 | idfObject.setString(openstudio::ZoneFields::PartofTotalFloorArea, "Yes"); |
| 213 | } else { | ||
| 214 | ✗ | idfObject.setString(openstudio::ZoneFields::PartofTotalFloorArea, "No"); | |
| 215 | } | ||
| 216 | |||
| 217 | } else { | ||
| 218 | // sort by space name | ||
| 219 |
1/1✓ Branch 3 taken 363 times.
|
363 | std::sort(spaces.begin(), spaces.end(), WorkspaceObjectNameLess()); |
| 220 | 363 | boost::optional<double> directionofRelativeNorth; | |
| 221 |
3/3✓ Branch 2 taken 363 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 323 times.
|
363 | if (!spaces[0].isDirectionofRelativeNorthDefaulted()) { |
| 222 |
2/2✓ Branch 2 taken 40 times.
✓ Branch 5 taken 40 times.
|
40 | directionofRelativeNorth = spaces[0].directionofRelativeNorth(); |
| 223 | } | ||
| 224 |
1/1✓ Branch 2 taken 363 times.
|
363 | double xOrigin = spaces[0].xOrigin(); |
| 225 |
1/1✓ Branch 2 taken 363 times.
|
363 | double yOrigin = spaces[0].yOrigin(); |
| 226 |
1/1✓ Branch 2 taken 363 times.
|
363 | double zOrigin = spaces[0].zOrigin(); |
| 227 | 363 | double totalFloorArea = 0.0; // only area included in total floor area | |
| 228 | 363 | bool needToSetFloorArea = false; | |
| 229 | 363 | bool anyNotPartofTotalFloorArea = false; | |
| 230 |
1/1✓ Branch 2 taken 363 times.
|
363 | bool partofTotalFloorArea = spaces[0].partofTotalFloorArea(); |
| 231 | |||
| 232 |
2/2✓ Branch 5 taken 571 times.
✓ Branch 6 taken 363 times.
|
934 | for (const Space& space : spaces) { |
| 233 | |||
| 234 | // if all spaces have same directionOfRelativeNorth use that, otherwise clear it | ||
| 235 |
3/3✓ Branch 1 taken 571 times.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 501 times.
|
571 | if (!space.isDirectionofRelativeNorthDefaulted()) { |
| 236 |
5/8✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 70 times.
✓ Branch 6 taken 70 times.
✓ Branch 8 taken 70 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 70 times.
|
70 | if (directionofRelativeNorth && (*directionofRelativeNorth == space.directionofRelativeNorth())) { |
| 237 | // no-op | ||
| 238 | } else { | ||
| 239 | ✗ | directionofRelativeNorth.reset(); | |
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | // pick the lower left corner if specified | ||
| 244 |
1/1✓ Branch 1 taken 571 times.
|
571 | xOrigin = std::min(xOrigin, space.xOrigin()); |
| 245 |
1/1✓ Branch 1 taken 571 times.
|
571 | yOrigin = std::min(yOrigin, space.yOrigin()); |
| 246 |
1/1✓ Branch 1 taken 571 times.
|
571 | zOrigin = std::min(zOrigin, space.zOrigin()); |
| 247 | |||
| 248 |
1/1✓ Branch 1 taken 571 times.
|
571 | double floorArea = space.floorArea(); |
| 249 | |||
| 250 | // space floor area is counted if any space is part of floor area | ||
| 251 |
3/3✓ Branch 1 taken 571 times.
✓ Branch 3 taken 556 times.
✓ Branch 4 taken 15 times.
|
571 | if (space.partofTotalFloorArea()) { |
| 252 | 556 | partofTotalFloorArea = true; | |
| 253 | 556 | totalFloorArea += floorArea; | |
| 254 | |||
| 255 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 555 times.
|
556 | if (anyNotPartofTotalFloorArea) { |
| 256 | 1 | needToSetFloorArea = true; | |
| 257 | } | ||
| 258 | |||
| 259 | } else { | ||
| 260 | 15 | anyNotPartofTotalFloorArea = true; | |
| 261 | |||
| 262 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | if (partofTotalFloorArea) { |
| 263 | ✗ | needToSetFloorArea = true; | |
| 264 | } | ||
| 265 | } | ||
| 266 | } // End loop on space | ||
| 267 | |||
| 268 | // set the origin the Thermal Zone (lower-left corner of all spaces) | ||
| 269 |
1/1✓ Branch 1 taken 363 times.
|
363 | idfObject.setDouble(openstudio::ZoneFields::XOrigin, xOrigin); |
| 270 |
1/1✓ Branch 1 taken 363 times.
|
363 | idfObject.setDouble(openstudio::ZoneFields::YOrigin, yOrigin); |
| 271 |
1/1✓ Branch 1 taken 363 times.
|
363 | idfObject.setDouble(openstudio::ZoneFields::ZOrigin, zOrigin); |
| 272 | |||
| 273 | // Important: we need to call Space::changeTransformation to align for the xOrigin, yOrigin, zOrigin (lower left corner) we identified above | ||
| 274 | // Because in E+ all coordinates are still relative to the Zone. The E+ 'Space' object has no specific origin x, y, z coordinates | ||
| 275 |
2/2✓ Branch 1 taken 363 times.
✓ Branch 4 taken 363 times.
|
363 | auto newTranslation = Transformation::translation(Vector3d(xOrigin, yOrigin, zOrigin)); |
| 276 | 363 | double degNorth = 0.0; | |
| 277 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 323 times.
|
363 | if (directionofRelativeNorth) { |
| 278 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
40 | idfObject.setDouble(openstudio::ZoneFields::DirectionofRelativeNorth, directionofRelativeNorth.get()); |
| 279 |
1/1✓ Branch 1 taken 40 times.
|
40 | degNorth = directionofRelativeNorth.get(); |
| 280 | } | ||
| 281 | // rotate negative amount around the z axis, EnergyPlus defines rotation clockwise | ||
| 282 |
3/3✓ Branch 1 taken 363 times.
✓ Branch 4 taken 363 times.
✓ Branch 7 taken 363 times.
|
363 | auto newRotation = Transformation::rotation(Vector3d(0, 0, 1), -openstudio::degToRad(degNorth)); |
| 283 |
1/1✓ Branch 1 taken 363 times.
|
363 | auto newTransformation = newTranslation * newRotation; |
| 284 | // This will also change the transformation for surfaces, daylighting controls, etc | ||
| 285 |
2/2✓ Branch 5 taken 571 times.
✓ Branch 6 taken 363 times.
|
934 | for (auto& space : spaces) { |
| 286 |
1/1✓ Branch 1 taken 571 times.
|
571 | space.changeTransformation(newTransformation); |
| 287 | } | ||
| 288 | |||
| 289 |
2/2✓ Branch 0 taken 350 times.
✓ Branch 1 taken 13 times.
|
363 | if (partofTotalFloorArea) { |
| 290 |
2/2✓ Branch 1 taken 350 times.
✓ Branch 4 taken 350 times.
|
700 | idfObject.setString(openstudio::ZoneFields::PartofTotalFloorArea, "Yes"); |
| 291 | } else { | ||
| 292 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
26 | idfObject.setString(openstudio::ZoneFields::PartofTotalFloorArea, "No"); |
| 293 | } | ||
| 294 | |||
| 295 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 362 times.
|
363 | if (needToSetFloorArea) { |
| 296 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
2 | if (modelObject.getDouble(openstudio::OS_ThermalZoneFields::FloorArea)) { |
| 297 | ✗ | LOG(Info, "ThermalZone " << tzName << " has a user-specified Floor Area, using this number"); | |
| 298 | ✗ | idfObject.setDouble(openstudio::ZoneFields::FloorArea, modelObject.getDouble(openstudio::OS_ThermalZoneFields::FloorArea).get()); | |
| 299 | } else { | ||
| 300 |
9/9✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
|
1 | LOG(Info, "ThermalZone '" << tzName << "' has spaces with mis-matched 'Part of Total Floor Area' flags. " |
| 301 | << "Setting the flag to 'Yes', but hard-coding the total floor area to only take into account the spaces " | ||
| 302 | << "that are part of total Floor Area"); | ||
| 303 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(openstudio::ZoneFields::FloorArea, totalFloorArea); |
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | // TODO: JM 2021-10-15: Aren't we having a lot of problems with DaylightingControls? Yes we are! | ||
| 308 | // Sooooo. Our API prevents us from effectively writing the daylightng objects to a Space because the ThermalZone itself bears the | ||
| 309 | // Primary/Secondary daylighting control + fraction of lights controlled. | ||
| 310 | // E+ will yell if you have space enclosures but the Daylighting objects are on Zone-level (also, it currently does not work, IlluminanceMap | ||
| 311 | // only accepts Zone level, and Daylighting:ReferencePoint should support Space Name but it doesn't) | ||
| 312 | // So here if the zone has daylighting control, we make an airwall between spaces and convert non airwalls to InternalMass | ||
| 313 | |||
| 314 | // another awesome thing is that z.primaryDaylightingControl() || z.secondaryDaylightingControl() || z.illuminanceMap() is probably not safe, since a | ||
| 315 | // DaylightingControl that isn't directly referenced to a zone might be translated too, because DaylightingControl does reference a space itself | ||
| 316 | |||
| 317 |
1/1✓ Branch 3 taken 363 times.
|
363 | int nDayligthingObjects = std::accumulate(spaces.cbegin(), spaces.cend(), 0, [](int sum, const Space& space) { |
| 318 |
2/2✓ Branch 1 taken 571 times.
✓ Branch 5 taken 571 times.
|
571 | return sum + space.daylightingControls().size() + space.illuminanceMaps().size(); |
| 319 | }); | ||
| 320 |
2/2✓ Branch 0 taken 43 times.
✓ Branch 1 taken 320 times.
|
363 | if (nDayligthingObjects > 0) { |
| 321 | |||
| 322 | 43 | boost::optional<InteriorPartitionSurfaceGroup> interiorPartitionSurfaceGroup; | |
| 323 | 43 | std::set<Surface> mergedSurfaces; | |
| 324 | |||
| 325 | 43 | std::vector<Surface> zoneSurfaces; | |
| 326 |
2/2✓ Branch 5 taken 132 times.
✓ Branch 6 taken 43 times.
|
175 | for (const auto& space : spaces) { |
| 327 |
3/3✓ Branch 1 taken 132 times.
✓ Branch 8 taken 750 times.
✓ Branch 9 taken 132 times.
|
882 | for (const auto& surface : space.surfaces()) { |
| 328 |
1/1✓ Branch 1 taken 750 times.
|
750 | zoneSurfaces.emplace_back(surface); |
| 329 | 132 | } | |
| 330 | } | ||
| 331 | |||
| 332 | // sort by surface name, for repeatability | ||
| 333 |
1/1✓ Branch 3 taken 43 times.
|
43 | std::sort(zoneSurfaces.begin(), zoneSurfaces.end(), WorkspaceObjectNameLess()); |
| 334 | |||
| 335 |
2/2✓ Branch 5 taken 750 times.
✓ Branch 6 taken 43 times.
|
793 | for (const auto& surface : zoneSurfaces) { |
| 336 | |||
| 337 | // Already processed? | ||
| 338 |
1/1✓ Branch 1 taken 750 times.
|
750 | auto it = mergedSurfaces.find(surface); |
| 339 |
2/2✓ Branch 2 taken 118 times.
✓ Branch 3 taken 632 times.
|
750 | if (it != mergedSurfaces.end()) { |
| 340 | 748 | continue; | |
| 341 | } | ||
| 342 | |||
| 343 |
1/1✓ Branch 1 taken 632 times.
|
632 | auto adjacentSurface_ = surface.adjacentSurface(); |
| 344 |
2/2✓ Branch 1 taken 495 times.
✓ Branch 2 taken 137 times.
|
632 | if (!adjacentSurface_) { |
| 345 | 495 | continue; | |
| 346 | } | ||
| 347 | |||
| 348 |
2/2✓ Branch 1 taken 137 times.
✓ Branch 4 taken 137 times.
|
137 | auto adjacentSpace_ = adjacentSurface_->space(); |
| 349 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
|
137 | if (!adjacentSpace_) { |
| 350 | ✗ | continue; | |
| 351 | } | ||
| 352 | |||
| 353 | // Adjacent Space must be part of this thermalZone as well | ||
| 354 |
4/4✓ Branch 2 taken 137 times.
✓ Branch 7 taken 137 times.
✓ Branch 10 taken 19 times.
✓ Branch 11 taken 118 times.
|
137 | if (std::find(spaces.cbegin(), spaces.cend(), adjacentSpace_.get()) == spaces.end()) { |
| 355 | 19 | continue; | |
| 356 | } | ||
| 357 | |||
| 358 | // handling both the surface and the adjacentSurface | ||
| 359 |
1/1✓ Branch 1 taken 118 times.
|
118 | mergedSurfaces.insert(surface); |
| 360 |
2/2✓ Branch 1 taken 118 times.
✓ Branch 4 taken 118 times.
|
118 | mergedSurfaces.insert(adjacentSurface_.get()); |
| 361 | |||
| 362 | // don't make interior partitions for interior air walls | ||
| 363 |
1/1✓ Branch 1 taken 118 times.
|
118 | bool isAirWall = surface.isAirWall(); |
| 364 |
2/2✓ Branch 1 taken 118 times.
✓ Branch 4 taken 118 times.
|
118 | bool isAdjacentAirWall = adjacentSurface_->isAirWall(); |
| 365 | |||
| 366 |
3/4✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
|
118 | if (isAirWall && isAdjacentAirWall) { |
| 367 | 116 | continue; | |
| 368 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | } else if (isAirWall) { |
| 369 | ✗ | LOG(Warn, "Interior surface '" << surface.nameString() << "' is an air wall but adjacent surface '" << adjacentSurface_->nameString() | |
| 370 | << "' is not, ignoring internal mass.") | ||
| 371 | ✗ | continue; | |
| 372 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | } else if (isAdjacentAirWall) { |
| 373 | ✗ | LOG(Warn, "Interior surface '" << adjacentSurface_->nameString() << "' is an air wall but adjacent surface '" << surface.nameString() | |
| 374 | << "' is not, ignoring internal mass.") | ||
| 375 | ✗ | continue; | |
| 376 | ✗ | } | |
| 377 | |||
| 378 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
|
2 | if (!interiorPartitionSurfaceGroup) { |
| 379 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | interiorPartitionSurfaceGroup = InteriorPartitionSurfaceGroup(modelObject.model()); |
| 380 | // TODO: I don't think I care about which space I assign it to, since currently that's only written at Zone Level but this might change | ||
| 381 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | interiorPartitionSurfaceGroup->setSpace(adjacentSpace_.get()); |
| 382 | } | ||
| 383 | |||
| 384 | // is there a better way to pick which vertices to keep based on outward normal? | ||
| 385 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | InteriorPartitionSurface interiorPartitionSurface(surface.vertices(), modelObject.model()); |
| 386 |
9/9✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
|
2 | interiorPartitionSurface.setName("Merged " + surface.name().get() + " - " + adjacentSurface_->name().get()); |
| 387 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | interiorPartitionSurface.setInteriorPartitionSurfaceGroup(*interiorPartitionSurfaceGroup); |
| 388 | |||
| 389 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<ConstructionBase> construction = surface.construction(); |
| 390 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (construction) { |
| 391 | ✗ | interiorPartitionSurface.setConstruction(*construction); | |
| 392 | } | ||
| 393 | 767 | } | |
| 394 | |||
| 395 |
2/2✓ Branch 1 taken 30 times.
✓ Branch 2 taken 13 times.
|
43 | if (!mergedSurfaces.empty()) { |
| 396 |
7/7✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✓ Branch 10 taken 30 times.
✓ Branch 14 taken 30 times.
✓ Branch 17 taken 30 times.
✓ Branch 20 taken 30 times.
|
30 | LOG(Warn, modelObject.briefDescription() << " has DaylightingControl Objects assigned. The interior walls between Spaces will be merged. " |
| 397 | "Make sure these are correctly Matched!"); | ||
| 398 | } | ||
| 399 | |||
| 400 |
2/2✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
|
43 | ConstructionAirBoundary airWallConstruction(modelObject.model()); |
| 401 | |||
| 402 | // std::set forces a const iterator, hence why I take a copy... | ||
| 403 |
3/3✓ Branch 4 taken 236 times.
✓ Branch 8 taken 236 times.
✓ Branch 9 taken 43 times.
|
279 | for (Surface mergedSurface : mergedSurfaces) { |
| 404 |
1/1✓ Branch 1 taken 236 times.
|
236 | mergedSurface.setConstruction(airWallConstruction); |
| 405 | 236 | } | |
| 406 | |||
| 407 | 43 | } // End Combine surfaces if daylighting | |
| 408 | 363 | } | |
| 409 | |||
| 410 |
2/2✓ Branch 4 taken 644 times.
✓ Branch 5 taken 436 times.
|
1080 | for (Space& space : spaces) { |
| 411 | |||
| 412 | // translate the space now: it will translate it's geometry children (ShadingSurface/InteriorPartition Groups + Surfaces) | ||
| 413 | // and all SpaceLoad directly associated with the space | ||
| 414 |
1/1✓ Branch 1 taken 644 times.
|
644 | translateAndMapModelObject(space); |
| 415 | |||
| 416 | } // end spaces | ||
| 417 | |||
| 418 | // translate daylighting controls | ||
| 419 | // TODO: move this out somewhere, figure out the right format. | ||
| 420 | // Maybe `translateDaylightingControl(DaylightingControl primaryDaylightingControl, boost::optional<DaylightingControl> secondaryDaylightingControl)` ? | ||
| 421 | 436 | auto translateDaylightingControls = [this, &tzName](model::ThermalZone& thermalZone) { | |
| 422 |
1/1✓ Branch 1 taken 436 times.
|
436 | boost::optional<DaylightingControl> primaryDaylightingControl = thermalZone.primaryDaylightingControl(); |
| 423 |
2/2✓ Branch 0 taken 61 times.
✓ Branch 1 taken 375 times.
|
436 | if (primaryDaylightingControl) { |
| 424 | |||
| 425 |
1/1✓ Branch 1 taken 61 times.
|
61 | boost::optional<DaylightingControl> secondaryDaylightingControl = thermalZone.secondaryDaylightingControl(); |
| 426 | |||
| 427 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | IdfObject daylightingControlObject(openstudio::IddObjectType::Daylighting_Controls); |
| 428 | // Name it like the Zone name + " DaylightingControls" | ||
| 429 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | daylightingControlObject.setName(tzName + " DaylightingControls"); |
| 430 |
1/1✓ Branch 1 taken 61 times.
|
61 | m_idfObjects.push_back(daylightingControlObject); |
| 431 | |||
| 432 | // Zone Name | ||
| 433 |
1/1✓ Branch 1 taken 61 times.
|
61 | daylightingControlObject.setString(Daylighting_ControlsFields::ZoneorSpaceName, tzName); |
| 434 | |||
| 435 | // Availability Schedule Name | ||
| 436 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 57 times.
|
122 | if (boost::optional<Schedule> sched = thermalZone.daylightingControlsAvailabilitySchedule()) { |
| 437 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
|
8 | if (boost::optional<IdfObject> idfo = translateAndMapModelObject(sched.get())) { |
| 438 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | daylightingControlObject.setString(Daylighting_ControlsFields::AvailabilityScheduleName, idfo->nameString()); |
| 439 | 4 | } | |
| 440 | 61 | } | |
| 441 | |||
| 442 | // Primary Control | ||
| 443 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | IdfObject primaryReferencePoint(openstudio::IddObjectType::Daylighting_ReferencePoint); |
| 444 | // Name it like the OS:Daylighting:Control corresponding to the Primary Reference Point | ||
| 445 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | primaryReferencePoint.setName(primaryDaylightingControl->nameString()); |
| 446 |
1/1✓ Branch 1 taken 61 times.
|
61 | m_idfObjects.push_back(primaryReferencePoint); |
| 447 | |||
| 448 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | OptionalSpace refSpace = primaryDaylightingControl->space(); |
| 449 |
2/2✓ Branch 0 taken 55 times.
✓ Branch 1 taken 6 times.
|
61 | if (refSpace) { |
| 450 |
2/2✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
|
55 | OptionalThermalZone refThermalZone = refSpace->thermalZone(); |
| 451 | // TODO: I think we should catch the case when refThermalZone != thermalZone... | ||
| 452 |
1/2✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
55 | if (refThermalZone) { |
| 453 |
3/3✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 7 taken 55 times.
|
55 | primaryReferencePoint.setString(Daylighting_ReferencePointFields::ZoneorSpaceName, refThermalZone->nameString()); |
| 454 | } | ||
| 455 | 55 | } | |
| 456 | |||
| 457 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | primaryReferencePoint.setDouble(Daylighting_ReferencePointFields::XCoordinateofReferencePoint, |
| 458 | primaryDaylightingControl->positionXCoordinate()); | ||
| 459 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | primaryReferencePoint.setDouble(Daylighting_ReferencePointFields::YCoordinateofReferencePoint, |
| 460 | primaryDaylightingControl->positionYCoordinate()); | ||
| 461 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | primaryReferencePoint.setDouble(Daylighting_ReferencePointFields::ZCoordinateofReferencePoint, |
| 462 | primaryDaylightingControl->positionZCoordinate()); | ||
| 463 | |||
| 464 |
1/1✓ Branch 1 taken 61 times.
|
61 | double primaryFrac = thermalZone.fractionofZoneControlledbyPrimaryDaylightingControl(); |
| 465 |
5/6✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 61 times.
|
183 | if (istringEqual("None", primaryDaylightingControl->lightingControlType())) { |
| 466 | ✗ | if (primaryFrac > 0.0) { | |
| 467 | ✗ | primaryFrac = 0.0; | |
| 468 | ✗ | LOG(Warn, "Fraction of Zone Controlled by Primary Daylight Control is " | |
| 469 | << primaryFrac << " but lighting control type is 'None'. Reseting Primary Fraction to " << 0.0); | ||
| 470 | } | ||
| 471 | } | ||
| 472 | |||
| 473 | std::vector<std::string> firstGroup{primaryReferencePoint.nameString(), toString(primaryFrac), | ||
| 474 |
3/5✓ Branch 1 taken 61 times.
✓ Branch 3 taken 183 times.
✓ Branch 4 taken 61 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
305 | toString(primaryDaylightingControl->illuminanceSetpoint())}; |
| 475 |
1/1✓ Branch 1 taken 61 times.
|
61 | daylightingControlObject.pushExtensibleGroup(firstGroup); |
| 476 | |||
| 477 | // Secondary Control | ||
| 478 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 50 times.
|
61 | if (secondaryDaylightingControl) { |
| 479 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | IdfObject secondaryReferencePoint(openstudio::IddObjectType::Daylighting_ReferencePoint); |
| 480 | // Name it like the OS:Daylighting:Control corresponding to the Secondary Reference Point | ||
| 481 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | secondaryReferencePoint.setName(secondaryDaylightingControl->nameString()); |
| 482 |
1/1✓ Branch 1 taken 11 times.
|
11 | m_idfObjects.push_back(secondaryReferencePoint); |
| 483 | |||
| 484 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | refSpace = secondaryDaylightingControl->space(); |
| 485 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
|
11 | if (refSpace) { |
| 486 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | OptionalThermalZone refThermalZone = refSpace->thermalZone(); |
| 487 | // TODO: catch if refThermalZone != thermalZone | ||
| 488 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if (refThermalZone) { |
| 489 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | secondaryReferencePoint.setString(Daylighting_ReferencePointFields::ZoneorSpaceName, refThermalZone->nameString()); |
| 490 | } | ||
| 491 | 9 | } | |
| 492 | |||
| 493 |
1/1✓ Branch 1 taken 11 times.
|
11 | secondaryReferencePoint.setString(Daylighting_ReferencePointFields::ZoneorSpaceName, tzName); |
| 494 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | secondaryReferencePoint.setDouble(Daylighting_ReferencePointFields::XCoordinateofReferencePoint, |
| 495 | secondaryDaylightingControl->positionXCoordinate()); | ||
| 496 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | secondaryReferencePoint.setDouble(Daylighting_ReferencePointFields::YCoordinateofReferencePoint, |
| 497 | secondaryDaylightingControl->positionYCoordinate()); | ||
| 498 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | secondaryReferencePoint.setDouble(Daylighting_ReferencePointFields::ZCoordinateofReferencePoint, |
| 499 | secondaryDaylightingControl->positionZCoordinate()); | ||
| 500 | |||
| 501 |
1/1✓ Branch 1 taken 11 times.
|
11 | double secondaryFrac = thermalZone.fractionofZoneControlledbySecondaryDaylightingControl(); |
| 502 |
5/6✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 11 times.
|
33 | if (istringEqual("None", secondaryDaylightingControl->lightingControlType())) { |
| 503 | ✗ | if (secondaryFrac > 0.0) { | |
| 504 | ✗ | secondaryFrac = 0.0; | |
| 505 | ✗ | LOG(Warn, "Fraction of Zone Controlled by Secondary Daylight Control is " | |
| 506 | << secondaryFrac << " but lighting control type is 'None'. Reseting Secondary Fraction to " << 0.0); | ||
| 507 | } | ||
| 508 | } else { | ||
| 509 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if ((primaryFrac + secondaryFrac) > 1) { |
| 510 | // Reset secondary to 1 - Primary | ||
| 511 | ✗ | secondaryFrac = std::max(1.0 - primaryFrac, 0.0); | |
| 512 | ✗ | LOG(Warn, "Fraction of Zone Controlled by Primary Daylight Control is " | |
| 513 | << primaryFrac << " while Secondary Fraction is " << secondaryFrac << ". Reseting Secondary Fraction to " << secondaryFrac); | ||
| 514 | } | ||
| 515 | } | ||
| 516 | |||
| 517 | std::vector<std::string> secondGroup{secondaryReferencePoint.nameString(), toString(secondaryFrac), | ||
| 518 |
3/5✓ Branch 1 taken 11 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 11 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
55 | toString(secondaryDaylightingControl->illuminanceSetpoint())}; |
| 519 |
1/1✓ Branch 1 taken 11 times.
|
11 | daylightingControlObject.pushExtensibleGroup(secondGroup); |
| 520 | 11 | } | |
| 521 | |||
| 522 | // Shared Data | ||
| 523 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | std::string lightingControlType = primaryDaylightingControl->lightingControlType(); |
| 524 |
3/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 61 times.
|
122 | if (istringEqual("None", lightingControlType)) { |
| 525 | // fraction for first point have been set to 0, try to get control type from second point | ||
| 526 | ✗ | if (secondaryDaylightingControl) { | |
| 527 | ✗ | lightingControlType = secondaryDaylightingControl->lightingControlType(); | |
| 528 | } | ||
| 529 | } | ||
| 530 | |||
| 531 |
3/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✗ Branch 8 not taken.
|
122 | if (istringEqual("None", lightingControlType)) { |
| 532 | // both fractions are 0 | ||
| 533 |
3/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✗ Branch 8 not taken.
|
122 | } else if (istringEqual("Continuous", lightingControlType)) { |
| 534 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
122 | daylightingControlObject.setString(Daylighting_ControlsFields::LightingControlType, "Continuous"); |
| 535 | ✗ | } else if (istringEqual("Stepped", lightingControlType)) { | |
| 536 | ✗ | daylightingControlObject.setString(Daylighting_ControlsFields::LightingControlType, "Stepped"); | |
| 537 | ✗ | } else if (istringEqual("Continuous/Off", lightingControlType)) { | |
| 538 | ✗ | daylightingControlObject.setString(Daylighting_ControlsFields::LightingControlType, "ContinuousOff"); | |
| 539 | } else { | ||
| 540 | ✗ | LOG(Warn, | |
| 541 | "Unknown lighting control type '" << lightingControlType << "' for OS:Daylighting:Control " << primaryDaylightingControl->nameString()); | ||
| 542 | } | ||
| 543 | |||
| 544 |
4/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 59 times.
|
61 | if (primaryDaylightingControl->psiRotationAroundXAxis() != 0.0) { |
| 545 |
12/12✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 29 taken 2 times.
✓ Branch 32 taken 2 times.
✓ Branch 35 taken 2 times.
|
2 | LOG(Warn, "Rotation of " << primaryDaylightingControl->psiRotationAroundXAxis() |
| 546 | << " degrees about X axis not mapped for OS:Daylighting:Control " << primaryDaylightingControl->nameString()); | ||
| 547 | } | ||
| 548 | |||
| 549 |
4/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 55 times.
|
61 | if (primaryDaylightingControl->thetaRotationAroundYAxis() != 0.0) { |
| 550 |
12/12✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✓ Branch 13 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 22 taken 6 times.
✓ Branch 25 taken 6 times.
✓ Branch 29 taken 6 times.
✓ Branch 32 taken 6 times.
✓ Branch 35 taken 6 times.
|
6 | LOG(Warn, "Rotation of " << primaryDaylightingControl->thetaRotationAroundYAxis() |
| 551 | << " degrees about Y axis not mapped for OS:Daylighting:Control " << primaryDaylightingControl->nameString()); | ||
| 552 | } | ||
| 553 | |||
| 554 | // glare: | ||
| 555 | // * openstudio uses the right-hand rule, y points North and x points east. | ||
| 556 | // So a positive rotation around the z-axis is counter-clockwise in the horizontal plane | ||
| 557 | // * E+ on the other hand is looking for something that is clockwise: | ||
| 558 | // > Field: Glare Calculation Azimuth Angle of View Direction Clockwise from Zone y-Axis | ||
| 559 | // > It is the angle, measured clockwise in the horizontal plane, between the zone y-axis and the occupant view direction | ||
| 560 | |||
| 561 | // 3D View: | ||
| 562 | // z | ||
| 563 | // ▲ | ||
| 564 | // │ | ||
| 565 | // │ | ||
| 566 | // | │ ▲ | ||
| 567 | // +└►├─┘ | ||
| 568 | // │ . OS convention for ϕ | ||
| 569 | // │ . | ||
| 570 | // │ .<-◝ | ||
| 571 | // │. ) ϕ | ||
| 572 | // ○─────────────────► y | ||
| 573 | // ╱ * ) | ||
| 574 | // ╱ *<-◞ E+ Field | ||
| 575 | // ╱ * | ||
| 576 | // ╱ | ||
| 577 | // ╱ | ||
| 578 | // x | ||
| 579 | // | ||
| 580 | // 2D View, from the top: | ||
| 581 | // | ||
| 582 | // y | ||
| 583 | // ▲ Glare Calculation Azimuth Angle of View Direction Clockwise from Zone y axis | ||
| 584 | // \ │ E+ / | ||
| 585 | // \ OS ϕ ├─────┐ / | ||
| 586 | // \ ┌────┤ ▼/ | ||
| 587 | // \▼ │ / | ||
| 588 | // \ │ / | ||
| 589 | // \ │ / | ||
| 590 | // \ │ / | ||
| 591 | // \ | / | ||
| 592 | // (◯)───────────────►x | ||
| 593 | // z | ||
| 594 | // | ||
| 595 | |||
| 596 |
2/2✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
|
61 | double glareAngle = -primaryDaylightingControl->phiRotationAroundZAxis(); |
| 597 | // Force [0,360[ | ||
| 598 | 61 | glareAngle = normalizeAngle0to360(glareAngle); | |
| 599 |
1/1✓ Branch 1 taken 61 times.
|
61 | daylightingControlObject.setDouble(Daylighting_ControlsFields::GlareCalculationAzimuthAngleofViewDirectionClockwisefromZoneyAxis, glareAngle); |
| 600 | |||
| 601 |
4/4✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 54 times.
|
122 | if (OptionalDouble d = primaryDaylightingControl->maximumAllowableDiscomfortGlareIndex()) { |
| 602 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | daylightingControlObject.setDouble(Daylighting_ControlsFields::MaximumAllowableDiscomfortGlareIndex, *d); |
| 603 | } | ||
| 604 | |||
| 605 |
1/1✓ Branch 1 taken 61 times.
|
61 | daylightingControlObject.setString(Daylighting_ControlsFields::GlareCalculationDaylightingReferencePointName, |
| 606 |
1/1✓ Branch 1 taken 61 times.
|
122 | primaryReferencePoint.nameString()); |
| 607 | |||
| 608 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | daylightingControlObject.setDouble(Daylighting_ControlsFields::MinimumInputPowerFractionforContinuousorContinuousOffDimmingControl, |
| 609 | primaryDaylightingControl->minimumInputPowerFractionforContinuousDimmingControl()); | ||
| 610 | |||
| 611 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | daylightingControlObject.setDouble(Daylighting_ControlsFields::MinimumLightOutputFractionforContinuousorContinuousOffDimmingControl, |
| 612 | primaryDaylightingControl->minimumLightOutputFractionforContinuousDimmingControl()); | ||
| 613 | |||
| 614 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | daylightingControlObject.setInt(Daylighting_ControlsFields::NumberofSteppedControlSteps, |
| 615 | primaryDaylightingControl->numberofSteppedControlSteps()); | ||
| 616 | |||
| 617 |
3/3✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
|
61 | daylightingControlObject.setDouble(Daylighting_ControlsFields::ProbabilityLightingwillbeResetWhenNeededinManualSteppedControl, |
| 618 | primaryDaylightingControl->probabilityLightingwillbeResetWhenNeededinManualSteppedControl()); | ||
| 619 | 61 | } | |
| 620 |
10/18✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
✓ Branch 13 taken 61 times.
✓ Branch 16 taken 11 times.
✓ Branch 19 taken 11 times.
✓ Branch 22 taken 11 times.
✓ Branch 25 taken 11 times.
✓ Branch 28 taken 11 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
|
508 | }; |
| 621 | |||
| 622 |
1/1✓ Branch 1 taken 436 times.
|
436 | translateDaylightingControls(modelObject); |
| 623 | |||
| 624 | // translate illuminance map | ||
| 625 |
1/1✓ Branch 1 taken 436 times.
|
436 | boost::optional<IlluminanceMap> illuminanceMap = modelObject.illuminanceMap(); |
| 626 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 400 times.
|
436 | if (illuminanceMap) { |
| 627 |
3/3✓ Branch 1 taken 36 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 34 times.
|
36 | if (!modelObject.primaryDaylightingControl()) { |
| 628 |
6/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
|
2 | LOG(Warn, |
| 629 | "Daylighting:Controls object is required to trigger daylighting calculations in EnergyPlus, adding a minimal one to Zone " << tzName); | ||
| 630 | |||
| 631 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject referencePoint(openstudio::IddObjectType::Daylighting_ReferencePoint); |
| 632 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | referencePoint.setName(tzName + " Daylighting Reference Point"); |
| 633 |
1/1✓ Branch 1 taken 2 times.
|
2 | m_idfObjects.push_back(referencePoint); |
| 634 |
1/1✓ Branch 1 taken 2 times.
|
2 | referencePoint.setString(Daylighting_ReferencePointFields::ZoneorSpaceName, tzName); |
| 635 | 2 | referencePoint.setDouble(Daylighting_ReferencePointFields::XCoordinateofReferencePoint, | |
| 636 |
5/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
|
2 | illuminanceMap->originXCoordinate() + 0.5 * illuminanceMap->xLength()); |
| 637 | 2 | referencePoint.setDouble(Daylighting_ReferencePointFields::YCoordinateofReferencePoint, | |
| 638 |
5/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
|
2 | illuminanceMap->originYCoordinate() + 0.5 * illuminanceMap->yLength()); |
| 639 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | referencePoint.setDouble(Daylighting_ReferencePointFields::ZCoordinateofReferencePoint, illuminanceMap->originZCoordinate()); |
| 640 | |||
| 641 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject daylightingControlObject(openstudio::IddObjectType::Daylighting_Controls); |
| 642 | // Name it like the Zone name + " DaylightingControls" | ||
| 643 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | daylightingControlObject.setName(tzName + " DaylightingControls"); |
| 644 |
1/1✓ Branch 1 taken 2 times.
|
2 | m_idfObjects.push_back(daylightingControlObject); |
| 645 | |||
| 646 |
1/1✓ Branch 1 taken 2 times.
|
2 | daylightingControlObject.setString(Daylighting_ControlsFields::ZoneorSpaceName, tzName); |
| 647 | std::vector<std::string> group{referencePoint.nameString(), // ref point name | ||
| 648 | "0.0", // fraction controlled | ||
| 649 |
3/5✓ Branch 1 taken 2 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
10 | ""}; // illuminance setpoint |
| 650 | 2 | daylightingControlObject.pushExtensibleGroup(group); | |
| 651 | 2 | } | |
| 652 | |||
| 653 | // TODO: move this to its own file | ||
| 654 | 36 | auto translateIlluminanceMap = [this](model::IlluminanceMap& illuminanceMap) -> IdfObject { | |
| 655 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | IdfObject illuminanceMapObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Output_IlluminanceMap, illuminanceMap); |
| 656 | |||
| 657 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | illuminanceMapObject.setDouble(Output_IlluminanceMapFields::Zheight, illuminanceMap.originZCoordinate()); |
| 658 | |||
| 659 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | illuminanceMapObject.setDouble(Output_IlluminanceMapFields::XMinimumCoordinate, illuminanceMap.originXCoordinate()); |
| 660 | 36 | illuminanceMapObject.setDouble(Output_IlluminanceMapFields::XMaximumCoordinate, | |
| 661 |
3/3✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
|
36 | illuminanceMap.originXCoordinate() + illuminanceMap.xLength()); |
| 662 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | illuminanceMapObject.setInt(Output_IlluminanceMapFields::NumberofXGridPoints, illuminanceMap.numberofXGridPoints()); |
| 663 | |||
| 664 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | illuminanceMapObject.setDouble(Output_IlluminanceMapFields::YMinimumCoordinate, illuminanceMap.originYCoordinate()); |
| 665 | 36 | illuminanceMapObject.setDouble(Output_IlluminanceMapFields::YMaximumCoordinate, | |
| 666 |
3/3✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
|
36 | illuminanceMap.originYCoordinate() + illuminanceMap.yLength()); |
| 667 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | illuminanceMapObject.setInt(Output_IlluminanceMapFields::NumberofYGridPoints, illuminanceMap.numberofYGridPoints()); |
| 668 | |||
| 669 |
2/3✓ Branch 1 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
|
36 | if (illuminanceMap.psiRotationAroundXAxis() != 0.0) { |
| 670 | ✗ | LOG(Warn, "Rotation of " << illuminanceMap.psiRotationAroundXAxis() << " degrees about X axis not mapped for OS:IlluminanceMap " | |
| 671 | << illuminanceMap.nameString()); | ||
| 672 | } | ||
| 673 | |||
| 674 |
2/3✓ Branch 1 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
|
36 | if (illuminanceMap.thetaRotationAroundYAxis() != 0.0) { |
| 675 | ✗ | LOG(Warn, "Rotation of " << illuminanceMap.thetaRotationAroundYAxis() << " degrees about Y axis not mapped for OS:IlluminanceMap " | |
| 676 | << illuminanceMap.nameString()); | ||
| 677 | } | ||
| 678 | |||
| 679 |
2/3✓ Branch 1 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
|
36 | if (illuminanceMap.phiRotationAroundZAxis() != 0.0) { |
| 680 | ✗ | LOG(Warn, "Rotation of " << illuminanceMap.phiRotationAroundZAxis() << " degrees about Z axis not mapped for OS:IlluminanceMap " | |
| 681 | << illuminanceMap.nameString()); | ||
| 682 | } | ||
| 683 | |||
| 684 | 36 | return illuminanceMapObject; | |
| 685 | ✗ | }; | |
| 686 | |||
| 687 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | auto illuminanceMapObject = translateIlluminanceMap(illuminanceMap.get()); |
| 688 |
1/1✓ Branch 1 taken 36 times.
|
36 | illuminanceMapObject.setString(Output_IlluminanceMapFields::ZoneorSpaceName, tzName); |
| 689 | 36 | } | |
| 690 | |||
| 691 | // TODO: this is definitely shared between both paths | ||
| 692 | // translate zone mixing objects which supply air to this zone | ||
| 693 |
1/1✓ Branch 1 taken 436 times.
|
436 | ZoneMixingVector supplyZoneMixing = modelObject.supplyZoneMixing(); |
| 694 |
1/1✓ Branch 3 taken 436 times.
|
436 | std::sort(supplyZoneMixing.begin(), supplyZoneMixing.end(), WorkspaceObjectNameLess()); |
| 695 |
2/2✓ Branch 4 taken 2 times.
✓ Branch 5 taken 436 times.
|
438 | for (ZoneMixing& mixing : supplyZoneMixing) { |
| 696 |
1/1✓ Branch 1 taken 2 times.
|
2 | translateAndMapModelObject(mixing); |
| 697 | } | ||
| 698 | |||
| 699 |
1/1✓ Branch 1 taken 436 times.
|
436 | auto zoneEquipment = modelObject.equipment(); |
| 700 | |||
| 701 | // In OS ZoneVentilationDesignFlowRate and ZoneVentilationWindandStackOpenArea are considered zone equipment, | ||
| 702 | // but for the E+ perspective it is not so we have to remove them and treat them differently. | ||
| 703 | 294 | auto isZoneVentilationObject = [](const ModelObject& mo) { | |
| 704 |
2/2✓ Branch 1 taken 294 times.
✓ Branch 4 taken 294 times.
|
294 | return ((mo.iddObjectType() == ZoneVentilationDesignFlowRate::iddObjectType()) |
| 705 |
6/6✓ Branch 0 taken 292 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 292 times.
✓ Branch 6 taken 292 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 286 times.
|
294 | || (mo.iddObjectType() == ZoneVentilationWindandStackOpenArea::iddObjectType())); |
| 706 | }; | ||
| 707 | |||
| 708 | 436 | std::vector<model::ModelObject> zoneVentilationObjects; | |
| 709 |
2/2✓ Branch 1 taken 436 times.
✓ Branch 6 taken 436 times.
|
436 | std::copy_if(zoneEquipment.begin(), zoneEquipment.end(), std::back_inserter(zoneVentilationObjects), isZoneVentilationObject); |
| 710 | |||
| 711 |
1/1✓ Branch 3 taken 436 times.
|
436 | auto zoneVentilationBegin = std::remove_if(zoneEquipment.begin(), zoneEquipment.end(), isZoneVentilationObject); |
| 712 |
1/1✓ Branch 4 taken 436 times.
|
436 | zoneEquipment.erase(zoneVentilationBegin, zoneEquipment.end()); |
| 713 | |||
| 714 | // translate thermostat and/or humidistat | ||
| 715 |
7/7✓ Branch 1 taken 309 times.
✓ Branch 2 taken 127 times.
✓ Branch 4 taken 309 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 296 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 296 times.
|
436 | if ((!zoneEquipment.empty()) || modelObject.useIdealAirLoads()) { |
| 716 | // Thermostat | ||
| 717 |
3/3✓ Branch 1 taken 140 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 93 times.
|
280 | if (auto thermostat = modelObject.thermostat()) { |
| 718 |
4/5✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 47 times.
|
47 | if (thermostat->iddObjectType() == ZoneControlThermostatStagedDualSetpoint::iddObjectType()) { |
| 719 | // This one we translate already | ||
| 720 | ✗ | translateAndMapModelObject(thermostat.get()); | |
| 721 | } else { | ||
| 722 | |||
| 723 | // This is a OS:ThermostatSetpoint:DualSetpoint as it's the only other choice. | ||
| 724 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | auto dualSetpoint = thermostat->cast<ThermostatSetpointDualSetpoint>(); |
| 725 | |||
| 726 | 47 | auto createZoneControlThermostat = [&]() { | |
| 727 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | IdfObject zoneControlThermostat(openstudio::IddObjectType::ZoneControl_Thermostat); |
| 728 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | zoneControlThermostat.setString(ZoneControl_ThermostatFields::Name, tzName + " Thermostat"); |
| 729 |
1/1✓ Branch 1 taken 47 times.
|
47 | zoneControlThermostat.setString(ZoneControl_ThermostatFields::ZoneorZoneListName, tzName); |
| 730 |
1/1✓ Branch 1 taken 47 times.
|
47 | m_idfObjects.push_back(zoneControlThermostat); |
| 731 | |||
| 732 | // Need to handle the control type base don thermostat type (1: Single heating, 2: single cooling, 4: Dual setpoint) | ||
| 733 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | IdfObject scheduleCompact(openstudio::IddObjectType::Schedule_Compact); |
| 734 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | scheduleCompact.setName(tzName + " Thermostat Schedule"); |
| 735 |
1/1✓ Branch 1 taken 47 times.
|
47 | m_idfObjects.push_back(scheduleCompact); |
| 736 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | scheduleCompact.setString(1, tzName + " Thermostat Schedule Type Limits"); |
| 737 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
94 | scheduleCompact.setString(2, "Through: 12/31"); |
| 738 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
94 | scheduleCompact.setString(3, "For: AllDays"); |
| 739 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
94 | scheduleCompact.setString(4, "Until: 24:00"); |
| 740 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | scheduleCompact.setString(5, "4"); |
| 741 | |||
| 742 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | IdfObject scheduleTypeLimits(openstudio::IddObjectType::ScheduleTypeLimits); |
| 743 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | scheduleTypeLimits.setName(tzName + " Thermostat Schedule Type Limits"); |
| 744 |
1/1✓ Branch 1 taken 47 times.
|
47 | m_idfObjects.push_back(scheduleTypeLimits); |
| 745 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
94 | scheduleTypeLimits.setString(1, "0"); |
| 746 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
94 | scheduleTypeLimits.setString(2, "4"); |
| 747 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | scheduleTypeLimits.setString(3, "DISCRETE"); |
| 748 | |||
| 749 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | zoneControlThermostat.setString(ZoneControl_ThermostatFields::ControlTypeScheduleName, scheduleCompact.nameString()); |
| 750 | |||
| 751 |
2/3✓ Branch 1 taken 47 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
|
94 | if (boost::optional<IdfObject> idfThermostat = translateAndMapModelObject(dualSetpoint)) { |
| 752 | // TODO: JM 2019-09-04 switch back to an extensible object once/if https://github.com/NREL/EnergyPlus/issues/7484 is addressed and the | ||
| 753 | // 'Temperature Difference Between Cutout And Setpoint' field is moved before the extensible fields | ||
| 754 | // For now, we revert to a non extensible object, so we can still write that field | ||
| 755 | |||
| 756 | //StringVector values(zoneControlThermostat.iddObject().properties().numExtensible); | ||
| 757 | //values[ZoneControl_ThermostatExtensibleFields::ControlObjectType] = idfThermostat->iddObject().name(); | ||
| 758 | //values[ZoneControl_ThermostatExtensibleFields::ControlName] = idfThermostat->nameString(); | ||
| 759 | //IdfExtensibleGroup eg = zoneControlThermostat.pushExtensibleGroup(values); | ||
| 760 | |||
| 761 |
4/4✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
✓ Branch 10 taken 47 times.
|
47 | zoneControlThermostat.setString(ZoneControl_ThermostatFields::Control1ObjectType, idfThermostat->iddObject().name()); |
| 762 |
3/3✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
|
47 | zoneControlThermostat.setString(ZoneControl_ThermostatFields::Control1Name, idfThermostat->nameString()); |
| 763 | |||
| 764 |
6/6✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
✓ Branch 10 taken 47 times.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 46 times.
|
47 | if (idfThermostat->iddObject().name() == "ThermostatSetpoint:SingleHeating") { |
| 765 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | scheduleCompact.setString(5, "1"); |
| 766 |
6/6✓ Branch 1 taken 46 times.
✓ Branch 4 taken 46 times.
✓ Branch 7 taken 46 times.
✓ Branch 10 taken 46 times.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 45 times.
|
46 | } else if (idfThermostat->iddObject().name() == "ThermostatSetpoint:SingleCooling") { |
| 767 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | scheduleCompact.setString(5, "2"); |
| 768 | } else { | ||
| 769 | // DualSetpoint | ||
| 770 |
2/2✓ Branch 1 taken 45 times.
✓ Branch 4 taken 45 times.
|
90 | scheduleCompact.setString(5, "4"); |
| 771 | } | ||
| 772 | |||
| 773 | // Thermostat's Temperature Difference Between Cutout And Setpoint is placed here on the ZoneControl:Thermostat | ||
| 774 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
|
47 | zoneControlThermostat.setDouble(ZoneControl_ThermostatFields::TemperatureDifferenceBetweenCutoutAndSetpoint, |
| 775 | dualSetpoint.temperatureDifferenceBetweenCutoutAndSetpoint()); | ||
| 776 | 47 | } | |
| 777 | 47 | }; | |
| 778 | |||
| 779 | // Only translate ThermostatSetpointDualSetpoint if there is at least one schedule attached | ||
| 780 | // The translation to SingleHeating, SingleCooling, or DualSetpoint as appropriate is handled in ForwardTranslateThermostatSetpointDualSetpoint | ||
| 781 |
9/16✓ Branch 1 taken 47 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 46 times.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 46 times.
✓ Branch 15 taken 47 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 47 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
95 | if (dualSetpoint.heatingSetpointTemperatureSchedule() || dualSetpoint.coolingSetpointTemperatureSchedule()) { |
| 782 |
1/1✓ Branch 1 taken 47 times.
|
47 | createZoneControlThermostat(); |
| 783 | } | ||
| 784 | 47 | } | |
| 785 | 140 | } | |
| 786 | |||
| 787 | // Humidistat | ||
| 788 |
2/3✓ Branch 1 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
|
280 | if (boost::optional<ZoneControlHumidistat> humidistat = modelObject.zoneControlHumidistat()) { |
| 789 | ✗ | if (boost::optional<IdfObject> idfHumidistat = translateAndMapModelObject(humidistat.get())) { | |
| 790 | ✗ | idfHumidistat->setString(ZoneControl_HumidistatFields::ZoneName, tzName); | |
| 791 | ✗ | } | |
| 792 | 140 | } | |
| 793 | |||
| 794 | // ZoneControlContaminantController | ||
| 795 |
2/3✓ Branch 1 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
|
280 | if (auto controller = modelObject.zoneControlContaminantController()) { |
| 796 | ✗ | translateAndMapModelObject(controller.get()); | |
| 797 | 140 | } | |
| 798 | } | ||
| 799 | |||
| 800 | // Ideal air loads | ||
| 801 |
3/3✓ Branch 1 taken 436 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 423 times.
|
436 | if (modelObject.useIdealAirLoads()) { |
| 802 |
1/1✓ Branch 1 taken 13 times.
|
13 | auto& idealLoadsAirSystem = m_idfObjects.emplace_back(IddObjectType::HVACTemplate_Zone_IdealLoadsAirSystem); |
| 803 |
1/1✓ Branch 1 taken 13 times.
|
13 | idealLoadsAirSystem.setString(HVACTemplate_Zone_IdealLoadsAirSystemFields::ZoneName, tzName); |
| 804 | } | ||
| 805 | |||
| 806 | // ZoneVentilationDesignFlowRate and ZoneVentilationWindandStackOpenArea do not go on equipment connections or associated list | ||
| 807 |
2/2✓ Branch 4 taken 4 times.
✓ Branch 5 taken 436 times.
|
440 | for (auto& zone_vent : zoneVentilationObjects) { |
| 808 |
1/1✓ Branch 1 taken 4 times.
|
4 | translateAndMapModelObject(zone_vent); |
| 809 | } | ||
| 810 | |||
| 811 | // ZoneMRTCalculation | ||
| 812 |
4/4✓ Branch 1 taken 436 times.
✓ Branch 4 taken 436 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 436 times.
|
438 | for (auto& zoneMRTCalculation : modelObject.getModelObjectSources<ZoneMRTCalculation>(ZoneMRTCalculation::iddObjectType())) { |
| 813 |
1/1✓ Branch 1 taken 2 times.
|
2 | translateAndMapModelObject(zoneMRTCalculation); |
| 814 | 436 | } | |
| 815 | |||
| 816 | 436 | bool zoneHVACIdealWorkaround = false; | |
| 817 | 436 | boost::optional<ZoneHVACIdealLoadsAirSystem> ideal; | |
| 818 |
2/2✓ Branch 1 taken 111 times.
✓ Branch 2 taken 325 times.
|
436 | if (zoneEquipment.size() == 1) { |
| 819 |
1/1✓ Branch 2 taken 111 times.
|
111 | ideal = zoneEquipment.front().optionalCast<model::ZoneHVACIdealLoadsAirSystem>(); |
| 820 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 109 times.
|
111 | if (ideal) { |
| 821 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | auto returnPlenum = ideal->returnPlenum(); |
| 822 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (returnPlenum) { |
| 823 | ✗ | auto allIdealHVAC = returnPlenum->getImpl<model::detail::AirLoopHVACReturnPlenum_Impl>()->zoneHVACIdealLoadsAirSystems(); | |
| 824 | ✗ | if (!allIdealHVAC.empty()) { | |
| 825 | ✗ | zoneHVACIdealWorkaround = true; | |
| 826 | } | ||
| 827 | ✗ | } | |
| 828 | 2 | } | |
| 829 | } | ||
| 830 | |||
| 831 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
|
436 | if (zoneHVACIdealWorkaround) { |
| 832 | // ZoneHVAC_EquipmentConnections | ||
| 833 | ✗ | IdfObject connectionsObject(openstudio::IddObjectType::ZoneHVAC_EquipmentConnections); | |
| 834 | ✗ | m_idfObjects.push_back(connectionsObject); | |
| 835 | |||
| 836 | ✗ | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneName, tzName); | |
| 837 | |||
| 838 | //set the inlet port list | ||
| 839 | ✗ | PortList inletPortList = modelObject.inletPortList(); | |
| 840 | ✗ | if (!inletPortList.modelObjects().empty()) { | |
| 841 | ✗ | boost::optional<IdfObject> _inletNodeList = translateAndMapModelObject(inletPortList); | |
| 842 | ✗ | if (_inletNodeList) { | |
| 843 | ✗ | _inletNodeList->setName(tzName + " Inlet Node List"); | |
| 844 | ✗ | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneAirInletNodeorNodeListName, _inletNodeList->nameString()); | |
| 845 | } | ||
| 846 | ✗ | } | |
| 847 | |||
| 848 | //set the zone air node | ||
| 849 | ✗ | Node node = modelObject.zoneAirNode(); | |
| 850 | ✗ | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneAirNodeName, node.nameString()); | |
| 851 | |||
| 852 | // Use the exhaust node as the zone return node in this workaround | ||
| 853 | //set the zone return air node | ||
| 854 | ✗ | auto exhaustPortList = modelObject.exhaustPortList(); | |
| 855 | ✗ | auto exhaustNodes = subsetCastVector<model::Node>(exhaustPortList.modelObjects()); | |
| 856 | ✗ | OS_ASSERT(exhaustNodes.size() == 1); | |
| 857 | ✗ | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneReturnAirNodeorNodeListName, | |
| 858 | ✗ | exhaustNodes.front().nameString()); | |
| 859 | |||
| 860 | // ZoneHVAC_EquipmentList | ||
| 861 | ✗ | ZoneHVACEquipmentList equipmentList = modelObject.getImpl<model::detail::ThermalZone_Impl>()->zoneHVACEquipmentList(); | |
| 862 | ✗ | boost::optional<IdfObject> _equipmentList = translateAndMapModelObject(equipmentList); | |
| 863 | |||
| 864 | ✗ | if (_equipmentList) { | |
| 865 | ✗ | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneConditioningEquipmentListName, _equipmentList->nameString()); | |
| 866 | } | ||
| 867 |
2/2✓ Branch 8 taken 127 times.
✓ Branch 9 taken 309 times.
|
436 | } else if (!zoneEquipment.empty()) { |
| 868 | // ZoneHVAC_EquipmentConnections | ||
| 869 |
2/2✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
|
127 | IdfObject connectionsObject(openstudio::IddObjectType::ZoneHVAC_EquipmentConnections); |
| 870 |
1/1✓ Branch 1 taken 127 times.
|
127 | m_idfObjects.push_back(connectionsObject); |
| 871 | |||
| 872 |
1/1✓ Branch 1 taken 127 times.
|
127 | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneName, tzName); |
| 873 | |||
| 874 | //set the inlet port list | ||
| 875 |
1/1✓ Branch 1 taken 127 times.
|
127 | PortList inletPortList = modelObject.inletPortList(); |
| 876 |
3/3✓ Branch 1 taken 127 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 14 times.
|
127 | if (!inletPortList.modelObjects().empty()) { |
| 877 |
1/1✓ Branch 1 taken 113 times.
|
113 | boost::optional<IdfObject> _inletNodeList = translateAndMapModelObject(inletPortList); |
| 878 |
1/2✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
|
113 | if (_inletNodeList) { |
| 879 |
3/3✓ Branch 1 taken 113 times.
✓ Branch 4 taken 113 times.
✓ Branch 7 taken 113 times.
|
113 | _inletNodeList->setName(tzName + " Inlet Node List"); |
| 880 |
3/3✓ Branch 1 taken 113 times.
✓ Branch 4 taken 113 times.
✓ Branch 7 taken 113 times.
|
113 | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneAirInletNodeorNodeListName, _inletNodeList->nameString()); |
| 881 | } | ||
| 882 | 113 | } | |
| 883 | |||
| 884 | //set the exhaust port list | ||
| 885 |
1/1✓ Branch 1 taken 127 times.
|
127 | PortList exhaustPortList = modelObject.exhaustPortList(); |
| 886 |
3/3✓ Branch 1 taken 127 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 79 times.
|
127 | if (!exhaustPortList.modelObjects().empty()) { |
| 887 |
1/1✓ Branch 1 taken 48 times.
|
48 | boost::optional<IdfObject> _exhaustNodeList = translateAndMapModelObject(exhaustPortList); |
| 888 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if (_exhaustNodeList) { |
| 889 |
3/3✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 7 taken 48 times.
|
48 | _exhaustNodeList->setName(tzName + " Exhaust Node List"); |
| 890 |
1/1✓ Branch 1 taken 48 times.
|
48 | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneAirExhaustNodeorNodeListName, |
| 891 |
2/2✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
|
96 | _exhaustNodeList->nameString()); |
| 892 | } | ||
| 893 | 48 | } | |
| 894 | |||
| 895 | //set the zone air node | ||
| 896 |
1/1✓ Branch 1 taken 127 times.
|
127 | Node node = modelObject.zoneAirNode(); |
| 897 |
2/2✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
|
127 | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneAirNodeName, node.nameString()); |
| 898 | |||
| 899 | //set the zone return air node | ||
| 900 |
1/1✓ Branch 1 taken 127 times.
|
127 | auto returnPortList = modelObject.returnPortList(); |
| 901 |
3/3✓ Branch 1 taken 127 times.
✓ Branch 5 taken 75 times.
✓ Branch 6 taken 52 times.
|
127 | if (!returnPortList.modelObjects().empty()) { |
| 902 |
1/1✓ Branch 1 taken 75 times.
|
75 | auto _returnNodeList = translateAndMapModelObject(returnPortList); |
| 903 |
1/2✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
|
75 | if (_returnNodeList) { |
| 904 |
3/3✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
✓ Branch 7 taken 75 times.
|
75 | _returnNodeList->setName(tzName + " Return Node List"); |
| 905 |
1/1✓ Branch 1 taken 75 times.
|
75 | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneReturnAirNodeorNodeListName, |
| 906 |
2/2✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
|
150 | _returnNodeList->nameString()); |
| 907 | } | ||
| 908 | 75 | } | |
| 909 | |||
| 910 | // ZoneHVAC_EquipmentList | ||
| 911 | |||
| 912 |
1/1✓ Branch 3 taken 127 times.
|
127 | ZoneHVACEquipmentList equipmentList = modelObject.getImpl<model::detail::ThermalZone_Impl>()->zoneHVACEquipmentList(); |
| 913 | |||
| 914 |
1/1✓ Branch 1 taken 127 times.
|
127 | boost::optional<IdfObject> _equipmentList = translateAndMapModelObject(equipmentList); |
| 915 | |||
| 916 |
1/2✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
|
127 | if (_equipmentList) { |
| 917 |
3/3✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
✓ Branch 7 taken 127 times.
|
127 | connectionsObject.setString(openstudio::ZoneHVAC_EquipmentConnectionsFields::ZoneConditioningEquipmentListName, _equipmentList->nameString()); |
| 918 | } | ||
| 919 | 127 | } | |
| 920 | |||
| 921 | // SizingZone | ||
| 922 | |||
| 923 |
7/7✓ Branch 1 taken 309 times.
✓ Branch 2 taken 127 times.
✓ Branch 4 taken 309 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 296 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 296 times.
|
436 | if ((!zoneEquipment.empty()) || modelObject.useIdealAirLoads()) { |
| 924 | // get sizing period objects from the model | ||
| 925 |
2/2✓ Branch 1 taken 140 times.
✓ Branch 4 taken 140 times.
|
140 | std::vector<SizingPeriod> sizingPeriod = modelObject.model().getModelObjects<SizingPeriod>(); |
| 926 | // map the sizing object only if a sizing period object exists | ||
| 927 | 140 | boost::optional<IdfObject> sizingZoneIdf; | |
| 928 |
2/2✓ Branch 1 taken 56 times.
✓ Branch 2 taken 84 times.
|
140 | if (!sizingPeriod.empty()) { |
| 929 |
1/1✓ Branch 1 taken 56 times.
|
56 | SizingZone sizingZone = modelObject.sizingZone(); |
| 930 |
1/1✓ Branch 1 taken 56 times.
|
56 | sizingZoneIdf = translateAndMapModelObject(sizingZone); |
| 931 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 4 not taken.
|
56 | OS_ASSERT(sizingZoneIdf); |
| 932 | 56 | } | |
| 933 | |||
| 934 | // For the ZoneVentilation workaround | ||
| 935 | 140 | bool createZvs = false; | |
| 936 | |||
| 937 |
4/4✓ Branch 1 taken 140 times.
✓ Branch 4 taken 140 times.
✓ Branch 8 taken 28 times.
✓ Branch 9 taken 112 times.
|
280 | if (auto dsoaOrList_ = getOrCreateThermalZoneDSOA(modelObject.cast<ThermalZone>())) { |
| 938 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 11 times.
|
28 | if (sizingZoneIdf) { |
| 939 |
4/4✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
|
17 | sizingZoneIdf->setString(Sizing_ZoneFields::DesignSpecificationOutdoorAirObjectName, dsoaOrList_->nameString()); |
| 940 | } | ||
| 941 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 25 times.
|
28 | if (zoneEquipment.empty()) { // We know this is useIdealAirLoads |
| 942 | 3 | createZvs = true; | |
| 943 | } | ||
| 944 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 73 times.
|
112 | } else if (sizingZoneIdf) { |
| 945 | // Controller:MechnicalVentilation: Design Specification Outdoor Air Object Name <x> | ||
| 946 | // > If this field is blank, the corresponding DesignSpecification:OutdoorAir object for the zone will come from | ||
| 947 | // > the DesignSpecification:OutdoorAir object referenced by the Sizing:Zone object for the same zone. | ||
| 948 | // > ***If no such zone match is found, default values from the IDD will be used for the DesignSpecification:OutdoorAir object | ||
| 949 | // > which is 0.0094 m3/s-person.*** | ||
| 950 | // Apparently I need to set an empty one or something | ||
| 951 |
1/1✓ Branch 1 taken 39 times.
|
39 | auto& dsoaObject = m_idfObjects.emplace_back(IddObjectType::DesignSpecification_OutdoorAir); |
| 952 | |||
| 953 |
3/3✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
|
39 | dsoaObject.setString(DesignSpecification_OutdoorAirFields::Name, modelObject.nameString() + " Zero air DSOA"); |
| 954 |
2/2✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
|
39 | dsoaObject.setString(DesignSpecification_OutdoorAirFields::OutdoorAirMethod, "Sum"); |
| 955 |
1/1✓ Branch 1 taken 39 times.
|
39 | dsoaObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowperPerson, 0.0); |
| 956 |
1/1✓ Branch 1 taken 39 times.
|
39 | dsoaObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowperZoneFloorArea, 0.0); |
| 957 |
1/1✓ Branch 1 taken 39 times.
|
39 | dsoaObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowperZone, 0.0); |
| 958 |
1/1✓ Branch 1 taken 39 times.
|
39 | dsoaObject.setDouble(DesignSpecification_OutdoorAirFields::OutdoorAirFlowAirChangesperHour, 0.0); |
| 959 | |||
| 960 |
3/3✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
|
39 | sizingZoneIdf->setString(Sizing_ZoneFields::DesignSpecificationOutdoorAirObjectName, dsoaObject.nameString()); |
| 961 | 140 | } | |
| 962 | |||
| 963 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 137 times.
|
140 | if (createZvs) { |
| 964 | 3 | double zvRateForPeople = 0.0; | |
| 965 | 3 | double zvRateForArea = 0.0; | |
| 966 | 3 | double zvRate = 0.0; | |
| 967 | 3 | double zvRateForVolume = 0.0; | |
| 968 | 3 | double totVolume = 0.0; | |
| 969 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 3 times.
|
9 | for (const Space& space : modelObject.spacesWithDesignSpecificationOutdoorAir()) { |
| 970 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | auto dsoa = space.designSpecificationOutdoorAir().get(); |
| 971 | |||
| 972 | // create zone ventilation if needed | ||
| 973 | // TODO: we could remove all this code if we used ZoneHVAC:IdealLoadsAirSystem instead of HVACTemplate:Zone:IdealLoadsAirSystem | ||
| 974 | // We have space level stuff, that we need to write at Zone-level. So we compute the rate for each component (per Person, Floor Area, | ||
| 975 | // absolute and ACH) by looping on spaces. Then we'll write that by dividing by the total zone number of people, floor area, 1, and volume | ||
| 976 | // This amount to computing a weighted average | ||
| 977 | |||
| 978 | // TODO: do we need the multiplier here?! | ||
| 979 | |||
| 980 |
1/1✓ Branch 1 taken 6 times.
|
6 | totVolume += space.volume(); |
| 981 | |||
| 982 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | double rateForPeople = space.numberOfPeople() * dsoa.outdoorAirFlowperPerson(); |
| 983 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | double rateForArea = space.floorArea() * dsoa.outdoorAirFlowperFloorArea(); |
| 984 |
1/1✓ Branch 1 taken 6 times.
|
6 | double rate = dsoa.outdoorAirFlowRate(); |
| 985 | // ACH * volume = m3/hour, divide by 3600 s/hr to get m3/s | ||
| 986 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | double rateForVolume = space.volume() * dsoa.outdoorAirFlowAirChangesperHour() / 3600.0; |
| 987 | |||
| 988 |
1/1✓ Branch 1 taken 6 times.
|
6 | std::string outdoorAirMethod = dsoa.outdoorAirMethod(); |
| 989 |
4/4✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 4 times.
|
12 | if (istringEqual(outdoorAirMethod, "Maximum")) { |
| 990 | |||
| 991 |
1/1✓ Branch 1 taken 2 times.
|
2 | double biggestRate = std::max({rateForPeople, rateForArea, rate, rateForVolume}); |
| 992 | |||
| 993 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (rateForPeople == biggestRate) { |
| 994 | //rateForPeople = 0.0; | ||
| 995 | ✗ | rateForArea = 0.0; | |
| 996 | ✗ | rate = 0.0; | |
| 997 | ✗ | rateForVolume = 0.0; | |
| 998 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2 | } else if (rateForArea == biggestRate) { |
| 999 | 1 | rateForPeople = 0.0; | |
| 1000 | //rateForArea = 0.0; | ||
| 1001 | 1 | rate = 0.0; | |
| 1002 | 1 | rateForVolume = 0.0; | |
| 1003 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | } else if (rate == biggestRate) { |
| 1004 | 1 | rateForPeople = 0.0; | |
| 1005 | 1 | rateForArea = 0.0; | |
| 1006 | //rate = 0.0; | ||
| 1007 | 1 | rateForVolume = 0.0; | |
| 1008 | } else { | ||
| 1009 | //rateForVolume == biggestRate | ||
| 1010 | ✗ | rateForPeople = 0.0; | |
| 1011 | ✗ | rateForArea = 0.0; | |
| 1012 | ✗ | rate = 0.0; | |
| 1013 | //rateForVolume = 0.0; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | } else { | ||
| 1017 | // sum | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | 6 | zvRateForPeople += rateForPeople; | |
| 1021 | 6 | zvRateForArea += rateForArea; | |
| 1022 | 6 | zvRate += rate; | |
| 1023 | 6 | zvRateForVolume += rateForVolume; | |
| 1024 | 9 | } | |
| 1025 | |||
| 1026 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
|
3 | if (zvRateForPeople > 0) { |
| 1027 | // TODO: improve this? | ||
| 1028 | // find first people schedule | ||
| 1029 | 2 | std::vector<People> allPeople; | |
| 1030 |
2/2✓ Branch 5 taken 5 times.
✓ Branch 6 taken 2 times.
|
7 | for (const auto& space : spaces) { |
| 1031 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 5 times.
|
9 | for (const People& people : space.people()) { |
| 1032 |
1/1✓ Branch 1 taken 4 times.
|
4 | allPeople.push_back(people); |
| 1033 | 5 | } | |
| 1034 |
2/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
10 | if (space.spaceType()) { |
| 1035 |
5/5✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 5 times.
|
7 | for (const People& people : space.spaceType()->people()) { |
| 1036 |
1/1✓ Branch 1 taken 2 times.
|
2 | allPeople.push_back(people); |
| 1037 | 5 | } | |
| 1038 | } | ||
| 1039 | } | ||
| 1040 | |||
| 1041 | 2 | boost::optional<Schedule> peopleSchedule; | |
| 1042 |
2/2✓ Branch 5 taken 6 times.
✓ Branch 6 taken 2 times.
|
8 | for (const People& people : allPeople) { |
| 1043 |
1/1✓ Branch 1 taken 6 times.
|
6 | peopleSchedule = people.numberofPeopleSchedule(); |
| 1044 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (peopleSchedule) { |
| 1045 | ✗ | break; | |
| 1046 | } | ||
| 1047 | } | ||
| 1048 | |||
| 1049 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if (!allPeople.empty()) { |
| 1050 |
1/1✓ Branch 1 taken 2 times.
|
2 | auto& zoneVentilation = m_idfObjects.emplace_back(IddObjectType::ZoneVentilation_DesignFlowRate); |
| 1051 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setName(tzName + " Ventilation per Person"); |
| 1052 |
1/1✓ Branch 1 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ZoneorZoneListorSpaceorSpaceListName, tzName); |
| 1053 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (peopleSchedule) { |
| 1054 | ✗ | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ScheduleName, peopleSchedule->nameString()); | |
| 1055 | } | ||
| 1056 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::DesignFlowRateCalculationMethod, "Flow/Person"); |
| 1057 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setDouble(ZoneVentilation_DesignFlowRateFields::FlowRateperPerson, zvRateForPeople / modelObject.numberOfPeople()); |
| 1058 | } else { | ||
| 1059 | ✗ | LOG(Warn, "No People found in ThermalZone '" << tzName << "', outdoor air per person will not be added"); | |
| 1060 | } | ||
| 1061 | 2 | } | |
| 1062 | |||
| 1063 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
|
3 | if (zvRateForArea > 0) { |
| 1064 |
1/1✓ Branch 1 taken 2 times.
|
2 | auto& zoneVentilation = m_idfObjects.emplace_back(IddObjectType::ZoneVentilation_DesignFlowRate); |
| 1065 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setName(tzName + " Ventilation per Floor Area"); |
| 1066 |
1/1✓ Branch 1 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ZoneorZoneListorSpaceorSpaceListName, tzName); |
| 1067 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ScheduleName, modelObject.model().alwaysOnDiscreteSchedule().nameString()); |
| 1068 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::DesignFlowRateCalculationMethod, "Flow/Area"); |
| 1069 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setDouble(ZoneVentilation_DesignFlowRateFields::FlowRateperFloorArea, zvRateForArea / modelObject.floorArea()); |
| 1070 | } | ||
| 1071 | |||
| 1072 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
|
3 | if (zvRate > 0) { |
| 1073 |
1/1✓ Branch 1 taken 2 times.
|
2 | auto& zoneVentilation = m_idfObjects.emplace_back(IddObjectType::ZoneVentilation_DesignFlowRate); |
| 1074 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setName(tzName + " Ventilation Rate"); |
| 1075 |
1/1✓ Branch 1 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ZoneorZoneListorSpaceorSpaceListName, tzName); |
| 1076 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ScheduleName, modelObject.model().alwaysOnDiscreteSchedule().nameString()); |
| 1077 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::DesignFlowRateCalculationMethod, "Flow/Zone"); |
| 1078 |
1/1✓ Branch 1 taken 2 times.
|
2 | zoneVentilation.setDouble(ZoneVentilation_DesignFlowRateFields::DesignFlowRate, zvRate); |
| 1079 | } | ||
| 1080 | |||
| 1081 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
|
3 | if (zvRateForVolume > 0) { |
| 1082 |
1/1✓ Branch 1 taken 2 times.
|
2 | auto& zoneVentilation = m_idfObjects.emplace_back(IddObjectType::ZoneVentilation_DesignFlowRate); |
| 1083 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setName(tzName + " Ventilation Air Changes per Hour"); |
| 1084 |
1/1✓ Branch 1 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ZoneorZoneListorSpaceorSpaceListName, tzName); |
| 1085 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::ScheduleName, modelObject.model().alwaysOnDiscreteSchedule().nameString()); |
| 1086 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | zoneVentilation.setString(ZoneVentilation_DesignFlowRateFields::DesignFlowRateCalculationMethod, "AirChanges/Hour"); |
| 1087 |
1/1✓ Branch 1 taken 2 times.
|
2 | zoneVentilation.setDouble(ZoneVentilation_DesignFlowRateFields::AirChangesperHour, 3600.0 * zvRateForVolume / totVolume); |
| 1088 | } | ||
| 1089 | } // zone.equipment().emptpy() | ||
| 1090 | 140 | } // End Sizing:Zone / ZV block | |
| 1091 | |||
| 1092 |
1/1✓ Branch 1 taken 436 times.
|
436 | return idfObject; |
| 1093 | 554 | } | |
| 1094 | |||
| 1095 | } // namespace energyplus | ||
| 1096 | |||
| 1097 | } // namespace openstudio | ||
| 1098 |