-
Notifications
You must be signed in to change notification settings - Fork 164
Description
Now that we further cleaned up the Kernel loop in #2333, and are also outputting the last output written (a huge improvement with respect to v3), there is another major output-caveat left in the Kernelloop-tutorial:
### 2. Be careful with updating particle variables that do not depend on Fields.
While assigning the interpolated value of a Field to a Particle goes well in the loop above, this is not necessarily so for assigning other attributes. For example, a line like particle.age += particle.dt is executed directly so may result in the age being dt at time = 0 in the output file.
One way to fix this is to treat custom variables the same as lon, lat and z:
- Also create a
dvarfor a custom variablevar(note withto_write=False) - Add code in
PositionUpdate()inkernel.pythat result in something like:
particles.var += particles.dvar
particles.dvar = 0This nicely aligns with the idea to frame Kernels more as ODE solvers (#2338), where the result of a call to RK2_integrator() would then be a dx.
Open question: should every custom Variable get a d-version, or only if users set a certain flag (and then what should be the default)? This is relevant since variables that won't change during the simulation don't need a d-version and fewer variables means less memory overhead.
Metadata
Metadata
Assignees
Type
Projects
Status
Status