source: development/momentum_sink/loop_friction.py @ 2891

Last change on this file since 2891 was 2466, checked in by nicholas, 19 years ago

Full set of friction values run through CCS.py for various building layouts. Report started for produced reports in Experiment 1.doc

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