In MATLAB R2017b, we added capabilities to manage operating points for Simscape models.
In this post, I will show an example of how to use this feature, and describe the possibilities it introduces.
Getting an Example
In case you were not aware, it is now really easy to get MATLAB Central examples. All you have to do is click on the Get Add-ons button in the MATLAB desktop.
In the Add-Ons Explorer, type what you are looking for, and once you found it, simply click Add To MATLAB.
As its name implies, this model simulates a scissor lift, where a hydraulic cylinder makes the lift go up and down. Here is an animation made using the Mechanics Explorer.
If you look accurately at the results, you will notice that at the beginning of the simulation, the platform falls slightly before the hydraulic pressure stabilizes to compensate gravity.
For this model it is not a major issue, but for large models, this type of transient response can take a considerable amount of time because the solver needs to take many small steps to capture it accurately.
Capturing an Operating Point
To avoid losing time with the transient response every time we simulate the model, we will simulate the model for a two seconds once, until the transient is passed, and then create an operating point object using simscape.op.create that will become our starting point for the next simulation.
Programmatically, this looks like:
Note that it is also possible to configure Simscape logging and Operating Point from the Simscape section of the model configuration.
It is important to point out is that the Simscape Operating Point is very flexible. This includes:
- It is possible to add nodes, remove nodes, and modify nodes programmatically
- If the model contains blocks without corresponding nodes, the block dialog specification will be used
- If the operating point contains nodes without corresponding blocks in the model, those are ignored
Let's take for example this simple thermal liquid model.
We can create an operating point from the logged data:
Now, let's say we decide to add one more pipe:
If you try simulating this model with the previously created operating point, it will simulate fine, however, the second pipe will start with the pressure and temperature specified in the block dialog. Instead, we could make a copy of the pipe node already existing in the operating point and add it to the operating point as a new node.
And now the second pipe operating point will also be controlled from the operating point object.
Are you already using the Simscape Operating point feature? If not, get started with those documentation pages:
- Using Operating Point Data for Model Initialization
- Initialize Model Using Operating Point from Logged Simulation Data
Let us know what you think of this feature in the comments below.