-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalSatFront.m
57 lines (56 loc) · 2 KB
/
calSatFront.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
function [index, Swf, dfwf, bf] = calSatFront(Sw, fw, dfw)
%% calculate advance front saturation using Welge graphic method
% Sw saturation vector of displacing wetting phase fluid
% fw fractional flow vector of displacing wetting phase fluid
% dfw fractional flow derivate vector of displacing wetting phase fluid
% index index of Swf in Sw
% Swf advance front saturation
% dfwf fractional flow derivative at Swf
% bf intercept value for tangent line
index = 0;
ns = size(Sw,1);
df = 1/(Sw(ns)-Sw(1));
dlt_Sw = Sw(ns)-Sw(ns-1);
if nargin == 2
% calculate derivate
for i = 3:(ns-2)
dfw(i) = (fw(i+1)-fw(i-1))/(2*dlt_Sw);
end
dfw(2) = (-11*fw(2)+18*fw(3)-9*fw(4)+2*fw(5))/(6*dlt_Sw);
dfw(1) = abs(2*dfw(2)-dfw(3));
dfw(ns-1) = -(-11*fw(nt-1)+18*fw(nt-2)-9*fw(nt-3)+2*fw(nt-4))/(6*dlt_Sw);
dfw(ns) = abs(2*dfw(nt-1)-dfw(nt-2));
% calculate Swf and its index
for i = 2:ns-1
dfds = fw(i)/(Sw(i)-Sw(1));
if (dfds < dfw(i1)) && (dfds > dfw(i+1)) && (dfds >= df)
index = i;
Swf = Sw(i);
dfwf = dfds;
bf = fw(i)-dfwf*Sw(i);
break;
end
end
if index == 0
error('Can’t find a tangent line through point (Swc,0). Decrease dlt_Sw!');
end
elseif nargin == 3
% calculate Swf and its index
for i = 2:ns-1
dfds = fw(i)/(Sw(i)-Sw(1));
if (dfds < dfw(i-1)) && (dfds > dfw(i+1)) && (dfds >= df)
index = i;
Swf = Sw(i);
dfwf = dfds;
bf = fw(i)-dfwf*Sw(i);
break;
end
end
if index == 0
error('Can’t find a tangent line through point (Swc,0). Decrease dlt_Sw!');
end
else
error('the number of input arguments in function calSatFront is incorrect!');
end
end
%% end function calSatFront()