@@ -59,9 +59,6 @@ Real64 WaterHeatingCoilUASizer::size(EnergyPlusData &state, Real64 _originalValu
5959 if (!this ->checkInitialized (state, errorsFound)) {
6060 return 0.0 ;
6161 }
62- Real64 constexpr Acc (0.0001 ); // Accuracy of result
63- int constexpr MaxIte (500 ); // Maximum number of iterations
64- int SolFla = 0 ; // Flag of solver
6562
6663 this ->preSize (state, _originalValue);
6764 if (this ->curZoneEqNum > 0 ) {
@@ -73,15 +70,21 @@ Real64 WaterHeatingCoilUASizer::size(EnergyPlusData &state, Real64 _originalValu
7370 Real64 UA1 = this ->dataCapacityUsedForSizing ;
7471 // Invert the simple heating coil model: given the design inlet conditions and the design load,
7572 // find the design UA.
73+
7674 auto f = [&state, this ](Real64 const UA) {
7775 state.dataWaterCoils ->WaterCoil (this ->dataCoilNum ).UACoilVariable = UA;
7876 WaterCoils::CalcSimpleHeatingCoil (state, this ->dataCoilNum , this ->dataFanOp , 1.0 , state.dataWaterCoils ->SimCalc );
7977 state.dataSize ->DataDesignCoilCapacity = state.dataWaterCoils ->WaterCoil (this ->dataCoilNum ).TotWaterHeatingCoilRate ;
8078 return (dataCapacityUsedForSizing - state.dataWaterCoils ->WaterCoil (this ->dataCoilNum ).TotWaterHeatingCoilRate ) /
8179 dataCapacityUsedForSizing;
8280 };
83- General::SolveRoot (state, Acc, MaxIte, SolFla, this ->autoSizedValue , f, UA0, UA1);
84- if (SolFla == -1 ) {
81+
82+ constexpr Real64 Acc = 0.0001 ; // Accuracy of result
83+ int SolFla;
84+ // Don't use SolveRoot2 (optimizer) for sizing
85+ General::SolveRoot (state, Acc, 500 , SolFla, this ->autoSizedValue , f, UA0, UA1);
86+
87+ if (SolFla == General::SOLVEROOT_ERROR_ITER) {
8588 errorsFound = true ;
8689 std::string msg = " Autosizing of heating coil UA failed for Coil:Heating:Water \" " + this ->compName + " \" " ;
8790 this ->addErrorMessage (msg);
@@ -142,7 +145,8 @@ Real64 WaterHeatingCoilUASizer::size(EnergyPlusData &state, Real64 _originalValu
142145 ShowContinueError (state, msg);
143146 }
144147 this ->dataErrorsFound = true ;
145- } else if (SolFla == -2 ) {
148+
149+ } else if (SolFla == General::SOLVEROOT_ERROR_INIT) {
146150 this ->errorType = AutoSizingResultType::ErrorType1;
147151 errorsFound = true ;
148152 std::string msg = " Autosizing of heating coil UA failed for Coil:Heating:Water \" " + this ->compName + " \" " ;
@@ -256,8 +260,13 @@ Real64 WaterHeatingCoilUASizer::size(EnergyPlusData &state, Real64 _originalValu
256260 return (dataCapacityUsedForSizing - state.dataWaterCoils ->WaterCoil (this ->dataCoilNum ).TotWaterHeatingCoilRate ) /
257261 dataCapacityUsedForSizing;
258262 };
259- General::SolveRoot (state, Acc, MaxIte, SolFla, this ->autoSizedValue , f, UA0, UA1);
260- if (SolFla == -1 ) {
263+
264+ constexpr Real64 Acc = 0.0001 ; // Necessary?
265+ int SolFla;
266+ // Don't use SolveRoot2 (optimizer) for sizing
267+ General::SolveRoot (state, Acc, 500 , SolFla, this ->autoSizedValue , f, UA0, UA1);
268+
269+ if (SolFla == General::SOLVEROOT_ERROR_ITER) {
261270 errorsFound = true ;
262271 std::string msg = " Autosizing of heating coil UA failed for Coil:Heating:Water \" " + this ->compName + " \" " ;
263272 this ->addErrorMessage (msg);
@@ -302,7 +311,7 @@ Real64 WaterHeatingCoilUASizer::size(EnergyPlusData &state, Real64 _originalValu
302311 ShowContinueError (state, msg);
303312 }
304313 this ->dataErrorsFound = true ;
305- } else if (SolFla == - 2 ) {
314+ } else if (SolFla == General::SOLVEROOT_ERROR_INIT ) {
306315 this ->errorType = AutoSizingResultType::ErrorType1;
307316 errorsFound = true ;
308317 std::string msg = " Autosizing of heating coil UA failed for Coil:Heating:Water \" " + this ->compName + " \" " ;
0 commit comments