Opened 11 years ago

Closed 11 years ago

#2723 closed defect (fixed)

OM accepts invalid code

Reported by: massimo ceraolo Owned by: Per Östlund
Priority: low Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc:

Description

Modelica specifications 3.3 at section 9.3 say:
"Connect-equations cannot be used inside if-equations with non-parametric condition".

From this I understand that the following code is invalid:

model DynamicConnect
  Modelica.Electrical.Analog.Basic.Resistor R1(R = 1), R2(R = 2), R3(R = 3);
  Modelica.Electrical.Analog.Sources.ConstantVoltage E(V=10);
  Modelica.Electrical.Analog.Basic.Ground G;
equation
  connect(G.p, E.n);
  connect(E.p, R1.p);
  if time < 1 then
    connect(R1.n, R2.p);
  else
    connect(R1.n, R3.p);
  end if;
  connect(R2.n, G.p);
  connect(R3.n, G.p);
  annotation(uses(Modelica(version = "3.2.1")));
end DynamicConnect;

OM accepts it, but gives as result a current through R1 equal to zero. If it had really done what the code says, it should have computed (as long as time<1s) a current through R1 equal to 3.33A

This is indeed what we get if we just use

model DynamicConnect
  Modelica.Electrical.Analog.Basic.Resistor R1(R = 1), R2(R = 2), R3(R = 3);
  Modelica.Electrical.Analog.Sources.ConstantVoltage E(V=10);
  Modelica.Electrical.Analog.Basic.Ground G;
equation
  connect(G.p, E.n);
  connect(E.p, R1.p);
//  if time < 1 then
    connect(R1.n, R2.p);
//  else
//    connect(R1.n, R3.p);
//  end if;
  connect(R2.n, G.p);
  connect(R3.n, G.p);
  annotation(uses(Modelica(version = "3.2.1")));
end DynamicConnect;

Change History (2)

comment:1 by Martin Sjölund, 11 years ago

Component: UnknownFrontend
Owner: changed from somebody to Per Östlund
Status: newassigned

comment:2 by Per Östlund, 11 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r21204.

Note: See TracTickets for help on using tickets.