Skip to content

Commit

Permalink
FastIAS: fix convergence criteria, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
longemen3000 committed Nov 16, 2024
1 parent 1af5028 commit a39842c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/methods/iast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ function iast_step!(::FastIAS, models, p, T, y, state::S, maxiters, reltol, abst
end
end
ΔRes = norm(δ,Inf)
ΔRes <= min(abstol,norm(Res,Inf)*reltol) && (converged = true)
ΔRes <= abstol && (converged = true)
norm(δ,1) <= reltol && (converged = true)
return (;η,K,Diag,Res,δ,x,q_tot,iters,converged)
end

Expand Down
16 changes: 16 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ end
@test iast(models,p,T,y,FastIAS())[1] q_tot
@test iast(models,p,T,y,IASTNestedLoop())[1] q_tot
@test iast(models,p,T,y,IASTNestedLoop(),x0 = x0)[1] q_tot

ethane_isotherm = Quadratic{Float64}(2.5087482698420104e-7, 2.1373377526197646e-19, 3.641079631515442, -6898.20708031339, -47789.60001500269)
ethylene_isotherm = Quadratic{Float64}(2.599227350906123e-8, 7.128313806215397e-19, 3.832139235999132, -11790.383728687304, -41702.74723166111)
p2 = 101325.0
T2 = 303.0
models2 = (ethane_isotherm,ethylene_isotherm)
yx = range(0.0, 1.00, 51)
for yi in yx
y = [yi,1-yi]
n1,w1,status1 = iast(models2,p2,T2,y,FastIAS())
n2,w2,status2 = iast(models2,p2,T2,y,IASTNestedLoop())
@test status1 == :success
@test status2 == :success
@test n1 n2
@test w1 w2
end
end


Expand Down

0 comments on commit a39842c

Please sign in to comment.