diff options
Diffstat (limited to '207')
-rw-r--r-- | 207/data3 | 2 | ||||
-rw-r--r-- | 207/ex1_1.print | 24 | ||||
-rw-r--r-- | 207/ex1_4.print | 34 | ||||
-rw-r--r-- | 207/main.cpp | 65 | ||||
-rw-r--r-- | 207/plots.gp | 86 | ||||
-rw-r--r-- | 207/print.txt | 25 |
6 files changed, 131 insertions, 105 deletions
@@ -1,5 +1,5 @@ n P T V x -1 990.8 315.40 43.5 ? +1 980.8 315.40 43.5 ? 2 984.6 316.42 ? ? 3 986.8 317.22 ? ? 4 989.2 317.98 ? ? diff --git a/207/ex1_1.print b/207/ex1_1.print deleted file mode 100644 index ec5efe0..0000000 --- a/207/ex1_1.print +++ /dev/null @@ -1,24 +0,0 @@ -Данные упражнения 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 deleted file mode 100644 index 9863903..0000000 --- a/207/ex1_4.print +++ /dev/null @@ -1,34 +0,0 @@ -Данные упражнения 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/main.cpp b/207/main.cpp index 6f606bd..5424940 100644 --- a/207/main.cpp +++ b/207/main.cpp @@ -17,28 +17,70 @@ f64p add_nu(table& t) { } void ex1(table &t1, const char *name) { + // t = const 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); + t1 .add_columns({"DAi", "DSi", "lnViV0"}) + .apply([&t1](vecarg a) -> f64 { + return prak::discrete_integral_trapezoid( + t1.begin("V"), std::find(t1.begin("V"), t1.end("V"), a[1])+1, + t1.begin("P"), std::find(t1.begin("P"), t1.end("P"), a[0])+1 + ); + }, {"P", "V"}, "DAi") + .apply([&t1](vecarg a){return a[0] / a[1];}, {"DAi", "T"}, "DSi") + .apply([&t1](vecarg a){ return std::log(a[0] / t1["V", 0]); }, "V", "lnViV0") + .apply([](vecarg a) {return std::abs(a[0]); }, "lnViV0", "lnViV0"); 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); + f64p A = std::abs(t1.least_squares_prop("lnViV0", "DSi", std::nullopt, 0.1)); + f64p R = A / nu; + std::cout << "Упражнение 1\n" var(DA) var(DS) var(nu) var(DS_teor) << "доп данные (упражнение 4):\n" + var(A) var(R) << std::endl; + t1 .write_plot(std::string("PV") + name + ".plot", "V", "P", std::nullopt) + .write_plot(std::string("PVV") + name + ".plot", "V", "x", std::nullopt) + .write_plot(std::string("DSilnViV0_Tconst") + name + ".plot", "lnViV0", "DSi", std::nullopt); std::ofstream f(std::string("ex1_") + name + ".print"); - f << "Данные упражнения 1"; + f << "Данные упражнения 1 (T = const)\n"; t1.print(f); f.close(); } -void ex2(const table &t) { - +void ex2(table &t) { + // p = const + std::cout << "Упражнение 2\n"; + std::ofstream f("ex2.print"); + f << "Данные упражнения 2 (P = const)\n"; + f64p nu = add_nu(t); + t .add_columns({"lnTiT0", "DSi"}) + .apply([&t](vecarg a) -> f64 {return std::log(a[0] / t["T", 0]); }, "T", "lnTiT0") + .apply([&t, &nu](vecarg a) -> f64 { + return nu.val * (prak::R<f64> * std::log(a[1] / t["V", 0]) + 5.0/2 * prak::R<f64> * a[2]); + }, {"T", "V", "lnTiT0"}, "DSi") + .write_plot("DSilnTiT0_Pconst.plot", "lnTiT0", "DSi", std::nullopt) + .write_plot("VTV.plot", "V", "x", std::nullopt) + .print(f); + f64p A = t.least_squares_prop("lnTiT0", "DSi", std::nullopt, 0.1); + f64p Cp = A / nu; + std::cout var(nu) var(A) var(Cp); } -void ex3(const table &t) { - -} - -void ex4(void) { +void ex3(table &t) { + // v = const + std::cout << "Упражнение 3\n"; + std::ofstream f("ex3.print"); + f << "Данные упражнения 3 (V = const)\n"; + f64p nu = add_nu(t); + t .add_columns({"lnTiT0", "DSi"}) + .apply([&t](vecarg a) -> f64 {return std::log(a[0] / t["T", 0]); }, "T", "lnTiT0") + .apply([&t, &nu](vecarg a) -> f64 { + return nu.val * (-prak::R<f64> * std::log(a[0] / t["P", 0]) + 7.0/2 * prak::R<f64> * a[1]); + }, {"P", "lnTiT0"}, "DSi") + .write_plot("DSilnTiT0_Vconst.plot", "lnTiT0", "DSi", std::nullopt) + .write_plot("PTP.plot", "P", "x", std::nullopt) + .print(f); + auto [A, B] = t.least_squares_linear("lnTiT0", "DSi", std::nullopt, 0.1); + f64p Cv = A / nu; + std::cout var(nu) var(A) var(Cv); } @@ -77,7 +119,6 @@ void ex(void) { ex1(tables[3], "4"); ex2(tables[1]); ex3(tables[2]); - ex4(); } int main() { diff --git a/207/plots.gp b/207/plots.gp index f197258..09b2442 100644 --- a/207/plots.gp +++ b/207/plots.gp @@ -1,16 +1,84 @@ set term pngcairo size 1000, 800 set grid +f1(x) = a1*x +f2(x) = a2*x +f3(x) = a3*x+b3 +f4(x) = a4*x+b4 -#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 output 'ex4.png' +fit f1(x) 'DSilnViV0_Tconst1.plot' using 1:2 via a1 +fit f2(x) 'DSilnViV0_Tconst4.plot' using 1:2 via a2 + +set title "Зависимость при разных температурах" +set xlabel "ед." +set ylabel "S_i, Дж/К" + +plot 'DSilnViV0_Tconst1.plot' notitle lc 0 pt 1 lw 2, \ + f1(x) title " (T = 289 K)" lc rgb "magenta",\ + 'DSilnViV0_Tconst4.plot' notitle lc 0 pt 1 lw 2, \ + f2(x) title " (T = 3232.5 K)" lc rgb "red" + + +set output 'ex1.png' +unset label +set title "зависимости P(V), PV(V) в изотермическом процессе при разных температурах" +set xlabel "V, м^3" +set ylabel "P, Па" +set y2tics +set y2label "PV, Па * м^3" set key top left +set yrange[950:1200] +set y2range[35000:45000] + +plot 'PV1.plot' notitle axis x1y1 lc 0 pt 1 lw 2, \ + 'PV1.plot' with lines axis x1y1 smooth csplines title "P(V) (T = 289 K)" lc rgb "orange", \ + 'PVV1.plot' notitle axis x1y2 lc 0 pt 1 lw 2, \ + 'PVV1.plot' with lines axis x1y2 smooth csplines title "PV(V) (T = 289 K)" lc rgb "magenta", \ + 'PV4.plot' notitle axis x1y1 lc 0 pt 1 lw 2, \ + 'PV4.plot' with lines axis x1y1 smooth csplines title "P(V) (T = 323.5 K)" lc rgb "red", \ + 'PVV4.plot' notitle axis x1y2 lc 0 pt 1 lw 2, \ + 'PVV4.plot' with lines axis x1y2 smooth csplines title "PV(V) (T = 323.5 K)" lc rgb "green" + + +set output 'ex23_mnk.png' +fit f1(x) 'DSilnTiT0_Pconst.plot' using 1:2 via a1 +fit f2(x) 'DSilnTiT0_Vconst.plot' using 1:2 via a2 + +unset xrange +unset yrange +unset x2tics +unset y2label +unset y2range +set title "зависимости при P = const, V = const" +set xlabel "ед." +set ylabel "S_i, Дж/К" + +set label sprintf("(A)_P = %.4g\n (A)_V = %.4g", a1, a2) at graph 0.2, 0.9 front boxed +plot 'DSilnTiT0_Vconst.plot' notitle lc rgb "green" pt 1 lw 3,\ + 'DSilnTiT0_Pconst.plot' notitle lc rgb "magenta" pt 2 lw 3,\ + f2(x) title "V = const" lc rgb "green",\ + f1(x) title "P = const" lc rgb "magenta" +unset label + +set output 'ex2.png' +set title "Зависимость V/T от V при P = const" +set xlabel "V, м^3" +set ylabel "V/T, м^3/К" +set yrange[0.13:0.14] + +plot 'VTV.plot' notitle lc 0 pt 1 lw 2,\ + 'VTV.plot' title "V/T (V)" lc rgb "magenta" with lines smooth csplines + + + +set output 'ex3.png' -#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" +set title "Зависимость P/T (P) при V = const (по большей части)" +set xlabel "P, Па" +set ylabel "P/T, Па/K" +set yrange[3:3.2] +set xrange [980:1001] +plot 'PTP.plot' notitle lc 0 pt 1 lw 2,\ + 'PTP.plot' title "P/T (P)" lc rgb "magenta" with lines smooth path diff --git a/207/print.txt b/207/print.txt deleted file mode 100644 index 85be337..0000000 --- a/207/print.txt +++ /dev/null @@ -1,25 +0,0 @@ -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 | -|____________|____________|____________|____________|____________| - |