aboutsummaryrefslogtreecommitdiffstats
path: root/110
diff options
context:
space:
mode:
Diffstat (limited to '110')
-rw-r--r--110/common4
-rw-r--r--110/common11
-rwxr-xr-x110/mainbin301936 -> 0 bytes
-rw-r--r--110/main.cpp101
-rw-r--r--110/plots.gp30
5 files changed, 112 insertions, 24 deletions
diff --git a/110/common b/110/common
index 75797ad..8888267 100644
--- a/110/common
+++ b/110/common
@@ -1,2 +1,2 @@
-R1 R2 x0_1 x2_1 x4_1 m1 R2_0 R2_1 m2_0 m2_1
-0.0194 0.0296 0.745 0 0.04 0.20145 0.0296 0.0194 0.20145 0.12977
+R1 R2 x0_1 x2_1 x4_1 m1 R2_0 R2_1 m2_0 m2_1 x0_2 x3_2 x4_2
+0.0194 0.0296 0.745 0 0.04 0.20145 0.0296 0.0194 0.20145 0.12977 0.76 0.76 0.1
diff --git a/110/common1 b/110/common1
deleted file mode 100644
index bd692b4..0000000
--- a/110/common1
+++ /dev/null
@@ -1 +0,0 @@
-R1 R2 x0 x2 m1 m2 x4
diff --git a/110/main b/110/main
deleted file mode 100755
index 2af817c..0000000
--- a/110/main
+++ /dev/null
Binary files differ
diff --git a/110/main.cpp b/110/main.cpp
index 3ce0d0b..6d6d6b1 100644
--- a/110/main.cpp
+++ b/110/main.cpp
@@ -4,8 +4,11 @@
using table = prak::table<double>;
using vecarg = const std::vector<f64> &;
+using f64p = prak::pvalue<f64>;
table data;
+const f64p g = {9.815710602, 0.001};
+
f64 get(std::string key) {
return data[key, 0];
}
@@ -15,27 +18,101 @@ f64 getsqrt(vecarg v) {
return std::sqrt(std::abs(get("x0_1") - v[0]));
}
-table prepare_ex1(std::string s) {
+f64 a_A(vecarg a) {
+ return 2/a[0]/a[0];
+}
+
+f64 J_mrga(vecarg a) {
+ return a[0] * a[1] * a[1] * (a[2]/a[3] + 1);
+}
+
+f64 ξ_x012(vecarg x) {
+ return (x[1] - x[0]) / (2*x[2] - x[0] - x[1]);
+}
+
+f64 Mfr_mgRξ(vecarg a) {
+ return a[0] * a[1] * a[2] * a[3];
+}
+
+f64 J_mrgtx034(vecarg a) {
+ return a[0]*a[1]*a[1]*(a[2]*a[3]*a[3] / 2 / std::pow(std::sqrt(std::abs(a[6]-a[4])) - std::sqrt(std::abs(a[5]-a[4])), 2) - 1);
+}
+
+table ex1(std::string s) {
table ret(s);
- ret.add_column("x1", std::vector<f64>(ret.rows, NAN));
- ret.add_column("t", std::vector<f64>(ret.rows, NAN));
- ret.add_column("st", std::vector<f64>(ret.rows, NAN));
- ret.add_column("sqrt", std::vector<f64>(ret.rows, NAN));
- ret .apply(prak::avg<f64>, {"x11", "x12", "x13"}, "x1")
+ ret.add_column("x1", std::vector<f64>(ret.rows, NAN))
+ .add_column("t", std::vector<f64>(ret.rows, NAN))
+ .add_column("st", std::vector<f64>(ret.rows, NAN))
+ .add_column("sqrt", std::vector<f64>(ret.rows, NAN))
+ .apply(prak::avg<f64>, {"x11", "x12", "x13"}, "x1")
.apply(prak::avg<f64>, {"t1", "t2", "t3"}, "t")
.apply(prak::stddev<f64>, {"t1", "t2", "t3"}, "st")
- .apply(getsqrt, {"x3"}, "sqrt");
-
- std::cout << ret;
+ .apply(getsqrt, {"x3"}, "sqrt")
+ .delete_cols({"x11", "x12", "x13", "t1", "t2", "t3"});
+ auto [A, B] = ret.least_squares_linear("sqrt", "t", "st", std::nullopt);
+
+ f64p m1 = {get("m1"), 0.00001},
+ R = {get("R1"), 0.00005},
+ x0 = {get("x0_1"), 0.01},
+ x1 = {ret.col_avg("x1"), ret.col_stddev("x1")},
+ x2 = {get("x2_1"), 0.01};
+
+ f64p a = prak::function<f64>(a_A, {A});
+ f64p J = prak::function<f64>(J_mrga, {m1, R, g, a});
+ f64p ξ = prak::function<f64>(ξ_x012, {x0, x1, x2});
+ f64p Mfr = prak::function<f64>(Mfr_mgRξ, {m1, g, R, ξ});
+ std::cout << ret
+ << "\na = " << a
+ << "\nJ = " << J
+ << "\nξ = " << ξ
+ << "\nМомент трения Mfr = " << Mfr
+ << std::endl;
return ret;
}
-void ex1(void) {
- table t;
+void ex2(std::string data) {
+ table table(data);
+ f64p R0 = {get("R2_0"), 0.00005},
+ R1 = {get("R2_1"), 0.00005},
+ m0 = {get("m2_0"), 0.00001},
+ m1 = {get("m2_1"), 0.00001},
+ x0 = {get("x0_2"), 0.01},
+ x3 = {get("x3_2"), 0.01},
+ x4 = {get("x4_2"), 0.01};
+
+ table .add_column("t", std::vector<f64>(table.rows, NAN))
+ .add_column("st", std::vector<f64>(table.rows, NAN))
+ .add_column("Ji", std::vector<f64>(table.rows, NAN))
+ .add_column("sJi", std::vector<f64>(table.rows, NAN))
+ .add_column("0", std::vector<f64>(table.rows, 0.0))
+ .apply(prak::avg<f64>, {"t1", "t2", "t3"}, "t")
+ .apply(prak::stddev<f64>, {"t1", "t2", "t3"}, "st")
+ .delete_cols({"t1", "t2", "t3"})
+ /* .apply([&R0, &R1](vecarg a) { return a[0] == 0 ? R0.val : R1.val; }, {"R"}, "R") */
+ /* .apply([&m0, &m1](vecarg a) { return a[0] == 0 ? m0.val : m1.val; }, {"M"}, "M") */
+ ;
+ for (size_t i = 0; i < table.rows; ++i) {
+ /* mrgtx034 */
+ std::vector<f64p> args = {
+ table["M", i] == 0 ? m0 : m1,
+ table["R", i] == 0 ? R0 : R1,
+ g, {table["t", i], table["st", i]},
+ // я проебался и только на первом измерении у меня x4 = 4см, на остальных 10см
+ x0, x3, table["M", i] == 0 && table["R", i] == 0 ? f64p{0.04, 0.01} : x4,
+ };
+ auto [val, err] = prak::function<f64>(J_mrgtx034, args);
+ table["Ji", i] = val;
+ table["sJi", i] = err;
+ }
+ table.write_plot("ex2_1.plot", "Ji", "0", "sJi");
+ table.multiply_column("sJi", 1 / std::sqrt(1 - 0.75));
+ table.write_plot("ex2_2.plot", "Ji", "0", "sJi");
+ std::cout << table;
}
int main() {
data = table("common");
- prepare_ex1("data1");
+ ex1("data1");
+ ex2("data2");
return 0;
}
diff --git a/110/plots.gp b/110/plots.gp
index 702408a..772accd 100644
--- a/110/plots.gp
+++ b/110/plots.gp
@@ -1,14 +1,26 @@
set term pngcairo size 1000, 800
-set tmargin at screen 0.95
+#set tmargin at screen 0.95
+set output 'compar.png'
+set title "Расположение J_i на оси J (пунктир: погрешность с коэффициентом доверия a=75%)"
-f1(x) = a1*x+b1
-fit f1(x) '.plot' using 1:2:3 yerr via a1, b1
+set multiplot layout 4,1
-set output ''
-set label "" at graph 0.5, graph 1.025 center
-set xlabel ""
-set ylabel ""
+set linetype 10 dashtype (5, 10)
-plot '.plot' using 1:2:3 with yerrorbars notitle lc 0 pt 1 lw 2, \
- f1(x) title "" lc rgb "red", \
+unset ytics
+unset xlabel
+
+set xrange[0.035:0.042]
+set yrange[-1:1]
+plot 'ex2_1.plot' every ::0::0 using 1:2:3 with xerrorbars title "J_1" lc 0 pt 1 lw 2,\
+ 'ex2_2.plot' every ::0::0 using 1:2:3 with xerrorbars title "J_{1_a}" lt 10 lc 0 pt 1 lw 2
+unset title
+plot 'ex2_1.plot' every ::1::1 using 1:2:3 with xerrorbars title "J_2" lc 0 pt 1 lw 2,\
+ 'ex2_2.plot' every ::1::1 using 1:2:3 with xerrorbars title "J_{2_a}" lt 10 lc 0 pt 1 lw 2
+plot 'ex2_1.plot' every ::2::2 using 1:2:3 with xerrorbars title "J_3" lc 0 pt 1 lw 2,\
+ 'ex2_2.plot' every ::2::2 using 1:2:3 with xerrorbars title "J_{3_a}" lt 10 lc 0 pt 1 lw 2
+set xlabel "J, кг*м^2"
+
+plot 'ex2_1.plot' every ::3::3 using 1:2:3 with xerrorbars title "J_4" lc 0 pt 1 lw 2,\
+ 'ex2_2.plot' every ::3::3 using 1:2:3 with xerrorbars title "J_{4_a}" lt 10 lc 0 pt 1 lw 2