Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactions Rework #109

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Interactions Rework #109

wants to merge 1 commit into from

Conversation

sgriswol
Copy link
Collaborator

Python 3.11 brought under-the-hood changes to the Enum library, breaking ASTERIA's interaction handling. In brief, ASTERIA's EnumMeta-based Interactions class was designed to be a mutable Enum-based object. This contradicts Enum's design, which is meant to be immutable. ASTERIA's implementation of the Interaction object was flawed, and obtusely written.

This branch converts Interactions to a custom class that does not depend on the Enum class. A private member contains the interaction objects and a custom iteration function to handle them. This member may be modified, but not directly. A setter method or similar should be used to modify the interaction list. The user should be able to request specific interactions be activated or deactivated.

The customizable functionality was intended to make interactions other than the defaults more accessible. Currently, only one such class (InvBetaTab) exists, but axion-ice or other interaction channels may be useful for future ASTERIA simulations.

Currently, this branch implements a functional version of the Interactions object. A default iterable of interactions is available on the class, and a customizable iterable of interactions is available upon instantiation. Example usage is provided below.

from asteria.interactions import Interactions
from asteria.interactions import ElectronScatter, InvBetaTab

# Default
for interaction in Interactions:
    print(interaction)

# Custom
custom_itrc = (ElectronScatter, InvBetaTab)
for interactions in Interactions(custom_itrc):
    print(interaction)
# Default
<class 'asteria.interactions.ElectronScatter'>
<class 'asteria.interactions.InvBetaPar'>
<class 'asteria.interactions.Oxygen16CC'>
<class 'asteria.interactions.Oxygen16NC'>
<class 'asteria.interactions.Oxygen18'>

#Custom
<class 'asteria.interactions.ElectronScatter'>
<class 'asteria.interactions.InvBetaTab'>

This implementation is imperfect, and has not been fully tested against other modules of ASTERIA. Of particular note is the flaw that a user must pass an iterable of the interactions to the Interactions object to receive an iterable of interactions from the Interactions object.

Additional development may be required, and alternatives to this implementation are welcome.

@sgriswol sgriswol changed the title Simplified definition of Interactions and _InteractionsMeta Interactions Rework Feb 18, 2025
@sgriswol
Copy link
Collaborator Author

Completion of this PR will contribute to #108 and #107

@sgriswol sgriswol added bug Something isn't working enhancement New feature or request labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant