Application Center - Maplesoft

App Preview:

Frequency Domain System Identification

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

 Frequency Domain System Identification 

? Maplesoft, a division of Waterloo Maple Inc., 2008 

System identification deals with the problem of identifying a model describing some physical system by measuring the response of the system. This example illustrates a problem where the structure of the model is known, and parameters of the model are identified. This is done by first designing the input signal, which is applied to the system. The measured output is converted to the frequency domain and the parameters are estimated in this domain. 

 

System Definition 

-   Parameters 

-   System Model 

 

Signal Generation and Simulation 

 

Discrete Fourier Transform (DFT) 

 

Parameter Estimation 

 

Drawing-Canvas 

A spring-mass-damper system consists of a mass connected by a spring and a damper to a solid frame. 

System Definitions 

 

Name/Description 

Value 

Unit 

Input Variables 

input force on the mass u(t) 

 

Unit('N') 

Output Variables 

output position of the mass y(t) 

 

Unit('m') 

 

Model Parameters 

mass of the object m 

Embedded component 

Unit('kg') 

damping coefficient (b) 

Embedded component 

Unit(`/`(`*`('kg'), `*`('s'))) 

spring constant k 

Embedded component 

Unit(`/`(`*`('N'), `*`('m'))) 

 

Simulation Parameters 

Simulation time 

Embedded component 

Unit('s') 

Sampling time 

Embedded component 

Unit('s') 

Noise standard deviation 

Embedded component 

Unit('N'), Unit('m') 

Parameter Set 

`:=`(model_params, {M = get_parameter(_text_m), b = get_parameter(_text_b), k = get_parameter(_text_k)})
`:=`(model_params, {M = get_parameter(_text_m), b = get_parameter(_text_b), k = get_parameter(_text_k)})
 

{M = 5, b = 2, k = 3} (1.1.1)

 

 

Model Definition 

`:=`(model_de, `+`(`*`(M, `*`(diff(y(t), t, t))), `*`(b, `*`(diff(y(t), t))), `*`(k, `*`(y(t)))) = u(t)) 

`+`(`*`(M, `*`(diff(diff(y(t), t), t))), `*`(b, `*`(diff(y(t), t))), `*`(k, `*`(y(t)))) = u(t) (1.2.1)

 

Initial Conditions 

`:=`(model_ic, {y(0) = 0, (D(y))(0) = 0}) 

{y(0) = 0, (D(y))(0) = 0} (1.3.1)

 

 

Signal Generation and Simulation 

To excite the system, we apply a chirp signal that sweeps the frequency spectrum from 0.01 Hz to 1 Hz over 50 seconds. 

`:=`(chirp_signal, sin(`+`(`*`(2, `*`(Pi, `*`(`+`(`*`(`*`(.99, `/`(1, 50)), `*`(t)), 0.1e-1), `*`(t))))))) 

sin(`+`(`*`(2, `*`(Pi, `*`(`+`(`*`(0.1980000000e-1, `*`(t)), 0.1e-1), `*`(t)))))) (2.1)

 

 

 

We want to simulate the response of the system to a chirp signal. First we substitute the model parameters and a chirp signal into the differential equation and simulate the system. 

Once the system is simulated, noise is added to reflect a realistic application.  

Button# System Response to Chirp 

 

ChirpResponse 

Plot_2d  

 

 

Discrete Fourier Transform of the Signals 

Button# DFT of Input & Output Signal 

Calculate the Discrete Fourier Transform of the input and the output signals. 

SignalVSFrequency 

Plot_2d  

 

 

Minimum frequency: Embedded component 

Maximum frequency:Embedded component 

Minimum Index: 

`:=`(min_idx, round(`*`(T_scale, `*`(parse(DocumentTools:-GetProperty('text_minF', 'value'))))))
`:=`(min_idx, round(`*`(T_scale, `*`(parse(DocumentTools:-GetProperty('text_minF', 'value'))))))
 

1 (3.1)

 

Maximum Index: 

`:=`(max_idx, round(`*`(T_scale, `*`(parse(DocumentTools:-GetProperty('text_maxF', 'value'))))))
`:=`(max_idx, round(`*`(T_scale, `*`(parse(DocumentTools:-GetProperty('text_maxF', 'value'))))))
 

50 (3.2)

 

Minimum Frequency: 

`:=`(min_freq, evalf(`/`(`*`(min_idx), `*`(T_scale)))) 

0.2000000000e-1 (3.3)

 

Maximum Frequency: 

`:=`(max_freq, evalf(`/`(`*`(max_idx), `*`(T_scale)))) 

1. (3.4)

 

The region of interest of the frequency spectrum. 

Button# Region of Interest 

 

plt_mag 

Plot_2d  

 

Estimation of the Model Parameters 

Given the differential equation: 

model_de 

`+`(`*`(M, `*`(diff(diff(y(t), t), t))), `*`(b, `*`(diff(y(t), t))), `*`(k, `*`(y(t)))) = u(t) (4.1)

 

the corresponding transfer function is given as: 

`:=`(model_tf, DETransferFn({model_de}, u(t), y(t), t, s))
`:=`(model_tf, DETransferFn({model_de}, u(t), y(t), t, s))
 

`/`(1, `*`(`+`(`*`(M, `*`(`^`(s, 2))), `*`(b, `*`(s)), k))) (4.2)

 

 

The transfer function (in the s domain) is converted to a Fourier transform by the following transformation of s to omega 

proc (s) options operator, arrow; `*`(`*`(2, `*`(I)), `*`(Pi, `*`(omega))) end proc 

 

This results in the following expression: 

`:=`(model_freq, simplify((unapply(simplify(model_tf), s))(`*`(`*`(2, I), `*`(Pi, `*`(omega))))))
`:=`(model_freq, simplify((unapply(simplify(model_tf), s))(`*`(`*`(2, I), `*`(Pi, `*`(omega))))))
 

`+`(`-`(`/`(1, `*`(`+`(`*`(4, `*`(M, `*`(`^`(Pi, 2), `*`(`^`(omega, 2))))), `-`(`*`(`+`(`*`(2, `*`(I))), `*`(b, `*`(Pi, `*`(omega))))), `-`(k)))))) (4.3)

 

This expression can be split into the real part 

`:=`(reTFModel, unapply(evalc(Re(model_freq)), omega)) 

proc (omega) options operator, arrow; `+`(`-`(`/`(`*`(`+`(`*`(4, `*`(M, `*`(`^`(Pi, 2), `*`(`^`(omega, 2))))), `-`(k))), `*`(`+`(`*`(`^`(`+`(`*`(4, `*`(M, `*`(`^`(Pi, 2), `*`(`^`(omega, 2))))), `-`(k)... (4.4)

 

and the imaginary part 

`:=`(imTFModel, unapply(evalc(Im(model_freq)), omega)) 

proc (omega) options operator, arrow; `+`(`-`(`/`(`*`(2, `*`(b, `*`(Pi, `*`(omega)))), `*`(`+`(`*`(`^`(`+`(`*`(4, `*`(M, `*`(`^`(Pi, 2), `*`(`^`(omega, 2))))), `-`(k)), 2)), `*`(4, `*`(`^`(b, 2), `*`(... (4.5)

 

 

Set up the objective function and perform the optimization to solve for the unknown parameters. 

 

The following solution has been achieved: 

Button# Optimization 

opt 

[0.482961949773475854e-1, [M = 4.92085588230966664, b = 1.90372543078507306, k = 2.98195317347659828]]
[0.482961949773475854e-1, [M = 4.92085588230966664, b = 1.90372543078507306, k = 2.98195317347659828]]
[0.482961949773475854e-1, [M = 4.92085588230966664, b = 1.90372543078507306, k = 2.98195317347659828]]
[0.482961949773475854e-1, [M = 4.92085588230966664, b = 1.90372543078507306, k = 2.98195317347659828]]
(4.6)

 

The error for the approximation is given as: 

opt[1] 

0.482961949773475854e-1 (4.7)

 

 

The estimated parameter set is given as: 

opt[2] 

[M = 4.92085588230966664, b = 1.90372543078507306, k = 2.98195317347659828]
[M = 4.92085588230966664, b = 1.90372543078507306, k = 2.98195317347659828]
[M = 4.92085588230966664, b = 1.90372543078507306, k = 2.98195317347659828]
(4.8)

 

 

The difference between the estimated parameters and the original parameters is given by: 

[Deltab = `+`(eval(b, opt[2]), `-`(eval(b, model_params))), Deltak = `+`(eval(k, opt[2]), `-`(eval(k, model_params))), DeltaM = `+`(eval(M, opt[2]), `-`(eval(M, model_params)))]
[Deltab = `+`(eval(b, opt[2]), `-`(eval(b, model_params))), Deltak = `+`(eval(k, opt[2]), `-`(eval(k, model_params))), DeltaM = `+`(eval(M, opt[2]), `-`(eval(M, model_params)))]
[Deltab = `+`(eval(b, opt[2]), `-`(eval(b, model_params))), Deltak = `+`(eval(k, opt[2]), `-`(eval(k, model_params))), DeltaM = `+`(eval(M, opt[2]), `-`(eval(M, model_params)))]
[Deltab = `+`(eval(b, opt[2]), `-`(eval(b, model_params))), Deltak = `+`(eval(k, opt[2]), `-`(eval(k, model_params))), DeltaM = `+`(eval(M, opt[2]), `-`(eval(M, model_params)))]
 

[Deltab = -0.96274569e-1, Deltak = -0.18046827e-1, DeltaM = -0.79144118e-1]
[Deltab = -0.96274569e-1, Deltak = -0.18046827e-1, DeltaM = -0.79144118e-1]
(4.9)

 

 

Compare the frequency response of the measured system and the original model: 

 

Button# Model Comparison with origin 

 

CompareModel 

Plot_2d