Automatize Tutorials html, py files creation (#496)
* workflow to export tutorials ---------
This commit is contained in:
committed by
Nicola Demo
parent
aea24d0bee
commit
0146155c9b
32
tutorials/tutorial12/tutorial.ipynb
vendored
32
tutorials/tutorial12/tutorial.ipynb
vendored
@@ -53,16 +53,17 @@
|
||||
"source": [
|
||||
"## routine needed to run the notebook on Google Colab\n",
|
||||
"try:\n",
|
||||
" import google.colab\n",
|
||||
" IN_COLAB = True\n",
|
||||
" import google.colab\n",
|
||||
"\n",
|
||||
" IN_COLAB = True\n",
|
||||
"except:\n",
|
||||
" IN_COLAB = False\n",
|
||||
" IN_COLAB = False\n",
|
||||
"if IN_COLAB:\n",
|
||||
" !pip install \"pina-mathlab\"\n",
|
||||
" !pip install \"pina-mathlab\"\n",
|
||||
"\n",
|
||||
"import torch\n",
|
||||
"\n",
|
||||
"#useful imports\n",
|
||||
"# useful imports\n",
|
||||
"from pina import Condition\n",
|
||||
"from pina.problem import SpatialProblem, TimeDependentProblem\n",
|
||||
"from pina.equation import Equation, FixedValue\n",
|
||||
@@ -166,22 +167,23 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Burgers1DEquation(Equation):\n",
|
||||
" \n",
|
||||
" def __init__(self, nu = 0.):\n",
|
||||
"\n",
|
||||
" def __init__(self, nu=0.0):\n",
|
||||
" \"\"\"\n",
|
||||
" Burgers1D class. This class can be\n",
|
||||
" used to enforce the solution u to solve the viscous Burgers 1D Equation.\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" :param torch.float32 nu: the viscosity coefficient. Default value is set to 0.\n",
|
||||
" \"\"\"\n",
|
||||
" self.nu = nu \n",
|
||||
" \n",
|
||||
" def equation(input_, output_):\n",
|
||||
" return grad(output_, input_, d='t') +\\\n",
|
||||
" output_*grad(output_, input_, d='x') -\\\n",
|
||||
" self.nu*laplacian(output_, input_, d='x')\n",
|
||||
" self.nu = nu\n",
|
||||
"\n",
|
||||
" def equation(input_, output_):\n",
|
||||
" return (\n",
|
||||
" grad(output_, input_, d=\"t\")\n",
|
||||
" + output_ * grad(output_, input_, d=\"x\")\n",
|
||||
" - self.nu * laplacian(output_, input_, d=\"x\")\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" super().__init__(equation)"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user