﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4541	connect last array element using [end]	m.thorade@…	Adrian Pop	"I took the example Modelica.Electrical.Analog.Examples.HeatingResistor and removed the graphical part and renamed it, this gives me:

{{{
model End_connect
  Modelica.Electrical.Analog.Basic.HeatingResistor heatingResistor(R_ref=100, alpha=1e-3, T_ref=293.15, i(start=0));
  Modelica.Electrical.Analog.Basic.Ground G;
  Modelica.Electrical.Analog.Sources.SineVoltage SineVoltage1(V=220, freqHz=1);
  Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor(G=50);
  Modelica.Thermal.HeatTransfer.Celsius.FixedTemperature fixedTemperature(T=20);

equation
  connect(SineVoltage1.n, G.p);
  connect(heatingResistor.heatPort, thermalConductor.port_a);
  connect(SineVoltage1.p, heatingResistor.p);
  connect(G.p, heatingResistor.n);
  connect(thermalConductor.port_b, fixedTemperature.port);

annotation (experiment(StopTime=5));

end End_connect;
}}}

This checks, translates and simulates just fine.
Now, I made every component an array and connect them as below:

{{{
model End_connect

  parameter Integer nEle=5;

  Modelica.Electrical.Analog.Basic.HeatingResistor heatingResistor[nEle](each R_ref=100, each alpha=1e-3, each T_ref=293.15, each i(start=0));
  Modelica.Electrical.Analog.Basic.Ground G[nEle];
  Modelica.Electrical.Analog.Sources.SineVoltage SineVoltage1[nEle](each V=220, each freqHz=1);
  Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor[nEle](each G=50);
  Modelica.Thermal.HeatTransfer.Celsius.FixedTemperature fixedTemperature[nEle](each T=20);

equation 
  // connect first
  connect(SineVoltage1[1].n, G[1].p);
  connect(heatingResistor[1].heatPort, thermalConductor[1].port_a);
  connect(SineVoltage1[1].p, heatingResistor[1].p);
  connect(G[1].p, heatingResistor[1].n);
  connect(thermalConductor[1].port_b, fixedTemperature[1].port);

  // connect middle
  for i in 2:nEle-1 loop
    connect(SineVoltage1[i].n, G[i].p);
    connect(heatingResistor[i].heatPort, thermalConductor[i].port_a);
    connect(SineVoltage1[i].p, heatingResistor[i].p);
    connect(G[i].p, heatingResistor[i].n);
    connect(thermalConductor[i].port_b, fixedTemperature[i].port);
  end for;

  //connect last
  connect(SineVoltage1[end].n, G[end].p);
  connect(heatingResistor[end].heatPort, thermalConductor[end].port_a);
  connect(SineVoltage1[end].p, heatingResistor[end].p);
  connect(G[end].p, heatingResistor[end].n);
  connect(thermalConductor[end].port_b, fixedTemperature[end].port);

annotation (experiment(StopTime=5));

end End_connect;
}}}
This checks, translates and simulates just fine in Dymola, but not in OpenModelica.
Is this syntax wrong and should be fixed in my model? How?
Or is it a bug in OpenModelica?

Note: The same error appears e.g. here:
https://libraries.openmodelica.org/branches/master/BuildingSystems/files/BuildingSystems_BuildingSystems.Technologies.ThermalStorages.Examples.FluidStorage.err
"	defect	closed	high	2.1.0	New Instantiation		fixed		Per Östlund
