I defined an elastic band. I have stiffness data (k) in three different coefficient of band initial length (L0) as follows:
K at 25%L0= 100
K at 50%L0=150
K at 75%L0=200
I want to use AnyFunInterpol to interpolates for the values in between and then apply the resulting force to the band. I’m wondering how I can also consider the changes in the length of the band. Any help would be greatly appreciated.

Here are the initial codes I wrote:
AnyKinPLine left = {
AnyRefFrame &p1 = Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.L3Seg.exo1r;
AnyRefFrame &p2 = Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.Left.exo2l;
AnyRefFrame &p3 = Main.HumanModel.BodyModel.Left.Leg.Seg.Thigh.HipJoint.exo3l;
AnyRefFrame &p4 = Main.HumanModel.BodyModel.Left.Leg.Seg.Thigh.GluteusMaximusInferior2Node.exo4l;
AnyRefFrame &p5 = Main.HumanModel.BodyModel.Left.Leg.Seg.Thigh.exo5l;
AnyDrawPLine drw = {
Thickness = 0.02;
RGB = {1,0,0};
};
};

AnyFunInterpol stiffness = {
Type= Bspline;
k = {100,150,200},
};
L0=0.4;
F = k*{ L0-left.Pos[0]};
};

Welcome to the AnyScript forum and apologies for the delayed response. This period has been a little bit busy.
You can use AnyFunInterpol to consider the changes in the length of the elastic band and apply the resulting force. You are on the right track, you have defined an AnyKinPLine that will give you a measure of the length of the elastic band.
The interpolation can be a little bit tricky to implement, especially when you are new to Anybody. But here is a piece of code that should help you get going:

AnyFunInterpol Int = {
Type = PiecewiseLinear; // there are different types of interpolation functions, see reference manual
T = L0*{0.25,0.5,0.75}; // replace L0 with your L0 value.
Data = {{100, 150, 200}}; // Force data corresponding to band length
};
AnyForce ElasticForce = {
AnyKinMeasure &Line = .left; // path to your elastic band
F = {.Int(Line.Pos[0])[0]};
};

Please note that if your elastic band length goes out of range, i.e. it goes beyond 25 to 75% L0 during the simulation, the interpolation function will throw an error.

Hi Dave,
Thank you so much for the codes. My issue is the place where the interpolation codes should go. When I defined two bands, I got an error.
Is it possible to do the interpolation in Matlab and then import the vector in AnyBody as an input?

There is one error that I noticed in my previous post. I inserted space between "Elastic force" in the name of the AnyForce object. This will create an error, I am sorry. Then you may use the same interpolation function for the left and right bands but you would need to create left and right AnyKinPLine and AnyForce objects.

Please let me know what is the error you are seeing?

Sure, it is possible to do the interpolation in Matlab. What you would need is a text file (.txt or .csv) with two columns that must be imported into AnyBody. The first column should be the length values (independent parameter) and the second column should be the stiffness value (dependent variable). But I am sure, the problem you are facing right now is unrelated to whether interpolation is done in Matlab or AnyBody.

Hi Dave,
Thank you so much! Now the codes work. Since I have two bands, I applied the interpolation to both the right and left bands.
However, I am currently facing another problem. I modeled two bands from the L3 to mid-thigh, intended to aid trunk extension and specifically designed to assist with lifting objects. I expected the joint reaction forces (L5-S1 is now important to me), would decrease. However, when testing with a 10 kg box, both the compressive and shear forces increased. I am uncertain whether I have made a mistake and would appreciate any insights you may have on this matter.
Thanks,
Zeinab

That's a good question. It's not unreasonable that the compression force increase. I imagine these bands to exert a tensile force, whose line of action would act to increase the compression force. You may have unloaded some of the extensor muscles but then their action is being replaced by the bands. On the other hand, the bands should have a greater moment arm than the muscles and need lower force to provide the same action like the muscles that they unload. I suppose it's a compromise and that's where a simulation can help you

Hi Dave,
How can I know the direction of force (line of action) in these two bands?
I'm still thinking about your explanation! If I understand correctly, by adding these two bands, we are essentially creating two more extensors that, while unloading the extensor muscles, also generate their own force. However, due to their greater moment arm, their force is lower than that of the actual extensor muscles.
In this case, given that we now have additional force in the same direction as the extensors, is it correct to subtract this force from the total compressive/shear force? I mean can I convert the force produced by these bands into negative values?

You find a viewForce object inside the AnyForce class. Please set viewForce.Visible = On;

Besides the moment arm, you should also think about the direction of the bands and the muscles. They would be different from each other. The direction of the bands will influence the vertical component of the force, which should reflect on the compressive force.

If your simulation is set up correctly, then the effects of the elastic band would be correctly reflected on the joint reaction force at L5-S1. I don't think you need to do any other computation unless, maybe, you are interested in isolating the effect of the band or muscles on the compressive force? If this is what you want to do, you can look at AnyForceMomentMeasure2.

Thank you so much. I have made some progress on my model and I'm still working on it.
The viewForce also worked very well.
I was interested to know the amount of changes in the band length that I modeled over a lifting task. However, I noticed that when I run the model with data related to people of different anthropometric dimensions (5 and 95 percentile), the band length is only about 1-2 cm different. Indeed, the band length doesn’t get scaled according to body dimensions. I'm wondering how it can happen, since I defined all the nodes according to the segments and also segments length are dependent on the bvh data I imported. Therefore, as the segments dimensions change the location of nodes also should change. Could you please provide me any insight on this?

Good to know that you are making progress on the model!

That's an interesting question and I think there can be one of several issues:

Firstly, I am not entirely sure how much is the difference that you expect? I am not sure of the numbers but I am expecting (guesstimating) a difference in height of around 40 cm between the extreme percentiles?? However, only a part of that difference will be visible in the band length and I am not sure how much that would be (you can make a rough guess as the ratio of the band length to the subject height would be roughly the same as the ratio of the differences in the two). How much difference are you expecting? I generally think that 1-2 cm may be a little bit too less.

Secondly, as you mentioned, when you use bvh data, the segment lengths would be coming from the bvh data. So, it could be worthwhile to double check that the segment dimensions that you see in the model are realistic and representative of the models from the two percentiles.

Thirdly, when you define reference nodes on the segments, you should consider adding a way to scale the sRel of the nodes you have defined. In case the sRel is a constant value, then it will always respect that constant value. For example, if the offset is defined as 10 cm from hip joint, then it will always be 10 cm from the hip joint irrespective of the segment dimension. You can make some relations with sRel as a factor of the segment dimension or you can use the same scaling function that is used to scale the human model.