" ] }, { "cell_type": "markdown", "id": "a938bb8e", "metadata": {}, "source": [ "**Purpose**: In this tutorial, you will learn how calculate the absorption spectrum of diamond on using **fastBSE** within exciting.\n", "\n", "

" ] }, { "cell_type": "markdown", "id": "c76ca71f", "metadata": {}, "source": [ "

\n",
" \n",
"**Table of Contents**\n",
"\n",
"[0. Preparation](#0)\n",
" \n",
"[1. Introduction](#1)\n",
" \n",
"[2. Theory](#1)\n",
" \n",
"[3. Calculations](#2)\n",
" \n",
"[3.1 Groundstate and Screening](#2.1)\n",
" \n",
"[3.2 Direct BSE](#2.2)\n",
" \n",
"[3.3 fastBSE](#2.3)\n",
" \n",
"[4. Compare the results](#3)\n",
" \n",
"\n",
"

"
]
},
{
"cell_type": "markdown",
"id": "9542538e",
"metadata": {},
"source": [
"\n",
"\n", "\n", "### 0. Preparation\n", "\n", "**Read the following paragraph before starting with the rest of this tutorial!**\n", "\n", "Before running any Jupyter tutorials, please refer to the **`00_before_starting.md`** document on how to correctly set up the environment. This only needs to be done once. After which, the **venv** can be (re)activated from **exciting**'s root directory:\n", "\n", "

\n",
"\n",
"```bash\n",
"source tools/excitingjupyter/venv/excitingvenv/bin/activate\n",
"```\n",
"\n",
"

\n",
"\n",
"\n",
"**Important note:** \n",
"\n",
"- All input parameters that will appear will be given in **atomic units**!\n",
"- For running **fastBSE** calculations, you need to link exciting to **HDF5** and **FFTW3**\n"
]
},
{
"cell_type": "markdown",
"id": "8ebd2fcd",
"metadata": {},
"source": [
"\n",
"\n", "\n", "### 1. Introduction\n", "\n", "In this tutorial you will learn how to calculate the optical absorption spectrum of with the **fastBSE** algorithm. To demonstrate that the results of the new method are equivalent to the old one, you will also calculate the spectrum with the **direct** algorithm. If you are not familiar how this is done, begin with the tutorial **Excited states from BSE**.\n", "\n", "**fastBSE** is low scaling, matrix-free, iterative algorithm to solve the Bethe-Salpeter equation (**BSE**). It scales with $\\mathcal O(N_v N_c(1 + \\log N_k))$. This is massive speed up compared to the **direct** algorithm that scales with $\\mathcal O(N_v^3 N_c^3 N_k^3)$.\n", "\n", "The **fastBSE** algorithm was published by **[Henneke and collegues](https://msp.org/camcos/2020/15-1/p04.xhtml)**." ] }, { "cell_type": "markdown", "id": "b15ca8fd", "metadata": {}, "source": [ "

\n", "\n", "### 2. Theory\n", "\n", "In this tutorial, we only consider the **Tamm-Dancoff-approximation** (**TDA**) and neglect the coupling between the resonant and anti-resonant components of the **Bethe-Salpeter Hamiltonian** (**BSH**). We also neglect finite momentum transitions, such that $\\mathbf{q} = \\mathbf{0}$.\n", "\n", "The heavy lifting of solving the **BSE** involves setting up and diagonalizing the **BSH**:\n", "\n", "$$\n", "H^{BSE} = D + 2V - W,\n", "$$\n", "\n", "where $D$ represents the diagonal part, accounting for the single electron properties; $V$ is the repulsive, long-range exchange interaction; and $W$ is the attractive screened interaction. To map the problem to linear algebra, we expand the exciton wave function in the two-particle basis:\n", "\n", "$$\n", "\\Phi^\\lambda(\\mathbf{r}, \\mathbf{r'}) = \\sum_{vck} C^\\lambda_{vck} \\psi_{vk}(\\mathbf{r}) \\psi^*_{ck}(\\mathbf{r'}),\n", "$$\n", "\n", "where $\\psi_{ik}(\\mathbf{r})$ is a single-electron wave function of band $i$ at $\\mathbf{r}$ and the $k$'th Brillouin zone (BZ) vector. The indices $v$ and $c$ refer to valence and conduction bands, respectively, and $\\lambda$ is the index of the exciton. Thus, the diagonalization can be rewritten as the following eigenvalue problem:\n", "\n", "$$\n", "H^{BSE}|\\Phi_\\lambda\\rangle = E^\\lambda |\\Phi_\\lambda\\rangle,\n", "$$\n", "\n", "In this expansion, the diagonal part is given by\n", "\n", "$$\n", "D_{vck, v'c'k'} = \\big(\\epsilon_{ck} - \\epsilon_{vk}\\big) \\delta_{cc'} \\delta_{vv'} \\delta_{kk'},\n", "$$\n", "\n", "the exchange interaction kernel by\n", "\n", "$$\n", "V_{vck, v'c'k'} = \\int d^3r \\int d^3 r' \\frac{ u^*_{v'k'}(\\mathbf{r'})u_{c'k'}(\\mathbf{r'})u^*_{ck}(\\mathbf{r})u_{vk}(\\mathbf{r}) } {| \\mathbf{r - r'} |},\n", "$$\n", "\n", "and the screened interaction kernel by\n", "\n", "$$\n", "W_{vck, v'c'k'} = \\int d^3r \\int d^3 r' u^*_{v'k'}(\\mathbf{r'})u_{vk}(\\mathbf{r'}) W(\\mathbf{r, r'})_{\\mathbf{k-k'}} u^*_{ck}(\\mathbf{r})u_{c'k'}(\\mathbf{r}).\n", "$$\n", "\n", "Here, it is taken into account that for periodic materials, the wave functions are Bloch waves and can be written as\n", "\n", "$$\n", "\\psi_{ik}(\\mathbf{r}) = u_{ik}(\\mathbf{r}) \\cdot e^{i\\mathbf{r} \\mathbf{k}},\n", "$$\n", "\n", "where $u_{ik}(\\mathbf{r})$ is the periodic part of the wave functions.\n", "\n", "In total, this results in a matrix with $(N_v N_c N_k)^2$ elements. Solving the **BSE** **directly** means calculating the full matrix and diagonalizing it. This scales with $\\mathcal{O}\\big((N_v N_c N_k)^3\\big)$. For many problems, a converged solution of the **BSE** cannot be calculated with reasonable resources." ] }, { "cell_type": "markdown", "id": "c4bb1afc", "metadata": {}, "source": [ "The **fastBSE** algorithm avoids calculating the full matrix by employing **interpolative separable density fitting** (**ISDF**) to approximate the wavefunction products as $u_{ik}(\\mathbf{r})u^*_{jk}(\\mathbf{r})$ in the formulas for the integrals:\n", "\n", "$$\n", "u_{ik}^*(\\mathbf{r})u_{jk'}(\\mathbf{r}) \\approx \\sum_{\\mu=1}^{N_\\mu} \\zeta_\\mu(\\mathbf{r}) u_{ik}^*(\\mathbf{r}_\\mu) u_{jk}(\\mathbf{r}_\\mu).\n", "$$\n", "\n", "When discretized on a real-space grid, $\\{\\mathbf{r}_i\\}_{i=1}^{N_r}$, $u_{ik}^*(\\mathbf{r})u_{jk'}(\\mathbf{r})$ can be seen as a matrix $Z \\in \\mathbb{C}^{N_r \\times N_iN_jN_k^2}$, where $N_i$ and $N_j$ represent the number of bands of $u_{ik}$ and $u_{jk'}$, respectively, to be combined. Therefore, for a given $\\mathbf{r}$, $u_{ik}(\\mathbf{r})^*u_{jk}(\\mathbf{r})$ can be viewed as a row vector of size $N_iN_jN_k^2$. The ISDF approximates all such rows as a linear combination of matrix rows with respect to a selected set of rows or interpolation points, and then it interpolates on a sub-grid $\\{\\mathbf{r}_\\mu\\}_{\\mu=1}^{N_\\mu} \\subseteq \\{\\mathbf{r}_i\\}_{i=1}^{N_r}$ with typically $N_\\mu \\ll N_r$. Similarly, we can represent the interpolation coefficients $\\zeta_\\mu(\\mathbf{r})$ in a matrix $\\Theta \\in \\mathbb{C}^{N_r \\times N_\\mu}$ and the interpolation rows $u_{ik}(\\mathbf{r})u_{jk'}(\\mathbf{r})$ in a matrix $C \\in \\mathbb{C}^{N_\\mu \\times N_iN_jN_k^2}$. Using linear algebra notation, we can express the approximation as:\n", "\n", "$$\n", "Z \\approx \\Theta C.\n", "$$\n", "\n", "In terms of the interpolation coefficients $\\Theta$, this equation becomes an over-determined linear system and can be solved using the least squares approximation:\n", "\n", "$$\n", "\\Theta = ZC^* (CC^*)^{-1}.\n", "$$\n", "\n", "Due to the tensor structure of $Z$ and $C$, the operations $ZC^*$ and $CC^*$ can be computed efficiently. The overall cost of evaluating $\\Theta$ is bounded by $\\mathcal{O}(N_g N N_kN_\\mu + N_\\mu^3 + N_gN_\\mu^2)$, where $N=N_i + N_j$.\n", "\n", "The interpolation points are computed using **centroidal Voronoi tessellation** (**CVT**). This method divides the unit cell into clusters with the same weight based on the electron density and can be calculated very efficiently in $\\mathcal{O}(N_rN_\\mu)$." ] }, { "cell_type": "markdown", "id": "9d5ebe6e", "metadata": {}, "source": [ "Since we have three different wavefunction pairings, we need to perform ISDF calculations three times:\n", "\n", "$$\n", "u^*_{ck}(\\mathbf{r})u_{vk}(\\mathbf{r}) \\approx \\sum_{\\mu=1}^{N_\\mu^V} \\zeta^V_\\mu(\\mathbf{r}) u^*_{ck}(\\mathbf{r}^V_\\mu)u_{vk}(\\mathbf{r}^V_\\mu).\n", "$$\n", "\n", "$$\n", "u^*_{vk}(\\mathbf{r})u_{vk'}(\\mathbf{r}) \\approx \\sum_{\\mu=1}^{N_\\mu^{W_v}} \\zeta^{W_v}_\\mu(\\mathbf{r}) u^*_{vk}(\\mathbf{r}^{W_c}_\\mu)u_{vk'}(\\mathbf{r}^{W_c}_\\mu),\n", "$$\n", "\n", "$$\n", "u^*_{ck}(\\mathbf{r})u_{ck'}(\\mathbf{r}) \\approx \\sum_{\\mu=1}^{N_\\mu^{W_c}} \\zeta^{W_c}_\\mu(\\mathbf{r}) u^*_{ck}(\\mathbf{r}^{W_c}_\\mu)u_{ck'}(\\mathbf{r}^{W_c}_\\mu).\n", "$$\n", "\n", "Replacing the wavefunction pairs in the formulas with these approximations, we obtain for $V$:\n", "\n", "$$\n", "V_{vc\\mathbf{k}, v'c'\\mathbf{k}'} \\approx \\frac{1}{N_k^2} \\sum_{\\mu=1}^{N_\\mu^V} \\sum_{\\nu=1}^{N_\\mu^V}\n", "u^*_{c\\mathbf{k}} (\\mathbf{r}_\\mu) u_{v\\mathbf{k}} (\\mathbf{r}_\\mu) \n", "\\tilde V_{\\mu \\nu}\n", "u^*_{c'\\mathbf{k}} (\\mathbf{r}_\\nu) u_{v'\\mathbf{k}} (\\mathbf{r}_\\nu),\n", "$$\n", "\n", "with \n", "\n", "$$\n", "\\tilde V_{\\mu \\nu} = \\int_{\\Omega^l\\times \\Omega^l}drdr' \\zeta_\\mu^{*V}(\\mathbf{r}) V(\\mathbf{r},\\mathbf{r'}) \\zeta_\\nu^{V}(\\mathbf{r'}),\n", "$$\n", "\n", "and for $W$:\n", "\n", "$$\n", "W_{vc\\mathbf{k}, v'c'\\mathbf{k}'} \\approx \\frac{1}{N_k^2} \\sum_{\\mu=1}^{N_{\\mu}^{W_c}} \\sum_{\\nu=1}^{N_{\\mu}^{W_v}}\n", "u^*_{c\\mathbf{k}} (\\mathbf{r}_\\mu) u_{c'\\mathbf{k'}} (\\mathbf{r}_\\mu)\n", "\\tilde W_{\\mu\\nu, \\mathbf{k-k'}}\n", "u^*_{v'\\mathbf{k'}} (\\mathbf{r}_\\nu) u_{v\\mathbf{k}} (\\mathbf{r}_\\nu),\n", "$$\n", "\n", "with \n", "\n", "$$\n", "\\tilde W_{\\mu\\nu, \\mathbf{k-k'}} = \\int_{\\Omega^l\\times \\Omega^l}drdr' \\zeta_\\mu^{*W_c}(\\mathbf{r}) W_{\\mathbf{k}-\\mathbf{k'}}(\\mathbf{r},\\mathbf{r'}) \\zeta_\\nu^{W_v}(\\mathbf{r'}).\n", "$$\n", "\n", "The first thing to note is that this drastically reduces the number of integrals to solve from $\\left( N_k N_v N_c \\right)^2$ to $\\left( N_\\mu^V \\right)^2$ and $N_{\\mu}^{W_v}N_{\\mu}^{W_c}$ for $V$ and $W$, respectively, given that we can choose:\n", "\n", "$$\n", "N_\\mu^V \\ll N_k N_v N_c \\\\\n", "N_{\\mu}^{W_v} \\ll N_k^2N_v^2 \\\\\n", "N_{\\mu}^{W_c} \\ll N_k^2N_c^2,\n", "$$\n", "\n", "which is always true." ] }, { "cell_type": "markdown", "id": "161ade5b", "metadata": {}, "source": [ "Secondly note that this approach does not reduce the number of matrix elements. To utilize the deconstructed matrix, we employ the Lanczos algorithm for diagonalization. The Lanczos algorithm constructs an approximation to the lowest eigenpairs of a matrix through iterative multiplication by a vector. Consequently, the computational complexity of diagonalization is scaled down to that of matrix-vector multiplication. As our focus is solely on the lowest eigenvalues, we do not lose any relevant information by not computing the entire solution. In the decomposed form, as illustrated above, we can efficiently apply the interaction kernels to a vector $X \\in \\mathbb{C}^{N_vN_cN_k}$:\n", "\n", "For the matrix $V$, we derive:\n", "\n", "$$\n", "[V \\cdot X]_{vck} = \\frac{1} {N_k}\n", "\\sum_{k'} \\sum_{v'} \\sum_{c'} \\sum_{\\mu=1}^{N_\\mu^V} \\sum_{\\nu=1}^{N_\\mu^V}\n", "u_{ck}^*(\\mathbf{r}_\\mu)\n", "u_{vk}(\\mathbf{r}_\\mu)\n", "\\tilde{V}_{\\mu\\nu}\n", "u^*_{v'k'}(\\mathbf{r}_\\nu)\n", "u_{c'k'}(\\mathbf{r}_\\nu)\n", "\\cdot X_{k' v' c'}.\n", "$$\n", "\n", "Rearranging the summations reveals an efficient evaluation of the matrix-vector product:\n", "\n", "$$\n", "[V \\cdot X]_{vck} = \\frac{1} {N_k} \\sum_{\\mu=1}^{N_\\mu^V}\n", "u^*_{ck}(\\mathbf{r}_\\mu) u_{vk}(\\mathbf{r}_\\mu)\n", "\\left\\{\n", "\\sum_{\\nu=1}^{N_\\mu^V} \\tilde V_{\\mu\\nu} \\left[ \\sum_{k'}\n", "\\left(\n", "\\sum_{c'} u_{c'k'}(\\mathbf{r}_\\nu)\n", "\\left[\n", "\\sum_{v'}\n", "u^*_{v'k'}(\\mathbf{r}_\\nu) \\cdot\n", "X_{k' v' c'}\n", "\\right]\n", "\\right)\n", "\\right]\n", "\\right\\},\n", "$$\n", "\n", "which scales as $\\mathcal{O}(N_\\mu^V N_v N_c N_k + N_\\mu N_c N_k)$, thus linear with respect to the number of $\\mathbf{k}$-points and quadratic with the number of electrons ($\\mathcal{O}(N_e) \\approx \\mathcal{O}(N_v) \\approx \\mathcal{O}(N_c)$).\n", "\n", "For the matrix $W$, the expression becomes:\n", "\n", "$$\n", "[W_A\\cdot X]_{vck} = \\frac{1}{N_k} \\sum_{k'} \\sum_{v'} \\sum_{c'} \\sum_{\\nu=1}^{N_\\mu^{W_v}} \\sum_{\\mu=1}^{N_\\mu^{W_c}}\n", "u^*_{v'k'}(\\mathbf r_\\nu^{W_v}) u_{vk}(\\mathbf r_\\nu^{W_v})\n", "\\tilde{W}_{\\mu\\nu, \\mathbf{k-k'}}\n", "u^*_{ck}(\\mathbf r_\\mu^{W_c}) u_{c'k'}(\\mathbf r_\\mu^{W_c})\n", "\\cdot X_{v'c'k'}.\n", "$$\n", "\n", "Once again, reordering the summations yields an efficient matrix-vector product evaluation:\n", "\n", "$$\n", "[W_A\\cdot X]_{vck} = \\frac{1} {N_k} \\sum_{\\nu=1}^{N_\\mu^{W_v}}\n", "u_{vk}(\\mathbf r_\\nu^{W_v}) \\left\\{ \\sum_{\\mu=1}^{N_\\mu^{W_c}}\n", "u^*_{ck}(\\mathbf r_\\mu^{W_c})\n", "\\left[\n", "\\sum_{\\mathbf{k'}}\n", "\\tilde{W}_{\\mu\\nu, \\mathbf{k-k'}}\n", "\\left(\n", "\\sum_{c'}\n", "u_{c'k'}(\\mathbf r_\\mu^{W_c})\n", "\\left[\n", "\\sum_{v'} \\cdot\n", "u^*_{\\mathbf{k'}j_o}(\\mathbf{\\hat{r}}_\\nu^W) X(\\mathbf{k'} j_o j_u)\n", "\\right]\n", "\\right)\n", "\\right]\n", "\\right\\},\n", "$$\n", "\n", "which scales as $\\mathcal{O}(N_\\mu^{W_v}N_v N_c N_k + N_\\mu^{W_v}N_\\mu^{W_c}(N_c N_k + N_k \\log N_k))$. The term $\\mathcal{O}(N_k \\log N_k)$ arises from the sum over $k'$:\n", "\n", "$$\n", "\\sum_{k'} W_{k-k'}A_{k'},\n", "$$\n", "\n", "which is a discrete convolution that can be efficiently calculated using **fast Fourier transformations**." ] }, { "cell_type": "markdown", "id": "fb124444", "metadata": {}, "source": [ "\n", "

\n", "\n", "### 3. Calculations" ] }, { "cell_type": "markdown", "id": "71f7864f", "metadata": {}, "source": [ "As an example, you will calculate the absorption spectrum for diamond on a $4 \\times 4 \\times 4$ $\\mathbf k$-grid. Please note that the parameters are not converged. A converged calculation would require too many resources for a tutorial calculation.\n", "\n", "As for all other tutorials, you can choose between executing all steps manually from your command line, or to simply execute the python cells in this Jupyter notebook." ] }, { "cell_type": "code", "execution_count": 1, "id": "ad39be18", "metadata": {}, "outputs": [], "source": [ "%%bash\n", "# Create working directory\n", "mkdir -p run_fastBSE_diamond" ] }, { "cell_type": "markdown", "id": "76f5b21e", "metadata": {}, "source": [ "\n", "#### 3.1 Groundstate and Screening\n", "\n", "First, calculate the common properties for both the **direct** and the **fastBSE** algorithm. These are the **electronic eigen energies** $\\epsilon_{ik}$, the corresponding **momentum matrix elements** and the **screened coulomb interaction**. In this example we use the electronic properties from a **DFT** groundstate calculation. As for the **direct** algorithm, you can also use a **GW** calculations as starting point for the **fastBSE** algorithm. The following **input.xml** tells exciting to calculate what we need:" ] }, { "cell_type": "markdown", "id": "f3661747", "metadata": {}, "source": [ "\n", "```xml\n", "\n", "\n", "

`xs`

element we define the general proerties of the **BSE** calculation. We can leave most of this as it if in the following, all important edits are explained.\n",
"\n",
"Note that in the `plan`

element we define a workflow that only calculates what we need for solving the **BSE** but not solving it.\n",
"\n",
"`solver=\"direct\"`

inside the `xs`

element tells exciting to use the **direct** solver workflow. This attribute is only important if you have not defined a costum workflow as we did in the `plan`

element."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f128e9db",
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"import os\n",
"from excitingjupyter.utilities import get_input_xml_from_notebook \n",
"\n",
"# Extract input file content from this notebook:\n",
"input_str = get_input_xml_from_notebook(\"07_tutorial_optical_spectra_from_fastBSE\", \"DIAMOND_GROUNDSTATE_SCREENING\")\n",
"\n",
"# Write out the input as an XML file:\n",
"with open('./run_fastBSE_diamond/input.xml', \"w\") as fid:\n",
" fid.write(input_str)"
]
},
{
"cell_type": "markdown",
"id": "3ef6428d",
"metadata": {},
"source": [
"In order to run **`exciting`** from the terminal, you need to execute the following commands."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "90d60fe9",
"metadata": {
"tags": [
"remove_output"
]
},
"outputs": [],
"source": [
"%%bash\n",
"cd run_fastBSE_diamond\n",
"# replace the string $EXCITINGROOT\n",
"python3 -m excitingscripts.setup.excitingroot\n",
"# execute exciting\n",
"python3 -m excitingscripts.execute.single\n",
"cd .."
]
},
{
"cell_type": "markdown",
"id": "cbc9a7c9",
"metadata": {},
"source": [
"\n",
"\n", "\n", "#### 3.2 Direct BSE Calculation\n", "\n", "Now calculate the absorption spectrum by solving the **BSE** **directly**. Therefore edit the **input.xml** as follows:\n" ] }, { "cell_type": "markdown", "id": "3d73df2f", "metadata": {}, "source": [ "\n", "```xml\n", "\n", "\n", "

`do=\"skip\"`

inside the `groundstate`

element. We do not need to calculate the groundstate again.\n",
"\n",
"The `plan`

element defines now a workflow to setup the interaction kernels and solve the **BSE**."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f5d5e323",
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"import os\n",
"from excitingjupyter.utilities import get_input_xml_from_notebook \n",
"\n",
"# Extract input file content from this notebook:\n",
"input_str = get_input_xml_from_notebook(\"07_tutorial_optical_spectra_from_fastBSE\", \"DIAMOND_BSE\")\n",
"\n",
"# Write out the input as an XML file:\n",
"with open('./run_fastBSE_diamond/input.xml', \"w\") as fid:\n",
" fid.write(input_str)"
]
},
{
"cell_type": "markdown",
"id": "84ed6665",
"metadata": {},
"source": [
"In order to run **`exciting`** from the terminal, you need to execute the following commands."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "19f84791",
"metadata": {
"tags": [
"remove_output"
]
},
"outputs": [],
"source": [
"%%bash\n",
"cd run_fastBSE_diamond\n",
"# replace the string $EXCITINGROOT\n",
"python3 -m excitingscripts.setup.excitingroot\n",
"# execute exciting\n",
"python3 -m excitingscripts.execute.single\n",
"cd .."
]
},
{
"cell_type": "markdown",
"id": "ceff1c79",
"metadata": {},
"source": [
"\n",
"\n", "\n", "#### 3.3 fastBSE\n", "\n", "Now we will calculate the same spectrum but use the **fastBSE** algorithm. Therefore edit the **input.xml** as follows:" ] }, { "cell_type": "markdown", "id": "0e80e41e", "metadata": {}, "source": [ "\n", "```xml\n", "\n", "\n", "

`plan`

element defines a workflow with the remaining tasks to calculate the absorption spectrum with the **fastBSE** algorithm. Without it, exciting will run a workflow, that automatically calculates all necessary properties.\n",
"\n",
"`solver=\"fastBSE\"`

inside the `xs`

element tells exciting to use the **fastBSE** solver. Since we use here a custom plan it has no effect.\n",
"\n",
"The `fastBSE`

element in the `xs`

element defines the following parameters for fast BSE.\n",
"\n",
"- `ngridr=\"20 20 20\"`

inside the `xs`

defines the real space grid on which $u_{ik}(\\mathbf r)$ is calculated.\n",
"\n",
"- `nisdf=\"80 200 200\"`

inside the `xs`

defines the number of interpolation points for the **ISDF** of the $u_{vk}(\\mathbf r)u_{ck}(\\mathbf r)$ pairs in $V$ and $u_{vk}(\\mathbf r)u_{v'k'}(\\mathbf r)$ and $u_{ck}(\\mathbf r)u_{c'k'}(\\mathbf r)$ in $W$ respectively.\n",
"\n",
"- `nlanczos=\"200\"`

inside the `xs`

defines the maximum number of Lanczos iterations to be calculated.\n",
"\n",
"As you can see, the properties of the BSE calculation do not need to be edited or copied. You only need to set `solver=\"fastBSE\"`

and define the properties for the **fastBSE** algorithm."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "284cc35b",
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"import os\n",
"from excitingjupyter.utilities import get_input_xml_from_notebook \n",
"\n",
"# Extract input file content from this notebook:\n",
"input_str = get_input_xml_from_notebook(\"07_tutorial_optical_spectra_from_fastBSE\", \"DIAMOND_fastBSE\")\n",
"\n",
"# Write out the input as an XML file:\n",
"with open('./run_fastBSE_diamond/input.xml', \"w\") as fid:\n",
" fid.write(input_str)"
]
},
{
"cell_type": "markdown",
"id": "c8d18860",
"metadata": {},
"source": [
"In order to run **`exciting`** from the terminal, you need to execute the following commands."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "84259f99",
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"cd run_fastBSE_diamond\n",
"# replace the string $EXCITINGROOT\n",
"python3 -m excitingscripts.setup.excitingroot\n",
"# execute exciting\n",
"python3 -m excitingscripts.execute.single\n",
"cd .."
]
},
{
"cell_type": "markdown",
"id": "015934ea",
"metadata": {},
"source": [
"\n",
"\n", "\n", "### 4. Compare the results\n", "\n", "By comparing the runtime, you already see that the **fastBSE** algorithm is significantly faster.\n", "\n", "To convince yourself that the absorption spectra calculated with both algorithms are equivalent plot the absorption spectrum by running the following commands. The image is saved as **PLOT.png**." ] }, { "cell_type": "code", "execution_count": 8, "id": "e1e604c1", "metadata": {}, "outputs": [], "source": [ "%%bash\n", "cd run_fastBSE_diamond\n", "cp EPSILON/EPSILON_BSE-singlet-TDA-BAR_SCR-full_OC11.OUT direct\n", "cp fastBSE_absorption_spectrum.out fastBSE\n", "python3 -m excitingscripts.plot.files -t 'Absorption Spectrum: Diamond' -f direct fastBSE -cx 1 -cy 3 -lx '$\\omega$ [eV]' -ly 'Im $\\epsilon_M$' -x 0 40\n", "cd .." ] }, { "cell_type": "markdown", "id": "f7cf39b2", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "id": "415606e6", "metadata": {}, "source": [ "

" ] } ], "metadata": { "kernelspec": { "display_name": "excitingjupyter", "language": "python", "name": "excitingjupyter" }, "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.7.10" } }, "nbformat": 4, "nbformat_minor": 5 }