Skip to content

Commit 562df62

Browse files
committed
Fix below grade surface xs_UNom / ms_UNom inconsistency
1 parent 46523a2 commit 562df62

File tree

12 files changed

+1125
-520
lines changed

12 files changed

+1125
-520
lines changed

src/CGWTHR.CPP

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,13 @@ RC WDHR::wd_WfReader( // read an hour's weather data and make adjustments
380380
}
381381

382382
// set up solar conditions
383-
#if 1
384-
if (iHrST == 0)
385-
slday( jDayST, SLTMLST);
386-
#else
383+
#if defined( SOLARFIX)
387384
slday( jDayST, SLTMLST, 1); // set up curr SLLOCDAT struct for today if needed
388385
// sets info re declination of earth's axis, hourly sunupf[], dircos[], slazm[], etc.
389386
// used by slaniso & most other slpak calls.
387+
#else
388+
if (iHrST == 0)
389+
slday( jDayST, SLTMLST);
390390
#endif
391391

392392
static float dchoriz[3] = { 0.f, 0.f, 1.f }; // dir cos of a horiz surface

src/CNCULT2.CPP

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ RC topReCkf()
186186
return topCkfI( TRUE);
187187
}
188188
//===========================================================================
189-
LOCAL RC topCkfI( int re)
190-
191-
// finish/check/set up inner function, used when RUN seen, and again (re TRUE) if main simulation follows autosize.
189+
LOCAL RC topCkfI( // finish/check/set up inner function
190+
int re) // 0: when RUN seen
191+
// nz: 2nd call when main simulation follows autosize
192192

193193
/* does:
194194
checking that must be deferred til multiple inputs present

src/CNCULT3.CPP

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ x printf( "Hit\n");
692692
ms_area = sf->x.xs_area; // net area
693693
isSubhrly = SFI::sf_IsSubhrly( sf->x.xs_modelr); // TRUE if to be simulated subhourly
694694

695-
ms_UNom = sf->x.xs_UNom; // u value: construction/layers + surfaces
695+
ms_UNom = sf->x.xs_UNom; // U-factor: construction/layers + nominal surface conductance
696+
// Note: ms_UNom also set in xs_SetUNom() to ensure consistency
696697
ms_tc = con->hc/sf->x.uI; // time constant, recomputed & stored here for reporting (cgresult.cpp) added 1-95
697698

698699
inside.bc_Setup( ss, MSBCZONE, 0); // 0 = doing inside
@@ -1940,7 +1941,8 @@ int XSURF::xs_CanHaveExtSlr() const // TRUE iff surface outside can receive ambi
19401941
&& xs_ty != CTPERIM && xs_ty != CTINTWALL;
19411942
} // XSURF::xs_CanHaveExtSlr
19421943
//-----------------------------------------------------------------------------
1943-
RC XSURF::xs_SetUNom()
1944+
RC XSURF::xs_SetUNom() // derive/set nominal U-factor
1945+
// also sets xs_UANom, xs_rSrfNom, xs_hSrfNom, and ms_UNom
19441946
{
19451947
static float rSrfASHRAE[ 3][ 2] =
19461948
// down up
@@ -1988,6 +1990,17 @@ static float rSrfASHRAE[ 3][ 2] =
19881990
for (int si=0; si<2; si++)
19891991
xs_hSrfNom[ si] = xs_rSrfNom[ si] > 0.f ? 1.f/xs_rSrfNom[ si] : 0.f;
19901992

1993+
#if 1 // 10-28-2017
1994+
// set/update derived values
1995+
// known case: xs_SetUNom is called a 2nd time for C_EXCNDCH_GROUND
1996+
// xs_UNom value changes
1997+
xs_UANom = xs_area * xs_UNom;
1998+
if (xs_msi)
1999+
{ MSRAT* ms = MsR.GetAt( xs_msi);
2000+
ms->ms_UNom = xs_UNom;
2001+
}
2002+
#endif
2003+
19912004
return RCOK;
19922005

19932006
} // XSURF::xs_SetUNom

src/CNDEFNS.H

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
#define DIM_POLYGONXYZ 37 // input arrays dimension
142142
// = MAX_POLYLPVERTICIES*3 + 1
143143

144+
#undef SOLARFIX // define to correct timing of slday() calls
145+
// and definition of HA, 10-25-2017
146+
144147
#endif // ifndef _CNEDEFNS_H
145148

146149
// cndefns.h end

src/CNGUTS.CPP

Lines changed: 17 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,8 +1660,8 @@ LOCAL void FC NEAR doIvlAccum()
16601660
RLUP( RSysResR, pRSR) // loop RSYS simulation results incl sum_of.
16611661
{ pRSR->H.rsr_Accum( &pRSR->D, Top.isBegDay, Top.isEndDay); // accumulate hour results to day. local
16621662
#if 0
1663-
if (pRSR->ss < RSysResR.n) // if not the sum record (last)
1664-
pRSR->H.rsr_Accum( &allRsysRes->H, pRSR->ss==1, pRSR->ss==RsR.n); // also accumulate each hour to sum_of_RSYS
1663+
0 if (pRSR->ss < RSysResR.n) // if not the sum record (last)
1664+
0 pRSR->H.rsr_Accum( &allRsysRes->H, pRSR->ss==1, pRSR->ss==RsR.n); // also accumulate each hour to sum_of_RSYS
16651665
#endif
16661666
}
16671667

@@ -1983,15 +1983,17 @@ LOCAL void FC NEAR accumAhr( // Accumulate air handler simulation results
19831983
LOCAL void FC NEAR mtrsAccum( // Accumulate metered energy use results: add interval to next, + tot and sum.
19841984

19851985
IVLCH ivl, // destination interval: day/month/year. Accumulates from hour/day/month. Not Top.ivl!
1986-
int firstflg ) // If TRUE, destination will be initialized before values are accumulated into it
1987-
1986+
int firstflg) // If TRUE, destination will be initialized before values are accumulated into it
19881987
{
19891988
MTR* mtr; // a meter record
19901989
int firstRec = 1;
1991-
RLUP( MtrB, mtr) // loop (good) meter records
1992-
{ int bTrc = 0; // strMatch( mtr->name, "ElecMtrInitNo");
1990+
RLUP( MtrB, mtr) // loop (good) meter records
1991+
{
1992+
#if defined( _DEBUG)
1993+
int bTrc = 0; // strMatch( mtr->name, "ElecMtrInitNo");
19931994
if (bTrc)
19941995
printf( "\nAccum Day=%d hr=%d mtr='%s' ivl=%d ff=%d", Top.jDay, Top.iHr, mtr->name, ivl, firstflg);
1996+
#endif
19951997

19961998
MTR_IVL_SUB* mtrSub2 = &mtr->Y + (ivl - C_IVLCH_Y); // point destination meter interval substruct for interval
19971999
// ASSUMES MTR interval members ordered like DTIVLCH choices
@@ -2002,37 +2004,20 @@ LOCAL void FC NEAR mtrsAccum( // Accumulate metered energy use results: add int
20022004
if (ivl==C_IVLCH_D)
20032005
{
20042006
// compute hour's total load in each record. .allEU then propogates to D, M, Y.
2005-
/// sum members .clg .. usr2 to .allEU, exclude .pv and .bt
2007+
// sum members .clg .. usr2 to .allEU, exclude .pv and .bt
20062008
mtrSub1->allEU = VSum<float,double>( &mtrSub1->clg, NENDUSES-2);
20072009

20082010
// compute sum of uses record (last record). .sum record then propogates to D, M, Y.
20092011
if (mtr->ss < MtrB.n) // don't add the sum record into itself
20102012
{ MTR_IVL_SUB& mtrSum = MtrB.p[MtrB.n].H;
2011-
mtrSum.mtr_Accum1( mtrSub1, ivl, 0+(firstflg!=0));
2012-
#if 0
2013-
if (firstRec)
2014-
memcpy( &mtrSum, mtrSub1, sizeof(MTR_IVL_SUB)); // copy first record
2015-
else // additional records: accumulate ...
2016-
mtrSum.mtr_Accum1( mtrSub1, ivl); // treatment of demand not necessarily sensible.
2017-
#endif
2013+
mtrSum.mtr_Accum1( mtrSub1, ivl, 0+(firstRec!=0));
20182014
}
20192015
firstRec = 0;
20202016
}
20212017

20222018
// accumulate: copy on first call (in lieu of 0'ing destination).
20232019
// Note: doHourGains 0's MTR hour info at start hour.
2024-
#if 1
20252020
mtrSub2->mtr_Accum1( mtrSub1, ivl, 0 + (firstflg!=0));
2026-
#else
2027-
if (firstflg) // if first call for destination interval
2028-
{ // copy selected members
2029-
VCopy( &mtrSub2->clg, NENDUSES-2, &mtrSub1->clg);
2030-
mtrSub2->pv = mtrSub1->pv;
2031-
mtrSub2->allEU = mtrSub1->allEU;
2032-
}
2033-
else // additional calls in interval use accumulation subr (next)
2034-
mtrSub2->mtr_Accum1( mtrSub1, ivl); // adds up uses w/o bt or tot
2035-
#endif
20362021
}
20372022

20382023
// DHWMTRs
@@ -2050,9 +2035,11 @@ LOCAL void FC NEAR mtrsFinalize( // Finalize meters (after post-stage calcs e.g
20502035
int firstRec = 1;
20512036
RLUP( MtrB, mtr) // loop (good) meter records
20522037
{
2038+
#if defined( _DEBUG)
20532039
int bTrc = 0; // strMatch( mtr->name, "ElecMtrInitNo");
20542040
if (bTrc)
20552041
printf( "\nFinal Day=%d hr=%d mtr='%s' ivl=%d ff=%d", Top.jDay, Top.iHr, mtr->name, ivl, firstflg);
2042+
#endif
20562043

20572044
MTR_IVL_SUB* mtrSub2 = &mtr->Y + (ivl - C_IVLCH_Y); // point destination meter interval substruct for interval
20582045
// ASSUMES MTR interval members ordered like DTIVLCH choices
@@ -2113,17 +2100,10 @@ LOCAL void FC NEAR mtrsFinalize( // Finalize meters (after post-stage calcs e.g
21132100

21142101
#endif
21152102

2116-
// accumulate: copy on first call (in lieu of 0'ing destination). Note: doHourGains 0's MTR hour info at start hour.
2117-
#if 1
2118-
// accumulate to next level, handles dmd
2103+
// accumulate: copy on first call (in lieu of 0'ing destination).
2104+
// handles dmd
2105+
// Note: doHourGains 0's MTR hour info at start hour.
21192106
mtrSub2->mtr_Accum1( mtrSub1, ivl, 2 + (firstflg!=0));
2120-
#else
2121-
if (firstflg) // if first call for destination interval
2122-
memcpy( mtrSub2, mtrSub1, sizeof(MTR_IVL_SUB) ); // copy whole subrecord
2123-
else // additional calls in interval use accumulation subr (next)
2124-
mtrSub2->mtr_Accum1( mtrSub1, ivl, 2); // finalizes totals, handles dmd
2125-
#endif
2126-
21272107

21282108
#if defined( _DEBUG)
21292109
if (1 || bTrc)
@@ -2147,7 +2127,6 @@ void MTR_IVL_SUB::mtr_Accum1( // accumulate of one submeter-interval into anoth
21472127
// else end-of-calc
21482128
// accums/copies mtrSub1 into *this
21492129
{
2150-
#if 1
21512130
bool bCopy = (options & 1) != 0;
21522131
bool bFinalize = (options & 2) != 0;
21532132

@@ -2171,17 +2150,7 @@ void MTR_IVL_SUB::mtr_Accum1( // accumulate of one submeter-interval into anoth
21712150
{ // after load management (e.g. battery)
21722151
// handle all mbrs w/ *p variability
21732152
if (bCopy)
2174-
{ memcpy( this, mtrSub1, sizeof( MTR_IVL_SUB));
2175-
2176-
#if 0
2177-
tot = mtrSub1->tot;
2178-
bt = mtrSub1->bt;
2179-
cost = mtrSub1->cost;
2180-
dmd = mtrSub1->dmd;
2181-
dmdCost = mtrSub1->dmdCost;
2182-
dmdShoy = mtrSub1->dmdShoy;
2183-
#endif
2184-
}
2153+
memcpy( this, mtrSub1, sizeof( MTR_IVL_SUB));
21852154
else
21862155
{ tot += mtrSub1->tot;
21872156
bt += mtrSub1->bt;
@@ -2191,7 +2160,6 @@ void MTR_IVL_SUB::mtr_Accum1( // accumulate of one submeter-interval into anoth
21912160
dmdCost += mtrSub1->dmdCost;
21922161

21932162
// keep peak demand, and its cost thru month level
2194-
21952163
if (mtrSub1->dmd > dmd) // if source demand (peak use) greater
21962164
{ dmd = mtrSub1->dmd; // update largest hourly demand in destination
21972165
dmdShoy = mtrSub1->dmdShoy; // update peak date & time (subhr of year)
@@ -2200,28 +2168,6 @@ void MTR_IVL_SUB::mtr_Accum1( // accumulate of one submeter-interval into anoth
22002168
}
22012169
}
22022170
}
2203-
#else
2204-
2205-
// Add up uses and cost, and demand cost if month to year
2206-
2207-
VAccum( &tot, // add 2nd arg float vector to 1st arg
2208-
NENDUSES // vector length: # end uses
2209-
+ 1 // plus .tot, assumed to precede end uses,
2210-
+ 1 // plus .cost, assumed to immed follow end uses
2211-
+ (ivl==C_IVLCH_Y), // plus .dmdCost if month-to-year (thru month, largest
2212-
// dmdCost is used, not sum, by code just below).
2213-
&mtrSub1->tot);
2214-
// Keep peak demand, and its cost thru month level
2215-
2216-
if (mtrSub1->dmd > dmd) // if source demand (peak use) greater
2217-
{
2218-
dmd = mtrSub1->dmd; // update largest hourly demand in destination
2219-
dmdShoy = mtrSub1->dmdShoy; // update peak date & time (subhr of year)
2220-
if (ivl != C_IVLCH_Y) // thru month level, keep largest demand cost
2221-
dmdCost = mtrSub1->dmdCost; // .. (but for month to year, dmdCost is summed, above).
2222-
}
2223-
2224-
#endif
22252171
} // MTR_IVL_SUB::mtr_Accum1
22262172
//-----------------------------------------------------------------------------------------------------------
22272173
double MTR_IVL_SUB::mtr_NetBldgLoad() const // building load (includes PV, excludes BT)
@@ -2362,7 +2308,7 @@ void TOPRAT::tp_DoDateDowStuff() // do date, day of week, and holiday stuff for
23622308

23632309
// allocate date string storage once. Small, error unlikely, abort ok. dmpak.cpp.
23642310
if (!dateStr)
2365-
dmal( DMPP( dateStr), max( TDDATELENMAX+1U, strlen("ddd Jan xxx cooling design day xx")), ABT); // small, error unlikely, let program abort.
2311+
dmal( DMPP( dateStr), max( TDDATELENMAX+1U, strlen("ddd Jan xxx cooling design day xx")), ABT); // small, error unlikely, let program abort.
23662312

23672313
if (tp_autoSizing) // set at start setup, cncult2.cpp
23682314
{

src/SLPAK.CPP

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void FC slday( // set up daily data in current SLLOCDAT
379379

380380
sldec( dec, timetype); // set declination-related slloccur members, below.
381381

382-
} /* slday */
382+
} // slday
383383
//======================================================================
384384
LOCAL void FC NEAR sldaydat(
385385

src/SLPAK.H

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
local time to solar (and date still changes at local/daylite midnite),
1818
so range is bit more than -Pi to Pi. (mainly used when sun is up.) */
1919

20-
#if 1
21-
#define HA 0.26179939
22-
#else
20+
#if defined( SOLARFIX)
2321
const double HA = k2Pi/24.; // earth rotation, rad/hr
2422
// for converting hours to hour angle
2523
// then add SLLOCDAT.tmconst.
24+
#else
25+
#define HA 0.26179939
2626
#endif
2727

2828
/*--------------------------------- TYPES ---------------------------------*/

src/csevrsn.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
// version # for current build
1515
// change ONLY here
1616
#define CSEVRSN_MAJOR 0
17-
#define CSEVRSN_MINOR 845
17+
#define CSEVRSN_MINOR 847
1818

1919
// version # as quoted text ("x.xxx")
2020
#define CSEVRSN_TEXT MAKE_LIT(CSEVRSN_MAJOR##.##CSEVRSN_MINOR)
2121

2222
// ONLY comments below here
2323

2424
/* History:
25+
0.847: fix inconsistent xs_UNom
26+
0.846: SOLARFIX test version, 10-25-2017
2527
0.845: added DHWHEATER whUAMult, 10-18-2017
2628
0.844: HPWH debug export enhanced, 10-17-2017
2729
0.843: BATTERY last hour values; DESCOND prelim version; 10-10-17

test/2Zone.cse

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ AIRHANDLER "Infil" //Constant Volume no energy, heating or cooling to model in
304304
gnMeter=GAINMETER
305305
gnEndUse=Lit
306306
gnPower=INTGAIN*.4
307+
308+
GAIN IX1
309+
gnMeter=GAINMETER
310+
gnEndUse=DHW
311+
gnPower=$DayOfYear
307312

308313
SURFACE Roof
309314
sfType=Ceiling
@@ -425,6 +430,11 @@ AIRHANDLER "Infil" //Constant Volume no energy, heating or cooling to model in
425430
gnMeter=GAINMETER
426431
gnEndUse=Lit
427432
gnPower=INTGAIN*.4
433+
434+
GAIN Ix2
435+
gnMeter=GAINMETER
436+
gnEndUse=Htg
437+
gnPower=$DayOfYear*.9
428438

429439
SURFACE Roof
430440
sfType=Ceiling
@@ -573,11 +583,15 @@ TERMINAL "infil" //Constant vol, no heat or cool to model infil
573583

574584
//--------- REPORTS ------------
575585

576-
REPORT rpType=ZDD rpZone=Z1
577586
REPORT rpType=AH rpAH="MainAH" rpFreq=Month
578587

579-
REPORT rpType=MTR rpMeter=HEATMETER rpFreq=Month
580-
REPORT "Heating Energy"
588+
REPORT rpType=MTR rpMeter=ALL rpFreq=Month
589+
590+
REPORT rpType=MTR rpMeter=All rpFreq=Day rpDayBeg=May 14 rpDayEnd=May 24
591+
592+
REPORT rpType=MTR rpMeter=All rpFreq=Hour rpDayBeg=May 15 rpDayEnd=May 15
593+
594+
REPORT "Heating Energy"
581595
rpType=UDT
582596
rpFreq=YEAR
583597
reportcol colVal=@meter[HEATMETER].Y.dmd/3413 ColHead="Pk kW"
@@ -586,9 +600,7 @@ TERMINAL "infil" //Constant vol, no heat or cool to model infil
586600
reportcol [email protected] ColHead="Pk Hr"
587601
reportcol colval=@meter[HEATMETER].y.tot* 0.000000292997 ColHead="Yr mWh"
588602

589-
590-
REPORT rpType=MTR rpMeter=COOLMETER rpFreq=Month
591-
REPORT "Cooling Energy"
603+
REPORT "Cooling Energy"
592604
rpType=UDT
593605
rpFreq=YEAR
594606
reportcol colVal=@meter[CoolMETER].Y.dmd/3413 ColHead="Pk kW"
@@ -597,8 +609,6 @@ TERMINAL "infil" //Constant vol, no heat or cool to model infil
597609
reportcol [email protected] ColHead="Pk Hr"
598610
reportcol colval=@meter[CoolMETER].y.tot* 0.000000292997 ColHead="Yr mWh"
599611

600-
REPORT rpType=MTR rpMeter=GAINMETER rpFreq=Month
601-
602612
REPORT rpType=ZEB rpZone=Z1 rpDayBeg=Jan 4 rpDayEnd=Jan 4 rpFreq=Hour
603613
REPORT rpType=AH rpAH="MainAH" rpDayBeg=Jan 4 rpDayEnd=Jan 4 rpFreq=HOUR
604614
REPORT rpType=ZEB rpZone=Z1 rpDayBeg=Jul 26 rpDayEnd=Jul 26 rpFreq=Hour
@@ -609,6 +619,7 @@ TERMINAL "infil" //Constant vol, no heat or cool to model infil
609619
// REPORT rpType=AH rpAH="Infil" rpDayBeg=Jul 26 rpDayEnd=Jul 26 rpFreq=HOUR
610620
// REPORT rpType=AH rpAH="Infil" rpDayBeg= Oct 16 rpDayEnd= Oct 16 rpFreq=HOUR
611621

622+
REPORT rpType=ZDD rpZone=Z1
612623

613624

614625
#if 0

0 commit comments

Comments
 (0)