Compare commits

..

3 Commits

@ -0,0 +1,37 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the OS, Python version and other tools you might need
build:
os: macOS-15.0.1
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"
# Build documentation in the "docs/" directory with Sphinx
sphinx:
builder: html
configuration: docs/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
fail_on_warning: true
# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub
# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
- requirements: requirements.txt

@ -6,6 +6,7 @@ More on the theoretical background can be seen on [arXiv](https://arxiv.org/abs/
- Run tests on different magnetic materials and compare it to Grogu Matlab --> ran on Jij_for_Marci_6p45ang, but I could not compare data
## Developing
- Use ReadThe Docs [addons](https://docs.readthedocs.io/en/stable/addons.html)
- Check the symmetrization of the Hamiltonian and overlap matrix to make them hermitian
- Check if exchange field has scalar part
- Add more tests!!

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: d8f86c3651bae6bbb2cfa348920c9196
config: 320e5b6dc420902025e0d306c97e86be
tags: 645f666f9bcd5a90fca523b33c5a78b7

@ -0,0 +1,525 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>grogupy.core &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=8d563738"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/design-tabs.js?v=f930bc37"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.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">
grogupy
</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" aria-label="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">
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</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">grogupy</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" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">grogupy.core</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for grogupy.core</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) [2024] []</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="c1"># in the Software without restriction, including without limitation the rights</span>
<span class="c1"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="c1"># copies of the Software, and to permit persons to whom the Software is</span>
<span class="c1"># furnished to do so, subject to the following conditions:</span>
<span class="c1">#</span>
<span class="c1"># The above copyright notice and this permission notice shall be included in all</span>
<span class="c1"># copies or substantial portions of the Software.</span>
<span class="c1">#</span>
<span class="c1"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="c1"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="c1"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<span class="c1"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="c1"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
<span class="c1"># SOFTWARE.</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">numpy.linalg</span> <span class="kn">import</span> <span class="n">inv</span>
<span class="kn">from</span> <span class="nn">grogupy.magnetism</span> <span class="kn">import</span> <span class="n">blow_up_orbindx</span><span class="p">,</span> <span class="n">parse_magnetic_entity</span>
<span class="kn">from</span> <span class="nn">grogupy.utilities</span> <span class="kn">import</span> <span class="n">commutator</span>
<div class="viewcode-block" id="parallel_Gk">
<a class="viewcode-back" href="../../grogupy.html#grogupy.core.parallel_Gk">[docs]</a>
<span class="k">def</span> <span class="nf">parallel_Gk</span><span class="p">(</span><span class="n">HK</span><span class="p">,</span> <span class="n">SK</span><span class="p">,</span> <span class="n">eran</span><span class="p">,</span> <span class="n">eset</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Calculates the Greens function by inversion.</span>
<span class="sd"> It calculates the Greens function on all the energy levels at the same time.</span>
<span class="sd"> Args:</span>
<span class="sd"> HK : (NO, NO), np.array_like</span>
<span class="sd"> Hamiltonian at a given k point</span>
<span class="sd"> SK : (NO, NO), np.array_like</span>
<span class="sd"> Overlap Matrix at a given k point</span>
<span class="sd"> eran : (eset) np.array_like</span>
<span class="sd"> Energy sample along the contour</span>
<span class="sd"> eset : int</span>
<span class="sd"> Number of energy samples along the contour</span>
<span class="sd"> Returns:</span>
<span class="sd"> Gk : (eset, NO, NO), np.array_like</span>
<span class="sd"> Green&#39;s function at a given k point</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Calculates the Greens function on all the energy levels</span>
<span class="k">return</span> <span class="n">inv</span><span class="p">(</span><span class="n">SK</span> <span class="o">*</span> <span class="n">eran</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">eset</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-</span> <span class="n">HK</span><span class="p">)</span></div>
<div class="viewcode-block" id="sequential_GK">
<a class="viewcode-back" href="../../grogupy.html#grogupy.core.sequential_GK">[docs]</a>
<span class="k">def</span> <span class="nf">sequential_GK</span><span class="p">(</span><span class="n">HK</span><span class="p">,</span> <span class="n">SK</span><span class="p">,</span> <span class="n">eran</span><span class="p">,</span> <span class="n">eset</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Calculates the Greens function by inversion.</span>
<span class="sd"> It calculates sequentially over the energy levels.</span>
<span class="sd"> Args:</span>
<span class="sd"> HK : (NO, NO), np.array_like</span>
<span class="sd"> Hamiltonian at a given k point</span>
<span class="sd"> SK : (NO, NO), np.array_like</span>
<span class="sd"> Overlap Matrix at a given k point</span>
<span class="sd"> eran : (eset) np.array_like</span>
<span class="sd"> Energy sample along the contour</span>
<span class="sd"> eset : int</span>
<span class="sd"> Number of energy samples along the contour</span>
<span class="sd"> Returns:</span>
<span class="sd"> Gk : (eset, NO, NO), np.array_like</span>
<span class="sd"> Green&#39;s function at a given k point</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># creates an empty holder</span>
<span class="n">Gk</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="n">eset</span><span class="p">,</span> <span class="n">HK</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">HK</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;complex128&quot;</span><span class="p">)</span>
<span class="c1"># fills the holder sequentially by the Greens function on a given energy</span>
<span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">eset</span><span class="p">):</span>
<span class="n">Gk</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">inv</span><span class="p">(</span><span class="n">SK</span> <span class="o">*</span> <span class="n">eran</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">-</span> <span class="n">HK</span><span class="p">)</span>
<span class="k">return</span> <span class="n">Gk</span></div>
<div class="viewcode-block" id="calc_Vu">
<a class="viewcode-back" href="../../grogupy.html#grogupy.core.calc_Vu">[docs]</a>
<span class="k">def</span> <span class="nf">calc_Vu</span><span class="p">(</span><span class="n">H</span><span class="p">,</span> <span class="n">Tu</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Calculates the local perturbation in case of a spin rotation.</span>
<span class="sd"> Args:</span>
<span class="sd"> H : (NO, NO) np.array_like</span>
<span class="sd"> Hamiltonian</span>
<span class="sd"> Tu : (NO, NO) array_like</span>
<span class="sd"> Rotation around u</span>
<span class="sd"> Returns:</span>
<span class="sd"> Vu1 : (NO, NO) np.array_like</span>
<span class="sd"> First order perturbed matrix</span>
<span class="sd"> Vu2 : (NO, NO) np.array_like</span>
<span class="sd"> Second order perturbed matrix</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">Vu1</span> <span class="o">=</span> <span class="mi">1</span><span class="n">j</span> <span class="o">/</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">commutator</span><span class="p">(</span><span class="n">H</span><span class="p">,</span> <span class="n">Tu</span><span class="p">)</span> <span class="c1"># equation 100</span>
<span class="n">Vu2</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">8</span> <span class="o">*</span> <span class="n">commutator</span><span class="p">(</span><span class="n">commutator</span><span class="p">(</span><span class="n">Tu</span><span class="p">,</span> <span class="n">H</span><span class="p">),</span> <span class="n">Tu</span><span class="p">)</span> <span class="c1"># equation 100</span>
<span class="k">return</span> <span class="n">Vu1</span><span class="p">,</span> <span class="n">Vu2</span></div>
<div class="viewcode-block" id="remove_clutter_for_save">
<a class="viewcode-back" href="../../grogupy.html#grogupy.core.remove_clutter_for_save">[docs]</a>
<span class="k">def</span> <span class="nf">remove_clutter_for_save</span><span class="p">(</span><span class="n">pairs</span><span class="p">,</span> <span class="n">magnetic_entities</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Removes unimportant data from the dictionaries.</span>
<span class="sd"> It is used before saving to throw away data that</span>
<span class="sd"> is not needed for post processing.</span>
<span class="sd"> Args:</span>
<span class="sd"> pairs : dict</span>
<span class="sd"> Contains all the pair information</span>
<span class="sd"> magnetic_entities : dict</span>
<span class="sd"> Contains all the magnetic entity information</span>
<span class="sd"> Returns:</span>
<span class="sd"> pairs : dict</span>
<span class="sd"> Contains all the reduced pair information</span>
<span class="sd"> magnetic_entities : dict</span>
<span class="sd"> Contains all the reduced magnetic entity information</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># remove clutter from magnetic entities and pair information</span>
<span class="k">for</span> <span class="n">pair</span> <span class="ow">in</span> <span class="n">pairs</span><span class="p">:</span>
<span class="k">del</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij&quot;</span><span class="p">]</span>
<span class="k">del</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij_tmp&quot;</span><span class="p">]</span>
<span class="k">del</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji&quot;</span><span class="p">]</span>
<span class="k">del</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji_tmp&quot;</span><span class="p">]</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="k">del</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii&quot;</span><span class="p">]</span>
<span class="k">del</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii_tmp&quot;</span><span class="p">]</span>
<span class="k">del</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu1&quot;</span><span class="p">]</span>
<span class="k">del</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu2&quot;</span><span class="p">]</span>
<span class="k">return</span> <span class="n">pairs</span><span class="p">,</span> <span class="n">magnetic_entities</span></div>
<div class="viewcode-block" id="build_hh_ss">
<a class="viewcode-back" href="../../grogupy.html#grogupy.core.build_hh_ss">[docs]</a>
<span class="k">def</span> <span class="nf">build_hh_ss</span><span class="p">(</span><span class="n">dh</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It builds the Hamiltonian and Overlap matrix from the sisl.dh class.</span>
<span class="sd"> It restructures the data in the SPIN BOX representation, where NS is</span>
<span class="sd"> the number of supercells and NO is the number of orbitals.</span>
<span class="sd"> Args:</span>
<span class="sd"> dh : sisl.physics.Hamiltonian</span>
<span class="sd"> Hamiltonian read in by sisl</span>
<span class="sd"> Returns:</span>
<span class="sd"> hh : (NS, NO, NO) np.array_like</span>
<span class="sd"> Hamiltonian in SPIN BOX representation</span>
<span class="sd"> ss : (NS, NO, NO) np.array_like</span>
<span class="sd"> Overlap matrix in SPIN BOX representation</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">NO</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">no</span> <span class="c1"># shorthand for number of orbitals in the unit cell</span>
<span class="c1"># preprocessing Hamiltonian and overlap matrix elements</span>
<span class="n">h11</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M11r</span><span class="p">)</span>
<span class="n">h11</span> <span class="o">+=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M11i</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.0</span><span class="n">j</span>
<span class="n">h11</span> <span class="o">=</span> <span class="n">h11</span><span class="o">.</span><span class="n">toarray</span><span class="p">()</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dh</span><span class="o">.</span><span class="n">n_s</span><span class="p">,</span> <span class="n">NO</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="s2">&quot;complex128&quot;</span><span class="p">)</span>
<span class="n">h22</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M22r</span><span class="p">)</span>
<span class="n">h22</span> <span class="o">+=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M22i</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.0</span><span class="n">j</span>
<span class="n">h22</span> <span class="o">=</span> <span class="n">h22</span><span class="o">.</span><span class="n">toarray</span><span class="p">()</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dh</span><span class="o">.</span><span class="n">n_s</span><span class="p">,</span> <span class="n">NO</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="s2">&quot;complex128&quot;</span><span class="p">)</span>
<span class="n">h12</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M12r</span><span class="p">)</span>
<span class="n">h12</span> <span class="o">+=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M12i</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.0</span><span class="n">j</span>
<span class="n">h12</span> <span class="o">=</span> <span class="n">h12</span><span class="o">.</span><span class="n">toarray</span><span class="p">()</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dh</span><span class="o">.</span><span class="n">n_s</span><span class="p">,</span> <span class="n">NO</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="s2">&quot;complex128&quot;</span><span class="p">)</span>
<span class="n">h21</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M21r</span><span class="p">)</span>
<span class="n">h21</span> <span class="o">+=</span> <span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">M21i</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.0</span><span class="n">j</span>
<span class="n">h21</span> <span class="o">=</span> <span class="n">h21</span><span class="o">.</span><span class="n">toarray</span><span class="p">()</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dh</span><span class="o">.</span><span class="n">n_s</span><span class="p">,</span> <span class="n">NO</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="s2">&quot;complex128&quot;</span><span class="p">)</span>
<span class="n">sov</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">dh</span><span class="o">.</span><span class="n">tocsr</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">S_idx</span><span class="p">)</span>
<span class="o">.</span><span class="n">toarray</span><span class="p">()</span>
<span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dh</span><span class="o">.</span><span class="n">n_s</span><span class="p">,</span> <span class="n">NO</span><span class="p">)</span>
<span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="s2">&quot;complex128&quot;</span><span class="p">)</span>
<span class="p">)</span>
<span class="c1"># Reorganization of Hamiltonian and overlap matrix elements to SPIN BOX representation</span>
<span class="n">U</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span>
<span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">kron</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">int</span><span class="p">),</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">kron</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">int</span><span class="p">),</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])]</span>
<span class="p">)</span>
<span class="c1"># This is the permutation that transforms ud1ud2 to u12d12</span>
<span class="c1"># That is this transforms FROM SPIN BOX to ORBITAL BOX =&gt; U</span>
<span class="c1"># the inverse transformation is U.T u12d12 to ud1ud2</span>
<span class="c1"># That is FROM ORBITAL BOX to SPIN BOX =&gt; U.T</span>
<span class="c1"># From now on everything is in SPIN BOX!!</span>
<span class="n">hh</span><span class="p">,</span> <span class="n">ss</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="p">[</span>
<span class="n">U</span><span class="o">.</span><span class="n">T</span>
<div class="viewcode-block" id="setup_pairs_and_magnetic_entities">
<a class="viewcode-back" href="../../grogupy.html#grogupy.core.setup_pairs_and_magnetic_entities">[docs]</a>
<span class="o">@</span> <span class="n">np</span><span class="o">.</span><span class="n">block</span><span class="p">([[</span><span class="n">h11</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">],</span> <span class="n">h12</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">]],</span> <span class="p">[</span><span class="n">h21</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">],</span> <span class="n">h22</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">]]])</span>
<span class="o">@</span> <span class="n">U</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">nsc</span><span class="o">.</span><span class="n">prod</span><span class="p">())</span>
<span class="p">]</span>
<span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="p">[</span>
<span class="n">U</span><span class="o">.</span><span class="n">T</span>
<span class="o">@</span> <span class="n">np</span><span class="o">.</span><span class="n">block</span><span class="p">(</span>
<span class="p">[[</span><span class="n">sov</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">],</span> <span class="n">sov</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">]</span> <span class="o">*</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="n">sov</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">]</span> <span class="o">*</span> <span class="mi">0</span><span class="p">,</span> <span class="n">sov</span><span class="p">[:,</span> <span class="p">:,</span> <span class="n">i</span><span class="p">]]]</span>
<span class="p">)</span>
<span class="o">@</span> <span class="n">U</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">nsc</span><span class="o">.</span><span class="n">prod</span><span class="p">())</span>
<span class="p">]</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">hh</span><span class="p">,</span> <span class="n">ss</span></div>
<span class="k">def</span> <span class="nf">setup_pairs_and_magnetic_entities</span><span class="p">(</span>
<span class="n">magnetic_entities</span><span class="p">,</span> <span class="n">pairs</span><span class="p">,</span> <span class="n">dh</span><span class="p">,</span> <span class="n">simulation_parameters</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It creates the complete structure of the dictionaries and fills some basic data.</span>
<span class="sd"> It creates orbital indexes, spin box indexes, coordinates and tags for magnetic entities.</span>
<span class="sd"> Furthermore it creates the structures for the energies, the perturbed potentials and</span>
<span class="sd"> the Greens function calculation. It dose the same for the pairs.</span>
<span class="sd"> Args:</span>
<span class="sd"> pairs : dict</span>
<span class="sd"> Contains the initial pair information</span>
<span class="sd"> magnetic_entities : dict</span>
<span class="sd"> Contains the initial magnetic entity information</span>
<span class="sd"> dh : sisl.physics.Hamiltonian</span>
<span class="sd"> Hamiltonian read in by sisl</span>
<span class="sd"> simulation_parameters : dict</span>
<span class="sd"> A set of parameters from the simulation</span>
<span class="sd"> Returns:</span>
<span class="sd"> pairs : dict</span>
<span class="sd"> Contains the initial information and the complete structure</span>
<span class="sd"> magnetic_entities : dict</span>
<span class="sd"> Contains the initial information and the complete structure</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># for every site we have to store 3 Greens function (and the associated _tmp-s) in the 3 reference directions</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="n">parsed</span> <span class="o">=</span> <span class="n">parse_magnetic_entity</span><span class="p">(</span><span class="n">dh</span><span class="p">,</span> <span class="o">**</span><span class="n">mag_ent</span><span class="p">)</span> <span class="c1"># parse orbital indexes</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;orbital_indices&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">parsed</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">blow_up_orbindx</span><span class="p">(</span>
<span class="n">parsed</span>
<span class="p">)</span> <span class="c1"># calculate spin box indexes</span>
<span class="c1"># if orbital is not set use all</span>
<span class="k">if</span> <span class="s2">&quot;l&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">mag_ent</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;l&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;all&quot;</span>
<span class="c1"># tag creation for one atom</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">],</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">mag_ent</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">mag_ent</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">mag_ent</span><span class="p">[</span><span class="s1">&#39;l&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="p">]</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;xyz&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">dh</span><span class="o">.</span><span class="n">xyz</span><span class="p">[</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">]]]</span>
<span class="c1"># tag creation for more atoms</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;xyz&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># iterate over atoms</span>
<span class="k">for</span> <span class="n">atom_idx</span> <span class="ow">in</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">]:</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">atom_idx</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atom_idx</span><span class="p">]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">mag_ent</span><span class="p">[</span><span class="s1">&#39;l&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="p">)</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;xyz&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">xyz</span><span class="p">[</span><span class="n">atom_idx</span><span class="p">])</span>
<span class="c1"># calculate size for Greens function generation</span>
<span class="n">spin_box_shape</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">])</span>
<span class="c1"># we will store the second order energy derivations here</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># These will be the perturbed potentials from eq. 100</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu1&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># so they are independent in memory</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu2&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># Greens function</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii_tmp&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># Greens function for parallelization</span>
<span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]:</span>
<span class="c1"># Rotations for every quantization axis</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu1&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu2&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
<span class="c1"># Greens functions for every quantization axis</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
<span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">],</span> <span class="n">spin_box_shape</span><span class="p">,</span> <span class="n">spin_box_shape</span><span class="p">),</span>
<span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;complex128&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii_tmp&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
<span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">],</span> <span class="n">spin_box_shape</span><span class="p">,</span> <span class="n">spin_box_shape</span><span class="p">),</span>
<span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;complex128&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="c1"># for every site we have to store 2x3 Greens function (and the associated _tmp-s)</span>
<span class="c1"># in the 3 reference directions, because G_ij and G_ji are both needed</span>
<span class="k">for</span> <span class="n">pair</span> <span class="ow">in</span> <span class="n">pairs</span><span class="p">:</span>
<span class="c1"># calculate distance</span>
<span class="n">xyz_ai</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;ai&quot;</span><span class="p">]][</span><span class="s2">&quot;xyz&quot;</span><span class="p">]</span>
<span class="n">xyz_aj</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;aj&quot;</span><span class="p">]][</span><span class="s2">&quot;xyz&quot;</span><span class="p">]</span>
<span class="n">xyz_aj</span> <span class="o">=</span> <span class="n">xyz_aj</span> <span class="o">+</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Ruc&quot;</span><span class="p">]</span> <span class="o">@</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;cell&quot;</span><span class="p">]</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;dist&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">xyz_ai</span> <span class="o">-</span> <span class="n">xyz_aj</span><span class="p">)</span>
<span class="c1"># calculate size for Greens function generation</span>
<span class="n">spin_box_shape_i</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;ai&quot;</span><span class="p">]][</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">])</span>
<span class="n">spin_box_shape_j</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;aj&quot;</span><span class="p">]][</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">])</span>
<span class="c1"># tag generation</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="p">[</span><span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;ai&quot;</span><span class="p">]],</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;aj&quot;</span><span class="p">]]]:</span>
<span class="n">tag</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="c1"># get atoms of magnetic entity</span>
<span class="n">atoms_idx</span> <span class="o">=</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">]</span>
<span class="n">orbitals</span> <span class="o">=</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;l&quot;</span><span class="p">]</span>
<span class="c1"># if magnetic entity contains one atoms</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">atoms_idx</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">tag</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">atoms_idx</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atoms_idx</span><span class="p">]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">orbitals</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="c1"># if magnetic entity contains more than one atoms</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">atoms_idx</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="c1"># iterate over atoms</span>
<span class="n">atom_group</span> <span class="o">=</span> <span class="s2">&quot;{&quot;</span>
<span class="k">for</span> <span class="n">atom_idx</span> <span class="ow">in</span> <span class="n">atoms_idx</span><span class="p">:</span>
<span class="n">atom_group</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">atom_idx</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atom_idx</span><span class="p">]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">orbitals</span><span class="si">}</span><span class="s2">)--&quot;</span>
<span class="c1"># end {} of the atoms in the magnetic entity</span>
<span class="n">tag</span> <span class="o">+=</span> <span class="n">atom_group</span><span class="p">[:</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;}&quot;</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tag</span><span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># we will store the second order energy derivations here</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># Greens function</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij_tmp&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># Greens function for parallelization</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji_tmp&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]:</span>
<span class="c1"># Greens functions for every quantization axis</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
<span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">],</span> <span class="n">spin_box_shape_i</span><span class="p">,</span> <span class="n">spin_box_shape_j</span><span class="p">),</span>
<span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;complex128&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij_tmp&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
<span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">],</span> <span class="n">spin_box_shape_i</span><span class="p">,</span> <span class="n">spin_box_shape_j</span><span class="p">),</span>
<span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;complex128&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
<span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">],</span> <span class="n">spin_box_shape_j</span><span class="p">,</span> <span class="n">spin_box_shape_i</span><span class="p">),</span>
<span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;complex128&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji_tmp&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
<span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">],</span> <span class="n">spin_box_shape_j</span><span class="p">,</span> <span class="n">spin_box_shape_i</span><span class="p">),</span>
<span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;complex128&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">pairs</span><span class="p">,</span> <span class="n">magnetic_entities</span></div>
<div class="viewcode-block" id="onsite_projection">
<a class="viewcode-back" href="../../grogupy.html#grogupy.core.onsite_projection">[docs]</a>
<span class="k">def</span> <span class="nf">onsite_projection</span><span class="p">(</span><span class="n">matrix</span><span class="p">,</span> <span class="n">idx1</span><span class="p">,</span> <span class="n">idx2</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It produces the slices of a matrix for the on site projection.</span>
<span class="sd"> The slicing is along the last two axes as these contains the orbital indexing.</span>
<span class="sd"> Args:</span>
<span class="sd"> matrix : (..., :, :) np.array_like</span>
<span class="sd"> Some matrix</span>
<span class="sd"> idx : np.array_like</span>
<span class="sd"> The indexes of the orbitals</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> Reduced matrix based on the projection</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">matrix</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">idx1</span><span class="p">,</span> <span class="p">:][</span><span class="o">...</span><span class="p">,</span> <span class="n">idx2</span><span class="p">]</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, grogupy.</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>

@ -0,0 +1,587 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>grogupy.grogu &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=8d563738"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/design-tabs.js?v=f930bc37"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.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">
grogupy
</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" aria-label="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">
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</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">grogupy</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" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">grogupy.grogu</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for grogupy.grogu</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) [2024] []</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="c1"># in the Software without restriction, including without limitation the rights</span>
<span class="c1"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="c1"># copies of the Software, and to permit persons to whom the Software is</span>
<span class="c1"># furnished to do so, subject to the following conditions:</span>
<span class="c1">#</span>
<span class="c1"># The above copyright notice and this permission notice shall be included in all</span>
<span class="c1"># copies or substantial portions of the Software.</span>
<span class="c1">#</span>
<span class="c1"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="c1"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="c1"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<span class="c1"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="c1"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
<span class="c1"># SOFTWARE.</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">sys</span> <span class="kn">import</span> <span class="n">getsizeof</span>
<span class="kn">from</span> <span class="nn">timeit</span> <span class="kn">import</span> <span class="n">default_timer</span> <span class="k">as</span> <span class="n">timer</span>
<span class="c1"># use numpy number of threads one</span>
<span class="k">try</span><span class="p">:</span>
<span class="kn">from</span> <span class="nn">threadpoolctl</span> <span class="kn">import</span> <span class="n">threadpool_info</span><span class="p">,</span> <span class="n">threadpool_limits</span>
<span class="n">user_api</span> <span class="o">=</span> <span class="n">threadpool_info</span><span class="p">()[</span><span class="s2">&quot;user_api&quot;</span><span class="p">]</span>
<span class="n">threadpool_limits</span><span class="p">(</span><span class="n">limits</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">user_api</span><span class="o">=</span><span class="n">user_api</span><span class="p">)</span>
<span class="k">except</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Warning: threadpoolctl could not make numpy use single thread!&quot;</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">sisl</span>
<span class="kn">from</span> <span class="nn">mpi4py</span> <span class="kn">import</span> <span class="n">MPI</span>
<span class="k">try</span><span class="p">:</span>
<span class="kn">from</span> <span class="nn">tqdm</span> <span class="kn">import</span> <span class="n">tqdm</span>
<span class="n">tqdm_imported</span> <span class="o">=</span> <span class="kc">True</span>
<span class="k">except</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Please install tqdm for nice progress bar.&quot;</span><span class="p">)</span>
<span class="n">tqdm_imported</span> <span class="o">=</span> <span class="kc">False</span>
<span class="kn">from</span> <span class="nn">grogupy</span> <span class="kn">import</span> <span class="o">*</span>
<div class="viewcode-block" id="main">
<a class="viewcode-back" href="../../grogupy.html#grogupy.grogu.main">[docs]</a>
<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="c1"># runtime information</span>
<span class="n">times</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;start_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="c1"># input output stuff</span>
<span class="c1">######################################################################</span>
<span class="c1">######################################################################</span>
<span class="c1">######################################################################</span>
<span class="n">infile</span> <span class="o">=</span> <span class="s2">&quot;/Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf&quot;</span>
<span class="n">outfile</span> <span class="o">=</span> <span class="s2">&quot;./Fe3GeTe2_notebook&quot;</span>
<span class="n">magnetic_entities</span> <span class="o">=</span> <span class="p">[</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">atom</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">l</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">atom</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">l</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">atom</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">l</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="p">]</span>
<span class="n">pairs</span> <span class="o">=</span> <span class="p">[</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">Ruc</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">0</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="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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">0</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="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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">0</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="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">])),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">])),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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="o">-</span><span class="mi">1</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="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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="o">-</span><span class="mi">1</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="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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="o">-</span><span class="mi">2</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="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">aj</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">Ruc</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="o">-</span><span class="mi">3</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="p">]</span>
<span class="n">simulation_parameters</span> <span class="o">=</span> <span class="n">default_args</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">infile</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">outfile</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kset&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">20</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kdirs&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;xy&quot;</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">600</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;esetp&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">10000</span>
<span class="c1">######################################################################</span>
<span class="c1">######################################################################</span>
<span class="c1">######################################################################</span>
<span class="c1"># MPI parameters</span>
<span class="n">comm</span> <span class="o">=</span> <span class="n">MPI</span><span class="o">.</span><span class="n">COMM_WORLD</span>
<span class="n">size</span> <span class="o">=</span> <span class="n">comm</span><span class="o">.</span><span class="n">Get_size</span><span class="p">()</span>
<span class="n">rank</span> <span class="o">=</span> <span class="n">comm</span><span class="o">.</span><span class="n">Get_rank</span><span class="p">()</span>
<span class="n">root_node</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="c1"># include parallel size in simulation parameters</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_size&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">size</span>
<span class="c1"># check versions for debugging</span>
<span class="k">try</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;sisl version: &quot;</span><span class="p">,</span> <span class="n">sisl</span><span class="o">.</span><span class="n">__version__</span><span class="p">)</span>
<span class="k">except</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;sisl version unknown.&quot;</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;numpy version: &quot;</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">__version__</span><span class="p">)</span>
<span class="k">except</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;numpy version unknown.&quot;</span><span class="p">)</span>
<span class="c1"># rename outfile</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">&quot;.pickle&quot;</span><span class="p">):</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="s2">&quot;.pickle&quot;</span>
<span class="c1"># if ebot is not given put it 0.1 eV under the smallest energy</span>
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">eigfile</span> <span class="o">=</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">][:</span><span class="o">-</span><span class="mi">3</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;EIG&quot;</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_siesta_emin</span><span class="p">(</span><span class="n">eigfile</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.1</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;automatic_ebot&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
<span class="k">except</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Could not determine ebot.&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Parameter was not given and .EIG file was not found.&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;automatic_ebot&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>
<span class="c1"># read sile</span>
<span class="n">fdf</span> <span class="o">=</span> <span class="n">sisl</span><span class="o">.</span><span class="n">get_sile</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">])</span>
<span class="c1"># read in hamiltonian</span>
<span class="n">dh</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">read_hamiltonian</span><span class="p">()</span>
<span class="c1"># read unit cell vectors</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;cell&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">read_geometry</span><span class="p">()</span><span class="o">.</span><span class="n">cell</span>
<span class="c1"># unit cell index</span>
<span class="n">uc_in_sc_idx</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">sc_index</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="mi">0</span><span class="p">])</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n\n\n\n\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;#################################################################### JOB INFORMATION ###########################################################################&quot;</span>
<span class="p">)</span>
<span class="n">print_job_description</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;################################################################################################################################################################&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n\n\n\n\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;setup_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Setup done. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;setup_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="n">NO</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">no</span> <span class="c1"># shorthand for number of orbitals in the unit cell</span>
<span class="c1"># reformat Hamltonian and Overlap matrix for manipulations</span>
<span class="n">hh</span><span class="p">,</span> <span class="n">ss</span> <span class="o">=</span> <span class="n">build_hh_ss</span><span class="p">(</span><span class="n">dh</span><span class="p">)</span>
<span class="c1"># symmetrizing Hamiltonian and Overlap matrix to make them hermitian</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">sc_off</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
<span class="n">j</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">sc_index</span><span class="p">(</span><span class="o">-</span><span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">sc_off</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
<span class="n">h1</span><span class="p">,</span> <span class="n">h1d</span> <span class="o">=</span> <span class="n">hh</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">hh</span><span class="p">[</span><span class="n">j</span><span class="p">]</span>
<span class="n">hh</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">hh</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">h1</span> <span class="o">+</span> <span class="n">h1d</span><span class="o">.</span><span class="n">T</span><span class="o">.</span><span class="n">conj</span><span class="p">())</span> <span class="o">/</span> <span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="n">h1d</span> <span class="o">+</span> <span class="n">h1</span><span class="o">.</span><span class="n">T</span><span class="o">.</span><span class="n">conj</span><span class="p">())</span> <span class="o">/</span> <span class="mi">2</span>
<span class="n">s1</span><span class="p">,</span> <span class="n">s1d</span> <span class="o">=</span> <span class="n">ss</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">ss</span><span class="p">[</span><span class="n">j</span><span class="p">]</span>
<span class="n">ss</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">ss</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">s1</span> <span class="o">+</span> <span class="n">s1d</span><span class="o">.</span><span class="n">T</span><span class="o">.</span><span class="n">conj</span><span class="p">())</span> <span class="o">/</span> <span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="n">s1d</span> <span class="o">+</span> <span class="n">s1</span><span class="o">.</span><span class="n">T</span><span class="o">.</span><span class="n">conj</span><span class="p">())</span> <span class="o">/</span> <span class="mi">2</span>
<span class="c1"># identifying TRS and TRB parts of the Hamiltonian</span>
<span class="n">TAUY</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">kron</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="n">NO</span><span class="p">),</span> <span class="n">tau_y</span><span class="p">)</span>
<span class="n">hTR</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="n">TAUY</span> <span class="o">@</span> <span class="n">hh</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">conj</span><span class="p">()</span> <span class="o">@</span> <span class="n">TAUY</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">nsc</span><span class="o">.</span><span class="n">prod</span><span class="p">())])</span>
<span class="n">hTRS</span> <span class="o">=</span> <span class="p">(</span><span class="n">hh</span> <span class="o">+</span> <span class="n">hTR</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="n">hTRB</span> <span class="o">=</span> <span class="p">(</span><span class="n">hh</span> <span class="o">-</span> <span class="n">hTR</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="c1"># extracting the exchange field</span>
<span class="n">traced</span> <span class="o">=</span> <span class="p">[</span><span class="n">spin_tracer</span><span class="p">(</span><span class="n">hTRB</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">dh</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">nsc</span><span class="o">.</span><span class="n">prod</span><span class="p">())]</span> <span class="c1"># equation 77</span>
<span class="n">XCF</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="p">[</span>
<span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">f</span><span class="p">[</span><span class="s2">&quot;x&quot;</span><span class="p">]</span> <span class="o">/</span> <span class="mi">2</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">traced</span><span class="p">]),</span>
<span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">f</span><span class="p">[</span><span class="s2">&quot;y&quot;</span><span class="p">]</span> <span class="o">/</span> <span class="mi">2</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">traced</span><span class="p">]),</span>
<span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">f</span><span class="p">[</span><span class="s2">&quot;z&quot;</span><span class="p">]</span> <span class="o">/</span> <span class="mi">2</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">traced</span><span class="p">]),</span>
<span class="p">]</span>
<span class="p">)</span>
<span class="c1"># check if exchange field has scalar part</span>
<span class="n">max_xcfs</span> <span class="o">=</span> <span class="nb">abs</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">f</span><span class="p">[</span><span class="s2">&quot;c&quot;</span><span class="p">]</span> <span class="o">/</span> <span class="mi">2</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">traced</span><span class="p">])))</span><span class="o">.</span><span class="n">max</span><span class="p">()</span>
<span class="k">if</span> <span class="n">max_xcfs</span> <span class="o">&gt;</span> <span class="mf">1e-12</span><span class="p">:</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Exchange field has non negligible scalar part. Largest value is </span><span class="si">{</span><span class="n">max_xcfs</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;H_and_XCF_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Hamiltonian and exchange field rotated. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;H_and_XCF_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="c1"># initialize pairs and magnetic entities based on input information</span>
<span class="n">pairs</span><span class="p">,</span> <span class="n">magnetic_entities</span> <span class="o">=</span> <span class="n">setup_pairs_and_magnetic_entities</span><span class="p">(</span>
<span class="n">magnetic_entities</span><span class="p">,</span> <span class="n">pairs</span><span class="p">,</span> <span class="n">dh</span><span class="p">,</span> <span class="n">simulation_parameters</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;site_and_pair_dictionaries_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Site and pair dictionaries created. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;site_and_pair_dictionaries_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="c1"># generate k space sampling</span>
<span class="n">kset</span> <span class="o">=</span> <span class="n">make_kset</span><span class="p">(</span>
<span class="n">dirs</span><span class="o">=</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kdirs&quot;</span><span class="p">],</span> <span class="n">NUMK</span><span class="o">=</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kset&quot;</span><span class="p">]</span>
<span class="p">)</span>
<span class="c1"># generate weights for k points</span>
<span class="n">wkset</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">kset</span><span class="p">))</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">kset</span><span class="p">)</span>
<span class="c1"># split the k points based on MPI size</span>
<span class="n">kpcs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array_split</span><span class="p">(</span><span class="n">kset</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
<span class="c1"># use progress bar if available</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span> <span class="ow">and</span> <span class="n">tqdm_imported</span><span class="p">:</span>
<span class="n">kpcs</span><span class="p">[</span><span class="n">root_node</span><span class="p">]</span> <span class="o">=</span> <span class="n">tqdm</span><span class="p">(</span><span class="n">kpcs</span><span class="p">[</span><span class="n">root_node</span><span class="p">],</span> <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;k loop&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;k_set_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;k set created. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;k_set_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="c1"># this will contain the three Hamiltonian in the</span>
<span class="c1"># reference directions needed to calculate the energy</span>
<span class="c1"># variations upon rotation</span>
<span class="n">hamiltonians</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># iterate over the reference directions (quantization axes)</span>
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">orient</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]):</span>
<span class="c1"># obtain rotated exchange field and Hamiltonian</span>
<span class="n">R</span> <span class="o">=</span> <span class="n">RotMa2b</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;scf_xcf_orientation&quot;</span><span class="p">],</span> <span class="n">orient</span><span class="p">[</span><span class="s2">&quot;o&quot;</span><span class="p">])</span>
<span class="n">rot_XCF</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">einsum</span><span class="p">(</span><span class="s2">&quot;ij,jklm-&gt;iklm&quot;</span><span class="p">,</span> <span class="n">R</span><span class="p">,</span> <span class="n">XCF</span><span class="p">)</span>
<span class="n">rot_H_XCF</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span>
<span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">kron</span><span class="p">(</span><span class="n">rot_XCF</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">tau</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">tau</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="n">tau_x</span><span class="p">,</span> <span class="n">tau_y</span><span class="p">,</span> <span class="n">tau_z</span><span class="p">])]</span>
<span class="p">)</span>
<span class="n">rot_H_XCF_uc</span> <span class="o">=</span> <span class="n">rot_H_XCF</span><span class="p">[</span><span class="n">uc_in_sc_idx</span><span class="p">]</span>
<span class="c1"># obtain total Hamiltonian with the rotated exchange field</span>
<span class="n">rot_H</span> <span class="o">=</span> <span class="n">hTRS</span> <span class="o">+</span> <span class="n">rot_H_XCF</span> <span class="c1"># equation 76</span>
<span class="c1"># store the relevant information of the Hamiltonian</span>
<span class="n">hamiltonians</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="n">orient</span><span class="o">=</span><span class="n">orient</span><span class="p">[</span><span class="s2">&quot;o&quot;</span><span class="p">],</span> <span class="n">H</span><span class="o">=</span><span class="n">rot_H</span><span class="p">))</span>
<span class="c1"># these are the rotations (for now) perpendicular to the quantization axis</span>
<span class="k">for</span> <span class="n">u</span> <span class="ow">in</span> <span class="n">orient</span><span class="p">[</span><span class="s2">&quot;vw&quot;</span><span class="p">]:</span>
<span class="c1"># section 2.H</span>
<span class="n">Tu</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">kron</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="n">NO</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">int</span><span class="p">),</span> <span class="n">tau_u</span><span class="p">(</span><span class="n">u</span><span class="p">))</span>
<span class="n">Vu1</span><span class="p">,</span> <span class="n">Vu2</span> <span class="o">=</span> <span class="n">calc_Vu</span><span class="p">(</span><span class="n">rot_H_XCF_uc</span><span class="p">,</span> <span class="n">Tu</span><span class="p">)</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="n">idx</span> <span class="o">=</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">]</span>
<span class="c1"># fill up the perturbed potentials (for now) based on the on-site projections</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu1&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">onsite_projection</span><span class="p">(</span><span class="n">Vu1</span><span class="p">,</span> <span class="n">idx</span><span class="p">,</span> <span class="n">idx</span><span class="p">))</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu2&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">onsite_projection</span><span class="p">(</span><span class="n">Vu2</span><span class="p">,</span> <span class="n">idx</span><span class="p">,</span> <span class="n">idx</span><span class="p">))</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;reference_rotations_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Rotations done perpendicular to quantization axis. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;reference_rotations_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="c1"># provide helpful information to estimate the runtime and memory</span>
<span class="c1"># requirements of the Greens function calculations</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Starting matrix inversions.&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;padawan_mode&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Padawan mode: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Total number of k points: </span><span class="si">{</span><span class="n">kset</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Number of energy samples per k point: </span><span class="si">{</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s1">&#39;eset&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Total number of directions: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">)</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Total number of matrix inversions: </span><span class="si">{</span><span class="n">kset</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">len</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s1">&#39;eset&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;The shape of the Hamiltonian and the Greens function is </span><span class="si">{</span><span class="n">NO</span><span class="si">}</span><span class="s2">x</span><span class="si">{</span><span class="n">NO</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="n">NO</span><span class="o">*</span><span class="n">NO</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span>
<span class="c1"># https://stackoverflow.com/questions/70746660/how-to-predict-memory-requirement-for-np-linalg-inv</span>
<span class="c1"># memory is O(64 n**2) for complex matrices</span>
<span class="n">memory_size</span> <span class="o">=</span> <span class="n">getsizeof</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s2">&quot;H&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">base</span><span class="p">)</span> <span class="o">/</span> <span class="mi">1024</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Memory taken by a single Hamiltonian is: </span><span class="si">{</span><span class="n">getsizeof</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;H&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">base</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mi">1024</span><span class="si">}</span><span class="s2"> KB&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Expected memory usage per matrix inversion: </span><span class="si">{</span><span class="n">memory_size</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">32</span><span class="si">}</span><span class="s2"> KB&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Expected memory usage per k point for parallel inversion: </span><span class="si">{</span><span class="n">memory_size</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">len</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s1">&#39;eset&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">32</span><span class="si">}</span><span class="s2"> KB&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Expected memory usage on root node: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array_split</span><span class="p">(</span><span class="n">kset</span><span class="p">,</span><span class="w"> </span><span class="n">size</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">memory_size</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="nb">len</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s1">&#39;eset&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">32</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="mi">1024</span><span class="si">}</span><span class="s2"> MB&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="c1"># MPI barrier</span>
<span class="n">comm</span><span class="o">.</span><span class="n">Barrier</span><span class="p">()</span>
<span class="c1"># make energy contour</span>
<span class="n">cont</span> <span class="o">=</span> <span class="n">make_contour</span><span class="p">(</span>
<span class="n">emin</span><span class="o">=</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">],</span>
<span class="n">enum</span><span class="o">=</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">],</span>
<span class="n">p</span><span class="o">=</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;esetp&quot;</span><span class="p">],</span>
<span class="p">)</span>
<span class="n">eran</span> <span class="o">=</span> <span class="n">cont</span><span class="o">.</span><span class="n">ze</span>
<span class="c1"># sampling the integrand on the contour and the BZ</span>
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">kpcs</span><span class="p">[</span><span class="n">rank</span><span class="p">]:</span>
<span class="c1"># weight of k point in BZ integral</span>
<span class="n">wk</span> <span class="o">=</span> <span class="n">wkset</span><span class="p">[</span><span class="n">rank</span><span class="p">]</span>
<span class="c1"># iterate over reference directions</span>
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">hamiltonian_orientation</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">):</span>
<span class="c1"># calculate Hamiltonian and Overlap matrix in a given k point</span>
<span class="n">H</span> <span class="o">=</span> <span class="n">hamiltonian_orientation</span><span class="p">[</span><span class="s2">&quot;H&quot;</span><span class="p">]</span>
<span class="n">HK</span><span class="p">,</span> <span class="n">SK</span> <span class="o">=</span> <span class="n">hsk</span><span class="p">(</span><span class="n">H</span><span class="p">,</span> <span class="n">ss</span><span class="p">,</span> <span class="n">dh</span><span class="o">.</span><span class="n">sc_off</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_solver_for_Gk&quot;</span><span class="p">]:</span>
<span class="n">Gk</span> <span class="o">=</span> <span class="n">parallel_Gk</span><span class="p">(</span><span class="n">HK</span><span class="p">,</span> <span class="n">SK</span><span class="p">,</span> <span class="n">eran</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">])</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># solve Greens function sequentially for the energies, because of memory bound</span>
<span class="n">Gk</span> <span class="o">=</span> <span class="n">sequential_GK</span><span class="p">(</span><span class="n">HK</span><span class="p">,</span> <span class="n">SK</span><span class="p">,</span> <span class="n">eran</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">])</span>
<span class="c1"># store the Greens function slice of the magnetic entities</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="n">idx</span> <span class="o">=</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">]</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii_tmp&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">+=</span> <span class="n">onsite_projection</span><span class="p">(</span><span class="n">Gk</span><span class="p">,</span> <span class="n">idx</span><span class="p">,</span> <span class="n">idx</span><span class="p">)</span> <span class="o">*</span> <span class="n">wk</span>
<span class="k">for</span> <span class="n">pair</span> <span class="ow">in</span> <span class="n">pairs</span><span class="p">:</span>
<span class="c1"># add phase shift based on the cell difference</span>
<span class="n">phase</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="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">k</span> <span class="o">@</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Ruc&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>
<span class="c1"># get the pair orbital sizes from the magnetic entities</span>
<span class="n">ai</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;ai&quot;</span><span class="p">]][</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">]</span>
<span class="n">aj</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;aj&quot;</span><span class="p">]][</span><span class="s2">&quot;spin_box_indices&quot;</span><span class="p">]</span>
<span class="c1"># store the Greens function slice of the magnetic entities</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij_tmp&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">+=</span> <span class="n">onsite_projection</span><span class="p">(</span><span class="n">Gk</span><span class="p">,</span> <span class="n">ai</span><span class="p">,</span> <span class="n">aj</span><span class="p">)</span> <span class="o">*</span> <span class="n">phase</span> <span class="o">*</span> <span class="n">wk</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji_tmp&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">+=</span> <span class="n">onsite_projection</span><span class="p">(</span><span class="n">Gk</span><span class="p">,</span> <span class="n">aj</span><span class="p">,</span> <span class="n">ai</span><span class="p">)</span> <span class="o">/</span> <span class="n">phase</span> <span class="o">*</span> <span class="n">wk</span>
<span class="c1"># summ reduce partial results of mpi nodes</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">hamiltonians</span><span class="p">)):</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="n">comm</span><span class="o">.</span><span class="n">Reduce</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii_tmp&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">root</span><span class="o">=</span><span class="n">root_node</span><span class="p">)</span>
<span class="k">for</span> <span class="n">pair</span> <span class="ow">in</span> <span class="n">pairs</span><span class="p">:</span>
<span class="n">comm</span><span class="o">.</span><span class="n">Reduce</span><span class="p">(</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij_tmp&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">root</span><span class="o">=</span><span class="n">root_node</span><span class="p">)</span>
<span class="n">comm</span><span class="o">.</span><span class="n">Reduce</span><span class="p">(</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji_tmp&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">root</span><span class="o">=</span><span class="n">root_node</span><span class="p">)</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;green_function_inversion_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Calculated Greens functions. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;green_function_inversion_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">rank</span> <span class="o">==</span> <span class="n">root_node</span><span class="p">:</span>
<span class="c1"># iterate over the magnetic entities</span>
<span class="k">for</span> <span class="n">tracker</span><span class="p">,</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">magnetic_entities</span><span class="p">):</span>
<span class="c1"># iterate over the quantization axes</span>
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">Gii</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Gii&quot;</span><span class="p">]):</span>
<span class="n">storage</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># iterate over the first and second order local perturbations</span>
<span class="k">for</span> <span class="n">Vu1</span><span class="p">,</span> <span class="n">Vu2</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu1&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;Vu2&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]):</span>
<span class="c1"># The Szunyogh-Lichtenstein formula</span>
<span class="n">traced</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">trace</span><span class="p">(</span>
<span class="p">(</span><span class="n">Vu2</span> <span class="o">@</span> <span class="n">Gii</span> <span class="o">+</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">Gii</span> <span class="o">@</span> <span class="n">Vu1</span> <span class="o">@</span> <span class="n">Gii</span><span class="p">),</span> <span class="n">axis1</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">axis2</span><span class="o">=</span><span class="mi">2</span>
<span class="p">)</span> <span class="c1"># this is the on site projection</span>
<span class="c1"># evaluation of the contour integral</span>
<span class="n">storage</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">int_de_ke</span><span class="p">(</span><span class="n">traced</span><span class="p">,</span> <span class="n">cont</span><span class="o">.</span><span class="n">we</span><span class="p">))</span>
<span class="c1"># fill up the magnetic entities dictionary with the energies</span>
<span class="n">magnetic_entities</span><span class="p">[</span><span class="n">tracker</span><span class="p">][</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">storage</span><span class="p">)</span>
<span class="c1"># convert to np array</span>
<span class="n">magnetic_entities</span><span class="p">[</span><span class="n">tracker</span><span class="p">][</span><span class="s2">&quot;energies&quot;</span><span class="p">]</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="n">magnetic_entities</span><span class="p">[</span><span class="n">tracker</span><span class="p">][</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span>
<span class="p">)</span>
<span class="c1"># iterate over the pairs</span>
<span class="k">for</span> <span class="n">tracker</span><span class="p">,</span> <span class="n">pair</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">pairs</span><span class="p">):</span>
<span class="c1"># iterate over the quantization axes</span>
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">Gij</span><span class="p">,</span> <span class="n">Gji</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gij&quot;</span><span class="p">],</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;Gji&quot;</span><span class="p">])):</span>
<span class="n">site_i</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;ai&quot;</span><span class="p">]]</span>
<span class="n">site_j</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;aj&quot;</span><span class="p">]]</span>
<span class="n">storage</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># iterate over the first order local perturbations in all possible orientations for the two sites</span>
<span class="k">for</span> <span class="n">Vui</span> <span class="ow">in</span> <span class="n">site_i</span><span class="p">[</span><span class="s2">&quot;Vu1&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]:</span>
<span class="k">for</span> <span class="n">Vuj</span> <span class="ow">in</span> <span class="n">site_j</span><span class="p">[</span><span class="s2">&quot;Vu1&quot;</span><span class="p">][</span><span class="n">i</span><span class="p">]:</span>
<span class="c1"># The Szunyogh-Lichtenstein formula</span>
<span class="n">traced</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">trace</span><span class="p">(</span>
<span class="p">(</span><span class="n">Vui</span> <span class="o">@</span> <span class="n">Gij</span> <span class="o">@</span> <span class="n">Vuj</span> <span class="o">@</span> <span class="n">Gji</span><span class="p">),</span> <span class="n">axis1</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">axis2</span><span class="o">=</span><span class="mi">2</span>
<span class="p">)</span> <span class="c1"># this is the on site projection</span>
<span class="c1"># evaluation of the contour integral</span>
<span class="n">storage</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">int_de_ke</span><span class="p">(</span><span class="n">traced</span><span class="p">,</span> <span class="n">cont</span><span class="o">.</span><span class="n">we</span><span class="p">))</span>
<span class="c1"># fill up the pairs dictionary with the energies</span>
<span class="n">pairs</span><span class="p">[</span><span class="n">tracker</span><span class="p">][</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">storage</span><span class="p">)</span>
<span class="c1"># convert to np array</span>
<span class="n">pairs</span><span class="p">[</span><span class="n">tracker</span><span class="p">][</span><span class="s2">&quot;energies&quot;</span><span class="p">]</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="n">pairs</span><span class="p">[</span><span class="n">tracker</span><span class="p">][</span><span class="s2">&quot;energies&quot;</span><span class="p">])</span>
<span class="c1"># calculate magnetic parameters</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="n">Kxx</span><span class="p">,</span> <span class="n">Kyy</span><span class="p">,</span> <span class="n">Kzz</span><span class="p">,</span> <span class="n">consistency</span> <span class="o">=</span> <span class="n">calculate_anisotropy_tensor</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">)</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;K&quot;</span><span class="p">]</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="n">Kxx</span><span class="p">,</span> <span class="n">Kyy</span><span class="p">,</span> <span class="n">Kzz</span><span class="p">])</span> <span class="o">*</span> <span class="n">sisl</span><span class="o">.</span><span class="n">unit_convert</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">,</span> <span class="s2">&quot;meV&quot;</span><span class="p">)</span>
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;K_consistency&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">consistency</span>
<span class="k">for</span> <span class="n">pair</span> <span class="ow">in</span> <span class="n">pairs</span><span class="p">:</span>
<span class="n">J_iso</span><span class="p">,</span> <span class="n">J_S</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span> <span class="o">=</span> <span class="n">calculate_exchange_tensor</span><span class="p">(</span><span class="n">pair</span><span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J_iso&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">J_iso</span> <span class="o">*</span> <span class="n">sisl</span><span class="o">.</span><span class="n">unit_convert</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">,</span> <span class="s2">&quot;meV&quot;</span><span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J_S&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">J_S</span> <span class="o">*</span> <span class="n">sisl</span><span class="o">.</span><span class="n">unit_convert</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">,</span> <span class="s2">&quot;meV&quot;</span><span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;D&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">D</span> <span class="o">*</span> <span class="n">sisl</span><span class="o">.</span><span class="n">unit_convert</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">,</span> <span class="s2">&quot;meV&quot;</span><span class="p">)</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">J</span> <span class="o">*</span> <span class="n">sisl</span><span class="o">.</span><span class="n">unit_convert</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">,</span> <span class="s2">&quot;meV&quot;</span><span class="p">)</span>
<span class="n">times</span><span class="p">[</span><span class="s2">&quot;end_time&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">timer</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n\n\n\n\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;##################################################################### GROGU OUTPUT #############################################################################&quot;</span>
<span class="p">)</span>
<span class="n">print_parameters</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">)</span>
<span class="n">print_atoms_and_pairs</span><span class="p">(</span><span class="n">magnetic_entities</span><span class="p">,</span> <span class="n">pairs</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;################################################################################################################################################################&quot;</span>
<span class="p">)</span>
<span class="n">print_runtime_information</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="c1"># remove unwanted stuff before saving</span>
<span class="n">pairs</span><span class="p">,</span> <span class="n">magnetic_entities</span> <span class="o">=</span> <span class="n">remove_clutter_for_save</span><span class="p">(</span><span class="n">pairs</span><span class="p">,</span> <span class="n">magnetic_entities</span><span class="p">)</span>
<span class="c1"># create output dictionary with all the relevant data</span>
<span class="n">results</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span>
<span class="n">parameters</span><span class="o">=</span><span class="n">simulation_parameters</span><span class="p">,</span>
<span class="n">magnetic_entities</span><span class="o">=</span><span class="n">magnetic_entities</span><span class="p">,</span>
<span class="n">pairs</span><span class="o">=</span><span class="n">pairs</span><span class="p">,</span>
<span class="n">runtime</span><span class="o">=</span><span class="n">times</span><span class="p">,</span>
<span class="p">)</span>
<span class="c1"># save results</span>
<span class="n">save_pickle</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">],</span> <span class="n">results</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n\n\n\n\n</span><span class="s2">&quot;</span><span class="p">)</span></div>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
<span class="n">main</span><span class="p">()</span>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, grogupy.</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>

@ -0,0 +1,456 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>grogupy.io &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=8d563738"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/design-tabs.js?v=f930bc37"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.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">
grogupy
</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" aria-label="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">
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</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">grogupy</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" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">grogupy.io</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for grogupy.io</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) [2024] []</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="c1"># in the Software without restriction, including without limitation the rights</span>
<span class="c1"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="c1"># copies of the Software, and to permit persons to whom the Software is</span>
<span class="c1"># furnished to do so, subject to the following conditions:</span>
<span class="c1">#</span>
<span class="c1"># The above copyright notice and this permission notice shall be included in all</span>
<span class="c1"># copies or substantial portions of the Software.</span>
<span class="c1">#</span>
<span class="c1"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="c1"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="c1"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<span class="c1"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="c1"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
<span class="c1"># SOFTWARE.</span>
<span class="kn">from</span> <span class="nn">argparse</span> <span class="kn">import</span> <span class="n">ArgumentParser</span>
<span class="kn">from</span> <span class="nn">pickle</span> <span class="kn">import</span> <span class="n">dump</span><span class="p">,</span> <span class="n">load</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="n">default_args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span>
<span class="n">infile</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">outfile</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">scf_xcf_orientation</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">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span>
<span class="n">ref_xcf_orientations</span><span class="o">=</span><span class="p">[</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">o</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">1</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="n">vw</span><span class="o">=</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</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="mi">1</span><span class="p">])]),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">o</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">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">vw</span><span class="o">=</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</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="n">np</span><span class="o">.</span><span class="n">array</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="mi">1</span><span class="p">])]),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">o</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">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="n">vw</span><span class="o">=</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</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="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">])]),</span>
<span class="p">],</span>
<span class="n">kset</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
<span class="n">kdirs</span><span class="o">=</span><span class="s2">&quot;xyz&quot;</span><span class="p">,</span>
<span class="n">ebot</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">eset</span><span class="o">=</span><span class="mi">42</span><span class="p">,</span>
<span class="n">esetp</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span>
<span class="n">parallel_solver_for_Gk</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">padawan_mode</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="c1"># parser = ArgumentParser()</span>
<span class="c1"># parser.add_argument(&#39;--input&#39; , dest = &#39;infile&#39; , default=None , help = &#39;Input file name&#39;)</span>
<span class="c1"># parser.add_argument(&#39;--output&#39; , dest = &#39;outfile&#39;, default=None , help = &#39;Output file name&#39;)</span>
<span class="c1"># parser.add_argument(&#39;--kset&#39; , dest = &#39;kset&#39; , default = 2 , type=int , help = &#39;k-space resolution of Jij calculation&#39;)</span>
<span class="c1"># parser.add_argument(&#39;--kdirs&#39; , dest = &#39;kdirs&#39; , default = &#39;xyz&#39; , help = &#39;Definition of k-space dimensionality&#39;)</span>
<span class="c1"># parser.add_argument(&#39;--ebot&#39; , dest = &#39;ebot&#39; , default = None , type=float, help = &#39;Bottom energy of the contour&#39;)</span>
<span class="c1"># parser.add_argument(&#39;--eset&#39; , dest = &#39;eset&#39; , default = 42 , type=int , help = &#39;Number of energy points on the contour&#39;)</span>
<span class="c1"># parser.add_argument(&#39;--eset-p&#39; , dest = &#39;esetp&#39; , default = 1000 , type=int , help = &#39;Parameter tuning the distribution on the contour&#39;)</span>
<span class="c1"># cmd_line_args = parser.parse_args()</span>
<div class="viewcode-block" id="save_pickle">
<a class="viewcode-back" href="../../grogupy.html#grogupy.io.save_pickle">[docs]</a>
<span class="k">def</span> <span class="nf">save_pickle</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Saves the data in the outfile with pickle.</span>
<span class="sd"> Args:</span>
<span class="sd"> outfile : str</span>
<span class="sd"> Path to outfile</span>
<span class="sd"> data : dict</span>
<span class="sd"> Contains the data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># save dictionary</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">&quot;wb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">output_file</span><span class="p">:</span>
<span class="n">dump</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">output_file</span><span class="p">)</span></div>
<div class="viewcode-block" id="load_pickle">
<a class="viewcode-back" href="../../grogupy.html#grogupy.io.load_pickle">[docs]</a>
<span class="k">def</span> <span class="nf">load_pickle</span><span class="p">(</span><span class="n">infile</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Loads the data from the infile with pickle.</span>
<span class="sd"> Args:</span>
<span class="sd"> infile : str</span>
<span class="sd"> Path to infile</span>
<span class="sd"> Returns:</span>
<span class="sd"> data : dict</span>
<span class="sd"> A dictionary of data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># open and read file</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">infile</span><span class="p">,</span> <span class="s2">&quot;wb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">input_file</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">load</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">input_file</span><span class="p">)</span>
<span class="k">return</span> <span class="n">data</span></div>
<div class="viewcode-block" id="print_parameters">
<a class="viewcode-back" href="../../grogupy.html#grogupy.io.print_parameters">[docs]</a>
<span class="k">def</span> <span class="nf">print_parameters</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the simulation parameters for the grogu out.</span>
<span class="sd"> Args:</span>
<span class="sd"> simulation_parameters : dict</span>
<span class="sd"> It contains the simulations parameters</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Input file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Output file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Number of nodes in the parallel cluster: &quot;</span><span class="p">,</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_size&quot;</span><span class="p">],</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Cell [Ang]: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;cell&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;DFT axis: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;scf_xcf_orientation&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Quantization axis and perpendicular rotation directions:&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">ref</span> <span class="ow">in</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">ref</span><span class="p">[</span><span class="s2">&quot;o&quot;</span><span class="p">],</span> <span class="s2">&quot; --» &quot;</span><span class="p">,</span> <span class="n">ref</span><span class="p">[</span><span class="s2">&quot;vw&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Parameters for the contour integral:&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Number of k points: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;k point directions: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kdirs&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Ebot: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Eset: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Esetp: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;esetp&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span></div>
<div class="viewcode-block" id="print_atoms_and_pairs">
<a class="viewcode-back" href="../../grogupy.html#grogupy.io.print_atoms_and_pairs">[docs]</a>
<span class="k">def</span> <span class="nf">print_atoms_and_pairs</span><span class="p">(</span><span class="n">magnetic_entities</span><span class="p">,</span> <span class="n">pairs</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the pair and magnetic entity information for the grogu out.</span>
<span class="sd"> Args:</span>
<span class="sd"> magnetic_entities : dict</span>
<span class="sd"> It contains the data on the magnetic entities</span>
<span class="sd"> pairs : dict</span>
<span class="sd"> It contains the data on the pairs</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Atomic information: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;[atom index]Element(orbitals) x [Ang] y [Ang] z [Ang] Sx Sy Sz Q Lx Ly Lz Jx Jy Jz&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="c1"># iterate over magnetic entities</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="c1"># iterate over atoms</span>
<span class="k">for</span> <span class="n">tag</span><span class="p">,</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">],</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;xyz&quot;</span><span class="p">]):</span>
<span class="c1"># coordinates and tag</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">tag</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Anisotropy [meV]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Magnetic entity x [Ang] y [Ang] z [Ang]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="c1"># iterate over magnetic entities</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="c1"># iterate over atoms</span>
<span class="k">for</span> <span class="n">tag</span><span class="p">,</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">],</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;xyz&quot;</span><span class="p">]):</span>
<span class="c1"># coordinates and tag</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">tag</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Consistency check: &quot;</span><span class="p">,</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;K_consistency&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Anisotropy diag: &quot;</span><span class="p">,</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;K&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Exchange [meV]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Magnetic entity1 Magnetic entity2 [i j k] d [Ang]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="c1"># iterate over pairs</span>
<span class="k">for</span> <span class="n">pair</span> <span class="ow">in</span> <span class="n">pairs</span><span class="p">:</span>
<span class="c1"># print pair parameters</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;tags&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;tags&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;Ruc&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> d [Ang] </span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;dist&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span>
<span class="c1"># print magnetic parameters</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Isotropic: &quot;</span><span class="p">,</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J_iso&quot;</span><span class="p">],</span> <span class="s2">&quot; # Tr[J] / 3&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;DMI: &quot;</span><span class="p">,</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;D&quot;</span><span class="p">],</span> <span class="s2">&quot; # Dx, Dy, Dz&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Symmetric-anisotropy: &quot;</span><span class="p">,</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J_S&quot;</span><span class="p">],</span>
<span class="s2">&quot; # J_S = J - J_iso * I &gt; Jxx, Jyy, Jxy, Jxz, Jyz&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;J: # Jxx, Jxy, Jxz, Jyx, Jyy, Jyz, Jzx, Jzy, Jzz&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span></div>
<div class="viewcode-block" id="print_runtime_information">
<a class="viewcode-back" href="../../grogupy.html#grogupy.io.print_runtime_information">[docs]</a>
<span class="k">def</span> <span class="nf">print_runtime_information</span><span class="p">(</span><span class="n">times</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the runtime information for the grogu out.</span>
<span class="sd"> Args:</span>
<span class="sd"> times : dict</span>
<span class="sd"> It contains the runtime data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Runtime information: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Total runtime: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;end_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;start_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Initial setup: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;setup_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;start_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Hamiltonian conversion and XC field extraction: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;H_and_XCF_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;setup_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Pair and site datastructure creatrions: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;site_and_pair_dictionaries_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;H_and_XCF_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;k set cration and distribution: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;k_set_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;site_and_pair_dictionaries_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Rotating XC potential: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;reference_rotations_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;k_set_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Greens function inversion: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;green_function_inversion_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;reference_rotations_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Calculate energies and magnetic components: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;end_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;green_function_inversion_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span></div>
<div class="viewcode-block" id="print_job_description">
<a class="viewcode-back" href="../../grogupy.html#grogupy.io.print_job_description">[docs]</a>
<span class="k">def</span> <span class="nf">print_job_description</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the parameters and the description of the job.</span>
<span class="sd"> Args:</span>
<span class="sd"> simulation_parameters : dict</span>
<span class="sd"> It contains the simulations parameters</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Input file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Output file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Number of nodes in the parallel cluster: &quot;</span><span class="p">,</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_size&quot;</span><span class="p">],</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_solver_for_Gk&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;solver used for Greens function calculation: parallel&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;solver used for Greens function calculation: sequential&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Cell [Ang]: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;cell&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;DFT axis: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;scf_xcf_orientation&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Quantization axis and perpendicular rotation directions:&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">ref</span> <span class="ow">in</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">ref</span><span class="p">[</span><span class="s2">&quot;o&quot;</span><span class="p">],</span> <span class="s2">&quot; --» &quot;</span><span class="p">,</span> <span class="n">ref</span><span class="p">[</span><span class="s2">&quot;vw&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Parameters for the contour integral:&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Number of k points: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;k point directions: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kdirs&quot;</span><span class="p">])</span>
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;automatic_ebot&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Ebot: &quot;</span><span class="p">,</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">],</span>
<span class="s2">&quot; WARNING: This was automatically determined!&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Ebot: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Eset: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Esetp: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;esetp&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, grogupy.</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>

@ -0,0 +1,348 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>grogupy.magnetism &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=8d563738"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/design-tabs.js?v=f930bc37"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.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">
grogupy
</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" aria-label="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">
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</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">grogupy</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" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">grogupy.magnetism</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for grogupy.magnetism</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) [2024] []</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="c1"># in the Software without restriction, including without limitation the rights</span>
<span class="c1"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="c1"># copies of the Software, and to permit persons to whom the Software is</span>
<span class="c1"># furnished to do so, subject to the following conditions:</span>
<span class="c1">#</span>
<span class="c1"># The above copyright notice and this permission notice shall be included in all</span>
<span class="c1"># copies or substantial portions of the Software.</span>
<span class="c1">#</span>
<span class="c1"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="c1"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="c1"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<span class="c1"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="c1"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
<span class="c1"># SOFTWARE.</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<div class="viewcode-block" id="blow_up_orbindx">
<a class="viewcode-back" href="../../grogupy.html#grogupy.magnetism.blow_up_orbindx">[docs]</a>
<span class="k">def</span> <span class="nf">blow_up_orbindx</span><span class="p">(</span><span class="n">orb_indices</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Function to blow up orbital indices to make SPIN BOX indices.</span>
<span class="sd"> Args:</span>
<span class="sd"> orb_indices : np.array_like</span>
<span class="sd"> These are the indices in ORBITAL BOX</span>
<span class="sd"> Returns:</span>
<span class="sd"> orb_indices : np.array_like</span>
<span class="sd"> These are the indices in SPIN BOX</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">orb_indices</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">2</span> <span class="o">*</span> <span class="n">o</span><span class="p">,</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">o</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">orb_indices</span><span class="p">])</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span>
<span class="k">return</span> <span class="n">orb_indices</span></div>
<div class="viewcode-block" id="spin_tracer">
<a class="viewcode-back" href="../../grogupy.html#grogupy.magnetism.spin_tracer">[docs]</a>
<span class="k">def</span> <span class="nf">spin_tracer</span><span class="p">(</span><span class="n">M</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Spin tracer utility.</span>
<span class="sd"> This takes an operator with the orbital-spin sequence:</span>
<span class="sd"> orbital 1 up,</span>
<span class="sd"> orbital 1 down,</span>
<span class="sd"> orbital 2 up,</span>
<span class="sd"> orbital 2 down,</span>
<span class="sd"> that is in the SPIN-BOX representation,</span>
<span class="sd"> and extracts orbital dependent Pauli traces.</span>
<span class="sd"> Args:</span>
<span class="sd"> M : np.array_like</span>
<span class="sd"> Traceable matrix</span>
<span class="sd"> Returns:</span>
<span class="sd"> dict</span>
<span class="sd"> It contains the traced matrix with &quot;x&quot;, &quot;y&quot;, &quot;z&quot; and &quot;c&quot;</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">M11</span> <span class="o">=</span> <span class="n">M</span><span class="p">[</span><span class="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="n">M12</span> <span class="o">=</span> <span class="n">M</span><span class="p">[</span><span class="mi">0</span><span class="p">::</span><span class="mi">2</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="n">M21</span> <span class="o">=</span> <span class="n">M</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="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="n">M22</span> <span class="o">=</span> <span class="n">M</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="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="n">M_o</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;x&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">M12</span> <span class="o">+</span> <span class="n">M21</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;y&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="p">(</span><span class="n">M12</span> <span class="o">-</span> <span class="n">M21</span><span class="p">)</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;z&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">M11</span> <span class="o">-</span> <span class="n">M22</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;c&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">M11</span> <span class="o">+</span> <span class="n">M22</span>
<span class="k">return</span> <span class="n">M_o</span></div>
<div class="viewcode-block" id="parse_magnetic_entity">
<a class="viewcode-back" href="../../grogupy.html#grogupy.magnetism.parse_magnetic_entity">[docs]</a>
<span class="k">def</span> <span class="nf">parse_magnetic_entity</span><span class="p">(</span><span class="n">dh</span><span class="p">,</span> <span class="n">atom</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">l</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Function to define orbital indexes of a given magnetic entity.</span>
<span class="sd"> Args:</span>
<span class="sd"> dh : sisl.physics.Hamiltonian</span>
<span class="sd"> Hamiltonian from sisl</span>
<span class="sd"> atom : integer or list of integers, optional</span>
<span class="sd"> Defining atom (or atoms) in the unit cell forming the magnetic entity. Defaults to None</span>
<span class="sd"> l : integer, optional</span>
<span class="sd"> Defining the angular momentum channel. Defaults to None</span>
<span class="sd"> Returns:</span>
<span class="sd"> list</span>
<span class="sd"> The orbital indexes of the given magnetic entity</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># case where we deal with more than one atom defining the magnetic entity</span>
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">atom</span><span class="p">)</span> <span class="o">==</span> <span class="nb">list</span><span class="p">:</span>
<span class="n">dat</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">atom</span><span class="p">:</span>
<span class="n">a_orb_idx</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">a2o</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="nb">all</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span>
<span class="nb">type</span><span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="o">==</span> <span class="nb">int</span>
<span class="p">):</span> <span class="c1"># if specified we restrict to given l angular momentum channel inside each atom</span>
<span class="n">a_orb_idx</span> <span class="o">=</span> <span class="n">a_orb_idx</span><span class="p">[[</span><span class="n">o</span><span class="o">.</span><span class="n">l</span> <span class="o">==</span> <span class="n">l</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">a</span><span class="p">]</span><span class="o">.</span><span class="n">orbitals</span><span class="p">]]</span>
<span class="n">dat</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">a_orb_idx</span><span class="p">)</span>
<span class="n">orbital_indeces</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">dat</span><span class="p">)</span>
<span class="c1"># case where we deal with a singel atom magnetic entity</span>
<span class="k">elif</span> <span class="nb">type</span><span class="p">(</span><span class="n">atom</span><span class="p">)</span> <span class="o">==</span> <span class="nb">int</span><span class="p">:</span>
<span class="n">orbital_indeces</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">a2o</span><span class="p">(</span><span class="n">atom</span><span class="p">,</span> <span class="nb">all</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span>
<span class="nb">type</span><span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="o">==</span> <span class="nb">int</span>
<span class="p">):</span> <span class="c1"># if specified we restrict to given l angular momentum channel</span>
<span class="n">orbital_indeces</span> <span class="o">=</span> <span class="n">orbital_indeces</span><span class="p">[</span>
<span class="p">[</span><span class="n">o</span><span class="o">.</span><span class="n">l</span> <span class="o">==</span> <span class="n">l</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atom</span><span class="p">]</span><span class="o">.</span><span class="n">orbitals</span><span class="p">]</span>
<span class="p">]</span>
<span class="k">return</span> <span class="n">orbital_indeces</span> <span class="c1"># numpy array containing integers labeling orbitals associated to a magnetic entity.</span></div>
<div class="viewcode-block" id="calculate_anisotropy_tensor">
<a class="viewcode-back" href="../../grogupy.html#grogupy.magnetism.calculate_anisotropy_tensor">[docs]</a>
<span class="k">def</span> <span class="nf">calculate_anisotropy_tensor</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Calculates the renormalized anisotropy tensor from the energies.</span>
<span class="sd"> It uses the grogu convention for output.</span>
<span class="sd"> Args:</span>
<span class="sd"> mag_ent : dict</span>
<span class="sd"> An element from the magnetic entities</span>
<span class="sd"> Returns:</span>
<span class="sd"> K : np.array_like</span>
<span class="sd"> elements of the anisotropy tensor</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># get the energies</span>
<span class="n">energies</span> <span class="o">=</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span>
<span class="c1"># calculate the diagonal tensor elements</span>
<span class="n">Kxx</span> <span class="o">=</span> <span class="n">energies</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">energies</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
<span class="n">Kyy</span> <span class="o">=</span> <span class="n">energies</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">energies</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="n">Kzz</span> <span class="o">=</span> <span class="mi">0</span>
<span class="c1"># perform consistency check</span>
<span class="n">calculated_diff</span> <span class="o">=</span> <span class="n">Kyy</span> <span class="o">-</span> <span class="n">Kxx</span>
<span class="n">expected_diff</span> <span class="o">=</span> <span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
<span class="n">consistency_check</span> <span class="o">=</span> <span class="nb">abs</span><span class="p">(</span><span class="n">calculated_diff</span> <span class="o">-</span> <span class="n">expected_diff</span><span class="p">)</span>
<span class="k">return</span> <span class="n">Kxx</span><span class="p">,</span> <span class="n">Kyy</span><span class="p">,</span> <span class="n">Kzz</span><span class="p">,</span> <span class="n">consistency_check</span></div>
<div class="viewcode-block" id="calculate_exchange_tensor">
<a class="viewcode-back" href="../../grogupy.html#grogupy.magnetism.calculate_exchange_tensor">[docs]</a>
<span class="k">def</span> <span class="nf">calculate_exchange_tensor</span><span class="p">(</span><span class="n">pair</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Calculates the exchange tensor from the energies.</span>
<span class="sd"> It produces the isotropic exchange, the relevant elements</span>
<span class="sd"> from the Dzyaloshinskii-Morilla (Dm) tensor, the symmetric-anisotropy</span>
<span class="sd"> and the complete exchange tensor.</span>
<span class="sd"> Args:</span>
<span class="sd"> pair : dict</span>
<span class="sd"> An element from the pairs</span>
<span class="sd"> Returns:</span>
<span class="sd"> J_iso : float</span>
<span class="sd"> Isotropic exchange (Tr[J] / 3)</span>
<span class="sd"> J_S : np.array_like</span>
<span class="sd"> Symmetric-anisotropy (J_S = J - J_iso * I &gt; Jxx, Jyy, Jxy, Jxz, Jyz)</span>
<span class="sd"> D : np.array_like</span>
<span class="sd"> DM elements (Dx, Dy, Dz)</span>
<span class="sd"> J : np.array_like</span>
<span class="sd"> Complete exchange tensor flattened (Jxx, Jxy, Jxz, Jyx, Jyy, Jyz, Jzx, Jzy, Jzz)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># energies from rotations</span>
<span class="n">energies</span> <span class="o">=</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span>
<span class="c1"># Initialize output arrays</span>
<span class="n">J</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="n">D</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="c1"># J matrix calculations</span>
<span class="c1"># J(1,1) = mean([DEij(2,2,2), DEij(2,2,3)])</span>
<span class="n">J</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="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]])</span>
<span class="c1"># J(1,2) = -mean([DEij(1,2,3), DEij(2,1,3)])</span>
<span class="n">J</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
<span class="n">J</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">J</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
<span class="c1"># J(1,3) = -mean([DEij(1,2,2), DEij(2,1,2)])</span>
<span class="n">J</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">energies</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="n">J</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">J</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span>
<span class="c1"># J(2,2) = mean([DEij(2,2,1), DEij(1,1,3)])</span>
<span class="n">J</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">]])</span>
<span class="c1"># J(2,3) = -mean([DEij(1,2,1), DEij(2,1,1)])</span>
<span class="n">J</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="o">=</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">energies</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
<span class="n">J</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">J</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="c1"># J(3,3) = mean([DEij(1,1,1), DEij(1,1,2)])</span>
<span class="n">J</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</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="n">energies</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]])</span>
<span class="c1"># D vector calculations</span>
<span class="c1"># D(1) = mean([DEij(1,2,1), -DEij(2,1,1)])</span>
<span class="n">D</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="o">-</span><span class="n">energies</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
<span class="c1"># D(2) = mean([DEij(2,1,2), -DEij(1,2,2)])</span>
<span class="n">D</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</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="o">-</span><span class="n">energies</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]])</span>
<span class="c1"># D(3) = mean([DEij(1,2,3), -DEij(2,1,3)])</span>
<span class="n">D</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="o">-</span><span class="n">energies</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">]])</span>
<span class="n">J_iso</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">trace</span><span class="p">(</span><span class="n">J</span><span class="p">)</span> <span class="o">/</span> <span class="mi">3</span>
<span class="c1"># based on the grogu output pdf</span>
<span class="c1"># traceless symmetric exchange matrix:</span>
<span class="c1"># Jxx, Jyy, Jxy, Jxz, Jyz</span>
<span class="n">J_S</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="n">J</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="o">-</span> <span class="n">J_iso</span><span class="p">,</span> <span class="n">J</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">J_iso</span><span class="p">,</span> <span class="n">J</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">J</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="n">J</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="k">return</span> <span class="n">J_iso</span><span class="p">,</span> <span class="n">J_S</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">J</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, grogupy.</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>

@ -5,31 +5,33 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>grogu.useful &mdash; Grogu 0.0.1 documentation</title>
<title>grogupy.utilities &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=d45e8c67"></script>
<script src="../../_static/documentation_options.js?v=8d563738"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/design-tabs.js?v=f930bc37"></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="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<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">
Grogu
grogupy
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@ -39,9 +41,29 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
</ul>
</div>
@ -50,7 +72,7 @@
<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">Grogu</a>
<a href="../../index.html">grogupy</a>
</nav>
<div class="wy-nav-content">
@ -59,7 +81,7 @@
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">grogu.useful</li>
<li class="breadcrumb-item active">grogupy.utilities</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
@ -67,9 +89,9 @@
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for grogu.useful</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) [2024] [Daniel Pozsar]</span>
<h1>Source code for grogupy.utilities</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) [2024] []</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
@ -89,10 +111,9 @@
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
<span class="c1"># SOFTWARE.</span>
<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">permutations</span><span class="p">,</span> <span class="n">product</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">scipy.special</span> <span class="kn">import</span> <span class="n">roots_legendre</span>
<span class="kn">from</span> <span class="nn">sisl.io.siesta</span> <span class="kn">import</span> <span class="n">eigSileSiesta</span>
<span class="c1"># Pauli matrices</span>
<span class="n">tau_x</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">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]])</span>
@ -101,19 +122,61 @@
<span class="n">tau_0</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">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]])</span>
<div class="viewcode-block" id="commutator">
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.commutator">[docs]</a>
<span class="k">def</span> <span class="nf">commutator</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Shorthand for commutator.</span>
<span class="sd"> Commutator of two matrices in the mathematical sense.</span>
<span class="sd"> Args:</span>
<span class="sd"> a : np.array_like</span>
<span class="sd"> The first matrix</span>
<span class="sd"> b : np.array_like</span>
<span class="sd"> The second matrix</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> The commutator of a and b</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">a</span> <span class="o">@</span> <span class="n">b</span> <span class="o">-</span> <span class="n">b</span> <span class="o">@</span> <span class="n">a</span></div>
<span class="c1"># define some useful functions</span>
<div class="viewcode-block" id="hsk">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.hsk">[docs]</a>
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.hsk">[docs]</a>
<span class="k">def</span> <span class="nf">hsk</span><span class="p">(</span><span class="n">H</span><span class="p">,</span> <span class="n">ss</span><span class="p">,</span> <span class="n">sc_off</span><span class="p">,</span> <span class="n">k</span><span class="o">=</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="mi">0</span><span class="p">)):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> One way to speed up Hk and Sk generation</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Speed up Hk and Sk generation.</span>
<span class="sd"> Calculates the Hamiltonian and the Overlap matrix at a given k point. It is faster that the sisl version.</span>
<span class="sd"> Args:</span>
<span class="sd"> H : np.array_like</span>
<span class="sd"> Hamiltonian in spin box form</span>
<span class="sd"> ss : np.array_like</span>
<span class="sd"> Overlap matrix in spin box form</span>
<span class="sd"> sc_off : list</span>
<span class="sd"> supercell indexes of the Hamiltonian</span>
<span class="sd"> k : tuple, optional</span>
<span class="sd"> The k point where the matrices are set up. Defaults to (0, 0, 0)</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> Hamiltonian at the given k point</span>
<span class="sd"> np.array_like</span>
<span class="sd"> Overlap matrix at the given k point</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span> <span class="c1"># this two conversion lines</span>
<span class="n">k</span><span class="o">.</span><span class="n">shape</span> <span class="o">=</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,)</span> <span class="c1"># are from the sisl source</span>
<span class="c1"># this two conversion lines are from the sisl source</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float64</span><span class="p">)</span>
<span class="n">k</span><span class="o">.</span><span class="n">shape</span> <span class="o">=</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,)</span>
<span class="c1"># this generates the list of phases</span>
<span class="n">phases</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="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">k</span> <span class="o">@</span> <span class="n">sc_off</span><span class="o">.</span><span class="n">T</span><span class="p">)</span>
<span class="c1"># phases applied to the hamiltonian</span>
<span class="n">HK</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">einsum</span><span class="p">(</span><span class="s2">&quot;abc,a-&gt;bc&quot;</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">phases</span><span class="p">)</span>
<span class="n">SK</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">einsum</span><span class="p">(</span><span class="s2">&quot;abc,a-&gt;bc&quot;</span><span class="p">,</span> <span class="n">ss</span><span class="p">,</span> <span class="n">phases</span><span class="p">)</span>
@ -121,48 +184,29 @@
<div class="viewcode-block" id="make_contour">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.make_contour">[docs]</a>
<span class="k">def</span> <span class="nf">make_contour</span><span class="p">(</span><span class="n">emin</span><span class="o">=-</span><span class="mi">20</span><span class="p">,</span> <span class="n">emax</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">enum</span><span class="o">=</span><span class="mi">42</span><span class="p">,</span> <span class="n">p</span><span class="o">=</span><span class="mi">150</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> A more sophisticated contour generator</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">x</span><span class="p">,</span> <span class="n">wl</span> <span class="o">=</span> <span class="n">roots_legendre</span><span class="p">(</span><span class="n">enum</span><span class="p">)</span>
<span class="n">R</span> <span class="o">=</span> <span class="p">(</span><span class="n">emax</span> <span class="o">-</span> <span class="n">emin</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="n">z0</span> <span class="o">=</span> <span class="p">(</span><span class="n">emax</span> <span class="o">+</span> <span class="n">emin</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="n">y1</span> <span class="o">=</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">p</span><span class="p">)</span>
<span class="n">y2</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">y</span> <span class="o">=</span> <span class="p">(</span><span class="n">y2</span> <span class="o">-</span> <span class="n">y1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">x</span> <span class="o">+</span> <span class="p">(</span><span class="n">y2</span> <span class="o">+</span> <span class="n">y1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="n">phi</span> <span class="o">=</span> <span class="p">(</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">y</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="n">p</span>
<span class="n">ze</span> <span class="o">=</span> <span class="n">z0</span> <span class="o">+</span> <span class="n">R</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="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="n">phi</span><span class="p">)</span>
<span class="n">we</span> <span class="o">=</span> <span class="o">-</span><span class="p">(</span><span class="n">y2</span> <span class="o">-</span> <span class="n">y1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</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">y</span><span class="p">)</span> <span class="o">/</span> <span class="n">p</span> <span class="o">*</span> <span class="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="p">(</span><span class="n">ze</span> <span class="o">-</span> <span class="n">z0</span><span class="p">)</span> <span class="o">*</span> <span class="n">wl</span>
<span class="k">class</span> <span class="nc">ccont</span><span class="p">:</span>
<span class="c1"># just an empty container class</span>
<span class="k">pass</span>
<span class="n">cont</span> <span class="o">=</span> <span class="n">ccont</span><span class="p">()</span>
<span class="n">cont</span><span class="o">.</span><span class="n">R</span> <span class="o">=</span> <span class="n">R</span>
<span class="n">cont</span><span class="o">.</span><span class="n">z0</span> <span class="o">=</span> <span class="n">z0</span>
<span class="n">cont</span><span class="o">.</span><span class="n">ze</span> <span class="o">=</span> <span class="n">ze</span>
<span class="n">cont</span><span class="o">.</span><span class="n">we</span> <span class="o">=</span> <span class="n">we</span>
<span class="n">cont</span><span class="o">.</span><span class="n">enum</span> <span class="o">=</span> <span class="n">enum</span>
<div class="viewcode-block" id="make_kset">
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.make_kset">[docs]</a>
<span class="k">def</span> <span class="nf">make_kset</span><span class="p">(</span><span class="n">dirs</span><span class="o">=</span><span class="s2">&quot;xyz&quot;</span><span class="p">,</span> <span class="n">NUMK</span><span class="o">=</span><span class="mi">20</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Simple k-grid generator to sample the Brillouin zone.</span>
<span class="k">return</span> <span class="n">cont</span></div>
<span class="sd"> Depending on the value of the dirs</span>
<span class="sd"> argument k sampling in 1,2 or 3 dimensions is generated.</span>
<span class="sd"> If dirs argument does not contain either of x, y or z</span>
<span class="sd"> a kset of a single k-pont at the origin is returned. The total number of k points is the NUMK**(dimensions)</span>
<span class="sd"> Args:</span>
<span class="sd"> dirs : str, optional</span>
<span class="sd"> Directions of the k points in the Brillouin zone. They are the three lattice vectors. Defaults to &quot;xyz&quot;</span>
<span class="sd"> NUMK : int, optional</span>
<span class="sd"> The number of k points in a direction. Defaults to 20</span>
<div class="viewcode-block" id="make_kset">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.make_kset">[docs]</a>
<span class="k">def</span> <span class="nf">make_kset</span><span class="p">(</span><span class="n">dirs</span><span class="o">=</span><span class="s2">&quot;xyz&quot;</span><span class="p">,</span> <span class="n">NUMK</span><span class="o">=</span><span class="mi">20</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Simple k-grid generator. Depending on the value of the dirs</span>
<span class="sd"> argument k sampling in 1,2 or 3 dimensions is generated.</span>
<span class="sd"> If dirs argument does not contain either of x,y or z</span>
<span class="sd"> a kset of a single k-pont at the origin is returend.</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> An array of k points that uniformly sample the Brillouin zone in the given directions</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># if there is no xyz in dirs return the Gamma point</span>
<span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="nb">sum</span><span class="p">([</span><span class="n">d</span> <span class="ow">in</span> <span class="n">dirs</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="s2">&quot;xyz&quot;</span><span class="p">])):</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</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="mi">0</span><span class="p">]])</span>
@ -181,43 +225,117 @@
<div class="viewcode-block" id="commutator">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.commutator">[docs]</a>
<span class="k">def</span> <span class="nf">commutator</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
<span class="s2">&quot;Shorthand for commutator&quot;</span>
<span class="k">return</span> <span class="n">a</span> <span class="o">@</span> <span class="n">b</span> <span class="o">-</span> <span class="n">b</span> <span class="o">@</span> <span class="n">a</span></div>
<div class="viewcode-block" id="make_contour">
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.make_contour">[docs]</a>
<span class="k">def</span> <span class="nf">make_contour</span><span class="p">(</span><span class="n">emin</span><span class="o">=-</span><span class="mi">20</span><span class="p">,</span> <span class="n">emax</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">enum</span><span class="o">=</span><span class="mi">42</span><span class="p">,</span> <span class="n">p</span><span class="o">=</span><span class="mi">150</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A more sophisticated contour generator.</span>
<span class="sd"> Calculates the parameters for the complex contour integral. It uses the</span>
<span class="sd"> Legendre-Gauss quadrature method. It returns a class that contains</span>
<span class="sd"> the information for the contour integral.</span>
<span class="sd"> Args:</span>
<span class="sd"> emin : int, optional</span>
<span class="sd"> Energy minimum of the contour. Defaults to -20</span>
<span class="sd"> emax : float, optional</span>
<span class="sd"> Energy maximum of the contour. Defaults to 0.0, so the Fermi level</span>
<span class="sd"> enum : int, optional</span>
<span class="sd"> Number of sample points along the contour. Defaults to 42</span>
<span class="sd"> p : int, optional</span>
<span class="sd"> Shape parameter that describes the distribution of the sample points. Defaults to 150</span>
<span class="sd"> Returns:</span>
<span class="sd"> ccont</span>
<span class="sd"> Contains all the information for the contour integral</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">x</span><span class="p">,</span> <span class="n">wl</span> <span class="o">=</span> <span class="n">roots_legendre</span><span class="p">(</span><span class="n">enum</span><span class="p">)</span>
<span class="n">R</span> <span class="o">=</span> <span class="p">(</span><span class="n">emax</span> <span class="o">-</span> <span class="n">emin</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span> <span class="c1"># radius</span>
<span class="n">z0</span> <span class="o">=</span> <span class="p">(</span><span class="n">emax</span> <span class="o">+</span> <span class="n">emin</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span> <span class="c1"># center point</span>
<span class="n">y1</span> <span class="o">=</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">p</span><span class="p">)</span> <span class="c1"># lower bound</span>
<span class="n">y2</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># upper bound</span>
<span class="n">y</span> <span class="o">=</span> <span class="p">(</span><span class="n">y2</span> <span class="o">-</span> <span class="n">y1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">x</span> <span class="o">+</span> <span class="p">(</span><span class="n">y2</span> <span class="o">+</span> <span class="n">y1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="n">phi</span> <span class="o">=</span> <span class="p">(</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">y</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="n">p</span> <span class="c1"># angle parameter</span>
<span class="n">ze</span> <span class="o">=</span> <span class="n">z0</span> <span class="o">+</span> <span class="n">R</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="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="n">phi</span><span class="p">)</span> <span class="c1"># complex points for path</span>
<span class="n">we</span> <span class="o">=</span> <span class="o">-</span><span class="p">(</span><span class="n">y2</span> <span class="o">-</span> <span class="n">y1</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</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">y</span><span class="p">)</span> <span class="o">/</span> <span class="n">p</span> <span class="o">*</span> <span class="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="p">(</span><span class="n">ze</span> <span class="o">-</span> <span class="n">z0</span><span class="p">)</span> <span class="o">*</span> <span class="n">wl</span>
<span class="c1"># just an empty container class</span>
<span class="k">class</span> <span class="nc">ccont</span><span class="p">:</span>
<span class="k">pass</span>
<span class="n">cont</span> <span class="o">=</span> <span class="n">ccont</span><span class="p">()</span>
<span class="n">cont</span><span class="o">.</span><span class="n">R</span> <span class="o">=</span> <span class="n">R</span>
<span class="n">cont</span><span class="o">.</span><span class="n">z0</span> <span class="o">=</span> <span class="n">z0</span>
<span class="n">cont</span><span class="o">.</span><span class="n">ze</span> <span class="o">=</span> <span class="n">ze</span>
<span class="n">cont</span><span class="o">.</span><span class="n">we</span> <span class="o">=</span> <span class="n">we</span>
<span class="n">cont</span><span class="o">.</span><span class="n">enum</span> <span class="o">=</span> <span class="n">enum</span>
<span class="k">return</span> <span class="n">cont</span></div>
<div class="viewcode-block" id="tau_u">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.tau_u">[docs]</a>
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.tau_u">[docs]</a>
<span class="k">def</span> <span class="nf">tau_u</span><span class="p">(</span><span class="n">u</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Pauli matrix in direction u.</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Pauli matrix in direction u.</span>
<span class="sd"> Returns the vector u in the basis of the Pauli matrices.</span>
<span class="sd"> Args:</span>
<span class="sd"> u : list or np.array_like</span>
<span class="sd"> The direction</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> Arbitrary direction in the base of the Pauli matrices</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">u</span> <span class="o">=</span> <span class="n">u</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">u</span><span class="p">)</span> <span class="c1"># u is force to be of unit length</span>
<span class="c1"># u is force to be of unit length</span>
<span class="n">u</span> <span class="o">=</span> <span class="n">u</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
<span class="k">return</span> <span class="n">u</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">tau_x</span> <span class="o">+</span> <span class="n">u</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">tau_y</span> <span class="o">+</span> <span class="n">u</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="n">tau_z</span></div>
<span class="c1">#</span>
<div class="viewcode-block" id="crossM">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.crossM">[docs]</a>
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.crossM">[docs]</a>
<span class="k">def</span> <span class="nf">crossM</span><span class="p">(</span><span class="n">u</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Definition for the cross-product matrix.</span>
<span class="sd"> Acting as a cross product with vector u.</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Definition for the cross-product matrix.</span>
<span class="sd"> It acts as a cross product with vector u.</span>
<span class="sd"> Args:</span>
<span class="sd"> u : list or np.array_like</span>
<span class="sd"> The second vector in the cross product</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> The matrix that represents teh cross product with a vector</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="n">u</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">u</span><span class="p">[</span><span class="mi">1</span><span class="p">]],</span> <span class="p">[</span><span class="n">u</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="n">u</span><span class="p">[</span><span class="mi">0</span><span class="p">]],</span> <span class="p">[</span><span class="o">-</span><span class="n">u</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">u</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="mi">0</span><span class="p">]])</span></div>
<div class="viewcode-block" id="RotM">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.RotM">[docs]</a>
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.RotM">[docs]</a>
<span class="k">def</span> <span class="nf">RotM</span><span class="p">(</span><span class="n">theta</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="mf">1e-10</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Definition of rotation matrix with angle theta around direction u.</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Definition of rotation matrix with angle theta around direction u.</span>
<span class="sd"> Args:</span>
<span class="sd"> theta : float</span>
<span class="sd"> The angle of rotation</span>
<span class="sd"> u : np.array_like</span>
<span class="sd"> The rotation axis</span>
<span class="sd"> eps : float, optional</span>
<span class="sd"> Cutoff for small elements in the resulting matrix. Defaults to 1e-10</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> The rotation matrix</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">u</span> <span class="o">=</span> <span class="n">u</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
<span class="n">M</span> <span class="o">=</span> <span class="p">(</span>
@ -225,146 +343,87 @@
<span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">theta</span><span class="p">)</span> <span class="o">*</span> <span class="n">crossM</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">cos</span><span class="p">(</span><span class="n">theta</span><span class="p">))</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">outer</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">u</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">M</span><span class="p">[</span><span class="nb">abs</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">eps</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span> <span class="c1"># kill off small numbers</span>
<span class="c1"># kill off small numbers</span>
<span class="n">M</span><span class="p">[</span><span class="nb">abs</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">eps</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="k">return</span> <span class="n">M</span></div>
<div class="viewcode-block" id="RotMa2b">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.RotMa2b">[docs]</a>
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.RotMa2b">[docs]</a>
<span class="k">def</span> <span class="nf">RotMa2b</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">eps</span><span class="o">=</span><span class="mf">1e-10</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Definition of rotation matrix rotating unit vector a to unit vector b.</span>
<span class="sd"> Function returns array R such that R@a = b holds.</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Definition of rotation matrix rotating unit vector a to unit vector b.</span>
<span class="sd"> Function returns array R such that R @ a = b holds.</span>
<span class="sd"> Args:</span>
<span class="sd"> a : np.array_like</span>
<span class="sd"> First vector</span>
<span class="sd"> b : np.array_like</span>
<span class="sd"> Second vector</span>
<span class="sd"> eps : float, optional</span>
<span class="sd"> Cutoff for small elements in the resulting matrix. Defaults to 1e-10</span>
<span class="sd"> Returns:</span>
<span class="sd"> np.array_like</span>
<span class="sd"> The rotation matrix with the above property</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">v</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">cross</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">a</span> <span class="o">@</span> <span class="n">b</span>
<span class="n">M</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">+</span> <span class="n">crossM</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">+</span> <span class="n">crossM</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">@</span> <span class="n">crossM</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="n">c</span><span class="p">)</span>
<span class="n">M</span><span class="p">[</span><span class="nb">abs</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">eps</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span> <span class="c1"># kill off small numbers</span>
<span class="c1"># kill off small numbers</span>
<span class="n">M</span><span class="p">[</span><span class="nb">abs</span><span class="p">(</span><span class="n">M</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">eps</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="k">return</span> <span class="n">M</span></div>
<div class="viewcode-block" id="spin_tracer">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.spin_tracer">[docs]</a>
<span class="k">def</span> <span class="nf">spin_tracer</span><span class="p">(</span><span class="n">M</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Spin tracer utility.</span>
<span class="sd"> This akes an operator with the orbital-spin sequence:</span>
<span class="sd"> orbital 1 up,</span>
<span class="sd"> orbital 1 down,</span>
<span class="sd"> orbital 2 up,</span>
<span class="sd"> orbital 2 down,</span>
<span class="sd"> that is in the SPIN-BOX representation,</span>
<span class="sd"> and extracts orbital dependent Pauli traces.</span>
<div class="viewcode-block" id="read_siesta_emin">
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.read_siesta_emin">[docs]</a>
<span class="k">def</span> <span class="nf">read_siesta_emin</span><span class="p">(</span><span class="n">eigfile</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It reads the lowest energy level from the siesta run.</span>
<span class="sd"> It uses the .EIG file from siesta that contains the eigenvalues.</span>
<span class="sd"> Args:</span>
<span class="sd"> eigfile : str</span>
<span class="sd"> The path to the .EIG file</span>
<span class="sd"> Returns:</span>
<span class="sd"> float</span>
<span class="sd"> The energy minimum</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">M11</span> <span class="o">=</span> <span class="n">M</span><span class="p">[</span><span class="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="n">M12</span> <span class="o">=</span> <span class="n">M</span><span class="p">[</span><span class="mi">0</span><span class="p">::</span><span class="mi">2</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="n">M21</span> <span class="o">=</span> <span class="n">M</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="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="n">M22</span> <span class="o">=</span> <span class="n">M</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="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
<span class="c1"># read the file</span>
<span class="n">eigs</span> <span class="o">=</span> <span class="n">eigSileSiesta</span><span class="p">(</span><span class="n">eigfile</span><span class="p">)</span><span class="o">.</span><span class="n">read_data</span><span class="p">()</span>
<span class="n">M_o</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;x&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">M12</span> <span class="o">+</span> <span class="n">M21</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;y&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span><span class="n">j</span> <span class="o">*</span> <span class="p">(</span><span class="n">M12</span> <span class="o">-</span> <span class="n">M21</span><span class="p">)</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;z&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">M11</span> <span class="o">-</span> <span class="n">M22</span>
<span class="n">M_o</span><span class="p">[</span><span class="s2">&quot;c&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">M11</span> <span class="o">+</span> <span class="n">M22</span>
<span class="k">return</span> <span class="n">eigs</span><span class="o">.</span><span class="n">min</span><span class="p">()</span></div>
<span class="k">return</span> <span class="n">M_o</span></div>
<div class="viewcode-block" id="int_de_ke">
<a class="viewcode-back" href="../../grogupy.html#grogupy.utilities.int_de_ke">[docs]</a>
<span class="k">def</span> <span class="nf">int_de_ke</span><span class="p">(</span><span class="n">traced</span><span class="p">,</span> <span class="n">we</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It numerically integrates the traced matrix.</span>
<div class="viewcode-block" id="parse_magnetic_entity">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.parse_magnetic_entity">[docs]</a>
<span class="k">def</span> <span class="nf">parse_magnetic_entity</span><span class="p">(</span><span class="n">dh</span><span class="p">,</span> <span class="n">atom</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">l</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Function to define orbital indeces of a given magnetic entity.</span>
<span class="sd"> dh: a sisl Hamiltonian object</span>
<span class="sd"> atom: an integer or list of integers, defining atom (or atoms) in the unicell forming the magnetic entity</span>
<span class="sd"> l: integer, defining the angular momentum channel</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># case where we deal with more than one atom defining the magnetic entity</span>
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">atom</span><span class="p">)</span> <span class="o">==</span> <span class="nb">list</span><span class="p">:</span>
<span class="n">dat</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">atom</span><span class="p">:</span>
<span class="n">a_orb_idx</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">a2o</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="nb">all</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span>
<span class="nb">type</span><span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="o">==</span> <span class="nb">int</span>
<span class="p">):</span> <span class="c1"># if specified we restrict to given l angular momentum channel inside each atom</span>
<span class="n">a_orb_idx</span> <span class="o">=</span> <span class="n">a_orb_idx</span><span class="p">[[</span><span class="n">o</span><span class="o">.</span><span class="n">l</span> <span class="o">==</span> <span class="n">l</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">a</span><span class="p">]</span><span class="o">.</span><span class="n">orbitals</span><span class="p">]]</span>
<span class="n">dat</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">a_orb_idx</span><span class="p">)</span>
<span class="n">orbital_indeces</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">dat</span><span class="p">)</span>
<span class="c1"># case where we deal with a singel atom magnetic entity</span>
<span class="k">elif</span> <span class="nb">type</span><span class="p">(</span><span class="n">atom</span><span class="p">)</span> <span class="o">==</span> <span class="nb">int</span><span class="p">:</span>
<span class="n">orbital_indeces</span> <span class="o">=</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">a2o</span><span class="p">(</span><span class="n">atom</span><span class="p">,</span> <span class="nb">all</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span>
<span class="nb">type</span><span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="o">==</span> <span class="nb">int</span>
<span class="p">):</span> <span class="c1"># if specified we restrict to given l angular momentum channel</span>
<span class="n">orbital_indeces</span> <span class="o">=</span> <span class="n">orbital_indeces</span><span class="p">[</span>
<span class="p">[</span><span class="n">o</span><span class="o">.</span><span class="n">l</span> <span class="o">==</span> <span class="n">l</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">dh</span><span class="o">.</span><span class="n">geometry</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atom</span><span class="p">]</span><span class="o">.</span><span class="n">orbitals</span><span class="p">]</span>
<span class="p">]</span>
<span class="k">return</span> <span class="n">orbital_indeces</span> <span class="c1"># numpy array containing integers labeling orbitals associated to a magnetic entity.</span></div>
<div class="viewcode-block" id="blow_up_orbindx">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.blow_up_orbindx">[docs]</a>
<span class="k">def</span> <span class="nf">blow_up_orbindx</span><span class="p">(</span><span class="n">orb_indices</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Function to blow up orbital indeces to make SPIN BOX indices.</span>
<span class="sd"> It is a wrapper from numpy.trapz and it contains the</span>
<span class="sd"> relevant constants to calculate the energy integral from</span>
<span class="sd"> equation 93 or 96.</span>
<span class="sd"> Args:</span>
<span class="sd"> traced : np.array_like</span>
<span class="sd"> The trace of a matrix or a matrix product</span>
<span class="sd"> we : float</span>
<span class="sd"> The weight of a point on the contour</span>
<span class="sd"> Returns:</span>
<span class="sd"> float</span>
<span class="sd"> The energy calculated from the integral formula</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">2</span> <span class="o">*</span> <span class="n">o</span><span class="p">,</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">o</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">orb_indices</span><span class="p">])</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span></div>
<div class="viewcode-block" id="calculate_exchange_tensor">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.calculate_exchange_tensor">[docs]</a>
<span class="k">def</span> <span class="nf">calculate_exchange_tensor</span><span class="p">(</span><span class="n">pair</span><span class="p">):</span>
<span class="n">o1</span><span class="p">,</span> <span class="n">o2</span><span class="p">,</span> <span class="n">o3</span> <span class="o">=</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span> <span class="c1"># o1=x, o2=y, o3=z</span>
<span class="c1"># dict(o=np.array([1, 0, 0]), vw=[np.array([0, 1, 0]), np.array([0, 0, 1])]),</span>
<span class="c1"># dict(o=np.array([0, 1, 0]), vw=[np.array([1, 0, 0]), np.array([0, 0, 1])]),</span>
<span class="c1"># dict(o=np.array([0, 0, 1]), vw=[np.array([1, 0, 0]), np.array([0, 1, 0])]),</span>
<span class="n">J_ii</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="n">o2</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">o3</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">o1</span><span class="p">[</span><span class="mi">0</span><span class="p">]])</span> <span class="c1"># xx, yy, zz</span>
<span class="n">J_S</span> <span class="o">=</span> <span class="o">-</span><span class="mf">0.5</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="n">o3</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">o3</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">o2</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">o2</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">o1</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">o1</span><span class="p">[</span><span class="mi">2</span><span class="p">]])</span> <span class="c1"># yz, zx, xy</span>
<span class="n">D</span> <span class="o">=</span> <span class="mf">0.5</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="n">o1</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">o1</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">o2</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="n">o2</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">o3</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">o3</span><span class="p">[</span><span class="mi">2</span><span class="p">]])</span> <span class="c1"># x, y, z</span>
<span class="k">return</span> <span class="n">J_ii</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span> <span class="o">/</span> <span class="mi">3</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">concatenate</span><span class="p">([</span><span class="n">J_ii</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="n">J_ii</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span> <span class="o">/</span> <span class="mi">3</span><span class="p">,</span> <span class="n">J_S</span><span class="p">])</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span></div>
<div class="viewcode-block" id="print_atomic_indices">
<a class="viewcode-back" href="../../grogu.html#grogu.useful.print_atomic_indices">[docs]</a>
<span class="k">def</span> <span class="nf">print_atomic_indices</span><span class="p">(</span><span class="n">pair</span><span class="p">,</span> <span class="n">magnetic_entities</span><span class="p">,</span> <span class="n">dh</span><span class="p">):</span>
<span class="n">atomic_indices</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="n">atoms</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;ai&quot;</span><span class="p">]]</span>
<span class="k">if</span> <span class="s2">&quot;l&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">atoms</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
<span class="n">atoms</span><span class="p">[</span><span class="s2">&quot;l&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;all&quot;</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">atoms</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">],</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">atomic_indices</span> <span class="o">+=</span> <span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;l&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="p">)</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">atoms</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">atomic_indices</span> <span class="o">+=</span> <span class="p">[</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atom</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">atom</span><span class="p">[</span><span class="s1">&#39;l&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="k">for</span> <span class="n">atom</span> <span class="ow">in</span> <span class="n">atoms</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">]</span>
<span class="p">]</span>
<span class="n">atoms</span> <span class="o">=</span> <span class="n">magnetic_entities</span><span class="p">[</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;aj&quot;</span><span class="p">]]</span>
<span class="k">if</span> <span class="s2">&quot;l&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">atoms</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
<span class="n">atoms</span><span class="p">[</span><span class="s2">&quot;l&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;all&quot;</span>
<span class="n">atomic_indices</span> <span class="o">+=</span> <span class="s2">&quot; &quot;</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">atoms</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">],</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">atomic_indices</span> <span class="o">+=</span> <span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;l&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="p">)</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">atoms</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">atomic_indices</span> <span class="o">+=</span> <span class="p">[</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">atoms</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">]</span><span class="si">{</span><span class="n">dh</span><span class="o">.</span><span class="n">atoms</span><span class="p">[</span><span class="n">atom</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">tag</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">atom</span><span class="p">[</span><span class="s1">&#39;l&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">)&quot;</span>
<span class="k">for</span> <span class="n">atom</span> <span class="ow">in</span> <span class="n">atoms</span><span class="p">[</span><span class="s2">&quot;atom&quot;</span><span class="p">]</span>
<span class="p">]</span>
<span class="n">atomic_indices</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">&quot; </span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;Ruc&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> d [Ang] Not yet.&quot;</span>
<span class="k">return</span> <span class="n">atomic_indices</span></div>
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">trapz</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">imag</span><span class="p">(</span><span class="n">traced</span> <span class="o">*</span> <span class="n">we</span><span class="p">))</span></div>
</pre></div>
@ -375,13 +434,13 @@
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, Grogu.</p>
<p>&#169; Copyright 2024, grogupy.</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>
@ -392,7 +451,7 @@
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</script>
</body>
</html>
</html>

@ -5,31 +5,33 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &mdash; Grogu 0.0.1 documentation</title>
<title>Overview: module code &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=d45e8c67"></script>
<script src="../_static/documentation_options.js?v=8d563738"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/design-tabs.js?v=f930bc37"></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="search" title="Search" href="../search.html" />
</head>
<body class="wy-body-for-nav">
<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">
Grogu
grogupy
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
@ -39,9 +41,29 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../modules.html">src</a></li>
<li class="toctree-l1"><a class="reference internal" href="../implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bibliography.html">Bibliography</a></li>
</ul>
</div>
@ -50,7 +72,7 @@
<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">Grogu</a>
<a href="../index.html">grogupy</a>
</nav>
<div class="wy-nav-content">
@ -66,9 +88,13 @@
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>All modules for which code is available</h1>
<ul><li><a href="grogu/useful.html">grogu.useful</a></li>
<ul><li><a href="grogupy/core.html">grogupy.core</a></li>
<li><a href="grogupy/grogu.html">grogupy.grogu</a></li>
<li><a href="grogupy/io.html">grogupy.io</a></li>
<li><a href="grogupy/magnetism.html">grogupy.magnetism</a></li>
<li><a href="grogupy/utilities.html">grogupy.utilities</a></li>
</ul>
</div>
@ -78,13 +104,13 @@
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, Grogu.</p>
<p>&#169; Copyright 2024, grogupy.</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>
@ -95,7 +121,7 @@
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</script>
</body>
</html>
</html>

@ -0,0 +1,4 @@
Bibliography
============
.. bibliography:: bibliography.bib

@ -0,0 +1,4 @@
Changelog
=========
Coming soon...

@ -0,0 +1,4 @@
Citing grogupy
==============
Coming soon...

@ -0,0 +1,4 @@
Contributing to grogupy
=======================
Coming soon...

@ -0,0 +1,2 @@
Environment variables
=====================

@ -0,0 +1,53 @@
grogupy package
===============
Submodules
----------
grogupy.core module
-------------------
.. automodule:: grogupy.core
:members:
:undoc-members:
:show-inheritance:
grogupy.grogu module
--------------------
.. automodule:: grogupy.grogu
:members:
:undoc-members:
:show-inheritance:
grogupy.io module
-----------------
.. automodule:: grogupy.io
:members:
:undoc-members:
:show-inheritance:
grogupy.magnetism module
------------------------
.. automodule:: grogupy.magnetism
:members:
:undoc-members:
:show-inheritance:
grogupy.utilities module
------------------------
.. automodule:: grogupy.utilities
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: grogupy
:members:
:undoc-members:
:show-inheritance:

@ -0,0 +1,11 @@
Implementation
==============
.. autosummary::
:toctree: generated
:recursive:
core
magnetism
utilities
io

@ -0,0 +1,82 @@
.. grogupy documentation master file, created by
sphinx-quickstart on Thu Oct 10 17:10:03 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. module:: grogupy
.. title:: grogupy: Script for calculating magnetic interactions
.. meta::
:description: Relativistic magnetic interactions from non-orthogonal basis sets.
:keywords: DFT, physics, grogu, magnetic interactions, Siesta
grogupy: Script for calculating magnetic interactions
=====================================================
Groupy is a generalized python script based on the Grogu matlab implementation.
More on the theoretical background can be seen `here <https://arxiv.org/abs/2309.02558>`_.
.. grid:: 1 1 2 2
:gutter: 2
.. grid-item-card:: -- Quick-start guides
:link: quickstart/index
:link-type: doc
Basic tutorial on how to use the `grogupy` script.
.. grid-item-card:: -- Implementation
:link: implementation/index
:link-type: doc
Detailed description of the implementation.
.. toctree::
:hidden:
:maxdepth: 2
:caption: Getting started
introduction
quickstart/index
cite
.. toctree::
:hidden:
:maxdepth: 2
:caption: User Guide
tutorials/index
.. toctree::
:hidden:
:maxdepth: 2
:caption: Advanced usage
implementation/index
environment
.. toctree::
:hidden:
:maxdepth: 2
:caption: Development
dev/index
.. toctree::
:hidden:
:maxdepth: 3
:caption: Extras
changelog/index
bibliography
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

@ -0,0 +1,17 @@
Introduction
============
The format of the documentation was based on and inspired by `sisl <https://sisl.readthedocs.io/en/latest/index.html>`_.
1.
2.
Package
-------
Go to :ref:`installation <quickstart>`.
Command line usage
------------------
Coming soon...

@ -1,7 +1,7 @@
src
===
grogupy
=======
.. toctree::
:maxdepth: 4
grogu
grogupy

@ -0,0 +1,21 @@
Quickstart
==========
installation
------------
.. grid:: 1 2 2 2
:gutter: 4
.. grid-item-card:: pip
:columns: 12 12 6 6
grogupy can be installed via pip from `Test PyPI <https://test.pypi.org>`_.
++++
.. code-block:: bash
python3 -m pip install --index-url https://test.pypi.org/simple/ grogupy
Coming soon...

@ -0,0 +1,4 @@
Tutorials
=========
Coming soon...

@ -0,0 +1,101 @@
// @ts-check
// Extra JS capability for selected tabs to be synced
// The selection is stored in local storage so that it persists across page loads.
/**
* @type {Record<string, HTMLElement[]>}
*/
let sd_id_to_elements = {};
const storageKeyPrefix = "sphinx-design-tab-id-";
/**
* Create a key for a tab element.
* @param {HTMLElement} el - The tab element.
* @returns {[string, string, string] | null} - The key.
*
*/
function create_key(el) {
let syncId = el.getAttribute("data-sync-id");
let syncGroup = el.getAttribute("data-sync-group");
if (!syncId || !syncGroup) return null;
return [syncGroup, syncId, syncGroup + "--" + syncId];
}
/**
* Initialize the tab selection.
*
*/
function ready() {
// Find all tabs with sync data
/** @type {string[]} */
let groups = [];
document.querySelectorAll(".sd-tab-label").forEach((label) => {
if (label instanceof HTMLElement) {
let data = create_key(label);
if (data) {
let [group, id, key] = data;
// add click event listener
// @ts-ignore
label.onclick = onSDLabelClick;
// store map of key to elements
if (!sd_id_to_elements[key]) {
sd_id_to_elements[key] = [];
}
sd_id_to_elements[key].push(label);
if (groups.indexOf(group) === -1) {
groups.push(group);
// Check if a specific tab has been selected via URL parameter
const tabParam = new URLSearchParams(window.location.search).get(
group
);
if (tabParam) {
console.log(
"sphinx-design: Selecting tab id for group '" +
group +
"' from URL parameter: " +
tabParam
);
window.sessionStorage.setItem(storageKeyPrefix + group, tabParam);
}
}
// Check is a specific tab has been selected previously
let previousId = window.sessionStorage.getItem(
storageKeyPrefix + group
);
if (previousId === id) {
// console.log(
// "sphinx-design: Selecting tab from session storage: " + id
// );
// @ts-ignore
label.previousElementSibling.checked = true;
}
}
}
});
}
/**
* Activate other tabs with the same sync id.
*
* @this {HTMLElement} - The element that was clicked.
*/
function onSDLabelClick() {
let data = create_key(this);
if (!data) return;
let [group, id, key] = data;
for (const label of sd_id_to_elements[key]) {
if (label === this) continue;
// @ts-ignore
label.previousElementSibling.checked = true;
}
window.sessionStorage.setItem(storageKeyPrefix + group, id);
}
document.addEventListener("DOMContentLoaded", ready, false);

File diff suppressed because one or more lines are too long

@ -922,4 +922,4 @@ div.math:hover a.headerlink {
#top-link {
display: none;
}
}
}

@ -1 +1 @@
.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions .rst-other-versions .rtd-current-item{font-weight:700}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}#flyout-search-form{padding:6px}
.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions .rst-other-versions .rtd-current-item{font-weight:700}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}#flyout-search-form{padding:6px}

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 433 KiB

After

Width:  |  Height:  |  Size: 434 KiB

File diff suppressed because one or more lines are too long

@ -0,0 +1,101 @@
// @ts-check
// Extra JS capability for selected tabs to be synced
// The selection is stored in local storage so that it persists across page loads.
/**
* @type {Record<string, HTMLElement[]>}
*/
let sd_id_to_elements = {};
const storageKeyPrefix = "sphinx-design-tab-id-";
/**
* Create a key for a tab element.
* @param {HTMLElement} el - The tab element.
* @returns {[string, string, string] | null} - The key.
*
*/
function create_key(el) {
let syncId = el.getAttribute("data-sync-id");
let syncGroup = el.getAttribute("data-sync-group");
if (!syncId || !syncGroup) return null;
return [syncGroup, syncId, syncGroup + "--" + syncId];
}
/**
* Initialize the tab selection.
*
*/
function ready() {
// Find all tabs with sync data
/** @type {string[]} */
let groups = [];
document.querySelectorAll(".sd-tab-label").forEach((label) => {
if (label instanceof HTMLElement) {
let data = create_key(label);
if (data) {
let [group, id, key] = data;
// add click event listener
// @ts-ignore
label.onclick = onSDLabelClick;
// store map of key to elements
if (!sd_id_to_elements[key]) {
sd_id_to_elements[key] = [];
}
sd_id_to_elements[key].push(label);
if (groups.indexOf(group) === -1) {
groups.push(group);
// Check if a specific tab has been selected via URL parameter
const tabParam = new URLSearchParams(window.location.search).get(
group
);
if (tabParam) {
console.log(
"sphinx-design: Selecting tab id for group '" +
group +
"' from URL parameter: " +
tabParam
);
window.sessionStorage.setItem(storageKeyPrefix + group, tabParam);
}
}
// Check is a specific tab has been selected previously
let previousId = window.sessionStorage.getItem(
storageKeyPrefix + group
);
if (previousId === id) {
// console.log(
// "sphinx-design: Selecting tab from session storage: " + id
// );
// @ts-ignore
label.previousElementSibling.checked = true;
}
}
}
});
}
/**
* Activate other tabs with the same sync id.
*
* @this {HTMLElement} - The element that was clicked.
*/
function onSDLabelClick() {
let data = create_key(this);
if (!data) return;
let [group, id, key] = data;
for (const label of sd_id_to_elements[key]) {
if (label === this) continue;
// @ts-ignore
label.previousElementSibling.checked = true;
}
window.sessionStorage.setItem(storageKeyPrefix + group, id);
}
document.addEventListener("DOMContentLoaded", ready, false);

@ -1,5 +1,5 @@
const DOCUMENTATION_OPTIONS = {
VERSION: '0.0.1',
VERSION: '1.0.0',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
@ -10,4 +10,4 @@ const DOCUMENTATION_OPTIONS = {
NAVIGATION_WITH_KEYS: false,
SHOW_SEARCH_SUMMARY: true,
ENABLE_SEARCH_SHORTCUTS: true,
};
};

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

@ -1 +1 @@
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}});
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}});

File diff suppressed because one or more lines are too long

@ -221,4 +221,4 @@ document.addEventListener("readthedocs-addons-data-ready", function (event) {
const event = new CustomEvent("readthedocs-search-show");
document.dispatchEvent(event);
});
});
});

Before

Width:  |  Height:  |  Size: 90 B

After

Width:  |  Height:  |  Size: 90 B

Before

Width:  |  Height:  |  Size: 90 B

After

Width:  |  Height:  |  Size: 90 B

@ -72,4 +72,4 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .vg { color: #19177C } /* Name.Variable.Global */
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
.highlight .vm { color: #19177C } /* Name.Variable.Magic */
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */

File diff suppressed because one or more lines are too long

@ -6,32 +6,34 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>asd documentation &mdash; Grogu 0.0.1 documentation</title>
<title>Bibliography &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=d45e8c67"></script>
<script src="_static/documentation_options.js?v=8d563738"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/design-tabs.js?v=f930bc37"></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="src" href="modules.html" />
<link rel="prev" title="Changelog" href="changelog/index.html" />
</head>
<body class="wy-body-for-nav">
<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="#" class="icon icon-home">
Grogu
<a href="index.html" class="icon icon-home">
grogupy
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
@ -41,9 +43,29 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="modules.html">src</a></li>
<li class="toctree-l1"><a class="reference internal" href="dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="changelog/index.html">Changelog</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Bibliography</a></li>
</ul>
</div>
@ -52,65 +74,45 @@
<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="#">Grogu</a>
<a href="index.html">grogupy</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="#" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">asd documentation</li>
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Bibliography</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
<a href="_sources/bibliography.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="asd-documentation">
<h1>asd documentation<a class="headerlink" href="#asd-documentation" title="Link to this heading"></a></h1>
<p>Add your content using <code class="docutils literal notranslate"><span class="pre">reStructuredText</span></code> syntax. See the
<a class="reference external" href="https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html">reStructuredText</a>
documentation for details.</p>
<div class="toctree-wrapper compound">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="modules.html">src</a><ul>
<li class="toctree-l2"><a class="reference internal" href="grogu.html">grogu package</a></li>
</ul>
</li>
</ul>
</div>
</section>
<section id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Link to this heading"></a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</section>
<section id="bibliography">
<h1>Bibliography<a class="headerlink" href="#bibliography" title="Link to this heading"></a></h1>
<span class="target" id="id1"></span></section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="modules.html" class="btn btn-neutral float-right" title="src" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="changelog/index.html" class="btn btn-neutral float-left" title="Changelog" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, Grogu.</p>
<p>&#169; Copyright 2024, grogupy.</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>
@ -121,7 +123,7 @@ documentation for details.</p>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</script>
</body>
</html>
</html>

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Changelog &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=8d563738"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/design-tabs.js?v=f930bc37"></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="Bibliography" href="../bibliography.html" />
<link rel="prev" title="Contributing to grogupy" href="../dev/index.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">
grogupy
</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" aria-label="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">
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bibliography.html">Bibliography</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">grogupy</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" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Changelog</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/changelog/index.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="changelog">
<h1>Changelog<a class="headerlink" href="#changelog" title="Link to this heading"></a></h1>
<p>Coming soon…</p>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="../dev/index.html" class="btn btn-neutral float-left" title="Contributing to grogupy" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="../bibliography.html" class="btn btn-neutral float-right" title="Bibliography" 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 2024, grogupy.</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>

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Citing grogupy &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=8d563738"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/design-tabs.js?v=f930bc37"></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="Tutorials" href="tutorials/index.html" />
<link rel="prev" title="Quickstart" href="quickstart/index.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">
grogupy
</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" aria-label="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">
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="implementation/index.html">Implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="bibliography.html">Bibliography</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">grogupy</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" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Citing grogupy</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/cite.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="citing-grogupy">
<h1>Citing grogupy<a class="headerlink" href="#citing-grogupy" title="Link to this heading"></a></h1>
<p>Coming soon…</p>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="quickstart/index.html" class="btn btn-neutral float-left" title="Quickstart" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="tutorials/index.html" class="btn btn-neutral float-right" title="Tutorials" 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 2024, grogupy.</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>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save