Up: Program Design

Introduction

slide 01 Good morning, and welcome to the first Software Carpentry lecture on program design. This episode will introduce our sample problem, invasion percolation.
slide 02 Our goal in this lecture is to talk about program design…
slide 03 …by which of course we mean the principles of program design.
slide 04 Unfortunately, principles are very difficult to teach in the abstract…
slide 05 …so instead, we’re going to give you a few examples of program design.
slide 06 And our first is called invasion percolation.
slide 07 Suppose that you’ve got a fractured piece of rock…
slide 08 …and you’re interested in finding out how far pollution will spread through it.
slide 09 One simple way to model this with a computer program is to create a two-dimensional grid of square cells…
slide 10 …and fill those cells with random values.
slide 11 Mark the center cell as being filled with pollutant…
slide 12 …and then look at its four neighbors. The neighbor with the lowest value is the one that has the least resistance to the spread of the pollutant—in our case, the most highly fractured rock.
slide 13 Mark that one as being filled…
slide 14 …and look at the neighbors of the new filled region.
slide 15 Find the one with the lowest value, and repeat the process over and over again.
slide 16 If you have two cells on the boundary that are tied equal for the lowest value, pick one of them at random…
slide 17 …and fill it in.
slide 18 Continue this process until you reach the edge of the grid.
slide 19 The fractal that results from this simulation will tell you about how far and how fast the pollutant would spread through the rock.
slide 20 Of course, if you want to look at the statistical properties of these fractals, you need to do lots of simulation…
slide 21 …on large grids.
slide 22 That means your program has to be fast.
slide 23 So in this lecture we will look at three questions. First, how do we do this at all?
slide 24 Second, how do we tell that it’s correct?
slide 25 And third, how do we make it fast?
slide 26

  1. November 3rd, 2011 at 07:36 | #1

    In this lecture: Nothing.

  1. No trackbacks yet.