Skip to content

Commit

Permalink
Merge pull request #144 from dynamicslab/pde_optimization
Browse files Browse the repository at this point in the history
PDE and weak form in arbitrary dimensions now functional!
  • Loading branch information
akaptano committed Jan 6, 2022
2 parents dfcdb37 + fd4befd commit 6d908c3
Show file tree
Hide file tree
Showing 36 changed files with 3,912 additions and 4,520 deletions.
8 changes: 4 additions & 4 deletions README.rst
Expand Up @@ -215,7 +215,7 @@ If you use PySINDy in your work, please cite it using the following two referenc

Brian M. de Silva, Kathleen Champion, Markus Quade, Jean-Christophe Loiseau, J. Nathan Kutz, and Steven L. Brunton., (2020). *PySINDy: A Python package for the sparse identification of nonlinear dynamical systems from data.* Journal of Open Source Software, 5(49), 2104, https://doi.org/10.21105/joss.02104

Alan A. Kaptanoglu, Brian M. de Silva, Urban Fasel, Kadierdan Kaheman, Jared L. Callaham, Charles B. Delahunt, Kathleen Champion, Jean-Christophe Loiseau,J. Nathan Kutz, and Steven L. Brunton. *PySINDy: A comprehensive Python packagefor robust sparse system identification.* arXiv preprint arXiv:2111.08481, 2021.
Alan A. Kaptanoglu, Brian M. de Silva, Urban Fasel, Kadierdan Kaheman, Jared L. Callaham, Charles B. Delahunt, Zachary G. Nicolaou, Kathleen Champion, Jean-Christophe Loiseau,J. Nathan Kutz, and Steven L. Brunton. *PySINDy: A comprehensive Python packagefor robust sparse system identification.* arXiv preprint arXiv:2111.08481, 2021.

Bibtex:

Expand All @@ -240,7 +240,7 @@ Bibtex:
@article{kaptanoglu2021pysindy,
title={PySINDy: A comprehensive Python package for robust sparse system identification},
author={Alan A. Kaptanoglu and Brian M. de Silva and Urban Fasel and Kadierdan Kaheman and Jared L. Callaham and Charles B. Delahunt and Kathleen Champion and Jean-Christophe Loiseau and J. Nathan Kutz and Steven L. Brunton},
author={Alan A. Kaptanoglu and Brian M. de Silva and Urban Fasel and Kadierdan Kaheman and Jared L. Callaham and Charles B. Delahunt and Zachary G. Nicolaou and Kathleen Champion and Jean-Christophe Loiseau and J. Nathan Kutz and Steven L. Brunton},
year={2021},
Journal = {arXiv preprint arXiv:2111.08481},
}
Expand All @@ -254,8 +254,8 @@ References
`[arXiv] <https://arxiv.org/abs/2004.08424>`__

- Kaptanoglu, Alan A., Brian M. de Silva, Urban Fasel, Kadierdan Kaheman,
Jared L. Callaham, Charles B. Delahunt, Kathleen Champion, Jean-Christophe Loiseau,
J. Nathan Kutz, and Steven L. Brunton.
Jared L. Callaham, Charles B. Delahunt, Zachary G. Nicolaou, Kathleen Champion,
Jean-Christophe Loiseau, J. Nathan Kutz, and Steven L. Brunton.
*PySINDy: A comprehensive Python package for robust sparse system identification.*
arXiv preprint arXiv:2111.08481 (2021).
`[arXiv] <https://arxiv.org/abs/2111.08481>`__
Expand Down
4 changes: 3 additions & 1 deletion docs/JOSS2/paper.md
Expand Up @@ -20,6 +20,8 @@ authors:
affiliation: 3
- name: Charles B. Delahunt
affiliation: 2
- name: Zachary G. Nicolaou
affiliation: 2
- name: Kathleen Champion
affiliation: 2
- name: Jean-Christophe Loiseau
Expand Down Expand Up @@ -81,7 +83,7 @@ Recent variants of the SINDy method are available that address systems with cont
In order to incorporate these new developments and accommodate the wide variety of possible dynamical systems, we have extended `PySINDy` to a more general setting and added significant new functionality. Our code\footnote{\url{https://github.com/dynamicslab/pysindy}} is thoroughly documented, contains extensive examples, and integrates a wide range of functionality, some of which may be found in a number of other local SINDy implementations\footnote{\url{https://github.com/snagcliffs/PDE-FIND}, \url{https://github.com/eurika-kaiser/SINDY-MPC},\\ \url{https://github.com/dynamicslab/SINDy-PI}, \url{https://github.com/SchatzLabGT/SymbolicRegression},\\ \url{https://github.com/dynamicslab/databook_python}, \url{https://github.com/sheadan/SINDy-BVP},\\ \url{https://github.com/sethhirsh/BayesianSindy}, \url{https://github.com/racdale/sindyr},\\ \url{https://github.com/SciML/DataDrivenDiffEq.jl}, \url{https://github.com/MathBioCU/WSINDy_PDE},\\ \url{https://github.com/pakreinbold/PDE_Discovery_Weak_Formulation}, \url{https://github.com/ZIB-IOL/CINDy}}. In contrast to some of these existing implementations, `PySINDy` is completely open-source, professionally-maintained (for instance, providing unit tests and adhering to PEP8 stylistic standards), and minimally dependent on non-standard Python packages.

# New features
Given spatiotemporal data $\mathbf{Q}(\mathbf{x}, t) \in \mathbb{R}^{m\times n}$, and optional control inputs $\mathbf{u} \in \mathbb{R}^{m \times r}$ (note $m$ has been redefined here to be the product of the number of spatial measurements and the number of time samples), `PySINDy` can now approximate algebraic systems of PDEs (and corresponding weak forms) in up to 3 spatial dimensions. Assuming the system is described by a function $\mathbf{g}$, we have
Given spatiotemporal data $\mathbf{Q}(\mathbf{x}, t) \in \mathbb{R}^{m\times n}$, and optional control inputs $\mathbf{u} \in \mathbb{R}^{m \times r}$ (note $m$ has been redefined here to be the product of the number of spatial measurements and the number of time samples), `PySINDy` can now approximate algebraic systems of PDEs (and corresponding weak forms) in an arbitrary number of spatial dimensions. Assuming the system is described by a function $\mathbf{g}$, we have
\begin{equation}\label{eq:pysindy_eq}
\mathbf{g}(\mathbf{q},\mathbf q_t, \mathbf q_x, \mathbf q_y, \mathbf q_{xx}, ..., \mathbf{u}) = 0.
\end{equation}
Expand Down
365 changes: 168 additions & 197 deletions examples/10_PDEFIND_examples.ipynb

Large diffs are not rendered by default.

357 changes: 191 additions & 166 deletions examples/11_SSR_FROLS_examples.ipynb

Large diffs are not rendered by default.

897 changes: 414 additions & 483 deletions examples/12_weakform_SINDy_examples.ipynb

Large diffs are not rendered by default.

325 changes: 156 additions & 169 deletions examples/13_ensembling.ipynb

Large diffs are not rendered by default.

79 changes: 38 additions & 41 deletions examples/14_cavity_flow.ipynb

Large diffs are not rendered by default.

299 changes: 151 additions & 148 deletions examples/15_pysindy_lectures.ipynb

Large diffs are not rendered by default.

439 changes: 210 additions & 229 deletions examples/1_feature_overview.ipynb

Large diffs are not rendered by default.

46 changes: 26 additions & 20 deletions examples/2_introduction_to_sindy.ipynb

Large diffs are not rendered by default.

55 changes: 34 additions & 21 deletions examples/3_original_paper.ipynb

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions examples/4_scikit_learn_compatibility.ipynb
Expand Up @@ -74,13 +74,15 @@
"t_train = np.arange(0, 10, dt)\n",
"t_train_span = (t_train[0], t_train[-1])\n",
"x0_train = [-8, 8, 27]\n",
"x_train = solve_ivp(lorenz, t_train_span, x0_train, t_eval=t_train, **integrator_keywords).y.T\n",
"x_train = solve_ivp(lorenz, t_train_span, x0_train, \n",
" t_eval=t_train, **integrator_keywords).y.T\n",
"\n",
"# Evolve the Lorenz equations in time using a different initial condition\n",
"t_test = np.arange(0, 15, dt)\n",
"t_test_span = (t_test[0], t_test[-1])\n",
"x0_test = np.array([8, 7, 15])\n",
"x_test = solve_ivp(lorenz, t_test_span, x0_test, t_eval=t_test, **integrator_keywords).y.T"
"x_test = solve_ivp(lorenz, t_test_span, x0_test, \n",
" t_eval=t_test, **integrator_keywords).y.T"
]
},
{
Expand Down Expand Up @@ -117,10 +119,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Best parameters: {'differentiation_method__order': 2, 'feature_library': PolynomialLibrary(), 'optimizer__alpha': 0.01, 'optimizer__threshold': 0.01}\n",
"(x0)' = -9.999 x0 + 9.999 x1\n",
"(x1)' = 27.992 x0 + -0.999 x1 + -1.000 x0 x2\n",
"(x2)' = -2.666 x2 + 1.000 x0 x1\n"
"Best parameters: {'differentiation_method__order': 1, 'feature_library': PolynomialLibrary(), 'optimizer__alpha': 0.01, 'optimizer__threshold': 0.01}\n",
"(x0)' = -10.021 x0 + 9.993 x1\n",
"(x1)' = 0.227 1 + 27.601 x0 + -0.611 x1 + -0.983 x0 x2 + -0.020 x1 x2\n",
"(x2)' = 0.590 1 + 0.045 x0 + -0.018 x1 + -2.691 x2 + 0.965 x0 x1 + 0.026 x1^2\n"
]
}
],
Expand Down Expand Up @@ -344,7 +346,9 @@
"source": [
"from sklearn.linear_model import ElasticNet\n",
"\n",
"model = ps.SINDy(optimizer=ElasticNet(l1_ratio=0.9, fit_intercept=False), t_default=dt)\n",
"model = ps.SINDy(optimizer=ElasticNet(l1_ratio=0.9, \n",
" fit_intercept=False), \n",
" t_default=dt)\n",
"model.fit(x_train)\n",
"model.print()"
]
Expand Down Expand Up @@ -373,7 +377,8 @@
"from sklearn.linear_model import OrthogonalMatchingPursuit\n",
"\n",
"model = ps.SINDy(\n",
" optimizer=OrthogonalMatchingPursuit(n_nonzero_coefs=8, fit_intercept=False),\n",
" optimizer=OrthogonalMatchingPursuit(n_nonzero_coefs=8, \n",
" fit_intercept=False),\n",
" t_default=dt\n",
")\n",
"model.fit(x_train)\n",
Expand Down
142 changes: 123 additions & 19 deletions examples/5_differentiation.ipynb

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions examples/6_deeptime_compatibility.ipynb

Large diffs are not rendered by default.

160 changes: 83 additions & 77 deletions examples/7_plasma_examples.ipynb

Large diffs are not rendered by default.

361 changes: 200 additions & 161 deletions examples/8_trapping_sindy_paper_examples.ipynb

Large diffs are not rendered by default.

49 changes: 34 additions & 15 deletions examples/9_sindypi_with_sympy.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pysindy/__init__.py
Expand Up @@ -14,6 +14,7 @@
from .pysindy import SINDy
from .differentiation import BaseDifferentiation
from .differentiation import FiniteDifference
from .differentiation import SpectralDerivative
from .differentiation import SINDyDerivative
from .differentiation import SmoothedFiniteDifference
from .feature_library import ConcatLibrary
Expand All @@ -24,6 +25,7 @@
from .feature_library import IdentityLibrary
from .feature_library import PolynomialLibrary
from .feature_library import PDELibrary
from .feature_library import WeakPDELibrary
from .feature_library import SINDyPILibrary
from .optimizers import BaseOptimizer
from .optimizers import ConstrainedSR3
Expand Down
2 changes: 2 additions & 0 deletions pysindy/differentiation/__init__.py
Expand Up @@ -2,11 +2,13 @@
from .finite_difference import FiniteDifference
from .sindy_derivative import SINDyDerivative
from .smoothed_finite_difference import SmoothedFiniteDifference
from .spectral_derivative import SpectralDerivative


__all__ = [
"BaseDifferentiation",
"FiniteDifference",
"SINDyDerivative",
"SmoothedFiniteDifference",
"SpectralDerivative",
]

0 comments on commit 6d908c3

Please sign in to comment.