Suitability for large branching structures?

Simbody is useful for internal coordinate and coarse grained molecule modeling, large scale mechanical models like skeletons, and anything else that can be modeled as bodies interconnected by joints, acted upon by forces, and restricted by constraints.
POST REPLY
User avatar
Alejandro Garcia
Posts: 1
Joined: Thu Oct 13, 2022 1:59 pm

Suitability for large branching structures?

Post by Alejandro Garcia » Thu Oct 20, 2022 9:06 pm

Hello, I was wondering if there were any performance tests regarding large 3D branching structures that have an angular spring between every rigid body?

I am trying to represent bending structures as systems of rigid bodies, so I was wondering what the 'practical limits' are regarding the number of actuated bodies in simbody, at least before performance times are not longer considered real-time. For a 2D example, I have played around with ExampleLongPendulum, but am not sure if my approach is the *most optimal* (I am using the CPODEs integrator).

Code: Select all

    // Cylindrical rigid body with pre-computed inertias of Ix, Iy, and Iz
    Body::Rigid pendulumBody(MassProperties(m, Vec3(0), Inertia(Ix, Iy, Iz)));
    // Add a cylinder mesh of height h and radius r, re-orient it
    pendulumBody.addDecoration(Rotation(Pi/2, CoordinateAxis(2)), DecorativeCylinder(r, h/2));

    MobilizedBody lastBody = matter.Ground();

    int num_bodies = 5;
    for (int i = 0; i < num_bodies; ++i)
    {
        // The first cylinder body is attached to origin, the rest are attached to it's parent's tip
        Vec3 attachPointParent = i == 0 ? Vec3(0, 0, 0) : Vec3(h / 2, 0, 0);

        Vec3 attachPointSelf = Vec3(-h / 2, 0, 0);

        Rotation r =  Rotation(0, CoordinateAxis(2));

        // Create mobilized body
        MobilizedBody::Pin pendulum(lastBody, Transform(attachPointParent) * Transform(r),
            pendulumBody, Transform(Vec3(attachPointSelf)));

        lastBody = pendulum;

        // This mobilized body will be acted upon a constant angular spring with precomputed spring constant k_z
        Force::MobilityLinearSpring springForce(forces, lastBody, 0, k_z, 0.);
    }

I also tried the above example with gimbals instead of pins, but found the simulation speed stagnated around a couple dozen bodies in a serial link. Is this the practical limit? Or could there be some extra settings/precautions I could take to speedup simulations?

User avatar
Michael Sherman
Posts: 812
Joined: Fri Apr 01, 2005 6:05 pm

Re: Suitability for large branching structures?

Post by Michael Sherman » Sun Oct 23, 2022 9:45 pm

Of course there is a limit to how big a system can run in real time, but I don't think you're close to it yet. Take a look at "ChainExample". That's an interactive 3d example with 100 bodies connected by ball joints so 300 dofs. Depending how stiff your springs are, you might find an explicit integrator is a better choice than CPodes. The ChainExample uses RungeKuttaMerson. One of the low-order SemiExplicit methods might work well also.

POST REPLY