Thermodynamical functions
ChemistryLab.ADIM_MATH_FUNCTIONSChemistryLab.AbstractFuncChemistryLab.NumericFuncChemistryLab.NumericFuncChemistryLab.NumericFuncChemistryLab.SymbolicFuncChemistryLab.SymbolicFuncChemistryLab.SymbolicFuncChemistryLab.SymbolicFuncChemistryLab.SymbolicFuncChemistryLab.ThermoFactoryChemistryLab.ThermoFactoryChemistryLab.ThermoFactoryBase.showBase.showBase.showBase.showChemistryLab.apply_symbolicChemistryLab.combine_symbolicChemistryLab.combine_symbolicChemistryLab.combine_symbolicChemistryLab.compile_symbolicChemistryLab.derivativeChemistryLab.extract_vars_paramsChemistryLab.get_unitChemistryLab.get_unit
ChemistryLab.ADIM_MATH_FUNCTIONS — Constant
ADIM_MATH_FUNCTIONSList of dimensionless mathematical functions to be extended for Quantity arguments.
ChemistryLab.AbstractFunc — Type
AbstractFuncAbstract type for objects that can be called like functions.
ChemistryLab.NumericFunc — Type
NumericFunc{N, F, R, Q} <: AbstractFuncClosure-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...) → valuein SI units.vars: names of the positional arguments (e.g.(:T, :P)).refs:NamedTupleof default variable values asQuantity(e.g.(T=298.15u"K", P=1e5u"Pa")).unit: output unit (DynamicQuantitiesQuantity).
ChemistryLab.NumericFunc — Method
NumericFunc(f, unit)Backward-compatible constructor: assumes vars = (:T, :P) and empty refs.
ChemistryLab.NumericFunc — Method
NumericFunc(f, vars, unit)Construct a NumericFunc with no refs (fallback to _NF_DEFAULT_REFS).
ChemistryLab.SymbolicFunc — Type
SymbolicFunc(expr::Expr, vars=[:T, :P, :t, :x, :y, :z]; kwargs...) -> SymbolicFuncCreate a SymbolicFunc from an expression.
ChemistryLab.SymbolicFunc — Type
SymbolicFuncThermodynamic function with symbolic expression and compiled evaluation.
ChemistryLab.SymbolicFunc — Method
SymbolicFunc(x::Quantity) -> SymbolicFuncCreate a constant SymbolicFunc from a quantity.
ChemistryLab.SymbolicFunc — Method
SymbolicFunc(x::Number) -> SymbolicFuncCreate a constant SymbolicFunc from a number (unitless).
ChemistryLab.SymbolicFunc — Method
SymbolicFunc(sym::Symbol; kwargs...) -> SymbolicFuncCreate a SymbolicFunc from a single symbol.
ChemistryLab.ThermoFactory — Type
ThermoFactory(expr, vars=[:T, :P, :t, :x, :y, :z]; units=nothing) -> ThermoFactoryCreate 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.
ChemistryLab.ThermoFactory — Type
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).
ChemistryLab.ThermoFactory — Method
(factory::ThermoFactory)(; kwargs...)Create a SymbolicFunc with caching for optimal performance.
ChemistryLab.apply_symbolic — Method
apply_symbolic(op, sf::SymbolicFunc)Apply unary operation.
ChemistryLab.combine_symbolic — Method
combine_symbolic(op, x::Number, sf::SymbolicFunc)Combine scalar with SymbolicFunc.
ChemistryLab.combine_symbolic — Method
combine_symbolic(op, sf::SymbolicFunc, x::Number)Combine SymbolicFunc with scalar.
ChemistryLab.combine_symbolic — Method
combine_symbolic(op, sf1::SymbolicFunc, sf2::SymbolicFunc)Combine two SymbolicFuncs.
ChemistryLab.compile_symbolic — Method
compile_symbolic(symbolic_expr, var_symbols)Compile a symbolic expression to RuntimeGeneratedFunction.
ChemistryLab.derivative — Method
derivative(sf::SymbolicFunc, var::Symbol) -> SymbolicFuncCompute 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)ChemistryLab.extract_vars_params — Method
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.
ChemistryLab.get_unit — Method
get_unit(factory::ThermoFactory, sym::Symbol) -> QuantityGet the unit of a specific variable or parameter in the factory.
ChemistryLab.get_unit — Method
get_unit(factory::ThermoFactory) -> QuantityGet the output unit of the expression managed by the factory.