-
Notifications
You must be signed in to change notification settings - Fork 57
/
btv_test04.m
56 lines (47 loc) · 1.34 KB
/
btv_test04.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
function btv_test04 ( )
%*****************************************************************************80
%
%% BTV_TEST04 tests BURGERS_TIME_VISCOUS with the shock initial condition.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 23 April 2012
%
% Author:
%
% John Burkardt
%
fprintf ( 1, '\n' );
fprintf ( 1, 'BTV_TEST04\n' );
fprintf ( 1, ' Test BURGERS_TIME_VISCOUS with the shock initial condition.\n' );
fprintf ( 1, ' Use periodic boundaries.\n' );
nx = 81;
nt = 300;
t_max = 3.0;
nu = 0.01;
bc = 4;
fprintf ( 1, '\n' );
fprintf ( 1, ' Initial condition: shock\n' );
fprintf ( 1, ' Number of space nodes = %d\n', nx );
fprintf ( 1, ' Number of time steps = %d\n', nt );
fprintf ( 1, ' Final time T_MAX = %g\n', t_max );
fprintf ( 1, ' Viscosity = %g\n', nu );
fprintf ( 1, ' Boundary condition = %d\n', bc );
U = burgers_time_viscous ( @ic_shock, nx, nt, t_max, nu, bc );
x = linspace ( -1.0, +1.0, nx );
figure ( 4 )
plot ( x, U(1:50:(nt+1),:), 'Linewidth', 3 )
grid on
xlabel ( '<-- X -->' )
ylabel ( '<-- U(X,T) -->' )
title ( 'Burgers equation solutions over time, initial condition shock' )
filename = 'btv_test04.png';
print ( '-dpng', filename )
fprintf ( 1, '\n' );
fprintf ( 1, ' Saved plot as "%s"\n', filename );
return
end