Simulation Core
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

246 Zeilen
14 KiB

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