rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
riccati_rb_simulation.m
Go to the documentation of this file.
1 function sim_data = riccati_rb_simulation(model, reduced_data)
2 %sim_data = riccati_rb_simulation(model, reduced_data)
3 % This function performs a reduced basis simulation. The solution to the
4 % reduced ARE is calculated by calling the function "care".
5 %
6 % The resulting structure sim_data contains the following fields:
7 % PN ...................... The reduced solution (N x N dimensional)
8 % time.solve .............. Time for solving the reduced equation
9 % time.estim .............. Time for the estimation procedure
10 % time.residual ........... Time for the residual calculation
11 % time.total .............. Total time for the whole rb simulation
12 % P_residual .............. Frobenius norm of the residual
13 % P_residual_normalized ... Frobenius norm of the residual, normalized
14 %
15 % Additionally, if model.RB_enable_estimator is true, the structure
16 % estim is added to the structure, containing the following fields:
17 % valid ................... 1/0 stating if the validity bound is valid
18 % validity_bound .......... Value of the validity bound
19 % bound ................... The error bound
20 % normPN .................. Norm of the reduced solution matrix W PN W'
21 % bound_relative .......... The relative error bound Delta_P(mu)/|| P ||
22 %
23 % Andreas Schmidt, 2015
24 sim_data = {};
25 
26 % Assemble the reduced matrices
27 [E,A,B,C] = riccati_assemble_system_matrices(model, reduced_data);
28 
29 time = {};
30 if norm(eye(size(A,1))-E) < 10e-6
31  t = tic;
32  sim_data.PN = care(A,B,C'*C);
33  time.solve = toc(t);
34 else
35  try
36  R = eye(size(B,2));
37  maxnm = 100;
38  maxadi = 200;
39 
40  t = tic;
41  sim_data.PN = real(care(full(A),full(B),full(C'*C),R,full(B*0),full(E)));
42  time.solve = toc(t);
43 
44  catch e
45  warning('Equation not solveable');
46  display(e)
47  sim_data.PN = zeros(size(A,1));
48  sim_data.P_residual = -1;
49  return
50  end
51 end
52 
53 t = tic;
54 [r,rn] = riccati_residual_norm(model, reduced_data, sim_data);
55 sim_data.P_residual = r;
56 sim_data.P_residual_normalized = rn;
57 time.residual = toc(t);
58 
59 % Perform the estimation process
60 time.estim = 0;
61 if model.RB_enable_estimator == 1
62  t = tic;
63 
64  gamma = riccati_rb_gamma(model, reduced_data, sim_data);
65  sim_data.estim.gamma = gamma;
66 
67  [validity_bound, valid] = riccati_validity_bound(model, ...
68  reduced_data, sim_data);
69  sim_data.estim.validity_bound = validity_bound;
70  sim_data.estim.valid = valid;
71 
72  % Calculate the norm:
73  % Assemble the values for ||E||^2 and ||B||^2
74  model.decomp_mode = 2;
75  Ecoeff = model.E(model, reduced_data);
76  if length(Ecoeff) > 1
77  error('Q_E > 1 currently not implemented');
78  end
79  normE2 = (reduced_data.estim.normE*Ecoeff(1))^2;
80 
81  Bcoeff = model.B(model, reduced_data);
82  if reduced_data.estim.normBBT_use2norm
83  normBBT = (reduced_data.estim.normBBT*Bcoeff(1))^2;
84  else
85  normBBT = 0;
86  for i = 1:length(Bcoeff)
87  for j = 1:length(Bcoeff)
88  for k = 1:length(Bcoeff)
89  for l = 1:length(Bcoeff)
90  normBBT = normBBT + Bcoeff(i)*Bcoeff(j)*Bcoeff(k)*Bcoeff(l)*reduced_data.estim.normBBT{i,j,k,l};
91  end
92  end
93  end
94  end
95  end
96 
97  epsilon = sim_data.P_residual;
98  sim_data.estim.bound = gamma*epsilon/(1-4*gamma^2*epsilon*normE2*normBBT);
99  sim_data.estim.bound2 = 2*gamma*epsilon;
100  sim_data.estim.normPN = sqrt( trace(sim_data.PN'*sim_data.PN) );
101  sim_data.estim.bound_relative = sim_data.estim.bound/sim_data.estim.normPN;
102  sim_data.estim.bound_relative2 = 2*gamma*epsilon/sim_data.estim.normPN;
103  time.estim = toc(t);
104 end
105 time.total = time.estim + time.solve + time.residual;
106 
107 sim_data.time = time;
108 end
function sim_data = riccati_rb_simulation(model, reduced_data)
sim_data = riccati_rb_simulation(model, reduced_data) This function performs a reduced basis simulati...
Implementation of the parametric algebraic Riccati equation.