Skip to content

Commit

Permalink
typos, add test for #309
Browse files Browse the repository at this point in the history
  • Loading branch information
longemen3000 committed Dec 1, 2024
1 parent d81bc4f commit efce934
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/methods/property_solvers/Tproperty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ function Tproperty_pure(model,p,prop,z,property::F,rootsolver,phase,abstol,relto
prop_v = vvsat
prop_l = vlsat
else
prop_v = property(model,P,Tsat,z,phase = :v)
prop_l = property(model,P,Tsat,z,phase = :l)
prop_v = property(model,p,Tsat,z,phase = :v)
prop_l = property(model,p,Tsat,z,phase = :l)
end

β = (prop - prop_l)/(prop_v - prop_l)
Expand Down
17 changes: 6 additions & 11 deletions src/methods/property_solvers/multicomponent/flash.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,13 @@ end

temperature(state::FlashResult) = state.data.T
pressure(state::FlashResult) = state.data.p
volume(state::FlashResult) = dot(state.fractions,state.volumes)
molar_density(state::FlashResult) = sum(state.fractions)/volume(state)

function volume(model::EoSModel,state::FlashResult)
comps, β, volumes, data = state
return dot(β,volumes)
end

function molar_density(model::EoSModel,state::FlashResult)
comps, β, volumes, data = state
v = volume(model,state)
n = sum(β)
return n/v
end
pressure(model::EoSModel,state::FlashResult) = pressure(state)
temperature(model::EoSModel,state::FlashResult) = temperature(state)
volume(model::EoSModel,state::FlashResult) = volume(state)
molar_density(model::EoSModel,state::FlashResult) = molar_density(state)

function __molecular_weight(model,state::FlashResult)
comps, β, volumes, data = state
Expand Down
24 changes: 12 additions & 12 deletions src/methods/property_solvers/multicomponent/flash/general_flash.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ function Base.show(io::IO,x::FlashSpecifications)
print(io,spec2," => ",val2,")")
end

spec_intensive(::typeof(pressure)) = false
spec_intensive(::typeof(temperature)) = false
spec_intensive(x) = true
spec_intensive(::typeof(pressure)) = true
spec_intensive(::typeof(temperature)) = true
spec_intensive(x) = false


function normalize_spec(s::FlashSpecifications,k)
_1 = oneunit(1/k)
spec1,spec2,val1,val2 = s.spec1,s.spec2,s.val1,s.val2
if !spec_intensive(spec1)
newval1 = val1/k
else
if spec_intensive(spec1)
newval1 = val1*_1
else
newval1 = val1/k
end

if !spec_intensive(spec2)
newval2 = val2/k
else
if spec_intensive(spec2)
newval2 = val2*_1
else
newval2 = val2/k
end

return FlashSpecifications(spec1,newval1,spec2,newval2)
Expand Down Expand Up @@ -705,13 +705,13 @@ end

function tx_flash_x0(model,T,x,z,spec::F,method::GeneralizedXYFlash) where F
if method.p0 == nothing
p,_phase = _Pproperty(model,p,x,z,spec)
p,_phase = _Pproperty(model,T,x,z,spec)
else
p = method.p0
_phase = :eq #we suppose this
end

TT = Base.promote_eltype(model,p,x,z,T)
TT = Base.promote_eltype(model,T,x,z,T)
if _phase != :eq
return FlashResult(model,p,T,z,phase = _phase)
end
Expand Down
13 changes: 13 additions & 0 deletions test/test_methods_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,19 @@ end
T3_calc = Tproperty(model3,p3,s30,z3,entropy)
s3 = entropy(model3,p3,T3_calc,z3)
@test s3 s30

#issue 309 (https://github.com/ClapeyronThermo/Clapeyron.jl/issues/309#issuecomment-2508038968)
model4 = cPR("R134A",idealmodel= ReidIdeal)
T_crit,p_crit,_ = crit_pure(model4)
T1 = 300.0
p1 = saturation_pressure(model4,T1)[1] + 101325
s1 = entropy(model4,p1,T1)
h1 = enthalpy(model4,p1,T1)
p2 = p_crit + 2*101325
T2 = Tproperty(model4,p2,s1,Clapeyron.SA[1.0],entropy)
s2 = entropy(model4,p2,T2)
h2 = enthalpy(model4,p2,T2)
@test s2 s1
end

@testset "bubble/dew point algorithms" begin
Expand Down

0 comments on commit efce934

Please sign in to comment.