atensor.rlg 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. Tue Feb 10 12:26:32 2004 run on Linux
  2. %*********************************************************************
  3. % ATENSOR TEST RUN.
  4. %
  5. % V.A.Ilyin & A.P.Kryukov
  6. % E-mail: ilyin@theory.npi.msu.su
  7. % kryukov@theory.npi.msu.su
  8. %
  9. % Nucl. Phys. Inst., Moscow State Univ.
  10. % 119899 Moscow, RUSSIA
  11. %*********************************************************************
  12. % First of all we have to load the ATENSOR program using the one of the
  13. % following command:
  14. % 1) in "atensor.red"$ % If we load source code
  15. % 2) load atensor$ % If we load binary (compiled) code.
  16. load atensor;
  17. % To control of total execution time clear timer:
  18. showtime;
  19. Time: 0 ms
  20. % Switch on the switch TIME to control of executing time
  21. % for each statement.
  22. %on time$
  23. % Let us introduce the antisymmetric tensor of the second order.
  24. tensor a2;
  25. % The antisymmetric property can be expressed as:
  26. tsym a2(i,j)+a2(j,i);
  27. % The K-basis that span K subspace is:
  28. kbasis a2;
  29. a2(i,j) + a2(j,i)
  30. 1
  31. % Let us input very simple example:
  32. a2(k,k);
  33. 0
  34. % By the way the next two expressions looks like different ones:
  35. a2(i,j);
  36. a2(i,j)
  37. a2(j,i);
  38. a2(j,i)
  39. % But the difference of them has a correct value:
  40. a2(j,i)-a2(i,j);
  41. 2*a2(j,i)
  42. % Next examples. For this purpose we introduce 3 abstract
  43. % vectors - v1,v2,v3:
  44. tensor v1,v2,v3;
  45. % The following expression equal zero:
  46. a2(i,j)*v1(i)*v1(j);
  47. 0
  48. % It is interest that the result is consequence of the equivalence
  49. % of the name of tensors.
  50. % While the next one - not:
  51. a2(i,j)*v1(i)*v2(j);
  52. a2(i,j)*v1(i)*v2(j)
  53. % Well. Let us introduce the symmetric tensor of the second order.
  54. tensor s2;
  55. tsym s2(i,j)-s2(j,i);
  56. % Their K-basis look like for a2 excepted sign:
  57. kbasis s2;
  58. s2(j,i) + (-1)*s2(i,j)
  59. 1
  60. % Of course the contraction symmetric and antisymmetric tensors
  61. % equal zero:
  62. a2(i,j)*s2(i,j);
  63. 0
  64. % By the way, the next example not so trivial for computer...
  65. a2(i,j)*a2(j,k)*a2(k,i);
  66. 0
  67. % Much more interesting examples we can demonstrate with the
  68. % the tensor higher order. For example full antisymmetric tensor
  69. % of the third order:
  70. tensor a3;
  71. % The antisymmetric property we can introduce through the
  72. % permutation of the two first indices:
  73. tsym a3(i,j,k)+a3(j,i,k);
  74. % And the cyclic permutation all of them:
  75. tsym a3(i,j,k)-a3(j,k,i);
  76. % The K basis of a3 consist of 5 vectors:
  77. kbasis a3;
  78. a3(k,i,j) + a3(j,i,k)
  79. a3(k,j,i) + (-1)*a3(j,i,k)
  80. a3(i,k,j) + (-1)*a3(j,i,k)
  81. a3(i,j,k) + a3(j,i,k)
  82. a3(j,k,i) + a3(j,i,k)
  83. 5
  84. % In the beginning some very simple examples:
  85. a3(i,k,i);
  86. 0
  87. a3(i,j,k)*s2(i,j);
  88. 0
  89. % The full symmetric tensor of the third order may be introduce
  90. % by the similar way:
  91. tensor s3;
  92. tsym s3(i,j,k)-s3(j,i,k);
  93. tsym s3(i,j,k)-s3(j,k,i);
  94. kbasis s3;
  95. s3(k,j,i) + (-1)*s3(i,j,k)
  96. s3(k,i,j) + (-1)*s3(i,j,k)
  97. s3(j,k,i) + (-1)*s3(i,j,k)
  98. s3(j,i,k) + (-1)*s3(i,j,k)
  99. s3(i,k,j) + (-1)*s3(i,j,k)
  100. 5
  101. % The next examples demonstrate some calculation with them:
  102. s3(i,j,k)-s3(i,k,j);
  103. 0
  104. s3(i,j,k)*a2(i,j);
  105. 0
  106. a3(i,j,k)*s2(i,j);
  107. 0
  108. s3(i,j,k)*a3(i,j,k);
  109. 0
  110. % Now we consider very important physical case - Rieman tensor:
  111. tensor ri;
  112. % It has the antisymmetric property with respect to the permutation
  113. % of the first two indices:
  114. tsym ri(i,j,k,l) + ri(j,i,k,l);
  115. % It has the antisymmetric property with respect to the permutation
  116. % of the second two indices:
  117. tsym ri(i,j,k,l) + ri(i,j,l,k);
  118. % And the triple term identity with cyclic permutation the
  119. % third of them:
  120. tsym ri(i,j,k,l) + ri(i,k,l,j) + ri(i,l,j,k);
  121. % The corresponding K basis consist of 22(!) vectors:
  122. kbasis ri;
  123. ri(l,k,i,j) + (-1)*ri(j,i,k,l)
  124. ri(l,k,j,i) + ri(j,i,k,l)
  125. ri(l,i,k,j) + (-1)*ri(j,k,i,l)
  126. ri(l,i,j,k) + ri(j,k,i,l)
  127. ri(l,j,k,i) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  128. ri(l,j,i,k) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  129. ri(k,l,i,j) + ri(j,i,k,l)
  130. ri(k,l,j,i) + (-1)*ri(j,i,k,l)
  131. ri(k,i,l,j) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  132. ri(k,i,j,l) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  133. ri(k,j,l,i) + (-1)*ri(j,k,i,l)
  134. ri(k,j,i,l) + ri(j,k,i,l)
  135. ri(i,l,k,j) + ri(j,k,i,l)
  136. ri(i,l,j,k) + (-1)*ri(j,k,i,l)
  137. ri(i,k,l,j) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  138. ri(i,k,j,l) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  139. ri(i,j,l,k) + (-1)*ri(j,i,k,l)
  140. ri(i,j,k,l) + ri(j,i,k,l)
  141. ri(j,l,k,i) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  142. ri(j,l,i,k) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  143. ri(j,k,l,i) + ri(j,k,i,l)
  144. ri(j,i,l,k) + ri(j,i,k,l)
  145. 22
  146. % So we get the answer for any expressions with 3 and more terms of
  147. % Rieman tensors with not more then 2 terms. For example:
  148. ri(i,j,k,l)+ri(j,k,l,i)+ri(k,l,i,j)+ri(l,i,j,k);
  149. (-2)*ri(l,j,i,k) + 4*ri(l,i,j,k)
  150. % This three identities leads us to very important symmetry property with
  151. % respect to exchange of pairs indices:
  152. ri(i,j,k,l)-ri(k,l,i,j);
  153. 0
  154. % Let us start with simple example:
  155. ri(m,n,m,n)-ri(m,n,n,m);
  156. 2*ri(m,n,m,n)
  157. % Much more complicated example is:
  158. a2(m,n)*ri(m,n,c,d) + a2(k,l)*ri(c,d,l,k);
  159. 0
  160. % The answer is trivial but not so simple to obtain one.
  161. % The dimension of the full space is 6! = 720.
  162. % The K basis consists of 690 vectors (to reduce output we
  163. % commented the last statement):
  164. %kbasis ri(a2);
  165. % One else nontrivial examples with Riemann tensors:
  166. (ri(i,j,k,l)-ri(i,k,j,l))*a2(i,j);
  167. a2(i,j)*ri(i,j,k,l)
  168. ---------------------
  169. 2
  170. %***************** END OF TEST RUN ************************
  171. % The total execution time is:
  172. showtime;
  173. Time: 9370 ms plus GC time: 60 ms
  174. $
  175. END$
  176. Time for test: 9370 ms, plus GC time: 60 ms