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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1807 - (hide annotations) (download) (as text)
Mon Jul 21 09:23:57 2008 UTC (12 years, 4 months ago) by jpye
File MIME type: text/x-python
File size: 2672 byte(s)
Added legend to zplot.
1 kchittur 1475 import extpy
2 kchittur 1728 from pylab import *
3     from solverreporter import *
4 kchittur 1457
5 kchittur 1728 def pvplot(self):
6 kchittur 1475
7 kchittur 1728 browser = extpy.getbrowser()
8     ioff()
9     figure()
10     #
11     # I have chosen several temperatures
12     #
13 jpye 1807
14     TT = [190,210,230,250,270,290,310,330,350,370,400,420]
15     for T in TT:
16 kchittur 1728 self.T.setRealValue(T)
17     #
18     # collect the data for plotting in two sets of arrays (one for X, one for Y)
19     # I have one set here - for P versus V at different T's
20     #
21     XX1 = []
22     YY1 = []
23     #
24     # there has to be a space between "in" and "["
25     #
26 kchittur 1457
27 kchittur 1728 for P in [8,9,10,15,20,25,30,40,50,60,70,80,100,120,140,150,170,190]:
28     self.P.setRealValueWithUnits(P,"bar")
29     #
30     # send the pair of values P, T to the solver
31     # and append the Volume and Pressure from the solver to the arrays
32     try:
33     browser.sim.solve(browser.solver,SimpleSolverReporter(browser,message="T = %f, P = %f" % (T,P)))
34     XX1.append(float(self.V))
35     YY1.append(float(self.P))
36     except:
37     browser.reporter.reportError('Failed to solve for P = %f' % P)
38     continue
39     ## plot the data
40    
41 jpye 1807 plot(XX1,YY1,label=("%d K" % T))
42 kchittur 1728
43     hold(1)
44 jpye 1807
45     legend()
46     xlabel("Molar volume")
47     ylabel("Presure (Pa)")
48     title("p-V curves at varying temperatures")
49 kchittur 1728 ion()
50     show()
51    
52     extpy.registermethod(pvplot)
53    
54 kchittur 1457 def zplot(self):
55    
56     browser = extpy.getbrowser()
57     ioff()
58     figure()
59 jpye 1807 axes([0.1,0.1,0.71,0.8])
60 kchittur 1457 #
61     # I have chosen three temperatures
62     #
63 jpye 1807 TT = [190,210,230,250,270,290,310,330,350,370]
64     for T in TT:
65 kchittur 1457 self.T.setRealValue(T)
66     #
67     # collect the data for plotting in two sets of arrays (one for X, one for Y)
68     # I have two sets here - one for P versus y and other for P versus x
69     #
70 jpye 1807 PPr1 = []
71     ZZ1 = []
72 kchittur 1457 #
73     # change x1 from 0 to 1.0
74     # there has to be a space between "in" and "["
75     #
76    
77 jpye 1807 for P in [10,11,12,13,15,20,25,30,40,50,60,70,80,100,120,140,150,170,175,180,185,190]:
78 kchittur 1457 self.P.setRealValueWithUnits(P,"bar")
79     #
80     # send the pair of values T x1 to the solver
81     # and append the Pressure and y1 (from the solver) to the arrays
82     # the x's are also appended
83     try:
84     browser.sim.solve(browser.solver,SimpleSolverReporter(browser,message="T = %f, P = %f" % (T,P)))
85 jpye 1807 PPr1.append(float(self.Pr))
86     ZZ1.append(float(self.Z))
87 kchittur 1457 except:
88     browser.reporter.reportError('Failed to solve for P = %f' % P)
89     continue
90     ## plot the data
91    
92 jpye 1807 plot(PPr1,ZZ1,label="%d K" % T)
93     hold(1)
94 kchittur 1457
95 jpye 1807 # after all the plots are done, add some labels and a legend
96     xlabel("Reduced pressure, p/p_crit")
97     ylabel("Generalised compressibility, z")
98     legend(loc=(1.03,0.2))
99 kchittur 1457 ion()
100     show()
101    
102     extpy.registermethod(zplot)
103 jpye 1807 # the above method can be called using "EXTERNAL zplot(self)" in ASCEND.
104 kchittur 1457 # if you want to see the azeotrope clearly, restrict the calculation to one
105 jpye 1807 # temperature
106    

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