Skip to content

Commit

Permalink
Put jupyter notebook into documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Mueller <[email protected]>
  • Loading branch information
johannes-mueller committed Jan 9, 2024
1 parent 40f2a07 commit 4b80d24
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
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

0 comments on commit 4b80d24

Please sign in to comment.