Repository navigation
Atomic physics - #24
Conversation
|
I just had a thought. For several of these methods, I'm calling element_symbol or isotope_symbol at the beginning to get the element or isotope into a standard format before doing whatever else inside the routine. I'm wondering if a more elegant/understandable way to go about this would be to have a decorator that converts the input into the standard form. I'm also not sure what the best way is to have a standard format for ionization state. Should it be something like |
|
|
||
| """ | ||
|
|
||
| if type(argument) not in [str, int]: |
There was a problem hiding this comment.
@namurphy isinstance is preferred over type in
| def ion_mass(argument, Z=1, mass_numb=None): | ||
| """Returns the mass of an ion. | ||
|
|
||
| by finding the atomic mass of a neutral |
There was a problem hiding this comment.
Is the indentation wrong here? Is part of your travis build a documentation build?
| "livermorium": "Lv", "tennessine": "Ts", | ||
| "oganesson": "Og", "neutron": "n"} | ||
|
|
||
| Elements = { |
There was a problem hiding this comment.
I am surprised this type of information is not tabulated elsewhere in scipy.
| sum_of_iso_comps += isotopic_composition(isotope) | ||
|
|
||
| assert np.isclose(sum_of_iso_comps, 1, atol=1e-6), \ | ||
| "Problem with: " + element |
|
Thank you, @smithsp! This is really helpful. I'll make the change and fix the docstring which I started editing but forgot to finish. I was surprised too that basic atomic data is not available in SciPy, and that it isn't in Astropy either. Thinking more, elemental and isotopic data would be most useful as an upstream feature. I'll try to remember to submit this as an issue to the SciPy repository, unless anyone else would like to do so. |
|
There was a conversation on the scipy-dev email list ten years ago about this very issue. However, it doesn't seem like they ended up completing the implementation. |
|
👍 |
I wrote up a bunch of routines to access atomic data, including elements and isotopes. I figured that plasma physicists occasionally care about atomic physics, and then I might have gotten just a little bit ridiculous. For plasma parameters calculations, we'll need ion_mass. I had fun writing the tests too, as there were a bunch of special cases and I wanted to test the exceptions too.
The routines are:
element_symbolisotope_symbolatomic_numberis_isotope_stablehalf_lifemass_numberelement_namestandard_atomic_weightisotope_massion_massnuclear_binding_energyenergy_from_nuclear_reactionknown_isotopescommon_isotopesstable_isotopesRemaining issues are:
element_symbolfor example can accept inputs like'hydrogen','H-1','D',42,'42','protium', etc. These are case insensitive except where case makes a difference:'p'refers to protons but'P'refers to phosphorus. (Also apparently are are elements besides hydrogen. Who knew?) I included neutrons in a bunch of these too, though we might want to adjust whether we want functionality likeelement_name('n')returningneutron.ElementsandIsotopesthat contain rudimentary atomic data. I also don't know where the best place is to deposit helper code that I used to write the code for the Isotopes data structures.isotopic_composition()to get the terrestrial relative abundances.physical_datainstead ofconstants.'Pb-209'for an isotope.# magicor# here be dragons), or if I should do some refactoring.