Maxwell phase equilibrium condition for FPROPS

229 views
Skip to first unread message

John Pye

unread,
Feb 18, 2009, 7:37:09 PM2/18/09
to op...@googlegroups.com
Hi all

I'm wondering if anyone here might be able to help me with adding
support for calculation of saturation curves using a Helmholtz function
combined with the Maxwell phase equilibrium condition/criterion.

This criterion is described in the IAPWS-95 document, see the following
URL. Basically, an small and efficient iterative algorithm is required,
but I have not had any immediate success with my current attempts. The
algorithm has to work without any additional correlation data; only the
pure Helmholtz a(T,rho) function can be used as input, together perhaps
with the acentric factor and critical point location.
http://www.iapws.org/relguide/IAPWS95.pdf

This work is part of my new open-source high-accuracy fluid properties
library, FPROPS, which I hope eventually will be of use to many people
on this list. It currently supports just a handful of fluids including
hydrogen, nitrogen, water, ammonia, is written in plain C, and in a way
that will hopefully permit more fluids to be added, providing data has
been published in a suitable form.
http://ascendwiki.cheme.cmu.edu/FPROPS

If anyone has any suggestions on how to write an efficient routine for
evaluation of the saturation curve in this situation, please let me
know. Any suggestions would be welcome.

Cheers
JP

--
John Pye
Dept of Engineering
Australian National University
http://pye.dyndns.org

KP

unread,
Feb 20, 2009, 6:27:04 PM2/20/09
to Open source Process Simulator
JP,

I solved the same problem using newton type solution search. Consider
the phase equilibrium criteria to be a function accepting three
arguments, i.e, phase_equilbrium(rhoV, rhoL, T or P). The function
will return three values (The residuals from the three equations for
the maxwell criterion). I have a quasi-newton solution algorithm that
changes the arguments of rhoV, rhoL and T or P until the residuals are
zero. This worked fast enough for my case. The only sticking point is
initial guesses. From my work, it really didn't matter what the the
initial guesses were as long as they were realistic values from a
possible solution set. I always use the vapor and liquid densities for
373.15 K (100C) and 1 atm.

As far as speed goes, the derivatives of the phi terms with respect to
tau and delta are available in the IAPWS document, so you could
always implement a full newton method. I am not sure how stable this
would be on the first few iterations though.

To figure out if a given T, P is on the saturation was a little
difficult. I guess there should be some stability test, but I just
cheated and used the IAPWS-84 release that gives an nice equation for
the saturation curve. I just pass the values from the IAPWS-84
equation as initial guesses and get a refined answer from the newton
root search.

--KP


On Feb 18, 7:37 pm, John Pye <j...@curioussymbols.com> wrote:
> Hi all
>
> I'm wondering if anyone here might be able to help me with adding
> support for calculation of saturation curves using a Helmholtz function
> combined with the Maxwell phase equilibrium condition/criterion.
>
> This criterion is described in the IAPWS-95 document, see the following
> URL. Basically, an small and efficient iterative algorithm is required,
> but I have not had any immediate success with my current attempts. The
> algorithm has to work without any additional correlation data; only the
> pure Helmholtz a(T,rho) function can be used as input, together perhaps
> with the acentric factor and critical point location.http://www.iapws.org/relguide/IAPWS95.pdf
>
> This work is part of my new open-source high-accuracy fluid properties
> library, FPROPS, which I hope eventually will be of use to many people
> on this list. It currently supports just a handful of fluids including
> hydrogen, nitrogen, water, ammonia, is written in plain C, and in a way
> that will hopefully permit more fluids to be added, providing data has
> been published in a suitable form.http://ascendwiki.cheme.cmu.edu/FPROPS

John Pye

unread,
Feb 21, 2009, 11:16:01 PM2/21/09
to op...@googlegroups.com
Hi KP

OK I will try a proper multivariable newton solver, rather than my
current ad hoc approach. You mentioned using IAPWS-84 for your initial
guess; this isn't an option, because I need a method that works for all
Helmholtz-function-defined fluids, not just steam.

BTW I didn't see your code for this in your proph2o package -- is your
implementation something you actually have released?

Cheers
JP

John Pye

unread,
Nov 1, 2010, 1:19:35 AM11/1/10
to op...@googlegroups.com
Hi all

As a follow-up to this thread, I note that we developed some nice new
code for solving phase equilibrium for pure substances as part of
FPROPS, you might want to have a look at it. We used a method given in a
paper by Akasaka.

http://ascendwiki.cheme.cmu.edu/FPROPS

Cheers
JP

--
Dr John Pye


Dept of Engineering
Australian National University

http://jpye.dyndns.org/


Daniel

unread,
Nov 2, 2010, 7:35:56 AM11/2/10
to Open source Process Simulator
Hi John,

I was thinking about adding FPROPS to DWSIM (maybe as a plugin), but I
don't know how to compile your code into a .NET DLL. Can you help me
on that?

Thanks in advance.
Daniel

John Pye

unread,
Nov 3, 2010, 1:47:01 AM11/3/10
to op...@googlegroups.com
Hi Daniel

I don't do any work with .NET, but it shouldn't be very hard, as far as
I can tell.

Starting with the code that exposes FPROPS to Python, you could modify
the SWIG wrappings to make it accessible to C#/.NET, as described here:
http://www.swig.org/Doc1.3/CSharp.html

Alternatively, if you are able to access C functions from arbitrary
DLLs, as is possible for example in Python, then you might just be able
to create a plain DLL file and access it directly from .NET:
http://docs.python.org/library/ctypes.html

I'm quite keen (in the context of my ASCEND work) to work on adding
support in FPROPS for calculation of mixture properties... that's
something you've implemented already in DWSIM, but would you have any
interest in being able to access fast C routines for performing these
same calculations in an outside DLL?

Hope that helps

Cheers
JP

Daniel

unread,
Nov 3, 2010, 8:32:52 AM11/3/10
to Open source Process Simulator
Hi John,

Of course I do! But first I would like to try calling FPROPS functions
in a property package, even if they are for single components only,
without any mixing rules. It may be interesting for some people.

The main idea now is to integrate free simulation and thermodynamics
software into DWSIM, because I was thinking, why reinvent the wheel?
There are great open-source software out there (like yours), and I
think that by integrating one with another, everybody wins...

Please, if you need anything, don't hesitate in contacting me.

Regards,
Daniel
Reply all
Reply to author
Forward
0 new messages