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 @@

    ContentsCombustion Reactions

  • 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[{'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

    +
    +
    +chemlib.chemistry.Reaction.limiting_reagent(self, *args, mode='grams')
    +

    Get the limiting reagent (limiting reactant) in the chemical reaction.

    +
    +
    Parameters
    +
      +
    • args – The amounts of each reactant to use in the chemical reaction.

    • +
    • mode (str) – The units of each amount in args. Default is grams, can also be moles or molecules.

    • +
    +
    +
    Returns
    +

    The limiting reagent of the reaction.

    +
    +
    Return type
    +

    chemlib.chemistry.Compound

    +
    +
    Raises
    +
      +
    • TypeError – If the number of args doesn’t match the number of reactants in the reaction.

    • +
    • 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₁'
    +
    +
    +
    +
    diff --git a/docs/build/html/searchindex.js b/docs/build/html/searchindex.js index 3ee7cf3..9772c62 100644 --- a/docs/build/html/searchindex.js +++ b/docs/build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["compounds","core","index","reactions"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["compounds.rst","core.rst","index.rst","reactions.rst"],objects:{"chemlib.chemistry":{Combustion:[3,1,1,""],Compound:[0,1,1,""],Element:[1,1,1,""],PeriodicTable:[1,1,1,""],Reaction:[3,1,1,""]},"chemlib.chemistry.Compound":{get_amounts:[0,2,1,""],molar_mass:[0,2,1,""],occurences:[0,0,1,""],percentage_by_mass:[0,2,1,""]},"chemlib.chemistry.Element":{AtomicMass:[1,0,1,""],AtomicNumber:[1,0,1,""],AtomicRadius:[1,0,1,""],BoilingPoint:[1,0,1,""],Density:[1,0,1,""],Discoverer:[1,0,1,""],Electronegativity:[1,0,1,""],Electrons:[1,0,1,""],Element:[1,0,1,""],FirstIonization:[1,0,1,""],Group:[1,0,1,""],Isotopes:[1,0,1,""],MeltingPoint:[1,0,1,""],Metal:[1,0,1,""],Metalloid:[1,0,1,""],Natural:[1,0,1,""],Neutrons:[1,0,1,""],Nonmetal:[1,0,1,""],Period:[1,0,1,""],Phase:[1,0,1,""],Protons:[1,0,1,""],Radioactive:[1,0,1,""],Symbol:[1,0,1,""],Type:[1,0,1,""]},"chemlib.chemistry.Reaction":{balance:[3,2,1,""],formula:[3,0,1,""],get_amounts:[3,2,1,""],is_balanced:[3,0,1,""],product_formulas:[3,0,1,""],reactant_formulas:[3,0,1,""]},chemlib:{AVOGADROS_NUMBER:[1,0,1,""]}},objnames:{"0":["py","data","Python data"],"1":["py","class","Python class"],"2":["py","function","Python function"]},objtypes:{"0":"py:data","1":"py:class","2":"py:function"},terms:{"00589":1,"018":3,"026":2,"02e":[1,2],"0463":3,"054e":3,"0606":2,"0926":3,"107e":3,"111":0,"113":[1,2],"114":[1,2],"115":[1,2],"116":[1,2],"117":[1,2],"118":[1,2],"1298":1,"131":1,"158":1,"160":[],"161":1,"165":1,"174":2,"1808":2,"183":0,"189":3,"1898":1,"1c\u2081h\u2084":3,"1c\u2081o\u2082":3,"1h\u2081n\u2081o\u2083":3,"1h\u2081o\u2082":2,"1h\u2082":2,"1h\u2082o\u2081":3,"1n\u2082o\u2085":3,"1o\u2082":2,"1s1":[1,2],"1s2":[1,2],"2016":[],"204e":0,"220":3,"2270":[],"2573":2,"288":[1,2],"289":[1,2],"292":[1,2],"293":1,"294":[1,2],"295":[1,2],"298":2,"2h\u2081n\u2081o\u2083":3,"2h\u2081o\u2082":2,"2h\u2082o\u2081":3,"2o\u2082":[2,3],"2p1":[1,2],"2s1":[1,2],"2s2":[1,2],"3223":0,"4200":2,"4d10":1,"518":3,"535":3,"575e":3,"5f14":[1,2],"5p6":1,"5s2":1,"647e":2,"6611":2,"685e":0,"6d10":[1,2],"787e":3,"7p2":[1,2],"7p3":[1,2],"7p4":[1,2],"7p5":[1,2],"7p6":[1,2],"7s2":[1,2],"811":2,"834":[0,2,3],"835":3,"boolean":[1,3],"class":[0,1,3],"float":[0,1],"h\u2081n\u2081o\u2083":3,"h\u2081o\u2082":2,"h\u2082o\u2081":[0,3],"hno\u2083":3,"import":[0,1,2,3],"int":[0,3],"n\u2082o\u2085":3,"return":[0,3],"true":[1,2,3],Gas:1,The:[0,1,3],Use:[],__init__:[],abov:3,accept:2,accur:[],algebra:3,all:[1,3],amount:[0,1,3],appear:[0,3],applic:3,arg:1,argument:[0,3],atom_list:0,atomicmass:[1,2],atomicnumb:[1,2],atomicradiu:[1,2],attribut:[],avogaadro:1,avogadro:[],avogadros_numb:1,background:[],base:1,basestr:[],best:3,bodi:[],boilingpoint:[1,2],bool:[],boron:2,calcul:2,can:[],certain:0,charact:[],chemistri:[0,1,3],chemlib:[0,1,3],chemsitri:[],choic:2,chosen:[0,3],code:[],column:[1,2],combust:2,come:[],composit:2,compound:3,compound_numb:[0,3],config:[1,2],constant:2,constitu:[0,1,2],contain:[0,1],core:2,correspond:[],data:2,datafram:1,declar:2,demonstr:3,densiti:[1,2],dict:[0,3],dictionari:0,discover:[1,2],document:[],each:3,easi:2,edu:[],either:0,electron:[1,2],electroneg:[1,2],element:0,equat:2,exampl:3,exce:[],fals:[1,2,3],first:3,firstion:[1,2],formula:[0,2,3],frame:1,frequenc:0,from:[0,1,2,3],gai:2,gas:1,get:[0,2,3],get_amount:[0,2,3],given:[0,3],gram:[0,2,3],greater:3,group:[1,2],gustafso:[],h2o:[2,3],help:[],hno3:3,http:[],hydrogen:0,hyperlink:[],index:2,inherit:3,initi:[],input:2,instanti:[0,1,3],integ:[],involv:3,is_balanc:[2,3],isn:0,isotop:[1,2],its:2,kwarg:[0,1,3],left:3,less:3,linear:3,list:[0,1,3],lussac:2,make:2,mass:2,massnumb:[1,2],math:[],matter:1,measur:0,meltingpoint:[1,2],messag:[],message_bodi:[],metal:[1,2],metalloid:[1,2],methan:3,modul:2,mol:0,molar:2,molar_mass:[0,2],mole:[0,2,3],molecul:[0,2,3],more:[0,3],n2o5:3,name:1,nan:1,natur:[1,2],necessari:[],neutron:[1,2],nitric_acid:2,nobl:1,none:3,nonmet:[1,2],number:[1,3],object:[0,1,3],occur:[0,2],one:[0,3],order:[0,3],other:2,overflow:[],oxygen:0,page:2,panda:1,paramet:[0,3],particl:1,pdf:[],percent:0,percentag:2,percentage_by_mass:[0,2],perform:2,periodict:1,person:[],phase:[1,2],pip:2,prioriti:[],product:[2,3],product_formula:3,project:[],properti:1,proton:[1,2],pte:[1,2],python:[],quickli:2,quux:[],radioact:[1,2],rais:[0,3],ramsai:1,reactant:[2,3],reactant_formula:3,reaction:0,recipi:[],relat:1,repres:0,respect:1,right:3,room:1,row:[1,2],s2017:[],sampl:1,sanchezdario:[],search:2,see:3,self:[0,3],send:[],send_messag:[],sender:[],shell:[1,2],signatur:[],solid:2,soon:[],sourc:[0,1,3],specificheat:[1,2],stack:[],state:1,stoichiometr:[0,3],stoichiometri:2,str:[0,1,3],substanc:1,symbol:[0,1,2],teh:[],temperatur:1,test:[],than:[0,3],third:3,those:[],traver:1,type:[0,1,2,3],typeerror:[],under:[0,3],unnam:[1,2],use:2,user:0,using:3,utah:[],valenc:[1,2],valu:[],valueerror:[0,3],want:0,water:[0,2],which:[0,1],www:[],xenon:1,year:[1,2]},titles:["Chemical Compounds","Core Data","chemlib: a pure Python chemistry library","Chemical Reactions"],titleterms:{"class":2,access:2,balanc:[2,3],chemic:[0,2,3],chemistri:2,chemlib:2,combust:3,composit:0,compound:[0,2],constant:1,content:2,convers:2,core:1,data:1,datafram:2,easili:2,element:[1,2],equat:3,featur:2,indic:2,instal:2,librari:2,make:[0,3],mass:0,molar:0,object:2,other:1,panda:2,percentag:0,period:[1,2],periodict:[],properti:2,pure:2,python:2,reaction:[2,3],stoichiometr:2,stoichiometri:[0,3],tabl:[1,2]}}) \ No newline at end of file +Search.setIndex({docnames:["compounds","core","index","reactions"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["compounds.rst","core.rst","index.rst","reactions.rst"],objects:{"chemlib.chemistry":{Combustion:[3,1,1,""],Compound:[0,1,1,""],Element:[1,1,1,""],PeriodicTable:[1,1,1,""],Reaction:[3,1,1,""]},"chemlib.chemistry.Compound":{get_amounts:[0,2,1,""],molar_mass:[0,2,1,""],occurences:[0,0,1,""],percentage_by_mass:[0,2,1,""]},"chemlib.chemistry.Element":{AtomicMass:[1,0,1,""],AtomicNumber:[1,0,1,""],AtomicRadius:[1,0,1,""],BoilingPoint:[1,0,1,""],Density:[1,0,1,""],Discoverer:[1,0,1,""],Electronegativity:[1,0,1,""],Electrons:[1,0,1,""],Element:[1,0,1,""],FirstIonization:[1,0,1,""],Group:[1,0,1,""],Isotopes:[1,0,1,""],MeltingPoint:[1,0,1,""],Metal:[1,0,1,""],Metalloid:[1,0,1,""],Natural:[1,0,1,""],Neutrons:[1,0,1,""],Nonmetal:[1,0,1,""],Period:[1,0,1,""],Phase:[1,0,1,""],Protons:[1,0,1,""],Radioactive:[1,0,1,""],Symbol:[1,0,1,""],Type:[1,0,1,""]},"chemlib.chemistry.Reaction":{balance:[3,2,1,""],formula:[3,0,1,""],get_amounts:[3,2,1,""],is_balanced:[3,0,1,""],limiting_reagent:[3,2,1,""],product_formulas:[3,0,1,""],reactant_formulas:[3,0,1,""]},chemlib:{AVOGADROS_NUMBER:[1,0,1,""]}},objnames:{"0":["py","data","Python data"],"1":["py","class","Python class"],"2":["py","function","Python function"]},objtypes:{"0":"py:data","1":"py:class","2":"py:function"},terms:{"00589":1,"018":3,"026":2,"02e":[1,2],"0463":3,"054e":3,"0606":2,"0926":3,"0x03136370":[],"107e":3,"111":0,"113":[1,2],"114":[1,2],"115":[1,2],"116":[1,2],"117":[1,2],"118":[1,2],"1298":1,"131":1,"158":1,"160":[],"161":1,"165":1,"174":2,"1808":2,"183":0,"189":3,"1898":1,"1c\u2081h\u2084":3,"1c\u2081o\u2082":3,"1h\u2081n\u2081o\u2083":3,"1h\u2081o\u2082":2,"1h\u2082":2,"1h\u2082o\u2081":3,"1n\u2082o\u2085":3,"1o\u2082":2,"1s1":[1,2],"1s2":[1,2],"2016":[],"204e":0,"220":3,"2270":[],"2573":2,"288":[1,2],"289":[1,2],"292":[1,2],"293":1,"294":[1,2],"295":[1,2],"298":2,"2h\u2081n\u2081o\u2083":3,"2h\u2081o\u2082":2,"2h\u2082o\u2081":3,"2o\u2082":[2,3],"2p1":[1,2],"2s1":[1,2],"2s2":[1,2],"3223":0,"4200":2,"4d10":1,"518":3,"535":3,"575e":3,"5f14":[1,2],"5p6":1,"5s2":1,"647e":2,"6611":2,"685e":0,"6d10":[1,2],"787e":3,"7p2":[1,2],"7p3":[1,2],"7p4":[1,2],"7p5":[1,2],"7p6":[1,2],"7s2":[1,2],"811":2,"834":[0,2,3],"835":3,"boolean":[1,3],"class":[0,1,3],"default":3,"float":[0,1],"h\u2081n\u2081o\u2083":3,"h\u2081o\u2082":2,"h\u2082o":3,"h\u2082o\u2081":[0,3],"hno\u2083":3,"import":[0,1,2,3],"int":[0,3],"n\u2082o\u2085":3,"return":[0,3],"true":[1,2,3],Gas:1,The:[0,1,3],Use:[],__init__:[],abov:3,accept:2,accur:[],algebra:3,all:[1,3],also:3,amount:[0,1,3],appear:[0,3],applic:3,arg:[1,3],argument:[0,3],atom_list:0,atomicmass:[1,2],atomicnumb:[1,2],atomicradiu:[1,2],attribut:[],avogaadro:1,avogadro:[],avogadros_numb:1,background:[],base:1,basestr:[],best:3,bodi:[],boilingpoint:[1,2],bool:[],boron:2,calcul:2,can:3,certain:0,charact:[],chemistri:[0,1,3],chemlib:[0,1,3],chemsitri:[],choic:2,chosen:[0,3],code:[],column:[1,2],combust:2,come:[],composit:2,compound:3,compound_numb:[0,3],config:[1,2],constant:2,constitu:[0,1,2],contain:[0,1],core:2,correspond:[],data:2,datafram:1,declar:2,demonstr:3,densiti:[1,2],dict:[0,3],dictionari:0,discover:[1,2],document:[],doesn:3,each:3,easi:2,edu:[],either:0,electron:[1,2],electroneg:[1,2],element:0,equat:2,exampl:3,exce:[],fals:[1,2,3],find:3,first:3,firstion:[1,2],formula:[0,2,3],frame:1,frequenc:0,from:[0,1,2,3],gai:2,gas:1,get:[0,2,3],get_amount:[0,2,3],given:[0,3],gram:[0,2,3],greater:3,group:[1,2],gustafso:[],h2o:[2,3],help:[],hno3:3,http:[],hydrogen:0,hyperlink:[],index:2,inherit:3,initi:[],input:2,instanti:[0,1,3],integ:[],involv:3,is_balanc:[2,3],isn:0,isotop:[1,2],its:2,kwarg:[0,1,3],left:3,less:3,limit:2,limiting_reag:3,linear:3,list:[0,1,3],lussac:2,make:2,mass:2,massnumb:[1,2],match:3,math:[],matter:1,measur:0,meltingpoint:[1,2],messag:[],message_bodi:[],metal:[1,2],metalloid:[1,2],methan:3,mode:3,modul:2,mol:0,molar:2,molar_mass:[0,2],mole:[0,2,3],molecul:[0,2,3],more:[0,3],n2o5:3,name:1,nan:1,natur:[1,2],necessari:[],neutron:[1,2],nitric_acid:2,nobl:1,none:3,nonmet:[1,2],number:[1,3],object:[0,1,3],occur:[0,2],one:[0,3],order:[0,3],other:2,overflow:[],oxygen:0,page:2,panda:1,paramet:[0,3],particl:1,pdf:[],percent:0,percentag:2,percentage_by_mass:[0,2],perform:2,periodict:1,person:[],phase:[1,2],pip:2,prioriti:[],product:[2,3],product_formula:3,project:[],properti:1,proton:[1,2],pte:[1,2],python:[],quickli:2,quux:[],radioact:[1,2],rais:[0,3],ramsai:1,reactant:[2,3],reactant_formula:3,reaction:0,reagent:2,recipi:[],relat:1,repres:0,respect:1,right:3,room:1,row:[1,2],s2017:[],sampl:1,sanchezdario:[],search:2,second:3,see:3,self:[0,3],send:[],send_messag:[],sender:[],shell:[1,2],signatur:[],solid:2,soon:[],sourc:[0,1,3],specificheat:[1,2],stack:[],state:1,stoichiometr:[0,3],stoichiometri:2,str:[0,1,3],substanc:1,symbol:[0,1,2],teh:[],temperatur:1,test:[],than:[0,3],third:3,those:[],traver:1,type:[0,1,2,3],typeerror:3,under:[0,3],unit:3,unnam:[1,2],use:[2,3],user:0,using:3,utah:[],valenc:[1,2],valu:[],valueerror:[0,3],want:0,water:[0,2],when:3,which:[0,1],www:[],xenon:1,year:[1,2]},titles:["Chemical Compounds","Core Data","chemlib: a pure Python chemistry library","Chemical Reactions"],titleterms:{"class":2,access:2,balanc:[2,3],chemic:[0,2,3],chemistri:2,chemlib:2,combust:3,composit:0,compound:[0,2],constant:1,content:2,convers:2,core:1,data:1,datafram:2,easili:2,element:[1,2],equat:3,featur:2,indic:2,instal:2,librari:2,limit:3,make:[0,3],mass:0,molar:0,object:2,other:1,panda:2,percentag:0,period:[1,2],periodict:[],properti:2,pure:2,python:2,reaction:[2,3],reagent:3,stoichiometr:2,stoichiometri:[0,3],tabl:[1,2]}}) \ No newline at end of file diff --git a/docs/source/reactions.rst b/docs/source/reactions.rst index 0db2703..c13606e 100644 --- a/docs/source/reactions.rst +++ b/docs/source/reactions.rst @@ -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