I'm going to demonstrate here how to solve a system of non-linear equations, the algebraic
equations, that result when we model vapor-liquid equilibrium for a binary system using the
Wilson equation to get the activity coefficient for the liquid phase.
So this is an example that is already explained in a separate video and I just reproduced
the numbers here from the problem statement and then the information that was given and
essentially have ten equations, as indicated here, and ten unknowns.
They're non-linear.
We have log terms in equations six and seven, also in equations one and two.
And then we have exponentials in nine and ten.
Temperature is unknown and it's appearing in the exponential.
And so we have the equations now written basically in the form used in POLYMATH to solve them,
so these are just copied form the POLYMATH solution.
And the important thing to realize is the way POLYMATH is going to solve these equations
is to say bring everything into one side of the equation, for example, this equation Y1
plus Y2 equals 1.
Well what we're going to write is 1 minus Y1 minus Y2 equals 0.
And then in the solution in POLYMATH we're going to write it as a function of something
equals 1 minus Y1 minus Y2.
And what POLYMATH is trying to do is set this function equal to 0.
And so the function is used to identify the 10 unknowns.
So it doesn't matter, you could put Y1 here or Y2.
I happen to have chosen to put T here but it's arbitrary.
I have 10 equations so I have 10 places to place my 10 unknowns, which is where doesn't
really matter.
It obviously seems easier for the equation for saturation pressure component 2 to make
this saturation pressure of the unknown just to make it easier to see what's happening
in the problem, but Y1 and Y2 are identified as the unknowns in the equations 3 and 4 and
then temperature in 5.
And then I've used the notation where in order to relate the equations, so this function
W, I used G for these symbols.
So G21 to make it easy to put into POLYMATH.
And so I'll solve these equations simultaneously and then POLYMATH then, what we have here
is a POLYMATH program.
I have to put in all of the parameters.
The pressure, the gas constant, the mole fractions of the liquid phase, these parameters for
the Wilson equation, the molar volumes.
And then I've written these exact equations that I just showed you, function of P2-sat
where what I want on the right side is this equation to be equal to zero.
That's what POLYMATH is going to solve for.
And the only thing that we haven't explained that's addition in POLYMATH is we have to
make an initial guess for the value of P2-sat.
So I arbitrarily put 50 here.
This notation P2-sat with the parenthesis and the 0 basically means this is my initial
guess for P2-sat.
And so I've listed for mole fraction two 0.5, one 0.6.
Well they don't add to 1 but that's okay, they're just guesses to get it started.
Initial temperature of the gas.
Guesses for the parameters.
Guesses for the activity coefficients.
It's non-linear, we don't expect them to be one 1.
I have no idea ahead of time the value of W, arbitrarily guessed 0.5.
And then from this equation when POLYMATH tells it to run the 10 equations, 10 unknowns,
it will give us the variables to solve for.
In particular, we are interested in the temperature, this is in Kelvin, and the mole fractions
in the vapor phase.
And it will give us more significant figures, I've reduced it here just to make it easier
to see.
Also indicates what we used as an initial guess and certainly they aren't necessarily
close.
This is how good the answer is.
So that function that is trying to set equal to zero, well it set it to 10 to the minus
16, 10 to the minus 12, so obviously within our accuracy this is excellent.
We've been able to sole non-linear, algebraic equations.
It takes POLYMATH less than a second to do the solution.
And then the other advantage of having this program is we could vary things.
We could pick a different liquid composition and it would just as rapidly solve for the
vapor composition and the temperature.