source: anuga_work/production/karratha_2005/run_karratha.py @ 4294

Last change on this file since 4294 was 3535, checked in by duncan, 18 years ago

change imports so reflect the new structure

File size: 6.3 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 anuga.pyvolution.shallow_water import Domain, Reflective_boundary, File_boundary,\
22     Dirichlet_boundary, Time_boundary, Transmissive_boundary
23from anuga.pyvolution.data_manager import convert_dem_from_ascii2netcdf,\
24     dem2pts, ferret2sww
25from anuga.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 anuga.pyvolution.data_manager import ferret2sww
47
48south = project.south
49north = project.north
50west = project.west
51east = project.east
52
53
54#Howard: Ignore this
55#cache(ferret2sww,
56#      (source_dir+project.boundary_basename,
57#       project.boundary_basename),
58#      {'verbose': True,
59#       'minlat': south-1,
60#       'maxlat': north+1,
61#       'minlon': west-1,
62#       'maxlon': east+1,
63#       'origin': project.mesh_origin,
64#       'mean_stage': tide,
65#       'zscale': 1,                 #Enhance tsunami
66#       'fail_on_NaN': False,
67#       'inverted_bathymetry': True},
68#      #evaluate = True,
69#      verbose = True)
70##FIXME: Dependencies
71
72   
73#ferret2sww(source_dir+project.boundary_basename,
74#           project.boundary_basename,
75#           verbose=True,
76#           minlat=south-1, maxlat=north+1,
77#           minlon=west-1, maxlon=east+1,
78#           origin = project.mesh_origin,
79#           mean_stage = tide,
80#           zscale = 1,
81#           fail_on_NaN = False,
82#           inverted_bathymetry = True)
83
84
85#Create Triangular Mesh
86from anuga.pmesh.create_mesh import create_mesh_from_regions
87
88resolution = 4000
89interior_regions = [#[project.karratha_polygon, 25000],
90                    #[project.dampier_polygon, 2000],
91                    #[project.refinery_polygon, 2000],
92                    #[project.point_polygon, 2000]]
93                    [project.neil1_polygon, resolution],
94                    [project.neil2_polygon, 64000]]
95
96#For visualisation
97#interior_regions = [[project.wb_polygon, 400],
98#                    [project.lwb_polygon, 8000]]
99
100 
101                   
102meshname = project.meshname + '_%d.msh' %resolution
103m = cache(create_mesh_from_regions,
104          project.polygon,
105          {'boundary_tags': {'back': [7, 8], 'side': [0, 6],
106                             'ocean': [1, 2, 3, 4, 5]},
107           'resolution': 100000,
108           #'filename': project.meshname + '.msh',           
109           'filename': meshname,
110           'interior_regions': interior_regions},
111          #verbose = True)         
112          verbose = True,
113          evaluate = True)
114
115
116#Setup domain
117
118#domain = cache(pmesh_to_domain_instance, (meshname, Domain),
119#               dependencies = [meshname],                     
120#               verbose = True)
121
122
123#This is how it will be Howard!
124domain = pmesh_to_domain_instance(meshname, Domain, use_cache=True)
125
126
127domain.set_name(project.basename + '_%d' %resolution)
128domain.set_datadir(project.outputdir)
129domain.store = True
130#domain.smooth = False
131
132
133#domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum']
134domain.quantities_to_be_stored = ['stage']
135       
136print 'Number of triangles = ', len(domain)
137print 'The extent is ', domain.get_extent()
138
139
140
141#Setup Initial Conditions
142domain.set_quantity('friction', 0)
143domain.set_quantity('stage', tide)
144domain.set_quantity('elevation',
145                    filename = demname + '.pts',
146                    use_cache = True,
147                    verbose = True)
148
149
150
151#Setup Boundary Conditions
152print domain.get_boundary_tags()
153
154
155#File boundary.
156#
157#Takes a arbitrary simulation output in the form of an sww file and use it to provide a boundary.
158#Values at every boundary point at every timestep are established by interpolation from the
159#values in the sww boundary file.
160#Boundary values at arbitrary timesteps needed in evolve are obtained by linear interpolation
161#
162#See also docstring for File_boundary in generic_boundary_conditions.py
163#
164Bf = File_boundary(project.boundary_basename + '.sww', domain, verbose = True)
165#domain.starttime = 3000  #Obtained from MOST
166domain.starttime = 0  #Obtained from MOST
167
168Br = Reflective_boundary(domain)
169Bt = Transmissive_boundary(domain)
170Bd = Dirichlet_boundary([tide,0,0])
171Bw = Time_boundary(domain=domain,
172                   f=lambda t: [(60<t<660)*4, 0, 0])
173
174
175domain.set_boundary( {'back': Br,'side': Bd, 'ocean': Bf} ) #MOST tsunami
176
177#domain.set_boundary( {'back': Bd,'side': Bd, 'ocean': Bd} )  #Nothing
178
179
180#Evolve
181import time
182t0 = time.time()
183
184#for t in domain.evolve(yieldstep = 1000, finaltime = 14000):
185#    domain.write_time()
186#    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')
187
188#for t in domain.evolve(yieldstep = 20, finaltime = 15000,
189#                       skip_initial_step = True):
190#    domain.write_time()
191#    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')
192   
193#for t in domain.evolve(yieldstep = 10, finaltime = 40000,
194#                       skip_initial_step = True):
195#    domain.write_time()
196#    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')
197
198for t in domain.evolve(yieldstep = 60, finaltime = 40000):
199#                       skip_initial_step = True):
200    domain.write_time()
201    domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage')       
202
203print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.