From e34c1153d4fac591990e95c109e8b3328d429bf5 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Sun, 8 Mar 2020 15:23:30 -0700 Subject: [PATCH] Add nitroethane groups --- .vscode/settings.json | 3 +++ Project.toml | 2 +- src/UNIFAC.jl | 26 ++++++++++++++------------ 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0533025 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "julia.environmentPath": "c:\\Users\\cclea\\source\\repos\\UNIFAC.jl" +} \ No newline at end of file diff --git a/Project.toml b/Project.toml index 141dad5..cb2fd23 100644 --- a/Project.toml +++ b/Project.toml @@ -1,4 +1,4 @@ name = "UNIFAC" uuid = "49c32154-e3b1-44a0-88e7-ff6c176fd7d7" authors = ["Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>"] -version = "0.1.0" +version = "0.1.1" diff --git a/src/UNIFAC.jl b/src/UNIFAC.jl index 0635892..cee1af9 100644 --- a/src/UNIFAC.jl +++ b/src/UNIFAC.jl @@ -8,14 +8,14 @@ export unifac function unifac(ν, x, T) # unifac takes three arguments: -# ν (that's the Greek lowercase nu) is a 42 x n Integer array where n is the +# ν (that's the Greek lowercase nu) is a 56 x n Integer array where n is the # number of species in the system. The number at ν[k,i] indicates how many # instances of subgroup k are present in a single molecule of species i # x is a 1 x n Float64 array that contains the liquid species mole fractions # T is the temperature of the system in Kelvins # Declare the UNIFAC subgroup parameters - R = Array{Float64}(undef, 42, 1) + R = Array{Float64}(undef, 56, 1) R[1] = 0.9011 R[2] = 0.6744 R[3] = 0.4469 @@ -35,8 +35,9 @@ function unifac(ν, x, T) R[34] = 0.9795 R[41] = 1.8701 R[42] = 1.6434 + R[56] = 1.7818 - Q = Array{Float64}(undef, 42, 1) + Q = Array{Float64}(undef, 56, 1) Q[1] = 0.848 Q[2] = 0.540 Q[3] = 0.228 @@ -56,9 +57,10 @@ function unifac(ν, x, T) Q[34] = 0.624 Q[41] = 1.724 Q[42] = 1.416 + Q[56] = 1.560 # Declare the subgroup interaction parameters - a = zeros(42, 42) + a = zeros(56, 56) a[1:4, 10] .= 61.13 a[1:4, 12:13] .= 76.50 a[1:4, 15] .= 986.50 @@ -153,7 +155,7 @@ function unifac(ν, x, T) end # Calculate e - e = zeros(42, size(ν, 2)) + e = zeros(56, size(ν, 2)) for i in 1:size(ν,2 ) e[:, i] = (ν[:, i] .* Q) ./ q[i] end @@ -162,22 +164,22 @@ function unifac(ν, x, T) τ = exp.(-a ./ T) # Calculate beta - β = zeros(42, size(ν, 2)) + β = zeros(56, size(ν, 2)) for i in 1:size(ν, 2) - for k in 1:42 + for k in 1:56 β[k, i] = sum(e[:, i] .* τ[:, k]) end end # Calculate Theta - Θ = zeros(42, 1) - for k in 1:42 + Θ = zeros(56, 1) + for k in 1:56 Θ[k] = sum(x .* q .* e[k, :]') / sum(x .* q) end # Calculate s - s = zeros(42, 1) - for k in 1:42 + s = zeros(56, 1) + for k in 1:56 s[k] = sum(Θ .* τ[:, k]) end @@ -191,7 +193,7 @@ function unifac(ν, x, T) for i in 1:size(ν, 2) γ_R[i] = q[i] * (1 - sum(Θ .* β[:, i] ./ s .- e[:, i] .* log.(β[:, i] ./ s))) end - + # Return the activity coefficients γ = exp.(γ_C .+ γ_R)