|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
5 |
| - "id": "116651d1-d44d-471d-b13c-36855d8464ec", |
| 5 | + "id": "0", |
6 | 6 | "metadata": {},
|
7 | 7 | "source": [
|
8 | 8 | "# The Poisson problem with complex numbers\n",
|
|
40 | 40 | {
|
41 | 41 | "cell_type": "code",
|
42 | 42 | "execution_count": null,
|
43 |
| - "id": "b52b39d9-260d-4c54-b62a-7440c3b92e5a", |
| 43 | + "id": "1", |
44 | 44 | "metadata": {},
|
45 | 45 | "outputs": [],
|
46 | 46 | "source": [
|
|
59 | 59 | },
|
60 | 60 | {
|
61 | 61 | "cell_type": "markdown",
|
62 |
| - "id": "699ab6a9-4427-4c54-95c8-ce5de5d11b97", |
| 62 | + "id": "2", |
63 | 63 | "metadata": {},
|
64 | 64 | "source": [
|
65 | 65 | "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",
|
|
72 | 72 | {
|
73 | 73 | "cell_type": "code",
|
74 | 74 | "execution_count": null,
|
75 |
| - "id": "4d5b03e3-4d7f-45b7-95eb-9130a5141f34", |
| 75 | + "id": "3", |
76 | 76 | "metadata": {},
|
77 | 77 | "outputs": [],
|
78 | 78 | "source": [
|
|
84 | 84 | },
|
85 | 85 | {
|
86 | 86 | "cell_type": "markdown",
|
87 |
| - "id": "9ea24650-5027-4491-a459-375d7cf69fe3", |
| 87 | + "id": "4", |
88 | 88 | "metadata": {},
|
89 | 89 | "source": [
|
90 | 90 | "## Variational problem\n",
|
|
94 | 94 | {
|
95 | 95 | "cell_type": "code",
|
96 | 96 | "execution_count": null,
|
97 |
| - "id": "be8461a0-a089-4ff3-8bc8-61b016407e70", |
| 97 | + "id": "5", |
98 | 98 | "metadata": {},
|
99 | 99 | "outputs": [],
|
100 | 100 | "source": [
|
|
108 | 108 | },
|
109 | 109 | {
|
110 | 110 | "cell_type": "markdown",
|
111 |
| - "id": "d6f70a1e-d128-470b-9b32-b86dd807a0bf", |
| 111 | + "id": "6", |
112 | 112 | "metadata": {},
|
113 | 113 | "source": [
|
114 | 114 | "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",
|
|
121 | 121 | {
|
122 | 122 | "cell_type": "code",
|
123 | 123 | "execution_count": null,
|
124 |
| - "id": "779ab267-4609-4628-9577-a280b9c18b6d", |
| 124 | + "id": "7", |
125 | 125 | "metadata": {},
|
126 | 126 | "outputs": [],
|
127 | 127 | "source": [
|
|
132 | 132 | },
|
133 | 133 | {
|
134 | 134 | "cell_type": "markdown",
|
135 |
| - "id": "9efe0968-bf32-4184-85f7-4e8cc3401cfb", |
| 135 | + "id": "8", |
136 | 136 | "metadata": {},
|
137 | 137 | "source": [
|
138 | 138 | "Similarly, if we want to use the function `ufl.derivative` to take derivatives of functionals, we need to take some special care. As `ufl.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"
|
|
141 | 141 | {
|
142 | 142 | "cell_type": "code",
|
143 | 143 | "execution_count": null,
|
144 |
| - "id": "d61c477a-d364-4a81-9362-42f1eb4cd8ee", |
| 144 | + "id": "9", |
145 | 145 | "metadata": {},
|
146 | 146 | "outputs": [],
|
147 | 147 | "source": [
|
|
153 | 153 | },
|
154 | 154 | {
|
155 | 155 | "cell_type": "markdown",
|
156 |
| - "id": "1b664480-fc11-404d-83ea-7e2548894904", |
| 156 | + "id": "10", |
157 | 157 | "metadata": {},
|
158 | 158 | "source": [
|
159 | 159 | "We define our Dirichlet condition and setup and solve the variational problem.\n",
|
|
163 | 163 | {
|
164 | 164 | "cell_type": "code",
|
165 | 165 | "execution_count": null,
|
166 |
| - "id": "eb2357ae-ac71-4407-bf37-432f1b1e31d0", |
| 166 | + "id": "11", |
167 | 167 | "metadata": {},
|
168 | 168 | "outputs": [],
|
169 | 169 | "source": [
|
|
177 | 177 | },
|
178 | 178 | {
|
179 | 179 | "cell_type": "markdown",
|
180 |
| - "id": "053bfa60-c382-4216-beaf-c06e95e70067", |
| 180 | + "id": "12", |
181 | 181 | "metadata": {},
|
182 | 182 | "source": [
|
183 | 183 | "We compute the $L^2$ error and the max error.\n",
|
|
188 | 188 | {
|
189 | 189 | "cell_type": "code",
|
190 | 190 | "execution_count": null,
|
191 |
| - "id": "f51d9a7a-2cde-4d0f-8606-91f91c372c4b", |
| 191 | + "id": "13", |
192 | 192 | "metadata": {},
|
193 | 193 | "outputs": [],
|
194 | 194 | "source": [
|
|
203 | 203 | },
|
204 | 204 | {
|
205 | 205 | "cell_type": "markdown",
|
206 |
| - "id": "36431a2a-2063-4070-b1fc-3f58a3b7316b", |
| 206 | + "id": "14", |
207 | 207 | "metadata": {},
|
208 | 208 | "source": [
|
209 | 209 | "## Plotting\n",
|
|
214 | 214 | {
|
215 | 215 | "cell_type": "code",
|
216 | 216 | "execution_count": null,
|
217 |
| - "id": "7a3f89d0-4771-4cc3-a0cd-ce8451a414ba", |
| 217 | + "id": "15", |
218 | 218 | "metadata": {},
|
219 | 219 | "outputs": [],
|
220 | 220 | "source": [
|
|
232 | 232 | {
|
233 | 233 | "cell_type": "code",
|
234 | 234 | "execution_count": null,
|
235 |
| - "id": "9564e40a-ca18-497a-8de0-ef075aae3199", |
| 235 | + "id": "16", |
236 | 236 | "metadata": {},
|
237 | 237 | "outputs": [],
|
238 | 238 | "source": [
|
|
247 | 247 | {
|
248 | 248 | "cell_type": "code",
|
249 | 249 | "execution_count": null,
|
250 |
| - "id": "c179fdda-6ae6-4979-a19b-fadfebab2f0e", |
| 250 | + "id": "17", |
251 | 251 | "metadata": {},
|
252 | 252 | "outputs": [],
|
253 | 253 | "source": [
|
|
263 | 263 | {
|
264 | 264 | "cell_type": "code",
|
265 | 265 | "execution_count": null,
|
266 |
| - "id": "a63144b5-e3fc-445e-acea-b5d744bf7634", |
| 266 | + "id": "18", |
267 | 267 | "metadata": {},
|
268 | 268 | "outputs": [],
|
269 | 269 | "source": []
|
|
0 commit comments