aboutsummaryrefslogtreecommitdiffstats
path: root/204
diff options
context:
space:
mode:
Diffstat (limited to '204')
-rw-r--r--204/Makefile18
-rw-r--r--204/README.md5
-rw-r--r--204/compile_flags.txt4
-rw-r--r--204/data10
-rw-r--r--204/data215
-rw-r--r--204/data2__2
l---------204/include1
-rw-r--r--204/main.cpp52
-rw-r--r--204/plots.gp62
9 files changed, 169 insertions, 0 deletions
diff --git a/204/Makefile b/204/Makefile
new file mode 100644
index 0000000..224506f
--- /dev/null
+++ b/204/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/204/README.md b/204/README.md
new file mode 100644
index 0000000..96fd716
--- /dev/null
+++ b/204/README.md
@@ -0,0 +1,5 @@
+<!-- Шаблон для прака -->
+<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean -->
+# Обработка <> прака
+
+
diff --git a/204/compile_flags.txt b/204/compile_flags.txt
new file mode 100644
index 0000000..34ae930
--- /dev/null
+++ b/204/compile_flags.txt
@@ -0,0 +1,4 @@
+-Iinclude
+-std=c++2c
+-mavx2
+
diff --git a/204/data b/204/data
new file mode 100644
index 0000000..94abed5
--- /dev/null
+++ b/204/data
@@ -0,0 +1,10 @@
+T F2 F s ss
+290.65 0.050 ? ? ?
+291.15 0.050 ? ? ?
+291.65 0.050 ? ? ?
+333 0.042 ? ? ?
+332 0.0425 ? ? ?
+352 0.041 ? ? ?
+349 0.041 ? ? ?
+322 0.043 ? ? ?
+315 0.045 ? ? ?
diff --git a/204/data2 b/204/data2
new file mode 100644
index 0000000..696eb10
--- /dev/null
+++ b/204/data2
@@ -0,0 +1,15 @@
+x1 f1 x2 f2 x3 f3 x4 f4
+111.5 0.021 114 0.029 108 0.026 110 0.027
+118 0.025 120 0.024 120 0.019 120 0.019
+120 0.024 130 0.015 125 0.0145 130 0.010
+123 0.020 135 0.010 130 0.010 120 0.019
+130 0.015 125 0.019 130 0.010 110 0.028
+135 0.010 115 0.028 122 0.017 100 0.036
+120 0.024 105 0.037 110 0.028 93 0.040
+115 0.0285 95 0.041 85 0.042 84 0.042
+110 0.033 85 0.049 0 0 0 0
+105 0.037 83 0.05 0 0 0 0
+100 0.041 0 0 0 0 0 0
+90 0.045 0 0 0 0 0 0
+82 0.05 0 0 0 0 0 0
+0 0 0 0 0 0 0 0
diff --git a/204/data2__ b/204/data2__
new file mode 100644
index 0000000..6b6c8ee
--- /dev/null
+++ b/204/data2__
@@ -0,0 +1,2 @@
+T1 T2 T3 T4
+293.15 293.15 348 343
diff --git a/204/include b/204/include
new file mode 120000
index 0000000..2225752
--- /dev/null
+++ b/204/include
@@ -0,0 +1 @@
+../libprakpp/include/ \ No newline at end of file
diff --git a/204/main.cpp b/204/main.cpp
new file mode 100644
index 0000000..64a11e2
--- /dev/null
+++ b/204/main.cpp
@@ -0,0 +1,52 @@
+#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> &;
+
+void ex1(std::string file) {
+ table t(file);
+ f64p F1 = {0.0215, 0.0005}, D = {0.0061, 0.0001}, k = {0.91, 0.01};
+ f64 sgm = (D.err / D.val) * (D.err / D.val) + (k.err / k.val) * (k.err / k.val);
+ f64 F_err = std::sqrt(2.0) * F1.err;
+ t .apply([&F1](vecarg a){ return a[0] - F1.val;}, {"F2"}, "F")
+ .apply([&](vecarg a){ return a[0] / (2 * k.val * prak::PI * D.val);}, {"F"}, "s")
+ .apply([&](vecarg a){ return a[0] * std::sqrt(F_err * F_err / (a[1] * a[1]) + sgm);}, {"s", "F"}, "ss")
+ .write_plot("s(T).plot", "T", "s", "ss")
+ .add_columns({"q", "sq", "U", "sU"});
+ auto [A, B] = t.least_squares_linear("T", "s", std::make_optional("ss"), std::nullopt);
+ t .apply([&A](vecarg a){ return -a[0] * A.val;}, {"T"}, "q")
+ .apply([&A](vecarg a){ return a[0] * A.err;}, {"T"}, "sq")
+ .apply_function(prak::sum<f64>, {"s", "q"}, {"ss", "sq"}, "U", "sU")
+ .write_plot("q(T).plot", "T", "q", "sq")
+ .write_plot("U(T).plot", "T", "U", "sU")
+ .print();
+ auto [qA, qB] = t.least_squares_linear("T", "q", "sq", std::nullopt);
+ auto [UA, UB] = t.least_squares_linear("T", "U", "sU", std::nullopt);
+ std::cout
+ << "s(T)" << A << "x+" << B << std::endl
+ << "q(T)" << qA << "x+" << qB << std::endl
+ << "U(T)" << UA << "x+" << UB << std::endl;
+}
+
+void ex2(std::string file) {
+ table t(file);
+ const char* strs = "1234";
+ std::string x = "x";
+ std::string f = "f";
+ std::string l = "f(x)";
+ for (int i = 0; i < 4; ++i) {
+ table _t({x, f}, {t.begin(x + strs[i]), t.begin(f + strs[i])}, t.find_index(x + strs[i], 0));
+ _t.write_plot(l + strs[i] + ".plot", "x", "f", std::nullopt).print();
+ }
+}
+
+int main() {
+ ex1("data");
+ ex2("data2");
+ return 0;
+}
diff --git a/204/plots.gp b/204/plots.gp
new file mode 100644
index 0000000..cbf7a1c
--- /dev/null
+++ b/204/plots.gp
@@ -0,0 +1,62 @@
+set term pngcairo size 1000, 800
+set grid
+
+f1(x) = a1*x+b1
+fit f1(x) 's(T).plot' using 1:2:3 yerr via a1, b1
+f2(x) = a2*x+b2
+fit f2(x) 'q(T).plot' using 1:2:3 yerr via a2, b2
+f3(x) = a3*x+b3
+fit f3(x) 'U(T).plot' using 1:2:3 yerr via a3, b3
+
+
+set output 's(T).png'
+set title "Зависимость коэффицента поверхностного натяжения от температуры"
+set xlabel "T, К"
+set ylabel "sigma, Н/м"
+
+plot 's(T).plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2, \
+ f1(x) title "" lc rgb "red"
+
+
+set output 'q(T),U(T).png'
+set title "Зависимости теплоты изотермического образования и поверхностной плотности внутренней энергии от температуры"
+set ytics nomirror
+set y2tics
+set xlabel "Т, К"
+set ylabel "q, дж/м^2"
+set y2label "U, дж/м^2"
+set yrange[1.1:1.8]
+set y2range[1:10]
+plot 'q(T).plot' using 1:2:3 with yerrorbars axes x1y1 notitle lc 0 pt 1 lw 2, \
+ 'U(T).plot' using 1:2:3 with yerrorbars axes x1y2 notitle lc 0 pt 1 lw 2, \
+ f2(x) lc rgb "red" axes x1y1 notitle, \
+ f3(x) lc rgb "red" axes x1y2 notitle, \
+ 'q(T).plot' with lines lc rgb "green" axes x1y1 title "q(T)", \
+ 'U(T).plot' with lines lc rgb "blue" axes x1y2 title "U(T)"
+unset y2tics
+unset y2label
+unset xrange
+unset yrange
+
+set xlabel "x, мм"
+set ylabel "f, мН"
+
+set output 'f1(x).png'
+set title "Зависимость силы натяжения от координаты (T = 293К)"
+plot 'f(x)1.plot' notitle lc 0 pt 1 lw 2 ,\
+ 'f(x)1.plot' notitle with lines lc rgb "blue"
+
+set output 'f2(x).png'
+set title "Зависимость силы натяжения от координаты (T = 293К)"
+plot 'f(x)2.plot' notitle lc 0 pt 1 lw 2 ,\
+ 'f(x)2.plot' notitle with lines lc rgb "blue"
+
+set output 'f3(x).png'
+set title "Зависимость силы натяжения от координаты (T = 343-333К)"
+plot 'f(x)3.plot' notitle lc 0 pt 1 lw 2 ,\
+ 'f(x)3.plot' notitle with lines lc rgb "red"
+
+set output 'f4(x).png'
+set title "Зависимость силы натяжения от координаты (T = 336-330К)"
+plot 'f(x)4.plot' notitle lc 0 pt 1 lw 2 ,\
+ 'f(x)4.plot' notitle with lines lc rgb "green"