### Run example with MPI Source: https://edrixs.github.io/edrixs/auto_examples/example_03_AIM_XAS.html Runs the example script with MPI using a specified number of processors. Running without mpirun also works but is slower. ```bash mpirun -n python example_AIM_XAS.py ``` -------------------------------- ### get_trans_oper() transition operator examples Source: https://edrixs.github.io/edrixs/reference/photon_transition.html Shows how to use get_trans_oper() to obtain transition operators for p→d, p→t2g, and p3/2→d transitions. The examples are from the docstring of get_trans_oper() and assume edrixs is imported. ```python >>> import edrixs p to d transition >>> trans_dp = get_trans_oper('dp') p to t2g transition >>> trans_t2gp = get_trans_oper('t2gp') p_{3/2} to d transition >>> trans_dp32 = get_trans_oper('dp32') ``` -------------------------------- ### Clone and Install edrixs from Source Source: https://edrixs.github.io/edrixs/_sources/user/installation.rst.txt Clone the edrixs repository and install it from the repository root, using pip options to use the environment's NumPy for building the extension and prevent dependency replacement. ```bash git clone https://github.com/EDRIXS/edrixs.git cd edrixs python -m pip install --no-build-isolation --no-deps . ``` -------------------------------- ### Import libraries for x-ray transitions example Source: https://edrixs.github.io/edrixs/_downloads/c9896ccbd0ac2123698377042de2ce96/example_07_transitions.ipynb Imports the required libraries: edrixs, numpy, matplotlib.pyplot, and scipy. ```python import edrixs import numpy as np import matplotlib.pyplot as plt import scipy ``` -------------------------------- ### Import libraries and reload example module Source: https://edrixs.github.io/edrixs/auto_examples/example_04_GS_analysis.html Imports the required libraries and reloads the example_03_AIM_XAS module to access its parameters. ```python import edrixs import numpy as np import matplotlib.pyplot as plt import scipy import example_03_AIM_XAS import importlib _ = importlib.reload(example_03_AIM_XAS) ``` -------------------------------- ### Import necessary modules for EDRIXS example Source: https://edrixs.github.io/edrixs/_downloads/9533e398daf1eb62ff3e3e097776acb7/example_00_ed_calculator.ipynb Imports numpy, math.comb, matplotlib, scipy, and edrixs for the exact diagonalization example. ```python import numpy as np from math import comb import matplotlib.pyplot as plt import scipy import edrixs ``` -------------------------------- ### docker compose up command Source: https://edrixs.github.io/edrixs/_sources/user/usedocker.rst.txt Starts the services defined in docker-compose.yml. Returns a URL to connect to the Jupyter session. ```bash docker compose up ``` -------------------------------- ### Verify Installed Package with Python and MPI Source: https://edrixs.github.io/edrixs/_sources/user/installation.rst.txt Run import and MPI checks from outside the source directory to verify the installed package works with the environment's libraries. ```bash cd .. python -c "from edrixs import fedrixs; print(fedrixs.__file__)" mpirun -np 2 python -c "from mpi4py import MPI; from edrixs import fedrixs; print(MPI.COMM_WORLD.rank)" ``` -------------------------------- ### Import parameters from example_03_AIM_XAS Source: https://edrixs.github.io/edrixs/auto_examples/example_04_GS_analysis.html Imports the parameters from the Anderson impurity model for NiO XAS example and sets ntot=20 spin-orbitals. ```python from example_03_AIM_XAS import (F0_dd, F2_dd, F4_dd, nd, norb_d, norb_bath, v_noccat, imp_mat, bath_level, hyb, ext_B, trans_c2n) ntot = 20 ``` -------------------------------- ### Import parameters and set ntot Source: https://edrixs.github.io/edrixs/_sources/auto_examples/example_04_GS_analysis.rst.txt Imports the parameters needed from the example_03_AIM_XAS example and sets ntot to 20 spin-orbitals. ```Python from example_03_AIM_XAS import (F0_dd, F2_dd, F4_dd, nd, norb_d, norb_bath, v_noccu, imp_mat, bath_level, hyb, ext_B, trans_c2n) ntot = 20 ``` -------------------------------- ### Import parameters for the NiO model Source: https://edrixs.github.io/edrixs/_downloads/08d855947820c8ec1cf710ebd2ad5b64/example_04_GS_analysis.ipynb Retrieves specific parameters from the previous example and sets the total number of spin-orbitals to 20. ```python from example_03_AIM_XAS import (F0_dd, F2_dd, F4_dd, nd, norb_d, norb_bath, v_noccu, imp_mat, bath_level, hyb, ext_B, trans_c2n) ntot = 20 ``` -------------------------------- ### Define parameters for p-shell example Source: https://edrixs.github.io/edrixs/_downloads/9533e398daf1eb62ff3e3e097776acb7/example_00_ed_calculator.ipynb Sets the orbital angular momentum l=1, number of spin-orbitals norb=6, occupancy noccu=2, and Slater integrals F0=4.0, F2=1.0. ```python l = 1 norb = 6 noccu = 2 F0, F2 = 4.0, 1.0 ``` -------------------------------- ### Import modules for exact diagonalization Source: https://edrixs.github.io/edrixs/auto_examples/example_00_ed_calculator.html Imports the required modules for the exact diagonalization example: numpy, math.comb, matplotlib.pyplot, scipy, and edrixs. ```python import numpy as np from math import comb import matplotlib.pyplot as plt import scipy import edrixs ``` -------------------------------- ### ED output Source: https://edrixs.github.io/edrixs/_sources/auto_examples/example_02_single_atom_RIXS.rst.txt Output from the exact diagonalization step of the example, showing the dimensions of the initial and intermediate Hamiltonians and the progress messages. ```none edrixs >>> Dimension of the initial Hamiltonian: 15 edrixs >>> Dimension of the intermediate Hamiltonian: 24 edrixs >>> Building Many-body Hamiltonians ... edrixs >>> Done ! edrixs >>> Exact Diagonalization of Hamiltonians ... edrixs >>> Done ! edrixs >>> ED Done ! ``` -------------------------------- ### Calculate eigenvalues for a t2g-orbital system Source: https://edrixs.github.io/edrixs/_sources/user/quickstart.rst.txt This example demonstrates how to use edrixs to build a Hamiltonian for a t2g-orbital system and calculate its eigenvalues using scipy.linalg.eigh. ```python >>> import edrixs >>> import scipy >>> norb = 6 >>> noccu = 2 >>> Ud, JH = edrixs.UJ_to_UdJH(4, 1) >>> F0, F2, F4 = edrixs.UdJH_to_F0F2F4(Ud, JH) >>> umat = edrixs.get_umat_slater('t2g', F0, F2, F4) >>> emat = edrixs.atom_hsoc('t2g', 0.2) >>> basis = edrixs.get_fock_bin_by_N(norb, noccu) >>> H = edrixs.build_opers(4, umat, basis) >>> e1, v1 = scipy.linalg.eigh(H) >>> H += edrixs.build_opers(2, emat, basis) >>> e2, v2 = scipy.linalg.eigh(H) >>> print(e1) [1. 1. 1. 1. 1. 1. 1. 1. 1. 3. 3. 3. 3. 3. 6.] >>> print(e2) [0.890519 0.890519 0.890519 0.890519 0.890519 1.1 1.1 1.1 1.183391 3.009481 3.009481 3.009481 3.009481 3.009481 6.016609] ``` -------------------------------- ### Set up Slater integrals for d-p shells with umat_slater Source: https://edrixs.github.io/edrixs/_modules/edrixs/coulomb_utensor.html Define Slater integrals for a d-p system (l_list=[2,1]) and populate the fk dictionary with d-d integrals. The example is incomplete; it does not show the final call to umat_slater. ```python >>> l_list = [2,1] >>> fk={} >>> F0_dd, F2_dd, F4_dd = 5.0, 4.0, 2.0 >>> F0_dp, F2_dp = 4.0, 2.0 >>> G1_dp, G3_dp = 2.0, 1.0 >>> F0_pp, F2_pp = 2.0, 1.0 ``` ```python >>> fk[(0,1,1,1,1)] = F0_dd >>> fk[(2,1,1,1,1)] = F2_dd >>> fk[(4,1,1,1,1)] = F4_dd ``` -------------------------------- ### Output of core-hole site energy calculation Source: https://edrixs.github.io/edrixs/auto_examples/example_03_AIM_XAS.html Example output of the previous calculation, showing the resulting site energies and core-level energy in eV. ```text E_d = -41.189 eV E_L = 12.511 eV E_dc = -77.367 eV E_Lc = 27.333 eV E_p = -44.467 eV ``` -------------------------------- ### Constructing Hamiltonians in EDRIXS Source: https://edrixs.github.io/edrixs/_modules/edrixs/solvers.html This code block demonstrates the setup of initial and intermediate Hamiltonians, including the calculation of Coulomb interactions via Slater integrals, application of SOC, crystal field effects, and Zeeman terms for external magnetic fields. ```python print("edrixs >>> Running ED ...") v_name_options = ['s', 'p', 't2g', 'd', 'f'] c_name_options = ['s', 'p', 'p12', 'p32', 't2g', 'd', 'd32', 'd52', 'f', 'f52', 'f72'] v_name = shell_name[0].strip() c_name = shell_name[1].strip() if v_name not in v_name_options: raise Exception("NOT supported type of valence shell: ", v_name) if c_name not in c_name_options: raise Exception("NOT supported type of core shell: ", c_name) info_shell = info_atomic_shell() # Quantum numbers of angular momentum v_orbl = info_shell[v_name][0] # number of orbitals including spin degree of freedom v_norb = info_shell[v_name][1] c_norb = info_shell[c_name][1] # total number of orbitals ntot = v_norb + c_norb emat_i = np.zeros((ntot, ntot), dtype=complex) emat_n = np.zeros((ntot, ntot), dtype=complex) # Coulomb interaction # Get the names of all the required slater integrals slater_name = slater_integrals_name((v_name, c_name), ('v', 'c')) nslat = len(slater_name) slater_i = np.zeros(nslat, dtype=float) slater_n = np.zeros(nslat, dtype=float) if slater is not None: if nslat > len(slater[0]): slater_i[0:len(slater[0])] = slater[0] else: slater_i[:] = slater[0][0:nslat] if nslat > len(slater[1]): slater_n[0:len(slater[1])] = slater[1] else: slater_n[:] = slater[1][0:nslat] # print summary of slater integrals print() print(" Summary of Slater integrals:") print(" ------------------------------") print(" Terms, Initial Hamiltonian, Intermediate Hamiltonian") for i in range(nslat): print(" ", slater_name[i], ": {:20.10f}{:20.10f}".format(slater_i[i], slater_n[i])) print() case = v_name + c_name umat_i = get_umat_slater(case, *slater_i) umat_n = get_umat_slater(case, *slater_n) if verbose > 0: write_umat(umat_i, 'coulomb_i.in') write_umat(umat_n, 'coulomb_n.in') # SOC if v_soc is not None: emat_i[0:v_norb, 0:v_norb] += atom_hsoc(v_name, v_soc[0]) emat_n[0:v_norb, 0:v_norb] += atom_hsoc(v_name, v_soc[1]) # when the core-shell is any of p12, p32, d32, d52, f52, f72, # do not need to add SOC for core shell if c_name in ['p', 'd', 'f']: emat_n[v_norb:ntot, v_norb:ntot] += atom_hsoc(c_name, c_soc) # crystal field if v_cfmat is not None: emat_i[0:v_norb, 0:v_norb] += np.array(v_cfmat) emat_n[0:v_norb, 0:v_norb] += np.array(v_cfmat) # other hopping matrix if v_othermat is not None: emat_i[0:v_norb, 0:v_norb] += np.array(v_othermat) emat_n[0:v_norb, 0:v_norb] += np.array(v_othermat) # energy of shells if shell_level is not None: emat_i[0:v_norb, 0:v_norb] += np.eye(v_norb) * shell_level[0] emat_i[v_norb:ntot, v_norb:ntot] += np.eye(c_norb) * shell_level[1] emat_n[0:v_norb, 0:v_norb] += np.eye(v_norb) * shell_level[0] emat_n[v_norb:ntot, v_norb:ntot] += np.eye(c_norb) * shell_level[1] # external magnetic field if v_name == 't2g': lx, ly, lz = get_lx(1, True), get_ly(1, True), get_lz(1, True) sx, sy, sz = get_sx(1), get_sy(1), get_sz(1) lx, ly, lz = -lx, -ly, -lz else: lx, ly, lz = get_lx(v_orbl, True), get_ly(v_orbl, True), get_lz(v_orbl, True) sx, sy, sz = get_sx(v_orbl), get_sy(v_orbl), get_sz(v_orbl) if ext_B is not None: if on_which.strip() == 'spin': zeeman = ext_B[0] * (2 * sx) + ext_B[1] * (2 * sy) + ext_B[2] * (2 * sz) elif on_which.strip() == 'orbital': zeeman = ext_B[0] * lx + ext_B[1] * ly + ext_B[2] * lz elif on_which.strip() == 'both': zeeman = ext_B[0] * (lx + 2 * sx) + ext_B[1] * (ly + 2 * sy) + ext_B[2] * (lz + 2 * sz) else: raise Exception("Unknown value of on_which", on_which) emat_i[0:v_norb, 0:v_norb] += zeeman emat_n[0:v_norb, 0:v_norb] += zeeman if verbose > 0: write_emat(emat_i, 'hopping_i.in') write_emat(emat_n, 'hopping_n.in') basis_i = get_fock_bin_by_N(v_norb, v_noccu, c_norb, c_norb) basis_n = get_fock_bin_by_N(v_norb, v_noccu+1, c_norb, c_norb - 1) ncfg_i, ncfg_n = len(basis_i), len(basis_n) print("edrixs >>> Dimension of the initial Hamiltonian: ", ncfg_i) print("edrixs >>> Dimension of the intermediate Hamiltonian: ", ncfg_n) ``` -------------------------------- ### Set Up Environment for Prebuilt Package with Mamba Source: https://edrixs.github.io/edrixs/_sources/user/installation.rst.txt Create the 'edrixs_env' Mamba environment, installing the prebuilt edrixs package and matplotlib from the conda-forge channel, with strict channel priority to ensure package compatibility. ```bash mamba create --name edrixs_env -c conda-forge --strict-channel-priority \ edrixs matplotlib conda activate edrixs_env ``` -------------------------------- ### Get binary Fock states with edrixs.fock_bin Source: https://edrixs.github.io/edrixs/reference/fock_basis.html Example usage of the fock_bin function to retrieve binary representations of Fock states. ```python >>> import edrixs >>> edrixs.fock_bin(4,2) [[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 1, 1]] ``` -------------------------------- ### Import required modules Source: https://edrixs.github.io/edrixs/_downloads/48dcf18f85586b5827baa0b5994f0d7e/example_05_charge_transfer.ipynb Initializes the environment by importing necessary libraries and reloading the example_03_AIM_XAS module. ```python import edrixs import numpy as np import matplotlib.pyplot as plt import scipy import example_03_AIM_XAS import importlib _ = importlib.reload(example_03_AIM_XAS) ``` -------------------------------- ### Install edrixs on Google Colaboratory Source: https://edrixs.github.io/edrixs/_sources/user/installation.rst.txt In a notebook cell, install Conda within Colab using condacolab, then install edrixs from the conda-forge channel. ```python !pip install -q condacolab import condacolab condacolab.install() !conda install -c conda-forge edrixs ``` -------------------------------- ### Write config.in with solver parameters Source: https://edrixs.github.io/edrixs/_modules/edrixs/iostream.html Builds a list of configuration lines for a 'config.in' file, then writes them to the file in the given directory. The configuration includes solver parameters and tolerances. The file is opened in write mode and closed after writing. ```python config = [ "&control", "ed_solver=" + str(ed_solver), "num_val_orbs=" + str(num_val_orbs), "num_core_orbs=" + str(num_core_orbs), "neval=" + str(neval), "nvector=" + str(nvector), "ncv=" + str(ncv), "idump=" + str(dump_vector), "num_gs=" + str(num_gs), "maxiter=" + str(maxiter), "linsys_max=" + str(linsys_max), "min_ndim=" + str(min_ndim), "nkryl=" + str(nkryl), "eigval_tol=" + str(eigval_tol), "linsys_tol=" + str(linsys_tol), "omega_in=" + str(omega_in), "gamma_in=" + str(gamma_in), "&end" ] f = open(directory + '/config.in', 'w') for item in config: f.write(item + "\n") f.close() ``` -------------------------------- ### edrixs.case_to_shell_name usage example Source: https://edrixs.github.io/edrixs/reference/utils.html Shows how to use edrixs.case_to_shell_name to map a case string to shell names. The example demonstrates that 'd' returns ('d',) and 't2gp32' returns ('t2g', 'p32'). ```python >>> import edrixs >>> edrixs.case_to_shell_name('d') ('d',) >>> edrixs.case_to_shell_name('t2gp32') ('t2g', 'p32') ``` -------------------------------- ### Verify edrixs installation with import and MPI test Source: https://edrixs.github.io/edrixs/user/installation.html Verifies the installed edrixs package from outside the source directory. The first command should print a path ending in .so; the second should print ranks 0 and 1. On macOS, the linker may print harmless compact unwind warnings while compiling gfortran objects. ```bash cd .. python -c "from edrixs import fedrixs; print(fedrixs.__file__)" mpirun -np 2 python -c "from mpi4py import MPI; from edrixs import fedrixs; print(MPI.COMM_WORLD.rank)" ``` -------------------------------- ### Initialize Ni 3d basis and Slater integrals Source: https://edrixs.github.io/edrixs/_downloads/b7332bf086a59638a80f0b4668705359/example_01_crystal_field.ipynb Sets up the basis and Slater integrals for a Ni 3d system with 8 electrons (2 holes) in 10 spin-orbitals. Uses edrixs.get_fock_bin_by_N and edrixs.get_atom_data with edge='L3'. ```python l = 2 norb = 10 noccu = 8 basis = edrixs.get_fock_bin_by_N(norb, noccu) slater = edrixs.get_atom_data('Ni', '3d', noccu, edge='L3')['slater_i'] ``` -------------------------------- ### tmat_r2c Source: https://edrixs.github.io/edrixs/reference/basis_transform.html Get the unitary transformation matrix from the basis of real spherical harmonics to complex spherical harmonics. ```APIDOC ## tmat_r2c(case, ispin=False) ### Description Get the unitary transformation matrix from the basis of real spherical harmonics to complex spherical harmonics. ### Parameters - **case** (string) - Required - Label for different systems. 'p' for p-shell, 't2g' for t2g-shell, 'd' for d-shell, 'f' for f-shell. - **ispin** (logical) - Optional - Whether including spin degree of freedom or not (default: False). ### Returns - **t_r2c** (2d complex array) - The transformation matrix. ``` -------------------------------- ### Initialize and fill impurity/bath Hamiltonian (emat_i, emat_n) Source: https://edrixs.github.io/edrixs/_modules/edrixs/solvers.html Initializes the impurity and bath Hamiltonian matrices (emat_i, emat_n) and fills them according to siam_type: for siam_type==1 it adds the hopping terms (general hybridization), for siam_type==0 it adds impurity matrix, bath levels, and hybridization terms. Raises an exception for unknown siam_type. ```python emat_i = np.zeros((ntot, ntot), dtype=complex) emat_n = np.zeros((ntot, ntot), dtype=complex) # General hybridization function, including off-diagonal terms if siam_type == 1: if hopping is not None: emat_i[0:ntot_v, 0:ntot_v] += hopping if hopping_n is not None: emat_n[0:ntot_v, 0:ntot_v] += hopping_n elif hopping is not None: emat_n[0:ntot_v, 0:ntot_v] += hopping # Diagonal hybridization function elif siam_type == 0: # matrix (CF or SOC) for impuirty site if imp_mat is not None: emat_i[0:v_norb, 0:v_norb] += imp_mat if imp_mat_n is not None: emat_n[0:v_norb, 0:v_norb] += imp_mat_n elif imp_mat is not None: emat_n[0:v_norb, 0:v_norb] += imp_mat # bath levels if bath_level is not None: for i in range(nbath): for j in range(v_norb): indx = (i + 1) * v_norb + j emat_i[indx, indx] += bath_level[i, j] if bath_level_n is not None: for i in range(nbath): for j in range(v_norb): indx = (i + 1) * v_norb + j emat_n[indx, indx] += bath_level_n[i, j] elif bath_level is not None: for i in range(nbath): for j in range(v_norb): indx = (i + 1) * v_norb + j emat_n[indx, indx] += bath_level[i, j] if hyb is not None: for i in range(nbath): for j in range(v_norb): indx1, indx2 = j, (i + 1) * v_norb + j emat_i[indx1, indx2] += hyb[i, j] emat_i[indx2, indx1] += np.conj(hyb[i, j]) if hyb_n is not None: for i in range(nbath): for j in range(v_norb): indx1, indx2 = j, (i + 1) * v_norb + j emat_n[indx1, indx2] += hyb_n[i, j] emat_n[indx2, indx1] += np.conj(hyb_n[i, j]) elif hyb is not None: for i in range(nbath): for j in range(v_norb): indx1, indx2 = j, (i + 1) * v_norb + j emat_n[indx1, indx2] += hyb[i, j] emat_n[indx2, indx1] += np.conj(hyb[i, j]) else: raise Exception("Unknown siam_type: ", siam_type) ``` -------------------------------- ### tmat_cub2r_f Source: https://edrixs.github.io/edrixs/reference/basis_transform.html Get the transformation matrix from the cubic spherical harmonics to real spherical harmonics, only for f system. ```APIDOC ## tmat_cub2r_f(ispin=False) ### Description Get the transformation matrix from the cubic spherical harmonics to real spherical harmonics, only for f system. ### Parameters - **ispin** (logical) - Optional - Whether including spin degree of freedom or not (default: False). ### Returns - **t_cub2r** (2d complex array) - The transformation matrix. ``` -------------------------------- ### write_config(directory='.', ed_solver=1, num_val_orbs=2, num_core_orbs=2, neval=1, nvector=1, ncv=1, idump=True, num_gs=1, maxiter=500, linsys_max=1000, min_ndim=1000, nkryl=500, eigval_tol=1e-08, linsys_tol=1e-10, omega_in=0.0, gamma_in=0.1) Source: https://edrixs.github.io/edrixs/reference/iostream.html Writes control parameters in config.in file for ed_fsolver. ```APIDOC ## write_config(directory='.', ed_solver=1, num_val_orbs=2, num_core_orbs=2, neval=1, nvector=1, ncv=1, idump=True, num_gs=1, maxiter=500, linsys_max=1000, min_ndim=1000, nkryl=500, eigval_tol=1e-08, linsys_tol=1e-10, omega_in=0.0, gamma_in=0.1) ### Description Writes control parameters in config.in file for ed_fsolver. ### Method Function call ### Parameters - **directory** (string) - Optional - Directory. Default: '.'. - **ed_solver** (int) - Optional - ED solver. Default: 1. - **num_val_orbs** (int) - Optional - Number of valence orbitals. Default: 2. - **num_core_orbs** (int) - Optional - Number of core orbitals. Default: 2. - **neval** (int) - Optional - Number of eigenvalues. Default: 1. - **nvector** (int) - Optional - Number of vectors. Default: 1. - **ncv** (int) - Optional - Number of Lanczos vectors. Default: 1. - **idump** (bool) - Optional - Dump flag. Default: True. - **num_gs** (int) - Optional - Number of ground states. Default: 1. - **maxiter** (int) - Optional - Maximum iterations. Default: 500. - **linsys_max** (int) - Optional - Linear system maximum. Default: 1000. - **min_ndim** (int) - Optional - Minimum dimension. Default: 1000. - **nkryl** (int) - Optional - Krylov dimension. Default: 500. - **eigval_tol** (float) - Optional - Eigenvalue tolerance. Default: 1e-08. - **linsys_tol** (float) - Optional - Linear system tolerance. Default: 1e-10. - **omega_in** (float) - Optional - Omega input. Default: 0.0. - **gamma_in** (float) - Optional - Gamma input. Default: 0.1. ``` -------------------------------- ### UniKVec.__init__ Source: https://edrixs.github.io/edrixs/_modules/edrixs/wannier_ham.html Initializes a UniKVec object for a uniform k-point grid. ```APIDOC ## UniKVec.__init__ n ### Description Initializes a UniKVec object for a uniform k-point grid. ### Method Constructor ### Parameters - **grid** (3-elements tuple) - Optional - Three numbers defining a uniform grid, for example: 11 x 11 x 11. ### Example ```python unikvec = UniKVec(grid=(11,11,11)) ``` ``` -------------------------------- ### Build transition operators and write XAS input files (_xas_1or2_valence_1core) Source: https://edrixs.github.io/edrixs/_modules/edrixs/solvers.html Internal helper that builds transition operators and prepares input files for XAS calculations. It validates shell names, sets default polarization and axes, and writes fock_i.in and fock_n.in on rank 0. Raises an exception for unsupported trans_to_which values or unsupported transition multipolarity. ```python def _xas_1or2_valence_1core( comm, shell_name, ominc, *, gamma_c=0.1, v_tot_noccu=1, trans_to_which=1, thin=1.0, phi=0, pol_type=None, num_gs=1, nkryl=200, temperature=1.0, loc_axis=None, scatter_axis=None ): from .fedrixs import xas_fsolver rank = comm.Get_rank() size = comm.Get_size() fcomm = comm.py2f() v1_name = shell_name[0].strip() v2_name = shell_name[1].strip() c_name = shell_name[2].strip() info_shell = info_atomic_shell() v1_norb = info_shell[v1_name][1] if v2_name != 'empty': v2_norb = info_shell[v2_name][1] else: v2_norb = 0 c_norb = info_shell[c_name][1] ntot = v1_norb + v2_norb + c_norb v1v2_norb = v1_norb + v2_norb if pol_type is None: pol_type = [('isotropic', 0)] if loc_axis is None: loc_axis = np.eye(3) else: loc_axis = np.array(loc_axis) if scatter_axis is None: scatter_axis = np.eye(3) else: scatter_axis = np.array(scatter_axis) if rank == 0: print("edrixs >>> Running XAS ...", flush=True) write_config(num_val_orbs=v1v2_norb, num_core_orbs=c_norb, num_gs=num_gs, nkryl=nkryl) write_fock_dec_by_N(v1v2_norb, v_tot_noccu, "fock_i.in") write_fock_dec_by_N(v1v2_norb, v_tot_noccu + 1, "fock_n.in") # Build transition operators in local-xyz axis if trans_to_which == 1: case = v1_name + c_name elif trans_to_which == 2 and v2_name != 'empty': case = v2_name + c_name else: raise Exception('Unkonwn trans_to_which: ', trans_to_which) tmp = get_trans_oper(case) npol, n, m = tmp.shape tmp_g = np.zeros((npol, n, m), dtype=complex) trans_mat = np.zeros((npol, ntot, ntot), dtype=complex) # Transform the transition operators to global-xyz axis # dipolar transition if npol == 3: for i in range(3): for j in range(3): tmp_g[i] += loc_axis[i, j] * tmp[j] # quadrupolar transition elif npol == 5: alpha, beta, gamma = rmat_to_euler(loc_axis) wignerD = get_wigner_dmat(4, alpha, beta, gamma) rotmat = np.dot(np.dot(tmat_r2c('d'), wignerD), np.conj(np.transpose(tmat_r2c('d')))) for i in range(5): for j in range(5): tmp_g[i] += rotmat[i, j] * tmp[j] else: raise Exception("Have NOT implemented this case: ", npol) if trans_to_which == 1: trans_mat[:, 0:v1_norb, v1v2_norb:ntot] = tmp_g else: trans_mat[:, v1_norb:v1v2_norb, v1v2_norb:ntot] = tmp_g n_om = len(ominc) gamma_core = np.zeros(n_om, dtype=float) if np.isscalar(gamma_c): gamma_core[:] = np.ones(n_om) * gamma_c else: gamma_core[:] = gamma_c ``` -------------------------------- ### Get decimal Fock states with get_fock_full_N Source: https://edrixs.github.io/edrixs/reference/fock_basis.html Retrieves the decimal representation of Fock states for 4 orbitals and 2 occupancy. ```python >>> import edrixs >>> edrixs.get_fock_full_N(4,2) [3, 5, 6, 9, 10, 12] ``` -------------------------------- ### SymKVec.__init__ Source: https://edrixs.github.io/edrixs/_modules/edrixs/wannier_ham.html Initializes a SymKVec object for high symmetry line k-points. ```APIDOC ## SymKVec.__init__ ### Description Initializes a SymKVec object for high symmetry line k-points. ### Method Constructor ### Parameters - **kbase** (3x3 float array) - Optional - Basis of the primitive reciprocal lattice. - **hsymkpt** (float array) - Optional - Starting and end k points along high symmetry lines. - **klen** (float array) - Optional - Length of segments of k points line. ### Example ```python symkvec = SymKVec(kbase=[[1,0,0],[0,1,0],[0,0,1]], hsymkpt=[[0,0,0],[0.5,0,0]], klen=[0,1]) ``` ``` -------------------------------- ### tmat_c2j Source: https://edrixs.github.io/edrixs/reference/basis_transform.html Get the transformation matrix from the complex spherical harmonics to the |j2, jz> basis in which the spin-orbit coupling Hamiltonian is diagonal. ```APIDOC ## tmat_c2j(orb_l) ### Description Get the transformation matrix from the complex spherical harmonics to the |j2, jz> basis in which the spin-orbit coupling Hamiltonian is diagonal. The orbital order is: |j = l - 1/2, -j>, |j = l - 1/2, -j + 1>, ... |j = l - 1/2, +j>, |j = l + 1/2, -j>, |j = l + 1/2, -j + 1>, ..., |j = l + 1/2, +j>. ### Parameters - **orb_l** (int) - Required - Quantum number of orbital angular momentum. ### Returns - **t_c2j** (2d complex array) - The transformation matrix. ``` -------------------------------- ### Create Fock basis with get_fock_bin_by_N Source: https://edrixs.github.io/edrixs/_downloads/9533e398daf1eb62ff3e3e097776acb7/example_00_ed_calculator.ipynb Generates the binary Fock basis for the given number of orbitals and occupancy, then prints it. ```python basis = edrixs.get_fock_bin_by_N(norb, noccu) print(np.array(basis)) ``` -------------------------------- ### Set up and run XAS calculation with xas_1v1c_py Source: https://edrixs.github.io/edrixs/auto_examples/example_02_single_atom_RIXS.html Configures the energy range, temperature, ground state list, geometry angles, and polarization, then calls xas_1v1c_py. The ground states are selected by Boltzmann population threshold. The output shows the expected EDRIXS messages. ```python ominc = np.linspace(11200, 11230, 50) temperature = 300 # in K prob = edrixs.boltz_dist(eval_i, temperature) gs_list = [n for n, prob in enumerate(prob) if prob > 1e-6] thin = 30*np.pi/180 phi = 0 pol_type = [('linear', 0)] xas = edrixs.xas_1v1c_py( eval_i, eval_n, trans_op, ominc, gamma_c=info['gamma_c'], thin=thin, phi=phi, pol_type=pol_type, gs_list=gs_list) ``` ```text edrixs >>> Running XAS ... edrixs >>> XAS Done ! ``` -------------------------------- ### Set temperature for Boltzmann distribution Source: https://edrixs.github.io/edrixs/_downloads/fb3c04d30abd45a0ba95741ec9da2ff1/example_03_AIM_XAS.ipynb Sets the temperature in Kelvin for the Boltzmann distribution of low-lying states. Used in the AIM XAS example. ```python temperature = 300 ``` -------------------------------- ### Initialize spin-orbit coupling parameters from atomic values Source: https://edrixs.github.io/edrixs/_downloads/fb3c04d30abd45a0ba95741ec9da2ff1/example_03_AIM_XAS.ipynb Initializes spin-orbit coupling parameters for the valence electrons in the ground state (zeta_d_i), with the core hole present (zeta_d_n), and for the core hole itself (c_soc) using atomic values from the info dictionary. ```python zeta_d_i = info['v_soc_i'][0] zeta_d_n = info['v_soc_n'][0] c_soc = info['c_soc'] ``` -------------------------------- ### SymKVec.from_hsymkpt Source: https://edrixs.github.io/edrixs/_modules/edrixs/wannier_ham.html Generates high symmetry k points given starting and end points of each segment and the number of points per segment. ```APIDOC ## SymKVec.from_hsymkpt ### Description Generates high symmetry k points given starting and end points of each segment and the number of points per segment. ### Method Method ### Parameters - **nkpt_per_path** (int) - Optional - Number of k points per each segment. Default is 20. ### Example ```python symkvec.from_hsymkpt(nkpt_per_path=30) ``` ``` -------------------------------- ### write_fock_dec_by_N(N, r, fname='fock_i.in') Source: https://edrixs.github.io/edrixs/_modules/edrixs/fock_basis.html Get decimal digitals to represent Fock states, sort them by ascending order and then write them to file. ```APIDOC ## write_fock_dec_by_N(N, r, fname='fock_i.in') ### Description Get decimal digitals to represent Fock states, sort them by ascending order and then write them to file. ### Parameters - **N** (int) - Required - Number of orbitals. - **r** (int) - Required - Number of occupancy. - **fname** (string) - Optional - File name. Default: 'fock_i.in'. ### Returns - **ndim** (int) - The dimension of the Hilbert space. ``` -------------------------------- ### ed_siam_fort Source: https://edrixs.github.io/edrixs/_modules/edrixs/solvers.html Find the ground state of the initial Hamiltonian of a Single Impuirty Anderson Model (SIAM), and also prepare input files, *hopping_i.in*, *hopping_n.in*, *coulomb_i.in*, *coulomb_n.in* for following XAS and RIXS calculations. ```APIDOC ## ed_siam_fort ### Description Find the ground state of the initial Hamiltonian of a Single Impuirty Anderson Model (SIAM), and also prepare input files, *hopping_i.in*, *hopping_n.in*, *coulomb_i.in*, *coulomb_n.in* for following XAS and RIXS calculations. ### Parameters - **comm** (MPI_Comm) - Required - MPI Communicator - **shell_name** (tuple of two strings) - Required - Names of valence and core shells. The 1st (2nd) string in the tuple is for the valence (core) shell. The 1st string can only be 's', 'p', 't2g', 'd', 'f', the 2nd string can be 's', 'p', 'p12', 'p32', 'd', 'd32', 'd52', 'f', 'f52', 'f72'. For example: shell_name=('d', 'p32') indicates a :math:`L_3` edge transition from core :math:`p_{3/2}` shell to valence :math:`d` shell. - **nbath** (int) - Required - Number of bath sites. - **siam_type** (int) - Optional - Type of SIAM Hamiltonian, 0: diagonal hybridization function, parameterized by *imp_mat*, *bath_level* and *hyb*; 1: general hybridization function, parameterized by matrix *hopping*. If *siam_type=0*, only *imp_mat*, *bath_level* and *hyb* are required, if *siam_type=1*, only *hopping* is required. - **v_noccu** (int) - Optional - Number of total occupancy of impurity and baths orbitals, required when do_ed=1, 2 - **static_core_pot** (float) - Optional - Static core hole potential. - **c_level** (float) - Optional - Energy level of core shell. - **c_soc** (float) - Optional - Spin-orbit coupling strength of core electrons. - **trans_c2n** (2d complex array) - Optional - The transformation matrix from the spherical harmonics basis to the basis on which the `imp_mat` and hybridization function (`bath_level`, `hyb`, `hopping`) are defined. - **imp_mat** (2d complex array) - Optional - Impurity matrix for the impurity site, including CF or SOC, for siam_type=0 and the initial configurations. - **imp_mat_n** (2d complex array) - Optional - Impurity matrix for the impurity site, including CF or SOC, for siam_type=0 and the intermediate configurations. If imp_mat_n=None, imp_mat will be used. - **bath_level** (2d complex array) - Optional - Energy level of bath sites, 1st (2nd) dimension is for different bath sites (orbitals), for siam_type=0 and the initial configurations. - **bath_level_n** (2d complex array) - Optional - Energy level of bath sites, 1st (2nd) dimension is for different bath sites (orbitals), for siam_type=0 and the intermediate configurations. If bath_level_n=None, bath_level will be used. - **hyb** (2d complex array) - Optional - Hybridization strength of bath sites, 1st (2nd) dimension is for different bath sites (orbitals), for siam_type=0 and the initial configurations. - **hyb_n** (2d complex array) - Optional - Hybridization strength of bath sites, 1st (2nd) dimension is for different bath sites (orbitals), for siam_type=0 and the intermediate configurations. If hyb_n=None, hyb will be used. - **hopping** (2d complex array) - Optional - General hopping matrix when siam_type=1, including imp_mat and hybridization functions, for siam_type=1 and the initial configurations. - **hopping_n** (2d complex array) - Optional - General hopping matrix when siam_type=1, including imp_mat and hybridization functions, for siam_type=1 and the intermediate configurations. If hopping_n=None, hopping will be used. - **slater** (tuple of two lists) - Optional - Slater integrals for initial (1st list) and intermediate (2nd list) Hamiltonians. The order of the elements in each list should be like this: [FX_vv, FX_vc, GX_vc, FX_cc], where X are integers with ascending order, it can be X=0, 2, 4, 6 or X=1, 3, 5. One can ignore all the continuous zeros at the end of the list. For example, if the full list is: [F0_dd, F2_dd, F4_dd, 0, F2_dp, 0, 0, 0, 0], one can just provide [F0_dd, F2_dd, F4_dd, 0, F2_dp]. All the Slater integrals will be set to zero if slater=None. - **ext_B** (tuple of three float numbers) - Optional - Vector of external magnetic field with respect to global :math:`xyz`-axis. ### Returns None ``` -------------------------------- ### get_fock_basis_by_N_abelian(norb, N, a_list) Source: https://edrixs.github.io/edrixs/_modules/edrixs/fock_basis.html Get decimal digitals to represent Fock states, using some Abelian good quantum number. ```APIDOC ## get_fock_basis_by_N_abelian(norb, N, a_list) ### Description Get decimal digitals to represent Fock states, using some Abelian good quantum number. ### Parameters - **norb** (int) - Required - Number of orbitals. - **N** (int) - Required - Number of total occupancy. - **a_list** (list of int) - Required - Quantum number of the Abelian symmetry for each orbital. ### Returns - **basis** (dict) - A dictionary containing the decimal digitals, the key is good quantum numbers, the value is a list of int. ``` -------------------------------- ### Initialize Crystal Field Matrix Source: https://edrixs.github.io/edrixs/_sources/auto_examples/example_03_AIM_XAS.rst.txt Sets up the crystal field matrix for cubic symmetry using numpy. ```Python ten_dq = 0.56 CF = np.zeros((norb_d, norb_d), dtype=complex) diagonal_indices = np.arange(norb_d) ``` -------------------------------- ### Run a Python script Source: https://edrixs.github.io/edrixs/_sources/user/pythontips.rst.txt The standard command to execute a Python script. ```bash python myscript.py ```