Skip to content

Commit fbfd08a

Browse files
authored
Merge pull request #134 from cse-sim/dhwloopheater
DHWHEATER whResType; HPWH resistance swingtank variant Bug fix: long object names Bug fix: cooling autosizing with inverted supply temp
2 parents 65b7ac1 + 458b596 commit fbfd08a

File tree

15 files changed

+185
-135
lines changed

15 files changed

+185
-135
lines changed

src/CGCOMP.CPP

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,10 @@ TI ZNR::zn_AddIZXFER( // add IZXFER coupled to this zone
12641264
IZXRAT* ize;
12651265
IzxR.add( &ize, ABT);
12661266

1267-
strcpy( ize->name, name);
1268-
strCatIf( ize->name, sizeof( ize->name), "-", nmSfx);
1267+
ize->SetName( name);
1268+
// append suffix
1269+
int catOption = 1; // attempt to truncate name size exceeded
1270+
strCatIf( ize->name, sizeof( ize->name), "-", nmSfx, catOption);
12691271
ize->iz_zi1 = ss; // idx of this zone
12701272
ize->iz_nvcntrl = ty;
12711273
ize->iz_pAF = pAF;

src/CNCULT.CPP

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,7 @@ CULT( "whType", DAT, DHWHEATER_TYPE, 0, 0, VEOI, TYCH, 0,
18521852
CULT( "whHeatSrc", DAT, DHWHEATER_HEATSRC, 0, 0, VEOI, TYCH, 0, C_WHHEATSRCCH_FUEL, N, N),
18531853
CULT( "whZone", DAT, DHWHEATER_ZNTI, 0, 0, VEOI, TYREF, &ZiB, 0, N, N),
18541854
CULT( "whTEx", DAT, DHWHEATER_TEX, 0, 0, VSUBHRLY,TYFL, 0, 70.f, N, N),
1855+
CULT( "whResType", DAT, DHWHEATER_RESTY, 0, 0, VEOI, TYCH, 0, C_WHRESTYCH_TYPICAL,N, N),
18551856
CULT( "whASHPType", DAT, DHWHEATER_ASHPTY, 0, 0, VEOI, TYCH, 0, -1, N, N),
18561857
CULT( "whASHPSrcZn", DAT, DHWHEATER_ASHPSRCZNTI,0, 0, VEOI, TYREF, &ZiB, 0, N, N),
18571858
CULT( "whASHPSrcT", DAT, DHWHEATER_ASHPTSRC,0, 0, VSUBHRLY,TYFL, 0, 70.f, N, N),

src/CNCULT4.CPP

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ LOCAL RC addRep( TI rfi, char *name, RPTYCH rpTy, TI zi, IVLCH freq, SI putAtEnd
142142
UCH *fs;
143143
RC rc;
144144

145-
E( RiB.add( &rp, WRN) ) // add report input record (ancrec.cpp) / return if error
146-
strncpy( rp->name, name, sizeof(ANAME)-1 ); // record name, for like/alter/delete
147-
rp->zi = zi; // 0, TI_SUM, or TI_ALL (or reference to a zone)
145+
E( RiB.add( &rp, WRN) ) // add report input record (ancrec.cpp) / return if error
146+
rp->SetName( name); // record name, for like/alter/delete
147+
rp->zi = zi; // 0, TI_SUM, or TI_ALL (or reference to a zone)
148148
rp->ownTi = rfi; // reference to report file
149149
rp->rpTy = rpTy; // type of report
150150
rp->rpFreq = freq; // 0 or frequency of report
@@ -1817,10 +1817,10 @@ LOCAL void addHdayDate( char *name, DOY date) // add holiday celebrated on spe
18171817
{
18181818
// for topPrfHday
18191819
HDAY *hdi;
1820-
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
1821-
strncpy( hdi->name, name, sizeof(ANAME)-1 ); // record name, for like/alter/delete and error messages
1822-
hdi->hdDateTrue = date; // store true date
1823-
hdi->hdOnMonday = C_NOYESCH_YES; // say observe on following monday if falls on weekend
1820+
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
1821+
hdi->SetName( name); // record name, for like/alter/delete and error messages
1822+
hdi->hdDateTrue = date; // store true date
1823+
hdi->hdOnMonday = C_NOYESCH_YES; // say observe on following monday if falls on weekend
18241824
// topHday will set hdDateObs.
18251825
} // addHdayDate
18261826
//---------------------------------------------------------------------------------------------------------------------------
@@ -1829,9 +1829,9 @@ LOCAL void addHdayRule( char *name, HDAYCASECH hdCase, DOWCH dow, MONTH mon)
18291829
{
18301830
// for topPrfHday
18311831
HDAY *hdi;
1832-
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
1833-
strncpy( hdi->name, name, sizeof(ANAME)-1 ); // record name, for like/alter/delete
1834-
hdi->hdCase = hdCase; // store arguments
1832+
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
1833+
hdi->SetName( name); // record name, for like/alter/delete
1834+
hdi->hdCase = hdCase; // store arguments
18351835
hdi->hdDow = dow;
18361836
hdi->hdMon = mon;
18371837
// topHday will set hdDateTrue and hdDateObs.

src/CNDTYPES.DEF

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ PIPESEGP -- "class PIPESEG*" 4 none
470470
SCALABLE_SP "Scalable_SP" // scalable type for autosized standard design
471471
}
472472

473+
*choicb WHRESTYCH { // resistance heater types
474+
TYPICAL "Typical"
475+
SWINGTANK "SwingTank"
476+
}
477+
473478
*choicb DHWEUCH { // hot end uses
474479
FAUCET "Faucet"
475480
SHOWER "Shower"

src/CNFIELDS.DEF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ WHTYPECH WHTYPECH LMNONE UNNONE
176176
WHHEATSRCCH WHHEATSRCCH LMNONE UNNONE
177177
WSCALCMODECH WSCALCMODECH LMNONE UNNONE
178178
WHASHPTYCH WHASHPTYCH LMNONE UNNONE
179+
WHRESTYCH WHRESTYCH LMNONE UNNONE
179180
DHWEUCH DHWEUCH LMNONE UNNONE
180181
DHWEUXCH DHWEUXCH LMNONE UNNONE
181182
DHWBRANCHMODELCH DHWBRANCHMODELCH LMNONE UNNONE

src/CNLOADS.CPP

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,10 +2055,10 @@ void RSYS::rs_RddiInit() // init before each autosize design day ITERATION
20552055
}
20562056
} // RSYS::rs_RddiInit
20572057
//-----------------------------------------------------------------------------
2058-
RC RSYS::rs_endP1DsdIter()
2058+
RC RSYS::rs_endP1DsdIter( // autosizing end of day
2059+
int auszMode) // rsmHEAT, rsmCOOL
20592060
{
20602061
RC rc = RCOK;
2061-
int auszMode = rs_IsAutoSizing();
20622062
if (auszMode == rsmHEAT)
20632063
{ // note: rs_fxCapHDay = 20 if no load
20642064
float f = rs_fxCapHAsF / max( rs_fxCapHDay, .01f);
@@ -2107,13 +2107,10 @@ RC RSYS::rs_endP1DsdIter()
21072107
float fX = bracket( .9f, errX+1.f, 1.1f);
21082108
rs_cap95 *= fX;
21092109

2110-
#if 1
2111-
if (rs_cap95 < 1200.f)
2112-
rs_cap95 = 1200.f; // never < 0.1 ton
2113-
else
2114-
#endif
2115-
if (rs_cap95 < rs_auszC.az_b)
2116-
rs_cap95 = rs_auszC.az_b; // never < previous design day peak
2110+
float cap95min = max(rs_auszC.az_b, 1200.f);
2111+
if (rs_cap95 < cap95min)
2112+
rs_cap95 = cap95min; // never < 0.1 ton
2113+
// never < previous design day peak
21172114
}
21182115

21192116
setToMax( rs_auszC.ldPk, rs_cap95); // peak
@@ -2819,8 +2816,13 @@ RC RSYS::rs_AfterHour()
28192816

28202817
if (Top.isEndDay)
28212818
{ // last step of day
2822-
rc = rs_endP1DsdIter();
2819+
int auszMode = rs_IsAutoSizing();
2820+
if (auszMode != rsmOFF)
2821+
rc = rs_endP1DsdIter( auszMode);
28232822
}
2823+
2824+
// prior interval values: none
2825+
28242826
return rc;
28252827
} // RSYS::rs_AfterHour
28262828
//-----------------------------------------------------------------------------
@@ -4336,15 +4338,21 @@ double RSYS::rs_ZoneAirRequest( // air quantity needed by zone
43364338
if (znSupReq > 1.e10) // znSupReq = DBL_MAX if supplyDT is tiny
43374339
znSupReq = rs_amf;
43384340
else if (znSupReq < 0.)
4339-
// reverse flow (caused by "backwards" supplyDT)
4341+
// reverse flow
4342+
// caused by "flipped" supply DT
4343+
// due to e.g. big duct losses
43404344
znSupReq =
4341-
#if 1
4345+
#if 1 // attempt to fix small load sizing, 7-16-2021
4346+
2. * rs_amf; // request "a lot"
4347+
#else
4348+
#if 1 // unknown date
43424349
Top.tp_autoSizing
43434350
#else
43444351
Top.tp_pass1A
43454352
#endif
43464353
? 1. // autosize warmup: ignore
43474354
: 2. * rs_amf; // simulation: request "a lot"
4355+
#endif
43484356

43494357
double znAmfSys = znSupReq / rs_ducts[ rs_DsHC()].ductLkXF[ 0];
43504358
rs_amfReq[ iAux] += znAmfSys; // all-zone total at system
@@ -4827,12 +4835,13 @@ static RC loadsIzxSh2() // interzone transfers, part 2
48274835
return rc;
48284836
} // ::loadsIzxSh2
48294837
//--------------------------------------------------------------------
4830-
static RC loadsXFans()
4838+
static RC loadsXFans() // SIMULATE zone exhaust fans (xfans)
48314839
{
4840+
RC rc = RCOK;
48324841
ZNR* zp;
48334842
RLUP( ZrB, zp)
4834-
zp->zn_XFan();
4835-
return RCOK;
4843+
rc |= zp->zn_XFan();
4844+
return rc;
48364845
} // ::loadsXFans
48374846
//--------------------------------------------------------------------
48384847
RC ZNR::zn_XFan() // zone exhaust fan calcs (hourly)

src/CNRECS.DEF

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,7 @@ RECORD RSYS "RSYS" *RAT // residential HVAC system
30683068
*declare "void rs_RddiInit();"
30693069
*declare "RC rs_pass1AtoB();"
30703070
*declare "RC rs_begP1b();"
3071-
*declare "RC rs_endP1DsdIter();"
3071+
*declare "RC rs_endP1DsdIter( int auszMode);"
30723072
*declare "RC rs_endAutosize();"
30733073
*declare "void rs_AuszFinal();"
30743074
*declare "float rs_ClgCapNomTons( float nearest=-1.f);"
@@ -3939,7 +3939,7 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
39393939
*declare "static int hw_HPWHInfo( WHASHPTYCH ashpTy, int& attrs);"
39403940
*declare "static int hw_IsAttr( WHASHPTYCH ashpTy, int attr) { int attrs; return hw_HPWHInfo( ashpTy, attrs) >= 0 ? (attr & attrs) != 0 : -1; }"
39413941
*declare "RC hw_InitPreset( WHASHPTYCH ashpTy);"
3942-
*declare "RC hw_InitResistance( float vol, float EF, float resHt, float resHt2);"
3942+
*declare "RC hw_InitResistance( WHRESTYCH resTy, float vol, float EF, float resHt, float resHt2, float tUse);"
39433943
*declare "RC hw_InitTank( float vol);"
39443944
*declare "RC hw_AdjustUAIf( float UA, float insulR, float tankCount=1.f);"
39453945
*declare "RC hw_InitFinalize( float inHtSupply, float inHtLoopRet);"
@@ -4073,8 +4073,10 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
40734073
*declare "int wh_GetFunction() const { return wh_fcn & 0xff; }"
40744074
*declare "int wh_SetFunction();"
40754075
*declare "bool wh_IsLastHeater() const { return (wh_fcn & whfcnLASTHEATER) != 0; }"
4076-
*i WHASHPTYCH wh_ashpTy; // air source heat pump (HPWH) type, required iff ASHPX, else ignored
4076+
*i WHASHPTYCH wh_ashpTy; // air source heat pump (HPWH) type, required iff wh_heatSrc=ASHPX, else ignored
40774077
// C_WHASHPTYCH_xxx, etc
4078+
*i WHRESTYCH wh_resTy; // resistance heater type, used iff wh_heatSrc=_ELRESX, else ignored
4079+
// C_WHRESTYCH_xxx, etc
40784080
*i TI wh_znTi; // DHWHEATER location zone re tank loss
40794081
// 0 iff wh_tEx being used
40804082
// heat losses go to half to zone air / half radiant

src/CUL.CPP

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ x name, strlen(name), sizeof(ANAME)-1 );
12931293
New record is all 0's (inits FsSET, FsVAL, FsERR, FsFROZ, etc to 0).
12941294
Default data can be supplied via STAR entry: see nuCult. Still??7-92 */
12951295
if (name) // if name given
1296-
strncpy( e->name, name, sizeof(ANAME)-1); // copy name into record
1296+
e->SetName( name); // copy name into record
12971297
// .fileIx & .line are set below, after LIKE/COPY/USETYPE
12981298

12991299
// do LIKE/COPY if given: look up record in this basAnc, copy data after name

src/DHWCalc.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,17 +2661,25 @@ RC HPWHLINK::hw_InitGeneric( // init HPWH as generic ASHP
26612661
} // HPWHLINK::hw_InitGeneric
26622662
//-----------------------------------------------------------------------------
26632663
RC HPWHLINK::hw_InitResistance( // set up HPWH has EF-rated resistance heater
2664-
float vol, // tank volume, gal
2665-
float EF, // rated EF
2666-
float resHtPwr, // upper resistance heat element power, W
2667-
float resHtPwr2)// lower resistance heat element power, W
2664+
WHRESTYCH resTy, // resistance heater type
2665+
float vol, // tank volume, gal
2666+
float EF, // rated EF
2667+
float resHtPwr, // upper resistance heat element power, W
2668+
float resHtPwr2, // lower resistance heat element power, W
2669+
float tUse) // use temp, F
26682670
// returns RCOK iff success
26692671
{
26702672
RC rc = RCOK;
26712673

2672-
if (hw_pHPWH->HPWHinit_resTank(GAL_TO_L(max(vol, 1.f)), EF,
2673-
resHtPwr, resHtPwr2) != 0)
2674+
int ret = resTy == C_WHRESTYCH_SWINGTANK
2675+
? hw_pHPWH->HPWHinit_resSwingTank(GAL_TO_L(max(vol, 1.f)), EF,
2676+
resHtPwr, resHtPwr2, F_TO_C( tUse))
2677+
: hw_pHPWH->HPWHinit_resTank(GAL_TO_L(max(vol, 1.f)), EF,
2678+
resHtPwr, resHtPwr2);
2679+
2680+
if (ret)
26742681
rc |= RCBAD;
2682+
26752683
return rc;
26762684
} // HPWHLINK::hw_InitResistance
26772685
//-----------------------------------------------------------------------------
@@ -3614,7 +3622,7 @@ RC DHWHEATER::wh_CkF() // water heater input check / default
36143622
else if (wh_heatSrc == C_WHHEATSRCCH_ASHPX)
36153623
{ // STRGSML or BUILTUP HPWH model
36163624
// TODO: more specific checking for ASHPX
3617-
ignoreN( whenHs, DHWHEATER_LDEF, DHWHEATER_RESHTPWR, DHWHEATER_RESHTPWR2, 0);
3625+
ignoreN( whenHs, DHWHEATER_LDEF, DHWHEATER_RESHTPWR, DHWHEATER_RESHTPWR2, DHWHEATER_RESTY, 0);
36183626
RC rc1 = requireN( whenHs, DHWHEATER_ASHPTY, 0);
36193627
rc |= rc1;
36203628
if (!rc1)
@@ -3703,7 +3711,7 @@ RC DHWHEATER::wh_CkF() // water heater input check / default
37033711

37043712
if (IsSet(DHWHEATER_VOLRUNNING))
37053713
{ if (!wh_CanSetVolFromVolRunning())
3706-
rc |= disallow(DHWHEATER_VOLRUNNING, whenTy);
3714+
rc |= disallow(DHWHEATER_VOLRUNNING, whenHs);
37073715
else if (IsSet(DHWHEATER_VOL))
37083716
rc |= oer("whVol and whVolRunning cannot both be specified");
37093717
}
@@ -3753,13 +3761,14 @@ int DHWHEATER::wh_CanSetVolFromVolRunning() const // can volume be derived from
37533761
// -1: maybe (re HPWH pending HPWHLINK setup)
37543762
{
37553763
int ret = 0;
3756-
if (wh_IsHPWHModel())
3764+
if (wh_heatSrc == C_WHHEATSRCCH_ASHPX)
37573765
{ ret = -1;
3758-
if (wh_HPWH.hw_HasCompressor()
3766+
if (wh_HPWH.hw_HasCompressor() // redundant *but* false if !hw_pHPWH
37593767
&& !wh_HPWH.hw_pHPWH->isTankSizeFixed())
37603768
ret = 1;
37613769
}
37623770
// else
3771+
// Other type (including C_WHHEATSRCCH_ELRESX): volRunning not supported
37633772
// ret = 0;
37643773

37653774
return ret;
@@ -4105,7 +4114,8 @@ RC DHWHEATER::wh_HPWHInit() // initialize HPWH model
41054114
if (wh_heatSrc == C_WHHEATSRCCH_ELRESX)
41064115
{ // resistance tank (no preset)
41074116
rc |= wh_HPWH.hw_InitResistance(
4108-
wh_vol, wh_EF, wh_resHtPwr, wh_resHtPwr2);
4117+
wh_resTy, wh_vol, wh_EF, wh_resHtPwr, wh_resHtPwr2, pWS->ws_tUse);
4118+
// bVolMaybeModifiable = true;
41094119
}
41104120
else if (wh_ashpTy == C_WHASHPTYCH_GENERIC)
41114121
{ // generic HPWH (no preset)
@@ -4160,17 +4170,16 @@ RC DHWHEATER::wh_HPWHInit() // initialize HPWH model
41604170
else if (IsSet(DHWHEATER_VOLRUNNING))
41614171
{ // semi-redundant check
41624172
if (!wh_CanSetVolFromVolRunning())
4163-
rc |= ooer(DHWHEATER_VOLRUNNING, "no can do");
4173+
oInfo("%s is ignored (tank volume is fixed at %0.0f gal)",
4174+
what, wh_HPWH.hw_pHPWH->getTankSize(HPWH::UNITS_GAL));
41644175
else
4165-
{
4166-
RC rc2 = wh_HPWH.hw_DeriveVolFromVolRunning(
4176+
{ RC rc2 = wh_HPWH.hw_DeriveVolFromVolRunning(
41674177
wh_volRunning,
41684178
wh_heatingCap,
41694179
pWS->ws_tSetpointDes - pWS->ws_tInletDes,
41704180
vol);
41714181
if (rc2)
41724182
rc |= err(PERR, "DHWHEATER::wh_HPWHInit: hw_CanSetVolFromVolRunning() inconsistency.");
4173-
// else wh_vol already known
41744183
}
41754184
}
41764185
else // IsSet( DHWHEATER_VOL)

src/IMPF.CPP

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ LOCAL RC impFcnFile( // find or add IFFNM record
442442
*pIffnmi = iffnm->ss; // return added record subscript
443443

444444
// use IMPORTFILE given object name as record name, for later association with IMPORTFILEs.
445-
strncpy( iffnm->name, impfName, sizeof(ANAME)-1 );
445+
iffnm->SetName( impfName);
446446

447447
// put source file index and line in record so (first) use can be reported in errmsg eg if no IMPF for IFFNM.
448448
iffnm->fileIx = fileIx;

0 commit comments

Comments
 (0)