def h1_moToIAO(parms, printvals=False): #LOAD IN IAOS act_iao = [5, 9, 6, 8, 11, 12, 7, 13, 1] iao = np.load('../../../pyscf/ub3lyp_full/b3lyp_iao_b.pickle') iao = iao[:, act_iao] #LOAD IN MOS act_mo = [5, 6, 7, 8, 9, 10, 11, 12, 13] chkfile = '../../../pyscf/chk/Cuvtz_r1.725_s1_B3LYP_1.chk' mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) mo = m.mo_coeff[:, act_mo] s = m.get_ovlp() #IAO ordering: ['del','del','yz','xz','x','y','z2','z','s'] #MO ordering: dxz, dyz, dz2, delta, delta, px, py, pz, 4s #es,edpi,edz2,edd,epi,epz,tpi,tdz,tsz,tds=parms #e=np.diag([edpi,edpi,edz2,edd,edd,epi,epi,epz,es]) es, epi, epz, tpi, tdz, tsz, tds = parms ed = 0 e = np.diag([ed, ed, ed, ed, ed, epi, epi, epz, es]) e[[0, 1, 5, 6], [5, 6, 0, 1]] = tpi e[[2, 7], [7, 2]] = tdz e[[8, 7], [7, 8]] = tsz e[[8, 2], [2, 8]] = tds mo_to_iao = reduce(np.dot, (mo.T, s, iao)) e = reduce(np.dot, (mo_to_iao.T, e, mo_to_iao)) e[np.abs(e) < 1e-10] = 0 e = (e + e.T) / 2 return e
def h1_moToIAO(printvals=False): #LOAD IN IAOS act_iao = [5, 9, 6, 8, 11, 12, 7, 13, 1] iao = np.load('../../../pyscf/ub3lyp_full/b3lyp_iao_b.pickle') iao = iao[:, act_iao] #LOAD IN MOS act_mo = [5, 6, 7, 8, 9, 10, 11, 12, 13] chkfile = '../../../pyscf/chk/Cuvtz_r1.725_s1_B3LYP_0.chk' mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) mo = m.mo_coeff[:, act_mo] s = m.get_ovlp() #IAO ordering: ['del','del','yz','xz','x','y','z2','z','s'] #MO ordering: dxz, dyz, dz2, delta, delta, px, py, pz, 4s e = np.diag(m.mo_energy[act_mo]) * 27.2114 if (printvals): w, vr = np.linalg.eigh(e) print('MO eigenvalues, Jsd=0 ------------------------------------') print(w) mo_to_iao = reduce(np.dot, (mo.T, s, iao)) e = reduce(np.dot, (mo_to_iao.T, e, mo_to_iao)) e[np.abs(e) < 1e-10] = 0 e = (e + e.T) / 2 if (printvals): w, vr = np.linalg.eigh(e) print('IAO eigenvalues, Jsd=0 ------------------------------------') print(w) return e
def format_df_iao(df): df['beta'] = -1000 #LOAD IN IAOS act_iao = [5, 9, 6, 8, 11, 12, 7, 13, 1] iao = np.load('../../../pyscf/ub3lyp_full/b3lyp_iao_b.pickle') iao = iao[:, act_iao] #LOAD IN MOS act_mo = [5, 6, 7, 8, 9, 10, 11, 12, 13] chkfile = '../../../pyscf/chk/Cuvtz_r1.725_s1_B3LYP_1.chk' mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) mo = m.mo_coeff[:, act_mo] s = m.get_ovlp() #IAO ordering: ['del','del','yz','xz','x','y','z2','z','s'] #MO ordering: dxz, dyz, dz2, delta, delta, px, py, pz, 4s df['iao_n_3dd'] = 0 df['iao_n_3dpi'] = 0 df['iao_n_3dz2'] = 0 df['iao_n_3d'] = 0 df['iao_n_2pz'] = 0 df['iao_n_2ppi'] = 0 df['iao_n_4s'] = 0 df['iao_t_pi'] = 0 df['iao_t_dz'] = 0 df['iao_t_ds'] = 0 df['iao_t_sz'] = 0 for z in range(df.shape[0]): print(z) e = np.zeros((9, 9)) orb1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 8, 3] orb2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 7, 8, 9, 9] for i in range(len(orb1)): e[orb1[i] - 1, orb2[i] - 1] = df['mo_' + str(orb1[i]) + '_' + str(orb2[i])].values[z] mo_to_iao = reduce(np.dot, (mo.T, s, iao)) e = reduce(np.dot, (mo_to_iao.T, e, mo_to_iao)) e[np.abs(e) < 1e-10] = 0 e = (e + e.T) / 2 df['iao_n_3dd'].iloc[z] = np.sum(np.diag(e)[[0, 1]]) df['iao_n_3dpi'].iloc[z] = np.sum(np.diag(e)[[2, 3]]) df['iao_n_3dz2'].iloc[z] = np.diag(e)[6] df['iao_n_3d'].iloc[z] = np.sum(np.diag(e)[[0, 1, 2, 3, 6]]) df['iao_n_2pz'].iloc[z] = np.sum(np.diag(e)[7]) df['iao_n_2ppi'].iloc[z] = np.sum(np.diag(e)[[4, 5]]) df['iao_n_4s'].iloc[z] = np.sum(np.diag(e)[8]) df['iao_t_pi'].iloc[z] = 2 * (e[3, 4] + e[2, 5]) df['iao_t_ds'].iloc[z] = 2 * e[6, 8] df['iao_t_dz'].iloc[z] = 2 * e[6, 7] df['iao_t_sz'].iloc[z] = 2 * e[7, 8] return df
def new_gs(parms): print(parms) e4s, e3d, epi, ez, tpi, tds, tdz, tsz = parms #dx, dy, dz2, dd, px, py, pz, 4s H = np.diag([e3d, e3d, e3d, e3d, e3d, epi, epi, ez, e4s]) H[[0, 1, 5, 6], [5, 6, 0, 1]] = tpi H[[2, 7], [7, 2]] = tdz H[[7, 8], [8, 7]] = tsz H[[2, 8], [8, 2]] = tds w, vr = np.linalg.eigh(H) from pyscf import lib, gto, scf, mcscf, fci, lo, ci, cc from pyscf.scf import ROHF, UHF, ROKS from pyscf2qwalk import print_qwalk_mol chkfile = "../../pyscf/chk/Cuvtz_r1.725_s1_B3LYP_1.chk" mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) m.mo_coeff[:, 5:14] = np.dot(m.mo_coeff[:, 5:14], vr) print_qwalk_mol(mol, m, basename="new_gs/new_gs")
import json from pyscf import lib, gto, scf, mcscf, fci, lo, ci, cc from pyscf.scf import ROHF, UHF, ROKS import numpy as np import pandas as pd import matplotlib.pyplot as plt from pyscf2qwalk import print_qwalk_mol charge = 0 S = [1, 1, 3, 3, 1, 3] r = 1.725 method = 'B3LYP' basis = 'vtz' el = 'Cu' occ = np.arange(14) mo_coeff = None for run in range(len(S)): chkfile = "../chk/" + el + basis + "_r" + str(r) + "_s" + str( S[run]) + "_" + method + "_" + str(run) + ".chk" mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) if (mo_coeff is None): mo_coeff = m.mo_coeff[:, occ] else: mo_coeff = np.concatenate((mo_coeff, m.mo_coeff[:, occ]), axis=1) #Write to file m.mo_coeff = mo_coeff print_qwalk_mol(mol, m, basename="../orbs/all")
#There should be 5 3d TM orbitals. Let's check this! assert len(TM_3d_orbitals)==5 ############################################################################################## if("U" in method): if("HF" in method): m=UHF(mol) else: m=UKS(mol) m.xc=method[1:] else: if(method=="ROHF"): m=ROHF(mol) else: m=ROKS(mol) m.xc=method ############################################################################################## dm=np.zeros(m.init_guess_by_minao().shape) #The 3s is always doubly-occupied for the TM atom for s in TM_3s_orbitals: for spin in [0,1]: dm[spin,s,s]=1 #The 4s is always at least singly-occupied for the TM atom for s in TM_4s_orbitals: dm[0,s,s]=1 #Control the 4s double-occupancy
charge = 0 S = 1 r = 1.725 method = 'UB3LYP' basis = 'vtz' el = 'Cu' nppi = [] npz = [] #for run in range(19): for run in [0, 1, 2, 3, 4, 5, 6, 7, 14]: chkfile = el + basis + "_r" + str(r) + "_s" + str( S) + "_" + method + "_" + str(run) + ".chk" print(chkfile) mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) #Build RDM on IAO basis s = m.get_ovlp() mo_occ = m.mo_occ M = m.mo_coeff[0][:, mo_occ[0] > 0] M = reduce(np.dot, (a.T, s, M)) dm_u = np.dot(M, M.T) M = m.mo_coeff[1][:, mo_occ[1] > 0] M = reduce(np.dot, (a.T, s, M)) dm_d = np.dot(M, M.T) #plt.title("S="+str(mol_spin)) #plt.matshow(dm_u+dm_d - np.diag(np.diag(dm_u+dm_d)),vmin=-1,vmax=1,cmap=plt.cm.bwr) #plt.show()
def analyze(df): df['gsw'] = np.round(df['gsw'], 2) df['n_3dd'] = df['t_8_8'] + df['t_9_9'] df['n_3dpi'] = df['t_5_5'] + df['t_6_6'] df['n_3dz2'] = df['t_7_7'] df['n_3d'] = df['n_3dd'] + df['n_3dpi'] + df['n_3dz2'] df['n_2ppi'] = df['t_10_10'] + df['t_11_11'] df['n_2pz'] = df['t_12_12'] df['n_2p'] = df['n_2ppi'] + df['n_2pz'] df['n_4s'] = df['t_13_13'] df['t_pi'] = 2 * (df['t_5_10'] + df['t_6_11']) df['t_dz'] = 2 * df['t_7_12'] df['t_ds'] = 2 * df['t_7_13'] df['t_sz'] = 2 * df['t_12_13'] #PAIRPLOTS -------------------------------------------------------------------------- #sns.pairplot(df,vars=['energy','n_3dd','n_3dpi','n_3dz2','n_3d'],hue='basestate',markers=['o']+['.']*8) #sns.pairplot(df,vars=['energy','n_2ppi','n_2pz','n_2p','n_4s'],hue='basestate',markers=['o']+['.']*8) #sns.pairplot(df,vars=['energy','t_pi','t_dz','t_ds','t_sz'],hue='basestate',markers=['o']+['.']*8) #plt.show() #exit(0) #FITS -------------------------------------------------------------------------- y = df['energy'] yerr = df['energy_err'] #BIGGEST #X=df[['n_3dd','n_3d','n_2ppi','n_2pz','n_2p','n_4s','t_pi','t_sz','t_dz','t_ds']] #SMALLEST #X=df[['n_3d','n_2ppi','n_2pz']] #SEQUENTIALLY BETTER #X=df[['n_3d','n_2ppi','n_2pz','t_pi']] #X=df[['n_3d','n_2ppi','n_2pz','t_ds']] #X=df[['n_3d','n_2ppi','n_2pz','t_pi','t_ds']] #X=df[['n_3d','n_2ppi','n_2pz','t_pi','t_ds','t_dz']] X = df[['n_3d', 'n_2ppi', 'n_2pz', 't_pi', 't_ds', 't_sz']] #X=df[['n_3d','n_2ppi','n_2pz','t_pi','t_ds','t_dz','t_sz']] X = sm.add_constant(X) ols = sm.OLS(y, X).fit() print(ols.params) print(ols.summary()) df['pred'] = ols.predict(X) g = sns.FacetGrid(df, hue='basestate', hue_kws=dict(marker=['o'] + ['.'] * 8)) g.map(plt.errorbar, "pred", "energy", "energy_err", fmt='o').add_legend() plt.plot(df['energy'], df['energy'], 'k--') plt.show() exit(0) #ROTATE TO IAOS -------------------------------------------------------------------------- #Gather IAOs f = '../../pyscf/analyze/b3lyp_iao_b.pickle' #IAOs which span the MOs a = np.load(f) chkfile = '../../pyscf/chk/Cuvtz_r1.725_s1_B3LYP_1.chk' #MOs we used to calculate RDM elements mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) s = m.get_ovlp() H1 = np.diag([ -3.1957, -3.1957, -3.1957, -3.1957, -3.1957, -1.6972, -1.6972, -2.5474, 0 ]) H1[0, 5] = 0.7858 H1[5, 0] = 0.7858 H1[1, 6] = 0.7858 H1[6, 1] = 0.7858 H1[2, 7] = -0.8329 H1[7, 2] = -0.8329 H1[7, 8] = 1.6742 H1[8, 7] = 1.6742 mo_coeff = m.mo_coeff[:, 5:14] e1 = reduce(np.dot, (a.T, s, mo_coeff, H1, mo_coeff.T, s.T, a)) e1 = (e1 + e1.T) / 2. plt.matshow(e1, vmax=5, vmin=-5, cmap=plt.cm.bwr) plt.colorbar() labels = [ '3s', '4s', '3px', '3py', '3pz', '3dxy', '3dyz', '3dz2', '3dxz', '3dx2-y2', '2s', '2px', '2py', '2pz' ] plt.xticks(np.arange(14), labels, rotation=90) plt.yticks(np.arange(14), labels) plt.show()
def init_density(self, in_dmat=None, scf_obj=None, env_method=None, kpts=None): """ Initializes the periodic subsystem density Parameters ---------- in_dmat : ndarray, optional New subsystem density matrix (default is None). scf_obj : pyscf:pbc:scf object, optional The PySCF subsystem object (default is None). env_method : str, optional Subsystem environment energy method (default is None). kpts : ndarray, optional Kpoints to use in calculation (default is None). Returns ------- dmat : ndarray The new / guessed density matrix """ import numpy as np import pyscf from pyscf.scf import RKS, RHF, ROKS, ROHF, UKS, UHF if in_dmat is not None: return in_dmat if scf_obj is None: scf_obj = self.env_scf if env_method is None: env_method = self.env_method if kpts is None: kpts = self.kpts nkpts = len(kpts) nao = scf_obj.cell.nao_nr() dmat = np.zeros((2, nkpts, nao, nao)) mol = scf_obj.cell.to_mol() mol.verbose = 0 if self.unrestricted: if env_method in ('hf', 'hartree-fock'): mf = UHF(mol) else: mf = UKS(mol) mf.xc = env_method mf.kernel() dtemp = mf.make_rdm1() elif mol.spin != 0: if env_method in ('hf', 'hartree-fock'): mf = ROHF(mol) else: mf = ROKS(mol) mf.xc = env_method mf.kernel() dtemp = mf.make_rdm1() else: if env_method in ('hf', 'hartree-fock'): mf = RHF(mol) else: mf = RKS(mol) mf.xc = env_method mf.kernel() dtemp = mf.make_rdm1() / 2.0 dtemp = [dtemp, dtemp] for k in range(nkpts): dmat[0, k] = dtemp[0] dmat[1, k] = dtemp[0] return dmat
def desc_ed(df): print("DESC_ED") #Get descriptors from ci mol = gto.Mole() cis = fci.direct_uhf.FCISolver(mol) sigUs = [] sigJsd = [] sigNdz2 = [] sigNdpi = [] sigNdd = [] sigNd = [] sigN2pz = [] sigN2ppi = [] sigN4s = [] sigTpi = [] sigTds = [] sigTdz = [] sigTsz = [] sigMONdz2 = [] sigMONdpi = [] sigMONdd = [] sigMONd = [] sigMON2pz = [] sigMON2ppi = [] sigMON4s = [] sigMOTpi = [] sigMOTds = [] sigMOTdz = [] sigMOTsz = [] #GET MO TO IAO MATRIX act_iao = [5, 9, 6, 8, 11, 12, 7, 13, 1] iao = np.load('../../../pyscf/ub3lyp_full/b3lyp_iao_b.pickle') iao = iao[:, act_iao] #LOAD IN MOS act_mo = [5, 6, 7, 8, 9, 10, 11, 12, 13] chkfile = '../../../pyscf/chk/Cuvtz_r1.725_s1_B3LYP_1.chk' mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) mo = m.mo_coeff[:, act_mo] s = m.get_ovlp() mo_to_iao = reduce(np.dot, (mo.T, s, iao)) for i in range(df.shape[0]): ci = df['ci'].iloc[i] norb = 9 nelec = (8, 7) if (df['Sz'].iloc[i] == 1.5): nelec = (9, 6) ci = ci.reshape((sp.misc.comb(norb, nelec[0], exact=True), sp.misc.comb(norb, nelec[1], exact=True))) dm2 = cis.make_rdm12s(ci, norb, nelec) sigUs.append(dm2[1][1][8, 8, 8, 8]) Jsd = 0 for j in [0, 1, 2, 3, 6]: Jsd += 0.25*(dm2[1][0][8,8,j,j] + dm2[1][2][8,8,j,j] - dm2[1][1][8,8,j,j] - dm2[1][1][j,j,8,8])-\ 0.5*(dm2[1][1][j,8,8,j] + dm2[1][1][8,j,j,8]) sigJsd.append(Jsd) dm = dm2[0][0] + dm2[0][1] #IAO ordering: ['del','del','yz','xz','x','y','z2','z','s'] sigNdz2.append(dm[6, 6]) sigNdpi.append(dm[2, 2] + dm[3, 3]) sigNdd.append(dm[0, 0] + dm[1, 1]) sigNd.append(dm[0, 0] + dm[1, 1] + dm[2, 2] + dm[3, 3] + dm[6, 6]) sigN2pz.append(dm[7, 7]) sigN2ppi.append(dm[4, 4] + dm[5, 5]) sigN4s.append(dm[8, 8]) sigTpi.append(2 * (dm[3, 4] + dm[2, 5])) sigTds.append(2 * dm[6, 8]) sigTdz.append(2 * dm[6, 7]) sigTsz.append(2 * dm[7, 8]) #MO ordering: dxz, dyz, dz2, delta, delta, px, py, pz, 4s mo_dm = reduce(np.dot, (mo_to_iao, dm, mo_to_iao.T)) sigMONdz2.append(mo_dm[2, 2]) sigMONdpi.append(mo_dm[0, 0] + mo_dm[1, 1]) sigMONdd.append(mo_dm[3, 3] + mo_dm[4, 4]) sigMONd.append(mo_dm[0, 0] + mo_dm[1, 1] + mo_dm[2, 2] + mo_dm[3, 3] + mo_dm[4, 4]) sigMON2pz.append(mo_dm[7, 7]) sigMON2ppi.append(mo_dm[6, 6] + mo_dm[5, 5]) sigMON4s.append(mo_dm[8, 8]) sigMOTpi.append(2 * (mo_dm[0, 5] + mo_dm[1, 6])) sigMOTds.append(2 * mo_dm[2, 8]) sigMOTdz.append(2 * mo_dm[2, 7]) sigMOTsz.append(2 * mo_dm[7, 8]) df['iao_n_3dz2'] = sigNdz2 df['iao_n_3dpi'] = sigNdpi df['iao_n_3dd'] = sigNdd df['iao_n_3d'] = sigNd df['iao_n_2pz'] = sigN2pz df['iao_n_2ppi'] = sigN2ppi df['iao_n_4s'] = sigN4s df['iao_t_pi'] = sigTpi df['iao_t_ds'] = sigTds df['iao_t_dz'] = sigTdz df['iao_t_sz'] = sigTsz df['mo_n_3dz2'] = sigMONdz2 df['mo_n_3dpi'] = sigMONdpi df['mo_n_3dd'] = sigMONdd df['mo_n_3d'] = sigMONd df['mo_n_2pz'] = sigMON2pz df['mo_n_2ppi'] = sigMON2ppi df['mo_n_4s'] = sigMON4s df['mo_t_pi'] = sigMOTpi df['mo_t_ds'] = sigMOTds df['mo_t_dz'] = sigMOTdz df['mo_t_sz'] = sigMOTsz df['Us'] = sigUs df['Jsd'] = sigJsd return df
def analyze(df): df['gsw'] = np.round(df['gsw'], 2) print(list(df)) df['n_3dd'] = df['t_4_4'] + df['t_5_5'] df['n_3dpi'] = df['t_1_1'] + df['t_2_2'] df['n_3dz2'] = df['t_3_3'] df['n_3d'] = df['n_3dd'] + df['n_3dpi'] + df['n_3dz2'] df['n_2ppi'] = df['t_6_6'] + df['t_7_7'] df['n_2pz'] = df['t_8_8'] df['n_2p'] = df['n_2ppi'] + df['n_2pz'] df['n_4s'] = df['t_9_9'] df['t_pi'] = 2 * (df['t_1_6'] + df['t_2_7']) df['t_dz'] = 2 * df['t_3_8'] df['t_sz'] = 2 * df['t_8_9'] df['t_ds'] = 2 * df['t_3_9'] df['n'] = df['n_3d'] + df['n_4s'] + df['n_2p'] #PAIRPLOTS -------------------------------------------------------------------------- #sns.pairplot(df,vars=['energy','n'],hue='basestate',markers=['o']+['.']*8) #sns.pairplot(df,vars=['energy','n_2ppi','n_2pz','n_3d'],hue='basestate',markers=['o']+['.']*8) #sns.pairplot(df,vars=['energy','t_pi','t_dz','t_ds','t_sz'],hue='basestate',markers=['o']+['.']*8) #plt.show() #exit(0) #FITS -------------------------------------------------------------------------- y = df['energy'] yerr = df['energy_err'] #BIGGEST #X=df[['n_3dd','n_3d','n_2ppi','n_2pz','n_2p','n_4s','t_pi','t_sz','t_dz','t_ds']] #SMALLEST #X=df[['n_3d','n_2ppi','n_2pz']] #SEQUENTIALLY BETTER #X=df[['n_3d','n_2ppi','n_2pz','t_pi']] #X=df[['n_3d','n_2ppi','n_2pz','t_pi','t_sz']] #X=df[['n_3d','n_2ppi','n_2pz','t_pi','t_dz']] #X=df[['n_3d','n_2ppi','n_2pz','t_pi','t_dz','t_sz']] #X=df[['n_3d','n_2ppi','n_2pz','t_dz']] #X=df[['n_3d','n_2ppi','n_2pz','t_sz']] X = df[['n_3d', 'n_2ppi', 'n_2pz', 't_ds', 't_pi']] #X=df[['n_3d','n_2ppi','n_2pz','t_pi','t_ds']] #X=df[['n_3d','n_2ppi','n_2pz','t_dz','t_ds']] #X=df[['n_3d','n_2ppi','n_2pz','t_sz','t_ds']] #X=df[['n_3d','n_2ppi','n_2pz','t_dz','t_sz','t_ds']] X = sm.add_constant(X) beta = 0.0 wls = sm.WLS(y, X, weights=np.exp(-beta * (y - min(y)))).fit() print(wls.summary()) df['pred'] = wls.predict(X) df['resid'] = df['energy'] - df['pred'] sns.pairplot(df, vars=['resid', 't_pi', 't_dz', 't_sz'], hue='basestate', markers=['o'] + ['.'] * 8) ''' g = sns.FacetGrid(df,hue='basestate',hue_kws=dict(marker=['o']+['.']*8),palette=sns.color_palette('husl',9)) g.map(plt.errorbar, "pred", "energy", "energy_err",fmt='o').add_legend() plt.plot(df['energy'],df['energy'],'k--') ''' plt.show() exit(0) #ROTATE TO IAOS -------------------------------------------------------------------------- #Gather IAOs f = '../../pyscf/analyze/b3lyp_iao_b.pickle' #IAOs which span the MOs a = np.load(f) chkfile = '../../pyscf/chk/Cuvtz_r1.725_s1_B3LYP_1.chk' #MOs we used to calculate RDM elements mol = lib.chkfile.load_mol(chkfile) m = ROKS(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) s = m.get_ovlp() #dpi,dpi,dz2,dd,dd,ppi,ppi,pz,4s #e3d,e2pz,e2ppi,tpi,tdz,tsz=(-3.2487,-2.5759,-1.6910,0.3782,-0.7785,1.1160) #DMC e3d, e2pz, e2ppi, tpi, tdz, tsz = (-3.3324, -1.8762, -0.9182, 0.8266, 0, 0 ) #DMC H = np.diag([e3d, e3d, e3d, e3d, e3d, e2ppi, e2ppi, e2pz, 0]) H[0, 5] = tpi H[5, 0] = tpi H[1, 6] = tpi H[6, 1] = tpi H[2, 7] = tdz H[7, 2] = tdz H[7, 8] = tsz H[8, 7] = tsz mo_coeff = m.mo_coeff[:, 5:14] #Only include active MOs a = a[:, [1, 5, 6, 7, 8, 9, 11, 12, 13]] #Only include active IAOs e1 = reduce(np.dot, (a.T, s, mo_coeff, H, mo_coeff.T, s.T, a)) e1 = (e1 + e1.T) / 2. plt.matshow(e1, vmax=5, vmin=-5, cmap=plt.cm.bwr) plt.colorbar() #labels=['3s','4s','3px','3py','3pz','3dxy','3dyz','3dz2','3dxz','3dx2-y2','2s','2px','2py','2pz'] labels = [ '4s', '3dxy', '3dyz', '3dz2', '3dxz', '3dx2-y2', '2px', '2py', '2pz' ] plt.xticks(np.arange(len(labels)), labels, rotation=90) plt.yticks(np.arange(len(labels)), labels) plt.show()