aboutsummaryrefslogtreecommitdiffstats
path: root/227
diff options
context:
space:
mode:
Diffstat (limited to '227')
-rw-r--r--227/Makefile18
-rw-r--r--227/README.md5
-rw-r--r--227/compile_flags.txt4
-rw-r--r--227/data16
l---------227/include1
-rw-r--r--227/main.cpp83
-rw-r--r--227/plots.gp31
7 files changed, 148 insertions, 0 deletions
diff --git a/227/Makefile b/227/Makefile
new file mode 100644
index 0000000..224506f
--- /dev/null
+++ b/227/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/227/README.md b/227/README.md
new file mode 100644
index 0000000..96fd716
--- /dev/null
+++ b/227/README.md
@@ -0,0 +1,5 @@
+<!-- Шаблон для прака -->
+<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean -->
+# Обработка <> прака
+
+
diff --git a/227/compile_flags.txt b/227/compile_flags.txt
new file mode 100644
index 0000000..34ae930
--- /dev/null
+++ b/227/compile_flags.txt
@@ -0,0 +1,4 @@
+-Iinclude
+-std=c++2c
+-mavx2
+
diff --git a/227/data1 b/227/data1
new file mode 100644
index 0000000..3e94706
--- /dev/null
+++ b/227/data1
@@ -0,0 +1,6 @@
+T h1 h2 p sp ln(p) 1/T t1 t2 t3 t st nu snu
+27.5 11.9 9.3 ? ? ? ? 77.1 76.5 78.1 ? ? ? ?
+29.5 12.0 9.2 ? ? ? ? 71.5 69.9 70.1 ? ? ? ?
+34.5 12.5 8.8 ? ? ? ? 51 48.9 48.8 ? ? ? ?
+37.5 12.8 8.5 ? ? ? ? 41.3 40.5 41.8 ? ? ? ?
+40.0 13.1 8.1 ? ? ? ? 36.1 37.0 35.9 ? ? ? ?
diff --git a/227/include b/227/include
new file mode 120000
index 0000000..2225752
--- /dev/null
+++ b/227/include
@@ -0,0 +1 @@
+../libprakpp/include/ \ No newline at end of file
diff --git a/227/main.cpp b/227/main.cpp
new file mode 100644
index 0000000..7c4c912
--- /dev/null
+++ b/227/main.cpp
@@ -0,0 +1,83 @@
+#include <iostream>
+
+#include "include/praktable.hpp"
+#include "include/prakphys.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> &;
+
+template <typename T>
+std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
+ os << "{ ";
+ for (const auto& val: vec) os << val << ", ";
+ os << "} ";
+ return os;
+}
+
+auto ex1(std::string file) {
+ table t(file);
+ t.column_width = 12;
+ std::cout << t
+ .apply(prak::diff<f64>, {"h1", "h2"}, "p")
+ .fill_column("sp", 0.1 * std::sqrt(2.0))
+ .apply(prak::log<f64>, {"p"}, "ln(p)")
+ .add_column("s_ln(p)")
+ .apply(prak::quot<f64>, {"sp", "p"}, "s_ln(p)")
+ .apply(prak::add<f64, conv::C_to_K<f64>>, {"T"}, "T")
+ .apply(prak::inv<f64>, {"T"}, "1/T")
+ .apply(prak::avg<f64>, {"t1", "t2", "t3"}, "t")
+ .apply(prak::stddev<f64>, {"t1", "t2", "t3"}, "st")
+ .delete_cols({"t1", "t2", "t3"})
+ .write_plot("plot_lnp.plot", "1/T", "ln(p)", "s_ln(p)");
+ auto [A, B] = t.least_squares_linear("1/T", "ln(p)", "s_ln(p)", std::nullopt);
+ std::cout << "Мнк ln(p) от (1/T): " << A << ' ' << B << std::endl;
+ f64 a_tbl = .5451, mu = .09209, v_w = .00100177, v_s = 57.8;
+ f64p Q = A * (-prak::R<f64>);
+ f64p q = Q/mu, p = 1333.2239023154 * (f64p){t["p", 4], t["sp", 4]};
+ f64p a = mu*mu*(q - p*v_s)*v_w;
+ std::cout << "\nmu = " << mu << ", v_воды = " << v_w << ", v_пар = " << v_s << ", p = " << p << " (темература 20 по методу наглых подгонов)"
+ << "\nQ = " << Q << ", q = " << q << ", a = " << a << ", a_теор = " << a_tbl << ", отклонение = " << a_tbl - a << std::endl;
+ return t;
+}
+
+void ex2(prak::table<f64> t) {
+ f64 beta = 6.1e-4, rho_0 = 1263.6, rho_1 = 8131, T_0 = 20 + conv::C_to_K<f64>, K = 114.4e-3, mu = .09209;
+ t .add_column("rho_2")
+ .apply([=](vecarg a){ return rho_0 / (1 + beta * (a[0] - T_0)); }, {"T"}, "rho_2")
+ .add_column("s_rho_2", 0.000001)
+ .apply_function_n( [=](vecarg a){ return K * (rho_1 - a[0]) * a[1]; },
+ {t.begin("rho_2"), t.begin("t")},
+ {t.begin("s_rho_2"), t.begin("st")},
+ t.rows, "nu", "snu")
+ .add_column("ln(nu)", NAN)
+ .add_column("s_ln(nu)", NAN)
+ .apply_function_n(prak::log<f64>, {t.begin("nu")}, {t.begin("snu")}, t.rows, "ln(nu)", "s_ln(nu)")
+ .add_column("1/nu", NAN)
+ .add_column("s_1/nu", NAN)
+ .add_column("1/rho_2", NAN)
+ .apply(prak::inv<f64>, {"nu"}, "1/nu")
+ .apply([](vecarg a){ return a[1] / a[0] / a[0]; }, {"nu", "snu"}, "s_1/nu")
+ .apply(prak::inv<f64>, {"rho_2"}, "1/rho_2")
+ .delete_cols({"h1", "h2", "p", "sp", "ln(p)", "t", "st"})
+ .write_plot("plot_lnn.plot", "1/T", "ln(nu)", "s_ln(nu)")
+ .write_plot("plot_nut.plot", "1/rho_2", "1/nu", "s_1/nu")
+ .print();
+ auto [A, B] = t.least_squares_linear("1/T", "ln(nu)", "s_ln(nu)", std::nullopt);
+ f64p eps = prak::k<f64> * A;
+ std::cout
+ << "Мнк ln(p) (1/T): (" << A << ")x + (" << B << ")\n"
+ << "энергия активации: " << eps * conv::J_to_eV<f64> << "эВ" << std::endl;
+ auto [A1, B1] = t.least_squares_linear("1/rho_2", "1/nu", "s_1/nu", std::nullopt);
+ f64p c = A / mu, b = -mu * B / A;
+ std::cout
+ << "Мнк 1/nu (1/rho_2): (" << A1 << ")x + (" << B1 << ")\n"
+ << "b = " << b << "; c = " << c << std::endl;
+}
+
+int main() {
+ ex2(ex1("data1"));
+ return 0;
+}
diff --git a/227/plots.gp b/227/plots.gp
new file mode 100644
index 0000000..8413681
--- /dev/null
+++ b/227/plots.gp
@@ -0,0 +1,31 @@
+set term pngcairo size 1000, 800
+set grid
+
+f1(x) = a1*x+b1
+fit f1(x) 'plot_lnp.plot' using 1:2:3 yerr via a1, b1
+
+set output 'plot_lnp.png'
+set title "Зависимость логарифма давления от обратной температуры"
+set xlabel "K^{-1}"
+set ylabel "ln(p), ln(см.рт.ст)"
+plot 'plot_lnp.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2, \
+ f1(x) title "" lc rgb "red"
+
+
+set output 'plot_lnn.png'
+set title "Зависимость логарифма динамической вязкости от обратной температы"
+set ylabel "ln(nu)"
+fit f1(x) 'plot_lnn.plot' using 1:2:3 yerr via a1, b1
+plot 'plot_lnn.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2,\
+ f1(x) title "" lc rgb "red"
+
+
+set output 'plot_nut.png'
+set title "Зависимость обратной динамической вязкости от обратной плотности"
+set xlabel "1/rho, м^3/кг"
+set ylabel "1/nu, Па^{-1}с^{-1}"
+fit f1(x) 'plot_nut.plot' using 1:2:3 yerr via a1, b1
+plot 'plot_nut.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2,\
+ 'plot_nut.plot' notitle with lines lc rgb "blue" lw 1,\
+ f1(x) title "Линейное приближение" lw 1 lc rgb "red"
+