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.

CPumps.f90 14 KiB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. module CPumps
  2. use SimulationVariables
  3. use json_module
  4. implicit none
  5. public
  6. contains
  7. subroutine PumpsToJson(parent)
  8. type(json_value),pointer :: parent
  9. type(json_core) :: json
  10. type(json_value),pointer :: p
  11. ! 1. create new node
  12. call json%create_object(p,'Pumps')
  13. ! 2. add member of data type to new node
  14. ! call StringConfigurationToJson(p)
  15. ! call FormationToJson(p)
  16. call json%add(p,"MudPump1LinerDiameter",data%Configuration%Pumps%MudPump1LinerDiameter)
  17. call json%add(p,"MudPump1Stroke",data%Configuration%Pumps%MudPump1Stroke)
  18. call json%add(p,"MudPump1MechanicalEfficiency",data%Configuration%Pumps%MudPump1MechanicalEfficiency)
  19. call json%add(p,"MudPump1VolumetricEfficiency",data%Configuration%Pumps%MudPump1VolumetricEfficiency)
  20. call json%add(p,"MudPump1Output",data%Configuration%Pumps%MudPump1Output)
  21. call json%add(p,"MudPump1OutputBblStroke",data%Configuration%Pumps%MudPump1OutputBblStroke)
  22. call json%add(p,"MudPump1Maximum",data%Configuration%Pumps%MudPump1Maximum)
  23. call json%add(p,"MudPump1ReliefValvePressure",data%Configuration%Pumps%MudPump1ReliefValvePressure)
  24. call json%add(p,"MudPump2LinerDiameter",data%Configuration%Pumps%MudPump2LinerDiameter)
  25. call json%add(p,"MudPump2Stroke",data%Configuration%Pumps%MudPump2Stroke)
  26. call json%add(p,"MudPump2MechanicalEfficiency",data%Configuration%Pumps%MudPump2MechanicalEfficiency)
  27. call json%add(p,"MudPump2VolumetricEfficiency",data%Configuration%Pumps%MudPump2VolumetricEfficiency)
  28. call json%add(p,"MudPump2Output",data%Configuration%Pumps%MudPump2Output)
  29. call json%add(p,"MudPump2OutputBblStroke",data%Configuration%Pumps%MudPump2OutputBblStroke)
  30. call json%add(p,"MudPump2Maximum",data%Configuration%Pumps%MudPump2Maximum)
  31. call json%add(p,"MudPump2ReliefValvePressure",data%Configuration%Pumps%MudPump2ReliefValvePressure)
  32. call json%add(p,"CementPumpLinerDiameter",data%Configuration%Pumps%CementPumpLinerDiameter)
  33. call json%add(p,"CementPumpStroke",data%Configuration%Pumps%CementPumpStroke)
  34. call json%add(p,"CementPumpMechanicalEfficiency",data%Configuration%Pumps%CementPumpMechanicalEfficiency)
  35. call json%add(p,"CementPumpVolumetricEfficiency",data%Configuration%Pumps%CementPumpVolumetricEfficiency)
  36. call json%add(p,"CementPumpOutput",data%Configuration%Pumps%CementPumpOutput)
  37. call json%add(p,"CementPumpOutputBblStroke",data%Configuration%Pumps%CementPumpOutputBblStroke)
  38. call json%add(p,"CementPumpMaximum",data%Configuration%Pumps%CementPumpMaximum)
  39. call json%add(p,"CementPumpReliefValvePressure ",data%Configuration%Pumps%CementPumpReliefValvePressure )
  40. call json%add(p,"MudPump1ReliefValveIsSet",data%Configuration%Pumps%MudPump1ReliefValveIsSet)
  41. call json%add(p,"MudPump2ReliefValveIsSet",data%Configuration%Pumps%MudPump2ReliefValveIsSet)
  42. call json%add(p,"CementPumpReliefValveIsSet",data%Configuration%Pumps%CementPumpReliefValveIsSet)
  43. call json%add(p,"ManualPumpPower",data%Configuration%Pumps%ManualPumpPower)
  44. call json%add(p,"Valve1",data%Configuration%Pumps%Valve1)
  45. call json%add(p,"Valve2",data%Configuration%Pumps%Valve2)
  46. call json%add(p,"Valve3",data%Configuration%Pumps%Valve3)
  47. call json%add(p,"Valve4",data%Configuration%Pumps%Valve4)
  48. call json%add(p,"Valve5",data%Configuration%Pumps%Valve5)
  49. ! 3. add new node to parent
  50. call json%add(parent,p)
  51. end subroutine
  52. subroutine PumpsFromJson(parent)
  53. use json_module,IK =>json_ik
  54. type(json_value),pointer :: parent
  55. type(json_core) :: json
  56. type(json_value),pointer :: p,pitems,pitem,pval,pbit
  57. call json%get(parent,'Pumps',p)
  58. call json%get(p,"MudPump1LinerDiameter",pitem)
  59. call json%get(pitem,data%Configuration%Pumps%MudPump1LinerDiameter)
  60. call json%get(p,"MudPump1Stroke",pitem)
  61. call json%get(pitem,data%Configuration%Pumps%MudPump1Stroke)
  62. call json%get(p,"MudPump1MechanicalEfficiency",pitem)
  63. call json%get(pitem,data%Configuration%Pumps%MudPump1MechanicalEfficiency)
  64. call json%get(p,"MudPump1VolumetricEfficiency",pitem)
  65. call json%get(pitem,data%Configuration%Pumps%MudPump1VolumetricEfficiency)
  66. call json%get(p,"MudPump1Output",pitem)
  67. call json%get(pitem,data%Configuration%Pumps%MudPump1Output)
  68. call json%get(p,"MudPump1OutputBblStroke",pitem)
  69. call json%get(pitem,data%Configuration%Pumps%MudPump1OutputBblStroke)
  70. call json%get(p,"MudPump1Maximum",pitem)
  71. call json%get(pitem,data%Configuration%Pumps%MudPump1Maximum)
  72. call json%get(p,"MudPump1ReliefValvePressure",pitem)
  73. call json%get(pitem,data%Configuration%Pumps%MudPump1ReliefValvePressure)
  74. call json%get(p,"MudPump2LinerDiameter",pitem)
  75. call json%get(pitem,data%Configuration%Pumps%MudPump2LinerDiameter)
  76. call json%get(p,"MudPump2Stroke",pitem)
  77. call json%get(pitem,data%Configuration%Pumps%MudPump2Stroke)
  78. call json%get(p,"MudPump2MechanicalEfficiency",pitem)
  79. call json%get(pitem,data%Configuration%Pumps%MudPump2MechanicalEfficiency)
  80. call json%get(p,"MudPump2VolumetricEfficiency",pitem)
  81. call json%get(pitem,data%Configuration%Pumps%MudPump2VolumetricEfficiency)
  82. call json%get(p,"MudPump2Output",pitem)
  83. call json%get(pitem,data%Configuration%Pumps%MudPump2Output)
  84. call json%get(p,"MudPump2OutputBblStroke",pitem)
  85. call json%get(pitem,data%Configuration%Pumps%MudPump2OutputBblStroke)
  86. call json%get(p,"MudPump2Maximum",pitem)
  87. call json%get(pitem,data%Configuration%Pumps%MudPump2Maximum)
  88. call json%get(p,"MudPump2ReliefValvePressure",pitem)
  89. call json%get(pitem,data%Configuration%Pumps%MudPump2ReliefValvePressure)
  90. call json%get(p,"CementPumpLinerDiameter",pitem)
  91. call json%get(pitem,data%Configuration%Pumps%CementPumpLinerDiameter)
  92. call json%get(p,"CementPumpStroke",pitem)
  93. call json%get(pitem,data%Configuration%Pumps%CementPumpStroke)
  94. call json%get(p,"CementPumpMechanicalEfficiency",pitem)
  95. call json%get(pitem,data%Configuration%Pumps%CementPumpMechanicalEfficiency)
  96. call json%get(p,"CementPumpVolumetricEfficiency",pitem)
  97. call json%get(pitem,data%Configuration%Pumps%CementPumpVolumetricEfficiency)
  98. call json%get(p,"CementPumpOutput",pitem)
  99. call json%get(pitem,data%Configuration%Pumps%CementPumpOutput)
  100. call json%get(p,"CementPumpOutputBblStroke",pitem)
  101. call json%get(pitem,data%Configuration%Pumps%CementPumpOutputBblStroke)
  102. call json%get(p,"CementPumpMaximum",pitem)
  103. call json%get(pitem,data%Configuration%Pumps%CementPumpMaximum)
  104. call json%get(p,"CementPumpReliefValvePressure",pitem)
  105. call json%get(pitem,data%Configuration%Pumps%CementPumpReliefValvePressure)
  106. call json%get(p,"MudPump1ReliefValveIsSet",pitem)
  107. call json%get(pitem,data%Configuration%Pumps%MudPump1ReliefValveIsSet)
  108. call json%get(p,"MudPump2ReliefValveIsSet",pitem)
  109. call json%get(pitem,data%Configuration%Pumps%MudPump2ReliefValveIsSet)
  110. call json%get(p,"CementPumpReliefValveIsSet",pitem)
  111. call json%get(pitem,data%Configuration%Pumps%CementPumpReliefValveIsSet)
  112. call json%get(p,"ManualPumpPower",pitem)
  113. call json%get(pitem,data%Configuration%Pumps%ManualPumpPower)
  114. call json%get(p,"Valve1",pitem)
  115. call json%get(pitem,data%Configuration%Pumps%Valve1)
  116. call json%get(p,"Valve2",pitem)
  117. call json%get(pitem,data%Configuration%Pumps%Valve2)
  118. call json%get(p,"Valve3",pitem)
  119. call json%get(pitem,data%Configuration%Pumps%Valve3)
  120. call json%get(p,"Valve4",pitem)
  121. call json%get(pitem,data%Configuration%Pumps%Valve4)
  122. call json%get(p,"Valve5",pitem)
  123. call json%get(pitem,data%Configuration%Pumps%Valve5)
  124. end subroutine
  125. subroutine OpenPump1()
  126. use CManifolds
  127. implicit none
  128. call ChangeValve(16, .true.)
  129. end subroutine
  130. subroutine ClosePump1()
  131. use CManifolds
  132. implicit none
  133. call ChangeValve(16, .false.)
  134. end subroutine
  135. subroutine OpenPump2()
  136. use CManifolds
  137. implicit none
  138. call ChangeValve(17, .true.)
  139. end subroutine
  140. subroutine ClosePump2()
  141. use CManifolds
  142. implicit none
  143. call ChangeValve(17, .false.)
  144. end subroutine
  145. subroutine OpenCementPump()
  146. use CManifolds
  147. implicit none
  148. call ChangeValve(18, .true.)
  149. end subroutine
  150. subroutine CloseCementPump()
  151. use CManifolds
  152. implicit none
  153. call ChangeValve(18, .false.)
  154. end subroutine
  155. ! subroutine SetMudPump1LinerDiameterN(a)
  156. ! implicit none
  157. ! real(8) :: a
  158. ! if(associated(MudPump1LinerDiameterPtr)) call MudPump1LinerDiameterPtr(a)
  159. ! end subroutine
  160. ! subroutine SetMudPump2LinerDiameterN(a)
  161. ! implicit none
  162. ! real(8) :: a
  163. ! if(associated(MudPump2LinerDiameterPtr)) call MudPump2LinerDiameterPtr(a)
  164. ! end subroutine
  165. ! subroutine SetMudPump3LinerDiameterN(a)
  166. ! implicit none
  167. ! real(8) :: a
  168. ! if(associated(MudPump3LinerDiameterPtr)) call MudPump3LinerDiameterPtr(a)
  169. ! end subroutine
  170. ! subroutine SetMudPump1OutputBblStrokeN(a)
  171. ! implicit none
  172. ! real(8) :: a
  173. ! if(associated(MudPump1OutputBblStrokePtr)) call MudPump1OutputBblStrokePtr(a)
  174. ! end subroutine
  175. ! subroutine SetMudPump2OutputBblStrokeN(a)
  176. ! implicit none
  177. ! real(8) :: a
  178. ! if(associated(MudPump2OutputBblStrokePtr)) call MudPump2OutputBblStrokePtr(a)
  179. ! end subroutine
  180. ! subroutine SetMudPump3OutputBblStrokeN(a)
  181. ! implicit none
  182. ! real(8) :: a
  183. ! if(associated(MudPump3OutputBblStrokePtr)) call MudPump3OutputBblStrokePtr(a)
  184. ! end subroutine
  185. ! subroutine CalcMudPump1LinerDiameter()
  186. ! use, intrinsic :: IEEE_ARITHMETIC
  187. ! implicit none
  188. ! real(8) :: a
  189. ! a = (MathPI / 4.d0) * data%Configuration%Pumps%MudPump1Stroke * 3.0d0 * data%Configuration%Pumps%MudPump1VolumetricEfficiency / 9702.03d0
  190. ! a = dsqrt(data%Configuration%Pumps%MudPump1OutputBblStroke / a)
  191. ! if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then
  192. ! data%Configuration%Pumps%MudPump1LinerDiameter = 0.0
  193. ! else
  194. ! data%Configuration%Pumps%MudPump1LinerDiameter = a
  195. ! endif
  196. ! call SetMudPump1LinerDiameterN(data%Configuration%Pumps%MudPump1LinerDiameter)
  197. ! end subroutine
  198. ! subroutine CalcMudPump2LinerDiameter()
  199. ! use, intrinsic :: IEEE_ARITHMETIC
  200. ! implicit none
  201. ! real(8) :: a
  202. ! a = (MathPI / 4.d0) * data%Configuration%Pumps%MudPump2Stroke * 3.0d0 * data%Configuration%Pumps%MudPump2VolumetricEfficiency / 9702.03d0
  203. ! a = dsqrt(data%Configuration%Pumps%MudPump2OutputBblStroke / a)
  204. ! if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then
  205. ! data%Configuration%Pumps%MudPump2LinerDiameter = 0.0
  206. ! else
  207. ! data%Configuration%Pumps%MudPump2LinerDiameter = a
  208. ! endif
  209. ! call SetMudPump2LinerDiameterN(data%Configuration%Pumps%MudPump2LinerDiameter)
  210. ! end subroutine
  211. ! subroutine CalcMudPump3LinerDiameter()
  212. ! use, intrinsic :: IEEE_ARITHMETIC
  213. ! implicit none
  214. ! real(8) :: a
  215. ! a = (MathPI / 4.d0) * data%Configuration%Pumps%CementPumpStroke * 3.0d0 * data%Configuration%Pumps%CementPumpVolumetricEfficiency / 9702.03d0
  216. ! a = dsqrt(data%Configuration%Pumps%CementPumpOutputBblStroke / a)
  217. ! if (.not.IEEE_IS_FINITE(a) .or. IEEE_IS_NAN(a)) then
  218. ! data%Configuration%Pumps%CementPumpLinerDiameter = 0.0
  219. ! else
  220. ! data%Configuration%Pumps%CementPumpLinerDiameter = a
  221. ! endif
  222. ! call SetMudPump3LinerDiameterN(data%Configuration%Pumps%CementPumpLinerDiameter)
  223. ! end subroutine
  224. ! subroutine CalcPump1OutputBblStroke()
  225. ! implicit none
  226. ! data%Configuration%Pumps%MudPump1OutputBblStroke = (MathPI / 4.d0) * (data%Configuration%Pumps%MudPump1LinerDiameter**2) * data%Configuration%Pumps%MudPump1Stroke * 3.0d0 * data%Configuration%Pumps%MudPump1VolumetricEfficiency / 9702.03d0
  227. ! call SetMudPump1OutputBblStrokeN(data%Configuration%Pumps%MudPump1OutputBblStroke)
  228. ! end subroutine
  229. ! subroutine CalcPump2OutputBblStroke()
  230. ! implicit none
  231. ! data%Configuration%Pumps%MudPump2OutputBblStroke = (MathPI / 4.d0) * (data%Configuration%Pumps%MudPump2LinerDiameter**2) * data%Configuration%Pumps%MudPump2Stroke * 3.0d0 * data%Configuration%Pumps%MudPump2VolumetricEfficiency / 9702.03d0
  232. ! call SetMudPump2OutputBblStrokeN(data%Configuration%Pumps%MudPump2OutputBblStroke)
  233. ! end subroutine
  234. ! subroutine CalcPump3OutputBblStroke()
  235. ! implicit none
  236. ! data%Configuration%Pumps%CementPumpOutputBblStroke = (MathPI / 4.d0) * (data%Configuration%Pumps%CementPumpLinerDiameter**2) * data%Configuration%Pumps%CementPumpStroke * 3.0d0 * data%Configuration%Pumps%CementPumpVolumetricEfficiency / 9702.03d0
  237. ! call SetMudPump3OutputBblStrokeN(data%Configuration%Pumps%CementPumpOutputBblStroke)
  238. ! end subroutine
  239. end module CPumps