Skip to content

Vector calculus follow-ups from #1663: eager divergence and a user guide fix #1731

Description

@rajeeja

Two things #1663 left behind.

1. divergence is eager on dask input. The metric term uses other.values where its companion in curl uses self.data, so u.curl(v) returns a dask.array.Array and u.divergence(v) returns an ndarray for the same chunked input. #1588's .values.data sweep reached the curl side during a conflict resolution on the #1663 branch and missed this one. One-word fix; there is no dask coverage anywhere in test/core/test_vector_calculus.py to have caught it.

2. docs/user-guide/vector_calculus.ipynb still teaches the planar operators. Cells 14 and 27 give ∂v/∂x − ∂u/∂y and ∂u/∂x + ∂v/∂y with no metric term, and eight code cells (16, 18, 20, 22, 29, 31, 35, 37) hand-roll the operators from gradient() components instead of calling curl()/divergence(). So every worked example demonstrates pre-#1663 physics while the library computes something else. Cell 43's "curl of gradient ≈ 0" is stated for the hand-rolled version.

Switching those cells to the API changes one result materially: curl and divergence of a constant field are no longer exactly zero, they are u·tan(φ)/a and −v·tan(φ)/a4.8e-09 and 9.6e-09 on this ±2° MPAS subset. That is correct spherical behaviour and worth saying out loud in the notebook rather than deleting. The other examples move by less than a part in 10⁴, except the two "≈ 0" residuals which go from 2.8e-10 to 4.0e-09 and stay ≈ 0.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions