-
Notifications
You must be signed in to change notification settings - Fork 0
User_Manual:_Code
(Back to User Manual)
The FLUX distribution consists of a 'C' library that handles the heavy lifting and a Perl/PDL interface layer. The C routines are compiled into a library file, libflux.a
, that is placed in your system's library repository (usually /usr/local/lib
, but this can be specified during installation). The Perl/PDL interface layer dynamically links the library into your running copy of Perl, giving "plugboard" access to the compiled simulation library.
High level functions, such as simulation setup, control, and rendering, are handled via Perl, so FLUX is most easily controlled by Perl scripts that set up each simulation run. Because Perl/PDL includes an interactive shell, you are not restricted to batch mode: you can test and run your simulations interactively. In addition to control subroutines and save/restore methods, the Perl interface gives you access to FLUX's internal data structures. FLUX data structures appear as Perl hashes, so you can access, set, test, adjust, and follow individual fields (including pointers) in the FLUX simulation arena.
3-D graphics I/O is through the PDL::Graphics::Gnuplot package that is available from CPAN; this in turn depends on a system installation of Gnuplot >= version 4.6. PDL::Graphics::Gnuplot, through its dependency Alien::Gnuplot, will attempt to install Gnuplot for you if it is not already present on your system. Within PDL, you can use any available plotting package (PDL::Graphics::Gnuplot, PDL::Graphics::PLPlot and PDL::Graphics::PGPLOT, respectively) to render cuts or plots.
The C library resides in $FLUX/lib/
(if $FLUX
is the location of the unpacked main source distribution). It consists of five files:
- data.c: low-level routines to handle manipulation of the data structures
- geometry.c: a geometry library to handle vector algebra, metrics, and hull finding
- io.c: an I/O package
- physics.c: a collection of force- and field-estimating routines for use in the relaxations
- model.c: the high level entry points for manipulation and relaxation of a fluxon model
There are corresponding header files in $FLUX/include/
, to declare the routines and global variables associated with the C library:
- data.h: Declares the base structure types
- geometry.h: Declares the subroutines for the geometry library
- io.h: Declares the subroutines for the I/O library
- physics.h: Declares the subroutines for the physics handling code
- model.h: Declares the subroutines for model infrastructure
- fluxperl.h: Declares the core structure used for dynamic linking to Perl (see Flux::Core).
FLUX is designed to be controlled from Perl/PDL scripts. PDL is a data manipulation extension to Perl, built on Perl's object-oriented features.
The Perl/PDL interface package resides in $FLUX/pdl/
, and consists of some MakeMaker modules and a PDL subdirectory. It implements a set of Perl objects and methods to manipulate them. The module files have the same name as the object type.
The main data objects in FLUX -- WORLD, FLUXON, VERTEX, and FLUX_CONCENTRATION -- are treated as Perl objects, which can be manipulated with type-specific methods. They are also tied to Perl hashes, so that (for example) a VERTEX object can be treated as a Perl hash ref whose key/value pairs are the elements of the underlying C structure.
Flux.pm (and Flux.xs): Implements Flux, the base class for fluxon simulations, including the glue code required to make FLUX structures behave like Perl hashes.
Core.pm (and Core.xs): Handles dynamic linking of the FLUX C libraries into Perl
World.pm (and World.xs): Implements Flux::World, the WORLD object class.
Fluxon.pm (and Fluxon.xs): Implements Flux::Fluxon, the FLUXON object class.
Vertex.pm (and Vertex.xs): Implements Flux::Vertex, the VERTEX object class.
Concentration.pm (and Concentration.xs): Implements Flux::Concentration, the FLUX_CONCENTRATION object class (albeit a bit sparsely).
Autoload files: Not a module at all, this suite of scripts and subroutine declarations contains high level control functions and useful demonstrations.