commit 7532722c8f82477bf23d614df29236630aeb6560 Author: Dmitrii Date: Sun Sep 25 17:45:59 2022 +0300 first commit diff --git a/1,5mA.csv b/1,5mA.csv new file mode 100644 index 0000000..a96f1a8 --- /dev/null +++ b/1,5mA.csv @@ -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 \ No newline at end of file diff --git a/3mA.csv b/3mA.csv new file mode 100644 index 0000000..17d7c4f --- /dev/null +++ b/3mA.csv @@ -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 \ No newline at end of file diff --git a/5mA.csv b/5mA.csv new file mode 100644 index 0000000..16e293f --- /dev/null +++ b/5mA.csv @@ -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 \ No newline at end of file diff --git a/Analize.py b/Analize.py new file mode 100644 index 0000000..ecb1399 --- /dev/null +++ b/Analize.py @@ -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() diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/U(I).csv b/U(I).csv new file mode 100644 index 0000000..aa5ddb2 --- /dev/null +++ b/U(I).csv @@ -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 \ No newline at end of file diff --git a/U(I).png b/U(I).png new file mode 100644 index 0000000..46d46b8 Binary files /dev/null and b/U(I).png differ diff --git a/[1,5mA].png b/[1,5mA].png new file mode 100644 index 0000000..f3f71f7 Binary files /dev/null and b/[1,5mA].png differ diff --git a/[3mA].png b/[3mA].png new file mode 100644 index 0000000..b163b08 Binary files /dev/null and b/[3mA].png differ diff --git a/[5mA].png b/[5mA].png new file mode 100644 index 0000000..eb147d1 Binary files /dev/null and b/[5mA].png differ