next previous
Up: CESAM: A code

C. Calculations with B-splines

  Computation with B-spline is not familiar in stellar modelling, so I briefly describe the basic of the method directed towards interpolation and integration of differential equations. For more advanced description and proofs refers to deBoor (), Shumaker () and to the literature cited herein.

With this technique the functions to be interpolated (respt. integrated) e.g. pressure, temperature, etc... are approximated by piecewise polynomials which coincide with the function at interpolation points (respt. fulfill the differential equation). With a lattice with points at qi, for algebra, the simplest way for writing piecewise polynomials at the location q, is the use of the canonical basis, i.e., the powers of (q-qi). For the calculations that basis leads to algorithms having poor stability conditions; among the bases available for the linear set of piecewise polynomials, a local basis, the normalized B-spline basis, leads to stable algorithms.

A B-spline is itself, obviously, a piecewise polynomial. It can be defined either from divided differences (deBoor, loc. cit.; Gaches, 1988), or from the algorithm used for their calculation; they are convolution products of the tex2html_wrap_inline6233 (door) function (Marchouk & Agochkov 1985).

C.1. The nodal vector: the key of the computations with B-splines

  Before going ahead in the definition of the B-splines, one must define more precisely what is a piecewise polynomial tex2html_wrap_inline6241 of order s, on a given partition tex2html_wrap_inline6245 of [1,n], tex2html_wrap_inline6249gif: tex2html_wrap_inline6241 is defined as a function which coincides, on each sub-interval tex2html_wrap_inline6253, with a polynomial of degree s-1. The existence and uniqueness of tex2html_wrap_inline6241 on tex2html_wrap_inline6245 results from the knowledge, at each breakpoint qi, of the kind of connection which is required between the right and the left pieces of polynomials. As an example, the so-called "natural spline" is a piecewise polynomial tex2html_wrap_inline6263 of order 4 (degree 3), constructed in such a way that, at the inner breakpoints tex2html_wrap_inline6265, the second derivatives tex2html_wrap_inline6267 are continuous.

Formally, the rules of connection can differ from one breakpoint to the next: at some of them, tex2html_wrap_inline6269 can be discontinuous, at some others the left and right pieces can be tied fulfilling the continuity of their first derivatives or only of tex2html_wrap_inline6269, etc...\ For each qi, the connection is characterized by the so-called multiplicity mi obtained as follows: let tex2html_wrap_inline6277 be the order of the oscularity of the connection between the left and right polynomial pieces at the breakpoint qi; di=0 means tex2html_wrap_inline5511 continuity of tex2html_wrap_inline6269, di=1 means tex2html_wrap_inline6289 continuity of the first derivative, di=2 (tex2html_wrap_inline6293) of the second ones etc... and one sets di=-1 for a tex2html_wrap_inline6297 discontinuity of the function itself. At i=1 and i=n (inner and outer boundaries) one fixes the value of tex2html_wrap_inline6269. This is equivalent to assume that tex2html_wrap_inline6305 is discontinuous at these points. Hence, one has d1=dn=-1. The multiplicity of the point qi is then defined as:
displaymath6235
From the vector of multiplicities: tex2html_wrap_inline6311 one constructs the heart of the calculation with B-spline: the so-called "nodal vector": tex2html_wrap_inline6313 associated to a B-spline basis; it is the vector which has the qi for coordinates, each of them appearing mi times. tex2html_wrap_inline5527 is written:
eqnarray1836
The dimension of tex2html_wrap_inline5527 is then S+mn, with tex2html_wrap_inline6325. A convenient schematic representation of a nodal vector consists in writing one column of mi elements for each breakpoint qi.

As an example, with s=4, n=7, continuity of tex2html_wrap_inline6241 at q3, of tex2html_wrap_inline6339 at q6, of tex2html_wrap_inline6343 at q2 and q5, and discontinuity of tex2html_wrap_inline6241 at q4, the nodal vector is represented as:
displaymath6236

Once given this nodal vector, the value of the k-th normalized B-spline on tex2html_wrap_inline5527 (tex2html_wrap_inline6357) is obtained by induction:
equation1861
and, for tex2html_wrap_inline6359:
equation1873
Note that its first derivative can easily be calculated:
displaymath6237
From these relationships one can see that tex2html_wrap_inline6361 if tex2html_wrap_inline6363. Hence the B-spline basis is a local basis. Moreover, tex2html_wrap_inline6365, only s B-splines of order s are not identically zero and their sum is equal to 1. For their calculation, algorithms which avoid zero denominator have been designed. The present work uses the Schumaker's () algorithms 5-5, 5-11 and 5-13.

It can be shown that the set tex2html_wrap_inline6371 of all the B-splines tex2html_wrap_inline6373, forms a basis for the linear space of the set of the piecewise polynomials having tex2html_wrap_inline5527 for nodal vector. Thus, the dimension of tex2html_wrap_inline6377 is precisely S.

For discontinuous piecewise polynomials the use of B-spline basis is particularly convenient since only the algorithm which constructs the nodal vector is concerned with the discontinuity.

The extension to several dimensions are found in Schumaker (loc. cit.) and in deBoor (loc. cit.)

C.2. Interpolation

  Let f(q) be a real function to be interpolated on the grid tex2html_wrap_inline6383, (tex2html_wrap_inline6385 if tex2html_wrap_inline6387), at each qi, f(qi) is known. For interpolation of order s the so-called Schoenberg's basis allows to reach an accuracy almost optimal (deBoor, loc. cit., Chapt. XIII, p. 219). The n coordinates of this nodal vector are written:
eqnarray1910
The dimension of this basis is exactly n. As an example, the standard natural spline of interpolation employed this basis, with s=4, the interpolating function is a cubic piecewise polynomial with pieces continuously connected up to second derivative.

C.3. Computation of the B-spline coefficients

  For tex2html_wrap_inline6403 the interpolating piecewise polynomial is written:
displaymath6401
where the coefficients pi fulfill the linear system:
 equation1920
It is a banded, totally positive linear system, thus it can be accurately solved by Gauss elimination without pivoting (deBoor, loc. cit., Chapt. XIII, p. 203).

C.4. Piecewise polynomial interpolation is conservative

  First briefly recall that standard polynomial interpolation is conservative. Let tex2html_wrap_inline6413 be a set of real functions to be interpolated on the grid tex2html_wrap_inline6415, tex2html_wrap_inline6417 if tex2html_wrap_inline6419. The polynomial P(x) for interpolation is written (Stoer & Bulirsch, ):
displaymath6407
where Lj(x) is the j-th. Lagrange's polynomial. Owing to the property:
displaymath6408
if any linear combination holds for the functions, e.g. conservation of baryon and charge numbers are relationships of that form, then:
displaymath6409
it also holds for the polynomials of interpolation:
eqnarray1931
Piecewise polynomials have the same property, since between to break points (i) they are polynomials and (ii) according to the Schoenberg-Whitney theorem (deBoor, loc. cit., p. 200, Theorem XIII.1) where is at least a location where the linear combination is fulfilled. As seen Sect. 3.3.1 (click here), the chemicals are interpolated using piecewise polynomials, the former property ensures the conservation of baryon and charge numbers.

C.5. Integration of differential equations

  One seeks, on [a,b], the solution of a differential equation in the form of piecewise polynomials. Then, with respect to their B-spline basis, tex2html_wrap_inline6433 of order s, at q, for the variables, the piecewise polynomials are written:
displaymath6427
where the pk,j are the coordinates of the j-th unknown with respect to the B-spline basis. The quantities to be calculated consist in the B-spline coefficients pk,j, rather than in the functions themselves. Formally, each of the differential equations can be expressed, for the pk,j, in the form:
 equation1943
where the function tex2html_wrap_inline6447 is the jth. coordinate in the right hand side of the differential equation. Hence, derivatives of the functions can be readily calculated by differentiation of the basis function Nks(q).

There are two standard methods for the calculation of the coordinates pk,j: i) in the collocation method one fulfills Eq. (B4 (click here)) at a number of grid points, tex2html_wrap_inline6455, equal to the dimension S of the B-spline basis, ii) in the Galerkin method one defines an inner product and calculates the weak solutions which ensure that the residual:
displaymath6428
is orthogonal to the basis:
 equation1963

With non-linear differential problems, Eq. (B4 (click here)) and Eq. (B5 (click here)) are also non-linear. They are linearized for the pk,j and solved by iterations (Newton-Raphson method). For the sake of brevity details are omitted.

C.5.1. Collocation with the deBoor's basis.

  With the deBoor's basis, in the case of first order differential equations, the continuity of the piecewise polynomials is ensured at the mesh points but not their subsequent derivatives. Hence, the nodal vector is represented by:
displaymath6461
and
displaymath6462
This allows to obtain the B-spline functions shown in Fig. 8 (click here); with s=2 the scheme is similar to the centered finite difference mid-point scheme. It is clear that the continuity of the derivatives of the functions is not ensured at the mesh points. This does not mean that the functions derivatives will be discontinuous but rather that they can be discontinuous at these points. (This property has been used in the Sect. A.2 (click here).)

  figure1987
Figure 8: Normalized B-splines of order s=2 (left panel) and s=3 (right panel) calculated with deBoor basis for n=3 equidistant mesh points. The nodal vectors are indicated by crosses below both graphs

For each mesh and for each piecewise polynomial, s parameters have to be known (recall that tex2html_wrap_inline6241 is, on [qi,qi+1], a polynomial of degree s-1). The continuity of the function or the boundary conditions of the problem provide one constraint, the equations have to be written at s-1 points within each mesh. These are called the collocation points, noted tex2html_wrap_inline6489, where S=(n-1)(s-1)+1 and are defined as follow:
equation1996
The quantities tex2html_wrap_inline6493 can be almost arbitrarily chosen. However, for the deBoor's nodal vector, they are chosen as the zeros of the (s-1)-th Legendre polynomial. Note that the collocation points are therefore different from the mesh points qi; this disposition is particularly convenient at the center. For this particular collocation pattern, it can be demonstrated that, for first order differential equations, the overall approximation is of order O(h)s, but that it is of order up to O(h)2(s-1) at the mesh points (deBoor & Swartz 1973); here h is the size of the mesh. This is the so-called superconvergence.

Once written the differential equation on this particular basis, including boundary conditions at both ends, is formally written:
 equation2010
where for the j-th unknown tex2html_wrap_inline6507 is a function of q and of the vector tex2html_wrap_inline6511 of the coordinates pk,j, tex2html_wrap_inline6515. The resolution of the non-linear system Eq. (B7 (click here)) is obtained by linearization (Newton-Raphson method) starting from the initial model. Since the B-splines basis is a local basis, the jacobian matrix is block-diagonal. This allows storage ease and faster calculations. Here one usually uses either s=2, s=3 or s=4 for the order of the piecewise polynomials. As an example for system Eq. (21 (click here)), the linear system to be solved has then one of the following structures for s=2 (left) and s=3 (right):
displaymath6463
here the "tex2html_wrap_inline6527" are tex2html_wrap_inline6529 matrix for the collocation points and the tex2html_wrap_inline6531 are tex2html_wrap_inline6533 matrix for the boundaries.

C.5.2. Basis for Petrov-Galerkin's method

  With the Galerkin type methods, the choice of the basis is more flexible. Here a basis with continuity up to tex2html_wrap_inline6605 for the derivatives at the grid points and tex2html_wrap_inline6289 (continuity) or tex2html_wrap_inline5511 (discontinuity) at LMR. As examples the nodal vectors with s=4 with continuity at LMR (tex2html_wrap_inline6613) is written:
displaymath2033
and with discontinuity (tex2html_wrap_inline6615):


displaymath2038

As an example from Eq. (21 (click here)) results a jacobian matrix 2s+1 bloc-diagonal of tex2html_wrap_inline6529 blocks. For s=2, the linear system to be solved has the following structure:
displaymath6603
Note that the inner products between two B-splines of order less or equal to s are obtained without error with a Gaussian type integration formula with s points; the same integration formula is also used for all the inner products; the calculation of these inner products is conveniently made with the algorithm 5-22 of Schumaker (loc. cit.). Emphasize is made again on the fact that the values of the functions are not needed at the grid points, particularly at the center.

C.5.3. Solving the linearized systems

  The resolution of the linear system is performed with partial pivoting. The robustness of the solution is improved by using the modified Newton-Raphson method which is based on the fact that, for unconstrained optimization problems, the "Newton direction is a descent direction" (Conte & de Boor 1987, p. 219), giving the values of the unknown functions at iteration l+1 from their values at iteration l:
 equation2050
where tex2html_wrap_inline6663 are the corrections and tex2html_wrap_inline6665 is a parameter which ensures that the variations of the unknowns pk,j remain small even when tex2html_wrap_inline6663 is large; here tex2html_wrap_inline5681 is adjusted in order that tex2html_wrap_inline6673 The iteration then stops when a sufficient accuracy is reached.


next previous
Up: CESAM: A code

Copyright by the European Southern Observatory (ESO)
web@ed-phys.fr