Closed qlambert-pro closed 1 year ago
For #2172 the main issue was lack of realistic examples, and it now seems we have them. In particular the array declaration of cellBus is good since it illustrates why following are good ideas:
Proposed new text:
At least one connector in the connect equation must reference a declared or potentially present component. If potentially present component it will be marked as being present (recursively if needed). If the other connector is not even potentially present it must be an undeclared element in a at least potentially present expandable connector and it is handled as follows (after marking the potentially present expandable connector as present):
Non-normative: The undeclared component in 'potentially present expandable connector' makes it possible to have a 'potentially present array of expandable connectors'. (Add example.)
Poll using emojis:
I don't understand the wording. Can you explain what your text is trying to do that specifying that potentially present component are considered declared does not?
I don't understand the wording. Can you explain what your text is trying to do that specifying that potentially present component are considered declared does not?
I see at least the following reasons:
I'm sure there might be other solutions, but that might require a lot of work and it is not clear that those potential solutions would be easier to understand.
In the package below MOk doesn't have the potentially present variable and thus translates ok. In MBad I added a silly connections to create it (which shouldn't be legal), and that fails. (The reason for the current rules is if a sub-component has an expandable connector without any contents and it is added elsewhere there would otherwise be a missing equation - I could add that as well.)
package P
expandable connector C
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end C;
expandable connector SubC
Modelica.Electrical.Analog.Interfaces.Pin pin;
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end SubC;
model MOk
C c annotation (Placement(transformation(extent={{-110,-18},{-90,2}})));
SubC subC annotation (Placement(transformation(extent={{94,26},{114,46}})));
equation
connect(c, subC.sub) annotation (Line(points={{-100,-8},{60,-8},{60,36},{104,
36}},
color={0,0,0}), Text(
string="%second",
index=-1,
extent={{-6,3},{-6,3}},
horizontalAlignment=TextAlignment.Right));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end MOk;
model MBad
C c annotation (Placement(transformation(extent={{-110,-18},{-90,2}})));
SubC subC annotation (Placement(transformation(extent={{94,26},{114,46}})));
equation
connect(c, subC.sub) annotation (Line(points={{-100,-8},{60,-8},{60,36},{104,
36}},
color={0,0,0}), Text(
string="%second",
index=-1,
extent={{-6,3},{-6,3}},
horizontalAlignment=TextAlignment.Right));
connect(subC.pin, subC.pin) annotation (Line(points={{104.05,36.05},{104.05,10},{90,10},{90,36.05},
{104.05,36.05}},
color={0,0,0}), Text(
string="%first",
index=-1,
extent={{-3,6},{-3,6}},
horizontalAlignment=TextAlignment.Right));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end MBad;
annotation (uses(Modelica(version="4.0.0")));
end P;
However, an alternative might be the following:
So for:
connect(gainLosses.u, stackBus.cellBus.lossPower);
stackBus.cellBus
is potentially present and is by 1 transformed into declared
Then gainLosses.u
is declared (assuming lossPower isn't), so 2 is ok.
And then since lossPower isn't declared we continue with 3.
But we still have the benefit that if we just drag in an expandable connector and don't connect it we avoid all of the issues, both the problem above for physical connectors, and also the lack of source for a causal one.
I prefer this alternative but I don't understand the purpose of 3.
. There are no potentially present connector then, since 1.
made them into declared component. To me 3.
sounds like it forbids adding an undeclared signal to an expandable connector. Unless what you mean is:
If the other connector is undeclared it must be a connector inside a declared expandable connector.
I prefer this alternative but I don't understand the purpose of
3.
. There are no potentially present connector then, since1.
made them into declared component. To me3.
sounds like it forbids adding an undeclared signal to an expandable connector. Unless what you mean is:If the other connector is undeclared it must be a connector inside a declared expandable connector.
Yes, that was the idea - I wrote 'not potentially present' intending to mean 'not even potentially present'; but you are right that undeclared is clearer.
In
Modelica.Electrical.Batteries.Utilities.BusTranscription
the connect equationfails to respect
as
lossPower
is an undeclared element in undeclared expandable connectorcellBus
This relates to #428 and #2172