@@ -212,6 +212,7 @@ public double molarVolume2(double pressure, double temperature, double A, double
212
212
213
213
setMolarVolume (1.0 / BonV * Btemp / numberOfMolesInPhase );
214
214
int iterations = 0 ;
215
+ int maxIterations = 1000 ;
215
216
216
217
do {
217
218
iterations ++;
@@ -257,19 +258,20 @@ public double molarVolume2(double pressure, double temperature, double A, double
257
258
258
259
setMolarVolume (1.0 / BonV * Btemp / numberOfMolesInPhase );
259
260
Z = pressure * getMolarVolume () / (R * temperature );
260
- } while (Math .abs (BonV - BonVold ) > 1.0e-9 && iterations < 1000 );
261
+ } while (Math .abs (BonV - BonVold ) > 1.0e-9 && iterations < maxIterations );
261
262
// molarVolume = 1.0/BonV*Btemp/numberOfMolesInPhase;
262
263
// Z = pressure*molarVolume/(R*temperature);
263
264
// logger.info("BonV: " + BonV + " " + h + " " +dh + " B " + Btemp + " D " +
264
265
// Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV());
265
266
// logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh +
266
267
// " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" +
267
268
// fVV());
268
- if (iterations >= 1000 ) {
269
- throw new neqsim .util .exception .TooManyIterationsException ();
269
+ if (iterations >= maxIterations ) {
270
+ throw new neqsim .util .exception .TooManyIterationsException (this , "molarVolume2" ,
271
+ maxIterations );
270
272
}
271
273
if (Double .isNaN (getMolarVolume ())) {
272
- throw new neqsim .util .exception .IsNaNException ();
274
+ throw new neqsim .util .exception .IsNaNException (this , "molarVolume2" , "Molar volume" );
273
275
// logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh +
274
276
// " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" +
275
277
// fVV());
@@ -293,15 +295,15 @@ public double molarVolume(double pressure, double temperature, double A, double
293
295
}
294
296
295
297
double BonVold = BonV , Btemp = getB (), h , dh , dhh , d1 , d2 , BonV2 ;
296
- int iterations = 0 ;
297
298
298
299
if (Btemp < 0 ) {
299
300
logger .info ("b negative in volume calc" );
300
301
}
301
302
setMolarVolume (1.0 / BonV * Btemp / numberOfMolesInPhase );
302
303
boolean changeFase = false ;
303
304
double error = 1.0 , errorOld = 1.0e10 ;
304
-
305
+ int iterations = 0 ;
306
+ int maxIterations = 300 ;
305
307
do {
306
308
errorOld = error ;
307
309
iterations ++;
@@ -354,18 +356,19 @@ public double molarVolume(double pressure, double temperature, double A, double
354
356
setMolarVolume (1.0 / BonV * Btemp / numberOfMolesInPhase );
355
357
Z = pressure * getMolarVolume () / (R * temperature );
356
358
// logger.info("Math.abs((BonV - BonVold)) " + Math.abs((BonV - BonVold)));
357
- } while (Math .abs ((BonV - BonVold ) / BonVold ) > 1.0e-10 && iterations < 300 );
359
+ } while (Math .abs ((BonV - BonVold ) / BonVold ) > 1.0e-10 && iterations < maxIterations );
358
360
// logger.info("pressure " + Z*R*temperature/molarVolume);
359
361
// logger.info("error in volume " +
360
362
// (-pressure+R*temperature/molarVolume-R*temperature*dFdV()) + " firstterm " +
361
363
// (R*temperature/molarVolume) + " second " + R*temperature*dFdV());
362
- if (iterations >= 300 ) {
363
- throw new neqsim .util .exception .TooManyIterationsException ();
364
+ if (iterations >= maxIterations ) {
365
+ throw new neqsim .util .exception .TooManyIterationsException (this , "molarVolume" ,
366
+ maxIterations );
364
367
}
365
368
if (Double .isNaN (getMolarVolume ())) {
366
369
// A = calcA(this, temperature, pressure, numberOfComponents);
367
370
// molarVolume(pressure, temperature, A, B, phase);
368
- throw new neqsim .util .exception .IsNaNException ();
371
+ throw new neqsim .util .exception .IsNaNException (this , "molarVolume" , "Molar volume" );
369
372
// logger.info("BonV: " + BonV + " "+" itert: " + iterations +" " +h + " " +dh +
370
373
// " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" +
371
374
// fVV());
0 commit comments