#include "peg_pic.h"


/***** Initial loading of particles. "initnp[k]" is *****/
/***** the number of loaded particles of species k  *****/

void load(int initnp[]) {
	int i, isp;
	float ddx;

	for (isp=0; isp<nsp; isp++) {
		np[isp] = initnp[isp];

		if (!np[isp]) {
			continue;
		}

		ddx= xnc/np[isp];

		for(i=0; i<np[isp]; i++) {
			x[isp][i] = (i +0.5)*ddx;
			maxwelli(&vx[isp][i], &vy[isp][i], &vz[isp][i], vpart[isp],
					vperpt[isp], vpar0[isp], vperp0[isp], Index[(i+1)%VVMAX], cs, sn);

			if (dde) {
				x[isp][i] += dde*sin(TWOPI*x[isp][i]/xnc);
			}
		}
	}  /* end for(isp=0 thru nsp-1..)" loop */
}  /* End of LOAD  */

/*********************************************************************/
