Skip to main content

Build Status Dev project chat PyPI - Version

Python wrapper for Clapeyron.jl.

Installation

Install pyclapeyron from PyPI via pip or uv:

pip install pyclapeyron

or

uv add pyclapeyron

Documentation

See the Clapeyron.jl documentation.

In general, pyclapeyron only acts as a wrapper around the Julia functions using the same syntax. In the following, notable deviations from the Julia syntax are highlighted.

  • Julia functions with !: Functions ending with ! in Julia (often used for inplace operations) are renamed to end with _b, e.g. fun!(...) in Julia is fun_b(...) in Python.
  • Array type: All numeric arrays passed to Clapeyron functions need to be numpy arrays, e.g.
import pyclapeyron as cl
import numpy as np

model = cl.vdW(["nitrogen", "argon"], userlocations={
    "Tc": np.array([127., 150.]),
    "Pc": np.array([34e5., 49e5]),
    "Mw": np.array([28.01, 39.95])
})

cl.molar_density(model, 1e5, 300., np.array([0.5,0.5]))
  • Syntax for group-contribution (GC) models: The components for group contribution models that include the groups need to be passed in the form ("component name", {"group1": n1, ...}, ...). The dict replaces Julias' Vector{Pair} as there is no direct equivalent in Python, e.g.
import pyclapeyron as cl

model = cl.CompositeModel(
    ["water", "ethanol", ("ibuprofen", {"ACH": 4, "ACCH2": 1, "ACCH": 1, "CH3": 3, "COOH": 1, "CH": 1})],
    liquid=cl.UNIFAC, solid=cl.SolidHfus
)
  • Electrolyte models: Similar to GC models, salts in electrolyte models need to be defined as salts = (("sodium chloride", [("sodium", 1), ("chloride", 1)]),).
  • Functions as function arguments: If you need to pass a Clapeyron function to another function, e.g. as in partial_property, you need to pass the original Clapeyron.some_func function, e.g. cl.partial_property(model, p, T, z, cl.Clapeyron.volume).

Examples

  • pure substance VLE
import pyclapeyron as cl
import numpy as np
import matplotlib.pyplot as plt

model = cl.PCSAFT("benzene")
Tc, pc, vc = cl.crit_pure(model)

Tx = np.linspace(0.5*Tc, Tc, 100)
ps, vl, vv = np.zeros(100), np.zeros(100), np.zeros(100)
for (i,Ti) in enumerate(Tx):
    ps[i], vl[i], vv[i] = cl.saturation_pressure(model, Ti)

fig, axs = plt.subplots(nrows=1, ncols=2, sharey=True, figsize=(6,3), tight_layout=True)
axs[0].plot(1e-3/np.concat([vl,np.flip(vv)]), np.concat([ps,np.flip(ps)])/1e5, c="blue")
axs[1].plot(Tx, ps/1e5, c="blue")
axs[0].scatter(1e-3/vc, pc/1e5, marker="*", c="blue")
axs[1].scatter(Tc, pc/1e5, marker="*", c="blue")
axs[0].set(yscale="log", xlabel="ϱ / mol l⁻¹", ylabel="p / bar")
axs[1].set(xlabel="T / K")

  • mixture VLE
import pyclapeyron as cl
import numpy as np
import matplotlib.pyplot as plt

components = ["methanol", "r123"]
components_with_groups = [("methanol", {"CH3OH": 1}), ("r123", {"CF3": 1, "CHCL2": 1})]
model = cl.UNIFAC2(components_with_groups, puremodel=cl.AntoineEqSat(components))

T_iso = 300.
x1 = np.linspace(0.,1.,100)
ps, y1 = np.zeros(100), np.zeros(100)
for (i,x1i) in enumerate(x1):
    ps[i], _, _, yi = cl.dew_pressure(model, T_iso, np.array([x1i,1-x1i]))
    y1[i] = yi[0]

fig, ax = plt.subplots(figsize=(4,3), tight_layout=True)
ax.plot(x1, ps/1e5, c="red")
ax.plot(y1, ps/1e5, c="red")
ax.set(xlim=(0,1), xlabel="x₁ / mol l⁻¹", ylabel="p / bar")

For Developers

  • Use uv add --dev path/to/local/pyclapeyron to add pyclapeyron to a local env.
  • You can optionally use a local dev version of Clapeyron.jl by replacing the line
"Clapeyron": {
    "uuid": "7c7805af-46cc-48c9-995b-ed0ed2dc909a",
    "version": "X.X.X"
}

by

"Clapeyron": {
    "uuid": "7c7805af-46cc-48c9-995b-ed0ed2dc909a",
    "dev": true,
    "path": "/path/to/.julia/dev/Clapeyron"
},

in the pyclapeyron/juliapkg.json file.

Metadata

Release files for pyclapeyron 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyclapeyron 0.1.1
File Size Uploaded Provenance Actions
pyclapeyron-0.1.1.tar.gz 10.2 kB Without provenance Details for pyclapeyron-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyclapeyron 0.1.1
File Interpreter ABI Platform Actions
pyclapeyron-0.1.1-py3-none-any.whl Python 3 none any Details for pyclapeyron-0.1.1-py3-none-any.whl

Total release size: 20.3 kB

Release files / pyclapeyron-0.1.1.tar.gz

Download URL pyclapeyron-0.1.1.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a1ead27dcd3d7042bb8e90a228edc14b9de272b73003ad800967f2b6ace58baf
BLAKE2b-256 checksum
How to use checksums
1dbfa70fe0cfb880f1e66ce4ab0fea367f08e0e781e020127d16d03a4e88b372
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pyclapeyron-0.1.1-py3-none-any.whl

Download URL pyclapeyron-0.1.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aad963e3e0960244b8852e5d16f7df1db3b71c1a992cb0ebfcc6d8bb4a08fb37
BLAKE2b-256 checksum
How to use checksums
258c5dd661f6b41ba43fc098765b42ba09a1b759343124ea5bb4d390a77b9ba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pyclapeyron 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page