.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/example_04_GS_analysis.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_example_04_GS_analysis.py: Ground state analysis for NiO ================================================================================ This example follows the :ref:`sphx_glr_auto_examples_example_03_AIM_XAS.py` example and considers the same model. This time we show how to analyze the eigenvectors in terms of a :math:`\alpha |d^8L^{10}\rangle + \beta |d^9L^9\rangle + \gamma |d^{10}L^8\rangle` representation. .. GENERATED FROM PYTHON SOURCE LINES 14-17 Hamiltonian ------------------------------------------------------------------------------ We start by obtaining all eigenvectors of the previous Hamiltonian. .. GENERATED FROM PYTHON SOURCE LINES 17-26 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt import edrixs backend = 'scipy' eval_i, evec_i = edrixs.ed(hmat_i, shift=shift, num_evals=len(basis_i), backend=backend) eval_i = eval_i - eval_i.min() .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/micromamba/envs/build-env/lib/python3.12/site-packages/edrixs/scipy_backend/scipy_backend.py:98: UserWarning: The problem size 190 minus the constraints size 0 is too small relative to the block size 190. Using a dense eigensolver instead of LOBPCG iterations.No output of the history of the iterations. eigenvalues, eigenvectors = lobpcg( .. GENERATED FROM PYTHON SOURCE LINES 36-43 Number of d electrons ------------------------------------------------------------------------------ We can count the number of :math:`d` electrons by building a single-particle operator :code:`single_particle_Nd` with ones on the diagonal at the nickel :math:`d`-shell orbitals and zeros elsewhere. :func:`~edrixs.solvers.build_op` transforms this into the many-body operator :code:`O`, whose expectation value in each eigenvector is the :math:`d`-electron count of that state. .. GENERATED FROM PYTHON SOURCE LINES 43-57 .. code-block:: Python single_particle_Nd = np.zeros_like(emat_i) single_particle_Nd[:norb_d, :norb_d] = np.eye(norb_d) O = edrixs.build_op(single_particle_Nd, None, basis_i, backend=backend) nd_expect = np.sum(evec_i.conj() * (O @ evec_i), axis=0).real fig, ax = plt.subplots() ax.set_xlabel('Energy (eV)') ax.set_ylabel('$d$ electron count') ax.plot(eval_i, nd_expect) .. image-sg:: /auto_examples/images/sphx_glr_example_04_GS_analysis_001.png :alt: example 04 GS analysis :srcset: /auto_examples/images/sphx_glr_example_04_GS_analysis_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] .. GENERATED FROM PYTHON SOURCE LINES 58-64 Configuration weights alpha, beta, gamma ------------------------------------------------------------------------------ Every Fock state has a definite :math:`d` occupation, so :math:`O` is diagonal in the Fock basis. :code:`O.diagonal()` therefore gives the :math:`d`-electron count of each Fock-basis component, in the same order as the amplitudes of the eigenvectors returned by :func:`~edrixs.solvers.ed`. .. GENERATED FROM PYTHON SOURCE LINES 64-81 .. code-block:: Python nd_per_component = np.rint(O.diagonal().real).astype(int) amp2 = np.abs(evec_i)**2 alphas = amp2[nd_per_component == 8].sum(axis=0) betas = amp2[nd_per_component == 9].sum(axis=0) gammas = amp2[nd_per_component == 10].sum(axis=0) print("Ground state\nalpha={:.3f}\tbeta={:.3f}\tgamma={:.3f}".format( alphas[0], betas[0], gammas[0])) fig, ax = plt.subplots() ax.plot(eval_i, alphas, label=r'$\alpha$ $d^8L^{10}$') ax.plot(eval_i, betas, label=r'$\beta$ $d^9L^{9}$') ax.plot(eval_i, gammas, label=r'$\gamma$ $d^{10}L^{8}$') ax.set_xlabel('Energy (eV)') ax.set_ylabel('Population') ax.legend() .. image-sg:: /auto_examples/images/sphx_glr_example_04_GS_analysis_002.png :alt: example 04 GS analysis :srcset: /auto_examples/images/sphx_glr_example_04_GS_analysis_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Ground state alpha=0.823 beta=0.172 gamma=0.004 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.322 seconds) .. _sphx_glr_download_auto_examples_example_04_GS_analysis.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_04_GS_analysis.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_04_GS_analysis.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_04_GS_analysis.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_