]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Mention notebook in the original program 9777/head
authorAlexander Grayver <agrayver@erdw.ethz.ch>
Mon, 30 Mar 2020 12:23:38 +0000 (14:23 +0200)
committerAlexander Grayver <agrayver@erdw.ethz.ch>
Tue, 7 Apr 2020 12:11:19 +0000 (14:11 +0200)
contrib/python-bindings/notebooks/index.ipynb
examples/step-53/doc/intro.dox
examples/step-53/step-53.ipynb

index 25d69b68c562e3809d2123b7eb88997061923d5d..c53164e0041bea170ae15d8af36137767d2f6d54 100644 (file)
     "[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": {
index c630d2f7559096963f093c4c971ac8e203eb6589..780d12ec6e033aff6536ef4f4316511364c262bb 100644 (file)
@@ -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 <a
+href="https://github.com/dealii/dealii/blob/master/examples/step-53/step-53.ipynb">github</a>.
+
 
 <a name="Intro"></a>
 <h1>Introduction</h1>
index 2979b5e765222cc2ca3bb5d89d86757a7e62aa10..8adc3128ae3ad414bbd1bfc69d91707cf0bad14f 100644 (file)
@@ -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**"
    ]
   },
   {
    ]
   },
   {
-   "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<br>\n",
+    "6.983333 25.016667 692<br>\n",
+    "6.983333 25.033333 701<br>\n",
+    "6.983333 25.050000 695<br>\n",
+    "6.983333 25.066667 710<br>\n",
+    "6.983333 25.083333 702<br>\n",
+    "...<br>\n",
+    "-11.983333 35.950000 707<br>\n",
+    "-11.983333 35.966667 687<br>\n",
+    "-11.983333 35.983333 659<br>"
    ]
   },
   {
    "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:"
    ]
   },
   {
     {
      "data": {
       "text/plain": [
-       "<matplotlib.colorbar.Colorbar at 0x7f159dd9ef60>"
+       "<matplotlib.colorbar.Colorbar at 0x7f5892559da0>"
       ]
      },
      "execution_count": 5,
     "            ((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",
    "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",
     }
    ],
    "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()))"
    ]
   },
   {
    "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."
    ]
   }
  ],

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.