コード例 #1
0
ファイル: test_pipe.py プロジェクト: MichaelD7/hydraulics
class TestPipe(unittest.TestCase):
    def setUp(self):
        self.pipe1 = Pipe()

    # Mild slope, critical depth at downstream end
    def test_run1(self):
        self.pipe1.setValues(0.5, 1.0, 100.0, 1.0, 0.9, 0.003, 1.141e-06)
        self.pipe1.calculate()
        self.assertAlmostEqual(self.pipe1.crit_depth, 0.399, 3)
        self.assertAlmostEqual(self.pipe1.norm_depth, 0.640, 3)
        self.assertAlmostEqual(self.pipe1.energy[0], 1.448, 3)
        self.assertAlmostEqual(self.pipe1.energy[-1], 1.634, 3)

    # Mild slope, downstream water depth 1.3m
    def test_run2(self):
        self.pipe1.setValues(0.5, 1.0, 100.0, 1.0, 0.9, 0.003, 1.141e-06, 0.4,
                             False, "DWCW", 0, 0)
        self.pipe1.calculate()
        self.assertAlmostEqual(self.pipe1.crit_depth, 0.399, 3)
        self.assertAlmostEqual(self.pipe1.norm_depth, 0.640, 3)
        self.assertAlmostEqual(self.pipe1.energy[0], 1.448, 3)
        self.assertAlmostEqual(self.pipe1.energy[-1], 1.634, 3)

    # Critical depth full length
    def test_run3(self):
        self.pipe1.setValues(0.5, 1.0, 100.0, 1.0, 0.0, 0.003, 1.141e-06, 0.0,
                             False, "DWCW", 0, 0)
        self.pipe1.calculate()
        self.assertAlmostEqual(self.pipe1.crit_depth, 0.399, 3)
        self.assertAlmostEqual(self.pipe1.norm_depth, 0.327, 3)
        self.assertAlmostEqual(self.pipe1.energy[0], 0.548, 3)
        self.assertAlmostEqual(self.pipe1.energy[-1], 1.548, 3)

    # Level slope
    def test_run4(self):
        self.pipe1.setValues(0.5, 1.0, 100.0, 1.0, 1.0, 0.003, 1.141e-06, 0.4,
                             False, "DWCW", 0, 0)
        self.pipe1.calculate()
        self.assertAlmostEqual(self.pipe1.crit_depth, 0.399, 3)
        self.assertAlmostEqual(self.pipe1.norm_depth, None, 3)
        self.assertAlmostEqual(self.pipe1.energy[0], 1.548, 3)
        self.assertAlmostEqual(self.pipe1.energy[-1], 1.698, 3)
コード例 #2
0
ファイル: pipe_test2.py プロジェクト: MichaelD7/hydraulics
import sys
from os import path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from pipe import Pipe
# main
"""enter flow, diameter, length, us invert, ds invert, Ks, kinematic viscocity"""
# channel1 = channel.Channel(0.5, 1.0, 2.0, 100, 0.1, 0.0, 0.003, 1.141e-06, 0.4)
print("Pipe Test Run 3")
pipe1 = Pipe()
pipe1.setValues(0.5, 1.0, 100.0, 1.0, 0.0, 0.003, 1.141e-06)
# print(channel1.critical_depth())
# print(channel1.normal_depth())
# crit_depth = channel1.critical_depth()
pipe1.calculate()
print(pipe1.crit_depth)
print(pipe1.norm_depth)
# print(channel1.chainage[0], channel1.energy[0], channel1.water[0], channel1.head[0])
x = 0
for i in pipe1.chainage:
    print("Length %.1f" % i, "Energy %.3f" % pipe1.energy[x],
          "Water %.3f" % pipe1.water[x], "Head %.3f" % pipe1.head[x])
    x += 1

print("Test Run 4")
pipe1.setValues(0.5, 1.0, 100.0, 1.0, 1.0, 0.003, 1.141e-06, 0.4, False,
                "DWCW", 0, 0)
# print(channel1.critical_depth())
# print(channel1.normal_depth())
# crit_depth = channel1.critical_depth()
pipe1.calculate()
print(pipe1.crit_depth)