示例#1
0
文件: uniax.py 项目: yankang84/woodem
def initTest():
    global mode
    print "init"
    if O.iter > 0:
        O.wait()
        O.loadTmp('initial')
        print "Reversing plot data"
        plot.reverseData()
    else:
        plot.plot()
    strainer.strainRate = abs(
        strainRateTension
    ) if mode == 'tension' else -abs(strainRateCompression)
    try:
        from woo import qt
        renderer = qt.Renderer()
        renderer.dispScale = (1000, 1000,
                              1000) if mode == 'tension' else (100, 100, 100)
    except ImportError:
        pass
    print "init done, will now run."
    O.step()
    # to create initial contacts
    # now reset the interaction radius and go ahead
    if not scGeom: ss2d3dg.distFactor = -1.
    else: ss2sc.interactionDetectionFactor = 1.
    is2aabb.aabbEnlargeFactor = -1.

    O.run()
示例#2
0
文件: uniax.py 项目: Azeko2xo/woodem
def initTest():
	global mode
	print "init"
	if O.iter>0:
		O.wait();
		O.loadTmp('initial')
		print "Reversing plot data"; plot.reverseData()
	else: plot.plot()
	strainer.strainRate=abs(strainRateTension) if mode=='tension' else -abs(strainRateCompression)
	try:
		from woo import qt
		renderer=qt.Renderer()
		renderer.dispScale=(1000,1000,1000) if mode=='tension' else (100,100,100)
	except ImportError: pass
	print "init done, will now run."
	O.step(); # to create initial contacts
	# now reset the interaction radius and go ahead
	if not scGeom: ss2d3dg.distFactor=-1.
	else: ss2sc.interactionDetectionFactor=1.
	is2aabb.aabbEnlargeFactor=-1.

	O.run()
示例#3
0
              2e6),  # Vector6 of prescribed final values
        stressMask=
        0b101100,  # prescribed ex,ey,sz,syz,ezx,sxy;   e..strain;  s..stress
        nSteps=nSteps,  # how many time steps the simulation will last
        # after reaching nSteps do doneHook action
        doneHook=
        'print("Simulation with Peri3dController finished."); O.pause()',

        # the prescribed path (step,value of stress/strain) can be defined in absolute values
        xxPath=[(465, 5e-4), (934, -5e-4), (1134, 10e-4)],
        # or in relative values
        yyPath=[(2, 4), (7, -2), (11, 0), (14, 4)],
        # if the goal value is 0, the absolute stress/strain values are always considered (step values remain relative)
        zzPath=[(5, -1e7), (10, 0)],
        # if ##Path is not explicitly defined, it is considered as linear function between (0,0) and (nSteps,goal)
        # as in yzPath and xyPath
        # the relative values are really relative (zxPath gives the same - except of the sign from goal value - result as yyPath)
        zxPath=[(4, 2), (14, -1), (22, 0), (28, 2)],
        xyPath=[(1, 1), (2, -1), (3, 1), (4, -1), (5, 1)],
        # variables used in the first step
        label='p3d'),
    PyRunner(command='plotAddData()', iterPeriod=1),
]

O.step()
bo1s.aabbEnlargeFactor = ig2ss.distFactor = -1

O.run()
#O.wait()
plot.plot()
    ForceResetter(),
    InsertionSortCollider( [Bo1_Sphere_Aabb(aabbEnlargeFactor=interactionRadius,label='aabb')] ), 

    InteractionLoop(
    [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,label='Ig2ssGeom')],
    [Ip2_WireMat_WireMat_WirePhys(linkThresholdIteration=1,label='interactionPhys')],
    [Law2_ScGeom_WirePhys_WirePM(linkThresholdIteration=1,label='interactionLaw')]
    ),
    NewtonIntegrator(damping=0.),
    PyRunner(initRun=True,iterPeriod=1,command='addPlotData()')
]


#### plot some results
plot.plots={'un':('Fn',)}
plot.plot(noShow=False, subPlots=False)


#### create link (no time step needed since loading is involved in this step)
O.step() # create cohesive link (cohesiveTresholdIteration=1)


#### initializes now the interaction detection factor
aabb.aabbEnlargeFactor=-1.
Ig2ssGeom.interactionDetectionFactor=-1.

## time step definition
## no time step definition is required since setVelocities=False in StepDisplacer


#### define simulation loading
示例#5
0
        Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,
                                 label='Ig2ssGeom')
    ], [
        Ip2_WireMat_WireMat_WirePhys(linkThresholdIteration=1,
                                     label='interactionPhys')
    ], [
        Law2_ScGeom_WirePhys_WirePM(linkThresholdIteration=1,
                                    label='interactionLaw')
    ]),
    NewtonIntegrator(damping=0.),
    PyRunner(initRun=True, iterPeriod=1, command='addPlotData()')
]

#### plot some results
plot.plots = {'un': ('Fn', )}
plot.plot(noShow=False, subPlots=False)

#### create link (no time step needed since loading is involved in this step)
O.step()  # create cohesive link (cohesiveTresholdIteration=1)

#### initializes now the interaction detection factor
aabb.aabbEnlargeFactor = -1.
Ig2ssGeom.interactionDetectionFactor = -1.

## time step definition
## no time step definition is required since setVelocities=False in StepDisplacer

#### define simulation loading
O.engines = [
    StepDisplacer(ids=[1],
                  mov=Vector3(0, +1e-5, 0),
示例#6
0
    jumper.rot=Quaternion(Vector3.UnitZ,1/(1e4*nSteps))

O.run(nSteps,True)
if mode=='mov':
    plot.plots={'zShift-DD':(
        #('epsT-DD','g-'),('epsT-Sc','r^'),
        ('dist-DD','g-'),('dist-Sc','r^'),
        None,
        ('sigmaT-DD','b-'),('sigmaT-Sc','m^')
        #('relResStr-DD','b-'),('relResStr-Sc','m^')
        #('epsN-DD','b-'),('epsN-Sc','m^')
    )}
elif mode=='rot':
    plot.plots={'zRot-DD':(
        ('epsT-DD','g|'),('epsT-Sc','r-'),
        None,
        ('sigmaT-DD','b-'),('sigmaT-Sc','mv')
    )}



if 1:
    f='/tmp/cpm-geom-'+mode+'.pdf'
    plot.plot(noShow=True).savefig(f)
    print 'Plot saved to '+f
    quit()
else:
    plot.plot()


示例#7
0
文件: uniax.py 项目: Azeko2xo/woodem
			mode='compression'
			O.save('/tmp/uniax-tension.woo.gz')
			print "Saved /tmp/uniax-tension.woo.gz (for use with interaction-histogram.py and uniax-post.py)"
			print "Damaged, switching to compression... "; O.pause()
			# important! initTest must be launched in a separate thread;
			# otherwise O.load would wait for the iteration to finish,
			# but it would wait for initTest to return and deadlock would result
			import thread; thread.start_new_thread(initTest,())
			return
		else:
			print "Damaged, stopping."
			ft,fc=max(sigma),min(sigma)
			print 'Strengths fc=%g, ft=%g, |fc/ft|=%g'%(fc,ft,abs(fc/ft))
			title=O.tags['description'] if 'description' in O.tags.keys() else O.tags['params']
			print 'gnuplot',plot.saveGnuplot(O.tags['id'],title=title)
			print 'Bye.'
			#O.pause()
			sys.exit(0)
		
def addPlotData():
	woo.plot.addData({'t':O.time,'i':O.iter,'eps':strainer.strain,'sigma':strainer.avgStress+isoPrestress,
		'sigma.25':utils.forcesOnCoordPlane(coord_25,axis)[axis]/area_25+isoPrestress,
		'sigma.50':utils.forcesOnCoordPlane(coord_50,axis)[axis]/area_50+isoPrestress,
		'sigma.75':utils.forcesOnCoordPlane(coord_75,axis)[axis]/area_75+isoPrestress,
		})
plot.plot()
O.run()
initTest()
utils.waitIfBatch()

示例#8
0
import woo.plot as yp


def myAddPlotData():
    yp.addData(t=O.time,
               F_applied=forcer.force[2],
               supportReaction=O.forces.f(0)[2])


O.saveTmp()

# try open 3d view, if not running in pure console mode
try:
    import woo.qt
    woo.qt.View()
except ImportError:
    pass

# run so many steps such that prescribed number of pulses is done
O.run(int((nPulses / freq) / O.dt), True)

# plot the time-series of force magnitude
import pylab
pylab.plot(times, magnitudes, label='Force magnitude over 1 pulse')
pylab.legend(('Force magnitude', ))
pylab.xlabel('t')
pylab.grid(True)
# plot some recorded data
yp.plots = {'t': ('F_applied', 'supportReaction')}
yp.plot()
示例#9
0
文件: law-test.py 项目: CrazyHeex/woo
    #    (-.02,.1,.1),(-.02,-.1,.1),(-.02,-.1,-.1),(-.02,.1,-.1),(-.02,.1,.1), # go in square in the shear plane without changing normal deformation
    #    (-1e-4,0,0) # back to the origin, but keep some overlap to not delete the interaction
    #    ],pathSteps=[100],doneHook='tester.dead=True; O.pause()',label='tester',rotWeight=.2,idWeight=.2),
    NewtonIntegrator(),
    PyRunner(iterPeriod=1,command='addPlotData()'),
]

def addPlotData():
    i=O.interactions[0,1]
    plot.addData(
        un=tester.uTest[0],us1=tester.uTest[1],us2=tester.uTest[2],
        ung=tester.uGeom[0],us1g=tester.uGeom[1],us2g=tester.uGeom[2],
        phiX=tester.uTest[3],phiY=tester.uTest[4],phiZ=tester.uTest[5],
        phiXg=tester.uGeom[3],phiYg=tester.uGeom[4],phiZg=tester.uGeom[5],
        i=O.iter,Fs=i.phys.shearForce.norm(),Fn=i.phys.normalForce.norm(),Tx=O.forces.t(0)[0],Tyz=sqrt(O.forces.t(0)[1]**2+O.forces.t(0)[2]**2)
    )
plot.plots={'us1':('us2',),'Fn':('Fs',),'i':('un','us1','us2'),' i':('Fs','Fn','Tx','Tyz'),'  i':('ung','us1g','us2g'),'i  ':('phiX','phiXg','phiY','phiYg','phiZ','phiZg')}  #'ung','us1g','us2g'
plot.plot(subPlots=True)

try:
    from woo import qt
    qt.Controller(); v=qt.View()
    rr=qt.Renderer()
    rr.extraDrawers=[GlExtra_LawTester()]
    rr.intrGeom=True
except ImportError: pass
O.dt=1

O.saveTmp()
#O.run()
示例#10
0
from woo import qt
qt.View()
qt.Controller()

############################################
##### now the part pertaining to plots #####
############################################

from math import *
from woo import plot
## make one plot: step as function of fn
plot.plots={'un':('fn')}

## this function is called by plotDataCollector
## it should add data with the labels that we will plot
## if a datum is not specified (but exists), it will be NaN and will not be plotted

def myAddPlotData():
	i=O.interactions[0,1]
	## store some numbers under some labels
	plot.addData(fn=i.phys.normalForce[0],step=O.iter,un=2*s0.shape.radius-s1.state.pos[0]+s0.state.pos[0],kn=i.phys.kn)	

O.run(100,True); plot.plot()

## We will have:
## 1) data in graphs (if you call plot.plot())
## 2) data in file (if you call plot.saveGnuplot('/tmp/a')
## 3) data in memory as plot.data['step'], plot.data['fn'], plot.data['un'], etc. under the labels they were saved

示例#11
0
文件: energy.py 项目: yankang84/woo
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]),
    ContactLoop(
        [Cg2_Sphere_Sphere_L6Geom(),Cg2_Wall_Sphere_L3Geom],
        [Cp2_FrictMat_FrictPhys(frictAngle=table.frictAngle)],
        [Law2_L6Geom_ElPerfPl()]
    ),
    IntraForce(
    GravityEngine(gravity=(0,0,-9.81)),
    NewtonIntegrator(damping=table.nonviscDamp,kinSplit=True),
    PyRunner(iterPeriod=1,command='addPlotData()'),
]
O.dt=.1*utils.PWaveTimeStep()

def addPlotData():
    Ek,maxId=utils.kineticEnergy(findMaxId=True)
    plot.addData(i=O.iter,total=O.energy.total(),maxId=maxId,**O.energy)

# turn on energy tracking
O.trackEnergy=True
O.saveTmp()
# the callable should return list of strings, plots will be updated automatically
plot.plots={'i':[O.energy.keys,None,'total']}

#from woo import timing
#O.timingEnabled=True
#timing.stats()
plot.plot(subPlots=True)
示例#12
0
    utils.sphere([0,0,0],1,dynamic=False,color=[1,0,0]),
    utils.sphere([0,0,2],1,color=[0,1,0])
])

# elastic timestep
O.dt=.5*utils.PWaveTimeStep()

# callback for plotDataCollector
import woo.plot as yp
def myAddPlotData():
    yp.addData(t=O.time,F_applied=forcer.force[2],supportReaction=O.forces.f(0)[2])

O.saveTmp()

# try open 3d view, if not running in pure console mode
try:
    import woo.qt
    woo.qt.View()
except ImportError: pass

# run so many steps such that prescribed number of pulses is done
O.run(int((nPulses/freq)/O.dt),True)

# plot the time-series of force magnitude
import pylab
pylab.plot(times,magnitudes,label='Force magnitude over 1 pulse'); pylab.legend(('Force magnitude',)); pylab.xlabel('t'); pylab.grid(True)
# plot some recorded data
yp.plots={'t':('F_applied','supportReaction')}
yp.plot()

示例#13
0
elif mode == 'rot':
    jumper.rot = Quaternion(Vector3.UnitZ, 1 / (1e4 * nSteps))

O.run(nSteps, True)
if mode == 'mov':
    plot.plots = {
        'zShift-DD': (
            #('epsT-DD','g-'),('epsT-Sc','r^'),
            ('dist-DD', 'g-'),
            ('dist-Sc', 'r^'),
            None,
            ('sigmaT-DD', 'b-'),
            ('sigmaT-Sc', 'm^')
            #('relResStr-DD','b-'),('relResStr-Sc','m^')
            #('epsN-DD','b-'),('epsN-Sc','m^')
        )
    }
elif mode == 'rot':
    plot.plots = {
        'zRot-DD': (('epsT-DD', 'g|'), ('epsT-Sc', 'r-'), None,
                    ('sigmaT-DD', 'b-'), ('sigmaT-Sc', 'mv'))
    }

if 1:
    f = '/tmp/cpm-geom-' + mode + '.pdf'
    plot.plot(noShow=True).savefig(f)
    print 'Plot saved to ' + f
    quit()
else:
    plot.plot()