Implementing a Moment-Load (not Force-Load) Goal

Hello everyone!

I’m wondering if there is way to implement a LoadGoal equivalent to the existing “Goals-Pt>Load” in Kangaroo2, but for applying a bending (twisting/torquing) point moment to a particle, and not a point force.

I understand that Kangaroo2 (@DanielPiker) implements the class GoalObject, and deriving from it, new custom goals can be programmed. For example the LoadGoal programmed by Cecilie Brandt-Olsen (@c.brandtolsen) in K2Engineering uses PPos[0], Move[0] and Weighting[0].

    public class LoadGoal : GoalObject
    {
        Vector3d load;

        public LoadGoal(Point3d pt, Vector3d force)
        {
            load = force;

            PPos = new Point3d[1] {pt};
            Move = new Vector3d[1] {load};
            Weighting = new double[1] {1.0};
        }
     
        public override void Calculate(List<KangarooSolver.Particle> p)
        {
            Move[0] = load;
        }

       //Output updated position of node where the load acts. Load in [kN]
       public override object Output(List<KangarooSolver.Particle> p)
       {
           //Create load data object to store output information
           DataTypes.PointLoadData loadData = new DataTypes.PointLoadData(p[PIndex[0]].Position, Move[0] * Weighting[0] * 1e-3);
           return loadData;
       }
     }

I have tried to code another GoalObject, for point moments (not point forces) using PPos[0], Torque[0] and TorqueWeighting[0], but it does not to work.

    public class MomentGoal : GoalObject
    {
        Vector3d load;
        Point3d initialP;

        public MomentGoal(Point3d pt, Vector3d moment)
        {
            load = moment;
            initialP = pt;

            PPos = new Point3d[1] {pt};
            Torque = new Vector3d[1] {load};
            TorqueWeighting = new double[1] {1.0};
        }
        
        public override void Calculate(List<KangarooSolver.Particle> p)
        {
            Torque[0] = load;
        }

       //Output updated position of node where the moment acts. Moment in [kNm]
       public override object Output(List<KangarooSolver.Particle> p)
       {
           //Create load data object to store output information
           DataTypes.PointLoadData loadData = new DataTypes.PointLoadData(p[PIndex[0]].Position, Torque[0] * TorqueWeighting[0] * 1e-3);
           return loadData;
       }
    }

I know that a moment (torque) should rotate and not translate (move) the particle, so perhaps the Goal needs to handle a local coordinate system (Plane), but I don’t manage to solve it.

Could someone give me a hint, please?

Thank you!!!

Hi, everyone!

Just in case someone is interested. I have solved the question.

The problem was that, with the MomentGoal, I only initilized the Torque and TorqueWeighting variables of the GoalClass, and left the Move and Weighting undefined.

So, the Kangaroo2 solver was unable to complete the first iteration… If a particle has no Weighting (for translations), it is completely unstable/undefined. Now the code works perfectly.

        public MomentGoal(Point3d pt, Vector3d moment)
        {
            load = moment;
            initialP = pt;

            PPos = new Point3d[1] {pt};

            Move = new Vector3d[1];
            Move[0] = new Vector3d(0.0,0.0,0.0);
            Weighting = new double[1] { 1.0 };

            Torque = new Vector3d[1] {load};
            TorqueWeighting = new double[1] {1.0};
        }

Hope this may help others.