source: trunk/anuga_work/shallow_water_balanced_steve/run_wave.py @ 8288

Last change on this file since 8288 was 8248, checked in by steve, 12 years ago

commiting at the anuga_core level

File size: 4.3 KB
Line 
1"""Simple water flow example using ANUGA
2
3Will Powers example of a simple sinusoidal wave which showed diffusive effects of
4thefirst order and standard second order method. Problem resolved if "rk2" timestepping
5and higher beta = 2 limiter used. Also new edge limiter with rk2 resolves problem
6"""
7
8#------------------------------------------------------------------------------
9# Import necessary modules
10#------------------------------------------------------------------------------
11
12import sys
13import anuga
14from anuga import Domain
15#from swb_domain import *
16
17from math import cos
18import numpy as num
19from time import localtime, strftime, gmtime
20from os import sep
21
22
23
24#-------------------------------------------------------------------------------
25# Copy scripts to time stamped output directory and capture screen
26# output to file
27#-------------------------------------------------------------------------------
28time = strftime('%Y%m%d_%H%M%S',localtime())
29
30output_dir = '.'
31output_file = 'data_wave_'+time
32
33#copy_code_files(output_dir,__file__)
34#start_screen_catcher(output_dir+sep)
35
36interactive_visualisation = True
37
38#------------------------------------------------------------------------------
39# Setup domain
40#------------------------------------------------------------------------------
41dx = 1000.
42dy = dx
43L = 100000.
44W = 10*dx
45
46# structured mesh
47points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, -W/2))
48
49domain = Domain(points, vertices, boundary) 
50
51domain.set_name(output_file)               
52domain.set_datadir(output_dir) 
53
54#------------------------------------------------------------------------------
55# Setup Algorithm
56#------------------------------------------------------------------------------
57domain.set_timestepping_method('rk2')
58domain.set_default_order(2)
59domain.set_beta(2.0)
60
61print domain.get_timestepping_method()
62
63#domain.use_edge_limiter = True
64#domain.tight_slope_limiters = False
65#domain.use_centroid_velocities = False
66
67
68#------------------------------------------------------------------------------
69# Setup initial conditions
70#------------------------------------------------------------------------------
71domain.set_quantity('elevation',-100.0)
72domain.set_quantity('friction', 0.00)
73domain.set_quantity('stage', 0.0)           
74
75#-----------------------------------------------------------------------------
76# Setup boundary conditions
77#------------------------------------------------------------------------------
78from math import sin, pi, exp
79Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
80Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary
81Bd = anuga.Dirichlet_boundary([1,0.,0.]) # Constant boundary values
82amplitude = 1
83wave_length = 300.0
84Bw = anuga.Time_boundary(domain=domain,     # Time dependent boundary
85## Sine wave
86                  f=lambda t: [(-amplitude*sin((1./wave_length)*t*2*pi)), 0.0, 0.0])
87## Sawtooth?
88#                   f=lambda t: [(-8.0*(sin((1./180.)*t*2*pi))+(1./2.)*sin((2./180.)*t*2*pi)+(1./3.)*sin((3./180.)*t*2*pi)), 0.0, 0.0])
89## Sharp rise, linear fall
90#                   f=lambda t: [(5.0*(-((t-0.)/300.)*(t<300.)-cos((t-300.)*2.*pi*(1./240.))*(t>=300. and t<420.)+(1.-(t-420.)/300.)*(t>=420. and t <720.))), 0.0, 0.0])
91#                   f=lambda t: [amplitude*(1.-2.*(pi*(1./720.)*(t-720.))**2)/exp((pi*(1./720.)*(t-720.))**2) , 0.0, 0.0])
92#                   f=lambda t: [(-8.0*sin((1./720.)*t*2*pi))*((t<720.)-0.5*(t<360.)), 0.0, 0.0])
93
94# Associate boundary tags with boundary objects
95domain.set_boundary({'left': Bw, 'right': Bt, 'top': Br, 'bottom': Br})
96
97
98#===============================================================================
99if interactive_visualisation:
100    from anuga.visualiser import RealtimeVisualiser
101    vis = RealtimeVisualiser(domain)
102    vis.render_quantity_height("stage", zScale =10000, dynamic=True)
103    vis.colour_height_quantity('stage', (1.0, 0.5, 0.5))
104    vis.start()
105#===============================================================================
106
107
108#------------------------------------------------------------------------------
109# Evolve system through time
110#------------------------------------------------------------------------------
111
112for t in domain.evolve(yieldstep = 50.0, finaltime = 60*60.):
113    domain.write_time()
114    if interactive_visualisation:
115        vis.update()
116
117if interactive_visualisation:
118    vis.evolveFinished()
119
Note: See TracBrowser for help on using the repository browser.