1 | """Module where global ANUGA model parameters and default values are set |
---|
2 | """ |
---|
3 | |
---|
4 | import os |
---|
5 | import sys |
---|
6 | |
---|
7 | ################################################################################ |
---|
8 | # Numerical constants |
---|
9 | ################################################################################ |
---|
10 | |
---|
11 | epsilon = 1.0e-12 # Smallest number - used for safe division |
---|
12 | max_float = 1.0e36 # Largest number - used to initialise |
---|
13 | # (max, min) ranges |
---|
14 | default_smoothing_parameter = 0.001 # Default alpha for penalised |
---|
15 | # least squares fitting |
---|
16 | single_precision = 1.0e-6 # Smallest single precision number |
---|
17 | velocity_protection = 1.0e-6 |
---|
18 | |
---|
19 | ################################################################################ |
---|
20 | # Standard filenames, directories and system parameters used by ANUGA |
---|
21 | ################################################################################ |
---|
22 | |
---|
23 | pmesh_filename = '.\\pmesh' |
---|
24 | version_filename = 'stored_version_info.py' |
---|
25 | default_datadir = '.' |
---|
26 | time_format = '%d/%m/%y %H:%M:%S' |
---|
27 | umask = 002 # Controls file and directory permission created by anuga |
---|
28 | default_boundary_tag = 'exterior' |
---|
29 | |
---|
30 | # Major revision number for use with create_distribution |
---|
31 | # and update_anuga_user_guide |
---|
32 | major_revision = '1.0beta' |
---|
33 | |
---|
34 | ################################################################################ |
---|
35 | # Physical constants |
---|
36 | ################################################################################ |
---|
37 | |
---|
38 | manning = 0.03 # Manning's friction coefficient |
---|
39 | #g = 9.80665 # Gravity - FIXME reinstate this and fix unit tests. |
---|
40 | g = 9.8 |
---|
41 | #g(phi) = 9780313 * (1 + 0.0053024 sin(phi)**2 - 0.000 0059 sin(2*phi)**2) micro m/s**2, where phi is the latitude |
---|
42 | #The 'official' average is 9.80665 |
---|
43 | |
---|
44 | eta_w = 3.0e-3 # Wind stress coefficient |
---|
45 | rho_a = 1.2e-3 # Atmospheric density |
---|
46 | rho_w = 1023 # Fluid density [kg/m^3] (rho_w = 1023 for salt water) |
---|
47 | |
---|
48 | ################################################################################ |
---|
49 | # Limiters - used with linear reconstruction of vertex |
---|
50 | # values from centroid values |
---|
51 | ################################################################################ |
---|
52 | |
---|
53 | # Betas [0;1] control the allowed steepness of gradient for second order |
---|
54 | # extrapolations. Values of 1 allow the steepes gradients while |
---|
55 | # lower values are more conservative. Values of 0 correspond to |
---|
56 | # 1'st order extrapolations. |
---|
57 | # |
---|
58 | |
---|
59 | # There are separate betas for the w, uh, and vh limiters |
---|
60 | # I think these are better SR but they conflict with the unit tests! |
---|
61 | beta_w = 1.0 |
---|
62 | beta_w_dry = 0.2 |
---|
63 | beta_uh = 1.0 |
---|
64 | beta_uh_dry = 0.2 |
---|
65 | beta_vh = 1.0 |
---|
66 | beta_vh_dry = 0.2 |
---|
67 | |
---|
68 | # Alpha_balance controls how limiters are balanced between deep and shallow. |
---|
69 | # A large value will favour the deep water limiters, allowing the a closer hug |
---|
70 | # to the coastline. This will minimise 'creep' but at the same time cause |
---|
71 | # smaller time steps |
---|
72 | # Range: |
---|
73 | alpha_balance = 2.0 |
---|
74 | |
---|
75 | # Flag use of new limiters. |
---|
76 | # tight_slope_limiters = 0 means use old limiters (e.g. for some tests) |
---|
77 | # tight_slope_limiters = 1 means use new limiters that hug the bathymetry closer |
---|
78 | tight_slope_limiters = True |
---|
79 | |
---|
80 | # Use centroid velocities to reconstruct momentum at vertices in |
---|
81 | # very shallow water |
---|
82 | # This option has a first order flavour to it, but we still have second order |
---|
83 | # reconstruction of stage and this option only applies in |
---|
84 | # balance_deep_and_shallow when |
---|
85 | # alpha < 1 so in deeper water the full second order scheme is used. |
---|
86 | # |
---|
87 | # This option is good with tight_slope_limiters, especially for large domains. |
---|
88 | use_centroid_velocities = True |
---|
89 | |
---|
90 | # FIXME (Ole) Maybe get rid of order altogether and use beta_w |
---|
91 | default_order = 2 |
---|
92 | |
---|
93 | ################################################################################ |
---|
94 | # Timestepping |
---|
95 | ################################################################################ |
---|
96 | |
---|
97 | CFL = 1.0 # CFL condition assigned to domain.CFL - controls timestep size |
---|
98 | |
---|
99 | # Choose type of timestepping, |
---|
100 | #timestepping_method = 'rk2' # 2nd Order TVD scheme |
---|
101 | timestepping_method = 'euler' # 1st order euler |
---|
102 | |
---|
103 | # rk2 is a little more stable than euler, so rk2 timestepping |
---|
104 | # can deal with a larger beta when slope limiting the reconstructed |
---|
105 | # solution. The large beta is needed if solving problems sensitive |
---|
106 | # to numerical diffusion, like a small forced wave in an ocean |
---|
107 | beta_euler = 1.0 |
---|
108 | beta_rk2 = 1.6 |
---|
109 | |
---|
110 | # Option to search for signatures where isolated triangles are |
---|
111 | # responsible for a small global timestep. |
---|
112 | # Treating these by limiting their momenta may help speed up the |
---|
113 | # overall computation. |
---|
114 | # This facility is experimental. |
---|
115 | # protect_against_isolated_degenerate_timesteps = False |
---|
116 | protect_against_isolated_degenerate_timesteps = False |
---|
117 | |
---|
118 | min_timestep = 1.0e-6 # Minimal timestep accepted in ANUGA |
---|
119 | max_timestep = 1.0e+3 |
---|
120 | max_smallsteps = 50 # Max number of degenerate steps allowed b4 |
---|
121 | # trying first order |
---|
122 | |
---|
123 | # Perhaps minimal timestep could be based on the geometry as follows: |
---|
124 | # Define maximal possible speed in open water v_max, e.g. 500m/s (soundspeed?) |
---|
125 | # Then work out minimal internal distance in mesh r_min and set |
---|
126 | # min_timestep = r_min/v_max |
---|
127 | # |
---|
128 | # Max speeds are calculated in the flux function as |
---|
129 | # |
---|
130 | # lambda = v +/- sqrt(gh) |
---|
131 | # |
---|
132 | # so with 500 m/s, h ~ 500^2/g = 2500 m well out of the domain of the |
---|
133 | # shallow water wave equation |
---|
134 | # |
---|
135 | # The actual soundspeed can be as high as 1530m/s |
---|
136 | # (see http://staff.washington.edu/aganse/public.projects/clustering/clustering.html), |
---|
137 | # but that would only happen with h>225000m in this equation. Why ? |
---|
138 | # The maximal speed we specify is really related to the max speed |
---|
139 | # of surface pertubation |
---|
140 | # |
---|
141 | # v_max = 100 #For use in domain_ext.c |
---|
142 | # sound_speed = 500 |
---|
143 | |
---|
144 | ################################################################################ |
---|
145 | # Ranges specific to the shallow water wave equation |
---|
146 | # These control maximal and minimal values of quantities |
---|
147 | ################################################################################ |
---|
148 | |
---|
149 | # Water depth below which it is considered to be 0 in the model |
---|
150 | minimum_allowed_height = 1.0e-3 |
---|
151 | |
---|
152 | # Water depth below which it is *stored* as 0 |
---|
153 | minimum_storable_height = 1.0e-5 |
---|
154 | |
---|
155 | # FIXME (Ole): Redefine this parameter to control maximal speeds in general |
---|
156 | # and associate it with protect_against_isolated_degenerate_timesteps = True |
---|
157 | maximum_allowed_speed = 0.0 # Maximal particle speed of water |
---|
158 | #maximum_allowed_speed = 1.0 # Maximal particle speed of water |
---|
159 | # Too large (100) creates 'flopping' water |
---|
160 | # Too small (0) creates 'creep' |
---|
161 | |
---|
162 | maximum_froude_number = 100.0 # To be used in limiters. |
---|
163 | |
---|
164 | ################################################################################ |
---|
165 | # Performance parameters used to invoke various optimisations |
---|
166 | ################################################################################ |
---|
167 | |
---|
168 | use_extensions = True # Use C-extensions |
---|
169 | use_psyco = True # Use psyco optimisations |
---|
170 | |
---|
171 | optimise_dry_cells = True # Exclude dry and still cells from flux computation |
---|
172 | optimised_gradient_limiter = True # Use hardwired gradient limiter |
---|
173 | use_edge_limiter = False # The edge limiter is better, but most runs have been |
---|
174 | # using vertex limiting. Validations passed with this |
---|
175 | # one True 9th May 2008, but many unit tests need |
---|
176 | # backward compatibility flag set FIXME(Ole). |
---|
177 | |
---|
178 | points_file_block_line_size = 500 # Number of lines read in from a points file |
---|
179 | # when blocking |
---|
180 | |
---|
181 | ################################################################################ |
---|
182 | # Dynamically-defined constants. |
---|
183 | ################################################################################ |
---|
184 | |
---|
185 | # Determine if we can read/write large NetCDF files |
---|
186 | netcdf_mode_w = 'w' |
---|
187 | netcdf_mode_a = 'a' |
---|
188 | netcdf_mode_r = 'r' |
---|
189 | |
---|
190 | # Code to set the write mode depending on |
---|
191 | # whether Scientific.IO supports large NetCDF files |
---|
192 | s = """from Scientific.IO.NetCDF import NetCDFFile; fid = NetCDFFile('tmpfilenamexx', 'wl')""" |
---|
193 | |
---|
194 | # Need to run in a separate process due an |
---|
195 | # error with older versions of Scientific.IO |
---|
196 | if sys.platform == 'win32': |
---|
197 | null = 'NUL' |
---|
198 | else: |
---|
199 | null = '/dev/null' |
---|
200 | cmd = 'python -c "%s" 2> %s' % (s, null) |
---|
201 | err = os.system(cmd) |
---|
202 | |
---|
203 | if err != 0: |
---|
204 | # The Python script s failed e.g. with a segfault |
---|
205 | # which means that large file support is |
---|
206 | # definitely not supported |
---|
207 | pass |
---|
208 | else: |
---|
209 | # Try the import within this process |
---|
210 | try: |
---|
211 | exec(s) |
---|
212 | except IOError: |
---|
213 | # NetCDFFile does not segfault but it does not |
---|
214 | # support large file support |
---|
215 | pass |
---|
216 | else: |
---|
217 | # Set the default mode to large file support |
---|
218 | netcdf_mode_w = 'wl' |
---|