#include #include #include "pdp1.h" #include "xgrafix.h" #define NEMAX 500 #define NIMAX 500 float asigma1(float), asigma2(float), asigma3(float), asigma4(float), asigma5(float); float gden, vgth, extengy0, ionengy0; void anewvel(float, float, float *, float *, float *, float, int); extern void maxwellv(float *, float *, float *, float); int ecolsp, icolsp, ionsp; // Monte Carlo Collisions for electron- and ion-neutrals // Function void argonmcc(int isp); {{{ void argonmcc(int isp) { static int init_flag=1; static float ecol_extra, icol_extra; static float max_sigmav_e, max_sigmav_i; static float col_prob_e, col_prob_i; register int j, k, index; int N, nnp, s; float random, dum, vel, sigma_total; float engy, rengy, del, phi1; float cosphi, sinphi, coschi, sinchi; float sum_sigma, temp, vneutx, vneuty, vneutz; if (init_flag) { gden = NperTORR*pressure/(gtemp+DBL_MIN); // Calculating the gas density ecolsp= ecollisional-1; icolsp= icollisional-1; ionsp = ionspecies-1; // Fixing the indices into the array of species // Calculating the null collision prob. {{{ if (ecollisional) { if (ionsp>0) vgth= sqrt(gtemp/Escale[ionsp]); extengy0 = 11.55; ionengy0 = 15.76; max_sigmav_e = 0.0; for (engy=0; engy= extengy0 && random <= (sum_sigma +=asigma2(engy))/sigma_total) { // first normalize vel vx[ecolsp][j] /= vel; vy[ecolsp][j] /= vel; vz[ecolsp][j] /= vel; engy -= extengy0; vel = sqrt(fabs(engy)/Escale[ecolsp]); // scatter the electron anewvel(engy, vel, &vx[ecolsp][j], &vy[ecolsp][j], &vz[ecolsp][j], x[ecolsp][j], 0); // collect diagnostics if (theRunWithXFlag) { s= x[ecolsp][j]; del= x[ecolsp][j] - s; mccrate[1][s] += (!s) ? 2*(1-del) : 1-del; mccrate[1][s+1]+= (s== nc-1) ? 2*del : del; } } // }}} // if the collision is ionization, add the released {{{ // * electron and ion first else if (engy >= ionengy0 && random <= (sum_sigma +=asigma3(engy))/sigma_total) { // first normalize vel vx[ecolsp][j] /= vel; vy[ecolsp][j] /= vel; vz[ecolsp][j] /= vel; //****************************** // subtract the ion. energy and // partition the remaining energy engy -= ionengy0; rengy = 10.0*tan(frand()*atan(engy/20.0)); engy -= rengy; //****************************** // scatter the created electron vel = sqrt(fabs(rengy)/Escale[ecolsp]); k = np[ecolsp]; vx[ecolsp][k] = vx[ecolsp][j]; vy[ecolsp][k] = vy[ecolsp][j]; vz[ecolsp][k] = vz[ecolsp][j]; anewvel(rengy, vel, &vx[ecolsp][k], &vy[ecolsp][k], &vz[ecolsp][k], x[ecolsp][j], 0); x[ecolsp][k] = x[ecolsp][j]; //************************************** // assign velocities to the created ion k = np[ionsp]; maxwellv( &vx[ionsp][k], &vy[ionsp][k], &vz[ionsp][k], vgth); x[ionsp][k] = x[ecolsp][j]; s = x[ionsp][k]; del = x[ionsp][k] - s; sp_n_mcc[ionsp][s] += 1. - del; sp_n_mcc[ionsp][s+1]+= del; //*************************************** // finally scatter the incident electron vel = sqrt(fabs(engy)/Escale[ecolsp]); anewvel(engy, vel, &vx[ecolsp][j], &vy[ecolsp][j], &vz[ecolsp][j], x[ecolsp][j], 0); if (++np[ionsp] >maxnp[ionsp] || ++np[ecolsp] >maxnp[ecolsp]) { puts("ADJUST(Ionization): too many particles. MUST EXIT!"); exit(-1); } // collect diagnostics if (theRunWithXFlag) { mccrate[2][s] += (!s) ? 2*(1-del) : 1-del; mccrate[2][s+1]+= (s== nc-1) ? 2*del : del; } } // }}} } } // }}} // Ar+ + Ar -> ..... {{{ if (icollisional && isp==icolsp) { //*** First Clear the diagnostics ***** if (theRunWithXFlag) { for (j=0; j e + Ar Elastic // Function float asigma1(float energy) {{{ float asigma1(float energy) { int i; float els_sigma, alpha; static int init_flag=1; static float *elastic1, *elastic2; // Initialization {{{ if (init_flag) { float engy; elastic1 = (float *) malloc(101*sizeof(float)); elastic2 = (float *) malloc(NEMAX*sizeof(float)); // With no Ramseur min. {{{ // for (i=0; i<100; i++) elastic1[i]= 1.4e-19; for (i=0; i e + Ar Excitation // Function float asigma2(float energy) {{{ float asigma2(float energy) { int i; float exc_sigma, alpha; static int init_flag=1; static float *excit; // Initialization {{{ if (init_flag) { float engy; excit = (float *) malloc(NEMAX*sizeof(float)); for (i=0; i e + e + Ar+ Ion. // Function float asigma3(float energy) {{{ float asigma3(float energy) { int i; float ion_sigma, alpha; static int init_flag=1; static float *ioniz; // Initialization {{{ if (init_flag) { float engy; ioniz = (float *) malloc(NEMAX*sizeof(float)); for (i=0; i Ar+ + Ar Charge X // Function float asigma4(float energy) {{{ float asigma4(float energy) { if (energy > 4.0) return(2.0e-19 +5.5e-19/sqrt(energy)); else return(-2.95e-19*sqrt(energy) +10.65e-19); } // }}} // Ar + Ar+ -> Ar + Ar+ Scat. // Function float asigma5(float energy) {{{ float asigma5(float energy) { if (energy > 4.0) return(1.8e-19 +4.0e-19/sqrt(energy)); else return(-2.0e-19*sqrt(energy) +7.8e-19); } // }}} // Function void makethefile(void) {{{ void makethefile(void) { float e; FILE *DMPFile; DMPFile = fopen("arxsects.dat", "w"); for (e=0; e<10; e+=0.01) fprintf(DMPFile, "%e %e %e %e %e %e\n", e+1e-30, asigma1(e)+1e-30, asigma2(e)+1e-30, asigma3(e)+1e-30, asigma4(e)+1e-30, asigma5(e)+1e-30); for (e=10; e<100; e+=0.1) fprintf(DMPFile, "%e %e %e %e %e %e\n", e+1e-30, asigma1(e)+1e-30, asigma2(e)+1e-30, asigma3(e)+1e-30, asigma4(e)+1e-30, asigma5(e)+1e-30); fclose(DMPFile); } // }}} // Modeline for ViM {{{1 // vim:set ts=4: // vim600:fdm=marker fdl=0 fdc=3: // 1}}}