bool GLGPUDataset::A(const float X[3], float A[3], int slot) const { if (B(slot)[1]>0) { A[0] = -Kex(slot); A[1] = X[0] * B(slot)[2]; A[2] = -X[0] * B(slot)[1]; } else { A[0] = -X[1] * B(slot)[2] - Kex(slot); A[1] = 0; A[2] = X[1] * B(slot)[0]; } return true; }
void GLGPUDataset::SerializeDataInfoToString(std::string& buf) const { #if WITH_PROTOBUF PBDataInfo pb; pb.set_model(PBDataInfo::GLGPU); pb.set_name(_data_name); if (Lengths()[0]>0) { pb.set_ox(Origins()[0]); pb.set_oy(Origins()[1]); pb.set_oz(Origins()[2]); pb.set_lx(Lengths()[0]); pb.set_ly(Lengths()[1]); pb.set_lz(Lengths()[2]); } pb.set_bx(B()[0]); pb.set_by(B()[1]); pb.set_bz(B()[2]); pb.set_kex(Kex()); pb.set_dx(dims()[0]); pb.set_dy(dims()[1]); pb.set_dz(dims()[2]); pb.set_pbc_x(pbc()[0]); pb.set_pbc_y(pbc()[0]); pb.set_pbc_z(pbc()[0]); pb.SerializeToString(&buf); #endif }
double GLGPU3DDataset::GaugeTransformation(const double X0[], const double X1[]) const { double gx, gy, gz; double dx = X1[0] - X0[0], dy = X1[1] - X0[1], dz = X1[2] - X0[2]; double x = X0[0] + 0.5*dx, y = X0[1] + 0.5*dy, z = X0[2] + 0.5*dz; if (By()>0) { // Y-Z gauge gx = dx * Kex(); gy =-dy * x * Bz(); // -dy*x^hat*Bz gz = dz * x * By(); // dz*x^hat*By } else { // X-Z gauge gx = dx * y * Bz() + dx * Kex(); // dx*y^hat*Bz + dx*K gy = 0; gz =-dz * y * Bx(); // -dz*y^hat*Bx } return gx + gy + gz; }
void GLGPUDataset::ModulateKex(int slot) { float K = Kex(slot); float *re = slot == 0 ? _re : _re1, *im = slot == 0 ? _im : _im1; for (int i=0; i<dims()[0]; i++) for (int j=0; j<dims()[1]; j++) for (int k=0; k<dims()[2]; k++) { const int idx[3] = {i, j, k}; NodeIdType nid = Idx2Nid(idx); float x = i * CellLengths()[0] + Origins()[0]; float rho = sqrt(re[nid]*re[nid] + im[nid]*im[nid]), // phi = atan2(im[nid], re[nid]) - K*x; phi = atan2(im[nid], re[nid]) + K*x; re[nid] = rho * cos(phi); im[nid] = rho * sin(phi); } }
void GLGPU3DDataset::ComputeSupercurrentField(int slot) { const int nvoxels = dims()[0]*dims()[1]*dims()[2]; if (_J[slot] != NULL) free(_J[slot]); _J[slot] = (double*)malloc(3*sizeof(double)*nvoxels); double *J = _J[slot]; memset(J, 0, 3*sizeof(double)*nvoxels); double u, v, rho2; double du[3], dv[3], A[3], j[3]; // central difference for (int x=1; x<dims()[0]-1; x++) { for (int y=1; y<dims()[1]-1; y++) { for (int z=1; z<dims()[2]-1; z++) { int idx[3] = {x, y, z}; double pos[3]; Idx2Pos(idx, pos); du[0] = 0.5 * (Re(x+1, y, z, slot) - Re(x-1, y, z, slot)) / dx(); du[1] = 0.5 * (Re(x, y+1, z, slot) - Re(x, y-1, z, slot)) / dy(); du[2] = 0.5 * (Re(x, y, z+1, slot) - Re(x, y, z-1, slot)) / dz(); dv[0] = 0.5 * (Im(x+1, y, z, slot) - Im(x-1, y, z, slot)) / dx(); dv[1] = 0.5 * (Im(x, y+1, z, slot) - Im(x, y-1, z, slot)) / dy(); dv[2] = 0.5 * (Im(x, y, z+1, slot) - Im(x, y, z-1, slot)) / dz(); this->A(pos, A, slot); u = Re(x, y, z, slot); v = Im(x, y, z, slot); rho2 = u*u + v*v; texel3Dv(J, dims(), 3, x, y, z, 0) = j[0] = (u*dv[0] - v*du[0]) - rho2*(A[0] + Kex()); // + Kex(); texel3Dv(J, dims(), 3, x, y, z, 1) = j[1] = (u*dv[1] - v*du[1]) - rho2*A[1]; texel3Dv(J, dims(), 3, x, y, z, 2) = j[2] = (u*dv[2] - v*du[2]) - rho2*A[2]; // fprintf(stderr, "J={%f, %f, %f}\n", j[0], j[1], j[2]); } } } }
float Ax(const float X[3], int slot=0) const {if (By()>0) return -Kex(slot); else return -X[1]*Bz()-Kex(slot);}