subroutine TD_BouyancyFactor (i)
    
   Use TD_DrillStemComponents
   use SimulationVariables !@
   use SimulationVariables !@
   use SimulationVariables !@
   

   implicit none
   
   Integer :: i

   
   

!====================================================
!           Bouyancy Factor Calculation
!====================================================
   
   if ( data%State%TD_DrillStems(i)%MudDensityOut==0.d0 .or. data%State%TD_DrillStems(i)%MudDensityIn==0.d0 ) then
       data%State%TD_DrillStems(i)%BouyancyFactor = 0.d0
   else
       data%State%TD_DrillStems(i)%BouyancyFactor = 1.d0-( ((data%State%TD_DrillStems(i)%MudDensityOut*(data%State%TD_DrillStems(i)%Od**2)/4.0d0) &
                                        -(data%State%TD_DrillStems(i)%MudDensityIn*(data%State%TD_DrillStems(i)%Id**2)/4.0d0)) &
                                        /(data%State%TD_DrillStems(i)%Density*((data%State%TD_DrillStems(i)%Od**2-data%State%TD_DrillStems(i)%Id**2))/4.0d0) )
   end if
   
   
 
   
   
end subroutine 