A package for discovering PDEs using data-driven techniques
Project description
Below is a description of our package
pdefinder is a Python package for discovering partial differential equations (PDEs) from data using data-driven techniques. The package implements methods inspired by PDE-FIND and includes utilities for building candidate libraries, computing numerical derivatives, performing sparse regression, and optimizing candidate coefficients.
Features
- Candidate Library Construction: Build a library of candidate PDE terms using polynomial functions and numerical differentiation.
- Numerical Differentiation: Compute derivatives using finite differences, polynomial interpolation, or Tikhonov regularization.
- Sparse Regression Methods: Available techniques include STRidge, Lasso, ElasticNet, and FoBa.
- Data Subsampling: Easily subsample data along spatial and temporal dimensions.
- LLM Integration: Interface with language models (via the OpenAI API) for initial coefficient estimation and verification.
- Optimization: Utilize CUDA-enabled PyTorch for efficient optimization of PDE coefficients.
Installation
Clone the repository and install the package locally:
git clone https://github.com/Amartya-Roy/pdefinder.git
cd pdefinder
pip install .
Alternatively, build the package distribution and install:
python setup.py sdist bdist_wheel
pip install dist/pdefinder-0.1.0-py3-none-any.whl
Usage
Command-Line Interface
You can run the PDE discovery pipeline from the command line. For example:
pdefinder --dataset KS --data_dir /path/to/data --P 5 --D 5 --epochs 1000
Python API
Import and run the main function in your own script:
from pdefinder import run_pde_finder
# Run the PDE discovery pipeline with custom parameters.
w_final, pde_expression = run_pde_finder(
dataset='KS',
P=5,
D=5,
num_epochs=1000,
data_dir='/path/to/data',
llm_initial='my_llm', # Identifier for the initial LLM
llm_verification='my_llm' # Identifier for the verification LLM
)
print("Optimized Coefficients:", w_final)
print("Discovered PDE:", pde_expression)
Parameters
- dataset: The dataset to use.(
.mator.npyformat) - P: Maximum polynomial power to include in the candidate library (default pipeline).
- D: Maximum derivative order to include (default pipeline).
- num_epochs: Number of epochs for the PyTorch optimization step (default pipeline).
- data_dir: Directory where the dataset files are located.
- llm_initial: Identifier for the language model used to generate initial coefficient guesses.
- llm_verification: Identifier for the language model used for verification.
Dependencies
The package requires:
Install the dependencies using pip:
pip install numpy scipy torch openai
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub for any bug reports, feature requests, or improvements.
Acknowledgments
This package is inspired by recent advances in data-driven PDE discovery methods. Special thanks to Soumya Mallick who helped me thinking about this idea.
Repository
For more information, visit the GitHub repository:
https://github.com/Amartya-Roy/pdefinder
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdefinder-0.1.7.tar.gz.
File metadata
- Download URL: pdefinder-0.1.7.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfb73c2297821ea3c3c1dc48e0e46611cbdfa6cbb9a221a3fa6cf9fbdb054f80
|
|
| MD5 |
47a26333fb1d854d8b2ad618e4e1bd68
|
|
| BLAKE2b-256 |
d1dfa41da5e7d2a6c5cc236e39ff66818eb4ada7b2ccc0043f56a9fdb53c3550
|
File details
Details for the file pdefinder-0.1.7-py3-none-any.whl.
File metadata
- Download URL: pdefinder-0.1.7-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4a8f0b98ca0c243699afc5402cae67ac01c7fd0073d4adc401799c78a7d6f98
|
|
| MD5 |
9754484cdca517f27a64aeffcb20460e
|
|
| BLAKE2b-256 |
73cb47fd688a4c89eb727e0ea60304e4db5470caebcfa096e04b41a81b038dec
|