after loading simulation

Asked by hafsa on 2019-02-15

hi ,
i saved simulation of falling cylinder by spheres in script ( initial.py) and now i load it ( O.load('init_config.yade.gz')) in second script(simul.py) , the problem now is i can't add oscillation and change iterations to the simulation .

there's my code :

from yade import plot

O.load('init_config.yade.gz')

# interactions and oscillation
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
    InteractionLoop(

        [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    NewtonIntegrator(gravity=(0,0,-9.81),damping=0.3),
    HarmonicMotionEngine(A=[0,0,0.5], f=[0,0,1.0], fi = [0.0,0.0,0.0],ids =Cylinder)
 ]
O.dt=utils.PWaveTimeStep()
O.run(17200)

the msg Error is:

  ngines=O.engines+[HarmonicMotionEngine(A=[0,0,1.], f=[0,0,2.6], fi = [0.0,0.0,0.0],ids =Cylinder)] #+PyRunner(iterPeriod=100,command='plotAddData()')# + SnapshotEngine(iterPeriod=1000,fileBase='fallingcylinder_',label='snapshooter')
TypeError: No registered converter was able to produce a C++ rvalue of type std::vector<int, std::allocator<int> > from this Python object of type Boost.Python.class

and the iteration in this part begin 12 000 and finish at 12 200 ( this iteration i used it in initial.py) .

thanks in advance .
thanks in

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-02-18
Last query:
2019-02-18
Last reply:
2019-02-18
Jan Stránský (honzik) said : #1

Hello,

> i can't ... change iterations to the simulation

you mean O.iter? it is read-only variable.. [1]

> TypeError: No registered converter ...

it seems that the error comes from the code, which is not shown. Please provide the complete code you are using such that we can reproduce your problem.

Just guessing, ids=Cylinder is the problematic part. Cylinder is a Yade class, but HarmonicMotionEngine expect ids to be a list of body IDs.

cheers
Jan

[1] https://gitlab.com/yade-dev/trunk/blob/master/core/Scene.hpp#L78

hafsa (sebbah.hafsa) said : #2

hi Jan ,
the fist code is :
#material of spheres
Mat2 = O.materials.append(CohFrictMat(poisson=4.,young=2.4e6,frictionAngle=radians(30),density=25.0))

#material of cylinder
Mat1 = O.materials.append(ViscElMat(kn=10.0e4,ks=10.0e4,frictionAngle=0.455,density=2650.0))

# create the big sphere
big_sphr=O.bodies.append(utils.sphere((0,0,16),4.,fixed=False,color=(1,0,0),highlight=True,material=Mat2))

# create sphere packing
sp=pack.SpherePack()
sp.makeCloud((-7.2,-7.2,18.),(7.2,7.2,82.9),rMean=.5,rRelFuzz=0,num=6000,seed=1)
sp.toSimulation(color=(0,1,0),material=Mat2)

# create Cylinder
Cylinder=O.bodies.append(geom.facetCylinder((0,0,30.),10.0,height=60.0,wallMask=6,segmentsNumber=64,material=Mat1))

# interactions
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
    InteractionLoop(

        [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    NewtonIntegrator(gravity=(0,0,-9.81),damping=0.3),
 ]
O.dt=utils.PWaveTimeStep()
O.run(11200)
O.save('init_config.yade.gz')

the second code is :

O.load('init_config.yade.gz')

# interactions and oscillation
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
    InteractionLoop(

        [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    NewtonIntegrator(gravity=(0,0,-9.81),damping=0.3),
    HarmonicMotionEngine(A=[0,0,0.5], f=[0,0,1.0], fi = [0.0,0.0,0.0],ids =Cylinder)
 ]
O.dt=utils.PWaveTimeStep()
O.run(17200)

the problem is that the simulation in the second code stop at 11200 iteration and i can't add harmonic motion
thanks in advance.

Jan Stránský (honzik) said : #3

Hello,

> O.run(11200)
> O.save('init_config.yade.gz')

I would suggest O.run(11200,True), otherwise O.save saves immediately. Maybe it is also related to the problem of running 11200 iterations in the second script..

> i can't add harmonic motion

see my previous comment, there is no Cylinder defined in the second script. You can try
print Cylinder # will print something like yade.wrapper.Cylinder

Do you really need two scripts?
Would saving the packing instead of O.save be sufficient?

cheers
Jan

hafsa (sebbah.hafsa) said : #4

hi Jan ,
yes i need two script , my work is based on adding interactions and oscillations to system after relaxation so i have many tests to do and i don't want to lose time in every test for relaxation .
when you said saving the packing it's mean saving positions and radius of particles in file ?

Jan Stránský (honzik) said : #5

> when you said saving the packing it's mean saving positions and radius of particles in file ?

yes

hafsa (sebbah.hafsa) said : #6

and how could i append harmonic motion ?

Best Jan Stránský (honzik) said : #7

For saving the packing (both O.save and saving just the packing), you have to use O.run(...,True) or O.run(...); O.wait(), otherwise Yade saves the state right away (i.e. saving initial makeCloud).

To solve your problem, there are several options:

- just correct the ids of HarmonicMotionEngine (as Cylinder is not defined in the second script), e.g.
HarmonicMotionEngine(...,ids=[b.id for b inO.bodies if isinstance(b.shape,Facet)],...) # just extract ids of facets

- define HarmonicMotionEngine in the first script, set dead=True and in the second script set dead=False

- use one script (anyway preferable solution) with a condition for creating the packing:
###
some content of script 1
if os.path.exists(packingFile):
   content of script 1 concerning creating the packing
content of script 2
###
........

cheers
Jan

hafsa (sebbah.hafsa) said : #8

Thanks Jan Stránský, that solved my question.