{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Impurity Solver Tutorial\n", "\n", "This tutorial goes through using the Hartree-Fock ImpuritySolver for a simple one band case. We start by importing the required modules:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Warning: could not identify MPI environment!\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Starting serial run at: 2022-05-02 14:09:51.982050\n" ] } ], "source": [ "import numpy as np\n", "from triqs.gf import *\n", "from triqs.operators import *\n", "from h5 import HDFArchive\n", "from triqs_hartree_fock import ImpuritySolver\n", "from triqs.plot.mpl_interface import oplot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we define G0, h_int, and the parameters that we will pass to the solver" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "beta = 40\n", "n_iw = 1025\n", "\n", "g0 = GfImFreq(beta=40, n_points=1025, target_shape=[1,1])\n", "g0 << inverse(iOmega_n + 2)\n", "G0 = BlockGf(name_list=['up', 'down'], block_list=[g0, g0], make_copies=True)\n", "\n", "h_int = 3*n('up', 0)*n('down', 0)\n", "\n", "gf_struct = [('up', 1), ('down', 1)]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we are ready to initialize the solver:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "S = ImpuritySolver(gf_struct=gf_struct, beta=beta, n_iw=n_iw)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we pass G0 to the solver:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Green Function G composed of 2 blocks: \n", " Greens Function G_up with mesh Matsubara Freq Mesh of size 2050, Domain: Matsubara domain with beta = 40, statistic = 1, positive_only : 0 and target_rank 2: \n", " \n", " Greens Function G_down with mesh Matsubara Freq Mesh of size 2050, Domain: Matsubara domain with beta = 40, statistic = 1, positive_only : 0 and target_rank 2: \n", " " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "S.G0_iw << G0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we are ready to call the solve method. By default with_fock is True but can be turned to False to only include Hartree terms." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "╔╦╗╦═╗╦╔═╗ ╔═╗ ┬ ┬┌─┐\n", " ║ ╠╦╝║║═╬╗╚═╗ ├─┤├┤ \n", " ╩ ╩╚═╩╚═╝╚╚═╝ ┴ ┴└ \n", "TRIQS: Hartree-Fock solver\n", "\n", "Running Impurity Solver\n", "beta = 40.0000\n", "h_int =\n", "3*c_dag('down',0)*c_dag('up',0)*c('up',0)*c('down',0)\n", "mode: self-consistent\n", "Including Fock terms:\n", "True\n", "Self Consistent Hartree-Fock converged successfully\n", "Calculated self energy:\n", "Sigma_HF['up']:\n", "[[1.9833+0.j]]\n", "Sigma_HF['down']:\n", "[[1.9833+0.j]]\n" ] } ], "source": [ "S.solve(h_int=h_int, with_fock=True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 4 }