functional#

normalize(array, sum_array=None, minimum=1e-16)[source]#

Return a normalized array to a magnitude of 1. If magnitude is zero, all fractions will have equal value.

first_true_index(x)[source]#

Return index of first true value.

mixing_simple(z, y)[source]#

Return a weighted average of y given the weights, z.

Examples

>>> import numpy as np
>>> mixing_simple(np.array([0.1, 0.9]), np.array([0.01, 0.02]))
0.019000000000000003
mixing_logarithmic(z, y)[source]#

Return the logarithmic weighted average y given weights, z.

\[y = \sum_i z_i \cdot \log(y_i)\]

Notes

Does not work on negative values.

Examples

>>> import numpy as np
>>> mixing_logarithmic(np.array([0.1, 0.9]), np.array([0.01, 0.02]))
0.01866065983073615
mu_to_nu(mu, rho)[source]#

Return the kinematic viscosity (nu) given the dynamic viscosity (mu) and density (rho).

\[\nu = \frac{\mu}{\rho}\]

Examples

>>> mu_to_nu(0.000998, 998.)
1.0e-06
V_to_rho(V, MW)[source]#

Return the density (rho) in kg/m^3 given the molar volume (V) in m^3/mol and molecular weight (MW) in g/mol.

\[\rho = \frac{MW}{1000\cdot V}\]
Parameters:
  • V (float) – Molar volume, [m^3/mol]

  • MW (float) – Molecular weight, [g/mol]

Returns:

rho – Density, [kg/m^3]

Return type:

float

Examples

>>> V_to_rho(0.000132, 86.18)
652.878...
rho_to_V(rho, MW)[source]#

Return the molar volume (V) in m^3/mol given the density (rho) in kg/m^3 and molecular weight (MW) in g/mol.

\[V = \left(\frac{1000 \rho}{MW}\right)^{-1}\]
Parameters:
  • rho (float) – Density, [kg/m^3]

  • MW (float) – Molecular weight, [g/mol]

Returns:

V – Molar volume, [m^3/mol]

Return type:

float

Examples

>>> rho_to_V(652.9, 86.18)
0.0001319957...