Simulation Core
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

UnityModule.f90 9.2 KiB

1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. module UnityModule
  2. use SimulationVariables
  3. implicit none
  4. contains
  5. subroutine UnityInputsFromJson(jsonfile)
  6. type(json_file)::jsonfile
  7. logical::found
  8. call jsonfile%get('UnityInputs.ElevatorConnectionPossible',data%Equipments%UnityInputs%ElevatorConnectionPossible,found)
  9. if ( .not. found ) call logg(4,"Not found: UnityInputs%ElevatorConnectionPossible")
  10. call jsonfile%get('UnityInputs.JointConnectionPossible',data%Equipments%UnityInputs%JointConnectionPossible,found)
  11. if ( .not. found ) call logg(4,"Not found: UnityInputs%JointConnectionPossible")
  12. call jsonfile%get('UnityInputs.IsKellyBushingSetInTable',data%Equipments%UnityInputs%IsKellyBushingSetInTable,found)
  13. if ( .not. found ) call logg(4,"Not found: UnityInputs%IsKellyBushingSetInTable")
  14. call jsonfile%get('UnityInputs.ElevatorPickup',data%Equipments%UnityInputs%ElevatorPickup,found)
  15. if ( .not. found ) call logg(4,"Not found: UnityInputs%ElevatorPickup")
  16. call jsonfile%get('UnityInputs.NearFloorPosition',data%Equipments%UnityInputs%NearFloorPosition,found)
  17. if ( .not. found ) call logg(4,"Not found: UnityInputs%NearFloorPosition")
  18. call jsonfile%get('UnityInputs.SingleSetInMouseHole',data%Equipments%UnityInputs%SingleSetInMouseHole,found)
  19. if ( .not. found ) call logg(4,"Not found: UnityInputs%SingleSetInMouseHole")
  20. call jsonfile%get('UnityInputs.TdsConnectionPossible',data%Equipments%UnityInputs%TdsConnectionPossible,found)
  21. if ( .not. found ) call logg(4,"Not found: UnityInputs%TdsConnectionPossible")
  22. call jsonfile%get('UnityInputs.TdsStemIn',data%Equipments%UnityInputs%TdsStemIn,found)
  23. if ( .not. found ) call logg(4,"Not found: UnityInputs%TdsStemIn")
  24. end subroutine
  25. subroutine UnityOutputsToJson(parent)
  26. type(json_value),pointer :: parent
  27. type(json_core) :: json
  28. type(json_value),pointer :: p
  29. ! 1. create new node
  30. call json%create_object(p,'Unity')
  31. ! 2. add member of data type to new node
  32. call json%add(p,"KellyHoseVibrationRate",data%Equipments%UnityOutputs%KellyHoseVibrationRate)
  33. call json%add(p,"BlowoutFromStringPercent",data%Equipments%UnityOutputs%BlowoutFromStringPercent)
  34. call json%add(p,"Pedal",data%Equipments%UnityOutputs%Pedal)
  35. call json%add(p,"FlowRate",data%Equipments%UnityOutputs%FlowRate)
  36. call json%add(p,"RotaryRpm",data%Equipments%UnityOutputs%RotaryRpm)
  37. call json%add(p,"BlowoutFromString",data%Equipments%UnityOutputs%BlowoutFromString)
  38. call json%add(p,"BlowoutFromAnnular",data%Equipments%UnityOutputs%BlowoutFromAnnular)
  39. call json%add(p,"FlowFromReturnLine",data%Equipments%UnityOutputs%FlowFromReturnLine)
  40. call json%add(p,"FlowFromKelly",data%Equipments%UnityOutputs%FlowFromKelly)
  41. call json%add(p,"FlowFromFillupHead",data%Equipments%UnityOutputs%FlowFromFillupHead)
  42. call json%add(p,"FlowKellyDisconnect",data%Equipments%UnityOutputs%FlowKellyDisconnect)
  43. call json%add(p,"FlowPipeDisconnect",data%Equipments%UnityOutputs%FlowPipeDisconnect)
  44. ! 3. add new node to parent
  45. call json%add(parent,p)
  46. end subroutine
  47. logical function Get_ElevatorPickup()
  48. Get_ElevatorPickup = data%Equipments%UnityInputs%ElevatorPickup
  49. end function
  50. logical function Get_IsKellyBushingSetInTable()
  51. Get_IsKellyBushingSetInTable = data%Equipments%UnityInputs%IsKellyBushingSetInTable
  52. end function
  53. logical function Get_JointConnectionPossible()
  54. Get_JointConnectionPossible = data%Equipments%UnityInputs%JointConnectionPossible
  55. end function
  56. logical function Get_ElevatorConnectionPossible()
  57. implicit none
  58. Get_ElevatorConnectionPossible = data%Equipments%UnityInputs%ElevatorConnectionPossible
  59. end function
  60. logical function Get_NearFloorPosition()
  61. Get_NearFloorPosition = data%Equipments%UnityInputs%NearFloorPosition
  62. end function
  63. subroutine Set_NearFloorPosition(v)
  64. implicit none
  65. logical, intent(in) :: v
  66. ! #ifdef ExcludeExtraChanges
  67. ! if(data%Equipments%UnityInputs%NearFloorPosition == v) return
  68. ! #endif
  69. data%Equipments%UnityInputs%NearFloorPosition = v
  70. !**call data%Equipments%UnityInputs%OnNearFloorPositionChange%RunAll()
  71. if(log_level>4) then
  72. if(print_log) print*, 'NearFloorPosition =', data%Equipments%UnityInputs%NearFloorPosition
  73. endif
  74. end subroutine
  75. logical function Get_SingleSetInMouseHole()
  76. Get_SingleSetInMouseHole = data%Equipments%UnityInputs%SingleSetInMouseHole
  77. end function
  78. logical function Get_TdsConnectionPossible()
  79. Get_TdsConnectionPossible = data%Equipments%UnityInputs%TdsConnectionPossible
  80. end function
  81. logical function Get_TdsStemIn()
  82. Get_TdsStemIn = data%Equipments%UnityInputs%TdsStemIn
  83. end function
  84. subroutine Set_BlowoutFromString(v)
  85. implicit none
  86. logical, intent (in) :: v
  87. data%Equipments%UnityOutputs%BlowoutFromString = v
  88. #ifdef deb
  89. if(print_log) print*, 'BlowoutFromString=', v
  90. #endif
  91. end subroutine
  92. logical function Get_BlowoutFromString()
  93. implicit none
  94. Get_BlowoutFromString = data%Equipments%UnityOutputs%BlowoutFromString
  95. end function
  96. subroutine Set_BlowoutFromAnnular(v)
  97. implicit none
  98. logical, intent (in) :: v
  99. data%Equipments%UnityOutputs%BlowoutFromAnnular = v
  100. #ifdef deb
  101. if(print_log) print*, 'BlowoutFromAnnular=', v
  102. #endif
  103. end subroutine
  104. logical function Get_BlowoutFromAnnular()
  105. implicit none
  106. Get_BlowoutFromAnnular = data%Equipments%UnityOutputs%BlowoutFromAnnular
  107. end function
  108. subroutine Set_FlowFromReturnLine(v)
  109. implicit none
  110. logical, intent (in) :: v
  111. data%Equipments%UnityOutputs%FlowFromReturnLine = v
  112. #ifdef deb
  113. if(print_log) print*, 'FlowFromReturnLine=', v
  114. #endif
  115. end subroutine
  116. logical function Get_FlowFromReturnLine()
  117. implicit none
  118. Get_FlowFromReturnLine = data%Equipments%UnityOutputs%FlowFromReturnLine
  119. end function
  120. subroutine Set_FlowFromKelly(v)
  121. implicit none
  122. real, intent (in) :: v
  123. data%Equipments%UnityOutputs%FlowFromKelly = v
  124. #ifdef deb
  125. if(print_log) print*, 'FlowFromKelly=', v
  126. #endif
  127. end subroutine
  128. real function Get_FlowFromKelly()
  129. implicit none
  130. Get_FlowFromKelly = data%Equipments%UnityOutputs%FlowFromKelly
  131. end function
  132. subroutine Set_FlowFromFillupHead(v)
  133. implicit none
  134. real, intent (in) :: v
  135. data%Equipments%UnityOutputs%FlowFromFillupHead = v
  136. #ifdef deb
  137. if(print_log) print*, 'FlowFromFillupHead=', v
  138. #endif
  139. end subroutine
  140. real function Get_FlowFromFillupHead()
  141. implicit none
  142. Get_FlowFromFillupHead = data%Equipments%UnityOutputs%FlowFromFillupHead
  143. end function
  144. subroutine Set_FlowKellyDisconnect(v)
  145. implicit none
  146. logical, intent (in) :: v
  147. data%Equipments%UnityOutputs%FlowKellyDisconnect = v
  148. #ifdef deb
  149. if(print_log) print*, 'FlowKellyDisconnect=', v
  150. #endif
  151. end subroutine
  152. logical function Get_FlowKellyDisconnect()
  153. implicit none
  154. Get_FlowKellyDisconnect = data%Equipments%UnityOutputs%FlowKellyDisconnect
  155. end function
  156. subroutine Set_FlowPipeDisconnect(v)
  157. implicit none
  158. logical, intent (in) :: v
  159. data%Equipments%UnityOutputs%FlowPipeDisconnect = v
  160. #ifdef deb
  161. if(print_log) print*, 'FlowPipeDisconnect=', v
  162. #endif
  163. end subroutine
  164. logical function Get_FlowPipeDisconnect()
  165. implicit none
  166. Get_FlowPipeDisconnect = data%Equipments%UnityOutputs%FlowPipeDisconnect
  167. end function
  168. subroutine Set_BlowoutFromStringPercent(v)
  169. implicit none
  170. real(8), intent (in) :: v
  171. data%Equipments%UnityOutputs%BlowoutFromStringPercent = v
  172. #ifdef deb
  173. if(print_log) print*, 'BlowoutFromStringPercent=', v
  174. #endif
  175. end subroutine
  176. real(8) function GetBlowoutFromStringPercent()
  177. implicit none
  178. GetBlowoutFromStringPercent = data%Equipments%UnityOutputs%BlowoutFromStringPercent
  179. end function
  180. subroutine Calc_KellyHoseVibrationRate(spm1, spm2)
  181. use CScaleRange
  182. implicit none
  183. real(8), intent (in) :: spm1, spm2
  184. real :: total
  185. total = (spm1 + spm2)/2
  186. data%Equipments%UnityOutputs%KellyHoseVibrationRate = ScaleRange(total, 0.0, 10.0, 0.0, 120.0)
  187. #ifdef deb
  188. if(print_log) print*, 'KellyHoseVibrationRate=', data%Equipments%UnityOutputs%KellyHoseVibrationRate
  189. #endif
  190. end subroutine
  191. real(8) function GetKellyHoseVibrationRate()
  192. implicit none
  193. GetKellyHoseVibrationRate = data%Equipments%UnityOutputs%KellyHoseVibrationRate
  194. end function
  195. subroutine Set_Pedal(v)
  196. implicit none
  197. real(8), intent (in) :: v
  198. data%Equipments%UnityOutputs%Pedal = v
  199. #ifdef deb
  200. if(print_log) print*, 'Pedal=', v
  201. #endif
  202. end subroutine
  203. real(8) function GetPedal()
  204. implicit none
  205. GetPedal = data%Equipments%UnityOutputs%Pedal
  206. end function
  207. subroutine Set_FlowRate(v)
  208. implicit none
  209. real(8), intent (in) :: v
  210. data%Equipments%UnityOutputs%FlowRate = v
  211. #ifdef deb
  212. if(print_log) print*, 'FlowRate=', v
  213. #endif
  214. end subroutine
  215. real(8) function GetFlowRate()
  216. implicit none
  217. GetFlowRate = data%Equipments%UnityOutputs%FlowRate
  218. end function
  219. subroutine Set_RotaryRpm(v)
  220. implicit none
  221. real(8), intent (in) :: v
  222. data%Equipments%UnityOutputs%RotaryRpm = v
  223. #ifdef deb
  224. if(print_log) print*, 'RotaryRpm=', v
  225. #endif
  226. end subroutine
  227. real(8) function GetRotaryRpm()
  228. implicit none
  229. GetRotaryRpm = data%Equipments%UnityOutputs%RotaryRpm
  230. end function
  231. end module UnityModule