StatMech
Loading...
Searching...
No Matches
generateRM.cuh File Reference

Functions

__global__ void MatrixElementsInSector (Complex_t *dmatTot, Integer_t const LDT, Complex_t const *__restrict__ dmatLoc, Integer_t const LDL, Integer_t const numLoc, Integer_t const n, Integer_t const dloc, Integer_t const momentum, Integer_t const SecDim, Integer_t const numPairs, Integer_t const *representatives, Integer_t const *periodicity, Real_t const *__restrict__ dfactor)
 
__device__ Complex_t< double > MAGMA_CEXP (Real_t theta)
 
__device__ Complex_t transEigenMatrixElements (Integer_t const idx, Integer_t const idy, Complex_t const *__restrict__ dmatLoc, Integer_t const LDL, Integer_t const n, Integer_t const dloc, Integer_t const momentum, Integer_t const *representatives, Integer_t const *periodicity, Real_t const *__restrict__ dfactor)
 

Variables

std::vector< Real_t * > prefactorH
 
std::vector< Real_t * > prefactorOp
 

Function Documentation

◆ MAGMA_CEXP()

__device__ Complex_t< float > MAGMA_CEXP ( Real_t  theta)
132 {
133 return MAGMA_Z_MAKE(cos(theta),sin(theta));
134}

◆ MatrixElementsInSector()

__global__ void MatrixElementsInSector ( Complex_t dmatTot,
Integer_t const  LDT,
Complex_t const *__restrict__  dmatLoc,
Integer_t const  LDL,
Integer_t const  numLoc,
Integer_t const  n,
Integer_t const  dloc,
Integer_t const  momentum,
Integer_t const  SecDim,
Integer_t const  numPairs,
Integer_t const *  representatives,
Integer_t const *  periodicity,
Real_t const *__restrict__  dfactor 
)
183 {
184 Integer_t const dim = (momentum==0) ? (SecDim - numPairs) : SecDim;
185 Integer_t const numParityEigens = (momentum==0) ? (SecDim - 2*numPairs) : SecDim;
186
187 int const idx = blockIdx.x*blockDim.x +threadIdx.x;
188 int const idy = blockIdx.y*blockDim.y +threadIdx.y;
189 if(idx>=dim || idy>=dim) return;
190 if(idx < idy) {
191 // dmatTot[idx+LDT*idy] = {NAN,NAN};
192 return;
193 }
194
195 if(idy < numParityEigens) {
196 if(idx < numParityEigens) {
197 dmatTot[idx+LDT*idy] = transEigenMatrixElements(idx, idy, dmatLoc, LDL, n, dloc, momentum, representatives, periodicity, dfactor);
198 } else {
199 Complex_t tempMatElem1 = transEigenMatrixElements(idx, idy, dmatLoc, LDL, n, dloc, momentum, representatives, periodicity, dfactor);
200 Complex_t tempMatElem2 = transEigenMatrixElements(idx+numPairs, idy, dmatLoc, LDL, n, dloc, momentum, representatives, periodicity, dfactor);
201 dmatTot[idx+LDT*idy] = (tempMatElem1 + tempMatElem2)/sqrt(2.0);
202 }
203 } else {
204 Complex_t tempMatElem1 = transEigenMatrixElements(idx, idy, dmatLoc, LDL, n, dloc, momentum, representatives, periodicity, dfactor);
205 Complex_t tempMatElem2 = transEigenMatrixElements(idx+numPairs, idy, dmatLoc, LDL, n, dloc, momentum, representatives, periodicity, dfactor);
206 dmatTot[idx+LDT*idy] = tempMatElem1 + tempMatElem2;
207 }
208
209 dmatTot[idy+LDT*idx] = conj(dmatTot[idx+LDT*idy]);
210 if( isnan(real(conj(dmatTot[idy+LDT*idx])*dmatTot[idy+LDT*idx])) ) printf("(idx,idy) = (%d,%d)\n", idx, idy);
211 if(idx==idy) dmatTot[idx+LDT*idx] = dComplexOne<>*real(dmatTot[idx+LDT*idx]);
212
213 return;
214}
__device__ Complex_t transEigenMatrixElements(Integer_t const idx, Integer_t const idy, Complex_t const *__restrict__ dmatLoc, Integer_t const LDL, Integer_t const n, Integer_t const dloc, Integer_t const momentum, Integer_t const *representatives, Integer_t const *periodicity, Real_t const *__restrict__ dfactor)
Definition generateRM.cuh:141
Definition mytypes.hpp:147
MKL_INT Integer_t
Definition mytypes.hpp:359

◆ transEigenMatrixElements()

__device__ Complex_t transEigenMatrixElements ( Integer_t const  idx,
Integer_t const  idy,
Complex_t const *__restrict__  dmatLoc,
Integer_t const  LDL,
Integer_t const  n,
Integer_t const  dloc,
Integer_t const  momentum,
Integer_t const *  representatives,
Integer_t const *  periodicity,
Real_t const *__restrict__  dfactor 
)
141 {
142 Integer_t trans1, trans2;
143 Integer_t Id1, Id2, locId1, locId2;
144 Integer_t Ndiff, diff, pos;
145 double theta;
146
147 Complex_t res = dComplexZero<>;
148 for(trans1 = 0;trans1 < periodicity[idx]; ++trans1) {
149 Id1 = transSpin(representatives[idx],trans1,dloc,n);
150 for(trans2 = 0;trans2 < periodicity[idy]; ++trans2) {
151 Id2 = transSpin(representatives[idy],trans2,dloc,n);
152 theta = 2.0*M_PI*momentum*(trans2-trans1)/(Real_t)n;
153 Ndiff = 0;
154 for(pos = 1;pos<n && Ndiff<2; ++pos) {
155 if( Bit(Id1,pos,dloc,n)!=Bit(Id2,pos,dloc,n) ) { Ndiff+=1; diff=pos; }
156 }
157 switch(Ndiff){
158 case 0:
159 for(diff = 1;diff < n; ++diff) {
160 locId1 = Bit(Id1,0,dloc,n) + dloc*Bit(Id1,diff,dloc,n);
161 locId2 = Bit(Id2,0,dloc,n) + dloc*Bit(Id2,diff,dloc,n);
162 if(locId1+LDL*locId2 >= 16) printf("# Case0: locId1+LDL*locId2 = %lld+%lld*%lld = %lld\n", locId1, LDL, locId2, locId1+LDL*locId2);
163 res += dfactor[diff]*dmatLoc[locId1+LDL*locId2]*MAGMA_CEXP(theta);
164 }
165 break;
166 case 1:
167 locId1 = Bit(Id1,0,dloc,n) + dloc*Bit(Id1,diff,dloc,n);
168 locId2 = Bit(Id2,0,dloc,n) + dloc*Bit(Id2,diff,dloc,n);
169 if(locId1+LDL*locId2 >= 16) printf("# Case1: locId1+LDL*locId2 = %lld+%lld*%lld = %lld\n", locId1, LDL, locId2, locId1+LDL*locId2);
170 res += dfactor[diff]*dmatLoc[locId1+LDL*locId2]*MAGMA_CEXP(theta);
171 break;
172 default:
173 continue;
174 }
175 }
176 }
177 res /= sqrt( (Real_t)periodicity[idx]*periodicity[idy] );
178
179 // if( isnan(real(conj(res)*res)) ) printf("(idx,idy) = (%lld,%lld)\n", idx, idy);
180 return res;
181}
__device__ Complex_t< double > MAGMA_CEXP(Real_t theta)
Definition generateRM.cuh:132
double Real_t
Definition mytypes.hpp:37

Variable Documentation

◆ prefactorH

std::vector<Real_t*> prefactorH

◆ prefactorOp

std::vector<Real_t*> prefactorOp