##Part A Chapter 4 Example 1 pg no 104
##find the work
P=689*1000;##Pa
V1=0.04;##m^3
V2=0.045;##m^3
Wpaddle=-4.88;##kJ
Wpiston=3.445##kJ
print"%s %.2f %s"%("Work done on piston = ",Wpiston," kJ");
Wnet=Wpiston+Wpaddle;##kJ
print"%s %.2f %s"%("Work done on system = ",abs(Wnet)," kJ");
##Part A Chapter 4 Example 2 pg no 105
##find the heat required
m=0.5;##kg
u1=26.6;##kJ/kg
u2=37.8;##kJ/kg
W=0;##as vessel is rigid
U1=m*u1;##kJ
U2=m*u2;##kJ
##Heat required
Q=U2-U1+W;##kJ
print"%s %.2f %s"%("Heat required = ",Q," kJ");
##Part A Chapter 4 Example 3 pgno 105
##find the heat
m=50.;##kg/hr
T1=800.;##degree C
T2=50.;##degree C
Cp=1.08;##kJ/kgK
Q=m*Cp*(T1-T2);##kJ/hr
print"%s %.2f %s"%("Heat should be removed at the rate of ",Q," kJ/hr");
##Part A Chapter 4 Example 4 pg no 106
##find the work donw air
V=0.78
Patm=101.325;##kPa
##W=work done by Patm
W=Patm*V;##kJ
print"%s %.2f %s"%("Work done by air = ",W," kJ");
##Part A Chapter 4 Example 5 pg no 106
##find the heat work and change internal energy
m=5.;##kg
p1=1.;##MPa
V1=0.5;##m^3
p2=0.5;##MPa
##u=1.8*p*v+85;##kJ/kg
n=1.3;##constant
##p1*V1^n=p2*V2^n
V2=(p1/p2*V1**n)**(1./n);##m^3
W=(p2*V2-p1*V1)*10**3/(1.-n);##kJ
delU=(p2*V2-p1*V1)*10**3;##kJ
delTheta=delU+W;##kJ
print"%s %.2f %s"%("Heat Interaction = ",delTheta," kJ");
print"%s %.2f %s"%("Work Interaction = ",W," kJ");
print"%s %.2f %s"%("Change in Internal Energy = ",delU," kJ");
##Part A Chapter 4 Example 6 pg no 107
##find the work
p1=1.;##MPa
p2=2.;##MPa
V1=0.05;##m^3
n=1.4;##constant
##U=7.5*p*v-425;##kJ/kg
delQ=180.;##kJ
##p1*V1^n=p2*V2^n
V2=(p1/p2)**(1/n)*V1;##m^3
delU=7.5*10**3*(p2*V2-p1*V1);##kJ
W=(p2*V2-p1*V1)*10**3/(1.-n);##kJ
delTheta=delU+W;##kJ
print"%s %.2f %s"%("Heat = ",delTheta," kJ");
print"%s %.2f %s"%("Work = ",W," kJ");
print"%s %.2f %s"%("Change in Internal Energy = ",delU," kJ");
##If heat transfer is 180 kJ
W=delQ-delU;##kJ
print"%s %.2f %s"%("Work = ",W," kJ");
##Part A Chapter 4 Example 7 pg 109
##find the heat
M=16.;##molecular weight
p1=101.3;##KPa
p2=600.;##MPa
T1=20.+273.;##K
n=1.3;##constant
Cp=1.7;##KJ/KgK
UGC=8.3143*10**3;##Universal Gas constant
R=UGC/M/1000.;##KJ/KgK
Cv=Cp-R;##KJ/KgK
Gamma=Cp/Cv;##constant
T2=T1*(p2/p1)**((n-1)/n);##K
W=R*(T2-T1)/(n-1);##
Q=W*(Gamma-n)/(Gamma-1);##Kj/Kg
print"%s %.2f %s"%("Heat = ",Q," KJ");