Reduce or remove rebound after contact
import random
import math
from yade import geom, pack, utils
import pandas as pd
# Define cylinder parameters
center = (0, 0, 0)
cyl_radius = 0.102
cyl_height = 0.064
# create cylindrical body with radius 0.102 m and height 0.064 m
cylinder = geom.facetCylin
# define material properties
mat = utils.Polyhedra
mat.density = 2600 # kg/m^3
mat.young = 1E6 # Pa
mat.poisson = 20000 / 1E6
mat.frictionAngle = 0.6 # rad
# assign material to each body in the cylinder
for body in cylinder:
body.bodyMat = mat
# add cylinder to simulation
O.bodies.
# Define box dimensions
box_dimensions = (0.1, 0.1, 0.1)
# Create box at origin
box = geom.facetBox(
# Define material properties for box
mat = O.materials.
# Assign material to each facet of box
for body in box:
body.bodyMat = mat
# Add box to simulation
O.bodies.
# define sphere parameters and number of spheres
radius = 0.01575
num = 6
radius1 = 0.01175
num1 = 7
radius2 = 0.011
num2 = 8
radius3 = 0.01025
num3 = 8
radius4 = 0.0083125
num4 = 31
radius5 = 0.007125
num5 = 31
radius6 = 0.0059375
num6 = 32
radius7 = 0.0041525
num7 = 25
radius8 = 0.003555
num8 = 26
radius9 = 0.0029575
num9 = 26
radius10 = 0.002065
num10 = 25
radius11 = 0.00177
num11 = 26
radius12 = 0.001475
num12 = 26
radius13 = 0.001035
num13 = 155
radius14 = 0.00089
num14 = 155
radius15 = 0.000745
num15 = 156
radius16 = 0.00045
num16 = 9735
## create empty sphere packing
sp = pack.SpherePack()
sp1 = pack.SpherePack()
sp2 = pack.SpherePack()
sp3 = pack.SpherePack()
sp4 = pack.SpherePack()
sp5 = pack.SpherePack()
sp6 = pack.SpherePack()
sp7 = pack.SpherePack()
sp8 = pack.SpherePack()
sp9 = pack.SpherePack()
sp10 = pack.SpherePack()
sp11 = pack.SpherePack()
sp12 = pack.SpherePack()
sp13 = pack.SpherePack()
sp14 = pack.SpherePack()
sp15 = pack.SpherePack()
sp16 = pack.SpherePack()
# generate randomly sphere
sp.makeCloud(
sp1.makeCloud(
sp2.makeCloud(
sp3.makeCloud(
sp4.makeCloud(
sp5.makeCloud(
sp6.makeCloud(
sp7.makeCloud(
sp8.makeCloud(
sp9.makeCloud(
sp10.makeCloud(
sp11.makeCloud(
sp12.makeCloud(
sp13.makeCloud(
sp14.makeCloud(
sp15.makeCloud(
sp16.makeCloud(
# add the sphere pack to the simulation
sp.toSimulation()
sp1.toSimulation()
sp2.toSimulation()
sp3.toSimulation()
sp4.toSimulation()
sp5.toSimulation()
sp6.toSimulation()
sp7.toSimulation()
sp8.toSimulation()
sp9.toSimulation()
sp10.toSimulation()
sp11.toSimulation()
sp12.toSimulation()
sp13.toSimulation()
sp14.toSimulation()
sp15.toSimulation()
sp16.toSimulation()
# add interaction of gravity of sphere and cylinder
O.engines = [ForceResetter(),
InsertionSortC
# handle sphere+sphere and facet+sphere collisions
),
]
O.dt = 0.1 * PWaveTimeStep()
# run the simulation for 1000 steps
O.run(1000, wait=True)
for body in O.bodies:
if not isinstance(
continue
if body.shape.radius == radius: #SP
if body.shape.radius == radius1: #SP1
if body.shape.radius == radius2: #SP2
if body.shape.radius == radius3: #SP3
if body.shape.radius == radius4: #SP4
if body.shape.radius == radius5: #SP5
if body.shape.radius == radius6: #SP6
if body.shape.radius == radius7: #SP7
if body.shape.radius == radius8: #SP8
if body.shape.radius == radius9: #SP9
if body.shape.radius == radius10: #SP10
if body.shape.radius == radius11: #SP11
if body.shape.radius == radius12: #SP12
if body.shape.radius == radius13: #SP13
if body.shape.radius == radius14: #SP14
if body.shape.radius == radius15: #SP15
if body.shape.radius == radius16: #SP16
# calculate the volume of the packing
volume_packing = 0
num_spheres = 0
for b in O.bodies:
if isinstance(b.shape, yade.wrapper.
num_spheres += 1
# calculate the volume of the cylinder
volume_cylinder = math.pi * cyl_radius**2 * cyl_height
# calculate the porosity and porosity percentage
porosity = (volume_cylinder - volume_packing) / volume_cylinder
porosity_percent = porosity * 100
print("Number of spheres:", "{:d}".
print("V Packing:", "{:e}".
print("V Cylinder:", "{:e}".
print("Porosity:", "{:.2f}
print("Porosity:", "{:.2f}
# print the number of spheres in each layer
print("Number of spheres in each layer:")
print(f"Layer 1: {len(sp)}")
print(f"Layer 2: {len(sp1)}")
print(f"Layer 3: {len(sp2)}")
print(f"Layer 4: {len(sp3)}")
print(f"Layer 5: {len(sp4)}")
print(f"Layer 6: {len(sp5)}")
print(f"Layer 7: {len(sp6)}")
print(f"Layer 8: {len(sp7)}")
print(f"Layer 9: {len(sp8)}")
print(f"Layer 10: {len(sp9)}")
print(f"Layer 11: {len(sp10)}")
print(f"Layer 12: {len(sp11)}")
print(f"Layer 13: {len(sp12)}")
print(f"Layer 14: {len(sp13)}")
print(f"Layer 15: {len(sp14)}")
print(f"Layer 16: {len(sp15)}")
print(f"Layer 17: {len(sp16)}")
# create a dictionary to store simulation data
data = {'Number of spheres': [num_spheres], 'V Packing': [volume_packing], 'V Cylinder': [volume_cylinder],
'Porosity': [porosity], 'Porosity %': [porosity_percent]}
# create a DataFrame from the data
df = pd.DataFrame(data)
# append the data to an existing file or create a new file if it doesn't exist
with open('simulatio
df.to_csv(file, header=file.tell() == 0, index=False)
1. Is it possible to only allows the particles to fall into the container without bouncing out after contact whether the contact might be against other spheres or the container?
In the simulation, I tried to generate a box and try to contain all the sphere into the cylinder, but it didn't work as I expected it to
Question information
- Language:
- English Edit question
- Status:
- Expired
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: