You can linearize models with Simscape™ components using Simulink® Control Design™ software. Typically, some states in a Simscape network have dependencies on other states through constraints.
To find a steady-state operating point at which to linearize a Simscape model, you can use:
Optimization-based trimming — Specify constraints on model inputs, outputs, or states, and compute a steady-state operating point that satisfies these constraints.
To produce better trimming results for Simscape models, you can use projection-based trim optimizers. These optimizers enforce the consistency of the model initial condition at each evaluation of the objective function or nonlinear constraint function.
Simulation snapshots — Specify model initial conditions near an expected equilibrium point, and simulate the model until it reaches steady state.
For more information, see Find Steady-State Operating Points for Simscape Models.
To linearize your model, you must specify the portion of the model you want to linearize using linear analysis points; that is, linearization inputs and outputs, and loop openings. You can only add analysis points to Simulink signals.
To add a linearization input or loop opening to the input of a Simscape component, first convert the Simulink signal using a Simulink-PS Converter block.
To add a linearization output or loop opening to the output of a Simscape component, first convert the Simscape signal using a PS-Simulink Converter block.
For more information on adding linear analysis points, see Specify Portion of Model to Linearize.
After you specify a steady-state operating point and linear analysis points, you can linearize your Simscape model using:
Simscape networks can commonly linearize to zero when a set of the system equation Jacobians are zero at a given operating condition. Usually, poor initial conditions of the network states cause these zero linearizations.
Consider a system where the mass flow rate from a variable orifice is controlling the position of a piston. The mass flow rate equation of the variable orifice is:
q is the mass flow rate.
Cd is the discharge coefficient.
A is the area of the variable orifice opening.
μ is the fluid density.
p is the pressure drop across the orifice, p = pa - pb.
pcr is the critical pressure, which is a function of pa and pb.
The control variable for this system is the orifice area, A, which controls the mass flow rate. The Jacobian of the mass flow rate with respect to the control variable is:
The linearized mass flow rate equation is:
where represents a deviation from the nominal variable.
In the linearized equation, if the nominal pressure drop p across the orifice is zero, then has no influence on . That is, if the instantaneous pressure drop across the orifice is zero, the orifice area has no influence on the mass flow rate. Therefore, you cannot control the piston position using the orifice area control variable.
To avoid this condition, linearize the model about an operating point where the pressure drop over the orifice is nonzero (pa ≠ pb).
To fix linearization problems caused by poor initial conditions of network states, you can:
Linearize the system at a snapshot operating point or trimmed operating point. When possible, this approach is recommended.
Find and modify the problematic states of the operating point. This option can be difficult for models with many states.
Using the first approach, you can ensure that the model states are consistent via the Simulink and Simscape simulation engine. Simscape initial conditions are not necessarily in a consistent state. The Simscape engine places them in a consistent state during simulation and for trimming using the Simscape trim solvers.
A common workflow is to simulate your model, observe at what time the model satisfies the operating condition at which you want to linearize, then take a simulation snapshot. Alternatively, you can trim the model about the condition you are interested in. In either case, the network states are in a consistent condition, which solves most poor linearization issues.
Using the second approach, you search through the physical network states to find conditions that can create a zero Jacobian. This approach can require some intuition about the dynamics of the physical components in your model. As a starting point, search for states that are zero and that interact directly with nonlinear physical elements, such as the variable orifice in the preceding example.
To search the physical states, you can use the Linearization Advisor, which collects diagnostic information during linearization. The Linearization Advisor does not provide diagnostic information on a component-level basis for Simscape networks. Instead, it groups diagnostic information for multiple Simscape components together.
Linearize your model with the Linearization Advisor enabled, and extract the
opt = linearizeOptions('StoreAdvisor',true); [linsys,linop,info] = linearize(mdl,io,op,opt); advisor = info.Advisor;
Create a custom query object, and search the diagnostic information for Simscape blocks.
qSS = linqueryIsBlockType('simscape'); advSS = find(advisor,qSS);
To find problematic state values, check the block operating point in each
Once you find a problematic state, you can change the value of the state in the model
operating point, or create an operating point using
You can also search the Linearization Advisor in the Linear Analysis Tool. For more information, see Find Blocks in Linearization Results Matching Specific Criteria.