Skip to content

Commit

Permalink
Clarify variable p is a 2D array
Browse files Browse the repository at this point in the history
and reword description of the input parameters for functions `plot2D` and `laplace2d`.

See also issue barbagroup#69.
  • Loading branch information
mesnardo committed Apr 29, 2020
1 parent a955baa commit 2bd6fc2
Showing 1 changed file with 26 additions and 34 deletions.
60 changes: 26 additions & 34 deletions lessons/12_Step_9.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"import numpy\n",
Expand All @@ -140,9 +138,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"def plot2D(x, y, p):\n",
Expand All @@ -162,7 +158,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The function `plot2D` takes three arguments, an x-vector, a y-vector and our p matrix. Given these three values, it produces a 3D projection plot, sets the plot limits and gives us a nice viewing angle. "
"The function `plot2D` takes three arguments:\n",
"\n",
"* `x`: 1D array with point locations along an horizontal gridline,\n",
"* `y`: 1D array with point locations along a vertical gridline,\n",
"* `p`: 2D array containing the numerical solution in the domain.\n",
"\n",
"Given these three values, it produces a 3D projection plot, sets the plot limits and gives us a nice viewing angle. "
]
},
{
Expand All @@ -175,9 +177,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"def laplace2d(p, y, dx, dy, l1norm_target):\n",
Expand All @@ -204,17 +204,21 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"`laplace2d` takes five arguments, the `p` matrix, the `y`-vector, `dx`, `dy` and the value `l1norm_target`. This last value defines how close the `p` matrix should be in two consecutive iterations before the loop breaks and returns the calculated `p` value. \n",
"`laplace2d` takes five arguments:\n",
"\n",
"* `p`: 2D array containing the initial solution in the domain,\n",
"* `y`: 1D array with point locations along a vertical gridline,\n",
"* `dx`: $x$-distance between two gridlines,\n",
"* `dy`: $y$-distance between two gridlines,\n",
"* `l1norm_target`: value to define convergence; we stop the iterative process (i.e., exit the `while` loop) when the relative difference between two consecutive solutions (in the $L_1$-norm) is lower or equal than `l1norm_target`.\n",
"\n",
"Note that when executing the cells above in your own notebook, there will be no output. You have *defined* the function but you have not yet *called* the function. It is now available for you to use, the same as `numpy.linspace` or any other function in our namespace. "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"##variable declarations\n",
Expand Down Expand Up @@ -250,9 +254,7 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -281,9 +283,7 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"p = laplace2d(p, y, dx, dy, 1e-4)"
Expand All @@ -299,9 +299,7 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -342,9 +340,7 @@
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -384,9 +380,7 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -419,9 +413,7 @@
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -551,9 +543,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

0 comments on commit 2bd6fc2

Please sign in to comment.