Savelyev_Vyacheslav

DuvalTryAng1

Mar 6th, 2022 (edited)
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. import numpy as np # мадуль для массива
  2. import matplotlib.pyplot as plt # для графиков
  3. step = 1 # шаг
  4. end = 100 # сторона треугольника
  5.  
  6. def makeTryAngl(step, end_): # создает все точки на треугольнике формат Дюваля массив []
  7. arTotal = []
  8. for i in np.arange(0, end_+1, step):
  9. for j in np.arange(0, end_+1, step):
  10. x = end_ - round(i,1)
  11. y = round(j,2)
  12. bary = end_-x-y
  13. if bary >= 0:
  14. x = end_ - round(i,1)
  15. y = round(j,2)
  16. z = end_ - x - y
  17. arTotal.append([x,y,z])
  18. return arTotal
  19.  
  20. def DuvToCoor(TryAngl): # меняет формат точек из дюваля в классический (Х и У) формат массив
  21. Draw = []
  22. for item in TryAngl:
  23. y = item[1]*3**0.5/2
  24. x = end - item[0] - item[1]*0.5
  25. Draw.append([x,y])
  26. return Draw
  27.  
  28. def CATsection(TryAngl, x1,x2, y1,y2, z1,z2): # вырезает куски графика где x1 начало х2 конец
  29. leg=[]
  30. for item in TryAngl:
  31. if (item[0] >= x1 and item[0] <= x2) and (item[1] >= y1 and item[1] <= y2) and (item[2] >= z1 and item[2] <= z2):
  32. leg.append(tuple(item))
  33. return set(leg)
  34.  
  35. def graf(TryAngl, color_="none"): # отрисовывет на графике массив точек
  36. font1 = {'family':'serif','color':'blue','size':20}
  37. font2 = {'family':'serif','color':'darkred','size':15}
  38. plt.title("DuvalTriAngle", fontdict = font1)
  39. plt.xlabel("C2H2", fontdict = font2)
  40. plt.ylabel("CH4", fontdict = font2)
  41. z = 3**0.5/2; p = 5
  42. # os Y
  43. plt.text(0, 10*z, "10"); plt.text(p, 20*z, "20"); plt.text(2*p, 30*z, "30")
  44. plt.text(3*p, 40*z, "40"); plt.text(4*p, 50*z, "50"); plt.text(5*p, 60*z, "60"); plt.text(6*p, 70*z, "70")
  45. plt.text(7*p, 80*z, "80"); plt.text(8*p, 90*z, "90"); plt.text(9*p, 101*z, "100");
  46. # os Z
  47. plt.text(102-p, 10*z, "90"); plt.text(100-2*p, 20*z, "80"); plt.text(100-3*p, 30*z, "70")
  48. plt.text(100-4*p, 40*z, "60"); plt.text(100-5*p, 50*z, "50"); plt.text(100-6*p, 60*z, "40")
  49. plt.text(100-7*p, 70*z, "30"); plt.text(100-8*p, 80*z, "20"); plt.text(100-9*p, 90*z, "10");
  50. #Ось X
  51. ds=-3.5
  52. plt.text(-3, ds, "0"); plt.text(10, ds, "10"); plt.text(20, ds, "20")
  53. plt.text(30, ds, "30"); plt.text(40, ds, "40"); plt.text(50, ds, "50"); plt.text(60, ds, "60")
  54. plt.text(70, ds, "70"); plt.text(80, ds, "80"); plt.text(90, ds, "90"); plt.text(100, ds, "100");
  55. Draw = DuvToCoor(TryAngl)
  56. frame = plt.gca()
  57.  
  58. frame.axes.get_xaxis().set_ticks([])
  59. frame.axes.get_yaxis().set_ticks([])
  60. plt.yticks(rotation=-30)
  61. plt.tick_params(axis='y', which='both', labelleft=False, labelright=True)
  62. x1, y1 = zip(*Draw); x1 = list(x1); y1 = list(y1)
  63. if color_ == "none":
  64. plt.plot(x1, y1)
  65. else:
  66. plt.plot(x1, y1, color = color_)
  67.  
  68.  
  69. def grafPtr(x,y,z): # отрисовывет на графике точку
  70. pp = 100/(x+y+z)
  71. Draw = DuvToCoor([[x*pp,y*pp,z*pp]])
  72. x1, y1 = zip(*Draw); x1 = list(x1); y1 = list(y1)
  73. plt.plot(x1, y1,color = "black", marker = "o", linestyle= "--", linewidth = 1, markersize = 10)
  74.  
  75. TryAngl = makeTryAngl(step, end) # все точки в треугольнике Дюваля формат массив
  76. copy = CATsection(TryAngl, 0,100, 0,100, 0,100) # копия всех почек в формате set{}
  77. D1 = CATsection(TryAngl, 14,100, 0,100, 0,23) # Частичный разряд (ЧР)
  78. PD = CATsection(TryAngl, 0,100, 98,100, 0,100) # Частичный разряд (ЧР)
  79. T1 = CATsection(TryAngl, 0, 4, 0, 98, 0, 20) # Тепловое повреждение (Т1) возникает в масле и (или) в бумаге при температуре ниже 300 °С
  80. T2 = CATsection(TryAngl, 0, 4, 0, 100, 20, 50) # Тепловое повреждение (Т2) возникает в масле и (или) в бумаге при температуре выше 300 °C и ниже 700 °C
  81. T3 = CATsection(TryAngl, 0, 15, 0, 100, 50, 100) # Тепловое повреждение (Т3) возникает в масле и (или) в бумаге при температуре выше 700 °C с явными признаками карбонизации масла, окрашивания металла (при 800 °C) или плавления металла (при температуре ниже 1000 °C).
  82.  
  83. D2_1 = CATsection(TryAngl, 15, 100, 0, 100, 23, 40) # Разряды низкой энергии (D2) составной
  84. D2_2 = CATsection(TryAngl, 29, 100, 0, 100, 40, 100) # Разряды высокой энергии (D2) составной
  85.  
  86. DT_1 = CATsection(TryAngl, 14,29, 0,100, 50,100) # Сочетание тепловых повреждений и разрядов составной
  87. DT_2 = CATsection(TryAngl, 4,29, 0,100, 40,50) # Сочетание тепловых повреждений и разрядов составной
  88. DT_3 = CATsection(TryAngl, 4,14, 0,100, 0,40) # Сочетание тепловых повреждений и разрядов составной
  89. ArAll = [D1, PD, T1, T2, T3, D2_1, D2_2, DT_1, DT_2, DT_3]
  90. AllName = ['D1', 'PD', 'T1', 'T2', 'T3', 'D2', 'D2', 'DT', 'DT', 'DT']
  91.  
  92. #graf(TryAngl)
  93.  
  94. def ALL():
  95. graf(D2_1,'orange')
  96. graf(D2_2, 'orange')
  97. graf(T3, "#f3f")
  98. graf(T2, '#f00')
  99. graf(T1, "#3fc")
  100. graf(PD, "#099")
  101. graf(D1, "#666")
  102. graf(DT_1, '#75ff89')
  103. graf(DT_2, '#75ff89')
  104. graf(DT_3, '#75ff89')
  105.  
  106. def Find(C2H2,CH4,C2H4, ArAll, AllName):
  107. j=0
  108. pp = 100/(C2H2+CH4+C2H4)
  109. C2H2 = round(C2H2*pp, 0)
  110. CH4 = round(CH4*pp, 0)
  111. C2H4 = round(C2H4*pp, 0)
  112. for i in ArAll:
  113. if(C2H2,CH4,C2H4) in i:
  114. print(AllName[j])
  115. j+=1
  116.  
  117.  
  118.  
  119. while True:
  120. ALL()
  121. C2H2 = float(input('C2H2 = '))
  122. CH4 = float(input('CH4 = '))
  123. C2H4 = float(input('C2H4 = '))
  124. if C2H2+CH4+C2H4==0:
  125. print("Сумма газов не может быть равна 0")
  126. continue
  127. Find(C2H2,CH4,C2H4, ArAll,AllName)
  128. grafPtr(C2H2,CH4,C2H4)
  129. plt.show()
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
Add Comment
Please, Sign In to add comment