у коефіцієнтів деполяризації
Файл main.cpp
/* depolarization coefficients */
# include lt; stdio.h gt;
# include lt; math.h gt;
# include lt; malloc.h gt;
# define mytype float
# define ASIZE 32
# define a 1.0
# define nn 33000
# define step 5
# define e 0.00000000001
* E0, * E1, * E2, * Ev; * x, * y, * z; r2 (int i2, int j2, int k)
{int i3, j3 ;;=(int) i2;=(int) j2; (k == 3) zq=sqrt ((x [i3] -x [j3]) * ( x [i3] -x [j3]) + (y [i3] -y [j3]) * (y [i3] -
y [j3]) + (z [i3] -z [j3]) * (z [i3] -z [j3])); if (k == 0) zq=sqrt ( (x [i3] -x [j3]) * (x [i3] -x [j3])); if (k == 1) zq=sqrt ((y [i3] -y [j3]) * (y [i3] -y [j3])); if (k == 2) zq=sqrt ((z [i3] -z [j3]) * (z [i3] -z [j3]));
;
}
main (intargc, char * argv [])
{* fp; i, j, x1, y1, z1, i2; N;, n; phi2, r, S, Sv, ee1, ee2, ee3, nx, ny, nz, r0 ; s [11];=nn; (" nCalculation of depolarization coefficients of arbitrary shape
body n ); ( Version 3.0, Copyright (C) 2003-2004 O.Gorobchenko n ); ( nmemory requesting ... n );= sizeof (mytype) * (N);=malloc (k);=malloc (k);=malloc (k);=malloc (k);=malloc (k);=malloc (k);=malloc (k) ; ( request completed, OK n ); ( file opening ... n" );
/* Open file */(argc gt; 1)
{printf (% s n , argv [1]); ((fp=fopen (argv [1], r )) == NULL)
{printf ( ERROR n ); exit (100);} printf ( OPENED! n );
} {(% s , s); ((fp=fopen (s, r )) == NULL)
{printf ( ERROR n ); exit (100);} ( OPENED! n );
}
/* reading */(i=0; i lt; nn; i ++)
{(fp, % d , amp; x1); (fp, % d , amp; y1); (fp, % d , amp ; z1); [i]=x1; [i]=y1; [i]=z1; (feof (fp));
} (fp);=i; ( Your object contains% d elements n , n); ( calculation of nx ... n );
/******************** nx ******************/( i=0; i lt; n; i ++)
{[i]=1.0; E1 [i]=0.0; E2 [i]=0.0;
}
(j=0; j lt; step; j ++)
{printf ( step% d n , j); (i=0; i lt; n; i ++)
{ee1=e; ee2=e; ee3=e; ( i =% d b b b b b b b , i); (i2= 0; i2 lt; n; i2 ++)
(r2 (i, i2,3)!=0)
{= (E0 [i] * r2 (i, i2,0) + E1 [i] * r2 (i, i2,1) + E2 [i] * r2 (i, i2, 2)) * a * a * a/(r2 (i, i2,3) * r2 (i, i
2,3) * r2 (i, i2,3) * r2 (i, i2,3)); +=S * r2 (i, i2,0);
+=S * r2 (i, i2,1);
+=S * r2 (i, i2,2);
} [i]=ee1/n; [i]=ee2/n; [i]=ee3/n; (j == 0) Ev [i]=E0 [i];
}
}=2.0 * ASIZE;=0.0;=0.0; (i=0; i lt; n; i ++)
{= sqrt ((x [i] -r0) * (x [i] -r0) + (y [i] -ASIZE/2.0) * (y [i] -ASIZE/2.0 ) + (z [i] -
ASIZE/2.0) * (z [i] -ASIZE/2.0)); (r!=0) +=(E0 [i]) * a * a * a/r0/r0/ r0;
}=(S);
=1.0/phi2;
( calculation of ny ... n );
/******************** ny ******************/( i=0; i lt; n; i ++)
{[i]=0.0; E1 [i]=1.0; E2 [i]=0.0;
} (j=0; j lt; step; j ++)
{printf ( step% d n , j); (i=0; i lt; n; i ++)
{ee1=e; ee2=e; ee3=e; ( i =% d b b b b b b b , i); (i2= 0; i2 lt; n; i2 ++)
(r2 (i, i2,3)!=0)
{= (E0 [i] * r2 (i, i2,0) + E1 [i] * r2 (i, i2,1) + E2 [i] * r2 (i, i2, 2)) * a * a * a/(r2 (i, i2,3) * r2 (i, i
2,3) * r2 (i, i2,3) * r2 (i, i2,3)); +=S * r2 (i, i2,0); +=S * r2 (i, i2,1);
+=S * r2 (i, i2,2);
}
[i]=ee1/n; [i]=ee2/n; [i]=ee3/n; (j == 0) Ev [i]=E1 [i];
}
}
=2.0 * ASIZE;=0.0;=0.0; (i=0; i lt; n; i ++)
{= sqrt ((y [i] -r0) * (y [i] -r0) + (x [i] -ASIZE/2.0) * (x [i] -ASIZE/2.0 ) + (z [i] -
ASIZE/2.0) * (z [i] -ASIZE/2.0)); (r!=0) +=(E1 [i]) * a * a * a/r0/r0/ r0; +=(1) * a * a * a/r/r/r;
}=(S);