Skip to content

Commit 6bfeb24

Browse files
committed
More clang cleanups
1 parent f40be68 commit 6bfeb24

File tree

7 files changed

+47
-23
lines changed

7 files changed

+47
-23
lines changed

src/cnah1.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,10 +985,6 @@ RC AH::ahEstimate() // set ahMode and supply temp for terminal computations b4 i
985985
return RCOK;
986986
} // AH::ahEstimate
987987
//-----------------------------------------------------------------------------------------------------------------------------
988-
//--- constants, also hard-coded in cncult2.cpp for Top.absTol; also in cnah2.cpp:
989-
//const float RELoverABS = .01f; use commented out 5-95 // relative to absolute tol ratio: +-1 corrsponds to +- 1%.
990-
//const float ABSoverREL = 1.f/RELoverABS; no uses 5-95 // reciprocal thereof
991-
//---------------------------------------------------------------------------------------------------------------------------
992988
RC AH::ahCompute() // airHandler full computation ("refine"), after terminals have been estimated
993989

994990
// (old) preceding call sequence: tuEstimate, ahEstimate, ztuCompute.

src/cnah2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ const int UULIM = 250; // 200-->250 to match default ahTsMx, after PSYCHROMAXT
8686
// AH::iter4Fs (next function) is called by ahCompute, which is in cnah1.cpp.
8787
//-----------------------------------------------------------------------------------------------------------------------------
8888
//--- constants, also hard-coded in cncult2.cpp for Top.absTol; also in cnah1.cpp:
89-
const float RELoverABS = .01f; // relative to absolute tolerance ratio: +-1 corrsponds to +- 1%.
90-
//const float ABSoverREL = 1.f/RELoverABS; no uses 5-95 // reciprocal thereof
89+
static constexpr float RELoverABS = .01f; // relative to absolute tolerance ratio: +-1 corrsponds to +- 1%.
90+
// static constexpr float ABSoverREL = 1.f/RELoverABS; no uses 5-95 // reciprocal thereof
9191
//-----------------------------------------------------------------------------------------------------------------------------
9292
//---- ahCompute callees (iter4Fs - antRatTs - etc) local variables
9393
LOCAL DBL tsmLLim, tsmULim; // antRatTs narrows these to next temp up and down from ts where zone mode changes

src/cncult3.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,9 +1265,12 @@ void ZNR::zn_SetAirRadXArea() // set mbrs re zone air radiant pseudo surface
12651265
#endif
12661266
} // ZNR::zn_SetAirRadXArea
12671267
//-----------------------------------------------------------------------------
1268+
#if 0
12681269
// FFactors() convergence failure seen in optimized release builds
12691270
// Disabling optimization seems to fix, did not fully analyze, 2-8-12
1271+
// Renabled optimization 10-9-2025, passes all tests
12701272
#pragma optimize( "", off)
1273+
#endif
12711274
static int FFactors( // derive spherical geometry factors
12721275
int nS, // # of surfaces
12731276
const double areaS[], // areas of surfaces
@@ -1322,7 +1325,9 @@ x printf( "Mismatch\n");
13221325

13231326
return errTxt[ 0] ? RCBAD : RCOK;
13241327
} // FFactors
1328+
#if 0
13251329
#pragma optimize( "", on)
1330+
#endif
13261331
//-----------------------------------------------------------------------------
13271332
// #undef CZM_COMPARE // #define in cndefns.h to use exact CZM values re result comparison
13281333
//-----------------------------------------------------------------------------
@@ -2275,7 +2280,9 @@ void XSURF::xs_Init( // initialize
22752280
//-----------------------------------------------------------------------------
22762281
XSURF& XSURF::Copy( const XSURF* pXS, [[maybe_unused]] int options /*=0*/)
22772282
{ record* pParent = xs_pParent; // save parent ptr (set by c'tor)
2278-
memcpy( reinterpret_cast< void *>(this), pXS, sizeof( XSURF)); // bitwise copy
2283+
memcpy( reinterpret_cast< void *>(this),
2284+
reinterpret_cast< const void *>(pXS),
2285+
sizeof( XSURF)); // bitwise copy
22792286
xs_pParent = pParent; // restore parent ptr
22802287
xs_Init( xs_pParent); // fix sub-objects
22812288
// (deletes FENAWs, xs_SetRunConstants remakes)

src/cnloads.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,9 +2660,8 @@ RC RSYS::rs_FazInit( // init before autosize (once) and main sim
26602660
return rc;
26612661
} // RSYS::rs_FazInit
26622662
//-----------------------------------------------------------------------------
2663-
RC RSYS::rs_RddInit( int isAusz) // init before each autosize design day and main sim
2663+
RC RSYS::rs_RddInit( int /*isAusz*/) // init before each autosize design day and main sim
26642664
{
2665-
isAusz;
26662665
return RCOK;
26672666
} // RSYS::rs_RddInit
26682667
//-----------------------------------------------------------------------------
@@ -4554,7 +4553,7 @@ float RSYS::rs_PerfASHP2( // ASHP performance
45544553
// multiplies final COP result
45554554
// returns gross (compressor-only) full-speed COP (as adjusted by COPAdjF)
45564555
{
4557-
RC rc = RCOK;
4556+
[[maybe_unused]] RC rc = RCOK;
45584557
capDfHt = 0.f;
45594558
bool bDoDefrostAux = (ashpModel & 0x100) == 0
45604559
&& rs_defrostModel == C_RSYSDEFROSTMODELCH_REVCYCLEAUX;
@@ -6145,6 +6144,7 @@ double RSYS::rs_FxCapForSpeedF( // call-back fcn for regula method
61456144
double& speedF) // trial speedF (may be returned modified)
61466145
// returns required rs_fxCap[ 0] (= rs_amf / amfReq), >1 = excess capacity
61476146
{
6147+
[[maybe_unused]] RC rc = RCOK;
61486148
#if defined( _DEBUG)
61496149
double speedFWas = speedF;
61506150
float rsSpeedFWas = rs_speedF;
@@ -6163,7 +6163,7 @@ double RSYS::rs_FxCapForSpeedF( // call-back fcn for regula method
61636163
// (when far from solution errors are common and not meaningful
61646164
int arOptions = abs(rs_fxCap[0] - 1.f) < .01f;
61656165

6166-
RC rc = rs_TotalAirRequestForSpeedF(float(speedF), arOptions);
6166+
rc |= rs_TotalAirRequestForSpeedF(float(speedF), arOptions);
61676167

61686168
// if rc != RCOK, rs_fxCap[0] is 0
61696169

src/cntp.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,20 @@ RC TOWERPLANT::varSpeedF( // determine f needed for one tower to output power q
383383
// initial trial f: when possible, interpolate from prior f and q for fast repeated calls in same subhr
384384
// CAUTION: old q will not corres to old f if weather, setpoint, etc changed, so never save initial point.
385385
if (_q > qMax1 || _q < qMin1) // /0 and major change protection
386-
if (_q <= qWant) _f = _f * (qWant - qMin1)/(_q - qMin1); // if prior q too big (negative), linear inter tween qMin1 and q
387-
else _f += (1. - _f)*(qWant - _q)/(qMax1 - _q); // else prior q too small (neg), interp tween q and qMax1
386+
{
387+
if (_q <= qWant)
388+
_f = _f * (qWant - qMin1)/(_q - qMin1); // if prior q too big (negative), linear inter tween qMin1 and q
389+
else
390+
_f += (1. - _f)*(qWant - _q)/(qMax1 - _q); // else prior q too small (neg), interp tween q and qMax1
391+
}
388392
// else: fall thru with old f as 1st trial. f < 0 and f > 1 fixed below.
389393

390394
#if 1 // believe this is faster than next, provided towModel is stable enuf to assure convergence. 9-92.
391395

392396
// search loop. secant method: inter/extrapolate from most recent two points
393397

394398
DBL f1=0., q1=qMin1; // init prior point to one precomputed end of interval
395-
for (SI niter = 0; ; )
399+
for (int niter = 0; ; )
396400
{
397401
if (_f <= 0.)
398402
{

src/cnztu.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ WHAT if we modify the smart terminal to shut off flow if supply temp is on wrong
5959
****** UNTIL details thought thru, don't bother to try to implement smart terminals. ******* */
6060

6161
//-----------------------------------------------------------------------------------------------------------------------------
62-
//--- constants, also hard-coded in cncult2.cpp for Top.absTol; also in cnah.cpp:
63-
const float RELoverABS = .01f; // relative to absolute tolerance ratio: +-1 corrsponds to +- 1%.
64-
const float ABSoverREL = 1.f/RELoverABS; // reciprocal thereof
65-
//---------------------------------------------------------------------------------------------------------------------------
6662
RC FC hvacIterSubhr()
6763

6864
// Iterative (estimate-refine) part of hvac subhour computations for all zones/terminals/airHandlers
@@ -531,25 +527,38 @@ RC TU::tu_Setup() // check and set up terminal record: call for each terminal
531527
SI vbl = FALSE; // TRUE if any variable exprs given: don't default
532528
float def = 0.f; // use only > 0 values
533529
if (sstat[TU_TUVFMN] & FsSET) // if minimum flow given
530+
{
534531
if (sstat[TU_TUVFMN] & FsAS) // if being autoSized 7-95, its not constant nor variable
535532
ausz++; // set flag
536533
else if (sstat[TU_TUVFMN] & FsVAL) // else if set now (thus constant)
537534
def = tuVfMn; // use it as default (if > 0)
538-
else vbl++; // not set, not autoSized --> must be variable, can't default
535+
else
536+
vbl++; // not set, not autoSized --> must be variable, can't default
537+
}
539538
if (cmAr & cmStH) // heat max only pertinent with tstat ctrl'd heat
539+
{
540540
if (sstat[TU_TUVFMXH] & FsSET) // if heat max flow given
541+
{
541542
if (sstat[TU_TUVFMXH] & FsAS) // if being autoSized 7-95, its not constant nor variable
542543
ausz++; // set flag
543544
else if (sstat[TU_TUVFMXH] & FsVAL) // if set now (thus constant)
544545
setToMax(def, tuVfMxH); // use it as default if larger
545-
else vbl++; // not set --> must be variable, can't default
546+
else
547+
vbl++; // not set --> must be variable, can't default
548+
}
549+
}
546550
if (cmAr & cmStC) // cool max only pertinent with tstat ctrl'd cool
551+
{
547552
if (sstat[TU_TUVFMXC] & FsSET) // if cool max flow given
553+
{
548554
if (sstat[TU_TUVFMXC] & FsAS) // if being autoSized 7-95, its not constant nor variable
549555
ausz++; // set flag
550556
else if (sstat[TU_TUVFMXC] & FsVAL) // if set now (thus constant)
551557
setToMax(def, tuVfMxC); // use it as default if larger
552-
else vbl++; // not set --> must be variable, can't default
558+
else
559+
vbl++; // not set --> must be variable, can't default
560+
}
561+
}
553562
/* if any exprs given, don't use the constants or autoSizes -- require input.
554563
if only constants or autoSizes given, use max for main sim.
555564
if both constants & autoSizes given, don't store the constants b4 ausz phase: leave 0 for dynamic default.
@@ -2498,6 +2507,9 @@ RC ZNR::ztuMode() // ztuCompute inner fcn: determine zone mode, zone temp, term
24982507
Turnoff happens: AH::setTsSp1 (some 0-flow cases), TU::tuEstimate (next subhour),
24992508
and now in ZNR::ztuAbs at most once per subhour. 4-95. */
25002509

2510+
default:
2511+
break;
2512+
25012513
} // end switch zhxTy
25022514

25032515
// sums for humidity, for setpoint modes: add active-terminal contribution if any to sums from ztuAbs
@@ -2773,7 +2785,7 @@ RC ZNR::ztuAbs( // compute stuff for zn's terminals in given zone mode
27732785
&& ah->isZNorZN2 // if ah supply temp is under ZN or ZN2 control this hour
27742786
// don't turn on ah if no flow possible: just turns itself off again --> ah-tu nonconvergence, 10-96.
27752787
&& (max( tu->tuVfMn, tu->tuVfMxH) > 0 || Top.tp_sizing && tu->vhAs.az_active) // tuVfMxH==0 is allowed input.
2776-
&& (ah->sfan.vfDs > 0 || Top.tp_sizing && ah->fanAs.az_active) ) // vfDs==0 could result from autoSizing.
2788+
&& (ah->sfan.vfDs > 0 || (Top.tp_sizing && ah->fanAs.az_active)) ) // vfDs==0 could result from autoSizing.
27772789
{
27782790
TU *ctu = TuB.p + ah->ahCtu; // point ZN/ZN2 control terminal for this air handler
27792791
ctu->wantMd = ahHEATING; // have terminal tell ah that it wants heat
@@ -2808,7 +2820,7 @@ RC ZNR::ztuAbs( // compute stuff for zn's terminals in given zone mode
28082820
&& ah->isZNorZN2 // if ah supply temp is under ZN or ZN2 control this hour
28092821
// don't turn on ah if no flow possible: just turns itself off again --> ah-tu nonconvergence, 10-96.
28102822
&& (max( tu->tuVfMn, tu->tuVfMxC) > 0 || Top.tp_sizing && tu->vcAs.az_active) // tuVfMxC==0 is allowed input.
2811-
&& (ah->sfan.vfDs > 0 || Top.tp_sizing && ah->fanAs.az_active) ) // vfDs==0 could result from autoSizing.
2823+
&& (ah->sfan.vfDs > 0 || (Top.tp_sizing && ah->fanAs.az_active)) ) // vfDs==0 could result from autoSizing.
28122824
{
28132825
TU *ctu = TuB.p + ah->ahCtu; // point ZN/ZN2 control terminal for this air handler
28142826
ctu->wantMd = ahCOOLING; // have terminal tell ah that it wants coolth
@@ -2862,6 +2874,8 @@ haveFlow: ; // other air handler cases join here with flow cz set
28622874
wc1 += cz * (ah->ah_wSupLs + ah->ah_wSup)/2.; // accumulate average supply hum rat * flow, for wcO1
28632875
wc += cz * ah->ah_wSup; // accumulate latest supply hum rat * flow
28642876
break;
2877+
default:
2878+
break;
28652879
}
28662880
}
28672881

@@ -3098,6 +3112,8 @@ tzOhum: ; // common exit for air cases. cz contains tu->cz.
30983112
}
30993113
break;
31003114
#undef TOLF
3115+
default:
3116+
break;
31013117
}
31023118
}
31033119
} // ZNR::ztuMdSets

src/cueval.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ LOCAL RC FC cuEvalI(
411411
static_assert( sizeof(SI)==sizeof(PSOP)); // assumed in (SI *) cast used in PSPKONN case
412412

413413
static bool bCoverageInited = false;
414+
if (!bCoverageInited)
414415
{ /* rc = */ CoverageInit();
415416
bCoverageInited = true;
416417
}

0 commit comments

Comments
 (0)