{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# The Parcels Kernel loop\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This tutorial explains how Parcels executes multiple Kernels, and what happens under the hood when you combine Kernels. \n", "\n", "This is probably not very relevant when you only use the built-in Advection kernels, but can be important when you are writing and combining your own Kernels!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Background\n", "\n", "When you run a Parcels simulation (i.e. a call to `pset.execute()`), the Kernel loop is the main part of the code that is executed. This part of the code loops through all particles and executes the Kernels that are defined for each particle.\n", "\n", "In order to make sure that the displacements of a particle in the different Kernels can be summed, all Kernels add to a _change_ in position (`particle_dlon`, `particle_dlat`, and `particle_ddepth`). This is important, because there are situations where movement kernels would otherwise not commute. Take the example of advecting particles by currents _and_ winds. If the particle would first be moved by the currents and then by the winds, the result could be different from first moving by the winds and then by the currents. Instead, by adding the changes in position, the ordering of the Kernels has no consequence on the particle displacement." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "