示例#1
0
def volweight(numsplit=(3, 3),
              factor=1,
              fact2=None,
              eq='/home/ian/python/g1120824019.01400'):

    b = TRIPPy.Tokamak(eqtools.EqdskReader(gfile=eq))

    rgrid = b.eq.getRGrid()
    zgrid = b.eq.getZGrid()
    rgrid = scipy.linspace(rgrid[0], rgrid[-1], len(rgrid) * factor)
    zgrid = scipy.linspace(zgrid[0], zgrid[-1], len(zgrid) * factor)

    twopi2 = twopi(b)

    surfs = twopi2[0].split(numsplit[0], numsplit[1])

    out = scipy.zeros((len(rgrid) - 1, len(zgrid) - 1))

    for i in surfs:
        for j in i:
            surf2 = j
            if fact2 is None:
                surf2 = j
            else:
                surf2 = j.split(fact2, fact2)

            beam = TRIPPy.beam.multiBeam(surf2, twopi2[1])
            b.trace(beam)
            #TRIPPy.plot.mayaplot.plotLine(beam)
            out += TRIPPy.beam.volWeightBeam(beam, rgrid, zgrid)

    return out
示例#2
0
def plotSIFGI():

    a = eqtools.EqdskReader(gfile='/afs/ipp-garching.mpg.de/home/i/ianf/codes/python/general/g33669.3000')
    a.remapLCFS()
    b = eqtools.AUGDDData(33669)
    tok = TRIPPy.Tokamak(b)
    cont = (pow(scipy.linspace(0,1,11),2)*(a.getFluxLCFS()-a.getFluxAxis())+a.getFluxAxis())

    print(a.getFluxAxis())
    print(a.getFluxLCFS())
    print(cont)
    temp = b.getMachineCrossSectionFull()
    plotEq.plot(a,33669,lims=temp,contours=-1*cont)
    
    GI = genGRW(tok)
    r = GI.r()[0][-2:]
    z = GI.r()[2][-2:]
    print(r,z)
    plt.plot(r,z,color='#0E525A',linewidth=2.)

    SIF = genSIF(tok)
    r = SIF.r()[0][-2:]
    z = SIF.r()[2][-2:]
    print(r,z)
    plt.plot(r,z,color='#228B22',linewidth=2.)
    plt.subplots_adjust(left=.2,right=.95)
    plt.gca().set_xlim([scipy.nanmin(temp[0].astype(float)),scipy.nanmax(temp[0].astype(float))])
    plt.gca().set_ylim([scipy.nanmin(temp[1].astype(float)),scipy.nanmax(temp[1].astype(float))])
    plt.text(1.4,.9,'CSXR',fontsize=22,zorder=10)
    plt.text(2.25,.1,'GI',fontsize=22,zorder=10)
    limy = plt.gca().get_ylim()
    limx = plt.gca().get_xlim()
    plt.gca().text(1.0075*(limx[1]-limx[0])+limx[0],.97*(limy[1]-limy[0])+limy[0],str(33669),rotation=90,fontsize=14)
示例#3
0
def pltne(nped=.7e20,ncor=1e20,tped=1e3,tcor=4e3,num=1e-3):
    fig = plt.figure(figsize=(6*.8,11*.6))
    ax = fig.add_subplot(211)
    te = data['en']

    ne = GIWprofiles.ne(GIWprofiles.te2rho2(te,4e3,1e3),1.0e20,.7e20)

    ax.semilogx(te,ne/1e19,color='#0E525A',linewidth=2.)
    ax.set_xlim(1e2,1e4)
    ax.set_ylim(0.,12)
    ax.set_ylabel('$n_e$ [$10^{19}$ m$^{-3}$]') 
    ax.text(2e2,7.5,'$n_e(T_e)$')

    ax2 = fig.add_subplot(212,sharex=ax)

    ax2.set_ylabel('$n_e^2dl$ [$10^{38}$ m$^{-5}$]')

    plt.subplots_adjust(hspace=.2,left=.2,right=.95,wspace=.1)

    a = eqtools.EqdskReader(gfile='/afs/ipp-garching.mpg.de/home/i/ianf/codes/python/general/g33669.3000')

    tok = TRIPPy.Tokamak(a)
    ray = genSIF(tok)
    print(ray.norm.s)
    inp = scipy.mgrid[ray.norm.s[-2]:ray.norm.s[-1]:num]
    r = ray(inp).r()[0]
    z = ray(inp).r()[2]
    l = inp - inp[0]

    logte = scipy.log(te)
    halfte = scipy.exp(logte[1:]/2. + logte[:-1]/2.)
    rho = scipy.squeeze(a.rz2psinorm(r, z, each_t=True, sqrt=True)) 
    print(rho.shape,l.shape)
    #solve at each time 
    output = SIFweightings.calcArealDens(l, te, halfte, rho, tped, tcor, nped, ncor)
    ax2.semilogx(te,output/1e38,color='#0E525A',linewidth=2.)
    ax2.set_xlabel('$T_e$ [eV]')
    ax2.text(2e2,2,'$M(T_e)$')
    
    ax.set_axis_bgcolor('#eaeaea')
示例#4
0
import TRIPPy
import TRIPPy.plot.mayaplot as mplt
import TRIPPy.BPLY
import mayavi.mlab as mlab
import eqtools
import matplotlib.pyplot as plt

xlim = [-1., 1.]
ylim = [-1., 1.]
zlim = [-.5, .5]

x1 = 201
y1 = 71
z1 = 201

k = eqtools.EqdskReader(gfile='/home/ian/python/g1120824019.01400')
pts1 = 201
xgrid = scipy.mgrid[xlim[0]:xlim[1]:complex(0, x1)]
ygrid = scipy.mgrid[ylim[0]:ylim[1]:complex(0, y1)]
zgrid = scipy.mgrid[zlim[0]:zlim[1]:complex(0, z1)]
x, y, z = scipy.mgrid[xlim[0]:xlim[-1]:complex(0, x1 - 1),
                      ylim[0]:ylim[-1]:complex(0, y1 - 1),
                      zlim[0]:zlim[-1]:complex(0, z1 - 1)]

output = k.rz2psinorm(scipy.sqrt(x**2 + y**2), z)
output[output > 1] = scipy.nan

cmod = TRIPPy.Tokamak(k)
#mplt.plotTokamak(cmod,angle=[-scipy.pi/6,scipy.pi/6],section=6)
#n=0
示例#5
0
def plotSIF2(num=1e-4):

    a = eqtools.EqdskReader(gfile='/afs/ipp-garching.mpg.de/home/i/ianf/codes/python/general/g33669.3000')
    a.remapLCFS()
    b = eqtools.AUGDDData(33669)
    tok = TRIPPy.Tokamak(b)
    cont = (pow(scipy.linspace(0,1,11),2)*(a.getFluxLCFS()-a.getFluxAxis())+a.getFluxAxis())

    print(a.getFluxAxis())
    print(a.getFluxLCFS())
    print(cont)
    temp = b.getMachineCrossSectionFull()
    plotEq.plot(a,33669,lims=temp,contours=-1*cont[[0,10]],alpha=.15)

    ray = genSIF(tok)
    print(ray.norm.s)
    #inp = scipy.linspace(ray.norm.s[-2],ray.norm.s[-1],num)
    inp = scipy.mgrid[ray.norm.s[-2]:ray.norm.s[-1]:num]
    r = ray(inp).r()[0]
    z = ray(inp).r()[2]
    l = inp - inp[0]

    print(r.shape,z.shape,l.shape)

    plt.plot(r,z,color='#228B22',linewidth=2.)

    plt.subplots_adjust(left=.2,right=.95)
    plt.gca().set_xlim([scipy.nanmin(temp[0].astype(float)),scipy.nanmax(temp[0].astype(float))])
    plt.gca().set_ylim([scipy.nanmin(temp[1].astype(float)),scipy.nanmax(temp[1].astype(float))])
    limy = plt.gca().get_ylim()
    limx = plt.gca().get_xlim()
    plt.gca().text(1.0075*(limx[1]-limx[0])+limx[0],.97*(limy[1]-limy[0])+limy[0],str(33669),rotation=90,fontsize=14)
    
    ax1 = plt.gca()
    ax1.arrow(1.8,-.608,.025,0.0,head_width=.05,head_length=.1,fc='k',ec='k',zorder=10)
    ax1.arrow(1.8,0.728,.025,0.0,head_width=.05,head_length=.1,fc='k',ec='k',zorder=10)

    iax = plt.axes([0,0,1,1])

    x0 = (r.min()-limx[0])/(limx[1]-limx[0])
    y0 = (z.min()-limy[0])/(limy[1]-limy[0])
    y1 = (z.max()-limy[0])/(limy[1]-limy[0])

    print(limx)
    print(limy)

    print([x0+.05,y0,.2,y1-y0])

    ip = InsetPosition(ax1, [x0+.1,y0,.3,y1-y0])
    #ip = plt.axes([.05,.05,.02,.02])
    iax.set_axes_locator(ip)
    

    tempData = scipy.squeeze(GIWprofiles.te(b.rz2psinorm(r,z,[3.0],sqrt=True,each_t=True),4e3,1e3))
    print(tempData.shape)
    iax.semilogx(tempData,l,color='#0E525A',linewidth=2.)
    iax.set_ylim(l.max(),l.min())
    iax.set_xlim(1e2,1e4)
    iax.set_xlabel('$T_e$ [eV]')
    iax.text(2e2,1.0,'$l(T_e)$')
    iax.yaxis.tick_right()
    iax.set_axis_bgcolor('#eaeaea')