주 콘텐츠로 건너뛰기
이 프로젝트는 베타 단계입니다. 버그를 발견하셨나요? GitHub 이슈 만들기. 질문이나 아이디어가 있으신가요? Discussions에서 질문하기 — 피드백을 기다립니다!
이 페이지의 번역 품질은 어떻습니까?

구성 풀에 페르미온 전이 추가하기

여기서는 각 전자 구성에 전이 연산자를 작용시켜 얻은 전자 구성 풀을 확장하는 기능을 보여 드립니다.

다음 유형의 단일 전자 호핑을 추가하는 방법을 보여 드립니다:

cpσ†cqσ∣x⟩c^\dagger_{p\sigma} c_{q\sigma} |\textbf{x} \rangle

여기서 p,q=1,...,Norbp, q = 1, ..., N_\textrm{orb}, σ∈{↑,↓}\sigma \in \{ \uparrow, \downarrow\}이며, 전자 구성 배치에 있는 모든 ∣x⟩|\textbf{x} \rangle에 대해 적용합니다. 먼저 무작위 전자 구성 배치를 생성합니다:

# Added by doQumentation — installs the packages this notebook needs if they are missing
import importlib.util

_needed = {"numpy": "numpy", "qiskit_addon_sqd": "qiskit-addon-sqd"}
_missing = [pip for module, pip in _needed.items()
if importlib.util.find_spec(module) is None]
# One at a time, so a package that fails to install does not block the others
for _pip in _missing:
%pip install -q {_pip}
if not _missing:
print("\u2713 All required packages are installed")
import numpy as np

n_qubits = 8
n_orb = n_qubits // 2

rand_seed = 22
np.random.seed(rand_seed)

# Generate some random bitstrings for testing
def random_bitstrings(n_samples, n_qubits):
return (
np.round(np.random.rand(n_samples, n_qubits))
.astype("int")
.astype("bool")
)

bitstring_matrix = random_bitstrings(100, n_qubits)

들뜸 연산자는 길이가 페르미온 노드(또는 Qubit)의 수와 같은 numpy 배열 안에 지정합니다. 배열의 각 요소는 다음 값을 가질 수 있는 문자열이어야 합니다:

  • 'I': Identity

  • '+': 생성 연산자

  • '-': 소멸 연산자

같은 스핀 종 사이에서 가능한 모든 단일 전자 전이를 생성합니다.

transitions_single = np.array(
[
["I" for i in range(2 * n_orb)]
for j in range(4 * (n_orb**2 - n_orb) // 2 + 1)
]
)
count = 1
for i in range(n_orb):
for j in range(i + 1, n_orb):
# spin up
transitions_single[count, i] = "+"
transitions_single[count, j] = "-"
count += 1
transitions_single[count, i] = "-"
transitions_single[count, j] = "+"
count += 1

# spin down
transitions_single[count, i + n_orb] = "+"
transitions_single[count, j + n_orb] = "-"
count += 1
transitions_single[count, i + n_orb] = "-"
transitions_single[count, j + n_orb] = "+"
count += 1

print(transitions_single)
[['I' 'I' 'I' 'I' 'I' 'I' 'I' 'I']
['+' '-' 'I' 'I' 'I' 'I' 'I' 'I']
['-' '+' 'I' 'I' 'I' 'I' 'I' 'I']
['I' 'I' 'I' 'I' '+' '-' 'I' 'I']
['I' 'I' 'I' 'I' '-' '+' 'I' 'I']
['+' 'I' '-' 'I' 'I' 'I' 'I' 'I']
['-' 'I' '+' 'I' 'I' 'I' 'I' 'I']
['I' 'I' 'I' 'I' '+' 'I' '-' 'I']
['I' 'I' 'I' 'I' '-' 'I' '+' 'I']
['+' 'I' 'I' '-' 'I' 'I' 'I' 'I']
['-' 'I' 'I' '+' 'I' 'I' 'I' 'I']
['I' 'I' 'I' 'I' '+' 'I' 'I' '-']
['I' 'I' 'I' 'I' '-' 'I' 'I' '+']
['I' '+' '-' 'I' 'I' 'I' 'I' 'I']
['I' '-' '+' 'I' 'I' 'I' 'I' 'I']
['I' 'I' 'I' 'I' 'I' '+' '-' 'I']
['I' 'I' 'I' 'I' 'I' '-' '+' 'I']
['I' '+' 'I' '-' 'I' 'I' 'I' 'I']
['I' '-' 'I' '+' 'I' 'I' 'I' 'I']
['I' 'I' 'I' 'I' 'I' '+' 'I' '-']
['I' 'I' 'I' 'I' 'I' '-' 'I' '+']
['I' 'I' '+' '-' 'I' 'I' 'I' 'I']
['I' 'I' '-' '+' 'I' 'I' 'I' 'I']
['I' 'I' 'I' 'I' 'I' 'I' '+' '-']
['I' 'I' 'I' 'I' 'I' 'I' '-' '+']]

이제 bitstring_matrix의 구성에 전이 연산자를 적용합니다:

from qiskit_addon_sqd.fermion import enlarge_batch_from_transitions

bitstring_matrix_aug = enlarge_batch_from_transitions(
bitstring_matrix, transitions_single
)

print(bitstring_matrix_aug.shape)
print(bitstring_matrix_aug)
(723, 8)
[[False False False ... False False True]
[False True False ... True False False]
[ True True True ... True False True]
...
[ True False True ... False False True]
[ True True True ... True False True]
[False False False ... False False True]]