1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;
}
|