Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

244 lines
14 KiB

  1. subroutine ROP_MainCalculation
  2. use SimulationVariables
  3. use sROP_Other_Variables
  4. use sROP_Variables
  5. use CStringConfigurationVariables
  6. use CformationVariables
  7. ! use CSimulationVariables
  8. use CDataDisplayConsole
  9. use SimulationVariables
  10. use CDrillingConsoleVariables
  11. use SimulationVariables
  12. use SimulationVariables
  13. use CmudPropertiesVariables
  14. use CHoistingVariables
  15. use SimulationVariables
  16. ! use CDrillingConsole
  17. use SimulationVariables !@
  18. use SimulationVariables !@, only: RTable
  19. use TD_DrillStemComponents
  20. use SimulationVariables !@
  21. use PressureDisplayVARIABLESModule
  22. USE MudSystemVARIABLES
  23. use SimulationVariables !@@@
  24. USE FricPressDropVarsModule
  25. use CReservoirVariables
  26. use CWarnings
  27. ! use ConfigurationVariables, only: TDS
  28. use SimulationVariables !@
  29. implicit none
  30. Integer :: i , zero_ROPcount
  31. !Real(8) :: data%State%ROP_Bit%SetROPGauge
  32. zero_ROPcount = 0
  33. data%State%ROP_Bit%NoOfFormations = data%Configuration%Formation%Count
  34. data%State%ROP_Bit%DrillingVerticalDepth = data%State%TD_WellGeneral%WellTotalVerticalLength
  35. !===> MaximumWellDepthExceeded Warning
  36. if ( data%State%ROP_Bit%DrillingVerticalDepth>=(data%Configuration%Formation%Formations(data%Configuration%Formation%Count)%Top+data%Configuration%Formation%Formations(data%Configuration%Formation%Count)%Thickness) ) then
  37. data%State%ROP_Bit%RateOfPenetration = 0.0d0
  38. Call Set_ROP(data%State%ROP_Bit%RateOfPenetration)
  39. Call Activate_MaximumWellDepthExceeded()
  40. return
  41. end if
  42. !=====================================
  43. if ( data%State%ROP_Spec%FormationNumber/=0 .and. data%Equipments%DrillingConsole%HideDrillingBrake==1 ) then ! Hide Drilling Brake Mode
  44. data%State%ROP_Spec%FormationNumber = data%State%ROP_Spec%FormationNumber
  45. else
  46. do i= 1,data%State%ROP_Bit%NoOfFormations
  47. data%State%ROP_Spec%FormationTopDepth = data%Configuration%Formation%Formations(i)%Top
  48. if (data%State%ROP_Bit%DrillingVerticalDepth>=data%State%ROP_Spec%FormationTopDepth) then
  49. data%State%ROP_Spec%FormationNumber = i
  50. end if
  51. end do
  52. end if
  53. !!===> Hide Drilling Brake Mode
  54. !if ( data%State%ROP_Spec%FormationNumber==FormationNo .and. HideDrillingBrake==1 ) then !????????????
  55. ! data%State%ROP_Spec%FormationNumber = FormationNo-1
  56. !end if
  57. !!=============================
  58. !data%State%ROP_Spec%BitClass = BitDefinition%BitCode !????????????
  59. call Bit_Specification
  60. ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$$** Variables Initialization: *$$$$$**$$$$$**$$$$$**$$$$$**$$$$$
  61. data%State%ROP_Spec%DiameterOfBit = data%Configuration%StringConfiguration%BitDefinition%BitSize ! unit : [in.] (Typical Range: 3.0 to 30.0)
  62. data%State%ROP_Spec%NumberOfBitNozzles = data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo ! (Typical Values: 1 to 10)
  63. data%State%ROP_Spec%DiameterOfBitNozzle = data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize ! unit : [inch] *** basic input: [1/32 in.] (Typical Range: 8.0 to 32.0)
  64. data%State%ROP_Spec%CriticalMudDensity = data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%PorePressureGradient/.465d0*9.d0 ! ????????? delete ,unit : [ppg] or [lb/gal] (Typical Range: 0 to 10.0)
  65. data%State%ROP_Bit%FormationMudDensity = data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%PorePressureGradient/0.052d0
  66. data%State%ROP_Bit%BottomHolePressure = data%State%PressureDisplay%PressureGauges(3) !5200 [psi]
  67. data%State%ROP_Bit%ECD = data%State%ROP_Bit%BottomHolePressure/(0.052*data%State%ROP_Bit%DrillingVerticalDepth)
  68. data%State%ROP_Spec%CriticalWeightOnBit = (data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%ThresholdWeight/5.d0)-(.06d0*(data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%ThresholdWeight-10.d0)) ! unit : [klb/in] (Typical Range: 0 to 10 ----> 0.6 to 2)
  69. !IF (ALLOCATED(FlowEl)) THEN
  70. ! data%State%ROP_Bit%MudViscosity = FlowEl(NoHorizontalEl + NoStringEl)%mueff !13.5 [cP]
  71. data%State%ROP_Bit%MudDensity = data%State%MudSystem%BitMudDensity ! [ppg]
  72. !ELSE
  73. data%State%ROP_Bit%MudViscosity = 13.5 ! [cP]
  74. !data%State%ROP_Bit%MudDensity = 9.2 ! [ppg]
  75. !END IF
  76. data%State%ROP_Bit%MudFlowrate = data%State%MudSystem%StringFlowRateFinal ! [gpm]
  77. data%State%ROP_Spec%ReynoldsNumber = data%State%ROP_Bit%MudFlowrate*data%State%ROP_Bit%MudDensity/(data%State%ROP_Bit%MudViscosity*data%State%ROP_Spec%NumberOfBitNozzles*data%State%ROP_Spec%DiameterOfBitNozzle) ! unit : [dimensionless] (Typical Range: 0.1 to 1000.0)
  78. ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$ End of Variable Initialization $$$$$**$$$$$**$$$$$**$$$$$**$$$$$
  79. ! -----**-----**-----**-----**-----* data%State%ROP_Bit%RateofPenetration Model Coefficients: *-----**-----**-----**-----**-----
  80. data%State%ROP_Spec%a1 = log(data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%Drillablity)
  81. data%State%ROP_Spec%a2 = 1.2799d-04
  82. data%State%ROP_Spec%a3 = 1.7952d-04
  83. data%State%ROP_Spec%a4 = 4.0656d-05
  84. data%State%ROP_Spec%a5 = 2.9021d-01
  85. data%State%ROP_Spec%a6 = 9.4882d-02
  86. data%State%ROP_Spec%a7 = 2.1837d-01
  87. data%State%ROP_Spec%a8 = 4.4915d-01
  88. data%State%ROP_Spec%dt = 0.1d0 ![s]
  89. data%State%ROP_Spec%TouH = data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%Abrasiveness*3600.d0 ! [hr]--->[s] ( Typical Range: 1<Abrasiveness<100 )
  90. ! -----**-----**-----**-----**--- End of data%State%ROP_Bit%RateofPenetration Model Coefficients ---**-----**-----**-----**-----
  91. ! $$$$$**$$$$$**$$$$$**$$$$$**$$$$$** Main Calculations: *$$$$$**$$$$$**$$$$$**$$$$$**$$$$$
  92. data%State%ROP_Spec%f1 = data%Configuration%Formation%Formations(data%State%ROP_Spec%FormationNumber)%Drillablity ! 1<=Drillability<=100 [ft/h]
  93. data%State%ROP_Spec%f2 = exp(2.303d0*data%State%ROP_Spec%a2*(10000.d0 - data%State%ROP_Bit%DrillingVerticalDepth)) ! First Compaction Vairable
  94. data%State%ROP_Spec%f3 = exp(2.303d0*data%State%ROP_Spec%a3*(data%State%ROP_Bit%DrillingVerticalDepth**0.69d0)*(data%State%ROP_Bit%FormationMudDensity-9.d0)) ! Second Compaction Vairable
  95. if ( (2.303d0*data%State%ROP_Spec%a4*data%State%ROP_Bit%DrillingVerticalDepth*(data%State%ROP_Bit%FormationMudDensity-data%State%ROP_Bit%ECD))>=0.d0 ) then
  96. data%State%ROP_Spec%f4 = exp(2.303d0*data%State%ROP_Spec%a4*data%State%ROP_Bit%DrillingVerticalDepth*(data%State%ROP_Bit%FormationMudDensity-data%State%ROP_Bit%ECD)) ! Underbalance Drilling Variable
  97. else
  98. data%State%ROP_Spec%f4 = 1.0d0
  99. end if
  100. if (data%State%TD_String%WeightOnBit>0.d0) then
  101. data%State%ROP_Bit%WeightOnBit = data%State%TD_String%WeightOnBit/1000.d0 ![klb]
  102. else
  103. data%State%ROP_Bit%WeightOnBit = 0.d0
  104. end if
  105. if ( (data%State%ROP_Bit%WeightOnBit/data%State%ROP_Spec%DiameterOfBit)<data%State%ROP_Spec%CriticalWeightOnBit ) then
  106. data%State%ROP_Spec%f5 = 0.0d0
  107. else
  108. data%State%ROP_Spec%f5 = ( ((data%State%ROP_Bit%WeightOnBit/data%State%ROP_Spec%DiameterOfBit)-data%State%ROP_Spec%CriticalWeightOnBit)/(4.d0-data%State%ROP_Spec%CriticalWeightOnBit) )**data%State%ROP_Spec%a5
  109. end if
  110. if (data%Configuration%Hoisting%DriveType==1 .and. data%State%RTable%Speed>0.d0) then
  111. data%State%ROP_Bit%RotarySpeed = data%State%RTable%Speed ![rpm]
  112. else if (data%Configuration%Hoisting%DriveType==0 .and. (data%State%TDS%Speed>0. .or. data%State%RTable%Speed>0.)) then
  113. data%State%ROP_Bit%RotarySpeed = data%State%TDS%Speed+data%State%RTable%Speed ![rpm]
  114. else
  115. data%State%ROP_Bit%RotarySpeed = 0.0d0
  116. end if
  117. data%State%ROP_Spec%f6 = (data%State%ROP_Bit%RotarySpeed/100.d0)**data%State%ROP_Spec%a6
  118. data%State%ROP_Spec%f7 = exp(-data%State%ROP_Spec%a7*data%State%ROP_Bit%BitWearing)
  119. Call JetImpactForce
  120. data%State%ROP_Spec%f8 = data%State%ROP_Bit%JetImpactForce/1000.d0
  121. data%State%ROP_Bit%RateOfPenetration = (data%State%ROP_Spec%f1*data%State%ROP_Spec%f2*data%State%ROP_Spec%f3*data%State%ROP_Spec%f4*data%State%ROP_Spec%f5*data%State%ROP_Spec%f6*data%State%ROP_Spec%f7*data%State%ROP_Spec%f8) ![ft/h]
  122. data%State%ROP_Bit%RateOfPenetration = (DINT(data%State%ROP_Bit%RateOfPenetration*10.d0))/10.d0
  123. if ( (data%State%TD_WellGeneral%WellTotalLength==data%Configuration%Path%Items(data%Configuration%Path%ItemCount)%MeasuredDepth) ) then
  124. data%State%ROP_Bit%SetROPGauge = data%State%ROP_Bit%RateOfPenetration
  125. Call Set_ROP(data%State%ROP_Bit%SetROPGauge) ![ft/h]
  126. data%State%ROP_Bit%OldROPValue(4) = data%State%ROP_Bit%RateOfPenetration
  127. !if(print_log) print* , 'first rop=' , data%State%ROP_Bit%OldROPValue , data%State%ROP_Bit%RateOfPenetration ,&
  128. ! zero_ROPcount , data%State%ROP_Bit%SetROPGauge , data%State%ROP_Bit%OldROPDepth , data%State%TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth
  129. else if ( ((data%State%TD_WellGeneral%WellTotalLength+(data%State%ROP_Bit%RateOfPenetration*data%State%TD_General%TimeStep/3600.d0))-data%State%ROP_Bit%OldROPDepth)>=0.1 ) then
  130. do i= 1,4
  131. if ( data%State%ROP_Bit%OldROPValue(i)==0. ) then
  132. zero_ROPcount = zero_ROPcount+1
  133. end if
  134. end do
  135. data%State%ROP_Bit%SetROPGauge = (data%State%ROP_Bit%RateOfPenetration+data%State%ROP_Bit%OldROPValue(1)+data%State%ROP_Bit%OldROPValue(2)+data%State%ROP_Bit%OldROPValue(3)+data%State%ROP_Bit%OldROPValue(4))/sngl(5-zero_ROPcount)
  136. Call Set_ROP(data%State%ROP_Bit%SetROPGauge) ![ft/h]
  137. do i= 2,4
  138. data%State%ROP_Bit%OldROPValue(i-1) = data%State%ROP_Bit%OldROPValue(i)
  139. end do
  140. data%State%ROP_Bit%OldROPValue(4) = data%State%ROP_Bit%RateOfPenetration
  141. data%State%ROP_Bit%OldROPDepth = data%State%TD_WellGeneral%WellTotalLength+(data%State%ROP_Bit%RateOfPenetration*data%State%TD_General%TimeStep/3600.d0)
  142. !if(print_log) print* , 'new rop=' , data%State%ROP_Bit%OldROPValue , data%State%ROP_Bit%RateOfPenetration ,&
  143. ! zero_ROPcount , data%State%ROP_Bit%SetROPGauge , data%State%ROP_Bit%OldROPDepth , data%State%TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth
  144. else
  145. Call Set_ROP(data%State%ROP_Bit%SetROPGauge) ![ft/h]
  146. !if(print_log) print* , 'old rop=' , data%State%ROP_Bit%OldROPValue , data%State%ROP_Bit%RateOfPenetration ,&
  147. ! zero_ROPcount , data%State%ROP_Bit%SetROPGauge , data%State%ROP_Bit%OldROPDepth , data%State%TD_WellGeneral%WellTotalLength , PathGenerations(PathGenerationCount)%MeasuredDepth
  148. end if
  149. if (data%State%ROP_Bit%RotarySpeed > 0.d0) THEN
  150. data%State%ROP_Bit%BitTorque = ( 3.79d0 + 19.17d0*sqrt( data%State%ROP_Bit%RateOfPenetration / (data%State%ROP_Bit%RotarySpeed*data%State%ROP_Spec%DiameterOfBit)) ) * data%State%ROP_Spec%DiameterOfBit * data%State%ROP_Bit%WeightOnBit * ( 1.d0 / ( 1.d0 + 0.00021d0*data%State%ROP_Bit%DrillingVerticalDepth) )
  151. !data%State%ROP_Bit%BitTorque = data%State%ROP_Bit%BitTorque/3. !bi dalil taghsim bar 3 shode(chon adad bozorg bude), baadan az rabete check shavad (seyyed gofte)
  152. else
  153. data%State%ROP_Bit%BitTorque = 0.d0
  154. end if
  155. if ( (data%State%ROP_Bit%WeightOnBit/data%State%ROP_Spec%DiameterOfBit)<(data%State%ROP_Spec%wdmax) ) then
  156. data%State%ROP_Bit%BitWearing = data%State%ROP_Bit%BitWearing +( (data%State%ROP_Spec%dt*data%State%ROP_Spec%H3/data%State%ROP_Spec%TouH)*((data%State%ROP_Bit%RotarySpeed/100.d0)**data%State%ROP_Spec%H1)*((data%State%ROP_Spec%wdmax-4.d0)/(data%State%ROP_Spec%wdmax-(data%State%ROP_Bit%WeightOnBit/data%State%ROP_Spec%DiameterOfBit)))*((1.d0+(data%State%ROP_Spec%H2/2.d0))/(1.d0+(data%State%ROP_Spec%H2*data%State%ROP_Bit%BitWearing))) )
  157. else
  158. data%State%ROP_Bit%BitWearing = 1.0d0 !( Typical Range: 0<=data%State%ROP_Bit%BitWearing<=1 )
  159. end if
  160. data%State%ROP_Bit%BearingWear = data%State%ROP_Bit%BearingWear+(data%State%ROP_Spec%dt/3600.d0)*(data%State%ROP_Bit%RotarySpeed/100.d0/data%State%ROP_Spec%BrCoef)*((data%State%ROP_Bit%WeightOnBit/4.d0/data%State%ROP_Spec%DiameterOfBit)**1.5d0)
  161. !if(print_log) print*, 'data%State%ROP_Bit%RateOfPenetration=', data%State%ROP_Bit%RateOfPenetration
  162. !!if(print_log) print*, 'data%State%ROP_Bit%FormationMudDensity=', data%State%ROP_Bit%FormationMudDensity
  163. !!if(print_log) print*, 'data%State%ROP_Bit%ECD=', data%State%ROP_Bit%ECD
  164. !!if(print_log) print*, 'data%State%ROP_Bit%DrillingVerticalDepth=', data%State%ROP_Bit%DrillingVerticalDepth
  165. !!if(print_log) print*, 'power=', (2.303*data%State%ROP_Spec%a4*data%State%ROP_Bit%DrillingVerticalDepth*(data%State%ROP_Bit%FormationMudDensity-data%State%ROP_Bit%ECD))
  166. !if(print_log) print*, 'data%State%ROP_Bit%RotarySpeed=', data%State%ROP_Bit%RotarySpeed
  167. !!
  168. !if(print_log) print*, 'data%State%ROP_Spec%f1=', data%State%ROP_Spec%f1
  169. !if(print_log) print*, 'data%State%ROP_Spec%f2=', data%State%ROP_Spec%f2
  170. !if(print_log) print*, 'data%State%ROP_Spec%f3=', data%State%ROP_Spec%f3
  171. !if(print_log) print*, 'data%State%ROP_Spec%f4=', data%State%ROP_Spec%f4
  172. !if(print_log) print*, 'data%State%ROP_Spec%f5=', data%State%ROP_Spec%f5
  173. !if(print_log) print*, 'data%State%ROP_Spec%f6=', data%State%ROP_Spec%f6
  174. !if(print_log) print*, 'data%State%ROP_Spec%f7=', data%State%ROP_Spec%f7
  175. !if(print_log) print*, 'data%State%ROP_Spec%f8=', data%State%ROP_Spec%f8
  176. !if(print_log) print*, '***********************'
  177. end subroutine