example_interview.ipynb 1.36 MB
 Theresa Pollinger committed Mar 08, 2018 1 2 3 { "cells": [ { 4 "cell_type": "markdown", Theresa Pollinger committed Mar 08, 2018 5 6 "metadata": {}, "source": [ Theresa Pollinger committed Apr 06, 2018 7 "**Hello, user! I am TheInterview, your partial differential equations and simulations expert.**\n", 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 "Let's set up a model and simulation together.\n", "\n", "To get explanations, enter explain . \n", "To see a recap of what we know so far, enter recap . \n", "To interactively visualize ther current theory graph, enter tgwiev or tgview mpd. \n", "Otherwise, you can always answer with LaTeX-type input.\n", "\n", "\n", "How many dimensions does your model have?\n", "\n", "\n", "I am just assuming it's 1, since that is all we can currently handle.\n", "\n", "\n", "\n", "\n", "What is the domain you would like to simulate for? Ω : type ❘ = [?;?], e.g. \\Omega = [0.0;1.0]\n", "By the way, you can always try and use LaTeX-type input.\n" Theresa Pollinger committed Mar 08, 2018 26 27 28 29 ] }, { "cell_type": "code", 30 "execution_count": 1, Theresa Pollinger committed Mar 08, 2018 31 "metadata": {}, 32 33 "outputs": [ { 34 35 36 37 38 "data": { "text/markdown": [ "we will just assume that the variable is called x for now.\n", "\n", "\n", Theresa Pollinger committed Apr 06, 2018 39 40 "\n", "Which variable(s) are you looking for? / What are the unknowns in your model? u : Ω ⟶ ??, e.g., u : Ω ⟶ ℝ ?\n" 41 42 43 44 ] }, "metadata": {}, "output_type": "display_data" 45 46 } ], Theresa Pollinger committed Mar 08, 2018 47 "source": [ Theresa Pollinger committed Apr 10, 2018 48 "Ω = [0.0;1.0]\n" Theresa Pollinger committed Mar 08, 2018 49 50 51 52 ] }, { "cell_type": "code", 53 "execution_count": 2, Theresa Pollinger committed Mar 08, 2018 54 "metadata": {}, 55 56 "outputs": [ { 57 58 "data": { "text/markdown": [ 59 "Ok, t : Ω ⟶ ℝ\n", Theresa Pollinger committed Apr 06, 2018 60 "\n", 61 62 "\n", "\n", Theresa Pollinger committed Apr 06, 2018 63 "Would you like to name additional parameters like constants or functions (that are independent of your unknowns)? c : ℝ = ? or f : Ω ⟶ ℝ = ?\n" 64 65 66 67 ] }, "metadata": {}, "output_type": "display_data" 68 69 } ], Theresa Pollinger committed Mar 08, 2018 70 "source": [ 71 "t : Ω ⟶ ℝ" Theresa Pollinger committed Mar 08, 2018 72 73 74 75 ] }, { "cell_type": "code", 76 "execution_count": 3, Theresa Pollinger committed Mar 08, 2018 77 "metadata": {}, 78 79 "outputs": [ { 80 81 82 "data": { "text/markdown": [ "Ok, f = [ x : Ω] x\n", Theresa Pollinger committed Apr 06, 2018 83 84 85 "\n", "\n", "\n", 86 87 88 89 90 "Would you like to declare more parameters?\n" ] }, "metadata": {}, "output_type": "display_data" 91 92 } ], Theresa Pollinger committed Mar 08, 2018 93 94 95 96 97 98 "source": [ "f = x" ] }, { "cell_type": "code", 99 "execution_count": 4, Theresa Pollinger committed Mar 08, 2018 100 "metadata": {}, 101 102 "outputs": [ { 103 104 "data": { "text/markdown": [ Theresa Pollinger committed Apr 16, 2018 105 "Ok, κ = [ x : Ω] -5.0\n", Theresa Pollinger committed Apr 06, 2018 106 107 108 "\n", "\n", "\n", 109 110 111 112 113 "Would you like to declare more parameters?\n" ] }, "metadata": {}, "output_type": "display_data" 114 115 } ], Theresa Pollinger committed Mar 08, 2018 116 "source": [ Theresa Pollinger committed Apr 16, 2018 117 "\\kappa = -5.0" Theresa Pollinger committed Mar 08, 2018 118 119 120 121 ] }, { "cell_type": "code", 122 "execution_count": 5, Theresa Pollinger committed Mar 08, 2018 123 "metadata": {}, 124 125 "outputs": [ { 126 127 128 129 130 "data": { "text/markdown": [] }, "metadata": {}, "output_type": "display_data" 131 132 } ], Theresa Pollinger committed Mar 08, 2018 133 134 135 136 137 138 "source": [ "y" ] }, { "cell_type": "code", 139 "execution_count": 6, 140 141 142 143 "metadata": { "scrolled": true }, "outputs": [ Theresa Pollinger committed Apr 16, 2018 144 145 146 147 148 149 150 151 152 153 154 155 { "data": { "text/markdown": [ "Ok, k = [ x : Ω] x ⋅ x\n", "\n", "\n", "\n", "Would you like to declare more parameters?\n" ] }, "metadata": {}, "output_type": "display_data" 156 157 } ], Theresa Pollinger committed Mar 08, 2018 158 "source": [ Theresa Pollinger committed Apr 16, 2018 159 "k = x ⋅ x" Theresa Pollinger committed Mar 08, 2018 160 161 162 163 ] }, { "cell_type": "code", 164 "execution_count": 7, Theresa Pollinger committed Mar 08, 2018 165 "metadata": {}, 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 "outputs": [ { "data": { "text/markdown": [ "These are the things we know so far about your problem:\n", "\n", "\n", "\n", "\n", "\n", "\n", "domain: {'name': 'Ω', 'theoryname': 'ephdomain', 'axes': OrderedDict([('x', '[0.0;1.0]')]), 'from': '0.0', 'to': '1.0', 'boundary_name': 'Ω', 'viewname': 'ephdomainASmDomain'}\n", "\n", "\n", "\n", "\n", "\n", "\n", 184 "unknowns: OrderedDict([('t', {'theoryname': 't', 'string': 't : Ω ⟶ ℝ', 'type': 'Ω ⟶ ℝ', 'codomain': 'ℝ', 'viewname': 'tASmUnknown'})])\n", 185 186 187 188 189 190 "\n", "\n", "\n", "\n", "\n", "\n", Theresa Pollinger committed Apr 16, 2018 191 "parameters: OrderedDict([('f', {'theoryname': 'f', 'string': 'f = x', 'parsestring': 'f = [ x : Ω] x', 'type': '{ : Ω } Ω', 'viewname': 'fASmParameter'}), ('κ', {'theoryname': 'κ', 'string': 'κ = -5.0', 'parsestring': 'κ = [ x : Ω] -5.0', 'type': '{ : Ω } ℝ', 'viewname': 'κASmParameter'}), ('k', {'theoryname': 'k', 'string': 'k = x ⋅ x', 'parsestring': 'k = [ x : Ω] x ⋅ x', 'type': '{ : Ω } ℝ', 'viewname': 'kASmParameter'})])\n", 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 "\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "recap" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, 209 210 "outputs": [ { 211 212 213 "data": { "text/markdown": [ "f = x\n", Theresa Pollinger committed Apr 16, 2018 214 215 "κ = -5.0\n", "k = x ⋅ x\n", 216 217 "\n", "\n", Theresa Pollinger committed Apr 06, 2018 218 "\n", 219 220 221 222 223 "Let's talk about your partial differential equation(s). What do they look like? Δu = 0.0, or laplace_operator Ω ℝ u = f ?\n" ] }, "metadata": {}, "output_type": "display_data" 224 225 } ], Theresa Pollinger committed Mar 08, 2018 226 227 228 229 230 231 "source": [ "n" ] }, { "cell_type": "code", 232 "execution_count": 9, Theresa Pollinger committed Mar 21, 2018 233 234 235 "metadata": { "scrolled": true }, 236 237 "outputs": [ { 238 239 240 241 "data": { "text/markdown": [ "Ok, \n", " \n", 242 " \n", 243 244 " \n", " \n", Theresa Pollinger committed Apr 16, 2018 245 " \n", 246 247 248 " \n", " \n", " \n", 249 " \n", 250 251 252 253 254 255 256 257 258 259 " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", 260 " \n", 261 262 263 264 265 " \n", " \n", " \n", " \n", " \n", 266 " \n", 267 268 269 270 271 272 273 274 " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", Theresa Pollinger committed Apr 06, 2018 275 " \n", 276 " \n", Theresa Pollinger committed Apr 16, 2018 277 " \n", 278 279 280 281 282 283 284 285 " \n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", Theresa Pollinger committed Apr 06, 2018 286 "\n", 287 288 289 290 291 292 "These are all the PDEs needed.\n", "Let's discuss your boundary conditions. What do they look like? u(x) = f(x) or u(1.0) = \\alpha ?\n" ] }, "metadata": {}, "output_type": "display_data" 293 294 } ], Theresa Pollinger committed Mar 08, 2018 295 "source": [ Theresa Pollinger committed Apr 16, 2018 296 "Δt = \\kappa" Theresa Pollinger committed Mar 08, 2018 297 298 299 300 ] }, { "cell_type": "code", 301 "execution_count": 10, Theresa Pollinger committed Mar 08, 2018 302 "metadata": {}, 303 304 "outputs": [ { 305 306 "data": { "text/markdown": [ Theresa Pollinger committed Apr 10, 2018 307 308 309 310 311 312 313 314 315 "Ok \n", "\n", "\n", "\n", "These are all the boundary conditions needed.\n", "\n", "\n", "\n", "Do you know something about the operator Δ? Is it e.g. linear, or not elliptic ? \n" 316 317 318 319 ] }, "metadata": {}, "output_type": "display_data" 320 321 } ], Theresa Pollinger committed Mar 08, 2018 322 "source": [ 323 "t = f" Theresa Pollinger committed Mar 08, 2018 324 325 326 327 ] }, { "cell_type": "code", 328 "execution_count": 11, Theresa Pollinger committed Mar 08, 2018 329 "metadata": {}, 330 331 "outputs": [ { 332 333 "data": { "text/markdown": [ Theresa Pollinger committed Apr 10, 2018 334 335 "OK!\n", "do you know anything else?\n" 336 337 338 339 ] }, "metadata": {}, "output_type": "display_data" 340 341 } ], Theresa Pollinger committed Mar 08, 2018 342 343 344 345 346 347 "source": [ "linear" ] }, { "cell_type": "code", 348 "execution_count": 12, Theresa Pollinger committed Mar 08, 2018 349 "metadata": {}, 350 351 "outputs": [ { 352 353 "data": { "text/markdown": [ Theresa Pollinger committed Apr 10, 2018 354 355 "OK!\n", "do you know anything else?\n" 356 357 358 359 ] }, "metadata": {}, "output_type": "display_data" 360 361 } ], Theresa Pollinger committed Mar 08, 2018 362 363 364 365 366 367 "source": [ "elliptic" ] }, { "cell_type": "code", 368 "execution_count": 13, Theresa Pollinger committed Mar 08, 2018 369 "metadata": {}, 370 371 "outputs": [ { 372 373 "data": { "text/markdown": [ Theresa Pollinger committed Apr 10, 2018 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 "\n", "\n", "\n", "These are the things we know so far about your problem:\n", "\n", "\n", "\n", "\n", "\n", "\n", "domain: {'name': 'Ω', 'theoryname': 'ephdomain', 'axes': OrderedDict([('x', '[0.0;1.0]')]), 'from': '0.0', 'to': '1.0', 'boundary_name': 'Ω', 'viewname': 'ephdomainASmDomain'}\n", "\n", "\n", "\n", "\n", "\n", "\n", 391 "unknowns: OrderedDict([('t', {'theoryname': 't', 'string': 't : Ω ⟶ ℝ', 'type': 'Ω ⟶ ℝ', 'codomain': 'ℝ', 'viewname': 'tASmUnknown'})])\n", Theresa Pollinger committed Apr 10, 2018 392 393 394 395 396 397 "\n", "\n", "\n", "\n", "\n", "\n", Theresa Pollinger committed Apr 16, 2018 398 "parameters: OrderedDict([('f', {'theoryname': 'f', 'string': 'f = x', 'parsestring': 'f = [ x : Ω] x', 'type': '{ : Ω } Ω', 'viewname': 'fASmParameter'}), ('κ', {'theoryname': 'κ', 'string': 'κ = -5.0', 'parsestring': 'κ = [ x : Ω] -5.0', 'type': '{ : Ω } ℝ', 'viewname': 'κASmParameter'}), ('k', {'theoryname': 'k', 'string': 'k = x ⋅ x', 'parsestring': 'k = [ x : Ω] x ⋅ x', 'type': '{ : Ω } ℝ', 'viewname': 'kASmParameter'})])\n", Theresa Pollinger committed Apr 10, 2018 399 400 401 402 403 404 "\n", "\n", "\n", "\n", "\n", "\n", Theresa Pollinger committed Apr 16, 2018 405 "pdes: {'pdes': [{'theoryname': 'ephemeral_pde1', 'string': 'Δt = κ', 'lhsstring': 'Δt', 'rhsstring': 'κ', 'rhsstring_expanded': '-5.0', 'viewname': 'ephemeral_pde1ASmPDE', 'op': 'Δ', 'lhsparsestring': ' [ anyt : Ω ⟶ ℝ ] Δ anyt ', 'rhsparsestring': ' κ'}]}\n", Theresa Pollinger committed Apr 10, 2018 406 407 408 409 410 411 "\n", "\n", "\n", "\n", "\n", "\n", 412 "bcs: {'theoryname': 'ephbcs', 'bcs': [{'name': 'bc0', 'string': 't = f', 'lhsstring': 't', 'rhsstring': 'f', 'rhsstring_expanded': 'x', 'type': ('Dirichlet',), 'on': ('x',), 'measure': (2,)}], 'viewname': 'ephbcsASmBCsRequired', 'measure_given': 2}\n", Theresa Pollinger committed Apr 10, 2018 413 414 415 416 417 418 419 420 421 422 423 424 425 426 "\n", "\n", "\n", "\n", "\n", "\n", "props: {'theoryname': 'ephBoundaryValueProblem', 'viewname': 'ephBoundaryValueProblemASmEllipticLinearDirichletBoundaryValueProblem', 'ops': [{'name': 'Δ', 'props': ['elliptic'], 'linear': True}]}\n", "\n", "\n", "\n", "\n", "\n", "\n", "sim: {'type': None}\n", 427 428 429 430 431 432 433 "\n", "\n", "\n", "## Solving\n", "\n", "\n", "\n", Theresa Pollinger committed Apr 10, 2018 434 "Would you like to try and solve the PDE using the Finite Difference Method in ExaStencils? If yes, you can provide a configuration name, or we'll just use your name.\n" 435 436 437 438 ] }, "metadata": {}, "output_type": "display_data" 439 440 } ], Theresa Pollinger committed Mar 08, 2018 441 442 443 444 445 446 "source": [ "n" ] }, { "cell_type": "code", 447 "execution_count": 14, Theresa Pollinger committed Mar 08, 2018 448 "metadata": {}, 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Generated ExaStencils input; running ExaStencils\n", "Ran ExaStencils; preparing visualization\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", " my plot\n", " \n", "\n", " \n", "\n", "\n", " \n", " \n", " \n", "