PartialFFT partial model

Requirements.ChecksInFixedWindow_withFFT.Internal.PartialFFT  · source

Icon of PartialFFT

Partial model containing the common part of the FFT blocks

Partial model with the common part of the FFT check blocks WithinAbsoluteDomain, WithinRelativeDomain and MaxTotalHarmonicDistortion: the interfaces, the sampling of input u into a buffer, the FFT computation, the storage of the FFT on file, and the property output y.

From f_max and f_resolution the number of sample points ns is computed with get_ns (even, ns = 2^i*3^j*5^k, maximum FFT frequency f_max_FFT ≥ 5*f_max), together with the sample period Ts = 1/(2*f_max_FFT) and the period T = (ns-1)*Ts one FFT needs. At a rising edge of condition (or if condition is true at initialization), u is sampled every Ts and stored in buffer u_buf; FFT_computation is true while the buffer is filled. When ns samples are stored, or the simulation terminates with a partially filled buffer, fftScaled computes the amplitudes A_buf of the first np frequency points (up to f_max_plot); if storeFFTonFile = true they are stored with saveFFTonFile in file <modelName>/FFT.<instanceName>.<index>.mat. Files of previous runs are removed at initialization with removeFFTresultFiles.

An extending block must compute yFFT and scaledDistance (and may set fA_plot) in a when-clause with the same condition as the FFT computation. Output y is Undefined before the first rising edge of condition, Undecided while the first buffer is filled and yFFT once an FFT has been computed. The optional output margin = scaledDistance/scale is the normalized margin (≥ 0 exactly when the check holds).

Revisions

DateDescription
Nov. 29, 2015Initial version implemented by Martin R. Kuhn and Martin Otter (DLR Institute of System Dynamics and Control)
The research leading to these results has received funding from the European Union’s Seventh Framework Programme (FP7/2007-2016) for the Clean Sky Joint Technology Initiative under grant agreement no. CSJU-GAM-SGO-2008-001.
Sept. 14, 2026A condition that is already true at initialization starts the FFT explicitly (initial() and condition): a tool that initializes pre(condition) to the condition's own value instead of honouring the initial equation pre(condition) = false (Modelon Impact) never saw the edge and the block stayed dead for the whole run (H. Tummescheit, Model Based Innovation LLC)

Parameters

NameTypeDescription
storeFFTonFile parameterBoolean= true, if FFT results shall be stored on file <modelName>/FFT.<instanceName>.<index>.mat
f_max parameterSI.FrequencyMaximum frequency of interest (sampling frequency >= 10*f_max)
f_resolution parameterSI.FrequencyFrequency resolution (frequency axis points are an integer multiple of f_resolution)
scale parameterRealScale of the margin: margin = scaledDistance/scale, with scale the requirement's tolerance (1 = the scaled distance itself)
computeMargin parameterBoolean= true, if the normalized margin output is provided
ns parameterIntegerNumber of FFT sample points (is even and can be expressed as ns = 2^i*3^j*5^k)
f_max_FFT parameterSI.FrequencyMaximum frequency used by FFT
nf parameterIntegerNumber of frequency points
Ts parameterSI.TimeSample period
T parameterSI.TimeSimulation time for one FFT calculation
np parameterIntegerNumber of frequency points used for plotting (only up to interested frequency)
f_max_plot parameterSI.FrequencyLargest frequency shown in the icon plot and stored on file

Components and variables

NameTypeDescription
conditionModelica.Blocks.Interfaces.BooleanInputBoolean input condition signal (a rising edge signals to store u-values in a buffer; if there are enough values in the buffer, an FFT is computed)
uModelica.Blocks.Interfaces.RealInputSignal on which an FFT is performed
yRequirements.Interfaces.PropertyOutputProperty output signal (= Satisfied, if FFT Amplitudes of u are within maxAmplitude)
FFT_computationModelica.Blocks.Interfaces.BooleanOutput= true, when u is stored in buffer for FFT computation
scaledDistanceModelica.Blocks.Interfaces.RealOutputMinimum distance of FFT Amplitudes of u to maxAmplitude (>= 0 if inside, otherwise outside of maxAmplitude)
marginRequirements.Interfaces.MarginOutputNormalized margin of the last FFT check: >= 0 exactly when it holds, in units of scale
periods_okBoolean= true, if all periods for FFT computations have been long enough
fillColor[…]IntegerFill colour of the icon's plot area (grey if satisfied, light red if violated)
fA_plot[…]Real[frequency, amplitude] matrix used for plotting in icon