#include #include "pdp1.h" #include "xgrafix.h" #define NEMAX 500 #define NIMAX 500 float hsigma1(float), hsigma2(float), hsigma3(float), hsigma4(float); void hmakethefile(void); void hnewvel(float, float, float *, float *, float *, int); extern void maxwellv(float *, float *, float *, float); float gden, vgth, extengy0, ionengy0; int ecolsp, icolsp, ionsp; // Monte Carlo Collisions for electron- and ion-neutrals // Function void heliummcc(int isp) {{{ void heliummcc(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; 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 = 19.8; ionengy0 = 24.5; max_sigmav_e = 0.0; for (engy=0; engy= extengy0 && random <= (sum_sigma +=hsigma2(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 hnewvel(engy, vel, &vx[ecolsp][j], &vy[ecolsp][j], &vz[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 + hsigma3(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]; hnewvel(rengy, vel, &vx[ecolsp][k], &vy[ecolsp][k], &vz[ecolsp][k], 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]); hnewvel(engy, vel, &vx[ecolsp][j], &vy[ecolsp][j], &vz[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; } } // }}} } } // }}} // He+ + He -> ..... {{{ if (icollisional && isp==icolsp) { //*** First Clear the diagnostics ***** if (theRunWithXFlag) { for (j=0; j e + He Elastic // Function float hsigma1(float energy) {{{ float hsigma1(float energy) { return (8.5e-19/(pow(energy+10.0, 1.1))); } // }}} // e + He -> e + He Excitation // Function float hsigma2(float energy) {{{ float hsigma2(float energy) { if (energy < extengy0) return (0.0); else if (extengy0 <= energy && energy <27.0) return (2.08e-22*(energy -extengy0)); else return (3.4e-19/(energy +200)); } // }}} // e + He -> e + e + He+ Ion. // Function float hsigma3(float energy) {{{ float hsigma3(float energy) { if (energy < ionengy0) return (0.0); else return(1e-17*(energy -ionengy0)/((energy +50)*pow(energy+300.0, 1.2))); } // }}} // He + He+ -> He+ + He Charge X // Function float hsigma4(float energy) {{{ float hsigma4(float energy) { return(3e-19); } // }}} // Function void hmakethefile(void) {{{ void hmakethefile(void) { float e; FILE *DMPFile; DMPFile = fopen("xsections", "w"); for (e=0; e<300; e+=.1) fprintf(DMPFile, "%g %g %g %g %g\n", e+1e-30, hsigma1(e)+1e-30, hsigma2(e)+1e-30, hsigma3(e)+1e-30, hsigma4(e)+1e-30); fclose(DMPFile); } // }}} // Modeline for ViM {{{1 // vim:set ts=4: // vim600:fdm=marker fdl=0 fdc=3: // 1}}}