jejjohnson / oceanbench

OceanBench - SSH edition
https://jejjohnson.github.io/oceanbench/
MIT License
16 stars 2 forks source link

Investigate Differential Operators 4 xarray #17

Closed jejjohnson closed 1 year ago

jejjohnson commented 1 year ago

This is to investigate some existing work for how we can calculate derivatives with the . Related to evaluation module in issue #7.


Motivation

There are many useful derived quantities that are useful, e.g. (u,v) velocities, potential vorticity, stream function, kinetic energy, enstropy, strain, etc. These all require some finite difference operations, i.e. derivative, gradient, Laplacian, divergence, and/or curl. So we need this functionality. I think that we may not need to implement these from scratch but it is worth investigating which packages exist that have the derivatives available.


Gradient Operators

Gradient $$ \nabla u: \mathbb{\Omega} \rightarrow \mathbb{\Omega}^{D} $$ ```python grad(u) = [du_dx, du_dy, du_dz] ```
Laplacian $$\nabla^2 u$$ ```python ap(u) = du2_dx2 + du2_dy2 + du2_dz2 ```
Divergence $$\text{ div}(u)$$ ```python div(u) = du_dx + dv_dy + dw_dz ```
Vorticity $$\text{ vort}(u, v)$$ ```python vort(u, v) = dv_dx - du_dy ```
Curl $$\text{ curl}(u, v, w)$$ ```python curl(u, v, w) = [dw_dy - dv_dz, du_dz - dw_dx, dv_dx - du_dy] ```
Tension Strain ```python tension_strain(u,v) = du_dx - dv_dy ```
Shear Strain ```python shear_strain(u,v) = dv_dx + du_dy ```
Shear Strain ```python def(u,v) = sqrt(tension_strain(u,v)**2 + shear_strain(u,v)**2) ```

Example Packages

metpy

This package features a lot of methods for calculating some gradient operations.

Positive:

List of Differential Operators * Divergence - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.divergence.html) | [Example]() * Gradient - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.gradient.html) | [Example](https://unidata.github.io/MetPy/latest/examples/calculations/Gradient.html#sphx-glr-examples-calculations-gradient-py) * Geospatial Gradient - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.geospatial_gradient.html) * Laplacian - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.laplacian.html) * Geospatial Laplacian - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.geospatial_laplacian.html) * Vector Derivative - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.vector_derivative.html#metpy.calc.vector_derivative) * Divergence - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.divergence.html) | [Example](https://unidata.github.io/MetPy/latest/examples/calculations/Divergence.html#sphx-glr-examples-calculations-divergence-py) * (Relative) Vorticity - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.vorticity.html#metpy.calc.vorticity) | [Example](https://unidata.github.io/MetPy/latest/examples/calculations/Vorticity.html#sphx-glr-examples-calculations-vorticity-py) * Absolute Vorticity - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.absolute_vorticity.html#metpy.calc.absolute_vorticity) | [Example](https://unidata.github.io/MetPy/latest/examples/calculations/Absolute_Vorticity.html#sphx-glr-examples-calculations-absolute-vorticity-py) * Shearing Deformation - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.shearing_deformation.html) | [Examples](https://unidata.github.io/MetPy/latest/examples/calculations/Shearing_Deformation.html#sphx-glr-examples-calculations-shearing-deformation-py) * Stretching Deformation - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.stretching_deformation.html#metpy.calc.stretching_deformation) | [Example](https://unidata.github.io/MetPy/latest/examples/calculations/Stretching_Deformation.html#sphx-glr-examples-calculations-stretching-deformation-py) * Total Deformation - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.total_deformation.html#metpy.calc.total_deformation) | [Example](https://unidata.github.io/MetPy/latest/examples/calculations/Total_Deformation.html#sphx-glr-examples-calculations-total-deformation-py) * Coriolis Parameter - [docs](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.coriolis_parameter.html#)

xinvert

A nice package with very easy to understand code. They also do a lot of Poisson solvers with a numba implementation. I don't think we need this though.

List of Operators
jejjohnson commented 1 year ago

Closing due to #36