Average material properties using number of atoms not mass
Averaging material properties over multiple layers e.g. when constructing MaterialProperties
is currently done using a mass-weighted average. For the relative atomic mass and the nuclear charge the weighting should be done by quantity instead.
Example
Assume two blocks of materials with N1,N2 atoms/molecules each with atomic masses A1,A2 and nuclear charges. We have a total of N = N1 + N2 atoms/molecules and should have average atomic masses and nuclear charges of
A = (A1*N1 + A2*N2) / (N1 + N2)
Z = (Z1*N1 + Z2*N2) / (N1 + N2)
Using the total masses
m1 = A1*N1
m2 = A2*N2
as weighting factors yields e.g.
Awrong = (A1*m1 + A2*m2) / (m1 + m2)
and is inconsistent with the initial definition of the averages.