|
36 | 36 | "metadata": {}, |
37 | 37 | "source": [ |
38 | 38 | "## Create an idealised flow\n", |
39 | | - "Here, we create a 3D version of the Bickley Jet (see [Hadjighasem et al (2017)](https://aip.scitation.org/doi/10.1063/1.4982720) for details), where the velocities linearly decay with depth. In order to compute a settling velocity of plastic particles (via density differences), we create a spatially-uniform temperature and salinity field. We also include spatiotemporally varying wind, wave, and biogeochemical fields used for windage drift, Stokes drift, and biofouling kernels, respectively.\n", |
| 39 | + "Here, we create a 3D version of the Bickley Jet (see [Hadjighasem et al (2017)](https://aip.scitation.org/doi/10.1063/1.4982720) for details), where the velocities linearly decay with depth. In order to compute a settling velocity of plastic particles (via density differences), we create a spatially-uniform temperature and salinity field. We also include spatiotemporally varying wind, wave, and biogeochemical fields used for windage drift, Stokes drift, and biofouling kernels, respectively. We also include an 'unbeaching' field, where velocities along the top and bottom of the domain will 'kick-back' any particles that are advected across these two boundaries. The code to generate the idealised flow fields can be found in the `idealised_flow.py` file.\n", |
40 | 40 | "\n", |
41 | | - "Since the flow is periodic in the zonal direction, we write a custom zonal boundary conditions kernel to overwrite the `plasticparcels` periodic boundary condition kernel used for longitudinal coordinates. We also include an 'unbeaching' field, where velocities along the top and bottom of the domain will 'kick-back' any particles that are advected across these two boundaries. The code to generate the idealised flow fields can be found in the `example_idealised_flow_functions.py` file." |
| 41 | + "Since the flow is periodic in the zonal direction, we write a custom zonal boundary conditions kernel to overwrite the `plasticparcels` periodic boundary condition kernel used for longitudinal coordinates." |
42 | 42 | ] |
43 | 43 | }, |
44 | 44 | { |
|
47 | 47 | "metadata": {}, |
48 | 48 | "outputs": [], |
49 | 49 | "source": [ |
50 | | - "# Import functions to create the idealised flow fields\n", |
51 | | - "from example_idealised_flow_functions import bickleyjet_fieldset_3d, add_uniform_temp_salt_field, add_biogeochemistry_field, add_wind_field, add_stokes_field, ZonalBC\n", |
52 | | - "\n", |
53 | | - "# List of times the analytic fieldset is evaluated on\n", |
54 | | - "times = np.arange(0, 5.1, 0.1) * 86400\n", |
55 | | - "\n", |
56 | | - "# Create the fieldset\n", |
57 | | - "fieldset = bickleyjet_fieldset_3d(times=times)\n", |
58 | | - "fieldset = add_uniform_temp_salt_field(fieldset, times)\n", |
59 | | - "fieldset = add_biogeochemistry_field(fieldset, times)\n", |
60 | | - "fieldset = add_wind_field(fieldset, times)\n", |
61 | | - "fieldset = add_stokes_field(fieldset, times)\n", |
| 50 | + "# Load the fieldset\n", |
| 51 | + "fieldset = parcels.FieldSet.from_modulefile('idealised_flow.py')\n", |
62 | 52 | "\n", |
63 | 53 | "# Add a periodic halo in the zonal direction\n", |
64 | 54 | "fieldset.add_constant(\"halo_west\", fieldset.U.grid.lon[0])\n", |
65 | 55 | "fieldset.add_constant(\"halo_east\", fieldset.U.grid.lon[-1])\n", |
66 | 56 | "fieldset.add_periodic_halo(zonal=True)" |
67 | 57 | ] |
68 | 58 | }, |
| 59 | + { |
| 60 | + "cell_type": "code", |
| 61 | + "execution_count": 3, |
| 62 | + "metadata": {}, |
| 63 | + "outputs": [], |
| 64 | + "source": [ |
| 65 | + "# Define a custom kernel to handle the periodic boundary conditions\n", |
| 66 | + "def ZonalBC(particle, fieldset, time):\n", |
| 67 | + " if particle.lon < fieldset.halo_west:\n", |
| 68 | + " particle_dlon += fieldset.halo_east - fieldset.halo_west\n", |
| 69 | + " elif particle.lon > fieldset.halo_east:\n", |
| 70 | + " particle_dlon -= fieldset.halo_east - fieldset.halo_west" |
| 71 | + ] |
| 72 | + }, |
69 | 73 | { |
70 | 74 | "cell_type": "markdown", |
71 | 75 | "metadata": {}, |
|
76 | 80 | }, |
77 | 81 | { |
78 | 82 | "cell_type": "code", |
79 | | - "execution_count": 3, |
| 83 | + "execution_count": 4, |
80 | 84 | "metadata": {}, |
81 | 85 | "outputs": [ |
82 | 86 | { |
|
129 | 133 | }, |
130 | 134 | { |
131 | 135 | "cell_type": "code", |
132 | | - "execution_count": 4, |
| 136 | + "execution_count": 5, |
133 | 137 | "metadata": {}, |
134 | 138 | "outputs": [], |
135 | 139 | "source": [ |
|
187 | 191 | }, |
188 | 192 | { |
189 | 193 | "cell_type": "code", |
190 | | - "execution_count": 5, |
| 194 | + "execution_count": 6, |
191 | 195 | "metadata": {}, |
192 | 196 | "outputs": [], |
193 | 197 | "source": [ |
|
198 | 202 | }, |
199 | 203 | { |
200 | 204 | "cell_type": "code", |
201 | | - "execution_count": 6, |
| 205 | + "execution_count": 7, |
202 | 206 | "metadata": {}, |
203 | 207 | "outputs": [], |
204 | 208 | "source": [ |
|
210 | 214 | }, |
211 | 215 | { |
212 | 216 | "cell_type": "code", |
213 | | - "execution_count": 7, |
| 217 | + "execution_count": 8, |
214 | 218 | "metadata": {}, |
215 | 219 | "outputs": [], |
216 | 220 | "source": [ |
|
263 | 267 | }, |
264 | 268 | { |
265 | 269 | "cell_type": "code", |
266 | | - "execution_count": 8, |
| 270 | + "execution_count": 9, |
267 | 271 | "metadata": {}, |
268 | 272 | "outputs": [], |
269 | 273 | "source": [ |
|
278 | 282 | }, |
279 | 283 | { |
280 | 284 | "cell_type": "code", |
281 | | - "execution_count": 9, |
| 285 | + "execution_count": 10, |
282 | 286 | "metadata": {}, |
283 | 287 | "outputs": [], |
284 | 288 | "source": [ |
|
293 | 297 | }, |
294 | 298 | { |
295 | 299 | "cell_type": "code", |
296 | | - "execution_count": 10, |
| 300 | + "execution_count": 11, |
297 | 301 | "metadata": {}, |
298 | 302 | "outputs": [ |
299 | 303 | { |
300 | 304 | "name": "stdout", |
301 | 305 | "output_type": "stream", |
302 | 306 | "text": [ |
303 | 307 | "INFO: Output files are stored in example_idealised_flow_experiment_1.zarr.\n", |
304 | | - "100%|██████████| 345600.0/345600.0 [00:39<00:00, 8722.69it/s]\n" |
| 308 | + "100%|██████████| 345600.0/345600.0 [00:38<00:00, 9005.98it/s]\n" |
305 | 309 | ] |
306 | 310 | } |
307 | 311 | ], |
|
312 | 316 | }, |
313 | 317 | { |
314 | 318 | "cell_type": "code", |
315 | | - "execution_count": 11, |
| 319 | + "execution_count": 12, |
316 | 320 | "metadata": {}, |
317 | 321 | "outputs": [ |
318 | 322 | { |
|
342 | 346 | }, |
343 | 347 | { |
344 | 348 | "cell_type": "code", |
345 | | - "execution_count": 12, |
| 349 | + "execution_count": 13, |
346 | 350 | "metadata": {}, |
347 | 351 | "outputs": [], |
348 | 352 | "source": [ |
|
358 | 362 | }, |
359 | 363 | { |
360 | 364 | "cell_type": "code", |
361 | | - "execution_count": 13, |
| 365 | + "execution_count": 14, |
362 | 366 | "metadata": {}, |
363 | 367 | "outputs": [], |
364 | 368 | "source": [ |
|
373 | 377 | }, |
374 | 378 | { |
375 | 379 | "cell_type": "code", |
376 | | - "execution_count": 14, |
| 380 | + "execution_count": 15, |
377 | 381 | "metadata": {}, |
378 | 382 | "outputs": [ |
379 | 383 | { |
380 | 384 | "name": "stdout", |
381 | 385 | "output_type": "stream", |
382 | 386 | "text": [ |
383 | 387 | "INFO: Output files are stored in example_idealised_flow_experiment_2.zarr.\n", |
384 | | - "100%|██████████| 345600.0/345600.0 [00:49<00:00, 7022.17it/s]\n" |
| 388 | + "100%|██████████| 345600.0/345600.0 [00:47<00:00, 7294.32it/s]\n" |
385 | 389 | ] |
386 | 390 | } |
387 | 391 | ], |
|
392 | 396 | }, |
393 | 397 | { |
394 | 398 | "cell_type": "code", |
395 | | - "execution_count": 15, |
| 399 | + "execution_count": 16, |
396 | 400 | "metadata": {}, |
397 | 401 | "outputs": [ |
398 | 402 | { |
|
422 | 426 | }, |
423 | 427 | { |
424 | 428 | "cell_type": "code", |
425 | | - "execution_count": 16, |
| 429 | + "execution_count": 17, |
426 | 430 | "metadata": {}, |
427 | 431 | "outputs": [], |
428 | 432 | "source": [ |
|
438 | 442 | }, |
439 | 443 | { |
440 | 444 | "cell_type": "code", |
441 | | - "execution_count": 17, |
| 445 | + "execution_count": 18, |
442 | 446 | "metadata": {}, |
443 | 447 | "outputs": [], |
444 | 448 | "source": [ |
|
453 | 457 | }, |
454 | 458 | { |
455 | 459 | "cell_type": "code", |
456 | | - "execution_count": 18, |
| 460 | + "execution_count": 19, |
457 | 461 | "metadata": {}, |
458 | 462 | "outputs": [ |
459 | 463 | { |
460 | 464 | "name": "stdout", |
461 | 465 | "output_type": "stream", |
462 | 466 | "text": [ |
463 | 467 | "INFO: Output files are stored in example_idealised_flow_experiment_3.zarr.\n", |
464 | | - "100%|██████████| 345600.0/345600.0 [00:55<00:00, 6241.77it/s]\n" |
| 468 | + "100%|██████████| 345600.0/345600.0 [00:55<00:00, 6224.79it/s]\n" |
465 | 469 | ] |
466 | 470 | } |
467 | 471 | ], |
|
472 | 476 | }, |
473 | 477 | { |
474 | 478 | "cell_type": "code", |
475 | | - "execution_count": 19, |
| 479 | + "execution_count": 20, |
476 | 480 | "metadata": {}, |
477 | 481 | "outputs": [ |
478 | 482 | { |
|
502 | 506 | }, |
503 | 507 | { |
504 | 508 | "cell_type": "code", |
505 | | - "execution_count": 20, |
| 509 | + "execution_count": 21, |
506 | 510 | "metadata": {}, |
507 | 511 | "outputs": [], |
508 | 512 | "source": [ |
|
518 | 522 | }, |
519 | 523 | { |
520 | 524 | "cell_type": "code", |
521 | | - "execution_count": 21, |
| 525 | + "execution_count": 22, |
522 | 526 | "metadata": {}, |
523 | 527 | "outputs": [], |
524 | 528 | "source": [ |
|
533 | 537 | }, |
534 | 538 | { |
535 | 539 | "cell_type": "code", |
536 | | - "execution_count": 22, |
| 540 | + "execution_count": 23, |
537 | 541 | "metadata": {}, |
538 | 542 | "outputs": [ |
539 | 543 | { |
540 | 544 | "name": "stdout", |
541 | 545 | "output_type": "stream", |
542 | 546 | "text": [ |
543 | 547 | "INFO: Output files are stored in example_idealised_flow_experiment_4.zarr.\n", |
544 | | - "100%|██████████| 345600.0/345600.0 [00:49<00:00, 6957.41it/s]\n" |
| 548 | + "100%|██████████| 345600.0/345600.0 [00:48<00:00, 7094.99it/s]\n" |
545 | 549 | ] |
546 | 550 | } |
547 | 551 | ], |
|
552 | 556 | }, |
553 | 557 | { |
554 | 558 | "cell_type": "code", |
555 | | - "execution_count": 23, |
| 559 | + "execution_count": 24, |
556 | 560 | "metadata": {}, |
557 | 561 | "outputs": [ |
558 | 562 | { |
|
582 | 586 | }, |
583 | 587 | { |
584 | 588 | "cell_type": "code", |
585 | | - "execution_count": 24, |
| 589 | + "execution_count": 25, |
586 | 590 | "metadata": {}, |
587 | 591 | "outputs": [], |
588 | 592 | "source": [ |
|
598 | 602 | }, |
599 | 603 | { |
600 | 604 | "cell_type": "code", |
601 | | - "execution_count": 25, |
| 605 | + "execution_count": 26, |
602 | 606 | "metadata": {}, |
603 | 607 | "outputs": [], |
604 | 608 | "source": [ |
|
613 | 617 | }, |
614 | 618 | { |
615 | 619 | "cell_type": "code", |
616 | | - "execution_count": 26, |
| 620 | + "execution_count": 27, |
617 | 621 | "metadata": {}, |
618 | 622 | "outputs": [ |
619 | 623 | { |
620 | 624 | "name": "stdout", |
621 | 625 | "output_type": "stream", |
622 | 626 | "text": [ |
623 | 627 | "INFO: Output files are stored in example_idealised_flow_experiment_5.zarr.\n", |
624 | | - "100%|██████████| 345600.0/345600.0 [01:08<00:00, 5059.36it/s]\n" |
| 628 | + "100%|██████████| 345600.0/345600.0 [01:07<00:00, 5113.66it/s]\n" |
625 | 629 | ] |
626 | 630 | } |
627 | 631 | ], |
|
632 | 636 | }, |
633 | 637 | { |
634 | 638 | "cell_type": "code", |
635 | | - "execution_count": 27, |
| 639 | + "execution_count": 28, |
636 | 640 | "metadata": {}, |
637 | 641 | "outputs": [ |
638 | 642 | { |
|
662 | 666 | }, |
663 | 667 | { |
664 | 668 | "cell_type": "code", |
665 | | - "execution_count": 28, |
| 669 | + "execution_count": 29, |
666 | 670 | "metadata": {}, |
667 | 671 | "outputs": [ |
668 | 672 | { |
|
0 commit comments