Documentation
¶
Overview ¶
Package zfactor provides a comprehensive library for thermodynamic property calculations and visualization. It includes tools for solving Cubic Equations of State (EOS), estimating properties using correlations like Lee-Kesler, calculating liquid properties, and generating Pressure-Volume (PV) diagrams.
Index ¶
Constants ¶
View Source
const ( // RSI is the Universal Gas Constant in SI units [J/(mol·K)]. RSI = 8.314 // AtmPa is the standard atmospheric pressure in Pascals (Pa). AtmPa = 101_325.0 // AtmKPa is the standard atmospheric pressure in Kilopascals (kPa). AtmKPa = AtmPa * 1e-3 // AtmBar is the standard atmospheric pressure in Bars. AtmBar = AtmPa * 1e-5 )
Variables ¶
View Source
var ( // ErrTemp is returned when the absolute temperature is less than or equal to 0. ErrTemp = InputError{Msg: "absolute temperature (T) cannot be less than or equal to 0"} // ErrPressure is returned when the pressure is less than 0. ErrPressure = InputError{Msg: "pressure (P) cannot be less than 0"} // ErrCriticalProp is returned when a critical property (Tc or Pc) is less than or equal to 0. ErrCriticalProp = InputError{Msg: "critical property (Tc, Pc, Vc or Zc) cannot have a value less than or equal to 0"} // ErrUniversalConst is returned when the universal gas constant (R) is less than or equal to 0. ErrUniversalConst = InputError{Msg: "universal gas constant (R) value cannot be less than or equal to 0"} // ErrVirialCoeff is returned when a virial coefficient is 0. ErrVirialCoeff = InputError{Msg: "virial coefficient (B or C) cannot be 0"} // ErrVolume is returned when the molar volume is less than or equal to 0 ErrVolume = InputError{Msg: "molar volume (V) cannot be less than or equal to 0"} // ErrHighPressureTwoTerm is returned when the pressure exceeds 15 bar for the two-term virial equation. ErrHighPressureTwoTerm = InputError{Msg: "pressure exceeds the validity limit (15 bar) for the two-term virial equation"} // ErrInvalidTr is returned when the reduced temperature (Tr) is less than or equal to 0. ErrInvalidTr = InputError{Msg: "reduced temperature (Tr) must be greater than 0"} // ErrInvalidPr is returned when the reduced pressure (Pr) is less than or equal to 0. ErrInvalidPr = InputError{Msg: "reduced pressure (Pr) must be greater than 0"} )
Functions ¶
func SolveCubic ¶
func SolveCubic(a, b, c, d float64) ([3]complex128, error)
SolveCubic solves ax^3 + bx^2 + cx + d = 0 Returns all 3 roots (possibly complex).
Types ¶
type Args ¶ added in v1.2.0
type Args struct {
T float64 // Temperature
P float64 // Pressure
R float64 // Gas constant
B float64 // Second virial coefficient
C float64 // Third virial coefficient
}
Args holds the thermodynamic state arguments to prevent order-dependent errors. It is used to pass parameters like Temperature and Pressure safely.
type InputError ¶ added in v1.1.1
type InputError struct {
Msg string
}
InputError represents an error resulting from invalid input parameters.
func (InputError) Error ¶ added in v1.1.1
func (e InputError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
Package abbott provides the generalized correlations for the second virial coefficient
|
Package abbott provides the generalized correlations for the second virial coefficient |
|
Package antoine provides coefficients and calculation methods for the Antoine equation, which estimates the saturation vapor pressure of pure substances as a function of temperature.
|
Package antoine provides coefficients and calculation methods for the Antoine equation, which estimates the saturation vapor pressure of pure substances as a function of temperature. |
|
gen
command
|
|
|
Package cp provides coefficients for the calculation of heat capacities of gases (in the ideal-gas state), solids, and liquids.
|
Package cp provides coefficients for the calculation of heat capacities of gases (in the ideal-gas state), solids, and liquids. |
|
gen
command
|
|
|
Package cubic provides implementations of cubic Equations of State (EOS) for calculating thermodynamic properties such as volume and pressure.
|
Package cubic provides implementations of cubic Equations of State (EOS) for calculating thermodynamic properties such as volume and pressure. |
|
examples
|
|
|
liquids
command
|
|
|
problem_ethane_cylinder
command
|
|
|
problem_mixture
command
|
|
|
residual
command
|
|
|
virial
command
|
|
|
package leekesler contains the Lee/Kesler generalized correlation tables for the compressibility factor, residual enthalpy, residual entropy and the fugacity coefficient.
|
package leekesler contains the Lee/Kesler generalized correlation tables for the compressibility factor, residual enthalpy, residual entropy and the fugacity coefficient. |
|
gen
command
|
|
|
Package liquids provides correlations and data for calculating liquid properties.
|
Package liquids provides correlations and data for calculating liquid properties. |
|
gen
command
|
|
|
Package state provides functionality for defining thermodynamic states and generating visual representations such as PV diagrams.
|
Package state provides functionality for defining thermodynamic states and generating visual representations such as PV diagrams. |
|
package substance contains the characteristic properties of pure species
|
package substance contains the characteristic properties of pure species |
|
gen
command
|
|
Click to show internal directories.
Click to hide internal directories.

