robynsb / interactive-track-and-trace

BSD 2-Clause "Simplified" License
0 stars 3 forks source link

Perform advection #6

Closed robynsb closed 6 months ago

robynsb commented 6 months ago

Integration

The python notebook he gave us has a very simple calculation, basically at each time step: $x \leftarrow x + u \cdot dt$ $y \leftarrow y + v \cdot dt$

RK methods are not much harder, see wiki article or Parcels advection.py:

def AdvectionRK4_3D(particle, fieldset, time):
    """
    Advection of particles using fourth-order Runge-Kutta
    integration including vertical velocity.
    Function needs to be converted to Kernel object before execution.
    """
    (u1, v1, w1) = fieldset.UVW[particle]
    lon1 = particle.lon + u1*.5*particle.dt
    lat1 = particle.lat + v1*.5*particle.dt
    dep1 = particle.depth + w1*.5*particle.dt
    (u2, v2, w2) = fieldset.UVW[time + .5 * particle.dt, dep1, lat1, lon1, particle]
    lon2 = particle.lon + u2*.5*particle.dt
    lat2 = particle.lat + v2*.5*particle.dt
    dep2 = particle.depth + w2*.5*particle.dt
    (u3, v3, w3) = fieldset.UVW[time + .5 * particle.dt, dep2, lat2, lon2, particle]
    lon3 = particle.lon + u3*particle.dt
    lat3 = particle.lat + v3*particle.dt
    dep3 = particle.depth + w3*particle.dt
    (u4, v4, w4) = fieldset.UVW[time + particle.dt, dep3, lat3, lon3, particle]
    particle_dlon += (u1 + 2*u2 + 2*u3 + u4) / 6. * particle.dt
    particle_dlat += (v1 + 2*v2 + 2*v3 + v4) / 6. * particle.dt
    particle_ddepth += (w1 + 2*w2 + 2*w3 + w4) / 6. * particle.dt

What scales to use

What happens when data runs out? Restart from beginning?

Boundary conditions

When u=v=0 this means the cell is land.