yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #17279
Re: [Question #668727]: How to give each clump a new material and a new color?
Question #668727 on Yade changed:
https://answers.launchpad.net/yade/+question/668727
Status: Needs information => Open
Kalyan Khanal gave more information on the question:
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''This example shows usage of clumpTemplate(), replaceByClumps() and
getRoundness().'''
#define material for all bodies:
id_Mat=O.materials.append(FrictMat(young=1e7,poisson=0.3,density=1000,frictionAngle=1))
Mat=O.materials[id_Mat]
#define engines:
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(damping=0.7,gravity=[0,0,-10])
]
from yade import qt
qt.Controller()
qt.View()
#create a box:
id_box = O.bodies.append(box((0,0,0),(2,2,.1),fixed=True,material=Mat))
#create assembly of spheres:
sp=pack.SpherePack()
sp.makeCloud(minCorner=(-1.5,-1.5,.1),maxCorner=(1.5,1.5,2),rMean=.2,rRelFuzz=.5,num=100,periodic=False)
O.bodies.append([sphere(c,r,material=Mat) for c,r in sp])
print len(sp),' particles generated.'
print 'Roundness coefficient without clumps is: ',O.bodies.getRoundness()
#### show how to use makeClumpTemplate():
#dyad:
relRadList1 = [1,1]
relPosList1 = [[1,0,0],[-1,0,0]]
#peanut:
relRadList2 = [.5,1,.5]
relPosList2 = [[1,0,0],[0,0,0],[-1,0,0]]
#stick:
relRadList3 = [1,1,1,1,1]
relPosList3 = [[0,1,0],[0,2,0],[0,3,0],[0,4,0],[0,5,0]]
templates= []
templates.append(clumpTemplate(relRadii=relRadList1,relPositions=relPosList1))
templates.append(clumpTemplate(relRadii=relRadList2,relPositions=relPosList2))
templates.append(clumpTemplate(relRadii=relRadList3,relPositions=relPosList3))
#### show how to use replaceByClumps():
#replace by 50% dyads, 30% peanuts and 10% sticks:
O.bodies.replaceByClumps(templates,[.5,.3,.1])
#### show how to use getRoundness():
#create a list of all standalone spheres:
standaloneList = []
for b in O.bodies:
if b.isStandalone:
standaloneList.append(b.id)
print 'Roundness coefficient for spheres and clumps is: ',O.bodies.getRoundness()
print 'Roundness coefficient just for clumps is: ',O.bodies.getRoundness(standaloneList)
O.dt=1e-6
This is an example of replace by clumps in yade.
since there are three different clumps but same material, how can I
make each clump a different material.
I tried the following but does not work but does not work:
from yade import pack
l = 0.06
b = 0.02
h = 0.06
vol = l*b*h
mn,mx=Vector3(0,0,0),Vector3(l,b,h)
O.materials.append(CohFrictMat(young=2e8,poisson=0.3,frictionAngle=radians(30),density=2650,label='spheres'))
O.materials.append(CohFrictMat(young=1e9,poisson=0.3,frictionAngle=radians(30),density=1000,label='fibres'))
sp=pack.SpherePack()
sp.makeCloud(mn,mx,-1,0.3333,100,False, 0.95)
O.bodies.append([sphere(center,rad,material='spheres',color=(255,0,0)) for center,rad in sp])
#dyad:
relRadList1 = [1,1]
relPosList1 = [[1,0,0],[-1,0,0]]
#peanut:
relRadList2 = [.5,1,.5]
relPosList2 = [[1,0,0],[0,0,0],[-1,0,0]]
templates= []
templates.append(clumpTemplate(relRadii=relRadList1,relPositions=relPosList1))
templates.append(clumpTemplate(relRadii=relRadList2,relPositions=relPosList2))
O.bodies.replaceByClumps(templates,[0.31,.31])
sp.toSimulation()
#for fibres
fibresp=pack.SpherePack()
fibresp.makeCloud(mn,mx,-1,0.3333,10,False, 0.95)
O.bodies.append([sphere(center,rad,material='spheres',color=(255,0,0)) for center,rad in fibresp])
#stick:
relRadList3 = [1,1,1,1,1]
relPosList3 = [[0,1,0],[0,2,0],[0,3,0],[0,4,0],[0,5,0]]
templatesf= []
templates.append(clumpTemplate(relRadii=relRadList3,relPositions=relPosList3))
O.bodies.replaceByClumps(templates,[.1])
fibresp.toSimulation()
I get error for length and I cannot assign different materials. I want
to give dyad and peanut shape sphere material and stick with fibre
material and also want to change their colours respectively.
I don't know the coding very well so I think a small algorithm could fix
this, I am trying but I am lost it seems.
--
You received this question notification because your team yade-users is
an answer contact for Yade.