-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatisticssampler.cpp
60 lines (48 loc) · 1.46 KB
/
statisticssampler.cpp
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
52
53
54
55
56
57
58
59
60
#include "system.h"
#include "statisticssampler.h"
#include "lennardjones.h"
#include <iostream>
using std::ofstream; using std::cout; using std::endl;
StatisticsSampler::StatisticsSampler()
{
}
void StatisticsSampler::saveToFile(System &system)
{
// Save the statistical properties for each timestep for plotting etc.
// First, open the file if it's not open already
if(!m_file.good()) {
m_file.open("statistics.txt", ofstream::out);
// If it's still not open, something bad happened...
if(!m_file.good()) {
cout << "Error, could not open statistics.txt" << endl;
exit(1);
}
}
// Print out values here
}
void StatisticsSampler::sample(System &system)
{
// Here you should measure different kinds of statistical properties and save it to a file.
sampleKineticEnergy(system);
samplePotentialEnergy(system);
sampleTemperature(system);
sampleDensity(system);
saveToFile(system);
}
void StatisticsSampler::sampleKineticEnergy(System &system)
{
m_kineticEnergy = 0; // Remember to reset the value from the previous timestep
for(Atom *atom : system.atoms()) {
}
}
void StatisticsSampler::samplePotentialEnergy(System &system)
{
m_potentialEnergy = system.potential().potentialEnergy();
}
void StatisticsSampler::sampleTemperature(System &system)
{
// Hint: reuse the kinetic energy that we already calculated
}
void StatisticsSampler::sampleDensity(System &system)
{
}