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, and the lower-triangular part is inferred from symmetry.
16
17U_m = [ 2.0, 4.0]
18U1_mn = [[ 0.0, 1.5
19 0.0, 0.0]]
20U2_mn = [[ 0.0, 1.0
21 0.0, 0.0]]
22J_mn = [[ 0.0, 0.5
23 0.0, 0.0]]
24"""
25import os
26
27os.environ["JAX_PLATFORMS"] = "cpu"
28os.environ["XLA_PYTHON_CLIENT_PREALLOCATE"] = "false"
29from jax import config
30
31config.update("jax_enable_x64", True)
32
33import numpy as np
34
35import autohf
36
37def make_T_multiband(Nx, Ny, Nbands, t, xperiodic=True, yperiodic=True):
38 Nsites = Nx * Ny
39
40 # Build single-band hopping on (Nsites, Nsites)
41 T_band = np.zeros((Nsites, Nsites))
42 for ix in range(Nx):
43 for iy in range(Ny):
44 s = ix * Ny + iy
45 if ix + 1 < Nx or xperiodic:
46 s_nb = ((ix + 1) % Nx) * Ny + iy
47 T_band[s, s_nb] = -t
48 T_band[s_nb, s] = -t
49 if iy + 1 < Ny or yperiodic:
50 s_nb = ix * Ny + (iy + 1) % Ny
51 T_band[s, s_nb] = -t
52 T_band[s_nb, s] = -t
53
54 # Uniform across bands: shape (Nbands, Nsites, Nsites)
55 T_intraband = np.stack([T_band] * Nbands, axis=0)
56
57 N = Nbands * Nsites
58 T = np.zeros((N, N))
59 for b in range(Nbands):
60 T[b::Nbands, b::Nbands] = T_intraband[b]
61 return T
62
63
64def make_interband_matrix(Nsites, Nbands, val):
65 """NxN upper-triangular matrix with `val` at every same-site inter-band pair."""
66 M_band = np.zeros((Nbands, Nbands))
67 M_band[np.triu_indices(Nbands, k=1)] = val
68 M = np.kron(np.eye(Nsites), M_band)
69 return M
70
71
72#### Define Parameters
73Nx, Ny = 6, 1
74Nbands = 2
75Nsites = Nx * Ny
76N = Nsites * Nbands
77xperiodic = True
78yperiodic = False
79
80t = 1.0
81U_val = 2.0
82U1_val = 1.5
83U2_val = 1.0
84J_val = 0.5
85
86Ne = 6
87steps = 500
88batch_size = 10
89
90hf_settings = {
91 "verbose": False,
92 "steps": steps,
93 "opt_method": "lbfgs",
94 "ansatz": "SD_ROT",
95 "batch_size": batch_size,
96 "gpu": False,
97 "nelec": (Ne, Ne),
98 "noncollinear": False,
99}
100
101
102T = make_T_multiband(Nx, Ny, Nbands, t, xperiodic=xperiodic, yperiodic=yperiodic)
103
104U1_mat = make_interband_matrix(Nsites, Nbands, U1_val)
105U2_mat = make_interband_matrix(Nsites, Nbands, U2_val)
106J_mat = make_interband_matrix(Nsites, Nbands, J_val)
107
108H = autohf.AutoHFHamiltonian(
109 T=(T, T),
110 U=U_val, # scalar → uniform on-orbital Hubbard
111 U1=U1_mat, # inter-orbital, opposite-spin density-density
112 U2=U2_mat, # inter-orbital, same-spin density-density
113 J=J_mat, # Hund's coupling
114 Nx=Nx,
115 Ny=Ny,
116 Nbands=Nbands,
117)
118
119
120autohf.lattice_hf(H, settings=hf_settings)