import math
# Variables
v1 = 0.05; # in m**3
v2 = 8. * v1; # in m**3
T1 = 280.; # in °C
T1 = T1 + 273; # in K
T2 = 25.; # in °C
T2 = T2 + 273; # in K
p1 = 8.; # in bar
C_p = 1.005; # in kJ/kgK
C_v = 0.712; # in kJ/kgK
# Calculations
R = C_p - C_v; # in kJ/kgK
del_phi = (R * ( math.log(v2/v1)) ) + (C_v * (math.log(T2/T1)) ); # in kJ/kgK
# Results
print "The change in entrophy of air during the process in kJ/kgK is : %.3f"%del_phi
import math
# Variables
m = 5.; # in kg
T1 = 50.; # in °C
T1 = T1 + 273; # in K
T2 = 250.; # in °C
T2 = T2 + 273; # in K
C_p = 1.0;
C_v = 0.72;
T3 = 50.; # in °C
T3 = T3 + 273; # in K
# Calculations
del_phi = m * C_p * (math.log(T2/T1)); # in kJ/ K (this is increase in entrophy)
del_phi1 = m * C_v * (math.log(T3/T2)); # in kJ/K (this is decrease in entrophy)
phi_net = del_phi - abs(del_phi1); # in kJ/K
# Results
print "net change in entrophy in kJ/K is : %.3f"%phi_net
# Variables
Q1 = 1600.; # in kJ
Q2 = 1600.; # in kJ
T1 = 800.; # in K
T2 = 127.; # in °C
# Calculations
T2 = T2 + 273; # in K
d1_phi = Q1/T1; # in kJ per K
d2_phi = Q2/T2; # in kJ per K
net_phi = d2_phi - d1_phi; # in kJ per K
# Results
print "entrophy generated during the process in kJ/K is : ",net_phi
import math
# Variables
T_A = 50.+273; # in K
T_B = 13.+273; # in K
P_A = 130.; # in kPa
P_B = 100.; # in kPa
Cp = 1.005; # in kJ/kg-K
pvByT = 0.287; # p in kPa, v in m**3/kg, T in K
# Calculations
del_S_system = Cp*math.log(T_B/T_A)-pvByT*math.log(P_B/P_A); # in kJ/kg-K
del_S_surrounding = 0;
del_S_universe = del_S_system+del_S_surrounding; # in kJ/kg-K
# Results
print "change in entropy in kJ/kg-K is : %.3f"%del_S_universe
print ("But a negative change in entropy is not possible,");
print ("therefore the flow of air must be from B to A")
import math
# Variables
m = 5. # in kg
s= 4.18
T1 = 0. # in °C
T2 = 20. # in °C
dt = T2 - T1; # in °C
Q = m * s * dt; # in kJ
L = 335.; # in kJ/kg
# Calculations
# Q = m_i * l
m_i = Q/L; # in kg
T1 = T1 + 273; # in K
T2 = T2 + 273; # in K
del_S = ((m_i * L)/T1) - (m * s * (math.log(T1/T2))); # in kJ per K
# Results
print "change in entropy of the adiabatic system in kJ/K is %.3f"%del_S
import math
# Variables
p1 = 1. * 10**5; # in N/m**2
C_p = 1.005; # in kJ/kg k
R = 287.; # in j/kg k
T1 = 290.; # in K
T2 = 580.; # in K
v1 = 1.; # in m**3
# Calculations
m = (p1 * v1)/(R * T1); # in kg
Q = m * R * (T2-T1); # in J
Q = Q * 10**-3; # in kJ
del_phi = m * C_p * (math.log(T2/T1)); # in kJ per K
R = R * 10**-3; # in kJ/kg K
C_v = C_p - R; # in kJ/kg k
del1_phi = m * C_v * (math.log(T1/T2)); # in kJ/K
net_phi = del_phi + del1_phi; # in kJ/K
# Results
print "Over all change in entrophy in kJ/K is : %.4f"%net_phi
# rounding off error