Changeset 9035
- Timestamp:
- Dec 4, 2013, 8:56:48 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/utilities/plot_utils.py
r9019 r9035 88 88 p1.time = numpy.append(p1.time, p_tmp.time) 89 89 p1.stage = numpy.append(p1.stage, p_tmp.stage, axis=0) 90 p1.height = numpy.append(p1.height, p_tmp.height, axis=0) 90 91 p1.xmom = numpy.append(p1.xmom, p_tmp.xmom, axis=0) 91 92 p1.ymom = numpy.append(p1.ymom, p_tmp.ymom, axis=0) … … 138 139 def __init__(self, filename, minimum_allowed_height=1.0e-03): 139 140 self.x, self.y, self.time, self.vols, self.stage, \ 140 self. elev, self.xmom, self.ymom, \141 self.height, self.elev, self.xmom, self.ymom, \ 141 142 self.xvel, self.yvel, self.vel, self.minimum_allowed_height = \ 142 143 read_output(filename, minimum_allowed_height) 144 self.filename=filename 143 145 144 146 … … 150 152 # we can then manipulate (e.g. plot, interrogate) 151 153 # 152 # Output: x, y, time, stage, elev, xmom, ymom, xvel, yvel, vel 154 # Output: x, y, time, stage, height, elev, xmom, ymom, xvel, yvel, vel 155 # x,y are only stored at one time 156 # elevation may be stored at one or multiple times 157 # everything else is stored every time step for vertices 153 158 154 159 # Import modules … … 170 175 171 176 elev=fid.variables['elevation'][:] 172 #elev=elev.getValue() 177 178 if(fid.variables.has_key('height')): 179 height=fid.variables['height'][:] 180 else: 181 # Back calculate height if it is not stored 182 height=fid.variables['stage'][:] 183 if(len(stage.shape)==len(elev.shape)): 184 for i in range(stage.shape[0]): 185 height[i,:]=stage[i,:]-elev[i,:] 186 else: 187 for i in range(stage.shape[0]): 188 height[i,:]=stage[i,:]-elev 189 173 190 174 191 xmom=fid.variables['xmomentum'][:] … … 190 207 191 208 for i in range(xmom.shape[0]): 192 xvel[i,:]=xmom[i,:]/( stage[i,:]-elev+1.0e-06)*(stage[i,:]> elev+minimum_allowed_height)193 yvel[i,:]=ymom[i,:]/( stage[i,:]-elev+1.0e-06)*(stage[i,:]> elev+minimum_allowed_height)209 xvel[i,:]=xmom[i,:]/(height[i,:]+1.0e-06)*(height[i,:]>minimum_allowed_height) 210 yvel[i,:]=ymom[i,:]/(height[i,:]+1.0e-06)*(height[i,:]>minimum_allowed_height) 194 211 195 212 vel = (xvel**2+yvel**2)**0.5 196 213 197 return x, y, time, vols, stage, elev, xmom, ymom, xvel, yvel, vel, minimum_allowed_height214 return x, y, time, vols, stage, height, elev, xmom, ymom, xvel, yvel, vel, minimum_allowed_height 198 215 199 216 ############## … … 207 224 p = util.get_output('my_sww.sww', minimum_allowed_height=0.01) # vertex values 208 225 pc=util.get_centroids(p, velocity_extrapolation=True) # centroid values 226 227 NOTE: elevation is only stored once in the output, even if it was stored every timestep 228 This is done because presently centroid elevations do not change over time. 209 229 """ 210 230 def __init__(self,p, velocity_extrapolation=False): 211 231 212 232 self.time, self.x, self.y, self.stage, self.xmom,\ 213 self.ymom, self. elev, self.xvel, \233 self.ymom, self.height, self.elev, self.xvel, \ 214 234 self.yvel, self.vel= \ 215 235 get_centroid_values(p, velocity_extrapolation) … … 246 266 x_cent=(p.x[vols0]+p.x[vols1]+p.x[vols2])/3.0 247 267 y_cent=(p.y[vols0]+p.y[vols1]+p.y[vols2])/3.0 248 249 stage_cent=(p.stage[:,vols0]+p.stage[:,vols1]+p.stage[:,vols2])/3.0250 elev_cent=(p.elev[vols0]+p.elev[vols1]+p.elev[vols2])/3.0251 252 # Here, we need to treat differently the case of momentum extrapolation or253 # velocity extrapolation254 if velocity_extrapolation:255 xvel_cent=(p.xvel[:,vols0]+p.xvel[:,vols1]+p.xvel[:,vols2])/3.0256 yvel_cent=(p.yvel[:,vols0]+p.yvel[:,vols1]+p.yvel[:,vols2])/3.0257 268 258 # Now compute momenta 259 xmom_cent=stage_cent*0.0 260 ymom_cent=stage_cent*0.0 261 262 t=len(p.time) 263 264 for i in range(t): 265 xmom_cent[i,:]=xvel_cent[i,:]*(stage_cent[i,:]-elev_cent+1.0e-06)*\ 266 (stage_cent[i,:]>elev_cent+p.minimum_allowed_height) 267 ymom_cent[i,:]=yvel_cent[i,:]*(stage_cent[i,:]-elev_cent+1.0e-06)*\ 268 (stage_cent[i,:]>elev_cent+p.minimum_allowed_height) 269 269 fid=NetCDFFile(p.filename) 270 if(fid.variables.has_key('stage_c')==False): 271 272 stage_cent=(p.stage[:,vols0]+p.stage[:,vols1]+p.stage[:,vols2])/3.0 273 height_cent=(p.height[:,vols0]+p.height[:,vols1]+p.height[:,vols2])/3.0 274 #elev_cent=(p.elev[:,vols0]+p.elev[:,vols1]+p.elev[:,vols2])/3.0 275 # Only store elevation centroid once (since it doesn't change) 276 if(len(p.elev.shape)==2): 277 elev_cent=(p.elev[0,vols0]+p.elev[0,vols1]+p.elev[0,vols2])/3.0 278 else: 279 elev_cent=(p.elev[vols0]+p.elev[vols1]+p.elev[vols2])/3.0 280 281 # Here, we need to treat differently the case of momentum extrapolation or 282 # velocity extrapolation 283 if velocity_extrapolation: 284 xvel_cent=(p.xvel[:,vols0]+p.xvel[:,vols1]+p.xvel[:,vols2])/3.0 285 yvel_cent=(p.yvel[:,vols0]+p.yvel[:,vols1]+p.yvel[:,vols2])/3.0 286 287 # Now compute momenta 288 xmom_cent=stage_cent*0.0 289 ymom_cent=stage_cent*0.0 290 291 t=len(p.time) 292 293 for i in range(t): 294 xmom_cent[i,:]=xvel_cent[i,:]*(height_cent[i,:]+1e-06)*\ 295 (height_cent[i,:]>p.minimum_allowed_height) 296 ymom_cent[i,:]=yvel_cent[i,:]*(height_cent[i,:]+1e-06)*\ 297 (height_cent[i,:]>p.minimum_allowed_height) 298 else: 299 xmom_cent=(p.xmom[:,vols0]+p.xmom[:,vols1]+p.xmom[:,vols2])/3.0 300 ymom_cent=(p.ymom[:,vols0]+p.ymom[:,vols1]+p.ymom[:,vols2])/3.0 301 302 # Now compute velocities 303 xvel_cent=stage_cent*0.0 304 yvel_cent=stage_cent*0.0 305 306 t=len(p.time) 307 308 for i in range(t): 309 xvel_cent[i,:]=xmom_cent[i,:]/(height_cent[i,:]+1.0e-06)*(height_cent[i,:]>p.minimum_allowed_height) 310 yvel_cent[i,:]=ymom_cent[i,:]/(height_cent[i,:]+1.0e-06)*(height_cent[i,:]>p.minimum_allowed_height) 311 270 312 else: 271 xmom_cent=(p.xmom[:,vols0]+p.xmom[:,vols1]+p.xmom[:,vols2])/3.0 272 ymom_cent=(p.ymom[:,vols0]+p.ymom[:,vols1]+p.ymom[:,vols2])/3.0 273 274 # Now compute velocities 275 xvel_cent=stage_cent*0.0 276 yvel_cent=stage_cent*0.0 277 278 t=len(p.time) 279 280 for i in range(t): 281 xvel_cent[i,:]=xmom_cent[i,:]/(stage_cent[i,:]-elev_cent+1.0e-06)*(stage_cent[i,:]>elev_cent+p.minimum_allowed_height) 282 yvel_cent[i,:]=ymom_cent[i,:]/(stage_cent[i,:]-elev_cent+1.0e-06)*(stage_cent[i,:]>elev_cent+p.minimum_allowed_height) 283 284 285 313 # Get centroid values from file 314 print 'Reading centroids from file' 315 stage_cent=fid.variables['stage_c'][:] 316 height_cent=fid.variables['height_c'][:] 317 elev_cent=fid.variables['elevation_c'][:] 318 if(len(elev_cent.shape)==2): 319 elev_cent=elev_cent[0,:] # Only store elevation centroid once -- since it is constant 320 xmom_cent=fid.variables['xmomentum_c'][:]*(height_cent>p.minimum_allowed_height) 321 ymom_cent=fid.variables['ymomentum_c'][:]*(height_cent>p.minimum_allowed_height) 322 xvel_cent=xmom_cent/(height_cent+1.0e-06) 323 yvel_cent=ymom_cent/(height_cent+1.0e-06) 324 325 286 326 # Compute velocity 287 327 vel_cent=(xvel_cent**2 + yvel_cent**2)**0.5 288 328 289 329 return p.time, x_cent, y_cent, stage_cent, xmom_cent,\ 290 ymom_cent, elev_cent, xvel_cent, yvel_cent, vel_cent 291 292 # Make plot of stage over time. 293 #pylab.close() 294 #pylab.ion() 295 #pylab.plot(time, stage[:,1]) 296 #for i in range(201): 297 # pylab.plot(time,stage[:,i]) 298 299 # Momentum should be 0. 300 #print 'Momentum max/min is', xmom.max() , xmom.min() 301 302 #pylab.gca().set_aspect('equal') 303 #pylab.scatter(x,y,c=elev,edgecolors='none') 304 #pylab.colorbar() 305 # 306 #n=xvel.shape[0]-1 307 #pylab.quiver(x,y,xvel[n,:],yvel[n,:]) 308 #pylab.savefig('Plot1.png') 330 ymom_cent, height_cent, elev_cent, xvel_cent, yvel_cent, vel_cent 331 309 332 310 333 def animate_1D(time, var, x, ylab=' '): #, x=range(var.shape[1]), vmin=var.min(), vmax=var.max()): -
trunk/anuga_core/source/anuga_validation_tests/analytical_exact/deep_wave/run_wave.py
r8776 r9035 98 98 return [amplitude*sin((1./wave_length)*t*2*pi),0.0,0.0] 99 99 100 Bw2 = anuga.shallow_water.boundaries.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, waveform) 100 def waveform2(t): 101 return amplitude*sin((1./wave_length)*t*2*pi) 102 103 Bw2 = anuga.shallow_water.boundaries.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, waveform2) 101 104 #Bw3 = swb2_boundary_conditions.Transmissive_momentum_nudge_stage_boundary(domain, waveform) 102 105 Bw3 = anuga.Time_boundary(domain, waveform) … … 109 112 110 113 # Associate boundary tags with boundary objects 111 domain.set_boundary({'left': Bw 3, 'right': Bt, 'top': Br, 'bottom': Br})114 domain.set_boundary({'left': Bw2, 'right': Bt, 'top': Br, 'bottom': Br}) 112 115 113 116 -
trunk/anuga_core/source/anuga_validation_tests/parameters.py
r8933 r9035 7 7 __date__ ="$20/08/2012 11:20:00 PM$" 8 8 9 alg = ' 1_5'9 alg = 'DE1' 10 10 cfl = 1.0 11 11 -
trunk/anuga_core/source/anuga_validation_tests/saved_parameters.tex
r9001 r9035 1 1 \newcommand{\cfl}{\UScore{1.0}} 2 \newcommand{\alg}{\UScore{ 1_5}}2 \newcommand{\alg}{\UScore{DE1}} 3 3 \newcommand{\majorR}{\UScore{1.3.0-beta}} 4 \newcommand{\minorR}{\UScore{ 8993}}5 \newcommand{\timeR}{{ Sat Sep 28 19:39:452013}}4 \newcommand{\minorR}{\UScore{9003}} 5 \newcommand{\timeR}{{Tue Dec 3 17:21:18 2013}} -
trunk/anuga_work/development/gareth/experimental/bal_and/plot_utils.py
r9022 r9035 79 79 p1.time = numpy.append(p1.time, p_tmp.time) 80 80 p1.stage = numpy.append(p1.stage, p_tmp.stage, axis=0) 81 p1.height = numpy.append(p1. stage, p_tmp.stage, axis=0)81 p1.height = numpy.append(p1.height, p_tmp.height, axis=0) 82 82 p1.xmom = numpy.append(p1.xmom, p_tmp.xmom, axis=0) 83 83 p1.ymom = numpy.append(p1.ymom, p_tmp.ymom, axis=0) … … 143 143 # we can then manipulate (e.g. plot, interrogate) 144 144 # 145 # Output: x, y, time, stage, elev, xmom, ymom, xvel, yvel, vel 145 # Output: x, y, time, stage, height, elev, xmom, ymom, xvel, yvel, vel 146 # x,y are only stored at one time 147 # elevation may be stored at one or multiple times 148 # everything else is stored every time step for vertices 146 149 147 150 # Import modules … … 157 160 158 161 stage=fid.variables['stage'][:] 159 160 height=fid.variables['height'][:] 161 162 162 163 elev=fid.variables['elevation'][:] 164 165 if(fid.variables.has_key('height')): 166 height=fid.variables['height'][:] 167 else: 168 # Back calculate height if it is not stored 169 height=fid.variables['stage'][:] 170 if(len(stage.shape)==len(elev.shape)): 171 for i in range(stage.shape[0]): 172 height[i,:]=stage[i,:]-elev[i,:] 173 else: 174 for i in range(stage.shape[0]): 175 height[i,:]=stage[i,:]-elev 176 163 177 164 178 xmom=fid.variables['xmomentum'][:] … … 192 206 p = util.get_output('my_sww.sww', minimum_allowed_height=0.01) # vertex values 193 207 pc=util.get_centroids(p, velocity_extrapolation=True) # centroid values 208 209 NOTE: elevation is only stored once in the output, even if it was stored every timestep 210 This is done because presently centroid elevations do not change over time. 194 211 """ 195 212 def __init__(self,p, velocity_extrapolation=False): … … 239 256 #elev_cent=(p.elev[:,vols0]+p.elev[:,vols1]+p.elev[:,vols2])/3.0 240 257 # Only store elevation centroid once (since it doesn't change) 241 elev_cent=(p.elev[0,vols0]+p.elev[0,vols1]+p.elev[0,vols2])/3.0 258 if(len(p.elev.shape)==2): 259 elev_cent=(p.elev[0,vols0]+p.elev[0,vols1]+p.elev[0,vols2])/3.0 260 else: 261 elev_cent=(p.elev[vols0]+p.elev[vols1]+p.elev[vols2])/3.0 242 262 243 263 # Here, we need to treat differently the case of momentum extrapolation or … … 278 298 height_cent=fid.variables['height_c'][:] 279 299 elev_cent=fid.variables['elevation_c'][:] 280 elev_cent=elev_cent[0,:] # Only store elevation centroid once -- since it is constant 300 if(len(elev_cent.shape)==2): 301 elev_cent=elev_cent[0,:] # Only store elevation centroid once -- since it is constant 281 302 xmom_cent=fid.variables['xmomentum_c'][:]*(height_cent>p.minimum_allowed_height) 282 303 ymom_cent=fid.variables['ymomentum_c'][:]*(height_cent>p.minimum_allowed_height)
Note: See TracChangeset
for help on using the changeset viewer.