Chemistry

My name is Peter Burbery. I would like to demonstrate some work of mine with chemistry functions.
The important functions I will be using are ChemicalReaction, ReactionBalance, ReactionBalancedQ, ChemicalInstance, and ChemicalFormula. I use ChemicalReaction to represent chemical reactions.
Introduction

ReactionData
Let’s use ReactionData for stoichiometry.
We have the reaction
(N
H
4
)
2
Cr
O
4
⟶
N
2
+
Cr
2
O
3
+4
H
2
O
. We have 1.234 kg of
(N
H
4
)
2
Cr
2
O
7
. For each chemical in the equation, calculate how the mass, moles, and number of molecules using stoichiometry and molar ratios:
In[]:=
reaction=ChemicalReaction<|
ammonium bichromate
CHEMICAL
->1|>-><|
nitrogen
CHEMICAL
->1,
chromium(III) oxide
CHEMICAL
->1,
water
CHEMICAL
->4|>
Out[]=
ChemicalReaction
(N
H
4
)
2
Cr
O
4
⟶
N
2
+
Cr
2
O
3
+
4
H
2
O

In[]:=
ResourceFunction["ReactionData"]reaction,ChemicalInstance
ammonium bichromate
CHEMICAL
,
1.234`
kg

Out[]=
Mass
Amount
MoleculeCount
ammonium bichromate
1.234kg
4.8956mol
2.9482×
24
10
molecules
nitrogen
0.137145kg
4.8956mol
2.9482×
24
10
molecules
chromium(III) oxide
0.744079kg
4.8956mol
2.9482×
24
10
molecules
water
0.352777kg
19.5824mol
1.17928×
25
10
molecules
Use an association instead of a dataset:
In[]:=
ResourceFunction["ReactionData"]reaction,ChemicalInstance
ammonium bichromate
CHEMICAL
,
1.234`
kg
,"Association"

Applications


LimitingReagent
We have
2C
H
3
OH+3
O
2
⟶ 2C
O
2
+4
H
2
O
. We have 1 Mg of each reactant and product. What is the limiting reactant? What reactants are in excess? How much of the excess reactant is left over? What would we need for an ideal reaction for each case? Give moles, mass, and molecules for each case.
In[]:=
ResourceFunction[CloudObject["https://www.wolframcloud.com/obj/burbery1/DeployedResources/Function/LimitingReagent"]]ChemicalReaction[<|Entity["Chemical","Methanol"]->2,Entity["Chemical","MolecularOxygen"]->3|>-><|Entity["Chemical","CarbonDioxide"]->2,Entity["Chemical","Water"]->4|>],ChemicalInstance
methanol
CHEMICAL
,
1
Mg
,ChemicalInstance
oxygen
CHEMICAL
,
1
Mg
,ChemicalInstance
carbon dioxide
CHEMICAL
,
1
Mg
,ChemicalInstance
water
CHEMICAL
,
1
Mg

Out[]=
LimitingReagent
oxygen
,ExcessReagents
methanol
,LimitingReagentReactionAssociation
methanol
Mass
667.6
kg
,Amount
20835.
mol
,MoleculeCount
1.2547×
28
10
molecules
,
oxygen
Mass
1000.0
kg
,Amount
31252.
mol
,MoleculeCount
1.8820×
28
10
molecules
,
carbon dioxide
Mass
916.9
kg
,Amount
20835.
mol
,MoleculeCount
1.2547×
28
10
molecules
,
water
Mass
750.7
kg
,Amount
41669.
mol
,MoleculeCount
2.5094×
28
10
molecules
,LimitingReagentReactionDataset
Mass
Amount
MoleculeCount
methanol
667.6kg
20835.mol
1.2547×
28
10
molecules
oxygen
1000.0kg
31252.mol
1.8820×
28
10
molecules
carbon dioxide
916.9kg
20835.mol
1.2547×
28
10
molecules
water
750.7kg
41669.mol
2.5094×
28
10
molecules
,ReactionDataAssociationChemicalInstance
methanol
,
1
Mg

methanol
Mass
1000.0
kg
,Amount
31209.
mol
,MoleculeCount
1.8795×
28
10
molecules
,
oxygen
Mass
1497.9
kg
,Amount
46814.
mol
,MoleculeCount
2.8192×
28
10
molecules
,
carbon dioxide
Mass
1373.5
kg
,Amount
31209.
mol
,MoleculeCount
1.8795×
28
10
molecules
,
water
Mass
1124.5
kg
,Amount
6.242×
4
10
mol
,MoleculeCount
3.7589×
28
10
molecules
,ChemicalInstance
oxygen
,
1
Mg

methanol
Mass
667.6
kg
,Amount
20835.
mol
,MoleculeCount
1.2547×
28
10
molecules
,
oxygen
Mass
1000.0
kg
,Amount
31252.
mol
,MoleculeCount
1.8820×
28
10
molecules
,
carbon dioxide
Mass
916.9
kg
,Amount
20835.
mol
,MoleculeCount
1.2547×
28
10
molecules
,
water
Mass
750.7
kg
,Amount
41669.
mol
,MoleculeCount
2.5094×
28
10
molecules
,ChemicalInstance
carbon dioxide
,
1
Mg

methanol
Mass
728.1
kg
,Amount
22723.
mol
,MoleculeCount
1.3684×
28
10
molecules
,
oxygen
Mass
1090.6
kg
,Amount
34084.
mol
,MoleculeCount
2.0526×
28
10
molecules
,
carbon dioxide
Mass
1000.0
kg
,Amount
22723.
mol
,MoleculeCount
1.3684×
28
10
molecules
,
water
Mass
818.7
kg
,Amount
45445.
mol
,MoleculeCount
2.7368×
28
10
molecules
,ChemicalInstance
water
,
1
Mg

methanol
Mass
889.3
kg
,Amount
27755.
mol
,MoleculeCount
1.6714×
28
10
molecules
,
oxygen
Mass
1332.1
kg
,Amount
41632.
mol
,MoleculeCount
2.5071×
28
10
molecules
,
carbon dioxide
Mass
1221.5
kg
,Amount
27755.
mol
,MoleculeCount
1.6714×
28
10
molecules
,
water
Mass
1000.0
kg
,Amount
5.551×
4
10
mol
,MoleculeCount
3.3428×
28
10
molecules
,ReactionDataset
Mass
Amount
MoleculeCount
ChemicalInstance
methanol
,
1
Mg

methanol
1000.0kg
31209.mol
1.8795×
28
10
molecules
oxygen
1497.9kg
46814.mol
2.8192×
28
10
molecules
carbon dioxide
1373.5kg
31209.mol
1.8795×
28
10
molecules
water
1124.5kg
6.242×
4
10
mol
3.7589×
28
10
molecules
ChemicalInstance
oxygen
,
1
Mg

methanol
667.6kg
20835.mol
1.2547×
28
10
molecules
oxygen
1000.0kg
31252.mol
1.8820×
28
10
molecules
carbon dioxide
916.9kg
20835.mol
1.2547×
28
10
molecules
water
750.7kg
41669.mol
2.5094×
28
10
molecules
ChemicalInstance
carbon dioxide
,
1
Mg

methanol
728.1kg
22723.mol
1.3684×
28
10
molecules
oxygen
1090.6kg
34084.mol
2.0526×
28
10
molecules
carbon dioxide
1000.0kg
22723.mol
1.3684×
28
10
molecules
water
818.7kg
45445.mol
2.7368×
28
10
molecules
ChemicalInstance
water
,
1
Mg

methanol
889.3kg
27755.mol
1.6714×
28
10
molecules
oxygen
1332.1kg
41632.mol
2.5071×
28
10
molecules
carbon dioxide
1221.5kg
27755.mol
1.6714×
28
10
molecules
water
1000.0kg
5.551×
4
10
mol
3.3428×
28
10
molecules
,LeftOverAssociation
methanol
Mass
332.4
kg
,Amount
10374.
mol
,Molecules
6.248×
27
10
molecules
,
oxygen
Mass
0.×
-2
10
kg
,Amount
0.×
-1
10
mol
,Molecules
0``-23.57565806398258
molecules
,
carbon dioxide
Mass
83.1
kg
,Amount
1888.
mol
,Molecules
1.137×
27
10
molecules
,
water
Mass
249.3
kg
,Amount
1.384×
4
10
mol
,Molecules
8.335×
27
10
molecules
,LeftOverDataset
Mass
Amount
Molecules
methanol
332.4kg
10374.mol
6.248×
27
10
molecules
oxygen
0.×
-2
10
kg
0.×
-1
10
mol
0``-23.57565806398258molecules
carbon dioxide
83.1kg
1888.mol
1.137×
27
10
molecules
water
249.3kg
1.384×
4
10
mol
8.335×
27
10
molecules

Please visit https://www.wolframcloud.com/obj/burbery1/DeployedResources/Function/LimitingReagent/ for more details.
LimitingIngredient
I made a function LimitingIngredient that has some issues with a cell. The function is available at https://www.wolframcloud.com/obj/burbery1/DeployedResources/Function/LimitingIngredient/.
This is from Chem Libretexts:
​
​
​
When there is not enough of one reactant in a chemical reaction, the reaction stops abruptly. To figure out the amount of product produced, it must be determined which reactant will limit the chemical reaction (the limiting reagent) and which reactant is in excess (the excess reagent). One way of finding the limiting reagent is by calculating the amount of product that can be formed by each reactant; the one that produces less product is the limiting reagent. The following scenario illustrates the significance of limiting reagents. In order to assemble a car, 4 tires and 2 headlights are needed (among other things). In this example, imagine that the tires and headlights are reactants while the car is the product formed from the reaction of 4 tires and 2 headlights. 4 tires+2 headlights=1 car
​
​
​
If you have 20 tires and 14 headlights, how many cars can be made? With 20 tires, 5 cars can be produced because there are 4 tires to a car. With 14 headlights, 7 cars can be built (each car needs 2 headlights). Although more cars can be made from the headlights available, only 5 full cars are possible because of the limited number of tires available. In this case, the headlights are in excess. Because the number of cars formed by 20 tires is less than number of cars produced by 14 headlights, the tires are the limiting reagent (they limit the full completion of the reaction, in which all of the reactants are used up).
​
​
​
I want to verify their analysis:
In[]:=
ResourceFunction[CloudObject["https://www.wolframcloud.com/obj/burbery1/DeployedResources/Function/LimitingIngredient"]][<|"tire"->4,"headlight"->2|>-><|"car"->1|>,{{"tire",20},{"headlight",14}}]
Out[]=
limitingitemtire,excessitems{headlight},limitingitemrelationtire20,headlight10car5,leftoverheadlight4,tire0,relationstiretire20,headlight10car5,headlighttire28,headlight14car7,factors{{tire,20}5,{headlight,14}7}
Consider another food analogy, making grilled cheese sandwiches (Figure 7.13): 1 slice of cheese+2 slices of bread⟶1 sandwich Stoichiometric amounts of sandwich ingredients for this recipe are bread and cheese slices in a 2:1 ratio. Provided with 28 slices of bread and 11 slices of cheese, one may prepare 11 sandwiches per the provided recipe, using all the provided cheese and having six slices of bread left over. In this scenario, the number of sandwiches prepared has been limited by the number of cheese slices, and the bread slices have been provided in excess:
Yield
This is available at https://www.wolframcloud.com/obj/burbery1/DeployedResources/Function/Yield/. There are issues with the cloud notebook.
Hess’s Law
I made a function to compute Hess’s Law. Please visit https://www.wolframcloud.com/obj/burbery1/DeployedResources/Function/HessLaw/ if you are interested.
The problem is the reaction that changes the state of HCl with delta H of -74.8 KJ and the reaction that changes the state of AlCl3 with a delta H of 323 KJ. There might be a way to account for this using EntityInstance. At the moment, I am going to say that unfortunately, Hess law problems with things like HCl(g)->HCl(aq) and AlCl3(aq)->AlCl(s) are not supported.
Combustion Reaction
This is from ReactionBalance’s documentation Application section.
Write a function to return balanced combustion reactions:
Find the balanced reactions to combust several hydrocarbons:
the paclet WolframChemistry/ChemistryFunctions
I would like to mention that the paclet WolframChemistry/ChemistryFunctions has a very helpful function for going from composition (I don’t like to say percent composition) to the molar formula and the molecular formula of a chemical.
Find the empirical formula for a compound that is 64.3% carbon, 7.2% hydrogen, and 28.5% oxygen:
Create a plot showing the electrons in the radioactive element californium:
Other

Significant Figures

To calculate significant figures, please use https://www.chemicalaid.com/’s calculator https://www.chemicalaid.com/tools/sigfigscalculator.php

Chemical Reaction Examples

For examples of chemical reactions, please visit https://chemequations.com/en/.
Other helpful resources include the free online Openstax Chemistry Atoms First 2e and Chemistry Libretexts.