Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colab tutorials #367

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial1/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Physics Informed Neural Networks on PINA
==================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial1/tutorial.ipynb

In this tutorial, we will demonstrate a typical use case of **PINA** on
a toy problem, following the standard API procedure.

Expand Down Expand Up @@ -74,6 +79,15 @@ What if our equation is also time-dependent? In this case, our ``class``
will inherit from both ``SpatialProblem`` and ``TimeDependentProblem``:

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

from pina.problem import SpatialProblem, TimeDependentProblem
from pina.geometry import CartesianDomain
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial10/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Averaging Neural Operator for solving Kuramoto Sivashinsky equation
=============================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial10/tutorial.ipynb

In this tutorial we will build a Neural Operator using the
``AveragingNeuralOperator`` model and the ``SupervisedSolver``. At the
end of the tutorial you will be able to train a Neural Operator for
Expand All @@ -11,6 +16,15 @@ operations.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import torch
import matplotlib.pyplot as plt
from scipy import io
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial11/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: PINA and PyTorch Lightning, training tips and visualizations
======================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial11/tutorial.ipynb

In this tutorial, we will delve deeper into the functionality of the
``Trainer`` class, which serves as the cornerstone for training **PINA**
`Solvers <https://mathlab.github.io/PINA/_rst/_code.html#solvers>`__.
Expand All @@ -18,6 +23,15 @@ problem and the ``PINN`` solver.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import torch

from pina import Condition, Trainer
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial12/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: The ``Equation`` Class
================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial12/tutorial.ipynb

In this tutorial, we will show how to use the ``Equation`` Class in
PINA. Specifically, we will see how use the Class and its inherited
classes to enforce residuals minimization in PINNs.
Expand Down Expand Up @@ -30,6 +35,15 @@ class.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

#useful imports
from pina.problem import SpatialProblem, TimeDependentProblem
from pina.equation import Equation, FixedValue, FixedGradient, FixedFlux
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial13/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Multiscale PDE learning with Fourier Feature Network
==============================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial13/tutorial.ipynb

This tutorial presents how to solve with Physics-Informed Neural
Networks (PINNs) a PDE characterized by multiscale behaviour, as
presented in `On the eigenvector bias of Fourier feature networks: From
Expand All @@ -11,6 +16,15 @@ First of all, some useful imports.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import torch

from pina import Condition, Plotter, Trainer, Plotter
Expand Down
15 changes: 15 additions & 0 deletions docs/source/_rst/tutorials/tutorial2/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Tutorial: Two dimensional Poisson problem using Extra Features Learning
=======================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial2/tutorial.ipynb


This tutorial presents how to solve with Physics-Informed Neural
Networks (PINNs) a 2D Poisson problem with Dirichlet boundary
conditions. We will train with standard PINN’s training, and with
Expand All @@ -13,6 +19,15 @@ First of all, some useful imports.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import torch
from torch.nn import Softplus

Expand Down
15 changes: 15 additions & 0 deletions docs/source/_rst/tutorials/tutorial3/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Tutorial: Two dimensional Wave problem with hard constraint
===========================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial3/tutorial.ipynb


In this tutorial we present how to solve the wave equation using hard
constraint PINNs. For doing so we will build a costum ``torch`` model
and pass it to the ``PINN`` solver.
Expand All @@ -9,6 +15,15 @@ First of all, some useful imports.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import torch

from pina.problem import SpatialProblem, TimeDependentProblem
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial4/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Unstructured convolutional autoencoder via continuous convolution
===========================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial4/tutorial.ipynb

In this tutorial, we will show how to use the Continuous Convolutional
Filter, and how to build common Deep Learning architectures with it. The
implementation of the filter follows the original work `A Continuous
Expand All @@ -11,6 +16,15 @@ First of all we import the modules needed for the tutorial:

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import torch
import matplotlib.pyplot as plt
from pina.problem import AbstractProblem
Expand Down
15 changes: 15 additions & 0 deletions docs/source/_rst/tutorials/tutorial5/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Two dimensional Darcy flow using the Fourier Neural Operator
======================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial5/tutorial.ipynb

In this tutorial we are going to solve the Darcy flow problem in two
dimensions, presented in `Fourier Neural Operator for Parametric Partial
Differential Equation <https://openreview.net/pdf?id=c8P9NQVtmnO>`__.
Expand All @@ -9,6 +14,16 @@ First of all we import the modules needed for the tutorial. Importing

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"
!pip install scipy

# !pip install scipy # install scipy
from scipy import io
import torch
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial6/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Building custom geometries with PINA ``Location`` class
=================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial6/tutorial.ipynb

In this tutorial we will show how to use geometries in PINA.
Specifically, the tutorial will include how to create geometries and how
to visualize them. The topics covered are:
Expand All @@ -13,6 +18,15 @@ We import the relevant modules first.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import matplotlib.pyplot as plt
from pina.geometry import EllipsoidDomain, Difference, CartesianDomain, Union, SimplexDomain
from pina.label_tensor import LabelTensor
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial7/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Resolution of an inverse problem
============================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial7/tutorial.ipynb

Introduction to the inverse problem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -33,6 +38,15 @@ In order to achieve both the goals we will need to define an

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import matplotlib.pyplot as plt
import torch
from pytorch_lightning.callbacks import Callback
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial8/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: Reduced order model (POD-RBF or POD-NN) for parametric problems
=========================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial8/tutorial.ipynb

The tutorial aims to show how to employ the **PINA** library in order to
apply a reduced order modeling technique [1]. Such methodologies have
several similarities with machine learning approaches, since the main
Expand Down Expand Up @@ -31,6 +36,15 @@ minimum PINA version to run this tutorial is the ``0.1``.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

%matplotlib inline

import matplotlib.pyplot as plt
Expand Down
14 changes: 14 additions & 0 deletions docs/source/_rst/tutorials/tutorial9/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Tutorial: One dimensional Helmotz equation using Periodic Boundary Conditions
=============================================================================

|Open In Colab|

.. |Open In Colab| image:: https://colab.research.google.com/assets/colab-badge.svg
:target: https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial9/tutorial.ipynb

This tutorial presents how to solve with Physics-Informed Neural
Networks (PINNs) a one dimensional Helmotz equation with periodic
boundary conditions (PBC). We will train with standard PINN’s training
Expand All @@ -12,6 +17,15 @@ First of all, some useful imports.

.. code:: ipython3

## routine needed to run the notebook on Google Colab
try:
import google.colab
IN_COLAB = True
except:
IN_COLAB = False
if IN_COLAB:
!pip install "pina-mathlab"

import torch
import matplotlib.pyplot as plt

Expand Down
13 changes: 12 additions & 1 deletion tutorials/tutorial1/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"id": "6f71ca5c",
"metadata": {},
"source": [
"# Tutorial: Physics Informed Neural Networks on PINA"
"# Tutorial: Physics Informed Neural Networks on PINA\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial1/tutorial.ipynb)\n"
]
},
{
Expand Down Expand Up @@ -83,6 +85,15 @@
"metadata": {},
"outputs": [],
"source": [
"## routine needed to run the notebook on Google Colab\n",
"try:\n",
" import google.colab\n",
" IN_COLAB = True\n",
"except:\n",
" IN_COLAB = False\n",
"if IN_COLAB:\n",
" !pip install \"pina-mathlab\"\n",
"\n",
"from pina.problem import SpatialProblem, TimeDependentProblem\n",
"from pina.geometry import CartesianDomain\n",
"\n",
Expand Down
Loading
Loading