Changeset 2429


Ignore:
Timestamp:
Feb 21, 2006, 8:33:21 AM (18 years ago)
Author:
nicholas
Message:

Updated CCS.py with successful implementation of 2nd normal test.

Location:
development/momentum_sink
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • development/momentum_sink/CCS.py

    r2418 r2429  
    1010# from run_friction import fric
    1111from pylab import *
    12    
     12from numerical_tools import norm, corr, err 
    1313
    14 swwfile_B = project.outputdir + sep  + 'Buildings_3662.sww'
     14swwfile_B = project.outputdir + sep  + 'Buildings_3260.sww'
    1515
    1616
    17 gauge_depth = Numeric.arrayrange(0, 2.5*WidtH, 5)
     17gauge_depth = Numeric.arrayrange(0, 1.5*WidtH, 20)
     18print len(gauge_depth),"gauge_depth length"
    1819gauge_breadth = 100
    1920gauge_locations = []
     
    2728quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum']
    2829
    29 
    30 
    3130f_B = file_function(swwfile_B,
    3231                  quantities = quantities,
     
    3433                  verbose = True,
    3534                  use_cache = True)
     35
     36Corr_OK=[]
    3637fric_OK=[]
    37 Friction = [1,2,3,5,7,10,20,30,50]
     38least_norm=[1]
     39norm_OK=[]
     40Friction = Numeric.arrayrange(1,51,1)
    3841for fric in Friction:
    3942    swwfile_F = project.outputdir + sep  + 'friction_n=' + repr(fric) + '_3135.sww'
     
    4851    stages_B = []
    4952    stages_F = []
    50     elevations = []
    51     momenta = []
    52     velocity = []
    5353    for i, GL in enumerate(gauge_depth):
    5454
     
    7070       
    7171       
    72    
    73     diff = abs(Numeric.array(stages_B) - Numeric.array(stages_F))
     72    Ar_B = Numeric.array(stages_B)
     73    Ar_F = Numeric.array(stages_F)
     74    diff = abs(Ar_B - Ar_F)
     75    norm_F = err(Ar_B, Ar_F, 2, relative = True)
     76     
     77    print " "
     78    print norm_F, "norm N_F"
     79    print " "
     80    G = corr(Ar_F, Ar_B)
     81    norm_OK.append(norm_F)
    7482
    75     if max(diff) < 1.2:
    76         print "_-_-_-_-_-_-_-_-_-_-_-_"
    77         print fric, " this file is OK"
    78         print "-_-_-_-_-_-_-_-_-_-_-_-"
    79         fric_OK.append(fric)
    80         #print swwfile_F, "this file OK"
     83    if norm_F < least_norm:
     84        least_norm = norm_F
     85        fric_OK = fric
    8186    else:
    82         print fric, " this file is definelty NOT OK"
    83 print fric_OK, "THESE FRICTION VALUES ARE OK"
     87        print fric, " NOT OK"
    8488
    8589   
     90   
     91print " "
     92print "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
     93print fric_OK, " <- This Manning's n is OK"
     94print "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
     95print least_norm, "2nd normal of Friction vs Buildings  "
     96print "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
    8697
    87 
  • development/momentum_sink/PCS.py

    r2417 r2429  
    1111from pylab import *
    1212
    13 fric = 1   
     13fric = 40   
    1414#swwfile = project.newoutputname + '.sww'
    1515#swwfile = project.outputname
    1616
    1717#swwfile_B = project.outputdir + sep  + 'Buildings_3790.sww'
    18 #swwfile_B = project.outputdir + sep  + 'Buildings_3662.sww'
    19 swwfile_B = project.outputdir + sep  + 'friction_n=10_3135.sww'
    20 swwfile_F = project.outputdir + sep  + 'friction_n=20_3135.sww'
     18swwfile_B = project.outputdir + sep  + 'Buildings_3662.sww'
     19#swwfile_B = project.outputdir + sep  + 'friction_n=10_3135.sww'
     20swwfile_F = project.outputdir + sep  + 'friction_n=40_3135.sww'
    2121
    22 gauge_depth = Numeric.arrayrange(0, 2.5*WidtH, 5)
     22gauge_depth = Numeric.arrayrange(0, 1.5*WidtH, 5)
    2323gauge_breadth = 100
    2424gauge_locations = []
     
    4545
    4646
    47 T = Numeric.arrayrange(0,500,20)
     47T = Numeric.arrayrange(0,1000,20)
    4848#T = [ 20, 50, 100, 150, 200 ]
    4949
  • development/momentum_sink/create_buildings.py

    r2417 r2429  
    88
    99WidtH = 200 # width of boudary in metres
    10 depth = 20 # depth of building side to oncoming wave
    11 breadth = 20 # breadth of building
     10depth = 15 # depth of building side to oncoming wave
     11breadth = 15 # breadth of building
    1212print "building footprint"
    1313print depth * breadth , "m^2"
     
    3737    # inner polygons => building boundaries
    3838   
    39     wh = depth/2
    40    
    41     lh = breadth/2
    42          
     39    whs = depth/2
     40    lhs = breadth/2
     41    #Th = (45 *(3.142/180)) # sets an initial rotation     
     42    Th = 0
    4343    ForDep = (0.2*WidtH) + (BL/2)
    4444    RearDep = 1.2*WidtH
    4545       
    46     Breadths = Numeric.arrayrange( (BL/2), WidtH, (BL))
     46    Breadths = Numeric.arrayrange( -(BL/2), WidtH+(BL/2), (BL))
    4747    print Breadths, "Breadths"
    4848    Depths = Numeric.arrayrange( ForDep, RearDep, BL )
    4949    print Depths, "Depths"
    5050
    51     for D in Depths:
    52         #Breadths = Breadths + BL/2 #Used to offset buildings
     51    for i,D in enumerate(Depths):
     52        Breadths = Breadths + ((-1)**i)*(BL/2) #Used to offset buildings
    5353        for B in Breadths:
    54             polygon = [[D-wh,B-lh],[D+wh,B-lh],[D+wh,B+lh],[D-wh,B+lh]]
     54            wh1 = (-whs) * math.cos(Th) + (-lhs) * math.sin(Th)
     55            lh1 = (-lhs) * math.cos(Th) - (-whs) * math.sin(Th)
     56            wh2 = (+whs) * math.cos(Th) + (-lhs) * math.sin(Th)
     57            lh2 = (-lhs) * math.cos(Th) - (+whs) * math.sin(Th)
     58            wh3 = (+whs) * math.cos(Th) + (+lhs) * math.sin(Th)
     59            lh3 = (+lhs) * math.cos(Th) - (+whs) * math.sin(Th)
     60            wh4 = (-whs) * math.cos(Th) + (+lhs) * math.sin(Th)
     61            lh4 = (+lhs) * math.cos(Th) - (-whs) * math.sin(Th)
     62            polygon = [[D+wh1,B+lh1],[D+wh2,B+lh2],[D+wh3,B+lh3],[D+wh4,B+lh4]]
     63            #polygon = [[D-wh,B-lh],[D+wh,B-lh],[D+wh,B+lh],[D-wh,B+lh]]
    5564            m.add_hole_from_polygon(polygon, tags={'wall':[0,1,2,3]})# Adds holes with reflective boundaries.       
    56        
     65            Th = Th + (37.3 *(3.142/180)) # keeps rotating individual buildings.
    5766
    5867            #print polygon
  • development/momentum_sink/loop_friction.py

    r2417 r2429  
    77# set friction value for zone
    88
    9 # fwojhrt
    109import time
    1110
    1211import project_friction
    13 
     12import Numeric
    1413from pyvolution.pmesh2domain import pmesh_to_domain_instance
    1514from caching import cache
     
    2524from pmesh.mesh import importMeshFromFile
    2625
    27 Friction = [1,2,3,5,7,10,20,30,50]
     26Friction = Numeric.arrayrange(1,50,1)
    2827for fric in Friction:
    2928    meshname = project_friction.meshname
    3029    outputname = project_friction.outputname
    31 
     30    print " "
     31    print "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
     32    print fric, "Manning friction value"
     33    print "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
    3234    t0 = time.time()
    3335
     
    8486    t0 = time.time()
    8587
    86     for t in domain.evolve(yieldstep = 10, finaltime = 500):
     88    for t in domain.evolve(yieldstep = 10, finaltime = 1000):
    8789        domain.write_time()     
    8890
Note: See TracChangeset for help on using the changeset viewer.