aboutsummaryrefslogtreecommitdiffstats
path: root/219
diff options
context:
space:
mode:
Diffstat (limited to '219')
-rw-r--r--219/Makefile18
-rw-r--r--219/README.md5
-rw-r--r--219/compile_flags.txt4
-rw-r--r--219/data13
-rw-r--r--219/data212
l---------219/include1
-rw-r--r--219/main.cpp61
-rw-r--r--219/plots.gp29
8 files changed, 143 insertions, 0 deletions
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 @@
+<!-- Шаблон для прака -->
+<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean -->
+# Обработка <> прака
+
+
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 <iostream>
+
+#include "include/praktable.hpp"
+
+using table = prak::table<f64>;
+using f64p = prak::pvalue<f64>;
+using f64v = std::vector<f64>;
+using vecarg = const std::vector<f64> &;
+using argvec = const std::vector<f64> &;
+
+f64p (ex1) (std::string file) {
+ table t(file);
+ t .add_columns({"sI", "sU", "sR", "sW"})
+ .multiply_column("I", 1e-3)
+ .apply(prak::mul<f64, 0.0025>, "U", "sU")
+ .apply(prak::add<f64, 0.02>, "sU", "sU")
+ .apply(prak::mul<f64, 0.01>, "I", "sI")
+ .apply_function([](argvec a){ return a[0]/a[1]; }, {"U", "I"}, {"sU", "sI"}, "R", "sR")
+ .apply_function(prak::prod<f64>, {"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<f64>([](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<f64>([](vecarg a){ return 2 * prak::PI * a[0] * a[1]; }, {r_1, L}),
+ R = {t.col_avg("R"), 0}, dT = prak::function<f64>([](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<f64, 1333.224>, "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"
+
+