# Variables
Q = 10. #kJ #heat transfered from reservoir
T = 100.+273 #K #isothermal expansion temperature
T_res = 300.+273 #K #reservoir temperature
# Calculations and Results
delta_S_sys = (Q/T) #kJ/K #delta S for the system
print "Change in entropyDelta S) for the system = %.2e kJ/K"%(delta_S_sys);
delta_S_res = -1*(Q/T_res) #kJ/K #delta S for the reservoir
print "Change in entropyDelta S) for the reservoir = %.4e kJ/K"%(delta_S_res);
# Variables
Q = 10. #kJ #heat transfered from reservoir
T = 100.+273 #K #isothermal expansion temperature
T_res = 100.+273 #K #reservoir temperature
# Calculations and Results
delta_S_sys = (Q/T) #kJ/K #delta S for the system
print "Change in entropyDelta S) for the system = %.2e kJ/K"%(delta_S_sys)
delta_S_res = -1*(Q/T_res) #kJ/K #delta S for the reservoir
print "Change in entropyDelta S) for the reservoir = %.2e kJ/K"%(delta_S_res);
# Variables
Q = 1.; #kJ #heat transfered from reservoir
T = 100.+273; #K #isothermal expansion temperature
T_res = 100.+273; #K #reservoir temperature
# Calculations and Results
delta_S_res = -1*(Q/T_res); #kJ/K #delta S for the reservoir
print "Change in entropyDelta S) for the reservoir = %.2e kJ/K"%(delta_S_res);
import math
# Variables
pA = 120. #kPa #Pressure at location A
TA = 50.+273 #K #Temperature at location A
VA = 150. #m/s #Velocity at location A
pB = 100. #kPa #Pressure at location B
TB = 30.+273 #K #Temperature at location B
VB = 250. #m/s #Velocity at location B
Cp = 1.005 #kJ/kg
R = 0.287 #kJ/kgK
# Calculations and Results
delta_S_sys = (Cp*math.log(TB/TA))-(R*math.log(pB/pA)) #kJ/kgK #Entropy of system
if delta_S_sys < 0 :
print "Flow is from B to A.";
else:
print "Flow is from A to B."
import math
# Variables
mi = 5. #kg #mass of ice
Ti = 273. - 10 #K #Temperature of ice
ci = 2.1 #kJ/kgK #specific heat of ice
L = 330. #kJ/kg #Latent heat
mw = 20. #kg #mass of water
Tw = 273.+80 #K #Temperatur of water
cw = 4.2 #kJ/kgK #specific heat of water
# calculatins and results
#Part(a)
print "Part a";
Tmix = ((mi*ci*(Ti-273))-(L*mi)+(mw*cw*Tw)+(mi*cw*273))/(mw*cw+mi*cw)
print "Temperature of the mixture when equilibrium is established between ice and water = %.f K"%(Tmix)
#Part (b)
print "Part b";
delta_S_ice = mi*(ci*math.log(273/Ti)+L/273+cw*math.log(Tmix/273)) #kJ/K #Entropy of ice
print "Entropy of ice = %.2f kJ/K"%(delta_S_ice)
#Part (c)
print "Part c";
delta_S_water = mw*(cw*math.log(Tmix/Tw)) #kJ/K #Entropy of water
print "Entropy of water = %.2f kJ/K"%(delta_S_water)
#Part (d)
print "Part d";
delta_S_uni = delta_S_water+delta_S_ice #kJ/K #Entropy of universe
print "Entropy of universe = %.2f kJ/K"%(delta_S_uni)
# note : rounding off error
# Variables
Q1 = 100. #kJ #Heat input
T0 = 300. #K #Surrounding temperature
#Part(a)
print "Part a";
T1 = 1000. #K #reservoir temperature
print "Avalable enery of 100 kJ of heat from a reservoir at 1000K = %.f kJ"%(Q1*1-T0/T1)
print "Unvalable enery of 100 kJ of heat from a reservoir at 1000K = %.1f kJ"%(Q1*(1-(T0/T1)))
#Part(b)
print "Part b";
T1 = 600 #K #reservoir temperature
print "Avalable enery of 100 kJ of heat from a reservoir at 1000K = %.f kJ"%(Q1*1-T0/T1)
print "Unvalable enery of 100 kJ of heat from a reservoir at 1000K = %.1f kJ"%(Q1*(1-(T0/T1)))
# Variables
T0 = 300. #K #Surrounding temperature
T1 = 1000. #K #Temperature of final reservoir
T2 = 600. #K #Temperature of intermediate reservoir
Q1 = 100. #kJ #Heat input
# Calculations and Results
print "Increase in unavaliable energy due to irreversible heat transfer = %.1f kJ"%(Q1*(1-T0/T1)-Q1*(1-T0/T2))
# Variables
T1 = 500. #K
T0 = 300. #K
T2 = 350. #K
W = 250. #kJ
Q1 = 1000. #kJ
# Results
print "Available energy = %.1f kJ"%(((1-T0/T1))*Q1);
print "Unavailable energy = %.1f kJ"%(Q1 - (((1-T0/T1))*Q1));