Loading [MathJax]/extensions/tex2jax.js

Friday, 7 February 2025

ascii2spec

As students of physics will know,  atomic and nuclear states are labelled using a sequence of letters that has a historical derivation from a time before the underlying physics was fully understood.  Thus the sequence of letters s, p, d, f, g, h, i, j, k, ... correspond to angular momentum values of 0, 1, 2, 3, 4, 5, 6, 7, 8, ... . The letters are known as spectroscopic notation.

Sometimes in computer codes it is nice to make the translation between the letter and the number.  Some new-fangled languages such as Python have things like "dictionaries" which let you do mappings between arbitrary data types.  In God's own language, Fortran, no such thing exists, but enterprising coders could use judicious if statements or something like that to do the mapping. 

However, there is already a well-known mapping between letters and numbers called ASCII which Fortran knows about.  Here is a little screen grab from a website ascii-code which shows the mapping for lower-case letters

 

Perhaps unsurprisingly, the mapping between the base-10 numbers ("Code" in the table) and the characters does not agree with the spectroscopic notation from physics.  Still,  mathematics provides a nice way of mapping some numbers onto some other numbers, known as a "function".  So, a real programmer would simply determine that function and use it to do the mapping.  

Here, then, is a function which takes an ascii code from the sequence above and returns the corresponding value of angular momentum:


 and a graphical view of the function, with blobs plotted at the values which correspond to the letters. 

you're welcome


No comments:

Post a Comment