subroutine TD_ForceUpB(i,TD_SemiMudVisc)
    
   Use TD_DrillStemComponents
   use SimulationVariables !@
   use SimulationVariables !@
   use SimulationVariables !@
   use SimulationVariables
   
   implicit none
   
   Integer :: i
   Real(8) :: TD_SemiMudVisc
   
   If (i==1) then
       data%State%TD_DrillStems(1)%Force1 = -data%State%TD_String%WeightOnBit
       data%State%TD_DrillStems(1)%Force2 = (data%State%TD_DrillStems(1)%Force1 * exp((TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))) - &
                            (((data%State%TD_DrillStems(1)%WeightperLength * data%State%TD_DrillStems(1)%RCurvature) / (1 + (TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)**2)) * &
                            (((1-(TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)**2)*(sin(data%State%TD_DrillStems(1)%EndAngle) - &
                            (exp((TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle)) * sin(data%State%TD_DrillStems(1)%StartAngle))))) - &
                            (2.0d0* (TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(cos(data%State%TD_DrillStems(1)%EndAngle) - &
                            (exp((TD_SemiMudVisc*data%State%TD_DrillStems(1)%MudVisCorrectCoef)*(data%State%TD_DrillStems(1)%EndAngle-data%State%TD_DrillStems(1)%StartAngle))* &
                            cos(data%State%TD_DrillStems(1)%StartAngle)))))
       
       
       if (data%State%TD_DrillStems(i)%ComponentType==0) then
           data%State%TD_DrillStems(i)%Torque = data%State%TD_String%BitTorque
       else
           data%State%TD_DrillStems(i)%Torque = (data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * &
                            data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * &
                            abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) + &
                            (2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * &
                            data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * &
                            (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle)))
       end if
       
       
       return
   End If
   
   
    
!=========> F1 Calculation
   data%State%TD_DrillStems(i)%Force1 = data%State%TD_DrillStems(i-1)%Force2
   
    
!=========> F2 Calculation
    data%State%TD_DrillStems(i)%Force2 = (data%State%TD_DrillStems(i)%Force1 * exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))) - &
                            (((data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature) / (1 + (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)) * &
                            (((1-(TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)**2)*(sin(data%State%TD_DrillStems(i)%EndAngle) - &
                            (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) * sin(data%State%TD_DrillStems(i)%StartAngle))))) - &
                            (2.0d0* (TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(cos(data%State%TD_DrillStems(i)%EndAngle) - &
                            (exp((TD_SemiMudVisc*data%State%TD_DrillStems(i)%MudVisCorrectCoef)*(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle))* &
                            cos(data%State%TD_DrillStems(i)%StartAngle)))))
    !    
    !   Strains(i)%Dl = TDForces(i)%Force * (Elements(i)%Length  ) / &
    !                         (Elements(i)%Area * Element%ElasticModule)
    !    
    data%State%TD_DrillStems(i)%Torque = (data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * &
                            data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) * &
                            abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle)) + &
                            (2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * &
                            data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature * &
                            (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle)))
    
    !!if (data%State%TD_DrillStems(i)%Torque>500.) then
    !     print* , 'data%State%TD_String%TotalTorqueb=' , i , data%State%TD_String%TotalTorque , data%State%TD_DrillStems(i)%Torque , data%State%TD_String%WeightOnBit , sin(30.) , sin(3.14/6.)
    !     print* , 'torquepropertiesb=' , data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint , (data%State%TD_DrillStems(i)%Force1 + (data%State%TD_DrillStems(i)%WeightperLength * &
    !                        data%State%TD_DrillStems(i)%RCurvature * sin(data%State%TD_DrillStems(i)%StartAngle))) , abs(data%State%TD_DrillStems(i)%EndAngle-data%State%TD_DrillStems(i)%StartAngle), &
    !                        2.0d0 * data%State%TD_DrillStems(i)%MudViscosity * data%State%TD_DrillStems(i)%RtoolJoint * &
    !                        data%State%TD_DrillStems(i)%WeightperLength * data%State%TD_DrillStems(i)%RCurvature , (cos(data%State%TD_DrillStems(i)%EndAngle) - cos(data%State%TD_DrillStems(i)%StartAngle))
    !     print* , 'propertiesb=' , data%State%TD_DrillStems(i)%Force2 , data%State%TD_DrillStems(i)%Force1 , data%State%TD_DrillStems(i)%MudViscosity , data%State%TD_DrillStems(i)%EndAngle , data%State%TD_DrillStems(i)%StartAngle , data%State%TD_DrillStems(i)%WeightperLength , data%State%TD_DrillStems(i)%MudVisCorrectCoef , data%State%TD_DrillStems(i)%RCurvature
    ! !end if
    
        
end subroutine 