Contents

Index

Primitive functions

Almost all models in Clapeyron based on helmholtz free energy have at least one of the following functions defined:

Clapeyron.eosFunction
eos(model::EoSModel, V, T, z=SA[1.0])

Returns the total Helmholtz free energy.

Inputs:

  • model::EoSModel Thermodynamic model to evaluate
  • V Total volume, in [m³]
  • T Temperature, in [K]
  • z mole amounts, in [mol], by default is @SVector [1.0]

Outputs:

  • Total Helmholtz free energy, in [J]

by default, it calls R̄*T*∑(z)*(a_ideal(ideal_model,V,T,z) + a_res(model,V,T,z)) where ideal_model == idealmodel(model), where a_res is the reduced residual Helmholtz energy and a_ideal is the reduced ideal Helmholtz energy. You can mix and match ideal models if you provide:

  • [idealmodel](@ref)(model): extracts the ideal model from your Thermodynamic model
  • [a_res](@ref)(model,V,T,z): residual reduced Helmholtz free energy
Clapeyron.eos_resFunction
eos_res(model::EoSModel, V, T, z=SA[1.0])

Returns the residual Helmholtz free energy.

Inputs:

  • model::EoSModel Thermodynamic model to evaluate
  • V Total volume, in [m³]
  • T Temperature, in [K]
  • z mole amounts, in [mol], by default is @SVector [1.0]

Outputs:

  • Residual Helmholtz free energy, in [J]

by default, it calls R̄*T*∑(z)*(a_res(model,V,T,z)) where a_res is the reduced residual Helmholtz energy.

Clapeyron.idealmodelFunction
idealmodel(model::EoSModel)

retrieves the ideal model from the input's model. if the model is already an idealmodel, return nothing

Examples:

julia> pr = PR(["water"],idealmodel=MonomerIdeal)
PR{MonomerIdeal, PRAlpha, NoTranslation, vdW1fRule} with 1 component:
 "water"
Contains parameters: a, b, Tc, Pc, Mw
julia> ideal = idealmodel(pr)
MonomerIdeal with 1 component:
 "water"
Contains parameters: Mw
julia> idealmodel(ideal) == nothing
true
Clapeyron.a_resFunction
a_res(model::EoSModel, V, T, z,args...)

Reduced residual Helmholtz free energy.

Inputs:

  • model::EoSModel Thermodynamic model to evaluate
  • V Total volume, in [m³]
  • T Temperature, in [K]
  • z mole amounts, in [mol], by default is @SVector [1.0]

Outputs:

  • Residual Helmholtz free energy, no units

You can define your own EoS by adding a method to a_res that accepts your custom model.

Automatic Differenciation functions

All bulk properties in Clapeyron are calculated via a combination of these Automatic Differenciation Primitives over eos or eos_res

Clapeyron.∂f∂TFunction
∂f∂T(model,V,T,z=SA[1.0])

returns f and ∂f/∂T at constant total volume and composition, where f is the total helmholtz energy, given by eos(model,V,T,z)

Clapeyron.∂f∂VFunction
∂f∂V(model,V,T,z=SA[1.0])

returns f and ∂f/∂V at constant temperature and composition, where f is the total helmholtz energy, given by eos(model,V,T,z), and V is the total volume

Clapeyron.∂fFunction
∂f(model,V,T,z)

returns zeroth order (value) and first order derivative information of the total helmholtz energy (given by eos(model,V,T,z)). the result is given in two values:

grad_f,fval = ∂2f(model,V,T,z)

where:

fval   = f(V,T) = eos(model,V,T,z)

grad_f = [ ∂f/∂V; ∂f/∂T]

Where V is the total volume, T is the temperature and f is the total helmholtz energy.

Clapeyron.p∂p∂VFunction
p∂p∂V(model,V,T,z=SA[1.0])

returns p and ∂p/∂V at constant temperature, where p is the pressure = pressure(model,V,T,z) and V is the total Volume.

Clapeyron.∂2fFunction
∂2f(model,V,T,z)

returns zeroth order (value), first order and second order derivative information of the total helmholtz energy (given by eos(model,V,T,z)). the result is given in three values:

hess_f,grad_f,fval = ∂2f(model,V,T,z)

where: ``` fval = f(V,T) = eos(model,V,T,z)

grad_f = [ ∂f/∂V; ∂f/∂T]

hess_f = [ ∂²f/∂V²; ∂²f/∂V∂T ∂²f/∂V∂T; ∂²f/∂V²] ```

Where V is the total volume, T is the temperature and f is the total helmholtz energy.

Clapeyron.∂2pFunction
∂2p(model,V,T,z)

returns zeroth order (value), first order and second order derivative information of the pressure. the result is given in three values:

hess_p,grad_p,pval = ∂2p(model,V,T,z)

where: ``` pval = p(V,T) = pressure(model,V,T,z)

grad_p = [ ∂p/∂V; ∂p/∂T]

hess_p = [ ∂²p/∂V²; ∂²p/∂V∂T ∂²p/∂V∂T; ∂²p/∂V²] ```

Where V is the total volume, T is the temperature and p is the pressure.

Clapeyron.f_hessFunction
f_hess(model,V,T,z)

returns the second order volume (V) and temperature (T) derivatives of the total helmholtz energy (given by eos(model,V,T,z)). the result is given in a 2x2 SMatrix, in the form:

[ ∂²f/∂V² ∂²f/∂V∂T ∂²f/∂V∂T ∂²f/∂T²]

use this instead of the ∂2f if you only need second order information. ∂2f also gives zeroth and first order derivative information, but due to a bug in the used AD, it allocates more than necessary.

Clapeyron.∂²³fFunction
∂²³f(model,V,T,z=SA[1.0])

returns ∂²A/∂V² and ∂³A/∂V³, in a single ForwardDiff pass. used mainly in crit_pure objective function

Thermodynamic Method Dispatch types

Clapeyron.ThermodynamicMethodType
ThermodynamicMethod

Abstract type for all thermodynamic methods.

normally, a thermodynamic method has the form: property(model,state..,method::ThermodynamicMethod). All methods used in this way subtype ThermodynamicMethod.

Examples

Saturation pressure:

model = PR(["water"])
Tsat = 373.15
saturation_pressure(model,Tsat) #using default method (chemical potential with volume base)
saturation_pressure(model,Tsat,SuperAncSaturation()) #solve using cubic superancillary

Bubble point pressure

model = PCSAFT(["methanol","cyclohexane"])
T = 313.15
z = [0.5,0.5]
bubble_pressure(model,T,z) #using default method (chemical potential equality)
bubble_pressure(model,T,z,FugBubblePressure(y0 =  = [0.6,0.4], p0 = 5e4)) #using isofugacity criteria with starting points
Clapeyron.SaturationMethodType
SaturationMethod <: ThermodynamicMethod

Abstract type for saturation_temperature and saturation_pressure routines. Should at least support passing the crit keyword, containing the critical point, if available.

Clapeyron.BubblePointMethodType
BubblePointMethod <: ThermodynamicMethod

Abstract type for bubble_pressure and bubble_temperature routines.

Should at least support passing the y0 keyword, containing an initial vapour phase, if available.

Clapeyron.DewPointMethodType
DewPointMethod <: ThermodynamicMethod

Abstract type for dew_pressure and dew_temperature routines.

Should at least support passing the x0 keyword, containing an initial vapour phase, if available.

Clapeyron.TPFlashMethodType
TPFlashMethod <: ThermodynamicMethod

Abstract type for tp_flash routines. it requires defining numphases(method) and tp_flash_impl(model,p,T,n,method). If the method accept component-dependent inputs, it also should define index_reduction(method,nonzero_indices)