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.
 
 
 
 
 
 

185 lines
5.5 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. use :: json_module, rk => json_rk
  22. implicit none
  23. ! real :: t0, dt, tf, mu
  24. real(kind=rk), allocatable :: x0(:)
  25. type(json_file) :: json
  26. logical :: is_found
  27. real T1,T2
  28. contains
  29. subroutine Simulate
  30. integer :: t
  31. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  32. t=0
  33. call init_modules()
  34. call cpu_time(T1)
  35. do while (t<100)
  36. !!read variable from shared file
  37. call read_variables()
  38. !! Tarmigh, Now merged with TorqueDrag (FluidFlow)
  39. ! call Rop_Step()
  40. !! Rafiee, nothing changed
  41. call BopStack_Step()
  42. !! Tarmigh, now is rewritten
  43. call Pump1_Step()
  44. !call Pump2_Step()
  45. !! Rafiee
  46. call ChokeControl_Step()
  47. !! Location ./Equipment/Rotarytable
  48. !! Variables:
  49. !! Does not have step function
  50. !! Call RTable_StartUp in the start
  51. !! Again has a loop in each step
  52. !! Tarmigh, now is rewritten
  53. call RotaryTable_Step()
  54. !! Location ./Equipment/Drawworks
  55. !! Variables:
  56. !! Does not have step function
  57. !! Call ..._StartUp in the start
  58. !! Again has a loop in each step
  59. !! Tarmigh, now is rewritten
  60. call Drawworks_Step()
  61. !! Empty nothing called
  62. !! Merged in FluidFlow
  63. ! call TorqueDrag_Step()
  64. !! Location: ./Equipment/MudSystem
  65. !! Variables: MudSystem_variables.f90 and MudSystem.f90
  66. !! Step function simply calls LineupAndPath in MudSystem.f90
  67. !! had not startUp
  68. !! Rafiee
  69. call MudSystem_Step()
  70. !! Location ./Equipment/BopStack
  71. !! Variables: VARIABLES,CBopStackVariables,CBopControlPanelVariables,CEquipmentsConstants
  72. !! Step function added, only call PIPE_RAMS1 and 2 function
  73. !! BOP_StartUp commented
  74. !! Rafiee
  75. call PipeRams1_Step()
  76. call PipeRams2_Step()
  77. !! Location ./Equipment/BopStack
  78. !! Variables: VARIABLES,CBopStackVariables,CBopControlPanelVariables,CEquipmentsConstants,CAccumulatorVariables,CSimulationVariables
  79. !! Step function added, only call PIPE_RAMS1 and PIPE_RAMS2 function
  80. !! BOP_StartUp commented
  81. !! Rafiee
  82. call KillLine_Step()
  83. !! Probably like other bopstack equipments
  84. !! Rafiee
  85. call ChokeLine_Step()
  86. call BlindRams_Step()
  87. call Annular_Step()
  88. !!Tarmigh. Step must rewrittem
  89. call TopDrive_Step()
  90. !!Empty
  91. ! call Geo_Step()
  92. !!Ahmadi
  93. call PathFinding_Step()
  94. !! Sheikh
  95. !call FluidFlow_Step()
  96. !! Ahmadi
  97. call OperationScenarios_Step()
  98. !! Write variables to shared files
  99. call write_variables()
  100. print *,"t=",t
  101. t = t + 1
  102. end do
  103. call cpu_time(T2)
  104. print *,"Total Execution Time =",t2-t1
  105. end subroutine Simulate
  106. subroutine write_variables
  107. !implicit none
  108. end subroutine
  109. subroutine read_variables
  110. ! call json%initialize()
  111. ! ! Load the file.
  112. ! call json%load_file('config.json'); if (json%failed()) stop
  113. ! call json%get('t0', t0, is_found); if (.not. is_found) return
  114. ! call json%get('dt', dt, is_found); if (.not. is_found) return
  115. ! call json%get('tf', tf, is_found); if (.not. is_found) return
  116. ! call json%get('mu', mu, is_found); if (.not. is_found) return
  117. ! call json%get('x0', x0, is_found); if (.not. is_found) return
  118. ! ! Output values.
  119. ! if (is_found) then
  120. ! print *, t0, dt, tf, mu
  121. ! print *, x0
  122. ! end if
  123. ! ! Clean up.
  124. ! call json%destroy()
  125. end subroutine
  126. subroutine init_modules
  127. !Tarmigh
  128. call Pump1_Init()
  129. !call Pump2_Step()
  130. call RotaryTable_Init()
  131. call Drawworks_Init()
  132. call TopDrive_Init()
  133. !Nothing in init (and step)
  134. ! call Rop_Init()
  135. ! call TorqueDrag_Init()
  136. ! call Geo_Step()
  137. !! Rafiee
  138. call BopStack_Init()
  139. call ChokeControl_Init()
  140. call MudSystem_Init()
  141. !Again calls Bop_Startup
  142. ! call PipeRams1_Init()
  143. ! call PipeRams2_Step()
  144. ! call KillLine_Step()
  145. ! call ChokeLine_Step()
  146. ! call BlindRams_Step()
  147. ! call Annular_Step()
  148. !! Sheikh
  149. !call FluidFlow_Init()
  150. !! Ahmadi
  151. call PathFinding_Init()
  152. ! Calls OSInitialization and that sub only subscribes some notif
  153. ! call OperationScenarios_Init()
  154. end subroutine init_modules
  155. end module Simulator