Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 7c2e6f9e authored by Matthew Partridge's avatar Matthew Partridge
Browse files

Version 1 commit

parents
#!/usr/bin/env python3
"""GasFill_GUI.py """
__author__ = "Matthew Partridge"
__copyright__ = "Copyright 2018, University of Southampton"
__license__ = "GPL"
__version__ = "1.0"
#Packages
import numpy
import math
from scipy import constants
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QPushButton, QLabel, QApplication, QGridLayout, QCheckBox, QRadioButton, QFileDialog, QLineEdit, QSlider, QGroupBox, QVBoxLayout)
from PyQt5.QtGui import (QPixmap, QIntValidator, QDoubleValidator, QPalette)
from PyQt5.QtCore import Qt
import sys
import GasFill_times
#fiber variables
dia_tube = 0.02 #(mm) capillary diameter
len_tube = 2.7 #(m)
#gas variables
P = 10 #(mbar) average pressure inside capillary
mW = 26.04 #(g/mol)
temp = 21 #(degC) Temperature of system
dia_mol = 3.34 #(pm) diameter of gas molecule
# 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()
#!/usr/bin/env python3
"""GasFill_times.py """
__author__ = "Matthew Partridge"
__copyright__ = "Copyright 2018, University of Southampton"
__license__ = "GPL"
__version__ = "0.1"
"""Based on equations from "Analytical modeling of the gas-filling dynamics in photonic crystal fibers"""
#Pacakges
import numpy
import math
import fluids
from scipy import constants
def filltime (dia_tube,len_tube,P,mW,temp,dia_mol):
#varable scale fixing
rad_tube = dia_tube/2 #(mm)
P = P*100 #(PA) average pressure inside capillary
Pav = P * 2/3 #(mbar) average pressure inside capillary
dia_tube = dia_tube / 1000 #(m)
rad_tube = rad_tube / 1000 #(m)
temp = temp + 273.15 #(K)
dia_mol = 3.34 / 10000000000 #(m)
mW = 26.04 / 1000 #(kg/mol)
mM = mW / 6.02214e23 #(kg)
#Knudsen number ---------------
lamda = constants.Boltzmann*temp / (numpy.sqrt(2)*numpy.pi*Pav*numpy.power(dia_mol,2)) #from "Analytical modeling of the gas-filling dynamics in photonic crystal fibers"
#Kn = lamda/(Pav*dia_tube) #from "Flow of gases through tubes and orifices" where lamda = 0.066 for air at 20 deg
Kn = lamda/rad_tube #from others
print ("Knudsen number: "+str(round(Kn,3))+" ("+("Molecular flow" if Kn > 0.5 else "Knudsen flow" if Kn > 0.01 else "Viscous flow")+")")
#Diffusion coefficent ---------------
mol_vel = numpy.sqrt((8*constants.Boltzmann*temp)/(numpy.pi*mM)) #mean molecular velocity
viscosity = (mol_vel*mM)/(2*numpy.sqrt(2)*numpy.pi*numpy.power(dia_mol,2))
print ("Viscosity: "+ str(round(viscosity,3)))
ZKn = ((1+2.507/Kn)/(1+3.095/Kn))
diff_coeff = ((numpy.power(rad_tube,2)*Pav) / (8*viscosity)) + (ZKn * 2/3 * rad_tube * mol_vel)
print ("Diffusion coefficent: "+ str(round(diff_coeff*10000,3))+ " (cm2/s)")
#Fill time ---------------
squigle = 2
Ppercent = 85 #percent ratio
Pred = P/100*Ppercent
Pratio = P/(P-Pred)
t_fill = (numpy.power((squigle*len_tube),2) / (numpy.power(numpy.pi,2)*diff_coeff))*numpy.log((numpy.power(numpy.pi,2)/8)*Pratio)
print ("Fill time: "+str(round(t_fill/60))+" (mins)")
return t_fill
if __name__ == '__main__':
#Variables ---------------
#fiber variables
dia_tube = 0.02 #(mm) capillary diameter
len_tube = 2.7 #(m)
#gas variables
P = 10 #(mbar) average pressure inside capillary
mW = 26.04 #(g/mol)
temp = 21 #(degC) Temperature of system
dia_mol = 3.34 #(pm) diameter of gas molecule
# execute only if run as the entry point into the program
filltime(dia_tube,len_tube,P,mW,temp,dia_mol)
# Project Title
Hollow core gas fill times calculator.
## Description
This python calcualtor is based on the paper Analytical modeling of the gas-filling dynamics in photonic crystal fibers, I Dicaire et al, Applied Optics, Vol 49, No 24 (2010)
This calcualtor allows for the simple calcualtion of the approximate gas fill time of hollow core fibre based on fibre and gas variables.
### Prerequisites
Python 3
PyQt5
scipy
### Instructions
Run GasFill_GUI.py
## Authors
Matthew Partridge
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment