climlab / chemlib /source /docs /build /html /compounds.html
ghh1125's picture
Upload 193 files
de52efb verified
Raw
History Blame Contribute Delete
14.5 kB
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chemical Compounds &mdash; chemlib v1.0 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Empirical Formulae" href="formulae.html" />
<link rel="prev" title="Core Data" href="core.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> chemlib
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="core.html">Core Data</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Chemical Compounds</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#making-a-compound">Making a Compound</a></li>
<li class="toctree-l2"><a class="reference internal" href="#molar-mass">Molar Mass</a></li>
<li class="toctree-l2"><a class="reference internal" href="#percentage-composition-by-mass">Percentage Composition by Mass</a></li>
<li class="toctree-l2"><a class="reference internal" href="#stoichiometry">Stoichiometry</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="formulae.html">Empirical Formulae</a></li>
<li class="toctree-l1"><a class="reference internal" href="reactions.html">Chemical Reactions</a></li>
<li class="toctree-l1"><a class="reference internal" href="solution.html">Aqueous Solutions</a></li>
<li class="toctree-l1"><a class="reference internal" href="electrochemistry.html">Electrochemistry</a></li>
<li class="toctree-l1"><a class="reference internal" href="quantum.html">Quantum Mechanics</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">chemlib</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li>Chemical Compounds</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/compounds.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="chemical-compounds">
<h1>Chemical Compounds<a class="headerlink" href="#chemical-compounds" title="Permalink to this headline"></a></h1>
<section id="making-a-compound">
<h2>Making a Compound<a class="headerlink" href="#making-a-compound" title="Permalink to this headline"></a></h2>
<dl class="py attribute">
<dt class="sig sig-object py" id="chemlib.chemistry.Compound">
<span class="sig-prename descclassname"><span class="pre">chemlib.chemistry.</span></span><span class="sig-name descname"><span class="pre">Compound</span></span><a class="reference internal" href="_modules/chemlib/chemistry.html#Compound"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#chemlib.chemistry.Compound" title="Permalink to this definition"></a></dt>
<dd><p>alias of <code class="xref py py-obj docutils literal notranslate"><span class="pre">chemlib.chemistry.chemlib.chemistry.Compound._name</span></code></p>
</dd></dl>
<p>Instantiate a <code class="docutils literal notranslate"><span class="pre">chemlib.Compound</span></code> object with the formula of the compound.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">chemlib</span> <span class="kn">import</span> <span class="n">Compound</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">water</span> <span class="o">=</span> <span class="n">Compound</span><span class="p">(</span><span class="s2">&quot;H2O&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">formula</span>
<span class="go">&#39;H₂O₁&#39;</span>
</pre></div>
</div>
<blockquote>
<div><dl class="py data">
<dt class="sig sig-object py" id="chemlib.chemistry.Compound.occurences">
<span class="sig-prename descclassname"><span class="pre">chemlib.chemistry.Compound.</span></span><span class="sig-name descname"><span class="pre">occurences</span></span><em class="property"><span class="pre">:</span> <span class="pre">dict</span></em><a class="headerlink" href="#chemlib.chemistry.Compound.occurences" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<p>A dictionary containing the frequencies of the constituent elements in the compound.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">occurences</span>
<span class="go">{&#39;H&#39;: 2, &#39;O&#39;: 1}</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="molar-mass">
<h2>Molar Mass<a class="headerlink" href="#molar-mass" title="Permalink to this headline"></a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="chemlib.chemistry.Compound.molar_mass">
<span class="sig-prename descclassname"><span class="pre">chemlib.chemistry.Compound.</span></span><span class="sig-name descname"><span class="pre">molar_mass</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#chemlib.chemistry.Compound.molar_mass" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The molar mass in (g/mol) of the compound</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
</dd></dl>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">molar_mass</span><span class="p">()</span>
<span class="go">18.01</span>
</pre></div>
</div>
</section>
<section id="percentage-composition-by-mass">
<h2>Percentage Composition by Mass<a class="headerlink" href="#percentage-composition-by-mass" title="Permalink to this headline"></a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="chemlib.chemistry.Compound.percentage_by_mass">
<span class="sig-prename descclassname"><span class="pre">chemlib.chemistry.Compound.</span></span><span class="sig-name descname"><span class="pre">percentage_by_mass</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">element</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#chemlib.chemistry.Compound.percentage_by_mass" title="Permalink to this definition"></a></dt>
<dd><p>Get the percentage composition by mass of a certain element of the compound.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>element</strong> (<em>str</em>) – The constituent element of which the user wants to get percentage composition.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The percentage composition by mass of the element in the compound.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>float</p>
</dd>
</dl>
</dd></dl>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">percentage_by_mass</span><span class="p">(</span><span class="s1">&#39;H&#39;</span><span class="p">)</span> <span class="c1">#Percent of Hydrogen in Compound</span>
<span class="go">11.183</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">percentage_by_mass</span><span class="p">(</span><span class="s1">&#39;O&#39;</span><span class="p">)</span> <span class="c1">#Percent of Oxygen in Compound</span>
<span class="go">88.834</span>
</pre></div>
</div>
</section>
<section id="stoichiometry">
<h2>Stoichiometry<a class="headerlink" href="#stoichiometry" title="Permalink to this headline"></a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="chemlib.chemistry.Compound.get_amounts">
<span class="sig-prename descclassname"><span class="pre">chemlib.chemistry.Compound.</span></span><span class="sig-name descname"><span class="pre">get_amounts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#chemlib.chemistry.Compound.get_amounts" title="Permalink to this definition"></a></dt>
<dd><p>Get stoichiometric amounts of the compound given one measurement.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>compound_number</strong> (<em>int</em>) – The chosen compound in the reaction by order of appearance.</p></li>
<li><p><strong>kwargs</strong> – The amount of the chosen compound (grams=, moles=, or molecules=)</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The gram, mole, and molecule amounts of the compound.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>dict</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>ValueError</strong> – If the kwargs argument isn’t either grams, moles, or molecules</p></li>
<li><p><strong>ValueError</strong> – if more than one argument is given under kwargs</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<p>Get the amount of moles and molecules of water given 2 grams of water.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">get_amounts</span><span class="p">(</span><span class="n">grams</span> <span class="o">=</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">{&#39;Compound&#39;: &#39;H₂O₁&#39;, &#39;Grams&#39;: 2, &#39;Moles&#39;: 0.111, &#39;Molecules&#39;: 6.685e+22}</span>
</pre></div>
</div>
<p>Get the amount of grams and molecules of water given 2 moles of water.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">get_amounts</span><span class="p">(</span><span class="n">moles</span> <span class="o">=</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">{&#39;Compound&#39;: &#39;H₂O₁&#39;, &#39;Grams&#39;: 36.02, &#39;Moles&#39;: 2, &#39;Molecules&#39;: 1.204e+24}</span>
</pre></div>
</div>
<p>Get the amount of moles and grams of water given 2e+24 molecules of water.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">water</span><span class="o">.</span><span class="n">get_amounts</span><span class="p">(</span><span class="n">molecules</span> <span class="o">=</span> <span class="mf">2e+24</span><span class="p">)</span>
<span class="go">{&#39;Compound&#39;: &#39;H₂O₁&#39;, &#39;Grams&#39;: 59.834, &#39;Moles&#39;: 3.3223, &#39;Molecules&#39;: 2e+24}</span>
</pre></div>
</div>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="core.html" class="btn btn-neutral float-left" title="Core Data" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="formulae.html" class="btn btn-neutral float-right" title="Empirical Formulae" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2020, Hari Ambethkar.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>