Hi, I think the best way is to use script section. you may need to use previous state values in your equations (i.e. "K-1"). #storage function can be useful to store variables from previous state. In some recently published papers, there are some cases of MATLAB/PSCAD interface examples to implement MPC. Since there are few examples about MPC in PSCAD, you have to be familiar with coding in PSCAD. The following paper is about MPC in battery EES. I hope you do it well and share your experience.
"Model Predictive Control Analysis for the Battery Energy Storage System