import math
#given data
V=10.0;#volumne of bucket in galon
t=50;#time taken to fill the bucket in sec
p=1;#density of water in kg/L
re=0.8/2/100;#radius of nozzle exit in m
#calculations
Vd=V/t*3.7854;#factor 0f 3.7854 for gal to L
print'volumne flow rate through hose %f L/s'%round(Vd,3);
m=p*Vd;
print'mass flow rate through hose %f kg/s'%round(m,3);
Ae=math.pi*re**2;
Ve=Vd/Ae/1000;#factor of 1000 for L to m^3
print'average velocity at the nozzle %f m/s'%round(Ve,1);
import math
from scipy.integrate import quad
from pylab import *
#given data
Dtank=3*12;#diameter of tank in inches
Djet=0.5;#diameter of water jet in inches
h0=2;#bottom reference in ft
h1=4;#height of water tank in ft
#constants used
g=32.2;#in ft/s^2
#calculations
#min - mout = dmCV/dt
#mout = p*(2*g*h*Ajet)^2
#mCV = p*Atank*h
#from these we get dt = Dtank^2/Djet^2 * (dh/(2*g*h)^2)
def intgrnd1(h):
return (Dtank**2/Djet**2*(1/sqrt(2*g*h)))
t, err = quad(intgrnd1, h0, h1)
t=(t/60);#in min
print'time taken to drop to 2 ft %f min'%round(t,1)
#given data
P=150;#operating pressure in kPa
Vliquid=0.6/1000.0;#amount of liquid in the cooker in m^3
t=40.0*60;#period of operation in sec
Ac=8*10**-6;#exit area of opening in m^2
#from Table A-5
#from P = 150 kPa
h=2693.1;
ug=2519.2;
vf=0.001053;
vg=1.1594;
#calculations
m=Vliquid/vf;
md=m/t;
print'mass flow rate %f kg/s'%md;
V=md*vg/(Ac);
print'exit velocity %f m/s'%round(V,1);
Eflow=h-ug;
Et=h;
print'flow energy %f kJ/kg'%round(Eflow,1);
print'total energy %f kJ/kg'%round(Et,1);
Emass=md*Et;
print'rate at which energy leaves the cooker %f kW'%round(Emass,3)
#given data
T1=283;#temperature of air in K
P1=80;#entering pressure in kPa
V1=200;#velocity ar inlet in m/s
A1=0.4;#inlet area in m^2
#constants used
R=0.287;#in kPa-m^3/kg-K
#calulations
v1=R*T1/P1;
m=V1*A1/v1;
print'mass flow rate of air %f kg/s'%round(m,1);
# Ein - Eout = dEsystem / dt
#from Table A-17
h1=283.14;
V2=0;
h2=h1-(V2^2 - V1^2)/2/1000;#factor of 1000 to convert to kJ/kg
#from Table A-17 at this value of h2
T2=303;
print'the temperature %i K is'%T2;
#given data
P1=250;#inlet pressure in psia
T1=700;#inlet temp in F
A1=0.2;#inlet area in ft^2
qout=1.2;#heat losses in Btu/lbm
m=10;#mass flow rate in lbm/sec
P2=200;#nozzle pressure in kPa
V2=900;#nozzle velocity in m/s
#from Table A-6E
v1=2.6883;
h1=1371.4;
#calculations
V1=m*v1/A1;
print'the inlet velocit %f f/s'%round(V1,1);
# Ein - Eout = dEsystem / dt
h2=h1-qout-(V2**2 - V1**2)/2/25037;#factor of 25037 to convert to Btu/lbm
#at this value h2, from Tablw A-6E
T2=662;
print'exit temperature %i F'%T2
#given data
T1=280;#intial pressure in kPa
P1=100;#intial temp in K
m=0.02;#mass flow rate in kg/s
qout=16;#heat losses in kJ/kg
P2=600;#final pressure in kPa
T2=400;#final temp in K
#from Table A-17
h1=280.13;
h2=400.98;
#calculations
# Ein - Eout = dEsystem / dt
Win=m*qout+m*(h2-h1);
print'the input power of compressor %f kW'%round(Win,2)
#given data
P1=2;#inlet pressure in MPa
T1=400;#inlet temp in K
V1=50.0;#inlet velocity in m/s
z1=10;#inlet height in m
P2=15;#final pressure in MPa
x2=0.9;#final dryness fraction
V2=180.0;#final velocity in m/s
z2=6;#final height in m
Wout=5*1000;#power output in kW
#from Table A-6
h1=3248.4;
#similarly for P2
hf=225.94;
hfg=2372.3;
#constants used
g=9.8;#in m/s^2
#calcualtions
h2=hf+x2*hfg;
print'difference in enthalpies %f kJ/kg'%round((h2-h1),2);
print'difference in kinetic energy %f kJ/kg'%round((V2**2-V1**2)/2/1000,2);#factor of 1000 to convert to kJ/kg
print'difference in potential energy %f kJ/kg'%round(g*(z2-z1)/1000,2);#factor of 1000 to convert to kJ/kg
wout=-((h2-h1)+(V2**2-V1**2)/2/1000+g*(z2-z1)/1000);#factor of 1000 to convert to kJ/kg
print'work done per unit of mass %f kJ/kg'%round(wout,2);
m=Wout/wout;
print'mass flow rate %f kg/s'%round(m,2)
#given data
P1=0.8;#entering pressure in MPa
P2=0.12;#throttled pressure in MPa
#from Table A-12
#sat. liq at P1
T1=31.31;
h1=95.47;
#since process is insentropic and at P2
h2=h1;
hf=22.49;
hg=236.97;
T2=-22.32;
#calculations
x2=(h2-hf)/(hg-hf);
print'the final state is %f'%round(x2,3);
dT=T2-T1;
print'temperature drop %f C'%round(dT,2)
#given data
T1=140;#inlet temp of hot water in F
T2=50;#inlet temp of cold water in F
T3=110;#steady state output temp in F
P=20;#operating pressure in psia
#for a compressed liq at given temp
h1=107.99;
h2=18.07;
h3=78.02;
#calculations
#Mass balance min = mout So, m1+m2 = m3
#Energy balance Ein = Eout So, m1*h1 + m2*h2 = m3*h3
#combining realations
#m1*h1 + m2*h2 = (m1+m2)*h3
#dividing by m2 and y=m1/m2
#we get, yh1 + h2 = (y+1)*h3
y=(h3-h2)/(h1-h3);
print'the ratio of mass flow rates %f'%round(y,1)
#given data
T1=15;#water inlet temp in C
P1=300;#water inlet pressure in kPa
T2=25;#water outlet temp in C
T3=70;#R-134a inlet temp in C
P3=1000;#R-134a inlet pressure in kPa
T4=35;#R-134a outlet temp in C
mr=6;#mass flow rate in kg/min
#from Table A-4, A-13 and A-11
h1=62.982;
h2=104.83;
h3=303.85;
h4=100.87;
#calculations
#mass balance m1=m2=mw and m3=m4=mr
#energy balance m1*h1 + m3*h3 = m2*h2 + m4*h4
#combining them mw*(h1-h2) = mr*(h4-h3)
mw= mr*(h4-h3)/(h1-h2);
print'mass flow rate of cooling water %f kg/min'%round(mw,1);
Qin=mw*(h2-h1);
print'heat transfer rate %i kJ/min'%round(Qin)
#given data
T1=17+273;#inlet temp in K
P1=100;#inlet pressure in kPa
V1=150;#inlet volumetric rate in m^3/min
Win=15;#rated power in kW
Qout=200/1000;#heat lost in kJ/s
#constants used
R=0.287;#in kPa-m^3/kg-K
cp=1.005;#in kJ/kg C
#calculations
v1=R*T1/P1;
m=V1/v1/60;#factor of 6 to convert to s
# Win - Qout = m*cp*(T2-T1)
T2= T1 + (Win - Qout)/(m*cp);
print'exit temperature %f C'%round((T2-273),2)
#given data
V=6.0/1000;#volumne of cooker in m^3
Pgage=75;#operating pressure in kPa
Patm=100;#atmospheric pressure in kPa
m1=1;#mass of water in kg
Qind=0.5;#heat supplying rate in kJ/sec ; d stands for .
t=30*60;#operating time in s
#calculation
Pabs=Pgage+Patm;
#from Table A-5, ths saturation temp
T=116.04;
print'the temperature at which cooking takes place %f C'%T;
#mass balance me=(m1-m2)cv
#energy balance Qin - mehe = (m2u2 - m1u1)cv
Qin=Qind*t;
#from Table A-5
he=2700.2;
vf=0.001;
vg=1.004;
uf=486.82;
ufg=2037.7;
v1=V/m1;
x1=(v1-vf)/(vg-vf);
u1=uf+x1*ufg;
U=m1*u1;
#Qin = (m1 - V/v2)*he + (V/v2*u2 - m1*u1)
#v2=vf + x2*(vg-vf)
#u2=uf + x2*ufg
#combining these equations we get
#solved using EES
x2=0.009;
v2=vf + x2*(vg-vf);
m2=V/v2;
print'amount of water left %f kg'%round(m2,1)