Skip to content

Improve VMEC from_cyl Newton iteration robustness #288

@krystophny

Description

@krystophny

Priority: High

Problem

The VMEC from_cyl Newton iteration in libneo can fail for points near the magnetic axis or outside the plasma domain. This causes silent failures or crashes during coordinate transformations, particularly in:

  • Chartmap spline construction (when sampling VMEC field at chartmap grid points)
  • Particle position conversions between coordinate systems

Current Behavior

  • Newton iteration may not converge
  • Error handling is inconsistent across call sites
  • Some failures are silent, others cause crashes

Proposed Solution

  1. Add robust error handling at all from_cyl call sites
  2. Implement fallback strategies (e.g., nearest valid point, graceful particle loss)
  3. Consider adding iteration limits and convergence tolerance parameters
  4. Document which regions are problematic (near axis, near/outside separatrix)

Related

  • Chartmap boundary limitation (splines restricted to [0.1, 0.99] to avoid this issue)
  • See DOC/coordinates-and-fields.md Appendix A.4

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