Beispiel #1
0
def _gen_hamiltonian_block(HL0, HR0, hgen_l, hgen_r, interop, blockinfo):
    '''Get the combined hamiltonian for specific block.'''
    ndiml, ndimr = HL0.shape[0], HR0.shape[0]
    bm_tot, pm = blockinfo['bmg'].join_bms(
        [blockinfo['bml'], blockinfo['bmr']]).compact_form()
    pm = ((blockinfo['pml'] * ndimr)[:, newaxis] +
          blockinfo['pmr']).ravel()[pm]
    indices = pm[bm_tot.get_slice(blockinfo['target_block'], uselabel=True)]
    cinds = ind2c(indices, N=[ndiml, ndimr])
    t0 = time.time()
    H1 = fget_subblock_dmrg(hl=HL0.toarray(),
                            hr=identity(ndimr),
                            indices=cinds,
                            is_identity=2)
    H2 = fget_subblock_dmrg(hl=identity(ndiml),
                            hr=HR0.toarray(),
                            indices=cinds,
                            is_identity=1)
    Hc = H1 + H2
    t1 = time.time()
    sb = SuperBlock(hgen_l, hgen_r)
    for op in interop:
        Hc = Hc + sb.get_op(op, indices=cinds)
    t2 = time.time()
    print 'Generate Hamiltonian %s, %s' % (t1 - t0, t2 - t1)
    return sps.csr_matrix(Hc), bm_tot, pm
    def createSuperBlock(self, fsimg, superBlockOffset, superBlockSize, mode,
                         data):
        superBlock = SuperBlock()

        if mode == 0:  # If we work locally
            superBlock.createFromBytes(fsimg, superBlockOffset, superBlockSize,
                                       mode, None)
            return superBlock
        elif mode == 1:  # If we work remotely
            superBlock.createFromBytes(None, None, None, mode, data)
            print superBlock.inodeCount
Beispiel #3
0
def _gen_hamiltonian_full(HL0, HR0, hgen_l, hgen_r, interop):
    '''Get the full hamiltonian.'''
    ndiml, ndimr = HL0.shape[0], HR0.shape[0]
    H1, H2 = kron(HL0, sps.identity(ndimr)), kron(sps.identity(ndiml), HR0)
    H = H1 + H2
    #get the link hamiltonians
    sb = SuperBlock(hgen_l, hgen_r)
    Hin = []
    for op in interop:
        Hin.append(sb.get_op(op))
    H = H + sum(Hin)
    H = _eliminate_zeros(H, ZERO_REF)
    return H
Beispiel #4
0
def _gen_hamiltonian_block0(HL0, HR0, hgen_l, hgen_r, interop, blockinfo):
    '''Get the combined hamiltonian for specific block.'''
    ndiml, ndimr = HL0.shape[0], HR0.shape[0]
    bml, bmr, pml, pmr, bmg, target_block = blockinfo['bml'], blockinfo[
        'bmr'], blockinfo['pml'], blockinfo['pmr'], blockinfo[
            'bmg'], blockinfo['target_block']
    bm_tot, pm = bmg.join_bms([bml, bmr]).compact_form()
    pm = ((pml * len(pmr))[:, newaxis] + pmr).ravel()[pm]
    t0 = time.time()
    H1, H2 = kron(HL0, sps.identity(ndimr)), kron(sps.identity(ndiml), HR0)
    t1 = time.time()
    indices = pm[bm_tot.get_slice(target_block, uselabel=True)]
    H1, H2 = H1.tocsr()[indices][:, indices], H2.tocsr()[indices][:, indices]
    Hc = H1 + H2
    sb = SuperBlock(hgen_l, hgen_r)
    for op in interop:
        Hc = Hc + (sb.get_op(op)).tocsr()[indices][:, indices]
    t2 = time.time()
    print 'Generate Hamiltonian %s, %s' % (t1 - t0, t2 - t1)
    return Hc, bm_tot, pm