Skip to main content

The PC-SAFT equation of state, including dipole, association and ion terms.

Project description

https://badge.fury.io/py/pcsaft.svg https://img.shields.io/badge/License-GPLv3-blue.svg PyPI - Downloads https://readthedocs.org/projects/pcsaft/badge/?version=latest

Introduction

This package implements the PC-SAFT equation of state. In addition to the hard chain and dispersion terms, these functions also include dipole, association and ion terms for use with these types of compounds. When the ion term is included it is also called electrolyte PC-SAFT (ePC-SAFT).

Documentation

Documentation for the package is available on Read the Docs.

Example

import numpy as np
from pcsaft import pcsaft_den

# Toluene
x = np.asarray([1.])
m = np.asarray([2.8149])
s = np.asarray([3.7169])
e = np.asarray([285.69])
pyargs = {'m':m, 's':s, 'e':e}

t = 320 # K
p = 101325 # Pa
den = pcsaft_den(t, p, x, pyargs, phase='liq')
print('Density of toluene at {} K: {} mol m^-3'.format(t, den))

# Water using default 2B association scheme
x = np.asarray([1.])
m = np.asarray([1.2047])
e = np.asarray([353.95])
volAB = np.asarray([0.0451])
eAB = np.asarray([2425.67])

t = 274
p = 101325
s = np.asarray([2.7927 + 10.11*np.exp(-0.01775*t) - 1.417*np.exp(-0.01146*t)]) # temperature dependent sigma is used for better accuracy
pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB}
den = pcsaft_den(t, p, x, pyargs, phase='liq')
print('Density of water at {} K: {} mol m^-3'.format(t, den))

# Water using 4C association scheme
x = np.asarray([1.])
m = np.asarray([1.2047])
e = np.asarray([353.95])
volAB = np.asarray([0.0451])
eAB = np.asarray([2425.67])
assoc_schemes = ['4c']

t = 274
p = 101325
s = np.asarray([2.7927 + 10.11*np.exp(-0.01775*t) - 1.417*np.exp(-0.01146*t)]) # temperature dependent sigma is used for better accuracy
pyargs = {'m':m, 's':s, 'e':e, 'e_assoc':eAB, 'vol_a':volAB, 'assoc_scheme':assoc_schemes}
den = pcsaft_den(t, p, x, pyargs, phase='liq')
print('Density of water at {} K: {} mol m^-3'.format(t, den))

Dependencies

The Numpy and Scipy packages are required. The core functions have been written in C++ to improve calculation speed, so Cython is needed, along with the Eigen package for linear algebra. For unit testing pytest is used.

Python package

To make it easier to use this code, it has been added as a package to PyPi (pcsaft), which means it can be installed using pip. This allows you to use the code without needing to compile the Cython code yourself. Binaries might not be available for all platforms or Python versions.

Compiling with Cython

To speed up the original Python code the core functions have been rewritten in C++. These are then connected with the remaining Python code using Cython. This gave a significant improvement in speed. The Cython code needs to be compiled before use. To do so install Cython. Then run the following command from the directory containing the PC-SAFT code

python setup.py build_ext --inplace

Make sure that the Eigen header files are somewhere on your path. More about the Cython build process can be found from the Cython documentation.

The original Python-only code has been removed from the repository. If you still want to use the original Python-only functions, go back to an earlier version of the repository. Note that the Python-only code is no longer maintained, so it may not be as reliable as the Cython code.

Author

License

This project is licensed under the GNU General Public License v3.0

Acknowledgments

When developing these functions the code from two other groups was used as references

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcsaft-1.4.1.tar.gz (117.1 kB view hashes)

Uploaded Source

Built Distributions

pcsaft-1.4.1-cp39-cp39-win_amd64.whl (194.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pcsaft-1.4.1-cp39-cp39-win32.whl (164.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

pcsaft-1.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

pcsaft-1.4.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl (2.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686 manylinux: glibc 2.5+ i686

pcsaft-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl (269.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pcsaft-1.4.1-cp38-cp38-win_amd64.whl (194.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pcsaft-1.4.1-cp38-cp38-win32.whl (165.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

pcsaft-1.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.5 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

pcsaft-1.4.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl (2.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686 manylinux: glibc 2.5+ i686

pcsaft-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl (267.9 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pcsaft-1.4.1-cp37-cp37m-win_amd64.whl (189.7 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pcsaft-1.4.1-cp37-cp37m-win32.whl (164.0 kB view hashes)

Uploaded CPython 3.7m Windows x86

pcsaft-1.4.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

pcsaft-1.4.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686 manylinux: glibc 2.5+ i686

pcsaft-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl (268.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

pcsaft-1.4.1-cp36-cp36m-win_amd64.whl (189.5 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

pcsaft-1.4.1-cp36-cp36m-win32.whl (163.7 kB view hashes)

Uploaded CPython 3.6m Windows x86

pcsaft-1.4.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

pcsaft-1.4.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl (2.1 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686 manylinux: glibc 2.5+ i686

pcsaft-1.4.1-cp36-cp36m-macosx_10_9_x86_64.whl (276.7 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page