Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import IPython.display
- import numpy as np
- import matplotlib.pyplot as plt
- import pandas as pd
- import math
- from IPython import display
- from docx import Document
- from docx.shared import Inches
- data9_1 = [[1, 0.9, 1.586], [0.818, 1, 1.442]]
- # data9_1 =[[1, 0.8, 1.586], [0.553, 1, 1.07]]
- x_1 = 1000 * data9_1[0][0] / data9_1[0][2]
- x_2 = 1000 * data9_1[1][1] / data9_1[1][2]
- L_1 = x_1 / (2 * math.pi)
- L_2 = x_2 / (2 * math.pi)
- x_m1 = 1000 * data9_1[0][1] / data9_1[0][2]
- x_m2 = 1000 * data9_1[1][0] / data9_1[1][2]
- M_1 = x_m1 / (2 * math.pi)
- M_2 = x_m2 / (2 * math.pi)
- #
- first = pd.DataFrame({"U1,V": [data9_1[0][0], data9_1[1][0]],
- "U2,V": [data9_1[0][1], data9_1[1][1]],
- "I,mA": [data9_1[0][2], data9_1[1][2]],
- "x_i,Om": [round(x_1, 2), round(x_2, 2)],
- "L_i,mH": [round(L_1, 2), round(L_2, 2)],
- "x_mi,Om": [round(x_m1, 2), round(x_m2, 2)],
- "|M|,mH": [round(M_1, 2), round(M_2, 2)]}
- )
- print(first)
- print(f"|M_ср|={(M_1 + M_2) / 2}", f"X_m_ср={(x_m1 + x_m2) / 2}")
- print(f"k_1={M_1/pow(L_1*L_2,1/2)}\nk_2={M_2/pow(L_1*L_2,1/2)}")
- data9_2 = [[1, 0.487, 0.513, 0.407], [1, 0.336, 0.665, 5.272]]
- # data9_2 = [[1, 0.465, 0.535, 0.369], [1, 0.364, 0.636, 1.441]]
- # data9_2=[[1, 0.223, 0.771, 1.761], [1, 0.439, 0.561, 0.387]]
- x_mean = (x_m1 + x_m2) / 2
- M_mean = (M_1 + M_2) / 2
- L_eq1 = L_1 + L_2 - 2 * M_mean
- L_eq2 = L_1 + L_2 + 2 * M_mean
- x_eq1 = math.pi * 2 * L_eq1
- x_eq2 = math.pi * 2 * L_eq2
- I_th1 = 1000 * data9_2[0][0] / x_eq1
- U_11 = I_th1 * (x_1 - x_mean) / 1000
- U_21 = I_th1 * (x_2 - x_mean) / 1000
- I_th2 = 1000 * data9_2[1][0] / x_eq2
- U_12 = I_th2 * (x_1 + x_mean) / 1000
- U_22 = I_th2 * (x_2 + x_mean) / 1000
- print("\n\n")
- second = pd.DataFrame({"U,V": [data9_2[0][0], data9_2[1][0]],
- "U1,V": [data9_2[0][1], data9_2[1][1]],
- "U2,V": [data9_2[0][2], data9_2[1][2]],
- "I,mA": [data9_2[0][3], data9_2[1][3]],
- "I_th,mA": [I_th1, I_th2],
- "U1_th,V": [U_11, U_12],
- "U2_th,V": [U_21, U_22],
- "L_eq,mH": [L_eq1, L_eq2]})
- print(second)
- print(f"x_1={x_eq2}", f"x_2={x_eq1}")
- data9_3 = [[1, 1.641], [1, 21]]
- L_sog = (L_1 * L_2 - M_mean * M_mean) / (L_1 + L_2 - 2 * M_mean)
- I_sog = data9_3[0][0] / (2 * math.pi * L_sog)
- L_vst = (L_1 * L_2 - M_mean * M_mean) / (L_1 + L_2 + 2 * M_mean)
- I_vst = data9_3[0][0] / (2 * math.pi * L_vst)
- third = pd.DataFrame({"U": [data9_3[0][0], data9_3[1][0]],
- "I": [data9_3[0][1], data9_3[1][1]],
- "I_th": [I_sog * 1000, I_vst * 1000],
- "L_экв": [L_sog, L_vst]})
- print("\n", third)
- R_1 = 1000
- R_2 = 220
- t = [90, 70, 60, 40, 30, 10]
- A = 0.82
- print([A * t[i] / 100 for i in range(len(t))])
- def frequency_response(M, R, L_1, L_2, f):
- w = 2 * np.pi * f
- num = abs(M) * R
- first = pow((L_1 * L_2 - M * M) * pow(10, -6), 2)
- second = pow((L_1 * R) * pow(10, -3) / w, 2)
- den = w * pow(first + second, 0.5)
- return num / den / 1000
- document = Document()
- table1 = document.add_table(rows=2, cols=8)
- table1.cell(0,0).text = "1"
- table1.cell(0,1).text = str(data9_1[0][0])
- table1.cell(0,2).text = str(data9_1[0][1])
- table1.cell(0,3).text = str(data9_1[0][2])
- table1.cell(0,4).text = str(round(x_1, 2))
- table1.cell(0,5).text = str(round(L_1, 2))
- table1.cell(0,6).text = str(round(x_m1,2))
- table1.cell(0,7).text = str(round(M_1,2))
- table1.cell(1,0).text = "2"
- table1.cell(1,1).text = str(data9_1[1][0])
- table1.cell(1,2).text = str(data9_1[1][1])
- table1.cell(1,3).text = str(data9_1[1][2])
- table1.cell(1,4).text = str(round(x_2, 2))
- table1.cell(1,5).text = str(round(L_2, 2))
- table1.cell(1,6).text = str(round(x_m2,2))
- table1.cell(1,7).text = str(round(M_2,2))
- table1.style = "Table Grid"
- frequency = [1.588, 4.886, 6.8, 11.54, 15.033, 33.23, 294.374, 2786, 5765, 7509, 12743, 17734, 54566]
- exp = [0.088, 0.261, 0.350, 0.521, 0.609, 0.798, 0.882, 0.791, 0.615, 0.528, 0.355, 0.266, 0.09]
- th = [frequency_response(M_mean, R_1, L_1, L_2, frequency[i]) for i in range(len(frequency))]
- table = document.add_table(rows=14, cols=6)
- for i in range(13):
- table.cell(i+1, 0).text = str(round(frequency[i],3))
- table.cell(i+1, 1).text = str(round(exp[i],3))
- table.cell(i+1, 2).text = str(round(th[i],3))
- table.style = "Table Grid"
- table.cell(0, 0).text = "frequency"
- table.cell(0, 1).text = "exp"
- table.cell(0, 2).text = "th"
- # Строим график с двумя кривыми
- data1 = pd.DataFrame({"frequency": frequency, "exp": exp, "th": th})
- # IPython.display.display(data1)
- # print(data1)
- plt.figure(figsize=(10, 6))
- plt.plot(frequency, exp, label="exp", linestyle='-', )
- plt.plot(frequency, th, label="th", linestyle='-.', )
- plt.xscale("log", base=2)
- plt.xlabel("Частота (Гц)")
- plt.ylabel("АЧХ R=1000")
- plt.legend()
- plt.show()
- frequency = [1.487, 4.886, 6.8, 11.54, 15.033, 29.115, 142.269, 695, 1345, 1754, 2976, 4142, 12743]
- exp = [0.080, 0.252, 0.336, 0.499, 0.581, 0.735, 0.822, 0.733, 0.579, 0.496, 0.334, 0.250, 0.085]
- th = [frequency_response(M_mean, R_2, L_1, L_2, frequency[i]) for i in range(len(frequency))]
- data2 = pd.DataFrame({"frequency": frequency, "exp": exp, "th": th})
- # print(data2)
- # IPython.display.display(data2)
- plt.figure(figsize=(10, 6))
- plt.plot(frequency, exp, label="exp", linestyle='-', )
- plt.plot(frequency, th, label="th", linestyle='-.', )
- plt.xscale("log", base=2)
- plt.xlabel("Частота (Гц)")
- plt.ylabel("АЧХ R=220")
- plt.legend()
- plt.show()
- for i in range(13):
- table.cell(i+1, 3).text = str(round(frequency[i],3))
- table.cell(i+1, 4).text = str(round(exp[i],3))
- table.cell(i+1, 5).text = str(round(th[i],3))
- table.cell(0, 3).text = "frequency"
- table.cell(0, 4).text = "exp"
- table.cell(0, 5).text = "th"
- document.save("document.docx")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement