src/energyplus/ForwardTranslator/ForwardTranslateRefrigerationWalkIn.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/RefrigerationWalkIn.hpp" | ||
| 9 | #include "../../model/RefrigerationWalkIn_Impl.hpp" | ||
| 10 | #include "../../model/ThermalZone.hpp" | ||
| 11 | #include "../../model/Schedule.hpp" | ||
| 12 | #include "../../model/RefrigerationWalkInZoneBoundary.hpp" | ||
| 13 | #include "../../utilities/time/Time.hpp" | ||
| 14 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 15 | |||
| 16 | #include <utilities/idd/Refrigeration_WalkIn_FieldEnums.hxx> | ||
| 17 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | #include <utilities/idd/IddFactory.hxx> | ||
| 20 | |||
| 21 | using namespace openstudio::model; | ||
| 22 | |||
| 23 | using namespace std; | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | |||
| 27 | namespace energyplus { | ||
| 28 | |||
| 29 | ✗ | boost::optional<IdfObject> ForwardTranslator::translateRefrigerationWalkIn(RefrigerationWalkIn& modelObject) { | |
| 30 | ✗ | OptionalModelObject temp; | |
| 31 | ✗ | boost::optional<std::string> s; | |
| 32 | ✗ | boost::optional<double> d; | |
| 33 | |||
| 34 | // Name | ||
| 35 | ✗ | IdfObject refrigerationWalkIn = createRegisterAndNameIdfObject(openstudio::IddObjectType::Refrigeration_WalkIn, modelObject); | |
| 36 | |||
| 37 | //AvailabilityScheduleName | ||
| 38 | ✗ | boost::optional<Schedule> availabilitySchedule = modelObject.availabilitySchedule(); | |
| 39 | |||
| 40 | ✗ | if (availabilitySchedule) { | |
| 41 | ✗ | boost::optional<IdfObject> _availabilitySchedule = translateAndMapModelObject(availabilitySchedule.get()); | |
| 42 | |||
| 43 | ✗ | if (_availabilitySchedule && _availabilitySchedule->name()) { | |
| 44 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::AvailabilityScheduleName, _availabilitySchedule->name().get()); | |
| 45 | } | ||
| 46 | ✗ | } | |
| 47 | |||
| 48 | //RatedCoilCoolingCapacity | ||
| 49 | ✗ | d = modelObject.ratedCoilCoolingCapacity(); | |
| 50 | ✗ | if (d) { | |
| 51 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::RatedCoilCoolingCapacity, d.get()); | |
| 52 | } | ||
| 53 | |||
| 54 | //OperatingTemperature | ||
| 55 | ✗ | d = modelObject.operatingTemperature(); | |
| 56 | ✗ | if (d) { | |
| 57 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::OperatingTemperature, d.get()); | |
| 58 | } | ||
| 59 | |||
| 60 | //RatedCoolingSourceTemperature | ||
| 61 | ✗ | d = modelObject.ratedCoolingSourceTemperature(); | |
| 62 | ✗ | if (d) { | |
| 63 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::RatedCoolingSourceTemperature, d.get()); | |
| 64 | } | ||
| 65 | |||
| 66 | //RatedTotalHeatingPower | ||
| 67 | ✗ | d = modelObject.ratedTotalHeatingPower(); | |
| 68 | ✗ | if (d) { | |
| 69 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::RatedTotalHeatingPower, d.get()); | |
| 70 | } | ||
| 71 | |||
| 72 | //HeatingPowerScheduleName | ||
| 73 | ✗ | boost::optional<Schedule> heatingPowerSchedule = modelObject.heatingPowerSchedule(); | |
| 74 | |||
| 75 | ✗ | if (heatingPowerSchedule) { | |
| 76 | ✗ | boost::optional<IdfObject> _heatingPowerSchedule = translateAndMapModelObject(heatingPowerSchedule.get()); | |
| 77 | |||
| 78 | ✗ | if (_heatingPowerSchedule && _heatingPowerSchedule->name()) { | |
| 79 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::HeatingPowerScheduleName, _heatingPowerSchedule->name().get()); | |
| 80 | } | ||
| 81 | ✗ | } | |
| 82 | |||
| 83 | //RatedCoolingCoilFanPower | ||
| 84 | ✗ | d = modelObject.ratedCoolingCoilFanPower(); | |
| 85 | ✗ | if (d) { | |
| 86 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::RatedCoolingCoilFanPower, d.get()); | |
| 87 | } | ||
| 88 | |||
| 89 | //RatedCirculationFanPower | ||
| 90 | ✗ | d = modelObject.ratedCirculationFanPower(); | |
| 91 | ✗ | if (d) { | |
| 92 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::RatedCirculationFanPower, d.get()); | |
| 93 | } | ||
| 94 | |||
| 95 | //RatedTotalLightingPower | ||
| 96 | ✗ | d = modelObject.ratedTotalLightingPower(); | |
| 97 | ✗ | if (d) { | |
| 98 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::RatedTotalLightingPower, d.get()); | |
| 99 | } | ||
| 100 | |||
| 101 | //LightingScheduleName | ||
| 102 | ✗ | boost::optional<Schedule> lightingSchedule = modelObject.lightingSchedule(); | |
| 103 | |||
| 104 | ✗ | if (lightingSchedule) { | |
| 105 | ✗ | boost::optional<IdfObject> _lightingSchedule = translateAndMapModelObject(lightingSchedule.get()); | |
| 106 | |||
| 107 | ✗ | if (_lightingSchedule && _lightingSchedule->name()) { | |
| 108 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::LightingScheduleName, _lightingSchedule->name().get()); | |
| 109 | } | ||
| 110 | ✗ | } | |
| 111 | |||
| 112 | //DefrostType | ||
| 113 | ✗ | s = modelObject.defrostType(); | |
| 114 | ✗ | if (s) { | |
| 115 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::DefrostType, s.get()); | |
| 116 | } | ||
| 117 | |||
| 118 | //DefrostControlType | ||
| 119 | ✗ | s = modelObject.defrostControlType(); | |
| 120 | ✗ | if (s) { | |
| 121 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::DefrostControlType, s.get()); | |
| 122 | } | ||
| 123 | |||
| 124 | //DefrostCycleParameters | ||
| 125 | ✗ | boost::optional<int> durationofDefrostCycle = modelObject.durationofDefrostCycle(); | |
| 126 | ✗ | boost::optional<int> dripDownTime = modelObject.dripDownTime(); | |
| 127 | ✗ | std::vector<openstudio::Time> defrostStartTimes = modelObject.getImpl<model::detail::RefrigerationWalkIn_Impl>()->defrostStartTimes(); | |
| 128 | |||
| 129 | ✗ | if (durationofDefrostCycle && dripDownTime && !defrostStartTimes.empty()) { | |
| 130 | ✗ | int defrostTimeHour = *durationofDefrostCycle / 60; | |
| 131 | ✗ | int defrostTimeMin = *durationofDefrostCycle % 60; | |
| 132 | ✗ | int dripDownTimeHour = *dripDownTime / 60; | |
| 133 | ✗ | int dripDownTimeMin = *dripDownTime % 60; | |
| 134 | |||
| 135 | ✗ | std::vector<std::pair<openstudio::Time, double>> defrostDefaultDay; | |
| 136 | ✗ | std::vector<std::pair<openstudio::Time, double>> dripDownDefaultDay; | |
| 137 | ✗ | for (auto _defrostStartTime = defrostStartTimes.begin(); _defrostStartTime != defrostStartTimes.end(); ++_defrostStartTime) { | |
| 138 | ✗ | defrostDefaultDay.push_back(std::make_pair(*_defrostStartTime, 0)); // defrost off | |
| 139 | ✗ | openstudio::Time defrostEndTime(0, _defrostStartTime->hours() + defrostTimeHour, _defrostStartTime->minutes() + defrostTimeMin); | |
| 140 | ✗ | defrostDefaultDay.push_back(std::make_pair(defrostEndTime, 1)); // defrost on | |
| 141 | |||
| 142 | ✗ | dripDownDefaultDay.push_back(std::make_pair(*_defrostStartTime, 0)); // drip down off | |
| 143 | ✗ | openstudio::Time dripDownEndTime(0, _defrostStartTime->hours() + defrostTimeHour + dripDownTimeHour, | |
| 144 | ✗ | _defrostStartTime->minutes() + defrostTimeMin + dripDownTimeMin); | |
| 145 | ✗ | dripDownDefaultDay.push_back(std::make_pair(dripDownEndTime, 1)); // drip down on | |
| 146 | } | ||
| 147 | |||
| 148 | ✗ | if ((defrostStartTimes.front().hours() != 0 && defrostStartTimes.front().minutes() != 0) || defrostStartTimes.back().hours() < 24) { | |
| 149 | ✗ | openstudio::Time defrostDayEnd(0, 24, 0); | |
| 150 | ✗ | defrostDefaultDay.push_back(std::make_pair(defrostDayEnd, 0)); // defrost off | |
| 151 | ✗ | dripDownDefaultDay.push_back(std::make_pair(defrostDayEnd, 0)); // drip down off | |
| 152 | } | ||
| 153 | |||
| 154 | //DefrostScheduleName | ||
| 155 | ✗ | std::string defrostName(modelObject.name().get() + " Defrost Schedule"); | |
| 156 | ✗ | boost::optional<IdfObject> defrostSchedule = this->createSimpleSchedule(defrostName, defrostDefaultDay); | |
| 157 | ✗ | if (defrostSchedule) { | |
| 158 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::DefrostScheduleName, defrostName); | |
| 159 | } | ||
| 160 | |||
| 161 | //DefrostDripDownScheduleName | ||
| 162 | ✗ | std::string dripDownName(modelObject.name().get() + " Defrost Drip Down Schedule"); | |
| 163 | ✗ | boost::optional<IdfObject> defrostDripDownSchedule = this->createSimpleSchedule(dripDownName, dripDownDefaultDay); | |
| 164 | ✗ | if (defrostDripDownSchedule) { | |
| 165 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::DefrostDripDownScheduleName, dripDownName); | |
| 166 | } | ||
| 167 | ✗ | } else { | |
| 168 | //DefrostScheduleName | ||
| 169 | ✗ | boost::optional<Schedule> defrostSchedule = modelObject.defrostSchedule(); | |
| 170 | |||
| 171 | ✗ | if (defrostSchedule) { | |
| 172 | ✗ | boost::optional<IdfObject> _defrostSchedule = translateAndMapModelObject(defrostSchedule.get()); | |
| 173 | |||
| 174 | ✗ | if (_defrostSchedule && _defrostSchedule->name()) { | |
| 175 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::DefrostScheduleName, _defrostSchedule->name().get()); | |
| 176 | } | ||
| 177 | ✗ | } | |
| 178 | |||
| 179 | //DefrostDripDownScheduleName | ||
| 180 | ✗ | boost::optional<Schedule> defrostDripDownSchedule = modelObject.defrostDripDownSchedule(); | |
| 181 | |||
| 182 | ✗ | if (defrostDripDownSchedule) { | |
| 183 | ✗ | boost::optional<IdfObject> _defrostDripDownSchedule = translateAndMapModelObject(defrostDripDownSchedule.get()); | |
| 184 | |||
| 185 | ✗ | if (_defrostDripDownSchedule && _defrostDripDownSchedule->name()) { | |
| 186 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::DefrostDripDownScheduleName, _defrostDripDownSchedule->name().get()); | |
| 187 | } | ||
| 188 | ✗ | } | |
| 189 | ✗ | } | |
| 190 | |||
| 191 | //DefrostPower | ||
| 192 | ✗ | d = modelObject.defrostPower(); | |
| 193 | ✗ | if (d) { | |
| 194 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::DefrostPower, d.get()); | |
| 195 | } | ||
| 196 | |||
| 197 | //TemperatureTerminationDefrostFractiontoIce | ||
| 198 | ✗ | d = modelObject.temperatureTerminationDefrostFractiontoIce(); | |
| 199 | ✗ | if (d) { | |
| 200 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::TemperatureTerminationDefrostFractiontoIce, d.get()); | |
| 201 | } | ||
| 202 | |||
| 203 | //RestockingScheduleName | ||
| 204 | ✗ | boost::optional<Schedule> restockingSchedule = modelObject.restockingSchedule(); | |
| 205 | |||
| 206 | ✗ | if (restockingSchedule) { | |
| 207 | ✗ | boost::optional<IdfObject> _restockingSchedule = translateAndMapModelObject(restockingSchedule.get()); | |
| 208 | |||
| 209 | ✗ | if (_restockingSchedule && _restockingSchedule->name()) { | |
| 210 | ✗ | refrigerationWalkIn.setString(Refrigeration_WalkInFields::RestockingScheduleName, _restockingSchedule->name().get()); | |
| 211 | } | ||
| 212 | ✗ | } | |
| 213 | |||
| 214 | //AverageRefrigerantChargeInventory | ||
| 215 | ✗ | d = modelObject.averageRefrigerantChargeInventory(); | |
| 216 | ✗ | if (d) { | |
| 217 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::AverageRefrigerantChargeInventory, d.get()); | |
| 218 | } | ||
| 219 | |||
| 220 | //InsulatedFloorSurfaceArea | ||
| 221 | ✗ | d = modelObject.insulatedFloorSurfaceArea(); | |
| 222 | ✗ | if (d) { | |
| 223 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::InsulatedFloorSurfaceArea, d.get()); | |
| 224 | } | ||
| 225 | |||
| 226 | //InsulatedFloorUValue | ||
| 227 | ✗ | d = modelObject.insulatedFloorUValue(); | |
| 228 | ✗ | if (d) { | |
| 229 | ✗ | refrigerationWalkIn.setDouble(Refrigeration_WalkInFields::InsulatedFloorUValue, d.get()); | |
| 230 | } | ||
| 231 | |||
| 232 | //ZoneBoundaries | ||
| 233 | ✗ | std::vector<RefrigerationWalkInZoneBoundary> zoneBoundaries = modelObject.zoneBoundaries(); | |
| 234 | |||
| 235 | ✗ | if (!zoneBoundaries.empty()) { | |
| 236 | ✗ | for (const auto& _zoneBoundary : zoneBoundaries) { | |
| 237 | ✗ | IdfExtensibleGroup eg = refrigerationWalkIn.pushExtensibleGroup(); | |
| 238 | |||
| 239 | //ZoneName | ||
| 240 | ✗ | boost::optional<ThermalZone> thermalZone = _zoneBoundary.thermalZone(); | |
| 241 | |||
| 242 | ✗ | if (thermalZone) { | |
| 243 | ✗ | boost::optional<IdfObject> _thermalZone = translateAndMapModelObject(thermalZone.get()); | |
| 244 | |||
| 245 | ✗ | if (_thermalZone && _thermalZone->name()) { | |
| 246 | ✗ | eg.setString(Refrigeration_WalkInExtensibleFields::ZoneName, _thermalZone->name().get()); | |
| 247 | } | ||
| 248 | ✗ | } | |
| 249 | |||
| 250 | //TotalInsulatedSurfaceAreaFacingZone | ||
| 251 | ✗ | d = _zoneBoundary.totalInsulatedSurfaceAreaFacingZone(); | |
| 252 | ✗ | if (d) { | |
| 253 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::TotalInsulatedSurfaceAreaFacingZone, d.get()); | |
| 254 | } | ||
| 255 | |||
| 256 | //InsulatedSurfaceUValueFacingZone | ||
| 257 | ✗ | d = _zoneBoundary.insulatedSurfaceUValueFacingZone(); | |
| 258 | ✗ | if (d) { | |
| 259 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::InsulatedSurfaceUValueFacingZone, d.get()); | |
| 260 | } | ||
| 261 | |||
| 262 | //AreaofGlassReachInDoorsFacingZone | ||
| 263 | ✗ | d = _zoneBoundary.areaofGlassReachInDoorsFacingZone(); | |
| 264 | ✗ | if (d) { | |
| 265 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::AreaofGlassReachInDoorsFacingZone, d.get()); | |
| 266 | } | ||
| 267 | |||
| 268 | //HeightofGlassReachInDoorsFacingZone | ||
| 269 | ✗ | d = _zoneBoundary.heightofGlassReachInDoorsFacingZone(); | |
| 270 | ✗ | if (d) { | |
| 271 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::HeightofGlassReachInDoorsFacingZone, d.get()); | |
| 272 | } | ||
| 273 | |||
| 274 | //GlassReachInDoorUValueFacingZone | ||
| 275 | ✗ | d = _zoneBoundary.glassReachInDoorUValueFacingZone(); | |
| 276 | ✗ | if (d) { | |
| 277 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::GlassReachInDoorUValueFacingZone, d.get()); | |
| 278 | } | ||
| 279 | |||
| 280 | //GlassReachInDoorOpeningScheduleNameFacingZone | ||
| 281 | ✗ | boost::optional<Schedule> glassReachInDoorOpeningScheduleFacingZone = _zoneBoundary.glassReachInDoorOpeningScheduleFacingZone(); | |
| 282 | |||
| 283 | ✗ | if (glassReachInDoorOpeningScheduleFacingZone) { | |
| 284 | boost::optional<IdfObject> _glassReachInDoorOpeningScheduleFacingZone = | ||
| 285 | ✗ | translateAndMapModelObject(glassReachInDoorOpeningScheduleFacingZone.get()); | |
| 286 | |||
| 287 | ✗ | if (_glassReachInDoorOpeningScheduleFacingZone && _glassReachInDoorOpeningScheduleFacingZone->name()) { | |
| 288 | ✗ | eg.setString(Refrigeration_WalkInExtensibleFields::GlassReachInDoorOpeningScheduleNameFacingZone, | |
| 289 | ✗ | _glassReachInDoorOpeningScheduleFacingZone->name().get()); | |
| 290 | } | ||
| 291 | ✗ | } | |
| 292 | |||
| 293 | //AreaofStockingDoorsFacingZone | ||
| 294 | ✗ | d = _zoneBoundary.areaofStockingDoorsFacingZone(); | |
| 295 | ✗ | if (d) { | |
| 296 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::AreaofStockingDoorsFacingZone, d.get()); | |
| 297 | } | ||
| 298 | |||
| 299 | //HeightofStockingDoorsFacingZone | ||
| 300 | ✗ | d = _zoneBoundary.heightofStockingDoorsFacingZone(); | |
| 301 | ✗ | if (d) { | |
| 302 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::HeightofStockingDoorsFacingZone, d.get()); | |
| 303 | } | ||
| 304 | |||
| 305 | //StockingDoorUValueFacingZone | ||
| 306 | ✗ | d = _zoneBoundary.stockingDoorUValueFacingZone(); | |
| 307 | ✗ | if (d) { | |
| 308 | ✗ | eg.setDouble(Refrigeration_WalkInExtensibleFields::StockingDoorUValueFacingZone, d.get()); | |
| 309 | } | ||
| 310 | |||
| 311 | //StockingDoorOpeningScheduleNameFacingZone | ||
| 312 | ✗ | boost::optional<Schedule> stockingDoorOpeningScheduleFacingZone = _zoneBoundary.stockingDoorOpeningScheduleFacingZone(); | |
| 313 | |||
| 314 | ✗ | if (stockingDoorOpeningScheduleFacingZone) { | |
| 315 | ✗ | boost::optional<IdfObject> _stockingDoorOpeningScheduleFacingZone = translateAndMapModelObject(stockingDoorOpeningScheduleFacingZone.get()); | |
| 316 | |||
| 317 | ✗ | if (_stockingDoorOpeningScheduleFacingZone && _stockingDoorOpeningScheduleFacingZone->name()) { | |
| 318 | ✗ | eg.setString(Refrigeration_WalkInExtensibleFields::StockingDoorOpeningScheduleNameFacingZone, | |
| 319 | ✗ | _stockingDoorOpeningScheduleFacingZone->name().get()); | |
| 320 | } | ||
| 321 | ✗ | } | |
| 322 | |||
| 323 | //StockingDoorOpeningProtectionTypeFacingZone | ||
| 324 | ✗ | s = _zoneBoundary.stockingDoorOpeningProtectionTypeFacingZone(); | |
| 325 | ✗ | if (s) { | |
| 326 | ✗ | eg.setString(Refrigeration_WalkInExtensibleFields::StockingDoorOpeningProtectionTypeFacingZone, s.get()); | |
| 327 | } | ||
| 328 | ✗ | } | |
| 329 | } | ||
| 330 | |||
| 331 | ✗ | return refrigerationWalkIn; | |
| 332 | ✗ | } | |
| 333 | } // namespace energyplus | ||
| 334 | } // namespace openstudio | ||
| 335 |