src/energyplus/ReverseTranslator/ReverseTranslateZoneMixing.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 "../ReverseTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/ZoneMixing.hpp" | ||
| 9 | #include "../../model/ZoneMixing_Impl.hpp" | ||
| 10 | #include "../../model/ThermalZone.hpp" | ||
| 11 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 12 | #include "../../model/Space.hpp" | ||
| 13 | #include "../../model/Space_Impl.hpp" | ||
| 14 | #include "../../model/Schedule.hpp" | ||
| 15 | #include "../../model/Schedule_Impl.hpp" | ||
| 16 | |||
| 17 | #include <utilities/idd/ZoneMixing_FieldEnums.hxx> | ||
| 18 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 19 | #include <utilities/idd/IddEnums.hxx> | ||
| 20 | |||
| 21 | #include "../../utilities/core/Assert.hpp" | ||
| 22 | |||
| 23 | using namespace openstudio::model; | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | |||
| 27 | namespace energyplus { | ||
| 28 | |||
| 29 | ✗ | OptionalModelObject ReverseTranslator::translateZoneMixing(const WorkspaceObject& workspaceObject) { | |
| 30 | ✗ | if (workspaceObject.iddObject().type() != IddObjectType::ZoneMixing) { | |
| 31 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: ZoneMixing"); | |
| 32 | ✗ | return boost::none; | |
| 33 | } | ||
| 34 | |||
| 35 | ✗ | OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::ZoneMixingFields::ZoneorSpaceName); | |
| 36 | ✗ | OptionalThermalZone zone; | |
| 37 | ✗ | if (target) { | |
| 38 | ✗ | if (OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target)) { | |
| 39 | ✗ | if (target->iddObject().type() == IddObjectType::Zone) { | |
| 40 | // Zone maps to Space in RT | ||
| 41 | ✗ | if (auto s_ = modelObject->optionalCast<Space>()) { | |
| 42 | ✗ | zone = s_->thermalZone(); | |
| 43 | ✗ | } | |
| 44 | } else { | ||
| 45 | // It's a space, but we don't allow mapping to a space in model SDK for now, and we don't have a Space RT... so we'll never get here | ||
| 46 | } | ||
| 47 | ✗ | } | |
| 48 | } | ||
| 49 | |||
| 50 | ✗ | if (!zone) { | |
| 51 | ✗ | return boost::none; | |
| 52 | } | ||
| 53 | |||
| 54 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::SourceZoneorSpaceName); | |
| 55 | ✗ | OptionalThermalZone sourceZone; | |
| 56 | ✗ | if (target) { | |
| 57 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 58 | ✗ | if (target->iddObject().type() == IddObjectType::Zone) { | |
| 59 | // Zone maps to Space in RT | ||
| 60 | ✗ | if (auto s_ = modelObject->optionalCast<Space>()) { | |
| 61 | ✗ | sourceZone = s_->thermalZone(); | |
| 62 | ✗ | } | |
| 63 | } else { | ||
| 64 | // It's a space, but we don't allow mapping to a space in model SDK for now, and we don't have a Space RT... so we'll never get here | ||
| 65 | } | ||
| 66 | ✗ | } | |
| 67 | |||
| 68 | ✗ | if (!sourceZone) { | |
| 69 | ✗ | return boost::none; | |
| 70 | } | ||
| 71 | |||
| 72 | ✗ | openstudio::model::ZoneMixing mixing(*zone); | |
| 73 | ✗ | mixing.setSourceZone(sourceZone.get()); | |
| 74 | |||
| 75 | ✗ | OptionalString s = workspaceObject.name(); | |
| 76 | ✗ | if (s) { | |
| 77 | ✗ | mixing.setName(*s); | |
| 78 | } | ||
| 79 | |||
| 80 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::ScheduleName); | |
| 81 | ✗ | if (target) { | |
| 82 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 83 | ✗ | if (modelObject) { | |
| 84 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 85 | ✗ | mixing.setSchedule(s.get()); | |
| 86 | ✗ | } | |
| 87 | } | ||
| 88 | ✗ | } | |
| 89 | |||
| 90 | ✗ | s = workspaceObject.getString(openstudio::ZoneMixingFields::DesignFlowRateCalculationMethod, true); | |
| 91 | ✗ | OS_ASSERT(s); | |
| 92 | |||
| 93 | ✗ | OptionalDouble d; | |
| 94 | ✗ | if (istringEqual("Flow/Zone", *s)) { | |
| 95 | ✗ | d = workspaceObject.getDouble(openstudio::ZoneMixingFields::DesignFlowRate); | |
| 96 | ✗ | if (d) { | |
| 97 | ✗ | mixing.setDesignFlowRate(*d); | |
| 98 | } else { | ||
| 99 | ✗ | LOG(Error, "Flow/Zone value not found for workspace object " << workspaceObject); | |
| 100 | } | ||
| 101 | ✗ | } else if (istringEqual("Flow/Area", *s)) { | |
| 102 | ✗ | d = workspaceObject.getDouble(openstudio::ZoneMixingFields::FlowRateperFloorArea); | |
| 103 | ✗ | if (d) { | |
| 104 | ✗ | mixing.setFlowRateperFloorArea(*d); | |
| 105 | } else { | ||
| 106 | ✗ | LOG(Error, "Flow/Area value not found for workspace object " << workspaceObject); | |
| 107 | } | ||
| 108 | ✗ | } else if (istringEqual("Flow/Person", *s)) { | |
| 109 | ✗ | d = workspaceObject.getDouble(openstudio::ZoneMixingFields::FlowRateperPerson); | |
| 110 | ✗ | if (d) { | |
| 111 | ✗ | mixing.setFlowRateperPerson(*d); | |
| 112 | } else { | ||
| 113 | ✗ | LOG(Error, "Flow/Person value not found for workspace object " << workspaceObject); | |
| 114 | } | ||
| 115 | ✗ | } else if (istringEqual("AirChanges/Hour", *s)) { | |
| 116 | ✗ | d = workspaceObject.getDouble(openstudio::ZoneMixingFields::AirChangesperHour); | |
| 117 | ✗ | if (d) { | |
| 118 | ✗ | mixing.setAirChangesperHour(*d); | |
| 119 | } else { | ||
| 120 | ✗ | LOG(Error, "AirChanges/Hour value not found for workspace object " << workspaceObject); | |
| 121 | } | ||
| 122 | } else { | ||
| 123 | ✗ | LOG(Error, "Unknown DesignFlowRateCalculationMethod value for workspace object" << workspaceObject); | |
| 124 | } | ||
| 125 | |||
| 126 | ✗ | d = workspaceObject.getDouble(openstudio::ZoneMixingFields::DeltaTemperature); | |
| 127 | ✗ | if (d) { | |
| 128 | ✗ | mixing.setDeltaTemperature(*d); | |
| 129 | } | ||
| 130 | |||
| 131 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::DeltaTemperatureScheduleName); | |
| 132 | ✗ | if (target) { | |
| 133 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 134 | ✗ | if (modelObject) { | |
| 135 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 136 | ✗ | mixing.setDeltaTemperatureSchedule(s.get()); | |
| 137 | ✗ | } | |
| 138 | } | ||
| 139 | ✗ | } | |
| 140 | |||
| 141 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::MinimumReceivingTemperatureScheduleName); | |
| 142 | ✗ | if (target) { | |
| 143 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 144 | ✗ | if (modelObject) { | |
| 145 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 146 | ✗ | mixing.setMinimumReceivingTemperatureSchedule(s.get()); | |
| 147 | ✗ | } | |
| 148 | } | ||
| 149 | ✗ | } | |
| 150 | |||
| 151 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::MaximumReceivingTemperatureScheduleName); | |
| 152 | ✗ | if (target) { | |
| 153 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 154 | ✗ | if (modelObject) { | |
| 155 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 156 | ✗ | mixing.setMaximumReceivingTemperatureSchedule(s.get()); | |
| 157 | ✗ | } | |
| 158 | } | ||
| 159 | ✗ | } | |
| 160 | |||
| 161 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::MinimumSourceTemperatureScheduleName); | |
| 162 | ✗ | if (target) { | |
| 163 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 164 | ✗ | if (modelObject) { | |
| 165 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 166 | ✗ | mixing.setMinimumSourceTemperatureSchedule(s.get()); | |
| 167 | ✗ | } | |
| 168 | } | ||
| 169 | ✗ | } | |
| 170 | |||
| 171 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::MaximumSourceTemperatureScheduleName); | |
| 172 | ✗ | if (target) { | |
| 173 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 174 | ✗ | if (modelObject) { | |
| 175 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 176 | ✗ | mixing.setMaximumSourceTemperatureSchedule(s.get()); | |
| 177 | ✗ | } | |
| 178 | } | ||
| 179 | ✗ | } | |
| 180 | |||
| 181 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::MinimumOutdoorTemperatureScheduleName); | |
| 182 | ✗ | if (target) { | |
| 183 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 184 | ✗ | if (modelObject) { | |
| 185 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 186 | ✗ | mixing.setMinimumOutdoorTemperatureSchedule(s.get()); | |
| 187 | ✗ | } | |
| 188 | } | ||
| 189 | ✗ | } | |
| 190 | |||
| 191 | ✗ | target = workspaceObject.getTarget(openstudio::ZoneMixingFields::MaximumOutdoorTemperatureScheduleName); | |
| 192 | ✗ | if (target) { | |
| 193 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 194 | ✗ | if (modelObject) { | |
| 195 | ✗ | if (auto s = modelObject->optionalCast<Schedule>()) { | |
| 196 | ✗ | mixing.setMaximumOutdoorTemperatureSchedule(s.get()); | |
| 197 | ✗ | } | |
| 198 | } | ||
| 199 | ✗ | } | |
| 200 | |||
| 201 | ✗ | return mixing; | |
| 202 | ✗ | } | |
| 203 | |||
| 204 | } // namespace energyplus | ||
| 205 | |||
| 206 | } // namespace openstudio | ||
| 207 |