Ask Your Question
1

Computing gradients of vector fields?

asked 2020-07-17 17:54:22 +0100

Okarin86 gravatar image

Premise, I'm not working with special/general relativity, so it may be that the way the formalism is thought in SageMath does not fit perfectly my needs.

I'm trying to define vector and tensor fields in Euclidean space and then differentiate them. For example, I'm interested in calculating the gradient of a vector field, namely, the tensor field

$$ T_{ij} = \frac{dv_i}{dx_j} $$

. However classes like EuclideanSpace only allow me to produce vector fields on which I can compute divergence and curl. Should I just create three scalar fields, one for each component, and go with that? Or are there ways to get nabla out as a vector and use it directly to operate on actual vectors and tensors (in which case I could use the tensor product, $T = nabla \otimes v$)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-07-17 22:22:05 +0100

eric_g gravatar image

You can get nabla via nabla = E.metric().connection(), where E is the Euclidean space; then you apply it to the vector v by nabla(v), not by means of the tensor product. Here is a full example:

sage: E.<x,y,z> = EuclideanSpace()
sage: v = E.vector_field(-y, x^2, 1+x*y)
sage: nabla = E.metric().connection()
sage: nabla
Levi-Civita connection nabla_g associated with the Riemannian metric g on the Euclidean space E^3
sage: t = nabla(v)
sage: t
Tensor field of type (1,1) on the Euclidean space E^3
sage: t[:]
[  0  -1   0]
[2*x   0   0]
[  y   x   0]
edit flag offensive delete link more

Comments

Thanks a lot! Another thing, if you know, is there a convenience method to create an identity tensor in EuclideanSpace?

Okarin86 gravatar imageOkarin86 ( 2020-07-19 09:43:10 +0100 )edit
1

E.tangent_identity_field() returns the identity tensor.

eric_g gravatar imageeric_g ( 2020-07-19 23:56:13 +0100 )edit

Awesome, thanks!

Okarin86 gravatar imageOkarin86 ( 2020-07-20 08:55:15 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-17 17:54:10 +0100

Seen: 657 times

Last updated: Jul 17 '20