Granular media

Overview

The scripts on this page are intended as a starting point to allow users to create their own granular-like meshes for use with Nmag. Although both scripts should be fully functional as they are, it is likely they will need amending for each particular case. There are two different programs, both written in Python, one which creates an array of ellipsoids using Netgen and the other creates a Voronoi-cell type arrangement of grains. Both programs have very similar input syntaxes.

Ellipsoid Builder

This program creates an array of meshed ellipsoids using Netgen. The program has many variables which can be selected from the command line; the full list of which can be found by running EllipsoidBuilder.py --help or reading the source code.

Download

Download here
This Dropbox page has the EllipsoidBuilder.py script, combined with a sample output which was used to make the image below for reference.

Prerequisites

Output

Once successfully run, the program outputs a selection of files as follows (assuming the chosen filename was Ellipsoids):
  • Ellipsoids.py - skeleton Python Nmag script with the material and meshes defined (needs actual simulation code to be written manually, e.g. to define a hysteresis loop etc.)
  • Ellipsoids.geo - geometry file read by Netgen
  • Ellipsoids.neutral - 'neutral' file which is the mesh output from Netgen
  • Ellipsoids.nmesh.h5 - the mesh file once interpreted and compressed using nmeshimport

A meshed output can be seen in the image below.

This was created using the default values in the script with 5 rows and 10 columns. Note that the script introduces randomness in the ellipsoid orientation by default.

Known Issues

On some installations, calling netgen will not start Netgen. The reference to Netgen at the bottom of the script may have to be changed to /opt/netgen/bin/netgen or a symbolic link or similar created.

Voronoi Builder

This program creates and array of extruded Voronoi cells using Gmsh which can be used to simulate a granular medium in Nmag. The program has many variables which can be selected from the command line; the full list of which can be found by running VoronoiBuilder.py --help or reading the source code. Unlike the Ellipsoid Builder script, this program does not automatically mesh the geometry. Instead, the .geo file must be opened in Gmsh and meshed manually.

Download

Download here
This Dropbox page has the VoronoiBuilder.py script, combined with a sample output which was used to make the images below for reference.

Prerequisites

Output

Once successfully run, the program outputs a selection of files as follows (assuming the chosen filename was Voronoi):
  • Voronoi.py - skeleton Python Nmag script with the material and meshes defined (needs actual simulation code to be written manually, e.g. to define a hysteresis loop etc.)
  • Voronoi.geo - geometry file read by Gmsh

A meshed output can be seen in the images below.

This was created using the default values in the script with 5 rows and 10 columns. Note that the script introduces randomness in the cell boundary position by default.

Also available in: HTML TXT