Function Repository Resource:

CoordinateMappingData

Source Notebook

Calculate characteristic properties for a generalized mapping between two coordinate systems

Contributed by: Lars Ulke-Winter

ResourceFunction["CoordinateMappingData"][mapping,property]

gives the value of the specified property for the coordinate transformation mapping.

ResourceFunction["CoordinateMappingData"][mapping,property,{x1,x2,,xn}]

gives the value of the property evaluated at the point {x1,x2,,xn}.

Details and Options

Metrics and Jacobians are fundamental objects in differential geometry and tensor analysis. ResourceFunction["CoordinateMappingData"] generalizes CoordinateChartData and CoordinateTransformData for arbitrary mappings between systems.
The value for mapping should be a Function or List of relations between coordinates.
Available properties include:
"CovariantBaseVectors"covariant base vectors bi (tangential to the coordinates lines)
"ContravariantBaseVectors"contravariant base vectors bj
"Metric"components of the 2-rank covariant metric tensor bij=bi·bj
"InverseMetric"components of the 2-rank contravariant metric tensor bkl=bk·bl, with
"VolumeFactor"coefficient of the differential in volume (surface, line) integrals,
"LeviCivitaCovariant", where ein is LeviCivitaTensor[n]
"LeviCivitaContravariant"
"MappingJacobian"Jacobian matrix of the mapping
"MappingJacobianDeterminant"determinant of the mapping Jacobian matrix
"InverseMappingJacobian"inverse of the Jacobian matrix of the mapping
Contravariant base vectors bj are also known as dual base vectors because the satisfy the relation .
For mappings to a lower-dimensional manifold, the "MappingJacobian" property returns the mixed shift tensor.
ResourceFunction["CoordinateMappingData"] takes the following option:
"UnitVectors"Falsewhether the components of the basis should be normalized

Examples

Basic Examples (5) 

Define local covariant base vectors in cylindrical coordinates:

In[1]:=
ResourceFunction[
 "CoordinateMappingData"][{Cos[#1[[2]]] #1[[1]], Sin[#1[[2]]] #1[[1]], #1[[3]]} &, "CovariantBaseVectors"]
Out[1]=

Get covariant base vectors at point {r,ϕ,z}:

In[2]:=
ResourceFunction[
  "CoordinateMappingData"][{Cos[#1[[2]]] #1[[1]], Sin[#1[[2]]] #1[[1]], #1[[3]]} &, "CovariantBaseVectors"][{r, \[Phi], z}]
Out[2]=

Define a mapping and coordinate system:

In[3]:=
mapping = {r Cos[\[Phi]], r Sin[\[Phi]], z}; coords = {r, \[Phi], z};

Calculate the associated covariant and contravariant base vectors:

In[4]:=
covBasis = ResourceFunction["CoordinateMappingData"][mapping, "CovariantBaseVectors", coords]
Out[4]=
In[5]:=
conBasis = ResourceFunction["CoordinateMappingData"][mapping, "ContravariantBaseVectors", coords] // Simplify
Out[5]=

Get normalized covariant and contravariant base vectors:

In[6]:=
mapping = {r Cos[\[Phi]], r Sin[\[Phi]], z}; coords = {r, \[Phi], z};
In[7]:=
covBasisNormalized = ResourceFunction["CoordinateMappingData"][mapping, "CovariantBaseVectors", coords, "UnitVectors" -> True] // Simplify[#, {r > 0, \[Phi] > 0}] &
Out[7]=
In[8]:=
conBasisNormalized = ResourceFunction["CoordinateMappingData"][mapping, "ContravariantBaseVectors", coords, "UnitVectors" -> True] // Simplify[#, {r > 0, \[Phi] > 0}] &
Out[8]=

Verify their inverse relationships:

In[9]:=
Table[covBasisNormalized[[i]] . conBasisNormalized[[j]], {i, 3}, {j, 3}] // Simplify // MatrixForm
Out[9]=

Get the covariant metric of mapping to a cylindrical system:

In[10]:=
mapping = {r Cos[\[Phi]], r Sin[\[Phi]], z}; coords = {r, \[Phi], z};
In[11]:=
(covMetric = ResourceFunction["CoordinateMappingData"][mapping, "Metric", coords] // Simplify) // MatrixForm
Out[11]=

Compare the result with the cataloged named system of CoordinateChartData:

In[12]:=
CoordinateChartData["Cylindrical", "Metric", coords] // MatrixForm
Out[12]=

Do a similar computation to get the inverse metric:

In[13]:=
(conMetric = ResourceFunction["CoordinateMappingData"][mapping, "InverseMetric",
      coords] // Simplify) // MatrixForm
Out[13]=
In[14]:=
CoordinateChartData["Cylindrical", "InverseMetric", coords] // MatrixForm
Out[14]=

Verify their inverse relationship:

In[15]:=
covMetric . conMetric // MatrixForm
Out[15]=

Identify the volume factor of a mapping:

In[16]:=
mapping = {r Cos[\[Phi]], r Sin[\[Phi]], z}; coords = {r, \[Phi], z};
In[17]:=
ResourceFunction["CoordinateMappingData"][mapping, "VolumeFactor", coords] // Simplify[#, r > 0] &
Out[17]=

Compare with CoordinateChartData:

In[18]:=
CoordinateChartData["Cylindrical", "VolumeFactor", coords]
Out[18]=

Calculate the covariant components of the Levi-Civita tensor :

In[19]:=
ResourceFunction["CoordinateMappingData"][mapping, "LeviCivitaCovariant", coords] // Simplify[#, r > 0] &
Out[19]=

Get the contravariant components of the Levi-Civita tensor :

In[20]:=
ResourceFunction["CoordinateMappingData"][mapping, "LeviCivitaContravariant", coords] // Simplify[#, r > 0] &
Out[20]=

Find out which properties are available:

In[21]:=
ResourceFunction["CoordinateMappingData"]["Properties"]
Out[21]=

Scope (9) 

Use the contravariant Levi-Civita symbol to evaluate the cross product :

In[22]:=
mapping = {r Cos[\[Phi]], r Sin[\[Phi]], z}; coords = {r, \[Phi], z};
In[23]:=
wCon = ResourceFunction["CoordinateMappingData"][mapping, "LeviCivitaContravariant", coords] . {0, 1, 0} . {1, 0, 0} // Simplify[#, r > 0] &;
covBasis = ResourceFunction["CoordinateMappingData"][mapping, "CovariantBaseVectors", coords];
\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(3\)]\(wCon[[
   i]] covBasis[[i]]\)\)
Out[19]=

Check the above result by calculating the cross product of contravariant base vectors b3=b1b2:

In[24]:=
conBasis = ResourceFunction["CoordinateMappingData"][mapping, "ContravariantBaseVectors", coords] // Simplify;
(conBasis[[1]]\[Cross]conBasis[[2]]) // Simplify
Out[15]=

Affine coordinate transformation (1) 

Find out the properties of an affine coordinate transformation:

In[25]:=
mapping = {3 x + y, 2 z, y + z}; coords = {x, y, z};
In[26]:=
{conBasis, covBasis, invJacobian, conMetric, conLeviCivita, covLeviCivita, jacobian, jacobianDet, covMetric, volumefactor} = ResourceFunction["CoordinateMappingData"][mapping, #, coords] & /@ (ResourceFunction["CoordinateMappingData"][
     "Properties"]);
MatrixForm /@ %
Out[18]=

Polar coordinate transformation (1) 

Compute properties for polar coordinates:

In[27]:=
mapping = {r Cos[\[Phi]], r Sin[\[Phi]]}; coords = {r, \[Phi]};
ResourceFunction["CoordinateMappingData"][mapping, #, coords] & /@ ResourceFunction["CoordinateMappingData"]["Properties"] // Simplify[#, r > 0] &
Out[26]=

Surfaces embedded in 3D Euclidean space (4) 

Identify some metrics on the surface of a sphere:

In[28]:=
mapping = {r Sin[u] Cos[v], r Sin[u] Sin[v], r Cos[u]}; coords = {u, v};

Get the tangent space (represented by the covariant vectors):

In[29]:=