@@ -6882,6 +6882,9 @@ algorithm
68826882
68836883 // generate system for initialization
68846884 (outInitDAE, outInitDAE_lambda0_option, outRemovedInitialEquationLst, globalKnownVars) := Initialization . solveInitialSystem(dae);
6885+ if Flags . isSet(Flags . WARN_NO_NOMINAL ) then
6886+ warnAboutIterationVariablesWithNoNominal(outInitDAE);
6887+ end if ;
68856888
68866889 // use function tree from initDAE further for simDAE
68876890 simDAE := BackendDAEUtil . setFunctionTree(dae, BackendDAEUtil . getFunctions(outInitDAE. shared ));
@@ -6897,6 +6900,9 @@ algorithm
68976900
68986901 // post-optimization phase
68996902 simDAE := postOptimizeDAE(simDAE, postOptModules, matchingAlgorithm, daeHandler);
6903+ if Flags . isSet(Flags . WARN_NO_NOMINAL ) then
6904+ warnAboutIterationVariablesWithNoNominal(simDAE);
6905+ end if ;
69006906
69016907 // sort the globalKnownVars
69026908 simDAE := sortGlobalKnownVarsInDAE(simDAE);
@@ -9235,5 +9241,53 @@ algorithm
92359241 names := stringDelimitList(list(ComponentReference . printComponentRefStr(BackendVariable . varCref(BackendVariable . getVarAt(varsArray, v))) for v in vars), ", " );
92369242end getVariableNamesForErrorMessage;
92379243
9244+ // =============================================================================
9245+ // warn about iteration variables with no nominal attribute
9246+ //
9247+ // =============================================================================
9248+
9249+ protected function warnAboutIterationVariablesWithNoNominal
9250+ " author: ptaeuber"
9251+ input BackendDAE . BackendDAE inDAE;
9252+ protected
9253+ BackendDAE . StrongComponents comps;
9254+ String daeTypeStr, compKind;
9255+ list< Integer > vlst = {};
9256+ list< BackendDAE . Var > vars;
9257+ algorithm
9258+ daeTypeStr := BackendDump . printBackendDAEType2String(inDAE. shared . backendDAEType);
9259+ for syst in inDAE. eqs loop
9260+ BackendDAE . EQSYSTEM (matching= BackendDAE . MATCHING (comps= comps)) := syst;
9261+
9262+ // Go through all the strongly connected components.
9263+ for comp in comps loop
9264+ // Get the component's variables.
9265+ (compKind, vlst) := match(comp)
9266+ case BackendDAE . EQUATIONSYSTEM (vars = vlst, jacType = BackendDAE . JAC_NONLINEAR ())
9267+ then ("nonlinear equation system in the " + daeTypeStr + " DAE:" , vlst);
9268+ case BackendDAE . EQUATIONSYSTEM (vars = vlst, jacType = BackendDAE . JAC_GENERIC ())
9269+ then ("equation system w/o analytic Jacobian in the " + daeTypeStr + " DAE:" , vlst);
9270+ case BackendDAE . EQUATIONSYSTEM (vars = vlst, jacType = BackendDAE . JAC_NO_ANALYTIC ())
9271+ then ("equation system w/o analytic Jacobian in the " + daeTypeStr + " DAE:" , vlst);
9272+ case BackendDAE . TORNSYSTEM (BackendDAE . TEARINGSET (tearingvars = vlst), linear = false )
9273+ then ("torn nonlinear equation system in the " + daeTypeStr + " DAE:" , vlst);
9274+ // If the component is none of these types, do nothing.
9275+ else ("" , {});
9276+ end match;
9277+
9278+ if not listEmpty(vlst) then
9279+ // Filter out the variables that are missing start values.
9280+ vars := List . map1r(vlst, BackendVariable . getVarAt, syst. orderedVars);
9281+ vars := list(v for v guard(not BackendVariable . varHasNominalValue(v)) in vars);
9282+
9283+ // Print a warning if we found any variables with missing start values.
9284+ if not listEmpty(vars) then
9285+ Error . addCompilerWarning(BackendDump . varListStringIndented(vars, "Iteration variables with no nominal value in " + compKind));
9286+ end if ;
9287+ end if ;
9288+ end for ;
9289+ end for ;
9290+ end warnAboutIterationVariablesWithNoNominal;
9291+
92389292annotation(__OpenModelica_Interface= "backend" );
92399293end BackendDAEUtil ;
0 commit comments