Skip to content

Commit 0d8bbe5

Browse files
Phil AhrenkielPhil Ahrenkiel
authored andcommitted
Merge main.
2 parents aaa6772 + 197544e commit 0d8bbe5

Some content is hidden

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

66 files changed

+13630
-13654
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
@@ -4537,7 +4537,7 @@ RECORD HPWHLINK "HPWHLink" *SUBSTRUCT // Ecotope's HPWH tank and heater
45374537
// calc'd at substep end only
45384538

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

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

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

47394735
*h *e DBL wh_totHARL; // cumulative (year to date) recovery load at heater, Btu
47404736
// = 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: 23 additions & 30 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

@@ -3620,9 +3620,8 @@ RC HPWHLINK::hw_DoSubhrStart( // HPWH subhour start
36203620

36213621
#define HPWH_DUMP // define to include debug CSV file
36223622
#if defined( HPWH_DUMP)
3623-
// #define HPWH_DUMPSMALL // #define to use abbreviated version
3624-
// use debug dump mechanism w/o headings to log file
3625-
// (dump goes to external CSV file)
3623+
// use debug dump mechanism w/o headings to log file
3624+
// (dump goes to external CSV file)
36263625
hw_bWriteCSV = DbDo(dbdHPWH, dbdoptNOHDGS);
36273626
#endif
36283627

@@ -3735,6 +3734,7 @@ RC HPWHLINK::hw_DoSubhrTick( // calcs for 1 tick
37353734
double qTXPwr // tick power (W)
37363735
= qTXkWh * 1000. / (Top.tp_tickDurHr);
37373736
hw_pNodePowerExtra_W = {qTXPwr, 0., 0., 0.}; // bottom 1/4 of tank
3737+
37383738
pNPX = &hw_pNodePowerExtra_W;
37393739
}
37403740

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

38793879
CSVGen csvGen(CI);
38803880

3881-
if (!hw_pFCSV)
3881+
if (hw_pFCSV == nullptr)
3882+
{
3883+
hw_pFCSV = new std::ofstream;
3884+
}
3885+
if (!hw_pFCSV->is_open())
38823886
{
38833887
// dump file name = <cseFile>_<DHWHEATER name>_hpwh.csv
38843888
// Overwrite pre-existing file
38853889
// >>> thus file contains info from only last RUN in multi-RUN sessions
38863890
const char* nameNoWS = strDeWS(strtmp(hw_pOwner->Name()));
3887-
const char* fName =
3888-
strsave(strffix2(strtprintf("%s_%s_hpwh", InputFilePathNoExt, nameNoWS), ".csv", 1));
3889-
hw_pFCSV = fopen(fName, "wt");
3890-
if (!hw_pFCSV)
3891+
const char* fName = strffix2(strtprintf("%s_%s_hpwh", InputFilePathNoExt, nameNoWS), ".csv", 1);
3892+
hw_pFCSV->open(fName, std::ifstream::out); // implies truncation
3893+
if (!hw_pFCSV->is_open())
38913894
err(PWRN, "HPWH report failure for '%s'", fName);
38923895
else
38933896
{ // headings
3894-
fprintf(hw_pFCSV, "%s,%s,%s\n",
3897+
*hw_pFCSV << strtprintf("%s,%s,%s\n",
38953898
hw_pOwner->GetDescription(), Top.repHdrL.CStr(), Top.runDateTime.CStr());
3896-
fprintf(hw_pFCSV, "%s%s %s %s HPWH %s\n",
3899+
*hw_pFCSV << strtprintf( "%s%s %s %s HPWH %s\n",
38973900
Top.tp_RepTestPfx(), ProgName, ProgVersion, ProgVariant,
38983901
Top.tp_HPWHVersion.CStr());
3899-
#if defined( HPWH_DUMPSMALL)
3900-
fprintf(wh_pFCSV, "minYear,draw( L)\n");
3901-
#else
39023902
WStr s("mon,day,hr,");
39033903
s += csvGen.cg_Hdgs(dumpUx);
3904-
hw_pHPWH->WriteCSVHeading(hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
3905-
#endif
3904+
hw_pHPWH->WriteCSVHeading(*hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
39063905
}
39073906
}
3908-
if (hw_pFCSV)
3909-
{
3910-
#if defined( HPWH_DUMPSMALL)
3911-
fprintf(wh_pFCSV, "%0.2f,%0.3f\n", minYear, GAL_TO_L(drawForTick));
3912-
#else
3913-
WStr s = strtprintf("%d,%d,%d,",
3907+
if (hw_pFCSV->is_open())
3908+
{ WStr s = strtprintf("%d,%d,%d,",
39143909
Top.tp_date.month, Top.tp_date.mday, Top.iHr + 1);
39153910
s += csvGen.cg_Values(dumpUx);
3916-
hw_pHPWH->WriteCSVRow(hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
3917-
#endif
3911+
hw_pHPWH->WriteCSVRow(*hw_pFCSV, s.c_str(), nTCouples, hpwhOptions);
39183912
}
39193913
}
39203914
#endif // HPWH_DUMP
@@ -4312,7 +4306,6 @@ RC DHWHEATER::wh_Init() // init for run
43124306
RC rc = RCOK;
43134307

43144308
DHWSYS* pWS = wh_GetDHWSYS();
4315-
wh_pFCSV = NULL;
43164309

43174310
// one-time inits
43184311
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)