Introduction#
Description#
Neper is a software package for polycrystal generation and meshing. The polycrystals can be 2D or 3D. Neper is built around four modules:
Module -T generates polycrystals as tessellations. The tessellations can be (i) standard tessellations (Voronoi, etc.) or tessellations generated from cell properties (e.g. a size distribution), or (ii) multiscale tessellations, which are characterized by cell subdivision and are able to represent more complex microstructures. All capabilities available for standard tessellations are also available for multiscale tessellations. Tessellations with a very wide variety of cell morphologies can be generated, subject to the constraint that cells must be convex. Once generated, the tessellations can be regularized by removing their smallest features (edges and faces), which then enables good-quality meshing. Periodicity conditions can be prescribed. Crystal orientations are provided for the cells. The output is a tessellation file written in a scalar (vector) format, .tess, or a raster format, .tesr. Scalar tessellations can be meshed by module -M while raster tessellations can typically be used by FFT solvers.
Module -M meshes polycrystals described as tessellation files (.tess and 2D .tesr). Two meshing techniques are available: free (or unstructured) meshing, which generates triangular elements (in 2D) or tetrahedral elements (in 3D) that follow the grain shapes, and mapped (or structured) meshing, which generates regular square elements (in 2D) or regular cubic elements (in 3D) that do not necessarily follow the grain shapes. Free meshing into good-quality elements is ensured by optimized meshing rules, and multimeshing—a complementary use of several meshing algorithms. Remeshing is also available and is similar to meshing except that it takes a mesh as input. Cohesive elements can be inserted at interfaces. The output is a mesh file written in the .msh format, which can readily be used as input by Neper’s companion program, FEPX, or in other formats.
Module -S processes simulation results from FEPX, written as a simulation directory .sim, and includes various post-processing capabilities to compute new results. The simulation directory can be used as such and loaded by module -V for result visualization.
Module -V generates publication-quality PNG images or VTK files of tessellations, meshes and simulation results. The results can be defined from internal data, data loaded from external files, or a simulation directory as generated by module -S. The output PNG images can be highly parameterized, with custom colors and transparency for the different entities, slices, etc. They are generated by ray tracing (using POV-Ray), while the output VTK files can be used for interactive visualization (e.g., using ParaView).
Neper can also be used from Python, using the neper Python package: the modules are run as Python functions, Neper’s files (tessellations, meshes, simulation directories, statistics, etc.) are read into NumPy arrays, NumPy arrays are passed to Neper as data, and the functions of Neper’s orientation library, Orilib, apply to NumPy arrays. This makes it possible to combine Neper with Python’s scientific libraries, e.g. to analyze tessellations, meshes and simulation results, plot them, or carry out parametric studies (see Python Interface).
Neper strives to be an easy-to-use, efficient and robust tool. All the input data are prescribed non-interactively, using command lines and / or ASCII files, so that all treatments can be automated. Neper is multithreaded and operates on all threads by default.
Resources and Support#
Several complementary resources describing Neper are available:
The Neper user documentation (this documentation, see Documentation) describes all of Neper’s capabilities.
The Neper website presents a general introduction to Neper, contains tutorials, and is where Neper can be downloaded from.
The Neper GitHub repository is where the latest, continuous-integration version is available and where user interactions take place:
To get the code, clone the repository using:
$ git clone https://github.com/neperfepx/neper.git
which gives access to the latest stable development release on the default,
mainbranch. To update the code, run git pull from within the repository.To report bugs or request new features, use the issue tracker.
To ask questions or share comments, use the discussion forum.
The four Neper reference papers (see also User Guidelines):
[CMAME2011]R. Quey, P.R. Dawson and F. Barbe, Large-scale 3D random polycrystals for the finite element method: Generation, meshing and remeshing, Comput. Methods Appl. Mech. Engrg., vol. 200, pp. 1729-1745, 2011, describes the regularization and meshing methodologies;
[CMAME2018]R. Quey and L. Renversade, Optimal polyhedral description of 3D polycrystals: Method and application to statistical and synchrotron X-ray diffraction data, Comput. Methods Appl. Mech. Engrg., vol. 330, pp. 308-333, 2018, describes tessellation generation from experimental properties;
[JAC2018]R. Quey, A. Villani and C. Maurice, Nearly uniform sampling of crystal orientations, J. Appl. Crystallogr., vol. 51, pp. 1162-1173, 2018, describes uniform sampling of crystal orientations;
Resources for FEPX can be accessed from https://fepx.info.
Installing Neper#
Neper can be installed using conda, which is the simplest method, or compiled from its source code. See Installation, which also describes the test suite, the Orilib program and the Python interface.
Getting Started#
The neper binary must be run in a terminal, followed by a list of arguments:
$ neper <arguments>
Neper returns messages in the terminal and results in ASCII (optionally binary) files. Neper can also be run from Python (see Using Neper from Python).
The list of arguments describes the problem to solve. There are several general-purpose, self-explanatory arguments:
$ neper --help
$ neper --version
$ neper --license
The following command shows where Neper’s data are read from:
$ neper --data
The remainder of this section explains how to call Neper’s modules, properly format option arguments and set up an initialization file.
Modules#
To call a module, run:
$ neper <module_name> <module_arguments>
where the module name can be -T, -M, -S or -V, and the module arguments can include both required input data and options. Input data (when not a file name) and options start with -. Options can be provided in arbitrary order and are always followed by a single argument.
String completion is available for all options, so they may be abbreviated as long as the abbreviation is not ambiguous. For instance, in module -T, option -regrsel can be abbreviated to -regr. Autocompletion is also available and will complete an option name (or provide possibilities for the option name) when hitting the Tab key. For instance, -regr<tab> completes to -regrsel, and neper -T -n 1 -d shows -domain -dim.
Important
An argument must not contain any spaces.
When an argument contains shell metacharacters (
(,),?,<, etc.), it must be enclosed in either single (') or double (") quotes to be read in properly (only double quotes enable variable substitution by the shell).
Logical options can be enabled or disabled by providing argument values of 1 or 0, respectively. Integer or real arguments can be written as numeral values or Mathematical and Logical Expressions. For instance, in module -M, option -rcl 0.5 can also be written as -rcl 1/2 or -rcl "cos(pi/3)". For some options, different values can be assigned to different entities by loading them from an external Data File (or similar), using file(<file_name>). For the more complex case of a multiscale tessellation, a Multiscale Cell File can also be used, and loaded using msfile(<file_name>).
Module -V shows some exceptions to these rules: the arguments can be listed in arbitrary order only before their corresponding -print call, string completion is not available for custom input options, and option -loop takes several arguments.
Argument Separators#
Some options may take several argument values, which can be combined using separators:
The
,separator is used to combine uncorrelated arguments, i.e. arguments of the same type, which can be processed independently from each other, in any order. This is for example the case of output file formats.The
:separator is used to combine correlated arguments, i.e. arguments of different types, which cannot be processed independently from each other and must be processed in order. This is for example the case of the values of a variable in different directions.The
::separator is used in module -T (and a little in module -M) to assign argument values to the different scales of a multiscale tessellation. It is a super-separator that takes precedence over the,and:standard separators.
Initialization File#
When Neper is run, it starts by reading commands from an initialization file, $HOME/.neperrc, if that file exists. Another initialization file can be specified with option --rcfile, before calling a module:
$ neper --rcfile <my_rc_file> <module_name> <module_arguments>
The reading of an initialization file can be disabled using option --rcfile none.
When a Neper module is called, Neper looks for the occurrence of neper <module_name> in the initialization file and then reads all arguments until the next occurrence of neper (which should denote the beginning of another module option field) or the end of the file. The arguments may be any legal arguments but are typically limited to frequently-used options. Moreover, any field of comments can be preceded by neper comments.
Here is the example of an initialization file, featuring its syntax (parts beginning with ## do not belong to the file):
neper comments ------------------------------------- ## comment
This is my initialization file. ## comment
## comment
It is pretty incomplete though... ## comment
## comment
neper -T -reg 1 ## -T option
neper -M -elttype tet ## -M option
-order 2 ## -M option
## comment
neper comments ## comment
Remember to add what I do not remember! ## comment
neper -V -povray my_povray_path ## -V option
neper comments ------------------------------------- ## comment
If the initialization file is not found, or if neper <module_name> is not found inside it, Neper will consider only the command line arguments. Also, if an argument is initialized several times (for instance, both in the initialization file and at the command line), only the last specified value is used.
Running Conditions#
Neper runs on all threads by default. The actual number of threads to use can be set at run stage, using the OMP_NUM_THREADS environment variable, as in
$ export OMP_NUM_THREADS=8
The environment variable is unset by default.
Using Neper from Python#
Once the Python interface is installed (see Python Interface), the modules can be run from Python, as functions whose arguments are the command-line options, and their results read into NumPy arrays:
import neper
res = neper.T(n=100, id=1, morpho="gg", statcell="vol") # neper -T -n 100 -id 1 -morpho gg -statcell vol
tess = res.read("tess") # the tessellation, as NumPy arrays (tess.seed_coo, etc.)
vol = res.stat("cell")["vol"] # the cell volumes
mesh = neper.M(tess.path).read() # neper -M n100-id1.tess, and the mesh
See Python Interface for a complete description, and Using Neper from Python for an example of a whole workflow, from tessellation generation to the post-processing of simulation results.
Conventions Used in This Documentation#
A command entered at the terminal is shown like this:
$ command
The first character on the line is the terminal prompt, and should not be typed. The dollar sign,
$, is used as the standard prompt in this documentation, although some systems may use a different character.A program (or command) option is printed like
this;An option argument is printed like
<this>;The name of a variable, or a meta-syntactic variable, is printed like
<this>;A series of values is enclosed in curly brackets (
{and}) and separated by,, as in{1,3};A range of integer values or letters is enclosed in curly brackets (
{and}) and separated by-, as in{1-3};Mutually exclusive values are enclosed in curly brackets (
{and}) and separated by|, as in{possibility1|possibility2};Optional arguments are enclosed in square brackets (
[and]);Different possibilities for an integer number, in a variable name, file name, etc. are printed using the
#symbol (e.g., one (or all) of<var1>,<var2>, etc. is printed<var#>);An arbitrary piece of text, composed of zero or more characters, is printed using the
*symbol (as in the shell language);Literal examples are printed like
thisFile names are printed like
this.
Just like the $ sign, the <, >, [, ], {, }, etc. signs are used only for formatting and should not be typed.
Options that are only of secondary importance or for fine tuning are tagged (Secondary option).
Some options, such as -datacellcol, -datafacecol, etc., differ only by the fact that they apply to different entities and are documented together, as -data{cell,...,face,...}col.
Some abbreviations are used consistently for options and contribute to Neper’s jargon:
Abbreviation |
Meaning |
|
algorithm |
|
aspect ratio |
|
characteristic length |
|
color or column |
|
convergence |
|
coordinate |
|
crystal symmetry |
|
coordinate system |
|
equivalent diameter |
|
dimension |
|
directory or direction |
|
distribution or distortion |
|
degree of freedom |
|
duplicate(d) |
|
element set |
|
element |
|
expression |
|
factor |
|
element face set |
|
geometry |
|
identifier |
|
infinity |
|
initial |
|
interpolation |
|
iteration |
|
maximum |
|
minimum |
|
morphology |
|
number |
|
neighbor |
|
node set |
|
optimization |
|
orientation |
|
partition |
|
polyhedron |
|
POV-Ray file |
|
quality |
|
radius |
|
relative characteristic length |
|
resolution |
|
relative maximum |
|
singular |
|
statistics |
|
surface |
|
raster tessellation |
|
scalar tessellation |
|
temporary |
|
transparency |
|
value |
|
variable |
|
vertex |