diff --git a/Project.toml b/Project.toml index 5873953..b2498af 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.3" +version = "0.1.4" diff --git a/src/UNIFAC.jl b/src/UNIFAC.jl index 4f0b2fb..a37c173 100644 --- a/src/UNIFAC.jl +++ b/src/UNIFAC.jl @@ -13,13 +13,13 @@ Calculates the activity coefficients of the chemical species described by the UNIFAC groups in `ν`, at the liquid mole fractions `x` and temperature `T` in Kelvins. -`ν` is constructed as a 56 x n `Array{Int}`, such that `ν[i,j]` is the number +`ν` is constructed as a 57 x n `Array{Int}`, such that `ν[i,j]` is the number of times subgroup `i` appears in molecule `j`. # Example ```julia-repl -julia> ν = zeros(56, 2); +julia> ν = zeros(57, 2); julia> ν[1, 1] = 2; julia> ν[2, 1] = 1; julia> ν[33, 1] = 1; @@ -32,162 +32,845 @@ julia> unifac(ν, [0.4 0.6], 308.15) """ function unifac(ν, x, T) # unifac takes three arguments: -# ν (that's the Greek lowercase nu) is a 56 x n Integer array where n is the +# ν (that's the Greek lowercase nu) is a 57 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 -# Most subgroup parameters and interactions are taken from Smith, Van Ness, & -# Abbott, _Introduction to Chemical Engineering Thermodynamics_, 7th Ed. pp. -# 791-7. Some subgroup parameters are taken from Dr. Aston's given table, and -# some of the interactions for those species are taken from -# http://www.aim.env.uea.ac.uk/aim/info/UNIFACgroups.html +# Procedure taken from Smith, Van Ness, & # Abbott, _Introduction to Chemical +# Engineering Thermodynamics_, 7th Ed. pp. 791-7. +# Subgroup parameters and interactions are taken from Hansen et al. +# "Vapor-Liquid Equilibria by UNIFAC Group Contribution. Revision and +# Extension" _IEC Research_ 30:2352-5 (1991) + + # Declare the number of subgroups that the package supports + n = 57 + + # Declare the group definitions + g = [1:4, 5:9, 10:11, 12:14, 15, 16, 17, 18, 19:20, 21, 22:23, 24, 25:28, 29:31, + 32:34, 35:36, 37, 38:40, 41:42, 43:44, 45:47, 48:50, 51:52, 53, 54, 55:57] # Declare the UNIFAC subgroup parameters - R = Array{Float64}(undef, 56, 1) - R[1] = 0.9011 - R[2] = 0.6744 - R[3] = 0.4469 - R[4] = 0.2195 - R[10] = 0.5313 - R[12] = 1.2663 - R[13] = 1.0396 - R[15] = 1.0000 - R[17] = 0.9200 - R[19] = 1.6724 - R[20] = 1.4457 - R[25] = 1.1450 - R[26] = 0.9183 - R[27] = 0.6908 - R[32] = 1.4337 - R[33] = 1.2070 - R[34] = 0.9795 - R[41] = 1.8701 - R[42] = 1.6434 - R[56] = 1.7818 + R = [0.9011 + 0.6744 + 0.4469 + 0.2195 + 1.3454 + 1.1167 + 1.1173 + 0.8886 + 0.6605 + 0.5313 + 0.3652 + 1.2663 + 1.0396 + 0.8121 + 1.0000 + 1.4311 + 0.9200 + 0.8952 + 1.6724 + 1.4457 + 0.9980 + 1.9031 + 1.6764 + 1.2420 + 1.1450 + 0.9183 + 0.6908 + 0.9183 + 1.5959 + 1.3692 + 1.1417 + 1.4337 + 1.2070 + 0.9795 + 1.1865 + 0.9597 + 1.0600 + 2.9993 + 2.8332 + 2.6670 + 1.8701 + 1.6434 + 1.3013 + 1.5280 + 1.4654 + 1.2380 + 1.0106 + 2.2564 + 2.0606 + 1.8016 + 2.8700 + 2.6401 + 3.3900 + 1.1562 + 2.0086 + 1.7818 + 1.5544] - Q = Array{Float64}(undef, 56, 1) - Q[1] = 0.848 - Q[2] = 0.540 - Q[3] = 0.228 - Q[4] = 0.000 - Q[10] = 0.400 - Q[12] = 0.968 - Q[13] = 0.660 - Q[15] = 1.200 - Q[17] = 1.400 - Q[19] = 1.488 - Q[20] = 1.180 - Q[25] = 1.088 - Q[26] = 0.780 - Q[27] = 0.468 - Q[32] = 1.244 - Q[33] = 0.936 - Q[34] = 0.624 - Q[41] = 1.724 - Q[42] = 1.416 - Q[56] = 1.560 + Q = [0.848 + 0.540 + 0.228 + 0.000 + 1.176 + 0.867 + 0.988 + 0.676 + 0.485 + 0.400 + 0.120 + 0.968 + 0.660 + 0.348 + 1.200 + 1.432 + 1.400 + 0.680 + 1.448 + 1.180 + 0.948 + 1.728 + 1.420 + 1.188 + 1.088 + 0.780 + 0.468 + 1.100 + 1.544 + 1.236 + 0.924 + 1.244 + 0.936 + 0.624 + 0.940 + 0.632 + 0.816 + 2.113 + 1.833 + 1.553 + 1.724 + 1.416 + 1.224 + 1.532 + 1.264 + 0.952 + 0.724 + 1.998 + 1.684 + 1.448 + 2.410 + 2.184 + 2.910 + 0.844 + 1.868 + 1.560 + 1.248] # Declare the subgroup interaction parameters - a = zeros(56, 56) - a[1:4, 10] .= 61.13 - a[1:4, 12:13] .= 76.50 - a[1:4, 15] .= 986.50 - a[1:4, 17] .= 1318.00 - a[1:4, 19:20] .= 476.40 - a[1:4, 25:27] .= 251.50 - a[1:4, 32:34] .= 255.70 - a[1:4, 41:42] .= 597.00 - a[1:4, 56] .= 661.50 + a = zeros(n, n) + a[g[1], g[1]] .= 0.0 + a[g[2], g[1]] .= -35.36 + a[g[3], g[1]] .= -11.12 + a[g[4], g[1]] .= -69.70 + a[g[5], g[1]] .= 156.4 + a[g[6], g[1]] .= 16.51 + a[g[7], g[1]] .= 300.0 + a[g[8], g[1]] .= 275.8 + a[g[9], g[1]] .= 26.76 + a[g[10], g[1]] .= 505.7 + a[g[11], g[1]] .= 114.8 + a[g[12], g[1]] .= 329.3 + a[g[13], g[1]] .= 83.36 + a[g[14], g[1]] .= -30.48 + a[g[15], g[1]] .= 65.33 + a[g[16], g[1]] .= -83.98 + a[g[17], g[1]] .= 1139 + a[g[18], g[1]] .= -101.6 + a[g[19], g[1]] .= 24.82 + a[g[20], g[1]] .= 315.3 + a[g[21], g[1]] .= 91.46 + a[g[22], g[1]] .= 34.01 + a[g[23], g[1]] .= 36.70 + a[g[24], g[1]] .= -78.45 + a[g[25], g[1]] .= 106.8 + a[g[26], g[1]] .= -32.69 - a[10, 1:4] .= -11.12 - a[10, 12:13] .= 167.00 - a[10, 15] = 636.10 - a[10, 17] = 903.80 - a[10, 19:20] .= 25.77 - a[10, 25:27] .= 32.14 - a[10, 32:34] .= 122.80 - a[10, 41:42] .= 212.50 - a[10, 56] = 168.00 + a[g[1], g[2]] .= 86.02 + a[g[2], g[2]] .= 0.0 + a[g[3], g[2]] .= 3.446 + a[g[4], g[2]] .= -113.6 + a[g[5], g[2]] .= 457.0 + a[g[6], g[2]] .= -12.52 + a[g[7], g[2]] .= 496.1 + a[g[8], g[2]] .= 217.5 + a[g[9], g[2]] .= 42.92 + a[g[10], g[2]] .= 56.30 + a[g[11], g[2]] .= 132.1 + a[g[12], g[2]] .= 110.4 + a[g[13], g[2]] .= 26.51 + a[g[14], g[2]] .= 1.163 + a[g[15], g[2]] .= -28.70 + a[g[16], g[2]] .= -25.38 + a[g[17], g[2]] .= 2000 + a[g[18], g[2]] .= -47.63 + a[g[19], g[2]] .= -40.62 + a[g[20], g[2]] .= 1264 + a[g[21], g[2]] .= 40.25 + a[g[22], g[2]] .= -23.50 + a[g[23], g[2]] .= 51.06 + a[g[24], g[2]] .= 160.9 + a[g[25], g[2]] .= 70.32 + a[g[26], g[2]] .= -1.996 - a[12:13, 1:4] .= -69.70 - a[12:13, 10] .= -146.80 - a[12:13, 15] .= 803.20 - a[12:13, 17] .= 5695.00 - a[12:13, 19:20] .= -52.10 - a[12:13, 25:27] .= 213.10 - a[12:13, 32:34] .= -49.29 - a[12:13, 41:42] .= 6096.00 - a[12:13, 56] .= 3629.0 + a[g[1], g[3]] .= 61.13 + a[g[2], g[3]] .= 38.81 + a[g[3], g[3]] .= 0.0 + a[g[4], g[3]] .= -146.8 + a[g[5], g[3]] .= 89.60 + a[g[6], g[3]] .= -50.00 + a[g[7], g[3]] .= 362.3 + a[g[8], g[3]] .= 25.34 + a[g[9], g[3]] .= 140.1 + a[g[10], g[3]] .= 23.39 + a[g[11], g[3]] .= 85.84 + a[g[12], g[3]] .= 18.12 + a[g[13], g[3]] .= 52.13 + a[g[14], g[3]] .= -44.85 + a[g[15], g[3]] .= -22.31 + a[g[16], g[3]] .= -223.9 + a[g[17], g[3]] .= 247.5 + a[g[18], g[3]] .= 31.87 + a[g[19], g[3]] .= -22.97 + a[g[20], g[3]] .= 62.32 + a[g[21], g[3]] .= 4.680 + a[g[22], g[3]] .= 121.3 + a[g[23], g[3]] .= 288.5 + a[g[24], g[3]] .= -4.700 + a[g[25], g[3]] .= -97.27 + a[g[26], g[3]] .= 10.38 - a[15, 1:4] .= 156.40 - a[15, 10] = 89.60 - a[15, 12:13] .= 25.82 - a[15, 17] = 353.50 - a[15, 19:20] .= 84.00 - a[15, 25:27] .= 28.06 - a[15, 32:34] .= 42.70 - a[15, 41:42] .= 6.712 - a[15, 56] = 256.5 + a[g[1], g[4]] .= 76.50 + a[g[2], g[4]] .= 74.15 + a[g[3], g[4]] .= 167.0 + a[g[4], g[4]] .= 0.000 + a[g[5], g[4]] .= 25.82 + a[g[6], g[4]] .= -44.50 + a[g[7], g[4]] .= 377.6 + a[g[8], g[4]] .= 244.2 + a[g[9], g[4]] .= 365.8 + a[g[10], g[4]] .= 106.0 + a[g[11], g[4]] .= -170.0 + a[g[12], g[4]] .= 428.0 + a[g[13], g[4]] .= 65.69 + a[g[14], g[4]] .= 296.4 + a[g[15], g[4]] .= 223.0 + a[g[16], g[4]] .= 109.9 + a[g[17], g[4]] .= 762.8 + a[g[18], g[4]] .= 49.80 + a[g[19], g[4]] .= -138.4 + a[g[20], g[4]] .= 89.86 + a[g[21], g[4]] .= 122.9 + a[g[22], g[4]] .= 140.8 + a[g[23], g[4]] .= 69.90 + a[g[24], g[4]] .= 134.7 + a[g[25], g[4]] .= 402.5 + a[g[26], g[4]] .= -97.05 - a[17, 1:4] .= 300.00 - a[17, 10] = 362.30 - a[17, 12:13] .= 377.60 - a[17, 15] = -229.10 - a[17, 19:20] .= -195.40 - a[17, 25:27] .= 540.50 - a[17, 32:34] .= 168.00 - a[17, 41:42] .= 112.60 - a[17, 56] = 220.60 + a[g[1], g[5]] .= 986.5 + a[g[2], g[5]] .= 524.1 + a[g[3], g[5]] .= 636.1 + a[g[4], g[5]] .= 803.2 + a[g[5], g[5]] = 0.000 + a[g[6], g[5]] = 249.1 + a[g[7], g[5]] = -229.1 + a[g[8], g[5]] = -451.6 + a[g[9], g[5]] .= 164.5 + a[g[10], g[5]] = 529.0 + a[g[11], g[5]] .= 245.4 + a[g[12], g[5]] = 139.4 + a[g[13], g[5]] .= 237.7 + a[g[14], g[5]] .= -242.8 + a[g[15], g[5]] .= -150.0 + a[g[16], g[5]] .= 28.60 + a[g[17], g[5]] = -17.40 + a[g[18], g[5]] .= -132.3 + a[g[19], g[5]] .= 185.4 + a[g[20], g[5]] .= -151.0 + a[g[21], g[5]] .= 562.2 + a[g[22], g[5]] .= 527.6 + a[g[23], g[5]] .= 742.1 + a[g[24], g[5]] = 856.3 + a[g[25], g[5]] = 325.7 + a[g[26], g[5]] .= 261.6 - a[19:20, 1:4] .= 26.79 - a[19:20, 10] .= 140.10 - a[19:20, 12:13] .= 365.80 - a[19:20, 15] .= 164.50 - a[19:20, 17] .= 472.50 - a[19:20, 25:27] .= -103.60 - a[19:20, 32:34] .= -174.20 - a[19:20, 41:42] .= 481.70 - a[19:20, 56] .= 137.50 + a[g[1], g[6]] .= 697.2 + a[g[2], g[6]] .= 787.6 + a[g[3], g[6]] .= 637.4 + a[g[4], g[6]] .= 603.3 + a[g[5], g[6]] = -137.1 + a[g[6], g[6]] = 0.000 + a[g[7], g[6]] = 289.6 + a[g[8], g[6]] = -265.2 + a[g[9], g[6]] .= 108.7 + a[g[10], g[6]] = -340.2 + a[g[11], g[6]] .= 249.6 + a[g[12], g[6]] = 227.8 + a[g[13], g[6]] .= 238.4 + a[g[14], g[6]] .= -481.7 + a[g[15], g[6]] .= -370.3 + a[g[16], g[6]] .= -406.8 + a[g[17], g[6]] = -118.1 + a[g[18], g[6]] .= -378.2 + a[g[19], g[6]] .= 162.6 + a[g[20], g[6]] .= 339.8 + a[g[21], g[6]] .= 529.0 + a[g[22], g[6]] .= 669.9 + a[g[23], g[6]] .= 649.1 + a[g[24], g[6]] = 709.6 + a[g[25], g[6]] = 612.8 + a[g[26], g[6]] .= 252.6 - a[25:27, 1:4] .= 83.36 - a[25:27, 10] .= 52.13 - a[25:27, 12:13] .= 65.69 - a[25:27, 15] .= 237.70 - a[25:27, 17] .= -314.70 - a[25:27, 19:20] .= 191.10 - a[25:27, 32:34] .= 251.50 - a[25:27, 41:42] .= -18.51 - a[25:27, 56] .= 95.108 + a[g[1], g[7]] .= 1318 + a[g[2], g[7]] .= 270.6 + a[g[3], g[7]] .= 903.8 + a[g[4], g[7]] .= 5695 + a[g[5], g[7]] = 353.5 + a[g[6], g[7]] = -181.0 + a[g[7], g[7]] = 0.0 + a[g[8], g[7]] = -601.8 + a[g[9], g[7]] .= 472.5 + a[g[10], g[7]] = 480.8 + a[g[11], g[7]] .= 200.8 + a[g[12], g[7]] = 0.0 # actually, missing + a[g[13], g[7]] .= -314.7 + a[g[14], g[7]] .= -330.4 + a[g[15], g[7]] .= -448.2 + a[g[16], g[7]] .= -598.8 + a[g[17], g[7]] = -341.6 + a[g[18], g[7]] .= -332.9 + a[g[19], g[7]] .= 242.8 + a[g[20], g[7]] .= -66.17 + a[g[21], g[7]] .= 698.2 + a[g[22], g[7]] .= 708.7 + a[g[23], g[7]] .= 626.8 + a[g[24], g[7]] = 1201 + a[g[25], g[7]] = -274.5 + a[g[26], g[7]] .= 417.9 - a[32:34, 1:4] .= 65.33 - a[32:34, 10] .= -22.31 - a[32:34, 12:13] .= 223.00 - a[32:34, 15] .= -150.00 - a[32:34, 17] .= -448.20 - a[32:34, 19:20] .= 394.60 - a[32:34, 25:27] .= -56.08 - a[32:34, 41:42] .= 147.10 + a[g[1], g[8]] .= 1333 + a[g[2], g[8]] .= 526.1 + a[g[3], g[8]] .= 1329 + a[g[4], g[8]] .= 884.9 + a[g[5], g[8]] = -259.7 + a[g[6], g[8]] = -101.7 + a[g[7], g[8]] = 324.5 + a[g[8], g[8]] = 0.0 + a[g[9], g[8]] .= -133.1 + a[g[10], g[8]] = -155.6 + a[g[11], g[8]] .= -36.72 + a[g[12], g[8]] = 0.0 # actually, missing + a[g[13], g[8]] .= -178.5 + a[g[14], g[8]] .= 0.0 # actually, missing + a[g[15], g[8]] .= 0.0 # actually, missing + a[g[16], g[8]] .= 0.0 # actually, missing + a[g[17], g[8]] = -253.1 + a[g[18], g[8]] .= -341.6 + a[g[19], g[8]] .= 0.0 # actually, missing + a[g[20], g[8]] .= -11.00 + a[g[21], g[8]] .= 0.0 # actually, missing + a[g[22], g[8]] .= 0.0 # actually, missing + a[g[23], g[8]] .= 0.0 # actually, missing + a[g[24], g[8]] = 10000 + a[g[25], g[8]] = 622.3 + a[g[26], g[8]] .= 0.0 # actually, missing - a[41:42, 1:4] .= 24.82 - a[41:42, 10] .= -22.97 - a[41:42, 12:13] .= -138.40 - a[41:42, 15] .= 185.40 - a[41:42, 17] .= 242.80 - a[41:42, 19:20] .= -287.50 - a[41:42, 25:27] .= 38.81 - a[41:42, 32:34] .= -108.50 - a[41:41, 56] .= -0.5150 + a[g[1], g[9]] .= 476.4 + a[g[2], g[9]] .= 182.6 + a[g[3], g[9]] .= 25.77 + a[g[4], g[9]] .= -52.10 + a[g[5], g[9]] .= 84.00 + a[g[6], g[9]] .= 23.39 + a[g[7], g[9]] .= -195.4 + a[g[8], g[9]] .= -356.1 + a[g[9], g[9]] .= 0.0 + a[g[10], g[9]] .= 128.0 + a[g[11], g[9]] .= 372.2 + a[g[12], g[9]] .= 385.4 + a[g[13], g[9]] .= 191.1 + a[g[14], g[9]] .= 0.0 # actually, missing + a[g[15], g[9]] .= 394.6 + a[g[16], g[9]] .= 225.3 + a[g[17], g[9]] .= -450.3 + a[g[18], g[9]] .= 29.10 + a[g[19], g[9]] .= -287.5 + a[g[20], g[9]] .= -297.5 + a[g[21], g[9]] .= 286.3 + a[g[22], g[9]] .= 82.86 + a[g[23], g[9]] .= 552.1 + a[g[24], g[9]] .= 372.0 + a[g[25], g[9]] .= 518.4 + a[g[26], g[9]] .= -142.6 - a[56, 1:4] .= -32.690 - a[56, 10] = 10.380 - a[56, 12:13] .= -97.050 - a[56, 15] = 261.60 - a[56, 17] = 417.90 - a[56, 19:20] .= -142.60 - a[56, 25:27] .= -94.490 - a[56, 41:42] .= 0.28270 + a[g[1], g[10]] .= 677.0 + a[g[2], g[10]] .= 448.8 + a[g[3], g[10]] .= 347.3 + a[g[4], g[10]] .= 586.8 + a[g[5], g[10]] = -203.6 + a[g[6], g[10]] = 306.4 + a[g[7], g[10]] = -116.0 + a[g[8], g[10]] = -271.1 + a[g[9], g[10]] .= -37.36 + a[g[10], g[10]] = 0.0 + a[g[11], g[10]] .= 185.1 + a[g[12], g[10]] = -236.5 + a[g[13], g[10]] .= -7.838 + a[g[14], g[10]] .= 0.0 # actually, missing + a[g[15], g[10]] .= 0.0 # actually, missing + a[g[16], g[10]] .= 0.0 # actually, missing + a[g[17], g[10]] = 0.0 # actually, missing + a[g[18], g[10]] .= 0.0 # actually, missing + a[g[19], g[10]] .= 0.0 # actually, missing + a[g[20], g[10]] .= -165.5 + a[g[21], g[10]] .= -47.51 + a[g[22], g[10]] .= 190.6 + a[g[23], g[10]] .= 242.8 + a[g[24], g[10]] = 0.0 # actually, missing + a[g[25], g[10]] = 0.0 # actually, missing + a[g[26], g[10]] .= 0.0 # actually, missing + + a[g[1], g[11]] .= 232.1 + a[g[2], g[11]] .= 37.85 + a[g[3], g[11]] .= 5.994 + a[g[4], g[11]] .= 5688 + a[g[5], g[11]] .= 101.1 + a[g[6], g[11]] .= -10.72 + a[g[7], g[11]] .= 72.87 + a[g[8], g[11]] .= -499.4 + a[g[9], g[11]] .= -213.7 + a[g[10], g[11]] .= -110.3 + a[g[11], g[11]] .= 0.0 + a[g[12], g[11]] .= 1167 + a[g[13], g[11]] .= 461.3 + a[g[14], g[11]] .= 0.0 # actually, missing + a[g[15], g[11]] .= 136.0 + a[g[16], g[11]] .= 2889 + a[g[17], g[11]] .= -294.8 + a[g[18], g[11]] .= 0.0 # actually, missing + a[g[19], g[11]] .= -266.6 + a[g[20], g[11]] .= -256.3 + a[g[21], g[11]] .= 35.38 + a[g[22], g[11]] .= -133.0 + a[g[23], g[11]] .= 176.5 + a[g[24], g[11]] .= 129.5 + a[g[25], g[11]] .= -171.1 + a[g[26], g[11]] .= 129.3 + + a[g[1], g[12]] .= 507.0 + a[g[2], g[12]] .= 333.5 + a[g[3], g[12]] .= 287.1 + a[g[4], g[12]] .= 197.8 + a[g[5], g[12]] = 267.8 + a[g[6], g[12]] = 179.7 + a[g[7], g[12]] = 0.0 # actually, missing + a[g[8], g[12]] = 0.0 # actually, missing + a[g[9], g[12]] .= -190.4 + a[g[10], g[12]] = 766.0 + a[g[11], g[12]] .= -241.8 + a[g[12], g[12]] = 0.0 + a[g[13], g[12]] .= 457.3 + a[g[14], g[12]] .= 0.0 # actually, missing + a[g[15], g[12]] .= 0.0 # actually, missing + a[g[16], g[12]] .= 0.0 # actually, missing + a[g[17], g[12]] = 0.0 # actually, missing + a[g[18], g[12]] .= 554.4 + a[g[19], g[12]] .= 99.37 + a[g[20], g[12]] .= 193.9 + a[g[21], g[12]] .= 0.0 # actually, missing + a[g[22], g[12]] .= 0.0 # actually, missing + a[g[23], g[12]] .= 235.6 + a[g[24], g[12]] = 351.9 + a[g[25], g[12]] = 383.3 + a[g[26], g[12]] .= 0.0 # actually, missing + + a[g[1], g[13]] .= 251.5 + a[g[2], g[13]] .= 214.5 + a[g[3], g[13]] .= 32.14 + a[g[4], g[13]] .= 213.1 + a[g[5], g[13]] .= 28.06 + a[g[6], g[13]] .= -128.6 + a[g[7], g[13]] .= 540.5 + a[g[8], g[13]] .= 162.9 + a[g[9], g[13]] .= 103.6 + a[g[10], g[13]] .= 304.1 + a[g[11], g[13]] .= -235.7 + a[g[12], g[13]] .= -234.0 + a[g[13], g[13]] .= 0.0 + a[g[14], g[13]] .= 222.1 + a[g[15], g[13]] .= -56.08 + a[g[16], g[13]] .= -194.1 + a[g[17], g[13]] .= 0.0 # actually, missing + a[g[18], g[13]] .= -156.1 + a[g[19], g[13]] .= 38.81 + a[g[20], g[13]] .= -338.5 + a[g[21], g[13]] .= 225.4 + a[g[22], g[13]] .= -197.7 + a[g[23], g[13]] .= -20.93 + a[g[24], g[13]] .= 113.9 + a[g[25], g[13]] .= -25.15 + a[g[26], g[13]] .= -94.49 + + a[g[1], g[14]] .= 391.5 + a[g[2], g[14]] .= 240.9 + a[g[3], g[14]] .= 161.7 + a[g[4], g[14]] .= 19.02 + a[g[5], g[14]] .= 8.642 + a[g[6], g[14]] .= 359.3 + a[g[7], g[14]] .= 48.89 + a[g[8], g[14]] .= 0.0 # actually, missing + a[g[9], g[14]] .= 0.0 # actually, missing + a[g[10], g[14]] .= 0.0 # actually, missing + a[g[11], g[14]] .= 0.0 # actually, missing + a[g[12], g[14]] .= 0.0 # actually, missing + a[g[13], g[14]] .= -78.36 + a[g[14], g[14]] .= 0.0 + a[g[15], g[14]] .= 127.4 + a[g[16], g[14]] .= 38.89 + a[g[17], g[14]] .= -15.07 + a[g[18], g[14]] .= 0.0 # actually, missing + a[g[19], g[14]] .= -157.3 + a[g[20], g[14]] .= 0.0 # actually, missing + a[g[21], g[14]] .= 131.2 + a[g[22], g[14]] .= 0.0 # actually, missing + a[g[23], g[14]] .= 0.0 # actually, missing + a[g[24], g[14]] .= 261.1 + a[g[25], g[14]] .= 108.5 + a[g[26], g[14]] .= 0.0 # actually, missing + + a[g[1], g[15]] .= 255.7 + a[g[2], g[15]] .= 163.9 + a[g[3], g[15]] .= 122.8 + a[g[4], g[15]] .= -49.29 + a[g[5], g[15]] .= 42.70 + a[g[6], g[15]] .= -20.98 + a[g[7], g[15]] .= 168.0 + a[g[8], g[15]] .= 0.0 # actually, missing + a[g[9], g[15]] .= -174.2 + a[g[10], g[15]] .= 0.0 # actually, missing + a[g[11], g[15]] .= -73.50 + a[g[12], g[15]] .= 0.0 # actually, missing + a[g[13], g[15]] .= 251.5 + a[g[14], g[15]] .= -107.2 + a[g[15], g[15]] .= 0.0 + a[g[16], g[15]] .= 865.9 + a[g[17], g[15]] .= 0.0 # actually, missing + a[g[18], g[15]] .= 0.0 # actually, missing + a[g[19], g[15]] .= -108.5 + a[g[20], g[15]] .= 0.0 # actually, missing + a[g[21], g[15]] .= 0.0 # actually, missing + a[g[22], g[15]] .= 0.0 # actually, missing + a[g[23], g[15]] .= 0.0 # actually, missing + a[g[24], g[15]] .= 91.13 + a[g[25], g[15]] .= 102.2 + a[g[26], g[15]] .= 0.0 # actually, missing + + a[g[1], g[16]] .= 206.6 + a[g[2], g[16]] .= 61.11 + a[g[3], g[16]] .= 90.49 + a[g[4], g[16]] .= 23.50 + a[g[5], g[16]] .= -323.0 + a[g[6], g[16]] .= 53.90 + a[g[7], g[16]] .= 304.0 + a[g[8], g[16]] .= 0.0 # actually, missing + a[g[9], g[16]] .= -169.0 + a[g[10], g[16]] .= 0.0 # actually, missing + a[g[11], g[16]] .= -196.7 + a[g[12], g[16]] .= 0.0 # actually, missing + a[g[13], g[16]] .= 5422 + a[g[14], g[16]] .= -41.11 + a[g[15], g[16]] .= -189.2 + a[g[16], g[16]] .= 0.0 + a[g[17], g[16]] .= 0.0 # actually, missing + a[g[18], g[16]] .= 0.0 # actually, missing + a[g[19], g[16]] .= 0.0 # actually, missing + a[g[20], g[16]] .= 0.0 # actually, missing + a[g[21], g[16]] .= 0.0 # actually, missing + a[g[22], g[16]] .= -141.4 + a[g[23], g[16]] .= -293.7 + a[g[24], g[16]] .= 316.9 + a[g[25], g[16]] .= 2951 + a[g[26], g[16]] .= 0.0 # actually, missing + + a[g[1], g[17]] .= 920.7 + a[g[2], g[17]] .= 749.3 + a[g[3], g[17]] .= 648.2 + a[g[4], g[17]] .= 664.2 + a[g[5], g[17]] = -52.39 + a[g[6], g[17]] = 489.7 + a[g[7], g[17]] = 243.2 + a[g[8], g[17]] = 119.9 + a[g[9], g[17]] .= 6201 + a[g[10], g[17]] = 0.0 # actually, missing + a[g[11], g[17]] .= 475.5 + a[g[12], g[17]] = 0.0 # actually, missing + a[g[13], g[17]] .= 0.0 # actually, missing + a[g[14], g[17]] .= -200.7 + a[g[15], g[17]] .= 0.0 # actually, missing + a[g[16], g[17]] .= 0.0 # actually, missing + a[g[17], g[17]] = 0.0 + a[g[18], g[17]] .= 117.4 + a[g[19], g[17]] .= 777.4 + a[g[20], g[17]] .= 493.8 + a[g[21], g[17]] .= 429.7 + a[g[22], g[17]] .= 140.8 + a[g[23], g[17]] .= 0.0 # actually, missing + a[g[24], g[17]] = 898.2 + a[g[25], g[17]] = 334.9 + a[g[26], g[17]] .= 0.0 # actually, missing + + a[g[1], g[18]] .= 287.8 + a[g[2], g[18]] .= 280.5 + a[g[3], g[18]] .= -4.449 + a[g[4], g[18]] .= 52.80 + a[g[5], g[18]] .= 170.0 + a[g[6], g[18]] .= 580.5 + a[g[7], g[18]] .= 459.0 + a[g[8], g[18]] .= -305.5 + a[g[9], g[18]] .= 7.941 + a[g[10], g[18]] .= 0.0 # actually, missing + a[g[11], g[18]] .= 0.0 # actually, missing + a[g[12], g[18]] .= -233.4 + a[g[13], g[18]] .= 213.2 + a[g[14], g[18]] .= 0.0 # actually, missing + a[g[15], g[18]] .= 0.0 # actually, missing + a[g[16], g[18]] .= 0.0 # actually, missing + a[g[17], g[18]] .= 89.70 + a[g[18], g[18]] .= 0.0 + a[g[19], g[18]] .= 134.3 + a[g[20], g[18]] .= -313.5 + a[g[21], g[18]] .= 0.0 # actually, missing + a[g[22], g[18]] .= 587.3 + a[g[23], g[18]] .= 18.98 + a[g[24], g[18]] .= 368.5 + a[g[25], g[18]] .= 0.0 # actually, missing + a[g[26], g[18]] .= 0.0 # actually, missing + + a[g[1], g[19]] .= 597.0 + a[g[2], g[19]] .= 336.9 + a[g[3], g[19]] .= 212.5 + a[g[4], g[19]] .= 6096 + a[g[5], g[19]] .= 6.712 + a[g[6], g[19]] .= 53.28 + a[g[7], g[19]] .= 122.6 + a[g[8], g[19]] .= 0.0 # actually, missing + a[g[9], g[19]] .= 481.7 + a[g[10], g[19]] .= 0.0 # actually, missing + a[g[11], g[19]] .= 494.6 + a[g[12], g[19]] .= -47.25 + a[g[13], g[19]] .= -18.51 + a[g[14], g[19]] .= 358.9 + a[g[15], g[19]] .= 147.1 + a[g[16], g[19]] .= 0.0 # actually, missing + a[g[17], g[19]] .= -281.6 + a[g[18], g[19]] .= -169.7 + a[g[19], g[19]] .= 0.0 + a[g[20], g[19]] .= 0.0 # actually, missing + a[g[21], g[19]] .= 54.32 + a[g[22], g[19]] .= 258.6 + a[g[23], g[19]] .= 74.04 + a[g[24], g[19]] .= 492.0 + a[g[25], g[19]] .= 363.5 + a[g[26], g[19]] .= 0.28300 + + a[g[1], g[20]] .= 663.5 + a[g[2], g[20]] .= 318.9 + a[g[3], g[20]] .= 537.4 + a[g[4], g[20]] .= 872.3 + a[g[5], g[20]] .= 199.0 + a[g[6], g[20]] .= -202.0 + a[g[7], g[20]] .= -14.09 + a[g[8], g[20]] .= 408.9 + a[g[9], g[20]] .= 669.4 + a[g[10], g[20]] .= 497.5 + a[g[11], g[20]] .= 660.2 + a[g[12], g[20]] .= -268.1 + a[g[13], g[20]] .= 664.6 + a[g[14], g[20]] .= 0.0 # actually, missing + a[g[15], g[20]] .= 0.0 # actually, missing + a[g[16], g[20]] .= 0.0 # actually, missing + a[g[17], g[20]] .= -396.0 + a[g[18], g[20]] .= -153.7 + a[g[19], g[20]] .= 0.0 # actually, missing + a[g[20], g[20]] .= 0.0 + a[g[21], g[20]] .= 519.1 + a[g[22], g[20]] .= 543.3 + a[g[23], g[20]] .= 504.2 + a[g[24], g[20]] .= 631.0 + a[g[25], g[20]] .= 993.4 + a[g[26], g[20]] .= 0.0 # actually, missing + + a[g[1], g[21]] .= 35.93 + a[g[2], g[21]] .= -36.87 + a[g[3], g[21]] .= -18.81 + a[g[4], g[21]] .= -114.1 + a[g[5], g[21]] .= 75.62 + a[g[6], g[21]] .= -38.32 + a[g[7], g[21]] .= 325.4 + a[g[8], g[21]] .= 0.0 # actually, missing + a[g[9], g[21]] .= -191.7 + a[g[10], g[21]] .= 751.9 + a[g[11], g[21]] .= -34.74 + a[g[12], g[21]] .= 0.0 # actually, missing + a[g[13], g[21]] .= 301.1 + a[g[14], g[21]] .= -82.92 + a[g[15], g[21]] .= 0.0 # actually, missing + a[g[16], g[21]] .= 0.0 # actually, missing + a[g[17], g[21]] .= 287.0 + a[g[18], g[21]] .= 0.0 # actually, missing + a[g[19], g[21]] .= 4.933 + a[g[20], g[21]] .= 13.41 + a[g[21], g[21]] .= 0.0 + a[g[22], g[21]] .= -84.53 + a[g[23], g[21]] .= -157.1 + a[g[24], g[21]] .= 11.80 + a[g[25], g[21]] .= -129.7 + a[g[26], g[21]] .= 113.0 + + a[g[1], g[22]] .= 53.79 + a[g[2], g[22]] .= 58.55 + a[g[3], g[22]] .= -144.4 + a[g[4], g[22]] .= -111.0 + a[g[5], g[22]] .= 65.28 + a[g[6], g[22]] .= -102.5 + a[g[7], g[22]] .= 370.4 + a[g[8], g[22]] .= 0.0 # actually, missing + a[g[9], g[22]] .= -130.3 + a[g[10], g[22]] .= 67.52 + a[g[11], g[22]] .= 108.9 + a[g[12], g[22]] .= 0.0 # actually, missing + a[g[13], g[22]] .= 137.8 + a[g[14], g[22]] .= 0.0 # actually, missing + a[g[15], g[22]] .= 0.0 # actually, missing + a[g[16], g[22]] .= -73.85 + a[g[17], g[22]] .= -111.0 + a[g[18], g[22]] .= -351.6 + a[g[19], g[22]] .= -152.7 + a[g[20], g[22]] .= -44.70 + a[g[21], g[22]] .= 108.3 + a[g[22], g[22]] .= 0.0 + a[g[23], g[22]] .= 0.0 + a[g[24], g[22]] .= 17.97 + a[g[25], g[22]] .= -8.309 + a[g[26], g[22]] .= -9.639 + + a[g[1], g[23]] .= 24.90 + a[g[2], g[23]] .= -13.99 + a[g[3], g[23]] .= -231.9 + a[g[4], g[23]] .= -80.25 + a[g[5], g[23]] .= -98.12 + a[g[6], g[23]] .= -139.4 + a[g[7], g[23]] .= 359.4 + a[g[8], g[23]] .= 0.0 # actually, missing + a[g[9], g[23]] .= -354.6 + a[g[10], g[23]] .= -483.7 + a[g[11], g[23]] .= -209.7 + a[g[12], g[23]] .= -126.2 + a[g[13], g[23]] .= -154.3 + a[g[14], g[23]] .= 0.0 # actually, missing + a[g[15], g[23]] .= 0.0 # actually, missing + a[g[16], g[23]] .= -352.9 + a[g[17], g[23]] .= 0.0 # actually, missing + a[g[18], g[23]] .= -114.7 + a[g[19], g[23]] .= -15.62 + a[g[20], g[23]] .= 39.63 + a[g[21], g[23]] .= 249.6 + a[g[22], g[23]] .= 0.0 + a[g[23], g[23]] .= 0.0 + a[g[24], g[23]] .= 51.90 + a[g[25], g[23]] .= -0.2266 + a[g[26], g[23]] .= 0.0 # actually, missing + + a[g[1], g[24]] .= 104.3 + a[g[2], g[24]] .= -109.7 + a[g[3], g[24]] .= 3.0 + a[g[4], g[24]] .= -141.3 + a[g[5], g[24]] = 143.1 + a[g[6], g[24]] = -44.76 + a[g[7], g[24]] = 497.5 + a[g[8], g[24]] = 1827 + a[g[9], g[24]] .= -39.20 + a[g[10], g[24]] = 0.0 # actually, missing + a[g[11], g[24]] .= 54.57 + a[g[12], g[24]] = 179.7 + a[g[13], g[24]] .= 47.67 + a[g[14], g[24]] .= -99.81 + a[g[15], g[24]] .= 71.23 + a[g[16], g[24]] .= -262.0 + a[g[17], g[24]] = 882.0 + a[g[18], g[24]] .= -205.3 + a[g[19], g[24]] .= -54.86 + a[g[20], g[24]] .= 183.4 + a[g[21], g[24]] .= 62.42 + a[g[22], g[24]] .= 56.33 + a[g[23], g[24]] .= -30.10 + a[g[24], g[24]] = 0.0 + a[g[25], g[24]] = 248.4 + a[g[26], g[24]] .= -34.68 + + a[g[1], g[25]] .= 11.44 + a[g[2], g[25]] .= 100.1 + a[g[3], g[25]] .= 187.0 + a[g[4], g[25]] .= -211.0 + a[g[5], g[25]] = 123.5 + a[g[6], g[25]] = -28.25 + a[g[7], g[25]] = 133.9 + a[g[8], g[25]] = 6915 + a[g[9], g[25]] .= -119.8 + a[g[10], g[25]] = 0.0 # actually, missing + a[g[11], g[25]] .= 442.4 + a[g[12], g[25]] = 24.28 + a[g[13], g[25]] .= 134.8 + a[g[14], g[25]] .= 30.05 + a[g[15], g[25]] .= -18.93 + a[g[16], g[25]] .= -181.9 + a[g[17], g[25]] = 617.5 + a[g[18], g[25]] .= 0.0 # actually, missing + a[g[19], g[25]] .= -4.624 + a[g[20], g[25]] .= -79.08 + a[g[21], g[25]] .= 153.0 + a[g[22], g[25]] .= 223.1 + a[g[23], g[25]] .= 192.1 + a[g[24], g[25]] = -75.97 + a[g[25], g[25]] = 0.0 + a[g[26], g[25]] .= 132.9 + + a[g[1], g[26]] .= 661.5 + a[g[2], g[26]] .= 357.5 + a[g[3], g[26]] .= 168.0 + a[g[4], g[26]] .= 3629 + a[g[5], g[26]] .= 256.5 + a[g[6], g[26]] .= 75.14 + a[g[7], g[26]] .= 220.6 + a[g[8], g[26]] .= 0.0 # actually, missing + a[g[9], g[26]] .= 137.5 + a[g[10], g[26]] .= 0.0 # actually, missing + a[g[11], g[26]] .= -81.13 + a[g[12], g[26]] .= 0.0 # actually, missing + a[g[13], g[26]] .= 95.18 + a[g[14], g[26]] .= 0.0 # actually, missing + a[g[15], g[26]] .= 0.0 # actually, missing + a[g[16], g[26]] .= 0.0 # actually, missing + a[g[17], g[26]] .= 0.0 # actually, missing + a[g[18], g[26]] .= 0.0 # actually, missing + a[g[19], g[26]] .= -0.5150 + a[g[20], g[26]] .= 0.0 # actually, missing + a[g[21], g[26]] .= 32.73 + a[g[22], g[26]] .= 108.9 + a[g[23], g[26]] .= 0.0 # actually, missing + a[g[24], g[26]] .= 490.9 + a[g[25], g[26]] .= 132.7 + a[g[26], g[26]] .= 0.0 # Calculate r r = zeros(1, size(ν, 2)) @@ -202,7 +885,7 @@ function unifac(ν, x, T) end # Calculate e - e = zeros(56, size(ν, 2)) + e = zeros(n, size(ν, 2)) for i in 1:size(ν,2 ) e[:, i] = (ν[:, i] .* Q) ./ q[i] end @@ -211,22 +894,22 @@ function unifac(ν, x, T) τ = exp.(-a ./ T) # Calculate beta - β = zeros(56, size(ν, 2)) + β = zeros(n, size(ν, 2)) for i in 1:size(ν, 2) - for k in 1:56 + for k in 1:n β[k, i] = sum(e[:, i] .* τ[:, k]) end end # Calculate Theta - Θ = zeros(56, 1) - for k in 1:56 + Θ = zeros(n, 1) + for k in 1:n Θ[k] = sum(x .* q .* e[k, :]') / sum(x .* q) end # Calculate s - s = zeros(56, 1) - for k in 1:56 + s = zeros(n, 1) + for k in 1:n s[k] = sum(Θ .* τ[:, k]) end