GasFill_GUI.py 4.12 KB
Newer Older
Matthew Partridge's avatar
Matthew Partridge committed
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/env python3

"""GasFill_GUI.py """

__author__  = "Matthew Partridge"
__copyright__   = "Copyright 2018, University of Southampton"
__license__ = "GPL"
__version__ = "1.0"

#Packages
import numpy
12
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QPushButton, QLabel, QApplication, QGridLayout, QFileDialog, QLineEdit, QGroupBox, QVBoxLayout)
Matthew Partridge's avatar
Matthew Partridge committed
13
14
15
16
17
18
19
from PyQt5.QtGui import (QPixmap, QIntValidator, QDoubleValidator, QPalette)
from PyQt5.QtCore import Qt
import sys
import GasFill_times


#fiber variables
20
dia_tube = 0.20 #(mm) capillary diameter
Matthew Partridge's avatar
Matthew Partridge committed
21
len_tube = 2.7 #(m)
22

Matthew Partridge's avatar
Matthew Partridge committed
23
24
#gas variables
P = 10 #(mbar) average pressure inside capillary
25
mW = 28.97 #(g/mol)
Matthew Partridge's avatar
Matthew Partridge committed
26
temp = 21 #(degC) Temperature of system
27
dia_mol = 359.99 #(pm) diameter of gas molecule
Matthew Partridge's avatar
Matthew Partridge committed
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# execute only if run as the entry point into the program


class GafFillGUI(QWidget):
    
    def __init__(self):
        super().__init__()
        
        self.initUI()
    
    def initUI(self):

        grid = QGridLayout()
        grid.setSpacing(5)

       	
        presetsgroupbox = QGroupBox("Variables")
        groupbox = QGridLayout()
        #groupbox.addStretch(0)
        presetsgroupbox.setLayout(groupbox)

        coreDiaText = QLabel('Core Diameter (mm)',self)
        groupbox.addWidget(coreDiaText, 0,0)

        self.coreDia = QLineEdit()
        self.coreDia.setValidator(QDoubleValidator()) #INT CHANGE
        self.coreDia.setText('0.02')
        groupbox.addWidget(self.coreDia, 0, 1)

        FibreLenText = QLabel('Fibre length (m)',self)
        groupbox.addWidget(FibreLenText, 1, 0)

        self.FibreLen = QLineEdit()
        self.FibreLen.setValidator(QDoubleValidator())
        self.FibreLen.setText('2.7')
        groupbox.addWidget(self.FibreLen, 1, 1)

        PressureText = QLabel('Pressure (mbar)',self)
        groupbox.addWidget(PressureText, 2, 0)

        self.Pressure = QLineEdit()
        self.Pressure.setValidator(QDoubleValidator())
        self.Pressure.setText('10')
        groupbox.addWidget(self.Pressure, 2, 1)

        TempText = QLabel('Temperature (Celcius)',self)
        groupbox.addWidget(TempText, 3, 0)

        self.Temp = QLineEdit()
        self.Temp.setValidator(QDoubleValidator())
        self.Temp.setText('20')
        groupbox.addWidget(self.Temp, 3, 1)

        mWText = QLabel('Molecular weight (g/mol)',self)
        groupbox.addWidget(mWText, 4, 0)

        self.mW = QLineEdit()
        self.mW.setValidator(QDoubleValidator())
        self.mW.setText('26.04')
        groupbox.addWidget(self.mW, 4, 1)

        diamolText = QLabel('Molecular diameter (pm)',self)
        groupbox.addWidget(diamolText, 5, 0)

        self.diamol = QLineEdit()
        self.diamol.setValidator(QDoubleValidator())
        self.diamol.setText('3.34')
        groupbox.addWidget(self.diamol, 5, 1)

        filltimeText = QLabel('Fill time (s)',self)
        grid.addWidget(filltimeText, 1, 0)

        grid.addWidget(presetsgroupbox,0,0, 1,3)

        self.filltime = QLineEdit()
        self.filltime.setValidator(QDoubleValidator())
        self.filltime.setReadOnly(True)
        Palette = QPalette()
        Palette.setColor(QPalette.Base, Qt.lightGray)
        self.filltime.setPalette(Palette)
        grid.addWidget(self.filltime, 1, 1)

        calc = QPushButton ('Calculate')
        grid.addWidget(calc,2,0)
        calc.clicked[bool].connect(self.calc)



        self.setLayout(grid)
        self.move(300, 200)
        self.resize(350,300)
        self.setWindowTitle('fiber ptssshhhh time')
        self.show()

    def calc (self):

        dia_tube = float(self.coreDia.text())
        len_tube = float(self.FibreLen.text())
        P = float(self.Pressure.text())
        mW = float(self.mW.text())
        temp = float(self.Temp.text())
        dia_mol = float(self.diamol.text())

        FillTime = GasFill_times.filltime(dia_tube,len_tube,P,mW,temp,dia_mol)
        self.filltime.setText(str(round(FillTime,1)))

    def quit (self):
        sys.exit(app.exec_())
        

GasFill_times.filltime(dia_tube,len_tube,P,mW,temp,dia_mol)

if __name__ == '__main__':
    
    app = QApplication(sys.argv)
    app.aboutToQuit.connect(quit) # myExitHandler is a callable
    ex = GafFillGUI()