示例#1
0
def simplegrid():

    nzones = 7

    gr = gpu.grid(nzones, xmin=0, xmax=1)

    gpu.drawGrid(gr, edgeTicks=0)

    # label a few cell-centers
    gpu.labelCenter(gr, nzones/2, r"$i$")
    gpu.labelCenter(gr, nzones/2-1, r"$i-1$")
    gpu.labelCenter(gr, nzones/2+1, r"$i+1$")

    # label a few edges
    gpu.labelEdge(gr, nzones/2, r"$i-1/2$")
    gpu.labelEdge(gr, nzones/2+1, r"$i+1/2$")


    # draw an average quantity
    gpu.drawCellAvg(gr, nzones/2, 0.4, color="r")
    gpu.labelCellAvg(gr, nzones/2, 0.4, r"$\,\langle a \rangle_i$", color="r")

    pylab.axis([gr.xmin-1.5*gr.dx,gr.xmax+1.5*gr.dx, -0.25, 1.5])
    pylab.axis("off")

    pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

    f = pylab.gcf()
    f.set_size_inches(10.0,2.5)


    pylab.savefig("simplegrid2.png")
    pylab.savefig("simplegrid2.eps")
示例#2
0
gpu.labelCenter(gr, nzones/2,   r"$i$")
gpu.labelCenter(gr, nzones/2-1, r"$i-1$")
gpu.labelCenter(gr, nzones/2+1, r"$i+1$")
gpu.labelCenter(gr, nzones/2-2, r"$i-2$")
gpu.labelCenter(gr, nzones/2+2, r"$i+2$")

gpu.labelEdge(gr, nzones/2,   r"$i-1/2$")
gpu.labelEdge(gr, nzones/2+1,   r"$i+1/2$")

# draw the data
i = 0
while i < nzones:
    gpu.drawCellAvg(gr, i, a[i], color="r")    
    i += 1
    
gpu.labelCellAvg(gr, nzones/2, a[nzones/2], r"$\langle f\rangle_i$", color="r")

# label dx
pylab.plot([gr.xr[gr.ng+nzones/2-1], gr.xr[gr.ng+nzones/2-1]], [-0.35,-0.25], color="k")
pylab.plot([gr.xr[gr.ng+nzones/2], gr.xr[gr.ng+nzones/2]], [-0.35,-0.25], color="k")
pylab.plot([gr.xr[gr.ng+nzones/2-1], gr.xr[gr.ng+nzones/2]], [-0.3,-0.3], color="k")
pylab.text(gr.xc[gr.ng+nzones/2], -0.45, r"$\Delta x$", 
           horizontalalignment="center")



pylab.axis([gr.xmin-0.5*gr.dx,gr.xmax+0.5*gr.dx, -0.5, 1.2])
pylab.axis("off")

pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)
示例#3
0
gpu.labelCenter(gr, gr.ilo-2, r"$\mathrm{lo-2}$")

gpu.labelCenter(gr, gr.ihi, r"$\mathrm{hi}$")
gpu.labelCenter(gr, gr.ihi+1, r"$\mathrm{hi+1}$")
gpu.labelCenter(gr, gr.ihi+2, r"$\mathrm{hi+2}$")

gpu.labelEdge(gr, ng+nzones/2,   r"$i-1/2$")
gpu.labelEdge(gr, ng+nzones/2+1,   r"$i+1/2$")

# draw the data
i = 0
while i < nzones:
    gpu.drawCellAvg(gr, ng+i, a[i], color="r")    
    i += 1
    
gpu.labelCellAvg(gr, ng+nzones/2, a[nzones/2], r"$\langle a\rangle_i$", color="r")

# label dx
pylab.plot([gr.xr[gr.ng+nzones/2-1], gr.xr[gr.ng+nzones/2-1]], [-0.35,-0.25], color="k")
pylab.plot([gr.xr[gr.ng+nzones/2], gr.xr[gr.ng+nzones/2]], [-0.35,-0.25], color="k")
pylab.plot([gr.xr[gr.ng+nzones/2-1], gr.xr[gr.ng+nzones/2]], [-0.3,-0.3], color="k")
pylab.text(gr.xc[gr.ng+nzones/2], -0.55, r"$\Delta x$", 
           horizontalalignment="center", fontsize=16)



pylab.axis([gr.xmin-2.02*gr.dx,gr.xmax+2.02*gr.dx, -0.5, 1.6])
pylab.axis("off")

pylab.subplots_adjust(left=0.025,right=0.975,bottom=0.05,top=0.95)
gpu.labelEdge(gr, ng + ncells / 2, r"$i-1/2$")
gpu.labelEdge(gr, ng + ncells / 2 + 1, r"$i+1/2$")

gpu.labelEdge(gr, ng + gr.nx, r"$b$")
gpu.labelEdge(gr, ng + 0, r"$a$")

# draw the data
i = 0
while i < ncells + 2 * ng:
    gpu.drawCellAvg(gr, i, acell[i], color="r")
    i += 1

gpu.labelCellAvg(gr,
                 ng + ncells / 2,
                 acell[ng + ncells / 2],
                 r"$\langle f\rangle_i$",
                 color="r")

# label dx
pylab.plot([gr.xr[gr.ng + ncells / 2 - 1], gr.xr[gr.ng + ncells / 2 - 1]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xr[gr.ng + ncells / 2], gr.xr[gr.ng + ncells / 2]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xr[gr.ng + ncells / 2 - 1], gr.xr[gr.ng + ncells / 2]],
           [-0.3, -0.3],
           color="k")
pylab.text(gr.xc[gr.ng + ncells / 2],
           -0.45,