-
Notifications
You must be signed in to change notification settings - Fork 16
Adding Covariant/Contravariant Vector Documentation and Visualization #2295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
27b4b2d
a3fc7e5
2167cb3
0e7d966
f84af0c
8192cac
1cd6766
477caa3
004cfb6
3b2a245
5d393de
90b7c83
97c613f
3c44a32
dc47827
d6c9bf8
af2ab60
db570e4
51c122c
53d8701
5da8681
8a7a3c4
23b7cdd
ab5a19e
e48c196
97e1896
60852e1
b20561d
84f9dae
97ed00d
5303b0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -62,6 +62,19 @@ then may want to consider different bases, as not all operators accept all bases | |||||
_Covariance_ and _contravariance_ describe how the quantitative description of | ||||||
certain geometric or physical entities changes with a change of basis. | ||||||
|
||||||
More specifically, | ||||||
|
||||||
__Covariant objects__ —whether you mean covariant components (the coefficients that sit in front of the basis) | ||||||
or the covariant basis vectors themselves—co-vary with the coordinate grid. In other words, when you change coordinates, | ||||||
these quantities transform in the same way as the coordinate differentials. By convention they carry lower indices (subscripts). | ||||||
|
||||||
__Contravariant objects__—whether you mean contravariant components or the contravariant basis vectors—vary contra | ||||||
to the coordinate grid. That is, they transform in the opposite way to the coordinate differentials so as to keep | ||||||
tensorial expressions invariant. By convention they carry upper indices (superscripts). | ||||||
|
||||||
In ClimaCore.jl, `CovariantVector`s are aligned with the _contravariant basis vectors_, but have _covariant components_. | ||||||
Conversely, `ContravariantVector`s are aligned with the _covariant basis vectors_, but have _contravariant components_. | ||||||
|
||||||
In ClimaCore.jl, the _covariant basis_ is specified by the partial derivative | ||||||
of the transformation from the reference element ``\xi \in [-1,1]^d`` (where ``d`` | ||||||
is the dimensionality of the domain ``\Omega``) to ``x`` in the physical space: | ||||||
|
@@ -74,6 +87,47 @@ while the _contravariant basis_ is the opposite: gradient in ``x`` of the coordi | |||||
\mathbf{e}^i = \nabla_x \xi^i | ||||||
``` | ||||||
|
||||||
If we plot these bases in a curvilinear space, _covariant basis_ vectors “ride along” the coordinate surface liness (parallel), while _contravariant basis_ vectors “stick out” of those surface lines (perpendicular). See the plot from [Yatunin2025](@cite) below: | ||||||
|
||||||
 | ||||||
|
||||||
Here is a visual representation of how vectors can be represented in _contravariant_ and _covariant_ components. | ||||||
|
||||||
 | ||||||
|
||||||
From the above two figures, we can see that parallel projections would lead to contravariant components $a^{1}$ and $a^{2}$, | ||||||
while perpendicular projections would lead to covariant components $b_{1} = \mathbf{b}\cdot \mathbf{e}_1$ and $b_{2} = \mathbf{b}\cdot \mathbf{e}_2$. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @yiyuef, I still have a question about the notation you used in your figure. To be consistent with the figure above from the paper, shouldn't your covariant components be defined in terms of contravariant bases, i.e., use the superscript for the unitary vectors "e", as in:
Suggested change
? Therefore, also the unitary "e" vectors in the figure should have superscripts rather than subscripts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prof. Barra, Sorry for the delay. So Then, what I want to convey next is that I am not sure if this would be a clear explanation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @dennisYatunin , please take a look at this quick documentation PR. If it does look to you and think that might be a useful contribution to the docs, it is fine to merge by me. As far as I am concerned, I am still a bit unsure about the notation used in this figure to match the one in the paper. Thank you! |
||||||
|
||||||
As to better connect the original idea of _covariant components_ / _contravariant components_ with the real application in ClimaCore.jl, | ||||||
we bring the case of __polar coordinates__ -- a classic example of a __curvilinear coordinate system__. | ||||||
|
||||||
First of all, we have the Polar‐to‐Cartesian mapping as following: | ||||||
```math | ||||||
\mathbf{r} (r,\theta ) = (r \cos \theta, r \sin \theta) | ||||||
``` | ||||||
|
||||||
Then we have the _covariant basis_: | ||||||
```math | ||||||
\mathbf{e}_r = \frac{\partial \mathbf{r} }{\partial r} = \frac{\partial (r \cos \theta, r \sin \theta) }{\partial r} = (\cos \theta, \sin \theta) | ||||||
``` | ||||||
```math | ||||||
\mathbf{e}_{\theta} = \frac{\partial \mathbf{r} }{\partial \theta } = \frac{\partial (r \cos \theta, r \sin \theta) }{\partial \theta } = (-r\sin \theta,r \cos \theta) | ||||||
``` | ||||||
|
||||||
where $\mathbf{e}_r$ represents the direction that is tangent to the radius, and the one $\mathbf{e}_{\theta}$ tangent to the unit circle. | ||||||
|
||||||
And the _contravariant basis_: | ||||||
|
||||||
```math | ||||||
\mathbf{e}^r = \nabla r(x,y) = (\frac{x}{\sqrt{x^{2} +y^{2} }}, \frac{y}{\sqrt{x^{2} +y^{2} }}) = (\frac{x}{r},\frac{y}{r} ) = (\cos \theta, \sin \theta) | ||||||
``` | ||||||
```math | ||||||
\mathbf{e}^{\theta} = \nabla \theta(x,y) = (\frac{-y}{x^{2} +y^{2}}, \frac{x}{x^{2} +y^{2}}) = (\frac{-\sin \theta}{r} , \frac{\cos \theta}{r}) | ||||||
``` | ||||||
where we have used that $r(x,y) = \sqrt{x^{2} +y^{2} }$ and $\theta (x,y) = \arctan (\frac{y}{x} )$. | ||||||
|
||||||
valeriabarra marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
$\mathbf{e}^r$ represents the direction that is perpendicular to the unit circle, and $\mathbf{e}^{\theta}$ the one that is perpendicular to the radius. | ||||||
|
||||||
|
||||||
**Note**: | ||||||
|
||||||
|
@@ -85,6 +139,9 @@ while the _contravariant basis_ is the opposite: gradient in ``x`` of the coordi | |||||
|
||||||
* things get a little more complicated in the presence of terrain, but ``\xi^3`` is radially aligned | ||||||
- the 3rd covariant component is aligned with W, but the 3rd contravariant component may not be (e.g. at the surface it is normal to the boundary). | ||||||
|
||||||
|
||||||
|
||||||
|
||||||
### Cartesian bases | ||||||
Analogously to `CartesianPoint`s, in ClimaCore, there are also `CartesianVector`s: | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.