Talk Contribution of Python to the LMGC90 platform

Presented by Alexandre Martin in Scientific track 2010 on 2010/07/10 from 10:45 to 11:00 in room Dussane
Many problems of Applied Mechanics or Physics are made of collection of objects in interactions, e.g. frictional contact, cohesion, etc. The shapes as the bulk and interaction behaviors may be complex, coupled with various physics. Moreover, the number of interacting bodies may be very large. Consequently, finding the motion of such a collection of bodies is quite complex. The LMGC90 platform is an academic open-source software designed to solve such problems, used by academics and industrial researchers. The core of this software is written in FORTRAN 90 due to its well known performance in numerical computing applications.

For such research software, which need a high level of flexibility, the design of a user interface raises many issues, some of them due to the FORTRAN language. Python, with its capabilities in scripting, object-oriented programming and other programming language interfacing, arises as an attractive complement. At the beginning we tried an automatic FORTRAN wrapping tool (f2py). However major drawbacks such as proper compiler version detection, management of compiler options, etc led us to find another solution.

After various trials, we developed our own recipe using the ISO C binding features offered by FORTRAN 2003 (implemented in the latest versions of compilers) which enables us wrapping LMGC90 using SWIG. The generated Python module is used to write scripts necessary to run each simulation. A script finely describes all stages of a simulation, moreover it provides new possibilities:
  • we can use all control structures provided by Python which were absent of our initial homemade scripting language (e.g. while loops, etc),
  • we can use features of various Python modules (e.g NumPy, SciPy, etc),
  • LMGC90 arrays can be accessed (through copy/pointer) as NumPy arrays, which offers new capabilities to manage (or couple) simulation.
Therefore LMGC90 platform has been successfully coupled with various scientific software providing a Python interface. For example during the Saladyn project a coupling between LMGC90 and Code_Aster (EdF structural mechanics software) was performed. It allows to model a collection of bodies in interaction, where the bulk behavior is computed using Code_Aster relevant features. Using mpi4py module we were able to develop a parallel (distributed memory) version of LMGC90 without modifying the FORTRAN core.

After these positive results we are using Python to reengineer the pre-processing part of our software, which is dedicated to the definition of our physical models. Previously many specific pieces of software dedicated to different tasks were developed with no possibility of interoperability. We developed a generic Python framework in order to plug these different libraries (wrapped using SWIG) and to add native Python code for new features. This Python module is:
  • easy to use and intuitive, as the physical objects are represented by Python objects,
  • richer, as it mixes old features and new ones,
  • extensible, since Python is powerful.
In the future we plan to use Python to reengineer the post-processing part of our software. Currently the specific computation are done in LMGC90 and the results are displayed with GMV for fields (e.g. velocity, stress, etc …) or Grace for plotting. This design of the post-processor needs to add each new functionality in the LMGC90 core which is neither practical for users nor developer team. An external Python module, embedding IO features of LMGC90, will allow end-users to design their own macros. Moreover it should be possible to use either MayaVi or Paraview to display fields and Matplotlib for plotting.

Authors: Bagneris M., Dubois F., Iceta D., Martin A. and Mozul R.