source: trunk/anuga_work/development/Rudy_vandrie_2007/kitchen_sink_2.py @ 7924

Last change on this file since 7924 was 4440, checked in by ole, 18 years ago

Examples prepared for Rudy

File size: 2.8 KB
Line 
1"""Example of shallow water wave equation.
2
3Specific methods pertaining to the 2D shallow water equation
4are imported from shallow_water
5for use with the generic finite volume framework
6
7Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the
8numerical vector named conserved_quantities.
9"""
10
11#------------------------------------------------------------------------------
12# Import necessary modules
13#------------------------------------------------------------------------------
14from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
15from anuga.shallow_water import Domain
16from anuga.shallow_water.shallow_water_domain import Reflective_boundary
17from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
18from anuga.shallow_water.shallow_water_domain import Inflow
19
20#------------------------------------------------------------------------------
21# Setup computational domain
22#------------------------------------------------------------------------------
23
24#N = 120
25N = 40
26points, vertices, boundary = rectangular(N, N)
27domain = Domain(points, vertices, boundary)   
28domain.set_name('kitchen_sink')                 # Output name
29print 'Size', len(domain)
30
31
32#------------------------------------------------------------------------------
33# Setup initial conditions
34#------------------------------------------------------------------------------
35
36domain.set_quantity('elevation', 0.0)  # Zero bed elevation
37domain.set_quantity('stage', 0.0)    # Constant stage
38domain.set_quantity('friction', 0.005) # Constant friction
39
40
41#------------------------------------------------------------------------------
42# Setup specialised forcing terms
43#------------------------------------------------------------------------------
44
45sink = Inflow(center=[0.7, 0.4], radius=0.0707, flow=0.0)               
46tap = Inflow(center=(0.5, 0.5), radius=0.0316,
47             flow=lambda t: min(0.01*t, 0.0142)) # Tap turning up       
48       
49
50domain.forcing_terms.append(tap)
51domain.forcing_terms.append(sink)
52
53#------------------------------------------------------------------------------
54# Setup boundary conditions
55#------------------------------------------------------------------------------
56
57Br = Reflective_boundary(domain)              # Solid reflective wall
58domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
59
60#------------------------------------------------------------------------------
61# Evolve system through time
62#------------------------------------------------------------------------------
63from math import sin
64for t in domain.evolve(yieldstep = 0.01, finaltime = 20):
65    domain.write_time()
66   
67    if domain.get_time() >= 6 and tap.flow != 0.0:
68        print 'Turning tap off'
69        tap.flow = 0.0
70       
71    if domain.get_time() >= 3 and sink.flow == 0.0:
72        print 'Turning drain on'
73        sink.flow = lambda t: -0.04 + sin(t)*0.005     
74   
Note: See TracBrowser for help on using the repository browser.