@@ -639,6 +639,8 @@ template simulationFile_nls(SimCode simCode)
639639 <%simulationFileHeader(simCode.fileNamePrefix)%>
640640 #include "<%simCode.fileNamePrefix%>_12jac.h"
641641 #include "simulation/jacobian_util.h"
642+ #include "simulation/arrayIndex.h"
643+
642644 #if defined(__cplusplus)
643645 extern "C" {
644646 #endif
@@ -663,6 +665,8 @@ template simulationFile_lsy(SimCode simCode)
663665 /* Linear Systems */
664666 <%simulationFileHeader(simCode.fileNamePrefix)%>
665667 #include "<%simCode.fileNamePrefix%>_12jac.h"
668+ #include "simulation/arrayIndex.h"
669+
666670 #if defined(__cplusplus)
667671 extern "C" {
668672 #endif
@@ -913,7 +917,29 @@ template simulationFile_jac_header(SimCode simCode)
913917 case simCode as SIMCODE(__) then
914918 <<
915919 /* Jacobians */
916- static const REAL_ATTRIBUTE dummyREAL_ATTRIBUTE = omc_dummyRealAttribute;
920+ static _index_t one_dim[1] = { 1 } ;
921+ static modelica_real nominal_data[1] = { 1.0 } ;
922+ static modelica_real start_data[1] = { 0.0 } ;
923+ static const REAL_ATTRIBUTE dummyREAL_ATTRIBUTE = {
924+ .unit = NULL,
925+ .displayUnit = NULL,
926+ .min = -DBL_MAX,
927+ .max = DBL_MAX,
928+ .fixed = FALSE ,
929+ .useNominal = FALSE ,
930+ .nominal = {
931+ .ndims = 1,
932+ .dim_size = one_dim,
933+ .data = ( void* )nominal_data,
934+ .flexible = FALSE
935+ } ,
936+ .start = {
937+ .ndims = 1,
938+ .dim_size = one_dim,
939+ .data = ( void* )start_data,
940+ .flexible = FALSE
941+ }
942+ };
917943
918944 <%symJacDefinition(jacobianMatrices, modelNamePrefix(simCode))%><%\n%>
919945 >>
@@ -931,6 +957,8 @@ template simulationFile_opt(SimCode simCode)
931957 /* Optimization */
932958 <%simulationFileHeader(simCode.fileNamePrefix)%>
933959 #include "<%fileNamePrefix%>_12jac.h"
960+ #include "simulation/arrayIndex.h"
961+
934962 #if defined(__cplusplus)
935963 extern "C" {
936964 #endif
@@ -2868,6 +2896,8 @@ template functionNonLinearResidualsMultiFile2(list<list<SimEqSystem>> nonlinearS
28682896 /* Non Linear Systems <%fullPathPrefix + fileName%> */
28692897 <%simulationFileHeader(fileNamePrefix)%>
28702898 #include "<%fileNamePrefix%>_12jac.h"
2899+ #include "simulation/arrayIndex.h"
2900+
28712901 #if defined(__cplusplus)
28722902 extern "C" {
28732903 #endif
@@ -3287,12 +3317,22 @@ template generateStaticInitialData(list<ComponentRef> crefs, String indexName)
32873317::=
32883318 let systemType = ' NONLINEAR_SYSTEM_DATA'
32893319 let bodyStaticData = (crefs |> cr hasindex i0 =>
3320+ let nominal = match cref2simvar(crefRemovePrePrefix(cr), getSimCode())
3321+ case SIMVAR(type_=T_REAL(__), varKind=PARAM()) then
3322+ ' getNominalFromScalarIdx(data-> simulationInfo , data-> modelData , VAR_KIND_PARAMETER, <% crefIndexWithComment(cr)%> )'
3323+ case SIMVAR(type_=T_REAL(__)) then
3324+ ' getNominalFromScalarIdx(data-> simulationInfo , data-> modelData , VAR_KIND_VARIABLE, <% crefIndexWithComment(cr)%> )'
3325+ else
3326+ ' <% crefAttributes(cr)%> .nominal'
3327+ end match
3328+
32903329 <<
32913330 /* static nls data for <%crefStrNoUnderscore(cr)%> */
3292- sysData->nominal[i] = <%crefAttributes(cr)%>.nominal ;
3331+ sysData->nominal[i] = <%nominal%> ;
32933332 sysData->min[i] = <%crefAttributes(cr)%>.min;
32943333 sysData->max[i++] = <%crefAttributes(cr)%>.max;
32953334 >>
3335+
32963336 ;separator="\n ")
32973337 <<
32983338
@@ -3406,17 +3446,17 @@ let &sub = buffer ""
34063446 {
34073447 /* min ******************************************************** */
34083448 infoStreamPrint(OMC_LOG_INIT, 1, "updating min-values");
3409- <%minValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix, contextOther)%>
3449+ <%( minValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix, contextOther) ; separator=" \n " )%>
34103450 messageClose(OMC_LOG_INIT);
34113451
34123452 /* max ******************************************************** */
34133453 infoStreamPrint(OMC_LOG_INIT, 1, "updating max-values");
3414- <%maxValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix, contextOther)%>
3454+ <%( maxValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix, contextOther) ; separator=" \n " )%>
34153455 messageClose(OMC_LOG_INIT);
34163456
34173457 /* nominal **************************************************** */
34183458 infoStreamPrint(OMC_LOG_INIT, 1, "updating nominal-values");
3419- <%nominalValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix, contextOther)%>
3459+ <%( nominalValueEquations |> eq as SES_SIMPLE_ASSIGN(__) => equation_call(eq, modelNamePrefix, contextOther) ; separator=" \n " )%>
34203460 messageClose(OMC_LOG_INIT);
34213461
34223462 /* start ****************************************************** */
@@ -3467,26 +3507,52 @@ template functionUpdateBoundVariableAttributesFunctionsSimpleAssign(SimEqSystem
34673507 "Generates an equation that is just a simple assignment for an arribute binding. The attribute type is given by the
34683508 function argument ' attibute' (e.g min, max ...)"
34693509::=
3470- match eq
3471- case SES_SIMPLE_ASSIGN(__)
3472- case SES_SIMPLE_ASSIGN_CONSTRAINTS(__) then
3473- let &sub = buffer ""
3474- let &preExp = buffer ""
3475- let expPart = daeExp(exp, context, &preExp, &varDecls, &auxFunction)
3476- let postExp = if isStartCref(cref) then
3477- <<
3478- <%cref(popCref(cref), &sub)%> = <%cref(cref, &sub)%>;
3479- infoStreamPrint(OMC_LOG_INIT_V, 0, "updated start value: %s(start=<%crefToPrintfArg(popCref(cref))%>)", <%crefVarInfo(popCref(cref))%>.name, (<%crefType(popCref(cref))%>) <%cref(popCref(cref), &sub)%>);
3480- >>
3481- <<
3482- <%modelicaLine(eqInfo(eq))%>
3483- <%preExp%>
3484- <%crefAttributes(cref)%>.<%attribute%> = <%expPart%>;
3485- infoStreamPrint(OMC_LOG_INIT_V, 0, "%s(<%attribute%>=<%crefToPrintfArg(cref)%>)", <%crefVarInfo(cref)%>.name,
3486- (<%crefType(cref)%>) <%crefAttributes(cref)%>.<%attribute%>);
3487- <%postExp%>
3488- <%endModelicaLine()%>
3489- >>
3510+ match eq
3511+ case SES_SIMPLE_ASSIGN(__)
3512+ case SES_SIMPLE_ASSIGN_CONSTRAINTS(__) then
3513+ let &sub = buffer ""
3514+ let &preExp = buffer ""
3515+ let expPart = daeExp(exp, context, &preExp, &varDecls, &auxFunction)
3516+ let postExp = if isStartCref(cref) then
3517+ <<
3518+ <%cref(popCref(cref), &sub)%> = <%cref(cref, &sub)%>;
3519+ infoStreamPrint(OMC_LOG_INIT_V, 0, "updated start value: %s(start=<%crefToPrintfArg(popCref(cref))%>)",
3520+ <%crefVarInfo(popCref(cref))%>.name,
3521+ (<%crefType(popCref(cref))%>) <%cref(popCref(cref), &sub)%>);
3522+ >>
3523+
3524+ let updateEqs = match attribute
3525+ case "nominal" then
3526+ <<
3527+ if (<%crefVarDimension(cref)%>.numberOfDimensions == 0) {
3528+ put_real_element(<%expPart%>, 0, &<%crefAttributes(cref)%>.nominal);
3529+ } else {
3530+ throwStreamPrint(NULL, "Not yet implemented for array nominals.");
3531+ }
3532+
3533+ if (omc_useStream[OMC_LOG_INIT_V]) {
3534+ char nominal_buffer[2048];
3535+ real_vector_to_string(&<%crefAttributes(cref)%>.nominal, <%crefVarDimension(cref)%>.numberOfDimensions == 0, nominal_buffer, 2048);
3536+ infoStreamPrint(OMC_LOG_INIT_V, 0, "%s(nominal=%s)",
3537+ <%crefVarInfo(cref)%>.name,
3538+ nominal_buffer);
3539+ }
3540+ >>
3541+ else
3542+ <<
3543+ <%crefAttributes(cref)%>.<%attribute%> = <%expPart%>;
3544+ infoStreamPrint(OMC_LOG_INIT_V, 0, "%s(<%attribute%>=<%crefToPrintfArg(cref)%>)",
3545+ <%crefVarInfo(cref)%>.name,
3546+ (<%crefType(cref)%>) <%crefAttributes(cref)%>.<%attribute%>);
3547+ >>
3548+
3549+ <<
3550+ <%modelicaLine(eqInfo(eq))%>
3551+ <%preExp%>
3552+ <%updateEqs%>
3553+ <%postExp%>
3554+ <%endModelicaLine()%>
3555+ >>
34903556end functionUpdateBoundVariableAttributesFunctionsSimpleAssign;
34913557
34923558
@@ -7090,7 +7156,7 @@ template optimizationComponents1(ClassAttributes classAttribute, SimCode simCode
70907156 <<
70917157 min[<%i0%>] = <%crefAttributes(name)%>.min;
70927158 max[<%i0%>] = <%crefAttributes(name)%>.max;
7093- nominal[<%i0%>] = <%crefAttributes (name)%>.nominal ;
7159+ nominal[<%i0%>] = getNominalFromScalarIdx(data->simulationInfo, data->modelData, VAR_KIND_VARIABLE, <%crefIndexWithComment (name)%>) ;
70947160 useNominal[<%i0%>] = <%crefAttributes(name)%>.useNominal;
70957161 name[<%i0%>] =(char *) <%crefVarInfo(name)%>.name;
70967162 <%match type_ case T_REAL() then
0 commit comments