Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2025, 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 : #include <EnergyPlus/ScheduleManager.hh>
61 :
62 : namespace EnergyPlus {
63 :
64 : // Forward declarations
65 : struct EnergyPlusData;
66 :
67 : namespace EconomicTariff {
68 :
69 : enum class ObjType
70 : {
71 : Invalid = -1,
72 : Tariff,
73 : Qualify,
74 : ChargeSimple,
75 : ChargeBlock,
76 : Ratchet,
77 : Variable,
78 : Computation,
79 : Category,
80 : Native,
81 : AssignCompute,
82 : Num
83 : };
84 :
85 : enum class EconConv
86 : {
87 : Invalid = -1,
88 : USERDEF,
89 : KWH,
90 : THERM,
91 : MMBTU, // million btu
92 : MJ,
93 : KBTU,
94 : MCF, // thousand cubic feet
95 : CCF, // hundred cubic feet
96 : M3, // cubic meter
97 : GAL,
98 : KGAL, // thousand gallons
99 : Num
100 : };
101 :
102 : enum class DemandWindow
103 : {
104 : Invalid = -1,
105 : Quarter,
106 : Half,
107 : Hour,
108 : Day,
109 : Week,
110 : Num
111 : };
112 :
113 : enum class BuySell
114 : {
115 : Invalid = -1,
116 : BuyFromUtility,
117 : SellToUtility,
118 : NetMetering,
119 : Num
120 : };
121 :
122 : // For several different objects that reference seasons
123 : enum class Season
124 : {
125 : Invalid = -1,
126 : Unused, // Can't use 0 because these things appear in schedules
127 : Winter,
128 : Spring,
129 : Summer,
130 : Fall,
131 : Annual,
132 : Monthly,
133 : Num
134 : };
135 :
136 : // For AssignVariablePt
137 : int constexpr varIsArgument(1); // if used as a value or on right side of expression
138 : int constexpr varIsAssigned(2); // if variable is assigned to or on left side of expression
139 :
140 : // For ComputeSteps
141 : // All are negative because all variables are positive
142 : enum class Op
143 : {
144 : Invalid = -1,
145 : SUM,
146 : MULTIPLY,
147 : SUBTRACT,
148 : DIVIDE,
149 : ABSOLUTEVALUE,
150 : INTEGER,
151 : SIGN,
152 : ROUND,
153 : MAXIMUM,
154 : MINIMUM,
155 : EXCEEDS,
156 : ANNUALMINIMUM,
157 : ANNUALMAXIMUM,
158 : ANNUALSUM,
159 : ANNUALAVERAGE,
160 : ANNUALOR,
161 : ANNUALAND,
162 : ANNUALMAXIMUMZERO,
163 : ANNUALMINIMUMZERO,
164 : IF,
165 : GREATERTHAN,
166 : GREATEREQUAL,
167 : LESSTHAN,
168 : LESSEQUAL,
169 : EQUAL,
170 : NOTEQUAL,
171 : AND,
172 : OR,
173 : NOT,
174 : ADD,
175 : NOOP,
176 : Num
177 : };
178 :
179 : // not predefined variable (user defined name - many variables and all objects)
180 : // used in econvar%specific
181 : int constexpr varUserDefined(-1);
182 : int constexpr varNotYetDefined(-2);
183 :
184 : enum class Cat
185 : {
186 : Invalid = -1,
187 : EnergyCharges,
188 : DemandCharges,
189 : ServiceCharges,
190 : Basis,
191 : Adjustment,
192 : Surcharge,
193 : Subtotal,
194 : Taxes,
195 : Total,
196 : NotIncluded,
197 : Num
198 : };
199 :
200 : enum class Native
201 : {
202 : Invalid = -1,
203 : TotalEnergy,
204 : TotalDemand,
205 : PeakEnergy,
206 : PeakDemand,
207 : ShoulderEnergy,
208 : ShoulderDemand,
209 : OffPeakEnergy,
210 : OffPeakDemand,
211 : MidPeakEnergy,
212 : MidPeakDemand,
213 : PeakExceedsOffPeak,
214 : OffPeakExceedsPeak,
215 : PeakExceedsMidPeak,
216 : MidPeakExceedsPeak,
217 : PeakExceedsShoulder,
218 : ShoulderExceedsPeak,
219 : IsWinter,
220 : IsNotWinter,
221 : IsSpring,
222 : IsNotSpring,
223 : IsSummer,
224 : IsNotSummer,
225 : IsAutumn,
226 : IsNotAutumn,
227 : PeakAndShoulderEnergy,
228 : PeakAndShoulderDemand,
229 : PeakAndMidPeakEnergy,
230 : PeakAndMidPeakDemand,
231 : ShoulderAndOffPeakEnergy,
232 : ShoulderAndOffPeakDemand,
233 : PeakAndOffPeakEnergy,
234 : PeakAndOffPeakDemand,
235 : RealTimePriceCosts,
236 : AboveCustomerBaseCosts,
237 : BelowCustomerBaseCosts,
238 : AboveCustomerBaseEnergy,
239 : BelowCustomerBaseEnergy,
240 : Num
241 : };
242 :
243 : int constexpr NumMonths(12);
244 : int constexpr maxNumBlk(15);
245 :
246 : enum class Period
247 : {
248 : Invalid = -1,
249 : Unused, // Can't use 0 because these things appear in schedules
250 : Peak,
251 : Shoulder,
252 : OffPeak,
253 : MidPeak,
254 : Num
255 : };
256 :
257 : enum class MeterType
258 : {
259 : Invalid = -1,
260 : ElecSimple,
261 : ElecProduced,
262 : ElecPurchased,
263 : ElecSurplusSold,
264 : ElecNet,
265 : Water,
266 : Gas,
267 : Other,
268 : Num
269 : };
270 :
271 : enum class VarUnitType
272 : {
273 : Invalid = -1,
274 : Energy,
275 : Demand,
276 : Dimensionless,
277 : Currency,
278 : Num
279 : };
280 :
281 : // Types
282 :
283 : struct EconVarType
284 : {
285 : // Members
286 : std::string name; // name of the economics object or variable
287 : int tariffIndx; // index of the tariff name in the tariff array
288 : ObjType kindOfObj; // enumerated list for the kind of economics object
289 : int index; // pointer to item in specific array
290 : Array1D<Real64> values; // values
291 : // the following items are not part of the object description
292 : bool isArgument; // flag if the variable is ever used as an argument (value needed)
293 : bool isAssigned; // flag if the variable is ever assigned to
294 : int specific; // the specific type of variable - see enumerated lists
295 : // the following items are used in determinging the dependency relationship of variables
296 : // and consist of an operator and a list of variables.
297 : int cntMeDependOn; // count of items in depend this line depends upon
298 : Op Operator = Op::Invalid; // operator used in equation (usually opSUM or opNOOP)
299 : int firstOperand; // first item in the operand array
300 : int lastOperand; // last item in the operand array
301 : bool activeNow; // flag if the econVar is used in the current tariff
302 : bool isEvaluated; // flag if the economics object that results in this variable
303 : // has already been evaulated
304 : bool isReported; // flag if the econVar has been reported in the output file
305 : VarUnitType varUnitType = VarUnitType::Invalid; // variable unit type: energy, demand, dimensionless, currency
306 :
307 : // Default Constructor
308 1129 : EconVarType()
309 1129 : : tariffIndx(0), kindOfObj(ObjType::Invalid), index(0), values(NumMonths, 0.0), isArgument(false), isAssigned(false), specific(0),
310 1129 : cntMeDependOn(0), firstOperand(0), lastOperand(0), activeNow(false), isEvaluated(false), isReported(false)
311 : {
312 1129 : }
313 : };
314 :
315 : struct TariffType
316 : {
317 : // Members
318 : std::string tariffName; // name of the tariff
319 : std::string reportMeter; // name of the report meter
320 : int reportMeterIndx; // index of the report meter
321 : MeterType kindMtr = MeterType::Invalid; // kind of electric meter - see enumerated list above, 0 is not electric
322 : Constant::eResource resource = Constant::eResource::Invalid; // based on list of DataGlobalConstants
323 : EconConv convChoice; // enumerated choice index of the conversion factor
324 : Real64 energyConv; // energy conversion factor
325 : Real64 demandConv; // demand conversion factor
326 : Sched::Schedule *periodSched = nullptr; // period schedule
327 : Sched::Schedule *seasonSched = nullptr; // season schedule
328 : Sched::Schedule *monthSched = nullptr; // month schedule
329 : DemandWindow demandWindow; // enumerated list of the kind of demand window
330 : Real64 demWinTime; // length of time for the demand window
331 : Real64 monthChgVal; // monthly charge value
332 : int monthChgPt; // pointer to a variable that contains the monthly charge
333 : // if 0 then use monthChgVal
334 : Real64 minMonthChgVal; // minimum monthly charge value
335 : int minMonthChgPt; // pointer to a variable that contains the minimum monthly charge
336 : // if 0 then use minMonthChgVal
337 : Sched::Schedule *chargeSched = nullptr; // index to the charge schedule
338 : Sched::Schedule *baseUseSched = nullptr; // index to the baseline use schedule
339 : std::string groupName; // name of the group
340 : std::string monetaryUnit; // text string representing monetary unit, usually $
341 : BuySell buyOrSell; // enumerated choice index of the buy or sell options
342 : // index to the first and last category variables
343 : int firstCategory; // first category referenced
344 : int lastCategory; // last category referenced
345 : // pointers to econ variables for categories
346 : std::array<int, (int)Cat::Num> cats;
347 : // index to the first and last native variables (energies and demands from the simulation)
348 : int firstNative;
349 : int lastNative;
350 : // native variables (based on energy and demands from the simulation)
351 : std::array<int, (int)Native::Num> natives = {0};
352 : // arrays for holding gathered values
353 : Array1D<std::array<Real64, (int)Period::Num>> gatherEnergy;
354 : Array1D<std::array<Real64, (int)Period::Num>> gatherDemand;
355 : Real64 collectTime;
356 : Real64 collectEnergy;
357 : // arryas for holding real time pricing gathered values
358 : Array1D<Real64> RTPcost;
359 : Array1D<Real64> RTPaboveBaseCost;
360 : Array1D<Real64> RTPbelowBaseCost;
361 : Array1D<Real64> RTPaboveBaseEnergy;
362 : Array1D<Real64> RTPbelowBaseEnergy;
363 : Array1D<Season> seasonForMonth;
364 : // overall qualification of the rate
365 : bool isQualified;
366 : int ptDisqualifier;
367 : // overall selection and annual cost
368 : bool isSelected;
369 : Real64 totalAnnualCost;
370 : Real64 totalAnnualEnergy;
371 :
372 : // Default Constructor
373 122 : TariffType()
374 244 : : reportMeterIndx(0), convChoice(EconConv::USERDEF), energyConv(0.0), demandConv(0.0), demandWindow(DemandWindow::Invalid),
375 244 : demWinTime(0.0), monthChgVal(0.0), monthChgPt(0), minMonthChgVal(0.0), minMonthChgPt(0), firstCategory(0), lastCategory(0),
376 122 : firstNative(0), lastNative(0), gatherEnergy(NumMonths, {0.0, 0.0, 0.0, 0.0}), gatherDemand(NumMonths, {0.0, 0.0, 0.0, 0.0}),
377 122 : collectTime(0.0), collectEnergy(0.0), RTPcost(NumMonths, 0.0), RTPaboveBaseCost(NumMonths, 0.0), RTPbelowBaseCost(NumMonths, 0.0),
378 122 : RTPaboveBaseEnergy(NumMonths, 0.0), RTPbelowBaseEnergy(NumMonths, 0.0), seasonForMonth(NumMonths, Season::Invalid), isQualified(false),
379 122 : ptDisqualifier(0), isSelected(false), totalAnnualCost(0.0), totalAnnualEnergy(0.0)
380 : {
381 122 : }
382 : };
383 :
384 : struct QualifyType
385 : {
386 : // Members
387 : int namePt; // index of the name and variable in the variable array
388 : int tariffIndx; // index of the tariff name in the tariff array
389 : int sourcePt; // index of the variable in the variable array
390 : bool isMaximum; // indicator if maximum test otherwise minimum
391 : Real64 thresholdVal; // value of the threshold
392 : int thresholdPt; // pointer to the variable holding the values
393 : Season season; // enumerated list of the kind of season
394 : bool isConsecutive; // indicator if consecutive months otherwise count
395 : int numberOfMonths; // number of months the test must be good for
396 :
397 : // Default Constructor
398 8 : QualifyType()
399 8 : : namePt(0), tariffIndx(0), sourcePt(0), isMaximum(false), thresholdVal(0.0), thresholdPt(0), isConsecutive(false), numberOfMonths(0)
400 : {
401 8 : }
402 : };
403 :
404 : struct ChargeSimpleType
405 : {
406 : // Members
407 : int namePt; // index of the name and variable in the variable array
408 : int tariffIndx; // index of the tariff name in the tariff array
409 : int sourcePt; // index of the variable in the variable array
410 : Season season = Season::Invalid; // enumerated list of the kind of season
411 : int categoryPt; // index of the category in the variable array
412 : Real64 costPerVal; // cost per unit value
413 : int costPerPt; // cost per unit index in the variable array (0 is flag for no variable)
414 :
415 : // Default Constructor
416 19 : ChargeSimpleType() : namePt(0), tariffIndx(0), sourcePt(0), categoryPt(0), costPerVal(0.0), costPerPt(0)
417 : {
418 19 : }
419 : };
420 :
421 : struct ChargeBlockType
422 : {
423 : // Members
424 : int namePt; // index of the name and variable in the variable array
425 : int tariffIndx; // index of the tariff name in the tariff array
426 : int sourcePt; // index of the variable in the variable array
427 : Season season = Season::Invalid; // enumerated list of the kind of season
428 : int categoryPt; // index of the category in the variable array
429 : int remainingPt; // index of the remaining into variable in the variable array
430 : Real64 blkSzMultVal; // block size multiplier value
431 : int blkSzMultPt; // block size variable in the variable array (0 is flag for no variable)
432 : int numBlk; // number of blocks used
433 : Array1D<Real64> blkSzVal; // array of block size values
434 : Array1D_int blkSzPt; // block size variables index to the variable array (0 is no variable)
435 : Array1D<Real64> blkCostVal; // array of block cost values
436 : Array1D_int blkCostPt; // block cost variables index to the variable array (0 is no variable)
437 :
438 : // Default Constructor
439 14 : ChargeBlockType()
440 14 : : namePt(0), tariffIndx(0), sourcePt(0), categoryPt(0), remainingPt(0), blkSzMultVal(0.0), blkSzMultPt(0), numBlk(0),
441 14 : blkSzVal(maxNumBlk, 0.0), blkSzPt(maxNumBlk, 0), blkCostVal(maxNumBlk, 0.0), blkCostPt(maxNumBlk, 0)
442 : {
443 14 : }
444 : };
445 :
446 : struct RatchetType
447 : {
448 : // Members
449 : int namePt; // index of the name and variable in the variable array
450 : int tariffIndx; // index of the tariff name in the tariff array
451 : int baselinePt; // index of the baseline variable in the variable array
452 : int adjustmentPt; // index fo the adjustment variable in the variable array
453 : Season seasonFrom = Season::Invalid; // enumerated list of the kind of season
454 : Season seasonTo = Season::Invalid; // enumerated list of the kind of season
455 : Real64 multiplierVal; // value of the ratchet multiplier
456 : int multiplierPt; // multiplier variable in the variable array (0 for no variable)
457 : Real64 offsetVal; // value of the ratchet offset
458 : int offsetPt; // offset variable in the variable array (0 for no variable)
459 :
460 : // Default Constructor
461 8 : RatchetType() : namePt(0), tariffIndx(0), baselinePt(0), adjustmentPt(0), multiplierVal(0.0), multiplierPt(0), offsetVal(0.0), offsetPt(0)
462 : {
463 8 : }
464 : };
465 :
466 : struct ComputationType
467 : {
468 : // Members
469 : std::string computeName; // name of the compute
470 : int firstStep; // index to steps array for the first step in this compute steps
471 : int lastStep; // index to steps array for the last step in this compute steps
472 : bool isUserDef; // if the computation steps were user defined
473 :
474 : // Default Constructor
475 14 : ComputationType() : firstStep(0), lastStep(0), isUserDef(false)
476 : {
477 14 : }
478 : };
479 :
480 : struct StackType
481 : {
482 : // Members
483 : int varPt = 0.0; // pointer to item in specific array
484 : Array1D<Real64> values; // values
485 :
486 50 : StackType() : varPt(0.0), values(NumMonths, 0.0)
487 : {
488 50 : }
489 : };
490 :
491 : void UpdateUtilityBills(EnergyPlusData &state);
492 :
493 : enum class StepType
494 : {
495 : Op,
496 : Var,
497 : EOL
498 : };
499 :
500 : struct Step
501 : {
502 : StepType type;
503 : Op op;
504 : int varNum;
505 : };
506 :
507 : //======================================================================================================================
508 : //======================================================================================================================
509 :
510 : // GET INPUT ROUTINES
511 :
512 : //======================================================================================================================
513 : //======================================================================================================================
514 :
515 : void GetInputEconomicsTariff(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
516 :
517 : void GetInputEconomicsQualify(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
518 :
519 : void GetInputEconomicsChargeSimple(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
520 :
521 : void GetInputEconomicsChargeBlock(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
522 :
523 : void GetInputEconomicsRatchet(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
524 :
525 : void GetInputEconomicsVariable(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
526 :
527 : void GetInputEconomicsComputation(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
528 :
529 : void GetInputEconomicsCurrencyType(EnergyPlusData &state, bool &ErrorsFound); // true if errors found during getting input objects.
530 :
531 : void parseComputeLine(EnergyPlusData &state, std::string const &lineOfCompute, int const fromTariff);
532 :
533 : void GetLastWord(std::string const &lineOfText, std::string::size_type &endOfScan, std::string &aWord);
534 :
535 : void initializeMonetaryUnit(EnergyPlusData &state);
536 :
537 : int FindTariffIndex(EnergyPlusData &state,
538 : std::string const &nameOfTariff,
539 : std::string const &nameOfReferingObj,
540 : bool &ErrorsFound,
541 : std::string const &nameOfCurObj);
542 :
543 : void warnIfNativeVarname(
544 : EnergyPlusData &state, std::string const &objName, int const curTariffIndex, bool &ErrorsFound, std::string const &curobjName);
545 :
546 : int AssignVariablePt(EnergyPlusData &state,
547 : std::string_view const stringIn,
548 : bool const flagIfNotNumeric,
549 : int const useOfVar,
550 : int const varSpecific,
551 : ObjType const econObjKind,
552 : int const objIndex,
553 : int const tariffPt);
554 :
555 : void incrementEconVar(EnergyPlusData &state);
556 :
557 : void incrementSteps(EnergyPlusData &state);
558 :
559 : std::string RemoveSpaces(EnergyPlusData &state, std::string_view const StringIn);
560 :
561 : void CreateCategoryNativeVariables(EnergyPlusData &state);
562 :
563 : int lookupOperator(std::string const &opString);
564 :
565 : //======================================================================================================================
566 : //======================================================================================================================
567 :
568 : // DEFAULT COMPUTATION RELATED ROUTINES
569 :
570 : //======================================================================================================================
571 : //======================================================================================================================
572 :
573 : void CreateDefaultComputation(EnergyPlusData &state);
574 :
575 : void addOperand(EnergyPlusData &state, int varMe, int varOperand);
576 :
577 : void addChargesToOperand(EnergyPlusData &state, int curTariff, int curPointer);
578 :
579 : //======================================================================================================================
580 : //======================================================================================================================
581 :
582 : // GATHER TIMESTEP VALUES ROUTINE
583 :
584 : //======================================================================================================================
585 : //======================================================================================================================
586 :
587 : void GatherForEconomics(EnergyPlusData &state);
588 :
589 : bool isWithinRange(EnergyPlusData &state, int const testVal, int const minThreshold, int const maxThreshold);
590 :
591 : //======================================================================================================================
592 : //======================================================================================================================
593 :
594 : // COMPUTE THE UTILITY BILLS AND CREATE REPORTS
595 :
596 : //======================================================================================================================
597 : //======================================================================================================================
598 :
599 : void ComputeTariff(EnergyPlusData &state);
600 :
601 : void pushStack(EnergyPlusData &state, Array1A<Real64> const monthlyArray, int const variablePointer);
602 :
603 : void popStack(EnergyPlusData &state, Array1A<Real64> monthlyArray, int &variablePointer);
604 :
605 : void evaluateChargeSimple(EnergyPlusData &state, int const usingVariable);
606 :
607 : void evaluateChargeBlock(EnergyPlusData &state, int const usingVariable);
608 :
609 : void evaluateRatchet(EnergyPlusData &state, int const usingVariable);
610 :
611 : void evaluateQualify(EnergyPlusData &state, int const usingVariable);
612 :
613 : void addMonthlyCharge(EnergyPlusData &state, int const usingVariable);
614 :
615 : void checkMinimumMonthlyCharge(EnergyPlusData &state, int const curTariff);
616 :
617 : void setNativeVariables(EnergyPlusData &state);
618 :
619 : void LEEDtariffReporting(EnergyPlusData &state);
620 :
621 : void WriteTabularTariffReports(EnergyPlusData &state);
622 :
623 : void showWarningsBasedOnTotal(EnergyPlusData &state);
624 :
625 : void getMaxAndSum(EnergyPlusData &state, int const varPointer, Real64 &sumResult, Real64 &maxResult);
626 :
627 : void ReportEconomicVariable(EnergyPlusData &state,
628 : std::string const &titleString,
629 : bool const includeCategory,
630 : bool const showCurrencySymbol,
631 : std::string const &forString);
632 :
633 : void selectTariff(EnergyPlusData &state);
634 :
635 : void GetMonthlyCostForResource(EnergyPlusData &state, Constant::eResource const inResourceNumber, Array1A<Real64> outMonthlyCosts);
636 :
637 : } // namespace EconomicTariff
638 :
639 : struct EconomicTariffData : BaseGlobalStruct
640 : {
641 :
642 : int numEconVar = 0;
643 : int sizeEconVar = 0;
644 :
645 : // holds the outbound connections for each variable
646 : Array1D<EconomicTariff::Step> operands; // sized to sizeOperand
647 : int numOperand = 0;
648 : int sizeOperand = 0;
649 :
650 : int numTariff = 0;
651 : int numQualify = 0;
652 : int numChargeSimple = 0;
653 : int numChargeBlock = 0;
654 : int numRatchet = 0;
655 : int numComputation = 0;
656 :
657 : // list of pointers to variable, 0 end of line, negative indicate operations
658 : Array1D<EconomicTariff::Step> steps;
659 : Array1D<EconomicTariff::Step> stepsCopy;
660 :
661 : int numSteps = 0;
662 : int sizeSteps = 0;
663 :
664 : int topOfStack = 0;
665 : int sizeStack = 0;
666 :
667 : bool Update_GetInput = true;
668 : int addOperand_prevVarMe = 0;
669 :
670 : Array1D<EconomicTariff::EconVarType> econVar;
671 : EPVector<EconomicTariff::TariffType> tariff;
672 : EPVector<EconomicTariff::QualifyType> qualify;
673 : EPVector<EconomicTariff::ChargeSimpleType> chargeSimple;
674 : EPVector<EconomicTariff::ChargeBlockType> chargeBlock;
675 : EPVector<EconomicTariff::RatchetType> ratchet;
676 : EPVector<EconomicTariff::ComputationType> computation;
677 : Array1D<EconomicTariff::StackType> stack;
678 :
679 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
680 : {
681 2126 : }
682 :
683 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
684 : {
685 1152 : }
686 :
687 2100 : void clear_state() override
688 : {
689 2100 : this->numEconVar = 0;
690 2100 : this->sizeEconVar = 0;
691 2100 : this->operands.deallocate();
692 2100 : this->numOperand = 0;
693 2100 : this->sizeOperand = 0;
694 2100 : this->numTariff = 0;
695 2100 : this->numQualify = 0;
696 2100 : this->numChargeSimple = 0;
697 2100 : this->numChargeBlock = 0;
698 2100 : this->numRatchet = 0;
699 2100 : this->numComputation = 0;
700 2100 : this->steps.deallocate();
701 2100 : this->stepsCopy.deallocate();
702 2100 : this->numSteps = 0;
703 2100 : this->sizeSteps = 0;
704 2100 : this->topOfStack = 0;
705 2100 : this->sizeStack = 0;
706 2100 : this->Update_GetInput = true;
707 2100 : this->addOperand_prevVarMe = 0;
708 2100 : this->econVar.deallocate();
709 2100 : this->tariff.deallocate();
710 2100 : this->qualify.deallocate();
711 2100 : this->chargeSimple.deallocate();
712 2100 : this->chargeBlock.deallocate();
713 2100 : this->ratchet.deallocate();
714 2100 : this->computation.deallocate();
715 2100 : this->stack.deallocate();
716 2100 : }
717 : };
718 :
719 : } // namespace EnergyPlus
720 :
721 : #endif
|