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/scenarios/channelflow/main.py

    r8320 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import random
    106import subprocess
    11 import ex1
    127import csv
    138import os
    149import time
    15 from anuga.utilities import system_tools, log
    1610from anuga.abstract_2d_finite_volumes.util import add_directories
     11from anuga.utilities.log_analyser import analyse_log
    1712
    1813#------------------------------------------------------------------------------
    19 # Setup computational domain
     14# Set up variables for the correct directories to store the output
    2015#------------------------------------------------------------------------------
    21 a = []
    22 
    23 
    2416home = os.getenv('INUNDATIONHOME')
    2517scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
    2618                                     "channelflow"])
    27 
    28 log.log_filename = os.path.join(scenariodir, 'log.txt')
    29 
     19store ='store.txt'
     20file_path_store = os.path.join(scenariodir, store)
     21storen ='storen.txt'
     22file_path_storen = os.path.join(scenariodir, storen)
    3023file = 'ex1.csv'
    3124file_path = os.path.join(scenariodir, file)
    3225
     26#set up the output files
    3327spamWriter = csv.writer(open(file_path, 'wb'))
    3428spamWriter.writerow(['Length','Stage','Time','Space'])
     29e = open(file_path_store,'a')
     30e.close()
     31e = open(file_path_storen,'a')
     32e.close()
    3533
     34#the main loops that give the length of the inflow boundary (i) and the place to begin the step (n)
    3635for i in range(100,100000,10000):
     36    for n in range(1,i/10,i/100):
     37       
     38        #adjust
     39        i = i /100.0
     40        n = n/10.0
    3741
    38     for n in range(1,i/10,i/100):
    39         i = i /100.0
    40         n = n/float(i)
    41         system_tools.MemoryUpdate()
    42         z = time.time()
    43         ex1.runex(n,i)
    44         b = system_tools.MemoryUpdate()[0]
    45         y = time.time()
    46         spamWriter.writerow([i,(n/float(i)) ,(y-z), b])
    47 print a
     42        #write these values to files
     43        g = open(file_path_store,'r+')
     44        g.write(str(i))
     45        h = open(file_path_storen,'r+')
     46        h.write(str(n))
    4847
     48        z = time.time() #time it
     49        subprocess.call(['python2.5', 'ex1.py'])#run the script
     50        y = time.time() #time it
     51
     52        spamWriter.writerow([i,n,(y-z), 'b'])#record it
     53print 'DONE'
     54
     55analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the various log files
Note: See TracChangeset for help on using the changeset viewer.