Function Repository Resource:

LewisSymbol

Source Notebook

Build the Lewis electron-dot symbol for an atom

Contributed by: Wolfram Chemistry

ResourceFunction["LewisSymbol"][atom]

build the Lewis symbol for atom.

ResourceFunction["LewisSymbol"][atom,type]

build the Lewis symbol for atom returning a type object.

Details and Options

LewisSymbol can depict up to eight valence electrons, with a maximum of two electrons on each side of the atomic symbol.
Possible forms for atom include:
Atom[…]an atom
ChemicalFormula[…] monatomic chemical formula
ChemicalInstance[…]a monatomic instance
Entity[…]an element or isotope entity
EntityInstance[…]an element or isotope instance
Molecule[…]a monatomic chemical
Possible values for type include:
Graphicsa two-dimensional grapical image
Textplain text format
The default value for type is Graphics.
LewisSymbol has the following options in addition to those for Graphics:
AlignmentCenterelectron dot alignment
"AtomColor"Automaticatomic symbol color
"DotColor"GrayLevel[0.3]electron dot color
"DotPlacement"{Right,Left,Above,Below}electron dot placement
"ElectronFilling""CubicalAtom"electron dot filling order
FontSizeScaled[0.2]atomic symbol font size
"NetCharge"Automaticnet charge
"PairPlacement"{Right,Left,Below,Above}electron pair placement
"ValenceElectronCount"Automaticnumber of valence electrons
Alignment must be Left, Right or Center.
For a known element, "AtomColor" defaults to a Darker versions of Entity["Element", element]["Color"].
"AtomColor" and "DotColor" must be color directives.
"DotPlacement" and "PairPlacement" refer to the four sides of the atomic symbol and must be a list containing Above, Below, Left and Right.
"ElectronFilling" determines how each of the four orbital sides of the atomic symbol are filled. "CubicalAtom" treats the orbitals as one degenerate subshell, filling the electrons according to Hund's rule following the placements specified by "DotPlacement" and "PairPlacement". "spShell" treats the orbitals as a s subshell and a higher energy p subshell while "Unequal" treats the orbitals as four inequivalent subshells. Both "spShell" and "Unequal" fill the electrons according to the Aufbau principle and Hund's rule following the placement specified by "DotPlacement".
"NetCharge" defaults to the value contained in atom or zero if not specified.
"NetCharge" and "ValenceElectronCount" must be Integer values.
For a known element, "ValenceElectronCount" defaults to Entity["Element", element]["ValenceElectronCount"].

Examples

Basic Examples (3) 

Display the electron-dot symbol for carbon:

In[1]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Carbon"]]
Out[1]=

Display the electron-dot symbol for carbon as Text:

In[2]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Carbon"], Text]
Out[2]=

Show the Lewis formula for arsenide anion:

In[3]:=
ResourceFunction["LewisSymbol"][
ChemicalFormula[{"As" -> 1}, <|"NetCharge" -> -3|>]]
Out[3]=

Show the Lewis formula for arsenide anion as Text:

In[4]:=
ResourceFunction[
 "LewisSymbol"][ChemicalFormula[{"As" -> 1}, <|"NetCharge" -> -3|>], Text]
Out[4]=

Generate the Lewis formula for chlorine-37:

In[5]:=
ResourceFunction["LewisSymbol"][Entity["Isotope", "Chlorine37"]]
Out[5]=

Generate the Lewis formula for chlorine-37 as Text:

In[6]:=
ResourceFunction["LewisSymbol"][Entity["Isotope", "Chlorine37"], Text]
Out[6]=

Scope (5) 

Generate the Lewis symbol for a ChemicalInstance of oxygen:

In[7]:=
ResourceFunction["LewisSymbol"][
 ChemicalInstance[Entity["Element", "Oxygen"], Quantity[5, "Milliliters"]]]
Out[7]=

An equivalent specification using Atom:

In[8]:=
ResourceFunction["LewisSymbol"][Atom["O"]]
Out[8]=

An equivalent specification using ChemicalFormula:

In[9]:=
ResourceFunction["LewisSymbol"][ChemicalFormula["O"]]
Out[9]=

An equivalent specification using Entity:

In[10]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Oxygen"]]
Out[10]=

An equivalent specification using Molecule:

In[11]:=
ResourceFunction["LewisSymbol"][Molecule["[O]"]]
Out[11]=

Options (10) 

Alignment (1) 

Adjust the alignment of unpaired electrons:

In[12]:=
GraphicsGrid[
 Map[ResourceFunction["LewisSymbol"][
    EntityValue[EntityClass["Element", "Period2"], "Entity"], Alignment -> #] &, {Center, Left, Right}],
 Frame -> All, ImageSize -> 750
 ]
Out[12]=

AtomColor (1) 

Change the default atomic symbol color:

In[13]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Chlorine"]]
Out[13]=
In[14]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Chlorine"], "AtomColor" -> Black]
Out[14]=

DotColor (1) 

Change the default electron dot color:

In[15]:=
ResourceFunction["LewisSymbol"][Atom["P"]]
Out[15]=
In[16]:=
ResourceFunction["LewisSymbol"][Atom["P"], "DotColor" -> Blue]
Out[16]=

DotPlacement (1) 

Specify the placement of unpaired electrons:

In[17]:=
GraphicsGrid[
 Transpose[Map[
   {#, ResourceFunction["LewisSymbol"][Entity["Element", "Cesium"], "DotPlacement" -> #]} &,
   NestList[RotateLeft, {Right, Left, Above, Below}, 3]
   ]],
 Frame -> All, ImageSize -> 750
 ]
Out[17]=

ElectronFilliing (2) 

Lewis symbols predated quantum mechanics by over 20 years, so the default results for He may surprise modern chemists:

In[18]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Helium"]]
Out[18]=

Use "spShell" to graft quantum mechanical electron filling onto Lewis symbols:

In[19]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Helium"], "ElectronFilling" -> "spShell"]
Out[19]=

Compare the electron dot filling methods:

In[20]:=
GraphicsGrid[
 Map[ResourceFunction["LewisSymbol"][
    EntityValue[EntityClass["Element", "Period2"], "Entity"], "ElectronFilling" -> #] &, {"CubicalAtom", "spShell", "Unequal"}],
 Frame -> All, ImageSize -> 750
 ]
Out[20]=

FontSize (1) 

Adjust the atomic symbol font size:

In[21]:=
ResourceFunction["LewisSymbol"][Atom["Ar"]]
Out[21]=
In[22]:=
ResourceFunction["LewisSymbol"][Atom["Ar"], FontSize -> Scaled[0.1]]
Out[22]=

NetCharge (1) 

Specify the charge for ions:

In[23]:=
GraphicsGrid[
 {Map[ResourceFunction["LewisSymbol"][Entity["Element", "Lithium"], "NetCharge" -> #] &, Range[1, -7, -1]],
  Map[ResourceFunction["LewisSymbol"][Entity["Element", "Chlorine"], "NetCharge" -> #] &, Range[7, -1, -1]]},
 Frame -> All, ImageSize -> 750
 ]
Out[23]=

PairPlacement (1) 

Specify the placement of paired electrons:

In[24]:=
GraphicsGrid[
 Transpose[Map[
   {#, ResourceFunction["LewisSymbol"][Entity["Element", "Antimony"], "PairPlacement" -> #]} &,
   NestList[RotateLeft, {Right, Left, Above, Below}, 3]
   ]],
 Frame -> All, ImageSize -> 750
 ]
Out[24]=

ValenceElectronCount (1) 

Elements not contained in the s and p blocks of the periodic table may utilize electrons with different principle quantum numbers as valence electrons:

In[25]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Yttrium"], "ValenceElectronCount" -> 3]
Out[25]=

Applications (2) 

Build Lewis structures for binary salts:

In[26]:=
GraphicsRow[
 ResourceFunction[
  "LewisSymbol"][{ChemicalFormula[{"Na" -> 1}, <|"NetCharge" -> 1|>], ChemicalFormula[{"Cl" -> 1}, <|"NetCharge" -> -1|>]}], Scaled[-0.7]]
Out[26]=

Typeset Lewis structures for binary salts:

In[27]:=
Row[ResourceFunction[
  "LewisSymbol"][{ChemicalFormula[{"Na" -> 1}, <|"NetCharge" -> 1|>], ChemicalFormula[{"Cl" -> 1}, <|"NetCharge" -> -1|>]}, Text], Spacer[5]]
Out[27]=

Properties and Relations (3) 

Lists are automatically threaded over:

In[28]:=
ResourceFunction["LewisSymbol"][{Atom["H"], Atom["Cl"]}]
Out[28]=

PlotRange and ImageSize in combination with FontSize can be used to reduce the white space in a Lewis symbol:

In[29]:=
ResourceFunction["LewisSymbol"][
ChemicalFormula[{"At" -> 1}, <|"NetCharge" -> -1|>]]
Out[29]=
In[30]:=
AbsoluteOptions[%, {PlotRange, ImageSize}]
Out[30]=
In[31]:=
ResourceFunction[
 "LewisSymbol"][ChemicalFormula[{"At" -> 1}, <|"NetCharge" -> -1|>], PlotRange -> Automatic, ImageSize -> 150, FontSize -> Scaled[0.4]]
Out[31]=
In[32]:=
AbsoluteOptions[%, {PlotRange, ImageSize}]
Out[32]=

Text results can be turned into Graphics:

In[33]:=
Graphics[
 Style[ResourceFunction["LewisSymbol"][
   ChemicalFormula[{"O" -> 1}, <|"NetCharge" -> 2|>], Text], FontSize -> Scaled[0.2]]]
Out[33]=

Possible Issues (5) 

Palladium fails since it has more than eight valence electrons:

In[34]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Palladium"]]
Out[34]=

Form the dication to see results:

In[35]:=
ResourceFunction["LewisSymbol"][Entity["Element", "Palladium"], "NetCharge" -> 2]
Out[35]=

A net charge larger than the number of valence electrons fails:

In[36]:=
ResourceFunction["LewisSymbol"][Atom["B"], "NetCharge" -> 4]
Out[36]=

An anion with more than eight electrons fails:

In[37]:=
ResourceFunction["LewisSymbol"][Atom["I"], "NetCharge" -> -2]
Out[37]=

The default valence electron count may be overly simplistic for elements not contained in the s and p blocks of the periodic table:

In[38]:=
ResourceFunction["LewisSymbol"][
ChemicalFormula[{"U" -> 1}, <|"NetCharge" -> 4|>]]
Out[38]=

In this case two 7s electrons, three 5f electrons and one 6d electron are valence electrons:

In[39]:=
ResourceFunction[
 "LewisSymbol"][ChemicalFormula[{"U" -> 1}, <|"NetCharge" -> 4|>], "ValenceElectronCount" -> 6]
Out[39]=

Unexpected results may occur for ions that fill a shell:

In[40]:=
ResourceFunction["LewisSymbol"][
ChemicalFormula[{"H" -> 1}, <|"NetCharge" -> -2|>]]
Out[40]=

Since Lewis symbols predate quantum mechanical electron configurations, use "ValenceElectronCount" to adjust the electron count:

In[41]:=
ResourceFunction[
 "LewisSymbol"][ChemicalFormula[{"H" -> 1}, <|"NetCharge" -> -2|>], "ValenceElectronCount" -> -1]
Out[41]=

Neat Examples (2) 

Build the Lewis symbol for element 119:

In[42]:=
ResourceFunction["LewisSymbol"][Atom[ResourceFunction[
ResourceObject[<|"Name" -> "ElementDesignator", "ShortName" -> "ElementDesignator", "UUID" -> "6a8e2cd0-077a-4fc5-a4f6-9aafdcd39681", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Obtain the International Union of Pure and Applied Chemistry (IUPAC) temporary designators for new elements", "RepositoryLocation" -> URL[
       "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$4a15c4fae0484ebcb94c79f562ec2bb1`ElementDesignator", "FunctionLocation" -> CloudObject[
       "https://www.wolframcloud.com/obj/e16538c5-adab-4c8f-8ed8-42d21436a533"]|>, ResourceSystemBase -> Automatic]][119]], "ValenceElectronCount" -> 1]
Out[42]=

Depict ionization reactions with Lewis electron-dot symbols:

In[43]:=
Style[Row[{ResourceFunction["LewisSymbol"][
ChemicalFormula[{"Ca" -> 1}]], Row[{ResourceFunction["LewisSymbol"][
ChemicalFormula[{"Ca" -> 1}, <|"NetCharge" -> 2|>]], Row[{2, Entity["Particle", "Electron"][
        EntityProperty["Particle", "FullSymbol"]]}]}, "+ "]}, "\[LongRightArrow]"],
  FontSize -> Scaled[0.02]]
Out[43]=

Publisher

WolframChemistry

Requirements

Wolfram Language 13.1 (June 2022) or above

Version History

  • 1.0.0 – 04 April 2025

Source Metadata

Related Resources

Author Notes

In 1902, Lewis first wrote down his cubical atom model of bonding that would later be published in the 1916 source article above. The model envisions an atom as a kernel of positive charge (aka nucleus) that remains unaltered in chemical changes. The kernel is surrounded by a shell of up to eight valence electrons, an octet, arranging themselves symmetrically on the eight corners of a cube. In this model, the kernel is represented by the atomic symbol in a different type (originally boldface) with the positive charge usually omitted. To typeset his cubical atom bonding model, Lewis suggests using dots to represent electrons around the four sides of the atomic symbol. The cubical shell of electrons is flattened into a square enclosing the kernel represented by the boldface atomic symbol. Since electrons are negatively charged particles and are outside of the kernel, the first four electrons in a Lewis symbol are typeset as far apart as possible to align with a classical mechanics understanding of electrons. With five to eight electrons, colons are used rather than dots in the symbols but the implication remains that those electrons would be as far apart from each other as possible, namely on the corners of a cube. It would be nearly 25 years before the notion of quantum mechanical orbitals would replace this classical mechanic bonding model.

License Information