Skip to content

Commit

Permalink
Merge pull request #492 from cse-sim/irskytemp
Browse files Browse the repository at this point in the history
Add capability of deriving sky temperature from weather file horizontal infrared radiation
  • Loading branch information
chipbarnaby authored Jul 2, 2024
2 parents ff384a5 + be880e6 commit 943ca98
Show file tree
Hide file tree
Showing 8 changed files with 2,561 additions and 34 deletions.
1 change: 1 addition & 0 deletions doc/src/records/top-members.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ DEFAULT, Default: tSky from weather file if available else Berdahl-Martin
BERDAHLMARTIN, Berdahl-Martin (tSky depends on dew point, cloud cover, and hour)
DRYBULB, tSky = dry-bulb temperature (for testing)
BLAST, Blast model (tSky depends on dry-bulb)
IRHORIZ, Derives tSky from horizonal infrared data from the weather file (available on some EPW files only). Caution: minimal error checking! Missing weather file IR values are not handled correctly.
END
%>

Expand Down
1 change: 1 addition & 0 deletions src/CNDTYPES.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ PIPESEGP -- "class PIPESEG*"
BERDAHLMARTIN "BerdahlMartin"
DRYBULB "DryBulb"
BLAST "Blast"
IRHORIZ "IRHoriz"
}
*choicb EXSHMODELCH {
NONE "None"
Expand Down
6 changes: 5 additions & 1 deletion src/CNRECS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ RECORD WDHR "wfdata sub" *SUBSTRUCT // hourly data substructure for WFDATA
*prefix wd_
*declare "void wd_Init( int options=0);"
*declare "WDHR& Copy( const WDHR& wd, int options=0);"
*declare "void wd_WriteCSV( int jDayST, int iHr) const;"
*declare "RC wd_WfReader( BOO nextHour, WFILE* pWF);"
*declare "void wd_Adjust( int iHrST);"
*declare "void wd_SetSolarValues( int jDayST, int iHrST);"
Expand Down Expand Up @@ -831,7 +832,10 @@ RECORD WDHR "wfdata sub" *SUBSTRUCT // hourly data substructure for WFDATA
*h float wd_glrad // global irradiance on horizontal surface, for daylighting calculations
*h float wd_cldCvr // total cloud cover in tenths, 0-11, or 15 for missing data

*h float wd_tSky // sky temperature, F from weather file or CalcSkyTemp() (Berdahl-Martin)
*h float wd_irHoriz // horizontal infrared sky radiation (integrated value for hour, Btu/ft2)
// available for epw files only
// used to calc Top.tSkyHr iff Top.skyModelLW == C_SKYMODLWCH_IRHORIZ
*h float wd_tSky // default sky temperature, F from weather file or CalcSkyTemp() (Berdahl-Martin)
// Note: Top.tSkyHr alternative value per Top.skyModelLW
*h float wd_tGrnd // ground temperature, F
*h float wd_taDp // air dew point temp, F
Expand Down
2 changes: 1 addition & 1 deletion src/cgwthr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ RC TOPRAT::tp_WthrFillDsDay(
{ // read actual day
rc = pWF->wf_Read(&wd, jDayST, iH, WRN | wfOp); // Read hour's data from weather file
if (tp_AuszWthrSource() == TOPRAT_COOLDSCOND)
{ // DSCOND design day: overwrite/adjust weather file values with generated
{ // DESCOND design day: overwrite/adjust weather file values with generated
int iDC = tp_coolDsCond[tp_dsDayI - 1];
const DESCOND& DC = DcR[iDC];
wd.wd_FillFromDESCOND(DC, iH);
Expand Down
67 changes: 46 additions & 21 deletions src/wfpak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,26 @@ RC WDHR::wd_Unpack( // single-hour unpack

return RCOK;
} // WDHR::wd_UnPack
//--------------------------------------------------------------------------
#if defined( _DEBUG)
void WDHR::wd_WriteCSV( // data writer for ad-hoc exports
int jDayST,
int iH) const
{
static FILE* pF = NULL; // file
if (!pF)
{
const char* fName = "wdhr.csv";
pF = fopen(fName, "wt");
if (pF)
fprintf(pF, "doy,hr,tdb,dni,dhi,ghi\n");
}
if (pF)
fprintf(pF, "%d,%d,%0.1f,%0.1f,%0.1f,%0.1f\n",
jDayST, iH, wd_db, wd_DNI, wd_DHI, wd_glrad);

} // WDHR::wd_WriteCSV
#endif
//============================================================================

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1575,12 +1595,14 @@ float CalcSkyTemp( // sky temp model
// C_SKYMODLWCH_BERDAHLMARTIN
// C_SKYMODLWCH_BLAST
// C_SKYMODLWCH_DRYBULB
// C_SKYMODLWCH_IRHORIZ
int iHr, // hour of day (0 - 23, 0=midnight - 1 AM)
float taDb, // dry bulb temp, F
float taDp, // dew point temp, F
float cldCvr, // total cloud cover, tenths (0.f - 10.f)
float presAtm // atmospheric pressure, in Hg
/*float ceilHt*/) // TODO
float presAtm, // atmospheric pressure, in Hg
float irHoriz // Horizontal infrared radiation, Btu/ft2
/*, float ceilHt*/) // TODO


// TODO
Expand All @@ -1604,6 +1626,8 @@ float CalcSkyTemp( // sky temp model
float tSky;
if (skyModelLW == C_SKYMODLWCH_DRYBULB)
tSky = taDb;
else if (skyModelLW == C_SKYMODLWCH_IRHORIZ)
tSky = DegRtoF(pow( irHoriz/sigmaSB, 0.25));
else
{ float eSky;
if (skyModelLW == C_SKYMODLWCH_BLAST)
Expand Down Expand Up @@ -1649,10 +1673,10 @@ RC WDHR::wd_EstimateMissingET1( // estimate values from ET1 data
} // WDHR::wd_EstimateMissingET1
//-----------------------------------------------------------------------------
float WDHR::wd_CalcSkyTemp(
int skyModelLW, // C_SKYMODLWCH_BERDAHLMARTIN, _BLAST, _DRYBULB,
int skyModelLW, // C_SKYMODLWCH_BERDAHLMARTIN, _BLAST, _DRYBULB, _IRHORIZ
int iHr) // hour of day (0 - 23)
{ return ::CalcSkyTemp( skyModelLW,
iHr, wd_db, wd_taDp, wd_cldCvr, PsyPBar);
iHr, wd_db, wd_taDp, wd_cldCvr, PsyPBar, wd_irHoriz);
} // WDHR::wd_CalcSkyTemp
//=============================================================================

Expand Down Expand Up @@ -3005,28 +3029,28 @@ RC WDHR::wd_EPWReadHr( // read 1 hour's data from EPW weather file
int yr, m, d, h, minute;
char sSink[ 100];
// temporaries for SI values
float db, dp, rh, prs, irhoriz, glrad, bmrad, dfrad, wndDir, wndSpd, tsc, osc;
float db, dp, rh, prs, irHoriz, glrad, bmrad, dfrad, wndDir, wndSpd, tsc, osc;
RC rc = RCOK;
while (1)
{ char wfLine[ WFMAXLNLEN];
pWF->yac->line( wfLine, sizeof( wfLine));
rc = pWF->yac->getLineCSV( erOp|YAC_NOREAD, pWF->isLeap,
"LLLLLCFFFFXXFFFFXXXXFFFF",
wfLine,
&yr, &m, &d, &h, &minute, // year, month / day / hour / minute (all 1-based)
&yr, &m, &d, &h, &minute, // 1 - 5 year, month / day / hour / minute (all 1-based)
_C( sSink), // data sources and uncertainty flags
&db, // dry bulb temp, degC
&dp, // dew point temp, degC
&rh, // relative humidity, %
&prs, // atmospheric station pressure, Pa
&irhoriz, // sky radiation, Wh/m2
&glrad, // global horizontal irradiation, Wh/m2
&bmrad, // direct normal irradiation, Wh/m2
&dfrad, // diffuse horizonal irradiation, Wh/m2
&wndDir, // wind direction, deg
&wndSpd, // wind spd, m/s
&tsc, // total sky cover, tenths
&osc, // opaque sky cover, tenths
&db, // 6 dry bulb temp, degC
&dp, // 7 dew point temp, degC
&rh, // 8 relative humidity, %
&prs, // 9 atmospheric station pressure, Pa
&irHoriz, // 12 sky radiation, Wh/m2
&glrad, // 13 global horizontal irradiation, Wh/m2
&bmrad, // 14 direct normal irradiation, Wh/m2
&dfrad, // 15 diffuse horizonal irradiation, Wh/m2
&wndDir, // 20 wind direction, deg
&wndSpd, // 21 wind spd, m/s
&tsc, // 22 total sky cover, tenths
&osc, // 23 opaque sky cover, tenths
NULL);
if (rc != RCBAD2)
{ if (rc)
Expand Down Expand Up @@ -3064,19 +3088,20 @@ x printf( "mismatch\n");
wd_wndDir = wndDir;
wd_wndSpd = VSItoIP( wndSpd);

wd_irHoriz = IrSItoIP(irHoriz);
wd_cldCvr = tsc;

wd_tSky = wd_CalcSkyTemp( C_SKYMODLWCH_BERDAHLMARTIN, h-1);

#if 0
// sky temp experiment
float tSkyIR = DegRtoF(pow( IrSItoIP( irhoriz)/sigmaSB, 0.25));
// sky temp compare
float tSkyIR = d_CalcSkyTemp( C_SKYMODLWCH_IRHORIZ, h-1);
static FILE* pF = NULL; // file
if (!pF)
{
const char* fName = "tSky.csv";
pF = fopen(fName, "wt");
fprintf(pF, "yr,mon,day,hr,osc,tsc,tSky_CSE,tSky_IR\n");
fprintf(pF, "yr,mon,day,hr,osc,tsc,tSky_BM (F),tSky_IR (F)\n");
}
fprintf(pF, "%d,%d,%d,%d,%0.1f,%0.1f,%0.1f,%0.1f\n", yr, m, d, h, osc, tsc, wd_tSky, tSkyIR);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/wfpak.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const int WF_SAVESLRGEOM = EROP7; // wfRead: do NOT overwrite solar geometry val

// public functions
float CalcSkyTemp( int skyModelLW, int iHr, float taDb, float taDp, float cldCvr,
float presAtm);
float presAtm, float irHoriz);


// end of wfpak.h
Loading

0 comments on commit 943ca98

Please sign in to comment.