Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : #ifndef ENERGYPLUS_PLANTLOOPHEATPUMPEIR_HH
49 : #define ENERGYPLUS_PLANTLOOPHEATPUMPEIR_HH
50 :
51 : // C++ headers
52 : #include <functional>
53 : #include <string>
54 : #include <vector>
55 :
56 : // EnergyPlus headers
57 : #include <EnergyPlus/Data/BaseData.hh>
58 : #include <EnergyPlus/Plant/PlantLocation.hh>
59 : #include <EnergyPlus/PlantComponent.hh>
60 : #include <EnergyPlus/WaterToWaterHeatPumps.hh>
61 :
62 : namespace EnergyPlus {
63 :
64 : // Forward declarations
65 : struct EnergyPlusData;
66 :
67 : namespace EIRPlantLoopHeatPumps {
68 :
69 : struct InOutNodePair
70 : {
71 : int inlet;
72 : int outlet;
73 :
74 8 : InOutNodePair() : inlet(0), outlet(0)
75 : {
76 8 : }
77 : };
78 :
79 6 : struct EIRPlantLoopHeatPump : public EnergyPlus::BasePlantLoopHeatPump
80 : {
81 :
82 : // fixed configuration parameters
83 : std::string name;
84 : DataPlant::PlantEquipmentType EIRHPType = DataPlant::PlantEquipmentType::Invalid;
85 : std::string companionCoilName;
86 : EIRPlantLoopHeatPump *companionHeatPumpCoil = nullptr;
87 : Real64 sizingFactor = 1.0;
88 : bool waterSource = false;
89 : bool airSource = false;
90 :
91 : // reference data
92 : Real64 referenceCapacity = 0.0;
93 : bool referenceCapacityWasAutoSized = false;
94 : Real64 referenceCOP = 0.0;
95 :
96 : // curve references
97 : int capFuncTempCurveIndex = 0;
98 : int powerRatioFuncTempCurveIndex = 0;
99 : int powerRatioFuncPLRCurveIndex = 0;
100 :
101 : // flow rate terms
102 : Real64 loadSideDesignVolFlowRate = 0.0;
103 : bool loadSideDesignVolFlowRateWasAutoSized = false;
104 : Real64 sourceSideDesignVolFlowRate = 0.0;
105 : bool sourceSideDesignVolFlowRateWasAutoSized = false;
106 : Real64 loadSideDesignMassFlowRate = 0.0;
107 : Real64 sourceSideDesignMassFlowRate = 0.0;
108 : Real64 loadSideMassFlowRate = 0.0;
109 : Real64 sourceSideMassFlowRate = 0.0;
110 :
111 : // simulation variables
112 : Real64 loadSideHeatTransfer = 0.0;
113 : Real64 sourceSideHeatTransfer = 0.0;
114 : Real64 loadSideInletTemp = 0.0;
115 : Real64 loadSideOutletTemp = 0.0;
116 : Real64 sourceSideInletTemp = 0.0;
117 : Real64 sourceSideOutletTemp = 0.0;
118 : Real64 powerUsage = 0.0;
119 : Real64 loadSideEnergy = 0.0;
120 : Real64 sourceSideEnergy = 0.0;
121 : Real64 powerEnergy = 0.0;
122 : bool running = false;
123 :
124 : // topology variables
125 : PlantLocation loadSidePlantLoc;
126 : PlantLocation sourceSidePlantLoc;
127 : InOutNodePair loadSideNodes;
128 : InOutNodePair sourceSideNodes;
129 :
130 : // counters and indexes
131 : int condMassFlowRateTriggerIndex = 0;
132 : int recurringConcurrentOperationWarningIndex = 0;
133 :
134 : // logic flags
135 : bool oneTimeInitFlag = true;
136 : bool envrnInit = true;
137 :
138 : // recurrent warning messages index integers
139 : int capModFTErrorIndex = 0;
140 : int eirModFTErrorIndex = 0;
141 : int eirModFPLRErrorIndex = 0;
142 :
143 : // a couple worker functions to easily allow merging of cooling and heating operations
144 : std::function<Real64(Real64, Real64)> calcLoadOutletTemp;
145 : std::function<Real64(Real64, Real64)> calcQsource;
146 : std::function<Real64(Real64, Real64)> calcSourceOutletTemp;
147 :
148 10 : virtual ~EIRPlantLoopHeatPump() = default;
149 :
150 4 : EIRPlantLoopHeatPump() = default;
151 :
152 : void
153 : simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override;
154 :
155 : void onInitLoopEquip([[maybe_unused]] EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation) override;
156 :
157 : void getDesignCapacities(EnergyPlusData &state,
158 : [[maybe_unused]] const PlantLocation &calledFromLocation,
159 : [[maybe_unused]] Real64 &MaxLoad,
160 : [[maybe_unused]] Real64 &MinLoad,
161 : [[maybe_unused]] Real64 &OptLoad) override;
162 :
163 : void doPhysics(EnergyPlusData &state, Real64 currentLoad);
164 :
165 : void sizeLoadSide(EnergyPlusData &state);
166 :
167 : void sizeSrcSideWSHP(EnergyPlusData &state);
168 :
169 : void sizeSrcSideASHP(EnergyPlusData &state);
170 :
171 : Real64 getLoadSideOutletSetPointTemp(EnergyPlusData &state) const;
172 :
173 : void setOperatingFlowRatesASHP(EnergyPlusData &state);
174 :
175 : void setOperatingFlowRatesWSHP(EnergyPlusData &state);
176 :
177 : void resetReportingVariables();
178 :
179 : static PlantComponent *factory(EnergyPlusData &state, DataPlant::PlantEquipmentType hp_type_of_num, const std::string &hp_name);
180 :
181 : static void pairUpCompanionCoils(EnergyPlusData &state);
182 :
183 : static void processInputForEIRPLHP(EnergyPlusData &state);
184 :
185 : static void checkConcurrentOperation(EnergyPlusData &state);
186 :
187 2418 : static Real64 add(Real64 const a, Real64 const b)
188 : {
189 2418 : return a + b;
190 : }
191 :
192 2406 : static Real64 subtract(Real64 const a, Real64 const b)
193 : {
194 2406 : return a - b;
195 : }
196 :
197 : void oneTimeInit(EnergyPlusData &state) override;
198 : };
199 :
200 : } // namespace EIRPlantLoopHeatPumps
201 :
202 1542 : struct EIRPlantLoopHeatPumpsData
203 : {
204 : std::vector<EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump> heatPumps;
205 : bool getInputsPLHP = true;
206 0 : void clear_state()
207 : {
208 0 : getInputsPLHP = true;
209 0 : heatPumps.clear();
210 0 : }
211 : };
212 :
213 : } // namespace EnergyPlus
214 :
215 : #endif // ENERGYPLUS_PLANTLOOPHEATPUMPEIR_HH
|