+ClosingTheLoop, the signal package in SciPy has a few nice functions. The control module (from Richard Murray's group) also has some nice functionality.
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?
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()
@@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?
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
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.
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.
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
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
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!
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.
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.
I just want to thank you from the bottom of my heart
Thank you so much. You are great
This was really helpful. Thank you so much!
This was extremely helpful! Thank you so much!
Never thought of using python for controls... nice.
+ClosingTheLoop, the signal package in SciPy has a few nice functions. The control module (from Richard Murray's group) also has some nice functionality.
ClosingTheLoop, check out the new control course in Python as well: apmonitor.com/pdc
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?
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()
What if we take u = e^-t for every case
How to write the code then?
You can precalculate u and then plug in those values to simulate the output.
@@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?
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
Yes, here are some examples using ODEINT that implements a RK method: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
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
Thanks
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.
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.
How should i do if itr
Xdot =Ax+bu+Ez
y=cx+du+fz
and i have disturbance
If you have additional disturbances that are inputs then you can augment the B and D matrices. The disturbances are just extra inputs.
Love Respect and Salute 4 U..
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
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
Thank you very much for support )
How do i include those libraries to my python?
You need to get the additional packages with pip or conda. Here are tutorials: apmonitor.com/che263/index.php/Main/PythonIntroduction
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
There is source code for solving this type of equation at apmonitor.com/pdc/index.php/Main/StateSpaceModel (select 'Show Solution').
do you have simulations of MIMO system? thanks.
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!
Good video, please, what is your Python version?
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.
thank you
You're welcome
Thank you so much!
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.
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.