Skip to content

Fixed some typos and wording. #171

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

Closed
wants to merge 8 commits into from
Closed
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
16 changes: 8 additions & 8 deletions chapter1/complex_mode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"\n",
"As in [Solving the Poisson equation](./fundamentals) we want to express our partial differential equation as a weak formulation.\n",
"\n",
"We start by defining our discrete function space $V_h$, such that $u_h\\in V_h$ and $u_h = \\sum_{i=1}^N c_i \\phi_i(x, y)$ where $\\phi_i$ are **real valued** global basis functions of our space $V_h$, $c_i \\in \\mathcal{C}$ are the **complex valued** degrees of freedom.\n",
"We start by defining our discrete function space $V_h$, such that $u_h\\in V_h$ and $u_h = \\sum_{i=1}^N c_i \\phi_i(x, y)$ where $\\phi_i$ are **real valued** global basis functions of our space $V_h$, and $c_i \\in \\mathcal{C}$ are the **complex valued** degrees of freedom.\n",
"\n",
"Next, we choose a test function $v\\in \\hat V_h$ where $\\hat V_h\\subset V_h$ such that $v\\vert_{\\partial\\Omega}=0$, as done in the first tutorial.\n",
"We now need to define our inner product space. We choose the $L^2$ inner product spaces, which is a _[sesquilinear](https://en.wikipedia.org/wiki/Sesquilinear_form) 2-form_, Meaning that $\\langle u, v\\rangle$ is a map from $V_h\\times V_h\\mapsto K$, and $\\langle u, v \\rangle = \\int_\\Omega u \\cdot \\bar v ~\\mathrm{d} x$. As it is sesquilinear, we have the following properties:\n",
"We now need to define our inner product space. We choose the $L^2$ inner product spaces, which is a _[sesquilinear](https://en.wikipedia.org/wiki/Sesquilinear_form) 2-form_, meaning that $\\langle u, v\\rangle$ is a map from $V_h\\times V_h\\mapsto K$, and $\\langle u, v \\rangle = \\int_\\Omega u \\cdot \\bar v ~\\mathrm{d} x$. As it is sesquilinear, we have the following properties:\n",
"\n",
"$$\\langle u , v \\rangle = \\overline{\\langle v, u \\rangle},$$\n",
"$$\\langle u , u \\rangle \\geq 0.$$\n",
Expand All @@ -34,7 +34,7 @@
"\n",
"## Installation of FEniCSx with complex number support\n",
"\n",
"FEniCSx supports both real and complex numbers, meaning that we can create a function spaces with real valued or complex valued coefficients.\n"
"FEniCSx supports both real and complex numbers, so we can create a function space with real valued or complex valued coefficients.\n"
]
},
{
Expand Down Expand Up @@ -71,7 +71,7 @@
"id": "699ab6a9-4427-4c54-95c8-ce5de5d11b97",
"metadata": {},
"source": [
"However, as we would like to solve linear algebra problems on the form $Ax=b$, we need to be able to use matrices and vectors that support real and complex numbers. As [PETSc](https://petsc.org/release/) is one of the most popular interfaces to linear algebra packages, we need to be able to work with their matrix and vector structures.\n",
"However, as we would like to solve linear algebra problems of the form $Ax=b$, we need to be able to use matrices and vectors that support real and complex numbers. As [PETSc](https://petsc.org/release/) is one of the most popular interfaces to linear algebra packages, we need to be able to work with their matrix and vector structures.\n",
"\n",
"Unfortunately, PETSc only supports one floating type in their matrices, thus we need to install two versions of PETSc, one that supports `float64` and one that supports `complex128`. In the [docker images](https://hub.docker.com/r/dolfinx/dolfinx) for DOLFINx, both versions are installed, and one can switch between them by calling `source dolfinx-real-mode` or `source dolfinx-complex-mode`. For the `dolfinx/lab` images, one can change the Python kernel to be either the real or complex mode, by going to `Kernel->Change Kernel...` and choose `Python3 (ipykernel)` (for real mode) or `Python3 (DOLFINx complex)` (for complex mode).\n",
"\n",
Expand Down Expand Up @@ -131,7 +131,7 @@
"source": [
"Note that we have used the `PETSc.ScalarType` to wrap the constant source on the right hand side. This is because we want the integration kernels to assemble into the correct floating type.\n",
"\n",
"Secondly, note that we are using `ufl.inner` to describe multiplication of $f$ and $v$, even if they are scalar values. This is because `ufl.inner` takes the conjugate of the second argument, as decribed by the $L^2$ inner product. One could alternatively write this out manually\n",
"Secondly, note that we are using `ufl.inner` to describe multiplication of $f$ and $v$, even if they are scalar values. This is because `ufl.inner` takes the conjugate of the second argument, as decribed by the $L^2$ inner product. One could alternatively write this out explicitly\n",
"\n",
"### Inner-products and derivatives\n"
]
Expand Down Expand Up @@ -162,7 +162,7 @@
"id": "9efe0968-bf32-4184-85f7-4e8cc3401cfb",
"metadata": {},
"source": [
"Similarly, if we want to use the function $ufl.derivative$ to take derivatives of functionals, we need to take some special care. As `derivative` inserts a `ufl.TestFunction` to represent the variation, we need to take the conjugate of this to be able to use it to assemble vectors.\n"
"Similarly, if we want to use the function `ufl.derivative` to take derivatives of functionals, we need to take some special care. As `derivative` inserts a `ufl.TestFunction` to represent the variation, we need to take the conjugate of this to in order to assemble vectors.\n"
]
},
{
Expand Down Expand Up @@ -276,7 +276,7 @@
"id": "053bfa60-c382-4216-beaf-c06e95e70067",
"metadata": {},
"source": [
"We compute the $L^2$ error and the max error\n",
"We compute the $L^2$ error and the max error.\n",
"\n",
"## Error computation\n"
]
Expand Down Expand Up @@ -312,7 +312,7 @@
"source": [
"## Plotting\n",
"\n",
"Finally, we plot the real and imaginary solution\n"
"Finally, we plot the real and imaginary solutions.\n"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions chapter2/nonlinpoisson_code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"Author: Jørgen S. Dokken\n",
"\n",
"## Test problem\n",
"To solve a test problem, we need to choose the right hand side $f$ and the coefficient $q(u)$ and the boundary $u_D$. Previously, we have worked with manufactured solutions that can be reproduced without approximation errors. This is more difficult in non-linear porblems, and the algebra is more tedious. Howeve, we will utilize UFLs differentiation capabilities to obtain a manufactured solution.\n",
"To solve a test problem, we need to choose the right hand side $f$, the coefficient $q(u)$, and the boundary $u_D$. Previously, we have worked with manufactured solutions that can be reproduced without approximation errors. This is more difficult in nonlinear problems, and the algebra is more tedious. However, we will utilize the UFL differentiation capabilities to obtain a manufactured solution.\n",
"\n",
"For this problem, we will choose $q(u) = 1 + u^2$ and define a two dimensional manufactured solution that is linear in $x$ and $y$:"
]
Expand Down Expand Up @@ -44,10 +44,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that since `x` is a 2D vector, the first component (index 0) resemble $x$, while the second component (index 1) resemble $y$. The resulting function `f` can be directly used in variational formulations in DOLFINx.\n",
"Note that since `x` is a 2D vector, the first component (index 0) represents $x$, while the second component (index 1) represents $y$. The resulting function `f` can be directly used in variational formulations in DOLFINx.\n",
"\n",
"As we now have defined our source term and exact solution, we can create the appropriate function space and boundary conditions.\n",
"Note that as we have already defined the exact solution, we only have to convert it to a python function that can be evaluated in the interpolation function. We do this by employing the Python `eval` and `lambda`-functions."
"As we now have defined our source term and an exact solution, we can create the appropriate function space and boundary conditions.\n",
"Note that as we have already defined the exact solution, we only have to convert it to a Python function that can be evaluated in the interpolation function. We do this by employing the Python `eval` and `lambda`-functions."
]
},
{
Expand Down Expand Up @@ -77,7 +77,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We are now ready to define the variational formulation. Note that as the problem is non-linear, we have replace the `TrialFunction` with a `Function`, which serves as the unknown of our problem."
"We are now ready to define the variational formulation. Note that as the problem is nonlinear, we have to replace the `TrialFunction` with a `Function`, which serves as the unknown of our problem."
]
},
{
Expand Down Expand Up @@ -114,7 +114,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, we use the dolfinx Newton solver. We can set the convergence criterions for the solver by changing the absolute tolerance (`atol`), relative tolerance (`rtol`) or the convergence criterion (`residual` or `incremental`)."
"Next, we use the DOLFINx Newton solver. We can set the convergence criteria for the solver by changing the absolute tolerance (`atol`), relative tolerance (`rtol`) or the convergence criterion (`residual` or `incremental`)."
]
},
{
Expand Down Expand Up @@ -213,7 +213,7 @@
"metadata": {},
"source": [
"We observe that the solver converges after $8$ iterations.\n",
"If we think of the problem in terms of finite differences on a uniform mesh, $\\mathcal{P}_1$ elements mimic standard second-order finite differences, which compute the derivative of a linear or quadratic funtion exactly. Here $\\nabla u$ is a constant vector, which is multiplied by $1+u^2$, which is a second order polynomial in $x$ and $y$, which the finite difference operator would compute exactly. We can therefore, even with $\\mathcal{P}_1$ elements, expect the manufactured solution to be reproduced by the numerical method. However, if we had chosen a nonlinearity, such as $1+u^4$, this would not be the case, and we would need to verify convergence rates."
"If we think of the problem in terms of finite differences on a uniform mesh, $\\mathcal{P}_1$ elements mimic standard second-order finite differences, which compute the derivative of a linear or quadratic funtion exactly. Here $\\nabla u$ is a constant vector, which is multiplied by $1+u^2$, giving a second order polynomial in $x$ and $y$, which the finite difference operator would compute exactly. We can therefore, even with $\\mathcal{P}_1$ elements, expect the manufactured solution to be reproduced by the numerical method. However, if we had chosen a nonlinearity, such as $1+u^4$, this would not be the case, and we would need to verify convergence rates."
]
},
{
Expand Down