I have to optimise the cost of a liquid pipeline with single variable( i.e. diameter of pipeline) genetic algorithm and I have written the algorithm but my program is not giving me the results. Please correct the error in my algorithm.
2 views (last 30 days)
Show older comments
{ function [TC]=costopti(x)
D=x(1);
%Diameter to be optimized
L=[11.298,21.394,25.0410,25.743,20.717,24.203]; TC=0;
%distance between sv stations along the pipeline route in (km).Also includes the highest point
e=.045;
%internal roughness of the pipeline in (nm)
Qo=640;
MAOP=1000;
%Design factor of offshore liquid pipelines
SMYS=60000;
T=6.35;
DI=D-(2*T);
%thickness of the pipelines in (mm)
V=4.7290;
%Kinematic Viscosity at 40?C, V (cst)
S=0.8359;
%Specific Gravity at 40?C, (no units)
F=15;
%Transmission factor (no units)
H=[15,-10,-91,-301,-36,-25];
%Elevation along the pipeline route in (meter)
P1(1,1)=x(2);
%Inlet pressure to the pipeline in (kg/m2) considering the possible diameters to find the pressure provide along the pipeline
Re=(353678*Qo)/(V*DI);
%Reynolds number for all possible diameters (no units)
F=-4*log10(e/(3.7*DI)+(1.255*(F/Re)));
%Finding the transmission factor by trial and error method for each diameters taken(no units)
Pkm=24.99*(10^10*((Qo/F)^2)*(S/DI^5));
%Pressure drop per km in kPa due to friction for the possible diameter for each diameter pressure loss due to friction and pressure loss due to elevation changes is to be found
for i=1:6
Pf(i,1)=Pkm*L(i)*0.0102;
%Pressure drop due to friction along the pipelines route
(kg/cm2)
Pe(1,i)=(H(i)*S/.102)*0.0102;
%Pressure drop due to elevation along the pipeline route
P1(i+1,1)=P1(i,1)-Pe(1,i)-Pf(i,1); PL(i,1)=(P1(i+1,1)-P1(i,1));
%pressure loss between stations in (kg/cm2)
totalPL1=sum(PL); Prloss=-[totalPL1];
%Pressure profile along the pipelines route for 12 inch diameter pipeline end
Le=128.396;
%Total length of pipelines in Km
Cpt=600;
%Cost of carbon steel per tonne in USD
PMC=0.02463*Le*(D-T)*T*(Cpt);
%Pipe Material Cost for the whole length of pipeline in USD
PC=PMC*60;
%Pipe material cost in rupees
V1=7.855*(10^-4)*(DI^2);
VL=V1*128.396;
LFC=VL*1000*55;
b=3.8620;
if x(2)-b>=0;
%by calculations it is known that if Hassan pumps are commissioned the product will be delivered at a pressure of 3.8620 kg/cm2 at Bangalore
Pr=x(2);
%operating cost is calculated by considering Bangalore outlet pressure
PPr=1.2*x(2);
%Mostly pumps run at 80 percent of its maximum capacity
Psig1=Pr*14.2233;
%kg/cm2 to psig conversion
Head1=2.31*Psig1/S;
%head necessary for operation in (ft)
Q=16924.45;
%flow rate in (lb/min)
HP1=(Q*Head1)/33000;
%Horse power required while operation
Psig=PPr*14.2233;
Head=2.31*Psig/S;
HP=(Q*Head)/33000;
%Horse Power required for structuring pump
PSC=1500*HP*60;
%Pump station cost by considering a multiplication factor
BHP=HP1/(.80*.90*.95);
%Brake Horse of Bangalore pumps power by considering pump efficiency ,motor or driver efficiency ,mechanical efficiency
OpC=BHP*24*350*0.08*0.746*60*30;
%Operating cost of Bangalore pumps by considering 30 years of operation
TC=PC+PSC+OpC+LFC;
%total cost by considering pipeline cost, pumps station cost, operation cost of Bangalore pumps else
Pr=x(2)-5.0438+26.9421;
%Outlet pressure from Bangalore if Hassan pumps are commissioned by considering pressure loss/gain due to elevation and friction
Psig1=Pr*14.2233; Head1=2.31*Psig1/S; Q=16924.45;
HP1=(Q*Head1)/33000;
BHP=HP1/(.80*.90*.95); OpC=BHP*24*350*0.08*0.746*60*30;
%Operating cost of Hassan Pumps by considering 30 years of operation
TC=PC+OpC+LFC;
disp('Total Cost') disp(TC) %total cost by considering pipe cost & operation cost Of Hassan pumps
end }
function [gineq geq]=progconstraint(x) D=x(1);
P1=x(2);
P2=x(3);
P3=x(4);
P4=x(5);
P5=x(6);
P6=x(7);
P7=x(8);
L=[11.298,21.394,25.0410,25.743,20.717,24.203];
e=.045;
%internal roughness in nm.
Qo=640;
%Maximum flow rate
T=6.35;
DI=D-(2*T);
V=4.7290;
S=0.8359;
F=15;
H=[15,-10,-91,-301,-36,-25];
Re=(353678*Qo)/(V*DI);
F=-4*log10((e/(3.7*DI)+1.255*(F/Re)));
Pkm=24.99*(10^10*((Qo/F^2)*(S/DI^5)));
for i=1:6;
Pf(1,i)=Pkm*L(i)*0.0102;
Pe(1,i)=(H(i)*S/.102)*0.0102;
end
geq(1)=P2-(P1-Pe(1,1)-Pf(1,1));
geq(2)=P3-(P2-Pe(1,2)-Pf(1,2));
geq(3)=P4-(P3-Pe(1,3)-Pf(1,3));
geq(4)=P5-(P4-Pe(1,4)-Pf(1,4));
geq(5)=P6-(P5-Pe(1,5)-Pf(1,5));
geq(6)=P7-(P6-Pe(1,6)-Pf(1,6));
%equality constraints
gineq(1)=3-P1;
gineq(2)=3-P2;
gineq(3)=3-P3;
gineq(4)=3-P4;
gineq(5)=3-P5;
gineq(6)=3-P6;
gineq(7)=3-P7;
%In equality constraints .Pressure at any points along the pipeline should be more than 3kg/cm2 to avoid loss due to interface mix end
1 Comment
Alan Weiss
on 13 Mar 2018
Please use the {} Code button to mark up your code so that we can read it.
Alan Weiss
MATLAB mathematical toolbox documentation
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!