Question: Prepare a flow chart for the following python code for the above problem import numpy as np import matplotlib.pyplot as plt # define IdealGas class

Prepare a flow chart for the following python code for the abovePrepare a flow chart for the following python code for the above problem

import numpy as np

import matplotlib.pyplot as plt

# define IdealGas class for OOP programming flow

class IdealGas:

def __init__(self,R,Tc,Pc):

self.R = R

self.Tc = Tc

self.Pc = Pc

def a(self):

return 27/64 * (self.R**2 * self.Tc**2 / self.Pc)

def b(self):

return self.R * self.Tc / (8 * self.Pc)

def T(self, P, V):

return (P + self.a() / V**2) * (V - self.b()) / self.R

def Z(self,P,V):

return (P * V ) / (self.R * self.T(P,V))

# define ammonia as an instance of IdealGas passing its values of R,Tc,Pc

ammonia = IdealGas(0.08206, 405.5, 111.3)

# PART a.

n = 5 # number of samples of P or V

P = np.linspace(30,50,n)

V = np.linspace(0.1,1,n)

print('\t P \t V \t\t T \t\t Z') # table header

for i in range(n):

T = ammonia.T(P[i],V[i]) # compute T

Z = ammonia.Z(P[i],V[i]) # compute Z

# display a table row

print('\t{:.0f}\t'.format(P[i]),'{:.1f}\t'.format(V[i]),'{:.2f}\t'.format(T),'{:.2f}\t'.format(Z))

# PART b.

Pr = [1, 2, 4, 10, 20];

P = [pr * ammonia.Pc for pr in Pr] # compute P = Pr * Pc

V = 0.5 # assume a value of V in range [0.1, 1]

Z = []

for i in range(len(P)):

Z.append(ammonia.Z(P[i],V)) # compute Z

# plot Z vs Pr

plt.plot(Pr,Z,'-o')

plt.grid(linestyle='--')

plt.xlabel('Reduced Pressure, Pr [atm]')

plt.ylabel('Compressibility Factor, Z')

plt.title('V = ' + str(V) + 'liters/g-mol')

Outcome CLO1 - Understand the operational procedure of python language. CLO2 - Use object-oriented in the programming flow. CLO4 - Develop a programming/syntax solution for chemical engineering case study. Question 2 The ideal gas law can represent the pressure-volume-temperature (PVT) relationship of gases only at low (near atmospheric) pressures. The van der Waals equation of state is given by (P +12) (v - b) = RT Where, 27 (R27 a= RT and b = The variables are defined by: P = pressure in atm V = molar volume in litres/g-mol T = temperature in K R = gas constant (R = 0.08206 atm.liter/g-mol.K) T = critical temperature (405.5 K for ammonia) Per critical pressure (111.3 atm for ammonia) Reduced pressure is defined as P = Pc And the compressibility is defined as PV Z= RT a. Calculate the temperature and compressibility factor for gaseous ammonia at pressure P in range of 30 to 50 atm and molar volume V in range of 0.1 to 1 litres/g-mol. b. Plot compressibility factor vs reduced pressure for the following reduced pressures: P = 1, 2, 4, 10 and 20

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!