src/energyplus/ForwardTranslator/ForwardTranslateAirTerminalSingleDuctInletSideMixer.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 | // copy from AirTerminalSingleDuctVAVReheat | ||
| 7 | #include "../ForwardTranslator.hpp" | ||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | #include "../../model/AirTerminalSingleDuctInletSideMixer.hpp" | ||
| 10 | #include "../../model/AirTerminalSingleDuctInletSideMixer_Impl.hpp" | ||
| 11 | #include "../../model/HVACComponent.hpp" | ||
| 12 | #include "../../model/Schedule.hpp" | ||
| 13 | #include "../../model/Schedule_Impl.hpp" | ||
| 14 | #include "../../model/Node.hpp" | ||
| 15 | #include "../../model/Node_Impl.hpp" | ||
| 16 | #include "../../model/ZoneHVACComponent.hpp" | ||
| 17 | #include "../../model/ZoneHVACComponent_Impl.hpp" | ||
| 18 | #include "../../model/AirLoopHVAC.hpp" | ||
| 19 | #include "../../model/DesignSpecificationOutdoorAir.hpp" | ||
| 20 | #include "../../model/Space.hpp" | ||
| 21 | #include "../../model/ThermalZone.hpp" | ||
| 22 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 23 | |||
| 24 | #include <utilities/idd/AirTerminal_SingleDuct_Mixer_FieldEnums.hxx> | ||
| 25 | #include <utilities/idd/ZoneHVAC_AirDistributionUnit_FieldEnums.hxx> | ||
| 26 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 27 | #include <utilities/idd/IddEnums.hxx> | ||
| 28 | #include <utilities/idd/IddFactory.hxx> | ||
| 29 | |||
| 30 | using namespace openstudio::model; | ||
| 31 | |||
| 32 | namespace openstudio { | ||
| 33 | |||
| 34 | namespace energyplus { | ||
| 35 | |||
| 36 | 2 | boost::optional<IdfObject> ForwardTranslator::translateAirTerminalSingleDuctInletSideMixer(AirTerminalSingleDuctInletSideMixer& modelObject) { | |
| 37 | 2 | OptionalModelObject temp; | |
| 38 | 2 | OptionalString optS; | |
| 39 | 2 | boost::optional<std::string> s; | |
| 40 | |||
| 41 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | std::string baseName = modelObject.name().get(); |
| 42 | |||
| 43 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject _airDistributionUnit(openstudio::IddObjectType::ZoneHVAC_AirDistributionUnit); |
| 44 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | _airDistributionUnit.setName("ADU " + baseName); //ADU: Air Distribution Unit |
| 45 | |||
| 46 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject idfObject(openstudio::IddObjectType::AirTerminal_SingleDuct_Mixer); |
| 47 | |||
| 48 |
1/1✓ Branch 1 taken 2 times.
|
2 | idfObject.setName(baseName); |
| 49 | |||
| 50 |
1/1✓ Branch 1 taken 2 times.
|
2 | m_idfObjects.push_back(_airDistributionUnit); |
| 51 | |||
| 52 |
1/1✓ Branch 1 taken 2 times.
|
2 | m_idfObjects.push_back(idfObject); |
| 53 | |||
| 54 | 2 | boost::optional<std::string> inletNodeName; | |
| 55 | 2 | boost::optional<std::string> outletNodeName; | |
| 56 | |||
| 57 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<ModelObject> inletModelObject = modelObject.inletModelObject()) { |
| 58 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (boost::optional<Node> inletNode = inletModelObject->optionalCast<Node>()) { |
| 59 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | inletNodeName = inletNode->name().get(); |
| 60 | 2 | } | |
| 61 | 2 | } | |
| 62 | |||
| 63 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<ModelObject> outletModelObject = modelObject.outletModelObject()) { |
| 64 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (boost::optional<Node> outletNode = outletModelObject->optionalCast<Node>()) { |
| 65 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | outletNodeName = outletNode->name().get(); |
| 66 | 2 | } | |
| 67 | 2 | } | |
| 68 | |||
| 69 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | if (outletNodeName && inletNodeName) { |
| 70 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::MixerOutletNodeName, outletNodeName.get()); |
| 71 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::MixerPrimaryAirInletNodeName, inletNodeName.get()); |
| 72 | } | ||
| 73 | |||
| 74 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<AirLoopHVAC> airLoopHVAC = modelObject.airLoopHVAC()) { |
| 75 | std::vector<ZoneHVACComponent> zoneHVACs = | ||
| 76 |
7/7✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
|
4 | subsetCastVector<ZoneHVACComponent>(airLoopHVAC->demandComponents(modelObject, airLoopHVAC->demandOutletNode())); |
| 77 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if (!zoneHVACs.empty()) { |
| 78 |
1/1✓ Branch 2 taken 2 times.
|
2 | ZoneHVACComponent zoneHVAC = zoneHVACs.front(); |
| 79 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<IdfObject> _zoneHVAC = translateAndMapModelObject(zoneHVAC)) { |
| 80 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::ZoneHVACUnitObjectType, _zoneHVAC->iddObject().name()); |
| 81 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::ZoneHVACUnitObjectName, _zoneHVAC->name().get()); |
| 82 | 2 | } | |
| 83 | 2 | } | |
| 84 | 4 | } | |
| 85 | |||
| 86 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::MixerConnectionType, "InletSide"); |
| 87 | |||
| 88 | // TerminalUnitSecondaryAirInletNodeName | ||
| 89 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<Node> secondaryInletNode = modelObject.secondaryAirInletNode()) { |
| 90 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::MixerSecondaryAirInletNodeName, secondaryInletNode->name().get()); |
| 91 | 2 | } | |
| 92 | |||
| 93 | // ControlForOutdoorAir | ||
| 94 | { | ||
| 95 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | if (modelObject.controlForOutdoorAir()) { |
| 96 | 2 | bool dsoa_found = false; | |
| 97 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto airLoopHVAC = modelObject.airLoopHVAC()) { |
| 98 |
5/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
|
2 | auto zones = airLoopHVAC->demandComponents(modelObject, airLoopHVAC->demandOutletNode(), model::ThermalZone::iddObjectType()); |
| 99 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if (!zones.empty()) { |
| 100 |
1/1✓ Branch 2 taken 2 times.
|
2 | auto zone = zones.front(); |
| 101 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 1 time.
|
4 | if (auto dsoaOrList_ = getOrCreateThermalZoneDSOA(zone.cast<ThermalZone>())) { |
| 102 | 1 | dsoa_found = true; | |
| 103 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::DesignSpecificationOutdoorAirObjectName, dsoaOrList_->nameString()); |
| 104 | 2 | } | |
| 105 | 2 | } | |
| 106 | 4 | } | |
| 107 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2 | if (!dsoa_found) { |
| 108 |
8/8✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
|
1 | LOG(Warn, "Cannot set the 'Design Specification Outdoor Air' (DSOA) object for " |
| 109 | << modelObject.briefDescription() | ||
| 110 | << ". No DSOA was found but 'Control for Outdoor' was set to 'Yes'. Ensure the zone's Space/SpaceType has a DSOA attached."); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 | { | ||
| 116 |
1/1✓ Branch 1 taken 2 times.
|
2 | auto value = modelObject.perPersonVentilationRateMode(); |
| 117 |
1/1✓ Branch 1 taken 2 times.
|
2 | idfObject.setString(AirTerminal_SingleDuct_MixerFields::PerPersonVentilationRateMode, value); |
| 118 | 2 | } | |
| 119 | |||
| 120 | // Populate fields for AirDistributionUnit | ||
| 121 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<ModelObject> outletNode = modelObject.outletModelObject()) { |
| 122 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirDistributionUnitOutletNodeName, outletNode->name().get()); |
| 123 | 2 | } | |
| 124 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalObjectType, idfObject.iddObject().name()); |
| 125 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalName, idfObject.name().get()); |
| 126 | |||
| 127 |
1/1✓ Branch 1 taken 2 times.
|
4 | return _airDistributionUnit; |
| 128 | 2 | } | |
| 129 | |||
| 130 | } // namespace energyplus | ||
| 131 | |||
| 132 | } // namespace openstudio | ||
| 133 |