here's the code :
import pychrono.core as chrono
import pychrono.irrlicht as chronoirr
import random
import numpy as np
# Sim-DATA :
simData = {
"Density" : 5200,
"ExpectedDiameter" : .05e-3
}
simData["ParticleVolume"] =
(3/4)*np.pi*np.power((simData["ExpectedDiameter"]/2), 3)
simData["ParticleMass"] =
simData["ParticleVolume"]*simData["Density"]
simData["ParticleInertia"] =
(2/5)*simData["ParticleMass"]*np.power((simData["ExpectedDiameter"]/2),
2)
# Create Chrono physical system
system = chrono.ChSystemNSC()
system.SetCollisionSystemType(chrono.ChCollisionSystem.Type_MULTICORE)
system.SetGravitationalAcceleration(chrono.ChVector3d(0,
-9.81, 0))
ground = chrono.ChBody()
ground.SetFixed(True)
system.Add(ground)
material = chrono.ChContactMaterialNSC()
material.SetFriction(.5)
def constrain_to_2D(body):
# Dummy body as reference :
dummy = chrono.ChBodyAuxRef()
dummy.SetFixed(True)
system.AddBody(dummy)
# Planar constraint and its frame :
plane_constraint = chrono.ChLinkLockPlanar()
frame_abs = chrono.ChFramed(body.GetPos(), chrono.QUNIT)
# Init :
plane_constraint.Initialize(body, dummy, True,
frame_abs, frame_abs)
# constraint generic mate :
lock = chrono.ChLinkMateGeneric()
lock.Initialize(body, dummy, False, frame_abs, frame_abs)
# Constrain Tz and X/Y rotation in case of offset :
lock.SetConstrainedCoords(False, False, True, # Tx, Ty, Tz
True, True, False) # Rx, Ry, Rz
system.Add(lock)
system.AddLink(plane_constraint)
def importMeshBody(meshFile, material, contrained2D=False,
fixed=True, scale=0.001, initialPos=chrono.ChVector3d(0, 0,
0), colorVec=chrono.ChColor(0.3, 0.3, 0.3)):
# Prior :
body = chrono.ChBody()
system.Add(body)
body.SetPos(initialPos)
if contrained2D :
constrain_to_2D(body)
# mesh :
mesh = chrono.ChTriangleMeshConnected()
mesh.LoadWavefrontMesh(meshFile)
transformationMatrix = chrono.ChMatrix33d(scale)
mesh.Transform(chrono.ChVector3d(0,0,0),
transformationMatrix)
# Visualization part :
visShape = chrono.ChVisualShapeTriangleMesh()
visShape.SetMesh(mesh)
visShape.SetColor(colorVec)
body.AddVisualShape(visShape)
# Collision part :
body_ct_shape =
chrono.ChCollisionShapeTriangleMesh(material, mesh, False,
False, 0.01)
body.AddCollisionShape(body_ct_shape)
body.EnableCollision(True)
body.SetFixed(fixed)
return body
plate = importMeshBody("test PLATE.obj", material,
contrained2D=True, scale=.001, fixed=True)
# Particles cloud :
particles = chrono.ChParticleCloud()
particles.SetMass(simData["ParticleMass"])
particles.SetInertiaXX(chrono.ChVector3d(simData["ParticleInertia"],
simData["ParticleInertia"], simData["ParticleInertia"]))
# Collision shape/model :
colModel = chrono.ChCollisionModel()
colModel.Clear()
cylShape = chrono.ChCollisionShapeCylinder(material, .01,
.002) # radius
colModel.AddShape(cylShape)
particles.AddCollisionModel(colModel)
particles.AddCollisionShape(cylShape)
visShape = chrono.ChVisualShapeCylinder(.01, .002)
frame = chrono.ChFramed(chrono.ChVector3d(0,0,0),
chrono.QuatFromAngleAxis(chrono.CH_PI/2,
chrono.ChVector3d(1,0,0)))
particles.AddVisualShape(visShape, frame)
# Add particles (positions only)
for i in range(20):
possys = chrono.ChCoordsysd(
chrono.ChVector3d(random.uniform(-.3, .3),
random.uniform(-.3, .3), 0),
chrono.QuatFromAngleAxis(-chrono.CH_PI/2,
chrono.ChVector3d(1,0,0))
)
particles.AddParticle(possys)
particles.EnableCollision(True)
system.Add(particles)
vis = chronoirr.ChVisualSystemIrrlicht()
vis.AttachSystem(system)
vis.SetWindowSize(1024, 768)
vis.SetWindowTitle("Mixer simulator")
vis.Initialize()
vis.AddSkyBox()
vis.AddCamera(chrono.ChVector3d(0, 0, 2))
vis.AddTypicalLights()
time_step = 0.005
while vis.Run():
vis.BeginScene()
vis.Render()
vis.EndScene()
system.DoStepDynamics(time_step)
Le lundi 25 août 2025 à 01:47:32 UTC+1, Dan Negrut a écrit :
Hi, would you mind dropping the entire PyChrono script,
top to bottom, that demonstrates the problem?
NOTE: this is a public forum, remove any sensitive
information/data.
Thank you,
Dan
---------------------------------------------
Bernard A. and Frances M. Weideman Professor
NVIDIA CUDA Fellow
Department of Mechanical Engineering
Department of Computer Science
University of Wisconsin - Madison
4150ME, 1513 University Avenue
Madison, WI 53706-1572
608 772 0914 <tel:(608)%20772-0914>
http://sbel.wisc.edu/ <http://sbel.wisc.edu/>
http://projectchrono.org/
<https://urldefense.com/v3/__http://projectchrono.org/__;!!Mak6IKo!ITBwK6AoQ7iC2NneNT03ytYMiDYSaYAZrEKJuUflDp6oKyToFy5ZnziS6wqNOxZebNMoYz5M9krJyntijC-1gw$>
---------------------------------------------
*From:*projec...@googlegroups.com
<projec...@googlegroups.com> *On Behalf Of *Zaftrox
*Sent:* Sunday, August 24, 2025 4:04 PM
*To:* ProjectChrono <projec...@googlegroups.com>
*Subject:* [chrono] Question about the ChParticleCloud,
Crash when collisions are enabled
Hi, i wanted to create a particlecloud to handle a bunch
of cylindrical objects in pychrono. However, when i
setup the particlecloud then enable the collisions, it
crashs immediately.
Here's the snippet :
# Particles cloud :
particles = chrono.ChParticleCloud()
particles.SetMass(simMat["ParticleMass"])
particles.SetInertiaXX(chrono.ChVector3d(
simMat["ParticleInertia"], simMat["ParticleInertia"],
simMat["ParticleInertia"]))
# Collision shape/model :
colModel = chrono.ChCollisionModel()
colModel.Clear()
cylShape = chrono.ChCollisionShapeCylinder(material,
.01, .002)
colModel.AddShape(cylShape)
particles.AddCollisionModel(colModel)
particles.AddCollisionShape(cylShape)
visShape = chrono.ChVisualShapeCylinder(.01, .002)
frame = chrono.ChFramed(chrono.ChVector3d(0,0,0),
chrono.QuatFromAngleAxis(chrono.CH_PI/2,
chrono.ChVector3d(1,0,0)))
particles.AddVisualShape(visShape, frame)
# addition loop :
for i in range(20):
possys = chrono.ChCoordsysd(
chrono.ChVector3d(random.uniform(-.3, .3),
random.uniform(-.3, .3), 0),
chrono.QuatFromAngleAxis(-chrono.CH_PI/2,
chrono.ChVector3d(1,0,0))
)
particles.AddParticle(possys)
#particles.EnableCollision(True)
system.Add(particles)
--
You received this message because you are subscribed to
the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to projectchron...@googlegroups.com.
To view this discussion visit
https://groups.google.com/d/msgid/projectchrono/a2929f89-b15a-42f5-a807-c7e7d02ec0edn%40googlegroups.com
<https://urldefense.com/v3/__https:/groups.google.com/d/msgid/projectchrono/a2929f89-b15a-42f5-a807-c7e7d02ec0edn*40googlegroups.com?utm_medium=email&utm_source=footer__;JQ!!Mak6IKo!O70Z-enwv3qPCNU5GsB0940X-7u5DtlNMuTw3zW-RVU8aTz_03LgUXyioYkelAHDYjGP2VlV_AMEqe82eWY$>.
--
You received this message because you are subscribed to the
Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to projectchron...@googlegroups.com.
To view this discussion visit
https://groups.google.com/d/msgid/projectchrono/0c2e271d-964f-444b-81e5-ceddcb392a48n%40googlegroups.com
<https://urldefense.com/v3/__https://groups.google.com/d/msgid/projectchrono/0c2e271d-964f-444b-81e5-ceddcb392a48n*40googlegroups.com?utm_medium=email&utm_source=footer__;JQ!!Mak6IKo!ITBwK6AoQ7iC2NneNT03ytYMiDYSaYAZrEKJuUflDp6oKyToFy5ZnziS6wqNOxZebNMoYz5M9krJyntp0Cwicg$>.