Debian Codegraph @

packages/rol/example/PDE-OPT/thermal-fluids/plotresults.m

raw
1 adj = load('cell_to_node_quad.txt') + 1; %% load node adjacency table, increment by 1 for 1-based indexing
2
3 nodes = load('nodes.txt'); %% load node coordinates
4
5 %% UNCONTROLLED.
6 data_obj = importdata('state_uncontrolled.txt', ' ', 2); %% we need to skip the first two lines
7 state = data_obj.data;
8
9 N = 4*length(nodes);
10 % Extract x-velocity
11 Ux = state(1:4:N);
12 % Extract y-velocity
13 Uy = state(2:4:N);
14 % Extract pressure
15 P = state(3:4:N);
16 % Extract temperature
17 T = state(4:4:N);
18
19 figure,
20 trisurf(adj, nodes(:,1), nodes(:,2), Ux);
21 shading interp;
22 view(0,90)
23 title('Uncontrolled X-Velocity')
24 axis equal
25 axis tight
26
27 figure,
28 trisurf(adj, nodes(:,1), nodes(:,2), Uy);
29 shading interp;
30 view(0,90)
31 title('Uncontrolled Y-Velocity')
32 axis equal
33 axis tight
34
35 figure,
36 trisurf(adj, nodes(:,1), nodes(:,2), sqrt(Ux.^2 + Uy.^2));
37 shading interp;
38 view(0,90)
39 title('Uncontrolled Velocity Magnitude')
40 axis equal
41 axis tight
42
43 figure,
44 trisurf(adj, nodes(:,1), nodes(:,2), P);
45 shading interp;
46 view(0,90)
47 title('Uncontrolled Pressure')
48 axis equal
49 axis tight
50
51 figure,
52 trisurf(adj, nodes(:,1), nodes(:,2), T);
53 shading interp;
54 view(0,90)
55 title('Uncontrolled Temperature')
56 axis equal
57 axis tight
58
59 figure,
60 quiver(nodes(:,1), nodes(:,2), Ux, Uy);
61 title('Uncontrolled Velocity')
62 axis equal
63 axis tight
64
65 %% CONTROLLED.
66 data_obj = importdata('state.txt', ' ', 2); %% we need to skip the first two lines
67 state = data_obj.data;
68
69 N = 4*length(nodes);
70 % Extract x-velocity
71 Ux = state(1:4:N);
72 % Extract y-velocity
73 Uy = state(2:4:N);
74 % Extract pressure
75 P = state(3:4:N);
76 % Extract temperature
77 T = state(4:4:N);
78
79 figure,
80 trisurf(adj, nodes(:,1), nodes(:,2), Ux);
81 shading interp;
82 view(0,90)
83 title('X-Velocity')
84 axis equal
85 axis tight
86
87 figure,
88 trisurf(adj, nodes(:,1), nodes(:,2), Uy);
89 shading interp;
90 view(0,90)
91 title('Y-Velocity')
92 axis equal
93 axis tight
94
95 figure,
96 trisurf(adj, nodes(:,1), nodes(:,2), sqrt(Ux.^2 + Uy.^2));
97 shading interp;
98 view(0,90)
99 title('Velocity Magnitude')
100 axis equal
101 axis tight
102
103 figure,
104 trisurf(adj, nodes(:,1), nodes(:,2), P);
105 shading interp;
106 view(0,90)
107 title('Pressure')
108 axis equal
109 axis tight
110
111 figure,
112 trisurf(adj, nodes(:,1), nodes(:,2), T);
113 shading interp;
114 view(0,90)
115 title('Temperature')
116 axis equal
117 axis tight
118
119 figure,
120 quiver(nodes(:,1), nodes(:,2), Ux, Uy);
121 title('Velocity')
122 axis equal
123 axis tight
124
125 data_obj = importdata('control.txt', ' ', 2); %% we need to skip the first two lines
126 control = data_obj.data;
127
128 % Extract x-velocity
129 Zx = control(1:4:N);
130 % Extract y-velocity
131 Zy = control(2:4:N);
132 % Extract pressure
133 P = control(3:4:N);
134 % Extract Temperature
135 T = control(4:4:N);
136
137 Xmin = min(nodes(:,1));
138 Xmax = max(nodes(:,1));
139
140 figure,
141 idx = find(nodes(:,2) == 0.0);
142 plot(nodes(idx,1), T(idx));
143 title('Bottom Controls')
144 xlim([Xmin,Xmax]);
145
146 figure,
147 idx = find(nodes(:,2) == 1.0);
148 plot(nodes(idx,1), T(idx));
149 title('Top Controls')
150 xlim([Xmin,Xmax]);