State and Output Function of a nonlinear dynamics to use is NMPC

Hello,
So far I simulated a dynamic equation based on real data inputs in Simullink. I also estimated my coefficients to getting as close as possible to the real data.
My dynamic equation belongs to an axial-flow pump intended to use for pacients with heart desease is as below:
a,b,c,d, and L are coefficients which I tuned.
and omega(refrence speed), H(head pressure) and Q(flow) are inputs from test data.
My intention is to build a nonlinear MPC for this dynamics. but the problem is I don't know how to write State and Output functions for it.
On this dynamics, I can contorl Omega and H and the output is flow. I want to control the flow.
Thank you for your time in Advance!
Best Regarsd

 채택된 답변

Sam Chak
Sam Chak 2022년 7월 21일
편집: Sam Chak 2022년 7월 25일
The axial-flow pump system is governed by this equation:
.
So, the State variable in this equation is Q, and the Output that you want is the flow, which is also Q.
The State function refers to the uncontrolled dynamics of the pump system. That means you don't need to supply the any math equation to the inputs ω and H because I think the NMPC calculate for you without requiring you to understand the behavior of the system at all. For example, here is the code for myStateFunction, where x , u(1) , and u(2) .
function z = myStateFunction(x, u)
a = 276.73;
b = -0.2703;
c = 17.5260;
d = -1.5806e-06;
L = -11.7480;
z = b/L*u(1) + c/L*u(2) + (d/L*u(1)^2 + a/L)*x;
end
If the output is also the state, then the code for myOutputFunction is given by
function y = myOutputFunction(x, u)
y = x;
end
NMPC-free method:
If you can manipulate the angular speed ω and the pressure head H, then you can probably control the flow Q without using the NMPC. Here is an example:
tspan = [0 10];
initv = 1;
[t, Q] = ode45(@odefcn, tspan, initv);
plot(t, Q, 'linewidth', 1.5), grid on, xlabel('t'), ylabel('Q'), ylim([0.5 2.5])
function dQdt = odefcn(t, Q)
a = 276.73;
b = -0.2703;
c = 17.5260;
d = -1.5806e-06;
L = -11.7480;
k = 1; % affects the rate of convergence
Qref = 2; % desired flowrate
omega = - (L/b)*k*(Q - Qref); % <--- correction % angular Speed
H = - (L/c)*((d/L*omega^2 + a/L)*Q); % pressure Head
dQdt = b/L*omega + c/L*H + (d/L*omega^2 + a/L)*Q; % ODE
endf

댓글 수: 5

Dear @Sam Chak,
Thank you so much. I tried to replace my test data in omega and H and also I replaced the coefficients with my data as well as the tspan. However my desired flow rate (Q_ref) is not a single number.below you can see
So, should I replace my refrence flow along with othe coefficients and variables or not? if yes, How?
span = timevals;
initv = 1;
[t, Q] = ode45(@odefcn, tspan, initv);
plot(t, Q), grid on, xlabel('t'), ylabel('Q'),
% ylim([0 1])
function dQdt = odefcn(t, Q)
a = 276.73;
b = -0.2703;
c = 17.5260;
d = -1.5806e-06;
L = -11.7480;
k = 1;
Qref = 2; % desired flowrate
v_meas_sim = - k*(Q - Qref); % angular Speed
H = - (L/c)*((d/L*v_meas_sim^2 + a/L)*Q); % pressure Head
dQdt = b/L*v_meas_sim + c/L*H + (d/L*v_meas_sim^2 + a/L)*Q; % ODE
end
The result is good. So I can be hopefull to design my controller.
So, this function would be my state function. right?
do you have any idea about my output function?
I have made a minor correction on this line:
omega = - (L/b)*k*(Q - Qref); % <--- correction % angular Speed
If everything works well, then the system becomes (after making all substitutions and eliminations)
and the output function for the flow is given by
Dear @Sam Chak,
Thank you so much for your response.
state function causes an error that I can not understand how to fix it!
As stated in the mathworks Prediction Model Specification, state function must contain states and inputs. while here I think it does not contain!
when I want to run my simulink containing nlmpc object that I made by your help this error pups up; Execution of script sputnikStFcn as a function is not supported
Do you know How can I fix it?
I am eagerly waiting for your response.
Best Wishes
Hi @seyyed Erfan ghoreyshipour, I updated to include myStateFunction and the myOutputFunction
Dear @Sam Chak,
Sorry for the delay. I am progressing with jacobian functions.
Thank you for your help. This helped me a lot!
I am currently writing state and output jacobian functions. If you have any idea about that please let me know.
Best Regards

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Robbie
Robbie 2022년 8월 24일

0 개 추천

Thanks for the solution. That works!

댓글 수: 1

Dear @Robbie,
Can you please tell me how did you implement the model?
I am still strugling with it! :)

댓글을 달려면 로그인하십시오.

Anna
Anna 2022년 10월 26일

0 개 추천

Thank you so much. It worked for my issue well. I appreciate that a lot Godskin Apostle
ann lily
ann lily 2023년 10월 20일

0 개 추천

The article about is very good, thank you for sharing! cuphead
emily
emily 2025년 12월 4일

0 개 추천

Interesting Simulink simulation for your axial-flow pump! For your MPC state-space representation, consider defining states as functions of Q (flow) and its derivatives. Your output function would simply be y = Q, since you're controlling flow. Have you explored using a simpler model, like a linearized version, initially for MPC development? This sounds like navigating challenging terrain, like riding a virtual Snow Rider !

카테고리

도움말 센터File Exchange에서 Model Predictive Control Toolbox에 대해 자세히 알아보기

질문:

2022년 7월 21일

답변:

2025년 12월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by