@@ -609,20 +609,31 @@ def _handle_error(self, e: RuntimeError) -> NoReturn:
609609 elif msg .startswith ("1 " ):
610610 msg = msg [2 :]
611611 zero_elements_index , inf_elements_index = self ._solver ._cy_solver .analyse_jacobian ()
612- if zero_elements_index :
612+ if inf_elements_index :
613+ inf_elements = [self ._elements [i ] for i in inf_elements_index ]
614+ printable_elements = ", " .join (f"{ type (e ).__name__ } ({ e .id !r} )" for e in inf_elements )
615+ msg += (
616+ f"The problem seems to come from the elements [{ printable_elements } ] that induce infinite values."
617+ )
618+ power_load = False
619+ flexible_load = False
620+ for inf_element in inf_elements :
621+ if isinstance (inf_element , PowerLoad ):
622+ power_load = True
623+ if inf_element .is_flexible :
624+ flexible_load = True
625+ if power_load :
626+ msg += " This might be caused by a bad potential initialization of a power load"
627+ if flexible_load :
628+ msg += ", or by flexible loads with very high alpha or incorrect flexible parameters voltages."
629+ raise RoseauLoadFlowException (msg = msg , code = RoseauLoadFlowExceptionCode .NAN_VALUE )
630+ elif zero_elements_index :
613631 zero_elements = [self ._elements [i ] for i in zero_elements_index ]
614632 printable_elements = ", " .join (f"{ type (e ).__name__ } ({ e .id !r} )" for e in zero_elements )
615633 msg += (
616634 f"The problem seems to come from the elements [{ printable_elements } ] that have at least one "
617635 f"disconnected phase. "
618636 )
619- if inf_elements_index :
620- inf_elements = [self ._elements [i ] for i in inf_elements_index ]
621- printable_elements = ", " .join (f"{ type (e ).__name__ } ({ e .id !r} )" for e in inf_elements )
622- msg += (
623- f"The problem seems to come from the elements [{ printable_elements } ] that induce infinite "
624- f"values. This might be caused by flexible loads with very high alpha."
625- )
626637 logger .error (msg )
627638 raise RoseauLoadFlowException (msg = msg , code = RoseauLoadFlowExceptionCode .BAD_JACOBIAN ) from e
628639 else :
0 commit comments