demo_create_method_from_scratch.ipynb 53.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "nbsphinx": "hidden"
   },
   "outputs": [],
   "source": [
    "from lbmpy.session import *\n",
    "import pystencils as ps\n",
    "from pystencils.stencils import visualize_stencil"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Demo: Create lbmpy Method from Scratch\n",
    "\n",
    "<img src='../../img/collision_space.svg' width=\"90%\">\n",
    "\n",
    "\n",
    "### Defining transformation to collision space"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA20AAAAUBAMAAADsGchtAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAdt3NMolEIma7mVTvEKvunM/GAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFf0lEQVRoBe2az4scVRDHvzuzvTP7o+Oai5CDDkHZQ1AXET0IZs9eskEjshcH/4Esufjj4oJIIAjuQdBcpEFyMIdl8SKIkEXEk+KoeJGQXURQRIka9RCJa1W915np6qoHb4nx4jtkuqvep771Y6en0zM4/DDwAtzVXzddvQ3TzMZ8AmfNYAkNh0gVYmvcWiK/9IMR/YeGeBrobQLfPPNUq3li+75lZsOLNiF7s4jexfMrOGT+cZCGtcoLr3oEF+ItW8MhElkRIV6tk27WS+++oYFw7jbLIsTGRCFz61LbHsOXreaJ7StT71GbwIcjIIu4guJPlMuWCGlIPOXrbpdLDsGFzH+m9tMp22wNh0hkRYR4tUqyWeUenh1qItksiwg2bm+Y2zm6uO2g0M0LtmKxpUfbK5Mof7w6oqAZBH4GPgVO2hohnvK9BjxpE6BCrmzdUPtrm6XhEX5WTARvUybdrEMjLOw0AaSbZRHBxu0Nc1sCZvcwrwsOtlLrsXxn3SSAe2huWcRHwNUVXFY1RY0QT/neBi6NTAJUCKZ0GbXN0vAIPysmgreZVrpZCwMc+r0J0FmqWRYRbNxemVtvANyxh5m/VOBoe0SZ+fSMTcQ+5xDHRzy37pCCqkUa5tz+Bk5vozskr1pciD+37pC8anmEnxUTwdsMlW5W94Y3NzjNsohoI6Lgz7epCtitMPNrM5PatqbMfHrEJmKfswjgwRGKioKqRRrW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L0W8dKaQSiz3ITqy5E23nL7SAOUHp+s5iguR2+9//fKUyMfuLw7MTxxOF//KMO/mXD1NHhPwrjTLx3gTLSAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\left [ \\left ( 0, \\quad 0\\right ), \\quad \\left ( 0, \\quad 1\\right ), \\quad \\left ( 0, \\quad 2\\right ), \\quad \\left ( 1, \\quad 0\\right ), \\quad \\left ( 1, \\quad 1\\right ), \\quad \\left ( 1, \\quad 2\\right ), \\quad \\left ( 2, \\quad 0\\right ), \\quad \\left ( 2, \\quad 1\\right ), \\quad \\left ( 2, \\quad 2\\right )\\right ]$$"
      ],
      "text/plain": [
       "[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from lbmpy.moments import moment_matrix, moments_up_to_component_order, exponents_to_polynomial_representations\n",
    "moment_exponents = list(moments_up_to_component_order(2, 2))\n",
    "moment_exponents"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcgAAAAcBAMAAAAXVzJUAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAMkS7zRCZdiKJ71Rmq90icBAQAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADq0lEQVRYCd2YMWgTYRTHX9JemkvSWMS9cRIHaUDUqZhdCjcImUorjXRRzJSiIA26qdBM1TGLOLbo1g7e5CAIgkUQB1HQOoioWBQU4ve978p39937I3djbvjy+P/e/7333XdpkxBlvjbPBpk92OCvXAYQ98GES1lsI9ADyX5/uoVYDv0B7cku3AcTrmSxjeio3ASp9X7hN2I59M802xdtuA8mXMhijrpaLDTFHlCsN8o/IMwOPtBGQ3ThPphwIYs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y, \\quad x y^{2}, \\quad x^{2}, \\quad x^{2} y, \\quad x^{2} y^{2}\\right )$$"
      ],
      "text/plain": [
       "⎛       2             2   2   2     2  2⎞\n",
       "⎝1, y, y , x, x⋅y, x⋅y , x , x ⋅y, x ⋅y ⎠"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "moments = exponents_to_polynomial_representations(moment_exponents)\n",
    "moments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAF5CAYAAABqT9akAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzt3Xl0XmWB+PHvk3RNW8qSUspSoQUXBAb0yCIiKG4BfwPiyDAyqIgL6igj6oz83BiP4CAyqHUZF9zBUWdk9PAjIgdQUFxREXcQKhRa2hRaupckz++PN2+bpHmTd73r93MOp+TNvW+eP27eb+597hJijEiSNJGutAcgScouIyFJqmlaUj8o9A90Ay8ATgDmAaHGohFYB3w/9vXelNDwpJpC/8BM4FTgWGA2brvKidA/0AO8GDgamDXJohFYC9wc+3pvHfMeSc1JhP6By4DTG1zti7Gv94OdGI9Uj5E/bq4Cjmtw1S/Fvt5LOzAkqS4jf9x8GTiywVWXxb7ej1e/SORwU+gfWEzjgQA4J/QP7NHu8UgNOJrGAwHwj6F/YM92D0ZqwIk0HgiA14b+gdnVL5Kak/ibJtfrBg5v50CkBrWy7R7WzoFIDWp2250FPLn6RVKRmJnSulKr3HaVVzNaWHfHtpvYxPWELnzRAdxz1yy6uytf77H3IJ//xX2pjkmayjeX7c4t35zPintmcNwpG7joc6vSHpLUkO9dM4+vX7kXa1dNZ/5eg1zwkVU87aQtEy2abiQA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152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from lbmpy.stencils import get_stencil\n",
    "d2q9 = get_stencil(\"D2Q9\", ordering='walberla')\n",
    "visualize_stencil(d2q9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWQAAADgCAMAAAADk+xoAAAAP1BMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADFBd4eAAAAFHRSTlMAMquZdlQQQO0wRO/NZondIrt8bFiOv0QAAAAJcEhZcwAADsQAAA7EAZUrDhsAAA0ZSURBVHgB7Z1tW9vYDkXDa2daoO29+f+/dXxsdiIlsvfWE6XJDOLDHGMtbx0vQmCCCruH/fz2uOu3cgM/F7e73cP+6Xl6eynv0IG792H2cT8kP7SOaxp4b8nX1Ltkn0p++fG61ZSUcamIJXE1VeRqsa17cZJfH58e9+uSSRltRCyJq6kiV4uRe3GSJ/Z5QzIvoxlJAYZVxEWM3cOVun7GRptsyXC+tkbW1tjpfIS35A1hcymytnFNhLfkDWEteV1O9GAK6FoMDaLUfiTDztoaWVtjp/MR3pI3hM2lyNrGNRHekjeEteR1OdGDKaBrMTSIUvuRDDtra2RtjZ3OR7iX/PT4Y//2+L6WQcq4TMSSuJoqcrXY9r14yWB7LTXQkkt1xmEtOfZSerYll+qMw1py7KX0bEsu1RmHteTYS+nZllyqMw5rybGX0rMtuVRnHNaSYy+lZ73k16eP948/PU4kNhWxUjtFYV7y2zQP9/rz13q2OBCCAAmnTZc0EZtgqauMpe4FsE93kt9/DOjj7Yi6I3EgBNeIOGmKNBHbiV1FDN0vw53k3/P07MvGfEv0aik2EqwKzpvOwSI2WKWrjs3dL8Od5P0s+ft+fYhW3H9mY7zpnCZigxU3KWKZewF7sgkr+XX/NKjv+2cD+8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KRB0iVi15+Yb/X/+bW0R7IlYt+TbDLeLfGxKxu38k32a4RZyFEbHi4RY8ji8acnHPyUjstdZAS671Gaa15FBL7cmWXOszTGvJoZbaky251meY1pJDLbUnW3KtzzCtJYdaak+25FqfYVpLDrXUnvSSyQAJKWNnIpbEk6lIv4fVSyYDJKSM+xGxJK6nimMotRjuJkp1kskACSmjjYglcTVVnFqpxXAvK6lOMhkgIWV0ErEknkgVX42vxXA7UaqTTAZISBltRCyJJ1Kj+0Q3s9ZiCI5SrWTyE2FSRhcRS+KZ1Og+0c6stRiCo1QrmQyQkDK6iFgSz6RG94l2Zq3FEBylesk93AJXxzWydqyeHUW4lUw+JUkZ7UQsiWdSo/tEO7PWYgiOUq3k3fLFpYdbIGxeI2sO8O9EuJNMBkhIGc1ELIknUqP7RDez1mIIjlKd5OUb/h5ugbB5jaw5wL8T4U5yD7d4YdeRTAZISBk7FLEkrqaKYyi1GO4lTvWPZLC9lhpoyaU647CWHHspPduSS3XGYS059lJ6dpG8H2+PpcEdNhv4Oaud/6Ty83j73l7qDbzPap93/wAdke0u6RSmcAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left[\\begin{matrix}1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\\\0 & 1 & -1 & 0 & 0 & 1 & 1 & -1 & -1\\\\0 & 1 & 1 & 0 & 0 & 1 & 1 & 1 & 1\\\\0 & 0 & 0 & -1 & 1 & -1 & 1 & -1 & 1\\\\0 & 0 & 0 & 0 & 0 & -1 & 1 & 1 & -1\\\\0 & 0 & 0 & 0 & 0 & -1 & 1 & -1 & 1\\\\0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1\\\\0 & 0 & 0 & 0 & 0 & 1 & 1 & -1 & -1\\\\0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡1  1  1   1   1  1   1  1   1 ⎤\n",
       "⎢                              ⎥\n",
       "⎢0  1  -1  0   0  1   1  -1  -1⎥\n",
       "⎢                              ⎥\n",
       "⎢0  1  1   0   0  1   1  1   1 ⎥\n",
       "⎢                              ⎥\n",
       "⎢0  0  0   -1  1  -1  1  -1  1 ⎥\n",
       "⎢                              ⎥\n",
       "⎢0  0  0   0   0  -1  1  1   -1⎥\n",
       "⎢                              ⎥\n",
       "⎢0  0  0   0   0  -1  1  -1  1 ⎥\n",
       "⎢                              ⎥\n",
       "⎢0  0  0   1   1  1   1  1   1 ⎥\n",
       "⎢                              ⎥\n",
       "⎢0  0  0   0   0  1   1  -1  -1⎥\n",
       "⎢                              ⎥\n",
       "⎣0  0  0   0   0  1   1  1   1 ⎦"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "M = moment_matrix(moments, stencil=d2q9)\n",
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAByMAAAA0BAMAAADbH4nKAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMA74lUMhAiZrvNmd12RKuJdf+/AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAUVUlEQVR4Ae1da4wkVRU+0z3VPTPdszOKiugijUaj6ypDfMRE43Qi/sAfTq9RIwHZAo0Q0cxgIsRXGN+IDybRqCOKLdHIQ2HwAYqoDeoPNoQZjDHxlR2JmqBENyLra2E891H3Vefc6p5amW22K9muc8859zv3fqdu163qe2cBRseIgREDAzNQufZrsToF5ljVkW3EwIiBbTDwLLg/VqvAHKsKp2z9PWofGUcMPPYZeN7AXbwFFtJIpQJzWDPZVJrK1tYsnHDGK0P7qDxi4PhioNIduL8/hMWNSKUCc67mr5QmOeMVs/CEnHWkGDFwnDHw/O30d74TrVVgDurWV7RifDQkA2pGxeOQgeoTt9Pp2+OVCsxh5Q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zAKfcwwcOOOt6S+rJuAQ/KEM1654+0ZNWDEwI4ysKu3o+Ex+K9UA5IzXjELp2xRfztxp1s4ij9i4NFkIPLe5VFpRvJHFaaytTX7PwyjZRSUjSEVAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\left [ \\left ( 1, \\quad \\rho, \\quad \\omega\\right ), \\quad \\left ( y, \\quad \\rho u_{1}, \\quad \\omega\\right ), \\quad \\left ( y^{2}, \\quad \\rho u_{1}^{2} + \\frac{\\rho}{3}, \\quad \\omega\\right ), \\quad \\left ( x, \\quad \\rho u_{0}, \\quad \\omega\\right ), \\quad \\left ( x y, \\quad \\rho u_{0} u_{1}, \\quad \\omega\\right ), \\quad \\left ( x y^{2}, \\quad \\frac{\\rho u_{0}}{3}, \\quad \\omega\\right ), \\quad \\left ( x^{2}, \\quad \\rho u_{0}^{2} + \\frac{\\rho}{3}, \\quad \\omega\\right ), \\quad \\left ( x^{2} y, \\quad \\frac{\\rho u_{1}}{3}, \\quad \\omega\\right ), \\quad \\left ( x^{2} y^{2}, \\quad \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}, \\quad \\omega\\right )\\right ]$$"
      ],
      "text/plain": [
       "⎡                                                                             \n",
       "⎢                         ⎛ 2      2   ρ   ⎞                                  \n",
       "⎢(1, ρ, ω), (y, ρ⋅u₁, ω), ⎜y , ρ⋅u₁  + ─, ω⎟, (x, ρ⋅u₀, ω), (x⋅y, ρ⋅u₀⋅u₁, ω),\n",
       "⎣                         ⎝            3   ⎠                                  \n",
       "\n",
       "                                                       ⎛           2       2  \n",
       " ⎛   2  ρ⋅u₀   ⎞  ⎛ 2      2   ρ   ⎞  ⎛ 2    ρ⋅u₁   ⎞  ⎜ 2  2  ρ⋅u₀    ρ⋅u₁   \n",
       " ⎜x⋅y , ────, ω⎟, ⎜x , ρ⋅u₀  + ─, ω⎟, ⎜x ⋅y, ────, ω⎟, ⎜x ⋅y , ───── + ───── +\n",
       " ⎝       3     ⎠  ⎝            3   ⎠  ⎝       3     ⎠  ⎝         3       3    \n",
       "\n",
       "     ⎞⎤\n",
       " ρ   ⎟⎥\n",
       " ─, ω⎟⎥\n",
       " 9   ⎠⎦"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from lbmpy.maxwellian_equilibrium import get_moments_of_continuous_maxwellian_equilibrium\n",
    "\n",
    "eq_moments = get_moments_of_continuous_maxwellian_equilibrium(moments, order=2, dim=2, \n",
    "                                                              c_s_sq=sp.Rational(1, 3))\n",
    "omega = sp.symbols(\"omega\")\n",
    "relaxation_info = [(moment, eq_value, omega) for moment, eq_value in zip(moments, eq_moments)]\n",
    "relaxation_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <table style=\"border:none; width: 100%\">\n",
       "            <tr style=\"border:none\">\n",
       "                <th style=\"border:none\" >Moment</th>\n",
       "                <th style=\"border:none\" >Eq. Value </th>\n",
       "                <th style=\"border:none\" >Relaxation Rate</th>\n",
       "            </tr>\n",
       "            <tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$1$</td>\n",
       "                            <td style=\"border:none\">$\\rho$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$y$</td>\n",
       "                            <td style=\"border:none\">$\\rho u_{1}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$y^{2}$</td>\n",
       "                            <td style=\"border:none\">$\\rho u_{1}^{2} + \\frac{\\rho}{3}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$x$</td>\n",
       "                            <td style=\"border:none\">$\\rho u_{0}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$x y$</td>\n",
       "                            <td style=\"border:none\">$\\rho u_{0} u_{1}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$x y^{2}$</td>\n",
       "                            <td style=\"border:none\">$\\frac{\\rho u_{0}}{3}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$x^{2}$</td>\n",
       "                            <td style=\"border:none\">$\\rho u_{0}^{2} + \\frac{\\rho}{3}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$x^{2} y$</td>\n",
       "                            <td style=\"border:none\">$\\frac{\\rho u_{1}}{3}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "<tr style=\"border:none\">\n",
       "                            <td style=\"border:none\">$x^{2} y^{2}$</td>\n",
       "                            <td style=\"border:none\">$\\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}$</td>\n",
       "                            <td style=\"border:none\">$\\omega$</td>\n",
       "                         </tr>\n",
       "\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<lbmpy.methods.momentbased.MomentBasedLbMethod at 0x7fd077d75828>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from lbmpy.methods.creationfunctions import create_generic_mrt\n",
    "\n",
    "force_model = forcemodels.Guo(sp.symbols(\"F_:2\"))\n",
    "method = create_generic_mrt(d2q9, relaxation_info, compressible=False, force_model=force_model, cumulant=False)\n",
    "method"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example of a update equation without simplifications"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>Subexpressions:</div><table style=\"border:none; width: 100%; \"><tr style=\"border:none\"> <td style=\"border:none\">$$vel0Term \\leftarrow f_{4} + f_{6} + f_{8}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$vel1Term \\leftarrow f_{1} + f_{5}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$\\rho \\leftarrow f_{0} + f_{2} + f_{3} + f_{7} + vel0Term + vel1Term$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$u_{0} \\leftarrow \\frac{F_{0}}{2} - f_{3} - f_{5} - f_{7} + vel0Term$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$u_{1} \\leftarrow \\frac{F_{1}}{2} - f_{2} + f_{6} - f_{7} - f_{8} + vel1Term$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{0} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(- \\frac{4 F_{0} u_{0}}{3} - \\frac{4 F_{1} u_{1}}{3}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{1} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(- \\frac{F_{0} u_{0}}{3} + \\frac{F_{1} \\left(2 u_{1} + 1\\right)}{3}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{2} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(- \\frac{F_{0} u_{0}}{3} + \\frac{F_{1} \\left(2 u_{1} - 1\\right)}{3}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{3} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(\\frac{F_{0} \\left(2 u_{0} - 1\\right)}{3} - \\frac{F_{1} u_{1}}{3}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{4} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(\\frac{F_{0} \\left(2 u_{0} + 1\\right)}{3} - \\frac{F_{1} u_{1}}{3}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{5} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(\\frac{F_{0} \\left(2 u_{0} - 3 u_{1} - 1\\right)}{12} + \\frac{F_{1} \\left(- 3 u_{0} + 2 u_{1} + 1\\right)}{12}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{6} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(\\frac{F_{0} \\left(2 u_{0} + 3 u_{1} + 1\\right)}{12} + \\frac{F_{1} \\left(3 u_{0} + 2 u_{1} + 1\\right)}{12}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{7} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(\\frac{F_{0} \\left(2 u_{0} + 3 u_{1} - 1\\right)}{12} + \\frac{F_{1} \\left(3 u_{0} + 2 u_{1} - 1\\right)}{12}\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$forceTerm_{8} \\leftarrow \\left(- \\frac{\\omega}{2} + 1\\right) \\left(\\frac{F_{0} \\left(2 u_{0} - 3 u_{1} + 1\\right)}{12} + \\frac{F_{1} \\left(- 3 u_{0} + 2 u_{1} - 1\\right)}{12}\\right)$$</td>  </tr> </table><div>Main Assignments:</div><table style=\"border:none; width: 100%; \"><tr style=\"border:none\"> <td style=\"border:none\">$$d_{0} \\leftarrow f_{0} + forceTerm_{0} + \\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right) - \\omega \\left(- f_{1} - f_{2} - f_{5} - f_{6} - f_{7} - f_{8} + \\rho u_{1}^{2} + \\frac{\\rho}{3}\\right) - \\omega \\left(- f_{3} - f_{4} - f_{5} - f_{6} - f_{7} - f_{8} + \\rho u_{0}^{2} + \\frac{\\rho}{3}\\right) + \\omega \\left(- f_{0} - f_{1} - f_{2} - f_{3} - f_{4} - f_{5} - f_{6} - f_{7} - f_{8} + \\rho\\right)$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{1} \\leftarrow f_{1} + forceTerm_{1} - \\frac{\\omega \\left(- f_{5} - f_{6} + f_{7} + f_{8} + \\frac{\\rho u_{1}}{3}\\right)}{2} + \\frac{\\omega \\left(- f_{1} + f_{2} - f_{5} - f_{6} + f_{7} + f_{8} + \\rho u_{1}\\right)}{2} - \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{2} + \\frac{\\omega \\left(- f_{1} - f_{2} - f_{5} - f_{6} - f_{7} - f_{8} + \\rho u_{1}^{2} + \\frac{\\rho}{3}\\right)}{2}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{2} \\leftarrow f_{2} + forceTerm_{2} + \\frac{\\omega \\left(- f_{5} - f_{6} + f_{7} + f_{8} + \\frac{\\rho u_{1}}{3}\\right)}{2} - \\frac{\\omega \\left(- f_{1} + f_{2} - f_{5} - f_{6} + f_{7} + f_{8} + \\rho u_{1}\\right)}{2} - \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{2} + \\frac{\\omega \\left(- f_{1} - f_{2} - f_{5} - f_{6} - f_{7} - f_{8} + \\rho u_{1}^{2} + \\frac{\\rho}{3}\\right)}{2}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{3} \\leftarrow f_{3} + forceTerm_{3} + \\frac{\\omega \\left(f_{5} - f_{6} + f_{7} - f_{8} + \\frac{\\rho u_{0}}{3}\\right)}{2} - \\frac{\\omega \\left(f_{3} - f_{4} + f_{5} - f_{6} + f_{7} - f_{8} + \\rho u_{0}\\right)}{2} - \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{2} + \\frac{\\omega \\left(- f_{3} - f_{4} - f_{5} - f_{6} - f_{7} - f_{8} + \\rho u_{0}^{2} + \\frac{\\rho}{3}\\right)}{2}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{4} \\leftarrow f_{4} + forceTerm_{4} - \\frac{\\omega \\left(f_{5} - f_{6} + f_{7} - f_{8} + \\frac{\\rho u_{0}}{3}\\right)}{2} + \\frac{\\omega \\left(f_{3} - f_{4} + f_{5} - f_{6} + f_{7} - f_{8} + \\rho u_{0}\\right)}{2} - \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{2} + \\frac{\\omega \\left(- f_{3} - f_{4} - f_{5} - f_{6} - f_{7} - f_{8} + \\rho u_{0}^{2} + \\frac{\\rho}{3}\\right)}{2}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{5} \\leftarrow f_{5} + forceTerm_{5} + \\frac{\\omega \\left(- f_{5} - f_{6} + f_{7} + f_{8} + \\frac{\\rho u_{1}}{3}\\right)}{4} - \\frac{\\omega \\left(f_{5} - f_{6} - f_{7} + f_{8} + \\rho u_{0} u_{1}\\right)}{4} - \\frac{\\omega \\left(f_{5} - f_{6} + f_{7} - f_{8} + \\frac{\\rho u_{0}}{3}\\right)}{4} + \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{4}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{6} \\leftarrow f_{6} + forceTerm_{6} + \\frac{\\omega \\left(- f_{5} - f_{6} + f_{7} + f_{8} + \\frac{\\rho u_{1}}{3}\\right)}{4} + \\frac{\\omega \\left(f_{5} - f_{6} - f_{7} + f_{8} + \\rho u_{0} u_{1}\\right)}{4} + \\frac{\\omega \\left(f_{5} - f_{6} + f_{7} - f_{8} + \\frac{\\rho u_{0}}{3}\\right)}{4} + \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{4}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} - \\frac{\\omega \\left(- f_{5} - f_{6} + f_{7} + f_{8} + \\frac{\\rho u_{1}}{3}\\right)}{4} + \\frac{\\omega \\left(f_{5} - f_{6} - f_{7} + f_{8} + \\rho u_{0} u_{1}\\right)}{4} - \\frac{\\omega \\left(f_{5} - f_{6} + f_{7} - f_{8} + \\frac{\\rho u_{0}}{3}\\right)}{4} + \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{4}$$</td>  </tr> <tr style=\"border:none\"> <td style=\"border:none\">$$d_{8} \\leftarrow f_{8} + forceTerm_{8} - \\frac{\\omega \\left(- f_{5} - f_{6} + f_{7} + f_{8} + \\frac{\\rho u_{1}}{3}\\right)}{4} - \\frac{\\omega \\left(f_{5} - f_{6} - f_{7} + f_{8} + \\rho u_{0} u_{1}\\right)}{4} + \\frac{\\omega \\left(f_{5} - f_{6} + f_{7} - f_{8} + \\frac{\\rho u_{0}}{3}\\right)}{4} + \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{4}$$</td>  </tr> </table>"
      ],
      "text/plain": [
       "Equation Collection for d_0,d_1,d_2,d_3,d_4,d_5,d_6,d_7,d_8"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "collision_rule = method.get_collision_rule()\n",
    "collision_rule"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Generic simplification strategy - common subexpresssion elimination"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table style=\"border:none\"><tr><th>Name</th><th>Runtime</th><th>Adds</th><th>Muls</th><th>Divs</th><th>Total</th></tr><tr><td>OriginalTerm</td><td>-</td> <td>293</td> <td>261</td> <td>0</td>  <td>554</td> </tr><tr><td>sympy_cse</td><td>61.27 ms</td> <td>114</td> <td>67</td> <td>0</td>  <td>181</td> </tr></table>"
      ],
      "text/plain": [
       "<pystencils.simp.simplificationstrategy.SimplificationStrategy.create_simplification_report.<locals>.Report at 0x7fd077bef438>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "generic_strategy = ps.simp.SimplificationStrategy()\n",
    "generic_strategy.add(ps.simp.sympy_cse)\n",
    "generic_strategy.create_simplification_report(collision_rule)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### A custom simplification strategy for moment-based methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table style=\"border:none\"><tr><th>Name</th><th>Runtime</th><th>Adds</th><th>Muls</th><th>Divs</th><th>Total</th></tr><tr><td>OriginalTerm</td><td>-</td> <td>293</td> <td>261</td> <td>0</td>  <td>554</td> </tr><tr><td>expand</td><td>32.60 ms</td> <td>116</td> <td>227</td> <td>0</td>  <td>343</td> </tr><tr><td>replace_second_order_velocity_products</td><td>14.12 ms</td> <td>126</td> <td>235</td> <td>0</td>  <td>361</td> </tr><tr><td>expand</td><td>10.95 ms</td> <td>118</td> <td>227</td> <td>0</td>  <td>345</td> </tr><tr><td>factor_relaxation_rates</td><td>15.49 ms</td> <td>118</td> <td>184</td> <td>0</td>  <td>302</td> </tr><tr><td>replace_density_and_velocity</td><td>5.22 ms</td> <td>118</td> <td>184</td> <td>0</td>  <td>302</td> </tr><tr><td>replace_common_quadratic_and_constant_term</td><td>21.72 ms</td> <td>106</td> <td>148</td> <td>0</td>  <td>254</td> </tr><tr><td>factor_density_after_factoring_relaxation_times</td><td>15.14 ms</td> <td>106</td> <td>136</td> <td>0</td>  <td>242</td> </tr><tr><td>subexpression_substitution_in_main_assignments</td><td>12.94 ms</td> <td>102</td> <td>132</td> <td>0</td>  <td>234</td> </tr><tr><td>add_subexpressions_for_divisions</td><td>4.48 ms</td> <td>102</td> <td>132</td> <td>0</td>  <td>234</td> </tr><tr><td>cse_in_opposing_directions</td><td>12.80 ms</td> <td>102</td> <td>116</td> <td>0</td>  <td>218</td> </tr><tr><td>sympy_cse</td><td>42.44 ms</td> <td>86</td> <td>73</td> <td>0</td>  <td>159</td> </tr></table>"
      ],
      "text/plain": [
       "<pystencils.simp.simplificationstrategy.SimplificationStrategy.create_simplification_report.<locals>.Report at 0x7fd077c7d080>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplification_strategy = create_simplification_strategy(method, cse_pdfs=True, cse_global=True)\n",
    "simplification_strategy.create_simplification_report(collision_rule)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Seeing the simplification in action"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<h5 style=\"padding-bottom:10px\">Initial Version</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} - \\frac{\\omega \\left(- f_{5} - f_{6} + f_{7} + f_{8} + \\frac{\\rho u_{1}}{3}\\right)}{4} + \\frac{\\omega \\left(f_{5} - f_{6} - f_{7} + f_{8} + \\rho u_{0} u_{1}\\right)}{4} - \\frac{\\omega \\left(f_{5} - f_{6} + f_{7} - f_{8} + \\frac{\\rho u_{0}}{3}\\right)}{4} + \\frac{\\omega \\left(- f_{5} - f_{6} - f_{7} - f_{8} + \\frac{\\rho u_{0}^{2}}{3} + \\frac{\\rho u_{1}^{2}}{3} + \\frac{\\rho}{9}\\right)}{4}$$</div><h5 style=\"padding-bottom:10px\">expand</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow - f_{7} \\omega + f_{7} + forceTerm_{7} + \\frac{\\omega \\rho u_{0}^{2}}{12} + \\frac{\\omega \\rho u_{0} u_{1}}{4} - \\frac{\\omega \\rho u_{0}}{12} + \\frac{\\omega \\rho u_{1}^{2}}{12} - \\frac{\\omega \\rho u_{1}}{12} + \\frac{\\omega \\rho}{36}$$</div><h5 style=\"padding-bottom:10px\">replace_second_order_velocity_products</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow - f_{7} \\omega + f_{7} + forceTerm_{7} + \\frac{\\omega \\rho u_{0}^{2}}{12} - \\frac{\\omega \\rho u_{0}}{12} + \\frac{\\omega \\rho u_{1}^{2}}{12} - \\frac{\\omega \\rho u_{1}}{12} + \\frac{\\omega \\rho \\left(u0Pu1^{2} - u_{0}^{2} - u_{1}^{2}\\right)}{8} + \\frac{\\omega \\rho}{36}$$</div><h5 style=\"padding-bottom:10px\">expand</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow - f_{7} \\omega + f_{7} + forceTerm_{7} + \\frac{\\omega \\rho u0Pu1^{2}}{8} - \\frac{\\omega \\rho u_{0}^{2}}{24} - \\frac{\\omega \\rho u_{0}}{12} - \\frac{\\omega \\rho u_{1}^{2}}{24} - \\frac{\\omega \\rho u_{1}}{12} + \\frac{\\omega \\rho}{36}$$</div><h5 style=\"padding-bottom:10px\">factor_relaxation_rates</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(- f_{7} + \\frac{\\rho u0Pu1^{2}}{8} - \\frac{\\rho u_{0}^{2}}{24} - \\frac{\\rho u_{0}}{12} - \\frac{\\rho u_{1}^{2}}{24} - \\frac{\\rho u_{1}}{12} + \\frac{\\rho}{36}\\right)$$</div><h5 style=\"padding-bottom:10px\">replace_density_and_velocity</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(- f_{7} + \\frac{\\rho u0Pu1^{2}}{8} - \\frac{\\rho u_{0}^{2}}{24} - \\frac{\\rho u_{0}}{12} - \\frac{\\rho u_{1}^{2}}{24} - \\frac{\\rho u_{1}}{12} + \\frac{\\rho}{36}\\right)$$</div><h5 style=\"padding-bottom:10px\">replace_common_quadratic_and_constant_term</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(- f_{7} + \\frac{f_{eq common}}{36} + \\frac{\\rho u0Pu1^{2}}{8} - \\frac{\\rho u_{0}}{12} - \\frac{\\rho u_{1}}{12}\\right)$$</div><h5 style=\"padding-bottom:10px\">factor_density_after_factoring_relaxation_times</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(- f_{7} + \\frac{f_{eq common}}{36} + \\rho \\left(\\frac{u0Pu1^{2}}{8} - \\frac{u_{0}}{12} - \\frac{u_{1}}{12}\\right)\\right)$$</div><h5 style=\"padding-bottom:10px\">subexpression_substitution_in_main_assignments</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(- f_{7} + \\frac{f_{eq common}}{36} + \\rho \\left(\\frac{u0Pu1^{2}}{8} - \\frac{u0Pu1}{12}\\right)\\right)$$</div><h5 style=\"padding-bottom:10px\">add_subexpressions_for_divisions</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(- f_{7} + \\frac{f_{eq common}}{36} + \\rho \\left(\\frac{u0Pu1^{2}}{8} - \\frac{u0Pu1}{12}\\right)\\right)$$</div><h5 style=\"padding-bottom:10px\">cse_in_opposing_directions</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(- f_{7} + \\rho \\left(- \\xi_{72} + \\xi_{73}\\right) + \\xi_{71}\\right)$$</div><h5 style=\"padding-bottom:10px\">sympy_cse</h5> <div style=\"padding-left:20px;\">$$d_{7} \\leftarrow f_{7} + forceTerm_{7} + \\omega \\left(\\rho \\left(- \\xi_{72} + \\xi_{73}\\right) + \\xi_{71} + \\xi_{76}\\right)$$</div>"
      ],
      "text/plain": [
       "<pystencils.simp.simplificationstrategy.SimplificationStrategy.show_intermediate_results.<locals>.IntermediateResults at 0x7fd077d6cef0>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplification_strategy.show_intermediate_results(collision_rule, symbols=[sp.Symbol(\"d_7\")])"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}