-
Notifications
You must be signed in to change notification settings - Fork 8
Description
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:
- Radial scaling (identity_scaling or sqrt_s_scaling)
- 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_cartare 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.