Is it possible to add hue to each radii sphere radius? Also, after simulation is my calculation wrong?
import random
import math
from yade import geom, pack, utils
from yade import export
import numpy as np
# Define cylinder parameters
center = (0, 0, 0)
radius = 0.08
height = 0.10
# create cylindrical body with radius 0.08 m and height 0.0605 m
cylinder = yade.geom.
O.bodies.
# Define sphere parameters and percentages
radii = [0.000075, 0.0006, 0.00236, 0.00475, 0.0095, 0.0125]
percentages = [0.04, 0.06, 0.05, 0.35, 0.2, 0.3]
# Generate sphere pack
sp = pack.SpherePack()
for r, ratio in zip(radii, percentages):
num_spheres = int(ratio * 1000)
sp.makeCloud
# add the sphere pack to the simulation
sp.toSimulation()
# Define gravity engine
O.engines = [ ForceResetter(), InsertionSortCo
Interaction
),
GlobalStiff
NewtonInteg
]
# Define simulation duration and time step
O.dt = 1e-5
O.run(1000)
# Count the number of spheres in the cylinder
num_spheres_
for body in O.bodies:
if body.id == 0: # skip the cylinder
continue
sphere_center = body.state.pos
dist_to_axis = math.sqrt(
if dist_to_axis <= radius and sphere_center[2] >= center[2] and sphere_center[2] <= center[2] + height:
# Calculate volume of spheres in cylinder
volume_
for body in O.bodies:
if body.id == 0: # skip the cylinder
continue
sphere_center = body.state.pos
dist_to_axis = math.sqrt(
if dist_to_axis <= radius and sphere_center[2] >= center[2] and sphere_center[2] <= center[2] + height:
if isinstance(
# Calculate volume of cylinder
volume_of_cylinder = (math.pi * radius**2) * height
# Calculate porosity
porosity = (volume_of_cylinder - volume_
porosity_percent = porosity * 100
# Print results
print("Number of spheres in cylinder:", num_spheres_
print("Volume of spheres in cylinder:", volume_
print("Volume of cylinder:", volume_of_cylinder)
print("Porosity:", porosity)
print("Porosity:", porosity_percent, "%")
I have two question
1. Is it possible to add color to each radii sphere radius?
2. After simulation, the sphere seems to pack well in the container, but my porosity after calculation if above 80+%
did I have mistake in my calculation process?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Stránský
- Solved:
- Last query:
- Last reply: