# Introduction to orthogonal coordinates

In $\mathbb{R}^3$, we can think that each point is given by the
intersection of three surfaces. Thus, we have three families of curved
surfaces that intersect each other at right angles. These surfaces are
orthogonal locally, but not (necessarily) globally, and  are
defined by

$$u_1 = f_1(x, y, z)\, ,\quad u_2 = f_2(x, y, z)\, ,\quad u_3=f_3(x, y, z) \, .$$

These functions should be invertible, at least locally, and we can also write

$$x = x(u_1, u_2, u_3)\, ,\quad y = y(u_1, u_2, u_3)\, ,\quad z = z(u_1, u_2, u_3)\, ,$$

where $x, y, z$ are the usual Cartesian coordinates. The curve defined by the intersection of two of the surfaces gives us
one of the coordinate curves.

## Scale factors

Since we are interested in how these surface intersect each other locally,
we want to express differential vectors in terms of the coordinates. Thus,
the differential for the position vector ($\mathbf{r}$) is given by

$$\mathrm{d}\mathbf{r} = \frac{\partial\mathbf{r}}{\partial u_1}\mathrm{d}u_1
+ \frac{\partial\mathbf{r}}{\partial u_2}\mathrm{d}u_2
+ \frac{\partial\mathbf{r}}{\partial u_3}\mathrm{d}u_3\, ,
$$

or

$$\mathrm{d}\mathbf{r} = \sum_{i=1}^3 \frac{\partial\mathbf{r}}{\partial u_i}\mathrm{d}u_i\, .$$

The factor $\partial \mathbf{r}/\partial u_i$ is a non-unitary vector that takes
into account the variation of $\mathbf{r}$ in the direction of $u_i$, and is then
tangent to the coordinate curve $u_i$. We can define a normalized basis $\hat{\mathbf{e}}_i$
using

$$\frac{\partial\mathbf{r}}{\partial u_i} = h_i \hat{\mathbf{e}}_i\, .$$

The coefficients $h_i$ are functions of $u_i$ and we call them _scale factors_. They
are really important since they allow us to _measure_ distances while we move along
our coordinates. We would need them to define vector operators in orthogonal coordinates.
When the coordinates are not orthogonal we would need to use the [metric tensor](https://en.wikipedia.org/wiki/Metric_tensor), but we are going to restrict ourselves to orthogonal systems.

Hence, we have the following

$$\begin{align}
&h_i = \left|\frac{\partial\mathbf{r}}{\partial u_i}\right|\, ,\\
&\hat{\mathbf{e}}_i = \frac{1}{h_i} \frac{\partial \mathbf{r}}{\partial u_i}\, .
\end{align}$$

## Curvilinear coordinates available

The following coordinate systems are available:

- Cartesian;

- Cylindrical;

- Spherical;

- Parabolic cylindrical;

- Parabolic;

- Paraboloidal;

- Elliptic cylindrical;

- Oblate spheroidal;

- Prolate spheroidal;

- Ellipsoidal;

- Bipolar cylindrical;

- Toroidal;

- Bispherical; and

- Conical.


To obtain the transformation for a given coordinate system we can use
the function `transform_coords` in the `vector` module.


```python
import sympy as sym
from continuum_mechanics import vector
```

First, we define the variables for the coordinates $(u, v, w)$.


```python
sym.init_printing()
u, v, w = sym.symbols("u v w")
```

And, we compute the coordinates for the **parabolic** system using ``transform_coords``.
The first parameter is a string defining the coordinate system and the second is
a tuple with the coordinates.


```python
vector.transform_coords("parabolic", (u, v, w))
```

The scale factors for the coordinate systems mentioned above are availabe.
We can compute them for bipolar cylindrical coordinates. The coordinates
are defined by

$$\begin{align}
&x = a \frac{\sinh\tau}{\cosh\tau - \cos\sigma}\, ,\\
&y = a \frac{\sin\sigma}{\cosh\tau - \cos\sigma}\, ,\\
&z = z\, ,
\end{align}$$

and have the following scale factors

$$h_\sigma = h_\tau = \frac{a}{\cosh\tau - \cos\sigma}\, ,$$

and $h_z = 1$.


```python
sigma, tau, z, a = sym.symbols("sigma tau z a")
z = sym.symbols("z")
scale = vector.scale_coeff_coords("bipolar_cylindrical", (sigma, tau, z), a=a)
scale
```

Finally, we can compute vector operators for different coordinates.

The Laplace operator for the bipolar cylindrical system is given by

$$
\nabla^2 \phi =
\frac{1}{a^2} \left( \cosh \tau - \cos\sigma \right)^{2}
\left( 
\frac{\partial^2 \phi}{\partial \sigma^2} + 
\frac{\partial^2 \phi}{\partial \tau^2} 
\right) + 
\frac{\partial^2 \phi}{\partial z^2}\, ,$$

and we can compute it using the function ``lap``. For this function,
the first parameter is the expression that we want to compute the
Laplacian for, the second parameter is a tuple with the coordinates
and the third parameter is a tuple with the scale factors.


```python
phi = sym.symbols("phi", cls=sym.Function)
lap = vector.lap(phi(sigma, tau, z), coords=(sigma, tau, z), h_vec=scale)
sym.simplify(lap)
```

37ad4501c97e4936a62f91748c39070b383beb66
ipynb
Jupyter Notebook
docs/tutorials/curvilinear_coordinates.ipynb
nicoguaro/continuum_mechanics
f8149b69b8461784f6ed721294cd1a49ffdfa3d7
MIT
2018-12-09T15:02:51.000Z
2022-02-16T09:28:38.000Z
docs/tutorials/curvilinear_coordinates.ipynb
nicoguaro/continuum_mechanics
f8149b69b8461784f6ed721294cd1a49ffdfa3d7
MIT
2019-05-06T16:31:50.000Z
2022-03-31T21:21:03.000Z
docs/tutorials/curvilinear_coordinates.ipynb
nicoguaro/continuum_mechanics
f8149b69b8461784f6ed721294cd1a49ffdfa3d7
MIT
2020-01-29T10:03:52.000Z
2022-02-25T19:34:37.000Z
Qwen/Qwen-72B
1. YES
2. YES