Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON CODE (PLEASE MAKE IT SIMPLE AND WITH FULL COMMENTS AT EACH STEP) Define a Python Class named Steam. The attributes and methods are defined

PYTHON CODE

(PLEASE MAKE IT SIMPLE AND WITH FULL COMMENTS AT EACH STEP)

Define a Python Class named Steam. The attributes and methods are defined below. The behavior of this class will be demonstrated with an example main program that uses the class. The class named Steam has 8 attributes, an three methods: __init__, calc, and print, as defined below:

import numpy as np from scipy.interpolate import griddata

class Steam: def __init__(self, pressure, T=None, h=None, s=None, x=None, v=None, name=None): self.p = pressure # pressure - kPa self.T = T # Temperature - degrees C self.x = x # quality (a value between 0 and 1) self.v = v # specific volume - m^3/kg self.h = h # enthalpy - kJ/kg self.s = s # entropy - kJ/(kg K) self.name = name # a useful identifier self.region = None # 'superheated' or 'saturated' if T==None and x==None and v==None and h==None and s==None: return self.calc() def calc(self): # calculate the missing steam properties using griddata() and the steam tables given earlier.

IMPORTANT:

a)look carefully at the PRESSURE units in the two tables. They are DIFFERENT.

b) Beware of the GAP IN THE DATA problem!

def print(self): # print the available (not None) Steam values

Note: calc(self) should raise errors if asked to do things in cannot handle such as:

raise ValueError('Error - this function cannot operate in the sub-cooled region') raise ValueError('Not enough properties specified')

def main():

inlet=Steam(7350, name='Turbine Inlet')

inlet.x =0.9 # 90 percent quality - accessed

inlet.calc() inlet.print() h1 = inlet.h; s1 = inlet.s

print(h1,s1,' ')

outlet=Steam(100, s=inlet.s, name='Turbine Exit')

#notice - s=inlet.s

outlet.print()

another=Steam(8575, h=2050, name='State 3')

another.print()

yetanother=Steam(8900, h=41250, name='State 4')

yetanother.print()

#uncommenting the next two lines will cause a ValueError error

#final1 = Steam(7000, T=250, name='State 5')

#final1.print()

if __name__ == "__main__":

main()

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

=+country competitive advantages? Why? Support your point of view.

Answered: 1 week ago

Question

=+from: a) a MNEs perspective? and b) the HRM managers perspective?

Answered: 1 week ago