﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
2990	max/min attributes overwrite start at initialization	crupp@…	Lennart Ochel	"When max and min equations exist for a variable, the start value gets improperly overwritten with the max attribute value.



Here is some example code:
{{{
loadString(""
model maxminbug
parameter Real L = 2.5;
parameter Real a = 0.24;
Real x(start = 1.0, min=-L^2.0, max=L^2.0);
Real y;
equation
der(x)=y;
der(y)=-a*x;
end maxminbug;
"");

// Notice that pre(x) for initialization is 6.25, this should not be x.max
simulate(maxminbug, simflags=""-lv=LOG_INIT"");

// With -iim=none, x.start is set to 6.25, this should definitely not be x.max
simulate(maxminbug, simflags=""-lv=LOG_INIT -iim=none"");
}}}

The output:
{{{
""true
record SimulationResult
    resultFile = \""S:/Scratch/OMBugs/maxminbug_res.mat\"",
    simulationOptions = \""startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'maxminbug', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv=LOG_INIT'\"",
    messages = \""LOG_INIT          | info    | ### START INITIALIZATION ###
LOG_INIT          | info    | updating min-values
|                 | |       | | x(min=-6.25)
LOG_INIT          | info    | updating max-values
|                 | |       | | x(max=6.25)
LOG_INIT          | info    | updating nominal-values
LOG_INIT          | info    | updating start-values
LOG_INIT          | info    | initialization method: symbolic        [solves the initialization problem symbolically - default]
LOG_INIT          | info    | parameter values
|                 | |       | | real parameters
|                 | |       | | | [1] parameter Real L(start=2.5, fixed=true) = 2.5
|                 | |       | | | [2] parameter Real a(start=0.24, fixed=true) = 0.24
LOG_SOTI          | info    | ### SOLUTION OF THE INITIALIZATION ###
|                 | |       | | states variables
|                 | |       | | | [1] Real x(start=1, nominal=1) = 1 (pre: 6.25)
|                 | |       | | | [2] Real y(start=0, nominal=1) = 0 (pre: 0)
|                 | |       | | derivatives variables
|                 | |       | | | [3] Real der(x) = 0 (pre: 0)
|                 | |       | | | [4] Real der(y) = -0.24 (pre: 0)
LOG_INIT          | info    | ### END INITIALIZATION ###
\"",
    timeFrontend = 0.01207791378747863,
    timeBackend = 0.001214175020201499,
    timeSimCode = 0.0009431108479240174,
    timeTemplates = 0.03195060665444899,
    timeCompile = 1.29165318028847,
    timeSimulation = 0.09866671713699776,
    timeTotal = 1.436676041102952
end SimulationResult;
record SimulationResult
    resultFile = \""S:/Scratch/OMBugs/maxminbug_res.mat\"",
    simulationOptions = \""startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'maxminbug', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv=LOG_INIT -iim=none'\"",
    messages = \""LOG_INIT          | info    | ### START INITIALIZATION ###
LOG_INIT          | info    | updating min-values
|                 | |       | | x(min=-6.25)
LOG_INIT          | info    | updating max-values
|                 | |       | | x(max=6.25)
LOG_INIT          | info    | updating nominal-values
LOG_INIT          | info    | updating start-values
LOG_INIT          | info    | initialization method: none            [sets all variables to their start values and skips the initialization process]
LOG_INIT          | info    | parameter values
|                 | |       | | real parameters
|                 | |       | | | [1] parameter Real L(start=2.5, fixed=true) = 2.5
|                 | |       | | | [2] parameter Real a(start=0.24, fixed=true) = 0.24
LOG_SOTI          | info    | ### SOLUTION OF THE INITIALIZATION ###
|                 | |       | | states variables
|                 | |       | | | [1] Real x(start=1, nominal=1) = 6.25 (pre: 1)
|                 | |       | | | [2] Real y(start=0, nominal=1) = 0 (pre: 0)
|                 | |       | | derivatives variables
|                 | |       | | | [3] Real der(x) = 0 (pre: 0)
|                 | |       | | | [4] Real der(y) = 0 (pre: 0)
LOG_INIT          | info    | ### END INITIALIZATION ###
\"",
    timeFrontend = 0.00790769575244046,
    timeBackend = 0.0009164856097003121,
    timeSimCode = 0.0007208061480562133,
    timeTemplates = 0.02231804456551621,
    timeCompile = 1.278270309042027,
    timeSimulation = 0.08834574828628097,
    timeTotal = 1.398650068343458
end SimulationResult;
""
Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
}}}

This bug also shows up in testsuite/simulation/modelica/initialization/bug_2207.mos if the nominal attribute is not set.

Produced using r23393 and somewhat earlier."	defect	closed	critical	1.9.4	Run-time	trunk	fixed		Lennart Ochel
