granular-channel-hydro

Subglacial hydrology model for sedimentary channels
git clone git://src.adamsgaard.dk/granular-channel-hydro
Log | Files | Refs | README | LICENSE

commit afff4e386f601b61e0e2a0323d80d16b3074fe7b
parent 4516a5f45c72fc1a57aa0d5da689b2225948ebbf
Author: Anders Damsgaard Christensen <adc@geo.au.dk>
Date:   Fri, 13 Jan 2017 22:44:10 -0800

increase entropy in grid

Diffstat:
Mgranular_channel_drainage/model.py | 28++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/granular_channel_drainage/model.py b/granular_channel_drainage/model.py @@ -15,7 +15,8 @@ class model: self.name = name def generateVoronoiDelaunayGrid(self, Lx, Ly, Nx, Ny, - structure='pseudorandom'): + structure='pseudorandom', + distribution='uniform'): ''' Generate a Voronoi Delaunay grid with randomly positioned nodes using Landlab. @@ -35,6 +36,10 @@ class model: grid points, while ``pseudorandom`` (default) will add random noise to a regular grid. :type structure: str + :name distribution: Type of random numeric distribution adding noise to + the pseudorandom structured grid. Accepted values are 'uniform' + (default) or 'normal'. + :type distribution: str ''' self.grid_type = 'VoronoiDelaunay' @@ -50,13 +55,24 @@ class model: #numpy.random.normal(0., noise_amplitude, N) #numpy.random.shuffle(x) #numpy.random.shuffle(y) - xPoints = numpy.linspace(Lx/Nx, Lx - Lx/Nx, Nx) - yPoints = numpy.linspace(Ly/Ny, Ly - Ly/Ny, Ny) + dx = Lx/Nx + dy = Ly/Ny + xPoints = numpy.linspace(dx*.5, Lx - dx*.5, Nx) + yPoints = numpy.linspace(dy*.5, Ly - dy*.5, Ny) gridPoints = numpy.array([[x,y] for y in yPoints for x in xPoints]) - gridPoints[::2, 1] = gridPoints[::2, 1] + Lx/Nx*0.5 + gridPoints[::2, 1] = gridPoints[::2, 1] + dy*0.5 N = len(gridPoints[:, 0]) - x = gridPoints[:, 0] + numpy.random.normal(0, Lx/Nx*0.10, N) - y = gridPoints[:, 1] + numpy.random.normal(0, Ly/Ny*0.10, N) + if distribution == 'normal': + x = gridPoints[:, 0] + numpy.random.normal(0, dx*0.10, N) + y = gridPoints[:, 1] + numpy.random.normal(0, dy*0.10, N) + elif distribution == 'uniform': + x = gridPoints[:, 0] + numpy.random.uniform(-dx*.5, dx*.5, N) + y = gridPoints[:, 1] + numpy.random.uniform(-dy*.5, dy*.5, N) + + else: + raise Exception('generateVoronoiDelaunayGrid: ' + + 'distribution type ' + distribution + + ' not understood.') self.grid = landlab.grid.VoronoiDelaunayGrid(x, y)