[770c98]: / Application / Examples / THA-KneeBendDemo / THA-KneeBendDemo.Main.any

Download this file

135 lines (103 with data), 5.5 kB

#include "../libdef.any"

/**
This is a demo model for the simulation of a knee bend for a body model 
with a total hip arthroplasty (THA)using:
    - either an ideal spherical joint with joint reaction forces
    - or force dependent kinematics and a contact model.

In the body model, the hip joint is excluded from the AnyBodyStudy and a new force dependent 
hip joint is included. Therefore, a acetabular cup and a femoral component (1) are included into the model 
and a contact force between these implants is defined. For stabiliy reasons an artifical spring
is implemented to avoid the joint to disconnect.

Please notice that this simulation is only a demo example.
The placement of hte implant is not based on any anatomical data.
Further, the implant includes an artificial spring (in Model/ContactForces.any) 
element to make the simulation more robust. For each simulation, the force produced 
by this artifical spring should be checked to be aware of the influence
of this spring on the results.

---
(1) The geometry data of the femoral component was kindly provided by Edmundo Fuentes via GrabCAD.com
    http://edmundofuentes.com
*/
Main = {
  
  // Switches to include AnyDrawWidgets to change the positions and orientation of the hip implants.
  
  // Widget to rotate the femoral component
  #define FEM_STEM_ROT 0  
  // Widget to move the femoral component
  #define FEM_STEM_LIN 0  
  // Widget to rotate the Acetabular cup
  #define PELVIS_CUP_ROT 0
  
  // Switch to use an ideal spherical joint, or force dependent kinematics for the right hip joint.
  #ifndef USE_FDK
    #define USE_FDK 1
  #endif
  
  // ----------------------------------------------------------
  // Path to draw settings
  // ----------------------------------------------------------
  #include "Model/DrawSettings.any"
  
  // ----------------------------------------------------------
  // Body Model Configuration
  // ----------------------------------------------------------
  #include "Model/BodyModelConfiguration.any"
  
  // The Mannequin file specifies load-time positions for all the segments
  // in the HumanModel. This is important for the model's ablity to resolve
  // all the kinematic constraints when the model is analyzed.
  // The mannequin file also drives those degrees of freedom of the human 
  // model that are not governed by problem-specific drivers at run time.    
  #include "Model/Mannequin.any" 

  // Model of the human body to be used for the analysis  
  #include "<ANYBODY_PATH_BODY>/HumanModel.any"

  /// The actual model where all components are assembled  
  AnyFolder Model ={
    /// Body model without default drivers
    AnyFolder &BodyModel=.HumanModel.BodyModel;
    /// Reference to the mannequin folder (used by drivers)
    AnyFolder &Mannequin =.HumanModel.Mannequin;  
    
    #include "Model/Environment.any"   
    
    // Implants defines and positions the stl surfaces of the hip implants.
    #include "Model/Implants.any"

    AnyFolder ModelEnvironmentConnection = {
      #include "Model/JointsAndDrivers.any"
    };
  };
  
  AnyBodyStudy Study = {
    AnyFolder &Model = .Model;

    // This file implements the implant contact forces.
    #if USE_FDK
    #include "Model/ContactForces.any"
    #endif
    
    // In this file, the bone of the femur is replaced.
    #include "Model/BoneExchange.any"

        
    tEnd = 10.0;
    Gravity = {0.0, -9.81, 0.0};
    nStep = 10;
 
    
    AnyFolder HipComparison =
    {
      
      #if USE_FDK 
      AnyFloat RightHipReactionForceFDK = (Main.Study.FSurf.Fslave[0]^2 
                                          + Main.Study.FSurf.Fslave[1]^2 
                                          + Main.Study.FSurf.Fslave[2]^2)^0.5;
      #else
      AnyFloat RightHipReactionForce = (Main.HumanModel.BodyModel.Right.Leg.Jnt.Hip.Constraints.Reaction.Fout[0]^2 
                                       + Main.HumanModel.BodyModel.Right.Leg.Jnt.Hip.Constraints.Reaction.Fout[1]^2 
                                       + Main.HumanModel.BodyModel.Right.Leg.Jnt.Hip.Constraints.Reaction.Fout[2]^2)^0.5;
      #endif   
      
      AnyFloat LeftHipReactionForce = (Main.HumanModel.BodyModel.Left.Leg.Jnt.Hip.Constraints.Reaction.Fout[0]^2 
                                       + Main.HumanModel.BodyModel.Left.Leg.Jnt.Hip.Constraints.Reaction.Fout[1]^2 
                                     + Main.HumanModel.BodyModel.Left.Leg.Jnt.Hip.Constraints.Reaction.Fout[2]^2)^0.5;
    };

    #if USE_FDK 
    // Here the hip joint from the body model is removed 
    // and new FDK drivers for the contact hip joint are 
    // defined.
    #include "Model/HipExchange.any"

    InverseDynamics.ForceDepKinOnOff=On;               //Values gained by experience
    InverseDynamics.ForceDepKin.ForceTol=10;           //Values gained by experience
    InverseDynamics.ForceDepKin.Perturbation=5e-5;     //Values gained by experience
    InverseDynamics.ForceDepKin.LocalSearchOnOff = On; //Values gained by experience
    //InverseDynamics.ForceDepKin.MaxNewtonStep = 0.1;    //Values gained by experience
    
    //InverseDynamics.ForceDepKin.UseAdaptiveForceTolOnOff = On;
   #endif
    
  }; // End of study

  // Include an operation sequence to run all required steps of your application (see Operations tab)
    #include "<ANYBODY_PATH_MODELUTILS>\Operations\RunAppSequence.any"     
  
}; //Main