~yade-dev/yade/0.80

« back to all changes in this revision

Viewing changes to doc/sphinx/tutorial/05-3d-postprocessing.py

  • Committer: Anton Gladky
  • Date: 2012-05-02 21:50:42 UTC
  • Revision ID: gladky.anton@gmail.com-20120502215042-v1fa9r65usqe7kfk
0.80.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# demonstrate 3d postprocessing with yade
 
2
#
 
3
# 1. qt.SnapshotEngine saves images of the 3d view as it appears on the screen periodically
 
4
#    utils.makeVideo is then used to make real movie from those images
 
5
# 2. VTKRecorder saves data in files which can be opened with Paraview
 
6
#    see the User's manual for an intro to Paraview
 
7
 
 
8
# generate loose packing
 
9
from yade import pack, qt
 
10
sp=pack.SpherePack()
 
11
sp.makeCloud((0,0,0),(2,2,2),rMean=.1,rRelFuzz=.6,periodic=True)
 
12
# add to scene, make it periodic
 
13
sp.toSimulation()
 
14
 
 
15
O.engines=[
 
16
        ForceResetter(),
 
17
        InsertionSortCollider([Bo1_Sphere_Aabb()]),
 
18
        InteractionLoop(
 
19
                [Ig2_Sphere_Sphere_L3Geom()],
 
20
                [Ip2_FrictMat_FrictMat_FrictPhys()],
 
21
                [Law2_L3Geom_FrictPhys_ElPerfPl()]
 
22
        ),
 
23
        NewtonIntegrator(damping=.4),
 
24
        # save data for Paraview
 
25
        VTKRecorder(fileName='3d-vtk-',recorders=['all'],iterPeriod=1000),
 
26
        # save data from Yade's own 3d view
 
27
        qt.SnapshotEngine(fileBase='3d-',iterPeriod=200,label='snapshot'),
 
28
        # this engine will be called after 20000 steps, only once
 
29
        PyRunner(command='finish()',iterPeriod=20000)
 
30
]
 
31
O.dt=.5*utils.PWaveTimeStep()
 
32
 
 
33
# prescribe constant-strain deformation of the cell
 
34
O.cell.velGrad=Matrix3(-.1,0,0, 0,-.1,0, 0,0,-.1)
 
35
 
 
36
# we must open the view explicitly (limitation of the qt.SnapshotEngine)
 
37
qt.View()
 
38
 
 
39
# this function is called when the simulation is finished
 
40
def finish():
 
41
        # snapshot is label of qt.SnapshotEngine
 
42
        # the 'snapshots' attribute contains list of all saved files
 
43
        utils.makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
 
44
        O.pause()
 
45
 
 
46
# set parameters of the renderer, to show network chains rather than particles
 
47
# these settings are accessible from the Controller window, on the second tab ("Display") as well
 
48
rr=yade.qt.Renderer()
 
49
rr.shape=False
 
50
rr.intrPhys=True
 
51