def get_analytic_derivatives_h2(g_num, states_num, atoms, nelec, nalpha, nbeta, atom, coord, complexsymmetric): for gi in range(g_num): mol = gto.Mole() mol.basis = 'sto-3g' mol.unit = 'bohr' mol.atom = [] for atom in range(atoms): pos_vec = np.loadtxt(f"coords.g{gi}.atom{atom}.txt") mol.atom.extend([['H',(pos_vec[0], pos_vec[1], pos_vec[2])]]) mol.build() g0_list = [] for si in range(states_num): g0_s_a = np.loadtxt(f"mo.coeffs.g{gi}.s{si}.a.txt") g0_s_b = np.loadtxt(f"mo.coeffs.g{gi}.s{si}.b.txt") g0_s = uhf_to_ghf(g0_s_a, g0_s_b, nalpha, nbeta) g0_list.append(g0_s) a = np.loadtxt(f"noci.coeffs.g{gi}.txt") e1_noci = get_e1_noci(a, mol, atom, coord, g0_list, nelec, complexsymmetric) bond_length = mol.atom[1][1][2] - mol.atom[0][1][2] with open("analytic_derivatives.txt", "a") as f: f.write(f"{bond_length} {e1_noci}\n")
def get_analytic_derivatives_lih(g_num, states_num, complexsymmetric): for gi in range(g_num): mol = gto.Mole() mol.basis = 'sto-3g' mol.unit = 'bohr' mol.atom = [] pos_vec0 = np.loadtxt(f"coords.g{gi}.atom{0}.txt") pos_vec1 = np.loadtxt(f"coords.g{gi}.atom{1}.txt") mol.atom.extend([['Li', (pos_vec0[0], pos_vec0[1], pos_vec0[2])]]) mol.atom.extend([['H', (pos_vec1[0], pos_vec1[1], pos_vec1[2])]]) mol.build() g0_list = [] for si in range(states_num): g0_s_a = np.loadtxt(f"mo.coeffs.g{gi}.s{si}.a.txt") g0_s_b = np.loadtxt(f"mo.coeffs.g{gi}.s{si}.b.txt") g0_s = uhf_to_ghf(g0_s_a, g0_s_b, 2, 2) g0_list.append(g0_s) a = np.loadtxt(f"noci.coeffs.g{gi}.txt") e1_noci = get_e1_noci(a, mol, 1, 2, g0_list, 4, complexsymmetric) bond_length = mol.atom[1][1][2] - mol.atom[0][1][2] with open("analytic_derivatives.txt", "a") as f: f.write(f"{bond_length} {e1_noci}\n")
g0uhfbeta0 = np.array([[-1.56782302496071901388, 0.52754646684681505420], [1.56782302496071901388, 0.52754646684681505420]]) g0ghf2 = uhf_to_ghf(g0uhfalpha0, g0uhfbeta0, 1, 1) # sigma u^2 # g0rhf2 = np.array([[-1.56782302496071901388, 0.52754646684681505420], # [1.56782302496071901388, 0.52754646684681505420]]) # g0ghf2 = rhf_to_ghf(g0rhf2, nelec) #energy = 1.1555300839 a_g2u2 = [0.9971103, -0.0759676] a_g2ug = [1, 0] #??? g0_list = [g0ghf1, g0ghf2] # g0_list = [g0ghf2] g1_list = get_g1_list(mol, atom, coord, g0_list, nelec, False) e1 = get_e1_noci(a_g2ug, mol, atom, coord, g0_list, nelec, False) print("e1_noci:\n", e1) "Slow troubleshooting" print("0_g0 sigma g 2:\n", g0ghf1) print("0_g1 sigma g 2 (differentiated):\n", g1_list[0]) # print("1_g0 sigma g sigma u:\n", g0ghf2) s1mat = get_s1mat(mol, atom, coord, g0_list, g1_list, nelec, False) print("s1mat:\n", s1mat) h1mat = get_h1mat(mol, atom, coord, g0_list, g1_list, nelec, False) print("h1mat:\n", h1mat)
from hamiltonian_derivative import get_h1mat from energy_derivative import get_e1_noci from h3states.h3_states import h3_states2, h3_states4 h3 = h3_states2() # h3 = h3_states4() mol = h3.mol nelec = h3.nelec atom = h3.atom coord = h3.coord g00 = h3.g00 g10 = h3.g10 # g20 = h3.g20 # g30 = h3.g30 a = h3.a g0_list = [g00, g10] # g0_list = [g00, g10, g20, g30] g1_list = get_g1_list(mol, atom, coord, g0_list, nelec, False) np.set_printoptions(precision=6) s1mat = get_s1mat(mol, atom, coord, g0_list, g1_list, nelec, False) print("s1mat:\n", s1mat) h1mat = get_h1mat(mol, atom, coord, g0_list, g1_list, nelec, False) print("Hamiltonian matrix:\n", h1mat) e1_noci = get_e1_noci(a, mol, atom, coord, g0_list, nelec, False) print("e1_noci:\n", e1_noci) # e1_scf = write_e1_single(mol, nelec, atom, coord, False, g00) # print("e1_scf for g00 state:\n", e1_scf)