src/energyplus/ForwardTranslator/ForwardTranslateFanSystemModel.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 | |||
| 9 | #include "../../model/FanSystemModel.hpp" | ||
| 10 | |||
| 11 | #include "../../model/Schedule.hpp" | ||
| 12 | #include "../../model/Curve.hpp" | ||
| 13 | #include "../../model/ThermalZone.hpp" | ||
| 14 | #include "../../model/Node.hpp" | ||
| 15 | #include "../../model/Node_Impl.hpp" | ||
| 16 | |||
| 17 | #include "../../utilities/core/Logger.hpp" | ||
| 18 | #include "../../utilities/core/Assert.hpp" | ||
| 19 | |||
| 20 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 21 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 22 | #include <utilities/idd/Fan_SystemModel_FieldEnums.hxx> | ||
| 23 | #include <utilities/idd/IddEnums.hxx> | ||
| 24 | #include <utilities/idd/IddFactory.hxx> | ||
| 25 | |||
| 26 | using namespace openstudio::model; | ||
| 27 | |||
| 28 | //using namespace std; | ||
| 29 | |||
| 30 | namespace openstudio { | ||
| 31 | |||
| 32 | namespace energyplus { | ||
| 33 | |||
| 34 | 18 | boost::optional<IdfObject> ForwardTranslator::translateFanSystemModel(FanSystemModel& modelObject) { | |
| 35 | //setup boost optionals to use to store get method returns | ||
| 36 | 18 | boost::optional<std::string> s; | |
| 37 | 18 | boost::optional<double> value; | |
| 38 | 18 | boost::optional<Node> node; | |
| 39 | 18 | OptionalModelObject mo; | |
| 40 | |||
| 41 | // Make sure the modelObject gets ut into the map, and the new idfObject gets put into the final file. | ||
| 42 | // Also sets the idfObjects name | ||
| 43 | |||
| 44 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | IdfObject idfObject = createRegisterAndNameIdfObject(IddObjectType::Fan_SystemModel, modelObject); |
| 45 | |||
| 46 | // Model Name | ||
| 47 | //std::string baseName = modelObject.name().get(); | ||
| 48 | |||
| 49 | // Availability Schedule Name: Required Object | ||
| 50 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | boost::optional<Schedule> availabilitySchedule = modelObject.availabilitySchedule(); |
| 51 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (availabilitySchedule) { |
| 52 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | boost::optional<IdfObject> _availabilitySchedule = translateAndMapModelObject(availabilitySchedule.get()); |
| 53 | |||
| 54 |
6/12✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 18 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 18 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 18 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
54 | if (_availabilitySchedule && _availabilitySchedule->name()) { |
| 55 |
4/4✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
✓ Branch 10 taken 18 times.
|
18 | idfObject.setString(Fan_SystemModelFields::AvailabilityScheduleName, _availabilitySchedule->name().get()); |
| 56 | } | ||
| 57 | 18 | } | |
| 58 | |||
| 59 | // Air Inlet Node Name: Optional Object | ||
| 60 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 14 times.
|
36 | if (boost::optional<ModelObject> inletModelObject = modelObject.inletModelObject()) { |
| 61 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
|
8 | if (boost::optional<Node> inletNode = inletModelObject->optionalCast<Node>()) { |
| 62 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | idfObject.setString(Fan_SystemModelFields::AirInletNodeName, inletNode->name().get()); |
| 63 | 4 | } | |
| 64 | 18 | } | |
| 65 | |||
| 66 | // Air Outlet Node Name: Optional Object | ||
| 67 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 14 times.
|
36 | if (boost::optional<ModelObject> outletModelObject = modelObject.outletModelObject()) { |
| 68 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
|
8 | if (boost::optional<Node> outletNode = outletModelObject->optionalCast<Node>()) { |
| 69 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | idfObject.setString(Fan_SystemModelFields::AirOutletNodeName, outletNode->name().get()); |
| 70 | 4 | } | |
| 71 | 18 | } | |
| 72 | |||
| 73 | // Design Maximum Air Flow Rate: Autosizable Double | ||
| 74 |
1/1✓ Branch 1 taken 18 times.
|
18 | value = modelObject.designMaximumAirFlowRate(); |
| 75 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 17 times.
|
18 | if (value) { |
| 76 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setDouble(Fan_SystemModelFields::DesignMaximumAirFlowRate, value.get()); |
| 77 | } else { | ||
| 78 |
2/2✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
|
34 | idfObject.setString(Fan_SystemModelFields::DesignMaximumAirFlowRate, "Autosize"); |
| 79 | } | ||
| 80 | |||
| 81 | // Speed Control Method: Required String | ||
| 82 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setString(Fan_SystemModelFields::SpeedControlMethod, modelObject.speedControlMethod()); |
| 83 | |||
| 84 | // Electric Power Minimum Flow Rate Fraction: Required Double | ||
| 85 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::ElectricPowerMinimumFlowRateFraction, modelObject.electricPowerMinimumFlowRateFraction()); |
| 86 | |||
| 87 | // Design Pressure Rise: Required Double | ||
| 88 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::DesignPressureRise, modelObject.designPressureRise()); |
| 89 | |||
| 90 | // Motor Efficiency: Required Double | ||
| 91 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::MotorEfficiency, modelObject.motorEfficiency()); |
| 92 | |||
| 93 | // Motor In Air Stream Fraction: Required Double | ||
| 94 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::MotorInAirStreamFraction, modelObject.motorInAirStreamFraction()); |
| 95 | |||
| 96 | // Design Electric Power Consumption: Autosizable | ||
| 97 |
1/1✓ Branch 1 taken 18 times.
|
18 | value = modelObject.designElectricPowerConsumption(); |
| 98 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 17 times.
|
18 | if (value) { |
| 99 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setDouble(Fan_SystemModelFields::DesignElectricPowerConsumption, value.get()); |
| 100 | } else { | ||
| 101 |
2/2✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
|
34 | idfObject.setString(Fan_SystemModelFields::DesignElectricPowerConsumption, "Autosize"); |
| 102 | } | ||
| 103 | |||
| 104 | // Design Power Sizing Method: Required String | ||
| 105 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setString(Fan_SystemModelFields::DesignPowerSizingMethod, modelObject.designPowerSizingMethod()); |
| 106 | |||
| 107 | // Electric Power Per Unit Flow Rate: Required Double | ||
| 108 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::ElectricPowerPerUnitFlowRate, modelObject.electricPowerPerUnitFlowRate()); |
| 109 | |||
| 110 | // Electric Power Per Unit Flow Rate Per Unit Pressure: Required Double | ||
| 111 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::ElectricPowerPerUnitFlowRatePerUnitPressure, |
| 112 | modelObject.electricPowerPerUnitFlowRatePerUnitPressure()); | ||
| 113 | |||
| 114 | // Fan Total Efficiency: Required Double | ||
| 115 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::FanTotalEfficiency, modelObject.fanTotalEfficiency()); |
| 116 | |||
| 117 | // Electric Power Function of Flow Fraction Curve Name: Optional Object | ||
| 118 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 17 times.
|
36 | if (boost::optional<Curve> _curve = modelObject.electricPowerFunctionofFlowFractionCurve()) { |
| 119 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (boost::optional<IdfObject> _idf_curve = translateAndMapModelObject(_curve.get())) { |
| 120 |
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(Fan_SystemModelFields::ElectricPowerFunctionofFlowFractionCurveName, _idf_curve->name().get()); |
| 121 | 1 | } | |
| 122 | 18 | } | |
| 123 | |||
| 124 | // Night Ventilation Mode Pressure Rise: Optional Double | ||
| 125 |
1/1✓ Branch 1 taken 18 times.
|
18 | value = modelObject.nightVentilationModePressureRise(); |
| 126 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 17 times.
|
18 | if (value) { |
| 127 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setDouble(Fan_SystemModelFields::NightVentilationModePressureRise, value.get()); |
| 128 | } | ||
| 129 | |||
| 130 | // Night Ventilation Mode Flow Fraction: Optional Double | ||
| 131 |
1/1✓ Branch 1 taken 18 times.
|
18 | value = modelObject.nightVentilationModeFlowFraction(); |
| 132 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 17 times.
|
18 | if (value) { |
| 133 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setDouble(Fan_SystemModelFields::NightVentilationModeFlowFraction, value.get()); |
| 134 | } | ||
| 135 | |||
| 136 | // Motor Loss Zone Name: Optional Object | ||
| 137 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 17 times.
|
36 | if (boost::optional<ThermalZone> _z = modelObject.motorLossZone()) { |
| 138 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (boost::optional<IdfObject> _idf_z = translateAndMapModelObject(_z.get())) { |
| 139 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(Fan_SystemModelFields::MotorLossZoneName, _idf_z->nameString()); |
| 140 | 1 | } | |
| 141 | 18 | } | |
| 142 | |||
| 143 | // Motor Loss Radiative Fraction: Optional Double | ||
| 144 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | value = modelObject.motorLossRadiativeFraction(); |
| 145 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (value) { |
| 146 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setDouble(Fan_SystemModelFields::MotorLossRadiativeFraction, value.get()); |
| 147 | } | ||
| 148 | |||
| 149 | // End-Use Subcategory: Required String | ||
| 150 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setString(Fan_SystemModelFields::EndUseSubcategory, modelObject.endUseSubcategory()); |
| 151 | |||
| 152 | // Speeds | ||
| 153 |
1/1✓ Branch 1 taken 18 times.
|
18 | std::vector<FanSystemModelSpeed> speeds = modelObject.speeds(); |
| 154 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 17 times.
|
18 | if (!speeds.empty()) { |
| 155 |
2/2✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 time.
|
4 | for (const FanSystemModelSpeed& speed : speeds) { |
| 156 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto eg = idfObject.pushExtensibleGroup(); |
| 157 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | eg.setDouble(Fan_SystemModelExtensibleFields::SpeedFlowFraction, speed.flowFraction()); |
| 158 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (auto epf_ = speed.electricPowerFraction()) { |
| 159 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | eg.setDouble(Fan_SystemModelExtensibleFields::SpeedElectricPowerFraction, epf_.get()); |
| 160 | } | ||
| 161 | 3 | } | |
| 162 | } | ||
| 163 | |||
| 164 | // Number of Speeds: Required Integer | ||
| 165 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | idfObject.setInt(Fan_SystemModelFields::NumberofSpeeds, modelObject.numberofSpeeds()); |
| 166 | |||
| 167 |
1/1✓ Branch 1 taken 18 times.
|
36 | return idfObject; |
| 168 | 18 | } | |
| 169 | |||
| 170 | } // namespace energyplus | ||
| 171 | |||
| 172 | } // namespace openstudio | ||
| 173 |