Need help in generating plot in while loop for Buckley Leverett code.
이전 댓글 표시
Hello, I'm trying to develop a code for the Buckley Leverett equation. I used a while loop to find the tangent point between the curve and tangent line by equating them to one and then subtracting one. The program is computing the correct values, however, it is not able to plot the graph (S-curve with a tangent line to it). A plot pops up with correct axis values but there is no graph. I'm assuming it's because it's graphing only one point because the while loop keeps iterating over it. I already tried hold on, and drawnow, but it was futile. I have included the code below. Any suggestions and thoughts are more than welcomed, thank you.
%Buckely Leverett Plot
clear all
clc
hold on
W=500; %ft
T=25; %ft
L= 1000; %ft
Por =0.18;
Permb= 50; %md base permeability
Sor=0.3;
Viscw= 1 %cp water viscosity
ViscO= 1.62 ; %cp
qi = 200; %B/D
Swi=0.3
Sw =.4
Swd=(Sw-Swi)/(1-Sor-Swi)
Krw= 0.248*Swd.^2.33
Kro=0.402*(1-Swd).^(2.06)
A=Viscw*Kro
B=ViscO*Krw
C= A/B
fw = 1/(1+((Viscw*Kro)/(ViscO*Krw)))+.1
fw2 = 1/(1+((Viscw*Kro)/(ViscO*Krw)))
% Slope1 = (fw - 0)/(Sw-Swi)
% Slope2 = (fw-fw2)/.0001
%fw= 1/(1+((Viscw*Kro)./(ViscO*Krw)))
while (fw/(Sw-Swi))/((fw-fw2)/.00001) - 1 <= .0001
%output(fw)
Slope1 = (fw - 0)/(Sw-Swi)
Slope2 = (fw-fw2)/.0001
Sw = Sw+.0001
Sw2 = Sw-.0001
Swd=(Sw-Swi)/(1-Sor-Swi);
Swd2 = (Sw2-Swi)/(1-Sor-Swi);
Krw= 0.248*Swd^2.33
Krw2= 0.248*Swd2^2.33;
Kro=0.402*(1-Swd)^(2.06)
Kro2=0.402*(1-Swd2)^(2.06);
fw= 1/(1+((Viscw*Kro)/(ViscO*Krw)));
fw2= 1/(1+((Viscw*Kro2)/(ViscO*Krw2)));
plot(Sw,fw,'r-')
drawnow
end
답변 (1개)
KSSV
2017년 4월 5일
Replace
plot(Sw,fw,'r-')
with
plot(Sw,fw,'.r')
댓글 수: 3
KSSV
2017년 4월 5일
And the better code would be:
%Buckely Leverett Plot
clear all
clc
W=500; %ft
T=25; %ft
L= 1000; %ft
Por =0.18;
Permb= 50; %md base permeability
Sor=0.3;
Viscw= 1 ; %cp water viscosity
ViscO= 1.62 ; %cp
qi = 200; %B/D
Swi=0.3 ;
Sw =.4 ;
Swd=(Sw-Swi)/(1-Sor-Swi) ;
Krw= 0.248*Swd.^2.33 ;
Kro=0.402*(1-Swd).^(2.06) ;
A=Viscw*Kro ;
B=ViscO*Krw ;
C= A/B ;
fw = 1/(+((Viscw*Kro)/(ViscO*Krw)))+.1 ;
fw2 = 1/(1+((Viscw*Kro)/(ViscO*Krw))) ;
% Slope1 = (fw - 0)/(Sw-Swi)
% Slope2 = (fw-fw2)/.0001
%fw= 1/(1+((Viscw*Kro)./(ViscO*Krw)))
count = 0 ;
x = [] ; y = [] ;
while (fw/(Sw-Swi))/((fw-fw2)/.00001) - 1 <= .0001
count = count+1 ;
%output(fw)
Slope1 = (fw - 0)/(Sw-Swi) ;
Slope2 = (fw-fw2)/.0001 ;
Sw = Sw+.0001 ;
Sw2 = Sw-.0001 ;
Swd=(Sw-Swi)/(1-Sor-Swi);
Swd2 = (Sw2-Swi)/(1-Sor-Swi);
Krw= 0.248*Swd^2.33 ;
Krw2= 0.248*Swd2^2.33;
Kro=0.402*(1-Swd)^(2.06) ;
Kro2=0.402*(1-Swd2)^(2.06);
fw= 1/(1+((Viscw*Kro)/(ViscO*Krw)));
fw2= 1/(1+((Viscw*Kro2)/(ViscO*Krw2)));
x(count) = Sw ;
y(count) = fw ;
end
plot(x,y,'r')
Nadia Menouar
2017년 4월 6일
KSSV
2017년 4월 6일
Actually it is not needed...For the present code. And thanks is accepting the answer.
카테고리
도움말 센터 및 File Exchange에서 Language Fundamentals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!