automated modeling

Upload: dennis-eldred

Post on 07-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Automated Modeling

    1/140

    THESIS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY

    Automation of Computational

    Mathematical Modeling

    ANDERS LOGG

    Department of Computational Mathematics

    CHALMERS UNIVERSITY OF TECHNOLOGY

    GOTEBORG UNIVERSITY

    Goteborg, Sweden 2004

    Automation of Computational Mathematical ModelingANDERS LOGGISBN 917291436X

    c ANDERS LOGG, 2004.

    Doktorsavhandlingar vid Chalmers tekniska hogskolaNy serie nr 2118ISSN 0346718X

    Department of Computational MathematicsChalmers University of TechnologyGoteborg UniversitySE412 96 GoteborgSwedenTelephone +46 (0)31 772 1000

    Tryckeriet, Matematiskt centrumGoteborg, Sweden 2004

  • 8/6/2019 Automated Modeling

    2/140

    Automation of Computational

    Mathematical Modeling

    ANDERS LOGGDepartment of Computational Mathematics

    Chalmers University of Technology

    Goteborg University

    ABSTRACT

    This thesis concerns the Automation of Computational MathematicalModeling (CMM), involving the key steps of automation of (i) discretiza-tion, (ii) discrete solution, (iii) error control, (iv) modeling, and (v) opti-mization.

    The automation of (i)(ii) is realized through multi-adaptive Galerkinmethods on general discretizations of spacetime with time steps variablein space. The automation of (iii) is realized through a posteriori errorestimation based on residuals of computed solutions and stability factorsor stability weights obtained by the solution of associated dual problems.The automation of (iv) is studied in a model case, while that of (v) isreduced to an application of (i)(iv).

    An open-source software system for the Automation of ComputationalMathematical Modeling is developed and implemented, based on generalorder multi-adaptive Galerkin methods, including automatic evaluation ofvariational forms, automatic discrete solution, automatic generation andsolution of dual problems, and automatic model reduction.

    Keywords: Computational mathematical modeling, automation, adaptivity, multi-

    adaptivity, individual time steps, dual problem, a priori, a posteriori, model re-

    duction.

    i ii

  • 8/6/2019 Automated Modeling

    3/140

    THESIS

    This thesis consists of an introduction, a sequence of papers as listed

    below, and the source code included on the compact disc.

    iii iv

  • 8/6/2019 Automated Modeling

    4/140

    APPENDED PAPERS

    The following papers are included in this thesis:

    PAPER I: Multi-Adaptive Galerkin Methods for ODEs I, SIAM J. Sci.Comput., vol. 24 (2003), pp. 18791902.

    PAPER II: Multi-Adaptive Galerkin Methods for ODEs II: Implemen-

    tation and Applications, SIAM J. Sci. Comput., vol. 25 (2003), pp. 11191141.

    PAPER III: Multi-Adaptive Galerkin Methods for ODEs III: Existence

    and Stability, submitted to SIAM J. Numer. Anal. (2004).

    PAPER IV: Multi-Adaptive Galerkin Methods for ODEs IV: A PrioriError Estimates, submitted to SIAM J. Numer. Anal. (2004).

    PAPER V: Multi-Adaptive Galerkin Methods for ODEs V: Stiff Prob-

    lems, submitted to BIT (2004), with J. Jansson.

    PAPER VI: Explicit Time-Stepping for Stiff ODEs, SIAM J. Sci. Com-put., vol. 25 (2003), pp. 11421157, with K. Eriksson and C. Johnson.

    PAPER VII: Interpolation Estimates for Piecewise Smooth Functions

    in One Dimension, Chalmers Finite Element Center Preprint Series, no.

    200402 (2004).

    PAPER VIII: Estimates of Derivatives and Jumps Across Element Bound-

    aries for Multi-Adaptive Galerkin Solutions of ODEs , Chalmers Finite El-ement Center Preprint Series, no. 200403 (2004).

    PAPER IX: Algorithms for Multi-Adaptive Time-Stepping, submitted toACM Trans. Math. Softw. (2004), with J. Jansson.

    PAPER X: Simulation of Mechanical Systems with Individual Time Steps,submitted to SIAM J. Appl. Dyn. Syst. (2004), with J. Jansson.

    PAPER XI: Computational Modeling of Dynamical Systems, to appearin M3AS (2004), with J. Jansson and C. Johnson.

    v

    The following papers are related, but are not included in the thesis:

    Topics in Adaptive Computational Methods for Differential Equa-tions, CEDYA 2001: Congreso de Ecuaciones Diferenciales y Apli-

    caciones (2001), with J. Hoffman and C. Johnson.

    Multi-Adaptive Time-Integration, Applied Numerical Mathematics,vol. 48, pp. 339354 (2004).

    Adaptive Computational Methods for Parabolic Problems, to appear inEncyclopedia of Computational Mechanics (2004), with K. Erikssonand C. Johnson.

    DOLFIN: Dynamic Object oriented Library for FINite element com-putation, Chalmers Finite Element Center Preprint Series, no. 200206 (2002), with J. Hoffman.

    The FEniCS project, Chalmers Finite Element Center Preprint Series,no. 200321 (2003), with T. Dupont, J. Hoffman, C. Johnson, R.C.Kirby, M.G. Larson, and L.R. Scott.

    vi

  • 8/6/2019 Automated Modeling

    5/140

    CONTENTS ON THE COMPACT DISC

    The included compact disc contains the following material:

    The introduction;

    PAPER IXI as listed above;

    Source code for DOLFIN version 0.4.11;

    Source code for Puffin version 0.1.6;

    Images and animations.

    vii viii

  • 8/6/2019 Automated Modeling

    6/140

    PREFACE

    To Prof. Kenneth Eriksson and Prof. Claes Johnson, my two advisors,

    thanks for all your inspiration and support over the years. Special thanksto Claes for the piano lessons, the tennis lessons, and the endless discussionson music, philosophy, and life.

    Thanks also to Prof. Endre Suli, Prof. Jan Verwer, and Prof. Ridg-way Scott for giving me the opportunity to visit Oxford, Amsterdam, andChicago during my time as a graduate student. These visits have all beeninvaluable experiences.

    To all my friends and colleagues at the Department of ComputationalMathematics at Chalmers, thanks for the many enlightening discussions onmathematics, programming, and football. In particular, I wish to acknowl-edge my co-authors Johan Hoffman and Johan Jansson. Thanks also to

    Goran Christiansson for valuable comments on the manuscript.Special thanks to all the members of the DOLFIN team: Fredrik Beng-

    zon, Niklas Ericsson, Georgios Foufas, David Heintz, Rasmus Hemph, Jo-han Hoffman, Johan Jansson, Karin Kraft, Aleksandra Krusper, AndreasMark, Axel Malqvist, Andreas Nilsson, Erik Svensson, Jim Tilander, Tho-mas Svedberg, Harald Svensson, and Walter Villanueva.

    But most of all, I would like to thank my wife Anna, my parents andgrandparents, my little sister Katarina, and Lysekilarna, for all their loveand support.

    Goteborg, April 2004Anders Logg

    ix x

  • 8/6/2019 Automated Modeling

    7/140

    And now that we may give final praise to the machine we maysay that it will be desirable to all who are engaged in compu-tations which, it is well known, are the managers of financialaffairs, the administrators of others estates, merchants, survey-

    ors, geographers, navigators, astronomers. . . For it is unworthyof excellent men to lose hours like slaves in the labor of cal-culations which could safely be relegated to anyone else if themachine were used.

    Gottfried Wilhelm Leibniz (16461716)

  • 8/6/2019 Automated Modeling

    8/140

  • 8/6/2019 Automated Modeling

    9/140

  • 8/6/2019 Automated Modeling

    10/140

  • 8/6/2019 Automated Modeling

    11/140

    with U(0) = u0 and where U(t) = U(tj1) + (t tj1)(U(tj) U(tj1))/kjon each interval Ij. Note that (7) represents a (possibly nonlinear) systemof equations for the degrees of freedom of the discrete solution U.

    Multi-Adaptive Galerkin

    It is desirable, in short, that in things which do not primarily concernothers, individuality should assert itself.

    John Stuart Mill (18061873), On Liberty (1859)

    Standard methods for the discretization of (1) require that the temporalresolution is constant in space at each given time t. In particular, thecG(1) method for (4) requires that the same time step k = k(t) is usedfor all components Ui = Ui(t) of the solution U. This can be very costlyif the system exhibits multiple time scales of different magnitudes. If thedifferent time scales are localized in space, corresponding to a difference

    in time scales between the different components of the solution U of (4),efficient representation of the solution thus requires that this difference intime scales is reflected in the choice of discrete representation ( V, V). Werefer to the resulting methods, recently introduced in a series of papers [44,45, 48, 49, 36], as multi-adaptive Galerkin methods. See also [40, 50, 35, 37].

    Figure 2: A simple mechanical system consisting of n = 5 particles exhibit-ing multiple time scales.

    Surprisingly, individual time-stepping (multi-adaptivity) has previouslyreceived little attention in the large literature on numerical methods forODEs, see e.g. [8, 29, 30, 5, 60, 1], but has been used to some extentfor specific applications, including specialized integrators for the n-bodyproblem [51, 9, 59], and low-order methods for conservation laws [53, 38, 10].Early attempts at individual time-stepping include [62, 63]. Recently, a newclass of related methods, known as asynchronous variational integrators

    (AVI) with individual time steps, has been introduced [42].To extend the standard cG(q) and dG(q) methods for (4), we modify

    the trial space V and the test space V to allow individual time steps foreach component. For i = 1, . . . , N , the time interval (0, T] is partitioned

    7

    Figure 3: Local time steps in a multi-adaptive solution of the 2D heatequation with a variable heat source localized to the center of the domain.

    into Mi subintervals, Ti = {Iij}Mij=1, with the length of each subinterval

    Iij = (ti,j1, tij] given by the local time step kij = tij ti,j1. The result-ing individual elements {(Iij, Ui|Iij )} are arranged in time slabs, collectingelements between common synchronized time levels {Tn}

    Mn=0, as shown in

    Figure 4. As discussed in [35], the multi-adaptive algorithm consists oftwo phases: the generation of time slabs and the solution of the discreteequations on each time slab. We return to the iteration on time slabs below.

    0

    i

    kij

    Kn

    T

    Iij

    ti,j1 tij

    Tn1 Tn

    Figure 4: A sequence of M = 4 time slabs for a system of size N = 6.

    For the multi-adaptive version of the standard cG(q) method, referred

    8

  • 8/6/2019 Automated Modeling

    12/140

    Figure 5: A multi-adaptive solution with individual time steps for the threedifferent components.

    to as the mcG(q) method, we define the trial and test spaces by

    V = {v [C([0, T])]N : vi|Iij Pqij (Iij), j = 1, . . . , M i, i = 1, . . . , N },

    V = {v : vi|Iij Pqij1(Iij), j = 1, . . . , M i, i = 1, . . . , N }.

    (8)

    In other words, V denotes the space of continuous piecewise polynomialsof degree q = qi(t) = qij, t Iij, and V denotes the space of (possiblydiscontinuous) piecewise polynomials of degree q 1. This is illustrated inFigure 5, showing the mcG(1) solution of a system with three componentswith individual partitions for the different components. The trial and testspaces for the multi-adaptive version of the standard dG(q) method, re-ferred to as the mdG(q) method, are defined similarly with discontinuoustrial and test functions, see [44] or [48].

    The mcG(q) method for (4) can now be defined as follows: Find U Vwith U(0) = u0, such thatT

    0(U , v) dt =

    T0

    (f(U, ), v) dt v V . (9)

    Rewriting (9) as a sequence of successive local problems for each component,

    9

    we obtain Iij

    Uiv dt =

    Iij

    fi(U, )v dt v Pqij1(Iij), (10)

    for each local interval Iij. For the solution of the discrete system given

    by (9), it is convenient to rewrite (10) in explicit form for the degrees offreedom {xijm}qijm=0 of the local polynomial Ui|Iij , corresponding to (7).

    This explicit form of (10) is given by

    xijm = xij0 +

    Iij

    w[qij ]m (ij(t)) fi(U(t), t) dt, m = 1, . . . , qij, (11)

    where {w[qij ]m }

    qijm=1 P

    qij1([0, 1]) is a set of polynomial weight functionsand ij maps Iij to (0, 1]: ij(t) = (t ti,j1)/(tij ti,j1).

    An example of multi-adaptive time-stepping taken from [35] is presentedin Figure 6, showing the solution and multi-adaptive time steps for thebistable equation (see [26, 57]),

    u u = u(1 u2) in (0, T],

    nu = 0 on ,

    u(, 0) = u0 in ,

    (12)

    on the unit cube = (0, 1) (0, 1) (0, 1) with T = 100 and = 0.0001.

    2 The Automation of Discrete Solution

    Depending on the model (1), the method used for the automatic discretiza-

    tion of (1), and the choice of discrete representation (V,V), the solution ofthe resulting discrete system of equations may require more or less work.

    Traditionally, the solution of the discrete system is obtained by someversion of Newtons method, with the linearized equations being solvedusing direct methods based on Gaussian elimination, or iterative methodssuch as the conjugate gradient method (CG) or GMRES in combinationwith a suitable choice of problem-specific preconditioner.

    Alternatively, direct fixed point iteration on the discrete equations (11)may be used. The fixed point iteration takes the form

    xn = g(xn1) = xn1 (xn1 g(xn1)) = xn1 F(xn1), (13)

    for n = 1, 2, . . ., converging to a unique solution of the equation F(x) x g(x) = 0 if the Lipschitz constant Lg of g satisfies Lg < 1.

    If the number of iterations remains small, fixed point iteration is a com-petitive alternative to standard Newton iteration. It is also an attractive

    10

  • 8/6/2019 Automated Modeling

    13/140

    Figure 6: Cross-section of solution (above) and multi-adaptive time steps(below) at time t = 10 for the bistable equation (12).

    11

    alternative for the iterative solution of the discrete equations on time slabsin multi-adaptive methods, since it avoids the formation of large Jacobianson time slabs. However, if the problem being solved is stiff, which is char-acterized by a large Lipschitz constant Lg > 1, simple fixed point iterationmay fail to converge.

    In adaptive fixed point iteration, the simple fixed point iteration (13) ismodified according to

    xn = (I )xn1 + g(xn1) = xn1 F(xn1), (14)

    with adaptively determined damping : RN RN. In [36], this idea isexplored for the iterative solution of the discrete equations on time slabs,based on ideas for the adaptive stabilization of stiff systems presented in[24], relying on the inherent property of the stiff problem itself: rapiddamping of high frequencies. The suitable damping is automaticallydetermined in each iteration, which in particular means that = I for anon-stiff problem.

    3 The Automation of Error Control

    Ideally, an algorithm for the solution of (1) should have the following prop-erties: Given a tolerance TOL > 0 and a functional L, the algorithm shallproduce a discrete solution U approximating the exact solution u of (1),such that

    (A) |L(e)| TOL, where e = U u;

    (B) the computational cost of obtaining the approximation U is minimal.

    The functional L is typically chosen to represent the error e in some outputquantity of interest, for example the error in the drag coefficient of an objectsuch as a car or an airplane in a numerical flow simulation. Other naturalchoices include L(e) = e(T) for a suitable choice of norm for functionson . Conditions (A) and (B) are satisfied by an adaptive algorithm, withthe construction of the discrete representation (V, V) based on feed-backfrom the computed solution.

    As discussed above, an adaptive algorithm typically involves a stoppingcriterion, indicating that the size of the error is less than the given tolerance,and a modification strategy to be applied if the stopping criterion is not

    satisfied. Often, the stopping criterion and the modification strategy arebased on an a posteriori error estimate E |L(e)|, estimating the errore = U u in terms of the residual R(U) = U f(U) and the solution ofa continuous dual problem connecting to the stability of (1).

    12

  • 8/6/2019 Automated Modeling

    14/140

  • 8/6/2019 Automated Modeling

    15/140

  • 8/6/2019 Automated Modeling

    16/140

    definition. We define a model of the form (1) to be parabolic if computa-tional solution is possible over long time without error accumulation, i.e.,if the stability factor S(T) remains bounded and of moderate size as Tincreases. A more detailed discussion on this subject can be found in [25].For a typical hyperbolic problem, the corresponding stability factor S(T)grows linearly in time, while for more general models the growth may bepolynomial or even exponential in time.

    We consider two basic examples with very different stability properties;the first one is a parabolic system of chemical reactions and the second oneis the Lorenz system which has an exponentially growing stability factor.

    The first example is the following system of reactiondiffusion equations,discussed in more detail in [57, 45]:

    u1 u1 = u1u22,

    u2 u2 = u1u22,

    (29)

    on (0, 100] with = (0, 1) (0, 0.25), = 0.0001, and homogeneousNeumann boundary conditions. With the initial conditions chosen to obtaina reaction front moving through the domain , the stability factor for thecomputation of the solution at final time at a given point in grows asshown in Figure 7. We note that the stability factor peaks at the timeof active reaction, and that before and after the reaction front has sweptthe region of observation, the stability factor S(T) is significantly smaller,indicating parabolicity for large values of T.

    Our second example is the Lorenz system, given by

    x = (y x),y = rx y xz,z = xy bz,

    (30)

    with = 10, b = 8/3, r = 28, and initial value (x(0), y(0), z(0)) = (1, 0, 0).The solution u(t) = (x(t), y(t), z(t)), shown in Figure 8 for T = 40, isvery sensitive to perturbations and is often said to be chaotic. With ourperspective, this is reflected by the rapid growth of the stability factor S(T),as shown in Figure 9. The stability factor grows on the average as 10T/3,which limits the computability of the Lorenz system to time T = 50 withstandard double precision arithmetic.

    Multi-AdaptivityThe a priori and a posteriori error analysis presented above extends natu-rally to the general multi-adaptive methods mcG(q) and mdG(q), as shownin [44, 45, 48, 49]. In particular, we obtain a priori error estimates showing

    17

    0 10 20 30 40 60 70 80 90 1000

    10

    20

    30

    40

    50

    60

    70

    80

    T

    S(T)

    Figure 7: The growth of the stability factor S(T) for the reaction frontproblem (29).

    0 10 20 30 4030

    20

    10

    0

    10

    20

    30

    40

    50

    20 10 0 10 200

    5

    10

    15

    20

    25

    30

    35

    40

    45

    50

    x

    z

    t

    U(t)

    Figure 8: The solution of the Lorenz system (30) on the time interval [0, 40].

    18

  • 8/6/2019 Automated Modeling

    17/140

  • 8/6/2019 Automated Modeling

    18/140

  • 8/6/2019 Automated Modeling

    19/140

    Figure 10: Simplified component diagram showing the modularized struc-ture ofDOLFIN.

    23

    class Poisson : PDE

    {

    real lhs(ShapeFunction u, ShapeFunction v)

    {

    return (grad(u),grad(v)) * dx;

    }real rhs(ShapeFunction v)

    {

    return f*v * dx;

    }

    }

    Table 1: Sketch of the sp ecification of the variational formulation of Pois-sons equation in DOLFIN.

    on some domain . Assuming homogeneous Dirichlet boundary conditions,the variational (weak) formulation of (39) takes the form: Find u H10(),such that

    (u, v) dx =

    fvdx v H10 (). (40)

    The specification of (40) in DOLFIN is given in Table 1, and consist ofthe specification of the two variational forms lhs and rhs, representing theleft- and right-hand sides of (40), respectively.

    Automatic Assembly

    DOLFIN automatically assembles the discrete system representing a givenvariational formulation, based on the automatic evaluation of variationalforms. This automates a large part of the implementation of a solver. Inthe case of Poissons equation, the algorithm becomes particularly simple:assemble the discrete system consisting of a matrix (the stiffness matrix)and a vector (the load vector), and solve the linear system.

    Automation of all parts of DOLFIN makes the implementation short,simple and clear at all levels. In fact, the algorithm for the automaticassembly is just a couple of lines, as shown in Table 2.

    Adaptive Mesh Refinement

    The concept of a mesh is central in the implementation of adaptive Galerkinfinite element methods for partial differential equations. Other importantconcepts include nodes, cells, edges, faces, boundaries, and mesh hierarchies.

    24

  • 8/6/2019 Automated Modeling

    20/140

    for (CellIterator cell(mesh); !cell.end(); ++cell)

    for (TestFunctionIterator v(element); !v.end(); ++v)

    for (TrialFunctionIterator u(element); !u.end(); ++u)

    A(v.dof(), u.dof()) += pde.lhs(u,v);

    for (CellIterator cell(mesh); !cell.end(); ++cell)for (TestFunctionIterator v(element); !v.end(); ++v)

    b(v.dof) += pde.rhs(v);

    Table 2: Sketch of the implementation of automatic assembly in DOLFIN.

    for (CellIterator c(m); !c.end(); ++c)

    for (NodeIterator n1(c); !n1.end(); ++n1)

    for (NodeIterator n2(n1); !n2.end(); ++n2)

    cout

  • 8/6/2019 Automated Modeling

    21/140

  • 8/6/2019 Automated Modeling

    22/140

    bistable equation, the NavierStokes equations, and general systems ofconvectiondiffusionreaction equations (see Figure 14 and 15).

    Figure 14: Solution of the bistable equation (12) in Puffin.

    Figure 15: Solution of the driven cavity problem for the NavierStokesequations in Puffin.

    29

    8 Summary of Appended Papers

    PAPER I: Multi-Adaptive Galerkin Methods for ODEs I

    This paper introduces the multi-adaptive Galerkin methods mcG(q) andmdG(q) for initial value problems for ordinary differential equations and

    contains the a posteriori error analysis of the methods.

    PAPER I I: Multi-Adaptive Galerkin Methods for ODEs II:

    Implementation and Applications

    Continuing from PAPER I, this paper discusses the implementation of themcG(q) and mdG(q) methods, in particular the adaptive algorithm basedon the a posteriori error estimates from PAPER I. This paper also discussesa number of applications of the multi-adaptive methods, and includes anevaluation of the performance of the multi-adaptive methods.

    PAPER II I: Multi-Adaptive Galerkin Methods for ODEs III:Existence and Stability

    This paper contains proofs of existence and stability for the discrete multi-adaptive solutions, which is an important step in the proof of a priori errorestimates for the multi-adaptive methods.

    PAPER IV: Multi-Adaptive Galerkin Methods for ODEs IV:

    A Priori Error Estimates

    Based on the stability estimates of PAPER III and a pair of special in-terpolation estimates proved in PAPER VII and PAPER VIII, this paper

    contains the proofs of the a priori error estimates for the multi-adaptivemethods mcG(q) and mdG(q).

    PAPER V: Multi-Adaptive Galerkin Methods for ODEs V:

    Stiff Problems

    This paper extends the applicability of the multi-adaptive methods to stiffproblems. In particular, a new strategy for adaptive fixed point iterationon time slabs is presented, based on ideas of adaptive stabilization of stiffproblems presented in PAPER VI.

    PAPER VI: Explicit Time-Stepping for Stiff ODEs

    This paper presents new ideas for adaptive stabilization of stiff problems,making it possible to solve stiff problems with explicit methods.

    30

  • 8/6/2019 Automated Modeling

    23/140

    PAPER VI I: Interpolation Estimates for Piecewise Smooth

    Functions in One Dimension

    This paper contains basic interpolation estimates for piecewise smooth func-tions. These estimates are used in the a priori error analysis of the multi-adaptive methods, where interpolation estimates are needed for functions

    with discontinuities.

    PAPER VII I: Estimates of Derivatives and Jumps Across Ele-

    ment Boundaries for Multi-Adaptive Galerkin Solutions of ODEs

    The interpolation estimates proved in PAPER VII are expressed in terms ofthe jumps in function values and derivatives at the points of discontinuityfor the interpolated function. This paper estimates the size of these jumpsfor the discrete multi-adaptive solutions.

    PAPER IX: Algorithms for Multi-Adaptive Time-Stepping

    This paper presents the key algorithms for multi-adaptive time-stepping,including the recursive construction of time slabs and adaptive fixed pointiteration on time slabs.

    PAPER X: Simulation of Mechanical Systems with Individual

    Time Steps

    This paper discusses the application of the multi-adaptive methods to me-chanical systems, in particular to large mass-spring systems modeling de-formable solids. The performance of the multi-adaptive methods is exam-ined, both for stiff and non-stiff problems.

    PAPER XI: Computational Modeling of Dynamical Systems

    This paper is a short note on the basic approach to automated computa-tional modeling of dynamical systems.

    31 32

  • 8/6/2019 Automated Modeling

    24/140

  • 8/6/2019 Automated Modeling

    25/140

    [43] A. Logg, Tanganyika, http://www.phi.chalmers.se/tanganyika/.

    [44] , Multi-adaptive Galerkin methods for ODEs I, SIAM J. Sci. Comput., 24(2003), pp. 18791902.

    [45] , Multi-adaptive Galerkin methods for ODEs II: Implementation and applica-tions, SIAM J. Sci. Comput., 25 (2003), pp. 11191141.

    [46] , Estimates of derivatives and jumps across element boundaries for multi-

    adaptive Galerkin solutions of ODEs, Tech. Rep. 200403, Chalmers Finite ElementCenter Preprint Series, 2004.

    [47] , Interpolation estimates for piecewise smooth functions in one dimension,Tech. Rep. 200402, Chalmers Finite Element Center Preprint Series, 2004.

    [48] , Multi-adaptive Galerkin methods for ODEs III: Existence and stability, sub-mitted to SIAM J. Numer. Anal., (2004).

    [49] , Multi-adaptive Galerkin methods for ODEs IV: A priori error estimates,submitted to SIAM J. Numer. Anal., (2004).

    [50] , Multi-adaptive time-integration, Applied Numerical Mathematics, 48 (2004),pp. 339354.

    [51] J. Makino and S. Aarseth, On a Hermite integrator with Ahmad-Cohen schemefor gravitational many-body problems, Publ. Astron. Soc. Japan, 44 (1992), pp. 141151.

    [52] I. Newton, Philosophiae Naturalis Principia Mathematica, vol. IIII, 1687.

    [53] S. Osher and R. Sanders, Numerical approximations to nonlinear conservationlaws with locally varying time and space grids , Math. Comp., 41 (1983), pp. 321336.

    [54] P.G. Ciarlet, Numerical Analysis of the Finite Element Method, Les Presses delUniversite de Montreal, 1976.

    [55] R.C. Kirby, A linear algebraic approach to representing and computing finite ele-ments, submitted to Math. Comp., (2003).

    [56] W. Ritz, Uber eine neue Methode zur Losung gewisser Variationsprobleme dermathematischen Physik, J. reine angew. Math., 135 (1908), pp. 161.

    [57] R. Sandboge, Adaptive Finite Element Methods for Reactive Flow Problems, PhD

    thesis, Department of mathematics, Chalmers University of Technology, Goteborg,1996.

    [58] S.C. Brenner and L.R. Scott, The Mathematical Theory of Finite Element Meth-ods, Springer-Verlag, 1994.

    [59] S.G. Alexander and C.B. Agnor, n-body simulations of late stage planetary formation with a simple fragmentation model, ICARUS, 132 (1998), pp. 113124.

    [60] L. Shampine, Numerical Solution of Ordinary Differential Equations, Chapman &Hall, 1994.

    [61] G. Strang and G.J. Fix, An Analysis of the Finite Element Method, Prentice-Hall,Englewood Cliffs, 1973.

    [62] T.J.R Hughes, I. Levit, and J. Winget, Element-by-element implicit algorithmsfor heat-conduction, J. Eng. Mech.-ASCE, 109 (1983), pp. 576585.

    [63] , An element-by-element solution algorithm for problems of structural and solidmechanics, Computer Methods in Applied Mechanics and Engineering, 36 (1983),pp. 241254.

    35

  • 8/6/2019 Automated Modeling

    26/140

  • 8/6/2019 Automated Modeling

    27/140

  • 8/6/2019 Automated Modeling

    28/140

  • 8/6/2019 Automated Modeling

    29/140

  • 8/6/2019 Automated Modeling

    30/140

  • 8/6/2019 Automated Modeling

    31/140

  • 8/6/2019 Automated Modeling

    32/140

  • 8/6/2019 Automated Modeling

    33/140

  • 8/6/2019 Automated Modeling

    34/140

  • 8/6/2019 Automated Modeling

    35/140

  • 8/6/2019 Automated Modeling

    36/140

  • 8/6/2019 Automated Modeling

    37/140

  • 8/6/2019 Automated Modeling

    38/140

  • 8/6/2019 Automated Modeling

    39/140

  • 8/6/2019 Automated Modeling

    40/140

  • 8/6/2019 Automated Modeling

    41/140

  • 8/6/2019 Automated Modeling

    42/140

  • 8/6/2019 Automated Modeling

    43/140

    MULTI-ADAPTIVE GALERKIN METHODS FOR ODEs II 1129

    5 10 15 200

    2

    4

    6

    8

    x 105

    5 10 15 200

    5

    10

    15

    20

    5 10 15 200

    1

    2

    3

    4x 10

    4

    5 10 15 200

    2

    4

    6

    8

    10

    x 106

    e(T)

    cputime/seconds

    functionevaluations

    steps

    20 40 60 80 1000

    2

    4

    6

    8

    x 105

    20 40 60 80 1000

    10

    20

    30

    40

    50

    60

    70

    20 40 60 80 1000

    0.5

    1

    1.5

    2x 10

    5

    20 40 60 80 1000

    1

    2

    3

    4

    5

    x 107

    e(T)

    cputime/seconds

    functionevaluations

    steps

    Fig. 5.2. Error, cpu time, total number of steps, and number of function evaluations as functionof the number of masses for the multi-adaptive cG(1) method (dashed lines) and the standard cG(1)method (solid lines).

    1130 ANDERS LOGG

    0 10 20 30 4030

    20

    10

    0

    10

    20

    30

    40

    50

    20 10 0 10 200

    5

    10

    15

    20

    25

    30

    35

    40

    45

    50

    x

    zU

    t

    Fig. 5.3. On the right is the trajectory of the Lorenz system for final time T = 40, computed withthe multi-adaptive cG(5) method. On the left is a plot of the time variation of the three components.

    The computational challenge is to solve the Lorenz system accurately on a time-interval [0, T] with T as large as possible. In Figure 5.3 is shown a computed solutionwhich is accurate on the interval [0 , 40]. We investigate the computability of theLorenz system by solving the dual problem and computing stability factors to findthe maximum value of T. The focus in this section is not on multi-adaptivitywewill use the same time-steps for all components, and so mcG(q) becomes cG(q)buton higher-order methods and the precise information that can be obtained about thecomputability of a system from solving the dual problem and computing stability

    factors.As an illustration, we present in Figure 5.4 solutions obtained with different meth-ods and constant time-step k = 0.1 for all components. For the lower-order methods,cG(5) to cG(11), it is clear that the error decreases as we increase the order. Startingwith the cG(12) method, however, the error does not decrease as we increase theorder. To explain this, we note that in every time-step a small round-off error of size 1016 is introduced if the computation is carried out in double precision arithmetic.These errors accumulate at a rate determined by the growth of the stability factorfor the computational error (see [10]). As we shall see below, this stability factorgrows exponentially for the Lorenz system and reaches a value of 1016 at final timeT = 50, and so at this point the accumulation of round-off errors results in a largecomputational error.

  • 8/6/2019 Automated Modeling

    44/140

    MULTI-ADAPTIVE GALERKIN METHODS FOR ODEs II 1131

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    cG(5)

    cG(6)

    cG(7)

    cG(8)

    cG(9)

    cG(10)

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    0 10 20 30 40 50 60 70 80 90 10020

    0

    20

    cG

    (11)

    cG(12)

    cG(13)

    cG(14)

    cG(15)

    Fig. 5.4. Solutions for the x-component of the Lorenz system with methods of different order,using a constant time-step k = 0.1. Dotted lines indicate the point beyond which the solution is nolonger accurate.

    1132 ANDERS LOGG

    0 5 10 15 20 30 35 40 45 50

    100

    102

    104

    106

    108

    1010

    1012

    1014

    1016

    T

    S[0](T)

    Fig. 5.5. The stability factor for computational and quadrature errors, as function of time forthe Lorenz system.

    5.2.1. Stability factors. We now investigate the computation of stability fac-tors for the Lorenz system. For simplicity we focus on global stability factors, suchas

    S[q](T) = maxv=1

    T0

    (q)(t) dt,(5.2)

    where (t) is the solution of the dual problem obtained with (T) = v (and g = 0).Letting (t) be the fundamental solution of the dual problem, we have

    maxv=1

    T

    0

    (q)(t)v dt

    T

    0

    maxv=1

    (q)(t)v dt =

    T

    0

    (q)(t) dt= S[q](T).(5.3)

    This gives a bound S[q](T) for S[q](T), which for the Lorenz system turns out to bequite sharp and which is simpler to compute since we do not have to compute themaximum in (5.2).

    In Figure 5.5 we plot the growth of the stability factor for q = 0, corresponding tocomputational and quadrature errors as described in [10]. The stability factor growsexponentially with time, but not as fast as indicated by an a priori error estimate.An a priori error estimate indicates that the stability factors grow as

    S[q](T) AqeAT,(5.4)

  • 8/6/2019 Automated Modeling

    45/140

  • 8/6/2019 Automated Modeling

    46/140

  • 8/6/2019 Automated Modeling

    47/140

  • 8/6/2019 Automated Modeling

    48/140

  • 8/6/2019 Automated Modeling

    49/140

    MULTI-ADAPTIVE GALERKIN METHODS FOR ODEs II 1141

    [10] A. Logg, Multi-adaptive Galerkin methods for ODEs I, SIAM J. Sci. Comput., 24 (2003),

    pp. 18791902.[11] A. Logg, Multi-Adaptive Galerkin Methods for ODEs II: Applications, Preprint 2001-10,Chalmers Finite Element Center, Chalmers University of Technology, Goteborg, Sweden,2001. Also available online from http://www.phi.chalmers.se/preprints/.

    [12] A. Logg, Tanganyika, Version1.2, 2001. http://www.phi.chalmers.se/tanganyika/.[13] W. Press, S. Teukolsky, W. Vetterling, and B. Flannery, Numerical Recipes in C. The

    Art of Scientific Computing, 2nd ed., Cambridge University Press, Cambridge, UK, 1992.Also available online from http://www.nr.com.

    [14] R. Sandboge, Adaptive Finite Element Methods for Reactive Flow Problems, Ph.D. thesis,Department of Mathematics, Chalmers University of Technology, Goteborg, Sweden, 1996.

    [15] G. Soderlind, The automatic control of numerical integration. Solving differential equationson parallel computers, CWI Quarterly, 11 (1998), pp. 5574.

  • 8/6/2019 Automated Modeling

    50/140

  • 8/6/2019 Automated Modeling

    51/140

  • 8/6/2019 Automated Modeling

    52/140

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES III 7 8 ANDERS LOGG

  • 8/6/2019 Automated Modeling

    53/140

    with U Pq([0, 1]). Let now {[q]n }

    qn=0 be a basis for P

    q([0, 1]). In terms of

    this basis, we have U(t) =

    qn=0 n

    [q]n (t), and so

    qn=0

    n1

    0[q]n [q1]m dt =

    10

    f [q1]m dt, m = 0, . . . , q 1.

    Since the solution is continuous, the value at t = 0 is known from theprevious interval (or from the initial condition). This gives

    U(0) =

    qn=0

    n[q]n (0) = 0,

    if we assume that [q]n (0) = 0n. The remaining q degrees of freedom are

    then determined byq

    n=1n1

    0 [q]n

    [q1]

    m1 dt =1

    0 f [q1]

    m1 01

    0 [q]

    0 [q1]

    m1 dt, m = 1, . . . , q .

    If det1

    0 [q]n

    [q1]m1 dt

    = 0, this system can be solved for the degrees of

    freedom (1, . . . , n). With [q]n (t) = tn, we have

    det

    10

    [q]n [q1]m1 dt

    = det

    10

    ntn1tm1 dt

    = det

    n

    m + n 1

    = 0,

    by Lemma 3.1. Solving for (1, . . . , n), we obtain

    n = [q]n 0 +

    1

    0w[q]n f dt, n = 1, . . . , q ,

    for some constants {[q]n }

    qn=1, where {w

    [q]n }

    qn=1 P

    q1([0, 1]) and 0 is deter-

    mined from the continuity requirement. For any other basis {[q]n }

    qn=0 with

    [q]n (0) = 0n, we obtain a similar expression for the degrees of freedom by

    a linear transformation. In particular, let {[q]n }

    qn=0 be the Lagrange basis

    functions for a partition of [0, 1] with t = 0 as a nodal point. For f 0 itis easy to see that the mcG(q) solution is constant and equal to its initial

    value. It follows that [q]n = 1, n = 1, . . . , q, and so

    n = 0 +

    10

    w[q]n f dt, n = 1, . . . , q ,

    with U(1) = q if also t = 1 is a nodal point. To see that w[q]q 1, takev 1 in (2.3). The result now follows by rescaling to Iij.

    Lemma 3.3. The mdG(q) method for (1.1) in fixed point form reads: Fori = 1, . . . , N , j = 1, . . . , M i, find {ijn}

    qijn=0, such that

    (3.2) ijn =

    ij0 +

    Iij

    w[qij]n (ij(t))fi(U(t), t) dt,

    with

    ij0 =

    i,j1,qi,j1, j > 1,ui(0), j = 1,

    where {w[qij]n }qijn=0 Pqij([0, 1]), w[qij]qij 1, and ij(t) = (t ti,j1)/(tij ti,j1). A component Ui(t) of the solution is given on Iij by

    Ui(t) =

    qijn=0

    ijn[qij]n (ij(t)),

    where {[qij]n }

    qijn=0 P

    qij([0, 1]) is the standard Lagrange basis on [0, 1] witht = 1 as one of its qij + 1 1 nodal points.

    Proof. In as similar way as in the proof of Lemma 3.2, we use (2.7) to obtain

    (0

    0 )[q]m (0) +

    q

    n=0

    n 1

    0

    [q]n [q]m dt =

    1

    0

    f [q]m dt, m = 0, . . . , q .

    With [q]n (t) = tn, these 1 + q equations can be written in the form

    0 +

    qn=1

    n

    10

    ntn1 dt =

    10

    f dt + 0 ,

    qn=1

    n

    10

    ntn1tm dt =

    10

    f tm dt, m = 1, . . . , q ,

    which by Lemma 3.1 has a solution, since

    det1

    0

    ntn1tm dt

    = det

    nm + n

    = 0.

    We thus obtain

    n = [q]n

    0 +

    10

    w[q]n f dt, n = 0, . . . , q .

    By the same argument as in the proof of Lemma 3.2, we conclude that when

    {[q]n }

    qn=0 is the Lagrange basis for a partition of [0 , 1], we have

    n =

    0 +

    10

    w[q]n f dt, n = 0, . . . , q ,

    with U(1) = q =

    0 +1

    0 f dt if t = 1 is a nodal point. The result nowfollows by rescaling to Iij.

    Lemma 3.4. The mcG(q) method for (2.9) in fixed point form reads: For

    i = 1, . . . , N , j = Mi, . . . , 1, find {ijn}qij1n=0 , such that

    (3.3) ijn = i +

    Ttij

    fi (, ) dt +

    Iij

    w[qij]n (ij(t))f

    i ((t), t) dt,

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES III 9 10 ANDERS LOGG

  • 8/6/2019 Automated Modeling

    54/140

    where f(, ) = J(u,U, ) + g, {w[qij]n }

    qij1n=0 P

    qij([0, 1]), w[qij]n (0) = 0,

    w[qij]n (1) = 1, n = 0, . . . , qij 1, and ij(t) = (t ti,j1)/(tij ti,j1). A

    component i(t) of the solution is given on Iij by

    i(t) =

    qij1n=0

    ijn[qij1]n (ij(t)),

    where {[qij1]n }

    qij1n=0 P

    qij1([0, 1]) is the standard Lagrange basis on [0, 1].

    Proof. Our starting point is the definition (2.14). For any 1 i N,take vn 0 when n = i and let vi be a continuous piecewise polynomialthat vanishes on [0, ti,j1] with vi 1 on [tij, T], see Figure 3.4. Withf(, ) = J(u,U, ) + g, we then have

    Mil=j

    [i]ilvi(til)

    Iil

    ivi dt

    =Tti,j1

    fi (, )vi dt.

    We integrate by parts, moving the derivative onto the test function, to get

    [i]ilvi(til)

    Iil

    ivi dt = [i]ilvi(til) [ivi]til

    t+i,l1

    +

    Iil

    ivi dt

    = i(t+i,l1)vi(ti,l1) i(t

    +il )vi(til) +

    Iil

    ivi dt.

    Summing up, noting that vi(ti,j1) = 0, vi = 0 on [tij, T] and i(t+Mi

    ) = i,we have

    i +

    Iij

    ivi dt =

    Tti,j1

    fi (, )vi dt,

    or Iij

    ivi dt = ij +

    Iij

    fi (, )vi dt,

    with ij = i+Ttij

    fi (, ) dt. Dropping indices and rescaling to the interval

    [0, 1], we obtain

    1

    0

    v dt = (1) + 1

    0

    fv dt,

    for all v Pq([0, 1]) with v(0) = 0 and v(1) = 1. Let now {[q1]n }

    q1n=0 be a

    basis of Pq1([0, 1]) and write (t) =q

    n=1 n[q1]n1 (t). For m = 1, . . . , q,

    we then have

    qn=1

    n

    10

    [q1]n1 (t) mt

    m1 dt = (1) +

    10

    f tm dt.

    If now det1

    0 [q1]n1 (t)mt

    m1 dt

    = 0, we can solve for (1, . . . , n). With

    [q1]n1 (t) = t

    n1, we have

    det1

    0

    [q1]n1 (t)mtm1 dt

    = det1

    0

    mtn1tm1 dt

    = det

    mm + n 1

    = 0,

    by Lemma 3.1. Solving for the degrees of freedom, we obtain

    n = [q]n (1) +

    10

    w[q]n f dt, n = 1, . . . , q .

    By a linear transformation, we obtain a similar expression for any otherbasis of Pq([0, 1]). For f 0, it is easy to see that the mcG(q) solution

    is constant and equal to its initial value. Thus, when {[q1]n }

    q1n=0 is the

    standard Lagrange basis for a partition of [0, 1], it follows that [q]n = 1,

    n = 1, . . . , q, and so

    n = (1) +

    1

    0w[q]n f

    dt, n = 1, . . . , q .

    We note that w[q]n (0) = 0, n = 1, . . . , q, since each w

    [q]n is a linear combination

    of the functions {tm}qm=1. We also conclude that w

    [q]n (1) = 1, since w

    [q]n (1) =

    [q]n = 1, n = 1, . . . , q. The result now follows by rescaling to Iij. We also

    relabel the degrees of freedom from (1, . . . , q) to (0, . . . , q1).

    0 Tti,j1 ti,j

    vi(t)

    Figure 2. The special choice of test function used in theproof of Lemma 3.4.

    Lemma 3.5. The mdG(q) method for (2.9) in fixed point form reads: Fori = 1, . . . , N , j = Mi, . . . , 1, find {ijn}

    qijn=0, such that

    (3.4) ijn = +ijqij +

    Iij

    w[qij]n (ij(t))f

    i ((t), t) dt,

    with

    +ijqij =

    i,j+1,0, j < M i,i, j = Mi,

    where f(, ) = J(u,U, ) + g, {w[qij ]n }

    qijn=0 P

    qij([0, 1]), and ij(t) =(t ti,j1)/(tij ti,j1). A component i(t) of the solution is given on Iij

  • 8/6/2019 Automated Modeling

    55/140

  • 8/6/2019 Automated Modeling

    56/140

  • 8/6/2019 Automated Modeling

    57/140

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES III 17

    h i th t ti k t t t th t

    18 ANDERS LOGG

    h h l d th ti T K Th t th

  • 8/6/2019 Automated Modeling

    58/140

    where, using the notation km = tm tm1, we note that

    mtm2

    (W(tm), AW(t

    m)) (W(t

    m1), AW(t

    m1))

    =m

    tm2

    (W(tm), AW(t

    m)) tm1

    2(W(tm1), AW(t

    m1))

    km2

    (W(tm1), AW(t

    m1))

    =Tn2

    (W(Tn ), AW(T

    n )) Tn1

    2(W(Tn1), AW(T

    n1))

    m

    km2

    (W(tm1), AW(t

    m1)).

    Collecting the terms, we thus have

    m

    tm([W]m1, A[W]m1) + Tn(W(Tn ), AW(Tn )) Tn1(W(Tn1),AW(Tn1))

    +2

    TnTn1

    (AW,(tAW)) dt =m

    km(W(t

    m1), AW(t

    m1)).

    (4.16)

    For n = 1, we haveTnTn1

    (AW,(tAW)) dt = T1

    T10

    (AW,(AW)) dt = T1

    T10

    AW2 dt,

    since (AW) = AW on [0, T1], where the same time steps and orders areused for all components. We further estimate the right-hand side of (4.16)as follows:

    K1(w0, Aw0) = K1([W]0, A[W]0)K1(W(0+), AW(0+)) + 2K1(w0, AW(0+))

    T1([W]0, A[W]0) + 2K1(w0, AW(0+))

    T1([W]0, A[W]0) +1

    w0

    2 + K21AW(0+)2

    T1([W]0, A[W]0) +1

    w0

    2 + CqT1

    T10

    AW2 dt,

    where we have used an inverse estimate for AW on [0, T1]. With = 1/Cq,we thus obtain the estimate

    (4.17) T1(W(T

    1 ), AW(T

    1 )) + T1

    T10

    AW2 Cqw02.

    For n > 1, it follows by the assumption (4.11), thatTnTn1

    (AW,(tAW)) dt 1Tn1

    TnTn1

    AW2 dt

    and thus TnTn1

    (AW,(tAW)) dt 1

    + 1Tn

    TnTn1

    AW2 dt,

    where we have also used the assumption Tn1 Kn. The terms on theright-hand side of (4.16) are now estimated as follows:

    km(W(t

    m1), AW(t

    m1)) = km(W(t+m1) [W]m1,A(W(t

    +m1) [W]m1))

    = km

    (W(t+m1), AW(t+m1)) + ([W]m1, A[W]m1) 2(W(t

    +m1),A[W]m1)

    km

    (1 + )(W(t+m1), AW(t

    +m1)) + (1 +

    1)([W]m1,A[W]m1),

    for any > 0. Choosing = 1/( 1), we obtain the following bound forkm(W(t

    m1), AW(t

    m1)):

    km 1

    (W(t+m1), AW(t+m1)) + km([W]m1, A[W]m1)

    Cq

    1

    Im

    (W,AW) dt + km([W]m1, A[W]m1),

    where we have again used an inverse estimate, for W on Im. From theassumption that Kn Tn1 for n > 1, it follows that km Kn Tn1 tm, and so

    Tn(W(T

    n ), AW(T

    n )) Tn1(W(T

    n1), AW(T

    n1))

    +21

    + 1Tn

    TnTn1

    AW2 dt Cq

    1

    TnTn1

    (W,AW) dt.

    Summing over n > 1 and using the estimate (4.17) for n = 1, we obtain by(4.12),

    T (W(T

    ), AW(T

    )) + T1T1

    0 AW

    2

    dt +

    21

    + 1

    Mn=2 T

    nTnTn1 AW

    2

    dt

    Cqw02 +

    Cq

    1

    TT1

    (W,AW) dt Cq

    1 +

    /2

    1

    w0

    2,

    which we write as

    Mn=1

    Tn

    TnTn1

    AW2 dt Cw02,

    noting that T(W(T), AW(T)) 0. For the proof of (4.13), it now sufficesto prove that

    (4.18)

    TnTn1

    W dt C

    TnTn1

    AW2 dt,

    and

    (4.19)ij

    [Wi]2i,j1/kij C

    TnTn1

    AW2 dt.

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES III 19

    To prove (4 18) we take v (t t )W /k on each local interval I

    20 ANDERS LOGG

    Finally to prove (4 14) we use Cauchys inequality with (4 13) to get

  • 8/6/2019 Automated Modeling

    59/140

    To prove (4.18), we take vi = (t ti,j1)Wi/kij on each local interval Iijin (4.15), which gives

    ij

    Iij

    t ti,j

    1kij

    W2i dt = ij

    Iij

    (AW)i t ti,j

    1kij

    Wi dt

    ij

    Iij

    t ti,j1kij

    (AW)2i dt

    1/2 Iij

    t ti,j1kij

    W2i dt

    1/2

    ij

    Iij

    t ti,j1kij

    (AW)2i dt

    1/2

    ij

    Iij

    t ti,j1kij

    W2i dt

    1/2

    ,

    where we have used Cauchys inequality twice; first on L2(Iij) and then on

    l2. Using an inverse estimate for W2i , we obtain

    TnTn1

    W2 dt =ij

    Iij

    W2i dt Cqij

    Iij

    t ti,j1kij

    W2i dt

    Cqij

    Iij

    t ti,j1kij

    (AW)2i dt

    Cqij

    Iij

    (AW)2i dt = Cq

    TnTn1

    AW dt,

    which proves (4.18).To prove (4.19), we take vi = [Wi]i,j1/kij on each local interval Iij in

    (4.15), which gives

    ij

    [Wi]2i,j1/kij =

    ij

    Iij

    (Wi + (AW)i) [Wi]i,j1/kij dt

    ij

    Iij

    (Wi + (AW)i)2 dt

    1/2

    ij

    [Wi]2i,j1/kij

    1/2

    ,

    where we have again used Cauchys inequality twice. We thus have

    ij

    [Wi]2i,j1/kij 2

    TnTn1

    W2 dt + 2

    TnTn1

    AW2 dt,

    and so (4.19) follows, using (4.18). This also proves (4.13).

    Finally, to prove (4.14), we use Cauchys inequality with (4.13) to get

    M

    n=1

    Tn

    Tn1

    W dt =M

    n=1

    Kn/TnTn/Kn Tn

    Tn1

    W dt

    Mn=1

    Kn/Tn

    1/2 Mn=1

    Tn

    TnTn1

    W2 dt

    1/2

    1 +

    TT1

    1

    tdt

    1/2Cw0

    C(log(T /K1) + 1)1/2 w0,

    with a similar estimate for AW. The proof is now complete, noting that

    M

    n=1

    ij

    |[Wi]i,j1|2

    1/2

    M

    n=1

    KnTn

    Tnij

    |[Wi]i,j1|2/kij

    1/2

    Mn=1

    Kn/Tn

    1/2 Mn=1

    Tnij

    |[Wi]i,j1|2/kij

    1/2

    C(log(T /K1) + 1)1/2 w0.

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES III 21

    References

  • 8/6/2019 Automated Modeling

    60/140

    References

    [1] K. Eriksson and C. Johnson, Adaptive finite element methods for parabolic problemsI: A linear model problem, SIAM J. Numer. Anal., 28, No. 1 (1991), pp. 4377.

    [2] K. Eriksson, C. Johnson, and A. Logg, Adaptive computational methods for par-abolic problems, To appear in Encyclopedia of Computational Mechanics, (2004).

    [3] C. Johnson, Error estimates and adaptive time-step control for a class of one-stepmethods for stiff ordinary differential equations, SIAM J. Numer. Anal., 25 (1988),pp. 908926.

    [4] A. Logg, Multi-adaptive Galerkin methods for ODEs I, SIAM J. Sci. Comput., 24(2003), pp. 18791902.

    [5] , Multi-adaptive Galerkin methods for ODEs II: Implementation and applications ,SIAM J. Sci. Comput., 25 (2003), pp. 11191141.

    [6] , Interpolation estimates for piecewise smooth functions in one dimension, Tech.Rep. 200402, Chalmers Finite Element Center Preprint Series, 2004.

    [7] , Multi-adaptive Galerkin methods for ODEs IV: A priori error estimates, Sub-mitted to SIAM J. Numer. Anal., (2004).

    [8] P. Niamsup and V. N. Phat, Asymptotic stability of nonlinear control systems de-

    scribed by difference equations with multiple delays, Electronic Journal of DifferentialEquations, 11 (2000), pp. 117.

  • 8/6/2019 Automated Modeling

    61/140

  • 8/6/2019 Automated Modeling

    62/140

  • 8/6/2019 Automated Modeling

    63/140

  • 8/6/2019 Automated Modeling

    64/140

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES IV 9 10 ANDERS LOGG

    for all time slabs T. We further assume that there is a constant ck > 0, suchthat

  • 8/6/2019 Automated Modeling

    65/140

    Iijti,j1 tij

    i(t)

    l(t)

    Figure 2. If some other component l = i has a node withinIij, then l may be discontinuous within Iij , causing i tobe discontinuous within Iij.

    Lemma 4.1. (Interpolation estimates for ) Let be defined as in (4.9). Ifassumptions (A1)(A5) hold, then there is a constant C = C(q, ck, ) > 0,such that

    (4.10) [qij2]cG i iL(Iij) Ck

    qij1ij f

    qijT L(T,l), qij = q 2,

    and

    (4.11) [qij1]dG i iL(Iij) Ck

    qijij f

    qij+1T L(T,l), qij = q 1,

    for each local interval Iij within the time slab T.

    Proof. See [6].

    4.2. Linear problems. For the linear problem (2.5), we make the followingbasic assumptions: Given a time slab T, assume that for each pair of localintervals Iij and Imn within the time slab, we have

    (B1) qij = qmn = q,

    and

    (B2) kij > kmn,

    for some q 0 and some (0, 1). Furthermore, assume that A has q 1continuous derivatives and let CA > 0 be constant, such that

    (B3) max

    A(p)L(T,l), A(p)L(T,l)

    C

    p+1A , p = 0, . . . , q,

    that

    (B4) kijCA ck.

    We summarize the list of assumptions as follows:

    (B1) the local orders qij are equal within each time slab;(B2) the local time steps kij are semi-uniform within each time slab;(B3) A and its derivatives are bounded;(B4) the local time steps kij are small.

    As for the general non-linear problem, we need to estimate the interpola-tion error i i on a local interval Iij , where i is now defined by

    (4.16) i = (A)i =

    Nl=1

    Alil, i = 1, . . . , N .

    Using assumptions (B1)(B4), we obtain the following interpolation esti-mates for the function .

    Lemma 4.2. (Interpolation estimates for ) Let be defined as in (4.16).If assumptions (B1)(B4) hold, then there is a constant C = C(q, ck , ) > 0,such that

    (4.17) [qij2]cG i iL(Iij) Ck

    qij1ij C

    qijA L(T,l), qij = q 2,

    and

    (4.18) [qij1]dG i iL(Iij) Ck

    qijij C

    qij+1A L(T,l), qij = q 1,

    for each local interval Iij within the time slab T.

    Proof. See [6].

    5. A priori error estimates

    Using the error representations derived in Section 3, the interpolationestimates of the previous section, and the stability estimates from [8], we nowderive our main results: a priori error estimates for general order mcG(q) andmdG(q). The estimates are derived first for the general non-linear problem(1.1), then for the general linear problem (2.5), and finally for a parabolicmodel problem.

    5.1. The general non-linear problem.

    Theorem 5.1. (A priori error estimate for mcG(q)) Let U be the mcG(q)solution of (1.1), and let be the corresponding mcG(q) solution of thedual problem (2.4). Then, there is a constantC = C(q) > 0, such that

    (5.1) |L,g(e)| CS(T)kq+1uq+1L([0,T],l2),

  • 8/6/2019 Automated Modeling

    66/140

  • 8/6/2019 Automated Modeling

    67/140

  • 8/6/2019 Automated Modeling

    68/140

  • 8/6/2019 Automated Modeling

    69/140

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES IV 19

    Note that we use an interpolation estimate for Aqu which is straightforwardsince the exact solution u is smooth. We conclude by estimating the stabilityf S(T ) f 0 1 i h bili i f h di

    20 ANDERS LOGG

    Table 1, and Table 2, it is clear that the predicted order of convergence isobtained, both for mcG(q) and mdG(q).

  • 8/6/2019 Automated Modeling

    70/140

    factor S(T) for q = 0, 1, using the strong stability estimate for the discretedual solution . For q = 0, it follows directly by Theorem 4.3 in [8], that

    S(T) =

    T0

    Al2 dt C

    log

    T

    KM+ 1

    1/2,

    and for q = 1, we obtain

    S(T) =

    T0

    k1( [0]dG)l2 dt C

    T0

    l2 dt,

    using an interpolation estimate in combination with an inverse estimate, and

    so the estimate S(T) C

    log TKM + 11/2

    follows again by Theorem 4.3 in

    [8].

    The stability factor S(T) that appears in the a priori error estimate is

    obtained from the discrete solution of the dual problem (2.6), and canthus be computed exactly by solving the discrete dual problem. Allowingnumerical computation of the stability factor, the additional assumptions(C3)(C6) needed to obtain the analytical bound for S(T) are no longerneeded. Numerical computation of the stability factor also directly revealswhether the problem is parabolic or not; if the stability factor is of unit sizeand does not grow, then the problem is parabolic by definition, see [2].

    6. Numerical examples

    We conclude by demonstrating the convergence of the multi-adaptivemethods in the case of a simple test problem. We also present some re-sults in support of assumption (C3).

    6.1. Convergence. Consider the problem

    u1 = u2,

    u2 = u1,

    u3 = u2 + 2u4,

    u4 = u1 2u3,

    u5 = u2 2u4 + 4u6,

    u6 = u1 + 2u3 4u5,

    (6.1)

    on [0, 1] with initial condition u(0) = (0, 1, 0, 2, 0, 3). The solution is givenby u(t) = (sin t, cos t, sin t + sin 2t, cos t + cos 2t, sin t + sin2t + sin4t, cos t +cos2t+cos4t). For given k0 > 0, we take ki(t) = k0 for i = 1, 2, ki(t) = k0/2for i = 3, 4, and ki(t) = k0/4 for i = 5, 6, and study the convergence of theerror e(T)l2 with decreasing k0. From the results presented in Figure 3,

    102

    101

    100

    1016

    1014

    1012

    10

    10

    108

    106

    104

    102

    100

    k0

    e(T)

    l2

    cG(1)

    cG(2)

    cG(3)

    cG(4)

    cG(5)

    dG(0)

    dG(1)

    dG(2)

    dG(3)

    dG(4)

    dG(5)

    Figure 3. Convergence of the error at final time for thesolution of the test problem (6.1) with mcG(q) and mdG(q),

    q 5.

    mcG(q) 1 2 3 4 5p 1.99 3.96 5.92 7.82 9.672q 2 4 6 8 10

    Table 1. Order of convergence p for mcG(q).

    mdG(q) 0 1 2 3 4 5p 0.92 2.96 4.94 6.87 9.10

    2q + 1 1 3 5 7 9 11

    Table 2. Order of convergence p for mdG(q).

  • 8/6/2019 Automated Modeling

    71/140

  • 8/6/2019 Automated Modeling

    72/140

  • 8/6/2019 Automated Modeling

    73/140

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES V 5

    which is Newtons method for the solution of (2.2).We now present an algorithm for stabilized fixed point iteration which

    adaptively determines the damping factor , and which avoids computing

    6 JOHAN JANSSON AND ANDERS LOGG

    Im

  • 8/6/2019 Automated Modeling

    74/140

    p y p g , p gthe Jacobian F and solving a linear system in each iteration as in Newtons

    method. We focus on the case where is either diagonal or scalar.

    3.1. Diagonal damping. Let = diag(1, . . . , N) be a diagonal matrix,and assume for simplicity that g is constant and equal to B. With thischoice of , the fixed point iteration is given by

    (3.6) xni = (1 i)xn1i + igi(xn1), i = 1, . . . , N ,or xn = Gx

    n1, with G = I (I + B). We assume that(1) B is diagonally dominant, and(2) Bii 0, i = 1, . . . , N .

    By (3.4), it follows that the fixed point iteration converges for Gl < 1,where Gl denotes the maximum absolute row sum, For i = 1, . . . , N ,we have

    Nj=1

    |(G)ij| = |1 i iBii|+ ij=i

    |Bij| |1 Bii| + iBii,

    since B is diagonally dominant and Bii 0. We now take(3.7) i = 1/(1 + Bii),

    which gives Nj=1 |(G)ij| = Bii/(1+ Bii) < 1. We thus conclude that ifB isdiagonally dominant and Bii 0 for each i, then we can choose diagonalsuch that the stabilized fixed point iteration (3.1) converges. We also notethat the convergence may be slow if some Bii 1, since then Bii/(1 + Bii)is close to unity.

    3.2. Scalar damping. With (0, 1] scalar, we assume as above thatg = B is constant. We further assume that

    (1) B is non-defective, i.e., B is diagonalizable:

    V = v1 vN non-singular : V1BV = diag(1, . . . , N),with 1, . . . , N the eigenvalues of B;(2) Re i > 1 for all i;

    (3) |Im i|/(1+Re i) tan , for some (0, /2), i.e., |arg(1+i) | for all i, as illustrated in Figure 2.

    Note that the first condition is not a major restriction. If B should bedefective, B will be made non-defective by a small perturbation, which willalways be introduced through round-off errors.

    Re

    1

    Figure 2. The eigenvalues of the matrix B are assumedto lie within the shaded sector.

    To determine the size of , we write the error en1 in the form en1 =Ni=1 e

    n1i v

    i. By (3.4), it follows that

    en = (I (I + B))N

    i=1

    en1i vi =

    N

    i=1

    en1i (1 (1 + i))vi =N

    i=1

    ien1i v

    i,

    where i = 1 (1 + i). It follows that the stabilized fixed point iterationconverges if we take such that |i| < 1 for i = 1, . . . , N . With

    (3.8) =cos

    1 + maxi |i| ,

    we obtain

    |i|2 = (Re i)2 + (Im i)2 = (1 (1 + Re i))2 + 2(Im i)2= 1 + 2r2i 2(1 + Re i),

    where ri = |1 + i|. By assumption, | arg(1 + i) | , and thus 1+Re i ri cos . It follows that

    |i|2 1 + 2r2i 2ri cos = 1 + r2i cos

    2

    (1+maxi |i|)2 2ri cos2 1+maxi |i|

    1 + ri cos2 1+maxi |i| 2ri cos2

    1+maxi |i|= 1 ri cos2 1+maxi |i| < 1,

    and thus the fixed point iteration (3.1) converges.We note that, since is chosen based on the largest eigenvalue, the con-

    vergence for eigenmodes corresponding to smaller eigenvalues may be slow,

  • 8/6/2019 Automated Modeling

    75/140

  • 8/6/2019 Automated Modeling

    76/140

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES V 11

    All components for which ki < K are assigned to the group I00 of com-ponents with small time steps, and the remaining components for whichki K are assigned to the group I01 of components with large time steps.A th t ith l ti t d t i th i i

    12 JOHAN JANSSON AND ANDERS LOGG

    This means in particular that the first element that is constructed is forthe component with the smallest time step. The original multi-adaptivealgorithm presented in [8] is based on the principle

  • 8/6/2019 Automated Modeling

    77/140

    Among the components with large time steps, we determine the minimum

    time step(4.2) K = min

    iki, i I01.

    The size of the time slab is then adjusted according to

    (4.3) Tn = min(Tn1 + K, T),

    i.e., we let K be the size of the time slab and adjust the size if we shouldreach the given final time T. We illustrate the partition of components inFigure 5.

    K K K

    Figure 5. The partition of components into groups of smalland large time steps for = 1/2.

    The time slab is then recursively created by first constructing a list of subslabs for the components contained in the group I00, and then constructingan element group containing one element for each of the components withinthe group I01, as illustrated in Figure 4. Each of these elements covers thefull length of the time slab, ti,j1 = Tn1 and tij = Tn.

    Note that we construct the list of sub slabs before we create the elementgroup. The tree of time slabs is thus constructed recursively depth first.

    (4.4) The last component steps first.

    This property is automatically obtained through the depth first nature of thenew recursive algorithm. In Figure 6, we illustrate the recursive constructionof elements by numbering the elements in the order in which they are created.

    31

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    32

    33

    34

    35

    Tn1 Tn

    Figure 6. Numbering of the elements in the order in whichthey are created.

    The list of sub slabs is constructed sequentially until the list of sub slabscovers the interval [Tn1, Tn] of the parent (root) time slab. For the con-struction of each of these sub slabs, we again determine the maximum timestep,

    (4.5) K = maxi

    ki, i I00.

    All components within I00 for which ki < K are assigned to the groupI000 of components with small time steps within I00, and the remainingcomponents for which ki K are assigned to the group I001 of componentswith large time steps within I00. As before, we let

    (4.6) K = mini ki, i I001,and let K be the length of the sub slab. For the components in the groupI000, we continue recursively, until the group of components with small timesteps is empty. At that point, the second time slab in the list of time slabswithin the current parent time slab is constructed, until finally all time slabsand element groups within the root time slab have been created.

  • 8/6/2019 Automated Modeling

    78/140

  • 8/6/2019 Automated Modeling

    79/140

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES V 17

    dG(0) method was used, unless otherwise stated. For comparison, we presentthe (wall clock) time of simulation for each of the test problems, obtainedon a standard desktop computer (Intel Pentium 4, 1.6 GHz) running DebianGNU/Linux.

    18 JOHAN JANSSON AND ANDERS LOGG

    (individual for each component) fixed point iteration (adaptive level 1 iter-ation).

    Note that the second component, which decays faster, initially uses smallertime steps than the first component. Later, when the second component is

  • 8/6/2019 Automated Modeling

    80/140

    /

    5.1. The test equation. The first test problem is the scalar problem

    u(t) + u(t) = 0, t (0, T],u(0) = u0,

    (5.1)

    for T = 10, = 1000, and u0 = 1. The solution, which is shown in Figure7, was computed in less than 0.01 seconds, using (diagonally) damped fixedpoint iteration (adaptive level 1 iteration).

    0 2 4 6 8 10

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 2 4 6 8 10

    x 103

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 2 4 6 8 10

    104

    102

    100

    0 2 4 6 8 10

    x 103

    104

    102

    100

    tt

    tt

    U(t)

    U(t)

    k(t)

    k(t)

    Figure 7. Solution and adaptive time step sequence for (5.1).

    5.2. The test system. The second test problem is the diagonal problem

    u(t) + Au(t) = 0, t (0, T],u(0) = u0,

    (5.2)

    for T = 10, A = diag(100, 1000), and u0 = (1, 1). The solution, which isshown in Figure 8, was computed in 0.01 seconds, using diagonally damped

    p p , p

    out of the transient with the first component still in its transient, the situ-ation is the opposite with smaller time steps for the first component.

    0 2 4 6 8 10

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 0.05 0.1

    0

    0.2

    0.4

    0.6

    0.8

    1

    0 2 4 6 8 10

    104

    102

    100

    0 0.05 0.1

    104

    102

    100

    tt

    tt

    U(t)

    U(t)

    k(t)

    k(t)

    Figure 8. Solution and adaptive time step sequence for (5.2).

    5.3. A non-normal test problem. The next problem is the mass-spring-dashpot system (3.14) with = 104, corresponding to critical damping,i.e.,

    u(t) + Au(t) = 0, t (0, T],u(0) = u0,

    (5.3)

    for T = 1, withA =

    0 1

    104 200

    and u0 = (1, 1). The solution, which is shown in Figure 9, was computedin 0.38 seconds, using a combination of adaptively stabilized fixed pointiteration on the time slab level (adaptive level 3 iteration), and stabilizingtime steps.

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES V 19

    15

    10

    5

    0

    15

    10

    5

    0

    U(t)

    U(t)

    20 JOHAN JANSSON AND ANDERS LOGG

    0.6

    0.8

    1

    0.6

    0.8

    1

    U(t)

    U(t)

  • 8/6/2019 Automated Modeling

    81/140

    0 0.2 0.4 0.6 0.8 1

    35

    30

    25

    20

    15

    0 0.05 0.1

    35

    30

    25

    20

    15

    0 0.2 0.4 0.6 0.8 110

    6

    104

    102

    100

    0 0.05 0.110

    6

    104

    102

    100

    tt

    tt

    UU

    k(t)

    k(t)

    Figure 9. Solution and adaptive time step sequence for (5.3).

    5.4. The HIRES problem. The HIRES problem (High Irradiance RE-Sponse) originates from plant physiology and is taken from a test set ofinitial value problems [11] for ODE solvers. The problem consists of thefollowing eight equations:

    (5.4)

    u1 = 1.71u1 + 0.43u2 + 8.32u3 + 0.0007,u2 = 1.71u1 8.75u2,u3 = 10.03u3 + 0.43u4 + 0.035u5,u4 = 8.32u2 + 1.71u3 1.12u4,u5 = 1.745u5 + 0.43u6 + 0.43u7,u6 =

    280.0u6u8 + 0.69u4 + 1.71u5

    0.43u6 + 0.69u7,

    u7 = 280.0u6u8 1.81u7,u8 = 280.0u6u8 + 1.81u7,

    on [0, 321.8122] with initial condition u0 = (1.0, 0, 0, 0, 0, 0, 0, 0.0057). Thesolution, which is shown in Figure 10, was computed in 0.32 seconds, usingdiagonally damped fixed point iteration (adaptive level 1 iteration).

    0 100 200 300

    0

    0.2

    0.4

    0 1 2 3 4 5

    0

    0.2

    0.4

    0 100 200 30010

    4

    102

    100

    0 1 2 3 4 510

    4

    102

    100

    tt

    tt

    UU

    k(t)

    k(t)

    Figure 10. Solution and adaptive time step sequence for (5.4).

    5.5. The Akzo-Nobel problem. We next solve the Chemical Akzo-Nobel

    problem taken from the test set [11], consisting of the following six equations:

    (5.5)

    u1 = 2r1 + r2 r3 r4,u2 = 0.5r1 r4 0.5r5 + F,u3 = r1 r2 + r3,u4 = r2 + r3 2r4,u5 = r2 r3 + r5,u6 = Ksu1u4 u6,

    on [0, 180], where F = 3.3 (0.9/737 u2) and the reaction rates aregiven by r1 = 18.7 u41

    u2, r2 = 0.58 u3u4, r3 = 0.58/34.4 u1u5, r4 =

    0.09 u1u2

    4, and r5 = 0.42 u2

    6u2. The initial condition is given by u0 =(0.444, 0.00123, 0, 0.007, 0, 0.36). The solution, which is shown in Figure 11,was computed in 0.14 seconds, using a combination of adaptively stabilizedfixed point iteration on the time slab level (adaptive level 3 iteration), andstabilizing time steps. Note that for this particular problem, the partition-ing threshold with a default value of = 0.5 forces all components to usethe same time steps.

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES V 21

    0.4

    0.5

    8

    10x 10

    4

    ))

    22 JOHAN JANSSON AND ANDERS LOGG

    5

    10

    15

    5

    10

    15

    (t)

    (t)

  • 8/6/2019 Automated Modeling

    82/140

    0 50 100 150

    0

    0.1

    0.2

    0.3

    0 1 2 3 4 5

    0

    2

    4

    6

    0 50 100 150

    102

    101

    100

    0 1 2 3 4 5

    102

    101

    100

    tt

    tt

    U(

    t)

    U(

    t)

    k(t)

    k(t)

    Figure 11. Solution and adaptive time step sequence for (5.5).

    5.6. Van der Pols equation. A stiff problem discussed in the book byHairer and Wanner [4] is Van der Pols equation,

    u + (u2 1)u + u = 0,

    which we write in the form

    (5.6)

    u1 = u2,u2 = (u21 1)u2 u1.

    We take = 10 and compute the solution on the interval [0, 100] withinitial condition u0 = (2, 0). The solution, which is shown in Figure 12,was computed in 1.89 seconds, using a combination of adaptively stabilizedfixed point iteration on the time slab level (adaptive level 3 iteration) andstabilizing time steps.

    Note how the time steps are drastically reduced at the points where thederivatives, and thus also the residuals, of the mdG(0) solution are large.

    0 20 40 60 80 10015

    10

    5

    0

    38 40 42 44 46 4815

    10

    5

    0

    0 20 40 60 80 10010

    10

    10

    5

    100

    38 40 42 44 46 48

    0

    0.2

    0.4

    0.6

    0.8

    1

    tt

    tt

    U

    U

    k(t)

    k(t)

    Figure 12. Solution and adaptive time step sequence for (5.6).

    5.7. The heat equation. A special stiff problem is the one-dimensionalheat equation,

    u(x, t) u(x, t) = f(x, t), x (0, 1), t > 0,u(0, t) = u(1, t) = 0, t > 0

    u(x, 0) = 0, x [0, 1],where we choose f(x, t) = f(x) as an approximation of the Dirac deltafunction at x = 0.5. Discretizing in space, we obtain the ODE

    u(t) + Au(t) = f,

    u(0) = 0,(5.7)

    where A is the stiffness matrix (including lumping of the mass matrix).With a spatial resolution of h = 0.01, the eigenvalues of A are distributed

    in the interval [0, 4 104]. The solution, which is shown in Figure 13, wascomputed with a partitioning threshold = 0.1 in 2.99 seconds, using acombination of adaptively stabilized fixed point iteration on the time slablevel (adaptive level 3 iteration) and stabilizing time steps.

    5.8. A chemical reaction test problem. The next problem originatingfrom 1966 (Robertson) is taken from Hairer and Wanner [4]. This problem

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES V 23

    0.2

    0.25

    0.3

    (t)

    24 JOHAN JANSSON AND ANDERS LOGG

    0.995

    1

    3

    4x 10

    5

    U1

    (t)

    t)

  • 8/6/2019 Automated Modeling

    83/140

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

    0

    0.05

    0.1

    0.15

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

    104

    102

    100

    t

    t

    U

    k

    (t)

    Figure 13. Solution and adaptive time step sequence for (5.7).

    models the following system of chemical reactions:

    A 0.04 B (slow)

    B + B 3107

    B + C (very fast)

    B + C 104

    A + C (fast)

    which gives an initial value problem of the form

    (5.8)

    u1 = 0.04u1 + 104u2u3,u2 = 0.04u1 104u2u3 3 107u22,u3 = 3

    107u22.

    We compute the solution on the interval [0 , 0.3] with u0 = (1, 0, 0). Thesolution, which is shown in Figure 14, was computed in 0.01 seconds, usingdiagonally damped fixed point iteration (adaptive level 1 iteration).

    5.9. A mixed stiff/non-stiff test problem. As a final test problem, wesolve the simple system

    0 0.1 0.2 0.3

    0.99

    0 0.1 0.2 0.3

    0

    5

    10

    x 103

    0 0.1 0.2 0.3

    0

    1

    2

    0 0.05 0.1 0.15 0.2 0.25 0.310

    3

    102

    101

    100

    t

    tt

    tU2

    (

    U3

    (t)

    k(t)

    Figure 14. Solution and adaptive time step sequence for (5.8).

    (5.9)

    u1

    = u2

    ,u2 = (1 u3)u1,u3 = (u21 + u22)u3,

    which, since u3 0 and u21 + u22 1, we recognize as the combination of aharmonic oscillator (the first and second components) and the simple scalartest problem (5.1). We take = 1000 and compute the solution on [0 , 30]with initial condition u0 = (0, 1, 1). As an illustration, we use the mcG(1)method for the first two non-stiff components and the mdG(0) method forthe third stiff component.

    The solution, which is shown in Figure 16, was computed in 0 .06 seconds,using diagonally damped fixed point iteration (adaptive level 1 iteration).

    With a partitioning threshold of default size = 0.5, we notice that thetime steps for the stiff third component are sometimes decreased, wheneverki > k 3 for i = 1 or i = 2. This is also evident in Figure 15, where we plotthe sequence of time slabs on the interval [10, 30].

    MULTI-ADAPTIVE GAL ER KIN METHO DS FO R O DES V 25 26 JOHAN JANSSON AND ANDERS LOGG

    References

    [1] G. Dahlquist, Stability and Error Bounds in the Numerical Integration of OrdinaryDifferential Equations, PhD thesis, Stockholm University, 1958.

    [2] T. Dupont, J. Hoffman, C. Johnson, R.C. Kirby, M.G. Larson, A. Logg,and L R Scott The FEniCS project

  • 8/6/2019 Automated Modeling

    84/140

    Figure 15. The structure of the time slabs on the interval[10, 30] for the solution of (5.9).

    0 10 20 30

    1

    0.5

    0

    0.5

    1

    0 0.1 0.2 0.3

    1

    0.5

    0

    0.5

    1

    0 5 10 15 20 25 30

    0

    0.2

    0.4

    0.6

    0.8

    1

    t

    tt

    U(t)

    U(t)

    k(t)

    Figure 16. Solution and adaptive time step sequence for (5.9).

    and L.R. Scott,

    The FEniCS project, Tech. Rep. 200321, Chalmers Finite ElementCenter Preprint Series, 2003.

    [3] K. Eriksson, C. Johnson, and A. Logg, Explicit time-stepping for stiff ODEs,SIAM J. Sci. Comput., 25 (2003), pp. 11421157.

    [4] E. Hairer and G. Wanner, Solving Ordinary Differential Equations II Stiff andDifferential-Algebraic Problems, Springer Series in Computational Mathematics, vol14, 1991.

    [5] J. Hoffman and A. Logg et al. , DOLFIN, http://www.phi.chalmers.se/dolfin/.[6] J. Jansson and A. Logg, Algorithms for multi-adaptive time-stepping, submitted

    to ACM Trans. Math. Softw., (2004).[7] A. Logg, Multi-adaptive Galerkin methods for ODEs I, SIAM J. Sci. Comput., 24

    (2003), pp. 18791902.[8] , Multi-adaptive Galerkin methods for ODEs II: Implementation and applica-

    tions, SIAM J. Sci. Comput., 25 (2003), pp. 11191141.

    [9] , Multi-adaptive Galerkin methods for ODEs III: Existence and stability, Sub-mitted to SIAM J. Numer. Anal., (2004).

    [10] , Multi-adaptive Galerkin methods for ODEs IV: A priori error estimates, Sub-mitted to SIAM J. Numer. Anal., (2004).

    [11] F. Mazzia and F. Iavernaro, Test set for initial value problem solvers, release 2.2,Department of Mathematics, University of Bari, Report 40/2003, (2003).

  • 8/6/2019 Automated Modeling

    85/140

  • 8/6/2019 Automated Modeling

    86/140

  • 8/6/2019 Automated Modeling

    87/140

  • 8/6/2019 Automated Modeling

    88/140

  • 8/6/2019 Automated Modeling

    89/140

    1152 KENNETH ERIKSSON, CLAES JOHNSSON, AND ANDERS LOGG

    0 6

    0.8

    1

    0 6

    0.8

    1

    (t

    )

    (t

    )

    EXPLICIT TIME-STEPPING FOR STIFF ODES 1153

    6

    8

    6

    8

    (t

    )

    (t

    )

  • 8/6/2019 Automated Modeling

    90/140

    0 2 4 6 8 10

    0

    0.2

    0.4

    0.6

    0 0.05 0.1

    0

    0.2

    0.4

    0.6

    0 1 2 3 4 5 6 7 8 9 10

    10-2

    100

    t

    tt

    U(t

    U(t

    k(t)

    Fig. 4. Solution and time step sequence for (9.2), /0 1/104.

    2 = 1000, and most of the damping steps are chosen to damp out this eigenmode, butsome of the damping steps are chosen based on the second largest eigenvalue 1 = 100(see Figure 4). When to damp out which eigenmode is automatically decided by the

    adaptive algorithm; the bad eigenmode that needs to be damped out becomes visiblein the iterative solution process. Since there is an additional eigenvalue, the cost issomewhat larger than for the scalar test problem, 18, which gives a cost reductionfactor of /0 1/104.

    9.3. A linear nonnormal problem. The method behaves similarly even if wemake the matrix A highly nonnormal. We now solve

    u(t) + Au(t) = 0 for t > 0,

    u(0) = u0,(9.3)

    on [0, 10], with

    A =

    1000 10000

    0 100

    and u0 = (1, 1). The cost is about the same as for the previous problem, 17, butthe cost reduction factor is better: /0 1/180. The solution and the time stepsequence are given in Figure 5.

    9.4. The HIRES problem. The so-called HIRES problem (High IrradianceRESponse) originates from plant physiology and is taken from the test set of ODEproblems compiled by Lioen and de Swart [6]. The problem consists of the following

    0 2 4 6 8 10

    0

    2

    4

    0 0.01 0.02 0.03 0.04 0.05

    0

    2

    4

    0 1 2 3 4 5 6 7 8 9 10

    10-4

    10-2

    100

    t

    tt

    U(t

    U(t

    k(t)

    Fig. 5. Solution and time step sequence for (9.3), /0 1/180.

    eight equations:

    u1 = 1.71u1 + 0.43u2 + 8.32u3 + 0.0007,u2 = 1.71u1

    8.75u2,

    u3 = 10.03u3 + 0.43u4 + 0.035u5,u4 = 8.32u2 + 1.71u3 1.12u4,u5 = 1.745u5 + 0.43u6 + 0.43u7,u6 = 280.0u6u8 + 0.69u4 + 1.71u5 0.43u6 + 0.69u7,u7 = 280.0u6u8 1.81u7,u8 = 280.0u6u8 + 1.81u7,

    (9.4)

    together with the initial condition u0 = (1.0, 0, 0, 0, 0, 0, 0, 0.0057). We integrate over[0, 321.8122] (as specified in [6]) and present the solution and the time step sequencein Figure 6. The cost is now 8, and the cost reduction factor is /0 1/33.

    9.5. The AkzoNobel problem. The next problem is a version of the Chem-ical AkzoNobel problem taken from the ODE test set [6], consisting of the following

    six equations:

    u1 = 2r1 + r2 r3 r4,u2 = 0.5r1 r4 0.5r5 + F,u3 = r1 r2 + r3,u4 = r2 + r3 2r4,u5 = r2 r3 + r5,u6 = r5,

    (9.5)

    where F = 3.3(0.9/737u2) and the reaction rates are given by r1 = 18.7u41

    u2, r2 =0.58 u3u4, r3 = 0.58/34.4 u1u5, r4 = 0.09 u1u24, and r5 = 0.42 u26

    u2. We integrate

    1154 KENNETH ERIKSSON, CLAES JOHNSSON, AND ANDERS LOGG

    0.6

    0.8

    1

    0.6

    0.8

    1

    U(t)

    U(t)

    EXPLICIT TIME-STEPPING FOR STIFF ODES 1155

    1.996

    1.998

    2

    -2

    -1

    0x 10

    -4

    U

    1(t)

    )

  • 8/6/2019 Automated Modeling

    91/140

    0 100 200 300

    0

    0.2

    0.4

    0 1 2 3 4 5

    0

    0.2

    0.4

    0 100 200 300

    10-2

    10-1

    100

    130 132 134 136 138 140

    10-2

    10-1

    100

    tt

    tt

    UU

    k(t)

    k(t)

    Fig. 6. Solution and time step sequence for (9.4), /0 1/33.

    0 50 100 150

    0

    0.2

    0.4

    0 1 2 3 4 5

    0

    2

    4

    6

    8

    10x 10

    -4

    0 20 40 60 80 100 120 140 160 180

    10-1

    100

    t

    tt

    U(t)

    U(t)

    k(t)

    Fig. 7. Solution and time step sequence for (9.5), /0 1/9.

    over the interval [0, 180] with initial condition u0 = (0.437, 0.00123, 0, 0, 0, 0.367).Allowing a maximum time step of kmax = 1 (chosen arbitrarily), the cost is only 2, and the cost reduction factor is /0 1/9. The actual gain in a specificsituation is determined by the quotient of the large time steps and the small dampingtime steps, as well as the number of small damping steps that are needed. In this

    0 2 4 6 8 10

    1.994

    0 0.05 0.1-8

    -6

    -4

    -2

    0

    x 10-4

    1.994 1.996 1.998 2

    -7

    -6

    -5

    -4

    -3

    0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5

    10-4

    10-2

    t

    t

    t

    U1(t)

    U2

    (t)

    U2

    (t)

    k(t)

    Fig. 8. Solution and time step sequence for (9.6), /0 1/75.

    case, the number of small damping steps is small, but the large time steps are notvery large compared to the small damping steps. The gain is thus determined both bythe stiff nature of the problem and the tolerance (or the size of the maximum allowedtime step).

    9.6. Van der Pols equation. A stiff problem discussed in the book by Hairerand Wanner [5] is Van der Pols equation,

    u + (u2 1)u + u = 0,

    which we write as

    u1 = u2,u2 = (u21 1)u2 u1.(9.6)

    We take = 1000 and compute the solution on the interval [0, 10] with initial conditionu0 = (2, 0). The time step sequence behaves as desired with only a small portion ofthe time interval spent on taking small damping steps (see Figure 8). The cost is now 140, and the cost reduction factor is /0 1/75.

    9.7. The heat equation. A special stiff problem is the one-dimensional heatequation,

    u(x, t) u(x, t) = f(x, t), x (0, 1), t > 0,u(0, t) = u(1, t) = 0, t > 0,

    u(x, 0) = 0, x [0, 1],

  • 8/6/2019 Automated Modeling

    92/140

  • 8/6/2019 Automated Modeling

    93/140

    INTERPOLATION ESTIMATES FOR PIECEWISE SMOOTH FUNCTIONS 3

    Let now v V and let

    (2.3) : V Pq([a, b]) V.

    If we can show that

    (1) is linear on V,(2) is exact on Pq([a, b]) V, that is, v = v for all v Pq([a, b]),

    4 ANDERS LOGG

    which is linear, bounded, and vanishes on Pq([a, b]). Now,

    K(t) =1

    q!

    ba

    (( t)q+)(x) (x t)

    q+

    g(x) dx

    =

    kq+1

    q!

    1

    kba

    t

    kq

    +

    (x)

    x tk

    q+

    g(x) dx

  • 8/6/2019 Automated Modeling

    94/140

    and(3) is bounded on V, that is, v Cv for all v V for some

    constant C > 0,

    then the Peano kernel theorem directly leads to a representation of theinterpolation error v v.

    Theorem 2.2. (Peano kernel theorem II) If is linear and bounded (withconstant C > 0) onV, and is exact onPq([a, b]) V, then there is a bounded

    function G : [a, b] [a, b] R, with |G(x, t)| 1 + C for all x, t [a, b],such that for all v Cq+1([a, b]),

    (2.4) v(x) v(x) =kq+1

    q!

    1

    k

    b

    av(q+1)(t)G(x, t) dt,

    where k = b a. Furthermore, if g is an integrable, (essentially) bounded function on[a, b], then there is a function Hg : [a, b] R, with |Hg(x)| (1 + C)g for all x [a, b], such that for all v Cq+1([a, b]),

    (2.5)

    ba

    (v(x) v(x)) g(x) dx =kq+1

    q!

    ba

    v(q+1)(x)Hg(x) dx.

    Proof. To prove (2.4), we define for any fixed x [a, b],

    xv = v(x) v(x),

    which is linear, since is linear. Furthermore, if v Pq([a, b]) then v = vso x vanishes on P

    q([a, b]). From the estimate,

    |xv| = |v(x) v(x)| |v(x)| + |v(x)| (1 + C)v,

    it follows that x is bounded. Now,

    Kx(t) =1

    q!x(( t)

    q+) =

    1

    q!

    (( t)q+)(x) (x t)

    q+

    =

    kq

    q!

    t

    k

    q+

    (x)

    x t

    k

    q+

    =

    kq

    q!G(x, t),

    where |G(x, t)| 1 + C for x, t [a, b]. Thus, by the Peano kernel theorem,

    v(x) v(x) = xv =kq+1

    q!

    1

    k

    b

    av(q+1)(t)G(x, t) dt.

    To prove (2.5), define by

    v =

    ba

    (v(x) v(x))g(x) dx,

    =

    kq+1

    q!Hg(t),

    where Hg(t) (1 + C)g for t [a, b]. By the Peano kernel theorem, itnow follows thatb

    a(v(x) v(x))g(x) dx =

    kq+1

    q!

    ba

    v(q+1)(t)Hg(t) dt.

    In order to derive a representation for derivatives of the interpolation

    error, we need to investigate the differentiability of the kernel G(x, t).Lemma 2.1. (Differentiability of G) If is linear on V, then the kernel G,defined by

    (2.6) G(x, t) =

    t

    k

    q+

    (x)

    x t

    k

    q+

    ,

    has the following properties:

    (i) For any fixed t [a, b], G(, t) Cq1([a, b]) and

    (2.7)p

    xpG(x, t) = kpGx,p(x, t), p = 0, . . . , q ,

    where each Gx,p is bounded on [a, b] [a, b] independent of k.

    (ii) For any fixed x [a, b], G(x, ) Cq

    1([a, b]) and

    (2.8)p

    tpG(x, t) = kpGt,p(x, t), p = 0, . . . , q ,

    where each Gt,p is bounded on [a, b] [a, b] independent of k.(iii) For x = t and p1, p2 0, we have

    (2.9)p2

    xp2p1

    tp1G(x, t) = k(p1+p2)Gt,x,p1,p2(x, t),

    where each Gt,x,p1,p2 is bounded on [a, b] [a, b]\{(x, t) : x = t} independentof k.

    Proof. Define

    G(x, t) =

    tk

    q

    +

    (x)

    x t

    k

    q

    +

    g(x, t) h(x, t).

    We first note that for any fixed t [a, b], h(, t) Cq1([a, b]) with

    p

    xph(x, t) =

    p

    xp

    x t

    k

    q+

    = kpq!

    (q p)!

    x t

    k

    qp+

    = kphx,p(x, t),

  • 8/6/2019 Automated Modeling

    95/140

    INTERPOLATION ESTIMATES FOR PIECEWISE SMOOTH FUNCTIONS 7

    for p = 0, . . . , r. When r < q, this holds also for p = r + 1 q, and forp = r + 1 = q, we note that (v)(p) v(p) = v(p) = v(r+1).

    This leads to the following estimate for the derivative of the interpolant.

    Corollary 3.2. If is linear and bounded on V, and is exact onPq([a, b])

    V, then there is a constant C = C(q) > 0, such that for all v Cq+1([a, b]),( ) ( )

    8 ANDERS LOGG

    4. Interpolation of piecewise smooth functions

    We now extend the interpolation results of the previous two sections topiecewise smooth functions.

    4.1. Extensions of the Peano kernel theorem. To extend the Peanok l th t i i th f ti t t th

  • 8/6/2019 Automated Modeling

    96/140

    (3.2) (v)(p) Cv(p),

    for p = 0, . . . , q.

    Proof. It is clear that (3.2) holds when p = 0 since is bounded. For0 < p q, we add and subtract v(p), to obtain

    (v)(p) (v)(p) v(p) + v(p).

    Since is exact on Pq([a, b]), it is exact on Pp1([a, b]) Pq([a, b]) for p q.It follows by Corollary 3.1, that

    (v)(p) Ck (p1)+1pv((p1)+1) + v(p) = (C+ 1)v(p) = Cv(p).

    Finally, we show that it is often enough to show that is linear on V andexact on P(q)([a, b]), that is, we do not have to show that is bounded.

    Lemma 3.1