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.

TopDrive_Solver.f90 12 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. subroutine TopDrive_Solver
  2. Use TopDrive_VARIABLES
  3. Use CTdsConnectionModesEnumVariables
  4. IMPLICIT NONE
  5. TDS%TDS_wOld = ((pi*TDS%Speed)/30.d0) ![rad/s]
  6. !******************************************************************
  7. if ( TDS%PowerState==-1 .or. TDS%OldPowerMode==-1 ) then !FWD
  8. if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE
  9. TDS%OperationFaultLed = 0
  10. TDS%Speed = 0.d0 !Speed [RPM]
  11. TDS%RpmGaugeOutput = 30.d0
  12. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  13. TDS%SoundRPM = 30
  14. TDS%Torque = 0.d0 ![ft.lbf]
  15. TDS%TorqueGaugeOutput = 0.d0
  16. TDS%OldPowerMode = -1
  17. else if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE
  18. TDS%OperationFaultLed = 0
  19. TDS%Speed = 0.d0 !Speed [RPM]
  20. TDS%RpmGaugeOutput = TDS%Speed
  21. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  22. TDS%SoundRPM = 0
  23. TDS%Torque = 0.d0 ![ft.lbf]
  24. TDS%TorqueGaugeOutput = 1000.d0
  25. TDS%OldPowerMode = -1
  26. else if ( TDS%DrillTorqueState==1 ) then ! TdsMu_Torque
  27. if ( TDS%RpmKnob>0. ) then
  28. TDS%OperationFaultLed = 1
  29. TDS%Speed = 0.d0 !Speed [RPM]
  30. TDS%RpmGaugeOutput = TDS%Speed
  31. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  32. TDS%SoundRPM = 0
  33. TDS%Torque = 0.d0 ![ft.lbf]
  34. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  35. TDS%OldPowerMode = -1
  36. else
  37. TDS%OperationFaultLed = 0
  38. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  39. TDS%Speed = 0.d0 !Speed [RPM]
  40. TDS%RpmGaugeOutput = TDS%Speed
  41. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  42. TDS%SoundRPM = 0
  43. TDS%Torque = 0.d0 ![ft.lbf]
  44. TDS%TorqueGaugeOutput = max( 1000.d0,((TDS%TorqueLimitKnob/10.d0)*60000.d0) ) ![ft.lbf] ????
  45. TDS%OldPowerMode = -1
  46. else if ( Get_TdsConnectionModes()==Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  47. TDS%Speed = 0.d0 !Speed [RPM]
  48. TDS%RpmGaugeOutput = TDS%Speed
  49. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  50. TDS%SoundRPM = 0
  51. TDS%Torque = 0.d0 ![ft.lbf]
  52. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  53. TDS%OldPowerMode = -1
  54. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  55. TDS%Speed = 0.d0 !Speed [RPM]
  56. TDS%RpmGaugeOutput = TDS%Speed
  57. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  58. TDS%SoundRPM = 0
  59. TDS%Torque = 0.d0 ![ft.lbf]
  60. TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf]
  61. TDS%OldPowerMode = -1
  62. end if
  63. end if
  64. else if ( TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL
  65. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  66. TDS%OperationFaultLed = 0
  67. TDS%Speed = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM]
  68. TDS%Speed = min(TDS%Speed,TDS%MaxRPM)
  69. TDS%RpmGaugeOutput = TDS%Speed
  70. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  71. TDS%SoundRPM = INT(TDS%Speed)
  72. TDS%Torque = ( ((TDS%J_coef+TDS%String_JCoef)*(((((pi*TDS%N_ref)/30.d0)/TDS%Conv_Ratio)-TDS%TDS_wOld)/TDS%time_step))+(TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf]
  73. TDS%Torque = min(TDS%Torque,TDS%MaxTorque) ! [ft.lbf]
  74. TDS%TorqueGaugeOutput = TDS%Torque
  75. TDS%OldPowerMode = -1
  76. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  77. TDS%OperationFaultLed = 0
  78. TDS%Speed = 0.0d0
  79. TDS%RpmGaugeOutput = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM]
  80. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  81. TDS%SoundRPM = INT(TDS%N_ref/TDS%Conv_Ratio)
  82. TDS%Torque = 0.0d0
  83. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  84. TDS%OldPowerMode = -1
  85. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  86. if ( TDS%RpmKnob>0. ) then
  87. TDS%OperationFaultLed = 1
  88. TDS%Speed = 0.d0 !Speed [RPM]
  89. TDS%RpmGaugeOutput = TDS%Speed
  90. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  91. TDS%SoundRPM = 0
  92. TDS%Torque = 0.d0 ![ft.lbf]
  93. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  94. TDS%OldPowerMode = -1
  95. else
  96. TDS%OperationFaultLed = 0
  97. TDS%Speed = 0.d0 !Speed [RPM]
  98. TDS%RpmGaugeOutput = TDS%Speed
  99. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  100. TDS%SoundRPM = 0
  101. TDS%Torque = 0.d0 ![ft.lbf]
  102. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  103. TDS%OldPowerMode = -1
  104. end if
  105. end if
  106. else
  107. TDS%OperationFaultLed = 0
  108. TDS%Speed = 0.d0 !Speed [RPM]
  109. TDS%RpmGaugeOutput = TDS%Speed
  110. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  111. TDS%SoundRPM = 0
  112. TDS%Torque = 0.d0 ![ft.lbf]
  113. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  114. TDS%OldPowerMode = -1
  115. end if
  116. else if ( TDS%PowerState==1 .or. TDS%OldPowerMode==1 ) then !REV
  117. if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then ! TdsMu_SPINE
  118. TDS%OperationFaultLed = 0
  119. TDS%Speed = 0.d0 !Speed [RPM]
  120. TDS%RpmGaugeOutput = 30.d0
  121. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  122. TDS%SoundRPM = 30
  123. TDS%Torque = 0.d0 ![ft.lbf]
  124. TDS%TorqueGaugeOutput = 0.d0
  125. TDS%OldPowerMode = 1
  126. else if ( TDS%DrillTorqueState==0 .and. Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then ! TdsMu_SPINE
  127. TDS%OperationFaultLed = 0
  128. TDS%Speed = 0.d0 !Speed [RPM]
  129. TDS%RpmGaugeOutput = 30.d0
  130. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  131. TDS%SoundRPM = 0
  132. TDS%Torque = 0.d0 ![ft.lbf]
  133. TDS%TorqueGaugeOutput = 1000.d0
  134. TDS%OldPowerMode = 1
  135. else if ( TDS%DrillTorqueState==1 ) then ! TdsMu_Torque
  136. if ( TDS%RpmKnob>0.d0 ) then
  137. TDS%OperationFaultLed = 1
  138. TDS%Speed = 0.d0 !Speed [RPM]
  139. TDS%RpmGaugeOutput = TDS%Speed
  140. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  141. TDS%SoundRPM = 0
  142. TDS%Torque = 0.d0 ![ft.lbf]
  143. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  144. TDS%OldPowerMode = 1
  145. else
  146. TDS%OperationFaultLed = 0
  147. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  148. TDS%Speed = 0.d0 !Speed [RPM]
  149. TDS%RpmGaugeOutput = TDS%Speed
  150. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  151. TDS%SoundRPM = 0
  152. TDS%Torque = 0.d0 ![ft.lbf]
  153. TDS%TorqueGaugeOutput = 2000.d0
  154. TDS%OldPowerMode = 1
  155. else if ( Get_TdsConnectionModes()==Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  156. TDS%Speed = 0.d0 !Speed [RPM]
  157. TDS%RpmGaugeOutput = TDS%Speed
  158. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  159. TDS%SoundRPM = 0
  160. TDS%Torque = 0.d0 ![ft.lbf]
  161. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  162. TDS%OldPowerMode = 1
  163. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  164. TDS%Speed = 0.d0 !Speed [RPM]
  165. TDS%RpmGaugeOutput = TDS%Speed
  166. TDS%RPMUnityOutput = TDS%RpmGaugeOutput
  167. TDS%SoundRPM = 0
  168. TDS%Torque = 0.d0 ![ft.lbf]
  169. TDS%TorqueGaugeOutput = 1000.d0 ![ft.lbf]
  170. TDS%OldPowerMode = -1
  171. end if
  172. end if
  173. else if ( TDS%DrillTorqueState==-1 ) then ! TdsMu_DRILL
  174. if ( Get_TdsConnectionModes()==TDS_CONNECTION_STRING ) then
  175. TDS%OperationFaultLed = 0
  176. TDS%Speed = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM]
  177. TDS%Speed = min(TDS%Speed,TDS%MaxRPM)
  178. TDS%RpmGaugeOutput = TDS%Speed
  179. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  180. TDS%SoundRPM = INT(TDS%Speed)
  181. TDS%Torque = ( ((TDS%J_coef+TDS%String_JCoef)*(((((pi*TDS%N_ref)/30.d0)/TDS%Conv_Ratio)-TDS%TDS_wOld)/TDS%time_step))+(TDS%String_Torque) )*0.73756215d0 ![N.m]*0.73756215 = [ft.lbf]
  182. TDS%Torque = min(TDS%Torque,TDS%MaxTorque) ! [ft.lbf]
  183. TDS%TorqueGaugeOutput = TDS%Torque
  184. TDS%OldPowerMode = 1
  185. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_NOTHING ) then
  186. TDS%OperationFaultLed = 0
  187. TDS%Speed = 0.0d0
  188. TDS%RpmGaugeOutput = TDS%N_ref/TDS%Conv_Ratio !Speed [RPM]
  189. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  190. TDS%SoundRPM = INT(TDS%N_ref/TDS%Conv_Ratio)
  191. TDS%Torque = 0.0d0
  192. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  193. TDS%OldPowerMode = 1
  194. else if ( Get_TdsConnectionModes()==TDS_CONNECTION_SPINE ) then
  195. if ( TDS%RpmKnob>0. ) then
  196. TDS%OperationFaultLed = 1
  197. TDS%Speed = 0.d0 !Speed [RPM]
  198. TDS%RpmGaugeOutput = TDS%Speed
  199. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  200. TDS%SoundRPM = 0
  201. TDS%Torque = 0.d0 ![ft.lbf]
  202. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  203. TDS%OldPowerMode = 1
  204. else
  205. TDS%OperationFaultLed = 0
  206. TDS%Speed = 0.d0 !Speed [RPM]
  207. TDS%RpmGaugeOutput = TDS%Speed
  208. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  209. TDS%SoundRPM = 0
  210. TDS%Torque = 0.d0 ![ft.lbf]
  211. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  212. TDS%OldPowerMode = 1
  213. end if
  214. end if
  215. else
  216. TDS%OperationFaultLed = 0
  217. TDS%Speed = 0.d0 !Speed [RPM]
  218. TDS%RpmGaugeOutput = TDS%Speed
  219. TDS%RPMUnityOutput = -TDS%RpmGaugeOutput
  220. TDS%SoundRPM = 0
  221. TDS%Torque = 0.d0 ![ft.lbf]
  222. TDS%TorqueGaugeOutput = 0.d0 ![ft.lbf]
  223. TDS%OldPowerMode = 1
  224. end if
  225. end if
  226. !******************************************************************
  227. END subroutine