first commit

This commit is contained in:
Дмитрий Пунов 2022-09-25 17:45:59 +03:00
commit 7532722c8f
10 changed files with 225 additions and 0 deletions

22
1,5mA.csv Normal file
View File

@ -0,0 +1,22 @@
24.98,27.17
22.2,26.39
19.3,25.41
16.15,24.39
13.22,23.29
10.24,21.32
7.97,18.88
6.22,15.96
4.39,12.55
2.14,6.32
0.69,2.6
-25.1,-29.19
-22.12,-28.19
-19.07,-27.2
-16.13,-26.18
-13.12,-24.34
-10.42,-22.97
-8.17,-20.06
-6.08,-16.45
-4.37,-11.93
-2.02,-6.33
-0.5,-1.65
1 24.98 27.17
2 22.2 26.39
3 19.3 25.41
4 16.15 24.39
5 13.22 23.29
6 10.24 21.32
7 7.97 18.88
8 6.22 15.96
9 4.39 12.55
10 2.14 6.32
11 0.69 2.6
12 -25.1 -29.19
13 -22.12 -28.19
14 -19.07 -27.2
15 -16.13 -26.18
16 -13.12 -24.34
17 -10.42 -22.97
18 -8.17 -20.06
19 -6.08 -16.45
20 -4.37 -11.93
21 -2.02 -6.33
22 -0.5 -1.65

22
3mA.csv Normal file
View File

@ -0,0 +1,22 @@
24.98,56.46
21.78,54.35
19.03,53.45
16.18,58.73
13.49,26
10.41,45.8
7.77,39.75
5.96,33.4
4.39,26.79
1.92,14.53
0.55,6.48
-25.1,-60.56
-21.87,-58.7
-19.14,-57.05
-16.4,-55.78
-13.2,-52.7
-10.12,-47.06
-8.1,-42.24
-6.16,-35.07
-4.26,-26.24
-2.11,-14.42
-0.5,-5.19
1 24.98 56.46
2 21.78 54.35
3 19.03 53.45
4 16.18 58.73
5 13.49 26
6 10.41 45.8
7 7.77 39.75
8 5.96 33.4
9 4.39 26.79
10 1.92 14.53
11 0.55 6.48
12 -25.1 -60.56
13 -21.87 -58.7
14 -19.14 -57.05
15 -16.4 -55.78
16 -13.2 -52.7
17 -10.12 -47.06
18 -8.1 -42.24
19 -6.16 -35.07
20 -4.26 -26.24
21 -2.11 -14.42
22 -0.5 -5.19

22
5mA.csv Normal file
View File

@ -0,0 +1,22 @@
24.98,105.85
21.94,103.84
19.09,101.27
16,97.68
13.1,91.76
9.74,80.93
8.1,73.68
6.12,62.93
4.1,49.76
2.1,32.23
0.5,18.01
-25,-113.54
-22.05,-110.88
-19.31,-108.29
-16.39,-103.44
-12.91,-96.33
-10.23,-87.22
-7.88,-75.27
-6,-64.18
-4.1,-49.99
-1.9,-30.78
-0.5,-18.87
1 24.98 105.85
2 21.94 103.84
3 19.09 101.27
4 16 97.68
5 13.1 91.76
6 9.74 80.93
7 8.1 73.68
8 6.12 62.93
9 4.1 49.76
10 2.1 32.23
11 0.5 18.01
12 -25 -113.54
13 -22.05 -110.88
14 -19.31 -108.29
15 -16.39 -103.44
16 -12.91 -96.33
17 -10.23 -87.22
18 -7.88 -75.27
19 -6 -64.18
20 -4.1 -49.99
21 -1.9 -30.78
22 -0.5 -18.87

116
Analize.py Normal file
View File

@ -0,0 +1,116 @@
from contextlib import redirect_stderr
import numpy as np
from matplotlib import pyplot as plt
import csv
import scipy.constants as sp
def main():
print("Code is running.")
plot_UI(open_CSV("U(I).csv"))
plot_UIs(open_CSV("1,5mA.csv"), '[1,5mA]')
plot_UIs(open_CSV("3mA.csv"), '[3mA]')
plot_UIs(open_CSV("5mA.csv"), '[5mA]')
def open_CSV(filename):
with open('/home/dmitrii/Physics Labs/3.5.1/' + filename, newline="") as csvfile:
datareader = csv.reader(csvfile, delimiter=",", quotechar="|")
data = []
for row in datareader:
res = [float(i) for i in row]
data.append(res)
data = np.array(data)
return data
def plot_UI(data):
plt.scatter(data[:, 1][0:23], data[:, 0][0:23], color="g")
plt.scatter(data[:, 1][23:len(data)], data[:, 0]
[23:len(data)], color="orange")
plt.xticks(np.arange(min(data[:, 1])-0.25, max(data[:, 1])+0.25, 0.25))
plt.yticks(np.arange(min(data[:, 0])-1, max(data[:, 0])+1, 1))
A = np.vstack([data[:, 1][5:12], np.ones(len(data[:, 1][5:12]))]).T
alpha = np.dot((np.dot(np.linalg.inv(np.dot(A.T, A)), A.T)),
data[:, 0][5:12])
var = str(round(alpha[1]*10**3))
delta = str(abs(round(alpha[0]*10**3)))
print("Максимальное дифференциальное сопротивление разряда: {}".format(
var) + u" \u00B1 " + "{}, Ом".format(delta))
plt.plot(data[:, 1][5:12], alpha[0]*data[:, 1][5:12]+alpha[1], 'r')
plt.ylabel('U, В', fontsize=20)
plt.xlabel('I, мкА', fontsize=20)
plt.grid()
plt.savefig('U(I).png')
plt.show()
def centre(data):
xdiff = [data[n]-data[n-1] for n in range(1, len(data))]
return sum(xdiff)/2
def bfl(data):
line = np.polyfit(data[:, 0], data[:, 1], 1)
return line
def plot_UIs(data, num):
ax = plt.gca()
ax.spines['top'].set_color('none')
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
plt.scatter(data[:, 0], data[:, 1], color="g",
marker="+", s=100) # Make a scatter plot
data = np.array(sorted(data, key=lambda x: x[0], reverse=True))
line1 = bfl(data[len(data)-5:len(data)])
line2 = bfl(data[0:5])
aprox = bfl(data[4:len(data)-5])
x1 = (line1[1]-aprox[1])/(aprox[0]-line1[0])
y1 = line1[0]*x1+line1[1]
plt.plot(x1, y1, marker='+', color='red')
x2 = (line2[1]-aprox[1])/(aprox[0]-line2[0])
y2 = line2[0]*x2+line2[1]
plt.plot(x2, y2, marker='+', color='red')
plt.plot((data[:, 0][len(data)-5:len(data)]), (data[:, 0]
[len(data)-5:len(data)]*line1[0]+line1[1]), color="orange")
plt.plot([x1, 0], [y1, line1[1]], linestyle="dashed", color="orange",
label='Ток насыщения: ' + str(round(line1[1], 2)) + ' ,А')
plt.plot(data[:, 0][0:5], data[:, 0]
[0:5]*line2[0]+line2[1], color="orange")
plt.plot([x2, 0], [y2, line2[1]], linestyle="dashed", color="orange",
label='Ток насыщения: ' + str(round(line2[1], 3)) + ' ,А')
S = sp.pi*0.2*10**-4*5.2*10**-4
me = 22*1.66*10**-27
Te = x2/2*11400
ni = line2[1]/0.4/sp.e/S/np.sqrt(2*sp.k*Te/me)/10**14
wp = np.sqrt(4*np.pi*ni*sp.e**2/me)*10**10
rde = np.sqrt(sp.k*Te/4/sp.pi/ni/sp.e**2)*10**-5
rd = np.sqrt(sp.k*300/4/sp.pi/ni/sp.e**2)
Nd = 4/3*sp.pi*rd**3*ni
print("-----Exp{}-----".format(num))
print("Ток насыщения: {},{}".format(
round(line1[1], 3), round(line2[1], 3)))
print("Te = {}".format(Te ))
print("Ni = {}".format(ni))
print("wp = {}".format(wp))
print("rde = {}".format(rde))
print("rd = {}".format(rd))
print("Nd = {}".format(Nd))
print("---------------")
plt.xlabel('U, В', fontsize=20)
plt.ylabel('I, мкА', fontsize=20)
plt.grid()
ax.legend()
plt.savefig(num + '.png')
plt.show()
return plt
def plotAll(plot1, plot2, plot3):
return True
if __name__ == "__main__":
main()

0
README.md Normal file
View File

43
U(I).csv Normal file
View File

@ -0,0 +1,43 @@
34.85,0.5
34.3,0.8
33.76,1
33.33,1.16
32.96,1.4
32.39,1.6
30.24,1.8
29.02,2
28.19,2.2
27.59,2.4
26.69,2.6
26.25,2.8
27.08,3
27.06,3.2
26.51,3.4
25.82,3.6
25.33,3.8
24.91,4.04
24.68,4.24
24.48,4.4
24.29,4.64
24.21,4.76
24.37,4.56
24.61,4.32
24.75,4.2
24.99,4.04
25.45,3.8
26.07,3.56
26.57,3.4
27.09,2.34
27.26,3
26.43,2.8
26.44,2.6
27.49,2.4
28.31,2.2
29.04,1.96
30.33,1.8
32.62,1.56
32.88,1.4
33.32,1.2
33.74,1.04
34.22,0.8
34.59,0.6
1 34.85 0.5
2 34.3 0.8
3 33.76 1
4 33.33 1.16
5 32.96 1.4
6 32.39 1.6
7 30.24 1.8
8 29.02 2
9 28.19 2.2
10 27.59 2.4
11 26.69 2.6
12 26.25 2.8
13 27.08 3
14 27.06 3.2
15 26.51 3.4
16 25.82 3.6
17 25.33 3.8
18 24.91 4.04
19 24.68 4.24
20 24.48 4.4
21 24.29 4.64
22 24.21 4.76
23 24.37 4.56
24 24.61 4.32
25 24.75 4.2
26 24.99 4.04
27 25.45 3.8
28 26.07 3.56
29 26.57 3.4
30 27.09 2.34
31 27.26 3
32 26.43 2.8
33 26.44 2.6
34 27.49 2.4
35 28.31 2.2
36 29.04 1.96
37 30.33 1.8
38 32.62 1.56
39 32.88 1.4
40 33.32 1.2
41 33.74 1.04
42 34.22 0.8
43 34.59 0.6

BIN
U(I).png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
[1,5mA].png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
[3mA].png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
[5mA].png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB