 Timestamp:
 Jun 22, 2010, 5:52:28 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/anuga_core/source/anuga/shallow_water_balanced/test_swb_forcing_terms.py
r7866 r7869 552 552 os.remove(filename + '.tms') 553 553 554 W = Wind_stress(F)554 W = anuga.Wind_stress(F) 555 555 556 556 domain.forcing_terms = [] … … 1163 1163 # on a circle affecting triangles #0 and #1 (bac and bce) 1164 1164 domain.forcing_terms = [] 1165 I = Inflow(domain, rate=lambda t: 2., center=(1,1), radius=1)1165 I = anuga.Inflow(domain, rate=lambda t: 2., center=(1,1), radius=1) 1166 1166 domain.forcing_terms.append(I) 1167 1167 … … 1290 1290 # for a range of stage values 1291 1291 for stage in [2.0, 1.0, 0.5, 0.25, 0.1, 0.0]: 1292 print stage1293 1294 1292 domain.time = 0.0 1295 1293 domain.set_quantity('stage', stage) … … 1302 1300 for t in domain.evolve(yieldstep=dt, finaltime=5.0): 1303 1301 volume = domain.quantities['stage'].get_integral() 1304 print t, volume, predicted_volume1305 1302 assert num.allclose (volume, predicted_volume) 1306 1303 predicted_volume = predicted_volume  2.0/pi/100/dt # Why 100? … … 1309 1306 # range of stage values 1310 1307 for stage in [2.0, 1.0, 0.5, 0.25, 0.1, 0.0]: 1311 print stage1312 1313 1308 domain.time = 0.0 1314 1309 domain.set_quantity('stage', stage) … … 1323 1318 for t in domain.evolve(yieldstep=dt, finaltime=5.0): 1324 1319 volume = domain.quantities['stage'].get_integral() 1325 1326 print t, volume1327 1320 assert num.allclose(volume, initial_volume) 1328 1321 … … 1403 1396 domain.forcing_terms.append(fixed_inflow) 1404 1397 1405 ref_flow = fixed_inflow.rate*number_of_inflows g1398 ref_flow = fixed_inflow.rate*number_of_inflows 1406 1399 1407 1400 # Compute normal depth on plane using Mannings equation … … 1417 1410 # 1418 1411 1419 Br = Reflective_boundary(domain)1412 Br = anuga.Reflective_boundary(domain) 1420 1413 1421 1414 # Define downstream boundary based on predicted depth … … 1423 1416 return (slope*length) + normal_depth 1424 1417 1425 Bt = Transmissive_momentum_set_stage_boundary(domain=domain, 1426 function=normal_depth_stage_downstream) 1427 1428 1429 1418 Bt = anuga.Transmissive_momentum_set_stage_boundary( 1419 domain=domain, function=normal_depth_stage_downstream) 1430 1420 1431 1421 domain.set_boundary({'left': Br, … … 1433 1423 'top': Br, 1434 1424 'bottom': Br}) 1435 1436 1425 1437 1426 … … 1617 1606 1618 1607 1619 1620 def Xtest_friction_dependent_flow_using_flowline(self): 1621 """test_friction_dependent_flow_using_flowline 1622 1623 Test the internal flow (using flowline) as a function of 1624 different values of Mannings n and different slopes. 1625 1626 Flow is applied in the form of boundary conditions with fixed momentum. 1627 """ 1628 1629 verbose = True 1630 1631 # 1632 # Import necessary modules 1633 # 1634 1635 from anuga.abstract_2d_finite_volumes.mesh_factory \ 1636 import rectangular_cross 1637 from anuga.shallow_water import Domain 1638 from anuga.shallow_water.shallow_water_domain import Reflective_boundary 1639 from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary 1640 from anuga.shallow_water.forcing import Inflow 1641 from anuga.shallow_water.data_manager \ 1642 import get_flow_through_cross_section 1643 from anuga.abstract_2d_finite_volumes.util \ 1644 import sww2csv_gauges, csv2timeseries_graphs 1645 1646 1647 # 1648 # Setup computational domain 1649 # 1650 1651 finaltime = 1000.0 1652 1653 length = 300. 1654 width = 20. 1655 dx = dy = 5 # Resolution: of grid on both axes 1656 1657 # Input parameters 1658 uh = 1.0 1659 vh = 0.0 1660 d = 1.0 1661 1662 ref_flow = uh*d*width # 20 m^3/s in the x direction across entire domain 1663 1664 points, vertices, boundary = rectangular_cross(int(length/dx), 1665 int(width/dy), 1666 len1=length, 1667 len2=width) 1668 1669 for mannings_n in [0.035]: #[0.0, 0.012, 0.035]: 1670 for slope in [1.0/300]: #[0.0, 1.0/300, 1.0/150]: 1671 # Loop over a range of bedslopes representing 1672 # sub to super critical flows 1673 if verbose: 1674 print 1675 print 'Slope:', slope, 'Mannings n:', mannings_n 1676 domain = Domain(points, vertices, boundary) 1677 domain.set_name('Inflow_flowline_test') # Output name 1678 1679 # 1680 # Setup initial conditions 1681 # 1682 1683 def topography(x, y): 1684 z = x * slope 1685 return z 1686 1687 # Use function for elevation 1688 domain.set_quantity('elevation', topography) 1689 # Constant friction 1690 domain.set_quantity('friction', mannings_n) 1691 1692 #domain.set_quantity('stage', expression='elevation') 1693 1694 # Set initial flow as depth=1m, uh=1.0 m/s, vh = 0.0 1695 # making it 20 m^3/s across entire domain 1696 domain.set_quantity('stage', expression='elevation + %f' % d) 1697 domain.set_quantity('xmomentum', uh) 1698 domain.set_quantity('ymomentum', vh) 1699 1700 # 1701 # Setup boundary conditions 1702 # 1703 1704 Br = Reflective_boundary(domain) # Solid reflective wall 1705 1706 # Constant flow in and out of domain 1707 # Depth = 1m, uh=1 m/s, i.e. a flow of 20 m^3/s 1708 # across boundaries 1709 Bi = Dirichlet_boundary([d, uh, vh]) 1710 Bo = Dirichlet_boundary([length*slope+d, uh, vh]) 1711 #Bo = Dirichlet_boundary([100, 0, 0]) 1712 1713 domain.set_boundary({'left': Bi, 'right': Bo, 1714 'top': Br, 'bottom': Br}) 1715 1716 # 1717 # Evolve system through time 1718 # 1719 1720 for t in domain.evolve(yieldstep=100.0, finaltime=finaltime): 1721 if verbose : 1722 print domain.timestepping_statistics() 1723 print domain.volumetric_balance_statistics() 1724 1725 # 90 degree flowline at 200m 1726 q = domain.get_flow_through_cross_section([[200.0, 0.0], 1727 [200.0, 20.0]]) 1728 msg = ('Predicted flow was %f, should have been %f' 1729 % (q, ref_flow)) 1730 if verbose: 1731 print ('90 degree flowline: ANUGA = %f, Ref = %f' 1732 % (q, ref_flow)) 1733 1734 # 45 degree flowline at 200m 1735 q = domain.get_flow_through_cross_section([[200.0, 0.0], 1736 [220.0, 20.0]]) 1737 msg = ('Predicted flow was %f, should have been %f' 1738 % (q, ref_flow)) 1739 if verbose: 1740 print ('45 degree flowline: ANUGA = %f, Ref = %f' 1741 % (q, ref_flow)) 1742 1743 # Stage recorder (gauge) in middle of plane at 200m 1744 x = 200.0 1745 y = 10.00 1746 w = domain.get_quantity('stage').\ 1747 get_values(interpolation_points=[[x, y]])[0] 1748 z = domain.get_quantity('elevation').\ 1749 get_values(interpolation_points=[[x, y]])[0] 1750 domain_depth = wz 1751 1752 xmom = domain.get_quantity('xmomentum').\ 1753 get_values(interpolation_points=[[x, y]])[0] 1754 ymom = domain.get_quantity('ymomentum').\ 1755 get_values(interpolation_points=[[x, y]])[0] 1756 if verbose: 1757 print ('At interpolation point (h, uh, vh): ', 1758 domain_depth, xmom, ymom) 1759 print 'uh * d * width = ', xmom*domain_depth*width 1760 1761 if slope > 0.0: 1762 # Compute normal depth at gauge location using Manning eqn 1763 # v=1/n*(r^2/3)*(s^0.5) or r=(Q*n/(s^0.5*W))^0.6 1764 normal_depth = (ref_flow*mannings_n/(slope**0.5*width))**0.6 1765 if verbose: 1766 print ('Depth: ANUGA = %f, Mannings = %f' 1767 % (domain_depth, normal_depth)) 1768 1769 os.remove('Inflow_flowline_test.sww') 1770 1771 1772 ################################################################################# 1608 ################################################################################ 1773 1609 1774 1610 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.