PyFlowMeld is a comprehensive Python toolkit for analyzing the results of multiphase flow simulations generated by FlowMeld, a physics-based multi-phase, multicomponent solver. PyFlowMeld provides specialized modules for phase flow physics, drying phenomena, and pore network analysis. This package enables powerful post-processing of simulation data with features for visualization, statistical analysis, and network extraction.
- Phase Flow Analysis: Track phase distributions, calculate saturations, and visualize flow patterns.
- Drying Simulation: Analyze evaporation processes and receding contact lines.
- Pore Network Extraction: Extract and analyze pore/throat networks from binary images.
- Velocity Field Analysis: Process and visualize velocity fields in multiphase systems.
- π Phase saturation tracking over time
- πΌοΈ Slice visualization generation
- π Saturation profile calculations
- π¨ 3D phase distribution maps
- π¨ Velocity field visualization (streamlines & quiver plots)
- π Liquid fraction computation
- π Drying rate analysis
- πΊοΈ Phase map generation for specific slices
- β±οΈ Time-series processing of evaporation
- π Pore network extraction via PoreSpy
- π Connectivity analysis
- π Pore size distribution statistics
- π§ Phase filling fraction calculations
- π Mercury intrusion porosimetry (MIP) curves
- Python 3.8 or newer (tested with 3.9)
- Git
- (Optional) Conda, pyenv, or uv for environment management
Before you begin, ensure you have the following files in your repo:
requirements.txt:
numpy>=1.20.0
scipy>=1.7.0
pandas>=1.3.0
matplotlib>=3.4.0
tqdm>=4.62.0
porespy>=2.0.0
openpnm>=3.0.0
natsort>=7.1.0
pytest>=6.2.0
pytest-cov>=2.12.0environment.yml (for conda):
name: pyflowmeld
channels:
- defaults
- conda-forge
dependencies:
- python=3.9
- numpy>=1.20.0
- scipy>=1.7.0
- pandas>=1.3.0
- matplotlib>=3.4.0
- tqdm>=4.62.0
- porespy>=2.0.0
- openpnm>=3.0.0
- natsort>=7.1.0
- pytest>=6.2.0
- pytest-cov>=2.12.0
- pip
- pip:
- -e .# Clone the repository first
git clone https://github.com/yourusername/pyflowmeld.git
cd pyflowmeld
# Create environment from YAML file
conda env create -f environment.yml
# Activate the environment
# On Linux/Mac:
conda activate pyflowmeld
# On Windows (Anaconda Prompt):
activate pyflowmeld# Create a new conda environment
conda create -n pyflowmeld python=3.9 -y
# On Linux/Mac:
conda activate pyflowmeld
# On Windows (Anaconda Prompt):
activate pyflowmeld
# Install dependencies from the requirements file
conda install --file requirements.txt -c conda-forge -y
# Install the package in development mode
pip install -e .# Clone the repository first
git clone https://github.com/yourusername/pyflowmeld.git
cd pyflowmeld
# Install Python 3.9 using pyenv (you can skip this if already installed)
pyenv install 3.9.16
pyenv local 3.9.16
# Create virtual environment
python -m venv venv
# Activate the virtual environment
# On Linux/Mac:
source venv/bin/activate
# On Windows (CMD or PowerShell):
venv\Scripts\activate
# Install dependencies from requirements.txt
pip install -r requirements.txt
# Install the package in development mode
pip install -e .# Clone the repository first
git clone https://github.com/yourusername/pyflowmeld.git
cd pyflowmeld
# Install uv if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment
uv venv
# Activate the virtual environment
# On Linux/Mac:
source .venv/bin/activate
# On Windows (CMD or PowerShell):
.venv\Scripts\activate
# Install dependencies from requirements.txt
uv pip install -r requirements.txt
# Install the package in development mode
uv pip install -e .- Linux/Mac:
source venv/bin/activateorsource .venv/bin/activate - Windows:
venv\Scripts\activateor.venv\Scripts\activate - conda (all OSs):
conda activate pyflowmeldoractivate pyflowmeld(Anaconda Prompt, Windows)
from pyflowmeld.postprocess.flowphysics import PhaseFlow
# Initialize phase flow analyzer
phase_flow = PhaseFlow(
data_path="/path/to/simulation/data",
domain_size=(100, 100, 100),
padding=[5, 5, 5, 5, 5, 5],
rho_f1_stem="f1_rho_",
rho_f2_stem="f2_rho_"
)
# Run analysis
phase_flow(
time_range=(0, 50),
slices={"x": 50, "z": 30},
phase="invading",
saturation_profiles=["x", "z"],
thresh="median"
)from pyflowmeld.postprocess.drying import Drying
# Initialize drying analyzer
drying = Drying(
path_to_data="/path/to/data",
padding=[0, 0, 0, 0, 0, 0],
domain_size=[100, 100, 100],
threshold_tol=0.1
)
# Process drying simulation
drying(
time_range=[0, 100],
slices={'x': [25, 50, 75], 'y': 50}
)from pyflowmeld.postprocess.network import (
PoreNetworkExtractor,
PoreNetworkAnalyzer,
PhaseDistributionTracker,
NetworkProperties
)
# Extract network from binary image
extractor = PoreNetworkExtractor()
network_data = extractor.extract(binary_image)
# Analyze network properties
analyzer = PoreNetworkAnalyzer(network_data)
properties = NetworkProperties.from_analyzer(analyzer)
properties.print_summary()
# Track phase distributions
tracker = PhaseDistributionTracker(network_data)
phase_data = tracker.track_phase(rho1, rho2, time_step=10)from pyflowmeld.postprocess.flowphysics import PhaseVelocities
# Initialize velocity processor
pv = PhaseVelocities(
path_to_data="/path/to/data",
domain_size=(100, 100, 100),
trim=[2, 2, 2, 2, 1, 1]
)
# Create flow visualization
fig, ax = pv.plot_flow(
plot_type="streamlines",
phase="f1",
number=10,
z_plane=50,
density=25
)pyflowmeld/
βββ postprocess/
β βββ __init__.py
β βββ flowphysics.py # π Phase flow analysis
β βββ drying.py # π‘οΈ Drying phenomena
β βββ network.py # πΈοΈ Pore network analysis
βββ utils/
β βββ tools.py # π§ Utility functions
βββ tests/ # π§ͺ Test suite
βββ examples/ # π Example scripts
βββ requirements.txt # π¦ Dependencies (pip)
βββ environment.yml # π¦ Dependencies (conda)
βββ setup.py # π§ Package setup
βββ README.md # π This file
# Activate your environment first (see above)
pip install --upgrade -r requirements.txt# Update all packages in the environment
conda update --all -y
# Or update specific package
conda update numpy scipy -yuv pip install --upgrade -r requirements.txt# Run all tests
python -m pytest tests/
# Run specific test module
python -m pytest tests/test_flowphysics.py
# Run with coverage
python -m pytest --cov=pyflowmeld tests/
On Windows, make sure to activate your environment as shown above before running these commands.
# 1. Clone the repository
git clone https://github.com/yourusername/pyflowmeld.git
cd pyflowmeld
# 2. Create and activate environment (choose one method)
# Using conda:
conda env create -f environment.yml
# On Linux/Mac:
conda activate pyflowmeld
# On Windows (Anaconda Prompt):
activate pyflowmeld
# OR using pip:
python -m venv venv
# On Linux/Mac:
source venv/bin/activate
# On Windows (CMD or PowerShell):
venv\Scripts\activate
pip install -r requirements.txt
pip install -e .
# 3. Verify installation
python -c "import pyflowmeld; print('PyFlowMeld installed successfully!')"
# 4. Run example (if available)
python examples/basic_analysis.pyWe welcome contributions! Please follow these steps:
- π΄ Fork the repository
- πΏ Create a feature branch (
git checkout -b feature/AmazingFeature) - πΎ Commit your changes (
git commit -m 'Add some AmazingFeature') - π€ Push to the branch (
git push origin feature/AmazingFeature) - π Open a Pull Request
- Follow PEP 8 guidelines
- Add type hints where applicable
- Include docstrings for all functions and classes
- Write unit tests for new features
Copyright 2025. Corning Incorporated. All rights reserved.
This software may only be used in accordance with the identified license(s).
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- Hamed Haddadi β Staff Scientist (haddadigh@corning.com)
- David Heine β Principal Scientist and Manager (heinedr@corning.com)
Special thanks to:
- PoreSpy β Pore network extraction
- OpenPNM β Pore network modeling
- NumPy β Numerical computing
- Matplotlib β Visualization
If you use PyFlowMeld in your research, please cite:
@software{pyflowmeld2025,
title = {PyFlowMeld: A Python Toolkit for Multiphase Flow Analysis},
author = {Haddadi, Hamed and Heine, David},
year = {2025},
organization = {Corning Incorporated}
}Made with β€οΈ by the Corning Incorporated Science and Technology Organization