From 4d3fc760349645cf403857a8c5c0040a8e7d46f2 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Mon, 4 Apr 2022 03:12:19 -0400 Subject: [PATCH 01/17] start of QCPR --- database/cubic/QCPR/QCPR_critical.csv | 7 ++ database/cubic/QCPR/QCPR_like.csv | 7 ++ database/cubic/QCPR/QCPR_translation.csv | 7 ++ database/cubic/QCPR/QCPR_unlike.csv | 8 ++ database/cubic/Twu_QCPR.csv | 8 ++ .../multicomponent/LLE_point.jl | 24 ++++- src/models/cubic/PR/variants/PR78.jl | 3 +- src/models/cubic/PR/variants/QCPR.jl | 58 ++++++++++ src/models/cubic/PR/variants/VTPR.jl | 2 + src/models/cubic/mixing/QCPR.jl | 100 ++++++++++++++++++ .../cubic/translation/ConstantTranslation.jl | 47 ++++++++ 11 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 database/cubic/QCPR/QCPR_critical.csv create mode 100644 database/cubic/QCPR/QCPR_like.csv create mode 100644 database/cubic/QCPR/QCPR_translation.csv create mode 100644 database/cubic/QCPR/QCPR_unlike.csv create mode 100644 database/cubic/Twu_QCPR.csv create mode 100644 src/models/cubic/PR/variants/QCPR.jl create mode 100644 src/models/cubic/mixing/QCPR.jl create mode 100644 src/models/cubic/translation/ConstantTranslation.jl diff --git a/database/cubic/QCPR/QCPR_critical.csv b/database/cubic/QCPR/QCPR_critical.csv new file mode 100644 index 000000000..09f6f496d --- /dev/null +++ b/database/cubic/QCPR/QCPR_critical.csv @@ -0,0 +1,7 @@ +Clapeyron Database File,,,,,, +Critical QCPR Like Parameters,,,,,, +species,Mw,Tc,Pc +hydrogen,2.01588,33.19,12.964e5 +deuterium,4.0282035556,38.34,16.796e5 +helium,4.002602,5.1953,2.276e5 +neon,20.1797,44.492,26.79e5 \ No newline at end of file diff --git a/database/cubic/QCPR/QCPR_like.csv b/database/cubic/QCPR/QCPR_like.csv new file mode 100644 index 000000000..d377fc70c --- /dev/null +++ b/database/cubic/QCPR/QCPR_like.csv @@ -0,0 +1,7 @@ +Clapeyron Database File,,,,,, +QCPR Like Parameters,,,,,, +species,A,B +hydrogen,3.0696,12.682 +deuterium,1.6501,7.309 +helium,1.4912,3.2634 +neon,0.4673,2.4634 \ No newline at end of file diff --git a/database/cubic/QCPR/QCPR_translation.csv b/database/cubic/QCPR/QCPR_translation.csv new file mode 100644 index 000000000..887734e62 --- /dev/null +++ b/database/cubic/QCPR/QCPR_translation.csv @@ -0,0 +1,7 @@ +Clapeyron Database File,,,,, +Constant translation for QCPR Like Parameters,,,,, +species,c +hydrogen,-3.8139e-6 +helium,-3.1791e-6 +neon,-2.4665e-6 +deuterium,-3.8718e-6 \ No newline at end of file diff --git a/database/cubic/QCPR/QCPR_unlike.csv b/database/cubic/QCPR/QCPR_unlike.csv new file mode 100644 index 000000000..090b4f99c --- /dev/null +++ b/database/cubic/QCPR/QCPR_unlike.csv @@ -0,0 +1,8 @@ +Clapeyron Database File +QCPR unlike Parameters +species1,species2,k,l +helium,deuterium,0.45,0 +helium,hydrogen,0.17,-0.16 +neon,deuterium,0.18,0.0 +neon,hydrogen,0.18,0.0 +neon,helium,-0.17,0.0 diff --git a/database/cubic/Twu_QCPR.csv b/database/cubic/Twu_QCPR.csv new file mode 100644 index 000000000..45bc8914a --- /dev/null +++ b/database/cubic/Twu_QCPR.csv @@ -0,0 +1,8 @@ +Clapeyron Database File,,,,, +TwuAlpha for QCPR Like Parameters,,,,, +species,DIPPR Number,L,M,N,source +hydrogen,,156.21,-0.0062072,5.047, +helium,,0.48558,1.7173,0.30271 +neon,,0.40453,0.95861,0.8396 +deuterium,,55.007,-0.016981,3.1621 + diff --git a/src/methods/property_solvers/multicomponent/LLE_point.jl b/src/methods/property_solvers/multicomponent/LLE_point.jl index 69bdb1902..bbedec5ec 100644 --- a/src/methods/property_solvers/multicomponent/LLE_point.jl +++ b/src/methods/property_solvers/multicomponent/LLE_point.jl @@ -9,6 +9,7 @@ function x0_LLE_pressure(model::EoSModel,T,x) prepend!(xx,log10.((V0_l,V0_ll))) return xx[1:end-1] end + """ LLE_pressure(model::EoSModel, T, x; v0 = x0_LLE_pressure(model,T,x)) @@ -77,4 +78,25 @@ end function x0_LLE_temperature(model,p,x) return 1.5*sum(T_scales(model))/length(x) -end \ No newline at end of file +end + +function presents_LLE(model,p,T) + pure = split_model(model) + g_pure = gibbs_free_energy.(pure,p,T) + + function mixing_gibbs(x1) + z = FractionVector(x1) + log∑z = log(sum(z)) + g_mix = gibbs_free_energy(model,p,T,z) + for i in 1:length(z) + g_mix -= z[i]*(g_pure[i] + R̄*T*(log(z[i]) - log∑z)) + end + return g_mix + end + + f0(x1) = ForwardDiff.derivative(mixing_gibbs,x1) + prob = Roots.ZeroProblem(f0,(0.9)) + res = Roots.solve(prob) + return (res,mixing_gibbs(res)) + +end diff --git a/src/models/cubic/PR/variants/PR78.jl b/src/models/cubic/PR/variants/PR78.jl index 89e401d2f..93c33b1a8 100644 --- a/src/models/cubic/PR/variants/PR78.jl +++ b/src/models/cubic/PR/variants/PR78.jl @@ -8,11 +8,12 @@ ideal_userlocations=String[], alpha_userlocations = String[], mixing_userlocations = String[], + translation_userlocations = String[], verbose=false) Peng Robinson (1978) equation of state. it uses the following models: -- Translation Model: `PR78Alpha` +- Translation Model: `NoTranslation` - Alpha Model: `PR78Alpha` - Mixing Rule Model: `vdW1fRule` diff --git a/src/models/cubic/PR/variants/QCPR.jl b/src/models/cubic/PR/variants/QCPR.jl new file mode 100644 index 000000000..70652af1c --- /dev/null +++ b/src/models/cubic/PR/variants/QCPR.jl @@ -0,0 +1,58 @@ +""" + QCPR(components::Vector{String}; idealmodel=BasicIdeal, + userlocations=String[], + ideal_userlocations=String[], + alpha_userlocations = String[], + mixing_userlocations = String[], + activity_userlocations = String[], + translation_userlocations = String[], + verbose=false) + +Quantum-corrected Peng Robinson equation of state. it uses the following models: + +- Translation Model: `ConstantTranslation` +- Alpha Model: `TwuAlpha` +- Mixing Rule Model: `QCPRRule` + +## References + +1. Aasen, A., Hammer, M., Lasala, S., Jaubert, J.-N., & Wilhelmsen, Ø. (2020). Accurate quantum-corrected cubic equations of state for helium, neon, hydrogen, deuterium and their mixtures. Fluid Phase Equilibria, 524(112790), 112790. doi:10.1016/j.fluid.2020.112790 + +""" +function QCPR(components::Vector{String}; idealmodel=BasicIdeal, + userlocations=String[], + ideal_userlocations=String[], + alpha_userlocations = String[], + mixing_userlocations = String[], + activity_userlocations = String[], + translation_userlocations = String[], + verbose=false) + + crit = "cubic/QCPR/QCPR_critical.csv" + + twu_alpha = "cubic/QCPR/Twu_QCPR.csv" + const_translation = "cubic/QCPR/QCPR_translation.csv" + + userlocations = vcat(crit,unlike,userlocations) + alpha_userlocations = vcat(twu_alpha,alpha_userlocations) + + translation_userlocations = vcat(const_translation,translation_userlocations) + + model = PR(components; idealmodel=idealmodel, + alpha = TwuAlpha, + mixing = QCPRRule, + activity=nothing, + translation=ConstantTranslation, + userlocations=userlocations, + ideal_userlocations=ideal_userlocations, + alpha_userlocations = alpha_userlocations, + mixing_userlocations = mixing_userlocations, + activity_userlocations = activity_userlocations, + translation_userlocations = translation_userlocations, + verbose=verbose) + + push!(model.references,"10.1016/j.fluid.2020.112790") + return model +end + +export QCPR \ No newline at end of file diff --git a/src/models/cubic/PR/variants/VTPR.jl b/src/models/cubic/PR/variants/VTPR.jl index 7524f5c9b..537c52402 100644 --- a/src/models/cubic/PR/variants/VTPR.jl +++ b/src/models/cubic/PR/variants/VTPR.jl @@ -30,6 +30,7 @@ function VTPR(components::Vector{String}; idealmodel=BasicIdeal, ideal_userlocations=String[], alpha_userlocations = String[], mixing_userlocations = String[], + translation_userlocations = String[], verbose=false) return PR(components; @@ -42,6 +43,7 @@ function VTPR(components::Vector{String}; idealmodel=BasicIdeal, ideal_userlocations = ideal_userlocations, alpha_userlocations = alpha_userlocations, mixing_userlocations = mixing_userlocations, + translation_userlocations = translation_userlocations, verbose = verbose) end export VTPR \ No newline at end of file diff --git a/src/models/cubic/mixing/QCPR.jl b/src/models/cubic/mixing/QCPR.jl new file mode 100644 index 000000000..8d6d25bdc --- /dev/null +++ b/src/models/cubic/mixing/QCPR.jl @@ -0,0 +1,100 @@ +struct QCPRRuleParam <: EoSParam + A::SingleParam{Float64} + B::SingleParam{Float64} + l::PairParam{Float64} +end + +abstract type QCPRRuleModel <: QCPRRule end + +struct QCPRRule <: QCPRRuleModel + components::Array{String,1} + params::QCPRRuleParam + references::Array{String,1} +end + +@registermodel QCPRRule + +""" + QCPRRule <: MHV2RuleModel + + QCPRRule(components::Vector{String}; + activity = Wilson, + userlocations::Vector{String}=String[], + activity_userlocations::Vector{String}=String[], + verbose::Bool=false) + +## Input Parameters + +None + +## Input models + +- `activity`: Activity Model + +## Description + +Quantum-Corrected Mixing Rule: +``` +aᵢⱼ = √(aᵢaⱼ)(1 - kᵢⱼ) +bᵢⱼ = (1-lᵢⱼ)(bqᵢ + bqⱼ)/2 +bqᵢ = bᵢβᵢ(T) +βᵢ(T) = (1 + Aᵢ/(T + Bᵢ))^3 / (1 + Aᵢ/(Tcᵢ + Bᵢ))^3 +ā = ∑aᵢⱼxᵢxⱼ√(αᵢ(T)αⱼ(T)) +b̄ = ∑bᵢⱼxᵢxⱼ +c̄ = ∑cᵢxᵢ +``` + +## References +1. Aasen, A., Hammer, M., Lasala, S., Jaubert, J.-N., & Wilhelmsen, Ø. (2020). Accurate quantum-corrected cubic equations of state for helium, neon, hydrogen, deuterium and their mixtures. Fluid Phase Equilibria, 524(112790), 112790. doi:10.1016/j.fluid.2020.112790 + +""" +QCPRRule + + +function QCPRRule(components::Vector{String}; activity = nothing, userlocations::Vector{String}=String[],activity_userlocations::Vector{String}=String[], verbose::Bool=false) + params = getparams(components, ["cubic/QCPR/QCPR_like.csv","cubic/QCPR/QCPR_unlike.csv"]; userlocations=userlocations, verbose=verbose) + references = String["10.1016/j.fluid.2020.112790"] + pkgparams = QCPRRuleParam(params["A"],params["B"],params["l"]) + model = QCPRRule(components, params ,references) + return model +end + +function mixing_rule(model::PRModel,V,T,z,mixing_model::UMRRuleModel,α,a,b,c) + n = sum(z) + invn = (one(n)/n) + invn2 = invn^2 + A = mixing_model.params.A.values + B = mixing_model.params.B.values + l = mixing_model.params.l.values + Tc = model.params.Tc.values + ā = zero(T+first(z)) + b̄ = zero(first(z)) + for i in 1:length(z) + zi = z[i] + αi = α[i] + zi2 = zi^2 + Bi = B[i] + Ai = A[i] + βi = (1 + Ai/(T + Bi))^3 / (1 + Ai/(Tc[i] + Bi))^3 + bqi = βi*b[i,i] + b̄ += bqi*zi2 + ā += a[i,i]*αi*zi^2 + for j in 1:(i-1) + zij = zi*z[j] + Bj = B[j] + Aj = A[j] + βj = (1 + Aj/(T + Bj))^3 / (1 + Aj/(Tc[j] + Bj))^3 + bqj = βj*b[j,j] + ā += 2*a[i,j]*sqrt(αi*α[j])*zij + b̄ += zij*(bqi+bqj)*(1-l[i,j]) #2 * zij * 0.5(bi + bj) + end + end + ā *= invn2 + b̄ *= invn2 + c̄ = dot(z,c)*invn + #dot(z,Symmetric(a .* sqrt.(α*α')),z) * invn2 + return ā,b̄,c̄ +end + + + diff --git a/src/models/cubic/translation/ConstantTranslation.jl b/src/models/cubic/translation/ConstantTranslation.jl new file mode 100644 index 000000000..5c2363855 --- /dev/null +++ b/src/models/cubic/translation/ConstantTranslation.jl @@ -0,0 +1,47 @@ +abstract type ConstantTranslationModel <: TranslationModel end + +struct ConstantTranslationParam <: EoSParam + c::SingleParam{Float64} +end + +@newmodelsimple ConstantTranslation ConstantTranslationModel ConstantTranslationParam + +""" + + ConstantTranslation <: ConstantTranslationModel + + ConstantTranslation(components::Vector{String}; + userlocations::Vector{String}=String[], + verbose::Bool=false) + +## Input Parameters + +- `c`: Single Parameter (`Float64`) - Volume shift `[m³/mol]` + +## Description + +Constant Translation model for cubics: +``` +V = V₀ + mixing_rule(cᵢ) +``` +where `cᵢ` is constant. + +It does not have parameters by default, the volume shifts must be user-supplied. + +""" +ConstantTranslation + +export ConstantTranslation + +function ConstantTranslation(components::Vector{String}; userlocations::Vector{String}=String[], verbose::Bool=false) + params = getparams(components, String[]; userlocations=userlocations, verbose=verbose) + c = params["c"] + packagedparams = ConstantTranslationParam(c) + model = ConstantTranslation(packagedparams, verbose=verbose) + return model +end + +function translation(model::CubicModel,V,T,z,translation_model::ConstantTranslationModel) + return translation_model.params.c.values +end + From 642971c1f032b110efddbec289a0d2dabfec5a27 Mon Sep 17 00:00:00 2001 From: pw0908 Date: Mon, 4 Apr 2022 17:41:06 -0700 Subject: [PATCH 02/17] Some fixes to QCPR There are still some problems with: * The databases don't work just yet since, I believe, we assume the path is relative the the current wd * The current implementation does not replicate the results from the paper... --- database/cubic/QCPR/Twu_QCPR.csv | 8 ++++++++ database/properties/critical.csv | 2 +- src/Clapeyron.jl | 1 + src/models/cubic/PR/variants/QCPR.jl | 4 ++-- src/models/cubic/mixing/QCPR.jl | 6 +++--- src/models/cubic/mixing/mixing.jl | 3 ++- src/models/cubic/translation/translation.jl | 3 ++- 7 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 database/cubic/QCPR/Twu_QCPR.csv diff --git a/database/cubic/QCPR/Twu_QCPR.csv b/database/cubic/QCPR/Twu_QCPR.csv new file mode 100644 index 000000000..45bc8914a --- /dev/null +++ b/database/cubic/QCPR/Twu_QCPR.csv @@ -0,0 +1,8 @@ +Clapeyron Database File,,,,, +TwuAlpha for QCPR Like Parameters,,,,, +species,DIPPR Number,L,M,N,source +hydrogen,,156.21,-0.0062072,5.047, +helium,,0.48558,1.7173,0.30271 +neon,,0.40453,0.95861,0.8396 +deuterium,,55.007,-0.016981,3.1621 + diff --git a/database/properties/critical.csv b/database/properties/critical.csv index cb968779e..337f4dc06 100644 --- a/database/properties/critical.csv +++ b/database/properties/critical.csv @@ -208,7 +208,7 @@ Chlorobenzene,108907,632.35,4.53E+06,3.57E-04,0.251 Bromobenzene,108861,670.15,4.52E+06,3.79E-04,0.251 Air,132259100,132.45,3.79E+06,8.93E-05,0 Hydrogen,1333740,33.19,1.32E+06,6.43E-05,-0.215 -Helium-4,7440597,5.2,2.30E+05,5.78E-05,-0.388 +helium,7440597,5.2,2.30E+05,5.78E-05,-0.388 Neon,7440019,44.4,2.67E+06,4.25E-05,-0.038 Argon,7440371,150.86,4.90E+06,7.87E-05,0 Fluorine,7782414,144.12,5.17E+06,7.12E-05,0.053 diff --git a/src/Clapeyron.jl b/src/Clapeyron.jl index b86b4d9ed..3238062fe 100644 --- a/src/Clapeyron.jl +++ b/src/Clapeyron.jl @@ -136,6 +136,7 @@ include("models/cubic/RK/variants/PSRK.jl") include("models/cubic/PR/variants/PR78.jl") include("models/cubic/PR/variants/VTPR.jl") include("models/cubic/PR/variants/UMRPR.jl") +include("models/cubic/PR/variants/QCPR.jl") include("models/LatticeFluid/SanchezLacombe/SanchezLacombe.jl") diff --git a/src/models/cubic/PR/variants/QCPR.jl b/src/models/cubic/PR/variants/QCPR.jl index 70652af1c..565d81d0a 100644 --- a/src/models/cubic/PR/variants/QCPR.jl +++ b/src/models/cubic/PR/variants/QCPR.jl @@ -33,7 +33,7 @@ function QCPR(components::Vector{String}; idealmodel=BasicIdeal, twu_alpha = "cubic/QCPR/Twu_QCPR.csv" const_translation = "cubic/QCPR/QCPR_translation.csv" - userlocations = vcat(crit,unlike,userlocations) + userlocations = vcat(crit,userlocations) alpha_userlocations = vcat(twu_alpha,alpha_userlocations) translation_userlocations = vcat(const_translation,translation_userlocations) @@ -55,4 +55,4 @@ function QCPR(components::Vector{String}; idealmodel=BasicIdeal, return model end -export QCPR \ No newline at end of file +export QCPR diff --git a/src/models/cubic/mixing/QCPR.jl b/src/models/cubic/mixing/QCPR.jl index 8d6d25bdc..4201e75af 100644 --- a/src/models/cubic/mixing/QCPR.jl +++ b/src/models/cubic/mixing/QCPR.jl @@ -4,7 +4,7 @@ struct QCPRRuleParam <: EoSParam l::PairParam{Float64} end -abstract type QCPRRuleModel <: QCPRRule end +abstract type QCPRRuleModel <: MixingRule end struct QCPRRule <: QCPRRuleModel components::Array{String,1} @@ -55,11 +55,11 @@ function QCPRRule(components::Vector{String}; activity = nothing, userlocations: params = getparams(components, ["cubic/QCPR/QCPR_like.csv","cubic/QCPR/QCPR_unlike.csv"]; userlocations=userlocations, verbose=verbose) references = String["10.1016/j.fluid.2020.112790"] pkgparams = QCPRRuleParam(params["A"],params["B"],params["l"]) - model = QCPRRule(components, params ,references) + model = QCPRRule(components, pkgparams ,references) return model end -function mixing_rule(model::PRModel,V,T,z,mixing_model::UMRRuleModel,α,a,b,c) +function mixing_rule(model::PRModel,V,T,z,mixing_model::QCPRRuleModel,α,a,b,c) n = sum(z) invn = (one(n)/n) invn2 = invn^2 diff --git a/src/models/cubic/mixing/mixing.jl b/src/models/cubic/mixing/mixing.jl index cc5db7005..29c968800 100644 --- a/src/models/cubic/mixing/mixing.jl +++ b/src/models/cubic/mixing/mixing.jl @@ -41,4 +41,5 @@ include("LCVM.jl") include("WS.jl") include("PSRK.jl") include("VTPR.jl") -include("UMR.jl") \ No newline at end of file +include("UMR.jl") +include("QCPR.jl") \ No newline at end of file diff --git a/src/models/cubic/translation/translation.jl b/src/models/cubic/translation/translation.jl index 3f76a10a4..a2db655d7 100644 --- a/src/models/cubic/translation/translation.jl +++ b/src/models/cubic/translation/translation.jl @@ -33,4 +33,5 @@ end include("NoTranslation.jl") include("Rackett.jl") include("Peneloux.jl") -include("MT.jl") \ No newline at end of file +include("MT.jl") +include("ConstantTranslation.jl") \ No newline at end of file From d58d68742badefc07c7675f097e77e486c993059 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Tue, 5 Apr 2022 04:05:47 -0400 Subject: [PATCH 03/17] start of EPPR78 --- database/cubic/EPPR78/EPPR78_groups.csv | 29 ++ database/cubic/EPPR78/EPPR78_unlike.csv | 353 ++++++++++++++++++++++++ database/cubic/Twu_QCPR.csv | 8 - src/models/cubic/PR/variants/EPPR78.jl | 43 +++ 4 files changed, 425 insertions(+), 8 deletions(-) create mode 100644 database/cubic/EPPR78/EPPR78_groups.csv create mode 100644 database/cubic/EPPR78/EPPR78_unlike.csv delete mode 100644 database/cubic/Twu_QCPR.csv create mode 100644 src/models/cubic/PR/variants/EPPR78.jl diff --git a/database/cubic/EPPR78/EPPR78_groups.csv b/database/cubic/EPPR78/EPPR78_groups.csv new file mode 100644 index 000000000..215fc7474 --- /dev/null +++ b/database/cubic/EPPR78/EPPR78_groups.csv @@ -0,0 +1,29 @@ +Clapeyron Database File, +EPPR78 Groups, +species,groups +ethane,"[""CH3"" => 2]" +propane,"[""CH3"" => 2, ""CH2"" => 1]" +butane,"[""CH3"" => 2, ""CH2"" => 2]" +isobutane,"[""CH3"" => 3, ""CH"" => 1]" +pentane,"[""CH3"" => 2, ""CH2"" => 3]" +hexane,"[""CH3"" => 2, ""CH2"" => 4]" +heptane,"[""CH3"" => 2, ""CH2"" => 5]" +octane,"[""CH3"" => 2, ""CH2"" => 6]" +nonane,"[""CH3"" => 2, ""CH2"" => 7]" +decane,"[""CH3"" => 2, ""CH2"" => 8]" +undecane,"[""CH3"" => 2, ""CH2"" => 9]" +pentadecane,"[""CH3"" => 2, ""CH2"" => 13]" +eicosane,"[""CH3"" => 2, ""CH2"" => 18]" +pentacosane,"[""CH3"" => 2, ""CH2"" => 23]" +triacontane,"[""CH3"" => 2, ""CH2"" => 28]" +methane,"[""CH4""=>1]" +carbon dioxide,"[""CO2""=>1]" +water,"[""H2O""=>1]" +hydrogen,"[""H2""=>1]" +helium,"[""He""=>1]" +argon,"[""Ar""=>1]" +oxygen,"[""O2""=>1]" +nitrogen,"[""N2""=>1]" +carbon monoxide,"[""CO""=>1]" +sulfur dioxide,"[""SO2""=>1]" +hydrogen sulfide,"[""H2S""=>1]" diff --git a/database/cubic/EPPR78/EPPR78_unlike.csv b/database/cubic/EPPR78/EPPR78_unlike.csv new file mode 100644 index 000000000..8f4722be9 --- /dev/null +++ b/database/cubic/EPPR78/EPPR78_unlike.csv @@ -0,0 +1,353 @@ +Clapeyron Database File +E-PPR78 unlike Parameters +species1,species2,A,B +CH3,CH2,65.54,65.54 +CH3,CH,214.9,214.9 +CH3,C,431.6,431.6 +CH3,CH4,28.48,28.48 +CH3,C2H6,3.775,3.775 +CH3,CH aro,98.83,98.83 +CH3,C aro,103.6,103.6 +CH3,C fused aromatic rings,624.9,624.9 +CH3,CH2 cyclic,43.58,43.58 +CH3,CH cyclic~|~C cyclic,293.4,293.4 +CH3,CO2,144.8,144.8 +CH3,N2,38.09,38.09 +CH3,H2S,159.6,159.6 +CH3,SH,789.6,789.6 +CH3,H2O,3557.0,3557.0 +CH3,C2H4,7.892,7.892 +CH3,CH2 alkenic~|~CH alkenic,48.73,48.73 +CH3,C alkenic,102.6,102.6 +CH3,CH cycloalkenic~|~C cycloalkenic,47.01,47.01 +CH3,H2,174.0,174.0 +CH3,C2F6,119.1,119.1 +CH3,CF3,123.2,123.2 +CH3,CF2,58.33,58.33 +CH3,CF2 double bond~|~CF double bond,-12.29,-12.29 +CH3,C2H4F2,128.3,128.3 +CH3,C2H2F4,158.5,158.5 +CH3,CO,91.24,91.24 +CH3,He,416.3,416.3 +CH3,Ar,11.27,11.27 +CH3,SO2,322.2,322.2 +CH3,O2,86.1,86.1 +CH3,C2H2,-6.86,-6.86 +CH3,HC=-C-,306.1,306.1 +CH3,-C=-C-,72.06,72.06 +CH2,CH,39.05,39.05 +CH2,C,134.5,134.5 +CH2,CH4,37.75,37.75 +CH2,C2H6,29.85,29.85 +CH2,CH aro,25.05,25.05 +CH2,C aro,5.147,5.147 +CH2,C fused aromatic rings,-17.84,-17.84 +CH2,CH2 cyclic,8.579,8.579 +CH2,CH cyclic~|~C cyclic,63.48,63.48 +CH2,CO2,141.4,141.4 +CH2,N2,83.73,83.73 +CH2,H2S,136.6,136.6 +CH2,SH,439.9,439.9 +CH2,H2O,4324.0,4324.0 +CH2,C2H4,59.71,59.71 +CH2,CH2 alkenic~|~CH alkenic,9.608,9.608 +CH2,C alkenic,64.85,64.85 +CH2,CH cycloalkenic~|~C cycloalkenic,34.31,34.31 +CH2,H2,155.4,155.4 +CH2,C2F6,105.0,105.0 +CH2,CF3,195.6,195.6 +CH2,CF2,58.33,58.33 +CH2,C2H4F2,107.1,107.1 +CH2,C2H2F4,86.47,86.47 +CH2,CO,44.0,44.0 +CH2,He,520.52,520.52 +CH2,Ar,113.6,113.6 +CH2,SO2,55.9,55.9 +CH2,O2,107.4,107.4 +CH2,C2H2,421.0,421.0 +CH2,HC=-C-,303.3,303.3 +CH2,-C=-C-,488.0,488.0 +CH,C,-86.13,-86.13 +CH,CH4,131.4,131.4 +CH,C2H6,156.1,156.1 +CH,CH aro,56.62,56.62 +CH,C aro,48.73,48.73 +CH,CH2 cyclic,73.09,73.09 +CH,CH cyclic~|~C cyclic,-120.8,-120.8 +CH,CO2,191.8,191.8 +CH,N2,383.6,383.6 +CH,H2S,192.5,192.5 +CH,SH,374.0,374.0 +CH,H2O,971.4,971.4 +CH,C2H4,147.9,147.9 +CH,CH2 alkenic~|~CH alkenic,84.76,84.76 +CH,C alkenic,91.62,91.62 +CH,CH cycloalkenic~|~C cycloalkenic,0.52,0.52 +CH,H2,326.0,326.0 +CH,CF3,531.5,531.5 +CH,CF2,-122.8,-122.8 +CH,C2H4F2,143.8,143.8 +CH,C2H2F4,121.5,121.5 +CH,He,728.1,728.1 +CH,Ar,185.8,185.8 +CH,SO2,-70.0,-70.0 +CH,HC=-C-,206.9,206.9 +CH,-C=-C-,4.46,4.46 +C,CH4,309.5,309.5 +C,C2H6,388.1,388.1 +C,CH aro,170.5,170.5 +C,C aro,128.3,128.3 +C,CH2 cyclic,208.6,208.6 +C,CH cyclic~|~C cyclic,25.05,25.05 +C,CO2,377.5,377.5 +C,N2,341.8,341.8 +C,H2S,330.8,330.8 +C,SH,685.9,685.9 +C,C2H4,366.8,366.8 +C,CH2 alkenic~|~CH alkenic,181.2,181.2 +C,H2,548.3,548.3 +C,CF3,413.1,413.1 +C,CF2,479.0,479.0 +C,Ar,899.0,899.0 +CH4,C2H6,9.951,9.951 +CH4,CH aro,67.26,67.26 +CH4,C aro,106.7,106.7 +CH4,C fused aromatic rings,249.1,249.1 +CH4,CH2 cyclic,33.97,33.97 +CH4,CH cyclic~|~C cyclic,188.0,188.0 +CH4,CO2,136.6,136.6 +CH4,N2,30.88,30.88 +CH4,H2S,190.1,190.1 +CH4,SH,701.7,701.7 +CH4,H2O,2277.1,2277.1 +CH4,C2H4,19.22,19.22 +CH4,CH2 alkenic~|~CH alkenic,48.73,48.73 +CH4,H2,156.1,156.1 +CH4,CO,14.43,14.43 +CH4,He,394.5,394.5 +CH4,Ar,15.97,15.97 +CH4,SO2,205.9,205.9 +CH4,COS,44.61,44.61 +CH4,NH3,436.1,436.1 +CH4,N2O,74.81,74.81 +C2H6,CH aro,41.18,41.18 +C2H6,C aro,67.94,67.94 +C2H6,CH2 cyclic,12.7,12.7 +C2H6,CH cyclic~|~C cyclic,118.0,118.0 +C2H6,CO2,136.2,136.2 +C2H6,N2,61.59,61.59 +C2H6,H2S,157.2,157.2 +C2H6,H2O,2333.0,2333.0 +C2H6,C2H4,7.549,7.549 +C2H6,CH2 alkenic~|~CH alkenic,26.77,26.77 +C2H6,H2,137.6,137.6 +C2H6,C2F6,96.08,96.08 +C2H6,CF3,87.16,87.16 +C2H6,CF2,79.27,79.27 +C2H6,CF2 double bond~|~CF double bond,95.55,95.55 +C2H6,C2H2F4,72.4,72.4 +C2H6,CO,15.42,15.42 +C2H6,He,581.3,581.3 +C2H6,Ar,43.81,43.81 +C2H6,C2H2,137.9,137.9 +CH aro,C aro,-16.47,-16.47 +CH aro,C fused aromatic rings,52.5,52.5 +CH aro,CH2 cyclic,28.82,28.82 +CH aro,CH cyclic~|~C cyclic,129.0,129.0 +CH aro,CO2,98.48,98.48 +CH aro,N2,185.3,185.3 +CH aro,H2S,21.28,21.28 +CH aro,SH,277.6,277.6 +CH aro,H2O,2268.0,2268.0 +CH aro,C2H4,25.74,25.74 +CH aro,CH2 alkenic~|~CH alkenic,9.951,9.951 +CH aro,C alkenic,-16.47,-16.47 +CH aro,CH cycloalkenic~|~C cycloalkenic,3.375,3.375 +CH aro,H2,288.9,288.9 +CH aro,CF3,680.1,680.1 +CH aro,CF2,-31.57,-31.57 +CH aro,CF2 double bond~|~CF double bond,-274.3,-274.3 +CH aro,CO,153.4,153.4 +CH aro,He,753.6,753.6 +CH aro,Ar,195.6,195.6 +CH aro,SO2,37.1,37.1 +CH aro,O2,233.4,233.4 +CH aro,C2H2,29.17,29.17 +CH aro,HC=-C-,96.08,96.08 +CH aro,-C=-C-,403.9,403.9 +C aro,C fused aromatic rings,-328.0,-328.0 +C aro,CH2 cyclic,37.4,37.4 +C aro,CH cyclic~|~C cyclic,-99.17,-99.17 +C aro,CO2,154.4,154.4 +C aro,N2,343.8,343.8 +C aro,H2S,9.608,9.608 +C aro,SH,1002.0,1002.0 +C aro,H2O,543.5,543.5 +C aro,C2H4,97.8,97.8 +C aro,CH2 alkenic~|~CH alkenic,-48.38,-48.38 +C aro,C alkenic,343.1,343.1 +C aro,CH cycloalkenic~|~C cycloalkenic,242.9,242.9 +C aro,H2,400.1,400.1 +C aro,CF3,733.0,733.0 +C aro,CF2,-8.922,-8.922 +C aro,CF2 double bond~|~CF double bond,78.62,78.62 +C fused aromatic rings,CH2 cyclic,140.7,140.7 +C fused aromatic rings,CH cyclic~|~C cyclic,-99.17,-99.17 +C fused aromatic rings,CO2,331.1,331.1 +C fused aromatic rings,N2,702.4,702.4 +C fused aromatic rings,H2S,9.608,9.608 +C fused aromatic rings,SH,1002.0,1002.0 +C fused aromatic rings,H2O,1340.0,1340.0 +C fused aromatic rings,C2H4,209.7,209.7 +C fused aromatic rings,CH2 alkenic~|~CH alkenic,669.8,669.8 +C fused aromatic rings,H2,602.9,602.9 +C fused aromatic rings,CO,197.0,197.0 +C fused aromatic rings,He,753.6,753.6 +CH2 cyclic,CH cyclic~|~C cyclic,139.0,139.0 +CH2 cyclic,CO2,144.1,144.1 +CH2 cyclic,N2,179.5,179.5 +CH2 cyclic,H2S,117.4,117.4 +CH2 cyclic,SH,493.1,493.1 +CH2 cyclic,H2O,4211.0,4211.0 +CH2 cyclic,C2H4,35.34,35.34 +CH2 cyclic,CH2 alkenic~|~CH alkenic,-15.44,-15.44 +CH2 cyclic,C alkenic,159.6,159.6 +CH2 cyclic,CH cycloalkenic~|~C cycloalkenic,31.91,31.91 +CH2 cyclic,H2,236.1,236.1 +CH2 cyclic,CF3,216.2,216.2 +CH2 cyclic,CF2,42.55,42.55 +CH2 cyclic,CO,113.1,113.1 +CH2 cyclic,Ar,1269.0,1269.0 +CH2 cyclic,O2,181.2,181.2 +CH2 cyclic,NO,-27.5,-27.5 +CH2 cyclic,HC=-C-,496.2,496.2 +CH2 cyclic,-C=-C-,845.9,845.9 +CH cyclic~|~C cyclic,CO2,216.2,216.2 +CH cyclic~|~C cyclic,N2,331.5,331.5 +CH cyclic~|~C cyclic,H2S,71.37,71.37 +CH cyclic~|~C cyclic,SH,463.2,463.2 +CH cyclic~|~C cyclic,H2O,244.0,244.0 +CH cyclic~|~C cyclic,C2H4,297.2,297.2 +CH cyclic~|~C cyclic,CH2 alkenic~|~CH alkenic,260.1,260.1 +CH cyclic~|~C cyclic,CH cycloalkenic~|~C cycloalkenic,151.3,151.3 +CH cyclic~|~C cyclic,H2,-51.82,-51.82 +CH cyclic~|~C cyclic,O2,102.3,102.3 +CH cyclic~|~C cyclic,HC=-C-,863.7,863.7 +CO2,N2,113.9,113.9 +CO2,H2S,135.2,135.2 +CO2,SH,484.15,484.15 +CO2,H2O,559.3,559.3 +CO2,C2H4,73.09,73.09 +CO2,CH2 alkenic~|~CH alkenic,60.74,60.74 +CO2,C alkenic,74.81,74.81 +CO2,CH cycloalkenic~|~C cycloalkenic,87.85,87.85 +CO2,H2,261.1,261.1 +CO2,C2F6,126.6,126.6 +CO2,CF3,156.5,156.5 +CO2,CF2,125.2,125.2 +CO2,CF2 double bond~|~CF double bond,36.25,36.25 +CO2,C2H4F2,48.73,48.73 +CO2,C2H2F4,29.51,29.51 +CO2,CO,87.85,87.85 +CO2,He,685.9,685.9 +CO2,Ar,177.8,177.8 +CO2,SO2,54.9,54.9 +CO2,O2,154.4,154.4 +CO2,NO,5.1,5.1 +CO2,COS,83.04,83.04 +CO2,NO2~|~N2O4,124.9,124.9 +CO2,N2O,3.77,3.77 +CO2,HC=-C-,60.05,60.05 +N2,H2S,319.5,319.5 +N2,SH,1042.0,1042.0 +N2,H2O,2574.0,2574.0 +N2,C2H4,45.3,45.3 +N2,CH2 alkenic~|~CH alkenic,59.71,59.71 +N2,C alkenic,541.5,541.5 +N2,H2,65.2,65.2 +N2,CO,23.33,23.33 +N2,He,204.7,204.7 +N2,Ar,6.488,6.488 +N2,SO2,282.4,282.4 +N2,O2,2.4,2.4 +N2,NO,258.7,258.7 +N2,NH3,585.8,585.8 +N2,NO2~|~N2O4,263.5,263.5 +N2,N2O,101.6,101.6 +H2S,SH,-157.8,-157.8 +H2S,H2O,603.9,603.9 +H2S,H2,145.8,145.8 +H2S,CO,278.6,278.6 +H2S,COS,101.9,101.9 +SH,H2O,30.88,30.88 +H2O,C2H4,1650.0,1650.0 +H2O,CH2 alkenic~|~CH alkenic,2243.0,2243.0 +H2O,H2,830.8,830.8 +H2O,CO,715.1,715.1 +H2O,Ar,1197.0,1197.0 +H2O,SO2,374.4,374.4 +H2O,O2,1376.0,1376.0 +H2O,NH3,-550.1,-550.1 +H2O,N2O,568.9,568.9 +H2O,C2H2,436.8,436.8 +H2O,HC=-C-,-2395.5,-2395.5 +C2H4,CH2 alkenic~|~CH alkenic,14.76,14.76 +C2H4,C alkenic,-518.2,-518.2 +C2H4,CH cycloalkenic~|~C cycloalkenic,-98.83,-98.83 +C2H4,H2,151.3,151.3 +C2H4,CF3,453.0,453.0 +C2H4,CF2 double bond~|~CF double bond,-132.7,-132.7 +C2H4,CO,84.55,84.55 +C2H4,He,569.6,569.6 +C2H4,SO2,26.8,26.8 +CH2 alkenic~|~CH alkenic,C alkenic,24.71,24.71 +CH2 alkenic~|~CH alkenic,CH cycloalkenic~|~C cycloalkenic,14.07,14.07 +CH2 alkenic~|~CH alkenic,H2,175.7,175.7 +CH2 alkenic~|~CH alkenic,C2F6,124.9,124.9 +CH2 alkenic~|~CH alkenic,CF3,155.4,155.4 +CH2 alkenic~|~CH alkenic,CF2,155.4,155.4 +CH2 alkenic~|~CH alkenic,CF2 double bond~|~CF double bond,88.21,88.21 +CH2 alkenic~|~CH alkenic,C2H4F2,76.86,76.86 +CH2 alkenic~|~CH alkenic,C2H2F4,64.51,64.51 +CH2 alkenic~|~CH alkenic,He,644.3,644.3 +CH2 alkenic~|~CH alkenic,Ar,203.0,203.0 +CH2 alkenic~|~CH alkenic,C2H2,165.4,165.4 +CH2 alkenic~|~CH alkenic,HC=-C-,134.5,134.5 +CH2 alkenic~|~CH alkenic,-C=-C-,255.6,255.6 +C alkenic,CH cycloalkenic~|~C cycloalkenic,23.68,23.68 +C alkenic,H2,621.4,621.4 +C alkenic,SO2,-141.7,-141.7 +C alkenic,HC=-C-,212.8,212.8 +C alkenic,-C=-C-,-874.3,-874.3 +CH cycloalkenic~|~C cycloalkenic,H2,460.8,460.8 +CH cycloalkenic~|~C cycloalkenic,CF3,1232.0,1232.0 +H2,CO,75.84,75.84 +H2,He,138.7,138.7 +H2,Ar,128.2,128.2 +H2,NH3,701.7,701.7 +C2F6,CF3,-14.47,-14.47 +C2F6,CF2 double bond~|~CF double bond,55.9,55.9 +C2F6,C2H2F4,60.74,60.74 +CF3,CF2,0.0,0.0 +CF3,CF2 double bond~|~CF double bond,17.55,17.55 +CF3,C2H4F2,113.2,113.2 +CF3,C2H2F4,28.14,28.14 +CF2,C2H4F2,120.1,120.1 +CF2,C2H2F4,229.9,229.9 +C2H4F2,C2H2F4,-4.118,-4.118 +C2H4F2,C2H2,-58.68,-58.68 +CO,He,260.1,260.1 +CO,Ar,4.042,4.042 +CO,NO,309.2,309.2 +He,Ar,243.1,243.1 +Ar,SO2,299.9,299.9 +Ar,O2,4.8,4.8 +Ar,NO,110.8,110.8 +Ar,NH3,630.0,630.0 +Ar,NO2~|~N2O4,278.6,278.6 +SO2,O2,340.0,340.0 +SO2,NO,172.3,172.3 +O2,NO2~|~N2O4,271.1,271.1 +O2,N2O,120.1,120.1 +C2H2,HC=-C-,122.5,122.5 +HC=-C-,-C=-C-,-497.6,-497.6 \ No newline at end of file diff --git a/database/cubic/Twu_QCPR.csv b/database/cubic/Twu_QCPR.csv deleted file mode 100644 index 45bc8914a..000000000 --- a/database/cubic/Twu_QCPR.csv +++ /dev/null @@ -1,8 +0,0 @@ -Clapeyron Database File,,,,, -TwuAlpha for QCPR Like Parameters,,,,, -species,DIPPR Number,L,M,N,source -hydrogen,,156.21,-0.0062072,5.047, -helium,,0.48558,1.7173,0.30271 -neon,,0.40453,0.95861,0.8396 -deuterium,,55.007,-0.016981,3.1621 - diff --git a/src/models/cubic/PR/variants/EPPR78.jl b/src/models/cubic/PR/variants/EPPR78.jl new file mode 100644 index 000000000..3b7a699aa --- /dev/null +++ b/src/models/cubic/PR/variants/EPPR78.jl @@ -0,0 +1,43 @@ +#= +groups: +CH3 +CH2 +CH +C +CH4 +C2H6 +CH aro +C aro +C fused aromatic rings +CH2 cyclic +CH cyclic~|~C cyclic +CO2 +N2 +H2S +SH +H2O +C2H4 +CH2 alkenic~|~CH alkenic +C alkenic +CH cycloalkenic~|~C cycloalkenic +H2 +C2F6 +CF3 +CF2 +CF2 double bond~|~CF double bond +C2H4F2 +C2H2F4 +CO +He +Ar +SO2 +O2 +NO +COS +NH3 +NO2~|~N2O4 +N2O +C2H2 +HC=-C- +-C=-C- +=# \ No newline at end of file From 40dc5cc2f7b50443502d20859a10a4dbc9d5a610 Mon Sep 17 00:00:00 2001 From: pw0908 Date: Wed, 6 Apr 2022 13:18:51 -0700 Subject: [PATCH 04/17] Implement QCPR Can now replicate both binary phase diagrams and pure diagrams for QCPR. Implementation is not finalised since it's quite messy and had to modify cubic equation.jl --- database/cubic/QCPR/QCPR_critical.csv | 2 +- database/cubic/QCPR/QCPR_like.csv | 2 +- database/cubic/QCPR/QCPR_translation.csv | 2 +- database/cubic/QCPR/Twu_QCPR.csv | 2 +- src/models/cubic/PR/variants/QCPR.jl | 49 ++++++++++++------------ src/models/cubic/equations.jl | 14 +++---- src/models/cubic/mixing/QCPR.jl | 2 +- test/test_models.jl | 5 +++ 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/database/cubic/QCPR/QCPR_critical.csv b/database/cubic/QCPR/QCPR_critical.csv index 09f6f496d..affa54609 100644 --- a/database/cubic/QCPR/QCPR_critical.csv +++ b/database/cubic/QCPR/QCPR_critical.csv @@ -1,6 +1,6 @@ Clapeyron Database File,,,,,, Critical QCPR Like Parameters,,,,,, -species,Mw,Tc,Pc +species,Mw,Tc,pc hydrogen,2.01588,33.19,12.964e5 deuterium,4.0282035556,38.34,16.796e5 helium,4.002602,5.1953,2.276e5 diff --git a/database/cubic/QCPR/QCPR_like.csv b/database/cubic/QCPR/QCPR_like.csv index d377fc70c..49ecf3bcb 100644 --- a/database/cubic/QCPR/QCPR_like.csv +++ b/database/cubic/QCPR/QCPR_like.csv @@ -4,4 +4,4 @@ species,A,B hydrogen,3.0696,12.682 deuterium,1.6501,7.309 helium,1.4912,3.2634 -neon,0.4673,2.4634 \ No newline at end of file +neon,0.22069,-0.65243 \ No newline at end of file diff --git a/database/cubic/QCPR/QCPR_translation.csv b/database/cubic/QCPR/QCPR_translation.csv index 887734e62..5ce73198d 100644 --- a/database/cubic/QCPR/QCPR_translation.csv +++ b/database/cubic/QCPR/QCPR_translation.csv @@ -3,5 +3,5 @@ Constant translation for QCPR Like Parameters,,,,, species,c hydrogen,-3.8139e-6 helium,-3.1791e-6 -neon,-2.4665e-6 +neon,-2.5676e-6 deuterium,-3.8718e-6 \ No newline at end of file diff --git a/database/cubic/QCPR/Twu_QCPR.csv b/database/cubic/QCPR/Twu_QCPR.csv index 45bc8914a..870243aac 100644 --- a/database/cubic/QCPR/Twu_QCPR.csv +++ b/database/cubic/QCPR/Twu_QCPR.csv @@ -3,6 +3,6 @@ TwuAlpha for QCPR Like Parameters,,,,, species,DIPPR Number,L,M,N,source hydrogen,,156.21,-0.0062072,5.047, helium,,0.48558,1.7173,0.30271 -neon,,0.40453,0.95861,0.8396 +neon,,0.3981,0.96535,0.82696 deuterium,,55.007,-0.016981,3.1621 diff --git a/src/models/cubic/PR/variants/QCPR.jl b/src/models/cubic/PR/variants/QCPR.jl index 565d81d0a..d42b31629 100644 --- a/src/models/cubic/PR/variants/QCPR.jl +++ b/src/models/cubic/PR/variants/QCPR.jl @@ -28,30 +28,31 @@ function QCPR(components::Vector{String}; idealmodel=BasicIdeal, translation_userlocations = String[], verbose=false) - crit = "cubic/QCPR/QCPR_critical.csv" - - twu_alpha = "cubic/QCPR/Twu_QCPR.csv" - const_translation = "cubic/QCPR/QCPR_translation.csv" - - userlocations = vcat(crit,userlocations) - alpha_userlocations = vcat(twu_alpha,alpha_userlocations) - - translation_userlocations = vcat(const_translation,translation_userlocations) - - model = PR(components; idealmodel=idealmodel, - alpha = TwuAlpha, - mixing = QCPRRule, - activity=nothing, - translation=ConstantTranslation, - userlocations=userlocations, - ideal_userlocations=ideal_userlocations, - alpha_userlocations = alpha_userlocations, - mixing_userlocations = mixing_userlocations, - activity_userlocations = activity_userlocations, - translation_userlocations = translation_userlocations, - verbose=verbose) - - push!(model.references,"10.1016/j.fluid.2020.112790") + userlocations = vcat(alpha_userlocations,translation_userlocations,userlocations) + + params = getparams(components, ["cubic/QCPR/QCPR_critical.csv", "cubic/QCPR/QCPR_unlike.csv","cubic/QCPR/Twu_QCPR.csv","cubic/QCPR/QCPR_translation.csv"]; userlocations=userlocations, verbose=verbose) + k = params["k"] + pc = params["pc"] + Mw = params["Mw"] + Tc = params["Tc"] + init_mixing = init_model(QCPRRule,components,nothing,mixing_userlocations,activity_userlocations,verbose) + a,b = ab_premixing(PR,init_mixing,Tc,pc,k) + init_idealmodel = init_model(idealmodel,components,ideal_userlocations,verbose) + + M = params["M"] + N = params["N"] + L = params["L"] + packagedparams = TwuAlphaParam(M,N,L) + init_alpha = TwuAlpha(packagedparams, verbose=verbose) + + c = params["c"] + packagedparams = ConstantTranslationParam(c) + init_translation = ConstantTranslation(packagedparams, verbose=verbose) + + icomponents = 1:length(components) + packagedparams = PRParam(a,b,Tc,pc,Mw) + references = String["10.1021/I160057A011"] + model = PR(components,icomponents,init_alpha,init_mixing,init_translation,packagedparams,init_idealmodel,references) return model end diff --git a/src/models/cubic/equations.jl b/src/models/cubic/equations.jl index fcc0f287c..25c34e9f2 100644 --- a/src/models/cubic/equations.jl +++ b/src/models/cubic/equations.jl @@ -29,13 +29,13 @@ function cubic_ab(model::ABCubicModel,V,T,z=SA[1.0],n=sum(z)) T = T*float(one(T)) α = @f(α_function,model.alpha) c = @f(translation,model.translation) - if length(z)>1 - ā,b̄,c̄ = @f(mixing_rule,model.mixing,α,a,b,c) - else - ā = a[1,1]*α[1] - b̄ = b[1,1] - c̄ = c[1,1] - end + # if length(z)>1 + ā,b̄,c̄ = @f(mixing_rule,model.mixing,α,a,b,c) + # else + # ā = a[1,1]*α[1] + # b̄ = b[1,1] + # c̄ = c[1,1] + # end return ā ,b̄, c̄ end diff --git a/src/models/cubic/mixing/QCPR.jl b/src/models/cubic/mixing/QCPR.jl index 4201e75af..bb9338dd2 100644 --- a/src/models/cubic/mixing/QCPR.jl +++ b/src/models/cubic/mixing/QCPR.jl @@ -78,7 +78,7 @@ function mixing_rule(model::PRModel,V,T,z,mixing_model::QCPRRuleModel,α,a,b,c) βi = (1 + Ai/(T + Bi))^3 / (1 + Ai/(Tc[i] + Bi))^3 bqi = βi*b[i,i] b̄ += bqi*zi2 - ā += a[i,i]*αi*zi^2 + ā += a[i,i]*αi*zi2 for j in 1:(i-1) zij = zi*z[j] Bj = B[j] diff --git a/test/test_models.jl b/test/test_models.jl index 9d72efdcb..ef9f45452 100644 --- a/test/test_models.jl +++ b/test/test_models.jl @@ -212,6 +212,11 @@ end @test Clapeyron.a_res(system, V, T, z) ≈ -1.1447318247939071 rtol = 1e-6 end + @testset "QCPR" begin + system = QCPR(["neon","helium"]) + @test Clapeyron.a_res(system, V, 25, z) ≈ -0.04727878068343511 rtol = 1e-6 + end + @testset "PR w/ BMAlpha" begin system = PR(["ethane","undecane"];alpha = BMAlpha) @test Clapeyron.a_res(system, V, T, z) ≈ -1.244507550417118 rtol = 1e-6 From 4607539c5b722383c191b02a585a2afc3489d341 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Wed, 6 Apr 2022 17:42:39 -0400 Subject: [PATCH 05/17] mockup of EPPR78 --- src/models/cubic/PR/variants/EPPR78.jl | 52 ++++++++++++++++- src/models/cubic/mixing/PPR78.jl | 79 ++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/models/cubic/mixing/PPR78.jl diff --git a/src/models/cubic/PR/variants/EPPR78.jl b/src/models/cubic/PR/variants/EPPR78.jl index 3b7a699aa..6a4dfb321 100644 --- a/src/models/cubic/PR/variants/EPPR78.jl +++ b/src/models/cubic/PR/variants/EPPR78.jl @@ -40,4 +40,54 @@ N2O C2H2 HC=-C- -C=-C- -=# \ No newline at end of file +=# + +""" + EPPR78(components::Vector{String}; idealmodel=BasicIdeal, + alpha = PR78Alpha, + mixing = vdW1fRule, + activity = nothing, + translation=NoTranslation, + userlocations=String[], + ideal_userlocations=String[], + alpha_userlocations = String[], + mixing_userlocations = String[], + translation_userlocations = String[], + verbose=false) + +Enhanced Predictive Peng Robinson equation of state. it uses the following models: + +- Translation Model: `NoTranslation` +- Alpha Model: `PR78Alpha` +- Mixing Rule Model: `PPR78Rule` + +## References + +1. Robinson DB, Peng DY. The characterization of the heptanes and heavier fractions for the GPA Peng-Robinson programs. Tulsa: Gas Processors Association; 1978 +""" +function EPPR78(components::Vector{String}; idealmodel=BasicIdeal, + alpha = PR78Alpha, + mixing = PPR78Rule, + activity = nothing, + translation=NoTranslation, + userlocations=String[], + ideal_userlocations=String[], + alpha_userlocations = String[], + mixing_userlocations = String[], + translation_userlocations = String[], + verbose=false) + + return PR(components; + idealmodel = idealmodel, + alpha = alpha, + mixing=mixing, + activity = activity, + translation=translation, + userlocations = userlocations, + ideal_userlocations = ideal_userlocations, + alpha_userlocations = alpha_userlocations, + mixing_userlocations = mixing_userlocations, + translation_userlocations = translation_userlocations, + verbose = verbose) +end +export EPPR78 \ No newline at end of file diff --git a/src/models/cubic/mixing/PPR78.jl b/src/models/cubic/mixing/PPR78.jl new file mode 100644 index 000000000..5eaa9fa3e --- /dev/null +++ b/src/models/cubic/mixing/PPR78.jl @@ -0,0 +1,79 @@ +abstract type PPR78RuleModel <: MixingRule end + + +struct PPR78Param <: EoSParam + A::PairParam{Float64} + B::PairParam{Float64} +end + +struct PPR78Rule <: PPR78RuleModel + groups::GroupParam + components::Vector{String} + params::PPR78Param + references::Vector{String} +end +@registermodel HVRule + +""" + HVRule{γ} <: HVRuleModel + + HVRule(components; + userlocations::Vector{String}=String[], + verbose::Bool=false) + +## Input Parameters + +- `A`: Pair Parameter (`Float64`) - Fitted Parameter `[K]` +- `B`: Pair Parameter (`Float64`) - Fitted Parameter `[K]` + +## Description + +PPR78 Mixing Rule +``` +aᵢⱼ = √(aᵢaⱼ) +bᵢⱼ = (bᵢ +bⱼ)/2 +b̄ = ∑bᵢⱼxᵢxⱼ +c̄ = ∑cᵢxᵢ +ā = b̄(∑[xᵢaᵢᵢαᵢ/(bᵢᵢ)] - ∑xᵢxⱼbᵢbⱼEᵢⱼ/2b̄) +Eᵢⱼ = ∑(z̄ᵢₖ - z̄ⱼₖ)(z̄ᵢₗ - z̄ⱼₗ) × Aₖₗ × (298.15/T)^(Aₖₗ/Bₖₗ - 1) +``` + +## References +1. Jaubert, J.-N., Privat, R., & Mutelet, F. (2010). Predicting the phase equilibria of synthetic petroleum fluids with the PPR78 approach. AIChE Journal. American Institute of Chemical Engineers, 56(12), 3225–3235. doi:10.1002/aic.12232 +2. Jaubert, J.-N., Qian, J.-W., Lasala, S., & Privat, R. (2022). The impressive impact of including enthalpy and heat capacity of mixing data when parameterising equations of state. Application to the development of the E-PPR78 (Enhanced-Predictive-Peng-Robinson-78) model. Fluid Phase Equilibria, (113456), 113456. doi:10.1016/j.fluid.2022.113456 + +""" +HVRule + +export HVRule +function HVRule(components::Vector{String}; activity = Wilson, userlocations::Vector{String}=String[],activity_userlocations::Vector{String}=String[], verbose::Bool=false) + init_activity = activity(components;userlocations = activity_userlocations,verbose) + + references = ["10.1002/aic.12232","10.1016/j.fluid.2022.113456"] + model = HVRule(components, init_activity,references) + return model +end + + +function mixing_rule(model::CubicModel,V,T,z,mixing_model::HVRuleModel,α,a,b,c) + n = sum(z) + invn = 1/n + invn2 = invn*invn + b̄ = dot(z,Symmetric(b),z) * invn2 + c̄ = dot(z,c)/n + gᴱ = zero(T+first(z)) + A = mixing_model.params.A.values + B = mixing_model.params.B.values + groups = mixing_model.groups + gc = groups + for i ∈ @comps + for j in 1:i-1 + for k in gc + end + end + end + ∑ab = sum(z[i]*a[i,i]*α[i]/b[i,i] for i ∈ @comps)*invn + ā = b̄*(∑ab-gᴱ/_λ) + return ā,b̄,c̄ +end + From a029b1f17ac768a5eb04b455e45de3ea287ca72b Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Wed, 6 Apr 2022 17:43:09 -0400 Subject: [PATCH 06/17] doc improvements --- src/models/cubic/PR/variants/PR78.jl | 2 ++ src/models/cubic/PR/variants/UMRPR.jl | 6 ++++++ src/models/cubic/PR/variants/VTPR.jl | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/models/cubic/PR/variants/PR78.jl b/src/models/cubic/PR/variants/PR78.jl index 93c33b1a8..59cfa1d05 100644 --- a/src/models/cubic/PR/variants/PR78.jl +++ b/src/models/cubic/PR/variants/PR78.jl @@ -30,6 +30,7 @@ function PR78(components::Vector{String}; idealmodel=BasicIdeal, ideal_userlocations=String[], alpha_userlocations = String[], mixing_userlocations = String[], + translation_userlocations = String[], verbose=false) return PR(components; @@ -42,6 +43,7 @@ function PR78(components::Vector{String}; idealmodel=BasicIdeal, ideal_userlocations = ideal_userlocations, alpha_userlocations = alpha_userlocations, mixing_userlocations = mixing_userlocations, + translation_userlocations = translation_userlocations, verbose = verbose) end export PR78 \ No newline at end of file diff --git a/src/models/cubic/PR/variants/UMRPR.jl b/src/models/cubic/PR/variants/UMRPR.jl index 46c87cd9a..39ddf13e9 100644 --- a/src/models/cubic/PR/variants/UMRPR.jl +++ b/src/models/cubic/PR/variants/UMRPR.jl @@ -8,6 +8,8 @@ ideal_userlocations=String[], alpha_userlocations = String[], mixing_userlocations = String[], + activity_userlocations = String[], + translation_userlocations = String[], verbose=false) Universal Mixing Rule Peng Robinson equation of state. it uses the following models: @@ -30,6 +32,8 @@ function UMRPR(components::Vector{String}; idealmodel=BasicIdeal, ideal_userlocations=String[], alpha_userlocations = String[], mixing_userlocations = String[], + activity_userlocations = String[], + translation_userlocations = String[], verbose=false) return PR(components; @@ -42,6 +46,8 @@ function UMRPR(components::Vector{String}; idealmodel=BasicIdeal, ideal_userlocations = ideal_userlocations, alpha_userlocations = alpha_userlocations, mixing_userlocations = mixing_userlocations, + activity_userlocations = activity_userlocations, + translation_userlocations = translation_userlocations, verbose = verbose) end export UMRPR \ No newline at end of file diff --git a/src/models/cubic/PR/variants/VTPR.jl b/src/models/cubic/PR/variants/VTPR.jl index 537c52402..8f6b1a3ca 100644 --- a/src/models/cubic/PR/variants/VTPR.jl +++ b/src/models/cubic/PR/variants/VTPR.jl @@ -8,6 +8,8 @@ ideal_userlocations=String[], alpha_userlocations = String[], mixing_userlocations = String[], + activity_userlocations = String[], + translation_userlocations = String[], verbose=false) Volume-translated Peng Robinson equation of state. it uses the following models: From a106e5215e0f3a82d8b421cba61f39cf1c31fd53 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Wed, 6 Apr 2022 17:58:31 -0400 Subject: [PATCH 07/17] specialization on QCPR --- src/models/cubic/PR/variants/QCPR.jl | 55 ++++++++++++++++++++++++++++ src/models/cubic/equations.jl | 15 ++++---- src/models/cubic/mixing/mixing.jl | 2 - 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/models/cubic/PR/variants/QCPR.jl b/src/models/cubic/PR/variants/QCPR.jl index d42b31629..eaf14b5f0 100644 --- a/src/models/cubic/PR/variants/QCPR.jl +++ b/src/models/cubic/PR/variants/QCPR.jl @@ -57,3 +57,58 @@ function QCPR(components::Vector{String}; idealmodel=BasicIdeal, end export QCPR + + +const QCPRModel = PR{T,TwuAlpha,QCPRRule,ConstantTranslation} where T + +function cubic_ab(model::QCPRModel,V,T,z=SA[1.0],n=sum(z)) + invn2 = (one(n)/n)^2 + a = model.params.a.values + b = model.params.b.values + T = T*float(one(T)) + α = @f(α_function,model.alpha) + c = @f(translation,model.translation) + if length(z)>1 + ā,b̄,c̄ = @f(mixing_rule,model.mixing,α,a,b,c) + else + ā = a[1,1]*α[1] + A = model.mixing.params.A.values[1,1] + B = model.mixing.params.B.values[1,1] + Tc = model.params.Tc.values[1] + β = (1 + A/(T + B))^3 / (1 + A/(Tc + B))^3 + b̄ = b[1,1]*β + c̄ = c[1] + end + return ā ,b̄, c̄ +end + +function lb_volume(model::QCPRModel,z=SA[1.0]) + A = model.mixing.params.A.values + B = model.mixing.params.B.values + l = mixing_model.params.l.values + Tc = model.params.Tc.values + n = sum(z) + invn = (one(n)/n) + c = model.translation.params.c.values + c̄ = dot(c,z) + b̄ = zero(first(z)) + for i in 1:length(z) + zi = z[i] + zi2 = zi^2 + Bi = B[i] + Ai = A[i] + βi = (1 + Ai/Bi)^3 / (1 + Ai/(Tc[i] + Bi))^3 + bqi = βi*b[i,i] + b̄ += bqi*zi2 + for j in 1:(i-1) + zij = zi*z[j] + Bj = B[j] + Aj = A[j] + βj = (1 + Aj/Bj)^3 / (1 + Aj/(Tc[j] + Bj))^3 + bqj = βj*b[j,j] + b̄ += zij*(bqi+bqj)*(1-l[i,j]) #2 * zij * 0.5(bi + bj) + end + end + return invn*(b̄ - c̄) +end + diff --git a/src/models/cubic/equations.jl b/src/models/cubic/equations.jl index 25c34e9f2..17627ad4f 100644 --- a/src/models/cubic/equations.jl +++ b/src/models/cubic/equations.jl @@ -23,19 +23,18 @@ function ab_premixing(::Type{T},mixing,Tc,pc,kij) where T <: ABCubicModel end function cubic_ab(model::ABCubicModel,V,T,z=SA[1.0],n=sum(z)) - invn2 = (one(n)/n)^2 a = model.params.a.values b = model.params.b.values T = T*float(one(T)) α = @f(α_function,model.alpha) c = @f(translation,model.translation) - # if length(z)>1 + if length(z)>1 ā,b̄,c̄ = @f(mixing_rule,model.mixing,α,a,b,c) - # else - # ā = a[1,1]*α[1] - # b̄ = b[1,1] - # c̄ = c[1,1] - # end + else + ā = a[1,1]*α[1] + b̄ = b[1,1] + c̄ = c[1] + end return ā ,b̄, c̄ end @@ -51,7 +50,7 @@ function lb_volume(model::CubicModel,z = SA[1.0]) invn = one(n)/n b = model.params.b.values c = @f(translation,model.translation) - b̄ = dot(z,Symmetric(b),z)*invn*invn + b̄ = dot(z,Symmetric(b),z)*invn #b has m3/mol units, result should have m3 units c̄ = dot(z,c)*invn return b̄-c̄ end diff --git a/src/models/cubic/mixing/mixing.jl b/src/models/cubic/mixing/mixing.jl index 29c968800..79d91b91d 100644 --- a/src/models/cubic/mixing/mixing.jl +++ b/src/models/cubic/mixing/mixing.jl @@ -1,7 +1,5 @@ abstract type MixingRule <:EoSModel end - - """ mixing_rule(model::CubicModel,V,T,z,mixing_model::MixingRule,α,a,b,c) From dc2778b72fd9923b5ecf2dabfea428e5a55d8a04 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Wed, 6 Apr 2022 18:23:17 -0400 Subject: [PATCH 08/17] working PPR78 rule --- src/models/cubic/mixing/PPR78.jl | 48 ++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/models/cubic/mixing/PPR78.jl b/src/models/cubic/mixing/PPR78.jl index 5eaa9fa3e..2c7d2a294 100644 --- a/src/models/cubic/mixing/PPR78.jl +++ b/src/models/cubic/mixing/PPR78.jl @@ -1,6 +1,5 @@ abstract type PPR78RuleModel <: MixingRule end - struct PPR78Param <: EoSParam A::PairParam{Float64} B::PairParam{Float64} @@ -15,9 +14,9 @@ end @registermodel HVRule """ - HVRule{γ} <: HVRuleModel + PPR78Rule <: PPR78RuleModel - HVRule(components; + PPR78Rule(components; userlocations::Vector{String}=String[], verbose::Bool=false) @@ -43,35 +42,60 @@ Eᵢⱼ = ∑(z̄ᵢₖ - z̄ⱼₖ)(z̄ᵢₗ - z̄ⱼₗ) × Aₖₗ × (298.1 2. Jaubert, J.-N., Qian, J.-W., Lasala, S., & Privat, R. (2022). The impressive impact of including enthalpy and heat capacity of mixing data when parameterising equations of state. Application to the development of the E-PPR78 (Enhanced-Predictive-Peng-Robinson-78) model. Fluid Phase Equilibria, (113456), 113456. doi:10.1016/j.fluid.2022.113456 """ -HVRule +PPR78Rule -export HVRule -function HVRule(components::Vector{String}; activity = Wilson, userlocations::Vector{String}=String[],activity_userlocations::Vector{String}=String[], verbose::Bool=false) - init_activity = activity(components;userlocations = activity_userlocations,verbose) - +export PPR78Rule +function PPR78Rule(components, userlocations::Vector{String}=String[],group_userlocations::Vector{String}=String[], verbose::Bool=false) + groups = GroupParam(components,["cubic/EPPR78_groups.csv"]; verbose=verbose) + params = getparams(groups, ["cubic/EPPR78_unlike.csv"]; userlocations=userlocations) + pkgparams = PPR78Rule(params["A"],params["B"]) references = ["10.1002/aic.12232","10.1016/j.fluid.2022.113456"] - model = HVRule(components, init_activity,references) + model = PPR78Rule(groups,groups.components,pkgparams,references) return model end -function mixing_rule(model::CubicModel,V,T,z,mixing_model::HVRuleModel,α,a,b,c) +function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) n = sum(z) invn = 1/n invn2 = invn*invn + T̄ = 298.15/T b̄ = dot(z,Symmetric(b),z) * invn2 c̄ = dot(z,c)/n - gᴱ = zero(T+first(z)) + _0 = zero(T+first(z)) + gᴱ = _0 + A = mixing_model.params.A.values B = mixing_model.params.B.values groups = mixing_model.groups - gc = groups + gc = groups.i_flattenedgroups + z̄n = groups.n_groups.cache + + for i ∈ @comps + zni = z̄n[i] + ∑zni⁻¹ = 1/sum(zni) for j in 1:i-1 + znj = z̄n[j] + ∑znj⁻¹ = 1/sum(znj) + Eij = _0 for k in gc + αik =zni[k]* ∑zni⁻¹ + αjk =znj[k]* ∑znj⁻¹ + Δαk = (αik - αjk) + for l in 1:k-1 + αil =zni[k]* ∑zni⁻¹ + αjl =znj[k]* ∑znj⁻¹ + Δαl = (αil - αjl) + Akl = A[k,l] + Bkl = B[k,l] + Eij -= Δαk*Δαl*Akl*T̄^(Akl/Bkl - 1) # -1/2 * 2 + end end + gᴱ += z[i]*z[j]*Eij end end + gᴱ = 0.5*gᴱ*invn2/b̄ ∑ab = sum(z[i]*a[i,i]*α[i]/b[i,i] for i ∈ @comps)*invn ā = b̄*(∑ab-gᴱ/_λ) return ā,b̄,c̄ From 983f1a8792d1b1e58ecba11d3f4f0c127b395acf Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Wed, 6 Apr 2022 18:49:10 -0400 Subject: [PATCH 09/17] fix when Akl = Bkl = 0 in EPPR78 --- src/models/cubic/mixing/PPR78.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/cubic/mixing/PPR78.jl b/src/models/cubic/mixing/PPR78.jl index 2c7d2a294..c7d64ddd1 100644 --- a/src/models/cubic/mixing/PPR78.jl +++ b/src/models/cubic/mixing/PPR78.jl @@ -89,7 +89,9 @@ function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) Δαl = (αil - αjl) Akl = A[k,l] Bkl = B[k,l] - Eij -= Δαk*Δαl*Akl*T̄^(Akl/Bkl - 1) # -1/2 * 2 + if !iszero(Akl) + Eij -= Δαk*Δαl*Akl*T̄^(Akl/Bkl - 1) # -1/2 * 2 + end end end gᴱ += z[i]*z[j]*Eij From 8e52a912a1125c04488291acaa9d8a9eae30afa7 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Wed, 6 Apr 2022 19:46:19 -0400 Subject: [PATCH 10/17] typo --- src/models/cubic/mixing/PPR78.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/cubic/mixing/PPR78.jl b/src/models/cubic/mixing/PPR78.jl index c7d64ddd1..c129c24f8 100644 --- a/src/models/cubic/mixing/PPR78.jl +++ b/src/models/cubic/mixing/PPR78.jl @@ -83,9 +83,9 @@ function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) αik =zni[k]* ∑zni⁻¹ αjk =znj[k]* ∑znj⁻¹ Δαk = (αik - αjk) - for l in 1:k-1 - αil =zni[k]* ∑zni⁻¹ - αjl =znj[k]* ∑znj⁻¹ + for l in 1:k-1 #Δαk*Δαl = Δαl*Δαk + αil =zni[l]* ∑zni⁻¹ + αjl =znj[l]* ∑znj⁻¹ Δαl = (αil - αjl) Akl = A[k,l] Bkl = B[k,l] From 24f03b10ae5aa628646ca908b3590b9f33f732df Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Wed, 6 Apr 2022 21:06:44 -0400 Subject: [PATCH 11/17] typos --- src/Clapeyron.jl | 1 + src/models/cubic/mixing/PPR78.jl | 23 ++++++++++++----------- src/models/cubic/mixing/mixing.jl | 3 ++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Clapeyron.jl b/src/Clapeyron.jl index 3238062fe..c81fd3b90 100644 --- a/src/Clapeyron.jl +++ b/src/Clapeyron.jl @@ -137,6 +137,7 @@ include("models/cubic/PR/variants/PR78.jl") include("models/cubic/PR/variants/VTPR.jl") include("models/cubic/PR/variants/UMRPR.jl") include("models/cubic/PR/variants/QCPR.jl") +include("models/cubic/PR/variants/EPPR78.jl") include("models/LatticeFluid/SanchezLacombe/SanchezLacombe.jl") diff --git a/src/models/cubic/mixing/PPR78.jl b/src/models/cubic/mixing/PPR78.jl index c129c24f8..0b8ee1840 100644 --- a/src/models/cubic/mixing/PPR78.jl +++ b/src/models/cubic/mixing/PPR78.jl @@ -11,7 +11,7 @@ struct PPR78Rule <: PPR78RuleModel params::PPR78Param references::Vector{String} end -@registermodel HVRule +@registermodel PPR78Rule """ PPR78Rule <: PPR78RuleModel @@ -45,10 +45,11 @@ Eᵢⱼ = ∑(z̄ᵢₖ - z̄ⱼₖ)(z̄ᵢₗ - z̄ⱼₗ) × Aₖₗ × (298.1 PPR78Rule export PPR78Rule -function PPR78Rule(components, userlocations::Vector{String}=String[],group_userlocations::Vector{String}=String[], verbose::Bool=false) - groups = GroupParam(components,["cubic/EPPR78_groups.csv"]; verbose=verbose) - params = getparams(groups, ["cubic/EPPR78_unlike.csv"]; userlocations=userlocations) - pkgparams = PPR78Rule(params["A"],params["B"]) + +function PPR78Rule(components; activity = nothing, userlocations::Vector{String}=String[],activity_userlocations::Vector{String}=String[], verbose::Bool=false) + groups = GroupParam(components,["cubic/EPPR78/EPPR78_groups.csv"]; verbose=verbose) + params = getparams(groups, ["cubic/EPPR78/EPPR78_unlike.csv"]; userlocations=userlocations) + pkgparams = PPR78Param(params["A"],params["B"]) references = ["10.1002/aic.12232","10.1016/j.fluid.2022.113456"] model = PPR78Rule(groups,groups.components,pkgparams,references) return model @@ -67,14 +68,14 @@ function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) A = mixing_model.params.A.values B = mixing_model.params.B.values - groups = mixing_model.groups + groups = mixing_model.groups gc = groups.i_flattenedgroups - z̄n = groups.n_groups.cache + z̄n = groups.n_groups_cache - for i ∈ @comps zni = z̄n[i] ∑zni⁻¹ = 1/sum(zni) + bi = b[i,i] for j in 1:i-1 znj = z̄n[j] ∑znj⁻¹ = 1/sum(znj) @@ -90,16 +91,16 @@ function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) Akl = A[k,l] Bkl = B[k,l] if !iszero(Akl) - Eij -= Δαk*Δαl*Akl*T̄^(Akl/Bkl - 1) # -1/2 * 2 + Eij -= Δαk*Δαl*Akl*T̄^(Bkl/Akl - 1) # -1/2 * 2 end end end - gᴱ += z[i]*z[j]*Eij + gᴱ += bi*b[j,j]*z[i]*z[j]*Eij end end gᴱ = 0.5*gᴱ*invn2/b̄ ∑ab = sum(z[i]*a[i,i]*α[i]/b[i,i] for i ∈ @comps)*invn - ā = b̄*(∑ab-gᴱ/_λ) + ā = b̄*(∑ab-gᴱ) return ā,b̄,c̄ end diff --git a/src/models/cubic/mixing/mixing.jl b/src/models/cubic/mixing/mixing.jl index 79d91b91d..b9b022d7b 100644 --- a/src/models/cubic/mixing/mixing.jl +++ b/src/models/cubic/mixing/mixing.jl @@ -40,4 +40,5 @@ include("WS.jl") include("PSRK.jl") include("VTPR.jl") include("UMR.jl") -include("QCPR.jl") \ No newline at end of file +include("QCPR.jl") +include("PPR78.jl") \ No newline at end of file From c236a8f164514a67ce6818e1454dcb0a6613221a Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Thu, 7 Apr 2022 01:14:00 -0400 Subject: [PATCH 12/17] add molar mass of some acids --- database/properties/molarmass.csv | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/database/properties/molarmass.csv b/database/properties/molarmass.csv index 087fb3971..a080adbdd 100644 --- a/database/properties/molarmass.csv +++ b/database/properties/molarmass.csv @@ -545,7 +545,12 @@ ethylamine,,45.09 1-propylamine,,59.11 2-propylamine,,59.11 aniline,,93.13 -acetic acid,,60.053 +formic acid,64186,46.02538 +acetic acid,64197,60.05 +propionic acid,79094,74.08 +n-Butyric acid,107926,88.11 +isobutyric acid,79312,88.11 +benzoic acid,65850,122.12 neon,,20.1797 sulfur hexafluoride,,146.055 nitrous oxide,,44.013 From ad6022dee45e196ce26879e4d25c9439532bb628 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Thu, 7 Apr 2022 01:14:46 -0400 Subject: [PATCH 13/17] add another mixing rule for SL, test everything --- .../SanchezLacombe/SanchezLacombe_like.csv | 28 +++++++-------- .../SanchezLacombe/SanchezLacombe.jl | 5 +-- .../SanchezLacombe/mixing/SLKrule.jl | 2 +- test/test_models.jl | 35 +++++++++++++++---- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/database/LatticeFluid/SanchezLacombe/SanchezLacombe_like.csv b/database/LatticeFluid/SanchezLacombe/SanchezLacombe_like.csv index 199420303..e6969fb30 100644 --- a/database/LatticeFluid/SanchezLacombe/SanchezLacombe_like.csv +++ b/database/LatticeFluid/SanchezLacombe/SanchezLacombe_like.csv @@ -1,17 +1,17 @@ Clapeyron Database File SanchezLacombe Like Parameters species,epsilon,vol,segment -carbon dioxide,2276.66,3.638,8.564 -ethane,2444.62,7.865,6.653 -ethylene,2273.34,7.238,6.518 -Xenon,2943.30,11.854,3.644 -Biphenyl,5280.12,14.985,11.708 -Naphthalene,5509.75,12.407,9.600 -"2,3-Dimethylnaphthalene",5604.69,13.069,11.245 -"2,6-Dimethylnaphthalene",5540.04,13.069,11.244 -Fluorene,5866.55,10.676,11.821 -Phenanthrene,6354.58,13.804,11.378 -Anthracene,6372.58,13.804,11.378 -Pyrene,6732.91,14.733,11.980 -n-Octacosane,5295.78,17.360,22.989 -Benzoic Acid,4920.81,6.196,15.431 \ No newline at end of file +carbon dioxide,2276.66,3.638e-6,8.564 +ethane,2444.62,7.865e-6,6.653 +ethylene,2273.34,7.238e-6,6.518 +Xenon,2943.30,11.854e-6,3.644 +Biphenyl,5280.12,14.985e-6,11.708 +Naphthalene,5509.75,12.407e-6,9.600 +"2,3-Dimethylnaphthalene",5604.69,13.069e-6,11.245 +"2,6-Dimethylnaphthalene",5540.04,13.069e-6,11.244 +Fluorene,5866.55,10.676e-6,11.821 +Phenanthrene,6354.58,13.804e-6,11.378 +Anthracene,6372.58,13.804e-6,11.378 +Pyrene,6732.91,14.733e-6,11.980 +n-Octacosane,5295.78,17.360e-6,22.989 +Benzoic Acid,4920.81,6.196e-6,15.431 \ No newline at end of file diff --git a/src/models/LatticeFluid/SanchezLacombe/SanchezLacombe.jl b/src/models/LatticeFluid/SanchezLacombe/SanchezLacombe.jl index 11bc98c34..076313a13 100644 --- a/src/models/LatticeFluid/SanchezLacombe/SanchezLacombe.jl +++ b/src/models/LatticeFluid/SanchezLacombe/SanchezLacombe.jl @@ -18,6 +18,9 @@ struct SanchezLacombe{T <: SLMixingRule,I<:IdealModel} <:SanchezLacombeModel references::Array{String,1} end @registermodel SanchezLacombe + + + const SL = SanchezLacombe function SanchezLacombe(components; @@ -32,8 +35,6 @@ function SanchezLacombe(components; segment = params["segment"] unmixed_epsilon = params["epsilon"] unmixed_vol = params["vol"] - unmixed_epsilon.values #.*= k_B #to convert from temperature to eps - unmixed_vol.values .*= 1e-6 #convert from cm3/mol to m3/mol Mw = params["Mw"] mixmodel = init_model(mixing,components,mixing_userlocations,verbose) ideal = init_model(idealmodel,components,ideal_userlocations,verbose) diff --git a/src/models/LatticeFluid/SanchezLacombe/mixing/SLKrule.jl b/src/models/LatticeFluid/SanchezLacombe/mixing/SLKrule.jl index 1b0f7e68b..ab47f4937 100644 --- a/src/models/LatticeFluid/SanchezLacombe/mixing/SLKrule.jl +++ b/src/models/LatticeFluid/SanchezLacombe/mixing/SLKrule.jl @@ -4,7 +4,7 @@ struct SLKRule <: SLMixingRule end @registermodel SLKRule - +export SLKRule function sl_mix(unmixed_vol,unmixed_epsilon,mixmodel::SLKRule) #dont mind the function names, it performs the correct mixing premixed_vol= epsilon_LorentzBerthelot(unmixed_vol) diff --git a/test/test_models.jl b/test/test_models.jl index ef9f45452..5620bfadd 100644 --- a/test/test_models.jl +++ b/test/test_models.jl @@ -217,6 +217,11 @@ end @test Clapeyron.a_res(system, V, 25, z) ≈ -0.04727878068343511 rtol = 1e-6 end + @testset "EPPR78" begin + system = EPPR78(["ethane","undecane"]) + @test Clapeyron.a_res(system, V, T, z) ≈ -1.2516664842567844 rtol = 1e-6 + end + @testset "PR w/ BMAlpha" begin system = PR(["ethane","undecane"];alpha = BMAlpha) @test Clapeyron.a_res(system, V, T, z) ≈ -1.244507550417118 rtol = 1e-6 @@ -416,11 +421,29 @@ end @test Clapeyron.shape_factors(system, V, T, z)[1] ≈ 1.3499576779924594 rtol = 1e-6 end end - @testset "lattice models" begin - T = 298.15 - V = 1e-4 - z = [1.] - system = Clapeyron.SanchezLacombe(["carbon dioxide"]) - @test Clapeyron.a_res(system, V, T, z) ≈ -0.9511044462267396 rtol = 1e-6 + + @testset "single component" begin + T = 298.15 + V = 1e-4 + z = [1.] + system = Clapeyron.SanchezLacombe(["carbon dioxide"]) + @test Clapeyron.a_res(system, V, T, z) ≈ -0.9511044462267396 rtol = 1e-6 + end + + @testset "Sanchez-Lacombe,Kij rule" begin + T = 298.15 + V = 1e-4 + z = [0.5,0.5] + system = SanchezLacombe(["carbon dioxide","benzoic acid"],mixing = SLKRule) + @test Clapeyron.a_res(system, V, T, z) ≈ -6.494291842858994 rtol = 1e-6 + end + + @testset "Sanchez-Lacombe K0-K1-L rule" begin + T = 298.15 + V = 1e-4 + z = [0.5,0.5] + system = SanchezLacombe(["carbon dioxide","benzoic acid"],mixing = SLk0k1lMixingRule) + @test Clapeyron.a_res(system, V, T, z) ≈ -5.579621796375229 rtol = 1e-6 + end end From ff71d64e5f2602c15c818a14af2958fc01afc52c Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Thu, 7 Apr 2022 04:02:28 -0400 Subject: [PATCH 14/17] fix EPPR78 --- database/cubic/EPPR78/EPPR78_unlike.csv | 693 ++++++++++++------------ src/models/cubic/mixing/PPR78.jl | 47 +- 2 files changed, 394 insertions(+), 346 deletions(-) diff --git a/database/cubic/EPPR78/EPPR78_unlike.csv b/database/cubic/EPPR78/EPPR78_unlike.csv index 8f4722be9..95c5dea1a 100644 --- a/database/cubic/EPPR78/EPPR78_unlike.csv +++ b/database/cubic/EPPR78/EPPR78_unlike.csv @@ -1,353 +1,358 @@ Clapeyron Database File E-PPR78 unlike Parameters species1,species2,A,B -CH3,CH2,65.54,65.54 -CH3,CH,214.9,214.9 -CH3,C,431.6,431.6 -CH3,CH4,28.48,28.48 -CH3,C2H6,3.775,3.775 -CH3,CH aro,98.83,98.83 +CH3,CH2,65.54,105.7 +CH3,CH,214.9,294.9 +CH3,C,431.6,575.0 +CH3,CH4,28.48,20.25 +CH3,C2H6,3.775,8.922 +CH3,CH aro,98.83,136.2 CH3,C aro,103.6,103.6 -CH3,C fused aromatic rings,624.9,624.9 -CH3,CH2 cyclic,43.58,43.58 -CH3,CH cyclic~|~C cyclic,293.4,293.4 -CH3,CO2,144.8,144.8 -CH3,N2,38.09,38.09 -CH3,H2S,159.6,159.6 -CH3,SH,789.6,789.6 -CH3,H2O,3557.0,3557.0 -CH3,C2H4,7.892,7.892 -CH3,CH2 alkenic~|~CH alkenic,48.73,48.73 -CH3,C alkenic,102.6,102.6 -CH3,CH cycloalkenic~|~C cycloalkenic,47.01,47.01 -CH3,H2,174.0,174.0 -CH3,C2F6,119.1,119.1 -CH3,CF3,123.2,123.2 -CH3,CF2,58.33,58.33 -CH3,CF2 double bond~|~CF double bond,-12.29,-12.29 -CH3,C2H4F2,128.3,128.3 -CH3,C2H2F4,158.5,158.5 -CH3,CO,91.24,91.24 -CH3,He,416.3,416.3 -CH3,Ar,11.27,11.27 -CH3,SO2,322.2,322.2 -CH3,O2,86.1,86.1 -CH3,C2H2,-6.86,-6.86 -CH3,HC=-C-,306.1,306.1 -CH3,-C=-C-,72.06,72.06 -CH2,CH,39.05,39.05 -CH2,C,134.5,134.5 -CH2,CH4,37.75,37.75 -CH2,C2H6,29.85,29.85 -CH2,CH aro,25.05,25.05 -CH2,C aro,5.147,5.147 -CH2,C fused aromatic rings,-17.84,-17.84 -CH2,CH2 cyclic,8.579,8.579 -CH2,CH cyclic~|~C cyclic,63.48,63.48 -CH2,CO2,141.4,141.4 -CH2,N2,83.73,83.73 -CH2,H2S,136.6,136.6 -CH2,SH,439.9,439.9 -CH2,H2O,4324.0,4324.0 -CH2,C2H4,59.71,59.71 -CH2,CH2 alkenic~|~CH alkenic,9.608,9.608 -CH2,C alkenic,64.85,64.85 -CH2,CH cycloalkenic~|~C cycloalkenic,34.31,34.31 -CH2,H2,155.4,155.4 -CH2,C2F6,105.0,105.0 -CH2,CF3,195.6,195.6 -CH2,CF2,58.33,58.33 -CH2,C2H4F2,107.1,107.1 -CH2,C2H2F4,86.47,86.47 -CH2,CO,44.0,44.0 -CH2,He,520.52,520.52 -CH2,Ar,113.6,113.6 -CH2,SO2,55.9,55.9 -CH2,O2,107.4,107.4 -CH2,C2H2,421.0,421.0 -CH2,HC=-C-,303.3,303.3 -CH2,-C=-C-,488.0,488.0 -CH,C,-86.13,-86.13 -CH,CH4,131.4,131.4 -CH,C2H6,156.1,156.1 -CH,CH aro,56.62,56.62 -CH,C aro,48.73,48.73 -CH,CH2 cyclic,73.09,73.09 -CH,CH cyclic~|~C cyclic,-120.8,-120.8 -CH,CO2,191.8,191.8 -CH,N2,383.6,383.6 -CH,H2S,192.5,192.5 -CH,SH,374.0,374.0 -CH,H2O,971.4,971.4 -CH,C2H4,147.9,147.9 -CH,CH2 alkenic~|~CH alkenic,84.76,84.76 -CH,C alkenic,91.62,91.62 -CH,CH cycloalkenic~|~C cycloalkenic,0.52,0.52 -CH,H2,326.0,326.0 -CH,CF3,531.5,531.5 -CH,CF2,-122.8,-122.8 -CH,C2H4F2,143.8,143.8 -CH,C2H2F4,121.5,121.5 -CH,He,728.1,728.1 -CH,Ar,185.8,185.8 -CH,SO2,-70.0,-70.0 -CH,HC=-C-,206.9,206.9 -CH,-C=-C-,4.46,4.46 -C,CH4,309.5,309.5 -C,C2H6,388.1,388.1 -C,CH aro,170.5,170.5 -C,C aro,128.3,128.3 -C,CH2 cyclic,208.6,208.6 -C,CH cyclic~|~C cyclic,25.05,25.05 -C,CO2,377.5,377.5 -C,N2,341.8,341.8 -C,H2S,330.8,330.8 -C,SH,685.9,685.9 -C,C2H4,366.8,366.8 -C,CH2 alkenic~|~CH alkenic,181.2,181.2 -C,H2,548.3,548.3 -C,CF3,413.1,413.1 -C,CF2,479.0,479.0 -C,Ar,899.0,899.0 -CH4,C2H6,9.951,9.951 -CH4,CH aro,67.26,67.26 -CH4,C aro,106.7,106.7 -CH4,C fused aromatic rings,249.1,249.1 -CH4,CH2 cyclic,33.97,33.97 -CH4,CH cyclic~|~C cyclic,188.0,188.0 -CH4,CO2,136.6,136.6 -CH4,N2,30.88,30.88 -CH4,H2S,190.1,190.1 -CH4,SH,701.7,701.7 -CH4,H2O,2277.1,2277.1 -CH4,C2H4,19.22,19.22 -CH4,CH2 alkenic~|~CH alkenic,48.73,48.73 -CH4,H2,156.1,156.1 -CH4,CO,14.43,14.43 -CH4,He,394.5,394.5 -CH4,Ar,15.97,15.97 -CH4,SO2,205.9,205.9 -CH4,COS,44.61,44.61 -CH4,NH3,436.1,436.1 -CH4,N2O,74.81,74.81 -C2H6,CH aro,41.18,41.18 -C2H6,C aro,67.94,67.94 -C2H6,CH2 cyclic,12.7,12.7 -C2H6,CH cyclic~|~C cyclic,118.0,118.0 -C2H6,CO2,136.2,136.2 -C2H6,N2,61.59,61.59 -C2H6,H2S,157.2,157.2 -C2H6,H2O,2333.0,2333.0 -C2H6,C2H4,7.549,7.549 -C2H6,CH2 alkenic~|~CH alkenic,26.77,26.77 -C2H6,H2,137.6,137.6 -C2H6,C2F6,96.08,96.08 -C2H6,CF3,87.16,87.16 -C2H6,CF2,79.27,79.27 -C2H6,CF2 double bond~|~CF double bond,95.55,95.55 -C2H6,C2H2F4,72.4,72.4 -C2H6,CO,15.42,15.42 -C2H6,He,581.3,581.3 -C2H6,Ar,43.81,43.81 -C2H6,C2H2,137.9,137.9 -CH aro,C aro,-16.47,-16.47 -CH aro,C fused aromatic rings,52.5,52.5 -CH aro,CH2 cyclic,28.82,28.82 -CH aro,CH cyclic~|~C cyclic,129.0,129.0 -CH aro,CO2,98.48,98.48 -CH aro,N2,185.3,185.3 -CH aro,H2S,21.28,21.28 -CH aro,SH,277.6,277.6 -CH aro,H2O,2268.0,2268.0 -CH aro,C2H4,25.74,25.74 -CH aro,CH2 alkenic~|~CH alkenic,9.951,9.951 -CH aro,C alkenic,-16.47,-16.47 -CH aro,CH cycloalkenic~|~C cycloalkenic,3.375,3.375 -CH aro,H2,288.9,288.9 -CH aro,CF3,680.1,680.1 -CH aro,CF2,-31.57,-31.57 -CH aro,CF2 double bond~|~CF double bond,-274.3,-274.3 +CH3,C fused aromatic rings,624.9,774.1 +CH3,CH2 cyclic,43.58,60.05 +CH3,CH cyclic~|~C cyclic,0.0,170.9 +CH3,CO2,144.8,401.5 +CH3,N2,38.09,88.19 +CH3,H2S,159.6,227.8 +CH3,SH,789.6,1829.0 +CH3,H2O,3557.0,11195.0 +CH3,C2H4,7.892,35.0 +CH3,CH2 alkenic~|~CH alkenic,0.0,44.27 +CH3,C alkenic,102.6,260.1 +CH3,CH cycloalkenic~|~C cycloalkenic,0.0,169.5 +CH3,H2,174.0,239.5 +CH3,C2F6,119.1,118.4 +CH3,CF3,123.2,133.8 +CH3,CF2,58.33,65.2 +CH3,CF2 double bond~|~CF double bond,0.0,16.54 +CH3,C2H4F2,128.3,292.4 +CH3,C2H2F4,158.5,3565.0 +CH3,CO,91.24,94.24 +CH3,He,416.3,513.4 +CH3,Ar,11.27,55.48 +CH3,SO2,322.2,201.4 +CH3,O2,86.1,87.5 +CH3,C2H2,-6.86,41.52 +CH3,HC=-C-,306.1,1167.0 +CH3,-C=-C-,72.06,1219.5 +CH2,CH,39.05,41.59 +CH2,C,134.5,183.9 +CH2,CH4,37.75,74.81 +CH2,C2H6,29.85,65.88 +CH2,CH aro,25.05,64.51 +CH2,C aro,5.147,-7.549 +CH2,C fused aromatic rings,-17.84,-4.118 +CH2,CH2 cyclic,8.579,27.79 +CH2,CH cyclic~|~C cyclic,0.0,-74.46 +CH2,CO2,141.4,237.1 +CH2,N2,83.73,188.7 +CH2,H2S,136.6,124.6 +CH2,SH,439.9,504.8 +CH2,H2O,4324.0,12126.0 +CH2,C2H4,59.71,82.35 +CH2,CH2 alkenic~|~CH alkenic,0.0,50.79 +CH2,C alkenic,64.85,51.82 +CH2,CH cycloalkenic~|~C cycloalkenic,0.0,51.13 +CH2,H2,155.4,240.9 +CH2,C2F6,105.0,130.4 +CH2,CF3,195.6,199.0 +CH2,CF2,58.33,68.63 +CH2,C2H4F2,107.1,119.8 +CH2,C2H2F4,86.47,-40.49 +CH2,CO,44.0,45.55 +CH2,He,520.52,673.22 +CH2,Ar,113.6,231.6 +CH2,SO2,55.9,-28.5 +CH2,O2,107.4,200.8 +CH2,C2H2,421.0,1193.8 +CH2,HC=-C-,303.3,316.0 +CH2,-C=-C-,488.0,826.6 +CH,C,-86.13,85.1 +CH,CH4,131.4,157.5 +CH,C2H6,156.1,96.77 +CH,CH aro,56.62,129.7 +CH,C aro,48.73,-89.22 +CH,CH2 cyclic,73.09,71.37 +CH,CH cyclic~|~C cyclic,0.0,18.53 +CH,CO2,191.8,380.9 +CH,N2,383.6,375.4 +CH,H2S,192.5,562.8 +CH,SH,374.0,520.9 +CH,H2O,971.4,567.6 +CH,C2H4,147.9,-55.59 +CH,CH2 alkenic~|~CH alkenic,0.0,193.2 +CH,C alkenic,91.62,54.9 +CH,CH cycloalkenic~|~C cycloalkenic,0.0,-7.2 +CH,H2,326.0,287.9 +CH,CF3,531.5,-1945.0 +CH,CF2,-122.8,458.8 +CH,C2H4F2,143.8,15.78 +CH,C2H2F4,121.5,-44.61 +CH,He,728.1,750.9 +CH,Ar,185.8,634.2 +CH,SO2,-70.0,233.7 +CH,HC=-C-,206.9,3975.0 +CH,-C=-C-,4.46,-245.4 +C,CH4,309.5,35.69 +C,C2H6,388.1,-224.8 +C,CH aro,170.5,284.1 +C,C aro,128.3,189.1 +C,CH2 cyclic,208.6,294.4 +C,CH cyclic~|~C cyclic,0.0,81.33 +C,CO2,377.5,162.7 +C,N2,341.8,635.2 +C,H2S,330.8,-297.2 +C,SH,685.9,1547.0 +C,C2H4,366.8,-219.3 +C,CH2 alkenic~|~CH alkenic,0.0,419.0 +C,H2,548.3,2343.0 +C,CF3,413.1,975.2 +C,CF2 double bond~|~CF double bond,0.0,1430.0 +C,Ar,899.0,4655.0 +CH4,C2H6,9.951,13.73 +CH4,CH aro,67.26,167.5 +CH4,C aro,106.7,190.8 +CH4,C fused aromatic rings,249.1,408.3 +CH4,CH2 cyclic,33.97,5.49 +CH4,CH cyclic~|~C cyclic,0.0,473.9 +CH4,CO2,136.6,214.8 +CH4,N2,30.88,37.06 +CH4,H2S,190.1,307.5 +CH4,SH,701.7,1318.0 +CH4,H2O,2277.1,4719.6 +CH4,C2H4,19.22,33.29 +CH4,CH2 alkenic~|~CH alkenic,0.0,60.29 +CH4,H2,156.1,92.99 +CH4,CO,14.43,20.92 +CH4,He,394.5,378.1 +CH4,Ar,15.97,24.48 +CH4,SO2,205.9,323.6 +CH4,COS,44.61,-95.05 +CH4,NH3,436.1,958.8 +CH4,N2O,74.81,107.1 +C2H6,CH aro,41.18,50.79 +C2H6,C aro,67.94,210.7 +C2H6,CH2 cyclic,12.7,73.43 +C2H6,CH cyclic~|~C cyclic,0.0,-212.8 +C2H6,CO2,136.2,235.7 +C2H6,N2,61.59,84.92 +C2H6,H2S,157.2,217.1 +C2H6,H2O,2333.0,5147.0 +C2H6,C2H4,7.549,20.93 +C2H6,CH2 alkenic~|~CH alkenic,0.0,-5.147 +C2H6,H2,137.6,150.0 +C2H6,C2F6,96.08,123.5 +C2H6,CF3,87.16,143.8 +C2H6,CF2,79.27,15.1 +C2H6,CF2 double bond~|~CF double bond,0.0,-231.1 +C2H6,C2H2F4,72.4,-305.4 +C2H6,CO,15.42,33.3 +C2H6,He,581.3,517.1 +C2H6,Ar,43.81,53.1 +C2H6,C2H2,137.9,168.1 +CH aro,C aro,-16.47,16.47 +CH aro,C fused aromatic rings,52.5,251.2 +CH aro,CH2 cyclic,28.82,65.54 +CH aro,CH cyclic~|~C cyclic,0.0,36.72 +CH aro,CO2,98.48,253.6 +CH aro,N2,185.3,490.7 +CH aro,H2S,21.28,6.177 +CH aro,SH,277.6,449.5 +CH aro,H2O,2268.0,6218.0 +CH aro,C2H4,25.74,78.92 +CH aro,CH2 alkenic~|~CH alkenic,0.0,19.9 +CH aro,C alkenic,-16.47,61.42 +CH aro,CH cycloalkenic~|~C cycloalkenic,0.0,1.716 +CH aro,H2,288.9,189.1 +CH aro,CF3,680.1,421.7 +CH aro,CF2,-31.57,43.24 +CH aro,CF2 double bond~|~CF double bond,0.0,-411.7 CH aro,CO,153.4,153.4 -CH aro,He,753.6,753.6 -CH aro,Ar,195.6,195.6 -CH aro,SO2,37.1,37.1 -CH aro,O2,233.4,233.4 -CH aro,C2H2,29.17,29.17 -CH aro,HC=-C-,96.08,96.08 +CH aro,He,753.6,590.5 +CH aro,Ar,195.6,361.3 +CH aro,SO2,37.1,-23.7 +CH aro,O2,233.4,404.9 +CH aro,C2H2,29.17,123.5 +CH aro,HC=-C-,96.08,148.2 CH aro,-C=-C-,403.9,403.9 -C aro,C fused aromatic rings,-328.0,-328.0 -C aro,CH2 cyclic,37.4,37.4 -C aro,CH cyclic~|~C cyclic,-99.17,-99.17 -C aro,CO2,154.4,154.4 -C aro,N2,343.8,343.8 -C aro,H2S,9.608,9.608 -C aro,SH,1002.0,1002.0 -C aro,H2O,543.5,543.5 -C aro,C2H4,97.8,97.8 -C aro,CH2 alkenic~|~CH alkenic,-48.38,-48.38 -C aro,C alkenic,343.1,343.1 -C aro,CH cycloalkenic~|~C cycloalkenic,242.9,242.9 -C aro,H2,400.1,400.1 -C aro,CF3,733.0,733.0 -C aro,CF2,-8.922,-8.922 -C aro,CF2 double bond~|~CF double bond,78.62,78.62 -C fused aromatic rings,CH2 cyclic,140.7,140.7 -C fused aromatic rings,CH cyclic~|~C cyclic,-99.17,-99.17 -C fused aromatic rings,CO2,331.1,331.1 -C fused aromatic rings,N2,702.4,702.4 -C fused aromatic rings,H2S,9.608,9.608 -C fused aromatic rings,SH,1002.0,1002.0 -C fused aromatic rings,H2O,1340.0,1340.0 -C fused aromatic rings,C2H4,209.7,209.7 -C fused aromatic rings,CH2 alkenic~|~CH alkenic,669.8,669.8 -C fused aromatic rings,H2,602.9,602.9 -C fused aromatic rings,CO,197.0,197.0 -C fused aromatic rings,He,753.6,753.6 -CH2 cyclic,CH cyclic~|~C cyclic,139.0,139.0 -CH2 cyclic,CO2,144.1,144.1 -CH2 cyclic,N2,179.5,179.5 -CH2 cyclic,H2S,117.4,117.4 -CH2 cyclic,SH,493.1,493.1 -CH2 cyclic,H2O,4211.0,4211.0 -CH2 cyclic,C2H4,35.34,35.34 -CH2 cyclic,CH2 alkenic~|~CH alkenic,-15.44,-15.44 -CH2 cyclic,C alkenic,159.6,159.6 -CH2 cyclic,CH cycloalkenic~|~C cycloalkenic,31.91,31.91 -CH2 cyclic,H2,236.1,236.1 -CH2 cyclic,CF3,216.2,216.2 -CH2 cyclic,CF2,42.55,42.55 -CH2 cyclic,CO,113.1,113.1 -CH2 cyclic,Ar,1269.0,1269.0 -CH2 cyclic,O2,181.2,181.2 -CH2 cyclic,NO,-27.5,-27.5 +C aro,C fused aromatic rings,-328.0,-569.3 +C aro,CH2 cyclic,37.4,53.53 +C aro,CH cyclic~|~C cyclic,0.0,-193.5 +C aro,CO2,154.4,374.4 +C aro,N2,343.8,1712.0 +C aro,H2S,9.608,-36.72 +C aro,SH,1002.0,-736.4 +C aro,H2O,543.5,411.8 +C aro,C2H4,97.8,67.94 +C aro,CH2 alkenic~|~CH alkenic,0.0,27.79 +C aro,C alkenic,343.1,880.2 +C aro,CH cycloalkenic~|~C cycloalkenic,0.0,-7.206 +C aro,H2,400.1,1201.0 +C aro,CF3,733.0,866.8 +C aro,CF2,-8.922,5.147 +C aro,CF2 double bond~|~CF double bond,0.0,-108.0 +C aro,CO,0.0,-231.1 +C aro,He,0.0,590.5 +C aro,SO2,0.0,-397.4 +C aro,O2,0.0,2259.4 +C aro,HC=-C-,0.0,-459.5 +C aro,-C=-C-,0.0,518.5 +C fused aromatic rings,CH2 cyclic,140.7,277.6 +C fused aromatic rings,CH cyclic~|~C cyclic,0.0,-193.5 +C fused aromatic rings,CO2,331.1,276.6 +C fused aromatic rings,N2,702.4,1889.0 +C fused aromatic rings,H2S,9.608,-36.72 +C fused aromatic rings,SH,1002.0,-736.4 +C fused aromatic rings,H2O,1340.0,-65.88 +C fused aromatic rings,C2H4,209.7,3819.0 +C fused aromatic rings,CH2 alkenic~|~CH alkenic,0.0,589.5 +C fused aromatic rings,H2,602.9,1463.0 +C fused aromatic rings,CO,197.0,-238.8 +C fused aromatic rings,He,753.6,590.5 +CH2 cyclic,CH cyclic~|~C cyclic,0.0,35.69 +CH2 cyclic,CO2,144.1,354.1 +CH2 cyclic,N2,179.5,546.6 +CH2 cyclic,H2S,117.4,166.4 +CH2 cyclic,SH,493.1,832.1 +CH2 cyclic,H2O,4211.0,13031.0 +CH2 cyclic,C2H4,35.34,52.5 +CH2 cyclic,CH2 alkenic~|~CH alkenic,0.0,24.36 +CH2 cyclic,C alkenic,159.6,140.7 +CH2 cyclic,CH cycloalkenic~|~C cycloalkenic,0.0,69.32 +CH2 cyclic,H2,236.1,192.5 +CH2 cyclic,CF3,216.2,343.1 +CH2 cyclic,CF2,42.55,-68.63 +CH2 cyclic,CO,113.1,143.6 +CH2 cyclic,Ar,1269.0,18666.0 +CH2 cyclic,O2,181.2,281.4 +CH2 cyclic,NO,-27.5,50.1 CH2 cyclic,HC=-C-,496.2,496.2 CH2 cyclic,-C=-C-,845.9,845.9 -CH cyclic~|~C cyclic,CO2,216.2,216.2 -CH cyclic~|~C cyclic,N2,331.5,331.5 -CH cyclic~|~C cyclic,H2S,71.37,71.37 -CH cyclic~|~C cyclic,SH,463.2,463.2 -CH cyclic~|~C cyclic,H2O,244.0,244.0 -CH cyclic~|~C cyclic,C2H4,297.2,297.2 -CH cyclic~|~C cyclic,CH2 alkenic~|~CH alkenic,260.1,260.1 -CH cyclic~|~C cyclic,CH cycloalkenic~|~C cycloalkenic,151.3,151.3 -CH cyclic~|~C cyclic,H2,-51.82,-51.82 -CH cyclic~|~C cyclic,O2,102.3,102.3 -CH cyclic~|~C cyclic,HC=-C-,863.7,863.7 -CO2,N2,113.9,113.9 -CO2,H2S,135.2,135.2 -CO2,SH,484.15,484.15 -CO2,H2O,559.3,559.3 -CO2,C2H4,73.09,73.09 -CO2,CH2 alkenic~|~CH alkenic,60.74,60.74 -CO2,C alkenic,74.81,74.81 -CO2,CH cycloalkenic~|~C cycloalkenic,87.85,87.85 -CO2,H2,261.1,261.1 -CO2,C2F6,126.6,126.6 -CO2,CF3,156.5,156.5 -CO2,CF2,125.2,125.2 -CO2,CF2 double bond~|~CF double bond,36.25,36.25 -CO2,C2H4F2,48.73,48.73 -CO2,C2H2F4,29.51,29.51 -CO2,CO,87.85,87.85 -CO2,He,685.9,685.9 -CO2,Ar,177.8,177.8 -CO2,SO2,54.9,54.9 -CO2,O2,154.4,154.4 -CO2,NO,5.1,5.1 -CO2,COS,83.04,83.04 -CO2,NO2~|~N2O4,124.9,124.9 -CO2,N2O,3.77,3.77 -CO2,HC=-C-,60.05,60.05 -N2,H2S,319.5,319.5 -N2,SH,1042.0,1042.0 -N2,H2O,2574.0,2574.0 -N2,C2H4,45.3,45.3 -N2,CH2 alkenic~|~CH alkenic,59.71,59.71 -N2,C alkenic,541.5,541.5 -N2,H2,65.2,65.2 -N2,CO,23.33,23.33 -N2,He,204.7,204.7 -N2,Ar,6.488,6.488 -N2,SO2,282.4,282.4 -N2,O2,2.4,2.4 -N2,NO,258.7,258.7 -N2,NH3,585.8,585.8 -N2,NO2~|~N2O4,263.5,263.5 -N2,N2O,101.6,101.6 -H2S,SH,-157.8,-157.8 -H2S,H2O,603.9,603.9 -H2S,H2,145.8,145.8 -H2S,CO,278.6,278.6 -H2S,COS,101.9,101.9 -SH,H2O,30.88,30.88 -H2O,C2H4,1650.0,1650.0 -H2O,CH2 alkenic~|~CH alkenic,2243.0,2243.0 -H2O,H2,830.8,830.8 -H2O,CO,715.1,715.1 -H2O,Ar,1197.0,1197.0 -H2O,SO2,374.4,374.4 -H2O,O2,1376.0,1376.0 -H2O,NH3,-550.1,-550.1 -H2O,N2O,568.9,568.9 -H2O,C2H2,436.8,436.8 -H2O,HC=-C-,-2395.5,-2395.5 -C2H4,CH2 alkenic~|~CH alkenic,14.76,14.76 -C2H4,C alkenic,-518.2,-518.2 -C2H4,CH cycloalkenic~|~C cycloalkenic,-98.83,-98.83 -C2H4,H2,151.3,151.3 -C2H4,CF3,453.0,453.0 -C2H4,CF2 double bond~|~CF double bond,-132.7,-132.7 -C2H4,CO,84.55,84.55 -C2H4,He,569.6,569.6 -C2H4,SO2,26.8,26.8 -CH2 alkenic~|~CH alkenic,C alkenic,24.71,24.71 -CH2 alkenic~|~CH alkenic,CH cycloalkenic~|~C cycloalkenic,14.07,14.07 -CH2 alkenic~|~CH alkenic,H2,175.7,175.7 -CH2 alkenic~|~CH alkenic,C2F6,124.9,124.9 -CH2 alkenic~|~CH alkenic,CF3,155.4,155.4 -CH2 alkenic~|~CH alkenic,CF2,155.4,155.4 -CH2 alkenic~|~CH alkenic,CF2 double bond~|~CF double bond,88.21,88.21 -CH2 alkenic~|~CH alkenic,C2H4F2,76.86,76.86 -CH2 alkenic~|~CH alkenic,C2H2F4,64.51,64.51 -CH2 alkenic~|~CH alkenic,He,644.3,644.3 -CH2 alkenic~|~CH alkenic,Ar,203.0,203.0 -CH2 alkenic~|~CH alkenic,C2H2,165.4,165.4 -CH2 alkenic~|~CH alkenic,HC=-C-,134.5,134.5 -CH2 alkenic~|~CH alkenic,-C=-C-,255.6,255.6 -C alkenic,CH cycloalkenic~|~C cycloalkenic,23.68,23.68 -C alkenic,H2,621.4,621.4 -C alkenic,SO2,-141.7,-141.7 -C alkenic,HC=-C-,212.8,212.8 -C alkenic,-C=-C-,-874.3,-874.3 -CH cycloalkenic~|~C cycloalkenic,H2,460.8,460.8 -CH cycloalkenic~|~C cycloalkenic,CF3,1232.0,1232.0 -H2,CO,75.84,75.84 -H2,He,138.7,138.7 -H2,Ar,128.2,128.2 -H2,NH3,701.7,701.7 -C2F6,CF3,-14.47,-14.47 -C2F6,CF2 double bond~|~CF double bond,55.9,55.9 -C2F6,C2H2F4,60.74,60.74 +CH cyclic~|~C cyclic,CO2,0.0,389.8 +CH cyclic~|~C cyclic,H2S,0.0,-127.7 +CH cyclic~|~C cyclic,SH,0.0,-337.7 +CH cyclic~|~C cyclic,H2O,0.0,-60.39 +CH cyclic~|~C cyclic,C2H4,0.0,-647.2 +CH cyclic~|~C cyclic,CH2 alkenic~|~CH alkenic,0.0,134.9 +CH cyclic~|~C cyclic,CH cycloalkenic~|~C cycloalkenic,0.0,2.745 +CH cyclic~|~C cyclic,H2,0.0,34.31 +CH cyclic~|~C cyclic,O2,0.0,988.0 +CH cyclic~|~C cyclic,HC=-C-,0.0,863.7 +CO2,N2,113.9,212.4 +CO2,H2S,135.2,199.0 +CO2,SH,484.15,646.58 +CO2,H2O,559.3,277.9 +CO2,C2H4,73.09,106.7 +CO2,CH2 alkenic~|~CH alkenic,0.0,183.9 +CO2,C alkenic,74.81,-266.6 +CO2,CH cycloalkenic~|~C cycloalkenic,0.0,66.91 +CO2,H2,261.1,300.9 +CO2,C2F6,126.6,241.2 +CO2,CF3,156.5,-116.0 +CO2,CF2,125.2,340.1 +CO2,CF2 double bond~|~CF double bond,0.0,63.49 +CO2,C2H4F2,48.73,751.1 +CO2,C2H2F4,29.51,89.9 +CO2,CO,87.85,190.8 +CO2,He,685.9,559.3 +CO2,Ar,177.8,86.82 +CO2,SO2,54.9,59.02 +CO2,O2,154.4,109.8 +CO2,NO,5.1,48.4 +CO2,COS,83.04,165.7 +CO2,NO2~|~N2O4,0.0,241.6 +CO2,N2O,3.77,14.07 +CO2,HC=-C-,60.05,-80.98 +N2,H2S,319.5,550.1 +N2,SH,1042.0,1722.68 +N2,H2O,2574.0,5490.0 +N2,C2H4,45.3,92.65 +N2,CH2 alkenic~|~CH alkenic,0.0,227.2 +N2,C alkenic,541.5,94.71 +N2,H2,65.2,70.1 +N2,CO,23.33,-25.4 +N2,He,204.7,222.8 +N2,Ar,6.488,8.774 +N2,SO2,282.4,362.7 +N2,O2,2.4,4.8 +N2,NO,258.7,100.5 +N2,NH3,585.8,1011.3 +N2,NO2~|~N2O4,0.0,260.0 +N2,N2O,101.6,230.9 +H2S,SH,-157.8,153.7 +H2S,H2O,603.9,599.1 +H2S,H2,145.8,823.5 +H2S,CO,278.6,404.2 +H2S,COS,101.9,98.14 +SH,H2O,30.88,-113.6 +H2O,C2H4,1650.0,1661.0 +H2O,CH2 alkenic~|~CH alkenic,0.0,5199.0 +H2O,H2,830.8,-137.9 +H2O,CO,715.1,-89.9 +H2O,Ar,1197.0,1211.0 +H2O,SO2,374.4,148.6 +H2O,O2,1376.0,1609.0 +H2O,NH3,-550.1,-1404.2 +H2O,N2O,568.9,-144.8 +H2O,C2H2,436.8,-200.1 +H2O,HC=-C-,-2395.5,-11671.0 +C2H4,CH2 alkenic~|~CH alkenic,0.0,11.32 +C2H4,C alkenic,-518.2,6815.0 +C2H4,CH cycloalkenic~|~C cycloalkenic,0.0,1809.0 +C2H4,H2,151.3,165.1 +C2H4,CF3,453.0,-611.5 +C2H4,CF2 double bond~|~CF double bond,0.0,548.3 +C2H4,CO,84.55,-7.515 +C2H4,He,569.6,536.7 +CH2 alkenic~|~CH alkenic,C alkenic,0.0,121.8 +CH2 alkenic~|~CH alkenic,CH cycloalkenic~|~C cycloalkenic,0.0,-12.35 +CH2 alkenic~|~CH alkenic,H2,0.0,373.0 +CH2 alkenic~|~CH alkenic,C2F6,0.0,219.6 +CH2 alkenic~|~CH alkenic,CF3,0.0,154.4 +CH2 alkenic~|~CH alkenic,CF2,0.0,154.4 +CH2 alkenic~|~CH alkenic,CF2 double bond~|~CF double bond,0.0,12.87 +CH2 alkenic~|~CH alkenic,C2H4F2,0.0,-145.5 +CH2 alkenic~|~CH alkenic,C2H2F4,0.0,-41.86 +CH2 alkenic~|~CH alkenic,He,0.0,687.7 +CH2 alkenic~|~CH alkenic,Ar,0.0,-11.78 +CH2 alkenic~|~CH alkenic,SO2,0.0,26.8 +CH2 alkenic~|~CH alkenic,C2H2,0.0,39.8 +CH2 alkenic~|~CH alkenic,HC=-C-,0.0,568.9 +CH2 alkenic~|~CH alkenic,-C=-C-,0.0,676.7 +C alkenic,CH cycloalkenic~|~C cycloalkenic,0.0,87.5 +C alkenic,H2,621.4,-495.5 +C alkenic,SO2,-141.7,-151.3 +C alkenic,HC=-C-,212.8,-2182.8 +C alkenic,-C=-C-,-874.3,1040.1 +CH cycloalkenic~|~C cycloalkenic,H2,0.0,2167.0 +CH cycloalkenic~|~C cycloalkenic,CF3,0.0,-495.5 +H2,CO,75.84,74.81 +H2,He,138.7,95.49 +H2,Ar,128.2,102.9 +H2,NH3,701.7,931.3 +C2F6,CF3,-14.47,-87.05 +C2F6,CF2 double bond~|~CF double bond,0.0,-193.3 +C2F6,C2H2F4,60.74,217.6 CF3,CF2,0.0,0.0 -CF3,CF2 double bond~|~CF double bond,17.55,17.55 -CF3,C2H4F2,113.2,113.2 -CF3,C2H2F4,28.14,28.14 -CF2,C2H4F2,120.1,120.1 -CF2,C2H2F4,229.9,229.9 -C2H4F2,C2H2F4,-4.118,-4.118 -C2H4F2,C2H2,-58.68,-58.68 -CO,He,260.1,260.1 -CO,Ar,4.042,4.042 -CO,NO,309.2,309.2 -He,Ar,243.1,243.1 -Ar,SO2,299.9,299.9 -Ar,O2,4.8,4.8 -Ar,NO,110.8,110.8 -Ar,NH3,630.0,630.0 -Ar,NO2~|~N2O4,278.6,278.6 -SO2,O2,340.0,340.0 -SO2,NO,172.3,172.3 -O2,NO2~|~N2O4,271.1,271.1 -O2,N2O,120.1,120.1 -C2H2,HC=-C-,122.5,122.5 -HC=-C-,-C=-C-,-497.6,-497.6 \ No newline at end of file +CF3,CF2 double bond~|~CF double bond,0.0,-92.99 +CF3,C2H4F2,113.2,247.1 +CF3,C2H2F4,28.14,8.235 +CF2,C2H4F2,120.1,264.2 +CF2,C2H2F4,229.9,259.1 +C2H4F2,C2H2F4,-4.118,4.118 +C2H4F2,C2H2,-58.68,303.7 +CO,He,260.1,259.9 +CO,Ar,4.042,8.18 +CO,NO,309.2,28.82 +He,Ar,243.1,305.6 +Ar,SO2,299.9,354.1 +Ar,O2,4.8,7.89 +Ar,NO,110.8,155.5 +Ar,NH3,630.0,1794.0 +Ar,NO2~|~N2O4,0.0,274.5 +SO2,O2,340.0,665.7 +SO2,NO,172.3,1343.0 +O2,NO2~|~N2O4,0.0,362.4 +O2,N2O,120.1,105.7 +C2H2,HC=-C-,122.5,247.8 +HC=-C-,-C=-C-,-497.6,-824.2 \ No newline at end of file diff --git a/src/models/cubic/mixing/PPR78.jl b/src/models/cubic/mixing/PPR78.jl index 0b8ee1840..5519518f1 100644 --- a/src/models/cubic/mixing/PPR78.jl +++ b/src/models/cubic/mixing/PPR78.jl @@ -95,12 +95,55 @@ function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) end end end - gᴱ += bi*b[j,j]*z[i]*z[j]*Eij + gᴱ += bi*b[j,j]*z[i]*z[j]*Eij #(0.5 * 2) end end - gᴱ = 0.5*gᴱ*invn2/b̄ + gᴱ = gᴱ*invn2/b̄ ∑ab = sum(z[i]*a[i,i]*α[i]/b[i,i] for i ∈ @comps)*invn ā = b̄*(∑ab-gᴱ) return ā,b̄,c̄ end +#= +groups: +["CH3", +"CH2", +"CH", +"C", +"CH4", +"C2H6", +"CH aro", +"C aro", +"C fused aromatic rings", +"CH2 cyclic", +"CH cyclic~|~C cyclic", +"CO2", +"N2", +"H2S", +"SH", +"H2O", +"C2H4", +"CH2 alkenic~|~CH alkenic", +"C alkenic", +"CH cycloalkenic~|~C cycloalkenic", +"H2", +"C2F6", +"CF3", +"CF2", +"CF2 double bond~|~CF double bond", +"C2H4F2", +"C2H2F4", +"CO", +"He", +"Ar", +"SO2", +"O2", +"NO", +"COS", +"NH3", +"NO2~|~N2O4", +"N2O", +"C2H2", +"HC=-C-", +"-C=-C-"] +=# \ No newline at end of file From 231189a6954ca06774dfdc385255f1e249d3c9d3 Mon Sep 17 00:00:00 2001 From: longemen3000 Date: Thu, 7 Apr 2022 04:36:20 -0400 Subject: [PATCH 15/17] remove EPPR78 test for now --- test/test_models.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_models.jl b/test/test_models.jl index 5620bfadd..6dedd1d77 100644 --- a/test/test_models.jl +++ b/test/test_models.jl @@ -217,10 +217,10 @@ end @test Clapeyron.a_res(system, V, 25, z) ≈ -0.04727878068343511 rtol = 1e-6 end - @testset "EPPR78" begin - system = EPPR78(["ethane","undecane"]) - @test Clapeyron.a_res(system, V, T, z) ≈ -1.2516664842567844 rtol = 1e-6 - end + #@testset "EPPR78" begin + # system = EPPR78(["ethane","undecane"]) + # @test Clapeyron.a_res(system, V, T, z) ≈ -1.2516664842567844 rtol = 1e-6 + #end @testset "PR w/ BMAlpha" begin system = PR(["ethane","undecane"];alpha = BMAlpha) From dcb6a9a085bc8247a1bbec4652cc0338cd7b2031 Mon Sep 17 00:00:00 2001 From: pw0908 Date: Thu, 7 Apr 2022 10:51:05 -0700 Subject: [PATCH 16/17] Fix EPPR78 --- database/cubic/EPPR78/EPPR78_groups.csv | 2 ++ database/properties/critical.csv | 1 + database/properties/molarmass.csv | 1 + src/models/cubic/mixing/PPR78.jl | 6 +++--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/database/cubic/EPPR78/EPPR78_groups.csv b/database/cubic/EPPR78/EPPR78_groups.csv index 215fc7474..0b7be874f 100644 --- a/database/cubic/EPPR78/EPPR78_groups.csv +++ b/database/cubic/EPPR78/EPPR78_groups.csv @@ -27,3 +27,5 @@ nitrogen,"[""N2""=>1]" carbon monoxide,"[""CO""=>1]" sulfur dioxide,"[""SO2""=>1]" hydrogen sulfide,"[""H2S""=>1]" +benzene,"[""CH aro""=>6]" +isooctane,"[""CH3""=>5,""CH2""=>1,""CH""=>1,""C""=>1]" \ No newline at end of file diff --git a/database/properties/critical.csv b/database/properties/critical.csv index 337f4dc06..7ec82643c 100644 --- a/database/properties/critical.csv +++ b/database/properties/critical.csv @@ -23,6 +23,7 @@ nonadecane,629925,758,1.21E+06,1.60E-03,0.851 eicosane,112958,768,1.17E+06,1.68E-03,0.912 isobutane,75285,408.14,3.62E+06,2.88E-04,0.177 isopentane,78784,460.43,3.37E+06,3.49E-04,0.226 +isooctane,,543.9,25.7e5,0.468e-3,0.301 "2,3-Dimethylbutane",79298,499.98,3.13E+06,4.08E-04,0.246 2-Methylpentane,107835,497.5,3.02E+06,4.21E-04,0.279 "2,3-Dimethylpentane",565593,537.35,2.88E+06,4.77E-04,0.292 diff --git a/database/properties/molarmass.csv b/database/properties/molarmass.csv index a080adbdd..94c569fc0 100644 --- a/database/properties/molarmass.csv +++ b/database/properties/molarmass.csv @@ -25,6 +25,7 @@ tetracosane,77,338.65 hexatriacontane,2086,506.97 isobutane,4,58.12 isopentane,8,72.15 +isooctane,,114.23 neopentane,9,72.15 "2,2-dimethylbutane",14,86.18 "2,3-dimethylbutane",15,86.18 diff --git a/src/models/cubic/mixing/PPR78.jl b/src/models/cubic/mixing/PPR78.jl index 5519518f1..edaa963d5 100644 --- a/src/models/cubic/mixing/PPR78.jl +++ b/src/models/cubic/mixing/PPR78.jl @@ -61,8 +61,8 @@ function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) invn = 1/n invn2 = invn*invn T̄ = 298.15/T - b̄ = dot(z,Symmetric(b),z) * invn2 - c̄ = dot(z,c)/n + b̄ = dot(z,diag(b)) * invn + c̄ = dot(z,c)*invn _0 = zero(T+first(z)) gᴱ = _0 @@ -98,7 +98,7 @@ function mixing_rule(model::CubicModel,V,T,z,mixing_model::PPR78Rule,α,a,b,c) gᴱ += bi*b[j,j]*z[i]*z[j]*Eij #(0.5 * 2) end end - gᴱ = gᴱ*invn2/b̄ + gᴱ = gᴱ*invn2/b̄*1e6 ∑ab = sum(z[i]*a[i,i]*α[i]/b[i,i] for i ∈ @comps)*invn ā = b̄*(∑ab-gᴱ) return ā,b̄,c̄ From f7a328e49bc8b21d5401ac198d9398a23891dcd2 Mon Sep 17 00:00:00 2001 From: pw0908 Date: Thu, 7 Apr 2022 11:12:10 -0700 Subject: [PATCH 17/17] Add test --- test/test_models.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_models.jl b/test/test_models.jl index 6dedd1d77..db626f3b2 100644 --- a/test/test_models.jl +++ b/test/test_models.jl @@ -217,10 +217,10 @@ end @test Clapeyron.a_res(system, V, 25, z) ≈ -0.04727878068343511 rtol = 1e-6 end - #@testset "EPPR78" begin - # system = EPPR78(["ethane","undecane"]) - # @test Clapeyron.a_res(system, V, T, z) ≈ -1.2516664842567844 rtol = 1e-6 - #end + @testset "EPPR78" begin + system = EPPR78(["benzene","isooctane"]) + @test Clapeyron.a_res(system, V, T, z) ≈ -1.138852387092216 rtol = 1e-6 + end @testset "PR w/ BMAlpha" begin system = PR(["ethane","undecane"];alpha = BMAlpha)