﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3992	A model to dynamically change network topology that does not work with OM	massimo ceraolo	somebody	"I use for this ticket the same code that I used for #2755, that I reproduce below.
This code tries to connect ""dynamically"" electrical components.
If intConst is 1, positive pins of resistor R and E1 are connected to each other and current flows through E1; if it is 2 current flows through E2.
It is useful for algebraic networks (i.e. not having storage elements such as capacitors and inductors) since it allows changing the network topology at runtime.
Although it is a bit tricky, I don't see any reason for which this should be invalid modelica.
In Dymola it works well (and I've been satisfactorily using rather large models containing many of such ""Commutator"" for years)
I've checked it with OM v1.11.0-dev-16 and got currents in E1 and E2 being either 0 or fluctuating between 0 and -1e-236.

So I will label this ticket as a defect, even though it may not be such (if there is some Modelica prescription it violates).


{{{
model commTest0
  model Commutator
    parameter Integer m(final min = 1);
    Modelica.Electrical.Analog.Interfaces.PositivePin pin_pm[m];
    Modelica.Electrical.Analog.Interfaces.PositivePin pin_p;
    Modelica.Blocks.Interfaces.IntegerInput z;
  equation
    pin_p.v = pin_pm[z].v;
    for j in 1:m loop
      pin_pm[j].i = if j == z then -pin_p.i else 0;
    end for;
  end Commutator;

  Commutator commutator(m = 2);
  Modelica.Electrical.Analog.Basic.Resistor resistor(R = 2);
  Modelica.Electrical.Analog.Basic.Ground ground;
  Modelica.Electrical.Analog.Sources.ConstantVoltage E1(V = 100);
  Modelica.Electrical.Analog.Sources.ConstantVoltage E2(V = 200);
  Modelica.Blocks.Sources.IntegerConstant intConst(k = 1);
equation
  connect(commutator.pin_p, resistor.p);
  connect(resistor.n, ground.p);
  connect(E1.p, commutator.pin_pm[1]);
  connect(E2.p, commutator.pin_pm[2]);
  connect(E1.n, ground.p);
  connect(E2.n, ground.p);
  connect(commutator.z, intConst.y);
end commTest0;
}}}
"	defect	closed	normal	1.12.0	*unknown*	v1.11.0	worksforme		
