1 | """Validation study of Merimbula lake using Pyvolution. |
---|
2 | |
---|
3 | Copyright 2004 |
---|
4 | Christopher Zoppou, Stephen Roberts, Ole Nielsen, Duncan Gray |
---|
5 | Geoscience Australia, ANU |
---|
6 | |
---|
7 | Specific methods pertaining to the 2D shallow water equation |
---|
8 | are imported from shallow_water |
---|
9 | for use with the generic finite volume framework |
---|
10 | |
---|
11 | Conserved quantities are h, uh and vh stored as elements 0, 1 and 2 in the |
---|
12 | numerical vector named conserved_quantities. |
---|
13 | |
---|
14 | Existence of file 'merimbula_interpolated.tsh' is assumed. |
---|
15 | """ |
---|
16 | |
---|
17 | #------------------------------ |
---|
18 | # Setup Path and import modules |
---|
19 | import sys |
---|
20 | from os import sep, path |
---|
21 | sys.path.append('..'+sep+'pyvolution') |
---|
22 | |
---|
23 | from shallow_water import Domain, Reflective_boundary, File_boundary,\ |
---|
24 | Dirichlet_boundary, Wind_stress |
---|
25 | from pmesh2domain import pmesh_to_domain_instance |
---|
26 | from util import file_function, Polygon_function, read_polygon, inside_polygon |
---|
27 | from Numeric import zeros, Float, asarray |
---|
28 | from least_squares import Interpolation |
---|
29 | from data_manager import sww2domain |
---|
30 | |
---|
31 | import time |
---|
32 | |
---|
33 | #------- |
---|
34 | # Domain |
---|
35 | # This is the original file used to create the SWW file from t = 0. |
---|
36 | # It is also needed to define the domain if it contains boundaryies other that |
---|
37 | # external. |
---|
38 | filename = 'merimbula_10834_bridge_refined_bathymetry.tsh' |
---|
39 | domain_old = pmesh_to_domain_instance(filename, Domain) |
---|
40 | |
---|
41 | # The evolution starts from the last time step contained in the following file. |
---|
42 | filename_sww = 'c:\grohm_output\Merimbula_2003_4days_dry.sww' |
---|
43 | print 'Creating domain from', filename_sww |
---|
44 | domain = sww2domain(filename_sww) |
---|
45 | print "Number of triangles = ", len(domain) |
---|
46 | |
---|
47 | # Extract old boundary data form original tsh file |
---|
48 | domain.boundary = domain_old.boundary |
---|
49 | |
---|
50 | #------------------------------------------ |
---|
51 | # Reduction operation for get_vertex_values |
---|
52 | from util import mean |
---|
53 | domain.reduction = mean |
---|
54 | |
---|
55 | domain.set_quantity('friction',0.03) |
---|
56 | #-------------------- |
---|
57 | # Boundary conditions |
---|
58 | |
---|
59 | #--------------------------------------- |
---|
60 | # Tidal cycle recorded at Eden as open |
---|
61 | filename = 'Eden_tide_Sept03.dat' |
---|
62 | print 'Open sea boundary condition from ',filename |
---|
63 | Bf = File_boundary(filename, domain) |
---|
64 | |
---|
65 | #-------------------------------------- |
---|
66 | # All other boundaries are reflective |
---|
67 | Br = Reflective_boundary(domain) |
---|
68 | domain.set_boundary({'exterior': Br, 'open': Bf}) |
---|
69 | |
---|
70 | #----------- |
---|
71 | # Wind field |
---|
72 | # Format is time [DD/MM/YY hh:mm:ss], speed [m/s] direction (degrees) |
---|
73 | filename = 'Merimbula_Weather_data_Sept03_m_per_s.dat' |
---|
74 | print 'Wind field from ',filename |
---|
75 | F = file_function(filename, domain) |
---|
76 | domain.forcing_terms.append(Wind_stress(F)) |
---|
77 | |
---|
78 | #-------------------------------- |
---|
79 | # Initial water surface elevation: only required for initial run |
---|
80 | # domain.set_quantity('stage', -50.0) |
---|
81 | # All conserved values are retrieved from the SWW file |
---|
82 | |
---|
83 | #---------------------------------------------------------- |
---|
84 | # Decide which quantities are to be stored at each timestep |
---|
85 | domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
86 | |
---|
87 | #------------------------------------- |
---|
88 | # Provide file name for storing output |
---|
89 | domain.store = True #Store for visualisation purposes |
---|
90 | domain.format = 'sww' #Native netcdf visualisation format |
---|
91 | # Caution: Should not store results in the SWW file |
---|
92 | filename = 'Merimbula_2003_4days_dry_plus' |
---|
93 | domain.filename = (filename) |
---|
94 | if filename_sww == filename: |
---|
95 | msg = 'SWW file name is the same as the output file name' |
---|
96 | raise msg |
---|
97 | |
---|
98 | #---------------------- |
---|
99 | # Set order of accuracy |
---|
100 | domain.default_order = 1 |
---|
101 | # Smooth in True or discontinuous triangles if False (Default is minimum for True) |
---|
102 | domain.smooth = True |
---|
103 | domain.reduction = 'mean' |
---|
104 | |
---|
105 | # Use the inscribed circle with safety factor of 0.9 to establish the time step |
---|
106 | # domain.set_to_inscribed_circle(safety_factor=0.9) |
---|
107 | |
---|
108 | #--------- |
---|
109 | # Evolution |
---|
110 | # t0 is the computer clock time |
---|
111 | t0 = time.time() |
---|
112 | yieldstep = 9 |
---|
113 | |
---|
114 | # domain.startime is obtained from the SWW file and is the last evolution time |
---|
115 | # time_extra is the additional evolution time final evolution time |
---|
116 | # is equal to desired_finaltime |
---|
117 | time_extra = 90 |
---|
118 | desired_finaltime = domain.starttime + time_extra |
---|
119 | finaltime = desired_finaltime - domain.starttime |
---|
120 | |
---|
121 | for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): |
---|
122 | domain.write_time() |
---|
123 | |
---|
124 | print 'That took %.2f seconds' %(time.time()-t0) |
---|