Effacer les filtres
Effacer les filtres

how to adjust the simulation time of the parent model with the referenced model?

4 vues (au cours des 30 derniers jours)
Mounira
Mounira le 15 Jan 2024
Hello,
so I have a dc microgrid model with sources generation and loads, and this microgrid is controlled by model predictive controller, the model predictive controller is a referenced model, as for the microgrid model it is defined as a parent model, plus the model predictive controller has a plant model, and it imports the signals from the microgrid model as well,
the parent model has simulation time of 0.48, and sample time 1e-6, and the simulation goes for about 48 data (for different pv outputs and loads); but the MPC has a sample time of 1, Tc=4 and Tp=10, i couldn't change these values a lot or else it will give an error,
so now i am getting results for the inputs and outputs of the model predictive controller, for a duration of 10 seconds,
the problem is that i don't if these 2 models are working together at the same time, so how i can be sure? and if they are not working together at the same time, how to fix it? is it related to the time frame?
thanks in advance

Réponses (1)

Hassaan
Hassaan le 15 Jan 2024
The MPC operates on a discrete time frame defined by its sample time (T_s), prediction horizon (T_p), and control horizon (T_c). If the sample time of the MPC is significantly different from the simulation step size of the plant model, synchronization issues may arise.
Here are some steps to verify:
Check the Sample Time Compatibility:
  • Ensure that the sample time of the MPC (T_s = 1 second) is appropriate for the dynamics of your microgrid model.
  • The sample time of the microgrid model is 1e-6, which is much finer than the MPC's sample time. This means the MPC will update its control action every 1 second, while the microgrid model updates every 1e-6 seconds.
Data Exchange Between Models:
  • Verify that the input/output data exchange between the MPC and the plant model is correctly configured. The MPC should receive updated measurements from the plant at each MPC sample time, and the plant should receive updated control actions from the MPC likewise.
Synchronize Simulation Times:
  • Match the simulation times: The parent model runs for 0.48 seconds, while the MPC's results are shown for 10 seconds. Ensure the end time for both simulations is the same. You might need to adjust the stop time of the plant model to match the duration for which the MPC calculates the control actions.
Adjusting MPC Parameters:
  • The prediction horizon (T_p) and the control horizon (T_c) should be chosen based on the dynamics of the plant model. If changing these parameters causes errors, it might be an indication that the MPC's design is not well-suited for the plant's dynamics.
Running Co-Simulation:
  • If the MPC is running as a referenced model, you should ensure that the data exchange during the co-simulation is correctly set up. This might require the use of special blocks or configurations to manage the timing and data flow.
Test with Step Responses:
  • Use a step input or a known disturbance to test the response of the overall system. Check if the response of the plant model corresponds to the control actions taken by the MPC. The control actions should be in sync with the plant's response to confirm that they are working together.
Review Model Settings:
  • Open the configuration settings of both the MPC block/model and the plant model to ensure that the solver settings are appropriate for discrete control. It may be necessary to use a fixed-step solver with a step size that matches the MPC sample time, or to configure the solver to handle multiple rates if the plant model requires a finer resolution.
You should be able to determine if the MPC and the plant model are working synchronously. If there are still issues, you may need to delve deeper into the MPC's design and its integration with the plant to ensure that the timing and data exchange are correctly aligned.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by