Changeset 3223
- Timestamp:
- Jun 24, 2006, 4:34:26 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentation/user_manual/examples/runuptest.py
r3197 r3223 17 17 from pyvolution.shallow_water import Transmissive_boundary 18 18 19 N = 10000.020 19 waveheight = 1.0 21 20 #------------------------------------------------------------------------------ … … 23 22 #------------------------------------------------------------------------------ 24 23 25 polygon = [[N,N],[-N,N],[-N,-N],[N,-N]] 26 #polygon = [[N,N],[0,N],[0,0],[N,0]] 24 west = 340000. 25 east = 380000. 26 south = 6265000. 27 north = 6250000. 28 polygon = [[east,north],[west,north],[west,south],[east,south]] 27 29 meshname = 'test.msh' 28 #interior_regions = 30 29 31 create_mesh_from_regions(polygon, 30 32 boundary_tags={'top': [0], … … 37 39 38 40 domain = Domain(meshname,use_cache=True,verbose = True) 39 domain.set_name(' bedslope') # Output to bedslope.sww41 domain.set_name('test') # Output to test.sww 40 42 domain.set_datadir('.') # Use current directory for output 41 43 domain.set_quantities_to_be_stored(['stage',# Store all conserved quantities … … 49 51 50 52 def topography(x,y): 51 return -x/2 # linear bed slope 52 #return x*(-(2.0-x)*.5) # curved bed slope 53 slope = -1./400. 54 c = 850.0 55 return slope*x+c # linear bed slope 53 56 54 57 domain.set_quantity('elevation', topography) # Use function for elevation 55 domain.set_quantity('friction', 0.1) # Constant friction 56 #domain.set_quantity('stage', -.4) # Constant negative initial stage 57 domain.set_quantity('stage', -N/2) # Constant negative initial stage 58 domain.set_quantity('friction', 0. ) # Constant friction 59 domain.set_quantity('stage', 0.0) # Constant initial stage 58 60 59 61 #------------------------------------------------------------------------------ … … 64 66 Br = Reflective_boundary(domain) # Solid reflective wall 65 67 Bt = Transmissive_boundary(domain) # Continue all values on boundary 66 Bd = Dirichlet_boundary([ -N/2.,0.,0.])# Constant boundary values68 Bd = Dirichlet_boundary([0.,0.,0.]) # Constant boundary values 67 69 Bw = Time_boundary(domain=domain, # Time dependent boundary 68 f=lambda t: [((1 <t<2)*waveheight), 0.0, 0.0])70 f=lambda t: [((10<t<20)*waveheight), 0.0, 0.0]) 69 71 70 72 # Associate boundary tags with boundary objects … … 77 79 78 80 stagestep = [] 79 filename = 'runupheight%.2f.csv' %waveheight80 fid = open(filename, 'w')81 81 for t in domain.evolve(yieldstep = 10, finaltime = 100.0): 82 82 domain.write_time() 83 thisstagestep = domain.get_quantity('stage')84 stagestep.append(max(max(thisstagestep.get_values())))85 83 86 s = '%.2f, %.2f\n' %(waveheight, max(stagestep)) 84 # Gauge line 85 def gauge_line(west,east,north,south): 86 from Numeric import arange 87 gaugex = arange(west,east,1000.) 88 gauges = [] 89 for x in gaugex: 90 y = (north+south)/2. 91 gauges.append([x,y]) 92 return gauges 93 94 #----------------------------------------------------------------------------- 95 # Interrogate solution 96 #----------------------------------------------------------------------------- 97 98 gauges = gauge_line(west,east,north,south) 99 100 f = file_function(gauges) 101 minw = 10000.0 102 theminw = minw 103 minws = [] 104 for k, g in enumerate(gauges): 105 for i, t in enumerate(f.get_time()): 106 if w < minw: minw = w 107 minws.append(minw) 108 if theminw < minw: 109 theminw = minw 110 gaugeloc = k 111 112 filename = 'maxrunup'+waveheight+'.csv' 113 fid = open(filename,'w') 114 s = 'Waveheight,Runup distance,Runup height\n' 87 115 fid.write(s) 116 gaugestar = gauges[gaugeloc] 117 s = '%.2f, %.2f/n' %(waveheight,gaugestar[0],gaugestar[1]) 118 fid.write(s) 119 120 from pylab import plot, xlabel, ylabel, title 121 plot(gaugex,minws,'g-',gaugestar[0],gaugestar[1],'r*') 122 xlabel('x') 123 ylabel('stage') 124 title('Minimum stage for gauge line')
Note: See TracChangeset
for help on using the changeset viewer.