How it works
The calculator uses thegetElementData() function to compute electron configurations based on atomic number (Z). It fills orbitals sequentially following the energy-level hierarchy:
chemistry.js
Orbital filling logic
The algorithm processes each orbital subshell in the sequence defined above:- Determines how many electrons to place in the current orbital (minimum of remaining electrons and orbital capacity)
- Adds the orbital and electron count to the configuration array
- Tracks the highest principal quantum number to identify valence electrons
- Continues until all electrons are distributed
chemistry.js
Return values
ThegetElementData() function returns an object containing:
z— Atomic numberconfigString— Full electron configuration (e.g., “1s2 2s2 2p6 3s2 3p2”)valenceElectrons— Number of electrons in the outermost shellholes— Number of holes calculated as 8 - valenceElectrons
Example outputs
Valence electron calculation
Valence electrons are identified by tracking the highest principal quantum number (n) encountered during filling:- When a new shell is encountered (higher n), the valence count resets to the electrons in that shell
- Electrons added to the same shell level accumulate in the valence count
- This approach correctly handles transition metals where d-orbitals fill after the next s-orbital
The valence electron count is critical for determining semiconductor behavior. Elements with 3, 4, or 5 valence electrons form the basis of P-type, intrinsic, and N-type semiconductors respectively.
Material type determination
ThedetermineMaterial() function uses valence electron counts to classify semiconductor combinations:
chemistry.js
