Wilson Activity Coefficient for Multicomponent

October 7, 2017 | Autor: Essid Abou Hligha | Categoría: Chemical Engineering, Chemical and Biological Engineering, Mixing Rules for Equations of State
Share Embed


Descripción

Program to calculate Activity Coefficient mix by Wilson Equation

Where that

is matrix

Procedure Of Program :-

OR

I prefer the second Algorithm ,not necessary calculate SumC in inner loop because it will be Zero at each full loop. Snapshot About Program Example:-

Gamma Code

Aij Code

Option Explicit Function Gamma_Wilson(X As Range, AIJ As Range) Dim i As Integer, j As Integer, k As Integer, NOC As Integer Dim AA As Variant, SUMA As Variant, SUMB As Variant, SUMC As Variant Dim CC As Variant, DD As Variant, N As Integer, Answer() As Variant Dim GA() As Variant N = X.Count ReDim Answer(1 To N) As Variant ReDim GA(1 To N) As Variant For i = 1 To N SUMB = 0: SUMC = 0 For j = 1 To N SUMA = 0 For k = 1 To N SUMA = SUMA + X(k) * AIJ(j, k) Next k SUMB = SUMB - X(j) * AIJ(j, i) / SUMA SUMC = SUMC + X(j) * AIJ(i, j) Next j GA(i) = Exp(1 + SUMB - WorksheetFunction.Ln(SUMC)) Next i 'RESULTS OUTPUT For i = 1 To N Answer(i) = GA(i) Next i Gamma_Wilson = WorksheetFunction.Transpose(Answer) End Function Option Explicit Function Aij_matrix(T As Variant, V As Range, TIJ As Range) Dim R As Variant, i As Integer, j As Integer, N As Integer Dim M As Integer, Aij() As Variant, Answer() As Variant R = 1.9872041

N = V.Count

ReDim Aij(1 To N, 1 To N) As Variant ReDim Answer(1 To N, 1 To N) As Variant

For i = 1 To N For j = 1 To N If i = j Then Aij(i, j) = 1 Else Aij(i, j) = V(j) / V(i) * Exp(-1 * TIJ(i, j) / (R * T)) End If Answer(i, j) = Aij(i, j) Next j Next i Aij_matrix = Answer End Function

Lihat lebih banyak...

Comentarios

Copyright © 2017 DATOSPDF Inc.