rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
multiscale_buckley_leverett_model.m
Go to the documentation of this file.
1 function model = multiscale_buckley_leverett_model(params)
2 % initialization of micromodel for buckley leverett multiscale
3 % problem
4 
5 % Bernard Haasdonk 5.5.2010
6 
7 model = [];
8 
9 model = nonlin_evol_model_default;
10 
11 model.mu_names = {'BL_Ul','BL_tau'};
12 model.mu_ranges = {[0.3,1],[1,20]};
13 % default values:
14 model.BL_Ul = 0.75;
15 model.BL_tau = 10;
16 model.T = 3*10^(-3); % Zeit, nicht Matrix
17 model.BL_n_x = 300;
18 
19 % parameters in test-routine:
20 model.BL_Time=3; % Endzeit fuer HMM-Berechnung
21 
22 % Regularisierungsparameter
23 model.BL_epsilon = 0.00001;
24 
25 model.BL_M = 2; % water/oil viscosity ratio
26 
27 %%%%%%%%%%%%%%% makroskopische Ortsschrittweite %%%%%%%%%%%%%%%%%%%%%%%
28 model.BL_DX=0.02;
29 
30 %%%%%%%%%%% Anzahl der Schritte auf mikroskopischer Skala %%%%%%%%%%%%%
31 %n = n_x-2;
32 model.BL_n = model.BL_n_x-2;
33 
34 %%%%%%%%%%%%%%%%%%%%%%%% Anfangsdaten %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %[U,Ur,xfront,lR,rR,X,N_X]=HMM_AB_U0_BL(DX,Ul);
36 % => in init_values
37 
38 %%%%%%%%%%%%%%%%%%%%%%%%% Schrittweiten %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 compute_dt = 1;
40 if compute_dt
41  [DT,N_T,dx,dt,LAMBDA]=HMM_CFL_BL(...
42  model.BL_DX,model.BL_Time,model.BL_epsilon,model.BL_M);
43  n_t=round(model.T/dt)-1; % Anzahl mikroskopischer Zeitschritte
44 % disp('model parameters should be set constant sometime');
45 else % variables from previous call of function...
46 % DT =
47 % N_T =
48 % dx =
49 % dt =
50 % LAMBDA =
51 end;
52 
53 % perhaps useful:
54 model.BL_DT = DT;
55 model.BL_N_T = N_T;
56 model.BL_dx = dx;
57 model.BL_dt = dt;
58 model.BL_LAMBDA = LAMBDA;
59 
60 % nonlin-evol nt:
61 % n_t unabhaegnig von tau, Ul
62 model.nt = n_t+1;
63 
64 % further fields required by nonlin-evol:
65 %model.gridtype = 'none';
66 model.inner_product_matrix_algorithm = @(model,model_data) ...
67  eye(model.BL_n_x);
68 model.verbose = 10;
69 model.debug = 0;
70 model.init_values_algorithm = @BL_init_values;
71 model.L_E_local_ptr = @BL_L_E_local;
72 model.plot = @(dummy) plot(dummy);
73 
74 %%% Diskretisierungsmatrix A in IR^{(nx-2)x(nx-2)}
75 %a = 2+dx^2/(epsilon^2*tau);
76 %c = epsilon^2*tau/(dx^2);
77 %A = c*(diag(a*ones(1,n))+diag(-ones(1,n-1),1)+diag(-ones(1,n-1),-1));
78 % => In detailed_data
79 
80 %%% Inverse der Tridiagonalmatrix A
81 %[T]=INVERSE_TRIDIAG(A);
82 %T = inv(A);
83 
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 
87 % % 1.Schritt: stueckweise konstante Rekonstruktion von u=RU
88 % [u,x,s]=HMM_REKONSTRUKTION(U,xfront,X,dx,n_x);
89 %
90 % % 2.Schritt: Loesung des mikroskopischen Modells mit den Anfangsdaten u=RU
91 % % auf dem mikroskopischen Gitter -> gibt Loesung u zurueck
92 %
93 % for iter=1:n_t % global Loesung zum Zeitpunkt T-dt
94 % [u_new,w]=HMM_MIKRO_teil(T,u,epsilon,tau,dx,dt,n_x,M);
95 % if ~isequal(u_new,w*dt+u)
96 % error('w*dt+u not equal new u!!');
97 % end;
98 % u = u_new;
99 % end
100 % u_sicher = u;
101 %
102 % i1=(15:1:20);
103 % i2=(150:1:170);
104 % i3=(190:1:210);
105 % i4=(230:1:235);
106 % index=[i1,i2,i3,i4];
107 %
108 % % lokale Loesung zum Zeitpunkt T
109 % [u,w,index_n]=HMM_MIKRO_teil(T,u_sicher,epsilon,tau,dx,dt,n_x,M,index);
110 % X = x(index_n);
111 %
112 % % kontrolle/ global Loesung zum Zeitpunkt T
113 % [u_kontrolle,w_k]=HMM_MIKRO_teil(T,u_sicher,epsilon,tau,dx,dt,n_x,M);
114 %
115 % % Fehler zwischen globaler und lokaler Loesung
116 % fehler = max(abs(u_kontrolle(index_n)-u));
117 %
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 %% PLOT %%
121 
122 %figure % Plot zu u-Werten
123 %plot(x,u_sicher,'g','LineWidth',2)
124 %hold on
125 %plot(x,u_kontrolle,'LineWidth',2)
126 %plot(X,u,'ro')
127 %title('u')
128 %legend('globale Lsg bei T-dt','globale Lsg bei T','lokale Lsg bei T')
129 %xlabel('x')
130 %
131 %figure % Plot zu w-Werten
132 %plot(x,w_k*dt)
133 %hold on
134 %plot(X,w*dt,'ro')
135 %title('w')
136 %xlabel('x')
137 
138 function U0 = BL_init_values(model,model_data)
139 %keyboard;
140 % Abhaegnig von Ulinks
141 % Unabhaegnig von Tau
142 % erster Eintrag Ul, rest 0!!!
143 U0 = zeros(1,model.BL_n_x);
144 U0(1)= model.BL_Ul;
145 %[U,Ur,xfront,lR,rR,X,N_X]=HMM_AB_U0_BL(model.BL_DX,model.BL_Ul);
146 % % 1.Schritt: stueckweise konstante Rekonstruktion von u=RU
147 %[U0,x,s]=HMM_REKONSTRUKTION(U,xfront,X,model.BL_dx,model.BL_n_x);
148 
149 function [inc, fluxes] = BL_L_E_local(model, model_data, U, index);
150 if isempty(index)
151  [UNew,w]=HMM_MIKRO_teil(model.T,(U(:))',...
152  model.BL_epsilon,model.BL_tau,model.BL_dx,...
153  model.dt,model.BL_n_x,model.BL_M);
154  inc = w * model.dt;
155 else
156 
157 end;
158 
159 fluxes = [];
function model = multiscale_buckley_leverett_model(params)
initialization of micromodel for buckley leverett multiscale problem