rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
demo_dare.m
1 function demo_dare
2 
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.')
9 display(' ')
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')
14 display(' ')
15 display('We begin by setting up the model. Type dbcont to continue')
16 keyboard
17 n = 20
18 model = dare_advection_diffusion(n)
19 model_data = gen_model_data(model)
20 
21 display('')
22 display('The parameters for this model are')
23 model.mu_names
24 model.set_mu([1 3 5]);
25 display('and the values')
26 model.get_mu()
27 display('Type dbcont to continue')
28 
29 keyboard
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');
35 
36 keyboard
37 reference = @(t) square(0.5*t)
38 [t,y,u,r,x] = model.simulate(model_data, 10, reference, dsim);
39 f = figure(1);clf;
40 plot(t, reference(t), 'LineStyle', '--', 'LineWidth', 1.2, 'DisplayName', 'Reference')
41 hold on;
42 plot(t, y, 'LineWidth', 1.2, 'DisplayName', 'Controlled output');
43 legend('Reference', 'Controlled output')
44 grid;
45 display('We now calculate the reduced basis for this problem')
46 display('Type dbcont to continue')
47 
48 keyboard
49 detailed_data = filecache_function(@gen_detailed_data,model,model_data)
50 
51 display('We now perform the same simulation as before, but with the reduced basis for N=1,2,3')
52 f = figure(2);clf;
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]);
57 
58 for i = 1:3
59  sub_detailed_data = detailed_data.extract_subbasis(i);
60  reduced_data = gen_reduced_data(model, sub_detailed_data);
61 
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)]);
66 end
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.
Definition: Kernel.m:1