示例#1
0
if not my_bodyfloor.IsNull():
    my_bodyfloor.SetMaterialSurface(pebble_material)
else:
    sys.exit('Error: cannot assign material to floor_box!')

# Create the pebbles

density_pebble = 2028
# kg/m^3
diameter_pebble = 0.045

mass_pebble = density_pebble * (4. / 3.) * chrono.CH_C_PI * pow(
    (diameter_pebble * 0.5), 3)
inertia_pebble = (2. / 5.) * mass_pebble * (pow((diameter_pebble * 0.5), 2))

pebbles = chrono.ChParticlesClonedShared()

pebbles.SetMass(mass_pebble)
pebbles.SetInertiaXX(
    chrono.ChVectorD(inertia_pebble, inertia_pebble, inertia_pebble))
pebbles.SetMaterialSurface(pebble_material)

pebbles.GetCollisionModel().ClearModel()
pebbles.GetCollisionModel().AddSphere(diameter_pebble / 2.)
pebbles.GetCollisionModel().BuildModel()
pebbles.SetCollide(True)

pebbles_shape = chrono.ChSphereShapeShared()
pebbles_shape.GetSphereGeometry().rad = diameter_pebble / 2.
pebbles.GetAssets().push_back(pebbles_shape)
my_system.Add(pebbles)
示例#2
0
# Create a physical system,
my_system = chrono.ChSystem()


# Set the default margins for collision detection, this is epecially
# important for very large or very small objects.
chrono.ChCollisionModel.SetDefaultSuggestedEnvelope(0.001)
chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.001)



# Create the set of the particle clones (many rigid bodies that
# share the same mass and collision shape, so they are memory efficient
# in case you want to simulate granular material)

body_particles = chrono.ChParticlesClonedShared()
body_particles.SetMass(0.01);
inertia = 2/5*(pow(0.005,2))*0.01;
body_particles.SetInertiaXX(chrono.ChVectorD(inertia,inertia,inertia));

# Collision shape (shared by all particle clones) Must be defined BEFORE adding particles
body_particles.GetCollisionModel().ClearModel()
body_particles.GetCollisionModel().AddSphere(0.005)
body_particles.GetCollisionModel().BuildModel()
body_particles.SetCollide(True)

# add particles
for ix in range(0,5):
    for iy in range(0,5):
        for iz in range(0,3):
            body_particles.AddParticle(chrono.ChCoordsysD(chrono.ChVectorD(ix/100,0.1+iy/100, iz/100)))