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 | import time |
---|
30 | |
---|
31 | #------- |
---|
32 | # Domain |
---|
33 | filename = 'merimbula_interpolated_bathymetry.tsh' |
---|
34 | filename = 'merimbula_10834_bridge_refined_bathymetry.tsh' |
---|
35 | filename = 'merimbula_10785_1.tsh' |
---|
36 | print 'Creating domain from', filename |
---|
37 | domain = pmesh_to_domain_instance(filename, Domain) |
---|
38 | print "Number of triangles = ", len(domain) |
---|
39 | |
---|
40 | #------------------------------------------ |
---|
41 | # Reduction operation for get_vertex_values |
---|
42 | from util import mean |
---|
43 | domain.reduction = mean |
---|
44 | |
---|
45 | |
---|
46 | domain.set_quantity('friction',0.03) |
---|
47 | #-------------------- |
---|
48 | # Boundary conditions |
---|
49 | |
---|
50 | #--------------------------------------- |
---|
51 | # Tidal cycle recorded at Eden as open |
---|
52 | filename = 'Eden_tide_Sept03.dat' |
---|
53 | print 'Open sea boundary condition from ',filename |
---|
54 | Bf = File_boundary(filename, domain) |
---|
55 | |
---|
56 | #-------------------------------------- |
---|
57 | # All other boundaries are reflective |
---|
58 | Br = Reflective_boundary(domain) |
---|
59 | domain.set_boundary({'exterior': Br, 'open': Bf}) |
---|
60 | |
---|
61 | #----------- |
---|
62 | # Wind field |
---|
63 | # Format is time [DD/MM/YY hh:mm:ss], speed [m/s] direction (degrees) |
---|
64 | filename = 'Merimbula_Weather_data_Sept03_m_per_s.dat' |
---|
65 | print 'Wind field from ',filename |
---|
66 | F = file_function(filename, domain) |
---|
67 | domain.forcing_terms.append(Wind_stress(F)) |
---|
68 | |
---|
69 | #-------------------------------- |
---|
70 | # Initial water surface elevation |
---|
71 | domain.set_quantity('stage', -50.0) |
---|
72 | |
---|
73 | #---------------------------------------------------------- |
---|
74 | # Decide which quantities are to be stored at each timestep |
---|
75 | domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] |
---|
76 | |
---|
77 | #------------------------------------- |
---|
78 | # Provide file name for storing output |
---|
79 | domain.store = True #Store for visualisation purposes |
---|
80 | domain.format = 'sww' #Native netcdf visualisation format |
---|
81 | from normalDate import ND |
---|
82 | domain.filename = 'Merimbula_2003_4days_dry_%s'%ND() |
---|
83 | |
---|
84 | print domain.filename |
---|
85 | |
---|
86 | #---------------------- |
---|
87 | # Set order of accuracy |
---|
88 | domain.default_order = 1 |
---|
89 | domain.smooth = True |
---|
90 | print domain.use_inscribed_circle |
---|
91 | |
---|
92 | #--------- |
---|
93 | # Evolution |
---|
94 | t0 = time.time() |
---|
95 | domain.visualise = True |
---|
96 | yieldstep = 10 |
---|
97 | finaltime = 588000*3 |
---|
98 | for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): |
---|
99 | domain.write_time() |
---|
100 | |
---|
101 | print 'That took %.2f seconds' %(time.time()-t0) |
---|