Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas-Nicodemus committed Apr 27, 2022
0 parents commit a955d8c
Show file tree
Hide file tree
Showing 39 changed files with 2,602 additions and 0 deletions.
436 changes: 436 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Jonas Nicodemus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!-- PROJECT SHIELDS -->
<!-- [![arXiv][arxiv-shield]][arxiv-url] -->
<!-- [![DOI][doi-shield]][doi-url] -->
<!-- [![MIT License][license-shield]][license-url] -->
<!-- [![LinkedIn][linkedin-shield]][linkedin-url] -->

# Port-Hamiltonian Dynamic Mode Decomposition

We present a novel physics-informed system identification method to construct a passive linear time-invariant system. In more detail, for a given quadratic energy functional, measurements of the input, state, and output of a system in the time domain, we find a realization that approximates the data well while guaranteeing that the energy functional satisfies a dissipation inequality. To this end, we use the framework of port-Hamiltonian (pH) systems and modify the dynamic mode decomposition to be feasible for continuous-time pH systems. We propose an iterative numerical method to solve the corresponding least-squares minimization problem. We construct an effective initialization of the algorithm by studying the least-squares problem in a weighted norm, for which we present the analytical minimum-norm solution. The efficiency of the proposed method is demonstrated with several numerical examples.

<!-- TABLE OF CONTENTS -->
<details open="open">
<summary><h2 style="display: inline-block">Table of Contents</h2></summary>
<ol>
<li>
<a href="#citing">Citing</a>
</li>
<li>
<a href="#installation">Installation</a>
</li>
<li><a href="#usage">Usage</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
</ol>
</details>

<!-- ## Citing
If you use this project for academic work, please consider citing our
[publication][arxiv-url]:
R. Morandin, J. Nicodemus, and B. Unger
Port-Hamiltonian Dynamic Mode Decomposition
ArXiv e-print TODO, 2022. -->

## Installation
A python environment is required with at least **Python 3.10**.

Install dependencies via `pip`:
```sh
pip install -r requirements.txt
```

<!-- USAGE EXAMPLES -->
## Usage

The executable script `main.py` executes the `pHDMD` algorithm for the current configuration, defined in `config.py`. Both files are located in `src`.

<!-- USAGE EXAMPLES -->
## Documentation

Documentation is available [online][docs-url]
or you can build it yourself from inside the `docs` directory
by executing:

make html

This will generate HTML documentation in `docs/build/html`.
It is required to have the `sphinx` dependencies installed. This can be done by

pip install -r requirements.txt

within the `docs` directory.


<!-- LICENSE -->
## License

Distributed under the MIT License. See `LICENSE` for more information.

<!-- CONTACT -->
## Contact
Jonas Nicodemus - [email protected]

Benjamin Unger - [email protected]\
Riccardo Morandin - [email protected]

Project Link: [https://github.com/Jonas-Nicodemus/phdmd][project-url]

[license-shield]: https://img.shields.io/github/license/Jonas-Nicodemus/phdmd.svg?style=for-the-badge
[license-url]: https://github.com/Jonas-Nicodemus/phdmd/blob/main/LICENSE
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/jonas-nicodemus-a34931209/
[doi-shield]: https://img.shields.io/badge/DOI-10.5281%20%2F%20zenodo.5520662-blue.svg?style=for-the-badge
[doi-url]: https://zenodo.org/badge/latestdoi/409099116
[arxiv-shield]: https://img.shields.io/badge/arXiv-2109.10793-b31b1b.svg?style=for-the-badge
[arxiv-url]: https://arxiv.org/abs/2109.10793
[project-url]:https://github.com/Jonas-Nicodemus/phdmd
[docs-url]:https://jonas-nicodemus.github.io/phdmd/
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Sphinx>=4.5.0
sphinx-rtd-theme>=1.0.0
sphinxcontrib-bibtex>=2.4.2
sphinxcontrib-katex>=0.8.6
37 changes: 37 additions & 0 deletions docs/source/algorithm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
algorithm package
=================

Submodules
----------

algorithm.phdmd module
----------------------

.. automodule:: algorithm.phdmd
:members:
:undoc-members:
:show-inheritance:

algorithm.skew\_procrustes module
---------------------------------

.. automodule:: algorithm.skew_procrustes
:members:
:undoc-members:
:show-inheritance:

algorithm.spsd\_procrustes module
---------------------------------

.. automodule:: algorithm.spsd_procrustes
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: algorithm
:members:
:undoc-members:
:show-inheritance:
8 changes: 8 additions & 0 deletions docs/source/bibliography.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
************
Bibliography
************

..
see https://sphinxcontrib-bibtex.readthedocs.io/en/latest/usage.html for options
.. bibliography::
130 changes: 130 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../../src'))


# -- Project information -----------------------------------------------------

project = 'pHDMD'
copyright = '2022, Jonas Nicodemus'
author = 'Jonas Nicodemus'

# The full version, including alpha/beta/rc tags
release = '1.0.0'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinxcontrib.katex',
'sphinxcontrib.bibtex',
]

import sphinxcontrib.katex as katex

latex_macros = r"""
\def \i {\mathrm{i}}
\def \e #1{\mathrm{e}^{#1}}
\def \vec #1{\mathbf{#1}}
\def \x {\vec{x}}
\def \d {\operatorname{d}\!}
\def \dirac #1{\operatorname{\delta}\left(#1\right)}
\def \scalarprod #1#2{\left\langle#1,#2\right\rangle}
\def \timeStep {\delta_t}
\def \nrSnapshots {M}
\def \nrSnapshotsGen {\tilde{\nrSnapshots}}
\def \state {x}
\def \stateVar {\state}
\def \stateDim {n}
\def \stateDimRed {r}
\def \inpVar {u}
\def \inputVar {\inpVar}
\def \inpVarDim {m}
\def \inputDim {\inpVarDim}
\def \outVar {y}
\def \outputVar {\outVar}
\def \dmdV {X_+}
\def \dmdW {X_{-}}
\def \dmdY {Y}
\def \dmdU {U}
\def \dataZ {\mathcal{Z}}
\def \dataT {\mathcal{T}}
\def \dmdJJ {\widetilde{\mathcal{J}}}
\def \dmdRR {\widetilde{\mathcal{R}}}
"""

# Translate LaTeX macros to KaTeX and add to options for HTML builder
katex_macros = katex.latex_defs_to_katex_macros(latex_macros)
katex_options = 'macros: {' + katex_macros + '}'

# Add LaTeX macros for LATEX builder
latex_elements = {'preamble': latex_macros}

bibtex_bibfiles = ['refs.bib']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# # Material theme options (see theme.conf for more information)
# html_theme_options = {
#
# # Set the name of the project to appear in the navigation.
# 'nav_title': 'pHDMD',
#
# # Set you GA account ID to enable tracking
# 'google_analytics_account': 'UA-XXXXX',
#
# # Specify a base_url used to generate sitemap.xml. If not
# # specified, then no sitemap will be built.
# 'base_url': 'https://project.github.io/project',
#
# # Set the color and the accent color
# 'color_primary': 'blue',
# 'color_accent': 'light-blue',
#
# # Set the repo location to get a badge with stats
# # TODO: change when release
# 'repo_url': 'https://github.com/Jonas-Nicodemus/crispy-pancake',
# 'repo_name': 'crispy-pancake',
#
# # Visible levels of the global TOC; -1 means unlimited
# 'globaltoc_depth': 3,
# # If False, expand all TOC entries
# 'globaltoc_collapse': False,
# # If True, show hidden TOC entries
# 'globaltoc_includehidden': False,
# }

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
10 changes: 10 additions & 0 deletions docs/source/contact.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Contact
=======

Jonas Nicodemus - [email protected]

Benjamin Unger - [email protected]

Riccardo Morandin - [email protected]

Project link: https://github.com/Jonas-Nicodemus/phdmd
Loading

0 comments on commit a955d8c

Please sign in to comment.