Some samples

Shortcuts (initialization cells)

Needs["Tens3D`"];

We define short notations for the predefined objects

B0 = CanonicalBasis;
G = MetricTensor;
H = OrientationTensor;

and names for the basis vectors of the canonical basis :

{e1, e2, e3} = BasisVectors[B0];

Definition of a coordinate system (initialization cells)

Uncomment one of the following coordinates systems or create four own coordinate system with the following conventions :
	- coords is the list of the name of the coordinates,
	- OM is the tens3D vector giving the point M function of the coordinates,
	- CS is the name of the natural basis of the coordinate system,
	- B1 is the name of the normalized basis.
With these conventions, all the further commands will run without editing.

Example 1 : cylindrical coordinates system (uncommented cells)

Following assumptions are useful to help the Simplify function :

$Assumptions =  $Assumptions  &&  
          r > 0  &&  θ > 0  &&  θ < 2 Pi;

u is the polar unit vector in the plane (e1,e2) :

u = (Cos[θ]∘
              e1) ⊕ (Sin[θ]∘ 
              e2);

Note : the vector is a function of θ :

(∂_θ) u // Components

In a cylindrical coordinate system, any point M is defined by :

OM =  (r∘u ) ⊕ (z∘
            e3)

Here is a shortcut for the list of the names of the coordinates :

coords = {r, θ, z};

Now we define the coordinates system. The result is the natural basis of the coordinates system.
Note that previous assumptions are necessary to find the orientation of the natural basis.

CS = DefineCoordinateSystem[OM, coords]

B1 is the normalized basis colinear to the natural basis :

B1 = NormalizedBasis[CS];

Example 2 : cartesian coordinates system (commented cells)

If fou want use it in the following demonstrations, uncomment theses commands :

Example 3: toroîdal coordinate system (commented cells)

If fou want use it in the following demonstrations, uncomment theses commands :

Definition of some tensorial fields (initialization cells)

F1 and F2 are two scalar fields :

F1 = f1[Apply[Sequence, coords]];
F2 = f2[Apply[Sequence, coords]];

V and W are two vector fields :
(note that they are defined by their components on the orthonormal basis B1)

V = DefineGeneralTensor[v, {1}, B1, coords]; 
    W = DefineGeneralTensor[w, {1}, B1, coords];
Components[V, {1}, B1]

Components[W, {1}, B0] // MatrixForm

T and S are two vector fields :
(note that they are defined by their components on the orthonormal basis B1)

T = 
        DefineGeneralTensor[t, {1, -1}, B1, 
          coords];
S = DefineGeneralTensor[s, {1, -1}, B1, coords];

Components[T, {1, -1}, B1] // MatrixForm

Using differential operators

The results in this section will change with the choosen coordinates system.

Gradient of tensorial fields

The gradient of a scalar field is a vector :

gradF1 = Gradient[F1, CS];
Rank[gradF1]

Components[gradF1, {-1}, B1] // CompactDerivativeForm

The gradient of a vector field is a rank 2 tensor

gradV = Gradient[V, CS];
Rank[gradV]

Components[gradV, {1, -1}, B1] // CompactDerivativeForm // 
      MatrixForm

Divergence of tensorial fields

The divergence of a vector field is a scalar

Divergence[V, CS] // CompactDerivativeForm

The divergence of a rank 2 tensorial field is a vector

divT = Divergence[T, CS];
Rank[divT]

Components[divT, {1}, B1] // CompactDerivativeForm // 
      MatrixForm

Curl of tensorial fields

The curl of a vector field is a vector field :

cuV = Curl[V, CS];
Rank[cuV]

Components[cuV, {1}, B1] //  CompactDerivativeForm  //  
      MatrixForm

Laplacian of tensorial fields

The laplacian of a scalar field is a scalar field :

Laplacian[F1, CS] // CompactDerivativeForm

The laplacian of a vector field is a vector field :

Components[Laplacian[V, CS], {1}, CS] // CompactDerivativeForm // 
      MatrixForm

Demonstration of some identities

The results in this section do not vary with the choosen coordinates system. They are identities.

H . V ⊖ 
V .  H // 
      Components

(H ∶ T) ⊖ 
(T ∶  
            H)  // Components

Gradient[OM, CS] ⊖ 
G  // 
      Components

Gradient[G, CS]  //  Components

Gradient[H, CS]  //  Components

Gradient[F1 F2, CS] ⊖
( 
          F1 ∘Gradient[F2, CS] ⊕ 
            F2∘Gradient[F1, CS] ) // Components

Gradient[F1∘V, CS] ⊖
( 
          F1∘Gradient[V, CS] ⊕ 
            V ⊗Gradient[F1, CS] ) // Components

Gradient[F1∘T, CS] ⊖
( 
          F1∘Gradient[T, CS] ⊕ 
            T ⊗Gradient[F1, CS] ) // Components

grad grad of a scalar field  is a rank 2 symmetrical tensor :

Asym[Gradient[Gradient[F1, CS], CS]] // Components

grad grad of a vectoriel field  is a rank 3 tensor, with symmetry on the two last indices :

Gradient[Gradient[V, CS], CS] ∶ H  // Components

Gradient[V . W, CS] ⊖
( 
          V  .  Gradient[W, CS] ⊕ 
            W .  Gradient[V, CS] )  // Components

The following identity is true but the calculation is a little bit long:

Gradient[T  ∶ S, 
          CS] ⊖
( (T ∶ 
                Gradient[S, CS]) ⊕ (S  ∶ 
                Gradient[T, CS]) )  //  Components

Gradient[T  ∶ G, CS] ⊖
( 
          G  ∶ Gradient[T, CS])   //  
      Components

Gradient[T  ∶ H, CS] ⊖
( 
          H  ∶ Gradient[T, CS])   //  Components

Gradient[T . V, CS]⊖
( 
          V . Gradient[Transpose[T], CS] ⊕ 
            T . Gradient[V, CS])  //  Components

Gradient[V . T, CS]⊖
( 
          V . Gradient[T, CS] ⊕ 
            Transpose[T] . Gradient[V, CS])  //  Components

Gradient[T  ∶ S, 
          CS] ⊖
( (S  ∶ 
                Gradient[T, CS]) ⊕ (T  ∶  
                Gradient[S, CS]) ) // Components

Divergence[F1∘V, CS]  - 
( 
          F1  Divergence[V, CS]  +  V  .  Gradient[F1, CS] )  // 
      Simplify

Divergence[F1∘T, 
          CS] ⊖
( 
          F1 ∘Divergence[T, CS] ⊕ 
            T  .  Gradient[F1, CS] ) // Components

Divergence[F1∘G, 
          CS] ⊖ 
Gradient[F1, CS] // 
      Components

Divergence[F1∘H, 
          CS] ⊖ 
H . Gradient[F1, CS] // 
      Components

Divergence[V⊗W, CS] ⊖
( 
          Gradient[V, CS] . W ⊕ 
            V∘Divergence[W, CS] )  // Components

Divergence[T . V, CS]  - 
( 
          Divergence[Transpose[T], CS] .  
              V  +  (Transpose[T]  ∶ 
                Gradient[V, CS]) )  //  Simplify

Divergence[V . T, 
          CS]  - 
(V .  
              Divergence[T, CS]  +  (Gradient[V, CS] ∶ 
                T) )  //  Simplify

Divergence[T . S, 
          CS] ⊖
( (Gradient[T, 
                  CS] ∶ S) ⊕ 
            T  .  Divergence[S, CS])  //  Components

Divergence[V  .  H, CS] ⊖ 
Curl[V, 
          CS]  // Components

Divergence[H .  V, CS] ⊖ 
Curl[V, 
          CS]  // Components

Divergence[T  .  H, CS] ⊖ 
Curl[T, 
          CS]  // Components

Divergence[H .  T, CS] ⊖ 
H . 
          Divergence[T, CS]  // Components

Divergence[T  ∶ H, CS]  -  
AutoContract[
          Gradient[T, CS] ∶ H] // Simplify

Divergence[H  ∶ T, CS]  -  
AutoContract[
          Gradient[T, CS] ∶ H] // Simplify

Divergence[V ⋀W, CS]  - 
( 
          W . Curl[V, CS]  -  V . Curl[W, CS] ) // Simplify

Curl[F1∘V, CS] ⊖
( 
          F1∘Curl[V, 
                CS] ⊕ (Gradient[F1, CS]⋀ V)) // 
      Components

Curl[F1∘T, CS] ⊖
( 
          F1∘Curl[T, CS] ⊖ ( 
              T⊗Gradient[F1, CS]  ∶ H) ) // 
      Components

Curl[F1∘G, 
          CS] ⊖  
Gradient[F1, CS] . 
          H   //  Components

Curl[V  .  H, CS] ⊖
( 
          Transpose[Gradient[V, CS]] ⊖ 
            Divergence[V, CS]∘G ) // Components

Curl[H  .  V, CS] ⊖
( 
          Transpose[Gradient[V, CS]] ⊖ 
            Divergence[V, CS]∘G ) // Components

Curl[T  ∶  H, 
          CS] ⊖
(  Divergence[T, 
              CS] ⊖   Divergence[Transpose[T], CS]) // 
      Components

Curl[H  ∶  T, 
          CS] ⊖
(  Divergence[T, 
              CS] ⊖   Divergence[Transpose[T], CS]) // 
      Components

Curl[V ⋀ W, 
          CS] ⊖
( V∘
                Divergence[W, CS]  ⊖ 
              W∘Divergence[V, CS] ⊕ Gradient[
                  V, CS] . W ⊖ Gradient[W, CS] . V)  //  
      Components

Curl[T . V, CS] ⊖
( 
          V .  Curl[Transpose[T], 
                CS] ⊖ ((T . Gradient[V, CS])  ∶ 
                H ) )  //  Components

Curl[V . T, CS] ⊖
( 
          V .  Curl[T, 
                CS] ⊖ 
((Transpose[T] . 
                    Gradient[V, CS])  ∶ H ) )  //  
      Components

Curl[Sph[T], 
          CS] ⊖ 
(1/3)∘
            Gradient[AutoContract[T], CS] .  H   //  
      Components

Laplacian[F1 F2, 
          CS]  -  
(  F1 Laplacian[F2, CS]  +  
            F2 Laplacian[F1, CS]  +  
            2 (Gradient[F1, CS] .  Gradient[F2, CS]))  //  
      Simplify

Laplacian[F1∘V, CS] ⊖
( 
          F1∘Laplacian[V, CS] ⊕ 
            V ∘Laplacian[F1, CS] ⊕ 
            2∘Gradient[V, CS] . Gradient[F1, CS] )  //  
      Components

Laplacian[F1∘T, CS] ⊖
( 
          F1∘Laplacian[T, CS] ⊕ 
            T ∘Laplacian[F1, CS] ⊕ 
            2∘Gradient[T, CS] . Gradient[F1, CS] )  //  
      Components

Laplacian[F1∘G, 
          CS] ⊖ 
Laplacian[F1, 
            CS]∘G  //  Components

Laplacian[F1∘H, 
          CS] ⊖ 
Laplacian[F1, 
            CS]∘H  //  Components

Laplacian[V . H, 
          CS] ⊖ 
Laplacian[V, CS] .  
          H  //  Components

Laplacian[T . H, 
          CS] ⊖ 
Laplacian[T, CS] .  
          H  //  Components

Laplacian[H .  T, CS] ⊖ 
H . 
          Laplacian[T, CS]  //  Components

Laplacian[H ∶  T, 
          CS] ⊖ 
(H ∶ 
            Laplacian[T, CS])  //  Components

Laplacian[ T ∶ H, 
          CS] ⊖ 
(Laplacian[T, 
              CS] ∶ H)  //  Components

Laplacian[V . W, CS]  -  
( 
          Laplacian[V, CS] . W  +  V .  Laplacian[W, CS]  +  
            2 (Gradient[V, CS] ∶ Gradient[W, CS] ) )  // 
      Simplify

Laplacian[AutoContract[T], CS]  -  
AutoContract[
          Laplacian[T, CS]]  //  Simplify

Laplacian[V, CS] ⊖
( 
          Gradient[Divergence[V, CS], CS]  ⊖ 
            Curl[Curl[V, CS], CS] )  //  Components

The following identity is true but the calculation is a little bit long:

Divergence[Curl[V, CS], CS] //  Simplify

Divergence[Curl[T, CS], CS] //  Components

Divergence[Transpose[Curl[T, CS]], 
          CS]⊖
Curl[
          Divergence[Transpose[T], CS], CS] //  Components

Curl[Gradient[F1, CS], CS]  //  Components

Curl[Gradient[V, CS], CS]  //  Components

Gradient[Curl[V, CS], CS] ⊖
Transpose[
          Curl[Transpose[Gradient[V, CS]], CS]]  //  Components

The following identity is true but the calculation is a little bit long:

Gradient[Divergence[V, CS], 
          CS] ⊖
Divergence[
          Transpose[Gradient[V, CS]], CS]  //  Components

(Curl[T, CS] ∶  H) ⊖
( 
          Gradient[AutoContract[T], 
              CS] ⊖ 
Divergence[
              Transpose[T], CS] )  //  Components

Laplacian[Curl[V, CS], CS] ⊖
Curl[
          Laplacian[V, CS], CS]  //  Components

Laplacian[Curl[T, CS], CS] ⊖
Curl[
          Laplacian[T, CS], CS]  //  Components

Laplacian[Divergence[V, CS], CS]  -  
Divergence[
          Laplacian[V, CS], CS]  //  Simplify

Laplacian[Divergence[T, CS], 
          CS] ⊖
Divergence[Laplacian[T, CS], 
          CS]  // Components

Laplacian[Gradient[F1, CS], 
          CS] ⊖ 
Gradient[Laplacian[F1, CS], 
          CS]  //  Components

Laplacian[Gradient[V, CS], 
          CS] ⊖ 
Gradient[Laplacian[V, CS], 
          CS]  //  Components

Laplacian[Gradient[T, CS], 
          CS] ⊖ 
Gradient[Laplacian[T, CS], 
          CS]  //  Components

Curl[T . S, CS] ⊖
( 
          T .  Curl[S, 
                CS] ⊖ (Gradient[T, 
                  CS] ∶ (S . H)) )  //  
      Components

V⋀Curl[W, 
            CS] ⊖ 
(V . 
              Gradient[W, CS] ⊖ Gradient[W, CS] . V)  //  
      Components

Gradient[V, CS]  .  
          V ⊖
( (1/2)∘
              Gradient[V . V, CS] ⊖ 
            V ⋀Curl[V, CS] )  //  Components