bmad-sim / AtomicAndPhysicalConstants.jl

Julia package for handling particle identification in simulations.
MIT License
0 stars 1 forks source link

new version of SetUnit.jl, included mass and length units as sample #18

Closed lllx125 closed 4 months ago

lllx125 commented 5 months ago

I made the new SetUnit.jl, with new structures for units. the function setunits() is not implemented but I wrote tests at the bottom and its results. The function and the units worked as desired. Once the file for global variable need to be declared is created, it would be easy to include other units and implement the body of the function setunits().

lllx125 commented 5 months ago

I wrote setunits() for some global variables.

lllx125 commented 5 months ago

I added initialization for variables in global.jl

lllx125 commented 5 months ago

I think it would be better to initialize variables in global.jl to 0 because I will be creating them in setunits() anyway. Also, there is 1 line that r_p = r_e * m_electron / m_proton, if m_proton =0 there will be runtime error

rot4te commented 5 months ago

Looks really good. My last quibble (which I should have mentioned earlier) is that your metric-prefix changing functions (k(), M(), etc.) aren't very informative... naming them the 4 or five character prefix name (kilo(), Mega(), etc.) might be better.

rot4te commented 4 months ago

I'm also curious as to why your global mass unit is amu, as opposed to eV/c^2, which is what all the base masses are in.

lllx125 commented 4 months ago

I'm also curious as to why your global mass unit is amu, as opposed to eV/c^2, which is what all the base masses are in. Looks really good. My last quibble (which I should have mentioned earlier) is that your metric-prefix changing functions (k(), M(), etc.) aren't very informative... naming them the 4 or five character prefix name (kilo(), Mega(), etc.) might be better.

I can change both of these. I thought the isotope masses were in amu, and that is the majority of the data. Should setunits() also convert the isotope data?

DavidSagan commented 4 months ago

Unless there was a good reason not to, I would favor having isotope masses in AMU since it makes it easier for someone doing a deep dive in the code to compare against the literature.

rot4te commented 4 months ago

Okay, this means you'll have to handle isotope masses differently from the other masses, Lixing. That shouldn't be too hard, because all the isotope masses are contained in a special type called 'AtomicSpecies' which has a dictionary member that contains all the iso masses for that element. If you look at the type definition in src/ParticleTypes.jl you might get some insight into how to differentiate the isotope masses from the regular mass constants