From d98307538747de73637bb6c23d4987fce1338d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amund=20Faller=20R=C3=A5heim?= Date: Thu, 13 Jun 2024 16:16:35 +0200 Subject: [PATCH] invalid_value parameter in compute_conductor_ampacity --- linerate/solver.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/linerate/solver.py b/linerate/solver.py index f2d01a8..c8f4c0e 100644 --- a/linerate/solver.py +++ b/linerate/solver.py @@ -118,6 +118,7 @@ def compute_conductor_ampacity( min_ampacity: Ampere = 0, max_ampacity: Ampere = 5_000, tolerance: float = 1, # Ampere + invalid_value=None, ) -> Ampere: r"""Use the bisection method to compute the steady-state thermal rating (ampacity). @@ -140,6 +141,10 @@ def compute_conductor_ampacity( bisection iterations will stop once the numerical ampacity uncertainty is below :math:`\Delta I`. The bisection method will run for :math:`\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 ------- @@ -148,4 +153,4 @@ def compute_conductor_ampacity( """ f = partial(heat_balance, max_conductor_temperature) - return bisect(f, min_ampacity, max_ampacity, tolerance, invalid_value=0) + return bisect(f, min_ampacity, max_ampacity, tolerance, invalid_value=invalid_value)