Skip to content
Merged
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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "vendor/kiva"]
path = vendor/kiva
url = https://github.com/bigladder/kiva.git
[submodule "vendor/btwxt"]
path = vendor/btwxt
url = https://github.com/bigladder/btwxt.git
[submodule "vendor/googletest"]
path = vendor/googletest
url = https://github.com/google/googletest.git
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ source_group("Source Files" FILES ${source})
source_group("Header Files" FILES ${headers})
source_group("Def Files" FILES ${defs})

target_link_libraries(CSE ${libs})
target_link_libraries(CSE PRIVATE ${libs})

add_dependencies(CSE version_header)

Expand Down
2 changes: 1 addition & 1 deletion src/CNRECS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -3424,7 +3424,7 @@ x *declare "float rs_Inp115Default( float inp95, float inp82) const;"
x *declare "RC rs_SetDefaultsClg();"
#endif
*declare "RC rs_SetupBtwxtClg();"
*declare "RC rs_SetupBtwxt( class Btwxt::RegularGridInterpolator* &pRgi, const std::vector<struct VSPERFP> ppV);"
*declare "RC rs_SetupBtwxt( const char* tag, class Btwxt::RegularGridInterpolator* &pRgi, const std::vector<struct VSPERFP> ppV);"
*declare "RC rs_GetPerfBtwxt( class Btwxt::RegularGridInterpolator* pRgi, float tdbOut, float& cap, float& inp, float& capMin, float& inpMin);"
*declare "void rs_AuszFinalASHP();"
*declare "float rs_CapEffASHP( float tdbout=-999.f, int ashpModel=0, float fanHRtd=-1.f, float fanHOpr=-1.f, float COPAdjF=-1.f);"
Expand Down
6 changes: 1 addition & 5 deletions src/RCDEF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ set(headers
../xiopak.h
)

include_directories(
.
..
)

add_executable(RCDEF ${source} ${headers})
target_compile_features(RCDEF PRIVATE cxx_std_17)
target_include_directories(RCDEF PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${CSE_SOURCE_DIR}/src")
target_compile_definitions(RCDEF PRIVATE NODTYPES)
target_link_libraries(RCDEF PRIVATE cse_common_interface)
21 changes: 21 additions & 0 deletions src/ancrec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,27 @@ RC record::CheckArray( // check array input for expected count

return rc;
} // record::CheckArray
//-----------------------------------------------------------------------------
/*virtual*/ void record::ReceiveMessage( // receive callback message
MSGTY msgTy, // message type: msgtyERROR etc
const char* msg) // message text
// logs/displays message with record type and name
// if msgTy == msgtyERROR, does not return
{
switch (msgTy)
{
case MSGTY::msgtyERROR:
oer(msg);
err(PABT|NOPREF, "Cannot recover from error above.");
break;
case MSGTY::msgtyWARNING:
oWarn(msg);
break;
default:
oInfo(msg);
break;
}
} // record::ReceiveMessage
//=============================================================================

///////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/ancrec.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class record // base class for records
virtual void DelSubOjects( int /*options*/=0) {} // override to delete records heap objects
virtual RC RunDup(const record* pSrc, int options=0) { Copy(pSrc, options); return RCOK; }
virtual void ReceiveRuntimeMessage( const char* /*msg*/) { }
virtual void ReceiveMessage(MSGTY msgTy, const char* msg);
virtual const char* GetDescription(int /*options*/ = 0) { return ""; }
virtual int ReportBalErrorsIf( int balErrCount, const char* ivlText) const;
private:
Expand Down
2 changes: 2 additions & 0 deletions src/cnglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ const int IGNX = 0x0100; // "extra ignore" -- no msg, do not return RCBAD (orMs
const int ERRRT = ERR | RTMSG;
const int WRNRT = WRN | RTMSG;

enum class MSGTY { msgtyUNKNOWN = 0, msgtyERROR, msgtyWARNING, msgtyINFO, msgtyDEBUG };

// options for rmkErr:screen() and :logit() remark display
const int NONL = 0x1000; // do NOT force remark to the beginning of its own line (default: start each message on new line)
const int DASHES = 0x2000; // separate this remark from preceding & following message with ------------
Expand Down
41 changes: 27 additions & 14 deletions src/cnloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4645,9 +4645,12 @@ RC RSYS::rs_SetupASHP() // set ASHP defaults and derived parameters

#if defined( _DEBUG)
// back-calc checks
float COP;
[[ maybe_unused]] float capHt = rs_PerfASHP(0, 47.f, COP);
capHt = rs_PerfASHP(0, 17.f, COP);
if (rc == RCOK)
{
float COP;
[[ maybe_unused]] float capHt = rs_PerfASHP(0, 47.f, COP);
capHt = rs_PerfASHP(0, 17.f, COP);
}
#endif

return rc;
Expand Down Expand Up @@ -4808,7 +4811,7 @@ RC RSYS::rs_SetupCHDHW() // check/set up combined heat / DWH

if (!rc)
{
rs_pCHDHW = new CHDHW();
rs_pCHDHW = new CHDHW( this);
float blowerEfficacy = float(rs_pCHDHW->hvt_GetRatedBlowerEfficacy());
if (!IsSet(RSYS_FANPWRH))
rs_fanPwrH = blowerEfficacy;
Expand Down Expand Up @@ -4909,15 +4912,15 @@ RC RSYS::rs_SetRunConstantsASHP() // finalize constant data for simulation
ppV.emplace_back(17.f, rs_cap17, rs_COP17, rs_CapMin17(), rs_COPMin17);
ppV.emplace_back(35.f, rs_cap35, rs_COP35, capMin35, rs_COPMin35);
ppV.emplace_back(47.f, rs_cap47, rs_COP47, rs_CapMin47(), rs_COPMin47);
rc |= rs_SetupBtwxt(rs_pRgiHtg[ 0], ppV);
rc |= rs_SetupBtwxt("Heating w/defrost", rs_pRgiHtg[0], ppV);

// steady-state performance (no defrost degradation)
// linear w/o 35 F point
// used iff temp in 17 - 45 F range
ppV.clear();
ppV.emplace_back(17.f, rs_cap17, rs_COP17, rs_CapMin17(), rs_COPMin17);
ppV.emplace_back(47.f, rs_cap47, rs_COP47, rs_CapMin47(), rs_COPMin47);
rc |= rs_SetupBtwxt(rs_pRgiHtg[1], ppV);
rc |= rs_SetupBtwxt("Heating w/o defrost", rs_pRgiHtg[1], ppV);

return rc;
} // RSYS::rs_SetRunConstantsASHP
Expand All @@ -4934,7 +4937,7 @@ RC RSYS::rs_SetupBtwxtClg()
ppV.emplace_back(115.f, -rs_cap115, rs_COP115, -rs_CapMin115(), rs_COPMin115);

// Populate Btwxt interpolator grid data from performance points
rc |= rs_SetupBtwxt(rs_pRgiClg, ppV);
rc |= rs_SetupBtwxt("Cooling", rs_pRgiClg, ppV);

return rc;
} // RSYS::rs_SetupBtwxtClg
Expand Down Expand Up @@ -4969,9 +4972,11 @@ float RSYS::rs_InpHtCurSpeedF() const
} // RSYS::rs_InpHtCurSpeedF()
//-----------------------------------------------------------------------------
RC RSYS::rs_SetupBtwxt( // init/populate btwxt for heating runtime interpolation
Btwxt::RegularGridInterpolator* & pRgi, // returned: heap ptr to Btwxt interpolator object
// note: any prior contents deleted
const std::vector< VSPERFP> ppV) // performance point vector
const char* tag, // identifying text for this interpolator (for messages)
Btwxt::RegularGridInterpolator*& pRgi, // returned: heap ptr to Btwxt interpolator object
// note: any prior contents deleted
const std::vector< VSPERFP> ppV) // performance point vector

{
RC rc = RCOK;

Expand All @@ -4994,13 +4999,16 @@ RC RSYS::rs_SetupBtwxt( // init/populate btwxt for heating runtime interpolation
}
}

auto MX = std::make_shared< CourierMsgHandlerRec>(this);

// single grid variable = dry-bulb temp (allow linear extrapolation)
Btwxt::GridAxis dbtRange(gridODB, "Dry-bulb temp", Btwxt::InterpolationMethod::linear, Btwxt::ExtrapolationMethod::linear);
std::vector<Btwxt::GridAxis> dbt{ dbtRange };
Btwxt::GridAxis dbtRange(gridODB,
Btwxt::InterpolationMethod::linear, Btwxt::ExtrapolationMethod::linear,
{ -DBL_MAX, DBL_MAX }, "Dry-bulb temp", MX);

// Btwxt::GriddedData perfMapHtg(dbt, values);
std::vector<Btwxt::GridAxis> dbt{ dbtRange};

pRgi = new Btwxt::RegularGridInterpolator( dbt, values);
pRgi = new Btwxt::RegularGridInterpolator(dbt, values, tag, MX);

#if 0
// test code
Expand Down Expand Up @@ -5033,8 +5041,13 @@ RC RSYS::rs_GetPerfBtwxt( // retrieve performance info from btwxt map
printf("\nCold");
#endif

#if 0
std::vector< double> targ{ tdbOut, 999. };
auto result = (*pRgi)(targ);
#else
std::vector< double> targ{ tdbOut };
auto result = (*pRgi)(targ);
#endif
cap = result[VSPERFP::ppCAPHS];
inp = result[VSPERFP::ppINPHS];
capMin = result[VSPERFP::ppCAPLS];
Expand Down
10 changes: 10 additions & 0 deletions src/cse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,16 @@ LOCAL int cse2( int argc, const char* argv[])
{
errlvl = exitCode;
}
catch (std::exception e)
{
err(PROGERR, "Unhandled exception '%s'\nTerminating", e.what());
errlvl = 2;
}
catch (...)
{
err( PROGERR, "Unhandled exception\nTerminating");
errlvl = 2;
}
cnClean( DONE); // clean up after successful or non-ABT error completion.

// local fcn, calls clean fcns elsewhere.
Expand Down
64 changes: 46 additions & 18 deletions src/hvac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <btwxt/btwxt.h>
#include "hvac.h"


//-----------------------------------------------------------------------------
float CoolingSHR( // derive cooling sensible heat ratio
float tdbOut, // outdoor dry bulb, F
Expand Down Expand Up @@ -92,8 +93,9 @@ void ASHPConsistentCaps( // make air source heat pump heating/cooling capaciti
// Harvest Thermal CHDHW (Combined Heat / DHW) routines
// Data + class CHDHW
///////////////////////////////////////////////////////////////////////////////
CHDHW::CHDHW()
: hvt_capHtgNetMin( 0.f), hvt_capHtgNetMaxFT( 0.f), hvt_tRiseMax( 0.f)
CHDHW::CHDHW( record* pParent)
: hvt_capHtgNetMin( 0.f), hvt_capHtgNetMaxFT( 0.f), hvt_tRiseMax( 0.f),
hvt_pParent( pParent)
{}
//-----------------------------------------------------------------------------
CHDHW::~CHDHW()
Expand All @@ -112,19 +114,36 @@ void CHDHW::hvt_Clear() // clear all non-static members

} // CHDHW::hvt_Clear
//-----------------------------------------------------------------------------
static void CHDHW_RGICallback( // btwxt message dispatcher
void* pContext, // pointer to specific RSYS
MSGTY msgTy, // message type: bsxmsgERROR etc
const char* msg) // message text
{
CHDHW* pCHDHW = reinterpret_cast<CHDHW*>(pContext);

record* pParent = pCHDHW->hvt_pParent;
const char* msgx = strtprintf("CHDHW: %s", msg);
pParent->ReceiveMessage(msgTy, msgx);

} // CHDHW_RGICallBack
//-----------------------------------------------------------------------------
RC CHDHW::hvt_Init( // one-time init
float blowerEfficacy) // full speed operating blower efficacy, W/cfm
// returns RCOK iff success
{
using namespace Btwxt;
using GridAxes = std::vector< GridAxis>;
using VVD = std::vector< std::vector< double>>;

RC rc = RCOK;
hvt_Clear();

// derive running fan power
double ratedBlowerEfficacy = hvt_GetRatedBlowerEfficacy();
double blowerPwrF = blowerEfficacy / ratedBlowerEfficacy; // blower power factor
// nominal full speed blower power = 0.2733 W/cfm at full speed
// nominal full speed blower power = 0.2733 W/cfm at full speed

// derive points adjusted for blower power
// derive points adjusted for blower power
std::vector< double> netCaps; // net capacities (coil + blower), Btuh
std::vector< double> blowerPwrOpr; // operating blower power, W

Expand All @@ -137,30 +156,39 @@ RC CHDHW::hvt_Init( // one-time init
double bpX = bp * blowerPwrF; // blower power at operating static, W
blowerPwrOpr.push_back(bpX);
double netCap = grossCap + bpX * BtuperWh;
netCaps.push_back( netCap);

netCaps.push_back(netCap);
}
std::vector< std::vector< double>> netCapAxis{ netCaps };

// lookup vars: avf and power for each net capacity
std::vector< std::vector<double>> avfPwrData{ hvt_AVF, blowerPwrOpr };
// message handler
auto cmhCHDHW = std::make_shared< CourierMsgHandler>(CHDHW_RGICallback, this);

// 1D grid: capacity
GridAxis netCapAxis(netCaps,
InterpolationMethod::linear, ExtrapolationMethod::constant,
{ 0., DBL_MAX }, "Net cap", cmhCHDHW);

hvt_pAVFPwrRGI.reset(new RGI(netCapAxis, avfPwrData));
hvt_pAVFPwrRGI.reset(new RGI(
GridAxes{ netCapAxis},
VVD{ hvt_AVF, blowerPwrOpr }, // lookup vars: avf and power for each net capacity
"AVF/power", cmhCHDHW));

// water flow grid variables: entering water temp, net capacity
std::vector< std::vector< double>> htMap{ hvt_tCoilEW, netCaps };
GridAxis ewtAxis(hvt_tCoilEW,
InterpolationMethod::linear, ExtrapolationMethod::constant,
{ 0., DBL_MAX }, "EWT", cmhCHDHW);

hvt_pWVFRGI.reset(new RGI(htMap, hvt_WVF));
hvt_pWVFRGI.reset(new RGI( GridAxes{ ewtAxis, netCapAxis},
hvt_WVF, "Water flow", cmhCHDHW));

// min/max capacities
hvt_capHtgNetMin = netCaps[0]; // min is independent of ewt
hvt_capHtgNetMaxFT = netCaps.back();
hvt_capHtgNetMaxFT = netCaps.back();
std::vector< double> capHtgNetMax(hvt_tCoilEW.size(), hvt_capHtgNetMaxFT);
capHtgNetMax[ 0] = netCaps[netCaps.size() - 2];
capHtgNetMax[0] = netCaps[netCaps.size() - 2];

std::vector< std::vector< double>> capHtgNetMaxLU{ capHtgNetMax };
std::vector< std::vector< double>> ewtAxis{ hvt_tCoilEW };
hvt_pCapMaxRGI.reset(new RGI(ewtAxis, capHtgNetMaxLU));
hvt_pCapMaxRGI.reset(new RGI(
GridAxes{ ewtAxis},
VVD{ capHtgNetMax },
"Min/max capacities", cmhCHDHW));

float avfMax = hvt_AVF.back();
float amfMax = AVFtoAMF(avfMax); // elevation?
Expand Down
Loading