Changeset 2448
- Timestamp:
- Feb 24, 2006, 6:22:02 PM (18 years ago)
- Location:
- development/stochastic_study
- Files:
-
- 1 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
development/stochastic_study/project.py
r2424 r2448 4 4 # Inputs 5 5 boundary_filename = 'input_wave.tms' 6 bathymetry_filename = 'bathymetry. txt'6 bathymetry_filename = 'bathymetry.pts' 7 7 8 8 # Model name 9 9 basename = 'simulation' 10 10 mesh_filename = basename + '.msh' 11 12 # Stats (Suresh ?) 13 number_of_samples = 300 14 std_dev = 0.01 15 mean = 0.0 16 blocksize = 100 #How many realisations to fit at a time 17 18 19 11 20 12 21 -
development/stochastic_study/run_model.py
r2433 r2448 22 22 import os 23 23 import time 24 import cPickle 24 25 25 26 # Related major packages … … 33 34 # Application specific imports 34 35 import project # Definition of file names and polygons 36 37 35 38 36 39 … … 47 50 print 'The extent is ', domain.get_extent() 48 51 49 domain.set_name(project.basename)50 52 domain.set_datadir('.') 51 53 domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) 52 54 53 domain.check_integrity() 54 55 56 #------------------------------------------------------------------------------ 57 # Setup initial conditions 58 #------------------------------------------------------------------------------ 59 domain.set_quantity('elevation', 60 filename = project.bathymetry_filename[:-4] + '.pts', 61 alpha = 0.001, 62 verbose = True, 63 use_cache = True) 64 65 domain.set_quantity('friction', 0.0) 66 domain.set_quantity('stage', 0.0) 55 #domain.check_integrity() 67 56 68 57 … … 80 69 81 70 #------------------------------------------------------------------------------ 82 # Evolve system through time71 # Setup initial conditions 83 72 #------------------------------------------------------------------------------ 84 t0 = time.time() 85 for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): 86 domain.write_time() 87 domain.write_boundary_statistics(tags = 'wave') 73 domain.set_quantity('friction', 0.0) 74 domain.set_quantity('stage', 0.0) 88 75 89 print 'That took %.2f seconds' %(time.time()-t0) 76 # Get prefitted realisations 77 realisation = 0 78 for filename in os.listdir('.'): 79 if filename.startswith(project.basename) and filename.endswith('.pck'): 80 print 'Reading %s' %filename 81 fid = open(filename) 82 V = cPickle.load(fid) 83 fid.close() 84 85 # For each column (each realisation) 86 for i in range(V.shape[1]): 87 name = project.basename + '_realisation_%d' %realisation 88 domain.set_name(name) #Output name 89 domain.set_quantity('elevation', V[:,i]) #Assign bathymetry 90 91 #--------------------------------------------------- 92 # Evolve system through time 93 #--------------------------------------------------- 94 print 'Running realisation %d of %d in block %s'\ 95 %(i, V.shape[1], filename) 96 t0 = time.time() 97 for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): 98 domain.write_time() 99 #domain.write_boundary_statistics(tags = 'wave') 100 101 print 'Realisation %d took %.2f seconds'\ 102 %(realisation, time.time()-t0) 103 104 realisation += 1
Note: See TracChangeset
for help on using the changeset viewer.