import math
# Variables
T1 = 37.+273;
T2 = 35.+273;
m = 1.;
cv = 4.187;
# Calculation
S = m*cv*math.log(T1/T2); # S = S2-S1
# Results
print "Change in the entropy of the water is %.4f KJ/K"%S
# note : answer is accurate. please check.
import math
# Part (a)
T1 = 273.;
T2 = 373.;
m = 1. ;
cv = 4.187;
# Calculation and Results
Ss = m*cv*math.log(T2/T1); # S = S2-S1
Q = m*cv*(T2-T1);
Sr = -(Q/T2);
S = Ss+Sr;
print "The entropy change of the universe is %.3f kJ/K"%S
# Part (b)
T3 = 323.;
Sw = m*cv*(math.log(T3/T1)+math.log(T2/T3));
Sr1 = -m*cv*(T3-T1)/T3;
Sr2 = -m*cv*(T2-T3)/T2;
Su = Sw+Sr1+Sr2;
print "The entropy change of the universe is %.3f kJ/K"%Su
import math
# Variables
# Part (a)
m = 1.;
T1 = -5.+273;
T2 = 20.+273;
T0 = 0.+273;
cp = 2.093;
cv = 4.187;
lf = 333.3;
# Calculation
Q = m*cp*(T0-T1)+1*333.3+m*cv*(T2-T0);
Sa = -Q/T2;
Ss1 = m*cp*math.log(T0/T1);
Ss2 = lf/T0;
Ss3 = m*cv*math.log(T2/T0);
St = Ss1+Ss2+Ss3;
Su = St+Sa;
# Results
print "The entropy change of the universe is %.4f kJ/K"%Su
# Part (b)
S = 1.5549; # S = S4-S1
Wmin = T2*(S)-Q;
print "The minimum risk required is %.1f kJ"%Wmin
# rounding off error. please check.
import math
Vo = 8.4;
Vh = 14.;
n1 = Vo/22.4;
n2 = Vh/22.4;
R = 8.31;
# Calculation
x1 = n1/(n1+n2);
x2 = n2/(n1+n2);
S = -R*(n1*math.log(x1)+n2*math.log(x2));
# Results
print "Entropy change for the process is %.2f J/K"%S
import math
from hornerc import horner
import sys
# Variables
#T = poly(0,'T'); # T = Tf
Tf_ = [700,-2] #700-2*T; # Tf_ = Tf'
# Calculation
# Bisection method to solve for the polynomial
def Temperature(a,b,f):
N = 100.;
eps = 1e-5;
if((f(a)*f(b))>0):
print ('no root possible f(a)*f(b)>0');
sys.exit(0);
if(abs(f(a))<eps):
print ('solution at a');
sys.exit(0)
if(abs(f(b))<eps):
print ('solution at b');
sys.exit(0)
while(N>0):
c = (a+b)/2
if(abs(f(c))<eps):
x = c ;
return x;
if((f(a)*f(c))<0 ):
b = c ;
else:
a = c ;
N = N-1;
print ('no convergence');
sys.exit(0);
def p(T):
return 2*T**3-700*T**2+9000000
T = Temperature(100,200,p);
Tf_ = horner(Tf_,T);
print "The final temperature of the body C is",Tf_,"K"
import math
from scipy.integrate import quad
import sys
from numpy import poly1d
from sympy import Symbol
# Variables
T1 = 200.;
T2 = 100.;
A = 0.042;
# Calculation
def f10(T):
return A*T**2
Q1 = quad(f10,T1,T2)[0]
def f11(T):
return A*T**2/T
S = quad(f11,T1,T2)[0]
W = Symbol('W');
Z = (-Q1-W)/T2 + S; # Polynomial to be solved for W
# Bisection method to solve for the Work
def Work(a,b,f):
N = 100.;
eps = 1e-5;
if((f(a)*f(b))>0):
print ('no root possible f(a)*f(b)>0');
sys.exit(0);
if(abs(f(a))<eps):
print ('solution at a');
sys.exit(0)
if(abs(f(b))<eps):
print ('solution at b');
sys.exit(0)
while(N>0):
c = (a+b)/2
if(abs(f(c))<eps):
x = c ;
return x;
if((f(a)*f(c))<0 ):
b = c ;
else:
a = c ;
N = N-1;
print ('no convergence');
sys.exit(0)
def p(W):
return 350-0.01*W
W = Work(34000,36000,p);
print "The maximum work that can be recovered is",W/1000,"kJ"
import math
from scipy.integrate import quad
# Variables
P1 = 0.5e06;
V1 = 0.2
V2 = 0.05;
n = 1.3
# Calculation
P2 = P1*(V1/V2)**n;
def H(p):
return ((P1*V1**n)/p)**(1./n);
def f0(p):
return H
H = quad(H,P1,P2)[0]
U = H-(P2*V2-P1*V1);
W12 = -U;
# Results
print "Change in enthalpy is %.1f kJ"%(H/1000)
print "Change in internal energy is %.2f kJ"%(U/1000)
print "The change in entropy and heat transfer are",0,"and",0,"kJ"
print "The work transfer during the process is %.2f kJ"%(W12/1000)
# rounding off error.
import math
from scipy.integrate import quad
# Variables
Pa = 130e03;
Pb = 100e03;
Ta = 50+273;
Tb = 13+273;
cp = 1.005;
# Calculation
def f1(T):
return cp/T
def f2(p):
return .287/p
Ss = quad(f1,Ta,Tb)[0] - quad(f2,Pa,Pb)[0]
Ssy = 0;
Su = Ss+Ssy;
# Results
print "Change in the entropy of the universe is %.3f kJ/Kg k"%Su
print "As the change in entropy of the universe in the process A-B is negative so the flow must be from B-A"
import math
# Variables
T1 = 300.
T2 = 330.
T3 = 270.
P1 = 4.
P2 =1.
P3 =1.
cp = 1.0005
R = 0.287;
# Calculation
S21 = cp*math.log(T2/T1)-R*math.log(P2/P1); # S21 = S2-S1
S31 = cp*math.log(T3/T1)-R*math.log(P3/P1); # S31 = S3-S1
Sgen = 1*S21 + 1*S31;
# Results
print "The entropy generated during the process is %.3f kW/K"%Sgen
print "As the entropy generated is positive so such device is possible"
import math
# Variables
A = 5.*7;
k = 0.71;
L = 0.32;
Ti = 21.+273;
To = 6.+273;
# Calculation and Results
Q = k*A*(Ti-To)/L ;
print "The rate of heat transfer through the wall is %.2f W"%Q
Sgen_wall = Q/To - Q/Ti;
print "The rate of entropy through the wall is %.3f W/K"%Sgen_wall
Tr = 27+273.;
Ts = 2+273.;
Sgen_total = Q/Ts-Q/Tr;
print "The rate of total entropy generation with this heat transfer process is %.3f W/K"%Sgen_total