source: production/karratha_2005/run_karratha.py @ 2058

Last change on this file since 2058 was 2020, checked in by ole, 19 years ago

Convergence study

File size: 5.7 KB
Line 
1"""Script for running a tsunami inundation scenario for Karratha, WA, 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 boundary data obtained from a tsunami simulation done with MOST.
9
10Ole Nielsen, GA - 2005
11"""
12
13#tide = 0.75   #HMWS estimate by Colin French, GA
14tide = 0       #HMW
15
16
17import os
18import time
19
20
21from pyvolution.shallow_water import Domain, Reflective_boundary, File_boundary,\
22     Dirichlet_boundary, Time_boundary, Transmissive_boundary
23from pyvolution.data_manager import convert_dem_from_ascii2netcdf,\
24     dem2pts, ferret2sww
25from pyvolution.pmesh2domain import pmesh_to_domain_instance
26from caching import cache
27import project
28
29#Data preparation
30#Convert ASC 2 DEM 2 PTS using source data and store result in source data
31demname = project.demname
32
33cache(convert_dem_from_ascii2netcdf, demname, {'verbose': True},
34      dependencies = [demname + '.asc'],
35      verbose = True)
36      #evaluate = True)
37
38cache(dem2pts, demname, {'verbose': True},
39      dependencies = [demname + '.dem'],     
40      verbose = True)
41
42
43#Convert MOST boundary
44source_dir = project.boundarydir
45
46from pyvolution.data_manager import ferret2sww
47
48south = project.south
49north = project.north
50west = project.west
51east = project.east
52
53
54cache(ferret2sww,
55      (source_dir+project.boundary_basename,
56       project.boundary_basename), 
57      {'verbose': True,
58       'minlat': south-1,
59       'maxlat': north+1,
60       'minlon': west-1,
61       'maxlon': east+1,
62       'origin': project.mesh_origin,
63       'mean_stage': tide,
64       'zscale': 1,                 #Enhance tsunami
65       'fail_on_NaN': False,
66       'inverted_bathymetry': True},
67      #evaluate = True,
68      verbose = True)
69#FIXME: Dependencies
70
71   
72#ferret2sww(source_dir+project.boundary_basename,
73#           project.boundary_basename,
74#           verbose=True,
75#           minlat=south-1, maxlat=north+1,
76#           minlon=west-1, maxlon=east+1,
77#           origin = project.mesh_origin,
78#           mean_stage = tide,
79#           zscale = 1,
80#           fail_on_NaN = False,
81#           inverted_bathymetry = True)
82
83
84#Create Triangular Mesh
85from pmesh.create_mesh import create_mesh_from_regions
86
87resolution = 4000
88interior_regions = [#[project.karratha_polygon, 25000],
89                    #[project.dampier_polygon, 2000],
90                    #[project.refinery_polygon, 2000],
91                    #[project.point_polygon, 2000]]
92                    [project.neil1_polygon, resolution],
93                    [project.neil2_polygon, 64000]]
94
95#For visualisation
96#interior_regions = [[project.wb_polygon, 400],
97#                    [project.lwb_polygon, 8000]]
98
99 
100                   
101meshname = project.meshname + '_%d.msh' %resolution
102m = cache(create_mesh_from_regions,
103          project.polygon,
104          {'boundary_tags': {'back': [7, 8], 'side': [0, 6],
105                             'ocean': [1, 2, 3, 4, 5]},
106           'resolution': 100000,
107           #'filename': project.meshname + '.msh',           
108           'filename': meshname,
109           'interior_regions': interior_regions},
110          #verbose = True)         
111          verbose = True,
112          evaluate = True)
113
114
115#Setup domain
116
117domain = cache(pmesh_to_domain_instance, (meshname, Domain),
118               dependencies = [meshname],                     
119               verbose = True)               
120
121
122domain.set_name(project.basename + '_%d' %resolution)
123domain.set_datadir(project.outputdir)
124domain.store = True
125#domain.smooth = False
126
127
128#domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum']
129domain.quantities_to_be_stored = ['stage']
130       
131print 'Number of triangles = ', len(domain)
132print 'The extent is ', domain.get_extent()
133
134
135
136#Setup Initial Conditions
137domain.set_quantity('friction', 0)
138domain.set_quantity('stage', tide)
139domain.set_quantity('elevation',
140                    filename = demname + '.pts',
141                    use_cache = True,
142                    verbose = True)
143
144
145
146#Setup Boundary Conditions
147print domain.get_boundary_tags()
148
149Bf = File_boundary(project.boundary_basename + '.sww', domain, verbose = True)
150#domain.starttime = 3000  #Obtained from MOST
151domain.starttime = 0  #Obtained from MOST
152
153Br = Reflective_boundary(domain)
154Bt = Transmissive_boundary(domain)
155Bd = Dirichlet_boundary([tide,0,0])
156Bw = Time_boundary(domain=domain,
157                   f=lambda t: [(60<t<660)*4, 0, 0])
158
159
160domain.set_boundary( {'back': Br,'side': Bd, 'ocean': Bf} ) #MOST tsunami
161
162#domain.set_boundary( {'back': Bd,'side': Bd, 'ocean': Bd} )  #Nothing
163
164
165#Evolve
166import time
167t0 = time.time()
168
169#for t in domain.evolve(yieldstep = 1000, finaltime = 14000):
170#    domain.write_time()
171#    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')
172
173#for t in domain.evolve(yieldstep = 20, finaltime = 15000,
174#                       skip_initial_step = True):
175#    domain.write_time()
176#    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')
177   
178#for t in domain.evolve(yieldstep = 10, finaltime = 40000,
179#                       skip_initial_step = True):
180#    domain.write_time()
181#    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')
182
183for t in domain.evolve(yieldstep = 60, finaltime = 40000):
184#                       skip_initial_step = True):
185    domain.write_time()
186    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')       
187
188print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.