#include #include "pdp1.h" #include "xgrafix.h" void species(int initnp[][], float jj0[][], int isp); extern void Restore(char *filename); extern void svel(void); extern void load(int initnp[][]); FILE *InputDeck; // Function void start(void) {{{ void start(void) { float t, s, psi=0.0, jj0[NSMAX][2]; char aachar[80]; int i, j, isp, imp_flag, initnp[NSMAX][2]; extern double revers(); // Open files and read in "general" parameters {{{ if (!WasInputFileGiven) { puts("Syntax:"); puts("\tPDP1 [dumpfile]"); exit(1); } InputDeck = fopen(theInputFile, "r"); // }}} // Read lines until we get to numbers {{{ while (fscanf(InputDeck,"%d %d %g %g %g %g %g %g %g", &nsp, &nc, &nc2p, &dt, &length, &area, &epsilon, &b, &psi) <9) fscanf(InputDeck, "%s", aachar); while (fscanf(InputDeck, "%g %g %g %g %g %g %g", &rhoback, &backj, &dde, &extr, &extl, &extc, &extq) <7) fscanf(InputDeck, "%s", aachar); while (fscanf(InputDeck, "%d %c %g %g %g %g %g", &dcramped, &src, &dcbias, &ramp, &acbias, &w0, &theta0) <7) fscanf(InputDeck, "%s", aachar); while (fscanf(InputDeck, "%d %d %d %d %d %d %d", &secondary, &ecollisional, &icollisional, &reflux, &nfft, &nsmoothing, &ntimestep) <7) fscanf(InputDeck, "%s", aachar); while (fscanf(InputDeck, "%g %g %d %g %g %d", &seec[0], &seec[1], &ionspecies, &pressure, >emp, &imp_flag) <6) fscanf(InputDeck, "%s", aachar); while (fscanf(InputDeck, "%d %d %d", &gas, &psource, &nstrt) <3) fscanf(InputDeck, "%s", aachar); // }}} // Check for errors in the "general" input parameters {{{ if (extl < 0. || extr < 0. || extc < 0.) { puts("START: dont be cute with R,L,C < 0\n"); exit(1); } if (dt<= 0.0) { puts("START: dt <= 0!!\n"); exit(1); } if (nsp > NSMAX) { puts("START: nsp > NSMAX.\n"); exit(1); } // }}} // make sure that oxygen has 3 species if ( (gas == OXYGEN) && (nsp != 3) ){ puts("START: OXYGEN, nsp must be 3\n"); exit(1); } // by default the gas is argon argonmcc returns without any action if // collisions are off mccptr =argonmcc; if (ecollisional || icollisional){ if ( (gas != OXYGEN) && (nsp == 3) ){ puts("START: if you want nsp = 3 AND collisions on, " "gas must be OXYGEN\n"); exit(1); } switch (gas){ case HELIUM: mccptr =heliummcc; break; case ARGON: mccptr =argonmcc; break; case NEON: mccptr =neonmcc; break; case OXYGEN: mccptr =oxygenmcc; break; } } // Check to see if nfft is an integer power of 2 if (nfft) { for (i=0; i<= 15; i++) { if (nfft == (1<0.0) { puts("SORRY: The implicit version of PDP1 does not have a B field!"); exit(1); } else moveptr = imp_move; } else moveptr = exp_move; xnc= nc; ng = nc+1; dx = length/xnc; // Allocate space for field parameters {{{ x_grid= (float *)malloc(ng*sizeof(float)); for (j=0; j0.0 || imp_flag) a_scale[isp] *= 0.5; if (imp_flag) sp_chi_scale[isp] = 0.25*q[isp]*a_scale[isp]*sp_k[isp]/epsilon; else { sp_chi_scale[isp] = 0.0; jdote_scale[isp] *= 0.5; j_scale[isp] *= 0.5; u_scale[isp] *= 0.5; } // Normalize velocities and energies v0[isp][0] /= vscale; v0[isp][1] /= vscale; vc[isp][0] /= vscale; vc[isp][1] /= vscale; vt[isp][0] /= vscale; vt[isp][1] /= vscale; vperpt[isp] /= vscale; vperp0[isp] /= vscale; emin[isp] /= Escale[isp]; de[isp] /= Escale[isp]; xs_mid[isp] /= dx; xf_mid[isp] /= dx; emin_mid[isp] /= Escale[isp]; de_mid[isp] /= Escale[isp]; // Normalize "enter" to = no. of particles injected PER dt enter[isp][0] = jj0[isp][0]*dt*sp_k[isp]/(fabs(q[isp])+DBL_MIN); enter[isp][1] = jj0[isp][1]*dt*sp_k[isp]/(fabs(q[isp])+DBL_MIN); if (enter[isp][0]> 0.0 || enter[isp][1]> 0.0) inject[isp] = 1; } // }}} fclose(InputDeck); if (!vxscale) vxscale = 1e4; vxscale *= 5; // psource =1, starts a uniform ionization source which compensates every // ion leaving with an ion-electron pair // have to call here since at this point, svel has all it needs if (psource) { svel(); tstrt = 10*dt; // default, start source after 10 dT if (nstrt) tstrt = nstrt*dt; } //* Allocate particle arrays * {{{ x = (float **)malloc(nsp*sizeof(float *)); vx = (float **)malloc(nsp*sizeof(float *)); vy = (float **)malloc(nsp*sizeof(float *)); vz = (float **)malloc(nsp*sizeof(float *)); for (isp=0; isp