Skip to main content

Calculate structure functions from fluid data

Project description

DOI documentation CI codecov

Overview

FluidSF is a Python package for calculating structure functions from fluid data. These structure functions can be used to estimate turbulence cascade rates without the constraints of spectral methods. This package serves as a useful tool for analyzing turbulent dynamics in the ocean, atmosphere, and beyond.

Plot of multiple methods to estimate energy flux for 2D fluid simulation

Note: FluidSF only calculates structure functions, it does not support spectral flux calculations or coarse-graining at this point. This image is an example use-case and demonstrates that advective structure functions agree with other common methods in ocean turbulence analysis.

For detailed documentation and examples, see the FluidSF website.

Installation

Fork/clone this repository to your local machine. The easiest method to install FluidSF is with pip:

$ pip install .

Quickstart

Once FluidSF is installed, you can load the module into Python and run some basic calculations with any data. Here we'll initialize linearly increasing velocity fields. For more detail on this example, see the full notebook on the FluidSF website.

First we'll initialize a random 2-D field to analyze:

import numpy as np

nx, ny = 100, 100
x = np.linspace(0, 1, nx)
y = np.linspace(0, 1, ny)
X, Y = np.meshgrid(x, y)
U = X
V = 0.5 * X

Next, we'll generate the advective structure functions.

import fluidsf
sf = fluidsf.generate_structure_functions_2d(U, V, x, y, sf_type=["ASF_V"], boundary=None)

Since we initialized our data as linearly increasing in x, we expect the advective structure function in x to scale with the squared separation distance $r^2$. Let's plot the structure function and this scaling relationship to show they match.


import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.loglog(sf["x-diffs"], sf["SF_advection_velocity_x"], label="Advective velocity SF in x", color='tab:red')
ax.loglog(sf["x-diffs"],(5 / 4) * sf["x-diffs"] ** 2,color="k",linestyle=(0, (5, 10)))
ax.set_xlabel("Separation distance")
ax.set_ylabel("Structure function")
ax.legend()
plt.show()

Advective structure function plots

"Can I use FluidSF with my data?"

Hopefully! FluidSF was initially developed for numerical simulations and satellite data, but there are of course many different types of data. If you are interested in using this package but you are unsure how to use it with your dataset, please reach out and we are happy to assist!

The best way to communicate about your data needs is to start a discussion where you can describe your dataset and what you're hoping to learn with FluidSF. Before starting a discussion you can check through other discussion posts or review the open (and closed) issues to see if any other users have a similar question or dataset.

We have plans to support many different types of data, especially oceanographic data, but we encourage any users to engage with us so we can make sure we support as many datasets as possible!

Contributing

This project welcomes contributions and suggestions. Feel free to open an issue, submit a pull request, and/or contact the owner directly.

References

  • Pearson, B. et al., 2021: Advective structure functions in anisotropic two-dimensional turbulence. Journal of Fluid Mechanics.
  • Lindborg, E. 2008: Third-order structure function relations for quasi-geostrophic turbulence. Journal of Fluid Mechanics.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluidsf-0.2.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

fluidsf-0.2.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file fluidsf-0.2.0.tar.gz.

File metadata

  • Download URL: fluidsf-0.2.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for fluidsf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 66c20ce68e66e3090fdac254ae1d9d666caea5081bed5c00017b67806e8057f9
MD5 938f62385836d1272e545a3e610504ed
BLAKE2b-256 5c1477d49d9392c15c56257c8af1828ac05c8143f029400e476b055615097cc7

See more details on using hashes here.

File details

Details for the file fluidsf-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fluidsf-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for fluidsf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0e6fb47f8371e356682719296d1908d313ec3228a93e2dc9ffc03311ed8f45d
MD5 060900b495b6fab88603743d5fead9ba
BLAKE2b-256 216461f45262cb06a2cc738520378244cd975146a7b44ff8b9c1c0cb4b531fd4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page