원시데이터 수집 시스템
선정목록으로

Multi-Dimensional Astrophysical Structural and Dynamical Analysis I. Development of a Nonlinear Finite Element Approach

관련 수소연료전지 · (6) PEM(고분자전해질막)

기본 정보

저자
  1. Meier, David L.
DOI
10.48550/arxiv.astro-ph/9806278
저널
arXiv (Cornell University)
발행년도
2022
발행기관
Cornell University
피인용수
0
라이선스
0
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.48550/arxiv.astro-ph/9806278
토픽
Surface Roughness and Optical Measurements
OpenAlex ID
W6929291185

평가 내용

관련도
관련
사업분야
수소연료전지 · (6) PEM(고분자전해질막)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '수소연료전지 > PEM(고분자전해질막)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

A new field of numerical astrophysics is introduced which addresses the solution of large, multidimensional structural or slowly-evolving problems (rotating stars, interacting binaries, thick advective accretion disks, four dimensional spacetimes, etc.). The technique employed is the Finite Element Method (FEM), commonly used to solve engineering structural problems. The approach developed herein has the following key features: 1. The computational mesh can extend into the time dimension, as well as space, perhaps only a few cells, or throughout spacetime. 2. Virtually all equations describing the astrophysics of continuous media, including the field equations, can be written in a compact form similar to that routinely solved by most engineering finite element codes. 3. The transformations that occur naturally in the four-dimensional FEM possess both coordinate and boost features, such that (a) although the computational mesh may have a complex, non-analytic, curvilinear structure, the physical equations still can be written in a simple coordinate system independent of the mesh geometry. (b) if the mesh has a complex flow velocity with respect to coordinate space, the transformations will form the proper arbitrary Lagrangian- Eulerian advective derivatives automatically. 4. The complex difference equations on the arbitrary curvilinear grid are generated automatically from encoded differential equations. This first paper concentrates on developing a robust and widely-applicable set of techniques using the nonlinear FEM and presents some examples.

본문 124,595자

본문 펼치기
## Multi-Dimensional Astrophysical Structural and Dynamical Analysis I. Development of a Nonlinear Finite Element Approach D. L. Meier Jet Propulsion Laboratory, California Institute of Technology, Pasadena, CA 91109 ABSTRACT A new field of numerical astrophysics is introduced which addresses the solution of large, multidimensional structural or slowly-evolving problems (rotating stars, interacting binaries, thick advective accretion disks, four dimensional spacetimes, etc.), as well as rapidly-evolving systems. The technique employed is the Finite Element Method (FEM), which has been used to solve engineering structural problems for more than three decades. The approach developed herein has the following key features: 1. The computational mesh can extend into the time dimension, as well as space generally only a few cells deep for most (flat-space) astrophysical problems, but throughout spacetime for solving Einstein’s field equations. 2. When time is treated as a mesh dimension, virtually all equations describing the astrophysics of continuous media, including the field equations, can be written in a compact form similar to that routinely solved by most engineering finite element codes (albeit for nonlinear equations in a four-dimensional spacetime instead of linear ones in two or three space dimensions): the divergence of a generalized stress tensor equals a generalized body force vector, both of which are functions only of position, the state variables and their gradients. 3. The transformations that occur naturally in the four-dimensional FEM possess both coordinate and boost features, such that (a) although the computational mesh may have a complex, non-analytic, curvilinear structure, and may be adapted to the geometry of the problem, the physical equations still can be written in a simple coordinate system that is independent of the mesh structure. (b) if the mesh has a complex flow velocity with respect to coordinate space, the transformations will form the proper advective derivatives, automatically converting the equations to arbitrary Lagrangian-Eulerian. 4. Only relatively simple differential equations need to be encoded. The complex difference equations on the arbitrary curvilinear grid are generated automatically by the FEM integrals. A different integration method must be used for equations of odd and even order. 1 This first paper concentrates on developing a robust and widely-applicable set of techniques using the nonlinear FEM and presents some examples. The second paper in this series will deal with making the method fast and efficient, so that large, astrophysicallyinteresting computational meshes can be employed. Subject headings: methods, numerical - hydrodynamics - magnetohydrodynamics: MHD - relativity - stars: rotation 2 1. Introduction The first problem to be solved with the techniques of numerical astrophysics was the structure and evolution of stars — an “implicit” problem that involves a static or slowly-evolving structure (Chandrasekhar 1957; Aller & McLaughlin 1965). Its solution consists of determining the state variables of the fluid (density, temperature, pressure, flux of radiation, composition) at each radius in the stellar interior, and is obtained by relaxing a large set of coupled nonlinear difference equations (derived from the differential equations of stellar structure) along with boundary conditions at the stellar center and surface. Radial stellar structure is only a one-dimensional problem and, while once considered difficult and CPUintensive, now is solved easily on personal computers (PCs). Since then, many other fields of numerical astrophysics have been developed: “explicit” hydrodynamic simulations of explosive and jet phenomena (Norman 1997); N-body and smooth particle hydrodynamics (SPH) of discrete or semi-discrete systems of particles (Dubinski & Hernquist 1997; Monaghan 1992); Monte Carlo simulations of radiation flow (Leahy 1997; Park & Hong 1998); etc. All have matured to the point where the solution of threedimensional, time-dependent problems is not uncommon. Ironically, however, only modest progress has been made in extending the original implicit problems into several dimensions: rapidly rotating stars, evolving and interacting binaries, detailed accretion disk structure and evolution, etc. There are several important reasons for this. Firstly, the geometry of these systems is unknown until the problem is solved. For example, the shape of the outer surface of a rotating star or (possibly thick and advective) accretion disk will be part of the solution, and the shape of a rapidly rotating stellar core may have a different oblateness (or even prolateness) from that of the outer envelope. No numerical method capable of operating in nearlyarbitrary geometries has been applied extensively in astrophysics. Instead, one either has assumed spherical symmetry and treated only slowly-rotating, perturbation problems (Kippenhahn & Thomas 1970), or has assumed that the isosurfaces of the state variables are coincident (which implies rotation on cylinders via von Zeipel’s theorem) and again solved an essentially one-dimensional, or limited two-dimensional problem (Eriguchi & M¨uller 1991; Clement 1994). Re cently, some progress for two- and three-dimensional stellar models has been made using a multi-domain approach and treating the stellar surface as a discontinuity (Bonazzola, Gourgoulhon, & Marck 1998). Secondly, even if a general geometrical method applicable to large numbers of two-dimensional and three-dimensional problems could be developed, the current stellar structure methods for solving the immense system of simultaneous nonlinear equations would take a prohibitively long amount of CPU time and memory. For example, a relatively modest problem with 256 <sup>3</sup> grid points and ten state variables at each point would generate a banded matrix 10 <sup>8.2</sup> × 10 <sup>8.2</sup> in size, taking up at least 10 <sup>14.9</sup> bytes (0.9 PB) for the non-zero elements. Direct inversion techniques, similar to the Henyey method commonly used in stellar structure (which take the bandedness into account), would take about a thousand years to invert this matrix once on a large parallel supercomputer like the Cray T3D, with perhaps 10 <sup>4</sup> or more such inversions necessary for a complete stellar evolution model <sup>1</sup> . Fortunately, there exist techniques for solving both of these problems that are well developed and have been in use in the engineering field for many years (although it is still rare to see both used at the same time). The Finite Element Method (FEM), introduced more than four decades ago and the preferred method of treating multidimensional structural engineering problems since the late 1960s (Zienkiewicz 1977), approximates objects as distorted lattices of small structural members called elements. For solving large systems of coupled equations generated by such grid problems, the multigrid method was introduced in the 1970s (Brandt 1977) and is now beginning to be used in astrophysics as well (Truelove et al. 1998; Norman 1998). This approach dispenses with the large matrix, cleverly reaching a solution after a few sweeps of the mesh. Together, these techniques promise to make multidimensional astrophysical structural problems possible, and bring the time to solve them within an order of magnitude or so of that for explicit problems. When coupled with the continued expected increase in speed of computers over the next few decades (which has averaged about a factor of 2 every 2 years for the past 20 years), it is not 1For this calculation it is assumed that the storage is proportional to the bandwidth B (∼ 10 <sup>5.8</sup> ) of the matrix times its length L and the time to invert is proportional to B <sup>2</sup> L. 3 inconceivable that three-dimensional structure problems will soon be solved routinely on future models of PCs and that four-dimensional problems will become commonplace on supercomputers. This first paper deals with the development of the general geometrical method for solving multidimensional structure and evolution problems. At this stage the speed and efficiency of execution of the method will not be a concern; the focus will be only on producing a robust and widely-applicable set of useful techniques. Our goal will be to determine the essential features of most astrophysical systems of equations and the geometrical demands they place on the numerical method. These properties will then be encoded at the outset, ensuring some measure of generality. The second section describes the set of equations that can be addressed with nonlinear astrophysical finite element analysis and develops a method for solution on fixed (non-moving) grids. In section 3, this then is generalized to include situations where the positions of the grid points are part of the solution and the grid can change with time. Finally, tests and examples are given, using the author’s code, including rotating polytropic star models. 2. The Basic Four-Dimensional, Nonlinear Finite Element Method on Fixed Grids This section describes the techniques used in the author’s computer code, entitled GENRAL, for solving general astrophysical problems. It utilizes the techniques of finite element analysis (FEA) - in use in the field of engineering for some time — but generalizes them to nonlinear equations in four dimensions, instead of linear equations in two or three dimensions. For this initial development, it is assumed that the coordinates of the grid points (or “nodes”) at which the variables are evaluated do not change while the solution is being computed. 2.1. General Form for Equations of Continuum Astrophysics Appendix A shows that the differential equations of continuum astrophysics in curved spacetime can be cast into the generic form ℜq ≡ (Tq <sup>β(∇w,</sup> <sup>w,</sup> <sup>x) √−g),β</sup> - Fq(∇w, w, x) <sup>√</sup> −g = 0 (1) where [w] <sup>v</sup> = w <sup>v</sup> is a generalized solution vector holding all of the v = 1, ..., V unknown state variables; ℜq is a generalized residual for each of the q = 1, ..., V equations (which will be forced to zero through numerical relaxation techniques); Tq and Fq are, respectively, the generalized stress tensor and force vector for these equations; and g is the determinant of the metric tensor g ([–+++]-signature). <sup>2</sup> In a similar manner, the boundary conditions on these equations can be cast as A raised index indicates contravariant properties of the tensor and a lowered index indicates covariant properties. Note that w <sup>v</sup> is written as a contravariant vector with a raised index, like the coordinates x <sup>α</sup> ; this is partly for convenience (to facilitate the summation convention) and partly to draw attention to the variables as generalized coordinates of the system. [ t <sup>β</sup> r <sup>(∇w,</sup> <sup>w,</sup> <sup>x) √−g ],µSµβ</sup> + [ hr(S - ∇w, w, x) <sup>√</sup> −g ],µn <sup>µ</sup> ℜr ≡ [ t <sup>β</sup> r - fr(∇w, w, x) <sup>√</sup> −g = 0 (2) for each of the r = 1, ..., R boundary conditions. In general, R̸ = V since, depending on the highest order derivative in ℜr, there may be 0, 1, or 2 associated boundary conditions. The last term in (2) is adequate for handling Dirichlet, Neumann, and mixed boundary conditions, such as the radiative condition at a stellar or accretion disk surface. The first two terms are necessary for including constraints on field equations. S is the projection tensor along the boundary ∂Ωand orthogonal to the boundary normal n S ≡ n ⊗ n + g (3) where n · n = −1, n · S = 0, and S - S = S, “⊗” is the outer (dyadic) product, and “·” is the inner (scalar) product. S causes the divergence in equation (2) to be performed on the boundary only and the derivative normal to the boundary to be only first 2Throughout the paper the notation of Misner, Thorne, & Wheeler (1973) is used, with Greek letters indicating coordinate indices in four-dimensional spacetime (α = 0, 1, 2, 3) and Latin “integer” letters indicating three-space indices only (i = 1, 2, 3). The comma denotes ordinary differentiation with respect to the coordinates, while a semicolon will denote covariant differentiation. Repeated indices indicate summation over the entire range of those indices (the Einstein summation convention), so that g <sup>αµ</sup> gµβ,γ ≡ 3 µ=0 g <sup>αµ ∂gµβ</sup> ∂x <sup>γ</sup> 4 order in n <sup>µ</sup> ∂/∂x <sup>µ</sup> . An alternative form for (2) is <sup>β</sup> r <sup>(∇w,</sup> <sup>w,</sup> <sup>x) √−g ],µSµ</sup> [ t <sup>′β</sup> ℜr ≡ r β r <sup>(∇w,</sup> <sup>w,</sup> <sup>x) √−g ],µSµ</sup> + [ h <sup>′µ</sup> r <sup>(S</sup> <sup>· ∇w,</sup> <sup>w,</sup> <sup>x) √−g</sup> + [ h <sup>′µ</sup> r <sup>(S</sup> <sup>· ∇w,</sup> <sup>w,</sup> <sup>x) √−g ],µ</sup> - f <sup>′</sup> r <sup>(∇w,</sup> <sup>w,</sup> <sup>x) √−g</sup> - f <sup>′</sup> r <sup>(∇w,</sup> <sup>w,</sup> <sup>x) √−g</sup> = 0 which also has no second derivatives in n <sup>µ</sup> ∂/∂x <sup>µ</sup> . It is important to note that equation (1) includes not only structural and steady problems, but also evolving ones as well. For these cases, in addition to having three spatial coordinates, the computational grid can extend into the fourth (time) dimension, possibly from the initial time step or hypersurface to the final one. While certainly increasing the computational and memory load on the computer, this approach will have distinct advantages over conventional approaches to initial-value problems. The boundary conditions are not necessarily completely described by equation (2). While it is well known that, physically, the boundary of a boundary is zero (∂∂Ω= 0), computationally one often introduces sub-boundaries by truncating the mesh or imposing symmetries on the problem. These conditions produce right-angle kinks in the boundary, where n suddenly rotates by 90 <sup>◦</sup> and the boundary conditions abruptly change. Such boundary corners occur, e.g., where the t = 0 initial hypersurface intersects the world line of a stellar surface or (in the case of axisymmetry or plane symmetry) where the stellar surface intersects the symmetry axis or plane. For example, when solving Maxwell’s evolutionary equations on the four-dimensional domain Ωunder such conditions, they will be bounded on the t = 0 portion of ∂Ωby the initial value (solenoidal and Coulomb) constraints; these will be bounded further at an external stellar 2-surface ∂∂Ω; and these may be bounded still further by the rotation axis or equatorial plane at edges ∂∂∂Ω. Therefore, additional equations, similar to (2), with successive projection of the first two terms into the sub-boundaries of lower dimension, may be needed until one reaches the zero-dimensional ∂∂∂∂Ω (endpoints of line segments) where the conditions become simply ℜr ≡− fr(∇w, w, x) = 0 (4) In the examples in this paper all boundary conditions are of the simple form (4), but in general astrophysical situations the form (2) will be needed. 2.2. Continuous Solution: The Element Mesh Formally, in the finite element method (FEM) the computational domain Ωis subdivided not into nodes, but into sub-domains (δΩ) called “elements” — similar to “zones” or “cells” in the finite difference method (FDM). (Nodes come later, and then only to facilitate the element process.) The elements are constructed in such a way that each function w <sup>v</sup> is continuous over the entire domain, but its derivatives are only piecewise continuous; i.e., w <sup>v</sup> is continuously differentiable only within each element. The x <sup>α</sup> are treated in the same manner; they also are continuous across element boundaries with no spatial “gaps” between elements. Although a variety of generic element shapes can be used, the most common are triangular and quadrangular. Of course, these assume higher-order shapes in three and four dimensions (i.e., equilateral triangles, tetrahedra, simplices [hyper-tetrahedra]; squares, cubes, and hypercubes), but they still shall be referred to here as the triangular and quadrangular classes. In GENRAL, elements of the quadrangular type are used exclusively because of their convenience. The computational domain is filled with a topologically rectangular set of E = D−1 α <sup>′</sup> =0 ℵα′ (5) of these building blocks, where D(≤ 4) is the dimensionality of the problem, and ℵα′ is the number of elements along each mesh dimension α <sup>′</sup> . Each element that borders the domain has one surface lying on the boundary that itself is an element of dimension D − 1. The total number of such boundary elements enclosing this rectangular mesh is a sum over the rectangular faces D−1 β <sup>′̸</sup> =α <sup>′</sup> B = 2 D−1 α <sup>′</sup> =0 ℵβ′ (6) The element mesh can be distorted by stretching, compressing, bending, or even twisting it to conform to the geometry of the domain (as, for example, in a curvilinear coordinate system). In the engineering FEM this coordinate transformation is called the “isoparametric” transformation, because coordinate values x <sup>α</sup> and the variables w <sup>v</sup> are specified at the same nodal points. In general relativity this transfor 5 mation is the generalized Lorentz transform (7) L <sup>α</sup> α′ ≡ ∂ξ <sup>∂xαα′</sup> with inverse L <sup>α′</sup> α <sup>≡</sup> <sup>∂ξ</sup> ∂x <sup>αα′</sup> (8) <sup>∂ξ</sup> ∂x <sup>αα′</sup> gives the metric coefficients in mesh space. However, one still needs to choose a system in which to write the differential equations; but, since the computer will be doing all the curvilinear work for us, one can select a very simple basic system, keeping the coordinates as Cartesian (or as Minkowskian) as possible. For example, in axisymmetric problems, cylindrical coordinates will be used, not spherical-polar. For threedimensional problems, Cartesian coordinates will be used, no matter how spherical the star or flattened the accretion disk. Any curvilinear properties of the metric orthogonal to the computational domain will be embodied in the volume element <sup>√</sup> −g, and curvilinear behavior within the domain will be handled by the isoparametric transformation. 2.4. Discrete Solution: The Nodal Mesh and Interpolation Scheme As with all continuum numerical methods, the solution is expressed as a finite set of discrete values. In the FDM these are values of the solution at specified points (nodes) in space; in spectral methods these are coefficients of basis or interpolation functions. In the FEM, these discrete values are both nodal values and basis function coefficients. That is, the FEM has properties of both finite difference and spectral methods. The finite element nodes are distributed within each element in such a way that the w <sup>v</sup> can be interpolated across the element in each dimension with at least linear accuracy or better. For quadrangular elements, the simplest approach is to fill each element box with a (possibly hyper-) cubic mesh of (℘α′ + 1) nodes per dimension α <sup>′</sup>, where ℘α′ is the order of interpolation in that dimension, and nodes are shared by adjacent elements at all the interfaces (corners, edges, faces, and hyperfaces). For a problem of total number of dimensions D, the total number of nodes describing each element is, then, where ξ <sup>α′</sup> is the coordinate in mesh space, with range 0 ≤ ξ <sup>α′</sup> ≤ 1 in each dimension α <sup>′</sup> . Basis vectors along the mesh coordinate direction α <sup>′</sup>, and corresponding 1-forms, are [eα′ ] <sup>α</sup> = L <sup>α</sup> α′ [ω <sup>α′</sup> ]α = L <sup>α′</sup> α Appendix B discusses conditions that may need to be satisfied by this transformation. However, unless one wishes to use the mesh as an actual Lorentz frame of reference, or wants to follow the evolution of all wave phenomena, only the Jacobi condition is necessary for numerical stability L ≡ det||L||̸ = 0 (9) 2.3. The Choice of a Basic Coordinate System In the past, when developing a finite difference numerical simulation code, for example, it has been customary (and considered necessary) to write the differential equations in the same coordinate system described by the computational mesh. That is, if the mesh is spherical-polar, then the equations are written in spherical-polar coordinates, and so on. However, in the numerical method developed in this paper, this degeneracy is neither necessary nor desirable, as the mesh coordinate system is unknown until the problem is solved. To allow for an arbitrary, unknown mesh, the differential equations will be written in a “basic” or “real-space” (x <sup>α</sup> ) system which does not change as the calculation proceeds. The derivatives still will be computed in the mesh (ξ <sup>α′</sup> ) system, but, in order to use them in the differential equations, will then be transformed to the basic system α <sup>′</sup> =0 I = D−1 α <sup>′</sup> =0 (℘α′ + 1) (12) [∇w] <sup>v</sup> α <sup>≡</sup> <sup>wv,α</sup> <sup>=</sup> <sup>Lα′</sup> α <sup>wv</sup>,α <sup>′</sup> (10) That is, for four-dimensional elements, I = 16 for first-order (linear) interpolation, I = 81 for secondorder (quadratic) interpolation, and I = 256 for thirdorder (cubic) interpolation - just within each element. The total number of nodes in the entire mesh using the isoparametric/Lorentz transformation. The choice of coordinate system for the mesh is determined by how one lays out the elements in real space. That is, gα′β′ = L <sup>α</sup> α′ L <sup>β</sup> β′ gαβ (11) 6 is functions are given by the normal Lagrange shape function with the Lagrange shape function for that missing node subtracted off I = D−1 α <sup>′</sup> =0 α <sup>′</sup> =0 (ℵα′℘α′ + 1) (13) ˆı <sup>(ξ)</sup> <sup>=</sup> <sup>£</sup> ˆı <sup>(ξ)</sup> <sup>−</sup> <sup>£</sup> ℓˆ <sup>(ξ)</sup> (19) (no sum on α <sup>′</sup> ). The number of nodes on each element’s boundary is the total minus those in the interior N <sup>′</sup> D−1 α <sup>′</sup> =0 with ℓ <sup>ˆ</sup> ̸ = ˆı. Most of the properties of Lagrangian elements can be illustrated in one dimension. Figure 1 shows a simple 1-dimensional, 5-node mesh and its discretization in linear and quadratic elements. Note that interior shape functions have continuous derivatives at their respective nodes, while shape functions on element boundaries have discontinuous derivatives. (The latter also involve more nodes as they are composed of shape function pieces from adjacent elements.) The FEM, therefore, can be considered to be a multidomain spectral method with each of the thousands to millions of elements being a separate domain. Because the shape functions are continuous throughout Ω, the solution w and the coordinates x are truly continuous functions of position in the mesh: K = I and for the entire mesh (℘α′ - 1) (14) α <sup>′</sup> =0 K = I D−1 α <sup>′</sup> =0 α <sup>′</sup> =0 (ℵα <sup>′</sup> ℘α <sup>′</sup> - 1) (15) No matter what the value of ℘α <sup>′</sup>, in these simple cases the basis functions in mesh space for a node ˆı within a given element e are products of Lagrange interpolation polynomials £ˆıeα′ in each dimension α <sup>′</sup> N <sup>′</sup> ˆıe(ξ) = £ˆıe(ξ) eˆ <sup>)</sup> <sup>α′</sup> ≡ = D−1 α <sup>′</sup> =0 α <sup>′</sup> =0 D−1 α <sup>′</sup> =0 £ˆıeα′ (ξ <sup>α′</sup> ) ˆı <sup>(ξ) w</sup> ˆı <sup>v</sup> ˆı (21) <sup>α</sup> w <sup>v</sup> (ξ) = N <sup>′</sup> eˆ (ξ <sup>α′</sup> - ξ <sup>α′</sup> like spectral methods but unlike the FDM where interpolation is only an ad hoc addition to the scheme. Also, because a unique inverse relation ξ = ξ(x) exists, the variables have an implicit function of position in real space w <sup>v</sup> (x) = w <sup>v</sup> (ξ(x)) (22) 2.5. Formation of Derivatives and the Differential Equations We now have a numerical procedure for computing the derivatives of the w <sup>v</sup> with respect to x <sup>α</sup> . First, the coordinate transformation matrix is formed ˆı (23) L <sup>α</sup> α′ = N <sup>′</sup> ˆı,α′ x <sup>α</sup> and then inverted to obtain L <sup>α′</sup> α <sup>.</sup> <sup>Then</sup> <sup>the</sup> <sup>deriva-</sup> tives of the variables are computed in mesh space ˆı (24) w <sup>v</sup>,α′ = N <sup>′</sup> ˆı,α′w <sup>v</sup> w <sup>v</sup> (ξ) = ˆı <sup>(ξ) w</sup> ˆı <sup>v</sup> (20) N <sup>′</sup> x <sup>α</sup> (ξ) = ˆı (21) N <sup>′</sup> ˆı(ξ) x <sup>α</sup> (16) eˆ <sup>α′</sup> <sup>)</sup> α <sup>′</sup> =0 ˆ=ˆ̸ ı �I (ξˆıe <sup>α′</sup> ˆıe <sup>α′</sup> <sup>−</sup> <sup>ξ</sup> eˆ <sup>α′</sup> where ξˆıe <sup>α′</sup> <sup>is</sup> <sup>the</sup> <sup>mesh</sup> <sup>coordinate</sup> <sup>value</sup> <sup>at</sup> <sup>node</sup> <sup>ˆı</sup> <sup>in</sup> element e, N <sup>′</sup> ˆıe is the contribution from that element to the basis or “shape” function for node ˆı, as measured in the mesh (primed) system. The range of the nodal indices in the entire mesh is ˆı, ˆ = 1, ..., I, but the product in equation (16) only runs over the nodes within element. The total basis function for node ˆı is, then, a sum over the element contributions N <sup>′</sup> ˆı <sup>(ξ)</sup> <sup>=</sup> e N <sup>′</sup> ˆıe <sup>(ξ)</sup> (17) (which actually involves only those elements containing that node). Note that each shape function attains unit value at its own node and zero at all other nodes in its associated elements (and in the mesh as well) N <sup>′</sup> ˆı(ξˆ) = δˆıˆ (18) Often the body-centered nodes, and sometimes even face-centered nodes, are removed from the standard Lagrangian elements elements to form the socalled “serendipitous” elements (Zienkiewicz 1977). In that case, if node ℓ <sup>ˆ</sup> is removed, then the basis and, finally, transformed to real space by the chain rule w <sup>v</sup>,α = L <sup>α′</sup> ˆı (25) α <sup>N ′</sup> ˆı,α <sup>′ wv</sup> Although not usually used in practice in the actual computer code, it is sometimes useful for analytic 7 purposes to express the shape functions in real space coordinates and use them to interpolate the w <sup>v</sup> and compute their derivatives w <sup>v</sup> (x) = ˆı Nˆı(x) w <sup>v</sup> ˆı (27) <sup>v</sup> w <sup>v</sup> (x) = ˆı (26) Nˆı(x) w <sup>v</sup> w <sup>v</sup>,α(x) = ˆı (27) Nˆı,α(x)w <sup>v</sup> Because ℜq can contain second derivatives, the integral in equation (30) cannot be performed uniquely for every node using only the interpolation within a single element. <sup>3</sup> The standard solution to this problem, and the key step in the finite element process, is to integrate the weighted residual by parts to arrive at the so-called “weak” form The real-space Nˆı also have the normalized property at their respective nodes Nˆı(xˆ) = δˆıˆ By comparing (26) and (27) with with (20) and (25), one concludes that the real-space basis functions and their derivatives are ℑqˆı(wˆ <sup>v)</sup> = ∂Ω Wˆı(x) Tq <sup>β</sup> <sup>d(∂Ω)β</sup> <sup>−</sup> Ω (Wˆı(x),βTq <sup>β</sup> <sup>+</sup> <sup>Wˆı(x</sup> ∂Ω Wˆı(x) Tq <sup>β</sup> Ω (Wˆı(x),βTq <sup>β</sup> q <sup>β</sup> <sup>+</sup> <sup>Wˆı(x) Fq) dΩ</sup> = 0 (31) Nˆı(x) = N <sup>′</sup> ˆı(ξ(x)) (28) Nˆı,α(x) = L <sup>α′</sup> α <sup>N ′</sup> ˆı,α <sup>′</sup> <sup>(ξ(x))</sup> (29) With expressions for the w <sup>v</sup> and w <sup>v</sup>,α (either in mesh or real space) we now can calculate the residuals ℜq (equation 1) at any point in the domain Ωand ℜr (equation 4) at any point on the boundary ∂Ω, not just at the nodes. 2.6. Generation of the Nodal (“Difference”) Equations: The Weighted Residual Method 2.6.1. General Formulation The next step in the development of the astrophysical FEM is to construct a set of V I equations for the V I shape function coefficients (wˆı <sup>v) that</sup> <sup>fully</sup> <sup>de-</sup> scribe w <sup>v</sup> (x). This is accomplished by integrating the physical differential equations (1) and/or boundary conditions (4) over a function Wˆı(x) which peaks near (but not necessarily at) node ˆı and falls to zero far from that node. This produces V I discrete nodal equations Note that, in order to generate the nodal equations in the interior of the domain, weights Wˆı(x) that vanish on the boundary always will be used. Therefore, the first term in equation (31) - the boundary term - will always be zero. 2.6.2. Second-order Equations: The Galerkin Method The weighted residual method can be derived in a number of ways. In early papers on finite element analysis, only linear problems were addressed and the nodal equations were generated using a variational approach that maximizes the norm of the solution 3The problem occurs at boundary nodes, where one needs information in adjacent elements. For example, in one dimension linear shape functions have zero second derivative, so they cannot represent the kernel at all. Quadratic shape functions do have a second derivative, but only one unique value within a given element, which is valid for the central node, but not for the boundary nodes. where, in the mesh system, the volume scalar is dξ <sup>α′</sup> dξ <sup>β′</sup> dξ <sup>γ′</sup> dξ <sup>δ′</sup> (32) dΩ= L <sup>√</sup> −g <sup>ǫα′β</sup> 4! <sup>′γ′δ′</sup> the surface 1-form normal to the domain boundary is d(∂Ω)β = L <sup>α′</sup> β <sup>d(∂Ω)</sup> α <sup>′</sup> β′γ′δ′ dξ <sup>β′</sup> dξ <sup>γ′</sup> dξ <sup>δ′</sup> (33) 3! = L <sup>√</sup> −g L <sup>α′</sup> β ǫα′β′γ′δ′ and ǫ is the flat-space Levi-Civita permutation tensor. In the weak form, all terms involve only firstorder derivatives of the variables w <sup>v</sup> with respect to the nodal coordinates. Second order derivatives are generated by the Wˆı,β term which, after integration, differences the flux Tq <sup>β</sup> <sup>on</sup> <sup>each</sup> <sup>side</sup> <sup>of</sup> <sup>each</sup> <sup>node</sup> <sup>in</sup> <sup>a</sup> manner similar to a finite volume scheme. ℑqˆı(wˆ <sup>v)</sup> <sup>=</sup> Ω Wˆı(x) ℜq(wˆ <sup>v) dΩ=</sup> <sup>0</sup> (30) Relaxation schemes in the code then attempt to force the nonlinear ℑqˆı to zero. In principle, each ℑqˆı is a function of all of the w <sup>v</sup> ˆ <sup>.</sup> However, in practice, because Wˆı is peaked near node ˆı, ℑqˆı involves only nodes local to ˆı - in fact, only nodes in those elements containing node ˆı. The ℑqˆı, therefore, are more similar to difference equations than to spectral equations and, when linearized, produce a banded rather than filled matrix. 8 (Zienkiewicz 1977). This led to the form (30) with the shape function itself as the weight Wˆı <sup>G(x)</sup> <sup>=</sup> <sup>Nˆı(x)</sup> (34) This choice for Wˆı is called the Galerkin method and is especially useful for second-order equations. For example, for the simple Poisson equation in one dimension (w,xx − ρ = 0), with quadratic elements and uniform node spacing ∆x, equation (31) generates the following nodal equation at the central node ˆı of each element 4∆x [ <sup>wˆı−1 −</sup> <sup>2wˆı + wˆı+1</sup> 3 ∆x <sup>2</sup> ] = 0 10 <sup>ρˆı + ρˆı+1</sup> <sup>2wˆı + wˆı+1</sup> ∆x <sup>2</sup> - <sup>ρˆı−1 + 8</sup> 10 <sup>ρˆı + ρˆı+1</sup> which is similar to the finite difference form (wˆı−1 − 2wˆı+wˆı+1)/∆x <sup>2</sup> - ρˆı = 0. (Somewhat more complex 4th order difference equations are generated for nodes on element boundaries.) In general the Galerkin weighted residual method generates derivatives similar to those expected in finite difference schemes (although in general geometry), but scalars and source terms are weighted averages of nodes surrounding ˆı rather than evaluated exclusively at ˆı. An important property of the shape functions hints at a more fundamental interpretation of the weighted residual method that is not discussed usually in the engineering literature. As the element volume δΩapproaches zero, the shape functions become good approximations to the Dirac delta function δΩlim→0 <sup>Nˆı(x)</sup> <sup>=</sup> <sup>kˆı δΩ</sup> <sup>δ(x −</sup> <sup>xˆı)</sup> (35) (no sum on ˆı) where kˆı is a scaling constant of order unity, but generally different for each node ˆı. Therefore, with the Galerkin method, the weights Wˆı in equation (30) are generalized approximations to δ(x − xˆı) which, when integrated over a differential equation, generate or “pick out” the corresponding difference equation near node ˆı. As the number of finite elements approaches infinity, the ℑqˆı more closely approximate the complete set of ℜq defined at all points in Ω. Therefore, while originally derived for linear equations, the weighted residual method is valid for nonlinear problems as well. 2.6.3. First-order Equations: Petrov-Galerkin Schemes and “Staggered Grids” The lack of a single, universally-applicable weighting function Wˆı(x) is the main impediment against developing a truly general simulation code. One must always know the order of differential equation being integrated. For example, while the Galerkin scheme works well for second-order equations, it has the same pitfalls for first-order equations and fluid flow as centered-differencing schemes have in the FDM: leapfrogging, in which important terms in the equations do not depend on variables at the node at which the integral (31) is evaluated ((∂w/∂x)ˆı ≈ (wˆı+1 − wˆı−1)/2∆x), and two-point oscillations near shocks. Such problems can be addressed by using weighting functions other than the Nˆı. These are called Petrov-Galerkin schemes (Hughes 1987). For oddorder equations, functions that shift the peak of the weight away from node ˆı reduce or eliminate many of these problems. This is the case for weights that are shape functions of twice the element interpolation order ˆı ˆı+ <sup>1</sup> <sup>P G1</sup> (x) = N <sup>2℘</sup> 2 ˆı W <sup>P G1</sup> (36) <sup>1</sup> 2 <sup>(x)</sup> ˆı+ <sup>1</sup> and for those that are distorted by the shape function derivative ˆı (37) W <sup>P G2</sup> (x) = Nˆı ± v <sup>α</sup> Nˆı,α(x) In the first case ˆı + <sup>1</sup> 2 In the first case ˆı + <sup>1</sup> 2 <sup>signifies</sup> <sup>a</sup> <sup>position</sup> <sup>in</sup> <sup>the</sup> <sup>mesh</sup> ˆı peak centered between nodes. The functions W <sup>P G1</sup> ˆı peak centered between nodes. The functions W <sup>P G1</sup> in between nodes and have almost the same effect as using a staggered grid does in the FDM. Both ˆı ˆı generate non-leapfrogging differ W <sup>P G1</sup> and W <sup>P G2</sup> ˆı ˆı <sup>P G1</sup> and W <sup>P G2</sup> ˆı ˆı generate non-leapfrogging differ W <sup>P G1</sup> and W <sup>P G2</sup> ences ((∂w/∂x)ˆı ≈ (wˆı+1 − wˆı)/∆x) and are still generally second-order accurate (or higher) as the scalar source terms are evaluated at the same place as the derivatives. An upwinding scheme can be generated by setting v <sup>α</sup> ∝ u <sup>α</sup> and integrating only the advective terms with this weight. However, this scheme has low order accuracy and is rather diffusive (Hughes 1987). Better methods for handling shocks are the van Leer scheme (van Leer 1979), in which one enforces monotonicity in the gradient of the flux of a conserved quantity, and higher order Godonov schemes (Colella & Woodward 1984; Colella 1990) in which one applies the shock jump conditions within the element itself. Upwinding schemes in the FEM are a sub-field in themselves and are largely beyond the scope of this paper. 2.7. Application of Boundary Conditions Not all of the nodal equations generated by (31) are useful. For example, for each second order differ 9 q ential equation (one where a given T <sup>β</sup> q is a function ential equation (one where a given T <sup>β</sup> of the gradient of at least one w <sup>v</sup> ) exactly K of the nodal equations (those integrated over shape functions peaking at boundary nodes on ∂Ω) are meaningless or incomplete. This is due to the absence of elements beyond the boundary needed to complete the integrals. For first-order equations (ones where Tq <sup>β</sup> <sup>is,</sup> at most, a function of w and x only) those on only on a very simple form in this local system. For linear interpolation in one dimension (with nodes lying at s˜1e = −1 and s˜2e = +1) N˜ıe <sup>′′</sup> ˜ıe <sup>′′</sup> <sup>(se)</sup> <sup>=</sup> <sup>0.5 (1</sup> <sup>+</sup> <sup>s˜ıe</sup> <sup>se)</sup> (43) integrals. For first-order equations (ones where Tq <sup>β</sup> <sup>is,</sup> at most, a function of w and x only) those on only one portion of the boundary must be discarded (e.g., on one side or surface). These ignored nodal equations must be replaced by exactly the same number of boundary or initial conditions. These are generated in a weighted residual manner similar to that in equation (30) except that the integral and weighting functions now are evaluated on the boundary For quadratic interpolation (with element nodes lying at s˜ıe = −1, 0, +1) N˜ıe <sup>′′</sup> <sup>(se)</sup> <sup>=</sup> 0.5 s˜ıe se (1 + s˜ıe se) (s˜ıe = ±1) e <sup>)</sup> (s˜ıe = 0) - (1 − s <sup>2</sup> e <sup>2)</sup> (s˜ıe = 0) (44) and so on for higher order interpolation. (Equations [43] and [44] are the functions depicted in Figure 1.) Higher dimensional element shape functions are products of these in a manner similar to equations (16) for Lagrangian elements and (19) for serendipitous elements. Equation (31) then becomes, dropping the first term, as discussed earlier, and summing over elements and Gaussian integration points, ßrkˆ(w <sup>v</sup> ˆ <sup>)</sup> <sup>=</sup> <sup>−</sup> ∂Ω Wkˆ(x) fr(wˆ <sup>v) d(∂Ω)</sup> (38) where d(∂Ω) is the magnitude of the surface element d(∂Ω) = n <sup>β</sup> d(∂Ω)β (39) and the nodes k <sup>ˆ</sup> lie on ∂Ω. The number of equations, therefore, will remain equal to the number of unknowns, as is necessary for a well-posed problem. 2.8. Numerical Aspects of the Method 2.8.1. Integration of the Weighted Residuals In the FEM the integrals in equations (31) and (38) often are performed numerically using Gaussian integration (Abramowitz & Segun 1965), with all sampled points xg interior to element boundaries. In practice, the integrals are calculated piecewise, element by element, with each element’s contribution to the various integrals summed accordingly. To accomplish this, one defines a local mesh coordinate system, referenced to the element center and parallel to the global ξ <sup>α′</sup> system g ℑqˆı ≈− e e ωg �Wˆı(xge),βTq <sup>β</sup> q <sup>β</sup> <sup>+</sup> <sup>Wˆı(xge) Fq</sup> - δΩe (45) g (45) where δΩe = L <sup>√</sup> −g D−1 α <sup>′</sup> =0 α <sup>′</sup> =0 ∆ξe <sup>α′</sup> (46) is the element volume in the real-space coordinate system, e = 1, ..., E is the element number in the mesh, g = 1, ..., G is the number of the Gaussian integration point within element e, and ωg is the Gaussian weight at that point. Similarly, equation (38) becomes g ßrkˆ ≈− b b ωg Wkˆ(xgb) fr nb <sup>α′</sup> δ(∂Ωb)α′ (47) g where b = 1, ..., B is the boundary element number, δ(∂Ωb)α′ = L <sup>√</sup> −g D−1 β <sup>′̸</sup> =α <sup>′</sup> β <sup>′̸</sup> =α <sup>′</sup> ∆ξb <sup>β′</sup> (48) is the surface 1-form on the α <sup>′</sup> boundaries, and n <sup>α</sup> b <sup>′</sup> s <sup>α</sup> e <sup>′′</sup> δ <sup>α′′</sup> ≡ s <sup>α</sup> e <sup>′′</sup> e α <sup>′</sup> <sup>2(ξα′</sup> <sup>−</sup> <sup>ξα′</sup> e <sup>)</sup> <sup>α′</sup> <sup>−</sup> <sup>ξα′</sup> ∆ξe <sup>α′</sup> e (40) is the surface 1-form on the α <sup>′</sup> boundaries, and n <sup>α</sup> b <sup>′</sup> <sup>is</sup> one of δ <sup>α′</sup> 0 <sup>′</sup> <sup>/√−g</sup> 0 <sup>′</sup> 0 <sup>′</sup> <sup>,</sup> <sup>δα′</sup> 1 <sup>′</sup> <sup>/√−g</sup> 1 <sup>′</sup> 1 <sup>′</sup> <sup>,</sup> <sup>etc.,</sup> <sup>depending</sup> b <sup>is</sup> one of δ <sup>α′</sup> 0 <sup>′</sup> <sup>/√−g</sup> 0 <sup>′</sup> 0 <sup>′</sup> <sup>,</sup> <sup>δα′</sup> 1 <sup>′</sup> <sup>/√−g</sup> 1 <sup>′</sup> 1 <sup>′</sup> <sup>,</sup> <sup>etc.,</sup> <sup>depending</sup> on the boundary. Because the residual weights [Wˆı(xg) = W <sup>′′</sup> ˆı(sg)], their derivatives, and the Gaussian weights ωg are the same for all elements, they can be precomputed and stored prior to beginning the relaxation of the solution. The only quantities necessary to compute during the relaxation are the Tq <sup>β</sup> <sup>and Fq</sup> <sup>at each xge</sup> <sup>inte-</sup> rior integration point and the fr at each xgb boundary integration point. Because the residual weights [Wˆı(xg) = W <sup>′′</sup> ˆı(sg)], their derivatives, and the Gaussian weights ωg are the same for all elements, they can be precomputed and stored prior to beginning the relaxation of the solution. The only quantities necessary to compute during the relaxation are the Tq <sup>β</sup> <sup>and Fq</sup> <sup>at each xge</sup> <sup>inte-</sup> ∂ ∂s <sup>α</sup> e <sup>′′</sup> α <sup>′′ ∆ξ</sup> e <sup>α′</sup> ∂ (41) 2 ∂ξ <sup>α′</sup> e α <sup>′′ ∆ξα′</sup> = δ <sup>α′</sup> s <sup>α</sup> e <sup>′′</sup> (42) −1 ≤ ≤ 1 where ξe is the position in mesh space of element e’s center, ∆ξe <sup>α′</sup> <sup>is the element width in direction ξα′</sup> <sup>, and</sup> double primes refer to the local element system. The Lagrangian shape functions within each element take 10 Historically, the number of integration points G used in each element is a function of the expected nonlinearity of the product Wˆıℜq with respect to position x. In engineering, this is usually of low order (linear or quadratic), but in astrophysics this product can vary with exponential order or higher. Nevertheless, in practice, even with highly nonlinear functions, the author has had quite satisfactory results using the same number of integration points as nodes in each dimension (i.e., G = I). Fewer than this (“underintegration”) reduces the order of accuracy or even can produce a singular matrix. More than this (“overintegration”) does little to improve accuracy (of order unity improvements only) at great computational expense. 2.8.2. Solution of the Simultaneous Nonlinear Equations: The Multi-Dimensional Henyey Method For solving the V I nodal equations and boundary conditions, the author currently uses a standard multivariate Newton-Raphson technique, sometimes called the “Henyey” method in astrophysics (Clayton 1968; Aller & McLaughlin 1965). The ℑqˆı are linearized by expanding in a Taylor series about the solution w <sup>v</sup> ˆ <sup>,</sup> <sup>resulting</sup> <sup>in</sup> <sup>a</sup> <sup>matrix</sup> <sup>inversion</sup> <sup>problem</sup> the solution. Furthermore, the elements of the stiffness matrix in equation (49) can be calculated using numerical differentiation, rather than writing out explicitly the partial derivatives of each equation with respect to each variable. This eliminates the need to know the geometry of the mesh beforehand - a feature important for multidimensional astrophysical structures. Numerical differentiation of ∂ℑqˆı/∂wˆ <sup>v</sup> <sup>is</sup> structures. Numerical differentiation of ∂ℑqˆı/∂wˆ <sup>v</sup> <sup>is</sup> not necessarily more expensive than algebraic differentiation, especially if the the baseline residual integrals ℑq <sup>[n</sup> ˆı <sup>]</sup> <sup>are</sup> <sup>calculated</sup> <sup>only</sup> <sup>once</sup> <sup>for</sup> <sup>each</sup> <sup>matrix,</sup> and those partial derivatives known to be identically grals ℑq <sup>[n</sup> ˆı <sup>]</sup> <sup>are</sup> <sup>calculated</sup> <sup>only</sup> <sup>once</sup> <sup>for</sup> <sup>each</sup> <sup>matrix,</sup> and those partial derivatives known to be identically zero are not computed. ∂ℑqˆı - ∂w <sup>v</sup> ˆ ∂w <sup>v</sup> ˆ δw <sup>v</sup> ˆ δw <sup>v</sup> ˆ ˆ �[n] <sup>v</sup> ˆ qˆı (49) [n] = −ℑ[n] <sup>v</sup> ˆ qˆı [n] = −ℑ[n] (no sum on the iteration number [n]) to solve for the corrections δw <sup>v</sup> ˆ [n] which need to be applied to the corrections δw <sup>v</sup> ˆ [n] which need to be applied to the current guess to obtain a new [n +1st] approximation to the solution ˆ [n] (50) 2.8.3. Logarithmic Variables It is quite common for an astrophysical state variable - e.g., the density ρ - to vary by many orders of magnitude over Ω. Therefore, in order to maintain the same relative accuracy over the domain, it may be necessary to solve for a much more slowly varying function, e.g., ρ˜ ≡ log10(ρ). In addition, for variables that can be positive or negative (like velocity) one may need a more complex function and its inverse v˜ = slog10(v) ≡ S log10(1 + S v/vscale) (51) sdex(˜v) ≡ S vscale (10 <sup>Sv˜</sup> - 1) (52) where S ≡ sgn(v) = sgn(˜v) and vscale is a fixed scaling value for v. These “scaled logarithmic variables” are linear for |v| << vscale and logarithmic for |v| >> vscale and can be negative or positive. Unfortunately, there is some loss of convenience and intuition in re-writing the equations in terms of these new, modified variables, especially if there are many of this nature. Therefore, the following procedure has been devised in order that the differential equations still can be coded in their basic form (i.e., using ρ and v) while maintaining the accuracy of solving for log10(ρ) and slog10(v): 1. Each variable is flagged as being linear, logarithmic, or scaled logarithmic, and then stored as w˜ <sup>v</sup> = ℓ(w <sup>v</sup> ) w <sup>v</sup> ˆ ˆ [ [n+1] ≈ wv [n] + δwvˆ [n] + δwvˆ In the engineering FEM ∂ℑqˆı/∂wˆ <sup>v</sup> In the engineering FEM ∂ℑqˆı/∂wˆ <sup>v</sup> <sup>is</sup> <sup>called</sup> <sup>the</sup> <sup>“tan-</sup> gent stiffness” matrix. It has a length V I on a side and bandwidth ∼ V I <sup>(1−1/D)</sup> . At present GENRAL uses direct methods (Gaussian elimination with lowerupper decomposition) to solve equation (49), repeatedly applying the corrections until the norm over all v and ˆ ˆ ∆w ≡∥δw <sup>v</sup> ˆ [n]/wvˆ ˆ [n+1]∥ falls below a certain tolerance. w <sup>v</sup> (if linear) log10(w <sup>v</sup> ) (if logarithmic) slog10(w <sup>v</sup> ) (if scaled logarithmic) The tangent stiffness matrix need not be extremely accurate. Indeed, when ∆w << 1, the matrix need not be recomputed at all, with little impact on the rate of convergence and no impact on the accuracy of ≡    11 2. Partial derivatives of the integrals in equation (49) are calculated with respect to w˜ <sup>v</sup> . However, when computing the functions Tq <sup>β, Fq, and</sup> fr, the stored variables and their gradients are re-exponentiated to their unmodified forms with w <sup>v</sup> = ε( ˜w <sup>v</sup> ) by where the boundary conditions are applied. Fortunately, the global pivot of the matrix is a property that usually does not evolve with the simulation; it need be determined only once. Therefore, an elaborate pre-pivoting scheme has been devised for GENRAL, in which, based only on the equation order and location of boundary conditions, shape function coefficients are identified with nodal equations, useless nodal equations are discarded, and boundary conditions are inserted. Local pivoting can still shift emphasis for a given variable from one differential equation to another, but the overall global identification of integrals (31) with nodes remains fixed. 3. The Finite Element Method with Nodal Coordinates as Part of the Solution In most multi-dimensional astrophysics problems, the grid chosen initially will not be a good match for the final structure, due to a poor fit to the object boundary or poor resolution in areas of rapid gradients. Therefore, the coordinates and/or quantity of nodes should be changed as the solution converges in order to get a better fit (“adaption”). In addition, one needs to allow for the mesh at one time step to be different from that at the previous time step (grid motion). 3.1. Adaptive Gridding Adaptive gridding, as used here, means modifying the mesh spacing in order to achieve greater accuracy or stability without changing the total number of nodes or the topology of the mesh. One-dimensional stellar structure models use a form of adaptive gridding as they utilize a mass coordinate rather than radius, allowing the radius of each mass zone, including the outer stellar radius, to expand or contract depending on the current state of the star. Our general multidimensional adaptive gridding scheme takes the same form as equation (1) except that it is written in mesh space w˜ <sup>v</sup> (if linear) 10w <sup>˜v</sup> (if logarithmic) sdex( ˜w <sup>v</sup> ) (if scaled logarithmic) ≡    and w <sup>v</sup> ,β <sup>=</sup> w˜,β <sup>v</sup> ∂ℓ(w <sup>v</sup> )/∂w <sup>v</sup> With this scheme one can choose a variable to be logarithmic or not at runtime, or even switch its character during execution, without modifying the code. 2.8.4. Pivoting Lower-upper decomposition techniques work well only when the matrix elements on the diagonal are decidedly non-zero. That is, one must identify which equation ℑqˆı is “for” which variable wˆ <sup>v.</sup> <sup>The term piv-</sup> oting refers to the exchange of rows and/or columns in the matrix to ensure that all elements on the diagonal are indeed large - i.e., that the trace of the stiffness matrix is a maximum. Local, or partial, pivoting ensures that, at a given node, the correct physical equation is paired with the correct variable. For example, in MHD computations, when the electrical conductivity is infinite, the current J is determined by Maxwell’s equations, not Ohm’s law. Or, in a hydrostatic star the momentum equation determines the pressure structure, while velocity is determined by energy or particle conservation. In the standard partial pivoting algorithm one searches a matrix column for the largest element and switches the row of that element with the one presently on that column’s diagonal (Press et al. 1989). When applied at a single node, this algorithm is very successful in automatically pairing equations and variables. That is, the solution will be able to evolve from a dynamic state to a hydrostatic one without re-casting the equations or writing a new simulation code. Global pivoting ensures that an equation ℑqˆı (integrated near node ˆı) is applied at the correct node ˆ. This is a more difficult task than local pivoting and is not easily automated in our case. The correct identification is not always ˆ = ˆı, especially for firstorder equations, for which the answer is determined A <sup>α′β′</sup> ,β <sup>′</sup> <sup>=</sup> <sup>0</sup> (53) Curwhere A <sup>α′β′</sup> is the adaptive gridding tensor. rently the author is using a diagonal form Aα <sup>′</sup> α <sup>′</sup> = [fv (C1 eαˆ <sup>′</sup> ·∇w <sup>v</sup> - <sup><</sup> ∆ <sup>∆</sup> x <sup>wαv′></sup> ) + <sup>C2</sup> ∆ <sup>∆</sup> x <sup>wαv′></sup> ∆x <sup>C2</sup> ∆x <sup>α′ ]</sup> <sup>(54)</sup> which ties the mesh spacing to the local gradient of the state variables. Note the sum over V variables; fv is a vector of 1’s and 0’s that, at run time, selects those 12 state variables to which the grid should be adapted, eαˆ <sup>′</sup> is a unit vector in spacetime along the local mesh direction ξ <sup>α′</sup> [eαˆ <sup>′</sup> ] <sup>α</sup> = L <sup>α</sup> α′ |gµν L <sup>µ</sup> α′ L <sup>ν</sup> α′ | <sup>1/2</sup> (no sum on α <sup>′</sup> ), <∆w <sup>v</sup> - is the average change in w <sup>v</sup> along the mesh direction ξ <sup>α′</sup> (determined from the current solution for w <sup>v</sup> ), ∆x <sup>α′</sup> is a measure of the local linear mesh spacing along an element edge As an example, consider the non-relativistic total advective derivative in flat spacetime D ∂ = Dt ∂t <sup>+</sup> <sup>vi</sup> ∂x <sup>∂</sup> <sup>i</sup> ∂ (56) ∂ξ <sup>α′</sup> ∂ξ <sup>α′</sup> = ∂t ∂ξ∂ <sup>α′</sup> <sup>+</sup> <sup>vi ∂ξ</sup> ∂x <sup>αi′</sup> ∆ξ <sup>α′</sup> ∆x <sup>α′</sup> = eαˆ′ - L <sup>α′</sup> α eαˆ′ - L <sup>α′</sup> = (55) |gα′α′| <sup>1/2</sup> ∆ξ <sup>α′</sup> (again, no sum on α <sup>′</sup> ), and C1 ≈ 0.2 is a constant that regulates the strength of the gradient term. Equations (53) provide four constraints on the nodal coordinate values, allowing the mesh spacing along ξ <sup>α′</sup> to decrease in regions of high gradients in the variables, but to be uniform otherwise. Note that the adaptive gridding equations are not the coordinate conditions needed to complete the description of the metric (see Appendix A). They simply move nodal positions around in an already-determined metric. C2 is a very small constant (≈ 10 <sup>−10</sup> ), such that in the absence of adaptive gridding (i.e., all f <sup>v</sup> = 0) and with the proper boundary conditions, the mesh will assume an appropriate curvilinear character with uniform spacing ∆x <sup>α′</sup> in each ξ <sup>α′</sup> . 3.2. Moving Grids and the Advective Derivative Adapting the grid to local conditions changes the spatial and time coordinates of the nodes. For an observer traveling along ξ <sup>0′</sup> this produces what appears to be motion of the grid through space. Now, computational fluid dynamics on stationary, uniformlyspaced meshes is a fairly complex field in itself. On arbitrarily-spaced and moving grids the resulting mixed Lagrangian-Eulerian hydrodynamic equations might seem intractable. However, with the FEM the exact opposite is true. If the elements have an extent in time as well as in space, then the inverse isoparametric transformation will automatically take into account the complicated effects of differencing the fluid equations with respect to a moving grid. It is unnecessary, and indeed incorrect, to attempt to include the grid velocity in the differential equations. where v <sup>i</sup> is the three-velocity of fluid flow. Now, let vg <sup>i</sup> <sup>be</sup> <sup>a</sup> <sup>grid</sup> <sup>three-velocity</sup> <sup>such</sup> <sup>that</sup> <sup>e</sup> ξ <sup>i′</sup> <sup>remains</sup> parallel to exi, although eξ0 <sup>′</sup> can make an angle (tan θ = |vg| ∆t/|∆x|) with et. (These are the conditions LeBlanc & Wilson (1970, 1971) placed on their moving grid in their Lagrangian-Eulerian MHD calculations.) The isoparametric transform and its inverse then are The first term in equation (59) is the apparent time derivative (along ξ <sup>0′</sup> ) at a given node in the grid frame while the second is simply the moving advective derivative (v - vg)·∇. Thus the isoparametric transform reproduces the Lagrangian-Eulerian equations of LeBlanc & Wilson under the same conditions. 3.3. Adaptive Mesh Refinement The purpose of adaptive mesh refinement (AMR) is similar to that of adaptive gridding: to increase resolution in a local region of the mesh. However, in the case of AMR the numbers of elements and nodes usually increase as the calculation proceeds. When the element mesh extends into the time dimension, AMR makes it possible to treat efficiently the propagation of particularly important wave phenomena. Rather than subdivide the entire domain finely, one does so only for the region of spacetime near the null geodesics along which the phenomenon propagates. ∆x <sup>β</sup> ∂x <sup>β</sup> = ∂ξ <sup>α′</sup>   ∆x <sup>β</sup> (if β = α <sup>′</sup> ) ∆ξ <sup>α′</sup> vg <sup>i</sup> (57) vg <sup>i</sup> <sup>∆t</sup> (if β = i; α <sup>′</sup> = 0) ∆ξ <sup>0′</sup> 0 (otherwise) ∆ξ <sup>α′</sup> ∆∆ξx <sup>αβ′</sup> (if α <sup>′</sup> = β) ∂ξ <sup>α′</sup> = ∂x <sup>β</sup>     (58) vg <sup>i</sup> g <sup>i</sup> <sup>∆ξi′</sup> vg <sup>i</sup> ∆ <sup>∆</sup> x <sup>ξii′</sup> (if α <sup>′</sup> = 0; β = i = i <sup>′</sup> ) 0 (otherwise) 0 (no sum on β or i). Substituting equation (58) into (56) one obtains DtD <sup>=</sup> <sup>∆</sup> ∆ <sup>ξ</sup> t <sup>0′</sup> ∂ g ∂ξ <sup>0′</sup> <sup>+</sup> <sup>(vi −</sup> <sup>vi</sup> ∆x <sup>i</sup> g <sup>) ∆ξi′</sup> <sup>i</sup> ∆x <sup>i</sup> ∂ (59) ∂ξ <sup>i′</sup> 13 The Courant condition (Appendix B) prescribes one form of AMR, as it places an upper limit on the temporal mesh spacing and, therefore, a lower limit on the number of elements necessary to solve a problem. If the Courant condition is not satisfied in a local region, the number of elements in ξ <sup>0′</sup> will have to be increased. In the FEM AMR can be achieved by subdividing some of the elements, usually by a power of two in a given dimension, and then rebuilding the interpolation grid of nodes within the newly-gridded subdomain. There are two matters of concern in this case: 1) the subdivision must be done by elements, not nodes, regardless of the final order of the interpolation grid used within each element, and 2) larger elements bounding the more finely subdivided region must have their internal interpolation scheme, and hence their nodal shape functions, modified by the addition of new boundary nodes. That is, these modified elements must be serendipitous elements. This ensures that the functions w <sup>v</sup> (ξ) and x <sup>α</sup> (ξ) are continuous across element boundaries and that there are no spatial gaps or “hanging nodes”. This second requirement can significantly increase the complexity of the mesh and the number of element types for which quantities need to be pre-computed and stored. Recently, however, the astrophysical community has been embracing an alternative, multi-level approach to AMR (Truelove et al. 1998; Norman 1998). A region of space is refined not by subdividing the grid cells themselves, but by applying separate, and successively more refined, grids at the same location and with some nodes in common between each level. This hierarchical approach eliminates the hanging node problem without resorting to defining many new serendipitous element types: each grid level is subdivided with standard linear or quadratic elements. This technique also fits naturally into a multigrid iterative scheme for solving the coupled nodal equations. 4. Tests and Examples Below are presented some tests of the code GENRAL on problems with known solutions. At the present time the code uses the multi-dimensional Henyey technique to solve the difference equations it generates. As discussed earlier, this approach has severe computer time and memory limitations. Therefore, all the examples involve a much smaller number of elements than the millions that one would use in a typical astrophysical simulation. (Generally, the full code running on a desktop workstation is limited to 4096 elements or 6561 nodes total [64 <sup>2</sup>, 16 <sup>3</sup>, or 8 <sup>4</sup> linear elements or 32 <sup>2</sup>, 8 <sup>3</sup>, or 4 <sup>4</sup> quadratic elements]). Nevertheless, the tests serve to demonstrate the unique features of the FEM, including its ability to solve nonlinear astrophysics-like problems in multidimensional, arbitrary curvilinear coordinate systems and to achieve high accuracy in the solution by employing higher order interpolation, adaptive gridding, and logarithmic variables. 4.1. Simple Tests 4.1.1. Tests of the Interpolation Scheme The first tests of the method involve no differential equations. Instead, the integrands in equations (45) and (47) are set to unity so that only domain volume and surface area are computed. The results are then compared with known solutions for various shapes (rectangular hyper-solids, hyper-spheres, and ellipsoids), different element interpolation schemes (linear [℘ = 1] and quadratic [℘ = 2]), different numbers of elements ℵ in each dimension (1,2,4,8,16), and different numbers of integration points G (℘ <sup>D</sup> and (℘ + 1) <sup>D</sup> ). This procedure is more than simply a verification that the numerical integrations work. It also exercises the coordinate transformations and the ability to form proper volume and surface elements in fairly arbitrary curvilinear situations. Table 1 summarizes the results, normalizing to grids with nine nodes in each dimension. <sup>4</sup> In this case (but, unfortunately, not for the differential equation tests below) both choices for G produce the same results: for linear elements the error EΩ ≡ (Ωℵ - Ω)/Ω varies as ∆x <sup>2</sup> ∝ (ℵ℘ - 1) <sup>−2</sup>, while quadratic elements produce fourth-order errors (EΩ ∝ ∆x <sup>4</sup> ∝ (ℵ℘ - 1) <sup>−4</sup> ). Results for surface area integration are similar, although the actual fractional error is about a factor of two smaller. Results for other ellipsoidal objects are also similar. 4Given that the method is element-based, one could compare equal numbers of linear and quadratic elements in each dimension. In that case, the errors in the right-hand column of Table 1 would be a factor of 16 smaller. However, performing the comparison in the latter manner would make it difficult to tell which part of the improvement for quadratic elements is due to the interpolation scheme alone and which is due to the increase in the number of nodes. 14 TABLE 1 Error Results for Volume Integration of D-Spheres <sup>a</sup> (Meshes with 9 Nodes in Each Dimension) Fractional Error for Element Type D Linear <sup>b</sup> Quadratic <sup>b</sup> 2 −6.4 × 10 <sup>−3</sup> −4.9 × 10 <sup>−5</sup> 3 −2.0 × 10 <sup>−2</sup> −9.0 × 10 <sup>−5</sup> 4 −3.7 × 10 <sup>−2</sup> −2.2 × 10 <sup>−4</sup> aSurface area results have a similar scaling, but with a factor of two better accuracy bAccuracy for linear elements varies with ∆x2 and quadratic elements as ∆x <sup>4</sup> TABLE 2 Error Results for Cartesian Grid Tests (Meshes with 9 Nodes in Each Dimension) Normalized L2 Error for Element Type n D Linear <sup>a</sup> Quadratic <sup>a</sup> 1 1 b b 1 2 2.5 × 10 <sup>−3</sup> 1.2 × 10 <sup>−3</sup> 1 3 1.4 × 10 <sup>−3</sup> 4.0 × 10 <sup>−4</sup> 1 4 9.9 × 10 <sup>−4</sup> 1.8 × 10 <sup>−4</sup> 2222 1234 5321....8338 × × × × 10 10 10 10 <sup>−−−−3333</sup> bbbb 3 1 1.2 × 10 <sup>−2</sup> 1.2 × 10 <sup>−3</sup> 3 2 6.1 × 10 <sup>−3</sup> 6.2 × 10 <sup>−4</sup> 3 3 4.0 × 10 <sup>−3</sup> 4.0 × 10 <sup>−4</sup> 3 4 3.0 × 10 <sup>−3</sup> 2.9 × 10 <sup>−4</sup> 4 1 2.1 × 10 <sup>−2</sup> 3.1 × 10 <sup>−3</sup> 4 2 1.0 × 10 <sup>−2</sup> 1.6 × 10 <sup>−3</sup> 4 3 6.4 × 10 <sup>−3</sup> 1.0 × 10 <sup>−3</sup> 4 4 4.6 × 10 <sup>−3</sup> 7.2 × 10 <sup>−4</sup> aAccuracy for linear elements varies with ∆x2 and quadratic elements as ∆x <sup>3</sup> bExact solution obtained for one-dimensional first-order prob lems and for all second-order problems with quadratic elements 4.1.2. Fixed Cartesian Grid Tests: Poisson’s Equation in One to Four Dimensions The second set of tests involves solving a differential equation in up to four dimensions, but on a regular Cartesian (not Minkowskian) grid of dimension D. The equation used is Poisson’s equation w,αα - ρ = 0 (60) with a known solution (E <sup>L</sup> w <sup>2</sup> ∝ ∆x <sup>3</sup> ∝ (ℵ℘ - 1) <sup>−3</sup> ), not fourth-order. Secondly, underintegration (G = ℘ <sup>D</sup> ) does not work. G always must be equal to or greater than (℘ +1) <sup>D</sup> (i.e., ≥ 2 <sup>D</sup> for linear elements and ≥ 3 <sup>D</sup> for quadratic elements) in order to generate the proper second-order differences in the Laplacian. Underintegration, at best, reduces the accuracy of the solution by one order. At worst, it destroys nearest neighbor differencing, producing leap-frogged differences, and can lead to no solution at all. “Iso-integration” (G = I) is probably sufficient for any equation of the form (1), but it should be checked in each circumstance to be certain. w0 ≡ r <sup>n</sup> (61) where r ≡ x <sup>2</sup> + y <sup>2</sup> + z <sup>2</sup> + t <sup>2</sup> is the radial distance from the origin and 0 < x <sup>α</sup> < 1. The components of the generalized equation (1) are then where r ≡ from the T <sup>β</sup> = w,β (62) F = ∇ <sup>2</sup> w0 = n (n + D − 2) r <sup>(n−2)</sup> (63) with Dirichlet conditions on the entire boundary f = w − [r(∂Ω)] <sup>n</sup> (64) where r(∂Ω) is the expression for r evaluated on the boundary. This test exercises the code’s ability to solve equations (45) and (47), but does not test the coordinate transformations. Results of the fixed grid tests are given in Table 2, which shows how the accuracy of the solution in different dimensions, determined by the normalized “L2” error norm �� Ω <sup>w</sup> 0 <sup>2</sup> E <sup>L2</sup> w ≡ �� Ω <sup>(w −</sup> <sup>w0)2 dΩ</sup> �1/2 0 <sup>2</sup> <sup>dΩ</sup> and �1/2 varies with number of nodes and elements used. Two differences from the volume and surface area integration tests are worth noting. Firstly, the solution errors for quadratic elements are third-order accurate (E <sup>L</sup> w <sup>2</sup> ∝ ∆x <sup>3</sup> ∝ (ℵ℘ - 1) <sup>−3</sup> ), not fourth-order. Sec 15 4.2. Adaptive and Curvilinear Grid Tests The third set of tests exercises nearly all the features of the code in order to obtain a solution to a rather pathological Poisson problem - a FermiDirac-like function 1 (65) w0 ≡ e <sup>f</sup> <sup>(r−0.5)</sup> + 1 with a cold temperature of 1/f = 0.02. Such sudden exponential drops in the solution are common at stellar core-halo boundaries or stellar surfaces and are difficult to resolve accurately without a large number of nodes or a variable change (to optical depth, for example). For this demonstration the conservative form for the stress and force terms (in up to four Cartesian dimensions) has been chosen T <sup>β</sup> = w,β + fw (66) r[1 + e <sup>−f</sup> <sup>(r−0.5)</sup> ] a <sup>2</sup> β <sup>2</sup> β <sup>xβ</sup> Turning on the adaptive gridding equations (53), however (middle panels), significantly improves accuracy for the same number of elements. This also demonstrates one aspect of the ispoarametric transformation: variable node spacing. A closer examination of this more accurate solution, however (Figure 2, bottom left), shows very large relative errors in the log when w << 1. Nevertheless, these can be overcome easily, without re-writing and re-coding the equations, as the bottom right panel of Figure 2 shows. When w is identified as a logarithmic variable, rather than linear, the solution remains accurate over eleven orders of magnitude. (Note the different node spacing in the bottom panels, with the grid adapting to w on the left and w˜ [= log10 w] on the right.) Figure 3 shows a similar development for a twodimensional Poisson problem where the Fermi-Dirac surface has an elliptical ratio of 2:1 (a = 2). The first three panels demonstrate the errors possible in locating the surface if the proper coordinate geometry is not used. Additional improvement in accuracy can be obtained by using adaptive gridding (middle right panel). However, this solution for r - 0.5 suffers the same oscillatory errors seen in the one-dimensional case (bottom left), which again can be eliminated by identifying w as logarithmic (bottom right). It is important to note that, in all of the solutions displayed in Figures 2 and 3, no explicit curvilinear coordinate system is used. The coordinates of the grid points (whether fixed or part of an adaptive gridding solution) are stored only as xˆı and yˆı, not as rˆı and θˆı, for example, and yet are still fully arbitrary (subject to the Jacobi condition). The Poisson equation is written only in terms of x and y as well. Of course, the derivatives are still calculated using the coordinate grids shown, but then they are immediately transformed to (x, y)-space using the transformations (7) and (8). Thus, with these new techniques the grid can be moved around to obtain a more accurate solution while the physical equations remain coded in the same very simple form. The Fermi-Dirac Poisson tests were used to determine a good value for the adaptive gridding constant in equation (54). Several dozen models like those in Figures 2 and 3 were computed for different values this parameter. It was found that the accuracy improved by factors of 3 - 10 as C1 was increased from 0 to 0.2, but beyond this point the accuracy did not improve much. In fact, for values much greater than 0.2, the models became unstable, often not converging. F = 0 (67) (no sum on β) where aβ = (1, a, b, c) are constants and r ≡ �x <sup>2</sup> + a <sup>2</sup> y <sup>2</sup> + b <sup>2</sup> z <sup>2</sup> + c <sup>2</sup> t <sup>2</sup> one dimension, a = b = (For example, in one dimension, a = b = c = 0; in two dimensions, b = c = 0; and so on.) And, as one is still interested at this stage in testing the FEM machinery and not the astrophysical viability of the code, once again simple Dirichlet boundary conditions are employed, so equation (4) becomes 1 f = w − (68) exp[f (r(∂Ω) − 0.5)] + 1 rather than, for example, a multipole expansion of the interior solution. The above conservative form (66 67) was chosen in favor of other forms (such as 62 - 63) because its solutions are particularly accurate for a small number of nodes and suitable for demonstrating adaptive gridding and the use of logarithmic variables. Figure 2 shows the solution of this Poisson problem in one dimension as one applies successively more features of the code. The top panels of Figures 2 show standard fixed, equally-space grids of 8 and 16 linear elements respectively. Some improvement in accuracy can be obtained by doubling the resolution, but this incurs additional storage and computational expense. 16 Therefore, C1 = 0.2 was chosen as a semi-universal value in the adaptive gridding equation. It has proven to be useful both in the Fermi-Dirac tests in Figures 2 and 3 and in the stellar structure models below. One important point about adaptive gridding should be mentioned. As currently implemented, the technique is rather volatile and unstable. Unless great care is taken, iterations with adaptive grids often diverge, violating the Jacobi condition in the process. In the case where a single solution to a steady state problem is sought, sometimes less CPU time cost will be incurred by subdividing the mesh more finely or using quadratic elements, rather than using adaptive gridding techniques. On the other hand, when many thousands of successive models are to be computed, as is the case for evolutionary problems, each newlyconverged model will be a good initial approximation to the next evolutionary state, yielding convergence for each time step in only a few iterations. In this case, the amount of time spent converging the first adaptively-gridded model will be a small cost compared to the CPU time adaptive gridding saves over the course of the evolution by using a smaller number of elements and nodes to obtain the same high level of accuracy. 4.3. Stellar Structure Tests: Polytropic Stars The fourth series of tests adds the ability to solve a coupled set of both first- and second-order partial differential equations. It also demonstrates the use of <sup>√</sup> −g to solve a problem in which the basic coordinate system (not just the grid) is curvilinear, due to the assumption of symmetry conditions involving a coordinate direction orthogonal to the computational domain. 4.3.1. Spherical Polytropes in One Dimension In one dimension the equations for polytropic stellar structure are hydrostatic equilibrium (Euler’s equation with zero velocity), Poisson’s equation for gravity, and the polytropic equation of state dp = 0 (69) dr <sup>+</sup> <sup>ρ (n + 1) dw</sup> dr coordinate. The polytropic index n is a measure of the hardness of the equation of state; the factor (n + 1) in the hydrostatic equilibrium (HSE) equation is a normalization constant for the gravitational potential w. In semi-analytic treatments, the hydrostatic equilibrium equation is multiplied by r <sup>2</sup> /ρ, differentiated with respect to the radius r, and combined with Poisson’s equation to give a single second-order equation. Following this procedure here, however, tests only our ability to solve that simple equation and not much else. A slightly stronger test of the method would be to leave the system as a set of coupled equations and identify Tp <sup>r</sup> = p,r + ρ (n + 1) w,r Fp = 0 Tw <sup>r</sup> = w,r (72) Fw = ρ (73) = r <sup>2</sup> (74) √−g with boundary conditions at r = 0 of p = 1 and p,r = 0. Note the need for a non-unit volume element of r <sup>2</sup> in order to form the proper divergence. A basic curvilinear coordinate system must be used because of the spherical symmetry assumed in directions orthogonal to er. Unfortunately, the above approach is still unsatisfactory, because it cleverly casts HSE as a secondorder equation, avoiding the first-order equation problems discussed earlier. Also, as shown below, it does not lend itself to generalization to two or more dimensions. To address these issues, the following alternate identification of the stress and force terms for the pressure equation has been chosen Tp <sup>r</sup> = 0 (75) Fp = p,r + ρ (n + 1) w,r (76) which casts HSE as a first-order equation (with only the boundary condition p = 1 at r = 0). Boundary conditions on the potential w are w,r = 0 at the stellar center and w = −rsurface/r at the stellar surface. In addition, the condition p = ps ≡ 10 <sup>−4</sup> is applied at the surface on the adaptive gridding equation to determine the stellar radius. Figure 4 shows an n = 1 polytrope in one dimension, which has the analytic solution ρ = <sup>sin r</sup> p = ρ <sup>2</sup> r w = −ρ − 1 - ρ = 0 (70) p = ρ <sup>1+1/n</sup> (71) r <sup>2</sup> <sup>dw</sup> dr 1 r <sup>2</sup> d dr Pressure p and density ρ are unity at the stellar center and zero at its surface, and r is the spherical radius 17 The left panel uses only the Galerkin method, while the right two panels show the solution using the Petrov-Galerkin scheme in equation (37) to integrate the HSE equation. The need to treat first-order equations differently from second-order ones is clearly evident. The leapfrogging first-order differences produced by the Galerkin method not only display pointto-point oscillations, they also miss an implicit boundary condition (p,r = 0 at r = 0, implied by w,r = 0 and equation 76). The Petrov-Galerkin scheme improves the accuracy considerably, and with adaptive gridding remains roughly second order accurate for linear elements and third order for quadratic. At the present time no robust, automated method for determining the order of the differential equation has been developed. The code must be told explicitly not only the order of each equation but also the location(s) of the boundary conditions. While this is the greatest obstacle to producing a truly general continuum simulation code to solve all types of equations, it is a relatively modest amount of effort compared with writing a new code for each problem. 4.3.2. Rotating Polytropes in Two Dimensions Treatment of a uniformly-rotating polytropic star in two dimensions poses several problems. Firstly, it appears to be an overdetermined system ∇p + ρ (n + 1) ∇w - ρRErot eR = 0 (77) 1 ∂ R <sup>∂w</sup> + <sup>∂2w</sup> = 0 (78) R ∂R ∂R - - ∂Z <sup>2</sup> <sup>−</sup> <sup>ρ</sup> perturbations when both the Dirichlet and Neumann boundary conditions are applied on the same (r = 0) surface, leaving the stellar surface free. Setting p = ps at the surface does not help either; in this case the mesh must become adaptive, and this constraint must be used as a boundary condition on the adaptive gridding equations, not on HSE. Moving the Neumann condition to the stellar surface is a better approach, but difficult to apply for more complex problems (e.g., rotating polytropes). An approach that does work is to project the HSE equation along a direction in which p and w have significant gradients. The projection direction need not be along ep ≡−∇p/|∇p|; er appears sufficient, even when the polytrope is rotating rapidly. But it must not be orthogonal to ep, along which the gradients are zero. The components of the general stressforce equation for the rotating polytrope are, therefore, similar to (75)-(76) and (72)-(74) Tp <sup>i</sup> = 0 (80) Fp = e <sup>i</sup> <sup>i</sup> r r <sup>[p,i</sup> <sup>+</sup> <sup>ρ (n + 1) w,i] −</sup> <sup>ρRErot</sup> <sup>eR</sup> Fp = e <sup>i</sup> r (81) r <sup>[p,i</sup> <sup>+</sup> <sup>ρ (n + 1) w,i] −</sup> <sup>ρRErot</sup> <sup>eR</sup> Tw <sup>i</sup> = w,i (82) w <sup>i</sup> = w,i (82) p = ρ <sup>[1+1/n]</sup> (79) ∂ ∂R R <sup>∂w</sup> ∂R ∂R + <sup>∂2w</sup> - ∂Z <sup>2</sup> ∂Z <sup>∂2w2</sup> <sup>−</sup> <sup>ρ</sup> = 0 (78) Fw = ρ (83) = R (84) √−g with a sum on i over R and Z, boundary conditions p = 1 and e <sup>i</sup> r <sup>w,i</sup> <sup>=</sup> <sup>0</sup> <sup>at</sup> <sup>the</sup> <sup>stellar</sup> <sup>center</sup> <sup>and</sup> <sup>at</sup> <sup>the</sup> stellar surface fp = p - ps (85) fw = w - ws (86) where ps << 1 is a small fraction of the central pressure and ws is the specified surface potential. Two different methods were tested for calculating ws. The first was an exterior multipole expansion (where Erot ≡ ω <sup>2</sup> /4πGρ is the normalized rotational energy per unit mass, ω is the uniform angular velocity of stellar rotation, and R and Z are the cylindrical radius and axis coordinates) with four equations but only three unknowns. In normal astrophysical situations this dilemma will not arise, as the fluid equations plus the conservation of energy are a well-posed problem. However, it occurs here because two unknowns (vR and vZ ) and only one equation (conservation of mass) have been removed from the full set. The trick is to convert the two redundant equations for HSE (77) into only one. One possible solution is to form a single secondorder equation by taking the divergence of the HSE equation, similar to the standard semi-analytic approach. However, while it works fine in one dimension, this approach is unstable to two-dimensional ws <sup>M</sup> = L ℓ=0 Mℓ r <sup>−ℓ−1</sup> Pℓ(Z/r) (87) where the Pℓ are Legendre polynomials and Mℓ are the moments of the mass distribution in the star Mℓ = Ω ρ(R, Z) r <sup>ℓ</sup> R dR dZ (88) which, because of additional equatorial plane symmetry, are non-zero only for even ℓ. Generally, orders up to L = 12 were used. The second method used a 18 Green’s function integral over the domain ws <sup>I</sup> = = Ω ρ |x − xs| <sup>dΩ</sup> Ω ρ(R, Z) R dR dZ [R <sup>2</sup> + Rs <sup>2</sup> + (Z − Zs) <sup>2</sup> ] <sup>1/2</sup> × Ie as the integrals are done only for surface points, this hybrid technique (differential equation with integral boundary conditions) still will be much cheaper than computing the global potential by performing such an integral for every point in the domain. Figure 5 shows two dimensional n = 1 non-rotating polytropes for the two element classes each with 9 <sup>2</sup> nodes - the analog of the middle and right panels of Figure 4 - using the multipole boundary condition. Note especially the variable grid spacing near the stellar surface and the difference in smoothness between linear and quadratic interpolation. Figure 6 shows the same models for the 33 <sup>2</sup> node cases. Note especially the departure from sphericity in the pressure contours in the models employing linear elements that is absent in the quadratic element cases; the 9 <sup>2</sup> quadratic model is more accurate than the 33 <sup>2</sup> linear model. However, errors in the two cases scale only as ln - ((RR − + RRss)) <sup>2</sup> 2 + (+ (ZZ − − ZZss)) <sup>2</sup> 2 ((RR − + RRss)) <sup>2</sup> 2 + (+ (ZZ − − ZZss)) <sup>2</sup> 2 �1/2 <sup>�</sup> (89) This expression is valid for all continuous, Newtonian self-gravitating, axisymmetric systems. <sup>5</sup> The singleparameter complete elliptic integral ds (90) (1 − tanh α cos 2πs) <sup>1/2</sup> Ie(α) ≡ 0 - 1 0 represents the summed relative contributions to the surface potential at (Rs, Zs) from different angular elements of a ring of matter at (R, Z). Ie diverges with α (a measure of how close the ring is to xs), but it can be evaluated numerically easily and tabulated to a part in 10 <sup>10</sup> accuracy for the useful range 0 ≤ α ≤ 10 (i.e., for rings approaching within only a fraction 2 × e <sup>−10</sup> = 9.1 × 10 <sup>−5</sup> of |xs|) over which the integral lies in the range 1.0 ≤ Ie ≤ 5.1. In all models presented here, even with the largest meshes (33 <sup>2</sup> ) welland belowadaptive8.0 griddingand Ie below(Rs/δR4.2.s ∼> 200), α remains which is one full order less accurate than expected. This may be due to the reflective boundary conditions along the axis and equator, which are only first and second order accurate, respectively, in the linear and quadratic cases. The nature of this boundary condition cannot be improved at this time, but will be once iterative/multigrid methods for solving the coupled equations are implemented. This will allow boundary “ghost” elements to be handled easily, allowing application of boundary conditions as accurate as the mesh interior. The Maclaurin spheroid sequence (a series of n = 0, uniform density polytropes) provides a full twodimensional test of the method. (Note that the method takes no advantage of the uniform rotation, uniform density, or polytropicity, so the ability of the code to solve the Maclaurin problem is a good indication of how it will do on general multidimensional stellar structure and other more complex problems.) The appearance of Maclaurin spheroids is similar to that of the n = 1 polytropes in Figure 5 and 6, but the logarithm of the pressure varies little with radius except near the surface, where the radial grid spacing decreases dramatically due to the sudden pressure drop. For this reason it is sufficient to use a larger pressure boundary value (ps = 10 <sup>−2</sup> rather than 10 <sup>−4</sup> ) in order to determine the locus of the Maclaurin spheroid surface. Figure 7 shows the analogy of Figure 6 for a Maclaurin spheroid with ω <sup>2</sup> /2πGρ = 0.224 E <sup>L2</sup> E <sup>L2</sup> <sup>L2</sup> quadratic ∝ (ℵ℘) <sup>−2.0</sup> <sup>L2</sup> linear ∝ (ℵ℘) <sup>−1.0</sup> As implemented in the author’s code, the speed of the integral outer boundary condition technique was significantly slower than the exterior multipole expansion, increasing the time to form the stiffness matrix (although not affecting the time to invert it) by factors of several. While the author made no attempt to optimize the implementation, even after such efforts it nevertheless should remain somewhat expensive, as it requires (for each non-zero stiffness matrix element and each right-hand-side vector element) the complete integration of the potential (equation 89) at 4-6 surface points, each integration being the equivalent of of a multipole moment computation. However, while the multipole expansion began to break down for modest rotation speeds, the integral technique converged with no problem for all rotation speeds up to breakup, making the extra computational effort worthwhile and necessary. In addition, 5The integral in equation (89) is over both northern and southern hemispheres of the star. If, as is often the case, reflection symmetry is assumed at the equator and Ωrefers only to the northern hemisphere, then the integral must take into account the southern contribution as well by summing one term as above plus one term with (Z - Zs) replaced by (Z + Zs). 19 very near the theoretical limit of 0.2246656 (Tassoul (1978)). The integral boundary condition (89) is used to compute the surface potential. The complete Maclaurin series from ω <sup>2</sup> /2πGρ = 0 to 0.224 was computed in four different ways, using 9 <sup>2</sup> and 17 <sup>2</sup> nodes for the two classes of elements (linear and quadratic). Values of τ ≡ Erot/|Ew|, the rotational flattening ratio of the semi-minor and semimajormentumaxesJ =f =Erot121 −Ωa <sup>ρ</sup> Z <sup>(R, Z</sup> /aR, <sup>)R</sup> and <sup>2 dΩhave</sup> total angular <sup>been</sup> <sup>com-</sup> mo puted from these models and are compared in Figure 8 with analytic curves from Tassoul (1978) and Chandrasekhar (1969). The fractional errors for the four series are shown in Figure 9. The models are quite accurate for such a small number of elements, with errors in the 10 <sup>−3</sup> to 10 <sup>−4</sup> range in the 17 <sup>2</sup> quadratic case. They show the expected result that third order interpolation is significantly more accurate than second order, but the decrease in the errors with increasing numbers of elements is not as steep as expected. Most of this behavior is probably due to the less accurate reflective boundary conditions mentioned earlier. 1 2 rot mentum J = E 5. Discussion 5.1. Summary This paper has developed a general method for solving multidimensional structural, and dynamical, problems of astrophysics. Virtually all situations involving continuous media are potentially addressable - in normal flat Cartesian space or in curved spacetime. Problems in this area include, but are not limited to, the full structure and secular evolution of viscous, rotating (and even magnetized) stars and accretion disks in two and three dimensions, interacting binaries, asymmetric stellar envelopes and winds, non-radial pulsating stars, nonlinear development of secular and thermal accretion disk instabilities, and stationary or evolving spacetimes. While this method is most useful for structures that evolve on timescales long compared to a dynamical time, there is no formal restriction on how short the evolution time must be. Therefore, the approach to dynamical instabilities from a stable configuration, and even initial dynamical development, also can be studied, although the author still recommends the use of an explicit code for full dynamical evolution. The equations of continuum astrophysics have been condensed into a general compact covariant form, and that form encoded into the author’s FEM program GENRAL. A user can solve a particular astrophysics problem by supplying a single subroutine that takes as input one given coordinate position, plus the value of the variables and their gradients there, and returns as output the differential equations (i.e., the generalized “stress tensor”, “body force vector”, and possible boundary conditions appropriate for that problem). The program then generates the nodal or “difference” equations on a user-specified general curvilinear grid using the finite element weighted residual integrals, and solves the large set of coupled equations to produce the solution to the equations. While described by discrete nodal values, as in finite difference methods, the finite element solution is continuous, as in spectral methods, due to the finite element interpolation functions. Either second order (linear interpolation) or third order (quadratic interpolation) accurate solutions are possible in the code. In addition, the positions of the nodes themselves can be part of the solution (a “rubber” mesh), allowing grids to be fit to unknown boundary shapes and regions of high gradients to be more finely resolved with the same number of mesh points. While the method is cast in a full covariant form, it is anticipated that the initial applications will be mainly in the area of non-relativistic stars or accretion disks in static gravitational fields. The covariant form, however, is important even for non-relativistic problems. When the mesh extends into the time domain, even only for one or two elements, the coordinate transformations that are a natural component of the finite element method automatically generate any arbitrary Lagrangian-Eulerian (ALE) advective derivatives needed to take possible grid motion into account. The method has been demonstrated on astrophysically interesting problems (spherical or rotating polytropic stars) in one and two dimensions, with full adaptive gridding, and on simpler problems in three and four dimensions. 5.2. A Note on the Solution of Elliptic Potential Problems A great deal has been written on the numerical solution of astrophysical potential problems like equation (78). The technique used here has elements of past approaches plus some new features and is wellsuited to the FEM. Like many past authors (Clement 1978; Bonazzola, Gourgoulhon, & Marck 1998), the 20 approach here casts the problem as a differential equation with boundary conditions specified on the exterior of the domain. However, rather than being a simple 1/r or low-order multipole potential at a large radius in the vacuum region, the author’s preferred boundary condition is an integral solution of the differential equation, specified at the stellar surface. This integral is physically equivalent (on that surface) to the “full integral” technique that computes the potential throughout the computational domain using a Green’s function integral rather than solving the differential equation itself (Tassoul (1978); Eriguchi & M¨uller 1985; Komatsu, Eriguchi, & Hachisu 1989). However, the author’s method of evaluating this integral is somewhat different as it requires no expansion in terms of Legendre polynomials, relying instead on a single, slowly-varying, numerically-tabulated function Ie(α) to handle the axisymmetry of the potential field. When calculated in this manner, using the integration techniques already available in the FEM, the numerical integral is a solution of the discrete finite element equations themselves to within the truncation error. The boundary condition and interior differential equation, therefore, match well, leading to good convergence of the models. This technique will work in any situation where the full integral technique can be used: extension of the Newtonian case into three dimensions will be trivial, and it will be straightforward for the general relativistic case as well. In three dimensions there is no axisymmetry, so Ie(α) will not be needed, and |x−xs| will take the simple Pythagorean form. For axisymmetric relativistic stars, the four metric potentials are given by three Green’s function integrals plus a first order equation (Komatsu, Eriguchi, & Hachisu 1989). Therefore, the three elliptic equations can be solved in the same manner as Poisson’s equation is solved here (although probably using different tabulated Ie functions), preserving the differential equations in the stellar interior but using the integral solution on the surface. The fourth equation would be handled with the Petrov-Galerkin scheme demonstrated in section 4. The advantage of this approach compared to the full integral technique is speed (the number of volume integrals is proportional to the domain surface area, not the volume). The advantage over the multidomain technique is convenience (one does not have to deal with the vacuum region and the matching of stellar and vacuum solutions). 5.3. Unresolved Issues While the code and method are mature enough to begin solving two-dimensional structural problems routinely, there are several unresolved issues, mentioned in the text, that must be addressed more completely before the full potential of the astrophysical finite element method can be realized. First and foremost are the execution speed and memory issues. While the reader may consider the generation of the transformations and finite element integrals rather time-consuming, by far the greatest use of computer resources is the technique currently used to solve the coupled equations - the Henyey technique. For large meshes in three or more dimensions, it becomes prohibitively expensive, requiring thousands to many millions of years of CPU time (∝ [ℵ℘] <sup>3D−2</sup> ) and equally absurd amounts of memory (∝ [ℵ℘] <sup>2D−1</sup> ) to invert once. However, multigrid methods (Brandt 1977) need only about twice the grid size in storage (∝ [ℵ℘] <sup>D</sup> ) and only require a few sweeps of the mesh to converge (∝ [ℵ℘] <sup>D</sup> log[ℵ℘] <sup>D</sup> ). The author and P. Godon have been experimenting with modern parallel multigrid algorithms in finite difference codes with considerable success. The CPUtime and memory scalings, and linear speedup on parallel supercomputers, all have been realized. Efforts are currently underway to make GENRAL a parallel, multigrid FEM code. Implementation of iterative schemes like multigrid for solving the equations will make straightforward the application of accurate reflective and periodic boundary conditions. While possible with the Henyey technique, this process is much more difficult as it involves columns of matrix elements far from the diagonal and special techniques for inversion. With iterative methods, as with explicit codes, one can enclose the computational domain in a layer of “ghost” elements whose properties are determined at each iteration by the interior solution. The ghost element approach will have the same order of accuracy as the interpolation scheme, unlike the current approach for the reflective boundary condition, which uses essentially a backward difference. Another possibly important issue is time evolution. All examples in this paper, even the four-dimensional ones, are time-independent and use a Cartesian metric. The inclusion of time dependence may be as simple as employing a Minkowski metric and time derivatives of the variables, and the letting the finite element 21 machinery solve the problem. Often, however, the addition of a new feature generates new numerical problems which require modification of that machinery. Until more experience is obtained with time dependent problems, it is not clear whether the techniques discussed here are complete or whether they will need additional major development to handle evolutionary situations. Finally, many issues remain in the use of the finite element method for dynamical evolution problems. These are currently important topics in the engineering field, but, because explicit finite difference codes do well for astrophysical problems in this area, development of these issues here will have lower priority. They include adaptive mesh refinement (for dynamical collapse situations), implementation of the general boundary conditions in equation (2) (for magnetohydrodynamics and solving Maxwell’s or Einstein’s equations), and proper upwinding schemes with behavior comparable to the higher order Godonov schemes (for problems that develop shocks). 5.4. A Note on Numerical Relativity with Finite Element Analysis In numerical relativity it is customary to perform a “3+1 split” of the metric such that ds <sup>2</sup> = (−α <sup>2</sup> + βiβ <sup>i</sup> )dt <sup>2</sup> + 2βi dx <sup>i</sup> dt + γij dx <sup>i</sup> dx <sup>j</sup> (91) where γij is the 3-metric that raises or lowers indices on the shift 3-vector βi, and α is the “lapse function”, all of which are functions of position in spacetime (Arnowitt, Deser, & Misner 1962; York 1979). The 3-metric is specified on the initial hypersurface by solving the field constraints (initial value data), the lapse and shift are computed from four coordinate (or “gauge”) conditions, and the Einstein field equations are used to evolve γij to the next hypersurface. The goal is to choose a gauge in which the hypersurfaces do not intersect a singularity before a significant amount of evolution occurs in some part of the mesh. The current method for singularity avoidance is to eliminate pathological parts of spacetime from the mesh (“excise the black hole”) (Cook et al. 1998). While such an approach is also possible with the FEM (Arnold, Mukherjee, & Pouly 1998, advancing time in a step-by-step fashion, the full covariant nature of the method and the lifting of the degeneracy between basic and mesh coordinate systems, allow ad ditional approaches to be taken. In particular, it becomes possible to extend the mesh fully in the time dimension, from initial to final hypersurface, choosing a relatively simple gauge for α and βi. Then, adaptive gridding in all four dimensions can be used to keep the grid boundaries away from singularities and to further adjust the separation in time between spacelike hypersurfaces. Because of the ispoarametric transformation, the foliation no longer has to be along surfaces of constant time x <sup>0</sup> . The separation between adjacent surfaces can be non-uniform, the time coordinate can vary considerably over the hypersurfaces, and the final hypersurface even can end at different times. In effect, the adaptive gridding completes, in mesh coordinates, the job of slicing and singularityavoiding that a poor gauge choice may fail to do. One advantage of this approach is that some or all of the field constraints can be applied on the final, instead of initial, hypersurface, turning an explicit hyperbolic problem into an implicit boundary value problem (like stellar structure) and possibly stabilizing the growth of errors. However, while such techniques probably can succeed in keeping physical singularities at bay, it is doubtful that they can avoid coordinate singularities in general situations. (These arise in the most benign of curved surfaces - on the surface of the earth, for example.) Apart from knowing the geometry before hand and choosing the proper basic coordinate system, there are only a few ways to avoid these problems entirely. One is to embed the spacetime in a higher dimensional, flat Minkowskian space. In principle, as many dimensions as independent spacetime metric coefficients (ten) would be needed for the embedding, although it may be possible with fewer. From the ten hyperspace coordinates, and how they vary in the four-dimensional mesh, one then could derive the local metric of the spacetime and use it in the physical equations. These ten equations for the metric in terms of the hyper-coordinates, plus the six Einstein equations and the four adaptive gridding equations, would be sufficient to determine the twenty independent gαβ and hyper-coordinates at each node in the finite element mesh. While a fairly immense job for present-day computers, this prescription has the advantage of being singularity-free in general situations. Another method of avoiding coordinate singularities using the FEM is to dispense with global coordinates entirely, using only line segment lengths and deficit angles to describe the geometry and the Regge 22 calculus to describe the physics (Regge 1961; Holst 1998). At present, this approach has been developed only for simplex-type elements and not hypercubes, so it is not a straightforward application of the code discussed herein. However, it may be useful to recast the Regge calculus for other element types. Finally, all methods that involve a full four-dimensional finite element spacetime are probably well beyond the capabilities of present computer technology, even with the use of parallel multigrid techniques. Nevertheless, they appear to have such attractive features and elegance that it is important to begin to develop them. The author is grateful to J. Fanselow for support during the early development of this work, to L. Caroff and M. Bicay at NASA for allowing a small portion of a theoretical astrophysics grant to be used for this purpose, and to the JPL Director’s Research and Development Fund for support to complete this work. Discussions with numerous people were very helpful, including G. Lyzenga and A. Raefsky on the finite element method, M. Norman on adaptive gridding, P. Godon on spectral methods and multigrid methods, and W. Cannon, S. Finn, M. Holst, K. Thorne, and J. York on the use of these techniques for general relativity. This research was carried out at the Jet Propulsion Laboratory, California Institute of Technology, under contract to the National Aeronautics and Space Administration. A. Appendix A. Casting of the Differential Equations of Continuum Astrophysics into General Finite Element Form This appendix shows that virtually all the equations of astrophysics of continuous media can be cast into the flux-conservative, finite element form (equation 1) and their boundary conditions into equation (2). That is, while possibly second order in spatial and time derivatives, they can be written as the fourdivergence of a generalized stress tensor plus a generalized body force vector, each of which are functions of no more than the first spacetime derivative (four-gradient) of the variables. Of course, it is always possible to define additional variables (e.g., the 24 connection coefficients) and turn the field equations and conservation laws into first-order equations involving only the Fq term in equation (1). The challenge, however, is to use only the original metric and field components as variables (avoiding additional computational expense), and still maintain the flux-conservative form. Below is one solution to this problem. A.1. The Equations in Geometric Form The discussion here is concerned only with differential equations. Local physics, such as the equations of state, opacity, emissivity, viscosity, etc., is not treated in detail. While having position and time dependence, these processes can be described with simple algebraic equations that do not affect the numerical method used. The differential equations are the deceptively simple set of the Einstein equations for the gravitational field G = 8π T (A1) (where G and T are the symmetric Einstein curvature and stress-energy-momentum [SEM] tensors), and Maxwell’s equations for the electromagnetic field ∇· F = 4π J (A2) ∇· M = 0 (A3) where ∇ is the covariant gradient operator, the antisymmetric Maxwell tensor M = <sup>∗</sup> F is the dual of the antisymmetric Faraday tensor F, and J is the four-current. With the symmetry, equations (A1) are 10 in number, and (A2)-(A3) constitute 8, for a total of 18. However, because of identities satisfied by the Einstein and Faraday tensors, there are actually only 12 independent equations (6 metric and 6 electromagnetic) but 16 unknowns at each point in space: the 10 independent components of the metric g and the 6 independent components (the electric and magnetic fields E and B) of the antisymmetric Faraday tensor. The remaining 4 metric unknowns are determined by the choice of a coordinate system or gauge. The standard method for generating a set of 12 evolutionary equations is to project (A1)-(A3) into the hypersurface normal to a time-like vector (or world line) n with the projection tensor (equation 3). For example, if nµ = g0µ/ <sup>√</sup> −g00), then only the spatial part Sij will be non-zero, with i, j = 1, 2, 3. In general, however, n can be any time-like vector, so the equations will be left in general form. If the twelve spacelike components of equations (A1)-(A3) are satisfied throughout the four-dimensional spacetime domain Ω(with one factor of S for each tensor 23 order) S - G - S = 8π S - T - S (A4) S· (∇· F ) = 4π S - J (A5) S· (∇· M) = 0 (A6) then all that is necessary to satisfy the timelike components n · G = 8π n · T (A7) n · ∇· F = 4π n · J (A8) n · ∇· M = 0 (A9) throughout all spacetime is to satisfy the latter equations on one hypersurface only. Equations (A4)-(A6), therefore, are the 12 independent differential equations to be solved for the six metric and six electromagnetic field components, while equations (A7)(A9) are the constraints that need to be satisfied in order for a solution to exist at all. (For reference, equation (A5) is Ampere’s law, (A6) Faraday’s law, (A7) contains the Hamiltonian and momentum constraints [by further contraction with n or S, respectively], (A8) is Coulomb’s law, and (A9) is the solenoidal condition on the magnetic field.) Equations (A4), with (A7) as initial conditions, constitute the Cauchy problem of general relativity. Equations (A6) and (A9) are the covariant form of the Evans-Hawley “constrained transport” method for enforcing the solenoidal constraint in nonrelativistic magnetohydrodynamics (Evans & Hawley 1988). Equations (A5) and (A8) represent constrained transport in the presence of sources. When (A4)-(A6) are solved as Cauchy problems, equations (A7)-(A9) are applied on the initial hypersurface. However, as our approach here is to relax the system for a four-dimensional spacetime, instead of evolving a three-dimensional surface forward in time, they can be applied on any spacelike hypersurface. In addition to the field equations, there are conservation laws that follow from identities satisfied by the fields. The Einstein curvature tensor is constructed in such a way that ∇· G = 0, so the conservation of energy and momentum ∇· T = 0 (A10) must also hold from equation (A1). Similarly, as F satisfies ∇· (∇· F ) = 0, then the four-current must also be conserved ∇· J = 0 (A11) The field equations then are “closed” by expressing the SEM tensor and four-current in terms of the state variables, and solving the conservation laws of energy and momentum for those variables. For most conceivable astrophysical situations - including those with multi-fluid dynamics, electromagnetic fields and currents, radiation, viscosity, and nuclear reactions expressions for T and J involve terms with, at most, first-order derivatives of the state variables with respect to space or time. This is true even in situations near black hole horizons where particle interaction and fluid flow time scales are comparable, and equations like Ohm’s law, for example, are no longer valid. A final group of differential equations comes from forming the zeroth, first, and second moments of the Boltzmann-Vlasov equation for each particle species (j) (photons, nuclei, etc.). These determine each species’ individual number density, velocity (including the peculiar drift velocity q <sup>(j)</sup> ), and internal energy per particle. The kinetic equations give rise to familiar processes like nuclear burning, radiative transport, viscosity, and electrical conductivity. Nevertheless, they all have the same “conservative” form, with the divergence of a term that involves (at most) first-order spatial derivatives of the state variables. For example, the zeroth moment of these kinetic equations yields ∇· N <sup>(j)</sup> [u + q <sup>(j)</sup> ] = c <sup>(j)</sup> (A12) where N <sup>(j)</sup> s the particle number density and c <sup>(j)</sup> is the net particle creation rate due to nuclear reactions. For many astrophysical situations, particle conservation will be the only one of these equations needed, the drift velocity and particle energies being determined by the diffusion or other approximations. A.2. The Equations in Component Form With no loss of generality one can choose to write the differential equations in a coordinate frame. In this case, the connection coefficients are given by Γ <sup>α</sup> βγ = <sup>1</sup> 2 <sup>gαµ (gµβ,γ</sup> <sup>+</sup> <sup>gµγ,β</sup> <sup>−</sup> <sup>gβγ,µ)</sup> (A13) and their trace reduces to (A14) Γ <sup>µ</sup> βµ = (ln <sup>√</sup> −g),β where g is the determinant of the metric g ≡ det||g|| (A15) 24 This yields simple expressions for the gradients and divergences in curved space, and the field equations (A4, A5, and A6) and conservation laws (A10, A11, and A12) become { S <sup>α</sup> i[n <sup>β</sup> (Γ <sup>µ</sup> ανΓ <sup>µ</sup> βν - Γ <sup>µ</sup> αµΓ <sup>ν</sup> βν + 8πTαβ) + αβ <sup>n</sup> µ,γ <sup>nγ</sup> <sup>+</sup> <sup>nβ</sup> (n <sup>β</sup> S <sup>α</sup> iΓ <sup>µ</sup> αβ √−g),γSαµ − (SβµSαiΓµαβ = 0 (A22) 8π(n <sup>α</sup> n <sup>β</sup> Tαβ - <sup>1</sup> 2 <sup>T ) ] √−g</sup> √−g),γnγ − αβ <sup>] +</sup> <sup>α</sup> i <sup>(Γµ</sup> αβ <sup>Sβ</sup> j <sup>−Sµ</sup> j <sup>Γβ</sup> αβ <sup>)√−g ]</sup>,µ <sup>−</sup> { S <sup>α</sup> iS <sup>β</sup> j[ Γ <sup>µ</sup> αν Γ <sup>ν</sup> βµ - Γ <sup>µ</sup> αµΓ <sup>ν</sup> βν ] + αβ <sup>n</sup> µ,γ <sup>nγ</sup> <sup>+</sup> <sup>nβ</sup>,µ <sup>β</sup>,µ <sup>Γµ</sup> [ S <sup>α</sup> i <sup>(Γµ</sup> αβ <sup>Sβ</sup> j <sup>−Sµ</sup> j <sup>Γβ</sup> n <sup>β</sup> Γ <sup>µ</sup> (S <sup>α</sup> i <sup>Sβ</sup> j <sup>)</sup>,µ <sup>Γµ</sup> αβ <sup>−</sup> <sup>(Sα</sup> i <sup>Sβ</sup> j <sup>)</sup>,β <sup>Γµ</sup> αµ <sup>+</sup> = 0 (A23) S <sup>α</sup> i,µ(n <sup>β</sup> Γ <sup>µ</sup> αβ - n <sup>µ</sup> Γ <sup>ν</sup> αν )} <sup>√</sup> −g = 0 (A16) 8π(S <sup>α</sup> iTαβ S <sup>β</sup> j - <sup>1</sup> 2 <sup>Sij</sup> <sup>T ) } √−g</sup> (nµF <sup>µν √</sup> −g),βS <sup>β</sup> ν − - = 0 (A24) (nµM <sup>µν √</sup> F− <sup>µν</sup> gn),βµ,βSS <sup>β</sup> <sup>β</sup> ν −ν - 4πnµJ <sup>µ �</sup> <sup>√</sup> −g (nµM <sup>µν √</sup> F− <sup>µν</sup> gn),βµ,βSS <sup>β</sup> <sup>β</sup> ν −ν (SiµF <sup>µβ √</sup> −g),β − = 0 (A17) - = 0 (A18) (SiµMS <sup>µβ</sup> iµ,β <sup>√</sup> F−g <sup>µβ</sup> ),β+−S4πiµ,βSiµMJ <sup>µµβ � √√</sup> −−gg M <sup>µν</sup> nµ,βS <sup>β</sup> ν = 0 (A25) √−g - = 0 (A18) (SiµMS <sup>µβ</sup> iµ,β <sup>√</sup> F−g <sup>µβ</sup> ),β+−S4πiµ,βSiµMJ <sup>µµβ � √√</sup> −−gg = 0 (A19) (T <sup>αβ √</sup> −g),β + Γ <sup>α</sup> µβT <sup>µβ √</sup> −g = 0 (A20) (J <sup>β √</sup> −g),β = 0 (A21) (N <sup>(j)</sup> [u <sup>β</sup> + q <sup>(j)β</sup> ] <sup>√</sup> −g),β - c <sup>(j) √</sup> −g which are all in the conservative finite element form (1). Use has been made of the expression for the Einstein tensor Gαβ = Rαβ - <sup>1</sup> 2 <sup>gαβR</sup> in terms of the Ricci tensor where n <sup>µ</sup> is now identified as the boundary normal. Equations (A22) and (A23) are, respectively, the Hamiltonian and momentum constraints. In addition to the Einstein field equations (A16) four more coordinate conditions, and their possible boundary conditions, are needed to completely specify the metric. As these are rather arbitrary, these are left unspecified for now. (Of course, if they are to be differential equations, they also must be in the form (1).) B. Appendix B. Conditions on the Isoparametric Transformation Not all L <sup>α</sup> α′ specified by equation (7) are valid transformations in all situations. Sometimes they must satisfy certain conditions, which are discussed below. Two of these are conditions on the new (element mesh) metric formed by the transformation and the third is a condition on the element spacing itself. However, only the first condition always needs to be satisfied for a stable mesh. The other two are necessary only under certain circumstances. B.1. The Jacobi Condition The most important of these conditions is that the Jacobian determinant of the transformation be nonzero 1 Rαβ = √−g (Γ <sup>µ</sup> αβ √−g),µ − (ln √−g),αβ − ΓµναΓνβµ where the Ricci scalar is the contraction R ≡R <sup>µ</sup> µ, and the SEM scalar is the contraction T ≡T <sup>µ</sup> µ. Note that, as equations (A16) are symmetric in i and j, they are six in number, and (A17) and (A18) are three equations each. The term inside the divergence in equation (A16) is the trace-free curvature - the “flux” of the metric; the “force” terms involve derivatives of the projection tensor and a matter source generating the curvature. Boundary conditions on the conservation laws are generally of the simple form (4). Furthermore, it is well known that the Einstein field constraints do not depend on second derivatives with respect to time, and the Maxwell constraints do not depend on time derivatives at all. So, it should be possible to write these in the form (2), with at most a divergence on the boundary and a gradient normal to it. One of the more compact versions of this is (B1) g <sup>′</sup> = det||g <sup>′</sup> || < 0 L ≡ det||L||̸ = 0 However, since L <sup>2</sup> g = g <sup>′</sup>, and since g < 0, this also means that the determinant of the new metric must be negative Γ <sup>µ</sup> αβ√−g),µ - (Γµαβ√−g),βSαβ − [ S <sup>αβ</sup> (Γ <sup>µ</sup> αν Γ <sup>ν</sup> βµ − Γ <sup>µ</sup> αµΓ <sup>ν</sup> βν) + S <sup>αβ</sup>,µΓ <sup>µ</sup> αβ + The Jacobi condition (B1) ensures that the unit vectors in the element (primed) system, while not necessarily orthogonal, nevertheless form an independent (S <sup>αβ</sup> Γ <sup>µ</sup> αβ √−g),µ - (Γµαβ 25 coordinate system that has an arrow of time. It is absolutely necessary that this condition be satisfied in order that the mesh be well behaved. B.2. The Local-Lorentz Condition A second possible condition is that the element coordinate system have a locally Lorentz character everywhere — i.e., that ξ <sup>0′</sup> be the mesh time coordinate. This ensures that, if the spatial portion of the element mesh moves with time, the mesh velocity always will be less than the speed of light. This is important, however, only if the mesh is used as a frame of reference for measuring physical quantities. There are various ways of ensuring the Lorentz nature of the transformation L <sup>α</sup> α′. The safest and simplest way is to ensure that each unit vector in the new space satisfies the proper timelike or spacelike constraint. With the constraints that ξ <sup>0′</sup> denotes the time dimension and that eα <sup>′</sup> - eβ <sup>′</sup> = gα <sup>′</sup> β <sup>′</sup>, these local Lorentz conditions become g0′0′ = L <sup>α</sup> 0′ L <sup>β</sup> 0′ gαβ < 0 (B2) gi′i′ = L <sup>α</sup> i′ L <sup>β</sup> i′ gαβ - 0 (B3) Inequality (B3) is equivalent to demanding that each of the element sides in the ξ <sup>i′</sup> direction be spacelike. A less stringent, but still sufficient, condition on gi′i′ could be derived by choosing a specific timelike vector, such as n <sup>µ′</sup> = δ0′ <sup>µ′</sup> / <sup>√</sup> −g0′0′ (which still requires g0′0′ < 0), and then constructing from the corresponding projection tensor a set of three independent vectors orthogonal to n <sup>µ′</sup> si′ <sup>µ′</sup> = ni′ n <sup>µ′</sup> + δi′ <sup>µ′</sup> The condition that these vectors be spacelike (si′ si′ - 0) leads to a modified form for inequality (B3) gi′i′ - −(g0′i′ / <sup>√</sup> −g0′0′ ) <sup>2</sup> In this less restrictive case, the ei <sup>′</sup> unit vectors can be a bit timelike, but no more so than that given by the above inequality. B.3. The Courant Condition In standard nonrelativistic computational fluid dynamics, in order that the (explicit) forward integration in time be stable, the distance traversed in a single time step by sound waves or by the fluid itself (whichever is faster) must be substantially less than in each element, with ∆ζ = (∆ξ <sup>0′</sup> /Cvmax <sup>′</sup> <sup>,</sup> <sup>∆ξ1′</sup> <sup>,</sup> ∆ξ <sup>2′</sup>, ∆ξ <sup>3′</sup> ); ∆ξ <sup>α′</sup> is the width of the element in each mesh dimension; and vmax <sup>′</sup> <sup>is</sup> <sup>a</sup> <sup>three-velocity</sup> <sup>magni-</sup> tude equal to the maximum disturbance speed within the element. Because stable implicit techniques are used in time as well as space, a Courant number very close to unity probably can be tolerated. Therefore, in the case of relativistic flow, where vmax <sup>′</sup> <sup>=</sup> <sup>1,</sup> <sup>the</sup> Courant condition reduces to the requirement that the geodesics connecting opposing corners in each element must be spacelike (gα′β′ ∆ξ <sup>α′</sup> ∆ξ <sup>β′</sup> = ∆s <sup>2</sup> - 0). Generally, the Courant condition (B4) is much too restrictive and is routinely violated in slowly evolving or steady-state problems, where time steps are very long or even infinite. In implicit codes the condition needs to be satisfied only if one wishes to follow every short timescale transient phenomenon or wave. REFERENCES Abramowitz, M. & Segun, I. A. 1965, Handbook of Mathematical Functions (New York: Dover). Aller, L. H. & McLaughlin, D. B. 1965, Stellar Struc ture (Chicago: Univ. of Chicago Press). Arnold, D. N., Mukherjee, A. & Pouly, L. 1998, in Nu merical Analysis 1997, ed. D. F. Griffiths & G.A. Watson (Reading, MA: Addison Wesley. Arnowitt, R., Deser, S., & Misner, C. W. 1962, in Gravitation, ed. L. Witten (New York: Wiley), p. 227. Bonazzola, S., Gourgoulhon, E., & Marck, J.-A. 1998, Phys. Rev. D, in press. Brandt, A. 1977, Math. Comp., 31, 333. the mesh spacing. The ratio of these distances, called the Courant number C, is chosen to be ∼ 0.1 − 0.4 or so depending on the stability of the numerical integration scheme. This nonrelativistic Courant condition (which can be written as −∆t <sup>2</sup> /C <sup>2</sup> vmax <sup>2</sup> <sup>+</sup> <sup>∆x2</sup> <sup>></sup> <sup>0</sup> for one-dimensional flow) easily generalizes in the four-dimensional general relativistic case to gαβ ∆χ <sup>α</sup> ∆χ <sup>β</sup> - 0 where the vector ∆χ = (∆t/Cvmax, ∆x, ∆y, ∆z). It further generalizes in the case of a general curvilinear element mesh to gα′β′ ∆ζ <sup>α′</sup> ∆ζ <sup>β′</sup> - 0 (B4) 26 Chandrasekhar, S. 1957, An Introduction to the Study of Stellar Structure (New York: Dover). Chandrasekhar, S. 1969, Ellipsoidal Figures of Equi librium (New Haven: Yale Univ. Press). Clayton, D. D. 1968, Principles of Stellar Evolution and Nucleosynthesis (New York: McGraw-Hill). Clement, M. J. 1978, ApJ, 222, 967. Clement, M. J. 1994, ApJ, 420, 797. Colella, P. 1990, J. Comput. Phys., 87, 171. Colella, P. & Woodward, P. R. 1984, J. Comput. Phys., 54, 174. Cook, G. B. al. 1998, Phys. Rev. Lett., 80, 2512. Dubinski, D. R. & Hernquist, L. 1997, New Astron omy, 2, 277. Eriguchi, Y. & M¨uller, E. 1985, A&A, 146, 260. Eriguchi, Y. & M¨uller, E. 1991, A&A, 248, 435. Evans, C. R. & Hawley, J. F. 1988, ApJ, 332, 659. Holst, M. 1998, in preparation. Hughes, T. J. R. 1987, The Finite Element Method (Englewood Cliffs, NJ: Prentice-Hall). Kippenhahn, R. & Thomas, H. C. 1970, in Stellar Rotation, ed. D. Slettebak (Dordrecht: Reidel). Komatsu, H., Eriguchi, Y., & Hachisu, I. 1989, M.N.R.A.S., Mon. Not. R. Astr. Soc., 237, 355. Leahy, D. A. 1997, in The 12th ‘Kingston Meeting’: Computational Astrophysics, ed. D. A. Clarke & M. J. West (San Francisco: Astron. Soc. Pacific), p. 109. Lebedev, N. N. 1972, Special Functions and their Ap plications (New York: Dover). LeBlanc, J. & Wilson, J. 1970, ApJ, 161, 541. LeBlanc, J. & Wilson, J. 1971, private communica tion. Misner, C. W., Thorne, K. S., & Wheeler, J. A. 1973, Gravitation (San Francisco: Freeman). Monaghan, J. J. 1992, Ann. Rev. Astron Astrophys., 30, 543. Norman, M. L. 1997, in The 12th ‘Kingston Meeting’: Computational Astrophysics, ed. D. A. Clarke & M. J. West (San Francisco: Astron. Soc. Pacific), p. 3. Norman, M. L. 1998, in Numerical Astrophysics 1998, in preparation. Park, Y.-S. & Hong, S. S. 1998, ApJ, 494, 605. Press, W. H., Flannery, B. P., Teukolsky, S. A., & Vetterling, W. T. 1989, Numerical Recipes (Cambridge: Cambridge Univ. Press). Regge, T. 1961, Nuovo Cimento, 19, 558. Tassoul, J.-L. 1978, Theory of Rotating Stars (Prince ton: Princeton Univ. Press). Truelove, J. K., Klein, R. I., McKee, C. F., Holliman, J. H., Howell, L. H., Grenough, J. A., & Woods, D. T. 1998, ApJ, 495, 821. van Leer, B. 1979, J. Comput. Phys., 89, 125. York, J. W. 1979, in Sources of Gravitational Ra diation, ed. L. L. Smarr (Cambridge: Cambridge Univ. Press), p. 83. Zienkiewicz, O. C. 1977, The Finite Element Method (London: McGraw-Hill). This 2-column preprint was prepared with the AAS L <sup>A</sup> TEX macros v4.0. 27 FIGURE CAPTIONS Fig. 1.— Examples of shape functions in one dimension for linear (top) and quadratic elements (bottom). The solid line shows the shape function for the <sup>ˆ</sup> 0 node (at ξ = ξˆ0 = 0); the dashed line for the <sup>ˆ</sup> 1 node (at ξˆ1 = 0.25); and so on. Note the element boundary nodes (large open circles) and interior nodes (smaller filled circles in the quadratic case). The derivatives of the shape functions are discontinuous at boundary nodes, although the functions themselves are continuous. Each function attains unit value at its corresponding node and exactly zero at all other nodes in the element. By definition, shape functions are also identically zero in elements not containing their corresponding node. Fig. 2.— One-dimensional results for adaptive grid tests. Top left: solution of the Fermi-Dirac function test with f = 50, using 8 linear, equally-spaced elements, and yielding a very large error (E <sup>L</sup> w <sup>2</sup> = 0.27); top right: using 16 equally-spaced elements (E <sup>L</sup> w <sup>2</sup> = 0.027); middle left: 8 adaptive elements (E <sup>L</sup> w <sup>2</sup> = 0.031); middle right: 16 adaptive elements (E <sup>L</sup> w <sup>2</sup> = 0.0068); bottom left: same as middle right, but plotted against log w; bottom right: results when solving for w˜ = log10 w. The dotted line shows the exact solution. Fig. 3.— Two-dimensional results for adaptive grid tests, showing contour plots of the solution w. All use meshes of 16 × 16 linear elements with f = 50, a = 2, and b = c = 0 in the Fermi-Dirac function. In all cases, coordinates and differential equations are expressed in x and y only, and although derivatives are calculated on the curvilinear grid, they are immediately transformed to the (x, y) system and used as such in the equations. Top left: uniformly-spaced Cartesian grid (E <sup>L</sup> w <sup>2</sup> = 0.081); top right: circular-polar grid (E <sup>L</sup> w <sup>2</sup> <sup>=</sup> <sup>0.067);</sup> <sup>middle</sup> <sup>left:</sup> elliptical grid with the same axial ratio as the solution (E <sup>L</sup> w <sup>2</sup> = 0.037); middle right: adaptive ellipti cal grid allowing finer resolution of the Fermi surface (E <sup>L</sup> w <sup>2</sup> <sup>= 0.010); bottom left:</sup> <sup>same as middle right, but</sup> with logarithmic contours (note oscillations similar to those in the bottom left panel of Figure 2); bottom right: resulting solution when solving for w˜ = log10 w. Fig. 5.— Two-dimensional n = 1 spherical polytropic stars with 9 <sup>2</sup> nodes using the multipole boundary condition (ws <sup>M</sup> <sup>).</sup> Top panels: mesh and pres sure contours for (bi-) linear elements; bottom panels: mesh and pressure contours for (bi-) quadratic elements. Contours follow the precise interpolation within the respective elements. Note the adaptive gridding near the stellar surface, similar to that in Figure 4. Fig. 6.— Same as Figure 5, but with 33 <sup>2</sup> nodes. Note the persistent errors in the pressure contours for linear elements which are absent in quadratic elements with far fewer nodes. Fig. 7.— Similar to Figure 6, but using the integral boundary condition (ws <sup>I</sup> <sup>)</sup> <sup>and</sup> <sup>solving</sup> <sup>a</sup> <sup>two-</sup> dimensional n = 0 rotating polytropic star (Maclaurin spheroid) with ω <sup>2</sup> /2πGρ = 0.224 - very close to the theoretical limit of 0.2246656. Fig. 8.— Comparison of rotating Maclaurin spheroid model stars, computed with different finite element meshes, with the analytic solution: Top panels: linear elements with 9 <sup>2</sup> and 17 <sup>2</sup> nodes, respectively; bottom panels: quadratic elements with 9 <sup>2</sup> and 17 <sup>2</sup> nodes. Although ω <sup>2</sup> is the primary model parameter, the flattening ratio, total angular momentum, and ω <sup>2</sup> itself, with the normalizations in Tassoul (1978), are plotted as a function of the derived parameter τ for comparison with the analytic theory. Fig. 9.— Absolute value of the fractional errors for the Maclaurin spheroids in Figure 8 as a function of ω <sup>2</sup> . Solid lines show models with linear elements, dashed lines quadratic elements; curves without symbols are for 9 <sup>2</sup> node models, those with are for 17 <sup>2</sup> models. Fig. 4.— One-dimensional n = 1 spherical polytropic stars with 9 nodes. Left: standard Galerkin weighting of the FEM integrals, with linear elements (E <sup>L</sup> p <sup>2</sup> = 1.4); middle: Petrov-Galerkin type 2 weight ing and linear elements (E <sup>L</sup> p <sup>2</sup> = 0.048); right: same as middle, but with quadratic elements (E <sup>L</sup> p <sup>2</sup> = 0.0018). All models use adaptive gridding and logarithmic variables. Note the close nodal spacing near the stellar surface. 28

섹션 본문

섹션 본문이 없습니다.

참고문헌

참고문헌 정보가 없습니다.