Update interaction and material parameters during the simlulation process

Asked by Henry

Hi all,
   I want to change the interaciton and material parameters during the simulation process through the following functions. However, the analysis results before and after the changes of the parameters.

Here is the function:

O.materials.append(CohFrictMat(young=1e8,poisson=0.2,density=den,frictionAngle=20,normalCohesion=1e3,shearCohesion=1e3,isCohesive=True,momentRotationLaw=True,etaRoll=0.1))

def Par_Change():
        Fos=2.0
        Fri_Fos=math.atan(math.tan(Frict_0)/Fos)
         # here we modify the material and interaction physics
        for b in O.bodies:
                b.mat.frictionAngle=Fri_Fos
                b.mat.normalCohesion=Coh_0/Fos
                b.mat.shearCohesion=Coh_0/Fos
        for i in O.interactions:
                i.phys.normalCohesion=Coh_0/Fos
                i.phys.shearCohesion=Coh_0/Fos
                i.phys.frictionAngle=Fri_Fos

Anyone can help me? Thanks a lot.
Henry

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Henry
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hi Henry,

> I want to change the interaciton and material parameters during the
> simulation process through the following functions. However, the analysis
> results before and after the changes of the parameters.
>

I miss something in the last sentence.. perhaps "... the analysis results
do not differ before and after"?

please also provide complete minimal working example. Do you call
Par_Change somewhere? I tried it, resulting in
AttributeError: 'FrictPhys' object has no attribute 'frictionAngle'

cheers
Jan

Revision history for this message
Jan Stránský (honzik) said :
#2

Sorry, the error is of course because I have wrong IPhys functor.. So do
not pay any attantion to my last comment, but the working script would be
useful :-)
cheers
Jan

2014-03-10 15:39 GMT+01:00 Jan Stránský <email address hidden>:

> Hi Henry,
>
>
>
>> I want to change the interaciton and material parameters during the
>> simulation process through the following functions. However, the analysis
>> results before and after the changes of the parameters.
>>
>
> I miss something in the last sentence.. perhaps "... the analysis results
> do not differ before and after"?
>
> please also provide complete minimal working example. Do you call
> Par_Change somewhere? I tried it, resulting in
> AttributeError: 'FrictPhys' object has no attribute 'frictionAngle'
>
> cheers
> Jan
>

Revision history for this message
Henry (wenjiexu) said :
#3

Thanks to Jan.
 Follows is a part of my script. I want to change the material paramteres during the simulation. But I found there is no change whether use the function of 'Par_Change() or not .

The script:

SoilMat=O.materials.append(CohFrictMat(young=Young_Soil,poisson=0.2,density=den,frictionAngle=Frict_0,normalCohesion=Coh_0,shearCohesion=0.1*Coh_0,isCohesive=True,momentRotationLaw=True,etaRoll=0.1,label='soil'))

#def sphereMat(): return JCFpmMat(type=1,young=5.0e11,frictionAngle=Frict_0,density=3000) ## Rq: density needs to be adapted as porosity of real rock is different to granular assembly due to difference in porosity (utils.sumForces(baseBodies,(0,1,0))/(Z*X) should be equal to Gamma*g*h with h=Y, g=9.82 and Gamma=2700 kg/m3
O.bodies.append(ymport.text(packing+'.spheres',scale=1.0,shift=Vector3(0,0,0),material=SoilMat))

O.engines=[

 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=interactionRadius,label='is2aabb'),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom6D(interactionDetectionFactor=interactionRadius,label='ss2d3dg'),Ig2_Box_Sphere_ScGeom6D()],#Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,label='ss2d3dg'),Ig2_Box_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys(),
        Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(label='cohesiveIp')],#setCohesionNow=False,setCohesionOnNewContacts=False,
        [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(
   useIncrementalForm=True, #useIncrementalForm is turned on as we want plasticity on the contact moments
   always_use_moment_law=True, #if we want "rolling" friction even if the contact is not cohesive (or cohesion is broken), we will have to turn this true somewhere
   label='cohesiveLaw')]
 ),
 GlobalStiffnessTimeStepper(timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8,defaultDt=O.dt),
    PyRunner(iterPeriod=1000,initRun=True,command='Par_Change()'),
 NewtonIntegrator(damping=0.5,gravity=(0.,-9.82,0.),label='Grav'),

]

def Par_Change():
    global Fos_Step,Coh_0,Frict_0
    global Fos,D_step
    if O.iter>Fos_Step:# and utils.unbalancedForce()<0.1:
        Fos=Fos+0.05
        Fos_Step=D_step+O.iter
        Fri_Fos=math.atan(math.tan(Frict_0)/Fos)
         # here we modify the material and interaction physics
        for b in O.bodies:
            if b.material.id==0:
                b.mat.frictionAngle=Fri_Fos
                b.mat.normalCohesion=Coh_0/Fos
                b.mat.shearCohesion=0.1*Coh_0/Fos
        for i in O.interactions:
            if O.bodies[i.id1].material.id==1 or O.bodies[i.id2].material.id==1:
                i.phys.normalCohesion=0.0
                i.phys.shearCohesion=0.0
                i.phys.frictionAngle=0.0
            else:
                i.phys.normalCohesion=Coh_0/Fos
                i.phys.shearCohesion=0.1*Coh_0/Fos
                i.phys.frictionAngle=Fri_Fos

Thanks a lot!
Henry

Revision history for this message
Jan Stránský (honzik) said :
#4

Hi Henry,

IPyhys of your interactions are of type CohFrictPhys, as defined in
O.engines. However, CohFrictPhys does not have any of the parameters you
try to assign (normalCohesion, shearCohesion, frictionAngle), see [1]. So
nothing is changed.

The change of material parameters will have effect only for newly created
interactions.

cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.CohFrictPhys

2014-03-10 16:06 GMT+01:00 Henry <email address hidden>:

> Question #245254 on Yade changed:
> https://answers.launchpad.net/yade/+question/245254
>
> Henry posted a new comment:
> Thanks to Jan.
> Follows is a part of my script. I want to change the material paramteres
> during the simulation. But I found there is no change whether use the
> function of 'Par_Change() or not .
>
> The script:
>
>
> SoilMat=O.materials.append(CohFrictMat(young=Young_Soil,poisson=0.2,density=den,frictionAngle=Frict_0,normalCohesion=Coh_0,shearCohesion=0.1*Coh_0,isCohesive=True,momentRotationLaw=True,etaRoll=0.1,label='soil'))
>
> #def sphereMat(): return
> JCFpmMat(type=1,young=5.0e11,frictionAngle=Frict_0,density=3000) ## Rq:
> density needs to be adapted as porosity of real rock is different to
> granular assembly due to difference in porosity
> (utils.sumForces(baseBodies,(0,1,0))/(Z*X) should be equal to Gamma*g*h
> with h=Y, g=9.82 and Gamma=2700 kg/m3
>
> O.bodies.append(ymport.text(packing+'.spheres',scale=1.0,shift=Vector3(0,0,0),material=SoilMat))
>
> O.engines=[
>
> ForceResetter(),
>
> InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=interactionRadius,label='is2aabb'),Bo1_Box_Aabb()]),
> InteractionLoop(
>
> [Ig2_Sphere_Sphere_ScGeom6D(interactionDetectionFactor=interactionRadius,label='ss2d3dg'),Ig2_Box_Sphere_ScGeom6D()],#Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,label='ss2d3dg'),Ig2_Box_Sphere_ScGeom()],
> [Ip2_FrictMat_FrictMat_FrictPhys(),
>
> Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(label='cohesiveIp')],#setCohesionNow=False,setCohesionOnNewContacts=False,
>
> [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(
> useIncrementalForm=True, #useIncrementalForm is
> turned on as we want plasticity on the contact moments
> always_use_moment_law=True, #if we want "rolling"
> friction even if the contact is not cohesive (or cohesion is broken), we
> will have to turn this true somewhere
> label='cohesiveLaw')]
> ),
>
> GlobalStiffnessTimeStepper(timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8,defaultDt=O.dt),
> PyRunner(iterPeriod=1000,initRun=True,command='Par_Change()'),
> NewtonIntegrator(damping=0.5,gravity=(0.,-9.82,0.),label='Grav'),
>
> ]
>
>
> def Par_Change():
> global Fos_Step,Coh_0,Frict_0
> global Fos,D_step
> if O.iter>Fos_Step:# and utils.unbalancedForce()<0.1:
> Fos=Fos+0.05
> Fos_Step=D_step+O.iter
> Fri_Fos=math.atan(math.tan(Frict_0)/Fos)
> # here we modify the material and interaction physics
> for b in O.bodies:
> if b.material.id==0:
> b.mat.frictionAngle=Fri_Fos
> b.mat.normalCohesion=Coh_0/Fos
> b.mat.shearCohesion=0.1*Coh_0/Fos
> for i in O.interactions:
> if O.bodies[i.id1].material.id==1 or O.bodies[i.id2].
> material.id==1:
> i.phys.normalCohesion=0.0
> i.phys.shearCohesion=0.0
> i.phys.frictionAngle=0.0
> else:
> i.phys.normalCohesion=Coh_0/Fos
> i.phys.shearCohesion=0.1*Coh_0/Fos
> i.phys.frictionAngle=Fri_Fos
>
> Thanks a lot!
> Henry
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Jérôme Duriez (jduriez) said :
#5

There might be several problems in your script. In what you showed us, you use JCFpmMat, but there is no Ip functor (the Ip2_... "engines") related to this material..

It seems to me that you use too many interaction functors (the Ip2.. and the Law2..), but never the right ones maybe... Try, if not already the case, to understand these names, it is really useful here ! (and possible !)

For ex Ip2_*FrictMat*_*FrictMat*_*FrictPhys* creates an interaction physics (gathering all the properties of the interaction) of type *FrictPhys*, because it is at the end of the name !

And, to do so, it needs that the materials of the two bodies in contact are both of *FrictMat* type. Because it appears twice in the middle of the name !

PS : if you see stars (* symbol) in my text, consider it as surrounding a bold word (to catch your attention !), not real symbols

Revision history for this message
Henry (wenjiexu) said :
#6

Dear Jan,
   How can I change the material parameters during the simulation?

 I tried the following script, but there is no change. :(

   for b in O.bodies:
             if b.material.id==0:
                 b.mat.frictionAngle=Fri_Fos
                 b.mat.normalCohesion=Coh_0/Fos
                 b.mat.shearCohesion=0.1*Coh_0/Fos

Thanks a lot!
Henry

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#7

Hi,

as already mentioned before a change of matrerial properties is affecting new interactions only. Therefore, you will see no change for existing interactions assuming all interactions in your script are created in the first 1000 steps.

A solution could be to loop over all interactions and change the interaction properties. But this would just be a hack (and very slow) because you have to re-implement some of the equations of the Ip2 functor in python and I am not sure if there is write access to all interaction parameters you need. But you can try something like:

for i in O.interactions:
 mat1=O.bodies[i.id1].mat.id
 mat2=O.bodies[i.id2].mat.id
 if ((mat1==0) or (mat2==0)):
  # change interaction physics here, have a look at doc for parameters and the code for the equation how they are calculated
  i.phys.kn=...
  i.phys.frictionAngle=...
  # etc

Not sure if there is a clean solution for your problem.

HTH
Klaus

Revision history for this message
Henry (wenjiexu) said :
#8

Thanks a lot.

Revision history for this message
Alexander Eulitz [Eugen] (kubeu) said :
#9

I asked a similar question some time ago [1] but I'm nor sure whether this will help you. In my case I had no problem with waiting some tousand iterations for settlement of the packing with changed material properties. If your application allows for this too it could a solution.

[1] https://answers.launchpad.net/yade/+question/238797

Revision history for this message
Jan Stránský (honzik) said :
#10

Hi Henry,

there are more possible approaches. It depends on purpose and what you
expect.

1) The approach you already mentioned (for loop oved all interactions), but
you have to change parameters which are defined on the specific IPhys
(CohFrictPhys [1] in your case, but you tried to change parameters that do
not exist). In some IPhys, as Klaus mentioned, not all parameters are
modifyable.

2) change material of all particles, but then you have to delete and
recreate all interactions, e.g.:

pairs = [(i.id1,i.id2) for i in O.interactions]
for b in O.bodies: b.mat = newMat
O.interactions.clear()
for id1,id2 in pairs: utils.createInteraction(id1,id2)

this will preserve also cohesive bonds, but delete all internal variables
of the bonds

cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.CohFrictPhys

2014-03-11 7:51 GMT+01:00 Henry <email address hidden>:

> Question #245254 on Yade changed:
> https://answers.launchpad.net/yade/+question/245254
>
> Status: Answered => Solved
>
> Henry confirmed that the question is solved:
> Thanks a lot.
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>