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: 4 additions & 2 deletions src/CGCOMP.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,10 @@ TI ZNR::zn_AddIZXFER( // add IZXFER coupled to this zone
IZXRAT* ize;
IzxR.add( &ize, ABT);

strcpy( ize->name, name);
strCatIf( ize->name, sizeof( ize->name), "-", nmSfx);
ize->SetName( name);
// append suffix
int catOption = 1; // attempt to truncate name size exceeded
strCatIf( ize->name, sizeof( ize->name), "-", nmSfx, catOption);
ize->iz_zi1 = ss; // idx of this zone
ize->iz_nvcntrl = ty;
ize->iz_pAF = pAF;
Expand Down
1 change: 1 addition & 0 deletions src/CNCULT.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,7 @@ CULT( "whType", DAT, DHWHEATER_TYPE, 0, 0, VEOI, TYCH, 0,
CULT( "whHeatSrc", DAT, DHWHEATER_HEATSRC, 0, 0, VEOI, TYCH, 0, C_WHHEATSRCCH_FUEL, N, N),
CULT( "whZone", DAT, DHWHEATER_ZNTI, 0, 0, VEOI, TYREF, &ZiB, 0, N, N),
CULT( "whTEx", DAT, DHWHEATER_TEX, 0, 0, VSUBHRLY,TYFL, 0, 70.f, N, N),
CULT( "whResType", DAT, DHWHEATER_RESTY, 0, 0, VEOI, TYCH, 0, C_WHRESTYCH_TYPICAL,N, N),
CULT( "whASHPType", DAT, DHWHEATER_ASHPTY, 0, 0, VEOI, TYCH, 0, -1, N, N),
CULT( "whASHPSrcZn", DAT, DHWHEATER_ASHPSRCZNTI,0, 0, VEOI, TYREF, &ZiB, 0, N, N),
CULT( "whASHPSrcT", DAT, DHWHEATER_ASHPTSRC,0, 0, VSUBHRLY,TYFL, 0, 70.f, N, N),
Expand Down
20 changes: 10 additions & 10 deletions src/CNCULT4.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ LOCAL RC addRep( TI rfi, char *name, RPTYCH rpTy, TI zi, IVLCH freq, SI putAtEnd
UCH *fs;
RC rc;

E( RiB.add( &rp, WRN) ) // add report input record (ancrec.cpp) / return if error
strncpy( rp->name, name, sizeof(ANAME)-1 ); // record name, for like/alter/delete
rp->zi = zi; // 0, TI_SUM, or TI_ALL (or reference to a zone)
E( RiB.add( &rp, WRN) ) // add report input record (ancrec.cpp) / return if error
rp->SetName( name); // record name, for like/alter/delete
rp->zi = zi; // 0, TI_SUM, or TI_ALL (or reference to a zone)
rp->ownTi = rfi; // reference to report file
rp->rpTy = rpTy; // type of report
rp->rpFreq = freq; // 0 or frequency of report
Expand Down Expand Up @@ -1817,10 +1817,10 @@ LOCAL void addHdayDate( char *name, DOY date) // add holiday celebrated on spe
{
// for topPrfHday
HDAY *hdi;
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
strncpy( hdi->name, name, sizeof(ANAME)-1 ); // record name, for like/alter/delete and error messages
hdi->hdDateTrue = date; // store true date
hdi->hdOnMonday = C_NOYESCH_YES; // say observe on following monday if falls on weekend
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
hdi->SetName( name); // record name, for like/alter/delete and error messages
hdi->hdDateTrue = date; // store true date
hdi->hdOnMonday = C_NOYESCH_YES; // say observe on following monday if falls on weekend
// topHday will set hdDateObs.
} // addHdayDate
//---------------------------------------------------------------------------------------------------------------------------
Expand All @@ -1829,9 +1829,9 @@ LOCAL void addHdayRule( char *name, HDAYCASECH hdCase, DOWCH dow, MONTH mon)
{
// for topPrfHday
HDAY *hdi;
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
strncpy( hdi->name, name, sizeof(ANAME)-1 ); // record name, for like/alter/delete
hdi->hdCase = hdCase; // store arguments
if (HdayiB.add( &hdi, WRN)) return; // add holiday input record (ancrec.cpp) / return if error (msg issued)
hdi->SetName( name); // record name, for like/alter/delete
hdi->hdCase = hdCase; // store arguments
hdi->hdDow = dow;
hdi->hdMon = mon;
// topHday will set hdDateTrue and hdDateObs.
Expand Down
5 changes: 5 additions & 0 deletions src/CNDTYPES.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ PIPESEGP -- "class PIPESEG*" 4 none
SCALABLE_SP "Scalable_SP" // scalable type for autosized standard design
}

*choicb WHRESTYCH { // resistance heater types
TYPICAL "Typical"
SWINGTANK "SwingTank"
}

*choicb DHWEUCH { // hot end uses
FAUCET "Faucet"
SHOWER "Shower"
Expand Down
1 change: 1 addition & 0 deletions src/CNFIELDS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ WHTYPECH WHTYPECH LMNONE UNNONE
WHHEATSRCCH WHHEATSRCCH LMNONE UNNONE
WSCALCMODECH WSCALCMODECH LMNONE UNNONE
WHASHPTYCH WHASHPTYCH LMNONE UNNONE
WHRESTYCH WHRESTYCH LMNONE UNNONE
DHWEUCH DHWEUCH LMNONE UNNONE
DHWEUXCH DHWEUXCH LMNONE UNNONE
DHWBRANCHMODELCH DHWBRANCHMODELCH LMNONE UNNONE
Expand Down
39 changes: 24 additions & 15 deletions src/CNLOADS.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -2055,10 +2055,10 @@ void RSYS::rs_RddiInit() // init before each autosize design day ITERATION
}
} // RSYS::rs_RddiInit
//-----------------------------------------------------------------------------
RC RSYS::rs_endP1DsdIter()
RC RSYS::rs_endP1DsdIter( // autosizing end of day
int auszMode) // rsmHEAT, rsmCOOL
{
RC rc = RCOK;
int auszMode = rs_IsAutoSizing();
if (auszMode == rsmHEAT)
{ // note: rs_fxCapHDay = 20 if no load
float f = rs_fxCapHAsF / max( rs_fxCapHDay, .01f);
Expand Down Expand Up @@ -2107,13 +2107,10 @@ RC RSYS::rs_endP1DsdIter()
float fX = bracket( .9f, errX+1.f, 1.1f);
rs_cap95 *= fX;

#if 1
if (rs_cap95 < 1200.f)
rs_cap95 = 1200.f; // never < 0.1 ton
else
#endif
if (rs_cap95 < rs_auszC.az_b)
rs_cap95 = rs_auszC.az_b; // never < previous design day peak
float cap95min = max(rs_auszC.az_b, 1200.f);
if (rs_cap95 < cap95min)
rs_cap95 = cap95min; // never < 0.1 ton
// never < previous design day peak
}

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

if (Top.isEndDay)
{ // last step of day
rc = rs_endP1DsdIter();
int auszMode = rs_IsAutoSizing();
if (auszMode != rsmOFF)
rc = rs_endP1DsdIter( auszMode);
}

// prior interval values: none

return rc;
} // RSYS::rs_AfterHour
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -4336,15 +4338,21 @@ double RSYS::rs_ZoneAirRequest( // air quantity needed by zone
if (znSupReq > 1.e10) // znSupReq = DBL_MAX if supplyDT is tiny
znSupReq = rs_amf;
else if (znSupReq < 0.)
// reverse flow (caused by "backwards" supplyDT)
// reverse flow
// caused by "flipped" supply DT
// due to e.g. big duct losses
znSupReq =
#if 1
#if 1 // attempt to fix small load sizing, 7-16-2021
2. * rs_amf; // request "a lot"
#else
#if 1 // unknown date
Top.tp_autoSizing
#else
Top.tp_pass1A
#endif
? 1. // autosize warmup: ignore
: 2. * rs_amf; // simulation: request "a lot"
#endif

double znAmfSys = znSupReq / rs_ducts[ rs_DsHC()].ductLkXF[ 0];
rs_amfReq[ iAux] += znAmfSys; // all-zone total at system
Expand Down Expand Up @@ -4827,12 +4835,13 @@ static RC loadsIzxSh2() // interzone transfers, part 2
return rc;
} // ::loadsIzxSh2
//--------------------------------------------------------------------
static RC loadsXFans()
static RC loadsXFans() // SIMULATE zone exhaust fans (xfans)
{
RC rc = RCOK;
ZNR* zp;
RLUP( ZrB, zp)
zp->zn_XFan();
return RCOK;
rc |= zp->zn_XFan();
return rc;
} // ::loadsXFans
//--------------------------------------------------------------------
RC ZNR::zn_XFan() // zone exhaust fan calcs (hourly)
Expand Down
8 changes: 5 additions & 3 deletions src/CNRECS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -3068,7 +3068,7 @@ RECORD RSYS "RSYS" *RAT // residential HVAC system
*declare "void rs_RddiInit();"
*declare "RC rs_pass1AtoB();"
*declare "RC rs_begP1b();"
*declare "RC rs_endP1DsdIter();"
*declare "RC rs_endP1DsdIter( int auszMode);"
*declare "RC rs_endAutosize();"
*declare "void rs_AuszFinal();"
*declare "float rs_ClgCapNomTons( float nearest=-1.f);"
Expand Down Expand Up @@ -3939,7 +3939,7 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
*declare "static int hw_HPWHInfo( WHASHPTYCH ashpTy, int& attrs);"
*declare "static int hw_IsAttr( WHASHPTYCH ashpTy, int attr) { int attrs; return hw_HPWHInfo( ashpTy, attrs) >= 0 ? (attr & attrs) != 0 : -1; }"
*declare "RC hw_InitPreset( WHASHPTYCH ashpTy);"
*declare "RC hw_InitResistance( float vol, float EF, float resHt, float resHt2);"
*declare "RC hw_InitResistance( WHRESTYCH resTy, float vol, float EF, float resHt, float resHt2, float tUse);"
*declare "RC hw_InitTank( float vol);"
*declare "RC hw_AdjustUAIf( float UA, float insulR, float tankCount=1.f);"
*declare "RC hw_InitFinalize( float inHtSupply, float inHtLoopRet);"
Expand Down Expand Up @@ -4073,8 +4073,10 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
*declare "int wh_GetFunction() const { return wh_fcn & 0xff; }"
*declare "int wh_SetFunction();"
*declare "bool wh_IsLastHeater() const { return (wh_fcn & whfcnLASTHEATER) != 0; }"
*i WHASHPTYCH wh_ashpTy; // air source heat pump (HPWH) type, required iff ASHPX, else ignored
*i WHASHPTYCH wh_ashpTy; // air source heat pump (HPWH) type, required iff wh_heatSrc=ASHPX, else ignored
// C_WHASHPTYCH_xxx, etc
*i WHRESTYCH wh_resTy; // resistance heater type, used iff wh_heatSrc=_ELRESX, else ignored
// C_WHRESTYCH_xxx, etc
*i TI wh_znTi; // DHWHEATER location zone re tank loss
// 0 iff wh_tEx being used
// heat losses go to half to zone air / half radiant
Expand Down
2 changes: 1 addition & 1 deletion src/CUL.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ x name, strlen(name), sizeof(ANAME)-1 );
New record is all 0's (inits FsSET, FsVAL, FsERR, FsFROZ, etc to 0).
Default data can be supplied via STAR entry: see nuCult. Still??7-92 */
if (name) // if name given
strncpy( e->name, name, sizeof(ANAME)-1); // copy name into record
e->SetName( name); // copy name into record
// .fileIx & .line are set below, after LIKE/COPY/USETYPE

// do LIKE/COPY if given: look up record in this basAnc, copy data after name
Expand Down
39 changes: 24 additions & 15 deletions src/DHWCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2661,17 +2661,25 @@ RC HPWHLINK::hw_InitGeneric( // init HPWH as generic ASHP
} // HPWHLINK::hw_InitGeneric
//-----------------------------------------------------------------------------
RC HPWHLINK::hw_InitResistance( // set up HPWH has EF-rated resistance heater
float vol, // tank volume, gal
float EF, // rated EF
float resHtPwr, // upper resistance heat element power, W
float resHtPwr2)// lower resistance heat element power, W
WHRESTYCH resTy, // resistance heater type
float vol, // tank volume, gal
float EF, // rated EF
float resHtPwr, // upper resistance heat element power, W
float resHtPwr2, // lower resistance heat element power, W
float tUse) // use temp, F
// returns RCOK iff success
{
RC rc = RCOK;

if (hw_pHPWH->HPWHinit_resTank(GAL_TO_L(max(vol, 1.f)), EF,
resHtPwr, resHtPwr2) != 0)
int ret = resTy == C_WHRESTYCH_SWINGTANK
? hw_pHPWH->HPWHinit_resSwingTank(GAL_TO_L(max(vol, 1.f)), EF,
resHtPwr, resHtPwr2, F_TO_C( tUse))
: hw_pHPWH->HPWHinit_resTank(GAL_TO_L(max(vol, 1.f)), EF,
resHtPwr, resHtPwr2);

if (ret)
rc |= RCBAD;

return rc;
} // HPWHLINK::hw_InitResistance
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -3614,7 +3622,7 @@ RC DHWHEATER::wh_CkF() // water heater input check / default
else if (wh_heatSrc == C_WHHEATSRCCH_ASHPX)
{ // STRGSML or BUILTUP HPWH model
// TODO: more specific checking for ASHPX
ignoreN( whenHs, DHWHEATER_LDEF, DHWHEATER_RESHTPWR, DHWHEATER_RESHTPWR2, 0);
ignoreN( whenHs, DHWHEATER_LDEF, DHWHEATER_RESHTPWR, DHWHEATER_RESHTPWR2, DHWHEATER_RESTY, 0);
RC rc1 = requireN( whenHs, DHWHEATER_ASHPTY, 0);
rc |= rc1;
if (!rc1)
Expand Down Expand Up @@ -3703,7 +3711,7 @@ RC DHWHEATER::wh_CkF() // water heater input check / default

if (IsSet(DHWHEATER_VOLRUNNING))
{ if (!wh_CanSetVolFromVolRunning())
rc |= disallow(DHWHEATER_VOLRUNNING, whenTy);
rc |= disallow(DHWHEATER_VOLRUNNING, whenHs);
else if (IsSet(DHWHEATER_VOL))
rc |= oer("whVol and whVolRunning cannot both be specified");
}
Expand Down Expand Up @@ -3753,13 +3761,14 @@ int DHWHEATER::wh_CanSetVolFromVolRunning() const // can volume be derived from
// -1: maybe (re HPWH pending HPWHLINK setup)
{
int ret = 0;
if (wh_IsHPWHModel())
if (wh_heatSrc == C_WHHEATSRCCH_ASHPX)
{ ret = -1;
if (wh_HPWH.hw_HasCompressor()
if (wh_HPWH.hw_HasCompressor() // redundant *but* false if !hw_pHPWH
&& !wh_HPWH.hw_pHPWH->isTankSizeFixed())
ret = 1;
}
// else
// Other type (including C_WHHEATSRCCH_ELRESX): volRunning not supported
// ret = 0;

return ret;
Expand Down Expand Up @@ -4105,7 +4114,8 @@ RC DHWHEATER::wh_HPWHInit() // initialize HPWH model
if (wh_heatSrc == C_WHHEATSRCCH_ELRESX)
{ // resistance tank (no preset)
rc |= wh_HPWH.hw_InitResistance(
wh_vol, wh_EF, wh_resHtPwr, wh_resHtPwr2);
wh_resTy, wh_vol, wh_EF, wh_resHtPwr, wh_resHtPwr2, pWS->ws_tUse);
// bVolMaybeModifiable = true;
}
else if (wh_ashpTy == C_WHASHPTYCH_GENERIC)
{ // generic HPWH (no preset)
Expand Down Expand Up @@ -4160,17 +4170,16 @@ RC DHWHEATER::wh_HPWHInit() // initialize HPWH model
else if (IsSet(DHWHEATER_VOLRUNNING))
{ // semi-redundant check
if (!wh_CanSetVolFromVolRunning())
rc |= ooer(DHWHEATER_VOLRUNNING, "no can do");
oInfo("%s is ignored (tank volume is fixed at %0.0f gal)",
what, wh_HPWH.hw_pHPWH->getTankSize(HPWH::UNITS_GAL));
else
{
RC rc2 = wh_HPWH.hw_DeriveVolFromVolRunning(
{ RC rc2 = wh_HPWH.hw_DeriveVolFromVolRunning(
wh_volRunning,
wh_heatingCap,
pWS->ws_tSetpointDes - pWS->ws_tInletDes,
vol);
if (rc2)
rc |= err(PERR, "DHWHEATER::wh_HPWHInit: hw_CanSetVolFromVolRunning() inconsistency.");
// else wh_vol already known
}
}
else // IsSet( DHWHEATER_VOL)
Expand Down
2 changes: 1 addition & 1 deletion src/IMPF.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ LOCAL RC impFcnFile( // find or add IFFNM record
*pIffnmi = iffnm->ss; // return added record subscript

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

// put source file index and line in record so (first) use can be reported in errmsg eg if no IMPF for IFFNM.
iffnm->fileIx = fileIx;
Expand Down
34 changes: 27 additions & 7 deletions src/STRPAK.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ x#endif
// ====================================================================
char * FC strtemp( // allocate n+1 bytes in temp string buffer (Tmpstr[])

SI n ) // number of bytes needed, less 1 (1 added here eg for null, 9-89)
size_t n ) // number of bytes needed, less 1 (1 added here eg for null)

// returns pointer to space in Tmpstr : Valid for a (very) short while

Expand Down Expand Up @@ -1038,8 +1038,13 @@ char* strTranslateEscapes( // translate standard escape sequences
return d;
} // strTranslateEscapes
//----------------------------------------------------------------------------
char* strCatIf( char* d, size_t dSize, const char *brk, const char* s)
// conditional concatenate
char* strCatIf( // conditional concatenation
char* d, // input / destination
size_t dSize, // dim of d (including space for \0)
const char* brk, // break, e.g. "-" or ", "
const char* s, // concat string
int options /*=0*/) // options
// 1: attempt to truncate d if dSize exceeded
// adds break string iff both d and s non-null --
// d s result
// --- --- -------
Expand All @@ -1048,16 +1053,31 @@ char* strCatIf( char* d, size_t dSize, const char *brk, const char* s)
// "" "s" "s"
// "d" "s" "d" + brk + "s"

// returns d
// returns NULL if combined result length exceeds dSize
// else d (updated)
{
// 7-2021 prior code used strcat_s. However, library code
// throws on too long altho docs say it returns errno_t.
// Modified to check length here and use strcat()
if ( s && *s) // if s contains a string
{ if (*d) // if d not ""
strcat_s( d, dSize, brk); // add break string
strcat_s( d, dSize, s); // add s
{ size_t dLen = strlen(d);
size_t len = dLen ? dLen + strlen(brk) + strlen(s) : 0;
if (len >= dSize)
{ size_t dLenMax = dSize - (len - dLen) - 1;
if (dLen < dLenMax || !(options & 1))
return NULL; // result does not fit
else
d[ dLenMax] = '\0';
}
if (*d) // if d not ""
strcat(d, brk); // add break string
strcat( d, s); // add s
}
return d;
} // strCatIf
//-------------------------------------------------------------------------
//
//-------------------------------------------------------------------------
char* strPluralize( // form plural of a word
char* d, // returned: maybe pluralized word (case generally
// preserved)
Expand Down
4 changes: 2 additions & 2 deletions src/STRPAK.H
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ char * FC strtBsDouble( char *s);
char * FC strBsUnDouble( char *s);
char * FC strsave( const char *s);
char * strsave( char* &p, const char *s);
char * FC strtemp( SI n);
char * FC strtemp( size_t n);
char * FC strtempPop( char *anS);
char * FC strtmp( const char *s);
char * CDEC strtcat( const char *s, ... );
Expand Down Expand Up @@ -137,7 +137,7 @@ BOOL IsBlank( const char* s, int len=999999);
char* strFill( char* d, const char* s, int len=-1);
const char* strSuffix(int n, int options = 0);
char* strTranslateEscapes( char* d, const char* s=NULL);
char* strCatIf( char* d, size_t dSize, const char* brk, const char* s);
char* strCatIf( char* d, size_t dSize, const char* brk, const char* s, int options=0);
char* strDeBar( char* d, const char* s=NULL);
char* strDeQuote( char* d, const char* s=NULL);
char* strDeWS( char* d, const char* s=NULL);
Expand Down
Loading