You are on page 1of 28

Computing (2013) 95 (Suppl 1):S381–S408

DOI 10.1007/s00607-013-0294-4
Numerical solution of coupled problems using
code Agros2D
Pavel Karban · František Mach · Pavel K

us ·
David Pánek · Ivo Doležel
Received: 5 November 2012 / Accepted: 9 January 2013 / Published online: 26 January 2013
© Springer-Verlag Wien 2013
Abstract New code Agros2D for 2D numerical solution of coupled problems is
presented. This code is based on the fully adaptive higher-order finite element method
and works with library Hermes2Dcontaining the most advanced numerical algorithms
for the numerical processing of systems of second-order partial differential equations.
It is characterized by several quite unique features such as work with hanging nodes of
any level, multimesh technology (every physical field can be calculated on a different
mesh generally varying in time) and a possibility of combining triangular, quadrilateral
and curved elements. The power of the code is illustrated by three typical coupled
problems.
Keywords Higher-order finite element method · Coupled problems ·
Monolithic solution · hp-adaptivity · Hanging nodes
Mathematics Subject Classification 65M60 · 68N01
P. Karban (B) · F. Mach · P. K

us · D. Pánek · I. Doležel
Department of Theory of Electrical Engineering,
University of West Bohemia, Pilsen, Czech Republic
e-mail: karban@kte.zcu.cz
F. Mach
e-mail: fmach@kte.zcu.cz
P. K

us
e-mail: pkus@kte.zcu.cz
D. Pánek
e-mail: panek50@kte.zcu.cz
I. Doležel
e-mail: idolezel@kte.zcu.cz
1 3
S382 P. Karban et al.
1 Introduction
Numerous physical phenomena are characterized by an interaction of several physical
fields, influencing mutually one another. From a wide spectrum we can mention, for
example, thermal and force effects of electromagnetic fields, changes in solid and
liquid structures subject to varying temperature or pressure, or behavior of plasma in
different external conditions. Let us illustrate this category of phenomena by a typical
technical example–induction heating of a steel cylinder (a heat-treatment technology
widely used in many industrial applications) in an inductor carrying time variable,
mostly periodic current, see Fig. 1.
The current passing through the inductor produces in its vicinity time-variable
magnetic field that generates induced currents in the cylinder. These currents (whose
density J
i
(t ) lag by almost 180

behind the field current density J(t )) produce in
it the Joule losses that are transformed into heat. The temperature of the cylinder
starts growing. We can say that the primary harmonic magnetic field in the inductor
produces the secondary temperature field in the heated billet. On the other hand, it is
well known that the physical properties of heated materials vary with their temperature.
This also holds for electrical conductivity and magnetic permeability of steel that start
decreasing. Thus, the secondary temperature field in the billet affects the primary
magnetic field in the inductor. It is obvious that both physical fields influence one
another.
When analyzing the process in more details, we can add, moreover, that heating
of the cylinder slightly influences its geometrical dimension that increase. This effect
is in practice not important and in most cases can be neglected, but strictly speaking,
the above geometrical variations also slightly affect both magnetic and temperature
fields.
Modeling of such multiphysics (called also coupled) phenomena is still a very chal-
lenging business. Their continuous mathematical models consist of systems of often
nonlinear and nonstationary partial differential equations describing the distributions
of relevant physical fields, that are often supplemented with a set of ordinary differ-
ential equations describing behavior of present circuits (electric, magnetic, thermal,
mechanical, hydraulic, pneumatic, etc.). The coefficients of all these equations are
mostly complicated functions of physical parameters of present materials and media
that, however, depend on the state variables such as temperature or pressure.
Fig. 1 Induction heating of a cylindrical billet in an inductor
1 3
Numerical solution of coupled problems using code Agros2D S383
The most difficult task is numerical processing of these continuous models that
should be acceptably fast, robust, and that should provide sufficiently accurate results.
The accuracy of results, however, does not depend only on the quality of the used algo-
rithms, but also on the accuracy of the input data and prescribed initial and boundary
conditions.
Nowadays, there exist several packages of ever developing codes that allowprocess-
ing such coupled problems, mostly in technical domains. They can be split into two
groups – commercial professional codes developed by software companies and used
both in industry and academy, and open source codes developed and used mostly in
the academic sphere. The industrial commercial codes (ANSYS [1], Flux [2], Opera
[15], Infolytica [8] and others) are mostly based on lower-order finite element meth-
ods, work with elements of the first and second orders and miss advanced adaptive
techniques. On the other hand, they may be considered user-friendly (they contain
very well elaborated preprocessors and postprocessors). A more powerful code in this
group is COMSOL Multiphysics [3] whose latest versions work with elements up to
the fifth order and a standard is h-adaptivity implemented in it.
The development of codes with advanced adaptive methods is intensively conducted
mostly in the open-source academia groups (such as FEniCS[25], deal.ii [5], Sundance
[26], FreeFem++ [6] and GetFEM++ [7]). But even when they often contain strong
algorithms and procedures, their user friendliness is rather low and some of them are
yet not suitable for solving complicated technical problems. Nevertheless, even in this
domain the progress is fast. Our group has been developing for years software Agros2D
[24] based on the library Hermes2D [36]. And the aim of this paper is to show the
structure of the code, its features, feasibilities and several illustrative examples solved
by this software.
2 Specific features of our codes
Unlike the mentioned professional codes, Agros2D and Hermes2D exhibit quite
unique features. We can mention the full hp-adaptivity, support of hanging nodes of
any level, multimesh technology (every physical field can be calculated on a different
mesh generally varying in time) and a possibility of combining triangular, quadrilateral
and curved elements. Details are provided in the following subsections.
2.1 Implemented adaptivity techniques
Generally, the algorithms of adaptivity start to be applied at the moment when some
local error of solution is higher than the acceptable tolerance. Consider an equation
L f = 0 , (1)
where L denotes a differential operator and f a function whose distribution over some
domain Ω is to be found. If f

is its approximation obtained by the numerical solution
of (1), the absolute and percentage relative errors δ and ε are defined by the relations
1 3
S384 P. Karban et al.
δ = f − f

η = 100

δ
f

. (2)
Not only the above errors can be used for evaluating the quality of the results. Errors
can also be estimated by means of norms. Hermes2D works with three of them:
– Basic energetic norm that is defined by the formula
e =


δ(Lδ) dΩ

1
2
. (3)
– L
2
norm defined by the relation
e
L
2 =


δ
2
dΩ

1
2
. (4)
– H
1
norm defined by the relation
e
H
1 =

δ
2
+grad δ · grad δ

dΩ

1
2
. (5)
Unfortunately, the exact solution f is usually known only in very simple, analyti-
cally solvable cases. Moreover, there exists no general method that would provide a
good estimation of the error for an arbitrary PDE (although for several classes of linear
PDEs we can find it). Moreover, in the case of the hp adaptivity the traditional error
estimate (one number per element) is not enough; we must know its distribution over
the whole element. In principle, it might be possible to obtain this information from
the estimates of local higher derivatives, but this approach is not very practical. That
is why we work [35] with the reference solution f
ref
instead, that is obtained either
by a refinement of the whole mesh (h-adaptivity), by enlargement of the polynomial
degree (p-adaptivity) or by both above techniques (hp-adaptivity). In this manner we
get the candidates for adaptivity even without knowledge of the exact solution f . The
library Hermes2D works with very sophisticated and subtle tools based on the above
considerations.
Before the adaptivity loop is applied, the code must initialize the refinement selector
that determines what kind of adaptivity is to be applied. The selector performs the
following steps:
– Selection of the candidates for refinement, computation of their local errors, which
is realized by projecting the reference solution on their FE spaces.
– Computation of the number of the degrees of freedom for every candidate.
– Evaluation of the score for each candidate and sorting the candidates according to
their values.
1 3
Numerical solution of coupled problems using code Agros2D S385
– Selection of the candidate with the highest score.
As mentioned before, the adaptivity algorithm in Hermes needs an actual mesh
solutionandanother solutionrealizedongloballyrefinedmesh(the reference solution).
These solutions are subtracted in each adaptivity step in order to obtain an error
estimate (as a function of the position). This function is used to decide which elements
need to be refined and in which way. Hence, the adaptivity loop begins with the global
refinement of the mesh and calculation of the reference solution.
If the error is higher than a given threshold, the adaptation process is started. The
calculated local error in the candidate is first evaluated with respect to the way of
adaptivity that should be used. Its weight is selected in the following way:
– w = 2 for the h-adaptivity,
– w = 1 for the p-adaptivity,
– w =

2 for the hp-adaptivity.
The score s of a candidate is given by the formula
s =
log
10
ε
ε
0
(d −d
0
)
α
, (6)
where ε is the estimated error in the candidate, d denotes its number of DOFs, ε
0
and
d
0
are selected parameters and α stands for the convergence exponent.
The particular kinds of adaptivity are realized in the following manner:
– h-adaptivity—while the original large finite element is split to several smaller ele-
ments, the degree of the polynomials replacing the real distribution of the inves-
tigated quantity in them remains the same. This is clear from Fig. 2 left, where
both large element and smaller elements are described by polynomials of the same
order.
– p-adaptivity—the shapes of elements in the region do not change, but we increase
the orders of the polynomial approximating the distribution of the investigated
quantity. The situation is depicted in Fig. 3 right.
– hp-adaptivity—combination of both above ways [32]. This way belongs to the
most flexible and powerful techniques characterized by an extremely fast (expo-
nential) convergence of results. Atypical possibility of its application is depicted in
Fig. 3.
2.2 Multimesh technology
Each physical field involved in the coupled task can be solved on quite a different
mesh that best corresponds to its particulars. For example, electromagnetic-thermal
problems are characterized by the influence of electromagnetic and temperature fields.
While the domains in which electromagnetic fields are calculated, are discretized with
respect to their behavior (a very fine discretization in the subdomains with currents
induced by the skin or proximity effect), temperature fields are usually smooth and
the corresponding mesh can consist of larger elements. Special powerful higher-order
1 3
S386 P. Karban et al.
techniques of mapping are then used to avoid any numerical errors in the process
of assembly of the stiffness matrix. All meshes can, moreover, change in time, in
accordance with the real evolution of the corresponding physical quantities. Their
application will be shown in the section with examples.
2.3 Hanging nodes
Hermes2Dsupports hanging nodes of any level [33]. Usually, the hanging nodes bring
about a considerable increase of the number of the degrees of freedom (DOFs). The
code contains higher-order algorithms for respecting these nodes without any need of
an additional refinement of the external parts neighboring with the refined subdomain.
2.4 Types of elements
Agros2D generates meshes that may generally consist of triangular, quadrilateral and
curvilinear elements. While creation of common triangular and quadrilateral elements
is well known and will not be discussed here, we will show creation of the curvilinear
elements suitable for covering areas adjacent to curved boundaries and interfaces (this
technique is original and we do not know any commercial software that would use
something like that).
Agros2Ddiscretizes 2Ddomains on the base of software Triangle [30] that provides
a high-quality triangular mesh. The corresponding input data for modeling curvilinear
boundaries or interfaces in Triangle are given by a series of points lying on this line
(together with the markers carrying information that these points belong to such a
line) while the output is represented by a set of triangular elements (see Fig. 4). In the
Fig. 2 Part of a discretization mesh after h-adaptive (left) and p-adaptive (right) process: light lines before
adaptivity, dark lines after adaptivity, the darker colour of the element, the higher polynomial
Fig. 3 Part of a discretization
mesh after hp-adaptive process:
the darker colour of the element,
the higher polynomial, some
elements are, moreover, split
1 3
Numerical solution of coupled problems using code Agros2D S387
Fig. 4 Input data for SW Triangle (left) and output mesh (right)
Fig. 5 Projection of a newly generated node on the curve (left) and resultant s elements formed in Agros2D
(right)
second step Agros2D repeats analyzing the curved lines and when any of the newly
generated nodes approximating the curve (see Fig. 4, right part) does not lie on it, it
is automatically projected on the original arc, see Fig. 5. At the same time a special
procedure determines the corresponding angles of projection.
In the course of numerical processing of the task the curvilinear elements are
mapped back on normal triangles where all remaining operations (such as Gaussian
numerical integration) are carried out and only in the final step (postprocessing) they
are mapped again to the curvilinear elements.
3 Main features of Agros2D
Agros2D (see Fig. 6) is a powerful code for numerical solutions of 2D coupled prob-
lems in technical disciplines. Its principal part is a user interface serving for com-
plete preprocessing and postprocessing of the tasks (it contains sophisticated tools for
building geometrical models and input of data, generators of meshes, tables of weak
forms for the partial differential equations and tools for evaluating results and drawing
graphs and maps). The processor is based on the library Hermes2Dcontaining the most
advanced numerical algorithms for monolithic and fully adaptive solution of systems
of generally nonlinear and nonstationary partial differential equations (PDEs) based on
the finite element method of higher order of accuracy. Both parts of the code are written
in C++. They are freely distributed under the GNU General Public License v2.1.
The development of the application Agros2Dwas started in 2009 at the Department
of Theory of Electrical Engineering at the University of West Bohemia in Pilsen.
It has been successfully used for research and teaching at several universities and
1 3
S388 P. Karban et al.
Fig. 6 Main window of Agros2D
scientific institutions. Moreover, it has been used by several companies for modeling
and development of various technical devices.
3.1 XML description of modules
The main ambition of Agros2D is to be universal tool for solution of various types of
partial differential equation. The core of the program is thus written generally, with no
dependence on properties of individual physical fields. All field-related data are stored
in separate XML files. This system makes it simple to create new modules, since the
code does not need to be changed, only a new XML file has to be created.
XML files describing modules and couplings can be converted into C++ code.
Agros2D uses several tools for transforming. For reading XML files, library Xerces-
C++ [16] is used. After reading, the data are processed by our own lexical and syntactic
analyzer. The lexical analyzer creates the vector of tokens, which are, after basic
syntactic check, replaced using required grammar. All the necessary files are then
generated using ctemplate library [4]. The source files are prepared for usage as Qt
plugins. Therefore, it is possible to change modules and couplings and compile them
during run-time.
A XML describing physical field consists of following parts. After the initial part
describing the field properties and considered types of analyses, follows the defini-
tion of volumetric weak forms (different for linear and nonlinear case and for planar
and antisymmetric coordinate system). In the next part, surface properties, especially
boundary condition types, are defined. Information from those two parts are used for
creation of weak forms and discretization of the problem. The following parts are
used to generate the graphical user interface (GUI). Material quantities are described
(to be filled in by the user) and formulas for postprocessor quantities and surface and
volume integrals are given. Note that in the sample file shown in the appendix, most
1 3
Numerical solution of coupled problems using code Agros2D S389
of the quantities are omitted to save space. By creating such file, a new physical field
together with GUI can be completely created with no changes in the code itself.
3.2 Physical fields
At the present moment, Agros2D is capable of solution of the following fields:
– electric currents,
– electrostatics,
– magnetic fields,
– heat transfer,
– structural mechanics
– radio frequency,
– acoustics,
– incompressible flow,
– mathematics (Laplace, Poisson, Helmholtz, diffusion, convection-diffusion, wave
equation).
The above fields may be solved in different modes (steady-states, transients, harmonic
fields) where appropriate. Nonlinear material properties may also be respected during
the solution process.
3.3 Coupled problems
For the solution of complex problems, interaction of more physical fields has to be con-
sidered. There are two fundamentally different approaches towards this complicated
issue, referred to as weak and hard coupling.
– The weak coupling is simpler to implement, since individual fields are calculated
separately. In the situation, where terms comprising values of one field are present
in the equation describing the other one, but not vice-versa (the case of one-way
coupling), this method is usually preferable. In the case of both-way coupling, the
use of the weak approach leads to the necessity of several repetitions of consecutive
solution of the individual fields, where the values of the second field are taken
from the previous iteration. This is obviously rather time-consuming and also
the convergence is a big issue. For such problems, the following method is more
suitable.
– Using the hard coupling approach, where is no need for iterating, since only one
discrete system is created and then solved using linear or nonlinear solver. It is,
however, much more complicated to implement and therefore the majority of finite
element codes use some variation of the weak coupling.
This being a rather novel feature of our code, we have implemented and tested three
coupling possibilities up to now:
– electric currents and heat transfer,
– magnetic fields and heat transfer,
– heat transfer and structural mechanics.
1 3
S390 P. Karban et al.
More options should be available soon. More than two fields may be coupled for
complicatedproblems, suchas magnetic, heat andelasticity, as it is showninillustrative
example in Sect. 4.2.
As described in Sect. 3.1, all information related to the individual fields (equations,
boundary conditions, material parameters, postprocessor quantities, etc.) are separated
from the computational core and stored in XML modules. The same model is used for
couplings definition. For each pair of fields A and B, whose coupling is considered,
one separate XML module is created with specification of coupling terms that are
to be added into the weak formulation for each combination of types of analyses of
A and B (steady state, transient or harmonic) and desired type of coupling (weak or
hard). Files are written in such a manner that no contents of field modules has to be
duplicated. C++ source codes are generated from coupling modules in the same way
as for the field modules, as it was described previously.
3.4 Time dependent problems
Alot of interest is usually paid to the spatial discretization and to the effort to minimize
its error with reasonable computational cost. It is equally important to try to minimize
the number of time steps, since the total computational time is proportional to it. The
basic implicit or explicit Euler method simply does not suffice. The usual strategy of
solving transient problems is to discretize the equation in space, solve it and, hence,
obtain a system of ordinary differential equations in time, which can then be handled
separately using standard tools for solution of ordinary differential equations. This is
not an option in our code, since the mesh may be different in each time step due to
possible space adaptivity. We have to use the Rothe method instead, carrying out the
time discretization first.
The continuous time-dependent problem can be written in the form
∂y
∂t
= F(y, t ) . (7)
To discretize the time derivative, we have implemented a variant of backward differ-
ential method (BDF)
n

i =0
α
i
y
k−i
= F(y
k
, t
k
) , (8)
where t
k
are time levels, y
k
= y(t
k
) corresponding solutions and coefficients α
i
depend
on the lengths of previous steps and thus allow the time step to be changed (in the
case of time adaptivity, which will be discussed later). After the time discretization is
done using this formula, the space discretization can be performed in the same way as
it would be for a steady state problem. The only difference is the necessity to provide
values of solutions from n previous time steps, projected to the current mesh. This
is possible thanks to capabilities of the Hermes library. We have implemented the
method of orders n = 1, 2, 3.
1 3
Numerical solution of coupled problems using code Agros2D S391
Fig. 7 Basic arrangement of
transient problem
Fig. 8 Dependence of resulting temperature at a selected point of the domain on the number of time steps
Using higher order time discretization can bring significant speed improvement
itself, but it can be further used to develop an adaptive time-step method. Solving the
problemusing two different orders, an estimate of the error can be obtained. It can then
be usedtodetermine the lengthof the next time step(enlarge or shorten) inorder tokeep
the error as close to the prescribed tolerance as possible and thus obtain solution with
desired accuracy using as fewtime steps as possible. Obviously, the question of choos-
ingthe right value of the tolerance andgenerallythe relationof the errors causedbyspa-
tial and time discretizations is very complicated and is beyond the scope of this article.
The advantages of adaptive selection of the time step length will be shown on an
illustrative example shown in Fig. 7.
Figure 8 depicts the dependence of the resultant temperature at a selected point
of the domain on the number of time steps (in the logarithmic scale) for fixed and
adaptive step lengths. All methods converge to the same value, but adaptive methods
(marked by squares) much faster than those with a fixed step (marked by discs).
3.5 Particle tracing
The movement of the particle obeys the equations for its velocity v and trajectory s in
the forms
m
dv
dt
= F,
ds
dt
= v, (9)
where F is the sum of all forces acting on the particle. The corresponding initial
conditions read
1 3
S392 P. Karban et al.
s(0) = s
0
, v(0) = v
0
, (10)
where s
0
is the entry position and v
0
is the entry velocity of the particle.
The following forces have to be considered.
– The force acting on the charged particle in electromagnetic field is called Lorentz
force. This force is given by the relation
F
L
= Q (E +v ×B) , (11)
where Edenotes the local value of the electric field and Bstands for the local value
of magnetic flux density. Q denotes the charge of the particle and v its velocity.
– The gravitational force is given by the formula
F
g
= mg, (12)
where m denotes the mass of the particle and g is the gravitational acceleration.
– The aerodynamic resistance is given by the formula
F
a
= −v
1
2
ρcSv, (13)
c being the friction coefficient (depending on geometry of the particle), ρ denotes
the density of ambient air, S is the characteristic surface of the particle and v stands
for the module of its velocity.
This set of two equations is strongly nonlinear due to the forces on the right-hand
side. For numerical solution of the trajectory of the particle we use the Runge–Kutta–
Fehlberg method. This method uses an O(h
4
) method together with an O(h
5
) method
that works with all the points of the O(h
4
) method, and, hence, it is often referred to
as an RKF45 method. Our code is fully adaptive and optimal time step is chosen.
3.6 Structure of Agros2D
The work-flow of Agros2D, as for most of the commercial codes, can be divided into
three main phases. First the user has to specify the problem and create geometry. Than
the actual solution takes place. After the field is resolved, various postprocessor tools
may be used.
3.6.1 Preprocessor
One of the main advantages of commercial codes over most of the academical projects,
which is of great importance for practitioners, is a presence of advanced preprocessor
tools. In Agros2D, we have implemented all features that are necessary for creation
of complex engineering problem (see Fig. 9). After selection of considered physical
fields and types of analyses, the user starts with geometry definition. It comprises of
creation of nodes, edges and areas. Curved edges can be used to create more realistic
1 3
Numerical solution of coupled problems using code Agros2D S393
Fig. 9 Window of preprocessor (geometry and physical properties of the furnace for silicon melting)
geometries. The mesh can be also imported from a file in the DXF format. Various
parameters can be supplied to specify mesh quality in individual areas or towards
edges or nodes to utilize a-priori knowledge of problem properties.
The second function of the preprocessor is to specify physical properties of indi-
vidual parts of volume and boundary by defining material constants and boundary
conditions. Material properties, including nonlinear characteristics of materials, can
be loaded from the material library. Various types of boundary conditions are pre-
defined for all fields, so the user only has to select the appropriate one and provide
necessary data related to the given problem.
3.6.2 Processor
After the geometry and physical properties are specified, the calculation can be started
by the user. After that, Agros2Dproceeds in several steps. First is the creation of mesh,
which is carried out by calling one of external mesh-creation tools according to users
preferences. In the present moment, our code uses either Triangle [30] or GMSH [23].
Various types of meshes (triangular, quadrilateral or combinations) may be used.
When the mesh is created, the core of the finite-element calculation takes place.
Weak forms are created according to physical fields and couplings, specified by the
user. They are then used for assembling matrices and right hand side vectors during
the calculation. The flow of the calculation depends on various settings. Matrices and
vectors have to be assembled for each step of nonlinear solver, for each adaptive or
transient step. For single field analysis or hard coupling of more fields, one matrix is
used, while for weak coupling, one matrix and vector are used for each field.
During the process, solution of system of linear equations is needed (for the most
simple linear problem without adaptivity only once, but typically multiple times). It
1 3
S394 P. Karban et al.
Fig. 10 Window of postprocessor (distribution of temperature after 45 min)
is carried out by supplying assembled matrix and vector to the external linear solver.
We usually use the well known direct solver UMFPACK [18], but MUMPS [10] and
SuperLU [19] can be also called, depending on users preferences.
3.6.3 Postprocessor
A very important part of software Agros2D is an advanced postprocessor. In technical
practice, it is necessary to work with a variety of derived variables. Agros2Dallows dis-
playing scalar variables in the form of color map or contour lines, for the vector quan-
tities it is possible to display their modules, components or vector field (see Fig. 10).
There are implemented integrals of surface and volume calculations. Other features
include determination of the point values, cross-section graphs and particle tracing.
Agros2Ditself contains only general support for postprocessing. The relations for cal-
culation of the local and the integral quantities are part of each specific module. There-
fore, it is easy to add postprocessor quantities by modifying the relevant XML file.
3.7 Scripting language
Agros2D also contains an engine for scripting language Python [13]. This engine
extends abilities of preprocessing, processing and also postprocessing. It is possible
to use Python expressions and defined variables for entering model data (geometry,
material and boundary parameters, etc.) in GUI. This functionality is advantageous
for work with complex models. But the main advantage of this engine is a full control
of model by using object-oriented wrappers available as special Python module of
Agros2D.
1 3
Numerical solution of coupled problems using code Agros2D S395
Fig. 11 Main window of PythonLab
Scripting in Agros2D allows making advanced analysis. For example, it is possible
to use scripts for parametric analysis, result analysis and their visualisation or couple
solved model with other models using computed results. Scripting also allows extend-
ing the basic functionality of Agros2D. Now, under development there is a Python
module for optimization, which allows using special algorithms for optimizing the
modeled problem.
It is possible to use the editor PythonLab (see Fig. 11) for editing scripts. PythonLab
is developed mainly for Agros2D and allows using:
– code completion,
– syntax highlighting,
– code bugs and quality checking with PyLint [12] and PyFlakes [11] and
– converter from model to script.
Python contains many modules that are possible to be used in Agros2D. It is one
of the main advantages of using Python. For example, SciPy [14] adds a support for
scientific computing, matplotlib [9] adds plotting capabilities.
4 Illustrative examples
The power of code Agros2D is documented by three following examples from the
domain of electrical engineering:
– induction heating of rotating nonmagnetic billets in static magnetic field generated
by permanent magnets,
– accurate setting of position based on thermoelastic principle,
– separation of plastic particles based on triboelectric effect.
1 3
S396 P. Karban et al.
The purpose of this demonstration is not only to show the unique capabilities of
the Hermes library (which has been already done in many papers, see, e.g., [21, 32–
34]), but also to show user-friendliness of the Agros2D software. The three following
examples have been selected in such a way to facilitate various aspects (adaptivity,
coupling, time-dependence, nonlinearities, etc.). Even when all such situations might
be handled by various existing codes, it would sometimes require a lot of work just
to describe the calculation (using many calls to the library or writing large script). In
Agros2D, everything can be done from graphical user interface, which is very fast,
efficient and less prone to errors.
Agros2D, however, is not just a GUI to the Hermes library. It should be viewed
as a higher level of the code, which utilizes low-level calls to the library to construct
everything necessary for the solution of the given problem. It is designed to help
engineers to select from various range of fields with predefined boundary conditions
types and materials, define their mutual interactions and finally to view values of
different quantities related to the field or to calculate surface or volume integrals.
Such things are usually not priorities of academical codes developers, which makes
them extremely difficult to use for the practitioners. The software is, however, written
in such a way, that it allows large control over the calculation. Therefore a more
advanced user can chose from various settings.
In the following examples, we decided not to show screen-shots from the calcu-
lations. The GUI itself is quite simple to use and this paper is not intended to be a
manual. The purpose is to show how complicated situations can be solved thanks to
the Agros2D layer over the Hermes with no need to write new single-purpose codes
calling Hermes routines, which might be very time consuming.
4.1 Induction heating of nonmagnetic cylindrical billets rotating in a system of static
permanent magnets
Induction heating of cylindrical billets of various nonmagnetic metals (mostly alu-
minum) is a widely spread technological process often used for their softening before
hot forming [17]. This process is usually realized using the two following ways:
– heating of an unmoving billet in a system of static, harmonic currents carrying
inductors,
– heating of a rotating billet in static magnetic field generated by static inductors.
Heating of billets placed inside harmonic current-carrying inductors belongs to the
classical ways of heat treatment. This technology has been employed since the thirties
of the twentieth century. But its effectiveness is rather low due to high Joule losses in
the inverter and inductor themselves (that must be transferred away by an appropriate
cooling medium). The efficiency of the process typically does not exceed 30–40 %.
Heating of a rotating billet in static magnetic field produced by direct current-
carrying inductor was proposed about 10 years ago and modeled by several groups of
authors, such as [22, 27]. The most important of them is generation of a sufficiently
high magnetic field and corresponding eddy currents in the billet. As its revolutions
are rather limited (in case of massive billets with diameters over 0.1 m their value
does not exceed 750 rpm), the only possible solution is using very high field currents,
1 3
Numerical solution of coupled problems using code Agros2D S397
Fig. 12 Basic arrangement (left) and experimental device (right)
which usually requires superconducting devices with all necessary infrastructure. In
this case, the Joule losses (due to low resistance of the field windings) are not crucial,
but certain amount of energy is consumed by the cooling devices and rotation of the
billet. The overall efficiency of the process is reported to be about 65–80 %.
In our case, the static magnetic field is generated by appropriately arranged high-
parameter permanent magnets. A typical disposition is depicted in Fig. 12.
This version of heating is characterized by the absence of the field coils (and the
corresponding Joule losses), thus the only losses in the system are the mechanical
losses. A physical model built in our laboratory is depicted in Fig. 12 right.
4.1.1 Mathematical model
The continuous mathematical model of heating consists of two nonlinear partial dif-
ferential equations providing the distribution of static magnetic field and evolutionary
temperature field in the system. The distribution of magnetic field is described in terms
of magnetic vector potential A by the equation
curl

1
µ
curl A −H
c

−γ (v ×curl A) = 0 , (14)
where µ stands for the magnetic permeability, γ is the electrical conductivity, v is
the local velocity of movement at a point, and H
c
is the coercive force. A sufficiently
distant artificial boundary is characterized by the Dirichlet condition A = 0.
The temperature field in the system obeys the equation
divλ grad T −ρc
dT
dt
= −p
J
, (15)
where λ is the thermal conductivity, ρ is the specific mass, and c denotes the specific
heat at a constant pressure. Finally, the symbol p
J
denotes the time average internal
sources of heat represented by the volumetric Joule losses. These are given by the
formula
1 3
S398 P. Karban et al.
p
J
=
J
eddy

2
γ
, where J
eddy
= γ (v ×curl A) . (16)
This equation is supplemented with the boundary condition respecting convection
−λ
∂T
∂n
= α (T − T
ext
) ,
where T
ext
is the temperature of ambient air. As the temperature of the magnetic circuit
is low (it does not exceed 50

C), the influence of radiation was neglected at this stage
of the research.
4.1.2 Example
The magnetic circuit of the experimental stand is made of standard carbon steel 12,040
whose magnetization characteristic is depicted in Fig. 13 left. The heated billet fixed
by a specific mechanism is driven by a 3 kW induction motor. The dependence of
physical parameters of aluminum on temperature are depicted in Figs. 13 and 14.
The radius of the billet is 60 mm. The nominal speed of the motor is 1, 500 rpm.
The permanent magnets are of type VMM10 and exhibit the remanent magnetic flux
density B
r
= 1.28T and relative permeability in the second quadrant µ
r
= 1.11.
Fig. 13 Magnetization characteristic of steel 12,040 and dependence of thermal conductivity of aluminum
on temperature
Fig. 14 Dependence of mass density (left) and specific heat (right) of aluminum on temperature
1 3
Numerical solution of coupled problems using code Agros2D S399
Fig. 15 Distribution of magnetic flux density B
Fig. 16 Distribution of permeability µ
r
and temperature T at time t = 180 s
4.1.3 Results
Figure 15 shows the distribution of magnetic flux density in the systemand Fig. 16 left
the corresponding distribution of magnetic permeability in the part of the magnetic
circuit. Finally, Fig. 16 right depicts the distribution of temperature in the system after
180 s of heating.
4.2 Accurate setting of position based on thermoelastic principle
Thermoelastic deformations of metal bodies produced by induction heating are
exploited in numerous industrial technologies (hot pressing, production of high forces
etc. [20, 31]). But thermoelasticity may also be advantageous for producing small,
but well controllable shifts. A schematic arrangement of the corresponding device is
depicted in Fig. 17. A dilatation element made of appropriate metal is inserted into
a current-carrying coil in a fixing ferromagnetic frame. The whole system is placed
in the insulating shell. The device is clamped by its bottom part (insulating front) in
1 3
S400 P. Karban et al.
Fig. 17 Basic arrangement of the device
the basement (ideally stiff wall). The time-variable magnetic field generated by the
field coil induces in the dilatation element eddy currents that produce its heating and
consequent geometrical changes of the thermoelastic origin.
4.2.1 Mathematical model
Distribution of electromagnetic field in the systemin the period of heating is described
by the equation for magnetic vector potential A
curl
1
µ
curlA +γ ·
∂A
∂t
= J
ext
, (17)
where µ denotes the magnetic permeability, γ is the electric conductivity and J
ext
stands for the vector of external harmonic current density in the inductor. Parameter
γ is generally a function of the temperature T and µ is a function of temperature T
and magnetic flux density B = curlA.
But solution to equation 17 is practically unfeasible. The reason consists in the
deep disproportion between the frequency f (10 or 100 Hz) of the field current and
time of heating (tens of seconds or minutes). That is why the model was somewhat
simplified using the assumption that the magnetic field is harmonic. In such a case it
can be described by the Helmholtz equation for the phasor A of the magnetic vector
potential A
curl curl A +j · ωγ µA = µJ
ext
, (18)
where ωis the angular frequency, and J
ext
is the phasor of the external harmonic current
density in the field coil. The conditions along the axis of the device and artificial
boundary placed at a sufficient distance from the system are of the Dirichlet type
A = 0.
The temperature field in the system is described by the heat transfer equation
divλ(T) grad T −ρ(T) c(T) ·
∂T
∂t
= −p
J
, (19)
where λ(T) is the thermal conductivity, ρ(T) denotes the mass density and symbol
c(T) stands for the specific heat (all of these parameters are generally temperature-
dependent functions). Finally, p
J
denotes the time average volume Joule losses due to
eddy currents in electrically conductive parts that are given by the formula
1 3
Numerical solution of coupled problems using code Agros2D S401
p
J
=
J
eddy

2
γ
, J
eddy
= −j · ωγ A. (20)
The boundary conditions take into account only convection
−λ
∂T
∂n
= α (T − T
ext
) ,
where T
ext
is external temperature. Since the dilatation element with the coil are
covered by the insulation (that is characterized by a poor thermal conductivity), we
can, without any significant error, neglect the influence of radiation.
The solution of the thermoelastic problem starts from the vector Lamé equation
that reads
(λ +µ) grad div u +µu −(3λ +2µ) α
T
grad T = −f , (21)
where λ and µ are coefficients associated with material parameters by relations
λ =
νE
(1 +ν)(1 −2ν)
, µ =
E
2(1 +ν)
.
Here E denotes the modulus of elasticity and ν the Poisson coefficient of the transverse
contraction, α
T
is the coefficient of the linear thermal dilatability of material and f the
vector of the internal volume forces. Finally u = (u
r
, u
ϕ
, u
z
) represents the resultant
displacement vector.
4.2.2 Example
The geometry of the investigated device follows from Fig. 17. The material of the
dilatation element is zinc with electrical conductivity γ = 16 MS/m, Young modulus
E = 130 GPa, Poisson number ν = 0.331, thermal expansion coefficient α
T
=
27 · 10
−6
K
−1
. Finally, its thermal conductivity λ(T), mass density ρ(T) and specific
heat c(T) are temperature-dependent functions depicted in Figs. 18 and 19. The field
coil is wound by a copper conductor (its thermal conductivity λ = 385 Wm
−1
K
−1
,
mass density ρ = 8, 700 kg m
−3
and specific heat c = 380 J kg
−1
K
−1
) and carries
harmonic current of density J
ext
= 10 MAm
−2
and frequency f = 500 Hz. Thermal
insulation is made of Teflon with thermal conductivity λ = 0.23 Wm
−1
K
−1
, mass
density ρ = 2, 200 kg m
−3
and specific heat c = 1, 000 J kg
−1
K
−1
.
Figure 20 shows the three independent meshes (at the initial stage) for computation
of magnetic field, temperature field and field of thermoelastic displacements.
4.2.3 Results
Figure 21 shows (from left to right) the distribution of magnetic field, temperature
field and field of thermoelastic displacements after 30 s of heating.
1 3
S402 P. Karban et al.
Fig. 18 Dependence of thermal conductivity (left) and mass density (right) of zinc on temperature
Fig. 19 Dependence of specific
heat of zinc on temperature
Fig. 20 Used meshes (from left to right) for computation of magnetic field, heat transfer and thermoelas-
ticity (multimesh technology)
1 3
Numerical solution of coupled problems using code Agros2D S403
Fig. 21 Solution at time t = 30 s (magnetic field, heat transfer and thermoelasticity)
Fig. 22 Time dependence of average temperature of the dilatation element and axial displacement of the
top in the dilatation element
Figure 22 left shows the time evolution of the avarage temperature of the dilatation
element and Fig. 22 right depicts an analogous evolution of the displacement of the
top end of the dilatation element.
Due toveryefficient thermal insulationof the device, the process of heatingis almost
adiabatic, so that both dependencies are practically linear within the investigated range
of temperatures.
4.3 Device for electrostatic separation of plastic particles
Nowadays, an intensive research is conducted worldwide, aimed at the possibilities of
recycling plastic materials, because in a lot of applications they may well replace the
new ones. The necessary prerequisite of this reprocessing is a high-quality separation
of particular kinds of plastics that are (at the first step of the process) grinded into
small sphere-shaped particles. One of the advanced techniques of separation of these
1 3
S404 P. Karban et al.
Fig. 23 Basic arrangement and dimensions of a typical separator
particles is based on the triboelectric effect [28, 29, 37]. It is known, that when electri-
cally non-conducting particles of two different levels come into contact with electric
charge, one of them becomes more positive (or negative) with respect to another one.
And when such charged particles get into electric field, their movement is then mainly
affected by the charge that they carry.
More accurately, the trajectories of the charged particles moving in electric field
are influenced by the Coulomb force exerted on them by this field, gravity, and drag
aerodynamic forces. And these trajectories predetermine their impact points, in other
words, the places where they fall down. It is clear fromFig. 23 left showing the scheme
of a typical separator of this kind.
The separator consists of two electrodes, one of them being grounded. The voltage
of the other electrode is used to be on the order of tens kV. The electrodes may
be covered by Teflon or another insulating material that prevents recharging of the
particles in case of the direct impact with them. The mixture of charged particles is
delivered by the feeder. At the bottom of the device there are several recycle bins used
for accumulating of particular levels of plastics. One of the principal demands is to
tune the shape of the electrodes and widths of the bins so that the particles of different
levels should fall down exactly to the corresponding bins.
4.3.1 Mathematical model
Electric field in the working space of the separator is described by the equation for the
electric potential ϕ
div ε grad ϕ = 0 , (22)
where ε is the dielectric permittivity. The boundary conditions are given by the known
values of the electric potential on the electrodes and the Neumann condition along the
artificial boundary placed at a sufficiently distance from the device.
1 3
Numerical solution of coupled problems using code Agros2D S405
The movement of the particle obeys the equations for its velocity v and trajectory
s in the forms
m
dv
dt
= F
e
+F
a
+F
g
,
ds
dt
= v , (23)
where F
e
is the Coulomb force acting on the particle. This force is given by the relation
F
e
= QE = −Q · grad ϕ , (24)
where E denotes the local value of the electric field strength. Symbol F
a
represents
the aerodynamic resistance given by (13) and gravity force F
g
is described by (12).
4.3.2 Example
Consider the basic arrangement depicted in Fig. 23 right. The particles of plastics of
charge Q = ±0.5 µC, mass density ρ = 1, 370 kg · m
−3
, radius R = 2 mm and
initial velocity v
0
= 0 get to the space between two electrodes, one of them being
grounded. There they are deflected according to their charge and fall down into the
recycle bins (presently, we neglect the Coulomb forces acting among the particles, so
that their movement is affected only by the external electric field). The task is to find
their trajectories and evaluate the effectiveness of separation. The voltage between the
electrodes is U = 45 kV.
4.3.3 Results
Table 1 shows the convergence of results for different adaptive techniques used for the
numerical solution. The lowercase letter p denotes the startingorder of the polynomials
and ε(x) the relative error of computation. Figure 24 left shows initial mesh before
adaptive process and Figs. 24 right and 25 depict the discretization meshes after the
corresponding adaptive processes.
Finally, Fig. 26 shows typical trajectories of the PVC and PET particles in the
separator.
5 Conclusions and outlooks to the future
In our paper, we have presented the current state of our open-source project Agros2D. It
combines advanced numerical algorithms for solution of partial differential equations
Table 1 Convergence for h, p
and hp adaptivity techniques
Start ε(x) DOFs (-) Steps (-) Time (s)
h-adaptivity p = 2 0.139 28086 9 72.811
p-adaptivity p = 1 0.177 13939 11 50.473
hp-adaptivity p = 1 0.197 12154 11 50.222
1 3
S406 P. Karban et al.
Fig. 24 Initial mesh (left), h-adaptivity, p = 2 (right)
Fig. 25 p-adaptivity, p = 1 (left), hp-adaptivity, p = 1 (right)
with modern and efficient graphical user interface. This combination makes it possible
for the practitioners to benefit from fast and reliable algorithms with no need to study
details of numerical mathematics. The advancedGUI is alsouseful for the development
of algorithms itself, since it is much simpler to maintain, test and modify such program
than it is for traditional academical one-purpose codes.
The work is, of course, far frombeing finished. Even though Agros2D is capable of
solving problems from various fields, few additional modules could be added. Thanks
to a complete separation of computational logic from the definition of individual
fields, addition of new modules is quiet simple, since the code itself does not need
to be changed. The next important issue, that has been addressed recently, is making
1 3
Numerical solution of coupled problems using code Agros2D S407
Fig. 26 Trajectories of selected particles (PVC and PET)
the code more efficient. Parallelization of the code is important toll in achieving this.
At the present moment, we use it onthe OpenMPlevel only. For anefficient deployment
on cluster computers, usage of MPI is necessary. It is, however, much more demanding
and requires substantional refactoring of the code.
Acknowledgements This work was supported by the European Regional Development Fund and Ministry
of Education, Youth and Sports of the Czech Republic (Project No. CZ.1.05/2.1.00/03.0094: Regional
Innovation Centre for Electrical Engineering - RICE) and Grant project GACR P102/11/0498.
References
1. ANSYS. http://www.ansys.com
2. CEDRAT Flux. http://www.cedrat.com
3. COMSOL Multiphysics. http://www.comsol.com
4. ctemplate. http://code.google.com/p/ctemplate
5. deal.ii. http://www.dealii.org
6. FreeFem++. http://www.freefem.org/ff++
7. GetFEM++. http://download.gna.org/getfem/html/homepage/index.html
8. infolytica. http://www.infolytica.com
9. matplotlib. http://matplotlib.org
10. MUMPS. http://graal.ens-lyon.fr/MUMPS
11. PyFlakes. http://pypi.python.org/pypi/pyflakes
12. PyLint. http://www.logilab.org/project/pylint
13. Python. http://www.python.org
14. SciPy. http://www.scipy.org
15. Vector Fields Software - Opera. http://www.cobham.com/about-cobham/aerospace-and-security/abo
16. Xerces CPP. http://xerces.apache.org/xerces-c
17. Cavaliere P (2002) Hot and warm forming of 2618 aluminum alloy. J Light Met 2:247–252
18. Davis TA (2004) A column pre-ordering strategy for the unsymmetric-pattern multifrontal method.
ACM Trans Math Soft 30(2):165–195
19. Demmel JW, Eisenstat SC, Gilbert JR, Li XS, Liu JWH(1999) Asupernodal approach to sparse partial
pivoting. SIAM J Matrix Anal Appl 20(3):720–755
1 3
S408 P. Karban et al.
20. Dolezel I, Karban P, Ulrych B, Pantelyat M, Matyukhin M, Gontarowskiy P, Shulzhenko M (2008)
Limit operation regimes of actuators working on principle of thermoelasticity. IEEE Trans Magn
44:810–813
21. Dubcova L, Solin P, Cerveny J, Kus P (2010) Space and time adaptive two-mesh hp-fem for transient
microwave heating problems. Electromagnetics 30:23–40
22. Fabbri M, Morandi A, RibanyL(2008) Dc inductionheatingof aluminumbillets usingsuperconducting
magnets. COMPEL 27:480–490
23. Geuzaine C, Remacle JF (2009) Gmsh: a three-dimensional finite element mesh generator with built-in
pre- and post-processing facilities. Int J Numer Meth Eng 79:1309–1331
24. Karban P, et al. Multiplatform C++ application for the solution of PDEs. http://agros2d.org (online)
25. Logg A, Mardal KA, Wells GNet al (2012) Automated Solution of Differential Equations by the Finite
Element Method, Springer, Berlin. doi:10.1007/978-3-642-23099-8
26. Long KR, Kirby RC(2010) Unified embedded parallel finite element computations via software-based
frechet differentiation. SIAM J Sci Comput 32(6):3323–3351
27. Magnusson N, Bersas R, Runde M (2004) Induction heating of aluminum billets using hts dc coils.
Ins Phy Conf Ser 2:1104–1109
28. Moesner FM, Toshiro H (1997) Contactless manipulation of microparts by electric field traps. Proc
SPIE’s Int Symp Microrobot Microsyst Fabr 3202:168–175
29. Saeki M (2008) Triboelectric separation of three-component plastic mixture. Part Sci Technol 26:494–
506
30. Shewchuk JR (1996) Triangle: engineering a 2d quality mesh generator and delaunay triangulator.
Applied Computational Geometry: towards Geometric Engineering 1148:203–222. http://www.cs.
cmu.edu/quake/triangle.html
31. Skopek M, Ulrych B, Dolezel I (2001) Optimized regime of induction heating of a disk before its
pressing on shaft. IEEE Trans Magn 37:3380–3383
32. Solin P, Andrs D, Cerveny J, Simko M (2010) Pde-independent adaptive hp-fem based on hierarchic
extension of finite element spaces. J Comput Appl Math 233:3086–3094
33. Solin P, Cerveny J, Dolezel I (2008) Arbitrary-level hanging nodes and automatic adaptivity in the
hp-fem. Math Comput Simul 77:117–132
34. Solin P, Korous L (2012) Adaptive higher-order finite element methods for transient pde problems
based on embedded higher-order implicit runge-kutta methods. J Comput Phy 231:1635–1649
35. Solin P, Segeth K, Dolezel I (2003) Higher-Order Finite Element Methods. CRC Press, Boca Raton
36. Solin P et al (2012) Hermes-higher-order modular finite element system (user’s guide). http://hpfem.
org (online)
37. Yanar DK, Kwetkus BA (1995) Journal of electrostatics. IEEE Trans Magn 36:257–266
1 3