#include #include #include #include #include #include #include "complex.h" #define NFREQ 512 #define LNES 12 #define LTES 16 #define NANG 19 #define MAX(x,y) ((x)>(y) ? (x) : (y)) #define MIN(x,y) ((x)<(y) ? (x) : (y)) fcomplex ****exlib; int first=1; void swab_test(void); //float swab(signed char *a); void read_exlib(char *s,int nfreq, int lnes, int lTes, int nang, fcomplex ****exlib); void initialize(void); //void collision_(float *np, float *tp, float *fp, float *ap, float *yr, float *yi)// step 1 void collision_(float *n, float *t, float *f, float *a, fcomplex *y); /* void main(void){ float n=4.9e11,t=1100.0,f=300.0,a=1.0; int i; fcomplex j; for(i=0;i<10;i++){ a+=0.05; collision_(&n,&t,&f,&a,&j); printf("%f %f %f \n",a,j.r,j.i); } } */ //void collision_(float *np, float *tp, float *fp, float *ap, float *yr, float *yi){ // step 2 void collision_(float *np, float *tp, float *fp, float *ap, fcomplex *y){ float ne[]={5.0e10, 1.0e11, 2.0e11, 3.5e11, 5.0e11, 7.5e11, 1.0e12, 1.5e12, 2.0e12, 2.5e12, 3.0e12, 3.5e12}; float te[]={600.0, 700.0, 800.0, 900.0, 1000.0, 1150.0, 1300.0, 1500.0, 1750.0, 2000.0, 2250.0, 2500.0, 2750.0, 3000.0, 3500.0, 4000.0}; float alpha[]={.125, .1875, .25, .3125, .375, .5, .625, .75, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0}; float freq[2],fmax=6237.79; float n,t,f,a; float v,w1,w2,w3,w4,weight; fcomplex g; int i,j,k,l,m,i1,j1,k1,l1; if(first==1){ //printf("initi"); initialize(); first=0; } //printf(" inputs in collision_ \n y.r %f y.i %f \n *************\n",(*y).r,(*y).i); //printf("After:print\n"); a=*ap; t=*tp; f=*fp; n=*np; a=MAX(MIN(a,6.0),0.125); t=MAX(MIN(t,4000.0),600.0); f=MIN(f,fmax-1.0); n=MAX(MIN(n,3.5e12),5.0e10); i1=((float)(NFREQ-1))*f/fmax; i1=MIN(i1,NFREQ-1); freq[0]=i1*fmax/(float)(NFREQ-1); freq[1]=(i1+1)*fmax/(float)(NFREQ-1); j1=0; while(n>ne[j1+1]) j1++; j1=MIN(j1,LNES-1); k1=0; while(t>te[k1+1]) k1++; k1=MIN(k1,LTES); l1=0; while(a>alpha[l1+1]) l1++; l1=MIN(l1,NANG); // printf("i,j,k,l: %i %i %i %i \n",i1,j1,k1,l1); v=(fmax/(float)(NFREQ-1))* (ne[j1+1]-ne[j1])*(te[k1+1]-te[k1])*(alpha[l1+1]-alpha[l1]); g=Complex(0.0,0.0); for(i=0;i<2;i++){ if(i==0) w1=freq[1]-f; else w1=f-freq[0]; for(j=0;j<2;j++){ if(j==0) w2=ne[j1+1]-n; else w2=n-ne[j1]; for(k=0;k<2;k++){ if(k==0) w3=te[k1+1]-t; else w3=t-te[k1]; for(l=0;l<2;l++){ if(l==0) w4=alpha[l1+1]-a; else w4=a-alpha[l1]; weight=w1*w2*w3*w4; g.r+=exlib[i1+i][j1+j][k1+k][l1+l].r*weight; g.i+=exlib[i1+i][j1+j][k1+k][l1+l].i*weight; // printf(" in collision i1+i %d j1+j %d k1+k %d l1+l %d exlib.r %f exlib.i %f \n",i1+i,j1+j,k1+k,l1+l,exlib[i1+i][j1+j][k1+k][l1+l].r,exlib[i1+i][j1+j][k1+k][l1+l].i); // printf(" in collision g.r %f g.i %f \n",g.r,g.i); } } } } g.r/=v; g.i/=v; *y=g; //*yr=g.r //*yi=g.i //printf(" outputs in collision_ \n g.r %f g.i %f \n *************\n",g.r,g.i); //exit(-2); //getchar(); return; } void initialize(void){ // char s[]="/usr/local/lib/faraday/jlib26feb2002"; // char s[]="/usr/local/lib/faraday/jlib26feb2002"; // FILE *s=fopen("/usr/local/lib/faraday/jlib26feb2002","r"); int nfreq=NFREQ, lnes=LNES, lTes=LTES, nang=NANG; int i,j,k; int crr,crr2; int the_number=1025; char the_path[1025]; get_path_reader_(the_path,&the_number); //printf("C the_number: %i",the_number); //printf("After\n"); //printf("The Path: %s", the_path); //printf("END\n"); //printf("%s%n",the_path,&crr); //printf("=%d",crr); //printf("END2\n"); char the_path_true[the_number]; memcpy(the_path_true,the_path,the_number); the_path_true[the_number] = '\0'; //printf("%s%n",the_path_true,&crr2); //printf("=%d",crr2); //printf("END3\n"); //printf("PATH: %s",s); //fprintf(s); exlib=malloc(nfreq*8); for(i=0;i