The solver module#

linerate.solver.bisect(f, xmin, xmax, tolerance, invalid_value=None)[source]#

Compute the roots of a function using a vectorized bisection method.

Parameters:
  • f (Callable[[float | float64 | ndarray[Any, dtype[float64]]], float | float64 | ndarray[Any, dtype[float64]]]) – \(f: \mathbb{R}^n \to \mathbb{R}^n\). Function whose roots we wish to find.

  • xmin (float | float64 | ndarray[Any, dtype[float64]]) – \(x_\min\). Minimum value for the free parameter, \(\mathbf{x}\). It is required that \(\text{sign}(f_i(x_\min)) \neq \text{sign}(f_i(x_\max))\). for all \(i\).

  • xmax (float | float64 | ndarray[Any, dtype[float64]]) – \(x_\max\). Maximum value for the free parameter, \(\mathbf{x}\). It is required that \(\text{sign}(f_i(x_\min)) \neq \text{sign}(f_i(x_\max))\). for all \(i\).

  • tolerance (float) – \(\Delta x\). The bisection iterations will terminate once all \(x_i\)-s are bounded within an interval of size \(\Delta x\) or less. The bisection method will run for \(\left\lceil\frac{x_\max - x_\min}{\Delta x}\right\rceil\) iterations.

  • invalid_value (float | None) – If provided, then this value is used whenever \(\text{sign}(f(\mathbf{x}_\min)) = \text{sign}(f(\mathbf{x}_\max))\).

Returns:

\(\tilde{\mathbf{x}}\). Estimate for the roots of \(f\). For each \(f_i\), there is a root \(x_i \in [\tilde{x}_i - 0.5 \Delta x, \tilde{x}_i + 0.5 \Delta x]\) so \(f_i(x_i) = 0\).

Return type:

Union[float, float64, ndarray[Any, dtype[float64]]]

linerate.solver.compute_conductor_temperature(heat_balance, current, min_temperature=-30, max_temperature=150, tolerance=0.5)[source]#

Use the bisection method to compute the steady state conductor temperature.

Parameters:
  • heat_balance (Callable[[Annotated[float | float64 | ndarray[Any, dtype[float64]], '°C'], Annotated[float | float64 | ndarray[Any, dtype[float64]], 'A']], Annotated[float | float64 | ndarray[Any, dtype[float64]], 'W/m']]) – \(f(T, A) = P_J + P_s - P_c - P_r~\left[\text{W}~\text{m}^{-1}\right]\). A function of both temperature and current that returns the heat balance for the given temperature-current pair.

  • current (Annotated[float | float64 | ndarray[Any, dtype[float64]], 'A']) – \(I_\text{max}~\left[\text{A}\right]\). The current flowing through the conductor.

  • min_temperature (Annotated[float | float64 | ndarray[Any, dtype[float64]], '°C']) – \(T_\text{min}~\left[^\circ\text{C}\right]\). Lower bound for the numerical scheme for computing the temperature

  • max_temperature (Annotated[float | float64 | ndarray[Any, dtype[float64]], '°C']) – \(T_\text{max}~\left[^\circ\text{C}\right]\). Upper bound for the numerical scheme for computing the temperature

  • tolerance (float) – \(\Delta T~\left[^\circ\text{C}\right]\). The numerical accuracy of the temperature. The bisection iterations will stop once the numerical temperature uncertainty is below \(\Delta T\). The bisection method will run for \(\left\lceil\frac{T_\text{min} - T_\text{min}}{\Delta T}\right\rceil\) iterations.

Returns:

\(I~\left[\text{A}\right]\). The thermal rating.

Return type:

Union[float, float64, ndarray[Any, dtype[float64]]]

linerate.solver.compute_conductor_ampacity(heat_balance, max_conductor_temperature, min_ampacity=0, max_ampacity=5000, tolerance=1, invalid_value=None)[source]#

Use the bisection method to compute the steady-state thermal rating (ampacity).

Parameters:
  • heat_balance (Callable[[Annotated[float | float64 | ndarray[Any, dtype[float64]], '°C'], Annotated[float | float64 | ndarray[Any, dtype[float64]], 'A']], Annotated[float | float64 | ndarray[Any, dtype[float64]], 'W/m']]) – \(f(T, A) = P_J + P_s - P_c - P_r~\left[\text{W}~\text{m}^{-1}\right]\). A function of both temperature and current that returns the heat balance for the given temperature-current pair.

  • max_conductor_temperature (Annotated[float | float64 | ndarray[Any, dtype[float64]], '°C']) – \(T_\text{max}~\left[^\circ\text{C}\right]\). Maximum allowed conductor temperature

  • min_ampacity (Annotated[float | float64 | ndarray[Any, dtype[float64]], 'A']) – \(I_\text{min}~\left[\text{A}\right]\). Lower bound for the numerical scheme for computing the ampacity

  • max_ampacity (Annotated[float | float64 | ndarray[Any, dtype[float64]], 'A']) – \(I_\text{min}~\left[\text{A}\right]\). Upper bound for the numerical scheme for computing the ampacity

  • tolerance (float) – \(\Delta I~\left[\text{A}\right]\). The numerical accuracy of the ampacity. The bisection iterations will stop once the numerical ampacity uncertainty is below \(\Delta I\). The bisection method will run for \(\left\lceil\frac{I_\text{max} - I_\text{min}}{\Delta I}\right\rceil\) iterations.

  • invalid_value – if the optimization problem is invalid, this value is returned instead of an error. Suggested value: 0 for 0-ampacity when max_conductor_temperature is exceeded for all ampacities.

Returns:

\(I~\left[\text{A}\right]\). The thermal rating.

Return type:

Union[float, float64, ndarray[Any, dtype[float64]]]