Skip to main content

Package for PIV data analysis

Project description

PyTorch accelerated Particle Image Velocimetry

This program implements the basic algorithms of the PIV method, such as an iterative cross-correlation method based on FFT with an integer and continuous displacement (DWS, CWS) of the interrogation windows, filtering and interpolation of the pair loss effect, and so on. At this stage, the graphical interface is available, the ability to select PIV hyperparameters. The key feature of the project is the use of GPU due to the torch library. PIV algorithm is completely vectorized, what results in a very high performance using the GPU, but still has a room for improvement.

Parameters of the program:

  1. Interrogation window size
  2. Window overlap size
  3. Coordinate scale
  4. Time between frames
  5. Selection of the device (CPU or any of your GPUs)
  6. Iteration method: DWS or CWS
  7. The number of iterations of the algorithm
  8. Interrogation window scale during iterations
  9. Supported image formats (bmp, jpg, tiff, ect.)
  10. Options for saving program results

Installation:
It is easier to use conda environment.

  1. Install nvidia CUDA Toolkit https://developer.nvidia.com/cuda-toolkit to ensure latest nvidia driver usage
  2. Install pytorch with GPU support https://pytorch.org/ . Matching your CUDA version is not critical since PyTorch installs it's own cudatoolkit.
  3. In your environment or command line pip install TorchPIV

Usage:
Start GUI version from terminal
python

import torchPIV 
torchPIV.runGUI()

Use as a part of the script

from torchPIV import OfflinePIV

piv_gen = OfflinePIV(
    folder="test_images", # Path to experiment
    device=torch.cuda.get_device_name(), # Device name
    file_fmt="bmp",
    wind_size=64,
    overlap=32,
    dt=12, # Time between frames, mcs
    scale = 0.02, # mm/pix
    multipass=2,
    multipass_mode="CWS", # CWS or DWS
    multipass_scale=2.0, # Window downscale on each pass
    folder_mode="pairs" # Pairs or sequential frames 
)

results = []
for out in piv_gen():
    x, y, vx, vy = out
    results.append(out)

Tested on Windows

Performance:
This method allows processing 4 thousand pairs of images with a size of 4 MP each with a search window of 64, overlap of 50%, two iterations with re-arranging (an increase in the number of vectors by 4 times) in less than 10 minutes. The first iteration of the algorithm (~[4000, 64, 64] subimage tensor) takes ~15 ms on a Geforce GTX 1660 Ti GPU.

Futhure plans: Creating a version of the program for processing data during their recording. The ability to process stereo PIV data.

You can cite this work with:
N. A. Nazarov and V. V Terekhov, “High level GPU-accelerated 2D PIV framework in Python,” Comput. Phys. Commun., p. 109009, 2023, doi: https://doi.org/10.1016/j.cpc.2023.109009.

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

torchpiv-0.1.18.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchpiv-0.1.18-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file torchpiv-0.1.18.tar.gz.

File metadata

  • Download URL: torchpiv-0.1.18.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for torchpiv-0.1.18.tar.gz
Algorithm Hash digest
SHA256 39fee149bd099040e2e575bc6905ca8f4fef9e0d8d95cd1e9c680617ef589bc9
MD5 f26d1b01754ee43f5a1db9f2a2836308
BLAKE2b-256 047f2cbb374f69da4f2d412516104f6c681c05d6badd1be94fc8de74dfa307d9

See more details on using hashes here.

File details

Details for the file torchpiv-0.1.18-py3-none-any.whl.

File metadata

  • Download URL: torchpiv-0.1.18-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for torchpiv-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 25683f9de17c19727fc2b299861b6f1ffe46eacb67bef8c5ab637b182e008fd6
MD5 351e8e92c79b36e03b6411193fa87147
BLAKE2b-256 456a0e0cc90b0a24e329e4a2e4bf217e0b1702c999aa7c417ab01f2e9480cb35

See more details on using hashes here.

Supported by

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