Beispiel #1
0
def get_udxc(voccs, weight=None, totkp=1):
    """Get up/down densities and corresponding mean field matrices"""
    import correlatorsf90
    ndim = voccs.shape[1]  # dimension of the matrix
    if weight is not None:
        if len(weight) != voccs.shape[0]: raise  # inconsistent dimensions
    nat = ndim // 2  # one half
    pdup = np.array([[2 * i, 2 * i] for i in range(nat)])  # up density
    pddn = pdup + 1  # down density
    pxc = np.array([[2 * i, 2 * i + 1] for i in range(nat)])  # exchange
    if weight is None:  # no weight
        vdup = correlatorsf90.correlators(voccs, pdup) / totkp
        vddn = correlatorsf90.correlators(voccs, pddn) / totkp
        vxc = correlatorsf90.correlators(voccs, pxc) / totkp
    else:  # with weight
        vdup = correlatorsf90.correlators_weighted(voccs, weight, pdup) / totkp
        vddn = correlatorsf90.correlators_weighted(voccs, weight, pddn) / totkp
        vxc = correlatorsf90.correlators_weighted(voccs, pxc) / totkp
    ndn = csc_matrix((vdup, pddn.transpose()),
                     dtype=np.complex,
                     shape=(ndim, ndim))
    nup = csc_matrix((vddn, pdup.transpose()),
                     dtype=np.complex,
                     shape=(ndim, ndim))
    xc = csc_matrix((np.conjugate(vxc), pxc.transpose()),
                    dtype=np.complex,
                    shape=(ndim, ndim))
    return (vdup, vddn, vxc, ndn, nup, xc)  # return everything
Beispiel #2
0
def get_super_correlator(voccs, weight=None, totkp=1):
    """Get the different correlators for a superconducting system"""
    import correlatorsf90
    ndim = voccs.shape[1]  # dimension of the matrix
    if weight is not None:
        if len(weight) != voccs.shape[0]: raise  # inconsistent dimensions
    nat = ndim // 4  # one fourth
    corrs = []  # empty list with the different correlators
    ops = []  # list with the operators
    for i in nat:  # loop over atoms
        corrs.append([4 * i, 4 * i])  # up density
        ops.append(csc_matrix(([1.], [1, 1]),
                              dtype=np.complex))  # down operator
        corrs.append([4 * i + 1, 4 * i + 1])  # up density
        ops.append(csc_matrix(([1.], [0, 0]),
                              dtype=np.complex))  # down operator
        corrs.append([4 * i, 4 * i + 1])  # up density
        ops.append(csc_matrix(([-1.], [1, 0]),
                              dtype=np.complex))  # down operator
        corrs.append([4 * i + 1, 4 * i])  # up density
        ops.append(csc_matrix(([-1.], [0, 1]),
                              dtype=np.complex))  # down operator
    pdup = np.array([[4 * i, 4 * i] for i in range(nat)])  # up density
    pddn = pdup + 1  # down density
    pxc = np.array([[4 * i, 4 * i + 1] for i in range(nat)])  # exchange
    deltadd = np.array([[4 * i + 1, 4 * i + 2]
                        for i in range(nat)])  # Delta dd
    deltauu = np.array([[4 * i, 4 * i + 3] for i in range(nat)])  # Delta uu
    deltaud = np.array([[4 * i, 4 * i + 2] for i in range(nat)])  # Delta ud
    deltadu = np.array([[4 * i + 1, 4 * i + 3]
                        for i in range(nat)])  # Delta du
    if weight is None:  # no weight
        vdup = correlatorsf90.correlators(voccs, pdup) / totkp
        vddn = correlatorsf90.correlators(voccs, pddn) / totkp
        vxc = correlatorsf90.correlators(voccs, pxc) / totkp
        vdeltadd = correlatorsf90.correlators(voccs, deltadd) / totkp
        vdeltauu = correlatorsf90.correlators(voccs, deltauu) / totkp
        vdeltadu = correlatorsf90.correlators(voccs, deltadu) / totkp
        vdeltaud = correlatorsf90.correlators(voccs, deltaud) / totkp
    else:  # with weight
        raise
        vdup = correlatorsf90.correlators_weighted(voccs, weight, pdup) / totkp
        vddn = correlatorsf90.correlators_weighted(voccs, weight, pddn) / totkp
        vxc = correlatorsf90.correlators_weighted(voccs, pxc) / totkp
    ndn = csc_matrix((vdup, pddn.transpose()),
                     dtype=np.complex,
                     shape=(ndim, ndim))
    nup = csc_matrix((vddn, pdup.transpose()),
                     dtype=np.complex,
                     shape=(ndim, ndim))
    xc = csc_matrix((np.conjugate(vxc), pxc.transpose()),
                    dtype=np.complex,
                    shape=(ndim, ndim))
    return (vdup, vddn, vxc, ndn, nup, xc)  # return everything
Beispiel #3
0
def get_magnetization(h,nkp=20):
  """Return the magnetization of the system"""
  totkp = nkp**(h.dimensionality)
  nat = h.intra.shape[0]//2 # number of atoms
  eigvals,eigvecs = h.eigenvectors(nkp)
  voccs = [] # accupied vectors
  eoccs = [] # accupied eigenvalues
  occs = [] # accupied eigenvalues
  for (e,v) in zip(eigvals,eigvecs): # loop over eigenvals,eigenvecs
    if e<0.0000001:  # if level is filled, add contribution
      voccs.append(v) # store
      eoccs.append(e) # store
  pdup = np.array([[2*i,2*i] for i in range(nat)]) # up density
  pddn = pdup + 1 # down density
  pxc = np.array([[2*i,2*i+1] for i in range(nat)]) # exchange
  import correlatorsf90
  vdup = correlatorsf90.correlators(voccs,pdup)/totkp
  vddn = correlatorsf90.correlators(voccs,pddn)/totkp
  vxc = correlatorsf90.correlators(voccs,pxc)/totkp
  magnetization = np.array([vxc.real,vxc.imag,vdup-vddn]).transpose().real
  from scftypes import write_magnetization
  write_magnetization(magnetization)
Beispiel #4
0
def get_udxc(voccs,weight=None,totkp=1):
  """Get up/down densities and corresponding mean field matrices"""
  import correlatorsf90
  ndim = voccs.shape[1] # dimension of the matrix
  if weight is not None:
    if len(weight)!=voccs.shape[0]: raise # inconsistent dimensions
  nat = ndim//2 # one half
  pdup = np.array([[2*i,2*i] for i in range(nat)]) # up density
  pddn = pdup + 1 # down density
  pxc = np.array([[2*i,2*i+1] for i in range(nat)]) # exchange
  if weight is None: # no weight
    vdup = correlatorsf90.correlators(voccs,pdup)/totkp
    vddn = correlatorsf90.correlators(voccs,pddn)/totkp
    vxc = correlatorsf90.correlators(voccs,pxc)/totkp
  else: # with weight
    vdup = correlatorsf90.correlators_weighted(voccs,weight,pdup)/totkp
    vddn = correlatorsf90.correlators_weighted(voccs,weight,pddn)/totkp
    vxc = correlatorsf90.correlators_weighted(voccs,pxc)/totkp
  ndn = csc_matrix((vdup,pddn.transpose()),dtype=np.complex,shape=(ndim,ndim))
  nup = csc_matrix((vddn,pdup.transpose()),dtype=np.complex,shape=(ndim,ndim))
  xc = csc_matrix((np.conjugate(vxc),pxc.transpose()),
                           dtype=np.complex,shape=(ndim,ndim))
  return (vdup,vddn,vxc,ndn,nup,xc) # return everything
Beispiel #5
0
def get_magnetization(h, nkp=20):
    """Return the magnetization of the system"""
    totkp = nkp**(h.dimensionality)
    nat = h.intra.shape[0] // 2  # number of atoms
    eigvals, eigvecs = h.eigenvectors(nkp)
    voccs = []  # accupied vectors
    eoccs = []  # accupied eigenvalues
    occs = []  # accupied eigenvalues
    for (e, v) in zip(eigvals, eigvecs):  # loop over eigenvals,eigenvecs
        if e < 0.0000001:  # if level is filled, add contribution
            voccs.append(v)  # store
            eoccs.append(e)  # store
    pdup = np.array([[2 * i, 2 * i] for i in range(nat)])  # up density
    pddn = pdup + 1  # down density
    pxc = np.array([[2 * i, 2 * i + 1] for i in range(nat)])  # exchange
    import correlatorsf90
    vdup = correlatorsf90.correlators(voccs, pdup) / totkp
    vddn = correlatorsf90.correlators(voccs, pddn) / totkp
    vxc = correlatorsf90.correlators(voccs, pxc) / totkp
    magnetization = np.array([vxc.real, vxc.imag,
                              vdup - vddn]).transpose().real
    from scftypes import write_magnetization
    write_magnetization(magnetization)