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.

PumpsMain.f90 35 KiB

1 年之前
1 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. module PumpsMain
  2. use SimulationVariables
  3. implicit none
  4. public
  5. contains
  6. ! ****************************************
  7. ! ***** subroutine Pump1MainBody *****
  8. ! ****************************
  9. ! subroutine Pump1_Setup()
  10. ! use CSimulationVariables
  11. ! implicit none
  12. ! call OnSimulationInitialization%Add(Pump1_Init)
  13. ! call OnSimulationStop%Add(Pump1_Init)
  14. ! call OnPump1Step%Add(Pump1_Step)
  15. ! call OnPump1Output%Add(Pump1_Output)
  16. ! call OnPump1Main%Add(Pump1MainBody)
  17. ! end subroutine
  18. subroutine Pump1_Init
  19. Call Pumps_StartUp
  20. end subroutine Pump1_Init
  21. subroutine Pump1_Step
  22. Call Pump1_MainSolver
  23. end subroutine Pump1_Step
  24. subroutine Pumps_MainSolver
  25. use SimulationVariables
  26. Implicit none
  27. Call DrillingConsole_ScrLEDs !koja bezaramesh?????
  28. Call Pumps_Inputs
  29. Call Pump1_MainSolver
  30. Call Pump2_MainSolver
  31. Call Pump3_MainSolver
  32. Call Pumps_TotalSolver
  33. Call Pumps_Outputs
  34. end subroutine Pumps_MainSolver
  35. subroutine Pumps_Inputs
  36. use CDrillingConsoleVariables
  37. use SimulationVariables
  38. Use MudSystemModule
  39. IMPLICIT NONE
  40. !>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  41. !data%State%Pump(1)%BlowPopOffMalf = 0 !??????? motaghayere voroudi
  42. if ( data%State%Pump(1)%BlowPopOffMalf==1 ) then ! Pump1 Malfunction ----> Blow Pop-offs (Relief Valves)
  43. data%State%Pump(1)%StandPipe_Pressure = 0.d0
  44. else
  45. data%State%Pump(1)%StandPipe_Pressure = PumpPressure1 ![psi]
  46. if ( data%State%Pump(1)%StandPipe_Pressure<=14.d0 ) then
  47. data%State%Pump(1)%StandPipe_Pressure = 14.d0
  48. end if
  49. end if
  50. data%State%Pump(1)%AssignmentSwitchh = data%Equipments%DrillingConsole%AssignmentSwitch
  51. data%State%Pump(1)%Switch = data%Equipments%DrillingConsole%MP1CPSwitch
  52. data%State%Pump(1)%Throttle = data%Equipments%DrillingConsole%MP1Throttle ![SPM] 0<MP1Throttle<data%State%Pump(1)%MaxSPM
  53. data%State%Pump(1)%Throttle = data%State%Pump(1)%Throttle*data%State%Pump(1)%Trans_Ratio ![RPM] 0<Pump(1)%Throttle<965 rpm
  54. !data%State%Pump(1)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump1 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad
  55. data%State%Pump(1)%Failure = data%Warnings%Pump1Failure !(Pump1 Warning ----> Failure)
  56. data%State%Pump(1)%N_new = data%State%Pump(1)%Throttle
  57. !>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  58. !data%State%Pump(2)%BlowPopOffMalf = 0 !??????? motaghayere voroudi
  59. if ( data%State%Pump(2)%BlowPopOffMalf==1 ) then ! Pump2 Malfunction ----> Blow Pop-offs (Relief Valves)
  60. data%State%Pump(2)%StandPipe_Pressure = 0.d0
  61. else
  62. data%State%Pump(2)%StandPipe_Pressure = PumpPressure2 ![psi]
  63. if ( data%State%Pump(2)%StandPipe_Pressure<=14.d0 ) then
  64. data%State%Pump(2)%StandPipe_Pressure = 14.d0
  65. end if
  66. end if
  67. data%State%Pump(2)%AssignmentSwitchh = data%Equipments%DrillingConsole%AssignmentSwitch
  68. data%State%Pump(2)%Switch = data%Equipments%DrillingConsole%MP2Switch
  69. data%State%Pump(2)%Throttle = data%Equipments%DrillingConsole%MP2Throttle ![SPM] 0<MP2Throttle<data%State%Pump(2)%MaxSPM
  70. data%State%Pump(2)%Throttle = data%State%Pump(2)%Throttle*data%State%Pump(2)%Trans_Ratio ![RPM] 0<Pump(2)%Throttle<965 rpm
  71. !data%State%Pump(2)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump2 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad
  72. data%State%Pump(2)%Failure = data%Warnings%Pump2Failure !(Pump2 Warning ----> Failure)
  73. data%State%Pump(2)%N_new = data%State%Pump(2)%Throttle
  74. !!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  75. !data%State%Pump(3)%BlowPopOffMalf = 0 !??????? motaghayere voroudi
  76. if ( data%State%Pump(3)%BlowPopOffMalf==1 ) then ! Pump3 Malfunction ----> Blow Pop-offs (Relief Valves)
  77. data%State%Pump(3)%StandPipe_Pressure = 0.d0
  78. else
  79. data%State%Pump(3)%StandPipe_Pressure = PumpPressure3 ![psi]
  80. if ( data%State%Pump(3)%StandPipe_Pressure<=14.d0 ) then
  81. data%State%Pump(3)%StandPipe_Pressure = 14.d0
  82. end if
  83. end if
  84. data%State%Pump(3)%Switch = data%Equipments%DrillingConsole%MP1CPSwitch
  85. data%State%Pump(3)%Throttle = data%Equipments%DrillingConsole%MP1Throttle ![SPM] 0<MP1Throttle<data%State%Pump(3)%MaxSPM
  86. data%State%Pump(3)%Throttle = data%State%Pump(3)%Throttle*data%State%Pump(3)%Trans_Ratio ![RPM] 0<Pump(3)%Throttle<965 rpm
  87. !data%State%Pump(3)%PowerFailMalf = 0 !??????? motaghayere voroudi (Pump3 Malfunction ----> Power Failure) !dar CPumpProblemsVariables meghdardehi mishavad
  88. data%State%Pump(3)%Failure = data%Warnings%Pump3Failure !(Pump1 Warning ----> Failure)
  89. data%State%Pump(3)%N_new = data%State%Pump(3)%Throttle
  90. !>>>>>>>>>>>>>>>>>>>>>>> Total Pumps <<<<<<<<<<<<<<<<<<<<<<<<<<<
  91. end subroutine Pumps_Inputs
  92. subroutine DrillingConsole_ScrLEDs
  93. use CDrillingConsoleVariables
  94. use SimulationVariables
  95. use SimulationVariables
  96. use SimulationVariables !@
  97. IMPLICIT NONE
  98. !===> Torque Limit
  99. data%Equipments%DrillingConsole%RTTorqueLimitGauge = sngl(1-data%State%RTable%TorqueLimitGaugeMalf)*(data%Equipments%DrillingConsole%RTTorqueLimitKnob/10.d0)*7000.d0 !tabdile bazeye 0-10 be 0-7000 taghribi anjam shode, baadan eslah shavad ??????
  100. if((any(data%Equipments%DrillingConsole%AssignmentSwitch==(/1,2,3,4,8,9,10,11/)))) then
  101. data%Equipments%DrillingConsole%SCR1LED=1
  102. data%Equipments%DrillingConsole%SCR2LED=1
  103. data%Equipments%DrillingConsole%SCR3LED=1
  104. data%Equipments%DrillingConsole%SCR4LED=1
  105. else if (data%Equipments%DrillingConsole%AssignmentSwitch == 5) then
  106. data%Equipments%DrillingConsole%SCR1LED=1
  107. data%Equipments%DrillingConsole%SCR2LED=1
  108. data%Equipments%DrillingConsole%SCR3LED=0
  109. data%Equipments%DrillingConsole%SCR4LED=1
  110. else if (data%Equipments%DrillingConsole%AssignmentSwitch == 7) then
  111. data%Equipments%DrillingConsole%SCR1LED=1
  112. data%Equipments%DrillingConsole%SCR2LED=1
  113. data%Equipments%DrillingConsole%SCR3LED=1
  114. data%Equipments%DrillingConsole%SCR4LED=0
  115. else
  116. data%Equipments%DrillingConsole%SCR1LED=0
  117. data%Equipments%DrillingConsole%SCR2LED=0
  118. data%Equipments%DrillingConsole%SCR3LED=0
  119. data%Equipments%DrillingConsole%SCR4LED=0
  120. end if
  121. end subroutine DrillingConsole_ScrLEDs
  122. subroutine Pump1_MainSolver
  123. use SimulationVariables
  124. Implicit none
  125. if (data%State%Pump(1)%Throttle<=0.d0) then
  126. data%State%Pump(1)%K_throttle = 1
  127. end if
  128. if((any(data%State%Pump(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (data%State%Pump(1)%Switch==-1) .and. (data%State%Pump(1)%K_throttle==1) .and. (data%State%Pump(1)%PowerFailMalf==0) .and. (data%State%Pump(1)%Failure==0)) then
  129. data%State%Pump(1)%SoundBlower = .true.
  130. data%State%Pump(1)%BLWR = 1
  131. !========================== Pump 1 Rate limit ==========================
  132. if (((data%State%Pump(1)%N_new-data%State%Pump(1)%N_old)/data%State%Pump(1)%time_step)>data%State%Pump(1)%RateChange) then
  133. data%State%Pump(1)%Speed =(data%State%Pump(1)%RateChange*data%State%Pump(1)%time_step)+data%State%Pump(1)%N_old ![RPM]
  134. else if (((data%State%Pump(1)%N_old-data%State%Pump(1)%N_new)/data%State%Pump(1)%time_step)>data%State%Pump(1)%RateChange) then
  135. data%State%Pump(1)%Speed = (-data%State%Pump(1)%RateChange*data%State%Pump(1)%time_step)+data%State%Pump(1)%N_old
  136. else
  137. data%State%Pump(1)%Speed = data%State%Pump(1)%N_new
  138. end if
  139. !=======================================================================
  140. Call Pump_OnMode_Solver(1)
  141. else
  142. if ((any(data%State%Pump(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (data%State%Pump(1)%Switch==-1)) then
  143. data%State%Pump(1)%SoundBlower = .true.
  144. else
  145. data%State%Pump(1)%SoundBlower = .false.
  146. end if
  147. if ((any(data%State%Pump(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (data%State%Pump(1)%Switch==-1) .and. (data%State%Pump(1)%PowerFailMalf==0) .and. (data%State%Pump(1)%Failure==0)) then
  148. data%State%Pump(1)%BLWR = 1
  149. else
  150. data%State%Pump(1)%BLWR = 0
  151. end if
  152. Call Pump_OffMode_Solver(1)
  153. data%State%Pump(1)%K_throttle = 0
  154. end if
  155. data%State%Pump(1)%N_old = data%State%Pump(1)%Speed
  156. end subroutine Pump1_MainSolver
  157. subroutine Pump2_MainSolver
  158. use SimulationVariables
  159. Implicit none
  160. if (data%State%Pump(2)%Throttle<=0.d0) then
  161. data%State%Pump(2)%K_throttle = 1
  162. end if
  163. if((any(data%State%Pump(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (data%State%Pump(2)%Switch==-1) .and. (data%State%Pump(2)%K_throttle==1) .and. (data%State%Pump(2)%PowerFailMalf==0) .and. (data%State%Pump(2)%Failure==0)) then
  164. data%State%Pump(2)%SoundBlower = .true.
  165. data%State%Pump(2)%BLWR = 1
  166. !========================== Pump 2 Rate limit ==========================
  167. if (((data%State%Pump(2)%N_new-data%State%Pump(2)%N_old)/data%State%Pump(2)%time_step)>data%State%Pump(2)%RateChange) then
  168. data%State%Pump(2)%Speed =(data%State%Pump(2)%RateChange*data%State%Pump(2)%time_step)+data%State%Pump(2)%N_old ![RPM]
  169. else if (((data%State%Pump(2)%N_old-data%State%Pump(2)%N_new)/data%State%Pump(2)%time_step)>data%State%Pump(2)%RateChange) then
  170. data%State%Pump(2)%Speed = (-data%State%Pump(2)%RateChange*data%State%Pump(2)%time_step)+data%State%Pump(2)%N_old
  171. else
  172. data%State%Pump(2)%Speed = data%State%Pump(2)%N_new
  173. end if
  174. !=======================================================================
  175. Call Pump_OnMode_Solver(2)
  176. else
  177. if ((any(data%State%Pump(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (data%State%Pump(2)%Switch==-1)) then
  178. data%State%Pump(2)%SoundBlower = .true.
  179. else
  180. data%State%Pump(2)%SoundBlower = .false.
  181. end if
  182. if ((any(data%State%Pump(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (data%State%Pump(2)%Switch==-1) .and. (data%State%Pump(2)%PowerFailMalf==0) .and. (data%State%Pump(2)%Failure==0)) then
  183. data%State%Pump(2)%BLWR = 1
  184. else
  185. data%State%Pump(2)%BLWR = 0
  186. end if
  187. Call Pump_OffMode_Solver(2)
  188. data%State%Pump(2)%K_throttle = 0
  189. end if
  190. data%State%Pump(2)%N_old = data%State%Pump(2)%Speed
  191. end subroutine Pump2_MainSolver
  192. subroutine Pump3_MainSolver
  193. use SimulationVariables
  194. Implicit none
  195. if (data%State%Pump(3)%Throttle<=0.d0) then
  196. data%State%Pump(3)%K_throttle = 1
  197. end if
  198. if((data%State%Pump(3)%Switch==1) .and. (data%State%Pump(3)%K_throttle==1) .and. (data%State%Pump(3)%PowerFailMalf==0) .and. (data%State%Pump(3)%Failure==0)) then
  199. !========================== Pump 3 Rate limit ==========================
  200. if (((data%State%Pump(3)%N_new-data%State%Pump(3)%N_old)/data%State%Pump(3)%time_step)>data%State%Pump(3)%RateChange) then
  201. data%State%Pump(3)%Speed =(data%State%Pump(3)%RateChange*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old ![RPM]
  202. else if (((data%State%Pump(3)%N_old-data%State%Pump(3)%N_new)/data%State%Pump(3)%time_step)>data%State%Pump(3)%RateChange) then
  203. data%State%Pump(3)%Speed = (-data%State%Pump(3)%RateChange*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old
  204. else
  205. data%State%Pump(3)%Speed = data%State%Pump(3)%N_new
  206. end if
  207. !=======================================================================
  208. Call Pump_OnMode_Solver(3)
  209. else
  210. Call Pump_OffMode_Solver(3)
  211. data%State%Pump(3)%K_throttle = 0
  212. end if
  213. data%State%Pump(3)%N_old = data%State%Pump(3)%Speed
  214. end subroutine Pump3_MainSolver
  215. subroutine Pumps_TotalSolver
  216. use SimulationVariables
  217. Implicit none
  218. data%Equipments%MPumps%Total_Pump_Gpm = data%State%Pump(1)%Flow_Rate+data%State%Pump(2)%Flow_Rate+data%State%Pump(3)%Flow_Rate ![gpm]
  219. data%Equipments%MPumps%Total_Pump_SPM = (data%State%Pump(1)%Speed/data%State%Pump(1)%Trans_Ratio)+(data%State%Pump(2)%Speed/data%State%Pump(2)%Trans_Ratio)+(data%State%Pump(3)%Speed/data%State%Pump(3)%Trans_Ratio) ![stk/min]
  220. end subroutine Pumps_TotalSolver
  221. subroutine Pumps_Outputs
  222. use CDataDisplayConsole
  223. use SimulationVariables
  224. Use MudSystemModule
  225. Use CSounds
  226. IMPLICIT NONE
  227. !>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  228. If (data%State%Pump(1)%Open_Close==1) then
  229. Call OpenPump1()
  230. Else if (data%State%Pump(1)%Open_Close==0) then
  231. Call ClosePump1()
  232. End if
  233. data%Equipments%DrillingConsole%MP1BLWR = data%State%Pump(1)%BLWR
  234. Call SetSoundBlowerMP1( data%State%Pump(1)%SoundBlower ) !.true. or .false.
  235. Call SetSoundMP1( data%State%Pump(1)%SoundSPM ) ![SPM] , integer
  236. if ((data%State%Pump(1)%Switch==-1) .or. (data%State%Pump(1)%Switch==0)) then
  237. Call Set_MP1SPMGauge( sngl(1-data%State%Pump(1)%SPMGaugeMalf)*real((data%State%Pump(1)%Speed/data%State%Pump(1)%Trans_Ratio),8) ) ![spm] , real
  238. data%Equipments%DrillingWatch%SPM1 = data%Equipments%DataDisplayConsole%MP1SPMGauge
  239. end if
  240. !data%State%Pump(1)%Flow_Rate !to other modules , [gpm]
  241. !>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  242. If (data%State%Pump(2)%Open_Close==1) then
  243. Call OpenPump2()
  244. Else if (data%State%Pump(2)%Open_Close==0) then
  245. Call ClosePump2()
  246. End if
  247. data%Equipments%DrillingConsole%MP2BLWR = data%State%Pump(2)%BLWR
  248. Call SetSoundBlowerMP2( data%State%Pump(2)%SoundBlower )
  249. Call SetSoundMP2( data%State%Pump(2)%SoundSPM ) ![SPM]
  250. Call Set_MP2SPMGauge( sngl(1-data%State%Pump(2)%SPMGaugeMalf)*real((data%State%Pump(2)%Speed/data%State%Pump(2)%Trans_Ratio),8) ) ![SPM]
  251. data%Equipments%DrillingWatch%SPM2 = data%Equipments%DataDisplayConsole%MP2SPMGauge
  252. !data%State%Pump(2)%Flow_Rate !to other modules
  253. !!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  254. If (data%State%Pump(3)%Open_Close==1) then
  255. Call OpenCementPump()
  256. Else if (data%State%Pump(3)%Open_Close==0) then
  257. Call CloseCementPump()
  258. End if
  259. Call SetSoundMP3( data%State%Pump(3)%SoundSPM )
  260. if (data%State%Pump(3)%Switch==1) then
  261. Call Set_MP1SPMGauge( real((data%State%Pump(3)%Speed/data%State%Pump(3)%Trans_Ratio),8) ) ![SPM] SPMGaugeMalf Malf nadarad????
  262. data%Equipments%DrillingWatch%SPM1 = data%Equipments%DataDisplayConsole%MP1SPMGauge
  263. end if
  264. !data%State%Pump(3)%Flow_Rate !to other modules
  265. !>>>>>>>>>>>>>>>>>>>>>>> Total Pumps <<<<<<<<<<<<<<<<<<<<<<<<<<<
  266. !data%Equipments%MPumps%Total_Pump_Gpm = 100.d0 !???????????
  267. !data%Equipments%MPumps%Total_Pump_SPM = 1000.d0 !?????????????
  268. !SCR1LED=1
  269. !SCR2LED=1
  270. !SCR3LED=1
  271. !SCR4LED=1
  272. end subroutine Pumps_Outputs
  273. subroutine Pumps_StartUp
  274. use CPumpsVariables
  275. use CPumps
  276. use SimulationVariables
  277. IMPLICIT NONE
  278. !>>>>>>>>>>>>>>>>>>>>>>> PUMP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  279. data%State%Pump(1)%FlowRatePerSTK = data%Configuration%Pumps%MudPump1VolumetricOutput !.1d0 ![bbl/stk]
  280. data%State%Pump(1)%RateChange = data%Configuration%Pumps%MudPump1PumpRateChange ![stk/min2 ??]
  281. data%State%Pump(1)%DelayToShutdown = data%Configuration%Pumps%MudPump1DelayToShutdown ![min]
  282. data%State%Pump(1)%Mech_Efficiency = data%Configuration%Pumps%MudPump1MechanicalEfficiency ![dimensionless]
  283. !data%State%Pump(1)%Vol_Efficiency = MudPump1VolumetricEfficiency !bayad hazf beshe ?
  284. data%State%Pump(1)%Max_Pressure = data%Configuration%Pumps%MudPump1MaximumPressure !6000.d0 ![psi]
  285. data%State%Pump(1)%MaxSPM = data%Configuration%Pumps%MudPump1Maximum ![spm]
  286. data%State%Pump(1)%Trans_Ratio = 965.d0/data%State%Pump(1)%MaxSPM
  287. data%State%Pump(1)%time_step = 0.1d0 !?????? niaz hast ya na??
  288. data%State%Pump(1)%RateChange = (data%State%Pump(1)%RateChange*data%State%Pump(1)%Trans_Ratio)/60.d0 ![rpm/s ??] 24/60
  289. data%State%Pump(1)%DelayToShutdown = data%State%Pump(1)%DelayToShutdown/60.d0 ![s]
  290. data%State%Pump(1)%K_throttle = 0
  291. data%State%Pump(1)%N_old = 0.d0
  292. Call Pump_OffMode_Solver(1)
  293. !>>>>>>>>>>>>>>>>>>>>>>> PUMP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  294. data%State%Pump(2)%FlowRatePerSTK = data%Configuration%Pumps%MudPump2VolumetricOutput !.1d0 ![bbl/stk]
  295. data%State%Pump(2)%RateChange = data%Configuration%Pumps%MudPump2PumpRateChange ![stk/min2 ??]
  296. data%State%Pump(2)%DelayToShutdown = data%Configuration%Pumps%MudPump2DelayToShutdown ![min]
  297. data%State%Pump(2)%Mech_Efficiency = data%Configuration%Pumps%MudPump2MechanicalEfficiency ![dimensionless]
  298. !data%State%Pump(2)%Vol_Efficiency = MudPump2VolumetricEfficiency !bayad hazf beshe ?
  299. data%State%Pump(2)%Max_Pressure = data%Configuration%Pumps%MudPump2MaximumPressure !6000.d0 ![psi]
  300. data%State%Pump(2)%MaxSPM = data%Configuration%Pumps%MudPump2Maximum ![spm]
  301. data%State%Pump(2)%Trans_Ratio = 965.d0/data%State%Pump(2)%MaxSPM
  302. data%State%Pump(2)%time_step = 0.1d0 !?????? niaz hast ya na??
  303. data%State%Pump(2)%RateChange = (data%State%Pump(2)%RateChange*data%State%Pump(2)%Trans_Ratio)/60.d0 ![rpm/s ??]
  304. data%State%Pump(2)%DelayToShutdown = data%State%Pump(2)%DelayToShutdown/60.d0 ![s]
  305. data%State%Pump(2)%K_throttle = 0
  306. data%State%Pump(2)%N_old = 0.d0
  307. Call Pump_OffMode_Solver(2)
  308. !!>>>>>>>>>>>>>>>>>>>>>>> PUMP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<<
  309. data%State%Pump(3)%FlowRatePerSTK = data%Configuration%Pumps%CementPumpVolumetricOutput !.1d0 ![bbl/stk]
  310. data%State%Pump(3)%RateChange = data%Configuration%Pumps%CementPumpPumpRateChange ![stk/min2 ??]
  311. data%State%Pump(3)%DelayToShutdown = data%Configuration%Pumps%CementPumpDelayToShutdown ![min]
  312. data%State%Pump(3)%Mech_Efficiency = data%Configuration%Pumps%CementPumpMechanicalEfficiency ![dimensionless]
  313. !data%State%Pump(3)%Vol_Efficiency = CementPumpVolumetricEfficiency !bayad hazf beshe ?
  314. data%State%Pump(3)%Max_Pressure = data%Configuration%Pumps%CementPumpMaximumPressure !6000.d0 ![psi]
  315. data%State%Pump(3)%MaxSPM = data%Configuration%Pumps%CementPumpMaximum ![spm]
  316. data%State%Pump(3)%Trans_Ratio = 965.d0/data%State%Pump(3)%MaxSPM
  317. data%State%Pump(3)%time_step = 0.1d0 !?????? niaz hast ya na??
  318. data%State%Pump(3)%RateChange = (data%State%Pump(3)%RateChange*data%State%Pump(3)%Trans_Ratio)/60.d0 ![rpm/s ??]
  319. data%State%Pump(3)%DelayToShutdown = data%State%Pump(3)%DelayToShutdown/60.d0 ![s]
  320. data%State%Pump(3)%K_throttle = 0
  321. data%State%Pump(3)%N_old = 0.d0
  322. Call Pump_OffMode_Solver(3)
  323. end subroutine Pumps_StartUp
  324. subroutine Pump_OffMode_Solver(Pump_No)
  325. use SimulationVariables
  326. IMPLICIT NONE
  327. INTEGER :: Pump_No
  328. data%State%Pump(Pump_No)%N_new = 0.d0
  329. !========================== Pump Rate limit ==========================
  330. if (((data%State%Pump(Pump_No)%N_new-data%State%Pump(Pump_No)%N_old)/data%State%Pump(Pump_No)%time_step)>data%State%Pump(Pump_No)%RateChange) then
  331. data%State%Pump(Pump_No)%Speed =(data%State%Pump(Pump_No)%RateChange*data%State%Pump(Pump_No)%time_step)+data%State%Pump(Pump_No)%N_old
  332. else if (((data%State%Pump(Pump_No)%N_old-data%State%Pump(Pump_No)%N_new)/data%State%Pump(Pump_No)%time_step)>data%State%Pump(Pump_No)%RateChange) then
  333. data%State%Pump(Pump_No)%Speed = (-data%State%Pump(Pump_No)%RateChange*data%State%Pump(Pump_No)%time_step)+data%State%Pump(Pump_No)%N_old
  334. else
  335. data%State%Pump(Pump_No)%Speed = data%State%Pump(Pump_No)%N_new
  336. end if
  337. !=======================================================================
  338. data%State%Pump(Pump_No)%Flow_Rate = data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) ![gpm]
  339. data%State%Pump(Pump_No)%HorsePower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%StandPipe_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP]
  340. !data%State%Pump(Pump_No)%Max_Horsepower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%Max_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP]
  341. data%State%Pump(Pump_No)%Max_Horsepower = (data%State%Pump(Pump_No)%Flow_Rate*data%State%Pump(Pump_No)%Max_Pressure)/(1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency)
  342. if ( data%State%Pump(Pump_No)%StandPipe_Pressure>data%State%Pump(Pump_No)%Max_Pressure ) then ! in shart check shavad
  343. !if ( (data%State%Pump(Pump_No)%StandPipe_Pressure*data%State%Pump(Pump_No)%Flow_Rate)>(1714.d0*data%State%Pump(Pump_No)%Max_Horsepower*data%State%Pump(Pump_No)%Mech_Efficiency) ) then
  344. data%State%Pump(Pump_No)%Flow_Rate = (1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency*data%State%Pump(Pump_No)%Max_Horsepower)/data%State%Pump(Pump_No)%StandPipe_Pressure ![gpm]
  345. data%State%Pump(Pump_No)%Speed = ( data%State%Pump(Pump_No)%Flow_Rate/(data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0) )*data%State%Pump(Pump_No)%Trans_Ratio ![rpm]
  346. end if
  347. data%State%Pump(Pump_No)%SoundSPM = INT(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) ![SPM]
  348. If (data%State%Pump(Pump_No)%Flow_Rate>0.d0) Then
  349. data%State%Pump(Pump_No)%Open_Close = 1
  350. Else
  351. data%State%Pump(Pump_No)%Open_Close = 0
  352. End if
  353. end subroutine Pump_OffMode_Solver
  354. subroutine Pump_OnMode_Solver(Pump_No)
  355. use SimulationVariables
  356. IMPLICIT NONE
  357. INTEGER :: Pump_No
  358. data%State%Pump(Pump_No)%Flow_Rate = data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) ![gpm]
  359. data%State%Pump(Pump_No)%Max_FlowRate = data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0*data%State%Pump(Pump_No)%MaxSPM ![gpm]
  360. data%State%Pump(Pump_No)%HorsePower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%StandPipe_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP]
  361. !data%State%Pump(Pump_No)%Max_Horsepower = ((data%State%Pump(Pump_No)%Flow_Rate/0.01d0)*data%State%Pump(Pump_No)%Max_Pressure)/(168067.d0*data%State%Pump(Pump_No)%Mech_Efficiency) ![HHP]
  362. data%State%Pump(Pump_No)%Max_Horsepower = (data%State%Pump(Pump_No)%Flow_Rate*data%State%Pump(Pump_No)%Max_Pressure)/(1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency)
  363. if ( data%State%Pump(Pump_No)%StandPipe_Pressure>data%State%Pump(Pump_No)%Max_Pressure ) then ! in shart check shavad
  364. !if ( (data%State%Pump(Pump_No)%StandPipe_Pressure*data%State%Pump(Pump_No)%Flow_Rate)>(1714.d0*data%State%Pump(Pump_No)%Max_Horsepower*data%State%Pump(Pump_No)%Mech_Efficiency) ) then
  365. data%State%Pump(Pump_No)%Flow_Rate = (1714.d0*data%State%Pump(Pump_No)%Mech_Efficiency*data%State%Pump(Pump_No)%Max_Horsepower)/data%State%Pump(Pump_No)%StandPipe_Pressure ![gpm]
  366. data%State%Pump(Pump_No)%Speed = ( data%State%Pump(Pump_No)%Flow_Rate/(data%State%Pump(Pump_No)%FlowRatePerSTK*4118.d0*0.01d0) )*data%State%Pump(Pump_No)%Trans_Ratio ![rpm]
  367. end if
  368. data%State%Pump(Pump_No)%SoundSPM = INT(data%State%Pump(Pump_No)%Speed/data%State%Pump(Pump_No)%Trans_Ratio) ![SPM] ![spm]
  369. If (data%State%Pump(Pump_No)%Flow_Rate>0.d0) Then
  370. data%State%Pump(Pump_No)%Open_Close = 1
  371. Else
  372. data%State%Pump(Pump_No)%Open_Close = 0
  373. End if
  374. end subroutine Pump_OnMode_Solver
  375. ! subroutine Pump1_Output
  376. ! implicit none
  377. ! end subroutine Pump1_Output
  378. ! subroutine Pump1MainBody
  379. ! use ifport
  380. ! use ifmt
  381. ! implicit none
  382. ! Call Pumps_StartUp
  383. ! loop1 : do
  384. ! Call Pumps_MainSolver
  385. ! end do loop1
  386. ! end subroutine Pump1MainBody
  387. ! ****************************************
  388. ! ***** subroutine Pump2MainBody *****
  389. ! ****************************
  390. ! subroutine Pump2_Setup()
  391. ! use CSimulationVariables
  392. ! implicit none
  393. ! call OnSimulationInitialization%Add(Pump2_Init)
  394. ! call OnSimulationStop%Add(Pump2_Init)
  395. ! call OnPump2Step%Add(Pump2_Step)
  396. ! call OnPump2Output%Add(Pump2_Output)
  397. ! call OnPump2Main%Add(Pump2MainBody)
  398. ! end subroutine
  399. !
  400. ! subroutine Pump2_Init
  401. ! implicit none
  402. ! end subroutine Pump2_Init
  403. !
  404. ! subroutine Pump2_Step
  405. ! call Pump2_MainSolver
  406. ! end subroutine Pump2_Step
  407. !
  408. ! subroutine Pump2_Output
  409. ! implicit none
  410. ! end subroutine Pump2_Output
  411. !
  412. ! subroutine Pump2MainBody
  413. ! use ifport
  414. ! use ifmt
  415. ! use CWarnings
  416. ! implicit none
  417. !
  418. ! integer,dimension(8) :: MP_START_TIME, MP_END_TIME
  419. ! INTEGER :: MP_SolDuration
  420. !
  421. ! Call Pump_StartUp
  422. !
  423. ! loop1 : do
  424. !
  425. ! Call DATE_AND_TIME(values=MP_START_TIME)
  426. !
  427. ! Call Pump2_MainSolver
  428. !
  429. ! Call DATE_AND_TIME(values=MP_END_TIME)
  430. ! MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  431. ! if(MP_SolDuration > 0.0) then
  432. ! Call sleepqq(MP_SolDuration)
  433. ! end if
  434. !
  435. ! if (IsStopped == .true.) then
  436. ! exit loop1
  437. ! end if
  438. !
  439. ! end do loop1
  440. !
  441. !
  442. ! end subroutine Pump2MainBody
  443. !
  444. !
  445. !
  446. !
  447. !! ****************************************
  448. !! ***** subroutine Pump3MainBody *****
  449. !! ****************************
  450. ! subroutine Pump3_Setup()
  451. ! use CSimulationVariables
  452. ! implicit none
  453. ! call OnSimulationInitialization%Add(Pump3_Init)
  454. ! call OnSimulationStop%Add(Pump3_Init)
  455. ! call OnPump3Step%Add(Pump3_Step)
  456. ! call OnPump3Output%Add(Pump3_Output)
  457. ! call OnPump3Main%Add(Pump3MainBody)
  458. ! end subroutine
  459. !
  460. ! subroutine Pump3_Init
  461. ! implicit none
  462. ! end subroutine Pump3_Init
  463. !
  464. ! subroutine Pump3_Step
  465. ! implicit none
  466. ! end subroutine Pump3_Step
  467. !
  468. ! subroutine Pump3_Output
  469. ! implicit none
  470. ! end subroutine Pump3_Output
  471. !
  472. ! subroutine Pump3MainBody
  473. ! use ifport
  474. ! use ifmt
  475. ! implicit none
  476. !
  477. !
  478. ! integer,dimension(8) :: MP_START_TIME, MP_END_TIME
  479. ! INTEGER :: MP_SolDuration
  480. !
  481. ! !Call Pump_StartUp
  482. ! !loop1 : do
  483. ! !
  484. ! ! Call sleepqq(10)
  485. ! !
  486. ! ! !!! Pump3 Malfunction ----> Power Failure
  487. ! ! !!if (data%State%Pump(1)%PowerFailMalf==1) then
  488. ! ! !! !MP1BLWR=0
  489. ! ! !! Call Pump3_OffMode_Solver
  490. ! ! !! Call ClosePump1()
  491. ! ! !!end if
  492. ! !
  493. ! ! !if( (MP1CPSwitch==1) .and. (MP1Throttle==0.) .and. (data%State%Pump(3)%PowerFailMalf==0) ) then
  494. ! !!
  495. ! !! loop2: do
  496. ! !!
  497. ! !! Call DATE_AND_TIME(values=MP_START_TIME)
  498. ! !!
  499. ! !!!! ! Pump3 Malfunction ----> Power Failure
  500. ! !!!! if (data%State%Pump(1)%PowerFailMalf==1) then
  501. ! !!!! !MP1BLWR=0
  502. ! !!!! Pump3_OffMode_Solver
  503. ! !!!! Call ClosePump1()
  504. ! !!!! exit loop2
  505. ! !!!! end if
  506. ! !!
  507. ! !! data%State%Pump(3)%N_new = MP1Throttle
  508. ! !! if (((data%State%Pump(3)%N_new-data%State%Pump(3)%N_old)/data%State%Pump(3)%time_step)>193.) then
  509. ! !! data%State%Pump(3)%N_ref =(193.*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old
  510. ! !! else if (((data%State%Pump(3)%N_old-data%State%Pump(3)%N_new)/data%State%Pump(3)%time_step)>193.) then
  511. ! !! data%State%Pump(3)%N_ref = (-193.*data%State%Pump(3)%time_step)+data%State%Pump(3)%N_old
  512. ! !! else
  513. ! !! data%State%Pump(3)%N_ref = data%State%Pump(3)%N_new
  514. ! !! end if
  515. ! !!
  516. ! !! Call Pump3_OnMode_Solver
  517. ! !!
  518. ! !! IF (data%State%Pump(3)%Flow_Rate>0.) Then
  519. ! !! Call OpenCementPump()
  520. ! !! Else
  521. ! !! Call CloseCementPump()
  522. ! !! End if
  523. ! !!
  524. ! !! data%State%Pump(3)%N_old = data%State%Pump(3)%N_ref
  525. ! !!
  526. ! !! Call DATE_AND_TIME(values=MP_END_TIME)
  527. ! !! MP_SolDuration = 100-(MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  528. ! !! !if(print_log) print*, 'MPtime=', MP_SolDuration
  529. ! !! if(MP_SolDuration > 0.0) then
  530. ! !! Call sleepqq(MP_SolDuration)
  531. ! !! end if
  532. ! !!
  533. ! !! if ((MP1CPSwitch==0) .or. (IsStopped == .true.)) then
  534. ! !! Call Pump3_OffMode_Solver
  535. ! !! Call CloseCementPump()
  536. ! !! exit loop2
  537. ! !! end if
  538. ! !! end do loop2
  539. ! !
  540. ! ! else
  541. ! !
  542. ! ! !Call Pump3_OffMode_Solver
  543. ! ! !Call CloseCementPump()
  544. ! !
  545. ! ! end if
  546. ! !
  547. ! ! if (IsStopped == .true.) then
  548. ! ! exit loop1
  549. ! ! end if
  550. ! !
  551. ! !end do loop1
  552. !
  553. !
  554. ! end subroutine Pump3MainBody
  555. end module PumpsMain