Source code for appliedchemlabwork_tayra.A3._calc_viscosity

# SPDX-FileCopyrightText: 2026-present Tayra Sakurai <tayra_sakurai@icloud.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Calculates the viscosities."""
import numpy as np
import numpy.typing as npt
from typing import Any

__all__ = [
    "calc_relative_viscosity",
    "calc_specific_viscosity",
    "calc_inherent_viscosity",
    "calc_reduced_viscosity",
]


[docs] def calc_relative_viscosity( t: npt.NDArray[np.floating[Any]], t_0: float | np.floating[Any] ) -> npt.NDArray[np.floating[Any]]: """Calculates the relative viscosities. Parameters ---------- t : NDArray[floating[Any]] The time of the flows. t_0 : Any floating number The time of the flows. Returns ------- viscosity : NDArray[floating[Any]] The viscosities. Notes ----- This calculates the viscosity with an approximation formula following below: .. math:: \\eta_{\\mathrm{r}} \\approx{} \\frac{t_1}{t_{\\mathrm{s}}} Please note that this approximation is good if the concentration of the solution is enough low. If you are using a highly concentrated solution, please use other method than viscosity method. Viscosity method is not suitable for calculating the molecular weight from the concentrated solution data. """ return t / t_0
[docs] def calc_specific_viscosity( t: npt.NDArray[np.floating[Any]], t_0: float | np.floating[Any] ) -> npt.NDArray[np.floating[Any]]: """Calculates the specific viscosity. Parameters ---------- t : NDArray[floating[Any]] The times elapsed while the solution flew down. t_0 : floating[Any] | float The time of the flow of the solvent. Returns ------- specific : NDArray[Floating[Any]] The specific viscosities. """ return (t - t_0) / t_0
[docs] def calc_inherent_viscosity( t: npt.NDArray[np.floating[Any]], c: npt.NDArray[np.floating[Any]], t_0: float | np.floating[Any] ) -> npt.NDArray[np.floating[Any]]: """Returns the inherent viscosity. Parameters ---------- t : NDArray[floating[Any]] t_0 : floating[Any] Please see :func:`calc_relative_viscosity`. c : NDArray[floating[Any]] The concentrations of the solution. Returns ------- viscosity : NDArray[floating[Any]] The viscosity. See Also -------- calc_relative_viscosity : Detailed descriptions. Notes ----- This function returns the values of inherent viscosities. .. math:: \\frac{\\ln \\eta_{\\mathrm{r}}}{c} """ return np.log(calc_relative_viscosity(t, t_0)) / c
[docs] def calc_reduced_viscosity( t: npt.NDArray[np.floating[Any]], c: npt.NDArray[np.floating[Any]], t_0: np.floating[Any] | float ) -> npt.NDArray[np.floating[Any]]: """Calculates the reduced viscosity. Parameters ---------- t : NDArray[floating[Any]] t_0 : floating[Any] Please see ``calc_specific_viscosity``. c : NDArray[floating[Any]] The concentrations. Returns ------- viscosity : NDArray[floating[Any]] The viscosities. See Also -------- calc_specific_viscosity : Detailed descriptions. """ return calc_specific_viscosity(t, t_0) / c