coordinate_transformation.py

Compute the coordinate transformation related variables for a mapping,

\Phi : \Omega_{\mathrm{ref}}\to\Omega

We get an instance of class CoordinateTransformation. The transformations are its methods.

⭕ To access the source code, click on the [source] button at the right side or click on [coordinate_transformation.py]. Dependence may exist. In case of error, check import and install required packages or download required scripts. © mathischeap.com

class coordinate_transformation.CoordinateTransformation(Phi, d_Phi)[source]

The coordinate transformation class.

Parameters:
  • Phi (function) –

    The mapping \Phi. It should be a function which returns three components of the mapping, i.e.,

    \Phi = (\Phi_x, \Phi_y, \Phi_z).

  • d_Phi (function) –

    The Jacobian matrix of \Phi, \mathcal{J}. It should be a function return the 9 components of the Jacobian matrix, i.e.,

    ( \dfrac{\partial x}{\partial\xi}, \dfrac{\partial x}{\partial\eta}, \dfrac{\partial x}{\partial\varsigma}), ( \dfrac{\partial y}{\partial\xi}, \dfrac{\partial y}{\partial\eta}, \dfrac{\partial y}{\partial\varsigma}), ( \dfrac{\partial z}{\partial\xi}, \dfrac{\partial z}{\partial\eta}, \dfrac{\partial z}{\partial\varsigma}).

Example:

>>> ct = CoordinateTransformation(Phi, d_Phi) # generate a CT instance
>>> xi = np.linspace(-0.9, 0.6, 3)
>>> et = np.linspace(-0.7, 0.9, 3)
>>> sg = np.linspace(-0.8, 0.7, 3)
>>> xi, et, sg = np.meshgrid(xi, et, sg, indexing='ij')
>>> x, y, z = ct.mapping(xi, et, sg)
>>> x 
array([[[0.06469463, 0.05391086, 0.02977458],...
>>> y 
array([[[0.16469463, 0.15391086, 0.12977458],...
>>> z 
array([[[0.11469463, 0.47891086, 0.82977458],...
>>> J = ct.Jacobian_matrix(xi, et, sg)
>>> J[0][0] # J_{1,1} 
array([[[0.64207986, 0.53781345, 0.30444385],...
>>> J[1][1] # J_{2,2} 
array([[[0.53354051, 0.50892654, 0.45383545],...
>>> detJ = ct.Jacobian(xi, et, sg)
>>> detJ 
array([[[0.1847901 , 0.11729178, 0.07611096],...
>>> iJ = ct.inverse_Jacobian_matrix(xi, et, sg)
>>> iJ[2][2] # J^{-1}_{3,3} 
array([[[1.82807508, 2.33068327, 1.69672867],...
>>> iJ[1][2] # J^{-1}_{2,3} 
array([[[-0.17192492,  0.33068327, -0.30327133],...
>>> G = ct.metric_matrix(xi, et, sg)
>>> G[0][1] # g_{1,2} 
array([[[ 0.10210648,  0.02438263, -0.09377707],...
>>> G[1][2] # g_{2,3} 
array([[[ 0.05493377, -0.03640053, -0.0063935 ],...
>>> g = ct.metric(xi, et, sg)
>>> g 
array([[[0.03414738, 0.01375736, 0.00579288],...
>>> iG = ct.inverse_metric_matrix(xi, et, sg)
>>> iG[1][2] # g^{2,3} 
array([[[-0.33977063,  0.72204401,  1.83434454],...
Jacobian(xi, et, sg)[source]

Compute the Jacobian \mathrm{det}(\mathcal{J}) of the mapping.

Returns:

The Jacobian \mathrm{det}(\mathcal{J}).

Jacobian_matrix(xi, et, sg)[source]

A wrap of the input Jacobian matrix, d_Phi, i.e., \mathcal{J}.

Returns:

Return the Jacobian matrix \mathcal{J}:

\mathcal{J} =
\begin{bmatrix}
\dfrac{\partial x}{\partial \xi} &
\dfrac{\partial x}{\partial \eta} &
\dfrac{\partial x}{\partial \varsigma} \\
\dfrac{\partial y}{\partial \xi} &
\dfrac{\partial y}{\partial \eta} &
\dfrac{\partial y}{\partial \varsigma} \\
\dfrac{\partial z}{\partial \xi} &
\dfrac{\partial z}{\partial \eta} &
\dfrac{\partial z}{\partial \varsigma}
\end{bmatrix}\,.

inverse_Jacobian(xi, et, sg)[source]

Compute the inverse Jacobian, the determinant of the inverse Jacobian matrix, \mathrm{det}(\mathcal{J}^{-1}).

inverse_Jacobian_matrix(xi, et, sg)[source]

Compute the Jacobian matrix of the inverse mapping \Phi^{-1},

(\xi,\eta,\varsigma) = \Phi^{-1}(x,y,z).

Returns:

Return the inverse Jacobian matrix : \mathcal{J}^{-1}:

\mathcal{J}^{-1} =
\begin{bmatrix}
\dfrac{\partial \xi}{\partial x} &
\dfrac{\partial \xi}{\partial y} &
\dfrac{\partial \xi}{\partial z} \\
\dfrac{\partial \eta}{\partial x} &
\dfrac{\partial \eta}{\partial y} &
\dfrac{\partial \eta}{\partial z} \\
\dfrac{\partial \varsigma}{\partial x} &
\dfrac{\partial \varsigma}{\partial y} &
\dfrac{\partial \varsigma}{\partial z}
\end{bmatrix}\,.

inverse_metric_matrix(xi, et, sg)[source]

Compute the inverse metric matrix, \mathcal{G}^{-1}.

Returns:

Return the inverse metric matrix : \mathcal{G}^{-1}:

\mathcal{G}^{-1} =
\begin{bmatrix}
g^{1,1} &
g^{1,2} &
g^{1,3} \\
g^{2,1} &
g^{2,2} &
g^{2,3} \\
g^{3,1} &
g^{3,2} &
g^{3,3}
\end{bmatrix}\,.

mapping(xi, et, sg)[source]

A wrap of the input mapping, Phi, i.e., \Phi.

Parameters:
  • xi\xi.

  • et\eta.

  • sg\varsigma.

Returns:

a tuple (x,y,z) = \Phi(\xi,\eta,\varsigma).

metric(xi, et, sg)[source]

The metric g:= \mathrm{det}(\mathcal{G}):=(\mathrm{det}(\mathcal{J}))^2.

metric_matrix(xi, et, sg)[source]

Compute the metric matrix \mathcal{G}.

Returns:

Return the metric matrix \mathcal{G}:

\mathcal{G} =
\begin{bmatrix}
g_{1,1} &
g_{1,2} &
g_{1,3} \\
g_{2,1} &
g_{2,2} &
g_{2,3} \\
g_{3,1} &
g_{3,2} &
g_{3,3}
\end{bmatrix}\,.

↩️ Back to Ph.D. thesis complements (ptc).