diff --git a/docs/changelog.md b/docs/changelog.md index 750fa0c68..4280321ec 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,6 +17,13 @@ # Versions 0.13.x +## Version 0.13.4 (2023-06-xx) + +Bugfix release (upcoming) + +- Handle better how the internal `SolutionAbort` is used. Some invalid states where not being handled on absence of float-point exceptions, leading to potential useless results (NaN) and even crashes. +- `VSource`: Abort the solution if Z1 is zero. + ## Version 0.13.3 (2023-06-11) Bugfix release for some components. No other major changes. diff --git a/src/Common/Solution.pas b/src/Common/Solution.pas index 250868161..dba718c02 100644 --- a/src/Common/Solution.pas +++ b/src/Common/Solution.pas @@ -1026,6 +1026,9 @@ procedure TSolutionObj.DoPFLOWsolution; end; end; + if DSS.SolutionAbort then + Exit; + // The above resets the active sparse set to hY SolutionInitialized := TRUE; end; @@ -1297,7 +1300,14 @@ function TSolutionObj.SolveCircuit: Integer; {$ENDIF} BuildYMatrix(DSS, WHOLEMATRIX, TRUE); // Side Effect: Allocates V end; + + if DSS.SolutionAbort then + Exit; + DoPFLOWsolution; + + if DSS.SolutionAbort then + Exit; except ON E: EEsolv32Problem do begin @@ -1312,6 +1322,13 @@ procedure TSolutionObj.ZeroInjCurr; var I: Integer; begin + if Currents = NIL then + begin + DoSimpleMsg(DSS, _('General error: internal Currents vector is NIL. Please check your input data and retry.'), 11002); + DSS.SolutionAbort := True; + Exit; + end; + for i := 0 to DSS.ActiveCircuit.NumNodes do Currents[i] := 0; end; diff --git a/src/Common/Ymatrix.pas b/src/Common/Ymatrix.pas index d16719c92..3275b899d 100644 --- a/src/Common/Ymatrix.pas +++ b/src/Common/Ymatrix.pas @@ -132,6 +132,13 @@ procedure InitializeNodeVbase(DSS: TDSSContext); i: Integer; begin + if DSS.ActiveCircuit.Solution.NodeVbase = NIL then + begin + DoSimpleMsg(DSS, _('General error: internal NodeVbase is NIL. Please check your input data and retry.'), 11002); + DSS.SolutionAbort := True; + Exit; + end; + with DSS.ActiveCircuit, Solution do begin for i := 1 to NumNodes do @@ -368,14 +375,12 @@ procedure BuildYMatrix(DSS: TDSSContext; BuildOption: Integer; AllocateVI: Boole ReCalcInvalidYPrims(DSS.ActiveCircuit); end; - if DSS.SolutionAbort then begin DoSimpleMsg(DSS, _('Y matrix build aborted due to error in primitive Y calculations.'), 11001); Exit; // Some problem occured building Yprims end; - FrequencyChanged := FALSE; if LogEvents then