Remove fmt - Part 1: Propagate std::format where possible and eliminate {T} string formatting option#11553
Remove fmt - Part 1: Propagate std::format where possible and eliminate {T} string formatting option#11553
std::format where possible and eliminate {T} string formatting option#11553Conversation
| Real64 viscosity; | ||
|
|
||
| AirState(); | ||
| explicit AirState(double const airDensity); |
There was a problem hiding this comment.
Just making the definition and declaration names the same.
| // C++ Headers | ||
| #include <algorithm> | ||
| #include <cmath> | ||
| #include <format> | ||
| #include <set> | ||
| #include <string> | ||
|
|
||
| // ObjexxFCL Headers | ||
| #include <ObjexxFCL/Array.functions.hh> | ||
| #include <ObjexxFCL/Array2D.hh> | ||
| // #include <ObjexxFCL/Fmath.hh> | ||
|
|
||
| // Local Headers | ||
| #include "AirflowNetwork/Elements.hpp" | ||
| #include "AirflowNetwork/Solver.hpp" | ||
|
|
||
| // EnergyPlus Headers |
There was a problem hiding this comment.
Since was adding #include <format> in a bunch of places, I spent a little time making the header includes consistent.
| @@ -954,25 +952,25 @@ namespace AirflowNetwork { | |||
| } | |||
| if (MultizoneCompDetOpeningData(i).NumFac > 2) { | |||
| if (MultizoneCompDetOpeningData(i).OpenFac2 >= MultizoneCompDetOpeningData(i).OpenFac3) { | |||
| ShowSevereError(m_state, EnergyPlus::format("{}: {} = {}", RoutineName, CurrentModuleObject, thisObjectName)); | |||
| ShowSevereError(m_state, std::format("{}: {} = {}", RoutineName, CurrentModuleObject, thisObjectName)); | |||
There was a problem hiding this comment.
25000 of these later...
| @@ -319,7 +316,7 @@ void InitializeRootFinder(EnergyPlusData &state, | |||
| XMinReset = XMax; | |||
| } else { | |||
| ShowFatalError( | |||
| state, EnergyPlus::format("InitializeRootFinder: Invalid min/max bounds XMin={:.6T} must be smaller than XMax={:.6T}", XMin, XMax)); | |||
There was a problem hiding this comment.
Thankfully it's just a 1:1 replacement, with the noted LSF rounding. IMO, that doesn't appear to be an issue.
Edit - this is addressed in subsequent commits.
| // T formatting is like R, but it trims instead of rounding | ||
| EXPECT_EQ(format("{:.3T}", 7.63142731775999418747E-003), "7.631E-003"); | ||
| EXPECT_EQ(format("{:.3T}", 1.28349999999999948505E-004), "1.283E-004"); | ||
| EXPECT_EQ(format("{:.3T}", 2.56700000000000005430E-004), "2.567E-004"); | ||
| EXPECT_EQ(format("{:.3T}", 0.15159450340364988286), "0.151"); | ||
| EXPECT_EQ(format("{:.3T}", 0.0), "0.000"); | ||
|
|
||
| EXPECT_EQ(format("{:.3T}", 2.14633893312000043063E-002), "2.146E-002"); | ||
| EXPECT_EQ(format("{:.3T}", 8.55666666666666278192E-005), "8.556E-005"); | ||
| EXPECT_EQ(format("{:.3T}", 6.41749999999999878051E-005), "6.417E-005"); | ||
| EXPECT_EQ(format("{:.3T}", 0.10106298657208269420), "0.101"); | ||
|
|
||
| EXPECT_EQ(format("{:.4T}", 0.14999999999999999445), "0.1500"); | ||
| EXPECT_EQ(format("{:.3T}", 4500.0), "4500.000"); | ||
| EXPECT_EQ(format("{:.4T}", 7.1846416734478406596), "7.1846"); | ||
| EXPECT_EQ(format("{:.4T}", 1.1846416734478406596), "1.1846"); | ||
| EXPECT_EQ(format("{:.4T}", 6.2565195738294026029), "6.2565"); | ||
| EXPECT_EQ(format("{:.4T}", 0.25651957382940215879), "0.2565"); |
There was a problem hiding this comment.
Old unit test showing how {T} option was behaving.
|
Looks like this partially addresses #11241 |
|
|
|
|
…001677 (m3/s)/W (125 cfm/ton) and 0.00003355 (m3/s)/W (250 cfm/ton).' changing to scientific notaton with 3 least significant digits
…. I think these are all likely to be in Celcius, so keeping a floating point representation seem appropriate
Diff SummaryDX Coils - Rated Vol Flow Per Watt ReportingDiff resolution commit: ab5e29c - ** ~~~ ** Min Rated Vol Flow Per Watt=[4.027E-005], Rated Vol Flow Per Watt=[7.475E-005], Max Rated Vol Flow Per Watt=[6.041E-005]. See Input Output Reference Manual for valid range.
+ ** ~~~ ** Min Rated Vol Flow Per Watt=[4.027e-05], Rated Vol Flow Per Watt=[7.476e-05], Max Rated Vol Flow Per Watt=[6.041e-05]. See Input-Output Reference Manual for valid range.Per this IO Ref, these values should be between '0.00001677 (m3/s)/W (125 cfm/ton) and 0.00003355 (m3/s)/W (250 cfm/ton).' Changing to fixed sci notation to reflect this. Psychrometric "Resultant Temperature" MessagesDiff resolution commit: fbd4a5a (ignore the files added accidentally) - ** ~~~ ** Resultant Temperature= -3.62E-003
+ ** ~~~ ** Resultant Temperature= -0.0036These look like they will always be in Celsius, so a fixed floating point number should be sufficient. EMS .edd File Trace DataDiff resolution commit: e9eb04d -CURVEOVERWRITEMGR,Line 8,SET C1 = 0.942567793,0.942567, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15
-CURVEOVERWRITEMGR,Line 9,SET C2 = 0.009543347,9.543347E-003, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15
-CURVEOVERWRITEMGR,Line 10,SET C2A = 0.009543347E0,9.543347E-003, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15
-CURVEOVERWRITEMGR,Line 11,SET C3 = 0.00068377E0,6.837700E-004, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15
+CURVEOVERWRITEMGR,Line 8,SET C1 = 0.942567793,0.942568, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15
+CURVEOVERWRITEMGR,Line 9,SET C2 = 0.009543347,9.543347e-03, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15
+CURVEOVERWRITEMGR,Line 10,SET C2A = 0.009543347E0,9.543347e-03, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15
+CURVEOVERWRITEMGR,Line 11,SET C3 = 0.00068377E0,6.837700e-04, During Warmup, Occurrence info=MIAMI INTL AP ANN HTG 99.6% CONDNS DB, 01/21 00:00 - 00:15This is only used to print to the .edd trace, so I picked a cutoff to switch between fixed floating point and scientific notation. Let me know if that's a problem. Psychrometric Humidity Ratio MessagesDiff resolution commit: 05e1825 - ** ~~~ ** Input Humidity Ratio= 1.257224E-003
+ ** ~~~ ** Input Humidity Ratio= 1.257225e-03This is another number that's always going to be less than 0, so scientific notation seems appropriate for these. Tank and Tank Node VolumesDiff resolution commits: 34fa25b 32811a7 -Chilled Water Tank Information,ThermalStorage:ChilledWater:Mixed,CHILLED WATER STORAGE TANK 1,50.0000,4.2120E-003,4.1819E-003
+Chilled Water Tank Information,ThermalStorage:ChilledWater:Mixed,CHILLED WATER STORAGE TANK 1,50.0000,4.2121e-03,4.1820e-03The tank and tank node volume are in m^3, and might be big or small, so I converted these to sci notation. Let me know if this is a problem for any of these. I think I've addressed all of the major issues. Remaining diffs are related to the LSF rounding differences between the old and new formats. |
|
|
|
|
|
|
rraustad
left a comment
There was a problem hiding this comment.
Diff review showed very small changes in magnitude and format.
Pull request overview
Begins the process of removing third-party/fmt library in lieu of
std::formatthat is now available in C++20.Description of the purpose of this PR
std::formatto all the easy places. I should have completed this in Upgrade to C++20 Standard #11423. Oh well.{T}formatting option. This results in some least significant figure rounding due to differences between how theToption vs.std::formatbehave.Pull Request Author
Reviewer