← Back to team overview

yade-users team mailing list archive

Re: [Question #176993]: launch several simulations within one script

 

Question #176993 on Yade changed:
https://answers.launchpad.net/yade/+question/176993

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Ning,

I was looking on the Omega class, and it should be no problem to modify
it to contain several scenes and the possibility to switch arbitrarily
between them, I try and test it and inform you about the progress :-)

Jan


ceguo píše v Po 06. 02. 2012 v 09:30 +0000:
> Question #176993 on Yade changed:
> https://answers.launchpad.net/yade/+question/176993
> 
>     Status: Answered => Open
> 
> ceguo is still having a problem:
> Hi,
> 
> I still need an answer in this question. I've wrapped a class for
> simulation as below:
> 
> 
> import `everything`
> 
> class simDEM(object):
>    def __init__(self,sd=1):
>       self.__id='thread'+str(sd)
>       self.__O=Omega()
>       self.__O.materials.append(FrictMat(young=1.e8,poisson=.3,frictionAngle=.5,density=1000))
>       self.__sp=pack.SpherePack()
>       self.__sp.makeCloud(minCorner=(0,0,0),maxCorner=(3,3,0),rMean=.03,rRelFuzz=.25,periodic=True,seed=sd)
>       self.__sp.toSimulation()
>       self.__O.cell.hSize=Matrix3(3,0,0, 0,3,0, 0,0,1)
>       for p in self.__O.bodies:
>          p.state.blockedDOFs='zXY'
>       self.__O.dt=.5*utils.PWaveTimeStep()
>       
>    def countParticle(self):
>       return len(self.__O.bodies)
>       
>    def getThreadID(self):
>       return self.__id
>       
>    def consolidate(self, stress=(-5.e4,-5.e4,0,0,0,0)):
>       self.__O.engines=[
>          ForceResetter(),
>          InsertionSortCollider([Bo1_Sphere_Aabb()]),
>          InteractionLoop(
>             [Ig2_Sphere_Sphere_Dem3DofGeom()],
>             [Ip2_FrictMat_FrictMat_FrictPhys()],
>             [Law2_Dem3DofGeom_FrictPhys_CundallStrack()]
>          ),
>          Peri3dController(
>             goal=stress,
>             stressMask=3,
>             nSteps=20000,
>             maxStrain=.5,
>             label='cons'
>          ),
>          NewtonIntegrator()
>       ]
>       self.__O.run()
>       self.__O.wait()
>    
>    def shear(self, strain=(1.e-2,-1.e-2,0,0,0,0)):
>       import __builtin__
>       __builtin__.__dict__['saveAddData']=self.saveAddData
>       self.__O.engines=[
>          ForceResetter(),
>          InsertionSortCollider([Bo1_Sphere_Aabb()]),
>          InteractionLoop(
>             [Ig2_Sphere_Sphere_Dem3DofGeom()],
>             [Ip2_FrictMat_FrictMat_FrictPhys()],
>             [Law2_Dem3DofGeom_FrictPhys_CundallStrack()]
>          ),
>          Peri3dController(
>             goal=strain,
>             stressMask=0,
>             nSteps=10000,
>             maxStrain=.5,
>             label='biax'
>          ),
>          NewtonIntegrator(),
>          PyRunner(command='saveAddData()',iterPeriod=100)
>       ]     
>       self.__O.run()
>       self.__O.wait()
> 
>    def getStress(self):
>       return biax.stress
>         
>    def finalization(self):
>       self.__O.exitNoBacktrace()
> 
> I want to run 2 simulations (more than 2 in real case, maybe tens)
> within one script like this:
> 
> a = simDEM(sd=1)
> b = simDEM(sd=2)
> a.anyfunc()
> b.anyfunc()
> 
> I expected a and b are separate simulations while they are not due to
> global defined Omega. How can I run several simulations simultaneously?
> Vaclav suggested using switchscene(), while it works for 2 scenes as I
> see it, but I need more than that. How to modify yade to expand its
> capacity in containing more scenes? Or is there a way to import yade
> locally to get a local Omega?
>

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.