Exemple #1
0
 def gamma_E_profile(self):
     r = self.r_profile
     # exclude first and last grid point, since those are potentially artificial
     D = diff_matrix(r[1], r[-2], len(r) - 2, order=4)
     omega0 = self.omega0_estimate_profile[1:-1]
     ddr_omega0 = np.dot(D, omega0)
     ddr_omega0 = np.concatenate(
         ([ddr_omega0[0]], ddr_omega0, [ddr_omega0[-1]]))
     return -r * ddr_omega0 / (self.q)
Exemple #2
0
def dpsiNdr(psi, r):
    from diff_matrix import diff_matrix

    psi_array = numpy.array([psi(ri) for ri in r])
    psiN_array = psi_array / psi_array[-1]
    rmin = r[0]
    rmax = r[-1]
    N = len(r)
    diff_matrix = diff_matrix(rmin, rmax, N)
    dpsiNdr_array = numpy.dot(diff_matrix, psiN_array)
    return dpsiNdr_array
    y,ddx_y=derivative_bezier_transition(flist,ddx_flist,plist,dlist,x)
    
    fig = plt.figure()
    ax = fig.add_subplot(numRows, numCols, plotNum); plotNum += 1
    
    plt.plot(x,y(x),'o')
    plt.hold(True)
    plt.plot(x,flist[0](x))
    plt.plot(x,flist[1](x))
    plt.plot(x,flist[2](x))

    ax = fig.add_subplot(numRows, numCols, plotNum); plotNum += 1
    
    plt.plot(x,ddx_y(x),'o')
    plt.hold(True)
    D=diff_matrix(x[0],x[-1],len(x))
    plt.plot(x, numpy.dot(D,y(x)))
    
 
    #ax = fig.add_subplot(numRows, numCols, plotNum); plotNum += 1

    #t=numpy.linspace(0,1)
    #P0=numpy.array([9,0])
    #P1=numpy.array([10,-2])
    #P2=numpy.array([13,-3])
    #y=bezier_func_y(P0,P1,P2)(t)
    #x=bezier_func_x(P0,P1,P2)(t)
    #plt.plot(x,y)    

    
    
Exemple #4
0
    return (min_val,max_val,psiMin,psiMax)

def generate_sin_profile(xPed,xPedGrad,psiMinPed,psiMaxPed):
    (min_val,max_val,psiMin,psiMax) = parameter_wrapper(xPed,xPedGrad,psiMinPed,psiMaxPed)
    return (sin_profile(min_val,max_val,psiMin,psiMax),ddx_sin_profile(min_val,max_val,psiMin,psiMax))

if __name__ == "__main__":
    xped=1.0
    w = 2
    dxdr = 0.1
    xsol = xped - dxdr*w
    
    psiN0 = 1.0
    psiN1 = psiN0 + w*2
    psiN=np.linspace(psiN0,psiN1)
    D=diff_matrix(psiN[0],psiN[-1],len(psiN))

    x=sin_profile(xsol,xped,psiN0,psiN1)
    dxdpsiN = ddx_sin_profile(xsol,xped,psiN0,psiN1)
    numerical_dxdpsiN = np.dot(D,x(psiN))

    plt.subplot(2, 1, 1)
    plt.hold(True)
    plt.plot(psiN,x(psiN))

    plt.subplot(2, 1, 2)
    plt.hold(True)
    plt.plot(psiN,dxdpsiN(psiN))
    plt.plot(psiN,numerical_dxdpsiN)