📄 f_analytic.c
字号:
/* for (n = 0 ; n < N ; n++){ jnkr[n] = Spherical_j_n(n,kr); jnka[n] = Spherical_j_n(n,ka); Spherical_h_n(1,n,kr,&hnkrr[n],&hnkri[n]); Spherical_h_n(1,n,ka,&hnkar[n],&hnkai[n]); } */ for (n = 0 ; n < N ; n++){ V_mi.Val[0] = 0.; V_mi.Val[MAX_DIM] = -1.; V_tmp.Val[0] = n ; V_tmp.Val[MAX_DIM] = 0.; Cal_PowerValue (&V_mi, &V_tmp, &V_mi); V_jnkr.Val[0] = jnkr[n]; V_jnkr.Val[MAX_DIM] = 0; V_jnka.Val[0] = jnka[n]; V_jnka.Val[MAX_DIM] = 0; V_hnkr.Val[0] = hnkrr[n]; V_hnkr.Val[MAX_DIM] = hnkri[n]; V_hnka.Val[0] = hnkar[n]; V_hnka.Val[MAX_DIM] = hnkai[n]; Cal_ComplexDivision(V_jnka.Val,V_hnka.Val,V_an.Val); Cal_ComplexProduct(V_an.Val,V_hnkr.Val,V_tmp.Val); V_tmp.Val[0] = V_jnkr.Val[0] - V_tmp.Val[0]; V_tmp.Val[MAX_DIM] = V_jnkr.Val[MAX_DIM] - V_tmp.Val[MAX_DIM]; Cal_ComplexProduct(V_mi.Val,V_tmp.Val,V_tmp2.Val); fact = (2*n+1) * Legendre(n,0,cos(theta)); V->Val[0] += fact * V_tmp2.Val[0] ; V->Val[MAX_DIM] += fact * V_tmp2.Val[MAX_DIM] ; }#undef N }/* ------------------------------------------------------------------------ *//* Exact solutions for cylinders *//* ------------------------------------------------------------------------ *//* Solid or hollow cylinder, in magnetostatic and magnetodynamics */void F_Cylinder (F_ARG) { int type ; double x, y ; double valx[2], valy[2]; double bxr, bxi, byr, byi, phir, phii=0 ; double mur, sigma, freq, b0, r0, r1 ; GetDP_Begin("F_Cylinder"); valx[0] = 0.0 ; valx[1] = 0.0 ; valy[0] = 0.0 ; valy[1] = 0.0 ; x = Current.x; y = Current.y; mur = Fct->Para[0] ; sigma = Fct->Para[1] ; freq = Fct->Para[2] ; b0 = Fct->Para[3] ; r0 = Fct->Para[4] ; r1 = Fct->Para[5] ; type = (int)Fct->Para[6] ; if (r0 == 0.0) solcyl_(&x,&y,&bxr,&bxi,&byr,&byi,&b0,&mur,&sigma,&freq,&r1); else hollowcyl(x,y,&bxr,&byr,&phir,b0,mur,r0,r1); if(type == 0){ valx[0] = bxr ; valx[1] = bxi ; valy[0] = byr ; valy[1] = byi ; } else{ valx[0] = phir ; valx[1] = phii ; } if (Current.NbrHar == 1) { V->Val[0] = valx[0] ; V->Val[1] = valy[0] ; V->Val[2] = 0.0 ; } else { V->Val[0] = valx[0] ; V->Val[1] = valy[0] ; V->Val[2] = 0.0 ; V->Val[MAX_DIM] = valx[1] ; V->Val[MAX_DIM+1] = valy[1] ; V->Val[MAX_DIM+2] = 0.0 ; } V->Type = VECTOR ; GetDP_End ;}/* Scattering by solid PEC cylinder, incident wave z-polarized. Returns current on cylinder surface */void F_JFIE_ZPolCyl(F_ARG){ double k0, r, kr, e0, eta, phi, a, b, c, d, den ; int i, ns ; GetDP_Begin("F_JFIE_ZPolCyl") ; phi = atan2( A->Val[1], A->Val[0] ) ; k0 = Fct->Para[0] ; eta = Fct->Para[1] ; e0 = Fct->Para[2] ; r = Fct->Para[3] ; kr = k0*r ; ns = 100 ; V->Val[0] = 0.; V->Val[MAX_DIM] = 0. ; for (i = -ns ; i <= ns ; i++ ){ a = cos(i*(phi-(PI/2))) ; b = sin(i*(phi-(PI/2))) ; c = jn(i,kr) ; d = -yn(i,kr) ; den = c*c+d*d ; V->Val[0] += (a*c+b*d)/den ; V->Val[MAX_DIM] += (b*c-a*d)/den ; } V->Val[0] *= -2*e0/kr/eta/PI ; V->Val[MAX_DIM] *= -2*e0/kr/eta/PI ; V->Type = SCALAR ; GetDP_End;} /* Scattering by solid PEC cylinder, incident wave z-polarized. Returns RCS */void F_RCS_ZPolCyl(F_ARG){ double k0, r, kr, rinf, krinf, phi, a, b, d,den ; double lambda, bjn, rr = 0., ri = 0. ; int i, ns ; GetDP_Begin("F_RCS_ZPolCyl") ; phi = atan2( A->Val[1], A->Val[0] ) ; k0 = Fct->Para[0] ; r = Fct->Para[1] ; rinf = Fct->Para[2] ; kr = k0*r ; krinf = k0*rinf ; lambda = 2*PI/k0 ; ns = 100 ; for (i = -ns ; i <= ns ; i++ ){ bjn = jn(i,kr) ; a = bjn * cos(i*phi) ; b = bjn * sin(i*phi) ; d = -yn(i,kr) ; den = bjn*bjn+d*d ; rr += (a*bjn+b*d)/den ; ri += (b*bjn-a*d)/den ; } V->Val[0] = 10*log10( 4*PI*SQU(rinf/lambda) * 2/krinf/PI *(SQU(rr)+SQU(ri)) ) ; V->Val[MAX_DIM] = 0. ; V->Type = SCALAR ; GetDP_End;} /* Scattering by solid PEC cylinder, incident wave polarized transversely to z. Returns current on cylinder surface */void F_JFIE_TransZPolCyl(F_ARG){ double k0, r, kr, h0, phi, a, b, c, d, den ; int i, ns ; GetDP_Begin("F_JFIE_TransZPolCyl") ; phi = atan2( A->Val[1], A->Val[0] ) ; k0 = Fct->Para[0] ; h0 = Fct->Para[1] ; r = Fct->Para[2] ; kr = k0*r ; ns = 100 ; V->Val[0] = 0.; V->Val[MAX_DIM] = 0. ; for (i = -ns ; i <= ns ; i++ ){ a = cos(PI/2 +i*(phi-(PI/2))) ; b = sin(PI/2 +i*(phi-(PI/2))) ; c = -jn(i+1,kr) + (i/kr)*jn(i,kr) ; d = yn(i+1,kr) - (i/kr)*yn(i,kr) ; den = c*c+d*d ; V->Val[0] += (a*c+b*d)/den ; V->Val[MAX_DIM] += (b*c-a*d)/den ; } V->Val[0] *= 2*h0/kr/PI ; V->Val[MAX_DIM] *= 2*h0/kr/PI ; V->Type = SCALAR ; GetDP_End;} /* Scattering by acoustically soft circular cylinder of radius R, under plane wave incidence e^{ikx}. Returns field outside */void F_AcousticFieldSoftCylinder(F_ARG){ cplx I = {0.,1.}, HnkR, Hnkr, tmp; double k, R, r, kr, kR, theta, cost ; int n, ns ; GetDP_Begin("F_AcousticFieldSoftCylinder") ; theta = atan2(A->Val[1], A->Val[0]) ; r = sqrt(A->Val[0]*A->Val[0] + A->Val[1]*A->Val[1]) ; k = Fct->Para[0] ; R = Fct->Para[1] ; kr = k*r; kR = k*R; V->Val[0] = 0.; V->Val[MAX_DIM] = 0. ; ns = (int)k + 10; for (n = 0 ; n < ns ; n++){ HnkR.r = jn(n,kR); HnkR.i = yn(n,kR); Hnkr.r = jn(n,kr); Hnkr.i = yn(n,kr); tmp = Cdiv( Cprod( Cpow(I,n) , Cprodr( HnkR.r, Hnkr) ) , HnkR ); cost = cos(n*theta); V->Val[0] += cost * tmp.r * (!n ? 0.5 : 1.); V->Val[MAX_DIM] += cost * tmp.i * (!n ? 0.5 : 1.); } V->Val[0] *= -2; V->Val[MAX_DIM] *= -2; V->Type = SCALAR ; GetDP_End;} cplx DHn(cplx *Hnkrtab, int n, double x){ if(n == 0){ return Cneg(Hnkrtab[1]); } else{ return Csub( Hnkrtab[n-1] , Cprodr((double)n/x, Hnkrtab[n]) ); }}/* Scattering by acoustically soft circular cylinder of radius R, under plane wave incidence e^{ikx}. Returns radial derivative of the solution of the Helmholtz equation outside */void F_DrAcousticFieldSoftCylinder(F_ARG){ cplx I = {0.,1.}, HnkR, tmp, *Hnkrtab; double k, R, r, kr, kR, theta, cost ; int n, ns ; GetDP_Begin("F_DrAcousticFieldSoftCylinder") ; theta = atan2(A->Val[1], A->Val[0]) ; r = sqrt(A->Val[0]*A->Val[0] + A->Val[1]*A->Val[1]) ; k = Fct->Para[0] ; R = Fct->Para[1] ; kr = k*r; kR = k*R; V->Val[0] = 0.; V->Val[MAX_DIM] = 0. ; ns = (int)k + 10; Hnkrtab = (cplx*)Malloc(ns*sizeof(cplx)); for (n = 0 ; n < ns ; n++){ Hnkrtab[n].r = jn(n,kr); Hnkrtab[n].i = yn(n,kr); } for (n = 0 ; n < ns ; n++){ HnkR.r = jn(n,kR); HnkR.i = yn(n,kR); tmp = Cdiv( Cprod( Cpow(I,n) , Cprodr( HnkR.r, DHn(Hnkrtab, n, kr) ) ) , HnkR ); cost = cos(n*theta); V->Val[0] += cost * tmp.r * (!n ? 0.5 : 1.); V->Val[MAX_DIM] += cost * tmp.i * (!n ? 0.5 : 1.); } Free(Hnkrtab); V->Val[0] *= -2 * k; V->Val[MAX_DIM] *= -2 * k; V->Type = SCALAR ; GetDP_End;} /* Scattering by acoustically hard circular cylinder of radius R, under plane wave incidence e^{ikx}. Returns solution outside */void F_AcousticFieldHardCylinder(F_ARG){ cplx I = {0.,1.}, Hnkr, dHnkR, tmp, *HnkRtab; double k, R, r, kr, kR, theta, cost ; int n, ns ; GetDP_Begin("F_AcousticFieldHardCylinder") ; theta = atan2(A->Val[1], A->Val[0]) ; r = sqrt(A->Val[0]*A->Val[0] + A->Val[1]*A->Val[1]) ; k = Fct->Para[0] ; R = Fct->Para[1] ; kr = k*r; kR = k*R; V->Val[0] = 0.; V->Val[MAX_DIM] = 0. ; ns = (int)k + 10; HnkRtab = (cplx*)Malloc(ns*sizeof(cplx)); for (n = 0 ; n < ns ; n++){ HnkRtab[n].r = jn(n,kR); HnkRtab[n].i = yn(n,kR); } for (n = 0 ; n < ns ; n++){ Hnkr.r = jn(n,kr); Hnkr.i = yn(n,kr); dHnkR = DHn(HnkRtab, n, kR); tmp = Cdiv( Cprod( Cpow(I,n) , Cprodr( dHnkR.r, Hnkr) ) , dHnkR ); cost = cos(n*theta); V->Val[0] += cost * tmp.r * (!n ? 0.5 : 1.); V->Val[MAX_DIM] += cost * tmp.i * (!n ? 0.5 : 1.); } Free(HnkRtab); V->Val[0] *= -2; V->Val[MAX_DIM] *= -2; V->Type = SCALAR ; GetDP_End;} /* ------------------------------------------------------------------------ *//* On Surface Radiation Conditions (OSRC) *//* ------------------------------------------------------------------------ *//* Coefficients C0, Aj and Bj: see papers 1) Kechroud, Antoine & Soulaimani, Nuemrical accuracy of a Pade-type non-reflecting..., IJNME 2005 2) Antoine, Darbas & Lu, An improved surface radiation condition... CMAME, 2006(?) */static double aj(int j, int N){ return 2./(2.*N + 1.) * SQU(sin((double)j * M_PI/(2.*N + 1.))) ;}static double bj(int j, int N){ return SQU(cos((double)j * M_PI/(2.*N + 1.))) ;}void F_OSRC_C0(F_ARG){ int j, N; double theta; cplx sum = {1., 0.}, z, un = {1., 0.}; GetDP_Begin("F_OSRC_C0") ; N = (int)Fct->Para[0] ; theta = Fct->Para[1] ; z.r = cos(-theta) - 1. ; z.i = sin(-theta) ; for(j = 1; j <= N; j++){ sum = Csum( sum, Cdiv( Cprodr(aj(j,N), z) , Csum(un, Cprodr(bj(j,N), z)))) ; } z.r = cos(theta/2.) ; z.i = sin(theta/2.) ; sum = Cprod(sum, z); V->Val[0] = sum.r; V->Val[MAX_DIM] = sum.i; V->Type = SCALAR ; GetDP_End;}void F_OSRC_Aj(F_ARG){ int j, N; double theta; cplx z, res, un = {1., 0.}; GetDP_Begin("F_OSRC_Aj") ; j = (int)Fct->Para[0] ; N = (int)Fct->Para[1] ; theta = Fct->Para[2] ; z.r = cos(-theta/2.) ; z.i = sin(-theta/2.) ; res = Cprodr(aj(j,N), z); z.r = cos(-theta) - 1. ; z.i = sin(-theta) ; res = Cdiv(res, Cpow( Csum(un, Cprodr(bj(j,N), z)), 2.)); V->Val[0] = res.r; V->Val[MAX_DIM] = res.i; V->Type = SCALAR ; GetDP_End;}void F_OSRC_Bj(F_ARG){ int j, N; double theta; cplx z, res, un = {1., 0.}; GetDP_Begin("F_OSRC_Bj") ; j = (int)Fct->Para[0] ; N = (int)Fct->Para[1] ; theta = Fct->Para[2] ; z.r = cos(-theta) ; z.i = sin(-theta) ; res = Cprodr(bj(j,N), z); z.r = cos(-theta) - 1. ; z.i = sin(-theta) ; res = Cdiv(res, Csum(un, Cprodr(bj(j,N), z))); V->Val[0] = res.r; V->Val[MAX_DIM] = res.i; V->Type = SCALAR ; GetDP_End;}#undef F_ARG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -