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/triangles/rectanglecross/main.py

    r8303 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 subprocess
    10 import runcairns
    116import csv
    127import os
    138import time
     9from anuga.abstract_2d_finite_volumes.util import add_directories
     10from anuga.utilities.log_analyser import analyse_log
    1411
    15 from anuga.utilities import system_tools, log
    16 from anuga.abstract_2d_finite_volumes.util import add_directories
    17 
     12#------------------------------------------------------------------------------
     13# Set up variables for the correct directories to store the output
     14#------------------------------------------------------------------------------
    1815home = os.getenv('INUNDATIONHOME')
    1916scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    2017                                     "rectanglecross"])
    21 
    22 log.log_filename = os.path.join(scenariodir, 'log.txt')
    23 
     18storea ='storea.txt'
     19file_path_storea = os.path.join(scenariodir, storea)
     20store ='store.txt'
     21file_path_store = os.path.join(scenariodir, store)
     22storen ='storen.txt'
     23file_path_storen = os.path.join(scenariodir, storen)
    2424file = 'ex1.csv'
    2525file_path = os.path.join(scenariodir, file)
    2626
    27 #------------------------------------------------------------------------------
    28 # Setup computational domain
    29 #------------------------------------------------------------------------------
    30 a = []
     27#create and set up the output files
    3128spamWriter = csv.writer(open(file_path, 'wb'))
    3229spamWriter.writerow(['Number Of Triangles' ,'MxM Rectangular Mesh', 'Extent', 'Space Used MB' , 'Time Taken s'])
     30e = open(file_path_storea,'a')
     31e.close()
     32e = open(file_path_store,'a')
     33e.close()
     34e = open(file_path_storen,'a')
     35e.close()
    3336
     37#these main loops assign the matrix size[number of triangles] (m) and the map side length(n)
     38for m in range(1,500,10):
     39    for n in range(1,1000,100):
    3440
     41        #write these values to file
     42        g = open(file_path_store,'r+')
     43        g.write(str(m))
     44        h = open(file_path_storen,'r+')
     45        h.write(str(n))
    3546
    36 def runlist(r):
    37     for n in range(1,2000,100):
    38         system_tools.MemoryUpdate()
    39         z = time.time()
    40         h = runcairns.runex(n,r)
    41         y = time.time()
    42         x = system_tools.MemoryUpdate()[0]
    43         spamWriter.writerow([h,r,(n*n),x ,(y-z)])
     47        z = time.time() #time it
     48        subprocess.call(['python2.5', 'runcairns.py']) #run the simulation
     49        y = time.time() #time it
    4450
    45 for m in range(1,100,10):
    46     runlist(m)
     51        #read the number of triangles from this file
     52        f = open(file_path_storea,'r+')
     53        h = float(f.readline())
     54        f.close()
    4755
     56        spamWriter.writerow([h,m,(n*n),'x' ,(y-z)]) #record it
    4857print 'DONE'
    4958
     59analyse_log(scenariodir, 'metalog.csv')#get the memory statistics from the log files
     60
Note: See TracChangeset for help on using the changeset viewer.