source: anuga_core/documentation/user_manual/examples/runsydney.py @ 3755

Last change on this file since 3755 was 3563, checked in by ole, 18 years ago

Moved shallow water out from the old pyvolution directory.
All tests pass, most examples and okushiri works again.

File size: 5.7 KB
Line 
1"""Script for running a tsunami inundation scenario for Sydney, NSW, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in project.outputdir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a simulated submarine landslide.
9
10"""
11
12
13#------------------------------------------------------------------------------
14# Import necessary modules
15#------------------------------------------------------------------------------
16
17# Standard modules
18import os
19import time
20
21# Related major packages
22from anuga.shallow_water import Domain, Dirichlet_boundary
23from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
24from anuga.abstract_2d_finite_volumes.combine_pts import combine_rectangular_points_files
25from anuga.pmesh.mesh_interface import create_mesh_from_regions
26
27# Application specific imports
28import project                           # Define file names and polygons
29from anuga.shallow_water.smf import slump_tsunami # Function for submarine mudslide
30
31
32
33#------------------------------------------------------------------------------
34# Prepare bathymetric and topographic data
35#------------------------------------------------------------------------------
36
37# filenames
38coarsedemname = project.coarsedemname + '.pts'
39finedemname = project.finedemname + '.pts'
40combineddemname = project.combineddemname + '.pts'
41meshname = project.meshname+'.msh'
42
43
44# combining the coarse and fine data
45combine_rectangular_points_files(finedemname,
46                                 coarsedemname,
47                                 combineddemname)
48
49
50
51#------------------------------------------------------------------------------
52# Setup computational domain
53#------------------------------------------------------------------------------
54
55# Interior regions and mesh resolutions
56interior_res = 5000
57interior_regions = [[project.northern_polygon, interior_res],
58                    [project.harbour_polygon, interior_res],
59                    [project.southern_polygon, interior_res],
60                    [project.manly_polygon, interior_res],
61                    [project.top_polygon, interior_res]]
62
63
64create_mesh_from_regions(project.demopoly,
65                         boundary_tags= {'oceannorth': [0], 
66                                         'onshorenorth1': [1],
67                                         'onshorenorthwest1': [2],
68                                         'onshorenorthwest2': [3],
69                                         'onshorenorth2': [4],
70                                         'onshorewest': [5],
71                                         'onshoresouth': [6],
72                                         'oceansouth': [7],
73                                         'oceaneast': [8]},
74                         maximum_triangle_area=100000,
75                         filename=meshname,           
76                         interior_regions=interior_regions)
77
78
79#Create shallow water domain
80
81domain = Domain(meshname,
82                use_cache = True,
83                verbose = True)                                 
84
85
86print 'Number of triangles = ', len(domain)
87print 'The extent is ', domain.get_extent()
88
89domain.set_name(project.basename)
90domain.set_datadir(project.outputdir)
91domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
92
93
94#------------------------------------------------------------------------------
95# Set up scenario (tsunami_source is a callable object used with set_quantity)
96#------------------------------------------------------------------------------
97
98tsunami_source = slump_tsunami(length=30000.0,
99                               depth=400.0,
100                               slope=6.0,
101                               thickness=176.0, 
102                               radius=3330,
103                               dphi=0.23,
104                               x0=project.slump_origin[0], 
105                               y0=project.slump_origin[1], 
106                               alpha=0.0, 
107                               domain=domain)
108
109
110#------------------------------------------------------------------------------
111# Setup initial conditions
112#------------------------------------------------------------------------------
113
114domain.set_quantity('stage', tsunami_source)
115domain.set_quantity('friction', 0.0) 
116domain.set_quantity('elevation',
117                    filename = combineddemname,
118                    use_cache = True,
119                    verbose = True)
120
121#------------------------------------------------------------------------------
122# Setup boundary conditions (all Dirichlet)
123#------------------------------------------------------------------------------
124
125print 'Available boundary tags', domain.get_boundary_tags()
126
127Bd = Dirichlet_boundary([0.0,0.0,0.0])
128domain.set_boundary( {'oceannorth': Bd,
129                      'onshorenorth1': Bd,
130                      'onshorenorthwest1': Bd,
131                      'onshorenorthwest2': Bd,
132                      'onshorenorth2': Bd,
133                      'onshorewest': Bd,
134                      'onshoresouth': Bd,
135                      'oceansouth': Bd,
136                      'oceaneast': Bd} )
137
138#------------------------------------------------------------------------------
139# Evolve system through time
140#------------------------------------------------------------------------------
141
142import time
143t0 = time.time()
144
145for t in domain.evolve(yieldstep = 60, finaltime = 7200):
146    print domain.timestepping_statistics()
147    print domain.boundary_statistics(tags = 'oceaneast')   
148   
149print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.