Parent Directory | Revision Log

Revision **1807** -
(**show annotations**)
(**download**)
(**as text**)

*Mon Jul 21 09:23:57 2008 UTC*
(12 years, 7 months ago)
by *jpye*

File MIME type: text/x-python

File size: 2672 byte(s)

File MIME type: text/x-python

File size: 2672 byte(s)

Added legend to zplot.

1 | import extpy |

2 | from pylab import * |

3 | from solverreporter import * |

4 | |

5 | def pvplot(self): |

6 | |

7 | browser = extpy.getbrowser() |

8 | ioff() |

9 | figure() |

10 | # |

11 | # I have chosen several temperatures |

12 | # |

13 | |

14 | TT = [190,210,230,250,270,290,310,330,350,370,400,420] |

15 | for T in TT: |

16 | 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 | |

27 | 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 | plot(XX1,YY1,label=("%d K" % T)) |

42 | |

43 | hold(1) |

44 | |

45 | legend() |

46 | xlabel("Molar volume") |

47 | ylabel("Presure (Pa)") |

48 | title("p-V curves at varying temperatures") |

49 | ion() |

50 | show() |

51 | |

52 | extpy.registermethod(pvplot) |

53 | |

54 | def zplot(self): |

55 | |

56 | browser = extpy.getbrowser() |

57 | ioff() |

58 | figure() |

59 | axes([0.1,0.1,0.71,0.8]) |

60 | # |

61 | # I have chosen three temperatures |

62 | # |

63 | TT = [190,210,230,250,270,290,310,330,350,370] |

64 | for T in TT: |

65 | 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 | PPr1 = [] |

71 | ZZ1 = [] |

72 | # |

73 | # change x1 from 0 to 1.0 |

74 | # there has to be a space between "in" and "[" |

75 | # |

76 | |

77 | 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 | 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 | PPr1.append(float(self.Pr)) |

86 | ZZ1.append(float(self.Z)) |

87 | except: |

88 | browser.reporter.reportError('Failed to solve for P = %f' % P) |

89 | continue |

90 | ## plot the data |

91 | |

92 | plot(PPr1,ZZ1,label="%d K" % T) |

93 | hold(1) |

94 | |

95 | # 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 | ion() |

100 | show() |

101 | |

102 | extpy.registermethod(zplot) |

103 | # the above method can be called using "EXTERNAL zplot(self)" in ASCEND. |

104 | # if you want to see the azeotrope clearly, restrict the calculation to one |

105 | # temperature |

106 |

john.pye@anu.edu.au | ViewVC Help |

Powered by ViewVC 1.1.22 |