Skip to content

polykin.properties.pvt_polymer¤

This module implements methods to evaluate the PVT behavior of pure polymers.

Flory ¤

Flory equation of state for the specific volume of a polymer.

This EoS implements the following implicit PVT dependence:

\[ \frac{\tilde{P}\tilde{V}}{\tilde{T}} = \frac{\tilde{V}^{1/3}}{\tilde{V}^{1/3}-1}-\frac{1}{\tilde{V}\tilde{T}}\]

where \(\tilde{V}=V/V^*\), \(\tilde{P}=P/P^*\) and \(\tilde{T}=T/T^*\) are, respectively, the reduced volume, reduced pressure and reduced temperature. \(V^*\), \(P^*\) and \(T^*\) are reference quantities that are polymer dependent.

References

  • Caruthers et al. Handbook of Diffusion and Thermal Properties of Polymers and Polymer Solutions. AIChE, 1998.
PARAMETER DESCRIPTION
V0

Reference volume, \(V^*\).

TYPE: float

T0

Reference temperature, \(T^*\).

TYPE: float

P0

Reference pressure, \(P^*\).

TYPE: float

Tmin

Lower temperature bound. Unit = K.

TYPE: float DEFAULT: 0.0

Tmax

Upper temperature bound. Unit = K.

TYPE: float DEFAULT: inf

Pmin

Lower pressure bound. Unit = Pa.

TYPE: float DEFAULT: 0.0

Pmax

Upper pressure bound. Unit = Pa.

TYPE: float DEFAULT: inf

name

Name.

TYPE: str DEFAULT: ''

Source code in src/polykin/properties/pvt_polymer/eos.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
class Flory(PolymerPVTEoS):
    r"""Flory equation of state for the specific volume of a polymer.

    This EoS implements the following implicit PVT dependence:

    $$ \frac{\tilde{P}\tilde{V}}{\tilde{T}} =
      \frac{\tilde{V}^{1/3}}{\tilde{V}^{1/3}-1}-\frac{1}{\tilde{V}\tilde{T}}$$

    where $\tilde{V}=V/V^*$, $\tilde{P}=P/P^*$ and $\tilde{T}=T/T^*$ are,
    respectively, the reduced volume, reduced pressure and reduced temperature.
    $V^*$, $P^*$ and $T^*$ are reference quantities that are polymer dependent.

    **References**

    *   Caruthers et al. Handbook of Diffusion and Thermal Properties of
        Polymers and Polymer Solutions. AIChE, 1998.

    Parameters
    ----------
    V0 : float
        Reference volume, $V^*$.
    T0 : float
        Reference temperature, $T^*$.
    P0 : float
        Reference pressure, $P^*$.
    Tmin : float
        Lower temperature bound.
        Unit = K.
    Tmax : float
        Upper temperature bound.
        Unit = K.
    Pmin : float
        Lower pressure bound.
        Unit = Pa.
    Pmax : float
        Upper pressure bound.
        Unit = Pa.
    name : str
        Name.
    """

    @staticmethod
    def equation(v: float,
                 t: float,
                 p: float
                 ) -> tuple[float, float, float]:
        r"""Flory equation of state and its volume derivatives.

        Parameters
        ----------
        v : float
            Reduced volume, $\tilde{V}$.
        t : float
            Reduced temperature, $\tilde{T}$.
        p : float
            Reduced pressure, $\tilde{P}$.

        Returns
        -------
        tuple[float, float, float]
            Equation of state, first derivative, second derivative.
        """
        f = p*v/t - (v**(1/3)/(v**(1/3) - 1) - 1/(v*t))  # =0
        d1f = p/t - 1/(t*v**2) - 1/(3*(v**(1/3) - 1)*v**(2/3)) + \
            1/(3*(v**(1/3) - 1)**2*v**(1/3))
        d2f = (2*(9/t + (v**(4/3) - 2*v**(5/3))/(-1 + v**(1/3))**3))/(9*v**3)
        return (f, d1f, d2f)

V ¤

V(
    T: Union[float, FloatArrayLike],
    P: Union[float, FloatArrayLike],
    Tunit: Literal["C", "K"] = "K",
    Punit: Literal["bar", "MPa", "Pa"] = "Pa",
) -> Union[float, FloatArray]

Evaluate the specific volume, \(\hat{V}\), at given temperature and pressure, including unit conversion and range check.

PARAMETER DESCRIPTION
T

Temperature. Unit = Tunit.

TYPE: float | FloatArrayLike

P

Pressure. Unit = Punit.

TYPE: float | FloatArrayLike

Tunit

Temperature unit.

TYPE: Literal['C', 'K'] DEFAULT: 'K'

Punit

Pressure unit.

TYPE: Literal['bar', 'MPa', 'Pa'] DEFAULT: 'Pa'

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/base.py
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def V(self,
      T: Union[float, FloatArrayLike],
      P: Union[float, FloatArrayLike],
      Tunit: Literal['C', 'K'] = 'K',
      Punit: Literal['bar', 'MPa', 'Pa'] = 'Pa'
      ) -> Union[float, FloatArray]:
    r"""Evaluate the specific volume, $\hat{V}$, at given temperature and
    pressure, including unit conversion and range check.

    Parameters
    ----------
    T : float | FloatArrayLike
        Temperature.
        Unit = `Tunit`.
    P : float | FloatArrayLike
        Pressure.
        Unit = `Punit`.
    Tunit : Literal['C', 'K']
        Temperature unit.
    Punit : Literal['bar', 'MPa', 'Pa']
        Pressure unit.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    TK = convert_check_temperature(T, Tunit, self.Trange)
    Pa = convert_check_pressure(P, Punit, self.Prange)
    return self.eval(TK, Pa)

alpha ¤

alpha(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate thermal expansion coefficient, \(\alpha\).

\[\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Thermal expansion coefficient, \(\alpha\). Unit = 1/K.

Source code in src/polykin/properties/pvt_polymer/eos.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
def alpha(self,
          T: Union[float, FloatArray],
          P: Union[float, FloatArray]
          ) -> Union[float, FloatArray]:
    r"""Calculate thermal expansion coefficient, $\alpha$.

    $$\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Thermal expansion coefficient, $\alpha$.
        Unit = 1/K.
    """
    dT = 0.5
    V2 = self.eval(T + dT, P)
    V1 = self.eval(T - dT, P)
    return (V2 - V1)/dT/(V1 + V2)

beta ¤

beta(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate isothermal compressibility coefficient, \(\beta\).

\[\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Isothermal compressibility coefficient, \(\beta\). Unit = 1/Pa.

Source code in src/polykin/properties/pvt_polymer/eos.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def beta(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Calculate isothermal compressibility coefficient, $\beta$.

    $$\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Isothermal compressibility coefficient, $\beta$.
        Unit = 1/Pa.
    """
    dP = 1e5
    P2 = P + dP
    P1 = np.max(P - dP, 0)
    V2 = self.eval(T, P2)
    V1 = self.eval(T, P1)
    return -(V2 - V1)/(P2 - P1)/(V1 + V2)*2

equation staticmethod ¤

equation(
    v: float, t: float, p: float
) -> tuple[float, float, float]

Flory equation of state and its volume derivatives.

PARAMETER DESCRIPTION
v

Reduced volume, \(\tilde{V}\).

TYPE: float

t

Reduced temperature, \(\tilde{T}\).

TYPE: float

p

Reduced pressure, \(\tilde{P}\).

TYPE: float

RETURNS DESCRIPTION
tuple[float, float, float]

Equation of state, first derivative, second derivative.

Source code in src/polykin/properties/pvt_polymer/eos.py
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
@staticmethod
def equation(v: float,
             t: float,
             p: float
             ) -> tuple[float, float, float]:
    r"""Flory equation of state and its volume derivatives.

    Parameters
    ----------
    v : float
        Reduced volume, $\tilde{V}$.
    t : float
        Reduced temperature, $\tilde{T}$.
    p : float
        Reduced pressure, $\tilde{P}$.

    Returns
    -------
    tuple[float, float, float]
        Equation of state, first derivative, second derivative.
    """
    f = p*v/t - (v**(1/3)/(v**(1/3) - 1) - 1/(v*t))  # =0
    d1f = p/t - 1/(t*v**2) - 1/(3*(v**(1/3) - 1)*v**(2/3)) + \
        1/(3*(v**(1/3) - 1)**2*v**(1/3))
    d2f = (2*(9/t + (v**(4/3) - 2*v**(5/3))/(-1 + v**(1/3))**3))/(9*v**3)
    return (f, d1f, d2f)

eval ¤

eval(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Evaluate specific volume, \(\hat{V}\), at given SI conditions without unit conversions or checks.

PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/eos.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@vectorize
def eval(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Evaluate specific volume, $\hat{V}$, at given SI conditions without
    unit conversions or checks.

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    t = T/self.T0
    p = P/self.P0
    solution = root_scalar(f=self.equation,
                           args=(t, p),
                           # bracket=[1.1, 1.5],
                           x0=1.05,
                           method='halley',
                           fprime=True,
                           fprime2=True)

    if solution.converged:
        v = solution.root
        V = v*self.V0
    else:
        print(solution.flag)
        V = -1.
    return V

from_database classmethod ¤

from_database(name: str) -> Optional[PolymerPVTEquation]

Construct PolymerPVTEquation with parameters from the database.

PARAMETER DESCRIPTION
name

Polymer code name.

TYPE: str

Source code in src/polykin/properties/pvt_polymer/base.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@classmethod
def from_database(cls,
                  name: str
                  ) -> Optional[PolymerPVTEquation]:
    r"""Construct `PolymerPVTEquation` with parameters from the database.

    Parameters
    ----------
    name : str
        Polymer code name.
    """
    table = load_PVT_parameters(method=cls.__name__)
    try:
        mask = table.index == name
        parameters = table[mask].iloc[0, :].to_dict()
        return cls(**parameters, name=name)
    except IndexError:
        print(
            f"Error: '{name}' does not exist in polymer database.\n"
            f"Valid names are: {table.index.to_list()}")

get_database classmethod ¤

get_database() -> pd.DataFrame

Get database with parameters for the respective PVT equation.

Method Reference
Flory [2] Table 4.1.7 (p. 72-73)
Hartmann-Haque [2] Table 4.1.11 (p. 85-86)
Sanchez-Lacombe [2] Table 4.1.9 (p. 78-79)
Tait [1] Table 3B-1 (p. 41)

References

  1. Danner, Ronald P., and Martin S. High. Handbook of polymer solution thermodynamics. John Wiley & Sons, 2010.
  2. Caruthers et al. Handbook of Diffusion and Thermal Properties of Polymers and Polymer Solutions. AIChE, 1998.
Source code in src/polykin/properties/pvt_polymer/base.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@classmethod
def get_database(cls) -> pd.DataFrame:
    r"""Get database with parameters for the respective PVT equation.

    | Method          | Reference                            |
    | :-----------    | ------------------------------------ |
    | Flory           | [2] Table 4.1.7  (p. 72-73)          |
    | Hartmann-Haque  | [2] Table 4.1.11 (p. 85-86)          |
    | Sanchez-Lacombe | [2] Table 4.1.9  (p. 78-79)          |
    | Tait            | [1] Table 3B-1 (p. 41)               |

    **References**

    1.  Danner, Ronald P., and Martin S. High. Handbook of polymer
        solution thermodynamics. John Wiley & Sons, 2010.
    2.  Caruthers et al. Handbook of Diffusion and Thermal Properties of
        Polymers and Polymer Solutions. AIChE, 1998.
    """
    return load_PVT_parameters(method=cls.__name__)

HartmannHaque ¤

Hartmann-Haque equation of state for the specific volume of a polymer.

This EoS implements the following implicit PVT dependence:

\[ \tilde{P}\tilde{V}^5=\tilde{T}^{3/2}-\ln{\tilde{V}} \]

where \(\tilde{V}=V/V^*\), \(\tilde{P}=P/P^*\) and \(\tilde{T}=T/T^*\) are, respectively, the reduced volume, reduced pressure and reduced temperature. \(V^*\), \(P^*\) and \(T^*\) are reference quantities that are polymer dependent.

References

  • Caruthers et al. Handbook of Diffusion and Thermal Properties of Polymers and Polymer Solutions. AIChE, 1998.
PARAMETER DESCRIPTION
V0

Reference volume, \(V^*\).

TYPE: float

T0

Reference temperature, \(T^*\).

TYPE: float

P0

Reference pressure, \(P^*\).

TYPE: float

Tmin

Lower temperature bound. Unit = K.

TYPE: float DEFAULT: 0.0

Tmax

Upper temperature bound. Unit = K.

TYPE: float DEFAULT: inf

Pmin

Lower pressure bound. Unit = Pa.

TYPE: float DEFAULT: 0.0

Pmax

Upper pressure bound. Unit = Pa.

TYPE: float DEFAULT: inf

name

Name.

TYPE: str DEFAULT: ''

Source code in src/polykin/properties/pvt_polymer/eos.py
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
class HartmannHaque(PolymerPVTEoS):
    r"""Hartmann-Haque equation of state for the specific volume of a polymer.

    This EoS implements the following implicit PVT dependence:

    $$ \tilde{P}\tilde{V}^5=\tilde{T}^{3/2}-\ln{\tilde{V}} $$

    where $\tilde{V}=V/V^*$, $\tilde{P}=P/P^*$ and $\tilde{T}=T/T^*$ are,
    respectively, the reduced volume, reduced pressure and reduced temperature.
    $V^*$, $P^*$ and $T^*$ are reference quantities that are polymer dependent.

    **References**

    *   Caruthers et al. Handbook of Diffusion and Thermal Properties of
        Polymers and Polymer Solutions. AIChE, 1998.

    Parameters
    ----------
    V0 : float
        Reference volume, $V^*$.
    T0 : float
        Reference temperature, $T^*$.
    P0 : float
        Reference pressure, $P^*$.
    Tmin : float
        Lower temperature bound.
        Unit = K.
    Tmax : float
        Upper temperature bound.
        Unit = K.
    Pmin : float
        Lower pressure bound.
        Unit = Pa.
    Pmax : float
        Upper pressure bound.
        Unit = Pa.
    name : str
        Name.
    """

    @staticmethod
    def equation(v: float,
                 t: float,
                 p: float
                 ) -> tuple[float, float, float]:
        """Hartmann-Haque equation of state and its volume derivatives.

        Parameters
        ----------
        v : float
            Reduced volume.
        t : float
            Reduced temperature.
        p : float
            Reduced pressure.

        Returns
        -------
        tuple[float, float, float]
            Equation of state, first derivative, second derivative.
        """
        f = p*v**5 - t**(3/2) + log(v)  # =0
        d1f = 5*p*v**4 + 1/v
        d2f = 20*p*v**3 - 1/v**2
        return (f, d1f, d2f)

V ¤

V(
    T: Union[float, FloatArrayLike],
    P: Union[float, FloatArrayLike],
    Tunit: Literal["C", "K"] = "K",
    Punit: Literal["bar", "MPa", "Pa"] = "Pa",
) -> Union[float, FloatArray]

Evaluate the specific volume, \(\hat{V}\), at given temperature and pressure, including unit conversion and range check.

PARAMETER DESCRIPTION
T

Temperature. Unit = Tunit.

TYPE: float | FloatArrayLike

P

Pressure. Unit = Punit.

TYPE: float | FloatArrayLike

Tunit

Temperature unit.

TYPE: Literal['C', 'K'] DEFAULT: 'K'

Punit

Pressure unit.

TYPE: Literal['bar', 'MPa', 'Pa'] DEFAULT: 'Pa'

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/base.py
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def V(self,
      T: Union[float, FloatArrayLike],
      P: Union[float, FloatArrayLike],
      Tunit: Literal['C', 'K'] = 'K',
      Punit: Literal['bar', 'MPa', 'Pa'] = 'Pa'
      ) -> Union[float, FloatArray]:
    r"""Evaluate the specific volume, $\hat{V}$, at given temperature and
    pressure, including unit conversion and range check.

    Parameters
    ----------
    T : float | FloatArrayLike
        Temperature.
        Unit = `Tunit`.
    P : float | FloatArrayLike
        Pressure.
        Unit = `Punit`.
    Tunit : Literal['C', 'K']
        Temperature unit.
    Punit : Literal['bar', 'MPa', 'Pa']
        Pressure unit.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    TK = convert_check_temperature(T, Tunit, self.Trange)
    Pa = convert_check_pressure(P, Punit, self.Prange)
    return self.eval(TK, Pa)

alpha ¤

alpha(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate thermal expansion coefficient, \(\alpha\).

\[\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Thermal expansion coefficient, \(\alpha\). Unit = 1/K.

Source code in src/polykin/properties/pvt_polymer/eos.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
def alpha(self,
          T: Union[float, FloatArray],
          P: Union[float, FloatArray]
          ) -> Union[float, FloatArray]:
    r"""Calculate thermal expansion coefficient, $\alpha$.

    $$\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Thermal expansion coefficient, $\alpha$.
        Unit = 1/K.
    """
    dT = 0.5
    V2 = self.eval(T + dT, P)
    V1 = self.eval(T - dT, P)
    return (V2 - V1)/dT/(V1 + V2)

beta ¤

beta(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate isothermal compressibility coefficient, \(\beta\).

\[\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Isothermal compressibility coefficient, \(\beta\). Unit = 1/Pa.

Source code in src/polykin/properties/pvt_polymer/eos.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def beta(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Calculate isothermal compressibility coefficient, $\beta$.

    $$\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Isothermal compressibility coefficient, $\beta$.
        Unit = 1/Pa.
    """
    dP = 1e5
    P2 = P + dP
    P1 = np.max(P - dP, 0)
    V2 = self.eval(T, P2)
    V1 = self.eval(T, P1)
    return -(V2 - V1)/(P2 - P1)/(V1 + V2)*2

equation staticmethod ¤

equation(
    v: float, t: float, p: float
) -> tuple[float, float, float]

Hartmann-Haque equation of state and its volume derivatives.

PARAMETER DESCRIPTION
v

Reduced volume.

TYPE: float

t

Reduced temperature.

TYPE: float

p

Reduced pressure.

TYPE: float

RETURNS DESCRIPTION
tuple[float, float, float]

Equation of state, first derivative, second derivative.

Source code in src/polykin/properties/pvt_polymer/eos.py
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
@staticmethod
def equation(v: float,
             t: float,
             p: float
             ) -> tuple[float, float, float]:
    """Hartmann-Haque equation of state and its volume derivatives.

    Parameters
    ----------
    v : float
        Reduced volume.
    t : float
        Reduced temperature.
    p : float
        Reduced pressure.

    Returns
    -------
    tuple[float, float, float]
        Equation of state, first derivative, second derivative.
    """
    f = p*v**5 - t**(3/2) + log(v)  # =0
    d1f = 5*p*v**4 + 1/v
    d2f = 20*p*v**3 - 1/v**2
    return (f, d1f, d2f)

eval ¤

eval(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Evaluate specific volume, \(\hat{V}\), at given SI conditions without unit conversions or checks.

PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/eos.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@vectorize
def eval(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Evaluate specific volume, $\hat{V}$, at given SI conditions without
    unit conversions or checks.

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    t = T/self.T0
    p = P/self.P0
    solution = root_scalar(f=self.equation,
                           args=(t, p),
                           # bracket=[1.1, 1.5],
                           x0=1.05,
                           method='halley',
                           fprime=True,
                           fprime2=True)

    if solution.converged:
        v = solution.root
        V = v*self.V0
    else:
        print(solution.flag)
        V = -1.
    return V

from_database classmethod ¤

from_database(name: str) -> Optional[PolymerPVTEquation]

Construct PolymerPVTEquation with parameters from the database.

PARAMETER DESCRIPTION
name

Polymer code name.

TYPE: str

Source code in src/polykin/properties/pvt_polymer/base.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@classmethod
def from_database(cls,
                  name: str
                  ) -> Optional[PolymerPVTEquation]:
    r"""Construct `PolymerPVTEquation` with parameters from the database.

    Parameters
    ----------
    name : str
        Polymer code name.
    """
    table = load_PVT_parameters(method=cls.__name__)
    try:
        mask = table.index == name
        parameters = table[mask].iloc[0, :].to_dict()
        return cls(**parameters, name=name)
    except IndexError:
        print(
            f"Error: '{name}' does not exist in polymer database.\n"
            f"Valid names are: {table.index.to_list()}")

get_database classmethod ¤

get_database() -> pd.DataFrame

Get database with parameters for the respective PVT equation.

Method Reference
Flory [2] Table 4.1.7 (p. 72-73)
Hartmann-Haque [2] Table 4.1.11 (p. 85-86)
Sanchez-Lacombe [2] Table 4.1.9 (p. 78-79)
Tait [1] Table 3B-1 (p. 41)

References

  1. Danner, Ronald P., and Martin S. High. Handbook of polymer solution thermodynamics. John Wiley & Sons, 2010.
  2. Caruthers et al. Handbook of Diffusion and Thermal Properties of Polymers and Polymer Solutions. AIChE, 1998.
Source code in src/polykin/properties/pvt_polymer/base.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@classmethod
def get_database(cls) -> pd.DataFrame:
    r"""Get database with parameters for the respective PVT equation.

    | Method          | Reference                            |
    | :-----------    | ------------------------------------ |
    | Flory           | [2] Table 4.1.7  (p. 72-73)          |
    | Hartmann-Haque  | [2] Table 4.1.11 (p. 85-86)          |
    | Sanchez-Lacombe | [2] Table 4.1.9  (p. 78-79)          |
    | Tait            | [1] Table 3B-1 (p. 41)               |

    **References**

    1.  Danner, Ronald P., and Martin S. High. Handbook of polymer
        solution thermodynamics. John Wiley & Sons, 2010.
    2.  Caruthers et al. Handbook of Diffusion and Thermal Properties of
        Polymers and Polymer Solutions. AIChE, 1998.
    """
    return load_PVT_parameters(method=cls.__name__)

SanchezLacombe ¤

Sanchez-Lacombe equation of state for the specific volume of a polymer.

This EoS implements the following implicit PVT dependence:

\[ \frac{1}{\tilde{V}^2} + \tilde{P} + \tilde{T}\left [ \ln\left ( 1-\frac{1}{\tilde{V}} \right ) + \frac{1}{\tilde{V}} \right ]=0 \]

where \(\tilde{V}=V/V^*\), \(\tilde{P}=P/P^*\) and \(\tilde{T}=T/T^*\) are, respectively, the reduced volume, reduced pressure and reduced temperature. \(V^*\), \(P^*\) and \(T^*\) are reference quantities that are polymer dependent.

References

  • Caruthers et al. Handbook of Diffusion and Thermal Properties of Polymers and Polymer Solutions. AIChE, 1998.
PARAMETER DESCRIPTION
V0

Reference volume, \(V^*\).

TYPE: float

T0

Reference temperature, \(T^*\).

TYPE: float

P0

Reference pressure, \(P^*\).

TYPE: float

Tmin

Lower temperature bound. Unit = K.

TYPE: float DEFAULT: 0.0

Tmax

Upper temperature bound. Unit = K.

TYPE: float DEFAULT: inf

Pmin

Lower pressure bound. Unit = Pa.

TYPE: float DEFAULT: 0.0

Pmax

Upper pressure bound. Unit = Pa.

TYPE: float DEFAULT: inf

name

Name.

TYPE: str DEFAULT: ''

Source code in src/polykin/properties/pvt_polymer/eos.py
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
class SanchezLacombe(PolymerPVTEoS):
    r"""Sanchez-Lacombe equation of state for the specific volume of a polymer.

    This EoS implements the following implicit PVT dependence:

    $$ \frac{1}{\tilde{V}^2} + \tilde{P} +
        \tilde{T}\left [ \ln\left ( 1-\frac{1}{\tilde{V}} \right ) +
        \frac{1}{\tilde{V}} \right ]=0 $$

    where $\tilde{V}=V/V^*$, $\tilde{P}=P/P^*$ and $\tilde{T}=T/T^*$ are,
    respectively, the reduced volume, reduced pressure and reduced temperature.
    $V^*$, $P^*$ and $T^*$ are reference quantities that are polymer dependent.

    **References**

    *   Caruthers et al. Handbook of Diffusion and Thermal Properties of
        Polymers and Polymer Solutions. AIChE, 1998.

    Parameters
    ----------
    V0 : float
        Reference volume, $V^*$.
    T0 : float
        Reference temperature, $T^*$.
    P0 : float
        Reference pressure, $P^*$.
    Tmin : float
        Lower temperature bound.
        Unit = K.
    Tmax : float
        Upper temperature bound.
        Unit = K.
    Pmin : float
        Lower pressure bound.
        Unit = Pa.
    Pmax : float
        Upper pressure bound.
        Unit = Pa.
    name : str
        Name.
    """

    @staticmethod
    def equation(v: float,
                 t: float,
                 p: float
                 ) -> tuple[float, float, float]:
        """Sanchez-Lacombe equation of state and its volume derivatives.

        Parameters
        ----------
        v : float
            Reduced volume.
        t : float
            Reduced temperature.
        p : float
            Reduced pressure.

        Returns
        -------
        tuple[float, float, float]
            Equation of state, first derivative, second derivative.
        """
        f = 1/v**2 + p + t*(log(1 - 1/v) + 1/v)  # =0
        d1f = ((t - 2)*v + 2)/((v - 1)*v**3)
        d2f = (-3*(t - 2)*v**2 + 2*(t - 6)*v + 6)/((v - 1)**2*v**4)
        return (f, d1f, d2f)

V ¤

V(
    T: Union[float, FloatArrayLike],
    P: Union[float, FloatArrayLike],
    Tunit: Literal["C", "K"] = "K",
    Punit: Literal["bar", "MPa", "Pa"] = "Pa",
) -> Union[float, FloatArray]

Evaluate the specific volume, \(\hat{V}\), at given temperature and pressure, including unit conversion and range check.

PARAMETER DESCRIPTION
T

Temperature. Unit = Tunit.

TYPE: float | FloatArrayLike

P

Pressure. Unit = Punit.

TYPE: float | FloatArrayLike

Tunit

Temperature unit.

TYPE: Literal['C', 'K'] DEFAULT: 'K'

Punit

Pressure unit.

TYPE: Literal['bar', 'MPa', 'Pa'] DEFAULT: 'Pa'

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/base.py
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def V(self,
      T: Union[float, FloatArrayLike],
      P: Union[float, FloatArrayLike],
      Tunit: Literal['C', 'K'] = 'K',
      Punit: Literal['bar', 'MPa', 'Pa'] = 'Pa'
      ) -> Union[float, FloatArray]:
    r"""Evaluate the specific volume, $\hat{V}$, at given temperature and
    pressure, including unit conversion and range check.

    Parameters
    ----------
    T : float | FloatArrayLike
        Temperature.
        Unit = `Tunit`.
    P : float | FloatArrayLike
        Pressure.
        Unit = `Punit`.
    Tunit : Literal['C', 'K']
        Temperature unit.
    Punit : Literal['bar', 'MPa', 'Pa']
        Pressure unit.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    TK = convert_check_temperature(T, Tunit, self.Trange)
    Pa = convert_check_pressure(P, Punit, self.Prange)
    return self.eval(TK, Pa)

alpha ¤

alpha(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate thermal expansion coefficient, \(\alpha\).

\[\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Thermal expansion coefficient, \(\alpha\). Unit = 1/K.

Source code in src/polykin/properties/pvt_polymer/eos.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
def alpha(self,
          T: Union[float, FloatArray],
          P: Union[float, FloatArray]
          ) -> Union[float, FloatArray]:
    r"""Calculate thermal expansion coefficient, $\alpha$.

    $$\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Thermal expansion coefficient, $\alpha$.
        Unit = 1/K.
    """
    dT = 0.5
    V2 = self.eval(T + dT, P)
    V1 = self.eval(T - dT, P)
    return (V2 - V1)/dT/(V1 + V2)

beta ¤

beta(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate isothermal compressibility coefficient, \(\beta\).

\[\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Isothermal compressibility coefficient, \(\beta\). Unit = 1/Pa.

Source code in src/polykin/properties/pvt_polymer/eos.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def beta(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Calculate isothermal compressibility coefficient, $\beta$.

    $$\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Isothermal compressibility coefficient, $\beta$.
        Unit = 1/Pa.
    """
    dP = 1e5
    P2 = P + dP
    P1 = np.max(P - dP, 0)
    V2 = self.eval(T, P2)
    V1 = self.eval(T, P1)
    return -(V2 - V1)/(P2 - P1)/(V1 + V2)*2

equation staticmethod ¤

equation(
    v: float, t: float, p: float
) -> tuple[float, float, float]

Sanchez-Lacombe equation of state and its volume derivatives.

PARAMETER DESCRIPTION
v

Reduced volume.

TYPE: float

t

Reduced temperature.

TYPE: float

p

Reduced pressure.

TYPE: float

RETURNS DESCRIPTION
tuple[float, float, float]

Equation of state, first derivative, second derivative.

Source code in src/polykin/properties/pvt_polymer/eos.py
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
@staticmethod
def equation(v: float,
             t: float,
             p: float
             ) -> tuple[float, float, float]:
    """Sanchez-Lacombe equation of state and its volume derivatives.

    Parameters
    ----------
    v : float
        Reduced volume.
    t : float
        Reduced temperature.
    p : float
        Reduced pressure.

    Returns
    -------
    tuple[float, float, float]
        Equation of state, first derivative, second derivative.
    """
    f = 1/v**2 + p + t*(log(1 - 1/v) + 1/v)  # =0
    d1f = ((t - 2)*v + 2)/((v - 1)*v**3)
    d2f = (-3*(t - 2)*v**2 + 2*(t - 6)*v + 6)/((v - 1)**2*v**4)
    return (f, d1f, d2f)

eval ¤

eval(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Evaluate specific volume, \(\hat{V}\), at given SI conditions without unit conversions or checks.

PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/eos.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@vectorize
def eval(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Evaluate specific volume, $\hat{V}$, at given SI conditions without
    unit conversions or checks.

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    t = T/self.T0
    p = P/self.P0
    solution = root_scalar(f=self.equation,
                           args=(t, p),
                           # bracket=[1.1, 1.5],
                           x0=1.05,
                           method='halley',
                           fprime=True,
                           fprime2=True)

    if solution.converged:
        v = solution.root
        V = v*self.V0
    else:
        print(solution.flag)
        V = -1.
    return V

from_database classmethod ¤

from_database(name: str) -> Optional[PolymerPVTEquation]

Construct PolymerPVTEquation with parameters from the database.

PARAMETER DESCRIPTION
name

Polymer code name.

TYPE: str

Source code in src/polykin/properties/pvt_polymer/base.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@classmethod
def from_database(cls,
                  name: str
                  ) -> Optional[PolymerPVTEquation]:
    r"""Construct `PolymerPVTEquation` with parameters from the database.

    Parameters
    ----------
    name : str
        Polymer code name.
    """
    table = load_PVT_parameters(method=cls.__name__)
    try:
        mask = table.index == name
        parameters = table[mask].iloc[0, :].to_dict()
        return cls(**parameters, name=name)
    except IndexError:
        print(
            f"Error: '{name}' does not exist in polymer database.\n"
            f"Valid names are: {table.index.to_list()}")

get_database classmethod ¤

get_database() -> pd.DataFrame

Get database with parameters for the respective PVT equation.

Method Reference
Flory [2] Table 4.1.7 (p. 72-73)
Hartmann-Haque [2] Table 4.1.11 (p. 85-86)
Sanchez-Lacombe [2] Table 4.1.9 (p. 78-79)
Tait [1] Table 3B-1 (p. 41)

References

  1. Danner, Ronald P., and Martin S. High. Handbook of polymer solution thermodynamics. John Wiley & Sons, 2010.
  2. Caruthers et al. Handbook of Diffusion and Thermal Properties of Polymers and Polymer Solutions. AIChE, 1998.
Source code in src/polykin/properties/pvt_polymer/base.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@classmethod
def get_database(cls) -> pd.DataFrame:
    r"""Get database with parameters for the respective PVT equation.

    | Method          | Reference                            |
    | :-----------    | ------------------------------------ |
    | Flory           | [2] Table 4.1.7  (p. 72-73)          |
    | Hartmann-Haque  | [2] Table 4.1.11 (p. 85-86)          |
    | Sanchez-Lacombe | [2] Table 4.1.9  (p. 78-79)          |
    | Tait            | [1] Table 3B-1 (p. 41)               |

    **References**

    1.  Danner, Ronald P., and Martin S. High. Handbook of polymer
        solution thermodynamics. John Wiley & Sons, 2010.
    2.  Caruthers et al. Handbook of Diffusion and Thermal Properties of
        Polymers and Polymer Solutions. AIChE, 1998.
    """
    return load_PVT_parameters(method=cls.__name__)

Tait ¤

Tait equation of state for the specific volume of a liquid.

This EoS implements the following explicit PVT dependence:

\[\hat{V}(T,P)=\hat{V}(T,0)\left[1-C\ln\left(\frac{P}{B(T)}\right)\right]\]

with:

\[ \begin{gather*} \hat{V}(T,0) = A_0 + A_1(T - 273.15) + A_2(T - 273.15)^2 \\ B(T) = B_0\exp\left [-B_1(T - 273.15)\right] \end{gather*} \]

where \(A_i\) and \(B_i\) are constant parameters, \(T\) is the absolute temperature, and \(P\) is the pressure.

References

  • Danner, Ronald P., and Martin S. High. Handbook of polymer solution thermodynamics. John Wiley & Sons, 2010.
PARAMETER DESCRIPTION
A0

Parameter of equation. Unit = m³/kg.

TYPE: float

A1

Parameter of equation. Unit = m³/(kg·K).

TYPE: float

A2

Parameter of equation. Unit = m³/(kg·K²).

TYPE: float

B0

Parameter of equation. Unit = Pa.

TYPE: float

B1

Parameter of equation. Unit = 1/K.

TYPE: float

Tmin

Lower temperature bound. Unit = K.

TYPE: float DEFAULT: 0.0

Tmax

Upper temperature bound. Unit = K.

TYPE: float DEFAULT: inf

Pmin

Lower pressure bound. Unit = Pa.

TYPE: float DEFAULT: 0.0

Pmax

Upper pressure bound. Unit = Pa.

TYPE: float DEFAULT: inf

name

Name.

TYPE: str DEFAULT: ''

Source code in src/polykin/properties/pvt_polymer/tait.py
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
class Tait(PolymerPVTEquation):
    r"""Tait equation of state for the specific volume of a liquid.

    This EoS implements the following explicit PVT dependence:

    $$\hat{V}(T,P)=\hat{V}(T,0)\left[1-C\ln\left(\frac{P}{B(T)}\right)\right]$$

    with:

    $$ \begin{gather*}
    \hat{V}(T,0) = A_0 + A_1(T - 273.15) + A_2(T - 273.15)^2 \\
    B(T) = B_0\exp\left [-B_1(T - 273.15)\right]
    \end{gather*} $$

    where $A_i$ and $B_i$ are constant parameters, $T$ is the absolute
    temperature, and $P$ is the pressure.

    **References**

    *   Danner, Ronald P., and Martin S. High. Handbook of polymer
        solution thermodynamics. John Wiley & Sons, 2010.

    Parameters
    ----------
    A0 : float
        Parameter of equation.
        Unit = m³/kg.
    A1 : float
        Parameter of equation.
        Unit = m³/(kg·K).
    A2 : float
        Parameter of equation.
        Unit = m³/(kg·K²).
    B0 : float
        Parameter of equation.
        Unit = Pa.
    B1 : float
        Parameter of equation.
        Unit = 1/K.
    Tmin : float
        Lower temperature bound.
        Unit = K.
    Tmax : float
        Upper temperature bound.
        Unit = K.
    Pmin : float
        Lower pressure bound.
        Unit = Pa.
    Pmax : float
        Upper pressure bound.
        Unit = Pa.
    name : str
        Name.
    """

    A0: float
    A1: float
    A2: float
    B0: float
    B1: float

    _C = 0.0894

    def __init__(self,
                 A0: float,
                 A1: float,
                 A2: float,
                 B0: float,
                 B1: float,
                 Tmin: float = 0.0,
                 Tmax: float = np.inf,
                 Pmin: float = 0.0,
                 Pmax: float = np.inf,
                 name: str = ''
                 ) -> None:
        """Construct `Tait` with the given parameters."""

        # Check bounds
        check_bounds(A0, 1e-4, 2e-3, 'A0')
        check_bounds(A1, 1e-7, 2e-6, 'A1')
        check_bounds(A2, -2e-9, 1e-8, 'A2')
        check_bounds(B0, 1e7, 1e9, 'B0')
        check_bounds(B1, 1e-3, 2e-2, 'B1')

        self.A0 = A0
        self.A1 = A1
        self.A2 = A2
        self.B0 = B0
        self.B1 = B1
        super().__init__(Tmin, Tmax, Pmin, Pmax, name)

    def __repr__(self) -> str:
        return (
            f"name:          {self.name}\n"
            f"symbol:        {self.symbol}\n"
            f"unit:          {self.unit}\n"
            f"Trange [K]:    {self.Trange}\n"
            f"Prange [Pa]:   {self.Prange}\n"
            f"A0 [m³/kg]:    {self.A0}\n"
            f"A1 [m³/kg.K]:  {self.A1}\n"
            f"A2 [m³/kg.K²]: {self.A2}\n"
            f"B0 [Pa]:       {self.B0}\n"
            f"B1 [1/K]:      {self.B1}"
        )

    def eval(self,
             T: Union[float, FloatArray],
             P: Union[float, FloatArray]
             ) -> Union[float, FloatArray]:
        r"""Evaluate specific volume, $\hat{V}$, at given SI conditions without
        unit conversions or checks.

        Parameters
        ----------
        T : float | FloatArray
            Temperature.
            Unit = K.
        P : float | FloatArray
            Pressure.
            Unit = Pa.

        Returns
        -------
        float | FloatArray
            Specific volume.
            Unit = m³/kg.
        """
        TC = T - 273.15
        V0 = self.A0 + self.A1*TC + self.A2*TC**2
        B = self._B(T)
        V = V0*(1 - self._C*log(1 + P/B))
        return V

    def _B(self,
           T: Union[float, FloatArray]
           ) -> Union[float, FloatArray]:
        r"""Parameter B(T).

        Parameters
        ----------
        T : float | FloatArray
            Temperature.
            Unit = K.

        Returns
        -------
        float | FloatArray
            B(T).
            Unit = Pa.
        """
        return self.B0*exp(-self.B1*(T - 273.15))

    def alpha(self,
              T: Union[float, FloatArray],
              P: Union[float, FloatArray]
              ) -> Union[float, FloatArray]:
        r"""Calculate thermal expansion coefficient, $\alpha$.

        $$\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}$$

        Parameters
        ----------
        T : float | FloatArray
            Temperature.
            Unit = K.
        P : float | FloatArray
            Pressure.
            Unit = Pa.

        Returns
        -------
        float | FloatArray
            Thermal expansion coefficient, $\alpha$.
            Unit = 1/K.
        """
        A0 = self.A0
        A1 = self.A1
        A2 = self.A2
        TC = T - 273.15
        alpha0 = (A1 + 2*A2*TC)/(A0 + A1*TC + A2*TC**2)
        return alpha0 - P*self.B1*self.beta(T, P)

    def beta(self,
             T: Union[float, FloatArray],
             P: Union[float, FloatArray]
             ) -> Union[float, FloatArray]:
        r"""Calculate isothermal compressibility coefficient, $\beta$.

        $$\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}$$

        Parameters
        ----------
        T : float | FloatArray
            Temperature.
            Unit = K.
        P : float | FloatArray
            Pressure.
            Unit = Pa.

        Returns
        -------
        float | FloatArray
            Isothermal compressibility coefficient, $\beta$.
            Unit = 1/Pa.
        """
        B = self._B(T)
        return (self._C/(P + B))/(1 - self._C*log(1 + P/B))

V ¤

V(
    T: Union[float, FloatArrayLike],
    P: Union[float, FloatArrayLike],
    Tunit: Literal["C", "K"] = "K",
    Punit: Literal["bar", "MPa", "Pa"] = "Pa",
) -> Union[float, FloatArray]

Evaluate the specific volume, \(\hat{V}\), at given temperature and pressure, including unit conversion and range check.

PARAMETER DESCRIPTION
T

Temperature. Unit = Tunit.

TYPE: float | FloatArrayLike

P

Pressure. Unit = Punit.

TYPE: float | FloatArrayLike

Tunit

Temperature unit.

TYPE: Literal['C', 'K'] DEFAULT: 'K'

Punit

Pressure unit.

TYPE: Literal['bar', 'MPa', 'Pa'] DEFAULT: 'Pa'

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/base.py
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def V(self,
      T: Union[float, FloatArrayLike],
      P: Union[float, FloatArrayLike],
      Tunit: Literal['C', 'K'] = 'K',
      Punit: Literal['bar', 'MPa', 'Pa'] = 'Pa'
      ) -> Union[float, FloatArray]:
    r"""Evaluate the specific volume, $\hat{V}$, at given temperature and
    pressure, including unit conversion and range check.

    Parameters
    ----------
    T : float | FloatArrayLike
        Temperature.
        Unit = `Tunit`.
    P : float | FloatArrayLike
        Pressure.
        Unit = `Punit`.
    Tunit : Literal['C', 'K']
        Temperature unit.
    Punit : Literal['bar', 'MPa', 'Pa']
        Pressure unit.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    TK = convert_check_temperature(T, Tunit, self.Trange)
    Pa = convert_check_pressure(P, Punit, self.Prange)
    return self.eval(TK, Pa)

__init__ ¤

__init__(
    A0: float,
    A1: float,
    A2: float,
    B0: float,
    B1: float,
    Tmin: float = 0.0,
    Tmax: float = np.inf,
    Pmin: float = 0.0,
    Pmax: float = np.inf,
    name: str = "",
) -> None

Construct Tait with the given parameters.

Source code in src/polykin/properties/pvt_polymer/tait.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
def __init__(self,
             A0: float,
             A1: float,
             A2: float,
             B0: float,
             B1: float,
             Tmin: float = 0.0,
             Tmax: float = np.inf,
             Pmin: float = 0.0,
             Pmax: float = np.inf,
             name: str = ''
             ) -> None:
    """Construct `Tait` with the given parameters."""

    # Check bounds
    check_bounds(A0, 1e-4, 2e-3, 'A0')
    check_bounds(A1, 1e-7, 2e-6, 'A1')
    check_bounds(A2, -2e-9, 1e-8, 'A2')
    check_bounds(B0, 1e7, 1e9, 'B0')
    check_bounds(B1, 1e-3, 2e-2, 'B1')

    self.A0 = A0
    self.A1 = A1
    self.A2 = A2
    self.B0 = B0
    self.B1 = B1
    super().__init__(Tmin, Tmax, Pmin, Pmax, name)

alpha ¤

alpha(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate thermal expansion coefficient, \(\alpha\).

\[\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Thermal expansion coefficient, \(\alpha\). Unit = 1/K.

Source code in src/polykin/properties/pvt_polymer/tait.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
def alpha(self,
          T: Union[float, FloatArray],
          P: Union[float, FloatArray]
          ) -> Union[float, FloatArray]:
    r"""Calculate thermal expansion coefficient, $\alpha$.

    $$\alpha=\frac{1}{V}\left(\frac{\partial V}{\partial T}\right)_{P}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Thermal expansion coefficient, $\alpha$.
        Unit = 1/K.
    """
    A0 = self.A0
    A1 = self.A1
    A2 = self.A2
    TC = T - 273.15
    alpha0 = (A1 + 2*A2*TC)/(A0 + A1*TC + A2*TC**2)
    return alpha0 - P*self.B1*self.beta(T, P)

beta ¤

beta(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Calculate isothermal compressibility coefficient, \(\beta\).

\[\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}\]
PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Isothermal compressibility coefficient, \(\beta\). Unit = 1/Pa.

Source code in src/polykin/properties/pvt_polymer/tait.py
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
def beta(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Calculate isothermal compressibility coefficient, $\beta$.

    $$\beta=-\frac{1}{V}\left(\frac{\partial V}{\partial P}\right)_{T}$$

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Isothermal compressibility coefficient, $\beta$.
        Unit = 1/Pa.
    """
    B = self._B(T)
    return (self._C/(P + B))/(1 - self._C*log(1 + P/B))

eval ¤

eval(
    T: Union[float, FloatArray], P: Union[float, FloatArray]
) -> Union[float, FloatArray]

Evaluate specific volume, \(\hat{V}\), at given SI conditions without unit conversions or checks.

PARAMETER DESCRIPTION
T

Temperature. Unit = K.

TYPE: float | FloatArray

P

Pressure. Unit = Pa.

TYPE: float | FloatArray

RETURNS DESCRIPTION
float | FloatArray

Specific volume. Unit = m³/kg.

Source code in src/polykin/properties/pvt_polymer/tait.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
def eval(self,
         T: Union[float, FloatArray],
         P: Union[float, FloatArray]
         ) -> Union[float, FloatArray]:
    r"""Evaluate specific volume, $\hat{V}$, at given SI conditions without
    unit conversions or checks.

    Parameters
    ----------
    T : float | FloatArray
        Temperature.
        Unit = K.
    P : float | FloatArray
        Pressure.
        Unit = Pa.

    Returns
    -------
    float | FloatArray
        Specific volume.
        Unit = m³/kg.
    """
    TC = T - 273.15
    V0 = self.A0 + self.A1*TC + self.A2*TC**2
    B = self._B(T)
    V = V0*(1 - self._C*log(1 + P/B))
    return V

from_database classmethod ¤

from_database(name: str) -> Optional[PolymerPVTEquation]

Construct PolymerPVTEquation with parameters from the database.

PARAMETER DESCRIPTION
name

Polymer code name.

TYPE: str

Source code in src/polykin/properties/pvt_polymer/base.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@classmethod
def from_database(cls,
                  name: str
                  ) -> Optional[PolymerPVTEquation]:
    r"""Construct `PolymerPVTEquation` with parameters from the database.

    Parameters
    ----------
    name : str
        Polymer code name.
    """
    table = load_PVT_parameters(method=cls.__name__)
    try:
        mask = table.index == name
        parameters = table[mask].iloc[0, :].to_dict()
        return cls(**parameters, name=name)
    except IndexError:
        print(
            f"Error: '{name}' does not exist in polymer database.\n"
            f"Valid names are: {table.index.to_list()}")

get_database classmethod ¤

get_database() -> pd.DataFrame

Get database with parameters for the respective PVT equation.

Method Reference
Flory [2] Table 4.1.7 (p. 72-73)
Hartmann-Haque [2] Table 4.1.11 (p. 85-86)
Sanchez-Lacombe [2] Table 4.1.9 (p. 78-79)
Tait [1] Table 3B-1 (p. 41)

References

  1. Danner, Ronald P., and Martin S. High. Handbook of polymer solution thermodynamics. John Wiley & Sons, 2010.
  2. Caruthers et al. Handbook of Diffusion and Thermal Properties of Polymers and Polymer Solutions. AIChE, 1998.
Source code in src/polykin/properties/pvt_polymer/base.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@classmethod
def get_database(cls) -> pd.DataFrame:
    r"""Get database with parameters for the respective PVT equation.

    | Method          | Reference                            |
    | :-----------    | ------------------------------------ |
    | Flory           | [2] Table 4.1.7  (p. 72-73)          |
    | Hartmann-Haque  | [2] Table 4.1.11 (p. 85-86)          |
    | Sanchez-Lacombe | [2] Table 4.1.9  (p. 78-79)          |
    | Tait            | [1] Table 3B-1 (p. 41)               |

    **References**

    1.  Danner, Ronald P., and Martin S. High. Handbook of polymer
        solution thermodynamics. John Wiley & Sons, 2010.
    2.  Caruthers et al. Handbook of Diffusion and Thermal Properties of
        Polymers and Polymer Solutions. AIChE, 1998.
    """
    return load_PVT_parameters(method=cls.__name__)