The python package provides a performant library for thermodynamic calculations like equilibrium reactions for several hundred gas species and their mixtures - written in Python/Numpy.
Species are treated as ideal gases. Therefore the application is limited to moderate pressures or high temperature applications.
It is designed with goal to be portable to Numpy-style GPU frameworks like JAX and PyTorch.
Key Features#
Pure Python implementation with NumPy vectorization for high performance
Immutable types and comprehensive type hints for reliability
Intuitive, Pythonic API for both rapid prototyping and complex multidimensional models
Ready for Jupyter Notebook and educational use
Designed for future GPU support (JAX, PyTorch)
Ships with a comprehensive NASA9-based species database
Installation#
Installation with pip:
Installation with conda:
Getting started#
Gaspype provides two main classes: fluid and elements.
Fluid#
A fluid class describes a mixture of molecular species and their individual molar amounts.
Its’ functions provides thermodynamic, mass balance and ideal gas properties of the mixture.
The arguments can be provided as numpy-arrays:
A fluid object can have multiple compositions. A multidimensional fluid object can be created for example by multiplication with a numpy array:
A fluid object can be converted to a pandas dataframe:
The broadcasting behavior is not limited to 1D-arrays:
Elements#
In some cases not the molecular but the atomic composition is of interest. The elements class can be used for atom based balances and works similar:
A elements object can be as well instantiated from a fluid object. Arithmetic operations between elements and fluid result in an elements object:
Going from an atomic composition to an molecular composition is possible as well. One way is to calculate the thermodynamic equilibrium for a mixture:
The equilibrium function can be called with a fluid or elements object as first argument. fluid and elements referencing a fluid_system object witch can be be set as shown above during the object instantiation. If not provided, a new one will be created automatically. Providing a fluid_system gives more control over which molecular species are included in derived fluid objects. Furthermore arithmetic operations between objects with the same fluid_system are potentially faster:
Especially if the fluid_system of one of the operants has not a subset of molecular species of the other fluid_system a new fluid_system will be created for the operation which might degrade performance:
Developer Guide#
Contributions are welcome, please open an issue or submit a pull request on GitHub.
To get started with developing the gaspype package, follow these steps.
First, clone the repository to your local machine using Git:
It’s recommended to setup an venv:
Install the package and dev-dependencies while keeping the package files in the current directory:
Compile binary property database from text based files:
Ensure that everything is set up correctly by running the tests:
License#
This project is licensed under the MIT License - see the LICENSE file for details.