Skip to main content
The chemistry module provides functions for calculating electron configurations, determining valence electrons, and identifying semiconductor material types based on element properties.

getElementData

Calculates the electron configuration and valence properties for an element given its atomic number.
import { getElementData } from './utils/chemistry.js';

const silicon = getElementData(14);
console.log(silicon);
// {
//   z: 14,
//   configString: "1s2 2s2 2p6 3s2 3p2",
//   valenceElectrons: 4,
//   holes: 4
// }

Parameters

z
number
required
The atomic number of the element (number of protons/electrons)

Returns

z
number
The atomic number that was passed in
configString
string
The electron configuration in standard notation (e.g., “1s2 2s2 2p6 3s2 3p2”)
valenceElectrons
number
The number of electrons in the outermost energy level
holes
number
The number of holes in the valence shell, calculated as 8 - valenceElectrons

determineMaterial

Determines the semiconductor material type based on the valence electron properties of two elements (host and dopant).
import { getElementData, determineMaterial } from './utils/chemistry.js';

const silicon = getElementData(14);  // 4 valence electrons
const phosphorus = getElementData(15);  // 5 valence electrons

const materialType = determineMaterial(silicon, phosphorus);
console.log(materialType);
// "Tipo N (Exceso de electrones)"

Parameters

el1
object
required
Element data object containing at minimum a valenceElectrons property (typically from getElementData)
el2
object
required
Element data object containing at minimum a valenceElectrons property (typically from getElementData)

Returns

Returns a string describing the semiconductor material type:
  • "Intrínseco (Aislante)" — Both elements have 4 valence electrons (e.g., Si-Si)
  • "Tipo N (Exceso de electrones)" — One element has 4 and the other has 5 valence electrons (e.g., Si-P)
  • "Tipo P (Exceso de huecos)" — One element has 4 and the other has 3 valence electrons (e.g., Si-B)
  • "Ninguno de los anteriores" — Does not match standard semiconductor doping patterns

getElectronsPerLevel

Calculates the distribution of electrons across energy levels (shells) for an element.
import { getElectronsPerLevel } from './utils/chemistry.js';

const distribution = getElectronsPerLevel(14);
console.log(distribution);
// {
//   1: 2,
//   2: 8,
//   3: 4,
//   4: 0,
//   5: 0,
//   6: 0,
//   7: 0
// }

Parameters

z
number
required
The atomic number of the element

Returns

Returns an object mapping energy level numbers (1-7) to the number of electrons in that level.
1
number
Number of electrons in the first energy level (K shell)
2
number
Number of electrons in the second energy level (L shell)
3
number
Number of electrons in the third energy level (M shell)
4
number
Number of electrons in the fourth energy level (N shell)
5
number
Number of electrons in the fifth energy level (O shell)
6
number
Number of electrons in the sixth energy level (P shell)
7
number
Number of electrons in the seventh energy level (Q shell)

Build docs developers (and LLMs) love