feos-org / feos

FeOs - A Framework for Equations of State and Classical Density Functional Theory
Other
110 stars 22 forks source link

Helping bubble points and dew points at given pressure to converge #184

Closed LoGaL93 closed 11 months ago

LoGaL93 commented 11 months ago

Currently, I am trying butane[0.3mol]hexane[0.7mol] at 28 bar (Pr = 0.70) with homosegmented PC-SAFT with Joback Cp.

When I initialize a dew point state with some fixed temperature:

dew_point = EoS.PhaseEquilibrium.dew_point(self.EoS, temperature_or_pressure=Input1PASCAL, tp_init =0.97*self.Tcrit\KELVIN, vapor_molefracs = self.fluid.cnc)

I get "Iteration resulted in trivial solution."

If instead I initialize it with: dew_point = EoS.PhaseEquilibrium.dew_point(self.EoS, temperature_or_pressure=Input1PASCAL, tp_init =480.914 KELVIN, vapor_molefracs = self.fluid.cnc)

I get a converged solution.

phase 0: T = 479.43032 K, ρ = 1.24859 kmol/m³, x = [0.30000, 0.70000] phase 1: T = 479.43032 K, ρ = 4.68100 kmol/m³, x = [0.20313, 0.79687]

This initial value I provided was very very close to the result, and I obtained it by asking the same calculation to our non-GC PC-SAFT implementation in FluidProp. Note though that also the other initial value, i.e. 0.97*Tcrit, is 483.4K, which is not so distant from the result.

I know these calculations are very initial value dependent, but is there anything you can do from python side to help the convergence? I see for example that there are there some solver settings to change? Would be nice if you had some code example

prehner commented 11 months ago

You can pass verbosity=Verbosity.Iter to see a bit more details of what is going wrong. However, calculating a bubble or dew point for given pressure that close to the critical point is difficult in general. FluidProp advertises these kind of calculations on their website, so I assume they put in a lot of effort to make their algorithms as robust as possible.

If you can rearrange your problem so that you evaluate bubble or dew points at given temperatures that would make it easier, or (although that is not a very satisfying solution) you can use a solver in Python to iterate the temperature until the bubble or dew point pressure matches your system pressure.

LoGaL93 commented 11 months ago

great, thanks!