1r"""
2Hubbard-Kanamori model on a 1-D chain with 2-bands per site.
3
4If site indices are :math:`i`, :math:`j` and band indices is :math:`m`, :math:`n`,
5The Hamiltonian is given by:
6
7.. math::
8 H = -t \sum_m \sum_{\langle i, j \rangle, \sigma} (c_{i\sigma}^\dagger c_{j\sigma} + h.c.)
9 + \sum_m U_m \sum_i n_{i\uparrow} n_{i\downarrow}
10 + \sum_{m < n} U^1_{mn} \sum_i (n_{im\uparrow} n_{in\downarrow} + n_{im\downarrow} n_{in\uparrow}) )
11 + \sum_{m < n} U^2_{mn} \sum_i (n_{im\uparrow} n_{in\uparrow} + n_{im\downarrow} n_{in\downarrow})
12 + \sum_{m < n} J_{mn} \sum_i (c_{im\uparrow}^\dagger c_{in\uparrow} c_{in\downarrow}^\dagger c_{im\downarrow} + h.c.)
13
14In this example, we have 2 bands, and make the following choices for the interaction parameters. Note that
15only the upper-triangular part of the interaction matrices are specified,
16and the lower-triangular part is inferred from symmetry.
17
18U_m = [ 2.0, 4.0]
19U1_mn = [[ 0.0, 1.5
20 0.0, 0.0]]
21U2_mn = [[ 0.0, 1.0
22 0.0, 0.0]]
23J_mn = [[ 0.0, 0.5
24 0.0, 0.0]]
25""" # noqa: E501
26import os
27
28os.environ["JAX_PLATFORMS"] = "cpu"
29os.environ["XLA_PYTHON_CLIENT_PREALLOCATE"] = "false"
30from jax import config
31
32config.update("jax_enable_x64", True)
33
34import numpy as np
35
36import autohf
37
38def make_T_multiband(Nx, Ny, Nbands, t, xperiodic=True, yperiodic=True):
39 Nsites = Nx * Ny
40
41 # Build single-band hopping on (Nsites, Nsites)
42 T_band = np.zeros((Nsites, Nsites))
43 for ix in range(Nx):
44 for iy in range(Ny):
45 s = ix * Ny + iy
46 if ix + 1 < Nx or xperiodic:
47 s_nb = ((ix + 1) % Nx) * Ny + iy
48 T_band[s, s_nb] = -t
49 T_band[s_nb, s] = -t
50 if iy + 1 < Ny or yperiodic:
51 s_nb = ix * Ny + (iy + 1) % Ny
52 T_band[s, s_nb] = -t
53 T_band[s_nb, s] = -t
54
55 # Uniform across bands: shape (Nbands, Nsites, Nsites)
56 T_intraband = np.stack([T_band] * Nbands, axis=0)
57
58 N = Nbands * Nsites
59 T = np.zeros((N, N))
60 for b in range(Nbands):
61 T[b::Nbands, b::Nbands] = T_intraband[b]
62 return T
63
64
65def make_interband_matrix(Nsites, Nbands, val):
66 """NxN upper-triangular matrix with `val` at every same-site inter-band pair."""
67 M_band = np.zeros((Nbands, Nbands))
68 M_band[np.triu_indices(Nbands, k=1)] = val
69 M = np.kron(np.eye(Nsites), M_band)
70 return M
71
72
73#### Define Parameters
74Nx, Ny = 6, 1
75Nbands = 2
76Nsites = Nx * Ny
77N = Nsites * Nbands
78xperiodic = True
79yperiodic = False
80
81t = 1.0
82U_val = 2.0
83U1_val = 1.5
84U2_val = 1.0
85J_val = 0.5
86
87Ne = 6
88steps = 500
89batch_size = 10
90
91hf_settings = {
92 "verbose": False,
93 "steps": steps,
94 "opt_method": "lbfgs",
95 "ansatz": "SD_ROT",
96 "batch_size": batch_size,
97 "gpu": False,
98 "nelec": (Ne, Ne),
99 "noncollinear": False,
100}
101
102
103T = make_T_multiband(Nx, Ny, Nbands, t, xperiodic=xperiodic, yperiodic=yperiodic)
104
105U1_mat = make_interband_matrix(Nsites, Nbands, U1_val)
106U2_mat = make_interband_matrix(Nsites, Nbands, U2_val)
107J_mat = make_interband_matrix(Nsites, Nbands, J_val)
108
109H = autohf.AutoHFHamiltonian(
110 T=(T, T),
111 U=U_val, # scalar → uniform on-orbital Hubbard
112 U1=U1_mat, # inter-orbital, opposite-spin density-density
113 U2=U2_mat, # inter-orbital, same-spin density-density
114 J=J_mat, # Hund's coupling
115 Nx=Nx,
116 Ny=Ny,
117 Nbands=Nbands,
118)
119
120
121autohf.lattice_hf(H, settings=hf_settings)