Esempio n. 1
0
def velocityFieldPlots(S, nameBase):
    import woo
    from woo import post2d
    flattener = post2d.CylinderFlatten(useRef=False,
                                       axis=2,
                                       origin=(.5 * S.cell.size[0],
                                               .5 * S.cell.size[1],
                                               (.6 / 2.2 * S.cell.size[2])))
    #maxVel=float('inf') #5e-2
    #exVel=lambda p: p.vel if p.vel.norm()<=maxVel else p.vel/(p.vel.norm()/maxVel)
    exVel = lambda p: p.vel
    exVelNorm = lambda p: exVel(p).norm()
    from matplotlib.figure import Figure
    fVRaw = Figure()
    ax = fVRaw.add_subplot(1, 1, 1)
    post2d.plot(post2d.data(S, exVel, flattener),
                axes=ax,
                alpha=.3,
                minlength=.3,
                cmap='jet')
    fV2 = Figure()
    ax = fV1.add_subplot(1, 1, 1)
    post2d.plot(post2d.data(S,
                            exVel,
                            flattener,
                            stDev=.5 * S.pre.psd[0][0],
                            div=(80, 80)),
                axes=ax,
                minlength=.6,
                cmap='jet')
    fV1 = Figure()
    ax = fV1.add_subplot(1, 1, 1)
    post2d.plot(post2d.data(S,
                            exVelNorm,
                            flattener,
                            stDev=.5 * S.pre.psd[0][0],
                            div=(80, 80)),
                axes=ax,
                cmap='jet')
    outs = []
    for name, fig in [('particle-velocity', fVRaw), ('smooth-velocity', fV2),
                      ('smooth-velocity-norm', fV1)]:
        out = nameBase + '.%s.png' % name
        fig.savefig(out)
        outs.append(out)
    return outs
Esempio n. 2
0
def velocityFieldPlots(S,nameBase):
    import woo
    from woo import post2d
    flattener=post2d.CylinderFlatten(useRef=False,axis=2,origin=(.5*S.cell.size[0],.5*S.cell.size[1],(.6/2.2*S.cell.size[2])))
    #maxVel=float('inf') #5e-2
    #exVel=lambda p: p.vel if p.vel.norm()<=maxVel else p.vel/(p.vel.norm()/maxVel)
    exVel=lambda p: p.vel
    exVelNorm=lambda p: exVel(p).norm()
    from matplotlib.figure import Figure
    fVRaw=Figure(); ax=fVRaw.add_subplot(1,1,1)
    post2d.plot(post2d.data(S,exVel,flattener),axes=ax,alpha=.3,minlength=.3,cmap='jet')
    fV2=Figure(); ax=fV1.add_subplot(1,1,1)
    post2d.plot(post2d.data(S,exVel,flattener,stDev=.5*S.pre.psd[0][0],div=(80,80)),axes=ax,minlength=.6,cmap='jet')
    fV1=Figure(); ax=fV1.add_subplot(1,1,1)
    post2d.plot(post2d.data(S,exVelNorm,flattener,stDev=.5*S.pre.psd[0][0],div=(80,80)),axes=ax,cmap='jet')
    outs=[]
    for name,fig in [('particle-velocity',fVRaw),('smooth-velocity',fV2),('smooth-velocity-norm',fV1)]:
        out=nameBase+'.%s.png'%name
        fig.savefig(out)
        outs.append(out)
    return outs
Esempio n. 3
0
loadFile='/tmp/uniax-tension.woo.gz'
if not os.path.exists(loadFile): raise RuntimeError("Run uniax.py first so that %s is created"%loadFile)
O.load(loadFile)

# flattener that project to the xz plane
flattener=post2d.AxisFlatten(useRef=False,axis=1)
# return scalar given a Body instance
extractDmg=lambda b: b.state.normDmg
# will call flattener.planar implicitly
# the same as: extractVelocity=lambda b: flattener.planar(b,b.state['vel'])
extractVelocity=lambda b: b.state.vel

# create new figure
pylab.figure()
# plot raw damage
post2d.plot(post2d.data(extractDmg,flattener))
pylab.suptitle('damage')

# plot smooth damage into new figure
pylab.figure(); ax,map=post2d.plot(post2d.data(extractDmg,flattener,stDev=2e-3))
pylab.suptitle('smooth damage')
# show color scale
pylab.colorbar(map,orientation='horizontal')

# shear stress
pylab.figure()
post2d.plot(post2d.data(lambda b: b.state.sigma,flattener))
pylab.suptitle('sigma')
pylab.figure()
post2d.plot(post2d.data(lambda b: b.state.tau,flattener,stDev=2e-3))
pylab.suptitle('smooth tau (in grid)')
Esempio n. 4
0
if not os.path.exists(loadFile):
    raise RuntimeError("Run uniax.py first so that %s is created" % loadFile)
O.load(loadFile)

# flattener that project to the xz plane
flattener = post2d.AxisFlatten(useRef=False, axis=1)
# return scalar given a Body instance
extractDmg = lambda b: b.state.normDmg
# will call flattener.planar implicitly
# the same as: extractVelocity=lambda b: flattener.planar(b,b.state['vel'])
extractVelocity = lambda b: b.state.vel

# create new figure
pylab.figure()
# plot raw damage
post2d.plot(post2d.data(extractDmg, flattener))
pylab.suptitle('damage')

# plot smooth damage into new figure
pylab.figure()
ax, map = post2d.plot(post2d.data(extractDmg, flattener, stDev=2e-3))
pylab.suptitle('smooth damage')
# show color scale
pylab.colorbar(map, orientation='horizontal')

# shear stress
pylab.figure()
post2d.plot(post2d.data(lambda b: b.state.sigma, flattener))
pylab.suptitle('sigma')
pylab.figure()
post2d.plot(post2d.data(lambda b: b.state.tau, flattener, stDev=2e-3))