Introduction to NeXLCore

This notebook serves as an introduction to two subjects:

  1. atomic physics as necessary to understand X-ray microanalysis

  2. NeXLCore, a Julia language library providing the basic physics algorithms necessary to perform X-ray microanalysis calculations.

You can use the notebook to learn either or both subjects.

When the notebook is first loaded, it will take a while to execute. That's just the nature of the Julia language - it is slow then fast. When code is first executed, Julia compiles it into fast native code. This takes time. However, subsequent execution of the code is exceedingly fast because it is efficient native code. To mitigate this problem, if you are interested in only learning the atomic physics, there is an HTML equivalent of this executable document that renders quickly in your browser. (However, the document will not be dynamic and may not be as current.)

Initially, most of the Julia code is hidden placing the emphasis on the atomic physics. The result is a document that consists of text blocks and output blocks. However, the Julia code is easily revealed using the "eye" icon to the left of the output block.

13.5 μs

A Dynamic Notebook

The code in this notebook is dynamic and there are many opportunities within the document for you to interact with the document. Sometimes the interaction is through a drop-down list and other times through a text edit field. Use these fields to explore the functionality discussed in the text.

5.4 μs

Units

Within microanalysis, it is common to express quantities in a consistent set of units. Most often mass is expressed in grams (g), time in seconds (s), lengths in centimeters (cm), energies in electron volts (eV) and mixtures of these units. For example, density is expressed in g/cm³.

While there are times when other units may be slightly more convenient, this document (and the NeXLCore library) will always express quantities in terms of these units.

5.2 μs
26.4 s

Elements and the Periodic Table

It should come as no surprise that support for elemental and compositional data is fundamental. Atoms are the building block of matter and X-ray microanalysis is all about measuring the relative amount of each element within a material.

4.9 μs
8.0 s

To get data about any element, select that element's symbol from this list:

133 ms
elm1
Silicon (Si), number 14:
categorymetalloid
atomic mass28.085 u
density2.329 g/cm³
molar heat19.789 J/mol⋅K
melting point1687.0 K
boiling point3538.0 K
phaseSolid
shells[2, 8, 4]
electron configuration1s² 2s² 2p⁶ 3s² 3p²
appearancecrystalline, reflective with bluish-tinged faces
summarySilicon is a chemical element with symbol Si and atomic number 14. It is a tetravalent metalloid, more reactive than germanium, the metalloid directly below it in the table. Controversy about silicon's character dates to its discovery.
discovered byJöns Jacob Berzelius
named byThomas Thomson (chemist)
sourcehttps://en.wikipedia.org/wiki/Silicon
Silicon_Spectra.jpg
5.6 ms

Elemental data is available for all elements from Hydrogen (Z=1) to Ununennium (Z=119). This data is also available to Julia code. The most commonly used data items are shown here. You'll notice that they update whenever you select a different element in the list box above.

( Name, Symbol, Atomic number, Atomic Weight, Nominal Density, STP Phase )

3.3 μs
15.4 ms

Since elements are so important, there are a couple of different ways you can select elements. The list above demonstrates one. Another is through interpreting the name, symbol or atomic number of the element as is demonstrated here.

The result from valid inputs will be immediately parsed and displayed below. Invalid inputs produce an error message.

14.6 ms
elm2
Zirconium (Zr), number 40:
categorytransition metal
atomic mass91.2242 u
density6.52 g/cm³
molar heat25.36 J/mol⋅K
melting point2128.0 K
boiling point4650.0 K
phaseSolid
shells[2, 8, 18, 10, 2]
electron configuration1s² 2s² 2p⁶ 3s² 3p⁶ 4s² 3d¹⁰ 4p⁶ 5s² 4d²
appearancesilvery white
summaryZirconium is a chemical element with symbol Zr and atomic number 40. The name of zirconium is taken from the name of the mineral zircon, the most important source of zirconium. The word zircon comes from the Persian word zargun زرگون, meaning "gold-colored".
discovered byMartin Heinrich Klaproth
sourcehttps://en.wikipedia.org/wiki/Zirconium
9.8 μs

The elements are often displayed organized into a tabular form which emphsizes the relationships between the elements due to commonalities in atomic shell structure.

2.6 μs
Elements(…119 elements…):
H                                                  He 
Li Be                               B  C  N  O  F  Ne 
Na Mg                               Al Si P  S  Cl Ar 
K  Ca Sc Ti V  Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr 
Rb Sr Y  Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I  Xe 
Cs Ba    Hf Ta W  Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn 
Fr Ra    Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og 
Uue                                                   
      La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu    
      Ac Th Pa U  Np Pu Am Cm Bk Cf Es Fm Md No Lr    
899 ns

Materials

Elements combine via chemical bonds to form materials. One common representation of a material is the relative amount of each element by mass-fraction.

4.5 ms
mat1
Apatite[F=0.0377,O=0.3807,P=0.1843,Ca=0.3974]
1.9 s

There are other useful ways to enter material data. Materials like the default example Apatite are often represented by the number of atoms of each element in a unit cell like this:

62.0 μs
mat2
Ca5(PO4)3F[F=0.0377,O=0.3807,P=0.1843,Ca=0.3974]
358 ms

There are various different common representations of material data. Three common ones are "mass fraction", "normalized mass fraction" and "atom fraction". The first two represent the contribution of weight of each element relative to the weight of the material. The final one represents the fraction of atoms in the bulk representing each element. The transform from mass fraction to atom fraction depends upon the atomic weight. Atomic weight is not a universal constant. It varies with isotopic abundances. Usually, we assume the nominal terrestrial atomic weights but other atomic weights are possible. For example, isotopically enhanced lithium can vary from the nominal 7.6% Li⁶ / 92.4% Li⁷. According to Wikipedia commercial sources of Li metal may contain as little at 1.6% Li⁶. Generally, this doesn't matter. However, it is worthwhile to remember that any time atom fraction is converted to mass fraction, or vice versa, there is an implicit assumption of atomic weight. (Programmatically, it is possible to specify custom atomic weights on a per material basis but this is an advanced topic.)

3.7 μs
MaterialElementZAMassFracNormMassAtomFrac
StringStringInt64AbstractFloatAbstractFloatAbstractFloatAbstractFloat
1
"Ca5(PO4)3F"
"O"
8
15.999
0.380702
0.380702
0.571429
2
"Ca5(PO4)3F"
"F"
9
18.9984
0.0376728
0.0376728
0.047619
3
"Ca5(PO4)3F"
"P"
15
30.9738
0.184258
0.184258
0.142857
4
"Ca5(PO4)3F"
"Ca"
20
40.0784
0.397367
0.397367
0.238095
902 ms

Many minerals can not be readily described by unit cell chemical formulas as Apatite can. For example, the garnet group has chemical formulae of the form "X₃Y₂(SiO₄)₃". The subclass of pyralspite garnets have Al in the Y position and Mg, Fe or Mn in the position. However, it is improbable to find a pure "end-member" composition of garnet. Usually, natural garnets are mixtures of these kinds. For an example, a sample that might be 40% by mass pyrope (Mg₃Al₂(SiO₄)₃) and 60% by mass spessartine (Mn₃Al₂(SiO₄)₃). (Try adding in a little almandine (Fe₃Al₂(SiO₄)₃) but be careful. The parser won't warn you if the sum of the factors isn't unity.)

62.1 μs
mat3
0.4×Mg3Al2(SiO4)₃+0.6×Mn3Al2(SiO4)3[Si=0.1857,Al=0.1190,Mn=0.1998,O=0.4232,Mg=0.0724]
152 ms
MaterialElementZAMassFracNormMassAtomFrac
StringStringInt64AbstractFloatAbstractFloatAbstractFloatAbstractFloat
1
"0.4×Mg3Al2(SiO4)₃+0.6×Mn3Al2(SiO4)3"
"O"
8
15.999
0.423205
0.423205
0.6
2
"0.4×Mg3Al2(SiO4)₃+0.6×Mn3Al2(SiO4)3"
"Mg"
12
24.305
0.0723505
0.0723505
0.0675211
3
"0.4×Mg3Al2(SiO4)₃+0.6×Mn3Al2(SiO4)3"
"Al"
13
26.9815
0.118952
0.118952
0.1
4
"0.4×Mg3Al2(SiO4)₃+0.6×Mn3Al2(SiO4)3"
"Si"
14
28.085
0.185726
0.185726
0.15
5
"0.4×Mg3Al2(SiO4)₃+0.6×Mn3Al2(SiO4)3"
"Mn"
25
54.938
0.199767
0.199767
0.0824789
82.8 μs

Similarly, iron oxides are often mixtures of Fe₂O₃, FeO₂, FeO and others.

64.1 μs
MaterialElementZAMassFracNormMassAtomFrac
StringStringInt64AbstractFloatAbstractFloatAbstractFloatAbstractFloat
1
"0.35×Fe2O3+0.4×FeO2+0.25×FeO"
"O"
8
15.999
0.306577
0.306577
0.606801
2
"0.35×Fe2O3+0.4×FeO2+0.25×FeO"
"Fe"
26
55.8452
0.693423
0.693423
0.393199
186 μs

Supplemental data can also be associated with materials like density, conductivity, a description or user-define properties. While the element data provides nominal densities for the pure elements, the density of a material is not readily calculable from the elemental densities. Wikipedia is often a good source for density and conductivity data. Within NeXLCore, mass values are always expressed in grams and length units in centimeters. Thus density is in g/cm³.

2.8 μs
mat4
Fluorite[F=0.4867,Ca=0.5133,3.18 g/cm³]
196 ms
5.8 ms

Throughout this document we have transformed materials into tables to display various different representations. There are programmatic ways to access the alternative representations. (These representations will look odd to the non-programmer.)

5.6 μs
mat5
0.2×FeO+0.3×Fe2O3+0.45×FeO2[Fe=0.6514,O=0.2986,5.40 g/cm³]
364 ms
0.95
3.5 ms
"Dict{PeriodicTable.Element,AbstractFloat}(Element(Iron) => 0.38457619142945987,Element(Oxygen) => 0.6154238085705401)"
186 ms
"Dict{PeriodicTable.Element,AbstractFloat}(Element(Iron) => 0.685656003628355,Element(Oxygen) => 0.3143439963716451)"
109 ms

This example makes use of a syntactic shortcut. Elements may be described in code using the notation n"XX" where XX is the element's name, symbol or atomic number. The mass fraction value associated with a material may be accessed using indexing syntax where the indexing argument is an Element.

3.1 μs
3.7 ms

Finally, there is a little additional syntactic sugar to assist with accessing properties. I can define custom properties like :Luster like this.

3.9 μs
"Metallic to splendent"
3.0 ms

The custom properties use a Symbol name and allow the user to customize the Material structure to contain any kind of custom data.

I can access properties like this:

3.8 μs
6.8 μs

Where :Density is a library defined property and :Luster is a user custom property.

2.6 μs

Finally we can display many materials in a single table. Unfortunately, the representation in this notebook cuts off a handful of columns on the right side. The DataFrame code object contains the columns and they do display in other output formats and are written correctly to CSV files.

2.8 μs
MaterialOFMgAlSiPCaMnFeTotal
StringAbstractFloatAbstractFloatAbstractFloatAbstractFloatAbstractFloatAbstractFloatAbstractFloatAbstractFloatAbstractFloatAbstractFloat
1
"Apatite"
0.3807
0.0377
0.0
0.0
0.0
0.1843
0.3974
0.0
0.0
1.0001
2
"Ca5(PO4)3F"
0.380702
0.0376728
0.0
0.0
0.0
0.184258
0.397367
0.0
0.0
1.0
3
"0.4×Mg3Al2(SiO4)₃+0.6×Mn3Al2(SiO4)3"
0.423205
0.0
0.0723505
0.118952
0.185726
0.0
0.0
0.199767
0.0
1.0
4
"Fluorite"
0.0
0.486669
0.0
0.0
0.0
0.0
0.513331
0.0
0.0
1.0
5
"0.2×FeO+0.3×Fe2O3+0.45×FeO2"
0.298627
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.651373
0.95
712 ms

Atomic Structure

The elements are defined by the number of protons in their nucleus. Hydrogen always has one proton, helium two protons, lithium three protons, all the way to ununennium with 119 protons. The number of neutrons can vary within a range between 1 to 2 neutrons per proton (mostly). Since neutrons and protons weight almost the same, this defines the general relationship between Z (atomic number) and A (atomic weight).

3.6 μs
Atomic Number -200 -150 -100 -50 0 50 100 150 200 250 300 350 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240 245 250 255 260 265 270 275 280 285 290 295 300 -200 0 200 400 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 h,j,k,l,arrows,drag to pan i,o,+,-,scroll,shift-drag to zoom r,dbl-click to reset c for coordinates ? for help ? -500 -400 -300 -200 -100 0 100 200 300 400 500 600 700 800 900 -400 -380 -360 -340 -320 -300 -280 -260 -240 -220 -200 -180 -160 -140 -120 -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 -500 0 500 1000 -400 -350 -300 -250 -200 -150 -100 -50 0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 Nominal Atomic Weight
446 ms

The neutrons and protons are bound together by nuclear forces into a small tight bundle called the nucleus. | In a neutral atom, the type we always study in microanalysis, the number of electrons exactly equals the number of protons. This is because the charge on an electron is precisely equal in magnitude to the charge on a proton but opposite in sign. By convention, electrons are said to have negative charge and protons positive charge. Almost all the mass of the atom is in the nucleus because an electron weights about 1/2000 the mass of either a neutron or a proton.

Positive and negative charges attract but there is a limit to how close the electrons can come to the nucleus. This limit is imposed by a purely quantum effect - the Pauli exclusion principle which in crude terms says that no two electrons can occupy the same position/angular momentum/spin state.

The result is that the electrons in a neutral ground state atom form into a series of shells in which each electron can be thought of as having own well defined state.

There are various different notations to express these states. We will stick with IUPAC notation because it is simple to understand and commonly used in microanalysis. We won't use Seigbahn notation because, while it is more common, it is also ambiguous and less clear having been designed before atomic structure was understood.

7.3 μs

IUPAC Notation

In IUPAC notation, there are atomic shells represented by the letters K, L, M, N... representing the principle atomic numbers, n, 1, 2, 3, 4, ....

The K-shell is most tightly bound and can contain only 2 electrons.

The L-shell is second most tightly bound and can contain (2 + 2 + 4) electrons.

The M-shell is next most tightly bound and can contain (2 + 2 + 4 + 4 + 6) electrons, and so on;

5.4 μs

Each shell has sub-shells. The K-shell has one subshell, the L-shell has 3 sub-shells (L₁, L₂, L₃), the M-shell has 5 sub-shells (M₁, M₂, M₃, M₄ and M₅) and so on with each subsequent shell gaining two additional sub-shells.

2.8 μs
62.5 μs
SubShellShelln𝓁jCapacity
SubShellShellInt64Int64RationalInt64
1
M5
Shell[M]
3
2
5//2
6
348 ms

In this table, n represents the principle quantum number, l represents the orbital angular momentum quantum number, j represents the total angular momentum quantum number and the capacity is the maximum number of electrons that can occupy this sub-shell.

It is no problem if you don't understand, the quantum numbers. Mostly, the library handles issues of quantum numbers transparently.

3.6 μs
SubShellShelln𝓁jCapacity
SubShellShellInt64Int64RationalInt64
1
Q3
Shell[Q]
7
1
3//2
4
2
Q2
Shell[Q]
7
1
1//2
2
3
Q1
Shell[Q]
7
0
1//2
2
4
P11
Shell[P]
6
5
11//2
12
5
P10
Shell[P]
6
5
9//2
10
6
P9
Shell[P]
6
4
9//2
10
7
P8
Shell[P]
6
4
7//2
8
8
P7
Shell[P]
6
3
7//2
8
9
P6
Shell[P]
6
3
5//2
6
10
P5
Shell[P]
6
2
5//2
6
more
39
K
Shell[K]
1
0
1//2
2
14.1 ms

This table summarizes the properties of all the sub-shells up to O2 (or so.)

Programmatic use is demonstrated below.

6.0 μs
14.6 ms

Sub-shells and Elements

Sub-shells become less abstract when combined with elements.

As the number of electrons in a element increase, the number of shells necessary to contain the electrons increases. The shells fill mostly in the nominal order of shells but not entirely.

Use this drop-down list to investigate which shells are occupied (in the ground state) for which elements.

50.1 ms
ShellSubShellEnergyICX_U2JumpRatioFluorYield
AtomicSubShellSubShellFloat64Float64Float64Float64
1
Fe M5
M5
3.6
0.0
0.0
0.0
2
Fe M4
M4
3.6
0.0
0.0
0.0
3
Fe M3
M3
54.0
5.38668e-18
1.33901
0.0
4
Fe M2
M2
54.0
2.58238e-18
1.33901
0.0
5
Fe M1
M1
92.9
1.14182e-18
1.06003
0.0
6
Fe L3
L3
708.1
1.33806e-19
6.34015
0.0019463
7
Fe L2
L2
721.1
6.42624e-20
1.41953
0.00198798
8
Fe L1
L1
846.1
3.52753e-20
1.12329
0.00132947
9
Fe K
K
7112.0
5.83137e-22
8.5227
0.336242
675 ms

Alternatively, you can use text parsing to investigate individual elements and sub-shells.

Type the element name/symbol/number followed by the sub-shell name:

4.2 μs
61.4 μs
ShellSubShellEnergyICX_U2JumpRatioFluorYield
AtomicSubShellSubShellFloat64Float64Float64Float64
1
Fe L3
L3
708.1
1.33806e-19
6.34015
0.0019463
99.0 μs

As you might expect, these values are also available programmatically. The units for the edge energy are eV and for the ionization cross-section cm². The jump ratio and fluorescence yields are unitless ratios.

2.7 μs
50.3 μs

Characteristic X-rays

Characteristic X-rays result from the relaxation of inner shell ionizations.

Two processes commonly lead to a single electron being ejected from an inner shell to form a singly ionized atom, 1) electron impact; 2) photoionization. In both cases, energy must be conserved. In the case of electron impact, the incident electron must have sufficient kinetic energy to overcome the atomic sub-shell's binding energy (as listed as energy in the above tables.) For photoionization, the photon (typically an X-ray) must have enough energy to exceed the sub-shell's binding energy.

An inner shell ionization is not stable. More weakly bound electrons will want to decay into the inner shell either via X-ray emission or by a two electron process called Auger emission. The fractional likelihood that an ionized atom decays via a characteristic X-ray is called the fluorescence yield and is listed in the above tables as FluorYield.

8.2 μs

Select an element to display all the characteristic X-rays associated with the element.

Note that as the number of electrons increases, the number of potential transitions also increases.

78.7 μs
XRayInnerOuterEnergyStrengthWeight
CharXRayAtomicSubShellAtomicSubShellFloat64Float64Float64
1
Al L3-M1
Al L3
Al M1
64.7243
4.92857e-6
1.0
2
Al L2-M1
Al L2
Al M1
64.7243
2.59701e-6
0.52693
3
Al K-L3
Al K
Al L3
1486.5
0.0245528
1.0
4
Al K-L2
Al K
Al L2
1486.5
0.0123699
0.503808
918 ms