source: development/momentum_sink/scripts/loop_friction.py @ 3112

Last change on this file since 3112 was 3112, checked in by nicholas, 18 years ago

Submission of 2nd draft friction report

File size: 3.4 KB
Line 
1""" File used for looping 'friction block.py' script to create many
2    friction scenarios with variations in Manning's n """
3
4#Convention for strings representing files
5# #_file has the extention
6#           #name does not have the extension
7
8
9import time
10import string
11import project_friction
12import Numeric
13from pyvolution.pmesh2domain import pmesh_to_domain_instance
14from caching import cache
15from pyvolution.shallow_water import Domain, Reflective_boundary,\
16     File_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary
17from region import Set_region
18from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA
19from friction_block import create_mesh
20from pmesh.mesh import importMeshFromFile
21
22# generation of friction value list
23Friction_large = list(Numeric.arange(1,120,1))
24Friction = list(Numeric.arange(0.025,1,0.025))
25Friction_log = list([200, 500, 1000, 2000, 5000, 10000])
26Friction.extend(Friction_large)
27Friction.extend(Friction_log)
28print Friction
29
30raw_input('check friction array >>')
31
32for fric in Friction:
33    meshname = project_friction.meshname
34    outputname = project_friction.outputname
35    print " "
36    print "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
37    print fric, "Manning friction value"
38    print "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
39    t0 = time.time()
40    #meshname, triagle_count =create_mesh(100,mesh_file=meshname,triangles_in_name=True)
41    meshname, triagle_count = cache(create_mesh,(100),
42                                    {'mesh_file':meshname,
43                                     'triangles_in_name':True}
44                                    ,dependencies = ['friction_block.py']
45                                    #,evaluate = True     
46                                    )
47    #meshname = 'build.tsh'
48    #outputname = outputname[:-4] + '_' + str(triagle_count) + outputname[-4:]
49    print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) 
50    #meshname = importMeshFromFile('build.tsh')
51    #Setup domain
52    domain = cache(pmesh_to_domain_instance, (meshname, Domain),
53                   dependencies = [meshname]                   
54                   ,verbose = False
55                   )               
56
57    #fr=str(fric).strip('.')
58    domain.set_name(project_friction.basename + '%s_%d' %(str(fric).strip('.'), triagle_count))
59    domain.set_datadir(project_friction.outputdir)
60    domain.store = True
61    domain.quantities_to_be_stored = ['stage','xmomentum','ymomentum']
62
63    print 'Number of triangles = ', len(domain)
64    print 'The extent is ', domain.get_extent()
65
66    #Setup Initial Conditions
67    domain.set_quantity('friction', 0.01)
68    domain.set_quantity('stage', 0)
69    domain.set_region(Set_region('mound', 'friction', fric)) #, location='unique vertices'))
70    #Setup Boundary Conditions
71    print domain.get_boundary_tags()
72
73    domain.starttime = 0  #Obtained from MOST
74
75    Br = Reflective_boundary(domain)
76    Bt = Transmissive_boundary(domain)
77    Bdw = Dirichlet_boundary([10,0,0])
78    Bdb = Dirichlet_boundary([0,0,0])
79    Bw = Time_boundary(domain=domain,
80                       f=lambda t: [(60<t<660)*4, 0, 0])
81
82    domain.set_boundary( {'wall': Br,'wave': Bdw, 'back': Bdb, 'exterior':Bdw} ) 
83
84    #Evolve
85    t0 = time.time()
86
87    for t in domain.evolve(yieldstep = 10, finaltime = 1000):
88        domain.write_time()     
89
90    print 'That took %.2f seconds' %(time.time()-t0)
91
Note: See TracBrowser for help on using the repository browser.