📄 xiangyang24.cpp
字号:
/*PML完全匹配层*/
#include "shuju5.h"
#include "bianjie.h"
main()
{ FILE *out;
char outfile[3];
int m,lp,loop,loop1,i,j,k,start=1000;
float Iz,Uz,Uzz[NN],Izz[NN],fs=0;
fuzhi();
printf("%f,%f,%f,%f,%f\n",dx,dy,dz,r0,c/f);
printf("%f\n",1/sqrt((1/dx)*(1/dx)+(1/dy)*(1/dy)+(1/dz)*(1/dz)));
printf("%f\n",1/(dx*dy/dz));
// printf("%f\n",1.0/(2*Pi*f*dt));
for(lp=0;lp<1;lp++)
{ f=f+5000000;dt=1.0/(f*400);
// dx=(37.0-1.0-lp)/20000;dy=(37.0-1.0-lp)/20000;sgmmax=0.0076/dx;
fuzhi();
printf("%f\n",1/sqrt((1/dx)*(1/dx)+(1/dy)*(1/dy)+(1/dz)*(1/dz)));
// printf("%f\n",1/(2*Pi*f*ee*er*dx*dy/dz));
for(loop=1;loop<=NN;loop++) /*主时间循环*/
{
m=chuanbo1(loop);
m=bianjie();
Uz=-sin(2*Pi*(loop-0.5)*f*dt)*1000*dz;
// Uz=-(sin(2*Pi*(loop-0.5)*f*dt)+sin(2*Pi*(loop-0.5)*(f+20000000)*dt)+sin(2*Pi*(loop-0.5)*(f+40000000)*dt)+sin(2*Pi*(loop-0.5)*(f+60000000)*dt)+sin(2*Pi*(loop-0.5)*(f+80000000)*dt)+sin(2*Pi*(loop-0.5)*(f+100000000)*dt)+sin(2*Pi*(loop-0.5)*(f+120000000)*dt)+sin(2*Pi*(loop-0.5)*(f+140000000)*dt)+sin(2*Pi*(loop-0.5)*(f+160000000)*dt)+sin(2*Pi*(loop-0.5)*(f+180000000)*dt)+sin(2*Pi*(loop-0.5)*(f+200000000)*dt)+sin(2*Pi*(loop-0.5)*(f+220000000)*dt)+sin(2*Pi*(loop-0.5)*(f+240000000)*dt)+sin(2*Pi*(loop-0.5)*(f+260000000)*dt)+sin(2*Pi*(loop-0.5)*(f+280000000)*dt)+sin(2*Pi*(loop-0.5)*(f+300000000)*dt))*dz*1000;
Uzz[loop-1]=Uz;
Iz=(-dx*(Hxy[Nx/2-DD/2+kx][Ny/2-DD/2+ky-1][NNN+5]-Hxy[Nx/2-DD/2+kx][Ny/2-DD/2+ky][NNN+5])-dy*(Hyz[Nx/2-DD/2+kx][Ny/2-DD/2+ky][NNN+5]-Hyz[Nx/2-DD/2+kx-1][Ny/2-DD/2+ky][NNN+5]))*1000;
Izz[loop-1]=Iz;
printf("%f,%f\n",Uz,Iz);
m=chuanbo2(loop);
printf("%d\n",loop);
printf("%f\n",Ezx[Nx/2][Ny/2][Nz/2]);
printf("%f\n",Ezy[Nx/2][Ny/2][Nz/2]);
flag3++;
if(loop==3990)
{ printf("enter the outfile name:\n");
scanf("%s",outfile);
if ((out=fopen(outfile,"w"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
for(j=0;j<Ny;j++)
{for(k=0;k<Nz;k++)
{fprintf(out,"%f ",Exy[Nx/2-5][j][k]);
}
fprintf(out,";\n");
}
fclose(out);
printf("enter the outfile name:\n");
scanf("%s",outfile);
if ((out=fopen(outfile,"w"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
for(j=0;j<Nx;j++)
{for(k=0;k<Nz;k++)
{fprintf(out,"%f ",Eyz[j][Ny/2-5][k]);
}
fprintf(out,";\n");
}
fclose(out);
printf("enter the outfile name:\n");
scanf("%s",outfile);
if ((out=fopen(outfile,"w"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
for(j=0;j<Nx;j++)
{for(k=0;k<Ny;k++)
{fprintf(out,"%f ",Ezx[j][k][Nz/2-5]);
}
fprintf(out,";\n");
}
fclose(out);
printf("enter the outfile name:\n");
scanf("%s",outfile);
if ((out=fopen(outfile,"w"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
for(j=0;j<Nx;j++)
{for(k=0;k<Ny;k++)
{fprintf(out,"%f ",sqrt(Ezx[j][k][Nz/2-5]*Ezx[j][k][Nz/2-5]+Exy[j][k][Nz/2-5]*Exy[j][k][Nz/2-5]+Eyz[j][k][Nz/2-5]*Eyz[j][k][Nz/2-5]));
}
fprintf(out,";\n");
}
fclose(out);
}
if(loop>=NN-400)
distill(loop);
}
printf("************************************\n");
// printf("频率为:%f时,第%d 运算",f,lp);
printf("************************************\n");
ffft(Uzz,Izz);
zukang();
zhubobi();
if ((out=fopen("jiexiao1","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<300;j++)
{
fprintf(out,"%f,%f\n",1/dt/Np*j,zk[j].shi);
}
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao2","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<300;j++)
{
fprintf(out,"%f,%f\n",1/dt/Np*j,zk[j].xu);
}
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao3","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<300;j++)
{
fprintf(out,"%f,%f\n",1/dt/Np*j,rou[j]);
}
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao4","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<300;j++)
{ fs+=(1/dt)/Np;
fprintf(out,"%f:%f+i*%f \n ",fs,zk[j].shi,zk[j].xu);
}
fs=0;
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao5","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{
{ for(j=0;j<NN/2;j++)
fprintf(out,"%f+(%f)*i \n ",pp1[j].shi,pp1[j].xu);
}
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao6","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<NN/2;j++)
fprintf(out," %f+(%f)*i \n",pp2[j].shi,pp2[j].xu);
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao7","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<300;j++)
fprintf(out," %f+(%f)*i \n",pr[j].shi,pr[j].xu);
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao8","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<NN;j++)
fprintf(out,"%f ",Uzz[j]);
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
if ((out=fopen("jiexiao9","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<NN;j++)
fprintf(out,"%f ",Izz[j]);
fprintf(out,"\n \n %f \n \n",f);
}
fclose(out);
waitui(0);
{
if ((out=fopen("jiexiao10","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<=180;j++)
fprintf(out,"%f\n",sqrt(fxhs[j].shi*fxhs[j].shi+fxhs[j].xu*fxhs[j].xu));
fprintf(out,"\n\n\n\n");
}
}
waitui(90);
{
if ((out=fopen("jiexiao11","a"))==NULL)
{printf("cannot open outfile\n");
goto end;
}
else
{ for(j=0;j<=180;j++)
fprintf(out,"%f\n",sqrt(fxhs[j].shi*fxhs[j].shi+fxhs[j].xu*fxhs[j].xu));
fprintf(out,"\n\n\n\n");
}
}
}
end: return(0);
}
void fuzhi()
{int loop1,loop2,loop3;
for(loop1=0;loop1<Nx;loop1++)
{ for(loop2=0;loop2<Ny+1;loop2++)
{for(loop3=0;loop3<Nz+1;loop3++)
{ Exy[loop1][loop2][loop3]=0;
Exz[loop1][loop2][loop3]=0;
}
}
} /*给x向电场赋初值*/
for(loop1=0;loop1<Nx+1;loop1++)
{ for(loop2=0;loop2<Ny;loop2++)
{for(loop3=0;loop3<Nz+1;loop3++)
{ Eyx[loop1][loop2][loop3]=0;
Eyz[loop1][loop2][loop3]=0;
}
}
} /*给y向电场赋初值*/
for(loop1=0;loop1<Nx+1;loop1++)
{ for(loop2=0;loop2<Ny+1;loop2++)
{for(loop3=0;loop3<Nz;loop3++)
{ Ezx[loop1][loop2][loop3]=0;
Ezy[loop1][loop2][loop3]=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -