development and evaluation of an open source

10 downloads 69595 Views 324KB Size Report
approach in developing a FEM framework using freely available python ... Thus, although ABAQUS, ANSYS are good for finite ... Some tests and functions use.
DEVELOPMENT AND EVALUATION OF AN OPEN SOURCE FINITE ELEMENT ANALYSIS FRAMEWORK Md. Golam Rashed 1* 1

Lecturer, Department of Civil Engineering, Ahsanullah University of Science and Technology, Dhaka-1208, Bangladesh, e-mail: [email protected]

ABSTRACT The use of Finite Element Method (FEM) in engineering simulation has been increasing with the rapid advancement of computing power. Complete control of the simulation process can not be achieved by using proprietary commercial FEM codes as they tend to act like a black box. This problem can be eliminated by using calls to existing compiled libraries from a high level language, preferably a scripting language like python. This paper discusses the benefits can be taken by employing open source software development approach in developing a FEM framework using freely available python libraries and wraping legacy C/C++ or FORTRAN libraries around python. It also discusses the working procedure of the developed framework and its evaluation as an answer to the black box dilemma. Keywords: Finite Element Method, Numerical Modeling, Engineering Simulation, Scientific Computing, Python. 1. INTRODUCTION The finite element analysis is a computer-based numerical technique that is widely used to solve engineering problems. Major applications for FEA include static, dynamic and thermal characterizations of mechanical phenomenon occuring in nature. Advances in computer hardware have made FEA easier and very efficient into solving complex engineering problems on desktop computers (Abaqus/CAE, 2011). In spite of the great power of FEA, the disadvantages of computer solutions must be kept in mind when using this method. They do not necessarily reveal how the stresses are influenced by important problem variables such as materials properties and geometrical features, and errors in input data can produce wildly incorrect results that may be overlooked by the analyst. Perhaps the most important function of theoretical modeling is that of sharpening the user’s intuition, users of finite element codes should plan their strategy toward this end by supplementing the computer simulation with as much closed-form and experimental analysis as possible (Roylance, 2001). Moreover, To avoid input errors and increase the simulation reliability, the user must have the access to the source code level. 2. PRACTICES IN ENGINEERING SIMULATION Basically, there are three possible approaches by which finite element analysis is performed for an engineering phenomena. Firstly, one can use a propritery finite element analysis software package, such as ABAQUS (Abaqus/CAE, 2011), ANSYS (ANSYS - Simulation Driven Product Development, 2011) or even general purpose prototyping framework MATLAB (MATLAB - The Language Of Technical Computing, 2011). The main advantage of these FEA software packages is that they come with both pre and post-prossesor equiped. The operation of a specific software is usually detailed in the documentation accompanying the software, and vendors of the more expensive codes will often offer workshops or training sessions as well to help users learn the intricacies of code operation. One problem users may have even after this training is that the code tends to be a "black box" whose inner workings are not understood by the end user. Thus, although ABAQUS, ANSYS are good for finite element analysis, they are not suitable for full-blown research projects, where complete control is the top most priority. Furthermore, they have fixed keywords, are not open source, very expensive and not wildly accepted in academia. Secondly, one could develop their own FEA program, in a high-level language. However, one should realize that, Most of the high level language is scripting type, so the concern for speed is great if the whole program is coded in that language alone. FEA involves solution of large matrices which require high computing power as well as efficient algorithm. In many cases, pre-written library routines offer solutions to numerical problems which are pretty hard to improve upon. Thirdly, coding can be done in a high-level language like python (Python Programming Language – Official Website, 2011), but using calls to pre-written, pre-compiled routines in commonly available subroutine libraries, such as UMFPACK (UMFPACK: unsymmetric multifrontal sparse LU factorization package, 2011), LAPACK (LAPACK - Linear Algebra PACKage, 2011) and BLAS (BLAS, 2011), to perform all of the real numerical

work. This approach is most beneficial for the coding easiness and the performance point of view. This approach is used by the majority of researchers & scientists in their modern FEA simulation program. So, it is evident that the use of open source FEA software is beneficial for both the user and research, and it will further enhance the simulation reliability if it is a self coded one. 3. OPEN SOURCE FINITE ELEMENT ANALYSIS FRAMEWORK To overcome all the difficulties and errors associated with commercial FEA packages, an open source FEA framework named "simple finite element in python" or "Sfepy" has been developed. SfePy is a finite element analysis software written almost entirely in Python (Millman, 2011), with exception of the most time demanding routines, those are written in C and wrapped by Cython or written directly in Cython (SfePy, 2011). SfePy is a software for solving systems of coupled partial differential equations by the finite element method in 2D and 3D. Solution of linear, nonlinear problems are possible in sfepy. The collection of modules sfepy carries are FE engine, problem description facilities, interfaces to various solvers, post-processing utilities. It can be viewed both as black-box PDE solver, and as a Python package which can be used for building custom applications. As a black box PDE solver, After preparing a problem description file in Python Sfepy will solve it where no real programming is involved. For Installation Sfepy prerequisites are recent NumPy (van der Walt, 2011), SciPy with Umfpack wrapper, Cython (SciPy, 2011) (Cython: C-Extensions for Python, 2011). Sfepy depends on matplotlib, pyparsing, Umfpack, pytables for smooth running. Some tests and functions use sympy. For post-processing, mayavi2 is required (Ramachandran, 2011). All these libraries are available as single package from Pythonxy (pythonxy - Scientific-oriented Python Distribution based on Qt and Spyder Google Project Hosting, 2011) and Enthought python distribution (Enthought Python Distribution :: Products :: Enthought, Inc., 2011). The typical working mechanism of Sfepy is described below. 1. A top-level script, usually simple.py reads in an input file. Following the contents of the input file, a ProblemDefinition instance is created; this is the input file coming to life. The problem sets up its domain, regions, fields, the equations and the solvers. The equations determine the materials and variables in use, only those are fully instantiated, so the input file can safely contain definitions of items that are not used actually. 2. Prior to solution, problem.time_update() function has to be called to setup boundary conditions, material parameters and other potentially time-dependent data. This holds also for stationary problems with a single “time step”. 3. The solution is then obtained by calling problem.solve() function. 4. Finally, the solution can be stored using problem.save_state() 5. Step 2, 3 & 4 are essentially repeated for each time step. So using the code a black-box PDE solver, shields the user from having to create the ProblemDefinition instance by hand. 3.1

Open Source vs. Closed Source

Optimum simulation depends on complete control over the finite element analysis framework but commercial products failed do so as they are proprietary, closed source. So a user is unable to see what is going on behind the scene during the simulation. Developing a finite element analysis framework, or at least using an open source finite element analysis software will help the end user by achieving complete control over the simulation process. Open source software is community driven, so large number of users can contribute to the continuing development of the software. And the uses of freely available modules ensure least cost in both usability and maintenance. 3.2

Development

The finite element method is comprised of three major phases: (1) Pre-processing, in which the analyst develops a finite element mesh to divide the subject geometry into subdomains for mathematical analysis, and applies material properties and boundary conditions, (2) Solution, during which the program derives the governing matrix equations from the model and solves for the primary quantities, and (3) Post-processing, in which the analyst checks the validity of the solution, examines the values of primary quantities such as displacements and stresses, and derives and examines additional quantities such as specialized stresses and error indicators. 3.2.1

Pre-processing

The goals of pre-processing are to develop an appropriate finite element mesh, assign suitable material properties, and apply boundary conditions in the form of restraints and loads. The finite element mesh subdivides the geometry into elements, upon which are found nodes. The model's degrees of freedom are assigned at the nodes. The assignment of nodal dof also depends on the class of analysis. For a thermal analysis,

2

only one temperature dof exists at each node. Developing the mesh is usually the most time-consuming task in FEA. In the past, node locations were keyed in manually to approximate the geometry. The more modern approach is to develop the mesh directly on the CAD geometry, which will be (1) wireframe, with points and curves representing edges, (2) surfaced, with surfaces defining boundaries, or (3) solid, defining where the material is. Solid geometry is preferred, but often a surfacing package can create a complex blend that a solids package will not handle. As far as geometric detail, an underlying rule of FEA is to "model what is there", and yet simplifying assumptions simply must be applied to avoid huge models. A badly distorted element will cause a matrix singularity, killing the solution. A less distorted element may solve, but can deliver very poor answers. Acceptable levels of distortion are dependent upon the solver being used. Material properties required vary with the type of solution. A linear statics analysis, will require an elastic modulus, Poisson's ratio and perhaps a density for each material. Thermal properties are required for a thermal analysis. Examples of restraints are declaring a nodal translation or temperature. Loads include forces, pressures and heat flux. Gmsh provides a reliable pre-processing solution and is the pre-processor of the developed FEA framework (Gmsh, 2011). The simplest way of using SfePy is to mesh the geometry using Gmsh and then solve a system of PDEs describing the physical problem in python programming language defined in a problem description file, also referred to as input file. In such a file, the problem is described using several keywords that allow one to define the equations, variables, finite element approximations, solvers, solution domain and subdomains etc. The syntax of the problem description file is very simple yet powerful, as the file itself is just a regular Python module that can be normally imported, no special parsing is necessary (Comparing Python to Other Languages, 1997). The keywords are regular Python variables, usually of the dict type with special names. The different components of problem description file are shown in Table 1. Table 1: Structure of Problem description file Sl No. 1 2

Keyword Finite Element Mesh Regions

3 4 5 6

Fields Integrals Variables Boundary Conditions

7 8

Initial conditions Materials

9

Equations

10

Solvers

11

Functions

12

Miscellaneous

Description FE meshes defines domain geometry. Four types of geometry elements are supported (Figure 1). Regions serve to select a certain part of the computational domain. It is the selection of nodes and elements of a FE mesh. They are used to define the boundary conditions, the domains of terms and materials etc. Fields correspond to Finite Element spaces. Define the integral type and quadrature rule. This keyword is optional. Variables use the Finite Element approximation given by the specified field. The boundary conditions apply in a given region given by its name, and, optionally, in selected times. The times can be given either using a list of tuples (t0, t1) making the condition active for t0

Suggest Documents