Closed davidemenegazzo closed 2 months ago
Yes it should be possible. I think I can update the Jacobian and residual functions to allow multiple components and just make the function more general. There is nothing magic about binaries from the VLE standpoint.
This will be sorted in concert with #142 in short order. I am writing a generalized multi-phase equilibrium routine and working out the mathematics. You will have to provide guess values for the two phases.
I have worked out the math, just need to do the implementation in teqp. It is going to be a very generalized treatment allowing for an arbitrary number of phases in equilibrium; it ends up being a pretty nice formulation that will replace the existing routines completely.
The stuff is all working, committed to https://github.com/usnistgov/teqp/tree/genphaseequil branch. Once the docs build, you should be able to see an example here: https://github.com/usnistgov/teqp/actions/runs/10512900351 in the generated docs in the algorithms section
@svenpohl1991 I know you were also interested
Complete aside from specification equations where a variable is in h,s,u
@longemen3000 I think this could be useful for Clapeyron.jl as well since a lot of the same machinery is available
i'll have to check this out!, we have a "generalized" algorithm for the bubble/dew pressure/temperatures, but not flashes, and more critically, not multiphase. on
equilibria, our current bubbledew implementations do the following:
as a first glance, i saw that you are using the first one, right? but there is additional processing related to the specification and the handling of zero compositions, right?
Yes @longemen3000, if I understand you correctly, I think my method is like your first one, although more general to permit a wide range of specification equations. We are working on a little paper working out the mathematics for future readers. The derivatives are not too painful when you are living in the isochoric formalism.
I think there are some downsides to the approach I am doing, notably, that you have more independent variables. An upside is that it is very flexible, but a very big upside is that the volume iteration is avoided. Let me know if you have questions. I should be merging into main sometime next week I think after I sort out the h, s, u derivatives which are all similar, and easy relative to some of the other specifications.
@ianhbell is the name here alright?
https://github.com/usnistgov/teqp/blob/01f5b8a7b16734c70e044b32392c746267037b32/include/teqp/algorithms/phase_equil.hpp#L543-L544C17
i see that you are calling residual derivatives for an ideal term?, shouldn't it be something like gradient_Psiig = R*T*map(log,rhovec)
?
You raise two good points. First, the gradient method was named when I didn't have any vision of being able to handle ideal-gas terms, thus the r for residual, but it operates just as well on ideal-gas terms. Second, I think your treatment is not quite correct. See the derivations in the SI of https://dx.doi.org/10.1002/aic.16074, summarized as:
Hi Ian, I would like to calculate bubble and dew points for mixtures of more than 2 components. For binary mixtures, one can use mix_VLE_Tx. May it be extended to n components?