src/energyplus/ForwardTranslator/ForwardTranslateCoilSystemCoolingWaterHeatExchangerAssisted.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ForwardTranslator.hpp" | ||
| 7 | #include "../../model/CoilSystemCoolingWaterHeatExchangerAssisted.hpp" | ||
| 8 | #include "../../model/CoilSystemCoolingWaterHeatExchangerAssisted_Impl.hpp" | ||
| 9 | #include "../../model/Node.hpp" | ||
| 10 | #include "../../model/Node_Impl.hpp" | ||
| 11 | #include "../../model/HeatExchangerAirToAirSensibleAndLatent.hpp" | ||
| 12 | #include "../../model/HeatExchangerAirToAirSensibleAndLatent_Impl.hpp" | ||
| 13 | #include "../../model/CoilCoolingWater.hpp" | ||
| 14 | #include "../../model/CoilCoolingWater_Impl.hpp" | ||
| 15 | #include "../../model/ControllerWaterCoil.hpp" | ||
| 16 | #include "../../model/ControllerWaterCoil_Impl.hpp" | ||
| 17 | #include "../../model/CoilSystemCoolingWater.hpp" | ||
| 18 | #include "../../model/CoilSystemCoolingWater_Impl.hpp" | ||
| 19 | |||
| 20 | #include "../../model/AirLoopHVAC.hpp" | ||
| 21 | #include "../../model/FanVariableVolume.hpp" | ||
| 22 | #include "../../model/FanVariableVolume_Impl.hpp" | ||
| 23 | #include "../../model/FanConstantVolume.hpp" | ||
| 24 | #include "../../model/FanConstantVolume_Impl.hpp" | ||
| 25 | #include "../../model/FanOnOff.hpp" | ||
| 26 | #include "../../model/FanOnOff_Impl.hpp" | ||
| 27 | #include "../../model/FanSystemModel.hpp" | ||
| 28 | #include "../../model/FanSystemModel_Impl.hpp" | ||
| 29 | |||
| 30 | #include "../../model/Model.hpp" | ||
| 31 | #include "../../utilities/core/Assert.hpp" | ||
| 32 | #include <utilities/idd/CoilSystem_Cooling_Water_HeatExchangerAssisted_FieldEnums.hxx> | ||
| 33 | #include <utilities/idd/HeatExchanger_AirToAir_SensibleAndLatent_FieldEnums.hxx> | ||
| 34 | #include <utilities/idd/Coil_Cooling_Water_FieldEnums.hxx> | ||
| 35 | #include <utilities/idd/Controller_WaterCoil_FieldEnums.hxx> | ||
| 36 | #include <utilities/idd/SetpointManager_MixedAir_FieldEnums.hxx> | ||
| 37 | #include <utilities/idd/IddEnums.hxx> | ||
| 38 | |||
| 39 | using namespace openstudio::model; | ||
| 40 | using namespace std; | ||
| 41 | |||
| 42 | namespace openstudio { | ||
| 43 | |||
| 44 | namespace energyplus { | ||
| 45 | |||
| 46 | boost::optional<IdfObject> | ||
| 47 | 4 | ForwardTranslator::translateCoilSystemCoolingWaterHeatExchangerAssisted(CoilSystemCoolingWaterHeatExchangerAssisted& modelObject) { | |
| 48 | |||
| 49 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::CoilSystem_Cooling_Water_HeatExchangerAssisted, modelObject); |
| 50 | |||
| 51 | 4 | std::string hxSupplyAirInletNodeName; | |
| 52 | 4 | std::string hxExhaustAirOutletNodeName; | |
| 53 | // InletNodeName | ||
| 54 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
8 | if (auto mo = modelObject.inletModelObject()) { |
| 55 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 56 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | hxSupplyAirInletNodeName = node->nameString(); |
| 57 | 2 | } | |
| 58 | // OutletNodeName | ||
| 59 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto mo = modelObject.outletModelObject()) { |
| 60 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 61 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | hxExhaustAirOutletNodeName = node->nameString(); |
| 62 | 2 | } | |
| 63 | 2 | } | |
| 64 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | } else if (auto comp_ = modelObject.containingHVACComponent()) { |
| 65 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
|
4 | if (auto coilSystem_ = comp_->optionalCast<CoilSystemCoolingWater>()) { |
| 66 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (auto mo = coilSystem_->inletModelObject()) { |
| 67 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (auto node = mo->optionalCast<Node>()) { |
| 68 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | hxSupplyAirInletNodeName = node->nameString(); |
| 69 | 1 | } | |
| 70 | 1 | } | |
| 71 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (auto mo = coilSystem_->outletModelObject()) { |
| 72 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (auto node = mo->optionalCast<Node>()) { |
| 73 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | hxExhaustAirOutletNodeName = node->nameString(); |
| 74 | 1 | } | |
| 75 | 1 | } | |
| 76 | 2 | } | |
| 77 | 6 | } | |
| 78 | |||
| 79 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | std::string hxSupplyAirOutletNodeName = modelObject.nameString() + " HX Supply Air Outlet - Cooling Inlet Node"; |
| 80 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | std::string hxExhaustAirInletNodeName = modelObject.nameString() + " HX Exhaust Air Inlet - Cooling Outlet Node"; |
| 81 | |||
| 82 | // HeatExchangerObjectType | ||
| 83 | // HeatExchangerName | ||
| 84 | { | ||
| 85 |
1/1✓ Branch 1 taken 4 times.
|
4 | auto hx = modelObject.heatExchanger(); |
| 86 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if (auto idf = translateAndMapModelObject(hx)) { |
| 87 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::HeatExchangerObjectType, idf->iddObject().name()); |
| 88 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::HeatExchangerName, idf->nameString()); |
| 89 |
5/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | if (idf->iddObject().type() == IddObjectType::HeatExchanger_AirToAir_SensibleAndLatent) { |
| 90 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idf->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::SupplyAirInletNodeName, hxSupplyAirInletNodeName); |
| 91 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idf->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::SupplyAirOutletNodeName, hxSupplyAirOutletNodeName); |
| 92 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idf->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::ExhaustAirOutletNodeName, hxExhaustAirOutletNodeName); |
| 93 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idf->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::ExhaustAirInletNodeName, hxExhaustAirInletNodeName); |
| 94 | } | ||
| 95 | 4 | } | |
| 96 | 4 | } | |
| 97 | |||
| 98 | // CoolingCoilObjectType | ||
| 99 | // CoolingCoilName | ||
| 100 | { | ||
| 101 |
1/1✓ Branch 1 taken 4 times.
|
4 | auto coolingCoil = modelObject.coolingCoil(); |
| 102 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if (auto idf = translateAndMapModelObject(coolingCoil)) { |
| 103 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::CoolingCoilObjectType, idf->iddObject().name()); |
| 104 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::CoolingCoilName, idf->nameString()); |
| 105 |
5/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | if (idf->iddObject().type() == IddObjectType::Coil_Cooling_Water) { |
| 106 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idf->setString(Coil_Cooling_WaterFields::AirInletNodeName, hxSupplyAirOutletNodeName); |
| 107 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idf->setString(Coil_Cooling_WaterFields::AirOutletNodeName, hxExhaustAirInletNodeName); |
| 108 | // Add IddObjectType::Coil_Cooling_Water_DetailedGeometry if implemented | ||
| 109 | } else { | ||
| 110 | // Shouldn't happen, accepts only Coil:Cooling:Water or Coil:Cooling:Water:DetailedGeometry | ||
| 111 | // Shouldn't happen, accepts only Coil:Cooling:DX:SingleSpeed or Coil:Cooling:DX:VariableSpeed | ||
| 112 | ✗ | LOG(Fatal, modelObject.briefDescription() | |
| 113 | << " appears to have a cooling coil that shouldn't have been accepted: " << coolingCoil.briefDescription()); | ||
| 114 | ✗ | OS_ASSERT(false); | |
| 115 | } | ||
| 116 | 4 | } | |
| 117 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if (auto coilCoolingWater = coolingCoil.optionalCast<CoilCoolingWater>()) { |
| 118 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 1 time.
|
8 | if (auto controller = coilCoolingWater->controllerWaterCoil()) { |
| 119 |
3/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
|
6 | if (auto idf = translateAndMapModelObject(controller.get())) { |
| 120 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | idf->setString(Controller_WaterCoilFields::SensorNodeName, hxExhaustAirInletNodeName); |
| 121 | 3 | } | |
| 122 | 4 | } | |
| 123 | 4 | } | |
| 124 | |||
| 125 | // Need a SPM:MixedAir on the Coil:Cooling:Water outlet node (that we **created** just above in IDF directly, so it won't get picked up by the | ||
| 126 | // ForwardTranslateAirLoopHVAC method) | ||
| 127 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
8 | if (boost::optional<AirLoopHVAC> airLoop_ = modelObject.airLoopHVAC()) { |
| 128 | 2 | std::vector<StraightComponent> fans; | |
| 129 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
4 | std::vector<ModelObject> supplyComponents = airLoop_->supplyComponents(); |
| 130 | |||
| 131 |
2/2✓ Branch 4 taken 6 times.
✓ Branch 5 taken 2 times.
|
8 | for (auto it = supplyComponents.begin(); it != supplyComponents.end(); ++it) { |
| 132 |
2/3✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
|
12 | if (auto fan_ = it->optionalCast<FanVariableVolume>()) { |
| 133 | ✗ | fans.insert(fans.begin(), std::move(*fan_)); | |
| 134 |
2/3✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
|
12 | } else if (auto fan_ = it->optionalCast<FanConstantVolume>()) { |
| 135 | ✗ | fans.insert(fans.begin(), std::move(*fan_)); | |
| 136 |
2/3✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
|
12 | } else if (auto fan_ = it->optionalCast<FanSystemModel>()) { |
| 137 | ✗ | fans.insert(fans.begin(), std::move(*fan_)); | |
| 138 |
2/3✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
|
12 | } else if (auto fan_ = it->optionalCast<FanOnOff>()) { |
| 139 | ✗ | fans.insert(fans.begin(), std::move(*fan_)); | |
| 140 | 24 | } | |
| 141 | } | ||
| 142 | |||
| 143 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!fans.empty()) { |
| 144 | // Fan closest to the supply outlet node | ||
| 145 | ✗ | StraightComponent fan = fans.front(); | |
| 146 | ✗ | OptionalNode inletNode = fan.inletModelObject()->optionalCast<Node>(); | |
| 147 | ✗ | OptionalNode outletNode = fan.outletModelObject()->optionalCast<Node>(); | |
| 148 | |||
| 149 | // No reason this wouldn't be ok at this point really... | ||
| 150 | // TODO: change to OS_ASSERT? | ||
| 151 | ✗ | if (inletNode && outletNode) { | |
| 152 | |||
| 153 | ✗ | IdfObject idf_spm(IddObjectType::SetpointManager_MixedAir); | |
| 154 | ✗ | idf_spm.setString(SetpointManager_MixedAirFields::Name, hxExhaustAirInletNodeName + " OS Default SPM"); | |
| 155 | ✗ | idf_spm.setString(SetpointManager_MixedAirFields::ControlVariable, "Temperature"); | |
| 156 | |||
| 157 | ✗ | Node supplyOutletNode = airLoop_->supplyOutletNode(); | |
| 158 | ✗ | idf_spm.setString(SetpointManager_MixedAirFields::ReferenceSetpointNodeName, supplyOutletNode.nameString()); | |
| 159 | |||
| 160 | ✗ | idf_spm.setString(SetpointManager_MixedAirFields::FanInletNodeName, inletNode->nameString()); | |
| 161 | ✗ | idf_spm.setString(SetpointManager_MixedAirFields::FanOutletNodeName, outletNode->nameString()); | |
| 162 | |||
| 163 | ✗ | idf_spm.setString(SetpointManager_MixedAirFields::SetpointNodeorNodeListName, hxExhaustAirInletNodeName); | |
| 164 | |||
| 165 | ✗ | m_idfObjects.push_back(idf_spm); | |
| 166 | ✗ | } | |
| 167 | ✗ | } | |
| 168 | 6 | } | |
| 169 | 4 | } | |
| 170 | |||
| 171 |
1/1✓ Branch 1 taken 4 times.
|
8 | return idfObject; |
| 172 | 4 | } | |
| 173 | |||
| 174 | } // namespace energyplus | ||
| 175 | } // namespace openstudio | ||
| 176 |