If the brineair fluidsystem is used with the mpnc model you get a singular matrix immediately. The 2pncmin/nonisothermal test works using the brineair fluidsystem and the 2pncmin model.
On the branch fix/mpnc-with-brineair you can find this test now using the mpnc model. Here the mineralization part is removed. On the branch fix/mpncmin-with-brineair the test is using a mpncmin model. In both cases a singular matrix is obtained immediately.
Edited
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
Did you initialize all variables consistently (in particular fugacities which are not privars in the 2pnc model). Can you find out if and if yes which parts of the residual are inf/nan?
The problem comes from the compositionfromfugacities constraintsolver which mpnc uses to calculate phase composition. If the fugacity coefficient for NaCl is 0 (for the liquid phase) we are dividing by 0.
In 2pncmin this also is an issue if we use areas where only the gas phase is present because then we also use this constraint solver.
I thought about the problem some more: I think the concept of fugacities as primary variables does not make sense if one of the fugacity coefficients is 0. We could avoid this by setting the mole fraction as a primary variable for the component in case a fugacity coefficient is 0. This would then mean however, that mpnc uses fugacities for all other primary variables only mole fraction for e.g. salt. This is probably not what we want?
Changing mpnc to mole fractions for all components is however also not so easy because then one had to define for which phase the mole fractions are set and also which phase state there is. But the phase state is not so easy for an mp system. This knowledge currently is in the problem, when one has to select the correct constraintsolver to compute the fugacities.
I would propose to set up a new system 2pnc with the ncp (instead of a phase switch). This would then solve the problem for the porenetwork models, that work better without a primary variables switch.
I can also try to implement such a model. It would mean for a 2p3c system that we solve 5 equations and use a pressure, a saturation and all mole fractions as primary variables. With the restriction to two phases I could then use the priVar state to set the phase presence and then basically compute the phase equilibrium as it is done in the 2pnc models.
You mean when one mole fraction is 0, which then leads to a fugacity of 0? Yes that should still work. Then the phase composition still makes sense and the component is not present.
The first proposal i thought was confusing, because then one uses fugacities as a primary variable for all components that have a non-zero fugacity coefficient but a mole fraction for one component because the fugacity coeff. is zero
Can you have a look if this would work for your application? Please note that it is a draft version and not very much tested. I only created one test, you can see the directory in the commit. I just thought it might make the discussion easier if we have a basis for discussion, so I implemented this. Bugs are still very possible so be aware of that.