upd
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def get_points_csv(column: int) -> list[int]:
|
||||
|
||||
with open(file="points.csv", mode="r") as points:
|
||||
res: list[int] = []
|
||||
|
||||
for line in points:
|
||||
row = line.split()
|
||||
try:
|
||||
res.append(row[column - 1])
|
||||
except Exception as e:
|
||||
print("something went wrong")
|
||||
raise e
|
||||
|
||||
return res[::-1]
|
||||
|
||||
|
||||
def get_plot(
|
||||
columns: list[int], label: str, xlabel: str, ylabel: str, filename: str, title: str
|
||||
) -> None:
|
||||
x = get_points_csv(column=columns[0])
|
||||
y = get_points_csv(column=columns[1])
|
||||
|
||||
print(f"x: {x}")
|
||||
print(f"y: {y}")
|
||||
|
||||
plt.plot(x, y, label=label, marker="o", markersize=6)
|
||||
|
||||
plt.xlabel(xlabel)
|
||||
plt.ylabel(ylabel)
|
||||
plt.xticks(rotation=45, fontsize=8)
|
||||
plt.yticks(fontsize=8)
|
||||
|
||||
plt.title(title)
|
||||
plt.legend()
|
||||
|
||||
plt.savefig(f"../assets/{filename}.png", bbox_inches="tight", dpi=300)
|
||||
plt.clf()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
get_plot(
|
||||
columns=[4, 7],
|
||||
label="B(H)",
|
||||
xlabel="H, А/м",
|
||||
ylabel="B, Тл",
|
||||
filename="b(h)",
|
||||
title="Кривая начального намагничивания",
|
||||
)
|
||||
|
||||
get_plot(
|
||||
columns=[4, 8],
|
||||
label="mu(H)",
|
||||
xlabel="H, А/м",
|
||||
ylabel="mu",
|
||||
filename="mu(h)",
|
||||
title="Зависимость магнитной проницаемости от напряженности магнитного поля",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,16 @@
|
||||
20 3.9 0.2 245.63 4.1 0.05 0.73 2365.56
|
||||
19 3.3 0.2 207.84 4.1 0.05 0.73 2795.66
|
||||
18 3.1 0.2 195.24 3.9 0.05 0.69 2830.85
|
||||
17 2.9 0.2 182.65 3.7 0.05 0.66 2870.90
|
||||
16 2.7 0.2 170.05 3.5 0.05 0.62 2916.88
|
||||
15 2.3 0.2 144.86 3.3 0.05 0.59 3228.49
|
||||
14 2.1 0.2 132.26 3.1 0.05 0.55 3321.67
|
||||
13 3.8 0.1 119.67 2.9 0.05 0.52 3434.46
|
||||
12 3.3 0.1 103.92 2.7 0.05 0.48 3682.08
|
||||
11 2.9 0.1 91.32 2.5 0.05 0.45 3879.59
|
||||
10 2.7 0.1 85.03 2.3 0.05 0.41 3833.61
|
||||
9 2.3 0.1 72.43 2.1 0.05 0.37 4108.99
|
||||
8 2.1 0.1 66.13 1.9 0.05 0.34 4071.72
|
||||
7 3.5 0.05 55.11 1.7 0.05 0.30 4371.74
|
||||
6 3.3 0.05 51.96 3.5 0.02 0.25 3818.46
|
||||
5 3.0 0.05 47.24 2.9 0.02 0.21 3480.25
|
||||
|
46
course2/sem3/labs_done/lab3.07_done/archive/scripts/main.py
Normal file
46
course2/sem3/labs_done/lab3.07_done/archive/scripts/main.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# from caas_jupyter_tools import display_dataframe_to_user
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
exp_data = [
|
||||
{"U":20,"X":3.9,"Kx":0.2,"H":245.63,"Y":4.1,"Ky":0.05,"B":0.73,"mu":2365.56},
|
||||
{"U":19,"X":3.3,"Kx":0.2,"H":207.84,"Y":4.1,"Ky":0.05,"B":0.73,"mu":2795.66},
|
||||
{"U":18,"X":3.1,"Kx":0.2,"H":195.24,"Y":3.9,"Ky":0.05,"B":0.69,"mu":2830.85},
|
||||
{"U":17,"X":2.9,"Kx":0.2,"H":182.65,"Y":3.7,"Ky":0.05,"B":0.66,"mu":2870.90},
|
||||
{"U":16,"X":2.7,"Kx":0.2,"H":170.05,"Y":3.5,"Ky":0.05,"B":0.62,"mu":2916.88},
|
||||
{"U":15,"X":2.3,"Kx":0.2,"H":144.86,"Y":3.3,"Ky":0.05,"B":0.59,"mu":3228.49},
|
||||
{"U":14,"X":2.1,"Kx":0.2,"H":132.26,"Y":3.1,"Ky":0.05,"B":0.55,"mu":3321.67},
|
||||
{"U":13,"X":3.8,"Kx":0.1,"H":119.67,"Y":2.9,"Ky":0.05,"B":0.52,"mu":3434.46},
|
||||
{"U":12,"X":3.3,"Kx":0.1,"H":103.92,"Y":2.7,"Ky":0.05,"B":0.48,"mu":3682.08},
|
||||
{"U":11,"X":2.9,"Kx":0.1,"H":91.32,"Y":2.5,"Ky":0.05,"B":0.45,"mu":3879.59},
|
||||
{"U":10,"X":2.7,"Kx":0.1,"H":85.03,"Y":2.3,"Ky":0.05,"B":0.41,"mu":3833.61},
|
||||
{"U":9,"X":2.3,"Kx":0.1,"H":72.43,"Y":2.1,"Ky":0.05,"B":0.37,"mu":4108.99},
|
||||
{"U":8,"X":2.1,"Kx":0.1,"H":66.13,"Y":1.9,"Ky":0.05,"B":0.34,"mu":4071.72},
|
||||
{"U":7,"X":3.5,"Kx":0.05,"H":55.11,"Y":1.7,"Ky":0.05,"B":0.30,"mu":4371.74},
|
||||
{"U":6,"X":3.3,"Kx":0.05,"H":51.96,"Y":3.5,"Ky":0.02,"B":0.25,"mu":3818.46},
|
||||
{"U":5,"X":3.0,"Kx":0.05,"H":47.24,"Y":2.9,"Ky":0.02,"B":0.21,"mu":3480.25}
|
||||
]
|
||||
|
||||
df = pd.DataFrame(exp_data)
|
||||
print(df[["U","H","B","mu"]])
|
||||
|
||||
plt.figure(figsize=(8,5))
|
||||
plt.plot(df["H"], df["B"], marker='o')
|
||||
plt.xlabel("H, A/m")
|
||||
plt.ylabel("B, T")
|
||||
plt.title("Кривая начального намагничивания B = B(H)")
|
||||
plt.grid(True)
|
||||
plt.tight_layout()
|
||||
plt.savefig("1.png", bbox_inches="tight", dpi=300)
|
||||
plt.show()
|
||||
|
||||
plt.figure(figsize=(8,5))
|
||||
plt.plot(df["H"], df["mu"], marker='o')
|
||||
plt.xlabel("H, A/m")
|
||||
plt.ylabel("μ")
|
||||
plt.title("Зависимость магнитной проницаемости μ = μ(H)")
|
||||
plt.grid(True)
|
||||
plt.tight_layout()
|
||||
plt.savefig("2.png", bbox_inches="tight", dpi=300)
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user