Opened 12 years ago

Closed 12 years ago

#1923 closed defect (fixed)

Connection Graph is not broken correctly

Reported by: Christian Schubert Owned by: Adrian Pop
Priority: critical Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: Connection Graph Cc: Jens Frenkel

Description

the models
Modelica.Electrical.QuasiStationary.SinglePhase.Examples.SeriesResonance
Modelica.Electrical.QuasiStationary.SinglePhase.Examples.ParallelResonance
fail because there is one equation missing. Looking into the code (+d=dumpdaelow) one notes that there is no equation for ground.pin.reference.gamma.
However, there are 4 equalityConstraint involving ground.pin.reference which do not count as equations, since they return an empty array.

I drew the connection graph with yEd (see attachment, dashed lines may be broken) and one can see that the "broken connections" (= equality constraints) do not even occur as edges in the connection graph. It seems that the equality constraints are produced from the connection set rather than the connection graph.

Attachments (3)

ParallelResonance.jpg (35.9 KB ) - added by anonymous 12 years ago.
ParallelResonance-GraphViz.png (38.6 KB ) - added by Adrian Pop 12 years ago.
obtained via ./omc +locale=C +d=cgraphGraphVizFile Modelica.Electrical.QuasiStationary.SinglePhase.Examples.ParallelResonance.mos
ParallelResonance-DymByHand-GraphViz.png (36.1 KB ) - added by Adrian Pop 12 years ago.
Done by hand using GraphViz from equations posted by Jens.

Download all attachments as: .zip

Change History (15)

by anonymous, 12 years ago

Attachment: ParallelResonance.jpg added

comment:1 by anonymous, 12 years ago

These are the generated equality constraints:

2 : {} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(resistor.pin_n.reference, ground.pin.reference)
3 : {} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(inductor.pin_n.reference, ground.pin.reference)
4 : {} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(capacitor.pin_n.reference, ground.pin.reference)
5 : {} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(voltageSensor.pin_n.reference, ground.pin.reference)

comment:2 by Adrian Pop, 12 years ago

You can run:

omc +locale=C +d=cgraphGraphVizFile Modelica.Electrical.QuasiStationary.SinglePhase.Examples.ParallelResonance.mos

to get Modelica.Electrical.QuasiStationary.SinglePhase.Examples.ParallelResonance.gv
with the connection graph and where it was broken. You can view the graph using GraphViz.
See the file I will attach next.

by Adrian Pop, 12 years ago

obtained via ./omc +locale=C +d=cgraphGraphVizFile Modelica.Electrical.QuasiStationary.SinglePhase.Examples.ParallelResonance.mos

comment:3 by Adrian Pop, 12 years ago

I did:

loadModel(Modelica, {"3.2.1"}); getErrorString();
instantiateModel(Modelica.Electrical.QuasiStationary.SinglePhase.Examples.ParallelResonance); getErrorString();

and I get a model having equation:

  if false then
  ground.pin.reference.gamma = 0.0;
  end if;

it comes from:

  Connections.potentialRoot(pin.reference, 256);
  if Connections.isRoot(pin.reference) then
    pin.reference.gamma = 0;
  end if;

which is rather correct as Connections.isRoot(ground.pin.reference) is only a potential root, not a root. Also, checkModel reports:

Class Modelica.Electrical.QuasiStationary.SinglePhase.Examples.ParallelResonance has 99 equation(s) and 99 variable(s).
57 of these are trivial equation(s).

so the model is balanced. The problem might be in the back-end someplace.

comment:4 by Adrian Pop, 12 years ago

Hm, the connection graph obtained via OpenModelica is rather different than your hand done one. Are you sure yours is correct?

comment:5 by Jens Frenkel, 12 years ago

Modelica Code:

connect(currentSource.pin_n, resistor.pin_p);
connect(currentSource.pin_n, inductor.pin_p);
connect(currentSource.pin_n, capacitor.pin_p);
connect(currentSource.pin_n, voltageSensor.pin_p);
connect(currentSource.pin_p, ground.pin);
connect(resistor.pin_n, ground.pin);
connect(inductor.pin_n, ground.pin);
connect(capacitor.pin_n, ground.pin);
connect(voltageSensor.pin_n, ground.pin);
connect(f.y, currentSource.f);
connect(polarToComplex.y, currentSource.I);
connect(phi.y, polarToComplex.phi);
connect(I.y, polarToComplex.len);
connect(voltageSensor.y, complexToPolar.u);

Dymola Flat Code:

connect(capacitor.pin_n.reference, currentSource.pin_p.reference);
connect(capacitor.pin_n.reference, ground.pin.reference);
connect(capacitor.pin_n.reference, inductor.pin_n.reference);
connect(capacitor.pin_n.reference, resistor.pin_n.reference);
connect(capacitor.pin_n.reference, voltageSensor.pin_n.reference);
connect(capacitor.pin_p.reference, currentSource.pin_n.reference);
connect(capacitor.pin_p.reference, inductor.pin_p.reference);
connect(capacitor.pin_p.reference, resistor.pin_p.reference);
connect(capacitor.pin_p.reference, voltageSensor.pin_p.reference);

comment:6 by Adrian Pop, 12 years ago

There is no description in the specification on how is best to connect things to get the connection graph. I see that Dymola goes via ground.pin .reference and currentSource.pin_p and connects the capacitor.pin_n to those. Why is done this way, i have no idea.

comment:7 by Jens Frenkel, 12 years ago

It seems this is not the problem but for the conntection between

ground.pin.reference and currentSource.pin_p.reference is no equation generated

currentSource.pin_p.reference.gamma = currentSource.pin_n.reference.gamma;
currentSource.omega = der(currentSource.pin_p.reference.gamma);

if false then
ground.pin.reference.gamma = 0.0;
end if;
{} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(resistor.pin_n.reference, ground.pin.reference);
{} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(inductor.pin_n.reference, ground.pin.reference);
{} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(capacitor.pin_n.reference, ground.pin.reference);
{} = Modelica.Electrical.QuasiStationary.Types.Reference.equalityConstraint(voltageSensor.pin_n.reference, ground.pin.reference);

comment:8 by Adrian Pop, 12 years ago

Ok, I get it if I look at the flattened code from OpenModelica.
There is not equation from connect(ground.pin.reference, currentSource.pin_p.reference) even if the connect is not broken it that case. I'll have a look at it.

by Adrian Pop, 12 years ago

Done by hand using GraphViz from equations posted by Jens.

comment:9 by Jens Frenkel, 12 years ago

in the functino handleOverconstrainedConnections pefore calling the funtion findResultGraph there is the equation

EQUEQUATION(capacitor.pin_n.reference.gamma = ground.pin.reference.gamma)

after calling this funktion it is not there anymore.

comment:10 by Adrian Pop, 12 years ago

Yes, i'm debugging that now. The equations are removed based on the equation source so it might be something wrong there.

comment:11 by Adrian Pop, 12 years ago

I found the issue and I'm doing a way better solution by deleting the connections directly from the connections sets before generating the final equations. I'll keep you informed on how it goes.

comment:12 by Adrian Pop, 12 years ago

Reporter: changed from cschube to Christian Schubert
Resolution: fixed
Status: newclosed

Fixed in revision r13778.
These models now simulate but there are some error messages that should not be there.

Note: See TracTickets for help on using tickets.