GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 88.6% 39 / 0 / 44
Functions: 100.0% 1 / 0 / 1
Branches: 74.0% 54 / 0 / 73

src/energyplus/ForwardTranslator/ForwardTranslateFanConstantVolume.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/FanConstantVolume.hpp"
9 #include "../../model/FanConstantVolume_Impl.hpp"
10 #include "../../model/AirLoopHVAC.hpp"
11 #include "../../model/AirLoopHVAC_Impl.hpp"
12 #include "../../model/Schedule.hpp"
13 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
14 #include "../../utilities/idf/Workspace.hpp"
15 #include "../../utilities/idf/WorkspaceObjectOrder.hpp"
16 #include "../../utilities/core/Logger.hpp"
17 #include <utilities/idd/Fan_ConstantVolume_FieldEnums.hxx>
18 #include <utilities/idd/IddEnums.hxx>
19
20 using namespace openstudio::model;
21
22 namespace openstudio {
23
24 namespace energyplus {
25
26 98 boost::optional<IdfObject> ForwardTranslator::translateFanConstantVolume(FanConstantVolume& modelObject) {
27 98 OptionalString s;
28 98 OptionalDouble d;
29 98 OptionalModelObject temp;
30
31 // Create a new IddObjectType::Fan_ConstantVolume
32
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 IdfObject idfObject(IddObjectType::Fan_ConstantVolume);
33
34 ///////////////////////////////////////////////////////////////////////////
35 // Field: Name ////////////////////////////////////////////////////////////
36
1/1
✓ Branch 1 taken 98 times.
98 s = modelObject.name();
37
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if (s) {
38
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 idfObject.setName(*s);
39 }
40 ///////////////////////////////////////////////////////////////////////////
41
42 // hook up required objects
43 try {
44
3/3
✓ Branch 1 taken 98 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 59 times.
196 if (boost::optional<model::AirLoopHVAC> airLoopHVAC = modelObject.airLoopHVAC()) {
45
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 Schedule sched = airLoopHVAC->availabilitySchedule();
46
1/1
✓ Branch 1 taken 39 times.
39 boost::optional<IdfObject> schedIdf = translateAndMapModelObject(sched);
47
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if (schedIdf) {
48
4/4
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
✓ Branch 7 taken 39 times.
✓ Branch 10 taken 39 times.
39 idfObject.setString(Fan_ConstantVolumeFields::AvailabilityScheduleName, schedIdf->name().get());
49 }
50 39 } else {
51
1/1
✓ Branch 1 taken 59 times.
59 Schedule sched = modelObject.availabilitySchedule();
52
1/1
✓ Branch 1 taken 59 times.
59 translateAndMapModelObject(sched);
53
3/3
✓ Branch 1 taken 59 times.
✓ Branch 4 taken 59 times.
✓ Branch 7 taken 59 times.
59 idfObject.setString(Fan_ConstantVolumeFields::AvailabilityScheduleName, sched.name().get());
54 157 }
55 ✗ } catch (std::exception& e) {
56 ✗ LOG(Error, "Could not translate " << modelObject.briefDescription() << ", because " << e.what() << ".");
57 ✗ return boost::none;
58 ✗ }
59
60 ///////////////////////////////////////////////////////////////////////////
61 // Fan Total Efficiency ///////////////////////////////////////////////////
62
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 idfObject.setDouble(openstudio::Fan_ConstantVolumeFields::FanTotalEfficiency, modelObject.fanEfficiency());
63 ///////////////////////////////////////////////////////////////////////////
64
65 ///////////////////////////////////////////////////////////////////////////
66 // Pressure Rise //////////////////////////////////////////////////////////
67
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 idfObject.setDouble(openstudio::Fan_ConstantVolumeFields::PressureRise, modelObject.pressureRise());
68 ///////////////////////////////////////////////////////////////////////////
69
70 ///////////////////////////////////////////////////////////////////////////
71 // Maximum Flow Rate //////////////////////////////////////////////////////
72
1/1
✓ Branch 1 taken 98 times.
98 d = modelObject.maximumFlowRate();
73
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if (d) {
74 ✗ idfObject.setDouble(openstudio::Fan_ConstantVolumeFields::MaximumFlowRate, *d);
75 } else {
76
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
196 idfObject.setString(openstudio::Fan_ConstantVolumeFields::MaximumFlowRate, "AutoSize");
77 }
78 ///////////////////////////////////////////////////////////////////////////
79
80 ///////////////////////////////////////////////////////////////////////////
81 // Motor Efficiency ///////////////////////////////////////////////////////
82
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 idfObject.setDouble(openstudio::Fan_ConstantVolumeFields::MotorEfficiency, modelObject.motorEfficiency());
83 ///////////////////////////////////////////////////////////////////////////
84
85 ///////////////////////////////////////////////////////////////////////////
86 // Motor In Airstream Fraction ////////////////////////////////////////////
87
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 idfObject.setDouble(openstudio::Fan_ConstantVolumeFields::MotorInAirstreamFraction, modelObject.motorInAirstreamFraction());
88 ///////////////////////////////////////////////////////////////////////////
89
90 ///////////////////////////////////////////////////////////////////////////
91 // Air Inlet Node Name ////////////////////////////////////////////////////
92
1/1
✓ Branch 1 taken 98 times.
98 temp = modelObject.inletModelObject();
93
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 59 times.
98 if (temp) {
94
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 s = temp->name();
95
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if (s) {
96
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 idfObject.setString(openstudio::Fan_ConstantVolumeFields::AirInletNodeName, *s);
97 }
98 }
99 ///////////////////////////////////////////////////////////////////////////
100
101 ///////////////////////////////////////////////////////////////////////////
102 // Air Outlet Node Name ///////////////////////////////////////////////////
103
1/1
✓ Branch 1 taken 98 times.
98 temp = modelObject.outletModelObject();
104
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 59 times.
98 if (temp) {
105
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 s = temp->name();
106
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if (s) {
107
2/2
✓ Branch 1 taken 39 times.
✓ Branch 4 taken 39 times.
39 idfObject.setString(openstudio::Fan_ConstantVolumeFields::AirOutletNodeName, *s);
108 }
109 }
110 ///
111 ////////////////////////////////////////////////////////////////////////
112
113 // End Use Subcategory
114
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 idfObject.setString(Fan_ConstantVolumeFields::EndUseSubcategory, modelObject.endUseSubcategory());
115
116
1/1
✓ Branch 1 taken 98 times.
98 m_idfObjects.push_back(idfObject);
117
1/1
✓ Branch 1 taken 98 times.
98 return idfObject;
118 98 }
119
120 } // namespace energyplus
121
122 } // namespace openstudio
123