diff --git a/docs/build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle
index cf8f527..559019a 100644
Binary files a/docs/build/doctrees/environment.pickle and b/docs/build/doctrees/environment.pickle differ
diff --git a/docs/build/doctrees/reactions.doctree b/docs/build/doctrees/reactions.doctree
index fb4d13b..a43f16a 100644
Binary files a/docs/build/doctrees/reactions.doctree and b/docs/build/doctrees/reactions.doctree differ
diff --git a/docs/build/html/_modules/chemlib/chemistry.html b/docs/build/html/_modules/chemlib/chemistry.html
index 52118c0..9bff25e 100644
--- a/docs/build/html/_modules/chemlib/chemistry.html
+++ b/docs/build/html/_modules/chemlib/chemistry.html
@@ -423,7 +423,31 @@
Source code for chemlib.chemistry
amounts.append(compound_list[i].get_amounts(moles = index_moles*multipliers[i]))
amounts[compound_number - 1] = index_amounts
- return amounts
+ return amounts
+
+ def limiting_reagent(self, *args, mode = 'grams'):
+ if mode not in ['grams', 'molecules', 'moles']:
+ raise ValueError("mode must be either grams, moles, or molecules. Default is grams")
+
+ if not self.is_balanced: self.balance()
+
+ reactants = []
+ rformulas = []
+ for i in self.reactants:
+ if i.formula not in rformulas:
+ rformulas.append(i.formula)
+ reactants.append(i)
+
+ if len(args) != len(reactants):
+ raise TypeError(f"Expected {len(reactants)} arguments. The number of arguments should be equal to the number of reactants.")
+
+ amounts = [reactants[i].get_amounts(**{mode: args[i]}) for i in range(len(args))]
+ moles = [i['Moles'] for i in amounts]
+ chosen_product = self.products[-1]
+ eq_amounts = [self.get_amounts(i + 1, moles = moles[i]) for i in range(len(args))]
+ data = [a[-1][mode.capitalize()] for a in eq_amounts]
+
+ return (reactants[np.argmin(data)])
class Combustion(Reaction):
diff --git a/docs/build/html/_sources/reactions.rst.txt b/docs/build/html/_sources/reactions.rst.txt
index 0db2703..c13606e 100644
--- a/docs/build/html/_sources/reactions.rst.txt
+++ b/docs/build/html/_sources/reactions.rst.txt
@@ -91,4 +91,29 @@ Get the amounts of ALL compounds in the above reaction given 5 grams of N₂O₅
Get the amounts of ALL compounds in the above reaction given 3.5 moles of HNO₃. It is the third compound in the reaction by order of appearance (left to right).
>>> r.get_amounts(3, moles=3.5)
-[{'Compound': 'N₂O₅', 'Grams': 189.018, 'Moles': 1.75, 'Molecules': 1.054e+24}, {'Compound': 'H₂O₁', 'Grams': 31.518, 'Moles': 1.75, 'Molecules': 1.054e+24}, {'Compound': 'H₁N₁O₃', 'Grams': 220.535, 'Moles': 3.5, 'Molecules': 2.107e+24}]
\ No newline at end of file
+[{'Compound': 'N₂O₅', 'Grams': 189.018, 'Moles': 1.75, 'Molecules': 1.054e+24}, {'Compound': 'H₂O₁', 'Grams': 31.518, 'Moles': 1.75, 'Molecules': 1.054e+24}, {'Compound': 'H₁N₁O₃', 'Grams': 220.535, 'Moles': 3.5, 'Molecules': 2.107e+24}]
+
+Limiting Reagent
+----------------
+.. py:function:: chemlib.chemistry.Reaction.limiting_reagent(self, *args, mode = 'grams')
+
+ Get the limiting reagent (limiting reactant) in the chemical reaction.
+
+ :param args: The amounts of each reactant to use in the chemical reaction.
+ :param str mode: The units of each amount in args. Default is grams, can also be moles or molecules.
+ :return: The limiting reagent of the reaction.
+ :rtype: chemlib.chemistry.Compound
+ :raises TypeError: If the number of args doesn't match the number of reactants in the reaction.
+ :raises ValueError: If the mode is not grams, moles, or molecules.
+
+ Find the limiting reagent of the reaction when using 50 grams of the first reactant (N₂O₅) and 80 grams of the second reactant (H₂O):
+
+ >>> lr = r.limiting_reagent(50, 50)
+ >>> lr.formula
+ 'N₂O₅'
+
+ Find the limiting reagent of the reaction when using 3 moles of the first reactant (N₂O₅) and 1 mole of the second reactant (H₂O):
+
+ >>> lr = r.limiting_reagent(3, 1, mode = 'moles')
+ >>> lr.formula
+ 'H₂O₁'
\ No newline at end of file
diff --git a/docs/build/html/genindex.html b/docs/build/html/genindex.html
index 238f8c7..0ad4472 100644
--- a/docs/build/html/genindex.html
+++ b/docs/build/html/genindex.html
@@ -174,6 +174,8 @@ B
chemlib.chemistry.Reaction.balance()
chemlib.chemistry.Reaction.get_amounts()
+
+ chemlib.chemistry.Reaction.limiting_reagent()
@@ -233,10 +235,10 @@ C
chemlib.chemistry.Element.Isotopes (built-in variable)
-
- |
+
chemlib.chemistry.Reaction.is_balanced (built-in variable)
+
+ chemlib.chemistry.Reaction.limiting_reagent()
+
+
chemlib.chemistry.Reaction.product_formulas (built-in variable)
chemlib.chemistry.Reaction.reactant_formulas (built-in variable)
diff --git a/docs/build/html/index.html b/docs/build/html/index.html
index 71f4c4d..2c4e899 100644
--- a/docs/build/html/index.html
+++ b/docs/build/html/index.html
@@ -281,6 +281,7 @@
Balancing the Equation
Stoichiometry
+Limiting Reagent
diff --git a/docs/build/html/objects.inv b/docs/build/html/objects.inv
index a662952..4fcf505 100644
Binary files a/docs/build/html/objects.inv and b/docs/build/html/objects.inv differ
diff --git a/docs/build/html/reactions.html b/docs/build/html/reactions.html
index e802b27..e9aa5bb 100644
--- a/docs/build/html/reactions.html
+++ b/docs/build/html/reactions.html
@@ -89,6 +89,7 @@
Combustion Reactions
Balancing the Equation
Stoichiometry
+Limiting Reagent
@@ -290,6 +291,47 @@ Stoichiometry |