Quick Start Guide¶
This guide will get you up and running with sandlercubics in just a few minutes.
Basic Concepts¶
sandlercubics provides implementations of pure-species cubic equations of state (EOS) presented in Sandler’s textbook:
van der Waals (vdW): The original cubic EOS, useful for understanding basic concepts
Peng-Robinson (PR): Industry-standard EOS with good accuracy for hydrocarbons
Soave-Redlich-Kwong (SRK): Alternative cubic EOS popular in gas processing
You can set up a state using temperature (T) and pressure (P) as inputs, along with a compound name from the sandlerprops database or by providing critical properties directly. Instead of T and P, you can also specify other combinations of state variables, such as T and molar volume (v), or P and molar enthalpy (h). Any two independent state variables are sufficient to define the thermodynamic state of a pure substance. However, at least one of the two variables must be temperature or pressure (for now).
The following computed properties are always represented by numpy arrays, even if they contain only a single value:
Compressibility factor (Z)
Molar enthalpy (h), entropy (s), volume (v), and internal energy (u) (with respect to reference temperature of 298.15 K and reference pressure of 0.1 MPa)
Enthalpy and entropy departure (Hdep, Sdep)
The following properties are available when applicable as scalars:
Heat of vaporization (ΔHvap) at state temperature and saturation pressure
Entropy of vaporization (ΔSvap) at state temperature and saturation pressure
Vapor pressure (Pvap) (aka, saturation pressure) at state temperature
Saturation temperature (Tsat) at state pressure
Vapor fraction (xvap) for two-phase states
Temperature is in Kelvin (K) and pressure is in megapascals (MPa) by default. All quantities are typed as pint.Quantity and therefore have units. See the API documentation for details.
First Calculation¶
Let’s calculate the molar volume of methane at 400 K and 0.5 MPa using the Peng-Robinson equation:
From the Command Line¶
sandlercubics state -T 400 -P 0.5 -eos pr -n methane
Output:
T = 400 kelvin
P = 0.5 megapascal
v = 0.00662792 meter ** 3 / mole
u = 544.821 joule / mole
h = 3858.78 joule / mole
s = -2.23817 joule / kelvin / mole
Pv = 3313.96 joule / mole
Z = 0.996444
Tsat = 135.11 kelvin at 0.5 megapascal
From Python¶
from sandlercubics import PengRobinsonEOS
# Create EOS object and set state
pr_methane = PengRobinsonEOS(T=400, P=0.5).set_compound('methane')
# Access calculated properties; remember these are numpy arrays
print(f"Compressibility factor: {', '.join([f'{z: 4g}' for z in pr_methane.Z])}")
print(f"Molar volume: {', '.join([f'{v: 6g}' for v in pr_methane.v])} m³/mol")
print(f"Enthalpy: {', '.join([f'{h: 6g}' for h in pr_methane.h])} J/mol")
print(f"Entropy: {', '.join([f'{s: 6g}' for s in pr_methane.s])} J/mol-K")
print(f"Enthalpy departure: {', '.join([f'{hdep: 6g}' for hdep in pr_methane.h_departure])} J/mol")
print(f"Entropy departure: {', '.join([f'{sdep: 6g}' for sdep in pr_methane.s_departure])} J/mol-K")
You need not set the state variables (T, P) during initialization; you can also just directly assign them later:
from sandlercubics import PengRobinsonEOS
# Create EOS object without state and without compound
pr = PengRobinsonEOS()
# Set compound later; .set_compound returns self for convenience
pr_methane = pr.set_compound('methane')
# Set state later
pr_methane.T = 400
pr_methane.P = 0.5
# Now access properties as before
print(f"Molar volume: {', '.join([f'{v: 6g}' for v in pr_methane.v])} m³/mol")
State-Change Calculations¶
Calculate property changes between two thermodynamic states:
From the Command Line¶
sandlercubics delta -T1 350 -P1 7.5 -T2 400 -P2 15.5 -n methane -eos pr --show-states
Output:
State-change calculations for methane using Peng-Robinson Equation of State:
State 1: State 2:
T = 350 kelvin T = 400 kelvin
P = 7.5 megapascal P = 15.5 megapascal
v = 0.000359369 meter ** 3 / mole v = 0.000204025 meter ** 3 / mole
u = -1765.92 joule / mole u = -661.182 joule / mole
h = 929.35 joule / mole h = 2501.21 joule / mole
s = -32.095 joule / kelvin / mole s = -33.5449 joule / kelvin / mole
Pv = 2695.27 joule / mole Pv = 3162.39 joule / mole
Z = 0.92619 Z = 0.950871
Property changes:
ΔT = 50 kelvin
ΔP = 8 megapascal
Δh = 1571.86 joule / mole
Δs = -1.44983 joule / kelvin / mole
Δu = 1104.74 joule / mole
Δv = -0.000155344 meter ** 3 / mole
ΔPv = 467.124 joule / mole
ΔZ = 0.0246816
From Python¶
State-change calculations can be performed by creating two EOS objects representing the initial and final states, then using the built-in methods to compute property differences:
from sandlercubics import PengRobinsonEOS
# State 1
pr_methane1 = PengRobinsonEOS(T=350, P=7.5).set_compound('methane')
# State 2
pr_methane2 = PengRobinsonEOS(T=400, P=15.5).set_compound('methane')
# Calculate property differences using built-in methods
delta = pr_methane1.delta_property(pr_methane2)
print(f"Δh = {', '.join([f'{dh: 7g}' for dh in delta['h']])} J/mol")
print(f"Δs = {', '.join([f'{ds: 7g}' for ds in delta['s']])} J/mol-K")
print(f"Δu = {', '.join([f'{du: 7g}' for du in delta['u']])} J/mol")
Available Equations of State¶
Ideal gas¶
from sandlercubics import IdealGasEOS
ig = IdealGasEOS()
van der Waals¶
from sandlercubics import VanDerWaalsEOS
vdw_methane = VanDerWaalsEOS().set_compound('methane')
Peng-Robinson¶
from sandlercubics import PengRobinsonEOS
pr_benzene = PengRobinsonEOS().set_compound('benzene')
Soave-Redlich-Kwong¶
from sandlercubics import SoaveRedlichKwongEOS
srk_ethanol = SoaveRedlichKwongEOS().set_compound('ethanol')
Next Steps¶
Learn more about the Command-Line Interface for advanced command-line usage
Explore Examples for more complex calculations
Read about the Theoretical Background behind cubic equations of state
Check the sandlercubics for complete API documentation