src/energyplus/ForwardTranslator/ForwardTranslateZoneMixing.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/Schedule.hpp" | ||
| 9 | #include "../../model/Schedule_Impl.hpp" | ||
| 10 | #include "../../model/ModelObject.hpp" | ||
| 11 | #include "../../model/ModelObject_Impl.hpp" | ||
| 12 | #include "../../model/ZoneMixing.hpp" | ||
| 13 | #include "../../model/ZoneMixing_Impl.hpp" | ||
| 14 | #include "../../model/ThermalZone.hpp" | ||
| 15 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 16 | #include "../../model/Space.hpp" | ||
| 17 | #include "../../model/Space_Impl.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/ZoneMixing_FieldEnums.hxx> | ||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | #include <utilities/idd/IddFactory.hxx> | ||
| 23 | |||
| 24 | using namespace openstudio::model; | ||
| 25 | |||
| 26 | namespace openstudio { | ||
| 27 | |||
| 28 | namespace energyplus { | ||
| 29 | |||
| 30 | 15 | boost::optional<IdfObject> ForwardTranslator::translateZoneMixing(ZoneMixing& modelObject) { | |
| 31 | |||
| 32 |
1/1✓ Branch 1 taken 15 times.
|
15 | ModelObject zoneOrSpace = modelObject.zoneOrSpace(); |
| 33 |
1/1✓ Branch 1 taken 15 times.
|
15 | boost::optional<ModelObject> sourceZoneOrSpace = modelObject.sourceZoneOrSpace(); |
| 34 | |||
| 35 | 22 | auto getParentObjectName = [this](const ModelObject& mo) { | |
| 36 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 10 times.
|
22 | if (!m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 37 | 12 | return mo.nameString(); | |
| 38 | } | ||
| 39 | |||
| 40 |
3/3✓ Branch 1 taken 10 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
|
20 | if (auto space_ = mo.optionalCast<Space>()) { |
| 41 |
3/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
16 | if (auto thermalZone_ = space_->thermalZone()) { |
| 42 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | return thermalZone_->nameString(); |
| 43 | } else { | ||
| 44 | ✗ | OS_ASSERT(false); // This shouldn't happen, since we removed all orphaned spaces earlier in the FT | |
| 45 | 8 | } | |
| 46 | 10 | } | |
| 47 | |||
| 48 | 2 | return mo.nameString(); | |
| 49 | 15 | }; | |
| 50 | |||
| 51 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 11 times.
|
15 | if (!sourceZoneOrSpace) { |
| 52 |
6/12✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
8 | if (m_forwardTranslatorOptions.excludeSpaceTranslation() && modelObject.space()) { |
| 53 |
7/7✓ 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 17 taken 4 times.
✓ Branch 20 taken 4 times.
|
4 | LOG(Warn, modelObject.briefDescription() |
| 54 | << " doesn't have a Source Zone or Space, it will not be translated. As you were using Space-Level ZoneMixing, and you are not " | ||
| 55 | "translating to Spaces, it's possible it was pointing to two spaces inside the same zone"); | ||
| 56 | } else { | ||
| 57 | ✗ | LOG(Warn, modelObject.briefDescription() << " doesn't have a Source Zone or Space, it will not be translated."); | |
| 58 | } | ||
| 59 | 4 | return boost::none; | |
| 60 | } | ||
| 61 | |||
| 62 |
3/4✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
|
11 | if (zoneOrSpace == sourceZoneOrSpace.get()) { |
| 63 | // This isn't going to happen, because zm.setSourceSpace(newSpace) in ThermalZone::combineSpaces will be rejected | ||
| 64 | // Let's play it safe though | ||
| 65 | ✗ | LOG(Warn, modelObject.briefDescription() << " has the same Receiving and Source Zone or Space, it will not be translated."); | |
| 66 | ✗ | if (!m_forwardTranslatorOptions.excludeSpaceTranslation()) { | |
| 67 | // We don't allow this at model time, the only reason we expect this to happen is when m_forwardTranslatorOptions.excludeSpaceTranslation() | ||
| 68 | // is true, we call combineSpaces, and if the user has a ZoneMixing pointing to two spaces from the same ThermalZone, | ||
| 69 | // you end up with matching Receiving and Source Spaces | ||
| 70 | ✗ | OS_ASSERT(false); | |
| 71 | } | ||
| 72 | ✗ | return boost::none; | |
| 73 | } | ||
| 74 | |||
| 75 | // Makes sure the modelObject gets put in the map, and that the new idfObject gets put in | ||
| 76 | // the final file. Also set's the idfObject's name. | ||
| 77 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | IdfObject idfObject = createRegisterAndNameIdfObject(IddObjectType::ZoneMixing, modelObject); |
| 78 | |||
| 79 | 11 | boost::optional<double> value; | |
| 80 | |||
| 81 | // ZoneorSpaceName | ||
| 82 |
1/1✓ Branch 1 taken 11 times.
|
11 | translateAndMapModelObject(zoneOrSpace); |
| 83 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | idfObject.setString(ZoneMixingFields::ZoneorSpaceName, getParentObjectName(zoneOrSpace)); |
| 84 | |||
| 85 | // ScheduleName | ||
| 86 |
1/1✓ Branch 1 taken 11 times.
|
11 | Schedule schedule = modelObject.schedule(); |
| 87 |
1/1✓ Branch 1 taken 11 times.
|
11 | translateAndMapModelObject(schedule); |
| 88 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | idfObject.setString(ZoneMixingFields::ScheduleName, schedule.nameString()); |
| 89 | |||
| 90 | // DesignFlowRateCalculationMethod | ||
| 91 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
11 | idfObject.setString(ZoneMixingFields::DesignFlowRateCalculationMethod, modelObject.designFlowRateCalculationMethod()); |
| 92 | |||
| 93 | // DesignFlowRate | ||
| 94 |
1/1✓ Branch 1 taken 11 times.
|
11 | value = modelObject.designFlowRate(); |
| 95 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
|
11 | if (value) { |
| 96 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | idfObject.setDouble(ZoneMixingFields::DesignFlowRate, *value); |
| 97 | } | ||
| 98 | |||
| 99 | // FlowRateperFloorArea | ||
| 100 |
1/1✓ Branch 1 taken 11 times.
|
11 | value = modelObject.flowRateperFloorArea(); |
| 101 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
|
11 | if (value) { |
| 102 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | idfObject.setDouble(ZoneMixingFields::FlowRateperFloorArea, *value); |
| 103 | } | ||
| 104 | |||
| 105 | // FlowRateperPerson | ||
| 106 |
1/1✓ Branch 1 taken 11 times.
|
11 | value = modelObject.flowRateperPerson(); |
| 107 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 10 times.
|
11 | if (value) { |
| 108 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setDouble(ZoneMixingFields::FlowRateperPerson, *value); |
| 109 | } | ||
| 110 | |||
| 111 | // AirChangesperHour | ||
| 112 |
1/1✓ Branch 1 taken 11 times.
|
11 | value = modelObject.airChangesperHour(); |
| 113 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 10 times.
|
11 | if (value) { |
| 114 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setDouble(ZoneMixingFields::AirChangesperHour, *value); |
| 115 | } | ||
| 116 | |||
| 117 | // SourceZoneorSpaceName | ||
| 118 | // DLM: do not translate source zone now, it will be translated at the right time | ||
| 119 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | idfObject.setString(ZoneMixingFields::SourceZoneorSpaceName, getParentObjectName(sourceZoneOrSpace.get())); |
| 120 | |||
| 121 | // DeltaTemperature | ||
| 122 |
1/1✓ Branch 1 taken 11 times.
|
11 | value = modelObject.deltaTemperature(); |
| 123 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (value) { |
| 124 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setDouble(ZoneMixingFields::DeltaTemperature, *value); |
| 125 | } | ||
| 126 | |||
| 127 | // DeltaTemperatureScheduleName | ||
| 128 |
1/1✓ Branch 1 taken 11 times.
|
11 | boost::optional<Schedule> optSchedule = modelObject.deltaTemperatureSchedule(); |
| 129 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (optSchedule) { |
| 130 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateAndMapModelObject(*optSchedule); |
| 131 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(ZoneMixingFields::DeltaTemperatureScheduleName, optSchedule->nameString()); |
| 132 | } | ||
| 133 | |||
| 134 | // MinimumReceivingTemperatureScheduleName | ||
| 135 |
1/1✓ Branch 1 taken 11 times.
|
11 | optSchedule = modelObject.minimumReceivingTemperatureSchedule(); |
| 136 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (optSchedule) { |
| 137 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateAndMapModelObject(*optSchedule); |
| 138 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(ZoneMixingFields::MinimumReceivingTemperatureScheduleName, optSchedule->nameString()); |
| 139 | } | ||
| 140 | |||
| 141 | // MaximumReceivingTemperatureScheduleName | ||
| 142 |
1/1✓ Branch 1 taken 11 times.
|
11 | optSchedule = modelObject.maximumReceivingTemperatureSchedule(); |
| 143 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (optSchedule) { |
| 144 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateAndMapModelObject(*optSchedule); |
| 145 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(ZoneMixingFields::MaximumReceivingTemperatureScheduleName, optSchedule->nameString()); |
| 146 | } | ||
| 147 | |||
| 148 | // MinimumSourceTemperatureScheduleName | ||
| 149 |
1/1✓ Branch 1 taken 11 times.
|
11 | optSchedule = modelObject.minimumSourceTemperatureSchedule(); |
| 150 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (optSchedule) { |
| 151 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateAndMapModelObject(*optSchedule); |
| 152 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(ZoneMixingFields::MinimumSourceTemperatureScheduleName, optSchedule->nameString()); |
| 153 | } | ||
| 154 | |||
| 155 | // MaximumSourceTemperatureScheduleName | ||
| 156 |
1/1✓ Branch 1 taken 11 times.
|
11 | optSchedule = modelObject.maximumSourceTemperatureSchedule(); |
| 157 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (optSchedule) { |
| 158 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateAndMapModelObject(*optSchedule); |
| 159 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(ZoneMixingFields::MaximumSourceTemperatureScheduleName, optSchedule->nameString()); |
| 160 | } | ||
| 161 | |||
| 162 | // MinimumOutdoorTemperatureScheduleName | ||
| 163 |
1/1✓ Branch 1 taken 11 times.
|
11 | optSchedule = modelObject.minimumOutdoorTemperatureSchedule(); |
| 164 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (optSchedule) { |
| 165 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateAndMapModelObject(*optSchedule); |
| 166 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(ZoneMixingFields::MinimumOutdoorTemperatureScheduleName, optSchedule->nameString()); |
| 167 | } | ||
| 168 | |||
| 169 | // MaximumOutdoorTemperatureScheduleName | ||
| 170 |
1/1✓ Branch 1 taken 11 times.
|
11 | optSchedule = modelObject.maximumOutdoorTemperatureSchedule(); |
| 171 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
|
11 | if (optSchedule) { |
| 172 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | translateAndMapModelObject(*optSchedule); |
| 173 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(ZoneMixingFields::MaximumOutdoorTemperatureScheduleName, optSchedule->nameString()); |
| 174 | } | ||
| 175 | |||
| 176 |
1/1✓ Branch 1 taken 11 times.
|
11 | return idfObject; |
| 177 | 15 | } | |
| 178 | |||
| 179 | } // namespace energyplus | ||
| 180 | |||
| 181 | } // namespace openstudio | ||
| 182 |