feos-org / feos

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

The specific heat capacity of an ideal gas #156

Closed fcyu0512 closed 1 year ago

fcyu0512 commented 1 year ago

In the process of calculating the molar enthalpy of mixtures using PC-SAFT, how is the specific heat capacity of an ideal gas determined.

g-bauer commented 1 year ago

Hi,

we currently have two models for the heat capacity of the ideal gas implemented, the QSPR method (where parameters are derived from PC-SAFT parameters) and the method of Joback and Reid.

One way to check which contribution is used is to calculate the individual contributions to the Helmholtz energy.

state = State(eos, temperature=t, pressure=p)
state.helmholtz_energy_contributions()

By default, if there are no parameters for the Joback model in your parameter record, the QSPR method will be used for PC-SAFT. If you add Joback parameters to your parameter file or records, the method of Joback and Reid will be automatically used. How the ideal gas contribution is handled is a bit opaque at the moment. It is something we will improve in the near future to make it more transparent which model is used.

If you have more questions or need a code example, please let us know.

fcyu0512 commented 1 year ago

Thanks for your reply.

fcyu0512 commented 1 year ago

When I use polar PC-SAFT to calculate the physical properties of the R134a-R245fa mixture, the phase equilibrium curve is perfect, but the specific enthalpy in the superheated state seems to have a large error. The problem lies in the specific heat capacity of the ideal gas. So please give me an example how to update QSPR method or use Joback and Reid.

prehner commented 1 year ago

Nice to hear that the phase equilibrium curve looks good. How do you specify the PC-SAFT parameters for your refrigerants?

The GC method of Joback and Reid is probably not parametrized for HFCs but you can still pass coefficients if your c_p correlation happens to be a polynomial.

As @g-bauer mentioned, this is somewhat unintuitive at the moment and we plan to improve that in the next update(s).

g-bauer commented 1 year ago

Here are some small Python functions that you can use to fit Joback parameters from other models such as DIPPR eq. 107 (see here for English site) . I did not test the functions but hopefully it's a good starting point. I am sure there are correlations for heat capacities for R134a and R245fa available somewhere.

import numpy as np
from scipy.optimize import least_squares
from feos.si import *

def dippr_eq_107(temperature, parameters):
    """DIPPR equation number 107.  

    Parameters
    ----------
    temperature : SINumber
        Temperature. 
    parameters : np.ndarray
        Parameter vector.

    Returns
    -------
    SINumber : c_p^ig
    """
    t = temperature / KELVIN
    return (
        parameters[0] 
        + parameters[1] * (parameters[2] / t / np.sinh(parameters[2] / t))**2 
        + parameters[3] * (parameters[4] / t / np.cosh(parameters[4] / t))**2
    ) * JOULE/MOL/KELVIN

def cp_ig_joback(temperature, parameters):
    """Ideal gas heat capacity using Joback's method. 

    Parameters
    ----------
    temperature : SINumber
        Temperature. 
    parameters : np.ndarray
        Parameter vector.

    Returns
    -------
    SINumber : c_p^ig
    """
    t = temperature / KELVIN
    a, b, c, d = parameters
    return (
        a - 37.93 
        + (b + 0.21)* t 
        + (c - 3.91e-4) * t**2 
        + (d + 2.06e-7) * t**3
    ) * JOULE/MOL/KELVIN

def cost(parameters, dippr_parameters, temperatures):
    """Cost is relative deviation."""
    dippr = dippr_eq_107(temperatures, dippr_parameters)
    joback = cp_ig_joback(temperatures, parameters)
    return (dippr - joback) / dippr

temperatures = np.arange(300.0, 500.0) * KELVIN # the T-range of the c_p model
x0 = np.array([...]) # initial guess
dippr_parameters = np.array([...]) # parameters for the substance 
result = least_squares(fun=cost, x0=x0, args=(dippr_parameters, temperatures), verbose=2)