﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6050	reinit with introduceOutputAliases broken	Andreas Heuermann	Andreas Heuermann	"
When enabeling preOptModule `introduceOutputAliases` (default for FMI 2.0) reinit will not reinitialize the correct variable for top level outputs leading to wrong event behavior.


{{{
loadString(""
model simpleEvent
  Real h(start=1, fixed=true);
  Real v(start=-2, fixed=true);
  Real x;
equation
  der(h) = v;
  der(v) = 0;
  when h <= 0 then
    reinit(v,-pre(v));
    x = 0.5*v;
  end when;
end simpleEvent;""); getErrorString();

loadString(""
model simpleEventOutput
  Real h(start=1, fixed=true);
  output Real v(start=-2, fixed=true);
  Real x;
equation
  der(h) = v;
  der(v) = 0;
  when h <= 0 then
    reinit(v,-pre(v));
    x = 0.5*v;
  end when;
end simpleEventOutput;""); getErrorString();

setCommandLineOptions(""--preOptModules+=introduceOutputAliases""); getErrorString();
mkdir(""simpleEvent""); getErrorString();
cd(""simpleEvent""); getErrorString();
simulate(simpleEvent); getErrorString();

cd(""..""); getErrorString();
mkdir(""simpleEventOutput""); getErrorString();
cd(""simpleEventOutput""); getErrorString();
simulate(simpleEventOutput); getErrorString();
}}}

When `v` is a top level output it should get replaced with `outputAlias_v` everywhere but is not inside the when equation containing `reinit`.

Working for:
{{{
/*
equation index: 14
type: WHEN

when {$whenCondition1} then
  x = 0.5 * $outputAlias_v;
end when;
*/
}}}

Not working for:
{{{
/*
equation index: 15
type: WHEN

when {$whenCondition1} then
  reinit(v,  -pre(v));
end when;
*/
}}}"	defect	closed	high	1.16.0	Backend	v1.16.0-dev	fixed	introduceOutputAliases reinit fmi fmi-cross-check	
