Contents

Index

Association types and methods

Clapeyron.Compressed4DMatrixType
Compressed4DMatrix{T,V<:AbstractVector{T}}
Compressed4DMatrix(vals::AbstractVector,ijab::AbstractVector)
Compressed4DMatrix(vals,ij,ab,unsafe::Bool = false)

Struct used to hold association data. as its name says, it is a compressed 4D matrix containing all the non-zero combinations of component-site pairs. The component-site pairs (i,j,a,b) are sorted lexicographically. the (i,j) pairs are stored in the outer_indices field, whereas the (a,b) pairs are stored in the inner_indices field. Let's see an associating model:

julia> model = PCSAFT(["water","methanol","ethane"],assoc_options = AssocOptions(combining = :esd))
PCSAFT{BasicIdeal} with 3 components:
 "water"
 "methanol"
 "ethane"
Contains parameters: Mw, segment, sigma, epsilon, epsilon_assoc, bondvol

We check out the bondvol parameter. note how ethane does not appear in the list:

julia> model.params.bondvol
AssocParam{Float64}["water", "methanol", "ethane"]) with 4 values:
("water", "e") >=< ("water", "H"): 0.034868
("methanol", "e") >=< ("water", "H"): 0.03495053755004983
("methanol", "H") >=< ("water", "e"): 0.03495053755004983
("methanol", "e") >=< ("methanol", "H"): 0.035176

The underlying structure used to store AssocParam values is a Compressed4DMatrix:

julia> vals = model.params.bondvol.values
Clapeyron.Compressed4DMatrix{Float64, Vector{Float64}} with 4 entries:
 (1, 1) >=< (1, 2): 0.034868
 (2, 1) >=< (1, 2): 0.03495053755004983
 (2, 2) >=< (1, 1): 0.03495053755004983
 (2, 1) >=< (2, 2): 0.035176
julia> vals.values
4-element Vector{Float64}:
 0.034868
 0.03495053755004983
 0.03495053755004983
 0.035176
julia> vals.outer_indices
4-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 1)
 (2, 1)
 (2, 2)
julia> vals.inner_indices
4-element Vector{Tuple{Int64, Int64}}:
 (1, 2)
 (1, 2)
 (2, 1)
 (1, 2)

If we check the indices:

julia> idxs = [(ij...,ab...) for (ij,ab) in zip(vals.outer_indices,vals.inner_indices)]
4-element Vector{NTuple{4, Int64}}:
 (1, 1, 1, 2)
 (2, 1, 1, 2)
 (2, 1, 2, 1)
 (2, 2, 1, 2)
julia> issorted(idxs)
true

You can build a Compressed4DMatrix in two ways:

  1. you can pass values and a list of (i,j,a,b)::NTuple{4,Int} indices:
julia> ijab, vals = [(1,1,1,2)], [3.0]
([(1, 1, 1, 2)], [3.0])
julia> Clapeyron.Compressed4DMatrix(vals,ijab)
Clapeyron.Compressed4DMatrix{Float64, Vector{Float64}} with 1 entry:
 (1, 1) >=< (1, 2): 3.0
  1. Using a list of values, a list of ij:Tuple{Int,Int} outer indices and a list of ab:Tuple{Int,Int} inner indices. this last form accepts the optional argument unsafe::Bool.

If unsafe is true, ij and ab will be considered sorted, and will build a Compressed4DMatrix directly, using the same reference to vals, ij and ab:

julia> ij, ab, vals = [(1,1)], [(1,2)], [3.0]
([(1, 1)], [(1, 2)], [3.0])
julia> assoc1,assoc2 = Clapeyron.Compressed4DMatrix(vals,ij,ab),Clapeyron.Compressed4DMatrix(vals,ij,ab,true)
(Clapeyron.Compressed4DMatrix{Float64, Vector{Float64}}[3.0], Clapeyron.Compressed4DMatrix{Float64, Vector{Float64}}[3.0])
julia> assoc1.values[1] = 100; (vals,assoc1.values[1])
([3.0], 100.0)
julia> assoc2.values[1] = 100; (vals,assoc2.values[1])
([100.0], 100.0)
Clapeyron.assoc_pair_lengthFunction
assoc_pair_length(model::EoSModel)

Indicates the number of pair combinations between the different sites in an association model.

Example:

julia> model = PCSAFT(["water"])
PCSAFT{BasicIdeal} with 1 component:
 "water"
Contains parameters: Mw, segment, sigma, epsilon, epsilon_assoc, bondvol

julia> model.params.bondvol
AssocParam{Float64}["water"]) with 1 value:
("water", "e") >=< ("water", "H"): 0.034868

julia> Clapeyron.assoc_pair_length(model)
1
Clapeyron.assoc_similarFunction
assoc_similar(mat::Compressed4DMatrix)
assoc_similar(mat::Compressed4DMatrix,::Type{𝕋}) where 𝕋 <:Number)

returns a Clapeyron.Compressed4DMatrix of the same shape as the input, with the same element type as 𝕋

assoc_similar(param::SiteParam)
assoc_similar(param::SiteParam,::Type{𝕋}) where 𝕋 <:Number)

returns a Clapeyron.Compressed4DMatrix with the smae number of components as the input AssocParam, with the same element type as 𝕋. All site combinations are filled.

Clapeyron.assoc_optionsFunction
assoc_options(model::EoSModel)

Returns association options used in the association solver.

Clapeyron.assoc_strengthFunction
assoc_strength(model::EoSModel,V,T,z,i,j,a,b,data = Clapeyron.data(Model,V,T,z))
Δ(model::EoSModel,V,T,z,i,j,a,b,data = Clapeyron.data(Model,V,T,z))

Calculates the asssociation strength between component i at site a and component j at site b.

Any precomputed values can be passed along by calling Clapeyron.data.

Example

julia> model = PCSAFT(["water"])
PCSAFT{BasicIdeal} with 1 component:
 "water"
Contains parameters: Mw, segment, sigma, epsilon, epsilon_assoc, bondvol

julia> model.params.bondvol.values
Clapeyron.Compressed4DMatrix{Float64, Vector{Float64}} with 1 entry:
 (1, 1) >=< (1, 2): 0.034868

julia> Clapeyron.assoc_strength(model,2.5e-5,298.15,[1.0],1,1,1,2) #you can also use Clapeyron.Δ
1.293144062056963e-26

#PCSAFT precomputed data: (d,ζ₀,ζ₁,ζ₂,ζ₃,m̄)
julia> _data = Clapeyron.data(model,2.5e-5,298.15,[1.0])
([2.991688553098391e-10], 1.3440137996322956e28, 4.020870699566213e18, 1.2029192845380957e9, 0.3598759853853927, 1.0656)

julia> Clapeyron.Δ(model,2.5e-5,298.15,[1.0],1,1,1,2,_data)
1.293144062056963e-26
Clapeyron.assoc_fractionsFunction
assoc_fractions(model::EoSModel, V, T, z,data = nothing)

Returns the solution for the association site fractions. used internally by all models that require association. The result is of type PackedVectorsOfVectors.PackedVectorOfVectors, with length = length(model), and x[i][a] representing the empty fraction of the site a at component i

Example:

julia> model = PCSAFT(["water","methanol","ethane"],assoc_options = AssocOptions(combining = :esd))
PCSAFT{BasicIdeal} with 3 components:
 "water"
 "methanol"
 "ethane"
Contains parameters: Mw, segment, sigma, epsilon, epsilon_assoc, bondvol

julia> x = Clapeyron.assoc_fractions(model,2.6e-5,300.15,[0.3,0.3,0.4]) #you can also use `Clapeyron.X`
3-element pack(::Vector{Vector{Float64}}):
 [0.041396427041509046, 0.041396427041509046]
 [0.018874664357682362, 0.018874664357682362]
 0-element view(::Vector{Float64}, 5:4) with eltype Float64