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

when equations in algebraic loop? #3498

Closed
gkurzbach opened this issue Apr 8, 2024 · 6 comments · Fixed by #3532
Closed

when equations in algebraic loop? #3498

gkurzbach opened this issue Apr 8, 2024 · 6 comments · Fixed by #3532
Labels
tool-issue Issue in tool(s) - not the specification itself
Milestone

Comments

@gkurzbach
Copy link
Collaborator

Is it allowed for when equations to be part of an algebraic loop?
Following model leads to an error in Dymola but not in OMEdit:

model algebraicLoop 
	Real x;
	Real y(start=0.5,fixed=true);
	equation
		x = time - y;
		when time>0.5 then
		    y = -x/2;
		end when;
end algebraicLoop;

I have not found any statement to this regard in the specification. Please clarify.

@HansOlsson
Copy link
Collaborator

It seems that it is allowed by the specification (there is even one example of it) , but that:

  • Few libraries use it (that's why the lack of support hasn't been noticed).
  • The specification misses the implications in some places, e.g., similarly to when initial() with impure function? #3499 there could here be a call of an impure function causing it to end up in a loop.

The when-equations are even designed to make it clear how such cases are handled. That's why you cannot write:

                x = time - y;
		when time>0.5 then
		    y + x/2 = 0;
		end when;

because it wouldn't make it clear which variables are updated as part of the when and which ones aren't.

@HansOlsson
Copy link
Collaborator

I believe the impure part can be handled in #3499 - The remaining part is thus just to state that there is nothing special with when-clauses and they can be part of systems of equations.

@henrikt-ma
Copy link
Collaborator

For what it's worth, System Modeler also builds and simulates this without any complaint.

@HansOlsson HansOlsson added the tool-issue Issue in tool(s) - not the specification itself label Apr 15, 2024
@HansOlsson
Copy link
Collaborator

Dymola 2024x Refresh 1 also builds and simulates this without any complaint.

@HansOlsson
Copy link
Collaborator

I thus believe it was just a tool-issue, but it might be that the specification should be clearer.

@HansOlsson HansOlsson added this to the 2024-3 milestone May 16, 2024
@HansOlsson
Copy link
Collaborator

Language group: Agreement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool-issue Issue in tool(s) - not the specification itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants