コード例 #1
0
ファイル: fields_1D.py プロジェクト: cycle13/hybrid
def get_grad_P(qn, te, grad_P, temp):
    '''
    Returns the electron pressure gradient (in 1D) on the E-field grid using P = nkT and 
    finite difference.
     
    INPUT:
        qn -- Grid charge density
        te -- Grid electron temperature
        DX -- Grid separation, used for diagnostic purposes. Defaults to simulation dx.
        inter_type -- Linear (0) or cubic spline (1) interpolation.
        
    NOTE: Interpolation is needed because the finite differencing causes the result to be deposited on the 
    B-grid. Moving it back to the E-grid requires an interpolation. Cubic spline is desired due to its smooth
    derivatives and its higher order weighting (without the polynomial craziness)
    '''
    grad_P[:] = qn * kB * te / q       # Not actually grad P, just using this array to store Pe
                                       # Putting [:] after array points to memory locations,
                                       # and prevents deferencing

    for ii in nb.prange(1, qn.shape[0]):
        temp[ii] = (grad_P[ii] - grad_P[ii - 1])  / dx
        
    temp[0] = temp[qn.shape[0] - 3]
    aux.interpolate_to_center_cspline1D(temp, grad_P)

    grad_P[0]               = grad_P[qn.shape[0] - 3]
    grad_P[qn.shape[0] - 2] = grad_P[1]
    grad_P[qn.shape[0] - 1] = grad_P[2] 
    return
コード例 #2
0
ファイル: fields_1D.py プロジェクト: cycle13/hybrid
def get_grad_P(qn, te, inter_type=1):
    '''
    Returns the electron pressure gradient (in 1D) on the E-field grid using P = nkT and 
    finite difference.
    
    INPUT:
        qn -- Grid charge density
        te -- Grid electron temperature
        DX -- Grid separation, used for diagnostic purposes. Defaults to simulation dx.
        inter_type -- Linear (0) or cubic spline (1) interpolation.
        
    NOTE: Interpolation is needed because the finite differencing causes the result to be deposited on the 
    B-grid. Moving it back to the E-grid requires an interpolation. Cubic spline is desired due to its smooth
    derivatives and its higher order weighting (without the polynomial craziness)
    '''
    grad_pe_B = np.zeros(qn.shape[0])
    grad_P = np.zeros(qn.shape[0])
    Pe = qn * kB * te / q

    for ii in np.arange(1, qn.shape[0]):
        grad_pe_B[ii] = (Pe[ii] - Pe[ii - 1])

    grad_pe_B[0] = grad_pe_B[qn.shape[0] - 3]

    # Re-interpolate to E-grid
    if inter_type == 0:
        grad_P = interpolate_to_center_linear_1D(grad_pe_B)
    elif inter_type == 1:
        grad_P = interpolate_to_center_cspline1D(grad_pe_B)

    grad_P[0] = grad_P[qn.shape[0] - 3]
    grad_P[qn.shape[0] - 2] = grad_P[1]
    grad_P[qn.shape[0] - 1] = grad_P[2]
    grad_P /= dx
    return grad_P