|
262 | 262 | [0.3618699698927814 0.6381300301072186; |
263 | 263 | 0.17888243310648602 0.821117566893514] rtol = 1e-6 |
264 | 264 | end |
| 265 | + |
| 266 | + @testset "Michelsen Algorithm in Implicit AD" begin |
| 267 | + admodel = cPR(["ethane","propane"]) |
| 268 | + function dflash(t) |
| 269 | + T = 200*t |
| 270 | + res = Clapeyron.tp_flash2(admodel,1e5,T,[0.5,0.5]) |
| 271 | + return res.volumes[2] |
| 272 | + end |
| 273 | + #= |
| 274 | + |
| 275 | + julia> Clapeyron.tp_flash2(admodel,1e5,200.0,[0.5,0.5]) |
| 276 | + Flash result at T = 200.0, p = 100000.0 with 2 phases: |
| 277 | + (x = [0.407352, 0.592648], β = 0.799439, v = 6.10901e-5) |
| 278 | + (x = [0.869296, 0.130704], β = 0.200561, v = 0.0161798) |
| 279 | +
|
| 280 | + julia> Clapeyron.tp_flash2(admodel,1e5,300.0,[0.5,0.5]) |
| 281 | + Flash result at T = 300.0, p = 100000.0 with 2 phases: |
| 282 | + (x = [0.5, 0.5], β = 0.0, v = 0.0246478) |
| 283 | + (x = [0.5, 0.5], β = 1.0, v = 0.0246478) |
| 284 | + =# |
| 285 | + |
| 286 | + @test Clapeyron.Solvers.derivative(dflash,1.0) ≈ Clapeyron.derivx(dflash,1.0) rtol = 1e-5 |
| 287 | + @test Clapeyron.Solvers.derivative(dflash,1.5) ≈ Clapeyron.derivx(dflash,1.5) rtol = 1e-5 |
| 288 | + end |
265 | 289 | end |
266 | 290 |
|
267 | 291 | @testset "XY flash" begin |
|
604 | 628 | cpr = cPR("Propane",idealmodel = ReidIdeal) |
605 | 629 | crit_cpr = crit_pure(cpr) |
606 | 630 | @test saturation_temperature(cpr,crit_cpr[2] - 1e3)[1] ≈ 369.88681908031606 rtol = 1e-6 |
| 631 | + |
| 632 | + #implicit AD |
| 633 | + dsatp(T) = first(saturation_pressure(cpr,250.0*T)) |
| 634 | + dsatt(p) = first(saturation_temperature(cpr,1e5*p)) |
| 635 | + @test Clapeyron.Solvers.derivative(dsatp,1.0) ≈ Clapeyron.derivx(dsatp,1.0) rtol = 1e-6 |
| 636 | + @test Clapeyron.Solvers.derivative(dsatt,1.0) ≈ Clapeyron.derivx(dsatt,1.0) rtol = 1e-6 |
607 | 637 | end |
608 | 638 |
|
609 | 639 | @testset "Tproperty/Property" begin |
|
815 | 845 | @test Clapeyron.Solvers.derivative(dp,1.0) ≈ Clapeyron.derivx(dp,1.0) rtol = 1e-5 |
816 | 846 | @test Clapeyron.Solvers.derivative(bt,1.0) ≈ Clapeyron.derivx(bt,1.0) rtol = 1e-5 |
817 | 847 | @test Clapeyron.Solvers.derivative(dt,1.0) ≈ Clapeyron.derivx(dt,1.0) rtol = 1e-5 |
818 | | - |
819 | 848 | end |
820 | 849 |
|
821 | 850 | end |
0 commit comments