yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #18639
[Question #677084]: manipulate the spheres during running
New question #677084 on Yade:
https://answers.launchpad.net/yade/+question/677084
I want to get the information of some specific spheres during the calculation when it meets some condition, like the time larger than some point. i have used two run mode of yade, one is just normal mode, the other is batch mode.
The flowchart of my code is that,
### to invode getDemandbody to get what i want
def getDandBody():
# input a box
vboxMin = (2.1,0.1,0.72)
vboxMax = (2.9,0.9,0.98)
vPorosity = utils.voxelPorosity(resolution=400, start=vboxMin, end=vboxMax)
# use the box the select the spheres and erase outside spheres
for eb in O.bodies:
if not isinstance(eb.shape, Sphere):
continue
if not (vboxMin[0]<= eb.state.pos[0]<= vboxMax[0] and vboxMin[1]<= eb.state.pos[1] <= vboxMax[1] and vboxMin[2] <=
eb.state.pos[2] <= vboxMax[2]):
O.bodies.erase(eb.id)
# output the information
with open('rel.txt', 'w') as fd:
fd.write('%e %e\n' % (sthrd, lthrd))
fd.write('%.4f, %d, %d, %.2f\n' % (1-vPorosity, snum, inum, inum*1.0/snum))
O.pause()
#define the new thread to load saved file
def newThread():
if O.time > 3.6:
import thread
thread.start_new_thread(newRun,())
def newRun():
O.pause();O.wait()
### import saved state
O.load('./svdir/t3-3.5')
### new engines and new run
### the function of getDemandBody is what i need to run to get sphere information
O.engines = [
PyRunner(iterPeriod=1,command='getDemandBody()'),
]
O.run(1)
### the save file function
def svfun():
some expressions
#define engines:
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
InteractionLoop(
# handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Facet_Sphere_ScGeom6D()],
[Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
[Law2_ScGeom6D_CohFrictPhys_CohesionMoment()]
),
PyRunner(iterPeriod=100,command='svfun()'),
PyRunner(iterPeriod=100,command='newThread()'),
NewtonIntegrator(damping=0.75, exactAsphericalRot=True, gravity=(0,0,-9810*gcof)),
]
O.run()
### script finished #####
I have two problems,
1. when i use the normal mode, like the command, yade myscript.py, it works. I can get the information of the selected spheres. But i want to ask, using a new thread is a must? In fact, i don't want to load saved file, just the current state is also ok.
2. when i use the yade-batch mode, it doesn't work. There is no output file. So i doubt there is a problem when create a new thread in batch mode.
So any suggestions?
Thanks,
Xuesong
--
You received this question notification because your team yade-users is
an answer contact for Yade.