#include #include "pdp1.h" // Function void load(int initnp[][2]) {{{ void load(int initnp[][2]) { // extern double fdist(); extern double fdist(double, int, int); double vv; int i, ix, k, isp, ksign, ii; float ddx, vmag, theta, v1, v2, ddv, sf, ddf, sumf, ss, ds, ff, vel[1024]; /* Load one species and one direction at a time */ for (isp=0; isp maxnp[isp]) { puts("LOAD: too many particles, species "); exit(1); } if (vt[isp][k]==0. ) { /* Loader for a COLD beam */ for (i=0; i 0.) ddv = ksign*min(fabs(ddv), .45*ds/ff); do { ddf = fdist(vv, k, isp) + 4.*fdist(vv + ddv, k, isp) + fdist(vv+ddv+ddv, k, isp); ddf *= fabs(ddv)/3.; if (ddf >= ds) ddv *= 0.5; } while (ddf >= ds); vv += ddv+ddv; sumf += ddf; if (sumf < ss) goto L12; /* When a desired velocity has been passed, interpolate to find it, and start looking for the next velocity */ vel[ii] = vv - (sumf - ss)*ddv/ddf; ii++; ss += ds; if (ii < 1024) goto L12; /* Compute the number of particles to be loaded, and load the 1024 velocities uniformly in space, in bit-rev order */ for (i=0; i0.." */ np[isp] += initnp[isp][k]; } /* end "for ( k=0,1...)" loop */ } /* end for (isp=0 thru nsp-1..)" loop */ } // }}} // Modeline for ViM {{{1 // vim:set ts=4: // vim600:fdm=marker fdl=0 fdc=3: // 1}}}