rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
buckley_leverett_model.m
1 function model = buckley_leverett_model(params)
2 % function model = buckley_leverett_model(params)
3 %
4 % optional fields of params:
5 % model_size: - 'big' simulations are done on a larger grid with very
6 % small time steps
7 % - 'small' simulations are done on a smaller grid with
8 % bigger time steps
9 % model_type: - 'buckley_leverett' -- A Buckley-Leverett problem
10 %
11  model = nonlin_evol_model_default;
12  model.name = 'buckley_leverett_model';
13  model.rb_problem_type = 'bl';
14  %% data that is definitely used outside of the detailed simulations
15  % model.mu_names = {'diff_m', 'diff_p', 'hill_height'};
16  % model.mu_ranges = {[0,0.5],[0.01,100],[0,0.3]};
17  model.mu_names = {'diff_k0'};
18  model.mu_ranges = {[0.01, 0.5]};
19 
20 
21  %% data that might be of interest outside of the detailed simulations
22  model.T = 0.2;
23  model.nt = 80;
24 
25  %% finite volume settings
26 % model.diffusivity_ptr = @diffusivity_buckley_leverett;
27 % model.diffusivity_derivative_ptr = @diffusivity_buckley_leverett_derivative;
28  model.diffusivity_ptr = @diffusivity_buckley_leverett_simple;
29  model.diffusivity_derivative_ptr = @diffusivity_buckley_leverett_simple_derivative;
30 
31  model.num_conv_flux_ptr = @fv_num_conv_flux_engquist_osher;
32  model.num_diff_flux_ptr = @fv_num_diff_flux_gradient;
33  model.flux_linear = 0;
34  model.name_flux = 'exponential';
35  model.geometry_transformation = 'none';
36 
37  model.newton_solver = 1;
38  model.collect_newton_steps = false;
39  model.newton_steps = 60;
40 
41 
42  model.operators_diff_implicit = @fv_operators_diff_implicit_gradient;
43  model.operators_conv_implicit = @fv_operators_zero;
44  model.operators_neumann_implicit = @fv_operators_zero;
45  model.fv_expl_conv_weight = 1.0;
46  model.fv_impl_diff_weight = 1.0;
47  model.implicit_gradient_operators_algorithm = ...
49 
50  % lxf_lambda = 1.25;
51  % lxf_lambda = fv_search_max_lxf_lambda([],
52 
53 
54  %% define the grid
55  model = unitcube(model);
56  model.xnumintervals = 100;
57  model.ynumintervals = 100;
58 
59  % pointer to function in rbmatlab/datafunc/dirichlet_values
60 % model.dirichlet_values_ptr = @dirichlet_values_uplow;
61 % model.c_dir = 0.2;
62 % model.dir_box_xrange = [-1 2];
63 % model.dir_box_yrange = 0.5 + [1/320 3/320];
64 % model.c_dir_left = 1;
65 % model.c_dir_right = 1;
66 % model.c_dir_up = 0;
67 % model.c_dir_low = 0.5;
68 % model.dir_middle = 0.7;
69  model.dirichlet_values_ptr = @(glob, params) params.c_low * ones(length(glob),1);
70 
71  % model.dirichlet_values_ptr = @dirichlet_values_leftright;
72  model.c_dir_left = 0.0;
73  model.c_dir_right = 0.0;
74  model.dir_middle = 0.5;
75 % model.c_dir = 0.1;
76 
77  % pointer to function in rbmatlab/datafunc/neumann_values
78  %model.neumann_values_ptr = @neumann_values_homogeneous;
79  model.neumann_values_ptr = @neumann_values_zero;
80  model.c_neu = 0.00;
81 
82  % name of function in rbmatlab/datafunc/init_values/
83 % model.init_values_ptr = @init_values_transformed_blobs;
84 % model.init_values_ptr = @init_values_bars;
85  model.init_values_ptr = @init_values_bl;
86  % parameters for data functions
87 
88  model.filecache_velocity_matrixfile_extract = 0;
89 
90  % settings for CRB generation
91  model.CRB_generation_mode = 'param-time-space-grid';
92  model.RB_generation_mode = 'greedy_refined';
93  model.RB_refinement_mode = 'uniform';
94  model.RB_stop_max_refinement_level = 3;
95  model.RB_val_rand_seed = 12345;
96  model.refinement_theta = 0.6;
97  model.Mmax = 250;
98  model.sMmax = {50, 50};
99  model.M = 40;
100  model.Mstrich = 5;
101  model.ei_stop_on_Mmax = 1;
102  % build ei-basis with WHOLE trajectory
103  model.ei_target_error = 'linfty';
104  model.RB_stop_max_val_train_ratio = 1.4;
105 
106  % target accuracy epsilon:
107 
108  % decide, whether estimator or true error is error-indicator for greedy
109  model.RB_error_indicator = 'error'; % true error
110  % RB_error_indicator = 'estimator'; % Delta from rb_simulation
111  % RB_error_indicator = 'ei_estimator_test'; % Delta from rb_simulation testet
112  % against true error
113 
114  model.divclean_mode = false;
115  model.flux_quad_degree = 1;
116 
117 % model.conv_flux_ptr = @conv_flux_brooks_corey;
118 % model.conv_flux_derivative_ptr = @conv_flux_brooks_corey_derivative;
119  model.conv_flux_ptr = @conv_flux_brooks_corey_simple;
120  model.conv_flux_derivative_ptr = @conv_flux_brooks_corey_simple_derivative;
121 
122  % set all to dirichlet-boundary by specifying "rectangles", all
123  % boundary within is set to boundary type by bnd_rect_index
124  model.bnd_rect_corner1 = [-0.999999, 0; ...
125  0, -0.9999999 ];
126  model.bnd_rect_corner2 = [ 2, 0.999999; ...
127  0.999999, 2 ];
128  % -1 means dirichlet, -2 means neumann
129  model.bnd_rect_index = [ -2, -2 ];
130 
131  if isfield(params, 'separate_CRBs') && params.separate_CRBs
132  model.separate_CRBs = params.separate_CRBs;
133  savepath_infix = '';
134  else
135  savepath_infix = '_one_CRB';
136  end
137 
138  model.ei_detailed_savepath = [model.name,'_',params.model_type,...
139  savepath_infix,'_ei_data_interpol'];
140  model.ei_operator_savepath = [model.name,'_',params.model_type,...
141  savepath_infix,'_ei_operators_interpol'];
142  model.RB_detailed_val_savepath = [model.name,'_',params.model_type,...
143  savepath_infix,'_RB_val_detailed'];
144  model.RB_detailed_train_savepath = [model.name,'_',params.model_type,...
145  savepath_infix,'_RB_train_detailed'];
146 % model.RB_detailed_train_savepath = model.ei_detailed_savepath;
147 
148  if isfield(params, 'model_size')
149  if strcmp(params.model_size, 'big') == 1
150  model.xnumintervals = 200;
151  model.ynumintervals = 200;
152  end
153  if strcmp(params.model_size, 'small') == 1
154  model.xnumintervals = 50;
155  model.ynumintervals = 50;
156  end
157  end
158 
159  if isfield(params, 'model_type')
160  if strcmp(params.model_type, 'buckley_leverett')
161  model.diff_K = 1.0000;
162  model.bl_k = 1/0.20;
163  model.bl_mu1 = 5;
164  model.bl_mu2 = 5;
165  model.bl_lambda = 0.3;
166  model.newton_regularisation = false;
167  model.c_low = 0.02;
168  model.c_high = 1.0;
169  model.T = 0.3;
170  model.mu_names = {'diff_K','c_low','bl_lambda'};
171  model.mu_ranges = {[0.1,2],[0.0,0.04],[0.1,0.4]};
172  model.adaptive_time_split_mode = false;
173  model.ei_stop_epsilon_first = 5e-3;
174  model.ei_stop_epsilon = 1e-6;
175  model.minimum_time_slice = 5;
176  model.time_split_Mmax = 75;
177  model.Mmax = Inf;
178  model.extend_crb = true;
179  model.skip_search = true;
180 
181 % model.mu_names = {'bl_mu2','diff_K','bl_lambda'};
182 % model.mu_ranges = {[1,50],[0,2],[0.1,0.4]};
183 % model.ei_numintervals = [8,4,3,3];
184 % model.RB_numintervals = [8,4,3,3];
185  model.ei_numintervals = [4,3,3];
186  model.RB_numintervals = [2,1,1];
187  model.nt = 60;
188  model.RB_stop_Nmax = 250;
189  model.RB_stop_epsilon = 5e-4;
190  model.RB_stop_timeout = 5*60*60;
191  model.bnd_rect_index = [-1,-1];
192  model.separate_CRBs = false;
193  model.ei_space_operators = { model.L_E_local_ptr , model.L_I_local_ptr };
194  model.c_width = 0.2;
195  model.c_height = 0.4;
196 
197 % if isfield(params, 'use_laplacian') && params.use_laplacian
198 % model.laplacian_derivative_ptr = @(glob, U, model) ...
199 % ones(size(U));
200 % model.laplacian_ptr = @(glob, U, model) ...
201 % U;
202 % model.diffusivity_ptr = @(glob, U, model) ...
203 % struct('K',1,'epsilon',0);
204 % model.diffusivity_derivative = @(glob, U, model) ...
205 % struct('K',1,'epsilon',0);
206 % model.implicit_gradient_operators_algorithm = ...
208 % end
209 % elseif strcmp(params.model_type, 'eoc')
210 % model.xnumintervals = 10;
211 % model.ynumintervals = 10;
212 % model.diff_k0 = 0.05;
213 % model.diff_m = 0;
214 % model.nt = 50;
215 % model.init_values_ptr = @exact_function_heat_equation;
216 % model.dirichlet_values_ptr = @exact_function_heat_equation;
217 % model.bnd_rect_index = [ -1, -1 ];
218 % elseif strcmp(params.model_type, 'eoc_nonlinear')
219 % model.xnumintervals = 10;
220 % model.ynumintervals = 10;
221 % model.newton_regularisation = 0;
222 % model.diff_k0 = 0.0;
223 % model.diff_m = 1;
224 % model.diff_p = 1.0;
225 % model.nt = 150;
226 % model.T = 1.0;
227 % model.init_values_ptr = @exact_function_plaplace;
228 % model.dirichlet_values_ptr = @exact_function_plaplace;
229 % model.data_const_in_time = false;
230 % model.bnd_rect_index = [ -1, -2 ];
231 % elseif strcmp(params.model_type, 'buckley_leverett')
232  end
233  end
234 
235  model.model_type = params.model_type;
236 
237  model.implicit_nonlinear = false;
238 
239  model.data_const_in_time = true;
240 
241  model = model_default(model);
242 
243  if ~isfield(model, 'ei_space_operators')
244  model.ei_space_operators = { model.L_E_local_ptr, model.L_I_local_ptr };
245  end
246 
247  if isfield(params, 'verbose')
248  model.verbose = params.verbose;
249  else
250  model.verbose = 0;
251  end
252  model.debug = 1;
253 
254 end
255 % vim: set et sw=2:
256 %| \docupdate
function [ L_I_diff , bdir_I_diff ] = fv_operators_diff_implicit_gradient(model, model_data, U, NU_ind)
computes diffusion contributions to finite volume time evolution matrices, or their Frechet derivati...
function Udirichlet = dirichlet_values(model, X, Y)
UDIRICHLET = DIRICHLET_VALUES([X],[Y], MODEL) Examples dirichlet_values([0,1,2],[1,1,1],struct(name_dirichlet_values, homogeneous, ... c_dir, 1)) dirichlet_values([0:0.1:1],[0],struct(name_dirichlet_values, xstripes, ... c_dir, [0 1 2], ... dir_borders, [0.3 0.6])) dirichlet_values([0:0.1:1],[0],struct(name_dirichlet_values, box, ... c_dir, 1, ... dir_box_xrange, [0.3 0.6], ... dir_box_yrange, [-0.1 0.1]))
function num_flux_mat = fv_num_diff_flux_gradient(model, model_data, U, NU_ind)
computes a numerical diffusive flux for a diffusion problem
function [ flux , lambda ] = conv_flux_brooks_corey_simple(glob, U, params)
convective flux for Buckley-Leverett problem with Brooks-Corey functions
function [ flux , lambda ] = conv_flux_brooks_corey_simple_derivative(glob, U, params)
convective flux for Buckley-Leverett problem with Brooks-Corey functions
function model = model_default(model, T, nt)
model = model_default(model)
Definition: model_default.m:17
function [ flux , lambda ] = conv_flux_brooks_corey(glob, U, params)
convective flux for Buckley-Leverett problem with Brooks-Corey functions
function model = unitcube(model)
function adding fields to model for generating a 2D rectgrid with 100 x 100 elements on the unit-squa...
Definition: unitcube.m:17
function [ L_I_diff_jac , bdir_I_diff_jac ] = fv_frechet_operators_diff_implicit_gradient(model, model_data, U, NU_ind)
computes a jacobian of implicit non-linear diffusion contributions to time evolution matrices at a po...
function buckley_leverett()
small script demonstrating a buckley leverett problem discretization and RB model reduction ...
function res = exact_function_plaplace(glob, params)
This is the first function from http://eqworld.ipmnet.ru/en/solutions/npde/npde1201.pdf.
function [ flux , lambda ] = conv_flux_brooks_corey_derivative(glob, U, params)
convective flux for Buckley-Leverett problem with Brooks-Corey functions
function num_flux = fv_num_conv_flux_engquist_osher(model, model_data, U, NU_ind)
Function computing a numerical convective Engquist-Osher flux matrix.