Skip to content

Commit 80e7876

Browse files
committed
Merge fix
2 parents 63b39ac + 197544e commit 80e7876

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+30517
-30548
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,6 @@ target_include_directories(CSE PRIVATE
238238
"${CSE_BINARY_DIR}/src"
239239
"${CSE_SOURCE_DIR}/src"
240240
"${penumbra_SOURCE_DIR}/include"
241-
"${HPWHsim_SOURCE_DIR}/src"
242-
"${HPWHsim_BINARY_DIR}/src"
243-
"${btwxt_SOURCE_DIR}/src"
244241
)
245242

246243
target_compile_features(CSE PUBLIC cxx_std_17)

src/CNRECS.DEF

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4539,7 +4539,7 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
45394539
// calc'd at substep end only
45404540

45414541
*h *e INT hw_bWriteCSV; // write HPWH debugging CSV iff nz
4542-
*declare "FILE* hw_pFCSV;" // file for debugging CSV (opened on 1st use)
4542+
*declare "std::ofstream* hw_pFCSV;" // file for debugging CSV (opened on 1st use)
45434543

45444544
*s *e DBl hw_qBal; // current step HPWH heat balance, kWh (s/b 0)
45454545
*s *e INT hw_balErrCount; // annual count of energy balance errors
@@ -4733,10 +4733,6 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
47334733
// DHW+DHWLOOP+CHDHW; does not include wh_qXBU
47344734
*s *e INT wh_nzDrawCount; // current substep # of draws > 0
47354735

4736-
*h *e INT wh_bWriteCSV; // write HPWH debugging CSV iff nz
4737-
*declare "FILE* wh_pFCSV;" // file for debugging CSV (opened on 1st use)
4738-
4739-
47404736

47414737
*h *e DBL wh_totHARL; // cumulative (year to date) recovery load at heater, Btu
47424738
// = SUM( HARL) (includes losses, solar etc)

src/cgcomp.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
#include "irats.h" // input RATs
2020
#include "cnguts.h" // decls for this file, IzxR
2121

22-
#if 0
23-
// Now #included below near point of use
24-
// When here, code generation associated with pow() is altered.
25-
// Cause not known.
26-
#include <Eigen\Dense>
27-
#endif
28-
2922
/*----------------------- LOCAL FUNCTION DECLARATIONS ---------------------*/
3023
LOCAL float FC cgnveffa( float a1, float a2);
3124

@@ -2283,8 +2276,6 @@ void TOPRAT::tp_AirNetDestroy()
22832276
// finds zone pressures that achieve balanced mass flows
22842277
///////////////////////////////////////////////////////////////////////////////
22852278
#if defined( AIRNET_EIGEN)
2286-
// Eigen #include located here because placement of top of file altered
2287-
// code generation associated with pow() (4-12-2023). Cause not known.
22882279
#include <Eigen\Dense>
22892280
using Eigen::MatrixXd;
22902281
using Eigen::VectorXd;

src/cnah1.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ RC AH::endSubhr() // airHandler stuff done at end subhr
630630
// using co_plrAv forces barely large enuf coil (makes frFanOn approach 1),
631631
// and is necessary to save correct info for AHSIZE report,
632632
// but has had a history of convergence problems (re heat), 6-97.
633+
#if 0
634+
x if (!Top.isWarmup)
635+
x printf("\nAH peak: %s %0.4f", Top.dateStr.CStr(), ahcc.co_plrAv);
636+
#endif
633637
ccAs.plrPk = ahcc.co_plrAv; // part load ratio peak value (curr total load / cap'y @ current conditions)
634638
ccAs.xPk = ahcc.captRat; // record capacity plr relates to in AUSZ member, 6-97
635639
ccAs.ldPk = ahcc.q; // total load at time of peak plr (negative)

src/cnglob.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct CULT;
8484
#include <ctype.h>
8585
#include <assert.h>
8686
#include <time.h>
87-
#include <math.h>
87+
#include <cmath>
8888
#include <float.h>
8989

9090
#if defined( USE_STDLIB)
@@ -93,6 +93,7 @@ struct CULT;
9393
#include <vector>
9494
#include <string>
9595
#include <map>
96+
#include <fstream>
9697
#define WVect std::vector
9798
typedef std::map< int, std::string> WMapIntStr;
9899
typedef std::string WStr;

src/cnloads.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#include "mspak.h"
2525
#include "nummeth.h"
2626

27-
#include "array"
28-
#include "btwxt.h"
27+
#include <array>
28+
#include <btwxt/btwxt.h>
2929

3030
#ifdef COMFORT_MODEL
3131
#include "comfort/comfort.h"
@@ -4987,12 +4987,12 @@ RC RSYS::rs_SetupBtwxt( // init/populate btwxt for heating runtime interpolation
49874987
}
49884988

49894989
// single grid variable = dry-bulb temp (allow linear extrapolation)
4990-
Btwxt::GridAxis dbtRange(gridODB, Btwxt::Method::LINEAR);
4990+
Btwxt::GridAxis dbtRange(gridODB, "Dry-bulb temp", Btwxt::InterpolationMethod::linear, Btwxt::ExtrapolationMethod::linear);
49914991
std::vector<Btwxt::GridAxis> dbt{ dbtRange };
49924992

4993-
Btwxt::GriddedData perfMapHtg(dbt, values);
4993+
// Btwxt::GriddedData perfMapHtg(dbt, values);
49944994

4995-
pRgi = new Btwxt::RegularGridInterpolator( perfMapHtg);
4995+
pRgi = new Btwxt::RegularGridInterpolator( dbt, values);
49964996

49974997
#if 0
49984998
// test code

src/dhwcalc.cpp

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,13 +2891,13 @@ void HPWHLINK::hw_Cleanup()
28912891
// duplicate calls OK
28922892
{
28932893
delete hw_pHPWH;
2894-
hw_pHPWH = NULL;
2894+
hw_pHPWH = nullptr;
2895+
28952896
delete[] hw_HSMap;
2896-
hw_HSMap = NULL;
2897-
if (hw_pFCSV)
2898-
{ fclose( hw_pFCSV);
2899-
hw_pFCSV = nullptr;
2900-
}
2897+
hw_HSMap = nullptr;
2898+
2899+
delete hw_pFCSV; // closes file if open
2900+
hw_pFCSV = nullptr;
29012901

29022902
hw_pNodePowerExtra_W.clear();
29032903

@@ -3618,9 +3618,8 @@ RC HPWHLINK::hw_DoSubhrStart( // HPWH subhour start
36183618

36193619
#define HPWH_DUMP // define to include debug CSV file
36203620
#if defined( HPWH_DUMP)
3621-
// #define HPWH_DUMPSMALL // #define to use abbreviated version
3622-
// use debug dump mechanism w/o headings to log file
3623-
// (dump goes to external CSV file)
3621+
// use debug dump mechanism w/o headings to log file
3622+
// (dump goes to external CSV file)
36243623
hw_bWriteCSV = DbDo(dbdHPWH, dbdoptNOHDGS);
36253624
#endif
36263625

@@ -3730,9 +3729,10 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
37303729
{
37313730
double qTXkWh = tk.wtk_qTX / BtuperkWh;
37323731
hw_qTX += qTXkWh; // subhour total (kWh)
3733-
double qTXPwr // tick power per node, W
3734-
= qTXkWh * 1000. / (hw_nQTXNodes * Top.tp_tickDurHr);
3735-
hw_pNodePowerExtra_W.assign(hw_nQTXNodes, qTXPwr);
3732+
double qTXPwr // tick power (W)
3733+
= qTXkWh * 1000. / (Top.tp_tickDurHr);
3734+
hw_pNodePowerExtra_W = {qTXPwr, 0., 0., 0.}; // bottom 1/4 of tank
3735+
37363736
pNPX = &hw_pNodePowerExtra_W;
37373737
}
37383738

@@ -3876,43 +3876,37 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
38763876

38773877
CSVGen csvGen(CI);
38783878

3879-
if (!hw_pFCSV)
3879+
if (hw_pFCSV == nullptr)
3880+
{
3881+
hw_pFCSV = new std::ofstream;
3882+
}
3883+
if (!hw_pFCSV->is_open())
38803884
{
38813885
// dump file name = <cseFile>_<DHWHEATER name>_hpwh.csv
38823886
// Overwrite pre-existing file
38833887
// >>> thus file contains info from only last RUN in multi-RUN sessions
38843888
const char* nameNoWS = strDeWS(strtmp(hw_pOwner->Name()));
3885-
const char* fName =
3886-
strsave(strffix2(strtprintf("%s_%s_hpwh", InputFilePathNoExt, nameNoWS), ".csv", 1));
3887-
hw_pFCSV = fopen(fName, "wt");
3888-
if (!hw_pFCSV)
3889+
const char* fName = strffix2(strtprintf("%s_%s_hpwh", InputFilePathNoExt, nameNoWS), ".csv", 1);
3890+
hw_pFCSV->open(fName, std::ifstream::out); // implies truncation
3891+
if (!hw_pFCSV->is_open())
38893892
err(PWRN, "HPWH report failure for '%s'", fName);
38903893
else
38913894
{ // headings
3892-
fprintf(hw_pFCSV, "%s,%s,%s\n",
3895+
*hw_pFCSV << strtprintf("%s,%s,%s\n",
38933896
hw_pOwner->GetDescription(), Top.repHdrL.CStr(), Top.runDateTime.CStr());
3894-
fprintf(hw_pFCSV, "%s%s %s %s HPWH %s\n",
3897+
*hw_pFCSV << strtprintf( "%s%s %s %s HPWH %s\n",
38953898
Top.tp_RepTestPfx(), ProgName, ProgVersion, ProgVariant,
38963899
Top.tp_HPWHVersion.CStr());
3897-
#if defined( HPWH_DUMPSMALL)
3898-
fprintf(wh_pFCSV, "minYear,draw( L)\n");
3899-
#else
39003900
WStr s("mon,day,hr,");
39013901
s += csvGen.cg_Hdgs(dumpUx);
3902-
hw_pHPWH->WriteCSVHeading(hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
3903-
#endif
3902+
hw_pHPWH->WriteCSVHeading(*hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
39043903
}
39053904
}
3906-
if (hw_pFCSV)
3907-
{
3908-
#if defined( HPWH_DUMPSMALL)
3909-
fprintf(wh_pFCSV, "%0.2f,%0.3f\n", minYear, GAL_TO_L(drawForTick));
3910-
#else
3911-
WStr s = strtprintf("%d,%d,%d,",
3905+
if (hw_pFCSV->is_open())
3906+
{ WStr s = strtprintf("%d,%d,%d,",
39123907
Top.tp_date.month, Top.tp_date.mday, Top.iHr + 1);
39133908
s += csvGen.cg_Values(dumpUx);
3914-
hw_pHPWH->WriteCSVRow(hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
3915-
#endif
3909+
hw_pHPWH->WriteCSVRow(*hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
39163910
}
39173911
}
39183912
#endif // HPWH_DUMP
@@ -4310,7 +4304,6 @@ RC DHWHEATER::wh_Init() // init for run
43104304
RC rc = RCOK;
43114305

43124306
DHWSYS* pWS = wh_GetDHWSYS();
4313-
wh_pFCSV = NULL;
43144307

43154308
// one-time inits
43164309
wh_balErrCount = 0;

src/envpak.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
#include "envpak.h" // declares functions in this file
2323

24-
#include <cmath> // isfinite
25-
2624
#if CSE_OS==CSE_OS_MACOS
2725
#include <mach-o/dyld.h> // _NSGetExecutablePath
2826
#endif
@@ -273,10 +271,9 @@ int enkichk() // Check whether a keyboard interrupt has been received
273271
/*-------------------------- FUNCTION DECLARATIONS ------------------------*/
274272
// PUBLIC functions called only from msc lib or interrupt code; no prototype
275273
// in envpak.h so inadvertent external calls are flagged. 8-31-91
276-
/* INT matherr( struct exception *); private math runtime error fcn;
277-
actual decl in math.h */
278-
void CDEC fpeErr( INT, INT); // intercepts floating point errors, and integer errors under Borland
279-
void CDEC iDiv0Err( SI); // intercepts integer x/0 errors under MSC
274+
// INT matherr( struct exception *); private math runtime error fcn;
275+
// actual decl in CRT (formerly math.h), now (12/23) not known
276+
// void CDEC fpeErr( INT, INT); // intercepts floating point errors, and integer errors under Borland
280277
#if 0 // Defined but not declated, 5-22
281278
void __cdecl fpeErr( INT, INT); // intercepts floating point errors, and integer errors under Borland
282279
#endif
@@ -368,7 +365,7 @@ UINT doControlFP()
368365
#if CSE_COMPILER==CSE_COMPILER_MSVC // TODO (MP) Add table for other compilers
369366
INT CDEC matherr( // Handle errors detected in Microsoft/Borland math library
370367

371-
struct _exception *x ) // Exception info structure provided by Microsoft; see math.h
368+
struct _exception *x ) // Exception info structure provided by MSVC library
372369

373370
// Calls rmkerr fcns to report error (as a warning), then returns a 1 to prevent error reporting out of library.
374371
{

src/envpak.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ void FC byebye( int exitCode); // exit fcn
3131

3232
void FC cknull(); // check for memory clobbers
3333
/* also public but called ONLY from msc lib or interrupt
34-
* SI matherr( struct exception *); * private math runtime error fcn *
35-
* void fpeErr( SI, SI); * intercepts floating point errors *
36-
* void iDiv0Err( SI); * intercepts int x/0 errors *
34+
* INT matherr( struct exception *); * private math runtime error fcn *
35+
* void fpeErr( INT, INT); * intercepts floating point errors *
3736
*/
3837

3938
// end of envpak.h

src/hvac.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
#include "cnglob.h"
99
#include "ancrec.h"
1010
#include "rccn.h"
11-
12-
#include <cmath>
13-
#include <btwxt.h>
11+
#include <btwxt/btwxt.h>
1412
#include "hvac.h"
1513

1614
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)