Let's do some imports
In [1]:
import numpy as np
import itertools
Now we define the states available
In [2]:
states = [[0,0],[1,0],[0,1],[1,1]]
states = [np.array(state) for state in states]
We can get all the combinations of the states as follows
In [3]:
list(itertools.combinations(states,2))
Out[3]:
Perform an XOR between the states which is equivalent to a hop process
In [4]:
for pair in itertools.combinations(states,2):
xor = np.logical_xor(*pair).astype(int)
print(f"Left state {pair[0]}, right state {pair[1]}, XOR result {xor}")
Let's define a helper function to determine if a transition is allowed. Basically, in this problem, the process has to conserve particle number in the sense that a hop only involves one electron.
In [5]:
def allowed(jump):
if np.sum(jump) != 1:
return 0
return 1
In [6]:
for pair in itertools.combinations(states,2):
xor = np.logical_xor(*pair).astype(int)
print(f"Left state {pair[0]}, right state {pair[1]}: allowed {bool(allowed(xor))}")
Now, building the matrix by calculating the combinations and then adding the transpose to have a symmetric matrix.
In [7]:
matrix = np.zeros((4,4))
for i in range(len(states)):
for j in range(i):
matrix[i][j] = allowed(np.logical_xor(states[i], states[j]).astype(int))
In [8]:
matrix+matrix.T
Out[8]: