source: anuga_work/debug/bad_time_step/run_dam.py @ 6842

Last change on this file since 6842 was 5085, checked in by ole, 17 years ago

Further simplification of run_dam debugging.

File size: 3.4 KB
RevLine 
[5074]1"""
[5085]2Script for debugging potential problem with the boundary
3condition: transmissive_momentum_set_stage
[5074]4
[5085]5When the wave reflects back towards the boundary excessive values
6for momentum are generated leading to degenerate timesteps.
[5074]7
[5085]8Ole Nielsen and Duncan Gray, GA - 2008
[5074]9"""
10
11
12#----------------------------------------------------------------------------
13# Import necessary modules
14#----------------------------------------------------------------------------
15
[5084]16# Related major packages
17from anuga.shallow_water import Domain
18from anuga.shallow_water import Reflective_boundary
19from anuga.shallow_water import Dirichlet_boundary
20from anuga.shallow_water import Time_boundary
21from anuga.shallow_water import File_boundary
22from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary
[5074]23
24
[5084]25from anuga.abstract_2d_finite_volumes.util import file_function
[5085]26from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
[5084]27from anuga.pmesh.mesh_interface import create_mesh_from_regions
[5074]28
[5084]29
30
[5074]31# Scenario specific imports
32import create_mesh
33
[5084]34
[5074]35def elevation_function(x,y):
36    from Numeric import zeros, size, Float
37    slope = 4 ## Bit of a magic Number
38   
39    z = zeros(size(x), Float)
40    for i in range(len(x)):
41        if x[i] < slope:
42            z[i] = 0.0
43        else:
44            z[i] = (x[i]-slope)*0.1
45    return z
46
47
[5084]48#-------------------------------------------------------------------------
49# Model parameters
50#-------------------------------------------------------------------------
51friction=0.01
[5074]52
[5084]53basename = 'debug_boundary'
[5074]54
[5084]55boundary_file = 'boundary.tms'
56#boundary_file = 'boundary_mellow.tms'
[5079]57
[5074]58
59
[5084]60#-------------------------------------------------------------------------
61# Create the triangular mesh
62#-------------------------------------------------------------------------
[5074]63
[5084]64xright  = 19.0
65ybottom = 0
66ytop    = 0.45
67xleft = 0.0
[5074]68
[5085]69#Very simple mesh
70points, elements, boundary = rectangular_cross(200, 5,
71                                               len1=xright,
72                                               len2=ytop,
73                                               origin = (0.0, 0.0))
[5074]74
[5079]75
[5074]76
[5084]77#-------------------------------------------------------------------------
78# Setup computational domain
79#-------------------------------------------------------------------------
[5085]80#domain = Domain(mesh_filename, use_cache = False, verbose = True)
81domain = Domain(points, elements, boundary, verbose = True)
[5084]82print domain.statistics()
[5074]83
[5084]84domain.set_name(basename)
85domain.set_datadir('.')
[5074]86
87
[5084]88#-------------------------------------------------------------------------
89# Setup initial conditions
90#-------------------------------------------------------------------------
91
92domain.set_quantity('stage', 0.06)
93domain.set_quantity('friction', friction) 
94domain.set_quantity('elevation', elevation_function)
95
96
97print 'Available boundary tags', domain.get_boundary_tags()
98
99# Create boundary function from timeseries provided in file
100function = file_function(boundary_file, domain, verbose=True)
101
102
103Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function)
104Br = Reflective_boundary(domain)
[5085]105domain.set_boundary( {'top': Br, 'right': Br, 'bottom':Br, 'left': Bts} )
[5084]106
107
108#-------------------------------------------------------------------------
109# Evolve system through time
110#-------------------------------------------------------------------------
111
112for t in domain.evolve(0.1, 15):
113    print domain.timestepping_statistics(track_speeds=False)
[5085]114    print domain.boundary_statistics(tags=['left'])
[5084]115   
116print 'finished'
117
Note: See TracBrowser for help on using the repository browser.