[PATCH] Fix up SAC calculations for ATM/bar confusion

jukka.lind at kolumbus.fi jukka.lind at kolumbus.fi
Mon Feb 25 01:12:32 PST 2013


Linus Torvalds [torvalds at linux-foundation.org] kirjoitti: 
> Hmm. Do you have a pointer to the math? The above compensation
> function ends up having the cross-over point at 160 bar, not 250 (ie
> that is where bar_comp == bar). I'd hate to have a jump at some point,
> which we would have if we picked 250 as the point we switch to that
> thing)
> 
> > Should the compressibility factor be counted in to_ATM (and not in
> > calculate_airuse or calculate_sac) ? To me the excessive calculation between
> > cuft, bar, L, atm, mbar seems confusing. Is it really necessary ? If we put
> > the factor to to_ATM shall we fix or break everything ?
> 
> Since I just fixed a bug in to_ATM(), I'm looking at the users, and I
> wouldn't want to just switch them without renaming the function.
> 
> But if we renamed it to surface_volume_multiplier(), we could do
> something like this:
> 
> /*
>  * At high pressures air becomes less compressible, and
>  * does not follow the ideal gas law any more.
>  *
>  * This tries to correct for that, becoming the same
>  * as to_ATM() at lower pressures.
>  */
> static inline double surface_volume_multiplier(pressure_t pressure,
> struct gasmix *mix)
> {
>         double bar = pressure.mbar / 1000.0;
> 
>         if (bar > 160)
>                 bar = -0.0007*bar*bar + 1.109*bar + 0.8;
>         return bar / (SURFACE_PRESSURE / 1000.0);
> }
> 
> However because of the lower switch-over point the above already
> changes things at 206 bar (which is the common pressure, so we'd
> notice it). Which makes me a bit unhappy.
> 
> Could you point me to the tables you mention at wikipedia? As
> mentioned, I do *not* want to have a function that suddenly jumps at
> some pressure, which means that either we'd need some other
> compensation function, or we need to do the above thing at 160 bar..
Originally I was thinking of using formula only above 250 bar. 
You are right, there should be no step.
This behaves well. No jump at beginning; curve is smooth between 200 and 300.
 /*
  * At high pressures air becomes less compressible, and
  * does not follow the ideal gas law any more.
  *
  * This tries to correct for that, becoming the same
  * as to_ATM() at lower pressures.
  */
 static inline double surface_volume_multiplier(pressure_t pressure,
 struct gasmix *mix)
 {
         double bar = pressure.mbar / 1000.0;
 
         if (bar > 200)
                 bar = 0.00038*bar*bar + 0.51629*bar + 81.542;
         return bar / (SURFACE_PRESSURE / 1000.0);
 }

The wikipedia table has values for 200, 250 and 300 bar:
http://en.wikipedia.org/wiki/Compressibility_factor
>From there we select the 300 K line (=27 C, a decent diving temperature).
 
> I doubt we want to do a full van der Waal, but if somebody has the
> proper function handly, we could do that too.
Seems even more difficult to me.

Jukka



More information about the subsurface mailing list