Thanks for that. Before you implement IAPWS-IF97 you might want to look
at freesteam, which implements quite a lot of it and includes a CppUnit
test suite, as well as IAPWS-95 for validation, and has hooks for Python
as well as ASCEND. It's all in C++ and includes some use of templates
for dealing with units of measurement and some algorithms. Perhaps
rather than starting a new project, you might like to collaborate on
improving the freesteam code a little further?
freesteam
http://freesteam.sourceforge.net/
http://freesteam.svn.sourceforge.net/viewvc/freesteam/freesteam/trunk/
One aspect of freesteam that works rather well is the 'Solver2'
interface which gives a robust calculation of properties in terms of
(p,h), (p,s), (u,v), (T,s) and various other combinations. This was
rather difficult to implement in the case of IAPWS-IF97 because of the
way that the correlation is given in terms of different independent
variables in different regions.
You might also want to look at FPROPS, which I mentioned previously,
which is currently confined to just Helmholtz energy functions, such as
as IAPWS-95, written in pure C:
http://ascendcode.cheme.cmu.edu/viewvc.cgi/code/branches/extfn/models/johnpye/fprops/
Cheers
JP
KP wrote:
> Hi JP,
>
> I was actually aware of the freesteam project before I wrote my code.
> The code I wrote was a minor part of a different application and the
> powers that be did not appreciate the "licensing" situation with
> freesteam. Also, I'm not a big fan of the template laden approach ...
> but every code has its niche. But with regards to freesteam, I'll
> check it out and take a look.
>
The template-laden code in freesteam is exactly the sort of thing that
it would be good to clean up a bit.
I think that it should be pretty easy to clear out the templates for the
core evaluation routines, and just leave the template layer in place
for the Solver2 code, perhaps. That way, people could use the core
routines (IAPWS-95 and IAPWS-IF97) directly, and just use the Solver2
code if they particular environment doesn't provide something
equivalent. freesteam could be divided into two libraries that way - the
core library and a solver library.
> Also, I was wondering ... are you aware of any IAPWS95 implementations
> that use TTSE approach (Tabular Taylor Series Expansion)? It's my
> understanding that it's much faster and is probably easier to write
> solver routines around.
>
I've heard mention of this but haven't tried an implementation as yet;
it sounds quite interesting. I found this paper:
http://cat.inist.fr/?aModele=afficheN&cpsidt=2653137
For the moment, with FPROPS, I've been trying to get a 'first-pass'
accurate and complete implementation of Helmholtz-based property
evaluation, with the intention of adding optimisations later on.
Also, I note that the code for REFPROP (from NIST) seems to include some
code that caches powers of delta and tau, to improve speed; whether that
turns out to be a comparable efficiency improvement I don't know.
FWIW in freesteam, there is a some optimisation, which is that a 'steam
state' is returned from the Solver or Solver2 routines (single- or
two-variable iteration), which means that once the state has been
determined, subsequent property evaluations, eg h(T,s), p(T,s), rho(T,s)
don't require any further iteration.
Cheers
JP