src/energyplus/ForwardTranslator/ForwardTranslateSizingPlant.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/Model.hpp" | ||
| 8 | #include "../../model/SizingPlant.hpp" | ||
| 9 | #include "../../model/SizingPlant_Impl.hpp" | ||
| 10 | #include "../../model/PlantLoop.hpp" | ||
| 11 | #include "../../model/PlantLoop_Impl.hpp" | ||
| 12 | #include "../../utilities/core/Logger.hpp" | ||
| 13 | #include "../../utilities/core/Assert.hpp" | ||
| 14 | #include <utilities/idd/Sizing_Plant_FieldEnums.hxx> | ||
| 15 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | #include <utilities/idd/IddFactory.hxx> | ||
| 18 | |||
| 19 | using namespace openstudio::model; | ||
| 20 | |||
| 21 | namespace openstudio { | ||
| 22 | |||
| 23 | namespace energyplus { | ||
| 24 | |||
| 25 | enum class PlantSizingType | ||
| 26 | { | ||
| 27 | HOTWATER, | ||
| 28 | CHILLEDWATER, | ||
| 29 | CONDENSER, | ||
| 30 | NONE | ||
| 31 | }; | ||
| 32 | |||
| 33 | ✗ | PlantSizingType plantSizingType(const ModelObject& component) { | |
| 34 | ✗ | switch (component.iddObject().type().value()) { | |
| 35 | ✗ | case openstudio::IddObjectType::OS_Boiler_HotWater: { | |
| 36 | ✗ | return PlantSizingType::HOTWATER; | |
| 37 | } | ||
| 38 | ✗ | case openstudio::IddObjectType::OS_WaterHeater_Mixed: { | |
| 39 | ✗ | return PlantSizingType::HOTWATER; | |
| 40 | } | ||
| 41 | ✗ | case openstudio::IddObjectType::OS_WaterHeater_Stratified: { | |
| 42 | ✗ | return PlantSizingType::HOTWATER; | |
| 43 | } | ||
| 44 | ✗ | case openstudio::IddObjectType::OS_DistrictHeating_Water: { | |
| 45 | ✗ | return PlantSizingType::HOTWATER; | |
| 46 | } | ||
| 47 | ✗ | case openstudio::IddObjectType::OS_DistrictHeating_Steam: { | |
| 48 | ✗ | return PlantSizingType::HOTWATER; | |
| 49 | } | ||
| 50 | ✗ | case openstudio::IddObjectType::OS_Chiller_Electric_ASHRAE205: { | |
| 51 | ✗ | return PlantSizingType::CHILLEDWATER; | |
| 52 | } | ||
| 53 | ✗ | case openstudio::IddObjectType::OS_Chiller_Electric_EIR: { | |
| 54 | ✗ | return PlantSizingType::CHILLEDWATER; | |
| 55 | } | ||
| 56 | ✗ | case openstudio::IddObjectType::OS_Chiller_Absorption_Indirect: { | |
| 57 | ✗ | return PlantSizingType::CHILLEDWATER; | |
| 58 | } | ||
| 59 | ✗ | case openstudio::IddObjectType::OS_Chiller_Absorption: { | |
| 60 | ✗ | return PlantSizingType::CHILLEDWATER; | |
| 61 | } | ||
| 62 | ✗ | case openstudio::IddObjectType::OS_ThermalStorage_Ice_Detailed: { | |
| 63 | ✗ | return PlantSizingType::CHILLEDWATER; | |
| 64 | } | ||
| 65 | ✗ | case openstudio::IddObjectType::OS_DistrictCooling: { | |
| 66 | ✗ | return PlantSizingType::CHILLEDWATER; | |
| 67 | } | ||
| 68 | ✗ | case openstudio::IddObjectType::OS_CoolingTower_SingleSpeed: { | |
| 69 | ✗ | return PlantSizingType::CONDENSER; | |
| 70 | } | ||
| 71 | ✗ | case openstudio::IddObjectType::OS_CoolingTower_VariableSpeed: { | |
| 72 | ✗ | return PlantSizingType::CONDENSER; | |
| 73 | } | ||
| 74 | ✗ | case openstudio::IddObjectType::OS_CoolingTower_TwoSpeed: { | |
| 75 | ✗ | return PlantSizingType::CONDENSER; | |
| 76 | } | ||
| 77 | ✗ | case openstudio::IddObjectType::OS_GroundHeatExchanger_Vertical: { | |
| 78 | ✗ | return PlantSizingType::CONDENSER; | |
| 79 | } | ||
| 80 | ✗ | case openstudio::IddObjectType::OS_GroundHeatExchanger_HorizontalTrench: { | |
| 81 | ✗ | return PlantSizingType::CONDENSER; | |
| 82 | } | ||
| 83 | ✗ | case openstudio::IddObjectType::OS_HeatExchanger_FluidToFluid: { | |
| 84 | ✗ | return PlantSizingType::CONDENSER; | |
| 85 | } | ||
| 86 | ✗ | default: { | |
| 87 | ✗ | return PlantSizingType::NONE; | |
| 88 | } | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | 240 | boost::optional<IdfObject> ForwardTranslator::translateSizingPlant(SizingPlant& modelObject) { | |
| 93 | // These will be used only if reasonable sizing values have not already been provided. | ||
| 94 | ✗ | auto condensorCheck = [](const ModelObject& comp) { return (plantSizingType(comp) == PlantSizingType::CONDENSER); }; | |
| 95 | |||
| 96 | ✗ | auto chilledWaterCheck = [](const ModelObject& comp) { return (plantSizingType(comp) == PlantSizingType::CHILLEDWATER); }; | |
| 97 | |||
| 98 |
3/8✓ Branch 1 taken 240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 240 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 240 times.
|
240 | if ((modelObject.designLoopExitTemperature() < 0.01) && (modelObject.loopDesignTemperatureDifference() < 0.01)) { |
| 99 | ✗ | const auto& components = modelObject.plantLoop().supplyComponents(); | |
| 100 | ✗ | if (std::find_if(components.begin(), components.end(), condensorCheck) != components.end()) { | |
| 101 | ✗ | modelObject.setLoopType("Condenser"); | |
| 102 | ✗ | modelObject.setDesignLoopExitTemperature(29.4); | |
| 103 | ✗ | modelObject.setLoopDesignTemperatureDifference(5.6); | |
| 104 | ✗ | } else if (std::find_if(components.begin(), components.end(), chilledWaterCheck) != components.end()) { | |
| 105 | ✗ | modelObject.setLoopType("Cooling"); | |
| 106 | ✗ | modelObject.setDesignLoopExitTemperature(7.22); | |
| 107 | ✗ | modelObject.setLoopDesignTemperatureDifference(6.67); | |
| 108 | } else { | ||
| 109 | ✗ | modelObject.setLoopType("Heating"); | |
| 110 | ✗ | modelObject.setDesignLoopExitTemperature(82.0); | |
| 111 | ✗ | modelObject.setLoopDesignTemperatureDifference(11.0); | |
| 112 | } | ||
| 113 | ✗ | } | |
| 114 | |||
| 115 | 240 | boost::optional<std::string> s; | |
| 116 | 240 | boost::optional<double> value; | |
| 117 | |||
| 118 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | IdfObject idfObject(IddObjectType::Sizing_Plant); |
| 119 | |||
| 120 | // PlantorCondenserLoopName | ||
| 121 | |||
| 122 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | s = modelObject.plantLoop().name(); |
| 123 |
1/2✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
|
240 | if (s) { |
| 124 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | idfObject.setString(Sizing_PlantFields::PlantorCondenserLoopName, s.get()); |
| 125 | } | ||
| 126 | |||
| 127 | // LoopType | ||
| 128 | |||
| 129 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | s = modelObject.loopType(); |
| 130 |
1/2✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
|
240 | if (s) { |
| 131 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | idfObject.setString(Sizing_PlantFields::LoopType, s.get()); |
| 132 | } | ||
| 133 | |||
| 134 | // DesignLoopExitTemperature | ||
| 135 | |||
| 136 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | value = modelObject.designLoopExitTemperature(); |
| 137 |
1/2✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
|
240 | if (value) { |
| 138 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | idfObject.setDouble(Sizing_PlantFields::DesignLoopExitTemperature, value.get()); |
| 139 | } | ||
| 140 | |||
| 141 | // LoopDesignTemperatureDifference | ||
| 142 | |||
| 143 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | value = modelObject.loopDesignTemperatureDifference(); |
| 144 |
1/2✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
|
240 | if (value) { |
| 145 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | idfObject.setDouble(Sizing_PlantFields::LoopDesignTemperatureDifference, value.get()); |
| 146 | } | ||
| 147 | |||
| 148 | // SizingOption | ||
| 149 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | s = modelObject.sizingOption(); |
| 150 |
1/2✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
|
240 | if (s) { |
| 151 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | idfObject.setString(Sizing_PlantFields::SizingOption, s.get()); |
| 152 | } | ||
| 153 | |||
| 154 | // ZoneTimestepsinAveragingWindow | ||
| 155 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | value = modelObject.zoneTimestepsinAveragingWindow(); |
| 156 |
1/2✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
|
240 | if (value) { |
| 157 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | idfObject.setDouble(Sizing_PlantFields::ZoneTimestepsinAveragingWindow, value.get()); |
| 158 | } | ||
| 159 | |||
| 160 | // CoincidentSizingFactorMode | ||
| 161 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | s = modelObject.coincidentSizingFactorMode(); |
| 162 |
1/2✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
|
240 | if (s) { |
| 163 |
2/2✓ Branch 1 taken 240 times.
✓ Branch 4 taken 240 times.
|
240 | idfObject.setString(Sizing_PlantFields::CoincidentSizingFactorMode, s.get()); |
| 164 | } | ||
| 165 | |||
| 166 |
1/1✓ Branch 1 taken 240 times.
|
240 | m_idfObjects.push_back(idfObject); |
| 167 | |||
| 168 |
1/1✓ Branch 1 taken 240 times.
|
480 | return idfObject; |
| 169 | 240 | } | |
| 170 | |||
| 171 | } // namespace energyplus | ||
| 172 | |||
| 173 | } // namespace openstudio | ||
| 174 |