# Variables
#four heat transfer
Q_1 = 900 #J
Q_2 = 80 #J
Q_3 = -800 #J
Q_4 = 150 #J
#four work interactions
W_1 = 200 #J
W_2 = 150 #J
W_3 = 300 #J
#W_4
# Calculations and Results
W_4 = Q_1 +Q_2 +Q_3 +Q_4 -W_1 -W_2 -W_3
print "Magnitude and Direction of the fourth work interaction, W4 = %.0f J"%(W_4)
# Variables
Q_a = -50 #KJ #heat transferred from the system along path A
W_a = -65 #KJ #work done along path A
Q_b = 0 #KJ #heat transferred from the system along path B
#W_b work done along path B
# Calculations and Results
#Part(a)
print "Part a";
delE_a = Q_a - W_a #KJ #Change in energy along path A
print "Change in energy of the system = %.0f KJ"%(delE_a);
#Part(b)
print "Part b";
delE_b = -1*delE_a #KJ #Change in energy along path B
W_b = delE_b - Q_b #KJ #work done along path B
print "Magnitude and direction of work done during B, W_b = %.0f KJ"%(W_b)
# Variables
m = 2.3 #kg #mass of substance
u = 21 * 10**3 #J/kg #internal energy
V = 110. #m/s #velocity
z = 1500. #m #elevation above sea level
g = 9.81 #m/s**2 #acceleration due to gravity
# Calculations and Results
E = m*(g*z + V**2/2 + u) #J/kg #Total energy of the system
print "The total energy of the system with respect to an observer at rest at sea level, E = %.4f KJ"%(0.001*E);
from numpy import *
from sympy import Derivative
# Variables
t = poly1d(0); #C #Temperature in C
u = 196. + .718*t; #KJ/kg #specific internal energy
pv = 287*(t+273.); #Nm/kg #p is pressure and v = specific volume
# Calculations and Results
Cv = poly(u);
print "Specific heat at constant volume,Cv = %.3f kJ/kgK"%(Cv[0])
h = u + pv*.001 #KJ/kg #enthalpy
Cp = poly(h);
print "Specific heat at constant pressure,Cp = %.3f kJ/kgK"%(Cp[0])
# Note: Poly function gives different result then book has.