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

[feature] re-implement interactions as trait objects #132

Open
drobnyjt opened this issue Apr 5, 2021 · 1 comment
Open

[feature] re-implement interactions as trait objects #132

drobnyjt opened this issue Apr 5, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@drobnyjt
Copy link
Collaborator

drobnyjt commented Apr 5, 2021

Right now, the interaction potentials are wrapped in layers of hand-typed match statements that appropriately yield the DOCA function, derivative of the DOCA function, etc. for each potential - thinking about keeping the code modular, I think it might make sense to rewrite it all as Interaction objects that implement an Interaction trait, including yielding the various functions. Maybe some operator overloading so that Interaction can be called like a function would be neat?

@drobnyjt
Copy link
Collaborator Author

This change is for the best, but it will require more work than I think I originally thought. Here's a to-do list for when I attempt this:

  • write an Interaction trait
  • write structs for ScreenedCoulomb, Spline, Polynomial, Exponential interactions that implement Interaction and new for building from enums/input file
  • refactor bca code to use structs that implement Interaction
  • write wrappers in input.rs that build the common Interactions (e.g., Kr-C) from the existing keywords to maintain backwards compatibility, as well as include the option to define your own manually
  • implement Fn trait from std so that the interactions can be called really easily:
kr_c = ScreenedCoulomb::new(...);
///if ScreenedCoulomb implements Fn, I could write:
kr_c(Z1, Z2, a, r) ///to get immediate access to the interaction potential

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant