-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfe2dx_n_fast_test.m
192 lines (176 loc) · 3.77 KB
/
fe2dx_n_fast_test.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
function fe2dx_n_fast_test ( )
%*****************************************************************************80
%
%% FE2DX_N_FAST_TEST tests the FE2DX_N_FAST code.
%
% Discussion:
%
% This function sets all parameter values and initial condition information
% necessary to execute the "fast" version of the fe2dx_n algorithm.
%
% Licensing:
%
% Copyright (C) 2014 Marcus R. Garvie.
% See 'mycopyright.txt' for details.
%
% Modified:
%
% 28 April 2014
%
% Author:
%
% Marcus R. Garvie.
%
% Reference:
%
% Marcus R Garvie, John Burkardt, Jeff Morgan,
% Simple Finite Element Methods for Approximating Predator-Prey Dynamics
% in Two Dimensions using MATLAB,
% Submitted to Bulletin of Mathematical Biology, 2014.
%
timestamp ( );
fprintf ( 1, '\n' );
fprintf ( 1, 'FE2DX_N_FAST_TEST:\n' );
fprintf ( 1, ' Test the FE2DX_N_FAST function\n' );
fprintf ( 1, ' which applies Neumann boundary conditions as it\n' );
fprintf ( 1, ' approximates a solution to a predator-prey system.\n' );
%
% Set the parameters.
%
alpha = 0.4;
beta = 2.0;
gamma = 0.6;
delta = 1.0;
%
% Use T=150.0 for normal run.
% Use T=0.50 for a "quick" run that might take 15 minutes of computing.
%
T = 0.50;
delt = 1.0 / 384.0;
t = tic;
fe2dx_n_fast ( alpha, beta, gamma, delta, T, delt, @u0f, @v0f, @guf, @gvf );
t = toc ( t );
fprintf ( 1, ' Execution took %10.2g minutes \n', t / 60.0 );
%
% Terminate.
%
fprintf ( 1, '\n' );
fprintf ( 1, 'FE2DX_N_FAST_TEST:\n' );
fprintf ( 1, ' Normal end of execution.\n' );
fprintf ( 1, '\n' );
timestamp ( );
return
end
function value = u0f ( x, y )
%*****************************************************************************80
%
%% U0F evaluates the initial condition for U.
%
% Licensing:
%
% Copyright (C) 2014 Marcus R. Garvie.
% See 'mycopyright.txt' for details.
%
% Modified:
%
% 26 April 2014
%
% Author:
%
% Marcus R. Garvie.
%
% Parameters:
%
% Input, real X, Y, a location in the region.
%
% Output, real VALUE, the initial condition for U at (X,Y).
%
value = 6.0 / 35.0 - 2.0E-07 * ( x - 0.1 * y - 225.0 ) * ( x - 0.1 * y - 675.0 );
return
return
end
function value = v0f ( x, y )
%*****************************************************************************80
%
%% V0F evaluates the initial condition for V.
%
% Licensing:
%
% Copyright (C) 2014 Marcus R. Garvie.
% See 'mycopyright.txt' for details.
%
% Modified:
%
% 26 April 2014
%
% Author:
%
% Marcus R. Garvie.
%
% Parameters:
%
% Input, real X, Y, a location in the region.
%
% Output, real VALUE, the initial condition for V at (X,Y).
%
value = 116.0 / 245.0 - 3.0E-05 * ( x - 450.0 ) - 1.2E-04 * ( y - 150.0 );
return
end
function value = guf ( x, y, t )
%*****************************************************************************80
%
%% GUF evaluates the Neumann boundary condition for U.
%
% Licensing:
%
% Copyright (C) 2014 Marcus R. Garvie.
% See 'mycopyright.txt' for details.
%
% Modified:
%
% 28 April 2014
%
% Author:
%
% Marcus R. Garvie.
%
% Parameters:
%
% Input, real X, Y, a location on the boundary.
%
% Input, real T, the time.
%
% Output, real VALUE, the prescribed value of dU/dn at (X,Y,T).
%
value = 0.0;
return
end
function value = gvf ( x, y, t )
%*****************************************************************************80
%
%% GVF evaluates the Neumann boundary condition for V.
%
% Licensing:
%
% Copyright (C) 2014 Marcus R. Garvie.
% See 'mycopyright.txt' for details.
%
% Modified:
%
% 28 April 2014
%
% Author:
%
% Marcus R. Garvie.
%
% Parameters:
%
% Input, real X, Y, a location on the boundary.
%
% Input, real T, the time.
%
% Output, real VALUE, the prescribed value of dV/dn at (X,Y,T).
%
value = 0.0;
return
end