PODImodels
PODImodels (Proper Orthogonal Decomposition-based Interpolation Models) is a Python package for creating Reduced-Order Models (ROM) using POD combined with various machine learning techniques. It provides a unified framework for reduced-order modeling of high-dimensional field data, particularly useful for computational fluid dynamics and other physics-based simulations.
Features
- Multiple Interpolation Methods: Support for Linear Regression, Ridge Regression, Gaussian Process Regression (GPR), Radial Basis Functions (RBF), and Artificial Neural Networks (ANN)
- Flexible Modeling Approaches: Choose between direct field prediction or POD coefficient interpolation
- Easy-to-Use API: Scikit-learn-inspired interface with
fit()andpredict()methods - Built-in Scaling: Optional data normalization for improved model performance
- Extensible Architecture: Abstract base class for implementing custom interpolation models
Installation
Install PODImodels using pip:
pip install PODImodels
For development installation:
git clone https://github.com/Ruansh233/PODImodels.git
cd PODImodels
pip install -e .
Requirements
- Python >= 3.8
- numpy
- scikit-learn
- scipy
- pyvista
- torch
All dependencies will be automatically installed with the package.
Quick Start
import numpy as np
from PODImodels import PODGPR, fieldsRBF
# Prepare your data
# parameters: (n_samples, n_parameters)
# field_snapshots: (n_samples, n_field_points)
parameters = np.random.rand(100, 3)
field_snapshots = np.random.rand(100, 10000)
# Example 1: POD with Gaussian Process Regression
model = PODGPR(rank=15, with_scaler_x=True, with_scaler_y=True)
model.fit(parameters, field_snapshots)
predictions = model.predict(new_parameters)
# Example 2: Direct field prediction with Radial Basis Functions
model = fieldsRBF(kernel='thin_plate_spline', degree=2)
model.fit(parameters, field_snapshots)
field_prediction = model.predict(test_parameters)
Available Models
PODImodels provides two categories of models:
- Direct Field Models (
fields*): Learn direct mapping from parameters to field values - POD Coefficient Models (
POD*): Learn mapping from parameters to POD coefficients (more efficient for large fields)
Linear Regression Models
fieldsLinear: Direct field prediction using linear regressionPODLinear: POD coefficient prediction using linear regressionfieldsRidge: Direct field prediction using Ridge regressionPODRidge: POD coefficient prediction using Ridge regression
Gaussian Process Regression Models
fieldsGPR: Direct field prediction using Gaussian Process RegressionPODGPR: POD coefficient prediction using Gaussian Process RegressionfieldsRidgeGPR: Field prediction with Ridge regularization and GPRPODRidgeGPR: POD coefficient prediction with Ridge regularization and GPR
Radial Basis Function Models
fieldsRBF: Direct field prediction using Radial Basis Function interpolationPODRBF: POD coefficient prediction using Radial Basis Function interpolationfieldsRidgeRBF: Field prediction with Ridge regularization and RBFPODRidgeRBF: POD coefficient prediction with Ridge regularization and RBF
Neural Network Models
PODANN: POD coefficient prediction using Artificial Neural Networks
Usage Examples
Example 1: POD-GPR for CFD Field Reconstruction
from PODImodels import PODGPR
import numpy as np
# Load your simulation data
# X: Design parameters (e.g., Reynolds number, geometry params)
# Y: Field snapshots (e.g., velocity, pressure fields)
X_train = np.load('parameters.npy') # shape: (n_samples, n_params)
Y_train = np.load('fields.npy') # shape: (n_samples, n_points)
# Initialize model with 20 POD modes
model = PODGPR(rank=20, with_scaler_x=True, with_scaler_y=True)
# Train the model
model.fit(X_train, Y_train)
# Predict new fields
X_test = np.array([[100, 0.5, 1.2]]) # New parameter set
Y_pred = model.predict(X_test)
Example 2: Direct Field Interpolation with RBF
from PODImodels import fieldsRBF
# Initialize RBF model
model = fieldsRBF(
kernel='thin_plate_spline',
degree=2,
with_scaler_x=True
)
# Train and predict
model.fit(X_train, Y_train)
Y_pred = model.predict(X_test)
Example 3: Using Neural Networks
from PODImodels import PODANN
# Initialize ANN model
model = PODANN(
rank=15,
hidden_layer_sizes=[64, 32],
activation_function_name='relu',
num_epochs=100
)
model.fit(X_train, Y_train)
Y_pred = model.predict(X_test)
Writing Results to VTK
PODImodels includes built-in helpers to export fields and reconstructions to VTK
(.vtm) so you can visualize results in ParaView or PyVista.
1) Export true/reconstructed/error fields directly from a model
Use reconstruct(...) to write:
true_i(reference field)rec_i(predicted field)err_i(difference field)
from PODImodels import PODGPR
import numpy as np
X = np.load("parameters.npy") # (n_samples, n_params)
Y = np.load("fields.npy") # (n_samples, n_points) or flattened vectors
model = PODGPR(rank=20, with_scaler_x=True, with_scaler_y=True)
model.reconstruct(
x=X,
y=Y,
refVTMName="reference_mesh.vtm", # mesh topology/template
saveFileName="reconstruction_case",# writes reconstruction_case.vtm
dataType="scalar", # or "vector"
is2D=False, # set True for 2D vectors
)
2) Export POD modes to VTK
If you want to inspect POD basis modes:
from PODImodels import PODDataSet
import numpy as np
Y = np.load("fields.npy")
pod = PODDataSet(Y, rank=20, fullData=True)
pod.saveModes(
saveFileName="pod_modes",
refVTMName="reference_mesh.vtm",
dataType="scalar", # or "vector"
rank=10,
is2D=False,
)
This writes:
pod_modes.vtmpod_modes_truncationError.txtpod_modes_singulars.txt
3) Low-level VTK writing helper
For full control, call vtk_writer(...) directly:
from PODImodels import vtk_writer
vtk_writer(
field_data=[field_0, field_1], # one array per output field
field_name=["prediction_0", "prediction_1"],
data_type="scalar", # or "vector"
refVTMName="reference_mesh.vtm",
save_path_name="custom_output", # writes custom_output.vtm
is2D=False,
)
Notes:
refVTMNamemust point to a valid reference.vtmmesh.- Use
dataType/data_type="vector"for vector fields. - For 2D vector data, set
is2D=Trueto append a zero z-component for VTK compatibility.
Model Selection Guide
- Linear/Ridge: Fast, interpretable, works well for linear relationships
- GPR: Best for smooth, continuous fields with uncertainty quantification
- RBF: Excellent for scattered data interpolation
- ANN: Powerful for complex nonlinear relationships, requires more data
Choose POD* models when dealing with large field dimensions (>1000 points) for better computational efficiency.
Documentation
For detailed documentation and API reference, visit the GitHub repository.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Citation
If you use PODImodels in your research, please cite:
@software{PODImodels2024,
author = {Ruan, Shenhui},
title = {PODImodels: POD-based Interpolation Models for Reduced-Order Modeling},
year = {2024},
url = {https://github.com/Ruansh233/PODImodels}
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Shenhui Ruan
Email: shenhui.ruan@kit.edu
GitHub: @Ruansh233
Acknowledgments
This package was developed for reduced-order modeling in computational physics applications, with a focus on CFD simulations.
Metadata
Release files for PODImodels 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| podimodels-0.0.4.tar.gz | 24.4 kB | Without provenance | Details for podimodels-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| podimodels-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for podimodels-0.0.4-py3-none-any.whl |
Total release size: 46.6 kB
Release files / podimodels-0.0.4.tar.gz
| Download URL | podimodels-0.0.4.tar.gz |
|---|---|
| Size | 24.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea0a032f25fff41fdef8ef9b40f884f567f7c8fdd45d262ff7db4653503e35af
|
|
BLAKE2b-256 checksum How to use checksums |
64449b758a8a5ff286d354a2cad7ea0a5ce3f189f5dc1dd1e30d6b019c8ef2e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / podimodels-0.0.4-py3-none-any.whl
| Download URL | podimodels-0.0.4-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a156b260a5830d1a9dcb70f4869ae8dac9d4a8b275adc4cb525aa37d4fce47f
|
|
BLAKE2b-256 checksum How to use checksums |
4d3dc52da17ef108ecef4f48e7b567b6bd1e1d8e6ce5ec18804b0b52d1a15d01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for PODImodels 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.