- Timestamp:
- Jan 31, 2012, 10:54:12 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/parameters/timestep/main.py
r8304 r8326 1 """Simple water flow example using ANUGA2 Water flowing down a channel3 """4 1 #------------------------------------------------------------------------------ 5 2 # Import necessary modules 6 3 #------------------------------------------------------------------------------ 7 # Import standard shallow water domain and standard boundaries.8 4 import anuga 9 5 import time 10 import random11 6 import subprocess 12 import ex113 7 import csv 14 8 import os 15 from anuga.utilities import system_tools,log9 from anuga.utilities import log 16 10 from anuga.abstract_2d_finite_volumes.util import add_directories 11 from anuga.utilities.log_analyser import analyse_log 12 17 13 #------------------------------------------------------------------------------ 18 # Set up computational domain14 # Set up variables for the correct directories to store the output 19 15 #------------------------------------------------------------------------------ 20 a = []21 16 home = os.getenv('INUNDATIONHOME') 22 23 24 17 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 25 18 "timestep"]) 26 19 file = 'ex1.csv' 27 28 log.log_filename = os.path.join(scenariodir, 'log.txt')29 30 20 file_path = os.path.join(scenariodir, file) 21 store ='store.txt' 22 file_path_store = os.path.join(scenariodir, store) 31 23 32 24 spamWriter = csv.writer(open(file_path, 'wb')) 25 spamWriter.writerow(['TimeStep' , 'Time Taken','Space Used']) 33 26 34 spamWriter.writerow(['Friction' , 'Time Taken','Space Used']) 27 e = open(file_path_store,'a') # create file 28 e.close() 35 29 30 #main loop that runs the script with different time steps (yield steps) 31 for n in range(1,10000,10): 32 n = n/100.0 # get it in the right range 36 33 37 for n in range(1,100,1): 38 n = n/100.0 39 system_tools.MemoryUpdate() 40 x = time.clock() 41 ex1.runex(n) 42 y = time.clock() 43 b = system_tools.MemoryUpdate()[0] 44 spamWriter.writerow([n ,(y-x),b]) 45 a.append((n,y-x,b)) 46 print a 34 g = open(file_path_store,'r+') 35 g.write(str(n)) #write the time step to the file 47 36 37 x = time.clock()#time it 38 subprocess.call(['python2.5', 'ex1.py']) # run it 39 y = time.clock() #time it 40 spamWriter.writerow([n ,(y-x),'b']) #record results 41 42 print 'Done' 43 44 analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
Note: See TracChangeset
for help on using the changeset viewer.