source: trunk/anuga_work/development/mem_time_tests/parameters/timelen/ex1.py

Last change on this file was 8427, checked in by davies, 12 years ago

Adding the trapezoidal channel validation test, and editing the ANUGA manual

File size: 3.0 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import time
6import os
7import sys
8from anuga.abstract_2d_finite_volumes.util import add_directories
9from anuga.utilities import log
10
11#set up variables to store the results and the log files of each experiment
12f = sys.argv[1]
13g = float(f)/100.0
14home = os.getenv('INUNDATIONHOME')
15scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
16                                       "timelength", "timelength-" + str(f)])
17log.log_filename = os.path.join(scenariodirV, "anuga.log")
18log._setup = False
19
20log.timingInfo(msg=('timelength,'+str(f))) #write the variable to be measured to file
21log.timingInfo(msg=('timestep,'+str(g))) #write the variable to be measured to file
22log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
23log.resource_usage_timing(prefix = 'beforesimulation') #get memory usage here
24
25#------------------------------------------------------------------------------
26# Create the domain and the mesh of the run
27#------------------------------------------------------------------------------
28points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
29domain = anuga.Domain(points, vertices, boundary) # Create domain
30domain.set_name('channel1') # Output name
31domain.set_datadir(scenariodirV) 
32
33log.resource_usage_timing(prefix = 'aftermesh') #get memory usage here
34log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
35#------------------------------------------------------------------------------
36# Setup initial conditions
37#------------------------------------------------------------------------------
38def topography(x, y):
39    return 0 # linear bed slope
40domain.set_quantity('elevation', topography) # Use function for elevation
41domain.set_quantity('friction', 0.01) # Constant friction
42domain.set_quantity('stage', 10)
43
44log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here
45
46#------------------------------------------------------------------------------
47# Setup boundary conditions
48#------------------------------------------------------------------------------
49Br = anuga.Reflective_boundary(domain) # Solid reflective wall
50domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
51
52log.resource_usage_timing(prefix='afterboundary')#get memory usage here
53
54#------------------------------------------------------------------------------
55# Evolve system through time
56#------------------------------------------------------------------------------
57for t in domain.evolve(yieldstep=g, finaltime=f):
58    print domain.timestepping_statistics()
59
60
61log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
62log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation
Note: See TracBrowser for help on using the repository browser.