Skip to content

ARTS2D: repair spherical-harmonic coordinates and make anisotropy trainable #136

Description

@joglekara

Problem

On current origin/main, the configured ARTS2D spherical-harmonic anisotropy cannot affect the fit as intended:

  1. sph_harm_y expects degree/order (n, m), but tsadar/core/modules/distribution_functions/spherical_harmonics.py:306-308 passes (j, i) for loop variables (l=i, m=j).
  2. Lines 202-204 set theta=atan2(vy, vx) and phi=acos(vy / abs(vy)). The latter is only 0 or pi, so the velocity plane is mapped onto the two poles. With the current call ordering, both configured l=1 modes evaluate to zero. Even after correcting (n, m), Re(Y_1^1) remains identically zero and Y_1^0 is only a half-plane step.
  3. FLM_MY.dt is annotated and stored as a Python float at lines 79-84. Equinox treats it as static even though the distribution filter marks dtx/dty trainable. Direct eqx.filter_value_and_grad returns None for both gradients.

Consequently existing Mora-Yahi spherical-harmonic runs effectively optimize the isotropic shape parameter, not the requested anisotropy.

Reproduction

  • Perturbing dty on the partially corrected local implementation changes the EDF by exactly zero.
  • On tracked origin/main, perturbing either dtx or dty leaves the anisotropic contribution zero because degree/order and plane coordinates both collapse the modes.
  • type(module.dt) is float, and the filtered gradient for each dt leaf is None.

Acceptance criteria

  • Document whether this is a 2-D polar Fourier basis or a projected 3-D spherical-harmonic basis, including angle and (l,m) conventions.
  • Pass degree/order correctly to the current JAX API and use nonsingular plane coordinates.
  • Store every enabled coefficient as a JAX array leaf and include all intended weights and biases in the filter specification.
  • Each enabled anisotropic coefficient produces a finite, nonzero EDF perturbation, a nonzero spectrum perturbation over a suitable test geometry, and a finite nonzero AD/finite-difference gradient.
  • The two l=1 Cartesian modes are linearly independent and have the expected odd x/y parity and centroids.
  • Add an active-leaf audit test: every deck parameter marked active must occur in the differentiable pytree, change the forward prediction where physically observable, and have a finite AD/FD derivative.
  • Cover Nl > 1 construction, state serialization, and get_unnormed_params without key errors.

Related: #124.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions