fftScaled impure function

Requirements.ChecksInFixedWindow_withFFT.Internal.fftScaled  · source

Icon of fftScaled

Compute scaled FFT

Extends Modelica.Icons.Function

Computes the amplitude spectrum of the samples u_buf (sample period Ts) with Modelica.Math.FastFourierTransform.Internal.rawRealFFT and returns the amplitudes of the first nf frequency points in A_buf; A_buf[1] is the mean value of the samples. The mean value is removed from the samples before the FFT.

If the buffer is not completely filled (iTick < size(u_buf,1), e.g. because the simulation ended), the stored samples are zero-padded, periods_ok is set to false and a message with the required and the actual period is printed; otherwise periods_ok keeps the value pre_periods_ok. The function asserts that the FFT succeeded. Called by PartialFFT.

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.

Inputs

NameTypeDescription
u_buf[…] inputRealSignal for which FFT shall be computed; (size(u_buf,1) MUST be EVEN and should be an integer multiple of 2,3,5, that is size(u_buf,1) = 2^a*3^b*5^c, with a,b,c Integer >= 0)
nf inputIntegerNumber of frequency points that shall be returned in amplitudes and phases (typically: nf = max(1,min(integer(ceil(f_max/f_resolution))+1,nf_max))); the maximal possible value is nf_Max=div(size(u_buf,1),2)+1)
iTick inputIntegerNumber of sample points that have been stored in u_buf
Ts inputSI.TimeSample period of FFT
pre_periods_ok inputBooleanPrevious value of periods_ok
instanceName inputStringInstance name used in the warning message

Outputs

NameTypeDescription
A_buf[…] outputRealAmplitudes at the first nf frequency points (A_buf[1] = mean value of u)
periods_ok outputBoolean= false, if this or a previous FFT was computed from a partially filled buffer