---
url: /dyad/stable/analyses/linear.md
description: >-
  Perform linearization and frequency/time-domain analysis of a model, including
  Bode plots, step response, modal analysis, and more.
---

# Linear Analysis {#LinearAnalysis}

Download as a Dyad projectLinearExample.zipOpen in Dyad Studio›

The Linear Analysis computes the linearized dynamics of a model and provides a suite of frequency- and time-domain analysis tools. This is useful for understanding the small-signal behavior of a system, including stability, resonance, and transient response.

## Method Overview {#Method-Overview}

Linear analysis is performed by linearizing the provided model around an operating point. The resulting linear system can be analyzed using classical control theory tools, including:

* **Frequency response** ([Bode](https://en.wikipedia.org/wiki/Bode_plot), [Nyquist](https://en.wikipedia.org/wiki/Nyquist_plot), [root locus](https://en.wikipedia.org/wiki/Root_locus), and [RGA](https://en.wikipedia.org/wiki/Relative_gain_array) plots)

* **Time response** ([step response](https://en.wikipedia.org/wiki/Step_response), [rise time](https://en.wikipedia.org/wiki/Rise_time), [settling time](https://en.wikipedia.org/wiki/Settling_time), overshoot, etc.)

* **Modal analysis** ([damping report](https://en.wikipedia.org/wiki/Damping_ratio), [pole-zero map](https://en.wikipedia.org/wiki/Pole%E2%80%93zero_plot))

### Symbolic linearization {#linear-analysis-symbolic}

Set `symbolic = true` in `DyadControlSystems.LinearAnalysis` to inspect how a small model's dynamics depend on its parameters. This option, available in DyadControlSystems 2.4.2, adds a symbolic linearization alongside the numerical result. Its $A, B, C, D$ matrices contain expressions that can be used to obtain a characteristic polynomial, poles, and a transfer function.

For example, the mass-spring-damper equation $m\ddot{x} + c\dot{x} + kx = u$ has the characteristic polynomial $s^2 + (c/m)s + k/m$. Symbolic results retain these parameter relationships.

Choose a small, smooth model for this option:

* Branching expressions such as `ifelse`, `max`, `min`, `clamp`, and saturation blocks are unsupported. The motor example below uses a controller with limiters and demonstrates numerical linearization only.

* Differential-algebraic models require a symbolic linear solve without pivoting; results can be unreliable or fail for higher-index systems.

* Expressions and computation costs grow rapidly with state dimension.

* `SymbolicPoles` requires `using Nemo` in the Julia session. Its closed-form root solver is limited to degree four after cancellation of trivial factors; this restriction does not apply to the other symbolic artifacts.

The symbolic result is a separate linearization: its state order and dimension may differ from the reduced numerical system. The analysis's `t` setting applies to the numerical result; symbolic expressions retain explicit time dependence.

For use directly from Julia, DyadControlSystems provides `named_ss_symbolic`, `symbolic_charpoly`, `symbolic_poles`, and `symbolic_tf`. After loading DyadControlSystems, enter `?named_ss_symbolic` in the Julia REPL for the API and a worked example.

## Example Definition {#Example-Definition}

Since we are opening the loop at `r` (the reference speed input to the controller), we need to provide an initial condition for `controller.u_s` — otherwise, the linearization cannot determine its operating point value. We do this by extending the test model and adding `initial controller.u_s = 0`:

```dyad
component DCMotorForLinearization
  extends DyadExampleComponents.TestDCMotorLoadControlled(w_motor = 0)
relations
  guess controller.u_s = 0
  guess controller.u_m = 0
  guess motor.R1.v = 0
  guess motor.emf.tau = 0
  guess motor.emf.rotor.tau = 0
  guess motor.emf.rotor.phi = 0
  guess motor.emf.p.i = 0
  guess motor.friction.phi_rel = 0
  guess load.phi = 0
  guess controller.proportional.y = 0
  guess controller.add_pid.y = 0
  guess controller.derivative.y = 0
end

analysis DCMotorLinearAnalysis
  extends DyadControlSystems.LinearAnalysis(
    outputs       = ["y"],
    inputs        = ["r"],
    loop_openings = ["r"],
    duration = 5.0
  )
  model = DCMotorForLinearization()
end
```

We set `w_motor` to zero so the controller does not saturate at the linearization point, and provide `guess controller.u_s = 0` so the disconnected setpoint input has a defined operating point. We also provide numeric guesses for the algebraic motor variables and the controller's internal block outputs so that the linearization solver does not encounter cyclic guesses.

```julia
using DyadInterface: artifacts
asol = DCMotorLinearAnalysis()
artifacts(asol, :StepInfoPlot)
```

![](kvbxtwu.svg)

```julia
artifacts(asol, :BodePlot)
```

![](mfwonpc.svg)

```julia
artifacts(asol, :DampReport)
```

## Analysis Arguments {#Analysis-Arguments}

The following arguments define a LinearAnalysis:

#### Required Arguments {#Required-Arguments}

* `model`: The model to be analyzed.

* `inputs::Vector{String}`: Names of the input analysis points

* `outputs::Vector{String}`: Names of the output analysis points

#### Optional Arguments {#Optional-Arguments}

* `wl::Real = -1`: Lower frequency bound for Bode plot (set to -1 for automatic selection).

* `wu::Real = -1`: Upper frequency bound for Bode plot (set to -1 for automatic selection).

* `num_frequencies::Int = 3000`: Number of frequency points.

* `duration::Real = -1`: Duration for the step response plot (set to -1 for automatic selection).

* `loop_openings::Vector{String} = []`: Analysis points where feedback loops are opened before linearization.

* `t::Real = 0`: Time at which to compute the numerical linearization.

* `symbolic::Bool = false`: Also compute the [symbolic linearization](/analyses/linear#linear-analysis-symbolic).

## Artifacts {#Artifacts}

A LinearAnalysis returns the following artifacts:

#### Standard Plots {#Standard-Plots}

* `BodePlot`: [Bode plot](https://en.wikipedia.org/wiki/Bode_plot) of the system.

* `MarginPlot`: Bode plot with [gain margin](https://en.wikipedia.org/wiki/Gain_margin) and [phase margin](https://en.wikipedia.org/wiki/Phase_margin).

* `StepResponse`: [Step response](https://en.wikipedia.org/wiki/Step_response) of the system.

* `StepInfoPlot`: Plot of [step response characteristics](https://en.wikipedia.org/wiki/Step_response).

* `RootLocusPlot`: [Root locus plot](https://en.wikipedia.org/wiki/Root_locus) of the system.

* `PoleZeroMap`: [Pole-zero map](https://en.wikipedia.org/wiki/Pole%E2%80%93zero_plot) of the system.

* `NyquistPlot`: [Nyquist plot](https://en.wikipedia.org/wiki/Nyquist_plot) of the system.

* `RGAPlot`: [Relative Gain Array (RGA)](https://en.wikipedia.org/wiki/Relative_gain_array) plot of the system.

#### Tables {#Tables}

* `DampReport`: DataFrame with [modal analysis](https://en.wikipedia.org/wiki/Modal_analysis) ([damping](https://en.wikipedia.org/wiki/Damping_ratio), frequency, time constant, etc.).

* `StepInfo`: DataFrame with [step response characteristics](https://en.wikipedia.org/wiki/Step_response).

* `ObservabilityReport`: DataFrame with [observability](https://en.wikipedia.org/wiki/Observability) information.

#### Symbolic Results {#Symbolic-Results}

With `symbolic = true`, the result also provides:

| Artifact                   | Result                                                                                  |
|:-------------------------- |:--------------------------------------------------------------------------------------- |
| `SymbolicStateSpace`       | State-space system with symbolic $A, B, C, D$ matrices.                                 |
| `SymbolicMatrices`         | Full symbolic Jacobians, including descriptor blocks for differential-algebraic models. |
| `CharacteristicPolynomial` | Characteristic polynomial $\det(sI-A)$.                                                 |
| `SymbolicPoles`            | Closed-form poles; requires Nemo and the degree limit described above.                  |
| `SymbolicTransferFunction` | Transfer function $C(sI-A)^{-1}B + D$.                                                  |

For a `result` computed with `symbolic = true`, use `artifacts(result, :SymbolicStateSpace)` or another artifact name from the table. Derived expressions are computed when requested; only the poles require Nemo.

## Further Reading {#Further-Reading}

* [ControlSystems.jl documentation](https://juliacontrol.github.io/ControlSystems.jl/dev/)

* [Linear system theory (Wikipedia)](https://en.wikipedia.org/wiki/Linear_system)

* [Modal analysis (Wikipedia)](https://en.wikipedia.org/wiki/Modal_analysis)
