SlideShare a Scribd company logo
1 of 13
Download to read offline
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 1 of 13
% Surge/Swab Pressure Calculations Algorithm Version 1.0
%
close all
clear
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Developed by Ankit Kukreja (ankit.kukreja.89@gmail.com)
% on July 3rd, 2012
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d=2.25; % Pipe ID (inch)
d1=4; % Pipe OD (inch)
d2=6.25; % Casing ID (inch)
rho=9; % Fluid density (ppg)
L= 10000; % Depth of well (ft)
theta600=60.8; % Fann dial reading at 600 rpm
theta300=37.4; % Fann dial reading at 300 rpm
Cd=0.9697; % Discharge coefficient at nozzle
Nsize=12; % Current nozzle size
Nno=3; % Number of Nozzles currently in use
qmin = 125; % Minimum flow rate (gpm)
% Pump parameters
Ppmax=3000; % Maximum achievable pump pressure
PHP=1250; % Pump rating (Horsepower)
e=0.91; % Pump efficiency
% Enter the choice of criterion to choose
% 1 - Maximum Jet impact force
% 2 - Maximum drill bit hydraulic horsepower
% 3 - Maximum jet velocity
choice=1;
%
% Step 1 calculations
% Flow behaviour parameter, n (dimensionless)
n=3.32*log10(theta600/theta300)
% Flow behaviour parameter, K (lbf/100 ft^2)
K=510*theta300/(511^n)
% Effective area through nozzle
Aeff=(pi/4)*Nno*((Nsize/32)^2)
% Maximum possible flow (gpm)
qmax=1714*PHP*e/Ppmax
% Selection of two flow rates
q1=qmax/3 % Flow rate 1 (gpm)
q2=2*qmax/3 % Flow rate 2 (gpm)
% q1=350; % Flow rate 1 (gpm)
% q2=550; % Flow rate 2 (gpm)
%%
% Calculation of pump pressure corresponding to flow rate q1
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe1=q1/(2.448*(d^2))
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann1=q1/(2.448*((d2^2)-(d1^2)));
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 2 of 13
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe1=(89100*rho*(vbar_pipe1^(2-n))/K)*((0.0416*d/(3+(1/n)))^n);
% Turbulence criteria of annulus, NRe_ann
NRe_ann1=(109000*rho*(vbar_ann1^(2-n))/K)*((0.0208*(d2-d1)/(2+(1/n)))^n);
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReC1=2000;
else
if n<0.5 && n>=0.2
log_ReC1=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC1=10^(log_ReC1);
end
end
if NRe_pipe1<ReC1
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe1=K*(vbar_pipe1^n)*(((3+(1/n))/0.0416)^n)/(144000*(d^(1+n)))
% Pump pressure, Pp
deltaPp1 = L*Lam_Pgrad_pipe1
end
if NRe_ann1<ReC1
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann1=K*(vbar_ann1^n)*(((2+(1/n))/0.0208)^n)/(144000*((d2-d1)...
^(1+n)))
end
% Calculation of friction factor of pipe, f_pipe
f_pipe1 = fsolve(@(f_pipe1)(sqrt(1/f_pipe1))-((4/(n^0.75))*log10...
(NRe_pipe1*(f_pipe1^(1-(n/2)))))+(0.395/(n^1.2)),1)
% Calculation of friction factor of annulus, f_ann
f_ann1 = fsolve(@(f_ann1)(sqrt(1/f_ann1))-((4/(n^0.75))*log10...
(NRe_ann1*(f_ann1^(1-(n/2)))))+(0.395/(n^1.2)),1)
if NRe_pipe1>=ReC1
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe1=(f_pipe1*rho*(vbar_pipe1^2))/(25.8*d)
% Pump pressure, Pp
deltaPp1 = L*Tur_Pgrad_pipe1
end
if NRe_ann1>=ReC1
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann1=(f_ann1*rho*(vbar_ann1^2))/(21.1*(d2-d1))
end
% Pressure loss at bit, deltaPb
deltaPb1=8.311*(10^(-5))*rho*(q1^2)/((Cd^2)*(Aeff^2))
%
%%
% Calculation of pump pressure corresponding to flow rate q2
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe2=q2/(2.448*(d^2))
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann2=q2/(2.448*((d2^2)-(d1^2)))
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe2=(89100*rho*(vbar_pipe2^(2-n))/K)*((0.0416*d/(3+(1/n)))^n)
% Turbulence criteria of annulus, NRe_ann
NRe_ann2=(109000*rho*(vbar_ann2^(2-n))/K)*((0.0208*(d2-d1)/(2+(1/n)))^n)
% Define critical Reynold number, ReC
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 3 of 13
if n<=1 && n>=0.5
ReC2=2000;
else
if n<0.5 && n>=0.2
log_ReC2=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC2=10^(log_ReC2);
end
end
if NRe_pipe2<ReC2
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe2=K*(vbar_pipe2^n)*(((3+(1/n))/0.0416)^n)/(144000*(d^(1+n)))
% Pump pressure, Pp
deltaPp2 = L*Lam_Pgrad_pipe2
end
if NRe_ann2<ReC2
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann2=K*(vbar_ann2^n)*(((2+(1/n))/0.0208)^n)/(144000*...
((d2-d1)^(1+n)))
end
% Calculation of friction factor of pipe, f_pipe
f_pipe2 = fsolve(@(f_pipe2)(sqrt(1/f_pipe2))-((4/(n^0.75))*...
log10(NRe_pipe2*(f_pipe2^(1-(n/2)))))+(0.395/(n^1.2)),1)
% Calculation of friction factor of annulus, f_ann
f_ann2 = fsolve(@(f_ann2)(sqrt(1/f_ann2))-((4/(n^0.75))*...
log10(NRe_ann2*(f_ann2^(1-(n/2)))))+(0.395/(n^1.2)),1)
if NRe_pipe2>=ReC2
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe2=(f_pipe2*rho*(vbar_pipe2^2))/(25.8*d)
% Pump pressure, Pp
deltaPp2 = L*Tur_Pgrad_pipe2
end
if NRe_ann2>=ReC2
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann2=(f_ann2*rho*(vbar_ann2^2))/(21.1*(d2-d1))
end
% Pressure loss at bit, deltaPb
deltaPb2=8.311*(10^(-5))*rho*(q2^2)/((Cd^2)*(Aeff^2))
%
%%
% Parasitic pressure loss
deltaPd1=deltaPp1-deltaPb1 % Corresponding to flow rate q1
deltaPd2=deltaPp2-deltaPb2 % Corresponding to flow rate q2
% Slope of analysis plot
m=(log10(deltaPd2/deltaPd1))/(log10(q2/q1))
%%%%%%%%%%%%%%%%% Path of optimum hydraulics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if choice==1
% For max jet impact force
deltaPd_choice=(2/(m+2))*Ppmax
end
if choice==2
% For max bit hydraulic horsepower
deltaPd_choice=(1/(m+1))*Ppmax
end
if choice==3
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 4 of 13
% For max jet velocity
deltaPd_choice=100
end
% Path definition
for qline=50:0.1:qmax
deltaPdline=10^(log10(deltaPd1)+m*log10(qline/q1));
plot(log10(qline),log10(deltaPdline))
hold on
if deltaPdline<=deltaPd_choice
plot(log10(qmax),log10(deltaPdline),'r')
hold on
end
if deltaPdline>=deltaPd_choice
plot(log10(qmin),log10(deltaPdline),'r')
hold on
end
if qline<=qmax && qline>=qmin
plot(log10(qline),log10(deltaPd_choice),'r')
hold on
end
plot(log10(qmin+1),log10(deltaPdline),'g')
hold on
for i=log10(100):0.1:log10(deltaPd_choice)
if log10(deltaPdline)<=log10(i+1) && log10(deltaPdline)...
>=log10(i-1) && log10(qline)<=log10(qmax+1) && ...
log10(qline)>=log10(qmax-1)
deltaPdopt=i;
qopt=qline;
end
end
if log10(deltaPdline)<=log10(deltaPd_choice+1) && ...
log10(deltaPdline)>=log10(deltaPd_choice-1) && ...
log10(qline)<log10(qmax) && log10(qline)>log10(qmin)
deltaPdopt=deltaPd_choice;
qopt=qline;
end
for k=log10(deltaPd_choice+1):0.1:log10(Ppmax)
if log10(deltaPdline)<=k+1 && log10(deltaPdline)>=k-1 && ...
log10(qline)<=log10(qmin+1) && log10(qline)>=log10(qmin-1)
deltaPdopt=k;
qopt=qline;
end
end
end
xlabel('Flow Rate (gpm)')
ylabel('Parasitic Pressure Loss(psi)')
grid on
title('Well dynamics (in blue) and optimum hydraulic path(in red and green)')
%%
% Calculation of pump pressure corresponding to flow rate qopt
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipeopt=qopt/(2.448*(d^2));
% Average velocity of annulus, vbar_ann (ft/sec)
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 5 of 13
vbar_annopt=qopt/(2.448*((d2^2)-(d1^2)));
% Turbulence criteria of pipe, NRe_pipe
NRe_pipeopt=(89100*rho*(vbar_pipeopt^(2-n))/K)*((0.0416*d/(3+(1/n)))^n)
% Turbulence criteria of annulus, NRe_ann
NRe_annopt=(109000*rho*(vbar_annopt^(2-n))/K)*((0.0208*(d2-d1)...
/(2+(1/n)))^n)
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReCopt=2000;
else
if n<0.5 && n>=0.2
log_ReCopt=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReCopt=10^(log_ReCopt);
end
end
if NRe_pipeopt<ReCopt
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipeopt=K*(vbar_pipeopt^n)*(((3+(1/n))/0.0416)^n)...
/(144000*(d^(1+n)))
% Pump pressure, Pp
deltaPpopt = L*Lam_Pgrad_pipeopt
end
if NRe_annopt<ReCopt
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_annopt=K*(vbar_annopt^n)*(((2+(1/n))/0.0208)^n)/...
(144000*((d2-d1)^(1+n)))
end
% Calculation of friction factor of pipe, f_pipe
f_pipeopt = fsolve(@(f_pipeopt)(sqrt(1/f_pipeopt))-((4/(n^0.75))*...
log10(NRe_pipeopt*(f_pipeopt^(1-(n/2)))))+(0.395/(n^1.2)),1)
% Calculation of friction factor of annulus, f_ann
f_annopt = fsolve(@(f_annopt)(sqrt(1/f_annopt))-((4/(n^0.75))*...
log10(NRe_annopt*(f_annopt^(1-(n/2)))))+(0.395/(n^1.2)),1)
if NRe_pipeopt>=ReCopt
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipeopt=(f_pipeopt*rho*(vbar_pipeopt^2))/(25.8*d)
% Pump pressure, Pp
deltaPpopt = L*Tur_Pgrad_pipeopt
end
if NRe_annopt>=ReCopt
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_annopt=(f_annopt*rho*(vbar_annopt^2))/(21.1*(d2-d1))
end
% Optimum bit pressure loss
deltaPbopt=deltaPpopt-deltaPdopt
% Proper total nozzle area
Aeffopt=sqrt(8.311*(10^-5)*rho*(qopt^2)/((Cd^2)*deltaPbopt))
% Surge/Swab Pressure calculation starts from here
% surgecp = surge with closed pipe
% surgeop = surge with open pipe
% K for closed pipe is tuned to value:
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 6 of 13
K_cp=1.527;
% Is the pipe is moving up or down?
% Down - 1
% Up - 2
direction=2;
vp=1/3; % Tripping speed (ft/s)
if direction==1
disp('Calculating surge pressure for closed pipe..')
% For closed pipe
q_surgecp=vp*pi*(d1^2)/4;
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe_surgecp=0;
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann_surgecp=q_surgecp/(2.448*((d2^2)-(d1^2)))+(K_cp*vp);
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe_surgecp=(89100*rho*(vbar_pipe_surgecp^(2-n))/K)...
*((0.0416*d/(3+(1/n)))^n)
% Turbulence criteria of annulus, NRe_ann
NRe_ann_surgecp=(109000*rho*(vbar_ann_surgecp^(2-n))/K)*((0.0208*(d2-d1)...
/(2+(1/n)))^n)
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReC_surgecp=2000;
else
if n<0.5 && n>=0.2
log_ReC_surgecp=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC_surgecp=10^(log_ReC_surgecp);
end
end
if NRe_pipe_surgecp<ReC_surgecp
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe_surgecp=K*(vbar_pipe_surgecp^n)*(((3+(1/n))/0.0416)^n)...
/(144000*(d^(1+n)));
% Pump pressure, Pp
deltaPp_surgecp = L*Lam_Pgrad_pipe_surgecp
end
if NRe_ann_surgecp<ReC_surgecp
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann_surgecp=K*(vbar_ann_surgecp^n)*(((2+(1/n))/0.0208)^n)/...
(144000*((d2-d1)^(1+n)));
% Annular pressure, Pa
deltaPa_surgecp = L*Lam_Pgrad_ann_surgecp
end
% Calculation of friction factor of pipe, f_pipe
f_pipe_surgecp = fsolve(@(f_pipe_surgecp)(sqrt(1/f_pipe_surgecp))...
-((4/(n^0.75))*log10(NRe_pipe_surgecp*(f_pipe_surgecp^...
(1-(n/2)))))+(0.395/(n^1.2)),1);
% Calculation of friction factor of annulus, f_ann
f_ann_surgecp = fsolve(@(f_ann_surgecp)(sqrt(1/f_ann_surgecp))-((4/(n^0.75))*...
log10(NRe_ann_surgecp*(f_ann_surgecp^(1-(n/2)))))+(0.395/(n^1.2)),1);
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 7 of 13
if NRe_pipe_surgecp>=ReC_surgecp
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe_surgecp=(f_pipe_surgecp*rho*(vbar_pipe_surgecp^2))/(25.8*d);
% Pump pressure, Pp
deltaPp_surgecp = L*Tur_Pgrad_pipe_surgecp
end
if NRe_ann_surgecp>=ReC_surgecp
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann_surgecp=(f_ann_surgecp*rho*(vbar_ann_surgecp^2))/(21.1*(d2-d1));
% Annular pressure, Pa
deltaPa_surgecp = L*Tur_Pgrad_ann_surgecp
end
disp('Calculating Equivalent Mud Weight for closed pipe..')
rho_c=rho+(231/(12*deltaPa_surgecp))
disp('Calculating surge pressure for open pipe..')
% For open pipe
K_op=1.2;
for fa=0:0.01:1
qa_surgeop=fa*vp*((pi*(d1^2)/4)-Aeffopt);
qp_surgeop=(1-fa)*vp*((pi*(d1^2)/4)-Aeffopt);
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op*vp);
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op*vp);
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*...
((0.0416*d/(3+(1/n)))^n);
% Turbulence criteria of annulus, NRe_ann
NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)...
/(2+(1/n)))^n);
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReC_surgeop=2000;
else
if n<0.5 && n>=0.2
log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC_surgeop=10^(log_ReC_surgeop);
end
end
if NRe_pipe_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)...
/(144000*(d^(1+n)));
% Pump pressure, Pp
deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop;
end
if NRe_ann_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/...
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 8 of 13
(144000*((d2-d1)^(1+n)));
% Annular pressure, Pa
deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop;
end
% Calculation of friction factor of pipe, f_pipe
f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-...
((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^...
(1-(n/2)))))+(0.395/(n^1.2)),1);
% Calculation of friction factor of annulus, f_ann
f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))...
-((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^(1-(n/2)))))...
+(0.395/(n^1.2)),1);
if NRe_pipe_surgeop>=ReC_surgeop
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d);
% Pump pressure, Pp
deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop;
end
if NRe_ann_surgeop>=ReC_surgeop
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1));
% Annular pressure, Pa
deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop;
end
if deltaPa_surgeop - deltaPp_surgeop <1
fa_final=fa;
end
end
qa_surgeop=fa_final*vp*((pi*(d1^2)/4)-Aeffopt);
qp_surgeop=(1-fa_final)*vp*((pi*(d1^2)/4)-Aeffopt);
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op*vp);
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op*vp);
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*...
((0.0416*d/(3+(1/n)))^n);
% Turbulence criteria of annulus, NRe_ann
NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)...
/(2+(1/n)))^n);
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReC_surgeop=2000;
else
if n<0.5 && n>=0.2
log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC_surgeop=10^(log_ReC_surgeop);
end
end
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 9 of 13
if NRe_pipe_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)...
/(144000*(d^(1+n)));
% Pump pressure, Pp
deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop
end
if NRe_ann_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/...
(144000*((d2-d1)^(1+n)));
% Annular pressure, Pa
deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop
end
% Calculation of friction factor of pipe, f_pipe
f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-...
((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^...
(1-(n/2)))))+(0.395/(n^1.2)),1);
% Calculation of friction factor of annulus, f_ann
f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))...
-((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^...
(1-(n/2)))))+(0.395/(n^1.2)),1);
if NRe_pipe_surgeop>=ReC_surgeop
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d);
% Pump pressure, Pp
deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop
end
if NRe_ann_surgeop>=ReC_surgeop
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1));
% Annular pressure, Pa
deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop
end
disp('Calculating Equivalent Mud Weight for open pipe..')
rho_o=rho+(231/(12*deltaPa_surgeop))
end
if direction==2
disp('Calculating swab pressure for closed pipe..')
% For closed pipe
q_surgecp=vp*pi*(d1^2)/4;
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe_surgecp=0;
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann_surgecp=q_surgecp/(2.448*((d2^2)-(d1^2)))+(K_cp*vp);
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe_surgecp=(89100*rho*(vbar_pipe_surgecp^(2-n))/K)*...
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 10 of 13
((0.0416*d/(3+(1/n)))^n);
% Turbulence criteria of annulus, NRe_ann
NRe_ann_surgecp=(109000*rho*(vbar_ann_surgecp^(2-n))/K)*((0.0208*(d2-d1)...
/(2+(1/n)))^n);
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReC_surgecp=2000;
else
if n<0.5 && n>=0.2
log_ReC_surgecp=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC_surgecp=10^(log_ReC_surgecp);
end
end
if NRe_pipe_surgecp<ReC_surgecp
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe_surgecp=K*(vbar_pipe_surgecp^n)*(((3+(1/n))/0.0416)^n)...
/(144000*(d^(1+n)));
% Pump pressure, Pp
deltaPp_surgecp = L*Lam_Pgrad_pipe_surgecp
end
if NRe_ann_surgecp<ReC_surgecp
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann_surgecp=K*(vbar_ann_surgecp^n)*(((2+(1/n))/0.0208)^n)/...
(144000*((d2-d1)^(1+n)));
% Annular pressure, Pa
deltaPa_surgecp = L*Lam_Pgrad_ann_surgecp
end
% Calculation of friction factor of pipe, f_pipe
f_pipe_surgecp = fsolve(@(f_pipe_surgecp)(sqrt(1/f_pipe_surgecp))-...
((4/(n^0.75))*log10(NRe_pipe_surgecp*(f_pipe_surgecp^...
(1-(n/2)))))+(0.395/(n^1.2)),1);
% Calculation of friction factor of annulus, f_ann
f_ann_surgecp = fsolve(@(f_ann_surgecp)(sqrt(1/f_ann_surgecp))-((4/(n^0.75))*...
log10(NRe_ann_surgecp*(f_ann_surgecp^(1-(n/2)))))+(0.395/(n^1.2)),1);
if NRe_pipe_surgecp>=ReC_surgecp
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe_surgecp=(f_pipe_surgecp*rho*(vbar_pipe_surgecp^2))/(25.8*d);
% Pump pressure, Pp
deltaPp_surgecp = L*Tur_Pgrad_pipe_surgecp
end
if NRe_ann_surgecp>=ReC_surgecp
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann_surgecp=(f_ann_surgecp*rho*(vbar_ann_surgecp^2))...
/(21.1*(d2-d1));
% Annular pressure, Pa
deltaPa_surgecp = L*Tur_Pgrad_ann_surgecp
end
disp('Calculating Equivalent Mud Weight for closed pipe..')
rho_c=rho-(231/(12*deltaPa_surgecp))
disp('Calculating swab pressure for open pipe..')
% For open pipe
K_op1=1.2;
K_op2=1.2;
for fa=0:0.01:1
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 11 of 13
qa_surgeop=fa*vp*((pi*(d1^2)/4)-Aeffopt);
qp_surgeop=(1-fa)*vp*((pi*(d1^2)/4)-Aeffopt);
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op1*vp);
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op2*vp);
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*((0.0416*d...
/(3+(1/n)))^n);
% Turbulence criteria of annulus, NRe_ann
NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)...
/(2+(1/n)))^n);
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReC_surgeop=2000;
else
if n<0.5 && n>=0.2
log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC_surgeop=10^(log_ReC_surgeop);
end
end
if NRe_pipe_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)...
/(144000*(d^(1+n)));
% Pump pressure, Pp
deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop;
end
if NRe_ann_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/...
(144000*((d2-d1)^(1+n)));
% Annular pressure, Pa
deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop;
end
% Calculation of friction factor of pipe, f_pipe
f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-...
((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^...
(1-(n/2)))))+(0.395/(n^1.2)),1);
% Calculation of friction factor of annulus, f_ann
f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))-...
((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^...
(1-(n/2)))))+(0.395/(n^1.2)),1);
if NRe_pipe_surgeop>=ReC_surgeop
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d);
% Pump pressure, Pp
deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop;
end
if NRe_ann_surgeop>=ReC_surgeop
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 12 of 13
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1));
% Annular pressure, Pa
deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop;
end
if deltaPa_surgeop - deltaPp_surgeop <1
fa_final=fa;
end
end
qa_surgeop=fa_final*vp*((pi*(d1^2)/4)-Aeffopt);
qp_surgeop=(1-fa_final)*vp*((pi*(d1^2)/4)-Aeffopt);
% Average velocity of pipe, vbar_pipe (ft/sec)
vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op1*vp);
% Average velocity of annulus, vbar_ann (ft/sec)
vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op2*vp);
% Turbulence criteria of pipe, NRe_pipe
NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*((0.0416*d/...
(3+(1/n)))^n);
% Turbulence criteria of annulus, NRe_ann
NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)...
/(2+(1/n)))^n);
% Define critical Reynold number, ReC
if n<=1 && n>=0.5
ReC_surgeop=2000;
else
if n<0.5 && n>=0.2
log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000);
ReC_surgeop=10^(log_ReC_surgeop);
end
end
if NRe_pipe_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of pipe
Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)...
/(144000*(d^(1+n)));
% Pump pressure, Pp
deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop
end
if NRe_ann_surgeop<ReC_surgeop
% If flow is laminar, frictional pressure loss gradient of annulus
Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/...
(144000*((d2-d1)^(1+n)));
% Annular pressure, Pa
deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop
end
% Calculation of friction factor of pipe, f_pipe
f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-...
((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^(1-(n/2)))))...
+(0.395/(n^1.2)),1);
% Calculation of friction factor of annulus, f_ann
f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))-...
((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^(1-(n/2)))))...
+(0.395/(n^1.2)),1);
7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 13 of 13
if NRe_pipe_surgeop>=ReC_surgeop
% If flow is turbulent, frictional pressure loss gradient of pipe
Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d);
% Pump pressure, Pp
deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop
end
if NRe_ann_surgeop>=ReC_surgeop
% If flow is turbulent, frictional pressure loss gradient of annulus
Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1));
% Annular pressure, Pa
deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop
end
disp('Calculating Equivalent Mud Weight for open pipe..')
rho_o=rho-(231/(12*deltaPa_surgeop))
end
% End of code

More Related Content

What's hot

Rudder Control Analysis / Hydraulic Pump Analysis
Rudder Control Analysis / Hydraulic Pump AnalysisRudder Control Analysis / Hydraulic Pump Analysis
Rudder Control Analysis / Hydraulic Pump AnalysisAndrè G. Odu
 
Offshore well intermediate
Offshore well intermediateOffshore well intermediate
Offshore well intermediateG.Balachandran
 
Analysis Of A Binary Outcome Variable
Analysis Of A Binary Outcome VariableAnalysis Of A Binary Outcome Variable
Analysis Of A Binary Outcome VariableArthur8898
 

What's hot (6)

BESTest
BESTestBESTest
BESTest
 
Ae11 sol
Ae11 solAe11 sol
Ae11 sol
 
Rudder Control Analysis / Hydraulic Pump Analysis
Rudder Control Analysis / Hydraulic Pump AnalysisRudder Control Analysis / Hydraulic Pump Analysis
Rudder Control Analysis / Hydraulic Pump Analysis
 
Master project report
Master project reportMaster project report
Master project report
 
Offshore well intermediate
Offshore well intermediateOffshore well intermediate
Offshore well intermediate
 
Analysis Of A Binary Outcome Variable
Analysis Of A Binary Outcome VariableAnalysis Of A Binary Outcome Variable
Analysis Of A Binary Outcome Variable
 

Similar to Surge Swab pressure code

Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfmeerobertsonheyde608
 
1D Simulation of intake manifolds in single-cylinder reciprocating engine
1D Simulation of intake manifolds in single-cylinder reciprocating engine1D Simulation of intake manifolds in single-cylinder reciprocating engine
1D Simulation of intake manifolds in single-cylinder reciprocating engineJuan Manzanero Torrico
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağıMerve Cvdr
 
reservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdf
reservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdfreservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdf
reservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdfRTEFGDFGJU
 
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdfI need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdfeyewatchsystems
 
Numerical Algorithm for a few Special Functions
Numerical Algorithm for a few Special FunctionsNumerical Algorithm for a few Special Functions
Numerical Algorithm for a few Special FunctionsAmos Tsai
 
Solutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdfSolutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdfWaleedHussain30
 
Comparison GUM versus GUM+1
Comparison GUM  versus GUM+1Comparison GUM  versus GUM+1
Comparison GUM versus GUM+1Maurice Maeck
 
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUBPresentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUBWorld University of Bangladesh
 
PID Control of True Integrating Processes - Greg McMillan Deminar
PID Control of True Integrating Processes - Greg McMillan DeminarPID Control of True Integrating Processes - Greg McMillan Deminar
PID Control of True Integrating Processes - Greg McMillan DeminarJim Cahill
 
Axial fan design
Axial fan designAxial fan design
Axial fan designMert G
 
IC Design of Power Management Circuits (III)
IC Design of Power Management Circuits (III)IC Design of Power Management Circuits (III)
IC Design of Power Management Circuits (III)Claudia Sin
 
Price of anarchy is independent of network topology
Price of anarchy is independent of network topologyPrice of anarchy is independent of network topology
Price of anarchy is independent of network topologyAleksandr Yampolskiy
 
Buck converter controlled with ZAD and FPIC for DC-DC signal regulation
Buck converter controlled with ZAD and FPIC for DC-DC signal regulationBuck converter controlled with ZAD and FPIC for DC-DC signal regulation
Buck converter controlled with ZAD and FPIC for DC-DC signal regulationTELKOMNIKA JOURNAL
 
New controllers efficient model based design method
New controllers efficient model based design methodNew controllers efficient model based design method
New controllers efficient model based design methodAlexander Decker
 

Similar to Surge Swab pressure code (20)

Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
 
1D Simulation of intake manifolds in single-cylinder reciprocating engine
1D Simulation of intake manifolds in single-cylinder reciprocating engine1D Simulation of intake manifolds in single-cylinder reciprocating engine
1D Simulation of intake manifolds in single-cylinder reciprocating engine
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
 
reservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdf
reservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdfreservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdf
reservoir-modeling-using-matlab-the-matalb-reservoir-simulation-toolbox-mrst.pdf
 
ACS 22LIE12 lab Manul.docx
ACS 22LIE12 lab Manul.docxACS 22LIE12 lab Manul.docx
ACS 22LIE12 lab Manul.docx
 
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdfI need help understanding the Pan Tompkins algorythm, and Id also .pdf
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
 
Numerical Algorithm for a few Special Functions
Numerical Algorithm for a few Special FunctionsNumerical Algorithm for a few Special Functions
Numerical Algorithm for a few Special Functions
 
Solutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdfSolutions_Manual_to_accompany_Applied_Nu.pdf
Solutions_Manual_to_accompany_Applied_Nu.pdf
 
Comparison GUM versus GUM+1
Comparison GUM  versus GUM+1Comparison GUM  versus GUM+1
Comparison GUM versus GUM+1
 
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUBPresentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
Presentation 3 ce801 by Rabindra Ranjan Saha, PEng, Assoc. Prof. WUB
 
NASA 2004 PP
NASA 2004 PPNASA 2004 PP
NASA 2004 PP
 
Capsizing
CapsizingCapsizing
Capsizing
 
Drift flux
Drift fluxDrift flux
Drift flux
 
PID Control of True Integrating Processes - Greg McMillan Deminar
PID Control of True Integrating Processes - Greg McMillan DeminarPID Control of True Integrating Processes - Greg McMillan Deminar
PID Control of True Integrating Processes - Greg McMillan Deminar
 
Axial fan design
Axial fan designAxial fan design
Axial fan design
 
IC Design of Power Management Circuits (III)
IC Design of Power Management Circuits (III)IC Design of Power Management Circuits (III)
IC Design of Power Management Circuits (III)
 
577hw2s
577hw2s577hw2s
577hw2s
 
Price of anarchy is independent of network topology
Price of anarchy is independent of network topologyPrice of anarchy is independent of network topology
Price of anarchy is independent of network topology
 
Buck converter controlled with ZAD and FPIC for DC-DC signal regulation
Buck converter controlled with ZAD and FPIC for DC-DC signal regulationBuck converter controlled with ZAD and FPIC for DC-DC signal regulation
Buck converter controlled with ZAD and FPIC for DC-DC signal regulation
 
New controllers efficient model based design method
New controllers efficient model based design methodNew controllers efficient model based design method
New controllers efficient model based design method
 

Surge Swab pressure code

  • 1. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 1 of 13 % Surge/Swab Pressure Calculations Algorithm Version 1.0 % close all clear clc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Developed by Ankit Kukreja (ankit.kukreja.89@gmail.com) % on July 3rd, 2012 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% d=2.25; % Pipe ID (inch) d1=4; % Pipe OD (inch) d2=6.25; % Casing ID (inch) rho=9; % Fluid density (ppg) L= 10000; % Depth of well (ft) theta600=60.8; % Fann dial reading at 600 rpm theta300=37.4; % Fann dial reading at 300 rpm Cd=0.9697; % Discharge coefficient at nozzle Nsize=12; % Current nozzle size Nno=3; % Number of Nozzles currently in use qmin = 125; % Minimum flow rate (gpm) % Pump parameters Ppmax=3000; % Maximum achievable pump pressure PHP=1250; % Pump rating (Horsepower) e=0.91; % Pump efficiency % Enter the choice of criterion to choose % 1 - Maximum Jet impact force % 2 - Maximum drill bit hydraulic horsepower % 3 - Maximum jet velocity choice=1; % % Step 1 calculations % Flow behaviour parameter, n (dimensionless) n=3.32*log10(theta600/theta300) % Flow behaviour parameter, K (lbf/100 ft^2) K=510*theta300/(511^n) % Effective area through nozzle Aeff=(pi/4)*Nno*((Nsize/32)^2) % Maximum possible flow (gpm) qmax=1714*PHP*e/Ppmax % Selection of two flow rates q1=qmax/3 % Flow rate 1 (gpm) q2=2*qmax/3 % Flow rate 2 (gpm) % q1=350; % Flow rate 1 (gpm) % q2=550; % Flow rate 2 (gpm) %% % Calculation of pump pressure corresponding to flow rate q1 % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe1=q1/(2.448*(d^2)) % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann1=q1/(2.448*((d2^2)-(d1^2)));
  • 2. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 2 of 13 % Turbulence criteria of pipe, NRe_pipe NRe_pipe1=(89100*rho*(vbar_pipe1^(2-n))/K)*((0.0416*d/(3+(1/n)))^n); % Turbulence criteria of annulus, NRe_ann NRe_ann1=(109000*rho*(vbar_ann1^(2-n))/K)*((0.0208*(d2-d1)/(2+(1/n)))^n); % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReC1=2000; else if n<0.5 && n>=0.2 log_ReC1=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC1=10^(log_ReC1); end end if NRe_pipe1<ReC1 % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe1=K*(vbar_pipe1^n)*(((3+(1/n))/0.0416)^n)/(144000*(d^(1+n))) % Pump pressure, Pp deltaPp1 = L*Lam_Pgrad_pipe1 end if NRe_ann1<ReC1 % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann1=K*(vbar_ann1^n)*(((2+(1/n))/0.0208)^n)/(144000*((d2-d1)... ^(1+n))) end % Calculation of friction factor of pipe, f_pipe f_pipe1 = fsolve(@(f_pipe1)(sqrt(1/f_pipe1))-((4/(n^0.75))*log10... (NRe_pipe1*(f_pipe1^(1-(n/2)))))+(0.395/(n^1.2)),1) % Calculation of friction factor of annulus, f_ann f_ann1 = fsolve(@(f_ann1)(sqrt(1/f_ann1))-((4/(n^0.75))*log10... (NRe_ann1*(f_ann1^(1-(n/2)))))+(0.395/(n^1.2)),1) if NRe_pipe1>=ReC1 % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe1=(f_pipe1*rho*(vbar_pipe1^2))/(25.8*d) % Pump pressure, Pp deltaPp1 = L*Tur_Pgrad_pipe1 end if NRe_ann1>=ReC1 % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann1=(f_ann1*rho*(vbar_ann1^2))/(21.1*(d2-d1)) end % Pressure loss at bit, deltaPb deltaPb1=8.311*(10^(-5))*rho*(q1^2)/((Cd^2)*(Aeff^2)) % %% % Calculation of pump pressure corresponding to flow rate q2 % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe2=q2/(2.448*(d^2)) % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann2=q2/(2.448*((d2^2)-(d1^2))) % Turbulence criteria of pipe, NRe_pipe NRe_pipe2=(89100*rho*(vbar_pipe2^(2-n))/K)*((0.0416*d/(3+(1/n)))^n) % Turbulence criteria of annulus, NRe_ann NRe_ann2=(109000*rho*(vbar_ann2^(2-n))/K)*((0.0208*(d2-d1)/(2+(1/n)))^n) % Define critical Reynold number, ReC
  • 3. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 3 of 13 if n<=1 && n>=0.5 ReC2=2000; else if n<0.5 && n>=0.2 log_ReC2=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC2=10^(log_ReC2); end end if NRe_pipe2<ReC2 % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe2=K*(vbar_pipe2^n)*(((3+(1/n))/0.0416)^n)/(144000*(d^(1+n))) % Pump pressure, Pp deltaPp2 = L*Lam_Pgrad_pipe2 end if NRe_ann2<ReC2 % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann2=K*(vbar_ann2^n)*(((2+(1/n))/0.0208)^n)/(144000*... ((d2-d1)^(1+n))) end % Calculation of friction factor of pipe, f_pipe f_pipe2 = fsolve(@(f_pipe2)(sqrt(1/f_pipe2))-((4/(n^0.75))*... log10(NRe_pipe2*(f_pipe2^(1-(n/2)))))+(0.395/(n^1.2)),1) % Calculation of friction factor of annulus, f_ann f_ann2 = fsolve(@(f_ann2)(sqrt(1/f_ann2))-((4/(n^0.75))*... log10(NRe_ann2*(f_ann2^(1-(n/2)))))+(0.395/(n^1.2)),1) if NRe_pipe2>=ReC2 % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe2=(f_pipe2*rho*(vbar_pipe2^2))/(25.8*d) % Pump pressure, Pp deltaPp2 = L*Tur_Pgrad_pipe2 end if NRe_ann2>=ReC2 % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann2=(f_ann2*rho*(vbar_ann2^2))/(21.1*(d2-d1)) end % Pressure loss at bit, deltaPb deltaPb2=8.311*(10^(-5))*rho*(q2^2)/((Cd^2)*(Aeff^2)) % %% % Parasitic pressure loss deltaPd1=deltaPp1-deltaPb1 % Corresponding to flow rate q1 deltaPd2=deltaPp2-deltaPb2 % Corresponding to flow rate q2 % Slope of analysis plot m=(log10(deltaPd2/deltaPd1))/(log10(q2/q1)) %%%%%%%%%%%%%%%%% Path of optimum hydraulics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if choice==1 % For max jet impact force deltaPd_choice=(2/(m+2))*Ppmax end if choice==2 % For max bit hydraulic horsepower deltaPd_choice=(1/(m+1))*Ppmax end if choice==3
  • 4. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 4 of 13 % For max jet velocity deltaPd_choice=100 end % Path definition for qline=50:0.1:qmax deltaPdline=10^(log10(deltaPd1)+m*log10(qline/q1)); plot(log10(qline),log10(deltaPdline)) hold on if deltaPdline<=deltaPd_choice plot(log10(qmax),log10(deltaPdline),'r') hold on end if deltaPdline>=deltaPd_choice plot(log10(qmin),log10(deltaPdline),'r') hold on end if qline<=qmax && qline>=qmin plot(log10(qline),log10(deltaPd_choice),'r') hold on end plot(log10(qmin+1),log10(deltaPdline),'g') hold on for i=log10(100):0.1:log10(deltaPd_choice) if log10(deltaPdline)<=log10(i+1) && log10(deltaPdline)... >=log10(i-1) && log10(qline)<=log10(qmax+1) && ... log10(qline)>=log10(qmax-1) deltaPdopt=i; qopt=qline; end end if log10(deltaPdline)<=log10(deltaPd_choice+1) && ... log10(deltaPdline)>=log10(deltaPd_choice-1) && ... log10(qline)<log10(qmax) && log10(qline)>log10(qmin) deltaPdopt=deltaPd_choice; qopt=qline; end for k=log10(deltaPd_choice+1):0.1:log10(Ppmax) if log10(deltaPdline)<=k+1 && log10(deltaPdline)>=k-1 && ... log10(qline)<=log10(qmin+1) && log10(qline)>=log10(qmin-1) deltaPdopt=k; qopt=qline; end end end xlabel('Flow Rate (gpm)') ylabel('Parasitic Pressure Loss(psi)') grid on title('Well dynamics (in blue) and optimum hydraulic path(in red and green)') %% % Calculation of pump pressure corresponding to flow rate qopt % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipeopt=qopt/(2.448*(d^2)); % Average velocity of annulus, vbar_ann (ft/sec)
  • 5. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 5 of 13 vbar_annopt=qopt/(2.448*((d2^2)-(d1^2))); % Turbulence criteria of pipe, NRe_pipe NRe_pipeopt=(89100*rho*(vbar_pipeopt^(2-n))/K)*((0.0416*d/(3+(1/n)))^n) % Turbulence criteria of annulus, NRe_ann NRe_annopt=(109000*rho*(vbar_annopt^(2-n))/K)*((0.0208*(d2-d1)... /(2+(1/n)))^n) % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReCopt=2000; else if n<0.5 && n>=0.2 log_ReCopt=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReCopt=10^(log_ReCopt); end end if NRe_pipeopt<ReCopt % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipeopt=K*(vbar_pipeopt^n)*(((3+(1/n))/0.0416)^n)... /(144000*(d^(1+n))) % Pump pressure, Pp deltaPpopt = L*Lam_Pgrad_pipeopt end if NRe_annopt<ReCopt % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_annopt=K*(vbar_annopt^n)*(((2+(1/n))/0.0208)^n)/... (144000*((d2-d1)^(1+n))) end % Calculation of friction factor of pipe, f_pipe f_pipeopt = fsolve(@(f_pipeopt)(sqrt(1/f_pipeopt))-((4/(n^0.75))*... log10(NRe_pipeopt*(f_pipeopt^(1-(n/2)))))+(0.395/(n^1.2)),1) % Calculation of friction factor of annulus, f_ann f_annopt = fsolve(@(f_annopt)(sqrt(1/f_annopt))-((4/(n^0.75))*... log10(NRe_annopt*(f_annopt^(1-(n/2)))))+(0.395/(n^1.2)),1) if NRe_pipeopt>=ReCopt % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipeopt=(f_pipeopt*rho*(vbar_pipeopt^2))/(25.8*d) % Pump pressure, Pp deltaPpopt = L*Tur_Pgrad_pipeopt end if NRe_annopt>=ReCopt % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_annopt=(f_annopt*rho*(vbar_annopt^2))/(21.1*(d2-d1)) end % Optimum bit pressure loss deltaPbopt=deltaPpopt-deltaPdopt % Proper total nozzle area Aeffopt=sqrt(8.311*(10^-5)*rho*(qopt^2)/((Cd^2)*deltaPbopt)) % Surge/Swab Pressure calculation starts from here % surgecp = surge with closed pipe % surgeop = surge with open pipe % K for closed pipe is tuned to value:
  • 6. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 6 of 13 K_cp=1.527; % Is the pipe is moving up or down? % Down - 1 % Up - 2 direction=2; vp=1/3; % Tripping speed (ft/s) if direction==1 disp('Calculating surge pressure for closed pipe..') % For closed pipe q_surgecp=vp*pi*(d1^2)/4; % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe_surgecp=0; % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann_surgecp=q_surgecp/(2.448*((d2^2)-(d1^2)))+(K_cp*vp); % Turbulence criteria of pipe, NRe_pipe NRe_pipe_surgecp=(89100*rho*(vbar_pipe_surgecp^(2-n))/K)... *((0.0416*d/(3+(1/n)))^n) % Turbulence criteria of annulus, NRe_ann NRe_ann_surgecp=(109000*rho*(vbar_ann_surgecp^(2-n))/K)*((0.0208*(d2-d1)... /(2+(1/n)))^n) % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReC_surgecp=2000; else if n<0.5 && n>=0.2 log_ReC_surgecp=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC_surgecp=10^(log_ReC_surgecp); end end if NRe_pipe_surgecp<ReC_surgecp % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe_surgecp=K*(vbar_pipe_surgecp^n)*(((3+(1/n))/0.0416)^n)... /(144000*(d^(1+n))); % Pump pressure, Pp deltaPp_surgecp = L*Lam_Pgrad_pipe_surgecp end if NRe_ann_surgecp<ReC_surgecp % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann_surgecp=K*(vbar_ann_surgecp^n)*(((2+(1/n))/0.0208)^n)/... (144000*((d2-d1)^(1+n))); % Annular pressure, Pa deltaPa_surgecp = L*Lam_Pgrad_ann_surgecp end % Calculation of friction factor of pipe, f_pipe f_pipe_surgecp = fsolve(@(f_pipe_surgecp)(sqrt(1/f_pipe_surgecp))... -((4/(n^0.75))*log10(NRe_pipe_surgecp*(f_pipe_surgecp^... (1-(n/2)))))+(0.395/(n^1.2)),1); % Calculation of friction factor of annulus, f_ann f_ann_surgecp = fsolve(@(f_ann_surgecp)(sqrt(1/f_ann_surgecp))-((4/(n^0.75))*... log10(NRe_ann_surgecp*(f_ann_surgecp^(1-(n/2)))))+(0.395/(n^1.2)),1);
  • 7. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 7 of 13 if NRe_pipe_surgecp>=ReC_surgecp % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe_surgecp=(f_pipe_surgecp*rho*(vbar_pipe_surgecp^2))/(25.8*d); % Pump pressure, Pp deltaPp_surgecp = L*Tur_Pgrad_pipe_surgecp end if NRe_ann_surgecp>=ReC_surgecp % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann_surgecp=(f_ann_surgecp*rho*(vbar_ann_surgecp^2))/(21.1*(d2-d1)); % Annular pressure, Pa deltaPa_surgecp = L*Tur_Pgrad_ann_surgecp end disp('Calculating Equivalent Mud Weight for closed pipe..') rho_c=rho+(231/(12*deltaPa_surgecp)) disp('Calculating surge pressure for open pipe..') % For open pipe K_op=1.2; for fa=0:0.01:1 qa_surgeop=fa*vp*((pi*(d1^2)/4)-Aeffopt); qp_surgeop=(1-fa)*vp*((pi*(d1^2)/4)-Aeffopt); % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op*vp); % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op*vp); % Turbulence criteria of pipe, NRe_pipe NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*... ((0.0416*d/(3+(1/n)))^n); % Turbulence criteria of annulus, NRe_ann NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)... /(2+(1/n)))^n); % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReC_surgeop=2000; else if n<0.5 && n>=0.2 log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC_surgeop=10^(log_ReC_surgeop); end end if NRe_pipe_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)... /(144000*(d^(1+n))); % Pump pressure, Pp deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop; end if NRe_ann_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/...
  • 8. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 8 of 13 (144000*((d2-d1)^(1+n))); % Annular pressure, Pa deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop; end % Calculation of friction factor of pipe, f_pipe f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-... ((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^... (1-(n/2)))))+(0.395/(n^1.2)),1); % Calculation of friction factor of annulus, f_ann f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))... -((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^(1-(n/2)))))... +(0.395/(n^1.2)),1); if NRe_pipe_surgeop>=ReC_surgeop % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d); % Pump pressure, Pp deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop; end if NRe_ann_surgeop>=ReC_surgeop % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1)); % Annular pressure, Pa deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop; end if deltaPa_surgeop - deltaPp_surgeop <1 fa_final=fa; end end qa_surgeop=fa_final*vp*((pi*(d1^2)/4)-Aeffopt); qp_surgeop=(1-fa_final)*vp*((pi*(d1^2)/4)-Aeffopt); % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op*vp); % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op*vp); % Turbulence criteria of pipe, NRe_pipe NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*... ((0.0416*d/(3+(1/n)))^n); % Turbulence criteria of annulus, NRe_ann NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)... /(2+(1/n)))^n); % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReC_surgeop=2000; else if n<0.5 && n>=0.2 log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC_surgeop=10^(log_ReC_surgeop); end end
  • 9. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 9 of 13 if NRe_pipe_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)... /(144000*(d^(1+n))); % Pump pressure, Pp deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop end if NRe_ann_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/... (144000*((d2-d1)^(1+n))); % Annular pressure, Pa deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop end % Calculation of friction factor of pipe, f_pipe f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-... ((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^... (1-(n/2)))))+(0.395/(n^1.2)),1); % Calculation of friction factor of annulus, f_ann f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))... -((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^... (1-(n/2)))))+(0.395/(n^1.2)),1); if NRe_pipe_surgeop>=ReC_surgeop % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d); % Pump pressure, Pp deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop end if NRe_ann_surgeop>=ReC_surgeop % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1)); % Annular pressure, Pa deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop end disp('Calculating Equivalent Mud Weight for open pipe..') rho_o=rho+(231/(12*deltaPa_surgeop)) end if direction==2 disp('Calculating swab pressure for closed pipe..') % For closed pipe q_surgecp=vp*pi*(d1^2)/4; % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe_surgecp=0; % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann_surgecp=q_surgecp/(2.448*((d2^2)-(d1^2)))+(K_cp*vp); % Turbulence criteria of pipe, NRe_pipe NRe_pipe_surgecp=(89100*rho*(vbar_pipe_surgecp^(2-n))/K)*...
  • 10. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 10 of 13 ((0.0416*d/(3+(1/n)))^n); % Turbulence criteria of annulus, NRe_ann NRe_ann_surgecp=(109000*rho*(vbar_ann_surgecp^(2-n))/K)*((0.0208*(d2-d1)... /(2+(1/n)))^n); % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReC_surgecp=2000; else if n<0.5 && n>=0.2 log_ReC_surgecp=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC_surgecp=10^(log_ReC_surgecp); end end if NRe_pipe_surgecp<ReC_surgecp % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe_surgecp=K*(vbar_pipe_surgecp^n)*(((3+(1/n))/0.0416)^n)... /(144000*(d^(1+n))); % Pump pressure, Pp deltaPp_surgecp = L*Lam_Pgrad_pipe_surgecp end if NRe_ann_surgecp<ReC_surgecp % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann_surgecp=K*(vbar_ann_surgecp^n)*(((2+(1/n))/0.0208)^n)/... (144000*((d2-d1)^(1+n))); % Annular pressure, Pa deltaPa_surgecp = L*Lam_Pgrad_ann_surgecp end % Calculation of friction factor of pipe, f_pipe f_pipe_surgecp = fsolve(@(f_pipe_surgecp)(sqrt(1/f_pipe_surgecp))-... ((4/(n^0.75))*log10(NRe_pipe_surgecp*(f_pipe_surgecp^... (1-(n/2)))))+(0.395/(n^1.2)),1); % Calculation of friction factor of annulus, f_ann f_ann_surgecp = fsolve(@(f_ann_surgecp)(sqrt(1/f_ann_surgecp))-((4/(n^0.75))*... log10(NRe_ann_surgecp*(f_ann_surgecp^(1-(n/2)))))+(0.395/(n^1.2)),1); if NRe_pipe_surgecp>=ReC_surgecp % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe_surgecp=(f_pipe_surgecp*rho*(vbar_pipe_surgecp^2))/(25.8*d); % Pump pressure, Pp deltaPp_surgecp = L*Tur_Pgrad_pipe_surgecp end if NRe_ann_surgecp>=ReC_surgecp % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann_surgecp=(f_ann_surgecp*rho*(vbar_ann_surgecp^2))... /(21.1*(d2-d1)); % Annular pressure, Pa deltaPa_surgecp = L*Tur_Pgrad_ann_surgecp end disp('Calculating Equivalent Mud Weight for closed pipe..') rho_c=rho-(231/(12*deltaPa_surgecp)) disp('Calculating swab pressure for open pipe..') % For open pipe K_op1=1.2; K_op2=1.2; for fa=0:0.01:1
  • 11. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 11 of 13 qa_surgeop=fa*vp*((pi*(d1^2)/4)-Aeffopt); qp_surgeop=(1-fa)*vp*((pi*(d1^2)/4)-Aeffopt); % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op1*vp); % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op2*vp); % Turbulence criteria of pipe, NRe_pipe NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*((0.0416*d... /(3+(1/n)))^n); % Turbulence criteria of annulus, NRe_ann NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)... /(2+(1/n)))^n); % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReC_surgeop=2000; else if n<0.5 && n>=0.2 log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC_surgeop=10^(log_ReC_surgeop); end end if NRe_pipe_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)... /(144000*(d^(1+n))); % Pump pressure, Pp deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop; end if NRe_ann_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/... (144000*((d2-d1)^(1+n))); % Annular pressure, Pa deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop; end % Calculation of friction factor of pipe, f_pipe f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-... ((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^... (1-(n/2)))))+(0.395/(n^1.2)),1); % Calculation of friction factor of annulus, f_ann f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))-... ((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^... (1-(n/2)))))+(0.395/(n^1.2)),1); if NRe_pipe_surgeop>=ReC_surgeop % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d); % Pump pressure, Pp deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop; end if NRe_ann_surgeop>=ReC_surgeop
  • 12. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 12 of 13 % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1)); % Annular pressure, Pa deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop; end if deltaPa_surgeop - deltaPp_surgeop <1 fa_final=fa; end end qa_surgeop=fa_final*vp*((pi*(d1^2)/4)-Aeffopt); qp_surgeop=(1-fa_final)*vp*((pi*(d1^2)/4)-Aeffopt); % Average velocity of pipe, vbar_pipe (ft/sec) vbar_pipe_surgeop=qp_surgeop/(2.448*(d^2))+(K_op1*vp); % Average velocity of annulus, vbar_ann (ft/sec) vbar_ann_surgeop=qa_surgeop/(2.448*((d2^2)-(d1^2)))+(K_op2*vp); % Turbulence criteria of pipe, NRe_pipe NRe_pipe_surgeop=(89100*rho*(vbar_pipe_surgeop^(2-n))/K)*((0.0416*d/... (3+(1/n)))^n); % Turbulence criteria of annulus, NRe_ann NRe_ann_surgeop=(109000*rho*(vbar_ann_surgeop^(2-n))/K)*((0.0208*(d2-d1)... /(2+(1/n)))^n); % Define critical Reynold number, ReC if n<=1 && n>=0.5 ReC_surgeop=2000; else if n<0.5 && n>=0.2 log_ReC_surgeop=((0.5-n)*(log10(2.1))/0.3)+log10(2000); ReC_surgeop=10^(log_ReC_surgeop); end end if NRe_pipe_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of pipe Lam_Pgrad_pipe_surgeop=K*(vbar_pipe_surgeop^n)*(((3+(1/n))/0.0416)^n)... /(144000*(d^(1+n))); % Pump pressure, Pp deltaPp_surgeop = L*Lam_Pgrad_pipe_surgeop end if NRe_ann_surgeop<ReC_surgeop % If flow is laminar, frictional pressure loss gradient of annulus Lam_Pgrad_ann_surgeop=K*(vbar_ann_surgeop^n)*(((2+(1/n))/0.0208)^n)/... (144000*((d2-d1)^(1+n))); % Annular pressure, Pa deltaPa_surgeop = L*Lam_Pgrad_ann_surgeop end % Calculation of friction factor of pipe, f_pipe f_pipe_surgeop = fsolve(@(f_pipe_surgeop)(sqrt(1/f_pipe_surgeop))-... ((4/(n^0.75))*log10(NRe_pipe_surgeop*(f_pipe_surgeop^(1-(n/2)))))... +(0.395/(n^1.2)),1); % Calculation of friction factor of annulus, f_ann f_ann_surgeop = fsolve(@(f_ann_surgeop)(sqrt(1/f_ann_surgeop))-... ((4/(n^0.75))*log10(NRe_ann_surgeop*(f_ann_surgeop^(1-(n/2)))))... +(0.395/(n^1.2)),1);
  • 13. 7/3/12 2:53 PM C:UserskukrejankitDesktopCoursestribologys...code2.m 13 of 13 if NRe_pipe_surgeop>=ReC_surgeop % If flow is turbulent, frictional pressure loss gradient of pipe Tur_Pgrad_pipe_surgeop=(f_pipe_surgeop*rho*(vbar_pipe_surgeop^2))/(25.8*d); % Pump pressure, Pp deltaPp_surgeop = L*Tur_Pgrad_pipe_surgeop end if NRe_ann_surgeop>=ReC_surgeop % If flow is turbulent, frictional pressure loss gradient of annulus Tur_Pgrad_ann_surgeop=(f_ann_surgeop*rho*(vbar_ann_surgeop^2))/(21.1*(d2-d1)); % Annular pressure, Pa deltaPa_surgeop = L*Tur_Pgrad_ann_surgeop end disp('Calculating Equivalent Mud Weight for open pipe..') rho_o=rho-(231/(12*deltaPa_surgeop)) end % End of code