[PATCH] Re: New Bug Reports/Feature Requests

Rick Walsh rickmwalsh at gmail.com
Wed Mar 2 15:21:59 PST 2016


Good morning,

On 3 March 2016 at 08:24, Robert Helling <helling at atdotde.de> wrote:

> Good evening,
>
> > On 02.03.2016, at 18:44, Linus Torvalds <torvalds at linux-foundation.org>
> wrote:
> >
> > On Wed, Mar 2, 2016 at 9:25 AM, Dirk Hohndel <dirk at hohndel.org> wrote:
> >>
> >> So since Robert's formula /should/ be the right way to calculate the
> >> compensation factors, let's figure out what about it is broken and use
> >> "matches the wikipedia data" as a measuring stick for that.
>
> I think (unless my implementation is wrong),this is as good as it gets
> with a two parameter model that is also not particularly tuned to our use
> case of air-like gases at 300K with 1–300bar pressure.
>
> >
> > Well, the thing is, Robert's formula isn't actually physical, it's
> > fundamentally an approximation too.
> >
> > In fact, it's arguably much less physical than the van der Waals
> > equation, that at least tries to model the physical behavior, while
> > afaik the Redlich–Kwong equation is _purely_ an empirical
> > approximation.
> >
> > The first paragraph in the wikipedia page really does sum it up:
> >
> >  https://en.wikipedia.org/wiki/Redlich%E2%80%93Kwong_equation_of_state
> >
> > so to some degree, Lubomirs least-square polynomial would actually be
> > superior: it is the same kind of approximation, but it's an
> > approximation that has been specialized for one particular gas and
> > pressure/temperature range we happen to care about.
> >
> > The Redlich–Kwong equation is intended to be much more general, but
> > exactly because of that it's much less accurate at least for one case
> > we care about.
> >
> > Side note: according to Wikipedia there are various newer refined
> > versions with more complexity (and some with more per-gas constants).
> > So it's possible that we could still get it all - both the "multiple
> > gases" _and_ "sufficient accuracy“.
>
> I really don’t know what is the correct approach.
>
> First of all, all this compressibility business is really a small effect
> and we are talking about small differences here, so all of this is somewhat
> academic, in particular as Linus has pointed out that we always ignore the
> effect of gas temperature which can be as much as 15%..
>
> The other thing to say is, after rereading the wikipedia page I realized
> that I was getting the calculation for mixtures wrong. I had assumed that
> it works like for van der Waals that you are supposed to take weighted
> averages of the critical data, but you don’t. But the difference this makes
> for air is much smaller than the difference to the empirical numbers. With
> the corrected procedure for mixtures I also calculated the curve for some
> typical trimix to see how important the effect of the gas composition is.
> Turns out, it is 3-4 times the difference between the table data and the
> computed Z. Or put differently: This is more significant than the
> difference between measured and modeled Z’s. Or: Taking the tabulated
> values for air and pretend they are the same for trimix gives an error 3-4
> times the error from using the model for air.
>
> As Linus said correctly, this model is semi-empirical, it uses some
> physical intuition about the general form of the correction but then plugs
> in measured values (and it is supposed to hold also in a regime where the
> gas is close to liquid). But there are only two per gas but this might be
> an aesthetic point.
>
> The problem is that beyond the air table from wikipedia, we (or at least
> I) don’t really have empirical data. We don’t know how to extrapolate to
> other gases or we don’t know what to match or which values to take for
> models with more parameters.
>
> I think what we need here is an executive decision from our beloved
> maintainer: How do you want to proceed, there are essentially three
> options: Linus’ table interpolation, Lubomir’s quadratic fit to that table
> which both cannot handle other gases than air or this semi-empirical model
> with its intrinsic error (in which case I would provide a new patch to get
> the mixing right, the above mentioned calculation is in mathematica). All
> have advantages and disadvantages.
>
>
I think we can fit the data set better.  Firstly, the experimental Z values
from Wikipedia fit very well with a quadratic equation (less expensive than
a cubic).  Secondly, we can adjust the coefficients of the quadratic
equation according to temperature with linear interpolation between the
values at 250 K, 300 K and 350 K.

K = Ax^2 + Bx + C

where
A = a1.T + a2
B = b1.T + b2
C = 0.999421

T = temp in Kelvin

a1 = -3.03810E-08
a2 = 1.12395E-05
b1 = 1.033437E-05
b2 = -3.367652E-03

This equation is fitted to the data for air at 300 K, and allows adjustment
according to temperature.  See the attached graph.

We could factor according to gas mix, with a simplified factor correlated
from Redlich–Kwong equation values at say 300 K and 100 bar.  I haven't got
my head around that equation yet, and have far too much work to do right
now.

Cheers,

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20160303/89263137/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Z correlation.pdf
Type: application/pdf
Size: 12533 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20160303/89263137/attachment-0001.pdf>


More information about the subsurface mailing list