source: branches/numpy/anuga/config.py @ 6533

Last change on this file since 6533 was 6533, checked in by rwilson, 15 years ago

Revert back to 6481, prior to auto-merge of trunk and numpy branch.

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