Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Dim b
Dim x(0 To 9)
'Array of Velocities at equilibrium'
Dim y(0 To 9)
'Calculations of velocities at equilibrium'
While index3 <= 9
y(index3) = 0.25
index3 = index3 + 1
End While
a(0) = y(0)
c(0) = y(0)
d(0) = y(0)
ee(0) = y(0)
f(0) = y(0)
g(0) = y(0)
h(0) = y(0)
i(0) = y(0)
'Filling Head reservoir values till the end of selected time of the simu
lation'
While index1 <= b
l(index1) = Val(TextBox7.Text)
index1 = index1 + 1
End While
'Calculation of Reynolds Number'
Re = (1000 * y(0) * (Val(TextBox6.Text) / 1000)) / 0.001
'Calculationf of Friction factor'
Fr = Val(TextBox4.Text)
'Calculation of Heads at equilibrium at every point'
While index4 <= 9
x(index4) = Val(TextBox7.Text) - (Le * Val(TextBox7.Text) / Val(Text
Box1.Text))
index4 = index4 + 1
Le = Le + (Val(TextBox1.Text) / 9)
End While
l(0) = 4
m(0) = 3.991
n(0) = 3.983
o(0) = 3.975
p(0) = 3.967
q(0) = 3.959
r(0) = 3.951
s(0) = 3.942
t(0) = 3.934
u(0) = 3.853
TextBox10.Text = m(0)
'Calculation of Velocity at valve between t= 0 to t valve closure'
While index2 < Val(TextBox8.Text) / Val(TextBox3.Text)
k(index2) = y(0) * (1 - (ti / Val(TextBox8.Text)))
index2 = index2 + 1
ti = ti + Val(TextBox3.Text)
End While
index5 = Val(TextBox8.Text) / Val(TextBox3.Text)
While index5 >= Val(TextBox8.Text) / Val(TextBox3.Text) And index5 < Val
(TextBox2.Text) / Val(TextBox3.Text)
k(index5) = 0
index5 = index5 + 1
End While
tiii = 0
'Transient calculations using C+ and C- equation for all points'
'velocity calcs' & 'Pressure calcs'
'tiii is time step!!'
While tiii < Val(TextBox2.Text) / Val(TextBox3.Text)
If tiii = 0 Then
a(tiii) = y(0)
c(tiii) = y(0)
d(tiii) = y(0)
ee(tiii) = y(0)
f(tiii) = y(0)
g(tiii) = y(0)
h(tiii) = y(0)
i(tiii) = y(0)
j(tiii) = y(0)
k(tiii) = y(0)
l(tiii) = l(0)
m(tiii) = m(0)
n(tiii) = n(0)
o(tiii) = o(0)
p(tiii) = p(0)
q(tiii) = q(0)
r(tiii) = r(0)
s(tiii) = s(0)
t(tiii) = t(0)
u(tiii) = u(0)
Else
a(tiii) = c(tiii - 1) + (9.81 / Val(TextBox5.Text) * (l(tiii - 1
) - m(tiii - 1))) - (Fr * Val(TextBox3.Text) / 2 * (Val(TextBox6.Text) / 1000) *
(c(tiii - 1)) * (Math.Abs(c(tiii - 1))))
c(tiii) = 0.5 * ((a(tiii - 1) + d(tiii - 1)) + (9.81 / Val(TextB
ox5.Text) * (l(tiii - 1) - n(tiii - 1))) - (Fr * Val(TextBox3.Text) / (2 * Val(T
extBox6.Text)) * ((a(tiii - 1) * Math.Abs(a(tiii - 1))) + (d(tiii - 1) * Math.Ab
s(d(tiii - 1))))))
d(tiii) = 0.5 * ((c(tiii - 1) + ee(tiii - 1)) + (9.81 / Val(Text
Box5.Text) * (m(tiii - 1) - o(tiii - 1))) - (Fr * Val(TextBox3.Text) / (2 * Val(
TextBox6.Text)) * ((c(tiii - 1) * Math.Abs(c(tiii - 1))) + (ee(tiii - 1) * Math.
Abs(ee(tiii - 1))))))
ee(tiii) = 0.5 * ((d(tiii - 1) + f(tiii - 1)) + (9.81 / Val(Text
Box5.Text) * (n(tiii - 1) - p(tiii - 1))) - (Fr * Val(TextBox3.Text) / (2 * Val(
TextBox6.Text)) * ((d(tiii - 1) * Math.Abs(d(tiii - 1))) + (f(tiii - 1) * Math.A
bs(f(tiii - 1))))))
f(tiii) = 0.5 * ((ee(tiii - 1) + g(tiii - 1)) + (9.81 / Val(Text
Box5.Text) * (o(tiii - 1) - q(tiii - 1))) - (Fr * Val(TextBox3.Text) / (2 * Val(
TextBox6.Text)) * ((ee(tiii - 1) * Math.Abs(ee(tiii - 1))) + (g(tiii - 1) * Math
.Abs(g(tiii - 1))))))
g(tiii) = 0.5 * ((f(tiii - 1) + h(tiii - 1)) + (9.81 / Val(TextB
ox5.Text) * (p(tiii - 1) - r(tiii - 1))) - (Fr * Val(TextBox3.Text) / (2 * Val(T
extBox6.Text)) * ((f(tiii - 1) * Math.Abs(f(tiii - 1))) + (h(tiii - 1) * Math.Ab
s(h(tiii - 1))))))
End
Dim
Dim
Dim
Dim
Dim
End If
tiii = tiii + 1
While
oExcel As Object
oBook As Object
oSheet As Object
ii As Integer
dd As Integer
ii = 0
dd = 1
'Start a new workbook in Excel.
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook.
While ii < (Val(TextBox2.Text) / Val(TextBox3.Text))
oSheet = oBook.Worksheets(1)
oSheet.Cells(dd, 1).Value = l(ii)
oSheet.Cells(dd, 2).Value = m(ii)
oSheet.Cells(dd, 3).Value = n(ii)
oSheet.Cells(dd, 5).Value = o(ii)
oSheet.Cells(dd, 6).Value = p(ii)
oSheet.Cells(dd, 6).Value = q(ii)
oSheet.Cells(dd, 6).Value = r(ii)
oSheet.Cells(dd, 6).Value = s(ii)
oSheet.Cells(dd, 6).Value = t(ii)
ii = ii + 1
dd = ii + 1
End While
'Save the Workbook and quit Excel.
oBook.SaveAs("C:\Users\kobeisr\Desktop\Book1.xlsx")
oSheet = Nothing
oBook = Nothing
oExcel.Quit()
oExcel = Nothing
GC.Collect()
End Sub
End Class