-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from ypaul21/MixingRules
Mixing rules
- Loading branch information
Showing
25 changed files
with
435 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ Clapeyron.SiteParam | |
## Model Splitting | ||
```@docs | ||
Clapeyron.split_model | ||
Clapeyron.is_splittable | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#just a function, no struct | ||
function PR78(components::Vector{String}; idealmodel=BasicIdeal, | ||
mixing = vdW1fRule, | ||
userlocations=String[], | ||
ideal_userlocations=String[], | ||
alpha_userlocations = String[], | ||
mixing_userlocations = String[], | ||
verbose=false) | ||
|
||
return PR(components; | ||
idealmodel = idealmodel, | ||
alpha = PR78Alpha, | ||
mixing=mixing, | ||
ideal_userlocations = ideal_userlocations, | ||
alpha_userlocations = alpha_userlocations, | ||
mixing_userlocations = mixing_userlocations, | ||
verbose = verbose) | ||
end | ||
export PR78 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,19 @@ | ||
function cubic_ab(model::RK{<:Any,SoaveAlpha},T,z=SA[1.0],n=sum(z)) | ||
a = model.params.a.values | ||
b = model.params.b.values | ||
αmodel = model.alpha | ||
ω = αmodel.params.acentricfactor.values | ||
Tc = model.params.Tc.values | ||
_1 = one(T+n) | ||
invn = one(n)/n | ||
αx = @. (_1+(0.480+1.547*ω-0.176*ω^2)*(1-√(T/Tc))) * z * invn | ||
āᾱ =dot(αx, Symmetric(a), αx) | ||
b̄ = dot(z, Symmetric(b), z) * invn * invn | ||
return āᾱ ,b̄ | ||
end | ||
#just a function, no struct | ||
function SRK(components::Vector{String}; idealmodel=BasicIdeal, | ||
activity = nothing, | ||
mixing = vdW1fRule, | ||
userlocations=String[], | ||
ideal_userlocations=String[], | ||
alpha_userlocations = String[], | ||
activity_userlocations = String[], | ||
mixing_userlocations = String[], | ||
verbose=false) | ||
|
||
return RK(components; | ||
idealmodel = idealmodel, | ||
alpha = SoaveAlpha, | ||
activity=activity, | ||
mixing=mixing, | ||
ideal_userlocations = ideal_userlocations, | ||
alpha_userlocations = alpha_userlocations, | ||
activity_userlocations = activity_userlocations, | ||
mixing_userlocations = mixing_userlocations, | ||
verbose = verbose) | ||
end | ||
export SRK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
abstract type BMAlphaModel <: AlphaModel end | ||
|
||
struct BMAlphaParam <: EoSParam | ||
acentricfactor::SingleParam{Float64} | ||
end | ||
|
||
@newmodelsimple BMAlpha BMAlphaModel BMAlphaParam | ||
|
||
export BMAlpha | ||
function BMAlpha(components::Vector{String}; userlocations::Vector{String}=String[], verbose::Bool=false) | ||
params = getparams(components, ["properties/critical.csv"]; userlocations=userlocations, verbose=verbose) | ||
acentricfactor = SingleParam(params["w"],"acentric factor") | ||
packagedparams = BMAlphaParam(acentricfactor) | ||
model = BMAlpha(packagedparams, verbose=verbose) | ||
return model | ||
end | ||
|
||
function α_function(model::RKModel,V,T,z,alpha_model::BMAlphaModel) | ||
Tc = model.params.Tc.values | ||
Tr = @. T/Tc | ||
ω = alpha_model.params.acentricfactor.values | ||
m = @. 0.480+1.547*ω-0.176*ω^2 | ||
α = @. (Tr>1)*(exp((1-2/(2+m))*(1-Tr^(1+m/2))))^2+(Tr<=1)*(1+m*(1-√(Tr)))^2 | ||
return α | ||
end | ||
|
||
function α_function(model::PRModel,V,T,z,alpha_model::BMAlphaModel) | ||
Tc = model.params.Tc.values | ||
Tr = @. T/Tc | ||
ω = alpha_model.params.acentricfactor.values | ||
m = @. 0.37464+1.54226*ω-0.26992*ω^2 | ||
α = @. (Tr>1)*(exp((1-2/(2+m))*(1-Tr^(1+m/2))))^2+(Tr<=1)*(1+m*(1-√(Tr)))^2 | ||
return α | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
abstract type PR78AlphaModel <: AlphaModel end | ||
|
||
struct PR78AlphaParam <: EoSParam | ||
acentricfactor::SingleParam{Float64} | ||
end | ||
|
||
@newmodelsimple PR78Alpha PR78AlphaModel PR78AlphaParam | ||
|
||
export PR78Alpha | ||
function PR78Alpha(components::Vector{String}; userlocations::Vector{String}=String[], verbose::Bool=false) | ||
params = getparams(components, ["properties/critical.csv"]; userlocations=userlocations, verbose=verbose) | ||
acentricfactor = SingleParam(params["w"],"acentric factor") | ||
packagedparams = PR78AlphaParam(acentricfactor) | ||
model = PR78Alpha(packagedparams, verbose=verbose) | ||
return model | ||
end | ||
|
||
function α_function(model::CubicModel,V,T,z,alpha_model::PR78AlphaModel) | ||
Tc = model.params.Tc.values | ||
ω = alpha_model.params.acentricfactor.values | ||
m = @. (ω<=0.491)*(0.37464+1.54226*ω-0.26992*ω^2)+(ω>0.491)*(0.379642+1.487503*ω-0.164423*ω^2-0.016666*ω^3) | ||
α = @. (1+m*(1-√(T/Tc)))^2 | ||
return α | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
abstract type PRAlphaModel <: AlphaModel end | ||
|
||
struct PRAlphaParam <: EoSParam | ||
acentricfactor::SingleParam{Float64} | ||
end | ||
|
||
@newmodelsimple PRAlpha PRAlphaModel PRAlphaParam | ||
|
||
export PRAlpha | ||
function PRAlpha(components::Vector{String}; userlocations::Vector{String}=String[], verbose::Bool=false) | ||
params = getparams(components, ["properties/critical.csv"]; userlocations=userlocations, verbose=verbose) | ||
acentricfactor = SingleParam(params["w"],"acentric factor") | ||
packagedparams = PRAlphaParam(acentricfactor) | ||
model = PRAlpha(packagedparams, verbose=verbose) | ||
return model | ||
end | ||
|
||
function α_function(model::CubicModel,V,T,z,alpha_model::PRAlphaModel) | ||
Tc = model.params.Tc.values | ||
ω = alpha_model.params.acentricfactor.values | ||
α = @. (1+(0.37464+1.54226*ω-0.26992*ω^2)*(1-√(T/Tc)))^2 | ||
return α | ||
end |
Oops, something went wrong.