Simulation Core
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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