Skip to content

Conversation

@rogeriojorge
Copy link
Collaborator

This PR (still in draft) introduces field interpolation in ESSOS. This solves the issue of really long field line tracing times and long particle tracing times in coil fields. This is based on the interpolation methods used in SIMSOPT.
An example is shown in VMEC, but the goal is to have a general interpolated field for any magnetic field class instead of specific implementations.

- Introduced tests for `InterpolatedField` including linear and quadratic fields, ensuring exactness and JIT compatibility.
- Implemented tests for `RegularGridInterpolant3D` to validate building and evaluation with linear fields, including skip function behavior.
- Added tests for `SurfaceRZFourier` to verify geometry, normals, cross-sectional area, and field evaluations on surfaces.
- Included a mock magnetic field for testing `B_on_surface`, `BdotN`, and `BdotN_over_B` functions.
- Established a `SurfaceClassifier` with tests for signed distances and vectorized evaluations.
- Ensured numerical stability by enabling x64 precision in tests.
@rogeriojorge
Copy link
Collaborator Author

@eduardolneto I refactored the surface classifier, and it appears to run faster. Could you check if it is faster for you and gives the same results?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces field interpolation capabilities to ESSOS to solve performance issues with long field line tracing and particle tracing in coil fields. The implementation builds on SIMSOPT's interpolation methods and adds comprehensive support for both general interpolated fields and VMEC-native coordinate interpolation.

Key changes:

  • Implements InterpolatedField and RegularGridInterpolant3D classes for fast 3D field interpolation
  • Adds InterpolatedVmecNative for native (s,θ,φ) coordinate interpolation
  • Enhances SurfaceClassifier with improved performance and phi wrapping capabilities

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
essos/interpolated_field.py Core interpolation framework with Lagrange basis functions, regular grid interpolants, and coordinate transformations
essos/surfaces.py Enhanced SurfaceClassifier with cKDTree optimization and phi wrapping support
tests/test_interpolated_field.py Comprehensive test suite covering interpolation rules, grid operations, and VMEC native interpolation
tests/test_surfaces.py Test suite for surface geometry, field evaluation, and classification functionality
examples/trace_fieldlines_interpolated.py Example demonstrating interpolated field usage for field line tracing with performance timing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

rogeriojorge and others added 2 commits September 22, 2025 08:43
…ssifier. It now uses different methods for cpu and for gpu. Also changed use_fundamental_phi default value to False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants