Skip to content
Draft
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
61 changes: 55 additions & 6 deletions src/CNRECS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on
*declare "void tp_DoDateDowStuff();"
*declare "void tp_DTInit();"
*declare "void tp_DoDTStuff();"
*declare "int tp_WthrHoursInDay( int jDayX) const;"
*declare "int tp_WthrDayHr0( int jDayX, int yrDays) const;"
*declare "bool tp_IsDTAtDayBeg( int jDayX) const;"
*declare "void tp_tmrSnapshot();"
*declare "const char* tp_AuszDoing() const;"
*declare "RC tp_BegDesDay();"
Expand Down Expand Up @@ -261,7 +264,7 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on
// brfr.h:getWorkDayMask() default, opk\progr.h/cpp:ProGrSub::workDayMask.
*i NOYESCH DT // YES (default) to enable daylight saving time
*r DOY DTBegDay // Daylight saving start day, 1-365, default 1st Sun (Sun after 1st Sat?) in April
*r DOY DTEndDay // Daylight saving end day, 1-365, defaulted by cncult2.cpp code to last Sun in October
*r DOY DTEndDay // Daylight saving end day, 1-365, defaulted by cncult2.cpp code to first Sun in November

// wind speed adjustment, see cgwthr.cpp
// appl sees Top.windF * max( wthrfile.wndSpd, Top.windSpeedMin);
Expand Down Expand Up @@ -764,6 +767,7 @@ RECORD WFILE "weatherFile" *RAT // weather file info, one static instance "Wfile
*declare "RC wf_EtDecodeHdr( char* hdr, int erOp, float* clrnss, float* turbid, float* atmois);"
*declare "RC wf_DecodeHdrFields( char* hdr, struct WFHTAB* wfht0, int erOp);"
*declare "RC wf_FillWDYEAR( int erOp=WRN);"
*declare "RC wf_InitStatRATs() const;"
*declare "enum { gshrFILEDAY, gshrDSDAY, gshrDSDAY0 };"
*declare "RC wf_GenSubhrRad( SLRINTERPMETH slrInterpMeth, int dayTy, int jDay);"
*declare "RC wf_GetSubhrRad( int jDay, int iHrST, int iSh, float& radBeamAv, float& radDiffAv);"
Expand All @@ -777,8 +781,6 @@ RECORD WFILE "weatherFile" *RAT // weather file info, one static instance "Wfile
*declare "RC wf_CSWHdrVal( const char* key, const char* val, float& v, RC& rcAll, int erOp=WRN);"
*declare "RC wf_CSWHdrVal( const char* key, const char* val, int& v, RC& rcAll, int erOp=WRN);"
*declare "RC wf_CSWPosHr1( int erOp=WRN);"
*declare "RC wf_T24DLLOpen( const char* wfName, int erOp);"
*declare "RC wf_T24DLLRead( WDHR* pwd, int jDay, int iHr, int erOp);"
*declare "RC wf_EPWOpen( const char* wfName, int erOp );"
*declare "RC wf_EPWPosHr1( int erOp=WRN);"
*declare "RC wf_EPWRead( WDHR* pwd, int jDay, int iHr, int erOp );"
Expand Down Expand Up @@ -862,9 +864,8 @@ RECORD WDHR "wfdata sub" *SUBSTRUCT // hourly data substructure for WFDATA
*declare "RC wd_GenDesCondHeating( WFILE* pWF, int jDayST, int iHrST);"
*declare "RC wd_UpdateDesCondHeating();"
*declare "void wd_FillFromDESCOND( const DESCOND& dc, int iHr);"
*declare "void wd_SetDayValues( const class WDDAY& wdd);"
*declare "void wd_SetDayValuesIfMissing( const class WDDAY& wdd);"
*declare "void wd_SetTdvElecHrRank( const class WDDAY& wdd);"
*declare "void wd_SetDayValues( const class WDDAY& wdd, int options=0);"
*declare "void wd_SetDayValues( const class WFSTATSDAY& wxd, const class WFSTATSDAY& wxdPv, int options=0);"
*declare "void wd_ShiftTdvElecHrRankForDST();"
*declare "bool wd_HasTdvData() const;"

Expand Down Expand Up @@ -953,6 +954,54 @@ RECORD WFDATA "weather" *RAT // hourly weather data, one static instance "Wthr",
// WDHR used elsewhere (e.g. whole file pre-read)
*END // WFDATA
//========================================================================================================
RECORD WFSTATSSUB "wfstatssub" *SUBSTRUCT // aggregated weather file statistics (day, month, year)
*prefix wx_
*declare "void wx_Accum( const WFSTATSSUB& wxSrc, bool bFirst, bool bLast);"

FLOAT wx_taDbMin; // min air dry bulb temp, F
FLOAT wx_taDbAvg; // mean air dry bulb temp, F
FLOAT wx_taDbMax; // max air dry bulb temp, F
FLOAT wx_tGrnd; // ground temp, F. Calculated with Kusuda model
// depth=10 ft, soilDiff = per user input
FLOAT wx_tMains; // cold water mains temp, F. calc'd per
// CEC 2013 methods, see CalcTMainsCEC()
FLOAT wx_GHI; // total GHI for interval, Btu/ft2
FLOAT wx_DHI; // total DHI for interval, Btu/ft2
FLOAT wx_DNI; // total DNI for interval, Btu/ft2

FLOAT wx_tdvElecPk; // TDV peak
FLOAT wx_tdvElecAvg; // TDV avg

*END // WFSTATSSUB
//========================================================================================================
RECORD WFSTATSDAY "wfstatsday" *RAT // aggregated weather file statistics for one day

*prefix wx_

*declare "RC wx_ComputeStats( const class WDYEAR& wdy);"
*declare "static int wx_TdvPkCompare(const void* p1, const void* p2);"

*d SI wx_dayOfYear // day of year of this WFSTATSDAY (1-365/366)

*d *noname *nest WFSTATSSUB d

*d SI wx_tdvElecPkRank; // rank within year of wx_tdvElecPk (1-366)
*d FLOAT wx_tdvElecPvPk; // peak for prior day
*d FLOAT wx_tdvElecAvg01; // avg for print day
*d *ARRAY 24 SI wx_tdvElecHrSTRank; // TDV hr ranking
// [ 0] = hour (1-24) with highest TDVElec
// [ 1] = hour (1-24) with 2nd highest TDVElec
// [ 2 .. 23] etc

// mean dry bulb temp over recent days, F
// *not* including current day
*d FLOAT wx_taDbAvg01; // 1 day
*d FLOAT wx_taDbAvg07; // 7 day
*d FLOAT wx_taDbAvg14; // 14 day
*d FLOAT wx_taDbAvg31; // 31 day

*END // WFSTATSDAY
//========================================================================================================
RECORD DESCOND "DESCOND" *RAT // cooling design conditions
*prefix dc_
*declare "RC dc_CkF();"
Expand Down
12 changes: 4 additions & 8 deletions src/cgwthr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,11 @@ RC TOPRAT::tp_WthrBegHour() // start-hour weather stuff: read file, set up publ
Wthr = WthrNxHr;

// get NEXT HOUR's weather data, needed to interpolate irradiance variables
if ( iHrST < 23 || !isLastDay // no read-ahead at main sim last day, last hour: might be no wthr data in file
|| tp_autoSizing) // do read-ahead when autosizing: wraps day, and day may be repeated.
{
rc = WthrNxHr.d.wd_WfReader( TRUE, // read next hour weather data, RCOK if OK. fcn below.
// do read-ahead when autosizing: wraps day, and day may be repeated.
rc = WthrNxHr.d.wd_WfReader( TRUE, // read next hour weather data, RCOK if OK. fcn below.
&Wfile); // public open weather file structure
if (rc)
return rc; // if failed (msg issued), return to caller
}
// else: last hour of run: re-use current hour values (already in WthrNxHr) as next hour values.
if (rc)
return rc; // if failed (msg issued), return to caller

// set top members from weather data
// integrated-over-hour values
Expand Down
7 changes: 6 additions & 1 deletion src/cncult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cnculti.h: cncult internal functions shared only amoung cncult,2,3,4,5,6.cpp */
#include "rccn.h" // TOPRATstr ZNRstr SFIstr SDIstr
#include "msghans.h" // MH_S0400

#include "cnguts.h" // Top CTWINDOW
#include "cnguts.h" // Top
#include "vrpak.h" // isUsedVrFile 7-13-92

#include "cuparse.h" // TYFL TYSTR evfTx
Expand Down Expand Up @@ -3128,6 +3128,10 @@ WFDATA Wthr((anc<WFDATA>*)& WthrR, 0); // record containing current hour's wea
makAncWFDATA2(WthrNxHrR, nullptr, "weatherNextHour"); // basAnc for...
WFDATA WthrNxHr((anc<WFDATA>*)& WthrNxHrR, 0); // record containing current next hour's weather data,
// extracted and adjusted, for cgWthr.cpp read-ahead

makAncWFSTATSDAY(WfStatsDay, nullptr);
// WFSTATSDAY WfStatsDay((anc<WFSTATSDAY>*)& WfStatsDay, 0);

makAncDESCOND(DcR, dcT); // design conditions

// zones, transfers, gains,
Expand Down Expand Up @@ -3295,6 +3299,7 @@ void FC cnPreInit() // preliminary cncult.cpp initialization [needed before sho
// and are detected if used in expressions.)
WthrR.ba_flags |= RFNOEX;
WthrNxHrR.ba_flags |= RFNOEX;
WfStatsDay.ba_flags |= RFNOEX;

SetupProbeModernizeTables();

Expand Down
2 changes: 0 additions & 2 deletions src/cncult6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#include "cnguts.h" // HpB BlrB

//#include <cuparse.h> // perl
//#include <exman.h> // ISNANDLE ISUNSET
#include "cul.h" // FsSET oer oWarn

//declaration for this file:
Expand Down
3 changes: 0 additions & 3 deletions src/cndefns.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@
#define AIRNET_EIGEN // define to use Eigen for AirNet solving
// else gaussjb

#undef WTHR_T24DLL // #define to support T24WTHR.DLL source for hourly compliance
// weather data

// implement zone exhaust fan, 8-10
#define ZONE_XFAN // define to enable zone exhaust fan implementation, 8-10
// FAN object historically in ZNISUB.xfan but previously not simulated
Expand Down
120 changes: 93 additions & 27 deletions src/cnguts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,20 @@ RC TOPRAT::tp_MainSimI() // Main hourly simulation inner routine
// caller: cgMainsim
RC rc=RCOK;


#if defined( _DEBUG)
printf("\nDT=%d DTBegDay=%s DTEndDay=%s", DT, tddys(DTBegDay), tddys(DTEndDay));
static bool bDTWas = false;
for (int jdx = 1; jdx<366; jdx++)
{
bool bDT = tp_IsDTAtDayBeg(jdx);
if (jdx==1 || bDT != bDTWas)
printf(" %s: %d", tddys(jdx), bDT);
bDTWas = bDT;
}
printf("\n");
#endif

// initialization not repeated after warmup

// set "doing" values before initialization
Expand Down Expand Up @@ -1129,33 +1143,6 @@ x pZR->zr_InitCurr(); // 0 ZNRES.curr
return rc;
} // cgAfterWarmup
//-----------------------------------------------------------------------------------------------------------
void TOPRAT::tp_DTInit() // Init Top.isDT, Top.jDayST, Top.iHrST at start warmup or run or autosizing design day.

// Uses Top.tp_autoSizing, Top.jDay.

{
// called from tp_MainSimI at start warmup and run, or from a cgAuszI callee for each new design day.

if (DT != C_NOYESCH_YES) // if no DT to be used in this run
isDT = 0; // DT is now off
else
{ // note for autoSizing, jDay is already suitably set for month of design day.
if (DTEndDay >= DTBegDay) // if normal (Northern Hemisphere) (for equal dates, isDT = 0 falls out).
isDT = jDay > DTBegDay && jDay <= DTEndDay; // 1 (exactly) if DT in use at hr 0 of 1st day of run, else 0
else // if DT starts later in year than ends: possible in Southern Hemisphere
isDT = jDay > DTBegDay || jDay <= DTEndDay; // 1 if DT in use at hr 0 of 1st day of run
}
if (isDT) // if DT in use
{
iHrST = 23-1; // initial standard time will be 11PM (23) after tp_DoDTStuff ++'s it.
jDayST = // initial standard time date
tp_autoSizing ? jDay // autoSizing ST date same cuz no ++ at midnite (days wrap to self!)
: jDay > 1 ? jDay-1 // initial main sim ST date is day before run start
: 365; // .. which is Dec 31 (no leap years) if run starts on Jan 1
}
// else: DT not in use: 1st tp_DoDTStuff call will init ST variables.
} // TOPRAT::tp_DTInit
//-----------------------------------------------------------------------------------------------------------
LOCAL RC FC doIvlExprs( // evaluate and store user-input variable expressions for interval

int ivlStage) // interval stage
Expand Down Expand Up @@ -3082,6 +3069,34 @@ void TOPRAT::tp_DoDateDowStuff() // do date, day of week, and holiday stuff for
isBegWorkWeek = isWorkDay && yesterNonWork; // workDay after non-workDay, for $isBegWorkWeek
} // TOPRAT::tp_DoDateDowStuff
//-----------------------------------------------------------------------------------------------------------
void TOPRAT::tp_DTInit() // Init Top.isDT, Top.jDayST, Top.iHrST at start warmup or run or autosizing design day.

// Uses Top.tp_autoSizing, Top.jDay.

{
// called from tp_MainSimI at start warmup and run, or from a cgAuszI callee for each new design day.

if (DT != C_NOYESCH_YES) // if no DT to be used in this run
isDT = 0; // DT is now off
else
{ // note for autoSizing, jDay is already suitably set for month of design day.
if (DTEndDay >= DTBegDay) // if normal (Northern Hemisphere) (for equal dates, isDT = 0 falls out).
isDT = jDay > DTBegDay && jDay <= DTEndDay; // 1 (exactly) if DT in use at hr 0 of 1st day of run, else 0
else // if DT starts later in year than ends: possible in Southern Hemisphere
isDT = jDay > DTBegDay || jDay <= DTEndDay; // 1 if DT in use at hr 0 of 1st day of run
}
if (isDT) // if DT in use
{
iHrST = 23-1; // initial standard time will be 11PM (23) after tp_DoDTStuff ++'s it.
jDayST = // initial standard time date
tp_autoSizing ? jDay // autoSizing ST date same cuz no ++ at midnite (days wrap to self!)
: jDay > 1 ? jDay-1 // initial main sim ST date is day before run start
: 365; // .. which is Dec 31 (no leap years) if run starts on Jan 1
}
// else: DT not in use: 1st tp_DoDTStuff call will init ST variables.

} // TOPRAT::tp_DTInit
//-----------------------------------------------------------------------------------------------------------
void TOPRAT::tp_DoDTStuff() // update .isDT, possibly .iHr, and STANDARD TIME time & date variables

// uses .DT, .DTBeg/EndDay, .iHr, .jDay, .tp_date.
Expand Down Expand Up @@ -3130,6 +3145,57 @@ void TOPRAT::tp_DoDTStuff() // update .isDT, possibly .iHr, and STANDARD TIME ti
iHrST++;
} // TOPRAT::tp_doDTStuff
//-----------------------------------------------------------------------------------------------------------
int TOPRAT::tp_WthrDayHr0( // idx of initial hour of arbitrary day (DT aware)
int jDayX, // day of year sought (1 - 365/366)
// jDayX=-1: Dec-30; jDayX=0: Dec-31; jDaXy=1: Jan-1; jDayX=2: Jan-2
int yrDays) const // # of days in wthr file year
{
int yrHrs = yrDays * 24;
int hr0 = (24 * (jDayX - 1) + yrHrs) % yrHrs;
if (DT==C_NOYESCH_YES)
{
if (DTEndDay > DTBegDay)
{
if (jDayX > DTBegDay && jDayX <= DTEndDay)
--hr0;
}
else if (jDayX > DTBegDay || jDayX <= DTEndDay)
--hr0;
}
return hr0;

} // TOPRAT::tp_WthrDayHr0
//-----------------------------------------------------------------------------------------------------------
bool TOPRAT::tp_IsDTAtDayBeg( // daylight savings for arbitrary day
int jDayX) const // day of year (1 - 365/366).

// return true iff daylight savings is in effect at the beginning of jDayX
{
if (DT != C_NOYESCH_YES)
return false; // daylight savings not modeled

// note: DTBegDay != DTEndDay always due to input checking
if (DTEndDay > DTBegDay)
return jDayX > DTBegDay && jDayX <= DTEndDay;
else
return jDayX > DTBegDay || jDayX <= DTEndDay;

} // TOPRAT::tp_IsDTAtDayBeg
//-----------------------------------------------------------------------------------------------------------
int TOPRAT::tp_WthrHoursInDay( // # of weather data hours in arbitrary day
int jDayX) const // day of year (1 - 365/366)
{
int hrsInDay = 24;
if (DT==C_NOYESCH_YES)
{ if (jDayX == DTBegDay)
hrsInDay = 23;
else if (jDayX == DTEndDay)
hrsInDay = 25;
}
return hrsInDay;

} // TOPRAT::tp_WthrHoursInDay
//-----------------------------------------------------------------------------------------------------------
void TOPRAT::tp_tmrSnapshot() // probe-able copies of timing data
// call e.g. daily
{
Expand Down
7 changes: 6 additions & 1 deletion src/cnguts.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,20 @@ static_assert(NDHWENDUSESXPP == C_DHWEUXCH_COUNT, "Inconsistent DHW UEX constant

// more comments and set/used info in rundata.cpp

//-- cnguts.cpp run record basAncs --
// global run record basAncs --
extern anc<TOPRAT> TopR; // basAnc for Top run record. ancrec.h template class.
extern TOPRAT Top; // the one static Top runtime record. rccn.h type.

// global weather-related
extern anc<WFILE> WfileR; // basAnc for the one weather file info record 1-94. Runtime only - no input basAnc.
extern WFILE Wfile; // the one static WFILE record with overall info and file buffer for 1 day's data
extern anc<WFDATA> WthrR; // basAnc for hour's weather data record. Runtime only - no corress input basAnc.
extern WFDATA Wthr; // the one static WFDATA record containing unpacked & adjusted data for hour 1-94
extern anc<WFDATA> WthrNxHrR; // basAnc for next hour's weather data record ("weatherNextHour")
extern WFDATA WthrNxHr; // static record for next hour's unpacked & adjusted data for cgwthr.cpp read-ahead

extern anc<WFSTATSDAY> WfStatsDay; // Weather statistics by day

extern anc<DESCOND> DcR; // design conditions

extern anc<ACCUMULATOR> AccumR; // accumulators
Expand Down
9 changes: 8 additions & 1 deletion src/cuprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,14 @@ w break;
break;

default:
errorSub = "unrecognized";
if (dt & DTBCHOICB)
{
lop = PSRATLOD2; // basAnc record load 2 bytes: fetches SI/USI.
ty = TYSI;
sz = 2;
}
else
errorSub = "unrecognized";
break;

} // switch (dt)
Expand Down
2 changes: 1 addition & 1 deletion src/exman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ RC FC exWalkRecs()

// returns non-RCOK if error (eg out of memory)
{
USI os[1000]; // big enough for max fields in any record
USI os[5000]; // big enough for max fields in any record

// loop over all record anchors as "registered" in basAnc::al and ::statSetup
BP b;
Expand Down
Loading
Loading