Skip to content

Commit

Permalink
fix, improve docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMVale committed Oct 30, 2023
1 parent c0d4378 commit 245ee06
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/polykin/properties/pvt_polymer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def eval(self, T: FloatOrArray, P: FloatOrArray) -> FloatOrArray:
-------
FloatOrArray
Specific volume.
Unit = m³/kg
Unit = m³/kg.
"""
pass

Expand Down
22 changes: 21 additions & 1 deletion src/polykin/properties/pvt_polymer/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ def eval(self,
T: FloatOrArray,
P: FloatOrArray
) -> FloatOrArray:
r"""Evaluate specific volume, $\hat{V}$, at given SI conditions without
unit conversions or checks.
Parameters
----------
T : FloatOrArray
Temperature.
Unit = K.
P : FloatOrArray
Pressure.
Unit = Pa.
Returns
-------
FloatOrArray
Specific volume.
Unit = m³/kg.
"""
t = T/self.T0
p = P/self.P0
solution = root_scalar(f=self.equation,
Expand Down Expand Up @@ -85,6 +103,7 @@ def alpha(self,
-------
FloatOrArray
Thermal expansion coefficient, $\alpha$.
Unit = 1/K.
"""
dT = 0.5
V2 = self.eval(T + dT, P)
Expand Down Expand Up @@ -112,6 +131,7 @@ def beta(self,
-------
FloatOrArray
Isothermal compressibility coefficient, $\beta$.
Unit = 1/Pa.
"""
dP = 1e5
P2 = P + dP
Expand Down Expand Up @@ -338,7 +358,7 @@ def equation(v: float, t: float, p: float) -> tuple[float, float, float]:
tuple[float, float, float]
Equation of state, first derivative, second derivative.
"""
f = 1/v**2 + p + t*(np.log(1 - 1/v) + 1/v)
f = 1/v**2 + p + t*(np.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)
10 changes: 6 additions & 4 deletions src/polykin/properties/pvt_polymer/tait.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def eval(self,
-------
FloatOrArray
Specific volume.
Unit = m³/kg
Unit = m³/kg.
"""
TC = T - 273.15
V0 = self.A0 + self.A1*TC + self.A2*TC**2
Expand All @@ -158,7 +158,7 @@ def _B(self,
-------
FloatOrArray
B(T).
Unit = Pa
Unit = Pa.
"""
return self.B0*np.exp(-self.B1*(T - 273.15))

Expand All @@ -182,7 +182,8 @@ def alpha(self,
Returns
-------
FloatOrArray
alpha.
Thermal expansion coefficient, $\alpha$.
Unit = 1/K.
"""
A0 = self.A0
A1 = self.A1
Expand Down Expand Up @@ -211,7 +212,8 @@ def beta(self,
Returns
-------
FloatOrArray
beta.
Isothermal compressibility coefficient, $\beta$.
Unit = 1/Pa.
"""
B = self._B(T)
return (self._C/(P + B))/(1 - self._C*np.log(1 + P/B))

0 comments on commit 245ee06

Please sign in to comment.