Getting started: Defining a vector field as a curl of another and defining a vector field to be always divergence free

39 views
Skip to first unread message

sambit ratha

unread,
Aug 22, 2021, 8:21:15 AM8/22/21
to xAct Tensor Computer Algebra
Hello everyone

I just got started with the package, and trying to define a vector field as the curl of another. This I did by defining the function (my metric is named 'met', and the corresponding covariant derivative is 'covD', and the indices are Latin alphabets {i,j,k,l,m,n} )
```
curl[ u_ , i_ ] := epsilonmet[ i , j , k ] covD[ -j ] u[ -k ] 
```
Now I define a vector fields 'B' and 'J' on my manifold called 'space' with the usual command ` DefTensor[ { B[ i ] , J[ i ] } , space ] `. I want J to be curl of the field B. I tried 
```
J[ i ] = curl [ B, i ]
```
which results in errors ` Validate: Found Indices with the same name j ` and `Throw: Uncaught Throw[Null] returned to top level `.

How do I fix it? Also, I have encountered the later message when I try to undefine a tensor that has not been defined, so any explanation of what it actually means is welcome. 

Thank you.

 

Jose

unread,
Aug 22, 2021, 8:33:02 AM8/22/21
to xAct Tensor Computer Algebra
Hi,

Try something like this:

<< xAct`xTensor`

$PrePrint = ScreenDollarIndices;

DefManifold[space, 3, {i, j, k, l}]

DefMetric[1, met[-i, -j], covD]

The use of := and Module here will avoid index collisions:

curl[ u_ , i_ ] := Module[{j, k}, epsilonmet[ i , j , k ] covD[ -j ][ u[ -k ] ]]

DefTensor[{B[i], J[i]}, space]

The use of := here will also avoid index collisions:

J[i_] := curl[B, i]

Then you can do things like:

In[13]:= met[-i, -j] J[i] J[j] // ToCanonical
Out[13]= - met[-i, -l]  met[-j, -k]  (covD[j][B[i]]) (covD[l][B[k]]) + met[-i, -k]   met[-j, -l]  (covD[j][B[i]]) (covD[l][B[k]])

Cheers,
Jose.

Leo Stein

unread,
Aug 22, 2021, 12:08:11 PM8/22/21
to Jose, sambit ratha, xAct Tensor Computer Algebra
Let me also add to Jose's answer. If you want the divergence of B to automatically vanish, you can write a very simple rule (you can use MakeRule to generate multiple rules for multiple index positions) and have it applied automatically (using AutomaticRules). There is also an example at this URL (https://github.com/xAct-contrib/DivFree) which uses the xTension framework to automate this, making it possible to write things like
  DefTensor[B[i], space, DivFree->{covD[-i]}]
so that the appropriate rules are written for you when B is defined.

This code worked 8 years ago, but I haven't checked it since then :)

Best
Leo

--
You received this message because you are subscribed to the Google Groups "xAct Tensor Computer Algebra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xact+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xact/c95c7276-4e62-4814-9055-fcb27679bdc8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages