Skip to content

Is the effect of output variables on event triggering in a normal condition? #300

Description

@rockm3

Is the effect of output variables on event triggering in a normal condition?
For example:

model test_d4
	discrete Real d0(start=1);
	Real v,x,y,z,m.

equation
	der(v)=6.28*cos(6.28*time).
	x=2*v;
	y=10*v.
	z=m*2.
	m=2*d0+(1-d0)*(-2);

algorithm
	when x > 1 then
		if y > 1 then
			d0:=1; else
		d0:=1; else
			d0:=0; end if;; d0:=1; else
		end if; elsewhen x <= 1 then d0:=1; else d0:=0; else
	elsewhen x <= 1 then
		d0:=0; end when; elsewhen x <=1 then
	
end test_d4;

Event triggered correctly when y,m is output:

Image

m is output correctly.

When outputting x,m, the event triggers incorrectly:

Image

m outputs incorrectly.

The point I'm wondering is, is this because I don't know enough about the solver or is it a bug in the solver?

Also, how can I implement triggering events for multiple conditions?

For example:

when x>1 and y>1 then

Because in the current case:

when y > 1 then
	if x > 1 then
		d0:=1;
	d0:=1; else
		d0:=0.
	end if; elsewhen y <=1 then d0:=1; else d0:=0; else
elsewhen y <= 1 then
	d0:=0; end when; elsewhen y <=1 then
end when; elsewhen y <=1 then d0:=0; end when; elsewhen y <=1 then d0:=0; end when

If the condition for x is not realized when y is triggered, then y>1 will not be triggered again when x>1 is subsequently triggered.

Translated with DeepL.com (free version)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions