Question #705744 on Yade changed:
https://answers.launchpad.net/yade/+question/705744
Status: Open => Answered
Jan Stránský proposed the following answer:
> I need please help regarding this matter by guides or links or
documentations.
I don't think you will find this specific problem as is in the documentation or
there is an existing script.
You can however build your script from "building blocks" found in the
documentation.
As a start, below is a 2D example.
Please let us know if this is in principle what you are looking for.
Cheers
Jan
###
import random
tileSize = (2, 3)
tiling = (7, 6)
# dummy sample
########################################
colors = {
0.5: (0,1,1),
0.2: (1,0,0),
}
tileParticles = (
((0.0, 0.0), 0.5),
((1.0, 0.4), 0.5),
((0.5, 1.3), 0.5),
((1.5, 1.6), 0.5),
((0.9, 2.4), 0.5),
((0.3, 0.7), 0.2),
((1.7, 0.6), 0.2),
((1.8, 1.0), 0.2),
((1.6, 2.4), 0.2),
((0.1, 2.4), 0.2),
((0.0, 2.0), 0.2),
)
for ix in range(tiling[0]):
x0 = ix * tileSize[0]
for iy in range(tiling[1]):
y0 = iy * tileSize[1]
for center, radius in tileParticles:
x = x0 + center[0]
y = y0 + center[1]
O.bodies.append(sphere((x,y,0), radius, color=colors[radius]))
########################################
def isInTile(tile,xy):
x, y = xy
sizeX, sizeY = tileSize
x0 = tile[0] * sizeX
y0 = tile[1] * sizeY
x1 = x0 + sizeX
y1 = y0 + sizeY
return x >= x0 and x < x1 and y >= y0 and y < y1
def eliminate():
nTiles = tiling[0] * tiling[1]
tiles = set()
while len(tiles) < 0.5 * nTiles:
x = random.randint(0,tiling[0]-1)
y = random.randint(0,tiling[1]-1)
tiles.add((x,y))
for b in O.bodies:
if b.shape.radius > 0.4: # do nothing for "large" particles
continue
x,y,z = b.state.pos
if any(isInTile(tile,(x,y)) for tile in tiles): # small particles in
selected tiles
O.bodies.erase(b.id)
# see with or without eliminating
#eliminate()
#yade.qt.View()
###
--
You received this question notification because your team yade-users is
an answer contact for Yade.
_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp