diff options
Diffstat (limited to '240')
-rw-r--r-- | 240/Makefile | 18 | ||||
-rw-r--r-- | 240/README.md | 5 | ||||
-rw-r--r-- | 240/compile_flags.txt | 4 | ||||
-rw-r--r-- | 240/data | 11 | ||||
l--------- | 240/include | 1 | ||||
-rw-r--r-- | 240/main.cpp | 28 | ||||
-rw-r--r-- | 240/plots.gp | 16 |
7 files changed, 83 insertions, 0 deletions
diff --git a/240/Makefile b/240/Makefile new file mode 100644 index 0000000..224506f --- /dev/null +++ b/240/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/240/README.md b/240/README.md new file mode 100644 index 0000000..96fd716 --- /dev/null +++ b/240/README.md @@ -0,0 +1,5 @@ +<!-- Шаблон для прака --> +<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean --> +# Обработка <> прака + + diff --git a/240/compile_flags.txt b/240/compile_flags.txt new file mode 100644 index 0000000..34ae930 --- /dev/null +++ b/240/compile_flags.txt @@ -0,0 +1,4 @@ +-Iinclude +-std=c++2c +-mavx2 + diff --git a/240/data b/240/data new file mode 100644 index 0000000..3e38f45 --- /dev/null +++ b/240/data @@ -0,0 +1,11 @@ +t dp1 dp ln +4.14 9.31 1.88 ? +5 5.88 1.04 ? +6 6.66 1.19 ? +7.27 1.88 0.25 ? +8.07 6.07 0.88 ? +10 6.61 0.82 ? +15 7.10 0.56 ? +20 6.42 0.32 ? +31 7.59 0.13 ? + diff --git a/240/include b/240/include new file mode 120000 index 0000000..2225752 --- /dev/null +++ b/240/include @@ -0,0 +1 @@ +../libprakpp/include/
\ No newline at end of file diff --git a/240/main.cpp b/240/main.cpp new file mode 100644 index 0000000..52af396 --- /dev/null +++ b/240/main.cpp @@ -0,0 +1,28 @@ +#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); + t.apply([](argvec a){ return std::log(a[0]/a[1]); }, std::vector<std::string>{"dp1", "dp"}, "ln"); + t.write_plot("mnk.plot", "t", "ln", std::nullopt); + auto [A, B] = t.least_squares_linear("t", "ln", std::nullopt, std::make_optional(0.1)); + f64p gamma = prak::function<f64>([](vecarg a) { return std::exp(a[0]) / (std::exp(a[0]) - 1); }, {B}); + f64p Cv = prak::R<f64> / (gamma - 1.0); + f64p i = 2.0 * Cv / prak::R<f64>, Cp = Cv + prak::R<f64>; + f64 m0 = 1.29 * 0.0127; + f64p alpha = m0 * Cp * A, tau = 1.0 / A; + std::cout << t var(A) var(B) var(gamma) var(Cv) var(i) var(m0) var(Cp) var(alpha) var(tau); +} + +int main() { + ex1("data"); + return 0; +} diff --git a/240/plots.gp b/240/plots.gp new file mode 100644 index 0000000..8c71dc0 --- /dev/null +++ b/240/plots.gp @@ -0,0 +1,16 @@ +set term pngcairo size 1000, 800 +set grid + +f1(x) = a1*x+b1 +fit f1(x) 'mnk.plot' using 1:2 via a1, b1 + +set output 'mnk.png' +set title "зависимтость от t" +set xlabel "t, c" +set ylabel "ln dp1/dp(t), ед." +set key top left + +set label sprintf("A = %.4g\n B = %.4g", a1, b1) at graph 0.2, 0.9 front boxed +plot 'mnk.plot' using 1:2 notitle lc 0 pt 1 lw 2, \ + f1(x) title "y(x)" lc rgb "red" + |