#include #include "include/praktable.hpp" #include "include/prakphys.hpp" using table = prak::table; using f64p = prak::pvalue; using f64v = std::vector; using vecarg = const std::vector &; using argvec = const std::vector &; void ex1(std::string file) { table t(file); f64 tmsgm = 1; t /*.multiply_column("t1", 1e-6) .multiply_column("t2", 1e-6) .multiply_column("t3", 1e-6)*/ .apply(prak::avg, {"t1", "t2", "t3"}, "t") .apply(prak::stddev, {"t1", "t2", "t3"}, "St") .apply([&](vecarg a) {return std::sqrt(a[0]*a[0] + tmsgm * tmsgm); }, "St", "st") .write_plot("ex1.plot", "L", "t", "st") .print(); auto [A, B] = t.least_squares_linear("L", "t", "st", std::nullopt); A = A * 1e-6; B = B * 1e-6; f64p v = 1.0 / A; std::cout var(A) var(B) var(v); } void ex2(std::string file) { table t(file); f64 L0 = 0.6, mu = 29e-3; t .apply(prak::add>, "t", "T") .apply([](vecarg a){ return std::sqrt(a[0]); }, "T", "sqrt(T)") .multiply_column("tau", 1e-6) .apply([&](vecarg a) { return L0 / a[0]; }, "tau", "v") .write_plot("ex2.plot", "sqrt(T)", "v", std::nullopt) .add_row({-273.15, 0, 0, 0, 0}) .print(); auto A = t.least_squares_prop("sqrt(T)", "v", std::nullopt, 0.01); f64p gamma = A * A * mu / prak::R; f64p Cv = prak::R / (gamma - 1.0), i = 2.0 / (gamma - 1.0); f64p tau = 1.2041 * Cv * t.col_avg("v") * t.col_avg("v") / 4.0 / 1e6 / 0.0259; std::cout var(L0) var(A) var(mu) var(gamma) var(Cv) var(i) var(tau); } int main() { ex1("data1"); ex2("data2"); return 0; }