Example #1
0
def do(n):
    global script, title
    script, title, freq = simulations[n]
    O.reset()
    plot.reset()
    execfile(script, globals())
    # add output engines
    O.engines = O.engines + [
        qt.SnapshotEngine(
            fileBase=O.tmpFilename(), iterPeriod=freq, plot='snapshot')
    ]
    # add the snapshot subplot
    plot.plots.update({'snapshot': None})
    # open the view so that it can be set up
    qt.View()
sp = pack.SpherePack()
sp.makeCloud((0, 0, 0), (2, 2, 2), rMean=.1, rRelFuzz=.6, periodic=True)
# add to scene, make it periodic
sp.toSimulation()

O.engines = [
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb()]),
    InteractionLoop([Ig2_Sphere_Sphere_ScGeom()],
                    [Ip2_FrictMat_FrictMat_FrictPhys()],
                    [Law2_ScGeom_FrictPhys_CundallStrack()]),
    NewtonIntegrator(damping=.4),
    # save data for Paraview
    VTKRecorder(fileName='3d-vtk-', recorders=['all'], iterPeriod=1000),
    # save data from Yade's own 3d view
    qt.SnapshotEngine(fileBase='3d-', iterPeriod=200, label='snapshot'),
    # this engine will be called after 20000 steps, only once
    PyRunner(command='finish()', iterPeriod=20000)
]
O.dt = .5 * PWaveTimeStep()

# prescribe constant-strain deformation of the cell
O.cell.velGrad = Matrix3(-.1, 0, 0, 0, -.1, 0, 0, 0, -.1)

# we must open the view explicitly (limitation of the qt.SnapshotEngine)
qt.View()


# this function is called when the simulation is finished
def finish():
    # snapshot is label of qt.SnapshotEngine
Example #3
0
#Creating a cylinder from facets
Cylinder=O.bodies.append(geom.facetCylinder(center=(0,0,0),radius=7,height=14,orientation=utils.Quaternion((1,0,0),pi/2),    segmentsNumber=15,wallMask=7,color=(0.3,0.3,0.3),angleRange=None,  closeGap=True))



O.engines=[
 ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],

  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]),
   NewtonIntegrator(gravity=(0,-9.8,0),damping=.4,label="newtonCustomLabel"),
   HelixEngine(rotateAroundZero=True,linearVelocity=0.0,rotationAxis=(0,1,0),angularVelocity=40, ids = Helix),#HelixEngine(rotateAroundZero=True,linearVelocity=0.0,rotationAxis=(0,1,0),angularVelocity=40, ids = Helix1),HelixEngine(rotateAroundZero=True,linearVelocity=0.0,rotationAxis=(0,1,0),angularVelocity=40, ids = Helix2),

qt.SnapshotEngine(fileBase='3d-', realPeriod=5000, label='snapshot'),
]



O.dt=0.6*utils.PWaveTimeStep()




print O.iter 
v=qt.View();

#engines -----
O.engines = [
    ForceResetter(),
    InsertionSortCollider([Bo1_Box_Aabb(),Bo1_Facet_Aabb(),Bo1_Sphere_Aabb(aabbEnlargeFactor=Enlarge,label='EF')]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=Enlarge,label='DF'),Ig2_Box_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
		[Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1,label='interactionPhys')],
		[Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=False,Key=OUT,label='interactionLaw')]
	),
    GlobalStiffnessTimeStepper(active=1, timeStepUpdateInterval=100, timestepSafetyCoefficient=0.5),
    NewtonIntegrator(damping = 0.4, gravity = (0,0,-9.81)),
    PyRunner(command = 'Coloring()', iterPeriod = pyRunnerPeriod, label = 'ctr'),   
    ]
#PyRunner(command = 'crackRecorder()',iterPeriod = crackRecordPeriod, label = 'crkRec') 
  
snapShot = qt.SnapshotEngine(fileBase='',initRun = True, iterPeriod=savePeriod)
vtkRecord = VTKRecorder(fileName='',initRun = True,recorders=['spheres','intr','colors','velocity','stress','jcfpm','cracks'],Key = OUT, iterPeriod=savePeriod)


sample = ymport.text('sample.txt')
spheres = O.bodies.append(sample)
    
for i in spheres:

	O.bodies[i].material = O.materials[rock_material]

GenerateFold('./cumulative strain')
GenerateFold('./periodical strain')
GenerateFold('./stress')
  
TW1 = TesselationWrapper() #TW1 records cumulative strain data
Example #5
0
print 30 * '*' + ' WARNING ' + 30 * '*' + '\nFor hardware/driver/...? reasons related to 3d, this script might\nsometimes crash when the first snapshot is taken with message such as\n\n\tQGLContext::makeCurrent(): Failed.\n\nor\n\n\tFatal IO error 11 (Resource temporarily unavailable) on X server :0.0.\n\nA workaround is to open the 3d view by hand, rather than having it\nopen by SnapshotEngine automatically when the first snapshot is\nabout to be taken. Sometimes only the message is displayed,\nwithout crash.\n' + 25 * '*' + ' This is a known bug. ' + 25 * '*'
TriaxialTest(noFiles=True).load()
from yade import qt, utils
O.engines = O.engines + [
    qt.SnapshotEngine(fileBase=O.tmpFilename(),
                      label='snapshotter',
                      iterPeriod=5,
                      ignoreErrors=False),
    PyRunner(iterPeriod=500, command='finito()')
]
rr = qt.Renderer()
rr.shape, rr.intrPhys = False, True


def finito():
    """This function will be called after 500 steps. Since SnapshotEngine waits for a new 3d view to open,
	it must run after the script has finished and the command line appears
	(see https://bugs.launchpad.net/yade/+bug/622669).

	For that reason, O.run() is at the end of the script and this function will be called
	once we want to exit really.
	"""
    utils.makeVideo(snapshotter.snapshots, out='/tmp/video.avi')
    print "Video saved in /tmp/video.avi"
    import sys
    sys.exit(0)


O.run()
Example #6
0
                           Bo1_Facet_Aabb()]),
    InteractionLoop([Ig2_Sphere_Sphere_ScGeom6D(),
                     Ig2_Facet_Sphere_ScGeom()], [
                         Ip2_FrictMat_FrictMat_FrictPhys(),
                         Ip2_ViscElCapMat_ViscElCapMat_ViscElCapPhys()
                     ], [
                         Law2_ScGeom_FrictPhys_CundallStrack(),
                         Law2_ScGeom_ViscElCapPhys_Basic()
                     ]),
    NewtonIntegrator(gravity=(0., 0., -10)),
    PyRunner(command='check()', iterPeriod=1000, initRun=True),
    # 移动设置 沿着Y轴以速度0.5m/s移动
    TranslationEngine(ids=BunkerID, translationAxis=(0, 1, 0), velocity=0.5),
    # 保存图片的位置需要新建tmp文件夹
    qt.SnapshotEngine(fileBase='../tmp/Bunker-',
                      iterPeriod=1000,
                      initRun=True,
                      label='snapshot')
]


def check():
    delta = 1 - sqrt(2)
    Now = O.bodies[0].state.pos
    # D为移动距离=现在位置-初始位置
    D = round(Now[1] - delta, 3)
    # 设置在初始位置停一段时间1s左右,然后以速度0.5移动
    if O.time < 0.35:
        O.engines[-2].velocity = 0
    else:
        O.engines[-2].velocity = 0.4
    # 如果移动距离大于0.8