int main() { double **Fmunu; double *x0, *x1, *zr1, *zr0, *zi1, *zi0, *p1, *p0; double *x2, *x3, *zr2, *zr3, *zi2, *zi3, *p2, *p3; double *xdot, *zrdot, *zidot, *pdot; double *xdot1, *zrdot1, *zidot1, *pdot1; double *xdot2, *zrdot2, *zidot2, *pdot2; double *xdot3, *zrdot3, *zidot3, *pdot3; double alpha, beta,t=0., H=0.,dt=dt0,v0, theta[7]; char name[400]; int i=0; FILE *IfPtr; sprintf(name,"CE_trajectory_RK_%d_.dat",run_name); if ( ( IfPtr = fopen( name, "w" ) ) == NULL ) printf( "File could not be opened. %s\n",name); Fmunu=allocate_2(4,4); x0=allocate_1(4); x1=allocate_1(4); x2=allocate_1(4); x3=allocate_1(4); zr0=allocate_1(4); zr1=allocate_1(4); zr2=allocate_1(4); zr3=allocate_1(4); zi0=allocate_1(4); zi1=allocate_1(4); zi2=allocate_1(4); zi3=allocate_1(4); p0=allocate_1(4); p1=allocate_1(4); p2=allocate_1(4); p3=allocate_1(4); xdot=allocate_1(4); xdot1=allocate_1(4); xdot2=allocate_1(4); xdot3=allocate_1(4); zrdot=allocate_1(4); zrdot1=allocate_1(4); zrdot2=allocate_1(4); zrdot3=allocate_1(4); zidot=allocate_1(4); zidot1=allocate_1(4); zidot2=allocate_1(4); zidot3=allocate_1(4); pdot=allocate_1(4); pdot1=allocate_1(4); pdot2=allocate_1(4); pdot3=allocate_1(4); //Initialize EM filed and charge state. ConstantEB(Fmunu); x0[0]=0.; x0[1]=0.; x0[2]=0.; x0[3]=0.; theta[0]=0.25*M_PI; theta[1]=0.25*M_PI; theta[2]=0.5*M_PI; theta[3]=0.5*M_PI; theta[4]=0.5*M_PI; theta[5]=0.25*M_PI; theta[6]=0.*M_PI; /** zr0[0]=cos(theta[0])*cos(theta[1]); zr0[1]=cos(theta[0])*sin(theta[1])*cos(theta[2]); zr0[2]=cos(theta[0])*sin(theta[1])*sin(theta[2])*cos(theta[3]); zr0[3]=cos(theta[0])*sin(theta[1])*sin(theta[2])*sin(theta[3]); zi0[0]=sin(theta[0])*cos(theta[4]); zi0[1]=sin(theta[0])*sin(theta[4])*cos(theta[5]); zi0[2]=sin(theta[0])*sin(theta[4])*sin(theta[5])*cos(theta[6]); zi0[3]=sin(theta[0])*sin(theta[4])*sin(theta[5])*sin(theta[6]); /**/ zr0[0]=1.; zr0[1]=0.; zr0[2]=0.; zr0[3]=-zr0[0]; theta[0]=-1.*M_PI; zi0[0]=0.; zi0[1]=0.*cos(theta[0]); zi0[2]=0.*sin(theta[0]); zi0[3]=0.; /**/ alpha=1.*0.5*M_PI; beta=0.*2.*M_PI; p0[0]=0.; p0[1]=p0[0]*cos(alpha); p0[2]=p0[0]*sin(alpha)*sin(beta); p0[3]=p0[0]*sin(alpha)*cos(beta); p0[0]=sqrt(1.+p0[1]*p0[1]+p0[2]*p0[2]+p0[3]*p0[3]); while(t<T && p0[0]*p0[0]-p0[1]*p0[1]-p0[2]*p0[2]-p0[3]*p0[3]>-0.1){ assingAtoB(zr0,zr1); assingAtoB(zi0,zi1); assingAtoB(p0,p1); assingAtoB(x0,x1); assingAtoB(zr0,zr2); assingAtoB(zi0,zi2); assingAtoB(p0,p2); assingAtoB(x0,x2); assingAtoB(zr0,zr3); assingAtoB(zi0,zi3); assingAtoB(p0,p3); assingAtoB(x0,x3); XDOT(zr0,zi0,xdot); ZDOT(zr0,zi0,p0,zrdot,zidot);/** OneOverr2E(Fmunu,x0);/**/ PDOT(Fmunu,xdot,pdot); v0=sqrt(xdot[1]*xdot[1]+xdot[2]*xdot[2]+xdot[3]*xdot[3]); // if(v0*dt>1.e-3) // dt=1.e-3/v0; // else dt=dt0; H=-p0[0]*xdot[0]+p0[1]*xdot[1]+p0[2]*xdot[2]+p0[3]*xdot[3]; alpha=zr0[0]*zr0[0]+zr0[1]*zr0[1]-zr0[2]*zr0[2]-zr0[3]*zr0[3]; alpha+=zi0[0]*zi0[0]+zi0[1]*zi0[1]-zi0[2]*zi0[2]-zi0[3]*zi0[3]; if(i%20==0){ fprintf(IfPtr,"%e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",t,H,x0[0],x0[1],x0[2],x0[3],p0[0],p0[1],p0[2],p0[3],zr0[0],zr0[1],zr0[2],zr0[3],zi0[0],zi0[1],zi0[2],zi0[3],xdot[0],xdot[1],xdot[2],xdot[3],alpha); printf("%e %e %e %e %e\n",t,x0[0],x0[1],x0[2],x0[3]); } /**/ x1[0]+=0.5*dt*xdot[0]; x1[1]+=0.5*dt*xdot[1]; x1[2]+=0.5*dt*xdot[2]; x1[3]+=0.5*dt*xdot[3]; zr1[0]+=0.5*dt*zrdot[0]; zr1[1]+=0.5*dt*zrdot[1]; zr1[2]+=0.5*dt*zrdot[2]; zr1[3]+=0.5*dt*zrdot[3]; zi1[0]+=0.5*dt*zidot[0]; zi1[1]+=0.5*dt*zidot[1]; zi1[2]+=0.5*dt*zidot[2]; zi1[3]+=0.5*dt*zidot[3]; p1[0]+=0.5*dt*pdot[0]; p1[1]+=0.5*dt*pdot[1]; p1[2]+=0.5*dt*pdot[2]; p1[3]+=0.5*dt*pdot[3]; XDOT(zr1,zi1,xdot1); ZDOT(zr1,zi1,p1,zrdot1,zidot1);/** OneOverr2E(Fmunu,x1);/**/ PDOT(Fmunu,xdot1,pdot1); x2[0]+=0.5*dt*xdot1[0]; x2[1]+=0.5*dt*xdot1[1]; x2[2]+=0.5*dt*xdot1[2]; x2[3]+=0.5*dt*xdot1[3]; zr2[0]+=0.5*dt*zrdot1[0]; zr2[1]+=0.5*dt*zrdot1[1]; zr2[2]+=0.5*dt*zrdot1[2]; zr2[3]+=0.5*dt*zrdot1[3]; zi2[0]+=0.5*dt*zidot1[0]; zi2[1]+=0.5*dt*zidot1[1]; zi2[2]+=0.5*dt*zidot1[2]; zi2[3]+=0.5*dt*zidot1[3]; p2[0]+=0.5*dt*pdot1[0]; p2[1]+=0.5*dt*pdot1[1]; p2[2]+=0.5*dt*pdot1[2]; p2[3]+=0.5*dt*pdot1[3]; XDOT(zr2,zi2,xdot2); ZDOT(zr2,zi2,p2,zrdot2,zidot2);/** OneOverr2E(Fmunu,x2);/**/ PDOT(Fmunu,xdot2,pdot2); x3[0]+=dt*xdot2[0]; x3[1]+=dt*xdot2[1]; x3[2]+=dt*xdot2[2]; x3[3]+=dt*xdot2[3]; zr3[0]+=dt*zrdot2[0]; zr3[1]+=dt*zrdot2[1]; zr3[2]+=dt*zrdot2[2]; zr3[3]+=dt*zrdot2[3]; zi3[0]+=dt*zidot2[0]; zi3[1]+=dt*zidot2[1]; zi3[2]+=dt*zidot2[2]; zi3[3]+=dt*zidot2[3]; p3[0]+=dt*pdot2[0]; p3[1]+=dt*pdot2[1]; p3[2]+=dt*pdot2[2]; p3[3]+=dt*pdot2[3]; XDOT(zr3,zi3,xdot3); ZDOT(zr3,zi3,p3,zrdot3,zidot3);/** OneOverr2E(Fmunu,x3);/**/ PDOT(Fmunu,xdot3,pdot3); /**/ x0[0]+=dt*(xdot[0]+2.*xdot1[0]+2.*xdot2[0]+xdot3[0])/6.; x0[1]+=dt*(xdot[1]+2.*xdot1[1]+2.*xdot2[1]+xdot3[1])/6.; x0[2]+=dt*(xdot[2]+2.*xdot1[2]+2.*xdot2[2]+xdot3[2])/6.; x0[3]+=dt*(xdot[3]+2.*xdot1[3]+2.*xdot2[3]+xdot3[3])/6.; zr0[0]+=dt*(zrdot[0]+2.*zrdot1[0]+2.*zrdot2[0]+zrdot3[0])/6.; zr0[1]+=dt*(zrdot[1]+2.*zrdot1[1]+2.*zrdot2[1]+zrdot3[1])/6.; zr0[2]+=dt*(zrdot[2]+2.*zrdot1[2]+2.*zrdot2[2]+zrdot3[2])/6.; zr0[3]+=dt*(zrdot[3]+2.*zrdot1[3]+2.*zrdot2[3]+zrdot3[3])/6.; zi0[0]+=dt*(zidot[0]+2.*zidot1[0]+2.*zidot2[0]+zidot3[0])/6.; zi0[1]+=dt*(zidot[1]+2.*zidot1[1]+2.*zidot2[1]+zidot3[1])/6.; zi0[2]+=dt*(zidot[2]+2.*zidot1[2]+2.*zidot2[2]+zidot3[2])/6.; zi0[3]+=dt*(zidot[3]+2.*zidot1[3]+2.*zidot2[3]+zidot3[3])/6.; p0[0]+=dt*(pdot[0]+2.*pdot1[0]+2.*pdot2[0]+pdot3[0])/6.; p0[1]+=dt*(pdot[1]+2.*pdot1[1]+2.*pdot2[1]+pdot3[1])/6.; p0[2]+=dt*(pdot[2]+2.*pdot1[2]+2.*pdot2[2]+pdot3[2])/6.; p0[3]+=dt*(pdot[3]+2.*pdot1[3]+2.*pdot2[3]+pdot3[3])/6.; t+=dt; i++; } freemn(Fmunu,4); free(Fmunu); free(x0); free(x1); free(x2); free(x3); free(zr0); free(zr1); free(zr2); free(zr3); free(zi0); free(zi1); free(zi2); free(zi3); free(p0); free(p1); free(p2); free(p3); free(xdot); free(xdot1); free(xdot2); free(xdot3); free(pdot); free(pdot1); free(pdot2); free(pdot3); free(zrdot); free(zrdot1); free(zrdot2); free(zrdot3); free(zidot); free(zidot1); free(zidot2); free(zidot3); fclose(IfPtr); return 0; }
void CNAME(BLASLONG m, BLASLONG n, BLASLONG ku, BLASLONG kl, FLOAT alpha_r, FLOAT alpha_i, FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG incx, FLOAT *y, BLASLONG incy, void *buffer){ BLASLONG i, offset_u, offset_l, start, end, length; FLOAT *X = x; FLOAT *Y = y; FLOAT *gemvbuffer = (FLOAT *)buffer; FLOAT *bufferY = gemvbuffer; FLOAT *bufferX = gemvbuffer; #ifdef TRANS FLOAT _Complex temp; #endif if (incy != 1) { Y = bufferY; bufferX = (FLOAT *)(((BLASLONG)bufferY + M * sizeof(FLOAT) * 2 + 4095) & ~4095); gemvbuffer = bufferX; COPY_K(M, y, incy, Y, 1); } if (incx != 1) { X = bufferX; gemvbuffer = (FLOAT *)(((BLASLONG)bufferX + N * sizeof(FLOAT) * 2 + 4095) & ~4095); COPY_K(N, x, incx, X, 1); } offset_u = ku; offset_l = ku + m; for (i = 0; i < MIN(n, m + ku); i++) { start = MAX(offset_u, 0); end = MIN(offset_l, ku + kl + 1); length = end - start; #ifndef TRANS ZAXPY(length, 0, 0, #ifndef XCONJ alpha_r * X[i * 2 + 0] - alpha_i * X[i * 2 + 1], alpha_i * X[i * 2 + 0] + alpha_r * X[i * 2 + 1], #else alpha_r * X[i * 2 + 0] + alpha_i * X[i * 2 + 1], alpha_i * X[i * 2 + 0] - alpha_r * X[i * 2 + 1], #endif a + start * 2, 1, Y + (start - offset_u) * 2, 1, NULL, 0); #else #ifndef XCONJ temp = ZDOT(length, a + start * 2, 1, X + (start - offset_u) * 2, 1); #else temp = ZDOT(length, X + (start - offset_u) * 2, 1, a + start * 2, 1); #endif #if !defined(XCONJ) || !defined(CONJ) Y[i * 2 + 0] += alpha_r * CREAL(temp) - alpha_i * CIMAG(temp); Y[i * 2 + 1] += alpha_i * CREAL(temp) + alpha_r * CIMAG(temp); #else Y[i * 2 + 0] += alpha_r * CREAL(temp) + alpha_i * CIMAG(temp); Y[i * 2 + 1] += alpha_i * CREAL(temp) - alpha_r * CIMAG(temp); #endif #endif offset_u --; offset_l --; a += lda * 2; } if (incy != 1) { COPY_K(M, Y, 1, y, incy); } return; }