Skip to main content

Function: fillShells()

fillShells(z, rule): number[]

Defined in: src/mobjects/chemistry/BohrDiagram.ts:148

Fill the electron shells for an atomic number.

With 'school' (the default) and z <= 20, shells fill to 2, 8, 8, 2 in order. Otherwise shell n holds up to 2n^2 electrons, and each shell fills before the next one starts. See the class doc for why both rules simplify real electron configurations.

Parameters​

z​

number

The atomic number (a positive integer).

rule​

BohrShellRule = 'school'

The filling rule. Default: 'school'.

Returns​

number[]

The electron count per shell, innermost first.

Post​

result.reduce((a, b) => a + b, 0) === z

Post​

rule === 'school' && z <= 20 => result.every((c, i) => c <= [2, 8, 8, 2][i])