← Back to team overview

yade-users team mailing list archive

Re: [Question #660590]: Loading and manipulating a saving file

 

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

amir gave more information on the question:
I have prepared a simple example to clarify the problem.

https://drive.google.com/open?id=1Vkl5lb89BXlxzaj44N3kPDMfy_a8cQDr

In the first script (tst1.py), one sphere was created on the facet and
gravity force was applied on the sphere. The simulation was run for 100
iterations. The simulation was saved as tst1.yade.

The script of tst1.py :


from yade import pack, plot, geom, utils, qt
E1 = 1e7 #Young's modulus (Pa)
poisson1 = 0.3 # Poison ratio
frictionAngle = .5 #Friction angle
density1 = 2650 #sphere density kg/m3
densitywater = 1000 #water density
g = 9.81 #gravity m/s2
r=.5 #radius of sphere (m)

O.materials.append(FrictMat(young=E1,poisson=poisson1,frictionAngle=frictionAngle,density=density1, label='mat_spheres'))
O.bodies.append(utils.sphere([1,1,.5],r,color=[1,0,0], material='mat_spheres'))
O.bodies.append(utils.geom.facetBox((1,1,1),(1,1,1),wallMask=31))
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(gravity=(0,0,-9.81),damping=0.7),
PyRunner(command='func1()',iterPeriod=1,label='checker'),
PyRunner(command='func2()',iterPeriod=100)
]
O.dt=utils.PWaveTimeStep()
O.trackEnergy=True
O.resetTime()
w=(4.0/3.0*3.1416*r**3)*density1*g # weight of sphere
print 'w :', w
bodies2 = [b for b in O.bodies if isinstance(b.shape,Sphere) and b.shape.radius == r]
print 'number of particles2 :', len(bodies2)
for b in bodies2:
print 'b.id 1:', b.id
print 'positions :', b.state.pos[2]
def func1():
i=0
for b in bodies2:
print 'iter :', O.iter
print 'positions :', b.state.pos[2]
print 'velocity :', b.state.vel[2]
force=O.forces.f(b.id)
print 'force :', force
i=i+1
for i in O.interactions:
if not i.isReal: continue
fn = i.phys.normalForce
print 'normalForce :', fn
def func2():
O.pause()
O.save("tst1.yade")


The results for the first and last iteration are as follow:

Yade [1]: iter : 1
positions : 0.499452315993
velocity : -0.0433336376693
force : Vector3(0,0,2599.6499999999164)
normalForce : Vector3(0,0,1299.8249999999582)
normalForce : Vector3(0,0,1299.8249999999582)
iter : 2
positions : 0.499009231927
velocity : -0.0544368756667
force : Vector3(0,0,7302.453422629214)
normalForce : Vector3(0,0,3651.226711314607)
normalForce : Vector3(0,0,3651.226711314607)
iter : 3
positions : 0.498560396874
velocity : -0.0551434362456
force : Vector3(0,0,13210.240974566765)
normalForce : Vector3(0,0,6605.120487283382)
normalForce : Vector3(0,0,6605.120487283382)

.
.
.

iter : 100
positions : 0.498979119867
velocity : -1.60095920204e-10
force : Vector3(0,0,13611.735089527067)
normalForce : Vector3(0,0,6805.867544763533)
normalForce : Vector3(0,0,6805.867544763533)


The second script (tst2.py) load tst1.yade. Then, the sphere was removed
and reintroduced. The gravity force was applied on the sphere. The
simulation is done for 2 iterations.

The tst2.py script:

import re
from yade import pack, plot,ymport,export,geom,bodiesHandling,qt, utils
O.load('test.yade')

E1 = 1e7 #Young's modulus (Pa)
poisson1 = 0.3 # Poison ratio
frictionAngle = .5 #Friction angle
density1 = 0 #sphere density kg/m3
density2 = 2650
densitywater = 1000 #water density
g = 9.81 #gravity m/s2
r=.5 #radius of sphere (m)

sp=SpherePack(); sp.fromSimulation()
for b in O.bodies:
if isinstance (b.shape,Sphere): O.bodies.erase(b.id)
O.bodies.clear()
sp.toSimulation()
O.bodies.append(utils.geom.facetBox((1,1,1),(1,1,1),wallMask=31))

O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(gravity=(0,0,-9.81),damping=.7),
PyRunner(command='func1()',iterPeriod=1,label='checker'),
PyRunner(command='func2()',iterPeriod=2)
]
O.dt=utils.PWaveTimeStep()
O.trackEnergy=True
O.resetTime()
w=(4.0/3.0*3.1416*r**3)*density2*g # weight of sphere
print 'w :', w
bodies2 = [b for b in O.bodies if isinstance(b.shape,Sphere) and b.shape.radius == r]
print 'number of particles :', len(bodies2)
for b in bodies2:
print 'b.id 1:', b.id
print 'positions :', b.state.pos[2]
def func1():
i=0
for b in bodies2:
print 'iter :', O.iter
print 'positions :', b.state.pos[2]
print 'velocity :', b.state.vel[2]
print 'force :', O.forces.f(b.id)
i=i+1
for i in O.interactions:
if not i.isReal: continue
fn = i.phys.normalForce
print 'normalForce :', fn
def func2():
O.save("tst2.yade")
O.pause()


The results:

Yade [1]: iter : 1
positions : 0.499489566596
velocity : 0.0387587036878
force : Vector3(0,0,22024.170567462126) ???
normalForce : Vector3(0,0,5506.042641865532)
normalForce : Vector3(0,0,5506.042641865532)
normalForce : Vector3(0,0,5506.042641865532)
normalForce : Vector3(0,0,5506.042641865532)
iter : 2
positions : 0.49980502513
velocity : 0.0387569274068
force : Vector3(0,0,13611.55744917723)
normalForce : Vector3(0,0,3402.8893622943074)
normalForce : Vector3(0,0,3402.8893622943074)
normalForce : Vector3(0,0,3402.8893622943074)
normalForce : Vector3(0,0,3402.8893622943074)

My questions:

Why body force (Vector3(0,0,22024.170567462126) ) on the sphere in the
1st iteration is equal to 22024.170567462126 while it has to be equal to
13611.73.

I have also applied the velocity of sphere from the loaded file before
the 1st iteration, but it does not change anything.

I was wondering if you could help me to solve the problem.

Thanks a lot

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.