Ignore:
Timestamp:
Jun 21, 2006, 9:31:57 AM (18 years ago)
Author:
sexton
Message:

MOST and ANUGA comparisons and updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • production/sydney_2006/run_sydney_smf.py

    r2640 r3190  
    2727from pyvolution.quantity import Quantity
    2828from Numeric import allclose
     29from utilities.polygon import inside_polygon
    2930
    3031# Application specific imports
     
    7071
    7172# original issue to Benfield
    72 #interior_res = 5000
    73 #interior_regions = [[project.harbour_polygon_2, interior_res],
    74 #                    [project.botanybay_polygon_2, interior_res]]
     73interior_res = 5000
     74interior_regions = [[project.harbour_polygon_2, interior_res],
     75                    [project.botanybay_polygon_2, interior_res]]
    7576
    7677# used for finer mesh
    77 interior_res1 = 5000
    78 interior_res2 = 315
    79 interior_regions = [[project.newpoly1, interior_res1],
    80                     [project.south1, interior_res1],
    81                     [project.finepolymanly, interior_res2],
    82                     [project.finepolyquay, interior_res2]]
    83 
    84 print 'number of interior regions', len(interior_regions)
     78#interior_res1 = 5000
     79#interior_res2 = 315
     80#interior_regions = [[project.newpoly1, interior_res1],
     81#                    [project.south1, interior_res1],
     82#                    [project.finepolymanly, interior_res2],
     83#                    [project.finepolyquay, interior_res2]]
     84
     85# used for coastal polygons constructed by GIS guys
     86def get_polygon_from_file(filename):
     87    """ Function to read in output from GIS determined polygon
     88    """
     89    fid = open(filename)
     90    lines = fid.readlines()
     91    fid.close()
     92   
     93    polygon = []
     94    for line in lines[1:]:
     95       fields = line.split(',')
     96       x = float(fields[1])
     97       y = float(fields[2])
     98       polygon.append([x, y])
     99       
     100    return polygon
     101
     102num_polygons = 9
     103fileext = '.csv'
     104filename = project.polygonptsfile
     105
     106#interior_res = 1000
     107#interior_regions = []
     108#bounding_polygon = project.diffpolygonall#project.demopoly
     109#count = 0
     110#for p in range(1, num_polygons+1):
     111#    thefilename = filename + str(p) + fileext
     112#    print 'reading in polygon points', thefilename
     113#    interior_polygon = get_polygon_from_file(thefilename)
     114#    interior_regions.append([interior_polygon, interior_res])
     115#    n = len(interior_polygon)
     116#    # check interior polygon falls in bounding polygon
     117#    if len(inside_polygon(interior_polygon, bounding_polygon,
     118#                   closed = True, verbose = False)) <> len(interior_polygon):
     119#        print 'WARNING: interior polygon %d is outside bounding polygon' %(p)
     120#        count += 1
     121#    # check for duplicate points in interior polygon
     122   
     123print 'number of interior polygons: ', len(interior_regions)
     124#if count == 0: print 'interior polygons OK'
    85125
    86126#FIXME: Fix caching of this one once the mesh_interface is ready
     
    89129# original + refined region
    90130_ = cache(create_mesh_from_regions,
    91           project.diffpolygonall,
     131          #project.demopoly,
     132          project.diffpolygonall2,
     133          #{'boundary_tags': {'bottom': [0],
     134          #                   'right1': [1], 'right0': [2],
     135          #                   'right2': [3], 'top': [4], 'left1': [5],
     136          #                   'left2': [6], 'left3': [7]},
    92137          {'boundary_tags': {'bottom': [0],
    93                              'right1': [1], 'right0': [2],
    94                              'right2': [3], 'top': [4], 'left1': [5],
     138                             'bottom1': [1], 'right': [2],
     139                             'top1': [3], 'top': [4], 'left1': [5],
    95140                             'left2': [6], 'left3': [7]},
     141          #{'boundary_tags': {'bottom': [0], 'right': [1],
     142          #                   'top': [2], 'left': [3]},
    96143           'maximum_triangle_area': 100000,
    97144           'filename': meshname,           
     
    126173                               radius=3330,
    127174                               dphi=0.23,
    128                                x0=project.slump_origin[0],
    129                                y0=project.slump_origin[1],
     175                               x0=project.slump_origin2[0],
     176                               y0=project.slump_origin2[1],
    130177                               alpha=0.0,
    131                                domain=domain)
    132 
     178                               domain=domain,
     179                               verbose=True)
    133180
    134181#-------------------------------------------------------------------------------                                 
     
    138185# apply slump after 30 mins, initialise to water level of tide = 0
    139186domain.set_quantity('stage', 0.0)
    140 domain.set_quantity('friction', 0.03)
     187domain.set_quantity('friction', 0.04)
    141188domain.set_quantity('elevation',
    142189                    filename = project.combineddemname + '.pts',
     
    158205#                      'right2': Br, 'top': Br, 'left1': Br,
    159206#                      'left2': Br, 'left3': Br} )
    160 
     207# for new tests 4 April 2006
     208#domain.set_boundary( {'bottom': Br, 'bottom1': Br, 'right': Br,
     209#                      'top1': Br, 'top': Br, 'left1': Br,
     210#                      'left2': Br, 'left3': Br} )
     211                             
    161212# enforce Dirichlet BC - from 30/03/06 Benfield visit
    162 domain.set_boundary( {'bottom': Bd, 'right1': Bd, 'right0': Bd,
    163                       'right2': Bd, 'top': Bd, 'left1': Bd,
     213domain.set_boundary( {'bottom': Bd, 'bottom1': Bd, 'right': Bd,
     214                      'top1': Bd, 'top': Bd, 'left1': Bd,
    164215                      'left2': Bd, 'left3': Bd} )
    165216
    166217# increasingly finer interior regions
    167 #domain.set_boundary( {'bottom': Br, 'right': Br, 'left': Br, 'top': Br} )
     218#domain.set_boundary( {'bottom': Bd, 'right': Bd, 'left': Bd, 'top': Bd} )
    168219
    169220
     
    177228fid = open(thisfile, 'w')
    178229
    179 for t in domain.evolve(yieldstep = 120, finaltime = 18000):
     230# save every 10 secs leading up to slump initiation
     231for t in domain.evolve(yieldstep = 10, finaltime = 60): # 6 steps
    180232    domain.write_time()
    181233    domain.write_boundary_statistics(tags = 'bottom')
    182 
    183     # calculate integral
    184     thisstagestep = domain.get_quantity('stage')
    185     s = '%.2f, %.2f\n' %(t, thisstagestep.get_integral())
    186     fid.write(s)
    187 
    188     # add slump after 30 mins
    189     if allclose(t, 30*60):
     234    # calculate integral
     235    thisstagestep = domain.get_quantity('stage')
     236    s = '%.2f, %.2f\n' %(t, thisstagestep.get_integral())
     237    fid.write(s)
     238    # add slump after 30 secs
     239    if allclose(t, 30):
    190240        slump = Quantity(domain)
    191241        slump.set_values(tsunami_source)
    192242        domain.set_quantity('stage', slump + thisstagestep)
    193    
     243        #test_stage = domain.get_quantity('stage')
     244        #test_elevation = domain.get_quantity('elevation')
     245        #test_depth = test_stage - test_elevation
     246        #test_max = max(test_depth.get_values())
     247        #print 'testing', test_max
     248
     249import sys; sys.exit()
     250
     251# save every two minutes leading up to interesting period
     252for t in domain.evolve(yieldstep = 120, finaltime = 660, # steps
     253                       skip_initial_step = True):
     254    domain.write_time()
     255    domain.write_boundary_statistics(tags = 'bottom')
     256    # calculate integral
     257    thisstagestep = domain.get_quantity('stage')
     258    s = '%.2f, %.2f\n' %(t, thisstagestep.get_integral())
     259    fid.write(s)
     260
     261
     262# save every thirty secs during interesting period
     263for t in domain.evolve(yieldstep = 60, finaltime = 5000, # steps
     264                       skip_initial_step = True):
     265    domain.write_time()
     266    domain.write_boundary_statistics(tags = 'bottom') #quantities = 'stage')
     267    # calculate integral
     268    thisstagestep = domain.get_quantity('stage')
     269    s = '%.2f, %.2f\n' %(t, thisstagestep.get_integral())
     270    fid.write(s)
     271
     272
     273import sys; sys.exit()
     274# save every two mins for next 5000 secs
     275for t in domain.evolve(yieldstep = 120, finaltime = 10000, # about 42 steps
     276                       skip_initial_step = True):
     277    domain.write_time()
     278    domain.write_boundary_statistics(tags = 'bottom') #quantities = 'stage')
     279    # calculate integral
     280    thisstagestep = domain.get_quantity('stage')
     281    s = '%.2f, %.2f\n' %(t, thisstagestep.get_integral())
     282    fid.write(s)
     283   
     284# save every half hour to end of simulation   
     285for t in domain.evolve(yieldstep = 1800, finaltime = 10*60*60, # 14 steps
     286                       skip_initial_step = True):
     287    domain.write_time()
     288    domain.write_boundary_statistics(tags = 'bottom') #quantities = 'stage'
     289    # calculate integral
     290    thisstagestep = domain.get_quantity('stage')
     291    s = '%.2f, %.2f\n' %(t, thisstagestep.get_integral())
     292    fid.write(s)
    194293   
    195294print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracChangeset for help on using the changeset viewer.