yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #07988
Re: [Question #230139]: clumps generating randomly in 2D simulation
Question #230139 on Yade changed:
https://answers.launchpad.net/yade/+question/230139
Status: Answered => Open
Fu zuoguang is still having a problem:
Dear Jan Stránský:
I am sorry for forgetting to describe these very important detials with a intact script, which can be shown at the end of this conmmunication. There are 2 types of bodies in my simulatiion, one is the wall and the other is of course the clumps. In my own script you can obviously see only 2 functions for Bodies defination. Seeking for you help!
#######################################################################################
from yade import pack,os,utils
import random
from numpy import arange
Mat = O.materials.append(FrictMat(poisson=0.5,density=1500,young=1e7,frictionAngle=0.5))
clumpsmat = O.materials[Mat]
wallmat = O.materials.append(FrictMat(poisson=0.5,density=1500,young=1e7,frictionAngle=0))
def Parameters(): # input some basic parameters for clumps generation
global sphnums,radius,clunums,callenY
clunums = (input( "Enter the number of clumps: " ) )
sphnums = (input( "Enter the number of spheres employed for generating only one clump: " ) )
radius = (input( "Enter the radius of master particle: " ) )
callenY = (input( "Enter the ratio of box-lengthY/lengthX: " ) )
global ratios,radii,overlaps,distances,unitcellrads
ratios = []; radii = []; overlaps = []; distances = []; unitcellrads=[]
for i in xrange(sphnums-1):
Enti01 = 'Enter the radius-ratio of number {0} slave sphere of clump: '.format(i+2)
rat = input (Enti01)
ratios.append(rat)
for i in xrange(sphnums-1):
Enti02 = 'Enter the overlap of number {0} slave sphere with the master: '.format(i+2)
ola = input (Enti02)
overlaps.append(ola)
unitcellrads.append( radius )
for i in xrange(sphnums-1):
radii.append( radius * rat)
Priti01 = 'the radius of number {0} slave sphere: '.format(i+2)
# print Priti01, radii[i]
unitcellrads.append( radii[i] )
for i in xrange(sphnums-1):
distances.append( (1+rat)*(1-ola)*radius )
Priti02 = 'distance of number {0} slave sphere with the master: '.format(i+2)
# print Priti02, distances[i]
global NX,rx,lengX,lengY,NY
NX = int ( pow ( 0.55*clunums, 0.5 ) ) + 1
rx = 1.1 * (2 * distances[0] + 2 * radii[0])
lengX = NX * rx
lengY = lengX * callenY
NY = int( lengY / rx ) - 1
def Coor(): # determine the coordinations of each point for generating
global mastcoorinp,mastcoordes,slavecoordes,coordes
mastcoorinp = []; mastcoordes = []
slavecoordes = []; coordes = []
for i in xrange(clunums):
coorX = lengX / NX * random.randint( 0, NX )
coorY = lengY / NY * random.randint( 0, NY )
mastcoorinp.append( [coorX, coorY, 0] )
if not mastcoorinp[i] in mastcoordes:
mastcoordes.append (mastcoorinp[i])
for i in xrange( len(mastcoordes) ):
slacoor = []
for j in xrange( len(radii) ):
ramx = (-1)**random.randint(0,1)
ramy = (-1)**random.randint(0,1)
sina = ramy*random.random()
cosa = ramx*pow( (1-sina*sina), 0.5 )
slavecoorX = mastcoordes[i][0] + distances[j] * cosa
slavecoorY = mastcoordes[i][1] + distances[j] * sina
sphcoor = []
sphcoor = ( [slavecoorX, slavecoorY, 0] )
slacoor.append(sphcoor)
slavecoordes.append(slacoor)
for i in xrange( len(mastcoordes) ):
clucoor = []
clucoor.append(mastcoordes[i])
for j in xrange( len(slavecoordes[i]) ):
clucoor.append(slavecoordes[i][j])
coordes.append(clucoor)
# print coordes
def spheres(): # define unitcell for clumps
global spherespara,sphereslist,spheres_con
spherespara = []; sphereslist = [];spheres_con = []
for i in xrange( len(mastcoordes) ):
cluparas = []
for j in xrange( len(unitcellrads) ):
clupara = []
clupara.append([coordes[i][j],unitcellrads[j]])
cluparas.append(clupara)
spherespara.append(cluparas)
for i in xrange( len(spherespara) ):
spheres_con = []
for j in xrange( len(spherespara[i]) ):
spherepar = []
spheres = []
if j == 0 :
spherepar = sphere (spherespara[i][j][0][0], radius=spherespara[i][j][0][1], color = [1,1,1])
spheres = O.bodies.append(spherepar)
else :
spherepar = sphere (spherespara[i][j][0][0], radius=spherespara[i][j][0][1], color = [1,0,0])
spheres = O.bodies.append(spherepar)
spheres_con.append(spheres)
sphereslist.append(spheres_con)
def clumps():
for b in sphereslist:
O.bodies.clump (b)
def material():
for b in O.bodies:
if b.isClump:
O.bodies.material = clumpsmat
def DOF(): # of course, DOF condition only for 2D simulation
for b in O.bodies:
if b.isClump:
b.state.blockedDOFs = 'zXY'
def walls():
lwall = 0 - (max(distances)+radius);
rwall = lengX + (max(distances)+radius);
bwall = 0 - (max(distances)+radius);
twall = lengY + (max(distances)+radius);
mn,mx=Vector3(lwall,bwall,-0.05),Vector3(rwall,twall,0.05)
wallids=O.bodies.append(utils.aabbWalls([mn,mx],thickness=.00001,material=wallmat))
def dynamiccontrol():
a = len( mastcoorinp ); b = len( mastcoordes )
print ( 'There are {0} clumps desired'.format(a) )
print ('But only {} clumps generated'.format(b) )
# control flows
Parameters()
Coor()
walls()
spheres()
clumps()
material()
DOF()
dynamiccontrol()
#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,-10,0]) #gravity in y-direction
]
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.