Dynamic Compaction Can't Repeat
Hi,
I'm trying to create a simulation that would have large spherical ball drop and hit the clump plate repeatedly 100 times. and calculate the average z and mass every time. Also, use export.text to get position of the packing every 10th time. However, the calculation would calculated every time the large ball drop instead of calculating in after it hit the plate.
-------
import random
import math
from yade import geom, pack, utils, plot, ymport, export
import numpy as np
# Define cylinder parameters
diameter = 0.102
height = 0.18
center = (0, 0, height/2)
# create cylindrical body with radius 0.102 m and height 0.064 m
cylinder = geom.facetCylin
# add cylinder to simulation
O.bodies.
# add sphere packing
O.bodies.
# materials Properties
gravel = CohFrictMat(young = 1e7, poisson = 0.25, density = 2700, label = 'gravel')
asphalt_binder = CohFrictMat(young = 1e7, poisson = 0.25, density = 1060, frictionAngle = radians(40), normalCohesion = 5e4, shearCohesion = 5e4, label = 'asphalt_binder')
weight = CohFrictMat(young = 1e7, poisson = 0.25, density = 11450,frictionAngle = radians(0), label = 'weight')
# add properties
O.materials.
O.materials.
O.materials.
# give color and properties to shpere
for body in O.bodies:
if not isinstance(
continue
if body.shape.radius == 0.01575/2 :
if body.shape.radius == 0.011/2:
if body.shape.radius == 0.007125/2:
if body.shape.radius == 0.003555/2:
if body.shape.radius == 0.00160/2 :
if body.shape.radius == 0.0008/2 :
# add clump plate
clump_bodies = ymport.
# plate properties
clump_plate = CohFrictMat(density = 7500, label = 'clump_plate')
# add properties
O.materials.
# define layer
total_clump_bodies = len(clump_bodies)
bodies_per_layer = total_clump_bodies / 8
for i, clump_body in enumerate(
layer_number = i // bodies_per_layer # Calculate the layer number for the clump body
if layer_number % 2 == 0:
color = (1, 0, 0) # red for even-numbered layers
else:
color = (1, 1, 1) # white for odd-numbered layers
clump_
clump_
O.bodies.
# z-coordinate for clump
clump_z = np.mean(
# create large ball
O.bodies.
# give color and properties to shpere
for body in O.bodies:
if not isinstance(
continue
if body.shape.radius == 0.10/2 :
# define original condition
x = 0
y = 0
window = 0.01575/2
def calculate_zmax(x, y, window):
zmax = float('-inf') # Initialize zmax to negative infinity
# Define the square region
x_min = x - window
x_max = x + window
y_min = y - window
y_max = y + window
# Iterate over all bodies in the simulation
for body in O.bodies:
if isinstance(
# Check if the sphere is within the square region
if x_min <= sphere_x <= x_max and y_min <= sphere_y <= y_max:
z = sphere_z + sphere_radius # Calculate the z-coordinate of the top of the sphere
# Update zmax if the current z-coordinate is higher
if z > zmax:
return zmax
def hundredblows():
# Perform 100 blows of the large ball
for blow_number in range(100):
# Perform the blow
O.run() # Adjust the number of iterations as needed
# Calculate clump_z
clump_z = np.mean(
# Remove spheres above clump_z
to_remove = [] # List to store the bodies to be removed
for body in O.bodies:
if isinstance(
if body.state.pos[2] > clump_z:
for body in to_remove:
# Calculate and print the average z-coordinate
zmax_values = [] # List to store the zmax values
for point in random_points:
x, y = point
zmax = calculate_zmax(x, y, window)
# Calculate total mass excluding clump
total_mass = 0.0
for clump in clump_bodies:
if isinstance(
for body in O.bodies:
if isinstance(
# Export positions to a text file
if (blow_number + 1) % 10 == 0:
O.engines = [
# handle sphere+sphere and facet+sphere collisions
),
# call the checkUnbalanced function (defined below) every 600 seconds
]
O.dt = PWaveTimeStep()
def checkUnbalanced():
if unbalancedForce() < .1:
O.pause()
# Call hundredblows() function
hundredblows()
# Run the simulation
O.run()
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Huan
- Solved:
- Last query:
- Last reply: