Frequency Response Analysis
The Frequency Response Analysis computes the frequency response from an input analysis point to one or more output analysis points in a model. This is useful for identifying system dynamics, resonance, and bandwidth, and for validating models against experimental data.
Method Overview
Frequency-response analysis excites the system with a wide range of frequencies (chirp or multisine) and estimates the transfer function from a specified input to one or more specified outputs over the selected frequency range. The result is typically visualized as a Bode plot (magnitude and phase).
Chirp excitation: A single frequency-swept signal, fast and efficient for most systems.
Multisine excitation: Multiple experiments are performed, each one with a different frequency. This alternative is typically slower but more accurate.
Example Definition
Download as a Dyad projectFrequencyResponseExample.zipOpen in Dyad Studio
We set w_motor to zero to analyze the system response around a stationary operating point, avoiding controller saturation. To make the initialization deterministic, we wrap the test model in a component that adds guess statements for the algebraic variables that would otherwise have cyclic guesses.
component DCMotorForFrequencyResponse
extends DyadExampleComponents.TestDCMotorLoadControlled(w_motor = 0, tau_load = 0.0)
relations
guess controller.u_s = 0
guess controller.u_m = 0
guess motor.R1.v = 0
guess motor.emf.tau = 0
guess motor.friction.phi_rel = 0
guess controller.proportional.y = 0
guess controller.add_pid.y = 0
guess controller.derivative.y = 0
end
analysis DCMotorFrequencyResponse
extends DyadControlSystems.FrequencyResponseAnalysis(
input = "r",
outputs = ["y"],
wl = 1.0,
wu = 1000.0,
input_type = "multisine"
)
model = DCMotorForFrequencyResponse()
endusing DyadInterface: artifacts
asol = DCMotorFrequencyResponse()
artifacts(asol, :BodePlot)The resulting Bode plot shows the frequency response from the reference input r to the measured output y. The magnitude plot reveals the system bandwidth and resonance characteristics, while the phase plot indicates stability margins and time delays in the control loop.
Note
Frequency-response analysis estimates the response of the underlying nonlinear system through simulation. If the excitation is large enough to engage nonlinearities, such as the output saturation of the PID controller in this example, the estimated response becomes amplitude dependent and may deviate from the exact linearization of the model. Around the resonance peak, where the loop amplifies the excitation, the controller in this example saturates and the estimated peak is lower than that of the linearized model.
Analysis Arguments
The following arguments define a FrequencyResponseAnalysis:
Required Arguments
model: The model to be analyzed.input::String: Name of the input analysis point.outputs::Vector{String}: Names of the output analysis points. Can be a single output or multiple outputs for MIMO analysis.wl: Lower frequency bound for the analysis.wu: Upper frequency bound for the analysis.
Optional Arguments
input_type::String = "chirp": Type of excitation signal, either"chirp"or"multisine".num_frequencies::Int = 50: Number of frequencies (only for"multisine").duration::Float64 = -1.0: Duration of the experiment (for chirp). If -1, a default of 5 periods of the lowest frequency is used. If the estimated frequency response shows ripple, increase the duration.Ts::Float64 = -1.0: Sample time for the experiment. If -1, use default based on the frequency range.
Artifacts
A FrequencyResponseAnalysis returns the following artifact:
Standard Plot
BodePlot: Bode plot (magnitude and phase) of the transfer function from input to each output.