Hello,
I am trying to write a program for the Calculation of Vapor Liquid Equilibrium by using energy and mass balances. I am currently using NLsolve.jl.
My problem is that I want the system of equations to be created automatically. Whenever I add a new component to my mixture, I increase the number of entries in the solution vector by 2 ( 2 extra equations ).
The first thing I am trying to do (and failing to do) is create the function for NLsolve without writing the balances into this said function.
a = :(F[1] = x[1] + x[2] -1)
b = :(F[2] = x[1]*(1-x[3]) + x[2] * (1-x[4]) - 0.5)
c = :(F[3] = getindex(K,1)*x[3] - x[4])
d = :(F[4] = getindex(K,2)*(1-x[3]) - (1-x[4]))
function nlsolve!(F, x)
a
b
c
d
end
This probably doesn`t make sense since I will also need a function with variable length, but I did not know where to start.
I am new to writing code and I am sorry if this is a stupid question.
Thanks a lot,
Ulrich