Code Monkey home page Code Monkey logo

coolprop-museum's Introduction

Welcome to CoolProp

CoolProp is a thermophysical property database and wrappers for a selection of programming environments. It offers similar functionality to REFPROP, but CoolProp is open-source and free. It was originally developed by Ian Bell, at the time a post-doc at the University of Liege, in Liege, Belgium.

  • CoolProp has flexible licensing terms: Commercial - ok! Academic? - ok! license
  • For Python, get the latest release via pip install coolprop PyPI downloads PyPI version
  • ... other binaries are available from SourceForge sourceforge downloads CoolProp version tag
  • There is also a bleeding edge nightly build of the development version .
  • The documentation is available for the latest release and the development version
  • For any kind of question regarding CoolProp and its usage, you can ask the CoolProp Discussions
  • ... you might also find answers in our FAQ
  • If you found a bug or have an issue that requires the developers to become active, please file an issue in our issue tracker
  • Contributions to this project are welcomed and encouraged! If you wish to contribute bug fixes, patches, or new features, wrappers, or material properties, please submit a Pull Request with your code.
  • If you are new to Git and Github, please see the CoolProp Wiki for guidance on becoming a contributor to the project.
  • Accelerate development of things you really need implemented by posting at Bountysource
  • Check Travis CI for build failures Travis CI builds and have a look at the coverity stats Coverity Scan Build Status

coolprop-museum's People

Contributors

edwinsoft avatar ghobold avatar ibell avatar lgpage avatar moesphere avatar rod-persky avatar spinnau avatar squoilin avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coolprop-museum's Issues

Working code in Python of v5

@jowr - check it out!

This is based on SWIG since I can't get xdress+cython working so far on windows:

import CoolProp

for backend,fluid in [("REFPROP","Ethane&Propane"), ("HEOS","Ethane&Propane")]:
    S = CoolProp.AbstractState_factory(backend, fluid)
    S.set_mole_fractions([0.5,0.5])
    S.update(CoolProp.PT_INPUTS, 1e5, 300)
    print S.rhomolar()

Another example with DLL in python

from ctypes import *

CoolProp = windll.LoadLibrary("CoolProp")

PropsSI = getattr(CoolProp, '_PropsSI@32')

PropsSI.argtypes = [c_char_p, c_char_p, c_double, c_char_p, c_double, c_char_p]
PropsSI.restype = c_double

print PropsSI("Dmolar", "T", 600, "P", 1e6, "REFPROP::Nitrogen[0.5]&Methane[0.5]")
print PropsSI("Dmolar", "T", 600, "P", 1e6, "HEOS::Nitrogen[0.5]&Methane[0.5]")

Yields

199.805701116
199.805701157

Higher order partials

So what do we do about the API for higher order partial derivatives? It starts to get really messy. Ideally we could support up to third partials, but second partials are already nasty enough.

See #6 for first partials.

We can express all second partials in terms of tau and delta, after a bit of math. In that way we could use a generic routine that we could easily test.

Select partial derivative based on string

I propose, at least for first partial derivatives, something like

"d(X)/d(Y)|Z"

which will call the correct partial derivative using the generic routine. It's not quite as nice as hard coding variables for each derivative, but then there are 6_5_4 = 120 possible triples of the 6 thermodynamic variables T,D,S,H,U,P

And for second partials, we could do something like

"d2(X)/d2(Y)|Z"

ExternalMedia

  • Port the state wrapper functions to the base class.
  • Replace setSat_p and setSat_T with setDew_p, setDew_T and setBubble_p, setBubble_T
  • Make a new interface for the incompressible fluids
  • Use Modelica to solve the ph-functions for incompressibles
  • Test the new classes on all platforms (Windows, Linux for Dymola and Windows, Linux, Mac for OpenModelica)
  • Commit code to Modelica.org SVN server
  • Update ThermoCycle to use ExternalMedia instead of CoolProp2Modelica.
  • Determine speed of static and dynamic libraries

CMake

  • Integrate the OLD code with CMake and try to run builds on all platforms.
  • Integrate tests with CMake and try to run builds on all platforms.
  • Make a proper decision about which generated files to commit to the repository. It has to be possible to build CoolProp without CMake...

High level API for CoolProp

@jowr, @squoilin etc.

I have fixed and added almost all the flash routines for pure and pseudo-pure fluids - see the v5 branch. The first set of rough consistency tests all pass for REFPROP. CoolProp still has a few cases that fail, and I need to add a few more flashes yet. I'm currently revisiting the high-level interface, and I don't know what the best way to handle the high level interface is. A couple of options:

double r0 = PropsSI("Dmass","T",298,"P",101325,"REFPROP-Propane[0.5],Ethane[0.5]");
std::vector<double> z(2,0.5);
double r1 = PropsSI("Dmass","T",298,"P",101325,"REFPROP-Propane,Ethane", z);
// and/or
double r2 = PropsSIZ("Dmass","T",298,"P",101325,"REFPROP-Propane,Ethane", z);

Basically the options are some combination of
a) Encode the mole fractions in the string (definitely will be supported), need to decide on the delimiters though. Perhaps we just stick with what we did before. I like '-' between backend and fluids, but some fluids ('n-Propane', etc.) have a '-' in the name. Or we could use "::" to get something like "REFPROP::Water". Would be kind of like C++, which has some appeal. I am less sure about the delimiters for mole fractions.
b) Overload (?) the PropsSI function with a form where you pass molar(!) fractions as the last parameter
c) Another function name entirely that takes mole fractions

maxiter in solvers

The solver loops simply terminate when the max amount of iterations is reached. This seems to be undesired. There is an error message that will never be printed, the exception will never be thrown.

double Newton(...)
{
...
    while ((iter < 2 || fabs(fval) > ftol) && iter < maxiter)
    {
...
        if (iter>maxiter)
        {
            errstring= "reached maximum number of iterations";
            throw SolutionError(format("Newton reached maximum number of iterations"));
        }
        iter=iter+1;
    }
    return x;
}

The while loop terminates 2 iterations before the exception is thrown. What is the intended behaviour?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.