Line |
Branch |
Exec |
Source |
1 |
|
|
#pragma once |
2 |
|
|
|
3 |
|
|
#include <H5Cpp.h> |
4 |
|
|
#include <string> |
5 |
|
|
#include <unordered_map> |
6 |
|
|
#include <vector> |
7 |
|
|
#include <yaml-cpp/yaml.h> |
8 |
|
|
|
9 |
|
|
#include "integrator.hpp" |
10 |
|
|
#include "particle.hpp" |
11 |
|
|
#include "system.hpp" |
12 |
|
|
#include "types.hpp" |
13 |
|
|
|
14 |
|
|
struct Stage; |
15 |
|
|
class System; |
16 |
|
|
class Integrator; |
17 |
|
|
|
18 |
|
|
class Timeseries { |
19 |
|
|
public: |
20 |
|
|
inline static std::unordered_map<std::string, double (*)(System *s, Integrator *i)> functions = { |
21 |
|
|
{"weight", [](System *s, Integrator *i) -> double { return i->weight(); }}, |
22 |
|
|
{"E", [](System *s, Integrator *i) -> double { return s->E; }}, |
23 |
|
|
{"N", [](System *s, Integrator *i) -> double { return s->particles.size(); }}, |
24 |
|
|
{"Nupper", |
25 |
|
✗ |
[](System *s, Integrator *i) -> double { |
26 |
|
✗ |
int count = 0; |
27 |
|
✗ |
Vec &L = s->L; |
28 |
|
✗ |
const std::vector<Particle> &particles = s->particles; |
29 |
|
✗ |
double Lzhalf = L[DIM - 1] / 2; |
30 |
|
✗ |
for (const Particle &p : particles) { |
31 |
|
✗ |
if (p.r[DIM - 1] > Lzhalf) { |
32 |
|
✗ |
count++; |
33 |
|
|
} |
34 |
|
|
} |
35 |
|
✗ |
return count; |
36 |
|
|
}}, |
37 |
|
|
{"Nlower", |
38 |
|
✗ |
[](System *s, Integrator *i) -> double { |
39 |
|
✗ |
int count = 0; |
40 |
|
✗ |
Vec &L = s->L; |
41 |
|
✗ |
const std::vector<Particle> &particles = s->particles; |
42 |
|
✗ |
double Lzhalf = L[DIM - 1] / 2; |
43 |
|
✗ |
for (const Particle &p : particles) { |
44 |
|
✗ |
if (p.r[DIM - 1] <= Lzhalf) { |
45 |
|
✗ |
count++; |
46 |
|
|
} |
47 |
|
|
} |
48 |
|
✗ |
return count; |
49 |
|
|
}}, |
50 |
|
|
{"RSwM-rejections", |
51 |
|
|
[](System *s, Integrator *i) -> double { |
52 |
|
|
return static_cast<BrownianHeunEulerRSwM *>(i)->rejections; |
53 |
|
|
}}, |
54 |
|
|
{"RSwM-error", |
55 |
|
|
[](System *s, Integrator *i) -> double { |
56 |
|
|
return static_cast<BrownianHeunEulerRSwM *>(i)->error; |
57 |
|
|
}}, |
58 |
|
|
{"MonteCarlo-acceptRatio", |
59 |
|
|
[](System *s, Integrator *i) -> double { |
60 |
|
|
return static_cast<MonteCarlo *>(i)->acceptRatio; |
61 |
|
|
}}, |
62 |
|
|
{"NoseHoover-xi", |
63 |
|
|
[](System *s, Integrator *i) -> double { |
64 |
|
|
return static_cast<MolecularNoseHooverVelocityVerlet *>(i)->xi1; |
65 |
|
|
}}, |
66 |
|
|
}; |
67 |
|
|
|
68 |
|
|
Stage *stage; |
69 |
|
|
System *system; |
70 |
|
|
Integrator *integrator; |
71 |
|
|
std::vector<double> step; |
72 |
|
|
std::vector<double> time; |
73 |
|
|
std::vector<std::string> keys; |
74 |
|
|
std::unordered_map<std::string, std::vector<double>> data; |
75 |
|
|
|
76 |
|
|
Timeseries(System *system, Integrator *integrator, const YAML::Node &config); |
77 |
|
|
|
78 |
|
|
void record(); |
79 |
|
|
}; |
80 |
|
|
|