// Branched pipeline program
#include <iostream.h>
int main ()
{
// input data
double g,t,ea,eb,ec,f1,f2,f3,l1,l2,l3,d1,d2,d3,r1,r2,r3,q1,q2,q3,q11,q22
double q33,q
g=9.8;
t=.001; // Tolerance value
// head of tanks (m)
ea=30;
eb=27;
ec=17;
// length of pipes (m)
l1=1000;
l2=300;
l3=600;
// value of friction losses at each pipe
f1=.03;
f2=.03;
f3=.04;
// diameter of each pipe (m)
d1=.3;
d2=.2;
d3=.2;
// Calculation method
// A- Get resistance in all pipes
r1=(0.8*f1*l1)/(g*(d1)^5);
r2=(0.8*f2*l2)/(g*(d2)^5);
r3=(0.8*f3*l3)/(g*(d3)^5);
for(ej=ec;ej<=ea;ej+.6)
{
q1=sqrt(((ea-ej)/r1));
q2=sqrt(((ej-eb)/r2));
q3=sqrt(((ej-ec)/r3));
if (abs(q1-q2-q3)<=t);
cout << ej;
break
else (ej=ea:ej>=ec:ej-.6:);
cout << ej;
cout << q;
}
cout << "ej ==" <<ej << endl;
cout << "q1 ==" <<q1 << endl;
cout << "q2 ==" <<q2 << endl;
cout << "q3 ==" <<q3 << endl;
}
and here the correct matlab source:
% this program is made to get the flow rate of 3 pipe networks connected to % different tanks at different levels clear clc %>>>>>>>>>>>>>>>>>> PROBLEM GIVEN DATA <<<<<<<<<<<<<<<<<<<<<<<< g=9.8 ; t=.001; % tolerance factor % head of tanks (m) ea=30; eb=27; ec=17; % length of pipes (m) l1=1000; l2=300; l3=600; % value of friction losses at each pipe f1=.03; f2=.03; f3=.04; %diameter of each pipe (m) d1=.3; d2=.2; d3=.2; % ------------- /// Calculation Method \\\ ------------- % get resistance in all pipes r1=(0.8*f1*l1)/(g*(d1)^5); r2=(0.8*f2*l2)/(g*(d2)^5); r3=(0.8*f3*l3)/(g*(d3)^5); for ej=ec:.6:ea; % get flow rate in each pipe q1=sqrt(((ea-ej)/r1)); q2=sqrt(((ej-eb)/r2)); q3=sqrt(((ej-ec)/r3)); q=q1-q2-q3; if abs(q)<=t; ej; break else ej=ea:-.6:ec; display(ej) display(q) end end % display all results display(ej) display(q1) display(q2) display(q3)
so any one could help me
MOD EDIT: When posting code...USE CODE TAGS!!!
This post has been edited by JackOfAllTrades: 28 October 2010 - 02:08 PM

New Topic/Question
Reply




MultiQuote




|