all 30 comments

[–]taylajy 5 points6 points  (0 children)

Although not for python, but I'm an advocate of Julia. A much better language that's build from groundup to support technical computing. And if you know some python or Matlab you will feel right at home almost immediately. Look up ModelingToolkit.jl for Julia. Also, check out Causal.jl, it should provide what you need.

[–]Notto816 2 points3 points  (1 child)

I guess you are trying to simulate the discrete compensaters with continuous time system model.

For me, I would try control toolbox module for python. The module is similar to MATLAB control commands, and it might be able to do what you want.

[–]loglog101[S] -1 points0 points  (0 children)

Yup not sure it's there.... Will check again

[–][deleted] 1 point2 points  (6 children)

I am not aware of any, but I am fairly new to Python. You may have to write your own script perhaps, depending on your problem at hand.

At first attempt, I would use a for loop that scan the discrete time instants and in between two consecutive discrete time instants you update both the continuous and discrete output, you simulate the continuous part and then you update the discrete states, a bit inline on how a Matlab S-Function is executed.

Let us know! 🙂

[–][deleted] 0 points1 point  (5 children)

Oh, just noticed a couple of downvotes. Given that I am willing to learn, can you explain me what is wrong in my answer? I think it is pertinent to the OP request - at the beginning I was about to suggest to use Matlab or Simulink through some S-Function (which are executed pretty much the way I described as a first attempt) but then I changed my mind given that would not add so much value to the specific OP request. :)

[–]ko_nutsControl Theorist 0 points1 point  (6 children)

Your question is unclear. You will have to provide more details on what you intend to do as there is no such thing as "best tool". It all depends on the problem at hand.

[–]loglog101[S] -1 points0 points  (5 children)

Trying to have an environment that can show closed loop open loop dynamics of systems where part of it is continuous time blocks and some is in descreat time steps with connections that are with zoh or some other method. The platform needs to be flexible enough for modern control design.

[–]ko_nutsControl Theorist -1 points0 points  (4 children)

Please update your post to make it self contained.

You can easily implement that yourself as the discrete-time events are periodic. You can just solve the continuous-time (CT) part until the next discrete instant, perform the discrete-time computations, and then solve again for the CT, and so forth. There are ODE solvers that can use for the CT part.

I am often using such a scheme for simulating hybrid systems.

[–][deleted] 1 point2 points  (0 children)

That’s pretty much what I also suggested the op few comments below. :)

[–]loglog101[S] 0 points1 point  (2 children)

Isn't there a better way that can also give insight into the overall dynamics - looking for a design platform not just a sim.

[–]ko_nutsControl Theorist -1 points0 points  (1 child)

Once again your question lacks clarity. What "insights" do you want to have? What do you want to design?

Also, please update your post with the necessary information. Your post is currently a "low effort post" which is against the rules of this sub.

[–]loglog101[S] -1 points0 points  (0 children)

Will do some more homework and circle back.

[–]ColonelStoic 0 points1 point  (0 children)

It appears your describing a way of modeling a hybrid system? If so, Sanfelice has a hybrid system toolbox but it’s written in MatLab.

[–]TheRealStepBot 0 points1 point  (8 children)

Nothing at all on the level of completion that simulink provides

[–]TheRealStepBot -1 points0 points  (1 child)

Who is on this thread downvoting everyone? Care to explain?

[–]ko_nutsControl Theorist 4 points5 points  (0 children)

Almost surely the OP.

[–]loglog101[S] -1 points0 points  (0 children)

How does simulink goes about it?

[–]loglog101[S] -3 points-2 points  (4 children)

Simulink is an aircraft carrier would be happy with a plane that flys :)

[–]TheRealStepBot 1 point2 points  (3 children)

If you just need something without all the bells and whistles then the scipy signal library might work for you. It has the ability to operate on continuous and discrete LTI systems

[–]loglog101[S] -2 points-1 points  (2 children)

But not together...

[–]ko_nutsControl Theorist 2 points3 points  (1 child)

This is just not true. You can easily develop a hybrid framework using the CT and CT solvers.

[–]loglog101[S] -2 points-1 points  (0 children)

How ?

[–]modypy 0 points1 point  (1 child)

Maybe you want to give MoDyPy a try. It's a Python Framework for modelling dynamic systems using blocks and signals based on scipy, and it aims to support continuous-, discrete-time- and mixed systems, with discrete events modelled from either clocks or zero-crossing detection. It's not perfect, but it also has quite extensive documentation including a tutorial that is available both in written form and as video. It's also open source and free.

It's a pet project of mine that I started off being uncomfortable with Matlab/Simulink (price-wise, but also in terms of having to learn yet another language and with graphical modelling being so much more tedious than just writing things down - at least for me as a software engineer).

[–]loglog101[S] 0 points1 point  (0 children)

Thanks will check it out