Sample from Slater determinants¶
A Slater determinant is a state obtained by applying an orbital rotation to an electronic configuration. The ffsim.sample_slater function draws electronic configuration samples from a Slater determinant specified by an orbital rotation and reference configuration. Unlike ffsim.sample_state_vector, which requires the full state vector as input, sample_slater
implements an efficient algorithm that works directly with the orbital rotation representation, allowing it to scale to much larger systems. This guide demonstrates the use of sample_slater on a few example systems.
Hartree-Fock state¶
The simplest Slater determinant is the Hartree-Fock state, in which the lowest \(N_\alpha\) spin-up and \(N_\beta\) spin-down orbitals are occupied, and no orbital rotation is applied. Since all probability is concentrated on a single configuration, every shot returns the same bitstring.
[1]:
import numpy as np
import ffsim
rng = np.random.default_rng(12345)
norb = 10
n_alpha = 5
n_beta = 3
samples = ffsim.sample_slater(norb, (range(n_alpha), range(n_beta)), shots=5, seed=rng)
samples
[1]:
['00000001110000011111',
'00000001110000011111',
'00000001110000011111',
'00000001110000011111',
'00000001110000011111']
Random Slater determinant¶
The following code cell samples a random Slater determinant with a few hundred orbitals and electrons.
[2]:
norb = 500
n_alpha = 100
n_beta = 100
orbital_rotation = ffsim.random.random_unitary(norb, seed=rng)
occupied_orbitals = (range(n_alpha), range(n_beta))
samples = ffsim.sample_slater(
norb, occupied_orbitals, orbital_rotation, shots=10, seed=rng
)
samples
[2]:
['0000000000110000011000000010000001000011001100000101000100111001011000000000000101000000000001000000000000000000010001000000000010100100000000000001000110001000000100000100001000001001001010000001000000000000110000100100100000111100101001011000010101000000000000100100000001100000100100000110000010100100000000000100100000001000010001000001010000100000101100100000001000000000000000000010101000100000000000000000000001000001000000000000000010000000000000100001000001001111000000000111000010100000100011000010001000000000000010001000000011000000000000010010000000100000000001001001000000000000000100111001000100000010000000001000001010001010000001110000000001000000000001000001000101011000000000001000100000000000100000000100010000000000001000000100000000110000000010000100000010100001100000011000110100000001100000001000000001000100001100100100001000000010010010000001100000000000000000000001000000100100011010001010010000000000010100100110011010100000101011000000000011010100000101000100000000000000',
'0010010000000000000010000000001110000010000010001110000011000010000110000011000100000100010010000000000000001000100000000100001000001001000000000101000010000001000000000000001010000000001010000000010000100000000000000000000100000000001110000000100100000001001010100100000000100000000100001110010101101000011000000000000010101011000000000000000110110011000001000101000101100000000000000100000010000001100000000010000001100000000100000010000100010000000001101000100000000000001100001100000010000000001100100000001011010000001000001000100001000001001100000100000000000000000000000000000001010000000000000101000100000001000000101001001000000010000000000000100001000000000000000000100100010000001001001101110000000000001000000100000000000010001000010000100000010000000000000000100000101100000010100100100010000000000000000010010000000000110100100111011010010010010000000000011101000000000001001000001100100000010000000010000010001101010000100000000100100000001000000101010100000010000000010001001111010100',
'1101000000000000000011000100100101000100100010000010000001000000001000000101000000000000101000000000000000000101101000000000001000000000000110000001110000000000000011000000000000000010100011000000000000001000000000110000011001000000000000100100100101100001000010001000011110110100000000000101001000100010000000010000010000100100100000000010001000100001000011000010000100000101000000000001000000100000000000000000001000100000000101010000001000001100100001010010001000000100111000000001000010001100000000110000000010000000000000000001100000000000000001000011001000100011000000000100000000001000100010001001000000000000000000010100000000000100100001011000111100000001000000000001000010010001000000010000000000100000011100010000001010010010000000001000000011100100000010000100000010000011010100000000000000000010100010010100100010000001000100000000110010010100000000110000000000001010000111000000010101000100100000000000000100010011000010110000000001011001000000100001000000000001001100100000001000000000',
'1100011101100100111000100000000010110000000010000000100000000010000000000100101000001000100100000001000000000000001000010001000000000010010100010000010011110000000001000100000001100100100100000000000000000000100000000000000011010001110010001000000010000011100000010000000100001000011001000001100001000000001000000010011100000000010000000000000000000100001000100000000000000001010000010000000000011100010010000000000000001100010000110001000001000100100000100000001000000000000010000110000000010000100100100111000000001000100010100010000000100000100010100011010000000100001000000000001110000000001000000110101000000000000100110000001000000000000010110000100011001001000000110000000000000000010000010000011000100110000100110001000000000000000001100000000000000000000100000001001000000100100100000001000000100010101100000101000011100000000000000100000010100000000000010000100000000010100000000000001101001000000000001000000000000000100000010011001110000000001001001100000011010000010000100001000000000100',
'1000100100010001101100000100000000000000000000000011000000001000001000000001010010000100000000000100100000110000000000000010000001100100001000001100001010000000000000001100100001000000110100000000100000101000010010000100011110100000000000010001010000000000001000011000101001000101000100100110000000010001000110100000001001000000000100000000110001010011000010000110000000000000010000000000000001010000010001000000000000000001000100101000000000001000001000100010001100000011000001000000100100000000000011001001011000011101100010010000010000010011001000101000000010000110000010000100000000000000000000000000001000101010010001000100000001000110000000001000100000001000000000100000010110000000001000000000100000100000000001000100000000010101010001000100000000000100001110000000000000000100000100000000000000000000111000000000011010000000000101010100100000000000000000010000001000101001000011000000001000000000010000001100001000001001010000000000000100001010100000000001100000100100000001101010001000100100',
'0010000001000100000000010000100010000101000000001000000100000011011000000000010000000110000100000101000010011010000100010010001100000101101000100100000000101000000000000000011011000000000101000010000011000000011000000000001001000000000000000001011000010000000000010011001100101100100000001000000000001000000001000100001000001000100010000000000001100001001000000000010000001010110000001000001000010010000001100010110010001001100000000000000100001010000000000000000000000000000000000000001100011000000001100000011000000000011000000100000000000000000001100110001000000001000110100001000110100010100010001000010000001101100010101010000000000000000100000001000000000001000000000000100000001000000100000000000110000001000001000000100101000010000000000100010001111010010000001000000001000001000101001010110000000010100000000001000000000001001000100000000100100001000000010000000000010111000010010000010000001110010000000010000010000000000000000010000001001000001001000010000010001010100000000000100000001100',
'0000001100100000000000000100000000000000001000000000001010000000000000000001000000000100011010011000000000011000010000110011001001001000001000001001000000000000010000000001000000000000000000000010100000010011010011010000001001100001000010001001010000100100101000101000110000000100000000100110100001000000010000100000000000000000101000000011010001000110100000001000010010000010000000101010110000010010001000000100000000010001110000000010000100101100000001000000001000000010000100000000000000110000001010001000110000000000100000000000000001000001000100111110000000100000000000000101000000000000000100010000010010001010001000001000000010001010000110110000001000100000000110010000010000001000010001000000001100001100100001000000000100000000000000110000010100010000001000100011000000110001010000000000100000001000010000001011000100000000000000000000000000100010010100011010000010010000000110110001000000000000100100000100100110001000000100000000010000100000000000100000010000000000001000001000001011010010',
'0001000000010000010100010100000000010110101000100111000100100100000000100010100100100000101000000010000000100100000001110000000000000001000000000000000000011000100000010010000010000000000001110000000000000100010000010000000000000010000010000010001000001000000000001010000100100000001010010001000000001000000010010001001100010110001100000100000100000001000000000101000000101001000000000000000100000101000100000000011000111100000000000010000000000100010000000000010100101000000010100000000010101110000010000001001000000000010000010010000100111100000001100000000000001100000110000001001100001001100000110000100001011100000100100000000100100001000001000000000000000100001001000000001110000001010000000100000000000000010000001100001000110011000100000010100000001000000011110010000000001011000010000000000000000000000000000010000000100010010110000000000000010000000010000010000101010010000000100000000010010100110000000000100100000000001000010000010000100001000000000001000010110000000001000000001000011000',
'0101100000000000101001001110010000000010001000000100000110101000010000100000101010000010010000000000000001001000001000010000000010100000000000000000000100000010000000010000000000100000001100000101010000000000101010000001000000001000000101100100000100100010100100000000000000000000101000001110000000000000000000011001010000100101000001000000010100000001000000000010000001001000100000010010000000000000101011000111010000000100000000000100000100010010010100000000000100000101000000001010001101001000000101000001001000000001000000001100010100100000000100011001001000000000110000000000000000000000000001010000001000010010000000100010111000000100000010111000000010000110000100000100000001010111000001000001010000001000111000000101000000000000000101101000000000000000000000000000101101000000100101111000000100000000000101010000000000110000100000001000000000000001000000010000010001001000101010000101000000000000000101000000000000000000111010010000101000110000000100000101000000001000000000001100000000100000',
'0000000010000100100000001000001000000011010000000001000000100000001000010010000000000001000011101000001011000110000101000110001100000000000010000100000001000010000000000001000000001000000001000100001000101000100101000010000010100000100100000100000010010000000000100000000000110000000010110000100001001000010000001100000001000001010000000010001000000000001000010110011000101100000100100000100100110001000000010010001001001010000100000000000001000000010100100000100000000100000000001010100000000000000000000000100000000100101000001000000100100110001000100010001100000001110111110101010010100010101000100100000010001001000010100000010000010000000110100100000000000001000100001000100100000010010000000001101010000000100000000000000000100000010001000010010000000000000000010000000001000000000000001101100000000000000000000010000100000000100001000011110101000000110001011000000001001000000000000100100000001000011000000100000000000000000000000100000000000000011000000001000001000000000001010001100000001100']
Tight-binding model¶
Our last example is the ground state of a tight-binding model of spinless fermions on a one-dimensional chain, at half filling. The Hamiltonian is given by
The Hamiltonian is diagonal in a basis of single-particle orbitals, and the ground state is constructed by filling the lowest-energy orbitals.
[3]:
from collections import Counter
norb = 20
nelec = 10 # half-filling
# Construct the matrix encoding the Hamiltonian
tunneling = 1.0
mat = np.diag(-tunneling * np.ones(norb - 1), k=1) + np.diag(
-tunneling * np.ones(norb - 1), k=-1
)
# Columns of orbital_rotation are the single-particle orbitals, sorted by energy
energies, orbital_rotation = np.linalg.eigh(mat)
# Fill the lowest-energy orbitals
occupied_orbitals = list(range(nelec))
print(f"Ground state energy: {sum(energies[occupied_orbitals])}")
# Sample electronic configurations
samples = Counter(
ffsim.sample_slater(
norb, occupied_orbitals, orbital_rotation, shots=10_000, seed=rng
)
)
samples.most_common(10)
Ground state energy: -12.381489999654752
[3]:
[('10101001010101101010', 12),
('01010101010101011010', 11),
('01010101011010101010', 11),
('10101010101010010101', 11),
('10101010101010101010', 10),
('01010101011001010101', 10),
('01101010101010101001', 9),
('10101010101010100101', 9),
('01011010101010101010', 8),
('10101010100101010110', 8)]