ttc: symbolic tensor and exterior calculus

9
Computers in Physics TTC: Symbolic tensor and exterior calculus P. Castellví, X. Jaén, and E. Llanta Citation: Computers in Physics 8, 360 (1994); doi: 10.1063/1.168499 View online: http://dx.doi.org/10.1063/1.168499 View Table of Contents: http://scitation.aip.org/content/aip/journal/cip/8/3?ver=pdfcov Published by the AIP Publishing Articles you may be interested in Application of exterior calculus to waveguides Am. J. Phys. 78, 264 (2010); 10.1119/1.3265544 TTC: Symbolic tensor calculus with indices Comput. Phys. 12, 286 (1998); 10.1063/1.168656 Symbolic tensor calculus using index notation Comput. Phys. 9, 335 (1995); 10.1063/1.168532 An exterior calculus for exact symplectic manifolds J. Math. Phys. 36, 1413 (1995); 10.1063/1.531130 Exterior differentiation in the Regge calculus J. Math. Phys. 27, 296 (1986); 10.1063/1.527332 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP: 65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Upload: e

Post on 09-Apr-2017

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: TTC: Symbolic tensor and exterior calculus

Computers in Physics TTC: Symbolic tensor and exterior calculusP. Castellví, X. Jaén, and E. Llanta Citation: Computers in Physics 8, 360 (1994); doi: 10.1063/1.168499 View online: http://dx.doi.org/10.1063/1.168499 View Table of Contents: http://scitation.aip.org/content/aip/journal/cip/8/3?ver=pdfcov Published by the AIP Publishing Articles you may be interested in Application of exterior calculus to waveguides Am. J. Phys. 78, 264 (2010); 10.1119/1.3265544 TTC: Symbolic tensor calculus with indices Comput. Phys. 12, 286 (1998); 10.1063/1.168656 Symbolic tensor calculus using index notation Comput. Phys. 9, 335 (1995); 10.1063/1.168532 An exterior calculus for exact symplectic manifolds J. Math. Phys. 36, 1413 (1995); 10.1063/1.531130 Exterior differentiation in the Regge calculus J. Math. Phys. 27, 296 (1986); 10.1063/1.527332

This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 2: TTC: Symbolic tensor and exterior calculus

TTC: Symbolic tensor and exterior calculus P. Castellvi Department de Fisica Aplicada, Universitat Politknica de Catalunya, Dr. Marak6m 44, 08028 Barcelona, Spain

X. Jadr? and E. Llantaa) Department de F%ica i Enginyeria Nuclear; Vniversitat Politknica de Catalunya, Pau Gargallo 5, 08028 Barcelona, Spain

(Received 14 September 1993; accepted 7 December 1993)

The package TTC (Tools of Tensor Calculus) implements the majority of the basic tools of tensor and exterior calculus in a differentiable manifold using the point-of-view of the modern differential geometry (DC). It can be of interest to any physicist using DG, for research or teaching purposes, in relativity theory, mechanics, electromagnetism, thermodynamics, Hamiltonian theory, fluid dynamics, elementary particle physics, etc. It is written in the computer algebra language Mathematics, which gives the user a powerful environment. Emphasis has been put on using the full expression of tensors, on defining objects with no restrictions at all, and on using a close-to-textbook notation.

NTHODUCTloN

Differential geometry (DG) has been increasing its role in physical and mathematical applications since the beginning of the 20th century. There are two reasons that can be used to explain this fact. First of all, the development of Ein- stein’s theory of relativity has proved that the simple Eu- clidean three space of the 19th century was only an ap- proximation to the framework of our physical world. On the other hand, mathematicians, influenced by Cartan’s work, have recognized that from the union of geometry and analysis one can obtain a lot of powerful tools and concepts suitable to develop new ideas.

Modern DG is becoming more and more important in theoretical physics. Special and general relativity have an obvious geometrical content, but there are also other fields where geometry has a relevant role: thermodynamics, Hamiltonian mechanics, electromagnetism, fluid dynamics, cosmology, elementary particle physics, etc.lT3

As everybody knows tensor algebra gives rise to te- dious and cumbersome computations, when the structure of the manifold is not trivial. Computer algebra can be a great help for dealing with all these tensors and the lengthy cal- culations that years ago where performed analytically and took a long time can now be performed in seconds or min- utes. It has not been by chance that general relativity, which is one of the fields where an extensive use of tensor calcu- lus is made, has been one of the pioneering fields of appli- cation of computer algebra and one of the motivators of its development.

Almost all computer algebra systems have applica- tions to deal with tensor calculus, which are usually fo- cused on general relativity computations. Without the inten-

a’Al~~ at Laboratori de Fisica Matemitica, Societat Catalana de Fisica, I.E.C., Barcelona, Spain.

360 COMPUTERS IN PHYSICS, VOL. 8, NO. 3, MAY/JUN 1994

tion of being exhaustive we will mention some of them. The EXCALC package is a part of REDUCE that provides facilities for exterior calculus.4*5 SHEEP is Lisp-based sys- tem designed mainly for general relativity.h CLAW and STENSOR are extensions of SHEEP used to classify s times and to handle indicial tensors. The MACSYMA P

ace- pro-

grams Ctensor, Itensor, Cartan, and Atensor perform com- ponent manipulation, indicial manipulation, exterior calculus, and tensor algebra, respectively. In MAPLE,* there are also several applications oriented to general relativity computations. MATHTENSOR~ is a Mathematical’ program for tensor calculus, which is marketed commercially as an extension of Mathematics.

The characteristic of the majority of these tensor ma- nipulators is that they deal with specific parts of the DG tools and when operating with tensors they in fact operate with the components of them and not with the complete tensors. The properties are defined on the components and not for the whole tensor. It is clear nowadays that the most economic and elegant way of dealing with tensors is con- sidering them as intrinsic objects, which can eventually be expanded in a particular basis. This is precisely the point- of-view of the majority of the modern DG books and the one we have treated to lead as far as possible in the design of TTC (Tools of Tensor Calculus).

In TTC, every tensor is a single object and all inputs and outputs give the full expressions of tensors as linear combinations of the elements of a coordinate basis. Thanks to this, all algebraic and differential operators can be de- fined using their most basic properties and the code is eas- ily readable by anyone knowing DG, since what is written is almost a translation of what one finds in the books. The restrictions in the operators are only the mathematical ones.

One of the objectives in the design of TTC has been to avoid any limitation in the objects it deals with. Indeed, the dimension of the manifolds and the kind of the tensors used

This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 3: TTC: Symbolic tensor and exterior calculus

are arbitrary, there is no limit in the number of coordinate systems, coordinate changes, and submanifolds simulta- neously used.

The input of any tensor contains all the information and when asking TTC to perform some operation, it will travel through the tensor expression and it will act accord- ing to what it finds. It is not necessarily a previous decla- ration, neither of the type of tensor nor of its symmetries. The output will be also a single object from where one can easily read the components.

Another aim in the design of TIC has been to allow the simultaneous use, during the same session, of the dif- ferent expressions of one tensor when written in different coordinate systems. This is very useful in general relativity computations, where the theory gives an absolute freedom to choose the coordinate system and consequently it is usual to compute things more than one.

We have chosen Mathematics to write TTC since it belongs to the new generation of symbolic manipulation languages, it has a large environment with a lot of capabili- ties and its high-level programming language is powerful enough to establish the basic properties of the operators of lTC. In addition, it has a large number of users around the world.

The size of TTC code is -50 Kb. It runs on every machine which can support MATHEMATICA using, when loaded, about 200 Kb of RAM memory. Nonetheless if the user wants to manipulate large tensor objects, he will pos- sibly need a considerable extra amount of RAM memory as usual in all computer algebra calculations.

In Sec. I, we present a general description of the TIC functions. In Sec. II, we present two applications of TTC. Finally, Sec. III contains the final comments.

I. TTC luNCTIDNS

TTC has several kinds of objects. Some of them are only used internally and will not be described here. The main purpose of this section is to explain the use of the functions and procedures of ?TC and also comment about particular aspects of their actual programming. It is not possible to describe all the functions included in TIC since this would make the paper too long. We have selected those that we consider more important, either to show the general rules and conventions used for all the functions of the package or to comment about the basic operators. The reader will find some functions used in the examples that have not been explained previously in the paper because of the abovemen- tioned reason.

Following the general convention of Mathematics, TTC uses full descriptive names, beginning with a capital letter, for all functions. This is not a problem since the user can decide to choose abbreviated forms of those names used more frequently.

Objects of TTC can be divided in the following cat- egories. l Declarations and definitions that do not give rise to any output. They are used to state the dimension of the mani- fold, the system of coordinates one wants to use, the metric tensor, etc. There are some defaults to facilitate the task of the user. l Operators and operations that take an input and convert it

to an output. The outer product, the contraction, the Lie derivative, the covariant derivative, etc., are some examples of them. l Auxiliary tools used to simplify intermediate or final ex- pressions, to get a format that is more easily readable by the user, to control the character of an object, etc.

A. Declarative functions

l Coordinate [x~{xL~xF!~. . .I] is used to introduce the name of the coordinate system and symbols to use for the coordinates. When entering the list of the coordinates, TTC also gets the dimension of the manifold and, hence, it is not to be declared separately.

Example: When the input is Coordinates [sp h .{r 7 t h 7 p h}], TTC understands that the symbols of the coordinates 1, 2, and 3 are r, th, and ph, respectively. In this declaration it is also implicit that D i men s i o n [s p h] =3 (see below). For simplicity, when one is going to use only one system of coordinates, it is not necessary to intro- duce the name of the system and the symbols of the coor- dinates. TTC, as a default, will take XX as the name of the system and X1,X2,. . . as the symbols of the coordinates. Only in this case, one has to input Dimension [xx]=.

l D i men s i on [x] is the dimension of the system of coordinates with the name x. Example: Let us consider the Euclidean three space. We can use different systems of co- ordinates: rectangular, spherical,... . It would be D i men - sion [rect]=3. Dimension [sph]=3,. . . . If we want to define a two sphere in the r e c t manifold we must input a name and a list of two symbols for the coordinate system used for the two sphere. If the name we give to this two sphere is sphere, it would be Dimension [sphere]=Z. Of course we must input also the relation between the coordinate systems or manifolds r ec t and sphere.

l This can be done using the following. Coor d i - natechange [oldx,newx,list] is used to input the old coordinates as a function of the new ones.

Example: Let us assume that we begin with a tensor T written in Cartesian coordinates {XL, X2, X3) and we want to change it to spherical coordinates (r 7 t h 7 p h}. The func- tions giving the old coordinates as a function of the new ones are stated in the following way:

CoordinateChangeCXX,sph,IX1:zr SinCthl Coslphl, XZ:>r Sintthl Sin[phl, X3:>= Cos[th]}]

As mentioned above we can also use this Coordi - n a t eC h a n g e function to input the parametric equation of a submanifold. In the case of the example given above (how to define a two sphere immersed in three dimensions), we can proceed as follows:

CoordinatesCsphere.{th.ph)l; CoordinateChangelrect,sphere,~x~>r Sin[th] Cos[ph],

y:>r Sin[thl Sinlph], z:>r Cos[th]>]

where now r means the radius of this two sphere. l ZZ[x , i]: Given a system of coordinates x? the natu-

ral basis for vectors is ei= d/dx’ and wl=dxl for dual forms. In ITC, the elements of the basis are ZZ[x 7 i],

COMPUTERS IN PHYSICS, VOL. 8, NO. 3, MAY/JUN 1994 361 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 4: TTC: Symbolic tensor and exterior calculus

where x is the name of the system of coordinates and i is the index of the element of the basis. As a general conven- tion in all of the package, i>O means an upper index and i<O means a lower one. The input of the elements of the natural basis is

el+ZZ[x,-L], (1)

w’+ZZ[x7L], (2)

where the symbol --+ will be used to establish a correspon- dence between the usual notation and the one used in TTC. As far as the format of the output is concerned, in TTC, there are two alternative ways of presenting it called TTCInFormat and TTCOutFormat. The second one is the format used to present the results of the examples given below. The differences between them are explained in Sec. I c.

ZZ is also used to input the elements of the basis of the tensors of any kind. This will be explained in Sec. I B in relation with the outer product.

In[l]:= OuterProductC3 ZZll1+5 ZZ[Z], 4 ZZ[311

Out[l]=lZ dXl*dXJ+ 20 dXZ*dX3

*ExteriorProduct [fL,fi?,f3,...]istheexterioror wedge product of the forms f L7 f 2 7 f 3 7 . . . . The exterior product of the forms of the basis {&‘I A dxi2 A dx’k}, i, # i, constitute the basis of the space of forms of type k. These elements of the basis are designated using the same symbol ZZ as before but with the indices inside curly brackets.

Example:

dx3Adx1Adx2-+ ZZ[ x .{3 7 L 2 2)]. (7)

As before if one wants to use the symbols of the coordi- nates themselves instead of the indices, an extra comma has to be added after the name of the coordinate system.

Once we know how to input forms of arbitrary type wecanuse ExteriorProduct.

Example:

B. Operations and operators

They constitute the bulk of TTC. Here we will present some of them to show the general rules and conventions.

l OuterProduct[T,W,...]gives the outer product (called tensor product in some references) of the tensors T,W,.... The outer product of the vectors and forms of the basis {epl @ ... @3 epk 63 0’1 63 *. . 8 my/} constitute the basis of the space of tensors of type (k,l). That is to say, every tensor of type (k,l) can be expanded in this basis:

T= c TP’ v,;;,$ke,,@-&? (3) p ,,..., u,=l

The tensors of the basis are represented by ZZ[x7i7j7. . .] with the abovementioned conventions.

Example:

In[l] :=Dimenslon[XXJ=4;

hL?]:= ExteriorProductC3 ZZ[l],ZZ[3]]

Out[21=3 dXl#dXJ

Note the symbol # that has been used in the output format for the wedge product of the elements of the basis. An output dXLSdX3 corresponds to an input ZZ[{L,3)].

In[31:= ExterlorProductK,4 ZZ[21+5 ZZ[411

Out131=-12 dXlXdXZ#dX3+15 dXiYdXJXdX4

l ApplyTensor [T] [Ql,Q2,cJ3, ...I implements the modern definition of a tensor as a machine that has several slots where one can introduce vectors or one-forms to pro- duce a scalar. It has been programmed with all the gener- ality since one can leave free some of the slots.

Example:

(4) Inll] :=ApplyTensor[ZZ[1.2,-311 [ZZC-11, ,ZZ[311

The declaration of the type of each tensor is automatic since it is implicit when one writes its expansion on a natu- ral basis.

Example: Let use assume that we are working in the Euclidean three space in the spherical coordinates basis. One tensor will be for instance:

2el@u2+3e2@,w3+2 ZZ[sph,-1,2]

+3 ZZ[sph,-2731. (5)

As sometimes one does not remember the numerical index of a concrete coordinate, it is better to use the symbols of the coordinates themselves to designate the index. In this case one has to write two commas between the name of the system of coordinates and the indices.

Example: An alternative way of writing the tensor of

(the second slot is empty)

Out Cl] -*dXz

Note that *dX2 is the output format of ZZ[XX,2]. In the case of only one element, the symbol * has been maintained in order to emphasize the output formatted character of dX2 and because it makes easier to find the different terms of the output expression. l Contraction [i, j] [T] is the contraction of the tensor T with respect to the indices positioned at i< j.

Example:

In[l]:-t- 2 ZZ[-1,21 - 5 ZZ[-1,31 - 3 ZZC-2,31 + 6 ZZ[-2,2]

Out[l]= 6 DXZ*dXZ - 3 DX2*dX3 + 2 DXl*dXZ - 5 DXltdX3

the previois example is

2e,@~*+3e2@W3+2 ZZ[sph,,-r,th]

Inl21 := Contraction[l.Z] [t]

Out I21 = 6

+3 ZZ[sph,,-thqph]. (6) On the other hand Contraction [i, j] [T,Q] is the con- tracted product of the tensors T,B with respect to the in-

Example: Using the default coordinate system: dexes positioned at i in T and j in a.

362 COMPUTERS IN PHYSICS, VOL. 8, NO. 3, MAY/JUN 1994 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 5: TTC: Symbolic tensor and exterior calculus

Usually one will have a metric tensor on the manifold. The input for it is the same as that of any other tensor but the name has to be Metric [g-x]. l Metric [g 7 x], where g is the name given to the metric tensor and x is the system of coordinates in which it is written. The name g is included since it is usual to work simultaneously with different metric tensors at the same time. It is even more usual to have to change the coordi- nates and so x is also included.

Example: If we want to work with the metric tensor of

hypersurface characterized with the coordinates x s, when the metric tensor of the space is Net r i c [g ‘I x]. l FirstFundamentalForm[g.x.xs] isthefirstfunda- mental form of the submanifold with coordinates xs in the metric space with N e t r i c [g ‘I x]. l SecondFundamentalForm [g,x,xs] is the second fundamental form of the submanifold with coordinates xs in the metric space with Met r i c [ g7 x],

C. Auxiliary tools

the Euclidean three space written in spherical coordinates we will input

In order to manipulate the tensorial objects, TIC needs to know what kind of treatment it has to give to them and it

Hctric[euclidean,sph]= zzt+,l,ll + r-2 ZZ[sph,2,21 + r-2 Sin[th]-2 ZZ[sph,3,3]

l Christoffel[g,x][i,j , k] computes the Christoffel symbol of the given indices (j and k have to be lower indices) for the soace with the metric tensor Metric [g,x].‘With ShowChristoffel Cg,xl all non-null con- nection coefficients are shown. It is worth noting here that when one particular coefficient is demanded all of them are computed and stored in memory. This is a general rule in TTC in the sense that all important objects are kept in memory and when invoked later in the session they do not t...... ‘_. L- --ss-nputed again. 11avc L” “C ‘CC”1

obviously depends on their specific type. One has to distin- guish between different types of tensors and scalar func- tions. To cope with this problem there are three functions in TIC which follow ..:..r. +L, ,..s,snrn, ~~.~,,,nt:~nr nf A,tn+h- 1,1& I,IG pIIG,aI L”,IYGIIII”IID “I ,“‘U, ematica have names ending with the letter 8.

l Tensora [T], Scalara [T], and Forma [T] test whether T is a tensor, a scalar, or a form, respectively, giving True or False as a result.

In order to obtain compact results for the tensors it is necessary to use the tools that Mathematics provides, but it is interesting to make them work on each term of the tensor expansion and not on the tensor as a whole.

l TensorSimplify [TTCSimplify] [T], where

l Co v a r i ant D [g] [v] [T] is the covariant derivative of the tensor T with respect to the vector v, when g is the metric tensor of our space.

l A b s o 1 u t e D [g] [T] is the absolute or covariant differen- tial of the tensor T, when g is the metric tensor of the manifold.

TTCS i m p 1 i f y is a list of conversion operators, makes the latter act on each term of T; the - default value of TTCSimplify=[Identity}. Even in this case it is nec- essary, since the action of Tensor S i m p 1 i f y joins to- gether the terms with the same basis element.

l Riemann [g,x], Ricci [9.x], and Curvature [g,x] compute the Riemann, the Ricci, and the curvature tensor, respectively, for the specified metric.

Once given a specific CoordinateChange, the pos- sibility of changing the coordinates in any tensor is imple- mented using the following function. l Change [o 1 d x 7 new x] [T] gives T expressed in the new basis.

Example: The Euclidean metric tensor is included as a default in TIC with the name Me tr i c [XX 7 XX] and with default dimension Dimension [Xx1=3.

Ill[l] ‘.Hstrlc[XX,XX] Out[l]= dXl’dX1 + dXZ*dXZ + dX34X3 In[2]:= CoordlnateChange[XX.sph,~Xl:>r Sin[th] Cos[ph],

X2:% SinCthl Sinlphl, X3:>r CosCth]>;

In[4]!-Hatric[XX,sph]-Change[XX,sph][Metric[XX,XXJ]

2 2 2 Out[4]-drrdr + r dth*dth + r Sin[th] dphrdph

Change can also be used to restrict coordinates from a manifold to a submanifold. This is very useful for the study of the geometry of hypersurfaces, since TIC also includes the functions to compute the main objects that characterize them. l TangentVector [x,xs][i] gives the ith vectorofthe basis of the tangent space to the surface with coordinates xs in the space with coordinates x. l NormalForm [g,x,xs] gives the normal form to the

Inside the program the majority of the functions have a TensorSimplify [TTCSimplify] acting on them at different places. Therefore, the user has only to give his/her preferred list of conversion operators depending on the characteristics of the particular computation.

Example: TTCSimplify={PowerExpand,Sim- plify} will produce the action of PowerExpand fol- lowed by that of S i m p 1 i f y. This is precisely the assign- ment used in all the examples presented in this paper.

It has been commented in this paper that there are two possibilities for the format of the output expressions. When TTCInFormat is active, the elements of the basis are writ- ten with ZZ’s. When TTCOutFormat is active, the ele- ments of the basis are expressed using D as the partial de- rivative symbol, d as the symbol of the differential, * as the outer product symbol, and # as the wedge product symbol.

Justtyping TTCOutFormat or TTCInFormat inone input line, one activates the corresponding format from then on. When loading the package, TTCOutFormat is active as a default.

Here we present two applications to illustrate the use of TIT. The first one shows how one can easily define new tools from those of TIC and the second one performs a general relativity computation which is very boring to do by hand.

A. Three-dimensional vector calculus

It is very simple to write a small program (called WCALC), which defines in a 3D Euclidean space, the usual operators

COMPUTERS IN PHYSICS, VOL. 8, NO. 3, MAY/JUN 1994 363 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 6: TTC: Symbolic tensor and exterior calculus

of classical vector calculus: the vector product and the gra- dient, divergence, curl and Laplacian operators.

Using the power of modern DG and its implementa- tion in TIC, we are able to copy the definitions of these functions directly as a program. The intrinsic definitions used here can be found in Ref. 3. The result is that any user, even if he/she does not know modern DG, can apply the curl operator to any three-vector expressed in an arbitrary well-defined coordinate system of the flat space.

Taking the Euclidean metric in a 3D space written in Euclidean coordinates (which is the default metric of TIC and has the name Met r i c [XX 7 XX]) and a particular change of coordinates, one can obtain the expression of the Euclidean metric tensor in these coordinates:

Metric[XX,x-1:.Metric[XX.xl= Change[XX,xl IMetriclXX,XXll

MetricSign[XX,x_l-1

The implementation of the operators is

l Vector product VXW=#*(PVr\$W)+

VectorProduct[V-,W-1 := ChangeType [XX] Ciiodge [XX] [

ExteriorProduct [ChangeType[XX] [VI , ChangeType [XX] [WI 1 1 1

In[6]:- Grad[s,sphl

s S .ph 9th

Out [a - __--_------ rDph + ---- *Dth + S *tlr 2 2 2 ,r

r Sin[thl r

(the standard Mathematics output has been formatted in order to eliminate the arguments of the (desired) functions and to write more clearly the partial derivatives of these functions).

In[71:= Lapls,sphl

S S S 2s ,ph,ph ,th ,th,th ,r

Out c71- ___--_-____ + __________ + .-.---- + ----- + s 2 2 2 2 r ,T,I

r Sinlthl r Tanlth] r

It is sometimes useful to introduce an orthonormal ba- sis. In order to work with any coordinate system, (i.e., not necessarily orthogonal, the Gram-Schmidt orthonormaliza- tion procedure provides a tool to transform any basis to an orthonormal one.” Given any basis et ;++e, in a space with metric g, the desired basis e;, .. .ei is found following the steps of the algorithm:

where $ is the operator transforming a vector (one-form) into a one-form (vector). * is the Hodge or star operator. l Gradient operator grad f= #df-t

Grad[f _ ,x-l : =ChangeType[XXl [ExteriorDCf ,x11

l Divergence operator div V=*d*$V-+ Its implementation is Div[V-] :=~odge[XX] [ ExteriorD[ HodgeCXXl C ChsngeTypeCXXl [VI 1 1 1

l Curl operator curl V= $l *d $lV+

curl [v-l : =chsngeType [xx] [Hedge [XXI [ExteriorD [ChangeType [XXI [VI 111

ortBssis[x_] [I-] :=ortBasis[x] [il=onitarylXXl CortbasistxlOmToIndextxl [ill

ortbasis [x-l [i-l : vrtbasis 1x1 Gil = zzcx,i1-

~~[~ppiy~en~~r[~etricCXX,xll CZZ[x,il .ortbesiskl C-sssll/ ApplyTensor[Metric[XX,x~l lortbasiskl I-sssl ,

ortbssis[xl [-SSS]] ortbasislxl I-sssl ,{sss,l,-i-111

l Laplacian operator A f = *d*df +

Lap[f-,x-l :=Hodga[XXI [ExteriorD[Hodge[XX] [ExteriorD[f ,x1111

ortbasis[x_l I-11 :-ortbasislxl I-ll=ZZIx,-11

A utility to find the components of any vector in this orthornormal basis is

That is all one needs. We can now use these operators ortcm,ponent[V-J [i.] :=ScalarlV,OrtBasislBasisCv]1C-111

directly over objects written in any coordinate system.

In[ll:=<<ttc.m; When working with spherical coordinates,

In[ZI:-<<v3calc.m 1n[81:= OrtBasisCsphl L-11

Out [91- *Dr As a simple example we can introduce spherical coor-

dinates: In[lOl := OrtBasis[sphl c-21

In[31:= CoordinatesCsph,{r,th,ph>l;

In[4]:= CoordinateChange[XX,sph,{Xl:>r Sinlthl Costphl, XZ:>r SinCthl Sintphl, X3: >r Cos Cthl >I ;

Out[lOl= - *Dth r

In[ll] := OrtBasisCsphl t-31

1

and a generic scalar function in these coordinates out[ll]= _________ +Dph r Sin[thl

then

InlSl:- s:-Slr,th,phl With this tools we can define two generic vectors in spherical coordinates and in the orthonormal basis related to them

364 COMPUTERS IN PHYSICS, VOL. 8, NO. 3, MAY/JIJN 1994 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 7: TTC: Symbolic tensor and exterior calculus

In[13]:-v:-Vl[r,th,ph] OrtFlasisCsphlE-ll+ VZ[r.th,ph] OrtBasisCsphl I-21+ VJCr,th,phl OrtBasisbphl C-31;

w:-Wllr,th,phl OrtBasisCsphlC-il+

particular characteristics of this problem can be found in Ref. 12. The program with the ingredients will be called SSVAL.

The general spherically symmetric metric tensor will WZ[r,th,ph] OrtBasisbphlC-21+ W3[r,th,ph] OrtBasislsphlt-31:

andusethemtotest VectorProduct,Div,Curl

be expressed using the so-called isotropic coordinates and the Vaidya metric tensor will be expressed in radiative co- ordinates. The declaration of the coordinate systems is

In[14]:= VectorProduct[v,vl CoordinatesCiso,~t,r,th,ph)l; Coordinates[rad,(T,R.th,ph}l

vz Wl - Vl wz v3 Wl - vi w3 Out[141- -(------------mm--) .aph + ________________ tDt,, _

r SinLthl r As both metric tensors are spherically symmetric, it is

useful to define the solid angle: > (V3 W2 - V2 W3) *Dr

In[151:- Div[v] SalidAngle~x~l:=ZZ~x,,th,thl+Sin~thl'2 ZZtx,,ph,phl;

Out[lSl- (2 T Sln[thl Vi + r V3 - The sign of the determinant of the metric tensor has to sph be given to TIC. In this case both metric tensors have the

2 same sign: > (-(I. Cos[thl V2) - r Sinlthl V2 )+r SinCthlVl )/

.th .r MetricSign[g_,x_]:=-1;

> (r2 Sin[thl) Finally the introduction of the metric tensors: 1n[16]:- Curl[vl

r Cos[th] V3 - r VZ + f Sinlthl V3 VP ,th

Out[161- ____________________________r___________- *Dr + 2

Metric[ss,isol:=MetricLss,isol= -A[t,r]'Z ZZ[iso,,t,t]+B[t,r]~Z (ZZ[iso,,r,rl+r^Z SolidAngla[isol)

Metric[val,rad]:=Metric[v=i,rad]= -(l-Z m[T]/R)ZZ[rad,,T,Tl-2 SymmetricCZZCrad,,R,Tll+

R-2 SolidAnnlelradl r SinLthl

vz - vi + r v2 ,th ,r

> ____________________ rDph _ 2

r Sin[thl

Sin[thl V3 - Vi t r Sin[th] V3 tp" ,r

> ____________________________________ fDt,, 2

r Sin[thl

where s s, va i, i so, and r ad stand for spherically sym- metric, Vaidya, isotropic and radiative, respectively.

The Einstein tensor can easily be defined using func- tions of TIC;

Einstein[g-,x-]:=Elnsteln[g,x]= Riccllg.xl-Curvature[g,xl Metriclg,xl/Z

As the output is not too long, we can present the result of the computation of the Einstein tensor for the Vaidya metric:

In[171:= OrtComponent[VectorProduct~v,wlllph3

Out[171= -wz Wl - vi WZ)

In[18]:- OrtComponent[Curl[vll lphl

Einstein[vai,rad]

1n[1]:= <<ttc.m;

InCZl:= ccs6vai.m;

v2 - vi + r vz 8th ,r

Out[l81= -____-____-_-_-_-.__ r

The reader can this way obtain all the results that are presented for different coordinate systems in any math- ematical handbook.

B. Q?hericaIly symmetric matching problem in general relativity

One problem in general relativity is the matching of two different space-times across the surface that separates them. The junction conditions that have to be satisfied are those of Darmois that essentially say that the first and the second fundamental forms have to be equal over the matching sur- face when computed coming from both sides. The compu- tation of these forms constitutes a long and boring compu- tation, of one has to do it by hand. We will show below how to perform this computation using TIC for the case where the two metric space-times are those of Vaidya and a general spherically symmetric one. The physics and the

In[3]:= Einstein[vai.radl

-2 m ,T

Out[41= ______ dTtdT 2

R

The hypersurface used to match both metrics is one that preserves the spherical symmetry of both space-times, which will be parametrized with three parameters {t ‘I t h 7 p h) with the name surf. The corresponding decla- ration of them and the restrictions of the coordinates from both sides are

Coordinates[surf,{t,th,ph)]

The computation of the fundamental forms needed to satisfy the Darmois’ junction conditions is straightforward. We present one of them here:

COMPUTERSIN PHYSICS,VOL.S,NO.3,MAY/JLJN 1994 365 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 8: TTC: Symbolic tensor and exterior calculus

I”[271 :- SecondFundamentalFormIss,iso,surfl

2 2 IS (A (B + rs B ) + B rs rs B )

.2-s .t .t

In [41 : = ApplyTensor [ Einstein[ss,isol//TensorSimplify[ {Change[ss,isoll 1

IC NV[ss,iso,surfl , VV[ss,iso,surfl+NV[ss,iso,surfl 1

,3”t[271= -----._.----_---:---------.----------- dthrdth + 2 2 2

A Sqrt[A - B rs 1 ,t

2 2 + Out[41= (A (rs (A + B rs ) B

,t ,r=

2 2 2 Sin[thl rs (A (B + rs B ) + B xs rs B )

.r= ,t ,t

> 2 B (B A +AB -2Brs B +rsA B J= ,rs ,t ,r= ,I= ,rs

> _.___-____________--____________________ _______ dphtdp,, _ > 2 2 2

A SqrtlA -B rs 1 ,t

> 2 2

> (B rs (A (-2 B A +AB j-B rs B )+ ,t ,r= ,r= ,t ,t >

2 > A (-(B rs A )+A(AA + B (B I-S * 2 r‘s B 1))) /

,t ,t ,TS ,t,t ,t ,t >

Brsrs B +rsB B - B rs B )) + ,t ,rs,rs ,r= ,t ,t,rs

2 B (B (2 rs (A * +srs * +lirr B +B* )-

,t ,r= ,t .r* ,t ,fS ,t

rs (A - 3Brs ) B ) - 2ABrs rs B 2 A B rs B .t ,t ,t .t,rs .t,t

2 4 /(A B rs(A-Brs ))

,t > (A B SqrtlA - B rs 1 Sqrt[A + B rs 1) dt*dt

,t ,t which coincides with that of Ref. 12.

Besides Darmois’ conditions, Israel showed that over the surface C the following conditions have to be satisfied:

(8)

(9)

where 7” is a one of the four vectors {up,ijs ,d4} tangent to C, being up the four velocity of the fluid which is the same at both sides of Z as a consequence of Darmois’ conditions, nFcE) is the normal vector, TIcEJGLV the stress-energy tensor or, from Einstein equations, the Einstein tensor (I, E stand for interior and exterior).

From this and the structure of the stress-energy tensor for each one of the metrics one can show:

z T,,JzpP+n~)=O, (10)

where we have considered the s s metric as the interior one. This relation is of the great importance since it depends only on the one of the two metrics. The four-velocity u and the normal vector n, are computed:

Unitary[gl I-l.TangentVectorCx.xsl[-ll// TensorSimplify[{Changelx,xsl>l

NVCg_,x_,xs_l:=NV[g,x,xsl= ChangeType [gl [Unitary [gl CNormalFormCg,x ,xsll//

TensorSimplify[{Change[x,xsl>l

The presence of TensorSimplify[{Change [x7 x s]}] has to be commented. These two vectors have to be expressed expanded on the basis of the four-space, but with their components as a function of the parameters of the surface. Remember that Tensors i mp 1 i f y acts pre- cisely on the components and so it will perform the desired task.

The required relation will be

‘)\

III. FINAL COMMENTS

As a conclusion we want to say that we think that the power of TIC lies in the fact that the intrinsic character of the modern DG is implemented faithfully. As a conse- quence of this, the inclusion of new functions is straight- forward in the sense that one only has to write, using the conventions of the program, what is found in the books. Everyone knowing DG and the playing rules of TTC can easily define his/her preferred applications.

Every field, where DG is used, is a potential place of application for the package. As there are no restrictions on the objects used and on the functions defined, it has only the limits imposed by the mathematical correctness and the knowledge of DG. There are some flags and filters inside the program to prevent a misuse of the functions, but TTC is not prepared to be used by persons not knowing the rules of DG.

We also think that it can be satisfactorily used for teaching purposes. It can be a great help for any DG course, since students can compute without effort or test the results obtained by hand.

We have performed long general relativity computa- tions using TIC and all the functions included in it have been tested and their results compared with long and boring calculations done by hand. Therefore, we think that it is a reliable product.

The present version of TTC is now being extended to include future improvements, such as the possibility of computing using noncoordinate basis and the construction of a package with more sophisticated general relativity ap- plications. A MAPLE version of TTC is also under develop- ment.

Source code from this article is available by FTP over Internet. To obtain source code, FTP to “pinet.aip.org” and go to the subdirectory “ciplsourcecode.” See page 254 for the password needed for this service.

ACKNOWLEO6MENT

One of us (X. J.) would like to acknowledge the Comision Asesora de Investigation Cientifica y Tdcnica for financial support under Contract No. PB90-0482-C02-01.

366 COMPUTERS IN PHYSICS, VOL. 8, NO. 3, MAY/JUN 1993 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41

Page 9: TTC: Symbolic tensor and exterior calculus

llEFEREWCES

I, Y, Chaquet-Bruhat. C. Dewitt-Morette. and M. Dillard-Bleick. Amly.~is. Mani- /&b uud P/ty.~k’.\ t North-Holland, Amsterdam. 1977).

2. B. E Szhutz. Gmwrricul Mrrhod~ of Mur/t~vrturicul flyairs (Cambridge Uni- vcrsity Prer*. Cambridge. 19801.

3. W. L. Burhc. .App/ied Din;‘renriul Geonrrrry (Cambridge University Press, Cam- hridgc. 1985).

4. A. c‘. Hcarn. REDUCE User’s Ma,rual (Rand CP78, The Rand Corp.. Santa Monica. CA. l9XS).

5 E. Schrufcr. ESCALC: A .S~.sfctn for Doing Calculatiorts in Modwn Drffermrial Gzoaqv, User > Muftual (Rand. The Rand Corp.. Santa Monica, CA, 1985).

6. M. A. H. MacCallum and J. E. F. Skea. in Procerdirtgs o/the Firsr Brarr/ian Scltool on Computer Algebra, edited by M. J. Rebouqs (Oxford University Press, 19YO).

I. Computer Algebra it? Applied Mathemurics. An Introducriott to MACSYMA. Pit- man Research Notes 94. edited by R. H. Rand (Pitman, London. 1984).

8. MAPLE by Waterloo Maple Corp.; see MAPLE V Languagr Rrftwnce Mortual (Springer. New York, 1991).

9. S. M. Christensen and L. Parker, Math. J. 1, 51 (lY9Ol. 10. S. Wolfram, Muthemarica: A Systrm for D&g Morhrmatic.r by Computer,

(Addison-Wesley, Reading, MA. 1988). 11. S. Lang, Lirwar Algebra (Addison-Wesley. Reading. MA, 1968). 12. E Fayos, X. Ja&, E. LLanta. and J. M. M. Senovilla. Phys. Rev. D 45.

2732 (1992).

COMPUTERS IN PHYSICS,VOL.S,NO.3,MAY/JUN 1994 367 This article is copyrighted as indicated in the article. Reuse of AIP content is subject to the terms at: http://scitationnew.aip.org/termsconditions. Downloaded to IP:

65.39.42.160 On: Mon, 08 Dec 2014 18:38:41