Skip to content

Commit abed7bb

Browse files
authored
Merge pull request #138 from cse-sim/vsashp
VSASHP progress
2 parents 7a26e94 + 50a6b43 commit abed7bb

File tree

9 files changed

+154
-95
lines changed

9 files changed

+154
-95
lines changed

src/ANCREC.H

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ class record // base class for records
228228

229229
// input-checking support functions in cncult2.cpp
230230
// require/disallow fields
231+
RC checkN(const char* when, RC (*checkFcn)(int fn, const char* when), va_list ap);
231232
RC disallowN( const char* when=NULL, ...);
232-
RC disallow( int fn, const char* when=NULL);
233+
RC disallow( int fn, const char* when);
233234
RC requireN( const char* when=NULL, ...);
234235
RC require( int fn, const char* when=NULL);
235236
RC ignoreN( const char* when=NULL, ...);

src/CGCOMP.CPP

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,13 @@ void AFMTR::amt_Accum(
357357
/////////////////////////////////////////////////////////////////////////////////
358358
// AIRSTATE
359359
/////////////////////////////////////////////////////////////////////////////////
360+
void AIRSTATE::as_Set(const AIRFLOW& af)
361+
// copy AIRFLOW state (ignore af_amf)
362+
{
363+
as_tdb = af.as_tdb;
364+
as_w = af.as_w;
365+
} // AIRSTATE::as_Set
366+
//------------------------------------------------------------------------------
360367
int AIRSTATE::as_IsEqual( const AIRSTATE& as, double tol/*=.001*/) const
361368
{ return frDiff( as_tdb, as.as_tdb) < tol
362369
&& frDiff( as_w, as.as_w) < tol;
@@ -2273,29 +2280,31 @@ void DUCTSEG::ds_FinalizeSh( // finish subhour calcs
22732280
if (runF > 0.f && ds_leakF > 0.f)
22742281
{
22752282
double amfLk = runF * ds_amfFL * ds_leakF; // leak amf, lb/hr
2283+
double tz = pRS->rs_asRet.as_tdb;
2284+
double wz = pRS->rs_asRet.as_w;
22762285
if (ds_IsSupply())
2277-
{ // supply (leakage is out of duct)
2278-
#if 0
2279-
double tz = pRS->rs_asZn.as_tdb;
2280-
#endif
2281-
double tz = pRS->rs_asRet.as_tdb;
2282-
double qDotIn = runF * mCpFL * ds_air[1].as_tdb;
2283-
double qDotOut = runF * mCpFL * (1.f - ds_leakF) * ds_air[3].as_tdb;
2284-
double qLeak = qDotOut - qDotIn - ds_qCond;
2285-
ds_qLeakSen = runF * mCpFL * ds_leakF * (ds_air[3].as_tdb - tz);
2286-
ds_qLeakLat = amfLk * PsyHCondWtr * ds_air[3].as_w; // TODO
2286+
{ // supply (leakage: + = out of duct, heating loss > 0, cooling loss < 0)
2287+
ds_qLeakSen = amfLk * Top.tp_airSH * (ds_air[3].as_tdb - tz);
2288+
ds_qLeakLat = amfLk * PsyHCondWtr * (ds_air[3].as_w - wz);
22872289
if (zpx)
22882290
zpx->zn_ductLkI.af_AccumDry(amfLk, ds_air[3]);
22892291
}
22902292
else
22912293
{ // return
2294+
// leakage flow is into the duct -- that is, negative per sign convention
2295+
// ds_amfFL is always > 0, so amfLk must be negated
22922296
if (zpx)
22932297
zpx->zn_ductLkO.af_AccumDry(-amfLk, zpx->tz, zpx->wz);
2298+
// return leakage losses: duct flow * deltaT across leak
2299+
// heating loss > 0, cooling loss < 0
2300+
ds_qLeakSen = runF * ds_amfFL * Top.tp_airSH * (ds_air[0].as_tdb - ds_air[1].as_tdb);
2301+
ds_qLeakLat = runF * ds_amfFL * PsyHCondWtr * (ds_air[0].as_w - ds_air[1].as_w);
22942302
}
22952303
}
22962304
// else ds_qLeakSen = ds_qLeakLat = 0. per ds_BegSubHr()
22972305

22982306
// populate results
2307+
// results zeroed in DUCTSEG::ds_BegSubhr()
22992308
DUCTSEGRES_IVL_SUB& R = ds_GetDUCTSEGRES()->curr.S;
23002309
if (pRS->rs_mode == RSYS::rsmHEAT)
23012310
{ R.qhCond = ds_qCond * Top.tp_subhrDur;

src/CNCULT.CPP

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,7 @@ CULT( "rsDesc", DAT, RSYS_DESC, 0, 0, VEOI, TYSTR, 0, 0, N,
16801680
CULT( "rsPerfMap", DAT, RSYS_PERFMAP, 0, 0, VEOI, TYCH, 0, C_NOYESCH_NO, N, N),
16811681
CULT( "rsFanTy", DAT, RSFAN( FANTY), 0, 0, VEOI, TYCH, 0, C_FANTYCH_BLOWTHRU, N, N ),
16821682
CULT( "rsFanMotTy", DAT, RSFAN( MOTTY), 0, 0, VEOI, TYCH, 0, C_MOTTYCH_PSC, N, N ),
1683+
CULT( "rsAdjForFanHt", DAT, RSYS_ADJFORFANHT,0, 0, VEOI, TYCH, 0, C_NOYESCH_YES, N, N),
16831684
CULT( "rsModeCtrl", DAT, RSYS_MODECTRL, 0, 0, VHRLY, TYCH, 0, C_RSYSMODECTRLCH_AUTO, N, N),
16841685
CULT( "rsElecMtr", DAT, RSYS_ELECMTRI, 0, 0, VEOI, TYREF, &MtriB, N, N, N),
16851686
CULT( "rsFuelMtr", DAT, RSYS_FUELMTRI, 0, 0, VEOI, TYREF, &MtriB, N, N, N),

src/CNCULT2.CPP

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ RC record::limitCheck( // range check, issue warning or error msg
20192019
// else RCxx if value out of range (msg issued)
20202020
{
20212021
RC rc = RCOK;
2022-
if (IsSet( fn))
2022+
if (IsVal( fn))
20232023
{ int dt = DType( fn);
20242024
void* pV = field( fn);
20252025
double v = 0.;
@@ -2074,13 +2074,40 @@ RC record::limitCheckFix( // range check, msg, set to min/max
20742074
///////////////////////////////////////////////////////////////////////////////
20752075
// 'record' MEMBER FUNCTIONS TO REQUIRE/DISALLOW FIELDS (class declaration: ancrec.h)
20762076
///////////////////////////////////////////////////////////////////////////////
2077-
RC CDEC record::disallowN( // issue "not allowed" message for each given field in 0-terminated list of field numbers
2078-
const char* when /*=NULL*/, // message insert. message handle ok (see lib\messages.cpp).
2077+
RC record::checkN(
2078+
const char* when, // message insert. message handle ok (see messages.cpp).
2079+
RC (*checkFcn)(int fn, const char* when),
2080+
va_list ap)
2081+
{
2082+
RC rc = RCOK;
2083+
char whenBuf[200];
2084+
if (!msgIsHan(when)) // not if handle given
2085+
if (when) // copy arg to local buffer in case in Tmpstr[], ...
2086+
when = strncpy0(whenBuf, when, sizeof(whenBuf)); // so any (possible future) strtprintf's in following loop
2087+
// won't overwrite it, 7-92.
2088+
for (; ; )
2089+
{
2090+
int fn = va_arg(ap, int);
2091+
if (!fn)
2092+
break;
2093+
if (fn > 1024)
2094+
rc |= oer((char*)MH_S0495, // "cncult2.cpp:%s Internal error: field # %nd: probable unterminated arg list"
2095+
"checkN", fn);
2096+
rc |= (*checkFcn)(fn, when);
2097+
}
2098+
return rc;
2099+
} // checkN
2100+
//-----------------------------------------------------------------------------
2101+
RC record::disallowN( // issue "not allowed" message for each given field in 0-terminated list of field numbers
2102+
const char* when /*=NULL*/, // message insert. message handle ok (see messages.cpp).
20792103
... ) // int field numbers, 0 ends list REMEMBER THE 0!
20802104
{
20812105
RC rc=RCOK;
20822106
va_list ap;
20832107
va_start( ap, when);
2108+
#if 0
2109+
rc = checkN(when, [this](int fn, const char* when)->RC { return this->disallow(fn, when); }, ap);
2110+
#else
20842111
char whenBuf[200];
20852112
if (!msgIsHan(when)) // not if handle given, lib\messages.cpp, 7-10-92
20862113
if (when) // copy arg to local buffer in case in Tmpstr[], ...
@@ -2095,6 +2122,7 @@ RC CDEC record::disallowN( // issue "not allowed" message for each given fiel
20952122
"disallowN", fn);
20962123
rc |= disallow( fn, when);
20972124
}
2125+
#endif
20982126
return rc;
20992127
} // disallowN
21002128
//-----------------------------------------------------------------------------
@@ -2107,7 +2135,7 @@ RC record::disallow( // issue message if field is given
21072135
return RCOK;
21082136
} // disallow
21092137
//-----------------------------------------------------------------------------
2110-
RC CDEC record::requireN( // issue "missing" message for each omitted field in 0-terminated list of field numbers
2138+
RC record::requireN( // issue "missing" message for each omitted field in 0-terminated list of field numbers
21112139
const char* when /*=NULL*/, // message insert (message handle ok)
21122140
... ) // int field numbers, 0 ends list REMEMBER THE 0!
21132141
{
@@ -2140,7 +2168,7 @@ RC record::require( // issue message if field is not given
21402168
return RCOK;
21412169
} // require
21422170
//-------------------------------------------------------------------------------
2143-
RC CDEC record::ignoreN( // issue "ignored" message for each given field in 0-terminated list of field numbers
2171+
RC record::ignoreN( // issue "ignored" message for each given field in 0-terminated list of field numbers
21442172
const char* when /*=NULL*/, // message insert. message handle ok (see messages.cpp).
21452173
... ) // int field numbers, 0 ends list REMEMBER THE 0!
21462174
{

src/CNGUTS.CPP

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,13 +1439,13 @@ void ZNRES::zr_InitCurr() // initialize curr mbrs
14391439
// floats: all
14401440
#define ZRf1 tAir // 1st of all float members (incl avgs & sums). cnguts.cpp
14411441
#define ZRnF ((oRes(litEu) - oRes(tAir))/sizeof(float) + 1) // total # float members. cnguts.cpp
1442-
// floats: to average (cnguts.cpp)
1442+
// floats: to average (cnguts.cpp)
14431443
#define ZRa1 tAir // 1st float to average in float mbrs. cnguts.cpp.
14441444
#define ZRnA ((oRes(wAir) - oRes(tAir))/sizeof(float) + 1) // # of floats to average
1445-
// floats: to sum: all (cnguts.cpp)
1445+
// floats: to sum: all (cnguts.cpp)
14461446
#define ZRs1 qCond // first one
14471447
#define ZRnS ((oRes(litEu) - oRes(qCond))/sizeof(float) + 1) // #
1448-
// floats to sum: sensible heat balance (cgenbal.cpp)
1448+
// floats to sum: sensible heat balance (cgenbal.cpp)
14491449
#define ZRq1 qCond // 1st float sum & 1st heat flow. cnguts.cpp, cgenbal.cpp.
14501450
#define ZRnQ ((oRes(qsMech) - oRes(qCond))/sizeof(float) + 1) // # of floats to sum / # heat flows. cnguts.cpp, cgenbal.cpp.
14511451
// floats to sum: latent heat balance

src/CNLOADS.CPP

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ RC ZNR::zn_BegHour2() // beginning-of-hour calcs for zone
355355
RC ZNR::zn_BegSubhr1() // zone start of subhour, part 1
356356
// call *before* airnet and possible others needing prior-step (lagged) values
357357
{
358-
// is following still needed? eg loadsIzxfer no longer accumulates to it... 11-95
359358
memset( &ZnresB.p[ss].curr.S, 0, sizeof( ZNRES_IVL_SUB) ); // access subhr results struct in ZNRES via subscr in ZrB & 0 it.
360359
ZnresB.p[ss].curr.S.nSubhr = 1L; // count subhours by setting to 1 at subhr level & accumulating
361360

@@ -1719,10 +1718,7 @@ RC RSYS::rs_CkF()
17191718
rs_fanPwrC = 0.f; // fan power included in primary by default
17201719
}
17211720
else
1722-
{ rc |= requireN(when, RSYS_SEER, 0);
1723-
if (IsSetCount(RSYS_COP95, RSYS_EER95, 0) == 2)
1724-
rc |= oer("rsEER and rsCOP95 cannot both be given %s", when);
1725-
}
1721+
rc |= requireN(when, RSYS_SEER, 0);
17261722

17271723
// cooling model air flow correlations have limited validity range
17281724
// verify air flow 150 - 550 cfm/ton (per Proctor Engineering)
@@ -2005,28 +2001,34 @@ RC RSYS::rs_TopRSys1() // check RSYS, initial set up for run
20052001

20062002
if (rs_CanCool())
20072003
{ // default/harmonize 95 F COP
2008-
// force rs_COP95 <-> rs_EER95 consistency
2009-
// at most 1 can be input
2004+
// inter-default rs_COP95 <-> rs_EER95
2005+
// if both input, values can be different
2006+
// rs_COP95 used for VCHP2, rs_EER95 used for single speed
20102007
// EER can default from SEER
20112008
if (rs_IsPkgRoom())
20122009
{ // pkg: derive SEER from EER
20132010
// abram conant fit, 6-20
20142011
rs_SEER = 1.07f * rs_EER95;
20152012
// rs_COP95 not allowed
20162013
}
2017-
else if (IsSet(RSYS_COP95))
2018-
rs_EER95 = rs_COP95 * BtuperWh;
2019-
else if (!IsSet(RSYS_EER95))
2020-
{ // estimate missing EER from SEER
2021-
// California ACM method
2022-
rs_EER95 = rs_SEER < 13.f ? 10.f + 0.84f * (rs_SEER - 11.5)
2023-
: rs_SEER < 16.f ? 11.3f + 0.57f * (rs_SEER - 13)
2024-
: 13.f;
2025-
if (rs_SEER <= rs_EER95)
2026-
rc |= oer("rsSEER (%g) must be > rsEER (%g)", rs_SEER, rs_EER95);
2014+
else if (IsSet(RSYS_EER95))
2015+
{ if (!IsSet(RSYS_COP95))
2016+
rs_COP95 = rs_EER95 / BtuperWh;
2017+
}
2018+
else
2019+
{ if (IsSet(RSYS_COP95))
2020+
rs_EER95 = rs_COP95 * BtuperWh;
2021+
else
2022+
{ // estimate missing EER from SEER
2023+
// California ACM method
2024+
rs_EER95 = rs_SEER < 13.f ? 10.f + 0.84f * (rs_SEER - 11.5)
2025+
: rs_SEER < 16.f ? 11.3f + 0.57f * (rs_SEER - 13)
2026+
: 13.f;
2027+
rs_COP95 = rs_EER95 / BtuperWh;
2028+
}
20272029
}
2028-
// rs_EER95 now set
2029-
rs_COP95 = rs_EER95 / BtuperWh;
2030+
if (rs_SEER <= rs_EER95)
2031+
rc |= oer("rsSEER (%g) must be > rsEER (%g)", rs_SEER, rs_EER95);
20302032
}
20312033

20322034
if (IsAusz( RSYS_CAP95))
@@ -2704,10 +2706,9 @@ float RSYS::rs_FanHRtdPerTon( // fan heat included in ratings
27042706
// returns fan heat included in ratings, Btuh
27052707
{
27062708
float fanHRtdPerTon =
2707-
rs_IsPkgRoom() ? 0.f // PkgRoom: no fan adjustment
2708-
: rs_fan.fn_motTy == C_MOTTYCH_PSC
2709-
? 500.f // PSC = Permanent Split Capacitor
2710-
: 283.f; // BPM = Brushless Permanent Magnet (aka ECM)
2709+
rs_IsPkgRoom() || rs_adjForFanHt == C_NOYESCH_NO ? 0.f // PkgRoom or user override: no fan adjustment
2710+
: rs_fan.fn_motTy == C_MOTTYCH_PSC ? 500.f // PSC = Permanent Split Capacitor
2711+
: 283.f; // BPM = Brushless Permanent Magnet (aka ECM)
27112712

27122713
return capNomTons * fanHRtdPerTon;
27132714

@@ -3120,23 +3121,26 @@ x printf("\nhit");
31203121
else
31213122
{ // total capacities and input, Btuh
31223123
// include rated fan power
3124+
// cap values are net Btuh, <0
31233125
float capClg, inpClg, capClgMin, inpClgMin;
31243126
RC rc = rs_GetPerfBtwxt(rs_pRgiClg, rs_tdbOut,
31253127
capClg, inpClg, capClgMin, inpClgMin);
31263128
rs_speedFMin = capClg >= 0.f ? 1.f : capClgMin / capClg;
31273129
float fanHAdj = rs_fanHRtdC; // fan heat adjustment, Btuh
3130+
// adjust for fan power (= convert to gross cooling)
31283131
capClg += fanHAdj;
31293132
inpClg -= fanHAdj;
31303133
capClgMin += fanHAdj * rs_speedFMin;
31313134
inpClgMin -= fanHAdj * rs_speedFMin;
31323135

3133-
rs_capTotCt = capClg * rs_speedF; // total coil capacity at current conditions and speed, Btuh
3136+
rs_capTotCt = capClg * rs_speedF; // total coil capacity (= gross) at current conditions and speed, Btuh
31343137
rs_capSenCt = rs_SHR * rs_capTotCt; // sensible coil capacity at current conditions and speed, Btuh
31353138

3139+
// input at current speed (Btuh)
31363140
float inpX = rs_speedF == 1.f
31373141
? inpClg
31383142
: inpClgMin
3139-
+ (inpClg - inpClgMin) * (rs_speedF - rs_speedFMin) / (1.f - rs_speedFMin);
3143+
+ (inpClg - inpClgMin) * (rs_speedF - rs_speedFMin) / (1.f - rs_speedFMin);
31403144

31413145
rs_effCt = abs( rs_capSenCt) / inpX; // compressor-only COP
31423146
}
@@ -4553,7 +4557,7 @@ void RSYS::rs_EnteringAirState() // RSYS entering air state
45534557
orWarn("dubious return temp (%.1f F)", afRet.as_tdb);
45544558
#endif
45554559
}
4556-
rs_asRet = afRet; // state = flow w/o amf
4560+
rs_asRet.as_Set( afRet); // state = flow w/o amf
45574561
}
45584562

45594563
// adjust state for return duct
@@ -4998,25 +5002,28 @@ RC RSYS::rs_AllocateZoneAirVC() //
49985002

49995003
} // RSYS::AllocateZoneAirVC()
50005004
//-----------------------------------------------------------------------------
5001-
RC RSYS::rs_TotalAirRequest(
5005+
RC RSYS::rs_TotalAirRequest( // all-zone air request at speedF
50025006
float speedF)
5003-
50045007
{
50055008
RC rc = RCOK;
50065009

5007-
rs_ClearSubhrResults(1); // init for speed re-try
5008-
int ret = rs_SupplyAirState(rs_mode, speedF);
5009-
ZNR* zp;
5010-
RLUPC(ZrB, zp, rs_IsZoneServed(zp))
5011-
zp->zn_AirRequest(this);
5012-
5013-
if (rs_amfReq[0] <= 0.) // if any air requested (by any zone)
5010+
if (speedF != rs_speedF)
50145011
{
5015-
printf("\nrs_AirRequest: rs_amfReq[ 0] <= 0.");
5016-
return RCBAD;
5017-
}
50185012

5019-
rs_fxCap[0] = rs_amf / rs_amfReq[0]; // >1 = excess capacity
5013+
rs_ClearSubhrResults(1); // init for speed re-try
5014+
int ret = rs_SupplyAirState(rs_mode, speedF);
5015+
ZNR* zp;
5016+
RLUPC(ZrB, zp, rs_IsZoneServed(zp))
5017+
zp->zn_AirRequest(this);
5018+
5019+
if (rs_amfReq[0] <= 0.) // if any air requested (by any zone)
5020+
{
5021+
printf("\nrs_AirRequest: rs_amfReq[ 0] <= 0.");
5022+
return RCBAD;
5023+
}
5024+
5025+
rs_fxCap[0] = rs_amf / rs_amfReq[0]; // >1 = excess capacity
5026+
}
50205027

50215028
return rc;
50225029
} // RSYS::rs_TotalAirRequest
@@ -5050,7 +5057,7 @@ double RSYS::rs_FindAirFlow()
50505057

50515058
#if defined( _DEBUG)
50525059
if (ret)
5053-
printf("\nrs_FindAirFlow(): secant ret=%d", ret);
5060+
printf("\nrs_FindAirFlow(): secant ret=%d rsMode=%d", ret, rs_mode);
50545061
if (rs_speedF < rs_speedFMin || rs_speedF > 1.f)
50555062
printf("\nrs_FindAirFlow() rs_speedF=%0.2f", rs_speedF);
50565063
#endif
@@ -5124,11 +5131,11 @@ RC RSYS::rs_FinalizeSh()
51245131
float runFFan = 0.f; // subhour fan run fraction
51255132
if (rs_mode == rsmCOOL)
51265133
{
5127-
rs_outSen = rs_loadF * rs_capSenCt; // average output w/o fan, Btuh (< 0)
5134+
rs_outSen = rs_loadF * rs_capSenCt; // average output w/o fan (= gross cooling), Btuh (< 0)
51285135
rs_outLat = rs_loadF * rs_capLatCt;
51295136
rs_outFan = rs_inFan = rs_loadF * rs_speedF * rs_fanHeatC; // all fan heat to air
51305137
runFFan = rs_loadF;
5131-
rs_outSenTot = rs_outSen + rs_outFan; // gross output
5138+
rs_outSenTot = rs_outSen + rs_outFan; // net cooling output, Btuh (generally < 0)
51325139

51335140
if (!rs_IsVCClg() || rs_speedF == 1.f)
51345141
{ rs_runF = rs_loadF;

0 commit comments

Comments
 (0)