예제 #1
0
 def comp_veff(self, vext, comega=1j * 0.0):
     from scipy.sparse.linalg import gmres, lgmres as gmres_alias, LinearOperator
     """ This computes an effective field (scalar potential) given the external scalar potential """
     assert len(vext) == len(
         self.moms0), "%r, %r " % (len(vext), len(self.moms0))
     self.comega_current = comega
     veff_op = LinearOperator((self.nprod, self.nprod),
                              matvec=self.vext2veff_matvec,
                              dtype=self.dtypeComplex)
     resgm = gmres_alias(veff_op,
                         np.require(vext,
                                    dtype=self.dtypeComplex,
                                    requirements='C'),
                         tol=self.tddft_iter_tol)
     return resgm
예제 #2
0
  def seff(self, sext, comega=1j*0.0):
    """ This computes an effective two point field (scalar non-local potential) given an external two point field.
        L = L0 (1 - K L0)^-1
        We want therefore an effective X_eff for a given X_ext
        X_eff = (1 - K L0)^-1 X_ext   or   we need to solve linear equation
        (1 - K L0) X_eff = X_ext  

        The operator (1 - K L0) is named self.sext2seff_matvec """
    
    from scipy.sparse.linalg import gmres, lgmres as gmres_alias, LinearOperator
    assert sext.size==(self.norbs2), "%r,%r"%(sext.size,self.norbs2)

    self.comega_current = comega
    op = LinearOperator((self.norbs2,self.norbs2), matvec=self.sext2seff_matvec, dtype=self.dtypeComplex)
    sext_shape = np.require(sext.reshape(self.norbs2), dtype=self.dtypeComplex, requirements='C')
    resgm,info = gmres_alias(op, sext_shape, tol=self.tddft_iter_tol)
    return (resgm.reshape([self.norbs,self.norbs]),info)