Chemlib Readthedocs Io en Latest
Chemlib Readthedocs Io en Latest
Release v1.0
Hari Ambethkar
1 Installation 3
2 Contents 5
2.1 Core Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Chemical Compounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Empirical Formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Chemical Reactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Aqueous Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 Electrochemistry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.7 Quantum Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Index 21
i
ii
chemlib, Release v1.0
Chemlib is a pure Python library that supports a variety of functions pertaining to the vast field of chemistry. It is under
active development and continually improved to include more and more features.
CONTENTS 1
chemlib, Release v1.0
2 CONTENTS
CHAPTER
ONE
INSTALLATION
3
chemlib, Release v1.0
4 Chapter 1. Installation
CHAPTER
TWO
CONTENTS
2.1.2 Elements
˓→'Ramsay and Travers', 'Year': '1898', 'SpecificHeat': '0.158', 'Shells': 5.0, 'Valence
>>> xenon.AtomicMass
131.293
>>> xenon.FirstIonization
'12.1298'
5
chemlib, Release v1.0
chemlib.chemistry.Element.AtomicNumber: float
chemlib.chemistry.Element.AtomicMass: float
chemlib.chemistry.Element.Neutrons: float
chemlib.chemistry.Element.Protons: float
chemlib.chemistry.Element.Electrons: float
chemlib.chemistry.Element.Period: float
chemlib.chemistry.Element.Group: float
chemlib.chemistry.Element.Radioactive: boolean
chemlib.chemistry.Element.Natural: boolean
chemlib.chemistry.Element.Metal: boolean
chemlib.chemistry.Element.Nonmetal: boolean
chemlib.chemistry.Element.Metalloid: boolean
chemlib.chemistry.Element.Type: str
chemlib.chemistry.Element.AtomicRadius: str
chemlib.chemistry.Element.Density: float
chemlib.chemistry.Element.MeltingPoint: float
chemlib.chemistry.Element.BoilingPoint: float
chemlib.chemistry.Element.Isotopes: float
chemlib.chemistry.Element.Discoverer: str
6 Chapter 2. Contents
chemlib, Release v1.0
Planck’s constant.
chemlib.R: float = 1.0974e+7
Rydberg constant.
chemlib.chemistry.Compound.occurences: dict
>>> water.occurences
{'H': 2, 'O': 1}
chemlib.chemistry.Compound.molar_mass(self )
Returns
The molar mass in (g/mol) of the compound
Return type
float
>>> water.molar_mass()
18.01
chemlib.chemistry.Compound.percentage_by_mass(self, element)
Get the percentage composition by mass of a certain element of the compound.
Parameters
element (str) – The constituent element of which the user wants to get percentage composition.
Returns
The percentage composition by mass of the element in the compound.
Return type
float
2.2.4 Stoichiometry
chemlib.chemistry.Compound.get_amounts(self, **kwargs)
Get stoichiometric amounts of the compound given one measurement.
Parameters
• compound_number (int) – The chosen compound in the reaction by order of appearance.
• kwargs – The amount of the chosen compound (grams=, moles=, or molecules=)
Returns
The gram, mole, and molecule amounts of the compound.
Return type
dict
Raises
• ValueError – If the kwargs argument isn’t either grams, moles, or molecules
• ValueError – if more than one argument is given under kwargs
Get the amount of moles and molecules of water given 2 grams of water.
>>> water.get_amounts(grams = 2)
{'Compound': 'H2 O1 ', 'Grams': 2, 'Moles': 0.111, 'Molecules': 6.685e+22}
Get the amount of grams and molecules of water given 2 moles of water.
>>> water.get_amounts(moles = 2)
{'Compound': 'H2 O1 ', 'Grams': 36.02, 'Moles': 2, 'Molecules': 1.204e+24}
Get the amount of moles and grams of water given 2e+24 molecules of water.
8 Chapter 2. Contents
chemlib, Release v1.0
chemlib.chemistry.empirical_formula_by_percent_comp(**kwargs)
Get the empirical formula given the percentage compositions of all elements in the compound.
Parameters
kwargs – The percentage compositions of elements in the compound (<Element symbol> =
<Percentage Composition> ...)
Returns
The empirical formula of the compound.
Return type
str
Raises
ValueError – If the sums of the percentages is not equal to 100.
Get the empirical formula of a compound that is composed of 80.6% C, and 19.4% H by mass:
chemlib.chemistry.combustion_analysis(CO2, H2O)
Get the empirical formula of a hydrocarbon given the grams of CO2 and grams of H2O formed from
its combustion.
Parameters
• CO2 – The grams of carbon dioxide formed as a result of the combustion of the hydrocarbon.
• H2O – The grams of water formed as a result of the combustion of the hydrocarbon.
Returns
The empirical formula of the hydrocarbon.
Return type
str
A hydrocarbon fuel is fully combusted with 18.214 g of oxygen to yield 23.118 g of carbon dioxide and 4.729 g of
water. Find the empirical formula for the hydrocarbon.
Instantiate a chemlib.Reaction object with a list of reactant Compounds and product Compounds.
chemlib.chemistry.Reaction.formula: str
>>> r.formula
'1N2 O5 + 1H2 O1 --> 1H1 N1 O3 '
chemlib.chemistry.Reaction.is_balanced: boolean
>>> r.is_balanced
False
chemlib.chemistry.Reaction.reactant_formulas: list
>>> r.reactant_formulas
['N2 O5 ', 'H2 O1 ']
chemlib.chemistry.Reaction.product_formulas: list
>>> r.product_formulas
['H1 N1 O3 ']
10 Chapter 2. Contents
chemlib, Release v1.0
class chemlib.chemistry.Combustion(compound)
chemlib.chemistry.Reaction.balance(self ) → None
Balances the chemical equation using linear algebra. See Applications of Linear Algebra in Chemistry.
>>> r.balance()
>>> r.formula
'1N2 O5 + 1H2 O1 --> 2H1 N1 O3 '
>>> r.is_balanced
True
2.4.4 Stoichiometry
>>> r.formula
'1N2 O5 + 1H2 O1 --> 2H1 N1 O3 '
Get the amounts of ALL compounds in the above reaction given 5 grams of N2 O5 . It is the first compound in the
reaction by order of appearance (left to right).
Get the amounts of ALL compounds in the above reaction given 3.5 moles of HNO3 . It is the third compound in the
reaction by order of appearance (left to right).
Find the limiting reagent of the reaction when using 3 moles of the first reactant (N2 O5 ) and 1 mole of the second
reactant (H2 O):
12 Chapter 2. Contents
chemlib, Release v1.0
chemlib.chemistry.pH(**kwargs)
For any inputted pH, pOH, [H+], or [OH-], finds the corresponding values.
Parameters
kwargs – The value of the chosen input (pH=, pOH=, H=, or OH=)
Return type
dict
What is the pH, pOH and [OH-] given a [H+] of 1.07x10^-6 M?
>>> chemlib.pH(OH=2.06e-3)
{'OH': 0.002, 'H': 5e-12, 'pOH': 2.699, 'pH': 11.301, 'acidity': 'basic'}
Instantiate a chemlib.Solution object with the formula of the solute, and the molarity in mol/L.
param solute (str)
The formula of the solute without using subscripts OR a chemlib.chemistry.Compound
object.
param molarity (float)
How many moles of solute per liter of solution
OR you can make a Solution with the solute, and grams per liter.
param str solute
The formula of the solute without using subscripts OR a chemlib.chemistry.Compound
object.
2.5.3 Dilutions
14 Chapter 2. Contents
chemlib, Release v1.0
2.6 Electrochemistry
Parameters
• (str) (electrode2) – The elemental composition of one of the electrodes of the galvanic
cell.
• (str) – The elemental composition of the other electrode of the galvanic cell.
Raises
NotImplementedError – If either of the electrodes is invalid or its reduction potential is un-
known.
Make a Galvanic Cell with Lead and Zinc electrodes:
chemlib.electrochemistry.Galvanic_Cell.properties: dict
>>> g.properties
{'Cell': 'Zn | Zn2+ || Pb2+ | Pb', 'Anode': 'Zn', 'Cathode': 'Pb', 'Cell Potential': 0.
˓→63}
>>>
chemlib.electrochemistry.Galvanic_Cell.cell_potential: float
>>> g.cell_potential
0.63
>>> g.E0
0.63
chemlib.electrochemistry.Galvanic_Cell.diagram: PIL.Image
>>> g.draw()
2.6. Electrochemistry 15
chemlib, Release v1.0
>>> g.diagram.save("filename.png")
>>>
2.6.2 Electrolysis
Parameters
• (str) (element) – The symbol of a chemical element.
• (int) (n) – The moles of electrons transferred.
• kwargs – Provide two of the values from amps, seconds, and grams.
Raises
TypeError – If not only 2 of the parameters in kwargs are specified.
Example: Copper metal is purified by electrolysis. How much copper metal (in grams) could be produced from copper
(ii) oxide by applying a current of 10.0 amps at the appropriate negative potential for 12.0 hours?
16 Chapter 2. Contents
chemlib, Release v1.0
Example: How long would it take to electroplate a flute with 28.3 g of silver at a constant current of 2.0 amps using
AgNO3?
Example: How much current was used to produce 805 grams of Aluminum metal from Al2O3 in 24 hours?
class chemlib.quantum_mechanics.Wave(**kwargs)
Makes a Wave object given either wavelength (in meters), frequency (in Hz), or energy (in J per photon), and calculates
the aforementioned values.
param kwargs
The value of the known variable (wavelength=, frequency=, or energy=)
Determine the wavelength, frequency, and energy of a wave with frequency 2e+17 Hz:
Determine the wavelength, frequency, and energy of a wave with wavelength 3e-9 m:
>>> w = Wave(wavelength=3e-9)
>>> w.properties
{'wavelength': 3e-09, 'frequency': 9.993e+16, 'energy': 6.622e-17}
Determine the wavelength, frequency, and energy of a wave with energy 3e-15 Joules per particle:
chemlib.quantum_mechanics.Wave.properties: dict
chemlib.quantum_mechanics.Wave.wavelength: float
chemlib.quantum_mechanics.Wave.frequency: float
chemlib.quantum_mechanics.Wave.energy: float
chemlib.quantum_mechanics.energy_of_hydrogen_orbital(n) → float
Gets the energy of an electron in the nth orbital of the Hydrogen atom in Joules.
18 Chapter 2. Contents
CHAPTER
THREE
• genindex
• modindex
• search
19
chemlib, Release v1.0
B chemlib.chemistry.Element.AtomicMass (built-in
built-in function variable), 6
chemlib.chemistry.combustion_analysis(), chemlib.chemistry.Element.AtomicNumber (built-
9 in variable), 5
chemlib.chemistry.Compound.get_amounts(), chemlib.chemistry.Element.AtomicRadius (built-
8 in variable), 6
chemlib.chemistry.Compound.molar_mass(), chemlib.chemistry.Element.BoilingPoint (built-
7 in variable), 6
chemlib.chemistry.Compound.percentage_by_mass(), chemlib.chemistry.Element.Density (built-in vari-
8 able), 6
chemlib.chemistry.Element.Discoverer
chemlib.chemistry.empirical_formula_by_percent_comp(), (built-in
9 variable), 6
chemlib.chemistry.pH(), 13 chemlib.chemistry.Element.Electronegativity
chemlib.chemistry.Reaction.balance(), 11 (built-in variable), 6
chemlib.chemistry.Reaction.get_amounts(), chemlib.chemistry.Element.Electrons (built-in
11 variable), 6
chemlib.chemistry.Reaction.limiting_reagent(), chemlib.chemistry.Element.Element (built-in vari-
12 able), 6
chemlib.chemistry.Solution.dilute(), 14 chemlib.chemistry.Element.FirstIonization
chemlib.electrochemistry.electrolysis(), (built-in variable), 6
16 chemlib.chemistry.Element.Group (built-in vari-
chemlib.quantum_mechanics.energy_of_hydrogen_orbital(), able), 6
18 chemlib.chemistry.Element.Isotopes (built-in
by_formula() (chemlib.chemistry.Reaction class variable), 6
method), 10 chemlib.chemistry.Element.MeltingPoint (built-
by_grams_per_liters() (chemlib.chemistry.Solution in variable), 6
class method), 13 chemlib.chemistry.Element.Metal (built-in vari-
able), 6
C chemlib.chemistry.Element.Metalloid (built-in
variable), 6
chemlib.AVOGADROS_NUMBER (built-in variable), 6
chemlib.chemistry.Element.Natural (built-in vari-
chemlib.c (built-in variable), 6
able), 6
chemlib.chemistry.Combustion (built-in class), 11
chemlib.chemistry.Element.Neutrons (built-in
chemlib.chemistry.combustion_analysis()
variable), 6
built-in function, 9
chemlib.chemistry.Element.Nonmetal (built-in
chemlib.chemistry.Compound.get_amounts()
variable), 6
built-in function, 8
chemlib.chemistry.Element.Period (built-in vari-
chemlib.chemistry.Compound.molar_mass()
able), 6
built-in function, 7
chemlib.chemistry.Element.Phase (built-in vari-
chemlib.chemistry.Compound.occurences (built-in
able), 6
variable), 7
chemlib.chemistry.Element.Protons (built-in vari-
chemlib.chemistry.Compound.percentage_by_mass()
able), 6
built-in function, 8
21
chemlib, Release v1.0
chemlib.chemistry.Element.Radioactive (built-in E
variable), 6 Element (class in chemlib.chemistry), 5
chemlib.chemistry.Element.Symbol (built-in vari-
able), 6 P
chemlib.chemistry.Element.Type (built-in vari-
PeriodicTable (class in chemlib.chemistry), 5
able), 6
chemlib.chemistry.empirical_formula_by_percent_comp()
built-in function, 9
R
chemlib.chemistry.pH() Reaction (class in chemlib.chemistry), 10
built-in function, 13
chemlib.chemistry.Reaction.balance()
built-in function, 11
chemlib.chemistry.Reaction.formula (built-in
variable), 10
chemlib.chemistry.Reaction.get_amounts()
built-in function, 11
chemlib.chemistry.Reaction.is_balanced (built-
in variable), 10
chemlib.chemistry.Reaction.limiting_reagent()
built-in function, 12
chemlib.chemistry.Reaction.product_formulas
(built-in variable), 10
chemlib.chemistry.Reaction.reactant_formulas
(built-in variable), 10
chemlib.chemistry.Solution (built-in class), 13
chemlib.chemistry.Solution.dilute()
built-in function, 14
chemlib.electrochemistry.electrolysis()
built-in function, 16
chemlib.electrochemistry.Galvanic_Cell (built-
in class), 15
chemlib.electrochemistry.Galvanic_Cell.cell_potential
(built-in variable), 15
chemlib.electrochemistry.Galvanic_Cell.diagram
(built-in variable), 15
chemlib.electrochemistry.Galvanic_Cell.properties
(built-in variable), 15
chemlib.h (built-in variable), 7
chemlib.quantum_mechanics.energy_of_hydrogen_orbital()
built-in function, 18
chemlib.quantum_mechanics.Wave (built-in class),
17
chemlib.quantum_mechanics.Wave.energy (built-in
variable), 17
chemlib.quantum_mechanics.Wave.frequency
(built-in variable), 17
chemlib.quantum_mechanics.Wave.properties
(built-in variable), 17
chemlib.quantum_mechanics.Wave.wavelength
(built-in variable), 17
chemlib.R (built-in variable), 7
Compound (class in chemlib.chemistry), 7
22 Index