src/energyplus/ForwardTranslator/ForwardTranslateAvailabilityManagerHybridVentilation.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/AvailabilityManagerHybridVentilation.hpp" | ||
| 8 | #include "../../model/AvailabilityManagerHybridVentilation_Impl.hpp" | ||
| 9 | #include "../../model/Curve.hpp" | ||
| 10 | #include "../../model/Curve_Impl.hpp" | ||
| 11 | #include "../../model/Model.hpp" | ||
| 12 | #include "../../model/Schedule.hpp" | ||
| 13 | #include "../../model/Schedule_Impl.hpp" | ||
| 14 | #include "../../model/ThermalZone.hpp" | ||
| 15 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 16 | #include "../../model/AirLoopHVAC.hpp" | ||
| 17 | #include "../../model/AirLoopHVAC_Impl.hpp" | ||
| 18 | #include "../../utilities/core/Assert.hpp" | ||
| 19 | #include <utilities/idd/AvailabilityManager_HybridVentilation_FieldEnums.hxx> | ||
| 20 | #include <utilities/idd/IddEnums.hxx> | ||
| 21 | |||
| 22 | using namespace openstudio::model; | ||
| 23 | using namespace std; | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | |||
| 27 | namespace energyplus { | ||
| 28 | |||
| 29 | 1 | boost::optional<IdfObject> ForwardTranslator::translateAvailabilityManagerHybridVentilation(AvailabilityManagerHybridVentilation& modelObject) { | |
| 30 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject idfObject(IddObjectType::AvailabilityManager_HybridVentilation); |
| 31 |
1/1✓ Branch 1 taken 1 time.
|
1 | m_idfObjects.push_back(idfObject); |
| 32 | |||
| 33 | 1 | boost::optional<AirLoopHVAC> airLoopHVAC; | |
| 34 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto loop = modelObject.loop()) { |
| 35 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | airLoopHVAC = loop->optionalCast<model::AirLoopHVAC>(); |
| 36 | 1 | } | |
| 37 | |||
| 38 | // Name | ||
| 39 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto s = modelObject.name()) { |
| 40 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setName(*s); |
| 41 | 1 | } | |
| 42 | |||
| 43 | // HVACAirLoopName | ||
| 44 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto loop = modelObject.loop()) { |
| 45 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::HVACAirLoopName, loop->name().get()); |
| 46 | 1 | } | |
| 47 | |||
| 48 | // ControlledZoneName | ||
| 49 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto zone = modelObject.controlledZone()) { |
| 50 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::ControlZoneName, zone->name().get()); |
| 51 | } else { | ||
| 52 | ✗ | if (airLoopHVAC) { | |
| 53 | ✗ | auto zones = airLoopHVAC->thermalZones(); | |
| 54 | ✗ | if (!zones.empty()) { | |
| 55 | ✗ | auto default_zone = zones.front(); | |
| 56 | ✗ | LOG(Info, modelObject.briefDescription() << " is missing Control Zone Name, defaulting to " << default_zone.briefDescription() << "."); | |
| 57 | ✗ | idfObject.setString(AvailabilityManager_HybridVentilationFields::ControlZoneName, default_zone.name().get()); | |
| 58 | ✗ | } | |
| 59 | ✗ | } | |
| 60 | 1 | } | |
| 61 | |||
| 62 | // VentilationControlModeScheduleName | ||
| 63 | { | ||
| 64 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto schedule = modelObject.ventilationControlModeSchedule(); |
| 65 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::VentilationControlModeScheduleName, schedule.name().get()); |
| 66 | 1 | } | |
| 67 | |||
| 68 | // UseWeatherFileRainIndicators | ||
| 69 | { | ||
| 70 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | if (modelObject.useWeatherFileRainIndicators()) { |
| 71 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | idfObject.setString(AvailabilityManager_HybridVentilationFields::UseWeatherFileRainIndicators, "Yes"); |
| 72 | } else { | ||
| 73 | ✗ | idfObject.setString(AvailabilityManager_HybridVentilationFields::UseWeatherFileRainIndicators, "No"); | |
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | // MaximumWindSpeed | ||
| 78 | { | ||
| 79 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.maximumWindSpeed(); |
| 80 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MaximumWindSpeed, value); |
| 81 | } | ||
| 82 | |||
| 83 | // MinimumOutdoorTemperature | ||
| 84 | { | ||
| 85 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.minimumOutdoorTemperature(); |
| 86 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MinimumOutdoorTemperature, value); |
| 87 | } | ||
| 88 | |||
| 89 | // MaximumOutdoorTemperature | ||
| 90 | { | ||
| 91 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.maximumOutdoorTemperature(); |
| 92 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MaximumOutdoorTemperature, value); |
| 93 | } | ||
| 94 | |||
| 95 | // MinimumOutdoorEnthalpy | ||
| 96 | { | ||
| 97 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.minimumOutdoorEnthalpy(); |
| 98 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MinimumOutdoorEnthalpy, value); |
| 99 | } | ||
| 100 | |||
| 101 | // MaximumOutdoorEnthalpy | ||
| 102 | { | ||
| 103 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.maximumOutdoorEnthalpy(); |
| 104 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MaximumOutdoorEnthalpy, value); |
| 105 | } | ||
| 106 | |||
| 107 | // MinimumOutdoorDewpoint | ||
| 108 | { | ||
| 109 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.minimumOutdoorDewpoint(); |
| 110 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MinimumOutdoorDewpoint, value); |
| 111 | } | ||
| 112 | |||
| 113 | // MaximumOutdoorDewpoint | ||
| 114 | { | ||
| 115 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.maximumOutdoorDewpoint(); |
| 116 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MaximumOutdoorDewpoint, value); |
| 117 | } | ||
| 118 | |||
| 119 | // MinimumOutdoorVentilationAirScheduleName | ||
| 120 | { | ||
| 121 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto schedule = modelObject.minimumOutdoorVentilationAirSchedule(); |
| 122 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::MinimumOutdoorVentilationAirScheduleName, schedule.name().get()); |
| 123 | 1 | } | |
| 124 | |||
| 125 | // OpeningFactorFunctionofWindSpeedCurveName | ||
| 126 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto curve = modelObject.openingFactorFunctionofWindSpeedCurve()) { |
| 127 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto idf = translateAndMapModelObject(curve.get()); |
| 128 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(idf); |
| 129 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::OpeningFactorFunctionofWindSpeedCurveName, idf->name().get()); |
| 130 | 2 | } | |
| 131 | |||
| 132 | // AirflowNetwork Control Type Schedule Name | ||
| 133 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto oSch = modelObject.airflowNetworkControlTypeSchedule()) { |
| 134 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto idf = translateAndMapModelObject(oSch.get()); |
| 135 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(idf); |
| 136 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::AirflowNetworkControlTypeScheduleName, idf->nameString()); |
| 137 | 2 | } | |
| 138 | |||
| 139 | // Simple Airflow Control Type Schedule Name | ||
| 140 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto oSch = modelObject.simpleAirflowControlTypeSchedule()) { |
| 141 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto idf = translateAndMapModelObject(oSch.get()); |
| 142 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(idf); |
| 143 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::SimpleAirflowControlTypeScheduleName, idf->nameString()); |
| 144 | 2 | } | |
| 145 | |||
| 146 | // ZoneVentilation Object Name | ||
| 147 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto oMo = modelObject.zoneVentilationObject()) { |
| 148 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto idf = translateAndMapModelObject(oMo.get()); |
| 149 | // Model API shouldn't allow setting a wrong type (other than ZV:DesignFlowRate or ZV:WindAndStackOpenArea) anyways | ||
| 150 | // and E+ will throw a clear warning if that were the case, so no need to check here | ||
| 151 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(idf); |
| 152 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(AvailabilityManager_HybridVentilationFields::ZoneVentilationObjectName, idf->nameString()); |
| 153 | 2 | } | |
| 154 | |||
| 155 | // Minimum HVAC Operation Time | ||
| 156 | { | ||
| 157 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.minimumHVACOperationTime(); |
| 158 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MinimumHVACOperationTime, value); |
| 159 | } | ||
| 160 | |||
| 161 | // Minimum Ventilation Time | ||
| 162 | { | ||
| 163 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto value = modelObject.minimumVentilationTime(); |
| 164 |
1/1✓ Branch 1 taken 1 time.
|
1 | idfObject.setDouble(AvailabilityManager_HybridVentilationFields::MinimumVentilationTime, value); |
| 165 | } | ||
| 166 | |||
| 167 |
1/1✓ Branch 1 taken 1 time.
|
2 | return idfObject; |
| 168 | 1 | } | |
| 169 | |||
| 170 | } // namespace energyplus | ||
| 171 | } // namespace openstudio | ||
| 172 |