Simulation Core
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

265 lignes
7.7 KiB

  1. module Simulator
  2. use Bop
  3. use PumpsMain
  4. use RopMain
  5. use RotaryTableMain
  6. use DrawworksMain
  7. use FluidFlowMain
  8. use TorqueDragMain
  9. use MudSystemMain
  10. use PipeRams1Main
  11. use PipeRams2Main
  12. use KillLineMain
  13. use ChokeLineMain
  14. use BlindRamsMain
  15. use AnnularMain
  16. use TopDriveMain
  17. use CManifolds
  18. use GeoMain
  19. use ChokeControlMain
  20. use COperationScenariosMain
  21. ! For Json read and write
  22. use CStringConfiguration
  23. use CFormation
  24. use CReservoir
  25. use CShoe
  26. use CAccumulator
  27. use CBopStack
  28. use CHoisting
  29. use CPower
  30. use CPumpsVariables
  31. use CRigSize
  32. use CCasingLinerChoke
  33. use CPathGeneration
  34. use CWellSurveyData
  35. ! use CMudProperties
  36. use :: json_module, rk => json_rk
  37. implicit none
  38. real :: a1, a2, a3, a4
  39. real(kind=rk), allocatable :: x0(:)
  40. type(json_file) :: jsonfile
  41. logical :: is_found
  42. real T1,T2
  43. contains
  44. subroutine Simulate
  45. integer :: t
  46. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  47. t=0
  48. call write_variables()
  49. ! call init_modules()
  50. call cpu_time(T1)
  51. do while (t<0)
  52. !!read variable from shared file
  53. call read_variables()
  54. exit
  55. !! Tarmigh, Now merged with TorqueDrag (FluidFlow)
  56. ! call Rop_Step()
  57. !! Rafiee, nothing changed
  58. call BopStack_Step()
  59. !! Tarmigh, now is rewritten
  60. call Pump1_Step()
  61. !call Pump2_Step()
  62. !! Rafiee
  63. call ChokeControl_Step()
  64. !! Location ./Equipment/Rotarytable
  65. !! Variables:
  66. !! Does not have step function
  67. !! Call RTable_StartUp in the start
  68. !! Again has a loop in each step
  69. !! Tarmigh, now is rewritten
  70. call RotaryTable_Step()
  71. !! Location ./Equipment/Drawworks
  72. !! Variables:
  73. !! Does not have step function
  74. !! Call ..._StartUp in the start
  75. !! Again has a loop in each step
  76. !! Tarmigh, now is rewritten
  77. call Drawworks_Step()
  78. !! Empty nothing called
  79. !! Merged in FluidFlow
  80. ! call TorqueDrag_Step()
  81. !! Location: ./Equipment/MudSystem
  82. !! Variables: MudSystem_variables.f90 and MudSystem.f90
  83. !! Step function simply calls LineupAndPath in MudSystem.f90
  84. !! had not startUp
  85. !! Rafiee
  86. call MudSystem_Step()
  87. !! Location ./Equipment/BopStack
  88. !! Variables: VARIABLES,CBopStackVariables,CBopControlPanelVariables,CEquipmentsConstants
  89. !! Step function added, only call PIPE_RAMS1 and 2 function
  90. !! BOP_StartUp commented
  91. !! Rafiee
  92. call PipeRams1_Step()
  93. call PipeRams2_Step()
  94. !! Location ./Equipment/BopStack
  95. !! Variables: VARIABLES,CBopStackVariables,CBopControlPanelVariables,CEquipmentsConstants,CAccumulatorVariables,CSimulationVariables
  96. !! Step function added, only call PIPE_RAMS1 and PIPE_RAMS2 function
  97. !! BOP_StartUp commented
  98. !! Rafiee
  99. call KillLine_Step()
  100. !! Probably like other bopstack equipments
  101. !! Rafiee
  102. call ChokeLine_Step()
  103. call BlindRams_Step()
  104. call Annular_Step()
  105. !!Tarmigh. Step must rewrittem
  106. call TopDrive_Step()
  107. !!Empty
  108. ! call Geo_Step()
  109. !!Ahmadi
  110. call PathFinding_Step()
  111. !! Sheikh
  112. !call FluidFlow_Step()
  113. !! Ahmadi
  114. call OperationScenarios_Step()
  115. !! Write variables to shared files
  116. call write_variables()
  117. print *,"t=",t
  118. t = t + 1
  119. end do
  120. call cpu_time(T2)
  121. print *,"Total Execution Time =",t2-t1
  122. end subroutine Simulate
  123. subroutine write_variables
  124. use CAccumulator
  125. implicit none
  126. type(json_core) :: json
  127. type(json_value),pointer :: p
  128. print *,"write starts"
  129. call json%create_object(p,'') !create the root
  130. call ConfigurationToJson(p)
  131. call json%print(p,'test.json') !write it to a file
  132. call json%destroy(p) !cleanup print *,"written"
  133. print *,"write ends"
  134. end subroutine
  135. subroutine read_variables
  136. type(json_core) :: json
  137. call jsonfile%initialize()
  138. print *,"Starting read"
  139. ! ! Load the file.
  140. call jsonfile%load_file('config.json'); if (jsonfile%failed()) stop
  141. print *,"read complete"
  142. call jsonfile%get('t0', a1, is_found); if (.not. is_found) return
  143. call jsonfile%get('dt', a2, is_found); if (.not. is_found) return
  144. call jsonfile%get('tf', a3, is_found); if (.not. is_found) return
  145. call jsonfile%get('mu', a4, is_found); if (.not. is_found) return
  146. call jsonfile%get('x0', x0, is_found); if (.not. is_found) return
  147. if (is_found) then
  148. print *, a1,a2,a3,a4
  149. print *, x0
  150. end if
  151. call jsonfile%destroy()
  152. end subroutine
  153. subroutine init_modules
  154. !Tarmigh
  155. call Pump1_Init()
  156. !call Pump2_Step()
  157. call RotaryTable_Init()
  158. call Drawworks_Init()
  159. call TopDrive_Init()
  160. !Nothing in init (and step)
  161. ! call Rop_Init()
  162. ! call TorqueDrag_Init()
  163. ! call Geo_Step()
  164. !! Rafiee
  165. call BopStack_Init()
  166. call ChokeControl_Init()
  167. call MudSystem_Init()
  168. !Again calls Bop_Startup
  169. ! call PipeRams1_Init()
  170. ! call PipeRams2_Step()
  171. ! call KillLine_Step()
  172. ! call ChokeLine_Step()
  173. ! call BlindRams_Step()
  174. ! call Annular_Step()
  175. !! Sheikh
  176. !call FluidFlow_Init()
  177. !! Ahmadi
  178. call PathFinding_Init()
  179. ! Calls OSInitialization and that sub only subscribes some notif
  180. ! call OperationScenarios_Init()
  181. end subroutine init_modules
  182. subroutine ConfigurationToJson(parent)
  183. type(json_value),pointer :: parent
  184. type(json_core) :: json
  185. type(json_value),pointer :: p
  186. ! 1. create new node
  187. call json%create_object(p,'Configuration')
  188. ! call AccumulatorToJsonToJson(p)
  189. ! 2. add member of data type to new node
  190. call StringConfigurationToJson(p)
  191. call FormationToJson(p)
  192. call ReservoirToJson(p)
  193. call ShoeToJson(p)
  194. call AccumulatorToJson(p)
  195. call BopStackToJson(p)
  196. call HoistingToJson(p)
  197. call PowerToJson(p)
  198. call PumpsToJson(p)
  199. call RigSizeToJson(p)
  200. call CasingLinerChokeToJson(p)
  201. call PathGenerationToJson(p)
  202. ! call WellSurveyDataToJson(p)
  203. ! call MudPropertiesToJson(p)
  204. ! 3. add new node to parent
  205. call json%add(parent,p)
  206. end subroutine
  207. !use this as a template
  208. subroutine SomeDSToJson(parent)
  209. type(json_value),pointer :: parent
  210. type(json_core) :: json
  211. type(json_value),pointer :: p
  212. ! 1. create new node
  213. call json%create_object(p,'Configuration')
  214. ! 2. add member of data type to new node
  215. ! call StringConfigurationToJson(p)
  216. ! call FormationToJson(p)
  217. ! call json%add(p,"",data%Configuration%Formation%Formations(i)%Abrasiveness)
  218. ! 3. add new node to parent
  219. call json%add(parent,p)
  220. end subroutine
  221. end module Simulator