← Back to team overview

yade-users team mailing list archive

[Question #706864]: unable to export text

 

New question #706864 on Yade:
https://answers.launchpad.net/yade/+question/706864

Hello,
I'm try to to use the clump as wall to press on the sphere packing. After the clump press the packing I want to export the text of sphere position excluding the clump sphere, but it doesn't work. My question is that whether if it is correct to put the code under def checkunbalancedForce() and why do I get the error that said 
>>if body not in idClump:
(argument of type 'int' is not iterable)
-----------------------------------------------------------------My code------------------------------------------------------------------------------------------------------------
import random
import math
from yade import geom, pack, utils, plot, ymport, export
import numpy as np

# Define cylinder with funnel parameters
center = (0, 0, 0)
diameter = 0.102
height = 0.18

# create cylindrical body with radius 0.102 m and height 0.064 m
cylinder = geom.facetCylinder(center=center, radius=diameter/2, height=height, segmentsNumber=80, wallMask=6)

# add cylinder to simulation
O.bodies.append(cylinder)

# plate properties
clump_plate = CohFrictMat(density = 7500, label = 'clump_plate')

# add properties
O.materials.append(clump_plate)

# clumping parameters
bodyList = []
zi = 0.025 
radius_clump = 0.00221
clumpLimit = (diameter/2)  - 0.005
# layer and offset condition
num_layers = 8
z_offset_increment = 0.00128

# adjust the z-coordinate based on the layer
for layer in range(num_layers):
    z_offset = layer * z_offset_increment  
    # if layer is divisible by to move x and y axis by 2mm 
    if layer % 2 == 0:
        x_offset = 0.002
        y_offset = 0.002
        color = (1, 1, 1) # white
    else:
        x_offset = 0
        y_offset = 0
        color = (0.647, 0.165, 0.165) #brown
    for xi in range(-60, 60, 4):
        x = xi / 1000 + x_offset
        for yi in range(-60, 60, 4):
            y = yi / 1000 + y_offset
        
            # Check if the sphere is within the clump limit
            if (math.sqrt(x**2 + y**2) + radius_clump) <= clumpLimit:
                sphere_obj = sphere([x, y, zi + z_offset], radius_clump)
                # Assign material properties to the sphere
                sphere_obj.material = clump_plate
                sphere_obj.shape.color = color
                bodyList.append(O.bodies.append(sphere_obj))

# add clump to bodyList
idClump = O.bodies.clump(bodyList)

# add sphere packing
O.bodies.append(ymport.textExt('initialization.txt',format='x_y_z_r'))

# materials Properties
gravel = CohFrictMat(young = 1e7, poisson = 0.25, density = 27000, label = 'gravel')
asphalt_binder = CohFrictMat(young = 1e7, poisson = 0.25, density = 10600, label = 'asphalt_binder')

# add properties
O.materials.append(gravel)
O.materials.append(asphalt_binder)

# give color and properties to shpere
for body in O.bodies:
   if not isinstance(body.shape, Sphere): 
       continue
   if body.shape.radius == 0.01575/2 :
       body.shape.color = (0,0,1) #blue
       body.material = gravel    
   if body.shape.radius == 0.011/2:
       body.shape.color = (1,0,0) #red
       body.material = gravel
   if body.shape.radius == 0.007125/2:
       body.shape.color = (0,1,0) #green
       body.material = gravel
   if body.shape.radius == 0.003555/2:
       body.shape.color = (1,1,0) #yellow
       body.material = gravel
   if body.shape.radius == 0.00160/2 :
       body.shape.color = (1,0,1) #magenta
       body.material = gravel
   if body.shape.radius == 0.0008/2 :
       body.shape.color = (0,0,0) #black
       body.material = asphalt_binder
       
O.engines = [
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
        InteractionLoop(
                # handle sphere+sphere and facet+sphere collisions
                [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
                [Ip2_FrictMat_FrictMat_FrictPhys()],
                [Law2_ScGeom_FrictPhys_CundallStrack()]
        ),
        NewtonIntegrator(gravity=(0, 0, -9.81), damping=0.4),
        # call the checkUnbalanced function (defined below) every 2 seconds
        PyRunner(command='checkUnbalanced()', realPeriod=2),
]
O.dt = PWaveTimeStep()

# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
    if unbalancedForce() < 0.05:
        for body in O.bodies:
            # Exclude the clumped spheres
            if body not in idClump:
                if isinstance(body.shape, Sphere):
                    export.txt("1st_flat.txt",format='x_y_z_r')
        O.pause()

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.