Skip to content

Fixing error for RK45 on spherical grids - #2827

Open
erikvansebille wants to merge 1 commit into
Parcels-code:mainfrom
erikvansebille:fix_rk45_tol
Open

Fixing error for RK45 on spherical grids#2827
erikvansebille wants to merge 1 commit 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant