-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathcombiningrules.jl
178 lines (139 loc) · 6.14 KB
/
combiningrules.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
include("combiningrules/base.jl")
include("combiningrules/implace.jl")
include("combiningrules/outplace.jl")
include("combiningrules/group.jl")
include("combiningrules/assoc.jl")
include("combiningrules/get_k.jl")
"""
sigma_LorentzBerthelot(σ::SingleOrPair,ζ::PairParam)::PairParam
sigma_LorentzBerthelot(σ::SingleOrPair)::PairParam
Combining rule for a single or pair parameter. returns a pair parameter with non diagonal entries equal to:
```
σᵢⱼ = (1 - ζᵢⱼ)*(σᵢ + σⱼ)/2
```
If `ζᵢⱼ` is not defined, the definition is reduced to a simple arithmetic mean:
```
σᵢⱼ = (σᵢ + σⱼ)/2
```
Ignores non-diagonal entries already set.
If a Single Parameter is passed as input, it will be converted to a Pair Parameter with `σᵢᵢ = σᵢ`.
"""
function sigma_LorentzBerthelot end
sigma_LorentzBerthelot(sigma::SingleOrPair,zeta = nothing) = kij_mix(mix_mean,sigma,zeta)
sigma_LorentzBerthelot!(sigma::PairParameter,zeta = nothing) = kij_mix!(mix_mean,sigma,zeta)
"""
epsilon_LorentzBerthelot(ϵ::SingleOrPair,k::PairParam)::PairParam
epsilon_LorentzBerthelot(ϵ::SingleOrPair)::PairParam
Combining rule for a single or pair parameter. returns a pair parameter with non diagonal entries equal to:
```
ϵᵢⱼ = (1 - kᵢⱼ)*√(ϵᵢϵⱼ)
```
If `kᵢⱼ` is not defined, the definition is reduced to a simple geometric mean:
```
ϵᵢⱼ = √(ϵᵢϵⱼ)
```
Ignores non-diagonal entries already set.
If a Single Parameter is passed as input, it will be converted to a Pair Parameter with `ϵᵢᵢ = ϵᵢ`.
"""
function epsilon_LorentzBerthelot end
epsilon_LorentzBerthelot(epsilon::SingleOrPair, k = nothing) = kij_mix(mix_geomean,epsilon,k)
epsilon_LorentzBerthelot!(epsilon::PairParameter, k = nothing) = kij_mix!(mix_geomean,epsilon,k)
"""
epsilon_HudsenMcCoubrey(ϵ::SingleOrPair,σ::PairParam)::PairParam
epsilon_HudsenMcCoubrey(ϵ::SingleOrPair)::PairParam
Combining rule for a single or pair parameter. returns a pair parameter with non diagonal entries equal to:
```
ϵᵢⱼ = √(ϵᵢϵⱼ)*(σᵢᵢ^3 * σⱼⱼ^3)/σᵢⱼ^6
```
If `σᵢⱼ` is not defined, the definition is reduced to a simple geometric mean:
```
ϵᵢⱼ = √(ϵᵢϵⱼ)
```
Ignores non-diagonal entries already set.
If a Single Parameter is passed as input, it will be converted to a Pair Parameter with `ϵᵢᵢ = ϵᵢ`.
"""
function epsilon_HudsenMcCoubrey(epsilon::SingleOrPair, sigma::PairParameter;k = nothing)
return pair_mix(mix_HudsenMcCoubrey,epsilon,sigma)
end
epsilon_HudsenMcCoubrey(epsilon) = epsilon_LorentzBerthelot(epsilon)
epsilon_HudsenMcCoubrey(epsilon,::Nothing) = epsilon_LorentzBerthelot(epsilon)
function epsilon_HudsenMcCoubrey!(epsilon::PairParameter, sigma::PairParameter)
return pair_mix!(mix_HudsenMcCoubrey,epsilon,sigma)
end
epsilon_HudsenMcCoubreysqrt(epsilon::PairParameter) = epsilon_LorentzBerthelot!(epsilon)
"""
epsilon_HudsenMcCoubreysqrt(ϵ::SingleOrPair,σ::PairParam)::PairParam
epsilon_HudsenMcCoubreysqrt(ϵ::SingleOrPair)::PairParam
Combining rule for a single or pair parameter. returns a pair parameter with non diagonal entries equal to:
```
ϵᵢⱼ = √(ϵᵢϵⱼ* σᵢᵢ^3 * σⱼⱼ^3)/σᵢⱼ^3
```
If `σᵢⱼ` is not defined, the definition is reduced to a simple geometric mean:
```
ϵᵢⱼ = √(ϵᵢϵⱼ)
```
Ignores non-diagonal entries already set.
If a Single Parameter is passed as input, it will be converted to a Pair Parameter with `ϵᵢᵢ = ϵᵢ`.
"""
function epsilon_HudsenMcCoubreysqrt(epsilon::SingleOrPair, sigma::PairParameter;k = nothing)
return pair_mix(mix_HudsenMcCoubreysqrt,epsilon,sigma)
end
epsilon_HudsenMcCoubreysqrt(epsilon) = epsilon_LorentzBerthelot(epsilon)
epsilon_HudsenMcCoubreysqrt(epsilon,::Nothing) = epsilon_LorentzBerthelot(epsilon)
function epsilon_HudsenMcCoubreysqrt!(epsilon::PairParameter, sigma::PairParameter)
return pair_mix!(mix_HudsenMcCoubreysqrt,epsilon,sigma)
end
epsilon_HudsenMcCoubrey(epsilon::PairParameter) = epsilon_LorentzBerthelot!(epsilon)
function lambda_LorentzBerthelot!(lambda::PairParameter,k = 3)
f(λi,λj,m) = mix_lambda(λi,λj,k)
return kij_mix!(f,lambda)
end
"""
lambda_LorentzBerthelot(λ::ClapeyronParam,k = 3)::PairParam
Combining rule for a single or pair parameter. returns a pair parameter with non diagonal entries equal to:
```
λᵢⱼ = k + √((λᵢᵢ - k)(λⱼⱼ - k))
```
with `k = 0` the definition is reduced to a simple geometric mean:
```
ϵᵢⱼ = √(ϵᵢϵⱼ)
```
Ignores non-diagonal entries already set.
If a Single Parameter is passed as input, it will be converted to a Pair Parameter with `λᵢᵢ = λᵢ`.
"""
function lambda_LorentzBerthelot(lambda::SingleOrPair,k = 3)
return return lambda_LorentzBerthelot!(PairParam(lambda),k)
end
"""
lambda_squarewell(λ::SingleOrPair,σ::PairParam)::PairParam
Combining rule for a single or pair parameter. returns a pair parameter with non diagonal entries equal to:
```
λᵢⱼ = (σᵢᵢλᵢᵢ + σⱼⱼλⱼⱼ)/(σᵢᵢ + σⱼⱼ)
```
Ignores non-diagonal entries already set.
If a Single Parameter is passed as input, it will be converted to a Pair Parameter with `λᵢᵢ = λᵢ`.
"""
function lambda_squarewell end
function lambda_squarewell(lambda::SingleOrPair, sigma::Union{PairParameter,SingleParameter})
return pair_mix(mix_lambda_squarewell,lambda,sigma)
end
function lambda_squarewell!(lambda::PairParameter, sigma::Union{PairParameter,SingleParameter})
return pair_mix!(mix_lambda_squarewell,lambda,sigma)
end
function mirror_pair!(param::PairParameter,f = identity)
mirror_pair!(param.values,param.ismissingvalues,f)
return param
end
"""
mirror_pair(param::PairParam,f = identity)
performs an operation `f` over the indices of `p` such as `p[j,i] = f(p[i,j])`. by default, `f = identity` (a symmetric matrix).
One key difference is that it sets the `ismissingvalues` field for each modified index to `false`
"""
mirror_pair(param::PairParameter,f = identity) = mirror_pair!(deepcopy(param),f)
export kij_mix, pair_mix
export sigma_LorentzBerthelot
export epsilon_LorentzBerthelot
export epsilon_HudsenMcCoubrey
export lambda_LorentzBerthelot
export lambda_squarewell
export group_sum,group_pairmean