Skip to content

Commit d62eeca

Browse files
committed
move more tests, add tests for Burkhardt models
1 parent 21e52c2 commit d62eeca

File tree

12 files changed

+112
-44
lines changed

12 files changed

+112
-44
lines changed
File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Clapeyron Database File,
2+
Burdhardt Groups [csvtype = groups,grouptype = BurkhardtAlyLee]
3+
species,groups
4+
ethane,"[""-CH3"" => 2]"
5+
propane~|~n-propane,"[""-CH3"" => 2, ""-CH2-"" => 1]"
6+
butane~|~n-butane,"[""-CH3"" => 2, ""-CH2-"" => 2]"
7+
pentane~|~n-pentane,"[""-CH3"" => 2, ""-CH2-"" => 3]"
8+
hexane~|~n-hexane,"[""-CH3"" => 2, ""-CH2-"" => 4]"
9+
heptane~|~n-heptane,"[""-CH3"" => 2, ""-CH2-"" => 5]"
10+
octane~|~n-octane,"[""-CH3"" => 2, ""-CH2-"" => 6]"
11+
nonane~|~n-nonane,"[""-CH3"" => 2, ""-CH2-"" => 7]"
12+
decane~|~n-decane,"[""-CH3"" => 2, ""-CH2-"" => 8]"
13+
undecane~|~n-undecane,"[""-CH3"" => 2, ""-CH2-"" => 9]"
14+
dodecane~|~n-dodecane,"[""-CH3"" => 2, ""-CH2-"" => 10]"
15+
tridecane~|~n-tridecane,"[""-CH3"" => 2, ""-CH2-"" => 11]"
16+
tetradecane~|~n-tetradecane,"[""-CH3"" => 2, ""-CH2-"" => 12]"
17+
pentadecane~|~n-pentadecane,"[""-CH3"" => 2, ""-CH2-"" => 13]"
18+
hexadecane~|~n-hexadecane,"[""-CH3"" => 2, ""-CH2-"" => 14]"
19+
heptadecane~|~n-heptadecane,"[""-CH3"" => 2, ""-CH2-"" => 15]"
20+
octadecane~|~n-octadecane,"[""-CH3"" => 2, ""-CH2-"" => 16]"
21+
nonadecane~|~n-nonadecane,"[""-CH3"" => 2, ""-CH2-"" => 17]"
22+
eicosane~|~n-eicosane,"[""-CH3"" => 2, ""-CH2-"" => 18]"
23+
hydrogen,"[""[2H]"" => 1]"

database/ideal/BurkhardtIdeal/BurkhardtIdeal_mw.csv

Whitespace-only changes.
File renamed without changes.

database/ideal/BurkhardtIdeal_groups.csv

Lines changed: 0 additions & 2 deletions
This file was deleted.

database/properties/molarmass_groups.csv

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,10 @@ SO42-,96.06
109109
HNO3-,63.012
110110
NO3-,62.004
111111
HCO3-,61.0168
112-
CO32-,60.01
112+
CO32-,60.01
113+
=S,32.06
114+
-B<,10.811
115+
>Si<,28.085
116+
>SiH-,29.093
117+
-SiH2-,30.101
118+
-SiH3,31.109

src/methods/methods.jl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,23 @@ function NLSolvers.NEqOptions(method::ThermodynamicMethod)
3535
maxiter = method.max_iters)
3636
end
3737

38-
mw(model::EoSModel) = model.params.Mw.values
38+
function mw(model::EoSModel)
39+
if has_groups(model)
40+
return group_Mw(model)
41+
else
42+
return model.params.Mw.values
43+
end
44+
end
3945

40-
group_Mw(model::EoSModel) = group_Mw(model.params.Mw.values,model.groups)
46+
group_Mw(model::EoSModel) = group_Mw(model.params.Mw,model.groups)
4147
function group_Mw(Mw_gc::SingleParam,groups::GroupParam)
4248
n = length(groups.components)
43-
mw_comp = zeros(eltype(Mw_gc.values),n)
49+
50+
mw_comp = zeros(Base.promote_eltype(Mw_gc,groups),n)
4451
v = groups.n_flattenedgroups
4552
mw_gc = Mw_gc.values
4653
for i in 1:n
54+
@show v[i],mw_gc
4755
mw_comp[i] = dot(mw_gc,v[i])
4856
end
4957
return mw_comp
@@ -72,14 +80,15 @@ molecular_weight(mw::AbstractVector,z) = comp_molecular_weight(mw,z)
7280
molecular_weight(mw::SingleParam,z) = comp_molecular_weight(mw.values,z)
7381

7482
function __molecular_weight(model,z)
75-
MW = mw(model)
7683
if has_groups(model)
77-
return group_molecular_weight(model.groups,MW,z)
84+
return group_molecular_weight(model,z)
7885
else
79-
return comp_molecular_weight(MW,z)
86+
return comp_molecular_weight(mw(model),z)
8087
end
8188
end
8289

90+
group_molecular_weight(model,z) = group_molecular_weight(model.groups,model.params.Mw.values,z)
91+
8392
const LIQUID_STR = (:liquid,:LIQUID,:L,:l)
8493

8594
"""

src/models/ideal/BurkhardtIdeal.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ struct BurkhardtIdealParam <: EoSParam
33
B::SingleParam{Float64}
44
C::SingleParam{Float64}
55
D::SingleParam{Float64}
6+
Mw::SingleParam{Float64}
67
reference_state::ReferenceState
78
end
89

910
abstract type BurkhardtIdealModel <: IdealModel end
1011
@newmodelgc BurkhardtIdeal BurkhardtIdealModel BurkhardtIdealParam false
1112
default_references(::Type{BurkhardtIdeal}) = ["10.1021/acs.jced.5c00573"]
12-
default_locations(::Type{BurkhardtIdeal}) = ["ideal/BurkhardtIdeal.csv"]
13-
default_gclocations(::Type{BurkhardtIdeal}) = ["ideal/BurkhardtIdeal_Groups.csv"]
13+
default_locations(::Type{BurkhardtIdeal}) = ["ideal/BurkhardtIdeal/BurkhardtIdeal.csv","properties/molarmass_groups.csv"]
14+
default_gclocations(::Type{BurkhardtIdeal}) = ["ideal/BurkhardtIdeal/BurkhardtIdeal_Groups.csv"]
15+
default_ignore_missing_singleparams(::Type{BurkhardtIdeal}) = ["Mw"]
1416

1517
"""
1618
BurkhardtIdeal <: BurkhardtIdealModel
@@ -39,6 +41,10 @@ Eᵢₖ = c₅*(Cₖ + c₃)
3941
c₁,c₂,c₃,c₄,c₅ = -0.350,2.245,8.858,1.487,0.432
4042
```
4143
44+
## Group Fragmentation
45+
46+
Molecule fragmentation into functional groups is available in GCIdentifier.jl, using `Burkhardt2025Groups`
47+
4248
## References
4349
4450
1. Burkhardt, J., Bauer, G., Stierle, R., & Gross, J. (2026). A new group-contribution approach for ideal gas heat capacity, critical temperature and normal Boiling Point. Journal of Chemical and Engineering Data, 71(1), 6–23. [doi:10.1021/acs.jced.5c00573](http://doi.org/10.1021/acs.jced.5c00573)

src/models/ideal/GCAlyLeeIdeal.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ struct GCAlyLeeParam <: EoSParam
44
C::SingleParam{Float64}
55
D::SingleParam{Float64}
66
E::SingleParam{Float64}
7+
Mw::SingleParam{Float64}
78
coeffs::SingleParam{NTuple{5,Float64}}
89
reference_state::ReferenceState
910
end
1011

1112
abstract type GCAlyLeeModel <: IdealModel end
1213
@newmodelgc GCAlyLeeIdeal GCAlyLeeModel GCAlyLeeParam false
1314
default_references(::Type{GCAlyLeeIdeal}) = ["10.1021/acs.jced.5c00573"]
14-
default_locations(::Type{GCAlyLeeIdeal}) = ["ideal/GCAlyLeeIdeal.csv"]
15-
default_gclocations(::Type{GCAlyLeeIdeal}) = ["ideal/BurkhardtIdeal_Groups.csv"]
15+
default_locations(::Type{GCAlyLeeIdeal}) = ["ideal/BurkhardtIdeal/GCAlyLeeIdeal.csv","properties/molarmass_groups.csv"]
16+
default_gclocations(::Type{GCAlyLeeIdeal}) = ["ideal/BurkhardtIdeal/BurkhardtIdeal_Groups.csv"]
17+
default_ignore_missing_singleparams(::Type{GCAlyLeeIdeal}) = ["Mw"]
1618

1719
function transform_params(::Type{GCAlyLeeIdeal},params,groups)
1820
components = groups.components
@@ -82,6 +84,9 @@ C = ∑Nᵢₖ*(Cᵢₖ + 500.642)
8284
D = ∑Nᵢₖ*(Dᵢₖ + 3.450)
8385
E = ∑Nᵢₖ*(Eᵢₖ + 514.210)
8486
```
87+
## Group Fragmentation
88+
89+
Molecule fragmentation into functional groups is available in GCIdentifier.jl, using `Burkhardt2025Groups`
8590
8691
## References
8792

test/test_methods_api.jl

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ end
316316
@test s1[3] 0.0015804179997257882 rtol = 1e-6
317317
end
318318

319+
#=
319320
@testset "#466" begin
320321
glycine = ("glycine" => ["COOH" => 1, "CH2" => 1, "NH2" => 1])
321322
lactic_acid = ("lactic acid" =>["COOH" => 1, "CH3" => 1, "CHOH" => 1])
@@ -328,10 +329,11 @@ end
328329
T2,_ = Clapeyron.eutectic_point(ox_gly)
329330
@test T1 ≈ 300.23095880432294 rtol = 1e-6
330331
@test T2 ≈ 454.27284723964925 rtol = 1e-6
331-
end
332+
end =#
332333
end
333334
GC.gc()
334-
#test for really really difficult equilibria.
335+
336+
#test for difficult equilibria.
335337
@testset "challenging equilibria" begin
336338

337339
#see https://github.com/ClapeyronThermo/Clapeyron.jl/issues/173
@@ -414,34 +416,6 @@ end
414416
end
415417
end
416418

417-
@testset "spinodals" begin
418-
# Example from Ref. https://doi.org/10.1016/j.fluid.2017.04.009
419-
model = PCSAFT(["methane","ethane"])
420-
T_spin = 223.
421-
x_spin = [0.2,0.8]
422-
(pl_spin, vl_spin) = spinodal_pressure(model,T_spin,x_spin;phase=:liquid)
423-
(pv_spin, vv_spin) = spinodal_pressure(model,T_spin,x_spin;phase=:vapor)
424-
@test vl_spin 7.218532167482202e-5 rtol = 1e-6
425-
@test vv_spin 0.0004261109817247137 rtol = 1e-6
426-
427-
(Tl_spin_impl, xl_spin_impl) = spinodal_temperature(model,pl_spin,x_spin;T0=220.,v0=vl_spin)
428-
(Tv_spin_impl, xv_spin_impl) = spinodal_temperature(model,pv_spin,x_spin;T0=225.,v0=vv_spin)
429-
@test Tl_spin_impl T_spin rtol = 1e-6
430-
@test Tv_spin_impl T_spin rtol = 1e-6
431-
432-
#test for #382: pure spinodal at low pressures
433-
model2 = PCSAFT("carbon dioxide")
434-
Tc,Pc,Vc = (310.27679925044134, 8.06391600653306e6, 9.976420206333288e-5)
435-
T = LinRange(Tc-70,Tc-0.1,50)
436-
psl = first.(spinodal_pressure.(model2,T,phase = :l))
437-
psv = first.(spinodal_pressure.(model2,T,phase = :v))
438-
psat = first.(saturation_pressure.(model2,T))
439-
@test all(psl .< psat)
440-
@test all(psat .< psv)
441-
@test issorted(psl)
442-
@test issorted(psv)
443-
end
444-
445419
@testset "supercritical lines" begin
446420
model = PR("methane")
447421
T_initial = 200.0

0 commit comments

Comments
 (0)