Skip to content

Commit 04bcbec

Browse files
authored
Merge pull request #112 from cse-sim/hpwhdr
Initial demand response test version; DHWSYSRES progress
2 parents b79cf38 + 31e45f4 commit 04bcbec

File tree

11 files changed

+415
-318
lines changed

11 files changed

+415
-318
lines changed

src/CNCULT.CPP

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,8 @@ CULT( "wsUse", DAT, DHWSYS_HWUSE, 0, 0, VHRLY, TYFL, 0, 0.f, N
20712071
CULT( "wsTUse", DAT, DHWSYS_TUSE, 0, 0, VHRLY, TYFL, 0, 120.f, N, N),
20722072
CULT( "wsTSetpoint", DAT, DHWSYS_TSETPOINT,0, 0, VHRLY, TYFL, 0, 120.f, N, N),
20732073
CULT( "wsTSetpointLH",DAT, DHWSYS_TSETPOINTLH,0, 0, VHRLY, TYFL, 0, 120.f, N, N),
2074+
CULT( "wsDRMethod", DAT, DHWSYS_DRMETHOD, 0, 0, VEOI, TYCH, 0, C_DHWDRMETH_NONE, N, N),
2075+
CULT( "wsDRSignal", DAT, DHWSYS_DRSIGNAL, 0, 0, VHRLY, TYCH, 0, nc( C_DHWDRSIG_ON), 0.f, N, N),
20742076
CULT( "wsDayUse", DAT, DHWSYS_DAYUSENAME,0, 0, VDAILY, TYSTR, 0, N, N, N),
20752077
CULT( "wsWHhwMtr", DAT, DHWSYS_WHHWMTRI, 0, 0, VEOI, TYREF, &WMtriB,N, N, N),
20762078
CULT( "wsFXhwMtr", DAT, DHWSYS_FXHWMTRI, 0, 0, VEOI, TYREF, &WMtriB,N, N, N),

src/CNDTYPES.DEF

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ PIPESEGP -- "class PIPESEG*" 4 none
356356
}
357357

358358
// DHW choices
359+
359360
*choicb WSCALCMODECH {
360361
PRERUN "PreRun"
361362
SIM "Simulate"
@@ -472,6 +473,7 @@ PIPESEGP -- "class PIPESEG*" 4 none
472473
}
473474
*choicb DHWLSEGTYCH { RET "return" SUP "supply" }
474475
*choicb DWHRTYCH { HORIZ "horizontal" VERT "vertical" SETEF "SetEF" }
476+
*choicb DHWDRMETH { NONE "none" SCHED "schedule" /* TDV */ }
475477

476478
// PV choices
477479
*choicb PVMODCH {
@@ -738,6 +740,17 @@ PIPESEGP -- "class PIPESEG*" 4 none
738740
TDVPEAKSAVE "TDVPeakSave"
739741
}
740742

743+
*choicn DHWDRSIG {
744+
ON "On"
745+
TOO "TOO"
746+
TXO "TXO"
747+
TOT "TOT"
748+
TXT "TXT"
749+
LOC "LOC"
750+
LOR "LOR"
751+
LOX "LOX"
752+
COUNT "*Count" // hidden
753+
}
741754

742755
/**********************************************************************************************************************
743756
** === CHOICN types: can hold these choices (as NAN), or float number

src/CNFIELDS.DEF

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,16 @@ RSYSMODECTRLCH RSYSMODECTRLCH LMNONE UNNONE
169169
RSYSTYCH RSYSTYCH LMNONE UNNONE
170170
RSYSOAVTYCH RSYSOAVTYCH LMNONE UNNONE
171171
RSYSDEFROSTMODELCH RSYSDEFROSTMODELCH LMNONE UNNONE
172+
WHTYPECH WHTYPECH LMNONE UNNONE
172173
WHHEATSRCCH WHHEATSRCCH LMNONE UNNONE
173174
WSCALCMODECH WSCALCMODECH LMNONE UNNONE
174-
WHTYPECH WHTYPECH LMNONE UNNONE
175175
WHASHPTYCH WHASHPTYCH LMNONE UNNONE
176176
DHWEUCH DHWEUCH LMNONE UNNONE
177177
DHWEUXCH DHWEUXCH LMNONE UNNONE
178178
DHWBRANCHMODELCH DHWBRANCHMODELCH LMNONE UNNONE
179179
DHWLSEGTYCH DHWLSEGTYCH LMNONE UNNONE
180180
DWHRTYCH DWHRTYCH LMNONE UNNONE
181+
DHWDRMETH DHWDRMETH LMNONE UNNONE // DHW demand response control method
181182
PVMODCH PVMODCH LMNONE UNNONE
182183
PVARRCH PVARRCH LMNONE UNNONE
183184
MOUNTCH MOUNTCH LMNONE UNNONE
@@ -221,6 +222,7 @@ NOYESVC NOYESVC LMNONE UNNONE
221222
OFFAVAILONVC OFFAVAILONVC LMNONE UNNONE
222223
VENTAVAILVC VENTAVAILVC LMNONE UNNONE
223224
BATCTRLALGVC BATCTRLALGVC LMNONE UNNONE
225+
DHWDRSIG DHWDRSIG LMNONE UNNONE
224226

225227
// number/choice (NC choicn) types
226228
TEMP_TSCM TSCMNC LMNONE UNTEMP

src/CNGUTS.CPP

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,6 @@ RC FC cgRddInit( // Perform initialization common to main simulation run and eac
987987
RLUP( AhB, ah)
988988
rc |= ah->rddInit( isAusz); // do run-or-design-day init for each air handler
989989

990-
#if 1
991990
// allocate results records paired with run records
992991
// do for both autoSize and run
993992
// no accum for autoSize, but code does incidental stores into xxRES
@@ -1003,40 +1002,6 @@ RC FC cgRddInit( // Perform initialization common to main simulation run and eac
10031002

10041003
EF(AhresB.AllocResultsRecs(AhB)); // AHRES <-> AH
10051004

1006-
#else
1007-
int i = ZrB.n + 1; // need a results record for each zone, and one for sum of zones
1008-
EF( ZnresB.al( i, WRN) ) // alloc ZNRES recs, at once for less fragmentation. destroys old.
1009-
do // (Note: may be no results accumulation during autoSize,
1010-
{ // but alloc anyway cuz code several places stores into records)
1011-
ZNRES *zp;
1012-
ZnresB.add( &zp, ABT, i); // init (to 0) each zone results record, 1 thru i. ancrec.cpp.
1013-
strcpy( zp->name, i <= ZrB.n ? ZrB.p[i].name : "sum_of_zones"); // results name for rpts: name of zone or "sum_of_zones"
1014-
zp->zr_InitPrior(); // provide plausible ZNRES.prior values for use in
1015-
// possible expressions that are evaluated at step beg
1016-
}
1017-
while (--i > 0);
1018-
1019-
i = RsR.n + 1; // need a results record for each RSYS, and one for sum of RSYSs
1020-
EF( RsResR.al( i, WRN) ) // alloc RSYSRES recs, at once for less fragmentation. destroys old.
1021-
do // (Note: may be no results accumulation during autoSize,
1022-
{ // but alloc anyway cuz code several places stores into records)
1023-
RSYSRES* pRSR;
1024-
RsResR.add( &pRSR, ABT, i); // init (to 0) each zone results record, 1 thru i.
1025-
strcpy( pRSR->name, i <= RsR.n ? RsR.p[i].name : "sum_of_RSYS"); // results name for rpts
1026-
}
1027-
while (--i > 0);
1028-
1029-
i = AhB.n + 1; // need a results record for each ah, and one for sum of ahs
1030-
EF( AhresB.al( i, WRN) ) // alloc AHRES recs, all at once for less mem frag. destroys any old.
1031-
do
1032-
{
1033-
AHRES *ahr;
1034-
AhresB.add( &ahr, ABT, i); // initialize each ah results record, 1 thru i. ancrec.cpp.
1035-
strcpy( ahr->name, i <= AhB.n ? AhB.p[i].name : "sum_of_ahs"); // ah results name for rpts: name of ah or "sum_of_ahs"
1036-
}
1037-
while (--i > 0);
1038-
#endif
1039-
10401005
#ifdef BINRES
10411006
// Init re binary results output files
10421007
// move call to cgInit (and review code) if file is to persist (stay open) thru autosize and main sim run.
@@ -1768,7 +1733,7 @@ LOCAL void FC NEAR doIvlAccum()
17681733
RLUP( RsResR, pRSR) // loop RSYS simulation results incl sum_of.
17691734
pRSR->curr.Y.rsr_Accum( &pRSR->curr.M, Top.isFirstMon, Top.isLastDay); // accumulate year from month
17701735
RLUP(WsResR, pWSR) // loop DHWSYSRES results incl sum_of.
1771-
pWSR->Y.wsr_Accum(&pWSR->D, Top.isFirstMon, Top.isLastDay);
1736+
pWSR->Y.wsr_Accum(&pWSR->M, Top.isFirstMon, Top.isLastDay);
17721737
mtrsAccum( C_IVLCH_Y, Top.isFirstMon, Top.isLastDay); // accumulate metered energy use: month to year
17731738
#ifdef BINRES
17741739
if (brf) // if outputting any binary results this run

src/CNLOADS.CPP

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3790,7 +3790,7 @@ void RSYS::rs_EnteringAirState( // RSYS entering air state
37903790
// rsMode determines assumed air source
37913791
// rsmOAV: outdoor air (as modified via rs_OAVTdbInlet)
37923792
// else: mixes air from zones plus return duct leakage
3793-
// then addes return duct conduction and leakage
3793+
// then adds return duct conduction and leakage
37943794

37953795
// returns
37963796
// rs_asIn = state of air entering RSYS (after return ducts)

src/CNRECS.DEF

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3507,14 +3507,15 @@ RECORD DHWSYSRES_IVL "DHWSYSRES interval sub" *SUBSTRUCT // interval substruct
35073507
*declare "void wsr_AccumTick( const struct DHWTICK& tk);"
35083508
*declare "static const size_t wsr_NFLOAT;"
35093509

3510-
// water heating energy (not fuel)
3510+
// water heating energy (not fuel), Btu
3511+
// values are for associated DHWSYS (wh_mult include, ws_mult not included)
35113512
*e FLOAT total //
35123513
*e FLOAT qDWHR // drain water heat recovery
35133514
*e FLOAT qSSF // implied energy contribution from ws_SSF
35143515
*e FLOAT qSolar // DHWSOLARSYS
3515-
*e FLOAT qWaterHeater // DHWHEATER
3516-
*e FLOAT qLoopHeater
3517-
*e FLOAT qXBU
3516+
*e FLOAT qWH // DHWHEATER primary (compressor, burner, )
3517+
*e FLOAT qLH // Loop heater primary
3518+
*e FLOAT qXBU // add'l backup heat
35183519

35193520
*END // DHWSYSRES_IVL
35203521
//=============================================================================
@@ -3610,7 +3611,7 @@ RECORD DHWSYS "DHWSys" *RAT // input / runtime DHW system
36103611

36113612
*h *e FLOAT ws_tInlet; // current hour cold water inlet temp, F for this DHWSYS
36123613
// user expression or default Wthr.d.wd_tMains
3613-
// Not modified by DWHR or Solar
3614+
// Not modified by solar and/or DHWHEATREC
36143615
*h *e FLOAT ws_tInletX; // hour average adjusted cold water temp, F
36153616
// reflects solar and/or DHWHEATREC
36163617
*h FLOAT ws_hwUse; // current hour hot water use (at fixtures), gal
@@ -3660,6 +3661,12 @@ RECORD DHWSYS "DHWSys" *RAT // input / runtime DHW system
36603661
// default = ws_tUse
36613662
*h FLOAT ws_tSetpointLH; // DHWLOOPHEATER set point (for all child DHWLOOPHEATERs using HPWH model), F
36623663
// default = ws_tUse
3664+
*r DHWDRMETH ws_drMethod // DHW demand response control method
3665+
// C_DHWDRMETH_NONE, C_DHWDRMETH_SCHED,
3666+
*h DHWDRSIG ws_drSignal; // DHW demand response control signal
3667+
*h *e INT ws_drModeHPWH; // DHW demand response HPWHsim base mode for hour
3668+
// may be modified at subhour or tick ivl
3669+
36633670
*s *hide DBL ws_tOutPrimSum; // working var re ws_tOutPrimLT
36643671
*s *e FLOAT ws_tOutPrimLT; // primary water heater outlet temp, F
36653672
// for HPWH only, re DHWLOOPHEATER entering temp
@@ -3789,11 +3796,6 @@ RECORD DHWSYS "DHWSys" *RAT // input / runtime DHW system
37893796
*h *e FLOAT ws_HARL; // hour total adjusted recovery load, Btu
37903797
*h *e FLOAT ws_HARLtk; // hour total adjusted recovery load, Btu
37913798
// check figure derived from ticks
3792-
3793-
#if 0
3794-
*s *e *nest DHWSYSRES ws_res // results
3795-
#endif
3796-
37973799
*END // DHWSYS
37983800

37993801
//=============================================================================
@@ -3828,9 +3830,9 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
38283830
*declare "void hw_SetQTX( float qTX);"
38293831
*declare "RC hw_DoHour( float& tSetpoint);"
38303832
*declare "RC hw_DoSubhrStart( float tEx, float tASHPSrc=-999.f);"
3831-
*declare "RC hw_DoSubhrTick( DHWTICK& tk, float tInlet, float scaleWH=1.f, float tMix=-1., float tMains=-1.f, float* pTOutNoMix=NULL);"
3833+
*declare "RC hw_DoSubhrTick( DHWTICK& tk, float tInlet, float scaleWH=1.f, float tMix=-1., float tMains=-1.f, float* pTOutNoMix=NULL, int drMode=0);"
38323834
*declare "RC hw_DoSubhrTick( int iTk, float draw, float tInlet, float* pTOut, float scaleWH=1.f);"
3833-
*declare "RC hw_DoSubhrEnd( float mult, ZNR* pZn, ZNR* pZnASHPSrc, double& totOut);"
3835+
*declare "RC hw_DoSubhrEnd( float mult, ZNR* pZn, ZNR* pZnASHPSrc);"
38343836

38353837
*declare "record* hw_pOwner;" // owner (DHWHEATER, DHWSOLARSYS, ...)
38363838
*declare "class HPWH* hw_pHPWH;" // pointer HPWH object
@@ -3855,7 +3857,7 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
38553857
// Loop return flow is reduced to balance load at ws_tUse.
38563858

38573859
*s *e *array 2 DBL hw_inElec; // current subhr HPWH electricity use, kWh
3858-
// [0]=resistance backup (iff HP) (not including wh_HPWHxBU)
3860+
// [0]=resistance backup (iff HP) (not including hw_HPWHxBU)
38593861
// [1]=primary(=compressor or non-HP resistance) + misc
38603862
*r FLOAT hw_HPWHxBU; // current subhr HPWH add'l backup resistance heat, Btu
38613863
// output water heated to ws_tUse iff HPWH output temp < ws_tUse
@@ -3865,7 +3867,7 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
38653867
// for 1 DHWHEATER (no wh_mult)
38663868
*s *e DBL hw_qHW; // current subhr HPWHtotal hot water heating, kWh. always >= 0
38673869
// for 1 DHWHEATER (no wh_mult)
3868-
// includes heat to DHWLOOP, does not include wh_HPWHxBU
3870+
// includes heat to DHWLOOP, does not include hw_HPWHxBU
38693871
*s *e DBL hw_qTX; // current subhr extra heat tank heat, kWh (not Btu)
38703872

38713873
*h *e INT hw_tankTempSet; // nz iff HPWH tank temp has been initialized
@@ -3912,13 +3914,15 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
39123914
*declare "RC wh_DoSubhrTick( struct DHWTICK& tk, float scaleWH);"
39133915
*declare "RC wh_InstUEFInit();"
39143916
*declare "RC wh_InstUEFDoSubhrTick( double draw, float tInletWH, float scaleWH, float tUse);"
3915-
*declare "RC wh_DoSubhrEnd();"
3917+
*declare "RC wh_DoSubhrEnd( bool bIsLH);"
39163918
*declare "RC wh_DoEndPreRun();"
39173919
*declare "RC wh_EndIvl( IVLCH ivl, float HARL, float wsMult);"
39183920
*declare "static WStr wh_GetHPWHVersion();"
39193921
*declare "int wh_ReportBalErrorsIf() const;"
39203922
*declare "virtual void ReceiveRuntimeMessage( const char* msg);"
39213923
*declare "RC wh_HPWHInit();"
3924+
*declare "static void wh_DRMapValidate();"
3925+
*declare "static int wh_DRMapSigToDRMode( DHWDRSIG drSig);"
39223926

39233927
*r FLOAT_GEZ wh_mult; // count of identical water heaters (default 1)
39243928
// models as if repeated identical input
@@ -3931,7 +3935,7 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
39313935
// _ELRESX: electric resistance (Ecotope HPWH)
39323936
*i WHTYPECH wh_type; // heater type
39333937
// C_WHTYPECH_STRGSML, _STRGLRG, _INSTSML, _INSTLRG,
3934-
// _INSTUEF
3938+
// _INSTUEF, _BUILTUP
39353939
*i ANAME wh_desc; // probe-able description text
39363940
*declare "virtual const char* GetDescription( int options=0) { options; return wh_desc; }"
39373941
*r INT wh_fcn; // function of this DHWHEATER per whfcnXXX enum
@@ -4003,7 +4007,7 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
40034007
// load that is unmet on 1 min basis
40044008
// default = 1; only for C_WHTYPECH_INSTUEF
40054009
*i DBL wh_loadCFwdMax; // max load carry-forward energy (from wh_loadCFwdF), Btu
4006-
// any excess load met via wh_HPWHxBU
4010+
// any excess load met via wh_qXBU
40074011
*s DBL wh_loadCFwd; // current load carry forward, Btu
40084012
// see wh_InstUEFDoSubhr()
40094013
*s *e FLOAT wh_nTickFullLoad; // INSTUEF: current subhour equiv full load ticks (fractional)
@@ -4028,15 +4032,15 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
40284032
*s *e *nest HPWHLINK wh_HPWH; // interface to Ecotope HPWH detailed heat pump model
40294033
// also used for resistance electric heaters
40304034

4031-
*s *e FLOAT wh_HPWHxBU; // current step HPWH add'l backup resistance heat, Btu
4035+
*s *e FLOAT wh_qXBU; // current step HPWH add'l backup resistance heat, Btu
40324036
// output water heated to ws_tUse iff HPWH output temp < ws_tUse
40334037
*s *e DBL wh_qEnv; // current step heat removed by HPWH from environment, kWh
40344038
// + = to water heater; for 1 DHWHEATER (no wh_mult)
40354039
*s *e DBL wh_qLoss; // current step HPWH standby losses, kWh. + = to surround
40364040
// for 1 DHWHEATER (no wh_mult)
4037-
*s *e DBL wh_qHW; // current step HPWHtotal hot water heating, kWh. always >= 0
4041+
*s *e float wh_qHW; // current step hot water heating, kWh. always >= 0
40384042
// for 1 DHWHEATER (no wh_mult)
4039-
// includes heat to DHWLOOP, does not include wh_HPWHxBU
4043+
// includes heat to DHWLOOP, does not include wh_qXBU
40404044
*s *e INT wh_nzDrawCount; // current substep # of draws > 0
40414045

40424046
*h *e INT wh_bWriteCSV; // write HPWH debugging CSV iff nz
@@ -4050,7 +4054,7 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
40504054
*h *e INT wh_hrCount; // # of hourly values included in wh_totHARL
40514055
// re calc of avg
40524056
*h *e DBL wh_totOut; // cumulative (year to date) total heat delivered to hot water, Btu
4053-
// includes wh_HPWHxBU
4057+
// includes wh_qXBU
40544058

40554059

40564060
// energy inputs for current subhour, Btu
@@ -4059,8 +4063,8 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
40594063
*s *e FLOAT wh_inElecSh; // primary electricity (including wh_parElec) (note not kWh)
40604064
// for HPWH, includes compressor + misc (not resistance)
40614065
*s *e FLOAT wh_inElecBUSh; // backup electricity (>0 only for HPWH resistance heat)
4062-
// (includes wh_HPWHxBU)
4063-
*s *e FLOAT wh_inElecXBUSh; // "extra" backup (reheating to maintain ws_tUse)
4066+
// (does not include wh_inElecXBUSh)
4067+
*s *e FLOAT wh_inElecXBUSh; // XBU "extra" backup (reheating to maintain ws_tUse)
40644068
*s *e FLOAT wh_inFuelSh; // fuel (including wh_pilotPwr)
40654069

40664070

@@ -4070,8 +4074,8 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
40704074
*h *e FLOAT wh_inElec; // primary electricity (including wh_parElec) (note not kWh)
40714075
// for HPWH, includes compressor + misc (not resistance)
40724076
*h *e FLOAT wh_inElecBU; // backup electricity (>0 only for HPWH resistance heat)
4073-
// (includes wh_HPWHxBU)
4074-
*h *e FLOAT wh_inElecXBU; // "extra" backup (reheating to maintain ws_tUse)
4077+
// (does not include wh_inElecXBU)
4078+
*h *e FLOAT wh_inElecXBU; // XBU "extra" backup (reheating to maintain ws_tUse)
40754079
*h *e FLOAT wh_inFuel; // fuel (including wh_pilotPwr)
40764080

40774081
// annual total energy inputs, Btu (check figures)
@@ -4084,6 +4088,8 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
40844088
// default = none (include wh_HPWHxBU in end use dhwBU)
40854089
*declare "MTR* wh_pMtrElec; MTR* wh_pMtrFuel;"
40864090
// runtime pointers to meters, NULL if not accum'ing
4091+
*declare "DHWSYSRES_IVL* wh_pResSh;" // pointer to DHWSYSRES subhour record
4092+
// re heat output accounting
40874093

40884094
*h *e INT wh_unMetSh; // count of subhrs in this hour
40894095
// when wh_tHWOut < wh_tUse

0 commit comments

Comments
 (0)