- 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/scenarios/channelflow/main.py
r8320 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 random 10 6 import subprocess 11 import ex112 7 import csv 13 8 import os 14 9 import time 15 from anuga.utilities import system_tools, log16 10 from anuga.abstract_2d_finite_volumes.util import add_directories 11 from anuga.utilities.log_analyser import analyse_log 17 12 18 13 #------------------------------------------------------------------------------ 19 # Set up computational domain14 # Set up variables for the correct directories to store the output 20 15 #------------------------------------------------------------------------------ 21 a = []22 23 24 16 home = os.getenv('INUNDATIONHOME') 25 17 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 26 18 "channelflow"]) 27 28 log.log_filename = os.path.join(scenariodir, 'log.txt') 29 19 store ='store.txt' 20 file_path_store = os.path.join(scenariodir, store) 21 storen ='storen.txt' 22 file_path_storen = os.path.join(scenariodir, storen) 30 23 file = 'ex1.csv' 31 24 file_path = os.path.join(scenariodir, file) 32 25 26 #set up the output files 33 27 spamWriter = csv.writer(open(file_path, 'wb')) 34 28 spamWriter.writerow(['Length','Stage','Time','Space']) 29 e = open(file_path_store,'a') 30 e.close() 31 e = open(file_path_storen,'a') 32 e.close() 35 33 34 #the main loops that give the length of the inflow boundary (i) and the place to begin the step (n) 36 35 for 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 37 41 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)) 48 47 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 53 print 'DONE' 54 55 analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the various log files
Note: See TracChangeset
for help on using the changeset viewer.