Changeset 5989


Ignore:
Timestamp:
Nov 21, 2008, 3:35:51 PM (16 years ago)
Author:
ole
Message:

Update from Ted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/ted_rigby/model_run.py

    r5984 r5989  
    1111
    1212Code Version : 1.00 June 2008 Initial release
     13               1.01 December 2008 Vble_n recoded to speed execution
    1314Author       : E Rigby (0437 250 500) ted.rigby@rienco.com.au
    1415
     
    141142
    142143# Assign uniform initial friction value to domain mesh centroids as initial condition
    143 # Note need to re-assess initial friction value based on rough_polys read in from tuflow
    144 # 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!!!!
    145146domain.set_quantity('friction', model_data.default_n, location = 'centroids')
    146147
     
    201202tms_filename=model_data.dsbc_hydrographs[0]
    202203lake_stage  = file_function(tms_filename,quantities='value',boundary_polygon=None)
    203 # Note: will need to be modified if more than one dsbcis to be applied
     204# Note: will need to be modified if more than one dsbc is to be applied
    204205print model_data.basename + ' >>>> Applying dsbc %s to model at the Lake_bdry ' %(tms_filename)
    205206
     
    227228#######################################################################################
    228229#                                                                                     #
    229 READ IN THE (TEMPORALLY DEPTH DEPENDENT) SURFACE ROUGHNESS (FRICTION) PARAMETERS   #
     230ASSIGN THE (TEMPORALLY DEPTH DEPENDENT) SURFACE ROUGHNESS (FRICTION) PARAMETERS    #
    230231#                                                                                     #
    231232#######################################################################################
    232233
    233234#---------------------------------------------------------------------------------------
    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 is used with depth to
    236 # 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).
    237238#
    238239# 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_RID
    240 # across the whole bounding poly area before applying (overwriting) with the actual RID polys
    241 # 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!!!!
    242243#--------------------------------------------------------------------------------------
    243244
     
    245246
    246247N = 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
     257material_variables = zeros((N, 5), Float)               
     258
     259# Set default material variables n0, d1, n1, d2, n2 in the roughness array
     260default_n0 = 0.040
     261default_d1 = 0.3
     262default_n1 = 0.050
     263default_d2 = 1.5
     264default_n2 = 0.030
     265
     266material_variables[:,0] = default_n0   # n0
     267material_variables[:,1] = default_d1   # d1 
     268material_variables[:,2] = default_n1   # n1 
     269material_variables[:,3] = default_d2   # d2 
     270material_variables[:,4] = default_n2   # n2 
     271
     272print '         ++++ 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
     277points = domain.get_centroid_coordinates(absolute=True)   
    261278
    262279for k, poly in enumerate(model_data.mat_poly_list):
     
    270287    # Material data for polygon     
    271288    n0, d1, n1, d2, n2 = model_data.mat_roughness_data[rid]   
    272        
     289   
     290    # Update the data for the elements inside the mat_poly   
    273291    for i in indices:
    274292        material_variables[i, 0] = n0
     
    280298   
    281299
    282 print '         ++++ Upgraded material_variables spatially 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 n to domain at t= %.2f hours ' %(float(time.time()-t0)/3600.0)
     300print '         ++++ Finally - material_variables data updated spatially with the material values set in the mif/mid files '
     301
     302   
     303print model_data.basename+' >>>> Completed assignment of material (surface roughness) data to domain at t= %.2f hours ' %(float(time.time()-t0)/3600.0)
    286304
    287305print model_data.basename+' >>>> Completed domain construction at t= %.2f hours ' %(float(time.time()-t0)/3600.0)
     
    296314
    297315#----------------------------------------------------------------------------------------
    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.                                                 
    300319#
    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.
    305335#----------------------------------------------------------------------------------------
    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 interest
    311 #       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 well
    313 
    314336print 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 data
    316 endtime       = 9000               # end at 9000 secs (150min) - Increase to 40hrs when debugged!!!!!!!!
    317 steptime      = 300                # write sww  file results out every 300secs = 5min
    318 
    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 
     337starttime     = 40*3600              # start simulation at t=40h relative to user/data time
     338endtime       = starttime + 4*3600   # end simulation at t=44h relative to user/data time
     339steptime      = 300                  # write sww  file results out every 300secs = 5min
     340
     341print 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
     343Initiate the starttime reset
    322344domain.set_starttime(starttime)
    323345
    324346
    325 for t in domain.evolve(yieldstep = steptime, finaltime = endtime):
     347for t in domain.evolve(yieldstep = steptime, finaltime = endtime):       # This is a steptime loop (not computaional timestep)
    326348   
    327349    domain.write_time()                                                  # confirm t each steptime
     
    329351    depth = domain.create_quantity_from_expression('stage - elevation')  # create depth instance for this timestep
    330352
    331 
    332     print '         ++++ Recomputing friction at t= ', domain.get_time()
    333        
     353    print '         ++++ Recomputing friction at t= ', t
    334354
    335355    # rebuild the 'friction' values adjusted for depth
    336     for i in domain.get_wet_elements():                                        # loop for each wet element in domain
     356    for i in domain.get_wet_elements():                                  # loop for each wet element in domain
    337357   
    338358        # Get roughness variables
     
    344364               
    345365
    346         # Recompute friction values from depth for this element get_tuflow_data.py
     366        # Recompute friction values from depth for this element
    347367        d = depth.get_values(location='centroids', indices=[i])[0]
    348368         
Note: See TracChangeset for help on using the changeset viewer.