1 | """Script for running a tsunami inundation scenario for Karratha, WA, Australia. |
---|
2 | |
---|
3 | Source data such as elevation and boundary data is assumed to be available in |
---|
4 | directories specified by project.py |
---|
5 | The output sww file is stored in project.outputdir |
---|
6 | |
---|
7 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
8 | the elevation data and boundary data obtained from a tsunami simulation done with MOST. |
---|
9 | |
---|
10 | Ole Nielsen, GA - 2005 |
---|
11 | """ |
---|
12 | |
---|
13 | tide = 0.75 #HMWS estimate by Colin French, GA |
---|
14 | |
---|
15 | |
---|
16 | import os |
---|
17 | import time |
---|
18 | |
---|
19 | |
---|
20 | from pyvolution.shallow_water import Domain, Reflective_boundary, File_boundary,\ |
---|
21 | Dirichlet_boundary, Time_boundary, Transmissive_boundary |
---|
22 | from pyvolution.data_manager import convert_dem_from_ascii2netcdf,\ |
---|
23 | dem2pts, ferret2sww |
---|
24 | from pyvolution.pmesh2domain import pmesh_to_domain_instance |
---|
25 | from caching import cache |
---|
26 | import project |
---|
27 | |
---|
28 | #Data preparation |
---|
29 | #Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
30 | demname = project.demname |
---|
31 | |
---|
32 | cache(convert_dem_from_ascii2netcdf, demname, {'verbose': True}, |
---|
33 | dependencies = [demname + '.asc'], |
---|
34 | verbose = True) |
---|
35 | #evaluate = True) |
---|
36 | |
---|
37 | cache(dem2pts, demname, {'verbose': True}, |
---|
38 | dependencies = [demname + '.dem'], |
---|
39 | verbose = True) |
---|
40 | |
---|
41 | |
---|
42 | #Convert MOST boundary |
---|
43 | source_dir = project.boundarydir |
---|
44 | |
---|
45 | from pyvolution.data_manager import ferret2sww |
---|
46 | |
---|
47 | south = project.south |
---|
48 | north = project.north |
---|
49 | west = project.west |
---|
50 | east = project.east |
---|
51 | |
---|
52 | |
---|
53 | cache(ferret2sww, |
---|
54 | (source_dir+project.boundary_basename, |
---|
55 | project.boundary_basename), |
---|
56 | {'verbose': True, |
---|
57 | 'minlat': south-1, |
---|
58 | 'maxlat': north+1, |
---|
59 | 'minlon': west-1, |
---|
60 | 'maxlon': east+1, |
---|
61 | 'origin': project.mesh_origin, |
---|
62 | 'mean_stage': tide, |
---|
63 | 'zscale': 1, |
---|
64 | 'fail_on_NaN': False, |
---|
65 | 'inverted_bathymetry': True}, |
---|
66 | verbose = True) |
---|
67 | #FIXME: Dependencies |
---|
68 | |
---|
69 | |
---|
70 | #ferret2sww(source_dir+project.boundary_basename, |
---|
71 | # project.boundary_basename, |
---|
72 | # verbose=True, |
---|
73 | # minlat=south-1, maxlat=north+1, |
---|
74 | # minlon=west-1, maxlon=east+1, |
---|
75 | # origin = project.mesh_origin, |
---|
76 | # mean_stage = tide, |
---|
77 | # zscale = 1, |
---|
78 | # fail_on_NaN = False, |
---|
79 | # inverted_bathymetry = True) |
---|
80 | |
---|
81 | |
---|
82 | #Create Triangular Mesh |
---|
83 | from create_mesh import create_mesh |
---|
84 | |
---|
85 | interior_regions = [[project.karratha_polygon, 10000]] |
---|
86 | m = cache(create_mesh, |
---|
87 | project.polygon, |
---|
88 | {'boundary_tags': {'back': [7, 8], 'side': [0, 6], 'ocean': [1, 2, 3, 4, 5]}, |
---|
89 | 'resolution': 80000, |
---|
90 | 'filename': project.meshname + '.msh', |
---|
91 | 'interior_regions': interior_regions}, |
---|
92 | verbose = True) |
---|
93 | #verbose = True, |
---|
94 | #evaluate = True ) |
---|
95 | |
---|
96 | |
---|
97 | #Setup domain |
---|
98 | mesh = project.meshname + '.msh' |
---|
99 | domain = cache(pmesh_to_domain_instance, (mesh, Domain), |
---|
100 | dependencies = [mesh], |
---|
101 | verbose = True) |
---|
102 | |
---|
103 | |
---|
104 | domain.set_name(project.basename) |
---|
105 | domain.set_datadir(project.outputdir) |
---|
106 | domain.store = True |
---|
107 | |
---|
108 | #domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
109 | domain.quantities_to_be_stored = ['stage'] |
---|
110 | |
---|
111 | print 'Number of triangles = ', len(domain) |
---|
112 | print 'The extent is ', domain.get_extent() |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | #Setup Initial Conditions |
---|
117 | domain.set_quantity('friction', 0) |
---|
118 | domain.set_quantity('stage', tide) |
---|
119 | domain.set_quantity('elevation', |
---|
120 | filename = demname + '.pts', |
---|
121 | use_cache = True, |
---|
122 | verbose = True) |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | #Setup Boundary Conditions |
---|
127 | print domain.get_boundary_tags() |
---|
128 | |
---|
129 | Bf = File_boundary(project.boundary_basename + '.sww', domain, verbose = True) |
---|
130 | #domain.starttime = 3000 #Obtained from MOST |
---|
131 | domain.starttime = 0 #Obtained from MOST |
---|
132 | |
---|
133 | Br = Reflective_boundary(domain) |
---|
134 | Bt = Transmissive_boundary(domain) |
---|
135 | Bd = Dirichlet_boundary([tide,0,0]) |
---|
136 | Bw = Time_boundary(domain=domain, |
---|
137 | f=lambda t: [(60<t<660)*4, 0, 0]) |
---|
138 | |
---|
139 | domain.set_boundary( {'back': Br,'side': Bd, 'ocean': Bf} ) |
---|
140 | |
---|
141 | #domain.set_boundary( {'back': Br,'side': Bd, 'ocean': Bd} ) #Nothing |
---|
142 | |
---|
143 | |
---|
144 | #Run |
---|
145 | #for t in domain.evolve(yieldstep = 600, finaltime = 15000): |
---|
146 | # domain.write_time() |
---|
147 | # domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage') |
---|
148 | # |
---|
149 | #for t in domain.evolve(yieldstep = 10, finaltime = 35000): |
---|
150 | # domain.write_time() |
---|
151 | # domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage') |
---|
152 | |
---|
153 | for t in domain.evolve(yieldstep = 60, finaltime = 40000): |
---|
154 | domain.write_time() |
---|
155 | domain.write_boundary_statistics(tags = 'ocean') #quantities = 'stage') |
---|