feos-org / feos

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

Difference in Molar Enthalpies between EoS and DFT #68

Closed RolfStierle closed 1 year ago

RolfStierle commented 1 year ago

Contributions.IdealGas uses different methods for EoS and DFT (see below).

Joback gives very small values for the IdealGas molar enthalpy (as fat as I tested all in the range ~1e-13 * JOULE).

import numpy as np

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

from feos.eos import EquationOfState, Contributions
from feos.eos import State as EosState
from feos.eos import PhaseEquilibrium as EosPhaseEquilibrium

from feos.dft import HelmholtzEnergyFunctional, PhaseEquilibrium
from feos.dft import State as DftState
from feos.dft import PhaseEquilibrium as DftPhaseEquilibrium

substances = ['nitrogen', 'methane']
params = PcSaftParameters.from_json(substances=substances, pure_path='pure_parameters.json', binary_path='binary_parameters.json', search_option=IdentifierOption.Name)

eos = EquationOfState.pcsaft(params)
dft = HelmholtzEnergyFunctional.pcsaft(params)

vle_eos = EosPhaseEquilibrium.bubble_point(eos, temperature_or_pressure=110*KELVIN, liquid_molefracs=np.array([0.1, 0.9]))
vle_dft = DftPhaseEquilibrium.bubble_point(dft, temperature_or_pressure=110*KELVIN, liquid_molefracs=np.array([0.1, 0.9]))

print(vle_eos.liquid.helmholtz_energy_contributions()) # Gives QSPR as IdealGas contribution
print(vle_dft.liquid.helmholtz_energy_contributions()) # Gives Joback as IdealGas contribution

print(vle_eos.liquid.molar_enthalpy(contributions=Contributions.ResidualNvt) - vle_dft.liquid.molar_enthalpy(contributions=Contributions.ResidualNvt)) #Gives very good agreement in the ResidualNvt contribution

print(vle_eos.liquid.molar_enthalpy(contributions=Contributions.IdealGas) - vle_dft.liquid.molar_enthalpy(contributions=Contributions.IdealGas)) # Gives large discrepancy in IdealGas contribution
prehner commented 1 year ago

Thanks for raising this issue. To be completely aware of what is happening, we would need the content of your pure_parameters.json file, but the fact that Joback gives ~0 and the other outputs suggest, that it does not contain Joback parameters. In this case the eos will fall back on the QSPR method whereas the functional will use Joback where all parameters are 0.

It is indeed confusing behavior that we should attempt to make more transparent.

prehner commented 1 year ago

Closed in favor of #109