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.
 
 
 
 
 
 

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