Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note : Make a Flow Chart of this python code part a and b in a Human Language. import numpy as np import matplotlib.pyplot as

Note : Make a Flow Chart of this python code part a and b in a Human Language.

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')

Note : Make a Flow Chart of this python code in a Human Language.

Use python software to run the code if needed .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions