-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
93 lines (77 loc) · 2.65 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import clr
clr.AddReferenceToFile("Pybrary.Plot.dll")
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
import System
from Pybrary import Plot
from System import Drawing
from GasProps import GasProps
from System.Drawing import Point, Size
from System.Windows.Forms import Application, Form, Label, DockStyle, MenuStrip
class MainForm(Form):
def __init__(self):
self.Text = self.Name = "Gas Property Calculator"
self.Size = Size(800, 600)
self.SuspendLayout()
pc = Plot.PlotControl()
pc.Location = Point(0, 22)
pc.Width = 640
pc.Height = 480
pc.Dock = DockStyle.Fill
pc.Plot = self.CreatePlot()
self.Controls.Add(pc)
menu = MenuStrip()
menu.Items.Add(pc.CreatePlotMenu())
self.Controls.Add(menu)
self.MainMenuStrip = menu
self.ResumeLayout()
def CreatePlot(self):
plot = Plot.Plot()
plot.UseNumericXAxis()
plot.DisplayLegend = True
plot.XAxis.Title = "Pressure (psia)"
plot.YAxes["Default"].Title = "z-factor"
plot.YAxes["Default"].AutoscaleIncludesZero = False
plot.YAxes.AddRight("Viscosity")
plot.YAxes["Viscosity"].Title = "Viscosity (cp)"
plot.YAxes["Viscosity"].GridlinesEnabled = False
#plot.YAxes["Viscosity"].AutoscaleIncludesZero = False
prop = GasProps()
prop.GG = 0.54
prop.N2 = prop.CO2 = prop.H2S = 0
p_data, z_data, mu_data = [], [], []
for p in range(20, 10000):
p_data.append(p)
z_data.append(prop.z(p, 560))
mu_data.append(prop.mug(p, 560))
series = Plot.ScatterSeries()
series.Data.Set(System.Array[float](p_data), System.Array[System.Nullable[float]](z_data))
series.YAxisName = "Default"
plot.Series[u"z @ 100\u00b0F"] = series
series = Plot.ScatterSeries()
series.Data.Set(System.Array[float](p_data), System.Array[System.Nullable[float]](mu_data))
series.YAxisName = "Viscosity"
series.Line.Color = Drawing.Color.Red
plot.Series[u"\u03bcg @ 560\u00b0F"] = series
return plot
form = MainForm()
Application.Run(form)
#import System
#from Pybrary import Plot
#from System import Drawing
#from GasProps import GasProps
#
#
#width_inches = 10
#height_inches = 8
#x_res = 96
#y_res = 96
#bmp = Drawing.Bitmap(width_inches*x_res, height_inches*y_res)
#bmp.SetResolution(x_res, y_res)
#
#g = Drawing.Graphics.FromImage(bmp)
#rect = Drawing.RectangleF(0, 0, width_inches*x_res, height_inches*y_res)
#plot.PaintOn(g, rect)
#g.Dispose()
#
#bmp.Save("test.png")