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.
- 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:
- Returns:
rho – Density, [kg/m^3]
- Return type:
Examples
>>> V_to_rho(0.000132, 86.18) 652.878...