Skip to content

Commit

Permalink
improved x0_sat_pure for cubics (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
longemen3000 committed Sep 2, 2024
1 parent c1a0ec4 commit c141a7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/models/cubic/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,29 +333,16 @@ function x0_sat_pure_cubic_ab(model::ABCubicModel, T)
= (pl0)/(vl_p0*dpdV)
vl = vl_p0*exp(_Δ)
vv = volume_virial(B,pl0,T) - c
return (vl, vv)
elseif T > 0.99*Tc
else
psat = critical_psat_extrapolation(model,T,crit)
#normally, the extrapolation gives a higher pressure than the final saturation pressure
#use virial approx for lower pressures
vl = volume(model,psat,T,phase = :l)
vv = volume(model,psat,T,phase = :v)
return (vl, vv)
else
vc = zc**Tc/pc - c
pv0 = -0.25**T/B
vl = vl_max
pc = model.params.Pc.values[1]
p_vl = cubic_p(model, vl, T, z, data)
p_low = min(p_vl, pc)
pl0 = max(zero(b), p_low)
p0 = 0.5 * (pl0 + pv0)
vv = volume_virial(B, p0, T) - c
if p_vl > pc #improves predictions around critical point
psat = critical_psat_extrapolation(model,T,crit)
vl = volume(model,psat,T,phase = :l)
vv = volume(model,psat,T,phase = :v)
return (vl, vv)
if psat < 0.95*pc
vv = volume_virial(B,psat,T) - c
else
vv = volume(model,0.99psat,T,phase = :v)
end
return (vl, vv)
end
return (vl, vv)
end
Expand Down
3 changes: 3 additions & 0 deletions test/test_methods_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ end

#ClapeyronSat
@test Clapeyron.saturation_temperature(model,p0,ClapeyronSaturation())[1] 374.2401401001685 rtol = 1e-6

#Issue #290
@test Clapeyron.saturation_temperature(cPR("R1233zde"),101325*20,crit_retry = false) 405.98925205830335 rtol = 1e-6
end

@testset "Tproperty" begin
Expand Down

0 comments on commit c141a7b

Please sign in to comment.