Main Content

Linearize Simscape Networks

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.

Find Steady-State Operating Point

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.

Specify Analysis Points

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 (Simscape) 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 (Simscape) block.

For more information on adding linear analysis points, see Specify Portion of Model to Linearize.

Linearize Model

After you specify a steady-state operating point and linear analysis points, you can linearize your Simscape model using one of the following:

Note

Linearization is not supported for Simscape networks configured to use a local solver. For more information on configuring the solver, see Solver Configuration (Simscape).

For general linearization examples, see Linearize Simulink Model at Model Operating Point and Linearize at Trimmed Operating Point.

Troubleshoot Simscape Network Linearizations

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.

Zero Linearization Example

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=CdA2μ(pp2+pcr2)0.25

Where:

  • 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:

qA=Cd2μ(pp2+pcr2)0.25

The linearized mass flow rate equation is:

q¯=Cd2μ(pp2+pcr2)0.25A¯+qμμ¯+(qpcrpcrpa+qp)p¯a+(qpcrpcrpbqp)p¯b

where ·¯ represents a deviation from the nominal variable.

In the linearized equation, if the nominal pressure drop p across the orifice is zero, then A¯ has no influence on q¯. 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 (papb).

Troubleshooting Tips

To fix linearization problems caused by poor initial conditions of network states, you can:

  1. Linearize the system at a snapshot operating point or trimmed operating point. When possible, this approach is recommended.

  2. 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.

  1. Linearize your model with the Linearization Advisor enabled, and extract the LinearizationAdvisor object.

    opt = linearizeOptions('StoreAdvisor',true);
    [linsys,linop,info] = linearize(mdl,io,op,opt);
    advisor = info.Advisor;
  2. Create a custom query object, and search the diagnostic information for Simscape blocks.

    qSS = linqueryIsBlockType('simscape');
    advSS = find(advisor,qSS);
  3. To find problematic state values, check the block operating point in each BlockDiagnostic object.

    advSS.BlockDiagnostics(i).OperatingPoint.States

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 operpoint.

You can also search the Linearization Advisor in the Model Linearizer. For more information, see Find Blocks in Linearization Results Matching Specific Criteria.

See Also

Apps

Functions

Related Topics