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 EconomicTariff_hh_INCLUDED
49 : #define EconomicTariff_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1A.hh>
53 : #include <ObjexxFCL/Array2D.hh>
54 :
55 : // EnergyPlus Headers
56 : #include <EnergyPlus/Data/BaseData.hh>
57 : #include <EnergyPlus/DataGlobals.hh>
58 : #include <EnergyPlus/EPVector.hh>
59 : #include <EnergyPlus/EnergyPlus.hh>
60 :
61 : namespace EnergyPlus {
62 :
63 : // Forward declarations
64 : struct EnergyPlusData;
65 :
66 : namespace EconomicTariff {
67 :
68 : enum class ObjType
69 : {
70 : Invalid = -1,
71 : Tariff,
72 : Qualify,
73 : ChargeSimple,
74 : ChargeBlock,
75 : Ratchet,
76 : Variable,
77 : Computation,
78 : Category,
79 : Native,
80 : AssignCompute,
81 : Num
82 : };
83 :
84 : enum class EconConv
85 : {
86 : Invalid = -1,
87 : USERDEF,
88 : KWH,
89 : THERM,
90 : MMBTU, // million btu
91 : MJ,
92 : KBTU,
93 : MCF, // thousand cubic feet
94 : CCF, // hundred cubic feet
95 : M3, // cubic meter
96 : GAL,
97 : KGAL, // thousand gallons
98 : Num
99 : };
100 :
101 282 : constexpr std::string_view convEneStrings(EconConv &e)
102 : {
103 282 : switch (e) {
104 106 : case EconConv::USERDEF:
105 106 : return "";
106 94 : case EconConv::KWH:
107 94 : return "kWh";
108 1 : case EconConv::THERM:
109 1 : return "Therm";
110 0 : case EconConv::MMBTU:
111 0 : return "MMBtu";
112 0 : case EconConv::MJ:
113 0 : return "MJ";
114 0 : case EconConv::KBTU:
115 0 : return "kBtu";
116 81 : case EconConv::MCF:
117 81 : return "MCF";
118 0 : case EconConv::CCF:
119 0 : return "CCF";
120 0 : case EconConv::M3:
121 0 : return "m3";
122 0 : case EconConv::GAL:
123 0 : return "gal";
124 0 : case EconConv::KGAL:
125 0 : return "kgal";
126 0 : default:
127 0 : assert(false);
128 : return "";
129 : }
130 : }
131 :
132 282 : constexpr std::string_view convDemStrings(EconConv &e)
133 : {
134 282 : switch (e) {
135 106 : case EconConv::USERDEF:
136 106 : return "";
137 94 : case EconConv::KWH:
138 94 : return "kW";
139 1 : case EconConv::THERM:
140 1 : return "Therm";
141 0 : case EconConv::MMBTU:
142 0 : return "MMBtu";
143 0 : case EconConv::MJ:
144 0 : return "MJ";
145 0 : case EconConv::KBTU:
146 0 : return "kBtu";
147 81 : case EconConv::MCF:
148 81 : return "MCF";
149 0 : case EconConv::CCF:
150 0 : return "CCF";
151 0 : case EconConv::M3:
152 0 : return "m3";
153 0 : case EconConv::GAL:
154 0 : return "gal";
155 0 : case EconConv::KGAL:
156 0 : return "kgal";
157 0 : default:
158 0 : assert(false);
159 : return "";
160 : }
161 : }
162 :
163 : enum class DemandWindow
164 : {
165 : Invalid = -1,
166 : Quarter,
167 : Half,
168 : Hour,
169 : Day,
170 : Week,
171 : Num
172 : };
173 :
174 188 : constexpr std::string_view demWindowStrings(DemandWindow &e)
175 : {
176 188 : switch (e) {
177 106 : case DemandWindow::Invalid:
178 106 : return "";
179 82 : case DemandWindow::Quarter:
180 : case DemandWindow::Half:
181 : case DemandWindow::Hour:
182 82 : return "/Hr";
183 0 : case DemandWindow::Day:
184 0 : return "/Day";
185 0 : case DemandWindow::Week:
186 0 : return "/Wk";
187 0 : default:
188 0 : assert(false);
189 : return "";
190 : }
191 : }
192 :
193 : int constexpr buyFromUtility(1);
194 : int constexpr sellToUtility(2);
195 : int constexpr netMetering(3);
196 :
197 : // For several different objects that reference seasons
198 : int constexpr seasonWinter(1);
199 : int constexpr seasonSpring(2);
200 : int constexpr seasonSummer(3);
201 : int constexpr seasonFall(4);
202 : int constexpr seasonAnnual(5);
203 : int constexpr seasonMonthly(6);
204 :
205 : // For AssignVariablePt
206 : int constexpr varIsArgument(1); // if used as a value or on right side of expression
207 : int constexpr varIsAssigned(2); // if variable is assigned to or on left side of expression
208 :
209 : // For ComputeSteps
210 : // All are negative because all variables are positive
211 : int constexpr opSUM(-1);
212 : int constexpr opMULTIPLY(-2);
213 : int constexpr opSUBTRACT(-3);
214 : int constexpr opDIVIDE(-4);
215 : int constexpr opABSOLUTE(-5);
216 : int constexpr opINTEGER(-6);
217 : int constexpr opSIGN(-7);
218 : int constexpr opROUND(-8);
219 : int constexpr opMAXIMUM(-9);
220 : int constexpr opMINIMUM(-10);
221 : int constexpr opEXCEEDS(-11);
222 : int constexpr opANNUALMINIMUM(-12);
223 : int constexpr opANNUALMAXIMUM(-13);
224 : int constexpr opANNUALSUM(-14);
225 : int constexpr opANNUALAVERAGE(-15);
226 : int constexpr opANNUALOR(-16);
227 : int constexpr opANNUALAND(-17);
228 : int constexpr opANNUALMAXIMUMZERO(-18);
229 : int constexpr opANNUALMINIMUMZERO(-19);
230 : int constexpr opIF(-20);
231 : int constexpr opGREATERTHAN(-21);
232 : int constexpr opGREATEREQUAL(-22);
233 : int constexpr opLESSTHAN(-23);
234 : int constexpr opLESSEQUAL(-24);
235 : int constexpr opEQUAL(-25);
236 : int constexpr opNOTEQUAL(-26);
237 : int constexpr opAND(-27);
238 : int constexpr opOR(-28);
239 : int constexpr opNOT(-29);
240 : int constexpr opADD(-30);
241 : int constexpr opNOOP(-31); // no operation - just list the operand variables - shown as FROM
242 :
243 : // not predefined variable (user defined name - many variables and all objects)
244 : // used in econvar%specific
245 : int constexpr varUserDefined(1);
246 : int constexpr varNotYetDefined(2);
247 :
248 : // category variables (used in econvar%specific)
249 : int constexpr catEnergyCharges(11);
250 : int constexpr catDemandCharges(12);
251 : int constexpr catServiceCharges(13);
252 : int constexpr catBasis(14);
253 : int constexpr catAdjustment(15);
254 : int constexpr catSurcharge(16);
255 : int constexpr catSubtotal(17);
256 : int constexpr catTaxes(18);
257 : int constexpr catTotal(19);
258 : int constexpr catNotIncluded(20);
259 :
260 : // native variables (based on energy and demands from the simulation) used in econvar%specific
261 : int constexpr nativeTotalEnergy(101);
262 : int constexpr nativeTotalDemand(102);
263 : int constexpr nativePeakEnergy(103);
264 : int constexpr nativePeakDemand(104);
265 : int constexpr nativeShoulderEnergy(105);
266 : int constexpr nativeShoulderDemand(106);
267 : int constexpr nativeOffPeakEnergy(107);
268 : int constexpr nativeOffPeakDemand(108);
269 : int constexpr nativeMidPeakEnergy(109);
270 : int constexpr nativeMidPeakDemand(110);
271 : int constexpr nativePeakExceedsOffPeak(111);
272 : int constexpr nativeOffPeakExceedsPeak(112);
273 : int constexpr nativePeakExceedsMidPeak(113);
274 : int constexpr nativeMidPeakExceedsPeak(114);
275 : int constexpr nativePeakExceedsShoulder(115);
276 : int constexpr nativeShoulderExceedsPeak(116);
277 : int constexpr nativeIsWinter(117);
278 : int constexpr nativeIsNotWinter(118);
279 : int constexpr nativeIsSpring(119);
280 : int constexpr nativeIsNotSpring(120);
281 : int constexpr nativeIsSummer(121);
282 : int constexpr nativeIsNotSummer(122);
283 : int constexpr nativeIsAutumn(123);
284 : int constexpr nativeIsNotAutumn(124);
285 :
286 : int constexpr nativePeakAndShoulderEnergy(125);
287 : int constexpr nativePeakAndShoulderDemand(126);
288 : int constexpr nativePeakAndMidPeakEnergy(127);
289 : int constexpr nativePeakAndMidPeakDemand(128);
290 : int constexpr nativeShoulderAndOffPeakEnergy(129);
291 : int constexpr nativeShoulderAndOffPeakDemand(130);
292 : int constexpr nativePeakAndOffPeakEnergy(131);
293 : int constexpr nativePeakAndOffPeakDemand(132);
294 :
295 : int constexpr nativeRealTimePriceCosts(133);
296 : int constexpr nativeAboveCustomerBaseCosts(134);
297 : int constexpr nativeBelowCustomerBaseCosts(135);
298 : int constexpr nativeAboveCustomerBaseEnergy(136);
299 : int constexpr nativeBelowCustomerBaseEnergy(137);
300 :
301 : int constexpr countPeriod(4);
302 : int constexpr MaxNumMonths(12);
303 : int constexpr maxNumBlk(15);
304 :
305 : int constexpr periodPeak(1);
306 : int constexpr periodShoulder(2);
307 : int constexpr periodOffPeak(3);
308 : int constexpr periodMidPeak(4);
309 :
310 : int constexpr kindMeterNotElectric(0); // must be zero because testing of >0 done later.
311 : int constexpr kindMeterElecSimple(1);
312 : int constexpr kindMeterElecProduced(2);
313 : int constexpr kindMeterElecPurchased(3);
314 : int constexpr kindMeterElecSurplusSold(4);
315 : int constexpr kindMeterElecNet(5);
316 :
317 : int constexpr kindMeterNotWater(0);
318 : int constexpr kindMeterWater(1);
319 :
320 : int constexpr kindMeterNotGas(0);
321 : int constexpr kindMeterGas(1);
322 :
323 : int constexpr varUnitTypeEnergy(1);
324 : int constexpr varUnitTypeDemand(2);
325 : int constexpr varUnitTypeDimensionless(3);
326 : int constexpr varUnitTypeCurrency(4);
327 :
328 : // Types
329 :
330 65596 : struct EconVarType
331 : {
332 : // Members
333 : std::string name; // name of the economics object or variable
334 : int tariffIndx; // index of the tariff name in the tariff array
335 : ObjType kindOfObj; // enumerated list for the kind of economics object
336 : int index; // pointer to item in specific array
337 : Array1D<Real64> values; // values
338 : // the following items are not part of the object description
339 : bool isArgument; // flag if the variable is ever used as an argument (value needed)
340 : bool isAssigned; // flag if the variable is ever assigned to
341 : int specific; // the specific type of variable - see enumerated lists
342 : // the following items are used in determinging the dependency relationship of variables
343 : // and consist of an operator and a list of variables.
344 : int cntMeDependOn; // count of items in depend this line depends upon
345 : int Operator; // operator used in equation (usually opSUM or opNOOP)
346 : int firstOperand; // first item in the operand array
347 : int lastOperand; // last item in the operand array
348 : bool activeNow; // flag if the econVar is used in the current tariff
349 : bool isEvaluated; // flag if the economics object that results in this variable
350 : // has already been evaulated
351 : bool isReported; // flag if the econVar has been reported in the output file
352 : int varUnitType; // variable unit type: energy, demand, dimensionless, currency
353 :
354 : // Default Constructor
355 196 : EconVarType()
356 196 : : tariffIndx(0), kindOfObj(ObjType::Invalid), index(0), values(MaxNumMonths, 0.0), isArgument(false), isAssigned(false), specific(0),
357 196 : cntMeDependOn(0), Operator(0), firstOperand(0), lastOperand(0), activeNow(false), isEvaluated(false), isReported(false), varUnitType(0)
358 : {
359 196 : }
360 : };
361 :
362 1345 : struct TariffType
363 : {
364 : // Members
365 : std::string tariffName; // name of the tariff
366 : std::string reportMeter; // name of the report meter
367 : int reportMeterIndx; // index of the report meter
368 : int kindElectricMtr; // kind of electric meter - see enumerated list above, 0 is not electric
369 : int kindWaterMtr; // kind of water meter - 0 (default) is not water, 1 is water
370 : int kindGasMtr; // kind of gas meter - 0 (default) is not gas, 1 is gas
371 : DataGlobalConstants::ResourceType resourceNum; // based on list of DataGlobalConstants
372 : EconConv convChoice; // enumerated choice index of the conversion factor
373 : Real64 energyConv; // energy conversion factor
374 : Real64 demandConv; // demand conversion factor
375 : std::string periodSchedule; // name of the period schedule (time of day)
376 : int periodSchIndex; // index to the period schedule
377 : std::string seasonSchedule; // name of the season schedule (winter/summer)
378 : int seasonSchIndex; // index to the season schedule
379 : std::string monthSchedule; // name of month schedule (when months end)
380 : int monthSchIndex; // index to the month schedule
381 : DemandWindow demandWindow; // enumerated list of the kind of demand window
382 : Real64 demWinTime; // length of time for the demand window
383 : Real64 monthChgVal; // monthly charge value
384 : int monthChgPt; // pointer to a variable that contains the monthly charge
385 : // if 0 then use monthChgVal
386 : Real64 minMonthChgVal; // minimum monthly charge value
387 : int minMonthChgPt; // pointer to a variable that contains the minimum monthly charge
388 : // if 0 then use minMonthChgVal
389 : std::string chargeSchedule; // name of the charge schedule (for real time pricing)
390 : int chargeSchIndex; // index to the charge schedule
391 : std::string baseUseSchedule; // name of the baseline use schedule (for real time pricing)
392 : int baseUseSchIndex; // index to the baseline use schedule
393 : std::string groupName; // name of the group
394 : std::string monetaryUnit; // text string representing monetary unit, usually $
395 : int buyOrSell; // enumerated choice index of the buy or sell options
396 : // index to the first and last category variables
397 : int firstCategory; // first category referenced
398 : int lastCategory; // last category referenced
399 : // pointers to econ variables for categories
400 : int ptEnergyCharges;
401 : int ptDemandCharges;
402 : int ptServiceCharges;
403 : int ptBasis;
404 : int ptAdjustment;
405 : int ptSurcharge;
406 : int ptSubtotal;
407 : int ptTaxes;
408 : int ptTotal;
409 : int ptNotIncluded;
410 : // index to the first and last native variables (energies and demands from the simulation)
411 : int firstNative;
412 : int lastNative;
413 : // native variables (based on energy and demands from the simulation)
414 : int nativeTotalEnergy;
415 : int nativeTotalDemand;
416 : int nativePeakEnergy;
417 : int nativePeakDemand;
418 : int nativeShoulderEnergy;
419 : int nativeShoulderDemand;
420 : int nativeOffPeakEnergy;
421 : int nativeOffPeakDemand;
422 : int nativeMidPeakEnergy;
423 : int nativeMidPeakDemand;
424 : int nativePeakExceedsOffPeak;
425 : int nativeOffPeakExceedsPeak;
426 : int nativePeakExceedsMidPeak;
427 : int nativeMidPeakExceedsPeak;
428 : int nativePeakExceedsShoulder;
429 : int nativeShoulderExceedsPeak;
430 : int nativeIsWinter;
431 : int nativeIsNotWinter;
432 : int nativeIsSpring;
433 : int nativeIsNotSpring;
434 : int nativeIsSummer;
435 : int nativeIsNotSummer;
436 : int nativeIsAutumn;
437 : int nativeIsNotAutumn;
438 : int nativePeakAndShoulderEnergy;
439 : int nativePeakAndShoulderDemand;
440 : int nativePeakAndMidPeakEnergy;
441 : int nativePeakAndMidPeakDemand;
442 : int nativeShoulderAndOffPeakEnergy;
443 : int nativeShoulderAndOffPeakDemand;
444 : int nativePeakAndOffPeakEnergy;
445 : int nativePeakAndOffPeakDemand;
446 : // real time pricing native variable pointers
447 : int nativeRealTimePriceCosts;
448 : int nativeAboveCustomerBaseCosts;
449 : int nativeBelowCustomerBaseCosts;
450 : int nativeAboveCustomerBaseEnergy;
451 : int nativeBelowCustomerBaseEnergy;
452 : // arrays for holding gathered values
453 : Array2D<Real64> gatherEnergy;
454 : Array2D<Real64> gatherDemand;
455 : Real64 collectTime;
456 : Real64 collectEnergy;
457 : // arryas for holding real time pricing gathered values
458 : Array1D<Real64> RTPcost;
459 : Array1D<Real64> RTPaboveBaseCost;
460 : Array1D<Real64> RTPbelowBaseCost;
461 : Array1D<Real64> RTPaboveBaseEnergy;
462 : Array1D<Real64> RTPbelowBaseEnergy;
463 : Array1D_int seasonForMonth;
464 : // overall qualification of the rate
465 : bool isQualified;
466 : int ptDisqualifier;
467 : // overall selection and annual cost
468 : bool isSelected;
469 : Real64 totalAnnualCost;
470 : Real64 totalAnnualEnergy;
471 :
472 : // Default Constructor
473 1057 : TariffType()
474 1057 : : reportMeterIndx(0), kindElectricMtr(0), kindWaterMtr(0), kindGasMtr(0), resourceNum(DataGlobalConstants::ResourceType::None),
475 : convChoice(EconConv::USERDEF), energyConv(0.0), demandConv(0.0), periodSchIndex(0), seasonSchIndex(0), monthSchIndex(0),
476 : demandWindow(DemandWindow::Invalid), demWinTime(0.0), monthChgVal(0.0), monthChgPt(0), minMonthChgVal(0.0), minMonthChgPt(0),
477 : chargeSchIndex(0), baseUseSchIndex(0), buyOrSell(0), firstCategory(0), lastCategory(0), ptEnergyCharges(0), ptDemandCharges(0),
478 : ptServiceCharges(0), ptBasis(0), ptAdjustment(0), ptSurcharge(0), ptSubtotal(0), ptTaxes(0), ptTotal(0), ptNotIncluded(0),
479 : firstNative(0), lastNative(0), nativeTotalEnergy(0), nativeTotalDemand(0), nativePeakEnergy(0), nativePeakDemand(0),
480 : nativeShoulderEnergy(0), nativeShoulderDemand(0), nativeOffPeakEnergy(0), nativeOffPeakDemand(0), nativeMidPeakEnergy(0),
481 : nativeMidPeakDemand(0), nativePeakExceedsOffPeak(0), nativeOffPeakExceedsPeak(0), nativePeakExceedsMidPeak(0),
482 : nativeMidPeakExceedsPeak(0), nativePeakExceedsShoulder(0), nativeShoulderExceedsPeak(0), nativeIsWinter(0), nativeIsNotWinter(0),
483 : nativeIsSpring(0), nativeIsNotSpring(0), nativeIsSummer(0), nativeIsNotSummer(0), nativeIsAutumn(0), nativeIsNotAutumn(0),
484 : nativePeakAndShoulderEnergy(0), nativePeakAndShoulderDemand(0), nativePeakAndMidPeakEnergy(0), nativePeakAndMidPeakDemand(0),
485 : nativeShoulderAndOffPeakEnergy(0), nativeShoulderAndOffPeakDemand(0), nativePeakAndOffPeakEnergy(0), nativePeakAndOffPeakDemand(0),
486 : nativeRealTimePriceCosts(0), nativeAboveCustomerBaseCosts(0), nativeBelowCustomerBaseCosts(0), nativeAboveCustomerBaseEnergy(0),
487 : nativeBelowCustomerBaseEnergy(0), gatherEnergy(MaxNumMonths, countPeriod, 0.0), gatherDemand(MaxNumMonths, countPeriod, 0.0),
488 : collectTime(0.0), collectEnergy(0.0), RTPcost(MaxNumMonths, 0.0), RTPaboveBaseCost(MaxNumMonths, 0.0),
489 : RTPbelowBaseCost(MaxNumMonths, 0.0), RTPaboveBaseEnergy(MaxNumMonths, 0.0), RTPbelowBaseEnergy(MaxNumMonths, 0.0),
490 1057 : seasonForMonth(MaxNumMonths, 0), isQualified(false), ptDisqualifier(0), isSelected(false), totalAnnualCost(0.0), totalAnnualEnergy(0.0)
491 : {
492 1057 : }
493 : };
494 :
495 : struct QualifyType
496 : {
497 : // Members
498 : int namePt; // index of the name and variable in the variable array
499 : int tariffIndx; // index of the tariff name in the tariff array
500 : int sourcePt; // index of the variable in the variable array
501 : bool isMaximum; // indicator if maximum test otherwise minimum
502 : Real64 thresholdVal; // value of the threshold
503 : int thresholdPt; // pointer to the variable holding the values
504 : int season; // enumerated list of the kind of season
505 : bool isConsecutive; // indicator if consecutive months otherwise count
506 : int numberOfMonths; // number of months the test must be good for
507 :
508 : // Default Constructor
509 304 : QualifyType()
510 304 : : namePt(0), tariffIndx(0), sourcePt(0), isMaximum(false), thresholdVal(0.0), thresholdPt(0), season(0), isConsecutive(false),
511 304 : numberOfMonths(0)
512 : {
513 304 : }
514 : };
515 :
516 : struct ChargeSimpleType
517 : {
518 : // Members
519 : int namePt; // index of the name and variable in the variable array
520 : int tariffIndx; // index of the tariff name in the tariff array
521 : int sourcePt; // index of the variable in the variable array
522 : int season; // enumerated list of the kind of season
523 : int categoryPt; // index of the category in the variable array
524 : Real64 costPerVal; // cost per unit value
525 : int costPerPt; // cost per unit index in the variable array (0 is flag for no variable)
526 :
527 : // Default Constructor
528 1648 : ChargeSimpleType() : namePt(0), tariffIndx(0), sourcePt(0), season(0), categoryPt(0), costPerVal(0.0), costPerPt(0)
529 : {
530 1648 : }
531 : };
532 :
533 635 : struct ChargeBlockType
534 : {
535 : // Members
536 : int namePt; // index of the name and variable in the variable array
537 : int tariffIndx; // index of the tariff name in the tariff array
538 : int sourcePt; // index of the variable in the variable array
539 : int season; // enumerated list of the kind of season
540 : int categoryPt; // index of the category in the variable array
541 : int remainingPt; // index of the remaining into variable in the variable array
542 : Real64 blkSzMultVal; // block size multiplier value
543 : int blkSzMultPt; // block size variable in the variable array (0 is flag for no variable)
544 : int numBlk; // number of blocks used
545 : Array1D<Real64> blkSzVal; // array of block size values
546 : Array1D_int blkSzPt; // block size variables index to the variable array (0 is no variable)
547 : Array1D<Real64> blkCostVal; // array of block cost values
548 : Array1D_int blkCostPt; // block cost variables index to the variable array (0 is no variable)
549 :
550 : // Default Constructor
551 365 : ChargeBlockType()
552 365 : : namePt(0), tariffIndx(0), sourcePt(0), season(0), categoryPt(0), remainingPt(0), blkSzMultVal(0.0), blkSzMultPt(0), numBlk(0),
553 365 : blkSzVal(maxNumBlk, 0.0), blkSzPt(maxNumBlk, 0), blkCostVal(maxNumBlk, 0.0), blkCostPt(maxNumBlk, 0)
554 : {
555 365 : }
556 : };
557 :
558 : struct RatchetType
559 : {
560 : // Members
561 : int namePt; // index of the name and variable in the variable array
562 : int tariffIndx; // index of the tariff name in the tariff array
563 : int baselinePt; // index of the baseline variable in the variable array
564 : int adjustmentPt; // index fo the adjustment variable in the variable array
565 : int seasonFrom; // enumerated list of the kind of season
566 : int seasonTo; // enumerated list of the kind of season
567 : Real64 multiplierVal; // value of the ratchet multiplier
568 : int multiplierPt; // multiplier variable in the variable array (0 for no variable)
569 : Real64 offsetVal; // value of the ratchet offset
570 : int offsetPt; // offset variable in the variable array (0 for no variable)
571 :
572 : // Default Constructor
573 96 : RatchetType()
574 96 : : namePt(0), tariffIndx(0), baselinePt(0), adjustmentPt(0), seasonFrom(0), seasonTo(0), multiplierVal(0.0), multiplierPt(0),
575 96 : offsetVal(0.0), offsetPt(0)
576 : {
577 96 : }
578 : };
579 :
580 671 : struct ComputationType
581 : {
582 : // Members
583 : std::string computeName; // name of the compute
584 : int firstStep; // index to steps array for the first step in this compute steps
585 : int lastStep; // index to steps array for the last step in this compute steps
586 : bool isUserDef; // if the computation steps were user defined
587 :
588 : // Default Constructor
589 383 : ComputationType() : firstStep(0), lastStep(0), isUserDef(false)
590 : {
591 383 : }
592 : };
593 :
594 9494 : struct StackType
595 : {
596 : // Members
597 : int varPt; // pointer to item in specific array
598 : Array1D<Real64> values; // values
599 :
600 : // Default Constructor
601 94 : StackType() : varPt(0), values(MaxNumMonths, 0.0)
602 : {
603 94 : }
604 : };
605 :
606 : void UpdateUtilityBills(EnergyPlusData &state);
607 :
608 : //======================================================================================================================
609 : //======================================================================================================================
610 :
611 : // GET INPUT ROUTINES
612 :
613 : //======================================================================================================================
614 : //======================================================================================================================
615 :
616 : void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
617 :
618 : void GetInputEconomicsQualify(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
619 :
620 : void GetInputEconomicsChargeSimple(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
621 :
622 : void GetInputEconomicsChargeBlock(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
623 :
624 : void GetInputEconomicsRatchet(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
625 :
626 : void GetInputEconomicsVariable(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
627 :
628 : void GetInputEconomicsComputation(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
629 :
630 : void GetInputEconomicsCurrencyType(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
631 :
632 : void parseComputeLine(EnergyPlusData &state, std::string const &lineOfCompute, int const fromTariff);
633 :
634 : void GetLastWord(std::string const &lineOfText, std::string::size_type &endOfScan, std::string &aWord);
635 :
636 : void initializeMonetaryUnit(EnergyPlusData &state);
637 :
638 : int LookUpSeason(EnergyPlusData &state, std::string const &nameOfSeason, std::string const &nameOfReferingObj);
639 :
640 : int FindTariffIndex(EnergyPlusData &state,
641 : std::string const &nameOfTariff,
642 : std::string const &nameOfReferingObj,
643 : bool &ErrorsFound,
644 : std::string const &nameOfCurObj);
645 :
646 : void warnIfNativeVarname(
647 : EnergyPlusData &state, std::string const &objName, int const curTariffIndex, bool &ErrorsFound, std::string const &curobjName);
648 :
649 : int AssignVariablePt(EnergyPlusData &state,
650 : std::string const &stringIn,
651 : bool const flagIfNotNumeric,
652 : int const useOfVar,
653 : int const varSpecific,
654 : ObjType const econObjKind,
655 : int const objIndex,
656 : int const tariffPt);
657 :
658 : void incrementEconVar(EnergyPlusData &state);
659 :
660 : void incrementSteps(EnergyPlusData &state);
661 :
662 : std::string RemoveSpaces(EnergyPlusData &state, std::string const &StringIn);
663 :
664 : void CreateCategoryNativeVariables(EnergyPlusData &state);
665 :
666 : int lookupOperator(std::string const &opString);
667 :
668 : //======================================================================================================================
669 : //======================================================================================================================
670 :
671 : // DEFAULT COMPUTATION RELATED ROUTINES
672 :
673 : //======================================================================================================================
674 : //======================================================================================================================
675 :
676 : void CreateDefaultComputation(EnergyPlusData &state);
677 :
678 : void addOperand(EnergyPlusData &state, int varMe, int varOperand);
679 :
680 : void addChargesToOperand(EnergyPlusData &state, int curTariff, int curPointer);
681 :
682 : //======================================================================================================================
683 : //======================================================================================================================
684 :
685 : // GATHER TIMESTEP VALUES ROUTINE
686 :
687 : //======================================================================================================================
688 : //======================================================================================================================
689 :
690 : void GatherForEconomics(EnergyPlusData &state);
691 :
692 : bool isWithinRange(EnergyPlusData &state, int const testVal, int const minThreshold, int const maxThreshold);
693 :
694 : //======================================================================================================================
695 : //======================================================================================================================
696 :
697 : // COMPUTE THE UTILITY BILLS AND CREATE REPORTS
698 :
699 : //======================================================================================================================
700 : //======================================================================================================================
701 :
702 : void ComputeTariff(EnergyPlusData &state);
703 :
704 : void pushStack(EnergyPlusData &state, Array1A<Real64> const monthlyArray, int const variablePointer);
705 :
706 : void popStack(EnergyPlusData &state, Array1A<Real64> monthlyArray, int &variablePointer);
707 :
708 : void evaluateChargeSimple(EnergyPlusData &state, int const usingVariable);
709 :
710 : void evaluateChargeBlock(EnergyPlusData &state, int const usingVariable);
711 :
712 : void evaluateRatchet(EnergyPlusData &state, int const usingVariable);
713 :
714 : void evaluateQualify(EnergyPlusData &state, int const usingVariable);
715 :
716 : void addMonthlyCharge(EnergyPlusData &state, int const usingVariable);
717 :
718 : void checkMinimumMonthlyCharge(EnergyPlusData &state, int const curTariff);
719 :
720 : void setNativeVariables(EnergyPlusData &state);
721 :
722 : void LEEDtariffReporting(EnergyPlusData &state);
723 :
724 : void WriteTabularTariffReports(EnergyPlusData &state);
725 :
726 : void showWarningsBasedOnTotal(EnergyPlusData &state);
727 :
728 : void getMaxAndSum(EnergyPlusData &state, int const varPointer, Real64 &sumResult, Real64 &maxResult);
729 :
730 : void ReportEconomicVariable(EnergyPlusData &state,
731 : std::string const &titleString,
732 : bool const includeCategory,
733 : bool const showCurrencySymbol,
734 : std::string const &forString);
735 :
736 : void selectTariff(EnergyPlusData &state);
737 :
738 : void GetMonthlyCostForResource(EnergyPlusData &state, DataGlobalConstants::ResourceType const inResourceNumber, Array1A<Real64> outMonthlyCosts);
739 :
740 : } // namespace EconomicTariff
741 :
742 1542 : struct EconomicTariffData : BaseGlobalStruct
743 : {
744 :
745 : int numEconVar = 0;
746 : int sizeEconVar = 0;
747 :
748 : // holds the outbound connections for each variable
749 : Array1D_int operand; // sized to sizeOperand
750 : int numOperand = 0;
751 : int sizeOperand = 0;
752 :
753 : int numTariff = 0;
754 : int numQualify = 0;
755 : int numChargeSimple = 0;
756 : int numChargeBlock = 0;
757 : int numRatchet = 0;
758 : int numComputation = 0;
759 :
760 : // list of pointers to variable, 0 end of line, negative indicate operations
761 : Array1D_int steps;
762 : Array1D_int stepsCopy;
763 : int numSteps = 0;
764 : int sizeSteps = 0;
765 :
766 : int topOfStack = 0;
767 : int sizeStack = 0;
768 :
769 : bool Update_GetInput = true;
770 : int addOperand_prevVarMe = 0;
771 :
772 : Array1D<EconomicTariff::EconVarType> econVar;
773 : EPVector<EconomicTariff::TariffType> tariff;
774 : EPVector<EconomicTariff::QualifyType> qualify;
775 : EPVector<EconomicTariff::ChargeSimpleType> chargeSimple;
776 : EPVector<EconomicTariff::ChargeBlockType> chargeBlock;
777 : EPVector<EconomicTariff::RatchetType> ratchet;
778 : EPVector<EconomicTariff::ComputationType> computation;
779 : Array1D<EconomicTariff::StackType> stack;
780 :
781 0 : void clear_state() override
782 : {
783 0 : this->numEconVar = 0;
784 0 : this->sizeEconVar = 0;
785 0 : this->operand.deallocate();
786 0 : this->numOperand = 0;
787 0 : this->sizeOperand = 0;
788 0 : this->numTariff = 0;
789 0 : this->numQualify = 0;
790 0 : this->numChargeSimple = 0;
791 0 : this->numChargeBlock = 0;
792 0 : this->numRatchet = 0;
793 0 : this->numComputation = 0;
794 0 : this->steps.deallocate();
795 0 : this->stepsCopy.deallocate();
796 0 : this->numSteps = 0;
797 0 : this->sizeSteps = 0;
798 0 : this->topOfStack = 0;
799 0 : this->sizeStack = 0;
800 0 : this->Update_GetInput = true;
801 0 : this->addOperand_prevVarMe = 0;
802 0 : this->econVar.deallocate();
803 0 : this->tariff.deallocate();
804 0 : this->qualify.deallocate();
805 0 : this->chargeSimple.deallocate();
806 0 : this->chargeBlock.deallocate();
807 0 : this->ratchet.deallocate();
808 0 : this->computation.deallocate();
809 0 : this->stack.deallocate();
810 0 : }
811 : };
812 :
813 : } // namespace EnergyPlus
814 :
815 : #endif
|