Skip to content

Conversation

@ax3l
Copy link
Member

@ax3l ax3l commented Jan 2, 2026

Add a transfer_map(ref, order="linear", fallback_identity_map=False) method to the element list, supporting the calculation of a linear transfer map of all elements in the list.

Close #1254

To Do / To Discuss

  • Python: implementation, test, docs
  • Implementation: Do we need to advance the reference particle with every element?
  • Do we need an output/diagnostics (to a file) for inputs files? Should we skip it and add it later/when users ask for it?
  • Will we ever be able to support on lattice a transfer map calculation that is non-linear via a lattice... method or should we rather add an interface to sim. ... (assuming higher-order transfer maps require particle tracking) - discussed: the primary use cases are only on the reference particle trajectory (linear and higher order). We could add this to tracking for the few collective effects that change the reference particle, but this is uncommon.

Add a `transfer_map(ref, order="linear", fallback_identity_map=False)`
method to the element list, supporting the calculation of
a linear transfer map of all elements in the list.
@ax3l ax3l requested a review from cemitch99 January 2, 2026 23:35
@ax3l ax3l added component: elements Elements/external fields component: python Python bindings tracking: reference orbit component: diagnostics all types of outputs labels Jan 2, 2026
@ax3l ax3l added this to the Advanced Methods (SciDAC-5) milestone Jan 2, 2026
@ax3l ax3l mentioned this pull request Jan 2, 2026
:return: True if at least one element of the specified kind exists
:rtype: bool

.. py::method:: transfer_map(ref, order="linear", fallback_identity_map=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

For review: we could also make order a number, if that is more sensible (linear: 1, etc.).

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine as-is for now. The best key word really depends on what options we would like to support in the future. For example, we could have multiple methods of computing the map (e.g., using Taylor maps or automatic differentiation or Lie maps), and "method" would be a good key word.

Copy link
Member Author

Choose a reason for hiding this comment

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

I could also remove the order keyword at all for now, since we do not use it. We can always introduce more keywords when we need them.

:param ref: A reference particle.
:param order: So far, only the calculation of linear transfer maps is supported.
:param fallback_identity_map: For elements with an undefined transfer map in the lattice, assume the identity matrix.
:return: The transfer map of all elements in the list.
Copy link
Member Author

Choose a reason for hiding this comment

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

For review: if we are later on calculating higher orders, should we return a list of transfer maps (one per order)?

Copy link
Member

Choose a reason for hiding this comment

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

For higher orders, there are several ways to represent the map, which may be organized into one (or more) arrays. It's useful to organize these by order-by-order. However, regarding terminology all this information is usually referred to as one map (singular).

Comment on lines +2619 to +2627
.def(
"transfer_map",
[](
KnownElementsList &v,
RefPart ref, // note: intentional copy
std::string order,
bool fallback_identity_map
)
{
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we could also implement this part fully in Python and it would probably be cleaner.
Only the exception handling in the inner loop is likely (quite) slower.

Can also be done later, when we find that we like to implement higher order logic rather in Python than C++.

@ax3l ax3l force-pushed the topic-lin-transport-map branch from 8730e11 to d2185ef Compare January 8, 2026 00:14
[9.98334297e-02, 4.99583537e-02, 0, 0, 1.00000000e00, -1.66466013e-03],
[0, 0, 0, 0, 0, 1.00000000e00],
]
)
Copy link
Member

Choose a reason for hiding this comment

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

Are these currently the true expected values or just dummy values?

Copy link
Member Author

Choose a reason for hiding this comment

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

I quickly put in the current computational result as expected. We should verify manually.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, def wrong values because of the multiplication order mix up :D

Co-authored-by: Chad Mitchell <[email protected]>
Copy link
Member

@cemitch99 cemitch99 left a comment

Choose a reason for hiding this comment

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

I fixed the existing test and ran some additional sanity checks, and everything looks good.

@cemitch99 cemitch99 merged commit 8f0acde into BLAST-ImpactX:development Jan 12, 2026
17 checks passed
@ax3l ax3l deleted the topic-lin-transport-map branch January 13, 2026 00:54
@ax3l
Copy link
Member Author

ax3l commented Jan 13, 2026

Thank you! :)

linear_transfer_map = linear_transfer_map * element_transport_map;
linear_transfer_map = element_transport_map * linear_transfer_map;
// TODO: shorthand needs https://github.com/AMReX-Codes/amrex/pull/4880 from AMReX 26.02+
// result *= element_transport_map;
Copy link
Member Author

@ax3l ax3l Jan 13, 2026

Choose a reason for hiding this comment

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

Comment cleanup needed: result *= element_transport_map; is not identical to the line above.

ax3l added a commit that referenced this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement return of linear transfer maps

2 participants