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

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 to Index

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

?InputCoordinates
InputCoordinates[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 basis
InputCoordinates[XX, n], being n a positive
number 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

?InputIndex
InputIndex[indexlist] is the way to introduce or
to 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 if
nedeed.

InputIndex[{i,j,k,l}]
{i, j, k, l}
Now we can define a tensor
?InputTensor
InputTensor[T,basis,tensortype] is the way to
input a symbolic tensor

InputTensor[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)
?Index
Index 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 use SuperIndexExpand  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       .;i

Compact[Off]
Off

h=X1^2+X2^2+X1 X2 X3
  2     2
X1  + X2  + X1 X2 X3

(M h)[.;-l]//Index[]
Storing AbsoluteD Tensor

M (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]
On

A=>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 z
M + 2 x

Compact[Off]
Off

A
  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]
                    2
3 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]
 2
z 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]*. %%)*. %
       2
6 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)
?Index
Index is the function used for doing computations in index notation.

T=>%%%%
                  2
3 q x dz*.Dx + 2 q  z dt*.Dt

T[-i,j]//Index[]
                  2
3 q x dz*.Dx + 2 q  z dt*.Dt

T[-i,i]//Index[]
Storing Contracted Tensor
    2
2 q  z

T[-i,j] cs[t][-j]//Index[]
   2
2 q  z dt

T[-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[]
                                     2
3 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

?InputSMetric
InputSMetric[metricname,coordinatename,outputstring,inputsymbol]
Is the way to define a symbolic metric. metricname is the name of the
metric 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 tensorial
expressions.

InputSMetric[gcs,cs,"g",g]
{W, h, M, g}

g[i,-i]//Index[gcs]

4

InputTensor[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
?InputMetric
InputMetric[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*.dq

Metric[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]

   2
2 q  Dt*.Dt + 3 Dz*.Dx

T[-i,-j]//Index[gcs]

   2                 2  2
3 q  t x dz*.dx + 2 q  z  dt*.dt

T[i,j] T[-i,-j]//Index[gcs]
   2          4  2
9 q  t x + 4 q  z

T[-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
    2

T[-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
    2

Metric[gcs,cs][-i,-j]//Index[gcs]
q x dz*.dz + z dt*.dt + q t dx*.dx + q dq*.dq

Metric[gcs,cs][i,-j]//Index[gcs]

Dq*.dq + Dx*.dx + Dt*.dt + Dz*.dz

Metric[gcs,cs][-i,j]//Index[gcs]

dz*.Dz + dt*.Dt + dx*.Dx + dq*.Dq

Metric[gcs,cs][-i,-j,.;-k]//Index[gcs]

0

Metric[gcs,cs][-i,i]//Index[gcs]

4

This page is maintained by XavierJaén.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值