ClaireGyn / torchphysics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


TorchPhysics is a Python library of deep learning methods for solving differential equations. You can use TorchPhysics to:

  • solve ordinary and partial differential equations via physics-informed neural networks (PINN) [1] or the Deep Ritz method [2]
  • train a neural network to approximate solutions for different parameters
  • solve inverse problems and interpolate external data via the above methods

TorchPhysics is build upon the machine learning library PyTorch.


The Goal of this library is to create a basic framework that can be used in many different applications and with different deep learning methods. To this end, TorchPhysics aims at a:

  • modular and expandable structure
  • easy to understand code and clean documentation
  • intuitive and compact way to transfer the mathematical problem into code
  • reliable and well tested code basis

Some build in features are:

  • mesh free domain generation. With pre implemented domain types: Point, Interval, Parallelogram, Circle, Triangle and Sphere
  • loading external created objects, thanks to a soft dependency on Trimesh and Shapely
  • creating complex domains with the boolean operators Union, Cut and Intersection and higher dimensional objects over the Cartesian product
  • allowing interdependence of different domains, e.g. creating moving domains
  • different point sampling methods for every domain: RandomUniform, Grid, Gaussian, Latin hypercube, Adaptive and some more for specific domains
  • different operators to easily define a differential equation
  • pre implemented fully connected neural network and easy implementation of additional model structures
  • sequentially or parallel evaluation/training of different neural networks
  • normalization layers and adaptive weights [3] to speed up the training process
  • powerful and versatile training thanks to PyTorch Lightning
    • many options for optimizers and learning rate control
    • monitoring the loss of individual conditions while training

Getting Started

To learn the functionality and usage of TorchPhysics we recommend to have a look at the following sections:


TorchPhysics can be installed by using:

pip install git+

If you want to change or add something to the code. You should first copy the repository and install it locally:

git clone
pip install .


TorchPhysics was originally developed by Nick Heilenkötter and Tom Freudenberg, as part of a seminar project at the University of Bremen, in cooperation with the Robert Bosch GmbH. Special thanks belong to Felix Hildebrand, Uwe Iben, Daniel Christopher Kreuter and Johannes Mueller, at the Robert Bosch GmbH, for support and supervision while creating this library.


TorchPhysics uses a Apache License, see the LICENSE file.


[1]Raissi, Perdikaris und Karniadakis, “Physics-informed neuralnetworks: A deep learning framework for solving forward and inverseproblems involving nonlinear partial differential equations”, 2019.
[2]E and Yu, "The Deep Ritz method: A deep learning-based numerical algorithm for solving variational problems", 2017
[3]McClenny und Braga-Neto, “Self-Adaptive Physics-Informed NeuralNetworks using a Soft Attention Mechanism”, 2020


License:Apache License 2.0


Language:Jupyter Notebook 72.9%Language:Python 27.0%Language:Shell 0.0%Language:Batchfile 0.0%