source: trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py @ 8427

Last change on this file since 8427 was 8427, checked in by davies, 13 years ago

Adding the trapezoidal channel validation test, and editing the ANUGA manual

File size: 3.2 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4# Import standard shallow water domain and standard boundaries.
5import anuga
6import time
7import subprocess
8import csv
9import os
10from anuga.abstract_2d_finite_volumes.util import add_directories
11from anuga.utilities.log_analyser import analyse_log
12
13
14#------------------------------------------------------------------------------
15# Set up variables for the correct directories to store the output
16#------------------------------------------------------------------------------
17home = os.getenv('INUNDATIONHOME')
18scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
19                                     "timelen-over-timestep"])
20meta = 'metalog.csv'
21meta_path = os.path.join(scenariodir, meta)
22final = 'final.csv'
23final_path = os.path.join(scenariodir, final)
24
25# main loops that give the time length (m) and the time step (n)
26for m in range(10,1000,200):
27
28    for n in range(10,1000,100):
29        n = n/100.0 #adjust it so its small enough to see the nature of the relationship
30        subprocess.call(['python2.5', 'ex1.py',str(m),str(n)])#run it
31print 'Done'
32
33#get the important data for the experiments from the anuga experiments
34analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) 
35
36#open files to read from and write to
37metalog = csv.reader(open(meta_path,'rb'))
38final = csv.writer(open(final_path,'wb'))
39
40#list stores the index of the values requird
41indexlist = []
42
43#read in the first row
44firstrow = metalog.next()
45
46#get the indices of the values we want, so that the data can be condensed
47indexlist.append(firstrow.index("beforetime"))
48indexlist.append(firstrow.index("aftertime"))
49indexlist.append(firstrow.index("aftermeshtime"))
50indexlist.append(firstrow.index("beforesimulationmemory"))
51indexlist.append(firstrow.index("aftermeshmemory"))
52indexlist.append(firstrow.index("afterinitialconditionsmemory"))
53indexlist.append(firstrow.index("afterboundarymemory"))
54indexlist.append(firstrow.index("aftersimulationmemory"))
55indexlist.append(firstrow.index("timelength"))
56indexlist.append(firstrow.index("timestep"))
57
58#write the header for the final csv
59final.writerow(["TimeTaken(s)","MeshTime(s)",
60                firstrow[(indexlist[3])],firstrow[(indexlist[4])],
61                firstrow[(indexlist[5])],firstrow[(indexlist[6])],
62                firstrow[(indexlist[7])],firstrow[(indexlist[8])],
63                firstrow[(indexlist[9])]])
64
65#write the data for each column in the final csv
66for row in metalog:
67
68    #manipulate the beginning and end time to get the time taken
69    begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S')
70    end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S')
71    mesh = time.strptime(row[(indexlist[2])],'%Y%m%d_%H%M%S')
72    taken = time.mktime(end) - time.mktime(begin)
73    meshtime = time.mktime(mesh) - time.mktime(begin)
74
75    #write to file
76    final.writerow([str(taken),str(meshtime),
77                    row[(indexlist[3])],row[(indexlist[4])],
78                    row[(indexlist[5])],row[(indexlist[6])],
79                    row[(indexlist[7])],row[(indexlist[8])],
80                    row[(indexlist[9])]])
Note: See TracBrowser for help on using the repository browser.