Created
August 17, 2021 19:23
-
-
Save ncrubin/d5529644d1aa4e65a183206f4b6f6bd0 to your computer and use it in GitHub Desktop.
problem between computer and screen?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
from itertools import product | |
def read_dr_li_data(ofile): | |
with open(ofile, 'r') as fid: | |
text = fid.read().strip().split('\n') | |
file_name = text[0] | |
nelectrons = int(text[1].split('=')[-1]) | |
norb = int(text[2].split('=')[-1]) | |
nsorb = 2 * norb | |
S2 = int(text[3].split('=')[-1]) | |
L2 = int(text[4].split('=')[-1]) | |
J2 = int(text[5].split('=')[-1]) | |
Jz = int(text[6].split('=')[-1]) | |
print(file_name) | |
print(nelectrons) | |
print(norb) | |
print("S2 = ", S2) | |
print("L2 = ", L2) | |
print("J2 = ", J2) | |
print("JZ = ", Jz) | |
tpdm = np.zeros((nsorb,) * 4, dtype=np.complex128) | |
for line in text[7:]: | |
tline = line.strip() | |
tline = tline.replace('(', '') | |
tline = tline.replace(')', '') | |
tline = tline.split(',') | |
i, j, k, l = [int(xx) for xx in tline[:4]] | |
real_val, imag_val = float(tline[4]), float(tline[5]) | |
print(i, j, k, l, complex(real_val, imag_val)) | |
print(tline) | |
tpdm[i, j, k, l] = float(real_val) + 1j * float(imag_val) | |
return file_name, nelectrons, norb, S2, L2, J2, Jz, tpdm | |
if __name__ == "__main__": | |
print(os.getcwd()) | |
file_name, nelectrons, norb, S2, L2, J2, Jz, tpdm = \ | |
read_dr_li_data('c_sto-3g_tpdm/c_sto-3g_0_0_0_0.out.dat') | |
print(np.einsum('ijij', tpdm)) | |
from itertools import permutations | |
for perm in permutations([0, 1, 2, 3]): | |
new_tpdm = tpdm.transpose(perm) | |
print(perm, np.einsum('ijij', new_tpdm), np.einsum('ijji', new_tpdm), np.einsum('iijj', new_tpdm)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment