Changeset 8986
- Timestamp:
- Sep 23, 2013, 9:13:05 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/test_boyd_box_operator.py
r8985 r8986 160 160 use_velocity_head=False, 161 161 manning=culvert_mannings, 162 logging= True,162 logging=False, 163 163 label='3.6x3.6RCBC', 164 164 verbose=False) … … 488 488 use_velocity_head=True, 489 489 manning=culvert_mannings, 490 logging= True,490 logging=False, 491 491 label='3.6x1.2RCBC', 492 492 verbose=False) … … 661 661 use_velocity_head=True, 662 662 manning=culvert_mannings, 663 logging= True,663 logging=False, 664 664 label='3.6x1.2RCBC', 665 665 verbose=False) … … 842 842 use_velocity_head=True, 843 843 manning=culvert_mannings, 844 logging= True,844 logging=False, 845 845 label='3.6x1.2RCBC', 846 846 verbose=False) … … 1024 1024 use_velocity_head=True, 1025 1025 manning=culvert_mannings, 1026 logging= True,1026 logging=False, 1027 1027 label='3.6x1.2RCBC', 1028 1028 verbose=False) … … 1200 1200 use_velocity_head=True, 1201 1201 manning=culvert_mannings, 1202 logging= True,1202 logging=False, 1203 1203 label='3.6x1.2RCBC', 1204 1204 verbose=False) … … 1375 1375 use_velocity_head=True, 1376 1376 manning=culvert_mannings, 1377 logging= True,1377 logging=False, 1378 1378 label='3.6x1.2RCBC', 1379 1379 verbose=False) … … 1393 1393 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1394 1394 1395 def test_boyd_7(self): 1396 """test_boyd_7 1397 1398 This tests the Boyd routine with data obtained from ??? by Petar Milevski 1399 """ 1400 # FIXME(Ole): This test fails (20 Feb 2009) 1401 1402 g=9.81 1403 1404 1405 inlet_depth=0.150 1406 outlet_depth=0.15 1407 inlet_velocity=1.00 1408 outlet_velocity=0.5 1409 1410 culvert_length=10.0 1411 culvert_width=3.6 1412 culvert_height=1.20 1413 1414 culvert_type='box' 1415 manning=0.013 1416 sum_loss=1.5 1417 1418 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1419 culvert_slope=1 # % Downward 1420 z_in = 10.0 1421 z_out = z_in-culvert_length*culvert_slope/100 1422 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1423 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1424 delta_total_energy = E_in-E_out 1425 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1426 1427 1428 Q_expected = 0.5526 1429 v_expected = 1.146 1430 d_expected = 0.1339 1431 1432 if verbose: 1433 print 50*'=' 1434 print 'width ',culvert_width 1435 print 'depth ',culvert_height 1436 print 'flow_width ',culvert_width 1437 print 'length ' ,culvert_length 1438 print 'driving_energy ',inlet_specific_energy 1439 print 'delta_total_energy ',delta_total_energy 1440 print 'outlet_enquiry_depth ',outlet_depth 1441 print 'sum_loss ',sum_loss 1442 print 'manning ',manning 1443 1444 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 1445 culvert_height, 1446 culvert_width, 1447 culvert_length, 1448 inlet_specific_energy, 1449 delta_total_energy, 1450 outlet_depth, 1451 sum_loss, 1452 manning) 1453 1454 # Q, v, d = boyd_generalised_culvert_model(inlet_depth, 1455 # outlet_depth, 1456 # inlet_velocity, 1457 # outlet_velocity, 1458 # inlet_specific_energy, 1459 # delta_total_energy, 1460 # g, 1461 # culvert_length, 1462 # culvert_width, 1463 # culvert_height, 1464 # culvert_type, 1465 # manning, 1466 # sum_loss) 1467 if verbose: 1468 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST01 Q-v-d',Q,v,d)) 1469 print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected)) 1470 1471 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 1472 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 1473 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 1474 1475 def test_boyd_7_operator(self): 1476 """test_boyd_non_skew 1477 1478 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 1479 calculation code by MJ Boyd 1480 """ 1481 1482 g=9.81 1483 1484 1485 inlet_depth=0.150 1486 outlet_depth=0.15 1487 inlet_velocity=1.00 1488 outlet_velocity=0.5 1489 1490 culvert_length=10.0 1491 culvert_width=3.6 1492 culvert_height=1.20 1493 1494 culvert_type='box' 1495 manning=0.013 1496 sum_loss=1.5 1497 1498 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1499 culvert_slope=1 # % Downward 1500 z_in = 10.0 1501 z_out = z_in-culvert_length*culvert_slope/100 1502 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1503 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1504 delta_total_energy = E_in-E_out 1505 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1506 1507 1508 Q_expected = 0.5526 1509 v_expected = 1.146 1510 d_expected = 0.1339 1511 1512 1513 1514 elevation_0 = z_in 1515 elevation_1 = z_out 1516 1517 stage_0 = elevation_0 + inlet_depth 1518 stage_1 = elevation_1 + outlet_depth 1519 1520 1521 domain_length = 200.0 1522 domain_width = 200.0 1523 1524 #culvert_length = 20.0 1525 #culvert_width = 3.66 1526 #culvert_height = 3.66 1527 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 1528 culvert_mannings = 0.013 1529 1530 culvert_apron = 0.0 1531 enquiry_gap = 5.0 1532 1533 1534 1535 1536 domain = self._create_domain(d_length=domain_length, 1537 d_width=domain_width, 1538 dx = 5.0, 1539 dy = 5.0, 1540 elevation_0 = elevation_0, 1541 elevation_1 = elevation_1, 1542 stage_0 = stage_0, 1543 stage_1 = stage_1, 1544 xvelocity_0 = inlet_velocity, 1545 xvelocity_1 = outlet_velocity) 1546 1547 1548 #print 'Defining Structures' 1549 1550 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 1551 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 1552 1553 1554 culvert = Boyd_box_operator(domain, 1555 losses=culvert_losses, 1556 width=culvert_width, 1557 end_points=[ep0, ep1], 1558 height=culvert_height, 1559 apron=culvert_apron, 1560 enquiry_gap=enquiry_gap, 1561 use_momentum_jet=False, 1562 use_velocity_head=True, 1563 manning=culvert_mannings, 1564 logging=False, 1565 label='3.6x1.2RCBC', 1566 verbose=False) 1567 1568 #culvert.determine_inflow_outflow() 1569 1570 ( Q, v, d ) = culvert.discharge_routine() 1571 1572 if verbose: 1573 print 'test_boyd_operator_1' 1574 print 'expected ',Q_expected,v_expected, d_expected 1575 print 'calc ',Q,v,d 1576 1577 1578 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 1579 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 1580 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1581 1582 1583 1584 def test_boyd_8(self): 1585 """test_boyd_8 1586 1587 This tests the Boyd routine with data obtained from ??? by Petar Milevski 1588 """ 1589 # FIXME(Ole): This test fails (20 Feb 2009) 1590 1591 g=9.81 1592 culvert_slope=1 # Downward 1593 1594 inlet_depth=0.500 1595 outlet_depth=0.700 1596 inlet_velocity=1.50 1597 outlet_velocity=0.50 1598 1599 culvert_length=10.0 1600 culvert_width=3.60 1601 culvert_height=1.20 1602 1603 culvert_type='box' 1604 manning=0.013 1605 sum_loss=1.5 1606 1607 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1608 z_in = 0.0 1609 z_out = z_in-culvert_length*culvert_slope/100 1610 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1611 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1612 delta_total_energy = E_in-E_out 1613 1614 1615 Q_expected = 0.224 1616 v_expected = 0.152 1617 d_expected = 0.409 1618 1619 if verbose: 1620 print 50*'=' 1621 print 'width ',culvert_width 1622 print 'depth ',culvert_height 1623 print 'flow_width ',culvert_width 1624 print 'length ' ,culvert_length 1625 print 'driving_energy ',inlet_specific_energy 1626 print 'delta_total_energy ',delta_total_energy 1627 print 'outlet_enquiry_depth ',outlet_depth 1628 print 'sum_loss ',sum_loss 1629 print 'manning ',manning 1630 1631 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 1632 culvert_height, 1633 culvert_width, 1634 culvert_length, 1635 inlet_specific_energy, 1636 delta_total_energy, 1637 outlet_depth, 1638 sum_loss, 1639 manning) 1640 1641 # Q, v, d = boyd_generalised_culvert_model(inlet_depth, 1642 # outlet_depth, 1643 # inlet_velocity, 1644 # outlet_velocity, 1645 # inlet_specific_energy, 1646 # delta_total_energy, 1647 # g, 1648 # culvert_length, 1649 # culvert_width, 1650 # culvert_height, 1651 # culvert_type, 1652 # manning, 1653 # sum_loss) 1654 if verbose: 1655 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST02 Q-v-d',Q,v,d)) 1656 print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected)) 1657 1658 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 1659 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 1660 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 1661 1662 def test_boyd_8_operator(self): 1663 """test_boyd_non_skew 1664 1665 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 1666 calculation code by MJ Boyd 1667 """ 1668 1669 g=9.81 1670 culvert_slope=1 # Downward 1671 1672 inlet_depth=0.500 1673 outlet_depth=0.700 1674 inlet_velocity=1.50 1675 outlet_velocity=0.50 1676 1677 culvert_length=10.0 1678 culvert_width=3.60 1679 culvert_height=1.20 1680 1681 culvert_type='box' 1682 manning=0.013 1683 sum_loss=1.5 1684 1685 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1686 z_in = 0.0 1687 z_out = z_in-culvert_length*culvert_slope/100 1688 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1689 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1690 delta_total_energy = E_in-E_out 1691 1692 1693 Q_expected = 0.224 1694 v_expected = 0.152 1695 d_expected = 0.409 1696 1697 elevation_0 = z_in 1698 elevation_1 = z_out 1699 1700 stage_0 = elevation_0 + inlet_depth 1701 stage_1 = elevation_1 + outlet_depth 1702 1703 1704 domain_length = 200.0 1705 domain_width = 200.0 1706 1707 #culvert_length = 20.0 1708 #culvert_width = 3.66 1709 #culvert_height = 3.66 1710 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 1711 culvert_mannings = 0.013 1712 1713 culvert_apron = 0.0 1714 enquiry_gap = 5.0 1715 1716 1717 1718 1719 domain = self._create_domain(d_length=domain_length, 1720 d_width=domain_width, 1721 dx = 5.0, 1722 dy = 5.0, 1723 elevation_0 = elevation_0, 1724 elevation_1 = elevation_1, 1725 stage_0 = stage_0, 1726 stage_1 = stage_1, 1727 xvelocity_0 = inlet_velocity, 1728 xvelocity_1 = outlet_velocity) 1729 1730 1731 #print 'Defining Structures' 1732 1733 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 1734 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 1735 1736 1737 culvert = Boyd_box_operator(domain, 1738 losses=culvert_losses, 1739 width=culvert_width, 1740 end_points=[ep0, ep1], 1741 height=culvert_height, 1742 apron=culvert_apron, 1743 enquiry_gap=enquiry_gap, 1744 use_momentum_jet=False, 1745 use_velocity_head=True, 1746 manning=culvert_mannings, 1747 logging=False, 1748 label='3.6x1.2RCBC', 1749 verbose=False) 1750 1751 #culvert.determine_inflow_outflow() 1752 1753 ( Q, v, d ) = culvert.discharge_routine() 1754 1755 if verbose: 1756 print 'test_boyd_operator_1' 1757 print 'expected ',Q_expected,v_expected, d_expected 1758 print 'calc ',Q,v,d 1759 1760 1761 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 1762 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 1763 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 1764 1765 1766 def test_boyd_9(self): 1767 """test_boyd_9 1768 1769 This tests the Boyd routine with data obtained from ??? by Petar Milevski 1770 """ 1771 # FIXME(Ole): This test fails (20 Feb 2009) 1772 1773 g=9.81 1774 culvert_slope=1 # Downward 1775 1776 inlet_depth=1.800 1777 outlet_depth=0.80 1778 inlet_velocity=1.0 1779 outlet_velocity=0.5 1780 1781 culvert_length=10.0 1782 culvert_width=3.60 1783 culvert_height=1.20 1784 1785 culvert_type='box' 1786 manning=0.013 1787 sum_loss=1.5 1788 1789 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1790 z_in = 0.0 1791 z_out = z_in-culvert_length*culvert_slope/100 1792 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1793 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1794 delta_total_energy = E_in-E_out 1795 1796 1797 Q_expected = 13.554 1798 v_expected = 3.329 1799 d_expected = 1.131 1800 1801 if verbose: 1802 print 50*'=' 1803 print 'width ',culvert_width 1804 print 'depth ',culvert_height 1805 print 'flow_width ',culvert_width 1806 print 'length ' ,culvert_length 1807 print 'driving_energy ',inlet_specific_energy 1808 print 'delta_total_energy ',delta_total_energy 1809 print 'outlet_enquiry_depth ',outlet_depth 1810 print 'sum_loss ',sum_loss 1811 print 'manning ',manning 1812 1813 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 1814 culvert_height, 1815 culvert_width, 1816 culvert_length, 1817 inlet_specific_energy, 1818 delta_total_energy, 1819 outlet_depth, 1820 sum_loss, 1821 manning) 1822 1823 1824 # Q, v, d = boyd_generalised_culvert_model(inlet_depth, 1825 # outlet_depth, 1826 # inlet_velocity, 1827 # outlet_velocity, 1828 # inlet_specific_energy, 1829 # delta_total_energy, 1830 # g, 1831 # culvert_length, 1832 # culvert_width, 1833 # culvert_height, 1834 # culvert_type, 1835 # manning, 1836 # sum_loss) 1837 1838 if verbose: 1839 print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy)) 1840 print ('%s,%.2f'%('Delta E = ',delta_total_energy)) 1841 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST03 Q-v-d',Q,v,d)) 1842 print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected)) 1843 1844 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 1845 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 1846 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 1847 1848 def test_boyd_9_operator(self): 1849 """test_boyd_non_skew 1850 1851 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 1852 calculation code by MJ Boyd 1853 """ 1854 1855 g=9.81 1856 culvert_slope=1 # Downward 1857 1858 inlet_depth=1.800 1859 outlet_depth=0.80 1860 inlet_velocity=1.0 1861 outlet_velocity=0.5 1862 1863 culvert_length=10.0 1864 culvert_width=3.60 1865 culvert_height=1.20 1866 1867 culvert_type='box' 1868 manning=0.013 1869 sum_loss=1.5 1870 1871 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1872 z_in = 0.0 1873 z_out = z_in-culvert_length*culvert_slope/100 1874 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1875 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1876 delta_total_energy = E_in-E_out 1877 1878 1879 Q_expected = 13.554 1880 v_expected = 3.329 1881 d_expected = 1.131 1882 1883 1884 elevation_0 = z_in 1885 elevation_1 = z_out 1886 1887 stage_0 = elevation_0 + inlet_depth 1888 stage_1 = elevation_1 + outlet_depth 1889 1890 1891 domain_length = 200.0 1892 domain_width = 200.0 1893 1894 #culvert_length = 20.0 1895 #culvert_width = 3.66 1896 #culvert_height = 3.66 1897 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 1898 culvert_mannings = 0.013 1899 1900 culvert_apron = 0.0 1901 enquiry_gap = 5.0 1902 1903 1904 1905 1906 domain = self._create_domain(d_length=domain_length, 1907 d_width=domain_width, 1908 dx = 5.0, 1909 dy = 5.0, 1910 elevation_0 = elevation_0, 1911 elevation_1 = elevation_1, 1912 stage_0 = stage_0, 1913 stage_1 = stage_1, 1914 xvelocity_0 = inlet_velocity, 1915 xvelocity_1 = outlet_velocity) 1916 1917 1918 #print 'Defining Structures' 1919 1920 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 1921 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 1922 1923 1924 culvert = Boyd_box_operator(domain, 1925 losses=culvert_losses, 1926 width=culvert_width, 1927 end_points=[ep0, ep1], 1928 height=culvert_height, 1929 apron=culvert_apron, 1930 enquiry_gap=enquiry_gap, 1931 use_momentum_jet=False, 1932 use_velocity_head=True, 1933 manning=culvert_mannings, 1934 logging=False, 1935 label='3.6x1.2RCBC', 1936 verbose=False) 1937 1938 #culvert.determine_inflow_outflow() 1939 1940 ( Q, v, d ) = culvert.discharge_routine() 1941 1942 if verbose: 1943 print 'test_boyd_operator_1' 1944 print 'expected ',Q_expected,v_expected, d_expected 1945 print 'calc ',Q,v,d 1946 1947 1948 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 1949 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 1950 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1951 1952 def test_boyd_10(self): 1953 """test_boyd_10 1954 1955 This tests the Boyd routine with data obtained from ??? by Petar Milevski 1956 """ 1957 # FIXME(Ole): This test fails (20 Feb 2009) 1958 1959 g=9.81 1960 culvert_slope=1 # Downward 1961 1962 inlet_depth=1.00 1963 outlet_depth=0.8 1964 inlet_velocity=1.0 1965 outlet_velocity=0.5 1966 culvert_length=10.0 1967 culvert_width=3.60 1968 culvert_height=1.20 1969 1970 culvert_type='box' 1971 manning=0.013 1972 sum_loss=1.5 1973 1974 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 1975 z_in = 10.0 1976 z_out = 10.0-culvert_length*culvert_slope/100 1977 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 1978 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 1979 delta_total_energy = E_in-E_out 1980 1981 1982 1983 Q_expected = 5.164 1984 v_expected = 2.047 1985 d_expected = 0.70 1986 1987 if verbose: 1988 print 50*'=' 1989 print 'width ',culvert_width 1990 print 'depth ',culvert_height 1991 print 'flow_width ',culvert_width 1992 print 'length ' ,culvert_length 1993 print 'driving_energy ',inlet_specific_energy 1994 print 'delta_total_energy ',delta_total_energy 1995 print 'outlet_enquiry_depth ',outlet_depth 1996 print 'sum_loss ',sum_loss 1997 print 'manning ',manning 1998 1999 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 2000 culvert_height, 2001 culvert_width, 2002 culvert_length, 2003 inlet_specific_energy, 2004 delta_total_energy, 2005 outlet_depth, 2006 sum_loss, 2007 manning) 2008 2009 # Q, v, d = boyd_generalised_culvert_model(inlet_depth, 2010 # outlet_depth, 2011 # inlet_velocity, 2012 # outlet_velocity, 2013 # inlet_specific_energy, 2014 # delta_total_energy, 2015 # g, 2016 # culvert_length, 2017 # culvert_width, 2018 # culvert_height, 2019 # culvert_type, 2020 # manning, 2021 # sum_loss) 2022 2023 if verbose: 2024 print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy)) 2025 print ('%s,%.2f'%('Delta E = ',delta_total_energy)) 2026 print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST04 Q-v-d',Q,v,d)) 2027 print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected)) 2028 2029 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 2030 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 2031 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 2032 2033 def test_boyd_10_operator(self): 2034 """test_boyd_non_skew 2035 2036 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 2037 calculation code by MJ Boyd 2038 """ 2039 2040 g=9.81 2041 culvert_slope=1 # Downward 2042 2043 inlet_depth=1.00 2044 outlet_depth=0.8 2045 inlet_velocity=1.0 2046 outlet_velocity=0.5 2047 culvert_length=10.0 2048 culvert_width=3.60 2049 culvert_height=1.20 2050 2051 culvert_type='box' 2052 manning=0.013 2053 sum_loss=1.5 2054 2055 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 2056 z_in = 10.0 2057 z_out = 10.0-culvert_length*culvert_slope/100 2058 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 2059 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 2060 delta_total_energy = E_in-E_out 2061 2062 2063 2064 Q_expected = 5.164 2065 v_expected = 2.047 2066 d_expected = 0.70 2067 2068 2069 2070 elevation_0 = z_in 2071 elevation_1 = z_out 2072 2073 stage_0 = elevation_0 + inlet_depth 2074 stage_1 = elevation_1 + outlet_depth 2075 2076 2077 domain_length = 200.0 2078 domain_width = 200.0 2079 2080 #culvert_length = 20.0 2081 #culvert_width = 3.66 2082 #culvert_height = 3.66 2083 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 2084 culvert_mannings = 0.013 2085 2086 culvert_apron = 0.0 2087 enquiry_gap = 5.0 2088 2089 2090 2091 2092 domain = self._create_domain(d_length=domain_length, 2093 d_width=domain_width, 2094 dx = 5.0, 2095 dy = 5.0, 2096 elevation_0 = elevation_0, 2097 elevation_1 = elevation_1, 2098 stage_0 = stage_0, 2099 stage_1 = stage_1, 2100 xvelocity_0 = inlet_velocity, 2101 xvelocity_1 = outlet_velocity) 2102 2103 2104 #print 'Defining Structures' 2105 2106 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 2107 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 2108 2109 2110 culvert = Boyd_box_operator(domain, 2111 losses=culvert_losses, 2112 width=culvert_width, 2113 end_points=[ep0, ep1], 2114 height=culvert_height, 2115 apron=culvert_apron, 2116 enquiry_gap=enquiry_gap, 2117 use_momentum_jet=False, 2118 use_velocity_head=True, 2119 manning=culvert_mannings, 2120 logging=False, 2121 label='3.6x1.2RCBC', 2122 verbose=False) 2123 2124 #culvert.determine_inflow_outflow() 2125 2126 ( Q, v, d ) = culvert.discharge_routine() 2127 2128 if verbose: 2129 print 'test_boyd_operator_1' 2130 print 'expected ',Q_expected,v_expected, d_expected 2131 print 'calc ',Q,v,d 2132 2133 2134 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 2135 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 2136 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 2137 2138 def test_boyd_11(self): 2139 """test_boyd_11 2140 2141 This tests the Boyd routine with data obtained from ??? by Petar Milevski 2142 """ 2143 # FIXME(Ole): This test fails (20 Feb 2009) 2144 2145 g=9.81 2146 culvert_slope=1 # Downward 2147 2148 inlet_depth=1.50 2149 inlet_velocity= 1.0 2150 outlet_depth=1.3 2151 outlet_velocity=0.5 2152 culvert_length=10.0 2153 culvert_width=3.60 2154 culvert_height=1.20 2155 2156 culvert_type='box' 2157 manning=0.013 2158 sum_loss=1.5 2159 2160 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 2161 z_in = 10.0 2162 z_out = 10.0-culvert_length*culvert_slope/100 2163 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 2164 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 2165 delta_total_energy = E_in-E_out 2166 2167 2168 Q_expected = 8.808 2169 v_expected = 2.039 2170 d_expected = 1.20 2171 2172 if verbose: 2173 print 50*'=' 2174 print 'width ',culvert_width 2175 print 'depth ',culvert_height 2176 print 'flow_width ',culvert_width 2177 print 'length ' ,culvert_length 2178 print 'driving_energy ',inlet_specific_energy 2179 print 'delta_total_energy ',delta_total_energy 2180 print 'outlet_enquiry_depth ',outlet_depth 2181 print 'sum_loss ',sum_loss 2182 print 'manning ',manning 2183 2184 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 2185 culvert_height, 2186 culvert_width, 2187 culvert_length, 2188 inlet_specific_energy, 2189 delta_total_energy, 2190 outlet_depth, 2191 sum_loss, 2192 manning) 2193 2194 # Q, v, d = boyd_generalised_culvert_model(inlet_depth, 2195 # outlet_depth, 2196 # inlet_velocity, 2197 # outlet_velocity, 2198 # inlet_specific_energy, 2199 # delta_total_energy, 2200 # g, 2201 # culvert_length, 2202 # culvert_width, 2203 # culvert_height, 2204 # culvert_type, 2205 # manning, 2206 # sum_loss) 2207 if verbose: 2208 print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy)) 2209 print ('%s,%.3f'%('Delta E = ',delta_total_energy)) 2210 2211 print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST05Q-v-d',Q,v,d)) 2212 print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected)) 2213 2214 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 2215 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 2216 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 2217 2218 def test_boyd_11_operator(self): 2219 """test_boyd_non_skew 2220 2221 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 2222 calculation code by MJ Boyd 2223 """ 2224 2225 g=9.81 2226 culvert_slope=1 # Downward 2227 2228 inlet_depth=1.50 2229 inlet_velocity= 1.0 2230 outlet_depth=1.3 2231 outlet_velocity=0.5 2232 culvert_length=10.0 2233 culvert_width=3.60 2234 culvert_height=1.20 2235 2236 culvert_type='box' 2237 manning=0.013 2238 sum_loss=1.5 2239 2240 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 2241 z_in = 10.0 2242 z_out = 10.0-culvert_length*culvert_slope/100 2243 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 2244 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 2245 delta_total_energy = E_in-E_out 2246 2247 2248 Q_expected = 8.808 2249 v_expected = 2.039 2250 d_expected = 1.20 2251 2252 2253 2254 elevation_0 = z_in 2255 elevation_1 = z_out 2256 2257 stage_0 = elevation_0 + inlet_depth 2258 stage_1 = elevation_1 + outlet_depth 2259 2260 2261 domain_length = 200.0 2262 domain_width = 200.0 2263 2264 #culvert_length = 20.0 2265 #culvert_width = 3.66 2266 #culvert_height = 3.66 2267 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 2268 culvert_mannings = 0.013 2269 2270 culvert_apron = 0.0 2271 enquiry_gap = 5.0 2272 2273 2274 2275 2276 domain = self._create_domain(d_length=domain_length, 2277 d_width=domain_width, 2278 dx = 5.0, 2279 dy = 5.0, 2280 elevation_0 = elevation_0, 2281 elevation_1 = elevation_1, 2282 stage_0 = stage_0, 2283 stage_1 = stage_1, 2284 xvelocity_0 = inlet_velocity, 2285 xvelocity_1 = outlet_velocity) 2286 2287 2288 #print 'Defining Structures' 2289 2290 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 2291 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 2292 2293 2294 culvert = Boyd_box_operator(domain, 2295 losses=culvert_losses, 2296 width=culvert_width, 2297 end_points=[ep0, ep1], 2298 height=culvert_height, 2299 apron=culvert_apron, 2300 enquiry_gap=enquiry_gap, 2301 use_momentum_jet=False, 2302 use_velocity_head=True, 2303 manning=culvert_mannings, 2304 logging=False, 2305 label='3.6x1.2RCBC', 2306 verbose=False) 2307 2308 #culvert.determine_inflow_outflow() 2309 2310 ( Q, v, d ) = culvert.discharge_routine() 2311 2312 if verbose: 2313 print 'test_boyd_operator_1' 2314 print 'expected ',Q_expected,v_expected, d_expected 2315 print 'calc ',Q,v,d 2316 2317 2318 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 2319 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 2320 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 2321 2322 2323 def test_boyd_12(self): 2324 """test_boyd_12 2325 2326 This tests the Boyd routine with data obtained from ??? by Petar Milevski 2327 """ 2328 # FIXME(Ole): This test fails (20 Feb 2009) 2329 2330 g=9.81 2331 culvert_slope=1 # Downward 2332 2333 inlet_depth=1.50 2334 inlet_velocity= 4.0 2335 outlet_depth=0.8 2336 outlet_velocity=4.0 2337 culvert_length=10.0 2338 culvert_width=3.60 2339 culvert_height=1.20 2340 2341 culvert_type='box' 2342 manning=0.013 2343 sum_loss=1.5 2344 2345 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 2346 z_in = 10.0 2347 z_out = 10.0-culvert_length*culvert_slope/100 2348 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 2349 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 2350 delta_total_energy = E_in-E_out 2351 2352 2353 Q_expected = 13.546 2354 v_expected = 3.136 2355 d_expected = 1.20 2356 2357 if verbose: 2358 print 50*'=' 2359 print 'width ',culvert_width 2360 print 'depth ',culvert_height 2361 print 'flow_width ',culvert_width 2362 print 'length ' ,culvert_length 2363 print 'driving_energy ',inlet_specific_energy 2364 print 'delta_total_energy ',delta_total_energy 2365 print 'outlet_enquiry_depth ',outlet_depth 2366 print 'sum_loss ',sum_loss 2367 print 'manning ',manning 2368 2369 Q, v, d, flow_area, case= boyd_box_function(culvert_width, 2370 culvert_height, 2371 culvert_width, 2372 culvert_length, 2373 inlet_specific_energy, 2374 delta_total_energy, 2375 outlet_depth, 2376 sum_loss, 2377 manning) 2378 2379 # Q, v, d = boyd_generalised_culvert_model(inlet_depth, 2380 # outlet_depth, 2381 # inlet_velocity, 2382 # outlet_velocity, 2383 # inlet_specific_energy, 2384 # delta_total_energy, 2385 # g, 2386 # culvert_length, 2387 # culvert_width, 2388 # culvert_height, 2389 # culvert_type, 2390 # manning, 2391 # sum_loss) 2392 if verbose: 2393 print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy)) 2394 print ('%s,%.3f'%('Delta E = ',delta_total_energy)) 2395 2396 print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST06 Q-v-d',Q,v,d)) 2397 print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected)) 2398 2399 assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow 2400 assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity 2401 assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v 2402 2403 def test_boyd_12_operator(self): 2404 """test_boyd_non_skew 2405 2406 This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer BD Parkinson, 2407 calculation code by MJ Boyd 2408 """ 2409 2410 g=9.81 2411 culvert_slope=1 # Downward 2412 2413 inlet_depth=1.50 2414 inlet_velocity= 4.0 2415 outlet_depth=0.8 2416 outlet_velocity=4.0 2417 culvert_length=10.0 2418 culvert_width=3.60 2419 culvert_height=1.20 2420 2421 culvert_type='box' 2422 manning=0.013 2423 sum_loss=1.5 2424 2425 inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 2426 z_in = 10.0 2427 z_out = 10.0-culvert_length*culvert_slope/100 2428 E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g 2429 E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g 2430 delta_total_energy = E_in-E_out 2431 2432 2433 Q_expected = 13.546 2434 v_expected = 3.136 2435 d_expected = 1.20 2436 2437 elevation_0 = z_in 2438 elevation_1 = z_out 2439 2440 stage_0 = elevation_0 + inlet_depth 2441 stage_1 = elevation_1 + outlet_depth 2442 2443 2444 domain_length = 200.0 2445 domain_width = 200.0 2446 2447 #culvert_length = 20.0 2448 #culvert_width = 3.66 2449 #culvert_height = 3.66 2450 culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0} 2451 culvert_mannings = 0.013 2452 2453 culvert_apron = 0.0 2454 enquiry_gap = 5.0 2455 2456 2457 2458 2459 domain = self._create_domain(d_length=domain_length, 2460 d_width=domain_width, 2461 dx = 5.0, 2462 dy = 5.0, 2463 elevation_0 = elevation_0, 2464 elevation_1 = elevation_1, 2465 stage_0 = stage_0, 2466 stage_1 = stage_1, 2467 xvelocity_0 = inlet_velocity, 2468 xvelocity_1 = outlet_velocity) 2469 2470 2471 #print 'Defining Structures' 2472 2473 ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0]) 2474 ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0]) 2475 2476 2477 culvert = Boyd_box_operator(domain, 2478 losses=culvert_losses, 2479 width=culvert_width, 2480 end_points=[ep0, ep1], 2481 height=culvert_height, 2482 apron=culvert_apron, 2483 enquiry_gap=enquiry_gap, 2484 use_momentum_jet=False, 2485 use_velocity_head=True, 2486 manning=culvert_mannings, 2487 logging=False, 2488 label='3.6x1.2RCBC', 2489 verbose=False) 2490 2491 #culvert.determine_inflow_outflow() 2492 2493 ( Q, v, d ) = culvert.discharge_routine() 2494 2495 if verbose: 2496 print 'test_boyd_operator_1' 2497 print 'expected ',Q_expected,v_expected, d_expected 2498 print 'calc ',Q,v,d 2499 2500 2501 assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow 2502 assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity 2503 assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v 1395 2504 1396 2505
Note: See TracChangeset
for help on using the changeset viewer.