HydroChrono icon indicating copy to clipboard operation
HydroChrono copied to clipboard

Added mass with fixed body in system crashes simulation

Open zur-quin opened this issue 2 years ago • 0 comments

In situations where one body in the chrono system is fixed in place, Project Chrono removes its mass/inertia matrix from the system's mass/inertia matrix. This does not cause problems when applying forces to the fixed body, but does cause problems when the added mass matrix is larger than the system mass matrix. There is a current (yet messy) solution: say the fixed body in the system is called body1. Then instead of fixing body1 in place, create a new extra ChBody called floor. Fix floor and link it to body1. Now, since body1 isn't fixed, its mass matrix is part of the system mass matrix and since floor is fixed, chrono removes its mass matrix from the system. Then added mass can be added as normal. This is the current method of fixing bodies in demo_oswec_decay and demo_f3of_DT3. See excerpt from oswec below:

   // define the base's initial conditions
    system.Add(base_body);
    base_body->SetPos(ChVector<>(0, 0, -10.9));
    base_body->SetMass(999);
    base_body->SetInertiaXX(ChVector<>(1, 1, 1));

    // create ground
    auto ground = chrono_types::make_shared<ChBody>();
    system.AddBody(ground);
    ground->SetPos(ChVector<>(0, 0, -10.9));
    ground->SetBodyFixed(true);
    ground->SetCollide(false);
    // fix base to ground with special constraint (don't use setfixed() because of mass matrix)
    auto anchor = chrono_types::make_shared<ChLinkMateGeneric>();
    anchor->Initialize(base_body, ground, false, base_body->GetVisualModelFrame(), base_body->GetVisualModelFrame());
    system.Add(anchor);
    anchor->SetConstrainedCoords(true, true, true, true, true, true);  // x, y, z, Rx, Ry, Rz

This issue can be resolved when the above code is replaced with

   // define the plate's initial conditions
    system.Add(base_body);
    base_body->SetNameString("body2");
    base_body->SetPos(ChVector<>(0, 0, -10.9));
    base_body->SetMass(999);
    base_body->SetInertiaXX(ChVector<>(1, 1, 1));
    base_body->SetBodyFixed(true);

and the demo runs, producing correct results.

zur-quin avatar May 24 '23 21:05 zur-quin