source: trunk/anuga_core/demos/cairns/runcairns.py @ 9264

Last change on this file since 9264 was 9264, checked in by steve, 10 years ago

Changed names of run files so they are easily incorporated into the user manual

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