aboutsummaryrefslogtreecommitdiffstats
path: root/206
diff options
context:
space:
mode:
Diffstat (limited to '206')
-rw-r--r--206/Makefile18
-rw-r--r--206/README.md5
-rw-r--r--206/compile_flags.txt4
-rw-r--r--206/data17
-rw-r--r--206/data227
-rw-r--r--206/final.pdfbin0 -> 96431 bytes
l---------206/include1
-rw-r--r--206/main.cpp51
-rw-r--r--206/plots.gp38
9 files changed, 151 insertions, 0 deletions
diff --git a/206/Makefile b/206/Makefile
new file mode 100644
index 0000000..224506f
--- /dev/null
+++ b/206/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/206/README.md b/206/README.md
new file mode 100644
index 0000000..96fd716
--- /dev/null
+++ b/206/README.md
@@ -0,0 +1,5 @@
+<!-- Шаблон для прака -->
+<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean -->
+# Обработка <> прака
+
+
diff --git a/206/compile_flags.txt b/206/compile_flags.txt
new file mode 100644
index 0000000..34ae930
--- /dev/null
+++ b/206/compile_flags.txt
@@ -0,0 +1,4 @@
+-Iinclude
+-std=c++2c
+-mavx2
+
diff --git a/206/data1 b/206/data1
new file mode 100644
index 0000000..c4b5435
--- /dev/null
+++ b/206/data1
@@ -0,0 +1,7 @@
+L t1 t2 t3 t St st
+0.1 280 279 280 ? ? ?
+0.2 568 569 567 ? ? ?
+0.3 857 858 857 ? ? ?
+0.4 1150 1150 1149 ? ? ?
+0.5 1432 1431 1430 ? ? ?
+0.6 1731 1730 1729 ? ? ?
diff --git a/206/data2 b/206/data2
new file mode 100644
index 0000000..24cafe0
--- /dev/null
+++ b/206/data2
@@ -0,0 +1,27 @@
+t T sqrt(T) tau v
+51.0 ? ? 1660 ?
+50.0 ? ? 1664 ?
+48.8 ? ? 1666 ?
+47.9 ? ? 1668 ?
+47.0 ? ? 1671 ?
+46.0 ? ? 1673 ?
+45.0 ? ? 1675 ?
+44.0 ? ? 1678 ?
+43.0 ? ? 1680 ?
+42.0 ? ? 1683 ?
+41.0 ? ? 1686 ?
+40.0 ? ? 1688 ?
+39.0 ? ? 1690 ?
+38.0 ? ? 1692 ?
+37.0 ? ? 1695 ?
+36.0 ? ? 1698 ?
+35.0 ? ? 1700 ?
+34.0 ? ? 1702 ?
+33.0 ? ? 1705 ?
+32.0 ? ? 1708 ?
+31.0 ? ? 1711 ?
+30.0 ? ? 1713 ?
+28.8 ? ? 1717 ?
+28.0 ? ? 1719 ?
+27.2 ? ? 1722 ?
+26.0 ? ? 1725 ?
diff --git a/206/final.pdf b/206/final.pdf
new file mode 100644
index 0000000..f15f111
--- /dev/null
+++ b/206/final.pdf
Binary files differ
diff --git a/206/include b/206/include
new file mode 120000
index 0000000..2225752
--- /dev/null
+++ b/206/include
@@ -0,0 +1 @@
+../libprakpp/include/ \ No newline at end of file
diff --git a/206/main.cpp b/206/main.cpp
new file mode 100644
index 0000000..8c94af3
--- /dev/null
+++ b/206/main.cpp
@@ -0,0 +1,51 @@
+#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> &;
+
+void ex1(std::string file) {
+ table t(file);
+ f64 tmsgm = 1;
+ t /*.multiply_column("t1", 1e-6)
+ .multiply_column("t2", 1e-6)
+ .multiply_column("t3", 1e-6)*/
+ .apply(prak::avg<f64>, {"t1", "t2", "t3"}, "t")
+ .apply(prak::stddev<f64>, {"t1", "t2", "t3"}, "St")
+ .apply([&](vecarg a) {return std::sqrt(a[0]*a[0] + tmsgm * tmsgm); }, "St", "st")
+ .write_plot("ex1.plot", "L", "t", "st")
+ .print();
+ auto [A, B] = t.least_squares_linear("L", "t", "st", std::nullopt);
+ A = A * 1e-6;
+ B = B * 1e-6;
+ f64p v = 1.0 / A;
+ std::cout var(A) var(B) var(v);
+}
+
+void ex2(std::string file) {
+ table t(file);
+ f64 L0 = 0.6, mu = 29e-3;
+ t .apply(prak::add<f64, conv::C_to_K<f64>>, "t", "T")
+ .apply([](vecarg a){ return std::sqrt(a[0]); }, "T", "sqrt(T)")
+ .multiply_column("tau", 1e-6)
+ .apply([&](vecarg a) { return L0 / a[0]; }, "tau", "v")
+ .write_plot("ex2.plot", "sqrt(T)", "v", std::nullopt)
+ .add_row({-273.15, 0, 0, 0, 0})
+ .print();
+ auto A = t.least_squares_prop("sqrt(T)", "v", std::nullopt, 0.01);
+ f64p gamma = A * A * mu / prak::R<f64>;
+ f64p Cv = prak::R<f64> / (gamma - 1.0), i = 2.0 / (gamma - 1.0);
+ f64p tau = 1.2041 * Cv * t.col_avg("v") * t.col_avg("v") / 4.0 / 1e6 / 0.0259;
+ std::cout var(L0) var(A) var(mu) var(gamma) var(Cv) var(i) var(tau);
+}
+
+int main() {
+ ex1("data1");
+ ex2("data2");
+ return 0;
+}
diff --git a/206/plots.gp b/206/plots.gp
new file mode 100644
index 0000000..5460021
--- /dev/null
+++ b/206/plots.gp
@@ -0,0 +1,38 @@
+set term pngcairo size 1000, 800
+set grid
+
+f1(x) = a1*x+b1
+fit f1(x) 'ex1.plot' using 1:2:3 yerr via a1, b1
+f2(x) = a2 * x
+fit f2(x) 'ex2.plot' using 1:2 via a2
+
+set output 'ex1.png'
+set title "Зависимость времени прохода волны от расстояния"
+set xlabel "L, м"
+set ylabel "t, мкc"
+set key top left
+
+set xrange[0:0.7]
+
+set label sprintf("A = %.4g\n B =%.4g", a1 / 10e6, b1 / 10e6) at graph 0.2, 0.9 front boxed
+plot 'ex1.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2, \
+ f1(x) title "t(L)" lc rgb "red"
+
+
+set output 'ex2.png'
+set title "Зависимость скорости от корня из температуры"
+set xlabel "T^{1/2}, K^{1/2}"
+set ylabel "v, м/c"
+set key top left
+
+unset xrange
+unset label
+set label sprintf("A = %.4g", a2) at graph 0.2, 0.9 front boxed
+plot 'ex2.plot' using 1:2 notitle lc 0 pt 1 lw 2, \
+ f2(x) title "v(T^{1/2})" lc rgb "red"
+
+
+set output 'ex2_0.png'
+set title "Зависимость скорости от корня из температуры (проход через 0)"
+set xrange[0:19]
+replot