import math
# Variables
R = 287.; #J/kg K
V1 = 40.; #m**3
V2 = 40.; #m**3
p1 = 1.*10**5; #Pa
p2 = 0.4*10**5; #Pa
T1 = 298.; #K
T2 = 278.; #K
# Calculations
m1 = p1*V1/R/T1;
m2 = p2*V2/R/T2;
#Let mass of air removed be m
m = m1-m2;
# Results
print ("Mass of air removed = %.3f")% (m),("kg")
V = m*R*T1/p1;
print ("Volume of gas removed = %.3f")% (V), ("m**3")
# Variables
V = 0.04; #m**3
p = 120.*10**5; #Pa
T = 293.; #K
R0 = 8314.;
# Calculations and Results
print ("(i) kg of nitrogen the flask can hold")
M = 28; #molecular weight of Nitrogen
R = R0/M;
m = p*V/R/T;
print ("kg of nitrogen = %.3f")% (m), ("kg")
print ("(ii) Temperature at which fusible plug should melt")
p = 150.*10**5; #Pa
T = p*V/R/m; #K
t = T-273; #0C
print ("Temperature = %.3f")% (t),("°C")
import math
# Variables
p1 = 1.*10**5; #Pa
T1 = 293.; #K
d = 6.; #m; diameter of the spherical balloon
p2 = 0.94*p1;
T2 = T1;
cv = 10400.; #J/kg K
R = 8314/2.;
r = 3.; #m
# Calculations and Results
print ("(i) Mass of original gas escaped")
mass_escaped = (p1-p2)/p1*100;
print ("%mass_escaped = "), (mass_escaped), ("%")
print ("(ii)Amount of heat to be removed ")
T2 = 0.94*T1;
m = p1*4/3*math.pi*r**3/R/T1;
Q = m*cv*(T1-T2)/10**6;
print ("Q = %.3f")% (Q),("MJ")
from numpy import *
import math
# Variables
m = 28.; #kg
V1 = 3.; #m**3
T1 = 363.; #K
R0 = 8314.;
M = 28.; #Molecular mass of N2
R = R0/m;
V2 = V1;
T2 = 293.; #K
# Calculations and Results
print ("(i) Pressure (p1) and specific volume (v1) of the gas")
p1 = m*R*T1/V1/10**5; #bar
print ("Pressure = %.3f")% (p1), ("bar")
v1 = V1/m;
print ("specific volume = %.3f")% (v1), ("m**3/kg")
#cp-cv = R/1000;
#cp-1.4cv = 0;
#solving the above two eqns
A = [[1,-1],[1,-1.4]];
B = [R/1000,0];
X = linalg.inv(A)*B;
cp = X[0,0]
print ("cp = %.3f")% (cp), ("kJ/kg K")
cv = X[1][0];
print ("cv = %.3f")% (cv),("kJ/kg K")
print ("(iii) Final pressure of the gas after cooling to 20°C")
p2 = p1*T2/T1;
print ("p2 = %.3f")% (p2), ("bar")
du = cv*(T2-T1);
print ("Increase in specific internal energy = %.3f")% (du), ("kJ/kg")
dh = cp*(T2-T1);
print ("Increase in specific Enthalpy = %.3f")%(dh), ("kJ/kg")
v2 = v1;
ds = cv*math.log(T2/T1) + R*math.log(v2/v1);
print ("Increase in specific entropy = %.3f")%(ds),("kJ/kg K")
W = 0; #constant volume process
Q = m*du+W;
print ("Heat transfer = %.3f")%(Q), ("kJ")
import math
print ("Part (a)")
# Variables
R = 0.287; #kJ/kg K
y = 1.4;
m1 = 1.; #kg
p1 = 8.*10**5; #Pa
T1 = 373.; #K
p2 = 1.8*10**5; #Pa
cv = 0.717; #kJ/kg K
n = 1.2;
# Calculations and Results
#pv**1.2 = consmath.tant
print ("(i) The final specific volume, temperature and increase in entropy")
v1 = R*10**3*T1/p1;
v2 = v1*(p1/p2)**(1./n);
print ("v2 = %.3f")%(v2), ("m**3/kg")
T2 = p2*v2/R/10**3; #K
t2 = T2-273; #0C
print ("Final temperature = %.3f")% (t2), ("0C")
ds = cv*math.log(T2/T1) + R*math.log(v2/v1);
print ("ds = %.3f")%(ds), ("kJ/kg K")
W = R*(T1-T2)/(n-1);
print ("Work done = %.3f")% (W), ("kJ/kg")
Q = cv*(T2-T1) + W;
print ("Heat transfer = %.3f")%(Q),("kJ/kg")
print ("Part (b)")
print ("(i) Though the process is assumed now to be irreversible and adiabatic, the end states are given to be the same as in (a). Therefore, all the properties at the end of the process are the same as in (a).")
print ("(ii) Adiabatic process")
Q = 0;
print ("Heat transfer = %.3f")%(Q), ("kJ/kg")
W = -cv*(T2-T1);
print ("Work done = %.3f")%(W),("kJ/kg")
# Variables
d = 2.5; #m; diameter
V1 = 4./3*math.pi*(d/2)**3; #volume of each sphere
T1 = 298.; #K
T2 = 298.; #K
m1 = 16.; #kg
m2 = 8.; #kg
V = 2.*V1; #total volume
m = m1+m2;
R = 287.; #kJ/kg K
# Calculations
p = m*R*T1/V/10**5; #bar
# Results
print ("pressure in the spheres when the system attains equilibrium = %.3f")%(p),("bar")
# Variables
m = 6.5/60; #kg/s
import math
cv = 0.837; #kJ/kg K
p1 = 10*10**5; #Pa
p2 = 1.05*10**5; #Pa
T1 = 453; #K
R0 = 8.314;
M = 44.; #Molecular mass of CO2
# Calculations and Results
R = R0/M;
cp = cv+R;
y = cp/cv;
T2 = T1*(p2/p1)**((y-1)/y);
print T2
t2 = T2-273;
print ("Final temperature = %.3f")%(t2),("0C")
v2 = R*10**3*T2/p2; #m**3/kg
print ("final specific volume = %.3f")%(v2), ("m**3/kg")
ds = 0; #Reversible and adiabatic process
print ("Increase in entropy = "), (ds)
Q = 0; #Adiabatic process
print ("Heat transfer rate from turbine = "), (Q)
W = m*cp*(T1-T2);
print ("Power delivered by the turbine = %.3f")% (W), ("kW")
# Note : answers wont match with the book because of the rounding error.
import math
# Variables
p1 = 8.*10**5; #Pa
V1 = 0.035; #m**3
T1 = 553.; #K
p2 = 8.*10**5; #Pa
V2 = 0.1; #m**3
n = 1.4;
R = 287.; #J/kg K
T3 = 553.; #K
cv = 0.71; #kJ/kg K
# Calculations and Results
m = p1*V1/R/T1;
T2 = p2*V2/m/R;
p3 = p2/((T2/T3)**(n/(n-1)));
V3 = m*R*T3/p3;
print ("(i) The heat received in the cycle")
#constant pressure process 1-2
W_12 = p1*(V2-V1)/10**3; #kJ
Q_12 = m*cv*(T2-T1) + W_12; #kJ
#polytropic process 2-3
W_23 = m*R/10**3*(T2-T3)/(n-1);
Q_23 = m*cv*(T3-T2) + W_23;
Q_received = Q_12 + Q_23;
print ("Total heat received in the cycle = "),(Q_received), ("kJ")
print ("(ii) The heat rejected in the cycle")
#Isothermal process 3-1
W_31 = p3*V3*math.log(V1/V3)/10**3; #kJ
Q_31 = m*cv*(T3-T1) + W_31;
print ("Heat rejected in the cycle = %.3f")% (-Q_31), ("kJ")
n = (Q_received - (-Q_31))/Q_received*100;
print ("Efficiency of the cycle = %.3f")% (n), ("%")
# Variables
v = 44.; #m**3/kg-mol
T = 373.; #K
# Calculations and Results
print ("(i) Using Van der Waals’ equation")
a = 362850.; #N*m**4/(kg-mol)**2
b = 0.0423; #M**3/kg-mol
R0 = 8314.; #J/kg K
p = ((R0*T/(v-b)) - a/v**2);
print ("Pressure umath.sing Van der Waals equation = %.3f")%(p), ("N/m**2")
print ("(ii) Using perfect gas equation")
p = R0*T/v;
print ("Pressure using perfect gas equation = %.3f")% (p), ("N/m**2")
# Variables
V = 3.; #m**3
m = 10.; #kg
T = 300.; #K
# Calculations and Results
R0 = 8314.;
M = 44.;
R = R0/M;
p = m*R*T/V;
print ("Pressure Using perfect gas equation = %.3f")% (p),("N/m**2")
a = 362850; #Nm**4/(kg-mol)**2
b = 0.0423; #m**3/(kg-mol)
v = 13.2; #m**3/kg-mol
p = R0*T/(v-b) - a/v**2;
print ("Pressure Using Van der Waals’ equation = %.3f")%(p), ("N/m**2")
A0 = 507.2836;
a = 0.07132;
B0 = 0.10476;
b = 0.07235;
C = 66*10**4;
A = A0*(1-a/v);
B = B0*(1-b/v);
e = C/v/T**3;
p = R0*T*(1-e)/v**2*(v+B) - A/v**2;
print ("Pressure Using Beattie Bridgeman equation = %.3f")%(p), ("N/m**2")
import math
from scipy.integrate import quad
# Variables
a = 139250; #Nm**4/(kg-mol)**2
b = 0.0314; #m**3/kg-mol
R0 = 8314; #Nm/kg-mol K
v1 = 0.2*32; #m**3/kg-mol
v2 = 0.08*32; #m**3/kg-mol
T = 333; #K
print ("(i) Work done during the process")
# Calculations
def f21( v):
return R0*T/(v-b) - a/v**2
W = quad(f21, v1, v2)[0]
# Results
print ("W = %.3f")% (W),("Nm/kg-mol")
print ("(ii) The final pressure")
p2 = R0*T/(v2-b) - a/v2**2;
print ("p2 = %.3f")%(p2), ("N/m**2")
# Variables
pr = 20;
Z = 1.25;
Tr = 8.0;
Tc = 282.4; #K
# Calculations
T = Tc*Tr;
# Results
print ("Temperature = %.3f")%(T),("K")
# Variables
p = 260.*10**5; #Pa
T = 288.; #K
pc = 33.94*10**5; #Pa
Tc = 126.2; #K
R = 8314./28;
# Calculations
pr = p/pc;
Tr = T/Tc;
Z = 1.08;
rho = p/Z/R/T;
# Results
print ("Density of N2 = %.3f")% (rho), ("kg/m**3")
# Variables
p = 200.*10**5; #Pa
pc = 73.86*10**5; #Pa
Tc = 304.2; #K
pr = p/pc;
Z = 1;
Tr = 2.48;
# Calculations
T = Tr*Tc;
# Results
print ("Temperature = "), (T), ("K")
import math
# Variables
d = 12.; #m; diameter of spherical balloon
V = 4./3*math.pi*(d/2)**3;
T = 303.; #K
p = 1.21*10**5; #Pa
pc = 12.97*10**5; #Pa
Tc = 33.3; #K
R = 8314./2;
# Calculations
pr = p/pc;
Tr = T/Tc;
Z = 1;
m = p*V/Z/R/T;
# Results
print ("Mass of H2 in the balloon = %.3f")% (m), ("kg")
# Calculations
Z_cp = 3./2-9./8;
# Results
print ("Z_cp = "),(Z_cp)