/[ascend]/trunk/models/kchittur/zplot.py
ViewVC logotype

Contents of /trunk/models/kchittur/zplot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1457 - (show annotations) (download) (as text)
Mon May 28 17:50:45 2007 UTC (13 years, 6 months ago) by kchittur
File MIME type: text/x-python
File size: 1441 byte(s)
krishnan chittur
1 # python script for calculating Pressure versus y from T and x
2 # binary system, modified raoult's law, simple activity coefficient model
3
4 import extpy
5 from pylab import *
6 from solverreporter import *
7
8 def zplot(self):
9
10 browser = extpy.getbrowser()
11 ioff()
12 figure()
13 #
14 # I have chosen three temperatures
15 #
16 for T in [190,210,230,250,270,290,310,330,350,370]:
17 self.T.setRealValue(T)
18 #
19 # collect the data for plotting in two sets of arrays (one for X, one for Y)
20 # I have two sets here - one for P versus y and other for P versus x
21 #
22 XX1 = []
23 PP1 = []
24 #
25 # change x1 from 0 to 1.0
26 # there has to be a space between "in" and "["
27 #
28
29 for P in [10,15,20,25,30,40,50,60,70,80,100,120,140,150,170,190]:
30 self.P.setRealValueWithUnits(P,"bar")
31 #
32 # send the pair of values T x1 to the solver
33 # and append the Pressure and y1 (from the solver) to the arrays
34 # the x's are also appended
35 try:
36 browser.sim.solve(browser.solver,SimpleSolverReporter(browser,message="T = %f, P = %f" % (T,P)))
37 XX1.append(float(self.Pr))
38 PP1.append(float(self.Z))
39 except:
40 browser.reporter.reportError('Failed to solve for P = %f' % P)
41 continue
42 ## plot the data
43
44 plot(XX1,PP1)
45
46 hold(1)
47
48 ## legend()
49 ion()
50 show()
51
52 extpy.registermethod(zplot)
53 #the above method can be called using "EXTERNAL vleplot(self)" in ASCEND.
54 # if you want to see the azeotrope clearly, restrict the calculation to one
55 # temperature

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22