Skip to content

Commit 04c7084

Browse files
committed
more work on MultiPhaseTPFlash
1 parent 7b52dc0 commit 04c7084

File tree

3 files changed

+122
-161
lines changed

3 files changed

+122
-161
lines changed

src/methods/property_solvers/fugacity_coefficient.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,13 @@ function modified_lnϕ(model, p, T, z, cache; phase = :unknown, vol0 = nothing)
333333
end
334334

335335
function modified_gibbs(model,p,T,w,phase = :unknown,vol = NaN)
336-
TT = Base.promote_eltype(model,p,T,w)
337-
RT = Rgas(model)*T
338-
∑w = sum(w)
339-
iszero(∑w) && return zero(TT), zero(TT)
340-
g_ideal = sum(xlogx,w) - xlogx(∑w)
341336
if isnan(vol)
342337
volw = volume(model,p,T,w,phase = phase)
343338
else
344339
volw = vol
345340
end
346-
∑zlogϕi,vv = ∑zlogϕ(model,p,T,w,phase = phase,vol = volw)
347-
return ∑zlogϕi + g_ideal,vv
341+
g = VT_gibbs_energy(model,volw,T,w,p) #+ eos_g(BasicIdeal(),p,T,w)
342+
return g,volw
348343
end
349344

350345
function modified_∂lnϕ∂n(model, p, T, z, cache; phase = :unknown, vol0 = nothing)

src/methods/property_solvers/multicomponent/flash.jl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -348,20 +348,12 @@ for prop in [:isochoric_heat_capacity, :isobaric_heat_capacity, :adiabatic_index
348348
end
349349
end
350350

351-
function _multiphase_gibbs(model,p,T,result)
352-
if result isa FlashResult
353-
return _multiphase_gibbs(model,p,T,(result.compositions,result.fractions,result.volumes))
354-
end
355-
if model isa PTFlashWrapper && length(β) == 2 #TODO: in the future, PTFlashWrappers could be multiphase
356-
if model.model isa RestrictedEquilibriaModel
357-
return zero(eltype(β))
358-
end
359-
end
360-
comps = result[1]
361-
β = result[2]
362-
volumes = result[3]
363-
data = FlashResult(model,p,T,comps,β,volumes)
364-
return Rgas(model)*T*data.data.g
351+
function _multiphase_gibbs(model,result,vapour_phase_index = 0)
352+
gibbs_energy(model,result)/Rgas(model)/result.data.T
353+
end
354+
355+
function _multiphase_gibbs(model::PTFlashWrapper,result,vapour_phase_index = 0)
356+
modified_gibbs(model,result;vapour_phase_index)/Rgas(model)/result.data.T
365357
end
366358

367359
function __mpflash_phase(vapour_phase_index,i)

0 commit comments

Comments
 (0)