Software for dunefield simulator

Back to main page

Downloads

Source code:

DunefieldModel_express2015.zip

To compile, download and unzip the above source files into a folder, then with free-to-install Microsoft 'Visual Studio Community 2019' on your system, click the 'sln' file. It can also be compiled and run using 'Visual Studio Express 2015 for Desktop'.

Executable:If you'd like to try the executable without compiling, you could try DunefieldModel.exe (right-click and save to your computer). It'll probably run on most up-to-date Win10 systems.

If there are problems, please let me know (bottom of this page).

Using the simulator

Fig 1. User interface of the simulator

Select a model from the drop-down list 'Model'. Select a 'Neighbourhood' method. Set the desired dunefield dimensions, which will be adjusted to be powers of 2. 'Length' refers to the dimension parallel to the wind (horizontal on the screen). A width of 1 cell is acceptable. The larger the dunefield, the slower the model executes. Select an initialization method (usually 'random' or 'uniform') and a sand height (usually 1 to 3 will generate barchans, 10 or more will generate transverse ridges). Important: After selecting or changing parameters, press 'Initialize' to make your choices effective. Then press 'Run' (or Tick). The 'Run' button will change to 'Stop' when the simulator is running.

Snapshots of the model can be recorded to disk using the controls at the bottom of the simulator window. Using QuickTime Pro is one way to assemble the snapshots into frames of a video.

Scale for the dunefield and for the cross-sectional profile can be controlled by entering values in the appropriate scale control box. 'Auto' causes the scale to automatically bracket whatever values are present at the next refresh.

The cross-sectional profile is taken from the dunefield at the position of the grey triangle left of the field; drag it to obtain a profile at a different location. Shading indicates positions within a shadow.

The dunefield normally displays elevation, but click on items in the 'Show' box to see other attributes.

Click on the dunefield to bring up a 'magnified view' of the dunefield (essentially a debug tool). Click or click-drag elsewhere in the dunefield to move the focus of the magnifier (if you click-drag, it will update as the mouse moves). Figure 2 shows a magnified view of a sand pile after a few ticks. Each cell contains the cell coordinates [width, length], the sand elevation, the shadow height, and the hop distance. If the cell is in a 'wind shadow', a grey circle with white border appears in the lower-right corner.

Fig 2. Example of the magnifier window; sand pile with Von Neumann neighbourhood

The 'sand pile/pit' model will generate a sand pile at the center of the dunefield if the initial sand height is zero, or a pit at the center if the initial sand height is greater than zero. The pile/pit is created by adding/subtracting one grain per tick from the center cell, and by moving one tick at a time, using the magnifier to watch, one can see (and check) the effect of avalanching, neighbourhood, and shadow calculations.

The 'Recycle' checkbox controls whether sand that blows or avalanches off the right end of the dunefield ought to be wrapped to the left side ('recycled'), ie., whether the field has periodic streamwise boundaries or not.

The current dunefield elevations can be saved to a file by pressing the 'Save' button, which brings up a file save dialog. A saved elevations can be loaded by selecting the 'File' choice (set the dunefield dimensions first, prior to intializing from the file). The file is human-readable; it can be opened with a text editor. Thus you could create a file yourself to load custom initial elevations.

Code structure

The source file is Visual C#, which is like Java and can be compiled using the free compiler from Microsoft (google for "visual C# express"). The source code works with the Visual Studio C# 2015 or 2019 editions (it was developed with the 2008 edition and then updated to work with later editions).

The code isn't extensively commented; it wasn't developed with the idea of public use. If there is value to anyone in improving it, or adding features, please let me know (via the link at the bottom of this page), I may be able to help.

The simulator can run many models, selected from a drop-down list, such as "Werner (1995)", "Momiji (2000)", etc. Each model can be run with one of several methods of finding steep slopes than need to be avalanched, such as "Moore, deterministic" or "Von Neumann, stochastic".

The models are implemented by the class 'Model.cs', which has virtual methods that can be overridden to implement various models and variants. For example, 'Werner1995.cs' provides overrides that implement Werner (1995).

As is standard for C# Windows Forms applications, the class Form1.cs contains the top-level controls. Within Form1.cs, the method 'init' sets up the simulator for a simulation according to settings of the user interface. A FindSlope object is created that implements the nearest-neighbour algorithm desired by the user, and then that is passed to the constructor for a Model object, which will be the simulator for that particular user request. Form1.run invokes the model's Tick method to have it run its model for one tick, and the user interface is updated after a user-specified number of ticks.

The dunefield array is owned by the model for efficiency, which slightly inconveniences some of the user interface display code.

The core of the simulator is Model.cs and its overrides (eg., werner1995.cs), and FindSlope.cs. The rest are user interface and controls. So adding a new model is easy -- just copy an existing model class (eg., Werner1995.cs), rename it, make changes, and add to the 'case' statements in Form1.Form1_Load and Form1.init (a bit clumsy; using attributes and reflection would have been classier). Experimenting with existing models is even easier -- just edit the model's code.

The Visual C# Express compiler is large but easy to download and install. C# is easy to read and modify if you know C or Java.

Comments or questions

You can reach me at: Comments

Jim Elder
2009 Nov; updated in 2011, 2015, 2019

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.5 Canada License.

Change log

2020-04: 'Save' and load from file ('File' button) changed. Instead of a binary file, it now uses a more human-friendly format.

2015: Thank you to Marissa Dattler for prompting fixes for compatibility with the 2015 compiler.