source: development/momentum_sink/loop_buildings.py @ 2465

Last change on this file since 2465 was 2458, checked in by nicholas, 19 years ago

CCS.py modified to loop through building scenarios and write results to file.

File size: 2.5 KB
Line 
1
2#Convention for strings representing files
3# #_file has the extention
4#           #name does not have the extension
5
6import time
7from pyvolution.pmesh2domain import pmesh_to_domain_instance
8from caching import cache
9from pyvolution.shallow_water import Domain, Reflective_boundary,\
10File_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary
11from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA
12import project
13from create_buildings import create_mesh
14from pmesh.mesh import importMeshFromFile
15import Numeric
16
17
18
19#from building_generator import create_mesh
20
21
22
23DR = [3,5,7,9,11,13,15,17]
24for depth in DR:
25   
26    meshname = project.meshname
27    outputname = project.outputname
28    t0 = time.time()
29    meshname, triagle_count = cache(create_mesh,(1000,depth),
30                                    {'mesh_file':meshname,
31                                     'triangles_in_name':True}
32                                    ,dependencies = ['create_buildings.py']
33                                    #,evaluate = True     
34                                    )
35   
36    print 'Initialising the mesh took %.2f seconds' %(time.time()-t0) 
37
38    #Setup domain
39    domain = cache(pmesh_to_domain_instance, (meshname, Domain),
40                   dependencies = [meshname]                   
41                   ,verbose = False
42                   )               
43
44
45    domain.set_name(project.basename + '_Orth(45)_D=%d_%d' %(depth, triagle_count))
46    domain.set_datadir(project.outputdir)
47    domain.store = True
48    domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum']
49
50    print 'Number of triangles = ', len(domain)
51    print 'The extent is ', domain.get_extent()
52    print 'current building depth = ', depth
53
54    #Setup Initial Conditions
55    domain.set_quantity('friction', 0.01)
56    domain.set_quantity('stage', 0)
57
58    #Setup Boundary Conditions
59    print domain.get_boundary_tags()
60
61    domain.starttime = 0  #Obtained from MOST
62
63    Br = Reflective_boundary(domain)
64    Bt = Transmissive_boundary(domain)
65    Bdw = Dirichlet_boundary([20,0,0])
66    Bdb = Dirichlet_boundary([0,0,0])
67    Bw = Time_boundary(domain=domain,
68                       f=lambda t: [(60<t<660)*4, 0, 0])
69
70    domain.set_boundary( {'wall': Br,'wave': Bdw, 'back': Bdb, 'exterior':Bdw} ) 
71
72    #Evolve
73    t0 = time.time()
74
75    for t in domain.evolve(yieldstep = 10, finaltime = 1000):
76        domain.write_time()     
77
78    print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.