Skip to content

Commit 39b6e66

Browse files
committed
update before talk
1 parent 0129bd7 commit 39b6e66

3 files changed

Lines changed: 178 additions & 120 deletions

File tree

presentations/pyro_intro.ipynb

Lines changed: 178 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"source": [
4949
"## Design ideas:\n",
5050
"\n",
51+
" * _Clarity is emphasized over performance_\n",
52+
"\n",
5153
" * Single driver implements core evolution\n",
52-
" \n",
53-
" * Clarity is emphasized over performance\n",
54-
" \n",
54+
" \n",
5555
" * Object-oriented structure: each solver provides a simulation class to manage the different parts of the update\n",
5656
" \n",
5757
" * All solvers are 2-d: right balance of complexity and usefulness\n",
@@ -82,6 +82,20 @@
8282
" - _Nov 2018_: python + NumPy + Numba"
8383
]
8484
},
85+
{
86+
"cell_type": "markdown",
87+
"metadata": {
88+
"slideshow": {
89+
"slide_type": "slide"
90+
}
91+
},
92+
"source": [
93+
"## Our usage\n",
94+
"\n",
95+
" * We start new undergraduate researchers out with pyro to learn about simulation workflows\n",
96+
" * Typically have UG add a new problem setup"
97+
]
98+
},
8599
{
86100
"cell_type": "markdown",
87101
"metadata": {
@@ -143,6 +157,155 @@
143157
"</div>"
144158
]
145159
},
160+
{
161+
"cell_type": "markdown",
162+
"metadata": {
163+
"slideshow": {
164+
"slide_type": "slide"
165+
}
166+
},
167+
"source": [
168+
"## Grids\n",
169+
"\n",
170+
"* ``patch`` module manages grids and data that lives on them\n",
171+
"\n",
172+
"* Fills boundaries, does prolongation/restriction for multigrid\n",
173+
"\n",
174+
"* Many convenience functions"
175+
]
176+
},
177+
{
178+
"cell_type": "code",
179+
"execution_count": 1,
180+
"metadata": {
181+
"slideshow": {
182+
"slide_type": "skip"
183+
}
184+
},
185+
"outputs": [],
186+
"source": [
187+
"import mesh.patch as patch\n",
188+
"import mesh.boundary as bnd\n",
189+
"import numpy as np"
190+
]
191+
},
192+
{
193+
"cell_type": "code",
194+
"execution_count": 2,
195+
"metadata": {
196+
"slideshow": {
197+
"slide_type": "fragment"
198+
}
199+
},
200+
"outputs": [
201+
{
202+
"name": "stdout",
203+
"output_type": "stream",
204+
"text": [
205+
"2-d grid: nx = 16, ny = 16, ng = 2\n"
206+
]
207+
}
208+
],
209+
"source": [
210+
"g = patch.Grid2d(16, 16, ng=2)\n",
211+
"print(g)"
212+
]
213+
},
214+
{
215+
"cell_type": "code",
216+
"execution_count": 3,
217+
"metadata": {
218+
"slideshow": {
219+
"slide_type": "fragment"
220+
}
221+
},
222+
"outputs": [
223+
{
224+
"name": "stdout",
225+
"output_type": "stream",
226+
"text": [
227+
"BCs: -x: periodic +x: periodic -y: reflect-even +y: outflow\n"
228+
]
229+
}
230+
],
231+
"source": [
232+
"bc = bnd.BC(xlb=\"periodic\", xrb=\"periodic\", ylb=\"reflect\", yrb=\"outflow\")\n",
233+
"print(bc)"
234+
]
235+
},
236+
{
237+
"cell_type": "code",
238+
"execution_count": 4,
239+
"metadata": {
240+
"slideshow": {
241+
"slide_type": "fragment"
242+
}
243+
},
244+
"outputs": [
245+
{
246+
"name": "stdout",
247+
"output_type": "stream",
248+
"text": [
249+
"cc data: nx = 16, ny = 16, ng = 2\n",
250+
" nvars = 1\n",
251+
" variables:\n",
252+
" a: min: 0.0000000000 max: 0.0000000000\n",
253+
" BCs: -x: periodic +x: periodic -y: reflect-even +y: outflow \n",
254+
"\n"
255+
]
256+
}
257+
],
258+
"source": [
259+
"d = patch.CellCenterData2d(g)\n",
260+
"d.register_var(\"a\", bc)\n",
261+
"d.create()\n",
262+
"print(d)"
263+
]
264+
},
265+
{
266+
"cell_type": "markdown",
267+
"metadata": {
268+
"slideshow": {
269+
"slide_type": "slide"
270+
}
271+
},
272+
"source": [
273+
"## Grids"
274+
]
275+
},
276+
{
277+
"cell_type": "code",
278+
"execution_count": 5,
279+
"metadata": {
280+
"slideshow": {
281+
"slide_type": "fragment"
282+
}
283+
},
284+
"outputs": [],
285+
"source": [
286+
"a = d.get_var(\"a\")"
287+
]
288+
},
289+
{
290+
"cell_type": "markdown",
291+
"metadata": {},
292+
"source": [
293+
"Data is stored as an ``ArrayIndexer`` object, which makes it easy to implement differencing on the entire array.\n",
294+
"\n",
295+
"To implement:\n",
296+
"$$ b = \\frac{a_{i+1,j} - a_{i-1,j}}{2 \\Delta x}$$"
297+
]
298+
},
299+
{
300+
"cell_type": "code",
301+
"execution_count": 6,
302+
"metadata": {},
303+
"outputs": [],
304+
"source": [
305+
"b = g.scratch_array()\n",
306+
"b.v()[:,:] = (a.ip(1) - a.ip(-1))/(2.0*a.g.dx)"
307+
]
308+
},
146309
{
147310
"cell_type": "markdown",
148311
"metadata": {
@@ -153,6 +316,8 @@
153316
"source": [
154317
"## Running\n",
155318
"\n",
319+
"* Each solver has a collection of problem setups (initial conditions) and inputs files\n",
320+
"\n",
156321
"* Commandline:\n",
157322
"\n",
158323
" ```\n",
@@ -175,7 +340,7 @@
175340
},
176341
{
177342
"cell_type": "code",
178-
"execution_count": 1,
343+
"execution_count": 7,
179344
"metadata": {
180345
"slideshow": {
181346
"slide_type": "fragment"
@@ -213,16 +378,16 @@
213378
"\u001b[33mparameter vis.store_images never used\u001b[0m\n",
214379
"\u001b[33mparameter particles.n_particles never used\u001b[0m\n",
215380
"\u001b[33mparameter particles.particle_generator never used\u001b[0m\n",
216-
"main: 0.08537530899047852\n"
381+
"main: 0.18631219863891602\n"
217382
]
218383
},
219384
{
220385
"data": {
221386
"text/plain": [
222-
"<advection.simulation.Simulation at 0x7f9c1829df10>"
387+
"<advection.simulation.Simulation at 0x7fc0a799b910>"
223388
]
224389
},
225-
"execution_count": 1,
390+
"execution_count": 7,
226391
"metadata": {},
227392
"output_type": "execute_result"
228393
}
@@ -249,7 +414,7 @@
249414
},
250415
{
251416
"cell_type": "code",
252-
"execution_count": 2,
417+
"execution_count": 8,
253418
"metadata": {
254419
"slideshow": {
255420
"slide_type": "fragment"
@@ -302,7 +467,7 @@
302467
},
303468
{
304469
"cell_type": "code",
305-
"execution_count": 3,
470+
"execution_count": 9,
306471
"metadata": {
307472
"slideshow": {
308473
"slide_type": "fragment"
@@ -343,84 +508,9 @@
343508
}
344509
},
345510
"source": [
346-
"## Grids"
347-
]
348-
},
349-
{
350-
"cell_type": "code",
351-
"execution_count": 4,
352-
"metadata": {
353-
"slideshow": {
354-
"slide_type": "fragment"
355-
}
356-
},
357-
"outputs": [
358-
{
359-
"name": "stdout",
360-
"output_type": "stream",
361-
"text": [
362-
"2-d grid: nx = 16, ny = 16, ng = 2\n"
363-
]
364-
}
365-
],
366-
"source": [
367-
"import mesh.patch as patch\n",
368-
"import mesh.boundary as bnd\n",
369-
"import numpy as np\n",
511+
"## Other solvers\n",
370512
"\n",
371-
"g = patch.Grid2d(16, 16, ng=2)\n",
372-
"print(g)"
373-
]
374-
},
375-
{
376-
"cell_type": "code",
377-
"execution_count": 5,
378-
"metadata": {
379-
"slideshow": {
380-
"slide_type": "fragment"
381-
}
382-
},
383-
"outputs": [
384-
{
385-
"name": "stdout",
386-
"output_type": "stream",
387-
"text": [
388-
"BCs: -x: periodic +x: periodic -y: reflect-even +y: outflow\n"
389-
]
390-
}
391-
],
392-
"source": [
393-
"bc = bnd.BC(xlb=\"periodic\", xrb=\"periodic\", ylb=\"reflect\", yrb=\"outflow\")\n",
394-
"print(bc)"
395-
]
396-
},
397-
{
398-
"cell_type": "code",
399-
"execution_count": 6,
400-
"metadata": {
401-
"slideshow": {
402-
"slide_type": "fragment"
403-
}
404-
},
405-
"outputs": [
406-
{
407-
"name": "stdout",
408-
"output_type": "stream",
409-
"text": [
410-
"cc data: nx = 16, ny = 16, ng = 2\n",
411-
" nvars = 1\n",
412-
" variables:\n",
413-
" a: min: 0.0000000000 max: 0.0000000000\n",
414-
" BCs: -x: periodic +x: periodic -y: reflect-even +y: outflow \n",
415-
"\n"
416-
]
417-
}
418-
],
419-
"source": [
420-
"d = patch.CellCenterData2d(g)\n",
421-
"d.register_var(\"a\", bc)\n",
422-
"d.create()\n",
423-
"print(d)"
513+
"![compressible](quad.png) \n"
424514
]
425515
},
426516
{
@@ -431,41 +521,9 @@
431521
}
432522
},
433523
"source": [
434-
"## Grids"
435-
]
436-
},
437-
{
438-
"cell_type": "code",
439-
"execution_count": 7,
440-
"metadata": {
441-
"slideshow": {
442-
"slide_type": "fragment"
443-
}
444-
},
445-
"outputs": [],
446-
"source": [
447-
"a = d.get_var(\"a\")\n",
448-
"a.v()[:,:] = np.random.rand(g.nx, g.ny)"
449-
]
450-
},
451-
{
452-
"cell_type": "markdown",
453-
"metadata": {},
454-
"source": [
455-
"Data is stored as an ``ArrayIndexer`` object, which makes it easy to implement differencing on the entire array.\n",
524+
"## Other solvers\n",
456525
"\n",
457-
"To implement:\n",
458-
"$$ b = \\frac{a_{i+1,j} - a_{i-1,j}}{2 \\Delta x}$$"
459-
]
460-
},
461-
{
462-
"cell_type": "code",
463-
"execution_count": 8,
464-
"metadata": {},
465-
"outputs": [],
466-
"source": [
467-
"b = g.scratch_array()\n",
468-
"b.v()[:,:] = (a.ip(1) - a.ip(-1))/(2.0*a.g.dx)"
526+
"![incompressible](shear.png)"
469527
]
470528
},
471529
{

presentations/quad.png

93.2 KB
Loading

presentations/shear.png

111 KB
Loading

0 commit comments

Comments
 (0)