- Timestamp:
- Oct 26, 2011, 6:32:44 PM (14 years ago)
- Location:
- trunk/anuga_work/development/2010-projects/anuga_1d/channel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/2010-projects/anuga_1d/channel/channel_domain.py
r8234 r8240 144 144 145 145 def update_derived_quantites(self): 146 146 147 pass 148 149 150 151 def initialize_plotting(self, 152 stage_lim = [-1.0, 40.0], 153 height_lim = [-1.0, 10.0], 154 velocity_lim = [-5.0, 5.0]): 155 156 import pylab 157 pylab.ion() 158 159 160 x = self.get_vertices().flatten() 161 z = self.quantities['elevation'].vertex_values.flatten() 162 w = self.quantities['stage'].vertex_values.flatten() 163 h = self.quantities['height'].vertex_values.flatten() 164 v = self.quantities['velocity'].vertex_values.flatten() 165 166 print x.shape 167 print z.shape 168 169 self.plot1 = pylab.subplot(311) 170 171 self.zplot, = pylab.plot(x, z) 172 self.wplot, = pylab.plot(x, w) 173 174 self.plot1.set_ylim(stage_lim) 175 pylab.xlabel('Position') 176 pylab.ylabel('Stage') 177 178 self.plot2 = pylab.subplot(312) 179 180 self.hplot, = pylab.plot(x, h) 181 182 self.plot2.set_ylim(height_lim) 183 pylab.xlabel('Position') 184 pylab.ylabel('Height') 185 186 self.plot3 = pylab.subplot(313) 187 188 self.vplot, = pylab.plot(x, v) 189 190 self.plot3.set_ylim(velocity_lim) 191 192 pylab.xlabel('Position') 193 pylab.ylabel('Velocity') 194 195 196 def update_plotting(self): 197 198 import pylab 199 200 #x = self.get_vertices().flatten() 201 z = self.quantities['elevation'].vertex_values.flatten() 202 w = self.quantities['stage'].vertex_values.flatten() 203 h = self.quantities['height'].vertex_values.flatten() 204 v = self.quantities['velocity'].vertex_values.flatten() 205 206 207 self.zplot.set_ydata(z) 208 self.wplot.set_ydata(w) 209 self.hplot.set_ydata(h) 210 self.vplot.set_ydata(v) 211 212 pylab.draw() 213 214 215 def hold_plotting(self): 216 217 self.update_plotting() 218 import pylab 219 220 pylab.ioff() 221 222 pylab.show() 223 224 225 226 def finalize_plotting(self): 227 228 pass 229 230 147 231 148 232 #=============== End of Channel Domain =============================== … … 198 282 # (i.e. bed and width) have been accurately computed in the previous 199 283 # timestep. 200 h_C[:] = numpy.where(a_C > 0.0, a_C/ (b_C + h0/b_C), 0.0)201 u_C[:] = numpy.where(a_C > 0.0, d_C/ (a_C + h0/a_C), 0.0)284 h_C[:] = numpy.where(a_C > 0.0, a_C/b_C, 0.0) 285 u_C[:] = numpy.where(a_C > 0.0, d_C/a_C, 0.0) 202 286 203 287 w_C[:] = h_C + z_C -
trunk/anuga_work/development/2010-projects/anuga_1d/channel/var_depth_only.py
r8234 r8240 54 54 import time 55 55 56 # Set final time and yield time for simulation 57 finaltime = 1 58 yieldstep = 0.1 56 59 57 60 58 # Length of channel (m) … … 103 101 104 102 105 #AreaC = domain.quantities['area'].centroid_values106 #BedC = domain.quantities['elevation'].centroid_values107 #WidthC = domain.quantities['width'].centroid_values108 # 109 #AreaC[:] = (6.0 - BedC)* WidthC103 AreaC = domain.quantities['area'].centroid_values 104 BedC = domain.quantities['elevation'].centroid_values 105 WidthC = domain.quantities['width'].centroid_values 106 # 107 AreaC[:] = (6.0 - BedC)* WidthC 110 108 111 109 #domain.set_quantity('area', initial_area) … … 126 124 print domain.quantities['width'].vertex_values 127 125 128 HeightC = domain.quantities['height'].centroid_values 129 DischargeC = domain.quantities['discharge'].centroid_values 130 C = domain.centroids 131 print 'That took %.2f seconds' %(time.time()-t0) 132 X = (domain.vertices).flatten() 133 HeightQ = (domain.quantities['height'].vertex_values).flatten() 134 VelocityQ = (domain.quantities['velocity'].vertex_values).flatten() 135 Z = (domain.quantities['elevation'].vertex_values).flatten() 136 stage=HeightQ + Z 137 138 139 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,savefig 140 import pylab as p 141 #hold(False) 142 143 plot1=subplot(211) 144 145 plot(X,stage,X,Z) 146 147 plot1.set_ylim([-1,11]) 148 xlabel('Position') 149 ylabel('Stage') 150 legend(('Solution', 'Bed Height'), 151 'upper right', shadow=True) 152 153 plot2=subplot(212) 154 155 156 plot(X,VelocityQ) 157 plot2.set_ylim([-5,5]) 158 xlabel('Position') 159 ylabel('Velocity') 160 161 savefig(str(i)+'.png') 162 i+=1 163 plot1.clear() 164 plot2.clear() 165 126 #HeightC = domain.quantities['height'].centroid_values 127 #DischargeC = domain.quantities['discharge'].centroid_values 128 #C = domain.centroids 129 #print 'That took %.2f seconds' %(time.time()-t0) 130 #X = (domain.vertices).flatten() 131 #HeightQ = (domain.quantities['height'].vertex_values).flatten() 132 #VelocityQ = (domain.quantities['velocity'].vertex_values).flatten() 133 #Z = (domain.quantities['elevation'].vertex_values).flatten() 134 #stage=HeightQ + Z 135 # 136 # 137 #from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,savefig 138 #import pylab as p 139 ##hold(False) 140 # 141 #plot1=subplot(211) 142 # 143 #plot(X,stage,X,Z) 144 # 145 #plot1.set_ylim([-1,11]) 146 #xlabel('Position') 147 #ylabel('Stage') 148 #legend(('Solution', 'Bed Height'), 149 # 'upper right', shadow=True) 150 # 151 #plot2=subplot(212) 152 # 153 # 154 #plot(X,VelocityQ) 155 #plot2.set_ylim([-5,5]) 156 #xlabel('Position') 157 #ylabel('Velocity') 158 # 159 #savefig(str(i)+'.png') 160 #i+=1 161 #plot1.clear() 162 #plot2.clear() 163 164 domain.distribute_to_vertices_and_edges() 165 166 167 168 # Set final time and yield time for simulation 169 finaltime = 100.0 170 yieldstep = 1.0 171 172 173 174 domain.initialize_plotting(stage_lim = [-2.0, 14.0], 175 height_lim = [-2.0, 14.0], 176 velocity_lim = [-10.0, 10.0]) 166 177 167 178 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 168 179 domain.write_time() 169 180 170 HeightC = domain.quantities['height'].centroid_values 171 DischargeC = domain.quantities['discharge'].centroid_values 172 C = domain.centroids 173 print 'That took %.2f seconds' %(time.time()-t0) 174 X = (domain.vertices).flatten() 175 HeightQ = (domain.quantities['height'].vertex_values).flatten() 176 VelocityQ = (domain.quantities['velocity'].vertex_values).flatten() 177 Z = (domain.quantities['elevation'].vertex_values).flatten() 178 stage=HeightQ + Z 179 180 181 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,savefig 182 import pylab as p 183 #hold(False) 181 domain.update_plotting() 182 183 # HeightC = domain.quantities['height'].centroid_values 184 # DischargeC = domain.quantities['discharge'].centroid_values 185 # C = domain.centroids 186 # print 'That took %.2f seconds' %(time.time()-t0) 187 # X = (domain.vertices).flatten() 188 # HeightQ = (domain.quantities['height'].vertex_values).flatten() 189 # VelocityQ = (domain.quantities['velocity'].vertex_values).flatten() 190 # Z = (domain.quantities['elevation'].vertex_values).flatten() 191 # stage=HeightQ + Z 192 # 193 # 194 # from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,savefig 195 # import pylab as p 196 ##hold(False) 197 # 198 # plot1=subplot(211) 199 # 200 # plot(X,stage,X,Z) 201 # 202 # plot1.set_ylim([-1,11]) 203 # xlabel('Position') 204 # ylabel('Stage') 205 # legend(('Solution', 'Bed Height'), 206 # 'upper right', shadow=True) 207 # 208 # plot2=subplot(212) 209 # 210 # 211 # plot(X,VelocityQ) 212 # plot2.set_ylim([-5,5]) 213 # xlabel('Position') 214 # ylabel('Velocity') 215 # 216 # savefig(str(i)+'.png') 217 # i+=1 218 # plot1.clear() 219 # plot2.clear() 220 221 print domain.quantities['elevation'].vertex_values 222 223 224 domain.hold_plotting() 225 226 227 #N = float(N) 228 #HeightC = domain.quantities['height'].centroid_values 229 #DischargeC = domain.quantities['discharge'].centroid_values 230 #C = domain.centroids 231 #print 'That took %.2f seconds' %(time.time()-t0) 232 #X = (domain.vertices).flatten() 233 #HeightQ = (domain.quantities['height'].vertex_values).flatten() 234 #VelocityQ = (domain.quantities['velocity'].vertex_values).flatten() 235 #Z = (domain.quantities['elevation'].vertex_values).flatten() 236 #stage=HeightQ + Z 237 # 238 # 239 #from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot 240 # 241 ##hold(False) 242 # 243 #plot1=subplot(211) 244 # 245 #plot(X,stage,X,Z) 246 # 247 #plot1.set_ylim([-1,11]) 248 #xlabel('Position') 249 #ylabel('Stage') 250 #legend(('Solution', 'Bed Height'), 251 # 'upper right', shadow=True) 252 # 253 #plot2=subplot(212) 254 #plot(X,VelocityQ) 255 #plot2.set_ylim([-5,5]) 256 #xlabel('Position') 257 #ylabel('Velocity') 184 258 185 plot1=subplot(211) 186 187 plot(X,stage,X,Z) 188 189 plot1.set_ylim([-1,11]) 190 xlabel('Position') 191 ylabel('Stage') 192 legend(('Solution', 'Bed Height'), 193 'upper right', shadow=True) 194 195 plot2=subplot(212) 196 197 198 plot(X,VelocityQ) 199 plot2.set_ylim([-5,5]) 200 xlabel('Position') 201 ylabel('Velocity') 202 203 savefig(str(i)+'.png') 204 i+=1 205 plot1.clear() 206 plot2.clear() 207 208 print domain.quantities['elevation'].vertex_values 209 210 N = float(N) 211 HeightC = domain.quantities['height'].centroid_values 212 DischargeC = domain.quantities['discharge'].centroid_values 213 C = domain.centroids 214 print 'That took %.2f seconds' %(time.time()-t0) 215 X = (domain.vertices).flatten() 216 HeightQ = (domain.quantities['height'].vertex_values).flatten() 217 VelocityQ = (domain.quantities['velocity'].vertex_values).flatten() 218 Z = (domain.quantities['elevation'].vertex_values).flatten() 219 stage=HeightQ + Z 220 221 222 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot 223 224 #hold(False) 225 226 plot1=subplot(211) 227 228 plot(X,stage,X,Z) 229 230 plot1.set_ylim([-1,11]) 231 xlabel('Position') 232 ylabel('Stage') 233 legend(('Solution', 'Bed Height'), 234 'upper right', shadow=True) 235 236 plot2=subplot(212) 237 plot(X,VelocityQ) 238 plot2.set_ylim([-5,5]) 239 xlabel('Position') 240 ylabel('Velocity') 241 242 show() 243 259 #show() 260
Note: See TracChangeset
for help on using the changeset viewer.