Contents
PRBT for standard systems
This demo script contains the application of the positive-real balanced truncation method (ml_ct_ss_prbt) on a test positive-real standard system of the form
x'(t) = Ax(t) + Bu(t), y(t) = Cx(t) + Du(t).
After loading the demo data, the optional parameters are assigned here explicitly and the ml_ct_ss_prbt function is called with its different input interfaces. The ss object version is only called if the System Control Toolbox (Matlab) or the Control Package (Octave) is installed/loaded.
To show the performance of the model reduction method, the sigma error of the inverse full-order and reduced-order model is plotted together with the computed error bound. In case the System Control Toolbox is installed, also a bode magnitude plot of the inverse error system is shown.
% % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Affero General Public License as published % by the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU Affero General Public License for more details. % % You should have received a copy of the GNU Affero General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. % % Copyright (C) 2006-2018 Peter Benner, Steffen W. R. Werner %
Initialization
For demonstration, a random positive-real standard system example was generated by the script morlab_data_std_pr.m and saved in morlab_data_std_pr.mat. The number of stable and unstable eigenvalues as well as the complete size of the system is saved in the datainfo structure.
if exist('OCTAVE_VERSION', 'builtin') orig_warn = warning('off', 'Octave:data-file-in-path'); load morlab_data_std_pr.mat; warning(orig_warn); else load morlab_data_std_pr.mat; end % Get information about installed/loaded toolboxes. hasControlPkg = size(license('inuse', 'control'), 2); hasControlTbx = license('test', 'control_toolbox');
Construction of the standard system structure
To test the different input-output formats, the struct and state-space object shapes of the standard system are formulated here.
sys_struct = struct('A', A, 'B', B, 'C', C, 'D', D); if hasControlPkg || hasControlTbx sys_ss = ss(A, B, C, D); end
Set of optional parameters
The default values are mainly taken here, which can be modified. Alternative values depending on the system are commented out. Usually for using default values the corresponding parameters are not set or empty. Also, the function call "opts = ml_morlabopts('ml_ct_ss_prbt')" generates an empty option struct of the following form.
% Option struct for Lyapunov solver inside the Riccati solver. lyapopts = struct(... 'AbsTol' , 0, ... 'CompTol', 1.0e-02 * sqrt(datainfo.n * eps), ... 'Info' , 0, ... % Info = 1 'MaxIter', 100, ... 'RelTol' , 1.0e+01 * datainfo.n * eps); % Option struct for Riccati equation solver. pcareopts = struct(... 'AbsTol' , 0, ... 'CompTol' , 1.0e-02 * sqrt(datainfo.n * eps), ... 'Info' , 0, ... % Info = 1 'lyapopts', lyapopts, ... 'MaxIter' , 100, ... 'RelTol' , 1.0e+02 * datainfo.n * eps); % Option struct for the complete function. opts = struct(... 'Epsilon' , 1.0e-03, ... 'Method' , 'sr', ... % Method = 'bfsr' 'Order' , 10, ... 'OrderComputation', 'tolerance', ... % OrderComputation = 'order' 'pcareopts' , pcareopts, ... 'Tolerance' , 1.0e-02);
Application of the function
Here the application of the ml_ct_ss_prbt function is shown for different interfaces and input-data. The default calls are commented out.
% Application with single matrices. % [Ar, Br, Cr, Dr, info] = ml_ct_ss_prbt(A, B, C, D); [Ar, Br, Cr, Dr, info] = ml_ct_ss_prbt(A, B, C, D, opts); % Application with structure. % [rom_struct, info_struct] = ml_ct_ss_prbt(sys_struct); [rom_struct, info_struct] = ml_ct_ss_prbt(sys_struct, opts); % Application with state-space object. if hasControlPkg || hasControlTbx % [rom_ss, info_ss] = ml_ct_ss_prbt(sys_ss); [rom_ss, info_ss] = ml_ct_ss_prbt(sys_ss, opts); end
Report
As visualization, a sigmaplot of the inverse error system is made for the standard system structures and a bode magnitude plot for the state- space objects.
% Sigmaplot of the inverse error system. R = info.M + info.M'; sys_inv_struct = struct(... 'A', A - B * (R \ C), ... 'B', B / R, ... 'C', -R \ C, ... 'D', inv(R)); rom_inv_struct = struct(... 'A', Ar - Br * (R \ Cr), ... 'B', Br / R, ... 'C', -R \ Cr, ... 'D', inv(R)); figure; ml_sigmaplot(sys_inv_struct, rom_inv_struct, -4, 4, 100, ... info.InvAbsErrBound, 'b.'); legend('Error bound', 'Sigma error of the inverse system'); title({'PRBT (sigmaplot, inverse error system)'; ... ['Full order = ' int2str(size(A, 1)) '; ' ... 'Reduced-order = ' int2str(size(Ar, 1))]}); if hasControlTbx % Bode magnitude plot of the inverse error system. sys_inv_ss = ss(... sys_inv_struct.A, ... sys_inv_struct.B, ... sys_inv_struct.C, ... sys_inv_struct.D); rom_inv_ss = ss(... rom_inv_struct.A, ... rom_inv_struct.B, ... rom_inv_struct.C, ... rom_inv_struct.D); bodeopts = bodeoptions('cstprefs'); bodeopts.MagUnits = 'abs'; figure; bodemag(sys_inv_ss - rom_inv_ss, bodeopts); title({'PRBT (Bode magnitude plot, inverse error system)'; ... ['Full order = ' int2str(size(A, 1)) '; ' ... 'Reduced-order = ' int2str(size(Ar, 1))]}); end


See Also