import math
#calculate the
##given data
Q = 2.272;##water volume flow rate in m**3/s
l = 300.;##length in m
Hf = 20.;##head loss in m
f = 0.01;##friction factor
g = 9.81;##acceleration due to gravity in m/s**2
##Calculations
d = (32.*f*l*((Q/math.pi)**2)/(g*Hf))**(1/5.);
##Results
print'%s %.2f %s'%('The diameter of the pipe = ',d,' m');
import math
#calculate the
##given data
P = 4.0;##in MW
N = 375.;##in rev/min
H_eps = 200.;##in m
KN = 0.98;##nozzle velocity coefficient
d = 1.5;##in m
k = 0.15;##decrease in relative flow velocity across the buckets
alpha = 165.;##in deg
g = 9.81;##in m/s^2
rho = 1000.;##in kg/m^3
##Calculations
U = N*math.pi*d*0.5/30.;
c1 = KN*math.sqrt(2*g*H_eps);
nu = U/c1;
eff = 2.*nu*(1.-nu)*(1.-(1.-k)*math.cos(alpha*math.pi/180.));
Q = (P*10**6 /eff)/(rho*g*H_eps);
Aj = Q/(2.*c1);
dj = math.sqrt(4.*Aj/math.pi);
omega_sp = (N*math.pi/30.)*math.sqrt((P*10**6)/rho)/((g*H_eps)**(5./4.));
##Results
print'%s %.2f %s'%('(i)The runner efficiency = ',eff,'');
print'%s %.2f %s'%('\n (ii)The diameter of each jet = ',dj,' m');
print'%s %.2f %s'%('\n (iii)The power specific speed = ',omega_sp,' rad');
import math
#calculate the
##given data
H_eps = 150.;##in m
z = 2.;##in m
U2 = 35.;##runner tip speed in m/s
c3 = 10.5;##meridonal velocity of water in m/s
c4 = 3.5;##velocity at exit in m/s
delHN = 6.0;##in m
delHR = 10.0;##in m
delHDT = 1.0;##in m
g = 9.81;##in m/s**2
Q = 20.;##in m**3/s
omega_sp = 0.8;##specific speed of turbine in rad
c2 = 38.73;##in m/s
##Calculations
H3 = ((c4**2. - c3**2.)/(2.*g)) + delHDT - z;
H2 = H_eps-delHN-(c2**2.)/(2.*g);
delW = g*(H_eps-delHN-delHR-z)-0.5*c3**2 -g*H3;
ctheta2 = delW/U2;
alpha2 = (180./math.pi)*math.atan(ctheta2/c3);
beta2 = (180./math.pi)*math.atan((ctheta2-U2)/c3);
eff_H = delW/(g*H_eps);
omega = (omega_sp*(g*H_eps)**(5./4.))/math.sqrt(Q*delW);
N = omega*30./math.pi;
D2 = 2.*U2/omega;
##Results
print'%s %.2f %s %.2f %s'%('(i)The pressure head H3 relative to the trailrace = ',H3,' m'and'\n The pressure head H2 at exit from the runner =',H2,' m');
print'%s %.2f %s %.2f %s '%('\n(ii)The flow angles at runner inlet and at guide vane exit:\n alpha2 = ',alpha2,' deg'and '\n beta2 = ',beta2,' deg');
print'%s %.2f %s'%('\n(iii)The hydraulic efficiency of the turbine = ',eff_H,'');
print'%s %.2f %s'%('\n The speed of rotation, N = ',N,' rev/min');
print'%s %.2f %s'%('\n The runner diameter is, D2 = ',D2,' m');
##there are small errors in the answers given in textbook
import math
#calculate the
##function to calculate flow angles
##given data
P = 8;##output power in MW
HE = 13.4;##available head at entry in m
N = 200;##in rev/min
L = 1.6;##length of inlet guide vanes
d1 = 3.1;##diameter of trailing edge in m
D2t = 2.9;##runner diameter in m
nu = 0.4;##hub-tip ratio
eff = 0.92;##hydraulic efficiency
rho = 1000;##density in kg/m**3
g = 9.81;##acceleration due to gravity in m/s**2
r=1.45
##Calculations
Q = P*10**6 /(eff*rho*g*HE);
cr1 = Q/(2*math.pi*0.5*d1*L);
cx2 = 4*Q/(math.pi*D2t**2 *(1-nu**2));
U2 = N*(math.pi/30)*D2t/2;
ctheta2 = eff*g*HE/U2;
ctheta1 = ctheta2*(D2t/d1);
alpha1 = (180/math.pi)*math.atan(ctheta1/cr1);
alpha2 = (180/math.pi)*math.atan(ctheta2/cx2);
beta2 = (180/math.pi)*math.atan((U2)*(r)/cx2 - math.tan(alpha2*math.pi/180));
beta3 = (180/math.pi)*math.atan((U2)*r/cx2) ;
alpha23=39.86
alpha22=25.51
alpha21=18.47
beta23=10.42
beta22=52.56
beta21=65.68
##Results
print('Calculated values of flow angles:\n Parameter Ratio of r/ri ');
print('\n ------------------------------------------------------------');
print('\n 0.4 0.7 1.0');
print('\n --------------------------------------');
print'%s %.2f %s %.2f %s %.2f %s '%('\n ctheta2(in m/s) ',ctheta2/0.4,''and '',ctheta2/0.7,''and '',ctheta2/1.0,'');
print'%s %.2f %s %.2f %s %.2f %s '%('\n tan(alpha2) ',math.tan(alpha23*math.pi/180),''and '',math.tan(alpha22*math.pi/180),'' and '',math.tan(alpha21*math.pi/180),'');
print'%s %.2f %s %.2f %s %.2f %s '%('\n alpha2(deg) ',alpha23,''and '',alpha22,''and '',alpha21,'');
print'%s %.2f %s %.2f %s %.2f %s '%('\n U/cx2 ',(U2/cx2)*0.4,''and '',(U2/cx2)*0.7,''and '',(U2/cx2)*1.0,'');
print'%s %.2f %s %.2f %s %.2f %s '%('\n beta2(deg) ',beta23,''and '',beta22,'' and '',beta21,'');
print('\n ------------------------------------------------------------');
import math
#calculate the
##given data
k = 1/5.;##scale ratio
Pm = 3.;##in kW
Hm = 1.8;##in m
Nm = 360.;##in rev/min
Qm = 0.215;##in m^3/s
Hp = 60.;##in m
n = 0.25;
rho = 1000;##in kg/m^3
g = 9.81;##in m/s^2
##Calculations
Np = Nm*k*(Hp/Hm)**0.5;
Qp = Qm*(Nm/Np)*(1./k)**3;
Pp = Pm*((Np/Nm)**3)*(1./k)**5;
eff_m = Pm*1000./(rho*Qm*g*Hm);
eff_p = 1 - (1.-eff_m)*0.2**n;
Pp_corrected = Pp*eff_p/eff_m;
##Results
print'%s %.2f %s'%('The speed = ',Np,' rev/min.');
print'%s %.2f %s'%('\n The flow rate =',Qp,' m^3/s.');
print'%s %.2f %s'%('\n Power of the full-scale = ',Pp/1000,' MW.');
print'%s %.2f %s'%('\n The efficiency of the model turbine = ',eff_m,'');
print'%s %.2f %s'%('\n The efficiency of the prototype = ',eff_p,'');
print'%s %.2f %s'%('\n The power of the full-size turbine = ',Pp_corrected/1000,' MW.')
import math
#calculate the
##given data
##data from EXAMPLE 9.3
H_eps = 150.;##in m
z = 2.;##in m
U2 = 35.;##runner tip speed in m/s
c3 = 10.5;##meridonal velocity of water in m/s
c4 = 3.5;##velocity at exit in m/s
delHN = 6.0;##in m
delHR = 10.0;##in m
delHDT = 1.0;##in m
g = 9.81;##in m/s**2
Q = 20.;##in m**3/s
omega_sp = 0.8;##specific speed of turbine in rad
c2 = 38.73;##in m/s
##data from this example
Pa = 1.013;##atmospheric pressure in bar
Tw = 25.;##temperature of water in degC
Pv = 0.03166;##vapor pressure of water at Tw
rho = 1000;##density of wate in kg/m**3
g = 9.81;##acceleration due to gravity in m/s**2
H3 = ((c4**2. - c3**2.)/(2.*g)) + delHDT - z;
H2 = H_eps-delHN-(c2**2.)/(2.*g);
delW = g*(H_eps-delHN-delHR-z)-0.5*c3**2 -g*H3;
ctheta2 = delW/U2;
alpha2 = (180/math.pi)*math.atan(ctheta2/c3);
beta2 = (180/math.pi)*math.atan((ctheta2-U2)/c3);
eff_H = delW/(g*H_eps);
omega = (omega_sp*(g*H_eps)**(5/4.))/math.sqrt(Q*delW);
Hs = (Pa-Pv)*(10**5)/(rho*g) - z;
sigma = Hs/H_eps;
omega_ss = omega*(Q**0.5)/(g*Hs)**(3/4.);
##Results
print'%s %.2f %s'%('The NSPH for the turbine = ',Hs,' m.');
if omega_ss>4.0:
print'%s %.2f %s'%('\n Since the suction specific speed (= ',omega_ss,')is greater than 4.0(rad), the cavitation is likely to occur.');
##there is small error in the answer given in textbook