aboutsummaryrefslogtreecommitdiffstats
path: root/226
diff options
context:
space:
mode:
Diffstat (limited to '226')
-rw-r--r--226/Makefile18
-rw-r--r--226/README.md5
-rw-r--r--226/compile_flags.txt4
-rw-r--r--226/data8
l---------226/include1
-rw-r--r--226/main.cpp32
-rw-r--r--226/plot.pdfbin0 -> 142006 bytes
-rw-r--r--226/plots.gp24
8 files changed, 92 insertions, 0 deletions
diff --git a/226/Makefile b/226/Makefile
new file mode 100644
index 0000000..224506f
--- /dev/null
+++ b/226/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/226/README.md b/226/README.md
new file mode 100644
index 0000000..96fd716
--- /dev/null
+++ b/226/README.md
@@ -0,0 +1,5 @@
+<!-- Шаблон для прака -->
+<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean -->
+# Обработка <> прака
+
+
diff --git a/226/compile_flags.txt b/226/compile_flags.txt
new file mode 100644
index 0000000..34ae930
--- /dev/null
+++ b/226/compile_flags.txt
@@ -0,0 +1,4 @@
+-Iinclude
+-std=c++2c
+-mavx2
+
diff --git a/226/data b/226/data
new file mode 100644
index 0000000..629cedb
--- /dev/null
+++ b/226/data
@@ -0,0 +1,8 @@
+U T1 T2 T3 sT1 sT2 sT3 T sT dU sdU vpr epr
+2.1 575 539 610 63 99 74 ? ? 1 0.01 139 0.02
+2.26 647 651 671 78 64 71 ? ? 1 0.01 143 0.04
+2.4 882 886 872 76 84 99 ? ? 1.02 0.01 171 ?
+2.54 1021 1079 1033 151 137 126 ? ? 1.03 0.02 193 ?
+2.68 1089 1143 1121 157 87 88 ? ? 1.026 0.01 196 ?
+2.82 1111 1160 1053 183 237 287 ? ? 0.997 0.03 206 ?
+3.0 1109 1063 1089 251 242 265 ? ? 0.957 0.03 206 ?
diff --git a/226/include b/226/include
new file mode 120000
index 0000000..2225752
--- /dev/null
+++ b/226/include
@@ -0,0 +1 @@
+../libprakpp/include/ \ No newline at end of file
diff --git a/226/main.cpp b/226/main.cpp
new file mode 100644
index 0000000..9584e60
--- /dev/null
+++ b/226/main.cpp
@@ -0,0 +1,32 @@
+#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);
+ t .apply(prak::avg<f64>, {"T1", "T2", "T3"}, "T")
+ .apply([](vecarg a){
+ return std::sqrt(std::pow(prak::stddev<f64>({a[0], a[1], a[2]}), 2)
+ + std::pow(prak::avg<f64>({a[3], a[4], a[5]}), 2)/3.0);
+ }, {"T1", "T2", "T3", "sT1", "sT2", "sT3"}, "sT")
+ .add_columns({"Tv", "sTv", "Te", "sTe"})
+ .add_columns({"svpr", "sepr"}, 6e3)
+ .multiply_column("vpr", 1e3)
+ .multiply_column("epr", conv::eV_to_J<f64>)
+ .apply_function([](vecarg a){return prak::m_e<f64> * a[0] * a[0] / (2 * prak::k<f64>);}, {"vpr"}, {"svpr"}, "Tv", "sTv")
+ .apply_function([](vecarg a){return 2 * a[0] / prak::k<f64>;}, {"epr"}, {"sepr"}, "Te", "sTe")
+ .delete_cols({"svpr", "sepr", "sTe"})
+ .write_plot("T(U).plot", "U", "T", "sT")
+ .write_plot("Tv(U).plot", "U", "Tv", "sTv")
+ .print();
+}
+
+int main() {
+ ex1("data");
+ return 0;
+}
diff --git a/226/plot.pdf b/226/plot.pdf
new file mode 100644
index 0000000..339cdf8
--- /dev/null
+++ b/226/plot.pdf
Binary files differ
diff --git a/226/plots.gp b/226/plots.gp
new file mode 100644
index 0000000..853d03d
--- /dev/null
+++ b/226/plots.gp
@@ -0,0 +1,24 @@
+set term pngcairo size 2400, 2000 font "Arial,30"
+set grid lw 4
+
+f1(x) = a1*x + b1
+f2(x) = a2*x + b2
+
+fit f1(x) 'T(U).plot' using 1:2:3 yerr via a1,b1
+a2=a1
+fit f2(x) 'Tv(U).plot' using 1:2:3 yerr via a2,b2
+
+set output 'plot.png'
+set title "Зависимость температур термоэлектронов от напряжения накала"
+set xlabel "U, В"
+set ylabel "T, К"
+set key top left
+
+set xrange[2.09:3.01]
+
+plot 'T(U).plot' using 1:2:3 with yerrorbars title "Расчёт по программе" lc rgb("blue") pt 2 lw 5, \
+ f1(x) lc rgb "red" lw 3 title "Расчёт по программе", \
+ 'Tv(U).plot' using 1:2:3 with yerrorbars title "расчёт по v_{нв}" lc rgb("orange") pt 3 lw 5, \
+ f2(x) lc rgb "green" lw 3 title "расчёт по v_{нв}"
+#'T(U).plot' with lines smooth csplines lc rgb "red" lw 3 title "Расчёт по ", \
+#'Tv(U).plot' with lines smooth csplines lc rgb "green" lw 3 title "Расчёт по v_{нв}"