[5436] | 1 | """ |
---|
| 2 | Small test of directional flow aka momentum jet |
---|
| 3 | """ |
---|
| 4 | |
---|
| 5 | #------------------------------------------------------------------------------ |
---|
| 6 | # Import necessary modules |
---|
| 7 | #------------------------------------------------------------------------------ |
---|
| 8 | from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross |
---|
| 9 | from anuga.shallow_water import Domain |
---|
| 10 | from anuga.shallow_water.shallow_water_domain import Reflective_boundary |
---|
| 11 | from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary |
---|
| 12 | from anuga.shallow_water.shallow_water_domain import Inflow, General_forcing |
---|
| 13 | from anuga.culvert_flows.culvert_polygons import create_culvert_polygons |
---|
| 14 | from anuga.utilities.polygon import plot_polygons |
---|
| 15 | |
---|
| 16 | from math import pi, sqrt, cos, sin |
---|
| 17 | |
---|
| 18 | #------------------------------------------------------------------------------ |
---|
| 19 | # Setup computational domain |
---|
| 20 | #------------------------------------------------------------------------------ |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | length = 40. |
---|
| 25 | width = 5. |
---|
| 26 | |
---|
| 27 | #dx = dy = 1 # Resolution: Length of subdivisions on both axes |
---|
| 28 | #dx = dy = .5 # Resolution: Length of subdivisions on both axes |
---|
| 29 | dx = dy = .25 # Resolution: Length of subdivisions on both axes |
---|
| 30 | #dx = dy = .1 # Resolution: Length of subdivisions on both axes |
---|
| 31 | |
---|
| 32 | # OLE.... How do I refine the resolution... in the area where I have the Culvert Opening ???...... |
---|
| 33 | # Can I refine in a X & Y Range ??? |
---|
| 34 | points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), |
---|
| 35 | len1=length, len2=width) |
---|
| 36 | domain = Domain(points, vertices, boundary) |
---|
| 37 | domain.set_name('jet_example') # Output name |
---|
| 38 | domain.set_default_order(2) |
---|
| 39 | domain.H0 = 0.01 |
---|
| 40 | domain.tight_slope_limiters = True |
---|
| 41 | domain.set_minimum_storable_height(0.02) |
---|
| 42 | print 'Size', len(domain) |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | #------------------------------------------------------------------------------ |
---|
| 46 | # Setup initial conditions |
---|
| 47 | #------------------------------------------------------------------------------ |
---|
| 48 | domain.set_quantity('elevation', 0.0) |
---|
| 49 | domain.set_quantity('friction', 0.01) # Constant friction |
---|
| 50 | domain.set_quantity('stage', |
---|
| 51 | expression='elevation') # Dry initial condition |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | #------------------------------------------------------------------------------ |
---|
| 55 | # Setup boundary conditions |
---|
| 56 | #------------------------------------------------------------------------------ |
---|
| 57 | Bi = Dirichlet_boundary([0.0, 0.0, 0.0]) |
---|
| 58 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
| 59 | Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow |
---|
| 60 | |
---|
| 61 | domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br}) |
---|
| 62 | |
---|
| 63 | #------------------------------------------------------------------------------ |
---|
| 64 | # Setup Application of specialised forcing terms |
---|
| 65 | #------------------------------------------------------------------------------ |
---|
| 66 | |
---|
| 67 | # This tests straight Inflow in m^3/s |
---|
| 68 | center=(6.0, 2.0) |
---|
| 69 | r = 1.2 |
---|
| 70 | fixed_flow = Inflow(domain, |
---|
| 71 | rate=6.00, |
---|
| 72 | center=center, |
---|
| 73 | radius=r) |
---|
| 74 | domain.forcing_terms.append(fixed_flow) |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | # This tests momentum update (6, 3) in m^2/s/s |
---|
| 78 | xmom_forcing = General_forcing(domain, |
---|
| 79 | 'xmomentum', |
---|
| 80 | rate=6.00, |
---|
| 81 | center=center, |
---|
| 82 | radius=r) |
---|
| 83 | ymom_forcing = General_forcing(domain, |
---|
| 84 | 'ymomentum', |
---|
| 85 | rate=3.00, |
---|
| 86 | center=center, |
---|
| 87 | radius=r) |
---|
| 88 | |
---|
| 89 | domain.forcing_terms.append(xmom_forcing) |
---|
| 90 | domain.forcing_terms.append(ymom_forcing) |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | #------------------------------------------------------------------------------ |
---|
| 95 | # Evolve system through time |
---|
| 96 | #------------------------------------------------------------------------------ |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | for t in domain.evolve(yieldstep = 0.1, finaltime = 20): |
---|
| 101 | |
---|
| 102 | if t > 6: |
---|
| 103 | # Swing forcing rate around with time |
---|
| 104 | xmom_forcing.rate = 5*cos(t/5*2*pi) |
---|
| 105 | ymom_forcing.rate = 5*sin(t/5*2*pi) |
---|
| 106 | |
---|
| 107 | print domain.timestepping_statistics() |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | |
---|