-
Notifications
You must be signed in to change notification settings - Fork 0
/
redovisning.asv
79 lines (65 loc) · 2.22 KB
/
redovisning.asv
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
%clear all, close all, clc
% område
format long
n = 100; % Upplösningen på området
from = -1;
to = 1;
r_scale = linspace(from, to, n); % Områdets omfattning
r_scale2 = linspace(from, to, floor(n/2)); % Halva upplösningen
[X, Y] = meshgrid(r_scale); % Skapar nxn X- och Y-matriser (så mycket snyggare än den gamla)
[X2, Y2] = meshgrid(r_scale2);
area = {'x.^2+y.^2<0.3'};
temp = {'5*x*(x>0.25)', '-2*(x<0.25)', '5*(y>0.25)', '-4*(y<0.25)'};
F = str2bond(area, X, Y);
B = str2rand(temp, X, Y);
F2 = str2bond(area, X2, Y2);
B2 = str2rand(temp, X2, Y2);
Q = @(x, y)200*exp(-(x-y).^2)+2000*exp(-1000*(x).^2); % Värmetillskott
q = bsxfun(Q, r_scale, r_scale');
q2 = bsxfun(Q, r_scale2, r_scale2');
% tidssteg
dt = 0.01;
drop = 1;
% fysik
k = 0.4;
dens = 1; % densitet
cap = 2.5; % Värmekapacitet
% Lös steady-state för att hitta utgångsläget
solution = solve_temp_Q(F, B, q, r_scale, k);
solution2 = solve_temp_Q(F2, B2, q2, r_scale2, k);
% lös
timed = solve_time_change(F, B, 0, solution, r_scale, dt, drop, k, dens, cap);
timed2 = solve_time_change(F2, B2, 0, solution2, r_scale2, dt, drop, k, dens, cap);
%
t_scale = 0:dt:timed+dt;
t_scale2 = 0:dt:timed2+dt;
conv = solve_time(F, B, 0, solution, r_scale, t_scale, drop, k, dens, cap);
conv2 = solve_time(F2, B2, 0, solution2, r_scale2, t_scale2, drop, k, dens, cap);
% Sätt plottstorlek
figure('units','normalized', 'position',[0.1 0.2 0.7 0.5])
conv_plot = subplot(1,2,1);
conv_plot2 = subplot(1,2,2);
text_ax = axes('position',[0,0,1,1],'visible','off');
timer = text(0.5, 0.3, num2str(0));
set(timer,'FontSize',22,'fontweight','bold');
view(text_ax, 2);
view(conv_plot, 3);
view(conv_plot2, 3);
for i=1:max([size(conv, 3), size(conv2, 3)])
if i <= size(conv, 3)
S = conv(:,:,i);
cla(conv_plot)
surf(conv_plot, r_scale, r_scale, S, 'LineStyle', 'none')
axis(conv_plot, [-1 1 -1 1 -6 30])
end
if i <= size(conv2, 3)
S2 = conv2(:,:,i);
cla(conv_plot2)
surf(conv_plot2, r_scale2, r_scale2, S2, 'LineStyle', 'none')
axis(conv_plot2, [-1 1 -1 1 -6 30])
end
set(timer,'String', num2str(i*dt,'%3.2f'));
pause(5*dt*drop)
end
s1 = solve_time_change(F, B, 0, solution, r_scale, dt, drop, k, dens, cap);
s2 =