Changeset 5989
- Timestamp:
- Nov 21, 2008, 3:35:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/ted_rigby/model_run.py
r5984 r5989 11 11 12 12 Code Version : 1.00 June 2008 Initial release 13 1.01 December 2008 Vble_n recoded to speed execution 13 14 Author : E Rigby (0437 250 500) ted.rigby@rienco.com.au 14 15 … … 141 142 142 143 # Assign uniform initial friction value to domain mesh centroids as initial condition 143 # Note need to re-assess initial friction value based on rough_polysread in from tuflow144 # files and computed depth during evolve time loop!!!!144 # Note: Friction will be re-assessed based on roughness data read in from tuflow 145 # 2d_mat files and computed depth during evolve time loop!!!! 145 146 domain.set_quantity('friction', model_data.default_n, location = 'centroids') 146 147 … … 201 202 tms_filename=model_data.dsbc_hydrographs[0] 202 203 lake_stage = file_function(tms_filename,quantities='value',boundary_polygon=None) 203 # Note: will need to be modified if more than one dsbc is to be applied204 # Note: will need to be modified if more than one dsbc is to be applied 204 205 print model_data.basename + ' >>>> Applying dsbc %s to model at the Lake_bdry ' %(tms_filename) 205 206 … … 227 228 ####################################################################################### 228 229 # # 229 # READ IN THE (TEMPORALLY DEPTH DEPENDENT) SURFACE ROUGHNESS (FRICTION) PARAMETERS#230 # ASSIGN THE (TEMPORALLY DEPTH DEPENDENT) SURFACE ROUGHNESS (FRICTION) PARAMETERS # 230 231 # # 231 232 ####################################################################################### 232 233 233 234 #--------------------------------------------------------------------------------------- 234 # This section creates a new domain quantity mat_RID and assigns surface roughness IDs (RID)235 # values to this quantity for later use in the evolve loop where RID isused with depth to236 # compute a depth dependent friction at each time step.235 # This section creates an array of surface roughness data for each element in the domain 236 # ready for later use in the evolve loop where the roughness data is used with depth to 237 # compute a depth dependent friction at each yieldstep (output timestep to the swww file). 237 238 # 238 239 # Note that because the polys read in should but may not cover the entire bounding poly area 239 # It is necessarry to declare a default material as in Tuflow applying the default to mat_RID240 # across the whole bounding poly area before applying (overwriting) with the actual RID polys241 # and their RID values obtained from the 2d_mat mid/mif files!!!!240 # It is prudent to initially declare a default material (as in Tuflow) applying the default 241 # to the whole domain before applying (overwriting) with the spatial roughness data from the 242 # polys obtained from the 2d_mat mid/mif files!!!! 242 243 #-------------------------------------------------------------------------------------- 243 244 … … 245 246 246 247 N = len(domain) 247 material_variables = zeros((N, 5), Float) 248 249 # Set default material variables n0, d1, n1, d2, n2 250 material_variables[:,0] = 0.035 # n0 251 material_variables[:,1] = 0.3 # d1 252 material_variables[:,2] = 0.050 # n1 253 material_variables[:,3] = 1.5 # d2 254 material_variables[:,4] = 0.030 # n2 255 256 257 # Assign polygonal data to material_variables from model_data.mat_poly_list 258 259 260 points = domain.get_centroid_coordinates(absolute=True) 248 # Create the new roughness array to hold the elemental roughness data 249 # In this array of Nx5 values 250 # n0 -- is the equivalent fixed roughness value 251 # d1 -- is the depth below which n1 applies 252 # n1 -- is the roughness applying below d1 253 # d2 -- is the depth above which n2 applies 254 # n2 -- is the roughness applying above d2 255 256 # Create and assign zeros to the roughness array 257 material_variables = zeros((N, 5), Float) 258 259 # Set default material variables n0, d1, n1, d2, n2 in the roughness array 260 default_n0 = 0.040 261 default_d1 = 0.3 262 default_n1 = 0.050 263 default_d2 = 1.5 264 default_n2 = 0.030 265 266 material_variables[:,0] = default_n0 # n0 267 material_variables[:,1] = default_d1 # d1 268 material_variables[:,2] = default_n1 # n1 269 material_variables[:,3] = default_d2 # d2 270 material_variables[:,4] = default_n2 # n2 271 272 print ' ++++ Initially - material_variables data set to default values across whole domain ' 273 274 # Update material_variables from model_data.mat_poly_list 275 276 # Obtain a list of real world centroid coords of model elements 277 points = domain.get_centroid_coordinates(absolute=True) 261 278 262 279 for k, poly in enumerate(model_data.mat_poly_list): … … 270 287 # Material data for polygon 271 288 n0, d1, n1, d2, n2 = model_data.mat_roughness_data[rid] 272 289 290 # Update the data for the elements inside the mat_poly 273 291 for i in indices: 274 292 material_variables[i, 0] = n0 … … 280 298 281 299 282 print ' ++++ Upgraded material_variablesspatially with the material values set in the mif/mid files '283 284 285 print model_data.basename+' >>>> Completed assignment of material (surface roughness) and default nto domain at t= %.2f hours ' %(float(time.time()-t0)/3600.0)300 print ' ++++ Finally - material_variables data updated spatially with the material values set in the mif/mid files ' 301 302 303 print model_data.basename+' >>>> Completed assignment of material (surface roughness) data to domain at t= %.2f hours ' %(float(time.time()-t0)/3600.0) 286 304 287 305 print model_data.basename+' >>>> Completed domain construction at t= %.2f hours ' %(float(time.time()-t0)/3600.0) … … 296 314 297 315 #---------------------------------------------------------------------------------------- 298 # This section starts the analysis of flow through the domain up to the specified finaltime 299 # All time is in seconds 316 # This section starts the analysis of flow through the domain from the specified (realworld) 317 # starttime up to the specified (realworld) finaltime 318 # All time is in seconds. 300 319 # 301 # Note: The internal computational timestep is set at each timestep to meet a CFL=1 limit. 302 # It is therefore important to examine the mesh statistics to see that there are no 303 # unintended small triangles, particularly in areas of deeper water as DT=DX/(g*H)**0.5 304 # Yieldstep is the interval at which results are saved to the output (sww) file 320 # Note: 321 # 1. -- The internal computational timestep is set at each timestep to meet a CFL=1 limit. 322 # It is therefore important to examine the mesh statistics to see that there are no 323 # unintended small triangles, particularly in areas of deeper water as they can 324 # dramatically reduce the computational timerstep and slow the model down. 325 # 2. -- The model runs on 'internal' time which will normally differ from realworld or 326 # 'Design' event time as input by the user in various datafiles. This 'internal'time is 327 # normally not seen by the user but users should be aware of its existence. 328 # 3. -- In a similar fashion the model runs with all coordinates recomputed to a local 329 # lower left frame origin (to impove numerical precission). The output files are in these 330 # 'internal' coordinates but each file also stores the new origin coordintes from which 331 # the realworld coordinates can be restored (as presently occurs in animate.exe) 332 # 4. -- 'friction' is recomputed as a function of depth and location at each steptime for 333 # all wet cells. Recomputation at every computational step was considered unnecessay 334 # and greatly incresed run times. 305 335 #---------------------------------------------------------------------------------------- 306 307 # Note: 'friction' is recomputed as a function of depth and location at each timestep( now each steptime!!)308 309 # EHR - could reduce recalc of friction to say every steptime??? this would markedly speedup?? Done??310 # EHR - need to set a startime and use in domain.set_time(starttime) to restrict to area of data of interest311 # not clear how initial conditions etc fit in to a start not at t=0???312 # EHR - could restrict update of friction to wet cells only as well313 314 336 print model_data.basename+' >>>> Starting the simulation for ',model_data.catchment,'-',model_data.simclass,'-',model_data.scenario,'-',model_data.event 315 starttime = 40*3600 # start simulation at t=40h relative to data316 endtime = 9000 # end at 9000 secs (150min) - Increase to 40hrs when debugged!!!!!!!!317 steptime = 300 # write sww file results out every 300secs = 5min318 319 print model_data.basename+' >>>> Simulation is for %.2f hours with output to the sww file at %.0f minute intervals ' %(float( endtime/3600.0),float(steptime/60.0))320 321 # 337 starttime = 40*3600 # start simulation at t=40h relative to user/data time 338 endtime = starttime + 4*3600 # end simulation at t=44h relative to user/data time 339 steptime = 300 # write sww file results out every 300secs = 5min 340 341 print model_data.basename+' >>>> Simulation is for %.2f hours with output to the sww file at %.0f minute intervals ' %(float((endtime-starttime)/3600.0),float(steptime/60.0)) 342 343 # Initiate the starttime reset 322 344 domain.set_starttime(starttime) 323 345 324 346 325 for t in domain.evolve(yieldstep = steptime, finaltime = endtime): 347 for t in domain.evolve(yieldstep = steptime, finaltime = endtime): # This is a steptime loop (not computaional timestep) 326 348 327 349 domain.write_time() # confirm t each steptime … … 329 351 depth = domain.create_quantity_from_expression('stage - elevation') # create depth instance for this timestep 330 352 331 332 print ' ++++ Recomputing friction at t= ', domain.get_time() 333 353 print ' ++++ Recomputing friction at t= ', t 334 354 335 355 # rebuild the 'friction' values adjusted for depth 336 for i in domain.get_wet_elements(): 356 for i in domain.get_wet_elements(): # loop for each wet element in domain 337 357 338 358 # Get roughness variables … … 344 364 345 365 346 # Recompute friction values from depth for this element get_tuflow_data.py366 # Recompute friction values from depth for this element 347 367 d = depth.get_values(location='centroids', indices=[i])[0] 348 368
Note: See TracChangeset
for help on using the changeset viewer.