You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

621 lines
67 KiB

<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>grogupy.io &mdash; grogupy 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />
<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=8d563738"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/design-tabs.js?v=f930bc37"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home">
grogupy
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cite.html">Citing grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Tutorials</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced usage</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/modules.html">src</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/grogupy.html">grogupy package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/environment.html">Environment variables</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Contributing to grogupy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../changelog/index.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">grogupy</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">grogupy.io</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for grogupy.io</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) [2024] []</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="c1"># in the Software without restriction, including without limitation the rights</span>
<span class="c1"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="c1"># copies of the Software, and to permit persons to whom the Software is</span>
<span class="c1"># furnished to do so, subject to the following conditions:</span>
<span class="c1">#</span>
<span class="c1"># The above copyright notice and this permission notice shall be included in all</span>
<span class="c1"># copies or substantial portions of the Software.</span>
<span class="c1">#</span>
<span class="c1"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="c1"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="c1"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<span class="c1"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="c1"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
<span class="c1"># SOFTWARE.</span>
<span class="sd">&quot;&quot;&quot;Docstring in io.</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">pickle</span> <span class="kn">import</span> <span class="n">dump</span><span class="p">,</span> <span class="n">load</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">sisl.io</span> <span class="kn">import</span> <span class="n">fdfSileSiesta</span>
<span class="c1"># list of accepted input parameters</span>
<span class="n">ACCEPTED_INPUTS</span> <span class="o">=</span> <span class="p">[</span>
<span class="s2">&quot;infile&quot;</span><span class="p">,</span>
<span class="s2">&quot;outfile&quot;</span><span class="p">,</span>
<span class="s2">&quot;scf_xcf_orientation&quot;</span><span class="p">,</span>
<span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">,</span>
<span class="s2">&quot;kset&quot;</span><span class="p">,</span>
<span class="s2">&quot;kdirs&quot;</span><span class="p">,</span>
<span class="s2">&quot;ebot&quot;</span><span class="p">,</span>
<span class="s2">&quot;eset&quot;</span><span class="p">,</span>
<span class="s2">&quot;esetp&quot;</span><span class="p">,</span>
<span class="s2">&quot;parallel_solver_for_Gk&quot;</span><span class="p">,</span>
<span class="s2">&quot;padawan_mode&quot;</span><span class="p">,</span>
<span class="p">]</span>
<span class="n">default_arguments</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span>
<span class="n">infile</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">outfile</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">scf_xcf_orientation</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span>
<span class="n">ref_xcf_orientations</span><span class="o">=</span><span class="p">[</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">o</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">vw</span><span class="o">=</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])]),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">o</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">vw</span><span class="o">=</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])]),</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">o</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span> <span class="n">vw</span><span class="o">=</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">])]),</span>
<span class="p">],</span>
<span class="n">kset</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
<span class="n">kdirs</span><span class="o">=</span><span class="s2">&quot;xyz&quot;</span><span class="p">,</span>
<span class="n">ebot</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">eset</span><span class="o">=</span><span class="mi">42</span><span class="p">,</span>
<span class="n">esetp</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span>
<span class="n">parallel_solver_for_Gk</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">padawan_mode</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<div class="viewcode-block" id="read_fdf">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.read_fdf">[docs]</a>
<span class="k">def</span> <span class="nf">read_fdf</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It reads the simulation parameters, magnetic entities and pairs from the fdf.</span>
<span class="sd"> Args:</span>
<span class="sd"> path : string</span>
<span class="sd"> The path to the .fdf file</span>
<span class="sd"> Returns:</span>
<span class="sd"> fdf_arguments : dict</span>
<span class="sd"> The read input arguments from the fdf file</span>
<span class="sd"> magnetic_entities : list</span>
<span class="sd"> It contains the dictionaries associated with the magnetic entities</span>
<span class="sd"> pairs : dict</span>
<span class="sd"> It contains the dictionaries associated with the pair information</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># read fdf file</span>
<span class="n">fdf</span> <span class="o">=</span> <span class="n">fdfSileSiesta</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">fdf_arguments</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="n">InputFile</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;InputFile&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">InputFile</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">InputFile</span>
<span class="n">OutputFile</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;OutputFile&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">OutputFile</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">OutputFile</span>
<span class="n">ScfXcfOrientation</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ScfXcfOrientation&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">ScfXcfOrientation</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;scf_xcf_orientation&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">ScfXcfOrientation</span><span class="p">)</span>
<span class="n">XCF_Rotation</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;XCF_Rotation&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">XCF_Rotation</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">rotations</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># iterate over rows</span>
<span class="k">for</span> <span class="n">rot</span> <span class="ow">in</span> <span class="n">XCF_Rotation</span><span class="p">:</span>
<span class="c1"># convert row to dictionary</span>
<span class="n">dat</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">rot</span><span class="o">.</span><span class="n">split</span><span class="p">()[:</span><span class="mi">9</span><span class="p">],</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span>
<span class="n">o</span> <span class="o">=</span> <span class="n">dat</span><span class="p">[:</span><span class="mi">3</span><span class="p">]</span>
<span class="n">vw</span> <span class="o">=</span> <span class="n">dat</span><span class="p">[</span><span class="mi">3</span><span class="p">:]</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="n">rotations</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">o</span><span class="o">=</span><span class="n">o</span><span class="p">,</span> <span class="n">vw</span><span class="o">=</span><span class="n">vw</span><span class="p">))</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">rotations</span>
<span class="n">Kset</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;INTEGRAL.Kset&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">Kset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;kset&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Kset</span>
<span class="n">Kdirs</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;INTEGRAL.Kdirs&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">Kdirs</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;kdirs&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Kdirs</span>
<span class="c1"># This is permitted because it means automatic Ebot definition</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;INTEGRAL.Ebot&quot;</span><span class="p">)</span>
<span class="n">Eset</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;INTEGRAL.Eset&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">Eset</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Eset</span>
<span class="n">Esetp</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;INTEGRAL.Esetp&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">Esetp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;esetp&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Esetp</span>
<span class="n">ParallelSolver</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;GREEN.ParallelSolver&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">ParallelSolver</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;parallel_solver_for_Gk&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ParallelSolver</span>
<span class="n">PadawanMode</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;PadawanMode&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">PadawanMode</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">fdf_arguments</span><span class="p">[</span><span class="s2">&quot;padawan_mode&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">PadawanMode</span>
<span class="n">Pairs</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;Pairs&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">Pairs</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">pairs</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># iterate over rows</span>
<span class="k">for</span> <span class="n">fdf_pair</span> <span class="ow">in</span> <span class="n">Pairs</span><span class="p">:</span>
<span class="c1"># convert data</span>
<span class="n">dat</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">fdf_pair</span><span class="o">.</span><span class="n">split</span><span class="p">()[:</span><span class="mi">5</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="c1"># create pair dictionary</span>
<span class="n">my_pair</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">ai</span><span class="o">=</span><span class="n">dat</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">aj</span><span class="o">=</span><span class="n">dat</span><span class="p">[</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="n">dat</span><span class="p">[</span><span class="mi">2</span><span class="p">:]))</span>
<span class="n">pairs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">my_pair</span><span class="p">)</span>
<span class="n">MagneticEntities</span> <span class="o">=</span> <span class="n">fdf</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;MagneticEntities&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">MagneticEntities</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">magnetic_entities</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="n">MagneticEntities</span><span class="p">:</span>
<span class="n">row</span> <span class="o">=</span> <span class="n">mag_ent</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
<span class="n">dat</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">string</span> <span class="ow">in</span> <span class="n">row</span><span class="p">:</span>
<span class="k">if</span> <span class="n">string</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
<span class="k">break</span>
<span class="n">dat</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">string</span><span class="p">)</span>
<span class="k">if</span> <span class="n">dat</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">&quot;Cluster&quot;</span><span class="p">,</span> <span class="s2">&quot;cluster&quot;</span><span class="p">}:</span>
<span class="n">magnetic_entities</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">atom</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">_</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">dat</span><span class="p">[</span><span class="mi">1</span><span class="p">:]]))</span>
<span class="k">continue</span>
<span class="k">elif</span> <span class="n">dat</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">&quot;AtomShell&quot;</span><span class="p">,</span> <span class="s2">&quot;Atomshell&quot;</span><span class="p">,</span> <span class="s2">&quot;atomShell&quot;</span><span class="p">,</span> <span class="s2">&quot;atomshell&quot;</span><span class="p">}:</span>
<span class="n">magnetic_entities</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">atom</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">l</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">_</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">dat</span><span class="p">[</span><span class="mi">2</span><span class="p">:]])</span>
<span class="p">)</span>
<span class="k">continue</span>
<span class="k">elif</span> <span class="n">dat</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">&quot;AtomOrbital&quot;</span><span class="p">,</span> <span class="s2">&quot;Atomorbital&quot;</span><span class="p">,</span> <span class="s2">&quot;tomOrbital&quot;</span><span class="p">,</span> <span class="s2">&quot;atomorbital&quot;</span><span class="p">}:</span>
<span class="n">magnetic_entities</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">atom</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">orb</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">_</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">dat</span><span class="p">[</span><span class="mi">2</span><span class="p">:]])</span>
<span class="p">)</span>
<span class="k">continue</span>
<span class="k">elif</span> <span class="n">dat</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">&quot;Orbitals&quot;</span><span class="p">,</span> <span class="s2">&quot;orbitals&quot;</span><span class="p">}:</span>
<span class="n">magnetic_entities</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">orb</span><span class="o">=</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">_</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">dat</span><span class="p">[</span><span class="mi">1</span><span class="p">:]]))</span>
<span class="k">continue</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;Unrecognizable magnetic entity in .fdf!&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">fdf_arguments</span><span class="p">,</span> <span class="n">magnetic_entities</span><span class="p">,</span> <span class="n">pairs</span></div>
<div class="viewcode-block" id="process_input_args">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.process_input_args">[docs]</a>
<span class="k">def</span> <span class="nf">process_input_args</span><span class="p">(</span>
<span class="n">default_arguments</span><span class="p">,</span>
<span class="n">fdf_arguments</span><span class="p">,</span>
<span class="n">command_line_arguments</span><span class="p">,</span>
<span class="n">accepted_inputs</span><span class="o">=</span><span class="n">ACCEPTED_INPUTS</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It returns the final simulation parameters based on the inputs.</span>
<span class="sd"> The merging is done in the order of priority:</span>
<span class="sd"> 1. command line arguments</span>
<span class="sd"> 2. fdf arguments</span>
<span class="sd"> 3. default arguments</span>
<span class="sd"> Args:</span>
<span class="sd"> default_arguments : dict</span>
<span class="sd"> Default arguments from grogupy</span>
<span class="sd"> fdf_arguments : dict</span>
<span class="sd"> Arguments read from the fdf input file</span>
<span class="sd"> command_line_arguments : dict</span>
<span class="sd"> Arguments from the command line</span>
<span class="sd"> Returns:</span>
<span class="sd"> dict</span>
<span class="sd"> The final simulation parameters</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># iterate over fdf_arguments and update default arguments</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">fdf_arguments</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
<span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">accepted_inputs</span><span class="p">:</span>
<span class="n">default_arguments</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
<span class="c1"># iterate over command_line_arguments and update default arguments</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">command_line_arguments</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
<span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">accepted_inputs</span><span class="p">:</span>
<span class="n">default_arguments</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">return</span> <span class="n">default_arguments</span></div>
<div class="viewcode-block" id="save_pickle">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.save_pickle">[docs]</a>
<span class="k">def</span> <span class="nf">save_pickle</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Saves the data in the outfile with pickle.</span>
<span class="sd"> Args:</span>
<span class="sd"> outfile : str</span>
<span class="sd"> Path to outfile</span>
<span class="sd"> data : dict</span>
<span class="sd"> Contains the data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># save dictionary</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">&quot;wb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">output_file</span><span class="p">:</span>
<span class="n">dump</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">output_file</span><span class="p">)</span></div>
<div class="viewcode-block" id="load_pickle">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.load_pickle">[docs]</a>
<span class="k">def</span> <span class="nf">load_pickle</span><span class="p">(</span><span class="n">infile</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Loads the data from the infile with pickle.</span>
<span class="sd"> Args:</span>
<span class="sd"> infile : str</span>
<span class="sd"> Path to infile</span>
<span class="sd"> Returns:</span>
<span class="sd"> data : dict</span>
<span class="sd"> A dictionary of data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># open and read file</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">infile</span><span class="p">,</span> <span class="s2">&quot;wb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">input_file</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">load</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">input_file</span><span class="p">)</span>
<span class="k">return</span> <span class="n">data</span></div>
<div class="viewcode-block" id="print_job_description">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.print_job_description">[docs]</a>
<span class="k">def</span> <span class="nf">print_job_description</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the parameters and the description of the job.</span>
<span class="sd"> Args:</span>
<span class="sd"> simulation_parameters : dict</span>
<span class="sd"> It contains the simulations parameters</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Input file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Output file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Number of nodes in the parallel cluster: &quot;</span><span class="p">,</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_size&quot;</span><span class="p">],</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_solver_for_Gk&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;solver used for Greens function calculation: parallel&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;solver used for Greens function calculation: sequential&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Cell [Ang]: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;cell&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;DFT axis: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;scf_xcf_orientation&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Quantization axis and perpendicular rotation directions:&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">ref</span> <span class="ow">in</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">ref</span><span class="p">[</span><span class="s2">&quot;o&quot;</span><span class="p">],</span> <span class="s2">&quot; --» &quot;</span><span class="p">,</span> <span class="n">ref</span><span class="p">[</span><span class="s2">&quot;vw&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Parameters for the contour integral:&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Number of k points: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;k point directions: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kdirs&quot;</span><span class="p">])</span>
<span class="k">if</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;automatic_ebot&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Ebot: &quot;</span><span class="p">,</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">],</span>
<span class="s2">&quot; WARNING: This was automatically determined!&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Ebot: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Eset: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Esetp: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;esetp&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span></div>
<div class="viewcode-block" id="print_parameters">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.print_parameters">[docs]</a>
<span class="k">def</span> <span class="nf">print_parameters</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the simulation parameters for the grogu out.</span>
<span class="sd"> Args:</span>
<span class="sd"> simulation_parameters : dict</span>
<span class="sd"> It contains the simulations parameters</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Input file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;infile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Output file: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;outfile&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Number of nodes in the parallel cluster: &quot;</span><span class="p">,</span>
<span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;parallel_size&quot;</span><span class="p">],</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Cell [Ang]: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;cell&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;DFT axis: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;scf_xcf_orientation&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Quantization axis and perpendicular rotation directions:&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">ref</span> <span class="ow">in</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ref_xcf_orientations&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">ref</span><span class="p">[</span><span class="s2">&quot;o&quot;</span><span class="p">],</span> <span class="s2">&quot; --» &quot;</span><span class="p">,</span> <span class="n">ref</span><span class="p">[</span><span class="s2">&quot;vw&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Parameters for the contour integral:&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Number of k points: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;k point directions: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;kdirs&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Ebot: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;ebot&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Eset: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;eset&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Esetp: &quot;</span><span class="p">,</span> <span class="n">simulation_parameters</span><span class="p">[</span><span class="s2">&quot;esetp&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span></div>
<div class="viewcode-block" id="print_atoms_and_pairs">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.print_atoms_and_pairs">[docs]</a>
<span class="k">def</span> <span class="nf">print_atoms_and_pairs</span><span class="p">(</span><span class="n">magnetic_entities</span><span class="p">,</span> <span class="n">pairs</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the pair and magnetic entity information for the grogu out.</span>
<span class="sd"> Args:</span>
<span class="sd"> magnetic_entities : dict</span>
<span class="sd"> It contains the data on the magnetic entities</span>
<span class="sd"> pairs : dict</span>
<span class="sd"> It contains the data on the pairs</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Atomic information: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;[atom index]Element(orbitals) x [Ang] y [Ang] z [Ang] Sx Sy Sz Q Lx Ly Lz Jx Jy Jz&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="c1"># iterate over magnetic entities</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="c1"># iterate over atoms</span>
<span class="k">for</span> <span class="n">tag</span><span class="p">,</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">],</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;xyz&quot;</span><span class="p">]):</span>
<span class="c1"># coordinates and tag</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">tag</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Anisotropy [meV]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Magnetic entity x [Ang] y [Ang] z [Ang]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="c1"># iterate over magnetic entities</span>
<span class="k">for</span> <span class="n">mag_ent</span> <span class="ow">in</span> <span class="n">magnetic_entities</span><span class="p">:</span>
<span class="c1"># iterate over atoms</span>
<span class="k">for</span> <span class="n">tag</span><span class="p">,</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;tags&quot;</span><span class="p">],</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;xyz&quot;</span><span class="p">]):</span>
<span class="c1"># coordinates and tag</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">tag</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">xyz</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Consistency check: &quot;</span><span class="p">,</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;K_consistency&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Anisotropy diag: &quot;</span><span class="p">,</span> <span class="n">mag_ent</span><span class="p">[</span><span class="s2">&quot;K&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Exchange [meV]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Magnetic entity1 Magnetic entity2 [i j k] d [Ang]&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="c1"># iterate over pairs</span>
<span class="k">for</span> <span class="n">pair</span> <span class="ow">in</span> <span class="n">pairs</span><span class="p">:</span>
<span class="c1"># print pair parameters</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;tags&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;tags&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;Ruc&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> d [Ang] </span><span class="si">{</span><span class="n">pair</span><span class="p">[</span><span class="s1">&#39;dist&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span>
<span class="c1"># print magnetic parameters</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Isotropic: &quot;</span><span class="p">,</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J_iso&quot;</span><span class="p">],</span> <span class="s2">&quot; # Tr[J] / 3&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;DMI: &quot;</span><span class="p">,</span> <span class="n">pair</span><span class="p">[</span><span class="s2">&quot;D&quot;</span><span class="p">],</span> <span class="s2">&quot; # Dx, Dy, Dz&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;Symmetric-anisotropy: &quot;</span><span class="p">,</span>
<span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J_S&quot;</span><span class="p">],</span>
<span class="s2">&quot; # J_S = J - J_iso * I &gt; Jxx, Jyy, Jxy, Jxz, Jyz&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;J: # Jxx, Jxy, Jxz, Jyx, Jyy, Jyz, Jzx, Jzy, Jzz&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">pair</span><span class="p">[</span><span class="s2">&quot;J&quot;</span><span class="p">])</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;================================================================================================================================================================&quot;</span>
<span class="p">)</span></div>
<div class="viewcode-block" id="print_runtime_information">
<a class="viewcode-back" href="../../implementation/grogupy.html#grogupy.io.print_runtime_information">[docs]</a>
<span class="k">def</span> <span class="nf">print_runtime_information</span><span class="p">(</span><span class="n">times</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;It prints the runtime information for the grogu out.</span>
<span class="sd"> Args:</span>
<span class="sd"> times : dict</span>
<span class="sd"> It contains the runtime data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Runtime information: &quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Total runtime: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;end_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;start_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;----------------------------------------------------------------------------------------------------------------------------------------------------------------&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Initial setup: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;setup_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;start_time&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> s&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Hamiltonian conversion and XC field extraction: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;H_and_XCF_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;setup_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Pair and site datastructure creatrions: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;site_and_pair_dictionaries_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;H_and_XCF_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;k set cration and distribution: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;k_set_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;site_and_pair_dictionaries_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Rotating XC potential: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;reference_rotations_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;k_set_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Greens function inversion: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;green_function_inversion_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;reference_rotations_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Calculate energies and magnetic components: </span><span class="si">{</span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;end_time&#39;</span><span class="p">]</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">times</span><span class="p">[</span><span class="s1">&#39;green_function_inversion_time&#39;</span><span class="p">]</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2"> s&quot;</span>
<span class="p">)</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2024, grogupy.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>