예제 #1
0
pylab.clf()

gpu.drawGrid(gr)

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$")


# draw the data
i = 0
while i < nzones:
    gpu.drawFDData(gr, i, a[i], color="r")    
    i += 1
    

gpu.labelFD(gr, nzones/2, a[nzones/2], r"$f_i$", color="r")

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



pylab.axis([gr.xmin-gr.dx,gr.xmax+gr.dx, -0.5, 1.2])
예제 #2
0
gr = gpu.grid(nzones, fd=1)

pylab.clf()

gpu.drawGrid(gr)

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$")

# draw the data
i = 0
while i < nzones:
    gpu.drawFDData(gr, i, a[i], color="r")
    i += 1

gpu.labelFD(gr, nzones / 2, a[nzones / 2], r"$f_i$", color="r")

# label dx
pylab.plot([gr.xc[gr.ng + nzones / 2 - 1], gr.xc[gr.ng + nzones / 2 - 1]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xc[gr.ng + nzones / 2], gr.xc[gr.ng + nzones / 2]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xc[gr.ng + nzones / 2 - 1], gr.xc[gr.ng + nzones / 2]],
           [-0.3, -0.3],
           color="k")
pylab.text(0.5 * (gr.xc[gr.ng + nzones / 2 - 1] + gr.xc[gr.ng + nzones / 2]),
예제 #3
0
gpu.drawGrid(gr, drawGhost=1)

labels = ["-1", "0", "1", "", "i-1", "i", "i+1", "", "N-2", "N-1", "N"]

i = gr.ilo - gr.ng
while (i < gr.ng + gr.nx + 1):

    if not labels[i] == "":
        gpu.labelCenter(gr, i, r"$%s$" % (labels[i]), fontsize="medium")
    i += 1

# draw the data
i = gr.ilo
while i < gr.ihi + 1:
    gpu.drawFDData(gr, i, a[i - gr.ng], color="r")
    i += 1

gpu.labelFD(gr, gr.ilo + 4, a[gr.ilo + 4 - gr.ng], r"$a_i$", color="r")

# label dx
pylab.plot([gr.xc[gr.ng + nzones / 2 - 1], gr.xc[gr.ng + nzones / 2 - 1]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xc[gr.ng + nzones / 2], gr.xc[gr.ng + nzones / 2]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xc[gr.ng + nzones / 2 - 1], gr.xc[gr.ng + nzones / 2]],
           [-0.3, -0.3],
           color="k")
pylab.text(0.5 * (gr.xc[gr.ng + nzones / 2 - 1] + gr.xc[gr.ng + nzones / 2]),
예제 #4
0
gr = gpu.grid(nnodes, ng=ng, fd=1)

pylab.clf()

gpu.drawGrid(gr, emphasizeEnd=1, drawGhost=1)

gpu.labelCenter(gr, ng + nnodes / 2, r"$i$")
gpu.labelCenter(gr, ng + nnodes / 2 - 1, r"$i-1$")
gpu.labelCenter(gr, ng + nnodes / 2 + 1, r"$i+1$")
#gpu.labelCenter(gr, ng+nnodes/2-2, r"$i-2$")
#gpu.labelCenter(gr, ng+nnodes/2+2, r"$i+2$")

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

gpu.labelFD(gr, ng + nnodes / 2, anode[ng + nnodes / 2], r"$f_i$", color="r")

# label dx
pylab.plot([gr.xc[gr.ng + nnodes / 2 - 1], gr.xc[gr.ng + nnodes / 2 - 1]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xc[gr.ng + nnodes / 2], gr.xc[gr.ng + nnodes / 2]],
           [-0.35, -0.25],
           color="k")
pylab.plot([gr.xc[gr.ng + nnodes / 2 - 1], gr.xc[gr.ng + nnodes / 2]],
           [-0.3, -0.3],
           color="k")
pylab.text(0.5 * (gr.xc[gr.ng + nnodes / 2 - 1] + gr.xc[gr.ng + nnodes / 2]),
예제 #5
0
gpu.drawGrid(gr, drawGhost=1)

labels = ["-1", "0", "1", "", "i-1", "i", "i+1", "", "N-2", "N-1", "N"]

i = gr.ilo-gr.ng
while (i < gr.ng+gr.nx+1):

    if not labels[i] == "":
        gpu.labelCenter(gr, i,   r"$%s$" % (labels[i]), fontsize="medium")
    i += 1

    
# draw the data
i = gr.ilo
while i < gr.ihi+1:
    gpu.drawFDData(gr, i, a[i-gr.ng], color="r")    
    i += 1
    

gpu.labelFD(gr, gr.ilo+4, a[gr.ilo+4-gr.ng], r"$a_i$", color="r")

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


pylab.axis([gr.xmin-1.1*gr.dx,gr.xmax+1.1*gr.dx, -0.5, 1.3])