Analyzing Simscape model initialization with variable viewer | Simscape Electrical Modeling Practices for Fast Simulation
From the series: Simscape Electrical Modeling Practices for Fast Simulation
The Variable Viewer can be used to check the results of the initialization for the model that uses Simscape. It allows to check, if individual initial value targets for variables have been satisfied. Use the Variable Viewer to check the models’ initial conditions with their priorities, explore issues when model initialization fails or throws warnings.
Published: 7 May 2024
Hello. My name is Eva, and I'm an application engineer at MathWorks. In this video, I would like to show you the Variable Viewer. The Variable Viewer can be used to analyze the initialization values in a Simscape network. This is helpful to verify chosen initialization values or finding causes of warnings or errors thrown during the initialization phase.
The model used in this example was taken from the Simscape electrical examples library. Using this example model, I would walk through the tool, open it by going to Debug, Simscape, and then Variable Viewer. If the model has not been run or initialized yet, it won't be populated with any information. I will do an update to trigger the initialization.
The report now lists all Simscape components in the model. I will check the tree view for better readability. The individual columns display information about status, priority, chosen target values, and the actual values for the different initial values of the variables. The actual value refers to the value that has been found by the solver for the initial state of the system, and it can differ from the target value.
The status column indicates the initialization status of the individual variables. It can, for example, be green, meaning that this target value has been satisfied or it was not assigned any initialization priority. A yellow triangle indicates low priority values that have not been satisfied. A red square points to high priority values which initialization target value was not satisfied. Additionally, you might see a cross when the initialization did not run successfully or a gray rectangle when no information is available yet.
The priority column tells you about the priority of the initial value. In short, a high priority target is one where the solver tries to exactly meet the target. You will get warnings or errors if this cannot be met. A low priority target will trigger the solver to meet or approximate that value, and the target of none will cost the solver to use that value for the first iteration for the initial value, but it will not try to satisfy this target.
You can right click any variable node in the Variable Viewer and select go to Block to navigate to the corresponding block in the model. Additional settings in the viewer give more insights. For example, the advanced view will add more valuable information in additional columns.
It is, for example, a good practice to ensure that differential variables, so variables where time derivatives appear in equations have high priority settings. You can make use of apply filters to search for variables according to specific conditions, for example, here, for differential variables with high priority initial targets. You can use Save to save the current variable viewer configuration settings, and the next time you will open the variable viewer it will open with the same settings.