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
10 changes: 5 additions & 5 deletions src/ANCREC.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ record::record( BP _b, TI i, SI noZ/*=0*/) // construct record i of basAnc b,
b->n++ : additional record in static array.
CAUTION can be called from statSetup (til eliminated). */

_b->validate("record::record"); // abort if base bad -- we depend on it for size
if (!noZ) // can be suppressed for data-init (static) records
_b->validate("record::record"); // abort if base bad -- we depend on it for size
if (!noZ) // can be suppressed for data-init (static) records
memset( (char *)this+SZVFTP, 0, _b->eSz-SZVFTP); /* zero all members of DERIVED CLASS record
except virtFcnTblPtr in 1st 2 or 4 bytes (ancrec.h define) */
b = _b;
Expand Down Expand Up @@ -685,9 +685,9 @@ SI FC basAnc::ancNext( USI &an, BP * _b) // (registered) record anchor iterator
//---------------------------------------------------------------------------------------------------------------------------
RC basAnc::validate( // validate an anchor: check self-consistency of anchor and its entry 0

char *fcnName, // calling fcn name, for err msgs.
int erOp /*=ABT*/, // reporting control. ABT-->PABT, WRN-->PWRN here.
SI noStat /*=0*/ ) // 0: caller's action OK on static-storage anchor. nz: not ok.
const char* fcnName, // calling fcn name, for err msgs.
int erOp /*=ABT*/, // reporting control. ABT-->PABT, WRN-->PWRN here.
SI noStat /*=0*/ ) // 0: caller's action OK on static-storage anchor. nz: not ok.

// if error, issues message, returns non-RCOK if not ABT
{
Expand Down
2 changes: 1 addition & 1 deletion src/ANCREC.H
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class basAnc // base class for record anchors: basAnc<recordName>
static BP FC anc4n( USI an, int erOp=ABT); // access anchor by anchor #
static RC FC findAnchorByNm( char *what, BP *b);
static SI FC ancNext( USI &an, BP *_b); // iterate anchors
RC validate( char *fcnName, int erOp=ABT, SI noStat=0); // check for valid anchor
RC validate( const char* fcnName, int erOp=ABT, SI noStat=0); // check for valid anchor
RC findRecByNm1( const char* _name, TI *_i, record **_r); // find record by 1st match on name
RC findRecByNmU( const char* _name, TI *_i, record **_r); // find record by unique name match
RC findRecByNmO( const char* _name, TI ownTi, TI *_i, record **_r); // find record by name and owner subscript
Expand Down
42 changes: 37 additions & 5 deletions src/CGCOMP.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,12 @@ RSYS* DUCTSEG::ds_GetRSYS() const
return pRS;
} // DUCTSEG::ds_GetRSYS
//-----------------------------------------------------------------------------
bool DUCTSEG::ds_IsRound() const
{ // if ds_exArea is input, assume flat area-only model
// else round
return !IsSet( DUCTSEG_EXAREA);
} // DUCTSEG::ds_IsRound
//-----------------------------------------------------------------------------
RC DUCTSEG::ds_TopDS( // set up run record
const DUCTSEG* pDSi) // input record
// caller must allocate this (in DsR)
Expand All @@ -1646,10 +1652,7 @@ RC DUCTSEG::ds_TopDS( // set up run record

Copy( pDSi); // copy record, incl name, excl internal front overhead.

BOOL bRound = !IsSet( DUCTSEG_EXAREA); // if exterior area is specified
// assume flat config (no radius adj)

if (bRound)
if (ds_IsRound())
{ if (!IsSet( DUCTSEG_DIAM))
{ if (ds_len > 0.f)
ds_diam = ds_inArea / (kPi * ds_len);
Expand Down Expand Up @@ -1698,7 +1701,7 @@ RC DUCTSEG::ds_TopDS( // set up run record
ds_RconvIn = 0.4; // approx inside convection resistance, ft2-F/Btuh
// derived per HOF correlations per typical diam, temp, vel
if (rc == RCOK)
{ if (bRound)
{ if (ds_IsRound())
{ // round configuration
double diamOut = ds_diam + 2.*ds_insulThk;
double diamRat = diamOut / ds_diam; // ratio of outside to inside diameter
Expand Down Expand Up @@ -1744,6 +1747,35 @@ void DUCTSEG::ds_SetRunConstants() // set constants that do not vary during sim
ZNR* zpx = ds_GetExZone(); // zone outside duct (NULL if none)
ds_sbcO.sb_SetRunConstants( zpx);
} // DUCTSEG::ds_SetRunConstants
//----------------------------------------------------------------------------
#if 0
RC DUCTSEG::ds_SetSizeFromAVF( // adjust diameter based on flow
float avf) // design air volume flow, cfm
{
const RSYS* pRS = ds_GetRSYS();

// # of runs
int nR = pRS->rs_areaServed / ds_desAirVel;

float avfPerRun = avf / ds_nDuctRun;

float ductArea = avfPerRun / ds_airVelDs;

ds_diam = 2.f * sqrt( ductArea / kPi);


} // DUCTSEG::ds_SetSizeFromAVF
//-----------------------------------------------------------------------------
int DUCTSEG::ds_GetDuctRunInfo(
float& runLen) // average run length, ft
// returns # of runs
{
const RSYS* pRS = ds_GetRSYS();

// # of runs
int nR = max( 1, iRound( pRS->rs_areaServed / ds_CFAperRun));
} // DUCTSEG::ds_GetRunInfo
#endif
//-----------------------------------------------------------------------------
RC DUCTSEG::ds_BegHour()
{
Expand Down
134 changes: 117 additions & 17 deletions src/CGWTHR.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,33 @@ void FC cgWthrClean( // cgwthr overall init/cleanup routine
cgWfDone(); // close any open weather file

// init weather file info record
Wfile.wf_Init(); // mbr function in wfpak.cpp sets record to say no file open
Wthr.wd_Init(); // mbr function in wfpak.cpp clears record
WthrNxHr.wd_Init(); // mbr function in wfpak.cpp clears record
Wfile.wf_Init(); // sets record to say no file open
Wthr.wd_Init(); // clears record
WthrNxHr.wd_Init(); // clears record

// add any other init/cleanup found necessary or desirable

} // cgWthrClean
//---------------------------------------------------------------------------
RC TOPRAT::tp_WfInit() // Initialize weather file. Displays any error messages.
// also uses: Top.tp_wfName [,.isDT]
RC TOPRAT::tp_WthrInit() // Initialize weather data/ display any error messages.
// also uses: tp_wfName, tp_TDVfName, [,.isDT]
// returns non-RCOK if error, message already issued.
{
RC rc = Wfile.wf_Open( tp_wfName, tp_TDVfName); // open wthr file and option TDV file
// init WFILE object, msg if error.
if (!rc)
rc = Wfile.wf_FillWDYEAR( WRN);
rc = Wfile.wf_FillWDYEAR( WRN); // read/cache entire weather file
// TODO: handle partial years

// design conditions
// set any derived values
// WHY here: location dependence, call after locinit
DESCOND* pDC;
RLUP( DcR, pDC)
rc |= pDC->dc_RunInit();

return rc;
} // TOPRAT::tp_WfInit
} // TOPRAT::tp_WthrInit
//---------------------------------------------------------------------------
RC TOPRAT::tp_WthrBegHour() // start-hour weather stuff: read file, set up public Wthr and Top members.
// tp_WthrBegSubhr must also be called, after this function.
Expand Down Expand Up @@ -345,7 +354,7 @@ RC WDHR::wd_WfReader( // read an hour's weather data and make adjustments
int iHrST = Top.iHrST; // hour 0-23, standard time.
int wfOp = WF_SAVESLRGEOM; // wf_Read(): do not overwrite solar geometry values
if (Top.isDT)
wfOp |= WF_DSTFIX; // wf_Read(): taDbPvPk during daylight savings
wfOp |= WF_DSTFIX; // wf_Read(): handle day-transition values during DST
RC rc = RCOK;

// modify iHrST and jDayST as needed
Expand Down Expand Up @@ -432,7 +441,7 @@ RC WDHR::wd_WfReader( // read an hour's weather data and make adjustments
if (Top.tp_AuszWthrSource() == TOPRAT_COOLDSCOND)
{ // DSCOND design day: overwrite/adjust weather file values with generated
int iDC = Top.tp_coolDsCond[ Top.tp_dsDayI-1];
const DESCOND& DC = DCiB[ iDC];
const DESCOND& DC = DcR[ iDC];
wd_FillFromDESCOND( DC, iHrST);
}
}
Expand Down Expand Up @@ -517,7 +526,7 @@ RC WDHR::wd_WfReader( // read an hour's weather data and make adjustments
rc = pWF->wf_Read( jDayST, iHrST, this, WRN|wfOp); // Read hour's data from weather file
if (Top.tp_AuszWthrSource() == TOPRAT_COOLDSCOND)
{ int iDC = Top.tp_coolDsCond[ Top.tp_dsDayI-1];
const DESCOND& DC = DCiB[ iDC];
const DESCOND& DC = DcR[ iDC];
DC.dc_GenerateTemps( iHrST, this);

}
Expand Down Expand Up @@ -611,11 +620,12 @@ void WDHR::wd_FillFromDESCOND( // overwrite/adjust hourly data for design condi
wd_taDbAvg14 += dbAvgDiff / 14.f;
wd_taDbAvg31 += dbAvgDiff / 31.f;


wd_wndSpd = dc.dc_wndSpd;
wd_wndDir = 0.f;

if (wd_sunup)
// derive irradiance
// note: tauB/tauD both 0 -> no solar
if (wd_sunup && dc.dc_tauB > 0.f && dc.dc_tauD > 0.f)
wd_glrad = slASHRAETauModel(
kPiOver2 - wd_slAlt,
dc.dc_tauB, dc.dc_tauD,
Expand All @@ -636,17 +646,107 @@ void WDHR::wd_FillFromDESCOND( // overwrite/adjust hourly data for design condi
/////////////////////////////////////////////////////////////////////////////
RC DESCOND::dc_CkF() // check after input
{ RC rc = RCOK;
if (dc_MCWB > dc_DB)
rc |= oer( "dcMCWB (%g) must be <= dcDB (%g)", dc_MCWB, dc_DB);
return rc;
} // DESCOND::dc_CkF
//-----------------------------------------------------------------------------
DOY DESCOND::dc_GetDOY() const
#if defined( _DEBUG)
static void DCTauTest( int doy)
{
return dc_day;
float ebnlist[] = { 150.f, 200.f, 250.f, 300.f, -1.f };
float edflist[] = { 20.f, 30.f, 40.f };

DESCOND dc( &DcR, 1);
dc.dc_doy = doy;
strcpy( dc.name, "Test");

for (int ib=0; ebnlist[ ib]>=0.f; ib++)
{ dc.dc_ebnSlrNoon = ebnlist[ ib];
for (int id=0; edflist[ id]>=0.f; id++)
{ dc.dc_edhSlrNoon = edflist[ id];
dc.dc_CheckFixSolar( 0);
}
}
} // DCTauTest
#endif
//------------------------------------------------------------------------------
RC DESCOND::dc_RunInit() // init for run
// call after all input-time expressions have been evaluated
// call after locInit (re latitude dependency)
{
#if defined( _DEBUG)
static int tested = 0;
if (!tested)
{ DCTauTest( dc_doy);
tested++;
}
#endif

} // DESCOND::dc_GetDOY
RC rc = RCOK;

if (dc_MCWB > dc_DB)
rc |= oer( "dcMCWB (%g) must be <= dcDB (%g)", dc_MCWB, dc_DB);

// if any solar values given, check and cross-derive
// else leave all 0 = no solar
if (dc_tauB + dc_tauD + dc_ebnSlrNoon + dc_edhSlrNoon > 0.f)
{ int nTau = IsSetCount( DESCOND_TAUB, DESCOND_TAUD, 0);
int nE = IsSetCount( DESCOND_EBNSLRNOON, DESCOND_EDHSLRNOON, 0);
if (nTau == 0)
rc |= dc_CheckFixSolar( 0); // derive tauB / tauD
else if (nE == 0)
rc |= dc_CheckFixSolar( 1); // derive Ebn / Edh
else
rc |= oer( "must give either dcTauB/dcTauD and"
" not dcEbnSlrNoon/dcEdhSlrNoon or vice-versa");
}
else
oInfo( "no irradiance due to dcTauB/dcTauD/dcEbnSlrNoon/dcEdhSlrNoon all 0");

return rc;
} // DESCOND::dc_RunInit
//-----------------------------------------------------------------------------
RC DESCOND::dc_CheckFixSolar(
int options) // option bits
// 0: derive tau from solar noon
// 1: derive solar noon from tau
{
RC rc = RCOK;

// solar noon angles
slday( dc_doy, SLTMSOLAR, 1);
float sunAlt, sunAzm;
slaltazm( 12.f, &sunAlt, &sunAzm);
float sunZen = kPiOver2 - sunAlt;

if (options & 1)
{ rc |= limitCheck( DESCOND_TAUB, .08, 1.)
| limitCheck( DESCOND_TAUD, 1.2, 3.2);
if (!rc)
slASHRAETauModel( sunZen, dc_tauB, dc_tauD,
dc_ebnSlrNoon, dc_edhSlrNoon);
}
else
{ rc |= limitCheck( DESCOND_EBNSLRNOON, 0., 370.)
| limitCheck( DESCOND_EDHSLRNOON, 0., 110.);
if (!rc)
{ bool ret = slASHRAETauModelInv( sunZen, dc_ebnSlrNoon, dc_edhSlrNoon,
dc_tauB, dc_tauD);
if (!ret)
rc = oer( "failed to derive dcTauB and dcTauD."
" Check dcEbnSlrNoon and dcEdhSlrNoon input values.");
#if defined( _DEBUG)
else
{ float ebn, edh;
float egl = slASHRAETauModel( sunZen, dc_tauB, dc_tauD, ebn, edh);
if (frDiff( ebn, dc_ebnSlrNoon) > .01f
|| frDiff( edh, dc_edhSlrNoon) > .01f)
oWarn( "ebn/edh mismatch");
}
#endif
}
}
return rc;
} // DESCOND::dc_CheckFixSolar
//-----------------------------------------------------------------------------
void DESCOND::dc_GenerateTemps(
int iHr, // hour of day (0 - 23)
Expand Down
4 changes: 2 additions & 2 deletions src/CNAUSZ.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const char* TOPRAT::tp_AuszDoing() const // current autosizing activity
else
{ int auszDoy;
if (iAWS == TOPRAT_COOLDSCOND)
auszDoy = DCiB[ tp_coolDsCond[ iDs]].dc_GetDOY();
auszDoy = DcR[ tp_coolDsCond[ iDs]].dc_GetDOY();
else if (iAWS == TOPRAT_COOLDSDAY)
auszDoy = tp_coolDsDay[ iDs];
if (auszDoy > 0)
Expand Down Expand Up @@ -232,7 +232,7 @@ x tp_dsDay = 1 + (tp_dsDayI != 0); // 1st desDay is heating (1), others coolin
auszMon = tp_date.month;
}
else if (tp_AuszWthrSource() == TOPRAT_COOLDSCOND)
{ const DESCOND* pDC = DCiB.GetAtSafe( tp_coolDsCond[ tp_dsDayI-1]);
{ const DESCOND* pDC = DcR.GetAtSafe( tp_coolDsCond[ tp_dsDayI-1]);
jDay = pDC->dc_GetDOY();
tddyi( tp_date, jDay);
auszMon = tp_date.month;
Expand Down
33 changes: 25 additions & 8 deletions src/CNCULT.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ makAncRI2(XiB,"export"); // EXPORT input info
makAncCOL(RcoliB); // REPORTCOL input info for UDT reports
makAncCOL2(XcoliB,"exportCol"); // EXPORTCOL input info for UDT exports
makAncIMPF(ImpfiB); // IMPORTFILE input info, 2-94
// holidays

makAncHDAY(HdayiB); // HDAY input info
makAncDESCOND(DCiB); // DESCOND input info

Expand Down Expand Up @@ -1544,11 +1544,20 @@ RC DUCTSEG::ds_Ckf()
RC rc=RCOK;

if (IsSet( DUCTSEG_EXAREA))
{ rc |= disallow( DUCTSEG_INAREA, "when dsExArea is given");
ignoreN( "when dsExArea is given", DUCTSEG_DIAM, DUCTSEG_LEN, 0);
{ // flat configuration: area is fixed
rc |= disallow( DUCTSEG_INAREA, "when dsExArea is given");
ignoreN( "when dsExArea is given", DUCTSEG_DIAM, DUCTSEG_LEN,
DUCTSEG_BRANCHCOUNT, DUCTSEG_BRANCHLEN, DUCTSEG_BRANCHCFA, DUCTSEG_AIRVELDS, 0);
}
else
{ int dimCount = IsSet( DUCTSEG_DIAM) + IsSet( DUCTSEG_LEN) + IsSet( DUCTSEG_INAREA);
{ // round: many interdependent defaults
// # of branches: user-input branch count takes precedence
if (IsSet( DUCTSEG_BRANCHCOUNT))
ignore( DUCTSEG_BRANCHCFA, "when dsBranchCount is given");
if (IsSet( DUCTSEG_BRANCHLEN))
rc |= disallow( DUCTSEG_LEN, "when dsBranchLen is given");

int dimCount = IsSet( DUCTSEG_DIAM) + IsSet( DUCTSEG_LEN) + IsSet( DUCTSEG_INAREA);
if (dimCount == 3)
rc |= oer( "at most 2 of dsDiameter, dsLength, and dsInArea are allowed");
}
Expand Down Expand Up @@ -1595,10 +1604,14 @@ static CULT dsT[] = //------ DUCTSEG cmd RAT Entry table, used from RSys
CULT( "*", STAR, 0, 0, 0, 0, 0, 0, 0.f, N, &dsStarCkf),
CULT( "dsRSys", DAT, DUCTSEG_OWNTI, NO_INP|RDFLIN,0,0, TYREF, &RSiB, 0, N, N),
CULT( "dsTy", DAT, DUCTSEG_TY, RQD, 0, VEOI, TYCH, 0, -1, N, N),
CULT( "dsBranchLen", DAT, DUCTSEG_BRANCHLEN,0,0, VEOI, TYFL, 0, -1.f, N, N),
CULT( "dsBranchCount",DAT, DUCTSEG_BRANCHCOUNT,0,0,VEOI, TYSI, 0, -1, N, N),
CULT( "dsBranchCFA", DAT, DUCTSEG_BRANCHCFA,0,0, VEOI, TYFL, 0, -1, N, N),
CULT( "dsAirVelDs", DAT, DUCTSEG_AIRVELDS, 0,0, VEOI, TYFL, 0, -1.f, N, N),
CULT( "dsExArea", DAT, DUCTSEG_EXAREA,0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dsInArea", DAT, DUCTSEG_INAREA,0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dsDiameter", DAT, DUCTSEG_DIAM, 0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dsLength", DAT, DUCTSEG_LEN, 0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dsLength", DAT, DUCTSEG_LEN, 0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dsExCnd", DAT, DUCTSEG_EXCND, 0, 0, 0, TYCH, 0, C_EXCNDCH_ADJZN, N, N),
CULT( "dsAdjZn", DAT, DSBC( ZI), 0, 0, VEOI, TYREF, &ZiB, 0.f, N, N),
CULT( "dsExT", DAT, DSBC( TXA), 0, 0, VSUBHRLY, TYFL, 0, 70.f, N, N),
Expand Down Expand Up @@ -2420,15 +2433,19 @@ static CULT dcT[] =
//---------- ----- --------------- ------- -- ------ ------ ---- ---------- ---- ----
CULT( "*", STAR, 0, 0, 0, 0, 0, 0, 0.f, N, dcStarCkf),

CULT( "dcDay", DAT, DESCOND_DAY, RQD, 0, VEOI, TYDOY, 0, 200, N, N),
CULT( "dcDay", DAT, DESCOND_DOY, RQD, 0, VEOI, TYDOY, 0, 200, N, N),

CULT( "dcDB", DAT, DESCOND_DB, RQD, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcMCDBR", DAT, DESCOND_MCDBR, RQD, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcMCWB", DAT, DESCOND_MCWB, RQD, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcMCWBR", DAT, DESCOND_MCWBR, RQD, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcWindSpeed",DAT, DESCOND_WNDSPD, RQD, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcTauB", DAT, DESCOND_TAUB, RQD, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcTauD", DAT, DESCOND_TAUD, RQD, 0, VEOI, TYFL, 0, 0.f, N, N),
// Taub/Taud and Ebn/Ebh interact, see dc_TopDC
CULT( "dcTauB", DAT, DESCOND_TAUB, 0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcTauD", DAT, DESCOND_TAUD, 0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcEbnSlrNoon",DAT, DESCOND_EBNSLRNOON,0, 0, VEOI, TYFL, 0, 0.f, N, N),
CULT( "dcEdhSlrNoon",DAT, DESCOND_EDHSLRNOON,0, 0, VEOI, TYFL, 0, 0.f, N, N),


CULT( "endDesCond", ENDER, 0, 0, 0, 0, 0, 0, 0.f, N, N),
CULT()
Expand Down
Loading