Skip to content

Commit

Permalink
Merge branch 'boschresearch:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
TomF98 authored Jan 31, 2024
2 parents 8a90383 + bc71747 commit 750e06b
Show file tree
Hide file tree
Showing 26 changed files with 380 additions and 224 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docs-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: documentation

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false


jobs:
build-docs:
runs-on: [ubuntu-latest]
container: python:3.10-bookworm
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
apt-get update
apt-get -y install xvfb pandoc
python -m pip install --upgrade pip setuptools setuptools_scm wheel
pip install -e .[docs]
pip install -r docs/requirements.txt
- name: Build documentation
run: |
sphinx-build -b html docs/ _site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy-docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
if: github.ref_name == 'main'
needs: build-docs
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
80 changes: 80 additions & 0 deletions .github/workflows/pypi-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build and upload to PyPI

on:
release:
type: [published]

env:
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-*
CIBW_BEFORE_BUILD: pip install cython
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014

jobs:
build_wheels:
name: Build wheels on [ ubuntu-latest ]
runs-on: [ ubuntu-latest ]
strategy:
matrix:
os: [ubuntu-latest] #, windows-latest]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.10'

- name: Install cibuildwheel
run: |
# python -m pip install cibuildwheel
pip install -U setuptools setuptools_scm wheel
- name: Build wheels
run: |
# python -m cibuildwheel --output-dir wheelhouse
python setup.py bdist_wheel
- uses: actions/upload-artifact@v2
with:
path: ./dist/*.whl


build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.10'

- name: Install setuptools
run: |
pip install -U setuptools setuptools_scm wheel
- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.upload_pypi }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: Unit tests

on:
push:
branches: '**'
branches: [ main ]
pull_request:
branches: [ main ]

Expand All @@ -16,17 +16,18 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools setuptools_scm wheel
python -m pip install flake8 pytest pytest-cov
python -m pip install -e .
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ Version 1.0.1
=============
- Updated documentation and error messages
- Simplyfied creation/definition of DeepONets
- Add more evalution types for the DeepONet
- Add more evalution types for the DeepONet

Version 1.0.2
=============
- Test for python versions up to 3.10
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
"sphinx.ext.ifconfig",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"nbsphinx",
"nbsphinx_link",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
9 changes: 8 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ trimesh>=3.9.19
shapely>=1.7.1
rtree>=0.9.7
scipy>=1.6.3
networkx>=2.5.1
networkx>=2.5.1
jupyter
nbsphinx
nbsphinx-link
sphinx_rtd_theme>=1.0
ipywidgets
ipython<8.17.0 # https://github.com/ipython/ipython/issues/14235
ipykernel
3 changes: 3 additions & 0 deletions docs/tutorial/Introduction_Tutorial_PINNs.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../examples/tutorial/Introduction_Tutorial_PINNs.ipynb"
}
41 changes: 18 additions & 23 deletions docs/tutorial/main_page.rst
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
=========================
The TorchPhysics Tutorial
=========================
Here one can find all important information and knowledge to get started with the
Here one can find all important information and knowledge to get started with the
software library TorchPhysics.

In order to make it as easy and user-friendly as possible for all users,
In order to make it as easy and user-friendly as possible for all users,
both complete novices and professionals in Machine Learning and PDEs, to get started, the tutorial
starts with some basics regarding differential equations and neural networks. For more
experienced users, these points can be skipped.

Afterward, we give a rough overview of different Deep Learning approaches for solving
Afterward, we give a rough overview of different Deep Learning approaches for solving
differential equations, with a focus on PINNs and DeepONet.

The main and final topic is the use of TorchPhysics. Here we split the tutorial into two parts.
The first part, guides you along some implementations of different small examples, while showing
The first part, guides you along some implementations of different small examples, while showing
all the important aspects and steps to solve a differential equation in TorchPhysics. This tutorial
series is aimed at an audience which is more interested on the direct utilization of the library
series is aimed at an audience which is more interested on the direct utilization of the library
and for getting a fast and small overview of the possibilities.

To get a deeper understanding of the library, we show in the second part how the library is
To get a deeper understanding of the library, we show in the second part how the library is
internally structured. This series is more aimed for users who plan to add or change functionalities.


Basics of Deep Learning and Differential Equations
=====================================================
Will be added in the future.
.. toctree::
:maxdepth: 1
:caption: Basics tutorial

Introduction_Tutorial_PINNs

Overview of Deep Learning Methods for Differential Equations
============================================================
Will be added in the future.

.. toctree::
:maxdepth: 1
:caption: Applied tutorial

Usage of TorchPhysics
=====================
Like mentioned at the beginning, here we explain the aspects of TorchPhysics in more
detail. We split the tutorial into two categories:
applied_tutorial_start

1) A more applied tutorial to learn TorchPhysics by implementing some examples.
All basics features will be explained. The start can be found here_.

2) A more in depth tutorial that focuses more on the library architecture. This
tutorial begins on this page_.
.. toctree::
:maxdepth: 1
:caption: In depth tutorial


.. _here : applied_tutorial_start.html
.. _page : tutorial_start.html
tutorial_start
24 changes: 13 additions & 11 deletions examples/tutorial/Introduction_Tutorial_PINNs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"id": "8da6279e-83c2-41ed-a56b-453b21f05d11",
"metadata": {},
"source": [
"# Recall PINNs\n",
"## Recall PINNs\n",
"The goal is to find a neural network $u_\\theta: \\overline{\\Omega\\times I} \\to \\mathbb{R}$, which approximately satisfies all four conditions of the PDE problem above, where $\\theta$ are the trainable parameters of the neural network.\n",
"Let us shortly recall the main idea behind PINNs.\n",
"\n",
Expand Down Expand Up @@ -105,7 +105,7 @@
"id": "8f0db4a0-cace-4d21-845f-f34680880d7d",
"metadata": {},
"source": [
"# Translating the PDE Problem into the Language of TorchPhysics\n",
"## Translating the PDE Problem into the Language of TorchPhysics\n",
"Translating the PDE problem into the framework of TorchPhysics works in a convenient and intuitive way, as the notation is close to the mathematical formulation. The general procedure can be devided into five steps. Also when solving other problems with TorchPhysics, such as parameter identification or variational problems, the same steps can be applied, see also the further [tutorials](https://torchphysics.readthedocs.io/en/latest/tutorial/tutorial_start.html) or [examples](https://torchphysics.readthedocs.io/en/latest/examples.html)."
]
},
Expand Down Expand Up @@ -529,7 +529,7 @@
"id": "31d80c43-5879-401c-8212-0e4a5fd6514c",
"metadata": {},
"source": [
"# Training based on Pytorch Lightning \n",
"## Training based on Pytorch Lightning \n",
"In order to train a model, TorchPhysics makes use of the Pytorch Lightning library, which hence must be imported. Further, we import \"os\" so that GPUs can be used for the calculations."
]
},
Expand Down Expand Up @@ -622,11 +622,13 @@
"outputs": [],
"source": [
"# Start the training\n",
"trainer = pl.Trainer(gpus=device, # or None if CPU is used\n",
" max_steps=5000, # number of training steps\n",
" logger=False,\n",
" benchmark=True,\n",
" checkpoint_callback=False)\n",
"trainer = pl.Trainer(\n",
" gpus=device, # or None if CPU is used\n",
" max_steps=5000, # number of training steps\n",
" logger=False,\n",
" benchmark=True,\n",
" # checkpoint_callback=False # Uncomment this for more verbose\n",
")\n",
"\n",
"trainer.fit(solver) # start training"
]
Expand All @@ -648,7 +650,7 @@
"id": "bac7c186-2be3-4ce0-a252-527ae5083019",
"metadata": {},
"source": [
"# Visualization\n",
"## Visualization\n",
"Torchphysics provides built-in functionalities for visualizing the outcome of the neural network.\n",
"As a first step, for the 2D heat equation example one might be interested in creating a contour plot for the heat distribution inside of the room at some fixed time.\n",
"\n",
Expand Down Expand Up @@ -862,7 +864,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -876,7 +878,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5", "wheel"]
build-backend = "setuptools.build_meta"

#[tool.setuptools_scm]
[tool.setuptools_scm]
# See configuration details in https://github.com/pypa/setuptools_scm
#version_scheme = "no-guess-dev"
version_scheme = "no-guess-dev"
7 changes: 3 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
name = torchphysics
description = PyTorch implementation of Deep Learning methods to solve differential equations
author = Nick Heilenkötter, Tom Freudenberg
version = 1.0.1
author_email = [email protected], [email protected]
license = Apache-2.0
long_description = file: README.rst
Expand Down Expand Up @@ -65,11 +64,11 @@ exclude =
[options.extras_require]
# Add here additional requirements for extra features, to install with:
# `pip install torchphysics[all]` like:
all =
all =
trimesh>=3.9.19
shapely>=1.7.1
rtree>=0.9.7
networkx>=2.5.1
networkx>=2.5.1

# Add here test requirements (semicolon/line-separated)
testing =
Expand Down Expand Up @@ -135,4 +134,4 @@ exclude =
# This will be used when updating. Do not change!
version = 4.0.1
package = torchphysics
extensions =
extensions =
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

if __name__ == "__main__":
try:
setup(use_scm_version=False) #use_scm_version={"version_scheme": "no-guess-dev"}
setup(use_scm_version={"version_scheme": "no-guess-dev"})
except: # noqa
print(
"\n\nAn error occurred while building the project, "
Expand Down
Loading

0 comments on commit 750e06b

Please sign in to comment.