#include "peg_pic.h"


/** Calculation of parameters for Coulomb collisions for species "isp" **/

void ccpar(isp) {

	if ((!isp) && (!(vspart[0]*vscale))) {
		/* vspart[0] is used for Landau log. */
		puts("v_thermal_electron=0\n");
		exit(1);
	}

	pp[isp] = qm[isp]*qm[isp]*q[isp]*q[isp]*area*dt*cc_step/(dx*vscale*vscale*
			vscale*PI*epsilon*epsilon*nc2p/wt[isp]);

	if (cc_coef) {
		pp[isp] *= cc_coef;
	}
	
	if (dshort>0.) {
		pp[isp] *=dshort;
	}
	
	Z[isp] = fabs(q[isp])*area*1.e19/(nc2p/wt[isp]*1.6022);
	miu[isp] = m[isp]*1.e31/9.1094;

	if (vspart[isp]*vscale<Z[isp]*Z[isp]*1.3e6) {
		/* calculation of  Landau log. */
		if (vspart[isp]) {
			LL[isp] = -9.2- 2.*log(Z[isp]/vspart[isp])- log(Z[0]/(vspart[0]*miu[isp])) +
			0.5*log(miu[0]) +3.*log(vscale) - lsq_n;
		} else {
			LL[isp] = 0.;
		}
	} else {
		LL[isp] =4.8 - log(Z[0]/(vspart[0]*vspart[isp]*miu[isp]))+ 0.5*log(miu[0]) +
		2.*log(vscale) - lsq_n;
	}

	if (LL[isp] < 5) {
		printf("Landau log. < 5 for speciec %d\n", isp);
		exit(1);
	}

	pp[isp] *=LL[isp];

	if ((ccc > 1) && (isp == 1)) {
		/* collisions between different species */
		if (sqrt(vspart[0]*vspart[0]+vspart[1]*vspart[1])*vscale < Z[1]*Z[0]*1.3e6) {
			LL_01 = LL[0] - log(0.5*Z[1]/Z[0]);
		} else  {
			LL_01 = LL[0];
		}

		if (LL_01 < 5) {
			puts("Landau log. < 5 for speciec 1-2\n");
			exit(1);
		}

		m_0 = m[0]/(m[0]+m[1]);
		m_1 = m[1]/(m[0]+m[1]);
		pp_01 = 0.25*LL_01*qm[0]*qm[1]*q[0]*q[1]*area*dt*cc_step/(dx*vscale*vscale*             
				vscale*PI*epsilon*epsilon*nc2p*m_0*m_1/wt[0]);

		if (wt[0] != wt[1]) {  
			puts("For Coulomb collisions same particle weight is reqired!\n");
			exit(1);
		}

		if (cc_coef) {
			pp_01 *= cc_coef;
		}
		
		if (dshort>0.) {
			pp_01 *= dshort;
		}
	}
}   /* End of ccpar()  */

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