-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QP flash bugs #325
Comments
There is one in Clapeyron.qt_flash(model,0.99,300,z) error: ERROR: UndefVarError: `T` not defined in local scope
Suggestion: check for an assignment to a local variable that shadows a global of the same name. |
if nothing is found in 24 hours, i'm releasing a new version with the fixes for the problems found here and in #320 |
I have not found any other bugs for now. If incase I will post it here. |
Hello, This discontinuity seems a bit odd to me? This is expected? I am attaching my code below for reproducibility: using Clapeyron, Plots
using Clapeyron.PH
function qp_temperature(model,q,p,z)
res = qp_flash(model,q,p,z)
return Clapeyron.temperature(model,res)
end
function qp_entropy(model,q,p,z)
res = qp_flash(model,q,p,z)
return Clapeyron.entropy(model,res)
end
function qp_enthalpy(model,q,p,z)
res = qp_flash(model,q,p,z)
return Clapeyron.enthalpy(model,res)
end
fluids = ["isobutane","pentane"]
model = cPR(fluids,idealmodel=ReidIdeal)
p = 101325; z = [5.0,5.0];
q = collect(range(0.001,0.999,100))
for i in eachindex(q)
T[i] = qp_temperature(model,q[i],p,z)
end
scatter(q,T,xlabel = "vapour fraction",ylabel = "temperature",title = "$(fluids)") |
Hello, With the latest fix we can do something nice: This non-linear glide in the two-phase zone is probably the correct way to interpret the behaviour of the fluid. I have attached my code to replicate it: using Clapeyron, Plots, Roots
function qp_temperature(model,q,p,z)
res = qp_flash(model,q,p,z)
return Clapeyron.temperature(model,res)
end
function qp_entropy(model,q,p,z)
res = qp_flash(model,q,p,z)
return Clapeyron.entropy(model,res)
end
function qp_enthalpy(model,q,p,z)
res = qp_flash(model,q,p,z)
return Clapeyron.enthalpy(model,res)
end
function my_mixture_entropy(model::EoSModel,p,T,z)
@assert size(model.components,1) >=2
crit = crit_mix(model,z)
T_,p_,_ = crit
@assert T <T_
@assert p < p_
bt = bubble_temperature(model,p,z)[1]
dt = dew_temperature(model,p,z)[1]
if T <= bt || T >= dt
return entropy(model,p,T,z)
end
if bt<=T<=dt
f(x) = qp_temperature(model,x,p,z) - T
sol_q = find_zero(f,(0,1))
return qp_entropy(model,sol_q,p,z)
end
end
fluids = ["isopentane","toluene"]
model = cPR(fluids,idealmodel=ReidIdeal)
p = 101325.0; z = [5.0,5.0];
T = collect(range(310.0,380.0,100))
s = similar(T)
for i in eachindex(T)
s[i] = my_mixture_entropy(model,p,T[i],z)
end
scatter(s,T,xlabel = "Entropy",ylabel = "Temperature",title = "$(fluids)") There are some downsides:
Thank you |
Hello, fluids = ["isobutane","toluene"]
model = cPR(fluids,idealmodel=ReidIdeal)
p = 8*101325.0; z = [5.0,5.0]; julia> qp_flash(model,0.4,101325*8,z)
Flash result at T = NaN, p = 810600.0 with 2 phases:
(x = [NaN, NaN], β = NaN, v = NaN)
(x = [NaN, NaN], β = NaN, v = NaN) It returns |
yeah, something is going on in the initial point:
|
I'm gonna close this for the moment, Clapeyron 0.6.7 was released |
Hello, |
There is a using Clapeyron
fluids= ["isopentane","isobutane"]
model = cPR(fluids,idealmodel=ReidIdeal)
p = 2*101325.0; z = [2.0,5.0];
q = 0.062744140625
# Perform a QP flash calculation
result_1 = qp_flash(model,q,p, z)
@show result_1
result_2 = qp_flash(model,q,p, z./10)
@show result_2
|
I am happy to inform that we have some cases in which we converge in our using Clapeyron,CoolProp
#CoolProp
#(https://github.com/CoolProp/CoolProp/issues/1870#issuecomment-2526192810)
p1 = 2.5e5
T = 133+273.15
sm1 = PropsSI("Smolar", "P", p1, "T", T, "Pentane")
p2 = 22e5
h1 = PropsSI("H", "P", p2, "Smolar", sm1, "Pentane") #fails
#Clapeyron:
model = SingleFluid("pentane")
sm2 = entropy(model,p1,T) #in this particular case, a flash is not necessary, an alternative that returns a flash object is Clapeyron.tp_flash2(model,p1,T,[1.0])
res1 = ps_flash(model,p2,sm2,[1.0]) #calculates successfully
h2 = enthalpy(model,res1)
res2 = ph_flash(model,p2,h2,[1.0])
sm3 = entropy(model,res2)
sm2 ≈ sm3 #true |
Hello,
The following will not work
error:
The text was updated successfully, but these errors were encountered: