This repository contains a complete workflow for generating and analyzing porous media parameters for fin-tube heat exchanger designs using Latin Hypercube Sampling (LHS) and CFD-based correlations.
The full dataset and additional resources are available on Google Drive: Dataset & Resources
This project implements a systematic approach to:
- Generate constrained design variable samples using LHS
- Calculate porous media parameters from fin-tube geometries
- Project samples onto existing datasets for diversity
- Analyze sample spread and distribution quality
- Visualize results in 3D parameter space
Generates constrained Latin Hypercube Samples for fin-tube design variables.
Features:
- Generates samples for S1=S2 (tube spacing), fin height, and fin spacing
- Enforces geometric feasibility constraints
- Uses tube diameter td=24mm with clearance margins
- Outputs:
1.constrained_LHS_100k.csv
Usage:
python "1. generate_lhs_100k.py" --n 100000 --seed 2025 --out constrained_LHS_100k.csvConstraints:
- S1=S2: 45-200 mm
- Fin spacing (fs): 2-8 mm
- Fin height (fh): 6 mm ≤ fh ≤ 0.5*(s/√2 - td) - 0.4 mm
Batch processor that converts design variables to porous media parameters.
Features:
- Uses Nir(1991) pressure-drop correlation for staggered tube banks
- Fits Darcy-Forchheimer model via least-squares over velocity range
- Calculates viscous and inertial resistance coefficients
- Outputs:
2.porous_params_100k_full.csv
Physics:
- Computes porosity, hydraulic diameter, area ratios
- Evaluates pressure drop using validated correlations
- Extracts inverse permeability (1/K) and inertial coefficient (C2)
Usage:
python "2. porous_from_design_integrated.py" constrained_LHS_100k.csv --out porous_params_100k_full.csvKey Parameters Calculated:
Viscous_Resistance_1_m2(1/K): Inverse permeabilityInertial_Resistance_1_m(C2): Inertial resistance coefficientPorosity(ε): Volume fraction available for flow
Projects LHS samples onto existing dataset to maximize diversity using optimal assignment.
Features:
- Log-transforms and normalizes porous parameters
- Uses KD-tree for efficient nearest-neighbor search
- Applies Hungarian algorithm for optimal one-to-one matching
- Minimizes total distance in parameter space
- Outputs:
3.porous_LHS_100_projected.csv
Usage:
python "3. lhs_project_to_dataset.py" \
--lhs_csv porous_LHS_100.csv \
--data_csv porous_params_100k_full.csv \
--out porous_LHS_100_projected.csvAnalyzes distribution quality and provides sample selection diagnostics.
Features:
- Computes minimum nearest-neighbor distances
- Calculates spread metrics (mean, median, std)
- Identifies poorly covered regions
- Exports selected samples with original row indices
- Outputs:
4.selected_with_row_indices.csv+ text report
Usage:
python "4.spread_and_index_report.py" \
--csv porous_LHS_100_projected.csv \
--out selected_with_row_indices.csvMetrics Reported:
- Average/median minimum distance to neighbors
- Coefficient of variation
- Worst-case coverage gaps
- Quantile analysis of spread distribution
Visualization tool for parameter space exploration.
Features:
- 3D scatter plot in (Porosity, 1/K, C2) space
- Individual histograms for each parameter
- Supports log-scale transformation
- Configurable bins and output format
Usage:
python plot_porous_3d_and_hist.pyOutputs:
porous_plots/porous_3d_scatter.pngporous_plots/porous_histograms.png
Step 1: Generate LHS samples
└─> 1. generate_lhs_100k.py
Output: constrained_LHS_100k.csv
Step 2: Calculate porous parameters
└─> 2. porous_from_design_integrated.py
Output: porous_params_100k_full.csv
Step 3: Project to optimal samples
└─> 3. lhs_project_to_dataset.py
Output: porous_LHS_100_projected.csv
Step 4: Analyze sample quality
└─> 4.spread_and_index_report.py
Output: selected_with_row_indices.csv + report
Step 5: Visualize results
└─> plot_porous_3d_and_hist.py
Output: PNG plots
numpy
pandas
scipy
matplotlibInstall with:
pip install numpy pandas scipy matplotlib1.constrained_LHS_100k.csv: Raw LHS samples in design space (S1, fh, fs)2.porous_params_100k_full.csv: Full porous parameter dataset3.porous_LHS_100_projected.csv: Projected optimal samples4.selected_with_row_indices.csv: Final selection with metadata4.porous_LHS_100_projected.csv: Alternative projected samples
Note: Full datasets are available on the Google Drive.
This work applies optimal experimental design principles to CFD-based porous media modeling:
- Latin Hypercube Sampling: Ensures uniform coverage in design variable space
- Nir(1991) Correlation: Physics-based pressure drop for staggered fin-tube arrays
- Darcy-Forchheimer Model: Industry-standard porous media representation
- Optimal Assignment: Maximizes diversity in parameter space via Hungarian algorithm
Nir, A. (1991). Heat Transfer and Friction Factor Correlations for Crossflow over Staggered Finned Tube Banks. Heat Transfer Engineering, 12(1), 43–58.
AI-CO-SCIENTIST Project
For research and educational purposes.
For questions or collaborations, please refer to the dataset folder for additional documentation.