Skip to content

Commit c39c8d9

Browse files
committed
Adding a reflective boundary condition kernel for bathymetry
1 parent 7d73a02 commit c39c8d9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

plasticparcels/kernels.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,34 @@ def checkThroughBathymetry(particle, fieldset, time):
629629
elif potential_depth > 3900.: # If particle >3.9km deep, stick it there
630630
particle_ddepth = 3900. - particle.depth # noqa
631631

632+
def reflectAtBathymetry(particle, fieldset, time):
633+
"""Reflect at bathymetry kernel.
634+
635+
Description
636+
----------
637+
A simple kernel to reflect particles at the ocean bathymetry, if they go through the bathymetry.
638+
639+
Parameter Requirements
640+
----------
641+
Fieldset:
642+
- `fieldset.bathymetry` - A 2D field containing the ocean bathymetry. Units [m].
643+
644+
Kernel Requirements
645+
----------
646+
Order of Operations:
647+
This kernel should be performed after all other movement kernels, as it samples the
648+
bathymetry field using the updated particle position.
649+
"""
650+
local_bathymetry = fieldset.bathymetry[time, particle.depth, particle.lat, particle.lon]
651+
potential_depth = particle.depth + particle_ddepth
652+
653+
if potential_depth > 100:
654+
local_bathymetry = 0.99*local_bathymetry # Handle linear interpolation issues for deep particles
655+
656+
if potential_depth > local_bathymetry:
657+
beyond_depth = potential_depth - local_bathymetry
658+
particle.depth = local_bathymetry - beyond_depth # Reflect the particle back above the bathymetry
659+
particle_ddepth = 0. # Set particle_ddepth to 0, as we have already updated the depth
632660

633661

634662
def periodicBC(particle, fieldset, time):

0 commit comments

Comments
 (0)