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

Linus Torvalds torvalds at linux-foundation.org
Sun Feb 24 15:44:53 PST 2013


On Sun, Feb 24, 2013 at 1:17 PM, Jukka <jukka.lind at kolumbus.fi> wrote:
>
> I have noticed something which surely distords SAC-calculation when using
> 300 bar tanks. Subsurface is not taking into account the air unlinear
> compressibility above 270 bar.
>
> Function bar_comp = -0.0007*bar*bar + 1.109*bar + 0.8
>
> would work from 250 to 300 bar very well (= close to wikipedia's table at
> temp 27 C)

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..

I doubt we want to do a full van der Waal, but if somebody has the
proper function handly, we could do that too.

                  Linus


More information about the subsurface mailing list