example_interview.ipynb 21.6 KB
 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 16, 2018 7  "**Hello, freifrau! I am TheInterview, your partial differential equations and simulations expert.**\n",  8 9 10 11  "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",  Theresa Pollinger committed Apr 16, 2018 12  "To interactively visualize the current theory graph, enter tgwiev or tgview mpd. \n",  13 14 15  "Otherwise, you can always answer with LaTeX-type input.\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 16 17 18 19  "## Modeling\n", "\n", "\n", "\n",  20 21 22  "How many dimensions does your model have?\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 23  "\n",  24 25 26 27 28  "I am just assuming it's 1, since that is all we can currently handle.\n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 29 30 31  "\n", "\n", "What is the domain in your model? Ω : type ❘ = [?;?], e.g. \\Omega = [0.0;1.0]"  Theresa Pollinger committed Mar 08, 2018 32 33 34 35  ] }, { "cell_type": "code",  36  "execution_count": 1,  Theresa Pollinger committed Mar 08, 2018 37  "metadata": {},  38 39  "outputs": [ {  40 41 42 43 44  "data": { "text/markdown": [ "we will just assume that the variable is called x for now.\n", "\n", "\n",  Theresa Pollinger committed Apr 06, 2018 45 46  "\n", "Which variable(s) are you looking for? / What are the unknowns in your model? u : Ω ⟶ ??, e.g., u : Ω ⟶ ℝ ?\n"  47 48 49 50  ] }, "metadata": {}, "output_type": "display_data"  51 52  } ],  Theresa Pollinger committed Mar 08, 2018 53  "source": [  Theresa Pollinger committed Apr 10, 2018 54  "Ω = [0.0;1.0]\n"  Theresa Pollinger committed Mar 08, 2018 55 56 57 58  ] }, { "cell_type": "code",  59  "execution_count": 2,  Theresa Pollinger committed Mar 08, 2018 60  "metadata": {},  61 62  "outputs": [ {  63 64  "data": { "text/markdown": [  65  "Ok, t : Ω ⟶ ℝ\n",  Theresa Pollinger committed Apr 06, 2018 66  "\n",  67 68  "\n", "\n",  Theresa Pollinger committed Apr 06, 2018 69  "Would you like to name additional parameters like constants or functions (that are independent of your unknowns)? c : ℝ = ? or f : Ω ⟶ ℝ = ?\n"  70 71 72 73  ] }, "metadata": {}, "output_type": "display_data"  74 75  } ],  Theresa Pollinger committed Mar 08, 2018 76  "source": [  77  "t : Ω ⟶ ℝ"  Theresa Pollinger committed Mar 08, 2018 78 79 80 81  ] }, { "cell_type": "code",  82  "execution_count": 3,  Theresa Pollinger committed Mar 08, 2018 83  "metadata": {},  84 85  "outputs": [ {  86 87 88  "data": { "text/markdown": [ "Ok, f = [ x : Ω] x\n",  Theresa Pollinger committed Apr 06, 2018 89 90 91  "\n", "\n", "\n",  92 93 94 95 96  "Would you like to declare more parameters?\n" ] }, "metadata": {}, "output_type": "display_data"  97 98  } ],  Theresa Pollinger committed Mar 08, 2018 99 100 101 102 103 104  "source": [ "f = x" ] }, { "cell_type": "code",  105  "execution_count": 4,  Theresa Pollinger committed Mar 08, 2018 106  "metadata": {},  107 108  "outputs": [ {  109 110  "data": { "text/markdown": [  Theresa Pollinger committed Apr 16, 2018 111  "Ok, κ = [ x : Ω] -5.0\n",  Theresa Pollinger committed Apr 06, 2018 112 113 114  "\n", "\n", "\n",  115 116 117 118 119  "Would you like to declare more parameters?\n" ] }, "metadata": {}, "output_type": "display_data"  120 121  } ],  Theresa Pollinger committed Mar 08, 2018 122  "source": [  Theresa Pollinger committed Apr 16, 2018 123  "\\kappa = -5.0"  Theresa Pollinger committed Mar 08, 2018 124 125 126 127  ] }, { "cell_type": "code",  128  "execution_count": 5,  Theresa Pollinger committed Mar 08, 2018 129  "metadata": {},  130 131  "outputs": [ {  132 133 134 135 136  "data": { "text/markdown": [] }, "metadata": {}, "output_type": "display_data"  137 138  } ],  Theresa Pollinger committed Mar 08, 2018 139 140 141 142 143 144  "source": [ "y" ] }, { "cell_type": "code",  145  "execution_count": 6,  146 147 148 149  "metadata": { "scrolled": true }, "outputs": [  Theresa Pollinger committed Apr 16, 2018 150 151 152 153 154 155 156 157 158 159 160 161  { "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"  162 163  } ],  Theresa Pollinger committed Mar 08, 2018 164  "source": [  Theresa Pollinger committed Apr 16, 2018 165  "k = x ⋅ x"  Theresa Pollinger committed Mar 08, 2018 166 167 168 169  ] }, { "cell_type": "code",  170  "execution_count": 7,  Theresa Pollinger committed Mar 08, 2018 171  "metadata": {},  172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189  "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",  190  "unknowns: OrderedDict([('t', {'theoryname': 't', 'string': 't : Ω ⟶ ℝ', 'type': 'Ω ⟶ ℝ', 'codomain': 'ℝ', 'viewname': 'tASmUnknown'})])\n",  191 192 193 194 195 196  "\n", "\n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 197  "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",  198 199  "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 200 201 202 203 204  "\n", "\n", "\n", "\n", "You can inspect the persistently loaded MMT theories under http://localhost:9000\n"  205 206 207 208 209 210 211 212 213 214 215 216 217 218  ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "recap" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {},  219 220  "outputs": [ {  221 222 223  "data": { "text/markdown": [ "f = x\n",  Theresa Pollinger committed Apr 16, 2018 224 225  "κ = -5.0\n", "k = x ⋅ x\n",  226 227  "\n", "\n",  Theresa Pollinger committed Apr 06, 2018 228  "\n",  229 230 231 232 233  "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"  234 235  } ],  Theresa Pollinger committed Mar 08, 2018 236 237 238 239 240 241  "source": [ "n" ] }, { "cell_type": "code",  242  "execution_count": 9,  Theresa Pollinger committed Mar 21, 2018 243 244 245  "metadata": { "scrolled": true },  246 247  "outputs": [ {  248 249 250 251  "data": { "text/markdown": [ "Ok, \n", " \n",  252  " \n",  253 254  " \n", " \n",  Theresa Pollinger committed Apr 16, 2018 255  " \n",  256 257 258  " \n", " \n", " \n",  259  " \n",  260 261 262 263 264 265 266 267 268 269  " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n",  270  " \n",  271 272 273 274 275  " \n", " \n", " \n", " \n", " \n",  276  " \n",  277 278 279 280 281 282 283 284  " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n",  Theresa Pollinger committed Apr 06, 2018 285  " \n",  286  " \n",  Theresa Pollinger committed Apr 16, 2018 287  " \n",  288 289 290 291 292 293 294 295  " \n", " \n", " \n", " \n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 06, 2018 296  "\n",  297 298 299 300 301 302  "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"  303 304  } ],  Theresa Pollinger committed Mar 08, 2018 305  "source": [  Theresa Pollinger committed Apr 16, 2018 306  "Δt = \\kappa"  Theresa Pollinger committed Mar 08, 2018 307 308 309 310  ] }, { "cell_type": "code",  311  "execution_count": 10,  Theresa Pollinger committed Mar 08, 2018 312  "metadata": {},  313 314  "outputs": [ {  315 316  "data": { "text/markdown": [  Theresa Pollinger committed Apr 10, 2018 317 318 319 320 321 322 323 324 325  "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"  326 327 328 329  ] }, "metadata": {}, "output_type": "display_data"  330 331  } ],  Theresa Pollinger committed Mar 08, 2018 332  "source": [  333  "t = f"  Theresa Pollinger committed Mar 08, 2018 334 335 336 337  ] }, { "cell_type": "code",  338  "execution_count": 11,  Theresa Pollinger committed Mar 08, 2018 339  "metadata": {},  340 341  "outputs": [ {  342 343  "data": { "text/markdown": [  Theresa Pollinger committed Apr 10, 2018 344 345  "OK!\n", "do you know anything else?\n"  346 347 348 349  ] }, "metadata": {}, "output_type": "display_data"  350 351  } ],  Theresa Pollinger committed Mar 08, 2018 352 353 354 355 356 357  "source": [ "linear" ] }, { "cell_type": "code",  358  "execution_count": 12,  Theresa Pollinger committed Mar 08, 2018 359  "metadata": {},  360 361  "outputs": [ {  362 363  "data": { "text/markdown": [  Theresa Pollinger committed Apr 10, 2018 364 365  "OK!\n", "do you know anything else?\n"  366 367 368 369  ] }, "metadata": {}, "output_type": "display_data"  370 371  } ],  Theresa Pollinger committed Mar 08, 2018 372 373 374 375 376 377  "source": [ "elliptic" ] }, { "cell_type": "code",  378  "execution_count": 13,  Theresa Pollinger committed Mar 08, 2018 379  "metadata": {},  380 381  "outputs": [ {  382 383  "data": { "text/markdown": [  Theresa Pollinger committed Apr 10, 2018 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400  "\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",  401  "unknowns: OrderedDict([('t', {'theoryname': 't', 'string': 't : Ω ⟶ ℝ', 'type': 'Ω ⟶ ℝ', 'codomain': 'ℝ', 'viewname': 'tASmUnknown'})])\n",  Theresa Pollinger committed Apr 10, 2018 402 403 404 405 406 407  "\n", "\n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 408  "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 409 410 411 412 413 414  "\n", "\n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 415  "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 416 417 418 419 420 421  "\n", "\n", "\n", "\n", "\n", "\n",  422  "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 423 424 425 426 427 428 429 430 431 432 433 434 435 436  "\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",  437 438 439  "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 440 441 442 443  "\n", "\n", "\n", "You can inspect the persistently loaded MMT theories under http://localhost:9000\n",  444 445 446 447  "## Solving\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 10, 2018 448  "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"  449 450 451 452  ] }, "metadata": {}, "output_type": "display_data"  453 454  } ],  Theresa Pollinger committed Mar 08, 2018 455 456 457 458 459 460  "source": [ "n" ] }, { "cell_type": "code",  Theresa Pollinger committed Apr 16, 2018 461  "execution_count": null,  Theresa Pollinger committed Mar 08, 2018 462  "metadata": {},  Theresa Pollinger committed Apr 16, 2018 463 464  "outputs": [], "source": []  465 466 467  }, { "cell_type": "code",  Theresa Pollinger committed Apr 16, 2018 468  "execution_count": 14,  469 470 471 472 473  "metadata": { "scrolled": false }, "outputs": [ {  474 475 476 477  "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, {  Theresa Pollinger committed Apr 16, 2018 492 493 494 495 496  "data": { "text/markdown": [] }, "metadata": {}, "output_type": "display_data"  497 498  } ],  499  "source": [  500  "tgview mpd"  501 502 503 504  ] }, { "cell_type": "code",  Theresa Pollinger committed Apr 16, 2018 505  "execution_count": 15,  506  "metadata": {},  507 508  "outputs": [ {  509 510  "data": { "text/markdown": [  Theresa Pollinger committed Apr 06, 2018 511 512 513 514 515 516 517  "These are the things we know so far about your problem:\n", "\n", "\n", "\n", "\n", "\n", "\n",  518  "domain: {'name': 'Ω', 'theoryname': 'ephdomain', 'axes': OrderedDict([('x', '[0.0;1.0]')]), 'from': '0.0', 'to': '1.0', 'boundary_name': 'Ω', 'viewname': 'ephdomainASmDomain'}\n",  Theresa Pollinger committed Apr 06, 2018 519 520 521 522 523 524  "\n", "\n", "\n", "\n", "\n", "\n",  525  "unknowns: OrderedDict([('t', {'theoryname': 't', 'string': 't : Ω ⟶ ℝ', 'type': 'Ω ⟶ ℝ', 'codomain': 'ℝ', 'viewname': 'tASmUnknown'})])\n",  Theresa Pollinger committed Apr 06, 2018 526 527 528 529 530 531  "\n", "\n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 532  "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 06, 2018 533 534 535 536 537 538  "\n", "\n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 539  "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 06, 2018 540 541 542 543 544 545  "\n", "\n", "\n", "\n", "\n", "\n",  546  "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 547 548 549 550 551 552 553 554 555 556 557 558 559  "\n", "\n", "\n", "\n", "\n", "\n", "props: {'theoryname': 'ephBoundaryValueProblem', 'viewname': 'ephBoundaryValueProblemASmEllipticLinearDirichletBoundaryValueProblem', 'ops': [{'name': 'Δ', 'props': ['elliptic'], 'linear': True}]}\n", "\n", "\n", "\n", "\n", "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 560 561 562  "sim: {'type': None}\n", "\n", "\n",  563 564  "\n", "\n",  Theresa Pollinger committed Apr 16, 2018 565 566 567  "\n", "\n", "You can inspect the persistently loaded MMT theories under http://localhost:9000\n"  568 569 570 571  ] }, "metadata": {}, "output_type": "display_data"  572 573  } ],  Theresa Pollinger committed Mar 14, 2018 574  "source": [  575  "recap"  Theresa Pollinger committed Mar 14, 2018 576  ]  577  },  578 579  { "cell_type": "code",  Theresa Pollinger committed Apr 16, 2018 580  "execution_count": 16,  Theresa Pollinger committed Apr 06, 2018 581  "metadata": {},  Theresa Pollinger committed Apr 10, 2018 582 583 584 585 586 587  "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/markdown": [] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "tgview" ]  Theresa Pollinger committed Apr 06, 2018 612  },  Theresa Pollinger committed Mar 08, 2018 613 614 615 616 617 618 619 620 621 622  { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": {  623  "display_name": "TheInterview",  Theresa Pollinger committed Mar 08, 2018 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641  "language": "text", "name": "interview" }, "language_info": { "file_extension": ".txt", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/plain", "name": "text" } }, "nbformat": 4, "nbformat_minor": 2 }