1 function rbsim = rb_simulation(model, reduced_data)
2 % RB_SIMULATION Perform a reduced simulation
4 % Andreas Schmidt, 2015
6 [E,A,B,C,Q,R] = model.assemble(reduced_data);
8 if norm(E - eye(size(E))) < 1e-8
9 PN = care(A,B,C
'*Q*C,R);
11 PN = care(A,B,C'*Q*C,R,0*B,E);
16 rbsim.time_sim = toc(tsim);
18 % Calculate the residual
if necessary:
19 if model.calc_residual
22 [n,nn,nnn] = model.rb_residual_norm(reduced_data, rbsim);
23 tResidual = toc(tResidual);
25 rbsim.time_residual = tResidual;
29 rbsim.nnresidual = nnn;
32 % If the error estimator is enabled, calculate the stuff:
33 if model.enable_error_estimator
34 if isempty(reduced_data.gamma_function)
35 warning('Cannot perform error estimation as no suitable gamma function was specified')
39 if ~strcmp(reduced_data.gamma_mode, model.gamma_mode)
40 warning('rbmatlab:are:gamma_mode_changed', 'The gamma mode in the
ReducedData class is different from the gamma mode in the
Model class!');
44 gamma = reduced_data.gamma_function(model, reduced_data, rbsim);
48 rbsim.time_gamma = tGamma;
50 normBRinvBt = 1;%norm(full(B))^2*norm(inv(R));
51 L = 2*reduced_data.estim.normE^2*normBRinvBt;
54 rbsim.validity_crit = 4*gamma^2*rbsim.residual*L;
55 rbsim.valid = rbsim.validity_crit <= 1;
57 rbsim.error_estimate = 1/2/gamma/L*(1 - sqrt( 1 - rbsim.validity_crit ));
58 rbsim.stab_crit = rbsim.error_estimate*2*gamma*normBRinvBt*reduced_data.estim.normE/reduced_data.estim.normEinv;
59 rbsim.stable = rbsim.stab_crit < 1;
61 rbsim.time_errorestim = toc(testim);
MODEL Abstract model class.
PN
The reduced solution NxN matrix.
Implementation of the parametric algebraic Riccati equation.