Compare commits
3 Commits
b6767c68d1
...
38a3be0558
Author | SHA1 | Date |
---|---|---|
Daniel Pozsar | 38a3be0558 | 2 months ago |
Daniel Pozsar | f4b9fb062f | 2 months ago |
Daniel Pozsar | 423ead86f5 | 2 months ago |
@ -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
|
@ -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 — 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 "Software"), 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 "AS IS", 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">"""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's function at a given k point</span>
|
||||
<span class="sd"> """</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">"""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's function at a given k point</span>
|
||||
<span class="sd"> """</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">"complex128"</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">"""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"> """</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">"""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"> """</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">"Gij"</span><span class="p">]</span>
|
||||
<span class="k">del</span> <span class="n">pair</span><span class="p">[</span><span class="s2">"Gij_tmp"</span><span class="p">]</span>
|
||||
<span class="k">del</span> <span class="n">pair</span><span class="p">[</span><span class="s2">"Gji"</span><span class="p">]</span>
|
||||
<span class="k">del</span> <span class="n">pair</span><span class="p">[</span><span class="s2">"Gji_tmp"</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">"Gii"</span><span class="p">]</span>
|
||||
<span class="k">del</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">"Gii_tmp"</span><span class="p">]</span>
|
||||
<span class="k">del</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">"Vu1"</span><span class="p">]</span>
|
||||
<span class="k">del</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">"Vu2"</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">"""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"> """</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">"complex128"</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">"complex128"</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">"complex128"</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">"complex128"</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">"complex128"</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 => 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 => 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">"""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"> """</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">"orbital_indices"</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">"spin_box_indices"</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">"l"</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">"l"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"all"</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">"atom"</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">"tags"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="sa">f</span><span class="s2">"[</span><span class="si">{</span><span class="n">mag_ent</span><span class="p">[</span><span class="s1">'atom'</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">'atom'</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">'l'</span><span class="p">]</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="p">]</span>
|
||||
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">"xyz"</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">"atom"</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">"atom"</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">"tags"</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">"xyz"</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">"atom"</span><span class="p">]:</span>
|
||||
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">"tags"</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">"[</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">'l'</span><span class="p">]</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">"xyz"</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">"spin_box_indices"</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">"energies"</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">"Vu1"</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">"Vu2"</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">"Gii"</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">"Gii_tmp"</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">"ref_xcf_orientations"</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">"Vu1"</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">"Vu2"</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">"Gii"</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">"eset"</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">"complex128"</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">"Gii_tmp"</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">"eset"</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">"complex128"</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">"ai"</span><span class="p">]][</span><span class="s2">"xyz"</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">"aj"</span><span class="p">]][</span><span class="s2">"xyz"</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">"Ruc"</span><span class="p">]</span> <span class="o">@</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">"cell"</span><span class="p">]</span>
|
||||
<span class="n">pair</span><span class="p">[</span><span class="s2">"dist"</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">"ai"</span><span class="p">]][</span><span class="s2">"spin_box_indices"</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">"aj"</span><span class="p">]][</span><span class="s2">"spin_box_indices"</span><span class="p">])</span>
|
||||
<span class="c1"># tag generation</span>
|
||||
<span class="n">pair</span><span class="p">[</span><span class="s2">"tags"</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">"ai"</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">"aj"</span><span class="p">]]]:</span>
|
||||
<span class="n">tag</span> <span class="o">=</span> <span class="s2">""</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">"atom"</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">"l"</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">"[</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">)"</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">"{"</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">"[</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">)--"</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">"}"</span>
|
||||
<span class="n">pair</span><span class="p">[</span><span class="s2">"tags"</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">"energies"</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">"Gij"</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">"Gji"</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">"Gij_tmp"</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">"Gji_tmp"</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">"ref_xcf_orientations"</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">"Gij"</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">"eset"</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">"complex128"</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">"Gij_tmp"</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">"eset"</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">"complex128"</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">"Gji"</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">"eset"</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">"complex128"</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">"Gji_tmp"</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">"eset"</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">"complex128"</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">"""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"> """</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>© 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 — 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 "Software"), 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 "AS IS", 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">"user_api"</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">"Warning: threadpoolctl could not make numpy use single thread!"</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">"Please install tqdm for nice progress bar."</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">"start_time"</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">"/Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf"</span>
|
||||
<span class="n">outfile</span> <span class="o">=</span> <span class="s2">"./Fe3GeTe2_notebook"</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">"infile"</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">"outfile"</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">"kset"</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">"kdirs"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"xy"</span>
|
||||
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">"eset"</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">"esetp"</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">"parallel_size"</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">"sisl version: "</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">"sisl version unknown."</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">"numpy version: "</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">"numpy version unknown."</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">"outfile"</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".pickle"</span><span class="p">):</span>
|
||||
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">"outfile"</span><span class="p">]</span> <span class="o">+=</span> <span class="s2">".pickle"</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">"ebot"</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">"infile"</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">"EIG"</span>
|
||||
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">"ebot"</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">"automatic_ebot"</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">"Could not determine ebot."</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"Parameter was not given and .EIG file was not found."</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">"automatic_ebot"</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">"infile"</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">"cell"</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">"</span><span class="se">\n\n\n\n\n</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"#################################################################### JOB INFORMATION ###########################################################################"</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">"################################################################################################################################################################"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\n\n\n\n\n</span><span class="s2">"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">times</span><span class="p">[</span><span class="s2">"setup_time"</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">"Setup done. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">'setup_time'</span><span class="p">]</span><span class="si">}</span><span class="s2"> s"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"================================================================================================================================================================"</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">"x"</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">"y"</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">"z"</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">"c"</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">></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">"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">"</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">"H_and_XCF_time"</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">"Hamiltonian and exchange field rotated. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">'H_and_XCF_time'</span><span class="p">]</span><span class="si">}</span><span class="s2"> s"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"================================================================================================================================================================"</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">"site_and_pair_dictionaries_time"</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">"Site and pair dictionaries created. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">'site_and_pair_dictionaries_time'</span><span class="p">]</span><span class="si">}</span><span class="s2"> s"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"================================================================================================================================================================"</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">"kdirs"</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">"kset"</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">"k loop"</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">"k_set_time"</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">"k set created. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">'k_set_time'</span><span class="p">]</span><span class="si">}</span><span class="s2"> s"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"================================================================================================================================================================"</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">"ref_xcf_orientations"</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">"scf_xcf_orientation"</span><span class="p">],</span> <span class="n">orient</span><span class="p">[</span><span class="s2">"o"</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">"ij,jklm->iklm"</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">"o"</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">"vw"</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">"spin_box_indices"</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">"Vu1"</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">"Vu2"</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">"reference_rotations_time"</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">"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">'reference_rotations_time'</span><span class="p">]</span><span class="si">}</span><span class="s2"> s"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"================================================================================================================================================================"</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">"Starting matrix inversions."</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">"padawan_mode"</span><span class="p">]:</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"Padawan mode: "</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"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">"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"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">'eset'</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"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">"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"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">'eset'</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"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">"</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">"H"</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">"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">'H'</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"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"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"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"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">'eset'</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"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"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">'eset'</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"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"================================================================================================================================================================"</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">"ebot"</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">"eset"</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">"esetp"</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">"H"</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">"parallel_solver_for_Gk"</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">"eset"</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">"eset"</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">"spin_box_indices"</span><span class="p">]</span>
|
||||
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">"Gii_tmp"</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">"Ruc"</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">"ai"</span><span class="p">]][</span><span class="s2">"spin_box_indices"</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">"aj"</span><span class="p">]][</span><span class="s2">"spin_box_indices"</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">"Gij_tmp"</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">"Gji_tmp"</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">"Gii_tmp"</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">"Gii"</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">"Gij_tmp"</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">"Gij"</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">"Gji_tmp"</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">"Gji"</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">"green_function_inversion_time"</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">"Calculated Greens functions. Elapsed time: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">'green_function_inversion_time'</span><span class="p">]</span><span class="si">}</span><span class="s2"> s"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"================================================================================================================================================================"</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">"Gii"</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">"Vu1"</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">"Vu2"</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">"energies"</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">"energies"</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">"energies"</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">"Gij"</span><span class="p">],</span> <span class="n">pair</span><span class="p">[</span><span class="s2">"Gji"</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">"ai"</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">"aj"</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">"Vu1"</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">"Vu1"</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">"energies"</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">"energies"</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">"energies"</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">"K"</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">"eV"</span><span class="p">,</span> <span class="s2">"meV"</span><span class="p">)</span>
|
||||
<span class="n">mag_ent</span><span class="p">[</span><span class="s2">"K_consistency"</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">"J_iso"</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">"eV"</span><span class="p">,</span> <span class="s2">"meV"</span><span class="p">)</span>
|
||||
<span class="n">pair</span><span class="p">[</span><span class="s2">"J_S"</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">"eV"</span><span class="p">,</span> <span class="s2">"meV"</span><span class="p">)</span>
|
||||
<span class="n">pair</span><span class="p">[</span><span class="s2">"D"</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">"eV"</span><span class="p">,</span> <span class="s2">"meV"</span><span class="p">)</span>
|
||||
<span class="n">pair</span><span class="p">[</span><span class="s2">"J"</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">"eV"</span><span class="p">,</span> <span class="s2">"meV"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">times</span><span class="p">[</span><span class="s2">"end_time"</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">"</span><span class="se">\n\n\n\n\n</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="nb">print</span><span class="p">(</span>
|
||||
<span class="s2">"##################################################################### GROGU OUTPUT #############################################################################"</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">"################################################################################################################################################################"</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">""</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">"outfile"</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">"</span><span class="se">\n\n\n\n\n</span><span class="s2">"</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
|
||||
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">"__main__"</span><span class="p">:</span>
|
||||
<span class="n">main</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© 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,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);
|
Before Width: | Height: | Size: 433 KiB After Width: | Height: | Size: 434 KiB |
@ -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',
|
Before Width: | Height: | Size: 286 B After Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
@ -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 — 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>© 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 — 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>© 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>
|