diff options
Diffstat (limited to '206/main.cpp')
-rw-r--r-- | 206/main.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/206/main.cpp b/206/main.cpp new file mode 100644 index 0000000..8c94af3 --- /dev/null +++ b/206/main.cpp @@ -0,0 +1,51 @@ +#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); + f64 tmsgm = 1; + t /*.multiply_column("t1", 1e-6) + .multiply_column("t2", 1e-6) + .multiply_column("t3", 1e-6)*/ + .apply(prak::avg<f64>, {"t1", "t2", "t3"}, "t") + .apply(prak::stddev<f64>, {"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<f64, conv::C_to_K<f64>>, "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<f64>; + f64p Cv = prak::R<f64> / (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; +} |