Esempio n. 1
0
def zp(x):
    """
    plasma dispersion function                                
    using complementary error function in mpmath library.                       
                                                                                
    """
    return -mp.sqrt(mp.pi) * mp.exp(-x**2) * mp.erfi(x) + mpc(0, 1) * mp.sqrt(mp.pi) * mp.exp(-x**2)
Esempio n. 2
0
def zp_mp(z):
    """
    Plasma dispersion function to user-defined precison.                              
    Utilize the complementary error function in mpmath library.                       

    Keyword arguments:
    z: dimensionless argument of the plasma dispersion function.
    
    Return the value of Zp(z) to arbitrary precision.
    'import mpmath' and 'mpmath.mp.dps=n' set the precison to n digit.
    """
    return -mp.sqrt(mp.pi) * mp.exp(-z**2) * mp.erfi(z) + mp.mpc(0, 1) * mp.sqrt(mp.pi) * mp.exp(-z**2)
Esempio n. 3
0
def HDiffCoeff(dPar, dPerp, kappa):
	
	dw = np.zeros((2,1))
	dParMdPerp = dPar - dPerp

	if (kappa < 1e-5):
		dParP2dPerp = dPar + 2*dPerp
		k2 = kappa*kappa
		dw[0] = dParP2dPerp/3 + 4*dParMdPerp*kappa/45 + 8*dParMdPerp*k2/945
		dw[1] = dParP2dPerp/3 - 2*dParMdPerp*kappa/45 - 4*dParMdPerp*k2/945

	else:
		sk = np.sqrt(kappa)
		dawsonf = 0.5*np.exp(-kappa)*np.sqrt(np.pi)*mp.erfi(sk)
		factor = sk/dawsonf
		dw[0] = (-dParMdPerp+2*dPerp*kappa+dParMdPerp*factor)/(2*kappa)
		dw[1] = (dParMdPerp+2*(dPar+dPerp)*kappa-dParMdPerp*factor)/(4*kappa)

	return dw

	
Esempio n. 4
0
def WatsonSHCoefficients(k):


    # Maximum order of SH coefficients
    n=6

    # Computing the SH coefficients
    C = np.zeros(n+1);

    # 0th order is a constant
    C[0] = 2*np.sqrt(np.pi);

    # Precompute some values
    sk = np.sqrt(k)
    sk2 = sk*k
    sk3 = sk2*k
    sk4 = sk3*k
    sk5 = sk4*k
    sk6 = sk5*k
    sk7 = sk6*k
    
    k2 = k*k
    k3 = k2*k
    k4 = k3*k
    k5 = k4*k
    k6 = k5*k
    k7 = k6*k

    
    erfik = mp.erfi(sk)
    ierfik = 1./erfik
    ek=np.exp(k)

    # dawson integral 
    dawsonk=0.5*np.sqrt(np.pi)*erfik/ek

    #Compute coefficients by hand
    C[1] = 3*sk - (3 + 2*k)*dawsonk
    C[1] = np.sqrt(5)*C[1]*ek
    C[1] = C[1]*ierfik/k

    C[2] = (105 + 60*k + 12*k2)*dawsonk
    C[2] = C[2] -105*sk + 10*sk2
    C[2] = .375*C[2]*ek/k2
    C[2] = C[2]*ierfik

    C[3] = -3465 - 1890*k - 420*k2 - 40*k3
    C[3] = C[3]*dawsonk
    C[3] = C[3] + 3465*sk - 420*sk2 + 84*sk3
    C[3] = C[3]*np.sqrt(13*np.pi)/64./k3
    C[3] = C[3]/dawsonk

    C[4] = 675675 + 360360*k + 83160*k2 + 10080*k3 + 560*k4
    C[4] = C[4]*dawsonk
    C[4] = C[4] - 675675*sk + 90090*sk2 - 23100*sk3 + 744*sk4
    C[4] = np.sqrt(17)*C[4]*ek
    C[4] = C[4]/512./k4
    C[4] = C[4]*ierfik

    C[5] = -43648605 - 22972950*k - 5405400*k2 - 720720*k3 - 55440*k4 - 2016*k5
    C[5] = C[5]*dawsonk
    C[5] = C[5] + 43648605*sk - 6126120*sk2 + 1729728*sk3 - 82368*sk4 + 5104*sk5
    C[5] = np.sqrt(21*np.pi)*C[5]/4096./k5
    C[5] = C[5]/dawsonk

    C[6] = 7027425405 + 3666482820*k + 872972100*k2 + 122522400*k3  + 10810800*k4 + 576576*k5 + 14784*k6
    C[6] = C[6]*dawsonk
    C[6] = C[6] - 7027425405*sk + 1018467450*sk2 - 302630328*sk3 + 17153136*sk4 - 1553552*sk5 + 25376*sk6
    C[6] = 5*C[6]*ek
    C[6] = C[6]/16384./k6
    C[6] = C[6]*ierfik

    return C