Skip to content

field-line tracing for axisymmetric EQDSK equilibria - #408

Draft
abhiyanpaudel wants to merge 13 commits into
developfrom
field-line-tracer
Draft

abhiyanpaudel wants to merge 13 commits into
developfrom
field-line-tracer

Conversation

@abhiyanpaudel

Copy link
Copy Markdown
Collaborator

AxisymmetricMagneticField builds psi and I(psi) splines from EQDSKData with an explicit poloidal sign. TraceFieldLines traces batches of field lines with RK4 in phi, landing exactly on the given stations, and WedgeStations produces the stations for cubic wedge layers. Tests compare against the analytic circular-equilibrium solution and check fourth-order convergence.

@jacobmerson jacobmerson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are significant code reuse issues.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

#397 merged, I think that addresses all of these issues.


/// Stage slopes, stage points and stage flags of one RK4 step, allocated once
/// per trace and reused by every substep.
struct RK4Workspace

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@hgangwar am I correct in thinking the timestepping code should support various schemes such as RK4 integration? I'd rather have time integration routines in a single place in PCMS in a consistent fashion.

};

/// Axis-aligned R-Z box of the equilibrium grid, in m.
struct Box

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are you implementing your own bounding box instead of using the one implemented in utility?

///
/// @details A point whose stages all succeeded and whose new position is in the
/// box moves; any other valid point is marked invalid and stays where it was.
void RK4Update(Real h, const Box& box, const Reals& k1R, const Reals& k1Z,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At a minimum, we need documentation on what is ok, valid, and all of the inputs as this is not clear from the names. Maybe this is in the hpp file. have not looked there yet.

/**
* @brief Positions of a batch of field lines at a list of toroidal angles
*/
struct TracedPoints

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If this is just the starting points. Can we use the PointCloud?

}

/// Output buffers of one batched AxisymmetricMagneticField::Evaluate call.
struct FieldSamples

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think field samples should be a "point cloud"

* reversed together with I_psi first. I is evaluated at psi clamped to the
* psi_grid range, so it is constant outside that range (vacuum field).
*/
class AxisymmetricMagneticField

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be handled by constructing a PCMS function space?

@jacobmerson

jacobmerson commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

I think you need derivative support to fully integrate this into PCMS capabilities. I'm experimenting with some approaches to support that here: https://github.com/jacobmerson/pcms/tree/meshfields-gradients . I will prioritize getting that fully fixed, and merged this week.

This branch was successfully deployed

1 active deployment
asics — 3834e903 Deployed Oct 30, 2026 by abhiyanpaudel via build_and_test #396
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