src/energyplus/ForwardTranslator/ForwardTranslateSpaceType.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ForwardTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | #include "../../model/Space.hpp" | ||
| 10 | #include "../../model/SpaceType.hpp" | ||
| 11 | #include "../../model/ThermalZone.hpp" | ||
| 12 | // Loads | ||
| 13 | #include "../../model/InternalMass.hpp" | ||
| 14 | #include "../../model/People.hpp" | ||
| 15 | #include "../../model/Lights.hpp" | ||
| 16 | #include "../../model/Luminaire.hpp" | ||
| 17 | #include "../../model/ElectricEquipment.hpp" | ||
| 18 | #include "../../model/ElectricEquipmentITEAirCooled.hpp" | ||
| 19 | #include "../../model/GasEquipment.hpp" | ||
| 20 | #include "../../model/HotWaterEquipment.hpp" | ||
| 21 | #include "../../model/SteamEquipment.hpp" | ||
| 22 | #include "../../model/OtherEquipment.hpp" | ||
| 23 | #include "../../model/SpaceInfiltrationDesignFlowRate.hpp" | ||
| 24 | #include "../../model/SpaceInfiltrationEffectiveLeakageArea.hpp" | ||
| 25 | #include "../../model/SpaceInfiltrationFlowCoefficient.hpp" | ||
| 26 | |||
| 27 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 28 | #include "../../utilities/idf/Workspace.hpp" | ||
| 29 | #include "../../utilities/idf/WorkspaceObjectOrder.hpp" | ||
| 30 | #include "../../utilities/core/Logger.hpp" | ||
| 31 | #include "../../utilities/core/Assert.hpp" | ||
| 32 | |||
| 33 | #include <iterator> | ||
| 34 | #include <utilities/idd/ZoneList_FieldEnums.hxx> | ||
| 35 | #include <utilities/idd/SpaceList_FieldEnums.hxx> | ||
| 36 | |||
| 37 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 38 | #include <utilities/idd/IddEnums.hxx> | ||
| 39 | |||
| 40 | using namespace openstudio::model; | ||
| 41 | |||
| 42 | using namespace std; | ||
| 43 | |||
| 44 | namespace openstudio { | ||
| 45 | |||
| 46 | namespace energyplus { | ||
| 47 | |||
| 48 | 19 | std::string ForwardTranslator::zoneListNameForSpaceType(const SpaceType& modelObject) const { | |
| 49 |
1/2✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
|
19 | if (m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 50 | 19 | return modelObject.nameString(); | |
| 51 | } else { | ||
| 52 | ✗ | return modelObject.nameString() + " ZoneList"; | |
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | 202 | boost::optional<IdfObject> ForwardTranslator::translateSpaceType(SpaceType& modelObject) { | |
| 57 |
1/1✓ Branch 1 taken 202 times.
|
202 | std::vector<Space> spaces = modelObject.spaces(); |
| 58 | |||
| 59 | // check if this is a dummy space type meant to prevent inheriting building space type | ||
| 60 | // TODO: why is that needed in the first place? Also, children() doesn't include DesignSpecificationOutdoorAir! | ||
| 61 |
3/3✓ Branch 1 taken 202 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 155 times.
|
202 | if (m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 62 |
1/1✓ Branch 1 taken 47 times.
|
47 | std::vector<ModelObject> children = modelObject.children(); |
| 63 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 2 taken 19 times.
|
47 | if (children.empty()) { |
| 64 |
9/9✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
✓ Branch 13 taken 28 times.
✓ Branch 16 taken 28 times.
✓ Branch 20 taken 28 times.
✓ Branch 23 taken 28 times.
✓ Branch 26 taken 28 times.
|
28 | LOG(Info, "SpaceType " << modelObject.name().get() << " has no children, it will not be translated"); |
| 65 | 28 | return boost::none; | |
| 66 | } | ||
| 67 | 47 | } | |
| 68 | |||
| 69 | 174 | OptionalIdfObject idfObject; | |
| 70 | |||
| 71 | 19 | auto makeZoneList = [this, &modelObject, &spaces](bool registerIt) -> IdfObject { | |
| 72 | 19 | boost::optional<IdfObject> idfObject; | |
| 73 |
1/2✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
|
19 | if (registerIt) { |
| 74 |
3/3✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
|
19 | idfObject = createAndRegisterIdfObject(openstudio::IddObjectType::ZoneList, modelObject); |
| 75 | } else { | ||
| 76 | ✗ | idfObject = m_idfObjects.emplace_back(openstudio::IddObjectType::ZoneList); | |
| 77 | } | ||
| 78 |
3/3✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
|
19 | idfObject->setName(zoneListNameForSpaceType(modelObject)); |
| 79 | |||
| 80 | // Unique zone names | ||
| 81 | 19 | std::set<std::string> zoneNames; | |
| 82 |
2/2✓ Branch 5 taken 25 times.
✓ Branch 6 taken 19 times.
|
44 | for (const Space& space : spaces) { |
| 83 |
2/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
|
50 | if (auto thermalZone_ = space.thermalZone()) { |
| 84 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
25 | zoneNames.insert(thermalZone_->nameString()); |
| 85 | 25 | } | |
| 86 | } | ||
| 87 | |||
| 88 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | idfObject->clearExtensibleGroups(); |
| 89 |
2/2✓ Branch 4 taken 25 times.
✓ Branch 5 taken 19 times.
|
44 | for (const std::string& zoneName : zoneNames) { |
| 90 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
|
75 | idfObject->pushExtensibleGroup(std::vector<std::string>(1, zoneName)); |
| 91 | } | ||
| 92 | |||
| 93 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
38 | return idfObject.get(); |
| 94 | 19 | }; | |
| 95 | |||
| 96 |
3/3✓ Branch 1 taken 174 times.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 155 times.
|
174 | if (m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 97 | |||
| 98 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | idfObject = makeZoneList(true); |
| 99 | |||
| 100 | } else { | ||
| 101 | |||
| 102 |
3/3✓ Branch 1 taken 155 times.
✓ Branch 4 taken 155 times.
✓ Branch 7 taken 155 times.
|
155 | idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::SpaceList, modelObject); |
| 103 | |||
| 104 | // Space names are already unique | ||
| 105 |
2/2✓ Branch 1 taken 155 times.
✓ Branch 4 taken 155 times.
|
155 | idfObject->clearExtensibleGroups(); |
| 106 |
2/2✓ Branch 4 taken 307 times.
✓ Branch 5 taken 155 times.
|
462 | for (const auto& s : spaces) { |
| 107 |
4/4✓ Branch 1 taken 307 times.
✓ Branch 4 taken 307 times.
✓ Branch 7 taken 307 times.
✓ Branch 10 taken 307 times.
|
614 | idfObject->pushExtensibleGroup(std::vector<std::string>(1, s.nameString())); |
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | // Translate all SpaceType loads | ||
| 112 | 1740 | auto translateSpaceLoads = [this](auto loads) { | |
| 113 | 1740 | std::sort(loads.begin(), loads.end(), WorkspaceObjectNameLess()); | |
| 114 |
14/20auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::ElectricEquipment, std::allocator<openstudio::model::ElectricEquipment> > >(std::vector<openstudio::model::ElectricEquipment, std::allocator<openstudio::model::ElectricEquipment> >) const:
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::ElectricEquipmentITEAirCooled, std::allocator<openstudio::model::ElectricEquipmentITEAirCooled> > >(std::vector<openstudio::model::ElectricEquipmentITEAirCooled, std::allocator<openstudio::model::ElectricEquipmentITEAirCooled> >) const:
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::GasEquipment, std::allocator<openstudio::model::GasEquipment> > >(std::vector<openstudio::model::GasEquipment, std::allocator<openstudio::model::GasEquipment> >) const:
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::HotWaterEquipment, std::allocator<openstudio::model::HotWaterEquipment> > >(std::vector<openstudio::model::HotWaterEquipment, std::allocator<openstudio::model::HotWaterEquipment> >) const:
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::InternalMass, std::allocator<openstudio::model::InternalMass> > >(std::vector<openstudio::model::InternalMass, std::allocator<openstudio::model::InternalMass> >) const:
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::Lights, std::allocator<openstudio::model::Lights> > >(std::vector<openstudio::model::Lights, std::allocator<openstudio::model::Lights> >) const:
✓ Branch 4 taken 113 times.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::Luminaire, std::allocator<openstudio::model::Luminaire> > >(std::vector<openstudio::model::Luminaire, std::allocator<openstudio::model::Luminaire> >) const:
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::OtherEquipment, std::allocator<openstudio::model::OtherEquipment> > >(std::vector<openstudio::model::OtherEquipment, std::allocator<openstudio::model::OtherEquipment> >) const:
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::People, std::allocator<openstudio::model::People> > >(std::vector<openstudio::model::People, std::allocator<openstudio::model::People> >) const:
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 174 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::SteamEquipment, std::allocator<openstudio::model::SteamEquipment> > >(std::vector<openstudio::model::SteamEquipment, std::allocator<openstudio::model::SteamEquipment> >) const:
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
|
2058 | for (auto& load : loads) { |
| 115 |
4/10auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::ElectricEquipment, std::allocator<openstudio::model::ElectricEquipment> > >(std::vector<openstudio::model::ElectricEquipment, std::allocator<openstudio::model::ElectricEquipment> >) const:
✓ Branch 1 taken 136 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::ElectricEquipmentITEAirCooled, std::allocator<openstudio::model::ElectricEquipmentITEAirCooled> > >(std::vector<openstudio::model::ElectricEquipmentITEAirCooled, std::allocator<openstudio::model::ElectricEquipmentITEAirCooled> >) const:
✗ Branch 1 not taken.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::GasEquipment, std::allocator<openstudio::model::GasEquipment> > >(std::vector<openstudio::model::GasEquipment, std::allocator<openstudio::model::GasEquipment> >) const:
✓ Branch 1 taken 2 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::HotWaterEquipment, std::allocator<openstudio::model::HotWaterEquipment> > >(std::vector<openstudio::model::HotWaterEquipment, std::allocator<openstudio::model::HotWaterEquipment> >) const:
✗ Branch 1 not taken.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::InternalMass, std::allocator<openstudio::model::InternalMass> > >(std::vector<openstudio::model::InternalMass, std::allocator<openstudio::model::InternalMass> >) const:
✗ Branch 1 not taken.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::Lights, std::allocator<openstudio::model::Lights> > >(std::vector<openstudio::model::Lights, std::allocator<openstudio::model::Lights> >) const:
✓ Branch 1 taken 113 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::Luminaire, std::allocator<openstudio::model::Luminaire> > >(std::vector<openstudio::model::Luminaire, std::allocator<openstudio::model::Luminaire> >) const:
✗ Branch 1 not taken.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::OtherEquipment, std::allocator<openstudio::model::OtherEquipment> > >(std::vector<openstudio::model::OtherEquipment, std::allocator<openstudio::model::OtherEquipment> >) const:
✗ Branch 1 not taken.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::People, std::allocator<openstudio::model::People> > >(std::vector<openstudio::model::People, std::allocator<openstudio::model::People> >) const:
✓ Branch 1 taken 67 times.
auto openstudio::energyplus::ForwardTranslator::translateSpaceType(openstudio::model::SpaceType&)::{lambda(auto:1)#1}::operator()<std::vector<openstudio::model::SteamEquipment, std::allocator<openstudio::model::SteamEquipment> > >(std::vector<openstudio::model::SteamEquipment, std::allocator<openstudio::model::SteamEquipment> >) const:
✗ Branch 1 not taken.
|
318 | translateAndMapModelObject(load); |
| 116 | } | ||
| 117 | 1740 | }; | |
| 118 | |||
| 119 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.internalMass()); |
| 120 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.lights()); |
| 121 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.luminaires()); |
| 122 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.people()); |
| 123 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.electricEquipment()); |
| 124 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.electricEquipmentITEAirCooled()); |
| 125 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.gasEquipment()); |
| 126 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.hotWaterEquipment()); |
| 127 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.steamEquipment()); |
| 128 |
2/2✓ Branch 1 taken 174 times.
✓ Branch 4 taken 174 times.
|
174 | translateSpaceLoads(modelObject.otherEquipment()); |
| 129 | |||
| 130 | // in translateModelPrivate, we have hard assigned the infiltration objects to each Space. | ||
| 131 | // In E+ these objects are Zone objects, they do not accept Space | ||
| 132 | // Technically this one accepts a Zone or ZoneList | ||
| 133 | // translateSpaceLoads(modelObject.spaceInfiltrationDesignFlowRates()); | ||
| 134 | // These two DO NOT ACCEPT a ZoneList, only a Zone | ||
| 135 | // translateSpaceLoads(modelObject.spaceInfiltrationEffectiveLeakageAreas()); | ||
| 136 | // translateSpaceLoads(modelObject.spaceInfiltrationFlowCoefficients()); | ||
| 137 | |||
| 138 | 174 | return idfObject; | |
| 139 | 202 | } | |
| 140 | |||
| 141 | } // namespace energyplus | ||
| 142 | |||
| 143 | } // namespace openstudio | ||
| 144 |