aboutsummaryrefslogtreecommitdiffstats
path: root/240/main.cpp
blob: 52af39642f6d26e42bd826ae5b8a3b7376c60bd9 (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
#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);
	t.apply([](argvec a){ return std::log(a[0]/a[1]); }, std::vector<std::string>{"dp1", "dp"}, "ln");
	t.write_plot("mnk.plot", "t", "ln", std::nullopt);
	auto [A, B] = t.least_squares_linear("t", "ln", std::nullopt, std::make_optional(0.1));
	f64p gamma = prak::function<f64>([](vecarg a) { return std::exp(a[0]) / (std::exp(a[0]) - 1); }, {B});
	f64p Cv = prak::R<f64> / (gamma - 1.0);
	f64p i = 2.0 * Cv / prak::R<f64>, Cp = Cv + prak::R<f64>;
	f64 m0 = 1.29 * 0.0127;
	f64p alpha = m0 * Cp * A, tau = 1.0 / A;
	std::cout << t var(A) var(B) var(gamma) var(Cv) var(i) var(m0) var(Cp) var(alpha) var(tau);
}

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