3 display(
'Demo for the application of the RB-DARE algorithm')
4 display('-------------------------------------------------')
5 display('The model under consideration is a two-dimensional advection-diffusion')
6 display('equation. The input is a distributed control on a subdomain \Omega_C')
7 display('and the output is the average temperature over the whole domain.')
8 display('The control objective is to track a desired output trajectory.')
10 display('This is realized by using the LQRI technique, i.e. by adding an ')
11 display('additional state that integrates the difference between the output')
12 display('and the desired trajectory. In the cost functional, this "state" is')
13 display('penalized, resulting in a tracking of the output trajectory')
15 display('We begin by setting up the model. Type dbcont to continue')
19 model_data = gen_model_data(model)
22 display('The parameters for this model are')
24 model.set_mu([1 3 5]);
25 display('and the values')
27 display('Type dbcont to continue')
30 display('We now perorm a state-space simulation of the model. For that purpose, we first')
31 display('calculate the full solution of the corresponding
DARE:')
32 dsim = detailed_simulation(model, model_data)
33 display('We now define a desired output trajectory and run the simulation')
34 display('Type dbcont to continue');
37 reference = @(t) square(0.5*t)
38 [t,y,u,r,x] = model.simulate(model_data, 10, reference, dsim);
40 plot(t, reference(t), 'LineStyle', '--', 'LineWidth', 1.2, 'DisplayName', 'Reference')
42 plot(t, y, 'LineWidth', 1.2, 'DisplayName', 'Controlled output');
43 legend('Reference', 'Controlled output')
45 display('We now calculate the reduced basis for this problem')
46 display('Type dbcont to continue')
51 display('We now perform the same simulation as before, but with the reduced basis for N=1,2,3')
53 plot(t, reference(t), 'LineStyle', '--', 'LineWidth', 1.2);
54 hold on;legend('-DynamicLegend')
55 plot(t, y, 'LineWidth', 2);
56 model.set_mu([2 8 10]);
59 sub_detailed_data = detailed_data.extract_subbasis(i);
60 reduced_data = gen_reduced_data(model, sub_detailed_data);
62 rbsim = rb_simulation(model, reduced_data);
63 rbrec = rb_reconstruction(model, sub_detailed_data, rbsim);
64 [t,y,u,r,x] = model.simulate(model_data, 10, reference, rbrec);
65 plot(t,y,'DisplayName',['N=',num2str(i)]);
67 legend('Reference', 'Full controller', 'N=1', 'N=2', 'N=3');
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.
Implicit Euler discretization of a finite-difference convection-diffusion model.
Implementation of the parametric discrete-time algebraic Riccati equation.