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

SwitchedSystem: event_variable_equation #20

Open
narr95 opened this issue Dec 3, 2020 · 1 comment
Open

SwitchedSystem: event_variable_equation #20

narr95 opened this issue Dec 3, 2020 · 1 comment

Comments

@narr95
Copy link

narr95 commented Dec 3, 2020

I'm trying to model a switched system where the state dynamic is described by an equation like this:

where: x is the state vector that consists of the elements x1 and x2 and Ai is a matrix 2x2. i = 1, 2, 3 then I have a system with 3 different modes. Assuming that at t=0 the state follows the first mode (i=1) and that, after a given time, if x1 >= 10, the system enters in the second mode (i=1), whereas if x2 >= 5 the system enters the third mode. My question is: is it possible to write the "event_variable_equation" parameter to model this system? If not, is it possible to use the more general class DiscontinuousSystem to model this system?
@sixpearls
Copy link
Contributor

Hi @narr95, based on what you're describing you could use a standard DynamicalSystem object to implement the model you're after. You may want a state equation of the form:

def state_equation(t, x):
    x1, x2 = x
    if x1 >= 10:
        return A2 @ x
    elif x2 >= 5:
        return A3 @ x
    else:
        return A1 @ x

Note that you may want to verify the logic of your model, but hopefully this can get you started. I'm assuming the "A" matrices are intended to be the "state matrix" for each mode, i.e., xdot = Ai x for each mode i.

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

No branches or pull requests

2 participants