You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that we have created a `parcels.FieldSet` object from the hydrodynamic data, we need to provide our second input:
62
62
the virtual particles for which we will calculate the trajectories.
63
63
64
-
We need to create a `parcels.ParticleSet` object with the particles' initial time and position. The `parcels.ParticleSet`
64
+
We need to create a {py:obj}`parcels.ParticleSet` object with the particles' initial time and position. The `parcels.ParticleSet`
65
65
object also needs to know about the `FieldSet` in which the particles "live". Finally, we need to specify the type of
66
-
`parcels.Particle` we want to use. The default particles have `time`, `z`, `lat`, and `lon`, but you can easily add
67
-
other `Variables` such as size, temperature, or age to create your own particles to mimic plastic or an [ARGO float](../user_guide/examples/tutorial_Argofloats.ipynb).
66
+
{py:obj}`parcels.ParticleClass` we want to use. The default particles have `time`, `z`, `lat`, and `lon`, but you can easily add
67
+
other {py:obj}`parcels.Variable`s such as size, temperature, or age to create your own particles to mimic plastic or an [ARGO float](../user_guide/examples/tutorial_Argofloats.ipynb).
After setting up the input data and particle start locations and times, we need to specify what calculations to do with
93
-
the particles. These calculations, or numerical integrations, will be performed by what we call a `Kernel`, operating on
93
+
the particles. These calculations, or numerical integrations, will be performed by what we call a {py:obj}`parcels.Kernel`, operating on
94
94
all particles in the `ParticleSet`. The most common calculation is the advection of particles through the velocity field.
95
-
Parcels comes with a number of standard kernels, from which we will use the Runge-Kutta advection kernel `AdvectionRK2`:
96
-
97
-
```{note}
98
-
TODO: link to a list of included kernels
99
-
```
95
+
Parcels comes with a number of common {py:obj}`parcels.kernels`, from which we will use the Runge-Kutta advection kernel {py:obj}`parcels.kernels.AdvectionRK2`:
@@ -117,18 +113,14 @@ the `outputdt` argument so that it captures the smallest timescales of our inter
117
113
118
114
## Run Simulation: `ParticleSet.execute()`
119
115
120
-
Finally, we can run the simulation by _executing_ the `ParticleSet` using the specified list of `kernels`.
116
+
Finally, we can run the simulation by _executing_ the `ParticleSet` using the specified list of `kernels`. This is done using the {py:meth}`parcels.ParticleSet.execute()` method.
121
117
Additionally, we need to specify:
122
118
123
119
- the `runtime`: for how long we want to simulate particles.
124
120
- the `dt`: the timestep with which to perform the numerical integration in the `kernels`. Depending on the numerical
125
121
integration scheme, the accuracy of our simulation will depend on `dt`. Read [this notebook](https://github.com/Parcels-code/10year-anniversary-session2/blob/8931ef69577dbf00273a5ab4b7cf522667e146c5/advection_and_windage.ipynb)
126
122
to learn more about numerical accuracy.
127
123
128
-
```{note}
129
-
TODO: add Michaels 10-years Parcels notebook to the user guide
Copy file name to clipboardExpand all lines: docs/user_guide/examples/explanation_kernelloop.md
+7-9Lines changed: 7 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,7 @@ Besides having commutable Kernels, the main advantage of this implementation is
43
43
Below is a simple example of some particles at the surface of the ocean. We create an idealised zonal wind flow that will "push" a particle that is already affected by the surface currents. The Kernel loop ensures that these two forces act at the same time and location.
Now we define a wind kernel that uses a forward Euler method to apply the wind forcing. Note that we update the `particles.dlon` and `particles.dlat` variables, rather than `particles.lon` and `particles.lat` directly.
78
79
79
80
```{code-cell}
80
81
def wind_kernel(particles, fieldset):
81
-
particles.dlon += (
82
-
fieldset.UWind[particles] * particles.dt
83
-
)
84
-
particles.dlat += (
85
-
fieldset.VWind[particles] * particles.dt
86
-
)
82
+
uwind, vwind = fieldset.Wind[particles]
83
+
particles.dlon += uwind * particles.dt
84
+
particles.dlat += vwind * particles.dt
87
85
```
88
86
89
87
First run a simulation where we apply kernels as `[AdvectionRK4, wind_kernel]`
0 commit comments