-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoseenTest.m
95 lines (73 loc) · 2.47 KB
/
oseenTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
clear;
clc;
close all;
logName = [datestr(now,'mmddyyyy') '.cavtst'];
lf = Msgcl(99,logName);
lf.pmsg(lf.ALL,'************************************************************************');
lf.pmsg(lf.ALL,'* Testing IRKA model reduction for the linearized Boussinesq System');
lf.pmsg(lf.ALL,'* over a 1m x 1m 2D cavity with temperature induced flow.');
dataLoc = 'data50_2';
n=50;
%% Build the matrices for the linear model
lf.pmsg(lf.ERR,'Creating the linearized model for u, T, and p');
create_uTp_matrices;
%% Solve the full linear model
Z0 = zeros(a,1);
%Z0(u_nodes) = u_adv(int_nodes); Z0(v_nodes) = v_adv(int_nodes);
%Z0(T_nodes) = T_eq(T_int_nodes);
tspan = [0,10];
lf.pmsg(lf.ERR,'Solving the full system.')
[ t, Z, Y ] = daesol2( A, B, C, D, E, tspan, @u_fcn,Z0);
lf.pmsg(lf.ERR,'Plotting control.')
figure('name','Control Function');
plot(t,u_fcn(t),'r');
lf.pmsg(lf.ERR,'Plotting velocity vector field movie.');
figure('name','Velocity Vector Field');
u_res = zeros((n+1)^2,1);v_res = zeros((n+1)^2,1);
for k=1:size(Z,2)
u_res(int_nodes) = Z(u_nodes,k);
v_res(int_nodes) = Z(v_nodes,k);
quiver(x(:,1),x(:,2),u_res,v_res);
F(k) = getframe;
end;
%movie(F,1);
%% Create reduced order model
lf.pmsg(lf.ERR,'Creating reduced order model.')
% Set the test run parameters
loglevel = 10;
tol = [1e-4, 1e-8];
distr_type = 1;
distr = [-1,2,0,0];
testnum = 3;
r = 15;
[Ar,Br,Cr,Dr,Er,Vr,Wr,siter] = irka_dae2(A,B,C,D,E,nv,r,loglevel,tol,distr_type,distr);
lf.pmsg(lf.WARN,'Printing Bode plot of full system versus reduced model')
figure('name', 'Bode Plots', 'NumberTitle', 'off');
bode_plt(A,B,C,D,E,-4,10,100);
hold on
bode_plt(Ar,Br,Cr,Dr,Er,-4,10,100, '-ro');
hold off
legend('G','Reduced G')
lf.pmsg(lf.ALL,'* END of test. Exiting.');
lf.pmsg(lf.ALL,'************************************************************************');
%% Solve the reduced model
xr0 = zeros(r,1);
[ t, xr, yr ] = daesol2( Ar, Br, Cr, Dr, Er, tspan, @u_fcn,xr0);
xr2f = Vr*xr;
avh = figure('name', 'Average Vorticity');
plot(t,Y,'r',t,yr,'ko');
legend('Full Model','Reduced Model','Location','SE');
figure('name','Velocity Vector Field (Reduced)');
u_res = zeros((n+1)^2,1);v_res = zeros((n+1)^2,1);
for k=1:size(Z,2)
u_res(int_nodes) = xr2f(u_nodes,k);
v_res(int_nodes) = xr2f(v_nodes,k);
quiver(x(:,1),x(:,2),u_res,v_res);
Fr(k) = getframe;
end;
figure('name','State Error Plot');
relerr = zeros(1,size(xr2f,2));
for k = 1:size(xr2f,2)
relerr(k) = norm(xr2f(:,k)-Z(1:nv,k))/norm(Z(1:nv,k));
end
plot(t,relerr)