How to add an instantaneous force on a node or frame?

Hey, I wanted to add an external force for a specific time period, i.e., instantaneous force. Can somebody share the code, if available?
Thank you.

Regards,
Suyash

Hi @Suyash

To accomplish that you can define a function that is zero until the specific time period and then it switches to a value. You then use that function in a AnyForce or derived class to apply a force.

Best regards,
Bjørn

Hey @Bjorn

Thank you so much for your reply.
Let's say I wanted to apply force only on the 50 to 90 frames out of 196 frames of the c3d(motion) files. How can I define the force function for that as it is not time-dependent?

          AnyFolder Loads = {
  AnyForce3D belt1 = {
    AnyRefFrame &AnkleJnt1=Main.Studies.HumanModel.BodyModel.Right.Leg.Seg.Shank.AnkleJoint;
    F = {0,-50,0};

This is the code and force value.

Hi @Suyash

Why can the function not be time dependent?
Here is how you could do a square wave function for an instant force.

AnyFunSquareWave ForceFun = {
  InitialValues = {0.0};
  Ts = {.tStart + (.tFrame * 50), .tStart + (.tFrame * 90)};
  Values = {{50.0, 0.0}};
  dT = {.tFrame};        
};

AnyForce3D belt1 = {
  AnyRefFrame &AnkleJnt1 = Main.HumanModel.BodyModel.Right.Leg.Seg.Shank.AnkleJoint;
  F = {0, -.ForceFun(.t)[0], 0};
};

This will be a force of 50 between the frames 50 and 90 and zero elsewhere.
If you have used one of the AnyMoCap models you should be able to put this inside the inverse dynamics study for it to work, otherwise you might need to change some of the referenced variables.

If you need a smoother application of the force you could achieve that with a AnyFunInterpol like so:

AnyFunInterpol ForceFun = {
  AnyInt ForceAmplitude = 50;
  Type = Bspline;
  BsplineOrder = 4;
  T = .tArray;
  Data ={
    arrcat(
      flatten(zeros(1, 50)), 
      flatten(ones(1, 90 - 50) * ForceAmplitude), 
      flatten(zeros(1, .nStep - 90))
    )
  };
};

which will ramp up the force over a few frames instead of applying it instantaneously.

Best regards,
Bjørn

Thank you for the reply.
On loading the code with script 2 and 1, it shows the following error respectively :
ERROR(SCR.PRS9) : C:/P..)/A..y/A..3/AMMR/A..n/E..s/G..y/GaitLowerExtremity.main.any : 'flatten' : Unresolved object
ERROR(SCR.PRS9) : C:/P..)/A..y/A..3/AMMR/A..n/E..s/G..y/GaitLowerExtremity.main.any : 'tFrame' : Unresolved object
I am sorry, but I am new to this, and your help is much appreciated.
PS: I am using GaitLowerExtremity model

Regards,
Suyash

Hi @Suyash

What version of the AnyBody Modeling System and AMMR are you using?
You are most likely on an older version where the flatten function is not present in the AMS and the GaitLoverExtremity model does not have a .tFrame in the study.

You will need to adapt the code to fit your model.

Best regards,
Bjørn

This topic was automatically closed 125 days after the last reply. New replies are no longer allowed.