Mathematica张量符号计算工具TTC指南

来源:互联网 发布:淘宝客服真的好忙好累 编辑:程序博客网 时间:2024/05/22 04:42

http://baldufa.upc.edu/xjaen/ttc/tutorial/esential.htm

Essential TTC

Sections in this chapter:

Introduction 
How to load the program 
How to introduce a coordinate system 
How to define tensor objects 
How to introduce a metric tensor

For other chapters go to Index

Introduction

Here you will find a minimal set  of TTC functions that allows you to make a lot of tensor operations. If you want to learn more things about TTC you could go toIndex

How to load the program

You must have at least the file ttc.m . Then input
<<path/ttc.m
 ---------------------------------------- |TTC: Tools  of  Tensor  Calculus 4.3.1| |  A.Balfagon,P.Castellvi and X.Jaen   | |     http://baldufa.upc.edu/ttc       | |     e-mail:Xavier.Jaen@upc.edu       | |    version: june, 1, 2005            | ---------------------------------------- |       TTC works correctly with       | |         Cell menu options:           | | Default Input FormatType=InputForm   | | Default Output FormatType=OutputForm | ---------------------------------------- |     Session started on               | |     June,      5 , 2005              | |     at 17 h 50 min 6.981 s           | ----------------------------------------
  After, you can decide if you want to work with the Compact switch On or Off. The default value is Off which means that the dispaly of of results explicit (E ) tensor calculus is full but big computation can run slowly. If On the dispaly is shorted (using TTC[number]) and the computation gain in time and memory

How to introduce a coordinate system

?InputCoordinatesInputCoordinates[x, {x1, x2,...}] declares the coordinate system named x with symbols x1, x2,...Once the coordinates system named x has been declared x[x1,x3,...] can be used  to input tensor basisInputCoordinates[XX, n], being n a positivenumber sets the dimension of the default system XX to n.InputCoordinates[cs,{z,t,x,q}]{XX, {X1, X2, X3}}{cs, {z, t, x, q}}
 To see how to input tensors using this coordinate system see How to define tensor objects

How to define tensor objects

There are two ways of define tensors in TTC. Explicit tensors (E-tensors ) and symbolic tensors (S-tensors)

S-tensors

are tensors (/scalars) defined through a symbol which must be declared. First of use symbolic index calcultion you must declare a choosed list of symbols which will be used as index to output the results

?InputIndexInputIndex[indexlist] is the way to introduce orto change the index you want to use in the present session.The list must to have minimum one element, say{i}, then i1,i2,i3,...etc will be used us a index ifnedeed.InputIndex[{i,j,k,l}]{i, j, k, l}
Now we can define a tensor
?InputTensorInputTensor[T,basis,tensortype] is the way toinput a symbolic tensorInputTensor[W,XX,{1,1}];{W}


We can also define some symmetric properties for this tensor Here we define W as an antisymmetric tensor using InputSymmetries 
  
 

?InputSymmetries   InputSymmetries[T[i,j,a,b,m],{{i,m}}[1],   {i,a,b}[2],{{i,j},{a,b}}[1]] will define   the following symmetries for the indexes   of the predefined tensor T: {{i,m}}   (i,m) antisymmetrics {i,a,b} (i,a,b)   symmetrics {{i,j},{a,b}} ((i,j)(a,b))   pairsymmetric Cyclic[i,a,b] (i,a,b)   cyclic. The list of symetries   specifications can be as long as you   want. The numbers [1]   [2]...[n]..indicates that the property   will be used with BasicRules[n]. See   examples in TTC tutorial. Example the   Levi Civita like symmetries:   InputSymmetries[s[i,j,k,l],{{i,j,k,l}}[1   ]] Example: the riemann like symmetries   : InputSymmetries[R[i,j,k,l],   {{i,j}}[1],{{k,l}}[1],{{i,j},{k,l}}[2],C   yclic[j,k,l][2]]   InputSymmetries[R[i,j,k,l,.;m],Cyclic[k,   l,m][2]] See examples in TTC tutorial.InputSymmetries[W[a,b],{{a,b}}[1]]
Now the tensor is ready to be used. We use the Index function with its first argument empty to indicate that the metric to be used when nedeed is the Euclidean one. The following input is the tranposed of the tensor W ( we use the tensor 0 in order to set a prefixed order of index)
?IndexIndex is the function used for doing computations in  index notation.0[a,-b]+W[-b,a]//Index[] i         i 0     + W   j     j %//Index[,SimplifyAllIndex[2]] i       i 0     - W   j       j
Here we define the scalar field h and the constant M. Then input an expression which includes the characters ".; " used for covariant derivative. We useSuperIndexExpand to expand the expression. After we explicit the non constant scalar fields and reinput the same expression.
InputTensor[h,XX,{}]{W,h}InputTensor[M,XX,{},{Constant}]{W, h, M}(M h)[.;-l]//Index[]0   + (M h) i         .;i %//Index[,SuperIndexExpand]0   + M h i       .;iCompact[Off]Offh=X1^2+X2^2+X1 X2 X3  2     2X1  + X2  + X1 X2 X3(M h)[.;-l]//Index[]Storing AbsoluteD TensorM (2 X1 + X2 X3) dX1 + M (2 X2 + X1 X3) dX2 +   M X1 X2 dX3
 Other examples can be found in: RiemanRules

E-tensors

To write explicit tensors it is not necesary that previously there exist as a symbolic ones. That is you can use explicit (E )calculus without known nothing about symbolic calculus (S).

You can use the coordinates as usual to define scalar fields. Note that we have used the symbol "=>" instead of "=" . If you want you can use "=" but in general TTCprefer "=>"

Compact[On]OnA=>z^2 t+q/(M+2 x)TTC[1]
The symbol A is attached to a compact object TTC[1] which can be momentary displayed using UncompactTensor or permanently displayed (this and others) using Compact[Off]
A//UncompactTensor q           2------- + t zM + 2 xCompact[Off]OffA  q          2------- + t z M + 2 x


The only thing you need to learn in order to handle explicit tensor fields is how to write the basis for vectors and forms ( related to our coordinates system cs)

the form dt

cs[t]dt
the vector 
cs[-t]Dt
now using the symbol *. for the tensor product we can write all kind of tensor field as a linear combination of tensor basis elements
2 z q^2 cs[t]*.cs[-t]+3 q x cs[z]*. cs[-x]                    23 q x dz*.Dx + 2 q z dt*.Dt
For quickly inputs we can use cs[t,-t].... instead of cs[t]*.cs[-t]...
2 z a cs[t,-t]+z^2 cs[z,-q] 2z dz*.Dq + 2 a z dt*.Dt
we can use this objects as usual in the context of Mathematica objects (use of % or Out[]...)
(cs[-q]*. 2 %%+cs[-x]*. %%)*. %       26 q x z  Dq*.dz*.Dx*.dz*.Dq +   12 a q x z Dq*.dz*.Dx*.dt*.Dt +      2  3 4 q  z  Dq*.dt*.Dt*.dz*.Dq +        2  2 8 a q  z  Dq*.dt*.Dt*.dt*.Dt +          2 3 q x z  Dx*.dz*.Dx*.dz*.Dq +   6 a q x z Dx*.dz*.Dx*.dt*.Dt +      2  3 2 q  z  Dx*.dt*.Dt*.dz*.Dq +        2  2 4 a q  z  Dx*.dt*.Dt*.dt*.Dt
Also we can perform any kind of indexed operation (Now without metric)
?IndexIndex is the function used for doing computations in index notation.T=>%%%%                  23 q x dz*.Dx + 2 q  z dt*.DtT[-i,j]//Index[]                  23 q x dz*.Dx + 2 q  z dt*.DtT[-i,i]//Index[]Storing Contracted Tensor    22 q  zT[-i,j] cs[t][-j]//Index[]   22 q  z dtT[-i,j] cs[x][-j] cs[-z][i]//Index[]3 q x
We use the symbols ".," in order to indicate the usual "," used for partial derivative operation
T[-i,j,.,-k]//Index[]                                     23 q dz*.Dx*.dx + 3 x dz*.Dx*.dq + 2 q  dt*.Dt*.dz +   4 q z dt*.Dt*.dq

 

How to introduce a metric tensor

S-tensors

You can make symbolic index calculations using a symbolic metric declared with InputSMetric. If later you need to explicit the calculations you would use InputMetric by using the same names for the metric and coordinates

?InputSMetricInputSMetric[metricname,coordinatename,outputstring,inputsymbol]Is the way to define a symbolic metric. metricname is the name of themetric we want to use, coordinatename is the name of the actual coordinates,outputstring is the symbol used to display the metric,inputsymbol is the symbol for the metric used in tensorialexpressions.InputSMetric[gcs,cs,"g",g]{W, h, M, g}g[i,-i]//Index[gcs]4InputTensor[Q,cs,{1,1}]{ W, h, M, g, Q}Q[i,-j] g[j,k]//Index[gcs] i j     i j 0     + Q
E-tensors
?InputMetricInputMetric[g, b, t] declares the tensor t to be the metric named g in basis b.InputMetric[gcs,cs,        z cs[t,t] + q cs[q,q]+ t q cs[x,x]+x q cs[z,z]] q x dz*.dz + z dt*.dt + q t dx*.dx + q dq*.dqMetric[gcs,cs]q x dz*.dz + z dt*.dt + q t dx*.dx + q dq*.dq


Now we can perform metric dependent operations

T[i,j]//Index[gcs]   22 q  Dt*.Dt + 3 Dz*.DxT[-i,-j]//Index[gcs]   2                 2  23 q  t x dz*.dx + 2 q  z  dt*.dtT[i,j] T[-i,-j]//Index[gcs]   2          4  29 q  t x + 4 q  zT[-i,-j,.,k]//Index[gcs]6 t x dz*.dx*.Dq + 3 q dz*.dx*.Dx +      2 3 q  x                 2 ------ dz*.dx*.Dt + 4 z  dt*.dt*.Dq +    z  4 q z ----- dt*.dt*.Dz   x


We use the symbols ".;" in order to indicate the usual ";" used for covariant derivative operation

T[-i,-j,.;-k]//Index[gcs]    2 3 q  x               2 ------ dz*.dz*.dz - q  z dz*.dt*.dt -    2     2                   2 3 q  x              3 q  x ------ dz*.dt*.dx + ------ dz*.dx*.dt +    2                   2     2 3 q  t ------ dz*.dx*.dx + 3 q t x dz*.dx*.dq -    2  3 q t x               2 ------- dz*.dq*.dx - q  z dt*.dz*.dt +     2     2                     2 2 q  z dt*.dt*.dz + 4 q z  dt*.dt*.dq +   3 q t               3 ----- dt*.dx*.dt + q  z dt*.dx*.dx +    2                       2  3                3 q  t q  z dx*.dt*.dx - ------ dx*.dx*.dz -                      2  3 q t x ------- dq*.dx*.dz    2T[-i,-j,.;k]//Index[gcs]3 q              3 q x               2--- dz*.dz*.Dz - ----- dz*.dt*.Dx - q  dz*.dt*.Dt +  2                2 t                     3 q 3 t x dz*.dx*.Dq + --- dz*.dx*.Dx +                      2     2 3 q  x              3 x               2 ------ dz*.dx*.Dt - --- dz*.dq*.Dx - q  dt*.dz*.Dt +   2 z                 2     2              2 q z 4 z  dt*.dt*.Dq + ----- dt*.dt*.Dz +                      x   2 q  z              3 q t ---- dt*.dx*.Dx + ----- dt*.dx*.Dt +   t                 2 z   2 q  z              3 q t              3 t ---- dx*.dt*.Dx - ----- dx*.dx*.Dz - --- dq*.dx*.Dz  t                 2 x                2%[-i,-j,-k] T[i,k]//Index[gcs]                2              2        3    4        9 q  x      3 (3 q  t + 2 q  t)-2 q  z dz - ------ dt + ------------------- dx -                2                  2  9 q t x ------- dq    2Metric[gcs,cs][-i,-j]//Index[gcs]q x dz*.dz + z dt*.dt + q t dx*.dx + q dq*.dqMetric[gcs,cs][i,-j]//Index[gcs]Dq*.dq + Dx*.dx + Dt*.dt + Dz*.dzMetric[gcs,cs][-i,j]//Index[gcs]dz*.Dz + dt*.Dt + dx*.Dx + dq*.DqMetric[gcs,cs][-i,-j,.;-k]//Index[gcs]0Metric[gcs,cs][-i,i]//Index[gcs]4

This page is maintained by XavierJaén.