From: Alexander Grayver Date: Mon, 30 Mar 2020 12:23:38 +0000 (+0200) Subject: Mention notebook in the original program X-Git-Tag: v9.2.0-rc1~271^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d99dbb35f5f3160a7072f2168809041767bd5068;p=dealii.git Mention notebook in the original program --- diff --git a/contrib/python-bindings/notebooks/index.ipynb b/contrib/python-bindings/notebooks/index.ipynb index 25d69b68c5..c53164e004 100644 --- a/contrib/python-bindings/notebooks/index.ipynb +++ b/contrib/python-bindings/notebooks/index.ipynb @@ -20,13 +20,6 @@ "[step-62](https://github.com/dealii/dealii/tree/master/examples/step-62/step-62.ipynb) shows how to calculate the [energy band gap](https://en.wikipedia.org/wiki/Band_gap) and the\n", "mechanical resonance of a [micropillar superlattice cavity](https://doi.org/10.1103/PhysRevA.94.033813).\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples/step-53/doc/intro.dox b/examples/step-53/doc/intro.dox index c630d2f755..780d12ec6e 100644 --- a/examples/step-53/doc/intro.dox +++ b/examples/step-53/doc/intro.dox @@ -8,6 +8,12 @@ implement it. These classes are grouped into the documentation module on @ref manifold "Manifold description for triangulations". See there for additional information. +@note This tutorial is also available as a Jupyter Python notebook that + uses the deal.II python interface. The notebook is available in the + same directory as the original C++ program. Rendered notebook can also + be viewed on the github. +

Introduction

diff --git a/examples/step-53/step-53.ipynb b/examples/step-53/step-53.ipynb index 2979b5e765..8adc3128ae 100644 --- a/examples/step-53/step-53.ipynb +++ b/examples/step-53/step-53.ipynb @@ -29,7 +29,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Provided the deal.II was compiled with the python wrappers, we can import the module **PyDealII**. Note that it is only a shell and importing it will only allow you to call\n", + "Provided the deal.II library was compiled with the python wrappers, we can import the module **PyDealII**. Note that it is only a shell and importing it will only allow you to call\n", "```python \n", "help(PyDealII)\n", "``` \n", @@ -37,7 +37,7 @@ " - **PyDealII.Debug** which uses the debug version of **deal.II**\n", " - **PyDealII.Release** which uses the release version of **deal.II**\n", " \n", - "Let's us import the release version of the library and give it the shortname **dealii**" + "Let us import the release version of the library and give it the shortname **dealii**" ] }, { @@ -280,19 +280,19 @@ ] }, { - "cell_type": "raw", + "cell_type": "markdown", "metadata": {}, "source": [ - "6.983333 25.000000 700\n", - "6.983333 25.016667 692\n", - "6.983333 25.033333 701\n", - "6.983333 25.050000 695\n", - "6.983333 25.066667 710\n", - "6.983333 25.083333 702\n", - "...\n", - "-11.983333 35.950000 707\n", - "-11.983333 35.966667 687\n", - "-11.983333 35.983333 659" + "6.983333 25.000000 700
\n", + "6.983333 25.016667 692
\n", + "6.983333 25.033333 701
\n", + "6.983333 25.050000 695
\n", + "6.983333 25.066667 710
\n", + "6.983333 25.083333 702
\n", + "...
\n", + "-11.983333 35.950000 707
\n", + "-11.983333 35.966667 687
\n", + "-11.983333 35.983333 659
" ] }, { @@ -361,7 +361,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now, create a 2-D triangulation object that would allow us to retrieve a topography value at an arbitrary location within the area. Since we have data on a regular grid with the known size, it is most efficient to use gridded 2-D interpolation:" + "Now, create a 2-D interpolation object that would allow us to retrieve a topography value at an arbitrary location within the area. Since we have data on a regular grid with the known size, it is most efficient to use gridded 2-D interpolation:" ] }, { @@ -394,7 +394,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 5, @@ -463,15 +463,15 @@ " ((1. - ellipticity**2.) * R_bar + d) * math.sin(theta)]\n", "\n", "def pull_back_wgs84(x):\n", - " b = math.sqrt(R * R * (1 - ellipticity * ellipticity))\n", - " ep = math.sqrt((R * R - b * b) / (b * b))\n", + " b = math.sqrt(R**2 * (1 - ellipticity**2))\n", + " ep = math.sqrt((R**2 - b**2) / b**2)\n", " p = math.sqrt(x[0]**2. + x[1]**2.)\n", " th = math.atan2(R * x[2], b * p)\n", " phi = math.atan2(x[1], x[0])\n", - " theta = math.atan2(x[2] + ep * ep * b * math.pow(math.sin(th), 3.),\n", + " theta = math.atan2(x[2] + ep**2 * b * math.pow(math.sin(th), 3.),\n", " (p -\n", - " (ellipticity * ellipticity * R * math.pow(math.cos(th), 3))))\n", - " R_bar = R / (math.sqrt(1 - ellipticity * ellipticity * math.sin(theta) *\n", + " (ellipticity**2 * R * math.pow(math.cos(th), 3))))\n", + " R_bar = R / (math.sqrt(1 - ellipticity**2 * math.sin(theta) *\n", " math.sin(theta)))\n", " R_plus_d = p / math.cos(theta)\n", "\n", @@ -591,10 +591,13 @@ "metadata": {}, "outputs": [], "source": [ + "repetitions = [1, 2, 1]\n", + "p1 = dealii.Point([26 * d2r, -10 * d2r, -500000])\n", + "p2 = dealii.Point([35 * d2r, 5 * d2r, 0.])\n", + "\n", "triangulation = dealii.Triangulation('3D')\n", - "triangulation.generate_subdivided_hyper_rectangle(repetitions = [1, 2, 1],\\\n", - " p1 = dealii.Point([26 * d2r, -10 * d2r, -500000]),\\\n", - " p2 = dealii.Point([35 * d2r, 5 * d2r, 0.]), colorize = True)\n", + "triangulation.generate_subdivided_hyper_rectangle(repetitions,\\\n", + " p1, p2, colorize = True)\n", "\n", "triangulation.transform(push_forward)\n", "\n", @@ -660,9 +663,10 @@ } ], "source": [ - "print('# of cells = %d\\nsmallest cell = %0.1f m\\nlargest cell = %0.1f m' % (triangulation.n_active_cells(),\\\n", - " triangulation.minimal_cell_diameter(),\\\n", - " triangulation.maximal_cell_diameter()))" + "fmt_str = '# of cells = %d\\nsmallest cell = %0.1f m\\nlargest cell = %0.1f m'\n", + "print(fmt_str % (triangulation.n_active_cells(),\\\n", + " triangulation.minimal_cell_diameter(),\\\n", + " triangulation.maximal_cell_diameter()))" ] }, { @@ -694,7 +698,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "For details about visualization and discussionof results and underlying issues the reader is referred to the section [Results](https://www.dealii.org/current/doxygen/deal.II/step_53.html) of the original tutorial program." + "For more details about visualization and discussion of results with underlying issues the reader is referred to the section [Results](https://www.dealii.org/current/doxygen/deal.II/step_53.html) of the original tutorial program." ] } ],