Changeset 4360 for anuga_core
- Timestamp:
- Apr 4, 2007, 12:48:14 PM (18 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/__init__.py
r3678 r4360 12 12 Transmissive_Momentum_Set_Stage_boundary,\ 13 13 Dirichlet_Discharge_boundary,\ 14 Constant_stage, Constant_height 14 Constant_stage, Constant_height,\ 15 Field_boundary 15 16 16 17 -
anuga_core/source/anuga/shallow_water/xtest_Bf.py
r4317 r4360 22 22 23 23 # Related major packages 24 from anuga.shallow_water import Domain,Dirichlet_boundary,File_boundary,Transmissive_boundary 25 #from anuga.shallow_water import Reflective_boundary24 from anuga.shallow_water import Domain,Dirichlet_boundary,File_boundary,Transmissive_boundary, Field_boundary 25 #from anuga.shallow_water.shallow_water_domain import Field_boundary 26 26 from Numeric import allclose, array 27 27 from anuga.pmesh.mesh_interface import create_mesh_from_regions … … 43 43 tide = 2.4 44 44 45 46 #EVOLVED MODEL 47 45 48 #-------------------------------------------------------------------------- 46 49 # Create the triangular mesh based on overall clipping polygon with a … … 52 55 #all = [[469000,7760000],[470000,7758000],[468000,7758000]] 53 56 #all = [[470000,7760000],[469000,7758000],[468000,7760000]] 54 all_large = [[474000,7764000],[474000,7756000],[466000,7756000],[466000,7764000]] 55 all = [[470000,7764000],[470000,7756000],[466000,7756000],[466000,7764000]] 57 58 #all_large = [[474000,7764000],[474000,7756000],[466000,7756000],[466000,7764000]] 59 #all = [[470000,7764000],[470000,7756000],[466000,7756000],[466000,7764000]] 60 all = [[465184,7764500],[470397,7764510],[470407,7758988],[465195,7758979]] 61 # N, W, S, E 62 56 63 create_mesh_from_regions(all, 57 64 # boundary_tags={'ocean': [0,1,2]}, 58 65 # boundary_tags={'ocean': [ 2],'side': [0, 1]}, 59 boundary_tags={'ocean': [ 2],'side': [1, 3], 'back': [0]},66 boundary_tags={'ocean': [ 0],'side': [1, 3], 'back': [2]}, 60 67 maximum_triangle_area=50000, 61 68 filename=meshes_dir_name, 62 69 use_cache=False, 63 #verbose=True70 # verbose=True 64 71 ) 65 72 … … 67 74 # Setup computational domain 68 75 #------------------------------------------------------------------------- 69 print 'Setup computational domain'76 #print 'Setup computational domain' 70 77 domain = Domain( meshes_dir_name, verbose=True) 78 79 from anuga.shallow_water.data_manager import urs2sww 80 boundaries_dir_name = 'o_test' 81 82 # convert MUX urs files to an SWW file output 83 #print 'boundary file is: ',boundaries_dir_name 84 from caching import cache 85 cache(urs2sww, 86 (boundaries_dir_name, 87 boundaries_dir_name), 88 {'verbose': False, 89 'mint': 9200, 'maxt': 11200, 90 # 'origin': domain.geo_reference.get_origin(), 91 'fail_on_NaN': False}, 92 verbose = False, 93 ) 71 94 72 95 #------------------------------------------------------------------------- … … 74 97 #------------------------------------------------------------------------- 75 98 76 print 'Start Set quantity'99 #print 'Start Set quantity' 77 100 78 101 domain.set_quantity('elevation', -42.3) 79 102 80 print 'Finished Set quantity'103 #print 'Finished Set quantity' 81 104 82 105 #------------------------------------------------------ … … 84 107 #------------------------------------------------------ 85 108 86 domain.set_quantity('stage', 2.4)109 domain.set_quantity('stage', tide) 87 110 domain.set_quantity('friction', 0.01) 88 111 domain.set_name(fileName) … … 92 115 # Setup boundary conditions 93 116 #------------------------------------------------------------------------- 94 Bf = File_boundary(out_dir + 'o_test_8500_12000.sww', 95 domain, time_thinning=24, use_cache=True, verbose=True) 96 97 print 'finished reading boundary file' 117 #Bf = File_boundary(out_dir + 'o_test_8500_12000.sww', 118 # domain, time_thinning=24, use_cache=True, verbose=True) 119 Bf = Field_boundary(out_dir + 'o_test.sww', 120 domain, mean_stage=tide, use_cache=True, verbose=False) 121 122 #print 'finished reading boundary file' 98 123 99 124 #Br = Reflective_boundary(domain) … … 101 126 Bd = Dirichlet_boundary([tide,0,0]) 102 127 103 print'set_boundary'128 #print'set_boundary' 104 129 105 130 domain.set_boundary({'back': Bt, … … 107 132 'ocean': Bf 108 133 }) 109 print'finish set boundary'134 #print'finish set boundary' 110 135 111 136 #---------------------------------------------------------------------------- … … 113 138 #---------------------------------------------------------------------------- 114 139 140 #remove mesh file!!! and o_test.sww 115 141 t0 = time.time() 116 142 117 for t in domain.evolve(yieldstep = 60, finaltime = 3400):143 for t in domain.evolve(yieldstep = 60, finaltime = 1920): 118 144 domain.write_time() 119 domain.write_boundary_statistics(tags = 'ocean')120 121 122 123 145 # domain.write_boundary_statistics() 146 147 148 149 #Gets timeseries from boundary sww and evolved sww 124 150 home = getenv('INUNDATIONHOME') #Sandpit's parent dir 125 151 #user = get_user_name() … … 145 171 146 172 147 gauge_boundary_filename = 'boundary_gauge_near_top.csv' 173 #gauge_boundary_filename = 'boundary_gauge_near_top.csv' 174 gauge_boundary_filename = 'gauges_time_series_b_near_top.csv' 148 175 gauge_evolved_filename = 'gauges_time_series_near_top.csv' 149 176 150 177 boundary_dir_filename = os.path.join(out_dir,gauge_boundary_filename) 151 print'boundary_dir_filename',boundary_dir_filename178 #print'boundary_dir_filename',boundary_dir_filename 152 179 153 180 evolved_dir_filename= os.path.join(out_dir,gauge_evolved_filename) 154 181 155 print'boundary_dir_filename',boundary_dir_filename156 print'evolved_dir_filename',evolved_dir_filename182 #print'boundary_dir_filename',boundary_dir_filename 183 #print'evolved_dir_filename',evolved_dir_filename 157 184 158 185 swwfiles = {} 159 186 swwfile = out_dir + fileName + '.sww' 160 187 swwfiles[swwfile] = run_time 161 print"swwfiles",swwfiles,"shallow_water"188 #print"swwfiles",swwfiles,"shallow_water" 162 189 163 190 texname, elev_output = sww2timeseries(swwfiles, … … 171 198 title_on = False, 172 199 use_cache = True, 173 verbose = True) 200 verbose = False) 201 202 swwfiles = {} 203 swwfile = out_dir + boundaries_dir_name + '.sww' 204 swwfiles[swwfile] = run_time 205 #print"swwfiles",swwfiles,"shallow_water" 206 207 texname, elev_output = sww2timeseries(swwfiles, 208 out_dir+sep+"boundary_gauges.csv", 209 production_dirs, 210 report = False, 211 plot_quantity = ['stage', 'xmomentum', 'ymomentum'], 212 surface = False, 213 time_min = None, 214 time_max = None, 215 title_on = False, 216 use_cache = True, 217 verbose = False) 174 218 175 219 #makes the csv files from the evolved model … … 182 226 e_elevation = e_data[:,4] 183 227 184 print'boundary_dir_filename',boundary_dir_filename228 #print'boundary_dir_filename',boundary_dir_filename 185 229 b_header, b_data = get_data_from_file(boundary_dir_filename) 186 230 … … 194 238 # compares the 2 models 195 239 j=0 196 k= 1240 k=0 197 241 b_sample = [] 198 242 e_sample = [] … … 200 244 # if j<(len(e_time)) and b_time[i] == e_time[j]: 201 245 if j<(len(e_time)) and k<(len(e_time)) and b_time[i] == e_time[j]: 202 b_sample.append(float( b_stage[i]))246 b_sample.append(float(tide+b_stage[i])) 203 247 e_sample.append(float(e_stage[k])) 204 # print 'out:', b_time[i], b_stage[i],i, j, b_sample[j],e_stage[j] 205 # if k <len(e_time): print 'time e equal b:', b_time[i], b_stage[i],i, j, b_sample[j],e_stage[j], e_stage[k],(len(e_time)-1) 206 if k <len(e_time): print 'time e equal b:', b_time[i],i, j, b_stage[i], e_stage[k],(len(e_time)-1) 248 # if k <len(e_time): print 'time e equal b:', b_time[i],i, j, b_stage[i], b_sample[i], e_stage[k],(len(e_time)-1) 207 249 j = j +1 208 250 k = k +1 209 251 210 252 211 print len(b_sample), len(e_stage),e_stage,type(e_stage)253 #print len(b_sample), len(e_stage),e_stage,type(e_stage) 212 254 e_stage = e_stage.tolist() 213 255 e_stage.pop() 214 256 #e_stage.pop() 215 257 216 print len(b_sample), len(e_stage),e_stage258 #print len(b_sample), len(e_stage),e_stage 217 259 218 260 … … 220 262 print "test successful" 221 263 os.remove(fileName+'.sww') 222 print 'evolved_dir_filename',evolved_dir_filename264 #print 'evolved_dir_filename',evolved_dir_filename 223 265 os.remove('gauges_time_series_near_top.csv') 266 os.remove('gauges_time_series_b_near_top.csv') 267 os.remove('gauges_t0.csv') 224 268 os.remove('gauges_maxmins.csv') 269 os.remove(meshes_dir_name) 270 225 271 226 272 assert allclose (b_sample, e_sample, 0.5, 0.5)
Note: See TracChangeset
for help on using the changeset viewer.