State Space Models and Simulation in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ย. 2024
  • Linear Time Invariant (LTI) state space models are a linear representation of a dynamic system in either discrete or continuous time. Putting a model into state space form is the basis for many methods in process dynamics and control analysis. See apmonitor.com/p... for source code and further information on state space models.

ความคิดเห็น • 40

  • @alyeasin3367
    @alyeasin3367 11 หลายเดือนก่อน +2

    Thank you so much. You are great

  • @touhidislamTOUHID498
    @touhidislamTOUHID498 6 ปีที่แล้ว +3

    I just want to thank you from the bottom of my heart

  • @NikolaosPapadakis
    @NikolaosPapadakis 5 ปีที่แล้ว +1

    Sorry for being such a stickler, especially since your videos are excellent, but on problem 3, the solution in the site apmonitor.com/pdc/index.php/Main/StateSpaceModel , has the columns in the wrong order compared to this video
    I assume what you are doing is assuming that the x vector is X = [x_2; x_1] , instead of [x_1; x_2] that you are assuming in the video.

    • @apm
      @apm  5 ปีที่แล้ว +1

      I love comments like this because they help me fix the inconsistencies on the web-site. Thanks for your careful attention to detail!
      I've updated the code online:
      # problem 3 (old)
      A = [[-0.5,-0.25],[1.0,0.0]]
      print(np.linalg.eig(A)[0])
      B = [[0.75],[0.0]]
      C = [0.0,1.0]
      D = [0.0]
      sys3 = signal.StateSpace(A,B,C,D)
      t = np.linspace(0,30,100)
      u = np.zeros(len(t))
      u[5:50] = 1.0 # first step input
      u[50:] = 2.0 # second step input
      t3,y3,x3 = signal.lsim(sys3,u,t)
      # problem 3 (new)
      A = [[0.0,1.0],[-0.25,-0.5]]
      print(np.linalg.eig(A)[0])
      B = [[0.0],[0.75]]
      C = [1.0,0.0]
      D = [0.0]
      sys3 = signal.StateSpace(A,B,C,D)
      t = np.linspace(0,30,100)
      u = np.zeros(len(t))
      u[5:50] = 1.0 # first step input
      u[50:] = 2.0 # second step input
      t3,y3,x3 = signal.lsim(sys3,u,t)
      Both give the same answer but the new one is consistent with the video.

  • @alialcapone5174
    @alialcapone5174 4 ปีที่แล้ว +1

    How should i do if itr
    Xdot =Ax+bu+Ez
    y=cx+du+fz
    and i have disturbance

    • @apm
      @apm  4 ปีที่แล้ว +1

      If you have additional disturbances that are inputs then you can augment the B and D matrices. The disturbances are just extra inputs.

  • @shashankshivakumar4732
    @shashankshivakumar4732 3 ปีที่แล้ว +1

    This was really helpful. Thank you so much!

  • @allanc.marques7496
    @allanc.marques7496 5 ปีที่แล้ว +1

    a doubt, if we have 2 equations like:
    x' = A.x + B.u
    y' + y = C.x + D.u
    where D = 0. I really appreciate ur videos! Thanks

    • @apm
      @apm  5 ปีที่แล้ว

      There is source code for solving this type of equation at apmonitor.com/pdc/index.php/Main/StateSpaceModel (select 'Show Solution').

  • @hussain55019
    @hussain55019 6 ปีที่แล้ว +1

    Love Respect and Salute 4 U..

  • @biswajitborah8628
    @biswajitborah8628 3 ปีที่แล้ว +1

    What if we take u = e^-t for every case
    How to write the code then?

    • @apm
      @apm  3 ปีที่แล้ว

      You can precalculate u and then plug in those values to simulate the output.

    • @biswajitborah8628
      @biswajitborah8628 3 ปีที่แล้ว

      @@apm thank you so much it was really helpful. I had another question. In model order reduction I have matrices A,B,C,D having order 48×48,48×1,1×48,0 respectively. I reduced it to A',B',C',D' having order 6×6,6×1,1×6,0 respectively. But not able to find the h2 norm. Can you please help me with it?
      I got the formula h2 = Tr(CUC') . U is controllability grammian matrix.
      My question is which C to take? Is it C or C' or C-C'? Also the U is the controllability grammian matrix of original system or reduced system or the system we get after we find the difference?

  • @mariahelenahatzinikolaou3567
    @mariahelenahatzinikolaou3567 7 ปีที่แล้ว +1

    This was extremely helpful! Thank you so much!

  • @hichambod
    @hichambod 5 ปีที่แล้ว +1

    thank you so much for this useful video
    do you have an example that implement a runge-kutta method to solve an ODE's system? thanks again

    • @apm
      @apm  5 ปีที่แล้ว +1

      Yes, here are some examples using ODEINT that implements a RK method: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations

    • @apm
      @apm  5 ปีที่แล้ว +1

      And here is another set of tutorials that use a different approach for the ODE solution (orthogonal collocation on finite elements): apmonitor.com/pdc/index.php/Main/PythonDifferentialEquations

    • @hichambod
      @hichambod 5 ปีที่แล้ว +1

      Thanks

  • @pabloignaciojeldescastro4215
    @pabloignaciojeldescastro4215 5 ปีที่แล้ว

    do you have simulations of MIMO system? thanks.

    • @apm
      @apm  5 ปีที่แล้ว

      Here are some MIMO simulations: apmonitor.com/do/index.php/Main/ModelIdentification and apmonitor.com/do/index.php/Main/AdvancedTemperatureControl I also have more material in Python at apmonitor.com/pdc Enjoy!

  • @philtoa334
    @philtoa334 4 ปีที่แล้ว +1

    thank you

    • @apm
      @apm  4 ปีที่แล้ว

      You're welcome

  • @pabloignaciojeldescastro4215
    @pabloignaciojeldescastro4215 5 ปีที่แล้ว

    a doubt, if i want to plot all states from system, we assume that not always the output is the states of system, how to plot output,state1,state2, that is to say, y,x1,x2 ? is there a way to do it with python?

    • @apm
      @apm  5 ปีที่แล้ว

      Sure, you can just have additional plot commands such as:
      plt.plot(x1,y1,'ro',label='First plot')
      plt.plot(x2,y2,'b-',label='Second plot')
      plt.legend(loc='best')
      plt.show()

  • @ashley1145
    @ashley1145 7 ปีที่แล้ว

    Good video, please, what is your Python version?

    • @apm
      @apm  7 ปีที่แล้ว

      It is the Anaconda distribution with Python 3.5. This example should also work with Python 2.7. The signal module is supported in both.

  • @SaeedAcronia
    @SaeedAcronia 6 ปีที่แล้ว

    How do i include those libraries to my python?

    • @apm
      @apm  6 ปีที่แล้ว

      You need to get the additional packages with pip or conda. Here are tutorials: apmonitor.com/che263/index.php/Main/PythonIntroduction

  • @hys0540
    @hys0540 6 ปีที่แล้ว

    You are a great engineer and teacher, thank you for the videos and material you do....keep it up.
    Can you please do more videos about non-linear model predictive control and fuzzy logic control, million thanks.

    • @apm
      @apm  6 ปีที่แล้ว

      There is more on nonlinear model predictive control here: apmonitor.com/do/index.php/Main/NonlinearControl I don't have any material on fuzzy logic, however. Thanks for the feedback.

  • @aerospace.x1424
    @aerospace.x1424 6 ปีที่แล้ว

    Thank your very much for video, I would like to ask a question; how can i regulate these system for 2-input and 2-output ? i have mimo 2-2 ss model but i could not imply multi input.
    best regards

    • @apm
      @apm  6 ปีที่แล้ว

      The dynamic optimization course is a good source for MIMO control software in APM MATLAB or Python GEKKO. The temperature control lab is a comprehensive tutorial on MIMO ID and control: apmonitor.com/do/index.php/Main/AdvancedTemperatureControl

    • @aerospace.x1424
      @aerospace.x1424 6 ปีที่แล้ว

      Thank you very much for support )

  • @closingtheloop2593
    @closingtheloop2593 7 ปีที่แล้ว

    Never thought of using python for controls... nice.

    • @apm
      @apm  7 ปีที่แล้ว +2

      +ClosingTheLoop, the signal package in SciPy has a few nice functions. The control module (from Richard Murray's group) also has some nice functionality.

    • @apm
      @apm  7 ปีที่แล้ว

      ClosingTheLoop, check out the new control course in Python as well: apmonitor.com/pdc

  • @franco521
    @franco521 5 ปีที่แล้ว

    Thank you so much!