-
Notifications
You must be signed in to change notification settings - Fork 0
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
Some type hierarchy suggestions #3
Comments
Hi Adam @adamslc , thank you for the suggestion. Actually, in my initial implementation, I include the mass field. However, it's a little bit redundant and confusing if one supply both mass number and mass (and do we need to verify they are equal?). Also, I would say the symbol is more fundamental than the mass number. For example electron and muon, they both have zero mass number, but they have different mass, we need something like symbol to differentiate them. But this is something we can discuss. Actually, I'm leaning towards the way of how
|
Yes, I agree with you that |
Thank you for all the suggestions. Yes it would be wonderful to incorporate into the |
I personally would find it very counterintuitive to call You make a good point that the symbol (encoding the actual type of the particle) is the more fundamental quantity. However, I would still like to see type parameters so that I can dispatch on the type of particle. Perhaps |
How about struct Particle <: AbstractParticle @kwdef struct CustomParticle <: AbstractParticle |
I've been thinking about this some more, and I'd really like to be able to use type interface to interact with and select particles. What do you think about a much more exhaustive type hierarchy:
This way the non-ion particles are easily distinguished by their type, and for ions, they can still be dispatched on by proton number ( Thus I propose:
The symbol can be kept for printing convenience, although I'm not sure it is needed. Maybe it should be a string instead of a symbol? |
Hi @adamslc . Exhaustive type hierarchy in my opinion is definitely better. My concern is that charge state only makes sense for ions. For particles like electron i feel it is more like internal thing. (I don't know too much about particle Physics, so i may be wrong) Something else to consider is in that Type hierarchy 'Particle' is not a good name anymore, we may need something like 'particle' function as an united interface to créate Particle. |
Yes, I agree that And having a |
Implemented now in #4 with suggested type hierarchy |
The two options here (option 1 with concrete fields, option 2 with type parameters) both have their merits, and the best choice depends on specific use case:
I think maybe we could incorporate both concrete field-based and type-parameterized Particle structures within the same Julia package. And allow users to select the most appropriate representation based on their specific needs, whether they prioritize flexibility or performance. What do you think? @adamslc For the option 2, maybe we could name it |
Hi @Beforerr, I wanted to offer a few suggestions for the type hierarchy that this package implements. This would help me to incorporate this into the JuliaPlasma/ParticleInCell.jl.
At it's core, I suggest making the type hierarchy something like:
This will allow for dispatch based on the mass number and charge state of the particle. Additionally, I wonder if it would be worth supporting a field in the
Particle
struct to specify the exact mass of the particle:If storing this information is not desired, the
T=Nothing
.Aside: I suggest renaming
ChargedParticleImpl
toParticle
regardless. In my (very) humble opinion, this is a more Julian way to name the type. You could also considerChargedParticle
, but sinceZ=0
is allowed, I don`t think it makes as much sense.Regardless of if you accept my suggestions, thanks for the great package!
The text was updated successfully, but these errors were encountered: