diff options
Diffstat (limited to '207')
-rw-r--r-- | 207/Makefile | 18 | ||||
-rw-r--r-- | 207/README.md | 5 | ||||
-rw-r--r-- | 207/compile_flags.txt | 4 | ||||
-rw-r--r-- | 207/data1 | 11 | ||||
-rw-r--r-- | 207/data2 | 7 | ||||
-rw-r--r-- | 207/data3 | 12 | ||||
-rw-r--r-- | 207/data4 | 16 | ||||
-rw-r--r-- | 207/ex1_1.print | 24 | ||||
-rw-r--r-- | 207/ex1_4.print | 34 | ||||
l--------- | 207/include | 1 | ||||
-rw-r--r-- | 207/main.cpp | 86 | ||||
-rw-r--r-- | 207/plots.gp | 16 | ||||
-rw-r--r-- | 207/print.txt | 25 |
13 files changed, 259 insertions, 0 deletions
diff --git a/207/Makefile b/207/Makefile new file mode 100644 index 0000000..17aed33 --- /dev/null +++ b/207/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 *.print diff --git a/207/README.md b/207/README.md new file mode 100644 index 0000000..96fd716 --- /dev/null +++ b/207/README.md @@ -0,0 +1,5 @@ +<!-- Шаблон для прака --> +<!-- файлы, заканчивающиеся на .plot считаются генерируемыми и удаляются через make clean --> +# Обработка <> прака + + diff --git a/207/compile_flags.txt b/207/compile_flags.txt new file mode 100644 index 0000000..34ae930 --- /dev/null +++ b/207/compile_flags.txt @@ -0,0 +1,4 @@ +-Iinclude +-std=c++2c +-mavx2 + diff --git a/207/data1 b/207/data1 new file mode 100644 index 0000000..0675a6e --- /dev/null +++ b/207/data1 @@ -0,0 +1,11 @@ +n P T V x +1 1110.3 289.9 35.5 ? +2 1091.8 289.9 36.0 ? +3 1089.9 289.9 36.5 ? +4 1074.4 289.9 37.0 ? +5 1062.4 289.9 37.5 ? +6 1050.0 289.9 38.0 ? +7 1038.8 289.9 38.5 ? +8 1024.0 289.9 39.0 ? +9 1012.2 289.9 39.5 ? +10 996.5 289.9 40.0 ? diff --git a/207/data2 b/207/data2 new file mode 100644 index 0000000..c5cabbf --- /dev/null +++ b/207/data2 @@ -0,0 +1,7 @@ +n P T V x +1 991.0 298.33 40.0 ? +2 991.0 302.84 40.5 ? +3 991.7 305.34 41.0 ? +4 991.2 307.78 41.5 ? +5 991.0 310.46 42.0 ? +6 990.8 313.57 42.5 ? diff --git a/207/data3 b/207/data3 new file mode 100644 index 0000000..ca2ca40 --- /dev/null +++ b/207/data3 @@ -0,0 +1,12 @@ +n P T V x +1 990.8 315.40 43.5 ? +2 984.6 316.42 ? ? +3 986.8 317.22 ? ? +4 989.2 317.98 ? ? +5 993.0 319.17 ? ? +6 995.3 320.04 ? ? +7 997.1 321.03 44.0 ? +8 998.5 322.02 ? ? +9 1000.0 323.02 ? ? +10 1000.0 323.85 ? ? +11 998.0 323.91 44.5 ? diff --git a/207/data4 b/207/data4 new file mode 100644 index 0000000..4941d5c --- /dev/null +++ b/207/data4 @@ -0,0 +1,16 @@ +n P T V x +1 997.1 323.61 44.5 ? +2 997.4 323.51 44.0 ? +3 999.0 323.51 43.5 ? +4 1014.2 323.48 43.0 ? +5 1023.3 323.48 42.5 ? +6 1037.3 323.38 42.0 ? +7 1048.0 323.38 41.5 ? +8 1060.0 323.35 41.0 ? +9 1070.7 323.35 40.5 ? +10 1083.8 323.35 40.0 ? +11 1098.5 323.35 39.5 ? +12 1108.8 323.35 39.0 ? +13 1122.9 323.35 38.5 ? +14 1139.0 323.35 38.0 ? +15 1148.1 323.28 37.5 ? diff --git a/207/ex1_1.print b/207/ex1_1.print new file mode 100644 index 0000000..ec5efe0 --- /dev/null +++ b/207/ex1_1.print @@ -0,0 +1,24 @@ +Данные упражнения 1columns: 6, rows: 10 +_______________________________________________________________________________ +|n |P |T |V |x |nu | +|____________|____________|____________|____________|____________|____________| +|1 |1110.3 |289.9 |35.5 |39415.7 |16.3526 | +|____________|____________|____________|____________|____________|____________| +|2 |1091.8 |289.9 |36 |39304.8 |16.3066 | +|____________|____________|____________|____________|____________|____________| +|3 |1089.9 |289.9 |36.5 |39781.4 |16.5043 | +|____________|____________|____________|____________|____________|____________| +|4 |1074.4 |289.9 |37 |39752.8 |16.4925 | +|____________|____________|____________|____________|____________|____________| +|5 |1062.4 |289.9 |37.5 |39840 |16.5286 | +|____________|____________|____________|____________|____________|____________| +|6 |1050 |289.9 |38 |39900 |16.5535 | +|____________|____________|____________|____________|____________|____________| +|7 |1038.8 |289.9 |38.5 |39993.8 |16.5924 | +|____________|____________|____________|____________|____________|____________| +|8 |1024 |289.9 |39 |39936 |16.5685 | +|____________|____________|____________|____________|____________|____________| +|9 |1012.2 |289.9 |39.5 |39981.9 |16.5875 | +|____________|____________|____________|____________|____________|____________| +|10 |996.5 |289.9 |40 |39860 |16.5369 | +|____________|____________|____________|____________|____________|____________| diff --git a/207/ex1_4.print b/207/ex1_4.print new file mode 100644 index 0000000..9863903 --- /dev/null +++ b/207/ex1_4.print @@ -0,0 +1,34 @@ +Данные упражнения 1columns: 6, rows: 15 +_______________________________________________________________________________ +|n |P |T |V |x |nu | +|____________|____________|____________|____________|____________|____________| +|1 |997.1 |323.61 |44.5 |44371 |16.4908 | +|____________|____________|____________|____________|____________|____________| +|2 |997.4 |323.51 |44 |43885.6 |16.3155 | +|____________|____________|____________|____________|____________|____________| +|3 |999 |323.51 |43.5 |43456.5 |16.156 | +|____________|____________|____________|____________|____________|____________| +|4 |1014.2 |323.48 |43 |43610.6 |16.2148 | +|____________|____________|____________|____________|____________|____________| +|5 |1023.3 |323.48 |42.5 |43490.2 |16.17 | +|____________|____________|____________|____________|____________|____________| +|6 |1037.3 |323.38 |42 |43566.6 |16.2034 | +|____________|____________|____________|____________|____________|____________| +|7 |1048 |323.38 |41.5 |43492 |16.1757 | +|____________|____________|____________|____________|____________|____________| +|8 |1060 |323.35 |41 |43460 |16.1653 | +|____________|____________|____________|____________|____________|____________| +|9 |1070.7 |323.35 |40.5 |43363.3 |16.1293 | +|____________|____________|____________|____________|____________|____________| +|10 |1083.8 |323.35 |40 |43352 |16.1251 | +|____________|____________|____________|____________|____________|____________| +|11 |1098.5 |323.35 |39.5 |43390.8 |16.1395 | +|____________|____________|____________|____________|____________|____________| +|12 |1108.8 |323.35 |39 |43243.2 |16.0846 | +|____________|____________|____________|____________|____________|____________| +|13 |1122.9 |323.35 |38.5 |43231.7 |16.0803 | +|____________|____________|____________|____________|____________|____________| +|14 |1139 |323.35 |38 |43282 |16.0991 | +|____________|____________|____________|____________|____________|____________| +|15 |1148.1 |323.28 |37.5 |43053.8 |16.0176 | +|____________|____________|____________|____________|____________|____________| diff --git a/207/include b/207/include new file mode 120000 index 0000000..2225752 --- /dev/null +++ b/207/include @@ -0,0 +1 @@ +../libprakpp/include/
\ No newline at end of file diff --git a/207/main.cpp b/207/main.cpp new file mode 100644 index 0000000..6f606bd --- /dev/null +++ b/207/main.cpp @@ -0,0 +1,86 @@ +#include <cmath> +#include <iostream> +#include <ranges> + +#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> &; + +f64p add_nu(table& t) { + t.add_column("nu").apply([](vecarg a) { return a[0] * a[1] / (prak::R<f64> * a[2]); }, {"P", "V", "T"}, "nu"); + return {t.col_avg("nu"), t.col_stddev("nu")}; +} + +void ex1(table &t1, const char *name) { + f64 DA = prak::discrete_integral_trapezoid(t1.cbegin("V"), t1.cend("V"), t1.cbegin("P"), t1.cend("P")); + f64 DS = DA / t1.col_avg("T"); + f64p nu = add_nu(t1); + f64p DS_teor = nu * prak::R<f64> * std::abs(std::log(*(t1.end("V")-1) / *t1.begin("V"))); + std::cout << "Упражнение 1\n" var(DA) var(DS) var(nu) var(DS_teor) << std::endl; + t1.write_plot(std::string("P(V)") + name + ".plot", "V", "P", std::nullopt); + t1.write_plot(std::string("PV(V)") + name + ".plot", "V", "x", std::nullopt); + std::ofstream f(std::string("ex1_") + name + ".print"); + f << "Данные упражнения 1"; + t1.print(f); + f.close(); +} + +void ex2(const table &t) { + +} + +void ex3(const table &t) { + +} + +void ex4(void) { + +} + +void ex(void) { + table tables[] = {table("data1"), table("data2"), table("data3"), table("data4")}; + + // approximate how the volume should have changed in ex3 using parabola + std::vector<f64> mrxdata; mrxdata.reserve(9); + std::vector<f64> mrydata; mrydata.reserve(3); + for (size_t i = 0; i < tables[2].rows; ++i) { + if (f64 v; !std::isnan(v = tables[2]["V", i])) { + f64 n = tables[2]["n", i]; + mrxdata.push_back(n*n); + mrxdata.push_back(n); + mrxdata.push_back(1); + mrydata.push_back(v); + } + } + prak::matrix<f64> xs(3, 3, std::move(mrxdata)), ys(3, 1, std::move(mrydata)); + prak::matrix<f64> poly = xs.inv().value() * ys; + for (size_t i = 0; i < tables[2].rows; ++i) + tables[2]["V", i] = (poly.tr() * prak::matrix<f64>(3, 1, {(double)(i+1)*(i+1), (double)(i+1), 1}))[0, 0]; + + std::function<f64(vecarg)> fs[] = { + [](vecarg a) { return a[0] * a[1]; }, + [](vecarg a) { return a[0] / a[1]; }, + [](vecarg a) { return a[0] / a[1]; }, + [](vecarg a) { return a[0] * a[1]; }, + }; + std::vector<std::string> vs[] = { + {"P", "V"}, {"V", "T"}, {"P", "T"}, {"P", "V"}, + }; + for (auto elem : std::views::zip(tables, fs, vs)) + std::get<0>(elem).apply(std::get<1>(elem), std::get<2>(elem), "x"); + ex1(tables[0], "1"); + ex1(tables[3], "4"); + ex2(tables[1]); + ex3(tables[2]); + ex4(); +} + +int main() { + ex(); + return 0; +} diff --git a/207/plots.gp b/207/plots.gp new file mode 100644 index 0000000..f197258 --- /dev/null +++ b/207/plots.gp @@ -0,0 +1,16 @@ +set term pngcairo size 1000, 800 +set grid + +#f1(x) = a1*x+b1 +#fit f1(x) '.plot' using 1:2:3 yerr via a1, b1 + +set output '' +set title "" +set xlabel "" +set ylabel "" +set key top left + +#set label sprintf("A = %.4g\n B = %.4g", a1, b1) at graph 0.2, 0.9 front boxed +#plot '.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2, \ +# f1(x) title "" lc rgb "red" + diff --git a/207/print.txt b/207/print.txt new file mode 100644 index 0000000..85be337 --- /dev/null +++ b/207/print.txt @@ -0,0 +1,25 @@ +columns: 5, rows: 10 +__________________________________________________________________ +|n |P |T |V |x | +|____________|____________|____________|____________|____________| +|1 |1110.3 |289.9 |35.5 |39415.7 | +|____________|____________|____________|____________|____________| +|2 |1091.8 |289.9 |36 |39304.8 | +|____________|____________|____________|____________|____________| +|3 |1089.9 |289.9 |36.5 |39781.4 | +|____________|____________|____________|____________|____________| +|4 |1074.4 |289.9 |37 |39752.8 | +|____________|____________|____________|____________|____________| +|5 |1062.4 |289.9 |37.5 |39840 | +|____________|____________|____________|____________|____________| +|6 |1050 |289.9 |38 |39900 | +|____________|____________|____________|____________|____________| +|7 |1038.8 |289.9 |38.5 |39993.8 | +|____________|____________|____________|____________|____________| +|8 |1024 |289.9 |39 |39936 | +|____________|____________|____________|____________|____________| +|9 |1012.2 |289.9 |39.5 |39981.9 | +|____________|____________|____________|____________|____________| +|10 |996.5 |289.9 |40 |39860 | +|____________|____________|____________|____________|____________| + |