pyiapws: IAPWS for python.
Project description
Introduction
Python wrapper around the
Fortran iapws library.
The Fortran library does not need to be installed, the python wrapper embeds all needed dependencies for Windows and MacOS.
On linux, you might have to install libgfortran
if it is not distributed with your linux distribution.
All functions that operate on arrays, more precisely on objects with the buffer protocol, return memory views in order to avoid compilation dependencies on 3rd party packages.
Installation
In a terminal, enter:
pip install pyiapws
Usage
import array
import numpy as np
import matplotlib.pyplot as plt
import pyiapws
print("########################## IAPWS VERSION ##########################")
print(pyiapws.__version__)
print("########################## IAPWS R2-83 ##########################")
print("Tc in H2O", pyiapws.r283.tc_H2O, "K")
print("pc in H2O", pyiapws.r283.pc_H2O, "MPa")
print("rhoc in H2O", pyiapws.r283.rhoc_H2O, "kg/m3")
print("Tc in D2O", pyiapws.r283.tc_D2O, "K")
print("pc in D2O", pyiapws.r283.pc_D2O, "MPa")
print("rhoc in D2O", pyiapws.r283.rhoc_D2O, "kg/m3")
print("")
print("########################## IAPWS G7-04 ##########################")
gas = "O2"
T = array.array("d", (25.0,))
# Compute kh and kd in H2O
heavywater = False
m = pyiapws.g704.kh(T, "O2", heavywater)
k = array.array("d", m)
print(f"Gas={gas}\tT={T[0]}C\tkh={k[0]:+10.4f}\n")
m = pyiapws.g704.kd(T, "O2", heavywater)
k = array.array("d", m)
print(f"Gas={gas}\tT={T[0]}C\tkh={k[0]:+10.4f}\n")
# Get and print the available gases
heavywater = False
gases_list = pyiapws.g704.gases(heavywater)
gases_str = pyiapws.g704.gases2(heavywater)
ngas = pyiapws.g704.ngases(heavywater)
print(f"Gases in H2O: {ngas:}")
print(gases_str)
for gas in gases_list:
print(gas)
heavywater = True
gases_list = pyiapws.g704.gases(heavywater)
gases_str = pyiapws.g704.gases2(heavywater)
ngas = pyiapws.g704.ngases(heavywater)
print(f"Gases in D2O: {ngas:}")
print(gases_str)
for gas in gases_list:
print(gas)
style = {"marker":".", "ls":"", "ms":2}
T_KELVIN = 273.15
T = np.linspace(0.0, 360.0, 1000)
solvent = {True: "D2O", False: "H2O"}
print("Generating plot for kh")
kname = "kh"
for HEAVYWATER in (False, True):
print(solvent[HEAVYWATER])
fig = plt.figure()
ax = fig.add_subplot()
ax.grid(visible=True, ls=':')
ax.set_xlabel("T /°C")
ax.set_ylabel("ln (kh/1GPa)")
gases = pyiapws.g704.gases(HEAVYWATER)
for gas in gases:
k_m = pyiapws.g704.kh(T, gas, HEAVYWATER)
k = np.asarray(k_m) / 1000.0
ln_k = np.log(k)
ax.plot(T, ln_k, label=gas, **style)
ax.legend(ncol=3)
print("Generating plot for kd")
kname = "kd"
for HEAVYWATER in (False, True):
print(solvent[HEAVYWATER])
fig = plt.figure()
ax = fig.add_subplot()
ax.grid(visible=True, ls=':')
ax.set_xlabel("T /°C")
ax.set_ylabel("ln kd")
gases = pyiapws.g704.gases(HEAVYWATER)
for gas in gases:
k_m = pyiapws.g704.kd(T, gas, HEAVYWATER)
k = np.asarray(k_m)
ln_k = np.log(k)
ax.plot(T, ln_k, label=gas, **style)
ax.legend(ncol=3)
License
MIT
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
pyiapws-0.3.0.tar.gz
(1.7 MB
view hashes)
Built Distributions
Close
Hashes for pyiapws-0.3.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af39eb350a8bd52bc622585b322719ad132363010829384622005c8c5abbb25b |
|
MD5 | 25c168474c475f4cc8a1800af1b300da |
|
BLAKE2b-256 | dd5e1e5c480ee950eeae80515654f2a466aa1634dbc12ea4f17d00eee710890d |
Close
Hashes for pyiapws-0.3.0-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | caf3b9ba19535a0d16d947a31754b448e74cbd1548b094475d47787505e4f2db |
|
MD5 | ba9496d50db123a40ea823bbefe5a42d |
|
BLAKE2b-256 | 3b5754088f545a9008baf27c5f2fccb4ad03e8dd87f588911cb83835233d8137 |
Close
Hashes for pyiapws-0.3.0-cp312-cp312-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b6bd3cc94338a55e091ca51012bc6c5da428c92eb2eb64efa08949826cf6ff3 |
|
MD5 | 14479a2632df86f02279583e9e9d087c |
|
BLAKE2b-256 | 81fca55b5e6bbf361456e656c7c52ab86424c7b668d0a4efb2b0ceb0f805a231 |
Close
Hashes for pyiapws-0.3.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0889a83fbc4bf66f4d16099c285589bd7c645713a83d5167359c9c74538d2964 |
|
MD5 | bb1829b132d9a996348a904b6c1df11a |
|
BLAKE2b-256 | 3c806608fb418f95076d71d2159c443109b9c541dc8d9e10d38f8685c8d8825c |
Close
Hashes for pyiapws-0.3.0-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e163577b9d365c304aa5d1f873b4aa715fc104785d11a12d866f14e4e32882a |
|
MD5 | 617bf847363116f7e0ca71b498a4a611 |
|
BLAKE2b-256 | cef06fe623f94576d6a7e81bd12469250f5906c607affd28b3571782c9ddb247 |
Close
Hashes for pyiapws-0.3.0-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bc793c823f76273ded00044d6f2bb2289d8399c965b3d52aee9dd1526b70d69 |
|
MD5 | ab5797886dc7522eb91f8d5b7283bf9c |
|
BLAKE2b-256 | 5cceec501027b91e772bdb7e8099696c6fa0b9a799de71b0051c47f79c50652b |
Close
Hashes for pyiapws-0.3.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdeceb9e53257f6909af42b531cbc8893172f39fa2e70850a647d044edebba83 |
|
MD5 | 85b9f984c0d826e73ca889952b624092 |
|
BLAKE2b-256 | 188bff6eb56918222b6be558e40e47bede618221e1d9bf898cf1c76976b3d688 |
Close
Hashes for pyiapws-0.3.0-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac718f7cb34ec60415cbf35c33c3293c8b67e7c64f2167619bc558c05cb0ec20 |
|
MD5 | 7658602a03cb820d691d2f2a9057cf3b |
|
BLAKE2b-256 | db7456f9a4416e9cdc335f0bd17fe5bc1063e4dda112bea0a3ef73ff3c496f15 |
Close
Hashes for pyiapws-0.3.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b71682d3ab31527be8193d82aed8fbc72cb17b0f3ed56cef67feb57d06f890e7 |
|
MD5 | 61d293daf28cd8ac9965186e64bae5b1 |
|
BLAKE2b-256 | f6ec04123c5263fc965c5e7af55da6a8413881fdd667396084ed7d19e6a2694f |
Close
Hashes for pyiapws-0.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c779cac854d04ce68704eff1af419ac3de30598161051030fadeba6e7c96e18 |
|
MD5 | e167de16cd72396ba2a87ca7fc3f5229 |
|
BLAKE2b-256 | 1534112f41f0aa06fa8fd9af70974c2c71109e4c7c4d7c5ac810a99ead00bb7b |
Close
Hashes for pyiapws-0.3.0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a8e09cbeee9a20af3c12903bbf24733fd84c5e14dead96b486b942264c1570a |
|
MD5 | 0f7cc360bab193c90f938f52d25a437f |
|
BLAKE2b-256 | f2d8f4d899d1ff0ab15a811000c40ce864f3df6a19be65db1015a57b1996c787 |
Close
Hashes for pyiapws-0.3.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b092c05094df9e60f11f3c955d5240821e87cd27ad89ab8ed4522102ff38bab |
|
MD5 | cc287f0f445fdfbb53379a5ced594934 |
|
BLAKE2b-256 | 7712accba70db6ffe7b9698d0d19ec4c1507bdcc0b59deb62d94c628cbf679c6 |
Close
Hashes for pyiapws-0.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6413ac475b808c34dc5b2392c272c4e4c00505b3a17ebd066e39ba65c33ac13b |
|
MD5 | d79ff94f7e3f2e8b86b8e19793d82589 |
|
BLAKE2b-256 | a298bbaeefb6f74b133185035181f60d857694d583840ea096841b397c3f4b2b |
Close
Hashes for pyiapws-0.3.0-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89c57a06feda39e3aa7b8b986116c8453989a6926ad6e651fba05af273760b44 |
|
MD5 | 380225725127528d4e5ff6ba7ef37847 |
|
BLAKE2b-256 | 054c34734cc6e5a3c61289b2f03e7aed7daf79428e9c0f3ff1a89294bb183469 |
Close
Hashes for pyiapws-0.3.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32922bb4b19de5fc1d113d34af226561af9995c2a659563f84917b7b37fce91b |
|
MD5 | 001abaa7bcaf6895af9576ef7070fe02 |
|
BLAKE2b-256 | 4c38592e9626cb44aa99aa631567671f36a46c293988ad55d61839e34adf83f7 |