def co_contravariant_transition_delta(self): """ Return mixed covariant-contravariant ao delta matrix """ S = Nod.S I = full.unit(S.shape[0]) delta_aa = (I - S*d for d in self.transition_ao_density) return tuple(delta_aa)
def Feff(Da, Db, Fa, Fb): I_n = full.unit(len(Da)) D = Da + Db Ds = Da - Db ID = I_n - D Fs = Fa - Fb F = ((Fa + Fb) + Ds * Fs * ID + ID * Fs * Ds) / 2 return F
def test_Dab(self): na = 2 nb = 1 C = full.unit(3) da, db = dens.C2Dab(C, na, nb) daref = full.init([[1.0, 0.0, 0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]]) dbref = full.init([[1.0, 0.0, 0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]) np.testing.assert_almost_equal(da, daref) np.testing.assert_almost_equal(db, dbref)
def project_occupied_from_virtual(self, S2): # # Project occupied out of virtual # vpa = [c - len(o) for c, o in zip(self.cpa, self.opa)] nocc = sum(len(occ) for occ in self.opa) occdim = (nocc, sum(vpa)) S2sb = S2.subblocked(occdim, occdim) nbf = S2.shape[0] T3sb = full.unit(nbf).subblocked(occdim, occdim) T3sb.subblock[0][1] = -S2sb.subblock[0][1] T3 = T3sb.unblock() return T3
def P2(self): vpa = [] adim = [] for at in range(self.noa): vpa.append(self.cpa[at]-len(self.opa[at])) adim.append(len(self.opa[at])) adim.append(vpa[at]) # # dimensions for permuted basis # pdim = [] for at in range(self.noa): pdim.append(len(self.opa[at])) for at in range(self.noa): pdim.append(vpa[at]) P2 = subblocked.matrix(adim, pdim) for i in range(0, len(adim), 2): P2.subblock[i][i//2] = full.unit(adim[i]) for i in range(1, len(adim), 2): P2.subblock[i][self.noa+(i-1)//2] = full.unit(adim[i]) P2 = P2.unblock() return P2
def setUp(self): self.tmp = os.path.join(os.path.dirname(__file__), 'test_h2_ab') self.qc = QuantumChemistry.get_factory('Dalton', tmpdir=self.tmp) def tmp(fil): return os.path.join(self.tmp, fil) vb.Nod.tmpdir = self.tmp vb.Nod.C = full.unit(2) vb.Nod.S = self.qc.get_overlap() self.wf = vb.WaveFunction( [vb.Structure( [vb.Nod([0], [0]), vb.Nod([1], [1])], [1.0, 1.0] ), vb.Structure( [vb.Nod([0], [1]), vb.Nod([1], [0])], [1.0, 1.0] ) ], [1.0, 1.0], tmpdir = self.tmp )
def setUp(self): """ Model the fci result as a wb wave function WF = cg(1sg|1sg) + cu(1su|1su) 1sg=Ng(a+b) norm Ng=1/sqrt(2(1+Sab)) 1su=Nu(a-b) norm Nu=1/sqrt(2(1-Sab)) WF = cg*Ng**2(a+b|a+b) + cu*Nu**2(a-b|a-b) = (cg*Ng**2+cu*Nu**2)[(a|a) + (b|b)] + (cg*Ng**2-cu*Nu**2)[(a|b) + (b|a)] """ VBTest.setUp(self, 'test_h2_ab') # # Setup VB wave function # Nod.C=full.unit(2) ion_a = Structure([Nod([0],[0])], [1.0], normalize=False) ion_b = Structure([Nod([1],[1])], [1.0], normalize=False) import math N = math.sqrt(0.5) cov=Structure([Nod([0],[1]),Nod([1],[0])], [N, N], normalize=False) cg = 0.99364675 cu = -0.11254389 Sab = 0.65987313 Ng2=1/(2*(1+Sab)) Nu2=1/(2*(1-Sab)) cion = cg*Ng2 + cu*Nu2 ccov = (cg*Ng2 - cu*Nu2)/N self.WF=WaveFunctionND( [cov, ion_a, ion_b],[ccov, cion, cion], tmpdir=self.tmpdir )
def gram_schmidt_atomic_blocks(self, S): cpa = self.cpa opa = self.opa # # 1. orthogonalize in each atomic block # nbf = sum(cpa) # # obtain atomic blocking # noa = len(cpa) nocc = 0 for at in range(noa): nocc += len(opa[at]) Satom = S.block(cpa, cpa) Ubl = full.unit(nbf).subblocked((nbf,), cpa) # # Diagonalize atom-wise # T1 = blocked.BlockDiagonalMatrix(cpa, cpa) for at in range(noa): T1.subblock[at] = Ubl.subblock[0][at].GST(S) T1 = T1.unblock() return T1
def test_S4(self): T = self.T.T S4 = T.T*self.S*T self.assert_allclose(S4, full.unit(58))
def test_s2n_S(): refs2 = matrix.diag([2., -2.]) s2 = [oli.s2n(n, tmpdir=suppdir) for n in unit(2)] assert_(s2, refs2)
def test_unit2(self): identity = init([[2, 0, 0], [0, 2, 0], [0, 0, 2]]) np.testing.assert_almost_equal(unit(3, factor=2), identity)
def test_unit(self): identity = init([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) np.testing.assert_almost_equal(unit(3), identity)
def test_S4(self, transformer): T = transformer.T S4 = T.T * transformer.S * T self.assert_allclose(S4, full.unit(58))
def test_e2n_S(): refe2 = init([[0.91587038, -0.00000000], [0.00000000, 0.91587038]]) e2 = init([oli.e2n(n, tmpdir=suppdir) for n in unit(2)]) assert_(e2, refe2)
def test_e2n_S(): refe2 = init([[0.78643356, -0.50624296], [-0.50624296, 0.78643356]]) e2 = [oli.e2n(n, tmpdir=suppdir) for n in unit(2)] assert_(e2, refe2)
def test_s2n_S(): refs2 = matrix.diag([1, -1]) s2 = init([oli.s2n(n, tmpdir=suppdir) for n in unit(2)]) assert_(s2, refs2)
def test_e2n_S(): refe2 = init([[-0.22605236, 0.50624296], [0.50624296, -0.22605236]]) e2 = init([oli.e2n(n, tmpdir=suppdir, Sg=-1, Sv=-1) for n in unit(2)]) assert_(e2, refe2)