Skip to main content

arXiv DOI Documentation Status MIT License

ApHIN - Autoencoder-based port-Hamiltonian Identification Networks

A data-driven framework for the identification of latent port-Hamiltonian systems [1].

ApHIN

Reference

The preprint is available on arXiv. If you use this project for academic work, please consider citing it

Johannes Rettberg, Jonas Kneifl, Julius Herb, Patrick Buchfink, Jörg Fehr, and Bernard Haasdonk. 
Data-driven identification of latent port-Hamiltonian systems. Arxiv, 2024.

Abstract

Conventional physics-based modeling techniques involve high effort, e.g.~time and expert knowledge, while data-driven methods often lack interpretability, structure, and sometimes reliability. To mitigate this, we present a data-driven system identification framework that derives models in the port-Hamiltonian (pH) formulation. This formulation is suitable for multi-physical systems while guaranteeing the useful system theoretical properties of passivity and stability.

Our framework combines linear and nonlinear reduction with structured, physics-motivated system identification. In this process, high-dimensional state data obtained from possibly nonlinear systems serves as the input for an autoencoder, which then performs two tasks: (i) nonlinearly transforming and (ii) reducing this data onto a low-dimensional manifold. In the resulting latent space, a pH system is identified by considering the unknown matrix entries as weights of a neural network. The matrices strongly satisfy the pH matrix properties through Cholesky factorizations. In a joint optimization process over the loss term, the pH matrices are adjusted to match the dynamics observed by the data, while defining a linear pH system in the latent space per construction. The learned, low-dimensional pH system can describe even nonlinear systems and is rapidly computable due to its small size.

The method is exemplified by a parametric mass-spring-damper and a nonlinear pendulum example as well as the high-dimensional model of a disc brake with linear thermoelastic behavior.

Features

This repository implements neural networks that identify linear port-Hamiltonian systems from (potentially high-dimensional) data[1].

  • Autoencoders (AEs) for dimensionality reduction
  • pH layer to identify system matrices that fulfill the definition of a linear pH system
  • Joint training of AE and pH layer to identify a latent pH system
  • Parametric extension using hypernetworks to identify parametric pH systems

The main functionalities are:

  • pHIN: identify a (parametric) low-dimensional port-Hamiltonian system directly
  • ApHIN: identify a (parametric) low-dimensional latent port-Hamiltonian system based on coordinate representations found using an autoencoder
  • Examples for the identification of linear pH systems from data
    • One-dimensional mass-spring-damper chain
    • Pendulum
    • discbrake model

Installation

You can either clone the repository and install the package locally or install it directly from PyPI.

PyPI

pip install aphin

Local

Clone this repository and install it to your local environment as package using pip:

git clone https://github.com/Institute-Eng-and-Comp-Mechanics-UStgt/ApHIN.git
cd ApHIN

Then you can activate the environment in which you want to install the package, and use pip to perform the installation.

pip install -e .

:warning: Please note that you need pip version 24.0 to install the repository in editable mode. Either upgrade pip to the latest version or install it without the -e argument

Docker

You can use docker and docker compose to run the ApHIN package with all dependencies in a containerized environment.

Build image:

docker build -t aphin .

Run container without GUI support:

docker run -it aphin

Run container with GUI support (assuming that the host OS is Linux):

xhost +local:root
docker run -it --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" aphin
xhost -local:root

See https://wiki.ros.org/docker/Tutorials/GUI for alternative solutions. Similar solutions are available for Windows or macOS as host OS.

Alternatively, start the container using docker compose:

xhost +local:root
docker compose run aphin
xhost -local:root

Terminate the container with exit.

Running the Experiments

Quick Start - Run All Experiments

To run all experiments and generate the paper figures:

python examples/main_script.py

Individual Experiments

Mass-Spring-Damper (MSD) System

This experiment demonstrates pHIN on a low-dimensinoal parametric mass-spring-damper chain.

  1. Data Generation:

    python examples/mass_spring_damper/data_generation/mass_spring_damper_data_generation.py
    

    Configuration: examples/mass_spring_damper/data_generation/config_data_gen.yml

  2. Model Training:

    python examples/mass_spring_damper/mass_spring_damper.py
    

    Configuration: examples/mass_spring_damper/config.yml

Pendulum System

This experiment shows the application of ApHIN to a nonlinear pendulum system.

  1. Data Generation:

    python examples/pendulum/pendulum_data_generation.py
    
  2. Model Training:

    python examples/pendulum/pendulum.py
    

    Configuration: examples/pendulum/config.yml

Disc Brake with Hole

This experiment demonstrates ApHIN on a high-dimensional disc brake model with thermoelastic behavior.

python examples/disc_brake_with_hole.py

Configuration: examples/disc_brake_with_hole/config.yml

:information_source: Note: This experiment includes automated data download, so no separate data generation step is required.

Configuration Files

Each experiment uses YAML configuration files to set hyperparameters, training settings, and system parameters. You can modify these configuration files to:

  • Adjust network architectures
  • Change training parameters (learning rate, epochs, batch size)
  • Modify system parameters for the physical models
  • Set data generation parameters

When running the main script, all figures from the corresponding paper will be recreated.

References

[1] Johannes Rettberg, Jonas Kneifl, Julius Herb, Patrick Buchfink, Jörg Fehr, and Bernard Haasdonk. Data-driven identification of latent port-Hamiltonian systems. Arxiv, 2024.

[2] Volker Mehrmann and Benjamin Unger. Control of port-Hamiltonian differential-algebraic systems and applications, 2022.

[3] Kathleen Champion, Bethany Lusch, J. Nathan Kutz, and Steven L. Brunton. Data-driven discovery of coordinates and governing equations. Proceedings of the National Academy of Sciences, 116(45):22445–22451, 2019.

Metadata

Release files for aphin 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aphin 1.1
File Size Uploaded
aphin-1.1.tar.gz 117.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aphin 1.1
File Interpreter ABI Platform
aphin-1.1-py3-none-any.whl Python 3 none any Details

Total release size: 250.1 kB

Release files / aphin-1.1.tar.gz

Download URL aphin-1.1.tar.gz
Size 117.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e69699d6f557178569b54399c9b85d6306c20460d0742c22f8fe6dcac5538b68
BLAKE2b-256 checksum
How to use checksums
4ff10a38254b687e14073183894f3506275be6e0a59d70ca1cf6e8855d76242d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release files / aphin-1.1-py3-none-any.whl

Download URL aphin-1.1-py3-none-any.whl
Size 132.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c801c74938dd4478101ef4f026fee9176ba04df2e03cd23383ff1e4d4b014511
BLAKE2b-256 checksum
How to use checksums
7a30bf9f9cb2be93306ac38fa5fa60981953721b8571852c36c05fc9d071da9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0.1

2 release files

1.0

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page