from math import pi
# given data
D=12.0;#diameter of rotor in m
V=10.0;#average velocity in m/s
# density of air at 25C & 1atm
p=1.18;
#calculations
ke=(V**2)/2/1000;#factor of 1000 for converting J into kJ
m=p*pi*(D**2)*V/4.0;
MP=m*(ke);
print'Maximum power %f kW'%round(MP,1)
#given values
TH=2000.0;#temperature of large furnace in R
T0=77+460.0;#temperature of enviroment in R
Qin=3000.0;#heat rate in Btu/sec
#calculation
nth=1-(T0/TH);
Wmax=nth*Qin;
Wmax=round(Wmax)
print'the rate of energy flow %i Btu/s'%round(Wmax)
#given data
Tsink=300.0;#temperature of sink in K
Tsource=1200.0;#temperature of source in K
Qin=500.0;#heat rate in kJ/s
Wuout=180;#power output in W
#calculations
Wrev=(1-Tsink/Tsource)*Qin;
print'The reversible power %i kW'%round(Wrev);
I=Wrev-Wuout;
print'the irreversiblity rate %i kW'%round(I)
import math
from scipy.integrate import quad
from pylab import *
#given data
m=500.0;#mass of iron block in kg
T1=473.0;#temperature of iron block in K
T0=300.0;#temperature of surrondings in K
#from Table A-3
cavg=0.45;
#calculations
def intgrnd1(T):
return ((1-T0/T)*(-m*cavg))#intergrant
Wrev, err = quad(intgrnd1,T1,T0) ;
Qtotal=m*cavg*(T1-T0);
print'The reversible power %i kJ'%round(Wrev);
Wu=0;
I=Wrev-Wu;
print'the irreversiblity rate %i kJ'%round(I)
#given data
Wrev=8191.0;#reversible work from Ex - 8.4
Wtotal=38925.0;#total work is equivalent to total heat lost to heat engine from Ex - 8.4
TL=278.0;#outdoor temperature in K
TH=300.0;#temperature of house in K
#calculations
Wrm=Wtotal-Wrev;#work remaining
COPHP=1/(1-TL/TH);
Wd=COPHP*Wrev;#work delivered
PS=Wd+Wrm;
PS=round(PS/1000);#factor of 1000 for converting kJ into MJ
print'Maximum amount of heat that can be supplied %i MJ'%PS
#given data
COP=1.0;# the efficiency that the dealer is referring to is the first law efficiency, meaning that for each unit of electric energy (work) consumed, the heater will supply the house with 1 unit of energy (heat). That is,the advertised heater has a COP of 1
TL=283.0;#outdoor temperature in K
TH=294.0;#indoor temperature in K
#calculations
COPHP=1/(1-TL/TH);
nII=COP/COPHP;
print'the second law efficiency %f'%round(nII,3)
from math import log
#given data
P1=1000.0;#pressure of compressed air in KPa
V=200.0;#volumne of rigid tank in m^3
T1=300.0;#temperature of enviroment in K
T0=T1;#state of air in tank
P0=100.0;#pressure of enviroment in KPa
#constants used
R=0.287;#in kPa m^3/kg K
#calculations
m1=P1*V/(R*T1);
O1=R*T0*(P0/P1-1)+R*T0*log(P1/P0);# O refers to exergy
X1=m1*O1/1000;#factor of 1000 for converting kJ into MJ
print'work obtained %i MJ'%round(X1)
#given data
T0=20+273;#temperature of enviroment in K
P1=0.14;#intail pressure in MPa
T1=-10;#intail temperature in K
P2=0.8;#final pressure in MPa
T2=50;#final temperature in K
#the properties of refrigerant
#at inlet
h1=246.36;
s1=0.9724;
#at outlet
h2=286.69;
s2=0.9802;
dO=h2-h1-T0*(s2-s1);# O refers to exergy
print'the exergy change of the refrigerant %i kJ/kg'%round(dO)
wmin=dO;
print'the minimum work input that needs to be supplied is %i kJ/kg'%wmin
#given values
Q=1035.0;#rate of heat transfer in W
T0=273.0;#outdoor temperature in C
Tin=293.0;#inner wall surface temperature in K
Tout=278.0;#outer wall surface temperature in K
T1=300.0;#indoor temperature in C
#calculations
#Xin - Xout - Xdestroyed = dX/dt
Xdestroyed=Q*(1-T0/Tin)-Q*(1-T0/Tout);
Xdestroyed=round(Xdestroyed);
print'the rate of exergy destroyed %i W'%round(Xdestroyed);
#the total rate of exergy destroyed
Xdestroyed=Q*(1-T0/T1)-Q*(1-T0/T0);
print'the total of exergy destroyed %f W'%round(Xdestroyed,1);
#given data
m=0.05;#mass of steam in kg
P1=1000;#intial pressure in MPa
T1=300+273;#intial temperature in K
P2=200;#final pressure in MPa
T2=150+273;#final temperature in K
P0=100;#pressure of surroundings in KPa
T0=25+273;#temperature of surroundings in K
Qout=2;#heat losses in kJ
#from Table A-6 & A-4
u1=2793.7;
v1=0.25799;
s1=7.1246;
u2=2577.1;
v2=0.95986;
s2=7.2810;
u0=104.83;
v0=0.00103;
s0=0.3672;
#calculations
X1=m*(u1-u0-T0*(s1-s0)+P0*(v1-v0));
X2=m*(u2-u0-T0*(s2-s0)+P0*(v2-v0));
print'exergy of intial state %i kJ'%round(X1);
print'exergy of final state %f kJ'%round(X2,1);
dX=X2-X1;
print'exergy change in system %f kJ'%round(dX,1);
Wout=-Qout-m*(u2-u1);
Wu=Wout-P0*m*(v2-v1);
Xdestroyed=X1-X2-Wu;
print'the exergy destroyed %f kJ'%round(Xdestroyed,1);
nII=Wu/(X1-X2);
print'second law efficiency of this process is %f'%round(nII,3)
import math
from scipy.integrate import quad
from pylab import *
#given data
m=2.0;#mass of air in lbm
T0=70+460.0;#intial temperature in R
P1=20.0;#intial pressure in psia
T1=70+460.0;#temperature of surroundings in R
T2=130+460.0;#final temperature in R
#constants used
Cv=0.172;#in Btu/lbm - F
#calculations
Xdestroyed=T0*m*Cv*log(T2/T1);
print'exergy destroyed %f Btu'%round(Xdestroyed,1);
def intgrnd1(T):
return ((1-T0/T)*m*Cv)#intergrant
Wrev, err = quad(intgrnd1,T1,T2) ;
print'the reversible work %f Btu'%round(Wrev,1)
#given data
T0=20+273.0;#temperature of surrounding in K
P0=100.0;#pressure of surrounding in kPa
Tiw=30+273.0;#temperature of water in K
mw=100.0;#mass of water in kg
Tii=350+273.0;#temperature of block in K
mi=5.0;#mass of block in kg
#constants used(Table A-3)
cw=4.18;#specific heat of water in kJ/kg C
ci=0.45;#specific heat of iron in kJ/kg C
#calculations
Tfk=(mi*ci*Tii+mw*cw*Tiw)/(mw*cw+mi*ci);
Tfc=Tfk-273;#in C
print'the final equilibrium temperature %f C'%round(Tfc,1);
X1i=mi*ci*(Tii-T0-T0*log(Tii/T0));
X1w=mw*cw*(Tiw-T0-T0*log(Tiw/T0));
X1t=X1i+X1w;#total exergy
print'intial exergy of combined systems %i kJ'%round(X1t);
X2i=mi*ci*(Tfk-T0-T0*log(Tfk/T0));
X2w=mw*cw*(Tfk-T0-T0*log(Tfk/T0));
X2t=X2i+X2w;#total exergy
print'intial exergy of combined systems %f kJ'%round(X2t,1);
Xdestroyed=X1t-X2t;
print'the wasted work %f kJ'%round(Xdestroyed,1)
#given data
TR=1200.0;#temperature of furnace
T0=300;#temperature of surrounding in K
P0=100;#pressure of surrounding in kPa
Tsys=400.0;#temperature of argon in K
P1=350;#temperature of argon in K
V1=0.01;#intail volumne in m^3
V2=2*V1;#final volumne
#calculations
W=P1*V1*log(V2/V1);
Wsurr=P0*(V2-V1);
Wu=W-Wsurr;
print'the useful work output %f kJ'%round(Wu,2);
# Qin - W = m*Cv*dT, Since dt=0
Q=W;
Sgen=Q/Tsys-Q/TR;
Xdestroyed=T0*Sgen;
print'the exergy destroyed %f kJ/K'%round(Xdestroyed,2);
Wrev=T0*Q/Tsys-Wsurr+(1-T0/TR)*Q;
print'the reversible work is done in the process %f kJ'%round(Wrev,2);
#calculation error in textbook in part - b which changes all the following answers
#given data
m=8.0;#mass flow rate in kg/s
T0=298.0;#temperature of surrounding in K
P0=100.0;#pressure of surrounding in kPa
P1=3000.0;#inlet pressure in kPa
T1=450.0;#inlet temperature in K
P2=200.0;#outlet pressure in kPa
T2=150.0;#outlet temperature in K
Qout=300.0;#heat rate in kW
#from Table A-6 and A-4
h1=3344.9;
s1=7.0856;
h2=2769.1;
s2=7.2810;
h0=104.83;
s0=0.3672;
#calculations
# Ein = Eout
Wout=m*(h1-h2)-Qout;
Wout=round(Wout)
print'the actual power output %i kW'%Wout
# Xin = Xout
Wrev=m*(h1-h2)-(T0*(s1-s2));
Wrev=round(Wrev);
print'the maximum possible work output %i kW'%Wrev;
nII=Wout/Wrev;
print'second law efficiency is %f'%round(nII,3);
Xdestroyed=Wrev-Wout;
print'the exergy destroyed %i kW'%round(Xdestroyed);
X1=h1-h0-T0*(s1-s0);
print'the exergy of the steam at inlet conditions %i kJ/kg'%round(X1);
#given data
T0=70+460;#temperature of surroundings in R
T1=50;#temperature of water in F
T2=240;#temperature of steam in F
T3=130;#outlet temperature in F
#as dicussed in example 7-20
m1=300;#mass flow rate of water in lbm/min
m2=22.7;#mass flow rate of steam in lbm/min
m3=322.7;#outlet mass flow rate in lbm/min
#from steam tables
h1=18.07;
s1=0.03609;
h2=1162.3;
s2=1.7406;
h3=97.99;
s3=0.18174;
#calculations
Wrev=m1*(h1-T0*s1)+m2*(h2-T0*s2)-m3*(h3-T0*s3);
Wrev=round(Wrev);
print'the reversible power %i Btu/min'%round(Wrev)
Xdestroyed=Wrev;
print'the rate of exergy destruction %i Btu/min'%Xdestroyed
#given data
V=200.0;#volumne of rigid tank in m^3
P1=100.0;#intial surroundings in kPa
P2=1000.0;#final pressure in kPa
P0=100.0;#pressure of surroundings in kPa
T=300.0;#temperature of surroundings in K
#constants used
R=0.287;#in kPa m^3/kg K
#calculations
#Xin - Xout = Xdestroyed = X2 - X1
m2=P2*V/(R*T);
X2=R*T*(log(P2/P0)+P0/P2-1);
Wrev=m2*X2/1000;
Wrev=round(Wrev);
print'Work requirement %i MJ'%Wrev