source: trunk/anuga_work/development/mem_time_tests/scenarios/stage/main.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: 1.8 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import random
6import subprocess
7import csv
8import os
9import time
10from anuga.abstract_2d_finite_volumes.util import add_directories
11from anuga.utilities.log_analyser import analyse_log
12
13#------------------------------------------------------------------------------
14# Set up variables for the correct directories to store the output
15#------------------------------------------------------------------------------
16home = os.getenv('INUNDATIONHOME')
17scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
18                                     "stage"])
19file = 'ex1.csv'
20file_path = os.path.join(scenariodir, file)
21store ='store.txt'
22file_path_store = os.path.join(scenariodir, store)
23storen ='storen.txt'
24file_path_storen = os.path.join(scenariodir, storen)
25
26#create files
27spamWriter = csv.writer(open(file_path, 'wb'))
28spamWriter.writerow(['Stage','Extent','Time','Space'])
29e = open(file_path_store,'a')
30e.close()
31e = open(file_path_storen,'a')
32e.close()
33
34#these are the main loops that determine the side length of the bounding square(m)
35#and the depth of the initial water (n)
36for m in range(100,1000,100):
37    for n in range(1,100,10):
38 
39        # thsese values are written to the files
40        g = open(file_path_store,'r+')
41        g.write(str(m))
42        h = open(file_path_storen,'r+')
43        h.write(str(n))
44
45        z = time.time() #time it
46        subprocess.call(['python2.5', 'ex1.py']) # run the simulation script
47        y = time.time() #time it
48        spamWriter.writerow([n ,((m**2)/2),(y-z),'a']) #record it
49print 'DONE'
50
51analyse_log(scenariodir, 'metalog.csv') #get the memory usage information from the log files
Note: See TracBrowser for help on using the repository browser.