source: trunk/anuga_documentation/user_manual/demos/cairns/run_cairns.py @ 8899

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

Made name consistent with run_parallel_cairn.py

File size: 6.9 KB
Line 
1"""Script for running a tsunami inundation scenario for Cairns, QLD 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 directory named after the scenario, i.e
6slide or fixed_wave.
7
8The scenario is defined by a triangular mesh created from project.polygon,
9the elevation data and a tsunami wave generated by a submarine mass failure.
10
11Geoscience Australia, 2004-present
12"""
13
14#------------------------------------------------------------------------------
15# Import necessary modules
16#------------------------------------------------------------------------------
17# Standard modules
18import os
19import time
20import sys
21
22# Related major packages
23import anuga
24
25# Application specific imports
26import project                 # Definition of file names and polygons
27
28#------------------------------------------------------------------------------
29# Preparation of topographic data
30# Convert ASC 2 DEM 2 PTS using source data and store result in source data
31#------------------------------------------------------------------------------
32# Create DEM from asc data
33anuga.asc2dem(project.name_stem+'.asc', use_cache=project.cache, verbose=project.verbose)
34
35# Create pts file for onshore DEM
36anuga.dem2pts(project.name_stem+'.dem', use_cache=project.cache, verbose=project.verbose)
37
38#------------------------------------------------------------------------------
39# Create the triangular mesh and domain based on
40# overall clipping polygon with a tagged
41# boundary and interior regions as defined in project.py
42#------------------------------------------------------------------------------
43domain = anuga.create_domain_from_regions(project.bounding_polygon,
44                                    boundary_tags={'top': [0],
45                                                   'ocean_east': [1],
46                                                   'bottom': [2],
47                                                   'onshore': [3]},
48                                    maximum_triangle_area=project.default_res,
49                                    mesh_filename=project.meshname,
50                                    interior_regions=project.interior_regions,
51                                    use_cache=project.cache,
52                                    verbose=project.verbose)
53
54# Print some stats about mesh and domain
55print 'Number of triangles = ', len(domain)
56print 'The extent is ', domain.get_extent()
57print domain.statistics()
58                                   
59#------------------------------------------------------------------------------
60# Setup parameters of computational domain
61#------------------------------------------------------------------------------
62domain.set_name('cairns_' + project.scenario) # Name of sww file
63domain.set_datadir('.')                       # Store sww output here
64domain.set_minimum_storable_height(0.01)      # Store only depth > 1cm
65domain.set_flow_algorithm('tsunami')
66
67#------------------------------------------------------------------------------
68# Setup initial conditions
69#------------------------------------------------------------------------------
70tide = project.tide
71domain.set_quantity('stage', tide)
72domain.set_quantity('friction', 0.0)
73
74
75domain.set_quantity('elevation', 
76                    filename=project.name_stem + '.pts',
77                    use_cache=project.cache,
78                    verbose=project.verbose,
79                    alpha=0.1)
80
81#------------------------------------------------------------------------------
82# Setup information for slide scenario (to be applied 1 min into simulation
83#------------------------------------------------------------------------------
84if project.scenario == 'slide':
85    # Function for submarine slide
86    tsunami_source = anuga.slide_tsunami(length=35000.0,
87                                   depth=project.slide_depth,
88                                   slope=6.0,
89                                   thickness=500.0, 
90                                   x0=project.slide_origin[0], 
91                                   y0=project.slide_origin[1], 
92                                   alpha=0.0, 
93                                   domain=domain,
94                                   verbose=project.verbose)
95
96#------------------------------------------------------------------------------
97# Setup boundary conditions
98#------------------------------------------------------------------------------
99print 'Available boundary tags', domain.get_boundary_tags()
100
101Bd = anuga.Dirichlet_boundary([tide, 0, 0]) # Mean water level
102Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
103
104if project.scenario == 'fixed_wave':
105    # Huge 50m wave starting after 60 seconds and lasting 1 hour.
106    Bw = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(
107                        domain=domain, 
108                        function=lambda t: [(60<t<3660)*50, 0, 0])
109
110    domain.set_boundary({'ocean_east': Bw,
111                         'bottom': Bs,
112                         'onshore': Bd,
113                         'top': Bs})
114
115if project.scenario == 'slide':
116    # Boundary conditions for slide scenario
117    domain.set_boundary({'ocean_east': Bd,
118                         'bottom': Bd,
119                         'onshore': Bd,
120                         'top': Bd})
121
122#------------------------------------------------------------------------------
123# Evolve system through time
124#------------------------------------------------------------------------------
125import time
126t0 = time.time()
127
128from numpy import allclose
129
130if project.scenario == 'slide':
131    # Initial run without any event
132    for t in domain.evolve(yieldstep=10, finaltime=60): 
133        print domain.timestepping_statistics()
134        print domain.boundary_statistics(tags='ocean_east')       
135       
136    # Add slide to water surface
137    if allclose(t, 60):
138        domain.add_quantity('stage', tsunami_source)   
139
140    # Continue propagating wave
141    for t in domain.evolve(yieldstep=10, finaltime=5000, 
142                           skip_initial_step=True):
143        print domain.timestepping_statistics()
144        print domain.boundary_statistics(tags='ocean_east')   
145
146if project.scenario == 'fixed_wave':
147    # Save every two mins leading up to wave approaching land
148    for t in domain.evolve(yieldstep=2*60, finaltime=5000): 
149        print domain.timestepping_statistics()
150        print domain.boundary_statistics(tags='ocean_east')   
151
152    # Save every 30 secs as wave starts inundating ashore
153    for t in domain.evolve(yieldstep=60*0.5, finaltime=10000, 
154                           skip_initial_step=True):
155        print domain.timestepping_statistics()
156        print domain.boundary_statistics(tags='ocean_east')
157           
158print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.