-
Notifications
You must be signed in to change notification settings - Fork 41
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
Simplify synchronous features #3240
Conversation
1f18aff
to
c4cfab3
Compare
Web Meeting (Hans, Henrik, Gerd, Martin, Oliver) It will drastically simplify the language if the system is partitioned in clocked partitions during flattening. A clocked partition needs to be declared in Flat Modelica somehow. This could be done by:
Discussion: to 2.) To be continued in next meeting. |
Web Meeting (Hans, Henrik, Gerd, Martin, Oliver)
Open issue:
|
We should also keep parameters and constants in mind when defining how to infer the set of variables belonging to a subpartition. |
Web Meeting (Hans, Henrik, Gerd, Martin, Oliver) noClock() is not allowed to create cyclic dependencies between subpartitions to be fixed in full Modelica. In Flat Modelica we don't want to have cyclic dependencies due to noClock() between subpartitions. Using previous() to indicate value of the current clock tick of the other subpartition might lead to wrong semantics. Example
noClock() shall be used to guard variables from other subpartitions. The order of the subpartitions is arbitrary, are not required to be in the order of their dependency. |
Web Meeting (Hans, Henrik, Gerd, Martin, Oliver) Discussion of the above approach:
Idea to avoid end partition:
Alternative 1: Clocks as component
Alternative 2: Begin Clock - end Clock
Poll Decision: Revisit this question of the order subpartition.
Alternative 2: required to be in the order of their dependency.
To be continued. |
Web Meeting (Hans, Henrik, Gerd, Martin, Oliver) Henrik: For equations it is not possible to define an order, but there are dependencies between subpartitions that must not be cyclic. This makes it a different case. Oliver: If the execution order is determined by the tool based on the dependencies, then it's different than an algorithm. Henrik: When the user knows that subpartitions have to be in order will help the understanding of execution at a tick. If it's only a recommendation and not stricty required by the specification, then the user cannot rely on it and derive it by himself to understand the execution order. Gerd: Agree that error messages will be much easier to comprehend. Hans: Will need some more thinking to conclude. Henrik: This could be part of the prototyping. Gerd: What will be the error message, when generating flat Modelica fails because no order can be derived in case of a cyclic dependency. Henrik: Flat Modelica can be the way to explain why it was not possible or where to problem occurred. Option A: Order of subpartitions is strictly required. Cyclic dependencies are always reported as error. Poll Decision: To go forward with option A and revisit this topic based on the experience gained in prototyping phase.
|
Co-authored-by: Hans Olsson <HansOlsson@users.noreply.github.com>
Also including solverMethod specification, and will make a comment in the PR to drag attention to this part.
RationaleMCP/0031/grammar.md
Outdated
> _sub-partition_ →\ | ||
>   **subpartition** _comment_\ | ||
>   _clock-clause_ **;**\ | ||
>   ( **solverMethod** _STRING_ **;** )?\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We hadn't settled how to specify solver method, so I added this as a starting point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web Meeting: (Hans, Henrik, Gerd, Martin, Oliver)
Subpartitions do not necessarily require a solver method.
In full Modelica there is no natural place to define a solver method for subpartitions. This makes it look a bit ugly and a risk of conflicting definitions.
Gerd: What I don't like is that the solverMethod looks like a declaration. Maybe we could move it ahead of clock-clause.
Henrik: Keyword 'discretization' would look better as a keyword together with partition/subpartition than the lower camel case 'solverMethod'.
If we swop these two lines then we avoid looking like a declaration.
Dropping the semicolon, but having encourages declaration on a separate line, which improves readability as we had discussed previously.
Oliver: solverMethod is a well established term.
Gerd: Could it remain a named argument?
Henrik: Technically the solverMethod is not associated with the clock but with the subpartition. This could not be expressed in a better way in full Modelica.
Examples:
subpartition "Alternative A"
Clock _subClock0 = subSample('baseClock', 2);
solverMethod "ImplicitEuler" annotation(tolerance=1e3);
...
subpartition "Alternative B"
solverMethod "ImplicitEuler" annotation(tolerance=1e3); //Better place for something that is not a component declaration
Clock _subClock0 = subSample('baseClock', 2);
...
subpartition "Alternative C"
discretization "ImplicitEuler" annotation(tolerance=1e3);
Clock _subClock0 = subSample('baseClock', 2);
...
subpartition "Alternative D" discretization "ImplicitEuler"
annotation(tolerance=1e3) // Keeping everything together
Clock _subClock0 = subSample('baseClock', 2);
...
subpartition(discretization(tolerance=1e3)="ImplicitEuler") "Alternative E"
Clock _subClock0=subSample('baseClock', 2);
...
subpartition subPart1 "Alternative F"
extends basepartition(
solverMethod="ImplicitEuler", tolerance=1e3,
subClock=subSample('baseClock', 2));
...
end subPart1;
subpartition subE2(
clock=subsample('baseClock',2),
solverMethod="ImplicitEuler", tolerance=1e3 "Alternative G"
subpartition "Alternative H"
Clock _subClock0 = subSample('baseClock', 2);
String solverMethod = "ImplicitEuler" annotation(tolerance=1e3);
Henrik: There might be the need for more sophisticated attributes for solver methods in the future. This could be done by:
solverMethod "ImplicitEuler"(tolerance=1e3);
We have an annotation on the subpartition and could also have an annotation on the solverMethod as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web Meeting: Hans, Henrik, Gerd, Martin, Oliver
Revised options above by adding tolerance to all of them.
Added Alternative H.
Discussion to be concluded in next meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me (Hans):
Most preferred: G (Also called E2 above)
Good: F
Acceptable: H
A, B, C, D all seem odd, as if it were a declaration of a Modelica variable discretization
with description-string "ImplicitEuler"
and we forgot its type (a mistake that some people do). E has the problem that clock and solverMethod are treated differently, but if really really needed I could accept it.
On a separate note: in general I believe that Rosenbrock methods are a better solution than ImplicitEuler with tolerance; thus I don't think the tolerance will be used much (and our experience in Dymola is that it isn't just a matter of one tolerance).
Another option for sophisticated attributes would be solverMethod(tolerance=1e3)="ImplicitEuler"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subpartition (
solverMethod="ImplicitEuler", tolerance=1e-3) "Alternative I"
Clock _subClock0 = subsample('baseClock',2);
An interesting extra is:
The complication is cVar5 will tick at the same times as baseVar, but it needs to be a separate subclock-partition:
There are two implications:
As far as I can see loops between different (sub-)clock partitions should be forbidden, will see how to ensure that for the normal spec. |
This is still being discussed, but the original proposal was not popular at all.
This matches how annotations are placed in other parts of the grammar.
This shows that we don't really need any new syntax for handling the choice of solver method, at the cost of having this important information hidden away in an annotation.
Web Meeting
Web Meeting: Hans, Henrik, Gerd, Martin, Oliver Option1: Extend the syntax to capture the solver method. Poll Decision: |
Web Meeting: Hans, Henrik, Gerd, Martin, Oliver Currently missing in the design:
This could be solved by either:
Do we need a name for a subclock? Should it be visible to which basepartition a subclock belongs?
Highest chance to with all implementation has the approach of having all subclock declarations at the top of basepartition. According to the specification there is only one basepartition. Probably some prototyping needed. Conclusion:
Parenthesis after a partition is unusual for Modelica, compared with:
But it's undesired to have crucial information in an annotation. The annotation is often cluttered with graphical and other stuff. Poll decide between option J and K Decision: |
As decided at last web meeting.
Web Meeting (Hans, Henrik, Gerd, Martin, Oliver) proposed design approved |
Initiating empty PR as decided in today's web meeting.