Skip to content

Commit

Permalink
Update dev docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Jul 15, 2024
1 parent 08bc5a5 commit 6496886
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 35 deletions.
85 changes: 63 additions & 22 deletions docs/_modules/pymatgen/analysis/diffusion/analyzer.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,30 @@ <h1>Source code for pymatgen.analysis.diffusion.tests.test_analyzer</h1><div cla
<span class="n">temps</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">300</span><span class="p">,</span> <span class="mi">1000</span><span class="p">,</span> <span class="mi">500</span><span class="p">])</span>
<span class="n">diffusivities</span> <span class="o">=</span> <span class="n">c</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">Ea</span> <span class="o">/</span> <span class="p">(</span><span class="n">k</span> <span class="o">*</span> <span class="n">temps</span><span class="p">))</span>
<span class="n">diffusivities</span> <span class="o">*=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">1.00601834013</span><span class="p">,</span> <span class="mf">1.00803236262</span><span class="p">,</span> <span class="mf">0.98609720824</span><span class="p">])</span>

<span class="n">r</span> <span class="o">=</span> <span class="n">fit_arrhenius</span><span class="p">(</span><span class="n">temps</span><span class="p">,</span> <span class="n">diffusivities</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">Ea</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">c</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="mf">0.000895566</span><span class="p">)</span>

<span class="n">r</span> <span class="o">=</span> <span class="n">fit_arrhenius</span><span class="p">(</span><span class="n">temps</span><span class="p">,</span> <span class="n">diffusivities</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;exp&quot;</span><span class="p">,</span> <span class="n">diffusivity_errors</span><span class="o">=</span><span class="n">diffusivities</span> <span class="o">*</span> <span class="mf">0.01</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">Ea</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">c</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="mf">0.000904815</span><span class="p">)</span>

<span class="c1"># when not enough values for error estimate</span>
<span class="n">r2</span> <span class="o">=</span> <span class="n">fit_arrhenius</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r2</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="mi">0</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertAlmostEqual</span><span class="p">(</span><span class="n">r2</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="mi">10</span><span class="p">)</span>
<span class="k">assert</span> <span class="n">r2</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span>

<span class="n">ax</span> <span class="o">=</span> <span class="n">get_arrhenius_plot</span><span class="p">(</span><span class="n">temps</span><span class="p">,</span> <span class="n">diffusivities</span><span class="p">)</span>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">mpl</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">Axes</span><span class="p">)</span></div>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">mpl</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">Axes</span><span class="p">)</span>

<span class="n">ax</span> <span class="o">=</span> <span class="n">get_arrhenius_plot</span><span class="p">(</span><span class="n">temps</span><span class="p">,</span> <span class="n">diffusivities</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;exp&quot;</span><span class="p">,</span> <span class="n">diffusivity_errors</span><span class="o">=</span><span class="n">diffusivities</span> <span class="o">*</span> <span class="mf">0.01</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="s2">&quot;eV&quot;</span><span class="p">)</span>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">mpl</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">Axes</span><span class="p">)</span>
<span class="k">assert</span> <span class="n">ax</span><span class="o">.</span><span class="n">get_xlabel</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;T (K)&quot;</span>
<span class="k">assert</span> <span class="n">ax</span><span class="o">.</span><span class="n">get_ylabel</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;D (cm$^2$/s)&quot;</span></div>
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h1>Source code for pymatgen.analysis.diffusion.utils.edge_data_from_sc</h1><div
<span class="n">mg</span><span class="p">:</span> <span class="n">MigrationGraph</span><span class="p">,</span>
<span class="n">i_sc</span><span class="p">:</span> <span class="n">Structure</span><span class="p">,</span>
<span class="n">e_sc</span><span class="p">:</span> <span class="n">Structure</span><span class="p">,</span>
<span class="n">data_array</span><span class="p">:</span> <span class="nb">list</span><span class="p">,</span>
<span class="n">data_array</span><span class="p">:</span> <span class="nb">list</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">float</span><span class="p">,</span>
<span class="n">key</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;custom_key&quot;</span><span class="p">,</span>
<span class="n">use_host_sg</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
Expand Down Expand Up @@ -106,7 +106,10 @@ <h1>Source code for pymatgen.analysis.diffusion.utils.edge_data_from_sc</h1><div
<span class="n">isite</span><span class="p">,</span> <span class="n">esite</span> <span class="o">=</span> <span class="n">i_wi</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">e_wi</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">uhop_index</span><span class="p">,</span> <span class="n">mh_from_sc</span> <span class="o">=</span> <span class="n">get_unique_hop</span><span class="p">(</span><span class="n">mg</span><span class="p">,</span> <span class="n">i_sc</span><span class="p">,</span> <span class="n">isite</span><span class="p">,</span> <span class="n">esite</span><span class="p">,</span> <span class="n">use_host_sg</span><span class="p">)</span>
<span class="n">add_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span> <span class="n">data_array</span><span class="p">}</span>
<span class="n">mg</span><span class="o">.</span><span class="n">add_data_to_similar_edges</span><span class="p">(</span><span class="n">target_label</span><span class="o">=</span><span class="n">uhop_index</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">add_dict</span><span class="p">,</span> <span class="n">m_hop</span><span class="o">=</span><span class="n">mh_from_sc</span><span class="p">)</span></div>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data_array</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">mg</span><span class="o">.</span><span class="n">add_data_to_similar_edges</span><span class="p">(</span><span class="n">target_label</span><span class="o">=</span><span class="n">uhop_index</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">add_dict</span><span class="p">,</span> <span class="n">m_hop</span><span class="o">=</span><span class="n">mh_from_sc</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">mg</span><span class="o">.</span><span class="n">add_data_to_similar_edges</span><span class="p">(</span><span class="n">target_label</span><span class="o">=</span><span class="n">uhop_index</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">add_dict</span><span class="p">)</span></div>



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ <h1>Source code for pymatgen.analysis.diffusion.utils.tests.test_edge_data_from_
<span class="n">key</span><span class="o">=</span><span class="n">test_key</span><span class="p">,</span>
<span class="p">)</span>

<span class="n">test_single_key</span> <span class="o">=</span> <span class="s2">&quot;test_single_key&quot;</span>
<span class="n">test_single</span> <span class="o">=</span> <span class="mi">100</span>
<span class="n">add_edge_data_from_sc</span><span class="p">(</span>
<span class="n">mg_Li</span><span class="p">,</span>
<span class="n">i_sc</span><span class="o">=</span><span class="n">input_struct_i</span><span class="p">,</span>
<span class="n">e_sc</span><span class="o">=</span><span class="n">input_struct_e</span><span class="p">,</span>
<span class="n">data_array</span><span class="o">=</span><span class="n">test_single</span><span class="p">,</span>
<span class="n">key</span><span class="o">=</span><span class="n">test_single_key</span><span class="p">,</span>
<span class="p">)</span>

<span class="n">edge_data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">_u</span><span class="p">,</span> <span class="n">_v</span><span class="p">,</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">mg_Li</span><span class="o">.</span><span class="n">m_graph</span><span class="o">.</span><span class="n">graph</span><span class="o">.</span><span class="n">edges</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
<span class="n">edge_data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
Expand Down
Binary file modified docs/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/doctrees/pymatgen.analysis.diffusion.analyzer.doctree
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 6496886

Please sign in to comment.