Ignore:
Timestamp:
Jan 31, 2012, 10:54:12 AM (12 years ago)
Author:
pittj
Message:

formatted the experiment scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
     
    107import random
    118import os
     9from anuga.abstract_2d_finite_volumes.util import add_directories
     10from anuga.utilities import log
     11
     12#set up the variables for the temporary file directories
     13home = os.getenv('INUNDATIONHOME')
     14scenariodir = add_directories(home, ["data","mem_time_test", "parameters","timestep"])
     15
     16store ='store.txt'
     17file_path_store = os.path.join(scenariodir, store)
     18
     19s = open(file_path_store,'r+') # read the timestep from the text file
     20f = float(s.readline())
     21s.close()
     22
     23#set up the variables for the log files and data directories
     24scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
     25                                       "timestep", "timestep-" + str(f)])
     26log.log_filename = os.path.join(scenariodirV, "anuga.log")
     27log._setup = False
     28
     29log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
    1230#------------------------------------------------------------------------------
    1331# Setup computational domain
    1432#------------------------------------------------------------------------------
    15 from anuga.abstract_2d_finite_volumes.util import add_directories
     33points, vertices, boundary = anuga.rectangular_cross(10,5,len1=10.0, len2=5.0) # Mesh
     34domain = anuga.Domain(points, vertices, boundary) # Create domain
     35domain.set_name('channel1') # Output name
     36domain.set_datadir(scenariodirV)
    1637
    17 home = os.getenv('INUNDATIONHOME')
    18 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    19                                      "timestep"])
    20 
    21 def runex(f):
    22    points, vertices, boundary = anuga.rectangular_cross(10,5,
    23    len1=10.0, len2=5.0) # Mesh
    24    domain = anuga.Domain(points, vertices, boundary) # Create domain
    25    domain.set_name('channel1') # Output name
    26    domain.set_datadir(scenariodir)
     38log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
    2739#------------------------------------------------------------------------------
    2840# Setup initial conditions
    2941#------------------------------------------------------------------------------
    30    def topography(x, y):
    31        return -x/10 # linear bed slope
    32        domain.set_quantity('elevation', topography) # Use function for elevation
    33        domain.set_quantity('friction', 0.01) # Constant friction
    34        domain.set_quantity('stage', # Dry bed
    35                            expression='elevation')
     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
    3649
    3750#------------------------------------------------------------------------------
    3851# Setup boundary conditions
    3952#------------------------------------------------------------------------------
    40    Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    41    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    42    domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     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})
    4356
     57log.resource_usage_timing(prefix='afterboundary') #get memory usage here
    4458#------------------------------------------------------------------------------
    4559# Evolve system through time
    4660#------------------------------------------------------------------------------
    47    for t in domain.evolve(yieldstep=f, finaltime=40.0):
    48       print domain.timestepping_statistics()
     61for t in domain.evolve(yieldstep=f, finaltime=40.0):
     62    print domain.timestepping_statistics()
    4963
     64log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
    5065
Note: See TracChangeset for help on using the changeset viewer.