I am trying to multiply a matrix by constants I have defined as the following:
E1 = "E1"
E2 = "E2"
J = "J"
However then when I try to multiply them by the matrices defined below I end up with an error:
# Defining the sigma functions and Identity matrices:
sigx = np.array([[0,1],[1,0]])
sigy = np.array([[0,-1j],[1j,0]])
sigz = np.array([[1,0],[0,-1]])
I1 = np.array([[1,0],[0,1]])
I2 = I1
# Trying to structure a Hamiltonian
H1 = np.kron(((E1)*(sigz)),I2)
H2 = np.kron((E2*(I1)),(sigz))
H3 = J*((np.kron((sigx),(sigx)))+(np.kron((sigy),(sigy))))
print(H1)
print(H2)
print(H3)
# Overall Hamiltonian Matrix
Hs = H1 + H2 + H3
print(Hs)
The script works if I do not define E1, E2 or J beforehand as shown above but it only works because python automatically assigns them a value of 1,2,3. How can I get it so E1,E2 and J appear in the matrix operation outputs?