Reset Interactions

Asked by Othman Sh on 2019-03-19

Hello Everyone,

I'm trying to model a uniaxial compression of a concrete cylinder. First I create the cylinder as a cloud of spheres in a cylindrical facet and compress it to a certain porosity. Then I remove the facet and start the uniaxial compression. I'm using CPM material model. The problem is that after achieving the desired porosity, all the bonds between the spheres is already damaged. I want to reset the interactions and change material properties (i.e. young, friction angle..etc) before starting the uniaxial compression. I tried doing that using O.interactions.clear() but the spheres explode. Can anyone please help? My code is below.

Thank you,
Othman

PS: I tried doing the compaction to a certain porosity in a different code and export the compacted spheres as a txt file and then import it in another code for uniaxial compression but didn't work because porosity was reset to the original cloud porosity. If anyone know how to export then import without loosing the applied compaction, it will make life much easier. Thanks

-------------------------------------------------------
from yade import pack

targetp = .45 ##specify the targeted porosity

##specimen geometry
radiuscyl=.05
heightcyl=.203*3
SphereRadius = .0045
# material parameters
E=1e6 #initial young modulus is low so that compaction is faster
poiss=.15
eps=1e-4
strength=2e5

concrete=O.materials.append(CpmMat(young = E, poisson = poiss,frictionAngle = atan(.2), epsCrackOnset = eps, relDuctility = 30, sigmaT = strength))

################ spheres ################

sp=pack.SpherePack()
sp.makeCloud((0,0,0),(.3,.3,0.7),rMean=SphereRadius,rRelFuzz=.3,periodic=True,seed=1)
#### cylinder extraction
pred=pack.inCylinder((.2,.2,0),(.2,.2,heightcyl),radiuscyl)
spFilter=filterSpherePack(pred,sp,Material=concrete, returnSpherePack=True)
spFilter.toSimulation(color=(1,0.5,0.2))

################ facet ################

facets=geom.facetCylinder((.2,.2,heightcyl/2),radiuscyl,heightcyl,segmentsNumber=50,wallMask=4)

cylinder=O.bodies.append(facets)
yade.qt.View()

##creating disks

d1=geom.facetCylinder((.2,.2,heightcyl),radiuscyl-.001,0,segmentsNumber=50,wallMask=1)
d2=geom.facetCylinder((.2,.2,0),radiuscyl-.001,0,segmentsNumber=50,wallMask=1)

disk1IDs= O.bodies.append(d1)
disk2IDs= O.bodies.append(d2)

for i in disk1IDs:
 body= O.bodies[i]
 body.state.vel = (0,0,-0.15)

for n in disk2IDs:
 body= O.bodies[n]
 body.state.vel = (0,0,0.15)

################ Compaction ################
O.dt=.5*utils.PWaveTimeStep()
enlargeFactor=1.5
O.engines=[
 ForceResetter(),
 InsertionSortCollider([
  Bo1_Sphere_Aabb(aabbEnlargeFactor=enlargeFactor,label='bo1s'),
  Bo1_Facet_Aabb()
 ]),
 InteractionLoop(
  [
   Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=enlargeFactor,label='ss2d3dg'),
   Ig2_Facet_Sphere_ScGeom(),
  ],
  [

   Ip2_CpmMat_CpmMat_CpmPhys(),
   Ip2_CpmMat_CpmMat_CpmPhys(),
  ],
  [

   Law2_ScGeom_CpmPhys_Cpm(),
  ],
 ),

 NewtonIntegrator(damping=.3),
 CpmStateUpdater(realPeriod=.5),

 PyRunner(iterPeriod=500,command='stop()'),

]
O.step()
# reset interaction detection enlargement
bo1s.aabbEnlargeFactor=ss2d3dg.interactionDetectionFactor=1.0

O.run()

################ Uniaxial compression ################
def stop():
   if utils.porosity()<targetp:
 O.pause()
 print 'Finished'
 print ('porosity = ', utils.porosity())
 for i in cylinder: O.bodies.erase(i)
 print ('unbalanced forces = ', utils.unbalancedForce())
 utils.calm()
 O.interactions.clear()
 O.step()
 for i in O.interactions:
  i.phys.young=1e9 # update young modulus
 #start uniaxial compression
 for b in disk1IDs:
  body= O.bodies[b]
  body.state.vel = (0,0,-0.009)
 for n in disk2IDs:
  body= O.bodies[n]
  body.state.vel = (0,0,0.009)

 O.run()

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Othman Sh
Solved:
2019-03-19
Last query:
2019-03-19
Last reply:
2019-03-19
Jérôme Duriez (jduriez) said : #1

Hi,

Almost any property of a YADE simulation can be accessed and modified through python [*]

E.g.

for b in O.bodies:
  b.mat.young = newYoungValue # this will affect future interactions, not the existing ones.
  # similar stuff for other bodies properties

for i in O.interactions:
  i.phys.kn = newValue # according to CPM model and the newYoungValue. This is necessary because, as said in the above, existing interactions would not have their properties updated when the properties of interacting bodies are updated.
  # similar stuff for other interaction properties

Jérôme

[*] https://yade-dev.gitlab.io/trunk/tutorial-data-mining.html#local-data

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

Hello,

> I tried doing the compaction to a certain porosity in a different code and export the compacted spheres as a txt file and then import it in another code for uniaxial compression but didn't work because porosity was reset to the original cloud porosity.

this is nonsense, how would the other script know how to "reset" the positions? Probably you accidentally saved the original packing and not the compacted one.
For example, it could be that you called the saving before O.run(...) or after O.run(...) without True parameter (see below).
For better answer, we would need your code.

I do not agree with Jerome's answer (sorry :-). Apart from i.phys.kn, you also have to modify i.phys.E and other values (epsCrackOnset, epsFracture....), so you should have a (very) good knowledge of CPM code before doing these modifications. Furthermore, i,phys has some read-only values (like damage variable) which you cannot set from python..

back to your problem, in general you can do:
###
...
O.switchScene() # the creation in independent scene
O.materials.append(...)
O.bodies.append(...)
O.engines = [...]
O.run()
O.wait() # (!) important, without this, the python evaluation directly continues and stores/saves original packing
sp = pack.SpherePack()
sp.fromSimulation()

O.switchScene() # back to the original simulation, starting from beginning
# define materials and engines again, since this is completely new simulation than the one before
# You can also use different parameters etc...
O.materials.append(...)
sp.toSimulation()
O.engines = [...]
###

A two script solution would look similarly, but instead of sp.from/toSomulation, you would call some saving / loading.

cheers
Jan

Othman Sh (othman-sh) said : #3

Thank you Jérôme and Jan. That solved my problem

Jan, I used your method and it works!. Previously I wasn't using O.wait(), so probably that's why the original packing was saved and not the final packing.

Best,
Othman