Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CROCO 3D velocities #1641

Merged
merged 53 commits into from
Oct 16, 2024
Merged

Support for CROCO 3D velocities #1641

merged 53 commits into from
Oct 16, 2024

Conversation

erikvansebille
Copy link
Member

@erikvansebille erikvansebille commented Aug 7, 2024

This PR implements support for 3D velocities in CROCO (and potentially also ROMS, but not tested). Users can simply call FieldSet.from_croco() and provide the w field from CROCO output in their variables list and call the AdvectionRK4_3D kernel. Under the hood, Parcels will then replace the kernel with AdvectionRK4_3D_CROCO, which works slightly different from the normal 3D advection kernel because it converts the vertical velocity in sigma-units.

In particular, the following algorithm is used (note that the RK4 version is slightly more complex than this Euler-Forward version, but the idea is identical)

    # calculate local sigma level of particle, by scaling depth by local ocean depth H
    sigma = particle.depth / fieldset.H[time, particle.depth, particle.lat, particle.lon]

    (u, v, w) = fieldset.UVW[time, particle.depth, particle.lat, particle.lon, particle]  

    # scaling the w with the sigma level of the particle
    w1 *= sigma 

    lon_new = particle.lon + u*particle.dt
    lat_new = particle.lat + v*particle.dt

    # calculating new sigma level
    sigma_new = sigma + w/fieldset.H[time, particle.depth, particle.lat, particle.lon]*particle.dt 
    
    # Converting back from sigma to depth, at _new_ location
    depth_new = sigma_new * fieldset.H[time, particle.depth, lat_new, lon_new]  

We have tested this algorithm on an idealised setup (created by @vesnaber) of a purely zonal flow over a sloping bottom. Particles indeed stay on their depth levels (so cross sigma-levels) as expected, with this algorithm. So we think this is an appropriate scheme.

To make this work under the hood, we had to adapt Parcels to convert from particle depth (in m) to sigma-coordinates in Field interpolations. In a call such as fieldset.U[time, particle.depth, particle.lat, particle.lon], the particle.depth will thus under-the-hood be converted to sigma (= particle.depth / fieldset.H[time, particle.depth, particle.lat, particle.lon]).

Todo before this PR can be merged

  • Further implement FieldSet.from_croco() for seamless use
  • Test 2D CROCO surface flow too (so without providing w field)
  • Create tutorial how to use Parcels with CROCO
  • Support for sampling of individual Fields (not velocities)
  • Test the new algorithm in more realistic simulations

erikvansebille and others added 24 commits August 7, 2024 13:12
As of commit 40b76ac, this test has been failing. Not at all clear why, so temporarily silencing them
Improving calculation of local w velocity
@erikvansebille erikvansebille marked this pull request as ready for review October 14, 2024 06:27
tests/test_data/fieldset_CROCO2D.py Outdated Show resolved Hide resolved
parcels/_typing.py Outdated Show resolved Hide resolved
parcels/tools/exampledata_utils.py Show resolved Hide resolved
tests/test_data/fieldset_CROCO2D.py Show resolved Hide resolved
tests/test_advection.py Outdated Show resolved Hide resolved
parcels/fieldfilebuffer.py Show resolved Hide resolved
parcels/compilation/codegenerator.py Outdated Show resolved Hide resolved
parcels/compilation/codegenerator.py Show resolved Hide resolved
tests/test_fieldset_sampling.py Outdated Show resolved Hide resolved
parcels/fieldfilebuffer.py Outdated Show resolved Hide resolved
@VeckoTheGecko VeckoTheGecko self-requested a review October 16, 2024 14:32
@erikvansebille erikvansebille merged commit 0ce0650 into master Oct 16, 2024
14 checks passed
@erikvansebille erikvansebille deleted the croco_3D_velocities branch October 16, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants