source: development/momentum_sink/scripts/loop_buildings.py @ 2938

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

Final organised folders of data

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