Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/CNRECS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -3664,7 +3664,7 @@ RECORD DHWSYS "DHWSys" *RAT // input / runtime DHW system
*r DHWDRMETH ws_drMethod // DHW demand response control method
// C_DHWDRMETH_NONE, C_DHWDRMETH_SCHED,
*h DHWDRSIG ws_drSignal; // DHW demand response control signal
*h *e INT ws_drModeHPWH; // DHW demand response HPWHsim base mode for hour
*h *e INT ws_drStatusHPWH;// DHW demand response HPWHsim base drStatus for hour
// may be modified at subhour or tick ivl

*s *hide DBL ws_tOutPrimSum; // working var re ws_tOutPrimLT
Expand Down Expand Up @@ -3830,7 +3830,7 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
*declare "void hw_SetQTX( float qTX);"
*declare "RC hw_DoHour( float& tSetpoint);"
*declare "RC hw_DoSubhrStart( float tEx, float tASHPSrc=-999.f);"
*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);"
*declare "RC hw_DoSubhrTick( DHWTICK& tk, float tInlet, float scaleWH=1.f, float tMix=-1., float tMains=-1.f, float* pTOutNoMix=NULL, int drStatus=0);"
*declare "RC hw_DoSubhrTick( int iTk, float draw, float tInlet, float* pTOut, float scaleWH=1.f);"
*declare "RC hw_DoSubhrEnd( float mult, ZNR* pZn, ZNR* pZnASHPSrc);"

Expand Down Expand Up @@ -3922,7 +3922,7 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
*declare "virtual void ReceiveRuntimeMessage( const char* msg);"
*declare "RC wh_HPWHInit();"
*declare "static void wh_DRMapValidate();"
*declare "static int wh_DRMapSigToDRMode( DHWDRSIG drSig);"
*declare "static int wh_DRMapSigToDRStatus( DHWDRSIG drSig);"

*r FLOAT_GEZ wh_mult; // count of identical water heaters (default 1)
// models as if repeated identical input
Expand Down
40 changes: 19 additions & 21 deletions src/DHWCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,15 +1203,15 @@ RC DHWSYS::ws_DoHour( // hourly calcs
#endif

// Demand response (DR) hourly setup
ws_drModeHPWH = HPWH::DR_ALLOW;
ws_drStatusHPWH = HPWH::DR_ALLOW;
if (!ws_HasCentralDHWSYS())
{ int drSig = CHN(ws_drSignal); // decode variable choice
ws_drModeHPWH = ws_drMethod == C_DHWDRMETH_SCHED
? DHWHEATER::wh_DRMapSigToDRMode( drSig)
ws_drStatusHPWH = ws_drMethod == C_DHWDRMETH_SCHED
? DHWHEATER::wh_DRMapSigToDRStatus( drSig)
: HPWH::DR_ALLOW;
}
else
ws_drModeHPWH = HPWH::DR_ALLOW; // no DR for child DHWSYSs (no DHWHEATERs)
ws_drStatusHPWH = HPWH::DR_ALLOW; // no DR for child DHWSYSs (no DHWHEATERs)

if (ws_wpCount > 0) // if any child pumps
{ DHWPUMP* pWP;
Expand Down Expand Up @@ -2779,7 +2779,7 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
// needed iff tMix is specified
float* pTOutNoMix/*=NULL*/, // unmixed output temp accumulated here re DHWLOOPHEATER
// average inlet temp
int drMode /*=0*/) // demand response control signal
int drStatus /*=0*/) // demand response control signal
{
RC rc = RCOK;

Expand Down Expand Up @@ -2833,7 +2833,7 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
DegFtoC(hw_tEx), // ambient T (=tank surround), C
DegFtoC(hw_tASHPSrc), // heat source T, C
// aka HPWH "external temp"
HPWH::DRMODES( drMode), // DRstatus: demand response signal
HPWH::DRMODES( drStatus), // DRstatus: demand response signal
GAL_TO_L(drawRL), DegFtoC(tRL), // 2ndary draw for DHWLOOP
// note drawForTick includes drawRL
pNPX); // additional node power (re e.g. solar tanks)
Expand Down Expand Up @@ -2907,7 +2907,7 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
}
#if defined( HPWH_DUMP)
// tick level CSV report for testing
int dumpUx = UNSYSSI; // unit system for CSV values
int dumpUx = UNSYSIP; // unit system for CSV values
int hpwhOptions = dumpUx == UNSYSIP ? HPWH::CSVOPT_IPUNITS : HPWH::CSVOPT_NONE;
static const int nTCouples = 12; // # of storage layers reported by HPWH

Expand All @@ -2931,7 +2931,6 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
"vLoss", drawLoss, UNLVOLUME2, 5,
"vRL", drawRL, UNLVOLUME2, 5,
"vTot", drawForTick, UNLVOLUME2, 5,
"DR", double(drMode), UNNONE, 1,
"tMains", tMains > 0. ? tMains : CSVItem::ci_UNSET,
UNTEMP, 5,
"tDWHR", tk.wtk_tInletX, UNTEMP, 5,
Expand All @@ -2950,8 +2949,7 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
UNENERGY3, 5,
"qLoss", KWH_TO_BTU(hw_pHPWH->getStandbyLosses()),
UNENERGY3, 5,
"XBU", HPWHxBU, UNENERGY3, 5,

"XBU", HPWHxBU, UNENERGY3, 5,
NULL
};

Expand Down Expand Up @@ -3589,7 +3587,7 @@ RC DHWHEATER::wh_HPWHInit() // initialize HPWH model
pWS->ignore(fn,
strtprintf("-- HPWH '%s' has a fixed setpoint.", name));
}
wh_DRMapValidate(); // validate DRMODE mapping (ABT if bad)
wh_DRMapValidate(); // validate drStatus mapping (ABT if bad)
}
return rc;
} // DHWHEATER::wh_HPWHInit
Expand All @@ -3598,7 +3596,7 @@ RC DHWHEATER::wh_HPWHInit() // initialize HPWH model
// Demand reduction (DR) stuff
struct DRMAP
{ DHWDRSIG drSig; // CSE signal choice
int drModeHPWH; // corresponding HPWH drMode
int drStatusHPWH; // corresponding HPWH drStatus
};
static const DRMAP drMap[] =
{ C_DHWDRSIG_ON, HPWH::DR_ALLOW,
Expand Down Expand Up @@ -3630,18 +3628,18 @@ static const DRMAP drMap[] =

} // DHWHEATER::wh_DRMapValidate
//-----------------------------------------------------------------------------
/* static*/ int DHWHEATER::wh_DRMapSigToDRMode(
/* static*/ int DHWHEATER::wh_DRMapSigToDRStatus(
DHWDRSIG drSig) // CSE DR choice value
// -1: validate table
// returns HPWH-compatible DRMODES value corresponding to CSE choice
{
int ixDrSig = drSig - C_DHWDRSIG_ON; // choice values assigned sequencially

int drMode = drMap[ixDrSig].drModeHPWH;
int drStatus = drMap[ixDrSig].drStatusHPWH;

return drMode;
return drStatus;

} // DHWHEATER::wh_DRMapSigToDRMode
} // DHWHEATER::wh_DRMapSigToDRStatus
//-----------------------------------------------------------------------------
RC DHWHEATER::wh_DoSubhrStart()
{
Expand Down Expand Up @@ -3726,17 +3724,17 @@ RC DHWHEATER::wh_DoSubhrTick( // DHWHEATER energy use for 1 tick
{ // demand response (DR)
// use DHWSYS hourly base value
// turn off hour-start one-shot signals if not hour start
int drMode;
int drStatus;
if (whfcn == whfcnPRIMARY)
{ drMode = pWS->ws_drModeHPWH;
{ drStatus = pWS->ws_drStatusHPWH;
if (tk.wtk_startMin > 0.f)
drMode &= ~(HPWH::DR_TOO | HPWH::DR_TOT);
drStatus &= ~(HPWH::DR_TOO | HPWH::DR_TOT);
}
else
drMode = HPWH::DR_ALLOW;
drStatus = HPWH::DR_ALLOW;

rc |= wh_HPWH.hw_DoSubhrTick(tk, tInletWH, scaleWH, tMix, pWS->ws_tInlet,
&tOutNoMix, drMode);
&tOutNoMix, drStatus);

if (whfcn == whfcnPRIMARY)
pWS->ws_tOutPrimSum += tOutNoMix * scaleWH * wh_mult;
Expand Down
2 changes: 1 addition & 1 deletion vendor/HPWHsim