aboutsummaryrefslogtreecommitdiffstats
path: root/226/main.cpp
blob: 9584e601497d60b9ac49e14331cd683f1b7cdcdc (plain)
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
#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);
	t	.apply(prak::avg<f64>, {"T1", "T2", "T3"}, "T")
		.apply([](vecarg a){
			return std::sqrt(std::pow(prak::stddev<f64>({a[0], a[1], a[2]}), 2) 
				+ std::pow(prak::avg<f64>({a[3], a[4], a[5]}), 2)/3.0);
		}, {"T1", "T2", "T3", "sT1", "sT2", "sT3"}, "sT")
		.add_columns({"Tv", "sTv", "Te", "sTe"})
		.add_columns({"svpr", "sepr"}, 6e3)
		.multiply_column("vpr", 1e3)
		.multiply_column("epr", conv::eV_to_J<f64>)
		.apply_function([](vecarg a){return prak::m_e<f64> * a[0] * a[0] / (2 * prak::k<f64>);}, {"vpr"}, {"svpr"}, "Tv", "sTv")
		.apply_function([](vecarg a){return 2 * a[0] / prak::k<f64>;}, {"epr"}, {"sepr"}, "Te", "sTe")
		.delete_cols({"svpr", "sepr", "sTe"})
		.write_plot("T(U).plot", "U", "T", "sT")
		.write_plot("Tv(U).plot", "U", "Tv", "sTv")
		.print();
}

int main() {
	ex1("data");
	return 0;
}