1# 2# CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry 3# Copyright (C) 2013-2018 Sebastian Wouters 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License along 16# with this program; if not, write to the Free Software Foundation, Inc., 17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18# 19 20import numpy as np 21cimport numpy as np 22from libcpp.string cimport string 23from libcpp cimport bool 24np.import_array() 25 26cimport Init 27cimport ConvScheme 28cimport Ham 29cimport Prob 30cimport Corr 31cimport TwoRDM 32cimport ThreeRDM 33cimport DMRGsolver 34cimport DMRGSCFopt 35cimport DMRGSCF 36cimport FullCI 37 38cdef class PyInitialize: 39 cdef Init.Initialize * thisptr 40 def __cinit__(self): 41 self.thisptr = new Init.Initialize() 42 def __dealloc__(self): 43 del self.thisptr 44 def Init(self): 45 self.thisptr.Init() 46 47cdef class PyConvergenceScheme: 48 cdef ConvScheme.ConvergenceScheme * thisptr 49 def __cinit__(self, int nInstructions): 50 self.thisptr = new ConvScheme.ConvergenceScheme(nInstructions) 51 def __dealloc__(self): 52 del self.thisptr 53 def setInstruction(self, int instruction, int D, double Econv, int nMax, double noisePrefactor): 54 self.thisptr.setInstruction(instruction, D, Econv, nMax, noisePrefactor) 55 def set_instruction(self, int instruction, int D, double Econv, int nMax, double noisePrefactor, double dvdson_rtol): 56 self.thisptr.set_instruction(instruction, D, Econv, nMax, noisePrefactor, dvdson_rtol) 57 def getD(self, int instruction): 58 return self.thisptr.get_D(instruction) 59 def getEconv(self, int instruction): 60 return self.thisptr.get_energy_conv(instruction) 61 def getMaxSweeps(self, int instruction): 62 return self.thisptr.get_max_sweeps(instruction) 63 def getNoisePrefactor(self, int instruction): 64 return self.thisptr.get_noise_prefactor(instruction) 65 def getDavidsonRTOL(self, int instruction): 66 return self.thisptr.get_dvdson_rtol(instruction) 67 68cdef class PyHamiltonian: 69 cdef Ham.Hamiltonian * thisptr 70 def __cinit__(self, int Norbitals, int nGroup, np.ndarray[int, ndim=1, mode="c"] OrbIrreps not None, string filename='none'): 71 if ( filename.compare('none')==0 ): 72 assert OrbIrreps.flags['C_CONTIGUOUS'] 73 assert OrbIrreps.shape[0] == Norbitals 74 self.thisptr = new Ham.Hamiltonian(Norbitals, nGroup, &OrbIrreps[0]) 75 else: 76 self.thisptr = new Ham.Hamiltonian(filename, nGroup) 77 def __dealloc__(self): 78 del self.thisptr 79 def getL(self): 80 return self.thisptr.getL() 81 def getNGroup(self): 82 return self.thisptr.getNGroup() 83 def getOrbitalIrrep(self, int orb): 84 return self.thisptr.getOrbitalIrrep(orb) 85 def setEconst(self, double value): 86 self.thisptr.setEconst(value) 87 def setTmat(self, int index1, int index2, double value): 88 self.thisptr.setTmat(index1, index2, value) 89 def setVmat(self, int index1, int index2, int index3, int index4, double value): 90 self.thisptr.setVmat(index1, index2, index3, index4, value) 91 def getEconst(self): 92 return self.thisptr.getEconst() 93 def getTmat(self, int index1, int index2): 94 return self.thisptr.getTmat(index1, index2) 95 def getVmat(self, int index1, int index2, int index3, int index4): 96 return self.thisptr.getVmat(index1, index2, index3, index4) 97 def save(self): 98 self.thisptr.save() 99 def read(self): 100 self.thisptr.read() 101 def writeFCIDUMP(self, string filename, int Nelec, int TwoS, int TargetIrrep): 102 self.thisptr.writeFCIDUMP( filename, Nelec, TwoS, TargetIrrep ) 103 104cdef class PyProblem: 105 cdef Prob.Problem * thisptr 106 def __cinit__(self, PyHamiltonian Hami, int TwoS, int N, int Irrep): 107 self.thisptr = new Prob.Problem(Hami.thisptr, TwoS, N, Irrep) 108 def __dealloc__(self): 109 del self.thisptr 110 def gL(self): 111 return self.thisptr.gL() 112 def gSy(self): 113 return self.thisptr.gSy() 114 def gIrrep(self, int orb): 115 return self.thisptr.gIrrep(orb) 116 def gTwoS(self): 117 return self.thisptr.gTwoS() 118 def gN(self): 119 return self.thisptr.gN() 120 def gIrrep(self): 121 return self.thisptr.gIrrep() 122 def gEconst(self): 123 return self.thisptr.gEconst() 124 def gMxElement(self, int index1, int index2, int index3, int index4): 125 return self.thisptr.gMxElement(index1, index2, index3, index4) 126 def setMxElement(self, int index1, int index2, int index3, int index4, double value): 127 self.thisptr.setMxElement(index1, index2, index3, index4, value) 128 def SetupReorderD2h(self): 129 self.thisptr.SetupReorderD2h() 130 131cdef class PyDMRG: 132 cdef DMRGsolver.DMRG * thisptr 133 def __cinit__(self, PyProblem Probl, PyConvergenceScheme OptScheme, bool makechkpt=False, string tmpfolder='/tmp'): 134 self.thisptr = new DMRGsolver.DMRG(Probl.thisptr, OptScheme.thisptr, makechkpt, tmpfolder) 135 def __dealloc__(self): 136 del self.thisptr 137 def Solve(self): 138 return self.thisptr.Solve() 139 def PreSolve(self): 140 self.thisptr.PreSolve() 141 def calc2DMandCorrelations(self): 142 self.thisptr.calc2DMandCorrelations() 143 def calc_rdms_and_correlations(self, bool do_3rdm): 144 self.thisptr.calc_rdms_and_correlations( do_3rdm ) 145 def deleteStoredMPS(self): 146 self.thisptr.deleteStoredMPS() 147 def deleteStoredOperators(self): 148 self.thisptr.deleteStoredOperators() 149 def activateExcitations(self, int nExcitations): 150 self.thisptr.activateExcitations(nExcitations) 151 def newExcitation(self, const double Eshift): 152 self.thisptr.newExcitation(Eshift) 153 #Access functions of the Corr.Correlations class 154 def getCspin(self, int row, int col): 155 return self.thisptr.getCorrelations().getCspin_HAM(row, col) 156 def getCdens(self, int row, int col): 157 return self.thisptr.getCorrelations().getCdens_HAM(row, col) 158 def getCspinflip(self, int row, int col): 159 return self.thisptr.getCorrelations().getCspinflip_HAM(row, col) 160 def getCdirad(self, int row, int col): 161 return self.thisptr.getCorrelations().getCdirad_HAM(row, col) 162 def getMutInfo(self, int row, int col): 163 return self.thisptr.getCorrelations().getMutualInformation_HAM(row, col) 164 def getSingleOrbEntropy(self, int index): 165 return self.thisptr.getCorrelations().SingleOrbitalEntropy_HAM(index) 166 def getMutInfoDistance(self, int power): 167 return self.thisptr.getCorrelations().MutualInformationDistance(power) 168 def printCorrelations(self): 169 self.thisptr.getCorrelations().Print() 170 #Access functions of the TwoDM class 171 def get2DMA(self, int i1, int i2, int i3, int i4): 172 return self.thisptr.get2DM().getTwoDMA_HAM(i1, i2, i3, i4) 173 def get2DMB(self, int i1, int i2, int i3, int i4): 174 return self.thisptr.get2DM().getTwoDMB_HAM(i1, i2, i3, i4) 175 def get2DMenergy(self): 176 return self.thisptr.get2DM().energy() 177 def getDoubleTrace2DMA(self): 178 return self.thisptr.get2DM().trace() 179 #Access functions of the ThreeDM class 180 def get3DM(self, int i1, int i2, int i3, int i4, int i5, int i6): 181 return self.thisptr.get3DM().get_ham_index(i1, i2, i3, i4, i5, i6) 182 def Symm4RDM(self, np.ndarray[double, ndim=1, mode="c"] output not None, int ham_orb1, int ham_orb2, bool last_case): 183 assert output.flags['C_CONTIGUOUS'] 184 self.thisptr.Symm4RDM(&output[0], ham_orb1, ham_orb2, last_case) 185 def getFCIcoefficient(self, np.ndarray[int, ndim=1, mode="c"] alpha not None, np.ndarray[int, ndim=1, mode="c"] beta not None): 186 assert alpha.flags['C_CONTIGUOUS'] 187 assert beta.flags['C_CONTIGUOUS'] 188 return self.thisptr.getFCIcoefficient(&alpha[0],&beta[0]) 189 190cdef class PyDMRGSCFoptions: 191 cdef DMRGSCFopt.DMRGSCFoptions * thisptr 192 def __cinit__(self): 193 self.thisptr = new DMRGSCFopt.DMRGSCFoptions() 194 def __dealloc__(self): 195 del self.thisptr 196 def getDoDIIS(self): 197 return self.thisptr.getDoDIIS() 198 def getDIISGradientBranch(self): 199 return self.thisptr.getDIISGradientBranch() 200 def getNumDIISVecs(self): 201 return self.thisptr.getNumDIISVecs() 202 def getStoreDIIS(self): 203 return self.thisptr.getStoreDIIS() 204 def getMaxIterations(self): 205 return self.thisptr.getMaxIterations() 206 def getGradientThreshold(self): 207 return self.thisptr.getGradientThreshold() 208 def getStoreUnitary(self): 209 return self.thisptr.getStoreUnitary() 210 def getWhichActiveSpace(self): 211 return self.thisptr.getWhichActiveSpace() 212 def getDumpCorrelations(self): 213 return self.thisptr.getDumpCorrelations() 214 def getStateAveraging(self): 215 return self.thisptr.getStateAveraging() 216 def setDoDIIS(self, bool val): 217 self.thisptr.setDoDIIS(val) 218 def setDIISGradientBranch(self, double val): 219 self.thisptr.setDIISGradientBranch(val) 220 def setNumDIISVecs(self, int val): 221 self.thisptr.setNumDIISVecs(val) 222 def setStoreDIIS(self, bool val): 223 self.thisptr.setStoreDIIS(val) 224 def setMaxIterations(self, int val): 225 self.thisptr.setMaxIterations(val) 226 def setGradientThreshold(self, double val): 227 self.thisptr.setGradientThreshold(val) 228 def setStoreUnitary(self, bool val): 229 self.thisptr.setStoreUnitary(val) 230 def setWhichActiveSpace(self, int val): 231 self.thisptr.setWhichActiveSpace(val) 232 def setDumpCorrelations(self, bool val): 233 self.thisptr.setDumpCorrelations(val) 234 def setStateAveraging(self, bool val): 235 self.thisptr.setStateAveraging(val) 236 237cdef class PyCASSCF: 238 cdef DMRGSCF.CASSCF * thisptr 239 def __cinit__(self, PyHamiltonian theHam, np.ndarray[int, ndim=1, mode="c"] DOCC not None, np.ndarray[int, ndim=1, mode="c"] SOCC not None, np.ndarray[int, ndim=1, mode="c"] NOCC not None, np.ndarray[int, ndim=1, mode="c"] NDMRG not None, np.ndarray[int, ndim=1, mode="c"] NVIRT not None): 240 assert DOCC.flags['C_CONTIGUOUS'] 241 assert SOCC.flags['C_CONTIGUOUS'] 242 assert NOCC.flags['C_CONTIGUOUS'] 243 assert NDMRG.flags['C_CONTIGUOUS'] 244 assert NVIRT.flags['C_CONTIGUOUS'] 245 self.thisptr = new DMRGSCF.CASSCF(theHam.thisptr, &DOCC[0], &SOCC[0], &NOCC[0], &NDMRG[0], &NVIRT[0]) 246 def __dealloc__(self): 247 del self.thisptr 248 def solve(self, int Nel, int TwoS, int Irrep, PyConvergenceScheme OptScheme, int rootNum, PyDMRGSCFoptions theDMRGSCFopts): 249 return self.thisptr.solve(Nel, TwoS, Irrep, OptScheme.thisptr, rootNum, theDMRGSCFopts.thisptr) 250 def caspt2(self, int Nel, int TwoS, int Irrep, PyConvergenceScheme OptScheme, int rootNum, PyDMRGSCFoptions theDMRGSCFopts, double IPEA, double IMAG, bool PSEUDOCANONICAL): 251 return self.thisptr.caspt2(Nel, TwoS, Irrep, OptScheme.thisptr, rootNum, theDMRGSCFopts.thisptr, IPEA, IMAG, PSEUDOCANONICAL) 252 def solve_fci(self, int Nel, int TwoS, int Irrep, int rootNum, PyDMRGSCFoptions theDMRGSCFopts): 253 return self.thisptr.solve(Nel, TwoS, Irrep, NULL, rootNum, theDMRGSCFopts.thisptr) 254 def caspt2_fci(self, int Nel, int TwoS, int Irrep, int rootNum, PyDMRGSCFoptions theDMRGSCFopts, double IPEA, double IMAG, bool PSEUDOCANONICAL): 255 return self.thisptr.caspt2(Nel, TwoS, Irrep, NULL, rootNum, theDMRGSCFopts.thisptr, IPEA, IMAG, PSEUDOCANONICAL) 256 def deleteStoredUnitary(self): 257 self.thisptr.deleteStoredUnitary() 258 def deleteStoredDIIS(self): 259 self.thisptr.deleteStoredDIIS() 260 261cdef class PyFCI: 262 cdef FullCI.FCI * thisptr 263 def __cinit__(self, PyHamiltonian theHam, unsigned int Nel_up, unsigned int Nel_down, int TargetIrrep, double maxMemWorkMB=100.0, int FCIverbose=1): 264 self.thisptr = new FullCI.FCI(theHam.thisptr, Nel_up, Nel_down, TargetIrrep, maxMemWorkMB, FCIverbose) 265 def __dealloc__(self): 266 del self.thisptr 267 def getVecLength(self): 268 return self.thisptr.getVecLength(0) 269 def LowestEnergyDeterminant(self): 270 return self.thisptr.LowestEnergyDeterminant() 271 def GSDavidson(self, np.ndarray[double, ndim=1, mode="c"] inoutput not None): 272 assert inoutput.flags['C_CONTIGUOUS'] 273 Energy = self.thisptr.GSDavidson(&inoutput[0]) 274 return Energy 275 def CalcSpinSquared(self, np.ndarray[double, ndim=1, mode="c"] GSvector not None): 276 assert GSvector.flags['C_CONTIGUOUS'] 277 SpinSquared = self.thisptr.CalcSpinSquared(&GSvector[0]) 278 return SpinSquared 279 def Fill2RDM(self, np.ndarray[double, ndim=1, mode="c"] GSvector not None, np.ndarray[double, ndim=1, mode="c"] TwoRDM not None): 280 assert GSvector.flags['C_CONTIGUOUS'] 281 assert TwoRDM.flags['C_CONTIGUOUS'] 282 EnergyByContraction = self.thisptr.Fill2RDM(&GSvector[0], &TwoRDM[0]) 283 return EnergyByContraction 284 def Fill3RDM(self, np.ndarray[double, ndim=1, mode="c"] GSvector not None, np.ndarray[double, ndim=1, mode="c"] ThreeRDM not None): 285 assert GSvector.flags['C_CONTIGUOUS'] 286 assert ThreeRDM.flags['C_CONTIGUOUS'] 287 self.thisptr.Fill3RDM(&GSvector[0], &ThreeRDM[0]) 288 def Fill4RDM(self, np.ndarray[double, ndim=1, mode="c"] GSvector not None, np.ndarray[double, ndim=1, mode="c"] FourRDM not None): 289 assert GSvector.flags['C_CONTIGUOUS'] 290 assert FourRDM.flags['C_CONTIGUOUS'] 291 self.thisptr.Fill4RDM(&GSvector[0], &FourRDM[0]) 292 def Diag4RDM(self, np.ndarray[double, ndim=1, mode="c"] GSvector not None, np.ndarray[double, ndim=1, mode="c"] ThreeRDM not None, unsigned int ham_orbz, np.ndarray[double, ndim=1, mode="c"] output not None): 293 assert GSvector.flags['C_CONTIGUOUS'] 294 assert ThreeRDM.flags['C_CONTIGUOUS'] 295 assert output.flags['C_CONTIGUOUS'] 296 self.thisptr.Diag4RDM(&GSvector[0], &ThreeRDM[0], ham_orbz, &output[0]) 297 def FillRandom(self, unsigned int vecLength, np.ndarray[double, ndim=1, mode="c"] vector not None): 298 assert vector.flags['C_CONTIGUOUS'] 299 self.thisptr.FillRandom(vecLength, &vector[0]) 300 def getFCIcoefficient(self, np.ndarray[int, ndim=1, mode="c"] alpha not None, np.ndarray[int, ndim=1, mode="c"] beta not None, np.ndarray[double, ndim=1, mode="c"] GSvector not None): 301 assert alpha.flags['C_CONTIGUOUS'] 302 assert beta.flags['C_CONTIGUOUS'] 303 assert GSvector.flags['C_CONTIGUOUS'] 304 return self.thisptr.getFCIcoeff(&alpha[0], &beta[0], &GSvector[0]) 305 def RetardedGF(self, double omega, double eta, int orb_alpha, int orb_beta, bool isUp, double GSenergy, np.ndarray[double, ndim=1, mode="c"] GSvector not None, PyHamiltonian Hami): 306 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([1]) 307 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([1]) 308 assert GSvector.flags['C_CONTIGUOUS'] 309 assert RePart.flags['C_CONTIGUOUS'] 310 assert ImPart.flags['C_CONTIGUOUS'] 311 self.thisptr.RetardedGF(omega, eta, orb_alpha, orb_beta, isUp, GSenergy, &GSvector[0], Hami.thisptr, &RePart[0], &ImPart[0]) 312 return (RePart[0], ImPart[0]) 313 def RetardedGF_addition(self, double omega, double eta, int orb_alpha, int orb_beta, bool isUp, double GSenergy, np.ndarray[double, ndim=1, mode="c"] GSvector not None, PyHamiltonian Hami, np.ndarray[double, ndim=1, mode="c"] Re2RDM not None, np.ndarray[double, ndim=1, mode="c"] Im2RDM not None, np.ndarray[double, ndim=1, mode="c"] Add2RDM not None): 314 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([1]) 315 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([1]) 316 assert GSvector.flags['C_CONTIGUOUS'] 317 assert RePart.flags['C_CONTIGUOUS'] 318 assert ImPart.flags['C_CONTIGUOUS'] 319 assert Re2RDM.flags['C_CONTIGUOUS'] 320 assert Im2RDM.flags['C_CONTIGUOUS'] 321 assert Add2RDM.flags['C_CONTIGUOUS'] 322 self.thisptr.RetardedGF_addition(omega, eta, orb_alpha, orb_beta, isUp, GSenergy, &GSvector[0], Hami.thisptr, &RePart[0], &ImPart[0], &Re2RDM[0], &Im2RDM[0], &Add2RDM[0]) 323 return (RePart[0], ImPart[0]) 324 def RetardedGF_removal(self, double omega, double eta, int orb_alpha, int orb_beta, bool isUp, double GSenergy, np.ndarray[double, ndim=1, mode="c"] GSvector not None, PyHamiltonian Hami, np.ndarray[double, ndim=1, mode="c"] Re2RDM not None, np.ndarray[double, ndim=1, mode="c"] Im2RDM not None, np.ndarray[double, ndim=1, mode="c"] Rem2RDM not None): 325 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([1]) 326 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([1]) 327 assert GSvector.flags['C_CONTIGUOUS'] 328 assert RePart.flags['C_CONTIGUOUS'] 329 assert ImPart.flags['C_CONTIGUOUS'] 330 assert Re2RDM.flags['C_CONTIGUOUS'] 331 assert Im2RDM.flags['C_CONTIGUOUS'] 332 assert Rem2RDM.flags['C_CONTIGUOUS'] 333 self.thisptr.RetardedGF_removal(omega, eta, orb_alpha, orb_beta, isUp, GSenergy, &GSvector[0], Hami.thisptr, &RePart[0], &ImPart[0], &Re2RDM[0], &Im2RDM[0], &Rem2RDM[0]) 334 return (RePart[0], ImPart[0]) 335 def GFmatrix_add(self, double alpha, double beta, double eta, np.ndarray[int, ndim=1, mode="c"] orbsLeft not None, np.ndarray[int, ndim=1, mode="c"] orbsRight not None, bool isUp, np.ndarray[double, ndim=1, mode="c"] GSvector not None, PyHamiltonian Hami): 336 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([len(orbsLeft)*len(orbsRight)]) 337 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([len(orbsLeft)*len(orbsRight)]) 338 assert GSvector.flags['C_CONTIGUOUS'] 339 assert RePart.flags['C_CONTIGUOUS'] 340 assert ImPart.flags['C_CONTIGUOUS'] 341 assert orbsLeft.flags['C_CONTIGUOUS'] 342 assert orbsRight.flags['C_CONTIGUOUS'] 343 self.thisptr.GFmatrix_addition(alpha, beta, eta, &orbsLeft[0], len(orbsLeft), &orbsRight[0], len(orbsRight), isUp, &GSvector[0], Hami.thisptr, &RePart[0], &ImPart[0]) 344 return ( RePart, ImPart ) 345 def GFmatrix_rem(self, double alpha, double beta, double eta, np.ndarray[int, ndim=1, mode="c"] orbsLeft not None, np.ndarray[int, ndim=1, mode="c"] orbsRight not None, bool isUp, np.ndarray[double, ndim=1, mode="c"] GSvector not None, PyHamiltonian Hami): 346 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([len(orbsLeft)*len(orbsRight)]) 347 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([len(orbsLeft)*len(orbsRight)]) 348 assert GSvector.flags['C_CONTIGUOUS'] 349 assert RePart.flags['C_CONTIGUOUS'] 350 assert ImPart.flags['C_CONTIGUOUS'] 351 assert orbsLeft.flags['C_CONTIGUOUS'] 352 assert orbsRight.flags['C_CONTIGUOUS'] 353 self.thisptr.GFmatrix_removal(alpha, beta, eta, &orbsLeft[0], len(orbsLeft), &orbsRight[0], len(orbsRight), isUp, &GSvector[0], Hami.thisptr, &RePart[0], &ImPart[0]) 354 return ( RePart, ImPart ) 355 def DensityResponseGF(self, double omega, double eta, int orb_alpha, int orb_beta, double GSenergy, np.ndarray[double, ndim=1, mode="c"] GSvector not None): 356 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([1]) 357 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([1]) 358 assert GSvector.flags['C_CONTIGUOUS'] 359 assert RePart.flags['C_CONTIGUOUS'] 360 assert ImPart.flags['C_CONTIGUOUS'] 361 self.thisptr.DensityResponseGF(omega, eta, orb_alpha, orb_beta, GSenergy, &GSvector[0], &RePart[0], &ImPart[0]) 362 return (RePart[0], ImPart[0]) 363 def DensityResponseGF_forward(self, double omega, double eta, int orb_alpha, int orb_beta, double GSenergy, np.ndarray[double, ndim=1, mode="c"] GSvector not None, np.ndarray[double, ndim=1, mode="c"] Re2RDM not None, np.ndarray[double, ndim=1, mode="c"] Im2RDM not None, np.ndarray[double, ndim=1, mode="c"] Dens2RDM not None): 364 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([1]) 365 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([1]) 366 assert GSvector.flags['C_CONTIGUOUS'] 367 assert RePart.flags['C_CONTIGUOUS'] 368 assert ImPart.flags['C_CONTIGUOUS'] 369 assert Re2RDM.flags['C_CONTIGUOUS'] 370 assert Im2RDM.flags['C_CONTIGUOUS'] 371 assert Dens2RDM.flags['C_CONTIGUOUS'] 372 self.thisptr.DensityResponseGF_forward(omega, eta, orb_alpha, orb_beta, GSenergy, &GSvector[0], &RePart[0], &ImPart[0], &Re2RDM[0], &Im2RDM[0], &Dens2RDM[0]) 373 return (RePart[0], ImPart[0]) 374 def DensityResponseGF_backward(self, double omega, double eta, int orb_alpha, int orb_beta, double GSenergy, np.ndarray[double, ndim=1, mode="c"] GSvector not None, np.ndarray[double, ndim=1, mode="c"] Re2RDM not None, np.ndarray[double, ndim=1, mode="c"] Im2RDM not None, np.ndarray[double, ndim=1, mode="c"] Dens2RDM not None): 375 cdef np.ndarray[double, ndim=1, mode="c"] RePart = np.zeros([1]) 376 cdef np.ndarray[double, ndim=1, mode="c"] ImPart = np.zeros([1]) 377 assert GSvector.flags['C_CONTIGUOUS'] 378 assert RePart.flags['C_CONTIGUOUS'] 379 assert ImPart.flags['C_CONTIGUOUS'] 380 assert Re2RDM.flags['C_CONTIGUOUS'] 381 assert Im2RDM.flags['C_CONTIGUOUS'] 382 assert Dens2RDM.flags['C_CONTIGUOUS'] 383 self.thisptr.DensityResponseGF_backward(omega, eta, orb_alpha, orb_beta, GSenergy, &GSvector[0], &RePart[0], &ImPart[0], &Re2RDM[0], &Im2RDM[0], &Dens2RDM[0]) 384 return (RePart[0], ImPart[0]) 385 386 387