source: anuga_work/development/MISG_2008/sensitivity_study.py @ 4937

Last change on this file since 4937 was 4937, checked in by ole, 16 years ago

Initial script for studying sensitivities to vertical errors in elevation for use with MISG_2008.

File size: 3.0 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water driven up a linear slope and time varying boundary,
4similar to a beach environment
5"""
6
7
8#------------------------------------------------------------------------------
9# Import necessary modules
10#------------------------------------------------------------------------------
11
12from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
13from anuga.shallow_water import Domain
14from anuga.shallow_water import Reflective_boundary
15from anuga.shallow_water import Dirichlet_boundary
16from anuga.shallow_water import Time_boundary
17from anuga.shallow_water import Transmissive_boundary
18
19from Numeric import zeros, Float
20from RandomArray import normal, seed
21
22seed(13, 17) # Ensure random number sequence is reproducible
23
24#------------------------------------------------------------------------------
25# Setup computational domain
26#------------------------------------------------------------------------------
27
28points, vertices, boundary = rectangular_cross(90, 30,
29                                               len1=3.0,
30                                               len2=1.0) # Basic mesh
31
32domain = Domain(points, vertices, boundary) # Create domain
33domain.set_name('sensitivity')              # Output to file runup.sww
34domain.set_datadir('.')                     # Use current directory for output
35domain.tight_slope_limiters = 1
36domain.beta_h = 0
37
38#------------------------------------------------------------------------------
39# Setup initial conditions
40#------------------------------------------------------------------------------
41
42def topography(x,y):
43
44    N = len(x)
45    z = zeros(N, Float)
46
47
48    for i in range(N):
49        # linear bed slope           
50        z[i] = -x[i]/15
51
52        # IID noise
53        z[i] += normal(0.0, 0.01)
54       
55    return z
56
57domain.set_quantity('elevation', topography) # Use function for elevation
58domain.set_quantity('friction', 0.01)        # Constant friction
59domain.set_quantity('stage', -.4)            # Constant negative initial stage
60
61
62#------------------------------------------------------------------------------
63# Setup boundary conditions
64#------------------------------------------------------------------------------
65
66from math import sin, pi, exp
67Br = Reflective_boundary(domain)      # Solid reflective wall
68Bt = Transmissive_boundary(domain)    # Continue all values on boundary
69Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values
70Bw = Time_boundary(domain=domain,     # Time dependent boundary 
71                   f=lambda t: [(.1*sin(t*2*pi)-0.1) , 0.0, 0.0])
72
73# Associate boundary tags with boundary objects
74domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br})
75
76
77import time
78t0 = time.time()
79#------------------------------------------------------------------------------
80# Evolve system through time
81#------------------------------------------------------------------------------
82
83for t in domain.evolve(yieldstep = 0.1, finaltime = 50.0):
84    domain.write_time()
85
86print 'That took %.2f seconds' %(time.time()-t0)
87
Note: See TracBrowser for help on using the repository browser.