Skip to content

Improve coordinate scaling documentation in code #291

@krystophny

Description

@krystophny

Priority: Medium

Problem

The coordinate scaling system (sqrt_s_scaling vs identity_scaling) requires careful Jacobian handling that is easy to get wrong. The relationship between different radial coordinates:

  • s = normalized toroidal flux (VMEC native)
  • rho = sqrt(s) = common radial coordinate
  • Jacobian factor: d(rho)/ds = 1/(2*sqrt(s))

When switching between scalings or adding new coordinate systems, it is easy to miss the required Jacobian adjustments.

Current State

  • Code works correctly but the scaling logic is spread across multiple files
  • Comments explaining the transformations are sparse
  • New developers may introduce bugs when modifying coordinate handling

Proposed Solution

  1. Add detailed comments at key transformation points in:
    • field_splined.f90 (spline construction)
    • reference_coordinates.f90 (scaling selection)
    • libneo coordinate implementations
  2. Consider adding validation/assertions for coordinate ranges
  3. Document the full transformation chain in code comments

Related

  • See DOC/coordinates-and-fields.md Section 2.4 and Appendix A.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions