Advertisement
Korotkodul

lab

Mar 5th, 2025 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.93 KB | None | 0 0
  1. """
  2. import numpy as np
  3.  
  4. Q = []
  5. dP = []
  6. ro = 0.805 * 10**(-3) / 10**(-6)
  7. g = 9.81
  8. """
  9.  
  10. """
  11. 1 tube
  12. dV = np.array([0.0005]*7)
  13. dT = np.array([11,12.3,13.2,16.2,20,27,36.5])
  14. print(np.round(dV/dT * 10**5, 2))
  15. Q
  16. #[4.55 4.07 3.79 3.09 2.5  1.85 1.37]
  17. #[4.55, 4.07, 3.79, 3.09, 2.5,  1.85, 1.37]
  18.  
  19. dh = np.array([12, 10.7, 9.8, 8.2, 6.8, 5.2, 3.6])
  20. dh /= 100
  21. dP = ro * g * dh
  22. print(dP)
  23. #[947.646   844.98435 773.9109  647.5581  536.9994  410.6466  284.2938 ]
  24. #[947.646,   844.98435, 773.9109,  647.5581,  536.9994,  410.6466,  284.2938 ]
  25. """
  26.  
  27. """
  28. 2 tube
  29.  
  30. dV = np.array([0.0005]*7)
  31. dT  = np.array([6.1, 5.7, 6.1, 6.2, 16.2, 6.6, 7.4])
  32. dT = np.round(dV/dT * 10**5, 2)
  33. dT[-3] = 8.06
  34. print(dT)
  35. #[8.2  8.77 8.2  8.06 8.06 7.58 6.76]
  36.  
  37. dh = np.array([6, 5.9, 5.4, 4.7, 0, 4, 3.2])
  38. dh /= 100
  39. dP = ro * g * dh
  40. dP[-3] = 339.227
  41. print(np.round(dP, 2))
  42. #[473.82 465.93 426.44 371.16 339.23 315.88 252.71]
  43. """
  44.  
  45. """
  46. 3 tube
  47.  
  48. dV = np.array([0.001]*7)
  49. dT  = np.array([10.8, 10.3, 10.5, 10.5, 10.5, 11.2, 11.1])
  50. print(np.round(dV/dT * 10**5, 2))
  51. #[9.26 9.71 9.52 9.52 9.52 8.93 9.01]
  52.  
  53. dh = np.array([9.8, 10, 10, 9.6, 8.9, 8.5, 7.7])
  54. dh /= 100
  55. dP = ro * g * dh
  56. print(np.round(dP, 2))
  57. #[773.91 789.71 789.71 758.12 702.84 671.25 608.07]
  58. """
  59.  
  60.  
  61.  
  62.  
  63. import numpy as np
  64. from numbers import Real
  65. from visualize import visualize_lsm
  66.  
  67. class ShapeMismatchError(BaseException):
  68.     pass
  69.  
  70. def get_lsm_coefficients(
  71.         abscissa: np.ndarray,
  72.         ordinates: np.ndarray,
  73. ) -> tuple[Real, Real]:
  74.     x = abscissa
  75.     y = ordinates
  76.  
  77.     if x.shape != y.shape:
  78.         raise ShapeMismatchError()
  79.  
  80.     x_mean = np.mean(x)
  81.     y_mean = np.mean(y)
  82.     x_squared_mean = np.mean(x ** 2)
  83.  
  84.     xy_mean = np.mean(x * y)
  85.  
  86.     a = (xy_mean - x_mean * y_mean) / (x_squared_mean - x_mean ** 2)
  87.     b = y_mean - a * x_mean
  88.  
  89.     return a, b
  90.  
  91. #tube1
  92. #abscissa = np.array([4.55, 4.07, 3.79, 3.09, 2.5,  1.85, 1.37])
  93. #ordinates = np.array([947.646,   844.98435, 773.9109,  647.5581,  536.9994,  410.6466,  284.2938 ]) * 10**(-5)
  94. #incline = 202.1854583810828
  95.  
  96. #tube2
  97. #abscissa = np.array([8.2,  8.77, 8.2,  8.06, 8.06, 7.58, 6.76])
  98. #ordinates = np.array([473.82, 465.93, 426.44, 371.16, 339.23, 315.88, 252.71]) * 10**(-5)
  99. #incline = 115.90762733277586
  100.  
  101.  
  102. #tube3
  103. #abscissa = np.array([9.26, 9.71, 9.52, 9.52, 9.52, 8.93, 9.01])
  104. #ordinates = np.array([773.91, 789.71, 789.71, 758.12, 702.84, 671.25, 608.07]) * 10**(-5)
  105. #incline = 182.1185812306331
  106.  
  107. def draw(abscissa, ordinates):
  108.     incline, shift = get_lsm_coefficients(abscissa, ordinates)
  109.     print("incline", incline)
  110.  
  111.     visualize_lsm(
  112.         abscissa=abscissa,
  113.         ordinates_experiment=ordinates,
  114.         ordinates_computed=incline * abscissa + shift,
  115.     )
  116.  
  117. #draw(abscissa, ordinates)
  118.  
  119.  
  120. """
  121. #tube1
  122. incline1 = 202.1854583810828
  123. incline1 = 0.0020218545838108196
  124. r1 = 10**(-4) * 1
  125. #l1 = 40 * 0.01
  126. l1 = 1
  127. nu1 = np.pi * r1**4 / (8 * l1) * incline1
  128. print("nu1", nu1)
  129. #nu1 1.984951095977171e-14
  130.  
  131. #tube2
  132. #incline2 = 115.90762733277586
  133. incline2 = 0.001159076273327769
  134. r2 = 10**(-4) * 1.5
  135. l2 = 40 * 0.01
  136. nu2 = np.pi * r2**4 / (8 * l2) * incline2
  137. print("nu2", nu2)
  138.  
  139. #tube3
  140. #incline3 = 182.1185812306331
  141. incline3 =  0.0018211858123059585
  142.  
  143. r3 = 10**(-4) * 2
  144. l3 = 40 * 0.01
  145. nu3 = np.pi * r3**4 / (8 * l3) * incline3
  146. print("nu3", nu3)
  147. """
  148.  
  149.  
  150. r1 = 2*10**-3
  151. Q1 = np.array([4.5,4.0,3.8,3.1,2.5,1.9,1.4]) * 10**(-5)
  152. P1 = np.array([946.7,844.1,773.1,646.9,536.5,410.2,280.0])
  153. Q2 = np.array([8.2,8.8,8.2,8.0,8.0,7.6,6.8]) * 10**(-5)
  154. P2 = np.array([473.3,465.5,426.0,370.7,339.2,315.6,252.4])
  155. Q3 = np.array([9.3,9.7,9.5,9.5,9.5,8.9,8.9]) * 10**(-5)
  156. P3 = np.array([773.1,788.9,788.9,753.3,702.1,670.6,607.4])
  157. Q = np.mean(Q1)
  158. P = np.mean(P1)
  159. nu1 = np.pi*r1**4*P/(8*Q)
  160. print("nu1", nu1)
  161.  
  162.  
  163. r2 = 3*10**-3
  164. Q = np.mean(Q2)
  165. P = np.mean(P2)
  166. nu2 = np.pi*r2**4*P/(8*Q)
  167. print("nu2", nu2)
  168.  
  169. r3 = 4*10**-3
  170. Q = np.mean(Q3)
  171. P = np.mean(P3)
  172. nu3 = np.pi*r3**4*P/(8*Q)
  173. print("nu3", nu3)
  174.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement