gas_eos
Real-gas equations of state (ideal, van der Waals, Redlich-Kwong, Peng-Robinson) from the critical temperature, critical pressure and acentric factor given as inputs: compressibility Z, liquid and vapour molar volumes, fugacity coefficient, second virial coefficient, saturation pressure by equal fugacity, the isotherm and the vapour-pressure curve as csv.
- Field
- Chemistry
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 0.05 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001ideal gas molar volume R T / P at 273.15 K and 101325 Pa = 22.41396954 L/mol (CODATA 2018, R exact from k_B N_A); closed form, rel 1e-9passed
molar_volume_L_per_mol22.414 ± 2.2e-0822.414locked22 % of the tolerance usedZ1 ± 1e-121lockedunder 0.01 % of the tolerance usedr0002van der Waals critical point (Tc 400 K, Pc 4 MPa): Zc = 3/8 exactly, Omega_a = 27/64, Omega_b = 1/8, dP/dV = d2P/dV2 = 0 at (Tc, Vc); Z of the triple root to abs 1e-4 because a triple root carries the cube root of rounding (~5e-6)passed
Zc0.375 ± 3.8e-130.375lockedunder 0.01 % of the tolerance usedomega_a0.421875 ± 4.2e-130.421875lockedunder 0.01 % of the tolerance usedomega_b0.125 ± 1.2e-130.125lockedunder 0.01 % of the tolerance usedcritical_pressure_ratio1 ± 1e-091lockedunder 0.01 % of the tolerance usedcritical_dP_dV_reduced0 ± 1e-09-1.18939e-15lockedunder 0.01 % of the tolerance usedcritical_d2P_dV2_reduced0 ± 1e-096.0759e-15lockedunder 0.01 % of the tolerance usedZ0.375 ± 0.00010.375002locked1.8 % of the tolerance usedtriple_root_spread0 to 0.00012.75088e-06lockedinside the ranger0003Redlich-Kwong critical point: Zc = 1/3 exactly, Omega_b = (2^(1/3)-1)/3 = 0.08664035, Omega_a = 1/(9(2^(1/3)-1)) = 0.42748023 (Redlich & Kwong 1949 closed forms, rel 1e-6); triple root Z abs 1e-4 (cube-root conditioning)passed
Zc0.333333 ± 3.3e-130.333333lockedunder 0.01 % of the tolerance usedomega_b0.0866404 ± 8.7e-080.0866403locked0.04 % of the tolerance usedomega_a0.42748 ± 4.3e-070.42748locked0.83 % of the tolerance usedcritical_dP_dV_reduced0 ± 1e-09-4.22895e-15lockedunder 0.01 % of the tolerance usedcritical_d2P_dV2_reduced0 ± 1e-091.44021e-14lockedunder 0.01 % of the tolerance usedZ0.333333 ± 0.00010.333337locked4 % of the tolerance usedtriple_root_spread0 to 0.00013.81471e-06lockedinside the ranger0004Peng-Robinson critical point (Peng & Robinson 1976 textbook values Zc 0.3074, Omega_a 0.45724, Omega_b 0.07780, abs tol half the last printed digit); dP/dV = d2P/dV2 = 0; triple root Z abs 1e-4 (cube-root conditioning)passed
Zc0.3074 ± 5e-050.307401locked2.6 % of the tolerance usedomega_a0.45724 ± 5e-060.457236locked89 % of the tolerance usedomega_b0.0778 ± 5e-060.0777961locked79 % of the tolerance usedalpha1 ± 1e-121lockedunder 0.01 % of the tolerance usedcritical_dP_dV_reduced0 ± 1e-09-2.92497e-15lockedunder 0.01 % of the tolerance usedcritical_d2P_dV2_reduced0 ± 1e-091.22484e-14lockedunder 0.01 % of the tolerance usedZ0.307401 ± 0.00010.307404locked3 % of the tolerance usedtriple_root_spread0 to 0.00013.4659e-06lockedinside the ranger0005van der Waals second virial B2 = b - a/(R T) = -(19/64) R Tc/Pc = -2.46835609e-4 m3/mol at T = Tc = 400 K, Pc = 4 MPa (closed form); Z at 1 Pa tends to 1 + B2 P/(R T) = 1 - 7.421875e-8 (abs 1e-12, the next virial term is ~1e-14); B2 from the solved Z at low pressure rel 1e-6 (finite-pressure slope)passed
second_virial_m3_per_mol-0.000246836 ± 2.5e-13-0.000246836lockedunder 0.01 % of the tolerance usedsecond_virial_from_Z_m3_per_mol-0.000246836 ± 2.5e-10-0.000246836locked0.5 % of the tolerance usedZ1 ± 1e-121locked0.46 % of the tolerance usedr0006van der Waals saturation by equal fugacity against Lekner's exact parametric coexistence (Am. J. Phys. 50, 161, 1982) at y = 1: T = 0.900880331 Tc, P = 0.649705129 Pc, V_L = 0.604476735 Vc, V_V = 2.336827136 Vc (Tc 400 K, Pc 4 MPa); closed form, rel 1e-7passed
saturation_pressure_Pa2.59882e+06 ± 0.262.59882e+06lockedunder 0.01 % of the tolerance usedsaturation_V_liquid_L_per_mol0.188471 ± 1.9e-080.188471lockedunder 0.01 % of the tolerance usedsaturation_V_vapor_L_per_mol0.728605 ± 7.3e-080.728605lockedunder 0.01 % of the tolerance usedsaturation_ln_phi_gap0 ± 1e-09-5.55112e-16lockedunder 0.01 % of the tolerance used
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
eos | 1 | peng_robinson | Equation of state. |
T_K | K | 300.0 | Temperature. |
P_Pa | Pa | 101325.0 | Absolute pressure. |
Tc_K | K | Critical temperature of the substance (needed for every eos but ideal). | |
Pc_Pa | Pa | Critical pressure of the substance (needed for every eos but ideal). | |
omega | 1 | 0.0 | Acentric factor (Peng-Robinson only). |
kappa | 1 | Peng-Robinson alpha slope; replaces the 1976 correlation 0.37464 + 1.54226 omega - 0.26992 omega^2 when given. | |
isotherm_points | 1 | 200 | Rows in out/isotherm.csv. |
Readings
| Name | Unit | Meaning |
|---|---|---|
eos | 1 | |
R_J_per_mol_K | J/(mol K) | |
T_K | K | |
P_Pa | Pa | |
reduced_temperature | 1 | |
reduced_pressure | 1 | |
omega_a | 1 | |
omega_b | 1 | |
alpha | 1 | |
kappa | 1 | |
a_Pa_m6_per_mol2 | Pa m^6/mol^2 | |
b_m3_per_mol | m^3/mol | |
A | 1 | |
B | 1 | |
Z | 1 | |
phase | 1 | |
real_root_count | 1 | |
Z_liquid | 1 | |
Z_vapor | 1 | |
molar_volume_m3_per_mol | m^3/mol | |
molar_volume_L_per_mol | L/mol | |
density_mol_per_m3 | mol/m^3 | |
V_liquid_L_per_mol | L/mol | |
V_vapor_L_per_mol | L/mol | |
ln_fugacity_coefficient | 1 | |
fugacity_coefficient | 1 | |
fugacity_Pa | Pa | |
fugacity_coefficient_liquid | 1 | |
fugacity_coefficient_vapor | 1 | |
cubic_residual | 1 | |
triple_root_spread | 1 | |
second_virial_m3_per_mol | m^3/mol | |
second_virial_from_Z_m3_per_mol | m^3/mol | |
Zc | 1 | |
Vc_L_per_mol | L/mol | |
critical_pressure_ratio | 1 | |
critical_dP_dV_reduced | 1 | |
critical_d2P_dV2_reduced | 1 | |
saturation_pressure_Pa | Pa | |
saturation_Z_liquid | 1 | |
saturation_Z_vapor | 1 | |
saturation_V_liquid_L_per_mol | L/mol | |
saturation_V_vapor_L_per_mol | L/mol | |
saturation_fugacity_coefficient | 1 | |
saturation_ln_phi_gap | 1 | |
spinodal_min_Pa | Pa | |
spinodal_max_Pa | Pa | |
pressure_over_saturation | 1 | |
isotherm_csv | 1 | out/isotherm.csv: V_L_per_mol, P_Pa, Z, P_ideal_Pa, P_coexistence_Pa (Maxwell line inside the two-phase dome). |
isotherm_points | 1 | |
saturation_curve_csv | 1 | out/saturation_curve.csv: T_K, T_over_Tc, P_sat_Pa, V_liquid_L_per_mol, V_vapor_L_per_mol from 0.45 Tc to 0.995 Tc. |
saturation_curve_points | 1 | |
all_ok | 1 | |
warnings | 1 |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.