I am doing a code that can calculate the hartree-fock energy. I want to form the two-electrons integral by reading the data from the input like this one below. The first four number are the indices of array(Matrix) and not all the indices are written because some of them are the same such as 2 1 1 1 == 1 2 1 1 and the float number is the value of index and value of my two-electrons that I want to form an array using these float number
1 1 1 1 0.7746059439198979
2 1 1 1 0.4441350695399573
2 1 2 1 0.2970603935859659
2 2 1 1 0.5696940113278337
2 2 2 1 0.4441350695399575
2 2 2 2 0.7746059439198979
I use my code and I didn't get what I want.
My code
electron2 = []
for line in open('Two_Electron.txt'):
r,c,d,e,v = line.split()
r = int(r)-1
c = int(c)-1
d = int(d)-1
e = int(e)-1
v = float(v)
if c == 0:
electron2.append( [v] )
else:
electron2[-1].append(v)
for i in range(len(electron2)-1):
for j in range(i+1,len(electron2)):
for k in range(len(electron2)-1):
for l in range(k+2,len(electron2)):
electron2[i].append( electron2[j][i] )
electron2[k].append( electron2[l][k] )
V_ee = np.array(electron2)
print(V_ee)
The output I got is
[list([0.7746059439198979, 0.4441350695399573, 0.2970603935859659, 0.2970603935859659, 0.2970603935859659, 0.2970603935859659])
list([0.4441350695399573, 0.5696940113278337])
list([0.2970603935859659, 0.5696940113278337, 0.4441350695399575, 0.7746059439198979])]
The output I want to get
[[[[0.77460594 0.4441351 ]
[0.4441351 0.56969403]]
[[0.4441351 0.29706043]
[0.29706043 0.4441351 ]]]
[[[0.4441351 0.29706043]
[0.29706043 0.4441351 ]]
[[0.56969403 0.4441351 ]
[0.4441351 0.77460594]]]]
What did I do wrong?