Changeset 5038


Ignore:
Timestamp:
Feb 18, 2008, 1:32:33 PM (17 years ago)
Author:
nick
Message:

updates of run_circular.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_validation/circular_island/run_circular.py

    r5036 r5038  
    22
    33This script sets up 2D circular island.....
     4
     5use 'res' parameter of 1 to make run fast.
    46
    57"""
     
    1416from anuga.pmesh.mesh_interface import create_mesh_from_regions
    1517from anuga.utilities.polygon import read_polygon#, plot_polygons
    16 #from cmath import cos,sin,cosh,pi
    1718from math import cos,pi,sin,tan,sqrt
    1819from Numeric import array, zeros, Float, allclose,resize
     
    9495          247.5, 270.0, 292.5, 315.0, 337.5)
    9596
    96 #x = 12.96
    97 #y = 13.80
    9897center_x = 12.96
    9998center_y = 13.80
    10099
    101 #wavelenght =
    102 
    103 r1 = 1.5
    104 r2 = 2.5
    105100d=0.75
    106 #res=.05
     101res=0.05
    107102res=1.
    108 L=4.11
    109 
     103#L=3.6 and therefore the gauges 1,2,3 and 4 are located 1.8 from the toe of the island
     104# 13.8 - 3.6(radii of island) - 1.8 = 8.4
     105L=8.4
    110106
    111107#create polygons (circles) to have higher resolution
     
    117113    angle = ((angle-180)/180.0)*pi
    118114
    119     p = get_xy(center_x,center_y,3.6,angle)
     115    p = get_xy(center_x,center_y,4.0,angle)
    120116    poly1.append([p[0],p[1]])
    121117
     
    127123    #convert Degs to Rads
    128124    angle = ((angle-180)/180.0)*pi
    129     p = get_xy(center_x,center_y,2.4,angle)
     125    p = get_xy(center_x,center_y,2.6,angle)
    130126    poly2.append([p[0],p[1]])
    131127   
     
    137133    #convert Degs to Rads
    138134    angle = ((angle-180)/180.0)*pi
    139     p = get_xy(center_x,center_y,1.6,angle)
     135#    p = get_xy(center_x,center_y,1.6,angle)
     136    p = get_xy(center_x,center_y,1.5,angle)
    140137    poly3.append([p[0],p[1]])
    141138   
     
    143140internal_poly.append([poly3,1*res])
    144141
    145 poly4 = []
    146 for i,angle in enumerate(angles1):
    147     #convert Degs to Rads
    148     angle = ((angle-180)/180.0)*pi
    149     p = get_xy(center_x,center_y,1.1,angle)
    150     poly4.append([p[0],p[1]])
    151    
    152 poly.append(poly4)
    153 internal_poly.append([poly2,.01*res])
    154 
    155142#plot_polygons(poly,'poly.png')
    156143
    157 #poly_all= [[0,7],[0,25],[30,25],[30,7]]
    158144poly_all= [[0,L],[0,25],[30,25],[30,L]]
    159145create_mesh_from_regions(poly_all,
    160146                         boundary_tags={'wall': [0,2],'wave': [3], 'buffer':[1]},
    161                          maximum_triangle_area=1,
     147                         maximum_triangle_area=1*res,
    162148                         interior_regions=internal_poly,
    163149                         filename='temp.msh',
     
    180166#print attribute_dic['number'][10]
    181167
    182 def test(x,y):
    183 #    center_x = 12.96
    184 #    center_y = 13.80
    185 #    center_y = 6.80
    186 
    187     list_xy = (center_x-x)**2+(center_y-L-y)**2
     168def circular_island_elevation(x,y):
     169
     170    list_xy_square = (center_x-x)**2+(center_y-L-y)**2
    188171    print 'x',min(x),max(x)
    189172    print 'y',min(y),max(y)
    190     z1=[]
    191     for xy in list_xy:
     173    list_z=[]
     174    for xy in list_xy_square:
    192175        # this finds the int that relates to the correct sqrt in the table
    193176        nn=int(round(xy,2)*100)
    194         zz=-float(attribute_dic['sqrt'][nn])
     177        #the square root is to find the distance from the center to the current xy
     178        distance = float(attribute_dic['sqrt'][nn])
     179#        zz=-float(attribute_dic['sqrt'][nn])
    195180#        print nn,zz
    196 
    197 #    z = -square_root((center_x-x)**2+(center_y-y)**2)
    198         z = zz*.25+0.8975
     181       
     182        # slope of cone is 1/4 and has a radii of 3.6 therefore the cone is 0.9 high.
     183        # So to have the elevation positive 0.90 has been added
     184#        z = zz*.25+0.90
     185        z = -distance*.25+0.90
     186#        z = zz*.25+0.8975
    199187
    200188        if z <0:
     
    203191            z=0.625
    204192#        print 'hello',z
    205         z1.append(z)
    206     return z1
    207 
    208 domain.set_quantity('elevation',test, verbose=True)
     193        list_z.append(z)
     194    return list_z
     195
     196domain.set_quantity('elevation', circular_island_elevation, verbose=True)
    209197
    210198
     
    227215
    228216# Create boundary function from timeseries provided in file
    229 #function = file_function(project.boundary_filename,
    230 #                         domain, verbose=True)
    231 
    232 # Create and assign boundary objects
     217
    233218boundary_filename="ts2cnew1_input"
    234219prepare_timeboundary(boundary_filename+'.txt')
     
    245230Bd = Dirichlet_boundary([water_height,0,0])
    246231domain.set_boundary({'wave': Bts, 'wall': Br, 'buffer':Bd})
    247 domain.starttime = 10
     232#domain.set_time(20.0)
    248233#-------------------------
    249234# Evolve through time
     
    273258          95.0, 100.0, 105.0, 112.5, 135.0, 157.5, 180.0, 202.5, 225.0,
    274259          247.5, 270.0, 292.5, 315.0, 337.5)
    275 #x = 12.96
    276 #y = 13.80
    277 r1 = 1.1
    278 r2 = 3.6
     260r1 = 1.5
     261r2 = 2.6
     262#degrees to check
    279263d=2
    280264
     
    283267for i,angle in enumerate(angles):
    284268    angle = ((angle-180)/180.0)*pi
    285 #    angle = angle1*3.14157
    286269    p1 = get_xy(center_x,center_y,r1,angle-0.01745*d)
    287270    p2 = get_xy(center_x,center_y,r2,angle-0.01745*d)
     
    295278    run_up, location = get_maximum_inundation_data(filename=model_name+'.sww',polygon=poly_segment, verbose=False)
    296279   
    297     print 'maxd %.3f, %.6f, %.6f, %.5s, %.5s '%(((angle/pi)*180)+180, run_up*100, run_up-water_height*100, location[0],location[1])
    298 
    299 
    300 
    301 
    302 
    303 
    304 
     280    print 'maxd %.3f, %.6f, %.6f, %.5s, %.5s '%(((angle/pi)*180)+180, run_up*100, (run_up-water_height)*100, location[0],location[1])
     281
     282
     283
     284
     285
     286
     287
Note: See TracChangeset for help on using the changeset viewer.