Thermodynamical functions

ChemistryLab.NumericFuncType
NumericFunc{N, F, R, Q} <: AbstractFunc

Closure-backed thermodynamic function for models that cannot be represented as symbolic expressions (e.g. HKF, or any other numeric model). Calling convention is identical to SymbolicFunc: f(; T=..., P=..., unit=false).

Variable values are resolved in order: kwarg > refs > _NF_DEFAULT_REFS. refs stores Quantity values so that unit information is preserved.

Fields

  • compiled: closure (vars...) → value in SI units.
  • vars: names of the positional arguments (e.g. (:T, :P)).
  • refs: NamedTuple of default variable values as Quantity (e.g. (T=298.15u"K", P=1e5u"Pa")).
  • unit: output unit (DynamicQuantities Quantity).
source
ChemistryLab.SymbolicFuncType
SymbolicFunc(expr::Expr, vars=[:T, :P, :t, :x, :y, :z]; kwargs...) -> SymbolicFunc

Create a SymbolicFunc from an expression.

source
ChemistryLab.ThermoFactoryType
ThermoFactory(expr, vars=[:T, :P, :t, :x, :y, :z]; units=nothing) -> ThermoFactory

Create a ThermoFactory from a symbolic expression.

Arguments

  • expr: symbolic expression (Expr or Symbol).
  • vars: list of variable symbols (default: T, P, t, x, y, z).
  • units: dictionary mapping symbols to their units.
source
ChemistryLab.ThermoFactoryType
ThermoFactory{Q}

Factory for creating SymbolicFunc instances from expressions. Units for each variable/parameter and the output unit are stored explicitly, removing the need for symbolic unit propagation (previously done via ModelingToolkitBase).

source
Base.showMethod
Base.show(io::IO, ::MIME"text/plain", sf::SymbolicFunc)

Detailed string representation of a SymbolicFunc.

source
Base.showMethod
Base.show(io::IO, ::MIME"text/plain", factory::ThermoFactory)

Detailed string representation of a ThermoFactory.

source
Base.showMethod
Base.show(io::IO, sf::SymbolicFunc)

Compact string representation of a SymbolicFunc.

source
Base.showMethod
Base.show(io::IO, factory::ThermoFactory)

Compact string representation of a ThermoFactory.

source
ChemistryLab.derivativeMethod
derivative(sf::SymbolicFunc, var::Symbol) -> SymbolicFunc

Compute the analytical derivative of sf with respect to variable var using Symbolics.jl and return a new SymbolicFunc for the result.

The output unit is inferred as sf.unit / unit_of_var, where unit_of_var is read from sf.refs (defaulting to dimensionless if var has no ref entry).

Examples

Cp = SymbolicFunc(:(a + b*T + c/T^2); a=25.0, b=8e-3, c=-1.5e5)
dCp_dT = derivative(Cp, :T)   # ∂Cp/∂T
dCp_dT(T = 500.0)
source
ChemistryLab.extract_vars_paramsMethod
extract_vars_params(expr, vars) -> (Vector{Symbol}, Vector{Symbol})

Identify variables and parameters in an expression.

Arguments

  • expr: symbolic expression to analyze.
  • vars: list of symbols considered as variables (others are parameters).

Returns

  • Tuple of (variables, parameters) found in the expression.
source
ChemistryLab.get_unitMethod
get_unit(factory::ThermoFactory, sym::Symbol) -> Quantity

Get the unit of a specific variable or parameter in the factory.

source
ChemistryLab.get_unitMethod
get_unit(factory::ThermoFactory) -> Quantity

Get the output unit of the expression managed by the factory.

source