Skip to content

Fixing error for RK45 on spherical grids - #2827

Merged
erikvansebille merged 2 commits into
Parcels-code:mainfrom
erikvansebille:fix_rk45_tol
Aug 17, 2026
Merged

Fixing error for RK45 on spherical grids#2827
erikvansebille merged 2 commits into
Parcels-code:mainfrom
erikvansebille:fix_rk45_tol

Conversation

@erikvansebille

@erikvansebille erikvansebille commented Aug 14, 2026

Copy link
Copy Markdown
Member

Description

I just came across this error in RK45 - which apparently wasn't tested on spherical grids.

AttributeError: Cannot assign 'RK45_tol' directly. Use fieldset.context['RK45_tol'] instead.

This PR adds such a test and fixes the AttributeError

Checklist

  • Closes None
  • Tests added
  • This PR targets the correct branch (main for normal development, v3-support for v3 support)

AI Disclosure

None

if self.fieldset.U.grid._mesh.is_spherical():
self.fieldset.RK45_tol /= (
self.fieldset.U.grid.deg2m
) # TODO does not account for zonal variation in meter -> degree conversion

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this TODO is relevant anymore - we didn't do this in v3 either and it would require a major refactoring

Comment thread tests/test_advection.py
if kernel == AdvectionRK45:
fieldset.add_context("RK45_tol", rtol)
fieldset.add_context("RK45_min_dt", 1)
fieldset.add_context("RK45_min_dt", 10)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a (slight) speedup of the tests

@erikvansebille
erikvansebille enabled auto-merge (squash) August 17, 2026 10:00
@erikvansebille
erikvansebille merged commit bfa4040 into Parcels-code:main Aug 17, 2026
15 of 16 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants