﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5687	Evaluting structural parameters and array modifications	Mahder Alemseged Gebremedhin	Per Östlund	"If you are not already aware of this, there seems to be a problem when constant evaluation is involved for array modifications

{{{
model ConservationEquation
  parameter Boolean aa = true;
end ConservationEquation;

model PartialMixingVolume
  parameter Boolean bp = true;
  ConservationEquation ba(aa = bp);
  Real p;  
end PartialMixingVolume;

model Pipe
  PartialMixingVolume[2] ca(bp = {false, false});
end Pipe;

}}}

Gets correctly flattened to 
{{{
class Pipe
  parameter Boolean ca[1].bp = false;
  parameter Boolean ca[1].ba.aa = ca[1].bp;
  Real ca[1].p;
  parameter Boolean ca[2].bp = false;
  parameter Boolean ca[2].ba.aa = ca[2].bp;
  Real ca[2].p;
end Pipe;
}}}

--------------------------------------------------------------------------------
However if you add an if equation, which I believe causes a constant evaluation as follows

{{{
model ConservationEquation
  parameter Boolean aa = true;
end ConservationEquation;

model PartialMixingVolume
  parameter Boolean bp = true;
  ConservationEquation ba(aa = bp);
  Real p;
initial equation
  if ba.aa then
    p = 3;
  end if;  
end PartialMixingVolume;

model Pipe
  PartialMixingVolume[2] ca(bp = {false, false});
end Pipe;

}}}

The model flattens to 
{{{
class Pipe
  parameter Boolean ca[1].bp = false;
  final parameter Boolean ca[1].ba.aa = false;
  Real ca[1].p;
  parameter Boolean ca[2].bp = false;
  final parameter Boolean ca[2].ba.aa = {false, false};
  Real ca[2].p;
initial equation
  if {false, false} then
    ca[1].p = 3.0;
  end if;
  if {false, false} then
    ca[2].p = 3.0;
  end if;
end Pipe;
}}}

The binding for {{{ca[2].ba.aa}}} is now cevaled to an array. Same for the loop condition.

It does not happen for the first element of the array. It only happens for the rest of the elements always (2nd, 3rd, ...).



  "	defect	closed	normal	1.16.0	New Instantiation		fixed		
