src/energyplus/ForwardTranslator/ForwardTranslateFanOnOff.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/Node.hpp" | ||
| 11 | #include "../../model/Node_Impl.hpp" | ||
| 12 | #include "../../model/FanOnOff.hpp" | ||
| 13 | #include "../../model/FanOnOff_Impl.hpp" | ||
| 14 | #include <utilities/idd/Fan_OnOff_FieldEnums.hxx> | ||
| 15 | #include "../../model/Curve.hpp" | ||
| 16 | #include "../../model/Curve_Impl.hpp" | ||
| 17 | #include "../../utilities/core/Logger.hpp" | ||
| 18 | #include "../../utilities/core/Assert.hpp" | ||
| 19 | |||
| 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 | //using namespace std; | ||
| 27 | |||
| 28 | namespace openstudio { | ||
| 29 | |||
| 30 | namespace energyplus { | ||
| 31 | |||
| 32 | 28 | boost::optional<IdfObject> ForwardTranslator::translateFanOnOff(FanOnOff& modelObject) { | |
| 33 | //setup boost optionals to use to store get method returns | ||
| 34 | 28 | boost::optional<std::string> s; | |
| 35 | 28 | boost::optional<double> value; | |
| 36 | 28 | boost::optional<Node> node; | |
| 37 | 28 | OptionalModelObject mo; | |
| 38 | |||
| 39 | // Make sure the modelObject gets ut into the map, and the new idfObject gets put into the final file. | ||
| 40 | // Also sets the idfObjects name | ||
| 41 | |||
| 42 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | IdfObject idfObject = createRegisterAndNameIdfObject(IddObjectType::Fan_OnOff, modelObject); |
| 43 | |||
| 44 | // Model Name | ||
| 45 | //std::string baseName = modelObject.name().get(); | ||
| 46 | |||
| 47 | // A3 ,Field Availability Schedule Name | ||
| 48 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | boost::optional<Schedule> availabilitySchedule = modelObject.availabilitySchedule(); |
| 49 | |||
| 50 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (availabilitySchedule) { |
| 51 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | boost::optional<IdfObject> _availabilitySchedule = translateAndMapModelObject(availabilitySchedule.get()); |
| 52 | |||
| 53 |
6/12✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 28 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 28 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
84 | if (_availabilitySchedule && _availabilitySchedule->name()) { |
| 54 |
4/4✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
|
28 | idfObject.setString(Fan_OnOffFields::AvailabilityScheduleName, _availabilitySchedule->name().get()); |
| 55 | } | ||
| 56 | 28 | } | |
| 57 | |||
| 58 | // N1 ,Field Fan Efficiency | ||
| 59 | |||
| 60 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | value = modelObject.fanEfficiency(); |
| 61 | |||
| 62 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (value) { |
| 63 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | idfObject.setDouble(Fan_OnOffFields::FanTotalEfficiency, *value); |
| 64 | } | ||
| 65 | |||
| 66 | // N2 Pressure Rise | ||
| 67 | |||
| 68 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | value = modelObject.pressureRise(); |
| 69 | |||
| 70 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (value) { |
| 71 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | idfObject.setDouble(Fan_OnOffFields::PressureRise, *value); |
| 72 | } | ||
| 73 | |||
| 74 | // N3, Field Maximum Flow Rate | ||
| 75 | |||
| 76 |
1/1✓ Branch 1 taken 28 times.
|
28 | value = modelObject.maximumFlowRate(); |
| 77 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
|
28 | if (value) { |
| 78 | ✗ | idfObject.setDouble(Fan_OnOffFields::MaximumFlowRate, value.get()); | |
| 79 | } else { | ||
| 80 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
56 | idfObject.setString(Fan_OnOffFields::MaximumFlowRate, "Autosize"); |
| 81 | } | ||
| 82 | |||
| 83 | // N4, Field Motor Efficiency | ||
| 84 | |||
| 85 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | value = modelObject.motorEfficiency(); |
| 86 | |||
| 87 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (value) { |
| 88 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | idfObject.setDouble(Fan_OnOffFields::MotorEfficiency, *value); |
| 89 | } | ||
| 90 | |||
| 91 | // N5, Field Motor In Airstream Fraction | ||
| 92 | |||
| 93 |
1/1✓ Branch 1 taken 28 times.
|
28 | value = modelObject.motorInAirstreamFraction(); |
| 94 | |||
| 95 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (value) { |
| 96 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | idfObject.setDouble(Fan_OnOffFields::MotorInAirstreamFraction, *value); |
| 97 | } | ||
| 98 | |||
| 99 | // A4 Air Inlet Node Name | ||
| 100 | |||
| 101 |
2/3✓ Branch 1 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28 times.
|
56 | if (boost::optional<ModelObject> inletModelObject = modelObject.inletModelObject()) { |
| 102 | ✗ | if (boost::optional<Node> inletNode = inletModelObject->optionalCast<Node>()) { | |
| 103 | ✗ | idfObject.setString(Fan_OnOffFields::AirInletNodeName, inletNode->name().get()); | |
| 104 | ✗ | } | |
| 105 | 28 | } | |
| 106 | |||
| 107 | // A5 , Field Air Outlet Node Name | ||
| 108 | |||
| 109 |
2/3✓ Branch 1 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28 times.
|
56 | if (boost::optional<ModelObject> ouletModelObject = modelObject.outletModelObject()) { |
| 110 | ✗ | if (boost::optional<Node> ouletNode = ouletModelObject->optionalCast<Node>()) { | |
| 111 | ✗ | idfObject.setString(Fan_OnOffFields::AirOutletNodeName, ouletNode->name().get()); | |
| 112 | ✗ | } | |
| 113 | 28 | } | |
| 114 | |||
| 115 | // A6 , Field Fan Power Ratio Function of Speed Ratio Curve Name | ||
| 116 | |||
| 117 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | boost::optional<Curve> fanPowerRatioFunctionofSpeedRatioCurve = modelObject.fanPowerRatioFunctionofSpeedRatioCurve(); |
| 118 | |||
| 119 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (fanPowerRatioFunctionofSpeedRatioCurve) { |
| 120 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | boost::optional<IdfObject> _fanPowerRatioFunctionofSpeedRatioCurve = translateAndMapModelObject(fanPowerRatioFunctionofSpeedRatioCurve.get()); |
| 121 | |||
| 122 |
6/12✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 28 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 28 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
84 | if (_fanPowerRatioFunctionofSpeedRatioCurve && _fanPowerRatioFunctionofSpeedRatioCurve->name()) { |
| 123 |
4/4✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
|
28 | idfObject.setString(Fan_OnOffFields::FanPowerRatioFunctionofSpeedRatioCurveName, _fanPowerRatioFunctionofSpeedRatioCurve->name().get()); |
| 124 | } | ||
| 125 | 28 | } | |
| 126 | |||
| 127 | // A7 , Field Fan Efficiency Ratio Function of Speed Ratio Curve Name | ||
| 128 | |||
| 129 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | boost::optional<Curve> fanEfficiencyRatioFunctionofSpeedRatioCurve = modelObject.fanEfficiencyRatioFunctionofSpeedRatioCurve(); |
| 130 | |||
| 131 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | if (fanEfficiencyRatioFunctionofSpeedRatioCurve) { |
| 132 | boost::optional<IdfObject> _fanEfficiencyRatioFunctionofSpeedRatioCurve = | ||
| 133 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | translateAndMapModelObject(fanEfficiencyRatioFunctionofSpeedRatioCurve.get()); |
| 134 | |||
| 135 |
6/12✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 28 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 28 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
84 | if (_fanEfficiencyRatioFunctionofSpeedRatioCurve && _fanEfficiencyRatioFunctionofSpeedRatioCurve->name()) { |
| 136 | 28 | idfObject.setString(Fan_OnOffFields::FanEfficiencyRatioFunctionofSpeedRatioCurveName, | |
| 137 |
4/4✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 7 taken 28 times.
✓ Branch 10 taken 28 times.
|
28 | _fanEfficiencyRatioFunctionofSpeedRatioCurve->name().get()); |
| 138 | } | ||
| 139 | 28 | } | |
| 140 | |||
| 141 | // A8 , Field End-Use Subcategory | ||
| 142 | |||
| 143 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | idfObject.setString(Fan_OnOffFields::EndUseSubcategory, modelObject.endUseSubcategory()); |
| 144 | |||
| 145 |
1/1✓ Branch 1 taken 28 times.
|
56 | return idfObject; |
| 146 | 28 | } | |
| 147 | |||
| 148 | } // namespace energyplus | ||
| 149 | |||
| 150 | } // namespace openstudio | ||
| 151 |