Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent optional diagnostics for unconnected connectors. #3117

Closed
HansOlsson opened this issue Feb 11, 2022 · 0 comments · Fixed by #3129
Closed

Consistent optional diagnostics for unconnected connectors. #3117

HansOlsson opened this issue Feb 11, 2022 · 0 comments · Fixed by #3129

Comments

@HansOlsson
Copy link
Collaborator

In #178 we decided that enabled conditional connectors must be connected.
After actually enabling this warning in Dymola, it seems we should reconsider it.

In MSL it is used in several models see:
modelica/ModelicaStandardLibrary#3947
And additionally many uses of Modelica.Mechanics.MultiBody.Joints.Revolute - e.g., Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.FullRobot where mechanics.r1.support is conditional and unconnected.

On the other hand the problem it is intended to find is real - enabling support for idealGear in Modelica.Mechanics.Rotational.Examples.FirstGrounded without connecting it is not good modeling.

I believe the issue is that we tried to solve the wrong problem.
We had the issue that for specific unconnected non-conditional connectors we can use asserts to generate diagnostics (using cardinality). That doesn't work for unconnected enabled conditional connectors, and based on some examples where the same applies for them we tried to add a rule for all of them (in this ticket and then amended to not be "all").
We failed to realize that support in rotational is special - it only enables one connector, and if disabled we have other equations.
For the other cases above the condition enables multiple connectors, and you don't have to use all of them.

Instead we should figure out a way to specify that a connector should be connected; and obviously skip that diagnostics if the connector is disabled. One possibility would be an annotation for connector components (this was also suggested in #1409 ):
parameter String mustBeConnected="..."
If non-empty it indicates that a diagnostics should be given if the connector is not connected (for a conditional connector this check is only active if the connector is enabled). For an array of connectors it applies separately to each element.
And possibly mayOnlyConnectOnce for the reverse.

If people think this diagnostics is super-useful and really hate annotations leading to diagnostics we could introduce some special construct for it.

With both of these annotations I believe this would allow us to remove all but two uses of cardinality in MSL, the remaining ones are:

  • PointMass
  • The ones in Modelica.Mechanics.MultiBody.Forces.LineForceWithMass* although I'm not sure if they are really that useful.
HansOlsson added a commit to HansOlsson/ModelicaSpecification that referenced this issue Mar 3, 2022
HansOlsson added a commit that referenced this issue Jul 1, 2022
* Describe new annotation for checking number of connections.
* Do not require that conditionally active connectors are connected; reverting #178
Closes #3117
* Apply suggestions from code review
* Removed elided code as suggested, and indicate that something is missing.
Also reduce to one flange-connector.
* Remove 2nd one; turn into separate PR.
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant