source: anuga_work/production/wollongong_2006/run_gong_slide.py @ 4186

Last change on this file since 4186 was 4186, checked in by sexton, 18 years ago

updates to slide modelling based on recent discussions with PMD (basically change in locations for potential slides and more accurate locations for the historical events, plus more accurate depth measurements)

File size: 8.2 KB
Line 
1"""Script for running a tsunami inundation scenario for Wollongong, NSW, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project_slide.py
5The output sww file is stored in project_slide.outputtimedir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a tsunami wave generated by s submarine mass failure.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006
11"""
12
13#-------------------------------------------------------------------------------
14# Import necessary modules
15#-------------------------------------------------------------------------------
16
17# Standard modules
18import os
19import time
20from shutil import copy
21from os.path import dirname, basename
22from os import mkdir, access, F_OK, sep
23import sys
24
25# Related major packages
26from anuga.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary
27from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
28from anuga.geospatial_data.geospatial_data import *
29from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
30
31# Application specific imports
32import project_slide              # Definition of file names and polygons
33
34#-------------------------------------------------------------------------------
35# Copy scripts to time stamped output directory and capture screen
36# output to file
37#-------------------------------------------------------------------------------
38
39# creates copy of code in output dir
40copy_code_files(project_slide.outputtimedir,__file__,dirname(project_slide.__file__)+sep+ project_slide.__name__+'.py' )
41myid = 0
42numprocs = 1
43start_screen_catcher(project_slide.outputtimedir, myid, numprocs)
44
45print 'USER:    ', project_slide.user
46
47#-------------------------------------------------------------------------------
48# Preparation of topographic data
49#
50# Convert ASC 2 DEM 2 PTS using source data and store result in source data
51#-------------------------------------------------------------------------------
52
53# filenames
54on_offshore10_dem_name = project_slide.on_offshore10_dem_name
55nsw_dem_name = project_slide.nsw_dem_name
56meshname = project_slide.meshname+'.msh'
57
58# creates DEM from asc data
59convert_dem_from_ascii2netcdf(on_offshore10_dem_name, use_cache=True, verbose=True)
60convert_dem_from_ascii2netcdf(nsw_dem_name, use_cache=True, verbose=True)
61
62#creates pts file for onshore DEM
63dem2pts(on_offshore10_dem_name, use_cache=True, verbose=True)
64dem2pts(nsw_dem_name,
65        easting_min=project_slide.eastingmin_nsw,
66        easting_max=project_slide.eastingmax_nsw,
67        northing_min=project_slide.northingmin_nsw,
68        northing_max= project_slide.northingmax_nsw,
69        use_cache=True, verbose=True)
70
71print 'create offshore'
72G11 = Geospatial_data(file_name = project_slide.offshore_dem_name1 + '.xya')
73G12 = Geospatial_data(file_name = project_slide.offshore_dem_name4 + '.xya')+\
74      Geospatial_data(file_name = project_slide.offshore_dem_name5 + '.xya')+\
75      Geospatial_data(file_name = project_slide.offshore_dem_name6 + '.xya')+\
76      Geospatial_data(file_name = project_slide.offshore_dem_name7 + '.xya')+\
77      Geospatial_data(file_name = project_slide.offshore_dem_name8 + '.xya')+\
78      Geospatial_data(file_name = project_slide.offshore_dem_name9 + '.xya')
79print 'create onshore'
80G2 = Geospatial_data(file_name = project_slide.on_offshore10_dem_name + '.pts')
81G4 = Geospatial_data(file_name = project_slide.nsw_dem_name + '.pts')
82print 'add'
83G = G11.clip(Geospatial_data(project_slide.poly_surveyclip)) +\
84    G12.clip(Geospatial_data(project_slide.polyAll)) +\
85    G2.clip(Geospatial_data(project_slide.poly_10mclip)) +\
86    (G4.clip(Geospatial_data(project_slide.polyAll))).clip_outside(Geospatial_data(project_slide.poly_surveyclip)).clip_outside(Geospatial_data(project_slide.poly_10mclip))
87print 'export points'
88G.export_points_file(project_slide.combined_dem_name + '.pts')
89#G.export_points_file(project_slide.combined_dem_name + '.xya')
90
91#----------------------------------------------------------------------------
92# Create the triangular mesh based on overall clipping polygon with a tagged
93# boundary and interior regions defined in project.py along with
94# resolutions (maximal area of per triangle) for each polygon
95#-------------------------------------------------------------------------------
96
97from anuga.pmesh.mesh_interface import create_mesh_from_regions
98remainder_res = 100000
99local_res = 25000
100gong_res = 500
101interior_regions = [[project_slide.poly_local, local_res],
102                    [project_slide.poly_gong, gong_res],
103                    [project_slide.poly_southgong, gong_res]]
104
105from caching import cache
106_ = cache(create_mesh_from_regions,
107          project_slide.polyAll,
108           {'boundary_tags': {'e0': [0], 'e1': [1], 'e2': [2],
109                              'e3': [3], 'e4':[4]},
110           'maximum_triangle_area': remainder_res,
111           'filename': meshname,
112           'interior_regions': interior_regions},
113          verbose = True, evaluate=False)
114print 'created mesh'
115
116#-------------------------------------------------------------------------------                                 
117# Setup computational domain
118#-------------------------------------------------------------------------------                                 
119domain = Domain(meshname, use_cache = True, verbose = True)
120
121print 'Number of triangles = ', len(domain)
122print 'The extent is ', domain.get_extent()
123print domain.statistics()
124
125domain.set_name(project_slide.basename)
126domain.set_datadir(project_slide.outputtimedir)
127domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
128domain.set_minimum_storable_height(0.01)
129
130#-------------------------------------------------------------------------------                                 
131# Setup initial conditions
132#-------------------------------------------------------------------------------
133
134tide = 0.0
135domain.set_quantity('stage', tide)
136domain.set_quantity('friction', 0.0) 
137domain.set_quantity('elevation', 
138                    filename = project_slide.combined_dem_name + '.pts',
139                    use_cache = True,
140                    verbose = True,
141                    alpha = 0.1
142                    )
143
144#-------------------------------------------------------------------------------
145# Set up scenario (tsunami_source is a callable object used with set_quantity)
146#-------------------------------------------------------------------------------
147from smf import slide_tsunami
148
149tsunami_source = slide_tsunami(length=project_slide.yacaaba_length,
150                               width=project_slide.yacaaba_width,
151                               depth=project_slide.yacaaba_depth,
152                               slope=project_slide.yacaaba_slope,
153                               thickness=project_slide.yacaaba_thickness, 
154                               x0=project_slide.slide_origin_yacaaba_a[0], 
155                               y0=project_slide.slide_origin_yacaaba_a[1], 
156                               alpha=project_slide.yacaaba_alpha, 
157                               domain=domain)
158
159#-------------------------------------------------------------------------------                                 
160# Setup boundary conditions
161#-------------------------------------------------------------------------------
162print 'Available boundary tags', domain.get_boundary_tags()
163
164Br = Reflective_boundary(domain)
165Bd = Dirichlet_boundary([tide,0,0])
166
167domain.set_boundary( {'e0': Bd,  'e1': Bd, 'e2': Bd, 'e3': Bd, 'e4': Bd} )
168
169
170#-------------------------------------------------------------------------------                                 
171# Evolve system through time
172#-------------------------------------------------------------------------------
173import time
174t0 = time.time()
175from Numeric import allclose
176from anuga.abstract_2d_finite_volumes.quantity import Quantity
177
178for t in domain.evolve(yieldstep = 30, finaltime = 5000): 
179    domain.write_time()
180    domain.write_boundary_statistics(tags = 'e14')
181    stagestep = domain.get_quantity('stage') 
182
183    if allclose(t, 30):
184        slide = Quantity(domain)
185        slide.set_values(tsunami_source)
186        domain.set_quantity('stage', slide + stagestep)
187   
188print 'That took %.2f seconds' %(time.time()-t0)
189
190print 'finished'
Note: See TracBrowser for help on using the repository browser.