Changeset 8241
- Timestamp:
- Oct 27, 2011, 8:23:34 PM (14 years ago)
- Location:
- trunk/anuga_work/development/2010-projects/anuga_1d/channel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/2010-projects/anuga_1d/channel/channel_domain.py
r8240 r8241 151 151 def initialize_plotting(self, 152 152 stage_lim = [-1.0, 40.0], 153 height_lim = [-1.0, 10.0],153 width_lim = [-1.0, 10.0], 154 154 velocity_lim = [-5.0, 5.0]): 155 155 … … 159 159 160 160 x = self.get_vertices().flatten() 161 161 162 z = self.quantities['elevation'].vertex_values.flatten() 162 163 w = self.quantities['stage'].vertex_values.flatten() 163 164 h = self.quantities['height'].vertex_values.flatten() 164 165 v = self.quantities['velocity'].vertex_values.flatten() 166 b = self.quantities['width'].vertex_values.flatten() 165 167 166 168 print x.shape 167 169 print z.shape 168 170 171 #------------------------------- 172 # Top plot 173 #------------------------------- 169 174 self.plot1 = pylab.subplot(311) 170 175 … … 173 178 174 179 self.plot1.set_ylim(stage_lim) 175 pylab.xlabel('Position')180 #pylab.xlabel('Position') 176 181 pylab.ylabel('Stage') 177 182 183 #------------------------------- 184 # Middle Plot 185 #------------------------------- 178 186 self.plot2 = pylab.subplot(312) 179 187 180 self.hplot, = pylab.plot(x, h) 181 182 self.plot2.set_ylim(height_lim) 183 pylab.xlabel('Position') 184 pylab.ylabel('Height') 185 188 self.bplot, = pylab.plot(x, b) 189 190 self.plot2.set_ylim(width_lim) 191 #pylab.xlabel('Position') 192 pylab.ylabel('Width') 193 194 #------------------------------- 195 # Bottom Plot 196 #------------------------------- 186 197 self.plot3 = pylab.subplot(313) 187 198 … … 203 214 h = self.quantities['height'].vertex_values.flatten() 204 215 v = self.quantities['velocity'].vertex_values.flatten() 216 b = self.quantities['width'].vertex_values.flatten() 205 217 206 218 207 219 self.zplot.set_ydata(z) 208 220 self.wplot.set_ydata(w) 209 self. hplot.set_ydata(h)221 self.bplot.set_ydata(b) 210 222 self.vplot.set_ydata(v) 211 223 … … 213 225 214 226 215 def hold_plotting(self ):227 def hold_plotting(self,save=None): 216 228 217 229 self.update_plotting() … … 219 231 220 232 pylab.ioff() 233 234 if save != None: 235 file = save+".pdf" 236 pylab.savefig(file) 221 237 222 238 pylab.show() … … 287 303 w_C[:] = h_C + z_C 288 304 289 print w_C305 #print w_C 290 306 291 307 # Extrapolate velocity and stage as well as channel geometry. -
trunk/anuga_work/development/2010-projects/anuga_1d/channel/channel_domain_ext.c
r7884 r8241 624 624 qrm[5] = width_edge_values[ki]; 625 625 626 _flux_function_channel (qlm,qlp,qrm,qrp,g,epsilon,h0,edgeflux,&max_speed);626 _flux_function_channel21(qlm,qlp,qrm,qrp,g,epsilon,h0,edgeflux,&max_speed); 627 627 flux[0] -= edgeflux[0]; 628 628 flux[1] -= edgeflux[1]; -
trunk/anuga_work/development/2010-projects/anuga_1d/channel/var_depth_only.py
r8240 r8241 105 105 WidthC = domain.quantities['width'].centroid_values 106 106 # 107 AreaC[:] = ( 6.0 - BedC)* WidthC107 AreaC[:] = (8.0 - BedC)* WidthC 108 108 109 109 #domain.set_quantity('area', initial_area) … … 124 124 print domain.quantities['width'].vertex_values 125 125 126 #HeightC = domain.quantities['height'].centroid_values127 #DischargeC = domain.quantities['discharge'].centroid_values128 #C = domain.centroids129 #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 + Z135 #136 #137 #from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,savefig138 #import pylab as p139 ##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+=1161 #plot1.clear()162 #plot2.clear()163 126 164 127 domain.distribute_to_vertices_and_edges() … … 170 133 yieldstep = 1.0 171 134 172 173 174 domain.initialize_plotting(stage_lim = [-2.0, 14.0], 175 height_lim = [-2.0, 14.0], 135 domain.initialize_plotting(stage_lim = [-2.0, 12.0], 136 width_lim = [0.0, 2.0], 176 137 velocity_lim = [-10.0, 10.0]) 177 138 … … 181 142 domain.update_plotting() 182 143 183 # HeightC = domain.quantities['height'].centroid_values184 # DischargeC = domain.quantities['discharge'].centroid_values185 # C = domain.centroids186 # 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 + Z192 #193 #194 # from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,savefig195 # import pylab as p196 ##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+=1218 # plot1.clear()219 # plot2.clear()220 144 221 145 print domain.quantities['elevation'].vertex_values 222 146 223 224 domain.hold_plotting() 147 domain.hold_plotting(save="not_well_balanced_random_depth") 225 148 226 149 227 #N = float(N)228 #HeightC = domain.quantities['height'].centroid_values229 #DischargeC = domain.quantities['discharge'].centroid_values230 #C = domain.centroids231 #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 + Z237 #238 #239 #from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot240 #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')258 259 #show()260 -
trunk/anuga_work/development/2010-projects/anuga_1d/channel/var_width_depth.py
r7884 r8241 1 1 import os 2 2 import random 3 from math import sqrt, pow, pi 4 from channel_domain _Abimport *5 from Numeric import allclose, array, zeros, ones, Float, take, sqrt6 from config import g, epsilon3 from math import sqrt, pow, pi 4 from channel_domain import * 5 from numpy import allclose, array, zeros, ones, take, sqrt 6 from anuga_1d.config import g, epsilon 7 7 8 9 random.seed(111) 8 10 9 11 print "Variable Width Only Test" … … 11 13 # Define functions for initial quantities 12 14 def initial_area(x): 13 y = zeros(len(x), Float)15 y = zeros(len(x),'f') 14 16 for i in range(len(x)): 15 17 y[i]=(10-randomarray[i]) … … 20 22 def width(x): 21 23 22 y = zeros(len(x), Float)24 y = zeros(len(x),'f') 23 25 for i in range(len(x)): 24 26 y[i]=randomarray[i] … … 28 30 def bed(x): 29 31 30 y = zeros(len(x), Float)32 y = zeros(len(x),'f') 31 33 for i in range(len(x)): 32 34 y[i]=randomarray2[i] … … 38 40 def stage(x): 39 41 40 y = zeros(len(x), Float)42 y = zeros(len(x),'f') 41 43 for i in range(len(x)): 42 44 if x[i]<200 and x[i]>150: … … 64 66 print "Evaluating domain with %d cells" %N 65 67 cell_len = L/N # Origin = 0.0 66 points = zeros(N+1, Float)68 points = zeros(N+1,'f') 67 69 68 70 # Define the centroid points … … 74 76 75 77 # Define random array for width 76 randomarray=zeros(len(points), Float)78 randomarray=zeros(len(points),'f') 77 79 for j in range(N+1): 78 80 randomarray[j]=random.normalvariate(3,1) 79 randomarray2=zeros(len(points), Float)81 randomarray2=zeros(len(points),'f') 80 82 for j in range(N+1): 81 83 randomarray2[j]=random.normalvariate(3,1) … … 98 100 t0 = time.time() 99 101 100 print domain.quantities['elevation'].vertex_values 102 103 AreaC = domain.quantities['area'].centroid_values 104 BedC = domain.quantities['elevation'].centroid_values 105 WidthC = domain.quantities['width'].centroid_values 106 # 107 AreaC[:] = (10.0 - BedC)* WidthC 108 109 110 #print domain.quantities['elevation'].vertex_values 111 112 finaltime = 100.0 113 yieldstep = 1.0 114 115 domain.initialize_plotting(stage_lim = [-1.0, 20.0], 116 width_lim = [0.0, 6.0], 117 velocity_lim = [-1.0, 1.0]) 118 101 119 102 120 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 103 121 domain.write_time() 104 122 105 print domain.quantities['elevation'].vertex_values 123 domain.update_plotting() 106 124 107 N = float(N) 108 HeightC = domain.quantities['height'].centroid_values 109 DischargeC = domain.quantities['discharge'].centroid_values 110 C = domain.centroids 111 print 'That took %.2f seconds' %(time.time()-t0) 112 X = domain.vertices 113 HeightQ = domain.quantities['height'].vertex_values 114 VelocityQ = domain.quantities['velocity'].vertex_values 115 x = X.flat 116 z = domain.quantities['elevation'].vertex_values.flat 117 b = domain.quantities['width'].vertex_values.flat 118 stage=HeightQ.flat+z 125 #print domain.quantities['elevation'].vertex_values 119 126 127 domain.hold_plotting() 120 128 121 122 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot123 124 #hold(False)125 126 plot1=subplot(211)127 128 plot(x,stage,x,z,x,b)129 130 plot1.set_ylim([-5,15])131 xlabel('Position')132 ylabel('Stage')133 legend(('Solution', 'Bed','Width'),134 'upper right', shadow=True)135 136 plot2=subplot(212)137 plot(x,VelocityQ.flat)138 plot2.set_ylim([-10,10])139 xlabel('Position')140 ylabel('Velocity')141 142 show()143
Note: See TracChangeset
for help on using the changeset viewer.