Real support for multiple concurrent sensors..

Robert Helling helling at
Thu Aug 3 12:33:33 PDT 2017

Hi Linus,

> On 3. Aug 2017, at 21:03, Linus Torvalds <torvalds at> wrote:
> It *should* be straightforward to fix, but it just looks nasty to
> really do. We don't even have a helper function to turn gas volume
> into a pressure value.
> The planner tries to do it in update_cylinder_pressure(), but I
> actually think it is doing it slightly wrong (it does a "correction
> factor", but I think it should probably iterate over that correction
> factor until it converges, rather than just doing it once - it uses
> the wrong initial pressure to calculate the compressibility factor,
> rather than the actual resulting pressure).
> I think the single-round correction probably gives the right answer in
> practice (especially for small incremental pressure changes), but it
> all feels wrong.

Yes, it’s my name under a pile of half a ton of garbage.

Isn’t the helper

double isothermal_pressure(struct gasmix *gas, double p1, int volume1, int volume2)

what you are looking for? This turns a gas volume at one pressure into a pressure at a different volume. As it says there in the comment that is to first order. IIRC the correction factor is a few percent  compared to the ideal gas law for all pressures we’ll ever meet. So, if you iterated (as you should) the second round will give you a correction of the order of a few percent of a few percent. And I would argue that this is so tiny to be ignored safely. That’s why I didn’t push that further.

Or put differently, one should use the correction factor at the true pressure. But that code uses it at the pressure obtained at the ideal gas pressure (which is a bit off). But the correction factor does not vary so much with pressure that it will be significantly different at the corrected pressure compared to the ideal gas one.

But I am a theorist. I did not try this out. And I have a history of getting such estimates wrong.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP
URL: <>

More information about the subsurface mailing list