Changeset 2984
- Timestamp:
- May 26, 2006, 3:15:44 PM (18 years ago)
- Location:
- development/stochastic_study
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
development/stochastic_study/project.py
r2979 r2984 27 27 28 28 # Stats (Suresh ?) 29 number_of_realisations = 229 number_of_realisations = 16000 30 30 #std_dev = 0.0026 #Range is 26.035 cm 31 31 #std_dev = 0.0013 #Range is 26.035 cm -
development/stochastic_study/run_model.py
r2979 r2984 32 32 from pyvolution.util import file_function 33 33 from caching.caching import cache 34 import pypar 34 35 35 36 # Application specific imports … … 37 38 38 39 40 #----------------------------------------------------------------------------- 41 # Read in processor information 42 #----------------------------------------------------------------------------- 43 44 myid = pypar.rank() 45 numprocs = pypar.size() 46 processor_name = pypar.Get_processor_name() 47 48 print 'I am process %d of %d running on %s' %(myid, numprocs, processor_name) 39 49 40 50 … … 42 52 # Setup computational domain 43 53 #----------------------------------------------------------------------------- 44 print 'Creating domain from', project.mesh_filename54 #print 'Creating domain from', project.mesh_filename 45 55 46 56 domain = Domain(project.working_dir + project.mesh_filename, 47 57 use_cache=False, 48 verbose= True)58 verbose=False) 49 59 50 60 51 print 'Number of triangles = ', len(domain)52 print domain.statistics()61 #print 'Number of triangles = ', len(domain) 62 #print domain.statistics() 53 63 54 64 … … 61 71 #------------------------------------------------------------------------------ 62 72 63 function = file_function(project.boundary_filename, domain, verbose = True)73 function = file_function(project.boundary_filename, domain, verbose = False) 64 74 Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) #Input wave 65 75 Br = Reflective_boundary(domain) #Wall … … 84 94 for filename in os.listdir(project.working_dir): 85 95 if filename.startswith(project.basename) and filename.endswith('.pck'): 86 print 'Reading %s' %filename96 #print 'Reading %s' %filename 87 97 fid = open(filename) 88 98 V = cPickle.load(fid) … … 91 101 # For each column (each realisation) 92 102 for i in range(V.shape[1]): 93 if i == 0:94 name = project.basename + '_original'95 else:96 name = project.basename97 domain.set_name(name) #Output name98 domain.set_quantity('elevation', V[:,i]) #Assign bathymetry99 domain.set_time(0.0) #Reset time100 103 101 #--------------------------------------------------- 102 # Evolve system through time 103 #--------------------------------------------------- 104 print 'Running realisation %d of %d in block %s'\ 105 %(i, V.shape[1], filename) 106 print 'Z Range:', min(V[:,i]), max(V[:,i]) 104 # Distribute work in round-robin fashion 105 if i%numprocs == myid: 106 107 name = project.basename + '_P%d' %myid 108 domain.set_name(name) #Output name 109 domain.set_quantity('elevation', V[:,i]) #Assign bathymetry 110 domain.set_time(0.0) #Reset time 107 111 108 t0 = time.time() 109 for t in domain.evolve(yieldstep = timestep, 110 finaltime = finaltime): 111 domain.write_time() 112 112 #--------------------------------------------------- 113 # Evolve system through time 114 #--------------------------------------------------- 115 print 'P%d: Running realisation %d of %d in block %s'\ 116 %(myid, realisation, V.shape[1], filename) 117 118 t0 = time.time() 119 for t in domain.evolve(yieldstep = timestep, 120 finaltime = finaltime): 121 pass 122 #domain.write_time() 123 113 124 114 print 'Simulation of realisation %d took %.2f seconds'\115 %(realisation, time.time()-t0)125 print 'P%d: Simulation of realisation %d took %.2f seconds'\ 126 %(myid, realisation, time.time()-t0) 116 127 117 128 118 129 119 130 120 #---------------------------------------------------121 # Now extract the 3 timeseries (Ch 5-7-9) and store them122 # in three files for this realisation123 f = file_function(project.working_dir + domain.filename + '.sww',124 quantities='stage',125 interpolation_points=project.gauges,126 verbose=True)131 #--------------------------------------------------- 132 # Now extract the 3 timeseries (Ch 5-7-9) and store them 133 # in three files for this realisation 134 f = file_function(project.working_dir + domain.filename + '.sww', 135 quantities='stage', 136 interpolation_points=project.gauges, 137 verbose=False) 127 138 128 139 129 simulation_name = project.working_dir + \130 domain.filename + '_realisation_%d' %realisation140 simulation_name = project.working_dir + \ 141 project.basename + '_realisation_%d' %realisation 131 142 132 for k, name in enumerate(project.gauge_names):133 fid = open(simulation_name + '_' + name + '.txt', 'w')134 for t in f.get_time():135 #For all precomputed timesteps136 val = f(t, point_id = k)[0]137 fid.write('%f %f\n' %(t, val))143 for k, name in enumerate(project.gauge_names): 144 fid = open(simulation_name + '_' + name + '.txt', 'w') 145 for t in f.get_time(): 146 #For all precomputed timesteps 147 val = f(t, point_id = k)[0] 148 fid.write('%f %f\n' %(t, val)) 138 149 139 fid.close()150 fid.close() 140 151 141 152 142 153 143 154 realisation += 1 155 156 157 pypar.finalize()
Note: See TracChangeset
for help on using the changeset viewer.