Ignore:
Timestamp:
May 22, 2009, 4:40:11 PM (15 years ago)
Author:
rwilson
Message:

Fiddling with layout of user guide.

Location:
anuga_core/documentation/user_manual/demos
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/documentation/user_manual/demos/cairns/ExportResults.py

    r5408 r7064  
    1 import project, os
     1import os
    22import sys
     3import project
    34
    45from anuga.shallow_water.data_manager import sww2dem
     
    78
    89scenario = 'slide'
    9 #scenario = 'fixed_wave'
    1010
    1111name = scenario + sep + scenario + 'source'
     
    1313print 'output dir:', name
    1414which_var = 4
    15 if which_var == 0:  # Stage
     15
     16if which_var == 0:    # Stage
    1617    outname = name + '_stage'
    1718    quantityname = 'stage'
    1819
    19 if which_var == 1:  # Absolute Momentum
     20if which_var == 1:    # Absolute Momentum
    2021    outname = name + '_momentum'
    21     quantityname = '(xmomentum**2 + ymomentum**2)**0.5'  #Absolute momentum
     22    quantityname = '(xmomentum**2 + ymomentum**2)**0.5'    #Absolute momentum
    2223
    23 if which_var == 2:  # Depth
     24if which_var == 2:    # Depth
    2425    outname = name + '_depth'
    2526    quantityname = 'stage-elevation'  #Depth
    2627
    27 if which_var == 3:  # Speed
     28if which_var == 3:    # Speed
    2829    outname = name + '_speed'
    2930    quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-30)'  #Speed
    3031
    31 if which_var == 4:  # Elevation
     32if which_var == 4:    # Elevation
    3233    outname = name + '_elevation'
    3334    quantityname = 'elevation'  #Elevation
     
    3536print 'start sww2dem'
    3637
    37 sww2dem(name, basename_out = outname,
    38             quantity = quantityname,
    39             cellsize = 100,     
    40             easting_min = project.eastingmin,
    41             easting_max = project.eastingmax,
    42             northing_min = project.northingmin,
    43             northing_max = project.northingmax,       
    44             reduction = max,
    45             verbose = True,
    46             format = 'ers')
    47 
     38sww2dem(name,
     39        basename_out=outname,
     40        quantity=quantityname,
     41        cellsize=100,     
     42        easting_min=project.eastingmin,
     43        easting_max=project.eastingmax,
     44        northing_min=project.northingmin,
     45        northing_max=project.northingmax,       
     46        reduction=max,
     47        verbose=True,
     48        format='ers')
  • anuga_core/documentation/user_manual/demos/cairns/GetTimeseries.py

    r4966 r7064  
    77
    88Note, this script will only work if pylab is installed on the platform
    9 
    109"""
    1110
     
    1615sww2csv_gauges('slide'+sep+'slidesource.sww',
    1716                project.gauge_filename,
    18                 quantities = ['stage','speed','depth','elevation'],
     17                quantities=['stage','speed','depth','elevation'],
    1918                verbose=True)
    2019               
    2120sww2csv_gauges('fixed_wave'+sep+'fixed_wavesource.sww',
    2221               project.gauge_filename,
    23                quantities = ['stage', 'speed','depth','elevation'],
     22               quantities=['stage', 'speed','depth','elevation'],
    2423               verbose=True)
    2524
    2625try:
    2726    import pylab
    28     csv2timeseries_graphs(directories_dic={'slide'+sep:['Slide',0, 0],
    29                                            'fixed_wave'+sep:['Fixed Wave',0,0]},
    30                             output_dir='fixed_wave'+sep,
    31                             base_name='gauge_',
    32                             plot_numbers='',
    33                             quantities=['stage','speed','depth'],
    34                             extra_plot_name='',
    35                             assess_all_csv_files=True,                           
    36                             create_latex=False,
    37                             verbose=True)
     27    csv2timeseries_graphs(directories_dic={'slide'+sep: ['Slide',0, 0],
     28                                           'fixed_wave'+sep: ['Fixed Wave',0,0]},
     29                          output_dir='fixed_wave'+sep,
     30                          base_name='gauge_',
     31                          plot_numbers='',
     32                          quantities=['stage','speed','depth'],
     33                          extra_plot_name='',
     34                          assess_all_csv_files=True,                           
     35                          create_latex=False,
     36                          verbose=True)
    3837except ImportError:
    3938    #ANUGA does not rely on pylab to work
    4039    print 'must have pylab installed to generate plots'
    41    
    42 
  • anuga_core/documentation/user_manual/demos/cairns/project.py

    r6889 r7064  
    1 """Common filenames and locations for topographic data, meshes and outputs.
    2 """
     1"""Common filenames and locations for topographic data, meshes and outputs."""
    32
    43from anuga.utilities.polygon import read_polygon, plot_polygons, \
    54                                    polygon_area, is_inside_polygon
    65
    7                                    
    86#------------------------------------------------------------------------------
    97# Define scenario as either slide or fixed_wave.
    108#------------------------------------------------------------------------------
    11 #scenario = 'slide'
    129scenario = 'fixed_wave'
    13                                    
    14                                    
     10#scenario = 'slide'
     11
    1512#------------------------------------------------------------------------------
    1613# Filenames
    1714#------------------------------------------------------------------------------
    18 demname = 'cairns' 
     15demname = 'cairns'
    1916meshname = demname + '.msh'
    2017
    2118# Filename for locations where timeseries are to be produced
    2219gauge_filename = 'gauges.csv'
    23                                  
    24                                    
     20
    2521#------------------------------------------------------------------------------
    2622# Domain definitions
    2723#------------------------------------------------------------------------------
    28 
    2924# bounding polygon for study area
    3025bounding_polygon = read_polygon('extent.csv')
    3126
    32 A = polygon_area(bounding_polygon)/1000000.0
     27A = polygon_area(bounding_polygon) / 1000000.0
    3328print 'Area of bounding polygon = %.2f km^2' % A
    34 
    3529
    3630#------------------------------------------------------------------------------
    3731# Interior region definitions
    3832#------------------------------------------------------------------------------
    39 
    4033# Read interior polygons
    4134poly_cairns = read_polygon('cairns.csv')
     
    4740
    4841# Optionally plot points making up these polygons
    49 #plot_polygons([bounding_polygon,poly_cairns,poly_island0,poly_island1,\
    50 #               poly_island2,poly_island3,poly_shallow],\
    51 #               style='boundingpoly',verbose=False)
    52 
    53 
     42#plot_polygons([bounding_polygon, poly_cairns, poly_island0, poly_island1,
     43#               poly_island2, poly_island3, poly_shallow],
     44#               style='boundingpoly', verbose=False)
    5445
    5546# Define resolutions (max area per triangle) for each polygon
    56 default_res = 10000000 # Background resolution
     47default_res = 10000000    # Background resolution
    5748islands_res = 100000
    5849cairns_res = 100000
     
    6051
    6152# Define list of interior regions with associated resolutions
    62 interior_regions = [[poly_cairns, cairns_res],
     53interior_regions = [[poly_cairns,  cairns_res],
    6354                    [poly_island0, islands_res],
    6455                    [poly_island1, islands_res],
     
    6657                    [poly_island3, islands_res],
    6758                    [poly_shallow, shallow_res]]
    68 
    69 
    7059
    7160#------------------------------------------------------------------------------
     
    8069# Data for landslide
    8170#------------------------------------------------------------------------------
    82 slide_origin = [451871, 8128376] # Assume to be on continental shelf
     71slide_origin = [451871, 8128376]   # Assume to be on continental shelf
    8372slide_depth = 500.
    84 
    85 
    86 
    87 
    88 
  • anuga_core/documentation/user_manual/demos/cairns/runcairns.py

    r6889 r7064  
    1515# Import necessary modules
    1616#------------------------------------------------------------------------------
    17 
    1817# Standard modules
    1918import os
     
    3736import project                 # Definition of file names and polygons
    3837
    39 
    4038#------------------------------------------------------------------------------
    4139# Preparation of topographic data
    4240# Convert ASC 2 DEM 2 PTS using source data and store result in source data
    4341#------------------------------------------------------------------------------
    44 
    4542# Create DEM from asc data
    4643convert_dem_from_ascii2netcdf(project.demname, use_cache=True, verbose=True)
     
    4946dem2pts(project.demname, use_cache=True, verbose=True)
    5047
    51 
    5248#------------------------------------------------------------------------------
    5349# Create the triangular mesh and domain based on
     
    5551# boundary and interior regions as defined in project.py
    5652#------------------------------------------------------------------------------
    57 
    5853domain = create_domain_from_regions(project.bounding_polygon,
    5954                                    boundary_tags={'top': [0],
     
    6762                                    verbose=True)
    6863
    69 
    7064# Print some stats about mesh and domain
    7165print 'Number of triangles = ', len(domain)
     
    7670# Setup parameters of computational domain
    7771#------------------------------------------------------------------------------
    78 
    79 
    8072domain.set_name('cairns_' + project.scenario) # Name of sww file
    8173domain.set_datadir('.')                       # Store sww output here
    8274domain.set_minimum_storable_height(0.01)      # Store only depth > 1cm
    8375
    84 
    8576#------------------------------------------------------------------------------
    8677# Setup initial conditions
    8778#------------------------------------------------------------------------------
    88 
    8979tide = 0.0
    9080domain.set_quantity('stage', tide)
     
    9686                    alpha=0.1)
    9787
    98 
    9988#------------------------------------------------------------------------------
    10089# Setup information for slide scenario (to be applied 1 min into simulation
    10190#------------------------------------------------------------------------------
    102 
    10391if project.scenario == 'slide':
    10492    # Function for submarine slide
     
    113101                                   verbose=True)
    114102
    115 
    116103#------------------------------------------------------------------------------
    117104# Setup boundary conditions
    118105#------------------------------------------------------------------------------
    119 
    120106print 'Available boundary tags', domain.get_boundary_tags()
    121 
    122107
    123108Bd = Dirichlet_boundary([tide,0,0]) # Mean water level
    124109Bs = Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
    125 
    126110
    127111if project.scenario == 'fixed_wave':
     
    129113    Bw = Time_boundary(domain=domain,
    130114                       function=lambda t: [(60<t<3660)*50, 0, 0])
    131                        
    132115    domain.set_boundary({'ocean_east': Bw,
    133116                         'bottom': Bs,
     
    141124                         'onshore': Bd,
    142125                         'top': Bd})
    143    
    144126
    145127#------------------------------------------------------------------------------
    146128# Evolve system through time
    147129#------------------------------------------------------------------------------
    148 
    149130import time
    150131t0 = time.time()
     
    154135
    155136if project.scenario == 'slide':
    156    
    157137    for t in domain.evolve(yieldstep=10, finaltime=60):
    158138        print domain.timestepping_statistics()
     
    171151        print domain.boundary_statistics(tags='ocean_east')   
    172152
    173        
    174153if project.scenario == 'fixed_wave':
    175 
    176154    # Save every two mins leading up to wave approaching land
    177155    for t in domain.evolve(yieldstep=120, finaltime=5000):
  • anuga_core/documentation/user_manual/demos/channel1.py

    r5173 r7064  
    1212from anuga.shallow_water import Dirichlet_boundary
    1313
    14 
    1514#------------------------------------------------------------------------------
    1615# Setup computational domain
     
    2120domain = Domain(points, vertices, boundary)  # Create domain
    2221domain.set_name('channel1')                  # Output name
    23 
    2422
    2523#------------------------------------------------------------------------------
     
    3432                    expression='elevation + 0.0') 
    3533
    36 
    3734#------------------------------------------------------------------------------
    3835# Setup boundary conditions
     
    4340domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
    4441
    45 
    4642#------------------------------------------------------------------------------
    4743# Evolve system through time
    4844#------------------------------------------------------------------------------
    49 for t in domain.evolve(yieldstep = 0.2, finaltime = 40.0):
     45for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    5046    print domain.timestepping_statistics()
    51 
    52 
  • anuga_core/documentation/user_manual/demos/channel2.py

    r6889 r7064  
    1313from anuga.shallow_water import Time_boundary
    1414
    15 
    1615#------------------------------------------------------------------------------
    1716# Setup computational domain
     
    2625domain.set_name('channel2')                 # Output name
    2726
    28 
    2927#------------------------------------------------------------------------------
    3028# Setup initial conditions
     
    3836                    expression='elevation')  # Dry initial condition
    3937
    40 
    4138#------------------------------------------------------------------------------
    4239# Setup boundary conditions
     
    4845domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
    4946
    50 
    5147#------------------------------------------------------------------------------
    5248# Evolve system through time
    5349#------------------------------------------------------------------------------
    54 for t in domain.evolve(yieldstep = 0.2, finaltime = 40.0):
     50for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    5551    print domain.timestepping_statistics()
    5652
     
    5955        print 'Stage > 0: Changing to outflow boundary'
    6056        domain.set_boundary({'right': Bo})
    61 
    62 
    63 
    64 
  • anuga_core/documentation/user_manual/demos/channel3.py

    r6889 r7064  
    1313from anuga.shallow_water import Time_boundary
    1414
    15 
    1615#------------------------------------------------------------------------------
    1716# Setup computational domain
     
    2322points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
    2423                                               len1=length, len2=width)
    25 domain = Domain(points, vertices, boundary)   
     24domain = Domain(points, vertices, boundary)
    2625domain.set_name('channel3')                  # Output name
    2726print domain.statistics()
    28 
    2927
    3028#------------------------------------------------------------------------------
     
    3230#------------------------------------------------------------------------------
    3331def topography(x,y):
    34     """Complex topography defined by a function of vectors x and y
    35     """
    36    
    37     z = -x/10                               
     32    """Complex topography defined by a function of vectors x and y."""
     33
     34    z = -x/10
    3835
    3936    N = len(x)
    4037    for i in range(N):
    41 
    4238        # Step
    4339        if 10 < x[i] < 12:
    44             z[i] += 0.4 - 0.05*y[i]       
    45        
     40            z[i] += 0.4 - 0.05*y[i]
     41
    4642        # Constriction
    4743        if 27 < x[i] < 29 and y[i] > 3:
    48             z[i] += 2       
    49        
     44            z[i] += 2
     45
    5046        # Pole
    5147        if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
     
    5450    return z
    5551
    56 
    57 domain.set_quantity('elevation', topography)  # Use function for elevation
    58 domain.set_quantity('friction', 0.01)         # Constant friction
    59 domain.set_quantity('stage',
    60                     expression='elevation')   # Dry initial condition
    61 
     52domain.set_quantity('elevation', topography)           # elevation is a function
     53domain.set_quantity('friction', 0.01)                  # Constant friction
     54domain.set_quantity('stage', expression='elevation')   # Dry initial condition
    6255
    6356#------------------------------------------------------------------------------
     
    7063domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
    7164
    72 
    7365#------------------------------------------------------------------------------
    7466# Evolve system through time
    7567#------------------------------------------------------------------------------
    76 for t in domain.evolve(yieldstep = 0.1, finaltime = 16.0):
     68for t in domain.evolve(yieldstep=0.1, finaltime=16.0):
    7769    print domain.timestepping_statistics()
    7870
    79 
    8071    if domain.get_quantity('stage').\
    81            get_values(interpolation_points=[[10, 2.5]]) > 0:       
     72           get_values(interpolation_points=[[10, 2.5]]) > 0:
    8273        print 'Stage > 0: Changing to outflow boundary'
    8374        domain.set_boundary({'right': Bo})
  • anuga_core/documentation/user_manual/demos/runup.py

    r6889 r7064  
    55"""
    66
    7 
    87#------------------------------------------------------------------------------
    98# Import necessary modules
    109#------------------------------------------------------------------------------
    11 
    1210from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
    1311from anuga.shallow_water import Domain
     
    2220# Setup computational domain
    2321#------------------------------------------------------------------------------
    24 
    2522points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
    2623
     
    2926domain.set_datadir('.')                     # Use current directory for output
    3027
    31 
    3228#------------------------------------------------------------------------------
    3329# Setup initial conditions
    3430#------------------------------------------------------------------------------
    35 
    3631def topography(x,y):
    37     return -x/2                             # linear bed slope
     32    return -x/2                              # linear bed slope
    3833    #return x*(-(2.0-x)*.5)                  # curved bed slope
    3934
     
    4237domain.set_quantity('stage', -.4)            # Constant negative initial stage
    4338
    44 
    4539#------------------------------------------------------------------------------
    4640# Setup boundary conditions
    4741#------------------------------------------------------------------------------
    48 
    4942Br = Reflective_boundary(domain)      # Solid reflective wall
    5043Bt = Transmissive_boundary(domain)    # Continue all values on boundary
     
    5649domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br})
    5750
    58 
    5951#------------------------------------------------------------------------------
    6052# Evolve system through time
    6153#------------------------------------------------------------------------------
    62 
    6354for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0):
    6455    print domain.timestepping_statistics()
    65    
    66 
    67 
Note: See TracChangeset for help on using the changeset viewer.