feos-org / feos

FeOs - A Framework for Equations of State and Classical Density Functional Theory
Other
116 stars 23 forks source link

Allow multiple association sites per molecule in PC-SAFT #233

Open prehner opened 6 months ago

prehner commented 6 months ago

The generic association implementation in FeOs already allows arbitrary numbers of association sites. This PR now enables the parametrization of PC-SAFT with multiple (distinguishable) association sites on the same molecule. The group contribution method is adjusted accordingly. Because this is a niche application, some extra effort is undertaken to make sure that the old interfaces can all still be used (json or building records by hand).

The example below shows how to construct molecules with multiple association sites. Because the sites are actually indistinguishable in the example, it is faster to just adjust the multiplicity of the association site (na/nb). In general, however, multiple association sites cannot be combined into a single one without losing information.

from feos.pcsaft import *
from feos.eos import *
from feos.si import *

record1 = PcSaftRecord(2.5, 3.5, 250., kappa_ab=0.005, epsilon_k_ab=1500, na=1, nb=2)
record2 = PcSaftRecord(2.5, 3.5, 250., association_records=[AssociationRecord(kappa_ab=0.005, epsilon_k_ab=1500, na=1, nb=1), AssociationRecord(kappa_ab=0.005, epsilon_k_ab=1500, nb=1)])

for record in [record1, record2]:
    eos = EquationOfState.pcsaft(PcSaftParameters.from_model_records([record]))
    %timeit State.critical_point(eos)
    print(record.to_json_str())
    print(State.critical_point(eos))
    print()
98.9 µs ± 197 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
{"m":2.5,"sigma":3.5,"epsilon_k":250.0,"kappa_ab":0.005,"epsilon_k_ab":1500.0,"na":1.0,"nb":2.0}
T = 515.18801 K, ρ = 4.31012 kmol/m³

237 µs ± 314 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
{"m":2.5,"sigma":3.5,"epsilon_k":250.0,"association_records":[{"kappa_ab":0.005,"epsilon_k_ab":1500.0,"na":1.0,"nb":1.0},{"kappa_ab":0.005,"epsilon_k_ab":1500.0,"nb":1.0}]}
T = 515.18801 K, ρ = 4.31012 kmol/m³