PyThermo

PyThermo.jl provides Julia access to Thermo, a Python library of thermophysical property data and correlations covering a large number of chemical species. It wraps thermo's Chemical and Mixture objects as the Julia types Species and Mixture, and adds a curated set of property accessors that return Unitful quantities in SI units. Properties without a curated accessor remain reachable as fields of the underlying Python object.

Installation

PyThermo is registered in Julia's General registry:

using Pkg
Pkg.add("PyThermo")

The Python dependencies are installed automatically through CondaPkg.jl the first time the package is loaded, as described under Interaction with Conda.

Quickstart

A Species is created by name. Temperature and pressure default to STP and may be given either as bare numbers in K and Pa or as Unitful quantities.

julia> using PyThermo, Unitful

julia> argon = Species("Ar", T = 300u"K")
Species(Ar, 300.0 K, 1.013e+05 Pa)

julia> density(argon)
1.6227671732556135 kg m^-3

Properties without a curated accessor are read straight from the underlying thermo object:

julia> argon.molecular_diameter   # Ångström
3.40744

A Mixture is created from its components and a composition. The same accessors work on mixtures:

julia> air = Mixture(["N2" => 0.78, "O2" => 0.21, "Ar" => 0.01])
Mixture(78% N2, 21% O2, 1% Ar, 298.1 K, 1.013e+05 Pa)

julia> soundspeed(air)
346.13450470160916 m s^-1

Guide

  • Mixtures covers building mixtures, including combining existing species and mixtures and the adiabatic, enthalpy-conserving mode.
  • Property accessors lists the curated accessors with their units, the strict and optional return conventions, and a thermo-to-PyThermo cheatsheet.
  • ShockTube module provides one-dimensional gas dynamics for shock jumps, driver pressures, and gas-gas Riemann problems.

Species

PyThermo.SpeciesType
Species(ID::String; T=298.15, P=101325)

Creates a Species object which contains basic information such as molecular weight and the structure of the species, as well as thermodynamic and transport properties as a function of temperature and pressure. If T and P are given as non-Unitful numbers, they must have units of K and Pa.

Parameters

ID : One of the following [-]:

  • Name, in IUPAC form or common form or a synonym registered in PubChem

  • InChI name, prefixed by "InChI=1S/" or "InChI=1/"

  • InChI key, prefixed by "InChIKey="

  • PubChem CID, prefixed by "PubChem="

  • SMILES (prefix with "SMILES=" to ensure smiles parsing)

  • CAS number

T : temperature of the chemical (default 298.15 K)

P : pressure of the chemical (default 101325 Pa)

Examples

julia> He = Species("He")
Species(He, 298.1 K, 1.013e+05 Pa)

julia> density(He)
0.16360253235815483 kg m^-3

julia> using Unitful

julia> He.T = 30u"K"
30 K

julia> density(He)
1.623503007493497 kg m^-3

A wide variety of unexported properties can be accessed from the underlying Python object:

julia> SF6 = Species("SF6", P=30u"psi")
Species(SF6, 298.1 K, 2.068e+05 Pa)

julia> SF6.MW
146.055419

help?> SF6.<tab>
A                                 SGs                                __init_subclass__
API                               STEL                               __le__
Am                                STEL_source                        __lt__
Bond                              STEL_sources                       __module__
Bvirial                           S_dep_Tb_P_ref_g                   __ne__
CAS                               S_dep_Tb_Pb_g                      __new__
Capillary                         S_dep_Tb_Pb_l                      __reduce__
Carcinogen                        S_dep_ref_g                        __reduce_ex__
Carcinogen_source                 S_int_Tb_to_T_ref_g                __repr__
Carcinogen_sources                S_int_l_Tm_to_Tb                   __setattr__
[...]
source

Interaction with Conda

PyThermo's Python dependencies are managed by CondaPkg.jl, which registers a project's dependencies in CondaPkg.toml (similar to Julia's Project.toml). These dependencies are installed automatically in a shared Conda environment located at ~/.julia/conda_environments/Thermo when PyThermo is first loaded. To use a different Conda environment, set the corresponding preference as described in the CondaPkg.jl documentation.

Index