Skip to content

Incorrect R,Z conversion in NetCDF output for MEISS/splined field #302

@krystophny

Description

@krystophny

Summary

When using MEISS (splined) field with chartmap coordinates, the xend_cart positions in the NetCDF output are incorrect because zend (integrator coordinates) is passed directly to ref_coords%evaluate_cart() without converting to reference coordinates first.

Root Cause

In src/netcdf_results_output.f90:326:

call ref_coords%evaluate_cart(zend(1:3, i), xend_cart(:, i))

The zend array contains coordinates in the integrator frame (after scaling and phi gauge transformation), but ref_coords%evaluate_cart() expects reference coordinates.

For MEISS field, the integrator coordinates differ from reference coordinates due to:

  1. Radial scaling (identity_scaling or sqrt_s_scaling)
  2. Phi gauge transformation (lam_phi)

The conversion integ_to_ref_meiss() in field_can_meiss.f90 handles this, but it is not called before writing NetCDF output.

Impact

  • Particle footprint R,Z positions are incorrect for chartmap-based tracing
  • Particles may appear to hit the wall at wrong locations (rho<1 inside LCFS)
  • Heat flux maps based on xend_cart are spatially incorrect
  • Loss fractions are correct (verified 57.32% match between VMEC and chartmap)

Fix

Add integ_to_ref conversion before evaluate_cart in netcdf_results_output.f90:

real(dp) :: zend_ref(3)
call integ_to_ref(zend(1:3, i), zend_ref)
call ref_coords%evaluate_cart(zend_ref, xend_cart(:, i))

Note: For CANFLUX/BOOZER, classification.f90 already converts zend angles to VMEC via can_to_vmec/boozer_to_vmec. This implicit conversion works because those field types don't have a phi gauge. MEISS is different.

Verification

After fix, chartmap footprint positions should match VMEC footprint positions for equivalent configurations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions