src/sdd/MapGeometry.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 "ReverseTranslator.hpp" | ||
| 7 | #include "ForwardTranslator.hpp" | ||
| 8 | #include "Helpers.hpp" | ||
| 9 | |||
| 10 | #include "../model/Model.hpp" | ||
| 11 | #include "../model/ModelObject.hpp" | ||
| 12 | #include "../model/ModelObject_Impl.hpp" | ||
| 13 | #include "../model/ConstructionBase.hpp" | ||
| 14 | #include "../model/ConstructionBase_Impl.hpp" | ||
| 15 | #include "../model/Construction.hpp" | ||
| 16 | #include "../model/Construction_Impl.hpp" | ||
| 17 | #include "../model/MasslessOpaqueMaterial.hpp" | ||
| 18 | #include "../model/MasslessOpaqueMaterial_Impl.hpp" | ||
| 19 | #include "../model/StandardOpaqueMaterial.hpp" | ||
| 20 | #include "../model/StandardOpaqueMaterial_Impl.hpp" | ||
| 21 | #include "../model/FFactorGroundFloorConstruction.hpp" | ||
| 22 | #include "../model/FFactorGroundFloorConstruction_Impl.hpp" | ||
| 23 | #include "../model/CFactorUndergroundWallConstruction.hpp" | ||
| 24 | #include "../model/CFactorUndergroundWallConstruction_Impl.hpp" | ||
| 25 | #include "../model/Building.hpp" | ||
| 26 | #include "../model/Building_Impl.hpp" | ||
| 27 | #include "../model/ThermalZone.hpp" | ||
| 28 | #include "../model/ThermalZone_Impl.hpp" | ||
| 29 | #include "../model/BuildingStory.hpp" | ||
| 30 | #include "../model/BuildingStory_Impl.hpp" | ||
| 31 | #include "../model/Space.hpp" | ||
| 32 | #include "../model/Space_Impl.hpp" | ||
| 33 | #include "../model/Surface.hpp" | ||
| 34 | #include "../model/Surface_Impl.hpp" | ||
| 35 | #include "../model/SubSurface.hpp" | ||
| 36 | #include "../model/SubSurface_Impl.hpp" | ||
| 37 | #include "../model/ShadingSurface.hpp" | ||
| 38 | #include "../model/ShadingSurface_Impl.hpp" | ||
| 39 | #include "../model/ShadingSurfaceGroup.hpp" | ||
| 40 | #include "../model/ShadingSurfaceGroup_Impl.hpp" | ||
| 41 | #include "../model/PeopleDefinition.hpp" | ||
| 42 | #include "../model/People.hpp" | ||
| 43 | #include "../model/LightsDefinition.hpp" | ||
| 44 | #include "../model/Lights.hpp" | ||
| 45 | #include "../model/ElectricEquipmentDefinition.hpp" | ||
| 46 | #include "../model/ElectricEquipment.hpp" | ||
| 47 | #include "../model/GasEquipmentDefinition.hpp" | ||
| 48 | #include "../model/GasEquipment.hpp" | ||
| 49 | #include "../model/HotWaterEquipmentDefinition.hpp" | ||
| 50 | #include "../model/HotWaterEquipment.hpp" | ||
| 51 | #include "../model/DesignSpecificationOutdoorAir.hpp" | ||
| 52 | #include "../model/SpaceInfiltrationDesignFlowRate.hpp" | ||
| 53 | #include "../model/Schedule.hpp" | ||
| 54 | #include "../model/Schedule_Impl.hpp" | ||
| 55 | #include "../model/ScheduleDay.hpp" | ||
| 56 | #include "../model/ScheduleDay_Impl.hpp" | ||
| 57 | #include "../model/ScheduleConstant.hpp" | ||
| 58 | #include "../model/ScheduleConstant_Impl.hpp" | ||
| 59 | #include "../model/ScheduleRuleset.hpp" | ||
| 60 | #include "../model/ScheduleRuleset_Impl.hpp" | ||
| 61 | #include "../model/ScheduleTypeLimits.hpp" | ||
| 62 | #include "../model/ScheduleTypeLimits_Impl.hpp" | ||
| 63 | #include "../model/SurfacePropertyConvectionCoefficients.hpp" | ||
| 64 | #include "../model/SurfacePropertyConvectionCoefficients_Impl.hpp" | ||
| 65 | #include "../model/PlantLoop.hpp" | ||
| 66 | #include "../model/PlantLoop_Impl.hpp" | ||
| 67 | #include "../model/WaterUseConnections.hpp" | ||
| 68 | #include "../model/WaterUseConnections_Impl.hpp" | ||
| 69 | #include "../model/WaterUseEquipment.hpp" | ||
| 70 | #include "../model/WaterUseEquipment_Impl.hpp" | ||
| 71 | #include "../model/WaterUseEquipmentDefinition.hpp" | ||
| 72 | #include "../model/WaterUseEquipmentDefinition_Impl.hpp" | ||
| 73 | #include "../model/ThermostatSetpointDualSetpoint.hpp" | ||
| 74 | #include "../model/AirLoopHVAC.hpp" | ||
| 75 | #include "../model/AirLoopHVAC_Impl.hpp" | ||
| 76 | |||
| 77 | #include "../utilities/geometry/Transformation.hpp" | ||
| 78 | #include "../utilities/geometry/Geometry.hpp" | ||
| 79 | #include "../utilities/units/QuantityConverter.hpp" | ||
| 80 | #include "../utilities/units/Quantity.hpp" | ||
| 81 | #include "../utilities/units/IPUnit.hpp" | ||
| 82 | #include "../utilities/units/SIUnit.hpp" | ||
| 83 | #include "../utilities/units/BTUUnit.hpp" | ||
| 84 | #include "../utilities/units/MPHUnit.hpp" | ||
| 85 | #include "../utilities/units/WhUnit.hpp" | ||
| 86 | #include "../utilities/units/UnitFactory.hpp" | ||
| 87 | #include "../utilities/units/TemperatureUnit.hpp" | ||
| 88 | #include "../utilities/units/TemperatureUnit_Impl.hpp" | ||
| 89 | #include "../utilities/plot/ProgressBar.hpp" | ||
| 90 | #include "../utilities/core/Assert.hpp" | ||
| 91 | #include "../utilities/core/StringHelpers.hpp" | ||
| 92 | |||
| 93 | #include <pugixml.hpp> | ||
| 94 | |||
| 95 | namespace openstudio { | ||
| 96 | namespace sdd { | ||
| 97 | |||
| 98 | constexpr double footToMeter = 0.3048; | ||
| 99 | constexpr double meterToFoot = 1.0 / 0.3048; | ||
| 100 | |||
| 101 | 150 | pugi::xml_node elementByTagNameAndIndex(const pugi::xml_node& root, const std::string& tagName, boost::optional<int> _index) { | |
| 102 | |||
| 103 |
1/1✓ Branch 1 taken 150 times.
|
150 | pugi::xml_node result; |
| 104 |
1/2✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
|
150 | if (_index) { |
| 105 | |||
| 106 |
4/6✓ Branch 2 taken 150 times.
✓ Branch 7 taken 150 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 150 times.
✓ Branch 15 taken 150 times.
✗ Branch 16 not taken.
|
150 | for (const pugi::xml_node& e : root.children(tagName.c_str())) { |
| 107 | // Check if the node has an attribute 'id' that is an int *and* matches the one we seek | ||
| 108 |
2/2✓ Branch 1 taken 150 times.
✓ Branch 4 taken 150 times.
|
150 | boost::optional<int> _thisIndex = lexicalCastToInt(e.attribute("index")); |
| 109 |
5/8✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 150 times.
✓ Branch 6 taken 150 times.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 150 times.
✗ Branch 11 not taken.
|
150 | if (_thisIndex && (_thisIndex.get() == _index.get())) { |
| 110 | 150 | result = e; | |
| 111 | 150 | break; | |
| 112 | } | ||
| 113 | } | ||
| 114 | } else { | ||
| 115 | // return first child (should be unique) | ||
| 116 | ✗ | result = root.child(tagName.c_str()); | |
| 117 | } | ||
| 118 | 150 | return result; | |
| 119 | } | ||
| 120 | |||
| 121 | 1 | boost::optional<model::ModelObject> ReverseTranslator::translateBuilding(const pugi::xml_node& element, openstudio::model::Model& model) { | |
| 122 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::model::Building building = model.getUniqueModelObject<openstudio::model::Building>(); |
| 123 | |||
| 124 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node nameElement = element.child("Name"); |
| 125 | |||
| 126 | // http://code.google.com/p/cbecc/issues/detail?id=378 | ||
| 127 | // The angle between the model Y-Axis and True North, measured clockwise from the model Y-Axis in Degrees. | ||
| 128 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node northAngleElement = element.child("NAng"); |
| 129 | // The angle between True North and the the model Y-Axis, measured clockwise from True North in Degrees. | ||
| 130 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node buildingAzimuthElement = element.child("BldgAz"); // this corresponds to Building::North Axis |
| 131 | |||
| 132 | // TODO: do we want to check if key Name is present or whether Name is not an empty string? | ||
| 133 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
1 | if (!nameElement) { |
| 134 | ✗ | LOG(Error, "Bldg element 'Name' is empty.") | |
| 135 | } else { | ||
| 136 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | std::string bldgname = nameElement.text().as_string(); |
| 137 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (bldgname.empty()) { |
| 138 | ✗ | LOG(Error, "Bldg element 'Name' is empty.") | |
| 139 | } else { | ||
| 140 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | building.setName(escapeName(bldgname)); |
| 141 | } | ||
| 142 | 1 | } | |
| 143 | |||
| 144 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | if (buildingAzimuthElement) { |
| 145 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | double buildingAzimuth = normalizeAngle0to360(buildingAzimuthElement.text().as_double()); |
| 146 |
1/1✓ Branch 1 taken 1 time.
|
1 | building.setNorthAxis(buildingAzimuth); |
| 147 | ✗ | } else if (northAngleElement) { | |
| 148 | // use NAng for backwards compatibility with SDD's only having NAng | ||
| 149 | ✗ | double northAngle = normalizeAngle0to360(northAngleElement.text().as_double()); | |
| 150 | ✗ | double buildingAzimuth = 360.0 - northAngle; | |
| 151 | ✗ | building.setNorthAxis(buildingAzimuth); | |
| 152 | } | ||
| 153 | |||
| 154 | // translate shadingSurfaces | ||
| 155 |
1/1✓ Branch 1 taken 1 time.
|
1 | std::vector<pugi::xml_node> exteriorShadingElements = makeVectorOfChildren(element, "ExtShdgObj"); |
| 156 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!exteriorShadingElements.empty()) { |
| 157 | ✗ | model::ShadingSurfaceGroup shadingSurfaceGroup(model); | |
| 158 | ✗ | shadingSurfaceGroup.setName("Building ShadingGroup"); | |
| 159 | ✗ | shadingSurfaceGroup.setShadingSurfaceType("Building"); | |
| 160 | ✗ | for (std::vector<pugi::xml_node>::size_type i = 0; i < exteriorShadingElements.size(); ++i) { | |
| 161 | ✗ | if (exteriorShadingElements[i].parent() == element) { | |
| 162 | ✗ | boost::optional<model::ModelObject> exteriorShading = translateShadingSurface(exteriorShadingElements[i], shadingSurfaceGroup); | |
| 163 | ✗ | if (!exteriorShading) { | |
| 164 | ✗ | LOG(Error, "Failed to translate 'ExtShdgObj' element " << i); | |
| 165 | } | ||
| 166 | ✗ | } | |
| 167 | } | ||
| 168 | ✗ | } | |
| 169 | |||
| 170 |
1/1✓ Branch 1 taken 1 time.
|
1 | std::vector<pugi::xml_node> thermalZoneElements = makeVectorOfChildren(element, "ThrmlZn"); |
| 171 | |||
| 172 | // It **Must** to be recursive here, since Spc lives inside Story and there are multiple stories | ||
| 173 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::vector<pugi::xml_node> spaceElements = makeVectorOfChildrenRecursive(element, "Spc"); |
| 174 | |||
| 175 |
1/1✓ Branch 1 taken 1 time.
|
1 | std::vector<pugi::xml_node> buildingStoryElements = makeVectorOfChildren(element, "Story"); |
| 176 | |||
| 177 | // OR: | ||
| 178 | /* | ||
| 179 | std::vector<pugi::xml_node> spaceElements; | ||
| 180 | for (const pugi::xml_node& buildingStoryElement: buildingStoryElements) { | ||
| 181 | for (const pugi::xml_node& spaceElement: buildingStoryElement.children("Spc")) { | ||
| 182 | spaceElements.push_back(spaceElement); | ||
| 183 | } | ||
| 184 | } | ||
| 185 | */ | ||
| 186 | |||
| 187 | // create all spaces | ||
| 188 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 2 taken 1 time.
|
26 | for (std::vector<pugi::xml_node>::size_type i = 0; i < spaceElements.size(); i++) { |
| 189 | 25 | pugi::xml_node spaceElement = spaceElements[i]; | |
| 190 |
1/1✓ Branch 1 taken 25 times.
|
25 | boost::optional<model::ModelObject> space = createSpace(spaceElement, model); |
| 191 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if (!space) { |
| 192 | ✗ | LOG(Error, "Failed to translate 'Spc' element " << i << ", named:" << spaceElement.child("Name").text().as_string()); | |
| 193 | } | ||
| 194 | 25 | } | |
| 195 | |||
| 196 | // create all thermal zones | ||
| 197 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 2 taken 1 time.
|
26 | for (std::vector<pugi::xml_node>::size_type i = 0; i < thermalZoneElements.size(); i++) { |
| 198 | |||
| 199 | // TODO: check already exists inside createThermalZone, this is redundant | ||
| 200 |
3/4✓ Branch 2 taken 25 times.
✓ Branch 5 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
|
25 | if (!thermalZoneElements[i].child("Name")) { |
| 201 | ✗ | LOG(Error, "ThrmlZn element 'Name' is empty, object will not be translated.") | |
| 202 | ✗ | continue; | |
| 203 | ✗ | } | |
| 204 | |||
| 205 |
1/1✓ Branch 2 taken 25 times.
|
25 | boost::optional<model::ModelObject> thermalZone = createThermalZone(thermalZoneElements[i], model); |
| 206 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if (!thermalZone) { |
| 207 | ✗ | LOG(Error, "Failed to translate 'ThrmlZn' element " << i); | |
| 208 | } | ||
| 209 | 25 | } | |
| 210 | |||
| 211 | // translate building stories | ||
| 212 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 213 | ✗ | m_progressBar->setWindowTitle(toString("Translating Storys")); | |
| 214 | ✗ | m_progressBar->setMinimum(0); | |
| 215 | ✗ | m_progressBar->setMaximum(buildingStoryElements.size()); | |
| 216 | ✗ | m_progressBar->setValue(0); | |
| 217 | } | ||
| 218 | |||
| 219 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 time.
|
6 | for (std::vector<pugi::xml_node>::size_type i = 0; i < buildingStoryElements.size(); i++) { |
| 220 |
1/1✓ Branch 2 taken 5 times.
|
5 | boost::optional<model::ModelObject> buildingStory = translateBuildingStory(buildingStoryElements[i], model); |
| 221 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (!buildingStory) { |
| 222 | ✗ | LOG(Error, "Failed to translate 'Story' element " << i); | |
| 223 | } | ||
| 224 | |||
| 225 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | if (m_progressBar) { |
| 226 | ✗ | m_progressBar->setValue(m_progressBar->value() + 1); | |
| 227 | } | ||
| 228 | 5 | } | |
| 229 | |||
| 230 | // remove unused CFactor constructions | ||
| 231 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 7 taken 5 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 1 time.
|
6 | for (model::CFactorUndergroundWallConstruction cFactorConstruction : model.getConcreteModelObjects<model::CFactorUndergroundWallConstruction>()) { |
| 232 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 4 times.
|
5 | if (cFactorConstruction.directUseCount(true) == 0) { |
| 233 |
1/1✓ Branch 1 taken 1 time.
|
1 | cFactorConstruction.remove(); |
| 234 | } | ||
| 235 | 6 | } | |
| 236 | |||
| 237 | // remove unused FFactor constructions | ||
| 238 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 7 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 1 time.
|
3 | for (model::FFactorGroundFloorConstruction fFactorConstruction : model.getConcreteModelObjects<model::FFactorGroundFloorConstruction>()) { |
| 239 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | if (fFactorConstruction.directUseCount(true) == 0) { |
| 240 |
1/1✓ Branch 1 taken 1 time.
|
1 | fFactorConstruction.remove(); |
| 241 | } | ||
| 242 | 3 | } | |
| 243 | |||
| 244 |
1/1✓ Branch 1 taken 1 time.
|
2 | return building; |
| 245 | 1 | } | |
| 246 | |||
| 247 | 25 | boost::optional<openstudio::model::ModelObject> ReverseTranslator::createThermalZone(const pugi::xml_node& element, | |
| 248 | openstudio::model::Model& model) { | ||
| 249 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node nameElement = element.child("Name"); |
| 250 | |||
| 251 |
1/1✓ Branch 1 taken 25 times.
|
25 | model::ThermalZone thermalZone(model); |
| 252 | |||
| 253 |
2/3✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
|
25 | if (!nameElement) { |
| 254 | ✗ | LOG(Error, "ThrmlZn element 'Name' is missing."); | |
| 255 | } else { | ||
| 256 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | std::string tzname = nameElement.text().as_string(); |
| 257 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if (tzname.empty()) { |
| 258 | ✗ | LOG(Error, "ThrmlZn element 'Name' is empty."); | |
| 259 | } else { | ||
| 260 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | thermalZone.setName(escapeName(tzname)); |
| 261 | } | ||
| 262 | 25 | } | |
| 263 | |||
| 264 |
1/1✓ Branch 1 taken 25 times.
|
50 | return thermalZone; |
| 265 | 25 | } | |
| 266 | |||
| 267 | 5 | boost::optional<openstudio::model::ModelObject> ReverseTranslator::translateBuildingStory(const pugi::xml_node& element, | |
| 268 | openstudio::model::Model& model) { | ||
| 269 |
1/1✓ Branch 1 taken 5 times.
|
5 | pugi::xml_node nameElement = element.child("Name"); |
| 270 |
1/1✓ Branch 1 taken 5 times.
|
5 | std::vector<pugi::xml_node> spaceElements = makeVectorOfChildren(element, "Spc"); |
| 271 | |||
| 272 |
1/1✓ Branch 1 taken 5 times.
|
5 | model::BuildingStory buildingStory(model); |
| 273 | |||
| 274 |
2/3✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
|
5 | if (!nameElement) { |
| 275 | ✗ | LOG(Error, "Story element 'Name' is missing."); | |
| 276 | } else { | ||
| 277 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | std::string name = nameElement.text().as_string(); |
| 278 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (name.empty()) { |
| 279 | ✗ | LOG(Error, "Story element 'Name' is empty."); | |
| 280 | } else { | ||
| 281 |
1/1✓ Branch 1 taken 5 times.
|
5 | buildingStory.setName(name); |
| 282 | } | ||
| 283 | 5 | } | |
| 284 | |||
| 285 |
1/1✓ Branch 1 taken 5 times.
|
5 | std::string name = buildingStory.nameString(); |
| 286 | |||
| 287 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 2 taken 5 times.
|
30 | for (std::vector<pugi::xml_node>::size_type i = 0; i < spaceElements.size(); i++) { |
| 288 | 25 | pugi::xml_node spaceElement = spaceElements[i]; | |
| 289 |
1/1✓ Branch 1 taken 25 times.
|
25 | boost::optional<model::ModelObject> space = translateSpace(spaceElement, buildingStory); |
| 290 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if (!space) { |
| 291 | ✗ | LOG(Error, "Failed to translate 'Spc' element " << i << " under Story '" << name << "'"); | |
| 292 | } | ||
| 293 | 25 | } | |
| 294 | |||
| 295 |
1/1✓ Branch 1 taken 5 times.
|
10 | return buildingStory; |
| 296 | 5 | } | |
| 297 | |||
| 298 | 25 | boost::optional<model::ModelObject> ReverseTranslator::createSpace(const pugi::xml_node& element, openstudio::model::Model& model) { | |
| 299 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node nameElement = element.child("Name"); |
| 300 | |||
| 301 | // TODO: move into block where we do set the name no? | ||
| 302 |
1/1✓ Branch 1 taken 25 times.
|
25 | model::Space space(model); |
| 303 | |||
| 304 |
2/3✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
|
25 | if (!nameElement) { |
| 305 | ✗ | LOG(Error, "Spc element 'Name' is missing."); | |
| 306 | } else { | ||
| 307 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | std::string name = nameElement.text().as_string(); |
| 308 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if (name.empty()) { |
| 309 | ✗ | LOG(Error, "Spc element 'Name' is empty."); | |
| 310 | } else { | ||
| 311 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | space.setName(escapeName(name)); |
| 312 | } | ||
| 313 | 25 | } | |
| 314 | |||
| 315 |
1/1✓ Branch 1 taken 25 times.
|
50 | return space; |
| 316 | 25 | } | |
| 317 | |||
| 318 | 25 | boost::optional<model::ModelObject> ReverseTranslator::translateSpace(const pugi::xml_node& element, | |
| 319 | openstudio::model::BuildingStory& buildingStory) { | ||
| 320 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node nameElement = element.child("Name"); |
| 321 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node hotWtrHtgRtElement = element.child("HotWtrHtgRtSim"); |
| 322 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node hotWtrHtgSchRefElement = element.child("HotWtrHtgSchRef"); |
| 323 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node shwFluidSegRefElement = element.child("SHWFluidSegRef"); |
| 324 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node hotWtrSupTempElement = element.child("HotWtrSupTemp"); |
| 325 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> exteriorWallElements = makeVectorOfChildren(element, "ExtWall"); |
| 326 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> exteriorFloorElements = makeVectorOfChildren(element, "ExtFlr"); |
| 327 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> roofElements = makeVectorOfChildren(element, "Roof"); |
| 328 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> undergroundFloorElements = makeVectorOfChildren(element, "UndgrFlr"); |
| 329 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> undergroundWallElements = makeVectorOfChildren(element, "UndgrWall"); |
| 330 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> ceilingElements = makeVectorOfChildren(element, "Ceiling"); |
| 331 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> interiorWallElements = makeVectorOfChildren(element, "IntWall"); |
| 332 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> interiorFloorElements = makeVectorOfChildren(element, "IntFlr"); |
| 333 | |||
| 334 | 25 | std::string spaceName; | |
| 335 | |||
| 336 |
2/3✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
|
25 | if (!nameElement) { |
| 337 | ✗ | LOG(Error, "Spc element 'Name' is missing."); | |
| 338 | } else { | ||
| 339 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | std::string name = nameElement.text().as_string(); |
| 340 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if (name.empty()) { |
| 341 | ✗ | LOG(Error, "Spc element 'Name' is empty."); | |
| 342 | } else { | ||
| 343 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | spaceName = escapeName(name); |
| 344 | } | ||
| 345 | 25 | } | |
| 346 | |||
| 347 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | boost::optional<model::Space> space = buildingStory.model().getConcreteModelObjectByName<model::Space>(spaceName); |
| 348 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if (!space) { |
| 349 | ✗ | LOG(Error, "Could not retrieve Space named '" << spaceName << "'."); | |
| 350 | ✗ | return boost::none; | |
| 351 | } | ||
| 352 | |||
| 353 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | space->setBuildingStory(buildingStory); |
| 354 | |||
| 355 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node thermalZoneElement = element.child("ThrmlZnRef"); |
| 356 | 25 | std::string thermalZoneName; | |
| 357 |
2/3✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
|
25 | if (!thermalZoneElement) { |
| 358 | ✗ | LOG(Error, "Spc element 'ThrmlZnRef' is empty for Space named '" << spaceName << "'."); | |
| 359 | } else { | ||
| 360 |
4/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
|
25 | thermalZoneName = escapeName(thermalZoneElement.text().as_string()); |
| 361 | } | ||
| 362 | |||
| 363 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | boost::optional<model::ThermalZone> thermalZone = space->model().getConcreteModelObjectByName<model::ThermalZone>(thermalZoneName); |
| 364 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | if (thermalZone) { |
| 365 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | space->setThermalZone(*thermalZone); |
| 366 | } else { | ||
| 367 | ✗ | LOG(Error, "Could not retrieve ThermalZone named '" << thermalZoneName << "'."); | |
| 368 | ✗ | LOG(Error, "ThermalZone not set for Space named '" << spaceName << "'."); | |
| 369 | } | ||
| 370 | |||
| 371 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | translateLoads(element, *space); |
| 372 | |||
| 373 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 2 taken 25 times.
|
57 | for (std::vector<pugi::xml_node>::size_type i = 0; i < exteriorWallElements.size(); i++) { |
| 374 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 5 taken 32 times.
|
32 | boost::optional<model::ModelObject> surface = translateSurface(exteriorWallElements[i], *space); |
| 375 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
|
32 | if (!surface) { |
| 376 | ✗ | LOG(Error, "Failed to translate 'ExtWall' element " << i << " for Space named '" << spaceName << "'."); | |
| 377 | } | ||
| 378 | 32 | } | |
| 379 | |||
| 380 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | for (std::vector<pugi::xml_node>::size_type i = 0; i < exteriorFloorElements.size(); i++) { |
| 381 | ✗ | boost::optional<model::ModelObject> surface = translateSurface(exteriorFloorElements[i], *space); | |
| 382 | ✗ | if (!surface) { | |
| 383 | ✗ | LOG(Error, "Failed to translate 'ExtFlr' element " << i << " for Space named '" << spaceName << "'."); | |
| 384 | } | ||
| 385 | ✗ | } | |
| 386 | |||
| 387 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 25 times.
|
26 | for (std::vector<pugi::xml_node>::size_type i = 0; i < roofElements.size(); i++) { |
| 388 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
|
1 | boost::optional<model::ModelObject> surface = translateSurface(roofElements[i], *space); |
| 389 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!surface) { |
| 390 | ✗ | LOG(Error, "Failed to translate 'Roof' element " << i << " for Space named '" << spaceName << "'."); | |
| 391 | } | ||
| 392 | 1 | } | |
| 393 | |||
| 394 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 25 times.
|
26 | for (std::vector<pugi::xml_node>::size_type i = 0; i < undergroundFloorElements.size(); i++) { |
| 395 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
|
1 | boost::optional<model::ModelObject> surface = translateSurface(undergroundFloorElements[i], *space); |
| 396 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!surface) { |
| 397 | ✗ | LOG(Error, "Failed to translate 'UndgrFlr' element " << i << " for Space named '" << spaceName << "'."); | |
| 398 | } | ||
| 399 | 1 | } | |
| 400 | |||
| 401 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 25 times.
|
29 | for (std::vector<pugi::xml_node>::size_type i = 0; i < undergroundWallElements.size(); i++) { |
| 402 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
|
4 | boost::optional<model::ModelObject> surface = translateSurface(undergroundWallElements[i], *space); |
| 403 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if (!surface) { |
| 404 | ✗ | LOG(Error, "Failed to translate 'UndgrWall' element " << i << " for Space named '" << spaceName << "'."); | |
| 405 | } | ||
| 406 | 4 | } | |
| 407 | |||
| 408 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | for (std::vector<pugi::xml_node>::size_type i = 0; i < ceilingElements.size(); i++) { |
| 409 | ✗ | boost::optional<model::ModelObject> surface = translateSurface(ceilingElements[i], *space); | |
| 410 | ✗ | if (!surface) { | |
| 411 | ✗ | LOG(Error, "Failed to translate 'Ceiling' element " << i << " for Space named '" << spaceName << "'."); | |
| 412 | } | ||
| 413 | ✗ | } | |
| 414 | |||
| 415 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 2 taken 25 times.
|
57 | for (std::vector<pugi::xml_node>::size_type i = 0; i < interiorWallElements.size(); i++) { |
| 416 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 5 taken 32 times.
|
32 | boost::optional<model::ModelObject> surface = translateSurface(interiorWallElements[i], *space); |
| 417 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
|
32 | if (!surface) { |
| 418 | ✗ | LOG(Error, "Failed to translate 'IntWall' element " << i << " for Space named '" << spaceName << "'."); | |
| 419 | } | ||
| 420 | 32 | } | |
| 421 | |||
| 422 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 2 taken 25 times.
|
65 | for (std::vector<pugi::xml_node>::size_type i = 0; i < interiorFloorElements.size(); i++) { |
| 423 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 5 taken 40 times.
|
40 | boost::optional<model::ModelObject> surface = translateSurface(interiorFloorElements[i], *space); |
| 424 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
|
40 | if (!surface) { |
| 425 | ✗ | LOG(Error, "Failed to translate 'IntFlr' element " << i << " for Space named '" << spaceName << "'."); | |
| 426 | } | ||
| 427 | 40 | } | |
| 428 | |||
| 429 | // translate shadingSurfaces | ||
| 430 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> exteriorShadingElements = makeVectorOfChildren(element, "ExtShdgObj"); |
| 431 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | model::ShadingSurfaceGroup shadingSurfaceGroup(space->model()); |
| 432 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | shadingSurfaceGroup.setName(spaceName + " ShadingGroup"); |
| 433 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | shadingSurfaceGroup.setSpace(*space); |
| 434 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | for (std::vector<pugi::xml_node>::size_type i = 0; i < exteriorShadingElements.size(); ++i) { |
| 435 | ✗ | if (exteriorShadingElements[i].parent() == element) { | |
| 436 | ✗ | boost::optional<model::ModelObject> exteriorShading = translateShadingSurface(exteriorShadingElements[i], shadingSurfaceGroup); | |
| 437 | ✗ | if (!exteriorShading) { | |
| 438 | ✗ | LOG(Error, "Failed to translate 'ExtShdgObj' element " << i << " for Space named '" << spaceName << "'."); | |
| 439 | } | ||
| 440 | ✗ | } | |
| 441 | } | ||
| 442 | |||
| 443 | // DLM: volume is now a property associated with Thermal Zone, http://code.google.com/p/cbecc/issues/detail?id=490 | ||
| 444 | //// volume | ||
| 445 | //if (volElement){ | ||
| 446 | // // sdd units = ft^3, os units = m^3 | ||
| 447 | // Quantity spaceVolumeIP(volElement.text().as_double(), BTUUnit(BTUExpnt(0,3,0,0))); | ||
| 448 | // OptionalQuantity spaceVolumeSI = QuantityConverter::instance().convert(spaceVolumeIP, UnitSystem(UnitSystem::Wh)); | ||
| 449 | // OS_ASSERT(spaceVolumeSI); | ||
| 450 | // OS_ASSERT(spaceVolumeSI->units() == WhUnit(WhExpnt(0,0,3,0))); | ||
| 451 | // | ||
| 452 | // if (thermalZone->isVolumeDefaulted()){ | ||
| 453 | // thermalZone->setVolume(spaceVolumeSI->value()); | ||
| 454 | // }else{ | ||
| 455 | // boost::optional<double> zoneVolume = thermalZone->volume(); | ||
| 456 | // OS_ASSERT(zoneVolume); | ||
| 457 | // zoneVolume = *zoneVolume + spaceVolumeSI->value(); | ||
| 458 | // thermalZone->setVolume(zoneVolume); | ||
| 459 | // } | ||
| 460 | //} | ||
| 461 | |||
| 462 | // Service Hot Water | ||
| 463 | |||
| 464 |
1/1✓ Branch 1 taken 25 times.
|
25 | boost::optional<double> _d = lexicalCastToDouble(hotWtrHtgRtElement); |
| 465 | |||
| 466 |
1/1✓ Branch 1 taken 25 times.
|
25 | model::Model model = buildingStory.model(); |
| 467 | |||
| 468 | 25 | boost::optional<model::PlantLoop> shwSys; | |
| 469 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 4 times.
|
25 | if (shwFluidSegRefElement) { |
| 470 |
1/1✓ Branch 1 taken 21 times.
|
21 | shwSys = serviceHotWaterLoopForSupplySegment(shwFluidSegRefElement, model); |
| 471 | } | ||
| 472 | |||
| 473 |
5/6✓ Branch 0 taken 21 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 4 times.
|
46 | if (_d && shwSys) { |
| 474 |
1/1✓ Branch 1 taken 21 times.
|
21 | model::WaterUseConnections connections(model); |
| 475 | |||
| 476 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | connections.setName(spaceName + " Water Use Connection"); |
| 477 | |||
| 478 |
1/1✓ Branch 1 taken 21 times.
|
21 | model::WaterUseEquipmentDefinition definition(model); |
| 479 | |||
| 480 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | definition.setName(spaceName + " Water Use Definition"); |
| 481 | |||
| 482 |
6/6✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 13 taken 21 times.
✓ Branch 16 taken 21 times.
|
63 | definition.setPeakFlowRate(unitToUnit(_d.get(), "gal/h", "m^3/s").get()); |
| 483 | |||
| 484 |
1/1✓ Branch 1 taken 21 times.
|
21 | _d = lexicalCastToDouble(hotWtrSupTempElement); |
| 485 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if (_d) { |
| 486 |
5/5✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 13 taken 21 times.
|
63 | double value = unitToUnit(_d.get(), "F", "C").get(); |
| 487 |
1/1✓ Branch 1 taken 21 times.
|
21 | model::ScheduleRuleset schedule(model); |
| 488 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | schedule.setName(spaceName + " Target SHW Temp"); |
| 489 |
1/1✓ Branch 1 taken 21 times.
|
21 | auto scheduleDay = schedule.defaultDaySchedule(); |
| 490 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | scheduleDay.addValue(Time(1.0), value); |
| 491 |
1/1✓ Branch 1 taken 21 times.
|
21 | definition.setTargetTemperatureSchedule(schedule); |
| 492 | 21 | } | |
| 493 | |||
| 494 |
1/1✓ Branch 1 taken 21 times.
|
21 | model::WaterUseEquipment equipment(definition); |
| 495 | |||
| 496 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | equipment.setName(spaceName + " Water Use Equipment"); |
| 497 | |||
| 498 |
5/6✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 14 taken 21 times.
✗ Branch 15 not taken.
|
42 | if (boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(hotWtrHtgSchRefElement.text().as_string())) { |
| 499 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | equipment.setFlowRateFractionSchedule(schedule.get()); |
| 500 | 21 | } | |
| 501 | |||
| 502 |
1/1✓ Branch 1 taken 21 times.
|
21 | connections.addWaterUseEquipment(equipment); |
| 503 | |||
| 504 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | shwSys->addDemandBranchForComponent(connections); |
| 505 | 21 | } | |
| 506 | |||
| 507 |
1/1✓ Branch 1 taken 25 times.
|
25 | return boost::optional<model::ModelObject>(space); |
| 508 | 25 | } | |
| 509 | |||
| 510 | 25 | boost::optional<openstudio::model::ModelObject> ReverseTranslator::translateLoads(const pugi::xml_node& element, openstudio::model::Space& space) { | |
| 511 | // element is 'Spc' here | ||
| 512 | |||
| 513 |
1/1✓ Branch 1 taken 25 times.
|
25 | UnitSystem siSys(UnitSystem::SI); |
| 514 |
1/1✓ Branch 1 taken 25 times.
|
25 | UnitSystem whSys(UnitSystem::Wh); |
| 515 | |||
| 516 |
1/1✓ Branch 1 taken 25 times.
|
25 | openstudio::model::Model model = space.model(); |
| 517 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | std::string name = space.name().get(); |
| 518 | |||
| 519 | // DLM: what to do with these? | ||
| 520 | //<SpcOcc>Office - Open</SpcOcc> | ||
| 521 | //<SchOcc>Table G-I Office Occupancy</SchOcc> | ||
| 522 | |||
| 523 | //***** OCCUPANCY ***** | ||
| 524 | { | ||
| 525 | //<OccDens>6.67</OccDens> - person per thousand ft2 | ||
| 526 | //<OccSensHtRt>250</OccSensHtRt> - Btu per h person | ||
| 527 | //<OccLatHtRt>200</OccLatHtRt> - Btu per h person | ||
| 528 | //<OccSchRef>Office Occup Sched</OccSchRef> | ||
| 529 | |||
| 530 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node occDensElement = element.child("OccDensSim"); |
| 531 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node occSensHtRtElement = element.child("OccSensHtRt"); |
| 532 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node occLatHtRtElement = element.child("OccLatHtRt"); |
| 533 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node occSchRefElement = element.child("OccSchRef"); |
| 534 | |||
| 535 |
8/9✓ Branch 1 taken 25 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 21 times.
✓ Branch 9 taken 21 times.
✓ Branch 11 taken 21 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 21 times.
✓ Branch 14 taken 4 times.
|
25 | if ((occDensElement != nullptr) && (occDensElement.text().as_double() > 0)) { |
| 536 |
5/8✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 21 times.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
21 | if (occSensHtRtElement && occLatHtRtElement) { |
| 537 | |||
| 538 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::Quantity peopleDensityIP(occDensElement.text().as_double() / 1000.0, |
| 539 |
6/6✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 13 taken 21 times.
✓ Branch 16 taken 21 times.
|
63 | openstudio::createUnit("people/ft^2", UnitSystem::BTU).get()); |
| 540 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | OptionalQuantity peopleDensitySI = QuantityConverter::instance().convert(peopleDensityIP, whSys); |
| 541 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 4 not taken.
|
21 | OS_ASSERT(peopleDensitySI); |
| 542 |
6/8✓ Branch 1 taken 21 times.
✓ Branch 5 taken 21 times.
✓ Branch 8 taken 21 times.
✓ Branch 11 taken 21 times.
✓ Branch 14 taken 21 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 21 times.
✗ Branch 19 not taken.
|
21 | OS_ASSERT(peopleDensitySI->units() == WhUnit(WhExpnt(0, 0, -2, 0, 0, 0, 0, 0, 0, 1))); |
| 543 | |||
| 544 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::model::PeopleDefinition peopleDefinition(model); |
| 545 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | peopleDefinition.setName(name + " People Definition"); |
| 546 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | peopleDefinition.setPeopleperSpaceFloorArea(peopleDensitySI->value()); // people/m2 |
| 547 | |||
| 548 | ✗ | openstudio::Quantity sensibleHeatRateIP(occSensHtRtElement.text().as_double(), | |
| 549 |
7/7✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 13 taken 21 times.
✓ Branch 16 taken 21 times.
✓ Branch 19 taken 21 times.
|
42 | openstudio::createUnit("Btu/h*person", UnitSystem::BTU).get()); |
| 550 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | OptionalQuantity sensibleHeatRateSI = QuantityConverter::instance().convert(sensibleHeatRateIP, whSys); |
| 551 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 4 not taken.
|
21 | OS_ASSERT(sensibleHeatRateSI); |
| 552 |
6/8✓ Branch 1 taken 21 times.
✓ Branch 5 taken 21 times.
✓ Branch 8 taken 21 times.
✓ Branch 11 taken 21 times.
✓ Branch 14 taken 21 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 21 times.
✗ Branch 19 not taken.
|
21 | OS_ASSERT(sensibleHeatRateSI->units() == WhUnit(WhExpnt(1, 0, 0, 0, 0, 0, 0, 0, 0, -1))); |
| 553 | |||
| 554 |
7/7✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 13 taken 21 times.
✓ Branch 16 taken 21 times.
✓ Branch 19 taken 21 times.
|
42 | openstudio::Quantity latentHeatRateIP(occLatHtRtElement.text().as_double(), openstudio::createUnit("Btu/h*person", UnitSystem::BTU).get()); |
| 555 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | OptionalQuantity latentHeatRateSI = QuantityConverter::instance().convert(latentHeatRateIP, whSys); |
| 556 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 4 not taken.
|
21 | OS_ASSERT(latentHeatRateSI); |
| 557 |
6/8✓ Branch 1 taken 21 times.
✓ Branch 5 taken 21 times.
✓ Branch 8 taken 21 times.
✓ Branch 11 taken 21 times.
✓ Branch 14 taken 21 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 21 times.
✗ Branch 19 not taken.
|
21 | OS_ASSERT(latentHeatRateSI->units() == WhUnit(WhExpnt(1, 0, 0, 0, 0, 0, 0, 0, 0, -1))); |
| 558 | |||
| 559 |
4/4✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
|
21 | double totalHeatRateSI = sensibleHeatRateSI->value() + latentHeatRateSI->value(); |
| 560 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if (totalHeatRateSI > 0) { |
| 561 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | double sensibleHeatFraction = sensibleHeatRateSI->value() / totalHeatRateSI; |
| 562 |
1/1✓ Branch 1 taken 21 times.
|
21 | peopleDefinition.setSensibleHeatFraction(sensibleHeatFraction); |
| 563 | } | ||
| 564 | |||
| 565 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::model::People people(peopleDefinition); |
| 566 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | people.setName(name + " People"); |
| 567 |
1/1✓ Branch 1 taken 21 times.
|
21 | people.setSpace(space); |
| 568 | |||
| 569 | // activity schedule | ||
| 570 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::model::ScheduleRuleset activitySchedule(model, totalHeatRateSI); |
| 571 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | activitySchedule.setName(name + " People Activity Level"); |
| 572 | |||
| 573 | //boost::optional<model::ScheduleTypeLimits> scheduleTypeLimits = model.getConcreteModelObjectByName<model::ScheduleTypeLimits>("Activity Level"); | ||
| 574 | //if (!scheduleTypeLimits){ | ||
| 575 | // scheduleTypeLimits = model::ScheduleTypeLimits(model); | ||
| 576 | // scheduleTypeLimits->setName("Activity Level"); | ||
| 577 | // scheduleTypeLimits->setNumericType("Continuous"); | ||
| 578 | // scheduleTypeLimits->setUnitType("ActivityLevel"); | ||
| 579 | //} | ||
| 580 | //if (scheduleTypeLimits){ | ||
| 581 | // activitySchedule.setScheduleTypeLimits(*scheduleTypeLimits); | ||
| 582 | //} | ||
| 583 | |||
| 584 |
1/1✓ Branch 1 taken 21 times.
|
21 | people.setActivityLevelSchedule(activitySchedule); |
| 585 | |||
| 586 | // number of people schedule | ||
| 587 | |||
| 588 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (occSchRefElement) { |
| 589 |
4/4✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
|
21 | std::string scheduleName = escapeName(occSchRefElement.text().as_string()); |
| 590 |
1/1✓ Branch 1 taken 21 times.
|
21 | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); |
| 591 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if (schedule) { |
| 592 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | people.setNumberofPeopleSchedule(*schedule); |
| 593 | } else { | ||
| 594 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 595 | } | ||
| 596 | 21 | } | |
| 597 | 21 | } else { | |
| 598 | ✗ | LOG(Error, "People density is non-zero but sensible and latent heat rates are not given"); | |
| 599 | } | ||
| 600 | } | ||
| 601 | } | ||
| 602 | |||
| 603 | //***** Infiltration ***** | ||
| 604 | { | ||
| 605 | //<InfMthd>FlowExteriorWallArea</InfMthd> | ||
| 606 | //<DsgnInfRt>0.0448</DsgnInfRt> | ||
| 607 | //<InfSchRef>School Inf Sch</InfSchRef> | ||
| 608 | //<InfModelCoefA>0</InfModelCoefA> | ||
| 609 | //<InfModelCoefC>0.10016</InfModelCoefC> | ||
| 610 | //<InfModelCoefD>0</InfModelCoefD> | ||
| 611 | |||
| 612 | //InfMthd = {AirChangesPerHour, FlowArea, FlowExteriorArea, FlowExteriorWallArea, FlowSpace} | ||
| 613 |
1/1✓ Branch 1 taken 25 times.
|
25 | std::vector<pugi::xml_node> infMthdNodes = makeVectorOfChildren(element, "InfMthd"); |
| 614 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 2 taken 25 times.
|
50 | for (std::vector<pugi::xml_node>::size_type i = 0; i < infMthdNodes.size(); i++) { |
| 615 | |||
| 616 | 25 | pugi::xml_node infMthdElement = infMthdNodes[i]; | |
| 617 | |||
| 618 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | boost::optional<int> _infIndex = lexicalCastToInt(infMthdElement.attribute("index")); |
| 619 | |||
| 620 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | pugi::xml_node dsgnInfRtElement = elementByTagNameAndIndex(element, "DsgnInfRt", _infIndex); |
| 621 | |||
| 622 |
5/8✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 25 times.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
|
25 | if (infMthdElement && dsgnInfRtElement) { |
| 623 | |||
| 624 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | std::string infMthd = infMthdElement.text().as_string(); |
| 625 | |||
| 626 |
8/21✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 9 taken 25 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 25 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 25 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 25 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
125 | if (openstudio::istringEqual(infMthd, "AirChangesPerHour") || openstudio::istringEqual(infMthd, "FlowArea") |
| 627 |
10/24✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 25 times.
✓ Branch 12 taken 25 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 25 times.
✓ Branch 17 taken 25 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 25 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 25 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 25 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
|
125 | || openstudio::istringEqual(infMthd, "FlowExteriorArea") || openstudio::istringEqual(infMthd, "FlowExteriorWallArea") |
| 628 |
5/17✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 25 times.
✓ Branch 18 taken 25 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
75 | || openstudio::istringEqual(infMthd, "FlowSpace")) { |
| 629 | |||
| 630 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
50 | pugi::xml_node infSchRefElement = elementByTagNameAndIndex(element, "InfSchRef", _infIndex); |
| 631 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
50 | pugi::xml_node infModelCoefAElement = elementByTagNameAndIndex(element, "InfModelCoefA", _infIndex); // unitless |
| 632 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
50 | pugi::xml_node infModelCoefBElement = elementByTagNameAndIndex(element, "InfModelCoefB", _infIndex); // 1/deltaF |
| 633 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
50 | pugi::xml_node infModelCoefCElement = elementByTagNameAndIndex(element, "InfModelCoefC", _infIndex); // hr/mile |
| 634 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | pugi::xml_node infModelCoefDElement = elementByTagNameAndIndex(element, "InfModelCoefD", _infIndex); // hr^2/mile^2 |
| 635 | |||
| 636 |
1/1✓ Branch 1 taken 25 times.
|
25 | openstudio::model::SpaceInfiltrationDesignFlowRate spaceInfiltrationDesignFlowRate(model); |
| 637 | 25 | std::string infName; | |
| 638 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | if (_infIndex) { |
| 639 |
4/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
|
25 | infName = name + " Space Infiltration Design Flow Rate " + openstudio::string_conversions::number(_infIndex.get() + 1); |
| 640 | } else { | ||
| 641 | ✗ | infName = name + " Space Infiltration Design Flow Rate"; | |
| 642 | } | ||
| 643 |
1/1✓ Branch 1 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setName(infName); |
| 644 |
1/1✓ Branch 1 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setSpace(space); |
| 645 | |||
| 646 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | double dsnInfRt = dsgnInfRtElement.text().as_double(); |
| 647 | |||
| 648 |
5/5✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
✓ Branch 13 taken 25 times.
|
50 | openstudio::Quantity dsgnInfRtIP(dsnInfRt, openstudio::createUnit("cfm", UnitSystem::BTU).get()); |
| 649 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | OptionalQuantity dsgnInfRtSI = QuantityConverter::instance().convert(dsgnInfRtIP, siSys); |
| 650 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 4 not taken.
|
25 | OS_ASSERT(dsgnInfRtSI); |
| 651 |
6/8✓ Branch 1 taken 25 times.
✓ Branch 5 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 11 taken 25 times.
✓ Branch 14 taken 25 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 25 times.
✗ Branch 19 not taken.
|
25 | OS_ASSERT(dsgnInfRtSI->units() == SIUnit(SIExpnt(0, 3, -1))); |
| 652 | |||
| 653 |
5/5✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
✓ Branch 13 taken 25 times.
|
50 | openstudio::Quantity dsgnInfRtAreaIP(dsnInfRt, openstudio::createUnit("cfm/ft^2", UnitSystem::BTU).get()); |
| 654 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | OptionalQuantity dsgnInfRtAreaSI = QuantityConverter::instance().convert(dsgnInfRtAreaIP, siSys); |
| 655 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 4 not taken.
|
25 | OS_ASSERT(dsgnInfRtAreaSI); |
| 656 |
6/8✓ Branch 1 taken 25 times.
✓ Branch 5 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 11 taken 25 times.
✓ Branch 14 taken 25 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 25 times.
✗ Branch 19 not taken.
|
50 | OS_ASSERT(dsgnInfRtAreaSI->units() == SIUnit(SIExpnt(0, 1, -1))); |
| 657 | |||
| 658 |
3/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
|
50 | if (openstudio::istringEqual(infMthd, "AirChangesPerHour")) { |
| 659 | ✗ | spaceInfiltrationDesignFlowRate.setAirChangesperHour(dsnInfRt); | |
| 660 |
3/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
|
50 | } else if (openstudio::istringEqual(infMthd, "FlowArea")) { |
| 661 | ✗ | spaceInfiltrationDesignFlowRate.setFlowperSpaceFloorArea(dsgnInfRtAreaSI->value()); | |
| 662 |
3/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 25 times.
|
50 | } else if (openstudio::istringEqual(infMthd, "FlowExteriorArea")) { |
| 663 | ✗ | spaceInfiltrationDesignFlowRate.setFlowperExteriorSurfaceArea(dsgnInfRtAreaSI->value()); | |
| 664 |
3/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✗ Branch 8 not taken.
|
50 | } else if (openstudio::istringEqual(infMthd, "FlowExteriorWallArea")) { |
| 665 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setFlowperExteriorWallArea(dsgnInfRtAreaSI->value()); |
| 666 | ✗ | } else if (openstudio::istringEqual(infMthd, "FlowSpace")) { | |
| 667 | ✗ | spaceInfiltrationDesignFlowRate.setDesignFlowRate(dsgnInfRtSI->value()); | |
| 668 | } | ||
| 669 | |||
| 670 |
2/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
|
25 | if (infSchRefElement) { |
| 671 |
4/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
|
25 | std::string scheduleName = escapeName(infSchRefElement.text().as_string()); |
| 672 |
1/1✓ Branch 1 taken 25 times.
|
25 | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); |
| 673 |
1/2✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
|
25 | if (schedule) { |
| 674 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setSchedule(*schedule); |
| 675 | } else { | ||
| 676 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 677 | } | ||
| 678 | 25 | } | |
| 679 | |||
| 680 |
2/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
|
25 | if (infModelCoefAElement) { |
| 681 | // unitless | ||
| 682 | //TODO: check if double conversion worked using lexicalCastToDouble? | ||
| 683 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | double infModelCoefA = infModelCoefAElement.text().as_double(); |
| 684 |
1/1✓ Branch 1 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setConstantTermCoefficient(infModelCoefA); |
| 685 | } | ||
| 686 | |||
| 687 |
2/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
|
25 | if (infModelCoefBElement) { |
| 688 | // convert 1/deltaF to 1/detlaC | ||
| 689 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setTemperatureTermCoefficient(infModelCoefBElement.text().as_double() * 5.0 / 9.0); |
| 690 | } | ||
| 691 | |||
| 692 |
2/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
|
25 | if (infModelCoefCElement) { |
| 693 | // SDD: hr/mile, OpenStudio: s/m | ||
| 694 |
5/5✓ Branch 1 taken 25 times.
✓ Branch 5 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 11 taken 25 times.
✓ Branch 14 taken 25 times.
|
25 | openstudio::Quantity infModelCoefCIP(infModelCoefCElement.text().as_double(), MPHUnit(MPHExpnt(0, -1, 1))); |
| 695 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | OptionalQuantity infModelCoefCSI = QuantityConverter::instance().convert(infModelCoefCIP, siSys); |
| 696 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 4 not taken.
|
25 | OS_ASSERT(infModelCoefCSI); |
| 697 |
6/8✓ Branch 1 taken 25 times.
✓ Branch 5 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 11 taken 25 times.
✓ Branch 14 taken 25 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 25 times.
✗ Branch 19 not taken.
|
25 | OS_ASSERT(infModelCoefCSI->units() == SIUnit(SIExpnt(0, -1, 1))); |
| 698 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setVelocityTermCoefficient(infModelCoefCSI->value()); |
| 699 | 25 | } | |
| 700 | |||
| 701 |
2/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
|
25 | if (infModelCoefDElement) { |
| 702 | // SDD: hr^2/mile^2, OpenStudio: s^2/m^2 | ||
| 703 |
5/5✓ Branch 1 taken 25 times.
✓ Branch 5 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 11 taken 25 times.
✓ Branch 14 taken 25 times.
|
25 | openstudio::Quantity infModelCoefDIP(infModelCoefDElement.text().as_double(), MPHUnit(MPHExpnt(0, -2, 2))); |
| 704 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | OptionalQuantity infModelCoefDSI = QuantityConverter::instance().convert(infModelCoefDIP, siSys); |
| 705 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 4 not taken.
|
25 | OS_ASSERT(infModelCoefDSI); |
| 706 |
6/8✓ Branch 1 taken 25 times.
✓ Branch 5 taken 25 times.
✓ Branch 8 taken 25 times.
✓ Branch 11 taken 25 times.
✓ Branch 14 taken 25 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 25 times.
✗ Branch 19 not taken.
|
25 | OS_ASSERT(infModelCoefDSI->units() == SIUnit(SIExpnt(0, -2, 2))); |
| 707 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | spaceInfiltrationDesignFlowRate.setVelocitySquaredTermCoefficient(infModelCoefDSI->value()); |
| 708 | 25 | } | |
| 709 | 25 | } | |
| 710 | 25 | } | |
| 711 | } // end for infMthdNodes | ||
| 712 | 25 | } | |
| 713 | |||
| 714 | //***** Interior Lights ***** | ||
| 715 | { | ||
| 716 | //<IntLPDReg>1.1</IntLPDReg> - W per ft2 | ||
| 717 | //<IntLtgRegSchRef>Office Lighting Sched</IntLtgRegSchRef> | ||
| 718 | //<IntLtgRegHtGnSpcFrac>0.61</IntLtgRegHtGnSpcFrac> - fraction to space, 1-Return Air Fraction | ||
| 719 | //<IntLtgRegHtGnRadFrac>0.75</IntLtgRegHtGnRadFrac> - radiant fraction | ||
| 720 | //<IntLPDNonReg>0</IntLPDNonReg> - W per ft2 | ||
| 721 | //<IntLtgNonRegSchRef>Office Lighting Sched</IntLtgNonRegSchRef> | ||
| 722 | //<IntLtgNonRegHtGnSpcFrac>0.5</IntLtgNonRegHtGnSpcFrac> - fraction to space, 1-Return Air Fraction | ||
| 723 | //<IntLtgNonRegHtGnRadFrac>0.55</IntLtgNonRegHtGnRadFrac> - radiant fraction | ||
| 724 | |||
| 725 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLPDRegSimElement = element.child("IntLPDRegSim"); |
| 726 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgRegSchRefElement = element.child("IntLtgRegSchRef"); |
| 727 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgRegHtGnSpcFracSimElement = element.child("IntLtgRegHtGnSpcFracSim"); |
| 728 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgRegHtGnRadFracSimElement = element.child("IntLtgRegHtGnRadFracSim"); |
| 729 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgRegEndUseElement = element.child("IntLtgRegEndUseCat"); |
| 730 |
8/9✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 25 times.
✓ Branch 9 taken 25 times.
✓ Branch 11 taken 21 times.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 21 times.
✓ Branch 14 taken 4 times.
|
25 | if ((intLPDRegSimElement != nullptr) && (intLPDRegSimElement.text().as_double() > 0)) { |
| 731 | |||
| 732 |
6/6✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 13 taken 21 times.
✓ Branch 16 taken 21 times.
|
21 | openstudio::Quantity lightingDensityIP(intLPDRegSimElement.text().as_double(), openstudio::createUnit("W/ft^2").get()); |
| 733 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | OptionalQuantity lightingDensitySI = QuantityConverter::instance().convert(lightingDensityIP, whSys); |
| 734 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 4 not taken.
|
21 | OS_ASSERT(lightingDensitySI); |
| 735 |
6/8✓ Branch 1 taken 21 times.
✓ Branch 5 taken 21 times.
✓ Branch 8 taken 21 times.
✓ Branch 11 taken 21 times.
✓ Branch 14 taken 21 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 21 times.
✗ Branch 19 not taken.
|
21 | OS_ASSERT(lightingDensitySI->units() == WhUnit(WhExpnt(1, 0, -2))); |
| 736 | |||
| 737 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::model::LightsDefinition lightsDefinition(model); |
| 738 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | lightsDefinition.setName(name + " Regulated Lights Definition"); |
| 739 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | lightsDefinition.setWattsperSpaceFloorArea(lightingDensitySI->value()); // W/m2 |
| 740 | |||
| 741 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::model::Lights lights(lightsDefinition); |
| 742 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | lights.setName(name + " Regulated Lights"); |
| 743 |
1/1✓ Branch 1 taken 21 times.
|
21 | lights.setSpace(space); |
| 744 | |||
| 745 |
1/1✓ Branch 1 taken 21 times.
|
21 | std::string subCategory = "ComplianceLtg"; |
| 746 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (intLtgRegEndUseElement) { |
| 747 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | subCategory = intLtgRegEndUseElement.text().as_string(); |
| 748 | } | ||
| 749 |
1/1✓ Branch 1 taken 21 times.
|
21 | lights.setEndUseSubcategory(subCategory); |
| 750 | |||
| 751 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (intLtgRegSchRefElement) { |
| 752 |
4/4✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
|
21 | std::string scheduleName = escapeName(intLtgRegSchRefElement.text().as_string()); |
| 753 |
1/1✓ Branch 1 taken 21 times.
|
21 | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); |
| 754 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if (schedule) { |
| 755 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | lights.setSchedule(*schedule); |
| 756 | } else { | ||
| 757 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 758 | } | ||
| 759 | 21 | } | |
| 760 | |||
| 761 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (intLtgRegHtGnSpcFracSimElement) { |
| 762 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | double spaceFraction = intLtgRegHtGnSpcFracSimElement.text().as_double(); |
| 763 | 21 | double returnAirFraction = 1.0 - spaceFraction; | |
| 764 |
1/1✓ Branch 1 taken 21 times.
|
21 | lightsDefinition.setReturnAirFraction(returnAirFraction); |
| 765 | |||
| 766 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (intLtgRegHtGnRadFracSimElement) { |
| 767 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | double fractionRadiant = intLtgRegHtGnRadFracSimElement.text().as_double() * spaceFraction; |
| 768 |
1/1✓ Branch 1 taken 21 times.
|
21 | lightsDefinition.setFractionRadiant(fractionRadiant); |
| 769 | } | ||
| 770 | ✗ | } else if (intLtgRegHtGnRadFracSimElement) { | |
| 771 | ✗ | LOG(Warn, "IntLtgRegHtGnRadFracSimElement is specified for space '" | |
| 772 | << name << "' but IntLtgRegHtGnSpcFracSimElement is not, IntLtgNonRegHtGnRadFracSimElement will be ignored."); | ||
| 773 | } | ||
| 774 | 21 | } | |
| 775 | |||
| 776 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLPDNonRegSimElement = element.child("IntLPDNonRegSim"); |
| 777 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgNonRegSchRefElement = element.child("IntLtgNonRegSchRef"); |
| 778 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgNonRegHtGnSpcFracSimElement = element.child("IntLtgNonRegHtGnSpcFracSim"); |
| 779 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgNonRegHtGnRadFracSimElement = element.child("IntLtgNonRegHtGnRadFracSim"); |
| 780 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node intLtgNonRegEndUseElement = element.child("IntLtgNonRegEndUseCat"); |
| 781 |
3/9✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
|
25 | if ((intLPDNonRegSimElement != nullptr) && (intLPDNonRegSimElement.text().as_double() > 0)) { |
| 782 | |||
| 783 | ✗ | openstudio::Quantity lightingDensityIP(intLPDNonRegSimElement.text().as_double(), openstudio::createUnit("W/ft^2").get()); | |
| 784 | ✗ | OptionalQuantity lightingDensitySI = QuantityConverter::instance().convert(lightingDensityIP, whSys); | |
| 785 | ✗ | OS_ASSERT(lightingDensitySI); | |
| 786 | ✗ | OS_ASSERT(lightingDensitySI->units() == WhUnit(WhExpnt(1, 0, -2))); | |
| 787 | |||
| 788 | ✗ | openstudio::model::LightsDefinition lightsDefinition(model); | |
| 789 | ✗ | lightsDefinition.setName(name + " Non-Regulated Lights Definition"); | |
| 790 | ✗ | lightsDefinition.setWattsperSpaceFloorArea(lightingDensitySI->value()); // W/m2 | |
| 791 | |||
| 792 | ✗ | openstudio::model::Lights lights(lightsDefinition); | |
| 793 | ✗ | lights.setName(name + " Non-Regulated Lights"); | |
| 794 | ✗ | lights.setSpace(space); | |
| 795 | |||
| 796 | ✗ | std::string subCategory = "NonComplianceLtg"; | |
| 797 | ✗ | if (intLtgRegEndUseElement) { | |
| 798 | ✗ | subCategory = intLtgNonRegEndUseElement.text().as_string(); | |
| 799 | } | ||
| 800 | ✗ | lights.setEndUseSubcategory(subCategory); | |
| 801 | |||
| 802 | ✗ | if (intLtgNonRegSchRefElement) { | |
| 803 | ✗ | std::string scheduleName = escapeName(intLtgNonRegSchRefElement.text().as_string()); | |
| 804 | ✗ | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 805 | ✗ | if (schedule) { | |
| 806 | ✗ | lights.setSchedule(*schedule); | |
| 807 | } else { | ||
| 808 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 809 | } | ||
| 810 | ✗ | } | |
| 811 | |||
| 812 | ✗ | if (intLtgNonRegHtGnSpcFracSimElement) { | |
| 813 | ✗ | double spaceFraction = intLtgNonRegHtGnSpcFracSimElement.text().as_double(); | |
| 814 | ✗ | double returnAirFraction = 1.0 - spaceFraction; | |
| 815 | ✗ | lightsDefinition.setReturnAirFraction(returnAirFraction); | |
| 816 | |||
| 817 | ✗ | if (intLtgNonRegHtGnRadFracSimElement) { | |
| 818 | ✗ | double fractionRadiant = intLtgNonRegHtGnRadFracSimElement.text().as_double() * spaceFraction; | |
| 819 | ✗ | lightsDefinition.setFractionRadiant(fractionRadiant); | |
| 820 | } | ||
| 821 | ✗ | } else if (intLtgNonRegHtGnRadFracSimElement) { | |
| 822 | ✗ | LOG(Warn, "IntLtgNonRegHtGnRadFracSimElement is specified for space '" | |
| 823 | << name << "' but IntLtgNonRegHtGnSpcFracSimElement is not, IntLtgNonRegHtGnRadFracSimElement will be ignored."); | ||
| 824 | } | ||
| 825 | ✗ | } | |
| 826 | } | ||
| 827 | |||
| 828 | //***** Recepticle Loads ***** | ||
| 829 | { | ||
| 830 | |||
| 831 | //<RecptPwrDens>2.53</RecptPwrDens> - W per ft2 | ||
| 832 | //<RecptSchRef>Office Plugs Sched</RecptSchRef> | ||
| 833 | //<RecptRadFrac>0.2</RecptRadFrac> | ||
| 834 | //<RecptLatFrac>0</RecptLatFrac> | ||
| 835 | //<RecptLostFrac>0</RecptLostFrac> | ||
| 836 | |||
| 837 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node recptPwrDensElement = element.child("RecptPwrDens"); |
| 838 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node recptPwrDensSchRefElement = element.child("RecptSchRef"); |
| 839 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node recptRadFracElement = element.child("RecptRadFrac"); |
| 840 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node recptLatFracElement = element.child("RecptLatFrac"); |
| 841 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node recptLostFracElement = element.child("RecptLostFrac"); |
| 842 |
8/9✓ Branch 1 taken 25 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 21 times.
✓ Branch 9 taken 21 times.
✓ Branch 11 taken 21 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 21 times.
✓ Branch 14 taken 4 times.
|
25 | if ((recptPwrDensElement != nullptr) && (recptPwrDensElement.text().as_double() > 0)) { |
| 843 | |||
| 844 |
6/6✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
✓ Branch 13 taken 21 times.
✓ Branch 16 taken 21 times.
|
21 | openstudio::Quantity electricalDensityIP(recptPwrDensElement.text().as_double(), openstudio::createUnit("W/ft^2").get()); |
| 845 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | OptionalQuantity electricalDensitySI = QuantityConverter::instance().convert(electricalDensityIP, whSys); |
| 846 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 4 not taken.
|
21 | OS_ASSERT(electricalDensitySI); |
| 847 |
6/8✓ Branch 1 taken 21 times.
✓ Branch 5 taken 21 times.
✓ Branch 8 taken 21 times.
✓ Branch 11 taken 21 times.
✓ Branch 14 taken 21 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 21 times.
✗ Branch 19 not taken.
|
21 | OS_ASSERT(electricalDensitySI->units() == WhUnit(WhExpnt(1, 0, -2))); |
| 848 | |||
| 849 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::model::ElectricEquipmentDefinition electricEquipmentDefinition(model); |
| 850 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | electricEquipmentDefinition.setName(name + " Recepticle Loads Definition"); |
| 851 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | electricEquipmentDefinition.setWattsperSpaceFloorArea(electricalDensitySI->value()); // W/m2 |
| 852 | |||
| 853 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (recptRadFracElement) { |
| 854 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | electricEquipmentDefinition.setFractionRadiant(recptRadFracElement.text().as_double()); |
| 855 | } | ||
| 856 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (recptLatFracElement) { |
| 857 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | electricEquipmentDefinition.setFractionLatent(recptLatFracElement.text().as_double()); |
| 858 | } | ||
| 859 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (recptLostFracElement) { |
| 860 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
|
21 | electricEquipmentDefinition.setFractionLost(recptLostFracElement.text().as_double()); |
| 861 | } | ||
| 862 | |||
| 863 |
1/1✓ Branch 1 taken 21 times.
|
21 | openstudio::model::ElectricEquipment electricEquipment(electricEquipmentDefinition); |
| 864 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | electricEquipment.setName(name + " Recepticle Loads"); |
| 865 |
1/1✓ Branch 1 taken 21 times.
|
21 | electricEquipment.setSpace(space); |
| 866 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | electricEquipment.setEndUseSubcategory("Receptacle"); |
| 867 | |||
| 868 |
2/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
21 | if (recptPwrDensSchRefElement) { |
| 869 |
4/4✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 10 taken 21 times.
|
21 | std::string scheduleName = escapeName(recptPwrDensSchRefElement.text().as_string()); |
| 870 |
1/1✓ Branch 1 taken 21 times.
|
21 | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); |
| 871 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if (schedule) { |
| 872 |
2/2✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
|
21 | electricEquipment.setSchedule(*schedule); |
| 873 | } else { | ||
| 874 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 875 | } | ||
| 876 | 21 | } | |
| 877 | 21 | } | |
| 878 | } | ||
| 879 | |||
| 880 | //***** Gas Equipment Loads ***** | ||
| 881 | { | ||
| 882 | |||
| 883 | //<GasEqpPwrDens>17.5377</GasEqpPwrDens> | ||
| 884 | //<GasEqpSchRef>RestaurantReceptacle</GasEqpSchRef> | ||
| 885 | //<GasEqpRadFrac>0.2</GasEqpRadFrac> | ||
| 886 | //<GasEqpLatFrac>0.4</GasEqpLatFrac> | ||
| 887 | //<GasEqpLostFrac>0.2></GasEqpLostFrac> | ||
| 888 | |||
| 889 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node gasEqpPwrDensElement = element.child("GasEqpPwrDens"); |
| 890 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node gasEqpPwrDensSchRefElement = element.child("GasEqpSchRef"); |
| 891 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node gasEqpRadFracElement = element.child("GasEqpRadFrac"); |
| 892 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node gasEqpLatFracElement = element.child("GasEqpLatFrac"); |
| 893 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node gasEqpLostFracElement = element.child("GasEqpLostFrac"); |
| 894 |
7/9✓ Branch 1 taken 25 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 21 times.
✓ Branch 9 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 21 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
|
25 | if ((gasEqpPwrDensElement != nullptr) && (gasEqpPwrDensElement.text().as_double() > 0)) { |
| 895 | |||
| 896 | ✗ | openstudio::Quantity gasDensityIP(gasEqpPwrDensElement.text().as_double(), openstudio::createUnit("Btu/h*ft^2").get()); | |
| 897 | ✗ | OptionalQuantity gasDensitySI = QuantityConverter::instance().convert(gasDensityIP, whSys); | |
| 898 | ✗ | OS_ASSERT(gasDensitySI); | |
| 899 | ✗ | OS_ASSERT(gasDensitySI->units() == WhUnit(WhExpnt(1, 0, -2))); | |
| 900 | |||
| 901 | ✗ | openstudio::model::GasEquipmentDefinition gasEquipmentDefinition(model); | |
| 902 | ✗ | gasEquipmentDefinition.setName(name + " Gas Equipment Loads Definition"); | |
| 903 | ✗ | gasEquipmentDefinition.setWattsperSpaceFloorArea(gasDensitySI->value()); // W/m2 | |
| 904 | |||
| 905 | ✗ | if (gasEqpRadFracElement) { | |
| 906 | ✗ | gasEquipmentDefinition.setFractionRadiant(gasEqpRadFracElement.text().as_double()); | |
| 907 | } | ||
| 908 | ✗ | if (gasEqpLatFracElement) { | |
| 909 | ✗ | gasEquipmentDefinition.setFractionLatent(gasEqpLatFracElement.text().as_double()); | |
| 910 | } | ||
| 911 | ✗ | if (gasEqpLostFracElement) { | |
| 912 | ✗ | gasEquipmentDefinition.setFractionLost(gasEqpLostFracElement.text().as_double()); | |
| 913 | } | ||
| 914 | |||
| 915 | ✗ | openstudio::model::GasEquipment gasEquipment(gasEquipmentDefinition); | |
| 916 | ✗ | gasEquipment.setName(name + " Gas Equipment Loads"); | |
| 917 | ✗ | gasEquipment.setSpace(space); | |
| 918 | ✗ | gasEquipment.setEndUseSubcategory("Receptacle"); | |
| 919 | |||
| 920 | ✗ | if (gasEqpPwrDensSchRefElement) { | |
| 921 | ✗ | std::string scheduleName = escapeName(gasEqpPwrDensSchRefElement.text().as_string()); | |
| 922 | ✗ | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 923 | ✗ | if (schedule) { | |
| 924 | ✗ | gasEquipment.setSchedule(*schedule); | |
| 925 | } else { | ||
| 926 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 927 | } | ||
| 928 | ✗ | } | |
| 929 | ✗ | } | |
| 930 | } | ||
| 931 | |||
| 932 | //***** Process Electricity Loads ***** | ||
| 933 | { | ||
| 934 | //<ProcElecPwrDens>0</ProcElecPwrDens> - W per ft2 | ||
| 935 | //<ProcElecSchRef>Office Plugs Sched</ProcElecSchRef> | ||
| 936 | //<ProcElecRadFrac>0.2</ProcElecRadFrac> | ||
| 937 | //<ProcElecLatFrac>0</ProcElecLatFrac> | ||
| 938 | //<ProcElecLostFrac>0</ProcElecLostFrac> | ||
| 939 | |||
| 940 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procElecPwrDensElement = element.child("ProcElecPwrDens"); |
| 941 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procElecSchRefElement = element.child("ProcElecSchRef"); |
| 942 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procElecRadFracElement = element.child("ProcElecRadFrac"); |
| 943 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procElecLatFracElement = element.child("ProcElecLatFrac"); |
| 944 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procElecLostFracElement = element.child("ProcElecLostFrac"); |
| 945 |
7/9✓ Branch 1 taken 25 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 21 times.
✓ Branch 9 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 21 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
|
25 | if ((procElecPwrDensElement != nullptr) && (procElecPwrDensElement.text().as_double() > 0)) { |
| 946 | |||
| 947 | ✗ | openstudio::Quantity electricalDensityIP(procElecPwrDensElement.text().as_double(), openstudio::createUnit("W/ft^2").get()); | |
| 948 | ✗ | OptionalQuantity electricalDensitySI = QuantityConverter::instance().convert(electricalDensityIP, whSys); | |
| 949 | ✗ | OS_ASSERT(electricalDensitySI); | |
| 950 | ✗ | OS_ASSERT(electricalDensitySI->units() == WhUnit(WhExpnt(1, 0, -2))); | |
| 951 | |||
| 952 | ✗ | openstudio::model::ElectricEquipmentDefinition electricEquipmentDefinition(model); | |
| 953 | ✗ | electricEquipmentDefinition.setName(name + " Process Electric Loads Definition"); | |
| 954 | ✗ | electricEquipmentDefinition.setWattsperSpaceFloorArea(electricalDensitySI->value()); // W/m2 | |
| 955 | |||
| 956 | ✗ | if (procElecRadFracElement) { | |
| 957 | ✗ | electricEquipmentDefinition.setFractionRadiant(procElecRadFracElement.text().as_double()); | |
| 958 | } | ||
| 959 | ✗ | if (procElecLatFracElement) { | |
| 960 | ✗ | electricEquipmentDefinition.setFractionLatent(procElecLatFracElement.text().as_double()); | |
| 961 | } | ||
| 962 | ✗ | if (procElecLostFracElement) { | |
| 963 | ✗ | electricEquipmentDefinition.setFractionLost(procElecLostFracElement.text().as_double()); | |
| 964 | } | ||
| 965 | |||
| 966 | ✗ | openstudio::model::ElectricEquipment electricEquipment(electricEquipmentDefinition); | |
| 967 | ✗ | electricEquipment.setName(name + " Process Electric Loads"); | |
| 968 | ✗ | electricEquipment.setSpace(space); | |
| 969 | ✗ | electricEquipment.setEndUseSubcategory("Process"); | |
| 970 | |||
| 971 | ✗ | if (procElecSchRefElement) { | |
| 972 | ✗ | std::string scheduleName = escapeName(procElecSchRefElement.text().as_string()); | |
| 973 | ✗ | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 974 | ✗ | if (schedule) { | |
| 975 | ✗ | electricEquipment.setSchedule(*schedule); | |
| 976 | } else { | ||
| 977 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 978 | } | ||
| 979 | ✗ | } | |
| 980 | ✗ | } | |
| 981 | } | ||
| 982 | |||
| 983 | //***** Refrigeration Loads ***** | ||
| 984 | { | ||
| 985 | //<CommRfrgEPD>0.06</CommRfrgEPD> - W per ft2 | ||
| 986 | //<CommRfrgEqpSchRef>Office Plugs Sched</CommRfrgEqpSchRef> | ||
| 987 | //<CommRfrgRadFrac>0.1</CommRfrgRadFrac> | ||
| 988 | //<CommRfrgLatFrac>0.1</CommRfrgLatFrac> | ||
| 989 | //<CommRfrgLostFrac>0.6</CommRfrgLostFrac> | ||
| 990 | |||
| 991 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node commRfrgEPDElement = element.child("CommRfrgEPD"); |
| 992 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node commRfrgEqpSchRefElement = element.child("CommRfrgEqpSchRef"); |
| 993 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node commRfrgRadFracElement = element.child("CommRfrgRadFrac"); |
| 994 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node commRfrgLatFracElement = element.child("CommRfrgLatFrac"); |
| 995 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node commRfrgLostFracElement = element.child("CommRfrgLostFrac"); |
| 996 |
3/9✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
|
25 | if ((commRfrgEPDElement != nullptr) && (commRfrgEPDElement.text().as_double() > 0)) { |
| 997 | |||
| 998 | ✗ | openstudio::Quantity electricalDensityIP(commRfrgEPDElement.text().as_double(), openstudio::createUnit("W/ft^2").get()); | |
| 999 | ✗ | OptionalQuantity electricalDensitySI = QuantityConverter::instance().convert(electricalDensityIP, whSys); | |
| 1000 | ✗ | OS_ASSERT(electricalDensitySI); | |
| 1001 | ✗ | OS_ASSERT(electricalDensitySI->units() == WhUnit(WhExpnt(1, 0, -2))); | |
| 1002 | |||
| 1003 | ✗ | openstudio::model::ElectricEquipmentDefinition electricEquipmentDefinition(model); | |
| 1004 | ✗ | electricEquipmentDefinition.setName(name + " Refrigeration Loads Definition"); | |
| 1005 | ✗ | electricEquipmentDefinition.setWattsperSpaceFloorArea(electricalDensitySI->value()); // W/m2 | |
| 1006 | |||
| 1007 | ✗ | if (commRfrgRadFracElement) { | |
| 1008 | ✗ | electricEquipmentDefinition.setFractionRadiant(commRfrgRadFracElement.text().as_double()); | |
| 1009 | } | ||
| 1010 | ✗ | if (commRfrgLatFracElement) { | |
| 1011 | ✗ | electricEquipmentDefinition.setFractionLatent(commRfrgLatFracElement.text().as_double()); | |
| 1012 | } | ||
| 1013 | ✗ | if (commRfrgLostFracElement) { | |
| 1014 | ✗ | electricEquipmentDefinition.setFractionLost(commRfrgLostFracElement.text().as_double()); | |
| 1015 | } | ||
| 1016 | |||
| 1017 | ✗ | openstudio::model::ElectricEquipment electricEquipment(electricEquipmentDefinition); | |
| 1018 | ✗ | electricEquipment.setName(name + " Refrigeration Loads"); | |
| 1019 | ✗ | electricEquipment.setSpace(space); | |
| 1020 | ✗ | electricEquipment.setEndUseSubcategory("Refrig"); | |
| 1021 | |||
| 1022 | ✗ | if (commRfrgEqpSchRefElement) { | |
| 1023 | ✗ | std::string scheduleName = escapeName(commRfrgEqpSchRefElement.text().as_string()); | |
| 1024 | ✗ | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 1025 | ✗ | if (schedule) { | |
| 1026 | ✗ | electricEquipment.setSchedule(*schedule); | |
| 1027 | } else { | ||
| 1028 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 1029 | } | ||
| 1030 | ✗ | } | |
| 1031 | ✗ | } | |
| 1032 | } | ||
| 1033 | |||
| 1034 | //***** Elevator Loads ***** | ||
| 1035 | { | ||
| 1036 | //<ElevPwr>20000</ElevPwr> | ||
| 1037 | //<ElevSchRef>OfficeElevator</ElevSchRef> | ||
| 1038 | //<ElevRadFrac>0</ElevRadFrac> | ||
| 1039 | //<ElevLatFrac>0</ElevLatFrac> | ||
| 1040 | //<ElevLostFrac>0.8</ElevLostFrac> | ||
| 1041 | |||
| 1042 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node elevPwrElement = element.child("ElevPwr"); |
| 1043 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node elevSchRefElement = element.child("ElevSchRef"); |
| 1044 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node elevRadFracElement = element.child("ElevRadFrac"); |
| 1045 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node elevLatFracElement = element.child("ElevLatFrac"); |
| 1046 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node elevLostFracElement = element.child("ElevLostFrac"); |
| 1047 |
3/9✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
|
25 | if ((elevPwrElement != nullptr) && (elevPwrElement.text().as_double() > 0)) { |
| 1048 | |||
| 1049 | ✗ | openstudio::model::ElectricEquipmentDefinition electricEquipmentDefinition(model); | |
| 1050 | ✗ | electricEquipmentDefinition.setName(name + " Elevator Definition"); | |
| 1051 | ✗ | electricEquipmentDefinition.setDesignLevel(elevPwrElement.text().as_double()); | |
| 1052 | |||
| 1053 | ✗ | if (elevRadFracElement) { | |
| 1054 | ✗ | electricEquipmentDefinition.setFractionRadiant(elevRadFracElement.text().as_double()); | |
| 1055 | } | ||
| 1056 | ✗ | if (elevLatFracElement) { | |
| 1057 | ✗ | electricEquipmentDefinition.setFractionLatent(elevLatFracElement.text().as_double()); | |
| 1058 | } | ||
| 1059 | ✗ | if (elevLostFracElement) { | |
| 1060 | ✗ | electricEquipmentDefinition.setFractionLost(elevLostFracElement.text().as_double()); | |
| 1061 | } | ||
| 1062 | |||
| 1063 | ✗ | openstudio::model::ElectricEquipment electricEquipment(electricEquipmentDefinition); | |
| 1064 | ✗ | electricEquipment.setName(name + " Elevator"); | |
| 1065 | ✗ | electricEquipment.setSpace(space); | |
| 1066 | ✗ | electricEquipment.setEndUseSubcategory("Internal Transport"); | |
| 1067 | |||
| 1068 | ✗ | if (elevSchRefElement) { | |
| 1069 | ✗ | std::string scheduleName = escapeName(elevSchRefElement.text().as_string()); | |
| 1070 | ✗ | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 1071 | ✗ | if (schedule) { | |
| 1072 | ✗ | electricEquipment.setSchedule(*schedule); | |
| 1073 | } else { | ||
| 1074 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 1075 | } | ||
| 1076 | ✗ | } | |
| 1077 | ✗ | } | |
| 1078 | } | ||
| 1079 | |||
| 1080 | //***** Escalator Loads ***** | ||
| 1081 | { | ||
| 1082 | //<EscalPwr>7860</EscalPwr> | ||
| 1083 | //<EscalSchRef>OfficeEscalator Sch</EscalSchRef> | ||
| 1084 | //<EscalRadFrac>0</EscalRadFrac> | ||
| 1085 | //<EscalLatFrac>0</EscalLatFrac> | ||
| 1086 | //<EscalLostFrac>0.2</EscalLostFrac> | ||
| 1087 | |||
| 1088 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node escalPwrElement = element.child("EscalPwr"); |
| 1089 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node escalSchRefElement = element.child("EscalSchRef"); |
| 1090 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node escalRadFracElement = element.child("EscalRadFrac"); |
| 1091 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node escalLatFracElement = element.child("EscalLatFrac"); |
| 1092 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node escalLostFracElement = element.child("EscalLostFrac"); |
| 1093 |
3/9✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
|
25 | if ((escalPwrElement != nullptr) && (escalPwrElement.text().as_double() > 0)) { |
| 1094 | |||
| 1095 | ✗ | openstudio::model::ElectricEquipmentDefinition electricEquipmentDefinition(model); | |
| 1096 | ✗ | electricEquipmentDefinition.setName(name + " Escalator Definition"); | |
| 1097 | ✗ | electricEquipmentDefinition.setDesignLevel(escalPwrElement.text().as_double()); | |
| 1098 | |||
| 1099 | ✗ | if (escalRadFracElement) { | |
| 1100 | ✗ | electricEquipmentDefinition.setFractionRadiant(escalRadFracElement.text().as_double()); | |
| 1101 | } | ||
| 1102 | ✗ | if (escalLatFracElement) { | |
| 1103 | ✗ | electricEquipmentDefinition.setFractionLatent(escalLatFracElement.text().as_double()); | |
| 1104 | } | ||
| 1105 | ✗ | if (escalLostFracElement) { | |
| 1106 | ✗ | electricEquipmentDefinition.setFractionLost(escalLostFracElement.text().as_double()); | |
| 1107 | } | ||
| 1108 | |||
| 1109 | ✗ | openstudio::model::ElectricEquipment electricEquipment(electricEquipmentDefinition); | |
| 1110 | ✗ | electricEquipment.setName(name + " Escalator"); | |
| 1111 | ✗ | electricEquipment.setSpace(space); | |
| 1112 | ✗ | electricEquipment.setEndUseSubcategory("Internal Transport"); | |
| 1113 | |||
| 1114 | ✗ | if (escalSchRefElement) { | |
| 1115 | ✗ | std::string scheduleName = escapeName(escalSchRefElement.text().as_string()); | |
| 1116 | ✗ | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 1117 | ✗ | if (schedule) { | |
| 1118 | ✗ | electricEquipment.setSchedule(*schedule); | |
| 1119 | } else { | ||
| 1120 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 1121 | } | ||
| 1122 | ✗ | } | |
| 1123 | ✗ | } | |
| 1124 | } | ||
| 1125 | |||
| 1126 | //***** Process Gas Loads ***** | ||
| 1127 | { | ||
| 1128 | //<ProcGasPwrDens>0.04</ProcGasPwrDens> - Btu per h ft2 | ||
| 1129 | //<ProcGasSchRef>Office Plugs Sched</ProcGasSchRef> | ||
| 1130 | //<ProcGasRadFrac>0.2</ProcGasRadFrac> | ||
| 1131 | //<ProcGasLatFrac>0.4</ProcGasLatFrac> | ||
| 1132 | //<ProcGasLostFrac>0.2</ProcGasLostFrac> | ||
| 1133 | |||
| 1134 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procGasPwrDensElement = element.child("ProcGasPwrDens"); |
| 1135 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procGasSchRefElement = element.child("ProcGasSchRef"); |
| 1136 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procGasRadFracElement = element.child("ProcGasRadFrac"); |
| 1137 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procGasLatFracElement = element.child("ProcGasLatFrac"); |
| 1138 |
1/1✓ Branch 1 taken 25 times.
|
25 | pugi::xml_node procGasLostFracElement = element.child("ProcGasLostFrac"); |
| 1139 |
7/9✓ Branch 1 taken 25 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 21 times.
✓ Branch 9 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 21 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25 times.
|
25 | if (bool(procGasPwrDensElement) && (procGasPwrDensElement.text().as_double() > 0)) { |
| 1140 | |||
| 1141 | ✗ | openstudio::Quantity gasDensityIP(procGasPwrDensElement.text().as_double(), openstudio::createUnit("Btu/h*ft^2").get()); | |
| 1142 | ✗ | OptionalQuantity gasDensitySI = QuantityConverter::instance().convert(gasDensityIP, whSys); | |
| 1143 | ✗ | OS_ASSERT(gasDensitySI); | |
| 1144 | ✗ | OS_ASSERT(gasDensitySI->units() == WhUnit(WhExpnt(1, 0, -2))); | |
| 1145 | |||
| 1146 | ✗ | openstudio::model::GasEquipmentDefinition gasEquipmentDefinition(model); | |
| 1147 | ✗ | gasEquipmentDefinition.setName(name + " Gas Loads Definition"); | |
| 1148 | ✗ | gasEquipmentDefinition.setWattsperSpaceFloorArea(gasDensitySI->value()); // W/m2 | |
| 1149 | |||
| 1150 | ✗ | if (procGasRadFracElement) { | |
| 1151 | ✗ | gasEquipmentDefinition.setFractionRadiant(procGasRadFracElement.text().as_double()); | |
| 1152 | } | ||
| 1153 | ✗ | if (procGasLatFracElement) { | |
| 1154 | ✗ | gasEquipmentDefinition.setFractionLatent(procGasLatFracElement.text().as_double()); | |
| 1155 | } | ||
| 1156 | ✗ | if (procGasLostFracElement) { | |
| 1157 | ✗ | gasEquipmentDefinition.setFractionLost(procGasLostFracElement.text().as_double()); | |
| 1158 | } | ||
| 1159 | |||
| 1160 | ✗ | openstudio::model::GasEquipment gasEquipment(gasEquipmentDefinition); | |
| 1161 | ✗ | gasEquipment.setName(name + " Gas Loads"); | |
| 1162 | ✗ | gasEquipment.setSpace(space); | |
| 1163 | ✗ | gasEquipment.setEndUseSubcategory("Process"); | |
| 1164 | |||
| 1165 | ✗ | if (procGasSchRefElement) { | |
| 1166 | ✗ | std::string scheduleName = escapeName(procGasSchRefElement.text().as_string()); | |
| 1167 | ✗ | boost::optional<model::Schedule> schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 1168 | ✗ | if (schedule) { | |
| 1169 | ✗ | gasEquipment.setSchedule(*schedule); | |
| 1170 | } else { | ||
| 1171 | ✗ | LOG(Error, "Could not find schedule '" << scheduleName << "'"); | |
| 1172 | } | ||
| 1173 | ✗ | } | |
| 1174 | ✗ | } | |
| 1175 | } | ||
| 1176 | |||
| 1177 |
1/1✓ Branch 1 taken 25 times.
|
50 | return space; |
| 1178 | 25 | } | |
| 1179 | |||
| 1180 | 16 | boost::optional<openstudio::model::ModelObject> ReverseTranslator::translateConvectionCoefficients(const pugi::xml_node& element, | |
| 1181 | openstudio::model::PlanarSurface& surface) { | ||
| 1182 | 16 | boost::optional<std::string> convectionCoefficient1Location; | |
| 1183 | 16 | boost::optional<std::string> convectionCoefficient1Type; | |
| 1184 | 16 | boost::optional<double> convectionCoefficient1; | |
| 1185 | 16 | boost::optional<std::string> convectionCoefficient2Location; | |
| 1186 | 16 | boost::optional<std::string> convectionCoefficient2Type; | |
| 1187 | 16 | boost::optional<double> convectionCoefficient2; | |
| 1188 | |||
| 1189 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node insideConvCoefElement = element.child("InsideConvCoef"); |
| 1190 |
2/3✓ Branch 1 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
|
16 | if (insideConvCoefElement) { |
| 1191 | |||
| 1192 | // sdd IP units (Btu/h-ft2-F), os SI units (W/m2-K) | ||
| 1193 | ✗ | Quantity coefIP(insideConvCoefElement.text().as_double(), BTUUnit(BTUExpnt(1, -2, -1, -1))); | |
| 1194 | ✗ | OptionalQuantity coefSI = QuantityConverter::instance().convert(coefIP, UnitSystem(UnitSystem::Wh)); | |
| 1195 | ✗ | OS_ASSERT(coefSI); | |
| 1196 | ✗ | OS_ASSERT(coefSI->units() == WhUnit(WhExpnt(1, 0, -2, -1))); | |
| 1197 | |||
| 1198 | ✗ | convectionCoefficient1Location = "Inside"; | |
| 1199 | ✗ | convectionCoefficient1 = coefSI->value(); | |
| 1200 | ✗ | } | |
| 1201 | |||
| 1202 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node outsideConvCoefElement = element.child("OutsideConvCoef"); |
| 1203 |
2/3✓ Branch 1 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
|
16 | if (outsideConvCoefElement) { |
| 1204 | |||
| 1205 | // sdd IP units (Btu/h-ft2-F), os SI units (W/m2-K) | ||
| 1206 | ✗ | Quantity coefIP(outsideConvCoefElement.text().as_double(), BTUUnit(BTUExpnt(1, -2, -1, -1))); | |
| 1207 | ✗ | OptionalQuantity coefSI = QuantityConverter::instance().convert(coefIP, UnitSystem(UnitSystem::Wh)); | |
| 1208 | ✗ | OS_ASSERT(coefSI); | |
| 1209 | ✗ | OS_ASSERT(coefSI->units() == WhUnit(WhExpnt(1, 0, -2, -1))); | |
| 1210 | |||
| 1211 | ✗ | if (convectionCoefficient1Location) { | |
| 1212 | ✗ | convectionCoefficient2Location = "Outside"; | |
| 1213 | ✗ | convectionCoefficient2 = coefSI->value(); | |
| 1214 | } else { | ||
| 1215 | ✗ | convectionCoefficient1Location = "Outside"; | |
| 1216 | ✗ | convectionCoefficient1 = coefSI->value(); | |
| 1217 | } | ||
| 1218 | ✗ | } | |
| 1219 | |||
| 1220 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
16 | if (convectionCoefficient1Location) { |
| 1221 | |||
| 1222 | ✗ | if (auto derivedSurface = surface.optionalCast<model::Surface>()) { | |
| 1223 | ✗ | model::SurfacePropertyConvectionCoefficients surfacePropertyConvectionCoefficients(derivedSurface.get()); | |
| 1224 | |||
| 1225 | ✗ | surfacePropertyConvectionCoefficients.setConvectionCoefficient1Location(*convectionCoefficient1Location); | |
| 1226 | ✗ | surfacePropertyConvectionCoefficients.setConvectionCoefficient1Type("Value"); | |
| 1227 | ✗ | surfacePropertyConvectionCoefficients.setConvectionCoefficient1(*convectionCoefficient1); | |
| 1228 | |||
| 1229 | ✗ | if (convectionCoefficient2Location) { | |
| 1230 | ✗ | surfacePropertyConvectionCoefficients.setConvectionCoefficient2Location(*convectionCoefficient2Location); | |
| 1231 | ✗ | surfacePropertyConvectionCoefficients.setConvectionCoefficient2Type("Value"); | |
| 1232 | ✗ | surfacePropertyConvectionCoefficients.setConvectionCoefficient2(*convectionCoefficient2); | |
| 1233 | } | ||
| 1234 | |||
| 1235 | ✗ | return surfacePropertyConvectionCoefficients; | |
| 1236 | ✗ | } | |
| 1237 | } | ||
| 1238 | |||
| 1239 | 16 | return boost::none; | |
| 1240 | 16 | } | |
| 1241 | |||
| 1242 | 110 | boost::optional<model::ModelObject> ReverseTranslator::translateSurface(const pugi::xml_node& element, openstudio::model::Space& space) { | |
| 1243 | 110 | boost::optional<model::ModelObject> result; | |
| 1244 | |||
| 1245 |
1/1✓ Branch 1 taken 110 times.
|
110 | UnitSystem siSys(UnitSystem::SI); |
| 1246 | |||
| 1247 | 110 | std::vector<openstudio::Point3d> vertices; | |
| 1248 | |||
| 1249 |
1/1✓ Branch 1 taken 110 times.
|
110 | pugi::xml_node polyLoopElement = element.child("PolyLp"); |
| 1250 |
2/3✓ Branch 1 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
|
110 | if (!polyLoopElement) { |
| 1251 | ✗ | LOG(Error, "Surface element 'PolyLp' is empty, cannot create Surface."); | |
| 1252 | ✗ | return boost::none; | |
| 1253 | } | ||
| 1254 | |||
| 1255 |
1/1✓ Branch 1 taken 110 times.
|
110 | std::vector<pugi::xml_node> cartesianPointElements = makeVectorOfChildren(polyLoopElement, "CartesianPt"); |
| 1256 |
2/2✓ Branch 1 taken 440 times.
✓ Branch 2 taken 110 times.
|
550 | for (std::vector<pugi::xml_node>::size_type i = 0; i < cartesianPointElements.size(); i++) { |
| 1257 |
1/1✓ Branch 2 taken 440 times.
|
440 | std::vector<pugi::xml_node> coordinateElements = makeVectorOfChildren(cartesianPointElements[i], "Coord"); |
| 1258 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
|
440 | if (coordinateElements.size() != 3) { |
| 1259 | ✗ | LOG(Error, "PolyLp element 'CartesianPt' does not have exactly 3 'Coord' elements, cannot create Surface."); | |
| 1260 | ✗ | return boost::none; | |
| 1261 | } | ||
| 1262 | |||
| 1263 | /* DLM: these unit conversions are taking about 75% of the total time to translate a large model | ||
| 1264 | |||
| 1265 | // sdd units = ft, os units = m | ||
| 1266 | Quantity xIP(coordinateElements.at(0).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1267 | Quantity yIP(coordinateElements.at(1).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1268 | Quantity zIP(coordinateElements.at(2).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1269 | |||
| 1270 | OptionalQuantity xSI = QuantityConverter::instance().convert(xIP, siSys); | ||
| 1271 | OS_ASSERT(xSI); | ||
| 1272 | OS_ASSERT(xSI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1273 | |||
| 1274 | OptionalQuantity ySI = QuantityConverter::instance().convert(yIP, siSys); | ||
| 1275 | OS_ASSERT(ySI); | ||
| 1276 | OS_ASSERT(ySI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1277 | |||
| 1278 | OptionalQuantity zSI = QuantityConverter::instance().convert(zIP, siSys); | ||
| 1279 | OS_ASSERT(zSI); | ||
| 1280 | OS_ASSERT(zSI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1281 | |||
| 1282 | vertices.push_back(openstudio::Point3d(xSI->value(), ySI->value(), zSI->value())); | ||
| 1283 | */ | ||
| 1284 | |||
| 1285 |
2/2✓ Branch 2 taken 440 times.
✓ Branch 5 taken 440 times.
|
440 | double x = footToMeter * coordinateElements[0].text().as_double(); |
| 1286 |
2/2✓ Branch 2 taken 440 times.
✓ Branch 5 taken 440 times.
|
440 | double y = footToMeter * coordinateElements[1].text().as_double(); |
| 1287 |
2/2✓ Branch 2 taken 440 times.
✓ Branch 5 taken 440 times.
|
440 | double z = footToMeter * coordinateElements[2].text().as_double(); |
| 1288 |
2/2✓ Branch 1 taken 440 times.
✓ Branch 4 taken 440 times.
|
440 | vertices.push_back(openstudio::Point3d(x, y, z)); |
| 1289 | 440 | } | |
| 1290 | |||
| 1291 |
2/2✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
|
110 | openstudio::model::Surface surface(vertices, space.model()); |
| 1292 |
1/1✓ Branch 1 taken 110 times.
|
110 | surface.setSpace(space); |
| 1293 | |||
| 1294 |
1/1✓ Branch 1 taken 110 times.
|
110 | pugi::xml_node nameElement = element.child("Name"); |
| 1295 | 110 | std::string name; | |
| 1296 |
2/3✓ Branch 1 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
|
110 | if (!nameElement) { |
| 1297 | ✗ | LOG(Error, "Surface element 'Name' is empty.") | |
| 1298 | } else { | ||
| 1299 |
4/4✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
✓ Branch 7 taken 110 times.
✓ Branch 10 taken 110 times.
|
110 | name = escapeName(nameElement.text().as_string()); |
| 1300 | } | ||
| 1301 |
1/1✓ Branch 1 taken 110 times.
|
110 | surface.setName(name); |
| 1302 | |||
| 1303 |
1/1✓ Branch 1 taken 110 times.
|
110 | result = surface; |
| 1304 | |||
| 1305 |
1/1✓ Branch 1 taken 110 times.
|
110 | pugi::xml_node constructionReferenceElement = element.child("ConsAssmRef"); |
| 1306 |
2/3✓ Branch 1 taken 110 times.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
|
110 | if (constructionReferenceElement) { |
| 1307 |
4/4✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
✓ Branch 7 taken 110 times.
✓ Branch 10 taken 110 times.
|
110 | std::string constructionName = escapeName(constructionReferenceElement.text().as_string()); |
| 1308 |
2/2✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
|
110 | boost::optional<model::ConstructionBase> construction = space.model().getModelObjectByName<model::ConstructionBase>(constructionName); |
| 1309 |
1/2✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
|
110 | if (construction) { |
| 1310 |
2/2✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
|
110 | surface.setConstruction(*construction); |
| 1311 | } else { | ||
| 1312 | ✗ | LOG(Error, "Cannot find construction '" << constructionName << "'"); | |
| 1313 | } | ||
| 1314 | 110 | } | |
| 1315 | |||
| 1316 | // Get element's (root) tagname | ||
| 1317 |
2/2✓ Branch 1 taken 110 times.
✓ Branch 4 taken 110 times.
|
110 | std::string tagName = element.name(); |
| 1318 |
3/3✓ Branch 1 taken 110 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 78 times.
|
110 | if (tagName == "ExtWall") { |
| 1319 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setSurfaceType("Wall"); |
| 1320 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setOutsideBoundaryCondition("Outdoors"); |
| 1321 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setSunExposure("SunExposed"); |
| 1322 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setWindExposure("WindExposed"); |
| 1323 |
2/3✓ Branch 1 taken 78 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
|
78 | } else if (tagName == "ExtFlr") { |
| 1324 | ✗ | surface.setSurfaceType("Floor"); | |
| 1325 | ✗ | surface.setOutsideBoundaryCondition("Outdoors"); | |
| 1326 | ✗ | surface.setSunExposure("SunExposed"); | |
| 1327 | ✗ | surface.setWindExposure("WindExposed"); | |
| 1328 |
3/3✓ Branch 1 taken 78 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 77 times.
|
78 | } else if (tagName == "Roof") { |
| 1329 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setSurfaceType("RoofCeiling"); |
| 1330 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setOutsideBoundaryCondition("Outdoors"); |
| 1331 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setSunExposure("SunExposed"); |
| 1332 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setWindExposure("WindExposed"); |
| 1333 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 76 times.
|
77 | } else if (tagName.find("UndgrFlr") != std::string::npos) { |
| 1334 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setSurfaceType("Floor"); |
| 1335 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setOutsideBoundaryCondition("Ground"); |
| 1336 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setSunExposure("NoSun"); |
| 1337 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | surface.setWindExposure("NoWind"); |
| 1338 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 72 times.
|
76 | } else if (tagName.find("UndgrWall") != std::string::npos) { |
| 1339 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | surface.setSurfaceType("Wall"); |
| 1340 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | surface.setOutsideBoundaryCondition("Ground"); |
| 1341 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | surface.setSunExposure("NoSun"); |
| 1342 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | surface.setWindExposure("NoWind"); |
| 1343 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
|
72 | } else if (tagName.find("Ceiling") != std::string::npos) { |
| 1344 | ✗ | surface.setSurfaceType("RoofCeiling"); | |
| 1345 | ✗ | surface.setOutsideBoundaryCondition("Adiabatic"); | |
| 1346 | ✗ | surface.setSunExposure("NoSun"); | |
| 1347 | ✗ | surface.setWindExposure("NoWind"); | |
| 1348 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 2 taken 40 times.
|
72 | } else if (tagName.find("IntWall") != std::string::npos) { |
| 1349 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setSurfaceType("Wall"); |
| 1350 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setOutsideBoundaryCondition("Adiabatic"); |
| 1351 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setSunExposure("NoSun"); |
| 1352 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
|
64 | surface.setWindExposure("NoWind"); |
| 1353 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | } else if (tagName.find("IntFlr") != std::string::npos) { |
| 1354 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
80 | surface.setSurfaceType("Floor"); |
| 1355 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
80 | surface.setOutsideBoundaryCondition("Adiabatic"); |
| 1356 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
80 | surface.setSunExposure("NoSun"); |
| 1357 |
2/2✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
|
80 | surface.setWindExposure("NoWind"); |
| 1358 | } else { | ||
| 1359 | ✗ | LOG(Error, "Unknown surface type '" << tagName << "'"); | |
| 1360 | } | ||
| 1361 | |||
| 1362 |
1/1✓ Branch 1 taken 110 times.
|
110 | pugi::xml_node perimExposedElement = element.child("PerimExposed"); |
| 1363 |
3/3✓ Branch 1 taken 110 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 109 times.
|
110 | if (perimExposedElement) { |
| 1364 | |||
| 1365 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | double perimeterExposedIP = perimExposedElement.text().as_double(); |
| 1366 | 1 | double perimeterExposedSI = footToMeter * perimeterExposedIP; | |
| 1367 | |||
| 1368 |
1/1✓ Branch 1 taken 1 time.
|
1 | boost::optional<model::ConstructionBase> construction = surface.construction(); |
| 1369 |
6/12✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
✓ Branch 15 taken 1 time.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
3 | if (construction && construction->optionalCast<model::FFactorGroundFloorConstruction>()) { |
| 1370 | // clone the existing FFactor construction, set perimeter, and assign to this surface | ||
| 1371 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto fFactorConstruction = construction->cast<model::FFactorGroundFloorConstruction>(); |
| 1372 |
1/1✓ Branch 1 taken 1 time.
|
1 | model::Model model = fFactorConstruction.model(); |
| 1373 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | auto clone = fFactorConstruction.clone(model).cast<model::FFactorGroundFloorConstruction>(); |
| 1374 | |||
| 1375 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | std::string cloneName = name + " " + fFactorConstruction.name().get(); |
| 1376 |
1/1✓ Branch 1 taken 1 time.
|
1 | clone.setName(cloneName); |
| 1377 |
1/1✓ Branch 1 taken 1 time.
|
1 | clone.setPerimeterExposed(perimeterExposedSI); |
| 1378 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | clone.setArea(surface.grossArea()); |
| 1379 |
1/1✓ Branch 1 taken 1 time.
|
1 | surface.setConstruction(clone); |
| 1380 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | surface.setOutsideBoundaryCondition("GroundFCfactorMethod"); |
| 1381 | 1 | } else { | |
| 1382 | ✗ | LOG(Error, "Cannot set exposed perimeter for surface '" << name << "''s construction."); | |
| 1383 | } | ||
| 1384 | 1 | } | |
| 1385 | |||
| 1386 |
1/1✓ Branch 1 taken 110 times.
|
110 | pugi::xml_node heightElement = element.child("Hgt"); |
| 1387 |
3/3✓ Branch 1 taken 110 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 106 times.
|
110 | if (heightElement) { |
| 1388 | |||
| 1389 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | double heightIP = heightElement.text().as_double(); |
| 1390 | 4 | double heightSI = footToMeter * heightIP; | |
| 1391 | |||
| 1392 |
1/1✓ Branch 1 taken 4 times.
|
4 | boost::optional<model::ConstructionBase> construction = surface.construction(); |
| 1393 |
6/12✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
12 | if (construction && construction->optionalCast<model::CFactorUndergroundWallConstruction>()) { |
| 1394 | // clone the existing CFactorUndergroundWallConstruction, set height, and assign to this surface | ||
| 1395 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | auto cFactorConstruction = construction->cast<model::CFactorUndergroundWallConstruction>(); |
| 1396 |
1/1✓ Branch 1 taken 4 times.
|
4 | model::Model model = cFactorConstruction.model(); |
| 1397 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | auto clone = cFactorConstruction.clone(model).cast<model::CFactorUndergroundWallConstruction>(); |
| 1398 | |||
| 1399 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | std::string cloneName = name + " " + cFactorConstruction.name().get(); |
| 1400 |
1/1✓ Branch 1 taken 4 times.
|
4 | clone.setName(cloneName); |
| 1401 |
1/1✓ Branch 1 taken 4 times.
|
4 | clone.setHeight(heightSI); |
| 1402 |
1/1✓ Branch 1 taken 4 times.
|
4 | surface.setConstruction(clone); |
| 1403 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | surface.setOutsideBoundaryCondition("GroundFCfactorMethod"); |
| 1404 | 4 | } else { | |
| 1405 | ✗ | LOG(Error, "Cannot set height for surface '" << name << "''s construction."); | |
| 1406 | } | ||
| 1407 | 4 | } | |
| 1408 | |||
| 1409 | // translate subSurfaces | ||
| 1410 |
1/1✓ Branch 1 taken 110 times.
|
110 | std::vector<pugi::xml_node> windowElements = makeVectorOfChildren(element, "Win"); |
| 1411 |
1/1✓ Branch 1 taken 110 times.
|
110 | std::vector<pugi::xml_node> doorElements = makeVectorOfChildren(element, "Dr"); |
| 1412 |
1/1✓ Branch 1 taken 110 times.
|
110 | std::vector<pugi::xml_node> skylightElements = makeVectorOfChildren(element, "Skylt"); |
| 1413 | |||
| 1414 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 2 taken 110 times.
|
126 | for (std::vector<pugi::xml_node>::size_type i = 0; i < windowElements.size(); ++i) { |
| 1415 |
1/1✓ Branch 2 taken 16 times.
|
16 | boost::optional<model::ModelObject> subSurface = translateSubSurface(windowElements[i], surface); |
| 1416 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
16 | if (!subSurface) { |
| 1417 | ✗ | LOG(Error, "Failed to translate 'Win' element " << i << " for Surface named '" << name << "'"); | |
| 1418 | } | ||
| 1419 | 16 | } | |
| 1420 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
|
110 | for (std::vector<pugi::xml_node>::size_type i = 0; i < doorElements.size(); ++i) { |
| 1421 | ✗ | boost::optional<model::ModelObject> subSurface = translateSubSurface(doorElements[i], surface); | |
| 1422 | ✗ | if (!subSurface) { | |
| 1423 | ✗ | LOG(Error, "Failed to translate 'Dr' element " << i << " for Surface named '" << name << "'"); | |
| 1424 | } | ||
| 1425 | ✗ | } | |
| 1426 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
|
110 | for (std::vector<pugi::xml_node>::size_type i = 0; i < skylightElements.size(); ++i) { |
| 1427 | ✗ | boost::optional<model::ModelObject> subSurface = translateSubSurface(skylightElements[i], surface); | |
| 1428 | ✗ | if (!subSurface) { | |
| 1429 | ✗ | LOG(Error, "Failed to translate 'Skylt' element " << i << " for Surface named '" << name << "'"); | |
| 1430 | } | ||
| 1431 | ✗ | } | |
| 1432 | |||
| 1433 | // check for adjacent surface | ||
| 1434 |
1/1✓ Branch 1 taken 110 times.
|
110 | pugi::xml_node adjacentSpaceElement = element.child("AdjacentSpcRef"); |
| 1435 |
3/3✓ Branch 1 taken 110 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 53 times.
|
110 | if (adjacentSpaceElement) { |
| 1436 |
4/4✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 57 times.
✓ Branch 10 taken 57 times.
|
57 | std::string adjacentSpaceName = escapeName(adjacentSpaceElement.text().as_string()); |
| 1437 |
2/2✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
|
57 | boost::optional<model::Space> otherSpace = space.model().getConcreteModelObjectByName<model::Space>(adjacentSpaceName); |
| 1438 | |||
| 1439 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
|
57 | if (!otherSpace) { |
| 1440 | ✗ | LOG(Error, "Cannot retrieve adjacent Space '" << adjacentSpaceName << "' for Surface named '" << name << "'"); | |
| 1441 | |||
| 1442 | // DLM: make adiabatic per David Reddy, 6/5/2015 | ||
| 1443 | //surface.remove(); | ||
| 1444 | //return boost::none; | ||
| 1445 | ✗ | surface.setOutsideBoundaryCondition("Adiabatic"); | |
| 1446 | |||
| 1447 |
5/6✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 57 times.
✓ Branch 10 taken 57 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 57 times.
|
57 | } else if (otherSpace->handle() == space.handle()) { |
| 1448 | ✗ | LOG(Error, | |
| 1449 | "Adjacent Space '" << adjacentSpaceName << "' is same as parent Space for Surface named '" << name << "'. Removing interior surface."); | ||
| 1450 | |||
| 1451 | // DLM: make adiabatic per David Reddy, 6/5/2015 | ||
| 1452 | //surface.remove(); | ||
| 1453 | //return boost::none; | ||
| 1454 | ✗ | surface.setOutsideBoundaryCondition("Adiabatic"); | |
| 1455 | |||
| 1456 | } else { | ||
| 1457 | // clone the surface and sub surfaces with reverse vertices | ||
| 1458 |
2/2✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
|
57 | boost::optional<model::Surface> otherSurface = surface.createAdjacentSurface(*otherSpace); |
| 1459 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
|
57 | if (!otherSurface) { |
| 1460 | ✗ | LOG(Error, | |
| 1461 | "Failed to create surface in adjacent Space '" << adjacentSpaceName << "' for Surface named '" << name << "'. Removing surface."); | ||
| 1462 | |||
| 1463 | // DLM: make adiabatic per David Reddy, 6/5/2015 | ||
| 1464 | //surface.remove(); | ||
| 1465 | //return boost::none; | ||
| 1466 | ✗ | surface.setOutsideBoundaryCondition("Adiabatic"); | |
| 1467 | } | ||
| 1468 | 57 | } | |
| 1469 | 57 | } | |
| 1470 | |||
| 1471 | 110 | return result; | |
| 1472 | 110 | } | |
| 1473 | |||
| 1474 | 16 | boost::optional<openstudio::model::ModelObject> ReverseTranslator::translateSubSurface(const pugi::xml_node& element, | |
| 1475 | openstudio::model::Surface& surface) { | ||
| 1476 | 16 | std::vector<openstudio::Point3d> vertices; | |
| 1477 | |||
| 1478 |
1/1✓ Branch 1 taken 16 times.
|
16 | UnitSystem siSys(UnitSystem::SI); |
| 1479 | |||
| 1480 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node polyLoopElement = element.child("PolyLp"); |
| 1481 |
2/3✓ Branch 1 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
|
16 | if (!polyLoopElement) { |
| 1482 | ✗ | LOG(Error, "SubSurface element 'PolyLp' is empty, cannot create SubSurface."); | |
| 1483 | ✗ | return boost::none; | |
| 1484 | } | ||
| 1485 | |||
| 1486 |
1/1✓ Branch 1 taken 16 times.
|
16 | std::vector<pugi::xml_node> cartesianPointElements = makeVectorOfChildren(polyLoopElement, "CartesianPt"); |
| 1487 |
2/2✓ Branch 1 taken 64 times.
✓ Branch 2 taken 16 times.
|
80 | for (std::vector<pugi::xml_node>::size_type i = 0; i < cartesianPointElements.size(); i++) { |
| 1488 |
1/1✓ Branch 2 taken 64 times.
|
64 | std::vector<pugi::xml_node> coordinateElements = makeVectorOfChildren(cartesianPointElements[i], "Coord"); |
| 1489 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
|
64 | if (coordinateElements.size() != 3) { |
| 1490 | ✗ | LOG(Error, "PolyLp element 'CartesianPt' does not have exactly 3 'Coord' elements, cannot create SubSurface."); | |
| 1491 | ✗ | return boost::none; | |
| 1492 | } | ||
| 1493 | |||
| 1494 | /* DLM: there conversions were taking about 75% of the time it takes to convert a large model | ||
| 1495 | |||
| 1496 | // sdd units = ft, os units = m | ||
| 1497 | Quantity xIP(coordinateElements.at(0).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1498 | Quantity yIP(coordinateElements.at(1).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1499 | Quantity zIP(coordinateElements.at(2).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1500 | |||
| 1501 | OptionalQuantity xSI = QuantityConverter::instance().convert(xIP, siSys); | ||
| 1502 | OS_ASSERT(xSI); | ||
| 1503 | OS_ASSERT(xSI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1504 | |||
| 1505 | OptionalQuantity ySI = QuantityConverter::instance().convert(yIP, siSys); | ||
| 1506 | OS_ASSERT(ySI); | ||
| 1507 | OS_ASSERT(ySI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1508 | |||
| 1509 | OptionalQuantity zSI = QuantityConverter::instance().convert(zIP, siSys); | ||
| 1510 | OS_ASSERT(zSI); | ||
| 1511 | OS_ASSERT(zSI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1512 | |||
| 1513 | vertices.push_back(openstudio::Point3d(xSI->value(), ySI->value(), zSI->value())); | ||
| 1514 | */ | ||
| 1515 | |||
| 1516 |
2/2✓ Branch 2 taken 64 times.
✓ Branch 5 taken 64 times.
|
64 | double x = footToMeter * coordinateElements[0].text().as_double(); |
| 1517 |
2/2✓ Branch 2 taken 64 times.
✓ Branch 5 taken 64 times.
|
64 | double y = footToMeter * coordinateElements[1].text().as_double(); |
| 1518 |
2/2✓ Branch 2 taken 64 times.
✓ Branch 5 taken 64 times.
|
64 | double z = footToMeter * coordinateElements[2].text().as_double(); |
| 1519 |
2/2✓ Branch 1 taken 64 times.
✓ Branch 4 taken 64 times.
|
64 | vertices.push_back(openstudio::Point3d(x, y, z)); |
| 1520 | 64 | } | |
| 1521 | |||
| 1522 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | model::SubSurface subSurface(vertices, surface.model()); |
| 1523 |
1/1✓ Branch 1 taken 16 times.
|
16 | subSurface.setSurface(surface); |
| 1524 | |||
| 1525 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node nameElement = element.child("Name"); |
| 1526 | 16 | std::string name; | |
| 1527 |
2/3✓ Branch 1 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
|
16 | if (!nameElement) { |
| 1528 | ✗ | LOG(Error, "Surface element 'Name' is empty.") | |
| 1529 | } else { | ||
| 1530 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | name = escapeName(nameElement.text().as_string()); |
| 1531 | } | ||
| 1532 |
1/1✓ Branch 1 taken 16 times.
|
16 | subSurface.setName(name); |
| 1533 | |||
| 1534 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | std::string tagName = element.name(); |
| 1535 |
2/3✓ Branch 1 taken 16 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
|
16 | if (tagName == "Win") { |
| 1536 | |||
| 1537 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | subSurface.setSubSurfaceType("FixedWindow"); |
| 1538 | |||
| 1539 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node constructionReferenceElement = element.child("FenConsRef"); |
| 1540 |
2/3✓ Branch 1 taken 16 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
|
16 | if (constructionReferenceElement) { |
| 1541 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
|
16 | std::string constructionName = escapeName(constructionReferenceElement.text().as_string()); |
| 1542 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | boost::optional<model::ConstructionBase> construction = surface.model().getModelObjectByName<model::ConstructionBase>(constructionName); |
| 1543 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (construction) { |
| 1544 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | subSurface.setConstruction(*construction); |
| 1545 | } else { | ||
| 1546 | ✗ | LOG(Error, "Cannot find construction '" << constructionName << "'"); | |
| 1547 | } | ||
| 1548 | 16 | } | |
| 1549 | |||
| 1550 | // Convert surface convection coefficients | ||
| 1551 |
1/1✓ Branch 1 taken 16 times.
|
16 | translateConvectionCoefficients(element, subSurface); |
| 1552 | |||
| 1553 | ✗ | } else if (tagName == "Dr") { | |
| 1554 | |||
| 1555 | ✗ | subSurface.setSubSurfaceType("Door"); | |
| 1556 | |||
| 1557 | ✗ | pugi::xml_node constructionReferenceElement = element.child("DrConsRef"); | |
| 1558 | ✗ | if (constructionReferenceElement) { | |
| 1559 | ✗ | std::string constructionName = escapeName(constructionReferenceElement.text().as_string()); | |
| 1560 | ✗ | boost::optional<model::ConstructionBase> construction = surface.model().getModelObjectByName<model::ConstructionBase>(constructionName); | |
| 1561 | ✗ | if (construction) { | |
| 1562 | ✗ | subSurface.setConstruction(*construction); | |
| 1563 | } else { | ||
| 1564 | ✗ | LOG(Error, "Cannot find construction '" << constructionName << "'"); | |
| 1565 | } | ||
| 1566 | ✗ | } | |
| 1567 | |||
| 1568 | // Convert surface convection coefficients | ||
| 1569 | ✗ | translateConvectionCoefficients(element, subSurface); | |
| 1570 | |||
| 1571 | ✗ | } else if (tagName == "Skylt") { | |
| 1572 | |||
| 1573 | ✗ | subSurface.setSubSurfaceType("Skylight"); | |
| 1574 | |||
| 1575 | ✗ | pugi::xml_node constructionReferenceElement = element.child("FenConsRef"); | |
| 1576 | ✗ | if (constructionReferenceElement) { | |
| 1577 | ✗ | std::string constructionName = escapeName(constructionReferenceElement.text().as_string()); | |
| 1578 | ✗ | boost::optional<model::ConstructionBase> construction = surface.model().getModelObjectByName<model::ConstructionBase>(constructionName); | |
| 1579 | ✗ | if (construction) { | |
| 1580 | ✗ | subSurface.setConstruction(*construction); | |
| 1581 | } else { | ||
| 1582 | ✗ | LOG(Error, "Cannot find construction '" << constructionName << "'"); | |
| 1583 | } | ||
| 1584 | ✗ | } | |
| 1585 | |||
| 1586 | // Convert surface convection coefficients | ||
| 1587 | ✗ | translateConvectionCoefficients(element, subSurface); | |
| 1588 | |||
| 1589 | } else { | ||
| 1590 | ✗ | LOG(Error, "Unknown subsurface type '" << tagName << "'"); | |
| 1591 | } | ||
| 1592 | |||
| 1593 | // DLM: currently unhandled | ||
| 1594 | // InternalShadingDevice | ||
| 1595 | |||
| 1596 |
1/1✓ Branch 1 taken 16 times.
|
16 | return subSurface; |
| 1597 | 16 | } | |
| 1598 | |||
| 1599 | boost::optional<openstudio::model::ModelObject> | ||
| 1600 | ✗ | ReverseTranslator::translateShadingSurface(const pugi::xml_node& element, openstudio::model::ShadingSurfaceGroup& shadingSurfaceGroup) { | |
| 1601 | ✗ | std::vector<openstudio::Point3d> vertices; | |
| 1602 | |||
| 1603 | ✗ | UnitSystem siSys(UnitSystem::SI); | |
| 1604 | |||
| 1605 | ✗ | pugi::xml_node polyLoopElement = element.child("PolyLp"); | |
| 1606 | ✗ | if (!polyLoopElement) { | |
| 1607 | ✗ | LOG(Error, "ShadingSurface element 'PolyLp' is empty, cannot create ShadingSurface."); | |
| 1608 | ✗ | return boost::none; | |
| 1609 | } | ||
| 1610 | |||
| 1611 | ✗ | std::vector<pugi::xml_node> cartesianPointElements = makeVectorOfChildren(polyLoopElement, "CartesianPt"); | |
| 1612 | ✗ | for (std::vector<pugi::xml_node>::size_type i = 0; i < cartesianPointElements.size(); i++) { | |
| 1613 | ✗ | std::vector<pugi::xml_node> coordinateElements = makeVectorOfChildren(cartesianPointElements[i], "Coord"); | |
| 1614 | ✗ | if (coordinateElements.size() != 3) { | |
| 1615 | ✗ | LOG(Error, "PolyLp element 'CartesianPt' does not have exactly 3 'Coord' elements, cannot create ShadingSurface."); | |
| 1616 | ✗ | return boost::none; | |
| 1617 | } | ||
| 1618 | |||
| 1619 | /* DLM: there conversions were taking about 75% of the time it takes to convert a large model | ||
| 1620 | |||
| 1621 | // sdd units = ft, os units = m | ||
| 1622 | Quantity xIP(coordinateElements.at(0).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1623 | Quantity yIP(coordinateElements.at(1).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1624 | Quantity zIP(coordinateElements.at(2).toElement().text().as_double(), IPUnit(IPExpnt(0,1,0))); | ||
| 1625 | |||
| 1626 | OptionalQuantity xSI = QuantityConverter::instance().convert(xIP, siSys); | ||
| 1627 | OS_ASSERT(xSI); | ||
| 1628 | OS_ASSERT(xSI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1629 | |||
| 1630 | OptionalQuantity ySI = QuantityConverter::instance().convert(yIP, siSys); | ||
| 1631 | OS_ASSERT(ySI); | ||
| 1632 | OS_ASSERT(ySI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1633 | |||
| 1634 | OptionalQuantity zSI = QuantityConverter::instance().convert(zIP, siSys); | ||
| 1635 | OS_ASSERT(zSI); | ||
| 1636 | OS_ASSERT(zSI->units() == SIUnit(SIExpnt(0,1,0))); | ||
| 1637 | |||
| 1638 | vertices.push_back(openstudio::Point3d(xSI->value(), ySI->value(), zSI->value())); | ||
| 1639 | */ | ||
| 1640 | |||
| 1641 | ✗ | double x = footToMeter * coordinateElements[0].text().as_double(); | |
| 1642 | ✗ | double y = footToMeter * coordinateElements[1].text().as_double(); | |
| 1643 | ✗ | double z = footToMeter * coordinateElements[2].text().as_double(); | |
| 1644 | ✗ | vertices.push_back(openstudio::Point3d(x, y, z)); | |
| 1645 | ✗ | } | |
| 1646 | |||
| 1647 | ✗ | model::Model model = shadingSurfaceGroup.model(); | |
| 1648 | ✗ | model::ShadingSurface shadingSurface(vertices, model); | |
| 1649 | ✗ | shadingSurface.setShadingSurfaceGroup(shadingSurfaceGroup); | |
| 1650 | |||
| 1651 | ✗ | pugi::xml_node nameElement = element.child("Name"); | |
| 1652 | ✗ | std::string name; | |
| 1653 | ✗ | if (!nameElement) { | |
| 1654 | ✗ | LOG(Error, "ShadingSurface element 'Name' is empty.") | |
| 1655 | } else { | ||
| 1656 | ✗ | name = escapeName(nameElement.text().as_string()); | |
| 1657 | } | ||
| 1658 | ✗ | shadingSurface.setName(name); | |
| 1659 | |||
| 1660 | ✗ | std::string tagName = element.name(); | |
| 1661 | ✗ | if (tagName == "ExtShdgObj") { | |
| 1662 | |||
| 1663 | // default to 0 reflectance | ||
| 1664 | // http://code.google.com/p/cbecc/issues/detail?id=344#c16 | ||
| 1665 | ✗ | double solRefl = 0.0; | |
| 1666 | ✗ | pugi::xml_node solReflElement = element.child("SolRefl"); | |
| 1667 | ✗ | if (solReflElement) { | |
| 1668 | ✗ | solRefl = solReflElement.text().as_double(); | |
| 1669 | } | ||
| 1670 | |||
| 1671 | ✗ | double visRefl = 0.0; | |
| 1672 | ✗ | pugi::xml_node visReflElement = element.child("VisRefl"); | |
| 1673 | ✗ | if (visReflElement) { | |
| 1674 | ✗ | visRefl = visReflElement.text().as_double(); | |
| 1675 | } | ||
| 1676 | |||
| 1677 | ✗ | model::ConstructionBase construction = shadingConstruction(model, solRefl, visRefl); | |
| 1678 | ✗ | shadingSurface.setConstruction(construction); | |
| 1679 | |||
| 1680 | ✗ | pugi::xml_node transOptionElement = element.child("TransOption"); | |
| 1681 | ✗ | if (transOptionElement) { | |
| 1682 | |||
| 1683 | ✗ | boost::optional<model::Schedule> schedule; | |
| 1684 | ✗ | std::string scheduleName; | |
| 1685 | |||
| 1686 | // constant transmittance | ||
| 1687 | ✗ | if (openstudio::istringEqual(transOptionElement.text().as_string(), "Constant")) { | |
| 1688 | |||
| 1689 | ✗ | pugi::xml_node transElement = element.child("Trans"); | |
| 1690 | ✗ | if (transElement) { | |
| 1691 | ✗ | schedule = shadingSchedule(model, transElement.text().as_double()); | |
| 1692 | ✗ | if (schedule) { | |
| 1693 | ✗ | scheduleName = schedule->name().get(); | |
| 1694 | } | ||
| 1695 | } else { | ||
| 1696 | ✗ | LOG(Error, "Cannot find shading transmittance for shading surface '" << name << "'"); | |
| 1697 | } | ||
| 1698 | |||
| 1699 | // transmittance schedule | ||
| 1700 | ✗ | } else if (openstudio::istringEqual(transOptionElement.text().as_string(), "Scheduled")) { | |
| 1701 | |||
| 1702 | ✗ | pugi::xml_node scheduleReferenceElement = element.child("TransSchRef"); | |
| 1703 | ✗ | if (scheduleReferenceElement) { | |
| 1704 | ✗ | scheduleName = escapeName(scheduleReferenceElement.text().as_string()); | |
| 1705 | ✗ | schedule = model.getModelObjectByName<model::Schedule>(scheduleName); | |
| 1706 | ✗ | if (!schedule) { | |
| 1707 | ✗ | LOG(Error, "Cannot find shading schedule '" << scheduleName << "' for shading surface '" << name << "'"); | |
| 1708 | } | ||
| 1709 | } else { | ||
| 1710 | ✗ | LOG(Error, "Cannot find shading schedule for shading surface '" << name << "'"); | |
| 1711 | } | ||
| 1712 | |||
| 1713 | } else { | ||
| 1714 | ✗ | LOG(Error, "Unknown TransOption value for shading surface '" << name << "'"); | |
| 1715 | } | ||
| 1716 | |||
| 1717 | ✗ | if (schedule) { | |
| 1718 | ✗ | bool test = shadingSurface.setTransmittanceSchedule(*schedule); | |
| 1719 | ✗ | if (!test) { | |
| 1720 | ✗ | LOG(Error, "Failed to assign shading schedule '" << scheduleName << "' to shading surface '" << name << "'"); | |
| 1721 | } | ||
| 1722 | } else { | ||
| 1723 | // DLM: could warn here | ||
| 1724 | } | ||
| 1725 | ✗ | } | |
| 1726 | |||
| 1727 | ✗ | } else { | |
| 1728 | ✗ | LOG(Error, "Unknown shading surface type '" << tagName << "'"); | |
| 1729 | } | ||
| 1730 | |||
| 1731 | ✗ | return shadingSurface; | |
| 1732 | ✗ | } | |
| 1733 | |||
| 1734 | ✗ | model::ConstructionBase ReverseTranslator::shadingConstruction(openstudio::model::Model& model, double solRefl, double visRefl) { | |
| 1735 | ✗ | std::pair<double, double> key = std::make_pair(solRefl, visRefl); | |
| 1736 | ✗ | auto it = m_shadingConstructionMap.find(key); | |
| 1737 | ✗ | if (it != m_shadingConstructionMap.end()) { | |
| 1738 | ✗ | return it->second; | |
| 1739 | } | ||
| 1740 | |||
| 1741 | ✗ | std::string description = boost::lexical_cast<std::string>(solRefl) + "-" + boost::lexical_cast<std::string>(visRefl); | |
| 1742 | ✗ | std::string constructionName = "Shading Construction " + description; | |
| 1743 | ✗ | std::string materialName = "Shading Material " + description; | |
| 1744 | |||
| 1745 | // create a construction with these properties | ||
| 1746 | ✗ | model::Construction construction(model); | |
| 1747 | ✗ | construction.setName(constructionName); | |
| 1748 | |||
| 1749 | ✗ | model::MasslessOpaqueMaterial material(model); | |
| 1750 | ✗ | material.setName(materialName); | |
| 1751 | |||
| 1752 | ✗ | bool test = material.setSolarAbsorptance(1.0 - solRefl); | |
| 1753 | ✗ | if (!test) { | |
| 1754 | ✗ | LOG(Error, "Failed to assign solar absorptance '" << 1.0 - solRefl << "' to material '" << materialName << "'"); | |
| 1755 | } | ||
| 1756 | |||
| 1757 | ✗ | test = material.setVisibleAbsorptance(1.0 - visRefl); | |
| 1758 | ✗ | if (!test) { | |
| 1759 | ✗ | LOG(Error, "Failed to assign visible absorptance '" << 1.0 - visRefl << "' to material '" << materialName << "'"); | |
| 1760 | } | ||
| 1761 | |||
| 1762 | ✗ | std::vector<model::Material> materials; | |
| 1763 | ✗ | materials.push_back(material); | |
| 1764 | ✗ | test = construction.setLayers(materials); | |
| 1765 | ✗ | if (!test) { | |
| 1766 | ✗ | LOG(Error, "Failed to assign material layers to Construction named '" << constructionName << "'"); | |
| 1767 | } | ||
| 1768 | |||
| 1769 | ✗ | m_shadingConstructionMap.insert(std::make_pair(key, construction)); | |
| 1770 | ✗ | return std::move(construction); | |
| 1771 | ✗ | } | |
| 1772 | |||
| 1773 | ✗ | model::Schedule ReverseTranslator::shadingSchedule(openstudio::model::Model& model, double trans) { | |
| 1774 | ✗ | auto it = m_shadingScheduleMap.find(trans); | |
| 1775 | ✗ | if (it != m_shadingScheduleMap.end()) { | |
| 1776 | ✗ | return it->second; | |
| 1777 | } | ||
| 1778 | |||
| 1779 | ✗ | auto description = boost::lexical_cast<std::string>(trans); | |
| 1780 | ✗ | std::string scheduleName = "Shading Schedule " + description; | |
| 1781 | |||
| 1782 | // create a schedule with these properties | ||
| 1783 | ✗ | model::ScheduleRuleset schedule(model, trans); | |
| 1784 | ✗ | schedule.setName(scheduleName); | |
| 1785 | |||
| 1786 | ✗ | m_shadingScheduleMap.insert(std::make_pair(trans, schedule)); | |
| 1787 | ✗ | return std::move(schedule); | |
| 1788 | ✗ | } | |
| 1789 | |||
| 1790 | 1 | boost::optional<pugi::xml_node> ForwardTranslator::translateBuilding(const openstudio::model::Building& building, pugi::xml_node& root) { | |
| 1791 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node result = root.append_child("Bldg"); |
| 1792 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | m_translatedObjects[building.handle()] = result; |
| 1793 | |||
| 1794 | // name | ||
| 1795 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | std::string name = building.name().get(); |
| 1796 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node nameElement = result.append_child("Name"); |
| 1797 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
|
1 | nameElement.text() = escapeName(name).c_str(); |
| 1798 | |||
| 1799 | // SDD: | ||
| 1800 | // FuncClassMthd - optional, ignore | ||
| 1801 | // RelocPubSchoolBldg - optional, in progress | ||
| 1802 | // WholeBldgModeled - required, need to add | ||
| 1803 | // BldgAz - required, done | ||
| 1804 | // TotStoryCnt - required, in progress | ||
| 1805 | // TotStoryCntNew - optional, need to add? | ||
| 1806 | // TotStoryCntExisting - optional, need to add? | ||
| 1807 | // TotStoryCntAltered - optional, need to add? | ||
| 1808 | // AboveGrdStoryCnt - required, in progress | ||
| 1809 | // AboveGrdStoryCntNew - optional, need to add? | ||
| 1810 | // AboveGrdStoryCntExisting - optional, need to add? | ||
| 1811 | // AboveGrdStoryCntAltered - optional, need to add? | ||
| 1812 | // LivingUnitCnt - defaulted, in progress | ||
| 1813 | // LivingUnitCntNew - optional, need to add? | ||
| 1814 | // LivingUnitCntExisting - optional, need to add? | ||
| 1815 | // LivingUnitCntAltered - optional, need to add? | ||
| 1816 | // TotFlrArea - defaulted, ignore | ||
| 1817 | // NonResFlrArea - defaulted, ignore | ||
| 1818 | // ResFlrArea - defaulted, ignore | ||
| 1819 | // TotCondVol - defaulted, ignore | ||
| 1820 | // PlantClgCap - defaulted, ignore | ||
| 1821 | // PlantHtgCap - defaulted, ignore | ||
| 1822 | // CoilClgCap - defaulted, ignore | ||
| 1823 | // CoilHtgCap - defaulted, ignore | ||
| 1824 | |||
| 1825 | // building azimuth | ||
| 1826 |
1/1✓ Branch 1 taken 1 time.
|
1 | double buildingAzimuth = normalizeAngle0to360(building.northAxis()); |
| 1827 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node buildingAzimuthElement = result.append_child("BldgAz"); |
| 1828 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
|
1 | buildingAzimuthElement.text() = openstudio::string_conversions::number(buildingAzimuth).c_str(); |
| 1829 | |||
| 1830 | // TotStoryCnt - required, Standards Number of Stories | ||
| 1831 | // AboveGrdStoryCnt - required, Standards Number of Above Ground Stories | ||
| 1832 | // LivingUnitCnt - defaulted, Standards Number of Living Units | ||
| 1833 | |||
| 1834 | // translate storys | ||
| 1835 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::vector<model::BuildingStory> buildingStories = building.model().getConcreteModelObjects<model::BuildingStory>(); |
| 1836 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(buildingStories.begin(), buildingStories.end(), WorkspaceObjectNameLess()); |
| 1837 | |||
| 1838 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 1839 | ✗ | m_progressBar->setWindowTitle(toString("Translating Building Stories")); | |
| 1840 | ✗ | m_progressBar->setMinimum(0); | |
| 1841 | ✗ | m_progressBar->setMaximum((int)buildingStories.size()); | |
| 1842 | ✗ | m_progressBar->setValue(0); | |
| 1843 | } | ||
| 1844 | |||
| 1845 | // DLM: do not translate aboveGradeStoryCount, Issue 243: Forward Translator - AboveGrdStryCount | ||
| 1846 | /* | ||
| 1847 | // aboveGradeStoryCount | ||
| 1848 | unsigned numAboveGroundStories = 0; | ||
| 1849 | for (const model::BuildingStory& buildingStory : buildingStories){ | ||
| 1850 | boost::optional<double> nominalZCoordinate = buildingStory.nominalZCoordinate(); | ||
| 1851 | if (nominalZCoordinate && *nominalZCoordinate >= 0){ | ||
| 1852 | numAboveGroundStories += 1; | ||
| 1853 | } | ||
| 1854 | } | ||
| 1855 | |||
| 1856 | pugi::xml_node aboveGradeStoryCountElement = result.append_child("AboveGrdStoryCnt"); | ||
| 1857 | aboveGradeStoryCountElement.text() = openstudio::string_conversions::number(numAboveGroundStories).c_str(); | ||
| 1858 | */ | ||
| 1859 | |||
| 1860 | // translate building shading | ||
| 1861 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::vector<model::ShadingSurfaceGroup> shadingSurfaceGroups = building.model().getConcreteModelObjects<model::ShadingSurfaceGroup>(); |
| 1862 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(shadingSurfaceGroups.begin(), shadingSurfaceGroups.end(), WorkspaceObjectNameLess()); |
| 1863 | |||
| 1864 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 1865 | ✗ | m_progressBar->setWindowTitle(toString("Translating Building Shading")); | |
| 1866 | ✗ | m_progressBar->setMinimum(0); | |
| 1867 | ✗ | m_progressBar->setMaximum((int)shadingSurfaceGroups.size()); | |
| 1868 | ✗ | m_progressBar->setValue(0); | |
| 1869 | } | ||
| 1870 | |||
| 1871 |
2/2✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 time.
|
4 | for (const model::ShadingSurfaceGroup& shadingSurfaceGroup : shadingSurfaceGroups) { |
| 1872 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 2 times.
|
6 | if (istringEqual(shadingSurfaceGroup.shadingSurfaceType(), "Building")) { |
| 1873 | |||
| 1874 |
1/1✓ Branch 1 taken 1 time.
|
1 | Transformation transformation = shadingSurfaceGroup.siteTransformation(); |
| 1875 | |||
| 1876 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 1 time.
|
2 | for (const model::ShadingSurface& shadingSurface : shadingSurfaceGroup.shadingSurfaces()) { |
| 1877 |
1/1✓ Branch 1 taken 1 time.
|
1 | translateShadingSurface(shadingSurface, transformation, result); |
| 1878 | 1 | } | |
| 1879 | 1 | } | |
| 1880 | |||
| 1881 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (m_progressBar) { |
| 1882 | ✗ | m_progressBar->setValue(m_progressBar->value() + 1); | |
| 1883 | } | ||
| 1884 | } | ||
| 1885 | |||
| 1886 | // translate building story | ||
| 1887 |
2/2✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
|
2 | for (const model::BuildingStory& buildingStory : buildingStories) { |
| 1888 |
1/1✓ Branch 1 taken 1 time.
|
1 | translateBuildingStory(buildingStory, result); |
| 1889 | |||
| 1890 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 1891 | ✗ | m_progressBar->setValue(m_progressBar->value() + 1); | |
| 1892 | } | ||
| 1893 | } | ||
| 1894 | |||
| 1895 | // issue warning if any spaces not assigned to building story | ||
| 1896 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::vector<model::Space> spaces = building.model().getConcreteModelObjects<model::Space>(); |
| 1897 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(spaces.begin(), spaces.end(), WorkspaceObjectNameLess()); |
| 1898 | 1 | std::string spacesWithoutStory; | |
| 1899 | 1 | std::string spacesWithoutZone; | |
| 1900 |
2/2✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 time.
|
5 | for (const model::Space& space : spaces) { |
| 1901 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
|
4 | if (!space.buildingStory()) { |
| 1902 | ✗ | spacesWithoutStory += " '" + space.name().get() + "',"; | |
| 1903 | } | ||
| 1904 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
|
4 | if (!space.thermalZone()) { |
| 1905 | ✗ | spacesWithoutZone += " '" + space.name().get() + "',"; | |
| 1906 | } | ||
| 1907 | } | ||
| 1908 | |||
| 1909 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!spacesWithoutStory.empty()) { |
| 1910 | ✗ | spacesWithoutStory.pop_back(); | |
| 1911 | ✗ | LOG(Warn, "Model contains spaces which are not assigned to a building story, these have not been translated:" << spacesWithoutStory); | |
| 1912 | } | ||
| 1913 | |||
| 1914 | 1 | if (!spacesWithoutZone.empty()) { | |
| 1915 | // DLM: desired workflow is to assign thermal zones in cbecc | ||
| 1916 | // DLM: Kyle, we will have to think about if we want to warn about this or not | ||
| 1917 | //Do not want this logged, http://code.google.com/p/cbecc/issues/detail?id=695 | ||
| 1918 | //spacesWithoutZone.pop_back(); | ||
| 1919 | //LOG(Warn, "Model contains spaces which are not assigned to a thermal zone, these have not been translated:" << spacesWithoutZone); | ||
| 1920 | } | ||
| 1921 | |||
| 1922 | // issue warning if any surfaces not assigned to space | ||
| 1923 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::vector<model::Surface> surfaces = building.model().getConcreteModelObjects<model::Surface>(); |
| 1924 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(surfaces.begin(), surfaces.end(), WorkspaceObjectNameLess()); |
| 1925 | 1 | std::string surfacesWithoutSpace; | |
| 1926 |
2/2✓ Branch 5 taken 24 times.
✓ Branch 6 taken 1 time.
|
25 | for (const model::Surface& surface : surfaces) { |
| 1927 |
2/3✓ Branch 1 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
|
24 | if (!surface.space()) { |
| 1928 | ✗ | surfacesWithoutSpace += " '" + surface.name().get() + "',"; | |
| 1929 | } | ||
| 1930 | } | ||
| 1931 | |||
| 1932 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!surfacesWithoutSpace.empty()) { |
| 1933 | ✗ | surfacesWithoutSpace.pop_back(); | |
| 1934 | ✗ | LOG(Warn, "Model contains surfaces which are not assigned to a space, these have not been translated:" << surfacesWithoutSpace); | |
| 1935 | } | ||
| 1936 | |||
| 1937 | // issue warning if any sub surfaces not assigned to surface | ||
| 1938 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::vector<model::SubSurface> subSurfaces = building.model().getConcreteModelObjects<model::SubSurface>(); |
| 1939 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(subSurfaces.begin(), subSurfaces.end(), WorkspaceObjectNameLess()); |
| 1940 | 1 | std::string subSurfacesWithoutSurface; | |
| 1941 |
2/2✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 time.
|
3 | for (const model::SubSurface& subSurface : subSurfaces) { |
| 1942 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | if (!subSurface.surface()) { |
| 1943 | ✗ | subSurfacesWithoutSurface += " '" + subSurface.name().get() + "',"; | |
| 1944 | } | ||
| 1945 | } | ||
| 1946 | |||
| 1947 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!subSurfacesWithoutSurface.empty()) { |
| 1948 | ✗ | subSurfacesWithoutSurface.pop_back(); | |
| 1949 | ✗ | LOG(Warn, "Model contains sub surfaces which are not assigned to a surface, these have not been translated:" << subSurfacesWithoutSurface); | |
| 1950 | } | ||
| 1951 | |||
| 1952 | // translate thermal zones | ||
| 1953 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | std::vector<model::ThermalZone> thermalZones = building.model().getConcreteModelObjects<model::ThermalZone>(); |
| 1954 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(thermalZones.begin(), thermalZones.end(), WorkspaceObjectNameLess()); |
| 1955 | |||
| 1956 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 1957 | ✗ | m_progressBar->setWindowTitle(toString("Translating Thermal Zones")); | |
| 1958 | ✗ | m_progressBar->setMinimum(0); | |
| 1959 | ✗ | m_progressBar->setMaximum((int)thermalZones.size()); | |
| 1960 | ✗ | m_progressBar->setValue(0); | |
| 1961 | } | ||
| 1962 | |||
| 1963 |
2/2✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
|
2 | for (const model::ThermalZone& thermalZone : thermalZones) { |
| 1964 | |||
| 1965 |
1/1✓ Branch 1 taken 1 time.
|
1 | translateThermalZone(thermalZone, result); |
| 1966 | |||
| 1967 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 1968 | ✗ | m_progressBar->setValue(m_progressBar->value() + 1); | |
| 1969 | } | ||
| 1970 | } | ||
| 1971 | |||
| 1972 | // translate AirLoopHVAC systems | ||
| 1973 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto airLoops = building.model().getConcreteModelObjects<model::AirLoopHVAC>(); |
| 1974 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(airLoops.begin(), airLoops.end(), WorkspaceObjectNameLess()); |
| 1975 | |||
| 1976 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 1977 | ✗ | m_progressBar->setWindowTitle(toString("Translating AirLoopHVAC Systems")); | |
| 1978 | ✗ | m_progressBar->setMinimum(0); | |
| 1979 | ✗ | m_progressBar->setMaximum((int)airLoops.size()); | |
| 1980 | ✗ | m_progressBar->setValue(0); | |
| 1981 | } | ||
| 1982 | |||
| 1983 |
2/2✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
|
2 | for (const auto& airLoop : airLoops) { |
| 1984 |
1/1✓ Branch 1 taken 1 time.
|
1 | translateAirLoopHVAC(airLoop, result); |
| 1985 | |||
| 1986 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (m_progressBar) { |
| 1987 | ✗ | m_progressBar->setValue(m_progressBar->value() + 1); | |
| 1988 | } | ||
| 1989 | } | ||
| 1990 | |||
| 1991 |
1/1✓ Branch 1 taken 1 time.
|
2 | return result; |
| 1992 | 1 | } | |
| 1993 | |||
| 1994 | 1 | boost::optional<pugi::xml_node> ForwardTranslator::translateBuildingStory(const openstudio::model::BuildingStory& buildingStory, | |
| 1995 | pugi::xml_node& root) { | ||
| 1996 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node result = root.append_child("Story"); |
| 1997 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | m_translatedObjects[buildingStory.handle()] = result; |
| 1998 | |||
| 1999 | // name | ||
| 2000 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | std::string name = buildingStory.name().get(); |
| 2001 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node nameElement = result.append_child("Name"); |
| 2002 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
|
1 | nameElement.text() = escapeName(name).c_str(); |
| 2003 | |||
| 2004 | // SDD: | ||
| 2005 | // Mult - defaulted, ignore (OS doesn't have this) | ||
| 2006 | // Z - only for simple geometry, ignore | ||
| 2007 | // FlrToFlrHgt - only for simple geometry, ignore | ||
| 2008 | // FlrToCeilingHgt - only for simple geometry, ignore | ||
| 2009 | |||
| 2010 | // translate spaces | ||
| 2011 |
1/1✓ Branch 1 taken 1 time.
|
1 | std::vector<model::Space> spaces = buildingStory.spaces(); |
| 2012 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::sort(spaces.begin(), spaces.end(), WorkspaceObjectNameLess()); |
| 2013 | |||
| 2014 |
2/2✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 time.
|
5 | for (const model::Space& space : spaces) { |
| 2015 |
1/1✓ Branch 1 taken 4 times.
|
4 | translateSpace(space, result); |
| 2016 | } | ||
| 2017 | |||
| 2018 |
1/1✓ Branch 1 taken 1 time.
|
2 | return result; |
| 2019 | 1 | } | |
| 2020 | |||
| 2021 | 4 | boost::optional<pugi::xml_node> ForwardTranslator::translateSpace(const openstudio::model::Space& space, pugi::xml_node& root) { | |
| 2022 |
1/1✓ Branch 1 taken 4 times.
|
4 | UnitSystem ipSys(UnitSystem::IP); |
| 2023 |
1/1✓ Branch 1 taken 4 times.
|
4 | UnitSystem btuSys(UnitSystem::BTU); |
| 2024 | |||
| 2025 |
1/1✓ Branch 1 taken 4 times.
|
4 | pugi::xml_node result = root.append_child("Spc"); |
| 2026 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | m_translatedObjects[space.handle()] = result; |
| 2027 | |||
| 2028 | // name | ||
| 2029 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | std::string name = space.name().get(); |
| 2030 |
1/1✓ Branch 1 taken 4 times.
|
4 | pugi::xml_node nameElement = result.append_child("Name"); |
| 2031 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
|
4 | nameElement.text() = escapeName(name).c_str(); |
| 2032 | |||
| 2033 | // SDD: | ||
| 2034 | // Status - required, need to add | ||
| 2035 | // CondgType - required, in progress | ||
| 2036 | // SupPlenumSpcRef - optional, in progress | ||
| 2037 | // RetPlenumSpcRef - optional, in progress | ||
| 2038 | // ThrmlZnRef - required, done | ||
| 2039 | // Area - only for simple geometry, done, can we remove? | ||
| 2040 | // FlrArea - optional, do we need this? | ||
| 2041 | // FlrZ - optional, do we need this? | ||
| 2042 | // FlrToCeilingHgt - optional, do we need this? | ||
| 2043 | // Vol - required, done, can we remove? | ||
| 2044 | // SpcFuncDefaultsRef - optional, do with space types | ||
| 2045 | // SpcFunc - compulsory, do with space types | ||
| 2046 | // FuncSchGrp - optional, do with space types | ||
| 2047 | // OccDensSim - optional, do with space types | ||
| 2048 | // OccSensHtRt - optional, do with space types | ||
| 2049 | // OccLatHtRt - optional, do with space types | ||
| 2050 | // OccSchRef - optional, do with space types | ||
| 2051 | // InfMthd - defaulted, do with space types | ||
| 2052 | // DsgnInfRt - defaulted, do with space types | ||
| 2053 | // InfSchRef - defaulted, do with space types | ||
| 2054 | // InfModelCoefA - required, do with space types | ||
| 2055 | // InfModelCoefB - required, do with space types | ||
| 2056 | // InfModelCoefC - required, do with space types | ||
| 2057 | // InfModelCoefD - required, do with space types | ||
| 2058 | // EnvStatus - optional, do with space types | ||
| 2059 | // LtgStatus - optional, do with space types | ||
| 2060 | // IntLtgSpecMthd - required, do with space types | ||
| 2061 | // IntLPDReg - optional, do with space types | ||
| 2062 | // IntLtgRegSchRef - optional, do with space types | ||
| 2063 | // IntLtgRegHtGnSpcFrac - optional, do with space types | ||
| 2064 | // IntLtgRegHtGnRadFrac - optional, do with space types | ||
| 2065 | // IntLPDNonReg - optional, do with space types | ||
| 2066 | // IntLtgNonRegSchRef - optional, do with space types | ||
| 2067 | // IntLtgNonRegHtGnSpcFrac - optional, do with space types | ||
| 2068 | // IntLtgNonRegHtGnRadFrac - optional, do with space types | ||
| 2069 | // SkylitDayltgInstalledLtgPwr - optional, do we need this? | ||
| 2070 | // PriSideDayltgInstalledLtgPwr - optional, do we need this? | ||
| 2071 | // SecSideDayltgInstalledLtgPwr - optional, do we need this? | ||
| 2072 | // Skylit100PctControlled - optional, do we need this? | ||
| 2073 | // PriSide100PctControlled - optional, do we need this? | ||
| 2074 | // SecSide100PctControlled - optional, do we need this? | ||
| 2075 | // SkylitDayltgRefPtCoord - optional, do we need this? | ||
| 2076 | // SkylitDayltgCtrlLtgPwr - optional, do we need this? | ||
| 2077 | // SkylitDayltgCtrlLtgFrac - optional, do we need this? | ||
| 2078 | // SkylitDayltgIllumSetpt - optional, do we need this? | ||
| 2079 | // PriSideDayltgRefPtCoord - optional, do we need this? | ||
| 2080 | // PriSideDayltgCtrlLtgPwr - optional, do we need this? | ||
| 2081 | // PriSideDayltgCtrlLtgFrac - optional, do we need this? | ||
| 2082 | // PriSideDayltgIllumSetpt - optional, do we need this? | ||
| 2083 | // SecSideDayltgRefPtCoord - optional, do we need this? | ||
| 2084 | // SecSideDayltgCtrlLtgPwr - optional, do we need this? | ||
| 2085 | // SecSideDayltgCtrlLtgFrac - optional, do we need this? | ||
| 2086 | // SecSideDayltgIllumSetpt - optional, do we need this? | ||
| 2087 | // DayltgCtrlType - optional, do we need this? | ||
| 2088 | // MinDimLtgFrac - optional, do we need this? | ||
| 2089 | // MinDimPwrFrac - optional, do we need this? | ||
| 2090 | // NumOfCtrlSteps - optional, do we need this? | ||
| 2091 | // GlrAz - optional, do we need this? | ||
| 2092 | // MaxGlrIdx - optional, do we need this? | ||
| 2093 | // SkyltReqExcpt - optional, do we need this? | ||
| 2094 | // SkyltReqExcptArea - optional, do we need this? | ||
| 2095 | // SkyltReqExcptFrac - optional, do we need this? | ||
| 2096 | // RecptPwrDens - defaulted, do with space types | ||
| 2097 | // RecptSchRef - defaulted, do with space types | ||
| 2098 | // RecptRadFrac - defaulted, do with space types | ||
| 2099 | // RecptLatFrac - defaulted, do with space types | ||
| 2100 | // RecptLostFrac - defaulted, do with space types | ||
| 2101 | // GasEqpPwrDens - defaulted, do with space types | ||
| 2102 | // GasEqpSchRef - defaulted, do with space types | ||
| 2103 | // GasEqpRadFrac - defaulted, do with space types | ||
| 2104 | // GasEqpLatFrac - defaulted, do with space types | ||
| 2105 | // GasEqpLostFrac - defaulted, do with space types | ||
| 2106 | // ProcElecPwrDens - optional, do with space types | ||
| 2107 | // ProcElecSchRef - optional, do with space types | ||
| 2108 | // ProcElecRadFrac - optional, do with space types | ||
| 2109 | // ProcElecLatFrac - optional, do with space types | ||
| 2110 | // ProcElecLostFrac - optional, do with space types | ||
| 2111 | // ProcGasPwrDens - optional, do with space types | ||
| 2112 | // ProcGasSchRef - optional, do with space types | ||
| 2113 | // ProcGasRadFrac - optional, do with space types | ||
| 2114 | // ProcGasLatFrac - optional, do with space types | ||
| 2115 | // ProcGasLostFrac - optional, do with space types | ||
| 2116 | // CommRfrgEPD - defaulted, do with space types | ||
| 2117 | // CommRfrgEqpSchRef - defaulted, do with space types | ||
| 2118 | // CommRfrgRadFrac - defaulted, do with space types | ||
| 2119 | // CommRfrgLatFrac - defaulted, do with space types | ||
| 2120 | // CommRfrgLostFrac - defaulted, do with space types | ||
| 2121 | // ElevCnt - optional, do with space types | ||
| 2122 | // ElevPwr - optional, do with space types | ||
| 2123 | // ElevSchRef - defaulted, do with space types | ||
| 2124 | // ElevRadFrac - optional, do with space types | ||
| 2125 | // ElevLatFrac - optional, do with space types | ||
| 2126 | // ElevLostFrac - optional, do with space types | ||
| 2127 | // EscalCnt - optional, do with space types | ||
| 2128 | // EscalPwr - optional, do with space types | ||
| 2129 | // EscalSchRef - defaulted, do with space types | ||
| 2130 | // EscalRadFrac - optional, do with space types | ||
| 2131 | // EscalLatFrac - optional, do with space types | ||
| 2132 | // EscalLostFrac - optional, do with space types | ||
| 2133 | // SHWFluidSegRef - optional, do with space types | ||
| 2134 | // RecircDHWSysRef - optional, do with space types | ||
| 2135 | // HotWtrHtgRt - defaulted, do with space types | ||
| 2136 | // RecircHotWtrHtgRt - optional, do with space types | ||
| 2137 | // HotWtrHtgSchRef - optional, do with space types | ||
| 2138 | // VentPerPerson - defaulted, do with space types | ||
| 2139 | // VentPerArea - defaulted, do with space types | ||
| 2140 | // VentACH - optional, do with space types | ||
| 2141 | // VentPerSpc - optional, do with space types | ||
| 2142 | // ExhPerArea - optional, do we need this? | ||
| 2143 | // ExhACH - optional, do we need this? | ||
| 2144 | // ExhPerSpc - optional, do we need this? | ||
| 2145 | // KitExhHoodLen - optional, do we need this? | ||
| 2146 | // KitExhHoodStyle - optional, do we need this? | ||
| 2147 | // KitExhHoodDuty - optional, do we need this? | ||
| 2148 | // KitExhHoodFlow - optional, do we need this? | ||
| 2149 | // LabExhRtType - optional, do we need this? | ||
| 2150 | // IntLPDPrescrip - optional, do we need this? | ||
| 2151 | // IsPlenumRet - optional, do we need this? | ||
| 2152 | // HighRiseResInt - optional, do we need this? | ||
| 2153 | // HighRiseResCondFlrArea - optional, do we need this? | ||
| 2154 | |||
| 2155 | // volume | ||
| 2156 |
1/1✓ Branch 1 taken 4 times.
|
4 | double volume = space.volume(); |
| 2157 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
|
4 | Quantity volumeSI(volume, SIUnit(SIExpnt(0, 3, 0))); |
| 2158 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | OptionalQuantity volumeIP = QuantityConverter::instance().convert(volumeSI, ipSys); |
| 2159 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(volumeIP); |
| 2160 |
6/8✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 14 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 19 not taken.
|
4 | OS_ASSERT(volumeIP->units() == IPUnit(IPExpnt(0, 3, 0))); |
| 2161 |
1/1✓ Branch 1 taken 4 times.
|
4 | pugi::xml_node volumeElement = result.append_child("Vol"); |
| 2162 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 14 taken 4 times.
|
4 | volumeElement.text() = openstudio::string_conversions::number(volumeIP->value()).c_str(); |
| 2163 | |||
| 2164 | // log warning if volume is 0 | ||
| 2165 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
|
4 | if (volumeIP->value() < std::numeric_limits<double>::epsilon()) { |
| 2166 | ✗ | LOG(Warn, "Space '" << name << "' has zero volume."); | |
| 2167 | } | ||
| 2168 | |||
| 2169 | // area | ||
| 2170 |
1/1✓ Branch 1 taken 4 times.
|
4 | double floorArea = space.floorArea(); |
| 2171 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
|
4 | Quantity floorAreaSI(floorArea, SIUnit(SIExpnt(0, 2, 0))); |
| 2172 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | OptionalQuantity floorAreaIP = QuantityConverter::instance().convert(floorAreaSI, ipSys); |
| 2173 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(floorAreaIP); |
| 2174 |
6/8✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 14 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 19 not taken.
|
4 | OS_ASSERT(floorAreaIP->units() == IPUnit(IPExpnt(0, 2, 0))); |
| 2175 |
1/1✓ Branch 1 taken 4 times.
|
4 | pugi::xml_node floorAreaElement = result.append_child("Area"); // SAC 3/14/14 |
| 2176 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 14 taken 4 times.
|
4 | floorAreaElement.text() = openstudio::string_conversions::number(floorAreaIP->value()).c_str(); |
| 2177 | |||
| 2178 | // log warning if area is 0 | ||
| 2179 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
|
4 | if (floorAreaIP->value() < std::numeric_limits<double>::epsilon()) { |
| 2180 | ✗ | LOG(Warn, "Space '" << name << "' has zero floor area."); | |
| 2181 | } | ||
| 2182 | |||
| 2183 | // translate floorPrint | ||
| 2184 |
1/1✓ Branch 1 taken 4 times.
|
4 | Transformation transformation = space.siteTransformation(); |
| 2185 | |||
| 2186 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | Point3dVector vertices = transformation * space.floorPrint(); |
| 2187 |
1/1✓ Branch 1 taken 4 times.
|
4 | boost::optional<double> floorPrintArea = openstudio::getArea(vertices); |
| 2188 |
3/6✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
|
4 | if (vertices.empty() || !floorPrintArea) { |
| 2189 | ✗ | LOG(Warn, "Cannot compute floor print for space '" << name << "'."); | |
| 2190 | } else { | ||
| 2191 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
|
4 | Quantity floorPrintAreaSI(*floorPrintArea, SIUnit(SIExpnt(0, 2, 0))); |
| 2192 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | OptionalQuantity floorPrintAreaIP = QuantityConverter::instance().convert(floorPrintAreaSI, ipSys); |
| 2193 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(floorPrintAreaIP); |
| 2194 |
6/8✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 14 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 19 not taken.
|
4 | OS_ASSERT(floorPrintAreaIP->units() == IPUnit(IPExpnt(0, 2, 0))); |
| 2195 | |||
| 2196 | // log warning if floor print area is 0 | ||
| 2197 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
|
4 | if (floorPrintAreaIP->value() < std::numeric_limits<double>::epsilon()) { |
| 2198 | ✗ | LOG(Warn, "Space '" << name << "' has zero floor print area."); | |
| 2199 | } | ||
| 2200 | 4 | } | |
| 2201 | |||
| 2202 |
1/1✓ Branch 1 taken 4 times.
|
4 | pugi::xml_node polyLoopElement = result.append_child("PolyLp"); |
| 2203 |
2/2✓ Branch 4 taken 16 times.
✓ Branch 5 taken 4 times.
|
20 | for (const Point3d& vertex : vertices) { |
| 2204 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node cartesianPointElement = polyLoopElement.append_child("CartesianPt"); |
| 2205 | |||
| 2206 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node coordinateXElement = cartesianPointElement.append_child("Coord"); |
| 2207 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 11 taken 16 times.
|
16 | coordinateXElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.x()).c_str(); |
| 2208 | |||
| 2209 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node coordinateYElement = cartesianPointElement.append_child("Coord"); |
| 2210 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 11 taken 16 times.
|
16 | coordinateYElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.y()).c_str(); |
| 2211 | |||
| 2212 |
1/1✓ Branch 1 taken 16 times.
|
16 | pugi::xml_node coordinateZElement = cartesianPointElement.append_child("Coord"); |
| 2213 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 11 taken 16 times.
|
16 | coordinateZElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.z()).c_str(); |
| 2214 | } | ||
| 2215 | |||
| 2216 | // thermal zone | ||
| 2217 |
1/1✓ Branch 1 taken 4 times.
|
4 | boost::optional<model::ThermalZone> thermalZone = space.thermalZone(); |
| 2218 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (thermalZone) { |
| 2219 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | std::string thermalZoneName = thermalZone->name().get(); |
| 2220 |
1/1✓ Branch 1 taken 4 times.
|
4 | pugi::xml_node thermalZoneElement = result.append_child("ThrmlZnRef"); |
| 2221 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
|
4 | thermalZoneElement.text() = escapeName(thermalZoneName).c_str(); |
| 2222 | |||
| 2223 | // CondgType - required | ||
| 2224 | // SupPlenumSpcRef - optional | ||
| 2225 | // RetPlenumSpcRef - optional | ||
| 2226 | // ThrmlZnRef - required | ||
| 2227 | 4 | } | |
| 2228 | |||
| 2229 | // translate space shading | ||
| 2230 |
1/1✓ Branch 1 taken 4 times.
|
4 | std::vector<model::ShadingSurfaceGroup> shadingSurfaceGroups = space.shadingSurfaceGroups(); |
| 2231 |
1/1✓ Branch 3 taken 4 times.
|
4 | std::sort(shadingSurfaceGroups.begin(), shadingSurfaceGroups.end(), WorkspaceObjectNameLess()); |
| 2232 | |||
| 2233 |
2/2✓ Branch 5 taken 1 time.
✓ Branch 6 taken 4 times.
|
5 | for (const model::ShadingSurfaceGroup& shadingSurfaceGroup : shadingSurfaceGroups) { |
| 2234 |
1/1✓ Branch 1 taken 1 time.
|
1 | Transformation shadingTransformation = shadingSurfaceGroup.siteTransformation(); |
| 2235 | |||
| 2236 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 1 time.
|
2 | for (const model::ShadingSurface& shadingSurface : shadingSurfaceGroup.shadingSurfaces()) { |
| 2237 |
1/1✓ Branch 1 taken 1 time.
|
1 | translateShadingSurface(shadingSurface, shadingTransformation, result); |
| 2238 | 1 | } | |
| 2239 | 1 | } | |
| 2240 | |||
| 2241 | // translate surfaces | ||
| 2242 |
1/1✓ Branch 1 taken 4 times.
|
4 | std::vector<model::Surface> surfaces = space.surfaces(); |
| 2243 |
1/1✓ Branch 3 taken 4 times.
|
4 | std::sort(surfaces.begin(), surfaces.end(), WorkspaceObjectNameLess()); |
| 2244 | |||
| 2245 | 4 | unsigned numFloors = 0; | |
| 2246 | 4 | unsigned numWalls = 0; | |
| 2247 | 4 | unsigned numRoofCeilings = 0; | |
| 2248 |
2/2✓ Branch 5 taken 24 times.
✓ Branch 6 taken 4 times.
|
28 | for (const model::Surface& surface : surfaces) { |
| 2249 |
1/1✓ Branch 1 taken 24 times.
|
24 | std::string surfaceType = surface.surfaceType(); |
| 2250 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 8 times.
|
48 | if (istringEqual("Wall", surfaceType)) { |
| 2251 | 16 | ++numWalls; | |
| 2252 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 4 times.
|
16 | } else if (istringEqual("RoofCeiling", surfaceType)) { |
| 2253 | 4 | ++numRoofCeilings; | |
| 2254 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
8 | } else if (istringEqual("Floor", surfaceType)) { |
| 2255 | 4 | ++numFloors; | |
| 2256 | } | ||
| 2257 | |||
| 2258 |
1/1✓ Branch 1 taken 24 times.
|
24 | translateSurface(surface, transformation, result); |
| 2259 | 24 | } | |
| 2260 | |||
| 2261 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (numFloors < 1) { |
| 2262 | ✗ | LOG(Warn, "Space '" << name << "' has less than 1 floor surfaces.") | |
| 2263 | } | ||
| 2264 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (numWalls < 3) { |
| 2265 | ✗ | LOG(Warn, "Space '" << name << "' has less than 3 wall surfaces.") | |
| 2266 | } | ||
| 2267 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (numRoofCeilings < 1) { |
| 2268 | ✗ | LOG(Warn, "Space '" << name << "' has less than 1 roof or ceiling surfaces.") | |
| 2269 | } | ||
| 2270 | |||
| 2271 |
1/1✓ Branch 1 taken 4 times.
|
8 | return result; |
| 2272 | 4 | } | |
| 2273 | |||
| 2274 | 24 | boost::optional<pugi::xml_node> ForwardTranslator::translateSurface(const openstudio::model::Surface& surface, | |
| 2275 | const openstudio::Transformation& transformation, pugi::xml_node& root) { | ||
| 2276 |
1/1✓ Branch 1 taken 24 times.
|
24 | UnitSystem ipSys(UnitSystem::IP); |
| 2277 | |||
| 2278 | 24 | boost::optional<pugi::xml_node> result; | |
| 2279 | |||
| 2280 | // return if already translated | ||
| 2281 |
4/4✓ Branch 2 taken 24 times.
✓ Branch 5 taken 24 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 20 times.
|
24 | if (m_translatedObjects.find(surface.handle()) != m_translatedObjects.end()) { |
| 2282 | 4 | return boost::none; | |
| 2283 | } | ||
| 2284 | |||
| 2285 |
1/1✓ Branch 1 taken 20 times.
|
20 | std::string surfaceType = surface.surfaceType(); |
| 2286 |
1/1✓ Branch 1 taken 20 times.
|
20 | std::string outsideBoundaryCondition = surface.outsideBoundaryCondition(); |
| 2287 |
4/4✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 8 times.
|
40 | if (istringEqual("Wall", surfaceType)) { |
| 2288 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 4 times.
|
24 | if (istringEqual("Outdoors", outsideBoundaryCondition)) { |
| 2289 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | result = root.append_child("ExtWall"); |
| 2290 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | } else if (surface.isGroundSurface()) { |
| 2291 | ✗ | result = root.append_child("UndgrWall"); | |
| 2292 |
8/26✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4 times.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 4 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
|
12 | } else if (istringEqual("Surface", outsideBoundaryCondition) || istringEqual("Adiabatic", outsideBoundaryCondition)) { |
| 2293 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | result = root.append_child("IntWall"); |
| 2294 | } | ||
| 2295 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 4 times.
|
16 | } else if (istringEqual("RoofCeiling", surfaceType)) { |
| 2296 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
8 | if (istringEqual("Outdoors", outsideBoundaryCondition)) { |
| 2297 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | result = root.append_child("Roof"); |
| 2298 | ✗ | } else if (surface.isGroundSurface()) { | |
| 2299 | // DLM: what to do here? | ||
| 2300 | ✗ | } else if (istringEqual("Surface", outsideBoundaryCondition) || istringEqual("Adiabatic", outsideBoundaryCondition)) { | |
| 2301 | // DLM: we are not translating interior ceiling surfaces, the paired interior floor will be written instead | ||
| 2302 | //result = root.append_child("Ceiling"); | ||
| 2303 | ✗ | return boost::none; | |
| 2304 | } | ||
| 2305 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
8 | } else if (istringEqual("Floor", surfaceType)) { |
| 2306 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
4 | if (surface.isGroundSurface()) { |
| 2307 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | result = root.append_child("UndgrFlr"); |
| 2308 | ✗ | } else if (istringEqual("Surface", outsideBoundaryCondition) || istringEqual("Adiabatic", outsideBoundaryCondition)) { | |
| 2309 | ✗ | result = root.append_child("IntFlr"); | |
| 2310 | ✗ | } else if (istringEqual("Outdoors", outsideBoundaryCondition)) { | |
| 2311 | ✗ | result = root.append_child("ExtFlr"); | |
| 2312 | } | ||
| 2313 | } | ||
| 2314 | |||
| 2315 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
|
20 | if (!result) { |
| 2316 | ✗ | LOG(Error, "Cannot map surface '" << surface.name().get() << "' to a known surfaceType"); | |
| 2317 | ✗ | return boost::none; | |
| 2318 | } | ||
| 2319 | |||
| 2320 |
3/3✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
|
20 | m_translatedObjects[surface.handle()] = *result; |
| 2321 | |||
| 2322 | // name | ||
| 2323 |
3/3✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
|
20 | std::string name = surface.name().get(); |
| 2324 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
|
20 | pugi::xml_node nameElement = result->append_child("Name"); |
| 2325 |
4/4✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 8 taken 20 times.
✓ Branch 11 taken 20 times.
|
20 | nameElement.text() = escapeName(name).c_str(); |
| 2326 | |||
| 2327 | // SDD: | ||
| 2328 | // Status - required (ExtFlr, ExtWall, IntWall, Roof, UndgrFlr, UndgrWall), need to add | ||
| 2329 | // ConsAssmRef - optional (Ceiling, ExtFlr, ExtWall, IntFlr, IntWall, Roof, UndgrFlr, UndgrWall), done | ||
| 2330 | // AdjacentSpcRef - optional (Ceiling, IntFlr, IntWall), done | ||
| 2331 | // Area - simplified geometry only (Ceiling, ExtFlr, ExtWall, IntFlr, IntWall, Roof, UndgrFlr, UndgrWall), ignore | ||
| 2332 | // Hgt - optional (UndgrWall), done, requires unique CFactor construction per surface | ||
| 2333 | // PerimExposed - optional (UndgrFlr), done requires unique FFactor construction per surface | ||
| 2334 | // DisplayPerim - optional (ExtWall), need to add? | ||
| 2335 | // Az - simplified geometry only (ExtWall, Roof), ignore | ||
| 2336 | // Tilt - simplified geometry only (Roof), ignore | ||
| 2337 | // ExtSolAbs - required (Ceiling, ExtFlr, ExtWall, IntWall), ignore, do at construction level | ||
| 2338 | // ExtThrmlAbs - required (Ceiling, ExtFlr, ExtWall, IntWall), ignore, do at construction level | ||
| 2339 | // ExtVisAbs - required (Ceiling, ExtFlr, ExtWall, IntWall), ignore, do at construction level | ||
| 2340 | // IntSolAbs - optional (Ceiling, ExtFlr, ExtWall, IntFlr, IntWall, Roof, UndgrFlr, UndgrWall), ignore, do at construction level | ||
| 2341 | // IntThrmlAbs - optional (Ceiling, ExtFlr, ExtWall, IntFlr, IntWall, Roof, UndgrFlr, UndgrWall), ignore, do at construction level | ||
| 2342 | // IntVisAbs - optional (Ceiling, ExtFlr, ExtWall, IntFlr, IntWall, Roof, UndgrFlr, UndgrWall), ignore, do at construction level | ||
| 2343 | // FieldAppliedCoating - optional (Roof), ignore, do at construction level | ||
| 2344 | // CRRCInitialRefl - optional (Roof), ignore, do at construction level | ||
| 2345 | // CRRCAgedRefl - optional (Roof), ignore, do at construction level | ||
| 2346 | // CRRCInitialEmittance - optional (Roof)), ignore, do at construction level | ||
| 2347 | // CRRCAgedEmittance - optional (Roof), ignore, do at construction level | ||
| 2348 | // CRRCInitialSRI - optional (Roof), ignore, do at construction level | ||
| 2349 | // CRRCAgedSRI - optional (Roof), ignore, do at construction level | ||
| 2350 | // CRRCProdID - optional (Roof), ignore, do at construction level | ||
| 2351 | |||
| 2352 | // adjacent surface | ||
| 2353 |
1/1✓ Branch 1 taken 20 times.
|
20 | boost::optional<model::Surface> adjacentSurface = surface.adjacentSurface(); |
| 2354 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
|
20 | if (adjacentSurface) { |
| 2355 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | boost::optional<model::Space> adjacentSpace = adjacentSurface->space(); |
| 2356 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (adjacentSpace) { |
| 2357 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | std::string adjacentSpaceName = adjacentSpace->name().get(); |
| 2358 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | pugi::xml_node adjacentSpaceElement = result->append_child("AdjacentSpcRef"); |
| 2359 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
|
4 | adjacentSpaceElement.text() = escapeName(adjacentSpaceName).c_str(); |
| 2360 | |||
| 2361 | // count adjacent surface as translated | ||
| 2362 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | m_translatedObjects[adjacentSurface->handle()] = *result; |
| 2363 | 4 | } | |
| 2364 | 4 | } | |
| 2365 | |||
| 2366 | // construction reference | ||
| 2367 |
1/1✓ Branch 1 taken 20 times.
|
20 | boost::optional<model::ConstructionBase> construction = surface.construction(); |
| 2368 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if (construction) { |
| 2369 | |||
| 2370 |
4/4✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
✓ Branch 10 taken 20 times.
|
20 | std::string constructionName = construction->name().get(); |
| 2371 | |||
| 2372 | // check that construction has been translated | ||
| 2373 |
5/5✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
✓ Branch 8 taken 20 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 4 times.
|
20 | if (m_translatedObjects.find(construction->handle()) != m_translatedObjects.end()) { |
| 2374 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | pugi::xml_node constructionReferenceElement = result->append_child("ConsAssmRef"); |
| 2375 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 11 taken 16 times.
|
16 | constructionReferenceElement.text() = escapeName(constructionName).c_str(); |
| 2376 | } else { | ||
| 2377 | //Do not want this logged, http://code.google.com/p/cbecc/issues/detail?id=695 | ||
| 2378 | //LOG(Error, "Surface '" << name << "' uses construction '" << constructionName << "' which has not been translated"); | ||
| 2379 | } | ||
| 2380 | 20 | } | |
| 2381 | |||
| 2382 | // if underground floor try to write out perimeter exposed | ||
| 2383 |
10/17✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 16 times.
✓ Branch 9 taken 4 times.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 20 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 20 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 4 times.
✓ Branch 19 taken 16 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
60 | if (istringEqual("Floor", surfaceType) && surface.isGroundSurface()) { |
| 2384 | // DLM: for now we will get the exposed perimeter from the FFactor construction | ||
| 2385 | // this assumes one construction per surface, I don't really like this, maybe we can do better later | ||
| 2386 |
6/12✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
12 | if (construction && construction->optionalCast<model::FFactorGroundFloorConstruction>()) { |
| 2387 | ✗ | auto fFactorConstruction = construction->cast<model::FFactorGroundFloorConstruction>(); | |
| 2388 | // check assumption of one surface per FFactor construction | ||
| 2389 | ✗ | if (fFactorConstruction.getModelObjectSources<model::Surface>().size() == 1) { | |
| 2390 | ✗ | double perimeterExposedSI = fFactorConstruction.perimeterExposed(); | |
| 2391 | ✗ | double perimeterExposedIP = meterToFoot * perimeterExposedSI; | |
| 2392 | ✗ | pugi::xml_node perimExposedElement = result->append_child("PerimExposed"); | |
| 2393 | ✗ | perimExposedElement.text() = openstudio::string_conversions::number(perimeterExposedIP).c_str(); | |
| 2394 | } else { | ||
| 2395 | //Do not want this logged, http://code.google.com/p/cbecc/issues/detail?id=695 | ||
| 2396 | //LOG(Error, "Cannot compute exposed perimeter for surface '" << name << "'."); | ||
| 2397 | } | ||
| 2398 | ✗ | } else { | |
| 2399 | //Do not want this logged, http://code.google.com/p/cbecc/issues/detail?id=695 | ||
| 2400 | //LOG(Error, "Cannot compute exposed perimeter for surface '" << name << "'."); | ||
| 2401 | } | ||
| 2402 | } | ||
| 2403 | |||
| 2404 | // if underground wall try to write out height | ||
| 2405 |
9/17✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 8 times.
✓ Branch 9 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✓ Branch 13 taken 20 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 20 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 20 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
|
60 | if (istringEqual("Wall", surfaceType) && surface.isGroundSurface()) { |
| 2406 | // DLM: for now we will get the height from the CFactor construction | ||
| 2407 | // this assumes one construction per surface, I don't really like this, maybe we can do better later | ||
| 2408 | ✗ | if (construction && construction->optionalCast<model::CFactorUndergroundWallConstruction>()) { | |
| 2409 | ✗ | auto cFactorConstruction = construction->cast<model::CFactorUndergroundWallConstruction>(); | |
| 2410 | // check assumption of one surface per CFactor construction | ||
| 2411 | ✗ | if (cFactorConstruction.getModelObjectSources<model::Surface>().size() == 1) { | |
| 2412 | ✗ | double heightSI = cFactorConstruction.height(); | |
| 2413 | ✗ | double heightIP = meterToFoot * heightSI; | |
| 2414 | ✗ | pugi::xml_node heightElement = result->append_child("Hgt"); | |
| 2415 | ✗ | heightElement.text() = openstudio::string_conversions::number(heightIP).c_str(); | |
| 2416 | } else { | ||
| 2417 | //Do not want this logged, http://code.google.com/p/cbecc/issues/detail?id=695 | ||
| 2418 | //LOG(Error, "Cannot compute height for surface '" << name << "'."); | ||
| 2419 | } | ||
| 2420 | ✗ | } else { | |
| 2421 | //Do not want this logged, http://code.google.com/p/cbecc/issues/detail?id=695 | ||
| 2422 | //LOG(Error, "Cannot compute height for surface '" << name << "'."); | ||
| 2423 | } | ||
| 2424 | } | ||
| 2425 | |||
| 2426 | // check area | ||
| 2427 |
1/1✓ Branch 1 taken 20 times.
|
20 | double grossArea = surface.grossArea(); |
| 2428 |
3/3✓ Branch 1 taken 20 times.
✓ Branch 5 taken 20 times.
✓ Branch 8 taken 20 times.
|
20 | Quantity grossAreaSI(grossArea, SIUnit(SIExpnt(0, 2, 0))); |
| 2429 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
|
20 | OptionalQuantity grossAreaIP = QuantityConverter::instance().convert(grossAreaSI, ipSys); |
| 2430 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 4 not taken.
|
20 | OS_ASSERT(grossAreaIP); |
| 2431 |
6/8✓ Branch 1 taken 20 times.
✓ Branch 5 taken 20 times.
✓ Branch 8 taken 20 times.
✓ Branch 11 taken 20 times.
✓ Branch 14 taken 20 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 20 times.
✗ Branch 19 not taken.
|
20 | OS_ASSERT(grossAreaIP->units() == IPUnit(IPExpnt(0, 2, 0))); |
| 2432 | |||
| 2433 | // log warning if area is 0 | ||
| 2434 |
3/4✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
|
20 | if (grossAreaIP->value() < std::numeric_limits<double>::epsilon()) { |
| 2435 | ✗ | LOG(Warn, "Surface '" << name << "' has zero area.") | |
| 2436 | } | ||
| 2437 | |||
| 2438 | // translate vertices | ||
| 2439 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
|
20 | Point3dVector vertices = transformation * surface.vertices(); |
| 2440 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
|
20 | pugi::xml_node polyLoopElement = result->append_child("PolyLp"); |
| 2441 |
2/2✓ Branch 4 taken 80 times.
✓ Branch 5 taken 20 times.
|
100 | for (const Point3d& vertex : vertices) { |
| 2442 |
1/1✓ Branch 1 taken 80 times.
|
80 | pugi::xml_node cartesianPointElement = polyLoopElement.append_child("CartesianPt"); |
| 2443 | |||
| 2444 | /* DLM: these conversions were taking about 75% of the time to convert a large model | ||
| 2445 | |||
| 2446 | Quantity xSI(vertex.x(), SIUnit(SIExpnt(0,1,0))); | ||
| 2447 | Quantity ySI(vertex.y(), SIUnit(SIExpnt(0,1,0))); | ||
| 2448 | Quantity zSI(vertex.z(), SIUnit(SIExpnt(0,1,0))); | ||
| 2449 | |||
| 2450 | OptionalQuantity xIP = QuantityConverter::instance().convert(xSI, ipSys); | ||
| 2451 | OS_ASSERT(xIP); | ||
| 2452 | OS_ASSERT(xIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2453 | |||
| 2454 | OptionalQuantity yIP = QuantityConverter::instance().convert(ySI, ipSys); | ||
| 2455 | OS_ASSERT(yIP); | ||
| 2456 | OS_ASSERT(yIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2457 | |||
| 2458 | OptionalQuantity zIP = QuantityConverter::instance().convert(zSI, ipSys); | ||
| 2459 | OS_ASSERT(zIP); | ||
| 2460 | OS_ASSERT(zIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2461 | |||
| 2462 | pugi::xml_node coordinateXElement = cartesianPointElement.append_child("Coord"); | ||
| 2463 | coordinateXElement.text() = openstudio::string_conversions::number(xIP->value()).c_str(); | ||
| 2464 | |||
| 2465 | pugi::xml_node coordinateYElement = cartesianPointElement.append_child("Coord"); | ||
| 2466 | coordinateYElement.text() = openstudio::string_conversions::number(yIP->value()).c_str(); | ||
| 2467 | |||
| 2468 | pugi::xml_node coordinateZElement = cartesianPointElement.append_child("Coord"); | ||
| 2469 | coordinateZElement.text() = openstudio::string_conversions::number(zIP->value()).c_str(); | ||
| 2470 | |||
| 2471 | */ | ||
| 2472 | |||
| 2473 |
1/1✓ Branch 1 taken 80 times.
|
80 | pugi::xml_node coordinateXElement = cartesianPointElement.append_child("Coord"); |
| 2474 |
4/4✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 8 taken 80 times.
✓ Branch 11 taken 80 times.
|
80 | coordinateXElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.x()).c_str(); |
| 2475 | |||
| 2476 |
1/1✓ Branch 1 taken 80 times.
|
80 | pugi::xml_node coordinateYElement = cartesianPointElement.append_child("Coord"); |
| 2477 |
4/4✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 8 taken 80 times.
✓ Branch 11 taken 80 times.
|
80 | coordinateYElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.y()).c_str(); |
| 2478 | |||
| 2479 |
1/1✓ Branch 1 taken 80 times.
|
80 | pugi::xml_node coordinateZElement = cartesianPointElement.append_child("Coord"); |
| 2480 |
4/4✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 8 taken 80 times.
✓ Branch 11 taken 80 times.
|
80 | coordinateZElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.z()).c_str(); |
| 2481 | } | ||
| 2482 | |||
| 2483 | // translate sub surfaces | ||
| 2484 |
1/1✓ Branch 1 taken 20 times.
|
20 | std::vector<model::SubSurface> subSurfaces = surface.subSurfaces(); |
| 2485 |
1/1✓ Branch 3 taken 20 times.
|
20 | std::sort(subSurfaces.begin(), subSurfaces.end(), WorkspaceObjectNameLess()); |
| 2486 | |||
| 2487 |
2/2✓ Branch 4 taken 2 times.
✓ Branch 5 taken 20 times.
|
22 | for (const model::SubSurface& subSurface : subSurfaces) { |
| 2488 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateSubSurface(subSurface, transformation, *result); |
| 2489 | } | ||
| 2490 | |||
| 2491 | 20 | return result; | |
| 2492 | 24 | } | |
| 2493 | |||
| 2494 | 2 | boost::optional<pugi::xml_node> ForwardTranslator::translateSubSurface(const openstudio::model::SubSurface& subSurface, | |
| 2495 | const openstudio::Transformation& transformation, pugi::xml_node& root) { | ||
| 2496 |
1/1✓ Branch 1 taken 2 times.
|
2 | UnitSystem ipSys(UnitSystem::IP); |
| 2497 | |||
| 2498 | 2 | boost::optional<pugi::xml_node> result; | |
| 2499 | |||
| 2500 | // return if already translated | ||
| 2501 |
3/4✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
|
2 | if (m_translatedObjects.find(subSurface.handle()) != m_translatedObjects.end()) { |
| 2502 | ✗ | return boost::none; | |
| 2503 | } | ||
| 2504 | |||
| 2505 |
1/1✓ Branch 1 taken 2 times.
|
2 | std::string subSurfaceType = subSurface.subSurfaceType(); |
| 2506 | 2 | std::string consRefElementName; | |
| 2507 |
22/38✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 14 taken 1 time.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 time.
✓ Branch 24 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 27 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 29 taken 1 time.
✓ Branch 30 taken 1 time.
✓ Branch 32 taken 1 time.
✓ Branch 33 taken 1 time.
✓ Branch 34 taken 2 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 2 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 1 time.
✓ Branch 40 taken 1 time.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
|
10 | if (istringEqual("FixedWindow", subSurfaceType) || istringEqual("OperableWindow", subSurfaceType) || istringEqual("GlassDoor", subSurfaceType)) { |
| 2508 |
1/1✓ Branch 1 taken 1 time.
|
1 | consRefElementName = "FenConsRef"; |
| 2509 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | result = root.append_child("Win"); |
| 2510 |
8/26✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 time.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 time.
✓ Branch 21 taken 1 time.
✗ Branch 22 not taken.
✓ Branch 24 taken 1 time.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 time.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
|
3 | } else if (istringEqual("Door", subSurfaceType) || istringEqual("OverheadDoor", subSurfaceType)) { |
| 2511 |
1/1✓ Branch 1 taken 1 time.
|
1 | consRefElementName = "DrConsRef"; |
| 2512 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | result = root.append_child("Dr"); |
| 2513 | ✗ | } else if (istringEqual("Skylight", subSurfaceType)) { | |
| 2514 | ✗ | consRefElementName = "FenConsRef"; | |
| 2515 | ✗ | result = root.append_child("Skylt"); | |
| 2516 | } | ||
| 2517 | |||
| 2518 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!result) { |
| 2519 | ✗ | LOG(Error, "Cannot map subsurface '" << subSurface.name().get() << "' to a known subsurfaceType"); | |
| 2520 | ✗ | return boost::none; | |
| 2521 | } | ||
| 2522 | |||
| 2523 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | m_translatedObjects[subSurface.handle()] = *result; |
| 2524 | |||
| 2525 | // name | ||
| 2526 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | std::string name = subSurface.name().get(); |
| 2527 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | pugi::xml_node nameElement = result->append_child("Name"); |
| 2528 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
|
2 | nameElement.text() = escapeName(name).c_str(); |
| 2529 | |||
| 2530 | // SDD: | ||
| 2531 | // Status - required (Win, Skylt, Dr), need to add | ||
| 2532 | // FenConsRef - optional (Win, Skylt), done | ||
| 2533 | // DrConsRef - optional (Dr), done | ||
| 2534 | // Oper - optional (Dr), in progress | ||
| 2535 | // Area - simple geometry only (Win, Skylt, Dr), ignore | ||
| 2536 | |||
| 2537 | // construction | ||
| 2538 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<model::ConstructionBase> construction = subSurface.construction(); |
| 2539 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (construction) { |
| 2540 | |||
| 2541 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | std::string constructionName = construction->name().get(); |
| 2542 | |||
| 2543 | // check that construction has been translated | ||
| 2544 |
4/5✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
|
2 | if (m_translatedObjects.find(construction->handle()) != m_translatedObjects.end()) { |
| 2545 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
|
2 | pugi::xml_node constructionReferenceElement = result->append_child(consRefElementName.c_str()); |
| 2546 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
|
2 | constructionReferenceElement.text() = escapeName(constructionName).c_str(); |
| 2547 | } else { | ||
| 2548 | //Do not want this logged, http://code.google.com/p/cbecc/issues/detail?id=695 | ||
| 2549 | //LOG(Error, "SubSurface '" << name << "' uses construction '" << constructionName << "' which has not been translated"); | ||
| 2550 | } | ||
| 2551 | 2 | } | |
| 2552 | |||
| 2553 | // check area | ||
| 2554 |
1/1✓ Branch 1 taken 2 times.
|
2 | double grossArea = subSurface.grossArea(); |
| 2555 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
|
2 | Quantity grossAreaSI(grossArea, SIUnit(SIExpnt(0, 2, 0))); |
| 2556 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | OptionalQuantity grossAreaIP = QuantityConverter::instance().convert(grossAreaSI, ipSys); |
| 2557 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(grossAreaIP); |
| 2558 |
6/8✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
✓ Branch 14 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 19 not taken.
|
2 | OS_ASSERT(grossAreaIP->units() == IPUnit(IPExpnt(0, 2, 0))); |
| 2559 | |||
| 2560 | // log warning if area is 0 | ||
| 2561 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
|
2 | if (grossAreaIP->value() < std::numeric_limits<double>::epsilon()) { |
| 2562 | ✗ | LOG(Warn, "Sub Surface '" << name << "' has zero area.") | |
| 2563 | } | ||
| 2564 | |||
| 2565 | // translate vertices | ||
| 2566 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Point3dVector vertices = transformation * subSurface.vertices(); |
| 2567 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | pugi::xml_node polyLoopElement = result->append_child("PolyLp"); |
| 2568 |
2/2✓ Branch 4 taken 8 times.
✓ Branch 5 taken 2 times.
|
10 | for (const Point3d& vertex : vertices) { |
| 2569 |
1/1✓ Branch 1 taken 8 times.
|
8 | pugi::xml_node cartesianPointElement = polyLoopElement.append_child("CartesianPt"); |
| 2570 | |||
| 2571 | /* DLM: these conversions were taking about 75% of the time it takes to convert a large model | ||
| 2572 | |||
| 2573 | Quantity xSI(vertex.x(), SIUnit(SIExpnt(0,1,0))); | ||
| 2574 | Quantity ySI(vertex.y(), SIUnit(SIExpnt(0,1,0))); | ||
| 2575 | Quantity zSI(vertex.z(), SIUnit(SIExpnt(0,1,0))); | ||
| 2576 | |||
| 2577 | OptionalQuantity xIP = QuantityConverter::instance().convert(xSI, ipSys); | ||
| 2578 | OS_ASSERT(xIP); | ||
| 2579 | OS_ASSERT(xIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2580 | |||
| 2581 | OptionalQuantity yIP = QuantityConverter::instance().convert(ySI, ipSys); | ||
| 2582 | OS_ASSERT(yIP); | ||
| 2583 | OS_ASSERT(yIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2584 | |||
| 2585 | OptionalQuantity zIP = QuantityConverter::instance().convert(zSI, ipSys); | ||
| 2586 | OS_ASSERT(zIP); | ||
| 2587 | OS_ASSERT(zIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2588 | |||
| 2589 | pugi::xml_node coordinateXElement = cartesianPointElement.append_child("Coord"); | ||
| 2590 | coordinateXElement.text() = openstudio::string_conversions::number(xIP->value()).c_str(); | ||
| 2591 | |||
| 2592 | pugi::xml_node coordinateYElement = cartesianPointElement.append_child("Coord"); | ||
| 2593 | coordinateYElement.text() = openstudio::string_conversions::number(yIP->value()).c_str(); | ||
| 2594 | |||
| 2595 | pugi::xml_node coordinateZElement = cartesianPointElement.append_child("Coord"); | ||
| 2596 | coordinateZElement.text() = openstudio::string_conversions::number(zIP->value()).c_str(); | ||
| 2597 | |||
| 2598 | */ | ||
| 2599 | |||
| 2600 |
1/1✓ Branch 1 taken 8 times.
|
8 | pugi::xml_node coordinateXElement = cartesianPointElement.append_child("Coord"); |
| 2601 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 8 taken 8 times.
✓ Branch 11 taken 8 times.
|
8 | coordinateXElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.x()).c_str(); |
| 2602 | |||
| 2603 |
1/1✓ Branch 1 taken 8 times.
|
8 | pugi::xml_node coordinateYElement = cartesianPointElement.append_child("Coord"); |
| 2604 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 8 taken 8 times.
✓ Branch 11 taken 8 times.
|
8 | coordinateYElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.y()).c_str(); |
| 2605 | |||
| 2606 |
1/1✓ Branch 1 taken 8 times.
|
8 | pugi::xml_node coordinateZElement = cartesianPointElement.append_child("Coord"); |
| 2607 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 8 taken 8 times.
✓ Branch 11 taken 8 times.
|
8 | coordinateZElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.z()).c_str(); |
| 2608 | } | ||
| 2609 | |||
| 2610 | 2 | return result; | |
| 2611 | 2 | } | |
| 2612 | |||
| 2613 | 3 | boost::optional<pugi::xml_node> ForwardTranslator::translateShadingSurface(const openstudio::model::ShadingSurface& shadingSurface, | |
| 2614 | const openstudio::Transformation& transformation, pugi::xml_node& root) { | ||
| 2615 |
1/1✓ Branch 1 taken 3 times.
|
3 | UnitSystem ipSys(UnitSystem::IP); |
| 2616 | |||
| 2617 | 3 | boost::optional<pugi::xml_node> result; | |
| 2618 | |||
| 2619 | // return if already translated | ||
| 2620 |
3/4✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
|
3 | if (m_translatedObjects.find(shadingSurface.handle()) != m_translatedObjects.end()) { |
| 2621 | ✗ | return boost::none; | |
| 2622 | } | ||
| 2623 | |||
| 2624 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | result = root.append_child("ExtShdgObj"); |
| 2625 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | m_translatedObjects[shadingSurface.handle()] = *result; |
| 2626 | |||
| 2627 | // name | ||
| 2628 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | std::string name = shadingSurface.name().get(); |
| 2629 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | pugi::xml_node nameElement = result->append_child("Name"); |
| 2630 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
|
3 | nameElement.text() = escapeName(name).c_str(); |
| 2631 | |||
| 2632 | // SDD: | ||
| 2633 | // Status - required, need to add | ||
| 2634 | // TransSchRef - optional, in progress | ||
| 2635 | // SolRefl - optional, done | ||
| 2636 | // VisRefl - optional, done | ||
| 2637 | |||
| 2638 | // schedule | ||
| 2639 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<model::Schedule> transmittanceSchedule = shadingSurface.transmittanceSchedule(); |
| 2640 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (transmittanceSchedule) { |
| 2641 | |||
| 2642 | ✗ | std::string transmittanceScheduleName = transmittanceSchedule->name().get(); | |
| 2643 | |||
| 2644 | // check that construction has been translated | ||
| 2645 | ✗ | if (m_translatedObjects.find(transmittanceSchedule->handle()) != m_translatedObjects.end()) { | |
| 2646 | ✗ | pugi::xml_node transmittanceScheduleReferenceElement = result->append_child("TransSchRef"); | |
| 2647 | ✗ | transmittanceScheduleReferenceElement.text() = escapeName(transmittanceScheduleName).c_str(); | |
| 2648 | } else { | ||
| 2649 | ✗ | LOG(Error, "ShadingSurface '" << name << "' uses transmittance schedule '" << transmittanceScheduleName << "' which has not been translated"); | |
| 2650 | } | ||
| 2651 | ✗ | } | |
| 2652 | |||
| 2653 | // default to 0 reflectance | ||
| 2654 | // http://code.google.com/p/cbecc/issues/detail?id=344#c16 | ||
| 2655 | 3 | double solRefl = 0.0; | |
| 2656 | 3 | double visRefl = 0.0; | |
| 2657 | |||
| 2658 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<model::ConstructionBase> constructionBase = shadingSurface.construction(); |
| 2659 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (constructionBase) { |
| 2660 | ✗ | boost::optional<model::Construction> construction = constructionBase->optionalCast<model::Construction>(); | |
| 2661 | ✗ | if (construction) { | |
| 2662 | |||
| 2663 | ✗ | std::vector<model::Material> layers = construction->layers(); | |
| 2664 | ✗ | if (!layers.empty()) { | |
| 2665 | |||
| 2666 | ✗ | if (layers[0].optionalCast<model::StandardOpaqueMaterial>()) { | |
| 2667 | ✗ | auto outerMaterial = layers[0].cast<model::StandardOpaqueMaterial>(); | |
| 2668 | ✗ | if (!outerMaterial.isSolarAbsorptanceDefaulted()) { | |
| 2669 | ✗ | boost::optional<double> test = outerMaterial.solarReflectance(); | |
| 2670 | ✗ | if (test) { | |
| 2671 | ✗ | solRefl = *test; | |
| 2672 | } | ||
| 2673 | } | ||
| 2674 | ✗ | if (!outerMaterial.isVisibleAbsorptanceDefaulted()) { | |
| 2675 | ✗ | boost::optional<double> test = outerMaterial.visibleReflectance(); | |
| 2676 | ✗ | if (test) { | |
| 2677 | ✗ | visRefl = *test; | |
| 2678 | } | ||
| 2679 | } | ||
| 2680 | ✗ | } | |
| 2681 | |||
| 2682 | ✗ | if (layers[0].optionalCast<model::MasslessOpaqueMaterial>()) { | |
| 2683 | ✗ | auto outerMaterial = layers[0].cast<model::MasslessOpaqueMaterial>(); | |
| 2684 | ✗ | if (!outerMaterial.isSolarAbsorptanceDefaulted()) { | |
| 2685 | ✗ | boost::optional<double> test = outerMaterial.solarReflectance(); | |
| 2686 | ✗ | if (test) { | |
| 2687 | ✗ | solRefl = *test; | |
| 2688 | } | ||
| 2689 | } | ||
| 2690 | ✗ | if (!outerMaterial.isVisibleAbsorptanceDefaulted()) { | |
| 2691 | ✗ | boost::optional<double> test = outerMaterial.visibleReflectance(); | |
| 2692 | ✗ | if (test) { | |
| 2693 | ✗ | visRefl = *test; | |
| 2694 | } | ||
| 2695 | } | ||
| 2696 | ✗ | } | |
| 2697 | } | ||
| 2698 | ✗ | } | |
| 2699 | ✗ | } | |
| 2700 | |||
| 2701 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | pugi::xml_node solReflElement = result->append_child("SolRefl"); |
| 2702 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
|
3 | solReflElement.text() = openstudio::string_conversions::number(solRefl).c_str(); |
| 2703 | |||
| 2704 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | pugi::xml_node visReflElement = result->append_child("VisRefl"); |
| 2705 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
|
3 | visReflElement.text() = openstudio::string_conversions::number(visRefl).c_str(); |
| 2706 | |||
| 2707 | // translate vertices | ||
| 2708 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | Point3dVector vertices = transformation * shadingSurface.vertices(); |
| 2709 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | pugi::xml_node polyLoopElement = result->append_child("PolyLp"); |
| 2710 |
2/2✓ Branch 4 taken 12 times.
✓ Branch 5 taken 3 times.
|
15 | for (const Point3d& vertex : vertices) { |
| 2711 |
1/1✓ Branch 1 taken 12 times.
|
12 | pugi::xml_node cartesianPointElement = polyLoopElement.append_child("CartesianPt"); |
| 2712 | |||
| 2713 | /* DLM: these conversions were taking about 75% of the time it takes to convert a large model | ||
| 2714 | |||
| 2715 | Quantity xSI(vertex.x(), SIUnit(SIExpnt(0,1,0))); | ||
| 2716 | Quantity ySI(vertex.y(), SIUnit(SIExpnt(0,1,0))); | ||
| 2717 | Quantity zSI(vertex.z(), SIUnit(SIExpnt(0,1,0))); | ||
| 2718 | |||
| 2719 | OptionalQuantity xIP = QuantityConverter::instance().convert(xSI, ipSys); | ||
| 2720 | OS_ASSERT(xIP); | ||
| 2721 | OS_ASSERT(xIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2722 | |||
| 2723 | OptionalQuantity yIP = QuantityConverter::instance().convert(ySI, ipSys); | ||
| 2724 | OS_ASSERT(yIP); | ||
| 2725 | OS_ASSERT(yIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2726 | |||
| 2727 | OptionalQuantity zIP = QuantityConverter::instance().convert(zSI, ipSys); | ||
| 2728 | OS_ASSERT(zIP); | ||
| 2729 | OS_ASSERT(zIP->units() == IPUnit(IPExpnt(0,1,0))); | ||
| 2730 | |||
| 2731 | pugi::xml_node coordinateXElement = cartesianPointElement.append_child("Coord"); | ||
| 2732 | coordinateXElement.text() = openstudio::string_conversions::number(xIP->value()).c_str(); | ||
| 2733 | |||
| 2734 | pugi::xml_node coordinateYElement = cartesianPointElement.append_child("Coord"); | ||
| 2735 | coordinateYElement.text() = openstudio::string_conversions::number(yIP->value()).c_str(); | ||
| 2736 | |||
| 2737 | pugi::xml_node coordinateZElement = cartesianPointElement.append_child("Coord"); | ||
| 2738 | coordinateZElement.text() = openstudio::string_conversions::number(zIP->value()).c_str(); | ||
| 2739 | |||
| 2740 | */ | ||
| 2741 | |||
| 2742 |
1/1✓ Branch 1 taken 12 times.
|
12 | pugi::xml_node coordinateXElement = cartesianPointElement.append_child("Coord"); |
| 2743 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 8 taken 12 times.
✓ Branch 11 taken 12 times.
|
12 | coordinateXElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.x()).c_str(); |
| 2744 | |||
| 2745 |
1/1✓ Branch 1 taken 12 times.
|
12 | pugi::xml_node coordinateYElement = cartesianPointElement.append_child("Coord"); |
| 2746 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 8 taken 12 times.
✓ Branch 11 taken 12 times.
|
12 | coordinateYElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.y()).c_str(); |
| 2747 | |||
| 2748 |
1/1✓ Branch 1 taken 12 times.
|
12 | pugi::xml_node coordinateZElement = cartesianPointElement.append_child("Coord"); |
| 2749 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 8 taken 12 times.
✓ Branch 11 taken 12 times.
|
12 | coordinateZElement.text() = openstudio::string_conversions::number(meterToFoot * vertex.z()).c_str(); |
| 2750 | } | ||
| 2751 | |||
| 2752 | 3 | return result; | |
| 2753 | 3 | } | |
| 2754 | |||
| 2755 | 1 | boost::optional<pugi::xml_node> ForwardTranslator::translateThermalZone(const openstudio::model::ThermalZone& thermalZone, pugi::xml_node& root) { | |
| 2756 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node result = root.append_child("ThrmlZn"); |
| 2757 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | m_translatedObjects[thermalZone.handle()] = result; |
| 2758 | |||
| 2759 | // Name | ||
| 2760 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | std::string name = thermalZone.name().get(); |
| 2761 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node nameElement = result.append_child("Name"); |
| 2762 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
|
1 | nameElement.text() = escapeName(name).c_str(); |
| 2763 | |||
| 2764 | // Type | ||
| 2765 | 1 | std::string type; // Conditioned, Unconditioned, Plenum | |
| 2766 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
|
2 | if (thermalZone.thermostatSetpointDualSetpoint()) { |
| 2767 |
1/1✓ Branch 1 taken 1 time.
|
1 | type = "Conditioned"; |
| 2768 | } else { | ||
| 2769 | ✗ | type = "Unconditioned"; | |
| 2770 | } | ||
| 2771 |
1/1✓ Branch 1 taken 1 time.
|
1 | pugi::xml_node typeElement = result.append_child("Type"); |
| 2772 |
2/2✓ Branch 2 taken 1 time.
✓ Branch 5 taken 1 time.
|
1 | typeElement.text() = type.c_str(); |
| 2773 | |||
| 2774 | // DLM: Not input | ||
| 2775 | // Mult | ||
| 2776 | //pugi::xml_node multElement = result.append_child("Mult"); | ||
| 2777 | //multElement.text() = thermalZone.multiplier(); | ||
| 2778 | |||
| 2779 |
1/1✓ Branch 1 taken 1 time.
|
2 | return result; |
| 2780 | 1 | } | |
| 2781 | |||
| 2782 | } // namespace sdd | ||
| 2783 | } // namespace openstudio | ||
| 2784 |