# source:trunk/anuga_core/source/anuga/structures/testing_culvert.py@8050

Last change on this file since 8050 was 8050, checked in by steve, 12 years ago

Added in an inlet_operator class to implement inflow "boundary condition" by setting up a inlet defined by a line close to the boundary. Look at testing_culvert_inlet.py as an example.

File size: 5.0 KB
RevLine
[7960]1import os.path
2import sys
3
4from anuga.utilities.system_tools import get_pathname_from_package
5from anuga.geometry.polygon_function import Polygon_function
6
7from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
8from anuga.abstract_2d_finite_volumes.quantity import Quantity
9
10import anuga
11
[8007]12from anuga.structures.boyd_pipe_operator import Boyd_pipe_operator
[8050]13from anuga.structures.inlet_operator import Inlet_operator
[7960]14
15#from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
16
17from math import pi, pow, sqrt
18
19import numpy as num
20
21
22
23
24
25"""test_that_culvert_runs_rating
26
27This test exercises the culvert and checks values outside rating curve
28are dealt with
29"""
30
31path = get_pathname_from_package('anuga.culvert_flows')
32
33length = 40.
[8007]34width = 15.
[7960]35
[7962]36dx = dy = 0.5          # Resolution: Length of subdivisions on both axes
[7960]37
38points, vertices, boundary = rectangular_cross(int(length/dx),
39                                               int(width/dy),
40                                               len1=length,
41                                               len2=width)
42domain = anuga.Domain(points, vertices, boundary)
43domain.set_name('Test_culvert')                 # Output name
44domain.set_default_order(2)
[7975]45#domain.set_beta(1.5)
[7960]46
47
48#----------------------------------------------------------------------
49# Setup initial conditions
50#----------------------------------------------------------------------
51
52def topography(x, y):
53    """Set up a weir
54
55    A culvert will connect either side
56    """
57    # General Slope of Topography
58    z=-x/1000
59
60    N = len(x)
61    for i in range(N):
62
63       # Sloping Embankment Across Channel
64        if 5.0 < x[i] < 10.1:
65            # Cut Out Segment for Culvert face
66            if  1.0+(x[i]-5.0)/5.0 <  y[i]  < 4.0 - (x[i]-5.0)/5.0:
67               z[i]=z[i]
68            else:
69               z[i] +=  0.5*(x[i] -5.0)    # Sloping Segment  U/S Face
70        if 10.0 < x[i] < 12.1:
71           z[i] +=  2.5                    # Flat Crest of Embankment
72        if 12.0 < x[i] < 14.5:
73            # Cut Out Segment for Culvert face
74            if  2.0-(x[i]-12.0)/2.5 <  y[i]  < 3.0 + (x[i]-12.0)/2.5:
75               z[i]=z[i]
76            else:
77               z[i] +=  2.5-1.0*(x[i] -12.0) # Sloping D/S Face
78
79
80    return z
81
82
83domain.set_quantity('elevation', topography)
84domain.set_quantity('friction', 0.01)         # Constant friction
85domain.set_quantity('stage',
86                    expression='elevation')   # Dry initial condition
87
88filename=os.path.join(path, 'example_rating_curve.csv')
[8007]89
90
91
92Boyd_pipe_operator(domain,
93                            end_point0=[9.0, 2.5],
[7978]94                            end_point1=[13.0, 2.5],
[8007]95                            losses=1.5,
96                            diameter=1.5,
97                            apron=5.0,
98                            use_momentum_jet=True,
100                            manning=0.013,
[7978]101                            verbose=False)
[7960]102
[8007]103
[8050]104line = [[0.0, 5.0], [0.0, 10.0]]
105Q = 5.0
106#Inlet_operator(domain, line, Q)
[7960]107
[7962]108
109
110
[7960]111##-----------------------------------------------------------------------
112## Setup boundary conditions
113##-----------------------------------------------------------------------
114
115## Inflow based on Flow Depth and Approaching Momentum
[7975]116Bi = anuga.Dirichlet_boundary([2.0, 0.0, 0.0])
[7962]117Br = anuga.Reflective_boundary(domain)              # Solid reflective wall
[7960]118#Bo = anuga.Dirichlet_boundary([-5, 0, 0])           # Outflow
119
120## Upstream and downstream conditions that will exceed the rating curve
121## I.e produce delta_h outside the range [0, 10] specified in the the
122## file example_rating_curve.csv
123#Btus = anuga.Time_boundary(domain, \
124            #lambda t: [100*num.sin(2*pi*(t-4)/10), 0.0, 0.0])
125#Btds = anuga.Time_boundary(domain, \
126            #lambda t: [-5*(num.cos(2*pi*(t-4)/20)), 0.0, 0.0])
127#domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br})
[7962]128domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
[7960]129
130
131##-----------------------------------------------------------------------
132## Evolve system through time
133##-----------------------------------------------------------------------
134
135#min_delta_w = sys.maxint
136#max_delta_w = -min_delta_w
[7979]137for t in domain.evolve(yieldstep = 1.0, finaltime = 200):
[7962]138    domain.write_time()
[7975]139
[8050]140    #if domain.get_time() > 150.5 and domain.get_time() < 151.5 :
141        #Bi = anuga.Dirichlet_boundary([0.0, 0.0, 0.0])
142        #domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
[7975]143
[7960]144    #delta_w = culvert.inlet.stage - culvert.outlet.stage
145
146    #if delta_w > max_delta_w: max_delta_w = delta_w
147    #if delta_w < min_delta_w: min_delta_w = delta_w
148
[7962]149    pass
[7960]150
151## Check that extreme values in rating curve have been exceeded
152## so that we know that condition has been exercised
153#assert min_delta_w < 0
154#assert max_delta_w > 10
155
156
157#os.remove('Test_culvert.sww')
Note: See TracBrowser for help on using the repository browser.