# ''' DF-MP2 natural orbitals for the allyl radical ''' from pyscf.gto import Mole from pyscf.scf import UHF from pyscf.tools import molden from pyscf.mp.dfump2_native import DFMP2 mol = Mole() mol.atom = ''' C -1.1528 -0.1151 -0.4645 C 0.2300 -0.1171 -0.3508 C 0.9378 0.2246 0.7924 H 0.4206 0.5272 1.7055 H 2.0270 0.2021 0.8159 H -1.6484 -0.3950 -1.3937 H -1.7866 0.1687 0.3784 H 0.8086 -0.4120 -1.2337 ''' mol.basis = 'def2-TZVP' mol.spin = 1 mol.build() mf = UHF(mol).run() # MP2 natural occupation numbers and natural orbitals natocc, natorb = DFMP2(mf).make_natorbs() # store the natural orbitals in a molden file molden.from_mo(mol, 'allyl_mp2nat.molden', natorb, occ=natocc)
#Various analyses 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 for name in ['4Phi', '4Delta', '2Delta', '4SigmaM']: mol_spin = int(name[0]) - 1 for r in [1.963925]: for method in ['B3LYP']: for basis in ['vtz']: for el in ['Cu']: for charge in [0]: chkfile = "../full_chk/" + el + basis + "_r" + str( r) + "_c" + str(charge) + "_s" + str( mol_spin) + "_" + method + "_" + name + ".chk" mol = lib.chkfile.load_mol(chkfile) if ("U" in method): m = UHF(mol) else: m = ROHF(mol) m.__dict__.update(lib.chkfile.load(chkfile, 'scf')) #Generate files for plotting orbitals in ../orbs #print_qwalk_mol(mol,m,basename="../full_orbs/"+el+basis+"_r"+str(r)+"_c"+str(charge)+"_s"+str(mol_spin)+"_"+method+"_"+name)
#Find the O 2s labels if (('2s' in x) and ('O' in x)): O_2s_orbitals.append(i) #Find the O 2p labels if (('2p' in x) and ('O' in x)): O_2p_orbitals.append(i) #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:
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