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

Last change on this file since 8326 was 8326, checked in by pittj, 12 years ago

formatted the experiment scripts

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import time
6import os
7from anuga.abstract_2d_finite_volumes.util import add_directories
8from anuga.utilities import log
9
10#set up variables for the temporary data files
11home = os.getenv('INUNDATIONHOME')
12scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
13                                     "timelength"])
14store ='store.txt'
15file_path_store = os.path.join(scenariodir, store)
16
17#get the time length from the store text file
18s = open(file_path_store,'r+')
19f = float(s.readline())
20s.close()
21
22#set up variables to store the results and the log files of each experiment
23scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
24                                       "timelength", "timelength-" + str(f)])
25log.log_filename = os.path.join(scenariodirV, "anuga.log")
26log._setup = False
27
28log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
29
30#------------------------------------------------------------------------------
31# Create the domain and the mesh of the run
32#------------------------------------------------------------------------------
33points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
34domain = anuga.Domain(points, vertices, boundary) # Create domain
35domain.set_name('channel1') # Output name
36domain.set_datadir(scenariodirV) 
37
38log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here
39#------------------------------------------------------------------------------
40# Setup initial conditions
41#------------------------------------------------------------------------------
42def topography(x, y):
43    return -x/10 # linear bed slope
44domain.set_quantity('elevation', topography) # Use function for elevation
45domain.set_quantity('friction', 0.01) # Constant friction
46domain.set_quantity('stage',expression='elevation')
47
48log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here
49
50#------------------------------------------------------------------------------
51# Setup boundary conditions
52#------------------------------------------------------------------------------
53Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
54Br = anuga.Reflective_boundary(domain) # Solid reflective wall
55domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
56
57log.resource_usage_timing(prefix='afterboundary')#get memory usage here
58
59#------------------------------------------------------------------------------
60# Evolve system through time
61#------------------------------------------------------------------------------
62for t in domain.evolve(yieldstep=0.2, finaltime=f):
63    print domain.timestepping_statistics()
64
65
66log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
67
Note: See TracBrowser for help on using the repository browser.