Skip to main content

Widening the finite element bounds

'Multiphysics' has unfortunate associations for me; it always sounds like marketing-speak, akin to 'multivitamin' and 'multigrain'. The reality is that it's a highly useful term, describing systems where multiple physical effects interact. For instance, to model convection in a boiler, fluid flow and heat transfer in the liquid are both involved. Analysis of this situation needs the simultaneous solution of coupled partial differential equations - almost certainly futile if you expect a closed-form result. It is, however, amenable to a numerical approach, and this is the staple task of multiphysics finite element packages.

Femlab, by Stockholm-based Comsol, was one of the earliest integrated FEM solvers (i.e. handling all steps of the FEM analysis). Originally launched in 1985 as a PDE Toolbox for Matlab, in 1998 it was succeeded by a 2D Femlab, and in 2001 with a 3D Femlab that first stressed the multiphysics capability. In form, if not in name, these were still Matlab Toolboxes. Femlab 3.0 makes a long-promised leap to stand-alone operation. It's not a complete divorce: Femlab's storage format is still a Matlab structure, so you can drive Femlab direct from the Matlab command line or save a Femlab session as an M-file. However, Matlab ownership is not mandatory.

I looked at the full installation of Femlab 3, which comprises the main package and three optional Modules for Electromagnetics, Structural Mechanics, and Chemical Engineering. Apart from the 500Mb disk space required, the suite isn't especially demanding on hardware. The Windows version needs any post-98 Windows on a Pentium II with 256Mb RAM and OpenGL 1.1 support, the only sticking point being the memory usage for large 3D models. The MacOs and Unix/Linux versions have equivalent requirements.

Whatever the configuration, Femlab works under a Java runtime environment that launches to a Model Navigator window, offering a tree of templates in 1D, 2D, and 3D, with new 1D and 2D Axial Symmetry formats. The bulk of the templates are 'Physics Modes' based on physical applications, with the best solver pre-loaded and the PDE parameters already expressed as appropriate physical units. For example, choosing 2D Heat Transfer/Conduction/Steady-state Analysis loads a template with inbuilt variables such as thermal conductivity, heat capacity, and temperature, with a stationary linear solver ready to run.

Templates and models The main groupings are 'Physics Modes' for acoustics, diffusion, electromagnetics, fluid dynamics, heat transfer, and structural mechanics, along with 'PDE Modes' for trying out classical PDEs and entering models in raw mathematical form ('coefficient', 'general', and 'weak' forms appropriate for particular problem classes). These empty templates are backed up by a 'Model Library', containing fully developed examples for study or modification. If the Specialist Modules are installed, their extra models slot into the tree. The Electromagnetics Module, for instance, contains Quasi-Statics (such as capacitors and inductors), Waves (such as antennae and waveguides), and Multiphysics (such as an EM brake and inductive heating).

Using Femlab is more or less a logical progression across the main toolbar. After loading a suitable template (or templates, for a multiphysics model that couples different PDE systems), you first select 'Options' to input the model's basic constants and expressions. This includes a small but extensible database of presets for engineering material properties and standard cross-sections. The next step is to use the 'Draw' menu, a CAD package which can import DXF files, but is primarily for creating the problem domain, using mouse-drawn primitives. For instance, these include lines, ellipses, and Bezier curves in 2D; and blocks, cones, and cylinders in 3D; with tools for generating 3D from 2D by rotation and extrusion out of the plane. These primitives can be merged or clipped, using Boolean operations, to make complex objects.

This step simultaneously sets up a logical structure, identifying (say) particular faces as boundaries for applying solution conditions in the following 'Physics' menu. Here, you set constants, initial values and properties of each boundary, before proceeding to 'Mesh', which generates the FEM grid. This is mostly automatic, but the mesh can be tweaked manually (for instance, to tighten the resolution in sharp corners where the solution gradient will be high).

With the setup complete, you move to 'Solve'. Femlab includes seven solver types - stationery linear and non-linear, parametric linear and non-linear, time-dependent, eigenvalue, and adaptive. Femlab auto-selects according to problem type, but the solution process can be fine-tuned by expert users (for example, those who really know what difference it might make to use a Hermitian transpose or not). On clicking 'Solve', a progress window opens to show how the solution is converging, and if all goes well, Femlab jumps to 'Postprocessing' mode, which shows the graphical solution. Many are obvious visualisation options: variable(s) to be plotted; graph types such as surface, streamline, and contour; and animations for time-dependent solutions. But 'Postprocessing' also allows computations, such as integrating over a line or region (e.g. total heat flux or volume), and plotting expressions derived from the output data.

As I mention in the box-out, the finite-element method can go badly wrong if the problem is ill conditioned, but Femlab's design and documentation address this problem very helpfully. One aid is the set of benchmark models, such as minimal surfaces, vibrating membranes, and the Black-Scholes equation, where analytical or experimental solutions are known. This gives a chance to play with the Femlab parameters to understand what effect they have on the solution process. Another is the manual's 'Analysis Guide', which discusses in detail how to check convergence and accuracy, how to avoid mesh singularities, what to do about non-linear problems and discontinuous functions, and how to use weak constraints, coupling variables, symmetry and artificial stabilisation.

Comsol's press release for Femlab 3 describes it as the result of 'a complete makeover ... compared to its predecessor, this new product can compute some models as much as 20 times faster while using just 5 per cent as much memory'. Comsol also released independent trials by the Lund Institute of Technology and the Royal Institute of Technology (Stockholm) reporting that Femlab 3, despite its generality, performed as well on structural mechanics and fluid dynamics problems as the big-name specialist packages Ansys and Fluent.

I wasn't able to test it quite as rigorously, but I still have the 500MHz Pentium I used for Femlab 2.0 in 2001, and was able to compare old/new performance on Femlab's benchmark models. Eigenmodes of a drumskin: 5/0.991 seconds. Wave equation in a vibrating membrane: 20/7.6 seconds. A minimal surface soap film: 30/3.1 seconds. Clearly the 20x speed-up is a best case, but these are still significant improvements. Greater speed was also very obvious in the 'Draw' and 'Postprocessing' modes, where rendering has become almost instantaneous, giving very smooth mouse-rotation of plots and switches between plot types.

Other updates are more evolutionary: a large list of algorithmic changes 'under the hood'; additional options and modes for advanced configuration; and many new models in the specialist modules that reflect the latest technology. For instance, the Chemical Engineering Module contains models for a microfluidics device, a 3D MEMS heat exchanger, and electrophoretic transport in a microchannel.

Femlab's documentation is extremely thorough, to the point of multiple redundancy; the text of the 11 softback manuals, totalling more than 2,600 pages, is repeated in Windows Help, HTML and PDF formats. This is backed up by a Support Knowledge Base, publication list, and semi-promotional model demonstrations on the Comsol website. Promotion may be a sore point for Comsol, which slightly shot itself in the foot prior to the Femlab 3 launch by sending out an unsolicited e-mail release that attracted some spam complaints. But, generally, I've been impressed by its approach. Within the UK at least, it's better than many companies in giving genuinely useful seminars, and coming to provincial universities, such as Exeter, to do so.

This friendliness applies to the product too. Despite comprehensive options for configuration (many of them baffling to anyone but FEM experts and mathematicians), it's simple enough for non-programmers to use off the shelf. It brings Femlab to a wider market, while retaining access to Matlab and its add-ons for users committed to that product. With the evident speed improvements too, Femlab 3 comes across as a very well conceived release.


The Finite Element Method

If the finite element method (FEM) keeps recurring as a topic in Scientific Computing World, it reflects its importance as one of the central techniques for physics simulation. It bridges the gap between the late 18th century, when mathematicians such as Lagrange recognised that a variety of physical phenomena were governed by partial differential equations, and our present ability to apply these equations to objects such as engineering components (or even multiphysics problems where linked PDEs operate simultaneously).

The term 'finite element method' dates from around 1960, coined by structural engineer Ray Clough of the University of California, but the generally acknowledged originator of the FEM was the German mathematician Richard Courant. Courant used the technique in 1943 to solve a torsion problem on a cylinder, although he first referred to it in a co-written 1922 book on function theory. Courant in turn drew heavily on the work of Lord Rayleigh, Boris Galerkin, and Walter Ritz.

The main reason driving such an approach was the insolubility of PDEs for all but simple geometries. Much simplifying, the FEM is a transformation to discretise the problem. The region under consideration is divided into a number of geometrical elements, in each of which the continuous field of the PDE variables is modelled by a local polynomial approximation controlled by a few coefficients. Linking these elements by the values at shared nodes results in a set of simultaneous algebraic equations that can be solved numerically by optimisation and matrix algorithms.

Generally, FEM modelling operates in standard stages: modelling of the region geometry; 'meshing' (creating the framework of element nodes); setup of the PDEs and their boundary conditions; solution; and post-processing for viewing. These stages may be done in different packages: for instance, a CAD model of an engineering component might be passed to a meshing program, then passed in turn to a solution and visualisation package.

Although recent years have brought remarkable developments - particularly the capacity to run, on a PC, models that only a decade ago required a workstation - the finite element method isn't a magical answer to all PDE problems. One limitation is that, as a numerical technique, it can never output a closed-form solution. Another is that it can go badly wrong. Lothar Collatz, in The Numerical Treatment of Differential Equations, warns that even for quite simple examples, approximate methods can converge to false solutions 'in a disarmingly innocuous manner'. Equation stiffness, approximation errors, bad meshing, and poor user choice of initial conditions can all make this happen with FEM models. But as long as the results are subject to a 'reality check', the FEM is an outstandingly powerful technique.



Media Partners