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
We set w_motor to zero to analyze the system response around a stationary operating point, avoiding controller saturation. To make MTK's 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)
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 = 0.1,
wu = 100.0
)
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.
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, use default.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.