Changeset 6453
- Timestamp:
- Mar 4, 2009, 3:30:29 PM (14 years ago)
- Location:
- anuga_work/development/anuga_1d
- Files:
-
- 19 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anuga_1d/channel_domain.py
r6042 r6453 6 6 consisting of methods specific to the Shallow Water Wave Equation 7 7 8 This particular modification of the Domain class implements the ability to 9 vary the width of the 1D channel that the water flows in. As a result the 10 conserved variables are different than previous implementations and so are the 11 equations. 8 12 9 13 U_t + E_x = S 10 14 11 15 where 12 13 U = [ w, uh]14 E = [ uh, u^2h+ gh^2/2]16 ------------!!!! NOTE THIS NEEDS UPDATING !!!!------------------ 17 U = [A, Q] 18 E = [Q, Q^2/A + gh^2/2] 15 19 S represents source terms forcing the system 16 20 (e.g. gravity, friction, wind stress, ...) … … 32 36 33 37 The conserved quantities are w, uh 34 38 -------------------------------------------------------------------------- 35 39 For details see e.g. 36 40 Christopher Zoppou and Stephen Roberts, … … 39 43 40 44 41 John Jakeman, Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou 42 Geoscience Australia, 2006 45 John Jakeman, Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou, 46 Padarn Wilson, Geoscience Australia, 2008 43 47 """ 44 48 -
anuga_work/development/anuga_1d/dam_padarn.py
r6167 r6453 10 10 11 11 def analytical_sol(C,t): 12 12 if t==0: 13 t=0.0001 13 14 #t = 0.0 # time (s) 14 15 # gravity (m/s^2) … … 90 91 yieldstep = finaltime 91 92 L = 2000.0 # Length of channel (m) 92 number_of_cells = [ 200]93 number_of_cells = [810] 93 94 k = 0 94 widths = [1 ]95 widths = [1,2,5] 95 96 heights= [] 97 velocities = [] 98 96 99 for i in range(len(widths)): 97 100 k=widths[i] … … 118 121 t0 = time.time() 119 122 120 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 123 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 121 124 domain.write_time() 122 125 … … 126 129 C = domain.centroids 127 130 h, uh, u = analytical_sol(C,domain.time) 128 #h_error[k] = 1.0/(N)*sum(abs(h-StageC))129 #uh_error[k] = 1.0/(N)*sum(abs(uh-XmomC))131 h_error = 1.0/(N)*sum(abs(h-HeightC)) 132 u_error = 1.0/(N)*sum(abs(uh-DischargeC)) 130 133 #print "h_error %.10f" %(h_error[k]) 131 134 #print "uh_error %.10f"% (uh_error[k]) … … 134 137 X = domain.vertices 135 138 heights.append(domain.quantities['height'].vertex_values) 136 VelocityQ = domain.quantities['velocity'].vertex_values139 velocities.append( domain.quantities['velocity'].vertex_values) 137 140 #stage = domain.quantities['stage'].vertex_values 138 141 h, uh, u = analytical_sol(X.flat,domain.time) 139 142 x = X.flat 140 143 144 print "Error in height", h_error 145 print "Error in xmom", u_error 141 146 #from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot 142 147 from pylab import * … … 144 149 import matplotlib.axes3d as p3 145 150 print 'test 2' 146 hold(False)151 #hold(False) 147 152 print 'test 3' 148 153 plot1 = subplot(211) 149 154 print 'test 4' 150 plot(x,h ,x,heights[0].flat)155 plot(x,heights[0].flat,x,h) 151 156 print 'test 5' 152 157 plot1.set_ylim([-1,11]) 153 158 xlabel('Position') 154 159 ylabel('Stage') 155 legend(('Analytical Solution', 'Numerical Solution'), 156 'upper right', shadow=True) 160 legend(('Numerical Solution','Analytic Soltuion'), 'upper right', shadow=True) 157 161 plot2 = subplot(212) 158 plot(x,u,x,VelocityQ.flat) 162 163 164 plot(x,velocities[0].flat,x,u) 159 165 plot2.set_ylim([-35,35]) 160 161 166 xlabel('Position') 162 167 ylabel('Velocity') 168 169 print heights[0].flat-heights[1].flat 163 170 164 171 file = "dry_bed_" … … 168 175 show() 169 176 170 171 #print "Error in height", h_error 172 #print "Error in xmom", uh_error 177 -
anuga_work/development/anuga_1d/domain.py
r6042 r6453 916 916 # Update ghosts 917 917 self.update_ghosts() 918 918 919 919 # Initial update of vertex and edge values 920 self.distribute_to_vertices_and_edges() 921 920 self.distribute_to_vertices_and_edges() 921 922 922 # Update extrema if necessary (for reporting) 923 923 self.update_extrema() -
anuga_work/development/anuga_1d/dry_dam_vel.py
r6452 r6453 78 78 for j in range(N+1): 79 79 points[j] = j*cell_len 80 81 boundary = {} 82 boundary[0,0] = 'left' 83 boundary[N-1,1] = 'right' 84 85 domain = Domain(points, boundary = boundary) 86 80 81 domain = Domain(points) 82 87 83 domain.set_quantity('stage', stage) 88 89 Br = Reflective_boundary(domain) 90 domain.set_boundary({'left': Br, 'right': Br}) 84 domain.set_boundary({'exterior': Reflective_boundary(domain)}) 91 85 domain.order = 2 92 86 domain.set_timestepping_method('euler') -
anuga_work/development/anuga_1d/quantity.py
r5858 r6453 135 135 #Use function specific method 136 136 self.set_function_values(X, location) 137 137 138 elif type(X) in [types.FloatType, types.IntType, types.LongType]: 138 139 if location == 'centroids': … … 163 164 164 165 if location == 'centroids': 165 166 166 167 P = self.domain.centroids 167 168 self.set_values(f(P), location) 168 169 else: 169 170 #Vertices 171 170 172 P = self.domain.get_vertices() 171 173 172 174 for i in range(2): 173 self.vertex_values[:,i] = f(P[:,i]) 174 175 176 self.vertex_values[:,i] = f(P[:,i]) 177 175 178 def set_array_values(self, values, location='vertices'): 176 179 """Set values for quantity
Note: See TracChangeset
for help on using the changeset viewer.