Skip to content

Commit

Permalink
build based on fa480b1
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Nov 28, 2024
1 parent 0c402cb commit d19e326
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 77 deletions.
2 changes: 1 addition & 1 deletion dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-28T10:38:06","documenter_version":"1.8.0"}}
{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-28T16:36:29","documenter_version":"1.8.0"}}
7 changes: 4 additions & 3 deletions dev/advanced/meanfield/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
julia&gt; h = lat |&gt; hamiltonian(model_0 + model_1 + model_2)</code></pre><p>Here <code>model_1</code> corresponds to Hartree and onsite-Fock mean field terms, while <code>model_2</code> corresponds to inter-site Fock terms. The default value <code>Φ = zerofield</code> is an singleton object that represents no interactions, so <code>model_1</code> and <code>model_2</code> vanish by default.</p><ul><li><p>We build the <code>GreenFunction</code> of <code>h</code> with <code>g = greenfunction(h, solver; kw...)</code> using the <code>GreenSolver</code> of choice</p></li><li><p>We construct a <code>M::MeanField</code> object using <code>M = meanfield(g; potential = pot, other_options...)</code></p><p>Here <code>pot(r)</code> is the charge-charge interaction potential between electrons. We can also specify <code>hopselector</code> directives to define which sites interacts, adding e.g. <code>selector = (; range = 2)</code> to <code>other_options</code>, to make sites at distance <code>2</code> interacting. See <code>meanfield</code> docstring for further details.</p></li><li><p>We evaluate this <code>M</code> with <code>Φ0 = M(µ, kBT; params...)</code>.</p><p>This computes the density matrix at specific chemical potential <code>µ</code> and temperature <code>kBT</code>, and for specific parameters of <code>h</code> (possibly including <code>Φ</code>). Then it computes the appropriate Hartree and Fock terms, and stores them in the returned <code>Φ0::OrbitalSliceMatrix</code>, where <code>Φ0ᵢⱼ = δᵢⱼ hartreeᵢ + fockᵢⱼ</code>. In normal systems, these terms read</p><p><span>$\text{hartree}_i = Q \sum_k v_H(r_i-r_k) \text{tr}(\rho_{kk}Q)$</span></p><p><span>$\text{fock}_{ij} = -v_F(r_i-r_j) Q \rho_{ij} Q$</span></p><p>where <code>v_H</code> and <code>v_F</code> are Hartree and Fock charge-charge interaction potentials (by default equal to <code>pot</code>), and the charge operator is <code>Q</code> (equal to the identity by default, but can be changed to implement e.g. spin-spin interactions).</p><p>When computing <code>Φ0</code> we don&#39;t specify <code>Φ</code> in <code>params</code>, so that <code>Φ0</code> is evaluated using the non-interacting model, hence its name.</p></li><li><p>The self-consistent condition can be tackled naively by iteration-until-convergence,</p></li></ul><pre><code class="language-julia hljs">Φ0 = M(µ, kBT; params...)
Φ1 = M(µ, KBT; Φ = Φ0, params...)
Φ2 = M(µ, KBT; Φ = Φ1, params...)
...</code></pre><p>A converged solution <code>Φ</code>, if found, should satisfy the fixed-point condition</p><pre><code class="nohighlight hljs">Φ_sol ≈ M(µ, KBT; Φ = Φ_sol, params...)</code></pre><p>Then, the self-consistent Hamiltonian is given by <code>h(; Φ = Φ_sol, params...)</code>.</p><p>The key problem is to actually find the fixed point of the <code>M</code> function. The naive iteration above is not optimal, and often does not converge. To do a better job we should use a dedicated fixed-point solver.</p><h2 id="Using-an-external-fixed-point-solver"><a class="docs-heading-anchor" href="#Using-an-external-fixed-point-solver">Using an external fixed-point solver</a><a id="Using-an-external-fixed-point-solver-1"></a><a class="docs-heading-anchor-permalink" href="#Using-an-external-fixed-point-solver" title="Permalink"></a></h2><p>We now show how to approach such a fixed-point problem. We will employ an external library to solve generic fixed-point problems, and show how to make it work with Quantica <code>MeanField</code> objects efficiently. Many generic fixed-point solver backends exist. Here we use the SIAMFANLEquations.jl package. It provides a simple utility <code>aasol(f, x0)</code> that computes the solution of <code>f(x) = x</code> with initial condition <code>x0</code> using Anderson acceleration. This is an example of how it works to compute the fixed point of function <code>f(x) = 1 + atan(x)</code></p><pre><code class="language-julia hljs">julia&gt; using SIAMFANLEquations
...</code></pre><p>A converged solution <code>Φ</code>, if found, should satisfy the fixed-point condition</p><pre><code class="nohighlight hljs">Φ_sol ≈ M(µ, KBT; Φ = Φ_sol, params...)</code></pre><p>Then, the self-consistent Hamiltonian is given by <code>h(; Φ = Φ_sol, params...)</code>.</p><p>The key problem is to actually find the fixed point of the <code>M</code> function. The naive iteration above is not optimal, and often does not converge. To do a better job we should use a dedicated fixed-point solver.</p><div class="admonition is-info"><header class="admonition-header">Superconducting systems</header><div class="admonition-body"><p>Superconducting (Nambu) Hamiltonians obey the same equations for the Hartree and Fock mean fields, with a proper definition of <code>Q</code>, and an extra <code>1/2</code> coefficient in the Hartree trace, see the <code>meanfield</code> doctring.</p></div></div><h2 id="Using-an-external-fixed-point-solver"><a class="docs-heading-anchor" href="#Using-an-external-fixed-point-solver">Using an external fixed-point solver</a><a id="Using-an-external-fixed-point-solver-1"></a><a class="docs-heading-anchor-permalink" href="#Using-an-external-fixed-point-solver" title="Permalink"></a></h2><p>We now show how to approach such a fixed-point problem. We will employ an external library to solve generic fixed-point problems, and show how to make it work with Quantica <code>MeanField</code> objects efficiently. Many generic fixed-point solver backends exist. Here we use the SIAMFANLEquations.jl package. It provides a simple utility <code>aasol(f, x0)</code> that computes the solution of <code>f(x) = x</code> with initial condition <code>x0</code> using Anderson acceleration. This is an example of how it works to compute the fixed point of function <code>f(x) = 1 + atan(x)</code></p><pre><code class="language-julia hljs">julia&gt; using SIAMFANLEquations

julia&gt; f!(x, x0) = (x .= 1 .+ atan.(x0))

Expand All @@ -23,10 +23,11 @@
julia&gt; h = LP.linear() |&gt; supercell(4) |&gt; onsite(r-&gt;r[1]) - hopping(1) + @onsite((i; phi = zerofield) --&gt; phi[i]);

julia&gt; M = meanfield(greenfunction(h); onsite = 1, selector = (; range = 0), fock = nothing)
MeanField{ComplexF64} : builder of Hartree-Fock mean fields
MeanField{ComplexF64} : builder of Hartree-Fock-Bogoliubov mean fields
Charge type : scalar (ComplexF64)
Hartree pairs : 4
Mean field pairs : 4
Nambu : false

julia&gt; Φ0 = M(0.0, 0.0);

Expand Down Expand Up @@ -80,4 +81,4 @@
0.15596283661234628 + 0.0im
0.34403716338765444 + 0.0im
0.34403716338765344 + 0.0im
0.15596283661234572 + 0.0im</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../serializers/">« Serializers</a><a class="docs-footer-nextpage" href="../wannier90/">Wannier90 imports »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Thursday 28 November 2024 10:38">Thursday 28 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
0.15596283661234572 + 0.0im</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../serializers/">« Serializers</a><a class="docs-footer-nextpage" href="../wannier90/">Wannier90 imports »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Thursday 28 November 2024 16:36">Thursday 28 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2 changes: 1 addition & 1 deletion dev/advanced/nonspatial/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
2.1382+0.0im -1.0+0.0im ⋅ ⋅
-1.0+0.0im 2.3618+0.0im -1.0+0.0im ⋅
⋅ -1.0+0.0im 2.3618+0.0im -1.0+0.0im
⋅ ⋅ -1.0+0.0im 2.1382+0.0im</code></pre><p>Note the <code>ρ[i]</code> above. This indexes <code>ρ</code> at site <code>i</code>. For a multiorbital hamiltonian, this will be a matrix (the local density matrix on each site <code>i</code>). Here it is just a number, either <code>0.138197</code> (sites 1 and 4) or <code>0.361803</code> (sites 2 and 3).</p><div class="admonition is-success"><header class="admonition-header">Sparse vs dense</header><div class="admonition-body"><p>The method explained above to build a Hamiltonian <code></code> using <code>--&gt;</code> supports all the <code>SiteSelector</code> and <code>HopSelector</code> functionality of conventional models. Therefore, although the density matrix computed above is dense, its application to the Hamiltonian is sparse: it only touches the onsite matrix elements in this case.</p></div></div></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../tutorial/observables/">« Observables</a><a class="docs-footer-nextpage" href="../serializers/">Serializers »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Thursday 28 November 2024 10:38">Thursday 28 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
⋅ ⋅ -1.0+0.0im 2.1382+0.0im</code></pre><p>Note the <code>ρ[i]</code> above. This indexes <code>ρ</code> at site <code>i</code>. For a multiorbital hamiltonian, this will be a matrix (the local density matrix on each site <code>i</code>). Here it is just a number, either <code>0.138197</code> (sites 1 and 4) or <code>0.361803</code> (sites 2 and 3).</p><div class="admonition is-success"><header class="admonition-header">Sparse vs dense</header><div class="admonition-body"><p>The method explained above to build a Hamiltonian <code></code> using <code>--&gt;</code> supports all the <code>SiteSelector</code> and <code>HopSelector</code> functionality of conventional models. Therefore, although the density matrix computed above is dense, its application to the Hamiltonian is sparse: it only touches the onsite matrix elements in this case.</p></div></div></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../tutorial/observables/">« Observables</a><a class="docs-footer-nextpage" href="../serializers/">Serializers »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Thursday 28 November 2024 16:36">Thursday 28 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2 changes: 1 addition & 1 deletion dev/advanced/serializers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
true

julia&gt; @btime deserialize!($as, serialize!($v, $as));
149.737 ns (0 allocations: 0 bytes)</code></pre><p>It also allows powerful compression into relevant degrees of freedom through appropriate use of encoders/decoders, see the <code>serializer</code> docstring.</p><h2 id="Serializers-of-OrbitalSliceArrays"><a class="docs-heading-anchor" href="#Serializers-of-OrbitalSliceArrays">Serializers of OrbitalSliceArrays</a><a id="Serializers-of-OrbitalSliceArrays-1"></a><a class="docs-heading-anchor-permalink" href="#Serializers-of-OrbitalSliceArrays" title="Permalink"></a></h2><p>Serialization of <code>OrbitalSliceArray</code>s is simpler than for <code>AbstractHamiltonians</code>, as there is no need for an intermediate <code>Serializer</code> object. To serialize an <code>m::OrbitalSliceArray</code> simply do <code>v = serialize(m)</code>. To deserialize, just do <code>m´ = deserialize(m, v)</code>.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../nonspatial/">« Non-spatial models</a><a class="docs-footer-nextpage" href="../meanfield/">Self-consistent mean fields »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Thursday 28 November 2024 10:38">Thursday 28 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
149.737 ns (0 allocations: 0 bytes)</code></pre><p>It also allows powerful compression into relevant degrees of freedom through appropriate use of encoders/decoders, see the <code>serializer</code> docstring.</p><h2 id="Serializers-of-OrbitalSliceArrays"><a class="docs-heading-anchor" href="#Serializers-of-OrbitalSliceArrays">Serializers of OrbitalSliceArrays</a><a id="Serializers-of-OrbitalSliceArrays-1"></a><a class="docs-heading-anchor-permalink" href="#Serializers-of-OrbitalSliceArrays" title="Permalink"></a></h2><p>Serialization of <code>OrbitalSliceArray</code>s is simpler than for <code>AbstractHamiltonians</code>, as there is no need for an intermediate <code>Serializer</code> object. To serialize an <code>m::OrbitalSliceArray</code> simply do <code>v = serialize(m)</code>. To deserialize, just do <code>m´ = deserialize(m, v)</code>.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../nonspatial/">« Non-spatial models</a><a class="docs-footer-nextpage" href="../meanfield/">Self-consistent mean fields »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.8.0 on <span class="colophon-date" title="Thursday 28 November 2024 16:36">Thursday 28 November 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit d19e326

Please sign in to comment.