From 320bf2f0155edd67557a3042403eeb843b90a41d Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Sun, 9 Mar 2025 23:15:32 +0300 Subject: added 219 --- 219/Makefile | 18 +++++++++++++++ 219/README.md | 5 +++++ 219/compile_flags.txt | 4 ++++ 219/data | 13 +++++++++++ 219/data2 | 12 ++++++++++ 219/include | 1 + 219/main.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 219/plots.gp | 29 ++++++++++++++++++++++++ 8 files changed, 143 insertions(+) create mode 100644 219/Makefile create mode 100644 219/README.md create mode 100644 219/compile_flags.txt create mode 100644 219/data create mode 100644 219/data2 create mode 120000 219/include create mode 100644 219/main.cpp create mode 100644 219/plots.gp (limited to '219') diff --git a/219/Makefile b/219/Makefile new file mode 100644 index 0000000..224506f --- /dev/null +++ b/219/Makefile @@ -0,0 +1,18 @@ + +CFLAGS = -std=c++2c -mavx -Iinclude -ggdb + +.PHONY: all run_main clean gnuplot + +run: gnuplot + +gnuplot: plots.gp run_main + gnuplot $< &>/dev/null + +run_main: main + ./main + +main: main.cpp include/* + $(CXX) -o $@ $< $(CFLAGS) + +clean: + rm -fr main *.png *.plot diff --git a/219/README.md b/219/README.md new file mode 100644 index 0000000..96fd716 --- /dev/null +++ b/219/README.md @@ -0,0 +1,5 @@ + + +# Обработка <> прака + + diff --git a/219/compile_flags.txt b/219/compile_flags.txt new file mode 100644 index 0000000..34ae930 --- /dev/null +++ b/219/compile_flags.txt @@ -0,0 +1,4 @@ +-Iinclude +-std=c++2c +-mavx2 + diff --git a/219/data b/219/data new file mode 100644 index 0000000..2cb863c --- /dev/null +++ b/219/data @@ -0,0 +1,13 @@ +I U R W +25 0.13 ? ? +100 0.54 ? ? +155 0.87 ? ? +200 1.14 ? ? +275 1.66 ? ? +350 2.25 ? ? +300 1.83 ? ? +250 1.48 ? ? +200 1.14 ? ? +150 0.85 ? ? +100 0.56 ? ? +50 0.26 ? ? diff --git a/219/data2 b/219/data2 new file mode 100644 index 0000000..9c44794 --- /dev/null +++ b/219/data2 @@ -0,0 +1,12 @@ +n I_V DP DP' A +? 2 1 ? ? +? 2.85 1.9 ? ? +? 5.8 2.7 ? ? +? 8.7 5 ? ? +? 13 7.9 ? ? +? 11.5 6.7 ? ? +? 7.7 4.5 ? ? +? 4.2 2.8 ? ? +? 3 2 ? ? +? 2.4 1.3 ? ? +? 2 1.1 ? ? diff --git a/219/include b/219/include new file mode 120000 index 0000000..2225752 --- /dev/null +++ b/219/include @@ -0,0 +1 @@ +../libprakpp/include/ \ No newline at end of file diff --git a/219/main.cpp b/219/main.cpp new file mode 100644 index 0000000..f6fc4e2 --- /dev/null +++ b/219/main.cpp @@ -0,0 +1,61 @@ +#include + +#include "include/praktable.hpp" + +using table = prak::table; +using f64p = prak::pvalue; +using f64v = std::vector; +using vecarg = const std::vector &; +using argvec = const std::vector &; + +f64p (ex1) (std::string file) { + table t(file); + t .add_columns({"sI", "sU", "sR", "sW"}) + .multiply_column("I", 1e-3) + .apply(prak::mul, "U", "sU") + .apply(prak::add, "sU", "sU") + .apply(prak::mul, "I", "sI") + .apply_function([](argvec a){ return a[0]/a[1]; }, {"U", "I"}, {"sU", "sI"}, "R", "sR") + .apply_function(prak::prod, {"U", "I"}, {"sU", "sI"}, "W", "sW") + .write_plot_4("R(W).plot", "W", "R", "sW", "sR") + .print(); + auto [A, B] = t.least_squares_linear("W", "R", "sR", std::nullopt); + std::cout << "МНК R(W): A = " << A << "; B = " << B << '\n'; + f64p alpha = {3.5e-3, 5e-5}, + L = {0.25, 0.005}, + r_2 = {0.006, 5e-6}, r_1 = {0.075e-3, 5e-6}, + k = prak::function([](vecarg a){ return a[0] * a[1] / (2 * prak::PI * a[2] * a[3]) * std::log(a[4]/a[5]);}, {alpha, B, L, A, r_2, r_1}); + std::cout << "k = " << k << '\n'; + f64p eps = {0.35, 0.005}, sgm = {5.67e-8, 0.01e-8}, + S = prak::function([](vecarg a){ return 2 * prak::PI * a[0] * a[1]; }, {r_1, L}), + R = {t.col_avg("R"), 0}, dT = prak::function([](vecarg a){return std::abs((a[0] - a[1])/(a[1]*a[2]));}, {R, B, alpha}), + T_0 = {295, 5}, T_1 = T_0 + dT, W_rad = eps * sgm * (T_1*T_1*T_1*T_1 - T_0*T_0*T_0*T_0)*S, + g = {9.8, 0.05}, beta = 1.0 / T_0, nu = {1.6e-5, 0.1e-5}, Gr = g * beta * L * L * L * dT / nu / nu, + alpha2 = 0.75 * k / L * ((0.7 * Gr) ^ 0.25), W_con = alpha2 * dT * S; + std::cout var(eps) var(sgm) var(R) var(dT) var(T_0) var(T_1) var(W_rad) var(beta) var(nu) var(Gr) var(alpha2) var(W_con); + return k; +} + +f64p (ex2) (const std::string& s) { + table t(s); + t .multiply_column("I_V", 1e-6) + .apply(prak::mul, "DP", "DP'") + .write_plot("I_V(DP).plot", "DP'", "I_V", std::nullopt) + .print(); + // gnuplot дал оценку лучше + f64p A = {1.24834e-09, 5.18e-11}, + B = {1.57878e-07, 2.787e-07}; + + f64p R = {1e-3, 5e-5}, l = {0.23, 0.005}, eta = prak::PI * (R^4.0) / (8.0 * l * A), + Re = 2.0 * f64p{1.2041, 0.02} * t.col_max("I_V") / (eta * prak::PI * R); + std::cout var(A) var(B) var(eta) var(Re) << std::endl; + return eta; +} + +int (main) (void) { + std::cout << ex1("data") / ex2("data2") / 2.0 + << " = C_P\nпо табличным значениям: C_P = " << 0.0259 / 0.001004 / 2 + << "\nПо здравому смыслу:7/2R = " << 7.0/2 * 8.31 << std::endl; + + return 0; +} diff --git a/219/plots.gp b/219/plots.gp new file mode 100644 index 0000000..9e1a17e --- /dev/null +++ b/219/plots.gp @@ -0,0 +1,29 @@ +set term pngcairo size 1000, 800 +set grid + +f1(x) = a1*x+b1 +fit f1(x) 'R(W).plot' using 1:2:3:4 xyerr via a1, b1 + +set output 'R(W).png' +set title "График зависимости сопротивления R от тепловой мощности W" +set xlabel "W, Дж" +set ylabel "R, Ом" +set label sprintf("A = %.5g\n B = %.5g", a1, b1) at graph 0.1, 0.9 front boxed +plot 'R(W).plot' using 1:2:3:4 with xyerrorbars notitle lc 0 pt 1 lw 2, \ + f1(x) title "R(W)" lc rgb "red" + +reset + +f2(x) = a2*x+b2 +fit f2(x) 'I_V(DP).plot' via a2, b2 + + set output 'I_V(DP).png' + set title "График зависимости плотности потока от разницы давлений" + set xlabel "P-P_0, Па" + set ylabel "I_V, м^3/с" +set label sprintf("A = %.5g\n B = %.5g", a2, b2) at graph 0.1, 0.9 front boxed + +plot 'I_V(DP).plot' notitle lc 0 pt 1 lw 2, \ + f2(x) title "I_V(dP)" lc rgb "red" + + -- cgit v1.2.3-70-g09d2